Skip to content

Commit 5987966

Browse files
authored
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
1 parent 676792d commit 5987966

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+3550
-448
lines changed

Sources/HTMLKit/Abstraction/Attributes/BasicAttributes.swift

Lines changed: 220 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import OrderedCollections
1010

1111
/// The alias combines the global attributes of the basic attributes.
12-
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
12+
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
1313

1414
/// The protocol provides the element with the accesskey handler.
1515
public protocol AccessKeyAttribute: Attribute {
@@ -2662,3 +2662,222 @@ extension ShadowRootModeAttribute where Self: ContentNode {
26622662
return self.mutate(key: "shadowrootmode", value: value)
26632663
}
26642664
}
2665+
2666+
/// The protocol provides the element with inhert handler.
2667+
public protocol InertAttribute: Attribute {
2668+
2669+
/// The function represents the html-attribute 'inert'.
2670+
///
2671+
/// ```html
2672+
/// <tag inert />
2673+
/// ```
2674+
func inert() -> Self
2675+
2676+
func inert(_ condition: Bool) -> Self
2677+
}
2678+
2679+
extension InertAttribute where Self: ContentNode {
2680+
2681+
internal func mutate(inert value: String) -> Self {
2682+
return self.mutate(key: "inert", value: value)
2683+
}
2684+
}
2685+
2686+
extension InertAttribute where Self: EmptyNode {
2687+
2688+
internal func mutate(inert value: String) -> Self {
2689+
return self.mutate(key: "inert", value: value)
2690+
}
2691+
}
2692+
2693+
public protocol FetchPriorityAttribute: Attribute {
2694+
2695+
/// The function represents the html-attribute 'shadowrootmode'.
2696+
///
2697+
/// ```html
2698+
/// <tag fetchpriority="" />
2699+
/// ```
2700+
func fetchPriority(_ value: Values.Priority) -> Self
2701+
}
2702+
2703+
extension FetchPriorityAttribute where Self: ContentNode {
2704+
2705+
internal func mutate(fetchpriority value: String) -> Self {
2706+
return self.mutate(key: "fetchpriority", value: value)
2707+
}
2708+
}
2709+
2710+
extension FetchPriorityAttribute where Self: EmptyNode {
2711+
2712+
internal func mutate(fetchpriority value: String) -> Self {
2713+
return self.mutate(key: "fetchpriority", value: value)
2714+
}
2715+
}
2716+
2717+
public protocol LoadingAttribute: Attribute {
2718+
2719+
/// The function represents the html-attribute 'loading'.
2720+
///
2721+
/// ```html
2722+
/// <tag loading="" />
2723+
/// ```
2724+
func loading(_ value: Values.Loading) -> Self
2725+
}
2726+
2727+
extension LoadingAttribute where Self: ContentNode {
2728+
2729+
internal func mutate(loading value: String) -> Self {
2730+
return self.mutate(key: "loading", value: value)
2731+
}
2732+
}
2733+
2734+
extension LoadingAttribute where Self: EmptyNode {
2735+
2736+
internal func mutate(loading value: String) -> Self {
2737+
return self.mutate(key: "loading", value: value)
2738+
}
2739+
}
2740+
2741+
public protocol SourceSetAttribute: Attribute {
2742+
2743+
/// The function represents the html-attribute 'loading'.
2744+
///
2745+
/// ```html
2746+
/// <tag srcset="" />
2747+
/// ```
2748+
func sourceSet(_ value: String) -> Self
2749+
}
2750+
2751+
extension SourceSetAttribute where Self: ContentNode {
2752+
2753+
internal func mutate(sourceset value: String) -> Self {
2754+
return self.mutate(key: "srcset", value: value)
2755+
}
2756+
}
2757+
2758+
extension SourceSetAttribute where Self: EmptyNode {
2759+
2760+
internal func mutate(sourceset value: String) -> Self {
2761+
return self.mutate(key: "srcset", value: value)
2762+
}
2763+
}
2764+
2765+
public protocol DecodingAttribute: Attribute {
2766+
2767+
/// The function represents the html-attribute 'decoding'.
2768+
///
2769+
/// ```html
2770+
/// <tag decoding="" />
2771+
/// ```
2772+
func decoding(_ value: Values.Decoding) -> Self
2773+
}
2774+
2775+
extension DecodingAttribute where Self: ContentNode {
2776+
2777+
internal func mutate(decoding value: String) -> Self {
2778+
return self.mutate(key: "decoding", value: value)
2779+
}
2780+
}
2781+
2782+
extension DecodingAttribute where Self: EmptyNode {
2783+
2784+
internal func mutate(decoding value: String) -> Self {
2785+
return self.mutate(key: "decoding", value: value)
2786+
}
2787+
}
2788+
2789+
public protocol BlockingAttribute: Attribute {
2790+
2791+
/// The function represents the html-attribute 'blocking'.
2792+
///
2793+
/// ```html
2794+
/// <tag blocking="" />
2795+
/// ```
2796+
func blocking(_ value: Values.Blocking) -> Self
2797+
}
2798+
2799+
extension BlockingAttribute where Self: ContentNode {
2800+
2801+
internal func mutate(blocking value: String) -> Self {
2802+
return self.mutate(key: "blocking", value: value)
2803+
}
2804+
}
2805+
2806+
extension BlockingAttribute where Self: EmptyNode {
2807+
2808+
internal func mutate(blocking value: String) -> Self {
2809+
return self.mutate(key: "blocking", value: value)
2810+
}
2811+
}
2812+
2813+
public protocol PopoverAttribute: Attribute {
2814+
2815+
/// The function represents the html-attribute 'popover'.
2816+
///
2817+
/// ```html
2818+
/// <tag popover="" />
2819+
/// ```
2820+
func popover(_ value: Values.Popover.State) -> Self
2821+
}
2822+
2823+
extension PopoverAttribute where Self: ContentNode {
2824+
2825+
internal func mutate(popover value: String) -> Self {
2826+
return self.mutate(key: "popover", value: value)
2827+
}
2828+
}
2829+
2830+
extension PopoverAttribute where Self: EmptyNode {
2831+
2832+
internal func mutate(popover value: String) -> Self {
2833+
return self.mutate(key: "popover", value: value)
2834+
}
2835+
}
2836+
2837+
public protocol PopoverTargetAttribute: Attribute {
2838+
2839+
/// The function represents the html-attribute 'popovertarget'.
2840+
///
2841+
/// ```html
2842+
/// <tag popovertarget="" />
2843+
/// ```
2844+
func popoverTarget(_ value: String) -> Self
2845+
}
2846+
2847+
extension PopoverAttribute where Self: ContentNode {
2848+
2849+
internal func mutate(popovertarget value: String) -> Self {
2850+
return self.mutate(key: "popovertarget", value: value)
2851+
}
2852+
}
2853+
2854+
extension PopoverAttribute where Self: EmptyNode {
2855+
2856+
internal func mutate(popovertarget value: String) -> Self {
2857+
return self.mutate(key: "popovertarget", value: value)
2858+
}
2859+
}
2860+
2861+
public protocol PopoverActionAttribute: Attribute {
2862+
2863+
/// The function represents the html-attribute 'popovertargetaction'.
2864+
///
2865+
/// ```html
2866+
/// <tag popovertargetaction="" />
2867+
/// ```
2868+
func popoverAction(_ value: Values.Popover.Action) -> Self
2869+
}
2870+
2871+
extension PopoverAttribute where Self: ContentNode {
2872+
2873+
internal func mutate(popoveraction value: String) -> Self {
2874+
return self.mutate(key: "popovertargetaction", value: value)
2875+
}
2876+
}
2877+
2878+
extension PopoverAttribute where Self: EmptyNode {
2879+
2880+
internal func mutate(popoveraction value: String) -> Self {
2881+
return self.mutate(key: "popovertargetaction", value: value)
2882+
}
2883+
}

Sources/HTMLKit/Abstraction/Elements/BasicElements.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,23 @@ extension Html: GlobalAttributes, GlobalEventAttributes {
188188
return mutate(translate: value.rawValue)
189189
}
190190

191+
public func inert() -> Html {
192+
return mutate(inert: "inert")
193+
}
194+
195+
public func inert(_ condition: Bool) -> Html {
196+
197+
if condition {
198+
return mutate(inert: "inert")
199+
}
200+
201+
return self
202+
}
203+
204+
public func popover(_ value: Values.Popover.State) -> Html {
205+
return mutate(popover: value.rawValue)
206+
}
207+
191208
public func custom(key: String, value: Any) -> Html {
192209
return mutate(key: key, value: value)
193210
}

0 commit comments

Comments
 (0)