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