@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,92 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Toolbar as ToolbarPrimitive } from '@base-ui/react/toolbar';
|
|
4
|
+
import { cva } from 'class-variance-authority';
|
|
5
|
+
import { Sparkles } from 'lucide-react';
|
|
6
|
+
import { createContext, useContext } from 'react';
|
|
7
|
+
import { cn } from '../lib/cn.js';
|
|
8
|
+
import { useOverflowScroll } from '../lib/overflow-scroll.js';
|
|
9
|
+
import { focusRing } from './button.js';
|
|
10
|
+
const toolbarVariants = cva('flex w-fit max-w-full items-stretch border border-neutral-200 bg-neutral-50 shadow-float', {
|
|
11
|
+
variants: {
|
|
12
|
+
variant: {
|
|
13
|
+
inline: 'h-control overflow-hidden rounded-control',
|
|
14
|
+
// The field row's 38px: items stretch to the 30px left inside a 3px inset and the hairline. It
|
|
15
|
+
// keeps the inline bar's corner, not the dock's pill, so both variants follow the theme's corners.
|
|
16
|
+
// The inset is fixed px, not the spacing unit, so the items' corner calc below stays true.
|
|
17
|
+
floating: 'h-control-lg rounded-control p-[3px] [--spacing-icon:var(--spacing-icon-lg)]',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
defaultVariants: { variant: 'inline' },
|
|
21
|
+
});
|
|
22
|
+
/*
|
|
23
|
+
* The items sit in a row inside the bar, so a bar wider than its room scrolls sideways under its
|
|
24
|
+
* own border and shadow rather than clipping its last actions: the scrollbar hidden, the edge with
|
|
25
|
+
* more faded. A bar that fits is left exactly as it was, since the row only scrolls once it
|
|
26
|
+
* overflows.
|
|
27
|
+
*/
|
|
28
|
+
const toolbarRowVariants = cva('flex min-w-0 items-stretch', {
|
|
29
|
+
variants: {
|
|
30
|
+
variant: {
|
|
31
|
+
inline: '',
|
|
32
|
+
// Scrolling, the row reaches out over the inset and the hairline, so a focus ring keeps its room.
|
|
33
|
+
floating: 'gap-0.5 data-overflows:-m-[4px] data-overflows:p-[4px]',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
defaultVariants: { variant: 'inline' },
|
|
37
|
+
});
|
|
38
|
+
const toolbarButtonVariants = cva([
|
|
39
|
+
'inline-flex cursor-pointer select-none items-center whitespace-nowrap font-medium text-neutral-600 text-xs transition-[background-color,color] duration-150',
|
|
40
|
+
'hover:text-neutral-950',
|
|
41
|
+
// Base UI keeps a disabled toolbar button focusable, so it sets data-disabled rather than the disabled attribute.
|
|
42
|
+
'data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg:not([class*=size-])]:size-icon [&_svg]:shrink-0',
|
|
43
|
+
// In a compact shell a button with an icon keeps only the icon, a square on the bar's height;
|
|
44
|
+
// its label stays in the tree at no size, so a screen reader still says it. A button
|
|
45
|
+
// without an icon keeps its label, since it has nothing else to show.
|
|
46
|
+
'@max-shell-compact/shell:has-[>svg]:gap-0 @max-shell-compact/shell:has-[>svg]:px-2 @max-shell-compact/shell:has-[>svg]:text-[0px]',
|
|
47
|
+
focusRing,
|
|
48
|
+
], {
|
|
49
|
+
variants: {
|
|
50
|
+
variant: {
|
|
51
|
+
// The bar clips overflow, so the ring has to sit inside the button. The divider runs the full
|
|
52
|
+
// height, but the hover sits 2px inside it, the same shape as the chip.
|
|
53
|
+
inline: [
|
|
54
|
+
'relative isolate gap-2 border-neutral-200 not-last:border-r px-3 focus-visible:-outline-offset-2',
|
|
55
|
+
'before:absolute before:inset-[2px] before:-z-10 before:rounded-[calc(var(--radius-control)-3px)] before:transition-colors before:duration-150 hover:before:bg-neutral-950/5',
|
|
56
|
+
],
|
|
57
|
+
// The bar's radius minus its 3px inset and 1px border, so the curves stay concentric.
|
|
58
|
+
floating: 'gap-2 rounded-[calc(var(--radius-control)-4px)] px-3 hover:bg-neutral-950/5',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
defaultVariants: { variant: 'inline' },
|
|
62
|
+
});
|
|
63
|
+
const ToolbarVariantContext = createContext('inline');
|
|
64
|
+
/**
|
|
65
|
+
* `inline` is an AI toolbar over a table cell or a selection: flush segments
|
|
66
|
+
* split by hairlines. `floating` is a bottom action bar: padded, with rounded
|
|
67
|
+
* items and no dividers, at the dock's height with the inline bar's corners.
|
|
68
|
+
*/
|
|
69
|
+
export const Toolbar = ({ variant, className, children, ...props }) => {
|
|
70
|
+
const { ref, edges, style } = useOverflowScroll();
|
|
71
|
+
return (_jsx(ToolbarVariantContext.Provider, { value: variant ?? 'inline', children: _jsx(ToolbarPrimitive.Root, { className: cn(toolbarVariants({ variant }), className), "data-slot": "toolbar", "data-variant": variant ?? 'inline', ...props, children: _jsx("div", { className: cn(toolbarRowVariants({ variant }), edges.overflows && 'scrollbar-none overflow-x-auto'), "data-overflows": edges.overflows || undefined, "data-slot": "toolbar-row", ref: ref, style: edges.overflows ? style : undefined, children: children }) }) }));
|
|
72
|
+
};
|
|
73
|
+
export const ToolbarButton = ({ className, ...props }) => {
|
|
74
|
+
const variant = useContext(ToolbarVariantContext);
|
|
75
|
+
return (_jsx(ToolbarPrimitive.Button, { className: cn(toolbarButtonVariants({ variant }), className), "data-slot": "toolbar-button", type: "button", ...props }));
|
|
76
|
+
};
|
|
77
|
+
const toolbarChipVariants = cva('inline-flex select-none items-center gap-1.5 whitespace-nowrap bg-primary-500/20 font-medium text-primary-800 text-xxs [&_svg:not([class*=size-])]:size-4 [&_svg]:shrink-0', {
|
|
78
|
+
variants: {
|
|
79
|
+
variant: {
|
|
80
|
+
// Inset 2px inside a 1px border, so the bar's radius minus 3px keeps it concentric.
|
|
81
|
+
inline: 'm-[2px] rounded-[calc(var(--radius-control)-3px)] px-2',
|
|
82
|
+
// The bar's own 3px inset already holds it, so it takes the buttons' size and corner.
|
|
83
|
+
floating: 'rounded-[calc(var(--radius-control)-4px)] px-2.5',
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
defaultVariants: { variant: 'inline' },
|
|
87
|
+
});
|
|
88
|
+
/** The lead chip ("AI suggestions") at the start of the toolbar, coloured like a primary badge. */
|
|
89
|
+
export const ToolbarChip = ({ icon, className, children, ...props }) => {
|
|
90
|
+
const variant = useContext(ToolbarVariantContext);
|
|
91
|
+
return (_jsxs("span", { className: cn(toolbarChipVariants({ variant }), className), "data-slot": "toolbar-chip", ...props, children: [icon ?? _jsx(Sparkles, { strokeWidth: 2 }), children] }));
|
|
92
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
|
|
2
|
+
import { type ComponentProps } from 'react';
|
|
3
|
+
import { type WithClassName } from '../lib/cn.js';
|
|
4
|
+
/**
|
|
5
|
+
* Groups the tooltips inside it: once one has shown, the next one pointed at opens at once, so
|
|
6
|
+
* moving along a rail or a toolbar reads each label without waiting again.
|
|
7
|
+
*/
|
|
8
|
+
export declare const TooltipProvider: ({ delay, children, ...props }: ComponentProps<typeof TooltipPrimitive.Provider>) => import("react").JSX.Element;
|
|
9
|
+
/**
|
|
10
|
+
* Brings its own provider when there is none higher up, so a lone tooltip works; inside a
|
|
11
|
+
* TooltipProvider it joins that one, since a provider of its own would cut it out of the group.
|
|
12
|
+
*/
|
|
13
|
+
export declare const Tooltip: (props: ComponentProps<typeof TooltipPrimitive.Root>) => import("react").JSX.Element;
|
|
14
|
+
export declare const TooltipTrigger: (props: ComponentProps<typeof TooltipPrimitive.Trigger>) => import("react").JSX.Element;
|
|
15
|
+
type TooltipContentProps = WithClassName<ComponentProps<typeof TooltipPrimitive.Popup>> & Pick<ComponentProps<typeof TooltipPrimitive.Positioner>, 'align' | 'alignOffset' | 'side' | 'sideOffset'> & {
|
|
16
|
+
/** Where the chip is portalled; the body by default. */
|
|
17
|
+
container?: ComponentProps<typeof TooltipPrimitive.Portal>['container'];
|
|
18
|
+
/** Classes for the positioner, such as a higher layer for a tooltip on something above dialogs. */
|
|
19
|
+
positionerClassName?: string;
|
|
20
|
+
};
|
|
21
|
+
/** Dark label chip for icon-only controls, such as the analytics rail. */
|
|
22
|
+
export declare const TooltipContent: ({ className, side, sideOffset, align, alignOffset, container, positionerClassName, ...props }: TooltipContentProps) => import("react").JSX.Element;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
|
|
4
|
+
import { createContext, useContext } from 'react';
|
|
5
|
+
import { cn } from '../lib/cn.js';
|
|
6
|
+
import { ThemeScope, usePortalContainer } from './theme.js';
|
|
7
|
+
// Whether a TooltipProvider sits above, so a tooltip inside it joins that provider's group.
|
|
8
|
+
const InProviderContext = createContext(false);
|
|
9
|
+
/**
|
|
10
|
+
* Groups the tooltips inside it: once one has shown, the next one pointed at opens at once, so
|
|
11
|
+
* moving along a rail or a toolbar reads each label without waiting again.
|
|
12
|
+
*/
|
|
13
|
+
export const TooltipProvider = ({ delay = 300, children, ...props }) => (_jsx(TooltipPrimitive.Provider, { "data-slot": "tooltip-provider", delay: delay, ...props, children: _jsx(InProviderContext.Provider, { value: true, children: children }) }));
|
|
14
|
+
/**
|
|
15
|
+
* Brings its own provider when there is none higher up, so a lone tooltip works; inside a
|
|
16
|
+
* TooltipProvider it joins that one, since a provider of its own would cut it out of the group.
|
|
17
|
+
*/
|
|
18
|
+
export const Tooltip = (props) => {
|
|
19
|
+
const root = _jsx(TooltipPrimitive.Root, { "data-slot": "tooltip", ...props });
|
|
20
|
+
return useContext(InProviderContext) ? root : _jsx(TooltipProvider, { children: root });
|
|
21
|
+
};
|
|
22
|
+
export const TooltipTrigger = (props) => (_jsx(TooltipPrimitive.Trigger, { "data-slot": "tooltip-trigger", ...props }));
|
|
23
|
+
/** Dark label chip for icon-only controls, such as the analytics rail. */
|
|
24
|
+
export const TooltipContent = ({ className, side = 'top', sideOffset = 6, align = 'center', alignOffset = 0, container, positionerClassName, ...props }) => (_jsx(TooltipPrimitive.Portal, { container: usePortalContainer(container), children: _jsx(ThemeScope, { children: _jsx(TooltipPrimitive.Positioner, { align: align, alignOffset: alignOffset, className: cn('z-50', positionerClassName), "data-slot": "tooltip-positioner", side: side, sideOffset: sideOffset, children: _jsx(TooltipPrimitive.Popup, { className: cn('max-w-tooltip origin-(--transform-origin) select-none text-balance rounded-chip bg-neutral-950 px-2 py-1 font-medium text-neutral-50 text-xxs',
|
|
25
|
+
// Base UI keeps the popup mounted while it fades out; data-instant marks a hop between
|
|
26
|
+
// grouped tooltips, which should swap without fading.
|
|
27
|
+
'transition-opacity duration-200 ease-out-strong data-ending-style:opacity-0 data-starting-style:opacity-0 data-instant:transition-none motion-reduce:transition-none', className), "data-slot": "tooltip-content", ...props }) }) }) }));
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { Menu as MenuPrimitive } from '@base-ui/react/menu';
|
|
2
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
3
|
+
import { type ComponentProps, type MouseEvent, type ReactNode } from 'react';
|
|
4
|
+
import { DropdownMenuContent } from './dropdown-menu.js';
|
|
5
|
+
declare const columns: {
|
|
6
|
+
readonly narrow: "max-w-content-narrow px-4 sm:px-6";
|
|
7
|
+
readonly default: "max-w-content px-4 sm:px-6";
|
|
8
|
+
readonly wide: "max-w-content-wide px-4 sm:px-6";
|
|
9
|
+
readonly dense: "max-w-content-dense px-4 sm:px-6";
|
|
10
|
+
readonly inset: "px-4 sm:px-6 lg:px-16 2xl:px-content-inset";
|
|
11
|
+
readonly full: "px-4";
|
|
12
|
+
};
|
|
13
|
+
export type TopNavProps = ComponentProps<'header'> & {
|
|
14
|
+
/** The page's column, as its `PageContent` width, so the bar lines up with the page under it. */
|
|
15
|
+
width?: keyof typeof columns;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The top navigation: the top of the page. A 56px bar across the shell, on the page's surface with
|
|
19
|
+
* a hairline under it, and the page straight under it, with no inset panel; put it in
|
|
20
|
+
* `<AppShell nav="top">`. Its contents keep to the page's column: the brand, then a switcher, the
|
|
21
|
+
* sections (links, and menus for a section with pages of its own), the account pushed right.
|
|
22
|
+
*
|
|
23
|
+
* Its sections scroll along the bar when they run out of room, so it keeps them up to the compact
|
|
24
|
+
* width (640). Below it the switcher, the sections and the actions leave the bar: a toggle before
|
|
25
|
+
* the brand opens the shell's drawer, which shows the switcher and the sections as a sidebar's rows.
|
|
26
|
+
*/
|
|
27
|
+
export declare const TopNav: ({ width, className, children, ...props }: TopNavProps) => import("react").JSX.Element;
|
|
28
|
+
type TopNavBrandProps = ComponentProps<'a'> & {
|
|
29
|
+
/** Swaps the link for another element, e.g. a router link. */
|
|
30
|
+
render?: useRender.RenderProp;
|
|
31
|
+
/** The 26px mark, in ink on no tile, as the sidebar's. */
|
|
32
|
+
logo: ReactNode;
|
|
33
|
+
};
|
|
34
|
+
/** The mark and the product's name, linking home. The name hides on a compact bar. */
|
|
35
|
+
export declare const TopNavBrand: ({ render, logo, className, children, ...props }: TopNavBrandProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
36
|
+
type TopNavSwitcherProps = Omit<MenuPrimitive.Root.Props, 'children'> & {
|
|
37
|
+
/** A `SidebarSwitcherMark`, avatar or logo: 20px on the bar, 28 in the drawer. */
|
|
38
|
+
mark?: ReactNode;
|
|
39
|
+
/** The current workspace, or what to say when there is none ("No project"). */
|
|
40
|
+
name: ReactNode;
|
|
41
|
+
/** The quiet line under the name, shown in the drawer only: the bar has room for one line. */
|
|
42
|
+
detail?: ReactNode;
|
|
43
|
+
/** Its name for screen readers, which should say it switches ("Northwind. Switch workspace"). */
|
|
44
|
+
'aria-label'?: string;
|
|
45
|
+
/** Where the menu is portalled; the body by default. */
|
|
46
|
+
container?: ComponentProps<typeof DropdownMenuContent>['container'];
|
|
47
|
+
className?: string;
|
|
48
|
+
/** The menu: the other workspaces as `DropdownMenuItem`s, then a separator and "New …". */
|
|
49
|
+
children: ReactNode;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* The sidebar's switcher on the bar: the current workspace, project or account, as a button that
|
|
53
|
+
* opens a menu of the others. A 20 mark, the name and an up-down chevron on a link's 34px row; the
|
|
54
|
+
* same menu as the sidebar's. In the drawer it is the sidebar's switcher, under the header.
|
|
55
|
+
*/
|
|
56
|
+
export declare const TopNavSwitcher: ({ mark, name, detail, "aria-label": label, container, className, children, ...props }: TopNavSwitcherProps) => import("react").JSX.Element;
|
|
57
|
+
/**
|
|
58
|
+
* The sections, 2px apart. On a narrow bar they scroll sideways rather than wrap, with a chevron
|
|
59
|
+
* at the end that has more and the current one kept in view.
|
|
60
|
+
*/
|
|
61
|
+
export declare const TopNavLinks: ({ className, children, ...props }: ComponentProps<"nav">) => import("react").JSX.Element;
|
|
62
|
+
type TopNavLinkProps = ComponentProps<'button'> & {
|
|
63
|
+
/** Swaps the button for another element, e.g. `render={<a href="/connections" />}`. */
|
|
64
|
+
render?: useRender.RenderProp;
|
|
65
|
+
active?: boolean;
|
|
66
|
+
/** Leading 16px icon; most bars read better without. */
|
|
67
|
+
icon?: ReactNode;
|
|
68
|
+
/** How many wait for the reader there, as the sidebar's count badge after the label. */
|
|
69
|
+
count?: ReactNode;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* A section, as a sidebar row is: 34px, the selected one on a 5% wash set via aria-current, so
|
|
73
|
+
* router links that set it themselves work too. In the shell's drawer it is drawn as a sidebar's
|
|
74
|
+
* row, and choosing it closes the drawer.
|
|
75
|
+
*/
|
|
76
|
+
export declare const TopNavLink: ({ render, active, icon, count, className, children, type, onClick, ...props }: TopNavLinkProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
77
|
+
type TopNavMenuProps = Omit<MenuPrimitive.Root.Props, 'children'> & {
|
|
78
|
+
/** The section's name on the bar. */
|
|
79
|
+
label: ReactNode;
|
|
80
|
+
/** Leading 16px icon, as the links have. */
|
|
81
|
+
icon?: ReactNode;
|
|
82
|
+
/** How many it holds, a plain figure after the chevron in the drawer, as a sidebar section's. */
|
|
83
|
+
count?: ReactNode;
|
|
84
|
+
/**
|
|
85
|
+
* Holds the page you are on. Found by itself among its rows (an item set `active`); set it
|
|
86
|
+
* where the page is not one of them.
|
|
87
|
+
*/
|
|
88
|
+
current?: boolean;
|
|
89
|
+
/** Where the menu is portalled; the body by default. */
|
|
90
|
+
container?: ComponentProps<typeof DropdownMenuContent>['container'];
|
|
91
|
+
className?: string;
|
|
92
|
+
/** Its pages, as `TopNavMenuItem`s, in `TopNavMenuGroup`s when they fall into groups. */
|
|
93
|
+
children: ReactNode;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* A section with pages of its own, the sidebar's foldout on the bar: a link with a chevron that opens
|
|
97
|
+
* a menu of its pages. Holding the page you are on, it takes the current look, since the page itself
|
|
98
|
+
* is not on the bar. In the drawer it is a sidebar section that folds open to its pages.
|
|
99
|
+
*/
|
|
100
|
+
export declare const TopNavMenu: ({ label, icon, count, current, container, className, children, ...props }: TopNavMenuProps) => import("react").JSX.Element;
|
|
101
|
+
type TopNavMenuGroupProps = Omit<ComponentProps<'div'>, 'children'> & {
|
|
102
|
+
/** Small heading above the group's pages ("Reports"). */
|
|
103
|
+
label?: ReactNode;
|
|
104
|
+
children: ReactNode;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* A group of a TopNavMenu's pages under a small heading, as a sidebar group is. In the menu a
|
|
108
|
+
* group after another is ruled off by a hairline; in the drawer it is the heading over its rows.
|
|
109
|
+
*/
|
|
110
|
+
export declare const TopNavMenuGroup: ({ label, className, children, ...props }: TopNavMenuGroupProps) => import("react").JSX.Element;
|
|
111
|
+
type TopNavMenuItemProps = Omit<ComponentProps<'button'>, 'onClick'> & {
|
|
112
|
+
/** Swaps the row for another element, e.g. `render={<a href="/reports/revenue" />}`. */
|
|
113
|
+
render?: useRender.RenderProp;
|
|
114
|
+
/** The page you are on: the selected wash, and its menu takes the bar's current look. */
|
|
115
|
+
active?: boolean;
|
|
116
|
+
/** Leading 16px icon. */
|
|
117
|
+
icon?: ReactNode;
|
|
118
|
+
/** How many wait for the reader there, as a count badge at the row's end. */
|
|
119
|
+
count?: ReactNode;
|
|
120
|
+
onClick?: (event: MouseEvent<HTMLElement>) => void;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* One page of a TopNavMenu: a menu row on the bar, the page you are on on the selected wash; a
|
|
124
|
+
* sidebar's inset row in the drawer.
|
|
125
|
+
*/
|
|
126
|
+
export declare const TopNavMenuItem: ({ render, active, icon, count, className, children, onClick, ...props }: TopNavMenuItemProps) => import("react").JSX.Element;
|
|
127
|
+
/** Pushed to the right: a search, a bell, the account's avatar and its menu. They hide on a compact shell. */
|
|
128
|
+
export declare const TopNavActions: ({ className, ...props }: ComponentProps<"div">) => import("react").JSX.Element;
|
|
129
|
+
export {};
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { Menu as MenuPrimitive } from '@base-ui/react/menu';
|
|
4
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
5
|
+
import { ChevronDown, ChevronsUpDown } from 'lucide-react';
|
|
6
|
+
import { Children, createContext, Fragment, isValidElement, useCallback, useContext, useEffect, useId, useMemo, useRef, useState, } from 'react';
|
|
7
|
+
import { createPortal } from 'react-dom';
|
|
8
|
+
import { cn } from '../lib/cn.js';
|
|
9
|
+
import { OverflowChevron, useOverflowScroll } from '../lib/overflow-scroll.js';
|
|
10
|
+
import { Badge } from './badge.js';
|
|
11
|
+
import { focusRing } from './button.js';
|
|
12
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuTrigger } from './dropdown-menu.js';
|
|
13
|
+
import { HeaderBarSidebarToggle } from './header-bar.js';
|
|
14
|
+
import { MenuItem } from './menu-item.js';
|
|
15
|
+
import { navDrawerClasses, SidebarItem, SidebarSection, sidebarItemClasses, useAppShellNav, } from './sidebar.js';
|
|
16
|
+
import { SidebarSwitcher } from './sidebar-switcher.js';
|
|
17
|
+
const TopNavContext = createContext({
|
|
18
|
+
drawer: false,
|
|
19
|
+
switcherHost: null,
|
|
20
|
+
linksHost: null,
|
|
21
|
+
});
|
|
22
|
+
/** Whether a part is drawn in the drawer's list rather than along the bar. */
|
|
23
|
+
const InDrawerContext = createContext(false);
|
|
24
|
+
/** Whether a part sits in a TopNavMenu's popup, so its rows are menu rows. */
|
|
25
|
+
const InMenuContext = createContext(false);
|
|
26
|
+
/** An item's count: how many wait for the reader there, as the sidebar's primary count badge. */
|
|
27
|
+
const TopNavCount = ({ children }) => (_jsx(Badge, { "data-slot": "top-nav-count", tone: "primary", variant: "count", children: children }));
|
|
28
|
+
/*
|
|
29
|
+
* The bar's contents keep to the page's column, so the brand starts where the page's title does:
|
|
30
|
+
* the same caps and side padding as PageContent's widths.
|
|
31
|
+
*/
|
|
32
|
+
const columns = {
|
|
33
|
+
narrow: 'max-w-content-narrow px-4 sm:px-6',
|
|
34
|
+
default: 'max-w-content px-4 sm:px-6',
|
|
35
|
+
wide: 'max-w-content-wide px-4 sm:px-6',
|
|
36
|
+
dense: 'max-w-content-dense px-4 sm:px-6',
|
|
37
|
+
inset: 'px-4 sm:px-6 lg:px-16 2xl:px-content-inset',
|
|
38
|
+
full: 'px-4',
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* The top navigation: the top of the page. A 56px bar across the shell, on the page's surface with
|
|
42
|
+
* a hairline under it, and the page straight under it, with no inset panel; put it in
|
|
43
|
+
* `<AppShell nav="top">`. Its contents keep to the page's column: the brand, then a switcher, the
|
|
44
|
+
* sections (links, and menus for a section with pages of its own), the account pushed right.
|
|
45
|
+
*
|
|
46
|
+
* Its sections scroll along the bar when they run out of room, so it keeps them up to the compact
|
|
47
|
+
* width (640). Below it the switcher, the sections and the actions leave the bar: a toggle before
|
|
48
|
+
* the brand opens the shell's drawer, which shows the switcher and the sections as a sidebar's rows.
|
|
49
|
+
*/
|
|
50
|
+
export const TopNav = ({ width = 'default', className, children, ...props }) => {
|
|
51
|
+
const shell = useAppShellNav();
|
|
52
|
+
const drawer = shell !== null && shell.nav === 'top' && !shell.inPanel;
|
|
53
|
+
const [switcherHost, setSwitcherHost] = useState(null);
|
|
54
|
+
const [linksHost, setLinksHost] = useState(null);
|
|
55
|
+
const drawerId = useId();
|
|
56
|
+
const setDrawer = shell?.setDrawer;
|
|
57
|
+
const context = useMemo(() => ({ drawer, switcherHost, linksHost }), [drawer, switcherHost, linksHost]);
|
|
58
|
+
return (_jsxs(TopNavContext.Provider, { value: context, children: [_jsx("header", { className: cn('sticky top-0 z-30 flex shrink-0 border-neutral-200 border-b bg-neutral-50', className), "data-slot": "top-nav", "data-width": width, ...props, children: _jsxs("div", { className: cn('mx-auto box-content flex h-nav min-w-0 flex-1 items-center gap-6 @max-shell-compact/shell:px-4', columns[width]), "data-slot": "top-nav-row", children: [drawer && _jsx(HeaderBarSidebarToggle, { className: "-mr-4" }), children] }) }), drawer && (_jsxs("div", { className: cn('@max-shell-compact/shell:flex hidden w-sidebar flex-col overflow-y-auto', navDrawerClasses(shell?.open ?? false, 'top')), "data-slot": "top-nav-drawer", id: drawerId, ref: setDrawer, tabIndex: shell?.open ? -1 : undefined, children: [_jsx("div", { className: "flex h-nav shrink-0 items-center px-4", children: _jsx(HeaderBarSidebarToggle, {}) }), _jsx("div", { className: "flex flex-col empty:hidden", ref: setSwitcherHost }), _jsx("div", { className: "flex flex-col pt-2 pr-3 pl-2", ref: setLinksHost })] }))] }));
|
|
59
|
+
};
|
|
60
|
+
/** The mark and the product's name, linking home. The name hides on a compact bar. */
|
|
61
|
+
export const TopNavBrand = ({ render, logo, className, children, ...props }) => useRender({
|
|
62
|
+
defaultTagName: 'a',
|
|
63
|
+
render,
|
|
64
|
+
props: {
|
|
65
|
+
className: cn('flex shrink-0 items-center gap-2 rounded-item pr-1 font-medium text-neutral-950 text-sm', focusRing, className),
|
|
66
|
+
'data-slot': 'top-nav-brand',
|
|
67
|
+
...props,
|
|
68
|
+
children: (_jsxs(_Fragment, { children: [_jsx("span", { className: "grid size-6.5 shrink-0 place-items-center [&_svg:not([class*=size-])]:size-4", children: logo }), children && (_jsx("span", { className: "@max-shell-compact/shell:hidden", children: children }))] })),
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
/**
|
|
72
|
+
* The sidebar's switcher on the bar: the current workspace, project or account, as a button that
|
|
73
|
+
* opens a menu of the others. A 20 mark, the name and an up-down chevron on a link's 34px row; the
|
|
74
|
+
* same menu as the sidebar's. In the drawer it is the sidebar's switcher, under the header.
|
|
75
|
+
*/
|
|
76
|
+
export const TopNavSwitcher = ({ mark, name, detail, 'aria-label': label, container, className, children, ...props }) => {
|
|
77
|
+
const { drawer, switcherHost } = useContext(TopNavContext);
|
|
78
|
+
return (_jsxs(_Fragment, { children: [_jsxs(DropdownMenu, { ...props, children: [_jsxs(DropdownMenuTrigger, { "aria-label": label, className: cn('flex h-control min-w-0 max-w-60 shrink-0 cursor-pointer items-center gap-2 rounded-item pr-2 pl-2 text-left transition-colors duration-150 hover:bg-neutral-950/5 data-popup-open:bg-selected', focusRing,
|
|
79
|
+
// Shown in the drawer instead, while the shell is compact.
|
|
80
|
+
drawer && '@max-shell-compact/shell:hidden', className), "data-slot": "top-nav-switcher", children: [mark && (
|
|
81
|
+
// A workspace mark, however it is wrapped, drawn at its 20 size (11 type);
|
|
82
|
+
// an avatar or an image fills the 20 square.
|
|
83
|
+
_jsx("span", { className: "grid size-5 shrink-0 place-items-center overflow-hidden rounded-chip *:size-full [&>img]:object-cover [&_[data-slot=sidebar-switcher-mark]]:size-5 [&_[data-slot=sidebar-switcher-mark]]:text-xxs", children: mark })), _jsx("span", { className: "min-w-0 truncate font-medium text-neutral-950 text-xs", children: name }), _jsx(ChevronsUpDown, { "aria-hidden": true, className: "size-icon shrink-0 text-neutral-500", strokeWidth: 2 })] }), _jsx(DropdownMenuContent, { align: "start", className: "min-w-menu-wide", container: container, children: children })] }), drawer &&
|
|
84
|
+
switcherHost &&
|
|
85
|
+
createPortal(_jsx(SidebarSwitcher, { "aria-label": label, container: container, detail: detail, mark: mark, name: name, children: children }), switcherHost)] }));
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* The sections, 2px apart. On a narrow bar they scroll sideways rather than wrap, with a chevron
|
|
89
|
+
* at the end that has more and the current one kept in view.
|
|
90
|
+
*/
|
|
91
|
+
export const TopNavLinks = ({ className, children, ...props }) => {
|
|
92
|
+
const { drawer, linksHost } = useContext(TopNavContext);
|
|
93
|
+
const { ref, edges, step, reveal, style } = useOverflowScroll();
|
|
94
|
+
const row = useRef(null);
|
|
95
|
+
const shown = useRef({ link: null });
|
|
96
|
+
const setRow = useCallback((node) => {
|
|
97
|
+
row.current = node;
|
|
98
|
+
ref(node);
|
|
99
|
+
}, [ref]);
|
|
100
|
+
// Brought into view only when the current section changes, as the dock does on its value, so a
|
|
101
|
+
// re-render never scrolls the row back while someone is looking along it. The links carry no
|
|
102
|
+
// value, so the current one is known by its place among them. `reveal` is new once the row has
|
|
103
|
+
// mounted, which counts as a change, so the first current link is brought into view too.
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
const links = Array.from(row.current?.children ?? []);
|
|
106
|
+
const index = links.findIndex(link => link.matches('[aria-current=page], [data-current]'));
|
|
107
|
+
const link = index < 0 ? null : `${index}:${links[index]?.textContent ?? ''}`;
|
|
108
|
+
if (link === shown.current.link && reveal === shown.current.reveal)
|
|
109
|
+
return;
|
|
110
|
+
shown.current = { link, reveal };
|
|
111
|
+
if (link)
|
|
112
|
+
reveal('[aria-current=page], [data-current]');
|
|
113
|
+
});
|
|
114
|
+
return (_jsxs(_Fragment, { children: [_jsxs("nav", { className: cn('flex min-w-0 items-center gap-0.5',
|
|
115
|
+
// Listed in the drawer instead, while the shell is compact.
|
|
116
|
+
drawer && '@max-shell-compact/shell:hidden', className), "data-slot": "top-nav-links", ...props, children: [edges.overflows && (_jsx(OverflowChevron, { className: chevron, direction: -1, disabled: !edges.start, onStep: step })), _jsx("div", { className: "scrollbar-none -my-1 flex min-w-0 items-center gap-0.5 overflow-x-auto py-1", ref: setRow, style: style, children: children }), edges.overflows && (_jsx(OverflowChevron, { className: chevron, direction: 1, disabled: !edges.end, onStep: step }))] }), drawer &&
|
|
117
|
+
linksHost &&
|
|
118
|
+
createPortal(_jsx(InDrawerContext.Provider, { value: true, children: _jsx("nav", { "aria-label": props['aria-label'], className: "flex flex-col gap-0.5", "data-slot": "top-nav-drawer-links", children: children }) }), linksHost)] }));
|
|
119
|
+
};
|
|
120
|
+
// A link's 34px and corner.
|
|
121
|
+
const chevron = 'size-control rounded-item';
|
|
122
|
+
// A section on the bar: the sidebar's row, as wide as its label, in the quieter grey until current.
|
|
123
|
+
const barLink = 'h-control w-auto shrink-0 px-3 text-neutral-600 text-xs hover:text-neutral-950 aria-[current=page]:text-neutral-950';
|
|
124
|
+
/**
|
|
125
|
+
* A section, as a sidebar row is: 34px, the selected one on a 5% wash set via aria-current, so
|
|
126
|
+
* router links that set it themselves work too. In the shell's drawer it is drawn as a sidebar's
|
|
127
|
+
* row, and choosing it closes the drawer.
|
|
128
|
+
*/
|
|
129
|
+
export const TopNavLink = ({ render, active, icon, count, className, children, type = 'button', onClick, ...props }) => {
|
|
130
|
+
const inDrawer = useContext(InDrawerContext);
|
|
131
|
+
const shell = useAppShellNav();
|
|
132
|
+
return useRender({
|
|
133
|
+
defaultTagName: 'button',
|
|
134
|
+
render,
|
|
135
|
+
props: {
|
|
136
|
+
'aria-current': active ? 'page' : undefined,
|
|
137
|
+
className: cn(sidebarItemClasses, inDrawer ? 'h-control text-neutral-950 text-xs' : barLink, className),
|
|
138
|
+
'data-slot': 'top-nav-link',
|
|
139
|
+
// A rendered link or router element is not a button, so it gets no type.
|
|
140
|
+
type: render ? undefined : type,
|
|
141
|
+
...props,
|
|
142
|
+
onClick: (event) => {
|
|
143
|
+
onClick?.(event);
|
|
144
|
+
if (inDrawer && !event.defaultPrevented)
|
|
145
|
+
shell?.setOpen(false);
|
|
146
|
+
},
|
|
147
|
+
children: inDrawer ? (_jsxs(_Fragment, { children: [icon, _jsx("span", { className: "min-w-0 flex-1 truncate", children: children }), count !== undefined && _jsx(TopNavCount, { children: count })] })) : (_jsxs(_Fragment, { children: [icon, children, count !== undefined && _jsx(TopNavCount, { children: count })] })),
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
/** Whether any of the menu's rows is the page you are on, read from their `active`. */
|
|
152
|
+
const holdsCurrent = (node) => {
|
|
153
|
+
let found = false;
|
|
154
|
+
const visit = (children) => Children.forEach(children, child => {
|
|
155
|
+
if (found || !isValidElement(child))
|
|
156
|
+
return;
|
|
157
|
+
const props = child.props;
|
|
158
|
+
if (child.type === TopNavMenuItem && props.active)
|
|
159
|
+
found = true;
|
|
160
|
+
else if (child.type === Fragment || child.type === TopNavMenuGroup)
|
|
161
|
+
visit(props.children);
|
|
162
|
+
});
|
|
163
|
+
visit(node);
|
|
164
|
+
return found;
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* A section with pages of its own, the sidebar's foldout on the bar: a link with a chevron that opens
|
|
168
|
+
* a menu of its pages. Holding the page you are on, it takes the current look, since the page itself
|
|
169
|
+
* is not on the bar. In the drawer it is a sidebar section that folds open to its pages.
|
|
170
|
+
*/
|
|
171
|
+
export const TopNavMenu = ({ label, icon, count, current, container, className, children, ...props }) => {
|
|
172
|
+
const inDrawer = useContext(InDrawerContext);
|
|
173
|
+
const holds = current || holdsCurrent(children);
|
|
174
|
+
if (inDrawer)
|
|
175
|
+
return (_jsx(SidebarSection
|
|
176
|
+
// Among the bar's links, listed as a sidebar's default rows: the section's row and
|
|
177
|
+
// its pages in their type and ink, not a project list's 14.
|
|
178
|
+
, {
|
|
179
|
+
// Among the bar's links, listed as a sidebar's default rows: the section's row and
|
|
180
|
+
// its pages in their type and ink, not a project list's 14.
|
|
181
|
+
className: cn('[&>[data-slot=sidebar-section-trigger]]:text-neutral-950 [&>[data-slot=sidebar-section-trigger]]:text-xs [&_[data-slot=sidebar-item]]:text-xs', className), count: count, current: current, defaultOpen: holds, icon: icon, label: label, children: children }));
|
|
182
|
+
return (_jsxs(DropdownMenu, { ...props, children: [_jsxs(DropdownMenuTrigger, { className: cn(sidebarItemClasses, barLink, 'group gap-1.5 data-popup-open:bg-neutral-950/5 data-popup-open:text-neutral-950',
|
|
183
|
+
// The section that holds the page draws as the current link.
|
|
184
|
+
'data-current:bg-nav-active data-current:text-nav-active-fg data-current:hover:bg-nav-active', 'data-current:[background-image:var(--nav-active-image)] data-current:[box-shadow:inset_0_0_0_1px_var(--color-nav-active-border),var(--shadow-nav-active)]', className), "data-current": holds || undefined, "data-slot": "top-nav-menu", children: [icon, label, _jsx(ChevronDown, { "aria-hidden": true, className: "-mr-1 text-neutral-500 transition-transform duration-200 ease-out-strong group-data-popup-open:rotate-180 motion-reduce:transition-none", strokeWidth: 2 })] }), _jsx(DropdownMenuContent, { align: "start", className: "min-w-menu-wide", container: container, children: _jsx(InMenuContext.Provider, { value: true, children: children }) })] }));
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* A group of a TopNavMenu's pages under a small heading, as a sidebar group is. In the menu a
|
|
188
|
+
* group after another is ruled off by a hairline; in the drawer it is the heading over its rows.
|
|
189
|
+
*/
|
|
190
|
+
export const TopNavMenuGroup = ({ label, className, children, ...props }) => {
|
|
191
|
+
const inMenu = useContext(InMenuContext);
|
|
192
|
+
const id = useId();
|
|
193
|
+
if (!inMenu)
|
|
194
|
+
return (_jsxs("div", { className: cn('flex flex-col gap-0.5', className), ...props, children: [label && (_jsx("p", { className: "pt-2 pb-1 pl-2.5 font-normal text-neutral-600 text-xs", children: label })), children] }));
|
|
195
|
+
return (_jsxs(MenuPrimitive.Group, { "aria-labelledby": label ? id : undefined, className: cn('flex flex-col gap-1 [[data-slot=top-nav-menu-group]+&]:border-neutral-200 [[data-slot=top-nav-menu-group]+&]:border-t [[data-slot=top-nav-menu-group]+&]:pt-1', className), "data-slot": "top-nav-menu-group", ...props, children: [label && (_jsx("div", { className: "px-3 pt-1.5 pb-1 font-medium text-neutral-600 text-xxs", id: id, children: label })), children] }));
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* One page of a TopNavMenu: a menu row on the bar, the page you are on on the selected wash; a
|
|
199
|
+
* sidebar's inset row in the drawer.
|
|
200
|
+
*/
|
|
201
|
+
export const TopNavMenuItem = ({ render, active, icon, count, className, children, onClick, ...props }) => {
|
|
202
|
+
const inMenu = useContext(InMenuContext);
|
|
203
|
+
if (!inMenu)
|
|
204
|
+
return (_jsx(SidebarItem, { active: active, className: className, count: count, icon: icon, onClick: onClick, render: render, variant: "inset", ...props, children: children }));
|
|
205
|
+
return (_jsx(MenuItem, { "aria-current": active ? 'page' : undefined, className: cn('aria-[current=page]:bg-selected aria-[current=page]:text-neutral-950', className), "data-slot": "top-nav-menu-item", leading: icon, render: _jsx(MenuPrimitive.Item, { onClick: onClick, render: render }), trailing: count !== undefined ? _jsx(TopNavCount, { children: count }) : undefined, children: children }));
|
|
206
|
+
};
|
|
207
|
+
/** Pushed to the right: a search, a bell, the account's avatar and its menu. They hide on a compact shell. */
|
|
208
|
+
export const TopNavActions = ({ className, ...props }) => {
|
|
209
|
+
const { drawer } = useContext(TopNavContext);
|
|
210
|
+
return (_jsx("div", { className: cn('ml-auto flex shrink-0 items-center gap-2', drawer && '@max-shell-compact/shell:hidden', className), "data-slot": "top-nav-actions", ...props }));
|
|
211
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type ComponentProps } from 'react';
|
|
2
|
+
import { TooltipContent } from './tooltip.js';
|
|
3
|
+
export type TruncateProps = Omit<ComponentProps<'span'>, 'children'> & {
|
|
4
|
+
/** The whole text. It stays whole in the page: a screen reader reads it and a copy copies it. */
|
|
5
|
+
children: string;
|
|
6
|
+
/**
|
|
7
|
+
* Where the ellipsis goes: `end` for names and labels read from the start; `middle` for file
|
|
8
|
+
* names, paths, hashes and IDs, which are told apart by their end.
|
|
9
|
+
*/
|
|
10
|
+
at?: 'end' | 'middle';
|
|
11
|
+
/**
|
|
12
|
+
* With `at="middle"`, how many characters the end keeps. Left out, it follows the kind of
|
|
13
|
+
* string: a file's extension and last word, a path's last part, a hash's last 4.
|
|
14
|
+
*/
|
|
15
|
+
end?: number;
|
|
16
|
+
/** Shows the whole text in a tooltip on hover while it is cut; on by default. */
|
|
17
|
+
tooltip?: boolean;
|
|
18
|
+
/** Where that tooltip opens; above by default. */
|
|
19
|
+
tooltipSide?: ComponentProps<typeof TooltipContent>['side'];
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* One line of text that never wraps or grows its row: at the width it is given it cuts, at the
|
|
23
|
+
* end or in the middle, and shows the whole on hover. The cut is only drawn: the whole text stays
|
|
24
|
+
* in the page, so it is what a screen reader reads, what find-in-page finds and what a copy takes.
|
|
25
|
+
*
|
|
26
|
+
* In the middle, the end the text keeps is fixed (its extension, its last 4) and the start fills
|
|
27
|
+
* the rest of the width, so a column of names keeps their ends lined up and readable.
|
|
28
|
+
*/
|
|
29
|
+
export declare const Truncate: ({ children: text, at, end, tooltip, tooltipSide, className, style, ...props }: TruncateProps) => import("react").JSX.Element;
|