glacia-native 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (403) hide show
  1. package/LICENSE +29 -4
  2. package/README.md +111 -17
  3. package/lib/module/Accordion.js +58 -0
  4. package/lib/module/ActionSheet.js +38 -0
  5. package/lib/module/Alert.js +23 -0
  6. package/lib/module/AlertDialog.js +47 -0
  7. package/lib/module/Avatar.js +48 -0
  8. package/lib/module/Badge.js +36 -0
  9. package/lib/module/Bars.js +13 -267
  10. package/lib/module/Button.js +57 -36
  11. package/lib/module/Card.js +32 -20
  12. package/lib/module/Checkbox.js +42 -0
  13. package/lib/module/Chip.js +80 -0
  14. package/lib/module/Collapsible.js +26 -0
  15. package/lib/module/ContextMenu.js +33 -0
  16. package/lib/module/Dialog.js +39 -124
  17. package/lib/module/DropdownMenu.js +33 -0
  18. package/lib/module/Field.js +22 -0
  19. package/lib/module/Glass.js +12 -5
  20. package/lib/module/Group.js +36 -0
  21. package/lib/module/IconButton.js +40 -0
  22. package/lib/module/Input.js +47 -40
  23. package/lib/module/Label.js +17 -0
  24. package/lib/module/MorphGroup.js +47 -0
  25. package/lib/module/Popover.js +29 -0
  26. package/lib/module/Progress.js +32 -0
  27. package/lib/module/RadioGroup.js +51 -0
  28. package/lib/module/Scrim.js +44 -0
  29. package/lib/module/SegmentedControl.js +74 -58
  30. package/lib/module/Select.js +51 -0
  31. package/lib/module/Separator.js +25 -0
  32. package/lib/module/Sheet.js +51 -0
  33. package/lib/module/Skeleton.js +48 -0
  34. package/lib/module/Slider.js +60 -40
  35. package/lib/module/Stepper.js +167 -0
  36. package/lib/module/Switch.js +45 -43
  37. package/lib/module/TabBar.js +62 -50
  38. package/lib/module/Tabs.js +3 -2
  39. package/lib/module/Textarea.js +18 -0
  40. package/lib/module/Toast.js +55 -0
  41. package/lib/module/Toggle.js +47 -0
  42. package/lib/module/ToggleGroup.js +56 -0
  43. package/lib/module/Toolbar.js +37 -0
  44. package/lib/module/Tooltip.js +31 -0
  45. package/lib/module/glass-provider.js +28 -0
  46. package/lib/module/glass-stack.js +61 -0
  47. package/lib/module/index.js +78 -109
  48. package/lib/module/internal/GlassBackdrop.js +36 -0
  49. package/lib/module/internal/GlassView.js +45 -13
  50. package/lib/module/internal/blur-community.js +20 -0
  51. package/lib/module/internal/blur-community.web.js +9 -0
  52. package/lib/module/internal/blur.js +75 -0
  53. package/lib/module/internal/fallback.js +110 -20
  54. package/lib/module/internal/glass-routing.js +154 -30
  55. package/lib/module/internal/glow.js +36 -0
  56. package/lib/module/internal/initials.js +12 -0
  57. package/lib/module/internal/lens.js +70 -0
  58. package/lib/module/internal/material.js +64 -0
  59. package/lib/module/internal/overlay.js +147 -0
  60. package/lib/module/internal/primitives.js +17 -0
  61. package/lib/module/internal/rim.js +35 -0
  62. package/lib/module/internal/tokens.js +34 -2
  63. package/lib/typescript/Accordion.d.ts +22 -0
  64. package/lib/typescript/ActionSheet.d.ts +24 -0
  65. package/lib/typescript/Alert.d.ts +15 -0
  66. package/lib/typescript/AlertDialog.d.ts +17 -0
  67. package/lib/typescript/Avatar.d.ts +22 -0
  68. package/lib/typescript/Badge.d.ts +12 -0
  69. package/lib/typescript/Bars.d.ts +3 -188
  70. package/lib/typescript/Button.d.ts +44 -10
  71. package/lib/typescript/Card.d.ts +30 -3
  72. package/lib/typescript/Checkbox.d.ts +14 -0
  73. package/lib/typescript/Chip.d.ts +19 -0
  74. package/lib/typescript/Collapsible.d.ts +17 -0
  75. package/lib/typescript/ContextMenu.d.ts +23 -0
  76. package/lib/typescript/Dialog.d.ts +8 -68
  77. package/lib/typescript/DropdownMenu.d.ts +23 -0
  78. package/lib/typescript/Field.d.ts +19 -0
  79. package/lib/typescript/Glass.d.ts +11 -2
  80. package/lib/typescript/Group.d.ts +35 -0
  81. package/lib/typescript/IconButton.d.ts +21 -0
  82. package/lib/typescript/Input.d.ts +17 -18
  83. package/lib/typescript/Label.d.ts +14 -0
  84. package/lib/typescript/MorphGroup.d.ts +46 -0
  85. package/lib/typescript/Popover.d.ts +17 -0
  86. package/lib/typescript/Progress.d.ts +13 -0
  87. package/lib/typescript/RadioGroup.d.ts +21 -0
  88. package/lib/typescript/Scrim.d.ts +33 -0
  89. package/lib/typescript/SegmentedControl.d.ts +24 -13
  90. package/lib/typescript/Select.d.ts +19 -0
  91. package/lib/typescript/Separator.d.ts +10 -0
  92. package/lib/typescript/Sheet.d.ts +45 -0
  93. package/lib/typescript/Skeleton.d.ts +10 -0
  94. package/lib/typescript/Slider.d.ts +15 -7
  95. package/lib/typescript/Stepper.d.ts +49 -0
  96. package/lib/typescript/Switch.d.ts +19 -12
  97. package/lib/typescript/TabBar.d.ts +18 -6
  98. package/lib/typescript/Textarea.d.ts +6 -0
  99. package/lib/typescript/Toast.d.ts +40 -0
  100. package/lib/typescript/Toggle.d.ts +21 -0
  101. package/lib/typescript/ToggleGroup.d.ts +22 -0
  102. package/lib/typescript/Toolbar.d.ts +35 -0
  103. package/lib/typescript/Tooltip.d.ts +16 -0
  104. package/lib/typescript/glass-provider.d.ts +34 -0
  105. package/lib/typescript/glass-stack.d.ts +54 -0
  106. package/lib/typescript/index.d.ts +39 -17
  107. package/lib/typescript/internal/GlassBackdrop.d.ts +33 -0
  108. package/lib/typescript/internal/GlassView.d.ts +31 -2
  109. package/lib/typescript/internal/blur-community.d.ts +2 -0
  110. package/lib/typescript/internal/blur-community.web.d.ts +2 -0
  111. package/lib/typescript/internal/blur.d.ts +24 -0
  112. package/lib/typescript/internal/fallback.d.ts +27 -2
  113. package/lib/typescript/internal/glass-routing.d.ts +83 -15
  114. package/lib/typescript/internal/glow.d.ts +11 -0
  115. package/lib/typescript/internal/initials.d.ts +2 -0
  116. package/lib/typescript/internal/lens.d.ts +47 -0
  117. package/lib/typescript/internal/material.d.ts +27 -0
  118. package/lib/typescript/internal/overlay.d.ts +74 -0
  119. package/lib/typescript/internal/primitives.d.ts +13 -0
  120. package/lib/typescript/internal/rim.d.ts +16 -0
  121. package/lib/typescript/internal/tokens.d.ts +36 -0
  122. package/package.json +15 -4
  123. package/src/Accordion.tsx +165 -0
  124. package/src/ActionSheet.tsx +149 -0
  125. package/src/Alert.tsx +85 -0
  126. package/src/AlertDialog.tsx +124 -0
  127. package/src/Avatar.tsx +102 -0
  128. package/src/Badge.tsx +80 -0
  129. package/src/Bars.tsx +10 -797
  130. package/src/Button.tsx +196 -60
  131. package/src/Card.tsx +106 -33
  132. package/src/Checkbox.tsx +98 -0
  133. package/src/Chip.tsx +149 -0
  134. package/src/Collapsible.tsx +66 -0
  135. package/src/ContextMenu.tsx +103 -0
  136. package/src/Dialog.tsx +86 -325
  137. package/src/DropdownMenu.tsx +103 -0
  138. package/src/Field.tsx +65 -0
  139. package/src/Glass.tsx +19 -5
  140. package/src/Group.tsx +98 -0
  141. package/src/IconButton.tsx +110 -0
  142. package/src/Input.tsx +143 -87
  143. package/src/Label.tsx +56 -0
  144. package/src/MorphGroup.tsx +134 -0
  145. package/src/Popover.tsx +81 -0
  146. package/src/Progress.tsx +83 -0
  147. package/src/RadioGroup.tsx +122 -0
  148. package/src/Scrim.tsx +94 -0
  149. package/src/SegmentedControl.tsx +147 -90
  150. package/src/Select.tsx +136 -0
  151. package/src/Separator.tsx +52 -0
  152. package/src/Sheet.tsx +139 -0
  153. package/src/Skeleton.tsx +77 -0
  154. package/src/Slider.tsx +100 -54
  155. package/src/Stepper.tsx +315 -0
  156. package/src/Switch.tsx +80 -58
  157. package/src/TabBar.tsx +118 -84
  158. package/src/Tabs.tsx +5 -0
  159. package/src/Textarea.tsx +34 -0
  160. package/src/Toast.tsx +131 -0
  161. package/src/Toggle.tsx +113 -0
  162. package/src/ToggleGroup.tsx +129 -0
  163. package/src/Toolbar.tsx +111 -0
  164. package/src/Tooltip.tsx +79 -0
  165. package/src/engine/CHANGELOG.md +430 -0
  166. package/src/engine/NOTICE +54 -0
  167. package/src/engine/README.md +975 -0
  168. package/src/engine/android/build.gradle +18 -0
  169. package/src/engine/android/src/main/AndroidManifest.xml +2 -0
  170. package/src/engine/android/src/main/java/expo/modules/liquidglass/ExpoLiquidGlassModule.kt +174 -0
  171. package/src/engine/android/src/main/java/expo/modules/liquidglass/GlassConstants.kt +7 -0
  172. package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassContainerView.kt +16 -0
  173. package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassProviderView.kt +165 -0
  174. package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassView.kt +1731 -0
  175. package/src/engine/android/src/main/java/expo/modules/liquidglass/enums/GlassEnums.kt +171 -0
  176. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/BackdropGraph.kt +146 -0
  177. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/BackdropSource.kt +53 -0
  178. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/ContinuousCorners.kt +188 -0
  179. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/CornerRadii.kt +62 -0
  180. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassAppearance.kt +352 -0
  181. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassDebug.kt +109 -0
  182. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassEnvironment.kt +139 -0
  183. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassHdr.kt +85 -0
  184. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassLuminanceProbe.kt +189 -0
  185. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassPressAnimator.kt +264 -0
  186. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassProgressiveBlur.kt +249 -0
  187. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassShaderCache.kt +256 -0
  188. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassShaderSource.kt +845 -0
  189. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassTier.kt +63 -0
  190. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/ProviderRegistry.kt +71 -0
  191. package/src/engine/android/src/main/java/expo/modules/liquidglass/records/GlassRecords.kt +288 -0
  192. package/src/engine/index.ts +24 -0
  193. package/src/engine/ios/Enums/GlassBlurDirection.swift +21 -0
  194. package/src/engine/ios/Enums/GlassVariant.swift +86 -0
  195. package/src/engine/ios/ExpoLiquidGlass.podspec +93 -0
  196. package/src/engine/ios/ExpoLiquidGlassModule.swift +77 -0
  197. package/src/engine/ios/Glass/BackdropCapturer.swift +811 -0
  198. package/src/engine/ios/Glass/ContinuousCorners.swift +165 -0
  199. package/src/engine/ios/Glass/GlassBackdrop.swift +176 -0
  200. package/src/engine/ios/Glass/GlassFramePhase.swift +126 -0
  201. package/src/engine/ios/Glass/GlassFrameScheduler.swift +261 -0
  202. package/src/engine/ios/Glass/GlassPressAnimator.swift +250 -0
  203. package/src/engine/ios/Glass/GlassRenderContext.swift +168 -0
  204. package/src/engine/ios/Glass/GlassRenderer.swift +186 -0
  205. package/src/engine/ios/Glass/GlassSurfaceView.swift +452 -0
  206. package/src/engine/ios/Glass/NonRenderableView.swift +54 -0
  207. package/src/engine/ios/Glass/StripCache.swift +545 -0
  208. package/src/engine/ios/Records/GlassCornerRadii.swift +79 -0
  209. package/src/engine/ios/Records/GlassMetalOptions.swift +180 -0
  210. package/src/engine/ios/Records/GlassRefractionCurve.swift +14 -0
  211. package/src/engine/ios/Shaders/LiquidGlass.metal +480 -0
  212. package/src/engine/ios/Shaders/bundle-marker.txt +6 -0
  213. package/src/engine/ios/Views/LiquidGlassContainerView.swift +99 -0
  214. package/src/engine/ios/Views/LiquidGlassView.swift +859 -0
  215. package/src/engine/package.json +70 -0
  216. package/src/engine/src/components/LiquidGlassButton/LiquidGlassButton.tsx +424 -0
  217. package/src/engine/src/components/LiquidGlassCard/LiquidGlassCard.tsx +98 -0
  218. package/src/engine/src/components/LiquidGlassChip/LiquidGlassChip.tsx +65 -0
  219. package/src/engine/src/components/LiquidGlassGroup/LiquidGlassGroup.tsx +350 -0
  220. package/src/engine/src/components/LiquidGlassIconButton/LiquidGlassIconButton.tsx +24 -0
  221. package/src/engine/src/components/LiquidGlassMorphGroup/LiquidGlassMorphGroup.tsx +434 -0
  222. package/src/engine/src/components/LiquidGlassScrim/LiquidGlassScrim.tsx +100 -0
  223. package/src/engine/src/components/LiquidGlassSegmentedControl/LiquidGlassSegmentedControl.tsx +213 -0
  224. package/src/engine/src/components/LiquidGlassSheet/LiquidGlassSheet.tsx +218 -0
  225. package/src/engine/src/components/LiquidGlassSlider/LiquidGlassSlider.tsx +327 -0
  226. package/src/engine/src/components/LiquidGlassStepper/LiquidGlassStepper.tsx +321 -0
  227. package/src/engine/src/components/LiquidGlassSwitch/LiquidGlassSwitch.tsx +296 -0
  228. package/src/engine/src/components/LiquidGlassTabBar/LiquidGlassTabBar.tsx +952 -0
  229. package/src/engine/src/components/LiquidGlassTextInput/LiquidGlassTextInput.tsx +151 -0
  230. package/src/engine/src/components/LiquidGlassToast/LiquidGlassToast.tsx +169 -0
  231. package/src/engine/src/components/LiquidGlassToolbar/LiquidGlassToolbar.tsx +124 -0
  232. package/src/engine/src/components/index.ts +16 -0
  233. package/src/engine/src/constants/index.ts +4 -0
  234. package/src/engine/src/constants/metal.constants.ts +327 -0
  235. package/src/engine/src/constants/metrics.constants.ts +325 -0
  236. package/src/engine/src/constants/springs.constants.ts +107 -0
  237. package/src/engine/src/constants/styles.constants.ts +12 -0
  238. package/src/engine/src/context/glass-group.context.ts +65 -0
  239. package/src/engine/src/context/index.ts +6 -0
  240. package/src/engine/src/core/components/LiquidGlassContainer/LiquidGlassContainer.tsx +32 -0
  241. package/src/engine/src/core/components/LiquidGlassContainer/index.ts +1 -0
  242. package/src/engine/src/core/components/LiquidGlassProvider/LiquidGlassProvider.tsx +66 -0
  243. package/src/engine/src/core/components/LiquidGlassProvider/index.ts +1 -0
  244. package/src/engine/src/core/components/LiquidGlassStack/LiquidGlassStack.tsx +184 -0
  245. package/src/engine/src/core/components/LiquidGlassStack/index.ts +1 -0
  246. package/src/engine/src/core/components/LiquidGlassView/LiquidGlassView.tsx +126 -0
  247. package/src/engine/src/core/components/LiquidGlassView/index.ts +1 -0
  248. package/src/engine/src/core/components/index.ts +4 -0
  249. package/src/engine/src/core/constants/glass.constants.ts +57 -0
  250. package/src/engine/src/core/constants/index.ts +20 -0
  251. package/src/engine/src/core/constants/native.constants.ts +16 -0
  252. package/src/engine/src/core/context/glass-stack.context.ts +30 -0
  253. package/src/engine/src/core/context/index.ts +4 -0
  254. package/src/engine/src/core/enum/index.ts +12 -0
  255. package/src/engine/src/core/index.ts +1 -0
  256. package/src/engine/src/core/interfaces/glass-hdr.interface.ts +15 -0
  257. package/src/engine/src/core/interfaces/glass-metal.interface.ts +248 -0
  258. package/src/engine/src/core/interfaces/glass-surface.interface.ts +9 -0
  259. package/src/engine/src/core/interfaces/index.ts +31 -0
  260. package/src/engine/src/core/interfaces/liquid-glass-container.interface.ts +6 -0
  261. package/src/engine/src/core/interfaces/liquid-glass-provider.interface.ts +14 -0
  262. package/src/engine/src/core/interfaces/liquid-glass-stack.interface.ts +21 -0
  263. package/src/engine/src/core/interfaces/liquid-glass-view.interface.ts +129 -0
  264. package/src/engine/src/core/interfaces/native-liquid-glass-view.interface.ts +19 -0
  265. package/src/engine/src/core/modules/ExpoLiquidGlassModule.ts +26 -0
  266. package/src/engine/src/core/modules/index.ts +2 -0
  267. package/src/engine/src/core/root/index.ts +51 -0
  268. package/src/engine/src/core/types/glass.types.ts +25 -0
  269. package/src/engine/src/core/types/index.ts +8 -0
  270. package/src/engine/src/core/utils/debug.utils.ts +17 -0
  271. package/src/engine/src/core/utils/dev-warn.utils.ts +17 -0
  272. package/src/engine/src/core/utils/hdr.utils.ts +37 -0
  273. package/src/engine/src/core/utils/index.ts +5 -0
  274. package/src/engine/src/core/utils/native-view.utils.ts +33 -0
  275. package/src/engine/src/core/utils/platform.utils.ts +34 -0
  276. package/src/engine/src/core/views/NativeGlassBackdropView.ts +24 -0
  277. package/src/engine/src/core/views/NativeLiquidGlassContainerView.ts +13 -0
  278. package/src/engine/src/core/views/NativeLiquidGlassContainerView.web.ts +10 -0
  279. package/src/engine/src/core/views/NativeLiquidGlassProviderView.ts +13 -0
  280. package/src/engine/src/core/views/NativeLiquidGlassProviderView.web.ts +10 -0
  281. package/src/engine/src/core/views/NativeLiquidGlassView.ts +19 -0
  282. package/src/engine/src/core/views/NativeLiquidGlassView.web.ts +14 -0
  283. package/src/engine/src/core/views/index.ts +4 -0
  284. package/src/engine/src/hooks/index.ts +18 -0
  285. package/src/engine/src/hooks/use-adaptive-glass.ts +91 -0
  286. package/src/engine/src/hooks/use-damped-drag.ts +332 -0
  287. package/src/engine/src/hooks/use-echo-filter.ts +55 -0
  288. package/src/engine/src/hooks/use-glass-group-member.ts +169 -0
  289. package/src/engine/src/hooks/use-gravity-highlight.ts +79 -0
  290. package/src/engine/src/hooks/use-press-progress.ts +44 -0
  291. package/src/engine/src/index.ts +120 -0
  292. package/src/engine/src/interfaces/index.ts +28 -0
  293. package/src/engine/src/interfaces/liquid-glass-button.interface.ts +94 -0
  294. package/src/engine/src/interfaces/liquid-glass-card.interface.ts +40 -0
  295. package/src/engine/src/interfaces/liquid-glass-chip.interface.ts +29 -0
  296. package/src/engine/src/interfaces/liquid-glass-group.interface.ts +32 -0
  297. package/src/engine/src/interfaces/liquid-glass-icon-button.interface.ts +19 -0
  298. package/src/engine/src/interfaces/liquid-glass-morph-group.interface.ts +59 -0
  299. package/src/engine/src/interfaces/liquid-glass-scrim.interface.ts +36 -0
  300. package/src/engine/src/interfaces/liquid-glass-segmented-control.interface.ts +32 -0
  301. package/src/engine/src/interfaces/liquid-glass-sheet.interface.ts +38 -0
  302. package/src/engine/src/interfaces/liquid-glass-slider.interface.ts +37 -0
  303. package/src/engine/src/interfaces/liquid-glass-stepper.interface.ts +35 -0
  304. package/src/engine/src/interfaces/liquid-glass-switch.interface.ts +27 -0
  305. package/src/engine/src/interfaces/liquid-glass-tab-bar.interface.ts +116 -0
  306. package/src/engine/src/interfaces/liquid-glass-text-input.interface.ts +42 -0
  307. package/src/engine/src/interfaces/liquid-glass-toast.interface.ts +36 -0
  308. package/src/engine/src/interfaces/liquid-glass-toolbar.interface.ts +33 -0
  309. package/src/engine/src/theme/glass-ui-theme.ts +100 -0
  310. package/src/engine/src/theme/index.ts +2 -0
  311. package/src/engine/src/utils/button-press.utils.ts +63 -0
  312. package/src/engine/src/utils/index.ts +3 -0
  313. package/src/engine/src/utils/metal.utils.ts +164 -0
  314. package/src/glass-provider.tsx +60 -0
  315. package/src/glass-stack.tsx +115 -0
  316. package/src/index.ts +48 -190
  317. package/src/internal/GlassBackdrop.tsx +60 -0
  318. package/src/internal/GlassView.tsx +70 -18
  319. package/src/internal/blur-community.ts +19 -0
  320. package/src/internal/blur-community.web.ts +7 -0
  321. package/src/internal/blur.ts +89 -0
  322. package/src/internal/fallback.tsx +158 -20
  323. package/src/internal/glass-routing.ts +211 -34
  324. package/src/internal/glow.tsx +62 -0
  325. package/src/internal/initials.ts +7 -0
  326. package/src/internal/lens.tsx +105 -0
  327. package/src/internal/material.ts +92 -0
  328. package/src/internal/overlay.tsx +258 -0
  329. package/src/internal/primitives.ts +26 -0
  330. package/src/internal/rim.tsx +79 -0
  331. package/src/internal/tokens.ts +34 -1
  332. package/lib/module/Carousel.js +0 -103
  333. package/lib/module/Display.js +0 -317
  334. package/lib/module/Feedback.js +0 -386
  335. package/lib/module/Form.js +0 -164
  336. package/lib/module/Forms2.js +0 -454
  337. package/lib/module/Message.js +0 -88
  338. package/lib/module/Overlays.js +0 -328
  339. package/lib/module/Pickers.js +0 -243
  340. package/lib/module/Table.js +0 -99
  341. package/lib/module/ai.js +0 -280
  342. package/lib/module/charts/AreaChart.js +0 -32
  343. package/lib/module/charts/BarChart.js +0 -67
  344. package/lib/module/charts/FunnelChart.js +0 -50
  345. package/lib/module/charts/HeatmapChart.js +0 -71
  346. package/lib/module/charts/LineChart.js +0 -81
  347. package/lib/module/charts/PlotChart.js +0 -52
  348. package/lib/module/charts/RadarChart.js +0 -78
  349. package/lib/module/charts/RingChart.js +0 -52
  350. package/lib/module/charts/ScatterChart.js +0 -95
  351. package/lib/module/charts/WaterfallChart.js +0 -85
  352. package/lib/module/charts/advanced.js +0 -313
  353. package/lib/module/charts/extra.js +0 -108
  354. package/lib/module/charts/index.js +0 -50
  355. package/lib/module/charts/scales.js +0 -140
  356. package/lib/typescript/Carousel.d.ts +0 -47
  357. package/lib/typescript/Display.d.ts +0 -178
  358. package/lib/typescript/Feedback.d.ts +0 -196
  359. package/lib/typescript/Form.d.ts +0 -97
  360. package/lib/typescript/Forms2.d.ts +0 -209
  361. package/lib/typescript/Message.d.ts +0 -71
  362. package/lib/typescript/Overlays.d.ts +0 -146
  363. package/lib/typescript/Pickers.d.ts +0 -105
  364. package/lib/typescript/Table.d.ts +0 -64
  365. package/lib/typescript/ai.d.ts +0 -166
  366. package/lib/typescript/charts/AreaChart.d.ts +0 -44
  367. package/lib/typescript/charts/BarChart.d.ts +0 -19
  368. package/lib/typescript/charts/FunnelChart.d.ts +0 -25
  369. package/lib/typescript/charts/HeatmapChart.d.ts +0 -23
  370. package/lib/typescript/charts/LineChart.d.ts +0 -30
  371. package/lib/typescript/charts/PlotChart.d.ts +0 -31
  372. package/lib/typescript/charts/RadarChart.d.ts +0 -27
  373. package/lib/typescript/charts/RingChart.d.ts +0 -28
  374. package/lib/typescript/charts/ScatterChart.d.ts +0 -34
  375. package/lib/typescript/charts/WaterfallChart.d.ts +0 -22
  376. package/lib/typescript/charts/advanced.d.ts +0 -107
  377. package/lib/typescript/charts/extra.d.ts +0 -63
  378. package/lib/typescript/charts/index.d.ts +0 -13
  379. package/lib/typescript/charts/scales.d.ts +0 -35
  380. package/src/Carousel.tsx +0 -233
  381. package/src/Display.tsx +0 -778
  382. package/src/Feedback.tsx +0 -969
  383. package/src/Form.tsx +0 -425
  384. package/src/Forms2.tsx +0 -1014
  385. package/src/Message.tsx +0 -219
  386. package/src/Overlays.tsx +0 -685
  387. package/src/Pickers.tsx +0 -590
  388. package/src/Table.tsx +0 -231
  389. package/src/ai.tsx +0 -707
  390. package/src/charts/AreaChart.tsx +0 -73
  391. package/src/charts/BarChart.tsx +0 -183
  392. package/src/charts/FunnelChart.tsx +0 -125
  393. package/src/charts/HeatmapChart.tsx +0 -155
  394. package/src/charts/LineChart.tsx +0 -247
  395. package/src/charts/PlotChart.tsx +0 -168
  396. package/src/charts/RadarChart.tsx +0 -208
  397. package/src/charts/RingChart.tsx +0 -133
  398. package/src/charts/ScatterChart.tsx +0 -223
  399. package/src/charts/WaterfallChart.tsx +0 -201
  400. package/src/charts/advanced.tsx +0 -676
  401. package/src/charts/extra.tsx +0 -242
  402. package/src/charts/index.ts +0 -86
  403. package/src/charts/scales.ts +0 -163
package/src/Forms2.tsx DELETED
@@ -1,1014 +0,0 @@
1
- import { forwardRef, useRef, useState, type ReactNode } from "react";
2
- import type { StyleProp, ViewStyle } from "react-native";
3
-
4
- import { Glass } from "./Glass";
5
- import { Text } from "./Text";
6
- import { colors, controlSizes, palette as tokenPalette, radii } from "./internal/tokens";
7
- import { primitives } from "./internal/primitives";
8
- import { useIsDark } from "./internal/motion";
9
-
10
- // ---------------------------------------------------------------------------
11
- // Stepper
12
-
13
- export interface StepperProps {
14
- /** Controlled value. Omit and the stepper keeps its own. */
15
- value?: number;
16
- defaultValue?: number;
17
- onValueChange?: (value: number) => void;
18
- min?: number;
19
- max?: number;
20
- step?: number;
21
- disabled?: boolean;
22
- /** Announced by screen readers, e.g. "Guests". */
23
- accessibilityLabel: string;
24
- /** Formats the middle readout; defaults to the plain number. */
25
- formatValue?: (value: number) => string;
26
- style?: StyleProp<ViewStyle>;
27
- isDark?: boolean;
28
- testID?: string;
29
- }
30
-
31
- /**
32
- * Minus / value / plus.
33
- *
34
- * The same interaction contract Slider established: `adjustable` with
35
- * increment and decrement accessibility actions, and clamping at min and max
36
- * rather than wrapping or drifting past the range.
37
- */
38
- export const Stepper = forwardRef<any, StepperProps>(function Stepper(
39
- {
40
- value: valueProp,
41
- defaultValue = 0,
42
- onValueChange,
43
- min = 0,
44
- max = 100,
45
- step = 1,
46
- disabled = false,
47
- accessibilityLabel,
48
- formatValue,
49
- style,
50
- isDark: isDarkProp,
51
- testID,
52
- ...props
53
- },
54
- ref,
55
- ) {
56
- const isDark = useIsDark(isDarkProp);
57
- const theme = isDark ? colors.dark : colors.light;
58
- const { View, Text: RNText, Pressable } = primitives();
59
-
60
- const [internal, setInternal] = useState(defaultValue);
61
- const value = valueProp !== undefined ? valueProp : internal;
62
-
63
- const apply = (next: number) => {
64
- const clamped = Math.min(Math.max(next, min), max);
65
- if (clamped === value) return;
66
- if (valueProp === undefined) setInternal(clamped);
67
- onValueChange?.(clamped);
68
- };
69
-
70
- const atMin = value <= min;
71
- const atMax = value >= max;
72
-
73
- const stepButton = (
74
- label: string,
75
- sign: "\u2212" | "+",
76
- action: () => void,
77
- blocked: boolean,
78
- ) => (
79
- <Pressable
80
- accessibilityRole="button"
81
- accessibilityLabel={label}
82
- accessibilityState={{ disabled: disabled || blocked }}
83
- disabled={disabled || blocked}
84
- onPress={action}
85
- style={{ width: 36, height: 36, alignItems: "center", justifyContent: "center", opacity: disabled || blocked ? 0.38 : 1 }}
86
- >
87
- <RNText style={{ fontSize: 20, fontWeight: "500", color: theme.foreground, lineHeight: 22 }}>
88
- {sign}
89
- </RNText>
90
- </Pressable>
91
- );
92
-
93
- return (
94
- <Glass
95
- ref={ref}
96
- effect="regular"
97
- isDark={isDark}
98
- testID={testID}
99
- accessibilityRole="adjustable"
100
- accessibilityLabel={accessibilityLabel}
101
- accessibilityValue={{ min, max, now: value }}
102
- accessibilityActions={[{ name: "increment" }, { name: "decrement" }]}
103
- onAccessibilityAction={(event: any) => {
104
- const delta = event?.nativeEvent?.actionName === "increment" ? step : -step;
105
- apply(value + delta);
106
- }}
107
- style={{
108
- flexDirection: "row",
109
- alignItems: "center",
110
- alignSelf: "flex-start",
111
- borderRadius: radii.pill,
112
- paddingHorizontal: 2,
113
- opacity: disabled ? 0.38 : 1,
114
- ...(style as ViewStyle),
115
- }}
116
- {...props}
117
- >
118
- {stepButton(`Decrease ${accessibilityLabel}`, "\u2212", () => apply(value - step), atMin)}
119
- <View style={{ minWidth: 44, alignItems: "center", justifyContent: "center" }}>
120
- <RNText style={{ fontSize: 16, fontWeight: "600", color: theme.foreground }} numberOfLines={1}>
121
- {formatValue ? formatValue(value) : String(value)}
122
- </RNText>
123
- </View>
124
- {stepButton(`Increase ${accessibilityLabel}`, "+", () => apply(value + step), atMax)}
125
- </Glass>
126
- );
127
- });
128
-
129
- // ---------------------------------------------------------------------------
130
- // Toggle
131
-
132
- export interface ToggleProps {
133
- /** Controlled pressed state. Omit and the toggle keeps its own. */
134
- pressed?: boolean;
135
- defaultPressed?: boolean;
136
- onPressedChange?: (pressed: boolean) => void;
137
- /** Equivalent to `pressed`, matching web's Toggle naming. */
138
- selected?: boolean;
139
- icon?: ReactNode;
140
- children?: ReactNode;
141
- variant?: "glass" | "ghost";
142
- size?: "sm" | "md" | "lg";
143
- disabled?: boolean;
144
- /** Required when the toggle has no visible text. */
145
- accessibilityLabel?: string;
146
- style?: StyleProp<ViewStyle>;
147
- isDark?: boolean;
148
- testID?: string;
149
- }
150
-
151
- const toggleSizes = { sm: 30, md: 36, lg: 44 };
152
-
153
- /**
154
- * A button that stays pressed.
155
- *
156
- * Distinct from Switch: this is a button with an on-state (bold, favourite,
157
- * pinned), not a setting. It reports `selected`, which is what web's Toggle
158
- * announces.
159
- */
160
- export const Toggle = forwardRef<any, ToggleProps>(function Toggle(
161
- {
162
- pressed: pressedProp,
163
- defaultPressed = false,
164
- onPressedChange,
165
- selected,
166
- icon,
167
- children,
168
- variant = "glass",
169
- size = "md",
170
- disabled = false,
171
- accessibilityLabel,
172
- style,
173
- isDark: isDarkProp,
174
- testID,
175
- ...props
176
- },
177
- ref,
178
- ) {
179
- const isDark = useIsDark(isDarkProp);
180
- const theme = isDark ? colors.dark : colors.light;
181
- const { View, Text: RNText, Pressable } = primitives();
182
-
183
- // `selected` is accepted as an alias so the controlled prop matches web.
184
- const controlled = pressedProp !== undefined ? pressedProp : selected;
185
- const [internal, setInternal] = useState(defaultPressed);
186
- const isPressed = controlled !== undefined ? controlled : internal;
187
-
188
- const dimension = toggleSizes[size];
189
-
190
- const handlePress = () => {
191
- const next = !isPressed;
192
- if (controlled === undefined) setInternal(next);
193
- onPressedChange?.(next);
194
- };
195
-
196
- return (
197
- <Pressable
198
- ref={ref}
199
- testID={testID}
200
- accessibilityRole="button"
201
- accessibilityLabel={accessibilityLabel ?? (typeof children === "string" ? children : undefined)}
202
- accessibilityState={{ selected: isPressed, disabled }}
203
- disabled={disabled}
204
- onPress={handlePress}
205
- style={({ pressed }: { pressed: boolean }) => ({ alignSelf: "flex-start", opacity: disabled ? 0.38 : pressed ? 0.8 : 1 })}
206
- {...props}
207
- >
208
- <Glass
209
- effect={variant === "ghost" ? "none" : "regular"}
210
- interactive={!disabled && variant !== "ghost"}
211
- isDark={isDark}
212
- tintColor={isPressed && variant !== "ghost" ? theme.glassActive : undefined}
213
- style={{
214
- height: dimension,
215
- borderRadius: radii.pill,
216
- paddingHorizontal: icon && !children ? 0 : 12,
217
- width: icon && !children ? dimension : undefined,
218
- flexDirection: "row",
219
- alignItems: "center",
220
- justifyContent: "center",
221
- gap: 6,
222
- backgroundColor: variant === "ghost" ? "transparent" : undefined,
223
- ...(style as ViewStyle),
224
- }}
225
- >
226
- {icon ? <View>{icon}</View> : null}
227
- {typeof children === "string" ? (
228
- <RNText
229
- numberOfLines={1}
230
- style={{
231
- fontSize: size === "sm" ? 12 : size === "lg" ? 15 : 13,
232
- fontWeight: isPressed ? "600" : "500",
233
- color: isPressed ? theme.foreground : theme.muted,
234
- }}
235
- >
236
- {children}
237
- </RNText>
238
- ) : (
239
- children
240
- )}
241
- </Glass>
242
- </Pressable>
243
- );
244
- });
245
-
246
- // ---------------------------------------------------------------------------
247
- // ToggleGroup
248
-
249
- export interface ToggleGroupItem {
250
- value: string;
251
- label: string;
252
- icon?: ReactNode;
253
- }
254
-
255
- export interface ToggleGroupProps {
256
- items: ToggleGroupItem[];
257
- /** Allow several items on at once. */
258
- multiple?: boolean;
259
- /** Controlled selection. A string for single mode, an array for multiple. */
260
- value?: string | string[];
261
- defaultValue?: string | string[];
262
- onValueChange?: (value: string | string[]) => void;
263
- size?: "sm" | "md" | "lg";
264
- disabled?: boolean;
265
- accessibilityLabel?: string;
266
- style?: StyleProp<ViewStyle>;
267
- isDark?: boolean;
268
- testID?: string;
269
- }
270
-
271
- /**
272
- * A row of toggles acting as one choice.
273
- *
274
- * Built from the same pieces as SegmentedControl — one glass container, toggles
275
- * inside it, `glassActive` marking the active ones — but each item carries the
276
- * button styling of Toggle.
277
- */
278
- export const ToggleGroup = forwardRef<any, ToggleGroupProps>(function ToggleGroup(
279
- {
280
- items,
281
- multiple = false,
282
- value: valueProp,
283
- defaultValue,
284
- onValueChange,
285
- size = "md",
286
- disabled = false,
287
- accessibilityLabel = "Toggle group",
288
- style,
289
- isDark: isDarkProp,
290
- testID,
291
- ...props
292
- },
293
- ref,
294
- ) {
295
- const isDark = useIsDark(isDarkProp);
296
- const theme = isDark ? colors.dark : colors.light;
297
- const { View, Text: RNText, Pressable } = primitives();
298
-
299
- const initial = defaultValue ?? (multiple ? [] : "");
300
- const [internal, setInternal] = useState<string | string[]>(initial);
301
- const selection = valueProp !== undefined ? valueProp : internal;
302
-
303
- const isOn = (value: string) =>
304
- Array.isArray(selection) ? selection.includes(value) : selection === value;
305
-
306
- const toggle = (value: string) => {
307
- let next: string | string[];
308
- if (multiple) {
309
- const current = Array.isArray(selection) ? selection : [];
310
- next = current.includes(value) ? current.filter((v) => v !== value) : [...current, value];
311
- } else {
312
- // Single mode: the same item pressed again clears it, as Toggle does.
313
- next = selection === value ? "" : value;
314
- }
315
- if (valueProp === undefined) setInternal(next);
316
- onValueChange?.(next);
317
- };
318
-
319
- const height = size === "sm" ? 30 : size === "lg" ? 42 : 36;
320
-
321
- return (
322
- <Glass
323
- ref={ref}
324
- effect="regular"
325
- isDark={isDark}
326
- testID={testID}
327
- accessibilityRole="radiogroup"
328
- accessibilityLabel={accessibilityLabel}
329
- style={{
330
- flexDirection: "row",
331
- alignItems: "center",
332
- alignSelf: "flex-start",
333
- padding: 3,
334
- gap: 3,
335
- borderRadius: radii.pill,
336
- ...(style as ViewStyle),
337
- }}
338
- {...props}
339
- >
340
- {items.map((item) => {
341
- const on = isOn(item.value);
342
- return (
343
- <Pressable
344
- key={item.value}
345
- accessibilityRole="button"
346
- accessibilityLabel={item.label}
347
- accessibilityState={{ selected: on, disabled }}
348
- disabled={disabled}
349
- onPress={() => toggle(item.value)}
350
- style={{ opacity: disabled ? 0.38 : 1 }}
351
- >
352
- <View
353
- style={{
354
- height: height - 6,
355
- paddingHorizontal: 14,
356
- borderRadius: radii.pill,
357
- flexDirection: "row",
358
- alignItems: "center",
359
- justifyContent: "center",
360
- gap: 6,
361
- backgroundColor: on ? theme.glassActive : "transparent",
362
- borderWidth: on ? 0.5 : 0,
363
- borderColor: theme.edge,
364
- }}
365
- >
366
- {item.icon ? <View>{item.icon}</View> : null}
367
- <RNText
368
- numberOfLines={1}
369
- style={{ fontSize: 13, fontWeight: on ? "600" : "500", color: on ? theme.foreground : theme.muted }}
370
- >
371
- {item.label}
372
- </RNText>
373
- </View>
374
- </Pressable>
375
- );
376
- })}
377
- </Glass>
378
- );
379
- });
380
-
381
- // ---------------------------------------------------------------------------
382
- // InputOTP
383
-
384
- export interface InputOTPProps {
385
- /** Controlled code. Omit and the field keeps its own. */
386
- value?: string;
387
- defaultValue?: string;
388
- onChange?: (value: string) => void;
389
- /** Fires once the code reaches `length` characters. */
390
- onComplete?: (value: string) => void;
391
- /** How many digits. */
392
- length?: number;
393
- disabled?: boolean;
394
- accessibilityLabel?: string;
395
- style?: StyleProp<ViewStyle>;
396
- isDark?: boolean;
397
- testID?: string;
398
- }
399
-
400
- /**
401
- * A verification-code row.
402
- *
403
- * One real text field drives the boxes. Keeping a single field — rather than N
404
- * inputs — is what makes paste and autofill fill every box in one go, and it is
405
- * what keeps the caret and keyboard behaviour sane across platforms.
406
- */
407
- export const InputOTP = forwardRef<any, InputOTPProps>(function InputOTP(
408
- {
409
- value: valueProp,
410
- defaultValue = "",
411
- onChange,
412
- onComplete,
413
- length = 6,
414
- disabled = false,
415
- accessibilityLabel = "Verification code",
416
- style,
417
- isDark: isDarkProp,
418
- testID,
419
- ...props
420
- },
421
- ref,
422
- ) {
423
- const isDark = useIsDark(isDarkProp);
424
- const theme = isDark ? colors.dark : colors.light;
425
- const { View, Text: RNText, TextInput } = primitives();
426
-
427
- const [internal, setInternal] = useState(defaultValue);
428
- const value = valueProp !== undefined ? valueProp : internal;
429
-
430
- // The code is digits only, and never longer than the boxes available.
431
- const normalise = (raw: string) => raw.replace(/[^0-9]/g, "").slice(0, length);
432
-
433
- const handleChange = (raw: string) => {
434
- const next = normalise(raw);
435
- if (valueProp === undefined) setInternal(next);
436
- onChange?.(next);
437
- if (next.length === length) onComplete?.(next);
438
- };
439
-
440
- const focusedIndex = Math.min(value.length, length - 1);
441
-
442
- return (
443
- <View
444
- ref={ref}
445
- testID={testID}
446
- style={[{ flexDirection: "row", alignItems: "center", gap: 8, alignSelf: "flex-start" }, style as ViewStyle]}
447
- {...props}
448
- >
449
- {Array.from({ length }, (_, index) => {
450
- const char = value[index] ?? "";
451
- const isActive = index === focusedIndex && !disabled;
452
- return (
453
- <Glass
454
- key={index}
455
- effect="regular"
456
- isDark={isDark}
457
- tintColor={isActive ? theme.glassActive : undefined}
458
- style={{
459
- width: 44,
460
- height: 52,
461
- borderRadius: radii.md,
462
- alignItems: "center",
463
- justifyContent: "center",
464
- borderColor: isActive ? theme.fill : theme.edge,
465
- opacity: disabled ? 0.38 : 1,
466
- }}
467
- >
468
- <RNText style={{ fontSize: 22, fontWeight: "600", color: theme.foreground }}>{char}</RNText>
469
- </Glass>
470
- );
471
- })}
472
- {/* The single real field. It is transparent and spans the row so a tap
473
- anywhere lands in the code, which is how the boxes stay in step. */}
474
- <TextInput
475
- accessibilityRole="text"
476
- accessibilityLabel={accessibilityLabel}
477
- accessibilityValue={{ text: value }}
478
- value={value}
479
- onChangeText={handleChange}
480
- editable={!disabled}
481
- keyboardType="number-pad"
482
- maxLength={length}
483
- textContentType="oneTimeCode"
484
- autoComplete="one-time-code"
485
- style={{
486
- position: "absolute",
487
- left: 0,
488
- right: 0,
489
- top: 0,
490
- bottom: 0,
491
- // Invisible but present: the boxes are the visible representation.
492
- opacity: 0.02,
493
- color: "transparent",
494
- }}
495
- />
496
- </View>
497
- );
498
- });
499
-
500
- // ---------------------------------------------------------------------------
501
- // ButtonGroup
502
-
503
- export interface ButtonGroupItem {
504
- label: string;
505
- onPress: () => void;
506
- disabled?: boolean;
507
- }
508
-
509
- export interface ButtonGroupProps {
510
- items: ButtonGroupItem[];
511
- size?: "sm" | "md" | "lg";
512
- /** `attached` shares edges; `segmented` leaves a gap between buttons. */
513
- variant?: "attached" | "segmented";
514
- /** A single handler instead of per-item `onPress`. */
515
- onItemPress?: (item: ButtonGroupItem, index: number) => void;
516
- accessibilityLabel?: string;
517
- style?: StyleProp<ViewStyle>;
518
- isDark?: boolean;
519
- testID?: string;
520
- }
521
-
522
- /**
523
- * A connected row of buttons.
524
- *
525
- * Stateless by design: it reports presses and holds no selection, which is what
526
- * separates it from SegmentedControl (a stateful choice) and ToggleGroup.
527
- */
528
- export const ButtonGroup = forwardRef<any, ButtonGroupProps>(function ButtonGroup(
529
- {
530
- items,
531
- size = "md",
532
- variant = "attached",
533
- onItemPress,
534
- accessibilityLabel,
535
- style,
536
- isDark: isDarkProp,
537
- testID,
538
- ...props
539
- },
540
- ref,
541
- ) {
542
- const isDark = useIsDark(isDarkProp);
543
- const theme = isDark ? colors.dark : colors.light;
544
- const { View, Text: RNText, Pressable } = primitives();
545
-
546
- const height = size === "sm" ? 32 : size === "lg" ? 46 : 40;
547
-
548
- return (
549
- <View
550
- ref={ref}
551
- testID={testID}
552
- accessibilityRole="group"
553
- accessibilityLabel={accessibilityLabel}
554
- style={{
555
- flexDirection: "row",
556
- alignSelf: "flex-start",
557
- gap: variant === "segmented" ? 6 : 0,
558
- ...(style as ViewStyle),
559
- }}
560
- {...props}
561
- >
562
- {items.map((item, index) => {
563
- const first = index === 0;
564
- const last = index === items.length - 1;
565
- // Attached buttons share edges: only the outer corners are rounded,
566
- // and the inner edges stay square so the group reads as one control.
567
- const pill = variant === "segmented" ? radii.pill : 0;
568
- return (
569
- <Pressable
570
- key={`${item.label}-${index}`}
571
- accessibilityRole="button"
572
- accessibilityLabel={item.label}
573
- accessibilityState={{ disabled: item.disabled }}
574
- disabled={item.disabled}
575
- onPress={() => {
576
- item.onPress();
577
- onItemPress?.(item, index);
578
- }}
579
- style={({ pressed }: { pressed: boolean }) => ({
580
- opacity: item.disabled ? 0.38 : pressed ? 0.85 : 1,
581
- })}
582
- >
583
- <Glass
584
- effect="regular"
585
- interactive={!item.disabled}
586
- isDark={isDark}
587
- style={{
588
- height,
589
- paddingHorizontal: 18,
590
- justifyContent: "center",
591
- alignItems: "center",
592
- borderRadius: variant === "segmented" ? pill : undefined,
593
- borderTopLeftRadius: variant === "segmented" ? pill : first ? radii.md : 0,
594
- borderBottomLeftRadius: variant === "segmented" ? pill : first ? radii.md : 0,
595
- borderTopRightRadius: variant === "segmented" ? pill : last ? radii.md : 0,
596
- borderBottomRightRadius: variant === "segmented" ? pill : last ? radii.md : 0,
597
- }}
598
- >
599
- <RNText numberOfLines={1} style={{ fontSize: size === "sm" ? 13 : 14, fontWeight: "500", color: theme.foreground }}>
600
- {item.label}
601
- </RNText>
602
- </Glass>
603
- </Pressable>
604
- );
605
- })}
606
- </View>
607
- );
608
- });
609
-
610
- // ---------------------------------------------------------------------------
611
- // ColorPicker
612
-
613
- export interface ColorPickerProps {
614
- /** A palette of hex colours the caller supplies. */
615
- colors?: string[];
616
- /** Controlled value. Omit and the picker keeps its own. */
617
- value?: string;
618
- defaultValue?: string;
619
- onChange?: (color: string) => void;
620
- /** The swatch size. */
621
- size?: "sm" | "md" | "lg";
622
- /** Rows in the palette grid. Defaults to a single row. */
623
- columns?: number;
624
- /** Whether a custom row (hue + picker) appears below the palette. */
625
- allowCustom?: boolean;
626
- disabled?: boolean;
627
- /** The accessible name. */
628
- accessibilityLabel?: string;
629
- style?: StyleProp<ViewStyle>;
630
- isDark?: boolean;
631
- testID?: string;
632
- }
633
-
634
- /**
635
- * A colour picker built from Glacia's own parts — no native widget.
636
- *
637
- * The palette is a grid of swatches from the caller's colours; the custom row
638
- * is a hue track drawn as an SVG gradient (the resolver's shapes, so it works
639
- * wherever the charts work) driven by the same Slider mechanics as the rest of
640
- * the library: a drag along the track picks a hue, and a second track saturates
641
- * it. The value is a hex string.
642
- *
643
- * The default palette is a small set of iOS-conventional colours, in case a
644
- * caller wants a picker with no colour knowledge of its own.
645
- */
646
- export const DEFAULT_PALETTE = tokenPalette.default;
647
-
648
- /** Parses a hex colour into its red, green and blue channels. */
649
- export function hexToRgb(hex: string): { r: number; g: number; b: number } | null {
650
- const match = /^#?([0-9a-f]{6})$/i.exec(hex.trim());
651
- if (!match) return null;
652
- const raw = match[1]!;
653
- return {
654
- r: parseInt(raw.slice(0, 2), 16),
655
- g: parseInt(raw.slice(2, 4), 16),
656
- b: parseInt(raw.slice(4, 6), 16),
657
- };
658
- }
659
-
660
- /** Builds a hue gradient's colours, sweeping red → orange → … → red. */
661
- export function hueGradientColors(): string[] {
662
- const stops = 12;
663
- return Array.from({ length: stops }, (_u, i) => {
664
- const angle = (i / stops) * 360;
665
- const c = hslToRgb(angle, 1, 0.5);
666
- return `#${c.r.toString(16).padStart(2, "0")}${c.g.toString(16).padStart(2, "0")}${c.b.toString(16).padStart(2, "0")}`;
667
- });
668
- }
669
-
670
- /** Converts an HSL triple (h 0–360, s/l 0–1) to an RGB hex string. */
671
- function hslToRgb(h: number, s: number, l: number): { r: number; g: number; b: number } {
672
- const c = (1 - Math.abs(2 * l - 1)) * s;
673
- const x = c * (1 - Math.abs(((h / 60) % 2) - 1));
674
- const m = l - c / 2;
675
- let r = 0, g = 0, b = 0;
676
- if (h < 60) { r = c; g = x; } else if (h < 120) { r = x; g = c; } else if (h < 180) { g = c; b = x; } else if (h < 240) { g = x; b = c; } else if (h < 300) { r = x; b = c; } else { r = c; b = x; }
677
- return {
678
- r: Math.round((r + m) * 255),
679
- g: Math.round((g + m) * 255),
680
- b: Math.round((b + m) * 255),
681
- };
682
- }
683
-
684
- /** Converts an RGB triple to a hex string. */
685
- export function rgbToHex(r: number, g: number, b: number): string {
686
- const clamp = (n: number) => Math.max(0, Math.min(255, Math.round(n)));
687
- return `#${clamp(r).toString(16).padStart(2, "0")}${clamp(g).toString(16).padStart(2, "0")}${clamp(b).toString(16).padStart(2, "0")}`;
688
- }
689
-
690
- export const ColorPicker = forwardRef<any, ColorPickerProps>(function ColorPicker(
691
- {
692
- colors: palette,
693
- value,
694
- defaultValue,
695
- onChange,
696
- size = "md",
697
- columns = 6,
698
- allowCustom = true,
699
- disabled = false,
700
- accessibilityLabel = "Color",
701
- style,
702
- isDark: isDarkProp,
703
- testID,
704
- ...props
705
- },
706
- ref,
707
- ) {
708
- const isDark = useIsDark(isDarkProp);
709
- const theme = isDark ? colors.dark : colors.light;
710
- const { View, Pressable, Text: RNText, PanResponder, Svg, Rect, Defs, LinearGradient, Stop } = primitives();
711
-
712
- const swatches = palette && palette.length > 0 ? palette : DEFAULT_PALETTE;
713
-
714
- const [internalValue, setInternalValue] = useState(defaultValue ?? swatches[0] ?? tokenPalette.fallback);
715
- const activeColor = value !== undefined ? value : internalValue;
716
-
717
- const setColor = (next: string) => {
718
- if (disabled) return;
719
- if (value === undefined) setInternalValue(next);
720
- onChange?.(next);
721
- };
722
-
723
- // The custom row's two tracks: hue on the top, saturation on the bottom.
724
- // Both are driven by PanResponder like the library's Slider — a press or a
725
- // drag along a track reports the colour at that position.
726
- const trackRef = useRef(0);
727
- const swatchSize = controlSizes.swatch[size];
728
-
729
- const hueColor = (h: number) => {
730
- const c = hslToRgb(h, 1, 0.5);
731
- return rgbToHex(c.r, c.g, c.b);
732
- };
733
-
734
- const colorAtFraction = (fraction: number, hue: number) => {
735
- const sat = Math.max(0, Math.min(1, fraction));
736
- const c = hslToRgb(hue, sat, 0.5);
737
- return rgbToHex(c.r, c.g, c.b);
738
- };
739
-
740
- const hue = hexToRgb(activeColor) ? hueOf(activeColor) : 0;
741
-
742
- const hueResponder = makeTrackResponder((fraction) => {
743
- setColor(hueColor(fraction * 360));
744
- }, PanResponder, trackRef);
745
-
746
- const satResponder = makeTrackResponder((fraction) => {
747
- setColor(colorAtFraction(fraction, hue));
748
- }, PanResponder, trackRef);
749
-
750
- const hueGradient = hueGradientColors();
751
-
752
- return (
753
- <View
754
- ref={ref}
755
- testID={testID}
756
- accessibilityRole="adjustable"
757
- accessibilityLabel={accessibilityLabel}
758
- accessibilityValue={{ text: activeColor }}
759
- style={{ gap: 12, opacity: disabled ? 0.38 : 1, ...(style as ViewStyle) }}
760
- {...props}
761
- >
762
- {/* The palette grid. */}
763
- <View style={{ flexDirection: "row", flexWrap: "wrap", gap: 8 }}>
764
- {swatches.map((swatch, index) => {
765
- const selected = swatch.toLowerCase() === activeColor.toLowerCase();
766
- return (
767
- <Pressable
768
- key={`${swatch}-${index}`}
769
- accessibilityRole="button"
770
- accessibilityLabel={`${swatch} color`}
771
- accessibilityState={{ selected }}
772
- disabled={disabled}
773
- onPress={() => setColor(swatch)}
774
- style={{
775
- width: swatchSize,
776
- height: swatchSize,
777
- borderRadius: swatchSize / 2,
778
- backgroundColor: swatch,
779
- borderWidth: selected ? 2 : 0.5,
780
- borderColor: selected ? theme.fill : theme.separator,
781
- }}
782
- />
783
- );
784
- })}
785
- </View>
786
-
787
- {allowCustom ? (
788
- <View style={{ gap: 8 }}>
789
- {/* Hue track */}
790
- <View
791
- style={{ height: controlSizes.picker.track, borderRadius: radii.md, overflow: "hidden" }}
792
- {...(hueResponder ? hueResponder.panHandlers : {})}
793
- >
794
- <Svg width="100%" height="100%">
795
- <Defs>
796
- <LinearGradient id="hueGradient" x1="0" y1="0" x2="1" y2="0">
797
- {hueGradient.map((color, i) => (
798
- <Stop key={i} offset={i / (hueGradient.length - 1)} stopColor={color} />
799
- ))}
800
- </LinearGradient>
801
- </Defs>
802
- <Rect x="0" y="0" width="100%" height="100%" fill="url(#hueGradient)" />
803
- </Svg>
804
- </View>
805
- {/* Saturation track: the hue at full saturation fading to white. */}
806
- <View
807
- style={{ height: controlSizes.picker.track, borderRadius: radii.md, overflow: "hidden" }}
808
- {...(satResponder ? satResponder.panHandlers : {})}
809
- >
810
- <Svg width="100%" height="100%">
811
- <Defs>
812
- <LinearGradient id="satGradient" x1="0" y1="0" x2="1" y2="0">
813
- <Stop offset="0" stopColor={theme.neutralTop} />
814
- <Stop offset="1" stopColor={hueColor(hue)} />
815
- </LinearGradient>
816
- </Defs>
817
- <Rect x="0" y="0" width="100%" height="100%" fill="url(#satGradient)" />
818
- </Svg>
819
- </View>
820
- <RNText style={{ fontSize: 12, color: theme.muted }}>{activeColor}</RNText>
821
- </View>
822
- ) : null}
823
- </View>
824
- );
825
- });
826
-
827
- /** The hue (0–360) of a hex colour. */
828
- function hueOf(hex: string): number {
829
- const rgb = hexToRgb(hex);
830
- if (!rgb) return 0;
831
- const { r, g, b } = rgb;
832
- const max = Math.max(r, g, b) / 255;
833
- const min = Math.min(r, g, b) / 255;
834
- const delta = max - min;
835
- if (delta === 0) return 0;
836
- let h = 0;
837
- if (max === r / 255) h = ((g / 255 - b / 255) / delta) % 6;
838
- else if (max === g / 255) h = (b / 255 - r / 255) / delta + 2;
839
- else h = (r / 255 - g / 255) / delta + 4;
840
- const degrees = h * 60;
841
- return degrees < 0 ? degrees + 360 : degrees;
842
- }
843
-
844
- /** Builds a PanResponder that reports the fraction (0–1) across a track. */
845
- function makeTrackResponder(
846
- onFraction: (fraction: number) => void,
847
- PanResponder: any,
848
- trackRef: { current: number },
849
- ): any {
850
- if (!PanResponder?.create) return null;
851
- return PanResponder.create({
852
- onStartShouldSetPanResponder: () => true,
853
- onMoveShouldSetPanResponder: () => true,
854
- onPanResponderGrant: (event: any) => {
855
- const fraction = fractionAt(event, 100);
856
- if (fraction !== null) onFraction(fraction);
857
- },
858
- onPanResponderMove: (event: any) => {
859
- const fraction = fractionAt(event, 100);
860
- if (fraction !== null) onFraction(fraction);
861
- },
862
- onPanResponderTerminationRequest: () => false,
863
- });
864
- }
865
-
866
- /** The fraction of the track under a touch, from the touch's X. */
867
- function fractionAt(event: any, fallbackWidth: number): number | null {
868
- const x = event?.nativeEvent?.locationX;
869
- const width = event?.nativeEvent?.layoutMeasurement?.width ?? fallbackWidth;
870
- if (typeof x !== "number" || typeof width !== "number" || width <= 0) return null;
871
- return Math.max(0, Math.min(1, x / width));
872
- }
873
-
874
- // ---------------------------------------------------------------------------
875
- // Combobox
876
-
877
- export interface ComboboxOption {
878
- label: string;
879
- value: string;
880
- /** Extra text under the label, if any. */
881
- description?: string;
882
- }
883
-
884
- export interface ComboboxProps {
885
- /** The options the user can choose from. */
886
- options: ComboboxOption[];
887
- /** Controlled value. Omit and the combobox keeps its own. */
888
- value?: string;
889
- defaultValue?: string;
890
- onChange?: (value: string) => void;
891
- /** A description of the underlying field. */
892
- label?: string;
893
- placeholder?: string;
894
- disabled?: boolean;
895
- /** Called when the dropdown's empty result shows. */
896
- onEmpty?: () => void;
897
- style?: StyleProp<ViewStyle>;
898
- isDark?: boolean;
899
- testID?: string;
900
- }
901
-
902
- /**
903
- * A type-to-search select.
904
- *
905
- * The Input patterns (real TextInput, themed placeholder, `value`/`defaultValue`)
906
- * open a Menu-style glass dropdown whose list filters as the user types — every
907
- * keystroke re-filters the options, so the visible set genuinely shrinks, never
908
- * a list that stays put and pretends to search.
909
- *
910
- * The filter is a case-insensitive substring match on label and description. An
911
- * empty result shows an explicit empty row, so the user sees a search that found
912
- * nothing rather than a list that silently went blank. The dropdown stays open
913
- * until an option is picked or the field loses focus.
914
- */
915
- export const Combobox = forwardRef<any, ComboboxProps>(function Combobox(
916
- {
917
- options,
918
- value,
919
- defaultValue,
920
- onChange,
921
- label,
922
- placeholder = "Search…",
923
- disabled = false,
924
- onEmpty,
925
- style,
926
- isDark: isDarkProp,
927
- testID,
928
- ...props
929
- },
930
- ref,
931
- ) {
932
- const isDark = useIsDark(isDarkProp);
933
- const theme = isDark ? colors.dark : colors.light;
934
- const { View, TextInput, Text: RNText, Pressable } = primitives();
935
-
936
- const [internalValue, setInternalValue] = useState(defaultValue ?? "");
937
- const [query, setQuery] = useState("");
938
-
939
- const selected = value !== undefined ? value : internalValue;
940
- const selectedLabel = (options ?? []).find((option) => option.value === selected)?.label ?? "";
941
-
942
- const setValue = (next: string) => {
943
- if (disabled) return;
944
- if (value === undefined) setInternalValue(next);
945
- onChange?.(next);
946
- };
947
-
948
- // Filter as the user types.
949
- // An option list that has not loaded yet is empty, not a crash: a combobox
950
- // is frequently rendered before its options arrive.
951
- const available = options ?? [];
952
- const needle = query.trim().toLowerCase();
953
- const matches = needle.length === 0
954
- ? available
955
- : available.filter((option) =>
956
- option.label.toLowerCase().includes(needle) ||
957
- (option.description ?? "").toLowerCase().includes(needle),
958
- );
959
-
960
- return (
961
- <View ref={ref} testID={testID} style={{ ...(style as ViewStyle) }}>
962
- <TextInput
963
- value={query}
964
- onChangeText={(text: string) => setQuery(text)}
965
- placeholder={placeholder}
966
- accessibilityLabel={label ?? placeholder}
967
- accessibilityState={{ disabled }}
968
- editable={!disabled}
969
- style={{
970
- borderRadius: radii.md,
971
- paddingHorizontal: 12,
972
- paddingVertical: 8,
973
- fontSize: 16,
974
- color: theme.foreground,
975
- backgroundColor: disabled ? theme.muted : theme.fieldWash,
976
- }}
977
- />
978
- {/* The dropdown: opens once there is something to match. */}
979
- {query.length > 0 ? (
980
- <View style={{ marginTop: 6, borderRadius: radii.md, overflow: "hidden", backgroundColor: disabled ? theme.muted : theme.glass }}>
981
- {matches.length === 0 ? (
982
- <View style={{ paddingHorizontal: 12, paddingVertical: 10 }}>
983
- <RNText style={{ fontSize: 14, color: theme.muted }}>No matches</RNText>
984
- </View>
985
- ) : (
986
- matches.map((option, index) => {
987
- const isSelected = option.value === selected;
988
- return (
989
- <Pressable
990
- key={`${option.value}-${index}`}
991
- accessibilityRole="button"
992
- accessibilityLabel={option.label}
993
- accessibilityState={{ selected: isSelected }}
994
- onPress={() => {
995
- setValue(option.value);
996
- setQuery("");
997
- }}
998
- style={{ flexDirection: "row", alignItems: "center", paddingHorizontal: 12, paddingVertical: 10, backgroundColor: isSelected ? theme.glassActive : "transparent" }}
999
- >
1000
- <View style={{ flex: 1 }}>
1001
- <RNText style={{ fontSize: 15, color: theme.foreground }}>{option.label}</RNText>
1002
- {option.description ? (
1003
- <RNText style={{ fontSize: 12, color: theme.muted }} numberOfLines={1}>{option.description}</RNText>
1004
- ) : null}
1005
- </View>
1006
- </Pressable>
1007
- );
1008
- })
1009
- )}
1010
- </View>
1011
- ) : null}
1012
- </View>
1013
- );
1014
- });