glacia-native 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (403) hide show
  1. package/LICENSE +29 -4
  2. package/README.md +111 -17
  3. package/lib/module/Accordion.js +58 -0
  4. package/lib/module/ActionSheet.js +38 -0
  5. package/lib/module/Alert.js +23 -0
  6. package/lib/module/AlertDialog.js +47 -0
  7. package/lib/module/Avatar.js +48 -0
  8. package/lib/module/Badge.js +36 -0
  9. package/lib/module/Bars.js +13 -267
  10. package/lib/module/Button.js +57 -36
  11. package/lib/module/Card.js +32 -20
  12. package/lib/module/Checkbox.js +42 -0
  13. package/lib/module/Chip.js +80 -0
  14. package/lib/module/Collapsible.js +26 -0
  15. package/lib/module/ContextMenu.js +33 -0
  16. package/lib/module/Dialog.js +39 -124
  17. package/lib/module/DropdownMenu.js +33 -0
  18. package/lib/module/Field.js +22 -0
  19. package/lib/module/Glass.js +12 -5
  20. package/lib/module/Group.js +36 -0
  21. package/lib/module/IconButton.js +40 -0
  22. package/lib/module/Input.js +47 -40
  23. package/lib/module/Label.js +17 -0
  24. package/lib/module/MorphGroup.js +47 -0
  25. package/lib/module/Popover.js +29 -0
  26. package/lib/module/Progress.js +32 -0
  27. package/lib/module/RadioGroup.js +51 -0
  28. package/lib/module/Scrim.js +44 -0
  29. package/lib/module/SegmentedControl.js +74 -58
  30. package/lib/module/Select.js +51 -0
  31. package/lib/module/Separator.js +25 -0
  32. package/lib/module/Sheet.js +51 -0
  33. package/lib/module/Skeleton.js +48 -0
  34. package/lib/module/Slider.js +60 -40
  35. package/lib/module/Stepper.js +167 -0
  36. package/lib/module/Switch.js +45 -43
  37. package/lib/module/TabBar.js +62 -50
  38. package/lib/module/Tabs.js +3 -2
  39. package/lib/module/Textarea.js +18 -0
  40. package/lib/module/Toast.js +55 -0
  41. package/lib/module/Toggle.js +47 -0
  42. package/lib/module/ToggleGroup.js +56 -0
  43. package/lib/module/Toolbar.js +37 -0
  44. package/lib/module/Tooltip.js +31 -0
  45. package/lib/module/glass-provider.js +28 -0
  46. package/lib/module/glass-stack.js +61 -0
  47. package/lib/module/index.js +78 -109
  48. package/lib/module/internal/GlassBackdrop.js +36 -0
  49. package/lib/module/internal/GlassView.js +45 -13
  50. package/lib/module/internal/blur-community.js +20 -0
  51. package/lib/module/internal/blur-community.web.js +9 -0
  52. package/lib/module/internal/blur.js +75 -0
  53. package/lib/module/internal/fallback.js +110 -20
  54. package/lib/module/internal/glass-routing.js +154 -30
  55. package/lib/module/internal/glow.js +36 -0
  56. package/lib/module/internal/initials.js +12 -0
  57. package/lib/module/internal/lens.js +70 -0
  58. package/lib/module/internal/material.js +64 -0
  59. package/lib/module/internal/overlay.js +147 -0
  60. package/lib/module/internal/primitives.js +17 -0
  61. package/lib/module/internal/rim.js +35 -0
  62. package/lib/module/internal/tokens.js +34 -2
  63. package/lib/typescript/Accordion.d.ts +22 -0
  64. package/lib/typescript/ActionSheet.d.ts +24 -0
  65. package/lib/typescript/Alert.d.ts +15 -0
  66. package/lib/typescript/AlertDialog.d.ts +17 -0
  67. package/lib/typescript/Avatar.d.ts +22 -0
  68. package/lib/typescript/Badge.d.ts +12 -0
  69. package/lib/typescript/Bars.d.ts +3 -188
  70. package/lib/typescript/Button.d.ts +44 -10
  71. package/lib/typescript/Card.d.ts +30 -3
  72. package/lib/typescript/Checkbox.d.ts +14 -0
  73. package/lib/typescript/Chip.d.ts +19 -0
  74. package/lib/typescript/Collapsible.d.ts +17 -0
  75. package/lib/typescript/ContextMenu.d.ts +23 -0
  76. package/lib/typescript/Dialog.d.ts +8 -68
  77. package/lib/typescript/DropdownMenu.d.ts +23 -0
  78. package/lib/typescript/Field.d.ts +19 -0
  79. package/lib/typescript/Glass.d.ts +11 -2
  80. package/lib/typescript/Group.d.ts +35 -0
  81. package/lib/typescript/IconButton.d.ts +21 -0
  82. package/lib/typescript/Input.d.ts +17 -18
  83. package/lib/typescript/Label.d.ts +14 -0
  84. package/lib/typescript/MorphGroup.d.ts +46 -0
  85. package/lib/typescript/Popover.d.ts +17 -0
  86. package/lib/typescript/Progress.d.ts +13 -0
  87. package/lib/typescript/RadioGroup.d.ts +21 -0
  88. package/lib/typescript/Scrim.d.ts +33 -0
  89. package/lib/typescript/SegmentedControl.d.ts +24 -13
  90. package/lib/typescript/Select.d.ts +19 -0
  91. package/lib/typescript/Separator.d.ts +10 -0
  92. package/lib/typescript/Sheet.d.ts +45 -0
  93. package/lib/typescript/Skeleton.d.ts +10 -0
  94. package/lib/typescript/Slider.d.ts +15 -7
  95. package/lib/typescript/Stepper.d.ts +49 -0
  96. package/lib/typescript/Switch.d.ts +19 -12
  97. package/lib/typescript/TabBar.d.ts +18 -6
  98. package/lib/typescript/Textarea.d.ts +6 -0
  99. package/lib/typescript/Toast.d.ts +40 -0
  100. package/lib/typescript/Toggle.d.ts +21 -0
  101. package/lib/typescript/ToggleGroup.d.ts +22 -0
  102. package/lib/typescript/Toolbar.d.ts +35 -0
  103. package/lib/typescript/Tooltip.d.ts +16 -0
  104. package/lib/typescript/glass-provider.d.ts +34 -0
  105. package/lib/typescript/glass-stack.d.ts +54 -0
  106. package/lib/typescript/index.d.ts +39 -17
  107. package/lib/typescript/internal/GlassBackdrop.d.ts +33 -0
  108. package/lib/typescript/internal/GlassView.d.ts +31 -2
  109. package/lib/typescript/internal/blur-community.d.ts +2 -0
  110. package/lib/typescript/internal/blur-community.web.d.ts +2 -0
  111. package/lib/typescript/internal/blur.d.ts +24 -0
  112. package/lib/typescript/internal/fallback.d.ts +27 -2
  113. package/lib/typescript/internal/glass-routing.d.ts +83 -15
  114. package/lib/typescript/internal/glow.d.ts +11 -0
  115. package/lib/typescript/internal/initials.d.ts +2 -0
  116. package/lib/typescript/internal/lens.d.ts +47 -0
  117. package/lib/typescript/internal/material.d.ts +27 -0
  118. package/lib/typescript/internal/overlay.d.ts +74 -0
  119. package/lib/typescript/internal/primitives.d.ts +13 -0
  120. package/lib/typescript/internal/rim.d.ts +16 -0
  121. package/lib/typescript/internal/tokens.d.ts +36 -0
  122. package/package.json +15 -4
  123. package/src/Accordion.tsx +165 -0
  124. package/src/ActionSheet.tsx +149 -0
  125. package/src/Alert.tsx +85 -0
  126. package/src/AlertDialog.tsx +124 -0
  127. package/src/Avatar.tsx +102 -0
  128. package/src/Badge.tsx +80 -0
  129. package/src/Bars.tsx +10 -797
  130. package/src/Button.tsx +196 -60
  131. package/src/Card.tsx +106 -33
  132. package/src/Checkbox.tsx +98 -0
  133. package/src/Chip.tsx +149 -0
  134. package/src/Collapsible.tsx +66 -0
  135. package/src/ContextMenu.tsx +103 -0
  136. package/src/Dialog.tsx +86 -325
  137. package/src/DropdownMenu.tsx +103 -0
  138. package/src/Field.tsx +65 -0
  139. package/src/Glass.tsx +19 -5
  140. package/src/Group.tsx +98 -0
  141. package/src/IconButton.tsx +110 -0
  142. package/src/Input.tsx +143 -87
  143. package/src/Label.tsx +56 -0
  144. package/src/MorphGroup.tsx +134 -0
  145. package/src/Popover.tsx +81 -0
  146. package/src/Progress.tsx +83 -0
  147. package/src/RadioGroup.tsx +122 -0
  148. package/src/Scrim.tsx +94 -0
  149. package/src/SegmentedControl.tsx +147 -90
  150. package/src/Select.tsx +136 -0
  151. package/src/Separator.tsx +52 -0
  152. package/src/Sheet.tsx +139 -0
  153. package/src/Skeleton.tsx +77 -0
  154. package/src/Slider.tsx +100 -54
  155. package/src/Stepper.tsx +315 -0
  156. package/src/Switch.tsx +80 -58
  157. package/src/TabBar.tsx +118 -84
  158. package/src/Tabs.tsx +5 -0
  159. package/src/Textarea.tsx +34 -0
  160. package/src/Toast.tsx +131 -0
  161. package/src/Toggle.tsx +113 -0
  162. package/src/ToggleGroup.tsx +129 -0
  163. package/src/Toolbar.tsx +111 -0
  164. package/src/Tooltip.tsx +79 -0
  165. package/src/engine/CHANGELOG.md +430 -0
  166. package/src/engine/NOTICE +54 -0
  167. package/src/engine/README.md +975 -0
  168. package/src/engine/android/build.gradle +18 -0
  169. package/src/engine/android/src/main/AndroidManifest.xml +2 -0
  170. package/src/engine/android/src/main/java/expo/modules/liquidglass/ExpoLiquidGlassModule.kt +174 -0
  171. package/src/engine/android/src/main/java/expo/modules/liquidglass/GlassConstants.kt +7 -0
  172. package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassContainerView.kt +16 -0
  173. package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassProviderView.kt +165 -0
  174. package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassView.kt +1731 -0
  175. package/src/engine/android/src/main/java/expo/modules/liquidglass/enums/GlassEnums.kt +171 -0
  176. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/BackdropGraph.kt +146 -0
  177. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/BackdropSource.kt +53 -0
  178. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/ContinuousCorners.kt +188 -0
  179. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/CornerRadii.kt +62 -0
  180. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassAppearance.kt +352 -0
  181. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassDebug.kt +109 -0
  182. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassEnvironment.kt +139 -0
  183. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassHdr.kt +85 -0
  184. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassLuminanceProbe.kt +189 -0
  185. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassPressAnimator.kt +264 -0
  186. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassProgressiveBlur.kt +249 -0
  187. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassShaderCache.kt +256 -0
  188. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassShaderSource.kt +845 -0
  189. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassTier.kt +63 -0
  190. package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/ProviderRegistry.kt +71 -0
  191. package/src/engine/android/src/main/java/expo/modules/liquidglass/records/GlassRecords.kt +288 -0
  192. package/src/engine/index.ts +24 -0
  193. package/src/engine/ios/Enums/GlassBlurDirection.swift +21 -0
  194. package/src/engine/ios/Enums/GlassVariant.swift +86 -0
  195. package/src/engine/ios/ExpoLiquidGlass.podspec +93 -0
  196. package/src/engine/ios/ExpoLiquidGlassModule.swift +77 -0
  197. package/src/engine/ios/Glass/BackdropCapturer.swift +811 -0
  198. package/src/engine/ios/Glass/ContinuousCorners.swift +165 -0
  199. package/src/engine/ios/Glass/GlassBackdrop.swift +176 -0
  200. package/src/engine/ios/Glass/GlassFramePhase.swift +126 -0
  201. package/src/engine/ios/Glass/GlassFrameScheduler.swift +261 -0
  202. package/src/engine/ios/Glass/GlassPressAnimator.swift +250 -0
  203. package/src/engine/ios/Glass/GlassRenderContext.swift +168 -0
  204. package/src/engine/ios/Glass/GlassRenderer.swift +186 -0
  205. package/src/engine/ios/Glass/GlassSurfaceView.swift +452 -0
  206. package/src/engine/ios/Glass/NonRenderableView.swift +54 -0
  207. package/src/engine/ios/Glass/StripCache.swift +545 -0
  208. package/src/engine/ios/Records/GlassCornerRadii.swift +79 -0
  209. package/src/engine/ios/Records/GlassMetalOptions.swift +180 -0
  210. package/src/engine/ios/Records/GlassRefractionCurve.swift +14 -0
  211. package/src/engine/ios/Shaders/LiquidGlass.metal +480 -0
  212. package/src/engine/ios/Shaders/bundle-marker.txt +6 -0
  213. package/src/engine/ios/Views/LiquidGlassContainerView.swift +99 -0
  214. package/src/engine/ios/Views/LiquidGlassView.swift +859 -0
  215. package/src/engine/package.json +70 -0
  216. package/src/engine/src/components/LiquidGlassButton/LiquidGlassButton.tsx +424 -0
  217. package/src/engine/src/components/LiquidGlassCard/LiquidGlassCard.tsx +98 -0
  218. package/src/engine/src/components/LiquidGlassChip/LiquidGlassChip.tsx +65 -0
  219. package/src/engine/src/components/LiquidGlassGroup/LiquidGlassGroup.tsx +350 -0
  220. package/src/engine/src/components/LiquidGlassIconButton/LiquidGlassIconButton.tsx +24 -0
  221. package/src/engine/src/components/LiquidGlassMorphGroup/LiquidGlassMorphGroup.tsx +434 -0
  222. package/src/engine/src/components/LiquidGlassScrim/LiquidGlassScrim.tsx +100 -0
  223. package/src/engine/src/components/LiquidGlassSegmentedControl/LiquidGlassSegmentedControl.tsx +213 -0
  224. package/src/engine/src/components/LiquidGlassSheet/LiquidGlassSheet.tsx +218 -0
  225. package/src/engine/src/components/LiquidGlassSlider/LiquidGlassSlider.tsx +327 -0
  226. package/src/engine/src/components/LiquidGlassStepper/LiquidGlassStepper.tsx +321 -0
  227. package/src/engine/src/components/LiquidGlassSwitch/LiquidGlassSwitch.tsx +296 -0
  228. package/src/engine/src/components/LiquidGlassTabBar/LiquidGlassTabBar.tsx +952 -0
  229. package/src/engine/src/components/LiquidGlassTextInput/LiquidGlassTextInput.tsx +151 -0
  230. package/src/engine/src/components/LiquidGlassToast/LiquidGlassToast.tsx +169 -0
  231. package/src/engine/src/components/LiquidGlassToolbar/LiquidGlassToolbar.tsx +124 -0
  232. package/src/engine/src/components/index.ts +16 -0
  233. package/src/engine/src/constants/index.ts +4 -0
  234. package/src/engine/src/constants/metal.constants.ts +327 -0
  235. package/src/engine/src/constants/metrics.constants.ts +325 -0
  236. package/src/engine/src/constants/springs.constants.ts +107 -0
  237. package/src/engine/src/constants/styles.constants.ts +12 -0
  238. package/src/engine/src/context/glass-group.context.ts +65 -0
  239. package/src/engine/src/context/index.ts +6 -0
  240. package/src/engine/src/core/components/LiquidGlassContainer/LiquidGlassContainer.tsx +32 -0
  241. package/src/engine/src/core/components/LiquidGlassContainer/index.ts +1 -0
  242. package/src/engine/src/core/components/LiquidGlassProvider/LiquidGlassProvider.tsx +66 -0
  243. package/src/engine/src/core/components/LiquidGlassProvider/index.ts +1 -0
  244. package/src/engine/src/core/components/LiquidGlassStack/LiquidGlassStack.tsx +184 -0
  245. package/src/engine/src/core/components/LiquidGlassStack/index.ts +1 -0
  246. package/src/engine/src/core/components/LiquidGlassView/LiquidGlassView.tsx +126 -0
  247. package/src/engine/src/core/components/LiquidGlassView/index.ts +1 -0
  248. package/src/engine/src/core/components/index.ts +4 -0
  249. package/src/engine/src/core/constants/glass.constants.ts +57 -0
  250. package/src/engine/src/core/constants/index.ts +20 -0
  251. package/src/engine/src/core/constants/native.constants.ts +16 -0
  252. package/src/engine/src/core/context/glass-stack.context.ts +30 -0
  253. package/src/engine/src/core/context/index.ts +4 -0
  254. package/src/engine/src/core/enum/index.ts +12 -0
  255. package/src/engine/src/core/index.ts +1 -0
  256. package/src/engine/src/core/interfaces/glass-hdr.interface.ts +15 -0
  257. package/src/engine/src/core/interfaces/glass-metal.interface.ts +248 -0
  258. package/src/engine/src/core/interfaces/glass-surface.interface.ts +9 -0
  259. package/src/engine/src/core/interfaces/index.ts +31 -0
  260. package/src/engine/src/core/interfaces/liquid-glass-container.interface.ts +6 -0
  261. package/src/engine/src/core/interfaces/liquid-glass-provider.interface.ts +14 -0
  262. package/src/engine/src/core/interfaces/liquid-glass-stack.interface.ts +21 -0
  263. package/src/engine/src/core/interfaces/liquid-glass-view.interface.ts +129 -0
  264. package/src/engine/src/core/interfaces/native-liquid-glass-view.interface.ts +19 -0
  265. package/src/engine/src/core/modules/ExpoLiquidGlassModule.ts +26 -0
  266. package/src/engine/src/core/modules/index.ts +2 -0
  267. package/src/engine/src/core/root/index.ts +51 -0
  268. package/src/engine/src/core/types/glass.types.ts +25 -0
  269. package/src/engine/src/core/types/index.ts +8 -0
  270. package/src/engine/src/core/utils/debug.utils.ts +17 -0
  271. package/src/engine/src/core/utils/dev-warn.utils.ts +17 -0
  272. package/src/engine/src/core/utils/hdr.utils.ts +37 -0
  273. package/src/engine/src/core/utils/index.ts +5 -0
  274. package/src/engine/src/core/utils/native-view.utils.ts +33 -0
  275. package/src/engine/src/core/utils/platform.utils.ts +34 -0
  276. package/src/engine/src/core/views/NativeGlassBackdropView.ts +24 -0
  277. package/src/engine/src/core/views/NativeLiquidGlassContainerView.ts +13 -0
  278. package/src/engine/src/core/views/NativeLiquidGlassContainerView.web.ts +10 -0
  279. package/src/engine/src/core/views/NativeLiquidGlassProviderView.ts +13 -0
  280. package/src/engine/src/core/views/NativeLiquidGlassProviderView.web.ts +10 -0
  281. package/src/engine/src/core/views/NativeLiquidGlassView.ts +19 -0
  282. package/src/engine/src/core/views/NativeLiquidGlassView.web.ts +14 -0
  283. package/src/engine/src/core/views/index.ts +4 -0
  284. package/src/engine/src/hooks/index.ts +18 -0
  285. package/src/engine/src/hooks/use-adaptive-glass.ts +91 -0
  286. package/src/engine/src/hooks/use-damped-drag.ts +332 -0
  287. package/src/engine/src/hooks/use-echo-filter.ts +55 -0
  288. package/src/engine/src/hooks/use-glass-group-member.ts +169 -0
  289. package/src/engine/src/hooks/use-gravity-highlight.ts +79 -0
  290. package/src/engine/src/hooks/use-press-progress.ts +44 -0
  291. package/src/engine/src/index.ts +120 -0
  292. package/src/engine/src/interfaces/index.ts +28 -0
  293. package/src/engine/src/interfaces/liquid-glass-button.interface.ts +94 -0
  294. package/src/engine/src/interfaces/liquid-glass-card.interface.ts +40 -0
  295. package/src/engine/src/interfaces/liquid-glass-chip.interface.ts +29 -0
  296. package/src/engine/src/interfaces/liquid-glass-group.interface.ts +32 -0
  297. package/src/engine/src/interfaces/liquid-glass-icon-button.interface.ts +19 -0
  298. package/src/engine/src/interfaces/liquid-glass-morph-group.interface.ts +59 -0
  299. package/src/engine/src/interfaces/liquid-glass-scrim.interface.ts +36 -0
  300. package/src/engine/src/interfaces/liquid-glass-segmented-control.interface.ts +32 -0
  301. package/src/engine/src/interfaces/liquid-glass-sheet.interface.ts +38 -0
  302. package/src/engine/src/interfaces/liquid-glass-slider.interface.ts +37 -0
  303. package/src/engine/src/interfaces/liquid-glass-stepper.interface.ts +35 -0
  304. package/src/engine/src/interfaces/liquid-glass-switch.interface.ts +27 -0
  305. package/src/engine/src/interfaces/liquid-glass-tab-bar.interface.ts +116 -0
  306. package/src/engine/src/interfaces/liquid-glass-text-input.interface.ts +42 -0
  307. package/src/engine/src/interfaces/liquid-glass-toast.interface.ts +36 -0
  308. package/src/engine/src/interfaces/liquid-glass-toolbar.interface.ts +33 -0
  309. package/src/engine/src/theme/glass-ui-theme.ts +100 -0
  310. package/src/engine/src/theme/index.ts +2 -0
  311. package/src/engine/src/utils/button-press.utils.ts +63 -0
  312. package/src/engine/src/utils/index.ts +3 -0
  313. package/src/engine/src/utils/metal.utils.ts +164 -0
  314. package/src/glass-provider.tsx +60 -0
  315. package/src/glass-stack.tsx +115 -0
  316. package/src/index.ts +48 -190
  317. package/src/internal/GlassBackdrop.tsx +60 -0
  318. package/src/internal/GlassView.tsx +70 -18
  319. package/src/internal/blur-community.ts +19 -0
  320. package/src/internal/blur-community.web.ts +7 -0
  321. package/src/internal/blur.ts +89 -0
  322. package/src/internal/fallback.tsx +158 -20
  323. package/src/internal/glass-routing.ts +211 -34
  324. package/src/internal/glow.tsx +62 -0
  325. package/src/internal/initials.ts +7 -0
  326. package/src/internal/lens.tsx +105 -0
  327. package/src/internal/material.ts +92 -0
  328. package/src/internal/overlay.tsx +258 -0
  329. package/src/internal/primitives.ts +26 -0
  330. package/src/internal/rim.tsx +79 -0
  331. package/src/internal/tokens.ts +34 -1
  332. package/lib/module/Carousel.js +0 -103
  333. package/lib/module/Display.js +0 -317
  334. package/lib/module/Feedback.js +0 -386
  335. package/lib/module/Form.js +0 -164
  336. package/lib/module/Forms2.js +0 -454
  337. package/lib/module/Message.js +0 -88
  338. package/lib/module/Overlays.js +0 -328
  339. package/lib/module/Pickers.js +0 -243
  340. package/lib/module/Table.js +0 -99
  341. package/lib/module/ai.js +0 -280
  342. package/lib/module/charts/AreaChart.js +0 -32
  343. package/lib/module/charts/BarChart.js +0 -67
  344. package/lib/module/charts/FunnelChart.js +0 -50
  345. package/lib/module/charts/HeatmapChart.js +0 -71
  346. package/lib/module/charts/LineChart.js +0 -81
  347. package/lib/module/charts/PlotChart.js +0 -52
  348. package/lib/module/charts/RadarChart.js +0 -78
  349. package/lib/module/charts/RingChart.js +0 -52
  350. package/lib/module/charts/ScatterChart.js +0 -95
  351. package/lib/module/charts/WaterfallChart.js +0 -85
  352. package/lib/module/charts/advanced.js +0 -313
  353. package/lib/module/charts/extra.js +0 -108
  354. package/lib/module/charts/index.js +0 -50
  355. package/lib/module/charts/scales.js +0 -140
  356. package/lib/typescript/Carousel.d.ts +0 -47
  357. package/lib/typescript/Display.d.ts +0 -178
  358. package/lib/typescript/Feedback.d.ts +0 -196
  359. package/lib/typescript/Form.d.ts +0 -97
  360. package/lib/typescript/Forms2.d.ts +0 -209
  361. package/lib/typescript/Message.d.ts +0 -71
  362. package/lib/typescript/Overlays.d.ts +0 -146
  363. package/lib/typescript/Pickers.d.ts +0 -105
  364. package/lib/typescript/Table.d.ts +0 -64
  365. package/lib/typescript/ai.d.ts +0 -166
  366. package/lib/typescript/charts/AreaChart.d.ts +0 -44
  367. package/lib/typescript/charts/BarChart.d.ts +0 -19
  368. package/lib/typescript/charts/FunnelChart.d.ts +0 -25
  369. package/lib/typescript/charts/HeatmapChart.d.ts +0 -23
  370. package/lib/typescript/charts/LineChart.d.ts +0 -30
  371. package/lib/typescript/charts/PlotChart.d.ts +0 -31
  372. package/lib/typescript/charts/RadarChart.d.ts +0 -27
  373. package/lib/typescript/charts/RingChart.d.ts +0 -28
  374. package/lib/typescript/charts/ScatterChart.d.ts +0 -34
  375. package/lib/typescript/charts/WaterfallChart.d.ts +0 -22
  376. package/lib/typescript/charts/advanced.d.ts +0 -107
  377. package/lib/typescript/charts/extra.d.ts +0 -63
  378. package/lib/typescript/charts/index.d.ts +0 -13
  379. package/lib/typescript/charts/scales.d.ts +0 -35
  380. package/src/Carousel.tsx +0 -233
  381. package/src/Display.tsx +0 -778
  382. package/src/Feedback.tsx +0 -969
  383. package/src/Form.tsx +0 -425
  384. package/src/Forms2.tsx +0 -1014
  385. package/src/Message.tsx +0 -219
  386. package/src/Overlays.tsx +0 -685
  387. package/src/Pickers.tsx +0 -590
  388. package/src/Table.tsx +0 -231
  389. package/src/ai.tsx +0 -707
  390. package/src/charts/AreaChart.tsx +0 -73
  391. package/src/charts/BarChart.tsx +0 -183
  392. package/src/charts/FunnelChart.tsx +0 -125
  393. package/src/charts/HeatmapChart.tsx +0 -155
  394. package/src/charts/LineChart.tsx +0 -247
  395. package/src/charts/PlotChart.tsx +0 -168
  396. package/src/charts/RadarChart.tsx +0 -208
  397. package/src/charts/RingChart.tsx +0 -133
  398. package/src/charts/ScatterChart.tsx +0 -223
  399. package/src/charts/WaterfallChart.tsx +0 -201
  400. package/src/charts/advanced.tsx +0 -676
  401. package/src/charts/extra.tsx +0 -242
  402. package/src/charts/index.ts +0 -86
  403. package/src/charts/scales.ts +0 -163
@@ -1,676 +0,0 @@
1
- import { useMemo, useState } from "react";
2
-
3
- import { colors } from "../internal/tokens";
4
- import { useIsDark } from "../internal/motion";
5
- import { primitives } from "../internal/primitives";
6
- import { formatValue, linearScale, niceDomain, seriesColor, ticks } from "./scales";
7
-
8
- export interface NativeCandle {
9
- label: string;
10
- open: number;
11
- high: number;
12
- low: number;
13
- close: number;
14
- }
15
-
16
- export interface NativeCandlestickChartProps {
17
- candles: NativeCandle[];
18
- width?: number;
19
- height?: number;
20
- isDark?: boolean;
21
- style?: any;
22
- onCandlePress?: (index: number) => void;
23
- }
24
-
25
- const PADDING = { top: 12, right: 8, bottom: 24, left: 42 };
26
-
27
- /**
28
- * Open, high, low and close for each period.
29
- *
30
- * A filled body means the period closed up and a hollow body means it closed
31
- * down, which is the convention traders read without a legend. Each candle is
32
- * tappable to reveal the four prices, replacing the web hover tooltip.
33
- */
34
- export function NativeCandlestickChart({
35
- candles,
36
- width = 320,
37
- height = 200,
38
- isDark: isDarkProp,
39
- style,
40
- onCandlePress,
41
- }: NativeCandlestickChartProps) {
42
- const [active, setActive] = useState<number | null>(null);
43
- const isDark = useIsDark(isDarkProp);
44
- const theme = isDark ? colors.dark : colors.light;
45
- const { View, Text, Svg, G, Line, Rect, SvgText } = primitives();
46
-
47
- const up = "#34c759";
48
- const down = "#ff3b30";
49
-
50
- const plot = {
51
- x: PADDING.left,
52
- y: PADDING.top,
53
- width: Math.max(0, width - PADDING.left - PADDING.right),
54
- height: Math.max(0, height - PADDING.top - PADDING.bottom),
55
- };
56
- const right = plot.x + plot.width;
57
- const bottom = plot.y + plot.height;
58
-
59
- const domain = useMemo(() => {
60
- const highs = candles.map((c) => c.high).filter(Number.isFinite);
61
- const lows = candles.map((c) => c.low).filter(Number.isFinite);
62
- if (!highs.length || !lows.length) return niceDomain(0, 1, 4);
63
- return niceDomain(Math.min(...lows), Math.max(...highs), 4);
64
- }, [candles.map((c) => `${c.high},${c.low}`).join("|")]);
65
-
66
- const y = linearScale(domain, [bottom, plot.y], { nice: false });
67
-
68
- if (candles.length === 0) {
69
- return (
70
- <View style={[{ width, height, alignItems: "center", justifyContent: "center" }, style]}>
71
- <Text style={{ color: theme.muted, fontSize: 12 }}>No candles to display</Text>
72
- </View>
73
- );
74
- }
75
-
76
- const step = plot.width / candles.length;
77
- const bodyWidth = Math.min(14, step * 0.6);
78
- const yTicks = ticks(domain, 4);
79
-
80
- return (
81
- <View style={style}>
82
- <Svg width={width} height={height}>
83
- {yTicks.map((tick, i) => (
84
- <Line
85
- key={`grid-${i}`}
86
- x1={plot.x}
87
- x2={right}
88
- y1={y(tick)}
89
- y2={y(tick)}
90
- stroke={theme.axis}
91
- strokeOpacity={0.22}
92
- strokeWidth={1}
93
- />
94
- ))}
95
-
96
- {candles.map((candle, index) => {
97
- const rising = candle.close >= candle.open;
98
- const color = rising ? up : down;
99
- const cx = plot.x + step * index + step / 2;
100
- const bodyTop = y(Math.max(candle.open, candle.close));
101
- const bodyBottom = y(Math.min(candle.open, candle.close));
102
- const isActive = active === index;
103
-
104
- return (
105
- <G
106
- key={candle.label}
107
- onPress={() => {
108
- setActive((current) => (current === index ? null : index));
109
- onCandlePress?.(index);
110
- }}
111
- >
112
- {/* Wick */}
113
- <Line
114
- x1={cx}
115
- x2={cx}
116
- y1={y(candle.high)}
117
- y2={y(candle.low)}
118
- stroke={color}
119
- strokeWidth={1}
120
- />
121
- {/* Body: filled when up, hollow when down. */}
122
- <Rect
123
- x={cx - bodyWidth / 2}
124
- y={bodyTop}
125
- width={bodyWidth}
126
- height={Math.max(1, bodyBottom - bodyTop)}
127
- rx={1}
128
- fill={rising ? color : "transparent"}
129
- stroke={color}
130
- strokeWidth={1}
131
- fillOpacity={isActive ? 1 : 0.9}
132
- />
133
- </G>
134
- );
135
- })}
136
-
137
- {yTicks.map((tick, i) => (
138
- <SvgText
139
- key={`y-${i}`}
140
- x={plot.x - 6}
141
- y={y(tick) + 3}
142
- fill={theme.muted}
143
- fontSize={9}
144
- textAnchor="end"
145
- >
146
- {formatValue(tick, { compact: true })}
147
- </SvgText>
148
- ))}
149
- </Svg>
150
-
151
- {active !== null && candles[active] && (
152
- <Text style={{ fontSize: 10, color: theme.muted, marginTop: 4 }}>
153
- {candles[active]!.label} · O {formatValue(candles[active]!.open)} · H{" "}
154
- {formatValue(candles[active]!.high)} · L {formatValue(candles[active]!.low)} · C{" "}
155
- {formatValue(candles[active]!.close)}
156
- </Text>
157
- )}
158
- </View>
159
- );
160
- }
161
-
162
- export interface NativeTreemapItem {
163
- label: string;
164
- value: number;
165
- color?: string;
166
- }
167
-
168
- export interface NativeTreemapChartProps {
169
- items: NativeTreemapItem[];
170
- width?: number;
171
- height?: number;
172
- isDark?: boolean;
173
- palette?: readonly string[];
174
- style?: any;
175
- onItemPress?: (index: number) => void;
176
- }
177
-
178
- interface Box {
179
- x: number;
180
- y: number;
181
- w: number;
182
- h: number;
183
- }
184
-
185
- /**
186
- * Squarified treemap: rectangles sized by value, packed to stay close to square.
187
- *
188
- * A naive slice-and-dice layout produces slivers that cannot hold a label. This
189
- * alternates the split direction and lays each row out along the shorter side,
190
- * so tiles keep a usable aspect ratio.
191
- */
192
- function squarify(values: number[], box: Box, output: Box[]) {
193
- if (values.length === 0) return;
194
- if (values.length === 1) {
195
- output.push({ ...box });
196
- return;
197
- }
198
-
199
- const total = values.reduce((sum, value) => sum + value, 0);
200
- if (total <= 0) {
201
- // Equal shares when the values carry no weight.
202
- output.push({ ...box });
203
- return;
204
- }
205
-
206
- // Split the larger side so both halves stay as square as possible.
207
- let split = 1;
208
- let accumulated = values[0] ?? 0;
209
- let best = Math.abs(accumulated / total - 0.5);
210
- for (let i = 2; i < values.length; i++) {
211
- accumulated += values[i - 1] ?? 0;
212
- const ratio = accumulated / total;
213
- const distance = Math.abs(ratio - 0.5);
214
- if (distance < best) {
215
- best = distance;
216
- split = i;
217
- }
218
- }
219
-
220
- const firstShare = values.slice(0, split).reduce((sum, value) => sum + value, 0) / total;
221
-
222
- if (box.w >= box.h) {
223
- const w = box.w * firstShare;
224
- squarify(values.slice(0, split), { x: box.x, y: box.y, w, h: box.h }, output);
225
- squarify(values.slice(split), { x: box.x + w, y: box.y, w: box.w - w, h: box.h }, output);
226
- } else {
227
- const h = box.h * firstShare;
228
- squarify(values.slice(0, split), { x: box.x, y: box.y, w: box.w, h }, output);
229
- squarify(values.slice(split), { x: box.x, y: box.y + h, w: box.w, h: box.h - h }, output);
230
- }
231
- }
232
-
233
- /** Proportional rectangles for part-to-whole comparison. */
234
- export function NativeTreemapChart({
235
- items,
236
- width = 320,
237
- height = 200,
238
- isDark: isDarkProp,
239
- palette,
240
- style,
241
- onItemPress,
242
- }: NativeTreemapChartProps) {
243
- const [active, setActive] = useState<number | null>(null);
244
- const isDark = useIsDark(isDarkProp);
245
- const theme = isDark ? colors.dark : colors.light;
246
- const { View, Text, Pressable } = primitives();
247
-
248
- if (items.length === 0) {
249
- return (
250
- <View style={[{ width, alignItems: "center", paddingVertical: 20 }, style]}>
251
- <Text style={{ color: theme.muted, fontSize: 12 }}>No items to display</Text>
252
- </View>
253
- );
254
- }
255
-
256
- // Larger first keeps the layout stable and the important tiles big.
257
- const ordered = items
258
- .map((item, index) => ({ item, index }))
259
- .sort((a, b) => b.item.value - a.item.value);
260
-
261
- const boxes: Box[] = [];
262
- squarify(
263
- ordered.map((entry) => entry.item.value),
264
- { x: 0, y: 0, w: width, h: height },
265
- boxes,
266
- );
267
-
268
- return (
269
- <View style={[{ width, height }, style]}>
270
- {boxes.map((box, i) => {
271
- const entry = ordered[i]!;
272
- const color = entry.item.color ?? seriesColor(i, palette);
273
- const showLabel = box.w > 46 && box.h > 22;
274
-
275
- return (
276
- <Pressable
277
- key={entry.item.label}
278
- accessibilityRole="button"
279
- accessibilityLabel={`${entry.item.label}: ${formatValue(entry.item.value)}`}
280
- onPress={() => {
281
- setActive((current) => (current === entry.index ? null : entry.index));
282
- onItemPress?.(entry.index);
283
- }}
284
- style={{
285
- position: "absolute",
286
- left: box.x,
287
- top: box.y,
288
- width: box.w,
289
- height: box.h,
290
- padding: 3,
291
- }}
292
- >
293
- <View
294
- style={{
295
- flex: 1,
296
- borderRadius: 4,
297
- backgroundColor: color,
298
- opacity: active === null || active === entry.index ? 0.9 : 0.45,
299
- padding: 4,
300
- justifyContent: "flex-start",
301
- overflow: "hidden",
302
- }}
303
- >
304
- {showLabel && (
305
- <Text
306
- numberOfLines={1}
307
- style={{ fontSize: 9, fontWeight: "600", color: "#fff" }}
308
- >
309
- {entry.item.label}
310
- </Text>
311
- )}
312
- </View>
313
- </Pressable>
314
- );
315
- })}
316
- </View>
317
- );
318
- }
319
-
320
- export interface NativeSankeyNode {
321
- id: string;
322
- label: string;
323
- }
324
-
325
- export interface NativeSankeyLink {
326
- from: string;
327
- to: string;
328
- value: number;
329
- }
330
-
331
- export interface NativeSankeyChartProps {
332
- nodes: NativeSankeyNode[];
333
- links: NativeSankeyLink[];
334
- width?: number;
335
- height?: number;
336
- isDark?: boolean;
337
- palette?: readonly string[];
338
- style?: any;
339
- }
340
-
341
- /**
342
- * Flow between stages, drawn as stacked columns joined by bands.
343
- *
344
- * Columns are assigned by longest path from a source, so a node always sits
345
- * after everything feeding it. Rendering uses Views rather than SVG because the
346
- * bands are axis-aligned rectangles.
347
- */
348
- export function NativeSankeyChart({
349
- nodes,
350
- links,
351
- width = 320,
352
- height = 200,
353
- isDark: isDarkProp,
354
- palette,
355
- style,
356
- }: NativeSankeyChartProps) {
357
- const isDark = useIsDark(isDarkProp);
358
- const theme = isDark ? colors.dark : colors.light;
359
- const { View, Text } = primitives();
360
-
361
- if (nodes.length === 0 || links.length === 0) {
362
- return (
363
- <View style={[{ width, alignItems: "center", paddingVertical: 20 }, style]}>
364
- <Text style={{ color: theme.muted, fontSize: 12 }}>No flows to display</Text>
365
- </View>
366
- );
367
- }
368
-
369
- // Longest-path column assignment; cycles fall back to the current depth.
370
- const depth = new Map<string, number>();
371
- for (const node of nodes) depth.set(node.id, 0);
372
-
373
- for (let pass = 0; pass < nodes.length; pass++) {
374
- let changed = false;
375
- for (const link of links) {
376
- const from = depth.get(link.from) ?? 0;
377
- const current = depth.get(link.to) ?? 0;
378
- if (from + 1 > current) {
379
- depth.set(link.to, from + 1);
380
- changed = true;
381
- }
382
- }
383
- if (!changed) break;
384
- }
385
-
386
- const columns = new Map<number, NativeSankeyNode[]>();
387
- for (const node of nodes) {
388
- const level = depth.get(node.id) ?? 0;
389
- const list = columns.get(level) ?? [];
390
- list.push(node);
391
- columns.set(level, list);
392
- }
393
-
394
- const levels = [...columns.keys()].sort((a, b) => a - b);
395
- const columnWidth = 10;
396
- const gap = levels.length > 1 ? (width - columnWidth * levels.length) / (levels.length - 1) : 0;
397
-
398
- return (
399
- <View style={[{ width, height }, style]}>
400
- {nodes.map((node) => {
401
- const level = depth.get(node.id) ?? 0;
402
- const columnIndex = levels.indexOf(level);
403
- const siblings = columns.get(level) ?? [node];
404
- const position = siblings.indexOf(node);
405
- const slot = height / siblings.length;
406
-
407
- return (
408
- <View
409
- key={node.id}
410
- style={{
411
- position: "absolute",
412
- left: columnIndex * (columnWidth + gap),
413
- top: position * slot,
414
- width: columnWidth,
415
- height: Math.max(4, slot - 4),
416
- borderRadius: 2,
417
- backgroundColor: seriesColor(columnIndex, palette),
418
- }}
419
- />
420
- );
421
- })}
422
-
423
- {levels.map((level, i) => (
424
- <Text
425
- key={level}
426
- style={{
427
- position: "absolute",
428
- left: Math.min(width - 40, i * (columnWidth + gap) - 6),
429
- bottom: -16,
430
- fontSize: 9,
431
- color: theme.muted,
432
- width: 52,
433
- textAlign: "center",
434
- }}
435
- >
436
- {i === 0 ? "Start" : i === levels.length - 1 ? "End" : `Stage ${i}`}
437
- </Text>
438
- ))}
439
- </View>
440
- );
441
- }
442
-
443
- export interface NativeBumpSeries {
444
- name: string;
445
- /** Rank per period; 1 is best. */
446
- ranks: number[];
447
- color?: string;
448
- }
449
-
450
- export interface NativeBumpChartProps {
451
- labels: string[];
452
- series: NativeBumpSeries[];
453
- width?: number;
454
- height?: number;
455
- isDark?: boolean;
456
- palette?: readonly string[];
457
- style?: any;
458
- onPointPress?: (seriesIndex: number, periodIndex: number) => void;
459
- }
460
-
461
- /** Rank changes over time, where the vertical position is the rank itself. */
462
- export function NativeBumpChart({
463
- labels,
464
- series,
465
- width = 320,
466
- height = 200,
467
- isDark: isDarkProp,
468
- palette,
469
- style,
470
- onPointPress,
471
- }: NativeBumpChartProps) {
472
- const isDark = useIsDark(isDarkProp);
473
- const theme = isDark ? colors.dark : colors.light;
474
- const { View, Text, Pressable, Svg, G, Line, Circle, SvgText } = primitives();
475
-
476
- const periods = labels.length;
477
-
478
- if (periods === 0 || series.length === 0) {
479
- return (
480
- <View style={[{ width, alignItems: "center", paddingVertical: 20 }, style]}>
481
- <Text style={{ color: theme.muted, fontSize: 12 }}>No rankings to display</Text>
482
- </View>
483
- );
484
- }
485
-
486
- const allRanks = series.flatMap((entry) => entry.ranks).filter(Number.isFinite);
487
- const worst = allRanks.length ? Math.max(...allRanks) : 1;
488
- const best = allRanks.length ? Math.min(...allRanks) : 1;
489
-
490
- const padding = { top: 10, right: 10, bottom: 22, left: 10 };
491
- const plotWidth = Math.max(0, width - padding.left - padding.right);
492
- const plotHeight = Math.max(0, height - padding.top - padding.bottom);
493
-
494
- // Rank 1 sits at the top, so the axis is inverted.
495
- const y = (rank: number) => {
496
- if (worst === best) return padding.top + plotHeight / 2;
497
- return padding.top + ((rank - best) / (worst - best)) * plotHeight;
498
- };
499
- const x = (period: number) =>
500
- padding.left + (periods === 1 ? plotWidth / 2 : (period / (periods - 1)) * plotWidth);
501
-
502
- return (
503
- <View style={style}>
504
- <Svg width={width} height={height}>
505
- {series.map((entry, si) => {
506
- const color = entry.color ?? seriesColor(si, palette);
507
- return (
508
- <G key={entry.name}>
509
- {entry.ranks.slice(0, -1).map((rank, pi) => {
510
- const next = entry.ranks[pi + 1];
511
- if (next == null) return null;
512
- return (
513
- <Line
514
- key={pi}
515
- x1={x(pi)}
516
- y1={y(rank)}
517
- x2={x(pi + 1)}
518
- y2={y(next)}
519
- stroke={color}
520
- strokeWidth={2}
521
- />
522
- );
523
- })}
524
- {entry.ranks.map((rank, pi) => (
525
- <Circle
526
- key={pi}
527
- cx={x(pi)}
528
- cy={y(rank)}
529
- r={4}
530
- fill={color}
531
- onPress={() => onPointPress?.(si, pi)}
532
- />
533
- ))}
534
- </G>
535
- );
536
- })}
537
-
538
- {labels.map((label, pi) => (
539
- <SvgText
540
- key={label}
541
- x={x(pi)}
542
- y={height - 6}
543
- fill={theme.muted}
544
- fontSize={9}
545
- textAnchor="middle"
546
- >
547
- {label}
548
- </SvgText>
549
- ))}
550
- </Svg>
551
- </View>
552
- );
553
- }
554
-
555
- export interface NativeHexPoint {
556
- x: number;
557
- y: number;
558
- /** Drives the bin's colour. */
559
- value: number;
560
- label?: string;
561
- }
562
-
563
- export interface NativeHexChartProps {
564
- points: NativeHexPoint[];
565
- /** Bin radius in points. */
566
- radius?: number;
567
- width?: number;
568
- height?: number;
569
- isDark?: boolean;
570
- style?: any;
571
- onBinPress?: (index: number) => void;
572
- }
573
-
574
- /**
575
- * Points aggregated into hexagonal bins whose colour is the mean value.
576
- *
577
- * Binning keeps thousands of points legible: reading one mark's exact position
578
- * matters less than seeing where density is concentrated.
579
- */
580
- export function NativeHexChart({
581
- points,
582
- radius = 9,
583
- width = 320,
584
- height = 200,
585
- isDark: isDarkProp,
586
- style,
587
- onBinPress,
588
- }: NativeHexChartProps) {
589
- const [active, setActive] = useState<number | null>(null);
590
- const isDark = useIsDark(isDarkProp);
591
- const theme = isDark ? colors.dark : colors.light;
592
- const { View, Text, Pressable, Svg, G, Path } = primitives();
593
-
594
- if (points.length === 0) {
595
- return (
596
- <View style={[{ width, alignItems: "center", paddingVertical: 20 }, style]}>
597
- <Text style={{ color: theme.muted, fontSize: 12 }}>No points to display</Text>
598
- </View>
599
- );
600
- }
601
-
602
- const xs = points.map((point) => point.x);
603
- const ys = points.map((point) => point.y);
604
- const minX = Math.min(...xs);
605
- const maxX = Math.max(...xs) || 1;
606
- const minY = Math.min(...ys);
607
- const maxY = Math.max(...ys) || 1;
608
-
609
- const hexWidth = Math.sqrt(3) * radius;
610
- const columns = Math.max(1, Math.floor(width / hexWidth));
611
- const rowHeight = 1.5 * radius;
612
- const rows = Math.max(1, Math.floor(height / rowHeight));
613
-
614
- // Bin by nearest grid cell centre.
615
- const bins = new Map<string, { sum: number; count: number; cx: number; cy: number }>();
616
- for (const point of points) {
617
- const col = Math.min(columns - 1, Math.max(0, Math.floor(((point.x - minX) / (maxX - minX || 1)) * columns)));
618
- const row = Math.min(rows - 1, Math.max(0, Math.floor(((point.y - minY) / (maxY - minY || 1)) * rows)));
619
- const key = `${col}:${row}`;
620
- const existing = bins.get(key);
621
- const cx = col * hexWidth + hexWidth / 2 + (row % 2 ? hexWidth / 2 : 0);
622
- const cy = row * rowHeight + rowHeight / 2;
623
- if (existing) {
624
- existing.sum += point.value;
625
- existing.count += 1;
626
- } else {
627
- bins.set(key, { sum: point.value, count: 1, cx, cy });
628
- }
629
- }
630
-
631
- const means = [...bins.values()].map((bin) => bin.sum / bin.count);
632
- const lowest = Math.min(...means);
633
- const highest = Math.max(...means);
634
- const span = highest - lowest;
635
-
636
- const hexPath = (cx: number, cy: number) => {
637
- const points_: string[] = [];
638
- for (let i = 0; i < 6; i++) {
639
- const angle = (Math.PI / 3) * i - Math.PI / 2;
640
- points_.push(`${cx + radius * Math.cos(angle)},${cy + radius * Math.sin(angle)}`);
641
- }
642
- return "M " + points_.join(" L ") + " Z";
643
- };
644
-
645
- return (
646
- <View style={style}>
647
- <Svg width={width} height={height}>
648
- {[...bins.values()].map((bin, index) => {
649
- const mean = bin.sum / bin.count;
650
- const t = span === 0 ? 0.5 : (mean - lowest) / span;
651
- // Blue ramp from low to high density.
652
- const red = Math.round(210 - t * 130);
653
- const green = Math.round(225 - t * 90);
654
- const blue = Math.round(250 - t * 15);
655
- const color = `rgb(${red}, ${green}, ${blue})`;
656
-
657
- return (
658
- <G key={index}>
659
- <Path
660
- d={hexPath(bin.cx, bin.cy)}
661
- fill={color}
662
- fillOpacity={active === null || active === index ? 1 : 0.4}
663
- stroke={theme.edge}
664
- strokeWidth={0.5}
665
- onPress={() => {
666
- setActive((current) => (current === index ? null : index));
667
- onBinPress?.(index);
668
- }}
669
- />
670
- </G>
671
- );
672
- })}
673
- </Svg>
674
- </View>
675
- );
676
- }