@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,615 @@
|
|
|
1
|
+
import { cn } from "../lib/cn.js";
|
|
2
|
+
import { toRem } from "../instruments/_rem.js";
|
|
3
|
+
import { resolveToken } from "./_token.js";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { clampChroma, converter, formatHex, inGamut, parse } from "culori";
|
|
7
|
+
//#region src/charts/ramps.tsx
|
|
8
|
+
/** Seven musical ranges — the default, and the one a mix engineer thinks in. */
|
|
9
|
+
const BANDS_7 = [
|
|
10
|
+
{
|
|
11
|
+
id: "sub-bass",
|
|
12
|
+
label: "Sub Bass",
|
|
13
|
+
minFreq: 20,
|
|
14
|
+
maxFreq: 60,
|
|
15
|
+
color: "#8b00ff"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: "bass",
|
|
19
|
+
label: "Bass",
|
|
20
|
+
minFreq: 60,
|
|
21
|
+
maxFreq: 250,
|
|
22
|
+
color: "#ff0000"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: "low-mid",
|
|
26
|
+
label: "Low Mid",
|
|
27
|
+
minFreq: 250,
|
|
28
|
+
maxFreq: 500,
|
|
29
|
+
color: "#ff6600"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: "mid",
|
|
33
|
+
label: "Mid",
|
|
34
|
+
minFreq: 500,
|
|
35
|
+
maxFreq: 2e3,
|
|
36
|
+
color: "#ffff00"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: "high-mid",
|
|
40
|
+
label: "High Mid",
|
|
41
|
+
minFreq: 2e3,
|
|
42
|
+
maxFreq: 4e3,
|
|
43
|
+
color: "#00ff00"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: "high",
|
|
47
|
+
label: "High",
|
|
48
|
+
minFreq: 4e3,
|
|
49
|
+
maxFreq: 8e3,
|
|
50
|
+
color: "#00ffff"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
id: "presence",
|
|
54
|
+
label: "Presence",
|
|
55
|
+
minFreq: 8e3,
|
|
56
|
+
maxFreq: 2e4,
|
|
57
|
+
color: "#0000ff"
|
|
58
|
+
}
|
|
59
|
+
];
|
|
60
|
+
/** Ten bands — the octave spacing of a standard graphic EQ. */
|
|
61
|
+
const BANDS_10 = [
|
|
62
|
+
{
|
|
63
|
+
id: "band-31",
|
|
64
|
+
label: "31 Hz",
|
|
65
|
+
minFreq: 22,
|
|
66
|
+
maxFreq: 44,
|
|
67
|
+
color: "#8b00ff"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
id: "band-62",
|
|
71
|
+
label: "62 Hz",
|
|
72
|
+
minFreq: 44,
|
|
73
|
+
maxFreq: 88,
|
|
74
|
+
color: "#9b00ff"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
id: "band-125",
|
|
78
|
+
label: "125 Hz",
|
|
79
|
+
minFreq: 88,
|
|
80
|
+
maxFreq: 177,
|
|
81
|
+
color: "#ff0000"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
id: "band-250",
|
|
85
|
+
label: "250 Hz",
|
|
86
|
+
minFreq: 177,
|
|
87
|
+
maxFreq: 355,
|
|
88
|
+
color: "#ff3300"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
id: "band-500",
|
|
92
|
+
label: "500 Hz",
|
|
93
|
+
minFreq: 355,
|
|
94
|
+
maxFreq: 710,
|
|
95
|
+
color: "#ff6600"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
id: "band-1k",
|
|
99
|
+
label: "1 kHz",
|
|
100
|
+
minFreq: 710,
|
|
101
|
+
maxFreq: 1420,
|
|
102
|
+
color: "#ffff00"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
id: "band-2k",
|
|
106
|
+
label: "2 kHz",
|
|
107
|
+
minFreq: 1420,
|
|
108
|
+
maxFreq: 2840,
|
|
109
|
+
color: "#66ff00"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
id: "band-4k",
|
|
113
|
+
label: "4 kHz",
|
|
114
|
+
minFreq: 2840,
|
|
115
|
+
maxFreq: 5680,
|
|
116
|
+
color: "#00ff00"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
id: "band-8k",
|
|
120
|
+
label: "8 kHz",
|
|
121
|
+
minFreq: 5680,
|
|
122
|
+
maxFreq: 11360,
|
|
123
|
+
color: "#00ffff"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
id: "band-16k",
|
|
127
|
+
label: "16 kHz",
|
|
128
|
+
minFreq: 11360,
|
|
129
|
+
maxFreq: 2e4,
|
|
130
|
+
color: "#0000ff"
|
|
131
|
+
}
|
|
132
|
+
];
|
|
133
|
+
/** Sixteen bands — half-octave detail. */
|
|
134
|
+
const BANDS_16 = [
|
|
135
|
+
{
|
|
136
|
+
id: "band-25",
|
|
137
|
+
label: "25 Hz",
|
|
138
|
+
minFreq: 20,
|
|
139
|
+
maxFreq: 32,
|
|
140
|
+
color: "#8b00ff"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
id: "band-40",
|
|
144
|
+
label: "40 Hz",
|
|
145
|
+
minFreq: 32,
|
|
146
|
+
maxFreq: 50,
|
|
147
|
+
color: "#9400ff"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
id: "band-63",
|
|
151
|
+
label: "63 Hz",
|
|
152
|
+
minFreq: 50,
|
|
153
|
+
maxFreq: 80,
|
|
154
|
+
color: "#9d00ff"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
id: "band-100",
|
|
158
|
+
label: "100 Hz",
|
|
159
|
+
minFreq: 80,
|
|
160
|
+
maxFreq: 125,
|
|
161
|
+
color: "#ff0000"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
id: "band-160",
|
|
165
|
+
label: "160 Hz",
|
|
166
|
+
minFreq: 125,
|
|
167
|
+
maxFreq: 200,
|
|
168
|
+
color: "#ff1100"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
id: "band-250",
|
|
172
|
+
label: "250 Hz",
|
|
173
|
+
minFreq: 200,
|
|
174
|
+
maxFreq: 315,
|
|
175
|
+
color: "#ff2200"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
id: "band-400",
|
|
179
|
+
label: "400 Hz",
|
|
180
|
+
minFreq: 315,
|
|
181
|
+
maxFreq: 500,
|
|
182
|
+
color: "#ff4400"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
id: "band-630",
|
|
186
|
+
label: "630 Hz",
|
|
187
|
+
minFreq: 500,
|
|
188
|
+
maxFreq: 800,
|
|
189
|
+
color: "#ff6600"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
id: "band-1k",
|
|
193
|
+
label: "1 kHz",
|
|
194
|
+
minFreq: 800,
|
|
195
|
+
maxFreq: 1250,
|
|
196
|
+
color: "#ffaa00"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
id: "band-1k6",
|
|
200
|
+
label: "1.6 kHz",
|
|
201
|
+
minFreq: 1250,
|
|
202
|
+
maxFreq: 2e3,
|
|
203
|
+
color: "#ffff00"
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
id: "band-2k5",
|
|
207
|
+
label: "2.5 kHz",
|
|
208
|
+
minFreq: 2e3,
|
|
209
|
+
maxFreq: 3150,
|
|
210
|
+
color: "#aaff00"
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
id: "band-4k",
|
|
214
|
+
label: "4 kHz",
|
|
215
|
+
minFreq: 3150,
|
|
216
|
+
maxFreq: 5e3,
|
|
217
|
+
color: "#66ff00"
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
id: "band-6k3",
|
|
221
|
+
label: "6.3 kHz",
|
|
222
|
+
minFreq: 5e3,
|
|
223
|
+
maxFreq: 8e3,
|
|
224
|
+
color: "#00ff00"
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
id: "band-10k",
|
|
228
|
+
label: "10 kHz",
|
|
229
|
+
minFreq: 8e3,
|
|
230
|
+
maxFreq: 12500,
|
|
231
|
+
color: "#00ff66"
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
id: "band-16k",
|
|
235
|
+
label: "16 kHz",
|
|
236
|
+
minFreq: 12500,
|
|
237
|
+
maxFreq: 18e3,
|
|
238
|
+
color: "#00ffff"
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
id: "band-20k",
|
|
242
|
+
label: "20 kHz",
|
|
243
|
+
minFreq: 18e3,
|
|
244
|
+
maxFreq: 2e4,
|
|
245
|
+
color: "#0000ff"
|
|
246
|
+
}
|
|
247
|
+
];
|
|
248
|
+
/** Thirty-one bands — ISO third-octave, the professional analyser resolution. */
|
|
249
|
+
const BANDS_31 = [
|
|
250
|
+
{
|
|
251
|
+
id: "band-20",
|
|
252
|
+
label: "20 Hz",
|
|
253
|
+
minFreq: 18,
|
|
254
|
+
maxFreq: 22,
|
|
255
|
+
color: "#8b00ff"
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
id: "band-25",
|
|
259
|
+
label: "25 Hz",
|
|
260
|
+
minFreq: 22,
|
|
261
|
+
maxFreq: 28,
|
|
262
|
+
color: "#8f00ff"
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
id: "band-31",
|
|
266
|
+
label: "31 Hz",
|
|
267
|
+
minFreq: 28,
|
|
268
|
+
maxFreq: 35,
|
|
269
|
+
color: "#9400ff"
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
id: "band-40",
|
|
273
|
+
label: "40 Hz",
|
|
274
|
+
minFreq: 35,
|
|
275
|
+
maxFreq: 45,
|
|
276
|
+
color: "#9800ff"
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
id: "band-50",
|
|
280
|
+
label: "50 Hz",
|
|
281
|
+
minFreq: 45,
|
|
282
|
+
maxFreq: 57,
|
|
283
|
+
color: "#9d00ff"
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
id: "band-63",
|
|
287
|
+
label: "63 Hz",
|
|
288
|
+
minFreq: 57,
|
|
289
|
+
maxFreq: 71,
|
|
290
|
+
color: "#ff0000"
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
id: "band-80",
|
|
294
|
+
label: "80 Hz",
|
|
295
|
+
minFreq: 71,
|
|
296
|
+
maxFreq: 90,
|
|
297
|
+
color: "#ff0800"
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
id: "band-100",
|
|
301
|
+
label: "100 Hz",
|
|
302
|
+
minFreq: 90,
|
|
303
|
+
maxFreq: 113,
|
|
304
|
+
color: "#ff1100"
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
id: "band-125",
|
|
308
|
+
label: "125 Hz",
|
|
309
|
+
minFreq: 113,
|
|
310
|
+
maxFreq: 142,
|
|
311
|
+
color: "#ff1900"
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
id: "band-160",
|
|
315
|
+
label: "160 Hz",
|
|
316
|
+
minFreq: 142,
|
|
317
|
+
maxFreq: 180,
|
|
318
|
+
color: "#ff2200"
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
id: "band-200",
|
|
322
|
+
label: "200 Hz",
|
|
323
|
+
minFreq: 180,
|
|
324
|
+
maxFreq: 226,
|
|
325
|
+
color: "#ff2b00"
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
id: "band-250",
|
|
329
|
+
label: "250 Hz",
|
|
330
|
+
minFreq: 226,
|
|
331
|
+
maxFreq: 284,
|
|
332
|
+
color: "#ff3300"
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
id: "band-315",
|
|
336
|
+
label: "315 Hz",
|
|
337
|
+
minFreq: 284,
|
|
338
|
+
maxFreq: 358,
|
|
339
|
+
color: "#ff3c00"
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
id: "band-400",
|
|
343
|
+
label: "400 Hz",
|
|
344
|
+
minFreq: 358,
|
|
345
|
+
maxFreq: 452,
|
|
346
|
+
color: "#ff4400"
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
id: "band-500",
|
|
350
|
+
label: "500 Hz",
|
|
351
|
+
minFreq: 452,
|
|
352
|
+
maxFreq: 566,
|
|
353
|
+
color: "#ff5500"
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
id: "band-630",
|
|
357
|
+
label: "630 Hz",
|
|
358
|
+
minFreq: 566,
|
|
359
|
+
maxFreq: 716,
|
|
360
|
+
color: "#ff6600"
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
id: "band-800",
|
|
364
|
+
label: "800 Hz",
|
|
365
|
+
minFreq: 716,
|
|
366
|
+
maxFreq: 906,
|
|
367
|
+
color: "#ff7700"
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
id: "band-1k",
|
|
371
|
+
label: "1 kHz",
|
|
372
|
+
minFreq: 906,
|
|
373
|
+
maxFreq: 1130,
|
|
374
|
+
color: "#ffaa00"
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
id: "band-1k25",
|
|
378
|
+
label: "1.25 kHz",
|
|
379
|
+
minFreq: 1130,
|
|
380
|
+
maxFreq: 1420,
|
|
381
|
+
color: "#ffcc00"
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
id: "band-1k6",
|
|
385
|
+
label: "1.6 kHz",
|
|
386
|
+
minFreq: 1420,
|
|
387
|
+
maxFreq: 1800,
|
|
388
|
+
color: "#ffff00"
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
id: "band-2k",
|
|
392
|
+
label: "2 kHz",
|
|
393
|
+
minFreq: 1800,
|
|
394
|
+
maxFreq: 2260,
|
|
395
|
+
color: "#ccff00"
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
id: "band-2k5",
|
|
399
|
+
label: "2.5 kHz",
|
|
400
|
+
minFreq: 2260,
|
|
401
|
+
maxFreq: 2840,
|
|
402
|
+
color: "#aaff00"
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
id: "band-3k15",
|
|
406
|
+
label: "3.15 kHz",
|
|
407
|
+
minFreq: 2840,
|
|
408
|
+
maxFreq: 3580,
|
|
409
|
+
color: "#88ff00"
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
id: "band-4k",
|
|
413
|
+
label: "4 kHz",
|
|
414
|
+
minFreq: 3580,
|
|
415
|
+
maxFreq: 4520,
|
|
416
|
+
color: "#66ff00"
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
id: "band-5k",
|
|
420
|
+
label: "5 kHz",
|
|
421
|
+
minFreq: 4520,
|
|
422
|
+
maxFreq: 5660,
|
|
423
|
+
color: "#44ff00"
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
id: "band-6k3",
|
|
427
|
+
label: "6.3 kHz",
|
|
428
|
+
minFreq: 5660,
|
|
429
|
+
maxFreq: 7160,
|
|
430
|
+
color: "#22ff00"
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
id: "band-8k",
|
|
434
|
+
label: "8 kHz",
|
|
435
|
+
minFreq: 7160,
|
|
436
|
+
maxFreq: 9060,
|
|
437
|
+
color: "#00ff00"
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
id: "band-10k",
|
|
441
|
+
label: "10 kHz",
|
|
442
|
+
minFreq: 9060,
|
|
443
|
+
maxFreq: 11300,
|
|
444
|
+
color: "#00ff44"
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
id: "band-12k5",
|
|
448
|
+
label: "12.5 kHz",
|
|
449
|
+
minFreq: 11300,
|
|
450
|
+
maxFreq: 14200,
|
|
451
|
+
color: "#00ff88"
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
id: "band-16k",
|
|
455
|
+
label: "16 kHz",
|
|
456
|
+
minFreq: 14200,
|
|
457
|
+
maxFreq: 18e3,
|
|
458
|
+
color: "#00ffff"
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
id: "band-20k",
|
|
462
|
+
label: "20 kHz",
|
|
463
|
+
minFreq: 18e3,
|
|
464
|
+
maxFreq: 2e4,
|
|
465
|
+
color: "#0000ff"
|
|
466
|
+
}
|
|
467
|
+
];
|
|
468
|
+
/** Every frequency ramp, coarsest first. */
|
|
469
|
+
const RAMP_NAMES = [
|
|
470
|
+
"bands-7",
|
|
471
|
+
"bands-10",
|
|
472
|
+
"bands-16",
|
|
473
|
+
"bands-31"
|
|
474
|
+
];
|
|
475
|
+
/**
|
|
476
|
+
* The frequency ramps, indexed by name, so a resolution picker can be a select
|
|
477
|
+
* over {@link RAMP_NAMES} rather than a switch statement.
|
|
478
|
+
*
|
|
479
|
+
* The sequential ramp is not in here on purpose: it depends on the live theme,
|
|
480
|
+
* so it is a call — {@link accentRamp} — not a constant.
|
|
481
|
+
*
|
|
482
|
+
* @example
|
|
483
|
+
* <ChartRamp label="Third octave" colors={RAMPS["bands-31"].map((band) => band.color)} />
|
|
484
|
+
*/
|
|
485
|
+
const RAMPS = {
|
|
486
|
+
"bands-7": BANDS_7,
|
|
487
|
+
"bands-10": BANDS_10,
|
|
488
|
+
"bands-16": BANDS_16,
|
|
489
|
+
"bands-31": BANDS_31
|
|
490
|
+
};
|
|
491
|
+
/** Steps in a sequential ramp when the caller does not say. */
|
|
492
|
+
const ACCENT_RAMP_STEPS = 9;
|
|
493
|
+
/** Lightness of the darkest step: dark enough to read as "none", still not black. */
|
|
494
|
+
const ACCENT_RAMP_MIN_LIGHTNESS = .3;
|
|
495
|
+
/** Lightness of the lightest step: bright enough to read as "most", still not white. */
|
|
496
|
+
const ACCENT_RAMP_MAX_LIGHTNESS = .92;
|
|
497
|
+
const toOklch = converter("oklch");
|
|
498
|
+
const srgb = inGamut("rgb");
|
|
499
|
+
/** Where step `index` of `count` sits on the 0–1 run. */
|
|
500
|
+
function position(index, count) {
|
|
501
|
+
return count <= 1 ? 0 : index / (count - 1);
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* The step as a live CSS expression, for when the accent cannot be computed.
|
|
505
|
+
*
|
|
506
|
+
* Mixing in oklch is the same colour space the resolved path derives in, and
|
|
507
|
+
* `var(--cue-accent)` keeps it theme-reactive — so a chart that paints before
|
|
508
|
+
* the stylesheet has resolved still gets a monotone ramp in the right hue,
|
|
509
|
+
* rather than a ramp in an invented one. It floors at 25% accent so neither end
|
|
510
|
+
* collapses to flat black or flat white.
|
|
511
|
+
*/
|
|
512
|
+
function mixExpression(t) {
|
|
513
|
+
const toward = t <= .5 ? "#000000" : "#ffffff";
|
|
514
|
+
return `color-mix(in oklch, var(--cue-accent) ${Math.round(25 + (t <= .5 ? t : 1 - t) * 150)}%, ${toward})`;
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* A sequential ramp anchored on the accent, darkest first.
|
|
518
|
+
*
|
|
519
|
+
* Lightness climbs linearly in oklch, which is the point of doing this in oklch
|
|
520
|
+
* at all: an evenly spaced sRGB ramp bunches up at the dark end, so the reader
|
|
521
|
+
* sees steps where the data has none. Hue is held at the accent's, and chroma is
|
|
522
|
+
* held at the accent's and then **clamped** into sRGB rather than clipped —
|
|
523
|
+
* clipping a too-saturated dark step turns it into a different colour, whereas
|
|
524
|
+
* clamping only takes the saturation the display cannot show anyway. That is
|
|
525
|
+
* also what tapers the ends naturally: no colour holds full chroma at L 0.3.
|
|
526
|
+
*
|
|
527
|
+
* @param options - Step count, anchor, and where to resolve the accent.
|
|
528
|
+
* @returns `steps` CSS colours, darkest first: hex when the anchor resolved, live
|
|
529
|
+
* `color-mix()` expressions when it did not — which covers a server render, a
|
|
530
|
+
* theme that has not loaded yet, and an anchor no colour parser recognises.
|
|
531
|
+
* @example
|
|
532
|
+
* <Area fill={accentRamp({ steps: 5 })[3]} />
|
|
533
|
+
*/
|
|
534
|
+
function accentRamp(options = {}) {
|
|
535
|
+
const { steps = 9, element, from } = options;
|
|
536
|
+
const count = Math.max(1, Math.floor(steps));
|
|
537
|
+
const anchor = from ?? resolveToken("accent", element);
|
|
538
|
+
const parsed = anchor === null ? void 0 : toOklch(parse(anchor));
|
|
539
|
+
return Array.from({ length: count }, (_unused, index) => {
|
|
540
|
+
const t = position(index, count);
|
|
541
|
+
if (parsed === void 0) return mixExpression(t);
|
|
542
|
+
const step = {
|
|
543
|
+
mode: "oklch",
|
|
544
|
+
l: ACCENT_RAMP_MIN_LIGHTNESS + t * .6200000000000001,
|
|
545
|
+
c: parsed.c,
|
|
546
|
+
h: parsed.h ?? 0
|
|
547
|
+
};
|
|
548
|
+
return formatHex(srgb(step) ? step : clampChroma(step, "oklch", "rgb"));
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* One colour and what it means: the atom a chart legend is built from.
|
|
553
|
+
*
|
|
554
|
+
* The chip is `aria-hidden` and the label is plain text, so the meaning survives
|
|
555
|
+
* without colour vision (WCAG 1.4.1). A swatch with no label is decoration and
|
|
556
|
+
* announces nothing at all, which is the honest reading of a colour with no
|
|
557
|
+
* caption.
|
|
558
|
+
*
|
|
559
|
+
* Static markup — no `"use client"`.
|
|
560
|
+
*
|
|
561
|
+
* @example
|
|
562
|
+
* {BANDS_7.map((band) => <ChartSwatch key={band.id} color={band.color} label={band.label} />)}
|
|
563
|
+
*/
|
|
564
|
+
const ChartSwatch = React.forwardRef(function ChartSwatch({ className, color, label, ...elementProps }, ref) {
|
|
565
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
566
|
+
ref,
|
|
567
|
+
"data-slot": "chart-swatch",
|
|
568
|
+
className: cn("inline-flex items-center gap-(--cue-space-2) font-mono text-(length:--cue-text-label) text-fg-muted", className),
|
|
569
|
+
...elementProps,
|
|
570
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
571
|
+
"aria-hidden": "true",
|
|
572
|
+
"data-slot": "chart-swatch-chip",
|
|
573
|
+
className: "size-[0.375rem] shrink-0 rounded-[1px]",
|
|
574
|
+
style: { backgroundColor: color }
|
|
575
|
+
}), label === void 0 ? null : /* @__PURE__ */ jsx("span", {
|
|
576
|
+
"data-slot": "chart-swatch-label",
|
|
577
|
+
children: label
|
|
578
|
+
})]
|
|
579
|
+
});
|
|
580
|
+
});
|
|
581
|
+
/** Default strip height in px at the 16px root — a rule, not a block. */
|
|
582
|
+
const DEFAULT_RAMP_HEIGHT_PX = 8;
|
|
583
|
+
/**
|
|
584
|
+
* A ramp drawn as a strip: equal cells, no gaps, in order.
|
|
585
|
+
*
|
|
586
|
+
* Equal cells rather than a CSS gradient, because a ramp *is* discrete — a
|
|
587
|
+
* gradient would show steps the data cannot address, and would quietly disagree
|
|
588
|
+
* with the same ramp used to fill bars. No seams either, for the same reason the
|
|
589
|
+
* cells are equal: a seam reads as a category boundary, and a sequential scale
|
|
590
|
+
* has none.
|
|
591
|
+
*
|
|
592
|
+
* Static markup — no `"use client"`.
|
|
593
|
+
*
|
|
594
|
+
* @example
|
|
595
|
+
* <ChartRamp label="Density" colors={accentRamp()} />
|
|
596
|
+
*/
|
|
597
|
+
const ChartRamp = React.forwardRef(function ChartRamp({ className, colors, label, height = DEFAULT_RAMP_HEIGHT_PX, ...elementProps }, ref) {
|
|
598
|
+
return /* @__PURE__ */ jsx("div", {
|
|
599
|
+
ref,
|
|
600
|
+
role: "img",
|
|
601
|
+
"aria-label": label,
|
|
602
|
+
"data-slot": "chart-ramp",
|
|
603
|
+
className: cn("flex w-full overflow-hidden rounded-(--radius-control)", className),
|
|
604
|
+
style: { height: toRem(height) },
|
|
605
|
+
...elementProps,
|
|
606
|
+
children: colors.map((color, index) => /* @__PURE__ */ jsx("span", {
|
|
607
|
+
"aria-hidden": "true",
|
|
608
|
+
"data-slot": "chart-ramp-cell",
|
|
609
|
+
className: "min-w-px flex-1",
|
|
610
|
+
style: { backgroundColor: color }
|
|
611
|
+
}, index))
|
|
612
|
+
});
|
|
613
|
+
});
|
|
614
|
+
//#endregion
|
|
615
|
+
export { 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 };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
//#region src/charts/theme.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* The recharts chrome, restated in this system's vocabulary.
|
|
5
|
+
*
|
|
6
|
+
* Recharts paints its grid, axes and ticks with presentation attributes baked
|
|
7
|
+
* into the SVG (`stroke="#ccc"`, `fill="#666"`). Those attributes lose to any
|
|
8
|
+
* CSS declaration, which is the whole opening: one scoped stylesheet on the
|
|
9
|
+
* chart's wrapper re-inks the entire chrome without a single prop threaded
|
|
10
|
+
* through the chart, and — because the declarations are token references — it
|
|
11
|
+
* re-inks again on a theme, mode or density switch with no React involved.
|
|
12
|
+
*
|
|
13
|
+
* The alternative, spreading a `{ stroke, fill, fontSize }` bundle onto every
|
|
14
|
+
* `CartesianGrid`, `XAxis` and `YAxis`, is the version of this that rots: the one
|
|
15
|
+
* axis somebody forgets to spread onto is grey forever, and nothing catches it.
|
|
16
|
+
*
|
|
17
|
+
* Deliberately recharts-free at the module level: only the container imports the
|
|
18
|
+
* library, so this file and the palette stay importable from groups that never
|
|
19
|
+
* render a chart.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Everything the chart wrapper needs to re-ink recharts' own SVG.
|
|
23
|
+
*
|
|
24
|
+
* Spread by `ChartContainer`; exported so an app that mounts a chart some other
|
|
25
|
+
* way (a recharts component outside the container, a printed export) gets the
|
|
26
|
+
* same chrome from the same source.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* <div className={cn(chartChromeClasses, "h-40")}><LineChart …/></div>
|
|
30
|
+
*/
|
|
31
|
+
declare const chartChromeClasses: string;
|
|
32
|
+
/**
|
|
33
|
+
* The cursor recharts draws under the tooltip.
|
|
34
|
+
*
|
|
35
|
+
* One object for both shapes it can take: a `<line>` on a line or area chart,
|
|
36
|
+
* where only the stroke lands, and a `<rect>` on a bar chart, where the faint
|
|
37
|
+
* fill washes the hovered band and the dashed rim keeps its edges legible. The
|
|
38
|
+
* dash is the same `2 3` the rest of the system uses for "this is a guide, not
|
|
39
|
+
* data".
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* <Tooltip cursor={chartTooltipCursor} content={<ChartTooltipContent />} />
|
|
43
|
+
*/
|
|
44
|
+
declare const chartTooltipCursor: {
|
|
45
|
+
readonly stroke: "var(--cue-fg)";
|
|
46
|
+
readonly strokeOpacity: 0.5;
|
|
47
|
+
readonly strokeWidth: 1;
|
|
48
|
+
readonly strokeDasharray: "2 3";
|
|
49
|
+
readonly fill: "var(--cue-fg)";
|
|
50
|
+
readonly fillOpacity: 0.06;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* One series' entry in a tooltip payload.
|
|
54
|
+
*
|
|
55
|
+
* Declared structurally rather than imported from recharts so nothing in this
|
|
56
|
+
* package's published types depends on an optional peer — an app that installs
|
|
57
|
+
* `@cueplusplus/ui` without recharts still type-checks.
|
|
58
|
+
*/
|
|
59
|
+
interface ChartTooltipEntry {
|
|
60
|
+
/** Series name, as recharts resolved it. */
|
|
61
|
+
name?: React.ReactNode;
|
|
62
|
+
/** The value at the hovered index. */
|
|
63
|
+
value?: number | string | readonly (number | string)[];
|
|
64
|
+
/** The colour recharts assigned the series. Drives the row's indicator. */
|
|
65
|
+
color?: string;
|
|
66
|
+
/** The key the series reads. Used for row identity when `name` repeats. */
|
|
67
|
+
dataKey?: string | number;
|
|
68
|
+
/** Unit suffix, when the series declares one. */
|
|
69
|
+
unit?: React.ReactNode;
|
|
70
|
+
}
|
|
71
|
+
interface ChartTooltipContentProps extends Omit<React.ComponentPropsWithoutRef<"div">, "children" | "content"> {
|
|
72
|
+
/** Whether the pointer is on the plot. Recharts supplies this. */
|
|
73
|
+
active?: boolean;
|
|
74
|
+
/** One entry per series at the hovered index. Recharts supplies this. */
|
|
75
|
+
payload?: readonly ChartTooltipEntry[];
|
|
76
|
+
/** The hovered category — the x value. Recharts supplies this. */
|
|
77
|
+
label?: React.ReactNode;
|
|
78
|
+
/** Drop the label line, for a chart whose x axis needs no restating. */
|
|
79
|
+
hideLabel?: boolean;
|
|
80
|
+
/** Drop the per-row colour chips, for a single-series chart. */
|
|
81
|
+
hideIndicator?: boolean;
|
|
82
|
+
/** Format the label line. */
|
|
83
|
+
labelFormatter?: (label: React.ReactNode, payload: readonly ChartTooltipEntry[]) => React.ReactNode;
|
|
84
|
+
/** Format one row's value. Return the unit too if you want to own it. */
|
|
85
|
+
formatter?: (value: ChartTooltipEntry["value"], name: React.ReactNode, entry: ChartTooltipEntry, index: number) => React.ReactNode;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The tooltip surface: an overlay, styled like every other overlay.
|
|
89
|
+
*
|
|
90
|
+
* A chart tooltip *is* a floating surface, so it gets exactly what a Popover
|
|
91
|
+
* gets — `surface-2` fill, the overlay rim, one soft shadow — from
|
|
92
|
+
* `_surface.ts` rather than from a second, chart-only recipe that would drift.
|
|
93
|
+
* What it adds is the reading discipline the rest of the system uses for
|
|
94
|
+
* numbers: mono, tabular figures, values right-aligned so a column of them lines
|
|
95
|
+
* up under the pointer.
|
|
96
|
+
*
|
|
97
|
+
* Returns `null` when the pointer is off the plot or the payload is empty,
|
|
98
|
+
* because recharts keeps the content mounted between hovers.
|
|
99
|
+
*
|
|
100
|
+
* `formatter` and `labelFormatter` may equally be set on the `<Tooltip>` itself:
|
|
101
|
+
* recharts forwards its own configuration into cloned content, so both spellings
|
|
102
|
+
* land here. Everything else in that configuration is dropped rather than
|
|
103
|
+
* rendered — see {@link domProps} — which also means a handler passed to this
|
|
104
|
+
* component does not reach the surface. Nothing would fire on it anyway: the
|
|
105
|
+
* tooltip is drawn under the pointer, not in its path.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* <Tooltip cursor={chartTooltipCursor} content={<ChartTooltipContent />} />
|
|
109
|
+
*/
|
|
110
|
+
declare const ChartTooltipContent: React.ForwardRefExoticComponent<ChartTooltipContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
111
|
+
//#endregion
|
|
112
|
+
export { ChartTooltipContent, ChartTooltipContentProps, ChartTooltipEntry, chartChromeClasses, chartTooltipCursor };
|