glacia-native 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (403) hide show
  1. package/LICENSE +29 -4
  2. package/README.md +111 -17
  3. package/lib/module/Accordion.js +58 -0
  4. package/lib/module/ActionSheet.js +38 -0
  5. package/lib/module/Alert.js +23 -0
  6. package/lib/module/AlertDialog.js +47 -0
  7. package/lib/module/Avatar.js +48 -0
  8. package/lib/module/Badge.js +36 -0
  9. package/lib/module/Bars.js +13 -267
  10. package/lib/module/Button.js +57 -36
  11. package/lib/module/Card.js +32 -20
  12. package/lib/module/Checkbox.js +42 -0
  13. package/lib/module/Chip.js +80 -0
  14. package/lib/module/Collapsible.js +26 -0
  15. package/lib/module/ContextMenu.js +33 -0
  16. package/lib/module/Dialog.js +39 -124
  17. package/lib/module/DropdownMenu.js +33 -0
  18. package/lib/module/Field.js +22 -0
  19. package/lib/module/Glass.js +12 -5
  20. package/lib/module/Group.js +36 -0
  21. package/lib/module/IconButton.js +40 -0
  22. package/lib/module/Input.js +47 -40
  23. package/lib/module/Label.js +17 -0
  24. package/lib/module/MorphGroup.js +47 -0
  25. package/lib/module/Popover.js +29 -0
  26. package/lib/module/Progress.js +32 -0
  27. package/lib/module/RadioGroup.js +51 -0
  28. package/lib/module/Scrim.js +44 -0
  29. package/lib/module/SegmentedControl.js +74 -58
  30. package/lib/module/Select.js +51 -0
  31. package/lib/module/Separator.js +25 -0
  32. package/lib/module/Sheet.js +51 -0
  33. package/lib/module/Skeleton.js +48 -0
  34. package/lib/module/Slider.js +60 -40
  35. package/lib/module/Stepper.js +167 -0
  36. package/lib/module/Switch.js +45 -43
  37. package/lib/module/TabBar.js +62 -50
  38. package/lib/module/Tabs.js +3 -2
  39. package/lib/module/Textarea.js +18 -0
  40. package/lib/module/Toast.js +55 -0
  41. package/lib/module/Toggle.js +47 -0
  42. package/lib/module/ToggleGroup.js +56 -0
  43. package/lib/module/Toolbar.js +37 -0
  44. package/lib/module/Tooltip.js +31 -0
  45. package/lib/module/glass-provider.js +28 -0
  46. package/lib/module/glass-stack.js +61 -0
  47. package/lib/module/index.js +78 -109
  48. package/lib/module/internal/GlassBackdrop.js +36 -0
  49. package/lib/module/internal/GlassView.js +45 -13
  50. package/lib/module/internal/blur-community.js +20 -0
  51. package/lib/module/internal/blur-community.web.js +9 -0
  52. package/lib/module/internal/blur.js +75 -0
  53. package/lib/module/internal/fallback.js +110 -20
  54. package/lib/module/internal/glass-routing.js +154 -30
  55. package/lib/module/internal/glow.js +36 -0
  56. package/lib/module/internal/initials.js +12 -0
  57. package/lib/module/internal/lens.js +70 -0
  58. package/lib/module/internal/material.js +64 -0
  59. package/lib/module/internal/overlay.js +147 -0
  60. package/lib/module/internal/primitives.js +17 -0
  61. package/lib/module/internal/rim.js +35 -0
  62. package/lib/module/internal/tokens.js +34 -2
  63. package/lib/typescript/Accordion.d.ts +22 -0
  64. package/lib/typescript/ActionSheet.d.ts +24 -0
  65. package/lib/typescript/Alert.d.ts +15 -0
  66. package/lib/typescript/AlertDialog.d.ts +17 -0
  67. package/lib/typescript/Avatar.d.ts +22 -0
  68. package/lib/typescript/Badge.d.ts +12 -0
  69. package/lib/typescript/Bars.d.ts +3 -188
  70. package/lib/typescript/Button.d.ts +44 -10
  71. package/lib/typescript/Card.d.ts +30 -3
  72. package/lib/typescript/Checkbox.d.ts +14 -0
  73. package/lib/typescript/Chip.d.ts +19 -0
  74. package/lib/typescript/Collapsible.d.ts +17 -0
  75. package/lib/typescript/ContextMenu.d.ts +23 -0
  76. package/lib/typescript/Dialog.d.ts +8 -68
  77. package/lib/typescript/DropdownMenu.d.ts +23 -0
  78. package/lib/typescript/Field.d.ts +19 -0
  79. package/lib/typescript/Glass.d.ts +11 -2
  80. package/lib/typescript/Group.d.ts +35 -0
  81. package/lib/typescript/IconButton.d.ts +21 -0
  82. package/lib/typescript/Input.d.ts +17 -18
  83. package/lib/typescript/Label.d.ts +14 -0
  84. package/lib/typescript/MorphGroup.d.ts +46 -0
  85. package/lib/typescript/Popover.d.ts +17 -0
  86. package/lib/typescript/Progress.d.ts +13 -0
  87. package/lib/typescript/RadioGroup.d.ts +21 -0
  88. package/lib/typescript/Scrim.d.ts +33 -0
  89. package/lib/typescript/SegmentedControl.d.ts +24 -13
  90. package/lib/typescript/Select.d.ts +19 -0
  91. package/lib/typescript/Separator.d.ts +10 -0
  92. package/lib/typescript/Sheet.d.ts +45 -0
  93. package/lib/typescript/Skeleton.d.ts +10 -0
  94. package/lib/typescript/Slider.d.ts +15 -7
  95. package/lib/typescript/Stepper.d.ts +49 -0
  96. package/lib/typescript/Switch.d.ts +19 -12
  97. package/lib/typescript/TabBar.d.ts +18 -6
  98. package/lib/typescript/Textarea.d.ts +6 -0
  99. package/lib/typescript/Toast.d.ts +40 -0
  100. package/lib/typescript/Toggle.d.ts +21 -0
  101. package/lib/typescript/ToggleGroup.d.ts +22 -0
  102. package/lib/typescript/Toolbar.d.ts +35 -0
  103. package/lib/typescript/Tooltip.d.ts +16 -0
  104. package/lib/typescript/glass-provider.d.ts +34 -0
  105. package/lib/typescript/glass-stack.d.ts +54 -0
  106. package/lib/typescript/index.d.ts +39 -17
  107. package/lib/typescript/internal/GlassBackdrop.d.ts +33 -0
  108. package/lib/typescript/internal/GlassView.d.ts +31 -2
  109. package/lib/typescript/internal/blur-community.d.ts +2 -0
  110. package/lib/typescript/internal/blur-community.web.d.ts +2 -0
  111. package/lib/typescript/internal/blur.d.ts +24 -0
  112. package/lib/typescript/internal/fallback.d.ts +27 -2
  113. package/lib/typescript/internal/glass-routing.d.ts +83 -15
  114. package/lib/typescript/internal/glow.d.ts +11 -0
  115. package/lib/typescript/internal/initials.d.ts +2 -0
  116. package/lib/typescript/internal/lens.d.ts +47 -0
  117. package/lib/typescript/internal/material.d.ts +27 -0
  118. package/lib/typescript/internal/overlay.d.ts +74 -0
  119. package/lib/typescript/internal/primitives.d.ts +13 -0
  120. package/lib/typescript/internal/rim.d.ts +16 -0
  121. package/lib/typescript/internal/tokens.d.ts +36 -0
  122. package/package.json +15 -4
  123. package/src/Accordion.tsx +165 -0
  124. package/src/ActionSheet.tsx +149 -0
  125. package/src/Alert.tsx +85 -0
  126. package/src/AlertDialog.tsx +124 -0
  127. package/src/Avatar.tsx +102 -0
  128. package/src/Badge.tsx +80 -0
  129. package/src/Bars.tsx +10 -797
  130. package/src/Button.tsx +196 -60
  131. package/src/Card.tsx +106 -33
  132. package/src/Checkbox.tsx +98 -0
  133. package/src/Chip.tsx +149 -0
  134. package/src/Collapsible.tsx +66 -0
  135. package/src/ContextMenu.tsx +103 -0
  136. package/src/Dialog.tsx +86 -325
  137. package/src/DropdownMenu.tsx +103 -0
  138. package/src/Field.tsx +65 -0
  139. package/src/Glass.tsx +19 -5
  140. package/src/Group.tsx +98 -0
  141. package/src/IconButton.tsx +110 -0
  142. package/src/Input.tsx +143 -87
  143. package/src/Label.tsx +56 -0
  144. package/src/MorphGroup.tsx +134 -0
  145. package/src/Popover.tsx +81 -0
  146. package/src/Progress.tsx +83 -0
  147. package/src/RadioGroup.tsx +122 -0
  148. package/src/Scrim.tsx +94 -0
  149. package/src/SegmentedControl.tsx +147 -90
  150. package/src/Select.tsx +136 -0
  151. package/src/Separator.tsx +52 -0
  152. package/src/Sheet.tsx +139 -0
  153. package/src/Skeleton.tsx +77 -0
  154. package/src/Slider.tsx +100 -54
  155. package/src/Stepper.tsx +315 -0
  156. package/src/Switch.tsx +80 -58
  157. package/src/TabBar.tsx +118 -84
  158. package/src/Tabs.tsx +5 -0
  159. package/src/Textarea.tsx +34 -0
  160. package/src/Toast.tsx +131 -0
  161. package/src/Toggle.tsx +113 -0
  162. package/src/ToggleGroup.tsx +129 -0
  163. package/src/Toolbar.tsx +111 -0
  164. package/src/Tooltip.tsx +79 -0
  165. package/src/engine/CHANGELOG.md +430 -0
  166. package/src/engine/NOTICE +54 -0
  167. package/src/engine/README.md +975 -0
  168. package/src/engine/android/build.gradle +18 -0
  169. package/src/engine/android/src/main/AndroidManifest.xml +2 -0
  170. package/src/engine/android/src/main/java/expo/modules/liquidglass/ExpoLiquidGlassModule.kt +174 -0
  171. package/src/engine/android/src/main/java/expo/modules/liquidglass/GlassConstants.kt +7 -0
  172. package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassContainerView.kt +16 -0
  173. package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassProviderView.kt +165 -0
  174. package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassView.kt +1731 -0
  175. package/src/engine/android/src/main/java/expo/modules/liquidglass/enums/GlassEnums.kt +171 -0
  176. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/BackdropGraph.kt +146 -0
  177. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/BackdropSource.kt +53 -0
  178. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/ContinuousCorners.kt +188 -0
  179. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/CornerRadii.kt +62 -0
  180. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassAppearance.kt +352 -0
  181. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassDebug.kt +109 -0
  182. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassEnvironment.kt +139 -0
  183. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassHdr.kt +85 -0
  184. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassLuminanceProbe.kt +189 -0
  185. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassPressAnimator.kt +264 -0
  186. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassProgressiveBlur.kt +249 -0
  187. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassShaderCache.kt +256 -0
  188. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassShaderSource.kt +845 -0
  189. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassTier.kt +63 -0
  190. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/ProviderRegistry.kt +71 -0
  191. package/src/engine/android/src/main/java/expo/modules/liquidglass/records/GlassRecords.kt +288 -0
  192. package/src/engine/index.ts +24 -0
  193. package/src/engine/ios/Enums/GlassBlurDirection.swift +21 -0
  194. package/src/engine/ios/Enums/GlassVariant.swift +86 -0
  195. package/src/engine/ios/ExpoLiquidGlass.podspec +93 -0
  196. package/src/engine/ios/ExpoLiquidGlassModule.swift +77 -0
  197. package/src/engine/ios/Glass/BackdropCapturer.swift +811 -0
  198. package/src/engine/ios/Glass/ContinuousCorners.swift +165 -0
  199. package/src/engine/ios/Glass/GlassBackdrop.swift +176 -0
  200. package/src/engine/ios/Glass/GlassFramePhase.swift +126 -0
  201. package/src/engine/ios/Glass/GlassFrameScheduler.swift +261 -0
  202. package/src/engine/ios/Glass/GlassPressAnimator.swift +250 -0
  203. package/src/engine/ios/Glass/GlassRenderContext.swift +168 -0
  204. package/src/engine/ios/Glass/GlassRenderer.swift +186 -0
  205. package/src/engine/ios/Glass/GlassSurfaceView.swift +452 -0
  206. package/src/engine/ios/Glass/NonRenderableView.swift +54 -0
  207. package/src/engine/ios/Glass/StripCache.swift +545 -0
  208. package/src/engine/ios/Records/GlassCornerRadii.swift +79 -0
  209. package/src/engine/ios/Records/GlassMetalOptions.swift +180 -0
  210. package/src/engine/ios/Records/GlassRefractionCurve.swift +14 -0
  211. package/src/engine/ios/Shaders/LiquidGlass.metal +480 -0
  212. package/src/engine/ios/Shaders/bundle-marker.txt +6 -0
  213. package/src/engine/ios/Views/LiquidGlassContainerView.swift +99 -0
  214. package/src/engine/ios/Views/LiquidGlassView.swift +859 -0
  215. package/src/engine/package.json +70 -0
  216. package/src/engine/src/components/LiquidGlassButton/LiquidGlassButton.tsx +424 -0
  217. package/src/engine/src/components/LiquidGlassCard/LiquidGlassCard.tsx +98 -0
  218. package/src/engine/src/components/LiquidGlassChip/LiquidGlassChip.tsx +65 -0
  219. package/src/engine/src/components/LiquidGlassGroup/LiquidGlassGroup.tsx +350 -0
  220. package/src/engine/src/components/LiquidGlassIconButton/LiquidGlassIconButton.tsx +24 -0
  221. package/src/engine/src/components/LiquidGlassMorphGroup/LiquidGlassMorphGroup.tsx +434 -0
  222. package/src/engine/src/components/LiquidGlassScrim/LiquidGlassScrim.tsx +100 -0
  223. package/src/engine/src/components/LiquidGlassSegmentedControl/LiquidGlassSegmentedControl.tsx +213 -0
  224. package/src/engine/src/components/LiquidGlassSheet/LiquidGlassSheet.tsx +218 -0
  225. package/src/engine/src/components/LiquidGlassSlider/LiquidGlassSlider.tsx +327 -0
  226. package/src/engine/src/components/LiquidGlassStepper/LiquidGlassStepper.tsx +321 -0
  227. package/src/engine/src/components/LiquidGlassSwitch/LiquidGlassSwitch.tsx +296 -0
  228. package/src/engine/src/components/LiquidGlassTabBar/LiquidGlassTabBar.tsx +952 -0
  229. package/src/engine/src/components/LiquidGlassTextInput/LiquidGlassTextInput.tsx +151 -0
  230. package/src/engine/src/components/LiquidGlassToast/LiquidGlassToast.tsx +169 -0
  231. package/src/engine/src/components/LiquidGlassToolbar/LiquidGlassToolbar.tsx +124 -0
  232. package/src/engine/src/components/index.ts +16 -0
  233. package/src/engine/src/constants/index.ts +4 -0
  234. package/src/engine/src/constants/metal.constants.ts +327 -0
  235. package/src/engine/src/constants/metrics.constants.ts +325 -0
  236. package/src/engine/src/constants/springs.constants.ts +107 -0
  237. package/src/engine/src/constants/styles.constants.ts +12 -0
  238. package/src/engine/src/context/glass-group.context.ts +65 -0
  239. package/src/engine/src/context/index.ts +6 -0
  240. package/src/engine/src/core/components/LiquidGlassContainer/LiquidGlassContainer.tsx +32 -0
  241. package/src/engine/src/core/components/LiquidGlassContainer/index.ts +1 -0
  242. package/src/engine/src/core/components/LiquidGlassProvider/LiquidGlassProvider.tsx +66 -0
  243. package/src/engine/src/core/components/LiquidGlassProvider/index.ts +1 -0
  244. package/src/engine/src/core/components/LiquidGlassStack/LiquidGlassStack.tsx +184 -0
  245. package/src/engine/src/core/components/LiquidGlassStack/index.ts +1 -0
  246. package/src/engine/src/core/components/LiquidGlassView/LiquidGlassView.tsx +126 -0
  247. package/src/engine/src/core/components/LiquidGlassView/index.ts +1 -0
  248. package/src/engine/src/core/components/index.ts +4 -0
  249. package/src/engine/src/core/constants/glass.constants.ts +57 -0
  250. package/src/engine/src/core/constants/index.ts +20 -0
  251. package/src/engine/src/core/constants/native.constants.ts +16 -0
  252. package/src/engine/src/core/context/glass-stack.context.ts +30 -0
  253. package/src/engine/src/core/context/index.ts +4 -0
  254. package/src/engine/src/core/enum/index.ts +12 -0
  255. package/src/engine/src/core/index.ts +1 -0
  256. package/src/engine/src/core/interfaces/glass-hdr.interface.ts +15 -0
  257. package/src/engine/src/core/interfaces/glass-metal.interface.ts +248 -0
  258. package/src/engine/src/core/interfaces/glass-surface.interface.ts +9 -0
  259. package/src/engine/src/core/interfaces/index.ts +31 -0
  260. package/src/engine/src/core/interfaces/liquid-glass-container.interface.ts +6 -0
  261. package/src/engine/src/core/interfaces/liquid-glass-provider.interface.ts +14 -0
  262. package/src/engine/src/core/interfaces/liquid-glass-stack.interface.ts +21 -0
  263. package/src/engine/src/core/interfaces/liquid-glass-view.interface.ts +129 -0
  264. package/src/engine/src/core/interfaces/native-liquid-glass-view.interface.ts +19 -0
  265. package/src/engine/src/core/modules/ExpoLiquidGlassModule.ts +26 -0
  266. package/src/engine/src/core/modules/index.ts +2 -0
  267. package/src/engine/src/core/root/index.ts +51 -0
  268. package/src/engine/src/core/types/glass.types.ts +25 -0
  269. package/src/engine/src/core/types/index.ts +8 -0
  270. package/src/engine/src/core/utils/debug.utils.ts +17 -0
  271. package/src/engine/src/core/utils/dev-warn.utils.ts +17 -0
  272. package/src/engine/src/core/utils/hdr.utils.ts +37 -0
  273. package/src/engine/src/core/utils/index.ts +5 -0
  274. package/src/engine/src/core/utils/native-view.utils.ts +33 -0
  275. package/src/engine/src/core/utils/platform.utils.ts +34 -0
  276. package/src/engine/src/core/views/NativeGlassBackdropView.ts +24 -0
  277. package/src/engine/src/core/views/NativeLiquidGlassContainerView.ts +13 -0
  278. package/src/engine/src/core/views/NativeLiquidGlassContainerView.web.ts +10 -0
  279. package/src/engine/src/core/views/NativeLiquidGlassProviderView.ts +13 -0
  280. package/src/engine/src/core/views/NativeLiquidGlassProviderView.web.ts +10 -0
  281. package/src/engine/src/core/views/NativeLiquidGlassView.ts +19 -0
  282. package/src/engine/src/core/views/NativeLiquidGlassView.web.ts +14 -0
  283. package/src/engine/src/core/views/index.ts +4 -0
  284. package/src/engine/src/hooks/index.ts +18 -0
  285. package/src/engine/src/hooks/use-adaptive-glass.ts +91 -0
  286. package/src/engine/src/hooks/use-damped-drag.ts +332 -0
  287. package/src/engine/src/hooks/use-echo-filter.ts +55 -0
  288. package/src/engine/src/hooks/use-glass-group-member.ts +169 -0
  289. package/src/engine/src/hooks/use-gravity-highlight.ts +79 -0
  290. package/src/engine/src/hooks/use-press-progress.ts +44 -0
  291. package/src/engine/src/index.ts +120 -0
  292. package/src/engine/src/interfaces/index.ts +28 -0
  293. package/src/engine/src/interfaces/liquid-glass-button.interface.ts +94 -0
  294. package/src/engine/src/interfaces/liquid-glass-card.interface.ts +40 -0
  295. package/src/engine/src/interfaces/liquid-glass-chip.interface.ts +29 -0
  296. package/src/engine/src/interfaces/liquid-glass-group.interface.ts +32 -0
  297. package/src/engine/src/interfaces/liquid-glass-icon-button.interface.ts +19 -0
  298. package/src/engine/src/interfaces/liquid-glass-morph-group.interface.ts +59 -0
  299. package/src/engine/src/interfaces/liquid-glass-scrim.interface.ts +36 -0
  300. package/src/engine/src/interfaces/liquid-glass-segmented-control.interface.ts +32 -0
  301. package/src/engine/src/interfaces/liquid-glass-sheet.interface.ts +38 -0
  302. package/src/engine/src/interfaces/liquid-glass-slider.interface.ts +37 -0
  303. package/src/engine/src/interfaces/liquid-glass-stepper.interface.ts +35 -0
  304. package/src/engine/src/interfaces/liquid-glass-switch.interface.ts +27 -0
  305. package/src/engine/src/interfaces/liquid-glass-tab-bar.interface.ts +116 -0
  306. package/src/engine/src/interfaces/liquid-glass-text-input.interface.ts +42 -0
  307. package/src/engine/src/interfaces/liquid-glass-toast.interface.ts +36 -0
  308. package/src/engine/src/interfaces/liquid-glass-toolbar.interface.ts +33 -0
  309. package/src/engine/src/theme/glass-ui-theme.ts +100 -0
  310. package/src/engine/src/theme/index.ts +2 -0
  311. package/src/engine/src/utils/button-press.utils.ts +63 -0
  312. package/src/engine/src/utils/index.ts +3 -0
  313. package/src/engine/src/utils/metal.utils.ts +164 -0
  314. package/src/glass-provider.tsx +60 -0
  315. package/src/glass-stack.tsx +115 -0
  316. package/src/index.ts +48 -190
  317. package/src/internal/GlassBackdrop.tsx +60 -0
  318. package/src/internal/GlassView.tsx +70 -18
  319. package/src/internal/blur-community.ts +19 -0
  320. package/src/internal/blur-community.web.ts +7 -0
  321. package/src/internal/blur.ts +89 -0
  322. package/src/internal/fallback.tsx +158 -20
  323. package/src/internal/glass-routing.ts +211 -34
  324. package/src/internal/glow.tsx +62 -0
  325. package/src/internal/initials.ts +7 -0
  326. package/src/internal/lens.tsx +105 -0
  327. package/src/internal/material.ts +92 -0
  328. package/src/internal/overlay.tsx +258 -0
  329. package/src/internal/primitives.ts +26 -0
  330. package/src/internal/rim.tsx +79 -0
  331. package/src/internal/tokens.ts +34 -1
  332. package/lib/module/Carousel.js +0 -103
  333. package/lib/module/Display.js +0 -317
  334. package/lib/module/Feedback.js +0 -386
  335. package/lib/module/Form.js +0 -164
  336. package/lib/module/Forms2.js +0 -454
  337. package/lib/module/Message.js +0 -88
  338. package/lib/module/Overlays.js +0 -328
  339. package/lib/module/Pickers.js +0 -243
  340. package/lib/module/Table.js +0 -99
  341. package/lib/module/ai.js +0 -280
  342. package/lib/module/charts/AreaChart.js +0 -32
  343. package/lib/module/charts/BarChart.js +0 -67
  344. package/lib/module/charts/FunnelChart.js +0 -50
  345. package/lib/module/charts/HeatmapChart.js +0 -71
  346. package/lib/module/charts/LineChart.js +0 -81
  347. package/lib/module/charts/PlotChart.js +0 -52
  348. package/lib/module/charts/RadarChart.js +0 -78
  349. package/lib/module/charts/RingChart.js +0 -52
  350. package/lib/module/charts/ScatterChart.js +0 -95
  351. package/lib/module/charts/WaterfallChart.js +0 -85
  352. package/lib/module/charts/advanced.js +0 -313
  353. package/lib/module/charts/extra.js +0 -108
  354. package/lib/module/charts/index.js +0 -50
  355. package/lib/module/charts/scales.js +0 -140
  356. package/lib/typescript/Carousel.d.ts +0 -47
  357. package/lib/typescript/Display.d.ts +0 -178
  358. package/lib/typescript/Feedback.d.ts +0 -196
  359. package/lib/typescript/Form.d.ts +0 -97
  360. package/lib/typescript/Forms2.d.ts +0 -209
  361. package/lib/typescript/Message.d.ts +0 -71
  362. package/lib/typescript/Overlays.d.ts +0 -146
  363. package/lib/typescript/Pickers.d.ts +0 -105
  364. package/lib/typescript/Table.d.ts +0 -64
  365. package/lib/typescript/ai.d.ts +0 -166
  366. package/lib/typescript/charts/AreaChart.d.ts +0 -44
  367. package/lib/typescript/charts/BarChart.d.ts +0 -19
  368. package/lib/typescript/charts/FunnelChart.d.ts +0 -25
  369. package/lib/typescript/charts/HeatmapChart.d.ts +0 -23
  370. package/lib/typescript/charts/LineChart.d.ts +0 -30
  371. package/lib/typescript/charts/PlotChart.d.ts +0 -31
  372. package/lib/typescript/charts/RadarChart.d.ts +0 -27
  373. package/lib/typescript/charts/RingChart.d.ts +0 -28
  374. package/lib/typescript/charts/ScatterChart.d.ts +0 -34
  375. package/lib/typescript/charts/WaterfallChart.d.ts +0 -22
  376. package/lib/typescript/charts/advanced.d.ts +0 -107
  377. package/lib/typescript/charts/extra.d.ts +0 -63
  378. package/lib/typescript/charts/index.d.ts +0 -13
  379. package/lib/typescript/charts/scales.d.ts +0 -35
  380. package/src/Carousel.tsx +0 -233
  381. package/src/Display.tsx +0 -778
  382. package/src/Feedback.tsx +0 -969
  383. package/src/Form.tsx +0 -425
  384. package/src/Forms2.tsx +0 -1014
  385. package/src/Message.tsx +0 -219
  386. package/src/Overlays.tsx +0 -685
  387. package/src/Pickers.tsx +0 -590
  388. package/src/Table.tsx +0 -231
  389. package/src/ai.tsx +0 -707
  390. package/src/charts/AreaChart.tsx +0 -73
  391. package/src/charts/BarChart.tsx +0 -183
  392. package/src/charts/FunnelChart.tsx +0 -125
  393. package/src/charts/HeatmapChart.tsx +0 -155
  394. package/src/charts/LineChart.tsx +0 -247
  395. package/src/charts/PlotChart.tsx +0 -168
  396. package/src/charts/RadarChart.tsx +0 -208
  397. package/src/charts/RingChart.tsx +0 -133
  398. package/src/charts/ScatterChart.tsx +0 -223
  399. package/src/charts/WaterfallChart.tsx +0 -201
  400. package/src/charts/advanced.tsx +0 -676
  401. package/src/charts/extra.tsx +0 -242
  402. package/src/charts/index.ts +0 -86
  403. package/src/charts/scales.ts +0 -163
@@ -1,328 +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", isDark: isDark, testID: testID ? `${testID}-popover` : undefined, style: { width, borderRadius: tokens_1.radii.md, paddingVertical: 4, overflow: "hidden", ...style }, 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: () => {
73
- setOpen(false);
74
- item.onPress();
75
- }, style: { flexDirection: "row", alignItems: "center", gap: 10, paddingVertical: 10, 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}`))) }));
76
- 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) }) }) }) })] }));
77
- });
78
- /** Wraps a popover in the entrance scale, which must land on an Animated.View. */
79
- function AnimatedScale({ scale, children }) {
80
- const { Animated } = (0, primitives_1.primitives)();
81
- return (0, jsx_runtime_1.jsx)(Animated.View, { style: { transform: [{ scale }] }, children: children });
82
- }
83
- /**
84
- * A bottom sheet.
85
- *
86
- * The general-purpose container: it slides up on the springs token, dismisses
87
- * on a scrim press and on Android back. ActionSheet remains the action-menu
88
- * specialisation of this shape; Sheet is for arbitrary content — a form, a
89
- * calendar, a detail panel.
90
- */
91
- /**
92
- * Turns a snap point into a pixel height.
93
- *
94
- * A number under 1 is a fraction of the window; anything else is points. The
95
- * result is clamped so a sheet can never be taller than the space it has.
96
- */
97
- function resolveSnapPoint(point, windowHeight) {
98
- const height = point > 0 && point < 1 ? point * windowHeight : point;
99
- return Math.max(0, Math.min(height, windowHeight));
100
- }
101
- /**
102
- * Picks the snap point nearest to where the user let go.
103
- *
104
- * `height` is how tall the sheet currently is. Ties go to the smaller sheet,
105
- * so a small flick does not jump the panel to full height.
106
- */
107
- function nearestSnapPoint(heights, height) {
108
- let best = 0;
109
- let bestDistance = Number.POSITIVE_INFINITY;
110
- heights.forEach((candidate, index) => {
111
- const distance = Math.abs(candidate - height);
112
- if (distance < bestDistance) {
113
- bestDistance = distance;
114
- best = index;
115
- }
116
- });
117
- return best;
118
- }
119
- 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) {
120
- const isDark = (0, motion_1.useIsDark)(isDarkProp);
121
- const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
122
- const { View, Text: RNText, Pressable, Modal, PanResponder, useWindowDimensions } = (0, primitives_1.primitives)();
123
- const [internalOpen, setInternalOpen] = (0, react_1.useState)(defaultOpen);
124
- const open = openProp !== undefined ? openProp : internalOpen;
125
- const setOpen = (0, react_1.useCallback)((next) => {
126
- if (openProp === undefined)
127
- setInternalOpen(next);
128
- onOpenChange?.(next);
129
- }, [openProp, onOpenChange]);
130
- const dismiss = (0, react_1.useCallback)(() => setOpen(false), [setOpen]);
131
- useBackDismiss(open, dismiss);
132
- // Snap points in pixels, smallest first so index 0 is the shortest sheet.
133
- const windowHeight = useWindowDimensions?.().height ?? 800;
134
- const heights = (0, react_1.useMemo)(() => {
135
- if (!snapPoints || snapPoints.length === 0)
136
- return [];
137
- return snapPoints.map((point) => resolveSnapPoint(point, windowHeight)).sort((a, b) => a - b);
138
- }, [snapPoints, windowHeight]);
139
- const [internalSnap, setInternalSnap] = (0, react_1.useState)(initialSnapIndex);
140
- const snapIndex = snapIndexProp !== undefined ? snapIndexProp : internalSnap;
141
- const activeHeight = heights.length > 0 ? heights[Math.min(snapIndex, heights.length - 1)] : null;
142
- // Drag offset in pixels: 0 is resting at the active snap point, positive is
143
- // dragged down. It resets to 0 after a release, because the settle either
144
- // changes the snap index or dismisses.
145
- const dragRef = (0, react_1.useRef)(0);
146
- const [drag, setDrag] = (0, react_1.useState)(0);
147
- const { value: rise, animated } = (0, motion_1.useSpring)(open ? 1 : 0, "gentle");
148
- const slideIn = animated ? rise.interpolate({ inputRange: [0, 1], outputRange: [420, 0] }) : 0;
149
- const heightsRef = (0, react_1.useRef)(heights);
150
- heightsRef.current = heights;
151
- const activeHeightRef = (0, react_1.useRef)(activeHeight);
152
- activeHeightRef.current = activeHeight;
153
- const snapIndexRef = (0, react_1.useRef)(snapIndex);
154
- snapIndexRef.current = snapIndex;
155
- const goToSnap = (0, react_1.useCallback)((index) => {
156
- if (snapIndexProp === undefined)
157
- setInternalSnap(index);
158
- onSnapIndexChange?.(index);
159
- if (haptics)
160
- (0, haptics_1.hapticSelection)();
161
- }, [snapIndexProp, onSnapIndexChange, haptics]);
162
- /**
163
- * The release decision.
164
- *
165
- * Below the lowest snap point the sheet dismisses when allowed, otherwise it
166
- * snaps back; anywhere else it settles at the nearest point, with a fast
167
- * downward flick counting as a step towards the smaller sheet.
168
- */
169
- const release = (0, react_1.useCallback)((dy, vy) => {
170
- const list = heightsRef.current;
171
- const current = list[snapIndexRef.current] ?? activeHeightRef.current ?? 0;
172
- const restingAfterDrag = current - dy;
173
- if (list.length === 0) {
174
- // No snap points: a decisive downward drag dismisses.
175
- if (dy > 120 || vy > 0.8)
176
- dismiss();
177
- return;
178
- }
179
- const lowest = list[0];
180
- const belowLowest = restingAfterDrag < lowest - 40;
181
- if (belowLowest && dismissOnSnapToBottom) {
182
- dismiss();
183
- return;
184
- }
185
- // A fast flick moves one step in its direction before distance decides.
186
- let index = nearestSnapPoint(list, restingAfterDrag);
187
- if (vy > 0.5)
188
- index = Math.max(0, Math.min(index, snapIndexRef.current - 1));
189
- if (vy < -0.5)
190
- index = Math.max(index, Math.min(snapIndexRef.current + 1, list.length - 1));
191
- if (index !== snapIndexRef.current)
192
- goToSnap(index);
193
- }, [dismiss, dismissOnSnapToBottom, goToSnap]);
194
- const panResponder = (0, react_1.useMemo)(() => {
195
- if (!draggable || !PanResponder?.create)
196
- return null;
197
- return PanResponder.create({
198
- // Vertical drags belong to the sheet; horizontal ones are left alone.
199
- onStartShouldSetPanResponder: () => false,
200
- onMoveShouldSetPanResponder: (_event, gesture) => Math.abs(gesture.dy) > Math.abs(gesture.dx) && Math.abs(gesture.dy) > 6,
201
- onPanResponderGrant: () => {
202
- dragRef.current = 0;
203
- },
204
- onPanResponderMove: (_event, gesture) => {
205
- // Dragging up past the tallest point has nowhere to go; clamp at 0.
206
- const next = Math.max(-40, gesture.dy);
207
- dragRef.current = next;
208
- setDrag(next);
209
- },
210
- onPanResponderRelease: (_event, gesture) => {
211
- release(gesture.dy, gesture.vy);
212
- dragRef.current = 0;
213
- setDrag(0);
214
- },
215
- onPanResponderTerminate: () => {
216
- dragRef.current = 0;
217
- setDrag(0);
218
- },
219
- onPanResponderTerminationRequest: () => false,
220
- });
221
- }, [draggable, PanResponder, release]);
222
- // Reduce Motion is honoured by useSpring: when it is on, `animated` is false
223
- // and the panel is already in position, so the sheet opens and snaps without
224
- // a transition.
225
- const translateY = drag !== 0 ? drag : animated ? slideIn : 0;
226
- const panel = ((0, jsx_runtime_1.jsx)(SheetPanel, { title: title, footer: footer, showHandle: showHandle, isDark: isDark, testID: testID, style: style, height: activeHeight, children: children }));
227
- 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) }) }) }));
228
- });
229
- function SheetRise({ translateY, children }) {
230
- const { Animated } = (0, primitives_1.primitives)();
231
- return (0, jsx_runtime_1.jsx)(Animated.View, { style: { transform: [{ translateY }] }, children: children });
232
- }
233
- /** The panel itself: a glass surface with a handle, a title and a footer. */
234
- function SheetPanel({ title, footer, showHandle, isDark, testID, style, height, children, }) {
235
- const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
236
- const { View, Text: RNText } = (0, primitives_1.primitives)();
237
- return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { effect: "regular", isDark: isDark, testID: testID, style: {
238
- borderTopLeftRadius: tokens_1.radii.xl,
239
- borderTopRightRadius: tokens_1.radii.xl,
240
- borderBottomLeftRadius: 0,
241
- borderBottomRightRadius: 0,
242
- paddingBottom: 20,
243
- // A snap point fixes the height; without one the panel is natural.
244
- ...(height != null ? { height } : { maxHeight: 560 }),
245
- ...style,
246
- }, children: [showHandle ? ((0, jsx_runtime_1.jsx)(View, { style: { alignItems: "center", paddingTop: 8, paddingBottom: 4 }, children: (0, jsx_runtime_1.jsx)(View, { accessibilityElementsHidden: true,
247
- // A capsule: the radius is half the handle's own height.
248
- style: { width: 36, height: 5, borderRadius: 5 / 2, backgroundColor: theme.separator } }) })) : null, title ? ((0, jsx_runtime_1.jsx)(View, { style: { paddingHorizontal: 20, 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: 20 }, children: children }), footer ? (0, jsx_runtime_1.jsx)(View, { style: { paddingHorizontal: 20, paddingTop: 12, gap: 8 }, children: footer }) : null] }));
249
- }
250
- /**
251
- * A side navigation drawer.
252
- *
253
- * The same overlay discipline as Sheet — scrim, spring slide, Android back —
254
- * but anchored to a side edge, with a square panel that runs the full height.
255
- * The caller supplies the content, typically a List.
256
- *
257
- * Dragging the panel towards its own edge follows the finger; releasing past
258
- * the halfway point, or with enough outward velocity, closes it, and a drag
259
- * that stays inside springs it back open. Reduce Motion is honoured: with it
260
- * on, the drawer appears and disappears without sliding.
261
- */
262
- 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) {
263
- const isDark = (0, motion_1.useIsDark)(isDarkProp);
264
- const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
265
- const { View, Pressable, Modal, PanResponder } = (0, primitives_1.primitives)();
266
- const [internalOpen, setInternalOpen] = (0, react_1.useState)(defaultOpen);
267
- const open = openProp !== undefined ? openProp : internalOpen;
268
- const setOpen = (0, react_1.useCallback)((next) => {
269
- if (openProp === undefined)
270
- setInternalOpen(next);
271
- onOpenChange?.(next);
272
- }, [openProp, onOpenChange]);
273
- const dismiss = (0, react_1.useCallback)(() => setOpen(false), [setOpen]);
274
- useBackDismiss(open, dismiss);
275
- const { value: slide, animated } = (0, motion_1.useSpring)(open ? 1 : 0, "gentle");
276
- // Slide in from off-screen: negative from the left, positive from the right.
277
- const slideIn = animated
278
- ? slide.interpolate({ inputRange: [0, 1], outputRange: [side === "left" ? -width : width, 0] })
279
- : 0;
280
- // The drag is measured in the drawer's own closing direction, so a drag
281
- // towards the anchored edge is always positive whichever side it is on.
282
- const [drag, setDrag] = (0, react_1.useState)(0);
283
- const panResponder = (0, react_1.useMemo)(() => {
284
- if (!draggable || !PanResponder?.create)
285
- return null;
286
- const outward = side === "left" ? -1 : 1;
287
- return PanResponder.create({
288
- onStartShouldSetPanResponder: () => false,
289
- onMoveShouldSetPanResponder: (_event, gesture) =>
290
- // Only a horizontal drag towards the edge is ours; the other way has
291
- // nowhere to go and should not fight content inside the panel.
292
- Math.abs(gesture.dx) > Math.abs(gesture.dy) && gesture.dx * outward > 6,
293
- onPanResponderMove: (_event, gesture) => {
294
- setDrag(Math.max(0, gesture.dx * outward));
295
- },
296
- onPanResponderRelease: (_event, gesture) => {
297
- const travelled = Math.max(0, gesture.dx * outward);
298
- const thrown = gesture.vx * outward > 0.4;
299
- setDrag(0);
300
- if (travelled > width / 2 || thrown) {
301
- if (haptics)
302
- (0, haptics_1.hapticSelection)();
303
- dismiss();
304
- }
305
- },
306
- onPanResponderTerminate: () => setDrag(0),
307
- onPanResponderTerminationRequest: () => false,
308
- });
309
- // `dismiss` is stable; the gesture only needs rebuilding when its shape
310
- // (side or width) changes.
311
- }, [draggable, PanResponder, side, width, haptics, dismiss]);
312
- const translateX = drag !== 0 ? (side === "left" ? -drag : drag) : animated ? slideIn : 0;
313
- const panel = ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { effect: "regular", isDark: isDark, testID: testID, style: {
314
- width,
315
- height: "100%",
316
- borderRadius: 0,
317
- paddingTop: 56,
318
- ...style,
319
- }, children: children }));
320
- 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: {
321
- flex: 1,
322
- alignItems: side === "left" ? "flex-start" : "flex-end",
323
- }, 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 }) }) }) }));
324
- });
325
- function DrawerSlide({ translateX, children }) {
326
- const { Animated } = (0, primitives_1.primitives)();
327
- return (0, jsx_runtime_1.jsx)(Animated.View, { style: { height: "100%", transform: [{ translateX }] }, children: children });
328
- }
@@ -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
- // ---------------------------------------------------------------------------
17
- // Date helpers
18
- //
19
- // Kept pure and exported so a caller (and the tests) can reason about the same
20
- // calendar maths the grid uses. Dates are compared by day, never by instant,
21
- // which is the bug that makes a picker select "yesterday" near midnight.
22
- /** Midnight on the same calendar day, so two picks compare equal. */
23
- function startOfDay(date) {
24
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
25
- }
26
- function sameDay(a, b) {
27
- if (!a || !b)
28
- return false;
29
- return (a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate());
30
- }
31
- /**
32
- * The six-row month grid.
33
- *
34
- * Always six rows so the calendar does not change height as months change,
35
- * which would make the surrounding layout jump between February and March.
36
- */
37
- function monthGrid(year, month, weekStartsOn = 0) {
38
- const first = new Date(year, month, 1);
39
- // getDay() is 0 for Sunday; the offset is how many leading cells to add.
40
- const offset = (first.getDay() - weekStartsOn + 7) % 7;
41
- const cells = [];
42
- for (let i = 0; i < 42; i += 1) {
43
- const date = new Date(year, month, 1 - offset + i);
44
- cells.push({
45
- date,
46
- outside: date.getMonth() !== month,
47
- key: `${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`,
48
- });
49
- }
50
- return cells;
51
- }
52
- exports.WEEKDAYS = ["S", "M", "T", "W", "T", "F", "S"];
53
- exports.MONTHS = [
54
- "January",
55
- "February",
56
- "March",
57
- "April",
58
- "May",
59
- "June",
60
- "July",
61
- "August",
62
- "September",
63
- "October",
64
- "November",
65
- "December",
66
- ];
67
- /**
68
- * A month calendar, built from Glacia's own views.
69
- *
70
- * No native date picker anywhere: the grid, the weekday header and the month
71
- * navigation are ours, so the calendar looks the same on iOS and Android and
72
- * wears the library's tokens. The selected day is a `glassActive` fill, today
73
- * carries a ring, and disabled days are dimmed.
74
- */
75
- exports.Calendar = (0, react_1.forwardRef)(function Calendar({ value, onChange, minDate, maxDate, initialMonth, weekStartsOn = 0, style, isDark: isDarkProp, testID, ...props }, ref) {
76
- const isDark = (0, motion_1.useIsDark)(isDarkProp);
77
- const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
78
- const { View, Text: RNText, Pressable } = (0, primitives_1.primitives)();
79
- const anchor = value ?? initialMonth ?? new Date();
80
- const [month, setMonth] = (0, react_1.useState)({ year: anchor.getFullYear(), month: anchor.getMonth() });
81
- const cells = (0, react_1.useMemo)(() => monthGrid(month.year, month.month, weekStartsOn), [month, weekStartsOn]);
82
- const today = startOfDay(new Date());
83
- const isDisabled = (date) => {
84
- const day = startOfDay(date);
85
- if (minDate && day < startOfDay(minDate))
86
- return true;
87
- if (maxDate && day > startOfDay(maxDate))
88
- return true;
89
- return false;
90
- };
91
- const shift = (delta) => {
92
- setMonth((current) => {
93
- const next = new Date(current.year, current.month + delta, 1);
94
- return { year: next.getFullYear(), month: next.getMonth() };
95
- });
96
- };
97
- const cellSize = 38;
98
- 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) => {
99
- const selected = sameDay(cell.date, value);
100
- const isToday = sameDay(cell.date, today);
101
- const disabled = isDisabled(cell.date);
102
- return ((0, jsx_runtime_1.jsx)(View, { style: { flex: 1, alignItems: "center", paddingVertical: 2 }, children: (0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: cell.date.toDateString(), accessibilityState: { selected, disabled }, disabled: disabled, onPress: () => onChange?.(startOfDay(cell.date)), style: {
103
- width: cellSize,
104
- height: cellSize,
105
- borderRadius: cellSize / 2,
106
- alignItems: "center",
107
- justifyContent: "center",
108
- backgroundColor: selected ? theme.glassActive : "transparent",
109
- borderWidth: isToday && !selected ? 0.5 : selected ? 1 : 0,
110
- borderColor: isToday && !selected ? theme.fill : theme.edge,
111
- opacity: disabled ? 0.28 : cell.outside ? 0.45 : 1,
112
- }, children: (0, jsx_runtime_1.jsx)(RNText, { style: {
113
- fontSize: 14,
114
- fontWeight: selected ? "600" : "400",
115
- color: selected ? theme.foreground : theme.foreground,
116
- }, children: String(cell.date.getDate()) }) }) }, cell.key));
117
- }) }, row)))] }));
118
- });
119
- /**
120
- * A date picker: the Calendar presented in a Sheet.
121
- *
122
- * Browsing months does not commit anything — the pending date is local until
123
- * the user confirms, so an accidental swipe of the calendar cannot change a
124
- * saved value.
125
- */
126
- 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) {
127
- const isDark = (0, motion_1.useIsDark)(isDarkProp);
128
- const [internalOpen, setInternalOpen] = (0, react_1.useState)(defaultOpen);
129
- const open = openProp !== undefined ? openProp : internalOpen;
130
- const [pending, setPending] = (0, react_1.useState)(value);
131
- const setOpen = (next) => {
132
- if (openProp === undefined)
133
- setInternalOpen(next);
134
- onOpenChange?.(next);
135
- };
136
- 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: () => {
137
- // Cancelling restores the committed value for the next open.
138
- setPending(value);
139
- onCancel?.();
140
- setOpen(false);
141
- }, children: cancelLabel }), (0, jsx_runtime_1.jsx)(Button_1.Button, { variant: "filled", accessibilityLabel: confirmLabel, disabled: pending === undefined, onPress: () => {
142
- if (pending)
143
- onConfirm?.(pending);
144
- setOpen(false);
145
- }, children: confirmLabel })] }), ...props, children: (0, jsx_runtime_1.jsx)(exports.Calendar, { value: pending, onChange: setPending, minDate: minDate, maxDate: maxDate, isDark: isDark, initialMonth: value }) }));
146
- });
147
- /** Splits "HH:MM" into parts, falling back to a sane default. */
148
- function parseTime(value) {
149
- const match = /^(\d{1,2}):(\d{2})$/.exec(value ?? "");
150
- if (!match)
151
- return { hour: 9, minute: 0 };
152
- return {
153
- hour: Math.min(Math.max(Number(match[1]), 0), 23),
154
- minute: Math.min(Math.max(Number(match[2]), 0), 59),
155
- };
156
- }
157
- /** Formats parts back to zero-padded "HH:MM". */
158
- function formatTime(hour, minute) {
159
- return `${String(hour).padStart(2, "0")}:${String(minute).padStart(2, "0")}`;
160
- }
161
- /**
162
- * A time picker: tappable hour/minute drums inside a Sheet.
163
- *
164
- * The drums are ordinary Pressables drawn by Glacia — not a native picker
165
- * widget. Tapping a value selects it; the whole column scrolls in the Sheet.
166
- */
167
- 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) {
168
- const isDark = (0, motion_1.useIsDark)(isDarkProp);
169
- const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
170
- const { View, Text: RNText, Pressable } = (0, primitives_1.primitives)();
171
- const [internalOpen, setInternalOpen] = (0, react_1.useState)(defaultOpen);
172
- const open = openProp !== undefined ? openProp : internalOpen;
173
- const initial = parseTime(value);
174
- const [hour, setHour] = (0, react_1.useState)(initial.hour);
175
- const [minute, setMinute] = (0, react_1.useState)(initial.minute);
176
- const setOpen = (next) => {
177
- if (openProp === undefined)
178
- setInternalOpen(next);
179
- onOpenChange?.(next);
180
- };
181
- const hours = Array.from({ length: 24 }, (_, i) => i);
182
- const minutes = Array.from({ length: Math.ceil(60 / minuteStep) }, (_, i) => i * minuteStep);
183
- // In 12-hour mode the column shows 1–12; the stored hour stays 24-hour.
184
- const displayHour = use12Hour ? (hour % 12 === 0 ? 12 : hour % 12) : hour;
185
- const isPm = hour >= 12;
186
- 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 }) }));
187
- 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: () => {
188
- setHour(initial.hour);
189
- setMinute(initial.minute);
190
- onCancel?.();
191
- setOpen(false);
192
- }, children: cancelLabel }), (0, jsx_runtime_1.jsx)(Button_1.Button, { variant: "filled", accessibilityLabel: confirmLabel, onPress: () => {
193
- onConfirm?.(formatTime(hour, minute));
194
- setOpen(false);
195
- }, 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) => {
196
- if (!use12Hour) {
197
- setHour(picked);
198
- return;
199
- }
200
- // Keep the current half of the day when the hour column changes.
201
- setHour(picked % 12 === 0 ? (isPm ? 12 : 0) : isPm ? picked + 12 : picked);
202
- }, "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) => {
203
- const active = label === "PM" ? isPm : !isPm;
204
- return ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: label, accessibilityState: { selected: active }, onPress: () => {
205
- const nextPm = label === "PM";
206
- if (nextPm === isPm)
207
- return;
208
- setHour((current) => (nextPm ? (current % 12) + 12 : current % 12));
209
- }, style: {
210
- height: 34,
211
- borderRadius: tokens_1.radii.sm,
212
- alignItems: "center",
213
- justifyContent: "center",
214
- backgroundColor: active ? theme.glassActive : "transparent",
215
- borderWidth: 0.5,
216
- borderColor: active ? theme.edge : "transparent",
217
- }, children: (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.jsx)(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: active ? theme.glassActive : "transparent",
234
- }, children: (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
- }