@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,94 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { ArrowLeft, ArrowRight } from 'lucide-react';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
import { cn } from '../lib/cn.js';
|
|
6
|
+
import { Button } from './button.js';
|
|
7
|
+
import { Notice, useNotice } from './notice.js';
|
|
8
|
+
import { SidebarToggle, useAppShellNav } from './sidebar.js';
|
|
9
|
+
/**
|
|
10
|
+
* The panel's top bar: breadcrumb on the left, actions on the right. Its hairline
|
|
11
|
+
* is one of the few kept: the page scrolls under it, and space can't mark that edge.
|
|
12
|
+
* It positions its notice, which hangs from that hairline.
|
|
13
|
+
*
|
|
14
|
+
* In an `AppShell` too narrow for the sidebar it starts with the toggle that opens the sidebar
|
|
15
|
+
* as a drawer, in the place of the back and forward arrows, which hide, as the actions do.
|
|
16
|
+
*/
|
|
17
|
+
export const HeaderBar = ({ sidebarToggle = true, className, children, ...props }) => {
|
|
18
|
+
const shell = useAppShellNav();
|
|
19
|
+
return (_jsxs("header", { className: cn('relative flex h-header shrink-0 items-center justify-between gap-4 border-neutral-200 border-b py-2 pr-2 pl-4',
|
|
20
|
+
// With the toggle shown first, the trail after it takes the free space, so it stays
|
|
21
|
+
// beside the toggle rather than being pushed to the far end.
|
|
22
|
+
'@max-shell-sidebar/shell:[&>[data-slot=header-bar-sidebar-toggle]+*]:mr-auto', className), "data-slot": "header-bar", ...props, children: [sidebarToggle && shell?.nav === 'side' && _jsx(HeaderBarSidebarToggle, {}), children] }));
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Opens the shell's navigation as a drawer. It is the sidebar's own toggle, the same icon in the
|
|
26
|
+
* same quiet grey, so the narrow bar reads as the wide shell with its sidebar folded away. It only
|
|
27
|
+
* shows while the shell is too narrow for its navigation (a sidebar under 1024, a top nav under
|
|
28
|
+
* 640), and renders nothing outside an `AppShell`
|
|
29
|
+
* with a drawer. The header bar starts with one of its own; put one in a bar of your own making.
|
|
30
|
+
*/
|
|
31
|
+
export const HeaderBarSidebarToggle = ({ openLabel = 'Open navigation', closeLabel = 'Close navigation', className, onClick, ...props }) => {
|
|
32
|
+
const shell = useAppShellNav();
|
|
33
|
+
if (!shell?.hasDrawer)
|
|
34
|
+
return null;
|
|
35
|
+
return (_jsx(SidebarToggle, { "aria-controls": shell.drawerId, "aria-label": shell.open ? closeLabel : openLabel,
|
|
36
|
+
// 12 to the trail, as in a bar that draws its own toggle, not the bar's 16 between its ends.
|
|
37
|
+
// A top nav's drawer comes only on a compact shell, a sidebar's under the sidebar's width.
|
|
38
|
+
className: cn('-mr-1 hidden shrink-0', shell.nav === 'top'
|
|
39
|
+
? '@max-shell-compact/shell:grid'
|
|
40
|
+
: '@max-shell-sidebar/shell:grid', className), "data-slot": "header-bar-sidebar-toggle", expanded: shell.open, onClick: event => {
|
|
41
|
+
onClick?.(event);
|
|
42
|
+
if (event.defaultPrevented)
|
|
43
|
+
return;
|
|
44
|
+
if (!shell.open)
|
|
45
|
+
shell.opener.current = event.currentTarget;
|
|
46
|
+
shell.setOpen(!shell.open);
|
|
47
|
+
}, ...props }));
|
|
48
|
+
};
|
|
49
|
+
/** The left of the bar: back and forward, then the breadcrumb; it gives way before the actions do. */
|
|
50
|
+
export const HeaderBarStart = ({ className, ...props }) => (_jsx("div", {
|
|
51
|
+
// Stretched to the bar's height, so the arrows' rule can run its full height.
|
|
52
|
+
className: cn('flex min-w-0 flex-1 items-center gap-3 self-stretch', className), "data-slot": "header-bar-start", ...props }));
|
|
53
|
+
/**
|
|
54
|
+
* Back and forward through the pages visited in the app, before the trail: the trail says where the
|
|
55
|
+
* page sits, the arrows where you came from. Ghost 28px buttons, ruled off from the trail by a
|
|
56
|
+
* hairline that runs the bar's full height, as the segments of a toolbar are.
|
|
57
|
+
* They hide on a shell too narrow for the sidebar, where the drawer's toggle takes their place.
|
|
58
|
+
*/
|
|
59
|
+
export const HeaderBarNav = ({ onBack, onForward, canGoBack = true, canGoForward = true, backLabel = 'Back', forwardLabel = 'Forward', className, ...props }) => (_jsxs("div", { className: cn(
|
|
60
|
+
/*
|
|
61
|
+
* Pulled through the bar's vertical padding, so the rule meets its top and its hairline,
|
|
62
|
+
* and through its left padding: 12px before the arrows, near the 13px the bar leaves above
|
|
63
|
+
* and below them, and 16px after, so the rule doesn't crowd them.
|
|
64
|
+
*/
|
|
65
|
+
'-my-2 -ml-4 flex @max-shell-sidebar/shell:hidden shrink-0 items-center gap-0.5 self-stretch border-neutral-200 border-r pr-4 pl-3', className), "data-slot": "header-bar-nav", ...props, children: [_jsx(Button, { "aria-label": backLabel, disabled: !canGoBack || !onBack, onClick: onBack, size: "icon-sm", variant: "ghost", children: _jsx(ArrowLeft, { strokeWidth: 2 }) }), onForward && (_jsx(Button, { "aria-label": forwardLabel, disabled: !canGoForward, onClick: onForward, size: "icon-sm", variant: "ghost", children: _jsx(ArrowRight, { strokeWidth: 2 }) }))] }));
|
|
66
|
+
/**
|
|
67
|
+
* A history for `HeaderBarNav` inside an app that keeps its own pages, not the browser's: `go` visits
|
|
68
|
+
* a page and drops anything forward of it, as a browser does. Use the router's history instead
|
|
69
|
+
* where there is one.
|
|
70
|
+
*/
|
|
71
|
+
export const usePageHistory = (initial, start = initial.length - 1) => {
|
|
72
|
+
const [state, setState] = useState({ pages: initial, index: start });
|
|
73
|
+
const page = state.pages[state.index];
|
|
74
|
+
return {
|
|
75
|
+
page,
|
|
76
|
+
canGoBack: state.index > 0,
|
|
77
|
+
canGoForward: state.index < state.pages.length - 1,
|
|
78
|
+
back: () => setState(s => ({ ...s, index: Math.max(0, s.index - 1) })),
|
|
79
|
+
forward: () => setState(s => ({ ...s, index: Math.min(s.pages.length - 1, s.index + 1) })),
|
|
80
|
+
go: (next) => setState(s => ({
|
|
81
|
+
pages: [...s.pages.slice(0, s.index + 1), next],
|
|
82
|
+
index: s.index + 1,
|
|
83
|
+
})),
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* The right of the bar: one or two actions, secondary before primary. They hide on a shell too
|
|
88
|
+
* narrow for the sidebar: the page keeps its own primary, and the bar its trail.
|
|
89
|
+
*/
|
|
90
|
+
export const HeaderBarActions = ({ className, ...props }) => (_jsx("div", { className: cn('flex @max-shell-sidebar/shell:hidden shrink-0 items-center gap-2', className), "data-slot": "header-bar-actions", ...props }));
|
|
91
|
+
/** @deprecated Moved to `Notice`, which hangs from any bar, not only the header. */
|
|
92
|
+
export const HeaderBarNotice = Notice;
|
|
93
|
+
/** @deprecated Moved to `useNotice`. */
|
|
94
|
+
export const useHeaderNotice = useNotice;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ButtonProps } from './button.js';
|
|
2
|
+
export type HoldButtonProps = Omit<ButtonProps, 'onClick' | 'render'> & {
|
|
3
|
+
/** Runs once the button has been held for `duration`. */
|
|
4
|
+
onConfirm: () => void;
|
|
5
|
+
/** How long the hold takes, in ms. */
|
|
6
|
+
duration?: number;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* A button that runs a destructive action only once it has been held: holding fills it from the
|
|
10
|
+
* start edge in the error tone over `duration` (1000ms), and the action runs when it is full.
|
|
11
|
+
* Letting go sooner drains it back and nothing happens. Space or Enter held works the same. For an
|
|
12
|
+
* action repeated in place where a dialog each time would be clicked through; its label says to
|
|
13
|
+
* hold ("Hold to remove").
|
|
14
|
+
*/
|
|
15
|
+
export declare const HoldButton: ({ onConfirm, duration, variant, className, style, disabled, onPointerDown, onPointerUp, onPointerLeave, onPointerCancel, onKeyDown, onKeyUp, onBlur, ...props }: HoldButtonProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef, useState, } from 'react';
|
|
4
|
+
import { cn } from '../lib/cn.js';
|
|
5
|
+
import { Button } from './button.js';
|
|
6
|
+
/** How long a fill that was let go of takes to drain, in ms. */
|
|
7
|
+
const DRAIN_MS = 200;
|
|
8
|
+
const isHoldKey = (key) => key === ' ' || key === 'Enter';
|
|
9
|
+
/**
|
|
10
|
+
* A button that runs a destructive action only once it has been held: holding fills it from the
|
|
11
|
+
* start edge in the error tone over `duration` (1000ms), and the action runs when it is full.
|
|
12
|
+
* Letting go sooner drains it back and nothing happens. Space or Enter held works the same. For an
|
|
13
|
+
* action repeated in place where a dialog each time would be clicked through; its label says to
|
|
14
|
+
* hold ("Hold to remove").
|
|
15
|
+
*/
|
|
16
|
+
export const HoldButton = ({ onConfirm, duration = 1000, variant = 'secondary', className, style, disabled, onPointerDown, onPointerUp, onPointerLeave, onPointerCancel, onKeyDown, onKeyUp, onBlur, ...props }) => {
|
|
17
|
+
const [holding, setHolding] = useState(false);
|
|
18
|
+
const timer = useRef(undefined);
|
|
19
|
+
// Whether a key or the pointer started this press, so a click that follows it is not mistaken
|
|
20
|
+
// for a screen reader's activation.
|
|
21
|
+
const pressed = useRef(false);
|
|
22
|
+
const confirm = useRef(onConfirm);
|
|
23
|
+
confirm.current = onConfirm;
|
|
24
|
+
const start = () => {
|
|
25
|
+
if (disabled || timer.current)
|
|
26
|
+
return;
|
|
27
|
+
pressed.current = true;
|
|
28
|
+
setHolding(true);
|
|
29
|
+
timer.current = setTimeout(() => {
|
|
30
|
+
timer.current = undefined;
|
|
31
|
+
setHolding(false);
|
|
32
|
+
confirm.current();
|
|
33
|
+
}, duration);
|
|
34
|
+
};
|
|
35
|
+
const stop = () => {
|
|
36
|
+
clearTimeout(timer.current);
|
|
37
|
+
timer.current = undefined;
|
|
38
|
+
setHolding(false);
|
|
39
|
+
};
|
|
40
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
41
|
+
return (_jsx(Button, { className: cn('relative isolate overflow-hidden',
|
|
42
|
+
// The fill: the error tone's 500 at 20%, under the label, growing from the start edge.
|
|
43
|
+
'before:absolute before:inset-0 before:-z-10 before:origin-left before:scale-x-0 before:bg-error-500/20 before:content-[""] rtl:before:origin-right', 'before:transition-[scale] before:ease-linear', holding
|
|
44
|
+
? 'text-error-700 before:scale-x-100 before:duration-(--hold-ms)'
|
|
45
|
+
: 'before:duration-(--drain-ms)', className), "data-holding": holding || undefined, "data-slot": "hold-button", disabled: disabled, onBlur: event => {
|
|
46
|
+
stop();
|
|
47
|
+
onBlur?.(event);
|
|
48
|
+
}, onClick: (event) => {
|
|
49
|
+
// A screen reader activates a button with a click and no key or pointer before it; it
|
|
50
|
+
// cannot hold, and its activation is deliberate, so it confirms at once.
|
|
51
|
+
if (event.detail === 0 && !pressed.current)
|
|
52
|
+
confirm.current();
|
|
53
|
+
pressed.current = false;
|
|
54
|
+
}, onKeyDown: (event) => {
|
|
55
|
+
if (isHoldKey(event.key)) {
|
|
56
|
+
// Enter would click on keydown; the hold decides instead.
|
|
57
|
+
event.preventDefault();
|
|
58
|
+
if (!event.repeat)
|
|
59
|
+
start();
|
|
60
|
+
}
|
|
61
|
+
onKeyDown?.(event);
|
|
62
|
+
}, onKeyUp: (event) => {
|
|
63
|
+
if (isHoldKey(event.key)) {
|
|
64
|
+
// Space clicks on keyup; held off so the release is only a release.
|
|
65
|
+
event.preventDefault();
|
|
66
|
+
stop();
|
|
67
|
+
pressed.current = false;
|
|
68
|
+
}
|
|
69
|
+
onKeyUp?.(event);
|
|
70
|
+
}, onPointerCancel: (event) => {
|
|
71
|
+
stop();
|
|
72
|
+
onPointerCancel?.(event);
|
|
73
|
+
}, onPointerDown: (event) => {
|
|
74
|
+
if (event.button === 0)
|
|
75
|
+
start();
|
|
76
|
+
onPointerDown?.(event);
|
|
77
|
+
}, onPointerLeave: (event) => {
|
|
78
|
+
stop();
|
|
79
|
+
onPointerLeave?.(event);
|
|
80
|
+
}, onPointerUp: (event) => {
|
|
81
|
+
stop();
|
|
82
|
+
onPointerUp?.(event);
|
|
83
|
+
}, style: {
|
|
84
|
+
'--hold-ms': `${duration}ms`,
|
|
85
|
+
'--drain-ms': `${DRAIN_MS}ms`,
|
|
86
|
+
...style,
|
|
87
|
+
}, variant: variant, ...props }));
|
|
88
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type VariantProps } from 'class-variance-authority';
|
|
2
|
+
import type { ComponentProps } from 'react';
|
|
3
|
+
export declare const iconTileVariants: (props?: ({
|
|
4
|
+
variant?: "filled" | "outline" | null | undefined;
|
|
5
|
+
tone?: "primary" | "neutral" | "success" | "warning" | "error" | null | undefined;
|
|
6
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
|
+
export type IconTileProps = ComponentProps<'span'> & VariantProps<typeof iconTileVariants>;
|
|
8
|
+
/**
|
|
9
|
+
* Square icon well: filled beside the report generator's option rows, outlined
|
|
10
|
+
* in the invoice sheet's status history.
|
|
11
|
+
*/
|
|
12
|
+
export declare const IconTile: ({ variant, tone, className, ...props }: IconTileProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cva } from 'class-variance-authority';
|
|
3
|
+
import { cn } from '../lib/cn.js';
|
|
4
|
+
export const iconTileVariants = cva('inline-flex size-8 shrink-0 items-center justify-center rounded-chip border border-neutral-200 [&_svg:not([class*=size-])]:size-4 [&_svg]:shrink-0', {
|
|
5
|
+
variants: {
|
|
6
|
+
variant: {
|
|
7
|
+
filled: 'bg-neutral-100',
|
|
8
|
+
outline: '',
|
|
9
|
+
},
|
|
10
|
+
// A glyph needs 3:1 on the tile: a ramp's 600, or 700 for the pale green and amber and for the
|
|
11
|
+
// theme's accent, which may be pale; dots and fills take 500.
|
|
12
|
+
tone: {
|
|
13
|
+
neutral: 'text-neutral-600',
|
|
14
|
+
success: 'text-success-700',
|
|
15
|
+
warning: 'text-warning-700',
|
|
16
|
+
error: 'text-error-600',
|
|
17
|
+
primary: 'text-primary-700',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
defaultVariants: {
|
|
21
|
+
variant: 'filled',
|
|
22
|
+
tone: 'neutral',
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* Square icon well: filled beside the report generator's option rows, outlined
|
|
27
|
+
* in the invoice sheet's status history.
|
|
28
|
+
*/
|
|
29
|
+
export const IconTile = ({ variant, tone, className, ...props }) => (_jsx("span", { className: cn(iconTileVariants({ variant, tone }), className), "data-slot": "icon-tile", "data-tone": tone ?? 'neutral', ...props }));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ComponentProps, type ReactNode } from 'react';
|
|
2
|
+
import { Popover, PopoverContent } from './popover.js';
|
|
3
|
+
export type InfoTipProps = Omit<ComponentProps<'button'>, 'children' | 'content'> & Pick<ComponentProps<typeof Popover>, 'open' | 'defaultOpen' | 'onOpenChange'> & Pick<ComponentProps<typeof PopoverContent>, 'side' | 'align' | 'container'> & {
|
|
4
|
+
/** What the tip explains. */
|
|
5
|
+
content: ReactNode;
|
|
6
|
+
/** The button's accessible name. */
|
|
7
|
+
label?: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* A ghost 16px info icon beside a section title that explains it on hover, focus and tap.
|
|
11
|
+
* Open state can be controlled with `open` and `onOpenChange`.
|
|
12
|
+
*/
|
|
13
|
+
export declare const InfoTip: ({ content, label, open, defaultOpen, onOpenChange, side, align, container, className, type, "aria-describedby": describedBy, ...props }: InfoTipProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Info } from 'lucide-react';
|
|
4
|
+
import { useId } from 'react';
|
|
5
|
+
import { cn } from '../lib/cn.js';
|
|
6
|
+
import { focusRing } from './button.js';
|
|
7
|
+
import { Popover, PopoverContent, PopoverTrigger } from './popover.js';
|
|
8
|
+
/**
|
|
9
|
+
* A ghost 16px info icon beside a section title that explains it on hover, focus and tap.
|
|
10
|
+
* Open state can be controlled with `open` and `onOpenChange`.
|
|
11
|
+
*/
|
|
12
|
+
export const InfoTip = ({ content, label = 'More information', open, defaultOpen, onOpenChange, side = 'top', align = 'center', container, className, type = 'button', 'aria-describedby': describedBy, ...props }) => {
|
|
13
|
+
const contentId = useId();
|
|
14
|
+
return (
|
|
15
|
+
/*
|
|
16
|
+
* A popover that also opens on hover rather than a tooltip: Base UI turns tooltips off on touch,
|
|
17
|
+
* which would leave the explanation out of reach on a phone. A tap opens this one.
|
|
18
|
+
*/
|
|
19
|
+
_jsxs(Popover, { defaultOpen: defaultOpen, onOpenChange: onOpenChange, open: open, children: [_jsx(PopoverTrigger, { delay: 300, openOnHover: true, render: _jsx("button", { "aria-describedby": [describedBy, contentId].filter(Boolean).join(' '), "aria-label": label, className: cn('relative inline-flex size-4 shrink-0 cursor-help items-center justify-center rounded-full text-neutral-500 transition-[color] duration-150 hover:text-neutral-800 data-popup-open:text-neutral-800',
|
|
20
|
+
// A 16px icon is too small to hit; the invisible 24px ring around it is the target.
|
|
21
|
+
'after:absolute after:-inset-1 after:content-[""]', focusRing, className), "data-slot": "info-tip", type: type, ...props }), children: _jsx(Info, { "aria-hidden": true, className: "size-4", strokeWidth: 2 }) }), _jsx("span", { className: "sr-only", "data-slot": "info-tip-description", id: contentId, children: content }), _jsx(PopoverContent, { align: align, "aria-label": label,
|
|
22
|
+
// A short explanation, not a panel of controls: sized to its text, with the item corner.
|
|
23
|
+
className: "w-auto max-w-tooltip gap-0 text-balance rounded-item px-2.5 py-1.5 text-neutral-700 text-xs", container: container, "data-slot": "info-tip-content",
|
|
24
|
+
// Focus stays on the icon, so tabbing on after a tap carries on through the page.
|
|
25
|
+
finalFocus: false, initialFocus: false, side: side, sideOffset: 6, children: content })] }));
|
|
26
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type VariantProps } from 'class-variance-authority';
|
|
2
|
+
import type { ComponentProps, ReactNode } from 'react';
|
|
3
|
+
export declare const inputVariants: (props?: ({
|
|
4
|
+
size?: "sm" | "md" | null | undefined;
|
|
5
|
+
variant?: "plain" | "outline" | null | undefined;
|
|
6
|
+
invalid?: boolean | null | undefined;
|
|
7
|
+
disabled?: boolean | null | undefined;
|
|
8
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
9
|
+
export declare const inputTextClass: string[];
|
|
10
|
+
export type InputProps = Omit<ComponentProps<'input'>, 'size'> & Omit<VariantProps<typeof inputVariants>, 'invalid' | 'disabled'> & {
|
|
11
|
+
leadingIcon?: ReactNode;
|
|
12
|
+
trailing?: ReactNode;
|
|
13
|
+
/** Classes for the native input; `className` goes on the bordered box. */
|
|
14
|
+
inputClassName?: string;
|
|
15
|
+
};
|
|
16
|
+
/** Inputs from the library ("input small/medium") and the report-generator forms. */
|
|
17
|
+
export declare const Input: ({ size, variant, leadingIcon, trailing, className, inputClassName, id, disabled, "aria-describedby": describedBy, "aria-invalid": ariaInvalid, ...props }: InputProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cva } from 'class-variance-authority';
|
|
4
|
+
import { cn } from '../lib/cn.js';
|
|
5
|
+
import { useFieldControl } from './field.js';
|
|
6
|
+
/*
|
|
7
|
+
* The wrapper carries the border so icons sit inside the box; the native input
|
|
8
|
+
* is borderless and the wrapper shows the focus ring when it is focused.
|
|
9
|
+
*/
|
|
10
|
+
export const inputVariants = cva([
|
|
11
|
+
'group/input flex w-full min-w-0 items-center gap-2 border transition-[border-color,background-color] duration-150',
|
|
12
|
+
'has-[input:focus-visible]:outline-2 has-[input:focus-visible]:outline-focus has-[input:focus-visible]:outline-offset-2',
|
|
13
|
+
'[&_svg:not([class*=size-])]:size-icon [&_svg]:shrink-0',
|
|
14
|
+
], {
|
|
15
|
+
variants: {
|
|
16
|
+
size: {
|
|
17
|
+
// The control row (level with a button) and the field row (level with a large one).
|
|
18
|
+
sm: 'h-control rounded-control px-3',
|
|
19
|
+
md: 'h-control-lg rounded-control px-3 [--spacing-icon:var(--spacing-icon-lg)]',
|
|
20
|
+
},
|
|
21
|
+
variant: {
|
|
22
|
+
outline: 'bg-control shadow-control',
|
|
23
|
+
/*
|
|
24
|
+
* No box: the search inside a container (a table's bar, a menu) is an icon and the
|
|
25
|
+
* text. It keeps the shared ring round where the box would be, so a keyboard still
|
|
26
|
+
* sees where it is.
|
|
27
|
+
*/
|
|
28
|
+
plain: 'border-transparent px-0',
|
|
29
|
+
},
|
|
30
|
+
invalid: {
|
|
31
|
+
true: 'border-error-500 [&_svg]:text-error-500',
|
|
32
|
+
false: '',
|
|
33
|
+
},
|
|
34
|
+
disabled: {
|
|
35
|
+
// As every control: the whole box at half strength, its colours and border kept.
|
|
36
|
+
true: 'cursor-not-allowed opacity-50',
|
|
37
|
+
false: '',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
compoundVariants: [
|
|
41
|
+
{
|
|
42
|
+
variant: 'outline',
|
|
43
|
+
invalid: false,
|
|
44
|
+
disabled: false,
|
|
45
|
+
className: 'border-neutral-200 hover:border-neutral-300 hover:bg-control-hover has-[input:focus]:border-neutral-300 [&_svg]:text-neutral-600',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
variant: 'outline',
|
|
49
|
+
invalid: false,
|
|
50
|
+
disabled: true,
|
|
51
|
+
className: 'border-neutral-200 [&_svg]:text-neutral-600',
|
|
52
|
+
},
|
|
53
|
+
{ variant: 'plain', invalid: false, className: '[&_svg]:text-neutral-600' },
|
|
54
|
+
],
|
|
55
|
+
defaultVariants: {
|
|
56
|
+
size: 'md',
|
|
57
|
+
variant: 'outline',
|
|
58
|
+
invalid: false,
|
|
59
|
+
disabled: false,
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
/*
|
|
63
|
+
* Value and placeholder colours shared with Textarea. The library's "selected"
|
|
64
|
+
* state is the value in neutral-900. Disabled keeps these colours: the box around
|
|
65
|
+
* them is dimmed to half strength, as every disabled control is. On a touch screen the text is
|
|
66
|
+
* 16px: anything smaller and iOS zooms the page in when the field takes focus.
|
|
67
|
+
*/
|
|
68
|
+
export const inputTextClass = [
|
|
69
|
+
'font-medium text-neutral-900 text-xs placeholder:text-neutral-600 pointer-coarse:text-base',
|
|
70
|
+
'aria-invalid:placeholder:text-error-300',
|
|
71
|
+
'disabled:cursor-not-allowed',
|
|
72
|
+
];
|
|
73
|
+
/** Inputs from the library ("input small/medium") and the report-generator forms. */
|
|
74
|
+
export const Input = ({ size, variant, leadingIcon, trailing, className, inputClassName, id, disabled, 'aria-describedby': describedBy, 'aria-invalid': ariaInvalid, ...props }) => {
|
|
75
|
+
const { invalid, ...control } = useFieldControl({
|
|
76
|
+
id,
|
|
77
|
+
disabled,
|
|
78
|
+
'aria-describedby': describedBy,
|
|
79
|
+
'aria-invalid': ariaInvalid,
|
|
80
|
+
});
|
|
81
|
+
const isDisabled = Boolean(control.disabled);
|
|
82
|
+
return (_jsxs("div", { className: cn(inputVariants({ size, variant, invalid, disabled: isDisabled }), className), "data-disabled": isDisabled || undefined, "data-invalid": invalid || undefined, "data-slot": "input", children: [leadingIcon, _jsx("input", { className: cn('h-full min-w-0 flex-1 bg-transparent outline-none', inputTextClass, !invalid && !isDisabled && 'group-hover/input:placeholder:text-neutral-700', inputClassName), "data-slot": "input-control", ...control, ...props }), trailing] }));
|
|
83
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Keyboard shortcut key from the sidebar menu item and the report editor's sidebar. A touch screen
|
|
4
|
+
* has no keys to press, so on a coarse pointer the hint is not drawn.
|
|
5
|
+
*/
|
|
6
|
+
export declare const Kbd: ({ className, ...props }: ComponentProps<"kbd">) => import("react").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from '../lib/cn.js';
|
|
3
|
+
/**
|
|
4
|
+
* Keyboard shortcut key from the sidebar menu item and the report editor's sidebar. A touch screen
|
|
5
|
+
* has no keys to press, so on a coarse pointer the hint is not drawn.
|
|
6
|
+
*/
|
|
7
|
+
export const Kbd = ({ className, ...props }) => (_jsx("kbd", { className: cn('inline-flex pointer-coarse:hidden h-5.5 min-w-5.5 shrink-0 items-center justify-center rounded-chip border border-neutral-300 px-1 font-medium font-sans text-neutral-700 text-xxs', className), "data-slot": "kbd", ...props }));
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
2
|
+
import { type VariantProps } from 'class-variance-authority';
|
|
3
|
+
import { type ComponentProps, type ReactNode } from 'react';
|
|
4
|
+
export declare const menuItemVariants: (props?: ({
|
|
5
|
+
variant?: "default" | "danger" | null | undefined;
|
|
6
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
|
+
declare const leads: {
|
|
8
|
+
readonly sm: "";
|
|
9
|
+
readonly md: "h-auto min-h-option-md gap-3 px-3 py-1.5";
|
|
10
|
+
readonly lg: "h-auto min-h-option-lg gap-3 px-3 py-1.5";
|
|
11
|
+
};
|
|
12
|
+
export type MenuItemLead = keyof typeof leads;
|
|
13
|
+
export type MenuItemProps = Omit<ComponentProps<'div'>, 'children'> & VariantProps<typeof menuItemVariants> & {
|
|
14
|
+
/** The list's own item, which keeps its behaviour: `render={<SelectPrimitive.Item value="a" />}`. */
|
|
15
|
+
render?: useRender.RenderProp;
|
|
16
|
+
/**
|
|
17
|
+
* Before the name: a 16px icon, an `Avatar`, a `MenuItemIndicator` (checkbox or radio),
|
|
18
|
+
* a chip. The row spaces itself to what leads it (see `lead`).
|
|
19
|
+
*/
|
|
20
|
+
leading?: ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* The row's spacing tier, from the size of what leads it. Worked out from an `Avatar` or a
|
|
23
|
+
* `Badge` in `leading`; set it for anything else of 24px (`md`) or 32px and up (`lg`).
|
|
24
|
+
*/
|
|
25
|
+
lead?: MenuItemLead;
|
|
26
|
+
/** Inline after the name: badges, chips, a label, a short muted note ("you"). */
|
|
27
|
+
meta?: ReactNode;
|
|
28
|
+
/** A second, quieter line under the name; the row grows to fit it. */
|
|
29
|
+
description?: ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* After everything, at the far end: a check, a `MenuItemShortcut`, a count, a badge, an
|
|
32
|
+
* icon, a chevron to a submenu. More than one sits 8px apart.
|
|
33
|
+
*/
|
|
34
|
+
trailing?: ReactNode;
|
|
35
|
+
/** The name. */
|
|
36
|
+
children?: ReactNode;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* A popup list's row. Each list renders its own Base UI item through it, so the highlight,
|
|
40
|
+
* selection and keyboard come from Base UI and the look from here. Its anatomy:
|
|
41
|
+
*
|
|
42
|
+
* [leading] name [meta] [trailing]
|
|
43
|
+
* description
|
|
44
|
+
*/
|
|
45
|
+
export declare const MenuItem: ({ render, variant, leading, lead, meta, description, trailing, className, children, ...props }: MenuItemProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
46
|
+
export type MenuItemIndicatorProps = Omit<ComponentProps<'span'>, 'children'> & {
|
|
47
|
+
kind?: 'checkbox' | 'radio';
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* A checkbox or radio drawn small at the head of a row. It reads the row's own state, checked in a
|
|
51
|
+
* menu, selected in a select, so it needs no props of its own to follow along.
|
|
52
|
+
*/
|
|
53
|
+
export declare const MenuItemIndicator: ({ kind, className, ...props }: MenuItemIndicatorProps) => import("react").JSX.Element;
|
|
54
|
+
/** A shortcut at the end of a row, muted: "⌘D", "G I". Not drawn on a touch screen, which has no keys. */
|
|
55
|
+
export declare const MenuItemShortcut: ({ className, ...props }: ComponentProps<"span">) => import("react").JSX.Element;
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
4
|
+
import { cva } from 'class-variance-authority';
|
|
5
|
+
import { Check } from 'lucide-react';
|
|
6
|
+
import { Children, Fragment, isValidElement } from 'react';
|
|
7
|
+
import { cn } from '../lib/cn.js';
|
|
8
|
+
import { Avatar } from './avatar.js';
|
|
9
|
+
import { Badge } from './badge.js';
|
|
10
|
+
/*
|
|
11
|
+
* The row every popup list is made of: a select's options, a combobox's, a menu's actions, a filter
|
|
12
|
+
* menu's values, the command menu's commands. 36px, padded the same on both sides so the label and
|
|
13
|
+
* a trailing check sit evenly, and cornered one step inside the panel round it: the panel's
|
|
14
|
+
* `rounded-card` (16) less its 4px padding and 1px border, within a pixel of `rounded-item` (10), the
|
|
15
|
+
* corner every item takes, so the curves stay concentric and the item matches a nav item.
|
|
16
|
+
*/
|
|
17
|
+
export const menuItemVariants = cva([
|
|
18
|
+
'relative flex h-option shrink-0 cursor-pointer select-none items-center gap-2 rounded-item px-3 py-2 font-medium text-xs outline-none',
|
|
19
|
+
'data-disabled:pointer-events-none data-disabled:opacity-50',
|
|
20
|
+
'[&_svg:not([class*=size-])]:size-icon [&_svg]:shrink-0',
|
|
21
|
+
], {
|
|
22
|
+
variants: {
|
|
23
|
+
variant: {
|
|
24
|
+
default: [
|
|
25
|
+
'text-neutral-700 [&_svg]:text-neutral-600',
|
|
26
|
+
'data-highlighted:bg-neutral-950/5 data-highlighted:text-neutral-800',
|
|
27
|
+
// The picked option in a select or combobox, the checked one in a radio group.
|
|
28
|
+
'data-selected:bg-selected data-selected:text-neutral-950',
|
|
29
|
+
],
|
|
30
|
+
danger: 'text-error-600 data-highlighted:bg-neutral-950/5 [&_svg]:text-current',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
defaultVariants: { variant: 'default' },
|
|
34
|
+
});
|
|
35
|
+
/*
|
|
36
|
+
* The leading element sets the row's rhythm: the row grows with its size, so an avatar sits in its
|
|
37
|
+
* own square of space as a 16px icon does. Each tier is a height token (44 and 56 as drawn), so the
|
|
38
|
+
* rows follow a theme's height scale as the plain 36px row does; a minimum, so larger type still fits.
|
|
39
|
+
*/
|
|
40
|
+
const leads = {
|
|
41
|
+
// A 16px icon, checkbox or radio: the 36px row as it is.
|
|
42
|
+
sm: '',
|
|
43
|
+
// A 24px avatar or a chip.
|
|
44
|
+
md: 'h-auto min-h-option-md gap-3 px-3 py-1.5',
|
|
45
|
+
// A 32 or 36px avatar.
|
|
46
|
+
lg: 'h-auto min-h-option-lg gap-3 px-3 py-1.5',
|
|
47
|
+
};
|
|
48
|
+
/** The tier of what leads the row, read from the elements it knows: an avatar by its size, a badge as a chip. */
|
|
49
|
+
const leadOf = (leading) => {
|
|
50
|
+
let size = 16;
|
|
51
|
+
const visit = (node) => Children.forEach(node, child => {
|
|
52
|
+
if (!isValidElement(child))
|
|
53
|
+
return;
|
|
54
|
+
if (child.type === Fragment)
|
|
55
|
+
visit(child.props.children);
|
|
56
|
+
else if (child.type === Avatar)
|
|
57
|
+
size = Math.max(size, Number(child.props.size ?? 32));
|
|
58
|
+
else if (child.type === Badge)
|
|
59
|
+
size = Math.max(size, 24);
|
|
60
|
+
});
|
|
61
|
+
visit(leading);
|
|
62
|
+
return size >= 32 ? 'lg' : size >= 22 ? 'md' : 'sm';
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* A popup list's row. Each list renders its own Base UI item through it, so the highlight,
|
|
66
|
+
* selection and keyboard come from Base UI and the look from here. Its anatomy:
|
|
67
|
+
*
|
|
68
|
+
* [leading] name [meta] [trailing]
|
|
69
|
+
* description
|
|
70
|
+
*/
|
|
71
|
+
export const MenuItem = ({ render, variant, leading, lead = leadOf(leading), meta, description, trailing, className, children, ...props }) => useRender({
|
|
72
|
+
defaultTagName: 'div',
|
|
73
|
+
render,
|
|
74
|
+
props: {
|
|
75
|
+
className: cn('group/menu-item', menuItemVariants({ variant }),
|
|
76
|
+
// Two lines: the row grows past 36px and keeps the same space above and below.
|
|
77
|
+
description !== undefined && 'h-auto min-h-option py-2.5', leads[lead],
|
|
78
|
+
// Beside an avatar or a chip one line of text sits closer; two lines keep the wider gap.
|
|
79
|
+
description === undefined && lead !== 'sm' && 'gap-2.5', className),
|
|
80
|
+
'data-lead': lead,
|
|
81
|
+
'data-slot': 'menu-item',
|
|
82
|
+
...props,
|
|
83
|
+
children: (_jsxs(_Fragment, { children: [leading, _jsxs("span", { className: "flex min-w-0 flex-1 flex-col", children: [_jsxs("span", { className: "flex min-w-0 items-center gap-1.5", children: [_jsx("span", { className: "min-w-0 truncate", children: children }), meta && (_jsx("span", { className: "flex shrink-0 items-center gap-1 font-normal text-neutral-600", "data-slot": "menu-item-meta", children: meta }))] }), description !== undefined && (_jsx("span", { className: "truncate font-normal text-neutral-600 text-xxs", "data-slot": "menu-item-description", children: description }))] }), trailing && (_jsx("span", { className: "ml-auto flex shrink-0 items-center gap-2 pl-2 font-normal text-neutral-600 text-xxs", "data-slot": "menu-item-trailing", children: trailing }))] })),
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
/**
|
|
87
|
+
* A checkbox or radio drawn small at the head of a row. It reads the row's own state, checked in a
|
|
88
|
+
* menu, selected in a select, so it needs no props of its own to follow along.
|
|
89
|
+
*/
|
|
90
|
+
export const MenuItemIndicator = ({ kind = 'checkbox', className, ...props }) => (_jsx("span", { className: cn('inline-flex size-4 shrink-0 items-center justify-center border border-neutral-300 text-on-action transition-[background-color,border-color] duration-150', kind === 'radio' ? 'rounded-full' : 'rounded-[calc(var(--radius-chip)-2px)]', 'group-data-checked/menu-item:border-transparent group-data-checked/menu-item:bg-action group-data-checked/menu-item:[background-image:var(--action-gradient)]', 'group-data-selected/menu-item:border-transparent group-data-selected/menu-item:bg-action group-data-selected/menu-item:[background-image:var(--action-gradient)]',
|
|
91
|
+
// The row greys its icons; the mark keeps the action's foreground.
|
|
92
|
+
'[&_svg]:text-on-action!', className), "data-kind": kind, "data-slot": "menu-item-indicator", ...props, children: _jsx("span", { className: "flex opacity-0 transition-opacity duration-150 group-data-checked/menu-item:opacity-100 group-data-selected/menu-item:opacity-100", children: kind === 'radio' ? (_jsx("span", { className: "size-1.5 rounded-full bg-current" })) : (_jsx(Check, { className: "size-3", strokeWidth: 2 })) }) }));
|
|
93
|
+
/** A shortcut at the end of a row, muted: "⌘D", "G I". Not drawn on a touch screen, which has no keys. */
|
|
94
|
+
export const MenuItemShortcut = ({ className, ...props }) => (_jsx("span", { className: cn('pointer-coarse:hidden font-medium text-neutral-600 text-xxs', className), "data-slot": "menu-item-shortcut", ...props }));
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { type ComponentProps, type ReactNode, type Ref } from 'react';
|
|
2
|
+
import { type DropdownMenuItemProps } from './dropdown-menu.js';
|
|
3
|
+
/**
|
|
4
|
+
* The "Add attachments" row of an `attachMenu`, in `MessageComposer` or `AssistantPrompt`: a paperclip and
|
|
5
|
+
* the label, opening that part's own file picker, so the files arrive through `onAttach` as they do
|
|
6
|
+
* without a menu. It needs `onAttach` on the part round it.
|
|
7
|
+
*/
|
|
8
|
+
export declare const MessageComposerAttachItem: ({ children, onClick, ...props }: DropdownMenuItemProps) => import("react").JSX.Element;
|
|
9
|
+
export type MessageComposerProps = Omit<ComponentProps<'form'>, 'onSubmit' | 'children'> & {
|
|
10
|
+
/** Controlled draft. */
|
|
11
|
+
value?: string;
|
|
12
|
+
defaultValue?: string;
|
|
13
|
+
onValueChange?: (value: string) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Called with the trimmed draft on Enter or the send button. The draft clears afterwards
|
|
16
|
+
* unless this returns `false`, e.g. when the message could not be queued. With attachments
|
|
17
|
+
* waiting, it is called even for an empty draft.
|
|
18
|
+
*/
|
|
19
|
+
onSend?: (text: string) => unknown;
|
|
20
|
+
/**
|
|
21
|
+
* Draws the leading attach button, which opens the file picker and calls this with the files
|
|
22
|
+
* chosen. Show them in `attachments`. The same prop, meaning the same, as on `AssistantPrompt`.
|
|
23
|
+
*/
|
|
24
|
+
onAttach?: (files: File[]) => void;
|
|
25
|
+
/** The picker's file types, as the input's `accept`: "image/*,.pdf". */
|
|
26
|
+
accept?: string;
|
|
27
|
+
/** Draws the leading attach button and calls this instead of opening the picker. */
|
|
28
|
+
onAdd?: () => void;
|
|
29
|
+
/**
|
|
30
|
+
* Makes the attach button open a menu above it of what can go with a message: `DropdownMenuItem`s
|
|
31
|
+
* with a 16 icon, and `MessageComposerAttachItem` for files (it opens the picker; needs `onAttach`).
|
|
32
|
+
*/
|
|
33
|
+
attachMenu?: ReactNode;
|
|
34
|
+
/** Replaces the attach button entirely, as `attach` does on `AssistantPrompt`. */
|
|
35
|
+
attach?: ReactNode;
|
|
36
|
+
/** @deprecated Use `attach`; `start` is the foot's left slot on `AssistantPrompt`. */
|
|
37
|
+
start?: ReactNode;
|
|
38
|
+
/**
|
|
39
|
+
* What waits to go: a `ChatAttachments` row of `ChatAttachment`s (files, images, linked
|
|
40
|
+
* records), each with `onRemove`. It sits in a row 8 above the box, never inside it.
|
|
41
|
+
*/
|
|
42
|
+
attachments?: ReactNode;
|
|
43
|
+
/**
|
|
44
|
+
* Who else is typing: a `ChatTyping`, in a row above everything else. Passed, the row's height
|
|
45
|
+
* is kept whether anyone types or not, so the box never moves when they start.
|
|
46
|
+
*/
|
|
47
|
+
typing?: ReactNode;
|
|
48
|
+
/**
|
|
49
|
+
* A `ChatSuggestions` panel, shown just above the box over whatever is there while it is passed:
|
|
50
|
+
* the records a "#" or "@" being typed could mean (see `useChatTrigger`). While it shows, the
|
|
51
|
+
* arrows move through its rows, Enter and Tab pick, and Escape calls `onSuggestionsClose`.
|
|
52
|
+
*/
|
|
53
|
+
suggestions?: ReactNode;
|
|
54
|
+
/** Escape, or the text losing focus, while `suggestions` show: stop passing them. */
|
|
55
|
+
onSuggestionsClose?: () => void;
|
|
56
|
+
placeholder?: string;
|
|
57
|
+
disabled?: boolean;
|
|
58
|
+
/** Accessible name of the text box. */
|
|
59
|
+
label?: string;
|
|
60
|
+
/** Accessible names of the attach and send buttons. */
|
|
61
|
+
attachLabel?: string;
|
|
62
|
+
/** @deprecated Use `attachLabel`. */
|
|
63
|
+
addLabel?: string;
|
|
64
|
+
sendLabel?: string;
|
|
65
|
+
name?: string;
|
|
66
|
+
maxLength?: number;
|
|
67
|
+
textareaRef?: Ref<HTMLTextAreaElement>;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Where the current user writes: an attach button filled in the action colour, a text box that
|
|
71
|
+
* grows with the draft and a quiet send arrow that wakes once there is something to send. Enter
|
|
72
|
+
* sends; Shift+Enter starts a new line. Above the box, from the top: who else is typing, then what
|
|
73
|
+
* waits to go with the message; suggestions for a reference being typed float just over the box.
|
|
74
|
+
*/
|
|
75
|
+
export declare const MessageComposer: ({ value: valueProp, defaultValue, onValueChange, onSend, onAttach, accept, onAdd, attachMenu, attach: attachSlot, start, attachments, typing, suggestions, onSuggestionsClose, placeholder, disabled, label, attachLabel, addLabel, sendLabel, name, maxLength, textareaRef, className, ...props }: MessageComposerProps) => import("react").JSX.Element;
|