@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,220 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { ArrowLeft, ArrowRight } from 'lucide-react';
|
|
4
|
+
import { type ComponentProps, useState } from 'react';
|
|
5
|
+
import { cn } from '../lib/cn';
|
|
6
|
+
import { Button } from './button';
|
|
7
|
+
import { Notice, type NoticeProps, useNotice } from './notice';
|
|
8
|
+
import { SidebarToggle, useAppShellNav } from './sidebar';
|
|
9
|
+
|
|
10
|
+
type HeaderBarProps = ComponentProps<'header'> & {
|
|
11
|
+
/**
|
|
12
|
+
* Whether the bar starts with the toggle that opens the shell's sidebar as a drawer, when the
|
|
13
|
+
* shell is too narrow for it. On by default; a bar with a toggle of its own turns it off.
|
|
14
|
+
*/
|
|
15
|
+
sidebarToggle?: boolean;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The panel's top bar: breadcrumb on the left, actions on the right. Its hairline
|
|
20
|
+
* is one of the few kept: the page scrolls under it, and space can't mark that edge.
|
|
21
|
+
* It positions its notice, which hangs from that hairline.
|
|
22
|
+
*
|
|
23
|
+
* In an `AppShell` too narrow for the sidebar it starts with the toggle that opens the sidebar
|
|
24
|
+
* as a drawer, in the place of the back and forward arrows, which hide, as the actions do.
|
|
25
|
+
*/
|
|
26
|
+
export const HeaderBar = ({
|
|
27
|
+
sidebarToggle = true,
|
|
28
|
+
className,
|
|
29
|
+
children,
|
|
30
|
+
...props
|
|
31
|
+
}: HeaderBarProps) => {
|
|
32
|
+
const shell = useAppShellNav();
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<header
|
|
36
|
+
className={cn(
|
|
37
|
+
'relative flex h-header shrink-0 items-center justify-between gap-4 border-neutral-200 border-b py-2 pr-2 pl-4',
|
|
38
|
+
// With the toggle shown first, the trail after it takes the free space, so it stays
|
|
39
|
+
// beside the toggle rather than being pushed to the far end.
|
|
40
|
+
'@max-shell-sidebar/shell:[&>[data-slot=header-bar-sidebar-toggle]+*]:mr-auto',
|
|
41
|
+
className,
|
|
42
|
+
)}
|
|
43
|
+
data-slot="header-bar"
|
|
44
|
+
{...props}
|
|
45
|
+
>
|
|
46
|
+
{/* A shell with a top nav keeps its toggle there. */}
|
|
47
|
+
{sidebarToggle && shell?.nav === 'side' && <HeaderBarSidebarToggle />}
|
|
48
|
+
{children}
|
|
49
|
+
</header>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
type HeaderBarSidebarToggleProps = Omit<ComponentProps<'button'>, 'children'> & {
|
|
54
|
+
/** Its names for screen readers while the drawer is closed and while it is open. */
|
|
55
|
+
openLabel?: string;
|
|
56
|
+
closeLabel?: string;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Opens the shell's navigation as a drawer. It is the sidebar's own toggle, the same icon in the
|
|
61
|
+
* same quiet grey, so the narrow bar reads as the wide shell with its sidebar folded away. It only
|
|
62
|
+
* shows while the shell is too narrow for its navigation (a sidebar under 1024, a top nav under
|
|
63
|
+
* 640), and renders nothing outside an `AppShell`
|
|
64
|
+
* with a drawer. The header bar starts with one of its own; put one in a bar of your own making.
|
|
65
|
+
*/
|
|
66
|
+
export const HeaderBarSidebarToggle = ({
|
|
67
|
+
openLabel = 'Open navigation',
|
|
68
|
+
closeLabel = 'Close navigation',
|
|
69
|
+
className,
|
|
70
|
+
onClick,
|
|
71
|
+
...props
|
|
72
|
+
}: HeaderBarSidebarToggleProps) => {
|
|
73
|
+
const shell = useAppShellNav();
|
|
74
|
+
if (!shell?.hasDrawer) return null;
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<SidebarToggle
|
|
78
|
+
aria-controls={shell.drawerId}
|
|
79
|
+
aria-label={shell.open ? closeLabel : openLabel}
|
|
80
|
+
// 12 to the trail, as in a bar that draws its own toggle, not the bar's 16 between its ends.
|
|
81
|
+
// A top nav's drawer comes only on a compact shell, a sidebar's under the sidebar's width.
|
|
82
|
+
className={cn(
|
|
83
|
+
'-mr-1 hidden shrink-0',
|
|
84
|
+
shell.nav === 'top'
|
|
85
|
+
? '@max-shell-compact/shell:grid'
|
|
86
|
+
: '@max-shell-sidebar/shell:grid',
|
|
87
|
+
className,
|
|
88
|
+
)}
|
|
89
|
+
data-slot="header-bar-sidebar-toggle"
|
|
90
|
+
expanded={shell.open}
|
|
91
|
+
onClick={event => {
|
|
92
|
+
onClick?.(event);
|
|
93
|
+
if (event.defaultPrevented) return;
|
|
94
|
+
if (!shell.open) shell.opener.current = event.currentTarget;
|
|
95
|
+
shell.setOpen(!shell.open);
|
|
96
|
+
}}
|
|
97
|
+
{...props}
|
|
98
|
+
/>
|
|
99
|
+
);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/** The left of the bar: back and forward, then the breadcrumb; it gives way before the actions do. */
|
|
103
|
+
export const HeaderBarStart = ({ className, ...props }: ComponentProps<'div'>) => (
|
|
104
|
+
<div
|
|
105
|
+
// Stretched to the bar's height, so the arrows' rule can run its full height.
|
|
106
|
+
className={cn('flex min-w-0 flex-1 items-center gap-3 self-stretch', className)}
|
|
107
|
+
data-slot="header-bar-start"
|
|
108
|
+
{...props}
|
|
109
|
+
/>
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
export type HeaderBarNavProps = Omit<ComponentProps<'div'>, 'children'> & {
|
|
113
|
+
onBack?: () => void;
|
|
114
|
+
/** Leave it out for a back button alone, as a detail page that returns to its list has. */
|
|
115
|
+
onForward?: () => void;
|
|
116
|
+
/** Whether there is somewhere to go; the arrow dims without it, or without its handler. */
|
|
117
|
+
canGoBack?: boolean;
|
|
118
|
+
canGoForward?: boolean;
|
|
119
|
+
/** The arrows' names for screen readers. */
|
|
120
|
+
backLabel?: string;
|
|
121
|
+
forwardLabel?: string;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Back and forward through the pages visited in the app, before the trail: the trail says where the
|
|
126
|
+
* page sits, the arrows where you came from. Ghost 28px buttons, ruled off from the trail by a
|
|
127
|
+
* hairline that runs the bar's full height, as the segments of a toolbar are.
|
|
128
|
+
* They hide on a shell too narrow for the sidebar, where the drawer's toggle takes their place.
|
|
129
|
+
*/
|
|
130
|
+
export const HeaderBarNav = ({
|
|
131
|
+
onBack,
|
|
132
|
+
onForward,
|
|
133
|
+
canGoBack = true,
|
|
134
|
+
canGoForward = true,
|
|
135
|
+
backLabel = 'Back',
|
|
136
|
+
forwardLabel = 'Forward',
|
|
137
|
+
className,
|
|
138
|
+
...props
|
|
139
|
+
}: HeaderBarNavProps) => (
|
|
140
|
+
<div
|
|
141
|
+
className={cn(
|
|
142
|
+
/*
|
|
143
|
+
* Pulled through the bar's vertical padding, so the rule meets its top and its hairline,
|
|
144
|
+
* and through its left padding: 12px before the arrows, near the 13px the bar leaves above
|
|
145
|
+
* and below them, and 16px after, so the rule doesn't crowd them.
|
|
146
|
+
*/
|
|
147
|
+
'-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',
|
|
148
|
+
className,
|
|
149
|
+
)}
|
|
150
|
+
data-slot="header-bar-nav"
|
|
151
|
+
{...props}
|
|
152
|
+
>
|
|
153
|
+
{/* An arrow with nothing to call has nowhere to go, so it dims as one at the end of the history. */}
|
|
154
|
+
<Button
|
|
155
|
+
aria-label={backLabel}
|
|
156
|
+
disabled={!canGoBack || !onBack}
|
|
157
|
+
onClick={onBack}
|
|
158
|
+
size="icon-sm"
|
|
159
|
+
variant="ghost"
|
|
160
|
+
>
|
|
161
|
+
<ArrowLeft strokeWidth={2} />
|
|
162
|
+
</Button>
|
|
163
|
+
{onForward && (
|
|
164
|
+
<Button
|
|
165
|
+
aria-label={forwardLabel}
|
|
166
|
+
disabled={!canGoForward}
|
|
167
|
+
onClick={onForward}
|
|
168
|
+
size="icon-sm"
|
|
169
|
+
variant="ghost"
|
|
170
|
+
>
|
|
171
|
+
<ArrowRight strokeWidth={2} />
|
|
172
|
+
</Button>
|
|
173
|
+
)}
|
|
174
|
+
</div>
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* A history for `HeaderBarNav` inside an app that keeps its own pages, not the browser's: `go` visits
|
|
179
|
+
* a page and drops anything forward of it, as a browser does. Use the router's history instead
|
|
180
|
+
* where there is one.
|
|
181
|
+
*/
|
|
182
|
+
export const usePageHistory = <Page,>(initial: Page[], start = initial.length - 1) => {
|
|
183
|
+
const [state, setState] = useState({ pages: initial, index: start });
|
|
184
|
+
const page = state.pages[state.index] as Page;
|
|
185
|
+
|
|
186
|
+
return {
|
|
187
|
+
page,
|
|
188
|
+
canGoBack: state.index > 0,
|
|
189
|
+
canGoForward: state.index < state.pages.length - 1,
|
|
190
|
+
back: () => setState(s => ({ ...s, index: Math.max(0, s.index - 1) })),
|
|
191
|
+
forward: () => setState(s => ({ ...s, index: Math.min(s.pages.length - 1, s.index + 1) })),
|
|
192
|
+
go: (next: Page) =>
|
|
193
|
+
setState(s => ({
|
|
194
|
+
pages: [...s.pages.slice(0, s.index + 1), next],
|
|
195
|
+
index: s.index + 1,
|
|
196
|
+
})),
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* The right of the bar: one or two actions, secondary before primary. They hide on a shell too
|
|
202
|
+
* narrow for the sidebar: the page keeps its own primary, and the bar its trail.
|
|
203
|
+
*/
|
|
204
|
+
export const HeaderBarActions = ({ className, ...props }: ComponentProps<'div'>) => (
|
|
205
|
+
<div
|
|
206
|
+
className={cn(
|
|
207
|
+
'flex @max-shell-sidebar/shell:hidden shrink-0 items-center gap-2',
|
|
208
|
+
className,
|
|
209
|
+
)}
|
|
210
|
+
data-slot="header-bar-actions"
|
|
211
|
+
{...props}
|
|
212
|
+
/>
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
/** @deprecated Moved to `Notice`, which hangs from any bar, not only the header. */
|
|
216
|
+
export const HeaderBarNotice = Notice;
|
|
217
|
+
/** @deprecated Moved to `NoticeProps`. */
|
|
218
|
+
export type HeaderBarNoticeProps = NoticeProps;
|
|
219
|
+
/** @deprecated Moved to `useNotice`. */
|
|
220
|
+
export const useHeaderNotice = useNotice;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type CSSProperties,
|
|
5
|
+
type KeyboardEvent,
|
|
6
|
+
type MouseEvent,
|
|
7
|
+
type PointerEvent,
|
|
8
|
+
useEffect,
|
|
9
|
+
useRef,
|
|
10
|
+
useState,
|
|
11
|
+
} from 'react';
|
|
12
|
+
import { cn } from '../lib/cn';
|
|
13
|
+
import { Button, type ButtonProps } from './button';
|
|
14
|
+
|
|
15
|
+
export type HoldButtonProps = Omit<ButtonProps, 'onClick' | 'render'> & {
|
|
16
|
+
/** Runs once the button has been held for `duration`. */
|
|
17
|
+
onConfirm: () => void;
|
|
18
|
+
/** How long the hold takes, in ms. */
|
|
19
|
+
duration?: number;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/** How long a fill that was let go of takes to drain, in ms. */
|
|
23
|
+
const DRAIN_MS = 200;
|
|
24
|
+
|
|
25
|
+
const isHoldKey = (key: string) => key === ' ' || key === 'Enter';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A button that runs a destructive action only once it has been held: holding fills it from the
|
|
29
|
+
* start edge in the error tone over `duration` (1000ms), and the action runs when it is full.
|
|
30
|
+
* Letting go sooner drains it back and nothing happens. Space or Enter held works the same. For an
|
|
31
|
+
* action repeated in place where a dialog each time would be clicked through; its label says to
|
|
32
|
+
* hold ("Hold to remove").
|
|
33
|
+
*/
|
|
34
|
+
export const HoldButton = ({
|
|
35
|
+
onConfirm,
|
|
36
|
+
duration = 1000,
|
|
37
|
+
variant = 'secondary',
|
|
38
|
+
className,
|
|
39
|
+
style,
|
|
40
|
+
disabled,
|
|
41
|
+
onPointerDown,
|
|
42
|
+
onPointerUp,
|
|
43
|
+
onPointerLeave,
|
|
44
|
+
onPointerCancel,
|
|
45
|
+
onKeyDown,
|
|
46
|
+
onKeyUp,
|
|
47
|
+
onBlur,
|
|
48
|
+
...props
|
|
49
|
+
}: HoldButtonProps) => {
|
|
50
|
+
const [holding, setHolding] = useState(false);
|
|
51
|
+
const timer = useRef<ReturnType<typeof setTimeout>>(undefined);
|
|
52
|
+
// Whether a key or the pointer started this press, so a click that follows it is not mistaken
|
|
53
|
+
// for a screen reader's activation.
|
|
54
|
+
const pressed = useRef(false);
|
|
55
|
+
const confirm = useRef(onConfirm);
|
|
56
|
+
confirm.current = onConfirm;
|
|
57
|
+
|
|
58
|
+
const start = () => {
|
|
59
|
+
if (disabled || timer.current) return;
|
|
60
|
+
pressed.current = true;
|
|
61
|
+
setHolding(true);
|
|
62
|
+
timer.current = setTimeout(() => {
|
|
63
|
+
timer.current = undefined;
|
|
64
|
+
setHolding(false);
|
|
65
|
+
confirm.current();
|
|
66
|
+
}, duration);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const stop = () => {
|
|
70
|
+
clearTimeout(timer.current);
|
|
71
|
+
timer.current = undefined;
|
|
72
|
+
setHolding(false);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<Button
|
|
79
|
+
className={cn(
|
|
80
|
+
'relative isolate overflow-hidden',
|
|
81
|
+
// The fill: the error tone's 500 at 20%, under the label, growing from the start edge.
|
|
82
|
+
'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',
|
|
83
|
+
'before:transition-[scale] before:ease-linear',
|
|
84
|
+
holding
|
|
85
|
+
? 'text-error-700 before:scale-x-100 before:duration-(--hold-ms)'
|
|
86
|
+
: 'before:duration-(--drain-ms)',
|
|
87
|
+
className,
|
|
88
|
+
)}
|
|
89
|
+
data-holding={holding || undefined}
|
|
90
|
+
data-slot="hold-button"
|
|
91
|
+
disabled={disabled}
|
|
92
|
+
onBlur={event => {
|
|
93
|
+
stop();
|
|
94
|
+
onBlur?.(event);
|
|
95
|
+
}}
|
|
96
|
+
onClick={(event: MouseEvent<HTMLButtonElement>) => {
|
|
97
|
+
// A screen reader activates a button with a click and no key or pointer before it; it
|
|
98
|
+
// cannot hold, and its activation is deliberate, so it confirms at once.
|
|
99
|
+
if (event.detail === 0 && !pressed.current) confirm.current();
|
|
100
|
+
pressed.current = false;
|
|
101
|
+
}}
|
|
102
|
+
onKeyDown={(event: KeyboardEvent<HTMLButtonElement>) => {
|
|
103
|
+
if (isHoldKey(event.key)) {
|
|
104
|
+
// Enter would click on keydown; the hold decides instead.
|
|
105
|
+
event.preventDefault();
|
|
106
|
+
if (!event.repeat) start();
|
|
107
|
+
}
|
|
108
|
+
onKeyDown?.(event);
|
|
109
|
+
}}
|
|
110
|
+
onKeyUp={(event: KeyboardEvent<HTMLButtonElement>) => {
|
|
111
|
+
if (isHoldKey(event.key)) {
|
|
112
|
+
// Space clicks on keyup; held off so the release is only a release.
|
|
113
|
+
event.preventDefault();
|
|
114
|
+
stop();
|
|
115
|
+
pressed.current = false;
|
|
116
|
+
}
|
|
117
|
+
onKeyUp?.(event);
|
|
118
|
+
}}
|
|
119
|
+
onPointerCancel={(event: PointerEvent<HTMLButtonElement>) => {
|
|
120
|
+
stop();
|
|
121
|
+
onPointerCancel?.(event);
|
|
122
|
+
}}
|
|
123
|
+
onPointerDown={(event: PointerEvent<HTMLButtonElement>) => {
|
|
124
|
+
if (event.button === 0) start();
|
|
125
|
+
onPointerDown?.(event);
|
|
126
|
+
}}
|
|
127
|
+
onPointerLeave={(event: PointerEvent<HTMLButtonElement>) => {
|
|
128
|
+
stop();
|
|
129
|
+
onPointerLeave?.(event);
|
|
130
|
+
}}
|
|
131
|
+
onPointerUp={(event: PointerEvent<HTMLButtonElement>) => {
|
|
132
|
+
stop();
|
|
133
|
+
onPointerUp?.(event);
|
|
134
|
+
}}
|
|
135
|
+
style={
|
|
136
|
+
{
|
|
137
|
+
'--hold-ms': `${duration}ms`,
|
|
138
|
+
'--drain-ms': `${DRAIN_MS}ms`,
|
|
139
|
+
...style,
|
|
140
|
+
} as CSSProperties
|
|
141
|
+
}
|
|
142
|
+
variant={variant}
|
|
143
|
+
{...props}
|
|
144
|
+
/>
|
|
145
|
+
);
|
|
146
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
2
|
+
import type { ComponentProps } from 'react';
|
|
3
|
+
import { cn } from '../lib/cn';
|
|
4
|
+
|
|
5
|
+
export const iconTileVariants = cva(
|
|
6
|
+
'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',
|
|
7
|
+
{
|
|
8
|
+
variants: {
|
|
9
|
+
variant: {
|
|
10
|
+
filled: 'bg-neutral-100',
|
|
11
|
+
outline: '',
|
|
12
|
+
},
|
|
13
|
+
// A glyph needs 3:1 on the tile: a ramp's 600, or 700 for the pale green and amber and for the
|
|
14
|
+
// theme's accent, which may be pale; dots and fills take 500.
|
|
15
|
+
tone: {
|
|
16
|
+
neutral: 'text-neutral-600',
|
|
17
|
+
success: 'text-success-700',
|
|
18
|
+
warning: 'text-warning-700',
|
|
19
|
+
error: 'text-error-600',
|
|
20
|
+
primary: 'text-primary-700',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
defaultVariants: {
|
|
24
|
+
variant: 'filled',
|
|
25
|
+
tone: 'neutral',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
export type IconTileProps = ComponentProps<'span'> & VariantProps<typeof iconTileVariants>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Square icon well: filled beside the report generator's option rows, outlined
|
|
34
|
+
* in the invoice sheet's status history.
|
|
35
|
+
*/
|
|
36
|
+
export const IconTile = ({ variant, tone, className, ...props }: IconTileProps) => (
|
|
37
|
+
<span
|
|
38
|
+
className={cn(iconTileVariants({ variant, tone }), className)}
|
|
39
|
+
data-slot="icon-tile"
|
|
40
|
+
data-tone={tone ?? 'neutral'}
|
|
41
|
+
{...props}
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Info } from 'lucide-react';
|
|
4
|
+
import { type ComponentProps, type ReactNode, useId } from 'react';
|
|
5
|
+
import { cn } from '../lib/cn';
|
|
6
|
+
import { focusRing } from './button';
|
|
7
|
+
import { Popover, PopoverContent, PopoverTrigger } from './popover';
|
|
8
|
+
|
|
9
|
+
export type InfoTipProps = Omit<ComponentProps<'button'>, 'children' | 'content'> &
|
|
10
|
+
Pick<ComponentProps<typeof Popover>, 'open' | 'defaultOpen' | 'onOpenChange'> &
|
|
11
|
+
Pick<ComponentProps<typeof PopoverContent>, 'side' | 'align' | 'container'> & {
|
|
12
|
+
/** What the tip explains. */
|
|
13
|
+
content: ReactNode;
|
|
14
|
+
/** The button's accessible name. */
|
|
15
|
+
label?: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A ghost 16px info icon beside a section title that explains it on hover, focus and tap.
|
|
20
|
+
* Open state can be controlled with `open` and `onOpenChange`.
|
|
21
|
+
*/
|
|
22
|
+
export const InfoTip = ({
|
|
23
|
+
content,
|
|
24
|
+
label = 'More information',
|
|
25
|
+
open,
|
|
26
|
+
defaultOpen,
|
|
27
|
+
onOpenChange,
|
|
28
|
+
side = 'top',
|
|
29
|
+
align = 'center',
|
|
30
|
+
container,
|
|
31
|
+
className,
|
|
32
|
+
type = 'button',
|
|
33
|
+
'aria-describedby': describedBy,
|
|
34
|
+
...props
|
|
35
|
+
}: InfoTipProps) => {
|
|
36
|
+
const contentId = useId();
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
/*
|
|
40
|
+
* A popover that also opens on hover rather than a tooltip: Base UI turns tooltips off on touch,
|
|
41
|
+
* which would leave the explanation out of reach on a phone. A tap opens this one.
|
|
42
|
+
*/
|
|
43
|
+
<Popover defaultOpen={defaultOpen} onOpenChange={onOpenChange} open={open}>
|
|
44
|
+
<PopoverTrigger
|
|
45
|
+
delay={300}
|
|
46
|
+
openOnHover
|
|
47
|
+
render={
|
|
48
|
+
<button
|
|
49
|
+
aria-describedby={[describedBy, contentId].filter(Boolean).join(' ')}
|
|
50
|
+
aria-label={label}
|
|
51
|
+
className={cn(
|
|
52
|
+
'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',
|
|
53
|
+
// A 16px icon is too small to hit; the invisible 24px ring around it is the target.
|
|
54
|
+
'after:absolute after:-inset-1 after:content-[""]',
|
|
55
|
+
focusRing,
|
|
56
|
+
className,
|
|
57
|
+
)}
|
|
58
|
+
data-slot="info-tip"
|
|
59
|
+
type={type}
|
|
60
|
+
{...props}
|
|
61
|
+
/>
|
|
62
|
+
}
|
|
63
|
+
>
|
|
64
|
+
<Info aria-hidden className="size-4" strokeWidth={2} />
|
|
65
|
+
</PopoverTrigger>
|
|
66
|
+
{/* The text is also in the page, so a screen reader hears it on focus without opening anything. */}
|
|
67
|
+
<span className="sr-only" data-slot="info-tip-description" id={contentId}>
|
|
68
|
+
{content}
|
|
69
|
+
</span>
|
|
70
|
+
<PopoverContent
|
|
71
|
+
align={align}
|
|
72
|
+
aria-label={label}
|
|
73
|
+
// A short explanation, not a panel of controls: sized to its text, with the item corner.
|
|
74
|
+
className="w-auto max-w-tooltip gap-0 text-balance rounded-item px-2.5 py-1.5 text-neutral-700 text-xs"
|
|
75
|
+
container={container}
|
|
76
|
+
data-slot="info-tip-content"
|
|
77
|
+
// Focus stays on the icon, so tabbing on after a tap carries on through the page.
|
|
78
|
+
finalFocus={false}
|
|
79
|
+
initialFocus={false}
|
|
80
|
+
side={side}
|
|
81
|
+
sideOffset={6}
|
|
82
|
+
>
|
|
83
|
+
{content}
|
|
84
|
+
</PopoverContent>
|
|
85
|
+
</Popover>
|
|
86
|
+
);
|
|
87
|
+
};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
4
|
+
import type { ComponentProps, ReactNode } from 'react';
|
|
5
|
+
import { cn } from '../lib/cn';
|
|
6
|
+
import { useFieldControl } from './field';
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* The wrapper carries the border so icons sit inside the box; the native input
|
|
10
|
+
* is borderless and the wrapper shows the focus ring when it is focused.
|
|
11
|
+
*/
|
|
12
|
+
export const inputVariants = cva(
|
|
13
|
+
[
|
|
14
|
+
'group/input flex w-full min-w-0 items-center gap-2 border transition-[border-color,background-color] duration-150',
|
|
15
|
+
'has-[input:focus-visible]:outline-2 has-[input:focus-visible]:outline-focus has-[input:focus-visible]:outline-offset-2',
|
|
16
|
+
'[&_svg:not([class*=size-])]:size-icon [&_svg]:shrink-0',
|
|
17
|
+
],
|
|
18
|
+
{
|
|
19
|
+
variants: {
|
|
20
|
+
size: {
|
|
21
|
+
// The control row (level with a button) and the field row (level with a large one).
|
|
22
|
+
sm: 'h-control rounded-control px-3',
|
|
23
|
+
md: 'h-control-lg rounded-control px-3 [--spacing-icon:var(--spacing-icon-lg)]',
|
|
24
|
+
},
|
|
25
|
+
variant: {
|
|
26
|
+
outline: 'bg-control shadow-control',
|
|
27
|
+
/*
|
|
28
|
+
* No box: the search inside a container (a table's bar, a menu) is an icon and the
|
|
29
|
+
* text. It keeps the shared ring round where the box would be, so a keyboard still
|
|
30
|
+
* sees where it is.
|
|
31
|
+
*/
|
|
32
|
+
plain: 'border-transparent px-0',
|
|
33
|
+
},
|
|
34
|
+
invalid: {
|
|
35
|
+
true: 'border-error-500 [&_svg]:text-error-500',
|
|
36
|
+
false: '',
|
|
37
|
+
},
|
|
38
|
+
disabled: {
|
|
39
|
+
// As every control: the whole box at half strength, its colours and border kept.
|
|
40
|
+
true: 'cursor-not-allowed opacity-50',
|
|
41
|
+
false: '',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
compoundVariants: [
|
|
45
|
+
{
|
|
46
|
+
variant: 'outline',
|
|
47
|
+
invalid: false,
|
|
48
|
+
disabled: false,
|
|
49
|
+
className:
|
|
50
|
+
'border-neutral-200 hover:border-neutral-300 hover:bg-control-hover has-[input:focus]:border-neutral-300 [&_svg]:text-neutral-600',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
variant: 'outline',
|
|
54
|
+
invalid: false,
|
|
55
|
+
disabled: true,
|
|
56
|
+
className: 'border-neutral-200 [&_svg]:text-neutral-600',
|
|
57
|
+
},
|
|
58
|
+
{ variant: 'plain', invalid: false, className: '[&_svg]:text-neutral-600' },
|
|
59
|
+
],
|
|
60
|
+
defaultVariants: {
|
|
61
|
+
size: 'md',
|
|
62
|
+
variant: 'outline',
|
|
63
|
+
invalid: false,
|
|
64
|
+
disabled: false,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
/*
|
|
70
|
+
* Value and placeholder colours shared with Textarea. The library's "selected"
|
|
71
|
+
* state is the value in neutral-900. Disabled keeps these colours: the box around
|
|
72
|
+
* them is dimmed to half strength, as every disabled control is. On a touch screen the text is
|
|
73
|
+
* 16px: anything smaller and iOS zooms the page in when the field takes focus.
|
|
74
|
+
*/
|
|
75
|
+
export const inputTextClass = [
|
|
76
|
+
'font-medium text-neutral-900 text-xs placeholder:text-neutral-600 pointer-coarse:text-base',
|
|
77
|
+
'aria-invalid:placeholder:text-error-300',
|
|
78
|
+
'disabled:cursor-not-allowed',
|
|
79
|
+
];
|
|
80
|
+
|
|
81
|
+
export type InputProps = Omit<ComponentProps<'input'>, 'size'> &
|
|
82
|
+
Omit<VariantProps<typeof inputVariants>, 'invalid' | 'disabled'> & {
|
|
83
|
+
leadingIcon?: ReactNode;
|
|
84
|
+
trailing?: ReactNode;
|
|
85
|
+
/** Classes for the native input; `className` goes on the bordered box. */
|
|
86
|
+
inputClassName?: string;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/** Inputs from the library ("input small/medium") and the report-generator forms. */
|
|
90
|
+
export const Input = ({
|
|
91
|
+
size,
|
|
92
|
+
variant,
|
|
93
|
+
leadingIcon,
|
|
94
|
+
trailing,
|
|
95
|
+
className,
|
|
96
|
+
inputClassName,
|
|
97
|
+
id,
|
|
98
|
+
disabled,
|
|
99
|
+
'aria-describedby': describedBy,
|
|
100
|
+
'aria-invalid': ariaInvalid,
|
|
101
|
+
...props
|
|
102
|
+
}: InputProps) => {
|
|
103
|
+
const { invalid, ...control } = useFieldControl({
|
|
104
|
+
id,
|
|
105
|
+
disabled,
|
|
106
|
+
'aria-describedby': describedBy,
|
|
107
|
+
'aria-invalid': ariaInvalid,
|
|
108
|
+
});
|
|
109
|
+
const isDisabled = Boolean(control.disabled);
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<div
|
|
113
|
+
className={cn(
|
|
114
|
+
inputVariants({ size, variant, invalid, disabled: isDisabled }),
|
|
115
|
+
className,
|
|
116
|
+
)}
|
|
117
|
+
data-disabled={isDisabled || undefined}
|
|
118
|
+
data-invalid={invalid || undefined}
|
|
119
|
+
data-slot="input"
|
|
120
|
+
>
|
|
121
|
+
{leadingIcon}
|
|
122
|
+
<input
|
|
123
|
+
className={cn(
|
|
124
|
+
'h-full min-w-0 flex-1 bg-transparent outline-none',
|
|
125
|
+
inputTextClass,
|
|
126
|
+
!invalid && !isDisabled && 'group-hover/input:placeholder:text-neutral-700',
|
|
127
|
+
inputClassName,
|
|
128
|
+
)}
|
|
129
|
+
data-slot="input-control"
|
|
130
|
+
{...control}
|
|
131
|
+
{...props}
|
|
132
|
+
/>
|
|
133
|
+
{trailing}
|
|
134
|
+
</div>
|
|
135
|
+
);
|
|
136
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
|
+
import { cn } from '../lib/cn';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Keyboard shortcut key from the sidebar menu item and the report editor's sidebar. A touch screen
|
|
6
|
+
* has no keys to press, so on a coarse pointer the hint is not drawn.
|
|
7
|
+
*/
|
|
8
|
+
export const Kbd = ({ className, ...props }: ComponentProps<'kbd'>) => (
|
|
9
|
+
<kbd
|
|
10
|
+
className={cn(
|
|
11
|
+
'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',
|
|
12
|
+
className,
|
|
13
|
+
)}
|
|
14
|
+
data-slot="kbd"
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
);
|