@zendir/ui 0.4.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/README.md +640 -631
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/index.js +17 -221
- package/dist/react/3d/CesiumCaptureSource.d.ts +0 -1
- package/dist/react/3d/CesiumCaptureSource.js +364 -283
- package/dist/react/3d/CesiumCaptureSource.js.map +1 -1
- package/dist/react/3d/ZenSpace3D.d.ts +2 -3
- package/dist/react/3d/ZenSpace3D.js +1681 -1237
- package/dist/react/3d/ZenSpace3D.js.map +1 -1
- package/dist/react/3d/ZenSpace3DCesium.d.ts +0 -1
- package/dist/react/3d/ZenSpace3DCesium.js +513 -560
- package/dist/react/3d/ZenSpace3DCesium.js.map +1 -1
- package/dist/react/3d/ZenSpace3DShaders.js +61 -66
- package/dist/react/3d/ZenSpace3DShaders.js.map +1 -1
- package/dist/react/3d/ZenSpace3DTypes.d.ts +19 -20
- package/dist/react/3d/ZenSpace3DUtils.d.ts +0 -1
- package/dist/react/3d/ZenSpace3DUtils.js +37 -24
- package/dist/react/3d/ZenSpace3DUtils.js.map +1 -1
- package/dist/react/3d/capturePngAnalysis.js +42 -36
- package/dist/react/3d/capturePngAnalysis.js.map +1 -1
- package/dist/react/3d/index.d.ts +3 -3
- package/dist/react/3d/index.js +5 -53
- package/dist/react/3d/threeLoader.d.ts +1 -1
- package/dist/react/3d/threeLoader.js +23 -18
- package/dist/react/3d/threeLoader.js.map +1 -1
- package/dist/react/astro/ClassificationBanner.d.ts +2 -3
- package/dist/react/astro/ClassificationBanner.js +95 -79
- package/dist/react/astro/ClassificationBanner.js.map +1 -1
- package/dist/react/astro/GlobalStatusBar.d.ts +0 -1
- package/dist/react/astro/GlobalStatusBar.js +157 -163
- package/dist/react/astro/GlobalStatusBar.js.map +1 -1
- package/dist/react/astro/MissionClock.d.ts +7 -8
- package/dist/react/astro/MissionClock.js +377 -400
- package/dist/react/astro/MissionClock.js.map +1 -1
- package/dist/react/astro/MonitoringIcon.d.ts +1 -2
- package/dist/react/astro/MonitoringIcon.js +422 -358
- package/dist/react/astro/MonitoringIcon.js.map +1 -1
- package/dist/react/astro/Notification.d.ts +1 -2
- package/dist/react/astro/Notification.js +229 -126
- package/dist/react/astro/Notification.js.map +1 -1
- package/dist/react/astro/Progress.d.ts +0 -1
- package/dist/react/astro/Progress.js +199 -141
- package/dist/react/astro/Progress.js.map +1 -1
- package/dist/react/astro/SimulationControls.d.ts +3 -4
- package/dist/react/astro/SimulationControls.js +596 -650
- package/dist/react/astro/SimulationControls.js.map +1 -1
- package/dist/react/astro/StatusIndicator.d.ts +0 -1
- package/dist/react/astro/StatusIndicator.js +236 -170
- package/dist/react/astro/StatusIndicator.js.map +1 -1
- package/dist/react/astro/UnifiedTimeline.d.ts +9 -10
- package/dist/react/astro/UnifiedTimeline.js +2345 -2392
- package/dist/react/astro/UnifiedTimeline.js.map +1 -1
- package/dist/react/astro/index.d.ts +5 -5
- package/dist/react/astro/index.js +1 -25
- package/dist/react/cards/AccessCard.d.ts +0 -1
- package/dist/react/cards/AccessCard.js +471 -405
- package/dist/react/cards/AccessCard.js.map +1 -1
- package/dist/react/cards/OrbitCard.d.ts +0 -1
- package/dist/react/cards/OrbitCard.js +487 -364
- package/dist/react/cards/OrbitCard.js.map +1 -1
- package/dist/react/cards/SpacecraftCard.d.ts +0 -1
- package/dist/react/cards/SpacecraftCard.js +813 -925
- package/dist/react/cards/SpacecraftCard.js.map +1 -1
- package/dist/react/cards/TelemetryCard.d.ts +0 -1
- package/dist/react/cards/TelemetryCard.js +1055 -732
- package/dist/react/cards/TelemetryCard.js.map +1 -1
- package/dist/react/cards/TelemetryStreamCard.d.ts +0 -1
- package/dist/react/cards/TelemetryStreamCard.js +323 -297
- package/dist/react/cards/TelemetryStreamCard.js.map +1 -1
- package/dist/react/cards/index.d.ts +1 -1
- package/dist/react/cards/index.js +1 -8
- package/dist/react/charts/GroundTrackMap.d.ts +6 -7
- package/dist/react/charts/GroundTrackMap.js +1377 -1256
- package/dist/react/charts/GroundTrackMap.js.map +1 -1
- package/dist/react/charts/GroundTrackMapLeaflet.d.ts +1 -2
- package/dist/react/charts/GroundTrackMapLeaflet.js +1065 -987
- package/dist/react/charts/GroundTrackMapLeaflet.js.map +1 -1
- package/dist/react/charts/groundTrackMapLeafletTiles.js +34 -25
- package/dist/react/charts/groundTrackMapLeafletTiles.js.map +1 -1
- package/dist/react/charts/groundTrackMapLeafletUtils.js +70 -61
- package/dist/react/charts/groundTrackMapLeafletUtils.js.map +1 -1
- package/dist/react/charts/index.d.ts +1 -1
- package/dist/react/charts/index.js +7 -100
- package/dist/react/charts/unified/AstroChart.d.ts +1 -2
- package/dist/react/charts/unified/AstroChart.js +1331 -1411
- package/dist/react/charts/unified/AstroChart.js.map +1 -1
- package/dist/react/charts/unified/PowerOverviewChart.d.ts +3 -3
- package/dist/react/charts/unified/PowerOverviewChart.js +495 -478
- package/dist/react/charts/unified/PowerOverviewChart.js.map +1 -1
- package/dist/react/charts/unified/domain.d.ts +12 -13
- package/dist/react/charts/unified/domain.js +3999 -3145
- package/dist/react/charts/unified/domain.js.map +1 -1
- package/dist/react/charts/unified/generators.d.ts +3 -4
- package/dist/react/charts/unified/generators.js +561 -498
- package/dist/react/charts/unified/generators.js.map +1 -1
- package/dist/react/charts/unified/index.d.ts +1 -1
- package/dist/react/charts/unified/presets.d.ts +14 -15
- package/dist/react/charts/unified/presets.js +857 -994
- package/dist/react/charts/unified/presets.js.map +1 -1
- package/dist/react/charts/unified/sync.d.ts +2 -3
- package/dist/react/charts/unified/sync.js +229 -195
- package/dist/react/charts/unified/sync.js.map +1 -1
- package/dist/react/charts/unified/theme.d.ts +11 -12
- package/dist/react/charts/unified/theme.js +606 -642
- package/dist/react/charts/unified/theme.js.map +1 -1
- package/dist/react/charts/unified/types.d.ts +32 -33
- package/dist/react/charts/unified/useChartStream.d.ts +1 -2
- package/dist/react/charts/unified/useChartStream.js +203 -216
- package/dist/react/charts/unified/useChartStream.js.map +1 -1
- package/dist/react/chatgpt/AppCard.d.ts +1 -2
- package/dist/react/chatgpt/index.d.ts +7 -7
- package/dist/react/chatgpt/index.js +160 -139
- package/dist/react/chatgpt/index.js.map +1 -1
- package/dist/react/context/CategoryContext.d.ts +0 -1
- package/dist/react/context/CategoryContext.js +78 -29
- package/dist/react/context/CategoryContext.js.map +1 -1
- package/dist/react/context/DisplaySettingsContext.d.ts +1 -2
- package/dist/react/context/DisplaySettingsContext.js +205 -156
- package/dist/react/context/DisplaySettingsContext.js.map +1 -1
- package/dist/react/context/SpatialSelectionContext.d.ts +0 -1
- package/dist/react/context/SpatialSelectionContext.js +36 -7
- package/dist/react/context/SpatialSelectionContext.js.map +1 -1
- package/dist/react/core/data/DataTable.d.ts +3 -4
- package/dist/react/core/data/DataTable.js +473 -440
- package/dist/react/core/data/DataTable.js.map +1 -1
- package/dist/react/core/data/DataValue.d.ts +4 -5
- package/dist/react/core/data/DataValue.js +605 -538
- package/dist/react/core/data/DataValue.js.map +1 -1
- package/dist/react/core/data/propertyConfig.d.ts +1 -2
- package/dist/react/core/data/propertyConfig.js +446 -382
- package/dist/react/core/data/propertyConfig.js.map +1 -1
- package/dist/react/core/display/AstroIcon.d.ts +4 -5
- package/dist/react/core/display/AstroIcon.js +339 -429
- package/dist/react/core/display/AstroIcon.js.map +1 -1
- package/dist/react/core/display/Badge.d.ts +2 -3
- package/dist/react/core/display/Badge.js +131 -131
- package/dist/react/core/display/Badge.js.map +1 -1
- package/dist/react/core/display/CardHeader.d.ts +0 -1
- package/dist/react/core/display/CardHeader.js +398 -311
- package/dist/react/core/display/CardHeader.js.map +1 -1
- package/dist/react/core/display/Container.d.ts +2 -3
- package/dist/react/core/display/Container.js +640 -668
- package/dist/react/core/display/Container.js.map +1 -1
- package/dist/react/core/display/CopyButton.d.ts +1 -2
- package/dist/react/core/display/CopyButton.js +158 -101
- package/dist/react/core/display/CopyButton.js.map +1 -1
- package/dist/react/core/display/GlassCard.d.ts +3 -4
- package/dist/react/core/display/GlassCard.js +416 -369
- package/dist/react/core/display/GlassCard.js.map +1 -1
- package/dist/react/core/display/HeaderIconWithStatus.d.ts +0 -1
- package/dist/react/core/display/HeaderIconWithStatus.js +152 -152
- package/dist/react/core/display/HeaderIconWithStatus.js.map +1 -1
- package/dist/react/core/display/Icon.d.ts +2 -3
- package/dist/react/core/display/Icon.js +172 -143
- package/dist/react/core/display/Icon.js.map +1 -1
- package/dist/react/core/display/Typography.d.ts +24 -25
- package/dist/react/core/display/Typography.js +360 -178
- package/dist/react/core/display/Typography.js.map +1 -1
- package/dist/react/core/feedback/ConfirmDialog.d.ts +1 -2
- package/dist/react/core/feedback/ConfirmDialog.js +343 -304
- package/dist/react/core/feedback/ConfirmDialog.js.map +1 -1
- package/dist/react/core/feedback/Dialog.d.ts +2 -3
- package/dist/react/core/feedback/Dialog.js +189 -197
- package/dist/react/core/feedback/Dialog.js.map +1 -1
- package/dist/react/core/feedback/Toast.d.ts +2 -3
- package/dist/react/core/feedback/Toast.js +346 -207
- package/dist/react/core/feedback/Toast.js.map +1 -1
- package/dist/react/core/index.d.ts +26 -26
- package/dist/react/core/index.js +7 -119
- package/dist/react/core/inputs/Button.d.ts +2 -3
- package/dist/react/core/inputs/Button.js +281 -304
- package/dist/react/core/inputs/Button.js.map +1 -1
- package/dist/react/core/inputs/Checkbox.d.ts +2 -3
- package/dist/react/core/inputs/Checkbox.js +139 -127
- package/dist/react/core/inputs/Checkbox.js.map +1 -1
- package/dist/react/core/inputs/Input.d.ts +3 -4
- package/dist/react/core/inputs/Input.js +277 -285
- package/dist/react/core/inputs/Input.js.map +1 -1
- package/dist/react/core/inputs/LimitsBar.d.ts +1 -2
- package/dist/react/core/inputs/LimitsBar.js +271 -196
- package/dist/react/core/inputs/LimitsBar.js.map +1 -1
- package/dist/react/core/inputs/NumberInput.d.ts +2 -3
- package/dist/react/core/inputs/NumberInput.js +531 -503
- package/dist/react/core/inputs/NumberInput.js.map +1 -1
- package/dist/react/core/inputs/PinInput.d.ts +2 -3
- package/dist/react/core/inputs/PinInput.js +224 -207
- package/dist/react/core/inputs/PinInput.js.map +1 -1
- package/dist/react/core/inputs/Select.d.ts +1 -2
- package/dist/react/core/inputs/Select.js +298 -299
- package/dist/react/core/inputs/Select.js.map +1 -1
- package/dist/react/core/inputs/Toggle.d.ts +2 -3
- package/dist/react/core/inputs/Toggle.js +142 -148
- package/dist/react/core/inputs/Toggle.js.map +1 -1
- package/dist/react/core/layout/Box.d.ts +3 -4
- package/dist/react/core/layout/Box.js +118 -122
- package/dist/react/core/layout/Box.js.map +1 -1
- package/dist/react/core/layout/Center.d.ts +0 -1
- package/dist/react/core/layout/Center.js +45 -32
- package/dist/react/core/layout/Center.js.map +1 -1
- package/dist/react/core/layout/Divider.d.ts +1 -2
- package/dist/react/core/layout/Divider.js +112 -106
- package/dist/react/core/layout/Divider.js.map +1 -1
- package/dist/react/core/layout/Flex.d.ts +4 -5
- package/dist/react/core/layout/Flex.js +120 -124
- package/dist/react/core/layout/Flex.js.map +1 -1
- package/dist/react/core/layout/Grid.d.ts +5 -6
- package/dist/react/core/layout/Grid.js +131 -138
- package/dist/react/core/layout/Grid.js.map +1 -1
- package/dist/react/core/layout/Spacer.d.ts +0 -1
- package/dist/react/core/layout/Spacer.js +36 -29
- package/dist/react/core/layout/Spacer.js.map +1 -1
- package/dist/react/core/layout/Stack.d.ts +4 -5
- package/dist/react/core/layout/Stack.js +127 -70
- package/dist/react/core/layout/Stack.js.map +1 -1
- package/dist/react/core/layout/responsive.d.ts +1 -2
- package/dist/react/core/layout/responsive.js +25 -19
- package/dist/react/core/layout/responsive.js.map +1 -1
- package/dist/react/core/layout/useBreakpoint.d.ts +1 -1
- package/dist/react/core/layout/useBreakpoint.js +119 -66
- package/dist/react/core/layout/useBreakpoint.js.map +1 -1
- package/dist/react/core/navigation/AppBar.d.ts +1 -2
- package/dist/react/core/navigation/AppBar.js +827 -805
- package/dist/react/core/navigation/AppBar.js.map +1 -1
- package/dist/react/core/navigation/Pagination.d.ts +2 -3
- package/dist/react/core/navigation/Pagination.js +207 -187
- package/dist/react/core/navigation/Pagination.js.map +1 -1
- package/dist/react/core/navigation/SideNav.d.ts +11 -5
- package/dist/react/core/navigation/SideNav.js +857 -602
- package/dist/react/core/navigation/SideNav.js.map +1 -1
- package/dist/react/core/navigation/Tabs.d.ts +0 -1
- package/dist/react/core/navigation/Tabs.js +113 -119
- package/dist/react/core/navigation/Tabs.js.map +1 -1
- package/dist/react/core/overlays/Popover.d.ts +2 -3
- package/dist/react/core/overlays/Popover.js +303 -282
- package/dist/react/core/overlays/Popover.js.map +1 -1
- package/dist/react/core/overlays/SidePanel.d.ts +1 -2
- package/dist/react/core/overlays/SidePanel.js +217 -212
- package/dist/react/core/overlays/SidePanel.js.map +1 -1
- package/dist/react/core/overlays/Tooltip.d.ts +1 -2
- package/dist/react/core/overlays/Tooltip.js +170 -176
- package/dist/react/core/overlays/Tooltip.js.map +1 -1
- package/dist/react/core/widgets/ActivityPlanner.d.ts +0 -1
- package/dist/react/core/widgets/ActivityPlanner.js +855 -517
- package/dist/react/core/widgets/ActivityPlanner.js.map +1 -1
- package/dist/react/core/widgets/Capture.d.ts +2 -3
- package/dist/react/core/widgets/Capture.js +965 -779
- package/dist/react/core/widgets/Capture.js.map +1 -1
- package/dist/react/core/widgets/ChatPanel.d.ts +16 -17
- package/dist/react/core/widgets/ChatPanel.js +1734 -1034
- package/dist/react/core/widgets/ChatPanel.js.map +1 -1
- package/dist/react/core/widgets/ColorPickerPanel.d.ts +0 -1
- package/dist/react/core/widgets/ColorPickerPanel.js +298 -287
- package/dist/react/core/widgets/ColorPickerPanel.js.map +1 -1
- package/dist/react/core/widgets/CommandBuilder.d.ts +2 -3
- package/dist/react/core/widgets/CommandBuilder.js +624 -516
- package/dist/react/core/widgets/CommandBuilder.js.map +1 -1
- package/dist/react/core/widgets/ConnectionForm.d.ts +2 -3
- package/dist/react/core/widgets/ConnectionForm.js +528 -492
- package/dist/react/core/widgets/ConnectionForm.js.map +1 -1
- package/dist/react/core/widgets/FileExplorer.d.ts +3 -4
- package/dist/react/core/widgets/FileExplorer.js +617 -505
- package/dist/react/core/widgets/FileExplorer.js.map +1 -1
- package/dist/react/core/widgets/HexViewer.d.ts +2 -3
- package/dist/react/core/widgets/HexViewer.js +1353 -1091
- package/dist/react/core/widgets/HexViewer.js.map +1 -1
- package/dist/react/core/widgets/ImageFrame.d.ts +1 -2
- package/dist/react/core/widgets/ImageFrame.js +230 -193
- package/dist/react/core/widgets/ImageFrame.js.map +1 -1
- package/dist/react/core/widgets/ImageGallery.d.ts +2 -1
- package/dist/react/core/widgets/ImageGallery.js +380 -314
- package/dist/react/core/widgets/ImageGallery.js.map +1 -1
- package/dist/react/core/widgets/ImagePanel.d.ts +0 -1
- package/dist/react/core/widgets/ImagePanel.js +110 -101
- package/dist/react/core/widgets/ImagePanel.js.map +1 -1
- package/dist/react/core/widgets/LogViewer.d.ts +2 -3
- package/dist/react/core/widgets/LogViewer.js +711 -607
- package/dist/react/core/widgets/LogViewer.js.map +1 -1
- package/dist/react/core/widgets/MessageStream.d.ts +3 -4
- package/dist/react/core/widgets/MessageStream.js +514 -444
- package/dist/react/core/widgets/MessageStream.js.map +1 -1
- package/dist/react/core/widgets/MissionCalendar.d.ts +3 -4
- package/dist/react/core/widgets/MissionCalendar.js +1488 -1020
- package/dist/react/core/widgets/MissionCalendar.js.map +1 -1
- package/dist/react/core/widgets/PacketViewer.d.ts +2 -3
- package/dist/react/core/widgets/PacketViewer.js +550 -421
- package/dist/react/core/widgets/PacketViewer.js.map +1 -1
- package/dist/react/core/widgets/capture-placeholder.png.js +6 -5
- package/dist/react/core/widgets/capture-placeholder.png.js.map +1 -1
- package/dist/react/hooks/index.d.ts +5 -5
- package/dist/react/hooks/useAccessWindows.d.ts +0 -1
- package/dist/react/hooks/useCompactMode.d.ts +1 -1
- package/dist/react/hooks/useCompactMode.js +104 -58
- package/dist/react/hooks/useCompactMode.js.map +1 -1
- package/dist/react/hooks/useGroundTrackHistory.d.ts +0 -1
- package/dist/react/hooks/useSimulationScene.d.ts +1 -2
- package/dist/react/hooks/useSimulationScene.js +481 -374
- package/dist/react/hooks/useSimulationScene.js.map +1 -1
- package/dist/react/index.d.ts +3 -3
- package/dist/react/panels/LayerControlPanel.d.ts +1 -2
- package/dist/react/panels/LayerControlPanel.js +223 -180
- package/dist/react/panels/LayerControlPanel.js.map +1 -1
- package/dist/react/panels/ObjectInventoryPanel.d.ts +2 -3
- package/dist/react/panels/ObjectInventoryPanel.js +315 -250
- package/dist/react/panels/ObjectInventoryPanel.js.map +1 -1
- package/dist/react/panels/index.d.ts +1 -1
- package/dist/react/panels/index.js +1 -6
- package/dist/react/shared/ErrorBoundary.d.ts +1 -2
- package/dist/react/shared/ErrorBoundary.js +170 -139
- package/dist/react/shared/ErrorBoundary.js.map +1 -1
- package/dist/react/shared/Skeleton.d.ts +1 -2
- package/dist/react/shared/Skeleton.js +300 -301
- package/dist/react/shared/Skeleton.js.map +1 -1
- package/dist/react/theme/ThemeProvider.d.ts +2 -321
- package/dist/react/theme/ThemeProvider.js +312 -939
- package/dist/react/theme/ThemeProvider.js.map +1 -1
- package/dist/react/theme/cardAccent.d.ts +1 -2
- package/dist/react/theme/cardAccent.js +196 -126
- package/dist/react/theme/cardAccent.js.map +1 -1
- package/dist/react/theme/config.d.ts +0 -1
- package/dist/react/theme/config.js +47 -25
- package/dist/react/theme/config.js.map +1 -1
- package/dist/react/theme/index.d.ts +2 -2
- package/dist/react/theme/index.js +1 -16
- package/dist/react/theme/types.d.ts +332 -0
- package/dist/react/theme/types.js +39 -0
- package/dist/react/theme/types.js.map +1 -0
- package/dist/react/types.d.ts +8 -8
- package/dist/react/types.js +147 -47
- package/dist/react/types.js.map +1 -1
- package/dist/react/utils/categoryPalette.d.ts +0 -1
- package/dist/react/utils/categoryPalette.js +91 -102
- package/dist/react/utils/categoryPalette.js.map +1 -1
- package/dist/react/utils/index.d.ts +5 -5
- package/dist/react/utils/index.js +457 -371
- package/dist/react/utils/index.js.map +1 -1
- package/dist/react/visualizations/EclipseTimerCard.d.ts +0 -1
- package/dist/react/visualizations/LinkBudgetCard.d.ts +0 -1
- package/dist/react/visualizations/NavBallCard.d.ts +0 -1
- package/dist/react/visualizations/PropulsionCard.d.ts +1 -2
- package/dist/react/visualizations/SensorFootprintCard.d.ts +1 -2
- package/dist/react/visualizations/ThermalHeatmapCard.d.ts +0 -1
- package/dist/react/visualizations/index.d.ts +3 -3
- package/dist/react.d.ts +2 -1
- package/dist/react.js +17 -221
- package/dist/shaders/atmosphere.frag.js +6 -5
- package/dist/shaders/atmosphere.frag.js.map +1 -1
- package/dist/shaders/atmosphere.vert.js +6 -5
- package/dist/shaders/atmosphere.vert.js.map +1 -1
- package/dist/shaders/stars.frag.js +6 -5
- package/dist/shaders/stars.frag.js.map +1 -1
- package/dist/shaders/stars.vert.js +6 -5
- package/dist/shaders/stars.vert.js.map +1 -1
- package/dist/style.css +217 -194
- package/dist/tokens/core.d.ts +159 -0
- package/dist/tokens/core.js +144 -0
- package/dist/tokens/core.js.map +1 -0
- package/dist/tokens/css-vars.d.ts +213 -2
- package/dist/tokens/css-vars.js +590 -227
- package/dist/tokens/css-vars.js.map +1 -1
- package/dist/tokens/index.d.ts +31 -228
- package/dist/tokens/index.js +281 -366
- package/dist/tokens/index.js.map +1 -1
- package/dist/tokens/palettes/astro.d.ts +129 -0
- package/dist/tokens/palettes/astro.js +112 -0
- package/dist/tokens/palettes/astro.js.map +1 -0
- package/dist/tokens/palettes/index.d.ts +288 -0
- package/dist/tokens/palettes/index.js +35 -0
- package/dist/tokens/palettes/index.js.map +1 -0
- package/dist/tokens/palettes/tailwind.d.ts +324 -0
- package/dist/tokens/palettes/tailwind.js +201 -0
- package/dist/tokens/palettes/tailwind.js.map +1 -0
- package/dist/tokens/palettes/zendir.d.ts +126 -0
- package/dist/tokens/palettes/zendir.js +92 -0
- package/dist/tokens/palettes/zendir.js.map +1 -0
- package/dist/tokens/themes.d.ts +30 -0
- package/dist/tokens/themes.js +704 -0
- package/dist/tokens/themes.js.map +1 -0
- package/dist/tokens/tokens.css +419 -41
- package/dist/types/index.d.ts +2 -2
- package/package.json +310 -313
- package/dist/index.js.map +0 -1
- package/dist/react/3d/index.js.map +0 -1
- package/dist/react/astro/index.js.map +0 -1
- package/dist/react/cards/index.js.map +0 -1
- package/dist/react/charts/index.js.map +0 -1
- package/dist/react/core/index.js.map +0 -1
- package/dist/react/panels/index.js.map +0 -1
- package/dist/react/theme/astro-tokens.d.ts +0 -153
- package/dist/react/theme/index.js.map +0 -1
- package/dist/react.js.map +0 -1
|
@@ -1,315 +1,354 @@
|
|
|
1
|
-
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { memo, useRef, useId, useEffect, useState, useCallback, useContext, createContext } from "react";
|
|
3
|
-
import { createPortal } from "react-dom";
|
|
4
1
|
import { useTheme } from "../../theme/ThemeProvider.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
2
|
+
import { createContext, memo, useCallback, useContext, useEffect, useId, useRef, useState } from "react";
|
|
3
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { createPortal } from "react-dom";
|
|
5
|
+
//#region src/react/core/feedback/ConfirmDialog.tsx
|
|
6
|
+
/**
|
|
7
|
+
* @zendir/ui - Confirmation Dialog
|
|
8
|
+
*
|
|
9
|
+
* Convenience wrapper over Dialog for confirm/cancel actions.
|
|
10
|
+
* Provides both a component API and a `useConfirm()` hook for imperative usage.
|
|
11
|
+
*
|
|
12
|
+
* Astro UX Compliance:
|
|
13
|
+
* - Status-based alert colors
|
|
14
|
+
* - Focus trap, escape to close
|
|
15
|
+
* - Primary button on right (Astro convention)
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* // Hook API (imperative)
|
|
20
|
+
* const confirm = useConfirm();
|
|
21
|
+
* const ok = await confirm({
|
|
22
|
+
* title: 'Reset Component',
|
|
23
|
+
* message: 'This will reboot the spacecraft and suspend commands for 120 seconds.',
|
|
24
|
+
* status: 'caution',
|
|
25
|
+
* confirmLabel: 'Reset',
|
|
26
|
+
* destructive: true,
|
|
27
|
+
* });
|
|
28
|
+
* if (ok) doReset();
|
|
29
|
+
*
|
|
30
|
+
* // Component API (declarative)
|
|
31
|
+
* <ConfirmDialog
|
|
32
|
+
* open={isOpen}
|
|
33
|
+
* onClose={() => setOpen(false)}
|
|
34
|
+
* onConfirm={handleReset}
|
|
35
|
+
* title="Delete All Data?"
|
|
36
|
+
* message="This cannot be undone."
|
|
37
|
+
* status="critical"
|
|
38
|
+
* destructive
|
|
39
|
+
* />
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
var ConfirmDialog = memo(function ConfirmDialog({ open, onClose, onConfirm, title, message, status, confirmLabel = "Confirm", cancelLabel = "Cancel", destructive = false }) {
|
|
43
|
+
const { tokens, theme } = useTheme();
|
|
44
|
+
const isTransparentTheme = theme === "transparent" || theme === "transparent-bold" || theme === "transparent-minimal";
|
|
45
|
+
const dialogRef = useRef(null);
|
|
46
|
+
const confirmRef = useRef(null);
|
|
47
|
+
const previousActiveElement = useRef(null);
|
|
48
|
+
const titleId = useId();
|
|
49
|
+
const messageId = useId();
|
|
50
|
+
const CONFIRM_DIALOG_Z_INDEX = 2147483200;
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (!open) return;
|
|
53
|
+
previousActiveElement.current = document.activeElement;
|
|
54
|
+
document.body.style.overflow = "hidden";
|
|
55
|
+
const handleKeyDown = (e) => {
|
|
56
|
+
if (e.key === "Escape") {
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
onClose();
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (e.key !== "Tab") return;
|
|
62
|
+
const root = dialogRef.current;
|
|
63
|
+
if (!root) return;
|
|
64
|
+
const focusableElements = root.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])");
|
|
65
|
+
const focusable = Array.from(focusableElements).filter((el) => !el.hasAttribute("disabled"));
|
|
66
|
+
if (focusable.length === 0) return;
|
|
67
|
+
const first = focusable[0];
|
|
68
|
+
const last = focusable[focusable.length - 1];
|
|
69
|
+
const active = document.activeElement;
|
|
70
|
+
if (e.shiftKey && active === first) {
|
|
71
|
+
e.preventDefault();
|
|
72
|
+
last.focus();
|
|
73
|
+
} else if (!e.shiftKey && active === last) {
|
|
74
|
+
e.preventDefault();
|
|
75
|
+
first.focus();
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
79
|
+
const focusTimer = window.setTimeout(() => {
|
|
80
|
+
confirmRef.current?.focus();
|
|
81
|
+
}, 0);
|
|
82
|
+
return () => {
|
|
83
|
+
window.clearTimeout(focusTimer);
|
|
84
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
85
|
+
document.body.style.overflow = "";
|
|
86
|
+
previousActiveElement.current?.focus();
|
|
87
|
+
};
|
|
88
|
+
}, [open, onClose]);
|
|
89
|
+
if (!open) return null;
|
|
90
|
+
if (typeof document === "undefined") return null;
|
|
91
|
+
const statusColors = {
|
|
92
|
+
normal: tokens.colors.status.normal,
|
|
93
|
+
caution: tokens.colors.status.caution,
|
|
94
|
+
serious: tokens.colors.status.serious,
|
|
95
|
+
critical: tokens.colors.status.critical
|
|
96
|
+
};
|
|
97
|
+
const accentColor = status ? statusColors[status] : tokens.colors.accent.primary;
|
|
98
|
+
const confirmBg = destructive ? tokens.colors.status.critical : tokens.colors.accent.primary;
|
|
99
|
+
const statusIcon = status && (() => {
|
|
100
|
+
const s = 32;
|
|
101
|
+
const innerIcon = /* @__PURE__ */ jsxs("svg", {
|
|
102
|
+
width: "16",
|
|
103
|
+
height: "16",
|
|
104
|
+
viewBox: "0 0 24 24",
|
|
105
|
+
fill: "none",
|
|
106
|
+
stroke: accentColor,
|
|
107
|
+
strokeWidth: "2.5",
|
|
108
|
+
strokeLinecap: "round",
|
|
109
|
+
children: [/* @__PURE__ */ jsx("path", { d: "M12 9v4" }), /* @__PURE__ */ jsx("path", { d: "M12 17h.01" })]
|
|
110
|
+
});
|
|
111
|
+
const baseStyle = {
|
|
112
|
+
width: s,
|
|
113
|
+
height: s,
|
|
114
|
+
display: "flex",
|
|
115
|
+
alignItems: "center",
|
|
116
|
+
justifyContent: "center",
|
|
117
|
+
flexShrink: 0
|
|
118
|
+
};
|
|
119
|
+
switch (status) {
|
|
120
|
+
case "critical": return /* @__PURE__ */ jsx("div", {
|
|
121
|
+
style: {
|
|
122
|
+
...baseStyle,
|
|
123
|
+
backgroundColor: `${accentColor}20`,
|
|
124
|
+
border: `2px solid ${accentColor}`,
|
|
125
|
+
clipPath: "polygon(50% 0%, 0% 100%, 100% 100%)",
|
|
126
|
+
paddingTop: 8
|
|
127
|
+
},
|
|
128
|
+
children: innerIcon
|
|
129
|
+
});
|
|
130
|
+
case "serious": return /* @__PURE__ */ jsx("div", {
|
|
131
|
+
style: {
|
|
132
|
+
...baseStyle,
|
|
133
|
+
backgroundColor: `${accentColor}20`,
|
|
134
|
+
border: `2px solid ${accentColor}`,
|
|
135
|
+
transform: "rotate(45deg)"
|
|
136
|
+
},
|
|
137
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
138
|
+
style: { transform: "rotate(-45deg)" },
|
|
139
|
+
children: innerIcon
|
|
140
|
+
})
|
|
141
|
+
});
|
|
142
|
+
case "caution": return /* @__PURE__ */ jsx("div", {
|
|
143
|
+
style: {
|
|
144
|
+
...baseStyle,
|
|
145
|
+
backgroundColor: `${accentColor}20`,
|
|
146
|
+
border: `2px solid ${accentColor}`,
|
|
147
|
+
borderRadius: "4px"
|
|
148
|
+
},
|
|
149
|
+
children: innerIcon
|
|
150
|
+
});
|
|
151
|
+
default: return /* @__PURE__ */ jsx("div", {
|
|
152
|
+
style: {
|
|
153
|
+
...baseStyle,
|
|
154
|
+
backgroundColor: `${accentColor}20`,
|
|
155
|
+
border: `2px solid ${accentColor}`,
|
|
156
|
+
borderRadius: "50%"
|
|
157
|
+
},
|
|
158
|
+
children: innerIcon
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
})();
|
|
162
|
+
return createPortal(/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
163
|
+
/* @__PURE__ */ jsx("div", {
|
|
164
|
+
style: {
|
|
165
|
+
position: "fixed",
|
|
166
|
+
inset: 0,
|
|
167
|
+
zIndex: CONFIRM_DIALOG_Z_INDEX,
|
|
168
|
+
backgroundColor: isTransparentTheme ? `${tokens.colors.background.base}80` : `${tokens.colors.background.base}B3`,
|
|
169
|
+
backdropFilter: "blur(6px)",
|
|
170
|
+
WebkitBackdropFilter: "blur(6px)",
|
|
171
|
+
animation: `zendir-confirm-backdrop 200ms ${tokens.animation.easing.default}`
|
|
172
|
+
},
|
|
173
|
+
onClick: onClose
|
|
174
|
+
}),
|
|
175
|
+
/* @__PURE__ */ jsxs("div", {
|
|
176
|
+
ref: dialogRef,
|
|
177
|
+
role: "alertdialog",
|
|
178
|
+
"aria-modal": "true",
|
|
179
|
+
"aria-labelledby": titleId,
|
|
180
|
+
"aria-describedby": message ? messageId : void 0,
|
|
181
|
+
onClick: (e) => e.stopPropagation(),
|
|
182
|
+
style: {
|
|
183
|
+
position: "fixed",
|
|
184
|
+
top: "50%",
|
|
185
|
+
left: "50%",
|
|
186
|
+
transform: "translate(-50%, -50%)",
|
|
187
|
+
zIndex: 2147483201,
|
|
188
|
+
width: "100%",
|
|
189
|
+
maxWidth: "min(440px, calc(100vw - 32px))",
|
|
190
|
+
backgroundColor: isTransparentTheme ? "rgba(15, 12, 30, 0.9)" : tokens.colors.background.surface,
|
|
191
|
+
border: `1px solid ${tokens.colors.border.default}`,
|
|
192
|
+
borderRadius: tokens.borderRadius.lg,
|
|
193
|
+
boxShadow: tokens.shadows.xl,
|
|
194
|
+
fontFamily: tokens.typography.fontFamily.primary,
|
|
195
|
+
animation: `zendir-confirm-enter 250ms ${tokens.animation.easing.default}`,
|
|
196
|
+
overflow: "hidden",
|
|
197
|
+
...isTransparentTheme ? {
|
|
198
|
+
backdropFilter: "blur(20px)",
|
|
199
|
+
WebkitBackdropFilter: "blur(20px)"
|
|
200
|
+
} : {}
|
|
201
|
+
},
|
|
202
|
+
children: [
|
|
203
|
+
status && /* @__PURE__ */ jsx("div", { style: {
|
|
204
|
+
height: 3,
|
|
205
|
+
backgroundColor: accentColor,
|
|
206
|
+
width: "100%"
|
|
207
|
+
} }),
|
|
208
|
+
/* @__PURE__ */ jsx("div", {
|
|
209
|
+
style: { padding: `${tokens.spacing.lg} ${tokens.spacing.lg} ${tokens.spacing.md}` },
|
|
210
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
211
|
+
style: {
|
|
212
|
+
display: "flex",
|
|
213
|
+
gap: tokens.spacing.md,
|
|
214
|
+
alignItems: "flex-start"
|
|
215
|
+
},
|
|
216
|
+
children: [statusIcon, /* @__PURE__ */ jsxs("div", {
|
|
217
|
+
style: { flex: 1 },
|
|
218
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
219
|
+
id: titleId,
|
|
220
|
+
style: {
|
|
221
|
+
fontSize: tokens.typography.fontSize.md,
|
|
222
|
+
fontWeight: tokens.typography.fontWeight.semibold,
|
|
223
|
+
color: tokens.colors.text.primary,
|
|
224
|
+
lineHeight: tokens.typography.lineHeight.tight
|
|
225
|
+
},
|
|
226
|
+
children: title
|
|
227
|
+
}), message && /* @__PURE__ */ jsx("div", {
|
|
228
|
+
id: messageId,
|
|
229
|
+
style: {
|
|
230
|
+
fontSize: tokens.typography.fontSize.sm,
|
|
231
|
+
color: tokens.colors.text.secondary,
|
|
232
|
+
marginTop: tokens.spacing.sm,
|
|
233
|
+
lineHeight: tokens.typography.lineHeight.normal
|
|
234
|
+
},
|
|
235
|
+
children: message
|
|
236
|
+
})]
|
|
237
|
+
})]
|
|
238
|
+
})
|
|
239
|
+
}),
|
|
240
|
+
/* @__PURE__ */ jsxs("div", {
|
|
241
|
+
style: {
|
|
242
|
+
display: "flex",
|
|
243
|
+
justifyContent: "flex-end",
|
|
244
|
+
gap: tokens.spacing.sm,
|
|
245
|
+
padding: `${tokens.spacing.md} ${tokens.spacing.lg} ${tokens.spacing.lg}`,
|
|
246
|
+
borderTop: tokens.borders.divider
|
|
247
|
+
},
|
|
248
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
249
|
+
onClick: onClose,
|
|
250
|
+
style: {
|
|
251
|
+
padding: `0 ${tokens.spacing.md}`,
|
|
252
|
+
minHeight: tokens.elementSize.lg,
|
|
253
|
+
fontSize: tokens.typography.fontSize.sm,
|
|
254
|
+
fontWeight: tokens.typography.fontWeight.medium,
|
|
255
|
+
fontFamily: tokens.typography.fontFamily.primary,
|
|
256
|
+
color: tokens.colors.text.primary,
|
|
257
|
+
backgroundColor: tokens.colors.background.base,
|
|
258
|
+
border: `1px solid ${tokens.colors.border.muted}`,
|
|
259
|
+
borderRadius: tokens.borderRadius.md,
|
|
260
|
+
cursor: "pointer",
|
|
261
|
+
transition: tokens.animation.fast
|
|
262
|
+
},
|
|
263
|
+
children: cancelLabel
|
|
264
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
265
|
+
ref: confirmRef,
|
|
266
|
+
onClick: () => {
|
|
267
|
+
onConfirm();
|
|
268
|
+
onClose();
|
|
269
|
+
},
|
|
270
|
+
style: {
|
|
271
|
+
padding: `0 ${tokens.spacing.md}`,
|
|
272
|
+
minHeight: tokens.elementSize.lg,
|
|
273
|
+
fontSize: tokens.typography.fontSize.sm,
|
|
274
|
+
fontWeight: tokens.typography.fontWeight.semibold,
|
|
275
|
+
fontFamily: tokens.typography.fontFamily.primary,
|
|
276
|
+
color: tokens.colors.text.inverse || "#fff",
|
|
277
|
+
backgroundColor: confirmBg,
|
|
278
|
+
border: "none",
|
|
279
|
+
borderRadius: tokens.borderRadius.md,
|
|
280
|
+
cursor: "pointer",
|
|
281
|
+
transition: tokens.animation.fast,
|
|
282
|
+
boxShadow: `0 2px 8px ${confirmBg}40`
|
|
283
|
+
},
|
|
284
|
+
children: confirmLabel
|
|
285
|
+
})]
|
|
286
|
+
})
|
|
287
|
+
]
|
|
288
|
+
}),
|
|
289
|
+
/* @__PURE__ */ jsx("style", { children: `
|
|
261
290
|
@keyframes zendir-confirm-backdrop { from { opacity: 0; } to { opacity: 1; } }
|
|
262
291
|
@keyframes zendir-confirm-enter {
|
|
263
292
|
from { opacity: 0; transform: translate(-50%, -50%) scale(0.95); }
|
|
264
293
|
to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
|
|
265
294
|
}
|
|
266
295
|
` })
|
|
267
|
-
|
|
296
|
+
] }), document.body);
|
|
268
297
|
});
|
|
269
|
-
|
|
298
|
+
var ConfirmContext = createContext(null);
|
|
299
|
+
/**
|
|
300
|
+
* Imperative confirmation hook.
|
|
301
|
+
* Must be used within `<ConfirmProvider>`.
|
|
302
|
+
*
|
|
303
|
+
* @example
|
|
304
|
+
* ```tsx
|
|
305
|
+
* const confirm = useConfirm();
|
|
306
|
+
* const ok = await confirm({ title: 'Delete?', status: 'critical', destructive: true });
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
270
309
|
function useConfirm() {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
310
|
+
const ctx = useContext(ConfirmContext);
|
|
311
|
+
if (!ctx) throw new Error("useConfirm must be used within <ConfirmProvider>");
|
|
312
|
+
return ctx.requestConfirm;
|
|
274
313
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
314
|
+
/**
|
|
315
|
+
* Provider for the useConfirm() hook.
|
|
316
|
+
* Renders the confirmation dialog as needed.
|
|
317
|
+
*/
|
|
318
|
+
var ConfirmProvider = memo(function ConfirmProvider({ children }) {
|
|
319
|
+
const [state, setState] = useState(null);
|
|
320
|
+
const requestConfirm = useCallback((options) => {
|
|
321
|
+
return new Promise((resolve) => {
|
|
322
|
+
setState({
|
|
323
|
+
...options,
|
|
324
|
+
resolve
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
}, []);
|
|
328
|
+
const handleClose = useCallback(() => {
|
|
329
|
+
state?.resolve(false);
|
|
330
|
+
setState(null);
|
|
331
|
+
}, [state]);
|
|
332
|
+
const handleConfirm = useCallback(() => {
|
|
333
|
+
state?.resolve(true);
|
|
334
|
+
setState(null);
|
|
335
|
+
}, [state]);
|
|
336
|
+
return /* @__PURE__ */ jsxs(ConfirmContext.Provider, {
|
|
337
|
+
value: { requestConfirm },
|
|
338
|
+
children: [children, state && /* @__PURE__ */ jsx(ConfirmDialog, {
|
|
339
|
+
open: true,
|
|
340
|
+
onClose: handleClose,
|
|
341
|
+
onConfirm: handleConfirm,
|
|
342
|
+
title: state.title,
|
|
343
|
+
message: state.message,
|
|
344
|
+
status: state.status,
|
|
345
|
+
confirmLabel: state.confirmLabel,
|
|
346
|
+
cancelLabel: state.cancelLabel,
|
|
347
|
+
destructive: state.destructive
|
|
348
|
+
})]
|
|
349
|
+
});
|
|
309
350
|
});
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
};
|
|
315
|
-
//# sourceMappingURL=ConfirmDialog.js.map
|
|
351
|
+
//#endregion
|
|
352
|
+
export { ConfirmDialog, ConfirmDialog as default, ConfirmProvider, useConfirm };
|
|
353
|
+
|
|
354
|
+
//# sourceMappingURL=ConfirmDialog.js.map
|