glacia-native 0.5.2 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (381) hide show
  1. package/README.md +84 -17
  2. package/lib/module/Accordion.js +58 -0
  3. package/lib/module/ActionSheet.js +38 -0
  4. package/lib/module/Alert.js +23 -0
  5. package/lib/module/AlertDialog.js +47 -0
  6. package/lib/module/Avatar.js +48 -0
  7. package/lib/module/Badge.js +36 -0
  8. package/lib/module/Bars.js +13 -268
  9. package/lib/module/Button.js +57 -39
  10. package/lib/module/Card.js +31 -19
  11. package/lib/module/Checkbox.js +42 -0
  12. package/lib/module/Chip.js +80 -0
  13. package/lib/module/Collapsible.js +26 -0
  14. package/lib/module/ContextMenu.js +33 -0
  15. package/lib/module/Dialog.js +39 -123
  16. package/lib/module/DropdownMenu.js +33 -0
  17. package/lib/module/Field.js +22 -0
  18. package/lib/module/Glass.js +10 -3
  19. package/lib/module/Group.js +36 -0
  20. package/lib/module/IconButton.js +40 -0
  21. package/lib/module/Input.js +43 -38
  22. package/lib/module/Label.js +17 -0
  23. package/lib/module/MorphGroup.js +47 -0
  24. package/lib/module/Popover.js +29 -0
  25. package/lib/module/Progress.js +32 -0
  26. package/lib/module/RadioGroup.js +51 -0
  27. package/lib/module/Scrim.js +44 -0
  28. package/lib/module/SegmentedControl.js +70 -63
  29. package/lib/module/Select.js +51 -0
  30. package/lib/module/Separator.js +25 -0
  31. package/lib/module/Sheet.js +51 -0
  32. package/lib/module/Skeleton.js +48 -0
  33. package/lib/module/Slider.js +45 -34
  34. package/lib/module/Stepper.js +167 -0
  35. package/lib/module/Switch.js +45 -55
  36. package/lib/module/TabBar.js +50 -44
  37. package/lib/module/Textarea.js +18 -0
  38. package/lib/module/Toast.js +55 -0
  39. package/lib/module/Toggle.js +47 -0
  40. package/lib/module/ToggleGroup.js +56 -0
  41. package/lib/module/Toolbar.js +37 -0
  42. package/lib/module/Tooltip.js +31 -0
  43. package/lib/module/glass-provider.js +28 -0
  44. package/lib/module/glass-stack.js +61 -0
  45. package/lib/module/index.js +78 -109
  46. package/lib/module/internal/GlassBackdrop.js +36 -0
  47. package/lib/module/internal/GlassView.js +43 -11
  48. package/lib/module/internal/blur-community.js +20 -0
  49. package/lib/module/internal/blur-community.web.js +9 -0
  50. package/lib/module/internal/blur.js +6 -9
  51. package/lib/module/internal/glass-routing.js +154 -30
  52. package/lib/module/internal/initials.js +12 -0
  53. package/lib/module/internal/overlay.js +147 -0
  54. package/lib/module/internal/primitives.js +16 -0
  55. package/lib/typescript/Accordion.d.ts +22 -0
  56. package/lib/typescript/ActionSheet.d.ts +24 -0
  57. package/lib/typescript/Alert.d.ts +15 -0
  58. package/lib/typescript/AlertDialog.d.ts +17 -0
  59. package/lib/typescript/Avatar.d.ts +22 -0
  60. package/lib/typescript/Badge.d.ts +12 -0
  61. package/lib/typescript/Bars.d.ts +3 -188
  62. package/lib/typescript/Button.d.ts +44 -10
  63. package/lib/typescript/Card.d.ts +30 -3
  64. package/lib/typescript/Checkbox.d.ts +14 -0
  65. package/lib/typescript/Chip.d.ts +19 -0
  66. package/lib/typescript/Collapsible.d.ts +17 -0
  67. package/lib/typescript/ContextMenu.d.ts +23 -0
  68. package/lib/typescript/Dialog.d.ts +8 -68
  69. package/lib/typescript/DropdownMenu.d.ts +23 -0
  70. package/lib/typescript/Field.d.ts +19 -0
  71. package/lib/typescript/Glass.d.ts +11 -2
  72. package/lib/typescript/Group.d.ts +35 -0
  73. package/lib/typescript/IconButton.d.ts +21 -0
  74. package/lib/typescript/Input.d.ts +17 -18
  75. package/lib/typescript/Label.d.ts +14 -0
  76. package/lib/typescript/MorphGroup.d.ts +46 -0
  77. package/lib/typescript/Popover.d.ts +17 -0
  78. package/lib/typescript/Progress.d.ts +13 -0
  79. package/lib/typescript/RadioGroup.d.ts +21 -0
  80. package/lib/typescript/Scrim.d.ts +33 -0
  81. package/lib/typescript/SegmentedControl.d.ts +24 -13
  82. package/lib/typescript/Select.d.ts +19 -0
  83. package/lib/typescript/Separator.d.ts +10 -0
  84. package/lib/typescript/Sheet.d.ts +45 -0
  85. package/lib/typescript/Skeleton.d.ts +10 -0
  86. package/lib/typescript/Slider.d.ts +15 -7
  87. package/lib/typescript/Stepper.d.ts +49 -0
  88. package/lib/typescript/Switch.d.ts +19 -12
  89. package/lib/typescript/TabBar.d.ts +18 -6
  90. package/lib/typescript/Textarea.d.ts +6 -0
  91. package/lib/typescript/Toast.d.ts +40 -0
  92. package/lib/typescript/Toggle.d.ts +21 -0
  93. package/lib/typescript/ToggleGroup.d.ts +22 -0
  94. package/lib/typescript/Toolbar.d.ts +35 -0
  95. package/lib/typescript/Tooltip.d.ts +16 -0
  96. package/lib/typescript/glass-provider.d.ts +34 -0
  97. package/lib/typescript/glass-stack.d.ts +54 -0
  98. package/lib/typescript/index.d.ts +38 -17
  99. package/lib/typescript/internal/GlassBackdrop.d.ts +33 -0
  100. package/lib/typescript/internal/GlassView.d.ts +18 -2
  101. package/lib/typescript/internal/blur-community.d.ts +2 -0
  102. package/lib/typescript/internal/blur-community.web.d.ts +2 -0
  103. package/lib/typescript/internal/glass-routing.d.ts +83 -15
  104. package/lib/typescript/internal/initials.d.ts +2 -0
  105. package/lib/typescript/internal/overlay.d.ts +74 -0
  106. package/lib/typescript/internal/primitives.d.ts +11 -0
  107. package/package.json +4 -2
  108. package/src/Accordion.tsx +165 -0
  109. package/src/ActionSheet.tsx +149 -0
  110. package/src/Alert.tsx +85 -0
  111. package/src/AlertDialog.tsx +124 -0
  112. package/src/Avatar.tsx +102 -0
  113. package/src/Badge.tsx +80 -0
  114. package/src/Bars.tsx +10 -807
  115. package/src/Button.tsx +196 -67
  116. package/src/Card.tsx +105 -32
  117. package/src/Checkbox.tsx +98 -0
  118. package/src/Chip.tsx +149 -0
  119. package/src/Collapsible.tsx +66 -0
  120. package/src/ContextMenu.tsx +103 -0
  121. package/src/Dialog.tsx +85 -335
  122. package/src/DropdownMenu.tsx +103 -0
  123. package/src/Field.tsx +65 -0
  124. package/src/Glass.tsx +15 -5
  125. package/src/Group.tsx +98 -0
  126. package/src/IconButton.tsx +110 -0
  127. package/src/Input.tsx +139 -87
  128. package/src/Label.tsx +56 -0
  129. package/src/MorphGroup.tsx +134 -0
  130. package/src/Popover.tsx +81 -0
  131. package/src/Progress.tsx +83 -0
  132. package/src/RadioGroup.tsx +122 -0
  133. package/src/Scrim.tsx +94 -0
  134. package/src/SegmentedControl.tsx +132 -99
  135. package/src/Select.tsx +136 -0
  136. package/src/Separator.tsx +52 -0
  137. package/src/Sheet.tsx +139 -0
  138. package/src/Skeleton.tsx +77 -0
  139. package/src/Slider.tsx +84 -47
  140. package/src/Stepper.tsx +315 -0
  141. package/src/Switch.tsx +81 -73
  142. package/src/TabBar.tsx +106 -93
  143. package/src/Textarea.tsx +34 -0
  144. package/src/Toast.tsx +131 -0
  145. package/src/Toggle.tsx +113 -0
  146. package/src/ToggleGroup.tsx +129 -0
  147. package/src/Toolbar.tsx +111 -0
  148. package/src/Tooltip.tsx +79 -0
  149. package/src/engine/CHANGELOG.md +430 -0
  150. package/src/engine/NOTICE +54 -0
  151. package/src/engine/README.md +975 -0
  152. package/src/engine/android/build.gradle +18 -0
  153. package/src/engine/android/src/main/AndroidManifest.xml +2 -0
  154. package/src/engine/android/src/main/java/expo/modules/liquidglass/ExpoLiquidGlassModule.kt +174 -0
  155. package/src/engine/android/src/main/java/expo/modules/liquidglass/GlassConstants.kt +7 -0
  156. package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassContainerView.kt +16 -0
  157. package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassProviderView.kt +165 -0
  158. package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassView.kt +1731 -0
  159. package/src/engine/android/src/main/java/expo/modules/liquidglass/enums/GlassEnums.kt +171 -0
  160. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/BackdropGraph.kt +146 -0
  161. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/BackdropSource.kt +53 -0
  162. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/ContinuousCorners.kt +188 -0
  163. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/CornerRadii.kt +62 -0
  164. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassAppearance.kt +352 -0
  165. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassDebug.kt +109 -0
  166. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassEnvironment.kt +139 -0
  167. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassHdr.kt +85 -0
  168. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassLuminanceProbe.kt +189 -0
  169. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassPressAnimator.kt +264 -0
  170. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassProgressiveBlur.kt +249 -0
  171. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassShaderCache.kt +256 -0
  172. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassShaderSource.kt +845 -0
  173. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassTier.kt +63 -0
  174. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/ProviderRegistry.kt +71 -0
  175. package/src/engine/android/src/main/java/expo/modules/liquidglass/records/GlassRecords.kt +288 -0
  176. package/src/engine/index.ts +24 -0
  177. package/src/engine/ios/Enums/GlassBlurDirection.swift +21 -0
  178. package/src/engine/ios/Enums/GlassVariant.swift +86 -0
  179. package/src/engine/ios/ExpoLiquidGlass.podspec +93 -0
  180. package/src/engine/ios/ExpoLiquidGlassModule.swift +77 -0
  181. package/src/engine/ios/Glass/BackdropCapturer.swift +811 -0
  182. package/src/engine/ios/Glass/ContinuousCorners.swift +165 -0
  183. package/src/engine/ios/Glass/GlassBackdrop.swift +176 -0
  184. package/src/engine/ios/Glass/GlassFramePhase.swift +126 -0
  185. package/src/engine/ios/Glass/GlassFrameScheduler.swift +261 -0
  186. package/src/engine/ios/Glass/GlassPressAnimator.swift +250 -0
  187. package/src/engine/ios/Glass/GlassRenderContext.swift +168 -0
  188. package/src/engine/ios/Glass/GlassRenderer.swift +186 -0
  189. package/src/engine/ios/Glass/GlassSurfaceView.swift +452 -0
  190. package/src/engine/ios/Glass/NonRenderableView.swift +54 -0
  191. package/src/engine/ios/Glass/StripCache.swift +545 -0
  192. package/src/engine/ios/Records/GlassCornerRadii.swift +79 -0
  193. package/src/engine/ios/Records/GlassMetalOptions.swift +180 -0
  194. package/src/engine/ios/Records/GlassRefractionCurve.swift +14 -0
  195. package/src/engine/ios/Shaders/LiquidGlass.metal +480 -0
  196. package/src/engine/ios/Shaders/bundle-marker.txt +6 -0
  197. package/src/engine/ios/Views/LiquidGlassContainerView.swift +99 -0
  198. package/src/engine/ios/Views/LiquidGlassView.swift +859 -0
  199. package/src/engine/package.json +70 -0
  200. package/src/engine/src/components/LiquidGlassButton/LiquidGlassButton.tsx +424 -0
  201. package/src/engine/src/components/LiquidGlassCard/LiquidGlassCard.tsx +98 -0
  202. package/src/engine/src/components/LiquidGlassChip/LiquidGlassChip.tsx +65 -0
  203. package/src/engine/src/components/LiquidGlassGroup/LiquidGlassGroup.tsx +350 -0
  204. package/src/engine/src/components/LiquidGlassIconButton/LiquidGlassIconButton.tsx +24 -0
  205. package/src/engine/src/components/LiquidGlassMorphGroup/LiquidGlassMorphGroup.tsx +434 -0
  206. package/src/engine/src/components/LiquidGlassScrim/LiquidGlassScrim.tsx +100 -0
  207. package/src/engine/src/components/LiquidGlassSegmentedControl/LiquidGlassSegmentedControl.tsx +213 -0
  208. package/src/engine/src/components/LiquidGlassSheet/LiquidGlassSheet.tsx +218 -0
  209. package/src/engine/src/components/LiquidGlassSlider/LiquidGlassSlider.tsx +327 -0
  210. package/src/engine/src/components/LiquidGlassStepper/LiquidGlassStepper.tsx +321 -0
  211. package/src/engine/src/components/LiquidGlassSwitch/LiquidGlassSwitch.tsx +296 -0
  212. package/src/engine/src/components/LiquidGlassTabBar/LiquidGlassTabBar.tsx +952 -0
  213. package/src/engine/src/components/LiquidGlassTextInput/LiquidGlassTextInput.tsx +151 -0
  214. package/src/engine/src/components/LiquidGlassToast/LiquidGlassToast.tsx +169 -0
  215. package/src/engine/src/components/LiquidGlassToolbar/LiquidGlassToolbar.tsx +124 -0
  216. package/src/engine/src/components/index.ts +16 -0
  217. package/src/engine/src/constants/index.ts +4 -0
  218. package/src/engine/src/constants/metal.constants.ts +327 -0
  219. package/src/engine/src/constants/metrics.constants.ts +325 -0
  220. package/src/engine/src/constants/springs.constants.ts +107 -0
  221. package/src/engine/src/constants/styles.constants.ts +12 -0
  222. package/src/engine/src/context/glass-group.context.ts +65 -0
  223. package/src/engine/src/context/index.ts +6 -0
  224. package/src/engine/src/core/components/LiquidGlassContainer/LiquidGlassContainer.tsx +32 -0
  225. package/src/engine/src/core/components/LiquidGlassContainer/index.ts +1 -0
  226. package/src/engine/src/core/components/LiquidGlassProvider/LiquidGlassProvider.tsx +66 -0
  227. package/src/engine/src/core/components/LiquidGlassProvider/index.ts +1 -0
  228. package/src/engine/src/core/components/LiquidGlassStack/LiquidGlassStack.tsx +184 -0
  229. package/src/engine/src/core/components/LiquidGlassStack/index.ts +1 -0
  230. package/src/engine/src/core/components/LiquidGlassView/LiquidGlassView.tsx +126 -0
  231. package/src/engine/src/core/components/LiquidGlassView/index.ts +1 -0
  232. package/src/engine/src/core/components/index.ts +4 -0
  233. package/src/engine/src/core/constants/glass.constants.ts +57 -0
  234. package/src/engine/src/core/constants/index.ts +20 -0
  235. package/src/engine/src/core/constants/native.constants.ts +16 -0
  236. package/src/engine/src/core/context/glass-stack.context.ts +30 -0
  237. package/src/engine/src/core/context/index.ts +4 -0
  238. package/src/engine/src/core/enum/index.ts +12 -0
  239. package/src/engine/src/core/index.ts +1 -0
  240. package/src/engine/src/core/interfaces/glass-hdr.interface.ts +15 -0
  241. package/src/engine/src/core/interfaces/glass-metal.interface.ts +248 -0
  242. package/src/engine/src/core/interfaces/glass-surface.interface.ts +9 -0
  243. package/src/engine/src/core/interfaces/index.ts +31 -0
  244. package/src/engine/src/core/interfaces/liquid-glass-container.interface.ts +6 -0
  245. package/src/engine/src/core/interfaces/liquid-glass-provider.interface.ts +14 -0
  246. package/src/engine/src/core/interfaces/liquid-glass-stack.interface.ts +21 -0
  247. package/src/engine/src/core/interfaces/liquid-glass-view.interface.ts +129 -0
  248. package/src/engine/src/core/interfaces/native-liquid-glass-view.interface.ts +19 -0
  249. package/src/engine/src/core/modules/ExpoLiquidGlassModule.ts +26 -0
  250. package/src/engine/src/core/modules/index.ts +2 -0
  251. package/src/engine/src/core/root/index.ts +51 -0
  252. package/src/engine/src/core/types/glass.types.ts +25 -0
  253. package/src/engine/src/core/types/index.ts +8 -0
  254. package/src/engine/src/core/utils/debug.utils.ts +17 -0
  255. package/src/engine/src/core/utils/dev-warn.utils.ts +17 -0
  256. package/src/engine/src/core/utils/hdr.utils.ts +37 -0
  257. package/src/engine/src/core/utils/index.ts +5 -0
  258. package/src/engine/src/core/utils/native-view.utils.ts +33 -0
  259. package/src/engine/src/core/utils/platform.utils.ts +34 -0
  260. package/src/engine/src/core/views/NativeGlassBackdropView.ts +24 -0
  261. package/src/engine/src/core/views/NativeLiquidGlassContainerView.ts +13 -0
  262. package/src/engine/src/core/views/NativeLiquidGlassContainerView.web.ts +10 -0
  263. package/src/engine/src/core/views/NativeLiquidGlassProviderView.ts +13 -0
  264. package/src/engine/src/core/views/NativeLiquidGlassProviderView.web.ts +10 -0
  265. package/src/engine/src/core/views/NativeLiquidGlassView.ts +19 -0
  266. package/src/engine/src/core/views/NativeLiquidGlassView.web.ts +14 -0
  267. package/src/engine/src/core/views/index.ts +4 -0
  268. package/src/engine/src/hooks/index.ts +18 -0
  269. package/src/engine/src/hooks/use-adaptive-glass.ts +91 -0
  270. package/src/engine/src/hooks/use-damped-drag.ts +332 -0
  271. package/src/engine/src/hooks/use-echo-filter.ts +55 -0
  272. package/src/engine/src/hooks/use-glass-group-member.ts +169 -0
  273. package/src/engine/src/hooks/use-gravity-highlight.ts +79 -0
  274. package/src/engine/src/hooks/use-press-progress.ts +44 -0
  275. package/src/engine/src/index.ts +120 -0
  276. package/src/engine/src/interfaces/index.ts +28 -0
  277. package/src/engine/src/interfaces/liquid-glass-button.interface.ts +94 -0
  278. package/src/engine/src/interfaces/liquid-glass-card.interface.ts +40 -0
  279. package/src/engine/src/interfaces/liquid-glass-chip.interface.ts +29 -0
  280. package/src/engine/src/interfaces/liquid-glass-group.interface.ts +32 -0
  281. package/src/engine/src/interfaces/liquid-glass-icon-button.interface.ts +19 -0
  282. package/src/engine/src/interfaces/liquid-glass-morph-group.interface.ts +59 -0
  283. package/src/engine/src/interfaces/liquid-glass-scrim.interface.ts +36 -0
  284. package/src/engine/src/interfaces/liquid-glass-segmented-control.interface.ts +32 -0
  285. package/src/engine/src/interfaces/liquid-glass-sheet.interface.ts +38 -0
  286. package/src/engine/src/interfaces/liquid-glass-slider.interface.ts +37 -0
  287. package/src/engine/src/interfaces/liquid-glass-stepper.interface.ts +35 -0
  288. package/src/engine/src/interfaces/liquid-glass-switch.interface.ts +27 -0
  289. package/src/engine/src/interfaces/liquid-glass-tab-bar.interface.ts +116 -0
  290. package/src/engine/src/interfaces/liquid-glass-text-input.interface.ts +42 -0
  291. package/src/engine/src/interfaces/liquid-glass-toast.interface.ts +36 -0
  292. package/src/engine/src/interfaces/liquid-glass-toolbar.interface.ts +33 -0
  293. package/src/engine/src/theme/glass-ui-theme.ts +100 -0
  294. package/src/engine/src/theme/index.ts +2 -0
  295. package/src/engine/src/utils/button-press.utils.ts +63 -0
  296. package/src/engine/src/utils/index.ts +3 -0
  297. package/src/engine/src/utils/metal.utils.ts +164 -0
  298. package/src/glass-provider.tsx +60 -0
  299. package/src/glass-stack.tsx +115 -0
  300. package/src/index.ts +47 -190
  301. package/src/internal/GlassBackdrop.tsx +60 -0
  302. package/src/internal/GlassView.tsx +53 -18
  303. package/src/internal/blur-community.ts +19 -0
  304. package/src/internal/blur-community.web.ts +7 -0
  305. package/src/internal/blur.ts +7 -8
  306. package/src/internal/glass-routing.ts +211 -34
  307. package/src/internal/initials.ts +7 -0
  308. package/src/internal/overlay.tsx +258 -0
  309. package/src/internal/primitives.ts +23 -0
  310. package/lib/module/Carousel.js +0 -103
  311. package/lib/module/Display.js +0 -318
  312. package/lib/module/Feedback.js +0 -395
  313. package/lib/module/Form.js +0 -160
  314. package/lib/module/Forms2.js +0 -471
  315. package/lib/module/Message.js +0 -84
  316. package/lib/module/Overlays.js +0 -344
  317. package/lib/module/Pickers.js +0 -243
  318. package/lib/module/Table.js +0 -100
  319. package/lib/module/ai.js +0 -283
  320. package/lib/module/charts/AreaChart.js +0 -32
  321. package/lib/module/charts/BarChart.js +0 -75
  322. package/lib/module/charts/FunnelChart.js +0 -50
  323. package/lib/module/charts/HeatmapChart.js +0 -71
  324. package/lib/module/charts/LineChart.js +0 -81
  325. package/lib/module/charts/PlotChart.js +0 -52
  326. package/lib/module/charts/RadarChart.js +0 -78
  327. package/lib/module/charts/RingChart.js +0 -52
  328. package/lib/module/charts/ScatterChart.js +0 -95
  329. package/lib/module/charts/WaterfallChart.js +0 -85
  330. package/lib/module/charts/advanced.js +0 -313
  331. package/lib/module/charts/extra.js +0 -108
  332. package/lib/module/charts/index.js +0 -50
  333. package/lib/module/charts/scales.js +0 -140
  334. package/lib/typescript/Carousel.d.ts +0 -47
  335. package/lib/typescript/Display.d.ts +0 -178
  336. package/lib/typescript/Feedback.d.ts +0 -196
  337. package/lib/typescript/Form.d.ts +0 -97
  338. package/lib/typescript/Forms2.d.ts +0 -209
  339. package/lib/typescript/Message.d.ts +0 -67
  340. package/lib/typescript/Overlays.d.ts +0 -146
  341. package/lib/typescript/Pickers.d.ts +0 -105
  342. package/lib/typescript/Table.d.ts +0 -64
  343. package/lib/typescript/ai.d.ts +0 -166
  344. package/lib/typescript/charts/AreaChart.d.ts +0 -44
  345. package/lib/typescript/charts/BarChart.d.ts +0 -19
  346. package/lib/typescript/charts/FunnelChart.d.ts +0 -25
  347. package/lib/typescript/charts/HeatmapChart.d.ts +0 -23
  348. package/lib/typescript/charts/LineChart.d.ts +0 -30
  349. package/lib/typescript/charts/PlotChart.d.ts +0 -31
  350. package/lib/typescript/charts/RadarChart.d.ts +0 -27
  351. package/lib/typescript/charts/RingChart.d.ts +0 -28
  352. package/lib/typescript/charts/ScatterChart.d.ts +0 -34
  353. package/lib/typescript/charts/WaterfallChart.d.ts +0 -22
  354. package/lib/typescript/charts/advanced.d.ts +0 -107
  355. package/lib/typescript/charts/extra.d.ts +0 -63
  356. package/lib/typescript/charts/index.d.ts +0 -13
  357. package/lib/typescript/charts/scales.d.ts +0 -35
  358. package/src/Carousel.tsx +0 -233
  359. package/src/Display.tsx +0 -781
  360. package/src/Feedback.tsx +0 -992
  361. package/src/Form.tsx +0 -445
  362. package/src/Forms2.tsx +0 -1055
  363. package/src/Message.tsx +0 -218
  364. package/src/Overlays.tsx +0 -704
  365. package/src/Pickers.tsx +0 -595
  366. package/src/Table.tsx +0 -232
  367. package/src/ai.tsx +0 -715
  368. package/src/charts/AreaChart.tsx +0 -73
  369. package/src/charts/BarChart.tsx +0 -221
  370. package/src/charts/FunnelChart.tsx +0 -125
  371. package/src/charts/HeatmapChart.tsx +0 -155
  372. package/src/charts/LineChart.tsx +0 -247
  373. package/src/charts/PlotChart.tsx +0 -168
  374. package/src/charts/RadarChart.tsx +0 -208
  375. package/src/charts/RingChart.tsx +0 -133
  376. package/src/charts/ScatterChart.tsx +0 -223
  377. package/src/charts/WaterfallChart.tsx +0 -201
  378. package/src/charts/advanced.tsx +0 -676
  379. package/src/charts/extra.tsx +0 -242
  380. package/src/charts/index.ts +0 -86
  381. package/src/charts/scales.ts +0 -163
package/src/Overlays.tsx DELETED
@@ -1,704 +0,0 @@
1
- import { forwardRef, useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react";
2
- import type { StyleProp, ViewStyle } from "react-native";
3
-
4
- import { Glass } from "./Glass";
5
- import { Text } from "./Text";
6
- import { colors, radii } from "./internal/tokens";
7
- import { primitives } from "./internal/primitives";
8
- import { useIsDark, useSpring } from "./internal/motion";
9
- import { hapticSelection } from "./internal/haptics";
10
-
11
- /**
12
- * Registers Android's hardware back while an overlay is open.
13
- *
14
- * Shared by Menu, Sheet and Drawer so every overlay dismisses the same way a
15
- * Dialog does: the back button closes the layer, not the screen behind it.
16
- */
17
- function useBackDismiss(open: boolean, onDismiss: () => void) {
18
- useEffect(() => {
19
- if (!open) return;
20
- const BackHandler = primitives().getBackHandler();
21
- if (!BackHandler) return;
22
- const sub = BackHandler.addEventListener("hardwareBackPress", () => {
23
- onDismiss();
24
- return true;
25
- });
26
- return () => sub.remove();
27
- }, [open, onDismiss]);
28
- }
29
-
30
- /**
31
- * Keeps a popover inside the window.
32
- *
33
- * Called with the trigger's measured frame and the popover's own size; returns
34
- * the offsets that bring it back on screen. A menu near the bottom edge flips
35
- * above its trigger rather than hanging off the display.
36
- */
37
- export function anchorPopover(
38
- trigger: { x: number; y: number; width: number; height: number },
39
- popover: { width: number; height: number },
40
- viewport: { width: number; height: number },
41
- gap = 6,
42
- ): { left: number; top: number; flipped: boolean } {
43
- const below = trigger.y + trigger.height + gap;
44
- const above = trigger.y - popover.height - gap;
45
- const fitsBelow = below + popover.height <= viewport.height;
46
- const flipped = !fitsBelow && above >= 0;
47
- const top = Math.max(0, Math.min(flipped ? above : below, viewport.height - popover.height));
48
- const left = Math.max(0, Math.min(trigger.x, viewport.width - popover.width));
49
- return { left, top, flipped };
50
- }
51
-
52
- // ---------------------------------------------------------------------------
53
- // Menu
54
-
55
- export interface MenuItem {
56
- label: string;
57
- onPress: () => void;
58
- icon?: ReactNode;
59
- disabled?: boolean;
60
- /** Renders in the destructive tone, for delete-and-similar. */
61
- destructive?: boolean;
62
- accessibilityLabel?: string;
63
- }
64
-
65
- export interface MenuProps {
66
- /** The control that opens the menu. */
67
- trigger: ReactNode;
68
- items: MenuItem[];
69
- /** Controlled open state. Omit and the menu keeps its own. */
70
- open?: boolean;
71
- onOpenChange?: (open: boolean) => void;
72
- /** The menu's width. The list scrolls if the items exceed the screen. */
73
- width?: number;
74
- accessibilityLabel?: string;
75
- style?: StyleProp<ViewStyle>;
76
- isDark?: boolean;
77
- testID?: string;
78
- }
79
-
80
- /**
81
- * An anchored dropdown menu.
82
- *
83
- * A press outside or on an item closes it; Android's back button does too. The
84
- * popover is a glass surface with `glassActive` rows, matching the way the
85
- * library marks a tappable row rather than nesting another glass panel.
86
- */
87
- export const Menu = forwardRef<any, MenuProps>(function Menu(
88
- {
89
- trigger,
90
- items,
91
- open: openProp,
92
- onOpenChange,
93
- width = 220,
94
- accessibilityLabel = "Menu",
95
- style,
96
- isDark: isDarkProp,
97
- testID,
98
- ...props
99
- },
100
- ref,
101
- ) {
102
- const isDark = useIsDark(isDarkProp);
103
- const theme = isDark ? colors.dark : colors.light;
104
- const { View, Text: RNText, Pressable, Modal } = primitives();
105
-
106
- const [internalOpen, setInternalOpen] = useState(false);
107
- const open = openProp !== undefined ? openProp : internalOpen;
108
-
109
- const setOpen = useCallback(
110
- (next: boolean) => {
111
- if (openProp === undefined) setInternalOpen(next);
112
- onOpenChange?.(next);
113
- },
114
- [openProp, onOpenChange],
115
- );
116
-
117
- const dismiss = useCallback(() => setOpen(false), [setOpen]);
118
- useBackDismiss(open, dismiss);
119
-
120
- const { value: enter, animated } = useSpring(open ? 1 : 0, "snappy");
121
- const scale = animated ? enter.interpolate({ inputRange: [0, 1], outputRange: [0.96, 1] }) : 1;
122
-
123
- const popover = (
124
- <Glass
125
- effect="regular"
126
- surface="overlay"
127
- isDark={isDark}
128
- testID={testID ? `${testID}-popover` : undefined}
129
- style={{
130
- width,
131
- borderRadius: radii.lg,
132
- paddingVertical: 4,
133
- // The web menu is deliberately near-solid so its labels stay legible
134
- // over any backdrop, and it floats on a real shadow.
135
- backgroundColor: theme.surface,
136
- shadowOpacity: 0.12,
137
- shadowRadius: 40,
138
- shadowOffset: { width: 0, height: 12 },
139
- ...(style as ViewStyle),
140
- }}
141
- >
142
- {items.map((item, index) => (
143
- <Pressable
144
- key={`${item.label}-${index}`}
145
- accessibilityRole="button"
146
- accessibilityLabel={item.accessibilityLabel ?? item.label}
147
- accessibilityState={{ disabled: item.disabled }}
148
- disabled={item.disabled}
149
- onPress={() => {
150
- setOpen(false);
151
- item.onPress();
152
- }}
153
- style={{ flexDirection: "row", alignItems: "center", gap: 10, minHeight: 40, paddingVertical: 8, paddingHorizontal: 12, opacity: item.disabled ? 0.38 : 1 }}
154
- >
155
- {item.icon ? <View>{item.icon}</View> : null}
156
- <RNText
157
- numberOfLines={1}
158
- style={{ fontSize: 15, color: item.destructive ? theme.destructive : theme.foreground }}
159
- >
160
- {item.label}
161
- </RNText>
162
- </Pressable>
163
- ))}
164
- </Glass>
165
- );
166
-
167
- return (
168
- <View ref={ref} style={{ alignSelf: "flex-start" }} {...props}>
169
- <Pressable
170
- accessibilityRole="button"
171
- accessibilityLabel={accessibilityLabel}
172
- accessibilityState={{ expanded: open }}
173
- onPress={() => setOpen(!open)}
174
- >
175
- {trigger}
176
- </Pressable>
177
-
178
- <Modal visible={open} transparent animationType="fade" onRequestClose={dismiss}>
179
- {/* The backdrop: any press outside the popover dismisses the menu. */}
180
- <Pressable
181
- accessibilityRole="button"
182
- accessibilityLabel="Close menu"
183
- onPress={dismiss}
184
- style={{ flex: 1, backgroundColor: theme.scrim }}
185
- >
186
- <View style={{ flex: 1, alignItems: "center", justifyContent: "center", padding: 24 }}>
187
- <Pressable accessibilityRole="none" onPress={() => {}}>
188
- {animated ? (
189
- <AnimatedScale scale={scale}>{popover}</AnimatedScale>
190
- ) : (
191
- popover
192
- )}
193
- </Pressable>
194
- </View>
195
- </Pressable>
196
- </Modal>
197
- </View>
198
- );
199
- });
200
-
201
- /** Wraps a popover in the entrance scale, which must land on an Animated.View. */
202
- function AnimatedScale({ scale, children }: { scale: any; children: ReactNode }) {
203
- const { Animated } = primitives();
204
- return <Animated.View style={{ transform: [{ scale }] }}>{children}</Animated.View>;
205
- }
206
-
207
- // ---------------------------------------------------------------------------
208
- // Sheet
209
-
210
- export interface SheetProps {
211
- /** Controlled visibility. Omit and the sheet keeps its own. */
212
- open?: boolean;
213
- defaultOpen?: boolean;
214
- onOpenChange?: (open: boolean) => void;
215
- title?: string;
216
- children?: ReactNode;
217
- footer?: ReactNode;
218
- /** Tapping the scrim dismisses. */
219
- dismissOnBackdropPress?: boolean;
220
- /** The drag handle at the top of the panel. */
221
- showHandle?: boolean;
222
- /**
223
- * Resting heights the sheet can settle at, smallest first. A number is
224
- * points; a fraction below 1 is a share of the window height. With one
225
- * point the sheet opens there; with several it can be dragged between them.
226
- * Omitted, the sheet uses its own natural height.
227
- */
228
- snapPoints?: number[];
229
- /** Which snap point to open at. Defaults to the first. */
230
- initialSnapIndex?: number;
231
- /** Controlled snap point. Omit and the sheet tracks its own. */
232
- snapIndex?: number;
233
- onSnapIndexChange?: (index: number) => void;
234
- /** Dragging below the lowest point dismisses instead of springing back. */
235
- dismissOnSnapToBottom?: boolean;
236
- /** Turns the drag gesture off, leaving press-and-back dismissal only. */
237
- draggable?: boolean;
238
- /** Opt out of the selection tick on snap changes. */
239
- haptics?: boolean;
240
- style?: StyleProp<ViewStyle>;
241
- isDark?: boolean;
242
- testID?: string;
243
- }
244
-
245
- /**
246
- * A bottom sheet.
247
- *
248
- * The general-purpose container: it slides up on the springs token, dismisses
249
- * on a scrim press and on Android back. ActionSheet remains the action-menu
250
- * specialisation of this shape; Sheet is for arbitrary content — a form, a
251
- * calendar, a detail panel.
252
- */
253
- /**
254
- * Turns a snap point into a pixel height.
255
- *
256
- * A number under 1 is a fraction of the window; anything else is points. The
257
- * result is clamped so a sheet can never be taller than the space it has.
258
- */
259
- export function resolveSnapPoint(point: number, windowHeight: number): number {
260
- const height = point > 0 && point < 1 ? point * windowHeight : point;
261
- return Math.max(0, Math.min(height, windowHeight));
262
- }
263
-
264
- /**
265
- * Picks the snap point nearest to where the user let go.
266
- *
267
- * `height` is how tall the sheet currently is. Ties go to the smaller sheet,
268
- * so a small flick does not jump the panel to full height.
269
- */
270
- export function nearestSnapPoint(heights: number[], height: number): number {
271
- let best = 0;
272
- let bestDistance = Number.POSITIVE_INFINITY;
273
- heights.forEach((candidate, index) => {
274
- const distance = Math.abs(candidate - height);
275
- if (distance < bestDistance) {
276
- bestDistance = distance;
277
- best = index;
278
- }
279
- });
280
- return best;
281
- }
282
-
283
- export const Sheet = forwardRef<any, SheetProps>(function Sheet(
284
- {
285
- open: openProp,
286
- defaultOpen = false,
287
- onOpenChange,
288
- title,
289
- children,
290
- footer,
291
- dismissOnBackdropPress = true,
292
- showHandle = true,
293
- snapPoints,
294
- initialSnapIndex = 0,
295
- snapIndex: snapIndexProp,
296
- onSnapIndexChange,
297
- dismissOnSnapToBottom = false,
298
- draggable = true,
299
- haptics = true,
300
- style,
301
- isDark: isDarkProp,
302
- testID,
303
- ...props
304
- },
305
- ref,
306
- ) {
307
- const isDark = useIsDark(isDarkProp);
308
- const theme = isDark ? colors.dark : colors.light;
309
- const { View, Text: RNText, Pressable, Modal, PanResponder, useWindowDimensions } = primitives();
310
-
311
- const [internalOpen, setInternalOpen] = useState(defaultOpen);
312
- const open = openProp !== undefined ? openProp : internalOpen;
313
-
314
- const setOpen = useCallback(
315
- (next: boolean) => {
316
- if (openProp === undefined) setInternalOpen(next);
317
- onOpenChange?.(next);
318
- },
319
- [openProp, onOpenChange],
320
- );
321
-
322
- const dismiss = useCallback(() => setOpen(false), [setOpen]);
323
- useBackDismiss(open, dismiss);
324
-
325
- // Snap points in pixels, smallest first so index 0 is the shortest sheet.
326
- const windowHeight = useWindowDimensions?.().height ?? 800;
327
- const heights = useMemo(() => {
328
- if (!snapPoints || snapPoints.length === 0) return [];
329
- return snapPoints.map((point) => resolveSnapPoint(point, windowHeight)).sort((a, b) => a - b);
330
- }, [snapPoints, windowHeight]);
331
-
332
- const [internalSnap, setInternalSnap] = useState(initialSnapIndex);
333
- const snapIndex = snapIndexProp !== undefined ? snapIndexProp : internalSnap;
334
- const activeHeight = heights.length > 0 ? heights[Math.min(snapIndex, heights.length - 1)]! : null;
335
-
336
- // Drag offset in pixels: 0 is resting at the active snap point, positive is
337
- // dragged down. It resets to 0 after a release, because the settle either
338
- // changes the snap index or dismisses.
339
- const dragRef = useRef(0);
340
- const [drag, setDrag] = useState(0);
341
-
342
- const { value: rise, animated } = useSpring(open ? 1 : 0, "gentle");
343
- const slideIn = animated ? rise.interpolate({ inputRange: [0, 1], outputRange: [420, 0] }) : 0;
344
-
345
- const heightsRef = useRef(heights);
346
- heightsRef.current = heights;
347
- const activeHeightRef = useRef(activeHeight);
348
- activeHeightRef.current = activeHeight;
349
- const snapIndexRef = useRef(snapIndex);
350
- snapIndexRef.current = snapIndex;
351
-
352
- const goToSnap = useCallback(
353
- (index: number) => {
354
- if (snapIndexProp === undefined) setInternalSnap(index);
355
- onSnapIndexChange?.(index);
356
- if (haptics) hapticSelection();
357
- },
358
- [snapIndexProp, onSnapIndexChange, haptics],
359
- );
360
-
361
- /**
362
- * The release decision.
363
- *
364
- * Below the lowest snap point the sheet dismisses when allowed, otherwise it
365
- * snaps back; anywhere else it settles at the nearest point, with a fast
366
- * downward flick counting as a step towards the smaller sheet.
367
- */
368
- const release = useCallback(
369
- (dy: number, vy: number) => {
370
- const list = heightsRef.current;
371
- const current = list[snapIndexRef.current] ?? activeHeightRef.current ?? 0;
372
- const restingAfterDrag = current - dy;
373
-
374
- if (list.length === 0) {
375
- // No snap points: a decisive downward drag dismisses.
376
- if (dy > 120 || vy > 0.8) dismiss();
377
- return;
378
- }
379
-
380
- const lowest = list[0]!;
381
- const belowLowest = restingAfterDrag < lowest - 40;
382
- if (belowLowest && dismissOnSnapToBottom) {
383
- dismiss();
384
- return;
385
- }
386
-
387
- // A fast flick moves one step in its direction before distance decides.
388
- let index = nearestSnapPoint(list, restingAfterDrag);
389
- if (vy > 0.5) index = Math.max(0, Math.min(index, snapIndexRef.current - 1));
390
- if (vy < -0.5) index = Math.max(index, Math.min(snapIndexRef.current + 1, list.length - 1));
391
-
392
- if (index !== snapIndexRef.current) goToSnap(index);
393
- },
394
- [dismiss, dismissOnSnapToBottom, goToSnap],
395
- );
396
-
397
- const panResponder = useMemo(() => {
398
- if (!draggable || !PanResponder?.create) return null;
399
- return PanResponder.create({
400
- // Vertical drags belong to the sheet; horizontal ones are left alone.
401
- onStartShouldSetPanResponder: () => false,
402
- onMoveShouldSetPanResponder: (_event: any, gesture: any) =>
403
- Math.abs(gesture.dy) > Math.abs(gesture.dx) && Math.abs(gesture.dy) > 6,
404
- onPanResponderGrant: () => {
405
- dragRef.current = 0;
406
- },
407
- onPanResponderMove: (_event: any, gesture: any) => {
408
- // Dragging up past the tallest point has nowhere to go; clamp at 0.
409
- const next = Math.max(-40, gesture.dy);
410
- dragRef.current = next;
411
- setDrag(next);
412
- },
413
- onPanResponderRelease: (_event: any, gesture: any) => {
414
- release(gesture.dy, gesture.vy);
415
- dragRef.current = 0;
416
- setDrag(0);
417
- },
418
- onPanResponderTerminate: () => {
419
- dragRef.current = 0;
420
- setDrag(0);
421
- },
422
- onPanResponderTerminationRequest: () => false,
423
- });
424
- }, [draggable, PanResponder, release]);
425
-
426
- // Reduce Motion is honoured by useSpring: when it is on, `animated` is false
427
- // and the panel is already in position, so the sheet opens and snaps without
428
- // a transition.
429
- const translateY = drag !== 0 ? drag : animated ? slideIn : 0;
430
-
431
- const panel = (
432
- <SheetPanel
433
- title={title}
434
- footer={footer}
435
- showHandle={showHandle}
436
- isDark={isDark}
437
- testID={testID}
438
- style={style}
439
- height={activeHeight}
440
- >
441
- {children}
442
- </SheetPanel>
443
- );
444
-
445
- return (
446
- <Modal visible={open} transparent animationType="fade" onRequestClose={dismiss}>
447
- <Pressable
448
- accessibilityRole="button"
449
- accessibilityLabel="Close sheet"
450
- onPress={dismissOnBackdropPress ? dismiss : undefined}
451
- style={{ flex: 1, justifyContent: "flex-end", backgroundColor: theme.scrim }}
452
- >
453
- <Pressable
454
- accessibilityRole="none"
455
- onPress={() => {}}
456
- style={{ width: "100%" }}
457
- {...(panResponder ? panResponder.panHandlers : {})}
458
- >
459
- {animated || drag !== 0 ? (
460
- <SheetRise translateY={translateY}>{panel}</SheetRise>
461
- ) : (
462
- panel
463
- )}
464
- </Pressable>
465
- </Pressable>
466
- </Modal>
467
- );
468
- });
469
-
470
- function SheetRise({ translateY, children }: { translateY: any; children: ReactNode }) {
471
- const { Animated } = primitives();
472
- return <Animated.View style={{ transform: [{ translateY }] }}>{children}</Animated.View>;
473
- }
474
-
475
- /** The panel itself: a glass surface with a handle, a title and a footer. */
476
- function SheetPanel({
477
- title,
478
- footer,
479
- showHandle,
480
- isDark,
481
- testID,
482
- style,
483
- height,
484
- children,
485
- }: {
486
- title?: string;
487
- footer?: ReactNode;
488
- showHandle: boolean;
489
- isDark: boolean;
490
- testID?: string;
491
- style?: StyleProp<ViewStyle>;
492
- /** The snap point's height, or null for the panel's natural height. */
493
- height?: number | null;
494
- children?: ReactNode;
495
- }) {
496
- const theme = isDark ? colors.dark : colors.light;
497
- const { View, Text: RNText } = primitives();
498
-
499
- return (
500
- <Glass
501
- effect="regular"
502
- surface="overlay"
503
- isDark={isDark}
504
- testID={testID}
505
- style={{
506
- borderTopLeftRadius: radii.xl,
507
- borderTopRightRadius: radii.xl,
508
- borderBottomLeftRadius: 0,
509
- borderBottomRightRadius: 0,
510
- paddingBottom: 24,
511
- // The web sheet carries a deep, soft shadow so it reads as a layer
512
- // above the page rather than a rectangle painted on it.
513
- shadowOpacity: 0.5,
514
- shadowRadius: 40,
515
- shadowOffset: { width: 0, height: 0 },
516
- // A snap point fixes the height; without one the panel is natural.
517
- ...(height != null ? { height } : { maxHeight: 560 }),
518
- ...(style as ViewStyle),
519
- }}
520
- >
521
- {showHandle ? (
522
- <View style={{ alignItems: "center", paddingTop: 8, paddingBottom: 4 }}>
523
- <View
524
- accessibilityElementsHidden
525
- // A capsule: the radius is half the handle's own height.
526
- style={{ width: 36, height: 5, borderRadius: 5 / 2, backgroundColor: theme.separator }}
527
- />
528
- </View>
529
- ) : null}
530
- {title ? (
531
- <View style={{ paddingHorizontal: 24, paddingVertical: 10 }}>
532
- <RNText accessibilityRole="heading" style={{ fontSize: 17, fontWeight: "600", color: theme.foreground }}>
533
- {title}
534
- </RNText>
535
- </View>
536
- ) : null}
537
- <View style={{ paddingHorizontal: 24 }}>{children}</View>
538
- {footer ? <View style={{ paddingHorizontal: 24, paddingTop: 12, gap: 8 }}>{footer}</View> : null}
539
- </Glass>
540
- );
541
- }
542
-
543
- // ---------------------------------------------------------------------------
544
- // Drawer
545
-
546
- export interface DrawerProps {
547
- /** Controlled visibility. Omit and the drawer keeps its own. */
548
- open?: boolean;
549
- defaultOpen?: boolean;
550
- onOpenChange?: (open: boolean) => void;
551
- /** The edge the panel slides in from. */
552
- side?: "left" | "right";
553
- /** Panel width. */
554
- width?: number;
555
- children?: ReactNode;
556
- /** Tapping the scrim dismisses. */
557
- dismissOnBackdropPress?: boolean;
558
- /** Turns the drag-to-close gesture off. */
559
- draggable?: boolean;
560
- /** Opt out of the selection tick when the drawer is thrown closed. */
561
- haptics?: boolean;
562
- style?: StyleProp<ViewStyle>;
563
- isDark?: boolean;
564
- testID?: string;
565
- }
566
-
567
- /**
568
- * A side navigation drawer.
569
- *
570
- * The same overlay discipline as Sheet — scrim, spring slide, Android back —
571
- * but anchored to a side edge, with a square panel that runs the full height.
572
- * The caller supplies the content, typically a List.
573
- *
574
- * Dragging the panel towards its own edge follows the finger; releasing past
575
- * the halfway point, or with enough outward velocity, closes it, and a drag
576
- * that stays inside springs it back open. Reduce Motion is honoured: with it
577
- * on, the drawer appears and disappears without sliding.
578
- */
579
- export const Drawer = forwardRef<any, DrawerProps>(function Drawer(
580
- {
581
- open: openProp,
582
- defaultOpen = false,
583
- onOpenChange,
584
- side = "left",
585
- width = 280,
586
- children,
587
- dismissOnBackdropPress = true,
588
- draggable = true,
589
- haptics = true,
590
- style,
591
- isDark: isDarkProp,
592
- testID,
593
- ...props
594
- },
595
- ref,
596
- ) {
597
- const isDark = useIsDark(isDarkProp);
598
- const theme = isDark ? colors.dark : colors.light;
599
- const { View, Pressable, Modal, PanResponder } = primitives();
600
-
601
- const [internalOpen, setInternalOpen] = useState(defaultOpen);
602
- const open = openProp !== undefined ? openProp : internalOpen;
603
-
604
- const setOpen = useCallback(
605
- (next: boolean) => {
606
- if (openProp === undefined) setInternalOpen(next);
607
- onOpenChange?.(next);
608
- },
609
- [openProp, onOpenChange],
610
- );
611
-
612
- const dismiss = useCallback(() => setOpen(false), [setOpen]);
613
- useBackDismiss(open, dismiss);
614
-
615
- const { value: slide, animated } = useSpring(open ? 1 : 0, "gentle");
616
- // Slide in from off-screen: negative from the left, positive from the right.
617
- const slideIn = animated
618
- ? slide.interpolate({ inputRange: [0, 1], outputRange: [side === "left" ? -width : width, 0] })
619
- : 0;
620
-
621
- // The drag is measured in the drawer's own closing direction, so a drag
622
- // towards the anchored edge is always positive whichever side it is on.
623
- const [drag, setDrag] = useState(0);
624
-
625
- const panResponder = useMemo(() => {
626
- if (!draggable || !PanResponder?.create) return null;
627
- const outward = side === "left" ? -1 : 1;
628
- return PanResponder.create({
629
- onStartShouldSetPanResponder: () => false,
630
- onMoveShouldSetPanResponder: (_event: any, gesture: any) =>
631
- // Only a horizontal drag towards the edge is ours; the other way has
632
- // nowhere to go and should not fight content inside the panel.
633
- Math.abs(gesture.dx) > Math.abs(gesture.dy) && gesture.dx * outward > 6,
634
- onPanResponderMove: (_event: any, gesture: any) => {
635
- setDrag(Math.max(0, gesture.dx * outward));
636
- },
637
- onPanResponderRelease: (_event: any, gesture: any) => {
638
- const travelled = Math.max(0, gesture.dx * outward);
639
- const thrown = gesture.vx * outward > 0.4;
640
- setDrag(0);
641
- if (travelled > width / 2 || thrown) {
642
- if (haptics) hapticSelection();
643
- dismiss();
644
- }
645
- },
646
- onPanResponderTerminate: () => setDrag(0),
647
- onPanResponderTerminationRequest: () => false,
648
- });
649
- // `dismiss` is stable; the gesture only needs rebuilding when its shape
650
- // (side or width) changes.
651
- }, [draggable, PanResponder, side, width, haptics, dismiss]);
652
-
653
- const translateX = drag !== 0 ? (side === "left" ? -drag : drag) : animated ? slideIn : 0;
654
-
655
- const panel = (
656
- <Glass
657
- effect="regular"
658
- surface="overlay"
659
- isDark={isDark}
660
- testID={testID}
661
- style={{
662
- width,
663
- height: "100%",
664
- borderRadius: 0,
665
- paddingTop: 56,
666
- ...(style as ViewStyle),
667
- }}
668
- >
669
- {children}
670
- </Glass>
671
- );
672
-
673
- return (
674
- <Modal visible={open} transparent animationType="fade" onRequestClose={dismiss}>
675
- <Pressable
676
- accessibilityRole="button"
677
- accessibilityLabel="Close drawer"
678
- onPress={dismissOnBackdropPress ? dismiss : undefined}
679
- style={{ flex: 1, backgroundColor: theme.scrim }}
680
- >
681
- <View
682
- style={{
683
- flex: 1,
684
- alignItems: side === "left" ? "flex-start" : "flex-end",
685
- }}
686
- >
687
- <Pressable
688
- accessibilityRole="none"
689
- onPress={() => {}}
690
- style={{ height: "100%" }}
691
- {...(panResponder ? panResponder.panHandlers : {})}
692
- >
693
- {animated || drag !== 0 ? <DrawerSlide translateX={translateX}>{panel}</DrawerSlide> : panel}
694
- </Pressable>
695
- </View>
696
- </Pressable>
697
- </Modal>
698
- );
699
- });
700
-
701
- function DrawerSlide({ translateX, children }: { translateX: any; children: ReactNode }) {
702
- const { Animated } = primitives();
703
- return <Animated.View style={{ height: "100%", transform: [{ translateX }] }}>{children}</Animated.View>;
704
- }