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/Display.tsx DELETED
@@ -1,778 +0,0 @@
1
- import { forwardRef, useEffect, useRef, useState, type ReactNode } from "react";
2
- import type { StyleProp, ViewStyle } from "react-native";
3
-
4
- import { Glass } from "./Glass";
5
- import { colors, controlSizes, radii } from "./internal/tokens";
6
- import { primitives } from "./internal/primitives";
7
- import { useIsDark, useSpring } from "./internal/motion";
8
-
9
- // ---------------------------------------------------------------------------
10
- // Avatar
11
-
12
- export type AvatarSize = "sm" | "md" | "lg";
13
-
14
- export interface AvatarProps {
15
- /** Image to show. When absent, or when it fails to load, initials render. */
16
- source?: { uri: string } | number;
17
- /** The person's name: initials are derived from it when no image loads. */
18
- name?: string;
19
- size?: AvatarSize;
20
- /** Draws a status dot in the corner. */
21
- status?: "online" | "offline" | "busy";
22
- style?: StyleProp<ViewStyle>;
23
- isDark?: boolean;
24
- testID?: string;
25
- }
26
-
27
- const avatarSizes: Record<AvatarSize, number> = { sm: 28, md: 40, lg: 64 };
28
-
29
- /** First letters of the first and last word, as an avatar fallback. */
30
- export function initialsOf(name: string): string {
31
- const words = name.trim().split(/\s+/).filter(Boolean);
32
- if (words.length === 0) return "";
33
- if (words.length === 1) return words[0]!.slice(0, 2).toUpperCase();
34
- return (words[0]![0]! + words[words.length - 1]![0]!).toUpperCase();
35
- }
36
-
37
- /**
38
- * A person or entity: their picture, or their initials when there is none.
39
- *
40
- * The frame is Glacia's glass so it belongs to the same family as the rest of
41
- * the library; the initials sit on it in the theme's foreground colour.
42
- */
43
- export const Avatar = forwardRef<any, AvatarProps>(function Avatar(
44
- { source, name, size = "md", status, style, isDark: isDarkProp, testID, ...props },
45
- ref,
46
- ) {
47
- const isDark = useIsDark(isDarkProp);
48
- const theme = isDark ? colors.dark : colors.light;
49
- const { View, Text, Image } = primitives();
50
-
51
- // A broken remote image falls back to initials rather than an empty circle.
52
- const [failed, setFailed] = useState(false);
53
- const dimension = avatarSizes[size];
54
- const initials = name ? initialsOf(name) : "";
55
-
56
- const statusColor =
57
- status === "online" ? theme.on : status === "busy" ? theme.destructive : theme.muted;
58
- const dot = Math.max(8, Math.round(dimension * 0.26));
59
-
60
- return (
61
- <View
62
- ref={ref}
63
- testID={testID}
64
- accessible
65
- accessibilityRole="image"
66
- accessibilityLabel={name ? `Avatar of ${name}` : "Avatar"}
67
- style={{ width: dimension, height: dimension, ...(style as ViewStyle) }}
68
- {...props}
69
- >
70
- <Glass
71
- effect="regular"
72
- isDark={isDark}
73
- style={{
74
- width: dimension,
75
- height: dimension,
76
- borderRadius: dimension / 2,
77
- alignItems: "center",
78
- justifyContent: "center",
79
- overflow: "hidden",
80
- }}
81
- >
82
- {source && !failed ? (
83
- <Image
84
- source={source}
85
- accessibilityLabel={name ?? "Avatar"}
86
- onError={() => setFailed(true)}
87
- style={{ width: dimension, height: dimension }}
88
- />
89
- ) : (
90
- <Text
91
- style={{
92
- fontSize: Math.round(dimension * 0.38),
93
- fontWeight: "600",
94
- color: theme.foreground,
95
- }}
96
- >
97
- {initials}
98
- </Text>
99
- )}
100
- </Glass>
101
-
102
- {status && (
103
- <View
104
- style={{
105
- position: "absolute",
106
- right: 0,
107
- bottom: 0,
108
- width: dot,
109
- height: dot,
110
- borderRadius: dot / 2,
111
- backgroundColor: statusColor,
112
- borderWidth: 1.5,
113
- borderColor: theme.glassActive,
114
- }}
115
- />
116
- )}
117
- </View>
118
- );
119
- });
120
-
121
- // ---------------------------------------------------------------------------
122
- // Badge
123
-
124
- export interface BadgeProps {
125
- /** The count or short label. Omit to render a plain dot. */
126
- children?: ReactNode;
127
- /** Draws the badge in the destructive tone (unread, errors). */
128
- tone?: "fill" | "destructive" | "success" | "muted";
129
- /** The element to overlay. Supplying it puts the badge in the corner. */
130
- overlay?: ReactNode;
131
- style?: StyleProp<ViewStyle>;
132
- isDark?: boolean;
133
- testID?: string;
134
- }
135
-
136
- /**
137
- * A small count or dot.
138
- *
139
- * Deliberately not glass: a badge is a micro-element, and a translucent 16pt
140
- * chip loses its contrast against whatever it sits on. It uses the solid theme
141
- * tint instead, which is what makes it legible in both themes.
142
- */
143
- export const Badge = forwardRef<any, BadgeProps>(function Badge(
144
- { children, tone = "fill", overlay, style, isDark: isDarkProp, testID, ...props },
145
- ref,
146
- ) {
147
- const isDark = useIsDark(isDarkProp);
148
- const theme = isDark ? colors.dark : colors.light;
149
- const { View, Text } = primitives();
150
-
151
- const background =
152
- tone === "destructive"
153
- ? theme.destructive
154
- : tone === "success"
155
- ? theme.on
156
- : tone === "muted"
157
- ? theme.muted
158
- : theme.fill;
159
-
160
- const isDot = children == null;
161
- const height = isDot ? 10 : 18;
162
-
163
- const badge = (
164
- <View
165
- ref={ref}
166
- testID={testID}
167
- accessibilityRole="text"
168
- accessibilityLabel={isDot ? undefined : String(children)}
169
- style={{
170
- minWidth: height,
171
- height,
172
- borderRadius: height / 2,
173
- paddingHorizontal: isDot ? 0 : 6,
174
- alignItems: "center",
175
- justifyContent: "center",
176
- backgroundColor: background,
177
- ...(style as ViewStyle),
178
- }}
179
- {...props}
180
- >
181
- {!isDot && (
182
- <Text style={{ fontSize: 11, fontWeight: "700", color: theme.onTint }} numberOfLines={1}>
183
- {children}
184
- </Text>
185
- )}
186
- </View>
187
- );
188
-
189
- if (overlay === undefined) return badge;
190
-
191
- // Overlaid: the badge floats at the top-right of whatever it decorates, which
192
- // needs a positioned box around the child rather than a bare fragment.
193
- return (
194
- <View style={{ alignSelf: "flex-start" }}>
195
- {overlay}
196
- <View style={{ position: "absolute", top: -4, right: -4 }}>{badge}</View>
197
- </View>
198
- );
199
- });
200
-
201
- // ---------------------------------------------------------------------------
202
- // Separator
203
-
204
- export interface SeparatorProps {
205
- orientation?: "horizontal" | "vertical";
206
- /** Inset from the leading edge, matching a list row's leading accessory. */
207
- inset?: number;
208
- style?: StyleProp<ViewStyle>;
209
- isDark?: boolean;
210
- testID?: string;
211
- }
212
-
213
- /**
214
- * A hairline divider in the theme's separator colour.
215
- *
216
- * A plain View rather than a Glass: a 1pt rule is not a surface, and glass on
217
- * a line has nothing to refract.
218
- */
219
- export const Separator = forwardRef<any, SeparatorProps>(function Separator(
220
- { orientation = "horizontal", inset = 0, style, isDark: isDarkProp, testID, ...props },
221
- ref,
222
- ) {
223
- const isDark = useIsDark(isDarkProp);
224
- const theme = isDark ? colors.dark : colors.light;
225
- const { View } = primitives();
226
-
227
- const separatorStyle: ViewStyle =
228
- orientation === "horizontal"
229
- ? { height: 0.5, alignSelf: "stretch", marginLeft: inset, backgroundColor: theme.separator }
230
- : { width: 0.5, alignSelf: "stretch", backgroundColor: theme.separator };
231
-
232
- return (
233
- <View
234
- ref={ref}
235
- testID={testID}
236
- accessibilityRole="none"
237
- style={{ ...separatorStyle, ...(style as ViewStyle) }}
238
- {...props}
239
- />
240
- );
241
- });
242
-
243
- // ---------------------------------------------------------------------------
244
- // Skeleton
245
-
246
- export interface SkeletonProps {
247
- /** Rectangles for cards and rows, circles for avatars, lines for a run of text. */
248
- shape?: "rect" | "circle" | "line";
249
- width?: number | string;
250
- height?: number;
251
- style?: StyleProp<ViewStyle>;
252
- isDark?: boolean;
253
- testID?: string;
254
- }
255
-
256
- /**
257
- * A loading placeholder.
258
- *
259
- * The pulse is opacity only and slow, on the gentle spring, so it reads as
260
- * "loading" without motion that could bother someone sensitive to movement.
261
- * Nothing about it is essential to understanding the screen, so it is hidden
262
- * from screen readers rather than announced.
263
- */
264
- export const Skeleton = forwardRef<any, SkeletonProps>(function Skeleton(
265
- { shape = "rect", width, height, style, isDark: isDarkProp, testID, ...props },
266
- ref,
267
- ) {
268
- const isDark = useIsDark(isDarkProp);
269
- const theme = isDark ? colors.dark : colors.light;
270
- const { View, Animated } = primitives();
271
-
272
- const { value: pulse, animated } = useSpring(1, "gentle");
273
- const opacity = animated
274
- ? pulse.interpolate({ inputRange: [0, 1], outputRange: [0.35, 1] })
275
- : 1;
276
-
277
- const resolvedWidth = width ?? (shape === "line" ? "100%" : shape === "circle" ? 40 : 120);
278
- const resolvedHeight = height ?? (shape === "line" ? 12 : shape === "circle" ? 40 : 80);
279
- const radius =
280
- shape === "circle" ? Math.min(resolvedHeight, 9999) / 2 : shape === "line" ? radii.sm : radii.md;
281
-
282
- const skeletonStyle: ViewStyle = {
283
- width: resolvedWidth as any,
284
- height: resolvedHeight,
285
- borderRadius: radius,
286
- backgroundColor: theme.skeleton,
287
- ...(style as ViewStyle),
288
- };
289
-
290
- const a11y = { accessibilityRole: "none" as const, accessible: false, testID };
291
-
292
- return animated ? (
293
- <Animated.View ref={ref} style={{ ...skeletonStyle, opacity }} {...a11y} {...props} />
294
- ) : (
295
- <View ref={ref} style={skeletonStyle} {...a11y} {...props} />
296
- );
297
- });
298
-
299
- // ---------------------------------------------------------------------------
300
- // Spinner
301
-
302
- export type SpinnerSize = "sm" | "md" | "lg";
303
-
304
- export interface SpinnerProps {
305
- size?: SpinnerSize;
306
- /** Spinner colour; defaults to the theme's muted foreground. */
307
- tint?: string;
308
- /** Announced to screen readers, since a spinner alone has no text. */
309
- accessibilityLabel?: string;
310
- style?: StyleProp<ViewStyle>;
311
- isDark?: boolean;
312
- testID?: string;
313
- }
314
-
315
- const spinnerSizes: Record<SpinnerSize, number> = { sm: 16, md: 22, lg: 32 };
316
-
317
- /**
318
- * A loading spinner, drawn by Glacia.
319
- *
320
- * An SVG arc that rotates on the gentle spring through Animated — not the
321
- * platform's ActivityIndicator, so it looks the same on every platform and
322
- * wears the theme's colour instead of inheriting the system tint.
323
- */
324
- export const Spinner = forwardRef<any, SpinnerProps>(function Spinner(
325
- {
326
- size = "md",
327
- tint,
328
- accessibilityLabel = "Loading",
329
- style,
330
- isDark: isDarkProp,
331
- testID,
332
- ...props
333
- },
334
- ref,
335
- ) {
336
- const isDark = useIsDark(isDarkProp);
337
- const theme = isDark ? colors.dark : colors.light;
338
- const { View, Svg, Circle, Animated } = primitives();
339
-
340
- const dimension = spinnerSizes[size];
341
- const stroke = Math.max(2, Math.round(dimension / 9));
342
- const color = tint ?? theme.muted;
343
- // An arc, not a full ring: a complete circle rotating looks static.
344
- const circumference = 2 * Math.PI * ((dimension - stroke) / 2);
345
- const dash = circumference * 0.28;
346
-
347
- // A continuous spin never settles, so it is driven by Animated.timing on a
348
- // loop rather than the spring hook, which is built for one-off targets.
349
- const { Animated: AnimatedAPI, isNative } = primitives();
350
- const spinning = isNative && Boolean(AnimatedAPI?.timing);
351
-
352
- const rotation = useRef<any>(null);
353
- if (rotation.current === null) {
354
- rotation.current = spinning ? new AnimatedAPI.Value(0) : null;
355
- }
356
-
357
- useEffect(() => {
358
- if (!spinning || !rotation.current) return;
359
- rotation.current.setValue(0);
360
- const loop = AnimatedAPI.loop(
361
- AnimatedAPI.timing(rotation.current, {
362
- toValue: 1,
363
- duration: 900,
364
- useNativeDriver: true,
365
- }),
366
- );
367
- loop.start?.();
368
- return () => loop.stop?.();
369
- }, [AnimatedAPI, spinning]);
370
-
371
- const spinStyle = spinning
372
- ? {
373
- transform: [
374
- {
375
- rotate: rotation.current.interpolate({
376
- inputRange: [0, 1],
377
- outputRange: ["0deg", "360deg"],
378
- }),
379
- },
380
- ],
381
- }
382
- : undefined;
383
-
384
- const svg = (
385
- <Svg width={dimension} height={dimension} viewBox={`0 0 ${dimension} ${dimension}`}>
386
- <Circle
387
- cx={dimension / 2}
388
- cy={dimension / 2}
389
- r={(dimension - stroke) / 2}
390
- stroke={theme.skeleton}
391
- strokeWidth={stroke}
392
- fill="none"
393
- />
394
- <Circle
395
- cx={dimension / 2}
396
- cy={dimension / 2}
397
- r={(dimension - stroke) / 2}
398
- stroke={color}
399
- strokeWidth={stroke}
400
- fill="none"
401
- strokeLinecap="round"
402
- strokeDasharray={`${dash} ${circumference - dash}`}
403
- />
404
- </Svg>
405
- );
406
-
407
- return (
408
- <View
409
- ref={ref}
410
- testID={testID}
411
- accessibilityRole="progressbar"
412
- accessibilityLabel={accessibilityLabel}
413
- style={[{ width: dimension, height: dimension }, style as ViewStyle]}
414
- {...props}
415
- >
416
- {spinning ? <Animated.View style={spinStyle}>{svg}</Animated.View> : svg}
417
- </View>
418
- );
419
- });
420
-
421
- // ---------------------------------------------------------------------------
422
- // Progress
423
-
424
- export type ProgressVariant = "bar" | "ring";
425
-
426
- export interface ProgressProps {
427
- /** 0–100. Values outside the range are clamped rather than drawn wrong. */
428
- value: number;
429
- variant?: ProgressVariant;
430
- /** Overrides the fill colour; defaults to the theme accent. */
431
- tint?: string;
432
- /** Announced by screen readers, e.g. "Uploading photo". */
433
- accessibilityLabel?: string;
434
- style?: StyleProp<ViewStyle>;
435
- isDark?: boolean;
436
- testID?: string;
437
- }
438
-
439
- const RING = 64;
440
-
441
- /**
442
- * Progress, linear or circular.
443
- *
444
- * The track is a glass surface, so it refracts what it sits on exactly like the
445
- * rest of the library; the fill is the theme accent. Both forms report
446
- * `progressbar` with a value, which is the contract NativeTask relies on
447
- * internally — this component generalises it.
448
- */
449
- export const Progress = forwardRef<any, ProgressProps>(function Progress(
450
- {
451
- value,
452
- variant = "bar",
453
- tint,
454
- accessibilityLabel,
455
- style,
456
- isDark: isDarkProp,
457
- testID,
458
- ...props
459
- },
460
- ref,
461
- ) {
462
- const isDark = useIsDark(isDarkProp);
463
- const theme = isDark ? colors.dark : colors.light;
464
- const { View, Text, Svg, Circle } = primitives();
465
-
466
- const clamped = Math.min(Math.max(value, 0), 100);
467
- const fill = tint ?? theme.fill;
468
- const a11y = {
469
- accessibilityRole: "progressbar" as const,
470
- accessibilityValue: { min: 0, max: 100, now: Math.round(clamped) },
471
- accessibilityLabel,
472
- testID,
473
- };
474
-
475
- if (variant === "ring") {
476
- const stroke = 6;
477
- const radius = (RING - stroke) / 2;
478
- const circumference = 2 * Math.PI * radius;
479
- return (
480
- <View
481
- ref={ref}
482
- style={[{ width: RING, height: RING }, style as ViewStyle]}
483
- {...a11y}
484
- {...props}
485
- >
486
- <Svg width={RING} height={RING} viewBox={`0 0 ${RING} ${RING}`}>
487
- <Circle
488
- cx={RING / 2}
489
- cy={RING / 2}
490
- r={radius}
491
- stroke={theme.skeleton}
492
- strokeWidth={stroke}
493
- fill="none"
494
- />
495
- <Circle
496
- cx={RING / 2}
497
- cy={RING / 2}
498
- r={radius}
499
- stroke={fill}
500
- strokeWidth={stroke}
501
- fill="none"
502
- strokeLinecap="round"
503
- strokeDasharray={`${(clamped / 100) * circumference} ${circumference}`}
504
- // Start the arc at twelve o'clock, the way progress dials read.
505
- transform={`rotate(-90 ${RING / 2} ${RING / 2})`}
506
- />
507
- </Svg>
508
- <View
509
- style={{
510
- position: "absolute",
511
- width: RING,
512
- height: RING,
513
- alignItems: "center",
514
- justifyContent: "center",
515
- }}
516
- >
517
- <Text style={{ fontSize: 13, fontWeight: "600", color: theme.foreground }}>
518
- {`${Math.round(clamped)}%`}
519
- </Text>
520
- </View>
521
- </View>
522
- );
523
- }
524
-
525
- return (
526
- <Glass
527
- ref={ref}
528
- effect="regular"
529
- isDark={isDark}
530
- style={{
531
- height: 8,
532
- borderRadius: radii.pill,
533
- overflow: "hidden",
534
- justifyContent: "center",
535
- ...(style as ViewStyle),
536
- }}
537
- {...a11y}
538
- {...props}
539
- >
540
- <View
541
- style={{
542
- width: `${clamped}%`,
543
- height: 8,
544
- borderRadius: radii.pill,
545
- backgroundColor: fill,
546
- }}
547
- />
548
- </Glass>
549
- );
550
- });
551
-
552
- // ---------------------------------------------------------------------------
553
- // Rating
554
-
555
- /** The five-pointed star, as a path in a unit box. */
556
- const STAR_PATH =
557
- "M12 2.4l2.95 5.98 6.6.96-4.78 4.66 1.13 6.57L12 17.46l-5.9 3.11 1.13-6.57L2.45 9.34l6.6-.96z";
558
-
559
- export interface RatingProps {
560
- /** How many stars are filled. Fractions render a partially filled star. */
561
- value: number;
562
- /** The number of stars. Defaults to five. */
563
- max?: number;
564
- size?: "sm" | "md" | "lg";
565
- /** Makes the stars tappable. Omit for a read-only rating. */
566
- onChange?: (value: number) => void;
567
- disabled?: boolean;
568
- /** The accessible name, e.g. "Rating". */
569
- accessibilityLabel?: string;
570
- style?: StyleProp<ViewStyle>;
571
- isDark?: boolean;
572
- testID?: string;
573
- }
574
-
575
- /**
576
- * A star rating.
577
- *
578
- * The stars are drawn as SVG paths from the resolver, so nothing is a
579
- * platform control. A fractional value fills part of a star: 3.5 draws three
580
- * full stars and one half, the half produced by clipping the filled star at the
581
- * fraction's width rather than by rounding — a 4.5-star average must look like
582
- * a 4.5-star average.
583
- *
584
- * Read-only unless `onChange` is given. With it, each star is tappable, the
585
- * value is exposed as an adjustable control (increment/decrement through
586
- * accessibility actions), and each star has its own label so a screen reader
587
- * can name the exact rating it sets.
588
- */
589
- export const Rating = forwardRef<any, RatingProps>(function Rating(
590
- {
591
- value,
592
- max = 5,
593
- size = "md",
594
- onChange,
595
- disabled = false,
596
- accessibilityLabel = "Rating",
597
- style,
598
- isDark: isDarkProp,
599
- testID,
600
- ...props
601
- },
602
- ref,
603
- ) {
604
- const isDark = useIsDark(isDarkProp);
605
- const theme = isDark ? colors.dark : colors.light;
606
- const { View, Pressable, Svg, Path, Defs, ClipPath, Rect } = primitives();
607
- const starSize = controlSizes.star[size];
608
- const interactive = Boolean(onChange) && !disabled;
609
- const clamped = Math.max(0, Math.min(value, max));
610
-
611
- const setValue = (next: number) => {
612
- const bounded = Math.max(0, Math.min(next, max));
613
- onChange?.(bounded);
614
- };
615
-
616
- const star = (index: number) => {
617
- // How much of this star is filled: 1 for a full star, 0 for empty, and the
618
- // remainder for the one the value lands inside.
619
- const filled = Math.max(0, Math.min(1, clamped - index));
620
- const half = filled > 0 && filled < 1;
621
-
622
- const glyph = (
623
- <Svg width={starSize} height={starSize} viewBox="0 0 24 24">
624
- {half ? (
625
- <Defs>
626
- {/* The clip is what makes a fractional star possible: the filled
627
- star is cut at the fraction's width. */}
628
- <ClipPath id={`rating-clip-${index}`}>
629
- <Rect x="0" y="0" width={24 * filled} height={24} />
630
- </ClipPath>
631
- </Defs>
632
- ) : null}
633
- {/* The empty star is always drawn, so the shape is complete. */}
634
- <Path d={STAR_PATH} fill={theme.separator} />
635
- {filled > 0 ? (
636
- <Path
637
- d={STAR_PATH}
638
- fill={theme.fill}
639
- {...(half ? { clipPath: `url(#rating-clip-${index})` } : {})}
640
- />
641
- ) : null}
642
- </Svg>
643
- );
644
-
645
- if (!interactive) return <View key={index}>{glyph}</View>;
646
-
647
- return (
648
- <Pressable
649
- key={index}
650
- accessibilityRole="button"
651
- accessibilityLabel={`${index + 1} of ${max} stars`}
652
- accessibilityState={{ selected: clamped === index + 1 }}
653
- onPress={() => setValue(index + 1)}
654
- hitSlop={4}
655
- >
656
- {glyph}
657
- </Pressable>
658
- );
659
- };
660
-
661
- const stars = Array.from({ length: Math.max(1, max) }, (_unused, index) => star(index));
662
-
663
- if (!interactive && !onChange) {
664
- return (
665
- <View
666
- ref={ref}
667
- testID={testID}
668
- accessibilityRole="text"
669
- accessibilityLabel={`${accessibilityLabel}, ${clamped} of ${max}`}
670
- style={{ flexDirection: "row", alignItems: "center", gap: 2, ...(style as ViewStyle) }}
671
- {...props}
672
- >
673
- {stars}
674
- </View>
675
- );
676
- }
677
-
678
- return (
679
- <View
680
- ref={ref}
681
- testID={testID}
682
- accessibilityRole="adjustable"
683
- accessibilityLabel={accessibilityLabel}
684
- accessibilityState={{ disabled }}
685
- accessibilityValue={{ min: 0, max, now: clamped }}
686
- accessibilityActions={[{ name: "increment" }, { name: "decrement" }]}
687
- onAccessibilityAction={(event: any) => {
688
- if (disabled) return;
689
- if (event?.nativeEvent?.actionName === "increment") setValue(clamped + 1);
690
- if (event?.nativeEvent?.actionName === "decrement") setValue(clamped - 1);
691
- }}
692
- style={{ flexDirection: "row", alignItems: "center", gap: 2, opacity: disabled ? 0.38 : 1, ...(style as ViewStyle) }}
693
- {...props}
694
- >
695
- {stars}
696
- </View>
697
- );
698
- });
699
-
700
- // ---------------------------------------------------------------------------
701
- // Image
702
-
703
- export interface NativeImageProps {
704
- /** The image to show. */
705
- source: { uri: string } | number;
706
- /** A description for screen readers. Required: an image with no name is a hole. */
707
- accessibilityLabel: string;
708
- /** Shown behind the image while it loads; a Skeleton when omitted. */
709
- placeholder?: ReactNode;
710
- /** Shown when the image fails to load. */
711
- fallback?: ReactNode;
712
- /** Fades the image in when it loads. Honours Reduce Motion. */
713
- fadeIn?: boolean;
714
- style?: StyleProp<ViewStyle>;
715
- isDark?: boolean;
716
- testID?: string;
717
- }
718
-
719
- /**
720
- * A plain image, with the loading and error states every app ends up writing.
721
- *
722
- * Three states, because an image on a phone is three states: loading (a
723
- * Skeleton behind it), loaded (a fade in), and failed (the caller's fallback).
724
- * Aspect ratio comes from `style`, so a caller sets `aspectRatio` and the height
725
- * follows.
726
- *
727
- * This is the plain one; `NativeImageGeneration` is the AI-specific cousin and
728
- * keeps its own state machine.
729
- */
730
- export const NativeImage = forwardRef<any, NativeImageProps>(function NativeImage(
731
- {
732
- source,
733
- accessibilityLabel,
734
- placeholder,
735
- fallback,
736
- fadeIn = true,
737
- style,
738
- isDark: isDarkProp,
739
- testID,
740
- ...props
741
- },
742
- ref,
743
- ) {
744
- const isDark = useIsDark(isDarkProp);
745
- const { View, Image: RNImage, Animated } = primitives();
746
- const [failed, setFailed] = useState(false);
747
- const [loaded, setLoaded] = useState(false);
748
- const { value: fade, animated } = useSpring(loaded ? 1 : 0, "gentle");
749
-
750
- const boxStyle: ViewStyle = { overflow: "hidden", ...(style as ViewStyle) };
751
-
752
- if (failed && fallback) {
753
- return (
754
- <View ref={ref} testID={testID} style={boxStyle} {...props}>
755
- {fallback}
756
- </View>
757
- );
758
- }
759
-
760
- const imageStyle: ViewStyle = { width: "100%", height: "100%" };
761
- const opacity = fadeIn && animated ? fade : 1;
762
-
763
- return (
764
- <View ref={ref} testID={testID} style={boxStyle} {...props}>
765
- {/* The placeholder sits under the image, so the box never collapses and
766
- the fade reveals rather than jumps. */}
767
- {!loaded ? <View style={{ position: "absolute", top: 0, left: 0, right: 0, bottom: 0 }}>{placeholder ?? <Skeleton shape="rect" isDark={isDark} />}</View> : null}
768
- <RNImage
769
- accessibilityRole="image"
770
- accessibilityLabel={accessibilityLabel}
771
- source={source}
772
- onLoad={() => setLoaded(true)}
773
- onError={() => setFailed(true)}
774
- style={[imageStyle, animated ? { opacity } : null]}
775
- />
776
- </View>
777
- );
778
- });