basalt-ui 2.20.0 → 2.21.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/CHANGELOG.md +39 -0
- package/MIGRATING.md +129 -12
- package/agent/agents/basalt-design-reviewer.md +22 -5
- package/agent/rules/basalt-tokens.md +2 -2
- package/agent/skills/basalt-design/SKILL.md +10 -23
- package/agent/skills/basalt-design/references/anti-defaults.md +24 -0
- package/agent/skills/basalt-design/references/catalogue.md +48 -0
- package/agent/skills/basalt-design/references/concept.md +36 -0
- package/agent/skills/basalt-design/references/encoding-rules.md +45 -0
- package/agent/skills/basalt-design/references/stat-tile.md +24 -0
- package/agent/templates/AGENTS-block.md.tpl +3 -3
- package/configs/oxlint-plugin.js +1 -0
- package/dist/charts/ChartCard.d.ts +6 -2
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +4 -0
- package/dist/charts/state.d.ts +5 -0
- package/dist/charts/state.d.ts.map +1 -1
- package/dist/charts/state.js +2 -0
- package/dist/cli/check-theme.d.ts.map +1 -1
- package/dist/cli/check-theme.js +3 -0
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +3 -2
- package/dist/cli/index.d.ts +4 -2
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +27 -15
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +3 -2
- package/dist/cli/shot/capture.d.ts.map +1 -1
- package/dist/cli/shot/capture.js +6 -1
- package/dist/cli/shot/detect.d.ts +51 -0
- package/dist/cli/shot/detect.d.ts.map +1 -0
- package/dist/cli/shot/detect.js +396 -0
- package/dist/cli/shot/index.d.ts.map +1 -1
- package/dist/cli/shot/index.js +7 -4
- package/dist/cli/shot/measure.d.ts +2 -0
- package/dist/cli/shot/measure.d.ts.map +1 -1
- package/dist/cli/shot/measure.js +2 -0
- package/dist/cli/shot/types.d.ts +4 -1
- package/dist/cli/shot/types.d.ts.map +1 -1
- package/dist/cli/shot/types.js +2 -0
- package/dist/cli/sync.d.ts +2 -0
- package/dist/cli/sync.d.ts.map +1 -1
- package/dist/cli/sync.js +2 -2
- package/dist/common/retry-button.d.ts +12 -0
- package/dist/common/retry-button.d.ts.map +1 -0
- package/dist/common/retry-button.js +22 -0
- package/dist/common/retry-button.module.css +58 -0
- package/dist/common/retry-button.module.css.d.ts +8 -0
- package/dist/dashboard/bar-list.d.ts +5 -2
- package/dist/dashboard/bar-list.d.ts.map +1 -1
- package/dist/dashboard/bar-list.js +2 -2
- package/dist/dashboard/meter-model.d.ts +34 -6
- package/dist/dashboard/meter-model.d.ts.map +1 -1
- package/dist/dashboard/meter-model.js +44 -13
- package/dist/dashboard/meter-parts.d.ts.map +1 -1
- package/dist/dashboard/meter-parts.js +167 -135
- package/dist/dashboard/meter.d.ts +11 -7
- package/dist/dashboard/meter.d.ts.map +1 -1
- package/dist/dashboard/meter.js +5 -1
- package/dist/dashboard/meter.module.css +18 -65
- package/dist/dashboard/meter.module.css.d.ts +2 -7
- package/dist/dashboard/query-state.d.ts +1 -1
- package/dist/dashboard/query-state.d.ts.map +1 -1
- package/dist/dashboard/query-state.js +3 -2
- package/dist/dashboard/stat-card.d.ts.map +1 -1
- package/dist/dashboard/stat-card.js +2 -1
- package/dist/dashboard/stat-strip.d.ts +17 -0
- package/dist/dashboard/stat-strip.d.ts.map +1 -1
- package/dist/dashboard/stat-strip.js +35 -5
- package/dist/dashboard/stat-strip.module.css +97 -14
- package/dist/dashboard/stat-strip.module.css.d.ts +4 -0
- package/dist/dashboard/visual-slot.d.ts +2 -0
- package/dist/dashboard/visual-slot.d.ts.map +1 -0
- package/dist/dashboard/visual-slot.js +5 -0
- package/dist/guard/index.d.ts +15 -2
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +14 -0
- package/dist/guard/palette.d.ts +51 -0
- package/dist/guard/palette.d.ts.map +1 -0
- package/dist/guard/palette.js +190 -0
- package/dist/guard/series-file.d.ts +15 -0
- package/dist/guard/series-file.d.ts.map +1 -0
- package/dist/guard/series-file.js +29 -0
- package/dist/guard/types.d.ts +3 -3
- package/dist/guard/types.d.ts.map +1 -1
- package/dist/surfaces.d.ts +1 -1
- package/dist/surfaces.d.ts.map +1 -1
- package/dist/surfaces.js +2 -0
- package/dist/theme/controls.module.css +10 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +18 -0
- package/dist/tokens/oklab.d.ts +28 -0
- package/dist/tokens/oklab.d.ts.map +1 -0
- package/dist/tokens/oklab.js +73 -0
- package/llms.txt +7 -5
- package/package.json +1 -1
- package/src/charts/ChartCard.tsx +9 -1
- package/src/charts/state.tsx +9 -0
- package/src/cli/check-theme.ts +3 -0
- package/src/cli/help.ts +18 -1
- package/src/cli/index.ts +48 -17
- package/src/cli/init.ts +2 -1
- package/src/cli/shot/capture.ts +15 -2
- package/src/cli/shot/detect.ts +533 -0
- package/src/cli/shot/index.ts +8 -4
- package/src/cli/shot/measure.ts +4 -0
- package/src/cli/shot/types.ts +5 -1
- package/src/cli/sync.ts +4 -2
- package/src/common/retry-button.module.css +58 -0
- package/src/common/retry-button.module.css.d.ts +8 -0
- package/src/common/retry-button.tsx +29 -0
- package/src/dashboard/bar-list.tsx +11 -8
- package/src/dashboard/meter-model.ts +91 -20
- package/src/dashboard/meter-parts.tsx +155 -115
- package/src/dashboard/meter.module.css +18 -65
- package/src/dashboard/meter.module.css.d.ts +2 -7
- package/src/dashboard/meter.tsx +18 -8
- package/src/dashboard/query-state.tsx +4 -7
- package/src/dashboard/stat-card.tsx +4 -1
- package/src/dashboard/stat-strip.module.css +97 -14
- package/src/dashboard/stat-strip.module.css.d.ts +4 -0
- package/src/dashboard/stat-strip.tsx +85 -5
- package/src/dashboard/visual-slot.ts +8 -0
- package/src/guard/index.ts +16 -4
- package/src/guard/palette.ts +261 -0
- package/src/guard/series-file.ts +51 -0
- package/src/guard/types.ts +3 -2
- package/src/surfaces.ts +2 -0
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +82 -48
- package/src/theme/controls.module.css +10 -0
- package/src/theme/index.ts +26 -0
- package/src/tokens/oklab.ts +97 -0
|
@@ -24,8 +24,11 @@ export type BarListProps = BasaltProps & {
|
|
|
24
24
|
format?: (value: number, part: 'value' | 'max') => string;
|
|
25
25
|
/** Scale end shared by rows without their own `max`. Default: the largest of those rows' values. */
|
|
26
26
|
max?: number;
|
|
27
|
-
/**
|
|
28
|
-
|
|
27
|
+
/**
|
|
28
|
+
* `thin` (default): label on its own line above a thin bar, value right-aligned on that line.
|
|
29
|
+
* `inline`: the label sits inside a heavier track, the value outside it.
|
|
30
|
+
*/
|
|
31
|
+
variant?: 'thin' | 'inline';
|
|
29
32
|
/** The first row's bar takes the accent. Off by default. */
|
|
30
33
|
accentLeader?: boolean;
|
|
31
34
|
/** Renders row-shaped skeletons. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bar-list.d.ts","sourceRoot":"","sources":["../../src/dashboard/bar-list.tsx"],"names":[],"mappings":"AAwCA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAIlD,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,6FAA6F;IAC7F,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,yEAAyE;IACzE,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,kGAAkG;IAClG,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG;IACvC,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAA;IACb,6EAA6E;IAC7E,KAAK,EAAE,SAAS,WAAW,EAAE,CAAA;IAC7B;;;OAGG;IACH,MA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EAAE,MAAM,CAAA;CACnB,CAAA;AAMD,wBAAgB,OAAO,CAAC,EACtB,KAAK,EACL,KAAK,EACL,MAAe,EACf,GAAG,EACH,OAAgB,EAChB,YAAoB,EACpB,OAAe,EACf,WAAe,EACf,SAAqB,EACrB,SAAS,EACT,KAAK,GACN,EAAE,YAAY,+BA6Fd"}
|
|
@@ -9,7 +9,7 @@ function BarList({
|
|
|
9
9
|
items,
|
|
10
10
|
format = asText,
|
|
11
11
|
max,
|
|
12
|
-
variant = "
|
|
12
|
+
variant = "thin",
|
|
13
13
|
accentLeader = false,
|
|
14
14
|
loading = false,
|
|
15
15
|
loadingRows = 5,
|
|
@@ -42,7 +42,7 @@ function BarList({
|
|
|
42
42
|
role: "list",
|
|
43
43
|
"aria-label": label,
|
|
44
44
|
"data-secondary": hasSecondary ? "" : void 0,
|
|
45
|
-
"data-variant":
|
|
45
|
+
"data-variant": variant,
|
|
46
46
|
children: items.map((item, i) => {
|
|
47
47
|
const isLeader = accentLeader && i === 0;
|
|
48
48
|
const rowScale = item.max ?? scale;
|
|
@@ -13,6 +13,11 @@ export type MeterZone = {
|
|
|
13
13
|
from: number;
|
|
14
14
|
to: number;
|
|
15
15
|
label: string;
|
|
16
|
+
/**
|
|
17
|
+
* A shorter name for a narrow track. The row tries `label`, then `short`, and only then hides the
|
|
18
|
+
* name; the holding zone always shows its full `label`. The described-by text keeps `label`.
|
|
19
|
+
*/
|
|
20
|
+
short?: string;
|
|
16
21
|
color?: string;
|
|
17
22
|
};
|
|
18
23
|
/** A mark on the track at `at` (in the reading's units). A label is captioned beside it. */
|
|
@@ -44,11 +49,14 @@ export type PartCaption = {
|
|
|
44
49
|
text: string;
|
|
45
50
|
color: string | undefined;
|
|
46
51
|
};
|
|
47
|
-
/** One zone's name on the
|
|
52
|
+
/** One zone's name on the label row: its span's centre and width (percent) and whether it holds the reading. */
|
|
48
53
|
export type ZoneLabel = {
|
|
49
54
|
key: string;
|
|
50
55
|
label: string;
|
|
51
|
-
|
|
56
|
+
/** The fallback name, when the zone has one. */
|
|
57
|
+
short?: string;
|
|
58
|
+
centrePct: number;
|
|
59
|
+
widthPct: number;
|
|
52
60
|
holding: boolean;
|
|
53
61
|
};
|
|
54
62
|
/**
|
|
@@ -92,11 +100,31 @@ export type LabelBox = {
|
|
|
92
100
|
right: number;
|
|
93
101
|
};
|
|
94
102
|
/**
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* Boxes are relative to the row's own start edge.
|
|
103
|
+
* A label on the shared row: its measured box and, for a zone name, the span it must stay inside.
|
|
104
|
+
* The holding zone's name never hides for width: it ignores its span and is shifted into the row.
|
|
98
105
|
*/
|
|
99
|
-
export
|
|
106
|
+
export type RowLabel = {
|
|
107
|
+
box: LabelBox;
|
|
108
|
+
span?: LabelBox;
|
|
109
|
+
holding?: boolean;
|
|
110
|
+
short?: LabelBox;
|
|
111
|
+
};
|
|
112
|
+
/** The placement of the row's labels, index-aligned with the input. */
|
|
113
|
+
export type RowPlacement = {
|
|
114
|
+
shown: boolean[];
|
|
115
|
+
/** Index-aligned with `shown`: the label shows as its `short` box rather than the full one. */
|
|
116
|
+
short: boolean[];
|
|
117
|
+
/** Pixels a shown label moves along the row's physical x axis to stay inside it (0 unless clamped). */
|
|
118
|
+
shift: number[];
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Which labels of the row show, in input order. The holding zone's name claims its place first (it
|
|
122
|
+
* is the reading's verdict, so it never hides for width: it may spill past its span, shifted inside
|
|
123
|
+
* the row); the labels without a span (the end ticks) go next; every other zone name then shows only
|
|
124
|
+
* when it lies inside the row and its own span and clears every label already kept, trying its full
|
|
125
|
+
* name and then its `short` box. A hidden name is still named in the described-by text.
|
|
126
|
+
*/
|
|
127
|
+
export declare function placeRowLabels(labels: readonly RowLabel[], rowWidth: number): RowPlacement;
|
|
100
128
|
/** A zone band as left edge + width in percent, clipped to the track. */
|
|
101
129
|
export declare function zoneBand(zone: MeterZone, min: number, span: number): {
|
|
102
130
|
start: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meter-model.d.ts","sourceRoot":"","sources":["../../src/dashboard/meter-model.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGtC,MAAM,MAAM,YAAY,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAA;AAC/F,MAAM,MAAM,SAAS,GAAG;
|
|
1
|
+
{"version":3,"file":"meter-model.d.ts","sourceRoot":"","sources":["../../src/dashboard/meter-model.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGtC,MAAM,MAAM,YAAY,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAA;AAC/F,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AACD,4FAA4F;AAC5F,MAAM,MAAM,SAAS,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAEtD,mGAAmG;AACnG,MAAM,MAAM,QAAQ,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,IAAI,EAAE,MAA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;IACjB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;CAC/B,CAAA;AAeD,2FAA2F;AAC3F,eAAO,MAAM,cAAc,GAAI,UAAU,SAAS,YAAY,EAAE,EAAE,KAAK,MAAM,KAAG,MAC/B,CAAA;AA0BjD,qGAAqG;AACrG,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAG5F;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,QAAQ,CA4DlD;AAED,8DAA8D;AAC9D,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,KAAG,MACvB,CAAA"}
|
|
@@ -50,11 +50,37 @@ function findHoldingZone(zones, value) {
|
|
|
50
50
|
return zones.find((z) => value >= z.from && (value < z.to || value === z.to && z.to === end));
|
|
51
51
|
}
|
|
52
52
|
const LABEL_SUBPIXEL = 0.5;
|
|
53
|
-
function
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
function placeRowLabels(labels, rowWidth) {
|
|
54
|
+
const shown = labels.map(() => false);
|
|
55
|
+
const short = labels.map(() => false);
|
|
56
|
+
const shift = labels.map(() => 0);
|
|
57
|
+
const kept = [];
|
|
58
|
+
const rank = (l) => l.holding ? 0 : l.span ? 2 : 1;
|
|
59
|
+
const order = labels.map((_, i) => i).toSorted((a, b) => rank(labels[a]) - rank(labels[b]));
|
|
60
|
+
const clears = (b) => !kept.some((k) => b.left < k.right - LABEL_SUBPIXEL && k.left < b.right - LABEL_SUBPIXEL);
|
|
61
|
+
for (const i of order) {
|
|
62
|
+
const label = labels[i];
|
|
63
|
+
const { span } = label;
|
|
64
|
+
let box = label.box;
|
|
65
|
+
if (label.holding) {
|
|
66
|
+
const width = box.right - box.left;
|
|
67
|
+
const left = Math.max(0, Math.min(box.left, rowWidth - width));
|
|
68
|
+
shift[i] = left - box.left;
|
|
69
|
+
box = { left, right: left + width };
|
|
70
|
+
if (!clears(box)) continue;
|
|
71
|
+
shown[i] = true;
|
|
72
|
+
kept.push(box);
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const fits = (b) => b.left >= -LABEL_SUBPIXEL && b.right <= rowWidth + LABEL_SUBPIXEL && (span === void 0 || b.left >= span.left - LABEL_SUBPIXEL && b.right <= span.right + LABEL_SUBPIXEL) && clears(b);
|
|
76
|
+
const useShort = !fits(box) && label.short !== void 0 && fits(label.short);
|
|
77
|
+
if (useShort) box = label.short;
|
|
78
|
+
else if (!fits(box)) continue;
|
|
79
|
+
shown[i] = true;
|
|
80
|
+
short[i] = useShort;
|
|
81
|
+
kept.push(box);
|
|
82
|
+
}
|
|
83
|
+
return { shown, short, shift };
|
|
58
84
|
}
|
|
59
85
|
function zoneBand(zone, min, span) {
|
|
60
86
|
const lo = clamp01((zone.from - min) / span);
|
|
@@ -119,12 +145,17 @@ function modelBar(input) {
|
|
|
119
145
|
forecastText: forecastLabels.length === 0 ? null : input.forecastCaption ?? `Forecast: ${forecastLabels.join(", ")}`,
|
|
120
146
|
captionMode,
|
|
121
147
|
partCaptions,
|
|
122
|
-
zoneLabels: !zoned ? [] : zones.map((z, i) =>
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
148
|
+
zoneLabels: !zoned ? [] : zones.map((z, i) => {
|
|
149
|
+
const band = zoneBand(z, min, span);
|
|
150
|
+
return {
|
|
151
|
+
key: String(i),
|
|
152
|
+
label: z.label,
|
|
153
|
+
...z.short !== void 0 && { short: z.short },
|
|
154
|
+
centrePct: band.start + band.width / 2,
|
|
155
|
+
widthPct: band.width,
|
|
156
|
+
holding: z === holding
|
|
157
|
+
};
|
|
158
|
+
}),
|
|
128
159
|
ticks,
|
|
129
160
|
markerPct: zoned ? toPct((reading - min) / span) : void 0,
|
|
130
161
|
targetPct: target === void 0 ? void 0 : toPct((target - min) / span),
|
|
@@ -142,11 +173,11 @@ export {
|
|
|
142
173
|
layoutSegments,
|
|
143
174
|
modelBar,
|
|
144
175
|
normalizeSegments,
|
|
176
|
+
placeRowLabels,
|
|
145
177
|
ringFraction,
|
|
146
178
|
segmentReading,
|
|
147
179
|
spanOf,
|
|
148
180
|
startCaptionText,
|
|
149
181
|
tickMarks,
|
|
150
|
-
zoneBand
|
|
151
|
-
zoneLabelsFit
|
|
182
|
+
zoneBand
|
|
152
183
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meter-parts.d.ts","sourceRoot":"","sources":["../../src/dashboard/meter-parts.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"meter-parts.d.ts","sourceRoot":"","sources":["../../src/dashboard/meter-parts.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAa,MAAM,OAAO,CAAA;AAWhE,OAAO,KAAK,EACV,YAAY,EACZ,SAAS,EACT,SAAS,EAKV,MAAM,eAAe,CAAA;AAKtB,MAAM,MAAM,KAAK,GAAG;IAClB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;IAC7B,KAAK,EAAE,aAAa,GAAG,SAAS,CAAA;IAChC,yDAAyD;IACzD,GAAG,EAAE,OAAO,CAAA;CACb,CAAA;AA8DD,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,IAAI,EACJ,KAAK,GACN,EAAE;IACD,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,OAAO,CAAA;IACb,KAAK,EAAE,KAAK,CAAA;CACb,+BAcA;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,+BAgB7F;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE;IAC/B,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;IACjC,KAAK,EAAE,KAAK,CAAA;CACb,+BAcA;AA+OD,wBAAgB,QAAQ,CAAC,KAAK,EAAE;IAC9B,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;IACjC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,QAAQ,EAAE,SAAS,YAAY,EAAE,GAAG,SAAS,CAAA;IAC7C,KAAK,EAAE,SAAS,SAAS,EAAE,GAAG,SAAS,CAAA;IACvC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,KAAK,EAAE,SAAS,SAAS,EAAE,GAAG,SAAS,CAAA;IACvC,IAAI,EAAE,OAAO,GAAG,SAAS,CAAA;IACzB,eAAe,EAAE,MAAM,GAAG,SAAS,CAAA;IACnC,YAAY,EAAE,SAAS,CAAA;IACvB,UAAU,EAAE,SAAS,CAAA;IACrB,KAAK,EAAE,KAAK,CAAA;CACb,+BAmGA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Skeleton, VisuallyHidden } from "@mantine/core";
|
|
3
|
-
import { useId, useRef, useState } from "react";
|
|
3
|
+
import { useContext, useId, useRef, useState } from "react";
|
|
4
4
|
import { useIsomorphicLayoutEffect } from "../common/isomorphic-layout-effect.js";
|
|
5
5
|
import { cx } from "../common/props.js";
|
|
6
6
|
import {
|
|
@@ -8,10 +8,11 @@ import {
|
|
|
8
8
|
modelBar,
|
|
9
9
|
ringFraction,
|
|
10
10
|
startCaptionText,
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
placeRowLabels,
|
|
12
|
+
zoneBand
|
|
13
13
|
} from "./meter-model.js";
|
|
14
14
|
import classes from "./meter.module.css";
|
|
15
|
+
import { VisualSlotContext } from "./visual-slot.js";
|
|
15
16
|
import { toPct } from "./scale.js";
|
|
16
17
|
function rootProps(shell) {
|
|
17
18
|
return {
|
|
@@ -108,19 +109,48 @@ function zoneStyle(zone, index, count, min, span) {
|
|
|
108
109
|
background: zone.color ?? `color-mix(in srgb, var(--vx-line) ${strength}%, transparent)`
|
|
109
110
|
};
|
|
110
111
|
}
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
const sameLayout = (a, b) => a.shown.length === b.shown.length && a.shown.every(
|
|
113
|
+
(v, i) => v === b.shown[i] && a.short[i] === b.short[i] && a.shift[i] === b.shift[i]
|
|
114
|
+
);
|
|
115
|
+
function useRowLabelLayout(rowRef, slots, shortOf, key) {
|
|
116
|
+
const [layout, setLayout] = useState({ shown: [], short: [], shift: [] });
|
|
117
|
+
const slotsRef = useRef(slots);
|
|
118
|
+
const shortOfRef = useRef(shortOf);
|
|
119
|
+
useIsomorphicLayoutEffect(() => {
|
|
120
|
+
slotsRef.current = slots;
|
|
121
|
+
shortOfRef.current = shortOf;
|
|
122
|
+
});
|
|
114
123
|
useIsomorphicLayoutEffect(() => {
|
|
115
124
|
const row = rowRef.current;
|
|
116
125
|
if (!row) return;
|
|
117
126
|
const measure = () => {
|
|
118
127
|
const origin = row.getBoundingClientRect();
|
|
119
|
-
const
|
|
128
|
+
const rtl = getComputedStyle(row).direction === "rtl";
|
|
129
|
+
const edge = (pct) => origin.width * (rtl ? 100 - pct : pct) / 100;
|
|
130
|
+
const children = [...row.children];
|
|
131
|
+
const labels = children.slice(0, slotsRef.current.length).map((c, i) => {
|
|
120
132
|
const r = c.getBoundingClientRect();
|
|
121
|
-
|
|
133
|
+
const slot = slotsRef.current[i];
|
|
134
|
+
const pct = slot?.spanPct;
|
|
135
|
+
const [a, b] = pct ? [edge(pct[0]), edge(pct[1])] : [];
|
|
136
|
+
return {
|
|
137
|
+
box: { left: r.left - origin.left, right: r.right - origin.left },
|
|
138
|
+
...a !== void 0 && b !== void 0 && { span: { left: Math.min(a, b), right: Math.max(a, b) } },
|
|
139
|
+
...slot?.holding && { holding: true }
|
|
140
|
+
};
|
|
141
|
+
});
|
|
142
|
+
shortOfRef.current.forEach((labelIndex, n) => {
|
|
143
|
+
const r = children[slotsRef.current.length + n]?.getBoundingClientRect();
|
|
144
|
+
const label = labels[labelIndex];
|
|
145
|
+
if (r && label) label.short = { left: r.left - origin.left, right: r.right - origin.left };
|
|
122
146
|
});
|
|
123
|
-
|
|
147
|
+
const placed = placeRowLabels(labels, origin.width);
|
|
148
|
+
const next = {
|
|
149
|
+
shown: placed.shown,
|
|
150
|
+
short: placed.short,
|
|
151
|
+
shift: placed.shift.map((v) => rtl ? -v : v)
|
|
152
|
+
};
|
|
153
|
+
setLayout((prev) => sameLayout(prev, next) ? prev : next);
|
|
124
154
|
};
|
|
125
155
|
measure();
|
|
126
156
|
const observer = typeof ResizeObserver === "undefined" ? void 0 : new ResizeObserver(measure);
|
|
@@ -135,7 +165,7 @@ function useZoneLabelLayout(rowRef, key) {
|
|
|
135
165
|
fonts?.removeEventListener?.("loadingdone", measure);
|
|
136
166
|
};
|
|
137
167
|
}, [rowRef, key]);
|
|
138
|
-
return
|
|
168
|
+
return layout;
|
|
139
169
|
}
|
|
140
170
|
function ZoneReading({ pct, children }) {
|
|
141
171
|
const rowRef = useRef(null);
|
|
@@ -169,152 +199,154 @@ function ZoneReading({ pct, children }) {
|
|
|
169
199
|
}
|
|
170
200
|
) });
|
|
171
201
|
}
|
|
172
|
-
function ZoneName({ label, ...rest }) {
|
|
173
|
-
return /* @__PURE__ */ jsx(
|
|
174
|
-
"span",
|
|
175
|
-
{
|
|
176
|
-
...rest,
|
|
177
|
-
className: cx(rest.className, label.holding && classes.zoneLabelHolding),
|
|
178
|
-
"data-meter-zone-label": label.label,
|
|
179
|
-
"data-holding": label.holding || void 0,
|
|
180
|
-
children: label.label
|
|
181
|
-
}
|
|
182
|
-
);
|
|
183
|
-
}
|
|
184
|
-
function ZoneLabels({ labels }) {
|
|
185
|
-
const rowRef = useRef(null);
|
|
186
|
-
const fits = useZoneLabelLayout(rowRef, labelsKey(labels));
|
|
187
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
188
|
-
/* @__PURE__ */ jsx(
|
|
189
|
-
"div",
|
|
190
|
-
{
|
|
191
|
-
ref: rowRef,
|
|
192
|
-
className: classes.zoneBand,
|
|
193
|
-
"data-meter-zone-band": true,
|
|
194
|
-
"data-collapsed": fits ? void 0 : "",
|
|
195
|
-
"aria-hidden": true,
|
|
196
|
-
children: labels.map((l) => /* @__PURE__ */ jsx(
|
|
197
|
-
ZoneName,
|
|
198
|
-
{
|
|
199
|
-
label: l,
|
|
200
|
-
className: classes.zoneLabel,
|
|
201
|
-
style: { insetInlineStart: `${l.startPct}%` }
|
|
202
|
-
},
|
|
203
|
-
l.key
|
|
204
|
-
))
|
|
205
|
-
}
|
|
206
|
-
),
|
|
207
|
-
!fits && /* @__PURE__ */ jsx("div", { className: classes.zoneList, "data-meter-zone-list": true, "aria-hidden": true, children: labels.map((l) => /* @__PURE__ */ jsx(ZoneName, { label: l, className: classes.zoneListItem }, l.key)) })
|
|
208
|
-
] });
|
|
209
|
-
}
|
|
210
202
|
const TICK_LABEL_FLIP_PCT = 50;
|
|
211
|
-
function
|
|
203
|
+
function LabelRow({ zones, ticks }) {
|
|
212
204
|
const rowRef = useRef(null);
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
205
|
+
const slots = [
|
|
206
|
+
...ticks.map(() => ({})),
|
|
207
|
+
...zones.map((z) => ({
|
|
208
|
+
spanPct: [z.centrePct - z.widthPct / 2, z.centrePct + z.widthPct / 2],
|
|
209
|
+
holding: z.holding
|
|
210
|
+
}))
|
|
211
|
+
];
|
|
212
|
+
const key = [
|
|
213
|
+
...ticks.map((t) => `${t.label}@${t.pct}`),
|
|
214
|
+
...zones.map((z) => `${z.label}${z.holding ? "*" : ""}@${z.centrePct}`)
|
|
215
|
+
].join("\0");
|
|
216
|
+
const twins = zones.flatMap((z, i) => z.short !== void 0 && !z.holding ? [i] : []);
|
|
217
|
+
const { shown, short, shift } = useRowLabelLayout(
|
|
218
|
+
rowRef,
|
|
219
|
+
slots,
|
|
220
|
+
twins.map((i) => ticks.length + i),
|
|
221
|
+
`${key}${twins.map((i) => zones[i]?.short).join("\0")}`
|
|
222
|
+
);
|
|
223
|
+
const hidden = (i) => shown[i] === false || short[i] === true ? "" : void 0;
|
|
224
|
+
const nudge = (i) => shift[i] ? { marginInlineStart: `${shift[i]}px` } : {};
|
|
225
|
+
return /* @__PURE__ */ jsxs(
|
|
226
|
+
"div",
|
|
227
|
+
{
|
|
228
|
+
ref: rowRef,
|
|
229
|
+
className: classes.labelRow,
|
|
230
|
+
...zones.length > 0 ? { "data-meter-zone-band": "" } : { "data-meter-tick-band": "" },
|
|
231
|
+
"aria-hidden": true,
|
|
232
|
+
children: [
|
|
233
|
+
ticks.map((t, i) => /* @__PURE__ */ jsx(
|
|
224
234
|
"span",
|
|
225
235
|
{
|
|
226
|
-
className: classes.
|
|
236
|
+
className: classes.rowLabel,
|
|
227
237
|
"data-meter-tick-label": "",
|
|
238
|
+
"data-hidden": hidden(i),
|
|
228
239
|
style: t.pct > TICK_LABEL_FLIP_PCT ? { insetInlineEnd: `${100 - t.pct}%` } : { insetInlineStart: `${t.pct}%` },
|
|
229
240
|
children: t.label
|
|
230
241
|
},
|
|
231
|
-
t.key
|
|
232
|
-
))
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
242
|
+
`t${t.key}`
|
|
243
|
+
)),
|
|
244
|
+
zones.map((z, i) => /* @__PURE__ */ jsx(
|
|
245
|
+
"span",
|
|
246
|
+
{
|
|
247
|
+
className: cx(classes.rowLabel, classes.zoneLabel, z.holding && classes.zoneLabelHolding),
|
|
248
|
+
"data-meter-zone-label": z.label,
|
|
249
|
+
"data-holding": z.holding || void 0,
|
|
250
|
+
"data-hidden": hidden(ticks.length + i),
|
|
251
|
+
style: { insetInlineStart: `${z.centrePct}%`, ...nudge(ticks.length + i) },
|
|
252
|
+
children: z.label
|
|
253
|
+
},
|
|
254
|
+
`z${z.key}`
|
|
255
|
+
)),
|
|
256
|
+
twins.map((zi) => {
|
|
257
|
+
const z = zones[zi];
|
|
258
|
+
const i = ticks.length + zi;
|
|
259
|
+
return /* @__PURE__ */ jsx(
|
|
260
|
+
"span",
|
|
261
|
+
{
|
|
262
|
+
className: cx(classes.rowLabel, classes.zoneLabel),
|
|
263
|
+
"data-meter-zone-short": z.label,
|
|
264
|
+
"data-hidden": short[i] === true ? void 0 : "",
|
|
265
|
+
style: { insetInlineStart: `${z.centrePct}%`, ...nudge(i) },
|
|
266
|
+
children: z.short
|
|
267
|
+
},
|
|
268
|
+
`s${z.key}`
|
|
269
|
+
);
|
|
270
|
+
})
|
|
271
|
+
]
|
|
272
|
+
}
|
|
273
|
+
);
|
|
237
274
|
}
|
|
238
275
|
function MeterBar(props) {
|
|
239
276
|
const { label, reading, min, max, format, zones, shell } = props;
|
|
240
277
|
const describedId = useId();
|
|
241
278
|
const model = modelBar(props);
|
|
242
279
|
const compact = shell.row;
|
|
243
|
-
const
|
|
280
|
+
const hosted = useContext(VisualSlotContext) && model.markerPct !== void 0 && props.startCaption === void 0;
|
|
281
|
+
const start = compact || hosted ? null : startCaptionText(model, props.startCaption);
|
|
244
282
|
const end = compact ? null : props.endCaption === void 0 ? model.endText : props.endCaption;
|
|
245
283
|
const anchored = model.markerPct !== void 0 && start !== null;
|
|
246
284
|
const hasCaptions = start !== null && !anchored || end !== null || !compact && model.forecastText !== null;
|
|
247
285
|
const hasParts = !compact && model.partCaptions.length > 0;
|
|
248
286
|
const tickLabels = compact ? [] : model.ticks.filter((t) => t.label !== void 0);
|
|
287
|
+
const zoneLabels = compact ? [] : model.zoneLabels;
|
|
249
288
|
const describedBy = model.describedByText === null ? {} : { "aria-describedby": describedId };
|
|
250
289
|
const root = rootProps(shell);
|
|
251
|
-
return /* @__PURE__ */ jsxs(
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
start !== null && !anchored && /* @__PURE__ */ jsx("span", { className: classes.caption, children: glue(start) }),
|
|
312
|
-
!compact && model.forecastText !== null && /* @__PURE__ */ jsx("span", { className: classes.caption, children: glue(model.forecastText) }),
|
|
313
|
-
end !== null && /* @__PURE__ */ jsx("span", { className: classes.captionEnd, children: glue(end) })
|
|
314
|
-
] })
|
|
315
|
-
]
|
|
316
|
-
}
|
|
317
|
-
);
|
|
290
|
+
return /* @__PURE__ */ jsxs("div", { ...root, className: root.className, children: [
|
|
291
|
+
tickLabels.length > 0 && zoneLabels.length === 0 && /* @__PURE__ */ jsx(LabelRow, { zones: zoneLabels, ticks: tickLabels }),
|
|
292
|
+
/* @__PURE__ */ jsxs(
|
|
293
|
+
"div",
|
|
294
|
+
{
|
|
295
|
+
className: classes.trackBox,
|
|
296
|
+
"aria-label": label,
|
|
297
|
+
...ariaValues(reading, min, max, format),
|
|
298
|
+
...describedBy,
|
|
299
|
+
children: [
|
|
300
|
+
/* @__PURE__ */ jsxs("div", { className: classes.track, "data-meter-track": true, children: [
|
|
301
|
+
model.markerPct !== void 0 && zones?.map((z, i) => /* @__PURE__ */ jsx(
|
|
302
|
+
"div",
|
|
303
|
+
{
|
|
304
|
+
className: classes.zone,
|
|
305
|
+
"data-meter-zone": z.label,
|
|
306
|
+
style: zoneStyle(z, i, zones.length, min, model.span)
|
|
307
|
+
},
|
|
308
|
+
i
|
|
309
|
+
)),
|
|
310
|
+
model.parts.map((p, i) => /* @__PURE__ */ jsx(
|
|
311
|
+
"div",
|
|
312
|
+
{
|
|
313
|
+
className: cx(classes.fill, p.forecast && classes.forecastFill),
|
|
314
|
+
"data-meter-fill": p.forecast ? "forecast" : "committed",
|
|
315
|
+
"data-tone": props.tone === "muted" && p.color === void 0 && !p.forecast ? "muted" : void 0,
|
|
316
|
+
style: fillStyle(p)
|
|
317
|
+
},
|
|
318
|
+
i
|
|
319
|
+
))
|
|
320
|
+
] }),
|
|
321
|
+
/* @__PURE__ */ jsx(Tick, { kind: "marker", className: classes.marker, pct: model.markerPct }),
|
|
322
|
+
/* @__PURE__ */ jsx(Tick, { kind: "boundary", className: classes.boundaryTick, pct: model.boundaryPct }),
|
|
323
|
+
model.ticks.map((t) => /* @__PURE__ */ jsx(Tick, { kind: "tick", className: classes.tick, pct: t.pct }, t.key)),
|
|
324
|
+
/* @__PURE__ */ jsx(Tick, { kind: "target", className: classes.tick, pct: model.targetPct })
|
|
325
|
+
]
|
|
326
|
+
}
|
|
327
|
+
),
|
|
328
|
+
zoneLabels.length > 0 && /* @__PURE__ */ jsx(LabelRow, { zones: zoneLabels, ticks: tickLabels }),
|
|
329
|
+
anchored && /* @__PURE__ */ jsx(ZoneReading, { pct: model.markerPct ?? 0, children: start }),
|
|
330
|
+
model.describedByText !== null && /* @__PURE__ */ jsx(VisuallyHidden, { id: describedId, className: classes.summary, children: model.describedByText }),
|
|
331
|
+
hasParts && // The explicit role is deliberate: `list-style: none` makes Safari/VoiceOver drop the implicit one.
|
|
332
|
+
// oxlint-disable-next-line jsx-a11y/no-redundant-roles
|
|
333
|
+
/* @__PURE__ */ jsx("ul", { className: classes.partCaptions, role: "list", "data-meter-parts": true, children: model.partCaptions.map((c) => /* @__PURE__ */ jsxs("li", { className: classes.partCaption, children: [
|
|
334
|
+
/* @__PURE__ */ jsx(
|
|
335
|
+
"span",
|
|
336
|
+
{
|
|
337
|
+
className: classes.swatch,
|
|
338
|
+
style: { background: c.color ?? "var(--vx-line)" },
|
|
339
|
+
"aria-hidden": true
|
|
340
|
+
}
|
|
341
|
+
),
|
|
342
|
+
glueUnits(`${c.label} ${c.text}`)
|
|
343
|
+
] }, c.key)) }),
|
|
344
|
+
hasCaptions && /* @__PURE__ */ jsxs("div", { className: classes.captions, "data-meter-captions": true, children: [
|
|
345
|
+
start !== null && !anchored && /* @__PURE__ */ jsx("span", { className: classes.caption, children: glue(start) }),
|
|
346
|
+
!compact && model.forecastText !== null && /* @__PURE__ */ jsx("span", { className: classes.caption, children: glue(model.forecastText) }),
|
|
347
|
+
end !== null && /* @__PURE__ */ jsx("span", { className: classes.captionEnd, children: glue(end) })
|
|
348
|
+
] })
|
|
349
|
+
] });
|
|
318
350
|
}
|
|
319
351
|
const TICK_WIDTH = "2px";
|
|
320
352
|
function tickPosition(kind, pct) {
|
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
* along is this against a limit"; choose `BarList` for a ranking and a chart for a trend. An HTML/CSS
|
|
5
5
|
* primitive, not a chart kind (no scale, axis or tooltip).
|
|
6
6
|
*
|
|
7
|
-
* Colour law:
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* Colour law: a plain `value` bar's fill is neutral (`--vx-muted` at a strength that holds 3:1 on
|
|
8
|
+
* the track; `tone="ink"` for full ink); `segments` and `zones` keep their own fills. `color` is
|
|
9
|
+
* for a VERDICT only (over budget, below target) and is a status colour the consumer passes;
|
|
10
|
+
* categorical `segments` take the consumer's series colours. Committed vs forecast is the same neutral at two strengths — never colour alone: a
|
|
10
11
|
* tick marks the boundary and a caption names the forecast. A value past `max` clamps the fill at the
|
|
11
12
|
* track end; the caption still states the real value.
|
|
12
13
|
*
|
|
@@ -73,16 +74,19 @@ type BarCommon = Common & {
|
|
|
73
74
|
target?: number;
|
|
74
75
|
/**
|
|
75
76
|
* More marks on the track (cut-offs, a window mean). Each is drawn at `at`; a `label` is captioned
|
|
76
|
-
* above the track,
|
|
77
|
+
* above the track, or on a zoned Meter in the zone-name row (the end ticks at the row's ends). A
|
|
78
|
+
* caption that would collide with another hides. A tick outside `[min, max]` is dropped, not
|
|
77
79
|
* clamped. All are listed in the accessible description. Works with `value`, `zones`, `segments`
|
|
78
80
|
* and `target`.
|
|
79
81
|
*/
|
|
80
82
|
ticks?: readonly MeterTick[];
|
|
81
83
|
/**
|
|
82
|
-
* `'muted'
|
|
83
|
-
*
|
|
84
|
+
* `'muted'` (default for a plain `value` bar; `segments` and `zones` keep their fills): a
|
|
85
|
+
* non-verdict fill (a load, not a verdict) in `--vx-muted` at a strength that holds 3:1 against
|
|
86
|
+
* the track in both schemes — the ink fill is near-white in dark. `'ink'` restores the full-ink
|
|
87
|
+
* `--vx-line` fill. A `color` wins over both.
|
|
84
88
|
*/
|
|
85
|
-
tone?: 'muted';
|
|
89
|
+
tone?: 'muted' | 'ink';
|
|
86
90
|
/**
|
|
87
91
|
* `'row'`: in-line use — a track one text line tall and no caption rows (reading, target, forecast,
|
|
88
92
|
* part, zone and tick captions). The label stays as `aria-label`; the described-by text keeps the
|