From 59879660b81b7df3eef49e9d8f2894c672080c56 Mon Sep 17 00:00:00 2001 From: Mattes Mohr Date: Mon, 16 Oct 2023 22:14:16 +0200 Subject: [PATCH] Upgrade the package (#142) * Make some of the components identifiable * Add center as an option for the content space * Revise some css * Make actions exclusive * Fix some css * Fix the test from failing The encoder doesn't keep the order of the keys. Therefore I revised the part to a simple text representation. It is okay for the time being. But later on, with more complex validators, it needs to be changed. * Revise the carousel component * Introduce the recently added search element * Introduce the recently added menu element * Update some of the value tokens accordingly to the latest html standard * Introduce the inert attribute * Introduce the fetchpriority attribute * Introduce the loading attribute * Introduce the sourceset attribute * Introduce the decoding attribute * Introduce the recently added blocking attribute * Introduce the recently added popover attribute * Introduce the recently added popovertarget attribute * Introduce the recently added popovertargetaction attribute --- .../Attributes/BasicAttributes.swift | 221 ++- .../Abstraction/Elements/BasicElements.swift | 17 + .../Abstraction/Elements/BodyElements.swift | 1696 ++++++++++++++++- .../Elements/DefinitionElements.swift | 34 + .../Abstraction/Elements/FigureElements.swift | 17 + .../Abstraction/Elements/FormElements.swift | 122 +- .../Abstraction/Elements/HeadElements.swift | 101 +- .../Abstraction/Elements/HtmlElements.swift | 34 + .../Abstraction/Elements/InputElements.swift | 68 + .../Abstraction/Elements/ListElements.swift | 17 + .../Abstraction/Elements/MapElements.swift | 19 +- .../Abstraction/Elements/MediaElements.swift | 40 +- .../Abstraction/Elements/ObjectElements.swift | 17 + .../Abstraction/Elements/RubyElements.swift | 34 + .../Abstraction/Elements/TableElements.swift | 153 ++ .../Abstraction/Tokens/ValueTokens.swift | 102 +- .../Actions/SubmitAction.swift | 28 +- .../Actions/ViewAction.swift | 70 +- .../Builders/ActionBuilder.swift | 7 + .../Builders/StringBuilder.swift | 7 - .../HTMLKitComponents/Components/Button.swift | 39 +- .../HTMLKitComponents/Components/Card.swift | 14 +- .../Components/Carousel.swift | 161 +- .../Components/Dropdown.swift | 14 +- .../HTMLKitComponents/Components/Form.swift | 181 +- .../HTMLKitComponents/Components/Grid.swift | 16 +- .../Components/Grouping.swift | 14 +- .../HTMLKitComponents/Components/Image.swift | 14 +- .../HTMLKitComponents/Components/Link.swift | 14 +- .../HTMLKitComponents/Components/List.swift | 32 +- .../HTMLKitComponents/Components/Modal.swift | 2 +- .../Components/Navigation.swift | 14 +- .../Components/Snippet.swift | 14 +- .../HTMLKitComponents/Components/Stack.swift | 48 +- .../HTMLKitComponents/Components/Text.swift | 39 +- .../HTMLKitComponents/Events/DragEvent.swift | 14 +- .../HTMLKitComponents/Events/FormEvent.swift | 10 +- .../HTMLKitComponents/Events/MouseEvent.swift | 14 +- .../HTMLKitComponents/Events/PressEvent.swift | 20 +- .../HTMLKitComponents/Primitives/Action.swift | 11 + .../Properties/Identifiable.swift | 2 +- .../Resources/css/globals.css | 42 +- .../Resources/css/layout/grid.css | 7 + .../Resources/css/layout/list.css | 3 + .../Resources/css/layout/stack.css | 17 + .../Resources/css/typography/link.css | 2 +- .../Resources/css/views/carousel.css | 85 +- .../Resources/css/views/divider.css | 3 +- .../Resources/css/views/dropdown.css | 2 +- .../Resources/css/views/image.css | 7 +- .../Resources/css/views/navigation.css | 18 +- .../Resources/css/views/scrollview.css | 2 + .../Resources/css/views/snippet.css | 4 +- Sources/HTMLKitComponents/Tokens.swift | 5 +- Sources/HTMLKitConverter/Parser.swift | 33 + .../ComponentTests.swift | 54 +- .../InteractionTests.swift | 24 +- .../ModifierTests.swift | 2 +- Tests/HTMLKitTests/AttributesTests.swift | 171 +- Tests/HTMLKitTests/ElementTests.swift | 26 + 60 files changed, 3550 insertions(+), 448 deletions(-) create mode 100644 Sources/HTMLKitComponents/Builders/ActionBuilder.swift delete mode 100644 Sources/HTMLKitComponents/Builders/StringBuilder.swift create mode 100644 Sources/HTMLKitComponents/Primitives/Action.swift diff --git a/Sources/HTMLKit/Abstraction/Attributes/BasicAttributes.swift b/Sources/HTMLKit/Abstraction/Attributes/BasicAttributes.swift index 87310709..b0864d10 100644 --- a/Sources/HTMLKit/Abstraction/Attributes/BasicAttributes.swift +++ b/Sources/HTMLKit/Abstraction/Attributes/BasicAttributes.swift @@ -9,7 +9,7 @@ import OrderedCollections /// The alias combines the global attributes of the basic attributes. -public typealias GlobalAttributes = AccessKeyAttribute & AutocapitalizeAttribute & AutofocusAttribute & ClassAttribute & EditAttribute & DirectionAttribute & DragAttribute & EnterKeyHintAttribute & HiddenAttribute & InputModeAttribute & IsAttribute & ItemIdAttribute & ItemPropertyAttribute & ItemReferenceAttribute & ItemScopeAttribute & ItemTypeAttribute & IdentifierAttribute & LanguageAttribute & NonceAttribute & RoleAttribute & SpellCheckAttribute & StyleAttribute & TabulatorAttribute & TitleAttribute & TranslateAttribute +public typealias GlobalAttributes = AccessKeyAttribute & AutocapitalizeAttribute & AutofocusAttribute & ClassAttribute & EditAttribute & DirectionAttribute & DragAttribute & EnterKeyHintAttribute & HiddenAttribute & InputModeAttribute & IsAttribute & ItemIdAttribute & ItemPropertyAttribute & ItemReferenceAttribute & ItemScopeAttribute & ItemTypeAttribute & IdentifierAttribute & LanguageAttribute & NonceAttribute & RoleAttribute & SpellCheckAttribute & StyleAttribute & TabulatorAttribute & TitleAttribute & TranslateAttribute & InertAttribute & PopoverAttribute /// The protocol provides the element with the accesskey handler. public protocol AccessKeyAttribute: Attribute { @@ -2662,3 +2662,222 @@ extension ShadowRootModeAttribute where Self: ContentNode { return self.mutate(key: "shadowrootmode", value: value) } } + +/// The protocol provides the element with inhert handler. +public protocol InertAttribute: Attribute { + + /// The function represents the html-attribute 'inert'. + /// + /// ```html + /// + /// ``` + func inert() -> Self + + func inert(_ condition: Bool) -> Self +} + +extension InertAttribute where Self: ContentNode { + + internal func mutate(inert value: String) -> Self { + return self.mutate(key: "inert", value: value) + } +} + +extension InertAttribute where Self: EmptyNode { + + internal func mutate(inert value: String) -> Self { + return self.mutate(key: "inert", value: value) + } +} + +public protocol FetchPriorityAttribute: Attribute { + + /// The function represents the html-attribute 'shadowrootmode'. + /// + /// ```html + /// + /// ``` + func fetchPriority(_ value: Values.Priority) -> Self +} + +extension FetchPriorityAttribute where Self: ContentNode { + + internal func mutate(fetchpriority value: String) -> Self { + return self.mutate(key: "fetchpriority", value: value) + } +} + +extension FetchPriorityAttribute where Self: EmptyNode { + + internal func mutate(fetchpriority value: String) -> Self { + return self.mutate(key: "fetchpriority", value: value) + } +} + +public protocol LoadingAttribute: Attribute { + + /// The function represents the html-attribute 'loading'. + /// + /// ```html + /// + /// ``` + func loading(_ value: Values.Loading) -> Self +} + +extension LoadingAttribute where Self: ContentNode { + + internal func mutate(loading value: String) -> Self { + return self.mutate(key: "loading", value: value) + } +} + +extension LoadingAttribute where Self: EmptyNode { + + internal func mutate(loading value: String) -> Self { + return self.mutate(key: "loading", value: value) + } +} + +public protocol SourceSetAttribute: Attribute { + + /// The function represents the html-attribute 'loading'. + /// + /// ```html + /// + /// ``` + func sourceSet(_ value: String) -> Self +} + +extension SourceSetAttribute where Self: ContentNode { + + internal func mutate(sourceset value: String) -> Self { + return self.mutate(key: "srcset", value: value) + } +} + +extension SourceSetAttribute where Self: EmptyNode { + + internal func mutate(sourceset value: String) -> Self { + return self.mutate(key: "srcset", value: value) + } +} + +public protocol DecodingAttribute: Attribute { + + /// The function represents the html-attribute 'decoding'. + /// + /// ```html + /// + /// ``` + func decoding(_ value: Values.Decoding) -> Self +} + +extension DecodingAttribute where Self: ContentNode { + + internal func mutate(decoding value: String) -> Self { + return self.mutate(key: "decoding", value: value) + } +} + +extension DecodingAttribute where Self: EmptyNode { + + internal func mutate(decoding value: String) -> Self { + return self.mutate(key: "decoding", value: value) + } +} + +public protocol BlockingAttribute: Attribute { + + /// The function represents the html-attribute 'blocking'. + /// + /// ```html + /// + /// ``` + func blocking(_ value: Values.Blocking) -> Self +} + +extension BlockingAttribute where Self: ContentNode { + + internal func mutate(blocking value: String) -> Self { + return self.mutate(key: "blocking", value: value) + } +} + +extension BlockingAttribute where Self: EmptyNode { + + internal func mutate(blocking value: String) -> Self { + return self.mutate(key: "blocking", value: value) + } +} + +public protocol PopoverAttribute: Attribute { + + /// The function represents the html-attribute 'popover'. + /// + /// ```html + /// + /// ``` + func popover(_ value: Values.Popover.State) -> Self +} + +extension PopoverAttribute where Self: ContentNode { + + internal func mutate(popover value: String) -> Self { + return self.mutate(key: "popover", value: value) + } +} + +extension PopoverAttribute where Self: EmptyNode { + + internal func mutate(popover value: String) -> Self { + return self.mutate(key: "popover", value: value) + } +} + +public protocol PopoverTargetAttribute: Attribute { + + /// The function represents the html-attribute 'popovertarget'. + /// + /// ```html + /// + /// ``` + func popoverTarget(_ value: String) -> Self +} + +extension PopoverAttribute where Self: ContentNode { + + internal func mutate(popovertarget value: String) -> Self { + return self.mutate(key: "popovertarget", value: value) + } +} + +extension PopoverAttribute where Self: EmptyNode { + + internal func mutate(popovertarget value: String) -> Self { + return self.mutate(key: "popovertarget", value: value) + } +} + +public protocol PopoverActionAttribute: Attribute { + + /// The function represents the html-attribute 'popovertargetaction'. + /// + /// ```html + /// + /// ``` + func popoverAction(_ value: Values.Popover.Action) -> Self +} + +extension PopoverAttribute where Self: ContentNode { + + internal func mutate(popoveraction value: String) -> Self { + return self.mutate(key: "popovertargetaction", value: value) + } +} + +extension PopoverAttribute where Self: EmptyNode { + + internal func mutate(popoveraction value: String) -> Self { + return self.mutate(key: "popovertargetaction", value: value) + } +} diff --git a/Sources/HTMLKit/Abstraction/Elements/BasicElements.swift b/Sources/HTMLKit/Abstraction/Elements/BasicElements.swift index 1611ed7c..47b1c9f3 100644 --- a/Sources/HTMLKit/Abstraction/Elements/BasicElements.swift +++ b/Sources/HTMLKit/Abstraction/Elements/BasicElements.swift @@ -188,6 +188,23 @@ extension Html: GlobalAttributes, GlobalEventAttributes { return mutate(translate: value.rawValue) } + public func inert() -> Html { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Html { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Html { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Html { return mutate(key: key, value: value) } diff --git a/Sources/HTMLKit/Abstraction/Elements/BodyElements.swift b/Sources/HTMLKit/Abstraction/Elements/BodyElements.swift index e645db17..69333203 100644 --- a/Sources/HTMLKit/Abstraction/Elements/BodyElements.swift +++ b/Sources/HTMLKit/Abstraction/Elements/BodyElements.swift @@ -484,6 +484,23 @@ extension Article: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes return mutate(translate: value.rawValue) } + public func inert() -> Article { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Article { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Article { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Article { return mutate(key: key, value: value) } @@ -737,6 +754,23 @@ extension Section: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes return mutate(translate: value.rawValue) } + public func inert() -> Section { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Section { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Section { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Section { return mutate(key: key, value: value) } @@ -990,6 +1024,23 @@ extension Navigation: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribu return mutate(translate: value.rawValue) } + public func inert() -> Navigation { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Navigation { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Navigation { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Navigation { return mutate(key: key, value: value) } @@ -1243,6 +1294,23 @@ extension Aside: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes { return mutate(translate: value.rawValue) } + public func inert() -> Aside { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Aside { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Aside { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Aside { return mutate(key: key, value: value) } @@ -1496,6 +1564,23 @@ extension Heading1: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribute return mutate(translate: value.rawValue) } + public func inert() -> Heading1 { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Heading1 { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Heading1 { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Heading1 { return mutate(key: key, value: value) } @@ -1756,6 +1841,23 @@ extension Heading2: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribute return mutate(translate: value.rawValue) } + public func inert() -> Heading2 { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Heading2 { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Heading2 { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Heading2 { return mutate(key: key, value: value) } @@ -2016,6 +2118,23 @@ extension Heading3: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribute return mutate(translate: value.rawValue) } + public func inert() -> Heading3 { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Heading3 { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Heading3 { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Heading3 { return mutate(key: key, value: value) } @@ -2276,6 +2395,23 @@ extension Heading4: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribute return mutate(translate: value.rawValue) } + public func inert() -> Heading4 { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Heading4 { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Heading4 { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Heading4 { return mutate(key: key, value: value) } @@ -2536,6 +2672,23 @@ extension Heading5: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribute return mutate(translate: value.rawValue) } + public func inert() -> Heading5 { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Heading5 { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Heading5 { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Heading5 { return mutate(key: key, value: value) } @@ -2796,6 +2949,23 @@ extension Heading6: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribute return mutate(translate: value.rawValue) } + public func inert() -> Heading6 { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Heading6 { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Heading6 { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Heading6 { return mutate(key: key, value: value) } @@ -3056,6 +3226,23 @@ extension HeadingGroup: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttri return mutate(translate: value.rawValue) } + public func inert() -> HeadingGroup { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> HeadingGroup { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> HeadingGroup { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> HeadingGroup { return mutate(key: key, value: value) } @@ -3309,6 +3496,23 @@ extension Header: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes return mutate(translate: value.rawValue) } + public func inert() -> Header { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Header { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Header { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Header { return mutate(key: key, value: value) } @@ -3562,6 +3766,23 @@ extension Footer: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes return mutate(translate: value.rawValue) } + public func inert() -> Footer { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Footer { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Footer { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Footer { return mutate(key: key, value: value) } @@ -3815,6 +4036,23 @@ extension Address: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes return mutate(translate: value.rawValue) } + public func inert() -> Address { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Address { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Address { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Address { return mutate(key: key, value: value) } @@ -4068,6 +4306,23 @@ extension Paragraph: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribut return mutate(translate: value.rawValue) } + public func inert() -> Paragraph { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Paragraph { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Paragraph { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Paragraph { return mutate(key: key, value: value) } @@ -4323,6 +4578,23 @@ extension HorizontalRule: GlobalAttributes, GlobalEventAttributes, GlobalAriaAtt return mutate(translate: value.rawValue) } + public func inert() -> HorizontalRule { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> HorizontalRule { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> HorizontalRule { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> HorizontalRule { return mutate(key: key, value: value) } @@ -4576,6 +4848,23 @@ extension PreformattedText: GlobalAttributes, GlobalEventAttributes, GlobalAriaA return mutate(translate: value.rawValue) } + public func inert() -> PreformattedText { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> PreformattedText { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> PreformattedText { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> PreformattedText { return mutate(key: key, value: value) } @@ -4829,10 +5118,27 @@ extension Blockquote: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribu return mutate(translate: value.rawValue) } + public func inert() -> Blockquote { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Blockquote { + + if condition { + return mutate(inert: "inert") + } + + return self + } + public func cite(_ value: String) -> Blockquote { return mutate(cite: value) } + public func popover(_ value: Values.Popover.State) -> Blockquote { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Blockquote { return mutate(key: key, value: value) } @@ -5092,6 +5398,19 @@ extension OrderedList: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttrib public func translate(_ value: Values.Decision) -> OrderedList { return mutate(translate: value.rawValue) } + + public func inert() -> OrderedList { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> OrderedList { + + if condition { + return mutate(inert: "inert") + } + + return self + } public func reversed() -> OrderedList { return mutate(reversed: "reversed") @@ -5105,6 +5424,10 @@ extension OrderedList: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttrib return mutate(type: value) } + public func popover(_ value: Values.Popover.State) -> OrderedList { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> OrderedList { return mutate(key: key, value: value) } @@ -5358,6 +5681,23 @@ extension UnorderedList: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttr return mutate(translate: value.rawValue) } + public func inert() -> UnorderedList { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> UnorderedList { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> UnorderedList { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> UnorderedList { return mutate(key: key, value: value) } @@ -5459,29 +5799,29 @@ extension UnorderedList: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttr } } -/// The element defines a list of terms and corresponding definitions. +/// The element represents a list of items, each of represents a command the user can perform. /// /// ```html -///
+/// /// ``` -public struct DescriptionList: ContentNode, HtmlElement, BodyElement, FormElement, FigureElement, ObjectElement { - - internal var name: String { "dl" } +public struct Menu: ContentNode, HtmlElement, BodyElement { + + internal var name: String { "menu" } internal var attributes: OrderedDictionary? - internal var content: [DescriptionElement] + internal var content: [ListElement] - public init(@ContentBuilder content: () -> [DescriptionElement]) { + public init(@ContentBuilder content: () -> [ListElement]) { self.content = content() } - internal init(attributes: OrderedDictionary?, content: [DescriptionElement]) { + internal init(attributes: OrderedDictionary?, content: [ListElement]) { self.attributes = attributes self.content = content } - public func modify(if condition: Bool, element: (DescriptionList) -> DescriptionList) -> DescriptionList { + public func modify(if condition: Bool, element: (Menu) -> Menu) -> Menu { if condition { return self.modify(element(self)) @@ -5490,7 +5830,7 @@ public struct DescriptionList: ContentNode, HtmlElement, BodyElement, FormElemen return self } - public func modify(unwrap value: T?, element: (DescriptionList, T) -> DescriptionList) -> DescriptionList { + public func modify(unwrap value: T?, element: (Menu, T) -> Menu) -> Menu { guard let value = value else { return self @@ -5500,37 +5840,211 @@ public struct DescriptionList: ContentNode, HtmlElement, BodyElement, FormElemen } } -extension DescriptionList: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes { +extension Menu: GlobalAttributes { - public func accessKey(_ value: Character) -> DescriptionList { + public func accessKey(_ value: Character) -> Menu { return mutate(accesskey: value) } - - public func autocapitalize(_ value: Values.Capitalization) -> DescriptionList { + + public func autocapitalize(_ value: Values.Capitalization) -> Menu { return mutate(autocapitalize: value.rawValue) } - - public func autofocus() -> DescriptionList { + + public func autofocus() -> Menu { return mutate(autofocus: "autofocus") } - - public func `class`(_ value: String) -> DescriptionList { + + public func `class`(_ value: String) -> Menu { return mutate(class: value) } - - public func isEditable(_ value: Bool) -> DescriptionList { + + public func isEditable(_ value: Bool) -> Menu { return mutate(contenteditable: value) } - - public func direction(_ value: Values.Direction) -> DescriptionList { + + public func direction(_ value: Values.Direction) -> Menu { return mutate(dir: value.rawValue) } - - public func isDraggable(_ value: Bool) -> DescriptionList { + + public func isDraggable(_ value: Bool) -> Menu { return mutate(draggable: value) } - - public func enterKeyHint(_ value: Values.Hint) -> DescriptionList { + + public func enterKeyHint(_ value: Values.Hint) -> Menu { + return mutate(enterkeyhint: value.rawValue) + } + + public func hidden() -> Menu { + return mutate(hidden: "hidden") + } + + public func hidden(_ condition: Bool) -> Menu { + + if condition { + return mutate(hidden: "hidden") + } + + return self + } + + public func inputMode(_ value: String) -> Menu { + return mutate(inputmode: value) + } + + public func `is`(_ value: String) -> Menu { + return mutate(is: value) + } + + public func itemId(_ value: String) -> Menu { + return mutate(itemid: value) + } + + public func itemProperty(_ value: String) -> Menu { + return mutate(itemprop: value) + } + + public func itemReference(_ value: String) -> Menu { + return mutate(itemref: value) + } + + public func itemScope(_ value: String) -> Menu { + return mutate(itemscope: value) + } + + public func itemType(_ value: String) -> Menu { + return mutate(itemtype: value) + } + + public func id(_ value: String) -> Menu { + return mutate(id: value) + } + + public func language(_ value: Values.Language) -> Menu { + return mutate(lang: value.rawValue) + } + + public func nonce(_ value: String) -> Menu { + return mutate(nonce: value) + } + + public func role(_ value: Values.Role) -> Menu { + return mutate(role: value.rawValue) + } + + public func hasSpellCheck(_ value: Bool) -> Menu { + return mutate(spellcheck: value) + } + + public func style(_ value: String) -> Menu { + return mutate(style: value) + } + + public func tabIndex(_ value: Int) -> Menu { + return mutate(tabindex: value) + } + + public func title(_ value: String) -> Menu { + return mutate(title: value) + } + + public func translate(_ value: Values.Decision) -> Menu { + return mutate(translate: value.rawValue) + } + + public func inert() -> Menu { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Menu { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Menu { + return mutate(popover: value.rawValue) + } + + public func custom(key: String, value: Any) -> Menu { + return mutate(key: key, value: value) + } +} + +/// The element defines a list of terms and corresponding definitions. +/// +/// ```html +///
+/// ``` +public struct DescriptionList: ContentNode, HtmlElement, BodyElement, FormElement, FigureElement, ObjectElement { + + internal var name: String { "dl" } + + internal var attributes: OrderedDictionary? + + internal var content: [DescriptionElement] + + public init(@ContentBuilder content: () -> [DescriptionElement]) { + self.content = content() + } + + internal init(attributes: OrderedDictionary?, content: [DescriptionElement]) { + self.attributes = attributes + self.content = content + } + + public func modify(if condition: Bool, element: (DescriptionList) -> DescriptionList) -> DescriptionList { + + if condition { + return self.modify(element(self)) + } + + return self + } + + public func modify(unwrap value: T?, element: (DescriptionList, T) -> DescriptionList) -> DescriptionList { + + guard let value = value else { + return self + } + + return self.modify(element(self, value as T)) + } +} + +extension DescriptionList: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes { + + public func accessKey(_ value: Character) -> DescriptionList { + return mutate(accesskey: value) + } + + public func autocapitalize(_ value: Values.Capitalization) -> DescriptionList { + return mutate(autocapitalize: value.rawValue) + } + + public func autofocus() -> DescriptionList { + return mutate(autofocus: "autofocus") + } + + public func `class`(_ value: String) -> DescriptionList { + return mutate(class: value) + } + + public func isEditable(_ value: Bool) -> DescriptionList { + return mutate(contenteditable: value) + } + + public func direction(_ value: Values.Direction) -> DescriptionList { + return mutate(dir: value.rawValue) + } + + public func isDraggable(_ value: Bool) -> DescriptionList { + return mutate(draggable: value) + } + + public func enterKeyHint(_ value: Values.Hint) -> DescriptionList { return mutate(enterkeyhint: value.rawValue) } @@ -5611,6 +6125,23 @@ extension DescriptionList: GlobalAttributes, GlobalEventAttributes, GlobalAriaAt return mutate(translate: value.rawValue) } + public func inert() -> DescriptionList { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> DescriptionList { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> DescriptionList { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> DescriptionList { return mutate(key: key, value: value) } @@ -5864,6 +6395,23 @@ extension Figure: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes return mutate(translate: value.rawValue) } + public func inert() -> Figure { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Figure { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Figure { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Figure { return mutate(key: key, value: value) } @@ -6117,6 +6665,19 @@ extension Anchor: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, return mutate(translate: value.rawValue) } + public func inert() -> Anchor { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Anchor { + + if condition { + return mutate(inert: "inert") + } + + return self + } + public func download() -> Anchor { return mutate(download: "download") } @@ -6153,6 +6714,10 @@ extension Anchor: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, return mutate(type: value) } + public func popover(_ value: Values.Popover.State) -> Anchor { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Anchor { return mutate(key: key, value: value) } @@ -6413,6 +6978,23 @@ extension Emphasize: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribut return mutate(translate: value.rawValue) } + public func inert() -> Emphasize { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Emphasize { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Emphasize { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Emphasize { return mutate(key: key, value: value) } @@ -6666,6 +7248,23 @@ extension Strong: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes return mutate(translate: value.rawValue) } + public func inert() -> Strong { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Strong { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Strong { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Strong { return mutate(key: key, value: value) } @@ -6919,6 +7518,23 @@ extension Small: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes { return mutate(translate: value.rawValue) } + public func inert() -> Small { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Small { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Small { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Small { return mutate(key: key, value: value) } @@ -7179,6 +7795,23 @@ extension StrikeThrough: GlobalAttributes, GlobalEventAttributes { return mutate(translate: value.rawValue) } + public func inert() -> StrikeThrough { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> StrikeThrough { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> StrikeThrough { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> StrikeThrough { return mutate(key: key, value: value) } @@ -7363,6 +7996,23 @@ extension Main: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes { return mutate(translate: value.rawValue) } + public func inert() -> Main { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Main { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Main { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Main { return mutate(key: key, value: value) } @@ -7464,6 +8114,180 @@ extension Main: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes { } } +/// The element represents a part that contains a set of controls to performing a search. +/// +/// ```html +/// +/// ``` +public struct Search: ContentNode, HtmlElement, BodyElement { + + internal var name: String { "search" } + + internal var attributes: OrderedDictionary? + + internal var content: [Content] + + public init(@ContentBuilder content: () -> [Content]) { + self.content = content() + } + + internal init(attributes: OrderedDictionary?, content: [Content]) { + self.attributes = attributes + self.content = content + } + + public func modify(if condition: Bool, element: (Search) -> Search) -> Search { + + if condition { + return self.modify(element(self)) + } + + return self + } + + public func modify(unwrap value: T?, element: (Search, T) -> Search) -> Search { + + guard let value = value else { + return self + } + + return self.modify(element(self, value as T)) + } +} + +extension Search: GlobalAttributes { + + public func accessKey(_ value: Character) -> Search { + return mutate(accesskey: value) + } + + public func autocapitalize(_ value: Values.Capitalization) -> Search { + return mutate(autocapitalize: value.rawValue) + } + + public func autofocus() -> Search { + return mutate(autofocus: "autofocus") + } + + public func `class`(_ value: String) -> Search { + return mutate(class: value) + } + + public func isEditable(_ value: Bool) -> Search { + return mutate(contenteditable: value) + } + + public func direction(_ value: Values.Direction) -> Search { + return mutate(dir: value.rawValue) + } + + public func isDraggable(_ value: Bool) -> Search { + return mutate(draggable: value) + } + + public func enterKeyHint(_ value: Values.Hint) -> Search { + return mutate(enterkeyhint: value.rawValue) + } + + public func hidden() -> Search { + return mutate(hidden: "hidden") + } + + public func hidden(_ condition: Bool) -> Search { + + if condition { + return mutate(hidden: "hidden") + } + + return self + } + + public func inputMode(_ value: String) -> Search { + return mutate(inputmode: value) + } + + public func `is`(_ value: String) -> Search { + return mutate(is: value) + } + + public func itemId(_ value: String) -> Search { + return mutate(itemid: value) + } + + public func itemProperty(_ value: String) -> Search { + return mutate(itemprop: value) + } + + public func itemReference(_ value: String) -> Search { + return mutate(itemref: value) + } + + public func itemScope(_ value: String) -> Search { + return mutate(itemscope: value) + } + + public func itemType(_ value: String) -> Search { + return mutate(itemtype: value) + } + + public func id(_ value: String) -> Search { + return mutate(id: value) + } + + public func language(_ value: Values.Language) -> Search { + return mutate(lang: value.rawValue) + } + + public func nonce(_ value: String) -> Search { + return mutate(nonce: value) + } + + public func role(_ value: Values.Role) -> Search { + return mutate(role: value.rawValue) + } + + public func hasSpellCheck(_ value: Bool) -> Search { + return mutate(spellcheck: value) + } + + public func style(_ value: String) -> Search { + return mutate(style: value) + } + + public func tabIndex(_ value: Int) -> Search { + return mutate(tabindex: value) + } + + public func title(_ value: String) -> Search { + return mutate(title: value) + } + + public func translate(_ value: Values.Decision) -> Search { + return mutate(translate: value.rawValue) + } + + public func inert() -> Search { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Search { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Search { + return mutate(popover: value.rawValue) + } + + public func custom(key: String, value: Any) -> Search { + return mutate(key: key, value: value) + } +} + /// The element is used to represent different kinds of containers. /// /// ```html @@ -7612,8 +8436,25 @@ extension Division: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribute return mutate(title: value) } - public func translate(_ value: Values.Decision) -> Division { - return mutate(translate: value.rawValue) + public func translate(_ value: Values.Decision) -> Division { + return mutate(translate: value.rawValue) + } + + public func inert() -> Division { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Division { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Division { + return mutate(popover: value.rawValue) } public func custom(key: String, value: Any) -> Division { @@ -7869,6 +8710,23 @@ extension Definition: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribu return mutate(translate: value.rawValue) } + public func inert() -> Definition { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Definition { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Definition { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Definition { return mutate(key: key, value: value) } @@ -8122,6 +8980,23 @@ extension Cite: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes { return mutate(translate: value.rawValue) } + public func inert() -> Cite { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Cite { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Cite { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Cite { return mutate(key: key, value: value) } @@ -8375,10 +9250,27 @@ extension ShortQuote: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribu return mutate(translate: value.rawValue) } + public func inert() -> ShortQuote { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> ShortQuote { + + if condition { + return mutate(inert: "inert") + } + + return self + } + public func cite(_ value: String) -> ShortQuote { return mutate(cite: value) } + public func popover(_ value: Values.Popover.State) -> ShortQuote { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> ShortQuote { return mutate(key: key, value: value) } @@ -8632,6 +9524,23 @@ extension Abbreviation: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttri return mutate(translate: value.rawValue) } + public func inert() -> Abbreviation { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Abbreviation { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Abbreviation { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Abbreviation { return mutate(key: key, value: value) } @@ -8885,6 +9794,23 @@ extension Ruby: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes { return mutate(translate: value.rawValue) } + public func inert() -> Ruby { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Ruby { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Ruby { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Ruby { return mutate(key: key, value: value) } @@ -9138,10 +10064,27 @@ extension Data: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, V return mutate(translate: value.rawValue) } + public func inert() -> Data { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Data { + + if condition { + return mutate(inert: "inert") + } + + return self + } + public func value(_ value: String) -> Data { return mutate(value: value) } + public func popover(_ value: Values.Popover.State) -> Data { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Data { return mutate(key: key, value: value) } @@ -9394,11 +10337,28 @@ extension Time: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, D public func translate(_ value: Values.Decision) -> Time { return mutate(translate: value.rawValue) } + + public func inert() -> Time { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Time { + + if condition { + return mutate(inert: "inert") + } + + return self + } public func dateTime(_ value: String) -> Time { return mutate(datetime: value) } + public func popover(_ value: Values.Popover.State) -> Time { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Time { return mutate(key: key, value: value) } @@ -9652,6 +10612,23 @@ extension Code: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes { return mutate(translate: value.rawValue) } + public func inert() -> Code { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Code { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Code { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Code { return mutate(key: key, value: value) } @@ -9905,6 +10882,23 @@ extension Variable: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribute return mutate(translate: value.rawValue) } + public func inert() -> Variable { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Variable { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Variable { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Variable { return mutate(key: key, value: value) } @@ -10158,6 +11152,23 @@ extension SampleOutput: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttri return mutate(translate: value.rawValue) } + public func inert() -> SampleOutput { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> SampleOutput { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> SampleOutput { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> SampleOutput { return mutate(key: key, value: value) } @@ -10411,6 +11422,23 @@ extension KeyboardInput: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttr return mutate(translate: value.rawValue) } + public func inert() -> KeyboardInput { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> KeyboardInput { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> KeyboardInput { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> KeyboardInput { return mutate(key: key, value: value) } @@ -10663,6 +11691,23 @@ extension Subscript: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribut return mutate(translate: value.rawValue) } + public func inert() -> Subscript { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Subscript { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Subscript { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Subscript { return mutate(key: key, value: value) } @@ -10916,6 +11961,23 @@ extension Superscript: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttrib return mutate(translate: value.rawValue) } + public func inert() -> Superscript { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Superscript { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Superscript { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Superscript { return mutate(key: key, value: value) } @@ -11169,6 +12231,23 @@ extension Italic: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes return mutate(translate: value.rawValue) } + public func inert() -> Italic { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Italic { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Italic { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Italic { return mutate(key: key, value: value) } @@ -11429,6 +12508,23 @@ extension Bold: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes { return mutate(translate: value.rawValue) } + public func inert() -> Bold { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Bold { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Bold { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Bold { return mutate(key: key, value: value) } @@ -11689,6 +12785,23 @@ extension Underline: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribut return mutate(translate: value.rawValue) } + public func inert() -> Underline { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Underline { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Underline { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Underline { return mutate(key: key, value: value) } @@ -11949,6 +13062,23 @@ extension Mark: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes { return mutate(translate: value.rawValue) } + public func inert() -> Mark { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Mark { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Mark { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Mark { return mutate(key: key, value: value) } @@ -12202,6 +13332,23 @@ extension Bdi: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes { return mutate(translate: value.rawValue) } + public func inert() -> Bdi { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Bdi { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Bdi { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Bdi { return mutate(key: key, value: value) } @@ -12450,6 +13597,23 @@ extension Bdo: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes { return mutate(translate: value.rawValue) } + public func inert() -> Bdo { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Bdo { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Bdo { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Bdo { return mutate(key: key, value: value) } @@ -12703,6 +13867,23 @@ extension Span: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes { return mutate(translate: value.rawValue) } + public func inert() -> Span { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Span { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Span { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Span { return mutate(key: key, value: value) } @@ -12951,6 +14132,23 @@ extension LineBreak: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribut return mutate(translate: value.rawValue) } + public func inert() -> LineBreak { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> LineBreak { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> LineBreak { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> LineBreak { return mutate(key: key, value: value) } @@ -13199,6 +14397,23 @@ extension WordBreak: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribut return mutate(translate: value.rawValue) } + public func inert() -> WordBreak { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> WordBreak { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> WordBreak { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> WordBreak { return mutate(key: key, value: value) } @@ -13452,6 +14667,19 @@ extension InsertedText: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttri return mutate(translate: value.rawValue) } + public func inert() -> InsertedText { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> InsertedText { + + if condition { + return mutate(inert: "inert") + } + + return self + } + public func cite(_ value: String) -> InsertedText { return mutate(cite: value) } @@ -13460,6 +14688,10 @@ extension InsertedText: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttri return mutate(datetime: value) } + public func popover(_ value: Values.Popover.State) -> InsertedText { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> InsertedText { return mutate(key: key, value: value) } @@ -13712,6 +14944,19 @@ extension DeletedText: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttrib public func translate(_ value: Values.Decision) -> DeletedText { return mutate(translate: value.rawValue) } + + public func inert() -> DeletedText { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> DeletedText { + + if condition { + return mutate(inert: "inert") + } + + return self + } public func cite(_ value: String) -> DeletedText { return mutate(cite: value) @@ -13721,6 +14966,10 @@ extension DeletedText: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttrib return mutate(datetime: value) } + public func popover(_ value: Values.Popover.State) -> DeletedText { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> DeletedText { return mutate(key: key, value: value) } @@ -13974,6 +15223,23 @@ extension Picture: GlobalAttributes, GlobalEventAttributes { return mutate(translate: value.rawValue) } + public func inert() -> Picture { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Picture { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Picture { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Picture { return mutate(key: key, value: value) } @@ -14035,7 +15301,7 @@ public struct Image: EmptyNode, HtmlElement, BodyElement, FormElement, FigureEle } } -extension Image: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, AlternateAttribute, SourceAttribute, SizesAttribute, WidthAttribute, HeightAttribute, ReferrerPolicyAttribute { +extension Image: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, AlternateAttribute, SourceAttribute, SizesAttribute, WidthAttribute, HeightAttribute, ReferrerPolicyAttribute, FetchPriorityAttribute & LoadingAttribute & SourceSetAttribute & DecodingAttribute { public func accessKey(_ value: Character) -> Image { return mutate(accesskey: value) @@ -14146,6 +15412,19 @@ extension Image: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, return mutate(translate: value.rawValue) } + public func inert() -> Image { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Image { + + if condition { + return mutate(inert: "inert") + } + + return self + } + public func alternate(_ value: String) -> Image { return mutate(alternate: value) } @@ -14158,6 +15437,10 @@ extension Image: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, return mutate(source: value) } + public func sourceSet(_ value: String) -> Image { + return mutate(sourceset: value) + } + public func sizes(_ size: Int) -> Image { return mutate(sizes: size) } @@ -14174,6 +15457,22 @@ extension Image: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, return mutate(referrerpolicy: value.rawValue) } + public func fetchPriority(_ value: Values.Priority) -> Image { + return mutate(fetchpriority: value.rawValue) + } + + public func loading(_ value: Values.Loading) -> Image { + return mutate(loading: value.rawValue) + } + + public func decoding(_ value: Values.Decoding) -> Image { + return mutate(decoding: value.rawValue) + } + + public func popover(_ value: Values.Popover.State) -> Image { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Image { return mutate(key: key, value: value) } @@ -14316,7 +15615,7 @@ public struct InlineFrame: ContentNode, HtmlElement, BodyElement, FormElement, F } } -extension InlineFrame: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, SourceAttribute, NameAttribute, WidthAttribute, HeightAttribute, ReferrerPolicyAttribute { +extension InlineFrame: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, SourceAttribute, NameAttribute, WidthAttribute, HeightAttribute, ReferrerPolicyAttribute & LoadingAttribute { public func accessKey(_ value: Character) -> InlineFrame { return mutate(accesskey: value) @@ -14427,6 +15726,19 @@ extension InlineFrame: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttrib return mutate(translate: value.rawValue) } + public func inert() -> InlineFrame { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> InlineFrame { + + if condition { + return mutate(inert: "inert") + } + + return self + } + public func source(_ value: String) -> InlineFrame { return mutate(source: value) } @@ -14451,6 +15763,14 @@ extension InlineFrame: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttrib return mutate(referrerpolicy: value.rawValue) } + public func loading(_ value: Values.Loading) -> InlineFrame { + return mutate(loading: value.rawValue) + } + + public func popover(_ value: Values.Popover.State) -> InlineFrame { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> InlineFrame { return mutate(key: key, value: value) } @@ -14698,6 +16018,19 @@ extension Embed: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, public func translate(_ value: Values.Decision) -> Embed { return mutate(translate: value.rawValue) } + + public func inert() -> Embed { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Embed { + + if condition { + return mutate(inert: "inert") + } + + return self + } public func source(_ value: String) -> Embed { return mutate(source: value) @@ -14719,6 +16052,10 @@ extension Embed: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, return mutate(height: size) } + public func popover(_ value: Values.Popover.State) -> Embed { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Embed { return mutate(key: key, value: value) } @@ -14972,6 +16309,19 @@ extension Object: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, return mutate(translate: value.rawValue) } + public func inert() -> Object { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Object { + + if condition { + return mutate(inert: "inert") + } + + return self + } + public func data(_ value: String) -> Object { return mutate(data: value) } @@ -14996,6 +16346,10 @@ extension Object: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, return mutate(height: size) } + public func popover(_ value: Values.Popover.State) -> Object { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Object { return mutate(key: key, value: value) } @@ -15248,6 +16602,19 @@ extension Video: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, public func translate(_ value: Values.Decision) -> Video { return mutate(translate: value.rawValue) } + + public func inert() -> Video { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Video { + + if condition { + return mutate(inert: "inert") + } + + return self + } public func source(_ value: String) -> Video { return mutate(source: value) @@ -15294,6 +16661,10 @@ extension Video: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, return mutate(preload: value.rawValue) } + public func popover(_ value: Values.Popover.State) -> Video { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Video { return mutate(key: key, value: value) } @@ -15546,6 +16917,19 @@ extension Audio: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, public func translate(_ value: Values.Decision) -> Audio { return mutate(translate: value.rawValue) } + + public func inert() -> Audio { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Audio { + + if condition { + return mutate(inert: "inert") + } + + return self + } public func source(_ value: String) -> Audio { return mutate(source: value) @@ -15584,6 +16968,10 @@ extension Audio: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, return mutate(preload: value.rawValue) } + public func popover(_ value: Values.Popover.State) -> Audio { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Audio { return mutate(key: key, value: value) } @@ -15836,11 +17224,28 @@ extension Map: GlobalAttributes, GlobalEventAttributes, NameAttribute { public func translate(_ value: Values.Decision) -> Map { return mutate(translate: value.rawValue) } + + public func inert() -> Map { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Map { + + if condition { + return mutate(inert: "inert") + } + + return self + } public func name(_ value: String) -> Map { return mutate(name: value) } + public func popover(_ value: Values.Popover.State) -> Map { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Map { return mutate(key: key, value: value) } @@ -16017,6 +17422,19 @@ extension Form: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, A public func translate(_ value: Values.Decision) -> Form { return mutate(translate: value.rawValue) } + + public func inert() -> Form { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Form { + + if condition { + return mutate(inert: "inert") + } + + return self + } public func action(_ value: String) -> Form { return mutate(action: value) @@ -16046,6 +17464,10 @@ extension Form: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, A return mutate(rel: value.rawValue) } + public func popover(_ value: Values.Popover.State) -> Form { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Form { return mutate(key: key, value: value) } @@ -16299,6 +17721,23 @@ extension DataList: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribute return mutate(translate: value.rawValue) } + public func inert() -> DataList { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> DataList { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> DataList { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> DataList { return mutate(key: key, value: value) } @@ -16552,6 +17991,19 @@ extension Output: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, return mutate(translate: value.rawValue) } + public func inert() -> Output { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Output { + + if condition { + return mutate(inert: "inert") + } + + return self + } + public func `for`(_ value: String) -> Output { return mutate(for: value) } @@ -16564,6 +18016,10 @@ extension Output: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, return mutate(name: value) } + public func popover(_ value: Values.Popover.State) -> Output { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Output { return mutate(key: key, value: value) } @@ -16816,6 +18272,19 @@ extension Progress: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribute public func translate(_ value: Values.Decision) -> Progress { return mutate(translate: value.rawValue) } + + public func inert() -> Progress { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Progress { + + if condition { + return mutate(inert: "inert") + } + + return self + } public func maximum(_ value: Float) -> Progress { return mutate(max: value) @@ -16825,6 +18294,10 @@ extension Progress: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribute return mutate(value: value) } + public func popover(_ value: Values.Popover.State) -> Progress { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Progress { return mutate(key: key, value: value) } @@ -17078,6 +18551,19 @@ extension Meter: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, return mutate(translate: value.rawValue) } + public func inert() -> Meter { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Meter { + + if condition { + return mutate(inert: "inert") + } + + return self + } + public func minimum(_ value: Float) -> Meter { return mutate(min: value) } @@ -17102,6 +18588,10 @@ extension Meter: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, return mutate(value: value) } + public func popover(_ value: Values.Popover.State) -> Meter { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Meter { return mutate(key: key, value: value) } @@ -17354,11 +18844,28 @@ extension Details: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes public func translate(_ value: Values.Decision) -> Details { return mutate(translate: value.rawValue) } + + public func inert() -> Details { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Details { + + if condition { + return mutate(inert: "inert") + } + + return self + } public func isOpen(_ value: Bool) -> Details { return mutate(open: value) } + public func popover(_ value: Values.Popover.State) -> Details { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Details { return mutate(key: key, value: value) } @@ -17611,11 +19118,28 @@ extension Dialog: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, public func translate(_ value: Values.Decision) -> Dialog { return mutate(translate: value.rawValue) } + + public func inert() -> Dialog { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Dialog { + + if condition { + return mutate(inert: "inert") + } + + return self + } public func isOpen(_ value: Bool) -> Dialog { return mutate(open: value) } + public func popover(_ value: Values.Popover.State) -> Dialog { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Dialog { return mutate(key: key, value: value) } @@ -17758,7 +19282,7 @@ public struct Script: ContentNode, HeadElement, BodyElement, FormElement, Figure } } -extension Script: GlobalAttributes, GlobalEventAttributes, AsynchronouslyAttribute, ReferrerPolicyAttribute, SourceAttribute, TypeAttribute { +extension Script: GlobalAttributes, GlobalEventAttributes, AsynchronouslyAttribute, ReferrerPolicyAttribute, SourceAttribute, TypeAttribute, FetchPriorityAttribute, BlockingAttribute { public func accessKey(_ value: Character) -> Script { return mutate(accesskey: value) @@ -17868,6 +19392,19 @@ extension Script: GlobalAttributes, GlobalEventAttributes, AsynchronouslyAttribu public func translate(_ value: Values.Decision) -> Script { return mutate(translate: value.rawValue) } + + public func inert() -> Script { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Script { + + if condition { + return mutate(inert: "inert") + } + + return self + } public func asynchronously() -> Script { return mutate(async: "async") @@ -17889,6 +19426,18 @@ extension Script: GlobalAttributes, GlobalEventAttributes, AsynchronouslyAttribu return mutate(type: value.rawValue) } + public func fetchPriority(_ value: Values.Priority) -> Script { + return mutate(fetchpriority: value.rawValue) + } + + public func blocking(_ value: Values.Blocking) -> Script { + return mutate(blocking: value.rawValue) + } + + public func popover(_ value: Values.Popover.State) -> Script { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Script { return mutate(key: key, value: value) } @@ -18066,6 +19615,23 @@ extension NoScript: GlobalAttributes, GlobalEventAttributes { return mutate(translate: value.rawValue) } + public func inert() -> NoScript { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> NoScript { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> NoScript { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> NoScript { return mutate(key: key, value: value) } @@ -18243,6 +19809,23 @@ extension Template: GlobalAttributes, GlobalEventAttributes, ShadowRootModeAttri return mutate(translate: value.rawValue) } + public func inert() -> Template { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Template { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Template { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Template { return mutate(key: key, value: value) } @@ -18424,6 +20007,19 @@ extension Canvas: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, return mutate(translate: value.rawValue) } + public func inert() -> Canvas { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Canvas { + + if condition { + return mutate(inert: "inert") + } + + return self + } + public func width(_ size: Int) -> Canvas { return mutate(width: size) } @@ -18432,6 +20028,10 @@ extension Canvas: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, return mutate(height: size) } + public func popover(_ value: Values.Popover.State) -> Canvas { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Canvas { return mutate(key: key, value: value) } @@ -18684,6 +20284,19 @@ extension Table: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, public func translate(_ value: Values.Decision) -> Table { return mutate(translate: value.rawValue) } + + public func inert() -> Table { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Table { + + if condition { + return mutate(inert: "inert") + } + + return self + } public func width(_ size: Int) -> Table { return mutate(width: size) @@ -18693,6 +20306,10 @@ extension Table: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, return mutate(height: size) } + public func popover(_ value: Values.Popover.State) -> Table { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Table { return mutate(key: key, value: value) } @@ -19054,6 +20671,19 @@ extension Slot: GlobalAttributes, NameAttribute { return mutate(translate: value.rawValue) } + public func inert() -> Slot { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Slot { + + if condition { + return mutate(inert: "inert") + } + + return self + } + public func name(_ value: String) -> Slot { return mutate(name: value) } @@ -19061,4 +20691,8 @@ extension Slot: GlobalAttributes, NameAttribute { public func custom(key: String, value: Any) -> Slot { return mutate(key: key, value: value) } + + public func popover(_ value: Values.Popover.State) -> Slot { + return mutate(popover: value.rawValue) + } } diff --git a/Sources/HTMLKit/Abstraction/Elements/DefinitionElements.swift b/Sources/HTMLKit/Abstraction/Elements/DefinitionElements.swift index 70afba0e..e68bb21b 100644 --- a/Sources/HTMLKit/Abstraction/Elements/DefinitionElements.swift +++ b/Sources/HTMLKit/Abstraction/Elements/DefinitionElements.swift @@ -178,6 +178,23 @@ extension TermName: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribute return mutate(translate: value.rawValue) } + public func inert() -> TermName { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> TermName { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> TermName { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> TermName { return mutate(key: key, value: value) } @@ -431,6 +448,23 @@ extension TermDefinition: GlobalAttributes, GlobalEventAttributes, GlobalAriaAtt return mutate(translate: value.rawValue) } + public func inert() -> TermDefinition { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> TermDefinition { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> TermDefinition { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> TermDefinition { return mutate(key: key, value: value) } diff --git a/Sources/HTMLKit/Abstraction/Elements/FigureElements.swift b/Sources/HTMLKit/Abstraction/Elements/FigureElements.swift index 5787701d..faf16a45 100644 --- a/Sources/HTMLKit/Abstraction/Elements/FigureElements.swift +++ b/Sources/HTMLKit/Abstraction/Elements/FigureElements.swift @@ -169,6 +169,23 @@ extension FigureCaption: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttr return mutate(translate: value.rawValue) } + public func inert() -> FigureCaption { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> FigureCaption { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> FigureCaption { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> FigureCaption { return mutate(key: key, value: value) } diff --git a/Sources/HTMLKit/Abstraction/Elements/FormElements.swift b/Sources/HTMLKit/Abstraction/Elements/FormElements.swift index 13c33494..f133dc36 100644 --- a/Sources/HTMLKit/Abstraction/Elements/FormElements.swift +++ b/Sources/HTMLKit/Abstraction/Elements/FormElements.swift @@ -44,7 +44,7 @@ public struct Input: EmptyNode, FormElement { } } -extension Input: GlobalAttributes, GlobalEventAttributes, AcceptAttribute, AlternateAttribute, AutocompleteAttribute, CheckedAttribute, DisabledAttribute, FormAttribute, FormActionAttribute, HeightAttribute, ListAttribute, MaximumValueAttribute, MaximumLengthAttribute, MinimumValueAttribute, MinimumLengthAttribute, MultipleAttribute, NameAttribute, PatternAttribute, PlaceholderAttribute, ReadyOnlyAttribute, RequiredAttribute, SizeAttribute, SourceAttribute, StepAttribute, TypeAttribute, ValueAttribute, WidthAttribute { +extension Input: GlobalAttributes, GlobalEventAttributes, AcceptAttribute, AlternateAttribute, AutocompleteAttribute, CheckedAttribute, DisabledAttribute, FormAttribute, FormActionAttribute, HeightAttribute, ListAttribute, MaximumValueAttribute, MaximumLengthAttribute, MinimumValueAttribute, MinimumLengthAttribute, MultipleAttribute, NameAttribute, PatternAttribute, PlaceholderAttribute, ReadyOnlyAttribute, RequiredAttribute, SizeAttribute, SourceAttribute, StepAttribute, TypeAttribute, ValueAttribute, WidthAttribute, PopoverTargetAttribute, PopoverActionAttribute { public func accessKey(_ value: Character) -> Input { return mutate(accesskey: value) @@ -154,6 +154,19 @@ extension Input: GlobalAttributes, GlobalEventAttributes, AcceptAttribute, Alter public func translate(_ value: Values.Decision) -> Input { return mutate(translate: value.rawValue) } + + public func inert() -> Input { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Input { + + if condition { + return mutate(inert: "inert") + } + + return self + } public func accept(_ value: String) -> Input { return mutate(accept: value) @@ -295,6 +308,18 @@ extension Input: GlobalAttributes, GlobalEventAttributes, AcceptAttribute, Alter return mutate(width: size) } + public func popover(_ value: Values.Popover.State) -> Input { + return mutate(popover: value.rawValue) + } + + public func popoverTarget(_ value: String) -> Input { + return mutate(popovertarget: value) + } + + public func popoverAction(_ value: Values.Popover.Action) -> Input { + return mutate(popoveraction: value.rawValue) + } + public func custom(key: String, value: Any) -> Input { return mutate(key: key, value: value) } @@ -472,10 +497,27 @@ extension Label: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, return mutate(translate: value.rawValue) } + public func inert() -> Label { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Label { + + if condition { + return mutate(inert: "inert") + } + + return self + } + public func `for`(_ value: String) -> Label { return mutate(for: value) } + public func popover(_ value: Values.Popover.State) -> Label { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Label { return mutate(key: key, value: value) } @@ -735,6 +777,19 @@ extension Select: GlobalAttributes, GlobalEventAttributes, AutocompleteAttribute public func translate(_ value: Values.Decision) -> Select { return mutate(translate: value.rawValue) } + + public func inert() -> Select { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Select { + + if condition { + return mutate(inert: "inert") + } + + return self + } public func hasCompletion(_ value: Bool) -> Select { return mutate(autocomplete: value) @@ -782,6 +837,10 @@ extension Select: GlobalAttributes, GlobalEventAttributes, AutocompleteAttribute return mutate(size: size) } + public func popover(_ value: Values.Popover.State) -> Select { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Select { return mutate(key: key, value: value) } @@ -958,6 +1017,19 @@ extension TextArea: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribute public func translate(_ value: Values.Decision) -> TextArea { return mutate(translate: value.rawValue) } + + public func inert() -> TextArea { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> TextArea { + + if condition { + return mutate(inert: "inert") + } + + return self + } public func hasCompletion(_ value: Bool) -> TextArea { return mutate(autocomplete: value) @@ -1034,6 +1106,10 @@ extension TextArea: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribute return mutate(wrap: value.rawValue) } + public func popover(_ value: Values.Popover.State) -> TextArea { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> TextArea { return mutate(key: key, value: value) } @@ -1176,7 +1252,7 @@ public struct Button: ContentNode, FormElement { } } -extension Button: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, DisabledAttribute, FormAttribute, FormActionAttribute, NameAttribute, TypeAttribute, ValueAttribute { +extension Button: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, DisabledAttribute, FormAttribute, FormActionAttribute, NameAttribute, TypeAttribute, ValueAttribute, PopoverTargetAttribute, PopoverActionAttribute { public func accessKey(_ value: Character) -> Button { return mutate(accesskey: value) @@ -1287,6 +1363,19 @@ extension Button: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, return mutate(translate: value.rawValue) } + public func inert() -> Button { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Button { + + if condition { + return mutate(inert: "inert") + } + + return self + } + public func disabled() -> Button { return mutate(disabled: "disabled") } @@ -1320,6 +1409,18 @@ extension Button: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, return mutate(value: value) } + public func popover(_ value: Values.Popover.State) -> Button { + return mutate(popover: value.rawValue) + } + + public func popoverTarget(_ value: String) -> Button { + return mutate(popovertarget: value) + } + + public func popoverAction(_ value: Values.Popover.Action) -> Button { + return mutate(popoveraction: value.rawValue) + } + public func custom(key: String, value: Any) -> Button { return mutate(key: key, value: value) } @@ -1579,6 +1680,19 @@ extension Fieldset: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribute public func translate(_ value: Values.Decision) -> Fieldset { return mutate(translate: value.rawValue) } + + public func inert() -> Fieldset { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Fieldset { + + if condition { + return mutate(inert: "inert") + } + + return self + } public func disabled() -> Fieldset { return mutate(disabled: "disabled") @@ -1601,6 +1715,10 @@ extension Fieldset: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribute return mutate(name: value) } + public func popover(_ value: Values.Popover.State) -> Fieldset { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Fieldset { return mutate(key: key, value: value) } diff --git a/Sources/HTMLKit/Abstraction/Elements/HeadElements.swift b/Sources/HTMLKit/Abstraction/Elements/HeadElements.swift index 6cef28f7..ca1592ba 100644 --- a/Sources/HTMLKit/Abstraction/Elements/HeadElements.swift +++ b/Sources/HTMLKit/Abstraction/Elements/HeadElements.swift @@ -160,6 +160,23 @@ extension Title: GlobalAttributes, GlobalEventAttributes { return mutate(translate: value.rawValue) } + public func inert() -> Title { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Title { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Title { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Title { return mutate(key: key, value: value) } @@ -332,6 +349,19 @@ extension Base: GlobalAttributes, GlobalEventAttributes, ReferenceAttribute, Tar return mutate(translate: value.rawValue) } + public func inert() -> Base { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Base { + + if condition { + return mutate(inert: "inert") + } + + return self + } + public func reference(_ value: String) -> Base { return mutate(href: value) } @@ -340,6 +370,10 @@ extension Base: GlobalAttributes, GlobalEventAttributes, ReferenceAttribute, Tar return mutate(target: value.rawValue) } + public func popover(_ value: Values.Popover.State) -> Base { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Base { return mutate(key: key, value: value) } @@ -511,6 +545,19 @@ extension Meta: GlobalAttributes, GlobalEventAttributes, ContentAttribute, NameA public func translate(_ value: Values.Decision) -> Meta { return mutate(translate: value.rawValue) } + + public func inert() -> Meta { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Meta { + + if condition { + return mutate(inert: "inert") + } + + return self + } public func content(_ value: String) -> Meta { return mutate(content: value) @@ -532,6 +579,10 @@ extension Meta: GlobalAttributes, GlobalEventAttributes, ContentAttribute, NameA return mutate(httpequiv: value.rawValue) } + public func popover(_ value: Values.Popover.State) -> Meta { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Meta { return mutate(key: key, value: value) } @@ -598,7 +649,7 @@ public struct Style: ContentNode, HeadElement { } } -extension Style: GlobalAttributes, GlobalEventAttributes, TypeAttribute, MediaAttribute { +extension Style: GlobalAttributes, GlobalEventAttributes, TypeAttribute, MediaAttribute, BlockingAttribute { public func accessKey(_ value: Character) -> Style { return mutate(accesskey: value) @@ -708,6 +759,19 @@ extension Style: GlobalAttributes, GlobalEventAttributes, TypeAttribute, MediaAt public func translate(_ value: Values.Decision) -> Style { return mutate(translate: value.rawValue) } + + public func inert() -> Style { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Style { + + if condition { + return mutate(inert: "inert") + } + + return self + } public func type(_ value: Values.Media) -> Style { return mutate(type: value.rawValue) @@ -717,6 +781,14 @@ extension Style: GlobalAttributes, GlobalEventAttributes, TypeAttribute, MediaAt return mutate(media: value) } + public func blocking(_ value: Values.Blocking) -> Style { + return mutate(blocking: value.rawValue) + } + + public func popover(_ value: Values.Popover.State) -> Style { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Style { return mutate(key: key, value: value) } @@ -778,7 +850,7 @@ public struct Link: EmptyNode, HeadElement, BodyElement { } } -extension Link: GlobalAttributes, GlobalEventAttributes, ReferenceAttribute, ReferenceLanguageAttribute, MediaAttribute, ReferrerPolicyAttribute, RelationshipAttribute, SizesAttribute, TypeAttribute, FormEventAttribute { +extension Link: GlobalAttributes, GlobalEventAttributes, ReferenceAttribute, ReferenceLanguageAttribute, MediaAttribute, ReferrerPolicyAttribute, RelationshipAttribute, SizesAttribute, TypeAttribute, FetchPriorityAttribute, BlockingAttribute, FormEventAttribute { public func accessKey(_ value: Character) -> Link { return mutate(accesskey: value) @@ -889,6 +961,19 @@ extension Link: GlobalAttributes, GlobalEventAttributes, ReferenceAttribute, Ref return mutate(translate: value.rawValue) } + public func inert() -> Link { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Link { + + if condition { + return mutate(inert: "inert") + } + + return self + } + public func reference(_ value: String) -> Link { return mutate(href: value) } @@ -917,6 +1002,18 @@ extension Link: GlobalAttributes, GlobalEventAttributes, ReferenceAttribute, Ref return mutate(type: value.rawValue) } + public func fetchPriority(_ value: Values.Priority) -> Link { + return mutate(fetchpriority: value.rawValue) + } + + public func blocking(_ value: Values.Blocking) -> Link { + return mutate(blocking: value.rawValue) + } + + public func popover(_ value: Values.Popover.State) -> Link { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Link { return mutate(key: key, value: value) } diff --git a/Sources/HTMLKit/Abstraction/Elements/HtmlElements.swift b/Sources/HTMLKit/Abstraction/Elements/HtmlElements.swift index 1836a33b..b2039561 100644 --- a/Sources/HTMLKit/Abstraction/Elements/HtmlElements.swift +++ b/Sources/HTMLKit/Abstraction/Elements/HtmlElements.swift @@ -160,6 +160,23 @@ extension Head: GlobalAttributes, GlobalEventAttributes { return mutate(translate: value.rawValue) } + public func inert() -> Head { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Head { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Head { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Head { return mutate(key: key, value: value) } @@ -337,6 +354,23 @@ extension Body: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, W return mutate(translate: value.rawValue) } + public func inert() -> Body { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Body { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Body { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Body { return mutate(key: key, value: value) } diff --git a/Sources/HTMLKit/Abstraction/Elements/InputElements.swift b/Sources/HTMLKit/Abstraction/Elements/InputElements.swift index 4062e864..b59f6f59 100644 --- a/Sources/HTMLKit/Abstraction/Elements/InputElements.swift +++ b/Sources/HTMLKit/Abstraction/Elements/InputElements.swift @@ -168,6 +168,19 @@ extension OptionGroup: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttrib public func translate(_ value: Values.Decision) -> OptionGroup { return mutate(translate: value.rawValue) } + + public func inert() -> OptionGroup { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> OptionGroup { + + if condition { + return mutate(inert: "inert") + } + + return self + } public func disabled() -> OptionGroup { return mutate(disabled: "disabled") @@ -186,6 +199,10 @@ extension OptionGroup: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttrib return mutate(label: value) } + public func popover(_ value: Values.Popover.State) -> OptionGroup { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> OptionGroup { return mutate(key: key, value: value) } @@ -438,6 +455,19 @@ extension Option: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, public func translate(_ value: Values.Decision) -> Option { return mutate(translate: value.rawValue) } + + public func inert() -> Option { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Option { + + if condition { + return mutate(inert: "inert") + } + + return self + } public func disabled() -> Option { return mutate(disabled: "disabled") @@ -464,6 +494,10 @@ extension Option: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, return mutate(selected: "selected") } + public func popover(_ value: Values.Popover.State) -> Option { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Option { return mutate(key: key, value: value) } @@ -719,6 +753,23 @@ extension Legend: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes return mutate(translate: value.rawValue) } + public func inert() -> Legend { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Legend { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Legend { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Legend { return mutate(key: key, value: value) } @@ -972,6 +1023,23 @@ extension Summary: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes return mutate(translate: value.rawValue) } + public func inert() -> Summary { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Summary { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Summary { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Summary { return mutate(key: key, value: value) } diff --git a/Sources/HTMLKit/Abstraction/Elements/ListElements.swift b/Sources/HTMLKit/Abstraction/Elements/ListElements.swift index c42b289a..be852bbd 100644 --- a/Sources/HTMLKit/Abstraction/Elements/ListElements.swift +++ b/Sources/HTMLKit/Abstraction/Elements/ListElements.swift @@ -169,10 +169,27 @@ extension ListItem: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribute return mutate(translate: value.rawValue) } + public func inert() -> ListItem { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> ListItem { + + if condition { + return mutate(inert: "inert") + } + + return self + } + public func value(_ value: String) -> ListItem { return mutate(value: value) } + public func popover(_ value: Values.Popover.State) -> ListItem { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> ListItem { return mutate(key: key, value: value) } diff --git a/Sources/HTMLKit/Abstraction/Elements/MapElements.swift b/Sources/HTMLKit/Abstraction/Elements/MapElements.swift index 93ba5a96..e4769740 100644 --- a/Sources/HTMLKit/Abstraction/Elements/MapElements.swift +++ b/Sources/HTMLKit/Abstraction/Elements/MapElements.swift @@ -50,7 +50,7 @@ public struct Area: ContentNode, MapElement { } extension Area: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, AlternateAttribute, CoordinatesAttribute, ShapeAttribute, ReferenceAttribute, TargetAttribute, DownloadAttribute, PingAttribute, RelationshipAttribute, ReferrerPolicyAttribute { - + public func accessKey(_ value: Character) -> Area { return mutate(accesskey: value) } @@ -160,6 +160,19 @@ extension Area: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, A return mutate(translate: value.rawValue) } + public func inert() -> Area { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Area { + + if condition { + return mutate(inert: "inert") + } + + return self + } + public func alternate(_ value: String) -> Area { return mutate(alternate: value) } @@ -196,6 +209,10 @@ extension Area: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, A return mutate(referrerpolicy: value.rawValue) } + public func popover(_ value: Values.Popover.State) -> Area { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Area { return mutate(key: key, value: value) } diff --git a/Sources/HTMLKit/Abstraction/Elements/MediaElements.swift b/Sources/HTMLKit/Abstraction/Elements/MediaElements.swift index 299a1d22..5d03d7ad 100644 --- a/Sources/HTMLKit/Abstraction/Elements/MediaElements.swift +++ b/Sources/HTMLKit/Abstraction/Elements/MediaElements.swift @@ -44,7 +44,7 @@ public struct Source: EmptyNode, MediaElement { } } -extension Source: GlobalAttributes, GlobalEventAttributes, TypeAttribute, SourceAttribute, SizesAttribute, MediaAttribute, WidthAttribute, HeightAttribute { +extension Source: GlobalAttributes, GlobalEventAttributes, TypeAttribute, SourceAttribute, SizesAttribute, MediaAttribute, WidthAttribute, HeightAttribute & SourceSetAttribute { public func accessKey(_ value: Character) -> Source { return mutate(accesskey: value) @@ -154,6 +154,19 @@ extension Source: GlobalAttributes, GlobalEventAttributes, TypeAttribute, Source public func translate(_ value: Values.Decision) -> Source { return mutate(translate: value.rawValue) } + + public func inert() -> Source { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Source { + + if condition { + return mutate(inert: "inert") + } + + return self + } public func type(_ value: Values.Media) -> Source { return mutate(type: value.rawValue) @@ -167,6 +180,10 @@ extension Source: GlobalAttributes, GlobalEventAttributes, TypeAttribute, Source return mutate(source: value) } + public func sourceSet(_ value: String) -> Source { + return mutate(sourceset: value) + } + public func sizes(_ size: Int) -> Source { return mutate(sizes: size) } @@ -183,6 +200,10 @@ extension Source: GlobalAttributes, GlobalEventAttributes, TypeAttribute, Source return mutate(height: size) } + public func popover(_ value: Values.Popover.State) -> Source { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Source { return mutate(key: key, value: value) } @@ -355,6 +376,19 @@ extension Track: GlobalAttributes, GlobalEventAttributes, KindAttribute, SourceA return mutate(translate: value.rawValue) } + public func inert() -> Track { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Track { + + if condition { + return mutate(inert: "inert") + } + + return self + } + public func kind(_ value: Values.Kind) -> Track { return mutate(kind: value.rawValue) } @@ -375,6 +409,10 @@ extension Track: GlobalAttributes, GlobalEventAttributes, KindAttribute, SourceA return mutate(default: "default") } + public func popover(_ value: Values.Popover.State) -> Track { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Track { return mutate(key: key, value: value) } diff --git a/Sources/HTMLKit/Abstraction/Elements/ObjectElements.swift b/Sources/HTMLKit/Abstraction/Elements/ObjectElements.swift index 872ae263..60775540 100644 --- a/Sources/HTMLKit/Abstraction/Elements/ObjectElements.swift +++ b/Sources/HTMLKit/Abstraction/Elements/ObjectElements.swift @@ -163,6 +163,19 @@ extension Parameter: GlobalAttributes, GlobalEventAttributes, NameAttribute, Val public func translate(_ value: Values.Decision) -> Parameter { return mutate(translate: value.rawValue) } + + public func inert() -> Parameter { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Parameter { + + if condition { + return mutate(inert: "inert") + } + + return self + } public func name(_ value: String) -> Parameter { return mutate(name: value) @@ -172,6 +185,10 @@ extension Parameter: GlobalAttributes, GlobalEventAttributes, NameAttribute, Val return mutate(value: value) } + public func popover(_ value: Values.Popover.State) -> Parameter { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Parameter { return mutate(key: key, value: value) } diff --git a/Sources/HTMLKit/Abstraction/Elements/RubyElements.swift b/Sources/HTMLKit/Abstraction/Elements/RubyElements.swift index b663c1e8..61fb48d4 100644 --- a/Sources/HTMLKit/Abstraction/Elements/RubyElements.swift +++ b/Sources/HTMLKit/Abstraction/Elements/RubyElements.swift @@ -178,6 +178,23 @@ extension RubyText: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribute return mutate(translate: value.rawValue) } + public func inert() -> RubyText { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> RubyText { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> RubyText { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> RubyText { return mutate(key: key, value: value) } @@ -431,6 +448,23 @@ extension RubyPronunciation: GlobalAttributes, GlobalEventAttributes, GlobalAria return mutate(translate: value.rawValue) } + public func inert() -> RubyPronunciation { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> RubyPronunciation { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> RubyPronunciation { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> RubyPronunciation { return mutate(key: key, value: value) } diff --git a/Sources/HTMLKit/Abstraction/Elements/TableElements.swift b/Sources/HTMLKit/Abstraction/Elements/TableElements.swift index 466fe700..c68590cd 100644 --- a/Sources/HTMLKit/Abstraction/Elements/TableElements.swift +++ b/Sources/HTMLKit/Abstraction/Elements/TableElements.swift @@ -232,6 +232,23 @@ extension Caption: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes return mutate(translate: value.rawValue) } + public func inert() -> Caption { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Caption { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> Caption { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Caption { return mutate(key: key, value: value) } @@ -484,11 +501,28 @@ extension ColumnGroup: GlobalAttributes, GlobalEventAttributes, SpanAttribute { public func translate(_ value: Values.Decision) -> ColumnGroup { return mutate(translate: value.rawValue) } + + public func inert() -> ColumnGroup { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> ColumnGroup { + + if condition { + return mutate(inert: "inert") + } + + return self + } public func span(_ size: Int) -> ColumnGroup { return mutate(span: size) } + public func popover(_ value: Values.Popover.State) -> ColumnGroup { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> ColumnGroup { return mutate(key: key, value: value) } @@ -666,10 +700,27 @@ extension Column: GlobalAttributes, GlobalEventAttributes, SpanAttribute { return mutate(translate: value.rawValue) } + public func inert() -> Column { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Column { + + if condition { + return mutate(inert: "inert") + } + + return self + } + public func span(_ size: Int) -> Column { return mutate(span: size) } + public func popover(_ value: Values.Popover.State) -> Column { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> Column { return mutate(key: key, value: value) } @@ -847,6 +898,19 @@ extension TableBody: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribut return mutate(translate: value.rawValue) } + public func inert() -> TableBody { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> TableBody { + + if condition { + return mutate(inert: "inert") + } + + return self + } + public func width(_ size: Int) -> TableBody { return mutate(width: size) } @@ -855,6 +919,10 @@ extension TableBody: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribut return mutate(height: size) } + public func popover(_ value: Values.Popover.State) -> TableBody { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> TableBody { return mutate(key: key, value: value) } @@ -1107,6 +1175,19 @@ extension TableHead: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribut public func translate(_ value: Values.Decision) -> TableHead { return mutate(translate: value.rawValue) } + + public func inert() -> TableHead { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> TableHead { + + if condition { + return mutate(inert: "inert") + } + + return self + } public func width(_ size: Int) -> TableHead { return mutate(width: size) @@ -1116,6 +1197,10 @@ extension TableHead: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribut return mutate(height: size) } + public func popover(_ value: Values.Popover.State) -> TableHead { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> TableHead { return mutate(key: key, value: value) } @@ -1369,6 +1454,23 @@ extension TableFoot: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribut return mutate(translate: value.rawValue) } + public func inert() -> TableFoot { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> TableFoot { + + if condition { + return mutate(inert: "inert") + } + + return self + } + + public func popover(_ value: Values.Popover.State) -> TableFoot { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> TableFoot { return mutate(key: key, value: value) } @@ -1621,6 +1723,19 @@ extension TableRow: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribute public func translate(_ value: Values.Decision) -> TableRow { return mutate(translate: value.rawValue) } + + public func inert() -> TableRow { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> TableRow { + + if condition { + return mutate(inert: "inert") + } + + return self + } public func width(_ size: Int) -> TableRow { return mutate(width: size) @@ -1630,6 +1745,10 @@ extension TableRow: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribute return mutate(height: size) } + public func popover(_ value: Values.Popover.State) -> TableRow { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> TableRow { return mutate(key: key, value: value) } @@ -1882,6 +2001,19 @@ extension DataCell: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribute public func translate(_ value: Values.Decision) -> DataCell { return mutate(translate: value.rawValue) } + + public func inert() -> DataCell { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> DataCell { + + if condition { + return mutate(inert: "inert") + } + + return self + } public func columnSpan(_ size: Int) -> DataCell { return mutate(colspan: size) @@ -1895,6 +2027,10 @@ extension DataCell: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribute return mutate(headers: value) } + public func popover(_ value: Values.Popover.State) -> DataCell { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> DataCell { return mutate(key: key, value: value) } @@ -2147,6 +2283,19 @@ extension HeaderCell: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribu public func translate(_ value: Values.Decision) -> HeaderCell { return mutate(translate: value.rawValue) } + + public func inert() -> HeaderCell { + return mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> HeaderCell { + + if condition { + return mutate(inert: "inert") + } + + return self + } public func columnSpan(_ size: Int) -> HeaderCell { return mutate(colspan: size) @@ -2164,6 +2313,10 @@ extension HeaderCell: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttribu return mutate(scope: value) } + public func popover(_ value: Values.Popover.State) -> HeaderCell { + return mutate(popover: value.rawValue) + } + public func custom(key: String, value: Any) -> HeaderCell { return mutate(key: key, value: value) } diff --git a/Sources/HTMLKit/Abstraction/Tokens/ValueTokens.swift b/Sources/HTMLKit/Abstraction/Tokens/ValueTokens.swift index 8a6cf2db..16612f8c 100644 --- a/Sources/HTMLKit/Abstraction/Tokens/ValueTokens.swift +++ b/Sources/HTMLKit/Abstraction/Tokens/ValueTokens.swift @@ -16,13 +16,16 @@ public enum Values { /// ``` public enum Name: String { + case applicationName = "application-name" case author = "author" case description = "description" case generator = "generator" case keywords = "keywords" + case referrer = "referrer" + case themeColor = "theme-color" + case colorScheme = "color-scheme" case robots = "robots" case viewport = "viewport" - case applicationName = "application-name" } /// A typ for buttons. @@ -78,28 +81,28 @@ public enum Values { /// ``` public enum Input: String { + case hidden case text - case button - case checkbox - case color - case date + case search + case phone = "tel" + case url case email - case file - case hidden - case image + case password + case date case month + case week + case time + case datetimeLocal = "datetime-local" case number - case password - case radio case range - case reset - case search + case color + case checkbox + case radio + case file case submit - case time - case url - case week - case datetimeLocal = "datetime-local" - case phone = "tel" + case image + case reset + case button } /// A language @@ -320,27 +323,35 @@ public enum Values { public enum Relation: String { case alternate + case canonical case author + case bookmark + case dnsPrefetch = "dns-prefetch" case external case help case icon + case manifest + case modulePreload = "modulepreload" case licence case next + case noFollow = "nofollow" + case noOpener = "noopener" + case noReferrer = "noreferrer" + case opener case pingback case preconnect case prefetch case preload + @available(*, deprecated, message: "It is no longer part of the web standards.") case prerender case prev case search case stylesheet - case noFollow = "nofollow" - case noReferrer = "noreferrer" - case noOpener = "noopener" - case dnsPrefetch = "dns-prefetch" + case tag + @available(*, deprecated, message: "It is no longer part of the web standards. Use 'icon' instead.") + case shortcutIcon = "shortcut icon" case appleTouchIcon = "apple-touch-icon" case appleTouchStartupImage = "apple-touch-startup-image" - case shortcutIcon = "shortcut icon" } /// A target for reference links. @@ -900,4 +911,51 @@ public enum Values { case closed } } + + public enum Priority: String { + /// Signals a higher priority for fetching relative to other resources. + case high + /// Signals a lower priority for fetching relative to other resources. + case low + /// Signals a automatic determination of the fetch priority. + case auto + } + + public enum Loading: String { + /// Defers fetching a resource until some conditions are met. + case lazy + /// Fetches a resource immediately + case eager + } + + public enum Decoding: String { + /// Indicates a preference to decode synchronously + case sync + /// Indicates a preference to decode asynchronously + case async + /// Indicates no preference for the decoding. + case auto + } + + public enum Blocking: String { + /// Indicates a render-blocking element. + case render + } + + public enum Popover { + + public enum State: String { + /// Closes other popovers when opened. + case auto + /// Does not close other popovers. + case manual + } + + public enum Action: String { + + case toggle + case show + case hide + } + } } diff --git a/Sources/HTMLKitComponents/Actions/SubmitAction.swift b/Sources/HTMLKitComponents/Actions/SubmitAction.swift index ad85448d..96ee6128 100644 --- a/Sources/HTMLKitComponents/Actions/SubmitAction.swift +++ b/Sources/HTMLKitComponents/Actions/SubmitAction.swift @@ -1,22 +1,22 @@ -import Foundation - -public protocol SubmitAction { +public struct SubmitAction: Action { - /// Validates the form. - func validate(_ target: String, _ validators: [Validator]) -> String -} - -extension SubmitAction { + public var actions: [String] = [] - public func validate(_ target: String, _ validators: [Validator]) -> String { + public func validate(_ target: String, _ validators: [Validator]) -> SubmitAction { + + var newSelf = self - if let data = try? JSONEncoder().encode(validators) { + if !validators.isEmpty { + + let result = validators.map { "{\"field\":\"\($0.field)\",\"rule\":\"\($0.rule)\"}" } - if let result = String(data: data, encoding: .utf8) { - return "$('#\(target.escape())').validate('\(result)');" - } + newSelf.actions.append("$('#\(target.escape())').validate('[\(result.joined(separator: ","))]');") + + return newSelf } - return "$('#\(target.escape())').validate('[]');" + newSelf.actions.append("$('#\(target.escape())').validate('[]');") + + return newSelf } } diff --git a/Sources/HTMLKitComponents/Actions/ViewAction.swift b/Sources/HTMLKitComponents/Actions/ViewAction.swift index a7a83ca8..8054efe1 100644 --- a/Sources/HTMLKitComponents/Actions/ViewAction.swift +++ b/Sources/HTMLKitComponents/Actions/ViewAction.swift @@ -1,42 +1,44 @@ -import Foundation - -public protocol ViewAction { - - /// Shows the target. - func show(_ target: String) -> String - - /// Hides the target. - func hide(_ target: String) -> String - - /// Animates the target. - func animate(_ target: String) -> String +public struct ViewAction: Action { - /// Opens the target. - func open(_ target: String) -> String + public var actions: [String] = [] - /// Closes the target. - func close(_ target: String) -> String -} - -extension ViewAction { - - public func show(_ target: String) -> String { - return "$('#\(target.escape())').show();" + public func show(_ target: String) -> ViewAction { + + var newSelf = self + newSelf.actions.append("$('#\(target.escape())').show();") + + return newSelf } - - public func hide(_ target: String) -> String { - return "$('#\(target.escape())').hide();" + + public func hide(_ target: String) -> ViewAction { + + var newSelf = self + newSelf.actions.append("$('#\(target.escape())').hide();") + + return newSelf } - - public func animate(_ target: String) -> String { - return "$('#\(target.escape())').animate();" + + public func animate(_ target: String) -> ViewAction { + + var newSelf = self + newSelf.actions.append("$('#\(target.escape())').animate();") + + return newSelf } - - public func open(_ target: String) -> String { - return "$('#\(target.escape())').open();" + + public func open(_ target: String) -> ViewAction { + + var newSelf = self + newSelf.actions.append("$('#\(target.escape())').open();") + + return newSelf } - - public func close(_ target: String) -> String { - return "$('#\(target.escape())').close();" + + public func close(_ target: String) -> ViewAction { + + var newSelf = self + newSelf.actions.append("$('#\(target.escape())').close();") + + return newSelf } } diff --git a/Sources/HTMLKitComponents/Builders/ActionBuilder.swift b/Sources/HTMLKitComponents/Builders/ActionBuilder.swift new file mode 100644 index 00000000..8f6db05a --- /dev/null +++ b/Sources/HTMLKitComponents/Builders/ActionBuilder.swift @@ -0,0 +1,7 @@ +@resultBuilder +public struct ActionBuilder { + + public static func buildBlock(_ components: Action...) -> [Action] { + return components + } +} diff --git a/Sources/HTMLKitComponents/Builders/StringBuilder.swift b/Sources/HTMLKitComponents/Builders/StringBuilder.swift deleted file mode 100644 index 33f1b9ab..00000000 --- a/Sources/HTMLKitComponents/Builders/StringBuilder.swift +++ /dev/null @@ -1,7 +0,0 @@ -@resultBuilder -public struct StringBuilder { - - public static func buildBlock(_ components: String...) -> [String] { - return components - } -} diff --git a/Sources/HTMLKitComponents/Components/Button.swift b/Sources/HTMLKitComponents/Components/Button.swift index a72eccb9..c018cddd 100644 --- a/Sources/HTMLKitComponents/Components/Button.swift +++ b/Sources/HTMLKitComponents/Components/Button.swift @@ -9,7 +9,7 @@ import Foundation /// A component that initiates an action. public struct Button: View, Modifiable, Actionable { - internal var id: String? + public var id: String? /// The role of the button internal var role: HTMLKit.Values.Button @@ -31,12 +31,13 @@ public struct Button: View, Modifiable, Actionable { } /// Creates a action button. - internal init(role: HTMLKit.Values.Button, content: [Content], classes: [String], events: [String]?) { + internal init(role: HTMLKit.Values.Button, content: [Content], classes: [String], events: [String]?, id: String?) { self.role = role self.content = content self.classes = classes self.events = events + self.id = id } public var body: Content { @@ -54,6 +55,10 @@ public struct Button: View, Modifiable, Actionable { } } } + + public func tag(_ value: String) -> Button { + return self.mutate(id: value) + } } extension Button: ButtonModifier { @@ -82,20 +87,16 @@ extension Button: ButtonModifier { extension Button: PressEvent { - public func tag(_ value: String) -> Button { - return self.mutate(id: value) - } - - public func onClick(@StringBuilder action: (ViewAction) -> [String]) -> Button { - return self.mutate(clickevent: action(self)) + public func onClick(@ActionBuilder action: (ViewAction) -> [Action]) -> Button { + return self.mutate(clickevent: action(.init())) } - public func onTap(@StringBuilder action: (ViewAction) -> [String]) -> Button { - return self.mutate(tapevent: action(self)) + public func onTap(@ActionBuilder action: (ViewAction) -> [Action]) -> Button { + return self.mutate(tapevent: action(.init())) } - public func onPress(@StringBuilder action: (ViewAction) -> [String]) -> Button { - return self.mutate(pressevent: action(self)) + public func onPress(@ActionBuilder action: (ViewAction) -> [Action]) -> Button { + return self.mutate(pressevent: action(.init())) } } @@ -152,7 +153,9 @@ extension Button: ViewModifier { } /// A component that initiates an action. -public struct LinkButton: View, Modifiable { +public struct LinkButton: View, Modifiable, Identifiable { + + public var id: String? internal let target: HTMLKit.Values.Target @@ -187,13 +190,14 @@ public struct LinkButton: View, Modifiable { } /// Creates a action button. - internal init(destination: String, target: HTMLKit.Values.Target, content: [Content], classes: [String], events: [String]?) { + internal init(destination: String, target: HTMLKit.Values.Target, content: [Content], classes: [String], events: [String]?, id: String?) { self.destination = destination self.target = target self.content = content self.classes = classes self.events = events + self.id = id } public var body: Content { @@ -204,6 +208,13 @@ public struct LinkButton: View, Modifiable { .target(target) .class(self.classes.joined(separator: " ")) .role(.button) + .modify(unwrap: id) { + $0.id($1) + } + } + + public func tag(_ value: String) -> LinkButton { + return self.mutate(id: value) } } diff --git a/Sources/HTMLKitComponents/Components/Card.swift b/Sources/HTMLKitComponents/Components/Card.swift index 6426ce0b..7df07863 100644 --- a/Sources/HTMLKitComponents/Components/Card.swift +++ b/Sources/HTMLKitComponents/Components/Card.swift @@ -6,7 +6,9 @@ import HTMLKit /// A component that distinguish content. -public struct Card: View, Modifiable { +public struct Card: View, Modifiable, Identifiable { + + public var id: String? /// The header of the card. public var header: [Content]? @@ -34,11 +36,12 @@ public struct Card: View, Modifiable { } /// Creates a card. - internal init(header: [Content]?, content: [Content], classes: [String]) { + internal init(header: [Content]?, content: [Content], classes: [String], id: String?) { self.header = header self.content = content self.classes = classes + self.id = id } public var body: Content { @@ -53,6 +56,13 @@ public struct Card: View, Modifiable { .class("card-body") } .class(classes.joined(separator: " ")) + .modify(unwrap: id) { + $0.id($1) + } + } + + public func tag(_ value: String) -> Card { + return self.mutate(id: value) } } diff --git a/Sources/HTMLKitComponents/Components/Carousel.swift b/Sources/HTMLKitComponents/Components/Carousel.swift index c3c484e0..f117d7d2 100644 --- a/Sources/HTMLKitComponents/Components/Carousel.swift +++ b/Sources/HTMLKitComponents/Components/Carousel.swift @@ -6,32 +6,29 @@ import HTMLKit /// A compnonent that cycles through an amount of views. -public struct Carousel: View { +public struct Carousel: View, Identifiable, Modifiable { - /// The indication for the carousel. - internal var indication: [Content] + public var id: String? /// The content of the carousel. - internal var content: [Content] + internal var content: [Identifiable] /// The classes of the carousel. internal var classes: [String] /// Creates a carousel. - public init(@ContentBuilder content: () -> [Content], - @ContentBuilder indication: () -> [Content]) { + public init(@ContentBuilder content: () -> [Identifiable]) { self.content = content() - self.indication = indication() self.classes = ["carousel"] } /// Creates a carousel. - internal init(indication: [Content], content: [Content], classes: [String]) { + internal init(content: [Identifiable], classes: [String], id: String?) { - self.indication = indication self.content = content self.classes = classes + self.id = id } public var body: Content { @@ -41,50 +38,104 @@ public struct Carousel: View { } .class("carousel-content") Division { - indication + for item in content { + Anchor { + } + .class("indicator") + .modify(unwrap: item.id) { + $0.reference("#" + $1) + } + } } .class("carousel-indication") } .class(classes.joined(separator: " ")) + .modify(unwrap: id) { + $0.id($1) + } + } + + public func tag(_ value: String) -> Carousel { + return self.mutate(id: value) } } -public struct Slide: View, Identifiable, Modifiable { +extension Carousel: ViewModifier { + + public func opacity(_ value: Tokens.OpacityValue) -> Carousel { + return self.mutate(opacity: value.value) + } + + public func zIndex(_ index: Tokens.PositionIndex) -> Carousel { + return self.mutate(zindex: index.value) + } + + public func hidden() -> Carousel { + return self.mutate(viewstate: Tokens.ViewState.hidden.value) + } + + public func hidden(_ condition: Bool) -> Carousel { + + if condition { + return self.mutate(viewstate: Tokens.ViewState.hidden.value) + } + + return self + } + + public func padding(insets: EdgeSet = .all, length: Tokens.PaddingLength = .small) -> Carousel { + return self.mutate(padding: length.value, insets: insets) + } + + public func borderColor(_ color: Tokens.BorderColor) -> Carousel { + return self.mutate(bordercolor: color.value) + } - internal var id: String? + public func borderShape(_ shape: Tokens.BorderShape) -> Carousel { + return self.mutate(bordershape: shape.value) + } + + public func backgroundColor(_ color: Tokens.BackgroundColor) -> Carousel { + return self.mutate(backgroundcolor: color.value) + } + + public func colorScheme(_ scheme: Tokens.ColorScheme) -> Carousel { + return self.mutate(scheme: scheme.value) + } - internal var source: String + public func frame(width: Tokens.ColumnSize, offset: Tokens.ColumnOffset? = nil) -> Carousel { + return mutate(frame: width.value, offset: offset?.value) + } + + public func margin(insets: EdgeSet = .all, length: Tokens.MarginLength = .small) -> Carousel { + return self.mutate(margin: length.value, insets: insets) + } +} + +public struct Slide: View, Identifiable, Modifiable { + + public var id: String? internal var classes: [String] - internal var caption: [Content] + internal var content: [Content] - public init(source: String, @ContentBuilder caption: () -> [Content]) { + public init(@ContentBuilder content: () -> [Content]) { - self.source = source - self.caption = caption() + self.content = content() self.classes = ["slide"] } - internal init(id: String?, source: String, caption: [Content], classes: [String]) { + internal init(id: String?, content: [Content], classes: [String]) { self.id = id - self.source = source - self.caption = caption + self.content = content self.classes = classes } public var body: Content { Division { - Division { - HTMLKit.Image() - .source(source) - } - .class("slide-thumbnail") - Division { - caption - } - .class("slide-caption") + content } .class(classes.joined(separator: " ")) .modify(unwrap: id) { @@ -97,18 +148,54 @@ public struct Slide: View, Identifiable, Modifiable { } } -public struct Indicator: View { +extension Slide: ViewModifier { + + public func opacity(_ value: Tokens.OpacityValue) -> Slide { + return self.mutate(opacity: value.value) + } - internal var tag: String + public func zIndex(_ index: Tokens.PositionIndex) -> Slide { + return self.mutate(zindex: index.value) + } - public init(for tag: String) { - self.tag = "#" + tag + public func hidden() -> Slide { + return self.mutate(viewstate: Tokens.ViewState.hidden.value) } - public var body: Content { - Anchor { + public func hidden(_ condition: Bool) -> Slide { + + if condition { + return self.mutate(viewstate: Tokens.ViewState.hidden.value) } - .class("indicator") - .reference(tag) + + return self + } + + public func padding(insets: EdgeSet = .all, length: Tokens.PaddingLength = .small) -> Slide { + return self.mutate(padding: length.value, insets: insets) + } + + public func borderColor(_ color: Tokens.BorderColor) -> Slide { + return self.mutate(bordercolor: color.value) + } + + public func borderShape(_ shape: Tokens.BorderShape) -> Slide { + return self.mutate(bordershape: shape.value) + } + + public func backgroundColor(_ color: Tokens.BackgroundColor) -> Slide { + return self.mutate(backgroundcolor: color.value) + } + + public func colorScheme(_ scheme: Tokens.ColorScheme) -> Slide { + return self.mutate(scheme: scheme.value) + } + + public func frame(width: Tokens.ColumnSize, offset: Tokens.ColumnOffset? = nil) -> Slide { + return mutate(frame: width.value, offset: offset?.value) + } + + public func margin(insets: EdgeSet = .all, length: Tokens.MarginLength = .small) -> Slide { + return self.mutate(margin: length.value, insets: insets) } } diff --git a/Sources/HTMLKitComponents/Components/Dropdown.swift b/Sources/HTMLKitComponents/Components/Dropdown.swift index 4cbf1ddf..767f73e4 100644 --- a/Sources/HTMLKitComponents/Components/Dropdown.swift +++ b/Sources/HTMLKitComponents/Components/Dropdown.swift @@ -6,7 +6,9 @@ import HTMLKit /// A component that displays a list of actions. -public struct Dropdown: View, Modifiable { +public struct Dropdown: View, Modifiable, Identifiable { + + public var id: String? /// The label for the dropdown. internal var label: [Content] @@ -26,11 +28,12 @@ public struct Dropdown: View, Modifiable { } /// Creates a dropdown. - internal init(label: [Content], content: [Content], classes: [String]) { + internal init(label: [Content], content: [Content], classes: [String], id: String?) { self.label = label self.content = content self.classes = classes + self.id = id } public var body: Content { @@ -45,6 +48,13 @@ public struct Dropdown: View, Modifiable { .class("dropdown-content") } .class(classes.joined(separator: " ")) + .modify(unwrap: id) { + $0.id($1) + } + } + + public func tag(_ value: String) -> Dropdown { + return self.mutate(id: value) } } diff --git a/Sources/HTMLKitComponents/Components/Form.swift b/Sources/HTMLKitComponents/Components/Form.swift index d2974539..c4a1ca14 100644 --- a/Sources/HTMLKitComponents/Components/Form.swift +++ b/Sources/HTMLKitComponents/Components/Form.swift @@ -9,7 +9,7 @@ import HTMLKit public struct Form: View, Actionable { /// The identifier of the form. - internal var id: String? + public var id: String? internal var method: HTMLKit.Values.Method @@ -60,16 +60,16 @@ public struct Form: View, Actionable { } } } -} - -extension Form: FormEvent { - + public func tag(_ value: String) -> Form { return self.mutate(id: value) } +} + +extension Form: FormEvent { - public func onSubmit(@StringBuilder action: (SubmitAction) -> [String]) -> Form { - return self.mutate(submitevent: action(self)) + public func onSubmit(@ActionBuilder action: (SubmitAction) -> [Action]) -> Form { + return self.mutate(submitevent: action(.init())) } } @@ -115,7 +115,9 @@ public struct FieldLabel: View { } /// A component that displays an editable form control. -public struct TextField: View, Modifiable { +public struct TextField: View, Modifiable, Identifiable { + + public var id: String? /// The identifier of the field. internal let name: String @@ -142,21 +144,24 @@ public struct TextField: View, Modifiable { } /// Creates a text field. - internal init(name: String, prompt: String?, value: String?, classes: [String], events: [String]?) { + internal init(name: String, prompt: String?, value: String?, classes: [String], events: [String]?, id: String?) { self.name = name self.prompt = prompt self.value = value self.classes = classes self.events = events + self.id = id } public var body: Content { Input() .type(.text) - .id(name) .name(name) .class(classes.joined(separator: " ")) + .modify(unwrap: id) { + $0.id($1) + } .modify(unwrap: value) { $0.value($1) } @@ -164,6 +169,10 @@ public struct TextField: View, Modifiable { $0.placeholder($1) } } + + public func tag(_ value: String) -> TextField { + return self.mutate(id: value) + } } extension TextField: InputModifier { @@ -235,7 +244,9 @@ extension TextField: ViewModifier { } /// A component that displays a editable and expandable form control. -public struct TextEditor: View, Modifiable { +public struct TextEditor: View, Modifiable, Identifiable { + + public var id: String? /// The identifier of the editor. internal let name: String @@ -265,7 +276,7 @@ public struct TextEditor: View, Modifiable { } /// Creates a text editor. - internal init(name: String, prompt: String?, rows: Int, content: [String], classes: [String], events: [String]?) { + internal init(name: String, prompt: String?, rows: Int, content: [String], classes: [String], events: [String]?, id: String?) { self.name = name self.prompt = prompt @@ -273,14 +284,17 @@ public struct TextEditor: View, Modifiable { self.content = content self.classes = classes self.events = events + self.id = id } public var body: Content { TextArea { content } - .id(name) .name(name) + .modify(unwrap: id) { + $0.id($1) + } .class(classes.joined(separator: " ")) .rows(rows) .modify(unwrap: prompt) { @@ -296,6 +310,10 @@ public struct TextEditor: View, Modifiable { return newSelf } + + public func tag(_ value: String) -> TextEditor { + return self.mutate(id: value) + } } extension TextEditor: InputModifier { @@ -366,7 +384,9 @@ extension TextEditor: ViewModifier { } } -public struct Picker: View, Modifiable { +public struct Picker: View, Modifiable, Identifiable { + + public var id: String? internal let name: String @@ -392,6 +412,13 @@ public struct Picker: View, Modifiable { } } .class(classes.joined(separator: " ")) + .modify(unwrap: id) { + $0.id($1) + } + } + + public func tag(_ value: String) -> Picker { + return self.mutate(id: value) } } @@ -399,7 +426,7 @@ public struct Picker: View, Modifiable { public struct CheckField: View, Modifiable, Selectable, Identifiable { /// The identifer for the label. - internal var id: String? + public var id: String? /// The identifier for the field. public var name: String? @@ -459,8 +486,8 @@ public struct CheckField: View, Modifiable, Selectable, Identifiable { .class(classes.joined(separator: " ")) } - public func tag(_ identifier: String) -> CheckField { - self.mutate(id: identifier) + public func tag(_ value: String) -> CheckField { + self.mutate(id: value) } } @@ -536,7 +563,7 @@ extension CheckField: ViewModifier { public struct RadioSelect: View, Modifiable, Selectable, Identifiable { /// The identifier for the label. - internal var id: String? + public var id: String? /// The identifier of the select. public var name: String? @@ -596,8 +623,8 @@ public struct RadioSelect: View, Modifiable, Selectable, Identifiable { .class(classes.joined(separator: " ")) } - public func tag(_ identifier: String) -> RadioSelect { - self.mutate(id: identifier) + public func tag(_ value: String) -> RadioSelect { + self.mutate(id: value) } } @@ -670,7 +697,9 @@ extension RadioSelect: ViewModifier { } /// A component that displays -public struct SelectField: View, Modifiable { +public struct SelectField: View, Modifiable, Identifiable { + + public var id: String? /// The identifier of the field. internal let name: String @@ -696,13 +725,14 @@ public struct SelectField: View, Modifiable { } /// Creates a select field. - internal init(name: String, selection: String?, content: [Selectable], classes: [String], events: [String]?) { + internal init(name: String, selection: String?, content: [Selectable], classes: [String], events: [String]?, id: String?) { self.name = name self.selection = selection self.content = content self.classes = classes self.events = events + self.id = id } public var body: Content { @@ -719,6 +749,13 @@ public struct SelectField: View, Modifiable { .class("selectfield-optionlist") } .class(classes.joined(separator: " ")) + .modify(unwrap: id) { + $0.id($1) + } + } + + public func tag(_ value: String) -> SelectField { + return self.mutate(id: value) } } @@ -791,7 +828,9 @@ extension SelectField: ViewModifier { } /// A component that displays -public struct SecureField: View, Modifiable { +public struct SecureField: View, Modifiable, Identifiable { + + public var id: String? /// The identifier of the field. internal let name: String @@ -818,20 +857,23 @@ public struct SecureField: View, Modifiable { } /// Creates a password field. - internal init(name: String, prompt: String?, value: String?, classes: [String], events: [String]?) { + internal init(name: String, prompt: String?, value: String?, classes: [String], events: [String]?, id: String?) { self.name = name self.prompt = prompt self.value = value self.classes = classes self.events = events + self.id = id } public var body: Content { Input() .type(.password) - .id(name) .name(name) + .modify(unwrap: id) { + $0.id($1) + } .class(classes.joined(separator: " ")) .modify(unwrap: value) { $0.value($1) @@ -840,6 +882,10 @@ public struct SecureField: View, Modifiable { $0.placeholder($1) } } + + public func tag(_ value: String) -> SecureField { + return self.mutate(id: value) + } } extension SecureField: InputModifier { @@ -911,7 +957,9 @@ extension SecureField: ViewModifier { } /// A component that displays -public struct Slider: View, Modifiable { +public struct Slider: View, Modifiable, Identifiable { + + public var id: String? /// The identifier of the slider. internal let name: String @@ -930,19 +978,26 @@ public struct Slider: View, Modifiable { } /// Creates a slider. - internal init(name: String, classes: [String], events: [String]?) { + internal init(name: String, classes: [String], events: [String]?, id: String?) { self.name = name self.classes = classes self.events = events + self.id = id } public var body: Content { Input() .type(.range) - .id(name) .name(name) .class(classes.joined(separator: " ")) + .modify(unwrap: id) { + $0.id($1) + } + } + + public func tag(_ value: String) -> Slider { + return self.mutate(id: value) } } @@ -1015,7 +1070,9 @@ extension Slider: ViewModifier { } /// A component that displays -public struct DatePicker: View, Modifiable { +public struct DatePicker: View, Modifiable, Identifiable { + + public var id: String? /// The identifier of the picker. internal let name: String @@ -1038,12 +1095,13 @@ public struct DatePicker: View, Modifiable { } /// Creates a date picker. - internal init(name: String, value: String?, classes: [String], events: [String]?) { + internal init(name: String, value: String?, classes: [String], events: [String]?, id: String?) { self.name = name self.value = value self.classes = classes self.events = events + self.id = id } public var body: Content { @@ -1051,7 +1109,6 @@ public struct DatePicker: View, Modifiable { Input() .type(.text) .class("datepicker-datefield") - .id(name) .name(name) .modify(unwrap: value) { $0.value($1) @@ -1059,6 +1116,9 @@ public struct DatePicker: View, Modifiable { self.calendar } .class(classes.joined(separator: " ")) + .modify(unwrap: id) { + $0.id($1) + } } public var calendar: Content { @@ -1206,7 +1266,9 @@ extension DatePicker: ViewModifier { } /// A component that displays -public struct SearchField: View, Modifiable { +public struct SearchField: View, Modifiable, Identifiable { + + public var id: String? /// The identifier of the search field. internal let name: String @@ -1233,20 +1295,23 @@ public struct SearchField: View, Modifiable { } /// Creates a search field. - internal init(name: String, prompt: String?, value: String?, classes: [String], events: [String]?) { + internal init(name: String, prompt: String?, value: String?, classes: [String], events: [String]?, id: String?) { self.name = name self.prompt = prompt self.value = value self.classes = classes self.events = events + self.id = id } public var body: Content { Input() .type(.search) - .id(name) .name(name) + .modify(unwrap: id) { + $0.id($1) + } .class(classes.joined(separator: " ")) .modify(unwrap: value) { $0.value($1) @@ -1255,6 +1320,10 @@ public struct SearchField: View, Modifiable { $0.placeholder($1) } } + + public func tag(_ value: String) -> SearchField { + return self.mutate(id: value) + } } extension SearchField: InputModifier { @@ -1326,7 +1395,9 @@ extension SearchField: ViewModifier { } /// A component that displays the progress of a task. -public struct Progress: View { +public struct Progress: View, Identifiable { + + public var id: String? internal let maximum: Float @@ -1351,13 +1422,14 @@ public struct Progress: View { } /// Creates a progress bar. - internal init(maximum: Float, value: String, content: [Content], classes: [String], events: [String]?) { + internal init(maximum: Float, value: String, content: [Content], classes: [String], events: [String]?, id: String?) { self.maximum = maximum self.value = value self.content = content self.classes = classes self.events = events + self.id = id } public var body: Content { @@ -1367,11 +1439,20 @@ public struct Progress: View { .value(value) .maximum(maximum) .class(classes.joined(separator: " ")) + .modify(unwrap: id) { + $0.id($1) + } + } + + public func tag(_ value: String) -> Progress { + return self.mutate(id: value) } } /// A component to edit and format text content. -public struct TextPad: View, Modifiable { +public struct TextPad: View, Modifiable, Identifiable { + + public var id: String? /// The identifier of the textpad. internal let name: String @@ -1398,13 +1479,14 @@ public struct TextPad: View, Modifiable { } /// Creates a textpad. - internal init(name: String, prompt: String?, rows: Int, content: [String], classes: [String]) { + internal init(name: String, prompt: String?, rows: Int, content: [String], classes: [String], id: String?) { self.name = name self.prompt = prompt self.rows = rows self.content = content self.classes = classes + self.id = id } public var body: Content { @@ -1455,12 +1537,14 @@ public struct TextPad: View, Modifiable { TextArea { content } - .id(name) .name(name) .rows(rows) .class("textpad-content") } .class(classes.joined(separator: " ")) + .modify(unwrap: id) { + $0.id($1) + } } /// Sets the limit of the maximum lines. @@ -1471,6 +1555,10 @@ public struct TextPad: View, Modifiable { return newSelf } + + public func tag(_ value: String) -> TextPad { + return self.mutate(id: value) + } } extension TextPad: InputModifier { @@ -1542,7 +1630,9 @@ extension TextPad: ViewModifier { } /// A component that displays -public struct FileDialog: View, Modifiable { +public struct FileDialog: View, Modifiable, Identifiable { + + public var id: String? /// The identifier of the search field. internal let name: String @@ -1561,19 +1651,26 @@ public struct FileDialog: View, Modifiable { } /// Creates a search field. - internal init(name: String, classes: [String], events: [String]?) { + internal init(name: String, classes: [String], events: [String]?, id: String?) { self.name = name self.classes = classes self.events = events + self.id = id } public var body: Content { Input() .type(.file) - .id(name) .name(name) .class(classes.joined(separator: " ")) + .modify(unwrap: id) { + $0.id($1) + } + } + + public func tag(_ value: String) -> FileDialog { + return self.mutate(id: value) } } diff --git a/Sources/HTMLKitComponents/Components/Grid.swift b/Sources/HTMLKitComponents/Components/Grid.swift index 24d3323e..93da189c 100644 --- a/Sources/HTMLKitComponents/Components/Grid.swift +++ b/Sources/HTMLKitComponents/Components/Grid.swift @@ -8,7 +8,7 @@ import HTMLKit /// A component that collects and arranges collection items horizontally. public struct Grid: View, Modifiable, Actionable { - internal var id: String? + public var id: String? /// The content of the collection. internal var content: [Content] @@ -57,20 +57,20 @@ public struct Grid: View, Modifiable, Actionable { return newSelf } -} - -extension Grid: MouseEvent, ViewAction { public func tag(_ value: String) -> Grid { return self.mutate(id: value) } +} + +extension Grid: MouseEvent { - public func onHover(@StringBuilder action: (ViewAction) -> [String]) -> Grid { - return self.mutate(hoverevent: action(self)) + public func onHover(@ActionBuilder action: (ViewAction) -> [Action]) -> Grid { + return self.mutate(hoverevent: action(.init())) } - public func onLeave(@StringBuilder action: (ViewAction) -> [String]) -> Grid { - return self.mutate(leaveevent: action(self)) + public func onLeave(@ActionBuilder action: (ViewAction) -> [Action]) -> Grid { + return self.mutate(leaveevent: action(.init())) } } diff --git a/Sources/HTMLKitComponents/Components/Grouping.swift b/Sources/HTMLKitComponents/Components/Grouping.swift index 29ad1f29..9d401db2 100644 --- a/Sources/HTMLKitComponents/Components/Grouping.swift +++ b/Sources/HTMLKitComponents/Components/Grouping.swift @@ -6,7 +6,9 @@ import HTMLKit /// A component that collects content. -public struct Grouping: View, Modifiable { +public struct Grouping: View, Modifiable, Identifiable { + + public var id: String? /// The content of the group. internal var content: [Content] @@ -22,10 +24,11 @@ public struct Grouping: View, Modifiable { } /// Creates a group. - internal init(content: [Content], classes: [String]) { + internal init(content: [Content], classes: [String], id: String?) { self.content = content self.classes = classes + self.id = id } public var body: Content { @@ -33,6 +36,9 @@ public struct Grouping: View, Modifiable { content } .class(classes.joined(separator: " ")) + .modify(unwrap: id) { + $0.id($1) + } } public func frame(width: Tokens.ColumnSize, offset: Tokens.ColumnOffset? = nil) -> Grouping { @@ -47,6 +53,10 @@ public struct Grouping: View, Modifiable { return newSelf } + + public func tag(_ value: String) -> Grouping { + return self.mutate(id: value) + } } extension Grouping: TextModifier { diff --git a/Sources/HTMLKitComponents/Components/Image.swift b/Sources/HTMLKitComponents/Components/Image.swift index db26dd09..4010cfe5 100644 --- a/Sources/HTMLKitComponents/Components/Image.swift +++ b/Sources/HTMLKitComponents/Components/Image.swift @@ -5,7 +5,9 @@ import HTMLKit -public struct Image: View, Modifiable { +public struct Image: View, Modifiable, Identifiable { + + public var id: String? /// The url path of the image. internal let source: DynamicType @@ -28,10 +30,11 @@ public struct Image: View, Modifiable { } /// Creates a image view. - internal init(source: String, classes: [String]) { + internal init(source: String, classes: [String], id: String?) { self.source = .string(source) self.classes = classes + self.id = id } public var body: Content { @@ -39,6 +42,13 @@ public struct Image: View, Modifiable { .source(source) .role(.img) .class(classes.joined(separator: " ")) + .modify(unwrap: id) { + $0.id($1) + } + } + + public func tag(_ value: String) -> Image { + return self.mutate(id: value) } } diff --git a/Sources/HTMLKitComponents/Components/Link.swift b/Sources/HTMLKitComponents/Components/Link.swift index a66aaa81..d43f616c 100644 --- a/Sources/HTMLKitComponents/Components/Link.swift +++ b/Sources/HTMLKitComponents/Components/Link.swift @@ -7,7 +7,9 @@ import HTMLKit import Foundation /// A component that navigates to an target. -public struct Link: View, Modifiable { +public struct Link: View, Modifiable, Identifiable { + + public var id: String? /// The target for the destination internal let target: HTMLKit.Values.Target @@ -43,13 +45,14 @@ public struct Link: View, Modifiable { } /// Creates a link. - internal init(destination: String, target: HTMLKit.Values.Target, content: [Content], classes: [String], events: [String]?) { + internal init(destination: String, target: HTMLKit.Values.Target, content: [Content], classes: [String], events: [String]?, id: String?) { self.destination = destination self.target = target self.content = content self.classes = classes self.events = events + self.id = id } public var body: Content { @@ -59,6 +62,13 @@ public struct Link: View, Modifiable { .reference(destination) .target(target) .class(classes.joined(separator: " ")) + .modify(unwrap: id) { + $0.id($1) + } + } + + public func tag(_ value: String) -> Link { + return self.mutate(id: value) } } diff --git a/Sources/HTMLKitComponents/Components/List.swift b/Sources/HTMLKitComponents/Components/List.swift index 0fb22189..d5cdd36d 100644 --- a/Sources/HTMLKitComponents/Components/List.swift +++ b/Sources/HTMLKitComponents/Components/List.swift @@ -8,7 +8,7 @@ import HTMLKit /// A component that collects and arranges list items vertically. public struct List: View, Modifiable, Actionable { - internal var id: String? + public var id: String? /// The content of the list. internal var content: [ListElement] @@ -57,20 +57,20 @@ public struct List: View, Modifiable, Actionable { return newSelf } -} - -extension List: MouseEvent, ViewAction { public func tag(_ value: String) -> List { return self.mutate(id: value) } +} + +extension List: MouseEvent { - public func onHover(@StringBuilder action: (ViewAction) -> [String]) -> List { - return self.mutate(hoverevent: action(self)) + public func onHover(@ActionBuilder action: (ViewAction) -> [Action]) -> List { + return self.mutate(hoverevent: action(.init())) } - public func onLeave(@StringBuilder action: (ViewAction) -> [String]) -> List { - return self.mutate(leaveevent: action(self)) + public func onLeave(@ActionBuilder action: (ViewAction) -> [Action]) -> List { + return self.mutate(leaveevent: action(.init())) } } @@ -129,7 +129,7 @@ extension List: ViewModifier { /// A component that represents a list item. public struct ListRow: View, Modifiable, Actionable { - internal var id: String? + public var id: String? /// The content of the row. internal var content: [Content] @@ -206,19 +206,19 @@ public struct ListRow: View, Modifiable, Actionable { return self.mutate(classes: classes) } -} - -extension ListRow: MouseEvent, ViewAction { public func tag(_ value: String) -> ListRow { return self.mutate(id: value) } +} + +extension ListRow: MouseEvent { - public func onHover(@StringBuilder action: (ViewAction) -> [String]) -> ListRow { - return self.mutate(hoverevent: action(self)) + public func onHover(@ActionBuilder action: (ViewAction) -> [Action]) -> ListRow { + return self.mutate(hoverevent: action(.init())) } - public func onLeave(@StringBuilder action: (ViewAction) -> [String]) -> ListRow { - return self.mutate(leaveevent: action(self)) + public func onLeave(@ActionBuilder action: (ViewAction) -> [Action]) -> ListRow { + return self.mutate(leaveevent: action(.init())) } } diff --git a/Sources/HTMLKitComponents/Components/Modal.swift b/Sources/HTMLKitComponents/Components/Modal.swift index 52dd4bf1..67aae330 100644 --- a/Sources/HTMLKitComponents/Components/Modal.swift +++ b/Sources/HTMLKitComponents/Components/Modal.swift @@ -8,7 +8,7 @@ import HTMLKit /// A component that presents a dialog on top of other views. public struct Modal: View, Modifiable, Actionable { - internal var id: String? + public var id: String? /// The content of the modal. internal var content: [Content] diff --git a/Sources/HTMLKitComponents/Components/Navigation.swift b/Sources/HTMLKitComponents/Components/Navigation.swift index 5eb1fc12..640d4985 100644 --- a/Sources/HTMLKitComponents/Components/Navigation.swift +++ b/Sources/HTMLKitComponents/Components/Navigation.swift @@ -1,6 +1,8 @@ import HTMLKit -public struct Navigation: View, Modifiable { +public struct Navigation: View, Modifiable, Identifiable { + + public var id: String? internal var content: [BodyElement] @@ -12,10 +14,11 @@ public struct Navigation: View, Modifiable { self.classes = ["navigation"] } - internal init(content: [BodyElement], classes: [String]) { + internal init(content: [BodyElement], classes: [String], id: String?) { self.content = content self.classes = classes + self.id = id } public var body: Content { @@ -23,6 +26,9 @@ public struct Navigation: View, Modifiable { content } .class(classes.joined(separator: " ")) + .modify(unwrap: id) { + $0.id($1) + } } /// Sets the style for the list. @@ -33,6 +39,10 @@ public struct Navigation: View, Modifiable { return newSelf } + + public func tag(_ value: String) -> Navigation { + return self.mutate(id: value) + } } extension Navigation: ViewModifier { diff --git a/Sources/HTMLKitComponents/Components/Snippet.swift b/Sources/HTMLKitComponents/Components/Snippet.swift index 2295ef79..2b17da5b 100644 --- a/Sources/HTMLKitComponents/Components/Snippet.swift +++ b/Sources/HTMLKitComponents/Components/Snippet.swift @@ -6,7 +6,9 @@ import HTMLKit /// A component that displays code content. -public struct Snippet: View, Modifiable { +public struct Snippet: View, Modifiable, Identifiable { + + public var id: String? /// The content of the snippet. internal var content: [Content] @@ -30,10 +32,11 @@ public struct Snippet: View, Modifiable { } /// Creates a snippet. - internal init(content: [Content], classes: [String]) { + internal init(content: [Content], classes: [String], id: String?) { self.content = content self.classes = classes + self.id = id } public var body: Content { @@ -41,6 +44,13 @@ public struct Snippet: View, Modifiable { content } .class(classes.joined(separator: " ")) + .modify(unwrap: id) { + $0.id($1) + } + } + + public func tag(_ value: String) -> Snippet { + return self.mutate(id: value) } } diff --git a/Sources/HTMLKitComponents/Components/Stack.swift b/Sources/HTMLKitComponents/Components/Stack.swift index 9a716cb0..c09cce86 100644 --- a/Sources/HTMLKitComponents/Components/Stack.swift +++ b/Sources/HTMLKitComponents/Components/Stack.swift @@ -9,7 +9,7 @@ import HTMLKit public struct HStack: View, Actionable, Modifiable { /// The identifier of the text. - internal var id: String? + public var id: String? /// The content of the stack. internal var content: [Content] @@ -59,20 +59,20 @@ public struct HStack: View, Actionable, Modifiable { return newSelf } -} - -extension HStack: MouseEvent { public func tag(_ value: String) -> HStack { return self.mutate(id: value) } +} + +extension HStack: MouseEvent { - public func onHover(@StringBuilder action: (ViewAction) -> [String]) -> HStack { - return self.mutate(hoverevent: action(self)) + public func onHover(@ActionBuilder action: (ViewAction) -> [Action]) -> HStack { + return self.mutate(hoverevent: action(.init())) } - public func onLeave(@StringBuilder action: (ViewAction) -> [String]) -> HStack { - return self.mutate(leaveevent: action(self)) + public func onLeave(@ActionBuilder action: (ViewAction) -> [Action]) -> HStack { + return self.mutate(leaveevent: action(.init())) } } @@ -131,7 +131,7 @@ extension HStack: ViewModifier { /// A component that arranges content vertically. public struct VStack: View, Actionable, Modifiable { - internal var id: String? + public var id: String? /// The content of the stack. internal var content: [Content] @@ -180,20 +180,20 @@ public struct VStack: View, Actionable, Modifiable { return newSelf } -} - -extension VStack: MouseEvent { public func tag(_ value: String) -> VStack { return self.mutate(id: value) } +} + +extension VStack: MouseEvent { - public func onHover(@StringBuilder action: (ViewAction) -> [String]) -> VStack { - return self.mutate(hoverevent: action(self)) + public func onHover(@ActionBuilder action: (ViewAction) -> [Action]) -> VStack { + return self.mutate(hoverevent: action(.init())) } - public func onLeave(@StringBuilder action: (ViewAction) -> [String]) -> VStack { - return self.mutate(leaveevent: action(self)) + public func onLeave(@ActionBuilder action: (ViewAction) -> [Action]) -> VStack { + return self.mutate(leaveevent: action(.init())) } } @@ -252,7 +252,7 @@ extension VStack: ViewModifier { /// A component that overlays content. public struct ZStack: View, Actionable, Modifiable { - internal var id: String? + public var id: String? /// The content of the stack. internal var content: [Content] @@ -292,20 +292,20 @@ public struct ZStack: View, Actionable, Modifiable { } } } -} - -extension ZStack: MouseEvent { public func tag(_ value: String) -> ZStack { return self.mutate(id: value) } +} + +extension ZStack: MouseEvent { - public func onHover(@StringBuilder action: (ViewAction) -> [String]) -> ZStack { - return self.mutate(hoverevent: action(self)) + public func onHover(@ActionBuilder action: (ViewAction) -> [Action]) -> ZStack { + return self.mutate(hoverevent: action(.init())) } - public func onLeave(@StringBuilder action: (ViewAction) -> [String]) -> ZStack { - return self.mutate(leaveevent: action(self)) + public func onLeave(@ActionBuilder action: (ViewAction) -> [Action]) -> ZStack { + return self.mutate(leaveevent: action(.init())) } } diff --git a/Sources/HTMLKitComponents/Components/Text.swift b/Sources/HTMLKitComponents/Components/Text.swift index 5246ddc2..088de96f 100644 --- a/Sources/HTMLKitComponents/Components/Text.swift +++ b/Sources/HTMLKitComponents/Components/Text.swift @@ -8,7 +8,7 @@ import HTMLKit /// A component that displays text. public struct Text: View, Actionable, Modifiable { - internal var id: String? + public var id: String? /// The content of the text. internal var content: [Content] @@ -54,35 +54,35 @@ public struct Text: View, Actionable, Modifiable { } } } -} - -extension Text: MouseEvent { public func tag(_ value: String) -> Text { return self.mutate(id: value) } +} + +extension Text: MouseEvent { - public func onHover(@StringBuilder action: (ViewAction) -> [String]) -> Text { - return self.mutate(hoverevent: action(self)) + public func onHover(@ActionBuilder action: (ViewAction) -> [Action]) -> Text { + return self.mutate(hoverevent: action(.init())) } - public func onLeave(@StringBuilder action: (ViewAction) -> [String]) -> Text { - return self.mutate(leaveevent: action(self)) + public func onLeave(@ActionBuilder action: (ViewAction) -> [Action]) -> Text { + return self.mutate(leaveevent: action(.init())) } } extension Text: PressEvent { - public func onClick(@StringBuilder action: (ViewAction) -> [String]) -> Text { - return self.mutate(clickevent: action(self)) + public func onClick(@ActionBuilder action: (ViewAction) -> [Action]) -> Text { + return self.mutate(clickevent: action(.init())) } - public func onTap(@StringBuilder action: (ViewAction) -> [String]) -> Text { - return self.mutate(tapevent: action(self)) + public func onTap(@ActionBuilder action: (ViewAction) -> [Action]) -> Text { + return self.mutate(tapevent: action(.init())) } - public func onPress(@StringBuilder action: (ViewAction) -> [String]) -> Text { - return self.mutate(pressevent: action(self)) + public func onPress(@ActionBuilder action: (ViewAction) -> [Action]) -> Text { + return self.mutate(pressevent: action(.init())) } } @@ -224,14 +224,3 @@ extension Text: ViewModifier { return self.mutate(margin: length.value, insets: insets) } } - -extension Text: ViewAction { - - public func show(_ target: String) -> String { - return "$('#\(target)').show();" - } - - public func open(_ target: String) -> String { - return "$('#\(target)').open();" - } -} diff --git a/Sources/HTMLKitComponents/Events/DragEvent.swift b/Sources/HTMLKitComponents/Events/DragEvent.swift index 306b1e48..c96f3353 100644 --- a/Sources/HTMLKitComponents/Events/DragEvent.swift +++ b/Sources/HTMLKitComponents/Events/DragEvent.swift @@ -4,21 +4,21 @@ */ /// A type that describes the modifier of a draggable component. -public protocol DragEvent: ViewAction { +public protocol DragEvent { /// The identifier of the component. func tag(_ value: String) -> Self /// Acts on a drag event. - func onDrag(@StringBuilder action: (ViewAction) -> [String]) -> Self + func onDrag(@ActionBuilder action: (ViewAction) -> [Action]) -> Self /// Acts on a drop event - func onDrop(@StringBuilder action: (ViewAction) -> [String]) -> Self + func onDrop(@ActionBuilder action: (ViewAction) -> [Action]) -> Self } extension DragEvent where Self: Actionable { - internal func mutate(dragevent actions: [String]) -> Self { + internal func mutate(dragevent actions: [Action]) -> Self { guard let identifier = self.id else { fatalError("Initiative identifier unkown.") @@ -26,14 +26,14 @@ extension DragEvent where Self: Actionable { let event = """ $('#\(identifier)').onDrag(function(){\ - \(actions.joined())\ + \(actions.map { $0.description }.joined())\ }); """ return self.mutate(event: event) } - internal func mutate(dropevent actions: [String]) -> Self { + internal func mutate(dropevent actions: [Action]) -> Self { guard let identifier = self.id else { fatalError("Initiative identifier unkown.") @@ -41,7 +41,7 @@ extension DragEvent where Self: Actionable { let event = """ $('#\(identifier)').onDrop(function(){\ - \(actions.joined())\ + \(actions.map { $0.description }.joined())\ }); """ diff --git a/Sources/HTMLKitComponents/Events/FormEvent.swift b/Sources/HTMLKitComponents/Events/FormEvent.swift index a283415d..4440314a 100644 --- a/Sources/HTMLKitComponents/Events/FormEvent.swift +++ b/Sources/HTMLKitComponents/Events/FormEvent.swift @@ -4,24 +4,24 @@ */ /// A type that describes the modifier of a form component. -public protocol FormEvent: SubmitAction { +public protocol FormEvent { /// The identifier of the component. func tag(_ value: String) -> Self /// Acts on a submit event. - func onSubmit(@StringBuilder action: (SubmitAction) -> [String]) -> Self + func onSubmit(@ActionBuilder action: (SubmitAction) -> [Action]) -> Self } extension FormEvent where Self: Actionable { - internal func mutate(submitevent actions: [String]) -> Self { + internal func mutate(submitevent actions: [Action]) -> Self { var validation = false for action in actions { - if action.contains("validate") { + if action.description.contains("validate") { validation = true } } @@ -33,7 +33,7 @@ extension FormEvent where Self: Actionable { let event = """ $('#\(identifier)').onSubmit(function(){\ event.preventDefault();\ - \(actions.joined())\ + \(actions.map { $0.description }.joined())\ },\(validation)); """ diff --git a/Sources/HTMLKitComponents/Events/MouseEvent.swift b/Sources/HTMLKitComponents/Events/MouseEvent.swift index d34e2d60..2862e845 100644 --- a/Sources/HTMLKitComponents/Events/MouseEvent.swift +++ b/Sources/HTMLKitComponents/Events/MouseEvent.swift @@ -4,21 +4,21 @@ */ /// A type that describes the modifier of a hoverable component. -public protocol MouseEvent: ViewAction { +public protocol MouseEvent { /// The identifier of the component. func tag(_ value: String) -> Self /// Acts on a hover event. - func onHover(@StringBuilder action: (ViewAction) -> [String]) -> Self + func onHover(@ActionBuilder action: (ViewAction) -> [Action]) -> Self /// Acts on a leave event. - func onLeave(@StringBuilder action: (ViewAction) -> [String]) -> Self + func onLeave(@ActionBuilder action: (ViewAction) -> [Action]) -> Self } extension MouseEvent where Self: Actionable { - internal func mutate(hoverevent actions: [String]) -> Self { + internal func mutate(hoverevent actions: [Action]) -> Self { guard let identifier = self.id else { fatalError("Initiative identifier unkown.") @@ -26,14 +26,14 @@ extension MouseEvent where Self: Actionable { let event = """ $('#\(identifier)').onHover(function(){\ - \(actions.joined())\ + \(actions.map { $0.description }.joined())\ }); """ return self.mutate(event: event) } - internal func mutate(leaveevent actions: [String]) -> Self { + internal func mutate(leaveevent actions: [Action]) -> Self { guard let identifier = self.id else { fatalError("Initiative identifier unkown.") @@ -41,7 +41,7 @@ extension MouseEvent where Self: Actionable { let event = """ $('#\(identifier)').onLeave(function(){\ - \(actions.joined())\ + \(actions.map { $0.description }.joined())\ }); """ diff --git a/Sources/HTMLKitComponents/Events/PressEvent.swift b/Sources/HTMLKitComponents/Events/PressEvent.swift index eb1a4472..dac47f11 100644 --- a/Sources/HTMLKitComponents/Events/PressEvent.swift +++ b/Sources/HTMLKitComponents/Events/PressEvent.swift @@ -4,24 +4,24 @@ */ /// A type thats describes the modifier of a pressable component. -public protocol PressEvent: ViewAction { +public protocol PressEvent { /// The identifier of the component. func tag(_ value: String) -> Self /// Acts on a click event. - func onClick(@StringBuilder action: (ViewAction) -> [String]) -> Self + func onClick(@ActionBuilder action: (ViewAction) -> [Action]) -> Self /// Acts on a tap event. - func onTap(@StringBuilder action: (ViewAction) -> [String]) -> Self + func onTap(@ActionBuilder action: (ViewAction) -> [Action]) -> Self /// Acts on a press event. - func onPress(@StringBuilder action: (ViewAction) -> [String]) -> Self + func onPress(@ActionBuilder action: (ViewAction) -> [Action]) -> Self } extension PressEvent where Self: Actionable { - internal func mutate(clickevent actions: [String]) -> Self { + internal func mutate(clickevent actions: [Action]) -> Self { guard let identifier = self.id else { fatalError("Initiative identifier unkown.") @@ -29,14 +29,14 @@ extension PressEvent where Self: Actionable { let event = """ $('#\(identifier)').onClick(function(){\ - \(actions.joined())\ + \(actions.map { $0.description }.joined())\ }); """ return self.mutate(event: event) } - internal func mutate(tapevent actions: [String]) -> Self { + internal func mutate(tapevent actions: [Action]) -> Self { guard let identifier = self.id else { fatalError("Initiative identifier unkown.") @@ -44,14 +44,14 @@ extension PressEvent where Self: Actionable { let event = """ $('#\(identifier)').onTapGesture(function(){\ - \(actions.joined())\ + \(actions.map { $0.description }.joined())\ }); """ return self.mutate(event: event) } - internal func mutate(pressevent actions: [String]) -> Self { + internal func mutate(pressevent actions: [Action]) -> Self { guard let identifier = self.id else { fatalError("Initiative identifier unkown.") @@ -59,7 +59,7 @@ extension PressEvent where Self: Actionable { let event = """ $('#\(identifier)').onLongPressGesture(function(){\ - \(actions.joined())\ + \(actions.map { $0.description }.joined())\ }); """ diff --git a/Sources/HTMLKitComponents/Primitives/Action.swift b/Sources/HTMLKitComponents/Primitives/Action.swift new file mode 100644 index 00000000..99a04d8f --- /dev/null +++ b/Sources/HTMLKitComponents/Primitives/Action.swift @@ -0,0 +1,11 @@ +public protocol Action { + + var actions: [String] { get set } +} + +extension Action { + + public var description: String { + return actions.joined() + } +} diff --git a/Sources/HTMLKitComponents/Properties/Identifiable.swift b/Sources/HTMLKitComponents/Properties/Identifiable.swift index 955ee72d..c69f1a9c 100644 --- a/Sources/HTMLKitComponents/Properties/Identifiable.swift +++ b/Sources/HTMLKitComponents/Properties/Identifiable.swift @@ -1,6 +1,6 @@ /// A type that describes a component with an identifier. -internal protocol Identifiable { +public protocol Identifiable { /// The identifier of the component. var id: String? { get set } diff --git a/Sources/HTMLKitComponents/Resources/css/globals.css b/Sources/HTMLKitComponents/Resources/css/globals.css index 4de9fe3b..c3231413 100644 --- a/Sources/HTMLKitComponents/Resources/css/globals.css +++ b/Sources/HTMLKitComponents/Resources/css/globals.css @@ -287,95 +287,115 @@ video { */ .border\:black { + --borderWidth: 1px !important; --borderColor: var(--blackColor) !important; + --borderOpacity: 1.0 !important; } .border\:blue { + --borderWidth: 1px !important; --borderColor: var(--blueColor) !important; + --borderOpacity: 1.0 !important; } .border\:brown { --borderWidth: 1px !important; --borderColor: var(--brownColor) !important; + --borderOpacity: 1.0 !important; } .border\:cyan { --borderWidth: 1px !important; --borderColor: var(--cyanColor) !important; + --borderOpacity: 1.0 !important; } .border\:gray { --borderWidth: 1px !important; --borderColor: var(--grayColor) !important; + --borderOpacity: 1.0 !important; } .border\:green { --borderWidth: 1px !important; --borderColor: var(--greenColor) !important; + --borderOpacity: 1.0 !important; } .border\:indigo { --borderWidth: 1px !important; --borderColor: var(--indigoColor) !important; + --borderOpacity: 1.0 !important; } .border\:mint { --borderWidth: 1px !important; --borderColor: var(--mintColor) !important; + --borderOpacity: 1.0 !important; } .border\:orange { --borderWidth: 1px !important; --borderColor: var(--orangeColor) !important; + --borderOpacity: 1.0 !important; } .border\:pink { --borderWidth: 1px !important; --borderColor: var(--pinkColor) !important; + --borderOpacity: 1.0 !important; } .border\:purple { --borderWidth: 1px !important; --borderColor: var(--purpleColor) !important; + --borderOpacity: 1.0 !important; } .border\:red { --borderWidth: 1px !important; --borderColor: var(--redColor) !important; + --borderOpacity: 1.0 !important; } .border\:teal { --borderWidth: 1px !important; --borderColor: var(--tealColor) !important; + --borderOpacity: 1.0 !important; } .border\:white { --borderWidth: 1px !important; --borderColor: var(--whiteColor) !important; + --borderOpacity: 1.0 !important; } .border\:yellow { --borderWidth: 1px !important; --borderColor: var(--yellowColor) !important; + --borderOpacity: 1.0 !important; } .border\:silver { --borderWidth: 1px !important; --borderColor: var(--silverColor) !important; + --borderOpacity: 1.0 !important; } .border\:primary { --borderWidth: 1px !important; --borderColor: var(--primaryColor) !important; + --borderOpacity: 1.0 !important; } .border\:secondary { --borderWidth: 1px !important; --borderColor: var(--secondaryColor) !important; + --borderOpacity: 1.0 !important; } .border\:transparent { - --borderOpacity: 0.0; + --borderOpacity: 0.0 !important; } /* @@ -384,78 +404,96 @@ video { .background\:black { --backgroundColor: var(--blackColor) !important; + --backgroundOpacity: 1.0 !important; } .background\:blue { --backgroundColor: var(--blueColor) !important; + --backgroundOpacity: 1.0 !important; } .background\:brown { --backgroundColor: var(--brownColor) !important; + --backgroundOpacity: 1.0 !important; } .background\:cyan { --backgroundColor: var(--cyanColor) !important; + --backgroundOpacity: 1.0 !important; } .background\:gray { --backgroundColor: var(--grayColor) !important; + --backgroundOpacity: 1.0 !important; } .background\:green { --backgroundColor: var(--greenColor) !important; + --backgroundOpacity: 1.0 !important; } .background\:indigo { --backgroundColor: var(--indigoColor) !important; + --backgroundOpacity: 1.0 !important; } .background\:mint { --backgroundColor: var(--mintColor) !important; + --backgroundOpacity: 1.0 !important; } .background\:orange { --backgroundColor: var(--orangeColor) !important; + --backgroundOpacity: 1.0 !important; } .background\:pink { --backgroundColor: var(--pinkColor) !important; + --backgroundOpacity: 1.0 !important; } .background\:purple { --backgroundColor: var(--purpleColor) !important; + --backgroundOpacity: 1.0 !important; } .background\:red { --backgroundColor: var(--redColor) !important; + --backgroundOpacity: 1.0 !important; } .background\:teal { --backgroundColor: var(--tealColor) !important; + --backgroundOpacity: 1.0 !important; } .background\:white { --backgroundColor: var(--whiteColor) !important; + --backgroundOpacity: 1.0 !important; } .background\:yellow { --backgroundColor: var(--yellowColor) !important; + --backgroundOpacity: 1.0 !important; } .background\:silver { --backgroundColor: var(--silverColor) !important; + --backgroundOpacity: 1.0 !important; } .background\:primary { --backgroundColor: var(--primaryColor) !important; + --backgroundOpacity: 1.0 !important; } .background\:secondary { --backgroundColor: var(--secondaryColor) !important; + --backgroundOpacity: 1.0 !important; } .background\:transparent { - --backgroundOpacity: 0.0; + --backgroundOpacity: 0.0 !important; } /* diff --git a/Sources/HTMLKitComponents/Resources/css/layout/grid.css b/Sources/HTMLKitComponents/Resources/css/layout/grid.css index ecf7251f..fa9b0778 100644 --- a/Sources/HTMLKitComponents/Resources/css/layout/grid.css +++ b/Sources/HTMLKitComponents/Resources/css/layout/grid.css @@ -7,6 +7,8 @@ --paddingInlineEnd: 0; --paddingBlockStart: 0; --paddingBlockEnd: 0; + --backgroundColor: 0, 0%, 0%; + --backgroundOpacity: 0.0; position: relative; inline-size: 100%; @@ -15,6 +17,7 @@ padding-block-end: var(--paddingBlockEnd); padding-inline-start: var(--paddingInlineStart); padding-inline-end: var(--paddingInlineEnd); + background-color: hsla(var(--backgroundColor), var(--backgroundOpacity)); } .grid.ratio\:fit { @@ -69,6 +72,10 @@ justify-content: space-evenly; } +.grid.space\:center { + justify-content: center; +} + .grid.space\:large { gap: 2.25rem; } diff --git a/Sources/HTMLKitComponents/Resources/css/layout/list.css b/Sources/HTMLKitComponents/Resources/css/layout/list.css index a53ef22e..c299dd03 100644 --- a/Sources/HTMLKitComponents/Resources/css/layout/list.css +++ b/Sources/HTMLKitComponents/Resources/css/layout/list.css @@ -7,6 +7,8 @@ --paddingBlockEnd: 0; --paddingInlineStart: 0; --paddingInlineEnd: 0; + --backgroundColor: 0, 0%, 0%; + --backgroundOpacity: 0.0; display: flex; padding-block-start: var(--paddingBlockStart); @@ -14,6 +16,7 @@ padding-inline-start: var(--paddingInlineStart); padding-inline-end: var(--paddingInlineEnd); list-style-type: none; + background-color: hsla(var(--backgroundColor), var(--backgroundOpacity)); } .list.direction\:horizontal { diff --git a/Sources/HTMLKitComponents/Resources/css/layout/stack.css b/Sources/HTMLKitComponents/Resources/css/layout/stack.css index 7cc88c58..4a7e32e1 100644 --- a/Sources/HTMLKitComponents/Resources/css/layout/stack.css +++ b/Sources/HTMLKitComponents/Resources/css/layout/stack.css @@ -7,6 +7,8 @@ --paddingInlineEnd: 0; --paddingBlockStart: 0; --paddingBlockEnd: 0; + --backgroundColor: 0, 0%, 0%; + --backgroundOpacity: 0.0; position: relative; inline-size: 100%; @@ -17,6 +19,7 @@ padding-block-end: var(--paddingBlockEnd); padding-inline-start: var(--paddingInlineStart); padding-inline-end: var(--paddingInlineEnd); + background-color: hsla(var(--backgroundColor), var(--backgroundOpacity)); } .hstack.alignment\:top { @@ -47,6 +50,10 @@ justify-content: space-evenly; } +.hstack.space\:center { + justify-content: center; +} + .hstack.space\:large { gap: 2.25rem; } @@ -68,6 +75,8 @@ --paddingInlineEnd: 0; --paddingBlockStart: 0; --paddingBlockEnd: 0; + --backgroundColor: 0, 0%, 0%; + --backgroundOpacity: 0.0; position: relative; inline-size: 100%; @@ -77,6 +86,7 @@ padding-block-end: var(--paddingBlockEnd); padding-inline-start: var(--paddingInlineStart); padding-inline-end: var(--paddingInlineEnd); + background-color: hsla(var(--backgroundColor), var(--backgroundOpacity)); } .vstack.alignment\:leading { @@ -103,6 +113,10 @@ justify-content: space-evenly; } +.vstack.space\:center { + justify-content: center; +} + .vstack.space\:large { gap: 2.25rem; } @@ -124,6 +138,8 @@ --paddingInlineEnd: 0; --paddingBlockStart: 0; --paddingBlockEnd: 0; + --backgroundColor: 0, 0%, 0%; + --backgroundOpacity: 0.0; position: absolute; inset: 0; @@ -133,4 +149,5 @@ padding-block-end: var(--paddingBlockEnd); padding-inline-start: var(--paddingInlineStart); padding-inline-end: var(--paddingInlineEnd); + background-color: hsla(var(--backgroundColor), var(--backgroundOpacity)); } diff --git a/Sources/HTMLKitComponents/Resources/css/typography/link.css b/Sources/HTMLKitComponents/Resources/css/typography/link.css index 3cab5f03..1d2a45e0 100644 --- a/Sources/HTMLKitComponents/Resources/css/typography/link.css +++ b/Sources/HTMLKitComponents/Resources/css/typography/link.css @@ -9,7 +9,7 @@ font-family: var(--fontFamily); font-size: var(--fontSize); - font-weight: var(--fontHeight); + font-weight: var(--fontWeight); line-height: var(--lineHeight); color: hsla(var(--foregroundColor), 1.0); text-decoration: none; diff --git a/Sources/HTMLKitComponents/Resources/css/views/carousel.css b/Sources/HTMLKitComponents/Resources/css/views/carousel.css index c56d05f8..bd11b624 100644 --- a/Sources/HTMLKitComponents/Resources/css/views/carousel.css +++ b/Sources/HTMLKitComponents/Resources/css/views/carousel.css @@ -1,22 +1,14 @@ /* - The rulesets for the carousel component. - - default: - container height: 400px; - border width: 1px; - border color:; - background color:; - - darkmode: - border color:; - background color:; + The stylesheet for the carousel component. */ .carousel { --borderWidth: 1px; - --borderRadius: 10px; - --borderColor: 0, 0%, 0%; - --backgroundColor: transparent; + --borderColor: 210, 14%, 89%; + --borderRadius: 0; + --borderOpacity: 1.0; + --backgroundColor: 0, 0%, 100%; + --backgroundOpacity: 1.0; display: flex; flex-direction: column; @@ -31,8 +23,9 @@ block-size: 350px; border-width: var(--borderWidth); border-style: solid; - border-color: hsla(var(--borderColor), 1.0); - background-color: hsla(var(--backgroundColor), 1.0); + border-color: hsla(var(--borderColor), var(--borderOpacity)); + border-radius: var(--borderRadius); + background-color: hsla(var(--backgroundColor), var(--backgroundOpacity)); overflow: hidden; } @@ -40,28 +33,6 @@ display: none; } -.slide { - display: flex; - block-size: auto; - overflow: hidden; -} - -.slide-thumbnail { - inline-size: 60%; -} - -.slide-thumbnail > img { - inline-size: 100%; - blocks-ize: 100%; - object-fit: cover; -} - -.slide-caption { - inline-size: 40%; - padding-block: 24px; - padding-inline: 24px; -} - .carousel-indication { display: flex; align-items: center; @@ -71,27 +42,31 @@ } .scheme\:dark .carousel, .carousel.scheme\:dark { - --borderColor: var(--blackColor); - --backgroundColor: transparent; + --borderColor: 210, 9%, 31%; + --backgroundColor: 210, 11%, 15%; +} + +.slide { + --backgroundColor: 0, 0%, 100%; + --backgroundOpacity: 1.0; + + position: relative; + display: flex; + block-size: inherit; + overflow: hidden; + background-color: hsla(var(--backgroundColor), var(--backgroundOpacity)); } /* indicator component - - border width:; - border radius:; - border color:; - background color:; - - darkmode: - border color:; - background color:; */ .indicator { --borderRadius: 5px; - --backgroundColor: transparent; - --borderColor: #000000; + --borderColor: 210, 14%, 89%; + --borderOpacity: 1.0; + --backgroundColor: 210, 14%, 89%; + --backgroundOpacity: 1.0; position: relative; display: inline-block; @@ -99,9 +74,9 @@ block-size: 6px; border-width: 1px; border-style: solid; - border-color: hsla(var(--borderColor), 1.0); + border-color: hsla(var(--borderColor), var(--borderOpacity)); border-radius: var(--borderRadius); - background-color: hsla(var(--backgroundColor), 1.0); + background-color: hsla(var(--backgroundColor), var(--backgroundOpacity)); cursor: pointer; } @@ -111,6 +86,6 @@ } .scheme\:dark .indicator, .indicator.scheme\:dark { - --backgroundColor: transparent; - --borderColor: #000000; + --borderColor: 210, 9%, 31%; + --backgroundColor: 210, 11%, 15%; } diff --git a/Sources/HTMLKitComponents/Resources/css/views/divider.css b/Sources/HTMLKitComponents/Resources/css/views/divider.css index f2215430..161d2b8c 100644 --- a/Sources/HTMLKitComponents/Resources/css/views/divider.css +++ b/Sources/HTMLKitComponents/Resources/css/views/divider.css @@ -10,13 +10,14 @@ .divider { --backgroundColor: 210, 14%, 89%; + --backgroundOpacity: 1.0; position: relative; display: block; inline-size: 100%; block-size: 1px; border-width: 0; - background-color: hsla(var(--backgroundColor), 1.0); + background-color: hsla(var(--backgroundColor), var(--backgroundOpacity)); } .scheme\:dark .divider, .divider.scheme\:dark { diff --git a/Sources/HTMLKitComponents/Resources/css/views/dropdown.css b/Sources/HTMLKitComponents/Resources/css/views/dropdown.css index 4703c192..ed21c905 100644 --- a/Sources/HTMLKitComponents/Resources/css/views/dropdown.css +++ b/Sources/HTMLKitComponents/Resources/css/views/dropdown.css @@ -57,7 +57,7 @@ border-style: solid; border-color: hsla(var(--borderColor), 1.0); border-radius: var(--borderRadius); - background-color: hsla(var(--backgroundColor), 1.0); + background-color: hsla(var(--backgroundColor), var(--backgroundOpacity)); overflow: hidden; } diff --git a/Sources/HTMLKitComponents/Resources/css/views/image.css b/Sources/HTMLKitComponents/Resources/css/views/image.css index ddb4938d..e37e180f 100644 --- a/Sources/HTMLKitComponents/Resources/css/views/image.css +++ b/Sources/HTMLKitComponents/Resources/css/views/image.css @@ -13,14 +13,19 @@ --inlineSize: 100%; --borderWidth: 0; --borderRadius: 0; + --borderColor: 0, 0%, 0%; + --borderOpacity: 0.0; + --backgroundColor: 0, 0%, 0%; + --backgroundOpacity: 0.0; position: relative; max-inline-size: var(--inlineSize); height: auto; border-width: var(--borderWidth); border-style: solid; - border-color: hsla(var(--borderColor), 1.0); + border-color: hsla(var(--borderColor), var(--borderOpacity)); border-radius: var(--borderRadius); + background-color: hsla(var(--backgroundColor), var(--backgroundOpacity)); } .image.aspect\:equal { diff --git a/Sources/HTMLKitComponents/Resources/css/views/navigation.css b/Sources/HTMLKitComponents/Resources/css/views/navigation.css index 525043ed..8db7cdf7 100644 --- a/Sources/HTMLKitComponents/Resources/css/views/navigation.css +++ b/Sources/HTMLKitComponents/Resources/css/views/navigation.css @@ -3,7 +3,19 @@ */ .navigation { + --borderWidth: 0; + --borderColor: 0, 0%, 0%; + --borderOpacity: 0,0; + --borderRadius: 0; + --backgroundColor: 0, 0%, 0%; + --backgroundOpacity: 0.0; + position: relative; + border-width: var(--borderWidth); + border-style: solid; + border-color: hsla(var(--borderColor), var(--borderOpacity)); + border-radius: var(--borderRadius); + background-color: hsla(var(--backgroundColor), var(--backgroundOpacity)); } .navigation > .list > .list-row > .link { @@ -30,12 +42,6 @@ --borderOpacity: 1.0; --backgroundColor: 0, 0%, 100%; --backgroundOpacity: 1.0; - - border-width: var(--borderWidth); - border-style: solid; - border-color: hsla(var(--borderColor), var(--borderOpacity)); - border-radius: var(--borderRadius); - background-color: hsla(var(--backgroundColor), var(--backgroundOpacity)); } .navigation.style\:pagination > .list > .list-row > .link { diff --git a/Sources/HTMLKitComponents/Resources/css/views/scrollview.css b/Sources/HTMLKitComponents/Resources/css/views/scrollview.css index 842e2a16..f9119440 100644 --- a/Sources/HTMLKitComponents/Resources/css/views/scrollview.css +++ b/Sources/HTMLKitComponents/Resources/css/views/scrollview.css @@ -15,6 +15,7 @@ grid-auto-columns: min-content; max-width: 100%; overflow-x: auto; + overflow-y: hidden; overscroll-behavior-inline: contain; } @@ -22,6 +23,7 @@ grid-auto-flow: row; grid-auto-rows: min-content; max-height: 100%; + overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: contain; } diff --git a/Sources/HTMLKitComponents/Resources/css/views/snippet.css b/Sources/HTMLKitComponents/Resources/css/views/snippet.css index 4ca6c422..5dfd50bb 100644 --- a/Sources/HTMLKitComponents/Resources/css/views/snippet.css +++ b/Sources/HTMLKitComponents/Resources/css/views/snippet.css @@ -19,13 +19,15 @@ --fontWeight: 400; --lineHeight: 1.5; --foregroundColor: 0, 0%, 0%; + --backgroundColor: 0, 0%, 0%; + --backgroundOpacity: 0.0; position: relative; display: block; inline-size: 100%; block-size: auto; counter-reset: line; - background-color: hsla(var(--backgroundColor), 1.0); + background-color: hsla(var(--backgroundColor), var(--backgroundOpacity)); overflow-inline: auto; } diff --git a/Sources/HTMLKitComponents/Tokens.swift b/Sources/HTMLKitComponents/Tokens.swift index 72163f76..3abbc1c7 100644 --- a/Sources/HTMLKitComponents/Tokens.swift +++ b/Sources/HTMLKitComponents/Tokens.swift @@ -951,10 +951,10 @@ public enum Tokens { case around case between case evenly + case center case large case medium case small - case custom(String) var value: String { @@ -968,6 +968,9 @@ public enum Tokens { case .evenly: return "evenly" + case .center: + return "center" + case .large: return "large" diff --git a/Sources/HTMLKitConverter/Parser.swift b/Sources/HTMLKitConverter/Parser.swift index 4c00d5d3..3da2a129 100644 --- a/Sources/HTMLKitConverter/Parser.swift +++ b/Sources/HTMLKitConverter/Parser.swift @@ -129,6 +129,9 @@ internal class Parser { case "ul": return try ContentElement(element: element, indent: indent).build(verbatim: "UnorderedList") + case "menu": + return try ContentElement(element: element, indent: indent).build() + case "dl": return try ContentElement(element: element, indent: indent).build(verbatim: "DescriptionList") @@ -150,6 +153,9 @@ internal class Parser { case "main": return try ContentElement(element: element, indent: indent).build() + case "search": + return try ContentElement(element: element, indent: indent).build() + case "div": return try ContentElement(element: element, indent: indent).build(verbatim: "Division") @@ -796,6 +802,33 @@ internal class Parser { case "xmlns": return try ValueAttribute(node: node).build(verbatim: "namespace") + case "inert": + return try EmptyAttribute(node: node).build() + + case "fetchpriority": + return try TypeAttribute(node: node).build(verbatim: "fetchPriority") + + case "loading": + return try TypeAttribute(node: node).build() + + case "decoding": + return try TypeAttribute(node: node).build() + + case "srcset": + return try ValueAttribute(node: node).build(verbatim: "sourceSet") + + case "blocking": + return try TypeAttribute(node: node).build() + + case "popover": + return try TypeAttribute(node: node).build() + + case "popovertarget": + return try ValueAttribute(node: node).build(verbatim: "popoverTarget") + + case "popovertargetaction": + return try TypeAttribute(node: node).build(verbatim: "popoverAction") + case "onafterprint": return try EventAttribute(node: node).build() diff --git a/Tests/HTMLKitComponentsTests/ComponentTests.swift b/Tests/HTMLKitComponentsTests/ComponentTests.swift index 8aa8ad88..d8db5bc3 100644 --- a/Tests/HTMLKitComponentsTests/ComponentTests.swift +++ b/Tests/HTMLKitComponentsTests/ComponentTests.swift @@ -103,7 +103,7 @@ final class ComponentTests: XCTestCase { XCTAssertEqual(try renderer.render(view: view), """ - + """ ) } @@ -118,7 +118,7 @@ final class ComponentTests: XCTestCase { XCTAssertEqual(try renderer.render(view: view), """ - + """ ) } @@ -131,7 +131,7 @@ final class ComponentTests: XCTestCase { XCTAssertEqual(try renderer.render(view: view), """ - + """ ) } @@ -145,7 +145,7 @@ final class ComponentTests: XCTestCase { XCTAssertEqual(try renderer.render(view: view), """
\ - \ + \
\
    \
  • \ @@ -190,7 +190,7 @@ final class ComponentTests: XCTestCase { XCTAssertEqual(try renderer.render(view: view), """ - + """ ) } @@ -275,7 +275,7 @@ final class ComponentTests: XCTestCase { XCTAssertEqual(try renderer.render(view: view), """ - + """ ) } @@ -443,50 +443,26 @@ final class ComponentTests: XCTestCase { func testCarousel() throws { let view = TestView { - Carousel {} indication: {} + Carousel { + Slide {} + .tag("slide") + } } XCTAssertEqual(try renderer.render(view: view), """ - """ - ) - } - - func testSlide() throws { - - let view = TestView { - Slide(source: "#") {} - } - - XCTAssertEqual(try renderer.render(view: view), - """ -
    \ -
    \ - \ + \ + \ -
    \
    """ ) } - func testIndicator() throws { - - let view = TestView { - Indicator(for: "example") - } - - XCTAssertEqual(try renderer.render(view: view), - """ - - """ - ) - } - func testDropdown() throws { let view = TestView { diff --git a/Tests/HTMLKitComponentsTests/InteractionTests.swift b/Tests/HTMLKitComponentsTests/InteractionTests.swift index d19d2f19..3e9a03e3 100644 --- a/Tests/HTMLKitComponentsTests/InteractionTests.swift +++ b/Tests/HTMLKitComponentsTests/InteractionTests.swift @@ -18,8 +18,8 @@ final class InteractionTests: XCTestCase { "Example" } .tag("sender") - .onClick { text in - text.show("reciever") + .onClick { action in + action.show("reciever") } } @@ -42,8 +42,8 @@ final class InteractionTests: XCTestCase { "Example" } .tag("sender") - .onTap { text in - text.hide("reciever") + .onTap { action in + action.hide("reciever") } } @@ -66,8 +66,8 @@ final class InteractionTests: XCTestCase { "Example" } .tag("sender") - .onHover { text in - text.open("reciever") + .onHover { action in + action.open("reciever") } } @@ -90,8 +90,8 @@ final class InteractionTests: XCTestCase { "Example" } .tag("sender") - .onLeave { text in - text.close("reciever") + .onLeave { action in + action.close("reciever") } } @@ -114,8 +114,8 @@ final class InteractionTests: XCTestCase { "Example" } .tag("sender") - .onPress { text in - text.animate("reciever") + .onPress { action in + action.animate("reciever") } } @@ -137,8 +137,8 @@ final class InteractionTests: XCTestCase { Form(method: .post) { } .tag("sender") - .onSubmit { form in - form.validate("test", [Validator(field: "testfield", rule: .value)]) + .onSubmit { action in + action.validate("test", [Validator(field: "testfield", rule: .value)]) } } diff --git a/Tests/HTMLKitComponentsTests/ModifierTests.swift b/Tests/HTMLKitComponentsTests/ModifierTests.swift index 25d485d0..16806a1f 100644 --- a/Tests/HTMLKitComponentsTests/ModifierTests.swift +++ b/Tests/HTMLKitComponentsTests/ModifierTests.swift @@ -279,7 +279,7 @@ final class ModifierTests: XCTestCase { XCTAssertEqual(try renderer.render(view: view), """ - + """ ) } diff --git a/Tests/HTMLKitTests/AttributesTests.swift b/Tests/HTMLKitTests/AttributesTests.swift index df680ea7..09920d4d 100644 --- a/Tests/HTMLKitTests/AttributesTests.swift +++ b/Tests/HTMLKitTests/AttributesTests.swift @@ -14,7 +14,7 @@ final class AttributesTests: XCTestCase { @ContentBuilder var body: Content } - typealias AllAttributes = AccessKeyAttribute & AcceptAttribute & ActionAttribute & AlternateAttribute & AsynchronouslyAttribute & AutocapitalizeAttribute & AutocompleteAttribute & AutofocusAttribute & AutoplayAttribute & CharsetAttribute & CheckedAttribute & CiteAttribute & ClassAttribute & ColumnsAttribute & ColumnSpanAttribute & ContentAttribute & EditAttribute & ControlsAttribute & CoordinatesAttribute & DataAttribute & DateTimeAttribute & DefaultAttribute & DeferAttribute & DirectionAttribute & DisabledAttribute & DownloadAttribute & DragAttribute & EncodingAttribute & EnterKeyHintAttribute & ForAttribute & FormAttribute & FormActionAttribute & EquivalentAttribute & HeaderAttribute & HeightAttribute & HiddenAttribute & HighAttribute & ReferenceAttribute & ReferenceLanguageAttribute & IdentifierAttribute & IsMapAttribute & InputModeAttribute & IsAttribute & ItemIdAttribute & ItemPropertyAttribute & ItemReferenceAttribute & ItemScopeAttribute & ItemTypeAttribute & KindAttribute & LabelAttribute & LanguageAttribute & ListAttribute & LoopAttribute & LowAttribute & MaximumValueAttribute & MaximumLengthAttribute & MediaAttribute & MethodAttribute & MinimumValueAttribute & MinimumLengthAttribute & MultipleAttribute & MutedAttribute & NameAttribute & NonceAttribute & NoValidateAttribute & OpenAttribute & OptimumAttribute & PatternAttribute & PartAttribute & PingAttribute & PlaceholderAttribute & PosterAttribute & PreloadAttribute & ReadyOnlyAttribute & ReferrerPolicyAttribute & RelationshipAttribute & RequiredAttribute & ReversedAttribute & RoleAttribute & RowsAttribute & RowSpanAttribute & SandboxAttribute & ScopeAttribute & ShapeAttribute & SizeAttribute & SizesAttribute & SlotAttribute & SpanAttribute & SpellCheckAttribute & SourceAttribute & StartAttribute & StepAttribute & StyleAttribute & TabulatorAttribute & TargetAttribute & TitleAttribute & TranslateAttribute & TypeAttribute & ValueAttribute & WidthAttribute & WrapAttribute & PropertyAttribute & SelectedAttribute & WindowEventAttribute & FocusEventAttribute & PointerEventAttribute & MouseEventAttribute & WheelEventAttribute & InputEventAttribute & KeyboardEventAttribute & DragEventAttribute & ClipboardEventAttribute & SelectionEventAttribute & MediaEventAttribute & FormEventAttribute & DetailEventAttribute & AriaAtomicAttribute & AriaBusyAttribute & AriaControlsAttribute & AriaCurrentAttribute & AriaDescribedAttribute & AriaDetailsAttribute & AriaDisabledAttribute & AriaErrorMessageAttribute & AriaFlowToAttribute & AriaPopupAttribute & AriaHiddenAttribute & AriaInvalidAttribute & AriaShortcutsAttribute & AriaLabelAttribute & AriaLabeledAttribute & AriaLiveAttribute & AriaOwnsAttribute & AriaRelevantAttribute & AriaRoleDescriptionAttribute & DrawAttribute & FillAttribute & FillOpacityAttribute & StrokeAttribute & StrokeWidthAttribute & StrokeOpacityAttribute & StrokeLineCapAttribute & StrokeLineJoinAttribute & RadiusAttribute & PositionPointAttribute & RadiusPointAttribute & CenterPointAttribute & ViewBoxAttribute & NamespaceAttribute & PointsAttribute & ShadowRootModeAttribute + typealias AllAttributes = AccessKeyAttribute & AcceptAttribute & ActionAttribute & AlternateAttribute & AsynchronouslyAttribute & AutocapitalizeAttribute & AutocompleteAttribute & AutofocusAttribute & AutoplayAttribute & CharsetAttribute & CheckedAttribute & CiteAttribute & ClassAttribute & ColumnsAttribute & ColumnSpanAttribute & ContentAttribute & EditAttribute & ControlsAttribute & CoordinatesAttribute & DataAttribute & DateTimeAttribute & DefaultAttribute & DeferAttribute & DirectionAttribute & DisabledAttribute & DownloadAttribute & DragAttribute & EncodingAttribute & EnterKeyHintAttribute & ForAttribute & FormAttribute & FormActionAttribute & EquivalentAttribute & HeaderAttribute & HeightAttribute & HiddenAttribute & HighAttribute & ReferenceAttribute & ReferenceLanguageAttribute & IdentifierAttribute & IsMapAttribute & InputModeAttribute & IsAttribute & ItemIdAttribute & ItemPropertyAttribute & ItemReferenceAttribute & ItemScopeAttribute & ItemTypeAttribute & KindAttribute & LabelAttribute & LanguageAttribute & ListAttribute & LoopAttribute & LowAttribute & MaximumValueAttribute & MaximumLengthAttribute & MediaAttribute & MethodAttribute & MinimumValueAttribute & MinimumLengthAttribute & MultipleAttribute & MutedAttribute & NameAttribute & NonceAttribute & NoValidateAttribute & OpenAttribute & OptimumAttribute & PatternAttribute & PartAttribute & PingAttribute & PlaceholderAttribute & PosterAttribute & PreloadAttribute & ReadyOnlyAttribute & ReferrerPolicyAttribute & RelationshipAttribute & RequiredAttribute & ReversedAttribute & RoleAttribute & RowsAttribute & RowSpanAttribute & SandboxAttribute & ScopeAttribute & ShapeAttribute & SizeAttribute & SizesAttribute & SlotAttribute & SpanAttribute & SpellCheckAttribute & SourceAttribute & StartAttribute & StepAttribute & StyleAttribute & TabulatorAttribute & TargetAttribute & TitleAttribute & TranslateAttribute & TypeAttribute & ValueAttribute & WidthAttribute & WrapAttribute & PropertyAttribute & SelectedAttribute & WindowEventAttribute & FocusEventAttribute & PointerEventAttribute & MouseEventAttribute & WheelEventAttribute & InputEventAttribute & KeyboardEventAttribute & DragEventAttribute & ClipboardEventAttribute & SelectionEventAttribute & MediaEventAttribute & FormEventAttribute & DetailEventAttribute & AriaAtomicAttribute & AriaBusyAttribute & AriaControlsAttribute & AriaCurrentAttribute & AriaDescribedAttribute & AriaDetailsAttribute & AriaDisabledAttribute & AriaErrorMessageAttribute & AriaFlowToAttribute & AriaPopupAttribute & AriaHiddenAttribute & AriaInvalidAttribute & AriaShortcutsAttribute & AriaLabelAttribute & AriaLabeledAttribute & AriaLiveAttribute & AriaOwnsAttribute & AriaRelevantAttribute & AriaRoleDescriptionAttribute & DrawAttribute & FillAttribute & FillOpacityAttribute & StrokeAttribute & StrokeWidthAttribute & StrokeOpacityAttribute & StrokeLineCapAttribute & StrokeLineJoinAttribute & RadiusAttribute & PositionPointAttribute & RadiusPointAttribute & CenterPointAttribute & ViewBoxAttribute & NamespaceAttribute & PointsAttribute & ShadowRootModeAttribute & InertAttribute & FetchPriorityAttribute & LoadingAttribute & SourceSetAttribute & DecodingAttribute & BlockingAttribute & PopoverAttribute & PopoverTargetAttribute & PopoverActionAttribute struct Tag: ContentNode, GlobalElement, AllAttributes { @@ -467,6 +467,10 @@ final class AttributesTests: XCTestCase { return mutate(source: value) } + func sourceSet(_ value: String) -> Tag { + return mutate(sourceset: value) + } + func start(_ size: Int) -> Tag { return self.mutate(start: size) } @@ -563,10 +567,38 @@ final class AttributesTests: XCTestCase { return self.mutate(points: value) } + func fetchPriority(_ value: Values.Priority) -> Tag { + return self.mutate(fetchpriority: value.rawValue) + } + + func loading(_ value: Values.Loading) -> Tag { + return self.mutate(loading: value.rawValue) + } + + func decoding(_ value: Values.Decoding) -> Tag { + return self.mutate(decoding: value.rawValue) + } + + func popover(_ value: Values.Popover.State) -> Tag { + return self.mutate(popover: value.rawValue) + } + + func popoverTarget(_ value: String) -> Tag { + return self.mutate(popovertarget: value) + } + + func popoverAction(_ value: Values.Popover.Action) -> Tag { + return self.mutate(popoveraction: value.rawValue) + } + func custom(key: String, value: Any) -> Tag { return self.mutate(key: key, value: value) } + func blocking(_ value: Values.Blocking) -> Tag { + return self.mutate(blocking: value.rawValue) + } + func on(event: Events.Window, _ value: String) -> Tag { return self.mutate(key: event.rawValue, value: value) } @@ -698,6 +730,19 @@ final class AttributesTests: XCTestCase { func shadowRootMode(_ value: Values.Shadow.Mode) -> Tag { return mutate(shadowrootmode: value.rawValue) } + + func inert() -> Tag { + return self.mutate(inert: "inert") + } + + public func inert(_ condition: Bool) -> Tag { + + if condition { + return mutate(inert: "inert") + } + + return self + } } var renderer = Renderer() @@ -1875,6 +1920,19 @@ final class AttributesTests: XCTestCase { ) } + func testSourceSetAttribute() throws { + + let view = TestView { + Tag {}.sourceSet("img2.png 100w, img3.png 500w") + } + + XCTAssertEqual(try renderer.render(view: view), + """ + + """ + ) + } + func testStartAttribute() throws { let view = TestView { @@ -1940,6 +1998,97 @@ final class AttributesTests: XCTestCase { ) } + func testFetchPriorityAttribute() throws { + + let view = TestView { + Tag {}.fetchPriority(.high) + } + + XCTAssertEqual(try renderer.render(view: view), + """ + + """ + ) + } + + func testLoadingAttribute() throws { + + let view = TestView { + Tag {}.loading(.lazy) + } + + XCTAssertEqual(try renderer.render(view: view), + """ + + """ + ) + } + + func testDecodingAttribute() throws { + + let view = TestView { + Tag {}.decoding(.async) + } + + XCTAssertEqual(try renderer.render(view: view), + """ + + """ + ) + } + + func testBlockingAttribute() throws { + + let view = TestView { + Tag {}.blocking(.render) + } + + XCTAssertEqual(try renderer.render(view: view), + """ + + """ + ) + } + + func testPopoverAttribute() throws { + + let view = TestView { + Tag {}.popover(.auto) + } + + XCTAssertEqual(try renderer.render(view: view), + """ + + """ + ) + } + + func testPopoverTargetAttribute() throws { + + let view = TestView { + Tag {}.popoverTarget("id") + } + + XCTAssertEqual(try renderer.render(view: view), + """ + + """ + ) + } + + func testPopoverActionAttribute() throws { + + let view = TestView { + Tag {}.popoverAction(.toggle) + } + + XCTAssertEqual(try renderer.render(view: view), + """ + + """ + ) + } + func testCustomAttribute() throws { let view = TestView { @@ -2576,4 +2725,24 @@ final class AttributesTests: XCTestCase { """ ) } + + func testInertAttribute() throws { + + let view = TestView { + // unconditionally + Tag {}.inert() + // with a false condition + Tag {}.inert(false) + // with a true condition + Tag {}.inert(true) + } + + XCTAssertEqual(try renderer.render(view: view), + """ + \ + \ + + """ + ) + } } diff --git a/Tests/HTMLKitTests/ElementTests.swift b/Tests/HTMLKitTests/ElementTests.swift index 21e6e5ea..b5cd45cc 100644 --- a/Tests/HTMLKitTests/ElementTests.swift +++ b/Tests/HTMLKitTests/ElementTests.swift @@ -405,6 +405,19 @@ final class ElementTests: XCTestCase { ) } + func testMenuElement() throws { + + let view = TestView { + Menu {} + } + + XCTAssertEqual(try renderer.render(view: view), + """ + + """ + ) + } + func testListItemElement() throws { let view = TestView { @@ -506,6 +519,19 @@ final class ElementTests: XCTestCase { ) } + func testSearchElement() throws { + + let view = TestView { + Search {} + } + + XCTAssertEqual(try renderer.render(view: view), + """ + + """ + ) + } + func testDivisionElement() throws { let view = TestView {