Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the inputmode modifier accept an enum #162

Merged
merged 5 commits into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions Sources/HTMLKit/Abstraction/Attributes/BasicAttributes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1113,16 +1113,19 @@ extension IsMapAttribute where Self: EmptyNode {
}
}

/// The protocol provides the element with the inputmode handler.
/// A type that provides the `inputMode` modifier.
@_documentation(visibility: internal)
public protocol InputModeAttribute: Attribute {

/// The function represents the html-attribute 'inputmode'.
/// Set the virtual keyboard mode for the editable element.
///
/// ```html
/// <tag inputmode="" />
/// ```swift
/// Input()
/// .inputMode(.numeric)
/// ```
func inputMode(_ value: String) -> Self
///
/// - Parameter value: The mode to set on
func inputMode(_ value: Values.Mode) -> Self
}

extension InputModeAttribute where Self: ContentNode {
Expand Down
5 changes: 5 additions & 0 deletions Sources/HTMLKit/Abstraction/Elements/BasicElements.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,14 @@ extension Html: GlobalAttributes, GlobalEventAttributes {
return self
}

@available(*, deprecated, message: "The inputmode attribute is actually an enumerated attribute. Use the inputMode(_: Mode) modifier instead.")
public func inputMode(_ value: String) -> Html {
return mutate(inputmode: value)
}

public func inputMode(_ value: Values.Mode) -> Html {
return mutate(inputmode: value.rawValue)
}

public func `is`(_ value: String) -> Html {
return mutate(is: value)
Expand Down
Loading