Repository Public MIT
1{2 "accessibility" : [3 "There is one text field, so VoiceOver meets one element: its label and the value \"3 of 6 digits entered\". The boxes are hidden from assistive technologies and the digits are not read one box at a time by GlassKit.",4 "The field uses the one-time-code content type, so the system can offer the code received by message, and the number pad on iOS.",5 "Pasting a whole code works as in any text field: long-press or Command-V; separators and letters are dropped.",6 "Boxes share the available width up to a square, their height follows Dynamic Type, and the digits shrink rather than clip.",7 "The caret of the active box blinks, except with Reduce Motion.",8 "Digits are always laid out left to right, including in right-to-left languages."9 ],10 "category" : "forms",11 "changelog" : [12 {13 "changes" : [14 "Release 1.1.0: see the project changelog."15 ],16 "date" : "2026-12-03",17 "version" : "1.1.0"18 },19 {20 "changes" : [21 "Initial release."22 ],23 "date" : "2026-12-02",24 "version" : "1.0.0"25 }26 ],27 "dependencies" : [28 {29 "id" : "glass-forms-support",30 "version" : "1.1.0"31 },32 {33 "id" : "glass-foundation",34 "version" : "1.1.0"35 }36 ],37 "description" : "One logical one-time-code field with paste, AutoFill and a segmented display.",38 "examples" : [39 {40 "code" : "import SwiftUI\nimport SPGlassKit\n\npublic struct GlassOTPFieldExample: GlassExample {\n public static let componentID = \"glass-otp-field\"\n /// The demo accepts this fictitious code only.\n private static let expected = \"246810\"\n\n @State private var code = \"\"\n @State private var shortCode = \"\"\n @State private var status = \"Enter the 6-digit demo code 246810.\"\n @State private var rejected = false\n\n public init() {}\n\n public var body: some View {\n ScrollView {\n VStack(alignment: .leading, spacing: 20) {\n GlassOTPField(code: $code, hasError: rejected) { entered in\n rejected = entered != Self.expected\n status = rejected ? \"That code is not valid. Try again.\" : \"Code accepted.\"\n }\n .onChange(of: code) { _, newValue in\n if newValue.count < 6 { rejected = false }\n }\n\n Label(status, systemImage: rejected ? \"xmark.octagon\" : \"info.circle\")\n .font(.callout)\n .foregroundStyle(.secondary)\n\n HStack {\n Button(\"Simulate paste “246 810”\") { code = GlassOTPSanitizer.sanitize(\"246 810\", length: 6) }\n Button(\"Clear\") { code = \"\" }\n }\n\n Text(\"Four digits\").font(.headline)\n GlassOTPField(code: $shortCode, length: 4, label: \"PIN\")\n\n Text(\"Disabled\").font(.headline)\n GlassOTPField(code: .constant(\"12\"), length: 4)\n .disabled(true)\n }\n .padding()\n }\n }\n}\n\n#Preview(\"GlassOTPField\") { GlassOTPFieldExample() }\n",41 "title" : "GlassOTPField example"42 }43 ],44 "files" : [45 {46 "bytes" : 10036,47 "path" : "Forms/Forms/GlassOTPField.swift",48 "sha256" : "9938fba3ade1b962f186d3bca542edfe85072cc07aa3ccb6b0a641427c4c13e8"49 }50 ],51 "frameworks" : [5253 ],54 "id" : "glass-otp-field",55 "kind" : "content-component",56 "license" : "MIT",57 "minimumOS" : {58 "iOS" : "26.0",59 "iPadOS" : "26.0",60 "macOS" : "26.0"61 },62 "name" : "GlassOTPField",63 "platforms" : [64 "iOS",65 "iPadOS",66 "macOS"67 ],68 "schemaVersion" : 1,69 "sha256" : "4135c68e851941ecfff3c08ba3724d1b69f047321b7ca0a759ec529bc949e14a",70 "symbols" : [71 "GlassOTPSanitizer",72 "GlassOTPField",73 "GlassOTPLayout"74 ],75 "version" : "1.1.0"76}77