glacia-native 0.5.2 → 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/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 +154 -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 +4 -2
- 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 +211 -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
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NativeLineChart = NativeLineChart;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
const tokens_1 = require("../internal/tokens");
|
|
7
|
-
const motion_1 = require("../internal/motion");
|
|
8
|
-
const primitives_1 = require("../internal/primitives");
|
|
9
|
-
const scales_1 = require("./scales");
|
|
10
|
-
const PADDING = { top: 12, right: 10, bottom: 24, left: 38 };
|
|
11
|
-
/**
|
|
12
|
-
* A line chart drawn with react-native-svg.
|
|
13
|
-
*
|
|
14
|
-
* Uses the same scale maths as the web LineChart, so the same series produces
|
|
15
|
-
* the same axis values on both platforms. Touching a column selects that
|
|
16
|
-
* point, which is the touch equivalent of hovering on the web.
|
|
17
|
-
*/
|
|
18
|
-
function NativeLineChart({ labels, series, width = 320, height = 200, area = false, smooth = true, showDots = false, isDark: isDarkProp, palette, style, onPointPress, }) {
|
|
19
|
-
const [active, setActive] = (0, react_1.useState)(null);
|
|
20
|
-
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
21
|
-
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
22
|
-
const { View, Text, Pressable, Svg, G, Line, Path, Circle, SvgText } = (0, primitives_1.primitives)();
|
|
23
|
-
const plot = {
|
|
24
|
-
x: PADDING.left,
|
|
25
|
-
y: PADDING.top,
|
|
26
|
-
width: Math.max(0, width - PADDING.left - PADDING.right),
|
|
27
|
-
height: Math.max(0, height - PADDING.top - PADDING.bottom),
|
|
28
|
-
};
|
|
29
|
-
const bottom = plot.y + plot.height;
|
|
30
|
-
const right = plot.x + plot.width;
|
|
31
|
-
const all = series.flatMap((s) => s.values).filter(Number.isFinite);
|
|
32
|
-
const domain = (0, react_1.useMemo)(() => {
|
|
33
|
-
if (all.length === 0)
|
|
34
|
-
return [0, 1];
|
|
35
|
-
const min = Math.min(...all);
|
|
36
|
-
const max = Math.max(...all);
|
|
37
|
-
return (0, scales_1.niceDomain)(area ? Math.min(0, min) : min, max, 4);
|
|
38
|
-
}, [all.join(","), area]);
|
|
39
|
-
const y = (0, scales_1.linearScale)(domain, [bottom, plot.y], { nice: false });
|
|
40
|
-
const x = (0, scales_1.bandScale)(labels.length, [plot.x, right], 0);
|
|
41
|
-
const yTicks = (0, scales_1.ticks)(domain, 4);
|
|
42
|
-
if (labels.length === 0 || series.length === 0) {
|
|
43
|
-
return ((0, jsx_runtime_1.jsx)(View, { style: [{ width, height, alignItems: "center", justifyContent: "center" }, style], children: (0, jsx_runtime_1.jsx)(Text, { style: { color: theme.muted, fontSize: 12 }, children: "No series to display" }) }));
|
|
44
|
-
}
|
|
45
|
-
return ((0, jsx_runtime_1.jsxs)(View, { style: style, children: [(0, jsx_runtime_1.jsxs)(Svg, { width: width, height: height, children: [yTicks.map((tick, i) => ((0, jsx_runtime_1.jsx)(Line, { x1: plot.x, x2: right, y1: y(tick), y2: y(tick), stroke: theme.axis, strokeOpacity: 0.24, strokeWidth: 1 }, `grid-${i}`))), series.map((s, si) => {
|
|
46
|
-
const color = s.color ?? (0, scales_1.seriesColor)(si, palette);
|
|
47
|
-
const points = s.values.map((value, i) => ({
|
|
48
|
-
x: x.center(i),
|
|
49
|
-
y: Number.isFinite(value) ? y(value) : bottom,
|
|
50
|
-
}));
|
|
51
|
-
const line = smooth
|
|
52
|
-
? (0, scales_1.smoothPath)(points)
|
|
53
|
-
: `M ${points.map((p) => `${p.x} ${p.y}`).join(" L ")}`;
|
|
54
|
-
return ((0, jsx_runtime_1.jsxs)(G, { children: [area && ((0, jsx_runtime_1.jsx)(Path, { d: `${line} L ${points[points.length - 1].x} ${bottom} L ${points[0].x} ${bottom} Z`, fill: color, fillOpacity: 0.16 })), (0, jsx_runtime_1.jsx)(Path, { d: line, fill: "none", stroke: color, strokeWidth: 2, strokeLinecap: "round" }), (showDots || active !== null) &&
|
|
55
|
-
points.map((p, i) => ((0, jsx_runtime_1.jsx)(Circle, { cx: p.x, cy: p.y, r: active === i ? 4 : 2.5, fill: color, opacity: active === null || active === i ? 1 : 0.4 }, i)))] }, s.name));
|
|
56
|
-
}), active !== null && ((0, jsx_runtime_1.jsx)(Line, { x1: x.center(active), x2: x.center(active), y1: plot.y, y2: bottom, stroke: theme.foreground, strokeOpacity: 0.24, strokeWidth: 1, strokeDasharray: "3 3" })), yTicks.map((tick, i) => ((0, jsx_runtime_1.jsx)(SvgText, { x: plot.x - 6, y: y(tick) + 3, fill: theme.muted, fontSize: 9, textAnchor: "end", children: (0, scales_1.formatValue)(tick, { compact: true }) }, `y-${i}`))), labels.map((label, i) => ((0, jsx_runtime_1.jsx)(SvgText, { x: x.center(i), y: height - 8, fill: theme.muted, fontSize: 9, textAnchor: "middle", children: label }, `x-${i}`)))] }), (0, jsx_runtime_1.jsx)(View, { style: {
|
|
57
|
-
position: "absolute",
|
|
58
|
-
left: plot.x,
|
|
59
|
-
top: plot.y,
|
|
60
|
-
width: plot.width,
|
|
61
|
-
height: plot.height,
|
|
62
|
-
flexDirection: "row",
|
|
63
|
-
}, children: labels.map((label, i) => ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: `${label}: ${series
|
|
64
|
-
.map((s) => `${s.name} ${(0, scales_1.formatValue)(s.values[i] ?? 0)}`)
|
|
65
|
-
.join(", ")}`, style: { flex: 1 }, onPress: () => {
|
|
66
|
-
setActive((current) => (current === i ? null : i));
|
|
67
|
-
onPointPress?.(i);
|
|
68
|
-
} }, label + i))) }), active !== null && ((0, jsx_runtime_1.jsxs)(View, { style: {
|
|
69
|
-
position: "absolute",
|
|
70
|
-
top: 0,
|
|
71
|
-
left: PADDING.left,
|
|
72
|
-
right: PADDING.right,
|
|
73
|
-
paddingVertical: 4,
|
|
74
|
-
paddingHorizontal: 8,
|
|
75
|
-
borderRadius: tokens_1.radii.sm,
|
|
76
|
-
backgroundColor: theme.glass,
|
|
77
|
-
flexDirection: "row",
|
|
78
|
-
flexWrap: "wrap",
|
|
79
|
-
gap: 8,
|
|
80
|
-
}, pointerEvents: "none", children: [(0, jsx_runtime_1.jsx)(Text, { style: { color: theme.foreground, fontSize: 10, fontWeight: "600" }, children: labels[active] }), series.map((s, si) => ((0, jsx_runtime_1.jsxs)(Text, { style: { color: s.color ?? (0, scales_1.seriesColor)(si, palette), fontSize: 10 }, children: [s.name, " ", (0, scales_1.formatValue)(s.values[active] ?? 0)] }, s.name)))] }))] }));
|
|
81
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NativePlotChart = NativePlotChart;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
const tokens_1 = require("../internal/tokens");
|
|
7
|
-
const motion_1 = require("../internal/motion");
|
|
8
|
-
const primitives_1 = require("../internal/primitives");
|
|
9
|
-
const scales_1 = require("./scales");
|
|
10
|
-
const PADDING = { top: 12, right: 12, bottom: 26, left: 44 };
|
|
11
|
-
/** Reads the chart as one sentence for a screen reader. */
|
|
12
|
-
function plotSummary(points, xDomain, yDomain) {
|
|
13
|
-
return (`Plot chart with ${points.length} points. ` +
|
|
14
|
-
`x from ${(0, scales_1.formatValue)(xDomain[0], { compact: true })} to ${(0, scales_1.formatValue)(xDomain[1], { compact: true })}, ` +
|
|
15
|
-
`y from ${(0, scales_1.formatValue)(yDomain[0], { compact: true })} to ${(0, scales_1.formatValue)(yDomain[1], { compact: true })}.`);
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* A numeric plot you supply the marks for.
|
|
19
|
-
*
|
|
20
|
-
* The axes, ticks and padding are handled here and the caller receives real
|
|
21
|
-
* pixel scales. That keeps stroke widths and text sizes honest regardless of
|
|
22
|
-
* the chart's width, instead of a scaled viewBox that would distort them.
|
|
23
|
-
*/
|
|
24
|
-
function NativePlotChart({ points, renderMark, width = 320, height = 200, xLabel, yLabel, isDark: isDarkProp, style, }) {
|
|
25
|
-
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
26
|
-
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
27
|
-
const { View, Text, Svg, G, Line, Circle, SvgText } = (0, primitives_1.primitives)();
|
|
28
|
-
const plot = {
|
|
29
|
-
x: PADDING.left,
|
|
30
|
-
y: PADDING.top,
|
|
31
|
-
width: Math.max(0, width - PADDING.left - PADDING.right),
|
|
32
|
-
height: Math.max(0, height - PADDING.top - PADDING.bottom),
|
|
33
|
-
};
|
|
34
|
-
const right = plot.x + plot.width;
|
|
35
|
-
const bottom = plot.y + plot.height;
|
|
36
|
-
const xDomain = (0, react_1.useMemo)(() => {
|
|
37
|
-
const values = points.map((point) => point.x).filter(Number.isFinite);
|
|
38
|
-
return (0, scales_1.niceDomain)(values.length ? Math.min(...values) : 0, values.length ? Math.max(...values) : 1, 4);
|
|
39
|
-
}, [points.map((point) => point.x).join(",")]);
|
|
40
|
-
const yDomain = (0, react_1.useMemo)(() => {
|
|
41
|
-
const values = points.map((point) => point.y).filter(Number.isFinite);
|
|
42
|
-
return (0, scales_1.niceDomain)(values.length ? Math.min(...values) : 0, values.length ? Math.max(...values) : 1, 4);
|
|
43
|
-
}, [points.map((point) => point.y).join(",")]);
|
|
44
|
-
const x = (0, scales_1.linearScale)(xDomain, [plot.x, right], { nice: false });
|
|
45
|
-
const y = (0, scales_1.linearScale)(yDomain, [bottom, plot.y], { nice: false });
|
|
46
|
-
if (points.length === 0) {
|
|
47
|
-
return ((0, jsx_runtime_1.jsx)(View, { style: [{ width, height, alignItems: "center", justifyContent: "center" }, style], children: (0, jsx_runtime_1.jsx)(Text, { style: { color: theme.muted, fontSize: 12 }, children: "No points to display" }) }));
|
|
48
|
-
}
|
|
49
|
-
const yTicks = (0, scales_1.ticks)(yDomain, 4);
|
|
50
|
-
const xTicks = (0, scales_1.ticks)(xDomain, 4);
|
|
51
|
-
return ((0, jsx_runtime_1.jsxs)(View, { style: style, accessible: true, accessibilityRole: "image", accessibilityLabel: plotSummary(points, xDomain, yDomain), children: [(0, jsx_runtime_1.jsxs)(Svg, { width: width, height: height, children: [yTicks.map((tick, i) => ((0, jsx_runtime_1.jsx)(Line, { x1: plot.x, x2: right, y1: y(tick), y2: y(tick), stroke: theme.axis, strokeOpacity: 0.22, strokeWidth: 1 }, `grid-${i}`))), renderMark ? (renderMark({ x, y, points, width: plot.width, height: plot.height })) : ((0, jsx_runtime_1.jsx)(G, { children: points.map((point, index) => ((0, jsx_runtime_1.jsx)(Circle, { cx: x(point.x), cy: y(point.y), r: 3.5, fill: theme.fill }, index))) })), yTicks.map((tick, i) => ((0, jsx_runtime_1.jsx)(SvgText, { x: plot.x - 6, y: y(tick) + 3, fill: theme.muted, fontSize: 9, textAnchor: "end", children: (0, scales_1.formatValue)(tick, { compact: true }) }, `y-${i}`))), xTicks.map((tick, i) => ((0, jsx_runtime_1.jsx)(SvgText, { x: x(tick), y: height - 8, fill: theme.muted, fontSize: 9, textAnchor: "middle", children: (0, scales_1.formatValue)(tick, { compact: true }) }, `x-${i}`)))] }), (xLabel || yLabel) && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 9, color: theme.muted, marginTop: 2 }, children: [xLabel, yLabel].filter(Boolean).join(" · ") }))] }));
|
|
52
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NativeRadarChart = NativeRadarChart;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
const tokens_1 = require("../internal/tokens");
|
|
7
|
-
const motion_1 = require("../internal/motion");
|
|
8
|
-
const primitives_1 = require("../internal/primitives");
|
|
9
|
-
const scales_1 = require("./scales");
|
|
10
|
-
const TAU = Math.PI * 2;
|
|
11
|
-
/** Point on a circle at `index` of `count`, starting at 12 o'clock. */
|
|
12
|
-
function vertex(index, count, radius, cx, cy) {
|
|
13
|
-
const angle = (index / count) * TAU - Math.PI / 2;
|
|
14
|
-
return { x: cx + Math.cos(angle) * radius, y: cy + Math.sin(angle) * radius };
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Several axes around a circle, one closed shape per series.
|
|
18
|
-
*
|
|
19
|
-
* Reading many dimensions off a phone is hard, so every axis label is also a
|
|
20
|
-
* touch target: tapping one lists that axis's values for all series instead of
|
|
21
|
-
* relying on a hover tooltip.
|
|
22
|
-
*/
|
|
23
|
-
function NativeRadarChart({ axes, series, size = 260, rings = 4, max, isDark: isDarkProp, palette, style, onAxisPress, }) {
|
|
24
|
-
const [active, setActive] = (0, react_1.useState)(null);
|
|
25
|
-
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
26
|
-
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
27
|
-
const { View, Text, Pressable, Svg, G, Line, Polygon, Circle, SvgText } = (0, primitives_1.primitives)();
|
|
28
|
-
if (axes.length < 3 || series.length === 0) {
|
|
29
|
-
return ((0, jsx_runtime_1.jsx)(View, { style: [{ width: size, alignItems: "center", paddingVertical: 20 }, style], children: (0, jsx_runtime_1.jsx)(Text, { style: { color: theme.muted, fontSize: 12 }, children: axes.length < 3 ? "A radar chart needs at least 3 axes" : "No series to display" }) }));
|
|
30
|
-
}
|
|
31
|
-
const cx = size / 2;
|
|
32
|
-
const cy = size / 2;
|
|
33
|
-
// Leave room for the axis labels, which sit outside the outer ring.
|
|
34
|
-
const radius = size / 2 - 26;
|
|
35
|
-
const allValues = series.flatMap((s) => s.values).filter(Number.isFinite);
|
|
36
|
-
const highest = max ?? (allValues.length ? Math.max(...allValues) : 1);
|
|
37
|
-
const ceiling = highest > 0 ? highest : 1;
|
|
38
|
-
const ringPolygons = Array.from({ length: rings }, (_, i) => {
|
|
39
|
-
const r = (radius * (i + 1)) / rings;
|
|
40
|
-
return axes
|
|
41
|
-
.map((_, a) => {
|
|
42
|
-
const p = vertex(a, axes.length, r, cx, cy);
|
|
43
|
-
return `${p.x},${p.y}`;
|
|
44
|
-
})
|
|
45
|
-
.join(" ");
|
|
46
|
-
});
|
|
47
|
-
return ((0, jsx_runtime_1.jsxs)(View, { style: [{ width: size }, style], children: [(0, jsx_runtime_1.jsxs)(Svg, { width: size, height: size, children: [ringPolygons.map((points, i) => ((0, jsx_runtime_1.jsx)(Polygon, { points: points, fill: "none", stroke: theme.axis, strokeOpacity: 0.22, strokeWidth: 1 }, `ring-${i}`))), axes.map((_, a) => {
|
|
48
|
-
const p = vertex(a, axes.length, radius, cx, cy);
|
|
49
|
-
return ((0, jsx_runtime_1.jsx)(Line, { x1: cx, y1: cy, x2: p.x, y2: p.y, stroke: theme.axis, strokeOpacity: 0.22, strokeWidth: 1 }, `spoke-${a}`));
|
|
50
|
-
}), series.map((s, si) => {
|
|
51
|
-
const color = s.color ?? (0, scales_1.seriesColor)(si, palette);
|
|
52
|
-
const points = s.values
|
|
53
|
-
.map((value, a) => {
|
|
54
|
-
const ratio = Math.max(0, Math.min(1, value / ceiling));
|
|
55
|
-
const p = vertex(a, axes.length, radius * ratio, cx, cy);
|
|
56
|
-
return `${p.x},${p.y}`;
|
|
57
|
-
})
|
|
58
|
-
.join(" ");
|
|
59
|
-
return ((0, jsx_runtime_1.jsxs)(G, { children: [(0, jsx_runtime_1.jsx)(Polygon, { points: points, fill: color, fillOpacity: active === null ? 0.18 : 0.1, stroke: color, strokeWidth: 2 }), s.values.map((value, a) => {
|
|
60
|
-
const ratio = Math.max(0, Math.min(1, value / ceiling));
|
|
61
|
-
const p = vertex(a, axes.length, radius * ratio, cx, cy);
|
|
62
|
-
return ((0, jsx_runtime_1.jsx)(Circle, { cx: p.x, cy: p.y, r: active === a ? 4 : 2.5, fill: color }, a));
|
|
63
|
-
})] }, s.name));
|
|
64
|
-
}), axes.map((axis, a) => {
|
|
65
|
-
const p = vertex(a, axes.length, radius + 13, cx, cy);
|
|
66
|
-
// Labels on the left half should end at the axis, not start from it.
|
|
67
|
-
const anchor = p.x < cx - 1 ? "end" : p.x > cx + 1 ? "start" : "middle";
|
|
68
|
-
return ((0, jsx_runtime_1.jsx)(SvgText, { x: p.x, y: p.y + 3, fill: active === a ? theme.foreground : theme.muted, fontSize: 9, textAnchor: anchor, children: axis }, `label-${a}`));
|
|
69
|
-
})] }), (0, jsx_runtime_1.jsx)(View, { style: { flexDirection: "row", flexWrap: "wrap", gap: 6, marginTop: 8 }, children: axes.map((axis, a) => ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: `${axis} axis`, onPress: () => {
|
|
70
|
-
setActive((current) => (current === a ? null : a));
|
|
71
|
-
onAxisPress?.(a);
|
|
72
|
-
}, style: {
|
|
73
|
-
paddingVertical: 3,
|
|
74
|
-
paddingHorizontal: 8,
|
|
75
|
-
borderRadius: 7,
|
|
76
|
-
backgroundColor: active === a ? theme.glassActive : theme.glass,
|
|
77
|
-
}, children: (0, jsx_runtime_1.jsx)(Text, { style: { color: theme.foreground, fontSize: 10 }, children: axis }) }, axis))) }), active !== null && ((0, jsx_runtime_1.jsx)(View, { style: { marginTop: 8 }, children: series.map((s, si) => ((0, jsx_runtime_1.jsxs)(Text, { style: { color: theme.muted, fontSize: 10, marginTop: 2 }, children: [s.name, ": ", (0, scales_1.formatValue)(s.values[active] ?? 0)] }, s.name))) }))] }));
|
|
78
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NativeRingChart = NativeRingChart;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
const tokens_1 = require("../internal/tokens");
|
|
7
|
-
const motion_1 = require("../internal/motion");
|
|
8
|
-
const primitives_1 = require("../internal/primitives");
|
|
9
|
-
const scales_1 = require("./scales");
|
|
10
|
-
const TAU = Math.PI * 2;
|
|
11
|
-
/**
|
|
12
|
-
* Proportional slices as a ring, drawn with react-native-svg.
|
|
13
|
-
*
|
|
14
|
-
* Shares the arc maths with the web RingChart, so slices land in the same
|
|
15
|
-
* places on both platforms. A legend is on by default: on a phone there is no
|
|
16
|
-
* hover, so colour alone cannot identify a slice.
|
|
17
|
-
*/
|
|
18
|
-
function NativeRingChart({ data, size = 180, thickness = 22, isDark: isDarkProp, palette, showLegend = true, style, onSlicePress, }) {
|
|
19
|
-
const [active, setActive] = (0, react_1.useState)(null);
|
|
20
|
-
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
21
|
-
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
22
|
-
const { View, Text, Pressable, Svg, Path } = (0, primitives_1.primitives)();
|
|
23
|
-
const total = data.reduce((sum, slice) => sum + Math.max(0, slice.value), 0);
|
|
24
|
-
if (data.length === 0 || total <= 0) {
|
|
25
|
-
return ((0, jsx_runtime_1.jsx)(View, { style: [{ width: size, alignItems: "center" }, style], children: (0, jsx_runtime_1.jsx)(Text, { style: { color: theme.muted, fontSize: 12 }, children: "No slices to display" }) }));
|
|
26
|
-
}
|
|
27
|
-
const outer = size / 2;
|
|
28
|
-
const inner = Math.max(0, outer - thickness);
|
|
29
|
-
let cursor = -Math.PI / 2;
|
|
30
|
-
return ((0, jsx_runtime_1.jsxs)(View, { style: [{ alignItems: "center" }, style], children: [(0, jsx_runtime_1.jsx)(Svg, { width: size, height: size, children: data.map((slice, i) => {
|
|
31
|
-
const share = Math.max(0, slice.value) / total;
|
|
32
|
-
const start = cursor;
|
|
33
|
-
const end = cursor + share * TAU;
|
|
34
|
-
cursor = end;
|
|
35
|
-
return ((0, jsx_runtime_1.jsx)(Path, { d: (0, scales_1.arcPath)(outer, outer, outer, inner, start, end), fill: slice.color ?? (0, scales_1.seriesColor)(i, palette), opacity: active === null || active === i ? 1 : 0.4, onPress: () => {
|
|
36
|
-
setActive((current) => (current === i ? null : i));
|
|
37
|
-
onSlicePress?.(i);
|
|
38
|
-
} }, slice.label));
|
|
39
|
-
}) }), showLegend && ((0, jsx_runtime_1.jsx)(View, { style: { marginTop: 12, width: "100%", maxWidth: 260, gap: 6 }, children: data.map((slice, i) => ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "button", accessibilityLabel: `${slice.label}: ${(0, scales_1.formatValue)(slice.value)}, ${Math.round((slice.value / total) * 100)} percent`, onPress: () => {
|
|
40
|
-
setActive((current) => (current === i ? null : i));
|
|
41
|
-
onSlicePress?.(i);
|
|
42
|
-
}, style: { flexDirection: "row", alignItems: "center", gap: 8 }, children: [(0, jsx_runtime_1.jsx)(View, { style: {
|
|
43
|
-
width: 9,
|
|
44
|
-
height: 9,
|
|
45
|
-
borderRadius: 3,
|
|
46
|
-
backgroundColor: slice.color ?? (0, scales_1.seriesColor)(i, palette),
|
|
47
|
-
} }), (0, jsx_runtime_1.jsx)(Text, { style: { color: theme.muted, fontSize: 12, flex: 1 }, numberOfLines: 1, children: slice.label }), (0, jsx_runtime_1.jsx)(Text, { style: {
|
|
48
|
-
color: theme.foreground,
|
|
49
|
-
fontSize: 12,
|
|
50
|
-
fontWeight: active === i ? "700" : "600",
|
|
51
|
-
}, children: (0, scales_1.formatValue)(slice.value) })] }, slice.label))) }))] }));
|
|
52
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NativeScatterChart = NativeScatterChart;
|
|
4
|
-
exports.NativeBubbleChart = NativeBubbleChart;
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const react_1 = require("react");
|
|
7
|
-
const tokens_1 = require("../internal/tokens");
|
|
8
|
-
const motion_1 = require("../internal/motion");
|
|
9
|
-
const primitives_1 = require("../internal/primitives");
|
|
10
|
-
const scales_1 = require("./scales");
|
|
11
|
-
const PADDING = { top: 12, right: 12, bottom: 24, left: 40 };
|
|
12
|
-
/**
|
|
13
|
-
* Two numeric axes, drawn with react-native-svg.
|
|
14
|
-
*
|
|
15
|
-
* BubbleChart is this component with `bubble` set, so the two share their
|
|
16
|
-
* axes, padding and touch behaviour instead of drifting apart.
|
|
17
|
-
*/
|
|
18
|
-
function NativeScatterChart({ series, width = 320, height = 200, radius = 4, bubble = false, isDark: isDarkProp, palette, style, onPointPress, }) {
|
|
19
|
-
const [active, setActive] = (0, react_1.useState)(null);
|
|
20
|
-
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
21
|
-
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
22
|
-
const { View, Text, Svg, G, Line, Circle, SvgText } = (0, primitives_1.primitives)();
|
|
23
|
-
const plot = {
|
|
24
|
-
x: PADDING.left,
|
|
25
|
-
y: PADDING.top,
|
|
26
|
-
width: Math.max(0, width - PADDING.left - PADDING.right),
|
|
27
|
-
height: Math.max(0, height - PADDING.top - PADDING.bottom),
|
|
28
|
-
};
|
|
29
|
-
const right = plot.x + plot.width;
|
|
30
|
-
const bottom = plot.y + plot.height;
|
|
31
|
-
const all = series.flatMap((s) => s.points);
|
|
32
|
-
const xDomain = (0, react_1.useMemo)(() => {
|
|
33
|
-
const xs = all.map((p) => p.x).filter(Number.isFinite);
|
|
34
|
-
return (0, scales_1.niceDomain)(xs.length ? Math.min(...xs) : 0, xs.length ? Math.max(...xs) : 1, 4);
|
|
35
|
-
}, [all.map((p) => p.x).join(",")]);
|
|
36
|
-
const yDomain = (0, react_1.useMemo)(() => {
|
|
37
|
-
const ys = all.map((p) => p.y).filter(Number.isFinite);
|
|
38
|
-
return (0, scales_1.niceDomain)(ys.length ? Math.min(...ys) : 0, ys.length ? Math.max(...ys) : 1, 4);
|
|
39
|
-
}, [all.map((p) => p.y).join(",")]);
|
|
40
|
-
const x = (0, scales_1.linearScale)(xDomain, [plot.x, right], { nice: false });
|
|
41
|
-
const y = (0, scales_1.linearScale)(yDomain, [bottom, plot.y], { nice: false });
|
|
42
|
-
const sizes = all.map((p) => p.size ?? 1);
|
|
43
|
-
const maxSize = sizes.length ? Math.max(...sizes) : 1;
|
|
44
|
-
const minSize = sizes.length ? Math.min(...sizes) : 0;
|
|
45
|
-
const maxRadius = Math.min(plot.width, plot.height) / 7;
|
|
46
|
-
const radiusFor = (point) => {
|
|
47
|
-
if (!bubble)
|
|
48
|
-
return radius;
|
|
49
|
-
const size = point.size ?? minSize;
|
|
50
|
-
const t = maxSize === minSize ? 1 : (size - minSize) / (maxSize - minSize);
|
|
51
|
-
return 3 + t * (maxRadius - 3);
|
|
52
|
-
};
|
|
53
|
-
if (all.length === 0) {
|
|
54
|
-
return ((0, jsx_runtime_1.jsx)(View, { style: [{ width, height, alignItems: "center", justifyContent: "center" }, style], children: (0, jsx_runtime_1.jsx)(Text, { style: { color: theme.muted, fontSize: 12 }, children: "No points to display" }) }));
|
|
55
|
-
}
|
|
56
|
-
const yTicks = (0, scales_1.ticks)(yDomain, 4);
|
|
57
|
-
const xTicks = (0, scales_1.ticks)(xDomain, 4);
|
|
58
|
-
return ((0, jsx_runtime_1.jsxs)(View, { style: style,
|
|
59
|
-
// One summary for the whole chart: the per-point touch targets below are
|
|
60
|
-
// the detailed access, this is what is announced on focus.
|
|
61
|
-
accessible: true, accessibilityRole: "image", accessibilityLabel: scatterSummary(series), children: [(0, jsx_runtime_1.jsxs)(Svg, { width: width, height: height, children: [yTicks.map((tick, i) => ((0, jsx_runtime_1.jsx)(Line, { x1: plot.x, x2: right, y1: y(tick), y2: y(tick), stroke: theme.axis, strokeOpacity: 0.24, strokeWidth: 1 }, `grid-${i}`))), series.map((s, si) => {
|
|
62
|
-
const color = s.color ?? (0, scales_1.seriesColor)(si, palette);
|
|
63
|
-
return ((0, jsx_runtime_1.jsx)(G, { children: s.points.map((point, pi) => {
|
|
64
|
-
const isActive = active?.s === si && active?.p === pi;
|
|
65
|
-
return ((0, jsx_runtime_1.jsx)(Circle, { cx: x(point.x), cy: y(point.y), r: radiusFor(point) + (isActive ? 2 : 0), fill: color, fillOpacity: isActive ? 0.95 : bubble ? 0.55 : 0.8, onPress: () => {
|
|
66
|
-
setActive(isActive ? null : { s: si, p: pi });
|
|
67
|
-
onPointPress?.(si, pi);
|
|
68
|
-
} }, pi));
|
|
69
|
-
}) }, s.name));
|
|
70
|
-
}), yTicks.map((tick, i) => ((0, jsx_runtime_1.jsx)(SvgText, { x: plot.x - 6, y: y(tick) + 3, fill: theme.muted, fontSize: 9, textAnchor: "end", children: (0, scales_1.formatValue)(tick, { compact: true }) }, `y-${i}`))), xTicks.map((tick, i) => ((0, jsx_runtime_1.jsx)(SvgText, { x: x(tick), y: height - 8, fill: theme.muted, fontSize: 9, textAnchor: "middle", children: (0, scales_1.formatValue)(tick, { compact: true }) }, `x-${i}`)))] }), active !== null && series[active.s]?.points[active.p] && ((0, jsx_runtime_1.jsxs)(View, { style: {
|
|
71
|
-
position: "absolute",
|
|
72
|
-
top: 0,
|
|
73
|
-
left: PADDING.left,
|
|
74
|
-
paddingVertical: 3,
|
|
75
|
-
paddingHorizontal: 7,
|
|
76
|
-
borderRadius: 8,
|
|
77
|
-
backgroundColor: theme.glass,
|
|
78
|
-
}, pointerEvents: "none", children: [(0, jsx_runtime_1.jsx)(Text, { style: { color: theme.foreground, fontSize: 10, fontWeight: "600" }, children: series[active.s].points[active.p].label ?? series[active.s].name }), (0, jsx_runtime_1.jsxs)(Text, { style: { color: theme.muted, fontSize: 10 }, children: ["x ", (0, scales_1.formatValue)(series[active.s].points[active.p].x), " \u00B7 y", " ", (0, scales_1.formatValue)(series[active.s].points[active.p].y)] })] }))] }));
|
|
79
|
-
}
|
|
80
|
-
/** Reads the chart as one sentence for a screen reader. */
|
|
81
|
-
function scatterSummary(series) {
|
|
82
|
-
const sentences = series.map((entry) => {
|
|
83
|
-
const ys = entry.points.map((point) => point.y).filter(Number.isFinite);
|
|
84
|
-
if (ys.length === 0)
|
|
85
|
-
return `${entry.name}: no points`;
|
|
86
|
-
const min = (0, scales_1.formatValue)(Math.min(...ys));
|
|
87
|
-
const max = (0, scales_1.formatValue)(Math.max(...ys));
|
|
88
|
-
return `${entry.name}: ${entry.points.length} points, y from ${min} to ${max}`;
|
|
89
|
-
});
|
|
90
|
-
return `Scatter chart. ${sentences.join(". ")}`;
|
|
91
|
-
}
|
|
92
|
-
/** Scatter marks sized by a third value. */
|
|
93
|
-
function NativeBubbleChart(props) {
|
|
94
|
-
return (0, jsx_runtime_1.jsx)(NativeScatterChart, { ...props, bubble: true });
|
|
95
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NativeWaterfallChart = NativeWaterfallChart;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
const tokens_1 = require("../internal/tokens");
|
|
7
|
-
const motion_1 = require("../internal/motion");
|
|
8
|
-
const primitives_1 = require("../internal/primitives");
|
|
9
|
-
const scales_1 = require("./scales");
|
|
10
|
-
const PADDING = { top: 12, right: 8, bottom: 26, left: 42 };
|
|
11
|
-
/**
|
|
12
|
-
* How a running total moves step by step.
|
|
13
|
-
*
|
|
14
|
-
* Each bar starts where the previous one ended, so the reader sees the bridge
|
|
15
|
-
* from opening to closing balance rather than a set of unrelated changes.
|
|
16
|
-
* Increases and decreases are coloured differently, and totals span the axis.
|
|
17
|
-
*/
|
|
18
|
-
function NativeWaterfallChart({ steps, width = 320, height = 200, isDark: isDarkProp, style, onStepPress, }) {
|
|
19
|
-
const [active, setActive] = (0, react_1.useState)(null);
|
|
20
|
-
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
21
|
-
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
22
|
-
const { View, Text, Pressable, Svg, G, Line, Rect, SvgText } = (0, primitives_1.primitives)();
|
|
23
|
-
if (steps.length === 0) {
|
|
24
|
-
return ((0, jsx_runtime_1.jsx)(View, { style: [{ width, alignItems: "center", paddingVertical: 20 }, style], children: (0, jsx_runtime_1.jsx)(Text, { style: { color: theme.muted, fontSize: 12 }, children: "No steps to display" }) }));
|
|
25
|
-
}
|
|
26
|
-
const up = "#34c759";
|
|
27
|
-
const down = "#ff375f";
|
|
28
|
-
const plot = {
|
|
29
|
-
x: PADDING.left,
|
|
30
|
-
y: PADDING.top,
|
|
31
|
-
width: Math.max(0, width - PADDING.left - PADDING.right),
|
|
32
|
-
height: Math.max(0, height - PADDING.top - PADDING.bottom),
|
|
33
|
-
};
|
|
34
|
-
const right = plot.x + plot.width;
|
|
35
|
-
const bottom = plot.y + plot.height;
|
|
36
|
-
// Bounds come from the running totals, not the raw deltas: a −50 midway
|
|
37
|
-
// through a climb needs the axis to reach below zero only if the running
|
|
38
|
-
// total actually does.
|
|
39
|
-
let running = 0;
|
|
40
|
-
const geometry = steps.map((step) => {
|
|
41
|
-
const start = step.isTotal ? 0 : running;
|
|
42
|
-
const end = step.isTotal ? step.value : running + step.value;
|
|
43
|
-
if (!step.isTotal)
|
|
44
|
-
running = end;
|
|
45
|
-
return {
|
|
46
|
-
start,
|
|
47
|
-
end,
|
|
48
|
-
low: Math.min(start, end),
|
|
49
|
-
high: Math.max(start, end),
|
|
50
|
-
};
|
|
51
|
-
});
|
|
52
|
-
const lows = geometry.map((g) => g.low);
|
|
53
|
-
const highs = geometry.map((g) => g.high);
|
|
54
|
-
const min = Math.min(0, ...lows);
|
|
55
|
-
const max = Math.max(0, ...highs);
|
|
56
|
-
const span = max - min || 1;
|
|
57
|
-
const y = (value) => bottom - ((value - min) / span) * plot.height;
|
|
58
|
-
const stepWidth = plot.width / steps.length;
|
|
59
|
-
const barWidth = Math.min(34, stepWidth * 0.6);
|
|
60
|
-
const zeroY = y(0);
|
|
61
|
-
return ((0, jsx_runtime_1.jsxs)(View, { style: style, accessible: true, accessibilityRole: "image", accessibilityLabel: waterfallSummary(steps, geometry), children: [(0, jsx_runtime_1.jsxs)(Svg, { width: width, height: height, children: [(0, jsx_runtime_1.jsx)(Line, { x1: plot.x, x2: right, y1: zeroY, y2: zeroY, stroke: theme.axis, strokeOpacity: 0.4, strokeWidth: 1 }), geometry.map((g, i) => {
|
|
62
|
-
const step = steps[i];
|
|
63
|
-
const top = y(g.high);
|
|
64
|
-
const barHeight = Math.max(1, y(g.low) - top);
|
|
65
|
-
const color = step.isTotal ? seriesTotalColor(isDark) : step.value >= 0 ? up : down;
|
|
66
|
-
const x = plot.x + stepWidth * i + (stepWidth - barWidth) / 2;
|
|
67
|
-
return ((0, jsx_runtime_1.jsxs)(G, { children: [(0, jsx_runtime_1.jsx)(Rect, { x: x, y: top, width: barWidth, height: barHeight, rx: 3, fill: color, fillOpacity: active === null || active === i ? 1 : 0.45, onPress: () => {
|
|
68
|
-
setActive((current) => (current === i ? null : i));
|
|
69
|
-
onStepPress?.(i);
|
|
70
|
-
} }), i < steps.length - 1 && !steps[i + 1].isTotal && ((0, jsx_runtime_1.jsx)(Line, { x1: x + barWidth, x2: plot.x + stepWidth * (i + 1) + (stepWidth - barWidth) / 2, y1: y(g.end), y2: y(g.end), stroke: theme.axis, strokeOpacity: 0.4, strokeWidth: 1, strokeDasharray: "2,2" })), (0, jsx_runtime_1.jsx)(SvgText, { x: x + barWidth / 2, y: height - 8, fill: theme.muted, fontSize: 8, textAnchor: "middle", children: step.label })] }, step.label));
|
|
71
|
-
}), [max, min].map((value, i) => ((0, jsx_runtime_1.jsx)(SvgText, { x: plot.x - 6, y: y(value) + 3, fill: theme.muted, fontSize: 9, textAnchor: "end", children: (0, scales_1.formatValue)(value, { compact: true }) }, `y-${i}`)))] }), active !== null && ((0, jsx_runtime_1.jsxs)(Text, { style: { color: theme.foreground, fontSize: 11, marginTop: 6 }, children: [steps[active].label, ": ", steps[active].value >= 0 ? "+" : "", (0, scales_1.formatValue)(steps[active].value), steps[active].isTotal
|
|
72
|
-
? " (total)"
|
|
73
|
-
: ` → ${(0, scales_1.formatValue)(geometry[active].end)} running`] }))] }));
|
|
74
|
-
}
|
|
75
|
-
/** Reads the chart as one sentence for a screen reader. */
|
|
76
|
-
function waterfallSummary(steps, geometry) {
|
|
77
|
-
const last = geometry[geometry.length - 1];
|
|
78
|
-
const changes = steps.filter((step) => !step.isTotal).length;
|
|
79
|
-
const closing = last ? ` Closing value ${(0, scales_1.formatValue)(last.end)}.` : "";
|
|
80
|
-
return `Waterfall chart. ${steps.length} steps, ${changes} of them changes.${closing}`;
|
|
81
|
-
}
|
|
82
|
-
/** Totals are neutral so they do not read as a gain or loss. */
|
|
83
|
-
function seriesTotalColor(isDark) {
|
|
84
|
-
return isDark ? "#8e8e93" : "#3c3c43";
|
|
85
|
-
}
|