glacia-native 0.5.2 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +84 -17
- package/lib/module/Accordion.js +58 -0
- package/lib/module/ActionSheet.js +38 -0
- package/lib/module/Alert.js +23 -0
- package/lib/module/AlertDialog.js +47 -0
- package/lib/module/Avatar.js +48 -0
- package/lib/module/Badge.js +36 -0
- package/lib/module/Bars.js +13 -268
- package/lib/module/Button.js +57 -39
- package/lib/module/Card.js +31 -19
- package/lib/module/Checkbox.js +42 -0
- package/lib/module/Chip.js +80 -0
- package/lib/module/Collapsible.js +26 -0
- package/lib/module/ContextMenu.js +33 -0
- package/lib/module/Dialog.js +39 -123
- package/lib/module/DropdownMenu.js +33 -0
- package/lib/module/Field.js +22 -0
- package/lib/module/Glass.js +10 -3
- package/lib/module/Group.js +36 -0
- package/lib/module/IconButton.js +40 -0
- package/lib/module/Input.js +43 -38
- package/lib/module/Label.js +17 -0
- package/lib/module/MorphGroup.js +47 -0
- package/lib/module/Popover.js +29 -0
- package/lib/module/Progress.js +32 -0
- package/lib/module/RadioGroup.js +51 -0
- package/lib/module/Scrim.js +44 -0
- package/lib/module/SegmentedControl.js +70 -63
- package/lib/module/Select.js +51 -0
- package/lib/module/Separator.js +25 -0
- package/lib/module/Sheet.js +51 -0
- package/lib/module/Skeleton.js +48 -0
- package/lib/module/Slider.js +45 -34
- package/lib/module/Stepper.js +167 -0
- package/lib/module/Switch.js +45 -55
- package/lib/module/TabBar.js +50 -44
- package/lib/module/Textarea.js +18 -0
- package/lib/module/Toast.js +55 -0
- package/lib/module/Toggle.js +47 -0
- package/lib/module/ToggleGroup.js +56 -0
- package/lib/module/Toolbar.js +37 -0
- package/lib/module/Tooltip.js +31 -0
- package/lib/module/glass-provider.js +28 -0
- package/lib/module/glass-stack.js +61 -0
- package/lib/module/index.js +78 -109
- package/lib/module/internal/GlassBackdrop.js +36 -0
- package/lib/module/internal/GlassView.js +43 -11
- package/lib/module/internal/blur-community.js +20 -0
- package/lib/module/internal/blur-community.web.js +9 -0
- package/lib/module/internal/blur.js +6 -9
- package/lib/module/internal/glass-routing.js +156 -30
- package/lib/module/internal/initials.js +12 -0
- package/lib/module/internal/overlay.js +147 -0
- package/lib/module/internal/primitives.js +16 -0
- package/lib/typescript/Accordion.d.ts +22 -0
- package/lib/typescript/ActionSheet.d.ts +24 -0
- package/lib/typescript/Alert.d.ts +15 -0
- package/lib/typescript/AlertDialog.d.ts +17 -0
- package/lib/typescript/Avatar.d.ts +22 -0
- package/lib/typescript/Badge.d.ts +12 -0
- package/lib/typescript/Bars.d.ts +3 -188
- package/lib/typescript/Button.d.ts +44 -10
- package/lib/typescript/Card.d.ts +30 -3
- package/lib/typescript/Checkbox.d.ts +14 -0
- package/lib/typescript/Chip.d.ts +19 -0
- package/lib/typescript/Collapsible.d.ts +17 -0
- package/lib/typescript/ContextMenu.d.ts +23 -0
- package/lib/typescript/Dialog.d.ts +8 -68
- package/lib/typescript/DropdownMenu.d.ts +23 -0
- package/lib/typescript/Field.d.ts +19 -0
- package/lib/typescript/Glass.d.ts +11 -2
- package/lib/typescript/Group.d.ts +35 -0
- package/lib/typescript/IconButton.d.ts +21 -0
- package/lib/typescript/Input.d.ts +17 -18
- package/lib/typescript/Label.d.ts +14 -0
- package/lib/typescript/MorphGroup.d.ts +46 -0
- package/lib/typescript/Popover.d.ts +17 -0
- package/lib/typescript/Progress.d.ts +13 -0
- package/lib/typescript/RadioGroup.d.ts +21 -0
- package/lib/typescript/Scrim.d.ts +33 -0
- package/lib/typescript/SegmentedControl.d.ts +24 -13
- package/lib/typescript/Select.d.ts +19 -0
- package/lib/typescript/Separator.d.ts +10 -0
- package/lib/typescript/Sheet.d.ts +45 -0
- package/lib/typescript/Skeleton.d.ts +10 -0
- package/lib/typescript/Slider.d.ts +15 -7
- package/lib/typescript/Stepper.d.ts +49 -0
- package/lib/typescript/Switch.d.ts +19 -12
- package/lib/typescript/TabBar.d.ts +18 -6
- package/lib/typescript/Textarea.d.ts +6 -0
- package/lib/typescript/Toast.d.ts +40 -0
- package/lib/typescript/Toggle.d.ts +21 -0
- package/lib/typescript/ToggleGroup.d.ts +22 -0
- package/lib/typescript/Toolbar.d.ts +35 -0
- package/lib/typescript/Tooltip.d.ts +16 -0
- package/lib/typescript/glass-provider.d.ts +34 -0
- package/lib/typescript/glass-stack.d.ts +54 -0
- package/lib/typescript/index.d.ts +38 -17
- package/lib/typescript/internal/GlassBackdrop.d.ts +33 -0
- package/lib/typescript/internal/GlassView.d.ts +18 -2
- package/lib/typescript/internal/blur-community.d.ts +2 -0
- package/lib/typescript/internal/blur-community.web.d.ts +2 -0
- package/lib/typescript/internal/glass-routing.d.ts +83 -15
- package/lib/typescript/internal/initials.d.ts +2 -0
- package/lib/typescript/internal/overlay.d.ts +74 -0
- package/lib/typescript/internal/primitives.d.ts +11 -0
- package/package.json +12 -10
- package/src/Accordion.tsx +165 -0
- package/src/ActionSheet.tsx +149 -0
- package/src/Alert.tsx +85 -0
- package/src/AlertDialog.tsx +124 -0
- package/src/Avatar.tsx +102 -0
- package/src/Badge.tsx +80 -0
- package/src/Bars.tsx +10 -807
- package/src/Button.tsx +196 -67
- package/src/Card.tsx +105 -32
- package/src/Checkbox.tsx +98 -0
- package/src/Chip.tsx +149 -0
- package/src/Collapsible.tsx +66 -0
- package/src/ContextMenu.tsx +103 -0
- package/src/Dialog.tsx +85 -335
- package/src/DropdownMenu.tsx +103 -0
- package/src/Field.tsx +65 -0
- package/src/Glass.tsx +15 -5
- package/src/Group.tsx +98 -0
- package/src/IconButton.tsx +110 -0
- package/src/Input.tsx +139 -87
- package/src/Label.tsx +56 -0
- package/src/MorphGroup.tsx +134 -0
- package/src/Popover.tsx +81 -0
- package/src/Progress.tsx +83 -0
- package/src/RadioGroup.tsx +122 -0
- package/src/Scrim.tsx +94 -0
- package/src/SegmentedControl.tsx +132 -99
- package/src/Select.tsx +136 -0
- package/src/Separator.tsx +52 -0
- package/src/Sheet.tsx +139 -0
- package/src/Skeleton.tsx +77 -0
- package/src/Slider.tsx +84 -47
- package/src/Stepper.tsx +315 -0
- package/src/Switch.tsx +81 -73
- package/src/TabBar.tsx +106 -93
- package/src/Textarea.tsx +34 -0
- package/src/Toast.tsx +131 -0
- package/src/Toggle.tsx +113 -0
- package/src/ToggleGroup.tsx +129 -0
- package/src/Toolbar.tsx +111 -0
- package/src/Tooltip.tsx +79 -0
- package/src/engine/CHANGELOG.md +430 -0
- package/src/engine/NOTICE +54 -0
- package/src/engine/README.md +975 -0
- package/src/engine/android/build.gradle +18 -0
- package/src/engine/android/src/main/AndroidManifest.xml +2 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/ExpoLiquidGlassModule.kt +174 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/GlassConstants.kt +7 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassContainerView.kt +16 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassProviderView.kt +165 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassView.kt +1731 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/enums/GlassEnums.kt +171 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/BackdropGraph.kt +146 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/BackdropSource.kt +53 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/ContinuousCorners.kt +188 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/CornerRadii.kt +62 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassAppearance.kt +352 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassDebug.kt +109 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassEnvironment.kt +139 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassHdr.kt +85 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassLuminanceProbe.kt +189 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassPressAnimator.kt +264 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassProgressiveBlur.kt +249 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassShaderCache.kt +256 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassShaderSource.kt +845 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassTier.kt +63 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/ProviderRegistry.kt +71 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/records/GlassRecords.kt +288 -0
- package/src/engine/index.ts +24 -0
- package/src/engine/ios/Enums/GlassBlurDirection.swift +21 -0
- package/src/engine/ios/Enums/GlassVariant.swift +86 -0
- package/src/engine/ios/ExpoLiquidGlass.podspec +93 -0
- package/src/engine/ios/ExpoLiquidGlassModule.swift +77 -0
- package/src/engine/ios/Glass/BackdropCapturer.swift +811 -0
- package/src/engine/ios/Glass/ContinuousCorners.swift +165 -0
- package/src/engine/ios/Glass/GlassBackdrop.swift +176 -0
- package/src/engine/ios/Glass/GlassFramePhase.swift +126 -0
- package/src/engine/ios/Glass/GlassFrameScheduler.swift +261 -0
- package/src/engine/ios/Glass/GlassPressAnimator.swift +250 -0
- package/src/engine/ios/Glass/GlassRenderContext.swift +168 -0
- package/src/engine/ios/Glass/GlassRenderer.swift +186 -0
- package/src/engine/ios/Glass/GlassSurfaceView.swift +452 -0
- package/src/engine/ios/Glass/NonRenderableView.swift +54 -0
- package/src/engine/ios/Glass/StripCache.swift +545 -0
- package/src/engine/ios/Records/GlassCornerRadii.swift +79 -0
- package/src/engine/ios/Records/GlassMetalOptions.swift +180 -0
- package/src/engine/ios/Records/GlassRefractionCurve.swift +14 -0
- package/src/engine/ios/Shaders/LiquidGlass.metal +480 -0
- package/src/engine/ios/Shaders/bundle-marker.txt +6 -0
- package/src/engine/ios/Views/LiquidGlassContainerView.swift +99 -0
- package/src/engine/ios/Views/LiquidGlassView.swift +859 -0
- package/src/engine/package.json +70 -0
- package/src/engine/src/components/LiquidGlassButton/LiquidGlassButton.tsx +424 -0
- package/src/engine/src/components/LiquidGlassCard/LiquidGlassCard.tsx +98 -0
- package/src/engine/src/components/LiquidGlassChip/LiquidGlassChip.tsx +65 -0
- package/src/engine/src/components/LiquidGlassGroup/LiquidGlassGroup.tsx +350 -0
- package/src/engine/src/components/LiquidGlassIconButton/LiquidGlassIconButton.tsx +24 -0
- package/src/engine/src/components/LiquidGlassMorphGroup/LiquidGlassMorphGroup.tsx +434 -0
- package/src/engine/src/components/LiquidGlassScrim/LiquidGlassScrim.tsx +100 -0
- package/src/engine/src/components/LiquidGlassSegmentedControl/LiquidGlassSegmentedControl.tsx +213 -0
- package/src/engine/src/components/LiquidGlassSheet/LiquidGlassSheet.tsx +218 -0
- package/src/engine/src/components/LiquidGlassSlider/LiquidGlassSlider.tsx +327 -0
- package/src/engine/src/components/LiquidGlassStepper/LiquidGlassStepper.tsx +321 -0
- package/src/engine/src/components/LiquidGlassSwitch/LiquidGlassSwitch.tsx +296 -0
- package/src/engine/src/components/LiquidGlassTabBar/LiquidGlassTabBar.tsx +952 -0
- package/src/engine/src/components/LiquidGlassTextInput/LiquidGlassTextInput.tsx +151 -0
- package/src/engine/src/components/LiquidGlassToast/LiquidGlassToast.tsx +169 -0
- package/src/engine/src/components/LiquidGlassToolbar/LiquidGlassToolbar.tsx +124 -0
- package/src/engine/src/components/index.ts +16 -0
- package/src/engine/src/constants/index.ts +4 -0
- package/src/engine/src/constants/metal.constants.ts +327 -0
- package/src/engine/src/constants/metrics.constants.ts +325 -0
- package/src/engine/src/constants/springs.constants.ts +107 -0
- package/src/engine/src/constants/styles.constants.ts +12 -0
- package/src/engine/src/context/glass-group.context.ts +65 -0
- package/src/engine/src/context/index.ts +6 -0
- package/src/engine/src/core/components/LiquidGlassContainer/LiquidGlassContainer.tsx +32 -0
- package/src/engine/src/core/components/LiquidGlassContainer/index.ts +1 -0
- package/src/engine/src/core/components/LiquidGlassProvider/LiquidGlassProvider.tsx +66 -0
- package/src/engine/src/core/components/LiquidGlassProvider/index.ts +1 -0
- package/src/engine/src/core/components/LiquidGlassStack/LiquidGlassStack.tsx +184 -0
- package/src/engine/src/core/components/LiquidGlassStack/index.ts +1 -0
- package/src/engine/src/core/components/LiquidGlassView/LiquidGlassView.tsx +126 -0
- package/src/engine/src/core/components/LiquidGlassView/index.ts +1 -0
- package/src/engine/src/core/components/index.ts +4 -0
- package/src/engine/src/core/constants/glass.constants.ts +57 -0
- package/src/engine/src/core/constants/index.ts +20 -0
- package/src/engine/src/core/constants/native.constants.ts +16 -0
- package/src/engine/src/core/context/glass-stack.context.ts +30 -0
- package/src/engine/src/core/context/index.ts +4 -0
- package/src/engine/src/core/enum/index.ts +12 -0
- package/src/engine/src/core/index.ts +1 -0
- package/src/engine/src/core/interfaces/glass-hdr.interface.ts +15 -0
- package/src/engine/src/core/interfaces/glass-metal.interface.ts +248 -0
- package/src/engine/src/core/interfaces/glass-surface.interface.ts +9 -0
- package/src/engine/src/core/interfaces/index.ts +31 -0
- package/src/engine/src/core/interfaces/liquid-glass-container.interface.ts +6 -0
- package/src/engine/src/core/interfaces/liquid-glass-provider.interface.ts +14 -0
- package/src/engine/src/core/interfaces/liquid-glass-stack.interface.ts +21 -0
- package/src/engine/src/core/interfaces/liquid-glass-view.interface.ts +129 -0
- package/src/engine/src/core/interfaces/native-liquid-glass-view.interface.ts +19 -0
- package/src/engine/src/core/modules/ExpoLiquidGlassModule.ts +26 -0
- package/src/engine/src/core/modules/index.ts +2 -0
- package/src/engine/src/core/root/index.ts +51 -0
- package/src/engine/src/core/types/glass.types.ts +25 -0
- package/src/engine/src/core/types/index.ts +8 -0
- package/src/engine/src/core/utils/debug.utils.ts +17 -0
- package/src/engine/src/core/utils/dev-warn.utils.ts +17 -0
- package/src/engine/src/core/utils/hdr.utils.ts +37 -0
- package/src/engine/src/core/utils/index.ts +5 -0
- package/src/engine/src/core/utils/native-view.utils.ts +33 -0
- package/src/engine/src/core/utils/platform.utils.ts +34 -0
- package/src/engine/src/core/views/NativeGlassBackdropView.ts +24 -0
- package/src/engine/src/core/views/NativeLiquidGlassContainerView.ts +13 -0
- package/src/engine/src/core/views/NativeLiquidGlassContainerView.web.ts +10 -0
- package/src/engine/src/core/views/NativeLiquidGlassProviderView.ts +13 -0
- package/src/engine/src/core/views/NativeLiquidGlassProviderView.web.ts +10 -0
- package/src/engine/src/core/views/NativeLiquidGlassView.ts +19 -0
- package/src/engine/src/core/views/NativeLiquidGlassView.web.ts +14 -0
- package/src/engine/src/core/views/index.ts +4 -0
- package/src/engine/src/hooks/index.ts +18 -0
- package/src/engine/src/hooks/use-adaptive-glass.ts +91 -0
- package/src/engine/src/hooks/use-damped-drag.ts +332 -0
- package/src/engine/src/hooks/use-echo-filter.ts +55 -0
- package/src/engine/src/hooks/use-glass-group-member.ts +169 -0
- package/src/engine/src/hooks/use-gravity-highlight.ts +79 -0
- package/src/engine/src/hooks/use-press-progress.ts +44 -0
- package/src/engine/src/index.ts +120 -0
- package/src/engine/src/interfaces/index.ts +28 -0
- package/src/engine/src/interfaces/liquid-glass-button.interface.ts +94 -0
- package/src/engine/src/interfaces/liquid-glass-card.interface.ts +40 -0
- package/src/engine/src/interfaces/liquid-glass-chip.interface.ts +29 -0
- package/src/engine/src/interfaces/liquid-glass-group.interface.ts +32 -0
- package/src/engine/src/interfaces/liquid-glass-icon-button.interface.ts +19 -0
- package/src/engine/src/interfaces/liquid-glass-morph-group.interface.ts +59 -0
- package/src/engine/src/interfaces/liquid-glass-scrim.interface.ts +36 -0
- package/src/engine/src/interfaces/liquid-glass-segmented-control.interface.ts +32 -0
- package/src/engine/src/interfaces/liquid-glass-sheet.interface.ts +38 -0
- package/src/engine/src/interfaces/liquid-glass-slider.interface.ts +37 -0
- package/src/engine/src/interfaces/liquid-glass-stepper.interface.ts +35 -0
- package/src/engine/src/interfaces/liquid-glass-switch.interface.ts +27 -0
- package/src/engine/src/interfaces/liquid-glass-tab-bar.interface.ts +116 -0
- package/src/engine/src/interfaces/liquid-glass-text-input.interface.ts +42 -0
- package/src/engine/src/interfaces/liquid-glass-toast.interface.ts +36 -0
- package/src/engine/src/interfaces/liquid-glass-toolbar.interface.ts +33 -0
- package/src/engine/src/theme/glass-ui-theme.ts +100 -0
- package/src/engine/src/theme/index.ts +2 -0
- package/src/engine/src/utils/button-press.utils.ts +63 -0
- package/src/engine/src/utils/index.ts +3 -0
- package/src/engine/src/utils/metal.utils.ts +164 -0
- package/src/glass-provider.tsx +60 -0
- package/src/glass-stack.tsx +115 -0
- package/src/index.ts +47 -190
- package/src/internal/GlassBackdrop.tsx +60 -0
- package/src/internal/GlassView.tsx +53 -18
- package/src/internal/blur-community.ts +19 -0
- package/src/internal/blur-community.web.ts +7 -0
- package/src/internal/blur.ts +7 -8
- package/src/internal/glass-routing.ts +212 -34
- package/src/internal/initials.ts +7 -0
- package/src/internal/overlay.tsx +258 -0
- package/src/internal/primitives.ts +23 -0
- package/lib/module/Carousel.js +0 -103
- package/lib/module/Display.js +0 -318
- package/lib/module/Feedback.js +0 -395
- package/lib/module/Form.js +0 -160
- package/lib/module/Forms2.js +0 -471
- package/lib/module/Message.js +0 -84
- package/lib/module/Overlays.js +0 -344
- package/lib/module/Pickers.js +0 -243
- package/lib/module/Table.js +0 -100
- package/lib/module/ai.js +0 -283
- package/lib/module/charts/AreaChart.js +0 -32
- package/lib/module/charts/BarChart.js +0 -75
- package/lib/module/charts/FunnelChart.js +0 -50
- package/lib/module/charts/HeatmapChart.js +0 -71
- package/lib/module/charts/LineChart.js +0 -81
- package/lib/module/charts/PlotChart.js +0 -52
- package/lib/module/charts/RadarChart.js +0 -78
- package/lib/module/charts/RingChart.js +0 -52
- package/lib/module/charts/ScatterChart.js +0 -95
- package/lib/module/charts/WaterfallChart.js +0 -85
- package/lib/module/charts/advanced.js +0 -313
- package/lib/module/charts/extra.js +0 -108
- package/lib/module/charts/index.js +0 -50
- package/lib/module/charts/scales.js +0 -140
- package/lib/typescript/Carousel.d.ts +0 -47
- package/lib/typescript/Display.d.ts +0 -178
- package/lib/typescript/Feedback.d.ts +0 -196
- package/lib/typescript/Form.d.ts +0 -97
- package/lib/typescript/Forms2.d.ts +0 -209
- package/lib/typescript/Message.d.ts +0 -67
- package/lib/typescript/Overlays.d.ts +0 -146
- package/lib/typescript/Pickers.d.ts +0 -105
- package/lib/typescript/Table.d.ts +0 -64
- package/lib/typescript/ai.d.ts +0 -166
- package/lib/typescript/charts/AreaChart.d.ts +0 -44
- package/lib/typescript/charts/BarChart.d.ts +0 -19
- package/lib/typescript/charts/FunnelChart.d.ts +0 -25
- package/lib/typescript/charts/HeatmapChart.d.ts +0 -23
- package/lib/typescript/charts/LineChart.d.ts +0 -30
- package/lib/typescript/charts/PlotChart.d.ts +0 -31
- package/lib/typescript/charts/RadarChart.d.ts +0 -27
- package/lib/typescript/charts/RingChart.d.ts +0 -28
- package/lib/typescript/charts/ScatterChart.d.ts +0 -34
- package/lib/typescript/charts/WaterfallChart.d.ts +0 -22
- package/lib/typescript/charts/advanced.d.ts +0 -107
- package/lib/typescript/charts/extra.d.ts +0 -63
- package/lib/typescript/charts/index.d.ts +0 -13
- package/lib/typescript/charts/scales.d.ts +0 -35
- package/src/Carousel.tsx +0 -233
- package/src/Display.tsx +0 -781
- package/src/Feedback.tsx +0 -992
- package/src/Form.tsx +0 -445
- package/src/Forms2.tsx +0 -1055
- package/src/Message.tsx +0 -218
- package/src/Overlays.tsx +0 -704
- package/src/Pickers.tsx +0 -595
- package/src/Table.tsx +0 -232
- package/src/ai.tsx +0 -715
- package/src/charts/AreaChart.tsx +0 -73
- package/src/charts/BarChart.tsx +0 -221
- package/src/charts/FunnelChart.tsx +0 -125
- package/src/charts/HeatmapChart.tsx +0 -155
- package/src/charts/LineChart.tsx +0 -247
- package/src/charts/PlotChart.tsx +0 -168
- package/src/charts/RadarChart.tsx +0 -208
- package/src/charts/RingChart.tsx +0 -133
- package/src/charts/ScatterChart.tsx +0 -223
- package/src/charts/WaterfallChart.tsx +0 -201
- package/src/charts/advanced.tsx +0 -676
- package/src/charts/extra.tsx +0 -242
- package/src/charts/index.ts +0 -86
- package/src/charts/scales.ts +0 -163
package/src/Display.tsx
DELETED
|
@@ -1,781 +0,0 @@
|
|
|
1
|
-
import { forwardRef, useEffect, useRef, useState, type ReactNode } from "react";
|
|
2
|
-
import type { StyleProp, ViewStyle } from "react-native";
|
|
3
|
-
|
|
4
|
-
import { Glass } from "./Glass";
|
|
5
|
-
import { colors, controlSizes, radii } from "./internal/tokens";
|
|
6
|
-
import { primitives } from "./internal/primitives";
|
|
7
|
-
import { useIsDark, useSpring } from "./internal/motion";
|
|
8
|
-
|
|
9
|
-
// ---------------------------------------------------------------------------
|
|
10
|
-
// Avatar
|
|
11
|
-
|
|
12
|
-
export type AvatarSize = "sm" | "md" | "lg";
|
|
13
|
-
|
|
14
|
-
export interface AvatarProps {
|
|
15
|
-
/** Image to show. When absent, or when it fails to load, initials render. */
|
|
16
|
-
source?: { uri: string } | number;
|
|
17
|
-
/** The person's name: initials are derived from it when no image loads. */
|
|
18
|
-
name?: string;
|
|
19
|
-
size?: AvatarSize;
|
|
20
|
-
/** Draws a status dot in the corner. */
|
|
21
|
-
status?: "online" | "offline" | "busy";
|
|
22
|
-
style?: StyleProp<ViewStyle>;
|
|
23
|
-
isDark?: boolean;
|
|
24
|
-
testID?: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const avatarSizes: Record<AvatarSize, number> = { sm: 28, md: 40, lg: 64 };
|
|
28
|
-
|
|
29
|
-
/** First letters of the first and last word, as an avatar fallback. */
|
|
30
|
-
export function initialsOf(name: string): string {
|
|
31
|
-
const words = name.trim().split(/\s+/).filter(Boolean);
|
|
32
|
-
if (words.length === 0) return "";
|
|
33
|
-
if (words.length === 1) return words[0]!.slice(0, 2).toUpperCase();
|
|
34
|
-
return (words[0]![0]! + words[words.length - 1]![0]!).toUpperCase();
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* A person or entity: their picture, or their initials when there is none.
|
|
39
|
-
*
|
|
40
|
-
* The frame is Glacia's glass so it belongs to the same family as the rest of
|
|
41
|
-
* the library; the initials sit on it in the theme's foreground colour.
|
|
42
|
-
*/
|
|
43
|
-
export const Avatar = forwardRef<any, AvatarProps>(function Avatar(
|
|
44
|
-
{ source, name, size = "md", status, style, isDark: isDarkProp, testID, ...props },
|
|
45
|
-
ref,
|
|
46
|
-
) {
|
|
47
|
-
const isDark = useIsDark(isDarkProp);
|
|
48
|
-
const theme = isDark ? colors.dark : colors.light;
|
|
49
|
-
const { View, Text, Image } = primitives();
|
|
50
|
-
|
|
51
|
-
// A broken remote image falls back to initials rather than an empty circle.
|
|
52
|
-
const [failed, setFailed] = useState(false);
|
|
53
|
-
const dimension = avatarSizes[size];
|
|
54
|
-
const initials = name ? initialsOf(name) : "";
|
|
55
|
-
|
|
56
|
-
const statusColor =
|
|
57
|
-
status === "online" ? theme.on : status === "busy" ? theme.destructive : theme.muted;
|
|
58
|
-
const dot = Math.max(8, Math.round(dimension * 0.26));
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<View
|
|
62
|
-
ref={ref}
|
|
63
|
-
testID={testID}
|
|
64
|
-
accessible
|
|
65
|
-
accessibilityRole="image"
|
|
66
|
-
accessibilityLabel={name ? `Avatar of ${name}` : "Avatar"}
|
|
67
|
-
style={{ width: dimension, height: dimension, ...(style as ViewStyle) }}
|
|
68
|
-
{...props}
|
|
69
|
-
>
|
|
70
|
-
<Glass
|
|
71
|
-
effect="regular"
|
|
72
|
-
surface="panel"
|
|
73
|
-
isDark={isDark}
|
|
74
|
-
style={{
|
|
75
|
-
width: dimension,
|
|
76
|
-
height: dimension,
|
|
77
|
-
borderRadius: dimension / 2,
|
|
78
|
-
alignItems: "center",
|
|
79
|
-
justifyContent: "center",
|
|
80
|
-
overflow: "hidden",
|
|
81
|
-
}}
|
|
82
|
-
>
|
|
83
|
-
{source && !failed ? (
|
|
84
|
-
<Image
|
|
85
|
-
source={source}
|
|
86
|
-
accessibilityLabel={name ?? "Avatar"}
|
|
87
|
-
onError={() => setFailed(true)}
|
|
88
|
-
style={{ width: dimension, height: dimension }}
|
|
89
|
-
/>
|
|
90
|
-
) : (
|
|
91
|
-
<Text
|
|
92
|
-
style={{
|
|
93
|
-
fontSize: Math.round(dimension * 0.38),
|
|
94
|
-
fontWeight: "600",
|
|
95
|
-
color: theme.foreground,
|
|
96
|
-
}}
|
|
97
|
-
>
|
|
98
|
-
{initials}
|
|
99
|
-
</Text>
|
|
100
|
-
)}
|
|
101
|
-
</Glass>
|
|
102
|
-
|
|
103
|
-
{status && (
|
|
104
|
-
<View
|
|
105
|
-
style={{
|
|
106
|
-
position: "absolute",
|
|
107
|
-
right: 0,
|
|
108
|
-
bottom: 0,
|
|
109
|
-
width: dot,
|
|
110
|
-
height: dot,
|
|
111
|
-
borderRadius: dot / 2,
|
|
112
|
-
backgroundColor: statusColor,
|
|
113
|
-
borderWidth: 1.5,
|
|
114
|
-
borderColor: theme.glassActive,
|
|
115
|
-
}}
|
|
116
|
-
/>
|
|
117
|
-
)}
|
|
118
|
-
</View>
|
|
119
|
-
);
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
// ---------------------------------------------------------------------------
|
|
123
|
-
// Badge
|
|
124
|
-
|
|
125
|
-
export interface BadgeProps {
|
|
126
|
-
/** The count or short label. Omit to render a plain dot. */
|
|
127
|
-
children?: ReactNode;
|
|
128
|
-
/** Draws the badge in the destructive tone (unread, errors). */
|
|
129
|
-
tone?: "fill" | "destructive" | "success" | "muted";
|
|
130
|
-
/** The element to overlay. Supplying it puts the badge in the corner. */
|
|
131
|
-
overlay?: ReactNode;
|
|
132
|
-
style?: StyleProp<ViewStyle>;
|
|
133
|
-
isDark?: boolean;
|
|
134
|
-
testID?: string;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* A small count or dot.
|
|
139
|
-
*
|
|
140
|
-
* Deliberately not glass: a badge is a micro-element, and a translucent 16pt
|
|
141
|
-
* chip loses its contrast against whatever it sits on. It uses the solid theme
|
|
142
|
-
* tint instead, which is what makes it legible in both themes.
|
|
143
|
-
*/
|
|
144
|
-
export const Badge = forwardRef<any, BadgeProps>(function Badge(
|
|
145
|
-
{ children, tone = "fill", overlay, style, isDark: isDarkProp, testID, ...props },
|
|
146
|
-
ref,
|
|
147
|
-
) {
|
|
148
|
-
const isDark = useIsDark(isDarkProp);
|
|
149
|
-
const theme = isDark ? colors.dark : colors.light;
|
|
150
|
-
const { View, Text } = primitives();
|
|
151
|
-
|
|
152
|
-
const background =
|
|
153
|
-
tone === "destructive"
|
|
154
|
-
? theme.destructive
|
|
155
|
-
: tone === "success"
|
|
156
|
-
? theme.on
|
|
157
|
-
: tone === "muted"
|
|
158
|
-
? theme.muted
|
|
159
|
-
: theme.fill;
|
|
160
|
-
|
|
161
|
-
const isDot = children == null;
|
|
162
|
-
// The web badge is 24 tall with 10 of horizontal padding and 12/500 type.
|
|
163
|
-
const height = isDot ? 10 : 24;
|
|
164
|
-
|
|
165
|
-
const badge = (
|
|
166
|
-
<View
|
|
167
|
-
ref={ref}
|
|
168
|
-
testID={testID}
|
|
169
|
-
accessibilityRole="text"
|
|
170
|
-
accessibilityLabel={isDot ? undefined : String(children)}
|
|
171
|
-
style={{
|
|
172
|
-
minWidth: height,
|
|
173
|
-
height,
|
|
174
|
-
borderRadius: height / 2,
|
|
175
|
-
paddingHorizontal: isDot ? 0 : 10,
|
|
176
|
-
alignItems: "center",
|
|
177
|
-
justifyContent: "center",
|
|
178
|
-
backgroundColor: background,
|
|
179
|
-
...(style as ViewStyle),
|
|
180
|
-
}}
|
|
181
|
-
{...props}
|
|
182
|
-
>
|
|
183
|
-
{!isDot && (
|
|
184
|
-
<Text style={{ fontSize: 12, fontWeight: "500", color: theme.onTint }} numberOfLines={1}>
|
|
185
|
-
{children}
|
|
186
|
-
</Text>
|
|
187
|
-
)}
|
|
188
|
-
</View>
|
|
189
|
-
);
|
|
190
|
-
|
|
191
|
-
if (overlay === undefined) return badge;
|
|
192
|
-
|
|
193
|
-
// Overlaid: the badge floats at the top-right of whatever it decorates, which
|
|
194
|
-
// needs a positioned box around the child rather than a bare fragment.
|
|
195
|
-
return (
|
|
196
|
-
<View style={{ alignSelf: "flex-start" }}>
|
|
197
|
-
{overlay}
|
|
198
|
-
<View style={{ position: "absolute", top: -4, right: -4 }}>{badge}</View>
|
|
199
|
-
</View>
|
|
200
|
-
);
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
// ---------------------------------------------------------------------------
|
|
204
|
-
// Separator
|
|
205
|
-
|
|
206
|
-
export interface SeparatorProps {
|
|
207
|
-
orientation?: "horizontal" | "vertical";
|
|
208
|
-
/** Inset from the leading edge, matching a list row's leading accessory. */
|
|
209
|
-
inset?: number;
|
|
210
|
-
style?: StyleProp<ViewStyle>;
|
|
211
|
-
isDark?: boolean;
|
|
212
|
-
testID?: string;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* A hairline divider in the theme's separator colour.
|
|
217
|
-
*
|
|
218
|
-
* A plain View rather than a Glass: a 1pt rule is not a surface, and glass on
|
|
219
|
-
* a line has nothing to refract.
|
|
220
|
-
*/
|
|
221
|
-
export const Separator = forwardRef<any, SeparatorProps>(function Separator(
|
|
222
|
-
{ orientation = "horizontal", inset = 0, style, isDark: isDarkProp, testID, ...props },
|
|
223
|
-
ref,
|
|
224
|
-
) {
|
|
225
|
-
const isDark = useIsDark(isDarkProp);
|
|
226
|
-
const theme = isDark ? colors.dark : colors.light;
|
|
227
|
-
const { View } = primitives();
|
|
228
|
-
|
|
229
|
-
const separatorStyle: ViewStyle =
|
|
230
|
-
orientation === "horizontal"
|
|
231
|
-
? { height: 1, alignSelf: "stretch", marginLeft: inset, backgroundColor: theme.separator }
|
|
232
|
-
: { width: 1, alignSelf: "stretch", backgroundColor: theme.separator };
|
|
233
|
-
|
|
234
|
-
return (
|
|
235
|
-
<View
|
|
236
|
-
ref={ref}
|
|
237
|
-
testID={testID}
|
|
238
|
-
accessibilityRole="none"
|
|
239
|
-
style={{ ...separatorStyle, ...(style as ViewStyle) }}
|
|
240
|
-
{...props}
|
|
241
|
-
/>
|
|
242
|
-
);
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
// ---------------------------------------------------------------------------
|
|
246
|
-
// Skeleton
|
|
247
|
-
|
|
248
|
-
export interface SkeletonProps {
|
|
249
|
-
/** Rectangles for cards and rows, circles for avatars, lines for a run of text. */
|
|
250
|
-
shape?: "rect" | "circle" | "line";
|
|
251
|
-
width?: number | string;
|
|
252
|
-
height?: number;
|
|
253
|
-
style?: StyleProp<ViewStyle>;
|
|
254
|
-
isDark?: boolean;
|
|
255
|
-
testID?: string;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* A loading placeholder.
|
|
260
|
-
*
|
|
261
|
-
* The pulse is opacity only and slow, on the gentle spring, so it reads as
|
|
262
|
-
* "loading" without motion that could bother someone sensitive to movement.
|
|
263
|
-
* Nothing about it is essential to understanding the screen, so it is hidden
|
|
264
|
-
* from screen readers rather than announced.
|
|
265
|
-
*/
|
|
266
|
-
export const Skeleton = forwardRef<any, SkeletonProps>(function Skeleton(
|
|
267
|
-
{ shape = "rect", width, height, style, isDark: isDarkProp, testID, ...props },
|
|
268
|
-
ref,
|
|
269
|
-
) {
|
|
270
|
-
const isDark = useIsDark(isDarkProp);
|
|
271
|
-
const theme = isDark ? colors.dark : colors.light;
|
|
272
|
-
const { View, Animated } = primitives();
|
|
273
|
-
|
|
274
|
-
const { value: pulse, animated } = useSpring(1, "gentle");
|
|
275
|
-
const opacity = animated
|
|
276
|
-
? pulse.interpolate({ inputRange: [0, 1], outputRange: [0.35, 1] })
|
|
277
|
-
: 1;
|
|
278
|
-
|
|
279
|
-
const resolvedWidth = width ?? (shape === "line" ? "100%" : shape === "circle" ? 40 : 120);
|
|
280
|
-
const resolvedHeight = height ?? (shape === "line" ? 12 : shape === "circle" ? 40 : 80);
|
|
281
|
-
const radius =
|
|
282
|
-
shape === "circle" ? Math.min(resolvedHeight, 9999) / 2 : shape === "line" ? radii.sm : radii.md;
|
|
283
|
-
|
|
284
|
-
const skeletonStyle: ViewStyle = {
|
|
285
|
-
width: resolvedWidth as any,
|
|
286
|
-
height: resolvedHeight,
|
|
287
|
-
borderRadius: radius,
|
|
288
|
-
backgroundColor: theme.skeleton,
|
|
289
|
-
...(style as ViewStyle),
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
const a11y = { accessibilityRole: "none" as const, accessible: false, testID };
|
|
293
|
-
|
|
294
|
-
return animated ? (
|
|
295
|
-
<Animated.View ref={ref} style={{ ...skeletonStyle, opacity }} {...a11y} {...props} />
|
|
296
|
-
) : (
|
|
297
|
-
<View ref={ref} style={skeletonStyle} {...a11y} {...props} />
|
|
298
|
-
);
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
// ---------------------------------------------------------------------------
|
|
302
|
-
// Spinner
|
|
303
|
-
|
|
304
|
-
export type SpinnerSize = "sm" | "md" | "lg";
|
|
305
|
-
|
|
306
|
-
export interface SpinnerProps {
|
|
307
|
-
size?: SpinnerSize;
|
|
308
|
-
/** Spinner colour; defaults to the theme's muted foreground. */
|
|
309
|
-
tint?: string;
|
|
310
|
-
/** Announced to screen readers, since a spinner alone has no text. */
|
|
311
|
-
accessibilityLabel?: string;
|
|
312
|
-
style?: StyleProp<ViewStyle>;
|
|
313
|
-
isDark?: boolean;
|
|
314
|
-
testID?: string;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
const spinnerSizes: Record<SpinnerSize, number> = { sm: 16, md: 22, lg: 32 };
|
|
318
|
-
|
|
319
|
-
/**
|
|
320
|
-
* A loading spinner, drawn by Glacia.
|
|
321
|
-
*
|
|
322
|
-
* An SVG arc that rotates on the gentle spring through Animated — not the
|
|
323
|
-
* platform's ActivityIndicator, so it looks the same on every platform and
|
|
324
|
-
* wears the theme's colour instead of inheriting the system tint.
|
|
325
|
-
*/
|
|
326
|
-
export const Spinner = forwardRef<any, SpinnerProps>(function Spinner(
|
|
327
|
-
{
|
|
328
|
-
size = "md",
|
|
329
|
-
tint,
|
|
330
|
-
accessibilityLabel = "Loading",
|
|
331
|
-
style,
|
|
332
|
-
isDark: isDarkProp,
|
|
333
|
-
testID,
|
|
334
|
-
...props
|
|
335
|
-
},
|
|
336
|
-
ref,
|
|
337
|
-
) {
|
|
338
|
-
const isDark = useIsDark(isDarkProp);
|
|
339
|
-
const theme = isDark ? colors.dark : colors.light;
|
|
340
|
-
const { View, Svg, Circle, Animated } = primitives();
|
|
341
|
-
|
|
342
|
-
const dimension = spinnerSizes[size];
|
|
343
|
-
const stroke = Math.max(2, Math.round(dimension / 9));
|
|
344
|
-
const color = tint ?? theme.muted;
|
|
345
|
-
// An arc, not a full ring: a complete circle rotating looks static.
|
|
346
|
-
const circumference = 2 * Math.PI * ((dimension - stroke) / 2);
|
|
347
|
-
const dash = circumference * 0.28;
|
|
348
|
-
|
|
349
|
-
// A continuous spin never settles, so it is driven by Animated.timing on a
|
|
350
|
-
// loop rather than the spring hook, which is built for one-off targets.
|
|
351
|
-
const { Animated: AnimatedAPI, isNative } = primitives();
|
|
352
|
-
const spinning = isNative && Boolean(AnimatedAPI?.timing);
|
|
353
|
-
|
|
354
|
-
const rotation = useRef<any>(null);
|
|
355
|
-
if (rotation.current === null) {
|
|
356
|
-
rotation.current = spinning ? new AnimatedAPI.Value(0) : null;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
useEffect(() => {
|
|
360
|
-
if (!spinning || !rotation.current) return;
|
|
361
|
-
rotation.current.setValue(0);
|
|
362
|
-
const loop = AnimatedAPI.loop(
|
|
363
|
-
AnimatedAPI.timing(rotation.current, {
|
|
364
|
-
toValue: 1,
|
|
365
|
-
duration: 900,
|
|
366
|
-
useNativeDriver: true,
|
|
367
|
-
}),
|
|
368
|
-
);
|
|
369
|
-
loop.start?.();
|
|
370
|
-
return () => loop.stop?.();
|
|
371
|
-
}, [AnimatedAPI, spinning]);
|
|
372
|
-
|
|
373
|
-
const spinStyle = spinning
|
|
374
|
-
? {
|
|
375
|
-
transform: [
|
|
376
|
-
{
|
|
377
|
-
rotate: rotation.current.interpolate({
|
|
378
|
-
inputRange: [0, 1],
|
|
379
|
-
outputRange: ["0deg", "360deg"],
|
|
380
|
-
}),
|
|
381
|
-
},
|
|
382
|
-
],
|
|
383
|
-
}
|
|
384
|
-
: undefined;
|
|
385
|
-
|
|
386
|
-
const svg = (
|
|
387
|
-
<Svg width={dimension} height={dimension} viewBox={`0 0 ${dimension} ${dimension}`}>
|
|
388
|
-
<Circle
|
|
389
|
-
cx={dimension / 2}
|
|
390
|
-
cy={dimension / 2}
|
|
391
|
-
r={(dimension - stroke) / 2}
|
|
392
|
-
stroke={theme.skeleton}
|
|
393
|
-
strokeWidth={stroke}
|
|
394
|
-
fill="none"
|
|
395
|
-
/>
|
|
396
|
-
<Circle
|
|
397
|
-
cx={dimension / 2}
|
|
398
|
-
cy={dimension / 2}
|
|
399
|
-
r={(dimension - stroke) / 2}
|
|
400
|
-
stroke={color}
|
|
401
|
-
strokeWidth={stroke}
|
|
402
|
-
fill="none"
|
|
403
|
-
strokeLinecap="round"
|
|
404
|
-
strokeDasharray={`${dash} ${circumference - dash}`}
|
|
405
|
-
/>
|
|
406
|
-
</Svg>
|
|
407
|
-
);
|
|
408
|
-
|
|
409
|
-
return (
|
|
410
|
-
<View
|
|
411
|
-
ref={ref}
|
|
412
|
-
testID={testID}
|
|
413
|
-
accessibilityRole="progressbar"
|
|
414
|
-
accessibilityLabel={accessibilityLabel}
|
|
415
|
-
style={[{ width: dimension, height: dimension }, style as ViewStyle]}
|
|
416
|
-
{...props}
|
|
417
|
-
>
|
|
418
|
-
{spinning ? <Animated.View style={spinStyle}>{svg}</Animated.View> : svg}
|
|
419
|
-
</View>
|
|
420
|
-
);
|
|
421
|
-
});
|
|
422
|
-
|
|
423
|
-
// ---------------------------------------------------------------------------
|
|
424
|
-
// Progress
|
|
425
|
-
|
|
426
|
-
export type ProgressVariant = "bar" | "ring";
|
|
427
|
-
|
|
428
|
-
export interface ProgressProps {
|
|
429
|
-
/** 0–100. Values outside the range are clamped rather than drawn wrong. */
|
|
430
|
-
value: number;
|
|
431
|
-
variant?: ProgressVariant;
|
|
432
|
-
/** Overrides the fill colour; defaults to the theme accent. */
|
|
433
|
-
tint?: string;
|
|
434
|
-
/** Announced by screen readers, e.g. "Uploading photo". */
|
|
435
|
-
accessibilityLabel?: string;
|
|
436
|
-
style?: StyleProp<ViewStyle>;
|
|
437
|
-
isDark?: boolean;
|
|
438
|
-
testID?: string;
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
const RING = 64;
|
|
442
|
-
|
|
443
|
-
/**
|
|
444
|
-
* Progress, linear or circular.
|
|
445
|
-
*
|
|
446
|
-
* The track is a glass surface, so it refracts what it sits on exactly like the
|
|
447
|
-
* rest of the library; the fill is the theme accent. Both forms report
|
|
448
|
-
* `progressbar` with a value, which is the contract NativeTask relies on
|
|
449
|
-
* internally — this component generalises it.
|
|
450
|
-
*/
|
|
451
|
-
export const Progress = forwardRef<any, ProgressProps>(function Progress(
|
|
452
|
-
{
|
|
453
|
-
value,
|
|
454
|
-
variant = "bar",
|
|
455
|
-
tint,
|
|
456
|
-
accessibilityLabel,
|
|
457
|
-
style,
|
|
458
|
-
isDark: isDarkProp,
|
|
459
|
-
testID,
|
|
460
|
-
...props
|
|
461
|
-
},
|
|
462
|
-
ref,
|
|
463
|
-
) {
|
|
464
|
-
const isDark = useIsDark(isDarkProp);
|
|
465
|
-
const theme = isDark ? colors.dark : colors.light;
|
|
466
|
-
const { View, Text, Svg, Circle } = primitives();
|
|
467
|
-
|
|
468
|
-
const clamped = Math.min(Math.max(value, 0), 100);
|
|
469
|
-
const fill = tint ?? theme.fill;
|
|
470
|
-
const a11y = {
|
|
471
|
-
accessibilityRole: "progressbar" as const,
|
|
472
|
-
accessibilityValue: { min: 0, max: 100, now: Math.round(clamped) },
|
|
473
|
-
accessibilityLabel,
|
|
474
|
-
testID,
|
|
475
|
-
};
|
|
476
|
-
|
|
477
|
-
if (variant === "ring") {
|
|
478
|
-
const stroke = 6;
|
|
479
|
-
const radius = (RING - stroke) / 2;
|
|
480
|
-
const circumference = 2 * Math.PI * radius;
|
|
481
|
-
return (
|
|
482
|
-
<View
|
|
483
|
-
ref={ref}
|
|
484
|
-
style={[{ width: RING, height: RING }, style as ViewStyle]}
|
|
485
|
-
{...a11y}
|
|
486
|
-
{...props}
|
|
487
|
-
>
|
|
488
|
-
<Svg width={RING} height={RING} viewBox={`0 0 ${RING} ${RING}`}>
|
|
489
|
-
<Circle
|
|
490
|
-
cx={RING / 2}
|
|
491
|
-
cy={RING / 2}
|
|
492
|
-
r={radius}
|
|
493
|
-
stroke={theme.skeleton}
|
|
494
|
-
strokeWidth={stroke}
|
|
495
|
-
fill="none"
|
|
496
|
-
/>
|
|
497
|
-
<Circle
|
|
498
|
-
cx={RING / 2}
|
|
499
|
-
cy={RING / 2}
|
|
500
|
-
r={radius}
|
|
501
|
-
stroke={fill}
|
|
502
|
-
strokeWidth={stroke}
|
|
503
|
-
fill="none"
|
|
504
|
-
strokeLinecap="round"
|
|
505
|
-
strokeDasharray={`${(clamped / 100) * circumference} ${circumference}`}
|
|
506
|
-
// Start the arc at twelve o'clock, the way progress dials read.
|
|
507
|
-
transform={`rotate(-90 ${RING / 2} ${RING / 2})`}
|
|
508
|
-
/>
|
|
509
|
-
</Svg>
|
|
510
|
-
<View
|
|
511
|
-
style={{
|
|
512
|
-
position: "absolute",
|
|
513
|
-
width: RING,
|
|
514
|
-
height: RING,
|
|
515
|
-
alignItems: "center",
|
|
516
|
-
justifyContent: "center",
|
|
517
|
-
}}
|
|
518
|
-
>
|
|
519
|
-
<Text style={{ fontSize: 13, fontWeight: "600", color: theme.foreground }}>
|
|
520
|
-
{`${Math.round(clamped)}%`}
|
|
521
|
-
</Text>
|
|
522
|
-
</View>
|
|
523
|
-
</View>
|
|
524
|
-
);
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
return (
|
|
528
|
-
<Glass
|
|
529
|
-
ref={ref}
|
|
530
|
-
effect="regular"
|
|
531
|
-
surface="rail"
|
|
532
|
-
isDark={isDark}
|
|
533
|
-
style={{
|
|
534
|
-
height: 8,
|
|
535
|
-
borderRadius: radii.pill,
|
|
536
|
-
overflow: "hidden",
|
|
537
|
-
justifyContent: "center",
|
|
538
|
-
...(style as ViewStyle),
|
|
539
|
-
}}
|
|
540
|
-
{...a11y}
|
|
541
|
-
{...props}
|
|
542
|
-
>
|
|
543
|
-
<View
|
|
544
|
-
style={{
|
|
545
|
-
width: `${clamped}%`,
|
|
546
|
-
height: 8,
|
|
547
|
-
borderRadius: radii.pill,
|
|
548
|
-
backgroundColor: fill,
|
|
549
|
-
}}
|
|
550
|
-
/>
|
|
551
|
-
</Glass>
|
|
552
|
-
);
|
|
553
|
-
});
|
|
554
|
-
|
|
555
|
-
// ---------------------------------------------------------------------------
|
|
556
|
-
// Rating
|
|
557
|
-
|
|
558
|
-
/** The five-pointed star, as a path in a unit box. */
|
|
559
|
-
const STAR_PATH =
|
|
560
|
-
"M12 2.4l2.95 5.98 6.6.96-4.78 4.66 1.13 6.57L12 17.46l-5.9 3.11 1.13-6.57L2.45 9.34l6.6-.96z";
|
|
561
|
-
|
|
562
|
-
export interface RatingProps {
|
|
563
|
-
/** How many stars are filled. Fractions render a partially filled star. */
|
|
564
|
-
value: number;
|
|
565
|
-
/** The number of stars. Defaults to five. */
|
|
566
|
-
max?: number;
|
|
567
|
-
size?: "sm" | "md" | "lg";
|
|
568
|
-
/** Makes the stars tappable. Omit for a read-only rating. */
|
|
569
|
-
onChange?: (value: number) => void;
|
|
570
|
-
disabled?: boolean;
|
|
571
|
-
/** The accessible name, e.g. "Rating". */
|
|
572
|
-
accessibilityLabel?: string;
|
|
573
|
-
style?: StyleProp<ViewStyle>;
|
|
574
|
-
isDark?: boolean;
|
|
575
|
-
testID?: string;
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
/**
|
|
579
|
-
* A star rating.
|
|
580
|
-
*
|
|
581
|
-
* The stars are drawn as SVG paths from the resolver, so nothing is a
|
|
582
|
-
* platform control. A fractional value fills part of a star: 3.5 draws three
|
|
583
|
-
* full stars and one half, the half produced by clipping the filled star at the
|
|
584
|
-
* fraction's width rather than by rounding — a 4.5-star average must look like
|
|
585
|
-
* a 4.5-star average.
|
|
586
|
-
*
|
|
587
|
-
* Read-only unless `onChange` is given. With it, each star is tappable, the
|
|
588
|
-
* value is exposed as an adjustable control (increment/decrement through
|
|
589
|
-
* accessibility actions), and each star has its own label so a screen reader
|
|
590
|
-
* can name the exact rating it sets.
|
|
591
|
-
*/
|
|
592
|
-
export const Rating = forwardRef<any, RatingProps>(function Rating(
|
|
593
|
-
{
|
|
594
|
-
value,
|
|
595
|
-
max = 5,
|
|
596
|
-
size = "md",
|
|
597
|
-
onChange,
|
|
598
|
-
disabled = false,
|
|
599
|
-
accessibilityLabel = "Rating",
|
|
600
|
-
style,
|
|
601
|
-
isDark: isDarkProp,
|
|
602
|
-
testID,
|
|
603
|
-
...props
|
|
604
|
-
},
|
|
605
|
-
ref,
|
|
606
|
-
) {
|
|
607
|
-
const isDark = useIsDark(isDarkProp);
|
|
608
|
-
const theme = isDark ? colors.dark : colors.light;
|
|
609
|
-
const { View, Pressable, Svg, Path, Defs, ClipPath, Rect } = primitives();
|
|
610
|
-
const starSize = controlSizes.star[size];
|
|
611
|
-
const interactive = Boolean(onChange) && !disabled;
|
|
612
|
-
const clamped = Math.max(0, Math.min(value, max));
|
|
613
|
-
|
|
614
|
-
const setValue = (next: number) => {
|
|
615
|
-
const bounded = Math.max(0, Math.min(next, max));
|
|
616
|
-
onChange?.(bounded);
|
|
617
|
-
};
|
|
618
|
-
|
|
619
|
-
const star = (index: number) => {
|
|
620
|
-
// How much of this star is filled: 1 for a full star, 0 for empty, and the
|
|
621
|
-
// remainder for the one the value lands inside.
|
|
622
|
-
const filled = Math.max(0, Math.min(1, clamped - index));
|
|
623
|
-
const half = filled > 0 && filled < 1;
|
|
624
|
-
|
|
625
|
-
const glyph = (
|
|
626
|
-
<Svg width={starSize} height={starSize} viewBox="0 0 24 24">
|
|
627
|
-
{half ? (
|
|
628
|
-
<Defs>
|
|
629
|
-
{/* The clip is what makes a fractional star possible: the filled
|
|
630
|
-
star is cut at the fraction's width. */}
|
|
631
|
-
<ClipPath id={`rating-clip-${index}`}>
|
|
632
|
-
<Rect x="0" y="0" width={24 * filled} height={24} />
|
|
633
|
-
</ClipPath>
|
|
634
|
-
</Defs>
|
|
635
|
-
) : null}
|
|
636
|
-
{/* The empty star is always drawn, so the shape is complete. */}
|
|
637
|
-
<Path d={STAR_PATH} fill={theme.separator} />
|
|
638
|
-
{filled > 0 ? (
|
|
639
|
-
<Path
|
|
640
|
-
d={STAR_PATH}
|
|
641
|
-
fill={theme.fill}
|
|
642
|
-
{...(half ? { clipPath: `url(#rating-clip-${index})` } : {})}
|
|
643
|
-
/>
|
|
644
|
-
) : null}
|
|
645
|
-
</Svg>
|
|
646
|
-
);
|
|
647
|
-
|
|
648
|
-
if (!interactive) return <View key={index}>{glyph}</View>;
|
|
649
|
-
|
|
650
|
-
return (
|
|
651
|
-
<Pressable
|
|
652
|
-
key={index}
|
|
653
|
-
accessibilityRole="button"
|
|
654
|
-
accessibilityLabel={`${index + 1} of ${max} stars`}
|
|
655
|
-
accessibilityState={{ selected: clamped === index + 1 }}
|
|
656
|
-
onPress={() => setValue(index + 1)}
|
|
657
|
-
hitSlop={4}
|
|
658
|
-
>
|
|
659
|
-
{glyph}
|
|
660
|
-
</Pressable>
|
|
661
|
-
);
|
|
662
|
-
};
|
|
663
|
-
|
|
664
|
-
const stars = Array.from({ length: Math.max(1, max) }, (_unused, index) => star(index));
|
|
665
|
-
|
|
666
|
-
if (!interactive && !onChange) {
|
|
667
|
-
return (
|
|
668
|
-
<View
|
|
669
|
-
ref={ref}
|
|
670
|
-
testID={testID}
|
|
671
|
-
accessibilityRole="text"
|
|
672
|
-
accessibilityLabel={`${accessibilityLabel}, ${clamped} of ${max}`}
|
|
673
|
-
style={{ flexDirection: "row", alignItems: "center", gap: 2, ...(style as ViewStyle) }}
|
|
674
|
-
{...props}
|
|
675
|
-
>
|
|
676
|
-
{stars}
|
|
677
|
-
</View>
|
|
678
|
-
);
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
return (
|
|
682
|
-
<View
|
|
683
|
-
ref={ref}
|
|
684
|
-
testID={testID}
|
|
685
|
-
accessibilityRole="adjustable"
|
|
686
|
-
accessibilityLabel={accessibilityLabel}
|
|
687
|
-
accessibilityState={{ disabled }}
|
|
688
|
-
accessibilityValue={{ min: 0, max, now: clamped }}
|
|
689
|
-
accessibilityActions={[{ name: "increment" }, { name: "decrement" }]}
|
|
690
|
-
onAccessibilityAction={(event: any) => {
|
|
691
|
-
if (disabled) return;
|
|
692
|
-
if (event?.nativeEvent?.actionName === "increment") setValue(clamped + 1);
|
|
693
|
-
if (event?.nativeEvent?.actionName === "decrement") setValue(clamped - 1);
|
|
694
|
-
}}
|
|
695
|
-
style={{ flexDirection: "row", alignItems: "center", gap: 2, opacity: disabled ? 0.38 : 1, ...(style as ViewStyle) }}
|
|
696
|
-
{...props}
|
|
697
|
-
>
|
|
698
|
-
{stars}
|
|
699
|
-
</View>
|
|
700
|
-
);
|
|
701
|
-
});
|
|
702
|
-
|
|
703
|
-
// ---------------------------------------------------------------------------
|
|
704
|
-
// Image
|
|
705
|
-
|
|
706
|
-
export interface NativeImageProps {
|
|
707
|
-
/** The image to show. */
|
|
708
|
-
source: { uri: string } | number;
|
|
709
|
-
/** A description for screen readers. Required: an image with no name is a hole. */
|
|
710
|
-
accessibilityLabel: string;
|
|
711
|
-
/** Shown behind the image while it loads; a Skeleton when omitted. */
|
|
712
|
-
placeholder?: ReactNode;
|
|
713
|
-
/** Shown when the image fails to load. */
|
|
714
|
-
fallback?: ReactNode;
|
|
715
|
-
/** Fades the image in when it loads. Honours Reduce Motion. */
|
|
716
|
-
fadeIn?: boolean;
|
|
717
|
-
style?: StyleProp<ViewStyle>;
|
|
718
|
-
isDark?: boolean;
|
|
719
|
-
testID?: string;
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
/**
|
|
723
|
-
* A plain image, with the loading and error states every app ends up writing.
|
|
724
|
-
*
|
|
725
|
-
* Three states, because an image on a phone is three states: loading (a
|
|
726
|
-
* Skeleton behind it), loaded (a fade in), and failed (the caller's fallback).
|
|
727
|
-
* Aspect ratio comes from `style`, so a caller sets `aspectRatio` and the height
|
|
728
|
-
* follows.
|
|
729
|
-
*
|
|
730
|
-
* This is the plain one; `NativeImageGeneration` is the AI-specific cousin and
|
|
731
|
-
* keeps its own state machine.
|
|
732
|
-
*/
|
|
733
|
-
export const NativeImage = forwardRef<any, NativeImageProps>(function NativeImage(
|
|
734
|
-
{
|
|
735
|
-
source,
|
|
736
|
-
accessibilityLabel,
|
|
737
|
-
placeholder,
|
|
738
|
-
fallback,
|
|
739
|
-
fadeIn = true,
|
|
740
|
-
style,
|
|
741
|
-
isDark: isDarkProp,
|
|
742
|
-
testID,
|
|
743
|
-
...props
|
|
744
|
-
},
|
|
745
|
-
ref,
|
|
746
|
-
) {
|
|
747
|
-
const isDark = useIsDark(isDarkProp);
|
|
748
|
-
const { View, Image: RNImage, Animated } = primitives();
|
|
749
|
-
const [failed, setFailed] = useState(false);
|
|
750
|
-
const [loaded, setLoaded] = useState(false);
|
|
751
|
-
const { value: fade, animated } = useSpring(loaded ? 1 : 0, "gentle");
|
|
752
|
-
|
|
753
|
-
const boxStyle: ViewStyle = { overflow: "hidden", ...(style as ViewStyle) };
|
|
754
|
-
|
|
755
|
-
if (failed && fallback) {
|
|
756
|
-
return (
|
|
757
|
-
<View ref={ref} testID={testID} style={boxStyle} {...props}>
|
|
758
|
-
{fallback}
|
|
759
|
-
</View>
|
|
760
|
-
);
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
const imageStyle: ViewStyle = { width: "100%", height: "100%" };
|
|
764
|
-
const opacity = fadeIn && animated ? fade : 1;
|
|
765
|
-
|
|
766
|
-
return (
|
|
767
|
-
<View ref={ref} testID={testID} style={boxStyle} {...props}>
|
|
768
|
-
{/* The placeholder sits under the image, so the box never collapses and
|
|
769
|
-
the fade reveals rather than jumps. */}
|
|
770
|
-
{!loaded ? <View style={{ position: "absolute", top: 0, left: 0, right: 0, bottom: 0 }}>{placeholder ?? <Skeleton shape="rect" isDark={isDark} />}</View> : null}
|
|
771
|
-
<RNImage
|
|
772
|
-
accessibilityRole="image"
|
|
773
|
-
accessibilityLabel={accessibilityLabel}
|
|
774
|
-
source={source}
|
|
775
|
-
onLoad={() => setLoaded(true)}
|
|
776
|
-
onError={() => setFailed(true)}
|
|
777
|
-
style={[imageStyle, animated ? { opacity } : null]}
|
|
778
|
-
/>
|
|
779
|
-
</View>
|
|
780
|
-
);
|
|
781
|
-
});
|