@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,351 @@
|
|
|
1
|
+
// biome-ignore-all lint/suspicious/noApproximativeNumericConstant: Tailwind's own measured values, not stand-ins for a constant.
|
|
2
|
+
/*
|
|
3
|
+
* Tailwind CSS 4.3.3's default palette, as oklch triples [lightness 0–1, chroma, hue] for the steps 50 to
|
|
4
|
+
* 950. The ramp engine in color.ts reads its curves off these: the lightness, the share of the gamut and
|
|
5
|
+
* the hue drift of every step, by hue. Generated from tailwindcss/theme.css (MIT, Tailwind Labs); do not
|
|
6
|
+
* edit by hand.
|
|
7
|
+
*/
|
|
8
|
+
/** The seventeen chromatic families. */
|
|
9
|
+
export const tailwindHues = {
|
|
10
|
+
red: [
|
|
11
|
+
[0.971, 0.013, 17.38],
|
|
12
|
+
[0.936, 0.032, 17.717],
|
|
13
|
+
[0.885, 0.062, 18.334],
|
|
14
|
+
[0.808, 0.114, 19.571],
|
|
15
|
+
[0.704, 0.191, 22.216],
|
|
16
|
+
[0.637, 0.237, 25.331],
|
|
17
|
+
[0.577, 0.245, 27.325],
|
|
18
|
+
[0.505, 0.213, 27.518],
|
|
19
|
+
[0.444, 0.177, 26.899],
|
|
20
|
+
[0.396, 0.141, 25.723],
|
|
21
|
+
[0.258, 0.092, 26.042],
|
|
22
|
+
],
|
|
23
|
+
orange: [
|
|
24
|
+
[0.98, 0.016, 73.684],
|
|
25
|
+
[0.954, 0.038, 75.164],
|
|
26
|
+
[0.901, 0.076, 70.697],
|
|
27
|
+
[0.837, 0.128, 66.29],
|
|
28
|
+
[0.75, 0.183, 55.934],
|
|
29
|
+
[0.705, 0.213, 47.604],
|
|
30
|
+
[0.646, 0.222, 41.116],
|
|
31
|
+
[0.553, 0.195, 38.402],
|
|
32
|
+
[0.47, 0.157, 37.304],
|
|
33
|
+
[0.408, 0.123, 38.172],
|
|
34
|
+
[0.266, 0.079, 36.259],
|
|
35
|
+
],
|
|
36
|
+
amber: [
|
|
37
|
+
[0.987, 0.022, 95.277],
|
|
38
|
+
[0.962, 0.059, 95.617],
|
|
39
|
+
[0.924, 0.12, 95.746],
|
|
40
|
+
[0.879, 0.169, 91.605],
|
|
41
|
+
[0.828, 0.189, 84.429],
|
|
42
|
+
[0.769, 0.188, 70.08],
|
|
43
|
+
[0.666, 0.179, 58.318],
|
|
44
|
+
[0.555, 0.163, 48.998],
|
|
45
|
+
[0.473, 0.137, 46.201],
|
|
46
|
+
[0.414, 0.112, 45.904],
|
|
47
|
+
[0.279, 0.077, 45.635],
|
|
48
|
+
],
|
|
49
|
+
yellow: [
|
|
50
|
+
[0.987, 0.026, 102.212],
|
|
51
|
+
[0.973, 0.071, 103.193],
|
|
52
|
+
[0.945, 0.129, 101.54],
|
|
53
|
+
[0.905, 0.182, 98.111],
|
|
54
|
+
[0.852, 0.199, 91.936],
|
|
55
|
+
[0.795, 0.184, 86.047],
|
|
56
|
+
[0.681, 0.162, 75.834],
|
|
57
|
+
[0.554, 0.135, 66.442],
|
|
58
|
+
[0.476, 0.114, 61.907],
|
|
59
|
+
[0.421, 0.095, 57.708],
|
|
60
|
+
[0.286, 0.066, 53.813],
|
|
61
|
+
],
|
|
62
|
+
lime: [
|
|
63
|
+
[0.986, 0.031, 120.757],
|
|
64
|
+
[0.967, 0.067, 122.328],
|
|
65
|
+
[0.938, 0.127, 124.321],
|
|
66
|
+
[0.897, 0.196, 126.665],
|
|
67
|
+
[0.841, 0.238, 128.85],
|
|
68
|
+
[0.768, 0.233, 130.85],
|
|
69
|
+
[0.648, 0.2, 131.684],
|
|
70
|
+
[0.532, 0.157, 131.589],
|
|
71
|
+
[0.453, 0.124, 130.933],
|
|
72
|
+
[0.405, 0.101, 131.063],
|
|
73
|
+
[0.274, 0.072, 132.109],
|
|
74
|
+
],
|
|
75
|
+
green: [
|
|
76
|
+
[0.982, 0.018, 155.826],
|
|
77
|
+
[0.962, 0.044, 156.743],
|
|
78
|
+
[0.925, 0.084, 155.995],
|
|
79
|
+
[0.871, 0.15, 154.449],
|
|
80
|
+
[0.792, 0.209, 151.711],
|
|
81
|
+
[0.723, 0.219, 149.579],
|
|
82
|
+
[0.627, 0.194, 149.214],
|
|
83
|
+
[0.527, 0.154, 150.069],
|
|
84
|
+
[0.448, 0.119, 151.328],
|
|
85
|
+
[0.393, 0.095, 152.535],
|
|
86
|
+
[0.266, 0.065, 152.934],
|
|
87
|
+
],
|
|
88
|
+
emerald: [
|
|
89
|
+
[0.979, 0.021, 166.113],
|
|
90
|
+
[0.95, 0.052, 163.051],
|
|
91
|
+
[0.905, 0.093, 164.15],
|
|
92
|
+
[0.845, 0.143, 164.978],
|
|
93
|
+
[0.765, 0.177, 163.223],
|
|
94
|
+
[0.696, 0.17, 162.48],
|
|
95
|
+
[0.596, 0.145, 163.225],
|
|
96
|
+
[0.508, 0.118, 165.612],
|
|
97
|
+
[0.432, 0.095, 166.913],
|
|
98
|
+
[0.378, 0.077, 168.94],
|
|
99
|
+
[0.262, 0.051, 172.552],
|
|
100
|
+
],
|
|
101
|
+
teal: [
|
|
102
|
+
[0.984, 0.014, 180.72],
|
|
103
|
+
[0.953, 0.051, 180.801],
|
|
104
|
+
[0.91, 0.096, 180.426],
|
|
105
|
+
[0.855, 0.138, 181.071],
|
|
106
|
+
[0.777, 0.152, 181.912],
|
|
107
|
+
[0.704, 0.14, 182.503],
|
|
108
|
+
[0.6, 0.118, 184.704],
|
|
109
|
+
[0.511, 0.096, 186.391],
|
|
110
|
+
[0.437, 0.078, 188.216],
|
|
111
|
+
[0.386, 0.063, 188.416],
|
|
112
|
+
[0.277, 0.046, 192.524],
|
|
113
|
+
],
|
|
114
|
+
cyan: [
|
|
115
|
+
[0.984, 0.019, 200.873],
|
|
116
|
+
[0.956, 0.045, 203.388],
|
|
117
|
+
[0.917, 0.08, 205.041],
|
|
118
|
+
[0.865, 0.127, 207.078],
|
|
119
|
+
[0.789, 0.154, 211.53],
|
|
120
|
+
[0.715, 0.143, 215.221],
|
|
121
|
+
[0.609, 0.126, 221.723],
|
|
122
|
+
[0.52, 0.105, 223.128],
|
|
123
|
+
[0.45, 0.085, 224.283],
|
|
124
|
+
[0.398, 0.07, 227.392],
|
|
125
|
+
[0.302, 0.056, 229.695],
|
|
126
|
+
],
|
|
127
|
+
sky: [
|
|
128
|
+
[0.977, 0.013, 236.62],
|
|
129
|
+
[0.951, 0.026, 236.824],
|
|
130
|
+
[0.901, 0.058, 230.902],
|
|
131
|
+
[0.828, 0.111, 230.318],
|
|
132
|
+
[0.746, 0.16, 232.661],
|
|
133
|
+
[0.685, 0.169, 237.323],
|
|
134
|
+
[0.588, 0.158, 241.966],
|
|
135
|
+
[0.5, 0.134, 242.749],
|
|
136
|
+
[0.443, 0.11, 240.79],
|
|
137
|
+
[0.391, 0.09, 240.876],
|
|
138
|
+
[0.293, 0.066, 243.157],
|
|
139
|
+
],
|
|
140
|
+
blue: [
|
|
141
|
+
[0.97, 0.014, 254.604],
|
|
142
|
+
[0.932, 0.032, 255.585],
|
|
143
|
+
[0.882, 0.059, 254.128],
|
|
144
|
+
[0.809, 0.105, 251.813],
|
|
145
|
+
[0.707, 0.165, 254.624],
|
|
146
|
+
[0.623, 0.214, 259.815],
|
|
147
|
+
[0.546, 0.245, 262.881],
|
|
148
|
+
[0.488, 0.243, 264.376],
|
|
149
|
+
[0.424, 0.199, 265.638],
|
|
150
|
+
[0.379, 0.146, 265.522],
|
|
151
|
+
[0.282, 0.091, 267.935],
|
|
152
|
+
],
|
|
153
|
+
indigo: [
|
|
154
|
+
[0.962, 0.018, 272.314],
|
|
155
|
+
[0.93, 0.034, 272.788],
|
|
156
|
+
[0.87, 0.065, 274.039],
|
|
157
|
+
[0.785, 0.115, 274.713],
|
|
158
|
+
[0.673, 0.182, 276.935],
|
|
159
|
+
[0.585, 0.233, 277.117],
|
|
160
|
+
[0.511, 0.262, 276.966],
|
|
161
|
+
[0.457, 0.24, 277.023],
|
|
162
|
+
[0.398, 0.195, 277.366],
|
|
163
|
+
[0.359, 0.144, 278.697],
|
|
164
|
+
[0.257, 0.09, 281.288],
|
|
165
|
+
],
|
|
166
|
+
violet: [
|
|
167
|
+
[0.969, 0.016, 293.756],
|
|
168
|
+
[0.943, 0.029, 294.588],
|
|
169
|
+
[0.894, 0.057, 293.283],
|
|
170
|
+
[0.811, 0.111, 293.571],
|
|
171
|
+
[0.702, 0.183, 293.541],
|
|
172
|
+
[0.606, 0.25, 292.717],
|
|
173
|
+
[0.541, 0.281, 293.009],
|
|
174
|
+
[0.491, 0.27, 292.581],
|
|
175
|
+
[0.432, 0.232, 292.759],
|
|
176
|
+
[0.38, 0.189, 293.745],
|
|
177
|
+
[0.283, 0.141, 291.089],
|
|
178
|
+
],
|
|
179
|
+
purple: [
|
|
180
|
+
[0.977, 0.014, 308.299],
|
|
181
|
+
[0.946, 0.033, 307.174],
|
|
182
|
+
[0.902, 0.063, 306.703],
|
|
183
|
+
[0.827, 0.119, 306.383],
|
|
184
|
+
[0.714, 0.203, 305.504],
|
|
185
|
+
[0.627, 0.265, 303.9],
|
|
186
|
+
[0.558, 0.288, 302.321],
|
|
187
|
+
[0.496, 0.265, 301.924],
|
|
188
|
+
[0.438, 0.218, 303.724],
|
|
189
|
+
[0.381, 0.176, 304.987],
|
|
190
|
+
[0.291, 0.149, 302.717],
|
|
191
|
+
],
|
|
192
|
+
fuchsia: [
|
|
193
|
+
[0.977, 0.017, 320.058],
|
|
194
|
+
[0.952, 0.037, 318.852],
|
|
195
|
+
[0.903, 0.076, 319.62],
|
|
196
|
+
[0.833, 0.145, 321.434],
|
|
197
|
+
[0.74, 0.238, 322.16],
|
|
198
|
+
[0.667, 0.295, 322.15],
|
|
199
|
+
[0.591, 0.293, 322.896],
|
|
200
|
+
[0.518, 0.253, 323.949],
|
|
201
|
+
[0.452, 0.211, 324.591],
|
|
202
|
+
[0.401, 0.17, 325.612],
|
|
203
|
+
[0.293, 0.136, 325.661],
|
|
204
|
+
],
|
|
205
|
+
pink: [
|
|
206
|
+
[0.971, 0.014, 343.198],
|
|
207
|
+
[0.948, 0.028, 342.258],
|
|
208
|
+
[0.899, 0.061, 343.231],
|
|
209
|
+
[0.823, 0.12, 346.018],
|
|
210
|
+
[0.718, 0.202, 349.761],
|
|
211
|
+
[0.656, 0.241, 354.308],
|
|
212
|
+
[0.592, 0.249, 0.584],
|
|
213
|
+
[0.525, 0.223, 3.958],
|
|
214
|
+
[0.459, 0.187, 3.815],
|
|
215
|
+
[0.408, 0.153, 2.432],
|
|
216
|
+
[0.284, 0.109, 3.907],
|
|
217
|
+
],
|
|
218
|
+
rose: [
|
|
219
|
+
[0.969, 0.015, 12.422],
|
|
220
|
+
[0.941, 0.03, 12.58],
|
|
221
|
+
[0.892, 0.058, 10.001],
|
|
222
|
+
[0.81, 0.117, 11.638],
|
|
223
|
+
[0.712, 0.194, 13.428],
|
|
224
|
+
[0.645, 0.246, 16.439],
|
|
225
|
+
[0.586, 0.253, 17.585],
|
|
226
|
+
[0.514, 0.222, 16.935],
|
|
227
|
+
[0.455, 0.188, 13.697],
|
|
228
|
+
[0.41, 0.159, 10.272],
|
|
229
|
+
[0.271, 0.105, 12.094],
|
|
230
|
+
],
|
|
231
|
+
};
|
|
232
|
+
/** The greys, achromatic or faintly tinted. */
|
|
233
|
+
export const tailwindGreys = {
|
|
234
|
+
slate: [
|
|
235
|
+
[0.984, 0.003, 247.858],
|
|
236
|
+
[0.968, 0.007, 247.896],
|
|
237
|
+
[0.929, 0.013, 255.508],
|
|
238
|
+
[0.869, 0.022, 252.894],
|
|
239
|
+
[0.704, 0.04, 256.788],
|
|
240
|
+
[0.554, 0.046, 257.417],
|
|
241
|
+
[0.446, 0.043, 257.281],
|
|
242
|
+
[0.372, 0.044, 257.287],
|
|
243
|
+
[0.279, 0.041, 260.031],
|
|
244
|
+
[0.208, 0.042, 265.755],
|
|
245
|
+
[0.129, 0.042, 264.695],
|
|
246
|
+
],
|
|
247
|
+
gray: [
|
|
248
|
+
[0.985, 0.002, 247.839],
|
|
249
|
+
[0.967, 0.003, 264.542],
|
|
250
|
+
[0.928, 0.006, 264.531],
|
|
251
|
+
[0.872, 0.01, 258.338],
|
|
252
|
+
[0.707, 0.022, 261.325],
|
|
253
|
+
[0.551, 0.027, 264.364],
|
|
254
|
+
[0.446, 0.03, 256.802],
|
|
255
|
+
[0.373, 0.034, 259.733],
|
|
256
|
+
[0.278, 0.033, 256.848],
|
|
257
|
+
[0.21, 0.034, 264.665],
|
|
258
|
+
[0.13, 0.028, 261.692],
|
|
259
|
+
],
|
|
260
|
+
zinc: [
|
|
261
|
+
[0.985, 0, 0],
|
|
262
|
+
[0.967, 0.001, 286.375],
|
|
263
|
+
[0.92, 0.004, 286.32],
|
|
264
|
+
[0.871, 0.006, 286.286],
|
|
265
|
+
[0.705, 0.015, 286.067],
|
|
266
|
+
[0.552, 0.016, 285.938],
|
|
267
|
+
[0.442, 0.017, 285.786],
|
|
268
|
+
[0.37, 0.013, 285.805],
|
|
269
|
+
[0.274, 0.006, 286.033],
|
|
270
|
+
[0.21, 0.006, 285.885],
|
|
271
|
+
[0.141, 0.005, 285.823],
|
|
272
|
+
],
|
|
273
|
+
neutral: [
|
|
274
|
+
[0.985, 0, 0],
|
|
275
|
+
[0.97, 0, 0],
|
|
276
|
+
[0.922, 0, 0],
|
|
277
|
+
[0.87, 0, 0],
|
|
278
|
+
[0.708, 0, 0],
|
|
279
|
+
[0.556, 0, 0],
|
|
280
|
+
[0.439, 0, 0],
|
|
281
|
+
[0.371, 0, 0],
|
|
282
|
+
[0.269, 0, 0],
|
|
283
|
+
[0.205, 0, 0],
|
|
284
|
+
[0.145, 0, 0],
|
|
285
|
+
],
|
|
286
|
+
stone: [
|
|
287
|
+
[0.985, 0.001, 106.423],
|
|
288
|
+
[0.97, 0.001, 106.424],
|
|
289
|
+
[0.923, 0.003, 48.717],
|
|
290
|
+
[0.869, 0.005, 56.366],
|
|
291
|
+
[0.709, 0.01, 56.259],
|
|
292
|
+
[0.553, 0.013, 58.071],
|
|
293
|
+
[0.444, 0.011, 73.639],
|
|
294
|
+
[0.374, 0.01, 67.558],
|
|
295
|
+
[0.268, 0.007, 34.298],
|
|
296
|
+
[0.216, 0.006, 56.043],
|
|
297
|
+
[0.147, 0.004, 49.25],
|
|
298
|
+
],
|
|
299
|
+
mauve: [
|
|
300
|
+
[0.985, 0, 0],
|
|
301
|
+
[0.96, 0.003, 325.6],
|
|
302
|
+
[0.922, 0.005, 325.62],
|
|
303
|
+
[0.865, 0.012, 325.68],
|
|
304
|
+
[0.711, 0.019, 323.02],
|
|
305
|
+
[0.542, 0.034, 322.5],
|
|
306
|
+
[0.435, 0.029, 321.78],
|
|
307
|
+
[0.364, 0.029, 323.89],
|
|
308
|
+
[0.263, 0.024, 320.12],
|
|
309
|
+
[0.212, 0.019, 322.12],
|
|
310
|
+
[0.145, 0.008, 326],
|
|
311
|
+
],
|
|
312
|
+
olive: [
|
|
313
|
+
[0.988, 0.003, 106.5],
|
|
314
|
+
[0.966, 0.005, 106.5],
|
|
315
|
+
[0.93, 0.007, 106.5],
|
|
316
|
+
[0.88, 0.011, 106.6],
|
|
317
|
+
[0.737, 0.021, 106.9],
|
|
318
|
+
[0.58, 0.031, 107.3],
|
|
319
|
+
[0.466, 0.025, 107.3],
|
|
320
|
+
[0.394, 0.023, 107.4],
|
|
321
|
+
[0.286, 0.016, 107.4],
|
|
322
|
+
[0.228, 0.013, 107.4],
|
|
323
|
+
[0.153, 0.006, 107.1],
|
|
324
|
+
],
|
|
325
|
+
mist: [
|
|
326
|
+
[0.987, 0.002, 197.1],
|
|
327
|
+
[0.963, 0.002, 197.1],
|
|
328
|
+
[0.925, 0.005, 214.3],
|
|
329
|
+
[0.872, 0.007, 219.6],
|
|
330
|
+
[0.723, 0.014, 214.4],
|
|
331
|
+
[0.56, 0.021, 213.5],
|
|
332
|
+
[0.45, 0.017, 213.2],
|
|
333
|
+
[0.378, 0.015, 216],
|
|
334
|
+
[0.275, 0.011, 216.9],
|
|
335
|
+
[0.218, 0.008, 223.9],
|
|
336
|
+
[0.148, 0.004, 228.8],
|
|
337
|
+
],
|
|
338
|
+
taupe: [
|
|
339
|
+
[0.986, 0.002, 67.8],
|
|
340
|
+
[0.96, 0.002, 17.2],
|
|
341
|
+
[0.922, 0.005, 34.3],
|
|
342
|
+
[0.868, 0.007, 39.5],
|
|
343
|
+
[0.714, 0.014, 41.2],
|
|
344
|
+
[0.547, 0.021, 43.1],
|
|
345
|
+
[0.438, 0.017, 39.3],
|
|
346
|
+
[0.367, 0.016, 35.7],
|
|
347
|
+
[0.268, 0.011, 36.5],
|
|
348
|
+
[0.214, 0.009, 43.1],
|
|
349
|
+
[0.147, 0.004, 49.3],
|
|
350
|
+
],
|
|
351
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The end of `text` that a middle truncation keeps whole, so the part that tells one name from the
|
|
3
|
+
* next always shows:
|
|
4
|
+
* - a path keeps its last part (`/donut-chart.tsx`), or that part's file-name end when it is long;
|
|
5
|
+
* - a file name keeps its extension and the last word before it (`-final.pdf`);
|
|
6
|
+
* - a hash or an ID keeps its last 4 characters (`9c1b`), as it is read and compared;
|
|
7
|
+
* - other text keeps its last word, or 8 characters.
|
|
8
|
+
*/
|
|
9
|
+
export declare const truncationTail: (text: string) => string;
|
|
10
|
+
/**
|
|
11
|
+
* `text` split for a middle truncation: the `head` that narrows to an ellipsis and the `tail` kept
|
|
12
|
+
* whole. `end` is how many characters the tail keeps; left out, `truncationTail` decides by the
|
|
13
|
+
* kind of string. A text too short to cut has an empty tail.
|
|
14
|
+
*/
|
|
15
|
+
export declare const splitForTruncation: (text: string, end?: number) => {
|
|
16
|
+
head: string;
|
|
17
|
+
tail: string;
|
|
18
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Where a name is cut when it is truncated in the middle: the end it keeps whole, worked out from
|
|
3
|
+
* what kind of string it is. The start is never counted here; it fills whatever width is left.
|
|
4
|
+
*/
|
|
5
|
+
// A file extension: a dot, then 1–6 letters or digits with at least one letter (".pdf", ".mp4",
|
|
6
|
+
// ".tar"), so a version ("v1.2") or an amount ("4.50") is not read as one.
|
|
7
|
+
const extension = /\.(?=[a-z0-9]{0,5}[a-z])[a-z0-9]{1,6}$/i;
|
|
8
|
+
// Where a name is naturally broken: the start of the tail is moved back to one of these.
|
|
9
|
+
const separators = /[-_ .]/;
|
|
10
|
+
// A path's last part is kept whole when it is no longer than this; longer, it is cut as a file name.
|
|
11
|
+
const segmentMax = 24;
|
|
12
|
+
/** The last piece of `stem` from a separator between `min` and `max` characters from its end. */
|
|
13
|
+
const piece = (stem, min, max, fallback) => {
|
|
14
|
+
for (let n = min; n <= Math.min(max, stem.length - 1); n++) {
|
|
15
|
+
if (separators.test(stem[stem.length - n] ?? '')) {
|
|
16
|
+
return stem.slice(-n);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const n = Math.min(fallback, stem.length - 1);
|
|
20
|
+
return n > 0 ? stem.slice(-n) : '';
|
|
21
|
+
};
|
|
22
|
+
/** The end of a file name kept whole: its extension and the last word of its name. */
|
|
23
|
+
const fileTail = (name) => {
|
|
24
|
+
const ext = name.match(extension)?.[0];
|
|
25
|
+
if (!ext || ext.length >= name.length) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const stem = name.slice(0, -ext.length);
|
|
29
|
+
return piece(stem, 3, 10, 6) + ext;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* The end of `text` that a middle truncation keeps whole, so the part that tells one name from the
|
|
33
|
+
* next always shows:
|
|
34
|
+
* - a path keeps its last part (`/donut-chart.tsx`), or that part's file-name end when it is long;
|
|
35
|
+
* - a file name keeps its extension and the last word before it (`-final.pdf`);
|
|
36
|
+
* - a hash or an ID keeps its last 4 characters (`9c1b`), as it is read and compared;
|
|
37
|
+
* - other text keeps its last word, or 8 characters.
|
|
38
|
+
*/
|
|
39
|
+
export const truncationTail = (text) => {
|
|
40
|
+
const slash = Math.max(text.lastIndexOf('/'), text.lastIndexOf('\\'));
|
|
41
|
+
if (slash >= 0 && slash < text.length - 1) {
|
|
42
|
+
const segment = text.slice(slash);
|
|
43
|
+
if (segment.length <= segmentMax) {
|
|
44
|
+
return segment;
|
|
45
|
+
}
|
|
46
|
+
return fileTail(segment) ?? segment.slice(-8);
|
|
47
|
+
}
|
|
48
|
+
const file = fileTail(text);
|
|
49
|
+
if (file) {
|
|
50
|
+
return file;
|
|
51
|
+
}
|
|
52
|
+
if (!/\s/.test(text)) {
|
|
53
|
+
return text.slice(-4);
|
|
54
|
+
}
|
|
55
|
+
return piece(text, 4, 14, 8);
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* `text` split for a middle truncation: the `head` that narrows to an ellipsis and the `tail` kept
|
|
59
|
+
* whole. `end` is how many characters the tail keeps; left out, `truncationTail` decides by the
|
|
60
|
+
* kind of string. A text too short to cut has an empty tail.
|
|
61
|
+
*/
|
|
62
|
+
export const splitForTruncation = (text, end) => {
|
|
63
|
+
const tail = end === undefined ? truncationTail(text) : end > 0 ? text.slice(-end) : '';
|
|
64
|
+
// Cutting only pays when the head keeps a few characters of its own beside the ellipsis.
|
|
65
|
+
if (tail.length === 0 || text.length - tail.length < 4) {
|
|
66
|
+
return { head: text, tail: '' };
|
|
67
|
+
}
|
|
68
|
+
return { head: text.slice(0, text.length - tail.length), tail };
|
|
69
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base UI's ToggleGroup hands back an empty array when the pressed item is
|
|
3
|
+
* clicked again, which would leave the group empty. Segmented controls and the dock must always keep one value.
|
|
4
|
+
*/
|
|
5
|
+
export declare const useSingleValue: (value: string | undefined, defaultValue: string | undefined, onValueChange: ((value: string) => void) | undefined) => readonly [string, (next: string) => void];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Base UI's ToggleGroup hands back an empty array when the pressed item is
|
|
5
|
+
* clicked again, which would leave the group empty. Segmented controls and the dock must always keep one value.
|
|
6
|
+
*/
|
|
7
|
+
export const useSingleValue = (value, defaultValue, onValueChange) => {
|
|
8
|
+
const [uncontrolled, setUncontrolled] = useState(defaultValue ?? '');
|
|
9
|
+
const select = (next) => {
|
|
10
|
+
if (!next)
|
|
11
|
+
return;
|
|
12
|
+
if (value === undefined)
|
|
13
|
+
setUncontrolled(next);
|
|
14
|
+
onValueChange?.(next);
|
|
15
|
+
};
|
|
16
|
+
return [value ?? uncontrolled, select];
|
|
17
|
+
};
|