@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,39 @@
|
|
|
1
|
+
//#region src/charts/_token.ts
|
|
2
|
+
/**
|
|
3
|
+
* Two ways to read a colour token, and the rule for when each one is right.
|
|
4
|
+
*
|
|
5
|
+
* A chart wants both. Anything the browser paints — a stroke, a fill, a CSS
|
|
6
|
+
* custom property — should carry the **reference** (`var(--cue-accent)`), because
|
|
7
|
+
* a reference re-resolves for free when the theme, the mode or a nested density
|
|
8
|
+
* island changes, with no React involved. Anything JavaScript has to *compute
|
|
9
|
+
* with* — deriving a ramp in oklch, handing a colour to a canvas — needs the
|
|
10
|
+
* **resolved** value, because `var()` is not a colour to anything but CSS.
|
|
11
|
+
*
|
|
12
|
+
* The resolution is deliberately a function call rather than a cached constant:
|
|
13
|
+
* called during render it sees the theme that is stamped right now, which is what
|
|
14
|
+
* makes every palette in this group theme-reactive.
|
|
15
|
+
*
|
|
16
|
+
* @internal Not part of the public API.
|
|
17
|
+
*/
|
|
18
|
+
/** The CSS-level reference to a semantic token: `accent` → `var(--cue-accent)`. */
|
|
19
|
+
function tokenRef(name) {
|
|
20
|
+
return `var(--cue-${name})`;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The token's computed value in the theme that applies at `element`.
|
|
24
|
+
*
|
|
25
|
+
* @param name - Token name without the `--cue-` prefix.
|
|
26
|
+
* @param element - Where to resolve. Defaults to the document element, which is
|
|
27
|
+
* where `ThemeProvider` stamps by default; pass a node inside a portal or a
|
|
28
|
+
* nested theme to read that scope instead.
|
|
29
|
+
* @returns The trimmed value, or `null` when there is no DOM (server render) or
|
|
30
|
+
* nothing has defined the token.
|
|
31
|
+
*/
|
|
32
|
+
function resolveToken(name, element) {
|
|
33
|
+
if (typeof window === "undefined" || typeof document === "undefined") return null;
|
|
34
|
+
const target = element ?? document.documentElement;
|
|
35
|
+
const value = window.getComputedStyle(target).getPropertyValue(`--cue-${name}`).trim();
|
|
36
|
+
return value === "" ? null : value;
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
export { resolveToken, tokenRef };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
//#region src/charts/container.d.ts
|
|
3
|
+
interface ChartContainerProps extends Omit<React.ComponentPropsWithoutRef<"div">, "children"> {
|
|
4
|
+
/** The chart. Exactly one element — recharts' container takes a single child. */
|
|
5
|
+
children: React.ReactElement;
|
|
6
|
+
/** Plot height in px at the 16px root. Defaults to `200`. Ignored when `aspect` is set. */
|
|
7
|
+
height?: number;
|
|
8
|
+
/** Width-to-height ratio, letting the plot size itself from its column instead. */
|
|
9
|
+
aspect?: number;
|
|
10
|
+
/**
|
|
11
|
+
* What the chart shows. Given, the box becomes a named `figure`; a shape is
|
|
12
|
+
* not self-describing, so name the series.
|
|
13
|
+
*/
|
|
14
|
+
label?: string;
|
|
15
|
+
/**
|
|
16
|
+
* The series palette, published as `--chart-1`…`--chart-N`. Defaults to
|
|
17
|
+
* {@link CHART_TONES}.
|
|
18
|
+
*/
|
|
19
|
+
tones?: readonly string[];
|
|
20
|
+
/** Throttle for the resize observer, in ms. Defaults to none. */
|
|
21
|
+
debounce?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The box every chart in this system sits in.
|
|
25
|
+
*
|
|
26
|
+
* It does three things, and deliberately not a fourth:
|
|
27
|
+
*
|
|
28
|
+
* 1. **It publishes the palette as custom properties.** `--chart-1`…`--chart-N`
|
|
29
|
+
* carry `var(--cue-accent)`, `var(--cue-info)` and the rest *by reference*,
|
|
30
|
+
* so a series written `<Line stroke={chartToneVar(0)} />` re-hues on a theme
|
|
31
|
+
* switch with no re-render, no context and no effect. Resolving the palette in
|
|
32
|
+
* JavaScript would have made the chart a subscriber to the theme; this way it
|
|
33
|
+
* is simply painted in it.
|
|
34
|
+
* 2. **It re-inks recharts' chrome.** {@link chartChromeClasses} restyles the
|
|
35
|
+
* grid, axes and ticks from tokens through the SVG's own class names, so
|
|
36
|
+
* every axis is themed whether or not somebody remembered to configure it.
|
|
37
|
+
* 3. **It measures.** `ResponsiveContainer` is the only reliable way to give a
|
|
38
|
+
* recharts chart a pixel size, and it needs a box with a real height — which
|
|
39
|
+
* is what `height` (or `aspect`) sets, in `rem` so the plot scales with the
|
|
40
|
+
* root font size like everything else.
|
|
41
|
+
*
|
|
42
|
+
* What it does not do is wrap or re-export recharts' chart components. A chart is
|
|
43
|
+
* a composition, and hiding `LineChart`/`XAxis`/`Tooltip` behind a props object
|
|
44
|
+
* would mean re-implementing a charting library's API surface one prop at a time.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* <ChartContainer label="Requests per minute" height={220}>
|
|
48
|
+
* <LineChart data={series}>
|
|
49
|
+
* <CartesianGrid vertical={false} />
|
|
50
|
+
* <XAxis dataKey="t" />
|
|
51
|
+
* <Tooltip cursor={chartTooltipCursor} content={<ChartTooltipContent />} />
|
|
52
|
+
* <Line dataKey="requests" stroke={chartToneVar(0)} dot={false} />
|
|
53
|
+
* </LineChart>
|
|
54
|
+
* </ChartContainer>
|
|
55
|
+
*/
|
|
56
|
+
declare const ChartContainer: React.ForwardRefExoticComponent<ChartContainerProps & React.RefAttributes<HTMLDivElement>>;
|
|
57
|
+
//#endregion
|
|
58
|
+
export { ChartContainer, ChartContainerProps };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../lib/cn.js";
|
|
3
|
+
import { toRem } from "../instruments/_rem.js";
|
|
4
|
+
import { chartChromeClasses } from "./theme.js";
|
|
5
|
+
import { CHART_TONES, chartToneProperty } from "./tones.js";
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
import { ResponsiveContainer } from "recharts";
|
|
9
|
+
//#region src/charts/container.tsx
|
|
10
|
+
/** Default plot height in px at the 16px root. */
|
|
11
|
+
const DEFAULT_HEIGHT_PX = 200;
|
|
12
|
+
/**
|
|
13
|
+
* The box every chart in this system sits in.
|
|
14
|
+
*
|
|
15
|
+
* It does three things, and deliberately not a fourth:
|
|
16
|
+
*
|
|
17
|
+
* 1. **It publishes the palette as custom properties.** `--chart-1`…`--chart-N`
|
|
18
|
+
* carry `var(--cue-accent)`, `var(--cue-info)` and the rest *by reference*,
|
|
19
|
+
* so a series written `<Line stroke={chartToneVar(0)} />` re-hues on a theme
|
|
20
|
+
* switch with no re-render, no context and no effect. Resolving the palette in
|
|
21
|
+
* JavaScript would have made the chart a subscriber to the theme; this way it
|
|
22
|
+
* is simply painted in it.
|
|
23
|
+
* 2. **It re-inks recharts' chrome.** {@link chartChromeClasses} restyles the
|
|
24
|
+
* grid, axes and ticks from tokens through the SVG's own class names, so
|
|
25
|
+
* every axis is themed whether or not somebody remembered to configure it.
|
|
26
|
+
* 3. **It measures.** `ResponsiveContainer` is the only reliable way to give a
|
|
27
|
+
* recharts chart a pixel size, and it needs a box with a real height — which
|
|
28
|
+
* is what `height` (or `aspect`) sets, in `rem` so the plot scales with the
|
|
29
|
+
* root font size like everything else.
|
|
30
|
+
*
|
|
31
|
+
* What it does not do is wrap or re-export recharts' chart components. A chart is
|
|
32
|
+
* a composition, and hiding `LineChart`/`XAxis`/`Tooltip` behind a props object
|
|
33
|
+
* would mean re-implementing a charting library's API surface one prop at a time.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* <ChartContainer label="Requests per minute" height={220}>
|
|
37
|
+
* <LineChart data={series}>
|
|
38
|
+
* <CartesianGrid vertical={false} />
|
|
39
|
+
* <XAxis dataKey="t" />
|
|
40
|
+
* <Tooltip cursor={chartTooltipCursor} content={<ChartTooltipContent />} />
|
|
41
|
+
* <Line dataKey="requests" stroke={chartToneVar(0)} dot={false} />
|
|
42
|
+
* </LineChart>
|
|
43
|
+
* </ChartContainer>
|
|
44
|
+
*/
|
|
45
|
+
const ChartContainer = React.forwardRef(function ChartContainer({ className, style, children, height = DEFAULT_HEIGHT_PX, aspect, label, tones = CHART_TONES, debounce, ...elementProps }, ref) {
|
|
46
|
+
const boxStyle = React.useMemo(() => {
|
|
47
|
+
const properties = {};
|
|
48
|
+
for (const [index, tone] of tones.entries()) properties[chartToneProperty(index)] = tone;
|
|
49
|
+
return {
|
|
50
|
+
...aspect === void 0 ? { height: toRem(height) } : null,
|
|
51
|
+
...properties,
|
|
52
|
+
...style
|
|
53
|
+
};
|
|
54
|
+
}, [
|
|
55
|
+
tones,
|
|
56
|
+
aspect,
|
|
57
|
+
height,
|
|
58
|
+
style
|
|
59
|
+
]);
|
|
60
|
+
return /* @__PURE__ */ jsx("div", {
|
|
61
|
+
ref,
|
|
62
|
+
role: label === void 0 ? void 0 : "figure",
|
|
63
|
+
"aria-label": label,
|
|
64
|
+
"data-slot": "chart",
|
|
65
|
+
className: cn("w-full min-w-0", chartChromeClasses, className),
|
|
66
|
+
style: boxStyle,
|
|
67
|
+
...elementProps,
|
|
68
|
+
children: /* @__PURE__ */ jsx(ResponsiveContainer, {
|
|
69
|
+
width: "100%",
|
|
70
|
+
...aspect === void 0 ? { height: "100%" } : { aspect },
|
|
71
|
+
debounce,
|
|
72
|
+
children
|
|
73
|
+
})
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
//#endregion
|
|
77
|
+
export { ChartContainer };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ChartContainer, ChartContainerProps } from "./container.js";
|
|
2
|
+
import { ACCENT_RAMP_MAX_LIGHTNESS, ACCENT_RAMP_MIN_LIGHTNESS, ACCENT_RAMP_STEPS, AccentRampOptions, BANDS_10, BANDS_16, BANDS_31, BANDS_7, ChartRamp, ChartRampProps, ChartSwatch, ChartSwatchProps, FrequencyBand, RAMPS, RAMP_NAMES, RampName, accentRamp } from "./ramps.js";
|
|
3
|
+
import { ChartTooltipContent, ChartTooltipContentProps, ChartTooltipEntry, chartChromeClasses, chartTooltipCursor } from "./theme.js";
|
|
4
|
+
import { CHART_EXTENDED_CHROMA, CHART_EXTENDED_HUES, CHART_EXTENDED_LIGHTNESS, CHART_EXTENDED_TONES, CHART_TONES, CHART_TONE_PROPERTY_PREFIX, CHART_TONE_TOKENS, ChartToneToken, ChartTonesOptions, chartToneProperty, chartToneVar, chartTones } from "./tones.js";
|
|
5
|
+
export { ACCENT_RAMP_MAX_LIGHTNESS, ACCENT_RAMP_MIN_LIGHTNESS, ACCENT_RAMP_STEPS, type AccentRampOptions, BANDS_10, BANDS_16, BANDS_31, BANDS_7, CHART_EXTENDED_CHROMA, CHART_EXTENDED_HUES, CHART_EXTENDED_LIGHTNESS, CHART_EXTENDED_TONES, CHART_TONES, CHART_TONE_PROPERTY_PREFIX, CHART_TONE_TOKENS, ChartContainer, type ChartContainerProps, ChartRamp, type ChartRampProps, ChartSwatch, type ChartSwatchProps, type ChartToneToken, type ChartTonesOptions, ChartTooltipContent, type ChartTooltipContentProps, type ChartTooltipEntry, type FrequencyBand, RAMPS, RAMP_NAMES, type RampName, accentRamp, chartChromeClasses, chartToneProperty, chartToneVar, chartTones, chartTooltipCursor };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ACCENT_RAMP_MAX_LIGHTNESS, ACCENT_RAMP_MIN_LIGHTNESS, ACCENT_RAMP_STEPS, BANDS_10, BANDS_16, BANDS_31, BANDS_7, ChartRamp, ChartSwatch, RAMPS, RAMP_NAMES, accentRamp } from "./ramps.js";
|
|
2
|
+
import { ChartTooltipContent, chartChromeClasses, chartTooltipCursor } from "./theme.js";
|
|
3
|
+
import { CHART_EXTENDED_CHROMA, CHART_EXTENDED_HUES, CHART_EXTENDED_LIGHTNESS, CHART_EXTENDED_TONES, CHART_TONES, CHART_TONE_PROPERTY_PREFIX, CHART_TONE_TOKENS, chartToneProperty, chartToneVar, chartTones } from "./tones.js";
|
|
4
|
+
import { ChartContainer } from "./container.js";
|
|
5
|
+
export { ACCENT_RAMP_MAX_LIGHTNESS, ACCENT_RAMP_MIN_LIGHTNESS, ACCENT_RAMP_STEPS, BANDS_10, BANDS_16, BANDS_31, BANDS_7, CHART_EXTENDED_CHROMA, CHART_EXTENDED_HUES, CHART_EXTENDED_LIGHTNESS, CHART_EXTENDED_TONES, CHART_TONES, CHART_TONE_PROPERTY_PREFIX, CHART_TONE_TOKENS, ChartContainer, ChartRamp, ChartSwatch, ChartTooltipContent, RAMPS, RAMP_NAMES, accentRamp, chartChromeClasses, chartToneProperty, chartToneVar, chartTones, chartTooltipCursor };
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
//#region src/charts/ramps.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* The ordered colour ramps: four frequency ramps, and one derived from the
|
|
5
|
+
* accent.
|
|
6
|
+
*
|
|
7
|
+
* A ramp is not a palette. A palette says *which category*; a ramp says *where
|
|
8
|
+
* on a scale* — which is why every ramp here is monotone in the thing it
|
|
9
|
+
* encodes, and why none of them re-hues per theme:
|
|
10
|
+
*
|
|
11
|
+
* - **The frequency ramps** are ported from ableton-sync verbatim, edges and
|
|
12
|
+
* colours intact. They are violet at 20 Hz through red, orange, yellow, green
|
|
13
|
+
* and cyan to blue at 20 kHz — the spectrum analogy every audio tool in the
|
|
14
|
+
* world uses. A listener who has learnt "bass is red" in one app must not have
|
|
15
|
+
* to relearn it here, and a theme switch must not move the bass.
|
|
16
|
+
* - **The accent ramp** is the sequential one, and it *does* follow the theme,
|
|
17
|
+
* because a heatmap's job is to say "more of the thing this console is about".
|
|
18
|
+
* It is derived in oklch from the live accent, so lightness climbs evenly by
|
|
19
|
+
* eye rather than by sRGB arithmetic.
|
|
20
|
+
*
|
|
21
|
+
* Kept free of recharts so the `/midi` spectrum visualiser can import the bands
|
|
22
|
+
* without pulling a charting library it never renders.
|
|
23
|
+
*/
|
|
24
|
+
/** One band of a frequency ramp. */
|
|
25
|
+
interface FrequencyBand {
|
|
26
|
+
/** Stable identity. Unique within its ramp. */
|
|
27
|
+
id: string;
|
|
28
|
+
/** What to print in a legend: `"1 kHz"`, `"Sub Bass"`. */
|
|
29
|
+
label: string;
|
|
30
|
+
/** Lower edge, in Hz. Equal to the previous band's `maxFreq`. */
|
|
31
|
+
minFreq: number;
|
|
32
|
+
/** Upper edge, in Hz. */
|
|
33
|
+
maxFreq: number;
|
|
34
|
+
/** The band's ink: a literal, deliberately independent of the theme. */
|
|
35
|
+
color: string;
|
|
36
|
+
}
|
|
37
|
+
/** Seven musical ranges — the default, and the one a mix engineer thinks in. */
|
|
38
|
+
declare const BANDS_7: readonly FrequencyBand[];
|
|
39
|
+
/** Ten bands — the octave spacing of a standard graphic EQ. */
|
|
40
|
+
declare const BANDS_10: readonly FrequencyBand[];
|
|
41
|
+
/** Sixteen bands — half-octave detail. */
|
|
42
|
+
declare const BANDS_16: readonly FrequencyBand[];
|
|
43
|
+
/** Thirty-one bands — ISO third-octave, the professional analyser resolution. */
|
|
44
|
+
declare const BANDS_31: readonly FrequencyBand[];
|
|
45
|
+
/** Every frequency ramp, coarsest first. */
|
|
46
|
+
declare const RAMP_NAMES: readonly ["bands-7", "bands-10", "bands-16", "bands-31"];
|
|
47
|
+
/** One of the four frequency ramps. */
|
|
48
|
+
type RampName = (typeof RAMP_NAMES)[number];
|
|
49
|
+
/**
|
|
50
|
+
* The frequency ramps, indexed by name, so a resolution picker can be a select
|
|
51
|
+
* over {@link RAMP_NAMES} rather than a switch statement.
|
|
52
|
+
*
|
|
53
|
+
* The sequential ramp is not in here on purpose: it depends on the live theme,
|
|
54
|
+
* so it is a call — {@link accentRamp} — not a constant.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* <ChartRamp label="Third octave" colors={RAMPS["bands-31"].map((band) => band.color)} />
|
|
58
|
+
*/
|
|
59
|
+
declare const RAMPS: Record<RampName, readonly FrequencyBand[]>;
|
|
60
|
+
/** Steps in a sequential ramp when the caller does not say. */
|
|
61
|
+
declare const ACCENT_RAMP_STEPS = 9;
|
|
62
|
+
/** Lightness of the darkest step: dark enough to read as "none", still not black. */
|
|
63
|
+
declare const ACCENT_RAMP_MIN_LIGHTNESS = 0.3;
|
|
64
|
+
/** Lightness of the lightest step: bright enough to read as "most", still not white. */
|
|
65
|
+
declare const ACCENT_RAMP_MAX_LIGHTNESS = 0.92;
|
|
66
|
+
interface AccentRampOptions {
|
|
67
|
+
/** How many steps. Defaults to {@link ACCENT_RAMP_STEPS}. */
|
|
68
|
+
steps?: number;
|
|
69
|
+
/**
|
|
70
|
+
* Where `--cue-accent` resolves. Defaults to the document element; pass a node
|
|
71
|
+
* inside a portal or a nested theme to read that scope instead.
|
|
72
|
+
*/
|
|
73
|
+
element?: Element | null;
|
|
74
|
+
/** Anchor colour, instead of the live accent. Any CSS colour CSS itself parses. */
|
|
75
|
+
from?: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* A sequential ramp anchored on the accent, darkest first.
|
|
79
|
+
*
|
|
80
|
+
* Lightness climbs linearly in oklch, which is the point of doing this in oklch
|
|
81
|
+
* at all: an evenly spaced sRGB ramp bunches up at the dark end, so the reader
|
|
82
|
+
* sees steps where the data has none. Hue is held at the accent's, and chroma is
|
|
83
|
+
* held at the accent's and then **clamped** into sRGB rather than clipped —
|
|
84
|
+
* clipping a too-saturated dark step turns it into a different colour, whereas
|
|
85
|
+
* clamping only takes the saturation the display cannot show anyway. That is
|
|
86
|
+
* also what tapers the ends naturally: no colour holds full chroma at L 0.3.
|
|
87
|
+
*
|
|
88
|
+
* @param options - Step count, anchor, and where to resolve the accent.
|
|
89
|
+
* @returns `steps` CSS colours, darkest first: hex when the anchor resolved, live
|
|
90
|
+
* `color-mix()` expressions when it did not — which covers a server render, a
|
|
91
|
+
* theme that has not loaded yet, and an anchor no colour parser recognises.
|
|
92
|
+
* @example
|
|
93
|
+
* <Area fill={accentRamp({ steps: 5 })[3]} />
|
|
94
|
+
*/
|
|
95
|
+
declare function accentRamp(options?: AccentRampOptions): string[];
|
|
96
|
+
interface ChartSwatchProps extends Omit<React.ComponentPropsWithoutRef<"span">, "children" | "color"> {
|
|
97
|
+
/** The colour to show. Any CSS colour, including a `var()` reference. */
|
|
98
|
+
color: string;
|
|
99
|
+
/** What the colour stands for. Omit for a bare chip. */
|
|
100
|
+
label?: React.ReactNode;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* One colour and what it means: the atom a chart legend is built from.
|
|
104
|
+
*
|
|
105
|
+
* The chip is `aria-hidden` and the label is plain text, so the meaning survives
|
|
106
|
+
* without colour vision (WCAG 1.4.1). A swatch with no label is decoration and
|
|
107
|
+
* announces nothing at all, which is the honest reading of a colour with no
|
|
108
|
+
* caption.
|
|
109
|
+
*
|
|
110
|
+
* Static markup — no `"use client"`.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* {BANDS_7.map((band) => <ChartSwatch key={band.id} color={band.color} label={band.label} />)}
|
|
114
|
+
*/
|
|
115
|
+
declare const ChartSwatch: React.ForwardRefExoticComponent<ChartSwatchProps & React.RefAttributes<HTMLSpanElement>>;
|
|
116
|
+
interface ChartRampProps extends Omit<React.ComponentPropsWithoutRef<"div">, "children"> {
|
|
117
|
+
/** The ramp, in order. Any CSS colours. */
|
|
118
|
+
colors: readonly string[];
|
|
119
|
+
/** What the ramp encodes. Required: it is the strip's accessible name. */
|
|
120
|
+
label: string;
|
|
121
|
+
/** Strip height in px at the 16px root, emitted as `rem`. Defaults to `8`. */
|
|
122
|
+
height?: number;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* A ramp drawn as a strip: equal cells, no gaps, in order.
|
|
126
|
+
*
|
|
127
|
+
* Equal cells rather than a CSS gradient, because a ramp *is* discrete — a
|
|
128
|
+
* gradient would show steps the data cannot address, and would quietly disagree
|
|
129
|
+
* with the same ramp used to fill bars. No seams either, for the same reason the
|
|
130
|
+
* cells are equal: a seam reads as a category boundary, and a sequential scale
|
|
131
|
+
* has none.
|
|
132
|
+
*
|
|
133
|
+
* Static markup — no `"use client"`.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* <ChartRamp label="Density" colors={accentRamp()} />
|
|
137
|
+
*/
|
|
138
|
+
declare const ChartRamp: React.ForwardRefExoticComponent<ChartRampProps & React.RefAttributes<HTMLDivElement>>;
|
|
139
|
+
//#endregion
|
|
140
|
+
export { ACCENT_RAMP_MAX_LIGHTNESS, ACCENT_RAMP_MIN_LIGHTNESS, ACCENT_RAMP_STEPS, AccentRampOptions, BANDS_10, BANDS_16, BANDS_31, BANDS_7, ChartRamp, ChartRampProps, ChartSwatch, ChartSwatchProps, FrequencyBand, RAMPS, RAMP_NAMES, RampName, accentRamp };
|