@contui/ui 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +30 -0
- package/README.md +150 -2
- package/cli/contui.mjs +250 -0
- package/dist/charts/area-chart.d.ts +8 -0
- package/dist/charts/area-chart.js +9 -0
- package/dist/charts/bar-chart.d.ts +9 -0
- package/dist/charts/bar-chart.js +10 -0
- package/dist/charts/bubble-chart.d.ts +60 -0
- package/dist/charts/bubble-chart.js +392 -0
- package/dist/charts/bullet-chart.d.ts +53 -0
- package/dist/charts/bullet-chart.js +123 -0
- package/dist/charts/candlestick-chart.d.ts +77 -0
- package/dist/charts/candlestick-chart.js +558 -0
- package/dist/charts/cartesian.d.ts +121 -0
- package/dist/charts/cartesian.js +625 -0
- package/dist/charts/chart-card.d.ts +80 -0
- package/dist/charts/chart-card.js +114 -0
- package/dist/charts/donut-chart.d.ts +40 -0
- package/dist/charts/donut-chart.js +88 -0
- package/dist/charts/funnel-chart.d.ts +16 -0
- package/dist/charts/funnel-chart.js +164 -0
- package/dist/charts/horizontal-bar-chart.d.ts +67 -0
- package/dist/charts/horizontal-bar-chart.js +481 -0
- package/dist/charts/index.d.ts +21 -0
- package/dist/charts/index.js +32 -0
- package/dist/charts/legend.d.ts +23 -0
- package/dist/charts/legend.js +22 -0
- package/dist/charts/lib/candlestick-window.d.ts +15 -0
- package/dist/charts/lib/candlestick-window.js +23 -0
- package/dist/charts/lib/color.d.ts +39 -0
- package/dist/charts/lib/color.js +83 -0
- package/dist/charts/lib/format.d.ts +11 -0
- package/dist/charts/lib/format.js +33 -0
- package/dist/charts/lib/frame.d.ts +6 -0
- package/dist/charts/lib/frame.js +6 -0
- package/dist/charts/lib/layout.d.ts +11 -0
- package/dist/charts/lib/layout.js +71 -0
- package/dist/charts/lib/path.d.ts +35 -0
- package/dist/charts/lib/path.js +203 -0
- package/dist/charts/lib/scale.d.ts +41 -0
- package/dist/charts/lib/scale.js +80 -0
- package/dist/charts/lib/use-active.d.ts +18 -0
- package/dist/charts/lib/use-active.js +71 -0
- package/dist/charts/lib/use-size.d.ts +9 -0
- package/dist/charts/lib/use-size.js +40 -0
- package/dist/charts/line-chart.d.ts +7 -0
- package/dist/charts/line-chart.js +8 -0
- package/dist/charts/radar-chart.d.ts +27 -0
- package/dist/charts/radar-chart.js +165 -0
- package/dist/charts/rose-chart.d.ts +35 -0
- package/dist/charts/rose-chart.js +242 -0
- package/dist/charts/sparkline.d.ts +35 -0
- package/dist/charts/sparkline.js +110 -0
- package/dist/charts/tooltip.d.ts +35 -0
- package/dist/charts/tooltip.js +22 -0
- package/dist/charts/treemap.d.ts +28 -0
- package/dist/charts/treemap.js +103 -0
- package/dist/charts/uptime-strip.d.ts +40 -0
- package/dist/charts/uptime-strip.js +178 -0
- package/dist/components/accordion.d.ts +31 -0
- package/dist/components/accordion.js +34 -0
- package/dist/components/activity-item.d.ts +12 -0
- package/dist/components/activity-item.js +6 -0
- package/dist/components/alert.d.ts +21 -0
- package/dist/components/alert.js +58 -0
- package/dist/components/assistant-answer.d.ts +52 -0
- package/dist/components/assistant-answer.js +40 -0
- package/dist/components/assistant-prompt.d.ts +63 -0
- package/dist/components/assistant-prompt.js +122 -0
- package/dist/components/avatar.d.ts +28 -0
- package/dist/components/avatar.js +75 -0
- package/dist/components/badge.d.ts +16 -0
- package/dist/components/badge.js +33 -0
- package/dist/components/bar-list.d.ts +65 -0
- package/dist/components/bar-list.js +119 -0
- package/dist/components/block-slider.d.ts +43 -0
- package/dist/components/block-slider.js +63 -0
- package/dist/components/branch-graph.d.ts +87 -0
- package/dist/components/branch-graph.js +231 -0
- package/dist/components/breadcrumb.d.ts +41 -0
- package/dist/components/breadcrumb.js +53 -0
- package/dist/components/button.d.ts +23 -0
- package/dist/components/button.js +108 -0
- package/dist/components/calendar.d.ts +5 -0
- package/dist/components/calendar.js +90 -0
- package/dist/components/card.d.ts +65 -0
- package/dist/components/card.js +104 -0
- package/dist/components/chat-attachment.d.ts +47 -0
- package/dist/components/chat-attachment.js +63 -0
- package/dist/components/chat-event.d.ts +7 -0
- package/dist/components/chat-event.js +7 -0
- package/dist/components/chat-message.d.ts +59 -0
- package/dist/components/chat-message.js +91 -0
- package/dist/components/chat-reference.d.ts +20 -0
- package/dist/components/chat-reference.js +41 -0
- package/dist/components/chat-shared.d.ts +21 -0
- package/dist/components/chat-shared.js +23 -0
- package/dist/components/chat-suggestions.d.ts +59 -0
- package/dist/components/chat-suggestions.js +88 -0
- package/dist/components/chat-thread.d.ts +39 -0
- package/dist/components/chat-thread.js +172 -0
- package/dist/components/chat-typing.d.ts +35 -0
- package/dist/components/chat-typing.js +66 -0
- package/dist/components/checkbox.d.ts +18 -0
- package/dist/components/checkbox.js +33 -0
- package/dist/components/checklist.d.ts +26 -0
- package/dist/components/checklist.js +18 -0
- package/dist/components/chip.d.ts +29 -0
- package/dist/components/chip.js +61 -0
- package/dist/components/code-input.d.ts +40 -0
- package/dist/components/code-input.js +285 -0
- package/dist/components/color-picker.d.ts +38 -0
- package/dist/components/color-picker.js +855 -0
- package/dist/components/combobox.d.ts +75 -0
- package/dist/components/combobox.js +112 -0
- package/dist/components/command-menu.d.ts +58 -0
- package/dist/components/command-menu.js +166 -0
- package/dist/components/copy-button.d.ts +16 -0
- package/dist/components/copy-button.js +31 -0
- package/dist/components/data-grid.d.ts +50 -0
- package/dist/components/data-grid.js +599 -0
- package/dist/components/date-picker.d.ts +109 -0
- package/dist/components/date-picker.js +268 -0
- package/dist/components/description-list.d.ts +12 -0
- package/dist/components/description-list.js +10 -0
- package/dist/components/dialog.d.ts +57 -0
- package/dist/components/dialog.js +140 -0
- package/dist/components/dock.d.ts +45 -0
- package/dist/components/dock.js +79 -0
- package/dist/components/drop-zone.d.ts +46 -0
- package/dist/components/drop-zone.js +101 -0
- package/dist/components/dropdown-menu.d.ts +50 -0
- package/dist/components/dropdown-menu.js +78 -0
- package/dist/components/editable-cell.d.ts +34 -0
- package/dist/components/editable-cell.js +89 -0
- package/dist/components/empty-state.d.ts +17 -0
- package/dist/components/empty-state.js +9 -0
- package/dist/components/field.d.ts +43 -0
- package/dist/components/field.js +75 -0
- package/dist/components/filter-condition.d.ts +188 -0
- package/dist/components/filter-condition.js +113 -0
- package/dist/components/filter-menu.d.ts +57 -0
- package/dist/components/filter-menu.js +46 -0
- package/dist/components/header-bar.d.ts +84 -0
- package/dist/components/header-bar.js +94 -0
- package/dist/components/hold-button.d.ts +15 -0
- package/dist/components/hold-button.js +88 -0
- package/dist/components/icon-tile.d.ts +12 -0
- package/dist/components/icon-tile.js +29 -0
- package/dist/components/info-tip.d.ts +13 -0
- package/dist/components/info-tip.js +26 -0
- package/dist/components/input.d.ts +17 -0
- package/dist/components/input.js +83 -0
- package/dist/components/kbd.d.ts +6 -0
- package/dist/components/kbd.js +7 -0
- package/dist/components/menu-item.d.ts +56 -0
- package/dist/components/menu-item.js +94 -0
- package/dist/components/message-composer.d.ts +75 -0
- package/dist/components/message-composer.js +199 -0
- package/dist/components/nav-rail.d.ts +31 -0
- package/dist/components/nav-rail.js +85 -0
- package/dist/components/notice.d.ts +45 -0
- package/dist/components/notice.js +66 -0
- package/dist/components/optimistic-undo.d.ts +28 -0
- package/dist/components/optimistic-undo.js +43 -0
- package/dist/components/option-row.d.ts +15 -0
- package/dist/components/option-row.js +14 -0
- package/dist/components/page-content.d.ts +11 -0
- package/dist/components/page-content.js +31 -0
- package/dist/components/pagination.d.ts +34 -0
- package/dist/components/pagination.js +41 -0
- package/dist/components/popover.d.ts +27 -0
- package/dist/components/popover.js +25 -0
- package/dist/components/progress.d.ts +33 -0
- package/dist/components/progress.js +75 -0
- package/dist/components/radio-group.d.ts +7 -0
- package/dist/components/radio-group.js +33 -0
- package/dist/components/readonly-field.d.ts +33 -0
- package/dist/components/readonly-field.js +80 -0
- package/dist/components/segmented-control.d.ts +21 -0
- package/dist/components/segmented-control.js +108 -0
- package/dist/components/select.d.ts +42 -0
- package/dist/components/select.js +86 -0
- package/dist/components/separator.d.ts +10 -0
- package/dist/components/separator.js +7 -0
- package/dist/components/setting-row.d.ts +53 -0
- package/dist/components/setting-row.js +93 -0
- package/dist/components/sidebar-switcher.d.ts +47 -0
- package/dist/components/sidebar-switcher.js +20 -0
- package/dist/components/sidebar.d.ts +220 -0
- package/dist/components/sidebar.js +327 -0
- package/dist/components/skeleton.d.ts +18 -0
- package/dist/components/skeleton.js +23 -0
- package/dist/components/slider.d.ts +15 -0
- package/dist/components/slider.js +28 -0
- package/dist/components/spinner.d.ts +14 -0
- package/dist/components/spinner.js +19 -0
- package/dist/components/status-dot.d.ts +24 -0
- package/dist/components/status-dot.js +35 -0
- package/dist/components/stepper.d.ts +60 -0
- package/dist/components/stepper.js +197 -0
- package/dist/components/switch.d.ts +9 -0
- package/dist/components/switch.js +26 -0
- package/dist/components/table-cell.d.ts +38 -0
- package/dist/components/table-cell.js +107 -0
- package/dist/components/table-context.d.ts +48 -0
- package/dist/components/table-context.js +69 -0
- package/dist/components/table-head.d.ts +42 -0
- package/dist/components/table-head.js +188 -0
- package/dist/components/table-tree.d.ts +96 -0
- package/dist/components/table-tree.js +137 -0
- package/dist/components/table.d.ts +78 -0
- package/dist/components/table.js +119 -0
- package/dist/components/tabs.d.ts +27 -0
- package/dist/components/tabs.js +79 -0
- package/dist/components/textarea.d.ts +3 -0
- package/dist/components/textarea.js +20 -0
- package/dist/components/theme.d.ts +41 -0
- package/dist/components/theme.js +60 -0
- package/dist/components/thinking.d.ts +68 -0
- package/dist/components/thinking.js +94 -0
- package/dist/components/toast.d.ts +39 -0
- package/dist/components/toast.js +110 -0
- package/dist/components/toolbar.d.ts +25 -0
- package/dist/components/toolbar.js +92 -0
- package/dist/components/tooltip.d.ts +23 -0
- package/dist/components/tooltip.js +27 -0
- package/dist/components/top-nav.d.ts +129 -0
- package/dist/components/top-nav.js +211 -0
- package/dist/components/truncate.d.ts +29 -0
- package/dist/components/truncate.js +138 -0
- package/dist/deprecated.d.ts +43 -0
- package/dist/deprecated.js +47 -0
- package/dist/index.d.ts +93 -0
- package/dist/index.js +93 -0
- package/dist/lib/cn.d.ts +5 -0
- package/dist/lib/cn.js +14 -0
- package/dist/lib/color.d.ts +136 -0
- package/dist/lib/color.js +307 -0
- package/dist/lib/contrast.d.ts +53 -0
- package/dist/lib/contrast.js +169 -0
- package/dist/lib/create-theme.d.ts +240 -0
- package/dist/lib/create-theme.js +461 -0
- package/dist/lib/harmony.d.ts +102 -0
- package/dist/lib/harmony.js +426 -0
- package/dist/lib/import-theme.d.ts +22 -0
- package/dist/lib/import-theme.js +221 -0
- package/dist/lib/overflow-scroll.d.ts +25 -0
- package/dist/lib/overflow-scroll.js +66 -0
- package/dist/lib/radio-toggle-render.d.ts +3 -0
- package/dist/lib/radio-toggle-render.js +9 -0
- package/dist/lib/reorder.d.ts +38 -0
- package/dist/lib/reorder.js +193 -0
- package/dist/lib/spacing.d.ts +101 -0
- package/dist/lib/spacing.js +118 -0
- package/dist/lib/tailwind-palette.d.ts +5 -0
- package/dist/lib/tailwind-palette.js +351 -0
- package/dist/lib/truncate.d.ts +18 -0
- package/dist/lib/truncate.js +69 -0
- package/dist/lib/use-single-value.d.ts +5 -0
- package/dist/lib/use-single-value.js +17 -0
- package/dist/styles.css +7988 -0
- package/mcp/server.mjs +87590 -0
- package/package.json +58 -5
- package/skills/continuum-fix-padding/SKILL.md +69 -0
- package/skills/continuum-fix-padding/scripts/compute.ts +155 -0
- package/skills/continuum-fix-padding/scripts/spacing.ts +189 -0
- package/skills/continuum-taste/SKILL.md +186 -0
- package/skills/continuum-taste/assets/tokens.css +647 -0
- package/skills/continuum-taste/references/charts.md +375 -0
- package/skills/continuum-taste/references/components.md +1369 -0
- package/skills/continuum-taste/references/foundations.md +539 -0
- package/skills/continuum-taste/references/media/canvas.md +75 -0
- package/skills/continuum-taste/references/media/css.md +61 -0
- package/skills/continuum-taste/references/media/react.md +161 -0
- package/skills/continuum-taste/references/method.md +87 -0
- package/skills/continuum-taste/references/pages.md +391 -0
- package/skills/continuum-taste/references/patterns.md +77 -0
- package/skills/continuum-taste/references/screens/agent.tsx +450 -0
- package/skills/continuum-taste/references/screens/analytics-overview.tsx +377 -0
- package/skills/continuum-taste/references/screens/checkout-funnel.tsx +193 -0
- package/skills/continuum-taste/references/screens/customer.tsx +475 -0
- package/skills/continuum-taste/references/screens/customers.tsx +608 -0
- package/skills/continuum-taste/references/screens/index.tsx +72 -0
- package/skills/continuum-taste/references/screens/invoice-editor.tsx +558 -0
- package/skills/continuum-taste/references/screens/new-customer.tsx +205 -0
- package/skills/continuum-taste/references/screens/overview.tsx +196 -0
- package/skills/continuum-taste/references/screens/report-generator.tsx +329 -0
- package/skills/continuum-taste/references/screens/risk-report.tsx +577 -0
- package/skills/continuum-taste/references/screens/sequence-editor.tsx +455 -0
- package/skills/continuum-taste/references/screens/settings.tsx +288 -0
- package/skills/continuum-taste/references/screens/shared.tsx +204 -0
- package/skills/continuum-taste/references/screens/sign-in.tsx +104 -0
- package/skills/continuum-taste/references/screens/workspace.tsx +596 -0
- package/skills/continuum-taste/references/theming.md +95 -0
- package/src/charts/area-chart.tsx +17 -0
- package/src/charts/bar-chart.tsx +15 -0
- package/src/charts/bubble-chart.tsx +913 -0
- package/src/charts/bullet-chart.tsx +419 -0
- package/src/charts/candlestick-chart.tsx +1242 -0
- package/src/charts/cartesian.tsx +1437 -0
- package/src/charts/chart-card.tsx +394 -0
- package/src/charts/donut-chart.tsx +299 -0
- package/src/charts/funnel-chart.tsx +373 -0
- package/src/charts/horizontal-bar-chart.tsx +991 -0
- package/src/charts/index.ts +76 -0
- package/src/charts/legend.tsx +59 -0
- package/src/charts/lib/candlestick-window.ts +42 -0
- package/src/charts/lib/color.ts +110 -0
- package/src/charts/lib/format.ts +42 -0
- package/src/charts/lib/frame.ts +6 -0
- package/src/charts/lib/layout.ts +78 -0
- package/src/charts/lib/path.ts +225 -0
- package/src/charts/lib/scale.ts +91 -0
- package/src/charts/lib/use-active.ts +87 -0
- package/src/charts/lib/use-size.ts +45 -0
- package/src/charts/line-chart.tsx +16 -0
- package/src/charts/radar-chart.tsx +485 -0
- package/src/charts/rose-chart.tsx +553 -0
- package/src/charts/sparkline.tsx +293 -0
- package/src/charts/tooltip.tsx +105 -0
- package/src/charts/treemap.tsx +271 -0
- package/src/charts/uptime-strip.tsx +469 -0
- package/src/components/accordion.tsx +136 -0
- package/src/components/activity-item.tsx +43 -0
- package/src/components/alert.tsx +135 -0
- package/src/components/assistant-answer.tsx +185 -0
- package/src/components/assistant-prompt.tsx +352 -0
- package/src/components/avatar.tsx +157 -0
- package/src/components/badge.tsx +55 -0
- package/src/components/bar-list.tsx +350 -0
- package/src/components/block-slider.tsx +189 -0
- package/src/components/branch-graph.tsx +580 -0
- package/src/components/breadcrumb.tsx +173 -0
- package/src/components/button.tsx +157 -0
- package/src/components/calendar.tsx +154 -0
- package/src/components/card.tsx +296 -0
- package/src/components/chat-attachment.tsx +255 -0
- package/src/components/chat-event.tsx +34 -0
- package/src/components/chat-message.tsx +332 -0
- package/src/components/chat-reference.tsx +100 -0
- package/src/components/chat-shared.ts +41 -0
- package/src/components/chat-suggestions.tsx +188 -0
- package/src/components/chat-thread.tsx +348 -0
- package/src/components/chat-typing.tsx +155 -0
- package/src/components/checkbox.tsx +83 -0
- package/src/components/checklist.tsx +146 -0
- package/src/components/chip.tsx +152 -0
- package/src/components/code-input.tsx +406 -0
- package/src/components/color-picker.tsx +1385 -0
- package/src/components/combobox.tsx +420 -0
- package/src/components/command-menu.tsx +405 -0
- package/src/components/copy-button.tsx +87 -0
- package/src/components/data-grid.tsx +965 -0
- package/src/components/date-picker.tsx +652 -0
- package/src/components/description-list.tsx +39 -0
- package/src/components/dialog.tsx +367 -0
- package/src/components/dock.tsx +192 -0
- package/src/components/drop-zone.tsx +283 -0
- package/src/components/dropdown-menu.tsx +323 -0
- package/src/components/editable-cell.tsx +219 -0
- package/src/components/empty-state.tsx +50 -0
- package/src/components/field.tsx +148 -0
- package/src/components/filter-condition.tsx +463 -0
- package/src/components/filter-menu.tsx +196 -0
- package/src/components/header-bar.tsx +220 -0
- package/src/components/hold-button.tsx +146 -0
- package/src/components/icon-tile.tsx +43 -0
- package/src/components/info-tip.tsx +87 -0
- package/src/components/input.tsx +136 -0
- package/src/components/kbd.tsx +17 -0
- package/src/components/menu-item.tsx +216 -0
- package/src/components/message-composer.tsx +458 -0
- package/src/components/nav-rail.tsx +235 -0
- package/src/components/notice.tsx +133 -0
- package/src/components/optimistic-undo.ts +68 -0
- package/src/components/option-row.tsx +54 -0
- package/src/components/page-content.tsx +44 -0
- package/src/components/pagination.tsx +182 -0
- package/src/components/popover.tsx +113 -0
- package/src/components/progress.tsx +222 -0
- package/src/components/radio-group.tsx +80 -0
- package/src/components/readonly-field.tsx +251 -0
- package/src/components/segmented-control.tsx +205 -0
- package/src/components/select.tsx +259 -0
- package/src/components/separator.tsx +30 -0
- package/src/components/setting-row.tsx +277 -0
- package/src/components/sidebar-switcher.tsx +134 -0
- package/src/components/sidebar.tsx +804 -0
- package/src/components/skeleton.tsx +57 -0
- package/src/components/slider.tsx +106 -0
- package/src/components/spinner.tsx +43 -0
- package/src/components/status-dot.tsx +100 -0
- package/src/components/stepper.tsx +459 -0
- package/src/components/switch.tsx +54 -0
- package/src/components/table-cell.tsx +239 -0
- package/src/components/table-context.ts +135 -0
- package/src/components/table-head.tsx +393 -0
- package/src/components/table-tree.tsx +357 -0
- package/src/components/table.tsx +295 -0
- package/src/components/tabs.tsx +191 -0
- package/src/components/textarea.tsx +44 -0
- package/src/components/theme.tsx +120 -0
- package/src/components/thinking.tsx +295 -0
- package/src/components/toast.tsx +308 -0
- package/src/components/toolbar.tsx +166 -0
- package/src/components/tooltip.tsx +84 -0
- package/src/components/top-nav.tsx +660 -0
- package/src/components/truncate.tsx +234 -0
- package/src/deprecated.ts +61 -0
- package/src/index.ts +184 -0
- package/src/lib/cn.ts +22 -0
- package/src/lib/color.ts +469 -0
- package/src/lib/contrast.ts +220 -0
- package/src/lib/create-theme.ts +659 -0
- package/src/lib/harmony.ts +609 -0
- package/src/lib/import-theme.ts +272 -0
- package/src/lib/overflow-scroll.tsx +108 -0
- package/src/lib/radio-toggle-render.tsx +15 -0
- package/src/lib/reorder.ts +222 -0
- package/src/lib/spacing.ts +189 -0
- package/src/lib/tailwind-palette.ts +355 -0
- package/src/lib/truncate.ts +79 -0
- package/src/lib/use-single-value.ts +23 -0
- package/src/styles/continuum.css +3 -0
- package/src/styles/theme.css +524 -0
- package/src/styles/tokens.css +647 -0
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Dialog as DialogPrimitive } from '@base-ui/react/dialog';
|
|
4
|
+
import { X } from 'lucide-react';
|
|
5
|
+
import {
|
|
6
|
+
type ComponentProps,
|
|
7
|
+
type CSSProperties,
|
|
8
|
+
createContext,
|
|
9
|
+
type ReactNode,
|
|
10
|
+
useCallback,
|
|
11
|
+
useContext,
|
|
12
|
+
useLayoutEffect,
|
|
13
|
+
useState,
|
|
14
|
+
} from 'react';
|
|
15
|
+
import { cn, type WithClassName } from '../lib/cn';
|
|
16
|
+
import { Button } from './button';
|
|
17
|
+
import { ThemeScope, usePortalContainer } from './theme';
|
|
18
|
+
|
|
19
|
+
const CloseButton = ({ className }: { className?: string }) => (
|
|
20
|
+
<DialogPrimitive.Close
|
|
21
|
+
aria-label="Close"
|
|
22
|
+
render={<Button className={className} size="icon-sm" variant="ghost" />}
|
|
23
|
+
>
|
|
24
|
+
<X strokeWidth={2} />
|
|
25
|
+
</DialogPrimitive.Close>
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
/*
|
|
29
|
+
* Layers: a sheet floats beside the page at z-40, and a modal dialog at z-50 above it, so a dialog opened
|
|
30
|
+
* while a non-modal sheet is open dims the sheet too. Menus and tooltips share z-50 and, being portalled
|
|
31
|
+
* after the dialog, open above it. Toasts stand a layer higher still (z-60), so one raised while a dialog
|
|
32
|
+
* is open is not hidden under its scrim.
|
|
33
|
+
*/
|
|
34
|
+
const SHEET_LAYER = 'z-40';
|
|
35
|
+
const DIALOG_LAYER = 'z-50';
|
|
36
|
+
|
|
37
|
+
// Black rather than a neutral step: the neutral ramp flips in dark mode and would turn the scrim white.
|
|
38
|
+
const overlayClass =
|
|
39
|
+
'fixed inset-0 bg-black/40 transition-opacity duration-200 ease-out-strong data-ending-style:opacity-0 data-starting-style:opacity-0 motion-reduce:transition-none';
|
|
40
|
+
|
|
41
|
+
/** Centred confirmation and form dialogs. */
|
|
42
|
+
export const Dialog = (props: DialogPrimitive.Root.Props) => (
|
|
43
|
+
<DialogPrimitive.Root data-slot="dialog" {...props} />
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
export const DialogTrigger = (props: DialogPrimitive.Trigger.Props) => (
|
|
47
|
+
<DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
export const DialogClose = (props: DialogPrimitive.Close.Props) => (
|
|
51
|
+
<DialogPrimitive.Close data-slot="dialog-close" {...props} />
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
export type DialogContentProps = WithClassName<DialogPrimitive.Popup.Props> & {
|
|
55
|
+
/** Where the dialog is portalled; the body by default. A positioned container that paints its own
|
|
56
|
+
* layer (`contain: paint`) holds the dialog and its scrim inside it, as the playground shows one. */
|
|
57
|
+
container?: DialogPrimitive.Portal.Props['container'];
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const DialogContent = ({ className, container, ...props }: DialogContentProps) => (
|
|
61
|
+
<DialogPrimitive.Portal container={usePortalContainer(container)}>
|
|
62
|
+
<ThemeScope>
|
|
63
|
+
<DialogPrimitive.Backdrop
|
|
64
|
+
className={cn(overlayClass, DIALOG_LAYER)}
|
|
65
|
+
data-slot="dialog-overlay"
|
|
66
|
+
/>
|
|
67
|
+
{/* Centred with margins rather than a transform, so the entry transition can own translate. */}
|
|
68
|
+
<DialogPrimitive.Popup
|
|
69
|
+
className={cn(
|
|
70
|
+
'fixed inset-0 m-auto flex h-fit max-h-[calc(100cqh-32px)] w-[min(var(--spacing-dialog),calc(100cqw-32px))] flex-col overflow-hidden rounded-card border border-neutral-200 bg-neutral-50 shadow-sheet outline-none',
|
|
71
|
+
'transition-[opacity,translate] duration-200 ease-out-strong data-ending-style:translate-y-2 data-starting-style:translate-y-2 data-ending-style:opacity-0 data-starting-style:opacity-0 motion-reduce:transition-none',
|
|
72
|
+
DIALOG_LAYER,
|
|
73
|
+
className,
|
|
74
|
+
)}
|
|
75
|
+
data-slot="dialog-content"
|
|
76
|
+
{...props}
|
|
77
|
+
/>
|
|
78
|
+
</ThemeScope>
|
|
79
|
+
</DialogPrimitive.Portal>
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Title row with the close button, ruled off full width; put a DialogTitle in it.
|
|
84
|
+
* Header, body and footer are three parts, and only the body scrolls.
|
|
85
|
+
*/
|
|
86
|
+
export const DialogHeader = ({ className, children, ...props }: ComponentProps<'div'>) => (
|
|
87
|
+
<div
|
|
88
|
+
className={cn(
|
|
89
|
+
'flex h-bar shrink-0 items-center justify-between gap-4 border-neutral-200 border-b pr-2.75 pl-5',
|
|
90
|
+
className,
|
|
91
|
+
)}
|
|
92
|
+
data-slot="dialog-header"
|
|
93
|
+
{...props}
|
|
94
|
+
>
|
|
95
|
+
{children}
|
|
96
|
+
{/* Outlined at the control radius, like the footer's buttons, so it follows each theme's corners. */}
|
|
97
|
+
<DialogPrimitive.Close
|
|
98
|
+
aria-label="Close"
|
|
99
|
+
render={
|
|
100
|
+
<Button
|
|
101
|
+
className="size-[calc(var(--spacing-bar)-22px)] rounded-control"
|
|
102
|
+
size="icon-sm"
|
|
103
|
+
variant="secondary"
|
|
104
|
+
/>
|
|
105
|
+
}
|
|
106
|
+
>
|
|
107
|
+
<X className="size-3.5" strokeWidth={2} />
|
|
108
|
+
</DialogPrimitive.Close>
|
|
109
|
+
</div>
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
export const DialogTitle = ({
|
|
113
|
+
className,
|
|
114
|
+
...props
|
|
115
|
+
}: WithClassName<DialogPrimitive.Title.Props>) => (
|
|
116
|
+
<DialogPrimitive.Title
|
|
117
|
+
className={cn('min-w-0 truncate font-medium text-neutral-950 text-sm', className)}
|
|
118
|
+
data-slot="dialog-title"
|
|
119
|
+
{...props}
|
|
120
|
+
/>
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
/** Goes first in the DialogBody. */
|
|
124
|
+
export const DialogDescription = ({
|
|
125
|
+
className,
|
|
126
|
+
...props
|
|
127
|
+
}: WithClassName<DialogPrimitive.Description.Props>) => (
|
|
128
|
+
<DialogPrimitive.Description
|
|
129
|
+
className={cn('text-neutral-600 text-xs', className)}
|
|
130
|
+
data-slot="dialog-description"
|
|
131
|
+
{...props}
|
|
132
|
+
/>
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
/** Everything between header and footer; scrolls on its own once the dialog reaches the viewport's height. */
|
|
136
|
+
export const DialogBody = ({ className, ...props }: ComponentProps<'div'>) => (
|
|
137
|
+
<div
|
|
138
|
+
className={cn('flex min-h-0 flex-1 flex-col gap-4 overflow-auto px-5 py-4', className)}
|
|
139
|
+
data-slot="dialog-body"
|
|
140
|
+
{...props}
|
|
141
|
+
/>
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* The actions, ruled off full width and pinned below the body. The header's height
|
|
146
|
+
* and right inset, so the last button lines up under the close button.
|
|
147
|
+
*/
|
|
148
|
+
export const DialogFooter = ({ className, ...props }: ComponentProps<'div'>) => (
|
|
149
|
+
<div
|
|
150
|
+
className={cn(
|
|
151
|
+
'flex h-bar shrink-0 items-center justify-end gap-2 border-neutral-200 border-t px-2.75',
|
|
152
|
+
className,
|
|
153
|
+
)}
|
|
154
|
+
data-slot="dialog-footer"
|
|
155
|
+
{...props}
|
|
156
|
+
/>
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
const SheetModalContext = createContext<DialogPrimitive.Root.Props['modal']>(false);
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Side sheet for history and details beside the page. Non-modal by default: no
|
|
163
|
+
* overlay, and the page behind stays usable without closing it.
|
|
164
|
+
*/
|
|
165
|
+
export const Sheet = ({
|
|
166
|
+
modal = false,
|
|
167
|
+
disablePointerDismissal = modal === false,
|
|
168
|
+
...props
|
|
169
|
+
}: DialogPrimitive.Root.Props) => (
|
|
170
|
+
<SheetModalContext.Provider value={modal}>
|
|
171
|
+
{/* A non-modal sheet would otherwise close on any click or focus outside it, so working on the page beside it would dismiss it. */}
|
|
172
|
+
<DialogPrimitive.Root
|
|
173
|
+
data-slot="sheet"
|
|
174
|
+
disablePointerDismissal={disablePointerDismissal}
|
|
175
|
+
modal={modal}
|
|
176
|
+
{...props}
|
|
177
|
+
/>
|
|
178
|
+
</SheetModalContext.Provider>
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
export const SheetTrigger = (props: DialogPrimitive.Trigger.Props) => (
|
|
182
|
+
<DialogPrimitive.Trigger data-slot="sheet-trigger" {...props} />
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
export const SheetClose = (props: DialogPrimitive.Close.Props) => (
|
|
186
|
+
<DialogPrimitive.Close data-slot="sheet-close" {...props} />
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
const SheetAreaContext = createContext<HTMLElement | null>(null);
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* The content area sheets float in, below the header bar and beside the sidebar.
|
|
193
|
+
* A sheet opened anywhere inside it sits 16px in from its top, right and bottom.
|
|
194
|
+
*/
|
|
195
|
+
export const SheetArea = ({ ref, ...props }: ComponentProps<'div'>) => {
|
|
196
|
+
// State, not a ref: a sheet inside renders before the area's ref is attached, and has to render again once it is.
|
|
197
|
+
const [area, setArea] = useState<HTMLDivElement | null>(null);
|
|
198
|
+
const setRef = useCallback(
|
|
199
|
+
(node: HTMLDivElement | null) => {
|
|
200
|
+
setArea(node);
|
|
201
|
+
if (typeof ref === 'function') ref(node);
|
|
202
|
+
else if (ref) ref.current = node;
|
|
203
|
+
},
|
|
204
|
+
[ref],
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
return (
|
|
208
|
+
<SheetAreaContext.Provider value={area}>
|
|
209
|
+
<div data-slot="sheet-area" ref={setRef} {...props} />
|
|
210
|
+
</SheetAreaContext.Provider>
|
|
211
|
+
);
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
const SHEET_GAP = 16;
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* The sheet is portalled and fixed, so it follows its area by measuring it: the area's
|
|
218
|
+
* box, cut down to whatever part of it the screen and any clipping ancestor still show,
|
|
219
|
+
* so a scrolled-away area never drags it along. The screen is the viewport, or the
|
|
220
|
+
* portal container when there is one (a phone drawn in a preview), whose box a fixed
|
|
221
|
+
* sheet then answers to; a container drawn scaled down is measured back at its own size.
|
|
222
|
+
* The sheet is never wider than its area, so on a phone it keeps 16px from both edges.
|
|
223
|
+
*/
|
|
224
|
+
const useAreaInset = (node: HTMLElement | null, screen: HTMLElement | null) => {
|
|
225
|
+
const [inset, setInset] = useState<CSSProperties>();
|
|
226
|
+
|
|
227
|
+
useLayoutEffect(() => {
|
|
228
|
+
if (!node) return;
|
|
229
|
+
|
|
230
|
+
const update = () => {
|
|
231
|
+
const view = screen
|
|
232
|
+
? screen.getBoundingClientRect()
|
|
233
|
+
: new DOMRect(
|
|
234
|
+
0,
|
|
235
|
+
0,
|
|
236
|
+
document.documentElement.clientWidth,
|
|
237
|
+
document.documentElement.clientHeight,
|
|
238
|
+
);
|
|
239
|
+
const scale = screen?.offsetWidth ? view.width / screen.offsetWidth : 1;
|
|
240
|
+
let { top, right, bottom, left } = node.getBoundingClientRect();
|
|
241
|
+
top = Math.max(top, view.top);
|
|
242
|
+
right = Math.min(right, view.right);
|
|
243
|
+
bottom = Math.min(bottom, view.bottom);
|
|
244
|
+
left = Math.max(left, view.left);
|
|
245
|
+
for (let parent = node.parentElement; parent; parent = parent.parentElement) {
|
|
246
|
+
if (getComputedStyle(parent).overflow === 'visible') continue;
|
|
247
|
+
const box = parent.getBoundingClientRect();
|
|
248
|
+
top = Math.max(top, box.top);
|
|
249
|
+
right = Math.min(right, box.right);
|
|
250
|
+
bottom = Math.min(bottom, box.bottom);
|
|
251
|
+
left = Math.max(left, box.left);
|
|
252
|
+
}
|
|
253
|
+
setInset({
|
|
254
|
+
top: (top - view.top) / scale + SHEET_GAP,
|
|
255
|
+
right: (view.right - right) / scale + SHEET_GAP,
|
|
256
|
+
bottom: (view.bottom - bottom) / scale + SHEET_GAP,
|
|
257
|
+
maxWidth: (right - left) / scale - 2 * SHEET_GAP,
|
|
258
|
+
// Too little of the area left to hold a sheet: hide it rather than squash it.
|
|
259
|
+
visibility: (bottom - top) / scale < 160 ? 'hidden' : undefined,
|
|
260
|
+
});
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
update();
|
|
264
|
+
const observer = new ResizeObserver(update);
|
|
265
|
+
observer.observe(node);
|
|
266
|
+
if (screen) observer.observe(screen);
|
|
267
|
+
window.addEventListener('scroll', update, { capture: true, passive: true });
|
|
268
|
+
window.addEventListener('resize', update);
|
|
269
|
+
return () => {
|
|
270
|
+
observer.disconnect();
|
|
271
|
+
window.removeEventListener('scroll', update, { capture: true });
|
|
272
|
+
window.removeEventListener('resize', update);
|
|
273
|
+
};
|
|
274
|
+
}, [node, screen]);
|
|
275
|
+
|
|
276
|
+
return inset;
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
export type SheetContentProps = WithClassName<DialogPrimitive.Popup.Props> & {
|
|
280
|
+
/** Where the sheet is portalled; the body by default. In a container of its own it keeps to that
|
|
281
|
+
* container's edges rather than the sheet area's. */
|
|
282
|
+
container?: DialogPrimitive.Portal.Props['container'];
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
export const SheetContent = ({ className, style, container, ...props }: SheetContentProps) => {
|
|
286
|
+
const modal = useContext(SheetModalContext);
|
|
287
|
+
const area = useContext(SheetAreaContext);
|
|
288
|
+
const screen = usePortalContainer() ?? null;
|
|
289
|
+
const inset = useAreaInset(container ? null : area, container ? null : screen);
|
|
290
|
+
|
|
291
|
+
return (
|
|
292
|
+
<DialogPrimitive.Portal container={container ?? screen ?? undefined}>
|
|
293
|
+
<ThemeScope>
|
|
294
|
+
{/* Base UI renders the backdrop whatever the modality, so only a fully modal sheet gets the scrim; "trap-focus" leaves the page clickable. */}
|
|
295
|
+
{modal === true && (
|
|
296
|
+
<DialogPrimitive.Backdrop
|
|
297
|
+
className={cn(overlayClass, SHEET_LAYER)}
|
|
298
|
+
data-slot="sheet-overlay"
|
|
299
|
+
/>
|
|
300
|
+
)}
|
|
301
|
+
<DialogPrimitive.Popup
|
|
302
|
+
// The surface and the panel radius, like the AppPanel it floats beside, so it follows every theme.
|
|
303
|
+
className={cn(
|
|
304
|
+
'fixed top-4 right-4 bottom-4 flex w-[min(var(--spacing-sheet),calc(100cqw-32px))] flex-col overflow-hidden rounded-panel border border-neutral-200 bg-neutral-50 shadow-sheet outline-none',
|
|
305
|
+
'transition-[opacity,translate] duration-200 ease-out-strong data-ending-style:translate-x-4 data-starting-style:translate-x-4 data-ending-style:opacity-0 data-starting-style:opacity-0 motion-reduce:transition-none',
|
|
306
|
+
SHEET_LAYER,
|
|
307
|
+
className,
|
|
308
|
+
)}
|
|
309
|
+
data-slot="sheet-content"
|
|
310
|
+
style={
|
|
311
|
+
typeof style === 'function'
|
|
312
|
+
? state => ({ ...inset, ...style(state) })
|
|
313
|
+
: { ...inset, ...style }
|
|
314
|
+
}
|
|
315
|
+
{...props}
|
|
316
|
+
/>
|
|
317
|
+
</ThemeScope>
|
|
318
|
+
</DialogPrimitive.Portal>
|
|
319
|
+
);
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
type SheetHeaderProps = ComponentProps<'div'> & {
|
|
323
|
+
/** Leading 16px icon before the title. */
|
|
324
|
+
icon?: ReactNode;
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
/** Title row with a leading icon and the close button, ruled off full width; put a SheetTitle in it. */
|
|
328
|
+
export const SheetHeader = ({ icon, className, children, ...props }: SheetHeaderProps) => (
|
|
329
|
+
<div
|
|
330
|
+
className={cn(
|
|
331
|
+
'flex h-bar shrink-0 items-center gap-2 border-neutral-200 border-b pr-1.5 pl-4 [&>svg:not([class*=size-])]:size-4 [&>svg]:shrink-0 [&>svg]:text-neutral-950',
|
|
332
|
+
className,
|
|
333
|
+
)}
|
|
334
|
+
data-slot="sheet-header"
|
|
335
|
+
{...props}
|
|
336
|
+
>
|
|
337
|
+
{icon}
|
|
338
|
+
{children}
|
|
339
|
+
{/* A 36px target rather than icon-sm's, sized to the 52px header. */}
|
|
340
|
+
<CloseButton className="ml-auto size-option" />
|
|
341
|
+
</div>
|
|
342
|
+
);
|
|
343
|
+
|
|
344
|
+
export const SheetTitle = ({ className, ...props }: WithClassName<DialogPrimitive.Title.Props>) => (
|
|
345
|
+
<DialogPrimitive.Title
|
|
346
|
+
className={cn('min-w-0 truncate font-medium text-neutral-950 text-sm', className)}
|
|
347
|
+
data-slot="sheet-title"
|
|
348
|
+
{...props}
|
|
349
|
+
/>
|
|
350
|
+
);
|
|
351
|
+
|
|
352
|
+
export const SheetBody = ({ className, ...props }: ComponentProps<'div'>) => (
|
|
353
|
+
<div
|
|
354
|
+
className={cn('min-h-0 flex-1 overflow-auto', className)}
|
|
355
|
+
data-slot="sheet-body"
|
|
356
|
+
{...props}
|
|
357
|
+
/>
|
|
358
|
+
);
|
|
359
|
+
|
|
360
|
+
/** A padded part of the sheet; every part after the first is ruled off by a full-width divider. */
|
|
361
|
+
export const SheetSection = ({ className, ...props }: ComponentProps<'section'>) => (
|
|
362
|
+
<section
|
|
363
|
+
className={cn('border-neutral-200 border-t p-5 first:border-t-0', className)}
|
|
364
|
+
data-slot="sheet-section"
|
|
365
|
+
{...props}
|
|
366
|
+
/>
|
|
367
|
+
);
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Toggle } from '@base-ui/react/toggle';
|
|
4
|
+
import { ToggleGroup } from '@base-ui/react/toggle-group';
|
|
5
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
6
|
+
import { type ComponentProps, useEffect } from 'react';
|
|
7
|
+
import { cn } from '../lib/cn';
|
|
8
|
+
import { OverflowChevron, useOverflowScroll } from '../lib/overflow-scroll';
|
|
9
|
+
import { radioToggleRender } from '../lib/radio-toggle-render';
|
|
10
|
+
import { useSingleValue } from '../lib/use-single-value';
|
|
11
|
+
import { buttonVariants, focusRing } from './button';
|
|
12
|
+
import type { SegmentedControlProps } from './segmented-control';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The bar that floats at the bottom of a page: a dock of sections and, beside
|
|
16
|
+
* it, the page's main action (a + or a filter). Its corners follow the theme,
|
|
17
|
+
* a full pill by default, unless `shape` says otherwise.
|
|
18
|
+
*/
|
|
19
|
+
export const BottomBar = ({
|
|
20
|
+
floating,
|
|
21
|
+
className,
|
|
22
|
+
...props
|
|
23
|
+
}: ComponentProps<'div'> & {
|
|
24
|
+
/**
|
|
25
|
+
* Pins the bar 24px above the bottom of its positioned parent, centred, and never wider than the
|
|
26
|
+
* parent less 16px a side, so a dock with more sections than fit scrolls rather than spills.
|
|
27
|
+
*/
|
|
28
|
+
floating?: boolean;
|
|
29
|
+
}) => (
|
|
30
|
+
<div
|
|
31
|
+
className={cn(
|
|
32
|
+
'flex min-w-0 max-w-full items-center gap-2',
|
|
33
|
+
floating && 'absolute inset-x-0 bottom-6 z-10 mx-auto w-fit max-w-[calc(100%-32px)]',
|
|
34
|
+
className,
|
|
35
|
+
)}
|
|
36
|
+
data-slot="bottom-bar"
|
|
37
|
+
{...props}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const shapeVariants = {
|
|
42
|
+
theme: '',
|
|
43
|
+
pill: '[--radius-dock:9999px]',
|
|
44
|
+
// A tighter corner, the item's 10px, so it still scales with the theme's corners.
|
|
45
|
+
rounded: '[--radius-dock:var(--radius-item)]',
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const dockVariants = cva(
|
|
49
|
+
// The field row's 38px: 32px items inside a 2px inset and a hairline. The inset is fixed like the
|
|
50
|
+
// heights, so it stays even on all four sides whatever the spacing unit.
|
|
51
|
+
'flex h-control-lg w-fit min-w-0 max-w-full items-center gap-0.5 rounded-dock border border-neutral-200 bg-neutral-50 p-[2px] shadow-float',
|
|
52
|
+
{ variants: { shape: shapeVariants }, defaultVariants: { shape: 'theme' } },
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
export type DockProps = SegmentedControlProps & VariantProps<typeof dockVariants>;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The sections of a page. Like a segmented control it always keeps one selected. More sections
|
|
59
|
+
* than fit scroll sideways, with a chevron at the end that has more and the selected one kept in view.
|
|
60
|
+
*/
|
|
61
|
+
export const Dock = ({
|
|
62
|
+
shape,
|
|
63
|
+
value,
|
|
64
|
+
defaultValue,
|
|
65
|
+
onValueChange,
|
|
66
|
+
className,
|
|
67
|
+
...props
|
|
68
|
+
}: DockProps) => {
|
|
69
|
+
const [current, select] = useSingleValue(value, defaultValue, onValueChange);
|
|
70
|
+
const { ref, edges, step, reveal, style } = useOverflowScroll<HTMLDivElement>();
|
|
71
|
+
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
// Again when the row starts overflowing, so the selected one is in view from the start.
|
|
74
|
+
if (current && edges.overflows) reveal('[data-pressed]');
|
|
75
|
+
}, [current, reveal, edges.overflows]);
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<div className={cn(dockVariants({ shape }), className)} data-slot="dock">
|
|
79
|
+
{edges.overflows && (
|
|
80
|
+
<OverflowChevron
|
|
81
|
+
className={chevron}
|
|
82
|
+
direction={-1}
|
|
83
|
+
disabled={!edges.start}
|
|
84
|
+
onStep={step}
|
|
85
|
+
/>
|
|
86
|
+
)}
|
|
87
|
+
<ToggleGroup
|
|
88
|
+
// The row clips at the dock's inset, not its items, so a focus ring keeps its room.
|
|
89
|
+
className="scrollbar-none my-[-2px] flex min-w-0 items-center gap-0.5 overflow-x-auto py-[2px]"
|
|
90
|
+
data-slot="dock-items"
|
|
91
|
+
ref={ref}
|
|
92
|
+
role="radiogroup"
|
|
93
|
+
style={style}
|
|
94
|
+
{...props}
|
|
95
|
+
// Clicking the pressed item hands back an empty array, which `select` ignores.
|
|
96
|
+
onValueChange={values => select(values[0] ?? '')}
|
|
97
|
+
value={current ? [current] : []}
|
|
98
|
+
/>
|
|
99
|
+
{edges.overflows && (
|
|
100
|
+
<OverflowChevron
|
|
101
|
+
className={chevron}
|
|
102
|
+
direction={1}
|
|
103
|
+
disabled={!edges.end}
|
|
104
|
+
onStep={step}
|
|
105
|
+
/>
|
|
106
|
+
)}
|
|
107
|
+
</div>
|
|
108
|
+
);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
// An item's 32px and its concentric corner.
|
|
112
|
+
const chevron = 'size-cell rounded-[calc(var(--radius-dock)-3px)]';
|
|
113
|
+
|
|
114
|
+
export type DockItemProps = Omit<Toggle.Props, 'className'> & { className?: string };
|
|
115
|
+
|
|
116
|
+
export const DockItem = ({ className, ...props }: DockItemProps) => (
|
|
117
|
+
<Toggle
|
|
118
|
+
className={cn(
|
|
119
|
+
// The bar's radius minus its 2px inset and 1px border, so the curves stay concentric.
|
|
120
|
+
'inline-flex h-cell cursor-pointer select-none items-center gap-2 whitespace-nowrap rounded-[calc(var(--radius-dock)-3px)] px-3 font-medium text-neutral-600 text-xs transition-[background-color,color,box-shadow] duration-150',
|
|
121
|
+
'hover:text-neutral-950',
|
|
122
|
+
'data-pressed:bg-segment data-pressed:text-segment-fg data-pressed:[box-shadow:inset_0_0_0_1px_var(--color-segment-border),var(--shadow-segment)]',
|
|
123
|
+
'data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg:not([class*=size-])]:size-4 [&_svg]:shrink-0',
|
|
124
|
+
focusRing,
|
|
125
|
+
className,
|
|
126
|
+
)}
|
|
127
|
+
data-slot="dock-item"
|
|
128
|
+
render={radioToggleRender}
|
|
129
|
+
{...props}
|
|
130
|
+
/>
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* A count after a dock item's label ("Active 12"), in the item's own colour at 70%, so it follows
|
|
135
|
+
* the pressed item onto its fill. It hides on a compact shell, where the labels need the room.
|
|
136
|
+
*/
|
|
137
|
+
export const DockCount = ({ className, ...props }: ComponentProps<'span'>) => (
|
|
138
|
+
<span
|
|
139
|
+
className={cn(
|
|
140
|
+
'@max-shell-compact/shell:hidden font-normal tabular-nums opacity-70',
|
|
141
|
+
className,
|
|
142
|
+
)}
|
|
143
|
+
data-slot="dock-count"
|
|
144
|
+
{...props}
|
|
145
|
+
/>
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
export const dockActionVariants = cva(
|
|
149
|
+
[
|
|
150
|
+
// A lit action's ring drawn inside, so it stays the dock's 38px instead of growing 1px each side.
|
|
151
|
+
'rounded-dock [box-shadow:inset_0_1px_0_0_var(--color-action-highlight),inset_0_0_0_1px_var(--color-action-ring)]',
|
|
152
|
+
// On a compact shell an action with an icon keeps only the icon, a 38px square, so the dock
|
|
153
|
+
// keeps the width; its label stays in the button for screen readers, set at no size.
|
|
154
|
+
'@max-shell-compact/shell:has-[svg]:w-control-lg @max-shell-compact/shell:has-[svg]:gap-0 @max-shell-compact/shell:has-[svg]:px-0 @max-shell-compact/shell:has-[svg]:text-[0px]',
|
|
155
|
+
],
|
|
156
|
+
{
|
|
157
|
+
variants: {
|
|
158
|
+
shape: shapeVariants,
|
|
159
|
+
size: {
|
|
160
|
+
default: '',
|
|
161
|
+
icon: 'w-control-lg px-0',
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
defaultVariants: { shape: 'theme', size: 'default' },
|
|
165
|
+
},
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
export type DockActionProps = ComponentProps<'button'> & VariantProps<typeof dockActionVariants>;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* The action beside the dock: a large primary Button with the dock's corners.
|
|
172
|
+
* "Start campaign" with a rocket, a filter with its count "(6)", or
|
|
173
|
+
* `size="icon"` for a lone +.
|
|
174
|
+
*/
|
|
175
|
+
export const DockAction = ({
|
|
176
|
+
shape,
|
|
177
|
+
size,
|
|
178
|
+
className,
|
|
179
|
+
type = 'button',
|
|
180
|
+
...props
|
|
181
|
+
}: DockActionProps) => (
|
|
182
|
+
<button
|
|
183
|
+
className={cn(
|
|
184
|
+
buttonVariants({ variant: 'primary', size: 'lg' }),
|
|
185
|
+
dockActionVariants({ shape, size }),
|
|
186
|
+
className,
|
|
187
|
+
)}
|
|
188
|
+
data-slot="dock-action"
|
|
189
|
+
type={type}
|
|
190
|
+
{...props}
|
|
191
|
+
/>
|
|
192
|
+
);
|