@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,45 @@
|
|
|
1
|
+
import { Toggle } from '@base-ui/react/toggle';
|
|
2
|
+
import { type VariantProps } from 'class-variance-authority';
|
|
3
|
+
import { type ComponentProps } from 'react';
|
|
4
|
+
import type { SegmentedControlProps } from './segmented-control.js';
|
|
5
|
+
/**
|
|
6
|
+
* The bar that floats at the bottom of a page: a dock of sections and, beside
|
|
7
|
+
* it, the page's main action (a + or a filter). Its corners follow the theme,
|
|
8
|
+
* a full pill by default, unless `shape` says otherwise.
|
|
9
|
+
*/
|
|
10
|
+
export declare const BottomBar: ({ floating, className, ...props }: ComponentProps<"div"> & {
|
|
11
|
+
/**
|
|
12
|
+
* Pins the bar 24px above the bottom of its positioned parent, centred, and never wider than the
|
|
13
|
+
* parent less 16px a side, so a dock with more sections than fit scrolls rather than spills.
|
|
14
|
+
*/
|
|
15
|
+
floating?: boolean;
|
|
16
|
+
}) => import("react").JSX.Element;
|
|
17
|
+
export declare const dockVariants: (props?: ({
|
|
18
|
+
shape?: "rounded" | "pill" | "theme" | null | undefined;
|
|
19
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
20
|
+
export type DockProps = SegmentedControlProps & VariantProps<typeof dockVariants>;
|
|
21
|
+
/**
|
|
22
|
+
* The sections of a page. Like a segmented control it always keeps one selected. More sections
|
|
23
|
+
* than fit scroll sideways, with a chevron at the end that has more and the selected one kept in view.
|
|
24
|
+
*/
|
|
25
|
+
export declare const Dock: ({ shape, value, defaultValue, onValueChange, className, ...props }: DockProps) => import("react").JSX.Element;
|
|
26
|
+
export type DockItemProps = Omit<Toggle.Props, 'className'> & {
|
|
27
|
+
className?: string;
|
|
28
|
+
};
|
|
29
|
+
export declare const DockItem: ({ className, ...props }: DockItemProps) => import("react").JSX.Element;
|
|
30
|
+
/**
|
|
31
|
+
* A count after a dock item's label ("Active 12"), in the item's own colour at 70%, so it follows
|
|
32
|
+
* the pressed item onto its fill. It hides on a compact shell, where the labels need the room.
|
|
33
|
+
*/
|
|
34
|
+
export declare const DockCount: ({ className, ...props }: ComponentProps<"span">) => import("react").JSX.Element;
|
|
35
|
+
export declare const dockActionVariants: (props?: ({
|
|
36
|
+
shape?: "rounded" | "pill" | "theme" | null | undefined;
|
|
37
|
+
size?: "icon" | "default" | null | undefined;
|
|
38
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
39
|
+
export type DockActionProps = ComponentProps<'button'> & VariantProps<typeof dockActionVariants>;
|
|
40
|
+
/**
|
|
41
|
+
* The action beside the dock: a large primary Button with the dock's corners.
|
|
42
|
+
* "Start campaign" with a rocket, a filter with its count "(6)", or
|
|
43
|
+
* `size="icon"` for a lone +.
|
|
44
|
+
*/
|
|
45
|
+
export declare const DockAction: ({ shape, size, className, type, ...props }: DockActionProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Toggle } from '@base-ui/react/toggle';
|
|
4
|
+
import { ToggleGroup } from '@base-ui/react/toggle-group';
|
|
5
|
+
import { cva } from 'class-variance-authority';
|
|
6
|
+
import { useEffect } from 'react';
|
|
7
|
+
import { cn } from '../lib/cn.js';
|
|
8
|
+
import { OverflowChevron, useOverflowScroll } from '../lib/overflow-scroll.js';
|
|
9
|
+
import { radioToggleRender } from '../lib/radio-toggle-render.js';
|
|
10
|
+
import { useSingleValue } from '../lib/use-single-value.js';
|
|
11
|
+
import { buttonVariants, focusRing } from './button.js';
|
|
12
|
+
/**
|
|
13
|
+
* The bar that floats at the bottom of a page: a dock of sections and, beside
|
|
14
|
+
* it, the page's main action (a + or a filter). Its corners follow the theme,
|
|
15
|
+
* a full pill by default, unless `shape` says otherwise.
|
|
16
|
+
*/
|
|
17
|
+
export const BottomBar = ({ floating, className, ...props }) => (_jsx("div", { className: cn('flex min-w-0 max-w-full items-center gap-2', floating && 'absolute inset-x-0 bottom-6 z-10 mx-auto w-fit max-w-[calc(100%-32px)]', className), "data-slot": "bottom-bar", ...props }));
|
|
18
|
+
const shapeVariants = {
|
|
19
|
+
theme: '',
|
|
20
|
+
pill: '[--radius-dock:9999px]',
|
|
21
|
+
// A tighter corner, the item's 10px, so it still scales with the theme's corners.
|
|
22
|
+
rounded: '[--radius-dock:var(--radius-item)]',
|
|
23
|
+
};
|
|
24
|
+
export const dockVariants = cva(
|
|
25
|
+
// The field row's 38px: 32px items inside a 2px inset and a hairline. The inset is fixed like the
|
|
26
|
+
// heights, so it stays even on all four sides whatever the spacing unit.
|
|
27
|
+
'flex h-control-lg w-fit min-w-0 max-w-full items-center gap-0.5 rounded-dock border border-neutral-200 bg-neutral-50 p-[2px] shadow-float', { variants: { shape: shapeVariants }, defaultVariants: { shape: 'theme' } });
|
|
28
|
+
/**
|
|
29
|
+
* The sections of a page. Like a segmented control it always keeps one selected. More sections
|
|
30
|
+
* than fit scroll sideways, with a chevron at the end that has more and the selected one kept in view.
|
|
31
|
+
*/
|
|
32
|
+
export const Dock = ({ shape, value, defaultValue, onValueChange, className, ...props }) => {
|
|
33
|
+
const [current, select] = useSingleValue(value, defaultValue, onValueChange);
|
|
34
|
+
const { ref, edges, step, reveal, style } = useOverflowScroll();
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
// Again when the row starts overflowing, so the selected one is in view from the start.
|
|
37
|
+
if (current && edges.overflows)
|
|
38
|
+
reveal('[data-pressed]');
|
|
39
|
+
}, [current, reveal, edges.overflows]);
|
|
40
|
+
return (_jsxs("div", { className: cn(dockVariants({ shape }), className), "data-slot": "dock", children: [edges.overflows && (_jsx(OverflowChevron, { className: chevron, direction: -1, disabled: !edges.start, onStep: step })), _jsx(ToggleGroup
|
|
41
|
+
// The row clips at the dock's inset, not its items, so a focus ring keeps its room.
|
|
42
|
+
, {
|
|
43
|
+
// The row clips at the dock's inset, not its items, so a focus ring keeps its room.
|
|
44
|
+
className: "scrollbar-none my-[-2px] flex min-w-0 items-center gap-0.5 overflow-x-auto py-[2px]", "data-slot": "dock-items", ref: ref, role: "radiogroup", style: style, ...props,
|
|
45
|
+
// Clicking the pressed item hands back an empty array, which `select` ignores.
|
|
46
|
+
onValueChange: values => select(values[0] ?? ''), value: current ? [current] : [] }), edges.overflows && (_jsx(OverflowChevron, { className: chevron, direction: 1, disabled: !edges.end, onStep: step }))] }));
|
|
47
|
+
};
|
|
48
|
+
// An item's 32px and its concentric corner.
|
|
49
|
+
const chevron = 'size-cell rounded-[calc(var(--radius-dock)-3px)]';
|
|
50
|
+
export const DockItem = ({ className, ...props }) => (_jsx(Toggle, { className: cn(
|
|
51
|
+
// The bar's radius minus its 2px inset and 1px border, so the curves stay concentric.
|
|
52
|
+
'inline-flex h-cell cursor-pointer select-none items-center gap-2 whitespace-nowrap rounded-[calc(var(--radius-dock)-3px)] px-3 font-medium text-neutral-600 text-xs transition-[background-color,color,box-shadow] duration-150', 'hover:text-neutral-950', 'data-pressed:bg-segment data-pressed:text-segment-fg data-pressed:[box-shadow:inset_0_0_0_1px_var(--color-segment-border),var(--shadow-segment)]', 'data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg:not([class*=size-])]:size-4 [&_svg]:shrink-0', focusRing, className), "data-slot": "dock-item", render: radioToggleRender, ...props }));
|
|
53
|
+
/**
|
|
54
|
+
* A count after a dock item's label ("Active 12"), in the item's own colour at 70%, so it follows
|
|
55
|
+
* the pressed item onto its fill. It hides on a compact shell, where the labels need the room.
|
|
56
|
+
*/
|
|
57
|
+
export const DockCount = ({ className, ...props }) => (_jsx("span", { className: cn('@max-shell-compact/shell:hidden font-normal tabular-nums opacity-70', className), "data-slot": "dock-count", ...props }));
|
|
58
|
+
export const dockActionVariants = cva([
|
|
59
|
+
// A lit action's ring drawn inside, so it stays the dock's 38px instead of growing 1px each side.
|
|
60
|
+
'rounded-dock [box-shadow:inset_0_1px_0_0_var(--color-action-highlight),inset_0_0_0_1px_var(--color-action-ring)]',
|
|
61
|
+
// On a compact shell an action with an icon keeps only the icon, a 38px square, so the dock
|
|
62
|
+
// keeps the width; its label stays in the button for screen readers, set at no size.
|
|
63
|
+
'@max-shell-compact/shell:has-[svg]:w-control-lg @max-shell-compact/shell:has-[svg]:gap-0 @max-shell-compact/shell:has-[svg]:px-0 @max-shell-compact/shell:has-[svg]:text-[0px]',
|
|
64
|
+
], {
|
|
65
|
+
variants: {
|
|
66
|
+
shape: shapeVariants,
|
|
67
|
+
size: {
|
|
68
|
+
default: '',
|
|
69
|
+
icon: 'w-control-lg px-0',
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
defaultVariants: { shape: 'theme', size: 'default' },
|
|
73
|
+
});
|
|
74
|
+
/**
|
|
75
|
+
* The action beside the dock: a large primary Button with the dock's corners.
|
|
76
|
+
* "Start campaign" with a rocket, a filter with its count "(6)", or
|
|
77
|
+
* `size="icon"` for a lone +.
|
|
78
|
+
*/
|
|
79
|
+
export const DockAction = ({ shape, size, className, type = 'button', ...props }) => (_jsx("button", { className: cn(buttonVariants({ variant: 'primary', size: 'lg' }), dockActionVariants({ shape, size }), className), "data-slot": "dock-action", type: type, ...props }));
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type ComponentProps, type ReactNode } from 'react';
|
|
2
|
+
/** "2.4 MB", "860 KB", "312 B": one decimal only where it still says something. */
|
|
3
|
+
export declare const formatFileSize: (bytes: number) => string;
|
|
4
|
+
export type DropZoneProps = Omit<ComponentProps<'div'>, 'title' | 'onDrop'> & {
|
|
5
|
+
/** What goes here, in a line: "Drop CSV files here". */
|
|
6
|
+
title?: ReactNode;
|
|
7
|
+
/** What is accepted and how much: "CSV or XLSX, up to 10 MB each". */
|
|
8
|
+
description?: ReactNode;
|
|
9
|
+
/** The secondary button that opens the file picker. */
|
|
10
|
+
action?: ReactNode;
|
|
11
|
+
icon?: ReactNode;
|
|
12
|
+
/** Passed to the file input, and checked again on drop, where the browser does not. */
|
|
13
|
+
accept?: string;
|
|
14
|
+
multiple?: boolean;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
/** Receives the picked or dropped files that match `accept`. */
|
|
17
|
+
onFiles?: (files: File[]) => void;
|
|
18
|
+
/** The name the hidden file input submits under in a form. */
|
|
19
|
+
name?: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* The empty-state panel made a drop target: a dashed, left-aligned well with one line on what goes
|
|
23
|
+
* here and a secondary button that opens the picker. Dragging files over it darkens the dash and
|
|
24
|
+
* lays the 3% wash over it.
|
|
25
|
+
*/
|
|
26
|
+
export declare const DropZone: ({ title, description, action, icon, accept, multiple, disabled: disabledProp, onFiles, name, id: idProp, className, "aria-invalid": ariaInvalid, ...props }: DropZoneProps) => import("react").JSX.Element;
|
|
27
|
+
/** The files taken by a drop zone, under it; spaced, not ruled. */
|
|
28
|
+
export declare const DropZoneFiles: ({ className, ...props }: ComponentProps<"ul">) => import("react").JSX.Element;
|
|
29
|
+
export type DropZoneFileProps = Omit<ComponentProps<'li'>, 'onError'> & {
|
|
30
|
+
name: string;
|
|
31
|
+
/** Bytes, formatted for you, or text as it should read. */
|
|
32
|
+
size?: number | string;
|
|
33
|
+
/** Upload progress 0–100 while `status` is uploading. */
|
|
34
|
+
progress?: number;
|
|
35
|
+
status?: 'uploading' | 'done' | 'error';
|
|
36
|
+
/** Why it failed, in place of the size. */
|
|
37
|
+
error?: ReactNode;
|
|
38
|
+
onRemove?: () => void;
|
|
39
|
+
/**
|
|
40
|
+
* Where a long name cuts: in the `middle` by default, so the extension and the end that tells
|
|
41
|
+
* one file from the next stay (`invoice-2026-…-0142.pdf`); `end` for names read from the start.
|
|
42
|
+
*/
|
|
43
|
+
truncate?: 'end' | 'middle';
|
|
44
|
+
};
|
|
45
|
+
/** One file: its tile, name and size, a bar while it uploads, and a ghost × to cancel or remove it. */
|
|
46
|
+
export declare const DropZoneFile: ({ name, size, progress, status, error, onRemove, truncate, className, ...props }: DropZoneFileProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { CircleAlert, CircleCheck, FileText, Upload, X } from 'lucide-react';
|
|
4
|
+
import { useId, useRef, useState, } from 'react';
|
|
5
|
+
import { cn } from '../lib/cn.js';
|
|
6
|
+
import { Button } from './button.js';
|
|
7
|
+
import { useFieldControl } from './field.js';
|
|
8
|
+
import { IconTile } from './icon-tile.js';
|
|
9
|
+
import { Progress } from './progress.js';
|
|
10
|
+
import { Truncate } from './truncate.js';
|
|
11
|
+
/** "2.4 MB", "860 KB", "312 B": one decimal only where it still says something. */
|
|
12
|
+
export const formatFileSize = (bytes) => {
|
|
13
|
+
if (bytes < 1024)
|
|
14
|
+
return `${bytes} B`;
|
|
15
|
+
const units = ['KB', 'MB', 'GB'];
|
|
16
|
+
let value = bytes / 1024;
|
|
17
|
+
let unit = 0;
|
|
18
|
+
while (value >= 1024 && unit < units.length - 1) {
|
|
19
|
+
value /= 1024;
|
|
20
|
+
unit += 1;
|
|
21
|
+
}
|
|
22
|
+
return `${value < 10 ? value.toFixed(1) : Math.round(value)} ${units[unit]}`;
|
|
23
|
+
};
|
|
24
|
+
/** Whether a file matches an `accept` list of extensions and MIME types (`image/*` included). */
|
|
25
|
+
const accepts = (file, accept) => {
|
|
26
|
+
if (!accept)
|
|
27
|
+
return true;
|
|
28
|
+
const name = file.name.toLowerCase();
|
|
29
|
+
const type = file.type.toLowerCase();
|
|
30
|
+
return accept
|
|
31
|
+
.split(',')
|
|
32
|
+
.map(rule => rule.trim().toLowerCase())
|
|
33
|
+
.some(rule => rule.startsWith('.')
|
|
34
|
+
? name.endsWith(rule)
|
|
35
|
+
: rule.endsWith('/*')
|
|
36
|
+
? type.startsWith(rule.slice(0, -1))
|
|
37
|
+
: type === rule);
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* The empty-state panel made a drop target: a dashed, left-aligned well with one line on what goes
|
|
41
|
+
* here and a secondary button that opens the picker. Dragging files over it darkens the dash and
|
|
42
|
+
* lays the 3% wash over it.
|
|
43
|
+
*/
|
|
44
|
+
export const DropZone = ({ title = 'Drop files here', description, action = 'Choose files', icon = _jsx(Upload, { strokeWidth: 2 }), accept, multiple = true, disabled: disabledProp, onFiles, name, id: idProp, className, 'aria-invalid': ariaInvalid, ...props }) => {
|
|
45
|
+
const input = useRef(null);
|
|
46
|
+
const [dragging, setDragging] = useState(false);
|
|
47
|
+
// dragenter and dragleave fire for every child crossed, so the zone counts them to know it is left.
|
|
48
|
+
const depth = useRef(0);
|
|
49
|
+
const generatedId = useId();
|
|
50
|
+
const { invalid, disabled, ...control } = useFieldControl({
|
|
51
|
+
id: idProp,
|
|
52
|
+
disabled: disabledProp,
|
|
53
|
+
'aria-invalid': ariaInvalid,
|
|
54
|
+
});
|
|
55
|
+
const inputId = control.id ?? generatedId;
|
|
56
|
+
const descriptionId = description ? `${inputId}-description` : undefined;
|
|
57
|
+
const describedBy = [descriptionId, control['aria-describedby']].filter(Boolean).join(' ') || undefined;
|
|
58
|
+
const take = (list) => {
|
|
59
|
+
if (!list)
|
|
60
|
+
return;
|
|
61
|
+
const files = Array.from(list).filter(file => accepts(file, accept));
|
|
62
|
+
if (files.length > 0)
|
|
63
|
+
onFiles?.(multiple ? files : files.slice(0, 1));
|
|
64
|
+
};
|
|
65
|
+
const onDragEnter = (event) => {
|
|
66
|
+
if (disabled || !event.dataTransfer.types.includes('Files'))
|
|
67
|
+
return;
|
|
68
|
+
event.preventDefault();
|
|
69
|
+
depth.current += 1;
|
|
70
|
+
setDragging(true);
|
|
71
|
+
};
|
|
72
|
+
const onDragLeave = () => {
|
|
73
|
+
depth.current = Math.max(0, depth.current - 1);
|
|
74
|
+
if (depth.current === 0)
|
|
75
|
+
setDragging(false);
|
|
76
|
+
};
|
|
77
|
+
const onDrop = (event) => {
|
|
78
|
+
event.preventDefault();
|
|
79
|
+
depth.current = 0;
|
|
80
|
+
setDragging(false);
|
|
81
|
+
if (!disabled)
|
|
82
|
+
take(event.dataTransfer.files);
|
|
83
|
+
};
|
|
84
|
+
return (_jsxs("div", { className: cn('flex flex-wrap items-center gap-x-3 gap-y-4 rounded-item border border-dashed p-4 transition-[background-color,border-color] duration-150 motion-reduce:transition-none', invalid ? 'border-error-500' : 'border-neutral-300', 'data-dragging:border-neutral-500 data-dragging:bg-neutral-950/3', 'data-disabled:opacity-50', className), "data-disabled": disabled || undefined, "data-dragging": dragging || undefined, "data-invalid": invalid || undefined, "data-slot": "drop-zone", onDragEnter: onDragEnter, onDragLeave: onDragLeave,
|
|
85
|
+
// Without preventing dragover the browser opens the file instead of dropping it here.
|
|
86
|
+
onDragOver: event => {
|
|
87
|
+
if (!disabled)
|
|
88
|
+
event.preventDefault();
|
|
89
|
+
}, onDrop: onDrop, ...props, children: [_jsx(IconTile, { tone: invalid ? 'error' : 'neutral', children: icon }), _jsxs("div", { className: "flex min-w-0 flex-1 basis-48 flex-col gap-0.5", "data-slot": "drop-zone-text", children: [_jsx("p", { className: "font-medium text-neutral-950 text-xs", children: title }), description && (_jsx("p", { className: cn('text-xs', invalid ? 'text-error-600' : 'text-neutral-600'), "data-slot": "drop-zone-description", id: descriptionId, children: description }))] }), _jsx(Button, { "aria-describedby": describedBy, disabled: disabled, onClick: () => input.current?.click(), variant: "secondary", children: action }), _jsx("input", { accept: accept, "aria-invalid": invalid || undefined, className: "hidden", "data-slot": "drop-zone-input", disabled: disabled, id: inputId, multiple: multiple, name: name, onChange: event => {
|
|
90
|
+
take(event.target.files);
|
|
91
|
+
// Cleared, so picking the same file again after removing it still reports it.
|
|
92
|
+
event.target.value = '';
|
|
93
|
+
}, ref: input, tabIndex: -1, type: "file" })] }));
|
|
94
|
+
};
|
|
95
|
+
/** The files taken by a drop zone, under it; spaced, not ruled. */
|
|
96
|
+
export const DropZoneFiles = ({ className, ...props }) => (_jsx("ul", { className: cn('flex flex-col gap-4', className), "data-slot": "drop-zone-files", ...props }));
|
|
97
|
+
/** One file: its tile, name and size, a bar while it uploads, and a ghost × to cancel or remove it. */
|
|
98
|
+
export const DropZoneFile = ({ name, size, progress = 0, status = 'done', error, onRemove, truncate = 'middle', className, ...props }) => {
|
|
99
|
+
const meta = status === 'error' ? error : typeof size === 'number' ? formatFileSize(size) : size;
|
|
100
|
+
return (_jsxs("li", { className: cn('flex items-center gap-3', className), "data-slot": "drop-zone-file", "data-status": status, ...props, children: [_jsx(IconTile, { tone: status === 'done' ? 'success' : status === 'error' ? 'error' : 'neutral', variant: status === 'uploading' ? 'filled' : 'outline', children: status === 'done' ? (_jsx(CircleCheck, { strokeWidth: 2 })) : status === 'error' ? (_jsx(CircleAlert, { strokeWidth: 2 })) : (_jsx(FileText, { strokeWidth: 2 })) }), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1.5", children: [_jsxs("div", { className: "flex items-baseline justify-between gap-3 text-xs", children: [_jsx(Truncate, { at: truncate, className: "font-medium text-neutral-950", children: name }), meta && (_jsx("span", { className: cn('shrink-0 tabular-nums', status === 'error' ? 'text-error-600' : 'text-neutral-600'), children: meta }))] }), status === 'uploading' && (_jsx(Progress, { "aria-label": `${name} upload`, value: progress }))] }), onRemove && (_jsx(Button, { "aria-label": `${status === 'uploading' ? 'Cancel' : 'Remove'} ${name}`, onClick: onRemove, size: "icon-sm", variant: "ghost", children: _jsx(X, { strokeWidth: 2 }) }))] }));
|
|
101
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Menu as MenuPrimitive } from '@base-ui/react/menu';
|
|
2
|
+
import type { VariantProps } from 'class-variance-authority';
|
|
3
|
+
import { type ComponentProps, type ReactNode } from 'react';
|
|
4
|
+
import { type WithClassName } from '../lib/cn.js';
|
|
5
|
+
import { menuItemVariants } from './menu-item.js';
|
|
6
|
+
type PositionProps = Pick<MenuPrimitive.Positioner.Props, 'side' | 'sideOffset' | 'align' | 'alignOffset' | 'collisionPadding'>;
|
|
7
|
+
/** Row-action and account menus (report editor ellipsis, invoice table rows). */
|
|
8
|
+
export declare const DropdownMenu: (props: MenuPrimitive.Root.Props) => import("react").JSX.Element;
|
|
9
|
+
export declare const DropdownMenuTrigger: (props: MenuPrimitive.Trigger.Props) => import("react").JSX.Element;
|
|
10
|
+
export declare const DropdownMenuGroup: (props: MenuPrimitive.Group.Props) => import("react").JSX.Element;
|
|
11
|
+
export declare const DropdownMenuSub: (props: MenuPrimitive.SubmenuRoot.Props) => import("react").JSX.Element;
|
|
12
|
+
export declare const DropdownMenuRadioGroup: (props: MenuPrimitive.RadioGroup.Props) => import("react").JSX.Element;
|
|
13
|
+
export type DropdownMenuContentProps = WithClassName<MenuPrimitive.Popup.Props> & PositionProps & {
|
|
14
|
+
/** Where the menu is portalled; the body by default. */
|
|
15
|
+
container?: MenuPrimitive.Portal.Props['container'];
|
|
16
|
+
};
|
|
17
|
+
export declare const DropdownMenuContent: ({ className, side, sideOffset, align, alignOffset, collisionPadding, container, ...props }: DropdownMenuContentProps) => import("react").JSX.Element;
|
|
18
|
+
export declare const DropdownMenuSubContent: ({ className, side, sideOffset, align, alignOffset, collisionPadding, container, ...props }: DropdownMenuContentProps) => import("react").JSX.Element;
|
|
19
|
+
export type DropdownMenuItemProps = WithClassName<MenuPrimitive.Item.Props> & VariantProps<typeof menuItemVariants>;
|
|
20
|
+
export declare const DropdownMenuItem: ({ variant, className, ...props }: DropdownMenuItemProps) => import("react").JSX.Element;
|
|
21
|
+
export declare const DropdownMenuCheckboxItem: ({ icon, className, children, ...props }: WithClassName<MenuPrimitive.CheckboxItem.Props> & {
|
|
22
|
+
/** A 16px icon before the name, in the row's leading slot like a plain item's. */
|
|
23
|
+
icon?: ReactNode;
|
|
24
|
+
}) => import("react").JSX.Element;
|
|
25
|
+
export declare const DropdownMenuRadioItem: ({ icon, className, children, ...props }: WithClassName<MenuPrimitive.RadioItem.Props> & {
|
|
26
|
+
/** A 16px icon before the name, in the row's leading slot like a plain item's. */
|
|
27
|
+
icon?: ReactNode;
|
|
28
|
+
}) => import("react").JSX.Element;
|
|
29
|
+
export declare const DropdownMenuSubTrigger: ({ icon, className, children, ...props }: WithClassName<MenuPrimitive.SubmenuTrigger.Props> & {
|
|
30
|
+
/** A 16px icon before the name, in the row's leading slot; in the children it would sit over the name. */
|
|
31
|
+
icon?: ReactNode;
|
|
32
|
+
}) => import("react").JSX.Element;
|
|
33
|
+
export declare const DropdownMenuLabel: ({ className, ...props }: ComponentProps<"div">) => import("react").JSX.Element;
|
|
34
|
+
export declare const DropdownMenuSeparator: ({ className, ...props }: WithClassName<MenuPrimitive.Separator.Props>) => import("react").JSX.Element;
|
|
35
|
+
export declare const DropdownMenuShortcut: ({ className, ...props }: ComponentProps<"span">) => import("react").JSX.Element;
|
|
36
|
+
export type DropdownMenuSearchProps = Omit<ComponentProps<'input'>, 'value' | 'onChange'> & {
|
|
37
|
+
value: string;
|
|
38
|
+
onValueChange: (value: string) => void;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* A search at the top of a menu, for one long enough to need it (assign to, move to, add label).
|
|
42
|
+
* No box: a 16px icon and the text, ruled off from the list full width, the icon in line with the
|
|
43
|
+
* rows' icons. It takes focus as the menu opens and keeps its typing from the menu's typeahead;
|
|
44
|
+
* the arrows still move into the list, and Enter runs the first item left. The menu filters its
|
|
45
|
+
* own items by `value`.
|
|
46
|
+
*/
|
|
47
|
+
export declare const DropdownMenuSearch: ({ value, onValueChange, placeholder, className, onKeyDown, ...props }: DropdownMenuSearchProps) => import("react").JSX.Element;
|
|
48
|
+
/** What a searched menu shows when nothing matches. */
|
|
49
|
+
export declare const DropdownMenuEmpty: ({ className, ...props }: ComponentProps<"div">) => import("react").JSX.Element;
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Menu as MenuPrimitive } from '@base-ui/react/menu';
|
|
4
|
+
import { Check, ChevronRight, Search } from 'lucide-react';
|
|
5
|
+
import { createContext, useContext, useEffect, useRef, } from 'react';
|
|
6
|
+
import { cn } from '../lib/cn.js';
|
|
7
|
+
import { MenuItem, menuItemVariants } from './menu-item.js';
|
|
8
|
+
import { ThemeScope, usePortalContainer } from './theme.js';
|
|
9
|
+
const contentClass = [
|
|
10
|
+
'flex max-h-(--available-height) min-w-menu flex-col gap-1 overflow-y-auto rounded-card border border-neutral-200 bg-neutral-50 p-1 shadow-float outline-none',
|
|
11
|
+
// Base UI keeps the popup mounted while it closes, so the same scale and fade play on the way out.
|
|
12
|
+
'origin-(--transform-origin) transition-[opacity,scale] duration-200 ease-out-strong data-ending-style:scale-95 data-starting-style:scale-95 data-ending-style:opacity-0 data-starting-style:opacity-0 motion-reduce:transition-none',
|
|
13
|
+
];
|
|
14
|
+
/*
|
|
15
|
+
* Base UI's GroupLabel throws outside a Group, while a label at the top of a menu is common.
|
|
16
|
+
* The groups below flag their subtree so the label can link itself to a group only when it has one.
|
|
17
|
+
*/
|
|
18
|
+
const InGroupContext = createContext(false);
|
|
19
|
+
/** Row-action and account menus (report editor ellipsis, invoice table rows). */
|
|
20
|
+
export const DropdownMenu = (props) => (_jsx(MenuPrimitive.Root, { "data-slot": "dropdown-menu", ...props }));
|
|
21
|
+
export const DropdownMenuTrigger = (props) => (_jsx(MenuPrimitive.Trigger, { "data-slot": "dropdown-menu-trigger", ...props }));
|
|
22
|
+
export const DropdownMenuGroup = (props) => (_jsx(InGroupContext.Provider, { value: true, children: _jsx(MenuPrimitive.Group, { "data-slot": "dropdown-menu-group", ...props }) }));
|
|
23
|
+
export const DropdownMenuSub = (props) => (_jsx(MenuPrimitive.SubmenuRoot, { "data-slot": "dropdown-menu-sub", ...props }));
|
|
24
|
+
export const DropdownMenuRadioGroup = (props) => (_jsx(InGroupContext.Provider, { value: true, children: _jsx(MenuPrimitive.RadioGroup, { "data-slot": "dropdown-menu-radio-group", ...props }) }));
|
|
25
|
+
export const DropdownMenuContent = ({ className, side, sideOffset = 4, align, alignOffset, collisionPadding, container, ...props }) => (_jsx(MenuPrimitive.Portal, { container: usePortalContainer(container), children: _jsx(ThemeScope, { children: _jsx(MenuPrimitive.Positioner, { align: align, alignOffset: alignOffset, className: "z-50 outline-none", collisionPadding: collisionPadding, "data-slot": "dropdown-menu-positioner", side: side, sideOffset: sideOffset, children: _jsx(MenuPrimitive.Popup, { className: cn(contentClass, className), "data-slot": "dropdown-menu-content", ...props }) }) }) }));
|
|
26
|
+
export const DropdownMenuSubContent = ({ className, side, sideOffset, align, alignOffset, collisionPadding, container, ...props }) => (_jsx(MenuPrimitive.Portal, { container: usePortalContainer(container), children: _jsx(ThemeScope, { children: _jsx(MenuPrimitive.Positioner, { align: align, alignOffset: alignOffset, className: "z-50 outline-none", collisionPadding: collisionPadding, "data-slot": "dropdown-menu-sub-positioner", side: side, sideOffset: sideOffset, children: _jsx(MenuPrimitive.Popup, { className: cn(contentClass, className), "data-slot": "dropdown-menu-sub-content", ...props }) }) }) }));
|
|
27
|
+
export const DropdownMenuItem = ({ variant, className, ...props }) => (_jsx(MenuPrimitive.Item, { className: cn(menuItemVariants({ variant }), className), "data-slot": "dropdown-menu-item", "data-variant": variant ?? 'default', ...props }));
|
|
28
|
+
export const DropdownMenuCheckboxItem = ({ icon, className, children, ...props }) => (_jsx(MenuItem, { className: className, "data-slot": "dropdown-menu-checkbox-item", leading: icon, render: _jsx(MenuPrimitive.CheckboxItem, { ...props }), trailing: _jsx(MenuPrimitive.CheckboxItemIndicator, { className: "flex", children: _jsx(Check, { strokeWidth: 2 }) }), children: children }));
|
|
29
|
+
export const DropdownMenuRadioItem = ({ icon, className, children, ...props }) => (
|
|
30
|
+
// Checked takes the same selected wash as a select's picked option.
|
|
31
|
+
_jsx(MenuItem, { className: cn('data-checked:bg-selected data-checked:text-neutral-950', className), "data-slot": "dropdown-menu-radio-item", leading: icon, render: _jsx(MenuPrimitive.RadioItem, { ...props }), trailing: _jsx(MenuPrimitive.RadioItemIndicator, { className: "flex", children: _jsx(Check, { strokeWidth: 2 }) }), children: children }));
|
|
32
|
+
export const DropdownMenuSubTrigger = ({ icon, className, children, ...props }) => (_jsx(MenuItem, { className: cn('data-popup-open:bg-selected data-popup-open:text-neutral-800', className), "data-slot": "dropdown-menu-sub-trigger", leading: icon, render: _jsx(MenuPrimitive.SubmenuTrigger, { ...props }), trailing: _jsx(ChevronRight, { strokeWidth: 2 }), children: children }));
|
|
33
|
+
const labelClass = 'px-3 pt-1.5 pb-1 font-medium text-neutral-600 text-xxs';
|
|
34
|
+
export const DropdownMenuLabel = ({ className, ...props }) => {
|
|
35
|
+
const inGroup = useContext(InGroupContext);
|
|
36
|
+
// Outside a group the label only titles the menu, so a plain element is enough.
|
|
37
|
+
const Label = inGroup ? MenuPrimitive.GroupLabel : 'div';
|
|
38
|
+
return (_jsx(Label, { className: cn(labelClass, className), "data-slot": "dropdown-menu-label", ...props }));
|
|
39
|
+
};
|
|
40
|
+
export const DropdownMenuSeparator = ({ className, ...props }) => (_jsx(MenuPrimitive.Separator, { className: cn('-mx-1 h-px bg-neutral-200', className), "data-slot": "dropdown-menu-separator", ...props }));
|
|
41
|
+
export const DropdownMenuShortcut = ({ className, ...props }) => (_jsx("span", { className: cn('ml-auto pl-3 font-medium text-neutral-600 text-xxs', className), "data-slot": "dropdown-menu-shortcut", ...props }));
|
|
42
|
+
// The keys a search hands on to the menu: moving into the list, and leaving it.
|
|
43
|
+
const menuKeys = new Set(['ArrowDown', 'ArrowUp', 'Escape', 'Tab']);
|
|
44
|
+
/**
|
|
45
|
+
* A search at the top of a menu, for one long enough to need it (assign to, move to, add label).
|
|
46
|
+
* No box: a 16px icon and the text, ruled off from the list full width, the icon in line with the
|
|
47
|
+
* rows' icons. It takes focus as the menu opens and keeps its typing from the menu's typeahead;
|
|
48
|
+
* the arrows still move into the list, and Enter runs the first item left. The menu filters its
|
|
49
|
+
* own items by `value`.
|
|
50
|
+
*/
|
|
51
|
+
export const DropdownMenuSearch = ({ value, onValueChange, placeholder = 'Search', className, onKeyDown, ...props }) => {
|
|
52
|
+
const ref = useRef(null);
|
|
53
|
+
// The menu focuses its popup as it opens; the search takes it over on the next frame.
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
const frame = requestAnimationFrame(() => ref.current?.focus());
|
|
56
|
+
return () => cancelAnimationFrame(frame);
|
|
57
|
+
}, []);
|
|
58
|
+
const handleKeyDown = (event) => {
|
|
59
|
+
onKeyDown?.(event);
|
|
60
|
+
if (!menuKeys.has(event.key))
|
|
61
|
+
event.stopPropagation();
|
|
62
|
+
// Enter runs the first item left, as a command menu's search does; not while an IME is composing.
|
|
63
|
+
if (event.key === 'Enter' && !event.defaultPrevented && !event.nativeEvent.isComposing) {
|
|
64
|
+
const first = event.currentTarget
|
|
65
|
+
.closest('[data-slot=dropdown-menu-content],[data-slot=dropdown-menu-sub-content]')
|
|
66
|
+
?.querySelector('[role^=menuitem]:not([data-disabled]):not([aria-disabled=true])');
|
|
67
|
+
if (first) {
|
|
68
|
+
event.preventDefault();
|
|
69
|
+
first.click();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
return (_jsxs("div", { className: "-mx-1 -mt-1 flex h-row shrink-0 items-center gap-3 border-neutral-200 border-b px-4 text-neutral-500 [&_svg]:size-4 [&_svg]:shrink-0", "data-slot": "dropdown-menu-search", children: [_jsx(Search, { "aria-hidden": true, strokeWidth: 2 }), _jsx("input", { autoComplete: "off", className: cn(
|
|
74
|
+
// 16px on a touch screen, or iOS zooms the page in when the search takes focus.
|
|
75
|
+
'h-full min-w-0 flex-1 bg-transparent pointer-coarse:text-base text-neutral-950 text-xs outline-none placeholder:text-neutral-600', className), "data-slot": "dropdown-menu-search-input", onChange: event => onValueChange(event.target.value), onKeyDown: handleKeyDown, placeholder: placeholder, ref: ref, spellCheck: false, value: value, ...props })] }));
|
|
76
|
+
};
|
|
77
|
+
/** What a searched menu shows when nothing matches. */
|
|
78
|
+
export const DropdownMenuEmpty = ({ className, ...props }) => (_jsx("div", { className: cn('px-3 py-2.5 text-neutral-600 text-xs', className), "data-slot": "dropdown-menu-empty", ...props }));
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
import { type SelectContentProps } from './select.js';
|
|
3
|
+
import { type TableCellProps } from './table-cell.js';
|
|
4
|
+
export type EditableCellOption = {
|
|
5
|
+
value: string;
|
|
6
|
+
label: ReactNode;
|
|
7
|
+
};
|
|
8
|
+
export type EditableCellProps = Omit<TableCellProps, 'children' | 'onChange' | 'copy' | 'copyLabel'> & {
|
|
9
|
+
value: string;
|
|
10
|
+
/** Called once, with the new value, when an edit is saved (Enter, a click away, or a pick). */
|
|
11
|
+
onValueChange: (value: string) => void;
|
|
12
|
+
/** What the cell is, for its name: "Quantity of Design review". */
|
|
13
|
+
label: string;
|
|
14
|
+
/** How the value reads while it is not being edited; the value itself by default. */
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
/** Picks from a set instead of typing: the cell opens a list under it. */
|
|
17
|
+
options?: readonly EditableCellOption[];
|
|
18
|
+
/** Where the list is portalled; the body by default. */
|
|
19
|
+
container?: SelectContentProps['container'];
|
|
20
|
+
placeholder?: string;
|
|
21
|
+
inputMode?: HTMLAttributes<HTMLInputElement>['inputMode'];
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* A cell that reads as its value and is edited where it sits. Under the pointer it shows the pointer
|
|
25
|
+
* cursor, since a click is what starts the edit. A click (or Enter on it) turns it into a borderless
|
|
26
|
+
* input on the tint wash, the text exactly where it was, so the row keeps its 41, and rings the cell
|
|
27
|
+
* inside its edges in the accent (`primary-500`, 2), so the cell being edited is plain to see. A 20 check at
|
|
28
|
+
* the field's end saves (before the figures in a right-aligned cell); Enter or a click away saves
|
|
29
|
+
* too, Escape puts the value back. With `options`, it opens a list instead
|
|
30
|
+
* and the pick saves. Under the pointer or on focus an editable cell shows a 14 mark at its end, a
|
|
31
|
+
* pencil for a typed value and a chevron for a pick: the one hint that it can change, kept off until
|
|
32
|
+
* asked for so the table still reads as values.
|
|
33
|
+
*/
|
|
34
|
+
export declare const EditableCell: ({ value, onValueChange, label, children, options, container, placeholder, inputMode, className, ...props }: EditableCellProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Select as SelectPrimitive } from '@base-ui/react/select';
|
|
4
|
+
import { Check, ChevronDown, Pencil } from 'lucide-react';
|
|
5
|
+
import { useEffect, useRef, useState } from 'react';
|
|
6
|
+
import { cn } from '../lib/cn.js';
|
|
7
|
+
import { Select, SelectContent, SelectItem } from './select.js';
|
|
8
|
+
import { TableCell } from './table-cell.js';
|
|
9
|
+
// The read state's button covers the whole cell, padding and all, so the cell is the target.
|
|
10
|
+
const stretched = "after:absolute after:inset-0 after:content-['']";
|
|
11
|
+
// The hint that a cell can change: a 14 mark in `neutral-500` at the cell's end, shown under the pointer
|
|
12
|
+
// and on focus (always on a touch screen, which has no pointer to show it); a pick's is a chevron, a
|
|
13
|
+
// typed value's a pencil.
|
|
14
|
+
const hint = 'pointer-coarse:opacity-100 size-3.5 shrink-0 text-neutral-500 opacity-0 transition-opacity duration-150 group-hover/edit:opacity-100 group-focus-visible/edit:opacity-100 group-data-popup-open/edit:opacity-100';
|
|
15
|
+
/**
|
|
16
|
+
* A cell that reads as its value and is edited where it sits. Under the pointer it shows the pointer
|
|
17
|
+
* cursor, since a click is what starts the edit. A click (or Enter on it) turns it into a borderless
|
|
18
|
+
* input on the tint wash, the text exactly where it was, so the row keeps its 41, and rings the cell
|
|
19
|
+
* inside its edges in the accent (`primary-500`, 2), so the cell being edited is plain to see. A 20 check at
|
|
20
|
+
* the field's end saves (before the figures in a right-aligned cell); Enter or a click away saves
|
|
21
|
+
* too, Escape puts the value back. With `options`, it opens a list instead
|
|
22
|
+
* and the pick saves. Under the pointer or on focus an editable cell shows a 14 mark at its end, a
|
|
23
|
+
* pencil for a typed value and a chevron for a pick: the one hint that it can change, kept off until
|
|
24
|
+
* asked for so the table still reads as values.
|
|
25
|
+
*/
|
|
26
|
+
export const EditableCell = ({ value, onValueChange, label, children, options, container, placeholder, inputMode, className, ...props }) => {
|
|
27
|
+
const [editing, setEditing] = useState(false);
|
|
28
|
+
const [draft, setDraft] = useState(value);
|
|
29
|
+
const input = useRef(null);
|
|
30
|
+
const read = useRef(null);
|
|
31
|
+
// Set when an edit ends from the keyboard, so focus goes back to the cell it left.
|
|
32
|
+
const refocus = useRef(false);
|
|
33
|
+
// Ending removes the input, which may blur it again; the edit ends only once.
|
|
34
|
+
const ended = useRef(false);
|
|
35
|
+
const right = (props.align ?? (props.numeric ? 'right' : 'left')) === 'right';
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (editing) {
|
|
38
|
+
input.current?.focus();
|
|
39
|
+
input.current?.select();
|
|
40
|
+
}
|
|
41
|
+
else if (refocus.current) {
|
|
42
|
+
refocus.current = false;
|
|
43
|
+
read.current?.focus();
|
|
44
|
+
}
|
|
45
|
+
}, [editing]);
|
|
46
|
+
const start = () => {
|
|
47
|
+
ended.current = false;
|
|
48
|
+
setDraft(value);
|
|
49
|
+
setEditing(true);
|
|
50
|
+
};
|
|
51
|
+
const end = (save, fromKeyboard) => {
|
|
52
|
+
if (ended.current)
|
|
53
|
+
return;
|
|
54
|
+
ended.current = true;
|
|
55
|
+
if (save && draft !== value)
|
|
56
|
+
onValueChange(draft);
|
|
57
|
+
refocus.current = fromKeyboard;
|
|
58
|
+
setEditing(false);
|
|
59
|
+
};
|
|
60
|
+
const cell = cn(
|
|
61
|
+
// The cell is the target: its button stretches over it. The tint wash while it is edited or its
|
|
62
|
+
// list is open.
|
|
63
|
+
'relative [&:has([data-popup-open])]:bg-tint',
|
|
64
|
+
// Focus on the cell's button rings the whole cell, inside its edges.
|
|
65
|
+
'[&:has(>[data-slot=table-edit-read]:focus-visible)]:outline-2 [&:has(>[data-slot=table-edit-read]:focus-visible)]:outline-focus [&:has(>[data-slot=table-edit-read]:focus-visible)]:outline-solid [&:has(>[data-slot=table-edit-read]:focus-visible)]:-outline-offset-2',
|
|
66
|
+
// The cell being edited: the wash, and the accent's ring inside its edges.
|
|
67
|
+
editing && 'bg-tint outline-2 outline-primary-500 outline-solid -outline-offset-2', className);
|
|
68
|
+
const shown = children ?? (value === '' ? placeholder : value);
|
|
69
|
+
if (options) {
|
|
70
|
+
const picked = options.find(option => option.value === value);
|
|
71
|
+
return (_jsx(TableCell, { className: cn(cell, 'cursor-pointer'), "data-editable": "", ...props, children: _jsxs(Select, { items: options, onValueChange: next => onValueChange(String(next)), value: value, children: [_jsxs(SelectPrimitive.Trigger, { "aria-label": label, className: cn('group/edit flex w-full cursor-pointer items-center gap-1 text-left outline-none', stretched), "data-slot": "table-edit-read", children: [_jsx("span", { className: "min-w-0 flex-1 truncate", children: children ?? picked?.label }), _jsx(ChevronDown, { className: hint, strokeWidth: 2 })] }), _jsx(SelectContent, { alignOffset: -12, container: container, sideOffset: 16, children: options.map(option => (_jsx(SelectItem, { value: option.value, children: option.label }, option.value))) })] }) }));
|
|
72
|
+
}
|
|
73
|
+
return (_jsx(TableCell, { className: cn(cell, !editing && 'cursor-pointer'), "data-editable": "", "data-editing": editing || undefined, ...props, children: editing ? (_jsxs("span", { className: cn('flex items-center gap-2', right && 'flex-row-reverse'), children: [_jsx("input", { "aria-label": label, className: cn(
|
|
74
|
+
// The value's own type and line, so nothing moves between reading and editing.
|
|
75
|
+
'block h-lh w-full min-w-0 bg-transparent p-0 text-inherit outline-none placeholder:font-normal placeholder:text-neutral-500', right && 'text-right'), "data-slot": "table-edit-input", inputMode: inputMode, onBlur: () => end(true, false), onChange: event => setDraft(event.target.value), onKeyDown: event => {
|
|
76
|
+
if (event.key === 'Enter') {
|
|
77
|
+
event.preventDefault();
|
|
78
|
+
end(true, true);
|
|
79
|
+
}
|
|
80
|
+
else if (event.key === 'Escape') {
|
|
81
|
+
event.preventDefault();
|
|
82
|
+
end(false, true);
|
|
83
|
+
}
|
|
84
|
+
}, placeholder: placeholder, ref: input, value: draft }), _jsx("button", { "aria-label": `Save ${label}`, className: "-my-0.5 inline-flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-chip text-neutral-600 transition-colors duration-150 hover:bg-neutral-950/5 hover:text-neutral-950", "data-slot": "table-edit-save",
|
|
85
|
+
// Keep focus in the field, so the click saves once rather than the blur first.
|
|
86
|
+
onMouseDown: event => event.preventDefault(), onClick: () => end(true, false), tabIndex: -1, title: "Save (Enter)", type: "button", children: _jsx(Check, { className: "size-3.5", strokeWidth: 2 }) })] })) : (_jsxs("button", { "aria-label": `${label}: ${value === '' ? 'empty' : value}`, className: cn('group/edit flex w-full cursor-pointer items-center gap-1 text-left outline-none',
|
|
87
|
+
// On a right-aligned cell the pencil goes first, so the figures stay flush.
|
|
88
|
+
right && 'flex-row-reverse text-right', stretched), "data-slot": "table-edit-read", onClick: start, ref: read, type: "button", children: [_jsx("span", { className: cn('min-w-0 flex-1 truncate', value === '' && 'font-normal text-neutral-500'), children: shown }), _jsx(Pencil, { className: hint, strokeWidth: 2 })] })) }));
|
|
89
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ComponentProps, ReactNode } from 'react';
|
|
2
|
+
export type EmptyStateProps = Omit<ComponentProps<'div'>, 'title'> & {
|
|
3
|
+
/** A 16px icon for what would be here, in a tile; no illustrations. */
|
|
4
|
+
icon?: ReactNode;
|
|
5
|
+
/** What would be here: "No invoices yet". */
|
|
6
|
+
title: ReactNode;
|
|
7
|
+
/** One sentence on how it fills, or why it is empty now. */
|
|
8
|
+
description?: ReactNode;
|
|
9
|
+
/** One action, usually a secondary Button; a filter that matched nothing offers to clear it. */
|
|
10
|
+
action?: ReactNode;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Where a list or a section would be, before there is anything in it: a dashed, left-aligned panel
|
|
14
|
+
* with what goes here, a sentence and one action. It holds the place at the content's width, so the
|
|
15
|
+
* page does not jump when the first record arrives.
|
|
16
|
+
*/
|
|
17
|
+
export declare const EmptyState: ({ icon, title, description, action, className, children, ...props }: EmptyStateProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from '../lib/cn.js';
|
|
3
|
+
import { IconTile } from './icon-tile.js';
|
|
4
|
+
/**
|
|
5
|
+
* Where a list or a section would be, before there is anything in it: a dashed, left-aligned panel
|
|
6
|
+
* with what goes here, a sentence and one action. It holds the place at the content's width, so the
|
|
7
|
+
* page does not jump when the first record arrives.
|
|
8
|
+
*/
|
|
9
|
+
export const EmptyState = ({ icon, title, description, action, className, children, ...props }) => (_jsxs("div", { className: cn('flex flex-col items-start gap-4 rounded-panel border border-neutral-200 border-dashed p-6', className), "data-slot": "empty-state", ...props, children: [icon && _jsx(IconTile, { children: icon }), _jsxs("div", { className: "flex max-w-measure flex-col gap-1", "data-slot": "empty-state-text", children: [_jsx("p", { className: "font-medium text-neutral-950 text-xs", children: title }), description && _jsx("p", { className: "text-neutral-600 text-xs", children: description })] }), children, action && (_jsx("div", { className: "flex flex-wrap items-center gap-2", "data-slot": "empty-state-action", children: action }))] }));
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
2
|
+
import { type ComponentProps } from 'react';
|
|
3
|
+
type FieldContextValue = {
|
|
4
|
+
id: string;
|
|
5
|
+
labelId: string;
|
|
6
|
+
helperId: string | undefined;
|
|
7
|
+
setHelperId: (helperId: string | undefined) => void;
|
|
8
|
+
invalid: boolean;
|
|
9
|
+
disabled: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare const FieldContext: import("react").Context<FieldContextValue | null>;
|
|
12
|
+
export declare const useField: () => FieldContextValue | null;
|
|
13
|
+
/**
|
|
14
|
+
* What a control inside a Field picks up: its id, the helper it is described by
|
|
15
|
+
* and the invalid/disabled state. Props passed to the control win.
|
|
16
|
+
*/
|
|
17
|
+
export declare const useFieldControl: ({ id, disabled, "aria-describedby": describedBy, "aria-invalid": ariaInvalid, }: {
|
|
18
|
+
id?: string;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
"aria-describedby"?: string;
|
|
21
|
+
"aria-invalid"?: boolean | "true" | "false" | "grammar" | "spelling";
|
|
22
|
+
}) => {
|
|
23
|
+
id: string | undefined;
|
|
24
|
+
disabled: boolean | undefined;
|
|
25
|
+
'aria-describedby': string | undefined;
|
|
26
|
+
'aria-invalid': true | undefined;
|
|
27
|
+
invalid: boolean;
|
|
28
|
+
};
|
|
29
|
+
type FieldProps = ComponentProps<'div'> & {
|
|
30
|
+
invalid?: boolean;
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
};
|
|
33
|
+
/** Label, control and helper text stacked, as in the library's input wrapper. */
|
|
34
|
+
export declare const Field: ({ invalid, disabled, className, ...props }: FieldProps) => import("react").JSX.Element;
|
|
35
|
+
type FieldLabelProps = useRender.ComponentProps<'label'>;
|
|
36
|
+
/**
|
|
37
|
+
* A plain label tied to the Field's control by htmlFor, so any control, native or
|
|
38
|
+
* Base UI, is named without a primitive in between. `render` swaps the element.
|
|
39
|
+
*/
|
|
40
|
+
export declare const FieldLabel: ({ className, htmlFor, id, render, ...props }: FieldLabelProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
41
|
+
/** Follows the input like the library's helper: darker on hover and while typing. */
|
|
42
|
+
export declare const FieldHelper: ({ className, id, ...props }: ComponentProps<"p">) => import("react").JSX.Element;
|
|
43
|
+
export {};
|