glacia-native 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +29 -4
- package/README.md +111 -17
- package/lib/module/Accordion.js +58 -0
- package/lib/module/ActionSheet.js +38 -0
- package/lib/module/Alert.js +23 -0
- package/lib/module/AlertDialog.js +47 -0
- package/lib/module/Avatar.js +48 -0
- package/lib/module/Badge.js +36 -0
- package/lib/module/Bars.js +13 -267
- package/lib/module/Button.js +57 -36
- package/lib/module/Card.js +32 -20
- package/lib/module/Checkbox.js +42 -0
- package/lib/module/Chip.js +80 -0
- package/lib/module/Collapsible.js +26 -0
- package/lib/module/ContextMenu.js +33 -0
- package/lib/module/Dialog.js +39 -124
- package/lib/module/DropdownMenu.js +33 -0
- package/lib/module/Field.js +22 -0
- package/lib/module/Glass.js +12 -5
- package/lib/module/Group.js +36 -0
- package/lib/module/IconButton.js +40 -0
- package/lib/module/Input.js +47 -40
- package/lib/module/Label.js +17 -0
- package/lib/module/MorphGroup.js +47 -0
- package/lib/module/Popover.js +29 -0
- package/lib/module/Progress.js +32 -0
- package/lib/module/RadioGroup.js +51 -0
- package/lib/module/Scrim.js +44 -0
- package/lib/module/SegmentedControl.js +74 -58
- package/lib/module/Select.js +51 -0
- package/lib/module/Separator.js +25 -0
- package/lib/module/Sheet.js +51 -0
- package/lib/module/Skeleton.js +48 -0
- package/lib/module/Slider.js +60 -40
- package/lib/module/Stepper.js +167 -0
- package/lib/module/Switch.js +45 -43
- package/lib/module/TabBar.js +62 -50
- package/lib/module/Tabs.js +3 -2
- package/lib/module/Textarea.js +18 -0
- package/lib/module/Toast.js +55 -0
- package/lib/module/Toggle.js +47 -0
- package/lib/module/ToggleGroup.js +56 -0
- package/lib/module/Toolbar.js +37 -0
- package/lib/module/Tooltip.js +31 -0
- package/lib/module/glass-provider.js +28 -0
- package/lib/module/glass-stack.js +61 -0
- package/lib/module/index.js +78 -109
- package/lib/module/internal/GlassBackdrop.js +36 -0
- package/lib/module/internal/GlassView.js +45 -13
- package/lib/module/internal/blur-community.js +20 -0
- package/lib/module/internal/blur-community.web.js +9 -0
- package/lib/module/internal/blur.js +75 -0
- package/lib/module/internal/fallback.js +110 -20
- package/lib/module/internal/glass-routing.js +154 -30
- package/lib/module/internal/glow.js +36 -0
- package/lib/module/internal/initials.js +12 -0
- package/lib/module/internal/lens.js +70 -0
- package/lib/module/internal/material.js +64 -0
- package/lib/module/internal/overlay.js +147 -0
- package/lib/module/internal/primitives.js +17 -0
- package/lib/module/internal/rim.js +35 -0
- package/lib/module/internal/tokens.js +34 -2
- package/lib/typescript/Accordion.d.ts +22 -0
- package/lib/typescript/ActionSheet.d.ts +24 -0
- package/lib/typescript/Alert.d.ts +15 -0
- package/lib/typescript/AlertDialog.d.ts +17 -0
- package/lib/typescript/Avatar.d.ts +22 -0
- package/lib/typescript/Badge.d.ts +12 -0
- package/lib/typescript/Bars.d.ts +3 -188
- package/lib/typescript/Button.d.ts +44 -10
- package/lib/typescript/Card.d.ts +30 -3
- package/lib/typescript/Checkbox.d.ts +14 -0
- package/lib/typescript/Chip.d.ts +19 -0
- package/lib/typescript/Collapsible.d.ts +17 -0
- package/lib/typescript/ContextMenu.d.ts +23 -0
- package/lib/typescript/Dialog.d.ts +8 -68
- package/lib/typescript/DropdownMenu.d.ts +23 -0
- package/lib/typescript/Field.d.ts +19 -0
- package/lib/typescript/Glass.d.ts +11 -2
- package/lib/typescript/Group.d.ts +35 -0
- package/lib/typescript/IconButton.d.ts +21 -0
- package/lib/typescript/Input.d.ts +17 -18
- package/lib/typescript/Label.d.ts +14 -0
- package/lib/typescript/MorphGroup.d.ts +46 -0
- package/lib/typescript/Popover.d.ts +17 -0
- package/lib/typescript/Progress.d.ts +13 -0
- package/lib/typescript/RadioGroup.d.ts +21 -0
- package/lib/typescript/Scrim.d.ts +33 -0
- package/lib/typescript/SegmentedControl.d.ts +24 -13
- package/lib/typescript/Select.d.ts +19 -0
- package/lib/typescript/Separator.d.ts +10 -0
- package/lib/typescript/Sheet.d.ts +45 -0
- package/lib/typescript/Skeleton.d.ts +10 -0
- package/lib/typescript/Slider.d.ts +15 -7
- package/lib/typescript/Stepper.d.ts +49 -0
- package/lib/typescript/Switch.d.ts +19 -12
- package/lib/typescript/TabBar.d.ts +18 -6
- package/lib/typescript/Textarea.d.ts +6 -0
- package/lib/typescript/Toast.d.ts +40 -0
- package/lib/typescript/Toggle.d.ts +21 -0
- package/lib/typescript/ToggleGroup.d.ts +22 -0
- package/lib/typescript/Toolbar.d.ts +35 -0
- package/lib/typescript/Tooltip.d.ts +16 -0
- package/lib/typescript/glass-provider.d.ts +34 -0
- package/lib/typescript/glass-stack.d.ts +54 -0
- package/lib/typescript/index.d.ts +39 -17
- package/lib/typescript/internal/GlassBackdrop.d.ts +33 -0
- package/lib/typescript/internal/GlassView.d.ts +31 -2
- package/lib/typescript/internal/blur-community.d.ts +2 -0
- package/lib/typescript/internal/blur-community.web.d.ts +2 -0
- package/lib/typescript/internal/blur.d.ts +24 -0
- package/lib/typescript/internal/fallback.d.ts +27 -2
- package/lib/typescript/internal/glass-routing.d.ts +83 -15
- package/lib/typescript/internal/glow.d.ts +11 -0
- package/lib/typescript/internal/initials.d.ts +2 -0
- package/lib/typescript/internal/lens.d.ts +47 -0
- package/lib/typescript/internal/material.d.ts +27 -0
- package/lib/typescript/internal/overlay.d.ts +74 -0
- package/lib/typescript/internal/primitives.d.ts +13 -0
- package/lib/typescript/internal/rim.d.ts +16 -0
- package/lib/typescript/internal/tokens.d.ts +36 -0
- package/package.json +15 -4
- package/src/Accordion.tsx +165 -0
- package/src/ActionSheet.tsx +149 -0
- package/src/Alert.tsx +85 -0
- package/src/AlertDialog.tsx +124 -0
- package/src/Avatar.tsx +102 -0
- package/src/Badge.tsx +80 -0
- package/src/Bars.tsx +10 -797
- package/src/Button.tsx +196 -60
- package/src/Card.tsx +106 -33
- package/src/Checkbox.tsx +98 -0
- package/src/Chip.tsx +149 -0
- package/src/Collapsible.tsx +66 -0
- package/src/ContextMenu.tsx +103 -0
- package/src/Dialog.tsx +86 -325
- package/src/DropdownMenu.tsx +103 -0
- package/src/Field.tsx +65 -0
- package/src/Glass.tsx +19 -5
- package/src/Group.tsx +98 -0
- package/src/IconButton.tsx +110 -0
- package/src/Input.tsx +143 -87
- package/src/Label.tsx +56 -0
- package/src/MorphGroup.tsx +134 -0
- package/src/Popover.tsx +81 -0
- package/src/Progress.tsx +83 -0
- package/src/RadioGroup.tsx +122 -0
- package/src/Scrim.tsx +94 -0
- package/src/SegmentedControl.tsx +147 -90
- package/src/Select.tsx +136 -0
- package/src/Separator.tsx +52 -0
- package/src/Sheet.tsx +139 -0
- package/src/Skeleton.tsx +77 -0
- package/src/Slider.tsx +100 -54
- package/src/Stepper.tsx +315 -0
- package/src/Switch.tsx +80 -58
- package/src/TabBar.tsx +118 -84
- package/src/Tabs.tsx +5 -0
- package/src/Textarea.tsx +34 -0
- package/src/Toast.tsx +131 -0
- package/src/Toggle.tsx +113 -0
- package/src/ToggleGroup.tsx +129 -0
- package/src/Toolbar.tsx +111 -0
- package/src/Tooltip.tsx +79 -0
- package/src/engine/CHANGELOG.md +430 -0
- package/src/engine/NOTICE +54 -0
- package/src/engine/README.md +975 -0
- package/src/engine/android/build.gradle +18 -0
- package/src/engine/android/src/main/AndroidManifest.xml +2 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/ExpoLiquidGlassModule.kt +174 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/GlassConstants.kt +7 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassContainerView.kt +16 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassProviderView.kt +165 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassView.kt +1731 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/enums/GlassEnums.kt +171 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/BackdropGraph.kt +146 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/BackdropSource.kt +53 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/ContinuousCorners.kt +188 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/CornerRadii.kt +62 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassAppearance.kt +352 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassDebug.kt +109 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassEnvironment.kt +139 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassHdr.kt +85 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassLuminanceProbe.kt +189 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassPressAnimator.kt +264 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassProgressiveBlur.kt +249 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassShaderCache.kt +256 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassShaderSource.kt +845 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassTier.kt +63 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/ProviderRegistry.kt +71 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/records/GlassRecords.kt +288 -0
- package/src/engine/index.ts +24 -0
- package/src/engine/ios/Enums/GlassBlurDirection.swift +21 -0
- package/src/engine/ios/Enums/GlassVariant.swift +86 -0
- package/src/engine/ios/ExpoLiquidGlass.podspec +93 -0
- package/src/engine/ios/ExpoLiquidGlassModule.swift +77 -0
- package/src/engine/ios/Glass/BackdropCapturer.swift +811 -0
- package/src/engine/ios/Glass/ContinuousCorners.swift +165 -0
- package/src/engine/ios/Glass/GlassBackdrop.swift +176 -0
- package/src/engine/ios/Glass/GlassFramePhase.swift +126 -0
- package/src/engine/ios/Glass/GlassFrameScheduler.swift +261 -0
- package/src/engine/ios/Glass/GlassPressAnimator.swift +250 -0
- package/src/engine/ios/Glass/GlassRenderContext.swift +168 -0
- package/src/engine/ios/Glass/GlassRenderer.swift +186 -0
- package/src/engine/ios/Glass/GlassSurfaceView.swift +452 -0
- package/src/engine/ios/Glass/NonRenderableView.swift +54 -0
- package/src/engine/ios/Glass/StripCache.swift +545 -0
- package/src/engine/ios/Records/GlassCornerRadii.swift +79 -0
- package/src/engine/ios/Records/GlassMetalOptions.swift +180 -0
- package/src/engine/ios/Records/GlassRefractionCurve.swift +14 -0
- package/src/engine/ios/Shaders/LiquidGlass.metal +480 -0
- package/src/engine/ios/Shaders/bundle-marker.txt +6 -0
- package/src/engine/ios/Views/LiquidGlassContainerView.swift +99 -0
- package/src/engine/ios/Views/LiquidGlassView.swift +859 -0
- package/src/engine/package.json +70 -0
- package/src/engine/src/components/LiquidGlassButton/LiquidGlassButton.tsx +424 -0
- package/src/engine/src/components/LiquidGlassCard/LiquidGlassCard.tsx +98 -0
- package/src/engine/src/components/LiquidGlassChip/LiquidGlassChip.tsx +65 -0
- package/src/engine/src/components/LiquidGlassGroup/LiquidGlassGroup.tsx +350 -0
- package/src/engine/src/components/LiquidGlassIconButton/LiquidGlassIconButton.tsx +24 -0
- package/src/engine/src/components/LiquidGlassMorphGroup/LiquidGlassMorphGroup.tsx +434 -0
- package/src/engine/src/components/LiquidGlassScrim/LiquidGlassScrim.tsx +100 -0
- package/src/engine/src/components/LiquidGlassSegmentedControl/LiquidGlassSegmentedControl.tsx +213 -0
- package/src/engine/src/components/LiquidGlassSheet/LiquidGlassSheet.tsx +218 -0
- package/src/engine/src/components/LiquidGlassSlider/LiquidGlassSlider.tsx +327 -0
- package/src/engine/src/components/LiquidGlassStepper/LiquidGlassStepper.tsx +321 -0
- package/src/engine/src/components/LiquidGlassSwitch/LiquidGlassSwitch.tsx +296 -0
- package/src/engine/src/components/LiquidGlassTabBar/LiquidGlassTabBar.tsx +952 -0
- package/src/engine/src/components/LiquidGlassTextInput/LiquidGlassTextInput.tsx +151 -0
- package/src/engine/src/components/LiquidGlassToast/LiquidGlassToast.tsx +169 -0
- package/src/engine/src/components/LiquidGlassToolbar/LiquidGlassToolbar.tsx +124 -0
- package/src/engine/src/components/index.ts +16 -0
- package/src/engine/src/constants/index.ts +4 -0
- package/src/engine/src/constants/metal.constants.ts +327 -0
- package/src/engine/src/constants/metrics.constants.ts +325 -0
- package/src/engine/src/constants/springs.constants.ts +107 -0
- package/src/engine/src/constants/styles.constants.ts +12 -0
- package/src/engine/src/context/glass-group.context.ts +65 -0
- package/src/engine/src/context/index.ts +6 -0
- package/src/engine/src/core/components/LiquidGlassContainer/LiquidGlassContainer.tsx +32 -0
- package/src/engine/src/core/components/LiquidGlassContainer/index.ts +1 -0
- package/src/engine/src/core/components/LiquidGlassProvider/LiquidGlassProvider.tsx +66 -0
- package/src/engine/src/core/components/LiquidGlassProvider/index.ts +1 -0
- package/src/engine/src/core/components/LiquidGlassStack/LiquidGlassStack.tsx +184 -0
- package/src/engine/src/core/components/LiquidGlassStack/index.ts +1 -0
- package/src/engine/src/core/components/LiquidGlassView/LiquidGlassView.tsx +126 -0
- package/src/engine/src/core/components/LiquidGlassView/index.ts +1 -0
- package/src/engine/src/core/components/index.ts +4 -0
- package/src/engine/src/core/constants/glass.constants.ts +57 -0
- package/src/engine/src/core/constants/index.ts +20 -0
- package/src/engine/src/core/constants/native.constants.ts +16 -0
- package/src/engine/src/core/context/glass-stack.context.ts +30 -0
- package/src/engine/src/core/context/index.ts +4 -0
- package/src/engine/src/core/enum/index.ts +12 -0
- package/src/engine/src/core/index.ts +1 -0
- package/src/engine/src/core/interfaces/glass-hdr.interface.ts +15 -0
- package/src/engine/src/core/interfaces/glass-metal.interface.ts +248 -0
- package/src/engine/src/core/interfaces/glass-surface.interface.ts +9 -0
- package/src/engine/src/core/interfaces/index.ts +31 -0
- package/src/engine/src/core/interfaces/liquid-glass-container.interface.ts +6 -0
- package/src/engine/src/core/interfaces/liquid-glass-provider.interface.ts +14 -0
- package/src/engine/src/core/interfaces/liquid-glass-stack.interface.ts +21 -0
- package/src/engine/src/core/interfaces/liquid-glass-view.interface.ts +129 -0
- package/src/engine/src/core/interfaces/native-liquid-glass-view.interface.ts +19 -0
- package/src/engine/src/core/modules/ExpoLiquidGlassModule.ts +26 -0
- package/src/engine/src/core/modules/index.ts +2 -0
- package/src/engine/src/core/root/index.ts +51 -0
- package/src/engine/src/core/types/glass.types.ts +25 -0
- package/src/engine/src/core/types/index.ts +8 -0
- package/src/engine/src/core/utils/debug.utils.ts +17 -0
- package/src/engine/src/core/utils/dev-warn.utils.ts +17 -0
- package/src/engine/src/core/utils/hdr.utils.ts +37 -0
- package/src/engine/src/core/utils/index.ts +5 -0
- package/src/engine/src/core/utils/native-view.utils.ts +33 -0
- package/src/engine/src/core/utils/platform.utils.ts +34 -0
- package/src/engine/src/core/views/NativeGlassBackdropView.ts +24 -0
- package/src/engine/src/core/views/NativeLiquidGlassContainerView.ts +13 -0
- package/src/engine/src/core/views/NativeLiquidGlassContainerView.web.ts +10 -0
- package/src/engine/src/core/views/NativeLiquidGlassProviderView.ts +13 -0
- package/src/engine/src/core/views/NativeLiquidGlassProviderView.web.ts +10 -0
- package/src/engine/src/core/views/NativeLiquidGlassView.ts +19 -0
- package/src/engine/src/core/views/NativeLiquidGlassView.web.ts +14 -0
- package/src/engine/src/core/views/index.ts +4 -0
- package/src/engine/src/hooks/index.ts +18 -0
- package/src/engine/src/hooks/use-adaptive-glass.ts +91 -0
- package/src/engine/src/hooks/use-damped-drag.ts +332 -0
- package/src/engine/src/hooks/use-echo-filter.ts +55 -0
- package/src/engine/src/hooks/use-glass-group-member.ts +169 -0
- package/src/engine/src/hooks/use-gravity-highlight.ts +79 -0
- package/src/engine/src/hooks/use-press-progress.ts +44 -0
- package/src/engine/src/index.ts +120 -0
- package/src/engine/src/interfaces/index.ts +28 -0
- package/src/engine/src/interfaces/liquid-glass-button.interface.ts +94 -0
- package/src/engine/src/interfaces/liquid-glass-card.interface.ts +40 -0
- package/src/engine/src/interfaces/liquid-glass-chip.interface.ts +29 -0
- package/src/engine/src/interfaces/liquid-glass-group.interface.ts +32 -0
- package/src/engine/src/interfaces/liquid-glass-icon-button.interface.ts +19 -0
- package/src/engine/src/interfaces/liquid-glass-morph-group.interface.ts +59 -0
- package/src/engine/src/interfaces/liquid-glass-scrim.interface.ts +36 -0
- package/src/engine/src/interfaces/liquid-glass-segmented-control.interface.ts +32 -0
- package/src/engine/src/interfaces/liquid-glass-sheet.interface.ts +38 -0
- package/src/engine/src/interfaces/liquid-glass-slider.interface.ts +37 -0
- package/src/engine/src/interfaces/liquid-glass-stepper.interface.ts +35 -0
- package/src/engine/src/interfaces/liquid-glass-switch.interface.ts +27 -0
- package/src/engine/src/interfaces/liquid-glass-tab-bar.interface.ts +116 -0
- package/src/engine/src/interfaces/liquid-glass-text-input.interface.ts +42 -0
- package/src/engine/src/interfaces/liquid-glass-toast.interface.ts +36 -0
- package/src/engine/src/interfaces/liquid-glass-toolbar.interface.ts +33 -0
- package/src/engine/src/theme/glass-ui-theme.ts +100 -0
- package/src/engine/src/theme/index.ts +2 -0
- package/src/engine/src/utils/button-press.utils.ts +63 -0
- package/src/engine/src/utils/index.ts +3 -0
- package/src/engine/src/utils/metal.utils.ts +164 -0
- package/src/glass-provider.tsx +60 -0
- package/src/glass-stack.tsx +115 -0
- package/src/index.ts +48 -190
- package/src/internal/GlassBackdrop.tsx +60 -0
- package/src/internal/GlassView.tsx +70 -18
- package/src/internal/blur-community.ts +19 -0
- package/src/internal/blur-community.web.ts +7 -0
- package/src/internal/blur.ts +89 -0
- package/src/internal/fallback.tsx +158 -20
- package/src/internal/glass-routing.ts +211 -34
- package/src/internal/glow.tsx +62 -0
- package/src/internal/initials.ts +7 -0
- package/src/internal/lens.tsx +105 -0
- package/src/internal/material.ts +92 -0
- package/src/internal/overlay.tsx +258 -0
- package/src/internal/primitives.ts +26 -0
- package/src/internal/rim.tsx +79 -0
- package/src/internal/tokens.ts +34 -1
- package/lib/module/Carousel.js +0 -103
- package/lib/module/Display.js +0 -317
- package/lib/module/Feedback.js +0 -386
- package/lib/module/Form.js +0 -164
- package/lib/module/Forms2.js +0 -454
- package/lib/module/Message.js +0 -88
- package/lib/module/Overlays.js +0 -328
- package/lib/module/Pickers.js +0 -243
- package/lib/module/Table.js +0 -99
- package/lib/module/ai.js +0 -280
- package/lib/module/charts/AreaChart.js +0 -32
- package/lib/module/charts/BarChart.js +0 -67
- package/lib/module/charts/FunnelChart.js +0 -50
- package/lib/module/charts/HeatmapChart.js +0 -71
- package/lib/module/charts/LineChart.js +0 -81
- package/lib/module/charts/PlotChart.js +0 -52
- package/lib/module/charts/RadarChart.js +0 -78
- package/lib/module/charts/RingChart.js +0 -52
- package/lib/module/charts/ScatterChart.js +0 -95
- package/lib/module/charts/WaterfallChart.js +0 -85
- package/lib/module/charts/advanced.js +0 -313
- package/lib/module/charts/extra.js +0 -108
- package/lib/module/charts/index.js +0 -50
- package/lib/module/charts/scales.js +0 -140
- package/lib/typescript/Carousel.d.ts +0 -47
- package/lib/typescript/Display.d.ts +0 -178
- package/lib/typescript/Feedback.d.ts +0 -196
- package/lib/typescript/Form.d.ts +0 -97
- package/lib/typescript/Forms2.d.ts +0 -209
- package/lib/typescript/Message.d.ts +0 -71
- package/lib/typescript/Overlays.d.ts +0 -146
- package/lib/typescript/Pickers.d.ts +0 -105
- package/lib/typescript/Table.d.ts +0 -64
- package/lib/typescript/ai.d.ts +0 -166
- package/lib/typescript/charts/AreaChart.d.ts +0 -44
- package/lib/typescript/charts/BarChart.d.ts +0 -19
- package/lib/typescript/charts/FunnelChart.d.ts +0 -25
- package/lib/typescript/charts/HeatmapChart.d.ts +0 -23
- package/lib/typescript/charts/LineChart.d.ts +0 -30
- package/lib/typescript/charts/PlotChart.d.ts +0 -31
- package/lib/typescript/charts/RadarChart.d.ts +0 -27
- package/lib/typescript/charts/RingChart.d.ts +0 -28
- package/lib/typescript/charts/ScatterChart.d.ts +0 -34
- package/lib/typescript/charts/WaterfallChart.d.ts +0 -22
- package/lib/typescript/charts/advanced.d.ts +0 -107
- package/lib/typescript/charts/extra.d.ts +0 -63
- package/lib/typescript/charts/index.d.ts +0 -13
- package/lib/typescript/charts/scales.d.ts +0 -35
- package/src/Carousel.tsx +0 -233
- package/src/Display.tsx +0 -778
- package/src/Feedback.tsx +0 -969
- package/src/Form.tsx +0 -425
- package/src/Forms2.tsx +0 -1014
- package/src/Message.tsx +0 -219
- package/src/Overlays.tsx +0 -685
- package/src/Pickers.tsx +0 -590
- package/src/Table.tsx +0 -231
- package/src/ai.tsx +0 -707
- package/src/charts/AreaChart.tsx +0 -73
- package/src/charts/BarChart.tsx +0 -183
- package/src/charts/FunnelChart.tsx +0 -125
- package/src/charts/HeatmapChart.tsx +0 -155
- package/src/charts/LineChart.tsx +0 -247
- package/src/charts/PlotChart.tsx +0 -168
- package/src/charts/RadarChart.tsx +0 -208
- package/src/charts/RingChart.tsx +0 -133
- package/src/charts/ScatterChart.tsx +0 -223
- package/src/charts/WaterfallChart.tsx +0 -201
- package/src/charts/advanced.tsx +0 -676
- package/src/charts/extra.tsx +0 -242
- package/src/charts/index.ts +0 -86
- package/src/charts/scales.ts +0 -163
package/src/Select.tsx
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// Wave 2 — Select.
|
|
2
|
+
//
|
|
3
|
+
// The donor's single-choice field: a `listbox`-style combobox whose trigger
|
|
4
|
+
// shows the chosen label, opening an anchored list where each option is
|
|
5
|
+
// selectable and the chosen one is marked. Controlled or internal, with a
|
|
6
|
+
// placeholder and disabled options.
|
|
7
|
+
|
|
8
|
+
import { useState } from "react";
|
|
9
|
+
import type { StyleProp, ViewStyle } from "react-native";
|
|
10
|
+
|
|
11
|
+
import { Glass } from "./Glass";
|
|
12
|
+
import { colors, radii } from "./internal/tokens";
|
|
13
|
+
import { primitives } from "./internal/primitives";
|
|
14
|
+
import { useIsDark } from "./internal/motion";
|
|
15
|
+
import { hapticSelection } from "./internal/haptics";
|
|
16
|
+
import { OverlayPanel, PanelItem, useTriggerAnchor } from "./internal/overlay";
|
|
17
|
+
|
|
18
|
+
export interface SelectOption {
|
|
19
|
+
value: string;
|
|
20
|
+
label: string;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface SelectProps {
|
|
25
|
+
value?: string;
|
|
26
|
+
defaultValue?: string;
|
|
27
|
+
onValueChange?: (value: string) => void;
|
|
28
|
+
options: SelectOption[];
|
|
29
|
+
placeholder?: string;
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
accessibilityLabel?: string;
|
|
32
|
+
isDark?: boolean;
|
|
33
|
+
style?: StyleProp<ViewStyle>;
|
|
34
|
+
testID?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function Select({
|
|
38
|
+
value: valueProp,
|
|
39
|
+
defaultValue,
|
|
40
|
+
onValueChange,
|
|
41
|
+
options,
|
|
42
|
+
placeholder = "Select…",
|
|
43
|
+
disabled = false,
|
|
44
|
+
accessibilityLabel = "Select",
|
|
45
|
+
isDark: isDarkProp,
|
|
46
|
+
style,
|
|
47
|
+
testID,
|
|
48
|
+
}: SelectProps) {
|
|
49
|
+
const isDark = useIsDark(isDarkProp);
|
|
50
|
+
const theme = isDark ? colors.dark : colors.light;
|
|
51
|
+
const { View, Pressable, Text: RNText } = primitives();
|
|
52
|
+
const [internal, setInternal] = useState(defaultValue);
|
|
53
|
+
const [open, setOpen] = useState(false);
|
|
54
|
+
const { ref, anchor, capture } = useTriggerAnchor();
|
|
55
|
+
|
|
56
|
+
const value = valueProp !== undefined ? valueProp : internal;
|
|
57
|
+
const chosen = options.find((option) => option.value === value);
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<View style={{ alignSelf: "flex-start", width: 220, maxWidth: "100%" }}>
|
|
61
|
+
<Pressable
|
|
62
|
+
ref={ref}
|
|
63
|
+
testID={testID}
|
|
64
|
+
accessibilityRole="button"
|
|
65
|
+
accessibilityLabel={chosen ? chosen.label : accessibilityLabel}
|
|
66
|
+
accessibilityState={{ expanded: open, disabled }}
|
|
67
|
+
accessibilityValue={chosen ? { text: chosen.label } : undefined}
|
|
68
|
+
disabled={disabled}
|
|
69
|
+
onPress={() => {
|
|
70
|
+
void capture();
|
|
71
|
+
setOpen(true);
|
|
72
|
+
}}
|
|
73
|
+
style={{ opacity: disabled ? 0.38 : 1 }}
|
|
74
|
+
>
|
|
75
|
+
<Glass
|
|
76
|
+
effect="regular"
|
|
77
|
+
surface="control"
|
|
78
|
+
isDark={isDark}
|
|
79
|
+
pressed={open}
|
|
80
|
+
style={{
|
|
81
|
+
height: 40,
|
|
82
|
+
borderRadius: radii.md,
|
|
83
|
+
paddingHorizontal: 14,
|
|
84
|
+
flexDirection: "row",
|
|
85
|
+
alignItems: "center",
|
|
86
|
+
justifyContent: "space-between",
|
|
87
|
+
gap: 8,
|
|
88
|
+
}}
|
|
89
|
+
>
|
|
90
|
+
<RNText
|
|
91
|
+
numberOfLines={1}
|
|
92
|
+
style={{
|
|
93
|
+
flex: 1,
|
|
94
|
+
fontSize: 15,
|
|
95
|
+
color: chosen ? theme.foreground : theme.muted,
|
|
96
|
+
}}
|
|
97
|
+
>
|
|
98
|
+
{chosen?.label ?? placeholder}
|
|
99
|
+
</RNText>
|
|
100
|
+
<RNText style={{ fontSize: 11, color: theme.muted, transform: [{ rotate: open ? "180deg" : "0deg" }] }}>
|
|
101
|
+
▾
|
|
102
|
+
</RNText>
|
|
103
|
+
</Glass>
|
|
104
|
+
</Pressable>
|
|
105
|
+
|
|
106
|
+
<OverlayPanel
|
|
107
|
+
open={open}
|
|
108
|
+
onClose={() => setOpen(false)}
|
|
109
|
+
anchor={anchor}
|
|
110
|
+
width={220}
|
|
111
|
+
isDark={isDark}
|
|
112
|
+
testID={testID ? `${testID}-list` : undefined}
|
|
113
|
+
accessibilityLabel={chosen ? chosen.label : accessibilityLabel}
|
|
114
|
+
role="listbox"
|
|
115
|
+
>
|
|
116
|
+
{options.map((option) => (
|
|
117
|
+
<PanelItem
|
|
118
|
+
key={option.value}
|
|
119
|
+
label={option.label}
|
|
120
|
+
disabled={option.disabled}
|
|
121
|
+
selected={option.value === value}
|
|
122
|
+
role="option"
|
|
123
|
+
isDark={isDark}
|
|
124
|
+
onPress={() => {
|
|
125
|
+
if (option.disabled) return;
|
|
126
|
+
setOpen(false);
|
|
127
|
+
if (valueProp === undefined) setInternal(option.value);
|
|
128
|
+
hapticSelection();
|
|
129
|
+
onValueChange?.(option.value);
|
|
130
|
+
}}
|
|
131
|
+
/>
|
|
132
|
+
))}
|
|
133
|
+
</OverlayPanel>
|
|
134
|
+
</View>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Wave 2 — Separator.
|
|
2
|
+
//
|
|
3
|
+
// The donor's semantic separator (`role="separator"`, horizontal by default,
|
|
4
|
+
// decorative when it carries no label), dressed at the family's hairline.
|
|
5
|
+
|
|
6
|
+
import type { StyleProp, ViewStyle } from "react-native";
|
|
7
|
+
|
|
8
|
+
import { colors } from "./internal/tokens";
|
|
9
|
+
import { primitives } from "./internal/primitives";
|
|
10
|
+
import { useIsDark } from "./internal/motion";
|
|
11
|
+
|
|
12
|
+
export interface SeparatorProps {
|
|
13
|
+
orientation?: "horizontal" | "vertical";
|
|
14
|
+
/** Leading inset for a horizontal rule inside a list, dp. */
|
|
15
|
+
inset?: number;
|
|
16
|
+
isDark?: boolean;
|
|
17
|
+
style?: StyleProp<ViewStyle>;
|
|
18
|
+
testID?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function Separator({
|
|
22
|
+
orientation = "horizontal",
|
|
23
|
+
inset = 0,
|
|
24
|
+
isDark: isDarkProp,
|
|
25
|
+
style,
|
|
26
|
+
testID,
|
|
27
|
+
}: SeparatorProps) {
|
|
28
|
+
const isDark = useIsDark(isDarkProp);
|
|
29
|
+
const theme = isDark ? colors.dark : colors.light;
|
|
30
|
+
const { View } = primitives();
|
|
31
|
+
const horizontal = orientation === "horizontal";
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<View
|
|
35
|
+
testID={testID}
|
|
36
|
+
accessibilityRole="none"
|
|
37
|
+
role="separator"
|
|
38
|
+
style={[
|
|
39
|
+
{
|
|
40
|
+
backgroundColor: theme.separator,
|
|
41
|
+
alignSelf: "stretch",
|
|
42
|
+
height: horizontal ? 1 : undefined,
|
|
43
|
+
width: horizontal ? undefined : 1,
|
|
44
|
+
marginLeft: horizontal ? inset : undefined,
|
|
45
|
+
marginVertical: horizontal ? 8 : 0,
|
|
46
|
+
},
|
|
47
|
+
horizontal ? null : { height: "100%" },
|
|
48
|
+
style,
|
|
49
|
+
]}
|
|
50
|
+
/>
|
|
51
|
+
);
|
|
52
|
+
}
|
package/src/Sheet.tsx
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
import type { StyleProp, ViewStyle } from "react-native";
|
|
4
|
+
|
|
5
|
+
import { loadEngineControl } from "./internal/glass-routing";
|
|
6
|
+
import { glassCapabilities } from "./internal/GlassView";
|
|
7
|
+
import { Glass } from "./Glass";
|
|
8
|
+
import { colors } from "./internal/tokens";
|
|
9
|
+
import { primitives } from "./internal/primitives";
|
|
10
|
+
import { useIsDark } from "./internal/motion";
|
|
11
|
+
|
|
12
|
+
export interface SheetProps {
|
|
13
|
+
/** Up while `true`; slides away when it turns `false`. */
|
|
14
|
+
visible: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Called when the sheet wants to go — dragged down past 30 % of its height,
|
|
17
|
+
* flung down, or the dim behind it tapped. The app flips `visible`; the sheet
|
|
18
|
+
* never hides itself.
|
|
19
|
+
*/
|
|
20
|
+
onDismiss?: () => void;
|
|
21
|
+
/** The sheet's height, dp. Defaults to 420. */
|
|
22
|
+
height?: number;
|
|
23
|
+
/** Top corner radius, continuous. Defaults to 28. */
|
|
24
|
+
cornerRadius?: number;
|
|
25
|
+
/** Shows the grab handle. Defaults to `true`. */
|
|
26
|
+
handle?: boolean;
|
|
27
|
+
/** Opacity of the black dim behind the sheet at full height; `0` for none. Defaults to 0.25. */
|
|
28
|
+
dim?: number;
|
|
29
|
+
/** A tap on the dim dismisses. Defaults to `true`. */
|
|
30
|
+
dismissOnTap?: boolean;
|
|
31
|
+
/** Surface wash. */
|
|
32
|
+
tint?: string;
|
|
33
|
+
variant?: "regular" | "clear";
|
|
34
|
+
/** The sheet frame — positioned absolutely at the bottom of its parent. */
|
|
35
|
+
style?: StyleProp<ViewStyle>;
|
|
36
|
+
/** The content view, under the handle. */
|
|
37
|
+
contentStyle?: StyleProp<ViewStyle>;
|
|
38
|
+
children?: ReactNode;
|
|
39
|
+
isDark?: boolean;
|
|
40
|
+
/** Passed to the sheet so it is testable. */
|
|
41
|
+
testID?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* A bottom sheet — ported from the engine's `LiquidGlassSheet`, the design
|
|
46
|
+
* Binyam approved on real devices this week (28dp top corners, 36x5 grab handle,
|
|
47
|
+
* dismissed past 30 % of its height or on a dim tap).
|
|
48
|
+
*
|
|
49
|
+
* With a glass renderer available the engine's own control mounts, carrying the
|
|
50
|
+
* approved material, handle and dismissal behaviour. Without one — Expo Go, below
|
|
51
|
+
* every tier, or Reduce Transparency — the fallback floor renders the same panel
|
|
52
|
+
* with a solid surface and the same dismissal affordances, so the sheet is never
|
|
53
|
+
* invisible.
|
|
54
|
+
*/
|
|
55
|
+
export const Sheet = forwardRef<any, SheetProps>(function Sheet(
|
|
56
|
+
{
|
|
57
|
+
visible,
|
|
58
|
+
onDismiss,
|
|
59
|
+
height = 420,
|
|
60
|
+
cornerRadius = 28,
|
|
61
|
+
handle = true,
|
|
62
|
+
dim = 0.25,
|
|
63
|
+
dismissOnTap = true,
|
|
64
|
+
tint,
|
|
65
|
+
variant = "regular",
|
|
66
|
+
style,
|
|
67
|
+
contentStyle,
|
|
68
|
+
children,
|
|
69
|
+
isDark: isDarkProp,
|
|
70
|
+
testID,
|
|
71
|
+
...props
|
|
72
|
+
},
|
|
73
|
+
ref,
|
|
74
|
+
) {
|
|
75
|
+
const isDark = useIsDark(isDarkProp);
|
|
76
|
+
const themeColors = isDark ? colors.dark : colors.light;
|
|
77
|
+
const { View } = primitives();
|
|
78
|
+
const capabilities = glassCapabilities();
|
|
79
|
+
const EngineSheet = loadEngineControl("Sheet");
|
|
80
|
+
|
|
81
|
+
if (!visible) return null;
|
|
82
|
+
|
|
83
|
+
if (EngineSheet && capabilities.supported) {
|
|
84
|
+
const EngineSheetComponent = EngineSheet;
|
|
85
|
+
return (
|
|
86
|
+
<EngineSheetComponent
|
|
87
|
+
visible={visible}
|
|
88
|
+
onDismiss={onDismiss}
|
|
89
|
+
height={height}
|
|
90
|
+
cornerRadius={cornerRadius}
|
|
91
|
+
handle={handle}
|
|
92
|
+
dim={dim}
|
|
93
|
+
dismissOnTap={dismissOnTap}
|
|
94
|
+
tint={tint}
|
|
95
|
+
variant={variant}
|
|
96
|
+
style={style}
|
|
97
|
+
contentStyle={contentStyle}
|
|
98
|
+
testID={testID}
|
|
99
|
+
>
|
|
100
|
+
{children}
|
|
101
|
+
</EngineSheetComponent>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Fallback floor: dim + solid panel at the bottom, same geometry.
|
|
106
|
+
const panelStyle: ViewStyle = {
|
|
107
|
+
position: "absolute",
|
|
108
|
+
bottom: 0,
|
|
109
|
+
left: 0,
|
|
110
|
+
right: 0,
|
|
111
|
+
height,
|
|
112
|
+
borderTopLeftRadius: cornerRadius,
|
|
113
|
+
borderTopRightRadius: cornerRadius,
|
|
114
|
+
overflow: "hidden",
|
|
115
|
+
backgroundColor: tint ?? themeColors.surface,
|
|
116
|
+
...(style as ViewStyle),
|
|
117
|
+
};
|
|
118
|
+
return (
|
|
119
|
+
<>
|
|
120
|
+
{dim > 0 ? (
|
|
121
|
+
<View
|
|
122
|
+
testID={testID ? `${testID}-dim` : undefined}
|
|
123
|
+
pointerEvents="box-none"
|
|
124
|
+
style={{ position: "absolute", top: 0, left: 0, right: 0, bottom: 0, backgroundColor: themeColors.scrim }}
|
|
125
|
+
onStartShouldSetResponder={() => true}
|
|
126
|
+
onResponderGrant={() => {
|
|
127
|
+
if (dismissOnTap) onDismiss?.();
|
|
128
|
+
}}
|
|
129
|
+
/>
|
|
130
|
+
) : null}
|
|
131
|
+
<View style={panelStyle} testID={testID}>
|
|
132
|
+
{handle ? (
|
|
133
|
+
<View style={{ width: 36, height: 5, borderRadius: 2.5, alignSelf: "center", marginTop: 8 }} />
|
|
134
|
+
) : null}
|
|
135
|
+
<View style={contentStyle}>{children}</View>
|
|
136
|
+
</View>
|
|
137
|
+
</>
|
|
138
|
+
);
|
|
139
|
+
});
|
package/src/Skeleton.tsx
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// Wave 2 — Skeleton.
|
|
2
|
+
//
|
|
3
|
+
// The donor's placeholder is decorative: it hides its content from screen
|
|
4
|
+
// readers and announces a busy state on the container instead. The shimmer is
|
|
5
|
+
// the family's motion and disappears under Reduce Motion.
|
|
6
|
+
|
|
7
|
+
import { useEffect, useRef } from "react";
|
|
8
|
+
import type { StyleProp, ViewStyle } from "react-native";
|
|
9
|
+
|
|
10
|
+
import { colors, radii } from "./internal/tokens";
|
|
11
|
+
import { primitives } from "./internal/primitives";
|
|
12
|
+
import { useIsDark } from "./internal/motion";
|
|
13
|
+
import { useReducedMotion } from "./internal/a11y";
|
|
14
|
+
|
|
15
|
+
export interface SkeletonProps {
|
|
16
|
+
shape?: "rect" | "circle" | "line";
|
|
17
|
+
width?: number | string;
|
|
18
|
+
height?: number;
|
|
19
|
+
isDark?: boolean;
|
|
20
|
+
style?: StyleProp<ViewStyle>;
|
|
21
|
+
testID?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function Skeleton({
|
|
25
|
+
shape = "rect",
|
|
26
|
+
width,
|
|
27
|
+
height,
|
|
28
|
+
isDark: isDarkProp,
|
|
29
|
+
style,
|
|
30
|
+
testID,
|
|
31
|
+
}: SkeletonProps) {
|
|
32
|
+
const isDark = useIsDark(isDarkProp);
|
|
33
|
+
const theme = isDark ? colors.dark : colors.light;
|
|
34
|
+
const reducedMotion = useReducedMotion();
|
|
35
|
+
const { View, Animated, isNative } = primitives();
|
|
36
|
+
|
|
37
|
+
const pulse = useRef<any>(null);
|
|
38
|
+
const animate = Boolean(isNative && Animated?.Value && Animated?.timing) && !reducedMotion;
|
|
39
|
+
if (pulse.current === null) pulse.current = animate ? new Animated.Value(0.55) : { value: 1 };
|
|
40
|
+
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (!animate) {
|
|
43
|
+
pulse.current.value = 1;
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const loop = Animated.loop(
|
|
47
|
+
Animated.sequence([
|
|
48
|
+
Animated.timing(pulse.current, { toValue: 1, duration: 700, useNativeDriver: true }),
|
|
49
|
+
Animated.timing(pulse.current, { toValue: 0.55, duration: 700, useNativeDriver: true }),
|
|
50
|
+
]),
|
|
51
|
+
);
|
|
52
|
+
loop.start();
|
|
53
|
+
return () => loop.stop?.();
|
|
54
|
+
}, [animate]);
|
|
55
|
+
|
|
56
|
+
const resolvedHeight = height ?? (shape === "line" ? 12 : 20);
|
|
57
|
+
|
|
58
|
+
const size = shape === "circle" ? resolvedHeight : undefined;
|
|
59
|
+
return (
|
|
60
|
+
<Animated.View
|
|
61
|
+
testID={testID}
|
|
62
|
+
accessibilityRole="none"
|
|
63
|
+
importantForAccessibility="no"
|
|
64
|
+
accessibilityElementsHidden
|
|
65
|
+
style={[
|
|
66
|
+
{
|
|
67
|
+
width: size ?? (width as any) ?? "100%",
|
|
68
|
+
height: resolvedHeight,
|
|
69
|
+
backgroundColor: theme.skeleton,
|
|
70
|
+
borderRadius: shape === "circle" ? resolvedHeight / 2 : radii.sm,
|
|
71
|
+
opacity: pulse.current,
|
|
72
|
+
},
|
|
73
|
+
style,
|
|
74
|
+
]}
|
|
75
|
+
/>
|
|
76
|
+
);
|
|
77
|
+
}
|
package/src/Slider.tsx
CHANGED
|
@@ -2,31 +2,42 @@ import { forwardRef, useMemo, useRef, useState } from "react";
|
|
|
2
2
|
import { measurePreviewWidth } from "./internal/primitives";
|
|
3
3
|
import type { StyleProp, ViewStyle } from "react-native";
|
|
4
4
|
|
|
5
|
+
import { loadEngineControl } from "./internal/glass-routing";
|
|
6
|
+
import { glassCapabilities } from "./internal/GlassView";
|
|
5
7
|
import { Glass } from "./Glass";
|
|
6
|
-
import { colors } from "./internal/tokens";
|
|
8
|
+
import { colors, material } from "./internal/tokens";
|
|
7
9
|
import { primitives } from "./internal/primitives";
|
|
8
10
|
import { useIsDark } from "./internal/motion";
|
|
9
11
|
import { hapticSelection } from "./internal/haptics";
|
|
10
12
|
|
|
11
13
|
export interface SliderProps {
|
|
14
|
+
/** Controlled value. Omit it and the slider keeps its own. */
|
|
12
15
|
value?: number;
|
|
13
16
|
defaultValue?: number;
|
|
17
|
+
/** Inclusive lower bound. Defaults to 0. */
|
|
14
18
|
min?: number;
|
|
19
|
+
/** Inclusive upper bound. Defaults to 100. */
|
|
15
20
|
max?: number;
|
|
21
|
+
/** Increment per step. Defaults to 1. */
|
|
16
22
|
step?: number;
|
|
23
|
+
/** Fires while dragging and once when the gesture ends (engine order). */
|
|
17
24
|
onValueChange?: (value: number) => void;
|
|
25
|
+
/** Fires once when the gesture ends, after the thumb has been released. */
|
|
26
|
+
onSlidingComplete?: (value: number) => void;
|
|
18
27
|
disabled?: boolean;
|
|
19
28
|
/** One selection tick each time the stepped value changes while dragging. */
|
|
20
29
|
haptics?: boolean;
|
|
21
30
|
accessibilityLabel: string;
|
|
22
31
|
style?: StyleProp<ViewStyle>;
|
|
23
32
|
isDark?: boolean;
|
|
24
|
-
/** Passed
|
|
33
|
+
/** Passed to the draggable track so it is testable. */
|
|
25
34
|
testID?: string;
|
|
26
35
|
}
|
|
27
36
|
|
|
28
|
-
|
|
29
|
-
const
|
|
37
|
+
// The web slider: a 6pt track and a glass-lens thumb rather than a small dot.
|
|
38
|
+
const TRACK_HEIGHT = 6;
|
|
39
|
+
const THUMB_WIDTH = 40;
|
|
40
|
+
const THUMB_HEIGHT = 24;
|
|
30
41
|
const CONTAINER_HEIGHT = 40;
|
|
31
42
|
|
|
32
43
|
/** Rounds `value` onto the nearest step from `min`, clamped to the range. */
|
|
@@ -35,19 +46,19 @@ function quantize(value: number, min: number, max: number, step: number): number
|
|
|
35
46
|
const clamped = Math.min(max, Math.max(min, value));
|
|
36
47
|
if (!(step > 0)) return clamped;
|
|
37
48
|
const stepped = min + Math.round((clamped - min) / step) * step;
|
|
38
|
-
// Round away binary float noise introduced by the division above.
|
|
39
49
|
const decimals = (String(step).split(".")[1] ?? "").length;
|
|
40
50
|
return Number(Math.min(max, Math.max(min, stepped)).toFixed(decimals));
|
|
41
51
|
}
|
|
42
52
|
|
|
43
53
|
/**
|
|
44
|
-
* A continuous value chosen by dragging
|
|
54
|
+
* A continuous value chosen by dragging — ported from the engine's
|
|
55
|
+
* `LiquidGlassSlider`, which keeps the approved drag behaviour while the
|
|
56
|
+
* material changes by platform.
|
|
45
57
|
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* platform; only the glass material changes.
|
|
58
|
+
* With a glass renderer available the engine's own control mounts, carrying the
|
|
59
|
+
* approved geometry and drag behaviour. Without one — Expo Go, below every tier,
|
|
60
|
+
* or Reduce Transparency — the fallback floor renders the same track and lens
|
|
61
|
+
* thumb with the fallback material, so the control is never invisible.
|
|
51
62
|
*/
|
|
52
63
|
export const Slider = forwardRef<any, SliderProps>(function Slider(
|
|
53
64
|
{
|
|
@@ -57,6 +68,7 @@ export const Slider = forwardRef<any, SliderProps>(function Slider(
|
|
|
57
68
|
max = 100,
|
|
58
69
|
step = 1,
|
|
59
70
|
onValueChange,
|
|
71
|
+
onSlidingComplete,
|
|
60
72
|
disabled = false,
|
|
61
73
|
haptics = true,
|
|
62
74
|
accessibilityLabel,
|
|
@@ -70,6 +82,8 @@ export const Slider = forwardRef<any, SliderProps>(function Slider(
|
|
|
70
82
|
const isDark = useIsDark(isDarkProp);
|
|
71
83
|
const themeColors = isDark ? colors.dark : colors.light;
|
|
72
84
|
const { View, Pressable, PanResponder } = primitives();
|
|
85
|
+
const capabilities = glassCapabilities();
|
|
86
|
+
const EngineSlider = loadEngineControl("Slider");
|
|
73
87
|
|
|
74
88
|
const [internalValue, setInternalValue] = useState(() => quantize(defaultValue, min, max, step));
|
|
75
89
|
const value = valueProp !== undefined ? quantize(valueProp, min, max, step) : internalValue;
|
|
@@ -79,9 +93,6 @@ export const Slider = forwardRef<any, SliderProps>(function Slider(
|
|
|
79
93
|
// second one starts from it instead of a stale closure.
|
|
80
94
|
const valueRef = useRef(value);
|
|
81
95
|
valueRef.current = value;
|
|
82
|
-
|
|
83
|
-
// Track width as measured on layout. A drag before layout is a no-op rather
|
|
84
|
-
// than a jump: without a width there is no honest mapping from x to value.
|
|
85
96
|
const widthRef = useRef(0);
|
|
86
97
|
|
|
87
98
|
/** Converts an x position relative to the track into a stepped value. */
|
|
@@ -122,10 +133,15 @@ export const Slider = forwardRef<any, SliderProps>(function Slider(
|
|
|
122
133
|
const next = valueAtX(event.nativeEvent.locationX);
|
|
123
134
|
if (next !== null) report(next);
|
|
124
135
|
},
|
|
136
|
+
onPanResponderRelease: (event: any) => {
|
|
137
|
+
const next = valueAtX(event.nativeEvent.locationX);
|
|
138
|
+
if (next !== null) {
|
|
139
|
+
report(next);
|
|
140
|
+
onSlidingComplete?.(next);
|
|
141
|
+
}
|
|
142
|
+
},
|
|
125
143
|
onPanResponderTerminationRequest: () => false,
|
|
126
144
|
});
|
|
127
|
-
// `report` reads the value from a ref, so the responder does not need to be
|
|
128
|
-
// rebuilt on every value change and never acts on a stale render.
|
|
129
145
|
}, [disabled, valueAtX]);
|
|
130
146
|
|
|
131
147
|
/** Steps the value for accessibility actions and hardware keys. */
|
|
@@ -160,49 +176,79 @@ export const Slider = forwardRef<any, SliderProps>(function Slider(
|
|
|
160
176
|
|
|
161
177
|
const thumbStyle: ViewStyle = {
|
|
162
178
|
position: "absolute",
|
|
163
|
-
top: (CONTAINER_HEIGHT -
|
|
179
|
+
top: (CONTAINER_HEIGHT - THUMB_HEIGHT) / 2,
|
|
164
180
|
left: `${Math.min(100, Math.max(0, percentage))}%`,
|
|
165
|
-
width:
|
|
166
|
-
height:
|
|
167
|
-
marginLeft: -
|
|
168
|
-
borderRadius:
|
|
169
|
-
backgroundColor:
|
|
181
|
+
width: THUMB_WIDTH,
|
|
182
|
+
height: THUMB_HEIGHT,
|
|
183
|
+
marginLeft: -THUMB_WIDTH / 2,
|
|
184
|
+
borderRadius: THUMB_HEIGHT / 2,
|
|
185
|
+
backgroundColor: themeColors.onTint,
|
|
170
186
|
borderWidth: 0.5,
|
|
171
|
-
borderColor:
|
|
187
|
+
borderColor: themeColors.edge,
|
|
188
|
+
shadowColor: material.shadowColor,
|
|
189
|
+
shadowOpacity: 0.2,
|
|
190
|
+
shadowRadius: 8,
|
|
191
|
+
shadowOffset: { width: 0, height: 3 },
|
|
192
|
+
elevation: 3,
|
|
172
193
|
};
|
|
173
194
|
|
|
195
|
+
// ------------------------------------------------------------------
|
|
196
|
+
// Fallback floor: the same track and lens thumb, on the fallback material.
|
|
197
|
+
// ------------------------------------------------------------------
|
|
198
|
+
if (!(EngineSlider && capabilities.supported)) {
|
|
199
|
+
const track = (
|
|
200
|
+
<View style={trackStyle}>
|
|
201
|
+
<View style={fillStyle} />
|
|
202
|
+
</View>
|
|
203
|
+
);
|
|
204
|
+
const thumb = <View style={thumbStyle} pointerEvents="none" />;
|
|
205
|
+
return (
|
|
206
|
+
<Pressable
|
|
207
|
+
testID={testID}
|
|
208
|
+
accessibilityRole="adjustable"
|
|
209
|
+
accessibilityLabel={accessibilityLabel}
|
|
210
|
+
accessibilityState={{ disabled }}
|
|
211
|
+
accessibilityValue={{ min, max, now: value }}
|
|
212
|
+
accessibilityActions={[{ name: "increment" }, { name: "decrement" }]}
|
|
213
|
+
disabled={disabled}
|
|
214
|
+
onAccessibilityAction={(event: any) => {
|
|
215
|
+
if (event?.nativeEvent?.actionName === "increment") nudge(1);
|
|
216
|
+
if (event?.nativeEvent?.actionName === "decrement") nudge(-1);
|
|
217
|
+
}}
|
|
218
|
+
onLayout={(event: any) => {
|
|
219
|
+
const width = event?.nativeEvent?.layout?.width;
|
|
220
|
+
if (typeof width === "number" && width > 0) widthRef.current = width;
|
|
221
|
+
}}
|
|
222
|
+
ref={(node: any) => {
|
|
223
|
+
measurePreviewWidth(node, widthRef);
|
|
224
|
+
if (typeof ref === "function") ref(node);
|
|
225
|
+
else if (ref) ref.current = node;
|
|
226
|
+
}}
|
|
227
|
+
style={containerStyle}
|
|
228
|
+
{...(panResponder ? panResponder.panHandlers : {})}
|
|
229
|
+
{...props}
|
|
230
|
+
>
|
|
231
|
+
<Glass effect="regular" isDark={isDark} style={trackStyle}>
|
|
232
|
+
{track}
|
|
233
|
+
</Glass>
|
|
234
|
+
{thumb}
|
|
235
|
+
</Pressable>
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const EngineSliderComponent = EngineSlider;
|
|
174
240
|
return (
|
|
175
|
-
<
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
onAccessibilityAction={(event: any) => {
|
|
183
|
-
if (event?.nativeEvent?.actionName === "increment") nudge(1);
|
|
184
|
-
if (event?.nativeEvent?.actionName === "decrement") nudge(-1);
|
|
185
|
-
}}
|
|
241
|
+
<EngineSliderComponent
|
|
242
|
+
value={value}
|
|
243
|
+
onValueChange={disabled ? undefined : onValueChange ?? report}
|
|
244
|
+
onSlidingComplete={disabled ? undefined : onSlidingComplete}
|
|
245
|
+
minimumValue={min}
|
|
246
|
+
maximumValue={max}
|
|
247
|
+
step={step}
|
|
186
248
|
disabled={disabled}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
// The DOM preview has no layout events, so measure on mount there too;
|
|
192
|
-
// on a device this resolves to nothing and onLayout is the source.
|
|
193
|
-
ref={(node: any) => {
|
|
194
|
-
measurePreviewWidth(node, widthRef);
|
|
195
|
-
if (typeof ref === "function") ref(node);
|
|
196
|
-
else if (ref) ref.current = node;
|
|
197
|
-
}}
|
|
198
|
-
style={containerStyle}
|
|
199
|
-
{...(panResponder ? panResponder.panHandlers : {})}
|
|
200
|
-
{...props}
|
|
201
|
-
>
|
|
202
|
-
<Glass effect="regular" isDark={isDark} style={trackStyle}>
|
|
203
|
-
<View style={fillStyle} />
|
|
204
|
-
</Glass>
|
|
205
|
-
<View style={thumbStyle} pointerEvents="none" />
|
|
206
|
-
</Pressable>
|
|
249
|
+
accentColor={themeColors.fill}
|
|
250
|
+
trackColor="rgba(120, 120, 128, 0.2)"
|
|
251
|
+
style={style}
|
|
252
|
+
/>
|
|
207
253
|
);
|
|
208
254
|
});
|