glacia-native 0.5.2 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +84 -17
- package/lib/module/Accordion.js +58 -0
- package/lib/module/ActionSheet.js +38 -0
- package/lib/module/Alert.js +23 -0
- package/lib/module/AlertDialog.js +47 -0
- package/lib/module/Avatar.js +48 -0
- package/lib/module/Badge.js +36 -0
- package/lib/module/Bars.js +13 -268
- package/lib/module/Button.js +57 -39
- package/lib/module/Card.js +31 -19
- package/lib/module/Checkbox.js +42 -0
- package/lib/module/Chip.js +80 -0
- package/lib/module/Collapsible.js +26 -0
- package/lib/module/ContextMenu.js +33 -0
- package/lib/module/Dialog.js +39 -123
- package/lib/module/DropdownMenu.js +33 -0
- package/lib/module/Field.js +22 -0
- package/lib/module/Glass.js +10 -3
- package/lib/module/Group.js +36 -0
- package/lib/module/IconButton.js +40 -0
- package/lib/module/Input.js +43 -38
- package/lib/module/Label.js +17 -0
- package/lib/module/MorphGroup.js +47 -0
- package/lib/module/Popover.js +29 -0
- package/lib/module/Progress.js +32 -0
- package/lib/module/RadioGroup.js +51 -0
- package/lib/module/Scrim.js +44 -0
- package/lib/module/SegmentedControl.js +70 -63
- package/lib/module/Select.js +51 -0
- package/lib/module/Separator.js +25 -0
- package/lib/module/Sheet.js +51 -0
- package/lib/module/Skeleton.js +48 -0
- package/lib/module/Slider.js +45 -34
- package/lib/module/Stepper.js +167 -0
- package/lib/module/Switch.js +45 -55
- package/lib/module/TabBar.js +50 -44
- package/lib/module/Textarea.js +18 -0
- package/lib/module/Toast.js +55 -0
- package/lib/module/Toggle.js +47 -0
- package/lib/module/ToggleGroup.js +56 -0
- package/lib/module/Toolbar.js +37 -0
- package/lib/module/Tooltip.js +31 -0
- package/lib/module/glass-provider.js +28 -0
- package/lib/module/glass-stack.js +61 -0
- package/lib/module/index.js +78 -109
- package/lib/module/internal/GlassBackdrop.js +36 -0
- package/lib/module/internal/GlassView.js +43 -11
- package/lib/module/internal/blur-community.js +20 -0
- package/lib/module/internal/blur-community.web.js +9 -0
- package/lib/module/internal/blur.js +6 -9
- package/lib/module/internal/glass-routing.js +156 -30
- package/lib/module/internal/initials.js +12 -0
- package/lib/module/internal/overlay.js +147 -0
- package/lib/module/internal/primitives.js +16 -0
- package/lib/typescript/Accordion.d.ts +22 -0
- package/lib/typescript/ActionSheet.d.ts +24 -0
- package/lib/typescript/Alert.d.ts +15 -0
- package/lib/typescript/AlertDialog.d.ts +17 -0
- package/lib/typescript/Avatar.d.ts +22 -0
- package/lib/typescript/Badge.d.ts +12 -0
- package/lib/typescript/Bars.d.ts +3 -188
- package/lib/typescript/Button.d.ts +44 -10
- package/lib/typescript/Card.d.ts +30 -3
- package/lib/typescript/Checkbox.d.ts +14 -0
- package/lib/typescript/Chip.d.ts +19 -0
- package/lib/typescript/Collapsible.d.ts +17 -0
- package/lib/typescript/ContextMenu.d.ts +23 -0
- package/lib/typescript/Dialog.d.ts +8 -68
- package/lib/typescript/DropdownMenu.d.ts +23 -0
- package/lib/typescript/Field.d.ts +19 -0
- package/lib/typescript/Glass.d.ts +11 -2
- package/lib/typescript/Group.d.ts +35 -0
- package/lib/typescript/IconButton.d.ts +21 -0
- package/lib/typescript/Input.d.ts +17 -18
- package/lib/typescript/Label.d.ts +14 -0
- package/lib/typescript/MorphGroup.d.ts +46 -0
- package/lib/typescript/Popover.d.ts +17 -0
- package/lib/typescript/Progress.d.ts +13 -0
- package/lib/typescript/RadioGroup.d.ts +21 -0
- package/lib/typescript/Scrim.d.ts +33 -0
- package/lib/typescript/SegmentedControl.d.ts +24 -13
- package/lib/typescript/Select.d.ts +19 -0
- package/lib/typescript/Separator.d.ts +10 -0
- package/lib/typescript/Sheet.d.ts +45 -0
- package/lib/typescript/Skeleton.d.ts +10 -0
- package/lib/typescript/Slider.d.ts +15 -7
- package/lib/typescript/Stepper.d.ts +49 -0
- package/lib/typescript/Switch.d.ts +19 -12
- package/lib/typescript/TabBar.d.ts +18 -6
- package/lib/typescript/Textarea.d.ts +6 -0
- package/lib/typescript/Toast.d.ts +40 -0
- package/lib/typescript/Toggle.d.ts +21 -0
- package/lib/typescript/ToggleGroup.d.ts +22 -0
- package/lib/typescript/Toolbar.d.ts +35 -0
- package/lib/typescript/Tooltip.d.ts +16 -0
- package/lib/typescript/glass-provider.d.ts +34 -0
- package/lib/typescript/glass-stack.d.ts +54 -0
- package/lib/typescript/index.d.ts +38 -17
- package/lib/typescript/internal/GlassBackdrop.d.ts +33 -0
- package/lib/typescript/internal/GlassView.d.ts +18 -2
- package/lib/typescript/internal/blur-community.d.ts +2 -0
- package/lib/typescript/internal/blur-community.web.d.ts +2 -0
- package/lib/typescript/internal/glass-routing.d.ts +83 -15
- package/lib/typescript/internal/initials.d.ts +2 -0
- package/lib/typescript/internal/overlay.d.ts +74 -0
- package/lib/typescript/internal/primitives.d.ts +11 -0
- package/package.json +12 -10
- package/src/Accordion.tsx +165 -0
- package/src/ActionSheet.tsx +149 -0
- package/src/Alert.tsx +85 -0
- package/src/AlertDialog.tsx +124 -0
- package/src/Avatar.tsx +102 -0
- package/src/Badge.tsx +80 -0
- package/src/Bars.tsx +10 -807
- package/src/Button.tsx +196 -67
- package/src/Card.tsx +105 -32
- package/src/Checkbox.tsx +98 -0
- package/src/Chip.tsx +149 -0
- package/src/Collapsible.tsx +66 -0
- package/src/ContextMenu.tsx +103 -0
- package/src/Dialog.tsx +85 -335
- package/src/DropdownMenu.tsx +103 -0
- package/src/Field.tsx +65 -0
- package/src/Glass.tsx +15 -5
- package/src/Group.tsx +98 -0
- package/src/IconButton.tsx +110 -0
- package/src/Input.tsx +139 -87
- package/src/Label.tsx +56 -0
- package/src/MorphGroup.tsx +134 -0
- package/src/Popover.tsx +81 -0
- package/src/Progress.tsx +83 -0
- package/src/RadioGroup.tsx +122 -0
- package/src/Scrim.tsx +94 -0
- package/src/SegmentedControl.tsx +132 -99
- package/src/Select.tsx +136 -0
- package/src/Separator.tsx +52 -0
- package/src/Sheet.tsx +139 -0
- package/src/Skeleton.tsx +77 -0
- package/src/Slider.tsx +84 -47
- package/src/Stepper.tsx +315 -0
- package/src/Switch.tsx +81 -73
- package/src/TabBar.tsx +106 -93
- package/src/Textarea.tsx +34 -0
- package/src/Toast.tsx +131 -0
- package/src/Toggle.tsx +113 -0
- package/src/ToggleGroup.tsx +129 -0
- package/src/Toolbar.tsx +111 -0
- package/src/Tooltip.tsx +79 -0
- package/src/engine/CHANGELOG.md +430 -0
- package/src/engine/NOTICE +54 -0
- package/src/engine/README.md +975 -0
- package/src/engine/android/build.gradle +18 -0
- package/src/engine/android/src/main/AndroidManifest.xml +2 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/ExpoLiquidGlassModule.kt +174 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/GlassConstants.kt +7 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassContainerView.kt +16 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassProviderView.kt +165 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassView.kt +1731 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/enums/GlassEnums.kt +171 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/BackdropGraph.kt +146 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/BackdropSource.kt +53 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/ContinuousCorners.kt +188 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/CornerRadii.kt +62 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassAppearance.kt +352 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassDebug.kt +109 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassEnvironment.kt +139 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassHdr.kt +85 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassLuminanceProbe.kt +189 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassPressAnimator.kt +264 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassProgressiveBlur.kt +249 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassShaderCache.kt +256 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassShaderSource.kt +845 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassTier.kt +63 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/ProviderRegistry.kt +71 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/records/GlassRecords.kt +288 -0
- package/src/engine/index.ts +24 -0
- package/src/engine/ios/Enums/GlassBlurDirection.swift +21 -0
- package/src/engine/ios/Enums/GlassVariant.swift +86 -0
- package/src/engine/ios/ExpoLiquidGlass.podspec +93 -0
- package/src/engine/ios/ExpoLiquidGlassModule.swift +77 -0
- package/src/engine/ios/Glass/BackdropCapturer.swift +811 -0
- package/src/engine/ios/Glass/ContinuousCorners.swift +165 -0
- package/src/engine/ios/Glass/GlassBackdrop.swift +176 -0
- package/src/engine/ios/Glass/GlassFramePhase.swift +126 -0
- package/src/engine/ios/Glass/GlassFrameScheduler.swift +261 -0
- package/src/engine/ios/Glass/GlassPressAnimator.swift +250 -0
- package/src/engine/ios/Glass/GlassRenderContext.swift +168 -0
- package/src/engine/ios/Glass/GlassRenderer.swift +186 -0
- package/src/engine/ios/Glass/GlassSurfaceView.swift +452 -0
- package/src/engine/ios/Glass/NonRenderableView.swift +54 -0
- package/src/engine/ios/Glass/StripCache.swift +545 -0
- package/src/engine/ios/Records/GlassCornerRadii.swift +79 -0
- package/src/engine/ios/Records/GlassMetalOptions.swift +180 -0
- package/src/engine/ios/Records/GlassRefractionCurve.swift +14 -0
- package/src/engine/ios/Shaders/LiquidGlass.metal +480 -0
- package/src/engine/ios/Shaders/bundle-marker.txt +6 -0
- package/src/engine/ios/Views/LiquidGlassContainerView.swift +99 -0
- package/src/engine/ios/Views/LiquidGlassView.swift +859 -0
- package/src/engine/package.json +70 -0
- package/src/engine/src/components/LiquidGlassButton/LiquidGlassButton.tsx +424 -0
- package/src/engine/src/components/LiquidGlassCard/LiquidGlassCard.tsx +98 -0
- package/src/engine/src/components/LiquidGlassChip/LiquidGlassChip.tsx +65 -0
- package/src/engine/src/components/LiquidGlassGroup/LiquidGlassGroup.tsx +350 -0
- package/src/engine/src/components/LiquidGlassIconButton/LiquidGlassIconButton.tsx +24 -0
- package/src/engine/src/components/LiquidGlassMorphGroup/LiquidGlassMorphGroup.tsx +434 -0
- package/src/engine/src/components/LiquidGlassScrim/LiquidGlassScrim.tsx +100 -0
- package/src/engine/src/components/LiquidGlassSegmentedControl/LiquidGlassSegmentedControl.tsx +213 -0
- package/src/engine/src/components/LiquidGlassSheet/LiquidGlassSheet.tsx +218 -0
- package/src/engine/src/components/LiquidGlassSlider/LiquidGlassSlider.tsx +327 -0
- package/src/engine/src/components/LiquidGlassStepper/LiquidGlassStepper.tsx +321 -0
- package/src/engine/src/components/LiquidGlassSwitch/LiquidGlassSwitch.tsx +296 -0
- package/src/engine/src/components/LiquidGlassTabBar/LiquidGlassTabBar.tsx +952 -0
- package/src/engine/src/components/LiquidGlassTextInput/LiquidGlassTextInput.tsx +151 -0
- package/src/engine/src/components/LiquidGlassToast/LiquidGlassToast.tsx +169 -0
- package/src/engine/src/components/LiquidGlassToolbar/LiquidGlassToolbar.tsx +124 -0
- package/src/engine/src/components/index.ts +16 -0
- package/src/engine/src/constants/index.ts +4 -0
- package/src/engine/src/constants/metal.constants.ts +327 -0
- package/src/engine/src/constants/metrics.constants.ts +325 -0
- package/src/engine/src/constants/springs.constants.ts +107 -0
- package/src/engine/src/constants/styles.constants.ts +12 -0
- package/src/engine/src/context/glass-group.context.ts +65 -0
- package/src/engine/src/context/index.ts +6 -0
- package/src/engine/src/core/components/LiquidGlassContainer/LiquidGlassContainer.tsx +32 -0
- package/src/engine/src/core/components/LiquidGlassContainer/index.ts +1 -0
- package/src/engine/src/core/components/LiquidGlassProvider/LiquidGlassProvider.tsx +66 -0
- package/src/engine/src/core/components/LiquidGlassProvider/index.ts +1 -0
- package/src/engine/src/core/components/LiquidGlassStack/LiquidGlassStack.tsx +184 -0
- package/src/engine/src/core/components/LiquidGlassStack/index.ts +1 -0
- package/src/engine/src/core/components/LiquidGlassView/LiquidGlassView.tsx +126 -0
- package/src/engine/src/core/components/LiquidGlassView/index.ts +1 -0
- package/src/engine/src/core/components/index.ts +4 -0
- package/src/engine/src/core/constants/glass.constants.ts +57 -0
- package/src/engine/src/core/constants/index.ts +20 -0
- package/src/engine/src/core/constants/native.constants.ts +16 -0
- package/src/engine/src/core/context/glass-stack.context.ts +30 -0
- package/src/engine/src/core/context/index.ts +4 -0
- package/src/engine/src/core/enum/index.ts +12 -0
- package/src/engine/src/core/index.ts +1 -0
- package/src/engine/src/core/interfaces/glass-hdr.interface.ts +15 -0
- package/src/engine/src/core/interfaces/glass-metal.interface.ts +248 -0
- package/src/engine/src/core/interfaces/glass-surface.interface.ts +9 -0
- package/src/engine/src/core/interfaces/index.ts +31 -0
- package/src/engine/src/core/interfaces/liquid-glass-container.interface.ts +6 -0
- package/src/engine/src/core/interfaces/liquid-glass-provider.interface.ts +14 -0
- package/src/engine/src/core/interfaces/liquid-glass-stack.interface.ts +21 -0
- package/src/engine/src/core/interfaces/liquid-glass-view.interface.ts +129 -0
- package/src/engine/src/core/interfaces/native-liquid-glass-view.interface.ts +19 -0
- package/src/engine/src/core/modules/ExpoLiquidGlassModule.ts +26 -0
- package/src/engine/src/core/modules/index.ts +2 -0
- package/src/engine/src/core/root/index.ts +51 -0
- package/src/engine/src/core/types/glass.types.ts +25 -0
- package/src/engine/src/core/types/index.ts +8 -0
- package/src/engine/src/core/utils/debug.utils.ts +17 -0
- package/src/engine/src/core/utils/dev-warn.utils.ts +17 -0
- package/src/engine/src/core/utils/hdr.utils.ts +37 -0
- package/src/engine/src/core/utils/index.ts +5 -0
- package/src/engine/src/core/utils/native-view.utils.ts +33 -0
- package/src/engine/src/core/utils/platform.utils.ts +34 -0
- package/src/engine/src/core/views/NativeGlassBackdropView.ts +24 -0
- package/src/engine/src/core/views/NativeLiquidGlassContainerView.ts +13 -0
- package/src/engine/src/core/views/NativeLiquidGlassContainerView.web.ts +10 -0
- package/src/engine/src/core/views/NativeLiquidGlassProviderView.ts +13 -0
- package/src/engine/src/core/views/NativeLiquidGlassProviderView.web.ts +10 -0
- package/src/engine/src/core/views/NativeLiquidGlassView.ts +19 -0
- package/src/engine/src/core/views/NativeLiquidGlassView.web.ts +14 -0
- package/src/engine/src/core/views/index.ts +4 -0
- package/src/engine/src/hooks/index.ts +18 -0
- package/src/engine/src/hooks/use-adaptive-glass.ts +91 -0
- package/src/engine/src/hooks/use-damped-drag.ts +332 -0
- package/src/engine/src/hooks/use-echo-filter.ts +55 -0
- package/src/engine/src/hooks/use-glass-group-member.ts +169 -0
- package/src/engine/src/hooks/use-gravity-highlight.ts +79 -0
- package/src/engine/src/hooks/use-press-progress.ts +44 -0
- package/src/engine/src/index.ts +120 -0
- package/src/engine/src/interfaces/index.ts +28 -0
- package/src/engine/src/interfaces/liquid-glass-button.interface.ts +94 -0
- package/src/engine/src/interfaces/liquid-glass-card.interface.ts +40 -0
- package/src/engine/src/interfaces/liquid-glass-chip.interface.ts +29 -0
- package/src/engine/src/interfaces/liquid-glass-group.interface.ts +32 -0
- package/src/engine/src/interfaces/liquid-glass-icon-button.interface.ts +19 -0
- package/src/engine/src/interfaces/liquid-glass-morph-group.interface.ts +59 -0
- package/src/engine/src/interfaces/liquid-glass-scrim.interface.ts +36 -0
- package/src/engine/src/interfaces/liquid-glass-segmented-control.interface.ts +32 -0
- package/src/engine/src/interfaces/liquid-glass-sheet.interface.ts +38 -0
- package/src/engine/src/interfaces/liquid-glass-slider.interface.ts +37 -0
- package/src/engine/src/interfaces/liquid-glass-stepper.interface.ts +35 -0
- package/src/engine/src/interfaces/liquid-glass-switch.interface.ts +27 -0
- package/src/engine/src/interfaces/liquid-glass-tab-bar.interface.ts +116 -0
- package/src/engine/src/interfaces/liquid-glass-text-input.interface.ts +42 -0
- package/src/engine/src/interfaces/liquid-glass-toast.interface.ts +36 -0
- package/src/engine/src/interfaces/liquid-glass-toolbar.interface.ts +33 -0
- package/src/engine/src/theme/glass-ui-theme.ts +100 -0
- package/src/engine/src/theme/index.ts +2 -0
- package/src/engine/src/utils/button-press.utils.ts +63 -0
- package/src/engine/src/utils/index.ts +3 -0
- package/src/engine/src/utils/metal.utils.ts +164 -0
- package/src/glass-provider.tsx +60 -0
- package/src/glass-stack.tsx +115 -0
- package/src/index.ts +47 -190
- package/src/internal/GlassBackdrop.tsx +60 -0
- package/src/internal/GlassView.tsx +53 -18
- package/src/internal/blur-community.ts +19 -0
- package/src/internal/blur-community.web.ts +7 -0
- package/src/internal/blur.ts +7 -8
- package/src/internal/glass-routing.ts +212 -34
- package/src/internal/initials.ts +7 -0
- package/src/internal/overlay.tsx +258 -0
- package/src/internal/primitives.ts +23 -0
- package/lib/module/Carousel.js +0 -103
- package/lib/module/Display.js +0 -318
- package/lib/module/Feedback.js +0 -395
- package/lib/module/Form.js +0 -160
- package/lib/module/Forms2.js +0 -471
- package/lib/module/Message.js +0 -84
- package/lib/module/Overlays.js +0 -344
- package/lib/module/Pickers.js +0 -243
- package/lib/module/Table.js +0 -100
- package/lib/module/ai.js +0 -283
- package/lib/module/charts/AreaChart.js +0 -32
- package/lib/module/charts/BarChart.js +0 -75
- package/lib/module/charts/FunnelChart.js +0 -50
- package/lib/module/charts/HeatmapChart.js +0 -71
- package/lib/module/charts/LineChart.js +0 -81
- package/lib/module/charts/PlotChart.js +0 -52
- package/lib/module/charts/RadarChart.js +0 -78
- package/lib/module/charts/RingChart.js +0 -52
- package/lib/module/charts/ScatterChart.js +0 -95
- package/lib/module/charts/WaterfallChart.js +0 -85
- package/lib/module/charts/advanced.js +0 -313
- package/lib/module/charts/extra.js +0 -108
- package/lib/module/charts/index.js +0 -50
- package/lib/module/charts/scales.js +0 -140
- package/lib/typescript/Carousel.d.ts +0 -47
- package/lib/typescript/Display.d.ts +0 -178
- package/lib/typescript/Feedback.d.ts +0 -196
- package/lib/typescript/Form.d.ts +0 -97
- package/lib/typescript/Forms2.d.ts +0 -209
- package/lib/typescript/Message.d.ts +0 -67
- package/lib/typescript/Overlays.d.ts +0 -146
- package/lib/typescript/Pickers.d.ts +0 -105
- package/lib/typescript/Table.d.ts +0 -64
- package/lib/typescript/ai.d.ts +0 -166
- package/lib/typescript/charts/AreaChart.d.ts +0 -44
- package/lib/typescript/charts/BarChart.d.ts +0 -19
- package/lib/typescript/charts/FunnelChart.d.ts +0 -25
- package/lib/typescript/charts/HeatmapChart.d.ts +0 -23
- package/lib/typescript/charts/LineChart.d.ts +0 -30
- package/lib/typescript/charts/PlotChart.d.ts +0 -31
- package/lib/typescript/charts/RadarChart.d.ts +0 -27
- package/lib/typescript/charts/RingChart.d.ts +0 -28
- package/lib/typescript/charts/ScatterChart.d.ts +0 -34
- package/lib/typescript/charts/WaterfallChart.d.ts +0 -22
- package/lib/typescript/charts/advanced.d.ts +0 -107
- package/lib/typescript/charts/extra.d.ts +0 -63
- package/lib/typescript/charts/index.d.ts +0 -13
- package/lib/typescript/charts/scales.d.ts +0 -35
- package/src/Carousel.tsx +0 -233
- package/src/Display.tsx +0 -781
- package/src/Feedback.tsx +0 -992
- package/src/Form.tsx +0 -445
- package/src/Forms2.tsx +0 -1055
- package/src/Message.tsx +0 -218
- package/src/Overlays.tsx +0 -704
- package/src/Pickers.tsx +0 -595
- package/src/Table.tsx +0 -232
- package/src/ai.tsx +0 -715
- package/src/charts/AreaChart.tsx +0 -73
- package/src/charts/BarChart.tsx +0 -221
- package/src/charts/FunnelChart.tsx +0 -125
- package/src/charts/HeatmapChart.tsx +0 -155
- package/src/charts/LineChart.tsx +0 -247
- package/src/charts/PlotChart.tsx +0 -168
- package/src/charts/RadarChart.tsx +0 -208
- package/src/charts/RingChart.tsx +0 -133
- package/src/charts/ScatterChart.tsx +0 -223
- package/src/charts/WaterfallChart.tsx +0 -201
- package/src/charts/advanced.tsx +0 -676
- package/src/charts/extra.tsx +0 -242
- package/src/charts/index.ts +0 -86
- package/src/charts/scales.ts +0 -163
package/src/Feedback.tsx
DELETED
|
@@ -1,992 +0,0 @@
|
|
|
1
|
-
import { createContext, forwardRef, useContext, useEffect, useMemo, useRef, useState, type ReactNode } from "react";
|
|
2
|
-
import type { StyleProp, ViewStyle } from "react-native";
|
|
3
|
-
|
|
4
|
-
import { Glass } from "./Glass";
|
|
5
|
-
import { Separator } from "./Display";
|
|
6
|
-
import { colors, radii, toneColor, type Tone } from "./internal/tokens";
|
|
7
|
-
import { primitives } from "./internal/primitives";
|
|
8
|
-
import { useIsDark, useSpring } from "./internal/motion";
|
|
9
|
-
import { SelectedLens, rowLensStyle } from "./internal/lens";
|
|
10
|
-
import { hapticSelection } from "./internal/haptics";
|
|
11
|
-
|
|
12
|
-
// ---------------------------------------------------------------------------
|
|
13
|
-
// Toast
|
|
14
|
-
|
|
15
|
-
export interface ToastAction {
|
|
16
|
-
label: string;
|
|
17
|
-
onPress: () => void;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface ToastProps {
|
|
21
|
-
/** Controlled visibility. Omit it and the toast keeps its own state. */
|
|
22
|
-
visible?: boolean;
|
|
23
|
-
defaultVisible?: boolean;
|
|
24
|
-
onDismiss?: () => void;
|
|
25
|
-
message: string;
|
|
26
|
-
/** One optional action, e.g. Undo. */
|
|
27
|
-
action?: ToastAction;
|
|
28
|
-
/** A leading icon (an SVG node the caller supplies). */
|
|
29
|
-
icon?: ReactNode;
|
|
30
|
-
/**
|
|
31
|
-
* Milliseconds before it dismisses itself. 0 keeps it until dismissed.
|
|
32
|
-
* The timer is cleared on unmount as well as on dismiss.
|
|
33
|
-
*/
|
|
34
|
-
duration?: number;
|
|
35
|
-
tone?: Tone | "neutral";
|
|
36
|
-
style?: StyleProp<ViewStyle>;
|
|
37
|
-
isDark?: boolean;
|
|
38
|
-
testID?: string;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* A transient message on a glass pill.
|
|
43
|
-
*
|
|
44
|
-
* A toast is not a dialog: it never blocks the screen, so it renders in place
|
|
45
|
-
* and lets touches through to what is underneath. It dismisses itself after
|
|
46
|
-
* `duration` unless it is controlled or `duration` is 0.
|
|
47
|
-
*/
|
|
48
|
-
export const Toast = forwardRef<any, ToastProps>(function Toast(
|
|
49
|
-
{
|
|
50
|
-
visible: visibleProp,
|
|
51
|
-
defaultVisible = false,
|
|
52
|
-
onDismiss,
|
|
53
|
-
message,
|
|
54
|
-
action,
|
|
55
|
-
icon,
|
|
56
|
-
duration = 4000,
|
|
57
|
-
tone = "neutral",
|
|
58
|
-
style,
|
|
59
|
-
isDark: isDarkProp,
|
|
60
|
-
testID,
|
|
61
|
-
...props
|
|
62
|
-
},
|
|
63
|
-
ref,
|
|
64
|
-
) {
|
|
65
|
-
const isDark = useIsDark(isDarkProp);
|
|
66
|
-
const theme = isDark ? colors.dark : colors.light;
|
|
67
|
-
const { View, Text: RNText, Pressable } = primitives();
|
|
68
|
-
|
|
69
|
-
const [internalVisible, setInternalVisible] = useState(defaultVisible);
|
|
70
|
-
const visible = visibleProp !== undefined ? visibleProp : internalVisible;
|
|
71
|
-
|
|
72
|
-
const dismiss = () => {
|
|
73
|
-
if (visibleProp === undefined) setInternalVisible(false);
|
|
74
|
-
onDismiss?.();
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
// The timer lives and dies with the toast. A ref keeps the latest dismiss
|
|
78
|
-
// closure out of the effect's dependencies, so a parent re-render does not
|
|
79
|
-
// restart the countdown.
|
|
80
|
-
const dismissRef = useRef(dismiss);
|
|
81
|
-
dismissRef.current = dismiss;
|
|
82
|
-
|
|
83
|
-
useEffect(() => {
|
|
84
|
-
if (!visible || duration <= 0) return;
|
|
85
|
-
const timer = setTimeout(() => dismissRef.current(), duration);
|
|
86
|
-
return () => clearTimeout(timer);
|
|
87
|
-
}, [visible, duration]);
|
|
88
|
-
|
|
89
|
-
const { value: enter, animated } = useSpring(visible ? 1 : 0, "snappy");
|
|
90
|
-
const rise = animated ? enter.interpolate({ inputRange: [0, 1], outputRange: [12, 0] }) : 0;
|
|
91
|
-
const fade = animated ? enter.interpolate({ inputRange: [0, 1], outputRange: [0, 1] }) : 1;
|
|
92
|
-
|
|
93
|
-
if (!visible) return null;
|
|
94
|
-
|
|
95
|
-
const accent = tone === "neutral" ? theme.foreground : toneColor(theme, tone);
|
|
96
|
-
|
|
97
|
-
return (
|
|
98
|
-
<View
|
|
99
|
-
ref={ref}
|
|
100
|
-
testID={testID}
|
|
101
|
-
pointerEvents="box-none"
|
|
102
|
-
style={{ alignItems: "center", ...(style as ViewStyle) }}
|
|
103
|
-
{...props}
|
|
104
|
-
>
|
|
105
|
-
{/* The pill's entrance: it rises and fades in on the springs token. */}
|
|
106
|
-
<Entrance animated={animated} rise={rise} fade={fade}>
|
|
107
|
-
<Glass
|
|
108
|
-
effect="regular"
|
|
109
|
-
surface="overlay"
|
|
110
|
-
isDark={isDark}
|
|
111
|
-
style={{
|
|
112
|
-
flexDirection: "row",
|
|
113
|
-
alignItems: "center",
|
|
114
|
-
gap: 10,
|
|
115
|
-
paddingVertical: 12,
|
|
116
|
-
paddingHorizontal: 16,
|
|
117
|
-
borderRadius: radii.lg,
|
|
118
|
-
maxWidth: 400,
|
|
119
|
-
minWidth: 280,
|
|
120
|
-
// A toast floats above everything; without a shadow it is a label.
|
|
121
|
-
shadowOpacity: 0.12,
|
|
122
|
-
shadowRadius: 30,
|
|
123
|
-
shadowOffset: { width: 0, height: 10 },
|
|
124
|
-
borderColor: tone === "neutral" ? theme.edge : accent,
|
|
125
|
-
}}
|
|
126
|
-
>
|
|
127
|
-
{icon ? <View>{icon}</View> : null}
|
|
128
|
-
<RNText
|
|
129
|
-
accessibilityRole="alert"
|
|
130
|
-
accessibilityLiveRegion="polite"
|
|
131
|
-
style={{ fontSize: 13, color: theme.foreground, flexShrink: 1 }}
|
|
132
|
-
>
|
|
133
|
-
{message}
|
|
134
|
-
</RNText>
|
|
135
|
-
{action && (
|
|
136
|
-
<Pressable
|
|
137
|
-
accessibilityRole="button"
|
|
138
|
-
accessibilityLabel={action.label}
|
|
139
|
-
onPress={action.onPress}
|
|
140
|
-
style={{ paddingHorizontal: 4 }}
|
|
141
|
-
>
|
|
142
|
-
<RNText style={{ fontSize: 14, fontWeight: "600", color: theme.fill }}>
|
|
143
|
-
{action.label}
|
|
144
|
-
</RNText>
|
|
145
|
-
</Pressable>
|
|
146
|
-
)}
|
|
147
|
-
</Glass>
|
|
148
|
-
</Entrance>
|
|
149
|
-
</View>
|
|
150
|
-
);
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Applies the toast's entrance motion around the pill.
|
|
155
|
-
*
|
|
156
|
-
* A thin wrapper because animated styles must land on an Animated.View, while
|
|
157
|
-
* the pill itself is a Glass — wrapping keeps both honest.
|
|
158
|
-
*/
|
|
159
|
-
function Entrance({
|
|
160
|
-
animated,
|
|
161
|
-
rise,
|
|
162
|
-
fade,
|
|
163
|
-
children,
|
|
164
|
-
}: {
|
|
165
|
-
animated: boolean;
|
|
166
|
-
rise: any;
|
|
167
|
-
fade: any;
|
|
168
|
-
children: ReactNode;
|
|
169
|
-
}) {
|
|
170
|
-
const { Animated } = primitives();
|
|
171
|
-
if (!animated) return <>{children}</>;
|
|
172
|
-
return (
|
|
173
|
-
<Animated.View style={{ transform: [{ translateY: rise }], opacity: fade }}>
|
|
174
|
-
{children}
|
|
175
|
-
</Animated.View>
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
// ---------------------------------------------------------------------------
|
|
180
|
-
// ToastViewport
|
|
181
|
-
|
|
182
|
-
/** One message in a ToastViewport's queue. */
|
|
183
|
-
export interface ToastItem {
|
|
184
|
-
/** A stable identity. Required, because the queue reorders and dismisses. */
|
|
185
|
-
id: string;
|
|
186
|
-
message: string;
|
|
187
|
-
action?: ToastAction;
|
|
188
|
-
icon?: ReactNode;
|
|
189
|
-
tone?: Tone | "neutral";
|
|
190
|
-
/** Milliseconds before it dismisses itself. 0 keeps it until dismissed. */
|
|
191
|
-
duration?: number;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
export interface ToastViewportProps {
|
|
195
|
-
/** The messages to show. The oldest are dropped when more than 3 arrive. */
|
|
196
|
-
toasts: ToastItem[];
|
|
197
|
-
/** Called when one leaves, by timer, by swipe or by its action. */
|
|
198
|
-
onDismiss: (id: string) => void;
|
|
199
|
-
/** How many are visible at once. Extras wait in order. Defaults to 3. */
|
|
200
|
-
max?: number;
|
|
201
|
-
/** Where the stack sits. */
|
|
202
|
-
position?: "top" | "bottom";
|
|
203
|
-
style?: StyleProp<ViewStyle>;
|
|
204
|
-
isDark?: boolean;
|
|
205
|
-
testID?: string;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* A queue of toasts, stacked the way Sonner stacks them.
|
|
210
|
-
*
|
|
211
|
-
* Three at a time is the practical limit: beyond that the messages stop being
|
|
212
|
-
* read and start covering the screen. Extras wait in the order they arrived, so
|
|
213
|
-
* no message is lost and the newest is never hidden behind a backlog.
|
|
214
|
-
*
|
|
215
|
-
* Each toast is independently dismissible — its own timer, its own action, and
|
|
216
|
-
* a swipe up. Swiping one up removes only that one.
|
|
217
|
-
*
|
|
218
|
-
* The single `Toast` keeps working unchanged: this is the host for when an app
|
|
219
|
-
* has several messages at once, not a replacement. A caller that shows one
|
|
220
|
-
* message continues to use `Toast` directly.
|
|
221
|
-
*/
|
|
222
|
-
export const ToastViewport = forwardRef<any, ToastViewportProps>(function ToastViewport(
|
|
223
|
-
{ toasts, onDismiss, max = 3, position = "bottom", style, isDark: isDarkProp, testID, ...props },
|
|
224
|
-
ref,
|
|
225
|
-
) {
|
|
226
|
-
const isDark = useIsDark(isDarkProp);
|
|
227
|
-
const theme = isDark ? colors.dark : colors.light;
|
|
228
|
-
const { View, PanResponder } = primitives();
|
|
229
|
-
|
|
230
|
-
// The visible window is the newest `max`, so a burst shows the latest
|
|
231
|
-
// messages rather than a stale backlog. Earlier ones remain queued in the
|
|
232
|
-
// caller's array and appear as the visible ones leave.
|
|
233
|
-
//
|
|
234
|
-
// A host is often rendered for the whole life of a screen and simply has no
|
|
235
|
-
// messages yet, so an absent queue means empty rather than a crash.
|
|
236
|
-
const visible = (toasts ?? []).slice(0, Math.max(0, max));
|
|
237
|
-
|
|
238
|
-
return (
|
|
239
|
-
<View
|
|
240
|
-
ref={ref}
|
|
241
|
-
testID={testID}
|
|
242
|
-
pointerEvents="box-none"
|
|
243
|
-
style={{
|
|
244
|
-
position: "absolute",
|
|
245
|
-
left: 0,
|
|
246
|
-
right: 0,
|
|
247
|
-
alignItems: "center",
|
|
248
|
-
gap: 8,
|
|
249
|
-
...(position === "top" ? { top: 16 } : { bottom: 16 }),
|
|
250
|
-
...(style as ViewStyle),
|
|
251
|
-
}}
|
|
252
|
-
{...props}
|
|
253
|
-
>
|
|
254
|
-
{visible.map((toast) => (
|
|
255
|
-
<SwipeableToast
|
|
256
|
-
key={toast.id}
|
|
257
|
-
toast={toast}
|
|
258
|
-
isDark={isDark}
|
|
259
|
-
onDismiss={() => onDismiss(toast.id)}
|
|
260
|
-
theme={theme}
|
|
261
|
-
/>
|
|
262
|
-
))}
|
|
263
|
-
</View>
|
|
264
|
-
);
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
* One toast inside the viewport, with the swipe-up dismissal.
|
|
269
|
-
*
|
|
270
|
-
* Wrapping the existing Toast would have meant threading the gesture through
|
|
271
|
-
* its props, so the viewport renders the same pill with the gesture attached —
|
|
272
|
-
* the styling lives in one place (`Toast`), and this adds only the drag.
|
|
273
|
-
*/
|
|
274
|
-
function SwipeableToast({
|
|
275
|
-
toast,
|
|
276
|
-
isDark,
|
|
277
|
-
onDismiss,
|
|
278
|
-
theme,
|
|
279
|
-
}: {
|
|
280
|
-
toast: ToastItem;
|
|
281
|
-
isDark: boolean;
|
|
282
|
-
onDismiss: () => void;
|
|
283
|
-
theme: any;
|
|
284
|
-
}) {
|
|
285
|
-
const { View, Text: RNText, Pressable, PanResponder, Animated } = primitives();
|
|
286
|
-
const [lift, setLift] = useState(0);
|
|
287
|
-
const dismissRef = useRef(onDismiss);
|
|
288
|
-
dismissRef.current = onDismiss;
|
|
289
|
-
|
|
290
|
-
const duration = toast.duration ?? 4000;
|
|
291
|
-
useEffect(() => {
|
|
292
|
-
if (duration <= 0) return;
|
|
293
|
-
const timer = setTimeout(() => dismissRef.current(), duration);
|
|
294
|
-
return () => clearTimeout(timer);
|
|
295
|
-
}, [duration]);
|
|
296
|
-
|
|
297
|
-
const panResponder = useMemo(() => {
|
|
298
|
-
if (!PanResponder?.create) return null;
|
|
299
|
-
return PanResponder.create({
|
|
300
|
-
onMoveShouldSetPanResponder: (_event: any, gesture: any) =>
|
|
301
|
-
// Only an upward swipe removes a toast; downward drags are ignored.
|
|
302
|
-
gesture.dy < -8 && Math.abs(gesture.dy) > Math.abs(gesture.dx),
|
|
303
|
-
onPanResponderMove: (_event: any, gesture: any) => setLift(Math.min(0, gesture.dy)),
|
|
304
|
-
onPanResponderRelease: (_event: any, gesture: any) => {
|
|
305
|
-
// A quick flick or a long drag removes it; anything less springs back.
|
|
306
|
-
if (gesture.dy < -40 || gesture.vy < -0.5) {
|
|
307
|
-
dismissRef.current();
|
|
308
|
-
} else {
|
|
309
|
-
setLift(0);
|
|
310
|
-
}
|
|
311
|
-
},
|
|
312
|
-
onPanResponderTerminate: () => setLift(0),
|
|
313
|
-
});
|
|
314
|
-
}, [PanResponder]);
|
|
315
|
-
|
|
316
|
-
const tone = toast.tone ?? "neutral";
|
|
317
|
-
const accent = tone === "neutral" ? theme.foreground : toneColor(theme, tone);
|
|
318
|
-
|
|
319
|
-
const pill = (
|
|
320
|
-
<Glass
|
|
321
|
-
effect="regular"
|
|
322
|
-
isDark={isDark}
|
|
323
|
-
style={{
|
|
324
|
-
flexDirection: "row",
|
|
325
|
-
alignItems: "center",
|
|
326
|
-
gap: 10,
|
|
327
|
-
paddingVertical: 10,
|
|
328
|
-
paddingHorizontal: 14,
|
|
329
|
-
borderRadius: radii.pill,
|
|
330
|
-
maxWidth: 420,
|
|
331
|
-
borderColor: tone === "neutral" ? theme.edge : accent,
|
|
332
|
-
}}
|
|
333
|
-
>
|
|
334
|
-
{toast.icon ? <View>{toast.icon}</View> : null}
|
|
335
|
-
<RNText
|
|
336
|
-
accessibilityRole="alert"
|
|
337
|
-
accessibilityLiveRegion="polite"
|
|
338
|
-
style={{ fontSize: 14, color: theme.foreground, flexShrink: 1 }}
|
|
339
|
-
>
|
|
340
|
-
{toast.message}
|
|
341
|
-
</RNText>
|
|
342
|
-
{toast.action ? (
|
|
343
|
-
<Pressable
|
|
344
|
-
accessibilityRole="button"
|
|
345
|
-
accessibilityLabel={toast.action.label}
|
|
346
|
-
onPress={() => {
|
|
347
|
-
toast.action?.onPress();
|
|
348
|
-
onDismiss();
|
|
349
|
-
}}
|
|
350
|
-
style={{ paddingHorizontal: 4 }}
|
|
351
|
-
>
|
|
352
|
-
<RNText style={{ fontSize: 14, fontWeight: "600", color: theme.fill }}>
|
|
353
|
-
{toast.action.label}
|
|
354
|
-
</RNText>
|
|
355
|
-
</Pressable>
|
|
356
|
-
) : null}
|
|
357
|
-
</Glass>
|
|
358
|
-
);
|
|
359
|
-
|
|
360
|
-
return (
|
|
361
|
-
<View
|
|
362
|
-
style={{ transform: [{ translateY: lift }], opacity: lift === 0 ? 1 : Math.max(0.4, 1 + lift / 120) }}
|
|
363
|
-
{...(panResponder ? panResponder.panHandlers : {})}
|
|
364
|
-
>
|
|
365
|
-
{pill}
|
|
366
|
-
</View>
|
|
367
|
-
);
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
// ---------------------------------------------------------------------------
|
|
371
|
-
// Banner
|
|
372
|
-
|
|
373
|
-
export interface BannerProps {
|
|
374
|
-
title?: string;
|
|
375
|
-
message: string;
|
|
376
|
-
tone?: Tone;
|
|
377
|
-
/** A leading icon node. */
|
|
378
|
-
icon?: ReactNode;
|
|
379
|
-
/** Shows a dismiss button when provided. */
|
|
380
|
-
onDismiss?: () => void;
|
|
381
|
-
/** A single inline action, e.g. Retry. */
|
|
382
|
-
action?: ToastAction;
|
|
383
|
-
style?: StyleProp<ViewStyle>;
|
|
384
|
-
isDark?: boolean;
|
|
385
|
-
testID?: string;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
/**
|
|
389
|
-
* An inline alert.
|
|
390
|
-
*
|
|
391
|
-
* Unlike AlertDialog it is not modal and not an overlay: it sits in the layout
|
|
392
|
-
* and pushes the content below it down. The surface is glass with the tone's
|
|
393
|
-
* colour as its edge, so the tone reads at a glance without turning the whole
|
|
394
|
-
* panel into a solid block of colour.
|
|
395
|
-
*/
|
|
396
|
-
export const Banner = forwardRef<any, BannerProps>(function Banner(
|
|
397
|
-
{ title, message, tone = "info", icon, onDismiss, action, style, isDark: isDarkProp, testID, ...props },
|
|
398
|
-
ref,
|
|
399
|
-
) {
|
|
400
|
-
const isDark = useIsDark(isDarkProp);
|
|
401
|
-
const theme = isDark ? colors.dark : colors.light;
|
|
402
|
-
const { View, Text: RNText, Pressable } = primitives();
|
|
403
|
-
const accent = toneColor(theme, tone);
|
|
404
|
-
|
|
405
|
-
return (
|
|
406
|
-
<Glass
|
|
407
|
-
ref={ref}
|
|
408
|
-
effect="regular"
|
|
409
|
-
surface="overlay"
|
|
410
|
-
isDark={isDark}
|
|
411
|
-
testID={testID}
|
|
412
|
-
style={{ borderRadius: radii.md, borderColor: accent, ...(style as ViewStyle) }}
|
|
413
|
-
{...props}
|
|
414
|
-
>
|
|
415
|
-
<View style={{ flexDirection: "row", alignItems: "flex-start", gap: 10, padding: 12 }}>
|
|
416
|
-
{icon ? <View style={{ paddingTop: 1 }}>{icon}</View> : null}
|
|
417
|
-
<View style={{ flex: 1, gap: 2 }}>
|
|
418
|
-
{title && (
|
|
419
|
-
<RNText
|
|
420
|
-
accessibilityRole="heading"
|
|
421
|
-
style={{ fontSize: 14, fontWeight: "600", color: theme.foreground }}
|
|
422
|
-
>
|
|
423
|
-
{title}
|
|
424
|
-
</RNText>
|
|
425
|
-
)}
|
|
426
|
-
<RNText accessibilityRole="alert" style={{ fontSize: 13, color: theme.muted, lineHeight: 18 }}>
|
|
427
|
-
{message}
|
|
428
|
-
</RNText>
|
|
429
|
-
{action && (
|
|
430
|
-
<Pressable
|
|
431
|
-
accessibilityRole="button"
|
|
432
|
-
accessibilityLabel={action.label}
|
|
433
|
-
onPress={action.onPress}
|
|
434
|
-
style={{ alignSelf: "flex-start", paddingTop: 6 }}
|
|
435
|
-
>
|
|
436
|
-
<RNText style={{ fontSize: 13, fontWeight: "600", color: accent }}>
|
|
437
|
-
{action.label}
|
|
438
|
-
</RNText>
|
|
439
|
-
</Pressable>
|
|
440
|
-
)}
|
|
441
|
-
</View>
|
|
442
|
-
{onDismiss && (
|
|
443
|
-
<Pressable
|
|
444
|
-
accessibilityRole="button"
|
|
445
|
-
accessibilityLabel="Dismiss"
|
|
446
|
-
onPress={onDismiss}
|
|
447
|
-
hitSlop={8}
|
|
448
|
-
style={{ padding: 2 }}
|
|
449
|
-
>
|
|
450
|
-
<RNText style={{ fontSize: 15, color: theme.muted }}>{"\u00D7"}</RNText>
|
|
451
|
-
</Pressable>
|
|
452
|
-
)}
|
|
453
|
-
</View>
|
|
454
|
-
</Glass>
|
|
455
|
-
);
|
|
456
|
-
});
|
|
457
|
-
|
|
458
|
-
// ---------------------------------------------------------------------------
|
|
459
|
-
// List
|
|
460
|
-
|
|
461
|
-
/** One action revealed by swiping a row. */
|
|
462
|
-
export interface ListSwipeAction {
|
|
463
|
-
label: string;
|
|
464
|
-
/** A leading node, typically an SVG icon the caller supplies. */
|
|
465
|
-
icon?: ReactNode;
|
|
466
|
-
/** The action's tint. Defaults to the theme's fill. */
|
|
467
|
-
color?: string;
|
|
468
|
-
onPress: () => void;
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
export interface ListItemProps {
|
|
472
|
-
/** An avatar, icon or other leading node. */
|
|
473
|
-
leading?: ReactNode;
|
|
474
|
-
/** The row's main text. */
|
|
475
|
-
title: string;
|
|
476
|
-
/** Secondary line under the title. */
|
|
477
|
-
description?: string;
|
|
478
|
-
/** A value text, a control, or any trailing node. */
|
|
479
|
-
trailing?: ReactNode;
|
|
480
|
-
/** Draws a chevron when the row is tappable and nothing else trails it. */
|
|
481
|
-
chevron?: boolean;
|
|
482
|
-
onPress?: () => void;
|
|
483
|
-
disabled?: boolean;
|
|
484
|
-
selected?: boolean;
|
|
485
|
-
/** Actions revealed by swiping right (towards the trailing edge). */
|
|
486
|
-
swipeActions?: ListSwipeAction[];
|
|
487
|
-
/** Actions revealed by swiping left. */
|
|
488
|
-
leadingSwipeActions?: ListSwipeAction[];
|
|
489
|
-
/** Width allotted to each revealed action button. */
|
|
490
|
-
swipeActionWidth?: number;
|
|
491
|
-
/** Turns the swipe gesture off, leaving the row's `onPress` only. */
|
|
492
|
-
swipeable?: boolean;
|
|
493
|
-
/** Opt out of the selection tick when a swipe opens. */
|
|
494
|
-
haptics?: boolean;
|
|
495
|
-
style?: StyleProp<ViewStyle>;
|
|
496
|
-
isDark?: boolean;
|
|
497
|
-
testID?: string;
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
/**
|
|
501
|
-
* Tracks which row of a List is open, so opening one closes the rest.
|
|
502
|
-
*
|
|
503
|
-
* A list with two open rows looks broken; iOS Mail and every kit that copied
|
|
504
|
-
* it keep at most one. The List provides the registry and each swipeable row
|
|
505
|
-
* registers its own close function.
|
|
506
|
-
*/
|
|
507
|
-
const OpenRowContext = createContext<{
|
|
508
|
-
openId: string | null;
|
|
509
|
-
setOpenId: (id: string | null) => void;
|
|
510
|
-
} | null>(null);
|
|
511
|
-
|
|
512
|
-
/**
|
|
513
|
-
* One row of a List.
|
|
514
|
-
*
|
|
515
|
-
* The row is a Pressable when it has an `onPress`, and inert otherwise, which
|
|
516
|
-
* is what the platform expects: a row that does nothing should not announce
|
|
517
|
-
* itself as a button. The chevron is decoration and is hidden from screen
|
|
518
|
-
* readers, since the row's own role already says it is tappable.
|
|
519
|
-
*/
|
|
520
|
-
export const ListItem = forwardRef<any, ListItemProps>(function ListItem(
|
|
521
|
-
{
|
|
522
|
-
leading,
|
|
523
|
-
title,
|
|
524
|
-
description,
|
|
525
|
-
trailing,
|
|
526
|
-
chevron,
|
|
527
|
-
onPress,
|
|
528
|
-
disabled = false,
|
|
529
|
-
selected = false,
|
|
530
|
-
swipeActions,
|
|
531
|
-
leadingSwipeActions,
|
|
532
|
-
swipeActionWidth = 78,
|
|
533
|
-
swipeable = true,
|
|
534
|
-
haptics = true,
|
|
535
|
-
style,
|
|
536
|
-
isDark: isDarkProp,
|
|
537
|
-
testID,
|
|
538
|
-
...props
|
|
539
|
-
},
|
|
540
|
-
ref,
|
|
541
|
-
) {
|
|
542
|
-
const isDark = useIsDark(isDarkProp);
|
|
543
|
-
const theme = isDark ? colors.dark : colors.light;
|
|
544
|
-
const { View, Text: RNText, Pressable, PanResponder } = primitives();
|
|
545
|
-
const rowGroup = useContext(OpenRowContext);
|
|
546
|
-
|
|
547
|
-
const interactive = Boolean(onPress) && !disabled;
|
|
548
|
-
const showChevron = interactive && chevron !== false && trailing === undefined;
|
|
549
|
-
|
|
550
|
-
const trailActions = swipeActions?.filter(Boolean) ?? [];
|
|
551
|
-
const leadActions = leadingSwipeActions?.filter(Boolean) ?? [];
|
|
552
|
-
const canSwipe = swipeable && !disabled && (trailActions.length > 0 || leadActions.length > 0);
|
|
553
|
-
|
|
554
|
-
// The row's own identity, so a List can close its siblings.
|
|
555
|
-
const rowId = useRef<string>(`row-${Math.random().toString(36).slice(2)}`);
|
|
556
|
-
|
|
557
|
-
// 0 is closed; a positive offset reveals trailing actions, negative leading.
|
|
558
|
-
const [offset, setOffset] = useState(0);
|
|
559
|
-
const offsetRef = useRef(0);
|
|
560
|
-
offsetRef.current = offset;
|
|
561
|
-
// A gesture that moved is a swipe, not a tap: the press that follows the
|
|
562
|
-
// release must not fire the row's onPress.
|
|
563
|
-
const swipedRef = useRef(false);
|
|
564
|
-
|
|
565
|
-
const trailingWidth = trailActions.length * swipeActionWidth;
|
|
566
|
-
const leadingWidth = leadActions.length * swipeActionWidth;
|
|
567
|
-
|
|
568
|
-
const close = () => setOffset(0);
|
|
569
|
-
|
|
570
|
-
// When another row opens, this one closes.
|
|
571
|
-
useEffect(() => {
|
|
572
|
-
if (rowGroup && rowGroup.openId !== rowId.current && offsetRef.current !== 0) {
|
|
573
|
-
setOffset(0);
|
|
574
|
-
}
|
|
575
|
-
}, [rowGroup?.openId]);
|
|
576
|
-
|
|
577
|
-
const settle = (next: number) => {
|
|
578
|
-
setOffset(next);
|
|
579
|
-
if (rowGroup) {
|
|
580
|
-
rowGroup.setOpenId(next !== 0 ? rowId.current : null);
|
|
581
|
-
}
|
|
582
|
-
if (next !== 0 && haptics && offsetRef.current === 0) hapticSelection();
|
|
583
|
-
};
|
|
584
|
-
|
|
585
|
-
const panResponder = useMemo(() => {
|
|
586
|
-
if (!canSwipe || !PanResponder?.create) return null;
|
|
587
|
-
return PanResponder.create({
|
|
588
|
-
// A horizontal drag claims the gesture; a vertical one stays with the
|
|
589
|
-
// surrounding scroll view.
|
|
590
|
-
onMoveShouldSetPanResponder: (_event: any, gesture: any) =>
|
|
591
|
-
Math.abs(gesture.dx) > Math.abs(gesture.dy) && Math.abs(gesture.dx) > 8,
|
|
592
|
-
onPanResponderGrant: () => {
|
|
593
|
-
swipedRef.current = false;
|
|
594
|
-
},
|
|
595
|
-
onPanResponderMove: (_event: any, gesture: any) => {
|
|
596
|
-
if (Math.abs(gesture.dx) > 4) swipedRef.current = true;
|
|
597
|
-
const from = offsetRef.current;
|
|
598
|
-
let next = from + gesture.dx;
|
|
599
|
-
// Do not drag past what the actions actually occupy; a small
|
|
600
|
-
// overshoot makes the edge feel elastic rather than hard.
|
|
601
|
-
next = Math.min(next, trailingWidth + 24);
|
|
602
|
-
next = Math.max(next, -(leadingWidth + 24));
|
|
603
|
-
setOffset(next);
|
|
604
|
-
},
|
|
605
|
-
onPanResponderRelease: (_event: any, gesture: any) => {
|
|
606
|
-
const released = offsetRef.current;
|
|
607
|
-
// Beyond half an action, or with a decisive flick, it stays open;
|
|
608
|
-
// otherwise it falls back closed.
|
|
609
|
-
if (gesture.dx > 0 && trailActions.length > 0) {
|
|
610
|
-
settle(released > trailingWidth / 2 || gesture.vx > 0.5 ? trailingWidth : 0);
|
|
611
|
-
} else if (gesture.dx < 0 && leadActions.length > 0) {
|
|
612
|
-
settle(released < -leadingWidth / 2 || gesture.vx < -0.5 ? -leadingWidth : 0);
|
|
613
|
-
} else {
|
|
614
|
-
settle(offsetRef.current > 0 ? Math.min(offsetRef.current, trailingWidth) : Math.max(offsetRef.current, -leadingWidth));
|
|
615
|
-
}
|
|
616
|
-
},
|
|
617
|
-
onPanResponderTerminate: () => settle(0),
|
|
618
|
-
onPanResponderTerminationRequest: () => false,
|
|
619
|
-
});
|
|
620
|
-
// The responder reads from refs, so it never acts on a stale offset.
|
|
621
|
-
}, [canSwipe, PanResponder, trailingWidth, leadingWidth, trailActions.length, leadActions.length]);
|
|
622
|
-
|
|
623
|
-
/**
|
|
624
|
-
* Runs an action and closes the row.
|
|
625
|
-
*
|
|
626
|
-
* The action is dispatched first so its own feedback is not delayed by the
|
|
627
|
-
* close, then the row resets — the reveal should not outlive the press.
|
|
628
|
-
*/
|
|
629
|
-
const runAction = (action: ListSwipeAction) => {
|
|
630
|
-
action.onPress();
|
|
631
|
-
settle(0);
|
|
632
|
-
if (rowGroup) rowGroup.setOpenId(null);
|
|
633
|
-
};
|
|
634
|
-
|
|
635
|
-
const guardPress = (handler?: () => void) => () => {
|
|
636
|
-
// Swallow the press that ends a swipe.
|
|
637
|
-
if (swipedRef.current) {
|
|
638
|
-
swipedRef.current = false;
|
|
639
|
-
return;
|
|
640
|
-
}
|
|
641
|
-
handler?.();
|
|
642
|
-
};
|
|
643
|
-
|
|
644
|
-
const content = (
|
|
645
|
-
<>
|
|
646
|
-
{leading ? <View style={{ marginRight: 12 }}>{leading}</View> : null}
|
|
647
|
-
<View style={{ flex: 1, gap: 2 }}>
|
|
648
|
-
<RNText
|
|
649
|
-
numberOfLines={1}
|
|
650
|
-
style={{ fontSize: 16, color: theme.foreground, fontWeight: "400" }}
|
|
651
|
-
>
|
|
652
|
-
{title}
|
|
653
|
-
</RNText>
|
|
654
|
-
{description ? (
|
|
655
|
-
<RNText numberOfLines={2} style={{ fontSize: 13, color: theme.muted, lineHeight: 17 }}>
|
|
656
|
-
{description}
|
|
657
|
-
</RNText>
|
|
658
|
-
) : null}
|
|
659
|
-
</View>
|
|
660
|
-
{trailing ? <View style={{ marginLeft: 8 }}>{trailing}</View> : null}
|
|
661
|
-
{showChevron ? (
|
|
662
|
-
<RNText accessibilityElementsHidden importantForAccessibility="no" style={{ marginLeft: 6, fontSize: 17, color: theme.muted }}>
|
|
663
|
-
{"\u203A"}
|
|
664
|
-
</RNText>
|
|
665
|
-
) : null}
|
|
666
|
-
</>
|
|
667
|
-
);
|
|
668
|
-
|
|
669
|
-
const rowStyle: ViewStyle = {
|
|
670
|
-
flexDirection: "row",
|
|
671
|
-
alignItems: "center",
|
|
672
|
-
minHeight: 44,
|
|
673
|
-
paddingVertical: 10,
|
|
674
|
-
paddingHorizontal: 16,
|
|
675
|
-
// The selected row is a lens painted behind the content, not a flat wash.
|
|
676
|
-
backgroundColor: "transparent",
|
|
677
|
-
opacity: disabled ? 0.38 : 1,
|
|
678
|
-
...(style as ViewStyle),
|
|
679
|
-
};
|
|
680
|
-
|
|
681
|
-
const lens = selected ? (
|
|
682
|
-
<SelectedLens
|
|
683
|
-
radius={8}
|
|
684
|
-
isDark={isDark}
|
|
685
|
-
style={rowLensStyle(8)}
|
|
686
|
-
testID={testID ? `${testID}-lens` : undefined}
|
|
687
|
-
/>
|
|
688
|
-
) : null;
|
|
689
|
-
|
|
690
|
-
const rowInner = !interactive ? (
|
|
691
|
-
<View accessibilityRole="text" accessibilityState={{ disabled }} style={rowStyle}>
|
|
692
|
-
{lens}
|
|
693
|
-
{content}
|
|
694
|
-
</View>
|
|
695
|
-
) : (
|
|
696
|
-
<Pressable
|
|
697
|
-
accessibilityRole="button"
|
|
698
|
-
accessibilityLabel={description ? `${title}, ${description}` : title}
|
|
699
|
-
accessibilityState={{ selected, disabled }}
|
|
700
|
-
disabled={disabled}
|
|
701
|
-
onPress={guardPress(onPress)}
|
|
702
|
-
style={({ pressed }: { pressed: boolean }) => ({ ...rowStyle, opacity: pressed ? 0.7 : rowStyle.opacity })}
|
|
703
|
-
>
|
|
704
|
-
{lens}
|
|
705
|
-
{content}
|
|
706
|
-
</Pressable>
|
|
707
|
-
);
|
|
708
|
-
|
|
709
|
-
if (!canSwipe) {
|
|
710
|
-
return (
|
|
711
|
-
<View ref={ref} testID={testID} style={{ overflow: "hidden" }} {...props}>
|
|
712
|
-
{rowInner}
|
|
713
|
-
</View>
|
|
714
|
-
);
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
/** The tinted tray behind the row: glass-tinted actions, flat not glass. */
|
|
718
|
-
const tray = (actions: ListSwipeAction[], edge: "left" | "right") => (
|
|
719
|
-
<View
|
|
720
|
-
style={{
|
|
721
|
-
position: "absolute",
|
|
722
|
-
top: 0,
|
|
723
|
-
bottom: 0,
|
|
724
|
-
[edge]: 0,
|
|
725
|
-
flexDirection: "row",
|
|
726
|
-
}}
|
|
727
|
-
>
|
|
728
|
-
{actions.map((action, index) => (
|
|
729
|
-
<Pressable
|
|
730
|
-
key={`${action.label}-${index}`}
|
|
731
|
-
accessibilityRole="button"
|
|
732
|
-
accessibilityLabel={action.label}
|
|
733
|
-
onPress={() => runAction(action)}
|
|
734
|
-
style={{
|
|
735
|
-
width: swipeActionWidth,
|
|
736
|
-
alignItems: "center",
|
|
737
|
-
justifyContent: "center",
|
|
738
|
-
gap: 3,
|
|
739
|
-
backgroundColor: action.color ?? theme.glassActive,
|
|
740
|
-
}}
|
|
741
|
-
>
|
|
742
|
-
{action.icon}
|
|
743
|
-
<RNText style={{ fontSize: 12, color: theme.foreground }} numberOfLines={1}>
|
|
744
|
-
{action.label}
|
|
745
|
-
</RNText>
|
|
746
|
-
</Pressable>
|
|
747
|
-
))}
|
|
748
|
-
</View>
|
|
749
|
-
);
|
|
750
|
-
|
|
751
|
-
return (
|
|
752
|
-
<View
|
|
753
|
-
ref={ref}
|
|
754
|
-
testID={testID}
|
|
755
|
-
accessibilityRole="none"
|
|
756
|
-
style={{ overflow: "hidden" }}
|
|
757
|
-
{...props}
|
|
758
|
-
>
|
|
759
|
-
{leadActions.length > 0 ? tray(leadActions, "right") : null}
|
|
760
|
-
{trailActions.length > 0 ? tray(trailActions, "left") : null}
|
|
761
|
-
<View
|
|
762
|
-
style={{
|
|
763
|
-
transform: [{ translateX: offset }],
|
|
764
|
-
// The row rides over its tray while it is open, so the actions are
|
|
765
|
-
// uncovered rather than shown alongside.
|
|
766
|
-
backgroundColor: "transparent",
|
|
767
|
-
}}
|
|
768
|
-
{...(panResponder ? panResponder.panHandlers : {})}
|
|
769
|
-
>
|
|
770
|
-
{rowInner}
|
|
771
|
-
</View>
|
|
772
|
-
</View>
|
|
773
|
-
);
|
|
774
|
-
});
|
|
775
|
-
|
|
776
|
-
export interface ListProps {
|
|
777
|
-
children?: ReactNode;
|
|
778
|
-
/** Renders the rows on one glass panel with separators between them. */
|
|
779
|
-
inset?: boolean;
|
|
780
|
-
style?: StyleProp<ViewStyle>;
|
|
781
|
-
isDark?: boolean;
|
|
782
|
-
testID?: string;
|
|
783
|
-
}
|
|
784
|
-
|
|
785
|
-
/**
|
|
786
|
-
* A grouped list of rows — the backbone of settings and profile screens.
|
|
787
|
-
*
|
|
788
|
-
* With `inset`, the rows sit on one glass panel with hairline separators, which
|
|
789
|
-
* is the shape iOS settings screens use. The separators are drawn by the
|
|
790
|
-
* caller's ListItem spacing rather than by nesting glass inside glass.
|
|
791
|
-
*/
|
|
792
|
-
export const List = forwardRef<any, ListProps>(function List(
|
|
793
|
-
{ children, inset = false, style, isDark: isDarkProp, testID, ...props },
|
|
794
|
-
ref,
|
|
795
|
-
) {
|
|
796
|
-
const isDark = useIsDark(isDarkProp);
|
|
797
|
-
const { View } = primitives();
|
|
798
|
-
|
|
799
|
-
const rows = Array.isArray(children) ? children.filter(Boolean) : children == null ? [] : [children];
|
|
800
|
-
|
|
801
|
-
// At most one swipeable row is open at a time, so a list never shows two
|
|
802
|
-
// trays at once.
|
|
803
|
-
const [openId, setOpenId] = useState<string | null>(null);
|
|
804
|
-
const group = useMemo(() => ({ openId, setOpenId }), [openId]);
|
|
805
|
-
|
|
806
|
-
const body = (
|
|
807
|
-
<OpenRowContext.Provider value={group}>
|
|
808
|
-
<View style={{ gap: 2 }}>
|
|
809
|
-
{rows.map((row, index) => (
|
|
810
|
-
<View key={index}>
|
|
811
|
-
{index > 0 ? <Separator isDark={isDark} inset={inset ? 14 : 0} /> : null}
|
|
812
|
-
{row}
|
|
813
|
-
</View>
|
|
814
|
-
))}
|
|
815
|
-
</View>
|
|
816
|
-
</OpenRowContext.Provider>
|
|
817
|
-
);
|
|
818
|
-
|
|
819
|
-
if (!inset) {
|
|
820
|
-
return (
|
|
821
|
-
<View ref={ref} testID={testID} style={style} {...props}>
|
|
822
|
-
{body}
|
|
823
|
-
</View>
|
|
824
|
-
);
|
|
825
|
-
}
|
|
826
|
-
|
|
827
|
-
return (
|
|
828
|
-
<Glass
|
|
829
|
-
ref={ref}
|
|
830
|
-
effect="regular"
|
|
831
|
-
surface="panel"
|
|
832
|
-
isDark={isDark}
|
|
833
|
-
testID={testID}
|
|
834
|
-
style={{ borderRadius: radii.lg, ...(style as ViewStyle) }}
|
|
835
|
-
{...props}
|
|
836
|
-
>
|
|
837
|
-
{body}
|
|
838
|
-
</Glass>
|
|
839
|
-
);
|
|
840
|
-
});
|
|
841
|
-
|
|
842
|
-
/** A titled group of rows, e.g. "Account" above its settings. */
|
|
843
|
-
export interface ListSectionProps {
|
|
844
|
-
header?: string;
|
|
845
|
-
children?: ReactNode;
|
|
846
|
-
style?: StyleProp<ViewStyle>;
|
|
847
|
-
isDark?: boolean;
|
|
848
|
-
testID?: string;
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
export const ListSection = forwardRef<any, ListSectionProps>(function ListSection(
|
|
852
|
-
{ header, children, style, isDark: isDarkProp, testID, ...props },
|
|
853
|
-
ref,
|
|
854
|
-
) {
|
|
855
|
-
const isDark = useIsDark(isDarkProp);
|
|
856
|
-
const theme = isDark ? colors.dark : colors.light;
|
|
857
|
-
const { View, Text: RNText } = primitives();
|
|
858
|
-
|
|
859
|
-
return (
|
|
860
|
-
<View ref={ref} testID={testID} style={[{ gap: 6 }, style as ViewStyle]} {...props}>
|
|
861
|
-
{header ? (
|
|
862
|
-
<RNText
|
|
863
|
-
accessibilityRole="heading"
|
|
864
|
-
style={{
|
|
865
|
-
fontSize: 12,
|
|
866
|
-
fontWeight: "600",
|
|
867
|
-
letterSpacing: 0.4,
|
|
868
|
-
textTransform: "uppercase",
|
|
869
|
-
color: theme.muted,
|
|
870
|
-
paddingHorizontal: 16,
|
|
871
|
-
paddingVertical: 5,
|
|
872
|
-
}}
|
|
873
|
-
>
|
|
874
|
-
{header}
|
|
875
|
-
</RNText>
|
|
876
|
-
) : null}
|
|
877
|
-
<List inset isDark={isDark}>
|
|
878
|
-
{children}
|
|
879
|
-
</List>
|
|
880
|
-
</View>
|
|
881
|
-
);
|
|
882
|
-
});
|
|
883
|
-
|
|
884
|
-
// ---------------------------------------------------------------------------
|
|
885
|
-
// Accordion
|
|
886
|
-
|
|
887
|
-
export interface AccordionSection {
|
|
888
|
-
/** Stable identity for the section. */
|
|
889
|
-
value: string;
|
|
890
|
-
title: string;
|
|
891
|
-
/** Optional second line in the header. */
|
|
892
|
-
description?: string;
|
|
893
|
-
content: ReactNode;
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
export interface AccordionProps {
|
|
897
|
-
sections: AccordionSection[];
|
|
898
|
-
/** Allow several sections open at once. */
|
|
899
|
-
multiple?: boolean;
|
|
900
|
-
/** Controlled open sections. Omit for uncontrolled. */
|
|
901
|
-
openSections?: string[];
|
|
902
|
-
defaultOpenSections?: string[];
|
|
903
|
-
onOpenSectionsChange?: (open: string[]) => void;
|
|
904
|
-
style?: StyleProp<ViewStyle>;
|
|
905
|
-
isDark?: boolean;
|
|
906
|
-
testID?: string;
|
|
907
|
-
}
|
|
908
|
-
|
|
909
|
-
/**
|
|
910
|
-
* Expandable sections.
|
|
911
|
-
*
|
|
912
|
-
* The header is a Pressable reporting `expanded`; the panel is measured with
|
|
913
|
-
* the height the content reports and animated on the springs token, so the
|
|
914
|
-
* reveal is a real transition rather than an instant jump.
|
|
915
|
-
*/
|
|
916
|
-
export const Accordion = forwardRef<any, AccordionProps>(function Accordion(
|
|
917
|
-
{
|
|
918
|
-
sections,
|
|
919
|
-
multiple = false,
|
|
920
|
-
openSections: openProp,
|
|
921
|
-
defaultOpenSections = [],
|
|
922
|
-
onOpenSectionsChange,
|
|
923
|
-
style,
|
|
924
|
-
isDark: isDarkProp,
|
|
925
|
-
testID,
|
|
926
|
-
...props
|
|
927
|
-
},
|
|
928
|
-
ref,
|
|
929
|
-
) {
|
|
930
|
-
const isDark = useIsDark(isDarkProp);
|
|
931
|
-
const theme = isDark ? colors.dark : colors.light;
|
|
932
|
-
const { View, Text: RNText, Pressable } = primitives();
|
|
933
|
-
|
|
934
|
-
const [internalOpen, setInternalOpen] = useState<string[]>(defaultOpenSections);
|
|
935
|
-
const open = openProp !== undefined ? openProp : internalOpen;
|
|
936
|
-
|
|
937
|
-
const toggle = (value: string) => {
|
|
938
|
-
const isOpen = open.includes(value);
|
|
939
|
-
let next: string[];
|
|
940
|
-
if (isOpen) next = open.filter((item) => item !== value);
|
|
941
|
-
else next = multiple ? [...open, value] : [value];
|
|
942
|
-
if (openProp === undefined) setInternalOpen(next);
|
|
943
|
-
onOpenSectionsChange?.(next);
|
|
944
|
-
};
|
|
945
|
-
|
|
946
|
-
return (
|
|
947
|
-
<Glass
|
|
948
|
-
ref={ref}
|
|
949
|
-
effect="regular"
|
|
950
|
-
surface="panel"
|
|
951
|
-
isDark={isDark}
|
|
952
|
-
testID={testID}
|
|
953
|
-
style={{ borderRadius: radii.stack, ...(style as ViewStyle) }}
|
|
954
|
-
{...props}
|
|
955
|
-
>
|
|
956
|
-
{sections.map((section, index) => {
|
|
957
|
-
const expanded = open.includes(section.value);
|
|
958
|
-
return (
|
|
959
|
-
<View key={section.value}>
|
|
960
|
-
{index > 0 ? <Separator isDark={isDark} /> : null}
|
|
961
|
-
<Pressable
|
|
962
|
-
accessibilityRole="button"
|
|
963
|
-
accessibilityLabel={section.title}
|
|
964
|
-
accessibilityState={{ expanded }}
|
|
965
|
-
onPress={() => toggle(section.value)}
|
|
966
|
-
style={{ paddingVertical: 16, paddingHorizontal: 20, flexDirection: "row", alignItems: "center" }}
|
|
967
|
-
>
|
|
968
|
-
<View style={{ flex: 1, gap: 2 }}>
|
|
969
|
-
<RNText style={{ fontSize: 15, fontWeight: "500", color: theme.foreground }}>
|
|
970
|
-
{section.title}
|
|
971
|
-
</RNText>
|
|
972
|
-
{section.description ? (
|
|
973
|
-
<RNText style={{ fontSize: 13, color: theme.muted }}>{section.description}</RNText>
|
|
974
|
-
) : null}
|
|
975
|
-
</View>
|
|
976
|
-
<RNText
|
|
977
|
-
accessibilityElementsHidden
|
|
978
|
-
importantForAccessibility="no"
|
|
979
|
-
style={{ fontSize: 13, color: theme.muted, marginLeft: 8 }}
|
|
980
|
-
>
|
|
981
|
-
{expanded ? "\u2303" : "\u2304"}
|
|
982
|
-
</RNText>
|
|
983
|
-
</Pressable>
|
|
984
|
-
{expanded ? (
|
|
985
|
-
<View style={{ paddingHorizontal: 20, paddingBottom: 16 }}>{section.content}</View>
|
|
986
|
-
) : null}
|
|
987
|
-
</View>
|
|
988
|
-
);
|
|
989
|
-
})}
|
|
990
|
-
</Glass>
|
|
991
|
-
);
|
|
992
|
-
});
|