Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 9 additions & 128 deletions Sources/HTMLKit/Abstraction/Attributes/BasicAttributes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import OrderedCollections

/// The alias combines the global attributes of the basic attributes.
@_documentation(visibility: internal)
public typealias GlobalAttributes = AccessKeyAttribute & AutocapitalizeAttribute & AutofocusAttribute & ClassAttribute & EditAttribute & DirectionAttribute & DragAttribute & EnterKeyAttribute & HiddenAttribute & InputModeAttribute & IsAttribute & ItemAttribute & ItemIdAttribute & ItemPropertyAttribute & ItemReferenceAttribute & ItemScopeAttribute & ItemTypeAttribute & IdentifierAttribute & LanguageAttribute & NonceAttribute & RoleAttribute & SpellCheckAttribute & StyleAttribute & TabulatorAttribute & TitleAttribute & TranslateAttribute & InertAttribute & PopoverAttribute
public typealias GlobalAttributes = AccessKeyAttribute & AutocapitalizeAttribute & AutofocusAttribute & ClassAttribute & EditAttribute & DirectionAttribute & DragAttribute & EnterKeyAttribute & HiddenAttribute & InputModeAttribute & IsAttribute & ItemAttribute & ItemPropertyAttribute & IdentifierAttribute & LanguageAttribute & NonceAttribute & RoleAttribute & SpellCheckAttribute & StyleAttribute & TabulatorAttribute & TitleAttribute & TranslateAttribute & InertAttribute & PopoverAttribute

/// A type that provides the `accessKey` modifier.
@_documentation(visibility: internal)
Expand Down Expand Up @@ -1680,6 +1680,10 @@ public protocol ItemAttribute: Attribute {

extension ItemAttribute where Self: ContentNode {

internal func mutate(itemscope value: String) -> Self {
return self.mutate(key: "itemscope", value: value)
}

internal func mutate(itemid value: String?) -> Self {

if let value = value {
Expand Down Expand Up @@ -1710,6 +1714,10 @@ extension ItemAttribute where Self: ContentNode {

extension ItemAttribute where Self: EmptyNode {

internal func mutate(itemscope value: String) -> Self {
return self.mutate(key: "itemscope", value: value)
}

internal func mutate(itemid value: String?) -> Self {

if let value = value {
Expand Down Expand Up @@ -1738,38 +1746,6 @@ extension ItemAttribute where Self: EmptyNode {
}
}

/// A type that provides the `itemId` modifier.
@_documentation(visibility: internal)
public protocol ItemIdAttribute: Attribute {

/// Set an unique identifier for an item.
///
/// ```swift
/// DefinitionList {
/// }
/// .itemId("urn:...")
/// ```
///
/// - Parameter value: The identifier to name the item after.
///
/// - Returns: The element
func itemId(_ value: String) -> Self
}

extension ItemIdAttribute where Self: ContentNode {

internal func mutate(itemid value: String) -> Self {
return self.mutate(key: "itemid", value: value)
}
}

extension ItemIdAttribute where Self: EmptyNode {

internal func mutate(itemid value: String) -> Self {
return self.mutate(key: "itemid", value: value)
}
}

/// A type that provides the `itemProperty` modifier.
@_documentation(visibility: internal)
public protocol ItemPropertyAttribute: Attribute {
Expand Down Expand Up @@ -1803,101 +1779,6 @@ extension ItemPropertyAttribute where Self: EmptyNode {
}
}

/// A type that provides the `itemReference` modifier.
@_documentation(visibility: internal)
public protocol ItemReferenceAttribute: Attribute {

/// Refer to other elements with additional item properties.
///
/// ```swift
/// DefinitionList {
/// }
/// .itemReference("foo bar")
/// ```
///
/// - Parameter value: The identifiers to relate to.
///
/// - Returns: The element
func itemReference(_ value: String) -> Self
}

extension ItemReferenceAttribute where Self: ContentNode {

internal func mutate(itemref value: String) -> Self {
return self.mutate(key: "itemref", value: value)
}
}

extension ItemReferenceAttribute where Self: EmptyNode {

internal func mutate(itemref value: String) -> Self {
return self.mutate(key: "itemref", value: value)
}
}

/// A type that provides the `itemScope` modifier.
@_documentation(visibility: internal)
public protocol ItemScopeAttribute: Attribute {

/// Create a new item scope.
///
/// ```swift
/// DefinitionList {
/// "Lorem ipsum..."
/// }
/// .itemScope()
/// ```
///
/// - Returns: The element
func itemScope(_ value: String) -> Self
}

extension ItemScopeAttribute where Self: ContentNode {

internal func mutate(itemscope value: String) -> Self {
return self.mutate(key: "itemscope", value: value)
}
}

extension ItemScopeAttribute where Self: EmptyNode {

internal func mutate(itemscope value: String) -> Self {
return self.mutate(key: "itemscope", value: value)
}
}

/// A type that provides the `itemType` modifier.
@_documentation(visibility: internal)
public protocol ItemTypeAttribute: Attribute {

/// Refer to an item vocabulary.
///
/// ```swift
/// DefintionList {
/// }
/// .itemType("https://...")
/// ```
///
/// - Parameter url: The url of the vocabulary to use.
///
/// - Returns: The element
func itemType(_ url: String) -> Self
}

extension ItemTypeAttribute where Self: ContentNode {

internal func mutate(itemtype value: String) -> Self {
return self.mutate(key: "itemtype", value: value)
}
}

extension ItemTypeAttribute where Self: EmptyNode {

internal func mutate(itemtype value: String) -> Self {
return self.mutate(key: "itemtype", value: value)
}
}

/// A type that provides the `kind` modifier.
@_documentation(visibility: internal)
public protocol KindAttribute: Attribute {
Expand Down
13 changes: 4 additions & 9 deletions Sources/HTMLKit/Abstraction/Elements/BasicElements.swift
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,6 @@ extension Html: GlobalAttributes, GlobalEventAttributes {

return self
}

@available(*, unavailable, message: "Use the inputMode(_:) modifier instead.")
public func inputMode(_ value: String) -> Html {
return mutate(inputmode: value)
}

public func inputMode(_ value: Values.Mode) -> Html {
return mutate(inputmode: value.rawValue)
Expand All @@ -185,7 +180,7 @@ extension Html: GlobalAttributes, GlobalEventAttributes {
return self.mutate(itemscope: "itemscope").mutate(itemid: id).mutate(itemtype: schema?.absoluteString).mutate(itemref: elements.joined(separator: " "))
}

@available(*, deprecated, message: "Use the item(id:as:for:) modifier instead.")
@available(*, unavailable, message: "Use the item(id:as:for:) modifier instead.")
public func itemId(_ value: String) -> Html {
return mutate(itemid: value)
}
Expand All @@ -194,17 +189,17 @@ extension Html: GlobalAttributes, GlobalEventAttributes {
return mutate(itemprop: value)
}

@available(*, deprecated, message: "Use the item(id:as:for:) modifier instead.")
@available(*, unavailable, message: "Use the item(id:as:for:) modifier instead.")
public func itemReference(_ value: String) -> Html {
return mutate(itemref: value)
}

@available(*, deprecated, message: "Use the item(id:as:for:) modifier instead.")
@available(*, unavailable, message: "Use the item(id:as:for:) modifier instead.")
public func itemScope(_ value: String) -> Html {
return mutate(itemscope: value)
}

@available(*, deprecated, message: "Use the item(id:as:for:) modifier instead.")
@available(*, unavailable, message: "Use the item(id:as:for:) modifier instead.")
public func itemType(_ value: String) -> Html {
return mutate(itemtype: value)
}
Expand Down
Loading