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/Overlays.tsx
DELETED
|
@@ -1,685 +0,0 @@
|
|
|
1
|
-
import { forwardRef, useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react";
|
|
2
|
-
import type { StyleProp, ViewStyle } from "react-native";
|
|
3
|
-
|
|
4
|
-
import { Glass } from "./Glass";
|
|
5
|
-
import { Text } from "./Text";
|
|
6
|
-
import { colors, radii } from "./internal/tokens";
|
|
7
|
-
import { primitives } from "./internal/primitives";
|
|
8
|
-
import { useIsDark, useSpring } from "./internal/motion";
|
|
9
|
-
import { hapticSelection } from "./internal/haptics";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Registers Android's hardware back while an overlay is open.
|
|
13
|
-
*
|
|
14
|
-
* Shared by Menu, Sheet and Drawer so every overlay dismisses the same way a
|
|
15
|
-
* Dialog does: the back button closes the layer, not the screen behind it.
|
|
16
|
-
*/
|
|
17
|
-
function useBackDismiss(open: boolean, onDismiss: () => void) {
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
if (!open) return;
|
|
20
|
-
const BackHandler = primitives().getBackHandler();
|
|
21
|
-
if (!BackHandler) return;
|
|
22
|
-
const sub = BackHandler.addEventListener("hardwareBackPress", () => {
|
|
23
|
-
onDismiss();
|
|
24
|
-
return true;
|
|
25
|
-
});
|
|
26
|
-
return () => sub.remove();
|
|
27
|
-
}, [open, onDismiss]);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Keeps a popover inside the window.
|
|
32
|
-
*
|
|
33
|
-
* Called with the trigger's measured frame and the popover's own size; returns
|
|
34
|
-
* the offsets that bring it back on screen. A menu near the bottom edge flips
|
|
35
|
-
* above its trigger rather than hanging off the display.
|
|
36
|
-
*/
|
|
37
|
-
export function anchorPopover(
|
|
38
|
-
trigger: { x: number; y: number; width: number; height: number },
|
|
39
|
-
popover: { width: number; height: number },
|
|
40
|
-
viewport: { width: number; height: number },
|
|
41
|
-
gap = 6,
|
|
42
|
-
): { left: number; top: number; flipped: boolean } {
|
|
43
|
-
const below = trigger.y + trigger.height + gap;
|
|
44
|
-
const above = trigger.y - popover.height - gap;
|
|
45
|
-
const fitsBelow = below + popover.height <= viewport.height;
|
|
46
|
-
const flipped = !fitsBelow && above >= 0;
|
|
47
|
-
const top = Math.max(0, Math.min(flipped ? above : below, viewport.height - popover.height));
|
|
48
|
-
const left = Math.max(0, Math.min(trigger.x, viewport.width - popover.width));
|
|
49
|
-
return { left, top, flipped };
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// ---------------------------------------------------------------------------
|
|
53
|
-
// Menu
|
|
54
|
-
|
|
55
|
-
export interface MenuItem {
|
|
56
|
-
label: string;
|
|
57
|
-
onPress: () => void;
|
|
58
|
-
icon?: ReactNode;
|
|
59
|
-
disabled?: boolean;
|
|
60
|
-
/** Renders in the destructive tone, for delete-and-similar. */
|
|
61
|
-
destructive?: boolean;
|
|
62
|
-
accessibilityLabel?: string;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export interface MenuProps {
|
|
66
|
-
/** The control that opens the menu. */
|
|
67
|
-
trigger: ReactNode;
|
|
68
|
-
items: MenuItem[];
|
|
69
|
-
/** Controlled open state. Omit and the menu keeps its own. */
|
|
70
|
-
open?: boolean;
|
|
71
|
-
onOpenChange?: (open: boolean) => void;
|
|
72
|
-
/** The menu's width. The list scrolls if the items exceed the screen. */
|
|
73
|
-
width?: number;
|
|
74
|
-
accessibilityLabel?: string;
|
|
75
|
-
style?: StyleProp<ViewStyle>;
|
|
76
|
-
isDark?: boolean;
|
|
77
|
-
testID?: string;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* An anchored dropdown menu.
|
|
82
|
-
*
|
|
83
|
-
* A press outside or on an item closes it; Android's back button does too. The
|
|
84
|
-
* popover is a glass surface with `glassActive` rows, matching the way the
|
|
85
|
-
* library marks a tappable row rather than nesting another glass panel.
|
|
86
|
-
*/
|
|
87
|
-
export const Menu = forwardRef<any, MenuProps>(function Menu(
|
|
88
|
-
{
|
|
89
|
-
trigger,
|
|
90
|
-
items,
|
|
91
|
-
open: openProp,
|
|
92
|
-
onOpenChange,
|
|
93
|
-
width = 220,
|
|
94
|
-
accessibilityLabel = "Menu",
|
|
95
|
-
style,
|
|
96
|
-
isDark: isDarkProp,
|
|
97
|
-
testID,
|
|
98
|
-
...props
|
|
99
|
-
},
|
|
100
|
-
ref,
|
|
101
|
-
) {
|
|
102
|
-
const isDark = useIsDark(isDarkProp);
|
|
103
|
-
const theme = isDark ? colors.dark : colors.light;
|
|
104
|
-
const { View, Text: RNText, Pressable, Modal } = primitives();
|
|
105
|
-
|
|
106
|
-
const [internalOpen, setInternalOpen] = useState(false);
|
|
107
|
-
const open = openProp !== undefined ? openProp : internalOpen;
|
|
108
|
-
|
|
109
|
-
const setOpen = useCallback(
|
|
110
|
-
(next: boolean) => {
|
|
111
|
-
if (openProp === undefined) setInternalOpen(next);
|
|
112
|
-
onOpenChange?.(next);
|
|
113
|
-
},
|
|
114
|
-
[openProp, onOpenChange],
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
const dismiss = useCallback(() => setOpen(false), [setOpen]);
|
|
118
|
-
useBackDismiss(open, dismiss);
|
|
119
|
-
|
|
120
|
-
const { value: enter, animated } = useSpring(open ? 1 : 0, "snappy");
|
|
121
|
-
const scale = animated ? enter.interpolate({ inputRange: [0, 1], outputRange: [0.96, 1] }) : 1;
|
|
122
|
-
|
|
123
|
-
const popover = (
|
|
124
|
-
<Glass
|
|
125
|
-
effect="regular"
|
|
126
|
-
isDark={isDark}
|
|
127
|
-
testID={testID ? `${testID}-popover` : undefined}
|
|
128
|
-
style={{ width, borderRadius: radii.md, paddingVertical: 4, overflow: "hidden", ...(style as ViewStyle) }}
|
|
129
|
-
>
|
|
130
|
-
{items.map((item, index) => (
|
|
131
|
-
<Pressable
|
|
132
|
-
key={`${item.label}-${index}`}
|
|
133
|
-
accessibilityRole="button"
|
|
134
|
-
accessibilityLabel={item.accessibilityLabel ?? item.label}
|
|
135
|
-
accessibilityState={{ disabled: item.disabled }}
|
|
136
|
-
disabled={item.disabled}
|
|
137
|
-
onPress={() => {
|
|
138
|
-
setOpen(false);
|
|
139
|
-
item.onPress();
|
|
140
|
-
}}
|
|
141
|
-
style={{ flexDirection: "row", alignItems: "center", gap: 10, paddingVertical: 10, paddingHorizontal: 12, opacity: item.disabled ? 0.38 : 1 }}
|
|
142
|
-
>
|
|
143
|
-
{item.icon ? <View>{item.icon}</View> : null}
|
|
144
|
-
<RNText
|
|
145
|
-
numberOfLines={1}
|
|
146
|
-
style={{ fontSize: 15, color: item.destructive ? theme.destructive : theme.foreground }}
|
|
147
|
-
>
|
|
148
|
-
{item.label}
|
|
149
|
-
</RNText>
|
|
150
|
-
</Pressable>
|
|
151
|
-
))}
|
|
152
|
-
</Glass>
|
|
153
|
-
);
|
|
154
|
-
|
|
155
|
-
return (
|
|
156
|
-
<View ref={ref} style={{ alignSelf: "flex-start" }} {...props}>
|
|
157
|
-
<Pressable
|
|
158
|
-
accessibilityRole="button"
|
|
159
|
-
accessibilityLabel={accessibilityLabel}
|
|
160
|
-
accessibilityState={{ expanded: open }}
|
|
161
|
-
onPress={() => setOpen(!open)}
|
|
162
|
-
>
|
|
163
|
-
{trigger}
|
|
164
|
-
</Pressable>
|
|
165
|
-
|
|
166
|
-
<Modal visible={open} transparent animationType="fade" onRequestClose={dismiss}>
|
|
167
|
-
{/* The backdrop: any press outside the popover dismisses the menu. */}
|
|
168
|
-
<Pressable
|
|
169
|
-
accessibilityRole="button"
|
|
170
|
-
accessibilityLabel="Close menu"
|
|
171
|
-
onPress={dismiss}
|
|
172
|
-
style={{ flex: 1, backgroundColor: theme.scrim }}
|
|
173
|
-
>
|
|
174
|
-
<View style={{ flex: 1, alignItems: "center", justifyContent: "center", padding: 24 }}>
|
|
175
|
-
<Pressable accessibilityRole="none" onPress={() => {}}>
|
|
176
|
-
{animated ? (
|
|
177
|
-
<AnimatedScale scale={scale}>{popover}</AnimatedScale>
|
|
178
|
-
) : (
|
|
179
|
-
popover
|
|
180
|
-
)}
|
|
181
|
-
</Pressable>
|
|
182
|
-
</View>
|
|
183
|
-
</Pressable>
|
|
184
|
-
</Modal>
|
|
185
|
-
</View>
|
|
186
|
-
);
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
/** Wraps a popover in the entrance scale, which must land on an Animated.View. */
|
|
190
|
-
function AnimatedScale({ scale, children }: { scale: any; children: ReactNode }) {
|
|
191
|
-
const { Animated } = primitives();
|
|
192
|
-
return <Animated.View style={{ transform: [{ scale }] }}>{children}</Animated.View>;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// ---------------------------------------------------------------------------
|
|
196
|
-
// Sheet
|
|
197
|
-
|
|
198
|
-
export interface SheetProps {
|
|
199
|
-
/** Controlled visibility. Omit and the sheet keeps its own. */
|
|
200
|
-
open?: boolean;
|
|
201
|
-
defaultOpen?: boolean;
|
|
202
|
-
onOpenChange?: (open: boolean) => void;
|
|
203
|
-
title?: string;
|
|
204
|
-
children?: ReactNode;
|
|
205
|
-
footer?: ReactNode;
|
|
206
|
-
/** Tapping the scrim dismisses. */
|
|
207
|
-
dismissOnBackdropPress?: boolean;
|
|
208
|
-
/** The drag handle at the top of the panel. */
|
|
209
|
-
showHandle?: boolean;
|
|
210
|
-
/**
|
|
211
|
-
* Resting heights the sheet can settle at, smallest first. A number is
|
|
212
|
-
* points; a fraction below 1 is a share of the window height. With one
|
|
213
|
-
* point the sheet opens there; with several it can be dragged between them.
|
|
214
|
-
* Omitted, the sheet uses its own natural height.
|
|
215
|
-
*/
|
|
216
|
-
snapPoints?: number[];
|
|
217
|
-
/** Which snap point to open at. Defaults to the first. */
|
|
218
|
-
initialSnapIndex?: number;
|
|
219
|
-
/** Controlled snap point. Omit and the sheet tracks its own. */
|
|
220
|
-
snapIndex?: number;
|
|
221
|
-
onSnapIndexChange?: (index: number) => void;
|
|
222
|
-
/** Dragging below the lowest point dismisses instead of springing back. */
|
|
223
|
-
dismissOnSnapToBottom?: boolean;
|
|
224
|
-
/** Turns the drag gesture off, leaving press-and-back dismissal only. */
|
|
225
|
-
draggable?: boolean;
|
|
226
|
-
/** Opt out of the selection tick on snap changes. */
|
|
227
|
-
haptics?: boolean;
|
|
228
|
-
style?: StyleProp<ViewStyle>;
|
|
229
|
-
isDark?: boolean;
|
|
230
|
-
testID?: string;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* A bottom sheet.
|
|
235
|
-
*
|
|
236
|
-
* The general-purpose container: it slides up on the springs token, dismisses
|
|
237
|
-
* on a scrim press and on Android back. ActionSheet remains the action-menu
|
|
238
|
-
* specialisation of this shape; Sheet is for arbitrary content — a form, a
|
|
239
|
-
* calendar, a detail panel.
|
|
240
|
-
*/
|
|
241
|
-
/**
|
|
242
|
-
* Turns a snap point into a pixel height.
|
|
243
|
-
*
|
|
244
|
-
* A number under 1 is a fraction of the window; anything else is points. The
|
|
245
|
-
* result is clamped so a sheet can never be taller than the space it has.
|
|
246
|
-
*/
|
|
247
|
-
export function resolveSnapPoint(point: number, windowHeight: number): number {
|
|
248
|
-
const height = point > 0 && point < 1 ? point * windowHeight : point;
|
|
249
|
-
return Math.max(0, Math.min(height, windowHeight));
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* Picks the snap point nearest to where the user let go.
|
|
254
|
-
*
|
|
255
|
-
* `height` is how tall the sheet currently is. Ties go to the smaller sheet,
|
|
256
|
-
* so a small flick does not jump the panel to full height.
|
|
257
|
-
*/
|
|
258
|
-
export function nearestSnapPoint(heights: number[], height: number): number {
|
|
259
|
-
let best = 0;
|
|
260
|
-
let bestDistance = Number.POSITIVE_INFINITY;
|
|
261
|
-
heights.forEach((candidate, index) => {
|
|
262
|
-
const distance = Math.abs(candidate - height);
|
|
263
|
-
if (distance < bestDistance) {
|
|
264
|
-
bestDistance = distance;
|
|
265
|
-
best = index;
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
return best;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
export const Sheet = forwardRef<any, SheetProps>(function Sheet(
|
|
272
|
-
{
|
|
273
|
-
open: openProp,
|
|
274
|
-
defaultOpen = false,
|
|
275
|
-
onOpenChange,
|
|
276
|
-
title,
|
|
277
|
-
children,
|
|
278
|
-
footer,
|
|
279
|
-
dismissOnBackdropPress = true,
|
|
280
|
-
showHandle = true,
|
|
281
|
-
snapPoints,
|
|
282
|
-
initialSnapIndex = 0,
|
|
283
|
-
snapIndex: snapIndexProp,
|
|
284
|
-
onSnapIndexChange,
|
|
285
|
-
dismissOnSnapToBottom = false,
|
|
286
|
-
draggable = true,
|
|
287
|
-
haptics = true,
|
|
288
|
-
style,
|
|
289
|
-
isDark: isDarkProp,
|
|
290
|
-
testID,
|
|
291
|
-
...props
|
|
292
|
-
},
|
|
293
|
-
ref,
|
|
294
|
-
) {
|
|
295
|
-
const isDark = useIsDark(isDarkProp);
|
|
296
|
-
const theme = isDark ? colors.dark : colors.light;
|
|
297
|
-
const { View, Text: RNText, Pressable, Modal, PanResponder, useWindowDimensions } = primitives();
|
|
298
|
-
|
|
299
|
-
const [internalOpen, setInternalOpen] = useState(defaultOpen);
|
|
300
|
-
const open = openProp !== undefined ? openProp : internalOpen;
|
|
301
|
-
|
|
302
|
-
const setOpen = useCallback(
|
|
303
|
-
(next: boolean) => {
|
|
304
|
-
if (openProp === undefined) setInternalOpen(next);
|
|
305
|
-
onOpenChange?.(next);
|
|
306
|
-
},
|
|
307
|
-
[openProp, onOpenChange],
|
|
308
|
-
);
|
|
309
|
-
|
|
310
|
-
const dismiss = useCallback(() => setOpen(false), [setOpen]);
|
|
311
|
-
useBackDismiss(open, dismiss);
|
|
312
|
-
|
|
313
|
-
// Snap points in pixels, smallest first so index 0 is the shortest sheet.
|
|
314
|
-
const windowHeight = useWindowDimensions?.().height ?? 800;
|
|
315
|
-
const heights = useMemo(() => {
|
|
316
|
-
if (!snapPoints || snapPoints.length === 0) return [];
|
|
317
|
-
return snapPoints.map((point) => resolveSnapPoint(point, windowHeight)).sort((a, b) => a - b);
|
|
318
|
-
}, [snapPoints, windowHeight]);
|
|
319
|
-
|
|
320
|
-
const [internalSnap, setInternalSnap] = useState(initialSnapIndex);
|
|
321
|
-
const snapIndex = snapIndexProp !== undefined ? snapIndexProp : internalSnap;
|
|
322
|
-
const activeHeight = heights.length > 0 ? heights[Math.min(snapIndex, heights.length - 1)]! : null;
|
|
323
|
-
|
|
324
|
-
// Drag offset in pixels: 0 is resting at the active snap point, positive is
|
|
325
|
-
// dragged down. It resets to 0 after a release, because the settle either
|
|
326
|
-
// changes the snap index or dismisses.
|
|
327
|
-
const dragRef = useRef(0);
|
|
328
|
-
const [drag, setDrag] = useState(0);
|
|
329
|
-
|
|
330
|
-
const { value: rise, animated } = useSpring(open ? 1 : 0, "gentle");
|
|
331
|
-
const slideIn = animated ? rise.interpolate({ inputRange: [0, 1], outputRange: [420, 0] }) : 0;
|
|
332
|
-
|
|
333
|
-
const heightsRef = useRef(heights);
|
|
334
|
-
heightsRef.current = heights;
|
|
335
|
-
const activeHeightRef = useRef(activeHeight);
|
|
336
|
-
activeHeightRef.current = activeHeight;
|
|
337
|
-
const snapIndexRef = useRef(snapIndex);
|
|
338
|
-
snapIndexRef.current = snapIndex;
|
|
339
|
-
|
|
340
|
-
const goToSnap = useCallback(
|
|
341
|
-
(index: number) => {
|
|
342
|
-
if (snapIndexProp === undefined) setInternalSnap(index);
|
|
343
|
-
onSnapIndexChange?.(index);
|
|
344
|
-
if (haptics) hapticSelection();
|
|
345
|
-
},
|
|
346
|
-
[snapIndexProp, onSnapIndexChange, haptics],
|
|
347
|
-
);
|
|
348
|
-
|
|
349
|
-
/**
|
|
350
|
-
* The release decision.
|
|
351
|
-
*
|
|
352
|
-
* Below the lowest snap point the sheet dismisses when allowed, otherwise it
|
|
353
|
-
* snaps back; anywhere else it settles at the nearest point, with a fast
|
|
354
|
-
* downward flick counting as a step towards the smaller sheet.
|
|
355
|
-
*/
|
|
356
|
-
const release = useCallback(
|
|
357
|
-
(dy: number, vy: number) => {
|
|
358
|
-
const list = heightsRef.current;
|
|
359
|
-
const current = list[snapIndexRef.current] ?? activeHeightRef.current ?? 0;
|
|
360
|
-
const restingAfterDrag = current - dy;
|
|
361
|
-
|
|
362
|
-
if (list.length === 0) {
|
|
363
|
-
// No snap points: a decisive downward drag dismisses.
|
|
364
|
-
if (dy > 120 || vy > 0.8) dismiss();
|
|
365
|
-
return;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
const lowest = list[0]!;
|
|
369
|
-
const belowLowest = restingAfterDrag < lowest - 40;
|
|
370
|
-
if (belowLowest && dismissOnSnapToBottom) {
|
|
371
|
-
dismiss();
|
|
372
|
-
return;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
// A fast flick moves one step in its direction before distance decides.
|
|
376
|
-
let index = nearestSnapPoint(list, restingAfterDrag);
|
|
377
|
-
if (vy > 0.5) index = Math.max(0, Math.min(index, snapIndexRef.current - 1));
|
|
378
|
-
if (vy < -0.5) index = Math.max(index, Math.min(snapIndexRef.current + 1, list.length - 1));
|
|
379
|
-
|
|
380
|
-
if (index !== snapIndexRef.current) goToSnap(index);
|
|
381
|
-
},
|
|
382
|
-
[dismiss, dismissOnSnapToBottom, goToSnap],
|
|
383
|
-
);
|
|
384
|
-
|
|
385
|
-
const panResponder = useMemo(() => {
|
|
386
|
-
if (!draggable || !PanResponder?.create) return null;
|
|
387
|
-
return PanResponder.create({
|
|
388
|
-
// Vertical drags belong to the sheet; horizontal ones are left alone.
|
|
389
|
-
onStartShouldSetPanResponder: () => false,
|
|
390
|
-
onMoveShouldSetPanResponder: (_event: any, gesture: any) =>
|
|
391
|
-
Math.abs(gesture.dy) > Math.abs(gesture.dx) && Math.abs(gesture.dy) > 6,
|
|
392
|
-
onPanResponderGrant: () => {
|
|
393
|
-
dragRef.current = 0;
|
|
394
|
-
},
|
|
395
|
-
onPanResponderMove: (_event: any, gesture: any) => {
|
|
396
|
-
// Dragging up past the tallest point has nowhere to go; clamp at 0.
|
|
397
|
-
const next = Math.max(-40, gesture.dy);
|
|
398
|
-
dragRef.current = next;
|
|
399
|
-
setDrag(next);
|
|
400
|
-
},
|
|
401
|
-
onPanResponderRelease: (_event: any, gesture: any) => {
|
|
402
|
-
release(gesture.dy, gesture.vy);
|
|
403
|
-
dragRef.current = 0;
|
|
404
|
-
setDrag(0);
|
|
405
|
-
},
|
|
406
|
-
onPanResponderTerminate: () => {
|
|
407
|
-
dragRef.current = 0;
|
|
408
|
-
setDrag(0);
|
|
409
|
-
},
|
|
410
|
-
onPanResponderTerminationRequest: () => false,
|
|
411
|
-
});
|
|
412
|
-
}, [draggable, PanResponder, release]);
|
|
413
|
-
|
|
414
|
-
// Reduce Motion is honoured by useSpring: when it is on, `animated` is false
|
|
415
|
-
// and the panel is already in position, so the sheet opens and snaps without
|
|
416
|
-
// a transition.
|
|
417
|
-
const translateY = drag !== 0 ? drag : animated ? slideIn : 0;
|
|
418
|
-
|
|
419
|
-
const panel = (
|
|
420
|
-
<SheetPanel
|
|
421
|
-
title={title}
|
|
422
|
-
footer={footer}
|
|
423
|
-
showHandle={showHandle}
|
|
424
|
-
isDark={isDark}
|
|
425
|
-
testID={testID}
|
|
426
|
-
style={style}
|
|
427
|
-
height={activeHeight}
|
|
428
|
-
>
|
|
429
|
-
{children}
|
|
430
|
-
</SheetPanel>
|
|
431
|
-
);
|
|
432
|
-
|
|
433
|
-
return (
|
|
434
|
-
<Modal visible={open} transparent animationType="fade" onRequestClose={dismiss}>
|
|
435
|
-
<Pressable
|
|
436
|
-
accessibilityRole="button"
|
|
437
|
-
accessibilityLabel="Close sheet"
|
|
438
|
-
onPress={dismissOnBackdropPress ? dismiss : undefined}
|
|
439
|
-
style={{ flex: 1, justifyContent: "flex-end", backgroundColor: theme.scrim }}
|
|
440
|
-
>
|
|
441
|
-
<Pressable
|
|
442
|
-
accessibilityRole="none"
|
|
443
|
-
onPress={() => {}}
|
|
444
|
-
style={{ width: "100%" }}
|
|
445
|
-
{...(panResponder ? panResponder.panHandlers : {})}
|
|
446
|
-
>
|
|
447
|
-
{animated || drag !== 0 ? (
|
|
448
|
-
<SheetRise translateY={translateY}>{panel}</SheetRise>
|
|
449
|
-
) : (
|
|
450
|
-
panel
|
|
451
|
-
)}
|
|
452
|
-
</Pressable>
|
|
453
|
-
</Pressable>
|
|
454
|
-
</Modal>
|
|
455
|
-
);
|
|
456
|
-
});
|
|
457
|
-
|
|
458
|
-
function SheetRise({ translateY, children }: { translateY: any; children: ReactNode }) {
|
|
459
|
-
const { Animated } = primitives();
|
|
460
|
-
return <Animated.View style={{ transform: [{ translateY }] }}>{children}</Animated.View>;
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
/** The panel itself: a glass surface with a handle, a title and a footer. */
|
|
464
|
-
function SheetPanel({
|
|
465
|
-
title,
|
|
466
|
-
footer,
|
|
467
|
-
showHandle,
|
|
468
|
-
isDark,
|
|
469
|
-
testID,
|
|
470
|
-
style,
|
|
471
|
-
height,
|
|
472
|
-
children,
|
|
473
|
-
}: {
|
|
474
|
-
title?: string;
|
|
475
|
-
footer?: ReactNode;
|
|
476
|
-
showHandle: boolean;
|
|
477
|
-
isDark: boolean;
|
|
478
|
-
testID?: string;
|
|
479
|
-
style?: StyleProp<ViewStyle>;
|
|
480
|
-
/** The snap point's height, or null for the panel's natural height. */
|
|
481
|
-
height?: number | null;
|
|
482
|
-
children?: ReactNode;
|
|
483
|
-
}) {
|
|
484
|
-
const theme = isDark ? colors.dark : colors.light;
|
|
485
|
-
const { View, Text: RNText } = primitives();
|
|
486
|
-
|
|
487
|
-
return (
|
|
488
|
-
<Glass
|
|
489
|
-
effect="regular"
|
|
490
|
-
isDark={isDark}
|
|
491
|
-
testID={testID}
|
|
492
|
-
style={{
|
|
493
|
-
borderTopLeftRadius: radii.xl,
|
|
494
|
-
borderTopRightRadius: radii.xl,
|
|
495
|
-
borderBottomLeftRadius: 0,
|
|
496
|
-
borderBottomRightRadius: 0,
|
|
497
|
-
paddingBottom: 20,
|
|
498
|
-
// A snap point fixes the height; without one the panel is natural.
|
|
499
|
-
...(height != null ? { height } : { maxHeight: 560 }),
|
|
500
|
-
...(style as ViewStyle),
|
|
501
|
-
}}
|
|
502
|
-
>
|
|
503
|
-
{showHandle ? (
|
|
504
|
-
<View style={{ alignItems: "center", paddingTop: 8, paddingBottom: 4 }}>
|
|
505
|
-
<View
|
|
506
|
-
accessibilityElementsHidden
|
|
507
|
-
// A capsule: the radius is half the handle's own height.
|
|
508
|
-
style={{ width: 36, height: 5, borderRadius: 5 / 2, backgroundColor: theme.separator }}
|
|
509
|
-
/>
|
|
510
|
-
</View>
|
|
511
|
-
) : null}
|
|
512
|
-
{title ? (
|
|
513
|
-
<View style={{ paddingHorizontal: 20, paddingVertical: 10 }}>
|
|
514
|
-
<RNText accessibilityRole="heading" style={{ fontSize: 17, fontWeight: "600", color: theme.foreground }}>
|
|
515
|
-
{title}
|
|
516
|
-
</RNText>
|
|
517
|
-
</View>
|
|
518
|
-
) : null}
|
|
519
|
-
<View style={{ paddingHorizontal: 20 }}>{children}</View>
|
|
520
|
-
{footer ? <View style={{ paddingHorizontal: 20, paddingTop: 12, gap: 8 }}>{footer}</View> : null}
|
|
521
|
-
</Glass>
|
|
522
|
-
);
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
// ---------------------------------------------------------------------------
|
|
526
|
-
// Drawer
|
|
527
|
-
|
|
528
|
-
export interface DrawerProps {
|
|
529
|
-
/** Controlled visibility. Omit and the drawer keeps its own. */
|
|
530
|
-
open?: boolean;
|
|
531
|
-
defaultOpen?: boolean;
|
|
532
|
-
onOpenChange?: (open: boolean) => void;
|
|
533
|
-
/** The edge the panel slides in from. */
|
|
534
|
-
side?: "left" | "right";
|
|
535
|
-
/** Panel width. */
|
|
536
|
-
width?: number;
|
|
537
|
-
children?: ReactNode;
|
|
538
|
-
/** Tapping the scrim dismisses. */
|
|
539
|
-
dismissOnBackdropPress?: boolean;
|
|
540
|
-
/** Turns the drag-to-close gesture off. */
|
|
541
|
-
draggable?: boolean;
|
|
542
|
-
/** Opt out of the selection tick when the drawer is thrown closed. */
|
|
543
|
-
haptics?: boolean;
|
|
544
|
-
style?: StyleProp<ViewStyle>;
|
|
545
|
-
isDark?: boolean;
|
|
546
|
-
testID?: string;
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
/**
|
|
550
|
-
* A side navigation drawer.
|
|
551
|
-
*
|
|
552
|
-
* The same overlay discipline as Sheet — scrim, spring slide, Android back —
|
|
553
|
-
* but anchored to a side edge, with a square panel that runs the full height.
|
|
554
|
-
* The caller supplies the content, typically a List.
|
|
555
|
-
*
|
|
556
|
-
* Dragging the panel towards its own edge follows the finger; releasing past
|
|
557
|
-
* the halfway point, or with enough outward velocity, closes it, and a drag
|
|
558
|
-
* that stays inside springs it back open. Reduce Motion is honoured: with it
|
|
559
|
-
* on, the drawer appears and disappears without sliding.
|
|
560
|
-
*/
|
|
561
|
-
export const Drawer = forwardRef<any, DrawerProps>(function Drawer(
|
|
562
|
-
{
|
|
563
|
-
open: openProp,
|
|
564
|
-
defaultOpen = false,
|
|
565
|
-
onOpenChange,
|
|
566
|
-
side = "left",
|
|
567
|
-
width = 280,
|
|
568
|
-
children,
|
|
569
|
-
dismissOnBackdropPress = true,
|
|
570
|
-
draggable = true,
|
|
571
|
-
haptics = true,
|
|
572
|
-
style,
|
|
573
|
-
isDark: isDarkProp,
|
|
574
|
-
testID,
|
|
575
|
-
...props
|
|
576
|
-
},
|
|
577
|
-
ref,
|
|
578
|
-
) {
|
|
579
|
-
const isDark = useIsDark(isDarkProp);
|
|
580
|
-
const theme = isDark ? colors.dark : colors.light;
|
|
581
|
-
const { View, Pressable, Modal, PanResponder } = primitives();
|
|
582
|
-
|
|
583
|
-
const [internalOpen, setInternalOpen] = useState(defaultOpen);
|
|
584
|
-
const open = openProp !== undefined ? openProp : internalOpen;
|
|
585
|
-
|
|
586
|
-
const setOpen = useCallback(
|
|
587
|
-
(next: boolean) => {
|
|
588
|
-
if (openProp === undefined) setInternalOpen(next);
|
|
589
|
-
onOpenChange?.(next);
|
|
590
|
-
},
|
|
591
|
-
[openProp, onOpenChange],
|
|
592
|
-
);
|
|
593
|
-
|
|
594
|
-
const dismiss = useCallback(() => setOpen(false), [setOpen]);
|
|
595
|
-
useBackDismiss(open, dismiss);
|
|
596
|
-
|
|
597
|
-
const { value: slide, animated } = useSpring(open ? 1 : 0, "gentle");
|
|
598
|
-
// Slide in from off-screen: negative from the left, positive from the right.
|
|
599
|
-
const slideIn = animated
|
|
600
|
-
? slide.interpolate({ inputRange: [0, 1], outputRange: [side === "left" ? -width : width, 0] })
|
|
601
|
-
: 0;
|
|
602
|
-
|
|
603
|
-
// The drag is measured in the drawer's own closing direction, so a drag
|
|
604
|
-
// towards the anchored edge is always positive whichever side it is on.
|
|
605
|
-
const [drag, setDrag] = useState(0);
|
|
606
|
-
|
|
607
|
-
const panResponder = useMemo(() => {
|
|
608
|
-
if (!draggable || !PanResponder?.create) return null;
|
|
609
|
-
const outward = side === "left" ? -1 : 1;
|
|
610
|
-
return PanResponder.create({
|
|
611
|
-
onStartShouldSetPanResponder: () => false,
|
|
612
|
-
onMoveShouldSetPanResponder: (_event: any, gesture: any) =>
|
|
613
|
-
// Only a horizontal drag towards the edge is ours; the other way has
|
|
614
|
-
// nowhere to go and should not fight content inside the panel.
|
|
615
|
-
Math.abs(gesture.dx) > Math.abs(gesture.dy) && gesture.dx * outward > 6,
|
|
616
|
-
onPanResponderMove: (_event: any, gesture: any) => {
|
|
617
|
-
setDrag(Math.max(0, gesture.dx * outward));
|
|
618
|
-
},
|
|
619
|
-
onPanResponderRelease: (_event: any, gesture: any) => {
|
|
620
|
-
const travelled = Math.max(0, gesture.dx * outward);
|
|
621
|
-
const thrown = gesture.vx * outward > 0.4;
|
|
622
|
-
setDrag(0);
|
|
623
|
-
if (travelled > width / 2 || thrown) {
|
|
624
|
-
if (haptics) hapticSelection();
|
|
625
|
-
dismiss();
|
|
626
|
-
}
|
|
627
|
-
},
|
|
628
|
-
onPanResponderTerminate: () => setDrag(0),
|
|
629
|
-
onPanResponderTerminationRequest: () => false,
|
|
630
|
-
});
|
|
631
|
-
// `dismiss` is stable; the gesture only needs rebuilding when its shape
|
|
632
|
-
// (side or width) changes.
|
|
633
|
-
}, [draggable, PanResponder, side, width, haptics, dismiss]);
|
|
634
|
-
|
|
635
|
-
const translateX = drag !== 0 ? (side === "left" ? -drag : drag) : animated ? slideIn : 0;
|
|
636
|
-
|
|
637
|
-
const panel = (
|
|
638
|
-
<Glass
|
|
639
|
-
effect="regular"
|
|
640
|
-
isDark={isDark}
|
|
641
|
-
testID={testID}
|
|
642
|
-
style={{
|
|
643
|
-
width,
|
|
644
|
-
height: "100%",
|
|
645
|
-
borderRadius: 0,
|
|
646
|
-
paddingTop: 56,
|
|
647
|
-
...(style as ViewStyle),
|
|
648
|
-
}}
|
|
649
|
-
>
|
|
650
|
-
{children}
|
|
651
|
-
</Glass>
|
|
652
|
-
);
|
|
653
|
-
|
|
654
|
-
return (
|
|
655
|
-
<Modal visible={open} transparent animationType="fade" onRequestClose={dismiss}>
|
|
656
|
-
<Pressable
|
|
657
|
-
accessibilityRole="button"
|
|
658
|
-
accessibilityLabel="Close drawer"
|
|
659
|
-
onPress={dismissOnBackdropPress ? dismiss : undefined}
|
|
660
|
-
style={{ flex: 1, backgroundColor: theme.scrim }}
|
|
661
|
-
>
|
|
662
|
-
<View
|
|
663
|
-
style={{
|
|
664
|
-
flex: 1,
|
|
665
|
-
alignItems: side === "left" ? "flex-start" : "flex-end",
|
|
666
|
-
}}
|
|
667
|
-
>
|
|
668
|
-
<Pressable
|
|
669
|
-
accessibilityRole="none"
|
|
670
|
-
onPress={() => {}}
|
|
671
|
-
style={{ height: "100%" }}
|
|
672
|
-
{...(panResponder ? panResponder.panHandlers : {})}
|
|
673
|
-
>
|
|
674
|
-
{animated || drag !== 0 ? <DrawerSlide translateX={translateX}>{panel}</DrawerSlide> : panel}
|
|
675
|
-
</Pressable>
|
|
676
|
-
</View>
|
|
677
|
-
</Pressable>
|
|
678
|
-
</Modal>
|
|
679
|
-
);
|
|
680
|
-
});
|
|
681
|
-
|
|
682
|
-
function DrawerSlide({ translateX, children }: { translateX: any; children: ReactNode }) {
|
|
683
|
-
const { Animated } = primitives();
|
|
684
|
-
return <Animated.View style={{ height: "100%", transform: [{ translateX }] }}>{children}</Animated.View>;
|
|
685
|
-
}
|