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/lib/module/Table.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NativeTable = NativeTable;
|
|
4
|
-
exports.NativeScrollArea = NativeScrollArea;
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const tokens_1 = require("./internal/tokens");
|
|
7
|
-
const primitives_1 = require("./internal/primitives");
|
|
8
|
-
const motion_1 = require("./internal/motion");
|
|
9
|
-
/**
|
|
10
|
-
* Tabular data laid out for a phone.
|
|
11
|
-
*
|
|
12
|
-
* A wide table cannot simply shrink: at phone width the columns become
|
|
13
|
-
* unreadable. Instead the first column is promoted to a row title and the rest
|
|
14
|
-
* are laid out as labelled pairs beneath it, which keeps every value readable
|
|
15
|
-
* without horizontal scrolling.
|
|
16
|
-
*/
|
|
17
|
-
function NativeTable({ columns, rows, onRowPress, caption, isDark: isDarkProp, style, emptyMessage = "No rows to display", testID, }) {
|
|
18
|
-
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
19
|
-
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
20
|
-
const { View, Text, Pressable } = (0, primitives_1.primitives)();
|
|
21
|
-
if (rows.length === 0) {
|
|
22
|
-
return ((0, jsx_runtime_1.jsx)(View, { style: [{ paddingVertical: 20, alignItems: "center" }, style], children: (0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 12, color: theme.muted }, children: emptyMessage }) }));
|
|
23
|
-
}
|
|
24
|
-
// The first column becomes the row's title when the caller marks none.
|
|
25
|
-
const primaryKey = columns.find((column) => column.primary)?.key ?? columns[0]?.key;
|
|
26
|
-
const primaryColumn = columns.find((column) => column.key === primaryKey);
|
|
27
|
-
const detailColumns = columns.filter((column) => column.key !== primaryKey);
|
|
28
|
-
return ((0, jsx_runtime_1.jsxs)(View, { style: style, testID: testID, children: [caption && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 12, color: theme.muted, marginBottom: 8 }, children: caption })), rows.map((row) => {
|
|
29
|
-
const RowWrapper = onRowPress ? Pressable : View;
|
|
30
|
-
const wrapperProps = onRowPress
|
|
31
|
-
? {
|
|
32
|
-
accessibilityRole: "button",
|
|
33
|
-
accessibilityLabel: rowAccessibilityLabel(row, primaryKey),
|
|
34
|
-
onPress: () => onRowPress(row),
|
|
35
|
-
}
|
|
36
|
-
: { accessibilityRole: "text" };
|
|
37
|
-
return ((0, jsx_runtime_1.jsxs)(RowWrapper, { ...wrapperProps, style: {
|
|
38
|
-
paddingVertical: 12,
|
|
39
|
-
paddingHorizontal: 16,
|
|
40
|
-
borderBottomWidth: 1,
|
|
41
|
-
borderBottomColor: theme.edge,
|
|
42
|
-
}, children: [primaryColumn && ((0, jsx_runtime_1.jsx)(Text, { style: {
|
|
43
|
-
fontSize: 14,
|
|
44
|
-
fontWeight: "600",
|
|
45
|
-
color: theme.foreground,
|
|
46
|
-
textAlign: primaryColumn.align ?? "left",
|
|
47
|
-
}, children: row.cells[primaryColumn.key] ?? "" })), detailColumns.length > 0 && ((0, jsx_runtime_1.jsx)(View, { style: { marginTop: 6, gap: 4 }, children: detailColumns.map((column) => ((0, jsx_runtime_1.jsxs)(View, { style: {
|
|
48
|
-
flexDirection: "row",
|
|
49
|
-
justifyContent: "space-between",
|
|
50
|
-
alignItems: "baseline",
|
|
51
|
-
gap: 12,
|
|
52
|
-
}, children: [(0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 12, fontWeight: "600", color: theme.muted }, children: column.header }), (0, jsx_runtime_1.jsx)(Text, { style: {
|
|
53
|
-
fontSize: 12,
|
|
54
|
-
color: theme.foreground,
|
|
55
|
-
textAlign: column.align ?? "left",
|
|
56
|
-
}, children: row.cells[column.key] ?? "" })] }, column.key))) }))] }, row.id));
|
|
57
|
-
})] }));
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* What screen readers announce for a pressable row.
|
|
61
|
-
*
|
|
62
|
-
* A cell can be any element, and `String(cell)` of an element announces
|
|
63
|
-
* "[object Object]". So: an explicit row label wins, then a textual primary
|
|
64
|
-
* cell, then a neutral fallback.
|
|
65
|
-
*/
|
|
66
|
-
function rowAccessibilityLabel(row, primaryKey) {
|
|
67
|
-
if (row.accessibilityLabel)
|
|
68
|
-
return row.accessibilityLabel;
|
|
69
|
-
const primary = primaryKey ? row.cells[primaryKey] : undefined;
|
|
70
|
-
if (typeof primary === "string" || typeof primary === "number")
|
|
71
|
-
return String(primary);
|
|
72
|
-
return "Row";
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* A bounded scroll region.
|
|
76
|
-
*
|
|
77
|
-
* Uses the platform ScrollView rather than drawing a custom scrollbar: the OS
|
|
78
|
-
* scroll indicator is the one users already recognise, and it stays correct
|
|
79
|
-
* under momentum, bouncing and accessibility settings.
|
|
80
|
-
*/
|
|
81
|
-
function NativeScrollArea({ children, maxHeight, bordered = false, horizontal = false, isDark: isDarkProp, style, accessibilityLabel, }) {
|
|
82
|
-
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
83
|
-
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
84
|
-
const { View, getScrollView } = (0, primitives_1.primitives)();
|
|
85
|
-
const ScrollView = getScrollView();
|
|
86
|
-
const containerStyle = {
|
|
87
|
-
maxHeight,
|
|
88
|
-
borderRadius: bordered ? 12 : undefined,
|
|
89
|
-
borderWidth: bordered ? 1 : 0,
|
|
90
|
-
borderColor: theme.edge,
|
|
91
|
-
overflow: "hidden",
|
|
92
|
-
...style,
|
|
93
|
-
};
|
|
94
|
-
if (!ScrollView) {
|
|
95
|
-
// Off-device there is no ScrollView; render the content in a clipped box so
|
|
96
|
-
// layout still matches instead of dropping children.
|
|
97
|
-
return ((0, jsx_runtime_1.jsx)(View, { accessibilityLabel: accessibilityLabel, style: containerStyle, children: children }));
|
|
98
|
-
}
|
|
99
|
-
return ((0, jsx_runtime_1.jsx)(View, { style: containerStyle, children: (0, jsx_runtime_1.jsx)(ScrollView, { horizontal: horizontal, showsVerticalScrollIndicator: true, showsHorizontalScrollIndicator: horizontal, accessibilityLabel: accessibilityLabel, children: children }) }));
|
|
100
|
-
}
|
package/lib/module/ai.js
DELETED
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NativePlan = NativePlan;
|
|
4
|
-
exports.NativeSources = NativeSources;
|
|
5
|
-
exports.NativeResponse = NativeResponse;
|
|
6
|
-
exports.NativeTask = NativeTask;
|
|
7
|
-
exports.NativeSoundwave = NativeSoundwave;
|
|
8
|
-
exports.NativeThinkingOrb = NativeThinkingOrb;
|
|
9
|
-
exports.NativePanelside = NativePanelside;
|
|
10
|
-
exports.NativeAIInput = NativeAIInput;
|
|
11
|
-
exports.NativeImageGeneration = NativeImageGeneration;
|
|
12
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
13
|
-
const react_1 = require("react");
|
|
14
|
-
const Glass_1 = require("./Glass");
|
|
15
|
-
const tokens_1 = require("./internal/tokens");
|
|
16
|
-
const primitives_1 = require("./internal/primitives");
|
|
17
|
-
const motion_1 = require("./internal/motion");
|
|
18
|
-
const lens_1 = require("./internal/lens");
|
|
19
|
-
const a11y_1 = require("./internal/a11y");
|
|
20
|
-
/**
|
|
21
|
-
* The ordered steps a model intends to take.
|
|
22
|
-
*
|
|
23
|
-
* Each step carries its own status, so a half-finished plan is legible instead
|
|
24
|
-
* of appearing blank until the whole thing completes.
|
|
25
|
-
*/
|
|
26
|
-
function NativePlan({ title = "Plan", steps, isDark: isDarkProp, style }) {
|
|
27
|
-
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
28
|
-
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
29
|
-
const { View, Text } = (0, primitives_1.primitives)();
|
|
30
|
-
const done = steps.filter((step) => step.status === "done").length;
|
|
31
|
-
const markerColor = (status) => status === "done"
|
|
32
|
-
? "#34c759"
|
|
33
|
-
: status === "failed"
|
|
34
|
-
? theme.destructive
|
|
35
|
-
: status === "running"
|
|
36
|
-
? theme.fill
|
|
37
|
-
: theme.muted;
|
|
38
|
-
return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { surface: "panel", isDark: isDark, style: [{ paddingHorizontal: 14, paddingVertical: 12, borderRadius: tokens_1.radii.lg }, style], children: [(0, jsx_runtime_1.jsxs)(View, { style: {
|
|
39
|
-
flexDirection: "row",
|
|
40
|
-
justifyContent: "space-between",
|
|
41
|
-
alignItems: "center",
|
|
42
|
-
marginBottom: 8,
|
|
43
|
-
}, children: [(0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 13, fontWeight: "600", color: theme.foreground }, children: title }), (0, jsx_runtime_1.jsxs)(Text, { style: { fontSize: 11, color: theme.muted }, children: [done, "/", steps.length] })] }), steps.map((step) => ((0, jsx_runtime_1.jsxs)(View, { accessibilityRole: "text", accessibilityLabel: `${step.title}: ${step.status}`, style: { flexDirection: "row", alignItems: "flex-start", gap: 9, marginBottom: 8 }, children: [(0, jsx_runtime_1.jsx)(View, { style: {
|
|
44
|
-
width: 16,
|
|
45
|
-
height: 16,
|
|
46
|
-
borderRadius: 8,
|
|
47
|
-
borderWidth: step.status === "pending" ? 1.5 : 0,
|
|
48
|
-
borderColor: theme.edge,
|
|
49
|
-
backgroundColor: step.status === "pending" ? "transparent" : markerColor(step.status),
|
|
50
|
-
alignItems: "center",
|
|
51
|
-
justifyContent: "center",
|
|
52
|
-
marginTop: 1,
|
|
53
|
-
}, children: step.status !== "pending" && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 9, color: "#fff", fontWeight: "700" }, children: step.status === "done" ? "✓" : step.status === "failed" ? "!" : "•" })) }), (0, jsx_runtime_1.jsxs)(View, { style: { flex: 1 }, children: [(0, jsx_runtime_1.jsx)(Text, { style: {
|
|
54
|
-
fontSize: 13,
|
|
55
|
-
color: step.status === "pending" ? theme.muted : theme.foreground,
|
|
56
|
-
}, children: step.title }), step.detail && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 11, color: theme.muted, marginTop: 2 }, children: step.detail }))] })] }, step.id)))] }));
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Citations behind an answer, so a claim can be traced to its origin.
|
|
60
|
-
*
|
|
61
|
-
* Native has no anchor element, so a row hands the source to the caller's
|
|
62
|
-
* `onSourcePress` instead of opening a browser the component cannot control.
|
|
63
|
-
*/
|
|
64
|
-
function NativeSources({ sources, title = "Sources", isDark: isDarkProp, style, onSourcePress, }) {
|
|
65
|
-
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
66
|
-
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
67
|
-
const { View, Text, Pressable } = (0, primitives_1.primitives)();
|
|
68
|
-
if (sources.length === 0)
|
|
69
|
-
return null;
|
|
70
|
-
return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { surface: "panel", isDark: isDark, style: [{ paddingHorizontal: 14, paddingVertical: 12, borderRadius: tokens_1.radii.lg }, style], children: [(0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 11, fontWeight: "600", color: theme.muted, marginBottom: 6 }, children: title }), sources.map((source, index) => ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "link", accessibilityLabel: source.title, onPress: () => onSourcePress?.(source), style: {
|
|
71
|
-
flexDirection: "row",
|
|
72
|
-
gap: 9,
|
|
73
|
-
paddingVertical: 7,
|
|
74
|
-
paddingHorizontal: 10,
|
|
75
|
-
borderRadius: tokens_1.radii.md,
|
|
76
|
-
borderWidth: 1,
|
|
77
|
-
borderColor: theme.edge,
|
|
78
|
-
marginBottom: 6,
|
|
79
|
-
}, children: [(0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 10, color: theme.muted, marginTop: 1 }, children: index + 1 }), (0, jsx_runtime_1.jsxs)(View, { style: { flex: 1 }, children: [(0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 12, color: theme.foreground, fontWeight: "500" }, children: source.title }), source.snippet && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 11, color: theme.muted, marginTop: 2 }, children: source.snippet })), source.domain && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 10, color: theme.muted, marginTop: 3 }, children: source.domain }))] })] }, source.id)))] }));
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Text revealed progressively as a streamed answer arrives.
|
|
83
|
-
*
|
|
84
|
-
* The caller owns the streaming clock (usually a network stream); this only
|
|
85
|
-
* renders the first `revealed` characters and shows a caret while incomplete.
|
|
86
|
-
*/
|
|
87
|
-
function NativeResponse({ text, revealed, streaming, isDark: isDarkProp, style, }) {
|
|
88
|
-
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
89
|
-
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
90
|
-
const { View, Text } = (0, primitives_1.primitives)();
|
|
91
|
-
const shown = revealed == null ? text : text.slice(0, Math.max(0, revealed));
|
|
92
|
-
const isStreaming = streaming ?? (revealed != null && revealed < text.length);
|
|
93
|
-
return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { surface: "panel", isDark: isDark, style: [{ paddingHorizontal: 14, paddingVertical: 12, borderRadius: tokens_1.radii.lg }, style], children: [(0, jsx_runtime_1.jsxs)(Text, { accessibilityRole: "text", accessibilityLabel: shown, style: { fontSize: 14, lineHeight: 21, color: theme.foreground }, children: [shown, isStreaming ? "▍" : ""] }), (0, jsx_runtime_1.jsx)(Text, { accessibilityRole: "alert", style: { height: 0, opacity: 0, fontSize: 0 }, children: isStreaming ? "Response streaming" : "Response complete" })] }));
|
|
94
|
-
}
|
|
95
|
-
/** Progress of a long-running background task. */
|
|
96
|
-
function NativeTask({ task, isDark: isDarkProp, style }) {
|
|
97
|
-
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
98
|
-
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
99
|
-
const { View, Text } = (0, primitives_1.primitives)();
|
|
100
|
-
const percent = task.progress == null ? null : Math.round(Math.min(1, Math.max(0, task.progress)) * 100);
|
|
101
|
-
const status = task.status ?? "running";
|
|
102
|
-
const fillColor = status === "failed" ? theme.destructive : status === "done" ? "#34c759" : theme.fill;
|
|
103
|
-
return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { surface: "panel", isDark: isDark, accessibilityRole: "progressbar", accessibilityLabel: task.label ?? "Task progress",
|
|
104
|
-
// Without the value, a screen reader only reads the label and never says
|
|
105
|
-
// how far along the task is.
|
|
106
|
-
accessibilityValue: percent == null ? undefined : { min: 0, max: 100, now: percent }, accessibilityState: {
|
|
107
|
-
disabled: false,
|
|
108
|
-
}, style: [{ paddingHorizontal: 14, paddingVertical: 12, borderRadius: tokens_1.radii.lg }, style], children: [(0, jsx_runtime_1.jsxs)(View, { style: { flexDirection: "row", justifyContent: "space-between", marginBottom: 6 }, children: [(0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 12, fontWeight: "500", color: theme.foreground }, children: task.label ?? "Task" }), (0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 11, color: theme.muted }, children: percent == null ? "…" : `${percent}%` })] }), (0, jsx_runtime_1.jsx)(View, { style: {
|
|
109
|
-
height: 6,
|
|
110
|
-
borderRadius: 3,
|
|
111
|
-
backgroundColor: isDark ? "rgba(235,235,245,0.15)" : "rgba(0,0,0,0.08)",
|
|
112
|
-
overflow: "hidden",
|
|
113
|
-
}, children: (0, jsx_runtime_1.jsx)(View, { style: {
|
|
114
|
-
// An indeterminate task fills partially rather than pretending 0%.
|
|
115
|
-
width: percent == null ? "35%" : `${percent}%`,
|
|
116
|
-
height: "100%",
|
|
117
|
-
borderRadius: 3,
|
|
118
|
-
backgroundColor: fillColor,
|
|
119
|
-
opacity: percent == null ? 0.6 : 1,
|
|
120
|
-
} }) }), task.detail && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 11, color: theme.muted, marginTop: 6 }, children: task.detail }))] }));
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* A waveform driven by real amplitude.
|
|
124
|
-
*
|
|
125
|
-
* Bars follow `levels` when supplied, so it can show live microphone input.
|
|
126
|
-
* Without levels it rests at a low, static profile instead of animating:
|
|
127
|
-
* continuous motion with no audio behind it would be decorative noise.
|
|
128
|
-
*/
|
|
129
|
-
function NativeSoundwave({ levels, bars = 28, active = true, height = 40, color, isDark: isDarkProp, style, label = "Audio level", }) {
|
|
130
|
-
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
131
|
-
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
132
|
-
const { View } = (0, primitives_1.primitives)();
|
|
133
|
-
const count = levels?.length || bars;
|
|
134
|
-
const tint = color ?? theme.foreground;
|
|
135
|
-
return ((0, jsx_runtime_1.jsx)(View, { accessibilityRole: "image", accessibilityLabel: label, style: { flexDirection: "row", alignItems: "center", gap: 2, height, ...style }, children: Array.from({ length: count }, (_, i) => {
|
|
136
|
-
const level = levels ? levels[i] ?? 0 : 0;
|
|
137
|
-
// Idle bars taper at the edges so the shape still reads as a wave.
|
|
138
|
-
const idle = 0.12 + Math.sin((i / count) * Math.PI) * 0.1;
|
|
139
|
-
const scale = Math.max(0.06, Math.min(1, active && levels ? level : idle));
|
|
140
|
-
return ((0, jsx_runtime_1.jsx)(View, { style: {
|
|
141
|
-
width: 3,
|
|
142
|
-
height: height * scale,
|
|
143
|
-
borderRadius: 2,
|
|
144
|
-
backgroundColor: tint,
|
|
145
|
-
opacity: active ? 0.85 : 0.35,
|
|
146
|
-
} }, i));
|
|
147
|
-
}) }));
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* A pulsing indicator shown while a model is working.
|
|
151
|
-
*
|
|
152
|
-
* Purely decorative, so it is hidden from screen readers and the label is
|
|
153
|
-
* exposed as text instead of relying on the motion being perceived.
|
|
154
|
-
*/
|
|
155
|
-
function NativeThinkingOrb({ label = "Thinking", size = 22, paused = false, isDark: isDarkProp, style, }) {
|
|
156
|
-
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
157
|
-
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
158
|
-
const { View, Text } = (0, primitives_1.primitives)();
|
|
159
|
-
const reducedMotion = (0, a11y_1.useReducedMotion)();
|
|
160
|
-
const [tick, setTick] = (0, react_1.useState)(0);
|
|
161
|
-
// Reduce Motion: the orb stops pulsing and holds a steady size. The label is
|
|
162
|
-
// what carries the meaning, so nothing is lost by not moving.
|
|
163
|
-
const still = paused || reducedMotion;
|
|
164
|
-
(0, react_1.useEffect)(() => {
|
|
165
|
-
if (still)
|
|
166
|
-
return;
|
|
167
|
-
const timer = setInterval(() => setTick((value) => value + 1), 700);
|
|
168
|
-
return () => clearInterval(timer);
|
|
169
|
-
}, [still]);
|
|
170
|
-
const scale = still ? 1 : [1, 1.12, 1][tick % 3];
|
|
171
|
-
return ((0, jsx_runtime_1.jsxs)(View, { accessibilityRole: "text", accessibilityLabel: label, style: { flexDirection: "row", alignItems: "center", gap: 8, ...style }, children: [(0, jsx_runtime_1.jsx)(View, { style: {
|
|
172
|
-
width: size,
|
|
173
|
-
height: size,
|
|
174
|
-
borderRadius: size / 2,
|
|
175
|
-
backgroundColor: theme.fill,
|
|
176
|
-
opacity: paused ? 0.5 : 0.85,
|
|
177
|
-
transform: [{ scale }],
|
|
178
|
-
} }), (0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 12, color: theme.muted }, children: label })] }));
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* A rail for an AI workspace: conversations, saved prompts or tasks.
|
|
182
|
-
*
|
|
183
|
-
* Selection is a press rather than navigation because the panel's content is
|
|
184
|
-
* client state; the caller decides what a selection means.
|
|
185
|
-
*/
|
|
186
|
-
function NativePanelside({ items, value, onValueChange, isDark: isDarkProp, style, title, }) {
|
|
187
|
-
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
188
|
-
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
189
|
-
const { View, Text, Pressable } = (0, primitives_1.primitives)();
|
|
190
|
-
return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { surface: "panel", isDark: isDark, style: [{ paddingHorizontal: 14, paddingVertical: 12, borderRadius: tokens_1.radii.lg }, style], children: [title && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 11, fontWeight: "600", color: theme.muted, marginBottom: 6 }, children: title })), items.map((item) => {
|
|
191
|
-
const isActive = item.id === value;
|
|
192
|
-
return ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "button", accessibilityState: { selected: isActive }, accessibilityLabel: item.label, onPress: () => onValueChange?.(item.id), style: {
|
|
193
|
-
flexDirection: "row",
|
|
194
|
-
alignItems: "center",
|
|
195
|
-
justifyContent: "space-between",
|
|
196
|
-
paddingVertical: 9,
|
|
197
|
-
paddingHorizontal: 11,
|
|
198
|
-
borderRadius: tokens_1.radii.md,
|
|
199
|
-
backgroundColor: "transparent",
|
|
200
|
-
marginBottom: 2,
|
|
201
|
-
}, children: [isActive ? (0, jsx_runtime_1.jsx)(lens_1.SelectedLens, { radius: tokens_1.radii.md, isDark: isDark, style: lens_1.lensFill }) : null, (0, jsx_runtime_1.jsx)(Text, { style: {
|
|
202
|
-
fontSize: 13,
|
|
203
|
-
color: isActive ? theme.foreground : theme.muted,
|
|
204
|
-
fontWeight: isActive ? "600" : "400",
|
|
205
|
-
}, children: item.label }), item.count != null && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 10, color: theme.muted }, children: item.count }))] }, item.id));
|
|
206
|
-
})] }));
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* The composer for an AI conversation.
|
|
210
|
-
*
|
|
211
|
-
* Send stays disabled until there is non-whitespace to send, which is the rule
|
|
212
|
-
* that prevents empty submissions rather than a validation message afterwards.
|
|
213
|
-
*/
|
|
214
|
-
function NativeAIInput({ value: valueProp, defaultValue, onChangeText, onSubmit, placeholder = "Ask anything", disabled = false, busy = false, sendLabel = "Send", isDark: isDarkProp, style, footer, }) {
|
|
215
|
-
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
216
|
-
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
217
|
-
const { View, Text, TextInput, Pressable } = (0, primitives_1.primitives)();
|
|
218
|
-
// Uncontrolled support: the composer owns its text when no `value` is given,
|
|
219
|
-
// which is what makes typed text appear in plain uncontrolled use.
|
|
220
|
-
const [internalText, setInternalText] = (0, react_1.useState)(defaultValue ?? "");
|
|
221
|
-
const value = valueProp !== undefined ? valueProp : internalText;
|
|
222
|
-
const handleChangeText = (next) => {
|
|
223
|
-
if (valueProp === undefined)
|
|
224
|
-
setInternalText(next);
|
|
225
|
-
onChangeText?.(next);
|
|
226
|
-
};
|
|
227
|
-
const canSend = !disabled && !busy && value.trim().length > 0;
|
|
228
|
-
// The themed placeholder is drawn as a Text, matching Input: the OS default
|
|
229
|
-
// placeholder colour ignores the theme.
|
|
230
|
-
const showPlaceholder = !value && Boolean(placeholder);
|
|
231
|
-
return ((0, jsx_runtime_1.jsxs)(View, { style: style, children: [(0, jsx_runtime_1.jsxs)(Glass_1.Glass, { surface: "field", isDark: isDark, style: {
|
|
232
|
-
flexDirection: "row",
|
|
233
|
-
alignItems: "flex-end",
|
|
234
|
-
gap: 8,
|
|
235
|
-
paddingVertical: 6,
|
|
236
|
-
paddingRight: 6,
|
|
237
|
-
paddingLeft: 16,
|
|
238
|
-
borderRadius: tokens_1.radii.pill,
|
|
239
|
-
opacity: disabled ? 0.5 : 1,
|
|
240
|
-
}, children: [(0, jsx_runtime_1.jsxs)(View, { style: { flex: 1, justifyContent: "center" }, children: [showPlaceholder && ((0, jsx_runtime_1.jsx)(Text, { pointerEvents: "none", numberOfLines: 1, style: {
|
|
241
|
-
position: "absolute",
|
|
242
|
-
left: 6,
|
|
243
|
-
fontSize: 14,
|
|
244
|
-
color: theme.muted,
|
|
245
|
-
}, children: placeholder })), (0, jsx_runtime_1.jsx)(TextInput, { value: value, onChangeText: handleChangeText, editable: !disabled, multiline: true, numberOfLines: 3, accessibilityLabel: placeholder, accessibilityState: { disabled }, style: {
|
|
246
|
-
minHeight: 34,
|
|
247
|
-
maxHeight: 120,
|
|
248
|
-
paddingHorizontal: 6,
|
|
249
|
-
paddingVertical: 7,
|
|
250
|
-
fontSize: 14,
|
|
251
|
-
color: theme.foreground,
|
|
252
|
-
} })] }), (0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: sendLabel, accessibilityState: { disabled: !canSend }, disabled: !canSend, onPress: () => canSend && onSubmit?.(), style: {
|
|
253
|
-
height: 34,
|
|
254
|
-
paddingHorizontal: 14,
|
|
255
|
-
alignItems: "center",
|
|
256
|
-
justifyContent: "center",
|
|
257
|
-
borderRadius: tokens_1.radii.pill,
|
|
258
|
-
backgroundColor: canSend ? theme.fill : theme.edge,
|
|
259
|
-
}, children: (0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 13, fontWeight: "600", color: canSend ? "#fff" : theme.muted }, children: busy ? "…" : sendLabel }) })] }), footer] }));
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* A generated image with its prompt and state.
|
|
263
|
-
*
|
|
264
|
-
* While generating, a placeholder with the same aspect ratio holds the space so
|
|
265
|
-
* the layout does not jump when the image arrives.
|
|
266
|
-
*/
|
|
267
|
-
function NativeImageGeneration({ image, prompt, status = "queued", isDark: isDarkProp, style, }) {
|
|
268
|
-
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
269
|
-
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
270
|
-
const { View, Text, Image } = (0, primitives_1.primitives)();
|
|
271
|
-
const width = image?.width ?? 320;
|
|
272
|
-
const height = image?.height ?? 200;
|
|
273
|
-
const showImage = image && status === "done";
|
|
274
|
-
return ((0, jsx_runtime_1.jsxs)(View, { style: style, children: [(0, jsx_runtime_1.jsx)(View, { style: {
|
|
275
|
-
width: "100%",
|
|
276
|
-
aspectRatio: width / height,
|
|
277
|
-
borderRadius: tokens_1.radii.md,
|
|
278
|
-
overflow: "hidden",
|
|
279
|
-
backgroundColor: isDark ? "rgba(235,235,245,0.08)" : "rgba(0,0,0,0.05)",
|
|
280
|
-
alignItems: "center",
|
|
281
|
-
justifyContent: "center",
|
|
282
|
-
}, children: showImage ? ((0, jsx_runtime_1.jsx)(Image, { source: { uri: image.url }, accessibilityLabel: image.alt, style: { width: "100%", height: "100%" } })) : ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 12, color: theme.muted }, children: status === "failed" ? "Generation failed" : "Generating…" })) }), prompt && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 11, color: theme.muted, marginTop: 6 }, children: prompt }))] }));
|
|
283
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NativeAreaChart = NativeAreaChart;
|
|
4
|
-
exports.NativeMirrorAreaChart = NativeMirrorAreaChart;
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const LineChart_1 = require("./LineChart");
|
|
7
|
-
/**
|
|
8
|
-
* A continuous series with its area filled.
|
|
9
|
-
*
|
|
10
|
-
* This is NativeLineChart drawing filled: the same scales, axis ticks and
|
|
11
|
-
* touch targets, so the two stay consistent when used side by side.
|
|
12
|
-
*/
|
|
13
|
-
function NativeAreaChart(props) {
|
|
14
|
-
return (0, jsx_runtime_1.jsx)(LineChart_1.NativeLineChart, { ...props, area: true });
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Two series mirrored across a shared centre line.
|
|
18
|
-
*
|
|
19
|
-
* The below series is negated and drawn on the same axis as the above series,
|
|
20
|
-
* so both directions are measured against one honest scale rather than two
|
|
21
|
-
* charts that could be scaled differently.
|
|
22
|
-
*/
|
|
23
|
-
function NativeMirrorAreaChart({ labels, series, aboveColor = "#0088ff", belowColor = "#ff375f", ...rest }) {
|
|
24
|
-
return ((0, jsx_runtime_1.jsx)(LineChart_1.NativeLineChart, { ...rest, labels: labels, area: true, series: [
|
|
25
|
-
{ name: `${series.name} (above)`, values: series.above, color: aboveColor },
|
|
26
|
-
{
|
|
27
|
-
name: `${series.name} (below)`,
|
|
28
|
-
values: series.below.map((v) => -Math.abs(v)),
|
|
29
|
-
color: belowColor,
|
|
30
|
-
},
|
|
31
|
-
] }));
|
|
32
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NativeBarChart = NativeBarChart;
|
|
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
|
-
/** Grouped or stacked bars, drawn with react-native-svg. */
|
|
12
|
-
function NativeBarChart({ labels, series, width = 320, height = 200, stacked = false, radius = 4, isDark: isDarkProp, palette, style, onBarPress, }) {
|
|
13
|
-
const [active, setActive] = (0, react_1.useState)(null);
|
|
14
|
-
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
15
|
-
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
16
|
-
const { View, Text, Pressable, Svg, G, Line, Rect, SvgText, Defs, LinearGradient, Stop, } = (0, primitives_1.primitives)();
|
|
17
|
-
const plot = {
|
|
18
|
-
x: PADDING.left,
|
|
19
|
-
y: PADDING.top,
|
|
20
|
-
width: Math.max(0, width - PADDING.left - PADDING.right),
|
|
21
|
-
height: Math.max(0, height - PADDING.top - PADDING.bottom),
|
|
22
|
-
};
|
|
23
|
-
const bottom = plot.y + plot.height;
|
|
24
|
-
const right = plot.x + plot.width;
|
|
25
|
-
const totals = stacked
|
|
26
|
-
? labels.map((_, i) => series.reduce((sum, s) => sum + (s.values[i] ?? 0), 0))
|
|
27
|
-
: series.flatMap((s) => s.values);
|
|
28
|
-
const domain = (0, react_1.useMemo)(() => {
|
|
29
|
-
const max = totals.length ? Math.max(...totals) : 1;
|
|
30
|
-
return (0, scales_1.niceDomain)(0, max, 4);
|
|
31
|
-
}, [totals.join(",")]);
|
|
32
|
-
const y = (0, scales_1.linearScale)(domain, [bottom, plot.y], { nice: false });
|
|
33
|
-
const bands = (0, scales_1.bandScale)(labels.length, [plot.x, right], 0.32);
|
|
34
|
-
const seriesColors = series.map((s, si) => s.color ?? (0, scales_1.seriesColor)(si, palette));
|
|
35
|
-
// One gradient per series, so the SVG can reference them by id.
|
|
36
|
-
const gradientKey = (0, react_1.useId)().replace(/[^a-zA-Z0-9_-]/g, "");
|
|
37
|
-
const barWidth = stacked ? bands.width : bands.width / Math.max(1, series.length);
|
|
38
|
-
const yTicks = (0, scales_1.ticks)(domain, 4);
|
|
39
|
-
if (labels.length === 0 || series.length === 0) {
|
|
40
|
-
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 bars to display" }) }));
|
|
41
|
-
}
|
|
42
|
-
return ((0, jsx_runtime_1.jsxs)(View, { style: style, children: [(0, jsx_runtime_1.jsxs)(Svg, { width: width, height: height, children: [(0, jsx_runtime_1.jsx)(Defs, { children: seriesColors.map((color, si) => (
|
|
43
|
-
// The web's bar fill runs from the series colour at the top to
|
|
44
|
-
// transparent at the base, so a bar reads as lit from above.
|
|
45
|
-
(0, jsx_runtime_1.jsxs)(LinearGradient, { id: `bar-${gradientKey}-${si}`, x1: "0", y1: "0", x2: "0", y2: "1", children: [(0, jsx_runtime_1.jsx)(Stop, { offset: "0", stopColor: color, stopOpacity: 1 }), (0, jsx_runtime_1.jsx)(Stop, { offset: "0.55", stopColor: color, stopOpacity: 0.62 }), (0, jsx_runtime_1.jsx)(Stop, { offset: "1", stopColor: color, stopOpacity: 0.04 })] }, `grad-${si}`))) }), 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}`))), labels.map((label, i) => {
|
|
46
|
-
let stackTop = bottom;
|
|
47
|
-
return ((0, jsx_runtime_1.jsx)(G, { children: series.map((s, si) => {
|
|
48
|
-
const value = s.values[i] ?? 0;
|
|
49
|
-
const color = s.color ?? (0, scales_1.seriesColor)(si, palette);
|
|
50
|
-
const barHeight = Math.max(0, bottom - y(value));
|
|
51
|
-
const barX = stacked
|
|
52
|
-
? bands.start(i)
|
|
53
|
-
: bands.start(i) + si * barWidth + (si > 0 ? 1 : 0);
|
|
54
|
-
const barY = stacked ? stackTop - barHeight : y(value);
|
|
55
|
-
const w = stacked ? bands.width : Math.max(1, barWidth - (si > 0 ? 1 : 0));
|
|
56
|
-
if (stacked)
|
|
57
|
-
stackTop -= barHeight;
|
|
58
|
-
return ((0, jsx_runtime_1.jsx)(Rect, { x: barX, y: barY, width: w, height: barHeight, rx: Math.min(radius, w / 2), fill: `url(#bar-${gradientKey}-${si})`,
|
|
59
|
-
// The inset edge the web draws inside every bar.
|
|
60
|
-
stroke: color, strokeOpacity: 0.35, strokeWidth: 0.5, opacity: active === null || active === i ? 1 : 0.45 }, s.name));
|
|
61
|
-
}) }, label + i));
|
|
62
|
-
}), 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: bands.center(i), y: height - 8, fill: theme.muted, fontSize: 9, textAnchor: "middle", children: label }, `x-${i}`)))] }), (0, jsx_runtime_1.jsx)(View, { style: {
|
|
63
|
-
position: "absolute",
|
|
64
|
-
left: plot.x,
|
|
65
|
-
top: plot.y,
|
|
66
|
-
width: plot.width,
|
|
67
|
-
height: plot.height,
|
|
68
|
-
flexDirection: "row",
|
|
69
|
-
}, children: labels.map((label, i) => ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: `${label}: ${series
|
|
70
|
-
.map((s) => `${s.name} ${(0, scales_1.formatValue)(s.values[i] ?? 0)}`)
|
|
71
|
-
.join(", ")}`, style: { flex: 1 }, onPress: () => {
|
|
72
|
-
setActive((current) => (current === i ? null : i));
|
|
73
|
-
onBarPress?.(i);
|
|
74
|
-
} }, label + i))) })] }));
|
|
75
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NativeFunnelChart = NativeFunnelChart;
|
|
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
|
-
/**
|
|
11
|
-
* A sequence of stages where each narrows the one before it.
|
|
12
|
-
*
|
|
13
|
-
* Built from plain Views rather than SVG: a funnel is a set of proportional
|
|
14
|
-
* rectangles, so vector drawing would add a dependency for nothing. Each row
|
|
15
|
-
* shows its own value, its share of entry, and the step conversion — the three
|
|
16
|
-
* numbers a funnel is actually read for.
|
|
17
|
-
*/
|
|
18
|
-
function NativeFunnelChart({ stages, width = 320, stageHeight = 38, baseline, isDark: isDarkProp, palette, style, onStagePress, }) {
|
|
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 } = (0, primitives_1.primitives)();
|
|
23
|
-
if (stages.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 stages to display" }) }));
|
|
25
|
-
}
|
|
26
|
-
const entry = baseline ?? stages[0]?.value ?? 1;
|
|
27
|
-
const widest = Math.max(entry, ...stages.map((s) => s.value)) || 1;
|
|
28
|
-
return ((0, jsx_runtime_1.jsx)(View, { style: [{ width }, style], children: stages.map((stage, i) => {
|
|
29
|
-
const previous = i === 0 ? null : stages[i - 1].value;
|
|
30
|
-
const stepRate = previous && previous > 0 ? stage.value / previous : null;
|
|
31
|
-
const share = entry > 0 ? stage.value / entry : 0;
|
|
32
|
-
const color = stage.color ?? (0, scales_1.seriesColor)(i, palette);
|
|
33
|
-
const widthPercent = Math.max(0.02, stage.value / widest);
|
|
34
|
-
return ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "button", accessibilityLabel: `${stage.label}: ${(0, scales_1.formatValue)(stage.value)}, ${Math.round(share * 100)} percent of entry`, onPress: () => {
|
|
35
|
-
setActive((current) => (current === i ? null : i));
|
|
36
|
-
onStagePress?.(i);
|
|
37
|
-
}, style: { marginBottom: i < stages.length - 1 ? 10 : 0 }, children: [(0, jsx_runtime_1.jsxs)(View, { style: { flexDirection: "row", justifyContent: "space-between", marginBottom: 4 }, children: [(0, jsx_runtime_1.jsx)(Text, { style: { color: theme.foreground, fontSize: 12, fontWeight: "500" }, children: stage.label }), (0, jsx_runtime_1.jsx)(Text, { style: { color: theme.muted, fontSize: 12 }, children: (0, scales_1.formatValue)(stage.value, { compact: true }) })] }), (0, jsx_runtime_1.jsx)(View, { style: {
|
|
38
|
-
height: stageHeight,
|
|
39
|
-
borderRadius: 10,
|
|
40
|
-
backgroundColor: isDark ? "rgba(235,235,245,0.08)" : "rgba(0,0,0,0.05)",
|
|
41
|
-
overflow: "hidden",
|
|
42
|
-
}, children: (0, jsx_runtime_1.jsx)(View, { style: {
|
|
43
|
-
width: `${widthPercent * 100}%`,
|
|
44
|
-
height: "100%",
|
|
45
|
-
borderRadius: 10,
|
|
46
|
-
backgroundColor: color,
|
|
47
|
-
opacity: active === null || active === i ? 1 : 0.5,
|
|
48
|
-
} }) }), (0, jsx_runtime_1.jsxs)(View, { style: { flexDirection: "row", gap: 10, marginTop: 3 }, children: [(0, jsx_runtime_1.jsxs)(Text, { style: { color: theme.muted, fontSize: 10 }, children: [Math.round(share * 100), "% of entry"] }), stepRate !== null && ((0, jsx_runtime_1.jsxs)(Text, { style: { color: theme.muted, fontSize: 10 }, children: [Math.round(stepRate * 100), "% from previous"] }))] })] }, stage.label));
|
|
49
|
-
}) }));
|
|
50
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NativeHeatmapChart = NativeHeatmapChart;
|
|
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
|
-
/** Parses "#rrggbb" into channels; anything else falls back to grey. */
|
|
11
|
-
function parseHex(hex) {
|
|
12
|
-
const match = /^#?([0-9a-f]{6})$/i.exec(hex);
|
|
13
|
-
if (!match)
|
|
14
|
-
return [128, 128, 128];
|
|
15
|
-
const int = parseInt(match[1], 16);
|
|
16
|
-
return [(int >> 16) & 255, (int >> 8) & 255, int & 255];
|
|
17
|
-
}
|
|
18
|
-
/** Linear blend between two hex colours, so a ramp needs no colour library. */
|
|
19
|
-
function mix(from, to, t) {
|
|
20
|
-
const a = parseHex(from);
|
|
21
|
-
const b = parseHex(to);
|
|
22
|
-
const clamped = Math.max(0, Math.min(1, t));
|
|
23
|
-
const channels = a.map((channel, i) => Math.round(channel + (b[i] - channel) * clamped));
|
|
24
|
-
return `rgb(${channels[0]}, ${channels[1]}, ${channels[2]})`;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* A grid where colour encodes magnitude.
|
|
28
|
-
*
|
|
29
|
-
* Cells are Views rather than SVG rects: the grid is uniform, so native layout
|
|
30
|
-
* positions it exactly and text stays crisp without vector text.
|
|
31
|
-
*/
|
|
32
|
-
function NativeHeatmapChart({ rows, columns, cellSize = 28, cellGap = 3, isDark: isDarkProp, minColor = "#e8eef7", maxColor = "#0088ff", style, onCellPress, }) {
|
|
33
|
-
const [active, setActive] = (0, react_1.useState)(null);
|
|
34
|
-
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
35
|
-
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
36
|
-
const { View, Text, Pressable } = (0, primitives_1.primitives)();
|
|
37
|
-
if (rows.length === 0 || columns.length === 0) {
|
|
38
|
-
return ((0, jsx_runtime_1.jsx)(View, { style: [{ alignItems: "center", paddingVertical: 20 }, style], children: (0, jsx_runtime_1.jsx)(Text, { style: { color: theme.muted, fontSize: 12 }, children: "No cells to display" }) }));
|
|
39
|
-
}
|
|
40
|
-
const all = rows.flatMap((row) => row.values).filter(Number.isFinite);
|
|
41
|
-
const min = all.length ? Math.min(...all) : 0;
|
|
42
|
-
const max = all.length ? Math.max(...all) : 1;
|
|
43
|
-
const span = max - min;
|
|
44
|
-
// A flat grid would otherwise tint every cell the same; centre it instead.
|
|
45
|
-
const position = (value) => (span === 0 ? 0.5 : (value - min) / span);
|
|
46
|
-
const labelWidth = 54;
|
|
47
|
-
return ((0, jsx_runtime_1.jsxs)(View, { style: style, children: [(0, jsx_runtime_1.jsx)(View, { style: { flexDirection: "row", marginLeft: labelWidth }, children: columns.map((column) => ((0, jsx_runtime_1.jsx)(View, { style: { width: cellSize + cellGap, alignItems: "center" }, children: (0, jsx_runtime_1.jsx)(Text, { style: { color: theme.muted, fontSize: 9 }, numberOfLines: 1, children: column }) }, column))) }), rows.map((row, r) => ((0, jsx_runtime_1.jsxs)(View, { style: { flexDirection: "row", alignItems: "center", marginTop: cellGap }, children: [(0, jsx_runtime_1.jsx)(View, { style: { width: labelWidth }, children: (0, jsx_runtime_1.jsx)(Text, { style: { color: theme.foreground, fontSize: 10 }, numberOfLines: 1, children: row.label }) }), columns.map((column, c) => {
|
|
48
|
-
const value = row.values[c];
|
|
49
|
-
const isActive = active?.r === r && active?.c === c;
|
|
50
|
-
const tint = value == null ? "transparent" : mix(minColor, maxColor, position(value));
|
|
51
|
-
return ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: `${row.label} ${column}: ${value == null ? "no data" : (0, scales_1.formatValue)(value)}`, onPress: () => {
|
|
52
|
-
if (value == null)
|
|
53
|
-
return;
|
|
54
|
-
setActive((current) => (current?.r === r && current?.c === c ? null : { r, c }));
|
|
55
|
-
onCellPress?.(r, c);
|
|
56
|
-
}, style: {
|
|
57
|
-
width: cellSize,
|
|
58
|
-
height: cellSize,
|
|
59
|
-
marginRight: cellGap,
|
|
60
|
-
borderRadius: 6,
|
|
61
|
-
backgroundColor: tint,
|
|
62
|
-
borderWidth: isActive ? 2 : 0,
|
|
63
|
-
borderColor: theme.foreground,
|
|
64
|
-
} }, column));
|
|
65
|
-
})] }, row.label))), (0, jsx_runtime_1.jsxs)(View, { style: { flexDirection: "row", alignItems: "center", marginTop: 10, marginLeft: labelWidth }, children: [(0, jsx_runtime_1.jsx)(Text, { style: { color: theme.muted, fontSize: 9, marginRight: 5 }, children: (0, scales_1.formatValue)(min, { compact: true }) }), (0, jsx_runtime_1.jsx)(View, { style: {
|
|
66
|
-
width: 70,
|
|
67
|
-
height: 6,
|
|
68
|
-
borderRadius: 3,
|
|
69
|
-
backgroundColor: mix(minColor, maxColor, 0.5),
|
|
70
|
-
} }), (0, jsx_runtime_1.jsx)(Text, { style: { color: theme.muted, fontSize: 9, marginLeft: 5 }, children: (0, scales_1.formatValue)(max, { compact: true }) })] }), active !== null && rows[active.r]?.values[active.c] != null && ((0, jsx_runtime_1.jsxs)(Text, { style: { color: theme.foreground, fontSize: 11, marginTop: 8, marginLeft: labelWidth }, children: [rows[active.r].label, " \u00B7 ", columns[active.c], ":", " ", (0, scales_1.formatValue)(rows[active.r].values[active.c])] }))] }));
|
|
71
|
-
}
|