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
@@ -0,0 +1,332 @@
1
+ import { useMemo } from "react";
2
+ import type { FrameInfo, SharedValue } from "react-native-reanimated";
3
+ import { useFrameCallback, useSharedValue } from "react-native-reanimated";
4
+
5
+ import type { ISpringSpec } from "../constants";
6
+ import {
7
+ SCALE_X_SPEC,
8
+ SCALE_Y_SPEC,
9
+ VALUE_SPEC,
10
+ VELOCITY_SPEC,
11
+ } from "../constants";
12
+
13
+ /** The reference's jelly: velocity (already divided) times these, clamped to ±`JELLY_LIMIT`. */
14
+ const JELLY_STRETCH_X = 0.75;
15
+ const JELLY_SQUASH_Y = 0.25;
16
+ const JELLY_LIMIT = 0.2;
17
+
18
+ /**
19
+ * The catalog's `DampedDragAnimation`, ported whole.
20
+ *
21
+ * Five spring channels advance together every frame: the value follower, press progress, the two
22
+ * grab scales, and a low-passed velocity. They are integrated here rather than driven by
23
+ * `withSpring` for one reason — Compose's `Animatable.animateTo` **inherits the current velocity**
24
+ * when it is re-targeted mid-flight, and `withSpring` does not. A drag re-targets the follower on
25
+ * every touch move, so without inherited velocity the pill visibly notches at each event. A
26
+ * semi-implicit Euler integrator gets that continuity for free: retargeting only changes where the
27
+ * spring is pulling, never the state it carries.
28
+ *
29
+ * The frame callback stays registered and cheaply early-outs when everything is at rest, rather
30
+ * than being toggled with `setActive`. Toggling would route gesture start through `runOnJS`, and a
31
+ * busy JS thread could then delay the first frame of the animation — exactly the failure this kit
32
+ * exists to avoid.
33
+ */
34
+
35
+ /** Semi-implicit Euler is stable here well past this, but substepping keeps k=1000 honest. */
36
+ const MAX_STEP_SECONDS = 1 / 60;
37
+
38
+ /** The reference's release gate: deflate once the follower is within 2.5% of the span. */
39
+ const CONVERGENCE_FRACTION = 0.025;
40
+
41
+ /**
42
+ * Velocity below this is treated as zero when deciding whether the system has settled, in
43
+ * range-fractions per second. The channel this gates is the *smoothed* one that feeds the jelly,
44
+ * and it rings down on an underdamped spring for a good third of a second after the follower
45
+ * has already landed; at 0.01 the deflate waited out that whole ring-down (a pill sat inflated
46
+ * ~0.3 s after arriving, which reads as lag, not as liquid). At 0.15 the residual stretch is
47
+ * ~1 % — below what the eye separates from rest — and the deflate starts on arrival.
48
+ */
49
+ const VELOCITY_REST = 0.15;
50
+
51
+ /**
52
+ * The window the follower's velocity is averaged over before it reaches its spring, matching the
53
+ * span a Compose `VelocityTracker` least-squares-fits. See the integrator.
54
+ */
55
+ const VELOCITY_WINDOW_SECONDS = 0.1;
56
+
57
+ interface IDampedDragConfig {
58
+ /** Inclusive range the follower is clamped to, e.g. `[0, tabCount - 1]`. */
59
+ range: [number, number];
60
+ initialValue: number;
61
+ /** Scale at rest. The reference always uses 1. */
62
+ initialScale?: number;
63
+ /** Scale while grabbed — `78/56` for the tab pill, `1.5` for the thumbs. */
64
+ pressedScale: number;
65
+ /**
66
+ * Velocity is divided by this before it reaches the jelly. The reference uses 10 for
67
+ * full-width controls (tab pill, slider) and 50 for short-throw ones (toggle).
68
+ */
69
+ velocityDivisor: number;
70
+ /**
71
+ * The follower's spring. Defaults to the reference's critically damped `spring(1, 1000)`,
72
+ * which lands dead on the value; the tab bar passes an overshooting one so the pill overruns
73
+ * its tab and settles back, as iOS 26's does. Press progress is not affected — the inflate
74
+ * always runs the reference's spring.
75
+ */
76
+ valueSpring?: ISpringSpec;
77
+ /**
78
+ * The jelly's reach. `gain` multiplies the reference's velocity-to-stretch mapping (0.75 on
79
+ * X, 0.25 on Y) and `limit` caps the stretch, both defaulting to the reference's (gain 1,
80
+ * limit 0.2 — at most 1.25x wide). The tab bar runs gain 2 / limit 0.45 for iOS 26's hotdog.
81
+ */
82
+ jelly?: { gain?: number; limit?: number };
83
+ }
84
+
85
+ interface IDampedDrag {
86
+ /** The damped follower — read this for position. */
87
+ value: SharedValue<number>;
88
+ /** The spring's goal. A drag moves this; `value` chases it. */
89
+ targetValue: SharedValue<number>;
90
+ pressProgress: SharedValue<number>;
91
+ scaleX: SharedValue<number>;
92
+ scaleY: SharedValue<number>;
93
+ /** Smoothed follower velocity, in range-fractions per second. */
94
+ velocity: SharedValue<number>;
95
+ /** Inflate and light up. Call on touch-down, with no slop. */
96
+ press: () => void;
97
+ /** Deflate — but only once the follower has essentially arrived. */
98
+ release: () => void;
99
+ /** Add to the target, clamped to the range. */
100
+ dragBy: (delta: number) => void;
101
+ /** The full grab choreography for a programmatic move: press, fly, release on arrival. */
102
+ animateTo: (next: number) => void;
103
+ /** The velocity-driven squash/stretch, ready to spread into a transform. */
104
+ jelly: () => { scaleX: number; scaleY: number };
105
+ }
106
+
107
+ function useDampedDrag(config: IDampedDragConfig): IDampedDrag {
108
+ const {
109
+ range,
110
+ initialValue,
111
+ initialScale = 1,
112
+ pressedScale,
113
+ velocityDivisor,
114
+ valueSpring,
115
+ jelly: jellyConfig,
116
+ } = config;
117
+ const valueSpec = valueSpring ?? VALUE_SPEC;
118
+ const jellyGain = jellyConfig?.gain ?? 1;
119
+ const jellyLimit = jellyConfig?.limit ?? JELLY_LIMIT;
120
+
121
+ const value = useSharedValue(initialValue);
122
+ const targetValue = useSharedValue(initialValue);
123
+ const pressProgress = useSharedValue(0);
124
+ const scaleX = useSharedValue(initialScale);
125
+ const scaleY = useSharedValue(initialScale);
126
+ const velocity = useSharedValue(0);
127
+
128
+ // Integrator state, one velocity per channel.
129
+ const valueRate = useSharedValue(0);
130
+ const pressRate = useSharedValue(0);
131
+ const scaleXRate = useSharedValue(0);
132
+ const scaleYRate = useSharedValue(0);
133
+ const velocityRate = useSharedValue(0);
134
+
135
+ const pressTarget = useSharedValue(0);
136
+ const scaleTarget = useSharedValue(initialScale);
137
+ const rawVelocity = useSharedValue(0);
138
+ const previousValue = useSharedValue(initialValue);
139
+ /** Set by `release()`; the integrator honours it once the follower converges. */
140
+ const releasePending = useSharedValue(false);
141
+ /** False during a programmatic snap — the reference stops sampling velocity there. */
142
+ const trackVelocity = useSharedValue(true);
143
+
144
+ const lower = range[0];
145
+ const upper = range[1];
146
+ const span = Math.max(upper - lower, 1e-6);
147
+
148
+ useFrameCallback((frame: FrameInfo): void => {
149
+ "worklet";
150
+ const elapsed = frame.timeSincePreviousFrame;
151
+ if (elapsed == null || elapsed <= 0) return;
152
+
153
+ const settled =
154
+ Math.abs(value.value - targetValue.value) < 1e-4 &&
155
+ Math.abs(valueRate.value) < 1e-3 &&
156
+ Math.abs(pressProgress.value - pressTarget.value) < 1e-4 &&
157
+ Math.abs(pressRate.value) < 1e-3 &&
158
+ Math.abs(scaleX.value - scaleTarget.value) < 1e-5 &&
159
+ Math.abs(scaleY.value - scaleTarget.value) < 1e-5 &&
160
+ Math.abs(velocity.value) < 1e-4 &&
161
+ !releasePending.value;
162
+ if (settled) return;
163
+
164
+ let remaining = Math.min(elapsed / 1000, 0.1);
165
+ while (remaining > 0) {
166
+ const dt = Math.min(remaining, MAX_STEP_SECONDS);
167
+ remaining -= dt;
168
+
169
+ // Follower. Clamped after integrating so a drag past the end dead-stops, as the reference
170
+ // does — the rubber band there is a separate, whole-panel affair.
171
+ const valueAccel =
172
+ valueSpec.stiffness * (targetValue.value - value.value) -
173
+ valueSpec.damping * valueRate.value;
174
+ valueRate.value += valueAccel * dt;
175
+ value.value = Math.min(
176
+ upper,
177
+ Math.max(lower, value.value + valueRate.value * dt)
178
+ );
179
+
180
+ const pressAccel =
181
+ VALUE_SPEC.stiffness * (pressTarget.value - pressProgress.value) -
182
+ VALUE_SPEC.damping * pressRate.value;
183
+ pressRate.value += pressAccel * dt;
184
+ pressProgress.value += pressRate.value * dt;
185
+
186
+ const scaleXAccel =
187
+ SCALE_X_SPEC.stiffness * (scaleTarget.value - scaleX.value) -
188
+ SCALE_X_SPEC.damping * scaleXRate.value;
189
+ scaleXRate.value += scaleXAccel * dt;
190
+ scaleX.value += scaleXRate.value * dt;
191
+
192
+ const scaleYAccel =
193
+ SCALE_Y_SPEC.stiffness * (scaleTarget.value - scaleY.value) -
194
+ SCALE_Y_SPEC.damping * scaleYRate.value;
195
+ scaleYRate.value += scaleYAccel * dt;
196
+ scaleY.value += scaleYRate.value * dt;
197
+
198
+ // Velocity is measured off the *follower*, not the finger, then low-passed by its own
199
+ // underdamped spring. That double filter is what makes the stretch wobble instead of
200
+ // tracking the touch instantly.
201
+ //
202
+ // The instantaneous derivative is only half of it. The reference reads a Compose
203
+ // `VelocityTracker`, which least-squares-fits the last ~100 ms of samples — so what reaches
204
+ // its spring is already a windowed average, not a per-frame difference. Feeding the raw
205
+ // difference straight in makes the channel far peakier than the reference's, and on a *flick*
206
+ // that difference is the whole story: the peak slams the jelly's +/-0.2 clamp and holds it
207
+ // there, so the pill wears its widest stretch on top of the grab scale for most of the
208
+ // throw. A tap never shows it, because `animateTo` stops sampling velocity altogether.
209
+ //
210
+ // One pole at the tracker's own window reproduces the smoothing without touching any of the
211
+ // reference's constants.
212
+ if (trackVelocity.value) {
213
+ const instant = (value.value - previousValue.value) / dt / span;
214
+ const alpha = 1 - Math.exp(-dt / VELOCITY_WINDOW_SECONDS);
215
+ rawVelocity.value += (instant - rawVelocity.value) * alpha;
216
+ }
217
+ previousValue.value = value.value;
218
+
219
+ const velocityAccel =
220
+ VELOCITY_SPEC.stiffness * (rawVelocity.value - velocity.value) -
221
+ VELOCITY_SPEC.damping * velocityRate.value;
222
+ velocityRate.value += velocityAccel * dt;
223
+ velocity.value += velocityRate.value * dt;
224
+ }
225
+
226
+ // The single most important detail of the choreography: the control stays inflated and glassy
227
+ // through the entire snap, deflating only once it has essentially arrived. Deflating on
228
+ // finger-up instead is the usual way this is got wrong.
229
+ if (
230
+ releasePending.value &&
231
+ Math.abs(value.value - targetValue.value) < span * CONVERGENCE_FRACTION &&
232
+ Math.abs(velocity.value) < VELOCITY_REST
233
+ ) {
234
+ releasePending.value = false;
235
+ trackVelocity.value = true;
236
+ pressTarget.value = 0;
237
+ scaleTarget.value = initialScale;
238
+ }
239
+ }, true);
240
+
241
+ return useMemo<IDampedDrag>(() => {
242
+ const press = (): void => {
243
+ "worklet";
244
+ releasePending.value = false;
245
+ trackVelocity.value = true;
246
+ rawVelocity.value = 0;
247
+ previousValue.value = value.value;
248
+ pressTarget.value = 1;
249
+ scaleTarget.value = pressedScale;
250
+ };
251
+
252
+ const release = (): void => {
253
+ "worklet";
254
+ releasePending.value = true;
255
+ };
256
+
257
+ const dragBy = (delta: number): void => {
258
+ "worklet";
259
+ targetValue.value = Math.min(
260
+ upper,
261
+ Math.max(lower, targetValue.value + delta)
262
+ );
263
+ };
264
+
265
+ const animateTo = (next: number): void => {
266
+ "worklet";
267
+ press();
268
+ targetValue.value = Math.min(upper, Math.max(lower, next));
269
+ // The reference stops sampling velocity during a programmatic snap and springs the existing
270
+ // velocity to zero instead; that unwind is the settle wobble.
271
+ trackVelocity.value = false;
272
+ rawVelocity.value = 0;
273
+ release();
274
+ };
275
+
276
+ const jelly = (): { scaleX: number; scaleY: number } => {
277
+ "worklet";
278
+ const v = (velocity.value / velocityDivisor) * jellyGain;
279
+ const stretch = Math.min(
280
+ jellyLimit,
281
+ Math.max(-jellyLimit, v * JELLY_STRETCH_X)
282
+ );
283
+ const squash = Math.min(
284
+ jellyLimit,
285
+ Math.max(-jellyLimit, v * JELLY_SQUASH_Y)
286
+ );
287
+ // Division on X, multiplication on Y — volume-preserving, and signed, so it inverts on
288
+ // reverse motion. Do not "fix" this to abs(); it changes the character.
289
+ return {
290
+ scaleX: scaleX.value / (1 - stretch),
291
+ scaleY: scaleY.value * (1 - squash),
292
+ };
293
+ };
294
+
295
+ return {
296
+ value,
297
+ targetValue,
298
+ pressProgress,
299
+ scaleX,
300
+ scaleY,
301
+ velocity,
302
+ press,
303
+ release,
304
+ dragBy,
305
+ animateTo,
306
+ jelly,
307
+ };
308
+ }, [
309
+ value,
310
+ targetValue,
311
+ pressProgress,
312
+ scaleX,
313
+ scaleY,
314
+ velocity,
315
+ pressTarget,
316
+ scaleTarget,
317
+ rawVelocity,
318
+ previousValue,
319
+ releasePending,
320
+ trackVelocity,
321
+ lower,
322
+ upper,
323
+ initialScale,
324
+ pressedScale,
325
+ velocityDivisor,
326
+ jellyGain,
327
+ jellyLimit,
328
+ ]);
329
+ }
330
+
331
+ export { useDampedDrag };
332
+ export type { IDampedDrag, IDampedDragConfig };
@@ -0,0 +1,55 @@
1
+ import { useCallback, useMemo, useRef } from "react";
2
+
3
+ /** How many un-echoed emits to remember before the oldest are forgotten. */
4
+ const ECHO_CAPACITY = 64;
5
+
6
+ interface IEchoFilter<T> {
7
+ /** Record a value this control just reported through its change callback. */
8
+ emitted: (value: T) => void;
9
+ /**
10
+ * Whether an incoming controlled `value` is merely one of our own reports coming back —
11
+ * in which case the control is already there (or past it) and must not re-target. Every
12
+ * report up to and including the matched one is forgotten; later ones stay pending for
13
+ * their own echoes.
14
+ */
15
+ isEcho: (value: T) => boolean;
16
+ }
17
+
18
+ /**
19
+ * Tells a controlled control's own echoes apart from a real external change.
20
+ *
21
+ * A dragged control reports many values a second through `runOnJS`. The parent stores each
22
+ * one and renders it back as `value`, and the control's effect must then decide: is this the
23
+ * app moving me, or my own report returning? Comparing against *the last* value reported is not
24
+ * enough — passive effects run after paint, so the effect of an earlier render can fire after
25
+ * several newer reports have gone out. The slider had exactly this: the effect for `0.47` ran
26
+ * once `0.66` had been reported, decided `0.47` was external and sprang the thumb back to it,
27
+ * and the drag looked like it kept bouncing to old positions.
28
+ *
29
+ * So the filter remembers every report that has not been echoed yet. An incoming value found
30
+ * in that list is an echo (echoes arrive in the order they were reported, so everything up to
31
+ * the match is done too); a value not in the list is the app's, and the control animates to it.
32
+ */
33
+ function useEchoFilter<T>(): IEchoFilter<T> {
34
+ const pending = useRef<T[]>([]);
35
+
36
+ const emitted = useCallback((value: T): void => {
37
+ const list = pending.current;
38
+ list.push(value);
39
+ if (list.length > ECHO_CAPACITY)
40
+ list.splice(0, list.length - ECHO_CAPACITY);
41
+ }, []);
42
+
43
+ const isEcho = useCallback((value: T): boolean => {
44
+ const list = pending.current;
45
+ const index = list.indexOf(value);
46
+ if (index < 0) return false;
47
+ list.splice(0, index + 1);
48
+ return true;
49
+ }, []);
50
+
51
+ return useMemo(() => ({ emitted, isEcho }), [emitted, isEcho]);
52
+ }
53
+
54
+ export { useEchoFilter };
55
+ export type { IEchoFilter };
@@ -0,0 +1,169 @@
1
+ import type { RefObject } from "react";
2
+ import { useCallback, useContext, useLayoutEffect, useRef } from "react";
3
+ import type { LayoutChangeEvent, View as RNView } from "react-native";
4
+ import type { SharedValue } from "react-native-reanimated";
5
+ import { useDerivedValue, useSharedValue } from "react-native-reanimated";
6
+
7
+ import { GlassGroupContext } from "../context";
8
+ import type { IGlassGroupMember, IGlassGroupRect } from "../context";
9
+
10
+ interface IGlassGroupMembership {
11
+ /** Whether a `LiquidGlassGroup` is above this control. */
12
+ inGroup: boolean;
13
+ /**
14
+ * Whether the pane should stay put — because the system merges natively (iOS 26), or because
15
+ * there is no group at all. When false the pane crossfades to the group's canvas while
16
+ * involved in a merge.
17
+ */
18
+ keepsPane: boolean;
19
+ /** This member's slot, on the UI thread; -1 until registered. */
20
+ slot: SharedValue<number>;
21
+ /**
22
+ * Attach to the member's outermost, untransformed view. Pass that view's instance too (or
23
+ * give the hook a `frameRef`): the frame is then measured against the group's row, so a
24
+ * wrapper between the two does not put the canvas pane in the wrong place.
25
+ */
26
+ onLayout: (event: LayoutChangeEvent, node?: RNView | null) => void;
27
+ /**
28
+ * Opacity for the member's own glass pane: 1 normally, `1 - activeProgress` while this member
29
+ * is the pressed one or its partner — the canvas is drawing both silhouettes for the duration.
30
+ */
31
+ paneOpacity: SharedValue<number>;
32
+ }
33
+
34
+ type TMeasurable = {
35
+ measureLayout?: (
36
+ relativeTo: unknown,
37
+ onSuccess: (x: number, y: number, width: number, height: number) => void,
38
+ onFail?: () => void
39
+ ) => void;
40
+ };
41
+
42
+ /**
43
+ * The member half of `LiquidGlassGroup`: registers the control's press channels with the group
44
+ * above it (if any), reports its frame, and hands back the opacity its own pane should wear.
45
+ *
46
+ * Every hook here mounts whether or not a group exists, so a control can be written once; outside
47
+ * a group `paneOpacity` is a constant 1 and `onLayout` is a no-op.
48
+ */
49
+ function useGlassGroupMember(
50
+ member: IGlassGroupMember,
51
+ frameRef?: RefObject<RNView | null>
52
+ ): IGlassGroupMembership {
53
+ const group = useContext(GlassGroupContext);
54
+ const slot = useSharedValue(-1);
55
+ const slotRef = useRef(-1);
56
+ const { progress, offsetX, offsetY, pressX, pressY, height, growth, light } =
57
+ member;
58
+
59
+ /** The frame measured against the group's row, with the layout event's numbers as fallback. */
60
+ const report = useCallback(
61
+ (
62
+ assigned: number,
63
+ node: RNView | null | undefined,
64
+ fallback?: IGlassGroupRect
65
+ ): void => {
66
+ if (group == null) return;
67
+ const host = group.hostRef.current;
68
+ const measurable = node as unknown as TMeasurable | null | undefined;
69
+ if (host != null && measurable?.measureLayout != null) {
70
+ measurable.measureLayout(
71
+ host,
72
+ (mx, my, mw, mh) => {
73
+ if (mw > 0 && mh > 0) {
74
+ group.setRect(assigned, { x: mx, y: my, w: mw, h: mh });
75
+ } else if (fallback != null) {
76
+ group.setRect(assigned, fallback);
77
+ }
78
+ },
79
+ () => {
80
+ if (fallback != null) group.setRect(assigned, fallback);
81
+ }
82
+ );
83
+ return;
84
+ }
85
+ if (fallback != null) group.setRect(assigned, fallback);
86
+ },
87
+ [group]
88
+ );
89
+
90
+ useLayoutEffect(() => {
91
+ if (group == null) return undefined;
92
+ const assigned = group.register({
93
+ progress,
94
+ offsetX,
95
+ offsetY,
96
+ pressX,
97
+ pressY,
98
+ height,
99
+ growth,
100
+ light,
101
+ });
102
+ slotRef.current = assigned;
103
+ slot.value = assigned;
104
+ // A re-registration (a prop in the deps changed, or a refresh) gets a new slot but no new
105
+ // layout event, so the frame is measured here as well; on first mount the view has no
106
+ // size yet and the layout event that follows fills it in.
107
+ report(assigned, frameRef?.current);
108
+ return () => {
109
+ group.unregister(assigned);
110
+ slotRef.current = -1;
111
+ slot.value = -1;
112
+ };
113
+ }, [
114
+ group,
115
+ progress,
116
+ offsetX,
117
+ offsetY,
118
+ pressX,
119
+ pressY,
120
+ height,
121
+ growth,
122
+ light,
123
+ slot,
124
+ report,
125
+ frameRef,
126
+ ]);
127
+
128
+ const onLayout = useCallback(
129
+ (event: LayoutChangeEvent, node?: RNView | null): void => {
130
+ if (group == null || slotRef.current < 0) return;
131
+ const { x, y, width: w, height: h } = event.nativeEvent.layout;
132
+ report(slotRef.current, node ?? frameRef?.current, { x, y, w, h });
133
+ },
134
+ [group, report, frameRef]
135
+ );
136
+
137
+ const keepsPane = group == null || group.native;
138
+ const activeSlot = group?.activeSlot;
139
+ const targetSlot = group?.targetSlot;
140
+ const activeProgress = group?.activeProgress;
141
+
142
+ const paneOpacity = useDerivedValue(() => {
143
+ if (
144
+ keepsPane ||
145
+ activeSlot == null ||
146
+ targetSlot == null ||
147
+ activeProgress == null
148
+ ) {
149
+ return 1;
150
+ }
151
+ const mine = slot.value;
152
+ const involved =
153
+ mine >= 0 && (activeSlot.value === mine || targetSlot.value === mine);
154
+ if (!involved) return 1;
155
+ // The press spring overshoots on both ends; the pane must not wrap around.
156
+ return Math.min(1, Math.max(0, 1 - activeProgress.value));
157
+ }, [keepsPane, activeSlot, targetSlot, activeProgress, slot]);
158
+
159
+ return {
160
+ inGroup: group != null,
161
+ keepsPane,
162
+ slot,
163
+ onLayout,
164
+ paneOpacity,
165
+ };
166
+ }
167
+
168
+ export { useGlassGroupMember };
169
+ export type { IGlassGroupMembership };
@@ -0,0 +1,79 @@
1
+ import { useCallback, useMemo } from "react";
2
+ import type { SharedValue } from "react-native-reanimated";
3
+ import { useSharedValue } from "react-native-reanimated";
4
+
5
+ interface IGravityHighlightOptions {
6
+ /**
7
+ * Low-pass weight of each new sample, `0`–`1`. Kyant's demo uses `0.5` at `SENSOR_DELAY_UI`
8
+ * (~60 Hz); lower is steadier, higher follows the hand faster.
9
+ */
10
+ smoothing?: number;
11
+ /** The angle to report before the first sample. Defaults to `180`, the vertical light axis. */
12
+ initialAngle?: number;
13
+ }
14
+
15
+ interface IGravityHighlight {
16
+ /**
17
+ * `highlight.angle` in the base view's degrees, on the UI thread — write it into `metal` from
18
+ * `useAnimatedProps`.
19
+ */
20
+ angle: SharedValue<number>;
21
+ /**
22
+ * Feed an accelerometer sample: `x` positive toward the device's right edge, `y` positive
23
+ * toward its top, in any unit — only the direction matters. `expo-sensors`'
24
+ * `Accelerometer.addListener` hands you exactly this.
25
+ */
26
+ push: (x: number, y: number) => void;
27
+ }
28
+
29
+ /**
30
+ * The highlight follows gravity: tilt the phone and the light on every glass edge slides with it,
31
+ * as if the panes sat under one fixed lamp. The AndroidLiquidGlass catalog's control-centre demo
32
+ * does this with the accelerometer (`UISensor`, Apache-2.0 — see NOTICE); this is the same
33
+ * filter, without the sensor. The kit takes no dependency on `expo-sensors` — the app subscribes
34
+ * and calls `push`.
35
+ *
36
+ * ```tsx
37
+ * const gravity = useGravityHighlight();
38
+ * useEffect(() => {
39
+ * Accelerometer.setUpdateInterval(16);
40
+ * const sub = Accelerometer.addListener(({ x, y }) => gravity.push(x, y));
41
+ * return () => sub.remove();
42
+ * }, [gravity]);
43
+ * const props = useAnimatedProps(() => ({
44
+ * metal: { ...GLASS_BAR_METAL, highlight: { ...GLASS_BAR_METAL.highlight, angle: gravity.angle.value } },
45
+ * }));
46
+ * ```
47
+ *
48
+ * Axis mapping: an upright phone reads gravity along `+y`, and the light should then sit on the
49
+ * vertical axis — top and bottom edges lit — which in `highlight.angle`'s convention is `180`.
50
+ * `atan2(y, x)` puts that at `90`, so the reported angle is Kyant's plus a quarter turn.
51
+ */
52
+ function useGravityHighlight(
53
+ options: IGravityHighlightOptions = {},
54
+ ): IGravityHighlight {
55
+ const smoothing = Math.min(1, Math.max(0.01, options.smoothing ?? 0.5));
56
+ const angle = useSharedValue(options.initialAngle ?? 180);
57
+ const filteredX = useSharedValue(0);
58
+ const filteredY = useSharedValue(1);
59
+
60
+ const push = useCallback(
61
+ (x: number, y: number): void => {
62
+ const norm = Math.hypot(x, y);
63
+ if (!Number.isFinite(norm) || norm < 1e-3) return;
64
+ // Filter the vector, not the angle: averaging angles across the ±180 seam would swing the
65
+ // light through every other direction on the way.
66
+ filteredX.value += (x / norm - filteredX.value) * smoothing;
67
+ filteredY.value += (y / norm - filteredY.value) * smoothing;
68
+ const gravity =
69
+ (Math.atan2(filteredY.value, filteredX.value) * 180) / Math.PI;
70
+ angle.value = gravity + 90;
71
+ },
72
+ [angle, filteredX, filteredY, smoothing],
73
+ );
74
+
75
+ return useMemo(() => ({ angle, push }), [angle, push]);
76
+ }
77
+
78
+ export { useGravityHighlight };
79
+ export type { IGravityHighlight, IGravityHighlightOptions };
@@ -0,0 +1,44 @@
1
+ import { useCallback } from "react";
2
+ import type { SharedValue, WithSpringConfig } from "react-native-reanimated";
3
+ import { useSharedValue, withSpring } from "react-native-reanimated";
4
+
5
+ import { GLOW_SPRING } from "../constants";
6
+
7
+ interface IPressProgress {
8
+ progress: SharedValue<number>;
9
+ pressIn: () => void;
10
+ pressOut: () => void;
11
+ }
12
+
13
+ /**
14
+ * A 0→1 press spring, on the reference's `InteractiveHighlight` spec by default:
15
+ * `spring(0.5f, 300f)`, the bouncy one.
16
+ *
17
+ * That is deliberately *not* the spec a dragged control presses with. `DampedDragAnimation` uses
18
+ * `spring(1f, 1000f)`, critically damped, and holds it up through the entire snap — so on the tab
19
+ * bar the two run side by side and disagree on purpose: the pill's lens is still fully dialled in
20
+ * while it flies home, and the light the bar throws under it has already begun to fade, because
21
+ * `InteractiveHighlight` releases on finger-up and waits for nothing.
22
+ *
23
+ * Both callbacks are worklets, so a gesture handler can drive them on the UI thread; calling them
24
+ * from JS still works, which is what the tap-only controls do.
25
+ */
26
+ function usePressProgress(
27
+ spring: WithSpringConfig = GLOW_SPRING,
28
+ ): IPressProgress {
29
+ const progress = useSharedValue(0);
30
+
31
+ const pressIn = useCallback((): void => {
32
+ "worklet";
33
+ progress.value = withSpring(1, spring);
34
+ }, [progress, spring]);
35
+ const pressOut = useCallback((): void => {
36
+ "worklet";
37
+ progress.value = withSpring(0, spring);
38
+ }, [progress, spring]);
39
+
40
+ return { progress, pressIn, pressOut };
41
+ }
42
+
43
+ export { usePressProgress };
44
+ export type { IPressProgress };