SPB Git

Repository Public MIT

manifest.json 4.6 KB 74 lines json

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        "Release 1.1.0: see the project changelog."13      ],14      "date" : "2026-12-03",15      "version" : "1.1.0"16    },17    {18      "changes" : [19        "Initial release."20      ],21      "date" : "2026-12-02",22      "version" : "1.0.0"23    }24  ],25  "dependencies" : [26    {27      "id" : "glass-forms-support",28      "version" : "1.1.0"29    },30    {31      "id" : "glass-foundation",32      "version" : "1.1.0"33    }34  ],35  "description" : "Search with suggestions, cancellation and a cancellable debounce for asynchronous queries.",36  "examples" : [37    {38      "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",39      "title" : "GlassSearchField example"40    }41  ],42  "files" : [43    {44      "bytes" : 9211,45      "path" : "Forms/Forms/GlassSearchField.swift",46      "sha256" : "f1ef28d1629f6b64fe812a00f8c706888eb587c5d3842a2369498118a820c2bb"47    }48  ],49  "frameworks" : [5051  ],52  "id" : "glass-search-field",53  "kind" : "native-wrapper",54  "license" : "MIT",55  "minimumOS" : {56    "iOS" : "26.0",57    "iPadOS" : "26.0",58    "macOS" : "26.0"59  },60  "name" : "GlassSearchField",61  "platforms" : [62    "iOS",63    "iPadOS",64    "macOS"65  ],66  "schemaVersion" : 1,67  "sha256" : "ebd1cad0467fc907044217b3587186b5b9db9ce9cdbe6ef7345586444f692f9c",68  "symbols" : [69    "GlassSearchSuggestion",70    "GlassSearchField"71  ],72  "version" : "1.1.0"73}74
Files main
Menu

Theme