@cueplusplus/ui 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/dist/charts/_token.js +39 -0
- package/dist/charts/container.d.ts +58 -0
- package/dist/charts/container.js +77 -0
- package/dist/charts/index.d.ts +5 -0
- package/dist/charts/index.js +5 -0
- package/dist/charts/ramps.d.ts +140 -0
- package/dist/charts/ramps.js +615 -0
- package/dist/charts/theme.d.ts +112 -0
- package/dist/charts/theme.js +165 -0
- package/dist/charts/tones.d.ts +111 -0
- package/dist/charts/tones.js +127 -0
- package/dist/chat/_glyphs.js +55 -0
- package/dist/chat/agent-color.d.ts +84 -0
- package/dist/chat/agent-color.js +101 -0
- package/dist/chat/agent-pile.d.ts +55 -0
- package/dist/chat/agent-pile.js +121 -0
- package/dist/chat/ask-box.d.ts +88 -0
- package/dist/chat/ask-box.js +341 -0
- package/dist/chat/composer.d.ts +66 -0
- package/dist/chat/composer.js +144 -0
- package/dist/chat/delegation-card.d.ts +60 -0
- package/dist/chat/delegation-card.js +129 -0
- package/dist/chat/index.d.ts +8 -0
- package/dist/chat/index.js +8 -0
- package/dist/chat/message-list.d.ts +39 -0
- package/dist/chat/message-list.js +105 -0
- package/dist/chat/message.d.ts +47 -0
- package/dist/chat/message.js +108 -0
- package/dist/chrome/_glyphs.js +101 -0
- package/dist/chrome/_tabs-scroll.d.ts +62 -0
- package/dist/chrome/_tabs-scroll.js +68 -0
- package/dist/chrome/_tree.d.ts +75 -0
- package/dist/chrome/_tree.js +49 -0
- package/dist/chrome/empty-state.d.ts +37 -0
- package/dist/chrome/empty-state.js +57 -0
- package/dist/chrome/eyebrow.d.ts +29 -0
- package/dist/chrome/eyebrow.js +36 -0
- package/dist/chrome/index.d.ts +17 -0
- package/dist/chrome/index.js +17 -0
- package/dist/chrome/navigation-menu.d.ts +80 -0
- package/dist/chrome/navigation-menu.js +121 -0
- package/dist/chrome/page-shell.d.ts +38 -0
- package/dist/chrome/page-shell.js +66 -0
- package/dist/chrome/panel.d.ts +55 -0
- package/dist/chrome/panel.js +67 -0
- package/dist/chrome/row.d.ts +82 -0
- package/dist/chrome/row.js +106 -0
- package/dist/chrome/scroll-area.d.ts +39 -0
- package/dist/chrome/scroll-area.js +70 -0
- package/dist/chrome/section-header.d.ts +42 -0
- package/dist/chrome/section-header.js +79 -0
- package/dist/chrome/segmented-control.d.ts +58 -0
- package/dist/chrome/segmented-control.js +76 -0
- package/dist/chrome/status-bar.d.ts +46 -0
- package/dist/chrome/status-bar.js +56 -0
- package/dist/chrome/tabs.d.ts +80 -0
- package/dist/chrome/tabs.js +176 -0
- package/dist/chrome/title-bar.d.ts +37 -0
- package/dist/chrome/title-bar.js +45 -0
- package/dist/chrome/toolbar.d.ts +46 -0
- package/dist/chrome/toolbar.js +62 -0
- package/dist/chrome/tree.d.ts +98 -0
- package/dist/chrome/tree.js +248 -0
- package/dist/color/_checker.js +14 -0
- package/dist/color/_convert.d.ts +52 -0
- package/dist/color/_convert.js +66 -0
- package/dist/color/_glyphs.js +28 -0
- package/dist/color/_thumb.js +15 -0
- package/dist/color/_value.js +28 -0
- package/dist/color/color-area.d.ts +27 -0
- package/dist/color/color-area.js +40 -0
- package/dist/color/color-field.d.ts +32 -0
- package/dist/color/color-field.js +43 -0
- package/dist/color/color-picker.d.ts +71 -0
- package/dist/color/color-picker.js +178 -0
- package/dist/color/color-slider.d.ts +31 -0
- package/dist/color/color-slider.js +51 -0
- package/dist/color/color-swatch.d.ts +32 -0
- package/dist/color/color-swatch.js +44 -0
- package/dist/color/index.d.ts +7 -0
- package/dist/color/index.js +7 -0
- package/dist/configurator/_export.d.ts +78 -0
- package/dist/configurator/_export.js +261 -0
- package/dist/configurator/_glyphs.js +92 -0
- package/dist/configurator/_overrides.d.ts +247 -0
- package/dist/configurator/_overrides.js +514 -0
- package/dist/configurator/configurator.d.ts +71 -0
- package/dist/configurator/configurator.js +279 -0
- package/dist/configurator/export-dialog.d.ts +30 -0
- package/dist/configurator/export-dialog.js +121 -0
- package/dist/configurator/index.d.ts +8 -0
- package/dist/configurator/index.js +8 -0
- package/dist/configurator/panel-sections.d.ts +86 -0
- package/dist/configurator/panel-sections.js +316 -0
- package/dist/configurator/token-editor.d.ts +74 -0
- package/dist/configurator/token-editor.js +149 -0
- package/dist/configurator/use-zoom.d.ts +87 -0
- package/dist/configurator/use-zoom.js +113 -0
- package/dist/date/_glyphs.js +34 -0
- package/dist/date/_segments.js +55 -0
- package/dist/date/_trigger.js +31 -0
- package/dist/date/calendar.d.ts +25 -0
- package/dist/date/calendar.js +125 -0
- package/dist/date/date-field.d.ts +34 -0
- package/dist/date/date-field.js +41 -0
- package/dist/date/date-picker.d.ts +69 -0
- package/dist/date/date-picker.js +89 -0
- package/dist/date/date-range-picker.d.ts +65 -0
- package/dist/date/date-range-picker.js +92 -0
- package/dist/date/index.d.ts +6 -0
- package/dist/date/index.js +6 -0
- package/dist/date/time-field.d.ts +29 -0
- package/dist/date/time-field.js +36 -0
- package/dist/dmx/_ramp.d.ts +77 -0
- package/dist/dmx/_ramp.js +169 -0
- package/dist/dmx/_readout.js +53 -0
- package/dist/dmx/_universe.d.ts +105 -0
- package/dist/dmx/_universe.js +112 -0
- package/dist/dmx/channel-matrix.d.ts +81 -0
- package/dist/dmx/channel-matrix.js +285 -0
- package/dist/dmx/dmx-bar.d.ts +50 -0
- package/dist/dmx/dmx-bar.js +107 -0
- package/dist/dmx/dmx-strip.d.ts +41 -0
- package/dist/dmx/dmx-strip.js +196 -0
- package/dist/dmx/index.d.ts +7 -0
- package/dist/dmx/index.js +7 -0
- package/dist/dmx/universe-grid.d.ts +61 -0
- package/dist/dmx/universe-grid.js +182 -0
- package/dist/flow/_frame.d.ts +52 -0
- package/dist/flow/_frame.js +38 -0
- package/dist/flow/controls.d.ts +41 -0
- package/dist/flow/controls.js +53 -0
- package/dist/flow/flow.css +121 -0
- package/dist/flow/handles.d.ts +40 -0
- package/dist/flow/handles.js +61 -0
- package/dist/flow/index.d.ts +7 -0
- package/dist/flow/index.js +7 -0
- package/dist/flow/node-card.d.ts +71 -0
- package/dist/flow/node-card.js +102 -0
- package/dist/flow/signal-edge.d.ts +60 -0
- package/dist/flow/signal-edge.js +108 -0
- package/dist/flow/use-flow-theme.d.ts +69 -0
- package/dist/flow/use-flow-theme.js +109 -0
- package/dist/forms/_chassis.d.ts +64 -0
- package/dist/forms/_chassis.js +59 -0
- package/dist/forms/_glyphs.js +143 -0
- package/dist/forms/_listbox.js +55 -0
- package/dist/forms/autocomplete.d.ts +61 -0
- package/dist/forms/autocomplete.js +88 -0
- package/dist/forms/button-group.d.ts +47 -0
- package/dist/forms/button-group.js +52 -0
- package/dist/forms/checkbox.d.ts +51 -0
- package/dist/forms/checkbox.js +98 -0
- package/dist/forms/combobox.d.ts +73 -0
- package/dist/forms/combobox.js +108 -0
- package/dist/forms/env-var-input.d.ts +74 -0
- package/dist/forms/env-var-input.js +116 -0
- package/dist/forms/field.d.ts +89 -0
- package/dist/forms/field.js +102 -0
- package/dist/forms/file-upload.d.ts +113 -0
- package/dist/forms/file-upload.js +232 -0
- package/dist/forms/index.d.ts +26 -0
- package/dist/forms/index.js +26 -0
- package/dist/forms/input-group.d.ts +31 -0
- package/dist/forms/input-group.js +54 -0
- package/dist/forms/input.d.ts +33 -0
- package/dist/forms/input.js +36 -0
- package/dist/forms/multi-select.d.ts +62 -0
- package/dist/forms/multi-select.js +107 -0
- package/dist/forms/number-field.d.ts +38 -0
- package/dist/forms/number-field.js +64 -0
- package/dist/forms/otp-field.d.ts +54 -0
- package/dist/forms/otp-field.js +59 -0
- package/dist/forms/password-input.d.ts +46 -0
- package/dist/forms/password-input.js +62 -0
- package/dist/forms/radio-group.d.ts +50 -0
- package/dist/forms/radio-group.js +64 -0
- package/dist/forms/rating.d.ts +69 -0
- package/dist/forms/rating.js +103 -0
- package/dist/forms/scrub-input.d.ts +81 -0
- package/dist/forms/scrub-input.js +249 -0
- package/dist/forms/search-input.d.ts +54 -0
- package/dist/forms/search-input.js +112 -0
- package/dist/forms/select.d.ts +75 -0
- package/dist/forms/select.js +91 -0
- package/dist/forms/slider.d.ts +44 -0
- package/dist/forms/slider.js +65 -0
- package/dist/forms/switch.d.ts +36 -0
- package/dist/forms/switch.js +71 -0
- package/dist/forms/tags-input.d.ts +69 -0
- package/dist/forms/tags-input.js +148 -0
- package/dist/forms/textarea.d.ts +27 -0
- package/dist/forms/textarea.js +37 -0
- package/dist/forms/toggle-group.d.ts +41 -0
- package/dist/forms/toggle-group.js +56 -0
- package/dist/forms/toggle.d.ts +41 -0
- package/dist/forms/toggle.js +100 -0
- package/dist/index.d.ts +112 -0
- package/dist/index.js +104 -0
- package/dist/instruments/_ansi.js +116 -0
- package/dist/instruments/_glyphs.js +90 -0
- package/dist/instruments/_motion.js +56 -0
- package/dist/instruments/_rem.js +21 -0
- package/dist/instruments/app-window-frame.d.ts +48 -0
- package/dist/instruments/app-window-frame.js +76 -0
- package/dist/instruments/copy-button.d.ts +41 -0
- package/dist/instruments/copy-button.js +112 -0
- package/dist/instruments/data-table.d.ts +168 -0
- package/dist/instruments/data-table.js +212 -0
- package/dist/instruments/group-bar.d.ts +63 -0
- package/dist/instruments/group-bar.js +122 -0
- package/dist/instruments/index.d.ts +13 -0
- package/dist/instruments/index.js +13 -0
- package/dist/instruments/log-viewer.d.ts +74 -0
- package/dist/instruments/log-viewer.js +215 -0
- package/dist/instruments/meter.d.ts +77 -0
- package/dist/instruments/meter.js +96 -0
- package/dist/instruments/progress.d.ts +45 -0
- package/dist/instruments/progress.js +61 -0
- package/dist/instruments/seam-grid.d.ts +66 -0
- package/dist/instruments/seam-grid.js +78 -0
- package/dist/instruments/sparkline.d.ts +39 -0
- package/dist/instruments/sparkline.js +85 -0
- package/dist/instruments/stat.d.ts +35 -0
- package/dist/instruments/stat.js +59 -0
- package/dist/instruments/table.d.ts +51 -0
- package/dist/instruments/table.js +92 -0
- package/dist/instruments/terminal-frame.d.ts +89 -0
- package/dist/instruments/terminal-frame.js +256 -0
- package/dist/instruments/two-step-button.d.ts +47 -0
- package/dist/instruments/two-step-button.js +147 -0
- package/dist/instruments/usage-chart.d.ts +55 -0
- package/dist/instruments/usage-chart.js +235 -0
- package/dist/layout/_collapse.js +46 -0
- package/dist/layout/_glyphs.js +45 -0
- package/dist/layout/accordion.d.ts +52 -0
- package/dist/layout/accordion.js +81 -0
- package/dist/layout/breadcrumb.d.ts +35 -0
- package/dist/layout/breadcrumb.js +67 -0
- package/dist/layout/card.d.ts +51 -0
- package/dist/layout/card.js +76 -0
- package/dist/layout/carousel.d.ts +96 -0
- package/dist/layout/carousel.js +211 -0
- package/dist/layout/collapsible.d.ts +74 -0
- package/dist/layout/collapsible.js +126 -0
- package/dist/layout/container.d.ts +27 -0
- package/dist/layout/container.js +40 -0
- package/dist/layout/description-list.d.ts +24 -0
- package/dist/layout/description-list.js +37 -0
- package/dist/layout/grid.d.ts +40 -0
- package/dist/layout/grid.js +48 -0
- package/dist/layout/index.d.ts +15 -0
- package/dist/layout/index.js +15 -0
- package/dist/layout/item.d.ts +65 -0
- package/dist/layout/item.js +100 -0
- package/dist/layout/link.d.ts +48 -0
- package/dist/layout/link.js +63 -0
- package/dist/layout/pagination.d.ts +54 -0
- package/dist/layout/pagination.js +121 -0
- package/dist/layout/resizable.d.ts +38 -0
- package/dist/layout/resizable.js +68 -0
- package/dist/layout/sidebar.d.ts +67 -0
- package/dist/layout/sidebar.js +129 -0
- package/dist/layout/stack.d.ts +46 -0
- package/dist/layout/stack.js +62 -0
- package/dist/layout/stepper.d.ts +49 -0
- package/dist/layout/stepper.js +81 -0
- package/dist/layout/timeline.d.ts +43 -0
- package/dist/layout/timeline.js +63 -0
- package/dist/lib/aria-class.js +24 -0
- package/dist/lib/cn.js +18 -0
- package/dist/lib/compose.js +38 -0
- package/dist/lib/cva.d.ts +18 -0
- package/dist/lib/cva.js +65 -0
- package/dist/midi/_notes.d.ts +101 -0
- package/dist/midi/_notes.js +183 -0
- package/dist/midi/_ruler.d.ts +100 -0
- package/dist/midi/_ruler.js +105 -0
- package/dist/midi/_time.d.ts +107 -0
- package/dist/midi/_time.js +130 -0
- package/dist/midi/index.d.ts +9 -0
- package/dist/midi/index.js +9 -0
- package/dist/midi/musical-time-input.d.ts +48 -0
- package/dist/midi/musical-time-input.js +154 -0
- package/dist/midi/piano-keyboard.d.ts +50 -0
- package/dist/midi/piano-keyboard.js +193 -0
- package/dist/midi/spectrum-visualizer.d.ts +65 -0
- package/dist/midi/spectrum-visualizer.js +213 -0
- package/dist/midi/threshold-rail.d.ts +72 -0
- package/dist/midi/threshold-rail.js +214 -0
- package/dist/midi/timeline-ruler.d.ts +83 -0
- package/dist/midi/timeline-ruler.js +152 -0
- package/dist/overlays/_debounce.js +34 -0
- package/dist/overlays/_glyphs.js +59 -0
- package/dist/overlays/_surface.d.ts +70 -0
- package/dist/overlays/_surface.js +70 -0
- package/dist/overlays/_wheel.js +42 -0
- package/dist/overlays/alert-dialog.d.ts +67 -0
- package/dist/overlays/alert-dialog.js +117 -0
- package/dist/overlays/command-palette.d.ts +93 -0
- package/dist/overlays/command-palette.js +193 -0
- package/dist/overlays/context-menu.d.ts +64 -0
- package/dist/overlays/context-menu.js +78 -0
- package/dist/overlays/dialog.d.ts +72 -0
- package/dist/overlays/dialog.js +124 -0
- package/dist/overlays/drawer.d.ts +75 -0
- package/dist/overlays/drawer.js +151 -0
- package/dist/overlays/dropdown-menu.d.ts +79 -0
- package/dist/overlays/dropdown-menu.js +156 -0
- package/dist/overlays/hover-card.d.ts +58 -0
- package/dist/overlays/hover-card.js +91 -0
- package/dist/overlays/index.d.ts +15 -0
- package/dist/overlays/index.js +15 -0
- package/dist/overlays/info-tip.d.ts +41 -0
- package/dist/overlays/info-tip.js +45 -0
- package/dist/overlays/menubar.d.ts +72 -0
- package/dist/overlays/menubar.js +100 -0
- package/dist/overlays/popover.d.ts +66 -0
- package/dist/overlays/popover.js +114 -0
- package/dist/overlays/sheet.d.ts +78 -0
- package/dist/overlays/sheet.js +131 -0
- package/dist/overlays/toast.d.ts +106 -0
- package/dist/overlays/toast.js +146 -0
- package/dist/overlays/tooltip.d.ts +57 -0
- package/dist/overlays/tooltip.js +95 -0
- package/dist/primitives/avatar.d.ts +51 -0
- package/dist/primitives/avatar.js +93 -0
- package/dist/primitives/button.d.ts +46 -0
- package/dist/primitives/button.js +94 -0
- package/dist/primitives/chip.d.ts +47 -0
- package/dist/primitives/chip.js +152 -0
- package/dist/primitives/icon-button.d.ts +41 -0
- package/dist/primitives/icon-button.js +59 -0
- package/dist/primitives/index.d.ts +10 -0
- package/dist/primitives/index.js +10 -0
- package/dist/primitives/kbd.d.ts +17 -0
- package/dist/primitives/kbd.js +24 -0
- package/dist/primitives/separator.d.ts +25 -0
- package/dist/primitives/separator.js +30 -0
- package/dist/primitives/skeleton.d.ts +20 -0
- package/dist/primitives/skeleton.js +27 -0
- package/dist/primitives/spinner.d.ts +26 -0
- package/dist/primitives/spinner.js +31 -0
- package/dist/primitives/status-dot.d.ts +44 -0
- package/dist/primitives/status-dot.js +50 -0
- package/dist/styles.css +19 -0
- package/dist/system/density.d.ts +33 -0
- package/dist/system/density.js +49 -0
- package/dist/system/index.d.ts +8 -0
- package/dist/system/index.js +7 -0
- package/dist/system/portal.d.ts +51 -0
- package/dist/system/portal.js +122 -0
- package/dist/system/prepaint.d.ts +38 -0
- package/dist/system/prepaint.js +37 -0
- package/dist/system/theme-provider.d.ts +72 -0
- package/dist/system/theme-provider.js +252 -0
- package/dist/system/use-density.d.ts +33 -0
- package/dist/system/use-density.js +84 -0
- package/dist/system/use-isomorphic-layout-effect.js +15 -0
- package/dist/system/use-theme.d.ts +19 -0
- package/dist/system/use-theme.js +25 -0
- package/dist/theming/_presets.d.ts +11 -0
- package/dist/theming/_presets.js +487 -0
- package/dist/theming/contrast.d.ts +110 -0
- package/dist/theming/contrast.js +167 -0
- package/dist/theming/create-theme.d.ts +165 -0
- package/dist/theming/create-theme.js +442 -0
- package/dist/theming/index.d.ts +5 -0
- package/dist/theming/index.js +5 -0
- package/dist/theming/serialize.d.ts +145 -0
- package/dist/theming/serialize.js +165 -0
- package/package.json +216 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
//#region src/theming/serialize.ts
|
|
2
|
+
/**
|
|
3
|
+
* Turning a resolved token map back into the stylesheet the tokens build would
|
|
4
|
+
* have written.
|
|
5
|
+
*
|
|
6
|
+
* This module exists so there is exactly **one** spelling of the output format.
|
|
7
|
+
* The spec's whole third-party theming story is "tier 2 always compiles down to
|
|
8
|
+
* tier 1" — a generated theme has to be indistinguishable from a hand-authored
|
|
9
|
+
* `[data-theme]` block, or a consumer ends up with two vocabularies and the
|
|
10
|
+
* generator becomes a toy. So the shapes below mirror `build.mjs` deliberately,
|
|
11
|
+
* comments included: same selector form, same declaration order, same section
|
|
12
|
+
* breaks. `test/theming/presets.test.ts` diffs the two.
|
|
13
|
+
*
|
|
14
|
+
* It is also the only place that touches raw strings, which makes it the place
|
|
15
|
+
* to stop injection. A theme name lands inside an attribute selector and a font
|
|
16
|
+
* stack lands inside a declaration; both are checked here rather than trusted.
|
|
17
|
+
*/
|
|
18
|
+
/** The one custom-property prefix this design system emits. */
|
|
19
|
+
const CUE_TOKEN_PREFIX = "--cue-";
|
|
20
|
+
/**
|
|
21
|
+
* What a theme may be called.
|
|
22
|
+
*
|
|
23
|
+
* The name is interpolated into `[data-theme="…"]`, so the pattern is a
|
|
24
|
+
* whitelist rather than an escape: a CSS identifier, which is also what a
|
|
25
|
+
* `data-theme` attribute is expected to hold and what a file called
|
|
26
|
+
* `<name>.css` can be named.
|
|
27
|
+
*/
|
|
28
|
+
const THEME_NAME_PATTERN = /^[a-z][a-z0-9-]*$/i;
|
|
29
|
+
/**
|
|
30
|
+
* Characters a value may never contain: the ones that end a declaration, end a
|
|
31
|
+
* block, or open a comment.
|
|
32
|
+
*
|
|
33
|
+
* Colour anchors do not need this — they are parsed by culori and re-emitted, so
|
|
34
|
+
* a value that is not a colour never reaches the output. Font stacks are the
|
|
35
|
+
* exception: they are free text by nature, and pass through verbatim.
|
|
36
|
+
*/
|
|
37
|
+
const UNSAFE_VALUE = /[;{}]|\/\*/;
|
|
38
|
+
/**
|
|
39
|
+
* Check a theme name and hand it back.
|
|
40
|
+
*
|
|
41
|
+
* @param name - The proposed theme name.
|
|
42
|
+
* @returns The same name, once it is known to be safe to interpolate.
|
|
43
|
+
* @throws TypeError if the name is not a CSS identifier.
|
|
44
|
+
* @example
|
|
45
|
+
* assertThemeName("acme-dark"); // → "acme-dark"
|
|
46
|
+
*/
|
|
47
|
+
function assertThemeName(name) {
|
|
48
|
+
if (!THEME_NAME_PATTERN.test(name)) throw new TypeError(`theme name must be a CSS identifier (letters, digits and dashes, starting with a letter), got ${JSON.stringify(name)}`);
|
|
49
|
+
return name;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Check a free-text declaration value and hand it back.
|
|
53
|
+
*
|
|
54
|
+
* @param name - The token the value belongs to, for the error message.
|
|
55
|
+
* @param value - The proposed value.
|
|
56
|
+
* @returns The same value, once it is known to stay inside its declaration.
|
|
57
|
+
* @throws TypeError if the value could end the declaration or the block.
|
|
58
|
+
* @example
|
|
59
|
+
* assertCssValue("font-mono", '"Berkeley Mono", monospace');
|
|
60
|
+
*/
|
|
61
|
+
function assertCssValue(name, value) {
|
|
62
|
+
if (UNSAFE_VALUE.test(value)) throw new TypeError(`${name} may not contain ";", "{", "}" or "/*" — got ${JSON.stringify(value)}`);
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The custom property a token is emitted as.
|
|
67
|
+
*
|
|
68
|
+
* Idempotent, so code that already holds `--cue-bg` can pass it straight back
|
|
69
|
+
* through instead of stripping the prefix first.
|
|
70
|
+
*
|
|
71
|
+
* @param name - A bare token name, or an already-prefixed property.
|
|
72
|
+
* @returns The `--cue-*` custom property name.
|
|
73
|
+
* @example
|
|
74
|
+
* tokenProperty("surface-1"); // → "--cue-surface-1"
|
|
75
|
+
*/
|
|
76
|
+
function tokenProperty(name) {
|
|
77
|
+
return name.startsWith("--cue-") ? name : `${CUE_TOKEN_PREFIX}${name}`;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The selector a theme's declarations live under.
|
|
81
|
+
*
|
|
82
|
+
* Attribute selectors, not classes, because the two axes have to compose: a
|
|
83
|
+
* `[data-theme]` on the root and another on a portal, a `[data-mode]` crossed
|
|
84
|
+
* over either, all at the same specificity so later blocks win predictably.
|
|
85
|
+
*
|
|
86
|
+
* @param name - The theme name. Not re-checked — {@link assertThemeName} owns that.
|
|
87
|
+
* @param options - Which axes to cross with.
|
|
88
|
+
* @returns The CSS selector.
|
|
89
|
+
* @example
|
|
90
|
+
* themeSelector("acme", { mode: "light" }); // → '[data-theme="acme"][data-mode="light"]'
|
|
91
|
+
*/
|
|
92
|
+
function themeSelector(name, options = {}) {
|
|
93
|
+
const { mode, density } = options;
|
|
94
|
+
return [
|
|
95
|
+
`[data-theme="${name}"]`,
|
|
96
|
+
mode === "light" ? "[data-mode=\"light\"]" : "",
|
|
97
|
+
density === void 0 ? "" : `[data-density="${density}"]`
|
|
98
|
+
].join("");
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The derived colours every theme block carries, as `[token, value]` pairs.
|
|
102
|
+
*
|
|
103
|
+
* They are `color-mix()` expressions over `var(--cue-*)` rather than resolved
|
|
104
|
+
* literals, and they are emitted **inside** the theme block rather than once on
|
|
105
|
+
* `:root`, for the same reason the build does it: a custom property's `var()`
|
|
106
|
+
* references are substituted at the element that declares it, so a `:root`-level
|
|
107
|
+
* mix would freeze the default theme's accent into every nested theme.
|
|
108
|
+
*/
|
|
109
|
+
const DERIVED_TOKEN_TEMPLATES = [["accent-soft", "color-mix(in oklch, var(--cue-accent) 14%, transparent)"], ...[
|
|
110
|
+
"ok",
|
|
111
|
+
"busy",
|
|
112
|
+
"warn",
|
|
113
|
+
"danger",
|
|
114
|
+
"info"
|
|
115
|
+
].flatMap((status) => [[`${status}-soft`, `color-mix(in oklch, var(--cue-${status}) 12%, transparent)`], [`${status}-border`, `color-mix(in oklch, var(--cue-${status}) 35%, transparent)`]])];
|
|
116
|
+
/**
|
|
117
|
+
* {@link DERIVED_TOKEN_TEMPLATES} as a property → value map.
|
|
118
|
+
*
|
|
119
|
+
* @returns The eleven derived declarations, keyed by custom property.
|
|
120
|
+
* @example
|
|
121
|
+
* derivedTokens()["--cue-accent-soft"];
|
|
122
|
+
*/
|
|
123
|
+
function derivedTokens() {
|
|
124
|
+
return Object.fromEntries(DERIVED_TOKEN_TEMPLATES.map(([name, value]) => [tokenProperty(name), value]));
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* One rule, printed.
|
|
128
|
+
*
|
|
129
|
+
* Empty sections vanish rather than leaving a comment with nothing under it —
|
|
130
|
+
* which is what makes "emit the fonts section only if there are fonts" a
|
|
131
|
+
* data decision instead of a branch at every call site.
|
|
132
|
+
*
|
|
133
|
+
* @param block - Selector, colour scheme and sections.
|
|
134
|
+
* @returns The rule, without a trailing newline.
|
|
135
|
+
* @example
|
|
136
|
+
* serializeThemeBlock({ selector: ":root", sections: [{ declarations: [["--cue-bg", "#000"]] }] });
|
|
137
|
+
*/
|
|
138
|
+
function serializeThemeBlock(block) {
|
|
139
|
+
const lines = [];
|
|
140
|
+
if (block.colorScheme !== void 0) lines.push(` color-scheme: ${block.colorScheme};`);
|
|
141
|
+
for (const section of block.sections) {
|
|
142
|
+
if (section.declarations.length === 0) continue;
|
|
143
|
+
if (section.comment !== void 0) {
|
|
144
|
+
if (lines.length > 0) lines.push("");
|
|
145
|
+
lines.push(` /* ${section.comment} */`);
|
|
146
|
+
}
|
|
147
|
+
for (const [name, value] of section.declarations) lines.push(` ${name}: ${value};`);
|
|
148
|
+
}
|
|
149
|
+
return `${block.selector} {\n${lines.join("\n")}\n}`;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* A whole generated stylesheet: banner, then one rule per block.
|
|
153
|
+
*
|
|
154
|
+
* @param blocks - The rules, in cascade order — later blocks win ties.
|
|
155
|
+
* @param options - Banner text.
|
|
156
|
+
* @returns The stylesheet, newline-terminated.
|
|
157
|
+
* @example
|
|
158
|
+
* serializeThemeCss(blocks, { banner: "@cueplusplus/ui — createTheme()" });
|
|
159
|
+
*/
|
|
160
|
+
function serializeThemeCss(blocks, options = {}) {
|
|
161
|
+
const rules = blocks.map(serializeThemeBlock);
|
|
162
|
+
return `${[...options.banner === void 0 ? [] : [`/*! ${options.banner}\n * Generated by createTheme(). Do not edit by hand.\n */`], ...rules].join("\n\n")}\n`;
|
|
163
|
+
}
|
|
164
|
+
//#endregion
|
|
165
|
+
export { CUE_TOKEN_PREFIX, DERIVED_TOKEN_TEMPLATES, THEME_NAME_PATTERN, assertCssValue, assertThemeName, derivedTokens, serializeThemeBlock, serializeThemeCss, themeSelector, tokenProperty };
|
package/package.json
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cueplusplus/ui",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CUE++ design system components: Tailwind v4 styled wrappers over Base UI, driven by @cueplusplus/tokens.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/cueplusplus/product-design-system"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"registry": "https://registry.npmjs.org"
|
|
13
|
+
},
|
|
14
|
+
"sideEffects": [
|
|
15
|
+
"**/*.css"
|
|
16
|
+
],
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=22"
|
|
19
|
+
},
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"default": "./dist/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./styles.css": "./dist/styles.css",
|
|
26
|
+
"./package.json": "./package.json",
|
|
27
|
+
"./primitives": {
|
|
28
|
+
"types": "./dist/primitives/index.d.ts",
|
|
29
|
+
"default": "./dist/primitives/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./forms": {
|
|
32
|
+
"types": "./dist/forms/index.d.ts",
|
|
33
|
+
"default": "./dist/forms/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./overlays": {
|
|
36
|
+
"types": "./dist/overlays/index.d.ts",
|
|
37
|
+
"default": "./dist/overlays/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./charts": {
|
|
40
|
+
"types": "./dist/charts/index.d.ts",
|
|
41
|
+
"default": "./dist/charts/index.js"
|
|
42
|
+
},
|
|
43
|
+
"./chat": {
|
|
44
|
+
"types": "./dist/chat/index.d.ts",
|
|
45
|
+
"default": "./dist/chat/index.js"
|
|
46
|
+
},
|
|
47
|
+
"./chrome": {
|
|
48
|
+
"types": "./dist/chrome/index.d.ts",
|
|
49
|
+
"default": "./dist/chrome/index.js"
|
|
50
|
+
},
|
|
51
|
+
"./dmx": {
|
|
52
|
+
"types": "./dist/dmx/index.d.ts",
|
|
53
|
+
"default": "./dist/dmx/index.js"
|
|
54
|
+
},
|
|
55
|
+
"./midi": {
|
|
56
|
+
"types": "./dist/midi/index.d.ts",
|
|
57
|
+
"default": "./dist/midi/index.js"
|
|
58
|
+
},
|
|
59
|
+
"./flow": {
|
|
60
|
+
"types": "./dist/flow/index.d.ts",
|
|
61
|
+
"default": "./dist/flow/index.js"
|
|
62
|
+
},
|
|
63
|
+
"./flow.css": "./dist/flow/flow.css",
|
|
64
|
+
"./instruments": {
|
|
65
|
+
"types": "./dist/instruments/index.d.ts",
|
|
66
|
+
"default": "./dist/instruments/index.js"
|
|
67
|
+
},
|
|
68
|
+
"./instruments/log-viewer": {
|
|
69
|
+
"types": "./dist/instruments/log-viewer.d.ts",
|
|
70
|
+
"default": "./dist/instruments/log-viewer.js"
|
|
71
|
+
},
|
|
72
|
+
"./instruments/data-table": {
|
|
73
|
+
"types": "./dist/instruments/data-table.d.ts",
|
|
74
|
+
"default": "./dist/instruments/data-table.js"
|
|
75
|
+
},
|
|
76
|
+
"./date": {
|
|
77
|
+
"types": "./dist/date/index.d.ts",
|
|
78
|
+
"default": "./dist/date/index.js"
|
|
79
|
+
},
|
|
80
|
+
"./color": {
|
|
81
|
+
"types": "./dist/color/index.d.ts",
|
|
82
|
+
"default": "./dist/color/index.js"
|
|
83
|
+
},
|
|
84
|
+
"./configurator": {
|
|
85
|
+
"types": "./dist/configurator/index.d.ts",
|
|
86
|
+
"default": "./dist/configurator/index.js"
|
|
87
|
+
},
|
|
88
|
+
"./layout": {
|
|
89
|
+
"types": "./dist/layout/index.d.ts",
|
|
90
|
+
"default": "./dist/layout/index.js"
|
|
91
|
+
},
|
|
92
|
+
"./layout/carousel": {
|
|
93
|
+
"types": "./dist/layout/carousel.d.ts",
|
|
94
|
+
"default": "./dist/layout/carousel.js"
|
|
95
|
+
},
|
|
96
|
+
"./layout/resizable": {
|
|
97
|
+
"types": "./dist/layout/resizable.d.ts",
|
|
98
|
+
"default": "./dist/layout/resizable.js"
|
|
99
|
+
},
|
|
100
|
+
"./system": {
|
|
101
|
+
"types": "./dist/system/index.d.ts",
|
|
102
|
+
"default": "./dist/system/index.js"
|
|
103
|
+
},
|
|
104
|
+
"./theming": {
|
|
105
|
+
"types": "./dist/theming/index.d.ts",
|
|
106
|
+
"default": "./dist/theming/index.js"
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
"files": [
|
|
110
|
+
"dist"
|
|
111
|
+
],
|
|
112
|
+
"dependencies": {
|
|
113
|
+
"clsx": "^2.1.1",
|
|
114
|
+
"culori": "^4.0.2",
|
|
115
|
+
"tailwind-merge": "^3.6.0",
|
|
116
|
+
"@cueplusplus/tokens": "0.1.0"
|
|
117
|
+
},
|
|
118
|
+
"peerDependencies": {
|
|
119
|
+
"@base-ui/react": "^1.7.0",
|
|
120
|
+
"@internationalized/date": "^3.12.3",
|
|
121
|
+
"@tanstack/react-table": "^9.1.2",
|
|
122
|
+
"@tanstack/react-virtual": "^3.14.9",
|
|
123
|
+
"@xyflow/react": "^12.11.3",
|
|
124
|
+
"anser": "^2.3.5",
|
|
125
|
+
"date-fns": "^4.4.0",
|
|
126
|
+
"embla-carousel-react": "^8.6.0",
|
|
127
|
+
"lucide-react": "^1.31.0",
|
|
128
|
+
"react": "^19.0.0",
|
|
129
|
+
"react-aria-components": "^1.20.0",
|
|
130
|
+
"react-day-picker": "^10.0.1",
|
|
131
|
+
"react-dom": "^19.0.0",
|
|
132
|
+
"react-resizable-panels": "^4.12.3",
|
|
133
|
+
"recharts": "^3.10.1",
|
|
134
|
+
"tailwindcss": "^4.0.0"
|
|
135
|
+
},
|
|
136
|
+
"peerDependenciesMeta": {
|
|
137
|
+
"@internationalized/date": {
|
|
138
|
+
"optional": true
|
|
139
|
+
},
|
|
140
|
+
"@tanstack/react-table": {
|
|
141
|
+
"optional": true
|
|
142
|
+
},
|
|
143
|
+
"@tanstack/react-virtual": {
|
|
144
|
+
"optional": true
|
|
145
|
+
},
|
|
146
|
+
"@xyflow/react": {
|
|
147
|
+
"optional": true
|
|
148
|
+
},
|
|
149
|
+
"anser": {
|
|
150
|
+
"optional": true
|
|
151
|
+
},
|
|
152
|
+
"date-fns": {
|
|
153
|
+
"optional": true
|
|
154
|
+
},
|
|
155
|
+
"embla-carousel-react": {
|
|
156
|
+
"optional": true
|
|
157
|
+
},
|
|
158
|
+
"lucide-react": {
|
|
159
|
+
"optional": true
|
|
160
|
+
},
|
|
161
|
+
"react-aria-components": {
|
|
162
|
+
"optional": true
|
|
163
|
+
},
|
|
164
|
+
"react-day-picker": {
|
|
165
|
+
"optional": true
|
|
166
|
+
},
|
|
167
|
+
"react-resizable-panels": {
|
|
168
|
+
"optional": true
|
|
169
|
+
},
|
|
170
|
+
"recharts": {
|
|
171
|
+
"optional": true
|
|
172
|
+
},
|
|
173
|
+
"tailwindcss": {
|
|
174
|
+
"optional": true
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
"devDependencies": {
|
|
178
|
+
"@arethetypeswrong/cli": "^0.18.5",
|
|
179
|
+
"@base-ui/react": "^1.7.0",
|
|
180
|
+
"@internationalized/date": "^3.12.3",
|
|
181
|
+
"@tanstack/react-table": "^9.1.2",
|
|
182
|
+
"@tanstack/react-virtual": "^3.14.9",
|
|
183
|
+
"@testing-library/dom": "^10.4.1",
|
|
184
|
+
"@testing-library/jest-dom": "^7.0.1",
|
|
185
|
+
"@testing-library/react": "^16.3.2",
|
|
186
|
+
"@testing-library/user-event": "^14.6.4",
|
|
187
|
+
"@types/culori": "^4.0.1",
|
|
188
|
+
"@types/node": "^24.0.0",
|
|
189
|
+
"@types/react": "^19.2.0",
|
|
190
|
+
"@types/react-dom": "^19.2.0",
|
|
191
|
+
"@vitejs/plugin-react": "^6.0.5",
|
|
192
|
+
"@xyflow/react": "^12.11.3",
|
|
193
|
+
"anser": "^2.3.5",
|
|
194
|
+
"date-fns": "^4.4.0",
|
|
195
|
+
"embla-carousel-react": "^8.6.0",
|
|
196
|
+
"jsdom": "^30.0.1",
|
|
197
|
+
"lucide-react": "^1.31.0",
|
|
198
|
+
"publint": "^0.3.23",
|
|
199
|
+
"react": "^19.2.0",
|
|
200
|
+
"react-aria-components": "^1.20.0",
|
|
201
|
+
"react-day-picker": "^10.0.1",
|
|
202
|
+
"react-dom": "^19.2.0",
|
|
203
|
+
"react-resizable-panels": "^4.12.3",
|
|
204
|
+
"recharts": "^3.10.1",
|
|
205
|
+
"tailwindcss": "^4.3.3",
|
|
206
|
+
"tsdown": "0.22.14",
|
|
207
|
+
"typescript": "^5.7.0",
|
|
208
|
+
"vitest": "^4.1.10",
|
|
209
|
+
"@repo/typescript-config": "0.0.0"
|
|
210
|
+
},
|
|
211
|
+
"scripts": {
|
|
212
|
+
"build": "tsdown",
|
|
213
|
+
"test": "vitest run",
|
|
214
|
+
"check:publish": "publint && attw --pack ."
|
|
215
|
+
}
|
|
216
|
+
}
|