Repository Public MIT
1{2 "accessibility" : [3 "The system field brings its own label, clear and cancel controls.",4 "The inline field is labelled \"Search\", has the search-field trait, and its clear and cancel buttons are labelled and reachable with the keyboard.",5 "Suggestions are system rows with text; symbols are decorative.",6 "The Cancel button fades in with the theme's fast animation; with Reduce Motion it is a short cross-fade."7 ],8 "category" : "forms",9 "changelog" : [10 {11 "changes" : [12 "Initial release."13 ],14 "date" : "2026-12-02",15 "version" : "1.0.0"16 }17 ],18 "dependencies" : [19 {20 "id" : "glass-forms-support",21 "version" : "1.0.0"22 },23 {24 "id" : "glass-foundation",25 "version" : "1.0.0"26 }27 ],28 "description" : "Search with suggestions, cancellation and a cancellable debounce for asynchronous queries.",29 "examples" : [30 {31 "code" : "import SwiftUI\nimport SPGlassKit\n\npublic struct GlassSearchFieldExample: GlassExample {\n public static let componentID = \"glass-search-field\"\n\n private static let catalogue = [\"Café crème\", \"Cafetière italienne\", \"Thé vert\", \"Théière en fonte\", \"Chocolat chaud\", \"Citronnade\", \"Eau pétillante\", \"Jus d’orange\"]\n private static let recent = [\n GlassSearchSuggestion(title: \"café\", systemImage: \"clock\"),\n GlassSearchSuggestion(title: \"thé\", systemImage: \"clock\"),\n GlassSearchSuggestion(title: \"Hot drinks\", systemImage: \"cup.and.saucer\", completion: \"chaud\"),\n ]\n\n @State private var query = \"\"\n @State private var inlineQuery = \"\"\n @State private var results = GlassSearchFieldExample.catalogue\n @State private var debouncer = GlassSearchDebouncer(delay: .milliseconds(250))\n\n public init() {}\n\n /// A stand-in for a remote search: it only filters a local list after a short pause.\n private static func search(_ query: String) async throws -> [String] {\n try await Task.sleep(for: .milliseconds(150))\n let needle = query.folding(options: [.caseInsensitive, .diacriticInsensitive], locale: nil)\n return needle.isEmpty ? catalogue : catalogue.filter { $0.folding(options: [.caseInsensitive, .diacriticInsensitive], locale: nil).contains(needle) }\n }\n\n public var body: some View {\n NavigationStack {\n List {\n Section(\"Inline field\") {\n GlassSearchField(text: $inlineQuery, prompt: \"Filter this section\")\n .listRowSeparator(.hidden)\n ForEach(Self.catalogue.filter { inlineQuery.isEmpty || $0.localizedStandardContains(inlineQuery) }, id: \\.self) { item in\n Text(verbatim: item)\n }\n }\n Section {\n ForEach(results, id: \\.self) { item in\n Text(verbatim: item)\n }\n if results.isEmpty {\n Text(\"No results\").foregroundStyle(.secondary)\n }\n } header: {\n HStack {\n Text(\"Debounced results\")\n if debouncer.isPending { ProgressView().controlSize(.small) }\n }\n }\n }\n .navigationTitle(\"Drinks\")\n .glassSearchable(text: $query, prompt: \"Search drinks\", suggestions: query.isEmpty ? Self.recent : [])\n .onChange(of: query) { _, newValue in\n debouncer.submit(newValue, search: Self.search) { results = $0 }\n }\n .onDisappear { debouncer.cancel() }\n }\n }\n}\n\n#Preview(\"GlassSearchField\") { GlassSearchFieldExample() }\n",32 "title" : "GlassSearchField example"33 }34 ],35 "files" : [36 {37 "bytes" : 9214,38 "path" : "Forms/Forms/GlassSearchField.swift",39 "sha256" : "ffbcaa4b823a7fa80d777c77ac25ddf9c2b4b63267017a366dde2939aacdcb23"40 }41 ],42 "frameworks" : [4344 ],45 "id" : "glass-search-field",46 "kind" : "native-wrapper",47 "license" : "MIT",48 "minimumOS" : {49 "iOS" : "26.0",50 "iPadOS" : "26.0",51 "macOS" : "26.0"52 },53 "name" : "GlassSearchField",54 "platforms" : [55 "iOS",56 "iPadOS",57 "macOS"58 ],59 "schemaVersion" : 1,60 "sha256" : "ab4e35b6468ab21b34d981a82858045b6033d6d31dddc723e5e9aa14cc92bb3e",61 "symbols" : [62 "GlassSearchSuggestion",63 "GlassSearchField"64 ],65 "version" : "1.0.0"66}67