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.
- package/LICENSE +29 -4
- package/README.md +111 -17
- package/lib/module/Accordion.js +58 -0
- package/lib/module/ActionSheet.js +38 -0
- package/lib/module/Alert.js +23 -0
- package/lib/module/AlertDialog.js +47 -0
- package/lib/module/Avatar.js +48 -0
- package/lib/module/Badge.js +36 -0
- package/lib/module/Bars.js +13 -267
- package/lib/module/Button.js +57 -36
- package/lib/module/Card.js +32 -20
- package/lib/module/Checkbox.js +42 -0
- package/lib/module/Chip.js +80 -0
- package/lib/module/Collapsible.js +26 -0
- package/lib/module/ContextMenu.js +33 -0
- package/lib/module/Dialog.js +39 -124
- package/lib/module/DropdownMenu.js +33 -0
- package/lib/module/Field.js +22 -0
- package/lib/module/Glass.js +12 -5
- package/lib/module/Group.js +36 -0
- package/lib/module/IconButton.js +40 -0
- package/lib/module/Input.js +47 -40
- package/lib/module/Label.js +17 -0
- package/lib/module/MorphGroup.js +47 -0
- package/lib/module/Popover.js +29 -0
- package/lib/module/Progress.js +32 -0
- package/lib/module/RadioGroup.js +51 -0
- package/lib/module/Scrim.js +44 -0
- package/lib/module/SegmentedControl.js +74 -58
- package/lib/module/Select.js +51 -0
- package/lib/module/Separator.js +25 -0
- package/lib/module/Sheet.js +51 -0
- package/lib/module/Skeleton.js +48 -0
- package/lib/module/Slider.js +60 -40
- package/lib/module/Stepper.js +167 -0
- package/lib/module/Switch.js +45 -43
- package/lib/module/TabBar.js +62 -50
- package/lib/module/Tabs.js +3 -2
- package/lib/module/Textarea.js +18 -0
- package/lib/module/Toast.js +55 -0
- package/lib/module/Toggle.js +47 -0
- package/lib/module/ToggleGroup.js +56 -0
- package/lib/module/Toolbar.js +37 -0
- package/lib/module/Tooltip.js +31 -0
- package/lib/module/glass-provider.js +28 -0
- package/lib/module/glass-stack.js +61 -0
- package/lib/module/index.js +78 -109
- package/lib/module/internal/GlassBackdrop.js +36 -0
- package/lib/module/internal/GlassView.js +45 -13
- package/lib/module/internal/blur-community.js +20 -0
- package/lib/module/internal/blur-community.web.js +9 -0
- package/lib/module/internal/blur.js +75 -0
- package/lib/module/internal/fallback.js +110 -20
- package/lib/module/internal/glass-routing.js +154 -30
- package/lib/module/internal/glow.js +36 -0
- package/lib/module/internal/initials.js +12 -0
- package/lib/module/internal/lens.js +70 -0
- package/lib/module/internal/material.js +64 -0
- package/lib/module/internal/overlay.js +147 -0
- package/lib/module/internal/primitives.js +17 -0
- package/lib/module/internal/rim.js +35 -0
- package/lib/module/internal/tokens.js +34 -2
- package/lib/typescript/Accordion.d.ts +22 -0
- package/lib/typescript/ActionSheet.d.ts +24 -0
- package/lib/typescript/Alert.d.ts +15 -0
- package/lib/typescript/AlertDialog.d.ts +17 -0
- package/lib/typescript/Avatar.d.ts +22 -0
- package/lib/typescript/Badge.d.ts +12 -0
- package/lib/typescript/Bars.d.ts +3 -188
- package/lib/typescript/Button.d.ts +44 -10
- package/lib/typescript/Card.d.ts +30 -3
- package/lib/typescript/Checkbox.d.ts +14 -0
- package/lib/typescript/Chip.d.ts +19 -0
- package/lib/typescript/Collapsible.d.ts +17 -0
- package/lib/typescript/ContextMenu.d.ts +23 -0
- package/lib/typescript/Dialog.d.ts +8 -68
- package/lib/typescript/DropdownMenu.d.ts +23 -0
- package/lib/typescript/Field.d.ts +19 -0
- package/lib/typescript/Glass.d.ts +11 -2
- package/lib/typescript/Group.d.ts +35 -0
- package/lib/typescript/IconButton.d.ts +21 -0
- package/lib/typescript/Input.d.ts +17 -18
- package/lib/typescript/Label.d.ts +14 -0
- package/lib/typescript/MorphGroup.d.ts +46 -0
- package/lib/typescript/Popover.d.ts +17 -0
- package/lib/typescript/Progress.d.ts +13 -0
- package/lib/typescript/RadioGroup.d.ts +21 -0
- package/lib/typescript/Scrim.d.ts +33 -0
- package/lib/typescript/SegmentedControl.d.ts +24 -13
- package/lib/typescript/Select.d.ts +19 -0
- package/lib/typescript/Separator.d.ts +10 -0
- package/lib/typescript/Sheet.d.ts +45 -0
- package/lib/typescript/Skeleton.d.ts +10 -0
- package/lib/typescript/Slider.d.ts +15 -7
- package/lib/typescript/Stepper.d.ts +49 -0
- package/lib/typescript/Switch.d.ts +19 -12
- package/lib/typescript/TabBar.d.ts +18 -6
- package/lib/typescript/Textarea.d.ts +6 -0
- package/lib/typescript/Toast.d.ts +40 -0
- package/lib/typescript/Toggle.d.ts +21 -0
- package/lib/typescript/ToggleGroup.d.ts +22 -0
- package/lib/typescript/Toolbar.d.ts +35 -0
- package/lib/typescript/Tooltip.d.ts +16 -0
- package/lib/typescript/glass-provider.d.ts +34 -0
- package/lib/typescript/glass-stack.d.ts +54 -0
- package/lib/typescript/index.d.ts +39 -17
- package/lib/typescript/internal/GlassBackdrop.d.ts +33 -0
- package/lib/typescript/internal/GlassView.d.ts +31 -2
- package/lib/typescript/internal/blur-community.d.ts +2 -0
- package/lib/typescript/internal/blur-community.web.d.ts +2 -0
- package/lib/typescript/internal/blur.d.ts +24 -0
- package/lib/typescript/internal/fallback.d.ts +27 -2
- package/lib/typescript/internal/glass-routing.d.ts +83 -15
- package/lib/typescript/internal/glow.d.ts +11 -0
- package/lib/typescript/internal/initials.d.ts +2 -0
- package/lib/typescript/internal/lens.d.ts +47 -0
- package/lib/typescript/internal/material.d.ts +27 -0
- package/lib/typescript/internal/overlay.d.ts +74 -0
- package/lib/typescript/internal/primitives.d.ts +13 -0
- package/lib/typescript/internal/rim.d.ts +16 -0
- package/lib/typescript/internal/tokens.d.ts +36 -0
- package/package.json +15 -4
- package/src/Accordion.tsx +165 -0
- package/src/ActionSheet.tsx +149 -0
- package/src/Alert.tsx +85 -0
- package/src/AlertDialog.tsx +124 -0
- package/src/Avatar.tsx +102 -0
- package/src/Badge.tsx +80 -0
- package/src/Bars.tsx +10 -797
- package/src/Button.tsx +196 -60
- package/src/Card.tsx +106 -33
- package/src/Checkbox.tsx +98 -0
- package/src/Chip.tsx +149 -0
- package/src/Collapsible.tsx +66 -0
- package/src/ContextMenu.tsx +103 -0
- package/src/Dialog.tsx +86 -325
- package/src/DropdownMenu.tsx +103 -0
- package/src/Field.tsx +65 -0
- package/src/Glass.tsx +19 -5
- package/src/Group.tsx +98 -0
- package/src/IconButton.tsx +110 -0
- package/src/Input.tsx +143 -87
- package/src/Label.tsx +56 -0
- package/src/MorphGroup.tsx +134 -0
- package/src/Popover.tsx +81 -0
- package/src/Progress.tsx +83 -0
- package/src/RadioGroup.tsx +122 -0
- package/src/Scrim.tsx +94 -0
- package/src/SegmentedControl.tsx +147 -90
- package/src/Select.tsx +136 -0
- package/src/Separator.tsx +52 -0
- package/src/Sheet.tsx +139 -0
- package/src/Skeleton.tsx +77 -0
- package/src/Slider.tsx +100 -54
- package/src/Stepper.tsx +315 -0
- package/src/Switch.tsx +80 -58
- package/src/TabBar.tsx +118 -84
- package/src/Tabs.tsx +5 -0
- package/src/Textarea.tsx +34 -0
- package/src/Toast.tsx +131 -0
- package/src/Toggle.tsx +113 -0
- package/src/ToggleGroup.tsx +129 -0
- package/src/Toolbar.tsx +111 -0
- package/src/Tooltip.tsx +79 -0
- package/src/engine/CHANGELOG.md +430 -0
- package/src/engine/NOTICE +54 -0
- package/src/engine/README.md +975 -0
- package/src/engine/android/build.gradle +18 -0
- package/src/engine/android/src/main/AndroidManifest.xml +2 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/ExpoLiquidGlassModule.kt +174 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/GlassConstants.kt +7 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassContainerView.kt +16 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassProviderView.kt +165 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassView.kt +1731 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/enums/GlassEnums.kt +171 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/BackdropGraph.kt +146 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/BackdropSource.kt +53 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/ContinuousCorners.kt +188 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/CornerRadii.kt +62 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassAppearance.kt +352 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassDebug.kt +109 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassEnvironment.kt +139 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassHdr.kt +85 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassLuminanceProbe.kt +189 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassPressAnimator.kt +264 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassProgressiveBlur.kt +249 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassShaderCache.kt +256 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassShaderSource.kt +845 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassTier.kt +63 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/ProviderRegistry.kt +71 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/records/GlassRecords.kt +288 -0
- package/src/engine/index.ts +24 -0
- package/src/engine/ios/Enums/GlassBlurDirection.swift +21 -0
- package/src/engine/ios/Enums/GlassVariant.swift +86 -0
- package/src/engine/ios/ExpoLiquidGlass.podspec +93 -0
- package/src/engine/ios/ExpoLiquidGlassModule.swift +77 -0
- package/src/engine/ios/Glass/BackdropCapturer.swift +811 -0
- package/src/engine/ios/Glass/ContinuousCorners.swift +165 -0
- package/src/engine/ios/Glass/GlassBackdrop.swift +176 -0
- package/src/engine/ios/Glass/GlassFramePhase.swift +126 -0
- package/src/engine/ios/Glass/GlassFrameScheduler.swift +261 -0
- package/src/engine/ios/Glass/GlassPressAnimator.swift +250 -0
- package/src/engine/ios/Glass/GlassRenderContext.swift +168 -0
- package/src/engine/ios/Glass/GlassRenderer.swift +186 -0
- package/src/engine/ios/Glass/GlassSurfaceView.swift +452 -0
- package/src/engine/ios/Glass/NonRenderableView.swift +54 -0
- package/src/engine/ios/Glass/StripCache.swift +545 -0
- package/src/engine/ios/Records/GlassCornerRadii.swift +79 -0
- package/src/engine/ios/Records/GlassMetalOptions.swift +180 -0
- package/src/engine/ios/Records/GlassRefractionCurve.swift +14 -0
- package/src/engine/ios/Shaders/LiquidGlass.metal +480 -0
- package/src/engine/ios/Shaders/bundle-marker.txt +6 -0
- package/src/engine/ios/Views/LiquidGlassContainerView.swift +99 -0
- package/src/engine/ios/Views/LiquidGlassView.swift +859 -0
- package/src/engine/package.json +70 -0
- package/src/engine/src/components/LiquidGlassButton/LiquidGlassButton.tsx +424 -0
- package/src/engine/src/components/LiquidGlassCard/LiquidGlassCard.tsx +98 -0
- package/src/engine/src/components/LiquidGlassChip/LiquidGlassChip.tsx +65 -0
- package/src/engine/src/components/LiquidGlassGroup/LiquidGlassGroup.tsx +350 -0
- package/src/engine/src/components/LiquidGlassIconButton/LiquidGlassIconButton.tsx +24 -0
- package/src/engine/src/components/LiquidGlassMorphGroup/LiquidGlassMorphGroup.tsx +434 -0
- package/src/engine/src/components/LiquidGlassScrim/LiquidGlassScrim.tsx +100 -0
- package/src/engine/src/components/LiquidGlassSegmentedControl/LiquidGlassSegmentedControl.tsx +213 -0
- package/src/engine/src/components/LiquidGlassSheet/LiquidGlassSheet.tsx +218 -0
- package/src/engine/src/components/LiquidGlassSlider/LiquidGlassSlider.tsx +327 -0
- package/src/engine/src/components/LiquidGlassStepper/LiquidGlassStepper.tsx +321 -0
- package/src/engine/src/components/LiquidGlassSwitch/LiquidGlassSwitch.tsx +296 -0
- package/src/engine/src/components/LiquidGlassTabBar/LiquidGlassTabBar.tsx +952 -0
- package/src/engine/src/components/LiquidGlassTextInput/LiquidGlassTextInput.tsx +151 -0
- package/src/engine/src/components/LiquidGlassToast/LiquidGlassToast.tsx +169 -0
- package/src/engine/src/components/LiquidGlassToolbar/LiquidGlassToolbar.tsx +124 -0
- package/src/engine/src/components/index.ts +16 -0
- package/src/engine/src/constants/index.ts +4 -0
- package/src/engine/src/constants/metal.constants.ts +327 -0
- package/src/engine/src/constants/metrics.constants.ts +325 -0
- package/src/engine/src/constants/springs.constants.ts +107 -0
- package/src/engine/src/constants/styles.constants.ts +12 -0
- package/src/engine/src/context/glass-group.context.ts +65 -0
- package/src/engine/src/context/index.ts +6 -0
- package/src/engine/src/core/components/LiquidGlassContainer/LiquidGlassContainer.tsx +32 -0
- package/src/engine/src/core/components/LiquidGlassContainer/index.ts +1 -0
- package/src/engine/src/core/components/LiquidGlassProvider/LiquidGlassProvider.tsx +66 -0
- package/src/engine/src/core/components/LiquidGlassProvider/index.ts +1 -0
- package/src/engine/src/core/components/LiquidGlassStack/LiquidGlassStack.tsx +184 -0
- package/src/engine/src/core/components/LiquidGlassStack/index.ts +1 -0
- package/src/engine/src/core/components/LiquidGlassView/LiquidGlassView.tsx +126 -0
- package/src/engine/src/core/components/LiquidGlassView/index.ts +1 -0
- package/src/engine/src/core/components/index.ts +4 -0
- package/src/engine/src/core/constants/glass.constants.ts +57 -0
- package/src/engine/src/core/constants/index.ts +20 -0
- package/src/engine/src/core/constants/native.constants.ts +16 -0
- package/src/engine/src/core/context/glass-stack.context.ts +30 -0
- package/src/engine/src/core/context/index.ts +4 -0
- package/src/engine/src/core/enum/index.ts +12 -0
- package/src/engine/src/core/index.ts +1 -0
- package/src/engine/src/core/interfaces/glass-hdr.interface.ts +15 -0
- package/src/engine/src/core/interfaces/glass-metal.interface.ts +248 -0
- package/src/engine/src/core/interfaces/glass-surface.interface.ts +9 -0
- package/src/engine/src/core/interfaces/index.ts +31 -0
- package/src/engine/src/core/interfaces/liquid-glass-container.interface.ts +6 -0
- package/src/engine/src/core/interfaces/liquid-glass-provider.interface.ts +14 -0
- package/src/engine/src/core/interfaces/liquid-glass-stack.interface.ts +21 -0
- package/src/engine/src/core/interfaces/liquid-glass-view.interface.ts +129 -0
- package/src/engine/src/core/interfaces/native-liquid-glass-view.interface.ts +19 -0
- package/src/engine/src/core/modules/ExpoLiquidGlassModule.ts +26 -0
- package/src/engine/src/core/modules/index.ts +2 -0
- package/src/engine/src/core/root/index.ts +51 -0
- package/src/engine/src/core/types/glass.types.ts +25 -0
- package/src/engine/src/core/types/index.ts +8 -0
- package/src/engine/src/core/utils/debug.utils.ts +17 -0
- package/src/engine/src/core/utils/dev-warn.utils.ts +17 -0
- package/src/engine/src/core/utils/hdr.utils.ts +37 -0
- package/src/engine/src/core/utils/index.ts +5 -0
- package/src/engine/src/core/utils/native-view.utils.ts +33 -0
- package/src/engine/src/core/utils/platform.utils.ts +34 -0
- package/src/engine/src/core/views/NativeGlassBackdropView.ts +24 -0
- package/src/engine/src/core/views/NativeLiquidGlassContainerView.ts +13 -0
- package/src/engine/src/core/views/NativeLiquidGlassContainerView.web.ts +10 -0
- package/src/engine/src/core/views/NativeLiquidGlassProviderView.ts +13 -0
- package/src/engine/src/core/views/NativeLiquidGlassProviderView.web.ts +10 -0
- package/src/engine/src/core/views/NativeLiquidGlassView.ts +19 -0
- package/src/engine/src/core/views/NativeLiquidGlassView.web.ts +14 -0
- package/src/engine/src/core/views/index.ts +4 -0
- package/src/engine/src/hooks/index.ts +18 -0
- package/src/engine/src/hooks/use-adaptive-glass.ts +91 -0
- package/src/engine/src/hooks/use-damped-drag.ts +332 -0
- package/src/engine/src/hooks/use-echo-filter.ts +55 -0
- package/src/engine/src/hooks/use-glass-group-member.ts +169 -0
- package/src/engine/src/hooks/use-gravity-highlight.ts +79 -0
- package/src/engine/src/hooks/use-press-progress.ts +44 -0
- package/src/engine/src/index.ts +120 -0
- package/src/engine/src/interfaces/index.ts +28 -0
- package/src/engine/src/interfaces/liquid-glass-button.interface.ts +94 -0
- package/src/engine/src/interfaces/liquid-glass-card.interface.ts +40 -0
- package/src/engine/src/interfaces/liquid-glass-chip.interface.ts +29 -0
- package/src/engine/src/interfaces/liquid-glass-group.interface.ts +32 -0
- package/src/engine/src/interfaces/liquid-glass-icon-button.interface.ts +19 -0
- package/src/engine/src/interfaces/liquid-glass-morph-group.interface.ts +59 -0
- package/src/engine/src/interfaces/liquid-glass-scrim.interface.ts +36 -0
- package/src/engine/src/interfaces/liquid-glass-segmented-control.interface.ts +32 -0
- package/src/engine/src/interfaces/liquid-glass-sheet.interface.ts +38 -0
- package/src/engine/src/interfaces/liquid-glass-slider.interface.ts +37 -0
- package/src/engine/src/interfaces/liquid-glass-stepper.interface.ts +35 -0
- package/src/engine/src/interfaces/liquid-glass-switch.interface.ts +27 -0
- package/src/engine/src/interfaces/liquid-glass-tab-bar.interface.ts +116 -0
- package/src/engine/src/interfaces/liquid-glass-text-input.interface.ts +42 -0
- package/src/engine/src/interfaces/liquid-glass-toast.interface.ts +36 -0
- package/src/engine/src/interfaces/liquid-glass-toolbar.interface.ts +33 -0
- package/src/engine/src/theme/glass-ui-theme.ts +100 -0
- package/src/engine/src/theme/index.ts +2 -0
- package/src/engine/src/utils/button-press.utils.ts +63 -0
- package/src/engine/src/utils/index.ts +3 -0
- package/src/engine/src/utils/metal.utils.ts +164 -0
- package/src/glass-provider.tsx +60 -0
- package/src/glass-stack.tsx +115 -0
- package/src/index.ts +48 -190
- package/src/internal/GlassBackdrop.tsx +60 -0
- package/src/internal/GlassView.tsx +70 -18
- package/src/internal/blur-community.ts +19 -0
- package/src/internal/blur-community.web.ts +7 -0
- package/src/internal/blur.ts +89 -0
- package/src/internal/fallback.tsx +158 -20
- package/src/internal/glass-routing.ts +211 -34
- package/src/internal/glow.tsx +62 -0
- package/src/internal/initials.ts +7 -0
- package/src/internal/lens.tsx +105 -0
- package/src/internal/material.ts +92 -0
- package/src/internal/overlay.tsx +258 -0
- package/src/internal/primitives.ts +26 -0
- package/src/internal/rim.tsx +79 -0
- package/src/internal/tokens.ts +34 -1
- package/lib/module/Carousel.js +0 -103
- package/lib/module/Display.js +0 -317
- package/lib/module/Feedback.js +0 -386
- package/lib/module/Form.js +0 -164
- package/lib/module/Forms2.js +0 -454
- package/lib/module/Message.js +0 -88
- package/lib/module/Overlays.js +0 -328
- package/lib/module/Pickers.js +0 -243
- package/lib/module/Table.js +0 -99
- package/lib/module/ai.js +0 -280
- package/lib/module/charts/AreaChart.js +0 -32
- package/lib/module/charts/BarChart.js +0 -67
- package/lib/module/charts/FunnelChart.js +0 -50
- package/lib/module/charts/HeatmapChart.js +0 -71
- package/lib/module/charts/LineChart.js +0 -81
- package/lib/module/charts/PlotChart.js +0 -52
- package/lib/module/charts/RadarChart.js +0 -78
- package/lib/module/charts/RingChart.js +0 -52
- package/lib/module/charts/ScatterChart.js +0 -95
- package/lib/module/charts/WaterfallChart.js +0 -85
- package/lib/module/charts/advanced.js +0 -313
- package/lib/module/charts/extra.js +0 -108
- package/lib/module/charts/index.js +0 -50
- package/lib/module/charts/scales.js +0 -140
- package/lib/typescript/Carousel.d.ts +0 -47
- package/lib/typescript/Display.d.ts +0 -178
- package/lib/typescript/Feedback.d.ts +0 -196
- package/lib/typescript/Form.d.ts +0 -97
- package/lib/typescript/Forms2.d.ts +0 -209
- package/lib/typescript/Message.d.ts +0 -71
- package/lib/typescript/Overlays.d.ts +0 -146
- package/lib/typescript/Pickers.d.ts +0 -105
- package/lib/typescript/Table.d.ts +0 -64
- package/lib/typescript/ai.d.ts +0 -166
- package/lib/typescript/charts/AreaChart.d.ts +0 -44
- package/lib/typescript/charts/BarChart.d.ts +0 -19
- package/lib/typescript/charts/FunnelChart.d.ts +0 -25
- package/lib/typescript/charts/HeatmapChart.d.ts +0 -23
- package/lib/typescript/charts/LineChart.d.ts +0 -30
- package/lib/typescript/charts/PlotChart.d.ts +0 -31
- package/lib/typescript/charts/RadarChart.d.ts +0 -27
- package/lib/typescript/charts/RingChart.d.ts +0 -28
- package/lib/typescript/charts/ScatterChart.d.ts +0 -34
- package/lib/typescript/charts/WaterfallChart.d.ts +0 -22
- package/lib/typescript/charts/advanced.d.ts +0 -107
- package/lib/typescript/charts/extra.d.ts +0 -63
- package/lib/typescript/charts/index.d.ts +0 -13
- package/lib/typescript/charts/scales.d.ts +0 -35
- package/src/Carousel.tsx +0 -233
- package/src/Display.tsx +0 -778
- package/src/Feedback.tsx +0 -969
- package/src/Form.tsx +0 -425
- package/src/Forms2.tsx +0 -1014
- package/src/Message.tsx +0 -219
- package/src/Overlays.tsx +0 -685
- package/src/Pickers.tsx +0 -590
- package/src/Table.tsx +0 -231
- package/src/ai.tsx +0 -707
- package/src/charts/AreaChart.tsx +0 -73
- package/src/charts/BarChart.tsx +0 -183
- package/src/charts/FunnelChart.tsx +0 -125
- package/src/charts/HeatmapChart.tsx +0 -155
- package/src/charts/LineChart.tsx +0 -247
- package/src/charts/PlotChart.tsx +0 -168
- package/src/charts/RadarChart.tsx +0 -208
- package/src/charts/RingChart.tsx +0 -133
- package/src/charts/ScatterChart.tsx +0 -223
- package/src/charts/WaterfallChart.tsx +0 -201
- package/src/charts/advanced.tsx +0 -676
- package/src/charts/extra.tsx +0 -242
- package/src/charts/index.ts +0 -86
- package/src/charts/scales.ts +0 -163
package/src/charts/AreaChart.tsx
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { NativeLineChart, type NativeLineSeries } from "./LineChart";
|
|
2
|
-
|
|
3
|
-
export interface NativeAreaChartProps {
|
|
4
|
-
labels: string[];
|
|
5
|
-
series: NativeLineSeries[];
|
|
6
|
-
width?: number;
|
|
7
|
-
height?: number;
|
|
8
|
-
smooth?: boolean;
|
|
9
|
-
isDark?: boolean;
|
|
10
|
-
palette?: readonly string[];
|
|
11
|
-
style?: any;
|
|
12
|
-
onPointPress?: (index: number) => void;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* A continuous series with its area filled.
|
|
17
|
-
*
|
|
18
|
-
* This is NativeLineChart drawing filled: the same scales, axis ticks and
|
|
19
|
-
* touch targets, so the two stay consistent when used side by side.
|
|
20
|
-
*/
|
|
21
|
-
export function NativeAreaChart(props: NativeAreaChartProps) {
|
|
22
|
-
return <NativeLineChart {...props} area />;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface NativeMirrorAreaSeries {
|
|
26
|
-
name: string;
|
|
27
|
-
/** Positive values drawn upward. */
|
|
28
|
-
above: number[];
|
|
29
|
-
/** Positive values drawn downward. */
|
|
30
|
-
below: number[];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface NativeMirrorAreaChartProps {
|
|
34
|
-
labels: string[];
|
|
35
|
-
series: NativeMirrorAreaSeries;
|
|
36
|
-
width?: number;
|
|
37
|
-
height?: number;
|
|
38
|
-
aboveColor?: string;
|
|
39
|
-
belowColor?: string;
|
|
40
|
-
isDark?: boolean;
|
|
41
|
-
style?: any;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Two series mirrored across a shared centre line.
|
|
46
|
-
*
|
|
47
|
-
* The below series is negated and drawn on the same axis as the above series,
|
|
48
|
-
* so both directions are measured against one honest scale rather than two
|
|
49
|
-
* charts that could be scaled differently.
|
|
50
|
-
*/
|
|
51
|
-
export function NativeMirrorAreaChart({
|
|
52
|
-
labels,
|
|
53
|
-
series,
|
|
54
|
-
aboveColor = "#0088ff",
|
|
55
|
-
belowColor = "#ff375f",
|
|
56
|
-
...rest
|
|
57
|
-
}: NativeMirrorAreaChartProps) {
|
|
58
|
-
return (
|
|
59
|
-
<NativeLineChart
|
|
60
|
-
{...rest}
|
|
61
|
-
labels={labels}
|
|
62
|
-
area
|
|
63
|
-
series={[
|
|
64
|
-
{ name: `${series.name} (above)`, values: series.above, color: aboveColor },
|
|
65
|
-
{
|
|
66
|
-
name: `${series.name} (below)`,
|
|
67
|
-
values: series.below.map((v) => -Math.abs(v)),
|
|
68
|
-
color: belowColor,
|
|
69
|
-
},
|
|
70
|
-
]}
|
|
71
|
-
/>
|
|
72
|
-
);
|
|
73
|
-
}
|
package/src/charts/BarChart.tsx
DELETED
|
@@ -1,183 +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 { bandScale, formatValue, linearScale, niceDomain, seriesColor, ticks } from "./scales";
|
|
7
|
-
|
|
8
|
-
export interface NativeBarSeries {
|
|
9
|
-
name: string;
|
|
10
|
-
values: number[];
|
|
11
|
-
color?: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface NativeBarChartProps {
|
|
15
|
-
labels: string[];
|
|
16
|
-
series: NativeBarSeries[];
|
|
17
|
-
width?: number;
|
|
18
|
-
height?: number;
|
|
19
|
-
stacked?: boolean;
|
|
20
|
-
radius?: number;
|
|
21
|
-
isDark?: boolean;
|
|
22
|
-
palette?: readonly string[];
|
|
23
|
-
style?: any;
|
|
24
|
-
onBarPress?: (index: number) => void;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const PADDING = { top: 12, right: 10, bottom: 24, left: 38 };
|
|
28
|
-
|
|
29
|
-
/** Grouped or stacked bars, drawn with react-native-svg. */
|
|
30
|
-
export function NativeBarChart({
|
|
31
|
-
labels,
|
|
32
|
-
series,
|
|
33
|
-
width = 320,
|
|
34
|
-
height = 200,
|
|
35
|
-
stacked = false,
|
|
36
|
-
radius = 4,
|
|
37
|
-
isDark: isDarkProp,
|
|
38
|
-
palette,
|
|
39
|
-
style,
|
|
40
|
-
onBarPress,
|
|
41
|
-
}: NativeBarChartProps) {
|
|
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, Pressable, Svg, G, Line, Rect, SvgText } = primitives();
|
|
46
|
-
|
|
47
|
-
const plot = {
|
|
48
|
-
x: PADDING.left,
|
|
49
|
-
y: PADDING.top,
|
|
50
|
-
width: Math.max(0, width - PADDING.left - PADDING.right),
|
|
51
|
-
height: Math.max(0, height - PADDING.top - PADDING.bottom),
|
|
52
|
-
};
|
|
53
|
-
const bottom = plot.y + plot.height;
|
|
54
|
-
const right = plot.x + plot.width;
|
|
55
|
-
|
|
56
|
-
const totals = stacked
|
|
57
|
-
? labels.map((_, i) => series.reduce((sum, s) => sum + (s.values[i] ?? 0), 0))
|
|
58
|
-
: series.flatMap((s) => s.values);
|
|
59
|
-
|
|
60
|
-
const domain = useMemo(() => {
|
|
61
|
-
const max = totals.length ? Math.max(...totals) : 1;
|
|
62
|
-
return niceDomain(0, max, 4);
|
|
63
|
-
}, [totals.join(",")]);
|
|
64
|
-
|
|
65
|
-
const y = linearScale(domain, [bottom, plot.y], { nice: false });
|
|
66
|
-
const bands = bandScale(labels.length, [plot.x, right], 0.32);
|
|
67
|
-
const barWidth = stacked ? bands.width : bands.width / Math.max(1, series.length);
|
|
68
|
-
const yTicks = ticks(domain, 4);
|
|
69
|
-
|
|
70
|
-
if (labels.length === 0 || series.length === 0) {
|
|
71
|
-
return (
|
|
72
|
-
<View style={[{ width, height, alignItems: "center", justifyContent: "center" }, style]}>
|
|
73
|
-
<Text style={{ color: theme.muted, fontSize: 12 }}>No bars to display</Text>
|
|
74
|
-
</View>
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return (
|
|
79
|
-
<View style={style}>
|
|
80
|
-
<Svg width={width} height={height}>
|
|
81
|
-
{yTicks.map((tick, i) => (
|
|
82
|
-
<Line
|
|
83
|
-
key={`grid-${i}`}
|
|
84
|
-
x1={plot.x}
|
|
85
|
-
x2={right}
|
|
86
|
-
y1={y(tick)}
|
|
87
|
-
y2={y(tick)}
|
|
88
|
-
stroke={theme.axis}
|
|
89
|
-
strokeOpacity={0.24}
|
|
90
|
-
strokeWidth={1}
|
|
91
|
-
/>
|
|
92
|
-
))}
|
|
93
|
-
|
|
94
|
-
{labels.map((label, i) => {
|
|
95
|
-
let stackTop = bottom;
|
|
96
|
-
|
|
97
|
-
return (
|
|
98
|
-
<G key={label + i}>
|
|
99
|
-
{series.map((s, si) => {
|
|
100
|
-
const value = s.values[i] ?? 0;
|
|
101
|
-
const color = s.color ?? seriesColor(si, palette);
|
|
102
|
-
const barHeight = Math.max(0, bottom - y(value));
|
|
103
|
-
|
|
104
|
-
const barX = stacked
|
|
105
|
-
? bands.start(i)
|
|
106
|
-
: bands.start(i) + si * barWidth + (si > 0 ? 1 : 0);
|
|
107
|
-
const barY = stacked ? stackTop - barHeight : y(value);
|
|
108
|
-
const w = stacked ? bands.width : Math.max(1, barWidth - (si > 0 ? 1 : 0));
|
|
109
|
-
|
|
110
|
-
if (stacked) stackTop -= barHeight;
|
|
111
|
-
|
|
112
|
-
return (
|
|
113
|
-
<Rect
|
|
114
|
-
key={s.name}
|
|
115
|
-
x={barX}
|
|
116
|
-
y={barY}
|
|
117
|
-
width={w}
|
|
118
|
-
height={barHeight}
|
|
119
|
-
rx={Math.min(radius, w / 2)}
|
|
120
|
-
fill={color}
|
|
121
|
-
opacity={active === null || active === i ? 1 : 0.45}
|
|
122
|
-
/>
|
|
123
|
-
);
|
|
124
|
-
})}
|
|
125
|
-
</G>
|
|
126
|
-
);
|
|
127
|
-
})}
|
|
128
|
-
|
|
129
|
-
{yTicks.map((tick, i) => (
|
|
130
|
-
<SvgText
|
|
131
|
-
key={`y-${i}`}
|
|
132
|
-
x={plot.x - 6}
|
|
133
|
-
y={y(tick) + 3}
|
|
134
|
-
fill={theme.muted}
|
|
135
|
-
fontSize={9}
|
|
136
|
-
textAnchor="end"
|
|
137
|
-
>
|
|
138
|
-
{formatValue(tick, { compact: true })}
|
|
139
|
-
</SvgText>
|
|
140
|
-
))}
|
|
141
|
-
|
|
142
|
-
{labels.map((label, i) => (
|
|
143
|
-
<SvgText
|
|
144
|
-
key={`x-${i}`}
|
|
145
|
-
x={bands.center(i)}
|
|
146
|
-
y={height - 8}
|
|
147
|
-
fill={theme.muted}
|
|
148
|
-
fontSize={9}
|
|
149
|
-
textAnchor="middle"
|
|
150
|
-
>
|
|
151
|
-
{label}
|
|
152
|
-
</SvgText>
|
|
153
|
-
))}
|
|
154
|
-
</Svg>
|
|
155
|
-
|
|
156
|
-
<View
|
|
157
|
-
style={{
|
|
158
|
-
position: "absolute",
|
|
159
|
-
left: plot.x,
|
|
160
|
-
top: plot.y,
|
|
161
|
-
width: plot.width,
|
|
162
|
-
height: plot.height,
|
|
163
|
-
flexDirection: "row",
|
|
164
|
-
}}
|
|
165
|
-
>
|
|
166
|
-
{labels.map((label, i) => (
|
|
167
|
-
<Pressable
|
|
168
|
-
key={label + i}
|
|
169
|
-
accessibilityRole="button"
|
|
170
|
-
accessibilityLabel={`${label}: ${series
|
|
171
|
-
.map((s) => `${s.name} ${formatValue(s.values[i] ?? 0)}`)
|
|
172
|
-
.join(", ")}`}
|
|
173
|
-
style={{ flex: 1 }}
|
|
174
|
-
onPress={() => {
|
|
175
|
-
setActive((current) => (current === i ? null : i));
|
|
176
|
-
onBarPress?.(i);
|
|
177
|
-
}}
|
|
178
|
-
/>
|
|
179
|
-
))}
|
|
180
|
-
</View>
|
|
181
|
-
</View>
|
|
182
|
-
);
|
|
183
|
-
}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { 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, seriesColor } from "./scales";
|
|
7
|
-
|
|
8
|
-
export interface NativeFunnelStage {
|
|
9
|
-
label: string;
|
|
10
|
-
value: number;
|
|
11
|
-
color?: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface NativeFunnelChartProps {
|
|
15
|
-
stages: NativeFunnelStage[];
|
|
16
|
-
width?: number;
|
|
17
|
-
stageHeight?: number;
|
|
18
|
-
/** Value the first stage is measured against. Defaults to its own value. */
|
|
19
|
-
baseline?: number;
|
|
20
|
-
isDark?: boolean;
|
|
21
|
-
palette?: readonly string[];
|
|
22
|
-
style?: any;
|
|
23
|
-
onStagePress?: (index: number) => void;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* A sequence of stages where each narrows the one before it.
|
|
28
|
-
*
|
|
29
|
-
* Built from plain Views rather than SVG: a funnel is a set of proportional
|
|
30
|
-
* rectangles, so vector drawing would add a dependency for nothing. Each row
|
|
31
|
-
* shows its own value, its share of entry, and the step conversion — the three
|
|
32
|
-
* numbers a funnel is actually read for.
|
|
33
|
-
*/
|
|
34
|
-
export function NativeFunnelChart({
|
|
35
|
-
stages,
|
|
36
|
-
width = 320,
|
|
37
|
-
stageHeight = 38,
|
|
38
|
-
baseline,
|
|
39
|
-
isDark: isDarkProp,
|
|
40
|
-
palette,
|
|
41
|
-
style,
|
|
42
|
-
onStagePress,
|
|
43
|
-
}: NativeFunnelChartProps) {
|
|
44
|
-
const [active, setActive] = useState<number | null>(null);
|
|
45
|
-
const isDark = useIsDark(isDarkProp);
|
|
46
|
-
const theme = isDark ? colors.dark : colors.light;
|
|
47
|
-
const { View, Text, Pressable } = primitives();
|
|
48
|
-
|
|
49
|
-
if (stages.length === 0) {
|
|
50
|
-
return (
|
|
51
|
-
<View style={[{ width, alignItems: "center", paddingVertical: 20 }, style]}>
|
|
52
|
-
<Text style={{ color: theme.muted, fontSize: 12 }}>No stages to display</Text>
|
|
53
|
-
</View>
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const entry = baseline ?? stages[0]?.value ?? 1;
|
|
58
|
-
const widest = Math.max(entry, ...stages.map((s) => s.value)) || 1;
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<View style={[{ width }, style]}>
|
|
62
|
-
{stages.map((stage, i) => {
|
|
63
|
-
const previous = i === 0 ? null : stages[i - 1]!.value;
|
|
64
|
-
const stepRate = previous && previous > 0 ? stage.value / previous : null;
|
|
65
|
-
const share = entry > 0 ? stage.value / entry : 0;
|
|
66
|
-
const color = stage.color ?? seriesColor(i, palette);
|
|
67
|
-
const widthPercent = Math.max(0.02, stage.value / widest);
|
|
68
|
-
|
|
69
|
-
return (
|
|
70
|
-
<Pressable
|
|
71
|
-
key={stage.label}
|
|
72
|
-
accessibilityRole="button"
|
|
73
|
-
accessibilityLabel={`${stage.label}: ${formatValue(stage.value)}, ${Math.round(
|
|
74
|
-
share * 100,
|
|
75
|
-
)} percent of entry`}
|
|
76
|
-
onPress={() => {
|
|
77
|
-
setActive((current) => (current === i ? null : i));
|
|
78
|
-
onStagePress?.(i);
|
|
79
|
-
}}
|
|
80
|
-
style={{ marginBottom: i < stages.length - 1 ? 10 : 0 }}
|
|
81
|
-
>
|
|
82
|
-
<View style={{ flexDirection: "row", justifyContent: "space-between", marginBottom: 4 }}>
|
|
83
|
-
<Text style={{ color: theme.foreground, fontSize: 12, fontWeight: "500" }}>
|
|
84
|
-
{stage.label}
|
|
85
|
-
</Text>
|
|
86
|
-
<Text style={{ color: theme.muted, fontSize: 12 }}>
|
|
87
|
-
{formatValue(stage.value, { compact: true })}
|
|
88
|
-
</Text>
|
|
89
|
-
</View>
|
|
90
|
-
|
|
91
|
-
<View
|
|
92
|
-
style={{
|
|
93
|
-
height: stageHeight,
|
|
94
|
-
borderRadius: 10,
|
|
95
|
-
backgroundColor: isDark ? "rgba(235,235,245,0.08)" : "rgba(0,0,0,0.05)",
|
|
96
|
-
overflow: "hidden",
|
|
97
|
-
}}
|
|
98
|
-
>
|
|
99
|
-
<View
|
|
100
|
-
style={{
|
|
101
|
-
width: `${widthPercent * 100}%`,
|
|
102
|
-
height: "100%",
|
|
103
|
-
borderRadius: 10,
|
|
104
|
-
backgroundColor: color,
|
|
105
|
-
opacity: active === null || active === i ? 1 : 0.5,
|
|
106
|
-
}}
|
|
107
|
-
/>
|
|
108
|
-
</View>
|
|
109
|
-
|
|
110
|
-
<View style={{ flexDirection: "row", gap: 10, marginTop: 3 }}>
|
|
111
|
-
<Text style={{ color: theme.muted, fontSize: 10 }}>
|
|
112
|
-
{Math.round(share * 100)}% of entry
|
|
113
|
-
</Text>
|
|
114
|
-
{stepRate !== null && (
|
|
115
|
-
<Text style={{ color: theme.muted, fontSize: 10 }}>
|
|
116
|
-
{Math.round(stepRate * 100)}% from previous
|
|
117
|
-
</Text>
|
|
118
|
-
)}
|
|
119
|
-
</View>
|
|
120
|
-
</Pressable>
|
|
121
|
-
);
|
|
122
|
-
})}
|
|
123
|
-
</View>
|
|
124
|
-
);
|
|
125
|
-
}
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { 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 } from "./scales";
|
|
7
|
-
|
|
8
|
-
export interface NativeHeatmapChartProps {
|
|
9
|
-
/** One row per series, each holding one value per column. */
|
|
10
|
-
rows: { label: string; values: number[] }[];
|
|
11
|
-
columns: string[];
|
|
12
|
-
cellSize?: number;
|
|
13
|
-
cellGap?: number;
|
|
14
|
-
isDark?: boolean;
|
|
15
|
-
/** Colour for the lowest and highest values. Defaults to a blue ramp. */
|
|
16
|
-
minColor?: string;
|
|
17
|
-
maxColor?: string;
|
|
18
|
-
style?: any;
|
|
19
|
-
onCellPress?: (rowIndex: number, columnIndex: number) => void;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/** Parses "#rrggbb" into channels; anything else falls back to grey. */
|
|
23
|
-
function parseHex(hex: string): [number, number, number] {
|
|
24
|
-
const match = /^#?([0-9a-f]{6})$/i.exec(hex);
|
|
25
|
-
if (!match) return [128, 128, 128];
|
|
26
|
-
const int = parseInt(match[1]!, 16);
|
|
27
|
-
return [(int >> 16) & 255, (int >> 8) & 255, int & 255];
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/** Linear blend between two hex colours, so a ramp needs no colour library. */
|
|
31
|
-
function mix(from: string, to: string, t: number): string {
|
|
32
|
-
const a = parseHex(from);
|
|
33
|
-
const b = parseHex(to);
|
|
34
|
-
const clamped = Math.max(0, Math.min(1, t));
|
|
35
|
-
const channels = a.map((channel, i) => Math.round(channel + (b[i]! - channel) * clamped));
|
|
36
|
-
return `rgb(${channels[0]}, ${channels[1]}, ${channels[2]})`;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* A grid where colour encodes magnitude.
|
|
41
|
-
*
|
|
42
|
-
* Cells are Views rather than SVG rects: the grid is uniform, so native layout
|
|
43
|
-
* positions it exactly and text stays crisp without vector text.
|
|
44
|
-
*/
|
|
45
|
-
export function NativeHeatmapChart({
|
|
46
|
-
rows,
|
|
47
|
-
columns,
|
|
48
|
-
cellSize = 28,
|
|
49
|
-
cellGap = 3,
|
|
50
|
-
isDark: isDarkProp,
|
|
51
|
-
minColor = "#e8eef7",
|
|
52
|
-
maxColor = "#0088ff",
|
|
53
|
-
style,
|
|
54
|
-
onCellPress,
|
|
55
|
-
}: NativeHeatmapChartProps) {
|
|
56
|
-
const [active, setActive] = useState<{ r: number; c: number } | null>(null);
|
|
57
|
-
const isDark = useIsDark(isDarkProp);
|
|
58
|
-
const theme = isDark ? colors.dark : colors.light;
|
|
59
|
-
const { View, Text, Pressable } = primitives();
|
|
60
|
-
|
|
61
|
-
if (rows.length === 0 || columns.length === 0) {
|
|
62
|
-
return (
|
|
63
|
-
<View style={[{ alignItems: "center", paddingVertical: 20 }, style]}>
|
|
64
|
-
<Text style={{ color: theme.muted, fontSize: 12 }}>No cells to display</Text>
|
|
65
|
-
</View>
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const all = rows.flatMap((row) => row.values).filter(Number.isFinite);
|
|
70
|
-
const min = all.length ? Math.min(...all) : 0;
|
|
71
|
-
const max = all.length ? Math.max(...all) : 1;
|
|
72
|
-
const span = max - min;
|
|
73
|
-
|
|
74
|
-
// A flat grid would otherwise tint every cell the same; centre it instead.
|
|
75
|
-
const position = (value: number) => (span === 0 ? 0.5 : (value - min) / span);
|
|
76
|
-
const labelWidth = 54;
|
|
77
|
-
|
|
78
|
-
return (
|
|
79
|
-
<View style={style}>
|
|
80
|
-
<View style={{ flexDirection: "row", marginLeft: labelWidth }}>
|
|
81
|
-
{columns.map((column) => (
|
|
82
|
-
<View key={column} style={{ width: cellSize + cellGap, alignItems: "center" }}>
|
|
83
|
-
<Text style={{ color: theme.muted, fontSize: 9 }} numberOfLines={1}>
|
|
84
|
-
{column}
|
|
85
|
-
</Text>
|
|
86
|
-
</View>
|
|
87
|
-
))}
|
|
88
|
-
</View>
|
|
89
|
-
|
|
90
|
-
{rows.map((row, r) => (
|
|
91
|
-
<View key={row.label} style={{ flexDirection: "row", alignItems: "center", marginTop: cellGap }}>
|
|
92
|
-
<View style={{ width: labelWidth }}>
|
|
93
|
-
<Text style={{ color: theme.foreground, fontSize: 10 }} numberOfLines={1}>
|
|
94
|
-
{row.label}
|
|
95
|
-
</Text>
|
|
96
|
-
</View>
|
|
97
|
-
|
|
98
|
-
{columns.map((column, c) => {
|
|
99
|
-
const value = row.values[c];
|
|
100
|
-
const isActive = active?.r === r && active?.c === c;
|
|
101
|
-
const tint = value == null ? "transparent" : mix(minColor, maxColor, position(value));
|
|
102
|
-
|
|
103
|
-
return (
|
|
104
|
-
<Pressable
|
|
105
|
-
key={column}
|
|
106
|
-
accessibilityRole="button"
|
|
107
|
-
accessibilityLabel={`${row.label} ${column}: ${
|
|
108
|
-
value == null ? "no data" : formatValue(value)
|
|
109
|
-
}`}
|
|
110
|
-
onPress={() => {
|
|
111
|
-
if (value == null) return;
|
|
112
|
-
setActive((current) => (current?.r === r && current?.c === c ? null : { r, c }));
|
|
113
|
-
onCellPress?.(r, c);
|
|
114
|
-
}}
|
|
115
|
-
style={{
|
|
116
|
-
width: cellSize,
|
|
117
|
-
height: cellSize,
|
|
118
|
-
marginRight: cellGap,
|
|
119
|
-
borderRadius: 6,
|
|
120
|
-
backgroundColor: tint,
|
|
121
|
-
borderWidth: isActive ? 2 : 0,
|
|
122
|
-
borderColor: theme.foreground,
|
|
123
|
-
}}
|
|
124
|
-
/>
|
|
125
|
-
);
|
|
126
|
-
})}
|
|
127
|
-
</View>
|
|
128
|
-
))}
|
|
129
|
-
|
|
130
|
-
<View style={{ flexDirection: "row", alignItems: "center", marginTop: 10, marginLeft: labelWidth }}>
|
|
131
|
-
<Text style={{ color: theme.muted, fontSize: 9, marginRight: 5 }}>
|
|
132
|
-
{formatValue(min, { compact: true })}
|
|
133
|
-
</Text>
|
|
134
|
-
<View
|
|
135
|
-
style={{
|
|
136
|
-
width: 70,
|
|
137
|
-
height: 6,
|
|
138
|
-
borderRadius: 3,
|
|
139
|
-
backgroundColor: mix(minColor, maxColor, 0.5),
|
|
140
|
-
}}
|
|
141
|
-
/>
|
|
142
|
-
<Text style={{ color: theme.muted, fontSize: 9, marginLeft: 5 }}>
|
|
143
|
-
{formatValue(max, { compact: true })}
|
|
144
|
-
</Text>
|
|
145
|
-
</View>
|
|
146
|
-
|
|
147
|
-
{active !== null && rows[active.r]?.values[active.c] != null && (
|
|
148
|
-
<Text style={{ color: theme.foreground, fontSize: 11, marginTop: 8, marginLeft: labelWidth }}>
|
|
149
|
-
{rows[active.r]!.label} · {columns[active.c]}:{" "}
|
|
150
|
-
{formatValue(rows[active.r]!.values[active.c]!)}
|
|
151
|
-
</Text>
|
|
152
|
-
)}
|
|
153
|
-
</View>
|
|
154
|
-
);
|
|
155
|
-
}
|