Repository Public MIT
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project : SP GlassKit7// File : Sources/SPGlassCore/GlassComponentCatalog.swift8// Module : SPGlassCore9// Repository : https://git.spboucher.ai/sp-glasskit10// Project Website : https://glass.spboucher.ai11// Created : 2026-12-0212// Last Modified : 2026-12-0213//14// Author : Simon-Pierre Boucher15// Position : Professor of Finance16// Institution : Université du Québec en Outaouais (UQO)17// Organization : SP Boucher18// Website : https://spboucher.ai19// Git : https://git.spboucher.ai20//21// Preferred Contact: contact@spboucher.ai22// Development : dev@spboucher.ai23// Support : support@spboucher.ai24// Security/Admin : admin@spboucher.ai25//26// Copyright (c) 202627// Simon-Pierre Boucher28// All rights reserved where applicable. This file is governed by the29// applicable project license, copyright notices and relevant law.30// Existing third-party rights and notices remain unaffected.31//32// License : MIT33//34// Do not embed credentials, private keys, access tokens,35// certificates or confidential personal information.36//37// =============================================================================38// END OF SP BOUCHER SOURCE HEADER39// =============================================================================4041import Foundation4243/// Catalogue entry of one component. The registry, the Studio, the website and the tests all read this list.44public struct GlassComponentInfo: Hashable, Codable, Sendable, Identifiable {45 /// Kebab-case identifier used by the registry and the CLI (`glass-tab-bar`).46 public let id: String47 /// Name of the main Swift type (`GlassTabBar`).48 public let name: String49 public let category: GlassComponentCategory50 public let kind: GlassComponentKind51 /// Swift module that declares the component.52 public let module: String53 /// One-sentence description in English.54 public let summary: String55 /// System frameworks the component needs besides SwiftUI.56 public let frameworks: [String]57 /// Position in the published catalogue, 1 to 50.58 public let number: Int5960 public var platforms: [GlassPlatform] { GlassPlatform.allCases }61 public var minimumOS: [String: String] { ["iOS": "26.0", "iPadOS": "26.0", "macOS": "26.0"] }62}6364public enum GlassComponentCatalog {65 /// The fifty components of version 1, in catalogue order.66 public static let all: [GlassComponentInfo] = {67 var entries: [GlassComponentInfo] = []68 func add(_ name: String, _ category: GlassComponentCategory, _ kind: GlassComponentKind, _ module: String, _ summary: String, frameworks: [String] = []) {69 entries.append(GlassComponentInfo(id: identifier(for: name), name: name, category: category, kind: kind, module: module, summary: summary, frameworks: frameworks, number: entries.count + 1))70 }71 let nav = "SPGlassNavigation", base = "SPGlassComponents", forms = "SPGlassForms", data = "SPGlassData"72 let media = "SPGlassMedia", maps = "SPGlassMaps", ai = "SPGlassAI"7374 add("GlassTabBar", .navigation, .nativeWrapper, nav, "Typed wrapper around the system TabView with badges, dynamic tabs, per-tab navigation state and deep links.")75 add("GlassNavigationBar", .navigation, .nativeWrapper, nav, "NavigationStack with a title, toolbar actions and the system back button.")76 add("GlassToolbar", .navigation, .nativeWrapper, nav, "Groups of toolbar actions with system placements, overflow and keyboard shortcuts.")77 add("GlassSidebar", .navigation, .nativeWrapper, nav, "NavigationSplitView sidebar with sections, selection, search and adaptive collapse.")78 add("GlassBreadcrumb", .navigation, .customGlass, nav, "Typed path with truncation, an overflow menu and keyboard navigation.")7980 add("GlassButton", .buttons, .nativeWrapper, base, "Button using the system glass styles, with destructive role, loading and disabled states.")81 add("GlassIconButton", .buttons, .nativeWrapper, base, "Symbol-only glass button with a mandatory accessibility label and a full-size hit target.")82 add("GlassFloatingButton", .buttons, .nativeWrapper, base, "Floating action placed inside the safe area, clear of the keyboard.")83 add("GlassSplitButton", .buttons, .nativeWrapper, base, "Primary action with a separate menu of secondary actions.")84 add("GlassButtonGroup", .buttons, .customGlass, base, "Related glass buttons rendered in one glass container so that they blend consistently.")8586 add("GlassTextField", .forms, .contentComponent, forms, "Text field with label, validation message, focus handling and keyboard configuration.")87 add("GlassSecureField", .forms, .contentComponent, forms, "Secure field with optional explicit reveal; its content is never logged.")88 add("GlassSearchField", .forms, .nativeWrapper, forms, "Search with suggestions, cancellation and a cancellable debounce for asynchronous queries.")89 add("GlassTextArea", .forms, .contentComponent, forms, "Multiline editor with an accessible placeholder, optional limit and counter.")90 add("GlassOTPField", .forms, .contentComponent, forms, "One logical one-time-code field with paste, AutoFill and a segmented display.")9192 add("GlassToggle", .selection, .nativeWrapper, forms, "System toggle with title, description and disabled state.")93 add("GlassSlider", .selection, .nativeWrapper, forms, "System slider with bounds, step, a readable value and VoiceOver adjustment.")94 add("GlassPicker", .selection, .nativeWrapper, forms, "Generic picker over Hashable options, as a menu or a wheel depending on the platform.")95 add("GlassSegmentedControl", .selection, .nativeWrapper, forms, "Segmented picker with labels that adapt to the available width.")96 add("GlassStepper", .selection, .nativeWrapper, forms, "System stepper with bounds, increments and a formatted value.")9798 add("GlassCard", .containers, .contentComponent, base, "Content container: opaque for dense content, glass when it floats above other content.")99 add("GlassPanel", .containers, .customGlass, base, "Floating panel of actions, resizable on macOS, with managed focus.")100 add("GlassSheet", .containers, .nativeWrapper, base, "System sheet with detents, keyboard handling and an accessible close action.")101 add("GlassPopover", .containers, .nativeWrapper, base, "System popover with anchoring, compact adaptation and an accessible close action.")102 add("GlassAccordion", .containers, .nativeWrapper, base, "Disclosure sections with controlled expansion and Reduce Motion support.")103104 add("GlassToast", .feedback, .customGlass, base, "Transient message with a bounded queue, duration, optional action and an accessibility announcement.")105 add("GlassAlert", .feedback, .nativeWrapper, base, "System alert and confirmation dialog described by a value with correct button roles.")106 add("GlassBanner", .feedback, .contentComponent, base, "Inline information, success, warning or error message with icon, text and dismissal.")107 add("GlassBadge", .feedback, .contentComponent, base, "Count, value or status marker that never relies on colour alone.")108 add("GlassProgress", .feedback, .nativeWrapper, base, "Determinate or indeterminate system progress with an optional cancel action.")109110 add("GlassTable", .data, .nativeWrapper, data, "System Table where available and a List elsewhere, with typed sorting and selection.")111 add("GlassChart", .data, .contentComponent, data, "Swift Charts line, bar and area charts with axes, units and accessible descriptions.", frameworks: ["Charts"])112 add("GlassMetricCard", .data, .contentComponent, data, "A value with unit, change and period, and states for missing, loading and failed data.")113 add("GlassDataGrid", .data, .contentComponent, data, "Lazy grid for large collections with stable identifiers and generic cells.")114 add("GlassTimeline", .data, .contentComponent, data, "Dated events in order, grouped by day and localised, with an empty state.")115116 add("GlassAudioPlayer", .media, .customGlass, media, "Audio transport with play, pause, seek, times and interruption handling; never starts by itself.", frameworks: ["AVFoundation"])117 add("GlassVideoPlayer", .media, .nativeWrapper, media, "AVKit video player with system controls and full screen where the platform offers it.", frameworks: ["AVKit"])118 add("GlassVolumeControl", .media, .nativeWrapper, media, "Volume of the application's own playback, with mute.")119 add("GlassGallery", .media, .contentComponent, media, "Lazy image grid with a zoomable viewer, navigation and cancellable loading.")120 add("GlassWaveform", .media, .contentComponent, media, "Bounded, aggregated audio samples drawn with Canvas and described in text.")121122 add("GlassMapControls", .maps, .customGlass, maps, "Zoom and orientation actions in a glass container, independent of the map provider.")123 add("GlassCompass", .maps, .customGlass, maps, "Compass driven by an injected heading, with reset to north and an unavailable state.")124 add("GlassLocationButton", .maps, .customGlass, maps, "Location action with injected state; permission is requested by the host application only.")125 add("GlassMapPin", .maps, .contentComponent, maps, "Configurable marker with selection and an accessible label; clustering is left to the map engine.")126 add("GlassMapPanel", .maps, .nativeWrapper, maps, "Extensible results panel that keeps the map behind it interactive.")127128 add("GlassChatBubble", .ai, .contentComponent, ai, "Message bubble with role, streaming state, text selection and copy.")129 add("GlassPromptBar", .ai, .customGlass, ai, "Multiline prompt editor with send and stop, attachments through callbacks and keyboard shortcuts.")130 add("GlassThinkingIndicator", .ai, .contentComponent, ai, "Explicit activity indicator with a reduced-motion form; it never shows presumed reasoning.")131 add("GlassModelPicker", .ai, .nativeWrapper, ai, "Picker over an injected list of models with capabilities and local or remote state.")132 add("GlassAgentPanel", .ai, .contentComponent, ai, "Tasks and observable steps with status, progress, errors and cancellation.")133 return entries134 }()135136 public static func component(id: String) -> GlassComponentInfo? {137 all.first { $0.id == id }138 }139140 public static func components(in category: GlassComponentCategory) -> [GlassComponentInfo] {141 all.filter { $0.category == category }142 }143144 /// `GlassTabBar` → `glass-tab-bar`, `GlassOTPField` → `glass-otp-field`.145 public static func identifier(for typeName: String) -> String {146 var result = ""147 let characters = Array(typeName)148 for (index, character) in characters.enumerated() {149 if character.isUppercase, index > 0 {150 let previous = characters[index - 1]151 let next = index + 1 < characters.count ? characters[index + 1] : nil152 if previous.isLowercase || (previous.isUppercase && next?.isLowercase == true) {153 result.append("-")154 }155 }156 result.append(contentsOf: character.lowercased())157 }158 return result159 }160}161