From f9cd18e07be2fcafd5b3df355e4d2fa6ec1d5a23 Mon Sep 17 00:00:00 2001 From: Jeff Verkoeyen Date: Tue, 13 Aug 2024 18:42:26 -0400 Subject: [PATCH] [feature] Add types for buttons and text fields. (#162) --- .../W3C/Forms/Forms-Button.md | 7 ++ .../W3C/Forms/Forms-TextField.md | 7 ++ .../W3C/Elements/Forms/Button.swift | 25 ++++- .../W3C/Elements/Forms/TextField.swift | 91 ++++++++++++++++++- .../W3C/Forms/ButtonTests.swift | 5 + .../W3C/Forms/TextFieldTests.swift | 15 +++ 6 files changed, 144 insertions(+), 6 deletions(-) create mode 100644 Sources/Slipstream/Documentation.docc/W3C/Forms/Forms-Button.md create mode 100644 Sources/Slipstream/Documentation.docc/W3C/Forms/Forms-TextField.md diff --git a/Sources/Slipstream/Documentation.docc/W3C/Forms/Forms-Button.md b/Sources/Slipstream/Documentation.docc/W3C/Forms/Forms-Button.md new file mode 100644 index 0000000..9e0fa8b --- /dev/null +++ b/Sources/Slipstream/Documentation.docc/W3C/Forms/Forms-Button.md @@ -0,0 +1,7 @@ +# ``Button`` + +## Topics + +### Supporting types + +- ``ButtonType`` diff --git a/Sources/Slipstream/Documentation.docc/W3C/Forms/Forms-TextField.md b/Sources/Slipstream/Documentation.docc/W3C/Forms/Forms-TextField.md new file mode 100644 index 0000000..5decab6 --- /dev/null +++ b/Sources/Slipstream/Documentation.docc/W3C/Forms/Forms-TextField.md @@ -0,0 +1,7 @@ +# ``TextField`` + +## Topics + +### Supporting types + +- ``TextFieldInputType`` diff --git a/Sources/Slipstream/W3C/Elements/Forms/Button.swift b/Sources/Slipstream/W3C/Elements/Forms/Button.swift index c7a6e4b..24e529c 100644 --- a/Sources/Slipstream/W3C/Elements/Forms/Button.swift +++ b/Sources/Slipstream/W3C/Elements/Forms/Button.swift @@ -1,5 +1,14 @@ import SwiftSoup +/// Constants that control the behavior of a ``Button`` when it is activated. +/// +/// - SeeAlso: W3C [button type](https://html.spec.whatwg.org/multipage/form-elements.html#attr-button-type) specification. +@available(iOS 17.0, macOS 14.0, *) +public enum ButtonType: String { + case submit + case reset +} + /// A control that initiates an action. /// /// - SeeAlso: W3C [button](https://html.spec.whatwg.org/multipage/form-elements.html#the-button-element) specification. @@ -7,36 +16,41 @@ import SwiftSoup public struct Button