@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,25 @@
|
|
|
1
|
+
import { type CSSProperties } from 'react';
|
|
2
|
+
export declare const useOverflowScroll: <T extends HTMLElement>() => {
|
|
3
|
+
ref: import("react").Dispatch<import("react").SetStateAction<T | null>>;
|
|
4
|
+
edges: {
|
|
5
|
+
start: boolean;
|
|
6
|
+
end: boolean;
|
|
7
|
+
overflows: boolean;
|
|
8
|
+
};
|
|
9
|
+
step: (direction: -1 | 1) => void | undefined;
|
|
10
|
+
reveal: (selector: string) => void;
|
|
11
|
+
style: CSSProperties;
|
|
12
|
+
};
|
|
13
|
+
type OverflowChevronProps = {
|
|
14
|
+
direction: -1 | 1;
|
|
15
|
+
/** At the end it points to, so there is nothing that way. */
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
onStep: (direction: -1 | 1) => void;
|
|
18
|
+
className?: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* The pointer's way along the row. Out of the tab order: keyboard focus already scrolls the item
|
|
22
|
+
* it lands on into view.
|
|
23
|
+
*/
|
|
24
|
+
export declare const OverflowChevron: ({ direction, disabled, onStep, className, }: OverflowChevronProps) => import("react").JSX.Element;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ChevronLeft, ChevronRight } from 'lucide-react';
|
|
3
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
4
|
+
import { cn } from './cn.js';
|
|
5
|
+
/*
|
|
6
|
+
* A row that can outgrow its width (a dock, the top nav's sections) scrolls sideways with its
|
|
7
|
+
* scrollbar hidden, and says which way there is more: a chevron either side steps it along, the
|
|
8
|
+
* one at an end it has reached disabled rather than gone so the row does not shift, and an edge
|
|
9
|
+
* with more fades so the cut-off item reads as cut off rather than as the end. A row that fits
|
|
10
|
+
* has no chevrons at all.
|
|
11
|
+
*/
|
|
12
|
+
const fade = 16;
|
|
13
|
+
export const useOverflowScroll = () => {
|
|
14
|
+
const [node, setNode] = useState(null);
|
|
15
|
+
const [edges, setEdges] = useState({ start: false, end: false, overflows: false });
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (!node)
|
|
18
|
+
return;
|
|
19
|
+
const update = () => {
|
|
20
|
+
const overflows = node.scrollWidth > node.clientWidth + 1;
|
|
21
|
+
const start = node.scrollLeft > 1;
|
|
22
|
+
const end = node.scrollLeft + node.clientWidth < node.scrollWidth - 1;
|
|
23
|
+
setEdges(current => current.start === start && current.end === end && current.overflows === overflows
|
|
24
|
+
? current
|
|
25
|
+
: { start, end, overflows });
|
|
26
|
+
};
|
|
27
|
+
update();
|
|
28
|
+
node.addEventListener('scroll', update, { passive: true });
|
|
29
|
+
// The row and its items both change size: a resize, a label, a font that loads late.
|
|
30
|
+
const observer = new ResizeObserver(update);
|
|
31
|
+
observer.observe(node);
|
|
32
|
+
for (const child of node.children)
|
|
33
|
+
observer.observe(child);
|
|
34
|
+
return () => {
|
|
35
|
+
node.removeEventListener('scroll', update);
|
|
36
|
+
observer.disconnect();
|
|
37
|
+
};
|
|
38
|
+
}, [node]);
|
|
39
|
+
/** Steps most of a view along, so the item cut off at the edge ends up whole. */
|
|
40
|
+
const step = useCallback((direction) => node?.scrollBy({ left: direction * node.clientWidth * 0.75, behavior: 'smooth' }), [node]);
|
|
41
|
+
/** Brings the selected item (matched by `selector`) into view, if it is out of it. */
|
|
42
|
+
const reveal = useCallback((selector) => {
|
|
43
|
+
const item = node?.querySelector(selector);
|
|
44
|
+
if (!node || !item)
|
|
45
|
+
return;
|
|
46
|
+
const box = item.getBoundingClientRect();
|
|
47
|
+
const left = box.left - node.getBoundingClientRect().left + node.scrollLeft - fade;
|
|
48
|
+
const right = left + box.width + fade * 2;
|
|
49
|
+
if (left < node.scrollLeft)
|
|
50
|
+
node.scrollTo({ left, behavior: 'smooth' });
|
|
51
|
+
else if (right > node.scrollLeft + node.clientWidth)
|
|
52
|
+
node.scrollTo({ left: right - node.clientWidth, behavior: 'smooth' });
|
|
53
|
+
}, [node]);
|
|
54
|
+
const style = {
|
|
55
|
+
maskImage: `linear-gradient(to right, ${edges.start ? 'transparent' : 'black'}, black ${fade}px, black calc(100% - ${fade}px), ${edges.end ? 'transparent' : 'black'})`,
|
|
56
|
+
};
|
|
57
|
+
return { ref: setNode, edges, step, reveal, style };
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* The pointer's way along the row. Out of the tab order: keyboard focus already scrolls the item
|
|
61
|
+
* it lands on into view.
|
|
62
|
+
*/
|
|
63
|
+
export const OverflowChevron = ({ direction, disabled, onStep, className, }) => {
|
|
64
|
+
const Icon = direction < 0 ? ChevronLeft : ChevronRight;
|
|
65
|
+
return (_jsx("button", { "aria-label": direction < 0 ? 'Scroll back' : 'Scroll on', className: cn('grid shrink-0 cursor-pointer place-items-center text-neutral-600 transition-[background-color,color] duration-150 enabled:hover:bg-neutral-950/5 enabled:hover:text-neutral-950', 'disabled:cursor-default disabled:text-neutral-300', className), "data-slot": "overflow-chevron", disabled: disabled, onClick: () => onStep(direction), tabIndex: -1, type: "button", children: _jsx(Icon, { className: "size-4", strokeWidth: 2 }) }));
|
|
66
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Base UI's Toggle is a pressed/unpressed button (aria-pressed), but a group that always keeps one
|
|
4
|
+
* value is a single choice, so each item is announced as a radio in a radiogroup.
|
|
5
|
+
* Otherwise a screen reader offers to "unpress" the active item, which useSingleValue then ignores.
|
|
6
|
+
*/
|
|
7
|
+
export const radioToggleRender = ({ 'aria-pressed': _pressed, ...props }, state) => (
|
|
8
|
+
// biome-ignore lint/a11y/useSemanticElements: a styled segment with the toggle group's roving focus, which a native radio input can't carry.
|
|
9
|
+
_jsx("button", { ...props, "aria-checked": state.pressed, role: "radio", type: "button" }));
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** A list with one item moved from one place to another: what a drop hands over, applied. */
|
|
2
|
+
export declare const moveItem: <T>(list: readonly T[], from: number, to: number) => T[];
|
|
3
|
+
/**
|
|
4
|
+
* Holds the pointer for a drag: one cursor over the whole page, and nothing under the pointer
|
|
5
|
+
* hovers, takes a cursor of its own or gets its text selected while the drag runs. Returns the
|
|
6
|
+
* release.
|
|
7
|
+
*/
|
|
8
|
+
export declare const holdPointer: (cursor: string) => () => void;
|
|
9
|
+
export type ReorderItem = {
|
|
10
|
+
/** What moves with the item: a row, or every cell of a column. */
|
|
11
|
+
nodes: HTMLElement[];
|
|
12
|
+
/** Where it starts and how long it is along the axis. */
|
|
13
|
+
start: number;
|
|
14
|
+
size: number;
|
|
15
|
+
};
|
|
16
|
+
type Options = {
|
|
17
|
+
axis: 'x' | 'y';
|
|
18
|
+
items: ReorderItem[];
|
|
19
|
+
index: number;
|
|
20
|
+
/** Where the pointer was when the drag began, along the axis. */
|
|
21
|
+
from: number;
|
|
22
|
+
/** Called once at the drop, inside a sync render, so the new order paints with the transforms gone. */
|
|
23
|
+
onMove: (from: number, to: number) => void;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Starts a drag from a pointer already down; ends at the pointer's release, or puts everything back
|
|
27
|
+
* on Escape. The drop calls `onMove`.
|
|
28
|
+
*/
|
|
29
|
+
export declare const startReorder: (options: Options) => void;
|
|
30
|
+
/**
|
|
31
|
+
* A press that becomes a drag once it has moved `threshold` px, so a click on the same target (a
|
|
32
|
+
* sortable head's label) still clicks. A press that dragged swallows the click that follows it.
|
|
33
|
+
*/
|
|
34
|
+
export declare const pressToDrag: (event: {
|
|
35
|
+
clientX: number;
|
|
36
|
+
clientY: number;
|
|
37
|
+
}, axis: "x" | "y", begin: (from: number) => void, threshold?: number) => void;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { flushSync } from 'react-dom';
|
|
3
|
+
/*
|
|
4
|
+
* Dragging one of a run of items (a table's rows, or its columns) to another place in the run. The
|
|
5
|
+
* item lifts and follows the pointer along one axis, and the items it passes step aside by its size,
|
|
6
|
+
* so the gap it would drop into is always open. Plain DOM transforms while the pointer moves: nothing
|
|
7
|
+
* re-renders until the drop, and then the move is handed over in one go and the item settles into its
|
|
8
|
+
* place from where it was let go.
|
|
9
|
+
*/
|
|
10
|
+
/** A list with one item moved from one place to another: what a drop hands over, applied. */
|
|
11
|
+
export const moveItem = (list, from, to) => {
|
|
12
|
+
const next = [...list];
|
|
13
|
+
const [item] = next.splice(from, 1);
|
|
14
|
+
if (item !== undefined)
|
|
15
|
+
next.splice(to, 0, item);
|
|
16
|
+
return next;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Holds the pointer for a drag: one cursor over the whole page, and nothing under the pointer
|
|
20
|
+
* hovers, takes a cursor of its own or gets its text selected while the drag runs. Returns the
|
|
21
|
+
* release.
|
|
22
|
+
*/
|
|
23
|
+
export const holdPointer = (cursor) => {
|
|
24
|
+
document.getSelection()?.removeAllRanges();
|
|
25
|
+
const style = document.createElement('style');
|
|
26
|
+
style.dataset.continuumDrag = '';
|
|
27
|
+
style.textContent = `html { cursor: ${cursor} !important; user-select: none !important; -webkit-user-select: none !important; } body * { pointer-events: none !important; }`;
|
|
28
|
+
document.head.append(style);
|
|
29
|
+
return () => style.remove();
|
|
30
|
+
};
|
|
31
|
+
const duration = 150;
|
|
32
|
+
const ease = `transform ${duration}ms cubic-bezier(0.215, 0.61, 0.355, 1)`;
|
|
33
|
+
/** Where the dragged item would land with its middle at `middle`. */
|
|
34
|
+
const targetOf = (items, index, middle) => {
|
|
35
|
+
let to = index;
|
|
36
|
+
items.forEach((item, i) => {
|
|
37
|
+
const centre = item.start + item.size / 2;
|
|
38
|
+
if (i > index && middle > centre)
|
|
39
|
+
to = Math.max(to, i);
|
|
40
|
+
if (i < index && middle < centre)
|
|
41
|
+
to = Math.min(to, i);
|
|
42
|
+
});
|
|
43
|
+
return to;
|
|
44
|
+
};
|
|
45
|
+
const translate = (axis, shift) => shift === 0 ? '' : `${axis === 'x' ? 'translateX' : 'translateY'}(${shift}px)`;
|
|
46
|
+
const place = (options, offset) => {
|
|
47
|
+
const { axis, items, index } = options;
|
|
48
|
+
const dragged = items[index];
|
|
49
|
+
if (!dragged)
|
|
50
|
+
return index;
|
|
51
|
+
const first = items[0];
|
|
52
|
+
const last = items.at(-1);
|
|
53
|
+
// The item stays within the run: it can reach either end, never leave it.
|
|
54
|
+
const min = (first?.start ?? 0) - dragged.start;
|
|
55
|
+
const max = (last ? last.start + last.size : 0) - (dragged.start + dragged.size);
|
|
56
|
+
const clamped = Math.min(Math.max(offset, min), max);
|
|
57
|
+
const to = targetOf(items, index, dragged.start + dragged.size / 2 + clamped);
|
|
58
|
+
items.forEach((item, i) => {
|
|
59
|
+
let shift = 0;
|
|
60
|
+
if (i === index)
|
|
61
|
+
shift = clamped;
|
|
62
|
+
else if (index < to && i > index && i <= to)
|
|
63
|
+
shift = -dragged.size;
|
|
64
|
+
else if (index > to && i < index && i >= to)
|
|
65
|
+
shift = dragged.size;
|
|
66
|
+
for (const node of item.nodes) {
|
|
67
|
+
node.style.transition = i === index ? 'none' : ease;
|
|
68
|
+
node.style.transform = translate(axis, shift);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return to;
|
|
72
|
+
};
|
|
73
|
+
/** Eases nodes from where they are drawn now to where they lie, then lets go of them. */
|
|
74
|
+
const settle = (nodes, axis, offsets, done) => {
|
|
75
|
+
nodes.forEach((node, i) => {
|
|
76
|
+
node.style.transition = 'none';
|
|
77
|
+
node.style.transform = translate(axis, offsets[i] ?? 0);
|
|
78
|
+
});
|
|
79
|
+
// Commit the start before the transition, so it runs from there.
|
|
80
|
+
void nodes[0]?.getBoundingClientRect();
|
|
81
|
+
for (const node of nodes) {
|
|
82
|
+
node.style.transition = ease;
|
|
83
|
+
node.style.transform = '';
|
|
84
|
+
}
|
|
85
|
+
window.setTimeout(() => {
|
|
86
|
+
for (const node of nodes)
|
|
87
|
+
node.style.transition = '';
|
|
88
|
+
done();
|
|
89
|
+
}, duration);
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Starts a drag from a pointer already down; ends at the pointer's release, or puts everything back
|
|
93
|
+
* on Escape. The drop calls `onMove`.
|
|
94
|
+
*/
|
|
95
|
+
export const startReorder = (options) => {
|
|
96
|
+
const { axis, items, index, from, onMove } = options;
|
|
97
|
+
const dragged = items[index];
|
|
98
|
+
if (!dragged)
|
|
99
|
+
return;
|
|
100
|
+
for (const node of dragged.nodes)
|
|
101
|
+
node.dataset.dragging = '';
|
|
102
|
+
const release = holdPointer('grabbing');
|
|
103
|
+
let to = index;
|
|
104
|
+
const edge = (node) => {
|
|
105
|
+
const box = node.getBoundingClientRect();
|
|
106
|
+
return axis === 'x' ? box.left : box.top;
|
|
107
|
+
};
|
|
108
|
+
const lift = () => {
|
|
109
|
+
for (const node of dragged.nodes)
|
|
110
|
+
delete node.dataset.dragging;
|
|
111
|
+
};
|
|
112
|
+
const move = (event) => {
|
|
113
|
+
to = place(options, (axis === 'x' ? event.clientX : event.clientY) - from);
|
|
114
|
+
};
|
|
115
|
+
const end = (drop) => {
|
|
116
|
+
window.removeEventListener('pointermove', move);
|
|
117
|
+
window.removeEventListener('pointerup', up);
|
|
118
|
+
window.removeEventListener('pointercancel', cancel);
|
|
119
|
+
window.removeEventListener('keydown', key, true);
|
|
120
|
+
release();
|
|
121
|
+
const others = items.filter((_, i) => i !== index).flatMap(item => item.nodes);
|
|
122
|
+
if (!drop || to === index) {
|
|
123
|
+
// Back where they came from, the dragged one and the ones that stepped aside alike.
|
|
124
|
+
const all = [...others, ...dragged.nodes];
|
|
125
|
+
for (const node of all) {
|
|
126
|
+
node.style.transition = ease;
|
|
127
|
+
node.style.transform = '';
|
|
128
|
+
}
|
|
129
|
+
window.setTimeout(() => {
|
|
130
|
+
for (const node of all)
|
|
131
|
+
node.style.transition = '';
|
|
132
|
+
lift();
|
|
133
|
+
}, duration);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
// Where the dragged item is drawn as it is let go; the others already stand where the new
|
|
137
|
+
// order puts them, so they drop their shifts without a step.
|
|
138
|
+
const before = dragged.nodes.map(edge);
|
|
139
|
+
flushSync(() => onMove(index, to));
|
|
140
|
+
for (const node of [...others, ...dragged.nodes]) {
|
|
141
|
+
node.style.transition = 'none';
|
|
142
|
+
node.style.transform = '';
|
|
143
|
+
}
|
|
144
|
+
const offsets = dragged.nodes.map((node, i) => (before[i] ?? 0) - edge(node));
|
|
145
|
+
for (const node of others)
|
|
146
|
+
node.style.transition = '';
|
|
147
|
+
settle(dragged.nodes, axis, offsets, lift);
|
|
148
|
+
};
|
|
149
|
+
const up = () => end(true);
|
|
150
|
+
const cancel = () => end(false);
|
|
151
|
+
const key = (event) => {
|
|
152
|
+
if (event.key !== 'Escape')
|
|
153
|
+
return;
|
|
154
|
+
event.preventDefault();
|
|
155
|
+
event.stopPropagation();
|
|
156
|
+
end(false);
|
|
157
|
+
};
|
|
158
|
+
window.addEventListener('pointermove', move);
|
|
159
|
+
window.addEventListener('pointerup', up);
|
|
160
|
+
window.addEventListener('pointercancel', cancel);
|
|
161
|
+
window.addEventListener('keydown', key, true);
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* A press that becomes a drag once it has moved `threshold` px, so a click on the same target (a
|
|
165
|
+
* sortable head's label) still clicks. A press that dragged swallows the click that follows it.
|
|
166
|
+
*/
|
|
167
|
+
export const pressToDrag = (event, axis, begin, threshold = 4) => {
|
|
168
|
+
const x = event.clientX;
|
|
169
|
+
const y = event.clientY;
|
|
170
|
+
const move = (next) => {
|
|
171
|
+
const distance = axis === 'x' ? next.clientX - x : next.clientY - y;
|
|
172
|
+
if (Math.abs(distance) < threshold)
|
|
173
|
+
return;
|
|
174
|
+
stop();
|
|
175
|
+
// The click this press ends in is the drop, not a sort. A click follows its pointerup in
|
|
176
|
+
// the same task, so the swallow goes right after it, also when no click comes.
|
|
177
|
+
const swallow = (click) => {
|
|
178
|
+
click.preventDefault();
|
|
179
|
+
click.stopPropagation();
|
|
180
|
+
};
|
|
181
|
+
window.addEventListener('click', swallow, { capture: true, once: true });
|
|
182
|
+
window.addEventListener('pointerup', () => setTimeout(() => window.removeEventListener('click', swallow, true), 0), { once: true });
|
|
183
|
+
begin(axis === 'x' ? x : y);
|
|
184
|
+
// The first step already counts.
|
|
185
|
+
window.dispatchEvent(new PointerEvent('pointermove', next));
|
|
186
|
+
};
|
|
187
|
+
const stop = () => {
|
|
188
|
+
window.removeEventListener('pointermove', move);
|
|
189
|
+
window.removeEventListener('pointerup', stop);
|
|
190
|
+
};
|
|
191
|
+
window.addEventListener('pointermove', move);
|
|
192
|
+
window.addEventListener('pointerup', stop);
|
|
193
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
export type SpacingParams = {
|
|
2
|
+
/** Padding per px of type. */
|
|
3
|
+
k: number;
|
|
4
|
+
/** How fast a box's padding grows with the lines it holds. */
|
|
5
|
+
alpha: number;
|
|
6
|
+
/** A box of boxes pads at least this times its children's padding. */
|
|
7
|
+
nesting: number;
|
|
8
|
+
/** The gap between boxes, as a share of their padding. */
|
|
9
|
+
gapRatio: number;
|
|
10
|
+
/** The gap within a pair (a header and subheader, a label and value, a figure and caption). */
|
|
11
|
+
tight: number;
|
|
12
|
+
/** The gap between blocks of text. */
|
|
13
|
+
loose: number;
|
|
14
|
+
/** How fast a gap between texts grows with the lines either side of it. */
|
|
15
|
+
beta: number;
|
|
16
|
+
/** The room a free-standing block claims, per px of its type. */
|
|
17
|
+
room: number;
|
|
18
|
+
/** How fast that room grows with the lines and rows the block holds. */
|
|
19
|
+
roomGrowth: number;
|
|
20
|
+
/** The share of its room a block claims inside a box with a surface (a card), beside an unlike block. */
|
|
21
|
+
inside: number;
|
|
22
|
+
/** The most lines a block counts toward its room inside a box with a surface. */
|
|
23
|
+
insideLines: number;
|
|
24
|
+
/** No padding past this, in px. */
|
|
25
|
+
cap: number;
|
|
26
|
+
};
|
|
27
|
+
/** The balance judged on a billing screen in the spacing lab, 4 Nov 2026. */
|
|
28
|
+
export declare const spacingDefaults: SpacingParams;
|
|
29
|
+
/**
|
|
30
|
+
* The Tailwind steps a result may land on, in units of `--spacing` (4px): half steps to 4, then
|
|
31
|
+
* whole steps, then wider ones, as Tailwind's own scale runs.
|
|
32
|
+
*/
|
|
33
|
+
export declare const spacingSteps: readonly [0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 20, 24];
|
|
34
|
+
export type SpacingStep = (typeof spacingSteps)[number];
|
|
35
|
+
/** The nearest Tailwind step to a length in px. */
|
|
36
|
+
export declare const toSpacingStep: (px: number) => SpacingStep;
|
|
37
|
+
/** A length in px, snapped to the scale and written as a class: `spacingClass('p', 22)` is `p-5`. */
|
|
38
|
+
export declare const spacingClass: (prefix: string, px: number) => string;
|
|
39
|
+
/** A length in px snapped to the scale, still in px. */
|
|
40
|
+
export declare const snapToSpacing: (px: number) => number;
|
|
41
|
+
export type TypeRun = {
|
|
42
|
+
/** Font size in px. */
|
|
43
|
+
size: number;
|
|
44
|
+
/** Rendered lines; measure them where you can, about eight words of body text to a line otherwise. */
|
|
45
|
+
lines: number;
|
|
46
|
+
};
|
|
47
|
+
/** About eight words of body text to a line, for when the lines cannot be measured. */
|
|
48
|
+
export declare const estimateLines: (text: string) => number;
|
|
49
|
+
/** A box's type size: averaged over its lines, so a large figure among small lines does not set it. */
|
|
50
|
+
export declare const typeSize: (runs: readonly TypeRun[]) => number;
|
|
51
|
+
export type InnerBox = {
|
|
52
|
+
/** The inner box's padding in px; for a group with no surface, its children's. */
|
|
53
|
+
padding: number;
|
|
54
|
+
/** The inner box's type size, which counts as one line of this box's content. */
|
|
55
|
+
size: number;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* A box's padding in px, unsnapped: from its own text and the boxes inside it (each one line of
|
|
59
|
+
* content at its own type size), and at least a step past those boxes' padding.
|
|
60
|
+
*/
|
|
61
|
+
export declare const boxPadding: ({ runs, children }: {
|
|
62
|
+
runs: readonly TypeRun[];
|
|
63
|
+
children?: readonly InnerBox[];
|
|
64
|
+
}, params?: SpacingParams) => number;
|
|
65
|
+
/** The gap between alike sibling boxes (cards in a row, a list's rows) in px, unsnapped, from their padding. */
|
|
66
|
+
export declare const boxGap: (children: readonly number[], params?: SpacingParams) => number;
|
|
67
|
+
/**
|
|
68
|
+
* The room a free-standing block claims on the side facing another block, in px, unsnapped, from
|
|
69
|
+
* what it holds (its texts, and each box inside it as one line at its own size), whether or not it
|
|
70
|
+
* has a surface: room × size × (1 + growth·log₂ lines). It grows faster with amount than padding
|
|
71
|
+
* does, so a dense table claims far more than a short card: a page head of a title and a line about
|
|
72
|
+
* 20, a table of twenty rows about 44, a short settings card about 12.
|
|
73
|
+
*/
|
|
74
|
+
export declare const blockRoom: ({ runs, children }: {
|
|
75
|
+
runs: readonly TypeRun[];
|
|
76
|
+
children?: readonly InnerBox[];
|
|
77
|
+
}, params?: SpacingParams) => number;
|
|
78
|
+
/**
|
|
79
|
+
* The room a block claims beside an unlike block inside a box with a surface (a card's title over
|
|
80
|
+
* its list, a figure over its badge), in px, unsnapped: the free-standing room, scaled by `inside`
|
|
81
|
+
* and counting at most `insideLines` lines, since inside a card both blocks are seen together and a
|
|
82
|
+
* list's length should not push its own title away. A stat card's figure over its badge lands on 12,
|
|
83
|
+
* a card's title over its list near 14.
|
|
84
|
+
*/
|
|
85
|
+
export declare const insideRoom: ({ size, lines }: TypeRun, params?: SpacingParams) => number;
|
|
86
|
+
/**
|
|
87
|
+
* The gap between two unlike blocks (a page head and its table, a chart and the section under it;
|
|
88
|
+
* inside a card, each with its insideRoom), in px, unsnapped: each brings its own room, so the gap is
|
|
89
|
+
* the sum, and it grows with how much either side holds. A page head over a dense table lands near
|
|
90
|
+
* 64; a bare title over a short card near 32.
|
|
91
|
+
*/
|
|
92
|
+
export declare const blockGap: (before: number, after: number) => number;
|
|
93
|
+
/**
|
|
94
|
+
* The gap between two texts in px, unsnapped: sized by the text after it, tight within a pair and
|
|
95
|
+
* loose between blocks, and wider the more lines sit either side.
|
|
96
|
+
*/
|
|
97
|
+
export declare const textGap: ({ before, after, pair }: {
|
|
98
|
+
before: TypeRun;
|
|
99
|
+
after: TypeRun;
|
|
100
|
+
pair: boolean;
|
|
101
|
+
}, params?: SpacingParams) => number;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The spacing formula: padding and gaps worked out from what a box holds rather than picked, and
|
|
3
|
+
* always landing on a Tailwind spacing step, never an arbitrary value. It covers boxes that hold
|
|
4
|
+
* content (cards, sections, panels, sheets, list rows) and the gaps between texts; a control's
|
|
5
|
+
* side padding stays fixed per kind, since its height already decides it.
|
|
6
|
+
*
|
|
7
|
+
* - A box of text pads by its type and its amount: k × size × (1 + α·log₂ lines), where size is
|
|
8
|
+
* the type size averaged over its lines, so one large figure does not size a whole card.
|
|
9
|
+
* - A box of boxes pads at least a step past its children: r × their padding.
|
|
10
|
+
* - Between alike boxes (cards in a row, a list's rows): g × their padding.
|
|
11
|
+
* - Between unlike blocks (a page head and its table, a chart and a section; inside a card, a title
|
|
12
|
+
* and its list, a figure and its badge): each claims its own room, growing with what it holds,
|
|
13
|
+
* and the gap is the sum. Inside a box with a surface a block claims less (× inside) and counts
|
|
14
|
+
* only its first lines (insideLines), so a long list does not push its own title away.
|
|
15
|
+
* - Between texts: t × the size of the text after the gap (type sets the space above a line in that
|
|
16
|
+
* line's own size), tight for a pair that belongs together and loose between blocks, growing with
|
|
17
|
+
* the lines either side: × (1 + β·log₂ lines).
|
|
18
|
+
*
|
|
19
|
+
* Kept free of imports so a script can load it on its own (the continuum-fix-padding skill runs it with Node).
|
|
20
|
+
*/
|
|
21
|
+
/** The balance judged on a billing screen in the spacing lab, 4 Nov 2026. */
|
|
22
|
+
export const spacingDefaults = {
|
|
23
|
+
k: 0.75,
|
|
24
|
+
alpha: 0.6,
|
|
25
|
+
nesting: 1.5,
|
|
26
|
+
gapRatio: 1.1,
|
|
27
|
+
tight: 0.25,
|
|
28
|
+
loose: 1.5,
|
|
29
|
+
beta: 0.6,
|
|
30
|
+
/* Fitted 16 Nov 2026 to Joan's anchors: a page head over a dense table about 64, over ten rows
|
|
31
|
+
about 56, a bare title over a short settings card about 32. */
|
|
32
|
+
room: 0.375,
|
|
33
|
+
roomGrowth: 1.85,
|
|
34
|
+
/* Fitted 17 Nov 2026 to the cards Continuum draws by eye (a stat card's badge 12 under its
|
|
35
|
+
figure, a card's title 16 over its list): off by about 1px on average across them. */
|
|
36
|
+
inside: 0.6,
|
|
37
|
+
insideLines: 3,
|
|
38
|
+
cap: 48,
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* The Tailwind steps a result may land on, in units of `--spacing` (4px): half steps to 4, then
|
|
42
|
+
* whole steps, then wider ones, as Tailwind's own scale runs.
|
|
43
|
+
*/
|
|
44
|
+
export const spacingSteps = [
|
|
45
|
+
0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 20, 24,
|
|
46
|
+
];
|
|
47
|
+
const unit = 4;
|
|
48
|
+
/** The nearest Tailwind step to a length in px. */
|
|
49
|
+
export const toSpacingStep = (px) => {
|
|
50
|
+
let best = 0;
|
|
51
|
+
for (const step of spacingSteps) {
|
|
52
|
+
if (Math.abs(step * unit - px) < Math.abs(best * unit - px))
|
|
53
|
+
best = step;
|
|
54
|
+
}
|
|
55
|
+
return best;
|
|
56
|
+
};
|
|
57
|
+
/** A length in px, snapped to the scale and written as a class: `spacingClass('p', 22)` is `p-5`. */
|
|
58
|
+
export const spacingClass = (prefix, px) => `${prefix}-${toSpacingStep(px)}`;
|
|
59
|
+
/** A length in px snapped to the scale, still in px. */
|
|
60
|
+
export const snapToSpacing = (px) => toSpacingStep(px) * unit;
|
|
61
|
+
/** About eight words of body text to a line, for when the lines cannot be measured. */
|
|
62
|
+
export const estimateLines = (text) => Math.max(1, text.trim().split(/\s+/).filter(Boolean).length / 8);
|
|
63
|
+
/** A box's type size: averaged over its lines, so a large figure among small lines does not set it. */
|
|
64
|
+
export const typeSize = (runs) => {
|
|
65
|
+
const total = runs.reduce((sum, run) => sum + run.lines, 0);
|
|
66
|
+
return total > 0 ? runs.reduce((sum, run) => sum + run.size * run.lines, 0) / total : 0;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* A box's padding in px, unsnapped: from its own text and the boxes inside it (each one line of
|
|
70
|
+
* content at its own type size), and at least a step past those boxes' padding.
|
|
71
|
+
*/
|
|
72
|
+
export const boxPadding = ({ runs, children = [] }, params = spacingDefaults) => {
|
|
73
|
+
const all = [...runs, ...children.map(child => ({ size: child.size, lines: 1 }))];
|
|
74
|
+
const amount = all.reduce((sum, run) => sum + run.lines, 0);
|
|
75
|
+
const fromContent = params.k * typeSize(all) * (1 + params.alpha * Math.log2(Math.max(1, amount)));
|
|
76
|
+
const fromChildren = Math.max(0, ...children.map(child => child.padding)) * params.nesting;
|
|
77
|
+
return Math.min(Math.max(fromContent, fromChildren), params.cap);
|
|
78
|
+
};
|
|
79
|
+
/** The gap between alike sibling boxes (cards in a row, a list's rows) in px, unsnapped, from their padding. */
|
|
80
|
+
export const boxGap = (children, params = spacingDefaults) => Math.max(0, ...children) * params.gapRatio;
|
|
81
|
+
/**
|
|
82
|
+
* The room a free-standing block claims on the side facing another block, in px, unsnapped, from
|
|
83
|
+
* what it holds (its texts, and each box inside it as one line at its own size), whether or not it
|
|
84
|
+
* has a surface: room × size × (1 + growth·log₂ lines). It grows faster with amount than padding
|
|
85
|
+
* does, so a dense table claims far more than a short card: a page head of a title and a line about
|
|
86
|
+
* 20, a table of twenty rows about 44, a short settings card about 12.
|
|
87
|
+
*/
|
|
88
|
+
export const blockRoom = ({ runs, children = [] }, params = spacingDefaults) => {
|
|
89
|
+
const all = [...runs, ...children.map(child => ({ size: child.size, lines: 1 }))];
|
|
90
|
+
const lines = all.reduce((sum, run) => sum + run.lines, 0);
|
|
91
|
+
return params.room * typeSize(all) * (1 + params.roomGrowth * Math.log2(Math.max(1, lines)));
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* The room a block claims beside an unlike block inside a box with a surface (a card's title over
|
|
95
|
+
* its list, a figure over its badge), in px, unsnapped: the free-standing room, scaled by `inside`
|
|
96
|
+
* and counting at most `insideLines` lines, since inside a card both blocks are seen together and a
|
|
97
|
+
* list's length should not push its own title away. A stat card's figure over its badge lands on 12,
|
|
98
|
+
* a card's title over its list near 14.
|
|
99
|
+
*/
|
|
100
|
+
export const insideRoom = ({ size, lines }, params = spacingDefaults) => params.inside *
|
|
101
|
+
blockRoom({ runs: [{ size, lines: Math.min(lines, params.insideLines) }] }, params);
|
|
102
|
+
/**
|
|
103
|
+
* The gap between two unlike blocks (a page head and its table, a chart and the section under it;
|
|
104
|
+
* inside a card, each with its insideRoom), in px, unsnapped: each brings its own room, so the gap is
|
|
105
|
+
* the sum, and it grows with how much either side holds. A page head over a dense table lands near
|
|
106
|
+
* 64; a bare title over a short card near 32.
|
|
107
|
+
*/
|
|
108
|
+
export const blockGap = (before, after) => before + after;
|
|
109
|
+
/**
|
|
110
|
+
* The gap between two texts in px, unsnapped: sized by the text after it, tight within a pair and
|
|
111
|
+
* loose between blocks, and wider the more lines sit either side.
|
|
112
|
+
*/
|
|
113
|
+
export const textGap = ({ before, after, pair }, params = spacingDefaults) => {
|
|
114
|
+
const around = before.lines + after.lines - 1;
|
|
115
|
+
return (after.size *
|
|
116
|
+
(pair ? params.tight : params.loose) *
|
|
117
|
+
(1 + params.beta * Math.log2(Math.max(1, around))));
|
|
118
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type PaletteRamp = readonly (readonly [number, number, number])[];
|
|
2
|
+
/** The seventeen chromatic families. */
|
|
3
|
+
export declare const tailwindHues: Record<string, PaletteRamp>;
|
|
4
|
+
/** The greys, achromatic or faintly tinted. */
|
|
5
|
+
export declare const tailwindGreys: Record<string, PaletteRamp>;
|