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,344 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Drawer = exports.Sheet = exports.Menu = void 0;
4
- exports.anchorPopover = anchorPopover;
5
- exports.resolveSnapPoint = resolveSnapPoint;
6
- exports.nearestSnapPoint = nearestSnapPoint;
7
- const jsx_runtime_1 = require("react/jsx-runtime");
8
- const react_1 = require("react");
9
- const Glass_1 = require("./Glass");
10
- const tokens_1 = require("./internal/tokens");
11
- const primitives_1 = require("./internal/primitives");
12
- const motion_1 = require("./internal/motion");
13
- const haptics_1 = require("./internal/haptics");
14
- /**
15
- * Registers Android's hardware back while an overlay is open.
16
- *
17
- * Shared by Menu, Sheet and Drawer so every overlay dismisses the same way a
18
- * Dialog does: the back button closes the layer, not the screen behind it.
19
- */
20
- function useBackDismiss(open, onDismiss) {
21
- (0, react_1.useEffect)(() => {
22
- if (!open)
23
- return;
24
- const BackHandler = (0, primitives_1.primitives)().getBackHandler();
25
- if (!BackHandler)
26
- return;
27
- const sub = BackHandler.addEventListener("hardwareBackPress", () => {
28
- onDismiss();
29
- return true;
30
- });
31
- return () => sub.remove();
32
- }, [open, onDismiss]);
33
- }
34
- /**
35
- * Keeps a popover inside the window.
36
- *
37
- * Called with the trigger's measured frame and the popover's own size; returns
38
- * the offsets that bring it back on screen. A menu near the bottom edge flips
39
- * above its trigger rather than hanging off the display.
40
- */
41
- function anchorPopover(trigger, popover, viewport, gap = 6) {
42
- const below = trigger.y + trigger.height + gap;
43
- const above = trigger.y - popover.height - gap;
44
- const fitsBelow = below + popover.height <= viewport.height;
45
- const flipped = !fitsBelow && above >= 0;
46
- const top = Math.max(0, Math.min(flipped ? above : below, viewport.height - popover.height));
47
- const left = Math.max(0, Math.min(trigger.x, viewport.width - popover.width));
48
- return { left, top, flipped };
49
- }
50
- /**
51
- * An anchored dropdown menu.
52
- *
53
- * A press outside or on an item closes it; Android's back button does too. The
54
- * popover is a glass surface with `glassActive` rows, matching the way the
55
- * library marks a tappable row rather than nesting another glass panel.
56
- */
57
- exports.Menu = (0, react_1.forwardRef)(function Menu({ trigger, items, open: openProp, onOpenChange, width = 220, accessibilityLabel = "Menu", style, isDark: isDarkProp, testID, ...props }, ref) {
58
- const isDark = (0, motion_1.useIsDark)(isDarkProp);
59
- const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
60
- const { View, Text: RNText, Pressable, Modal } = (0, primitives_1.primitives)();
61
- const [internalOpen, setInternalOpen] = (0, react_1.useState)(false);
62
- const open = openProp !== undefined ? openProp : internalOpen;
63
- const setOpen = (0, react_1.useCallback)((next) => {
64
- if (openProp === undefined)
65
- setInternalOpen(next);
66
- onOpenChange?.(next);
67
- }, [openProp, onOpenChange]);
68
- const dismiss = (0, react_1.useCallback)(() => setOpen(false), [setOpen]);
69
- useBackDismiss(open, dismiss);
70
- const { value: enter, animated } = (0, motion_1.useSpring)(open ? 1 : 0, "snappy");
71
- const scale = animated ? enter.interpolate({ inputRange: [0, 1], outputRange: [0.96, 1] }) : 1;
72
- const popover = ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { effect: "regular", surface: "overlay", isDark: isDark, testID: testID ? `${testID}-popover` : undefined, style: {
73
- width,
74
- borderRadius: tokens_1.radii.lg,
75
- paddingVertical: 4,
76
- // The web menu is deliberately near-solid so its labels stay legible
77
- // over any backdrop, and it floats on a real shadow.
78
- backgroundColor: theme.surface,
79
- shadowOpacity: 0.12,
80
- shadowRadius: 40,
81
- shadowOffset: { width: 0, height: 12 },
82
- ...style,
83
- }, children: items.map((item, index) => ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "button", accessibilityLabel: item.accessibilityLabel ?? item.label, accessibilityState: { disabled: item.disabled }, disabled: item.disabled, onPress: () => {
84
- setOpen(false);
85
- item.onPress();
86
- }, style: { flexDirection: "row", alignItems: "center", gap: 10, minHeight: 40, paddingVertical: 8, paddingHorizontal: 12, opacity: item.disabled ? 0.38 : 1 }, children: [item.icon ? (0, jsx_runtime_1.jsx)(View, { children: item.icon }) : null, (0, jsx_runtime_1.jsx)(RNText, { numberOfLines: 1, style: { fontSize: 15, color: item.destructive ? theme.destructive : theme.foreground }, children: item.label })] }, `${item.label}-${index}`))) }));
87
- return ((0, jsx_runtime_1.jsxs)(View, { ref: ref, style: { alignSelf: "flex-start" }, ...props, children: [(0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: accessibilityLabel, accessibilityState: { expanded: open }, onPress: () => setOpen(!open), children: trigger }), (0, jsx_runtime_1.jsx)(Modal, { visible: open, transparent: true, animationType: "fade", onRequestClose: dismiss, children: (0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: "Close menu", onPress: dismiss, style: { flex: 1, backgroundColor: theme.scrim }, children: (0, jsx_runtime_1.jsx)(View, { style: { flex: 1, alignItems: "center", justifyContent: "center", padding: 24 }, children: (0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "none", onPress: () => { }, children: animated ? ((0, jsx_runtime_1.jsx)(AnimatedScale, { scale: scale, children: popover })) : (popover) }) }) }) })] }));
88
- });
89
- /** Wraps a popover in the entrance scale, which must land on an Animated.View. */
90
- function AnimatedScale({ scale, children }) {
91
- const { Animated } = (0, primitives_1.primitives)();
92
- return (0, jsx_runtime_1.jsx)(Animated.View, { style: { transform: [{ scale }] }, children: children });
93
- }
94
- /**
95
- * A bottom sheet.
96
- *
97
- * The general-purpose container: it slides up on the springs token, dismisses
98
- * on a scrim press and on Android back. ActionSheet remains the action-menu
99
- * specialisation of this shape; Sheet is for arbitrary content — a form, a
100
- * calendar, a detail panel.
101
- */
102
- /**
103
- * Turns a snap point into a pixel height.
104
- *
105
- * A number under 1 is a fraction of the window; anything else is points. The
106
- * result is clamped so a sheet can never be taller than the space it has.
107
- */
108
- function resolveSnapPoint(point, windowHeight) {
109
- const height = point > 0 && point < 1 ? point * windowHeight : point;
110
- return Math.max(0, Math.min(height, windowHeight));
111
- }
112
- /**
113
- * Picks the snap point nearest to where the user let go.
114
- *
115
- * `height` is how tall the sheet currently is. Ties go to the smaller sheet,
116
- * so a small flick does not jump the panel to full height.
117
- */
118
- function nearestSnapPoint(heights, height) {
119
- let best = 0;
120
- let bestDistance = Number.POSITIVE_INFINITY;
121
- heights.forEach((candidate, index) => {
122
- const distance = Math.abs(candidate - height);
123
- if (distance < bestDistance) {
124
- bestDistance = distance;
125
- best = index;
126
- }
127
- });
128
- return best;
129
- }
130
- exports.Sheet = (0, react_1.forwardRef)(function Sheet({ open: openProp, defaultOpen = false, onOpenChange, title, children, footer, dismissOnBackdropPress = true, showHandle = true, snapPoints, initialSnapIndex = 0, snapIndex: snapIndexProp, onSnapIndexChange, dismissOnSnapToBottom = false, draggable = true, haptics = true, style, isDark: isDarkProp, testID, ...props }, ref) {
131
- const isDark = (0, motion_1.useIsDark)(isDarkProp);
132
- const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
133
- const { View, Text: RNText, Pressable, Modal, PanResponder, useWindowDimensions } = (0, primitives_1.primitives)();
134
- const [internalOpen, setInternalOpen] = (0, react_1.useState)(defaultOpen);
135
- const open = openProp !== undefined ? openProp : internalOpen;
136
- const setOpen = (0, react_1.useCallback)((next) => {
137
- if (openProp === undefined)
138
- setInternalOpen(next);
139
- onOpenChange?.(next);
140
- }, [openProp, onOpenChange]);
141
- const dismiss = (0, react_1.useCallback)(() => setOpen(false), [setOpen]);
142
- useBackDismiss(open, dismiss);
143
- // Snap points in pixels, smallest first so index 0 is the shortest sheet.
144
- const windowHeight = useWindowDimensions?.().height ?? 800;
145
- const heights = (0, react_1.useMemo)(() => {
146
- if (!snapPoints || snapPoints.length === 0)
147
- return [];
148
- return snapPoints.map((point) => resolveSnapPoint(point, windowHeight)).sort((a, b) => a - b);
149
- }, [snapPoints, windowHeight]);
150
- const [internalSnap, setInternalSnap] = (0, react_1.useState)(initialSnapIndex);
151
- const snapIndex = snapIndexProp !== undefined ? snapIndexProp : internalSnap;
152
- const activeHeight = heights.length > 0 ? heights[Math.min(snapIndex, heights.length - 1)] : null;
153
- // Drag offset in pixels: 0 is resting at the active snap point, positive is
154
- // dragged down. It resets to 0 after a release, because the settle either
155
- // changes the snap index or dismisses.
156
- const dragRef = (0, react_1.useRef)(0);
157
- const [drag, setDrag] = (0, react_1.useState)(0);
158
- const { value: rise, animated } = (0, motion_1.useSpring)(open ? 1 : 0, "gentle");
159
- const slideIn = animated ? rise.interpolate({ inputRange: [0, 1], outputRange: [420, 0] }) : 0;
160
- const heightsRef = (0, react_1.useRef)(heights);
161
- heightsRef.current = heights;
162
- const activeHeightRef = (0, react_1.useRef)(activeHeight);
163
- activeHeightRef.current = activeHeight;
164
- const snapIndexRef = (0, react_1.useRef)(snapIndex);
165
- snapIndexRef.current = snapIndex;
166
- const goToSnap = (0, react_1.useCallback)((index) => {
167
- if (snapIndexProp === undefined)
168
- setInternalSnap(index);
169
- onSnapIndexChange?.(index);
170
- if (haptics)
171
- (0, haptics_1.hapticSelection)();
172
- }, [snapIndexProp, onSnapIndexChange, haptics]);
173
- /**
174
- * The release decision.
175
- *
176
- * Below the lowest snap point the sheet dismisses when allowed, otherwise it
177
- * snaps back; anywhere else it settles at the nearest point, with a fast
178
- * downward flick counting as a step towards the smaller sheet.
179
- */
180
- const release = (0, react_1.useCallback)((dy, vy) => {
181
- const list = heightsRef.current;
182
- const current = list[snapIndexRef.current] ?? activeHeightRef.current ?? 0;
183
- const restingAfterDrag = current - dy;
184
- if (list.length === 0) {
185
- // No snap points: a decisive downward drag dismisses.
186
- if (dy > 120 || vy > 0.8)
187
- dismiss();
188
- return;
189
- }
190
- const lowest = list[0];
191
- const belowLowest = restingAfterDrag < lowest - 40;
192
- if (belowLowest && dismissOnSnapToBottom) {
193
- dismiss();
194
- return;
195
- }
196
- // A fast flick moves one step in its direction before distance decides.
197
- let index = nearestSnapPoint(list, restingAfterDrag);
198
- if (vy > 0.5)
199
- index = Math.max(0, Math.min(index, snapIndexRef.current - 1));
200
- if (vy < -0.5)
201
- index = Math.max(index, Math.min(snapIndexRef.current + 1, list.length - 1));
202
- if (index !== snapIndexRef.current)
203
- goToSnap(index);
204
- }, [dismiss, dismissOnSnapToBottom, goToSnap]);
205
- const panResponder = (0, react_1.useMemo)(() => {
206
- if (!draggable || !PanResponder?.create)
207
- return null;
208
- return PanResponder.create({
209
- // Vertical drags belong to the sheet; horizontal ones are left alone.
210
- onStartShouldSetPanResponder: () => false,
211
- onMoveShouldSetPanResponder: (_event, gesture) => Math.abs(gesture.dy) > Math.abs(gesture.dx) && Math.abs(gesture.dy) > 6,
212
- onPanResponderGrant: () => {
213
- dragRef.current = 0;
214
- },
215
- onPanResponderMove: (_event, gesture) => {
216
- // Dragging up past the tallest point has nowhere to go; clamp at 0.
217
- const next = Math.max(-40, gesture.dy);
218
- dragRef.current = next;
219
- setDrag(next);
220
- },
221
- onPanResponderRelease: (_event, gesture) => {
222
- release(gesture.dy, gesture.vy);
223
- dragRef.current = 0;
224
- setDrag(0);
225
- },
226
- onPanResponderTerminate: () => {
227
- dragRef.current = 0;
228
- setDrag(0);
229
- },
230
- onPanResponderTerminationRequest: () => false,
231
- });
232
- }, [draggable, PanResponder, release]);
233
- // Reduce Motion is honoured by useSpring: when it is on, `animated` is false
234
- // and the panel is already in position, so the sheet opens and snaps without
235
- // a transition.
236
- const translateY = drag !== 0 ? drag : animated ? slideIn : 0;
237
- const panel = ((0, jsx_runtime_1.jsx)(SheetPanel, { title: title, footer: footer, showHandle: showHandle, isDark: isDark, testID: testID, style: style, height: activeHeight, children: children }));
238
- return ((0, jsx_runtime_1.jsx)(Modal, { visible: open, transparent: true, animationType: "fade", onRequestClose: dismiss, children: (0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: "Close sheet", onPress: dismissOnBackdropPress ? dismiss : undefined, style: { flex: 1, justifyContent: "flex-end", backgroundColor: theme.scrim }, children: (0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "none", onPress: () => { }, style: { width: "100%" }, ...(panResponder ? panResponder.panHandlers : {}), children: animated || drag !== 0 ? ((0, jsx_runtime_1.jsx)(SheetRise, { translateY: translateY, children: panel })) : (panel) }) }) }));
239
- });
240
- function SheetRise({ translateY, children }) {
241
- const { Animated } = (0, primitives_1.primitives)();
242
- return (0, jsx_runtime_1.jsx)(Animated.View, { style: { transform: [{ translateY }] }, children: children });
243
- }
244
- /** The panel itself: a glass surface with a handle, a title and a footer. */
245
- function SheetPanel({ title, footer, showHandle, isDark, testID, style, height, children, }) {
246
- const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
247
- const { View, Text: RNText } = (0, primitives_1.primitives)();
248
- return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { effect: "regular", surface: "overlay", isDark: isDark, testID: testID, style: {
249
- borderTopLeftRadius: tokens_1.radii.xl,
250
- borderTopRightRadius: tokens_1.radii.xl,
251
- borderBottomLeftRadius: 0,
252
- borderBottomRightRadius: 0,
253
- paddingBottom: 24,
254
- // The web sheet carries a deep, soft shadow so it reads as a layer
255
- // above the page rather than a rectangle painted on it.
256
- shadowOpacity: 0.5,
257
- shadowRadius: 40,
258
- shadowOffset: { width: 0, height: 0 },
259
- // A snap point fixes the height; without one the panel is natural.
260
- ...(height != null ? { height } : { maxHeight: 560 }),
261
- ...style,
262
- }, children: [showHandle ? ((0, jsx_runtime_1.jsx)(View, { style: { alignItems: "center", paddingTop: 8, paddingBottom: 4 }, children: (0, jsx_runtime_1.jsx)(View, { accessibilityElementsHidden: true,
263
- // A capsule: the radius is half the handle's own height.
264
- style: { width: 36, height: 5, borderRadius: 5 / 2, backgroundColor: theme.separator } }) })) : null, title ? ((0, jsx_runtime_1.jsx)(View, { style: { paddingHorizontal: 24, paddingVertical: 10 }, children: (0, jsx_runtime_1.jsx)(RNText, { accessibilityRole: "heading", style: { fontSize: 17, fontWeight: "600", color: theme.foreground }, children: title }) })) : null, (0, jsx_runtime_1.jsx)(View, { style: { paddingHorizontal: 24 }, children: children }), footer ? (0, jsx_runtime_1.jsx)(View, { style: { paddingHorizontal: 24, paddingTop: 12, gap: 8 }, children: footer }) : null] }));
265
- }
266
- /**
267
- * A side navigation drawer.
268
- *
269
- * The same overlay discipline as Sheet — scrim, spring slide, Android back —
270
- * but anchored to a side edge, with a square panel that runs the full height.
271
- * The caller supplies the content, typically a List.
272
- *
273
- * Dragging the panel towards its own edge follows the finger; releasing past
274
- * the halfway point, or with enough outward velocity, closes it, and a drag
275
- * that stays inside springs it back open. Reduce Motion is honoured: with it
276
- * on, the drawer appears and disappears without sliding.
277
- */
278
- exports.Drawer = (0, react_1.forwardRef)(function Drawer({ open: openProp, defaultOpen = false, onOpenChange, side = "left", width = 280, children, dismissOnBackdropPress = true, draggable = true, haptics = true, style, isDark: isDarkProp, testID, ...props }, ref) {
279
- const isDark = (0, motion_1.useIsDark)(isDarkProp);
280
- const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
281
- const { View, Pressable, Modal, PanResponder } = (0, primitives_1.primitives)();
282
- const [internalOpen, setInternalOpen] = (0, react_1.useState)(defaultOpen);
283
- const open = openProp !== undefined ? openProp : internalOpen;
284
- const setOpen = (0, react_1.useCallback)((next) => {
285
- if (openProp === undefined)
286
- setInternalOpen(next);
287
- onOpenChange?.(next);
288
- }, [openProp, onOpenChange]);
289
- const dismiss = (0, react_1.useCallback)(() => setOpen(false), [setOpen]);
290
- useBackDismiss(open, dismiss);
291
- const { value: slide, animated } = (0, motion_1.useSpring)(open ? 1 : 0, "gentle");
292
- // Slide in from off-screen: negative from the left, positive from the right.
293
- const slideIn = animated
294
- ? slide.interpolate({ inputRange: [0, 1], outputRange: [side === "left" ? -width : width, 0] })
295
- : 0;
296
- // The drag is measured in the drawer's own closing direction, so a drag
297
- // towards the anchored edge is always positive whichever side it is on.
298
- const [drag, setDrag] = (0, react_1.useState)(0);
299
- const panResponder = (0, react_1.useMemo)(() => {
300
- if (!draggable || !PanResponder?.create)
301
- return null;
302
- const outward = side === "left" ? -1 : 1;
303
- return PanResponder.create({
304
- onStartShouldSetPanResponder: () => false,
305
- onMoveShouldSetPanResponder: (_event, gesture) =>
306
- // Only a horizontal drag towards the edge is ours; the other way has
307
- // nowhere to go and should not fight content inside the panel.
308
- Math.abs(gesture.dx) > Math.abs(gesture.dy) && gesture.dx * outward > 6,
309
- onPanResponderMove: (_event, gesture) => {
310
- setDrag(Math.max(0, gesture.dx * outward));
311
- },
312
- onPanResponderRelease: (_event, gesture) => {
313
- const travelled = Math.max(0, gesture.dx * outward);
314
- const thrown = gesture.vx * outward > 0.4;
315
- setDrag(0);
316
- if (travelled > width / 2 || thrown) {
317
- if (haptics)
318
- (0, haptics_1.hapticSelection)();
319
- dismiss();
320
- }
321
- },
322
- onPanResponderTerminate: () => setDrag(0),
323
- onPanResponderTerminationRequest: () => false,
324
- });
325
- // `dismiss` is stable; the gesture only needs rebuilding when its shape
326
- // (side or width) changes.
327
- }, [draggable, PanResponder, side, width, haptics, dismiss]);
328
- const translateX = drag !== 0 ? (side === "left" ? -drag : drag) : animated ? slideIn : 0;
329
- const panel = ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { effect: "regular", surface: "overlay", isDark: isDark, testID: testID, style: {
330
- width,
331
- height: "100%",
332
- borderRadius: 0,
333
- paddingTop: 56,
334
- ...style,
335
- }, children: children }));
336
- return ((0, jsx_runtime_1.jsx)(Modal, { visible: open, transparent: true, animationType: "fade", onRequestClose: dismiss, children: (0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: "Close drawer", onPress: dismissOnBackdropPress ? dismiss : undefined, style: { flex: 1, backgroundColor: theme.scrim }, children: (0, jsx_runtime_1.jsx)(View, { style: {
337
- flex: 1,
338
- alignItems: side === "left" ? "flex-start" : "flex-end",
339
- }, children: (0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "none", onPress: () => { }, style: { height: "100%" }, ...(panResponder ? panResponder.panHandlers : {}), children: animated || drag !== 0 ? (0, jsx_runtime_1.jsx)(DrawerSlide, { translateX: translateX, children: panel }) : panel }) }) }) }));
340
- });
341
- function DrawerSlide({ translateX, children }) {
342
- const { Animated } = (0, primitives_1.primitives)();
343
- return (0, jsx_runtime_1.jsx)(Animated.View, { style: { height: "100%", transform: [{ translateX }] }, children: children });
344
- }
@@ -1,243 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TimePicker = exports.DatePicker = exports.Calendar = exports.MONTHS = exports.WEEKDAYS = void 0;
4
- exports.startOfDay = startOfDay;
5
- exports.sameDay = sameDay;
6
- exports.monthGrid = monthGrid;
7
- exports.parseTime = parseTime;
8
- exports.formatTime = formatTime;
9
- const jsx_runtime_1 = require("react/jsx-runtime");
10
- const react_1 = require("react");
11
- const Button_1 = require("./Button");
12
- const Overlays_1 = require("./Overlays");
13
- const tokens_1 = require("./internal/tokens");
14
- const primitives_1 = require("./internal/primitives");
15
- const motion_1 = require("./internal/motion");
16
- const lens_1 = require("./internal/lens");
17
- // ---------------------------------------------------------------------------
18
- // Date helpers
19
- //
20
- // Kept pure and exported so a caller (and the tests) can reason about the same
21
- // calendar maths the grid uses. Dates are compared by day, never by instant,
22
- // which is the bug that makes a picker select "yesterday" near midnight.
23
- /** Midnight on the same calendar day, so two picks compare equal. */
24
- function startOfDay(date) {
25
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
26
- }
27
- function sameDay(a, b) {
28
- if (!a || !b)
29
- return false;
30
- return (a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate());
31
- }
32
- /**
33
- * The six-row month grid.
34
- *
35
- * Always six rows so the calendar does not change height as months change,
36
- * which would make the surrounding layout jump between February and March.
37
- */
38
- function monthGrid(year, month, weekStartsOn = 0) {
39
- const first = new Date(year, month, 1);
40
- // getDay() is 0 for Sunday; the offset is how many leading cells to add.
41
- const offset = (first.getDay() - weekStartsOn + 7) % 7;
42
- const cells = [];
43
- for (let i = 0; i < 42; i += 1) {
44
- const date = new Date(year, month, 1 - offset + i);
45
- cells.push({
46
- date,
47
- outside: date.getMonth() !== month,
48
- key: `${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`,
49
- });
50
- }
51
- return cells;
52
- }
53
- exports.WEEKDAYS = ["S", "M", "T", "W", "T", "F", "S"];
54
- exports.MONTHS = [
55
- "January",
56
- "February",
57
- "March",
58
- "April",
59
- "May",
60
- "June",
61
- "July",
62
- "August",
63
- "September",
64
- "October",
65
- "November",
66
- "December",
67
- ];
68
- /**
69
- * A month calendar, built from Glacia's own views.
70
- *
71
- * No native date picker anywhere: the grid, the weekday header and the month
72
- * navigation are ours, so the calendar looks the same on iOS and Android and
73
- * wears the library's tokens. The selected day is a `glassActive` fill, today
74
- * carries a ring, and disabled days are dimmed.
75
- */
76
- exports.Calendar = (0, react_1.forwardRef)(function Calendar({ value, onChange, minDate, maxDate, initialMonth, weekStartsOn = 0, style, isDark: isDarkProp, testID, ...props }, ref) {
77
- const isDark = (0, motion_1.useIsDark)(isDarkProp);
78
- const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
79
- const { View, Text: RNText, Pressable } = (0, primitives_1.primitives)();
80
- const anchor = value ?? initialMonth ?? new Date();
81
- const [month, setMonth] = (0, react_1.useState)({ year: anchor.getFullYear(), month: anchor.getMonth() });
82
- const cells = (0, react_1.useMemo)(() => monthGrid(month.year, month.month, weekStartsOn), [month, weekStartsOn]);
83
- const today = startOfDay(new Date());
84
- const isDisabled = (date) => {
85
- const day = startOfDay(date);
86
- if (minDate && day < startOfDay(minDate))
87
- return true;
88
- if (maxDate && day > startOfDay(maxDate))
89
- return true;
90
- return false;
91
- };
92
- const shift = (delta) => {
93
- setMonth((current) => {
94
- const next = new Date(current.year, current.month + delta, 1);
95
- return { year: next.getFullYear(), month: next.getMonth() };
96
- });
97
- };
98
- const cellSize = 38;
99
- return ((0, jsx_runtime_1.jsxs)(View, { ref: ref, testID: testID, accessibilityRole: "none", style: [{ alignSelf: "stretch" }, style], ...props, children: [(0, jsx_runtime_1.jsxs)(View, { style: { flexDirection: "row", alignItems: "center", justifyContent: "space-between", paddingBottom: 8 }, children: [(0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: "Previous month", onPress: () => shift(-1), hitSlop: 8, style: { padding: 6 }, children: (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 17, color: theme.foreground }, children: "\u2039" }) }), (0, jsx_runtime_1.jsx)(RNText, { accessibilityRole: "heading", style: { fontSize: 16, fontWeight: "600", color: theme.foreground }, children: `${exports.MONTHS[month.month]} ${month.year}` }), (0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: "Next month", onPress: () => shift(1), hitSlop: 8, style: { padding: 6 }, children: (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 17, color: theme.foreground }, children: "\u203A" }) })] }), (0, jsx_runtime_1.jsx)(View, { style: { flexDirection: "row" }, children: Array.from({ length: 7 }, (_, i) => ((0, jsx_runtime_1.jsx)(View, { style: { flex: 1, alignItems: "center", paddingVertical: 4 }, children: (0, jsx_runtime_1.jsx)(RNText, { accessibilityElementsHidden: true, style: { fontSize: 11, fontWeight: "600", color: theme.muted }, children: exports.WEEKDAYS[(i + weekStartsOn) % 7] }) }, i))) }), Array.from({ length: 6 }, (_, row) => ((0, jsx_runtime_1.jsx)(View, { style: { flexDirection: "row" }, children: cells.slice(row * 7, row * 7 + 7).map((cell) => {
100
- const selected = sameDay(cell.date, value);
101
- const isToday = sameDay(cell.date, today);
102
- const disabled = isDisabled(cell.date);
103
- return ((0, jsx_runtime_1.jsx)(View, { style: { flex: 1, alignItems: "center", paddingVertical: 2 }, children: (0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "button", accessibilityLabel: cell.date.toDateString(), accessibilityState: { selected, disabled }, disabled: disabled, onPress: () => onChange?.(startOfDay(cell.date)), style: {
104
- width: cellSize,
105
- height: cellSize,
106
- borderRadius: cellSize / 2,
107
- alignItems: "center",
108
- justifyContent: "center",
109
- backgroundColor: "transparent",
110
- // Today is ringed; the selection is a lens on top of it.
111
- borderWidth: isToday && !selected ? 0.5 : 0,
112
- borderColor: isToday && !selected ? theme.fill : theme.edge,
113
- opacity: disabled ? 0.28 : cell.outside ? 0.45 : 1,
114
- }, children: [selected ? ((0, jsx_runtime_1.jsx)(lens_1.SelectedLens, { radius: cellSize / 2, isDark: isDark, style: lens_1.lensFill })) : null, (0, jsx_runtime_1.jsx)(RNText, { style: {
115
- fontSize: 14,
116
- fontWeight: selected ? "600" : "400",
117
- color: selected ? theme.foreground : theme.foreground,
118
- }, children: String(cell.date.getDate()) })] }) }, cell.key));
119
- }) }, row)))] }));
120
- });
121
- /**
122
- * A date picker: the Calendar presented in a Sheet.
123
- *
124
- * Browsing months does not commit anything — the pending date is local until
125
- * the user confirms, so an accidental swipe of the calendar cannot change a
126
- * saved value.
127
- */
128
- exports.DatePicker = (0, react_1.forwardRef)(function DatePicker({ open: openProp, defaultOpen = false, onOpenChange, value, onConfirm, onCancel, title = "Select date", confirmLabel = "Confirm", cancelLabel = "Cancel", minDate, maxDate, style, isDark: isDarkProp, testID, ...props }, ref) {
129
- const isDark = (0, motion_1.useIsDark)(isDarkProp);
130
- const [internalOpen, setInternalOpen] = (0, react_1.useState)(defaultOpen);
131
- const open = openProp !== undefined ? openProp : internalOpen;
132
- const [pending, setPending] = (0, react_1.useState)(value);
133
- const setOpen = (next) => {
134
- if (openProp === undefined)
135
- setInternalOpen(next);
136
- onOpenChange?.(next);
137
- };
138
- return ((0, jsx_runtime_1.jsx)(Overlays_1.Sheet, { ref: ref, open: open, onOpenChange: setOpen, title: title, isDark: isDark, testID: testID, style: style, footer: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Button_1.Button, { variant: "ghost", accessibilityLabel: cancelLabel, onPress: () => {
139
- // Cancelling restores the committed value for the next open.
140
- setPending(value);
141
- onCancel?.();
142
- setOpen(false);
143
- }, children: cancelLabel }), (0, jsx_runtime_1.jsx)(Button_1.Button, { variant: "filled", accessibilityLabel: confirmLabel, disabled: pending === undefined, onPress: () => {
144
- if (pending)
145
- onConfirm?.(pending);
146
- setOpen(false);
147
- }, children: confirmLabel })] }), ...props, children: (0, jsx_runtime_1.jsx)(exports.Calendar, { value: pending, onChange: setPending, minDate: minDate, maxDate: maxDate, isDark: isDark, initialMonth: value }) }));
148
- });
149
- /** Splits "HH:MM" into parts, falling back to a sane default. */
150
- function parseTime(value) {
151
- const match = /^(\d{1,2}):(\d{2})$/.exec(value ?? "");
152
- if (!match)
153
- return { hour: 9, minute: 0 };
154
- return {
155
- hour: Math.min(Math.max(Number(match[1]), 0), 23),
156
- minute: Math.min(Math.max(Number(match[2]), 0), 59),
157
- };
158
- }
159
- /** Formats parts back to zero-padded "HH:MM". */
160
- function formatTime(hour, minute) {
161
- return `${String(hour).padStart(2, "0")}:${String(minute).padStart(2, "0")}`;
162
- }
163
- /**
164
- * A time picker: tappable hour/minute drums inside a Sheet.
165
- *
166
- * The drums are ordinary Pressables drawn by Glacia — not a native picker
167
- * widget. Tapping a value selects it; the whole column scrolls in the Sheet.
168
- */
169
- exports.TimePicker = (0, react_1.forwardRef)(function TimePicker({ open: openProp, defaultOpen = false, onOpenChange, value, onConfirm, onCancel, use12Hour = false, title = "Select time", confirmLabel = "Confirm", cancelLabel = "Cancel", minuteStep = 1, style, isDark: isDarkProp, testID, ...props }, ref) {
170
- const isDark = (0, motion_1.useIsDark)(isDarkProp);
171
- const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
172
- const { View, Text: RNText, Pressable } = (0, primitives_1.primitives)();
173
- const [internalOpen, setInternalOpen] = (0, react_1.useState)(defaultOpen);
174
- const open = openProp !== undefined ? openProp : internalOpen;
175
- const initial = parseTime(value);
176
- const [hour, setHour] = (0, react_1.useState)(initial.hour);
177
- const [minute, setMinute] = (0, react_1.useState)(initial.minute);
178
- const setOpen = (next) => {
179
- if (openProp === undefined)
180
- setInternalOpen(next);
181
- onOpenChange?.(next);
182
- };
183
- const hours = Array.from({ length: 24 }, (_, i) => i);
184
- const minutes = Array.from({ length: Math.ceil(60 / minuteStep) }, (_, i) => i * minuteStep);
185
- // In 12-hour mode the column shows 1–12; the stored hour stays 24-hour.
186
- const displayHour = use12Hour ? (hour % 12 === 0 ? 12 : hour % 12) : hour;
187
- const isPm = hour >= 12;
188
- const column = (items, selected, onPick, label, pad = 2) => ((0, jsx_runtime_1.jsx)(View, { style: { height: 168, flex: 1 }, accessibilityRole: "none", accessibilityLabel: label, children: (0, jsx_runtime_1.jsx)(ScrollColumn, { items: items, selected: selected, onPick: onPick, isDark: isDark, pad: pad }) }));
189
- return ((0, jsx_runtime_1.jsx)(Overlays_1.Sheet, { ref: ref, open: open, onOpenChange: setOpen, title: title, isDark: isDark, testID: testID, style: style, footer: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Button_1.Button, { variant: "ghost", accessibilityLabel: cancelLabel, onPress: () => {
190
- setHour(initial.hour);
191
- setMinute(initial.minute);
192
- onCancel?.();
193
- setOpen(false);
194
- }, children: cancelLabel }), (0, jsx_runtime_1.jsx)(Button_1.Button, { variant: "filled", accessibilityLabel: confirmLabel, onPress: () => {
195
- onConfirm?.(formatTime(hour, minute));
196
- setOpen(false);
197
- }, children: confirmLabel })] }), ...props, children: (0, jsx_runtime_1.jsxs)(View, { style: { flexDirection: "row", gap: 8, alignItems: "center" }, children: [column(use12Hour ? Array.from({ length: 12 }, (_, i) => i + 1) : hours, displayHour, (picked) => {
198
- if (!use12Hour) {
199
- setHour(picked);
200
- return;
201
- }
202
- // Keep the current half of the day when the hour column changes.
203
- setHour(picked % 12 === 0 ? (isPm ? 12 : 0) : isPm ? picked + 12 : picked);
204
- }, "Hour"), (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 22, color: theme.muted }, children: ":" }), column(minutes, minute, setMinute, "Minute"), use12Hour && ((0, jsx_runtime_1.jsx)(View, { style: { flex: 1, gap: 6 }, children: ["AM", "PM"].map((label) => {
205
- const active = label === "PM" ? isPm : !isPm;
206
- return ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "button", accessibilityLabel: label, accessibilityState: { selected: active }, onPress: () => {
207
- const nextPm = label === "PM";
208
- if (nextPm === isPm)
209
- return;
210
- setHour((current) => (nextPm ? (current % 12) + 12 : current % 12));
211
- }, style: {
212
- height: 34,
213
- borderRadius: tokens_1.radii.sm,
214
- alignItems: "center",
215
- justifyContent: "center",
216
- backgroundColor: "transparent",
217
- }, children: [active ? (0, jsx_runtime_1.jsx)(lens_1.SelectedLens, { radius: tokens_1.radii.sm, isDark: isDark, style: lens_1.lensFill }) : null, (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 14, fontWeight: active ? "600" : "500", color: active ? theme.foreground : theme.muted }, children: label })] }, label));
218
- }) }))] }) }));
219
- });
220
- /** One scrollable column of the time drums. */
221
- function ScrollColumn({ items, selected, onPick, isDark, pad, }) {
222
- const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
223
- const { getScrollView } = (0, primitives_1.primitives)();
224
- const ScrollView = getScrollView();
225
- const { View, Text: RNText, Pressable } = (0, primitives_1.primitives)();
226
- const rows = items.map((item) => {
227
- const active = item === selected;
228
- return ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "button", accessibilityLabel: String(item).padStart(pad, "0"), accessibilityState: { selected: active }, onPress: () => onPick(item), style: {
229
- height: 34,
230
- alignItems: "center",
231
- justifyContent: "center",
232
- borderRadius: tokens_1.radii.sm,
233
- backgroundColor: "transparent",
234
- }, children: [active ? (0, jsx_runtime_1.jsx)(lens_1.SelectedLens, { radius: tokens_1.radii.sm, isDark: isDark, style: lens_1.lensFill }) : null, (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 17, fontWeight: active ? "600" : "400", color: active ? theme.foreground : theme.muted }, children: String(item).padStart(pad, "0") })] }, item));
235
- });
236
- if (!ScrollView) {
237
- // Off-device: no ScrollView, so the column is clipped to its height rather
238
- // than truncated. Every value stays present and selectable, which is what
239
- // the real drum shows once it can scroll.
240
- return (0, jsx_runtime_1.jsx)(View, { style: { gap: 2, overflow: "hidden", height: 168 }, children: rows });
241
- }
242
- return ((0, jsx_runtime_1.jsx)(ScrollView, { showsVerticalScrollIndicator: false, style: { flex: 1 }, children: (0, jsx_runtime_1.jsx)(View, { style: { gap: 2 }, children: rows }) }));
243
- }