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
@@ -1,103 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PageControl = exports.Carousel = void 0;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
- const react_1 = require("react");
6
- const tokens_1 = require("./internal/tokens");
7
- const primitives_1 = require("./internal/primitives");
8
- const motion_1 = require("./internal/motion");
9
- /**
10
- * A horizontally paging swiper.
11
- *
12
- * It rides the resolver's ScrollView with `pagingEnabled`, so the paging feel is
13
- * the platform's own and the pages are plain content the caller supplies. The
14
- * active page is derived from the scroll offset, which is also what reports
15
- * `onIndexChange`.
16
- */
17
- exports.Carousel = (0, react_1.forwardRef)(function Carousel({ slides, index: indexProp, defaultIndex = 0, onIndexChange, gap = 0, style, isDark: isDarkProp, testID, ...props }, ref) {
18
- const isDark = (0, motion_1.useIsDark)(isDarkProp);
19
- const { getScrollView } = (0, primitives_1.primitives)();
20
- const ScrollView = getScrollView();
21
- const { View } = (0, primitives_1.primitives)();
22
- const [internalIndex, setInternalIndex] = (0, react_1.useState)(defaultIndex);
23
- const index = indexProp !== undefined ? indexProp : internalIndex;
24
- const viewportWidth = (0, react_1.useRef)(0);
25
- const scrollRef = (0, react_1.useRef)(null);
26
- // Derives the page from the offset rather than trusting a counter, so a
27
- // fast swipe that skips pages still reports the page it landed on.
28
- const handleScroll = (event) => {
29
- const { contentOffset, layoutMeasurement } = event?.nativeEvent ?? {};
30
- const width = layoutMeasurement?.width || viewportWidth.current;
31
- if (!width || !contentOffset)
32
- return;
33
- const next = Math.round(contentOffset.x / width);
34
- const clamped = Math.min(Math.max(next, 0), Math.max(slides.length - 1, 0));
35
- if (clamped !== index) {
36
- if (indexProp === undefined)
37
- setInternalIndex(clamped);
38
- onIndexChange?.(clamped);
39
- }
40
- };
41
- const pages = slides.map((slide, i) => ((0, jsx_runtime_1.jsx)(View, { style: { width: viewportWidth.current || "100%", paddingRight: gap }, children: slide }, i)));
42
- // Off-device there is no ScrollView; the pages still render in a row so the
43
- // component mounts, and the tests drive `handleScroll` through onScroll.
44
- if (!ScrollView) {
45
- return ((0, jsx_runtime_1.jsx)(View, { ref: ref, testID: testID, style: [{ flexDirection: "row", overflow: "hidden" }, style], ...props, children: pages }));
46
- }
47
- return ((0, jsx_runtime_1.jsx)(View, { ref: ref, testID: testID, onLayout: (event) => {
48
- viewportWidth.current = event?.nativeEvent?.layout?.width ?? 0;
49
- }, style: style, ...props, children: (0, jsx_runtime_1.jsx)(ScrollView, { ref: scrollRef, horizontal: true, pagingEnabled: gap === 0, showsHorizontalScrollIndicator: false, onScroll: handleScroll, scrollEventThrottle: 16, accessibilityRole: "adjustable", accessibilityLabel: "Carousel", accessibilityValue: { min: 0, max: Math.max(slides.length - 1, 0), now: index }, accessibilityActions: [{ name: "increment" }, { name: "decrement" }], onAccessibilityAction: (event) => {
50
- const step = event?.nativeEvent?.actionName === "increment" ? 1 : -1;
51
- const next = Math.min(Math.max(index + step, 0), Math.max(slides.length - 1, 0));
52
- if (next === index)
53
- return;
54
- if (indexProp === undefined)
55
- setInternalIndex(next);
56
- onIndexChange?.(next);
57
- }, children: pages }) }));
58
- });
59
- const DOT = 7;
60
- const ACTIVE_DOT = 18;
61
- /**
62
- * The page dots.
63
- *
64
- * The active dot elongates and the others stay narrow, which is how iOS reads
65
- * "you are here". The width change runs on the springs token through Animated.
66
- */
67
- exports.PageControl = (0, react_1.forwardRef)(function PageControl({ count, activeIndex: activeProp, defaultActiveIndex = 0, onChange, tint, hidesForSinglePage = false, style, isDark: isDarkProp, testID, ...props }, ref) {
68
- const isDark = (0, motion_1.useIsDark)(isDarkProp);
69
- const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
70
- const { View, Pressable } = (0, primitives_1.primitives)();
71
- const [internalIndex, setInternalIndex] = (0, react_1.useState)(defaultActiveIndex);
72
- const active = activeProp !== undefined ? activeProp : internalIndex;
73
- if (hidesForSinglePage && count <= 1)
74
- return null;
75
- // The accent tints the active dot; the resting dots sit on `glassActive` so
76
- // selection reads the same way it does in SegmentedControl and TabBar.
77
- const accent = tint ?? theme.fill;
78
- const resting = theme.glassActive;
79
- return ((0, jsx_runtime_1.jsx)(View, { ref: ref, testID: testID, accessibilityRole: "tablist", style: [{ flexDirection: "row", alignItems: "center", gap: 6, alignSelf: "center" }, style], ...props, children: Array.from({ length: Math.max(count, 0) }, (_, index) => {
80
- const isActive = index === active;
81
- return ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "tab", accessibilityLabel: `Page ${index + 1} of ${count}`, accessibilityState: { selected: isActive }, onPress: () => {
82
- if (activeProp === undefined)
83
- setInternalIndex(index);
84
- onChange?.(index);
85
- }, hitSlop: 8, children: (0, jsx_runtime_1.jsx)(Dot, { active: isActive, accent: accent, muted: resting }) }, index));
86
- }) }));
87
- });
88
- /** One dot, whose width springs between the resting and active lengths. */
89
- function Dot({ active, accent, muted }) {
90
- const { Animated, View } = (0, primitives_1.primitives)();
91
- const { value: progress, animated } = (0, motion_1.useSpring)(active ? 1 : 0, "snappy");
92
- const width = animated
93
- ? progress.interpolate({ inputRange: [0, 1], outputRange: [DOT, ACTIVE_DOT] })
94
- : active
95
- ? ACTIVE_DOT
96
- : DOT;
97
- const style = {
98
- height: DOT,
99
- borderRadius: DOT / 2,
100
- backgroundColor: active ? accent : muted,
101
- };
102
- return animated ? ((0, jsx_runtime_1.jsx)(Animated.View, { style: { ...style, width } })) : ((0, jsx_runtime_1.jsx)(View, { style: { ...style, width: width } }));
103
- }
@@ -1,318 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NativeImage = exports.Rating = exports.Progress = exports.Spinner = exports.Skeleton = exports.Separator = exports.Badge = exports.Avatar = void 0;
4
- exports.initialsOf = initialsOf;
5
- const jsx_runtime_1 = require("react/jsx-runtime");
6
- const react_1 = require("react");
7
- const Glass_1 = require("./Glass");
8
- const tokens_1 = require("./internal/tokens");
9
- const primitives_1 = require("./internal/primitives");
10
- const motion_1 = require("./internal/motion");
11
- const avatarSizes = { sm: 28, md: 40, lg: 64 };
12
- /** First letters of the first and last word, as an avatar fallback. */
13
- function initialsOf(name) {
14
- const words = name.trim().split(/\s+/).filter(Boolean);
15
- if (words.length === 0)
16
- return "";
17
- if (words.length === 1)
18
- return words[0].slice(0, 2).toUpperCase();
19
- return (words[0][0] + words[words.length - 1][0]).toUpperCase();
20
- }
21
- /**
22
- * A person or entity: their picture, or their initials when there is none.
23
- *
24
- * The frame is Glacia's glass so it belongs to the same family as the rest of
25
- * the library; the initials sit on it in the theme's foreground colour.
26
- */
27
- exports.Avatar = (0, react_1.forwardRef)(function Avatar({ source, name, size = "md", status, style, isDark: isDarkProp, testID, ...props }, ref) {
28
- const isDark = (0, motion_1.useIsDark)(isDarkProp);
29
- const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
30
- const { View, Text, Image } = (0, primitives_1.primitives)();
31
- // A broken remote image falls back to initials rather than an empty circle.
32
- const [failed, setFailed] = (0, react_1.useState)(false);
33
- const dimension = avatarSizes[size];
34
- const initials = name ? initialsOf(name) : "";
35
- const statusColor = status === "online" ? theme.on : status === "busy" ? theme.destructive : theme.muted;
36
- const dot = Math.max(8, Math.round(dimension * 0.26));
37
- return ((0, jsx_runtime_1.jsxs)(View, { ref: ref, testID: testID, accessible: true, accessibilityRole: "image", accessibilityLabel: name ? `Avatar of ${name}` : "Avatar", style: { width: dimension, height: dimension, ...style }, ...props, children: [(0, jsx_runtime_1.jsx)(Glass_1.Glass, { effect: "regular", surface: "panel", isDark: isDark, style: {
38
- width: dimension,
39
- height: dimension,
40
- borderRadius: dimension / 2,
41
- alignItems: "center",
42
- justifyContent: "center",
43
- overflow: "hidden",
44
- }, children: source && !failed ? ((0, jsx_runtime_1.jsx)(Image, { source: source, accessibilityLabel: name ?? "Avatar", onError: () => setFailed(true), style: { width: dimension, height: dimension } })) : ((0, jsx_runtime_1.jsx)(Text, { style: {
45
- fontSize: Math.round(dimension * 0.38),
46
- fontWeight: "600",
47
- color: theme.foreground,
48
- }, children: initials })) }), status && ((0, jsx_runtime_1.jsx)(View, { style: {
49
- position: "absolute",
50
- right: 0,
51
- bottom: 0,
52
- width: dot,
53
- height: dot,
54
- borderRadius: dot / 2,
55
- backgroundColor: statusColor,
56
- borderWidth: 1.5,
57
- borderColor: theme.glassActive,
58
- } }))] }));
59
- });
60
- /**
61
- * A small count or dot.
62
- *
63
- * Deliberately not glass: a badge is a micro-element, and a translucent 16pt
64
- * chip loses its contrast against whatever it sits on. It uses the solid theme
65
- * tint instead, which is what makes it legible in both themes.
66
- */
67
- exports.Badge = (0, react_1.forwardRef)(function Badge({ children, tone = "fill", overlay, style, isDark: isDarkProp, testID, ...props }, ref) {
68
- const isDark = (0, motion_1.useIsDark)(isDarkProp);
69
- const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
70
- const { View, Text } = (0, primitives_1.primitives)();
71
- const background = tone === "destructive"
72
- ? theme.destructive
73
- : tone === "success"
74
- ? theme.on
75
- : tone === "muted"
76
- ? theme.muted
77
- : theme.fill;
78
- const isDot = children == null;
79
- // The web badge is 24 tall with 10 of horizontal padding and 12/500 type.
80
- const height = isDot ? 10 : 24;
81
- const badge = ((0, jsx_runtime_1.jsx)(View, { ref: ref, testID: testID, accessibilityRole: "text", accessibilityLabel: isDot ? undefined : String(children), style: {
82
- minWidth: height,
83
- height,
84
- borderRadius: height / 2,
85
- paddingHorizontal: isDot ? 0 : 10,
86
- alignItems: "center",
87
- justifyContent: "center",
88
- backgroundColor: background,
89
- ...style,
90
- }, ...props, children: !isDot && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 12, fontWeight: "500", color: theme.onTint }, numberOfLines: 1, children: children })) }));
91
- if (overlay === undefined)
92
- return badge;
93
- // Overlaid: the badge floats at the top-right of whatever it decorates, which
94
- // needs a positioned box around the child rather than a bare fragment.
95
- return ((0, jsx_runtime_1.jsxs)(View, { style: { alignSelf: "flex-start" }, children: [overlay, (0, jsx_runtime_1.jsx)(View, { style: { position: "absolute", top: -4, right: -4 }, children: badge })] }));
96
- });
97
- /**
98
- * A hairline divider in the theme's separator colour.
99
- *
100
- * A plain View rather than a Glass: a 1pt rule is not a surface, and glass on
101
- * a line has nothing to refract.
102
- */
103
- exports.Separator = (0, react_1.forwardRef)(function Separator({ orientation = "horizontal", inset = 0, style, isDark: isDarkProp, testID, ...props }, ref) {
104
- const isDark = (0, motion_1.useIsDark)(isDarkProp);
105
- const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
106
- const { View } = (0, primitives_1.primitives)();
107
- const separatorStyle = orientation === "horizontal"
108
- ? { height: 1, alignSelf: "stretch", marginLeft: inset, backgroundColor: theme.separator }
109
- : { width: 1, alignSelf: "stretch", backgroundColor: theme.separator };
110
- return ((0, jsx_runtime_1.jsx)(View, { ref: ref, testID: testID, accessibilityRole: "none", style: { ...separatorStyle, ...style }, ...props }));
111
- });
112
- /**
113
- * A loading placeholder.
114
- *
115
- * The pulse is opacity only and slow, on the gentle spring, so it reads as
116
- * "loading" without motion that could bother someone sensitive to movement.
117
- * Nothing about it is essential to understanding the screen, so it is hidden
118
- * from screen readers rather than announced.
119
- */
120
- exports.Skeleton = (0, react_1.forwardRef)(function Skeleton({ shape = "rect", width, height, style, isDark: isDarkProp, testID, ...props }, ref) {
121
- const isDark = (0, motion_1.useIsDark)(isDarkProp);
122
- const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
123
- const { View, Animated } = (0, primitives_1.primitives)();
124
- const { value: pulse, animated } = (0, motion_1.useSpring)(1, "gentle");
125
- const opacity = animated
126
- ? pulse.interpolate({ inputRange: [0, 1], outputRange: [0.35, 1] })
127
- : 1;
128
- const resolvedWidth = width ?? (shape === "line" ? "100%" : shape === "circle" ? 40 : 120);
129
- const resolvedHeight = height ?? (shape === "line" ? 12 : shape === "circle" ? 40 : 80);
130
- const radius = shape === "circle" ? Math.min(resolvedHeight, 9999) / 2 : shape === "line" ? tokens_1.radii.sm : tokens_1.radii.md;
131
- const skeletonStyle = {
132
- width: resolvedWidth,
133
- height: resolvedHeight,
134
- borderRadius: radius,
135
- backgroundColor: theme.skeleton,
136
- ...style,
137
- };
138
- const a11y = { accessibilityRole: "none", accessible: false, testID };
139
- return animated ? ((0, jsx_runtime_1.jsx)(Animated.View, { ref: ref, style: { ...skeletonStyle, opacity }, ...a11y, ...props })) : ((0, jsx_runtime_1.jsx)(View, { ref: ref, style: skeletonStyle, ...a11y, ...props }));
140
- });
141
- const spinnerSizes = { sm: 16, md: 22, lg: 32 };
142
- /**
143
- * A loading spinner, drawn by Glacia.
144
- *
145
- * An SVG arc that rotates on the gentle spring through Animated — not the
146
- * platform's ActivityIndicator, so it looks the same on every platform and
147
- * wears the theme's colour instead of inheriting the system tint.
148
- */
149
- exports.Spinner = (0, react_1.forwardRef)(function Spinner({ size = "md", tint, accessibilityLabel = "Loading", style, isDark: isDarkProp, testID, ...props }, ref) {
150
- const isDark = (0, motion_1.useIsDark)(isDarkProp);
151
- const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
152
- const { View, Svg, Circle, Animated } = (0, primitives_1.primitives)();
153
- const dimension = spinnerSizes[size];
154
- const stroke = Math.max(2, Math.round(dimension / 9));
155
- const color = tint ?? theme.muted;
156
- // An arc, not a full ring: a complete circle rotating looks static.
157
- const circumference = 2 * Math.PI * ((dimension - stroke) / 2);
158
- const dash = circumference * 0.28;
159
- // A continuous spin never settles, so it is driven by Animated.timing on a
160
- // loop rather than the spring hook, which is built for one-off targets.
161
- const { Animated: AnimatedAPI, isNative } = (0, primitives_1.primitives)();
162
- const spinning = isNative && Boolean(AnimatedAPI?.timing);
163
- const rotation = (0, react_1.useRef)(null);
164
- if (rotation.current === null) {
165
- rotation.current = spinning ? new AnimatedAPI.Value(0) : null;
166
- }
167
- (0, react_1.useEffect)(() => {
168
- if (!spinning || !rotation.current)
169
- return;
170
- rotation.current.setValue(0);
171
- const loop = AnimatedAPI.loop(AnimatedAPI.timing(rotation.current, {
172
- toValue: 1,
173
- duration: 900,
174
- useNativeDriver: true,
175
- }));
176
- loop.start?.();
177
- return () => loop.stop?.();
178
- }, [AnimatedAPI, spinning]);
179
- const spinStyle = spinning
180
- ? {
181
- transform: [
182
- {
183
- rotate: rotation.current.interpolate({
184
- inputRange: [0, 1],
185
- outputRange: ["0deg", "360deg"],
186
- }),
187
- },
188
- ],
189
- }
190
- : undefined;
191
- const svg = ((0, jsx_runtime_1.jsxs)(Svg, { width: dimension, height: dimension, viewBox: `0 0 ${dimension} ${dimension}`, children: [(0, jsx_runtime_1.jsx)(Circle, { cx: dimension / 2, cy: dimension / 2, r: (dimension - stroke) / 2, stroke: theme.skeleton, strokeWidth: stroke, fill: "none" }), (0, jsx_runtime_1.jsx)(Circle, { cx: dimension / 2, cy: dimension / 2, r: (dimension - stroke) / 2, stroke: color, strokeWidth: stroke, fill: "none", strokeLinecap: "round", strokeDasharray: `${dash} ${circumference - dash}` })] }));
192
- return ((0, jsx_runtime_1.jsx)(View, { ref: ref, testID: testID, accessibilityRole: "progressbar", accessibilityLabel: accessibilityLabel, style: [{ width: dimension, height: dimension }, style], ...props, children: spinning ? (0, jsx_runtime_1.jsx)(Animated.View, { style: spinStyle, children: svg }) : svg }));
193
- });
194
- const RING = 64;
195
- /**
196
- * Progress, linear or circular.
197
- *
198
- * The track is a glass surface, so it refracts what it sits on exactly like the
199
- * rest of the library; the fill is the theme accent. Both forms report
200
- * `progressbar` with a value, which is the contract NativeTask relies on
201
- * internally — this component generalises it.
202
- */
203
- exports.Progress = (0, react_1.forwardRef)(function Progress({ value, variant = "bar", tint, accessibilityLabel, style, isDark: isDarkProp, testID, ...props }, ref) {
204
- const isDark = (0, motion_1.useIsDark)(isDarkProp);
205
- const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
206
- const { View, Text, Svg, Circle } = (0, primitives_1.primitives)();
207
- const clamped = Math.min(Math.max(value, 0), 100);
208
- const fill = tint ?? theme.fill;
209
- const a11y = {
210
- accessibilityRole: "progressbar",
211
- accessibilityValue: { min: 0, max: 100, now: Math.round(clamped) },
212
- accessibilityLabel,
213
- testID,
214
- };
215
- if (variant === "ring") {
216
- const stroke = 6;
217
- const radius = (RING - stroke) / 2;
218
- const circumference = 2 * Math.PI * radius;
219
- return ((0, jsx_runtime_1.jsxs)(View, { ref: ref, style: [{ width: RING, height: RING }, style], ...a11y, ...props, children: [(0, jsx_runtime_1.jsxs)(Svg, { width: RING, height: RING, viewBox: `0 0 ${RING} ${RING}`, children: [(0, jsx_runtime_1.jsx)(Circle, { cx: RING / 2, cy: RING / 2, r: radius, stroke: theme.skeleton, strokeWidth: stroke, fill: "none" }), (0, jsx_runtime_1.jsx)(Circle, { cx: RING / 2, cy: RING / 2, r: radius, stroke: fill, strokeWidth: stroke, fill: "none", strokeLinecap: "round", strokeDasharray: `${(clamped / 100) * circumference} ${circumference}`,
220
- // Start the arc at twelve o'clock, the way progress dials read.
221
- transform: `rotate(-90 ${RING / 2} ${RING / 2})` })] }), (0, jsx_runtime_1.jsx)(View, { style: {
222
- position: "absolute",
223
- width: RING,
224
- height: RING,
225
- alignItems: "center",
226
- justifyContent: "center",
227
- }, children: (0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 13, fontWeight: "600", color: theme.foreground }, children: `${Math.round(clamped)}%` }) })] }));
228
- }
229
- return ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { ref: ref, effect: "regular", surface: "rail", isDark: isDark, style: {
230
- height: 8,
231
- borderRadius: tokens_1.radii.pill,
232
- overflow: "hidden",
233
- justifyContent: "center",
234
- ...style,
235
- }, ...a11y, ...props, children: (0, jsx_runtime_1.jsx)(View, { style: {
236
- width: `${clamped}%`,
237
- height: 8,
238
- borderRadius: tokens_1.radii.pill,
239
- backgroundColor: fill,
240
- } }) }));
241
- });
242
- // ---------------------------------------------------------------------------
243
- // Rating
244
- /** The five-pointed star, as a path in a unit box. */
245
- const STAR_PATH = "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";
246
- /**
247
- * A star rating.
248
- *
249
- * The stars are drawn as SVG paths from the resolver, so nothing is a
250
- * platform control. A fractional value fills part of a star: 3.5 draws three
251
- * full stars and one half, the half produced by clipping the filled star at the
252
- * fraction's width rather than by rounding — a 4.5-star average must look like
253
- * a 4.5-star average.
254
- *
255
- * Read-only unless `onChange` is given. With it, each star is tappable, the
256
- * value is exposed as an adjustable control (increment/decrement through
257
- * accessibility actions), and each star has its own label so a screen reader
258
- * can name the exact rating it sets.
259
- */
260
- exports.Rating = (0, react_1.forwardRef)(function Rating({ value, max = 5, size = "md", onChange, disabled = false, accessibilityLabel = "Rating", style, isDark: isDarkProp, testID, ...props }, ref) {
261
- const isDark = (0, motion_1.useIsDark)(isDarkProp);
262
- const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
263
- const { View, Pressable, Svg, Path, Defs, ClipPath, Rect } = (0, primitives_1.primitives)();
264
- const starSize = tokens_1.controlSizes.star[size];
265
- const interactive = Boolean(onChange) && !disabled;
266
- const clamped = Math.max(0, Math.min(value, max));
267
- const setValue = (next) => {
268
- const bounded = Math.max(0, Math.min(next, max));
269
- onChange?.(bounded);
270
- };
271
- const star = (index) => {
272
- // How much of this star is filled: 1 for a full star, 0 for empty, and the
273
- // remainder for the one the value lands inside.
274
- const filled = Math.max(0, Math.min(1, clamped - index));
275
- const half = filled > 0 && filled < 1;
276
- const glyph = ((0, jsx_runtime_1.jsxs)(Svg, { width: starSize, height: starSize, viewBox: "0 0 24 24", children: [half ? ((0, jsx_runtime_1.jsx)(Defs, { children: (0, jsx_runtime_1.jsx)(ClipPath, { id: `rating-clip-${index}`, children: (0, jsx_runtime_1.jsx)(Rect, { x: "0", y: "0", width: 24 * filled, height: 24 }) }) })) : null, (0, jsx_runtime_1.jsx)(Path, { d: STAR_PATH, fill: theme.separator }), filled > 0 ? ((0, jsx_runtime_1.jsx)(Path, { d: STAR_PATH, fill: theme.fill, ...(half ? { clipPath: `url(#rating-clip-${index})` } : {}) })) : null] }));
277
- if (!interactive)
278
- return (0, jsx_runtime_1.jsx)(View, { children: glyph }, index);
279
- return ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: `${index + 1} of ${max} stars`, accessibilityState: { selected: clamped === index + 1 }, onPress: () => setValue(index + 1), hitSlop: 4, children: glyph }, index));
280
- };
281
- const stars = Array.from({ length: Math.max(1, max) }, (_unused, index) => star(index));
282
- if (!interactive && !onChange) {
283
- return ((0, jsx_runtime_1.jsx)(View, { ref: ref, testID: testID, accessibilityRole: "text", accessibilityLabel: `${accessibilityLabel}, ${clamped} of ${max}`, style: { flexDirection: "row", alignItems: "center", gap: 2, ...style }, ...props, children: stars }));
284
- }
285
- return ((0, jsx_runtime_1.jsx)(View, { ref: ref, testID: testID, accessibilityRole: "adjustable", accessibilityLabel: accessibilityLabel, accessibilityState: { disabled }, accessibilityValue: { min: 0, max, now: clamped }, accessibilityActions: [{ name: "increment" }, { name: "decrement" }], onAccessibilityAction: (event) => {
286
- if (disabled)
287
- return;
288
- if (event?.nativeEvent?.actionName === "increment")
289
- setValue(clamped + 1);
290
- if (event?.nativeEvent?.actionName === "decrement")
291
- setValue(clamped - 1);
292
- }, style: { flexDirection: "row", alignItems: "center", gap: 2, opacity: disabled ? 0.38 : 1, ...style }, ...props, children: stars }));
293
- });
294
- /**
295
- * A plain image, with the loading and error states every app ends up writing.
296
- *
297
- * Three states, because an image on a phone is three states: loading (a
298
- * Skeleton behind it), loaded (a fade in), and failed (the caller's fallback).
299
- * Aspect ratio comes from `style`, so a caller sets `aspectRatio` and the height
300
- * follows.
301
- *
302
- * This is the plain one; `NativeImageGeneration` is the AI-specific cousin and
303
- * keeps its own state machine.
304
- */
305
- exports.NativeImage = (0, react_1.forwardRef)(function NativeImage({ source, accessibilityLabel, placeholder, fallback, fadeIn = true, style, isDark: isDarkProp, testID, ...props }, ref) {
306
- const isDark = (0, motion_1.useIsDark)(isDarkProp);
307
- const { View, Image: RNImage, Animated } = (0, primitives_1.primitives)();
308
- const [failed, setFailed] = (0, react_1.useState)(false);
309
- const [loaded, setLoaded] = (0, react_1.useState)(false);
310
- const { value: fade, animated } = (0, motion_1.useSpring)(loaded ? 1 : 0, "gentle");
311
- const boxStyle = { overflow: "hidden", ...style };
312
- if (failed && fallback) {
313
- return ((0, jsx_runtime_1.jsx)(View, { ref: ref, testID: testID, style: boxStyle, ...props, children: fallback }));
314
- }
315
- const imageStyle = { width: "100%", height: "100%" };
316
- const opacity = fadeIn && animated ? fade : 1;
317
- return ((0, jsx_runtime_1.jsxs)(View, { ref: ref, testID: testID, style: boxStyle, ...props, children: [!loaded ? (0, jsx_runtime_1.jsx)(View, { style: { position: "absolute", top: 0, left: 0, right: 0, bottom: 0 }, children: placeholder ?? (0, jsx_runtime_1.jsx)(exports.Skeleton, { shape: "rect", isDark: isDark }) }) : null, (0, jsx_runtime_1.jsx)(RNImage, { accessibilityRole: "image", accessibilityLabel: accessibilityLabel, source: source, onLoad: () => setLoaded(true), onError: () => setFailed(true), style: [imageStyle, animated ? { opacity } : null] })] }));
318
- });