glacia-native 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (403) hide show
  1. package/LICENSE +29 -4
  2. package/README.md +111 -17
  3. package/lib/module/Accordion.js +58 -0
  4. package/lib/module/ActionSheet.js +38 -0
  5. package/lib/module/Alert.js +23 -0
  6. package/lib/module/AlertDialog.js +47 -0
  7. package/lib/module/Avatar.js +48 -0
  8. package/lib/module/Badge.js +36 -0
  9. package/lib/module/Bars.js +13 -267
  10. package/lib/module/Button.js +57 -36
  11. package/lib/module/Card.js +32 -20
  12. package/lib/module/Checkbox.js +42 -0
  13. package/lib/module/Chip.js +80 -0
  14. package/lib/module/Collapsible.js +26 -0
  15. package/lib/module/ContextMenu.js +33 -0
  16. package/lib/module/Dialog.js +39 -124
  17. package/lib/module/DropdownMenu.js +33 -0
  18. package/lib/module/Field.js +22 -0
  19. package/lib/module/Glass.js +12 -5
  20. package/lib/module/Group.js +36 -0
  21. package/lib/module/IconButton.js +40 -0
  22. package/lib/module/Input.js +47 -40
  23. package/lib/module/Label.js +17 -0
  24. package/lib/module/MorphGroup.js +47 -0
  25. package/lib/module/Popover.js +29 -0
  26. package/lib/module/Progress.js +32 -0
  27. package/lib/module/RadioGroup.js +51 -0
  28. package/lib/module/Scrim.js +44 -0
  29. package/lib/module/SegmentedControl.js +74 -58
  30. package/lib/module/Select.js +51 -0
  31. package/lib/module/Separator.js +25 -0
  32. package/lib/module/Sheet.js +51 -0
  33. package/lib/module/Skeleton.js +48 -0
  34. package/lib/module/Slider.js +60 -40
  35. package/lib/module/Stepper.js +167 -0
  36. package/lib/module/Switch.js +45 -43
  37. package/lib/module/TabBar.js +62 -50
  38. package/lib/module/Tabs.js +3 -2
  39. package/lib/module/Textarea.js +18 -0
  40. package/lib/module/Toast.js +55 -0
  41. package/lib/module/Toggle.js +47 -0
  42. package/lib/module/ToggleGroup.js +56 -0
  43. package/lib/module/Toolbar.js +37 -0
  44. package/lib/module/Tooltip.js +31 -0
  45. package/lib/module/glass-provider.js +28 -0
  46. package/lib/module/glass-stack.js +61 -0
  47. package/lib/module/index.js +78 -109
  48. package/lib/module/internal/GlassBackdrop.js +36 -0
  49. package/lib/module/internal/GlassView.js +45 -13
  50. package/lib/module/internal/blur-community.js +20 -0
  51. package/lib/module/internal/blur-community.web.js +9 -0
  52. package/lib/module/internal/blur.js +75 -0
  53. package/lib/module/internal/fallback.js +110 -20
  54. package/lib/module/internal/glass-routing.js +154 -30
  55. package/lib/module/internal/glow.js +36 -0
  56. package/lib/module/internal/initials.js +12 -0
  57. package/lib/module/internal/lens.js +70 -0
  58. package/lib/module/internal/material.js +64 -0
  59. package/lib/module/internal/overlay.js +147 -0
  60. package/lib/module/internal/primitives.js +17 -0
  61. package/lib/module/internal/rim.js +35 -0
  62. package/lib/module/internal/tokens.js +34 -2
  63. package/lib/typescript/Accordion.d.ts +22 -0
  64. package/lib/typescript/ActionSheet.d.ts +24 -0
  65. package/lib/typescript/Alert.d.ts +15 -0
  66. package/lib/typescript/AlertDialog.d.ts +17 -0
  67. package/lib/typescript/Avatar.d.ts +22 -0
  68. package/lib/typescript/Badge.d.ts +12 -0
  69. package/lib/typescript/Bars.d.ts +3 -188
  70. package/lib/typescript/Button.d.ts +44 -10
  71. package/lib/typescript/Card.d.ts +30 -3
  72. package/lib/typescript/Checkbox.d.ts +14 -0
  73. package/lib/typescript/Chip.d.ts +19 -0
  74. package/lib/typescript/Collapsible.d.ts +17 -0
  75. package/lib/typescript/ContextMenu.d.ts +23 -0
  76. package/lib/typescript/Dialog.d.ts +8 -68
  77. package/lib/typescript/DropdownMenu.d.ts +23 -0
  78. package/lib/typescript/Field.d.ts +19 -0
  79. package/lib/typescript/Glass.d.ts +11 -2
  80. package/lib/typescript/Group.d.ts +35 -0
  81. package/lib/typescript/IconButton.d.ts +21 -0
  82. package/lib/typescript/Input.d.ts +17 -18
  83. package/lib/typescript/Label.d.ts +14 -0
  84. package/lib/typescript/MorphGroup.d.ts +46 -0
  85. package/lib/typescript/Popover.d.ts +17 -0
  86. package/lib/typescript/Progress.d.ts +13 -0
  87. package/lib/typescript/RadioGroup.d.ts +21 -0
  88. package/lib/typescript/Scrim.d.ts +33 -0
  89. package/lib/typescript/SegmentedControl.d.ts +24 -13
  90. package/lib/typescript/Select.d.ts +19 -0
  91. package/lib/typescript/Separator.d.ts +10 -0
  92. package/lib/typescript/Sheet.d.ts +45 -0
  93. package/lib/typescript/Skeleton.d.ts +10 -0
  94. package/lib/typescript/Slider.d.ts +15 -7
  95. package/lib/typescript/Stepper.d.ts +49 -0
  96. package/lib/typescript/Switch.d.ts +19 -12
  97. package/lib/typescript/TabBar.d.ts +18 -6
  98. package/lib/typescript/Textarea.d.ts +6 -0
  99. package/lib/typescript/Toast.d.ts +40 -0
  100. package/lib/typescript/Toggle.d.ts +21 -0
  101. package/lib/typescript/ToggleGroup.d.ts +22 -0
  102. package/lib/typescript/Toolbar.d.ts +35 -0
  103. package/lib/typescript/Tooltip.d.ts +16 -0
  104. package/lib/typescript/glass-provider.d.ts +34 -0
  105. package/lib/typescript/glass-stack.d.ts +54 -0
  106. package/lib/typescript/index.d.ts +39 -17
  107. package/lib/typescript/internal/GlassBackdrop.d.ts +33 -0
  108. package/lib/typescript/internal/GlassView.d.ts +31 -2
  109. package/lib/typescript/internal/blur-community.d.ts +2 -0
  110. package/lib/typescript/internal/blur-community.web.d.ts +2 -0
  111. package/lib/typescript/internal/blur.d.ts +24 -0
  112. package/lib/typescript/internal/fallback.d.ts +27 -2
  113. package/lib/typescript/internal/glass-routing.d.ts +83 -15
  114. package/lib/typescript/internal/glow.d.ts +11 -0
  115. package/lib/typescript/internal/initials.d.ts +2 -0
  116. package/lib/typescript/internal/lens.d.ts +47 -0
  117. package/lib/typescript/internal/material.d.ts +27 -0
  118. package/lib/typescript/internal/overlay.d.ts +74 -0
  119. package/lib/typescript/internal/primitives.d.ts +13 -0
  120. package/lib/typescript/internal/rim.d.ts +16 -0
  121. package/lib/typescript/internal/tokens.d.ts +36 -0
  122. package/package.json +15 -4
  123. package/src/Accordion.tsx +165 -0
  124. package/src/ActionSheet.tsx +149 -0
  125. package/src/Alert.tsx +85 -0
  126. package/src/AlertDialog.tsx +124 -0
  127. package/src/Avatar.tsx +102 -0
  128. package/src/Badge.tsx +80 -0
  129. package/src/Bars.tsx +10 -797
  130. package/src/Button.tsx +196 -60
  131. package/src/Card.tsx +106 -33
  132. package/src/Checkbox.tsx +98 -0
  133. package/src/Chip.tsx +149 -0
  134. package/src/Collapsible.tsx +66 -0
  135. package/src/ContextMenu.tsx +103 -0
  136. package/src/Dialog.tsx +86 -325
  137. package/src/DropdownMenu.tsx +103 -0
  138. package/src/Field.tsx +65 -0
  139. package/src/Glass.tsx +19 -5
  140. package/src/Group.tsx +98 -0
  141. package/src/IconButton.tsx +110 -0
  142. package/src/Input.tsx +143 -87
  143. package/src/Label.tsx +56 -0
  144. package/src/MorphGroup.tsx +134 -0
  145. package/src/Popover.tsx +81 -0
  146. package/src/Progress.tsx +83 -0
  147. package/src/RadioGroup.tsx +122 -0
  148. package/src/Scrim.tsx +94 -0
  149. package/src/SegmentedControl.tsx +147 -90
  150. package/src/Select.tsx +136 -0
  151. package/src/Separator.tsx +52 -0
  152. package/src/Sheet.tsx +139 -0
  153. package/src/Skeleton.tsx +77 -0
  154. package/src/Slider.tsx +100 -54
  155. package/src/Stepper.tsx +315 -0
  156. package/src/Switch.tsx +80 -58
  157. package/src/TabBar.tsx +118 -84
  158. package/src/Tabs.tsx +5 -0
  159. package/src/Textarea.tsx +34 -0
  160. package/src/Toast.tsx +131 -0
  161. package/src/Toggle.tsx +113 -0
  162. package/src/ToggleGroup.tsx +129 -0
  163. package/src/Toolbar.tsx +111 -0
  164. package/src/Tooltip.tsx +79 -0
  165. package/src/engine/CHANGELOG.md +430 -0
  166. package/src/engine/NOTICE +54 -0
  167. package/src/engine/README.md +975 -0
  168. package/src/engine/android/build.gradle +18 -0
  169. package/src/engine/android/src/main/AndroidManifest.xml +2 -0
  170. package/src/engine/android/src/main/java/expo/modules/liquidglass/ExpoLiquidGlassModule.kt +174 -0
  171. package/src/engine/android/src/main/java/expo/modules/liquidglass/GlassConstants.kt +7 -0
  172. package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassContainerView.kt +16 -0
  173. package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassProviderView.kt +165 -0
  174. package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassView.kt +1731 -0
  175. package/src/engine/android/src/main/java/expo/modules/liquidglass/enums/GlassEnums.kt +171 -0
  176. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/BackdropGraph.kt +146 -0
  177. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/BackdropSource.kt +53 -0
  178. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/ContinuousCorners.kt +188 -0
  179. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/CornerRadii.kt +62 -0
  180. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassAppearance.kt +352 -0
  181. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassDebug.kt +109 -0
  182. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassEnvironment.kt +139 -0
  183. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassHdr.kt +85 -0
  184. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassLuminanceProbe.kt +189 -0
  185. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassPressAnimator.kt +264 -0
  186. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassProgressiveBlur.kt +249 -0
  187. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassShaderCache.kt +256 -0
  188. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassShaderSource.kt +845 -0
  189. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassTier.kt +63 -0
  190. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/ProviderRegistry.kt +71 -0
  191. package/src/engine/android/src/main/java/expo/modules/liquidglass/records/GlassRecords.kt +288 -0
  192. package/src/engine/index.ts +24 -0
  193. package/src/engine/ios/Enums/GlassBlurDirection.swift +21 -0
  194. package/src/engine/ios/Enums/GlassVariant.swift +86 -0
  195. package/src/engine/ios/ExpoLiquidGlass.podspec +93 -0
  196. package/src/engine/ios/ExpoLiquidGlassModule.swift +77 -0
  197. package/src/engine/ios/Glass/BackdropCapturer.swift +811 -0
  198. package/src/engine/ios/Glass/ContinuousCorners.swift +165 -0
  199. package/src/engine/ios/Glass/GlassBackdrop.swift +176 -0
  200. package/src/engine/ios/Glass/GlassFramePhase.swift +126 -0
  201. package/src/engine/ios/Glass/GlassFrameScheduler.swift +261 -0
  202. package/src/engine/ios/Glass/GlassPressAnimator.swift +250 -0
  203. package/src/engine/ios/Glass/GlassRenderContext.swift +168 -0
  204. package/src/engine/ios/Glass/GlassRenderer.swift +186 -0
  205. package/src/engine/ios/Glass/GlassSurfaceView.swift +452 -0
  206. package/src/engine/ios/Glass/NonRenderableView.swift +54 -0
  207. package/src/engine/ios/Glass/StripCache.swift +545 -0
  208. package/src/engine/ios/Records/GlassCornerRadii.swift +79 -0
  209. package/src/engine/ios/Records/GlassMetalOptions.swift +180 -0
  210. package/src/engine/ios/Records/GlassRefractionCurve.swift +14 -0
  211. package/src/engine/ios/Shaders/LiquidGlass.metal +480 -0
  212. package/src/engine/ios/Shaders/bundle-marker.txt +6 -0
  213. package/src/engine/ios/Views/LiquidGlassContainerView.swift +99 -0
  214. package/src/engine/ios/Views/LiquidGlassView.swift +859 -0
  215. package/src/engine/package.json +70 -0
  216. package/src/engine/src/components/LiquidGlassButton/LiquidGlassButton.tsx +424 -0
  217. package/src/engine/src/components/LiquidGlassCard/LiquidGlassCard.tsx +98 -0
  218. package/src/engine/src/components/LiquidGlassChip/LiquidGlassChip.tsx +65 -0
  219. package/src/engine/src/components/LiquidGlassGroup/LiquidGlassGroup.tsx +350 -0
  220. package/src/engine/src/components/LiquidGlassIconButton/LiquidGlassIconButton.tsx +24 -0
  221. package/src/engine/src/components/LiquidGlassMorphGroup/LiquidGlassMorphGroup.tsx +434 -0
  222. package/src/engine/src/components/LiquidGlassScrim/LiquidGlassScrim.tsx +100 -0
  223. package/src/engine/src/components/LiquidGlassSegmentedControl/LiquidGlassSegmentedControl.tsx +213 -0
  224. package/src/engine/src/components/LiquidGlassSheet/LiquidGlassSheet.tsx +218 -0
  225. package/src/engine/src/components/LiquidGlassSlider/LiquidGlassSlider.tsx +327 -0
  226. package/src/engine/src/components/LiquidGlassStepper/LiquidGlassStepper.tsx +321 -0
  227. package/src/engine/src/components/LiquidGlassSwitch/LiquidGlassSwitch.tsx +296 -0
  228. package/src/engine/src/components/LiquidGlassTabBar/LiquidGlassTabBar.tsx +952 -0
  229. package/src/engine/src/components/LiquidGlassTextInput/LiquidGlassTextInput.tsx +151 -0
  230. package/src/engine/src/components/LiquidGlassToast/LiquidGlassToast.tsx +169 -0
  231. package/src/engine/src/components/LiquidGlassToolbar/LiquidGlassToolbar.tsx +124 -0
  232. package/src/engine/src/components/index.ts +16 -0
  233. package/src/engine/src/constants/index.ts +4 -0
  234. package/src/engine/src/constants/metal.constants.ts +327 -0
  235. package/src/engine/src/constants/metrics.constants.ts +325 -0
  236. package/src/engine/src/constants/springs.constants.ts +107 -0
  237. package/src/engine/src/constants/styles.constants.ts +12 -0
  238. package/src/engine/src/context/glass-group.context.ts +65 -0
  239. package/src/engine/src/context/index.ts +6 -0
  240. package/src/engine/src/core/components/LiquidGlassContainer/LiquidGlassContainer.tsx +32 -0
  241. package/src/engine/src/core/components/LiquidGlassContainer/index.ts +1 -0
  242. package/src/engine/src/core/components/LiquidGlassProvider/LiquidGlassProvider.tsx +66 -0
  243. package/src/engine/src/core/components/LiquidGlassProvider/index.ts +1 -0
  244. package/src/engine/src/core/components/LiquidGlassStack/LiquidGlassStack.tsx +184 -0
  245. package/src/engine/src/core/components/LiquidGlassStack/index.ts +1 -0
  246. package/src/engine/src/core/components/LiquidGlassView/LiquidGlassView.tsx +126 -0
  247. package/src/engine/src/core/components/LiquidGlassView/index.ts +1 -0
  248. package/src/engine/src/core/components/index.ts +4 -0
  249. package/src/engine/src/core/constants/glass.constants.ts +57 -0
  250. package/src/engine/src/core/constants/index.ts +20 -0
  251. package/src/engine/src/core/constants/native.constants.ts +16 -0
  252. package/src/engine/src/core/context/glass-stack.context.ts +30 -0
  253. package/src/engine/src/core/context/index.ts +4 -0
  254. package/src/engine/src/core/enum/index.ts +12 -0
  255. package/src/engine/src/core/index.ts +1 -0
  256. package/src/engine/src/core/interfaces/glass-hdr.interface.ts +15 -0
  257. package/src/engine/src/core/interfaces/glass-metal.interface.ts +248 -0
  258. package/src/engine/src/core/interfaces/glass-surface.interface.ts +9 -0
  259. package/src/engine/src/core/interfaces/index.ts +31 -0
  260. package/src/engine/src/core/interfaces/liquid-glass-container.interface.ts +6 -0
  261. package/src/engine/src/core/interfaces/liquid-glass-provider.interface.ts +14 -0
  262. package/src/engine/src/core/interfaces/liquid-glass-stack.interface.ts +21 -0
  263. package/src/engine/src/core/interfaces/liquid-glass-view.interface.ts +129 -0
  264. package/src/engine/src/core/interfaces/native-liquid-glass-view.interface.ts +19 -0
  265. package/src/engine/src/core/modules/ExpoLiquidGlassModule.ts +26 -0
  266. package/src/engine/src/core/modules/index.ts +2 -0
  267. package/src/engine/src/core/root/index.ts +51 -0
  268. package/src/engine/src/core/types/glass.types.ts +25 -0
  269. package/src/engine/src/core/types/index.ts +8 -0
  270. package/src/engine/src/core/utils/debug.utils.ts +17 -0
  271. package/src/engine/src/core/utils/dev-warn.utils.ts +17 -0
  272. package/src/engine/src/core/utils/hdr.utils.ts +37 -0
  273. package/src/engine/src/core/utils/index.ts +5 -0
  274. package/src/engine/src/core/utils/native-view.utils.ts +33 -0
  275. package/src/engine/src/core/utils/platform.utils.ts +34 -0
  276. package/src/engine/src/core/views/NativeGlassBackdropView.ts +24 -0
  277. package/src/engine/src/core/views/NativeLiquidGlassContainerView.ts +13 -0
  278. package/src/engine/src/core/views/NativeLiquidGlassContainerView.web.ts +10 -0
  279. package/src/engine/src/core/views/NativeLiquidGlassProviderView.ts +13 -0
  280. package/src/engine/src/core/views/NativeLiquidGlassProviderView.web.ts +10 -0
  281. package/src/engine/src/core/views/NativeLiquidGlassView.ts +19 -0
  282. package/src/engine/src/core/views/NativeLiquidGlassView.web.ts +14 -0
  283. package/src/engine/src/core/views/index.ts +4 -0
  284. package/src/engine/src/hooks/index.ts +18 -0
  285. package/src/engine/src/hooks/use-adaptive-glass.ts +91 -0
  286. package/src/engine/src/hooks/use-damped-drag.ts +332 -0
  287. package/src/engine/src/hooks/use-echo-filter.ts +55 -0
  288. package/src/engine/src/hooks/use-glass-group-member.ts +169 -0
  289. package/src/engine/src/hooks/use-gravity-highlight.ts +79 -0
  290. package/src/engine/src/hooks/use-press-progress.ts +44 -0
  291. package/src/engine/src/index.ts +120 -0
  292. package/src/engine/src/interfaces/index.ts +28 -0
  293. package/src/engine/src/interfaces/liquid-glass-button.interface.ts +94 -0
  294. package/src/engine/src/interfaces/liquid-glass-card.interface.ts +40 -0
  295. package/src/engine/src/interfaces/liquid-glass-chip.interface.ts +29 -0
  296. package/src/engine/src/interfaces/liquid-glass-group.interface.ts +32 -0
  297. package/src/engine/src/interfaces/liquid-glass-icon-button.interface.ts +19 -0
  298. package/src/engine/src/interfaces/liquid-glass-morph-group.interface.ts +59 -0
  299. package/src/engine/src/interfaces/liquid-glass-scrim.interface.ts +36 -0
  300. package/src/engine/src/interfaces/liquid-glass-segmented-control.interface.ts +32 -0
  301. package/src/engine/src/interfaces/liquid-glass-sheet.interface.ts +38 -0
  302. package/src/engine/src/interfaces/liquid-glass-slider.interface.ts +37 -0
  303. package/src/engine/src/interfaces/liquid-glass-stepper.interface.ts +35 -0
  304. package/src/engine/src/interfaces/liquid-glass-switch.interface.ts +27 -0
  305. package/src/engine/src/interfaces/liquid-glass-tab-bar.interface.ts +116 -0
  306. package/src/engine/src/interfaces/liquid-glass-text-input.interface.ts +42 -0
  307. package/src/engine/src/interfaces/liquid-glass-toast.interface.ts +36 -0
  308. package/src/engine/src/interfaces/liquid-glass-toolbar.interface.ts +33 -0
  309. package/src/engine/src/theme/glass-ui-theme.ts +100 -0
  310. package/src/engine/src/theme/index.ts +2 -0
  311. package/src/engine/src/utils/button-press.utils.ts +63 -0
  312. package/src/engine/src/utils/index.ts +3 -0
  313. package/src/engine/src/utils/metal.utils.ts +164 -0
  314. package/src/glass-provider.tsx +60 -0
  315. package/src/glass-stack.tsx +115 -0
  316. package/src/index.ts +48 -190
  317. package/src/internal/GlassBackdrop.tsx +60 -0
  318. package/src/internal/GlassView.tsx +70 -18
  319. package/src/internal/blur-community.ts +19 -0
  320. package/src/internal/blur-community.web.ts +7 -0
  321. package/src/internal/blur.ts +89 -0
  322. package/src/internal/fallback.tsx +158 -20
  323. package/src/internal/glass-routing.ts +211 -34
  324. package/src/internal/glow.tsx +62 -0
  325. package/src/internal/initials.ts +7 -0
  326. package/src/internal/lens.tsx +105 -0
  327. package/src/internal/material.ts +92 -0
  328. package/src/internal/overlay.tsx +258 -0
  329. package/src/internal/primitives.ts +26 -0
  330. package/src/internal/rim.tsx +79 -0
  331. package/src/internal/tokens.ts +34 -1
  332. package/lib/module/Carousel.js +0 -103
  333. package/lib/module/Display.js +0 -317
  334. package/lib/module/Feedback.js +0 -386
  335. package/lib/module/Form.js +0 -164
  336. package/lib/module/Forms2.js +0 -454
  337. package/lib/module/Message.js +0 -88
  338. package/lib/module/Overlays.js +0 -328
  339. package/lib/module/Pickers.js +0 -243
  340. package/lib/module/Table.js +0 -99
  341. package/lib/module/ai.js +0 -280
  342. package/lib/module/charts/AreaChart.js +0 -32
  343. package/lib/module/charts/BarChart.js +0 -67
  344. package/lib/module/charts/FunnelChart.js +0 -50
  345. package/lib/module/charts/HeatmapChart.js +0 -71
  346. package/lib/module/charts/LineChart.js +0 -81
  347. package/lib/module/charts/PlotChart.js +0 -52
  348. package/lib/module/charts/RadarChart.js +0 -78
  349. package/lib/module/charts/RingChart.js +0 -52
  350. package/lib/module/charts/ScatterChart.js +0 -95
  351. package/lib/module/charts/WaterfallChart.js +0 -85
  352. package/lib/module/charts/advanced.js +0 -313
  353. package/lib/module/charts/extra.js +0 -108
  354. package/lib/module/charts/index.js +0 -50
  355. package/lib/module/charts/scales.js +0 -140
  356. package/lib/typescript/Carousel.d.ts +0 -47
  357. package/lib/typescript/Display.d.ts +0 -178
  358. package/lib/typescript/Feedback.d.ts +0 -196
  359. package/lib/typescript/Form.d.ts +0 -97
  360. package/lib/typescript/Forms2.d.ts +0 -209
  361. package/lib/typescript/Message.d.ts +0 -71
  362. package/lib/typescript/Overlays.d.ts +0 -146
  363. package/lib/typescript/Pickers.d.ts +0 -105
  364. package/lib/typescript/Table.d.ts +0 -64
  365. package/lib/typescript/ai.d.ts +0 -166
  366. package/lib/typescript/charts/AreaChart.d.ts +0 -44
  367. package/lib/typescript/charts/BarChart.d.ts +0 -19
  368. package/lib/typescript/charts/FunnelChart.d.ts +0 -25
  369. package/lib/typescript/charts/HeatmapChart.d.ts +0 -23
  370. package/lib/typescript/charts/LineChart.d.ts +0 -30
  371. package/lib/typescript/charts/PlotChart.d.ts +0 -31
  372. package/lib/typescript/charts/RadarChart.d.ts +0 -27
  373. package/lib/typescript/charts/RingChart.d.ts +0 -28
  374. package/lib/typescript/charts/ScatterChart.d.ts +0 -34
  375. package/lib/typescript/charts/WaterfallChart.d.ts +0 -22
  376. package/lib/typescript/charts/advanced.d.ts +0 -107
  377. package/lib/typescript/charts/extra.d.ts +0 -63
  378. package/lib/typescript/charts/index.d.ts +0 -13
  379. package/lib/typescript/charts/scales.d.ts +0 -35
  380. package/src/Carousel.tsx +0 -233
  381. package/src/Display.tsx +0 -778
  382. package/src/Feedback.tsx +0 -969
  383. package/src/Form.tsx +0 -425
  384. package/src/Forms2.tsx +0 -1014
  385. package/src/Message.tsx +0 -219
  386. package/src/Overlays.tsx +0 -685
  387. package/src/Pickers.tsx +0 -590
  388. package/src/Table.tsx +0 -231
  389. package/src/ai.tsx +0 -707
  390. package/src/charts/AreaChart.tsx +0 -73
  391. package/src/charts/BarChart.tsx +0 -183
  392. package/src/charts/FunnelChart.tsx +0 -125
  393. package/src/charts/HeatmapChart.tsx +0 -155
  394. package/src/charts/LineChart.tsx +0 -247
  395. package/src/charts/PlotChart.tsx +0 -168
  396. package/src/charts/RadarChart.tsx +0 -208
  397. package/src/charts/RingChart.tsx +0 -133
  398. package/src/charts/ScatterChart.tsx +0 -223
  399. package/src/charts/WaterfallChart.tsx +0 -201
  400. package/src/charts/advanced.tsx +0 -676
  401. package/src/charts/extra.tsx +0 -242
  402. package/src/charts/index.ts +0 -86
  403. package/src/charts/scales.ts +0 -163
package/src/Feedback.tsx DELETED
@@ -1,969 +0,0 @@
1
- import { createContext, forwardRef, useContext, useEffect, useMemo, useRef, useState, type ReactNode } from "react";
2
- import type { StyleProp, ViewStyle } from "react-native";
3
-
4
- import { Glass } from "./Glass";
5
- import { Separator } from "./Display";
6
- import { colors, radii, toneColor, type Tone } 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
- // Toast
13
-
14
- export interface ToastAction {
15
- label: string;
16
- onPress: () => void;
17
- }
18
-
19
- export interface ToastProps {
20
- /** Controlled visibility. Omit it and the toast keeps its own state. */
21
- visible?: boolean;
22
- defaultVisible?: boolean;
23
- onDismiss?: () => void;
24
- message: string;
25
- /** One optional action, e.g. Undo. */
26
- action?: ToastAction;
27
- /** A leading icon (an SVG node the caller supplies). */
28
- icon?: ReactNode;
29
- /**
30
- * Milliseconds before it dismisses itself. 0 keeps it until dismissed.
31
- * The timer is cleared on unmount as well as on dismiss.
32
- */
33
- duration?: number;
34
- tone?: Tone | "neutral";
35
- style?: StyleProp<ViewStyle>;
36
- isDark?: boolean;
37
- testID?: string;
38
- }
39
-
40
- /**
41
- * A transient message on a glass pill.
42
- *
43
- * A toast is not a dialog: it never blocks the screen, so it renders in place
44
- * and lets touches through to what is underneath. It dismisses itself after
45
- * `duration` unless it is controlled or `duration` is 0.
46
- */
47
- export const Toast = forwardRef<any, ToastProps>(function Toast(
48
- {
49
- visible: visibleProp,
50
- defaultVisible = false,
51
- onDismiss,
52
- message,
53
- action,
54
- icon,
55
- duration = 4000,
56
- tone = "neutral",
57
- style,
58
- isDark: isDarkProp,
59
- testID,
60
- ...props
61
- },
62
- ref,
63
- ) {
64
- const isDark = useIsDark(isDarkProp);
65
- const theme = isDark ? colors.dark : colors.light;
66
- const { View, Text: RNText, Pressable } = primitives();
67
-
68
- const [internalVisible, setInternalVisible] = useState(defaultVisible);
69
- const visible = visibleProp !== undefined ? visibleProp : internalVisible;
70
-
71
- const dismiss = () => {
72
- if (visibleProp === undefined) setInternalVisible(false);
73
- onDismiss?.();
74
- };
75
-
76
- // The timer lives and dies with the toast. A ref keeps the latest dismiss
77
- // closure out of the effect's dependencies, so a parent re-render does not
78
- // restart the countdown.
79
- const dismissRef = useRef(dismiss);
80
- dismissRef.current = dismiss;
81
-
82
- useEffect(() => {
83
- if (!visible || duration <= 0) return;
84
- const timer = setTimeout(() => dismissRef.current(), duration);
85
- return () => clearTimeout(timer);
86
- }, [visible, duration]);
87
-
88
- const { value: enter, animated } = useSpring(visible ? 1 : 0, "snappy");
89
- const rise = animated ? enter.interpolate({ inputRange: [0, 1], outputRange: [12, 0] }) : 0;
90
- const fade = animated ? enter.interpolate({ inputRange: [0, 1], outputRange: [0, 1] }) : 1;
91
-
92
- if (!visible) return null;
93
-
94
- const accent = tone === "neutral" ? theme.foreground : toneColor(theme, tone);
95
-
96
- return (
97
- <View
98
- ref={ref}
99
- testID={testID}
100
- pointerEvents="box-none"
101
- style={{ alignItems: "center", ...(style as ViewStyle) }}
102
- {...props}
103
- >
104
- {/* The pill's entrance: it rises and fades in on the springs token. */}
105
- <Entrance animated={animated} rise={rise} fade={fade}>
106
- <Glass
107
- effect="regular"
108
- isDark={isDark}
109
- style={{
110
- flexDirection: "row",
111
- alignItems: "center",
112
- gap: 10,
113
- paddingVertical: 10,
114
- paddingHorizontal: 14,
115
- borderRadius: radii.pill,
116
- maxWidth: 420,
117
- borderColor: tone === "neutral" ? theme.edge : accent,
118
- }}
119
- >
120
- {icon ? <View>{icon}</View> : null}
121
- <RNText
122
- accessibilityRole="alert"
123
- accessibilityLiveRegion="polite"
124
- style={{ fontSize: 14, color: theme.foreground, flexShrink: 1 }}
125
- >
126
- {message}
127
- </RNText>
128
- {action && (
129
- <Pressable
130
- accessibilityRole="button"
131
- accessibilityLabel={action.label}
132
- onPress={action.onPress}
133
- style={{ paddingHorizontal: 4 }}
134
- >
135
- <RNText style={{ fontSize: 14, fontWeight: "600", color: theme.fill }}>
136
- {action.label}
137
- </RNText>
138
- </Pressable>
139
- )}
140
- </Glass>
141
- </Entrance>
142
- </View>
143
- );
144
- });
145
-
146
- /**
147
- * Applies the toast's entrance motion around the pill.
148
- *
149
- * A thin wrapper because animated styles must land on an Animated.View, while
150
- * the pill itself is a Glass — wrapping keeps both honest.
151
- */
152
- function Entrance({
153
- animated,
154
- rise,
155
- fade,
156
- children,
157
- }: {
158
- animated: boolean;
159
- rise: any;
160
- fade: any;
161
- children: ReactNode;
162
- }) {
163
- const { Animated } = primitives();
164
- if (!animated) return <>{children}</>;
165
- return (
166
- <Animated.View style={{ transform: [{ translateY: rise }], opacity: fade }}>
167
- {children}
168
- </Animated.View>
169
- );
170
- }
171
-
172
- // ---------------------------------------------------------------------------
173
- // ToastViewport
174
-
175
- /** One message in a ToastViewport's queue. */
176
- export interface ToastItem {
177
- /** A stable identity. Required, because the queue reorders and dismisses. */
178
- id: string;
179
- message: string;
180
- action?: ToastAction;
181
- icon?: ReactNode;
182
- tone?: Tone | "neutral";
183
- /** Milliseconds before it dismisses itself. 0 keeps it until dismissed. */
184
- duration?: number;
185
- }
186
-
187
- export interface ToastViewportProps {
188
- /** The messages to show. The oldest are dropped when more than 3 arrive. */
189
- toasts: ToastItem[];
190
- /** Called when one leaves, by timer, by swipe or by its action. */
191
- onDismiss: (id: string) => void;
192
- /** How many are visible at once. Extras wait in order. Defaults to 3. */
193
- max?: number;
194
- /** Where the stack sits. */
195
- position?: "top" | "bottom";
196
- style?: StyleProp<ViewStyle>;
197
- isDark?: boolean;
198
- testID?: string;
199
- }
200
-
201
- /**
202
- * A queue of toasts, stacked the way Sonner stacks them.
203
- *
204
- * Three at a time is the practical limit: beyond that the messages stop being
205
- * read and start covering the screen. Extras wait in the order they arrived, so
206
- * no message is lost and the newest is never hidden behind a backlog.
207
- *
208
- * Each toast is independently dismissible — its own timer, its own action, and
209
- * a swipe up. Swiping one up removes only that one.
210
- *
211
- * The single `Toast` keeps working unchanged: this is the host for when an app
212
- * has several messages at once, not a replacement. A caller that shows one
213
- * message continues to use `Toast` directly.
214
- */
215
- export const ToastViewport = forwardRef<any, ToastViewportProps>(function ToastViewport(
216
- { toasts, onDismiss, max = 3, position = "bottom", style, isDark: isDarkProp, testID, ...props },
217
- ref,
218
- ) {
219
- const isDark = useIsDark(isDarkProp);
220
- const theme = isDark ? colors.dark : colors.light;
221
- const { View, PanResponder } = primitives();
222
-
223
- // The visible window is the newest `max`, so a burst shows the latest
224
- // messages rather than a stale backlog. Earlier ones remain queued in the
225
- // caller's array and appear as the visible ones leave.
226
- //
227
- // A host is often rendered for the whole life of a screen and simply has no
228
- // messages yet, so an absent queue means empty rather than a crash.
229
- const visible = (toasts ?? []).slice(0, Math.max(0, max));
230
-
231
- return (
232
- <View
233
- ref={ref}
234
- testID={testID}
235
- pointerEvents="box-none"
236
- style={{
237
- position: "absolute",
238
- left: 0,
239
- right: 0,
240
- alignItems: "center",
241
- gap: 8,
242
- ...(position === "top" ? { top: 16 } : { bottom: 16 }),
243
- ...(style as ViewStyle),
244
- }}
245
- {...props}
246
- >
247
- {visible.map((toast) => (
248
- <SwipeableToast
249
- key={toast.id}
250
- toast={toast}
251
- isDark={isDark}
252
- onDismiss={() => onDismiss(toast.id)}
253
- theme={theme}
254
- />
255
- ))}
256
- </View>
257
- );
258
- });
259
-
260
- /**
261
- * One toast inside the viewport, with the swipe-up dismissal.
262
- *
263
- * Wrapping the existing Toast would have meant threading the gesture through
264
- * its props, so the viewport renders the same pill with the gesture attached —
265
- * the styling lives in one place (`Toast`), and this adds only the drag.
266
- */
267
- function SwipeableToast({
268
- toast,
269
- isDark,
270
- onDismiss,
271
- theme,
272
- }: {
273
- toast: ToastItem;
274
- isDark: boolean;
275
- onDismiss: () => void;
276
- theme: any;
277
- }) {
278
- const { View, Text: RNText, Pressable, PanResponder, Animated } = primitives();
279
- const [lift, setLift] = useState(0);
280
- const dismissRef = useRef(onDismiss);
281
- dismissRef.current = onDismiss;
282
-
283
- const duration = toast.duration ?? 4000;
284
- useEffect(() => {
285
- if (duration <= 0) return;
286
- const timer = setTimeout(() => dismissRef.current(), duration);
287
- return () => clearTimeout(timer);
288
- }, [duration]);
289
-
290
- const panResponder = useMemo(() => {
291
- if (!PanResponder?.create) return null;
292
- return PanResponder.create({
293
- onMoveShouldSetPanResponder: (_event: any, gesture: any) =>
294
- // Only an upward swipe removes a toast; downward drags are ignored.
295
- gesture.dy < -8 && Math.abs(gesture.dy) > Math.abs(gesture.dx),
296
- onPanResponderMove: (_event: any, gesture: any) => setLift(Math.min(0, gesture.dy)),
297
- onPanResponderRelease: (_event: any, gesture: any) => {
298
- // A quick flick or a long drag removes it; anything less springs back.
299
- if (gesture.dy < -40 || gesture.vy < -0.5) {
300
- dismissRef.current();
301
- } else {
302
- setLift(0);
303
- }
304
- },
305
- onPanResponderTerminate: () => setLift(0),
306
- });
307
- }, [PanResponder]);
308
-
309
- const tone = toast.tone ?? "neutral";
310
- const accent = tone === "neutral" ? theme.foreground : toneColor(theme, tone);
311
-
312
- const pill = (
313
- <Glass
314
- effect="regular"
315
- isDark={isDark}
316
- style={{
317
- flexDirection: "row",
318
- alignItems: "center",
319
- gap: 10,
320
- paddingVertical: 10,
321
- paddingHorizontal: 14,
322
- borderRadius: radii.pill,
323
- maxWidth: 420,
324
- borderColor: tone === "neutral" ? theme.edge : accent,
325
- }}
326
- >
327
- {toast.icon ? <View>{toast.icon}</View> : null}
328
- <RNText
329
- accessibilityRole="alert"
330
- accessibilityLiveRegion="polite"
331
- style={{ fontSize: 14, color: theme.foreground, flexShrink: 1 }}
332
- >
333
- {toast.message}
334
- </RNText>
335
- {toast.action ? (
336
- <Pressable
337
- accessibilityRole="button"
338
- accessibilityLabel={toast.action.label}
339
- onPress={() => {
340
- toast.action?.onPress();
341
- onDismiss();
342
- }}
343
- style={{ paddingHorizontal: 4 }}
344
- >
345
- <RNText style={{ fontSize: 14, fontWeight: "600", color: theme.fill }}>
346
- {toast.action.label}
347
- </RNText>
348
- </Pressable>
349
- ) : null}
350
- </Glass>
351
- );
352
-
353
- return (
354
- <View
355
- style={{ transform: [{ translateY: lift }], opacity: lift === 0 ? 1 : Math.max(0.4, 1 + lift / 120) }}
356
- {...(panResponder ? panResponder.panHandlers : {})}
357
- >
358
- {pill}
359
- </View>
360
- );
361
- }
362
-
363
- // ---------------------------------------------------------------------------
364
- // Banner
365
-
366
- export interface BannerProps {
367
- title?: string;
368
- message: string;
369
- tone?: Tone;
370
- /** A leading icon node. */
371
- icon?: ReactNode;
372
- /** Shows a dismiss button when provided. */
373
- onDismiss?: () => void;
374
- /** A single inline action, e.g. Retry. */
375
- action?: ToastAction;
376
- style?: StyleProp<ViewStyle>;
377
- isDark?: boolean;
378
- testID?: string;
379
- }
380
-
381
- /**
382
- * An inline alert.
383
- *
384
- * Unlike AlertDialog it is not modal and not an overlay: it sits in the layout
385
- * and pushes the content below it down. The surface is glass with the tone's
386
- * colour as its edge, so the tone reads at a glance without turning the whole
387
- * panel into a solid block of colour.
388
- */
389
- export const Banner = forwardRef<any, BannerProps>(function Banner(
390
- { title, message, tone = "info", icon, onDismiss, action, style, isDark: isDarkProp, testID, ...props },
391
- ref,
392
- ) {
393
- const isDark = useIsDark(isDarkProp);
394
- const theme = isDark ? colors.dark : colors.light;
395
- const { View, Text: RNText, Pressable } = primitives();
396
- const accent = toneColor(theme, tone);
397
-
398
- return (
399
- <Glass
400
- ref={ref}
401
- effect="regular"
402
- isDark={isDark}
403
- testID={testID}
404
- style={{ borderRadius: radii.md, borderColor: accent, ...(style as ViewStyle) }}
405
- {...props}
406
- >
407
- <View style={{ flexDirection: "row", alignItems: "flex-start", gap: 10, padding: 12 }}>
408
- {icon ? <View style={{ paddingTop: 1 }}>{icon}</View> : null}
409
- <View style={{ flex: 1, gap: 2 }}>
410
- {title && (
411
- <RNText
412
- accessibilityRole="heading"
413
- style={{ fontSize: 14, fontWeight: "600", color: theme.foreground }}
414
- >
415
- {title}
416
- </RNText>
417
- )}
418
- <RNText accessibilityRole="alert" style={{ fontSize: 13, color: theme.muted, lineHeight: 18 }}>
419
- {message}
420
- </RNText>
421
- {action && (
422
- <Pressable
423
- accessibilityRole="button"
424
- accessibilityLabel={action.label}
425
- onPress={action.onPress}
426
- style={{ alignSelf: "flex-start", paddingTop: 6 }}
427
- >
428
- <RNText style={{ fontSize: 13, fontWeight: "600", color: accent }}>
429
- {action.label}
430
- </RNText>
431
- </Pressable>
432
- )}
433
- </View>
434
- {onDismiss && (
435
- <Pressable
436
- accessibilityRole="button"
437
- accessibilityLabel="Dismiss"
438
- onPress={onDismiss}
439
- hitSlop={8}
440
- style={{ padding: 2 }}
441
- >
442
- <RNText style={{ fontSize: 15, color: theme.muted }}>{"\u00D7"}</RNText>
443
- </Pressable>
444
- )}
445
- </View>
446
- </Glass>
447
- );
448
- });
449
-
450
- // ---------------------------------------------------------------------------
451
- // List
452
-
453
- /** One action revealed by swiping a row. */
454
- export interface ListSwipeAction {
455
- label: string;
456
- /** A leading node, typically an SVG icon the caller supplies. */
457
- icon?: ReactNode;
458
- /** The action's tint. Defaults to the theme's fill. */
459
- color?: string;
460
- onPress: () => void;
461
- }
462
-
463
- export interface ListItemProps {
464
- /** An avatar, icon or other leading node. */
465
- leading?: ReactNode;
466
- /** The row's main text. */
467
- title: string;
468
- /** Secondary line under the title. */
469
- description?: string;
470
- /** A value text, a control, or any trailing node. */
471
- trailing?: ReactNode;
472
- /** Draws a chevron when the row is tappable and nothing else trails it. */
473
- chevron?: boolean;
474
- onPress?: () => void;
475
- disabled?: boolean;
476
- selected?: boolean;
477
- /** Actions revealed by swiping right (towards the trailing edge). */
478
- swipeActions?: ListSwipeAction[];
479
- /** Actions revealed by swiping left. */
480
- leadingSwipeActions?: ListSwipeAction[];
481
- /** Width allotted to each revealed action button. */
482
- swipeActionWidth?: number;
483
- /** Turns the swipe gesture off, leaving the row's `onPress` only. */
484
- swipeable?: boolean;
485
- /** Opt out of the selection tick when a swipe opens. */
486
- haptics?: boolean;
487
- style?: StyleProp<ViewStyle>;
488
- isDark?: boolean;
489
- testID?: string;
490
- }
491
-
492
- /**
493
- * Tracks which row of a List is open, so opening one closes the rest.
494
- *
495
- * A list with two open rows looks broken; iOS Mail and every kit that copied
496
- * it keep at most one. The List provides the registry and each swipeable row
497
- * registers its own close function.
498
- */
499
- const OpenRowContext = createContext<{
500
- openId: string | null;
501
- setOpenId: (id: string | null) => void;
502
- } | null>(null);
503
-
504
- /**
505
- * One row of a List.
506
- *
507
- * The row is a Pressable when it has an `onPress`, and inert otherwise, which
508
- * is what the platform expects: a row that does nothing should not announce
509
- * itself as a button. The chevron is decoration and is hidden from screen
510
- * readers, since the row's own role already says it is tappable.
511
- */
512
- export const ListItem = forwardRef<any, ListItemProps>(function ListItem(
513
- {
514
- leading,
515
- title,
516
- description,
517
- trailing,
518
- chevron,
519
- onPress,
520
- disabled = false,
521
- selected = false,
522
- swipeActions,
523
- leadingSwipeActions,
524
- swipeActionWidth = 78,
525
- swipeable = true,
526
- haptics = true,
527
- style,
528
- isDark: isDarkProp,
529
- testID,
530
- ...props
531
- },
532
- ref,
533
- ) {
534
- const isDark = useIsDark(isDarkProp);
535
- const theme = isDark ? colors.dark : colors.light;
536
- const { View, Text: RNText, Pressable, PanResponder } = primitives();
537
- const rowGroup = useContext(OpenRowContext);
538
-
539
- const interactive = Boolean(onPress) && !disabled;
540
- const showChevron = interactive && chevron !== false && trailing === undefined;
541
-
542
- const trailActions = swipeActions?.filter(Boolean) ?? [];
543
- const leadActions = leadingSwipeActions?.filter(Boolean) ?? [];
544
- const canSwipe = swipeable && !disabled && (trailActions.length > 0 || leadActions.length > 0);
545
-
546
- // The row's own identity, so a List can close its siblings.
547
- const rowId = useRef<string>(`row-${Math.random().toString(36).slice(2)}`);
548
-
549
- // 0 is closed; a positive offset reveals trailing actions, negative leading.
550
- const [offset, setOffset] = useState(0);
551
- const offsetRef = useRef(0);
552
- offsetRef.current = offset;
553
- // A gesture that moved is a swipe, not a tap: the press that follows the
554
- // release must not fire the row's onPress.
555
- const swipedRef = useRef(false);
556
-
557
- const trailingWidth = trailActions.length * swipeActionWidth;
558
- const leadingWidth = leadActions.length * swipeActionWidth;
559
-
560
- const close = () => setOffset(0);
561
-
562
- // When another row opens, this one closes.
563
- useEffect(() => {
564
- if (rowGroup && rowGroup.openId !== rowId.current && offsetRef.current !== 0) {
565
- setOffset(0);
566
- }
567
- }, [rowGroup?.openId]);
568
-
569
- const settle = (next: number) => {
570
- setOffset(next);
571
- if (rowGroup) {
572
- rowGroup.setOpenId(next !== 0 ? rowId.current : null);
573
- }
574
- if (next !== 0 && haptics && offsetRef.current === 0) hapticSelection();
575
- };
576
-
577
- const panResponder = useMemo(() => {
578
- if (!canSwipe || !PanResponder?.create) return null;
579
- return PanResponder.create({
580
- // A horizontal drag claims the gesture; a vertical one stays with the
581
- // surrounding scroll view.
582
- onMoveShouldSetPanResponder: (_event: any, gesture: any) =>
583
- Math.abs(gesture.dx) > Math.abs(gesture.dy) && Math.abs(gesture.dx) > 8,
584
- onPanResponderGrant: () => {
585
- swipedRef.current = false;
586
- },
587
- onPanResponderMove: (_event: any, gesture: any) => {
588
- if (Math.abs(gesture.dx) > 4) swipedRef.current = true;
589
- const from = offsetRef.current;
590
- let next = from + gesture.dx;
591
- // Do not drag past what the actions actually occupy; a small
592
- // overshoot makes the edge feel elastic rather than hard.
593
- next = Math.min(next, trailingWidth + 24);
594
- next = Math.max(next, -(leadingWidth + 24));
595
- setOffset(next);
596
- },
597
- onPanResponderRelease: (_event: any, gesture: any) => {
598
- const released = offsetRef.current;
599
- // Beyond half an action, or with a decisive flick, it stays open;
600
- // otherwise it falls back closed.
601
- if (gesture.dx > 0 && trailActions.length > 0) {
602
- settle(released > trailingWidth / 2 || gesture.vx > 0.5 ? trailingWidth : 0);
603
- } else if (gesture.dx < 0 && leadActions.length > 0) {
604
- settle(released < -leadingWidth / 2 || gesture.vx < -0.5 ? -leadingWidth : 0);
605
- } else {
606
- settle(offsetRef.current > 0 ? Math.min(offsetRef.current, trailingWidth) : Math.max(offsetRef.current, -leadingWidth));
607
- }
608
- },
609
- onPanResponderTerminate: () => settle(0),
610
- onPanResponderTerminationRequest: () => false,
611
- });
612
- // The responder reads from refs, so it never acts on a stale offset.
613
- }, [canSwipe, PanResponder, trailingWidth, leadingWidth, trailActions.length, leadActions.length]);
614
-
615
- /**
616
- * Runs an action and closes the row.
617
- *
618
- * The action is dispatched first so its own feedback is not delayed by the
619
- * close, then the row resets — the reveal should not outlive the press.
620
- */
621
- const runAction = (action: ListSwipeAction) => {
622
- action.onPress();
623
- settle(0);
624
- if (rowGroup) rowGroup.setOpenId(null);
625
- };
626
-
627
- const guardPress = (handler?: () => void) => () => {
628
- // Swallow the press that ends a swipe.
629
- if (swipedRef.current) {
630
- swipedRef.current = false;
631
- return;
632
- }
633
- handler?.();
634
- };
635
-
636
- const content = (
637
- <>
638
- {leading ? <View style={{ marginRight: 12 }}>{leading}</View> : null}
639
- <View style={{ flex: 1, gap: 2 }}>
640
- <RNText
641
- numberOfLines={1}
642
- style={{ fontSize: 16, color: theme.foreground, fontWeight: "400" }}
643
- >
644
- {title}
645
- </RNText>
646
- {description ? (
647
- <RNText numberOfLines={2} style={{ fontSize: 13, color: theme.muted, lineHeight: 17 }}>
648
- {description}
649
- </RNText>
650
- ) : null}
651
- </View>
652
- {trailing ? <View style={{ marginLeft: 8 }}>{trailing}</View> : null}
653
- {showChevron ? (
654
- <RNText accessibilityElementsHidden importantForAccessibility="no" style={{ marginLeft: 6, fontSize: 17, color: theme.muted }}>
655
- {"\u203A"}
656
- </RNText>
657
- ) : null}
658
- </>
659
- );
660
-
661
- const rowStyle: ViewStyle = {
662
- flexDirection: "row",
663
- alignItems: "center",
664
- minHeight: 48,
665
- paddingVertical: 10,
666
- paddingHorizontal: 14,
667
- backgroundColor: selected ? theme.glassActive : "transparent",
668
- opacity: disabled ? 0.38 : 1,
669
- ...(style as ViewStyle),
670
- };
671
-
672
- const rowInner = !interactive ? (
673
- <View accessibilityRole="text" accessibilityState={{ disabled }} style={rowStyle}>
674
- {content}
675
- </View>
676
- ) : (
677
- <Pressable
678
- accessibilityRole="button"
679
- accessibilityLabel={description ? `${title}, ${description}` : title}
680
- accessibilityState={{ selected, disabled }}
681
- disabled={disabled}
682
- onPress={guardPress(onPress)}
683
- style={({ pressed }: { pressed: boolean }) => ({ ...rowStyle, opacity: pressed ? 0.7 : rowStyle.opacity })}
684
- >
685
- {content}
686
- </Pressable>
687
- );
688
-
689
- if (!canSwipe) {
690
- return (
691
- <View ref={ref} testID={testID} style={{ overflow: "hidden" }} {...props}>
692
- {rowInner}
693
- </View>
694
- );
695
- }
696
-
697
- /** The tinted tray behind the row: glass-tinted actions, flat not glass. */
698
- const tray = (actions: ListSwipeAction[], edge: "left" | "right") => (
699
- <View
700
- style={{
701
- position: "absolute",
702
- top: 0,
703
- bottom: 0,
704
- [edge]: 0,
705
- flexDirection: "row",
706
- }}
707
- >
708
- {actions.map((action, index) => (
709
- <Pressable
710
- key={`${action.label}-${index}`}
711
- accessibilityRole="button"
712
- accessibilityLabel={action.label}
713
- onPress={() => runAction(action)}
714
- style={{
715
- width: swipeActionWidth,
716
- alignItems: "center",
717
- justifyContent: "center",
718
- gap: 3,
719
- backgroundColor: action.color ?? theme.glassActive,
720
- }}
721
- >
722
- {action.icon}
723
- <RNText style={{ fontSize: 12, color: theme.foreground }} numberOfLines={1}>
724
- {action.label}
725
- </RNText>
726
- </Pressable>
727
- ))}
728
- </View>
729
- );
730
-
731
- return (
732
- <View
733
- ref={ref}
734
- testID={testID}
735
- accessibilityRole="none"
736
- style={{ overflow: "hidden" }}
737
- {...props}
738
- >
739
- {leadActions.length > 0 ? tray(leadActions, "right") : null}
740
- {trailActions.length > 0 ? tray(trailActions, "left") : null}
741
- <View
742
- style={{
743
- transform: [{ translateX: offset }],
744
- // The row rides over its tray while it is open, so the actions are
745
- // uncovered rather than shown alongside.
746
- backgroundColor: "transparent",
747
- }}
748
- {...(panResponder ? panResponder.panHandlers : {})}
749
- >
750
- {rowInner}
751
- </View>
752
- </View>
753
- );
754
- });
755
-
756
- export interface ListProps {
757
- children?: ReactNode;
758
- /** Renders the rows on one glass panel with separators between them. */
759
- inset?: boolean;
760
- style?: StyleProp<ViewStyle>;
761
- isDark?: boolean;
762
- testID?: string;
763
- }
764
-
765
- /**
766
- * A grouped list of rows — the backbone of settings and profile screens.
767
- *
768
- * With `inset`, the rows sit on one glass panel with hairline separators, which
769
- * is the shape iOS settings screens use. The separators are drawn by the
770
- * caller's ListItem spacing rather than by nesting glass inside glass.
771
- */
772
- export const List = forwardRef<any, ListProps>(function List(
773
- { children, inset = false, style, isDark: isDarkProp, testID, ...props },
774
- ref,
775
- ) {
776
- const isDark = useIsDark(isDarkProp);
777
- const { View } = primitives();
778
-
779
- const rows = Array.isArray(children) ? children.filter(Boolean) : children == null ? [] : [children];
780
-
781
- // At most one swipeable row is open at a time, so a list never shows two
782
- // trays at once.
783
- const [openId, setOpenId] = useState<string | null>(null);
784
- const group = useMemo(() => ({ openId, setOpenId }), [openId]);
785
-
786
- const body = (
787
- <OpenRowContext.Provider value={group}>
788
- <View style={{ gap: 2 }}>
789
- {rows.map((row, index) => (
790
- <View key={index}>
791
- {index > 0 ? <Separator isDark={isDark} inset={inset ? 14 : 0} /> : null}
792
- {row}
793
- </View>
794
- ))}
795
- </View>
796
- </OpenRowContext.Provider>
797
- );
798
-
799
- if (!inset) {
800
- return (
801
- <View ref={ref} testID={testID} style={style} {...props}>
802
- {body}
803
- </View>
804
- );
805
- }
806
-
807
- return (
808
- <Glass
809
- ref={ref}
810
- effect="regular"
811
- isDark={isDark}
812
- testID={testID}
813
- style={{ borderRadius: radii.md, overflow: "hidden", ...(style as ViewStyle) }}
814
- {...props}
815
- >
816
- {body}
817
- </Glass>
818
- );
819
- });
820
-
821
- /** A titled group of rows, e.g. "Account" above its settings. */
822
- export interface ListSectionProps {
823
- header?: string;
824
- children?: ReactNode;
825
- style?: StyleProp<ViewStyle>;
826
- isDark?: boolean;
827
- testID?: string;
828
- }
829
-
830
- export const ListSection = forwardRef<any, ListSectionProps>(function ListSection(
831
- { header, children, style, isDark: isDarkProp, testID, ...props },
832
- ref,
833
- ) {
834
- const isDark = useIsDark(isDarkProp);
835
- const theme = isDark ? colors.dark : colors.light;
836
- const { View, Text: RNText } = primitives();
837
-
838
- return (
839
- <View ref={ref} testID={testID} style={[{ gap: 6 }, style as ViewStyle]} {...props}>
840
- {header ? (
841
- <RNText
842
- accessibilityRole="heading"
843
- style={{
844
- fontSize: 12,
845
- fontWeight: "600",
846
- letterSpacing: 0.4,
847
- textTransform: "uppercase",
848
- color: theme.muted,
849
- paddingHorizontal: 14,
850
- }}
851
- >
852
- {header}
853
- </RNText>
854
- ) : null}
855
- <List inset isDark={isDark}>
856
- {children}
857
- </List>
858
- </View>
859
- );
860
- });
861
-
862
- // ---------------------------------------------------------------------------
863
- // Accordion
864
-
865
- export interface AccordionSection {
866
- /** Stable identity for the section. */
867
- value: string;
868
- title: string;
869
- /** Optional second line in the header. */
870
- description?: string;
871
- content: ReactNode;
872
- }
873
-
874
- export interface AccordionProps {
875
- sections: AccordionSection[];
876
- /** Allow several sections open at once. */
877
- multiple?: boolean;
878
- /** Controlled open sections. Omit for uncontrolled. */
879
- openSections?: string[];
880
- defaultOpenSections?: string[];
881
- onOpenSectionsChange?: (open: string[]) => void;
882
- style?: StyleProp<ViewStyle>;
883
- isDark?: boolean;
884
- testID?: string;
885
- }
886
-
887
- /**
888
- * Expandable sections.
889
- *
890
- * The header is a Pressable reporting `expanded`; the panel is measured with
891
- * the height the content reports and animated on the springs token, so the
892
- * reveal is a real transition rather than an instant jump.
893
- */
894
- export const Accordion = forwardRef<any, AccordionProps>(function Accordion(
895
- {
896
- sections,
897
- multiple = false,
898
- openSections: openProp,
899
- defaultOpenSections = [],
900
- onOpenSectionsChange,
901
- style,
902
- isDark: isDarkProp,
903
- testID,
904
- ...props
905
- },
906
- ref,
907
- ) {
908
- const isDark = useIsDark(isDarkProp);
909
- const theme = isDark ? colors.dark : colors.light;
910
- const { View, Text: RNText, Pressable } = primitives();
911
-
912
- const [internalOpen, setInternalOpen] = useState<string[]>(defaultOpenSections);
913
- const open = openProp !== undefined ? openProp : internalOpen;
914
-
915
- const toggle = (value: string) => {
916
- const isOpen = open.includes(value);
917
- let next: string[];
918
- if (isOpen) next = open.filter((item) => item !== value);
919
- else next = multiple ? [...open, value] : [value];
920
- if (openProp === undefined) setInternalOpen(next);
921
- onOpenSectionsChange?.(next);
922
- };
923
-
924
- return (
925
- <Glass
926
- ref={ref}
927
- effect="regular"
928
- isDark={isDark}
929
- testID={testID}
930
- style={{ borderRadius: radii.md, overflow: "hidden", ...(style as ViewStyle) }}
931
- {...props}
932
- >
933
- {sections.map((section, index) => {
934
- const expanded = open.includes(section.value);
935
- return (
936
- <View key={section.value}>
937
- {index > 0 ? <Separator isDark={isDark} /> : null}
938
- <Pressable
939
- accessibilityRole="button"
940
- accessibilityLabel={section.title}
941
- accessibilityState={{ expanded }}
942
- onPress={() => toggle(section.value)}
943
- style={{ paddingVertical: 12, paddingHorizontal: 14, flexDirection: "row", alignItems: "center" }}
944
- >
945
- <View style={{ flex: 1, gap: 2 }}>
946
- <RNText style={{ fontSize: 15, fontWeight: "500", color: theme.foreground }}>
947
- {section.title}
948
- </RNText>
949
- {section.description ? (
950
- <RNText style={{ fontSize: 13, color: theme.muted }}>{section.description}</RNText>
951
- ) : null}
952
- </View>
953
- <RNText
954
- accessibilityElementsHidden
955
- importantForAccessibility="no"
956
- style={{ fontSize: 13, color: theme.muted, marginLeft: 8 }}
957
- >
958
- {expanded ? "\u2303" : "\u2304"}
959
- </RNText>
960
- </Pressable>
961
- {expanded ? (
962
- <View style={{ paddingHorizontal: 14, paddingBottom: 12 }}>{section.content}</View>
963
- ) : null}
964
- </View>
965
- );
966
- })}
967
- </Glass>
968
- );
969
- });