glacia-native 0.5.2 → 0.6.1
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/README.md +84 -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 -268
- package/lib/module/Button.js +57 -39
- package/lib/module/Card.js +31 -19
- 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 -123
- package/lib/module/DropdownMenu.js +33 -0
- package/lib/module/Field.js +22 -0
- package/lib/module/Glass.js +10 -3
- package/lib/module/Group.js +36 -0
- package/lib/module/IconButton.js +40 -0
- package/lib/module/Input.js +43 -38
- 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 +70 -63
- 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 +45 -34
- package/lib/module/Stepper.js +167 -0
- package/lib/module/Switch.js +45 -55
- package/lib/module/TabBar.js +50 -44
- 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 +43 -11
- 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 +6 -9
- package/lib/module/internal/glass-routing.js +156 -30
- package/lib/module/internal/initials.js +12 -0
- package/lib/module/internal/overlay.js +147 -0
- package/lib/module/internal/primitives.js +16 -0
- 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 +38 -17
- package/lib/typescript/internal/GlassBackdrop.d.ts +33 -0
- package/lib/typescript/internal/GlassView.d.ts +18 -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/glass-routing.d.ts +83 -15
- package/lib/typescript/internal/initials.d.ts +2 -0
- package/lib/typescript/internal/overlay.d.ts +74 -0
- package/lib/typescript/internal/primitives.d.ts +11 -0
- package/package.json +12 -10
- 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 -807
- package/src/Button.tsx +196 -67
- package/src/Card.tsx +105 -32
- 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 +85 -335
- package/src/DropdownMenu.tsx +103 -0
- package/src/Field.tsx +65 -0
- package/src/Glass.tsx +15 -5
- package/src/Group.tsx +98 -0
- package/src/IconButton.tsx +110 -0
- package/src/Input.tsx +139 -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 +132 -99
- 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 +84 -47
- package/src/Stepper.tsx +315 -0
- package/src/Switch.tsx +81 -73
- package/src/TabBar.tsx +106 -93
- 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 +47 -190
- package/src/internal/GlassBackdrop.tsx +60 -0
- package/src/internal/GlassView.tsx +53 -18
- package/src/internal/blur-community.ts +19 -0
- package/src/internal/blur-community.web.ts +7 -0
- package/src/internal/blur.ts +7 -8
- package/src/internal/glass-routing.ts +212 -34
- package/src/internal/initials.ts +7 -0
- package/src/internal/overlay.tsx +258 -0
- package/src/internal/primitives.ts +23 -0
- package/lib/module/Carousel.js +0 -103
- package/lib/module/Display.js +0 -318
- package/lib/module/Feedback.js +0 -395
- package/lib/module/Form.js +0 -160
- package/lib/module/Forms2.js +0 -471
- package/lib/module/Message.js +0 -84
- package/lib/module/Overlays.js +0 -344
- package/lib/module/Pickers.js +0 -243
- package/lib/module/Table.js +0 -100
- package/lib/module/ai.js +0 -283
- package/lib/module/charts/AreaChart.js +0 -32
- package/lib/module/charts/BarChart.js +0 -75
- 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 -67
- 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 -781
- package/src/Feedback.tsx +0 -992
- package/src/Form.tsx +0 -445
- package/src/Forms2.tsx +0 -1055
- package/src/Message.tsx +0 -218
- package/src/Overlays.tsx +0 -704
- package/src/Pickers.tsx +0 -595
- package/src/Table.tsx +0 -232
- package/src/ai.tsx +0 -715
- package/src/charts/AreaChart.tsx +0 -73
- package/src/charts/BarChart.tsx +0 -221
- 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/RingChart.tsx
DELETED
|
@@ -1,133 +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 { arcPath, formatValue, seriesColor } from "./scales";
|
|
7
|
-
|
|
8
|
-
export interface NativeRingSlice {
|
|
9
|
-
label: string;
|
|
10
|
-
value: number;
|
|
11
|
-
color?: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface NativeRingChartProps {
|
|
15
|
-
data: NativeRingSlice[];
|
|
16
|
-
size?: number;
|
|
17
|
-
/**
|
|
18
|
-
* Ring thickness. Larger leaves a bigger hole.
|
|
19
|
-
* A pie is the same shape with no hole: pass `size` to fill it.
|
|
20
|
-
*/
|
|
21
|
-
thickness?: number;
|
|
22
|
-
isDark?: boolean;
|
|
23
|
-
palette?: readonly string[];
|
|
24
|
-
/** Show the slice list beneath the ring. */
|
|
25
|
-
showLegend?: boolean;
|
|
26
|
-
style?: any;
|
|
27
|
-
onSlicePress?: (index: number) => void;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const TAU = Math.PI * 2;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Proportional slices as a ring, drawn with react-native-svg.
|
|
34
|
-
*
|
|
35
|
-
* Shares the arc maths with the web RingChart, so slices land in the same
|
|
36
|
-
* places on both platforms. A legend is on by default: on a phone there is no
|
|
37
|
-
* hover, so colour alone cannot identify a slice.
|
|
38
|
-
*/
|
|
39
|
-
export function NativeRingChart({
|
|
40
|
-
data,
|
|
41
|
-
size = 180,
|
|
42
|
-
thickness = 22,
|
|
43
|
-
isDark: isDarkProp,
|
|
44
|
-
palette,
|
|
45
|
-
showLegend = true,
|
|
46
|
-
style,
|
|
47
|
-
onSlicePress,
|
|
48
|
-
}: NativeRingChartProps) {
|
|
49
|
-
const [active, setActive] = useState<number | null>(null);
|
|
50
|
-
const isDark = useIsDark(isDarkProp);
|
|
51
|
-
const theme = isDark ? colors.dark : colors.light;
|
|
52
|
-
const { View, Text, Pressable, Svg, Path } = primitives();
|
|
53
|
-
|
|
54
|
-
const total = data.reduce((sum, slice) => sum + Math.max(0, slice.value), 0);
|
|
55
|
-
|
|
56
|
-
if (data.length === 0 || total <= 0) {
|
|
57
|
-
return (
|
|
58
|
-
<View style={[{ width: size, alignItems: "center" }, style]}>
|
|
59
|
-
<Text style={{ color: theme.muted, fontSize: 12 }}>No slices to display</Text>
|
|
60
|
-
</View>
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const outer = size / 2;
|
|
65
|
-
const inner = Math.max(0, outer - thickness);
|
|
66
|
-
let cursor = -Math.PI / 2;
|
|
67
|
-
|
|
68
|
-
return (
|
|
69
|
-
<View style={[{ alignItems: "center" }, style]}>
|
|
70
|
-
<Svg width={size} height={size}>
|
|
71
|
-
{data.map((slice, i) => {
|
|
72
|
-
const share = Math.max(0, slice.value) / total;
|
|
73
|
-
const start = cursor;
|
|
74
|
-
const end = cursor + share * TAU;
|
|
75
|
-
cursor = end;
|
|
76
|
-
|
|
77
|
-
return (
|
|
78
|
-
<Path
|
|
79
|
-
key={slice.label}
|
|
80
|
-
d={arcPath(outer, outer, outer, inner, start, end)}
|
|
81
|
-
fill={slice.color ?? seriesColor(i, palette)}
|
|
82
|
-
opacity={active === null || active === i ? 1 : 0.4}
|
|
83
|
-
onPress={() => {
|
|
84
|
-
setActive((current) => (current === i ? null : i));
|
|
85
|
-
onSlicePress?.(i);
|
|
86
|
-
}}
|
|
87
|
-
/>
|
|
88
|
-
);
|
|
89
|
-
})}
|
|
90
|
-
</Svg>
|
|
91
|
-
|
|
92
|
-
{showLegend && (
|
|
93
|
-
<View style={{ marginTop: 12, width: "100%", maxWidth: 260, gap: 6 }}>
|
|
94
|
-
{data.map((slice, i) => (
|
|
95
|
-
<Pressable
|
|
96
|
-
key={slice.label}
|
|
97
|
-
accessibilityRole="button"
|
|
98
|
-
accessibilityLabel={`${slice.label}: ${formatValue(slice.value)}, ${Math.round(
|
|
99
|
-
(slice.value / total) * 100,
|
|
100
|
-
)} percent`}
|
|
101
|
-
onPress={() => {
|
|
102
|
-
setActive((current) => (current === i ? null : i));
|
|
103
|
-
onSlicePress?.(i);
|
|
104
|
-
}}
|
|
105
|
-
style={{ flexDirection: "row", alignItems: "center", gap: 8 }}
|
|
106
|
-
>
|
|
107
|
-
<View
|
|
108
|
-
style={{
|
|
109
|
-
width: 9,
|
|
110
|
-
height: 9,
|
|
111
|
-
borderRadius: 3,
|
|
112
|
-
backgroundColor: slice.color ?? seriesColor(i, palette),
|
|
113
|
-
}}
|
|
114
|
-
/>
|
|
115
|
-
<Text style={{ color: theme.muted, fontSize: 12, flex: 1 }} numberOfLines={1}>
|
|
116
|
-
{slice.label}
|
|
117
|
-
</Text>
|
|
118
|
-
<Text
|
|
119
|
-
style={{
|
|
120
|
-
color: theme.foreground,
|
|
121
|
-
fontSize: 12,
|
|
122
|
-
fontWeight: active === i ? "700" : "600",
|
|
123
|
-
}}
|
|
124
|
-
>
|
|
125
|
-
{formatValue(slice.value)}
|
|
126
|
-
</Text>
|
|
127
|
-
</Pressable>
|
|
128
|
-
))}
|
|
129
|
-
</View>
|
|
130
|
-
)}
|
|
131
|
-
</View>
|
|
132
|
-
);
|
|
133
|
-
}
|
|
@@ -1,223 +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 NativeScatterPoint {
|
|
9
|
-
x: number;
|
|
10
|
-
y: number;
|
|
11
|
-
label?: string;
|
|
12
|
-
/** Bubble radius driver; ignored when `bubble` is not set. */
|
|
13
|
-
size?: number;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface NativeScatterSeries {
|
|
17
|
-
name: string;
|
|
18
|
-
points: NativeScatterPoint[];
|
|
19
|
-
color?: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface NativeScatterChartProps {
|
|
23
|
-
series: NativeScatterSeries[];
|
|
24
|
-
width?: number;
|
|
25
|
-
height?: number;
|
|
26
|
-
/** Fixed dot radius. */
|
|
27
|
-
radius?: number;
|
|
28
|
-
/** Size each mark by its `size` value instead of a fixed radius. */
|
|
29
|
-
bubble?: boolean;
|
|
30
|
-
isDark?: boolean;
|
|
31
|
-
palette?: readonly string[];
|
|
32
|
-
style?: any;
|
|
33
|
-
onPointPress?: (seriesIndex: number, pointIndex: number) => void;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const PADDING = { top: 12, right: 12, bottom: 24, left: 40 };
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Two numeric axes, drawn with react-native-svg.
|
|
40
|
-
*
|
|
41
|
-
* BubbleChart is this component with `bubble` set, so the two share their
|
|
42
|
-
* axes, padding and touch behaviour instead of drifting apart.
|
|
43
|
-
*/
|
|
44
|
-
export function NativeScatterChart({
|
|
45
|
-
series,
|
|
46
|
-
width = 320,
|
|
47
|
-
height = 200,
|
|
48
|
-
radius = 4,
|
|
49
|
-
bubble = false,
|
|
50
|
-
isDark: isDarkProp,
|
|
51
|
-
palette,
|
|
52
|
-
style,
|
|
53
|
-
onPointPress,
|
|
54
|
-
}: NativeScatterChartProps) {
|
|
55
|
-
const [active, setActive] = useState<{ s: number; p: number } | null>(null);
|
|
56
|
-
const isDark = useIsDark(isDarkProp);
|
|
57
|
-
const theme = isDark ? colors.dark : colors.light;
|
|
58
|
-
const { View, Text, Svg, G, Line, Circle, SvgText } = primitives();
|
|
59
|
-
|
|
60
|
-
const plot = {
|
|
61
|
-
x: PADDING.left,
|
|
62
|
-
y: PADDING.top,
|
|
63
|
-
width: Math.max(0, width - PADDING.left - PADDING.right),
|
|
64
|
-
height: Math.max(0, height - PADDING.top - PADDING.bottom),
|
|
65
|
-
};
|
|
66
|
-
const right = plot.x + plot.width;
|
|
67
|
-
const bottom = plot.y + plot.height;
|
|
68
|
-
|
|
69
|
-
const all = series.flatMap((s) => s.points);
|
|
70
|
-
|
|
71
|
-
const xDomain = useMemo(() => {
|
|
72
|
-
const xs = all.map((p) => p.x).filter(Number.isFinite);
|
|
73
|
-
return niceDomain(xs.length ? Math.min(...xs) : 0, xs.length ? Math.max(...xs) : 1, 4);
|
|
74
|
-
}, [all.map((p) => p.x).join(",")]);
|
|
75
|
-
|
|
76
|
-
const yDomain = useMemo(() => {
|
|
77
|
-
const ys = all.map((p) => p.y).filter(Number.isFinite);
|
|
78
|
-
return niceDomain(ys.length ? Math.min(...ys) : 0, ys.length ? Math.max(...ys) : 1, 4);
|
|
79
|
-
}, [all.map((p) => p.y).join(",")]);
|
|
80
|
-
|
|
81
|
-
const x = linearScale(xDomain, [plot.x, right], { nice: false });
|
|
82
|
-
const y = linearScale(yDomain, [bottom, plot.y], { nice: false });
|
|
83
|
-
|
|
84
|
-
const sizes = all.map((p) => p.size ?? 1);
|
|
85
|
-
const maxSize = sizes.length ? Math.max(...sizes) : 1;
|
|
86
|
-
const minSize = sizes.length ? Math.min(...sizes) : 0;
|
|
87
|
-
const maxRadius = Math.min(plot.width, plot.height) / 7;
|
|
88
|
-
|
|
89
|
-
const radiusFor = (point: NativeScatterPoint) => {
|
|
90
|
-
if (!bubble) return radius;
|
|
91
|
-
const size = point.size ?? minSize;
|
|
92
|
-
const t = maxSize === minSize ? 1 : (size - minSize) / (maxSize - minSize);
|
|
93
|
-
return 3 + t * (maxRadius - 3);
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
if (all.length === 0) {
|
|
97
|
-
return (
|
|
98
|
-
<View style={[{ width, height, alignItems: "center", justifyContent: "center" }, style]}>
|
|
99
|
-
<Text style={{ color: theme.muted, fontSize: 12 }}>No points to display</Text>
|
|
100
|
-
</View>
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const yTicks = ticks(yDomain, 4);
|
|
105
|
-
const xTicks = ticks(xDomain, 4);
|
|
106
|
-
|
|
107
|
-
return (
|
|
108
|
-
<View
|
|
109
|
-
style={style}
|
|
110
|
-
// One summary for the whole chart: the per-point touch targets below are
|
|
111
|
-
// the detailed access, this is what is announced on focus.
|
|
112
|
-
accessible
|
|
113
|
-
accessibilityRole="image"
|
|
114
|
-
accessibilityLabel={scatterSummary(series)}
|
|
115
|
-
>
|
|
116
|
-
<Svg width={width} height={height}>
|
|
117
|
-
{yTicks.map((tick, i) => (
|
|
118
|
-
<Line
|
|
119
|
-
key={`grid-${i}`}
|
|
120
|
-
x1={plot.x}
|
|
121
|
-
x2={right}
|
|
122
|
-
y1={y(tick)}
|
|
123
|
-
y2={y(tick)}
|
|
124
|
-
stroke={theme.axis}
|
|
125
|
-
strokeOpacity={0.24}
|
|
126
|
-
strokeWidth={1}
|
|
127
|
-
/>
|
|
128
|
-
))}
|
|
129
|
-
|
|
130
|
-
{series.map((s, si) => {
|
|
131
|
-
const color = s.color ?? seriesColor(si, palette);
|
|
132
|
-
return (
|
|
133
|
-
<G key={s.name}>
|
|
134
|
-
{s.points.map((point, pi) => {
|
|
135
|
-
const isActive = active?.s === si && active?.p === pi;
|
|
136
|
-
return (
|
|
137
|
-
<Circle
|
|
138
|
-
key={pi}
|
|
139
|
-
cx={x(point.x)}
|
|
140
|
-
cy={y(point.y)}
|
|
141
|
-
r={radiusFor(point) + (isActive ? 2 : 0)}
|
|
142
|
-
fill={color}
|
|
143
|
-
fillOpacity={isActive ? 0.95 : bubble ? 0.55 : 0.8}
|
|
144
|
-
onPress={() => {
|
|
145
|
-
setActive(isActive ? null : { s: si, p: pi });
|
|
146
|
-
onPointPress?.(si, pi);
|
|
147
|
-
}}
|
|
148
|
-
/>
|
|
149
|
-
);
|
|
150
|
-
})}
|
|
151
|
-
</G>
|
|
152
|
-
);
|
|
153
|
-
})}
|
|
154
|
-
|
|
155
|
-
{yTicks.map((tick, i) => (
|
|
156
|
-
<SvgText
|
|
157
|
-
key={`y-${i}`}
|
|
158
|
-
x={plot.x - 6}
|
|
159
|
-
y={y(tick) + 3}
|
|
160
|
-
fill={theme.muted}
|
|
161
|
-
fontSize={9}
|
|
162
|
-
textAnchor="end"
|
|
163
|
-
>
|
|
164
|
-
{formatValue(tick, { compact: true })}
|
|
165
|
-
</SvgText>
|
|
166
|
-
))}
|
|
167
|
-
|
|
168
|
-
{xTicks.map((tick, i) => (
|
|
169
|
-
<SvgText
|
|
170
|
-
key={`x-${i}`}
|
|
171
|
-
x={x(tick)}
|
|
172
|
-
y={height - 8}
|
|
173
|
-
fill={theme.muted}
|
|
174
|
-
fontSize={9}
|
|
175
|
-
textAnchor="middle"
|
|
176
|
-
>
|
|
177
|
-
{formatValue(tick, { compact: true })}
|
|
178
|
-
</SvgText>
|
|
179
|
-
))}
|
|
180
|
-
</Svg>
|
|
181
|
-
|
|
182
|
-
{active !== null && series[active.s]?.points[active.p] && (
|
|
183
|
-
<View
|
|
184
|
-
style={{
|
|
185
|
-
position: "absolute",
|
|
186
|
-
top: 0,
|
|
187
|
-
left: PADDING.left,
|
|
188
|
-
paddingVertical: 3,
|
|
189
|
-
paddingHorizontal: 7,
|
|
190
|
-
borderRadius: 8,
|
|
191
|
-
backgroundColor: theme.glass,
|
|
192
|
-
}}
|
|
193
|
-
pointerEvents="none"
|
|
194
|
-
>
|
|
195
|
-
<Text style={{ color: theme.foreground, fontSize: 10, fontWeight: "600" }}>
|
|
196
|
-
{series[active.s]!.points[active.p]!.label ?? series[active.s]!.name}
|
|
197
|
-
</Text>
|
|
198
|
-
<Text style={{ color: theme.muted, fontSize: 10 }}>
|
|
199
|
-
x {formatValue(series[active.s]!.points[active.p]!.x)} · y{" "}
|
|
200
|
-
{formatValue(series[active.s]!.points[active.p]!.y)}
|
|
201
|
-
</Text>
|
|
202
|
-
</View>
|
|
203
|
-
)}
|
|
204
|
-
</View>
|
|
205
|
-
);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/** Reads the chart as one sentence for a screen reader. */
|
|
209
|
-
function scatterSummary(series: NativeScatterSeries[]): string {
|
|
210
|
-
const sentences = series.map((entry) => {
|
|
211
|
-
const ys = entry.points.map((point) => point.y).filter(Number.isFinite);
|
|
212
|
-
if (ys.length === 0) return `${entry.name}: no points`;
|
|
213
|
-
const min = formatValue(Math.min(...ys));
|
|
214
|
-
const max = formatValue(Math.max(...ys));
|
|
215
|
-
return `${entry.name}: ${entry.points.length} points, y from ${min} to ${max}`;
|
|
216
|
-
});
|
|
217
|
-
return `Scatter chart. ${sentences.join(". ")}`;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/** Scatter marks sized by a third value. */
|
|
221
|
-
export function NativeBubbleChart(props: Omit<NativeScatterChartProps, "bubble" | "radius">) {
|
|
222
|
-
return <NativeScatterChart {...props} bubble />;
|
|
223
|
-
}
|
|
@@ -1,201 +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 NativeWaterfallStep {
|
|
9
|
-
label: string;
|
|
10
|
-
/** Signed change. A step with `isTotal` set is drawn as an absolute bar. */
|
|
11
|
-
value: number;
|
|
12
|
-
isTotal?: boolean;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface NativeWaterfallChartProps {
|
|
16
|
-
steps: NativeWaterfallStep[];
|
|
17
|
-
width?: number;
|
|
18
|
-
height?: number;
|
|
19
|
-
isDark?: boolean;
|
|
20
|
-
style?: any;
|
|
21
|
-
onStepPress?: (index: number) => void;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const PADDING = { top: 12, right: 8, bottom: 26, left: 42 };
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* How a running total moves step by step.
|
|
28
|
-
*
|
|
29
|
-
* Each bar starts where the previous one ended, so the reader sees the bridge
|
|
30
|
-
* from opening to closing balance rather than a set of unrelated changes.
|
|
31
|
-
* Increases and decreases are coloured differently, and totals span the axis.
|
|
32
|
-
*/
|
|
33
|
-
export function NativeWaterfallChart({
|
|
34
|
-
steps,
|
|
35
|
-
width = 320,
|
|
36
|
-
height = 200,
|
|
37
|
-
isDark: isDarkProp,
|
|
38
|
-
style,
|
|
39
|
-
onStepPress,
|
|
40
|
-
}: NativeWaterfallChartProps) {
|
|
41
|
-
const [active, setActive] = useState<number | null>(null);
|
|
42
|
-
const isDark = useIsDark(isDarkProp);
|
|
43
|
-
const theme = isDark ? colors.dark : colors.light;
|
|
44
|
-
const { View, Text, Pressable, Svg, G, Line, Rect, SvgText } = primitives();
|
|
45
|
-
|
|
46
|
-
if (steps.length === 0) {
|
|
47
|
-
return (
|
|
48
|
-
<View style={[{ width, alignItems: "center", paddingVertical: 20 }, style]}>
|
|
49
|
-
<Text style={{ color: theme.muted, fontSize: 12 }}>No steps to display</Text>
|
|
50
|
-
</View>
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const up = "#34c759";
|
|
55
|
-
const down = "#ff375f";
|
|
56
|
-
|
|
57
|
-
const plot = {
|
|
58
|
-
x: PADDING.left,
|
|
59
|
-
y: PADDING.top,
|
|
60
|
-
width: Math.max(0, width - PADDING.left - PADDING.right),
|
|
61
|
-
height: Math.max(0, height - PADDING.top - PADDING.bottom),
|
|
62
|
-
};
|
|
63
|
-
const right = plot.x + plot.width;
|
|
64
|
-
const bottom = plot.y + plot.height;
|
|
65
|
-
|
|
66
|
-
// Bounds come from the running totals, not the raw deltas: a −50 midway
|
|
67
|
-
// through a climb needs the axis to reach below zero only if the running
|
|
68
|
-
// total actually does.
|
|
69
|
-
let running = 0;
|
|
70
|
-
const geometry = steps.map((step) => {
|
|
71
|
-
const start = step.isTotal ? 0 : running;
|
|
72
|
-
const end = step.isTotal ? step.value : running + step.value;
|
|
73
|
-
if (!step.isTotal) running = end;
|
|
74
|
-
return {
|
|
75
|
-
start,
|
|
76
|
-
end,
|
|
77
|
-
low: Math.min(start, end),
|
|
78
|
-
high: Math.max(start, end),
|
|
79
|
-
};
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
const lows = geometry.map((g) => g.low);
|
|
83
|
-
const highs = geometry.map((g) => g.high);
|
|
84
|
-
const min = Math.min(0, ...lows);
|
|
85
|
-
const max = Math.max(0, ...highs);
|
|
86
|
-
const span = max - min || 1;
|
|
87
|
-
|
|
88
|
-
const y = (value: number) => bottom - ((value - min) / span) * plot.height;
|
|
89
|
-
const stepWidth = plot.width / steps.length;
|
|
90
|
-
const barWidth = Math.min(34, stepWidth * 0.6);
|
|
91
|
-
|
|
92
|
-
const zeroY = y(0);
|
|
93
|
-
|
|
94
|
-
return (
|
|
95
|
-
<View
|
|
96
|
-
style={style}
|
|
97
|
-
accessible
|
|
98
|
-
accessibilityRole="image"
|
|
99
|
-
accessibilityLabel={waterfallSummary(steps, geometry)}
|
|
100
|
-
>
|
|
101
|
-
<Svg width={width} height={height}>
|
|
102
|
-
<Line
|
|
103
|
-
x1={plot.x}
|
|
104
|
-
x2={right}
|
|
105
|
-
y1={zeroY}
|
|
106
|
-
y2={zeroY}
|
|
107
|
-
stroke={theme.axis}
|
|
108
|
-
strokeOpacity={0.4}
|
|
109
|
-
strokeWidth={1}
|
|
110
|
-
/>
|
|
111
|
-
|
|
112
|
-
{geometry.map((g, i) => {
|
|
113
|
-
const step = steps[i]!;
|
|
114
|
-
const top = y(g.high);
|
|
115
|
-
const barHeight = Math.max(1, y(g.low) - top);
|
|
116
|
-
const color = step.isTotal ? seriesTotalColor(isDark) : step.value >= 0 ? up : down;
|
|
117
|
-
const x = plot.x + stepWidth * i + (stepWidth - barWidth) / 2;
|
|
118
|
-
|
|
119
|
-
return (
|
|
120
|
-
<G key={step.label}>
|
|
121
|
-
<Rect
|
|
122
|
-
x={x}
|
|
123
|
-
y={top}
|
|
124
|
-
width={barWidth}
|
|
125
|
-
height={barHeight}
|
|
126
|
-
rx={3}
|
|
127
|
-
fill={color}
|
|
128
|
-
fillOpacity={active === null || active === i ? 1 : 0.45}
|
|
129
|
-
onPress={() => {
|
|
130
|
-
setActive((current) => (current === i ? null : i));
|
|
131
|
-
onStepPress?.(i);
|
|
132
|
-
}}
|
|
133
|
-
/>
|
|
134
|
-
{/* Connector to the next bar's baseline, so the accumulation reads. */}
|
|
135
|
-
{i < steps.length - 1 && !steps[i + 1]!.isTotal && (
|
|
136
|
-
<Line
|
|
137
|
-
x1={x + barWidth}
|
|
138
|
-
x2={plot.x + stepWidth * (i + 1) + (stepWidth - barWidth) / 2}
|
|
139
|
-
y1={y(g.end)}
|
|
140
|
-
y2={y(g.end)}
|
|
141
|
-
stroke={theme.axis}
|
|
142
|
-
strokeOpacity={0.4}
|
|
143
|
-
strokeWidth={1}
|
|
144
|
-
strokeDasharray="2,2"
|
|
145
|
-
/>
|
|
146
|
-
)}
|
|
147
|
-
<SvgText
|
|
148
|
-
x={x + barWidth / 2}
|
|
149
|
-
y={height - 8}
|
|
150
|
-
fill={theme.muted}
|
|
151
|
-
fontSize={8}
|
|
152
|
-
textAnchor="middle"
|
|
153
|
-
>
|
|
154
|
-
{step.label}
|
|
155
|
-
</SvgText>
|
|
156
|
-
</G>
|
|
157
|
-
);
|
|
158
|
-
})}
|
|
159
|
-
|
|
160
|
-
{[max, min].map((value, i) => (
|
|
161
|
-
<SvgText
|
|
162
|
-
key={`y-${i}`}
|
|
163
|
-
x={plot.x - 6}
|
|
164
|
-
y={y(value) + 3}
|
|
165
|
-
fill={theme.muted}
|
|
166
|
-
fontSize={9}
|
|
167
|
-
textAnchor="end"
|
|
168
|
-
>
|
|
169
|
-
{formatValue(value, { compact: true })}
|
|
170
|
-
</SvgText>
|
|
171
|
-
))}
|
|
172
|
-
</Svg>
|
|
173
|
-
|
|
174
|
-
{active !== null && (
|
|
175
|
-
<Text style={{ color: theme.foreground, fontSize: 11, marginTop: 6 }}>
|
|
176
|
-
{steps[active]!.label}: {steps[active]!.value >= 0 ? "+" : ""}
|
|
177
|
-
{formatValue(steps[active]!.value)}
|
|
178
|
-
{steps[active]!.isTotal
|
|
179
|
-
? " (total)"
|
|
180
|
-
: ` → ${formatValue(geometry[active]!.end)} running`}
|
|
181
|
-
</Text>
|
|
182
|
-
)}
|
|
183
|
-
</View>
|
|
184
|
-
);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/** Reads the chart as one sentence for a screen reader. */
|
|
188
|
-
function waterfallSummary(
|
|
189
|
-
steps: NativeWaterfallStep[],
|
|
190
|
-
geometry: { end: number }[],
|
|
191
|
-
): string {
|
|
192
|
-
const last = geometry[geometry.length - 1];
|
|
193
|
-
const changes = steps.filter((step) => !step.isTotal).length;
|
|
194
|
-
const closing = last ? ` Closing value ${formatValue(last.end)}.` : "";
|
|
195
|
-
return `Waterfall chart. ${steps.length} steps, ${changes} of them changes.${closing}`;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/** Totals are neutral so they do not read as a gain or loss. */
|
|
199
|
-
function seriesTotalColor(isDark: boolean) {
|
|
200
|
-
return isDark ? "#8e8e93" : "#3c3c43";
|
|
201
|
-
}
|