glacia-native 0.5.2 → 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/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 +154 -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 +4 -2
- 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 +211 -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
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// Wave 2 — Accordion.
|
|
2
|
+
//
|
|
3
|
+
// The donor's disclosure behaviour: one section open at a time unless `multiple`,
|
|
4
|
+
// a controlled list when `openSections` is passed, and headers that announce
|
|
5
|
+
// their expanded state. Dressed on the family's glass surface with the same
|
|
6
|
+
// hairlines and type steps as the rest of the library.
|
|
7
|
+
|
|
8
|
+
import { useState, type ReactNode } from "react";
|
|
9
|
+
import type { StyleProp, ViewStyle } from "react-native";
|
|
10
|
+
|
|
11
|
+
import { Glass } from "./Glass";
|
|
12
|
+
import { colors, radii, typeScale } from "./internal/tokens";
|
|
13
|
+
import { primitives } from "./internal/primitives";
|
|
14
|
+
import { useIsDark, useSpring } from "./internal/motion";
|
|
15
|
+
|
|
16
|
+
export interface AccordionSection {
|
|
17
|
+
/** Stable identity for the section. */
|
|
18
|
+
value: string;
|
|
19
|
+
title: string;
|
|
20
|
+
/** Optional second line in the header. */
|
|
21
|
+
description?: string;
|
|
22
|
+
content: ReactNode;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface AccordionProps {
|
|
26
|
+
sections: AccordionSection[];
|
|
27
|
+
/** Allow several sections open at once. */
|
|
28
|
+
multiple?: boolean;
|
|
29
|
+
openSections?: string[];
|
|
30
|
+
defaultOpenSections?: string[];
|
|
31
|
+
onOpenSectionsChange?: (open: string[]) => void;
|
|
32
|
+
style?: StyleProp<ViewStyle>;
|
|
33
|
+
isDark?: boolean;
|
|
34
|
+
testID?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function Accordion({
|
|
38
|
+
sections,
|
|
39
|
+
multiple = false,
|
|
40
|
+
openSections,
|
|
41
|
+
defaultOpenSections,
|
|
42
|
+
onOpenSectionsChange,
|
|
43
|
+
style,
|
|
44
|
+
isDark: isDarkProp,
|
|
45
|
+
testID,
|
|
46
|
+
}: AccordionProps) {
|
|
47
|
+
const isDark = useIsDark(isDarkProp);
|
|
48
|
+
const theme = isDark ? colors.dark : colors.light;
|
|
49
|
+
const { View, Pressable, Text: RNText } = primitives();
|
|
50
|
+
|
|
51
|
+
const [internal, setInternal] = useState<string[]>(defaultOpenSections ?? []);
|
|
52
|
+
const open = openSections !== undefined ? openSections : internal;
|
|
53
|
+
|
|
54
|
+
const toggle = (value: string) => {
|
|
55
|
+
const isOpen = open.includes(value);
|
|
56
|
+
let next: string[];
|
|
57
|
+
if (multiple) {
|
|
58
|
+
next = isOpen ? open.filter((entry) => entry !== value) : [...open, value];
|
|
59
|
+
} else {
|
|
60
|
+
next = isOpen ? [] : [value];
|
|
61
|
+
}
|
|
62
|
+
if (openSections === undefined) setInternal(next);
|
|
63
|
+
onOpenSectionsChange?.(next);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<Glass
|
|
68
|
+
effect="regular"
|
|
69
|
+
surface="panel"
|
|
70
|
+
isDark={isDark}
|
|
71
|
+
testID={testID}
|
|
72
|
+
style={[{ borderRadius: radii.lg, overflow: "hidden" }, style]}
|
|
73
|
+
>
|
|
74
|
+
{sections.map((section, index) => (
|
|
75
|
+
<AccordionRow
|
|
76
|
+
key={section.value}
|
|
77
|
+
section={section}
|
|
78
|
+
open={open.includes(section.value)}
|
|
79
|
+
onPress={() => toggle(section.value)}
|
|
80
|
+
first={index === 0}
|
|
81
|
+
isDark={isDark}
|
|
82
|
+
borderColor={theme.separator}
|
|
83
|
+
foreground={theme.foreground}
|
|
84
|
+
muted={theme.muted}
|
|
85
|
+
/>
|
|
86
|
+
))}
|
|
87
|
+
</Glass>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function AccordionRow({
|
|
92
|
+
section,
|
|
93
|
+
open,
|
|
94
|
+
onPress,
|
|
95
|
+
first,
|
|
96
|
+
isDark,
|
|
97
|
+
borderColor,
|
|
98
|
+
foreground,
|
|
99
|
+
muted,
|
|
100
|
+
}: {
|
|
101
|
+
section: AccordionSection;
|
|
102
|
+
open: boolean;
|
|
103
|
+
onPress: () => void;
|
|
104
|
+
first: boolean;
|
|
105
|
+
isDark: boolean;
|
|
106
|
+
borderColor: string;
|
|
107
|
+
foreground: string;
|
|
108
|
+
muted: string;
|
|
109
|
+
}) {
|
|
110
|
+
const { View, Pressable, Text: RNText } = primitives();
|
|
111
|
+
const { value: progress, animated } = useSpring(open ? 1 : 0, "snappy");
|
|
112
|
+
const rotation = animated
|
|
113
|
+
? progress.interpolate({ inputRange: [0, 1], outputRange: ["0deg", "90deg"] })
|
|
114
|
+
: open
|
|
115
|
+
? "90deg"
|
|
116
|
+
: "0deg";
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<View
|
|
120
|
+
style={
|
|
121
|
+
first
|
|
122
|
+
? null
|
|
123
|
+
: { borderTopWidth: 0.5, borderTopColor: borderColor }
|
|
124
|
+
}
|
|
125
|
+
>
|
|
126
|
+
<Pressable
|
|
127
|
+
accessibilityRole="button"
|
|
128
|
+
accessibilityLabel={section.title}
|
|
129
|
+
accessibilityState={{ expanded: open }}
|
|
130
|
+
onPress={onPress}
|
|
131
|
+
style={{
|
|
132
|
+
flexDirection: "row",
|
|
133
|
+
alignItems: "center",
|
|
134
|
+
gap: 12,
|
|
135
|
+
paddingHorizontal: 16,
|
|
136
|
+
paddingVertical: 14,
|
|
137
|
+
}}
|
|
138
|
+
>
|
|
139
|
+
<View style={{ flex: 1 }}>
|
|
140
|
+
<RNText style={{ ...typeScale.body, fontWeight: "600", color: foreground }}>
|
|
141
|
+
{section.title}
|
|
142
|
+
</RNText>
|
|
143
|
+
{section.description ? (
|
|
144
|
+
<RNText style={{ ...typeScale.caption, color: muted, marginTop: 2 }}>
|
|
145
|
+
{section.description}
|
|
146
|
+
</RNText>
|
|
147
|
+
) : null}
|
|
148
|
+
</View>
|
|
149
|
+
<AnimatedChevron rotation={rotation} color={muted} />
|
|
150
|
+
</Pressable>
|
|
151
|
+
{open ? (
|
|
152
|
+
<View style={{ paddingHorizontal: 16, paddingBottom: 16 }}>{section.content}</View>
|
|
153
|
+
) : null}
|
|
154
|
+
</View>
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function AnimatedChevron({ rotation, color }: { rotation: any; color: string }) {
|
|
159
|
+
const { Animated, Text: RNText } = primitives();
|
|
160
|
+
return (
|
|
161
|
+
<Animated.View style={{ transform: [{ rotate: rotation }] }}>
|
|
162
|
+
<RNText style={{ fontSize: 13, color }}>▸</RNText>
|
|
163
|
+
</Animated.View>
|
|
164
|
+
);
|
|
165
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState, type ReactNode } from "react";
|
|
2
|
+
import type { StyleProp, ViewStyle } from "react-native";
|
|
3
|
+
|
|
4
|
+
import { colors, radii } from "./internal/tokens";
|
|
5
|
+
import { primitives } from "./internal/primitives";
|
|
6
|
+
import { useIsDark } from "./internal/motion";
|
|
7
|
+
import { Glass } from "./Glass";
|
|
8
|
+
import { Button } from "./Button";
|
|
9
|
+
|
|
10
|
+
export interface ActionSheetOption {
|
|
11
|
+
label: string;
|
|
12
|
+
/** Tints the row destructive, for delete actions. */
|
|
13
|
+
destructive?: boolean;
|
|
14
|
+
onPress?: () => void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ActionSheetProps {
|
|
18
|
+
open?: boolean;
|
|
19
|
+
onOpenChange?: (open: boolean) => void;
|
|
20
|
+
title?: string;
|
|
21
|
+
message?: string;
|
|
22
|
+
options: ActionSheetOption[];
|
|
23
|
+
cancelLabel?: string;
|
|
24
|
+
isDark?: boolean;
|
|
25
|
+
/** Passed through to the sheet so it is testable. */
|
|
26
|
+
testID?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* A list of choices attached to the bottom of the screen.
|
|
31
|
+
*
|
|
32
|
+
* Anchored to the bottom because that is where a thumb reaches, and it keeps a
|
|
33
|
+
* separate Cancel row so a mis-tap is always reversible.
|
|
34
|
+
*/
|
|
35
|
+
export function ActionSheet({
|
|
36
|
+
open: controlledOpen,
|
|
37
|
+
onOpenChange,
|
|
38
|
+
title,
|
|
39
|
+
message,
|
|
40
|
+
options,
|
|
41
|
+
cancelLabel = "Cancel",
|
|
42
|
+
isDark: isDarkProp,
|
|
43
|
+
testID,
|
|
44
|
+
}: ActionSheetProps) {
|
|
45
|
+
const isDark = useIsDark(isDarkProp);
|
|
46
|
+
const theme = isDark ? colors.dark : colors.light;
|
|
47
|
+
// Android's back button is handled by Modal's onRequestClose, so no
|
|
48
|
+
// BackHandler subscription is needed here.
|
|
49
|
+
const { View, Text, Pressable, Modal } = primitives();
|
|
50
|
+
const [uncontrolled, setUncontrolled] = useState(false);
|
|
51
|
+
const open = controlledOpen ?? uncontrolled;
|
|
52
|
+
|
|
53
|
+
const close = () => {
|
|
54
|
+
if (controlledOpen === undefined) setUncontrolled(false);
|
|
55
|
+
onOpenChange?.(false);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<Modal
|
|
60
|
+
visible={open}
|
|
61
|
+
transparent
|
|
62
|
+
animationType="slide"
|
|
63
|
+
onRequestClose={close}
|
|
64
|
+
testID={testID}
|
|
65
|
+
>
|
|
66
|
+
<Pressable
|
|
67
|
+
accessibilityRole="button"
|
|
68
|
+
accessibilityLabel="Dismiss actions"
|
|
69
|
+
onPress={close}
|
|
70
|
+
style={{ flex: 1, justifyContent: "flex-end", backgroundColor: theme.scrim }}
|
|
71
|
+
>
|
|
72
|
+
<Pressable
|
|
73
|
+
accessibilityRole="none"
|
|
74
|
+
onPress={() => {}}
|
|
75
|
+
style={{ padding: 10, gap: 8 }}
|
|
76
|
+
>
|
|
77
|
+
{/* The web's ActionSheet is not one panel: it is a stack of separate
|
|
78
|
+
glass pills. That shape is the single most visible difference in
|
|
79
|
+
the owner's screenshots, so each row gets its own surface. */}
|
|
80
|
+
{(title || message) && (
|
|
81
|
+
<Glass
|
|
82
|
+
effect="regular"
|
|
83
|
+
surface="overlay"
|
|
84
|
+
isDark={isDark}
|
|
85
|
+
style={{ borderRadius: radii.lg }}
|
|
86
|
+
>
|
|
87
|
+
<View style={{ paddingVertical: 12, paddingHorizontal: 16, alignItems: "center" }}>
|
|
88
|
+
{title && (
|
|
89
|
+
<Text style={{ fontSize: 13, fontWeight: "600", color: theme.foreground }}>
|
|
90
|
+
{title}
|
|
91
|
+
</Text>
|
|
92
|
+
)}
|
|
93
|
+
{message && (
|
|
94
|
+
<Text style={{ fontSize: 12, color: theme.muted, marginTop: 4, textAlign: "center" }}>
|
|
95
|
+
{message}
|
|
96
|
+
</Text>
|
|
97
|
+
)}
|
|
98
|
+
</View>
|
|
99
|
+
</Glass>
|
|
100
|
+
)}
|
|
101
|
+
|
|
102
|
+
{options.map((option) => (
|
|
103
|
+
<Glass
|
|
104
|
+
key={option.label}
|
|
105
|
+
effect="regular"
|
|
106
|
+
surface="overlay"
|
|
107
|
+
isDark={isDark}
|
|
108
|
+
style={{ borderRadius: radii.pill }}
|
|
109
|
+
>
|
|
110
|
+
<Pressable
|
|
111
|
+
accessibilityRole="button"
|
|
112
|
+
accessibilityLabel={option.label}
|
|
113
|
+
onPress={() => {
|
|
114
|
+
option.onPress?.();
|
|
115
|
+
close();
|
|
116
|
+
}}
|
|
117
|
+
style={{ minHeight: 44, paddingVertical: 12, paddingHorizontal: 20, alignItems: "center", justifyContent: "center" }}
|
|
118
|
+
>
|
|
119
|
+
<Text
|
|
120
|
+
style={{
|
|
121
|
+
fontSize: 17,
|
|
122
|
+
// The web's iOS-style action sheet: every row is the tint
|
|
123
|
+
// colour, and only a destructive one is red.
|
|
124
|
+
color: option.destructive ? theme.destructive : theme.fill,
|
|
125
|
+
}}
|
|
126
|
+
>
|
|
127
|
+
{option.label}
|
|
128
|
+
</Text>
|
|
129
|
+
</Pressable>
|
|
130
|
+
</Glass>
|
|
131
|
+
))}
|
|
132
|
+
|
|
133
|
+
<Glass effect="regular" surface="overlay" isDark={isDark} style={{ borderRadius: radii.pill }}>
|
|
134
|
+
<Pressable
|
|
135
|
+
accessibilityRole="button"
|
|
136
|
+
accessibilityLabel={cancelLabel}
|
|
137
|
+
onPress={close}
|
|
138
|
+
style={{ minHeight: 44, paddingVertical: 12, alignItems: "center", justifyContent: "center" }}
|
|
139
|
+
>
|
|
140
|
+
<Text style={{ fontSize: 17, fontWeight: "600", color: theme.foreground }}>
|
|
141
|
+
{cancelLabel}
|
|
142
|
+
</Text>
|
|
143
|
+
</Pressable>
|
|
144
|
+
</Glass>
|
|
145
|
+
</Pressable>
|
|
146
|
+
</Pressable>
|
|
147
|
+
</Modal>
|
|
148
|
+
);
|
|
149
|
+
}
|
package/src/Alert.tsx
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// Wave 2 — Alert.
|
|
2
|
+
//
|
|
3
|
+
// The donor's static callout: a named region with a title and description, not a
|
|
4
|
+
// tap target. Dressed on the family's glass with the same radius and type steps
|
|
5
|
+
// as Card, tinted by tone rather than by a second surface.
|
|
6
|
+
|
|
7
|
+
import type { ReactNode } from "react";
|
|
8
|
+
import type { StyleProp, ViewStyle } from "react-native";
|
|
9
|
+
|
|
10
|
+
import { Glass } from "./Glass";
|
|
11
|
+
import { colors, radii, typeScale } from "./internal/tokens";
|
|
12
|
+
import { primitives } from "./internal/primitives";
|
|
13
|
+
import { useIsDark } from "./internal/motion";
|
|
14
|
+
|
|
15
|
+
export type AlertTone = "default" | "info" | "success" | "warning" | "destructive";
|
|
16
|
+
|
|
17
|
+
export interface AlertProps {
|
|
18
|
+
title: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
icon?: ReactNode;
|
|
21
|
+
tone?: AlertTone;
|
|
22
|
+
/** Optional dismiss control. */
|
|
23
|
+
onDismiss?: () => void;
|
|
24
|
+
isDark?: boolean;
|
|
25
|
+
style?: StyleProp<ViewStyle>;
|
|
26
|
+
testID?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function Alert({
|
|
30
|
+
title,
|
|
31
|
+
description,
|
|
32
|
+
icon,
|
|
33
|
+
tone = "default",
|
|
34
|
+
onDismiss,
|
|
35
|
+
isDark: isDarkProp,
|
|
36
|
+
style,
|
|
37
|
+
testID,
|
|
38
|
+
}: AlertProps) {
|
|
39
|
+
const isDark = useIsDark(isDarkProp);
|
|
40
|
+
const theme = isDark ? colors.dark : colors.light;
|
|
41
|
+
const { View, Pressable, Text: RNText } = primitives();
|
|
42
|
+
|
|
43
|
+
const accent =
|
|
44
|
+
tone === "destructive"
|
|
45
|
+
? theme.destructive
|
|
46
|
+
: tone === "success"
|
|
47
|
+
? theme.on
|
|
48
|
+
: tone === "warning"
|
|
49
|
+
? theme.warning
|
|
50
|
+
: tone === "info"
|
|
51
|
+
? theme.info
|
|
52
|
+
: theme.foreground;
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<Glass
|
|
56
|
+
effect="regular"
|
|
57
|
+
surface="panel"
|
|
58
|
+
isDark={isDark}
|
|
59
|
+
testID={testID}
|
|
60
|
+
accessibilityRole="alert"
|
|
61
|
+
role="alert"
|
|
62
|
+
style={[{ borderRadius: radii.lg, padding: 14 }, style]}
|
|
63
|
+
>
|
|
64
|
+
<View style={{ flexDirection: "row", gap: 12, alignItems: "flex-start" }}>
|
|
65
|
+
{icon ? <View style={{ marginTop: 1 }}>{icon}</View> : null}
|
|
66
|
+
<View style={{ flex: 1, gap: 3 }}>
|
|
67
|
+
<RNText style={{ ...typeScale.label, color: accent }}>{title}</RNText>
|
|
68
|
+
{description ? (
|
|
69
|
+
<RNText style={{ ...typeScale.caption, color: theme.muted }}>{description}</RNText>
|
|
70
|
+
) : null}
|
|
71
|
+
</View>
|
|
72
|
+
{onDismiss ? (
|
|
73
|
+
<Pressable
|
|
74
|
+
accessibilityRole="button"
|
|
75
|
+
accessibilityLabel="Dismiss"
|
|
76
|
+
onPress={onDismiss}
|
|
77
|
+
hitSlop={8}
|
|
78
|
+
>
|
|
79
|
+
<RNText style={{ fontSize: 13, color: theme.muted }}>✕</RNText>
|
|
80
|
+
</Pressable>
|
|
81
|
+
) : null}
|
|
82
|
+
</View>
|
|
83
|
+
</Glass>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// Wave 2 — AlertDialog.
|
|
2
|
+
//
|
|
3
|
+
// The donor's deliberate modal: it is announced as an alert dialog, it does not
|
|
4
|
+
// dismiss on a backdrop press, and it always offers a cancel path. Dressed with
|
|
5
|
+
// the family's glass, buttons and destructive tone.
|
|
6
|
+
|
|
7
|
+
import { useState, type ReactNode } from "react";
|
|
8
|
+
|
|
9
|
+
import { Button } from "./Button";
|
|
10
|
+
import { Glass } from "./Glass";
|
|
11
|
+
import { colors, radii, typeScale } from "./internal/tokens";
|
|
12
|
+
import { primitives } from "./internal/primitives";
|
|
13
|
+
import { useIsDark } from "./internal/motion";
|
|
14
|
+
import { useBackDismiss } from "./internal/overlay";
|
|
15
|
+
|
|
16
|
+
export interface AlertDialogProps {
|
|
17
|
+
open?: boolean;
|
|
18
|
+
onOpenChange?: (open: boolean) => void;
|
|
19
|
+
title: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
/** Extra content between the description and the actions. */
|
|
22
|
+
children?: ReactNode;
|
|
23
|
+
confirmLabel?: string;
|
|
24
|
+
cancelLabel?: string;
|
|
25
|
+
destructive?: boolean;
|
|
26
|
+
onConfirm?: () => void;
|
|
27
|
+
onCancel?: () => void;
|
|
28
|
+
isDark?: boolean;
|
|
29
|
+
testID?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function AlertDialog({
|
|
33
|
+
open: openProp,
|
|
34
|
+
onOpenChange,
|
|
35
|
+
title,
|
|
36
|
+
description,
|
|
37
|
+
children,
|
|
38
|
+
confirmLabel = "Confirm",
|
|
39
|
+
cancelLabel = "Cancel",
|
|
40
|
+
destructive = false,
|
|
41
|
+
onConfirm,
|
|
42
|
+
onCancel,
|
|
43
|
+
isDark: isDarkProp,
|
|
44
|
+
testID,
|
|
45
|
+
}: AlertDialogProps) {
|
|
46
|
+
const isDark = useIsDark(isDarkProp);
|
|
47
|
+
const theme = isDark ? colors.dark : colors.light;
|
|
48
|
+
const { View, Pressable, Text: RNText, Modal } = primitives();
|
|
49
|
+
|
|
50
|
+
const [internalOpen, setInternalOpen] = useState(false);
|
|
51
|
+
const open = openProp !== undefined ? openProp : internalOpen;
|
|
52
|
+
|
|
53
|
+
const close = (next: boolean) => {
|
|
54
|
+
if (openProp === undefined) setInternalOpen(next);
|
|
55
|
+
onOpenChange?.(next);
|
|
56
|
+
};
|
|
57
|
+
useBackDismiss(open, () => {
|
|
58
|
+
onCancel?.();
|
|
59
|
+
close(false);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<Modal visible={open} transparent animationType="fade" onRequestClose={() => close(false)}>
|
|
64
|
+
<View style={{ flex: 1, backgroundColor: theme.scrim }}>
|
|
65
|
+
<Pressable
|
|
66
|
+
accessibilityRole="button"
|
|
67
|
+
accessibilityLabel="Close dialog"
|
|
68
|
+
// Deliberately inert: an alert dialog is a decision, not a dismissible
|
|
69
|
+
// surface. The backdrop exists only to block what is behind it.
|
|
70
|
+
onPress={undefined}
|
|
71
|
+
style={{ position: "absolute", top: 0, left: 0, right: 0, bottom: 0 }}
|
|
72
|
+
/>
|
|
73
|
+
<View style={{ flex: 1, justifyContent: "center", padding: 24 }} pointerEvents="box-none">
|
|
74
|
+
<Pressable accessibilityRole="none" onPress={() => {}}>
|
|
75
|
+
<Glass
|
|
76
|
+
effect="regular"
|
|
77
|
+
surface="overlay"
|
|
78
|
+
isDark={isDark}
|
|
79
|
+
testID={testID}
|
|
80
|
+
accessibilityViewIsModal
|
|
81
|
+
style={{
|
|
82
|
+
borderRadius: radii.lg,
|
|
83
|
+
backgroundColor: theme.surface,
|
|
84
|
+
padding: 20,
|
|
85
|
+
gap: 10,
|
|
86
|
+
}}
|
|
87
|
+
>
|
|
88
|
+
<RNText accessibilityRole="heading" as any style={{ ...typeScale.heading, color: theme.foreground }}>
|
|
89
|
+
{title}
|
|
90
|
+
</RNText>
|
|
91
|
+
{description ? (
|
|
92
|
+
<RNText style={{ ...typeScale.body, color: theme.muted }}>{description}</RNText>
|
|
93
|
+
) : null}
|
|
94
|
+
{children ? <View>{children}</View> : null}
|
|
95
|
+
<View style={{ flexDirection: "row", justifyContent: "flex-end", gap: 8, marginTop: 8 }}>
|
|
96
|
+
<Button
|
|
97
|
+
accessibilityLabel={cancelLabel}
|
|
98
|
+
variant="ghost"
|
|
99
|
+
onPress={() => {
|
|
100
|
+
onCancel?.();
|
|
101
|
+
close(false);
|
|
102
|
+
}}
|
|
103
|
+
>
|
|
104
|
+
{cancelLabel}
|
|
105
|
+
</Button>
|
|
106
|
+
<Button
|
|
107
|
+
accessibilityLabel={confirmLabel}
|
|
108
|
+
variant="filled"
|
|
109
|
+
tint={destructive ? theme.destructive : theme.fill}
|
|
110
|
+
onPress={() => {
|
|
111
|
+
onConfirm?.();
|
|
112
|
+
close(false);
|
|
113
|
+
}}
|
|
114
|
+
>
|
|
115
|
+
{confirmLabel}
|
|
116
|
+
</Button>
|
|
117
|
+
</View>
|
|
118
|
+
</Glass>
|
|
119
|
+
</Pressable>
|
|
120
|
+
</View>
|
|
121
|
+
</View>
|
|
122
|
+
</Modal>
|
|
123
|
+
);
|
|
124
|
+
}
|
package/src/Avatar.tsx
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// Wave 2 — Avatar.
|
|
2
|
+
//
|
|
3
|
+
// The donor's behaviour: a decorative image with an accessible name, an
|
|
4
|
+
// initials fallback when the image is missing or fails, and a status dot that is
|
|
5
|
+
// announced rather than colour-only. Dressed as the family's glass ring.
|
|
6
|
+
|
|
7
|
+
import { useState } from "react";
|
|
8
|
+
import type { StyleProp, ViewStyle } from "react-native";
|
|
9
|
+
|
|
10
|
+
import { Glass } from "./Glass";
|
|
11
|
+
import { colors, controlSizes, radii } from "./internal/tokens";
|
|
12
|
+
import { primitives } from "./internal/primitives";
|
|
13
|
+
import { useIsDark } from "./internal/motion";
|
|
14
|
+
import { initialsOf } from "./internal/initials";
|
|
15
|
+
|
|
16
|
+
export type AvatarSize = "sm" | "md" | "lg";
|
|
17
|
+
|
|
18
|
+
export interface AvatarProps {
|
|
19
|
+
source?: { uri: string } | number;
|
|
20
|
+
name?: string;
|
|
21
|
+
size?: AvatarSize;
|
|
22
|
+
status?: "online" | "offline" | "busy";
|
|
23
|
+
style?: StyleProp<ViewStyle>;
|
|
24
|
+
isDark?: boolean;
|
|
25
|
+
testID?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const STATUS_COLOR = { online: "on", offline: "muted", busy: "destructive" } as const;
|
|
29
|
+
|
|
30
|
+
export function Avatar({
|
|
31
|
+
source,
|
|
32
|
+
name,
|
|
33
|
+
size = "md",
|
|
34
|
+
status,
|
|
35
|
+
style,
|
|
36
|
+
isDark: isDarkProp,
|
|
37
|
+
testID,
|
|
38
|
+
}: AvatarProps) {
|
|
39
|
+
const isDark = useIsDark(isDarkProp);
|
|
40
|
+
const theme = isDark ? colors.dark : colors.light;
|
|
41
|
+
const { View, Text: RNText, Image } = primitives();
|
|
42
|
+
const [failed, setFailed] = useState(false);
|
|
43
|
+
const dimension = controlSizes.swatch[size === "sm" ? "sm" : size === "lg" ? "lg" : "md"];
|
|
44
|
+
const label = name ? `Avatar of ${name}` : "Avatar";
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<View testID={testID} style={{ alignSelf: "flex-start" }}>
|
|
48
|
+
<Glass
|
|
49
|
+
effect="regular"
|
|
50
|
+
surface="control"
|
|
51
|
+
isDark={isDark}
|
|
52
|
+
accessible
|
|
53
|
+
accessibilityRole="image"
|
|
54
|
+
accessibilityLabel={label}
|
|
55
|
+
style={[
|
|
56
|
+
{
|
|
57
|
+
width: dimension,
|
|
58
|
+
height: dimension,
|
|
59
|
+
borderRadius: radii.pill,
|
|
60
|
+
alignItems: "center",
|
|
61
|
+
justifyContent: "center",
|
|
62
|
+
backgroundColor: theme.wash,
|
|
63
|
+
overflow: "visible",
|
|
64
|
+
},
|
|
65
|
+
style,
|
|
66
|
+
]}
|
|
67
|
+
>
|
|
68
|
+
{source && !failed ? (
|
|
69
|
+
<Image
|
|
70
|
+
source={source}
|
|
71
|
+
onError={() => setFailed(true)}
|
|
72
|
+
accessibilityLabel={name}
|
|
73
|
+
style={{ width: dimension, height: dimension, borderRadius: dimension / 2 }}
|
|
74
|
+
/>
|
|
75
|
+
) : (
|
|
76
|
+
<RNText style={{ fontSize: dimension * 0.36, fontWeight: "600", color: theme.foreground }}>
|
|
77
|
+
{initialsOf(name ?? "?")}
|
|
78
|
+
</RNText>
|
|
79
|
+
)}
|
|
80
|
+
{status ? (
|
|
81
|
+
<View
|
|
82
|
+
style={{
|
|
83
|
+
position: "absolute",
|
|
84
|
+
right: 0,
|
|
85
|
+
bottom: 0,
|
|
86
|
+
width: Math.max(9, dimension * 0.26),
|
|
87
|
+
height: Math.max(9, dimension * 0.26),
|
|
88
|
+
borderRadius: dimension,
|
|
89
|
+
borderWidth: 2,
|
|
90
|
+
borderColor: theme.glassSolid,
|
|
91
|
+
backgroundColor:
|
|
92
|
+
status === "online" ? theme.on : status === "busy" ? theme.destructive : theme.muted,
|
|
93
|
+
}}
|
|
94
|
+
/>
|
|
95
|
+
) : null}
|
|
96
|
+
</Glass>
|
|
97
|
+
</View>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export { initialsOf };
|
|
102
|
+
export type { STATUS_COLOR };
|
package/src/Badge.tsx
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// Wave 2 — Badge.
|
|
2
|
+
//
|
|
3
|
+
// The donor's badge is a short, non-interactive count/label that is announced as
|
|
4
|
+
// one unit. Dressed as the family's capsule: the same 28dp small height as the
|
|
5
|
+
// button scale, the same pill radius, the same type step.
|
|
6
|
+
|
|
7
|
+
import type { ReactNode } from "react";
|
|
8
|
+
import type { StyleProp, ViewStyle } from "react-native";
|
|
9
|
+
|
|
10
|
+
import { colors, radii, typeScale } from "./internal/tokens";
|
|
11
|
+
import { primitives } from "./internal/primitives";
|
|
12
|
+
import { useIsDark } from "./internal/motion";
|
|
13
|
+
|
|
14
|
+
export interface BadgeProps {
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
tone?: "fill" | "destructive" | "success" | "muted";
|
|
17
|
+
/** Wraps the badge around a control, e.g. an icon button with a count. */
|
|
18
|
+
overlay?: ReactNode;
|
|
19
|
+
isDark?: boolean;
|
|
20
|
+
style?: StyleProp<ViewStyle>;
|
|
21
|
+
testID?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function Badge({
|
|
25
|
+
children,
|
|
26
|
+
tone = "fill",
|
|
27
|
+
overlay,
|
|
28
|
+
isDark: isDarkProp,
|
|
29
|
+
style,
|
|
30
|
+
testID,
|
|
31
|
+
}: BadgeProps) {
|
|
32
|
+
const isDark = useIsDark(isDarkProp);
|
|
33
|
+
const theme = isDark ? colors.dark : colors.light;
|
|
34
|
+
const { View, Text: RNText } = primitives();
|
|
35
|
+
|
|
36
|
+
const background =
|
|
37
|
+
tone === "destructive"
|
|
38
|
+
? theme.destructive
|
|
39
|
+
: tone === "success"
|
|
40
|
+
? theme.on
|
|
41
|
+
: tone === "muted"
|
|
42
|
+
? theme.wash
|
|
43
|
+
: theme.fill;
|
|
44
|
+
const color = tone === "muted" ? theme.foreground : theme.onTint;
|
|
45
|
+
|
|
46
|
+
const badge = (
|
|
47
|
+
<View
|
|
48
|
+
testID={testID}
|
|
49
|
+
accessible
|
|
50
|
+
accessibilityRole="text"
|
|
51
|
+
style={[
|
|
52
|
+
{
|
|
53
|
+
minHeight: 20,
|
|
54
|
+
minWidth: 20,
|
|
55
|
+
paddingHorizontal: 7,
|
|
56
|
+
borderRadius: radii.pill,
|
|
57
|
+
backgroundColor: background,
|
|
58
|
+
alignItems: "center",
|
|
59
|
+
justifyContent: "center",
|
|
60
|
+
alignSelf: "flex-start",
|
|
61
|
+
},
|
|
62
|
+
style,
|
|
63
|
+
]}
|
|
64
|
+
>
|
|
65
|
+
{typeof children === "string" || typeof children === "number" ? (
|
|
66
|
+
<RNText style={{ ...typeScale.caption, fontWeight: "700", color }}>{children}</RNText>
|
|
67
|
+
) : (
|
|
68
|
+
children
|
|
69
|
+
)}
|
|
70
|
+
</View>
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
if (!overlay) return badge;
|
|
74
|
+
return (
|
|
75
|
+
<View style={{ alignSelf: "flex-start" }}>
|
|
76
|
+
{overlay}
|
|
77
|
+
<View style={{ position: "absolute", top: -6, right: -6 }}>{badge}</View>
|
|
78
|
+
</View>
|
|
79
|
+
);
|
|
80
|
+
}
|