// // Input.swift // HTMLStandard // // Generated on 09/23/2025. // THIS FILE IS GENERATED. DO NOT EDIT. // import Foundation /// Form control public class Input : HTMLNode, IFlow, IFormAssociated, IInteractive, ILabelable, IListed, IPalpable, IPhrasing, IResettable, ISubmittable { public enum Formenctype : String, CaseIterable { case application_xWwwFormUrlencoded = "application/x-www-form-urlencoded" case multipart_formData = "multipart/form-data" case text_plain = "text/plain" public init?(rawValue: Substring) { guard let value = Self.allCases.first(where: { $0.rawValue == rawValue }) else { return nil } self = value } public init(expect: Substring) throws { guard let value = Self.allCases.first(where: { $0.rawValue == expect }) else { throw AppError("Unexpected value for Formenctype: \(expect)") } self = value } public init(expect: String) throws { guard let result = Formenctype(rawValue: expect) else { throw AppError("Unexpected value for Formenctype: \(expect)") } self = result } static func parseList(_ value:String?, _ separator:String = " ") throws -> [Formenctype] { guard let value = value else { return [] } var iterator = value.componentsIterator(separatedBy: separator) let result = try iterator.map { input in return try expect(Formenctype(rawValue: input), "unexpected value for Formenctype: \(input)") } return result } } public enum Formmethod : String, CaseIterable { case GET case POST case dialog public init?(rawValue: Substring) { guard let value = Self.allCases.first(where: { $0.rawValue == rawValue }) else { return nil } self = value } public init(expect: Substring) throws { guard let value = Self.allCases.first(where: { $0.rawValue == expect }) else { throw AppError("Unexpected value for Formmethod: \(expect)") } self = value } public init(expect: String) throws { guard let result = Formmethod(rawValue: expect) else { throw AppError("Unexpected value for Formmethod: \(expect)") } self = result } static func parseList(_ value:String?, _ separator:String = " ") throws -> [Formmethod] { guard let value = value else { return [] } var iterator = value.componentsIterator(separatedBy: separator) let result = try iterator.map { input in return try expect(Formmethod(rawValue: input), "unexpected value for Formmethod: \(input)") } return result } } /// Hint for expected file type in file upload controls. Set of comma-separated tokens* consisting of valid MIME type strings with no parameters or audio/*, video/*, or image/. The actual rules are more complicated than indicated. public var accept:[String] = [] /// Replacement text for use when images are not available. Text. The actual rules are more complicated than indicated. public var alt:String? = nil /// Hint for form autofill feature. Autofill field name and related tokens. The actual rules are more complicated than indicated. public var autocomplete:String? = nil /// Whether the control is checked. public var checked:Bool = false /// Name of form control to use for sending the element's directionality in form submission. Text. The actual rules are more complicated than indicated. public var dirname:String? = nil /// Whether the form control is disabled. public var disabled:Bool = false /// Associates the element with a form element. ID. The actual rules are more complicated than indicated. public var form:String? = nil /// URL to use for form submission. Valid non-empty URL potentially surrounded by spaces. public var formaction:URL? = nil /// Entry list encoding type to use for form submission. public var formenctype:Formenctype? = nil /// Variant to use for form submission. public var formmethod:Formmethod? = nil /// Bypass form control validation for form submission. public var formnovalidate:Bool = false /// Browsing context for form submission. Valid browsing context name or keyword. public var formtarget:String? = nil /// Vertical dimension. Valid non-negative integer. public var height:UInt? = nil /// List of autocomplete options. ID. The actual rules are more complicated than indicated. public var list:String? = nil /// Maximum value. Varies. The actual rules are more complicated than indicated. public var max:String? = nil /// Maximum length of value. Valid non-negative integer. public var maxlength:UInt? = nil /// Minimum value. Varies. The actual rules are more complicated than indicated. public var min:String? = nil /// Minimum length of value. Valid non-negative integer. public var minlength:UInt? = nil /// Whether to allow multiple values. public var multiple:Bool = false /// Name of the element to use for form submission and in the form.elements API. Text. The actual rules are more complicated than indicated. public var name:String? = nil /// Pattern to be matched by the form control's value. Regular expression matching the JavaScript Pattern production. public var pattern:String? = nil /// User-visible label to be placed within the form control. Text. The actual rules are more complicated than indicated. public var placeholder:String? = nil /// Whether to allow the value to be edited by the user. public var readonly:Bool = false /// Whether the control is required for form submission. public var required:Bool = false /// Size of the control. Valid non-negative integer greater than zero. public var size:UInt? = nil /// Address of the resource. Valid non-empty URL potentially surrounded by spaces. public var src:URL? = nil /// Granularity to be matched by the form control's value. Valid floating-point number greater than zero, or "any". public var step:Float? = nil /// Description of pattern (when used with pattern attribute). public var title:String? { get { return globalAttributes[.title] } set { globalAttributes[.title] = newValue } } /// Type of form control or Type of form control. input type keyword or An input type e.g. "text" public var type:String? = nil /// Value of the form control. Varies. The actual rules are more complicated than indicated. public var value:String? = nil /// Horizontal dimension. Valid non-negative integer. public var width:UInt? = nil public init(_ attributes:[String:String], _ parser:XMLParser? = nil) throws { var globalAttr = GlobalAttributesBuilder() for (key, attValue) in attributes { switch (key) { case "accept": accept = try String.parseList(attValue, ",") continue case "alt": alt = attValue continue case "autocomplete": autocomplete = attValue continue case "checked": checked = true continue case "dirname": dirname = attValue continue case "disabled": disabled = true continue case "form": form = attValue continue case "formaction": formaction = try URL(expect: attValue) continue case "formenctype": formenctype = try Formenctype(expect: attValue) continue case "formmethod": formmethod = try Formmethod(expect: attValue) continue case "formnovalidate": formnovalidate = true continue case "formtarget": formtarget = attValue continue case "height": height = UInt(attValue) continue case "list": list = attValue continue case "max": max = attValue continue case "maxlength": maxlength = UInt(attValue) continue case "min": min = attValue continue case "minlength": minlength = UInt(attValue) continue case "multiple": multiple = true continue case "name": name = attValue continue case "pattern": pattern = attValue continue case "placeholder": placeholder = attValue continue case "readonly": readonly = true continue case "required": required = true continue case "size": size = UInt(attValue) continue case "src": src = try URL(expect: attValue) continue case "step": step = Float(attValue) continue case "type": type = attValue continue case "value": value = attValue continue case "width": width = UInt(attValue) continue default: break } if globalAttr.trySetGlobalAttribute(key, attValue) { continue } continue } super.init(globalAttr) } public override func renderAttributes() -> String { var result = super.renderAttributes() result += " accept='\(accept.toStringList(","))'" if let alt = alt { result += " alt='\(alt)'" } if let autocomplete = autocomplete { result += " autocomplete='\(autocomplete)'" } if checked { result += " checked" } if let dirname = dirname { result += " dirname='\(dirname)'" } if disabled { result += " disabled" } if let form = form { result += " form='\(form)'" } if let formaction = formaction { result += " formaction='\(formaction.absoluteString)'" } if let formenctype = formenctype { result += " formenctype='\(formenctype.rawValue)'" } if let formmethod = formmethod { result += " formmethod='\(formmethod.rawValue)'" } if formnovalidate { result += " formnovalidate" } if let formtarget = formtarget { result += " formtarget='\(formtarget)'" } if let height = height { result += " height='\(height)'" } if let list = list { result += " list='\(list)'" } if let max = max { result += " max='\(max)'" } if let maxlength = maxlength { result += " maxlength='\(maxlength)'" } if let min = min { result += " min='\(min)'" } if let minlength = minlength { result += " minlength='\(minlength)'" } if multiple { result += " multiple" } if let name = name { result += " name='\(name)'" } if let pattern = pattern { result += " pattern='\(pattern)'" } if let placeholder = placeholder { result += " placeholder='\(placeholder)'" } if readonly { result += " readonly" } if required { result += " required" } if let size = size { result += " size='\(size)'" } if let src = src { result += " src='\(src.absoluteString)'" } if let step = step { result += " step='\(step)'" } if let type = type { result += " type='\(type)'" } if let value = value { result += " value='\(value)'" } if let width = width { result += " width='\(width)'" } return result } override var nodeName: String { return "input" } override var isVoidElement: Bool { return true } }