basalt-ui 2.21.0 → 2.23.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 +60 -0
- package/MIGRATING.md +452 -12
- package/agent/agents/basalt-design-reviewer.md +1 -1
- package/agent/rules/basalt-tokens.md +1 -1
- package/agent/skills/basalt-design/SKILL.md +1 -1
- package/agent/skills/basalt-design/references/anti-defaults.md +1 -1
- package/agent/skills/basalt-design/references/catalogue.md +1 -0
- package/dist/charts/BandStrip.d.ts.map +1 -1
- package/dist/charts/BandStrip.js +73 -3
- package/dist/charts/Bars.d.ts.map +1 -1
- package/dist/charts/Bars.js +6 -0
- package/dist/charts/CartesianChart.d.ts +10 -0
- package/dist/charts/CartesianChart.d.ts.map +1 -1
- package/dist/charts/CartesianChart.js +8 -5
- package/dist/charts/ChartCard.d.ts +12 -3
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +39 -8
- package/dist/charts/DualPanel.d.ts.map +1 -1
- package/dist/charts/DualPanel.js +5 -8
- package/dist/charts/Heatmap.d.ts +12 -1
- package/dist/charts/Heatmap.d.ts.map +1 -1
- package/dist/charts/Heatmap.js +34 -5
- package/dist/charts/Lines.d.ts +3 -0
- package/dist/charts/Lines.d.ts.map +1 -1
- package/dist/charts/Lines.js +29 -6
- package/dist/charts/MirroredBars.d.ts.map +1 -1
- package/dist/charts/MirroredBars.js +4 -6
- package/dist/charts/Sparkline.d.ts +14 -2
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/Sparkline.js +101 -22
- package/dist/charts/StackedArea.d.ts +4 -1
- package/dist/charts/StackedArea.d.ts.map +1 -1
- package/dist/charts/StackedArea.js +9 -3
- package/dist/charts/band-fold.d.ts +38 -1
- package/dist/charts/band-fold.d.ts.map +1 -1
- package/dist/charts/band-fold.js +18 -1
- package/dist/charts/chart-box.module.css +19 -0
- package/dist/charts/chart-card.module.css +25 -0
- package/dist/charts/chart-dates.d.ts +12 -0
- package/dist/charts/chart-dates.d.ts.map +1 -0
- package/dist/charts/chart-dates.js +16 -0
- package/dist/charts/chart-legend.module.css +7 -0
- package/dist/charts/compile.d.ts +25 -6
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +152 -72
- package/dist/charts/date-tick-format.d.ts +5 -5
- package/dist/charts/date-tick-format.d.ts.map +1 -1
- package/dist/charts/date-tick-format.js +3 -7
- package/dist/charts/labels.d.ts +21 -6
- package/dist/charts/labels.d.ts.map +1 -1
- package/dist/charts/labels.js +52 -17
- package/dist/charts/legend.d.ts +2 -0
- package/dist/charts/legend.d.ts.map +1 -1
- package/dist/charts/legend.js +7 -21
- package/dist/charts/marks.js +1 -1
- package/dist/charts/panel.d.ts +0 -6
- package/dist/charts/panel.d.ts.map +1 -1
- package/dist/charts/panel.js +1 -10
- package/dist/charts/ref-label.d.ts +43 -0
- package/dist/charts/ref-label.d.ts.map +1 -0
- package/dist/charts/ref-label.js +75 -0
- package/dist/charts/scales.d.ts +4 -1
- package/dist/charts/scales.d.ts.map +1 -1
- package/dist/charts/scales.js +14 -3
- package/dist/charts/sparkline.module.css +13 -17
- package/dist/charts/sparkline.module.css.d.ts +1 -2
- package/dist/charts/state.d.ts +2 -0
- package/dist/charts/state.d.ts.map +1 -1
- package/dist/charts/state.js +5 -2
- package/dist/charts/types.d.ts +18 -8
- package/dist/charts/types.d.ts.map +1 -1
- package/dist/cli/doctor-upgrade.d.ts +1 -0
- package/dist/cli/doctor-upgrade.d.ts.map +1 -1
- package/dist/cli/doctor-upgrade.js +1 -0
- package/dist/cli/init.d.ts +2 -0
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +68 -4
- package/dist/cli/shot/capture.d.ts +21 -2
- package/dist/cli/shot/capture.d.ts.map +1 -1
- package/dist/cli/shot/capture.js +202 -36
- package/dist/cli/shot/detect.d.ts.map +1 -1
- package/dist/cli/shot/detect.js +17 -1
- package/dist/cli/shot/playwright.d.ts +13 -2
- package/dist/cli/shot/playwright.d.ts.map +1 -1
- package/dist/cli/shot/playwright.js +5 -1
- package/dist/cli/shot/types.d.ts +4 -0
- package/dist/cli/shot/types.d.ts.map +1 -1
- package/dist/cli/shot/types.js +2 -0
- package/dist/cli/tokens-css.d.ts +5 -7
- package/dist/cli/tokens-css.d.ts.map +1 -1
- package/dist/cli/tokens-css.js +11 -12
- package/dist/controls/controls.module.css +11 -1
- package/dist/controls/filter-pill.d.ts.map +1 -1
- package/dist/controls/filter-pill.js +1 -0
- package/dist/controls/sync-button.d.ts.map +1 -1
- package/dist/controls/sync-button.js +22 -3
- package/dist/controls/sync-button.module.css +34 -2
- package/dist/controls/sync-button.module.css.d.ts +1 -0
- package/dist/dashboard/bar-list.d.ts +6 -1
- package/dist/dashboard/bar-list.d.ts.map +1 -1
- package/dist/dashboard/bar-list.js +15 -8
- package/dist/dashboard/bar-list.module.css +83 -0
- package/dist/dashboard/bar-list.module.css.d.ts +1 -0
- package/dist/dashboard/delta-badge.d.ts.map +1 -1
- package/dist/dashboard/delta-badge.js +2 -2
- package/dist/dashboard/index.d.ts +1 -0
- package/dist/dashboard/index.d.ts.map +1 -1
- package/dist/dashboard/index.js +2 -0
- package/dist/dashboard/meter-model.d.ts +84 -5
- package/dist/dashboard/meter-model.d.ts.map +1 -1
- package/dist/dashboard/meter-model.js +100 -15
- package/dist/dashboard/meter-parts.d.ts +9 -1
- package/dist/dashboard/meter-parts.d.ts.map +1 -1
- package/dist/dashboard/meter-parts.js +276 -74
- package/dist/dashboard/meter.d.ts +54 -65
- package/dist/dashboard/meter.d.ts.map +1 -1
- package/dist/dashboard/meter.js +21 -4
- package/dist/dashboard/meter.module.css +76 -0
- package/dist/dashboard/meter.module.css.d.ts +6 -0
- package/dist/dashboard/page-summary.d.ts +20 -0
- package/dist/dashboard/page-summary.d.ts.map +1 -0
- package/dist/dashboard/page-summary.js +28 -0
- package/dist/dashboard/page-summary.module.css +89 -0
- package/dist/dashboard/page-summary.module.css.d.ts +15 -0
- package/dist/dashboard/query-state.d.ts.map +1 -1
- package/dist/dashboard/query-state.js +1 -1
- package/dist/dashboard/section.d.ts +25 -2
- package/dist/dashboard/section.d.ts.map +1 -1
- package/dist/dashboard/section.js +10 -5
- package/dist/dashboard/section.module.css +23 -0
- package/dist/dashboard/section.module.css.d.ts +1 -0
- package/dist/dashboard/stat-card-parts.d.ts.map +1 -1
- package/dist/dashboard/stat-card-parts.js +1 -1
- package/dist/dashboard/stat-card.d.ts +4 -2
- package/dist/dashboard/stat-card.d.ts.map +1 -1
- package/dist/dashboard/stat-card.js +7 -5
- package/dist/dashboard/stat-card.module.css +36 -0
- package/dist/dashboard/stat-group.module.css +7 -0
- package/dist/dashboard/stat-strip.d.ts +22 -6
- package/dist/dashboard/stat-strip.d.ts.map +1 -1
- package/dist/dashboard/stat-strip.js +104 -60
- package/dist/dashboard/stat-strip.module.css +122 -53
- package/dist/dashboard/stat-strip.module.css.d.ts +4 -0
- package/dist/dashboard/visual-slot.d.ts +7 -1
- package/dist/dashboard/visual-slot.d.ts.map +1 -1
- package/dist/dashboard/visual-slot.js +3 -1
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +0 -5
- package/dist/guard/vx-names.d.ts.map +1 -1
- package/dist/guard/vx-names.js +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/styles.css +43 -4
- package/dist/theme/chrome-vars.d.ts +20 -5
- package/dist/theme/chrome-vars.d.ts.map +1 -1
- package/dist/theme/chrome-vars.js +46 -3
- package/dist/theme/controls.module.css +37 -0
- package/dist/theme/controls.module.css.d.ts +2 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +18 -27
- package/dist/theme/status-verdict.d.ts.map +1 -1
- package/dist/theme/status-verdict.js +9 -1
- package/dist/tokens/core.d.ts +2 -1
- package/dist/tokens/core.d.ts.map +1 -1
- package/dist/tokens/core.js +6 -1
- package/dist/tokens/derive.d.ts +3 -1
- package/dist/tokens/derive.d.ts.map +1 -1
- package/dist/tokens/derive.js +16 -1
- package/dist/tokens/palette.d.ts +11 -10
- package/dist/tokens/palette.d.ts.map +1 -1
- package/dist/tokens/palette.js +11 -10
- package/dist/tokens/status-text.d.ts.map +1 -1
- package/dist/tokens/status-text.js +3 -1
- package/llms.txt +42 -22
- package/package.json +1 -1
- package/src/charts/BandStrip.tsx +83 -3
- package/src/charts/Bars.tsx +7 -0
- package/src/charts/CartesianChart.tsx +18 -3
- package/src/charts/ChartCard.tsx +54 -13
- package/src/charts/DualPanel.tsx +3 -6
- package/src/charts/Heatmap.tsx +54 -5
- package/src/charts/Lines.tsx +56 -10
- package/src/charts/MirroredBars.tsx +3 -5
- package/src/charts/Sparkline.tsx +135 -25
- package/src/charts/StackedArea.tsx +14 -4
- package/src/charts/band-fold.ts +50 -1
- package/src/charts/chart-box.module.css +19 -0
- package/src/charts/chart-card.module.css +25 -0
- package/src/charts/chart-dates.ts +30 -0
- package/src/charts/chart-legend.module.css +7 -0
- package/src/charts/compile.ts +253 -87
- package/src/charts/date-tick-format.ts +10 -13
- package/src/charts/labels.ts +81 -26
- package/src/charts/legend.tsx +10 -20
- package/src/charts/marks.ts +1 -1
- package/src/charts/panel.tsx +1 -16
- package/src/charts/ref-label.ts +131 -0
- package/src/charts/scales.ts +22 -2
- package/src/charts/sparkline.module.css +13 -17
- package/src/charts/sparkline.module.css.d.ts +1 -2
- package/src/charts/state.tsx +9 -4
- package/src/charts/types.ts +18 -8
- package/src/cli/doctor-upgrade.ts +1 -1
- package/src/cli/init.ts +100 -3
- package/src/cli/shot/capture.ts +266 -35
- package/src/cli/shot/detect.ts +18 -1
- package/src/cli/shot/playwright.ts +20 -4
- package/src/cli/shot/types.ts +5 -0
- package/src/cli/tokens-css.ts +18 -20
- package/src/controls/controls.module.css +11 -1
- package/src/controls/filter-pill.tsx +2 -0
- package/src/controls/sync-button.module.css +34 -2
- package/src/controls/sync-button.module.css.d.ts +1 -0
- package/src/controls/sync-button.tsx +40 -4
- package/src/dashboard/bar-list.module.css +83 -0
- package/src/dashboard/bar-list.module.css.d.ts +1 -0
- package/src/dashboard/bar-list.tsx +107 -69
- package/src/dashboard/delta-badge.tsx +6 -2
- package/src/dashboard/index.ts +1 -0
- package/src/dashboard/meter-model.ts +207 -24
- package/src/dashboard/meter-parts.tsx +349 -67
- package/src/dashboard/meter.module.css +76 -0
- package/src/dashboard/meter.module.css.d.ts +6 -0
- package/src/dashboard/meter.tsx +72 -18
- package/src/dashboard/page-summary.module.css +89 -0
- package/src/dashboard/page-summary.module.css.d.ts +15 -0
- package/src/dashboard/page-summary.tsx +95 -0
- package/src/dashboard/query-state.tsx +1 -1
- package/src/dashboard/section.module.css +23 -0
- package/src/dashboard/section.module.css.d.ts +1 -0
- package/src/dashboard/section.tsx +59 -11
- package/src/dashboard/stat-card-parts.tsx +5 -1
- package/src/dashboard/stat-card.module.css +36 -0
- package/src/dashboard/stat-card.tsx +12 -6
- package/src/dashboard/stat-group.module.css +7 -0
- package/src/dashboard/stat-strip.module.css +122 -53
- package/src/dashboard/stat-strip.module.css.d.ts +4 -0
- package/src/dashboard/stat-strip.tsx +176 -91
- package/src/dashboard/visual-slot.ts +12 -3
- package/src/guard/index.ts +0 -5
- package/src/guard/vx-names.ts +2 -0
- package/src/index.ts +2 -0
- package/src/styles.css +43 -4
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +200 -68
- package/src/theme/chrome-vars.ts +77 -8
- package/src/theme/controls.module.css +37 -0
- package/src/theme/controls.module.css.d.ts +2 -0
- package/src/theme/index.ts +22 -32
- package/src/theme/status-verdict.tsx +5 -1
- package/src/tokens/core.ts +4 -1
- package/src/tokens/derive.ts +32 -3
- package/src/tokens/palette.ts +11 -10
- package/src/tokens/status-text.ts +2 -0
|
@@ -29,8 +29,8 @@ function DeltaBadge({
|
|
|
29
29
|
const tone = resolveTone(value, polarity);
|
|
30
30
|
const glyph = directionGlyph(value);
|
|
31
31
|
const showGlyph = withGlyph && glyph !== void 0;
|
|
32
|
-
return /* @__PURE__ */ jsxs("span", { className: classes.deltaBadge, style: { color: tone }, children: [
|
|
33
|
-
showGlyph && /* @__PURE__ */ jsx("span", { className: classes.deltaGlyph, children: glyph }),
|
|
32
|
+
return /* @__PURE__ */ jsxs("span", { className: classes.deltaBadge, style: { color: tone }, "data-delta": "", children: [
|
|
33
|
+
showGlyph && /* @__PURE__ */ jsx("span", { className: classes.deltaGlyph, "data-delta-glyph": "", children: glyph }),
|
|
34
34
|
format(value),
|
|
35
35
|
period !== void 0 && " ",
|
|
36
36
|
period !== void 0 && /* @__PURE__ */ jsx("span", { className: classes.deltaPeriod, children: composePeriod(period, periodPrefix) })
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { WidgetHeader } from './widget-header.js';
|
|
2
2
|
export { DeltaBadge } from './delta-badge.js';
|
|
3
3
|
export { Section } from './section.js';
|
|
4
|
+
export { PageSummary, type PageSummaryProps } from './page-summary.js';
|
|
4
5
|
export { StatCard, type StatCardBreakdownRow, type StatCardSparklineSize } from './stat-card.js';
|
|
5
6
|
export { StatGroup } from './stat-group.js';
|
|
6
7
|
export type { StatStripCell, StatStripRow } from './stat-strip.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dashboard/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,KAAK,oBAAoB,EAAE,KAAK,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAC7F,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC7E,OAAO,EAAE,KAAK,EAAE,KAAK,UAAU,EAAE,MAAM,SAAS,CAAA;AAChD,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACvE,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dashboard/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACnE,OAAO,EAAE,QAAQ,EAAE,KAAK,oBAAoB,EAAE,KAAK,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAC7F,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC7E,OAAO,EAAE,KAAK,EAAE,KAAK,UAAU,EAAE,MAAM,SAAS,CAAA;AAChD,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACvE,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/dashboard/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { WidgetHeader } from "./widget-header.js";
|
|
2
2
|
import { DeltaBadge } from "./delta-badge.js";
|
|
3
3
|
import { Section } from "./section.js";
|
|
4
|
+
import { PageSummary } from "./page-summary.js";
|
|
4
5
|
import { StatCard } from "./stat-card.js";
|
|
5
6
|
import { StatGroup } from "./stat-group.js";
|
|
6
7
|
import { EmptyState } from "./empty-state.js";
|
|
@@ -13,6 +14,7 @@ export {
|
|
|
13
14
|
DeltaBadge,
|
|
14
15
|
EmptyState,
|
|
15
16
|
Meter,
|
|
17
|
+
PageSummary,
|
|
16
18
|
Section,
|
|
17
19
|
SettingsRow,
|
|
18
20
|
SettingsSection,
|
|
@@ -7,12 +7,22 @@ export type MeterSegment = {
|
|
|
7
7
|
value: number;
|
|
8
8
|
label: string;
|
|
9
9
|
color?: string;
|
|
10
|
+
/**
|
|
11
|
+
* `'muted'`: the part takes the one flat muted fill every muted part shares, a hairline seam
|
|
12
|
+
* between neighbours (never a lightness step). A `color` wins.
|
|
13
|
+
*/
|
|
14
|
+
tone?: 'muted';
|
|
10
15
|
forecast?: boolean;
|
|
11
16
|
};
|
|
12
17
|
export type MeterZone = {
|
|
13
18
|
from: number;
|
|
14
19
|
to: number;
|
|
15
20
|
label: string;
|
|
21
|
+
/**
|
|
22
|
+
* `'muted'`: the band takes the one flat muted fill every muted zone shares, a hairline gap
|
|
23
|
+
* between neighbours (never a lightness step): a non-verdict band is not a value bar. A `color` wins.
|
|
24
|
+
*/
|
|
25
|
+
tone?: 'muted';
|
|
16
26
|
/**
|
|
17
27
|
* A shorter name for a narrow track. The row tries `label`, then `short`, and only then hides the
|
|
18
28
|
* name; the holding zone always shows its full `label`. The described-by text keeps `label`.
|
|
@@ -20,16 +30,43 @@ export type MeterZone = {
|
|
|
20
30
|
short?: string;
|
|
21
31
|
color?: string;
|
|
22
32
|
};
|
|
23
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* A mark on the track at `at` (in the reading's units). A `label` is captioned beside it, above the
|
|
35
|
+
* track; a `caption` sits under the track, centred on the mark and clamped inside the track.
|
|
36
|
+
*/
|
|
24
37
|
export type MeterTick = {
|
|
25
38
|
at: number;
|
|
26
39
|
label?: string;
|
|
40
|
+
caption?: string;
|
|
41
|
+
};
|
|
42
|
+
/** A colour of a `stops` gradient at `at` (in the reading's units); the colour is the consumer's. */
|
|
43
|
+
type MeterStop = {
|
|
44
|
+
at: number;
|
|
45
|
+
color: string;
|
|
27
46
|
};
|
|
47
|
+
/** A ramp step's strength in percent of its neutral: from `lo`, spread over `step` across the steps. */
|
|
48
|
+
export declare const RAMP_ZONE: {
|
|
49
|
+
lo: number;
|
|
50
|
+
step: number;
|
|
51
|
+
solo: number;
|
|
52
|
+
};
|
|
53
|
+
/** Neighbouring steps stay at least this far apart (the contrast the zone ramp always had), up to `RAMP_MAX`. */
|
|
54
|
+
export declare const RAMP_MIN_STEP = 15;
|
|
55
|
+
export declare const RAMP_MAX = 95;
|
|
56
|
+
/**
|
|
57
|
+
* Step `index` of `count`. The spread is floored at `RAMP_MIN_STEP` per step, so a ramp stays
|
|
58
|
+
* distinguishable by lightness up to six zones; past that the last steps clamp at
|
|
59
|
+
* `RAMP_MAX` and merge, which is the cue to group parts.
|
|
60
|
+
*/
|
|
61
|
+
export declare function rampStrength(index: number, count: number, ramp: typeof RAMP_ZONE): number;
|
|
62
|
+
/** A zone's fill: its own colour, else the one flat muted fill (`tone="muted"`), else its step of the line ramp. */
|
|
63
|
+
export declare function zoneFill(zone: MeterZone, index: number, count: number): string;
|
|
28
64
|
/** One tick on the track: its percent position and what it says (caption `label`, aria `text`). */
|
|
29
65
|
export type TickMark = {
|
|
30
66
|
key: string;
|
|
31
67
|
pct: number;
|
|
32
68
|
label: string | undefined;
|
|
69
|
+
caption: string | undefined;
|
|
33
70
|
text: string;
|
|
34
71
|
};
|
|
35
72
|
/** A fill on the track, as fractions (0–1) of the span, with the segment it was laid out from. */
|
|
@@ -38,6 +75,8 @@ export type Part = {
|
|
|
38
75
|
readonly size: number;
|
|
39
76
|
readonly color: string | undefined;
|
|
40
77
|
readonly forecast: boolean;
|
|
78
|
+
/** A muted part right after another muted part: a hairline seam keeps the shared fill apart. */
|
|
79
|
+
readonly seam: boolean;
|
|
41
80
|
readonly label: string;
|
|
42
81
|
/** The segment's own (normalised) amount, in the reading's units — what its caption states. */
|
|
43
82
|
readonly amount: number;
|
|
@@ -48,6 +87,8 @@ export type PartCaption = {
|
|
|
48
87
|
label: string;
|
|
49
88
|
text: string;
|
|
50
89
|
color: string | undefined;
|
|
90
|
+
/** Where the part starts on the track, in percent: the caption sits under it when they all fit. */
|
|
91
|
+
startPct: number;
|
|
51
92
|
};
|
|
52
93
|
/** One zone's name on the label row: its span's centre and width (percent) and whether it holds the reading. */
|
|
53
94
|
export type ZoneLabel = {
|
|
@@ -70,6 +111,13 @@ type Format = (value: number) => string;
|
|
|
70
111
|
* is DROPPED, never clamped: a mark pinned to the end would state a position it is not at.
|
|
71
112
|
*/
|
|
72
113
|
export declare function tickMarks(ticks: readonly MeterTick[] | undefined, min: number, max: number, format: Format): TickMark[];
|
|
114
|
+
/** A `stops` gradient's colour list, in order along the track; `at` outside `[min, max]` clamps. */
|
|
115
|
+
export declare function stopsGradient(stops: readonly MeterStop[], min: number, span: number): string;
|
|
116
|
+
/** A ring's marks (target, ticks): the angle clockwise from the top, and the accessible text. */
|
|
117
|
+
export declare function ringMarks(target: number | undefined, ticks: readonly MeterTick[] | undefined, min: number, max: number, format: Format): {
|
|
118
|
+
angle: number;
|
|
119
|
+
text: string;
|
|
120
|
+
}[];
|
|
73
121
|
export declare const isReading: (n: number | null | undefined) => n is number;
|
|
74
122
|
/** The track's span. A track that ends at or before its start falls back to 1 and is `valid: false`. */
|
|
75
123
|
export declare function spanOf(min: number, max: number): {
|
|
@@ -107,6 +155,8 @@ export type RowLabel = {
|
|
|
107
155
|
box: LabelBox;
|
|
108
156
|
span?: LabelBox;
|
|
109
157
|
holding?: boolean;
|
|
158
|
+
/** A tick at the track's start or end: it keeps its place over every zone name it would touch. */
|
|
159
|
+
end?: boolean;
|
|
110
160
|
short?: LabelBox;
|
|
111
161
|
};
|
|
112
162
|
/** The placement of the row's labels, index-aligned with the input. */
|
|
@@ -120,11 +170,14 @@ export type RowPlacement = {
|
|
|
120
170
|
/**
|
|
121
171
|
* Which labels of the row show, in input order. The holding zone's name claims its place first (it
|
|
122
172
|
* is the reading's verdict, so it never hides for width: it may spill past its span, shifted inside
|
|
123
|
-
* the row); the
|
|
124
|
-
* when it lies inside the row and its own span and
|
|
125
|
-
*
|
|
173
|
+
* the row); the other ticks go next, then the end ticks (at the track's start or end: a scale's
|
|
174
|
+
* figures); every other zone name then shows only when it lies inside the row and its own span and
|
|
175
|
+
* clears every label already kept, trying its full name, then its `short` box, then hiding. An end
|
|
176
|
+
* figure hides only when it cannot clear the holding name, an interior tick or the other end. A tick
|
|
177
|
+
* keeps at least `gap` px (one gap step of the host's spacing) from every other label; zone names
|
|
178
|
+
* among themselves only must not touch. A hidden name is still named in the described-by text.
|
|
126
179
|
*/
|
|
127
|
-
export declare function placeRowLabels(labels: readonly RowLabel[], rowWidth: number): RowPlacement;
|
|
180
|
+
export declare function placeRowLabels(labels: readonly RowLabel[], rowWidth: number, gap?: number): RowPlacement;
|
|
128
181
|
/** A zone band as left edge + width in percent, clipped to the track. */
|
|
129
182
|
export declare function zoneBand(zone: MeterZone, min: number, span: number): {
|
|
130
183
|
start: number;
|
|
@@ -137,6 +190,7 @@ export type BarInput = {
|
|
|
137
190
|
format: Format;
|
|
138
191
|
segments?: readonly MeterSegment[] | undefined;
|
|
139
192
|
zones?: readonly MeterZone[] | undefined;
|
|
193
|
+
stops?: readonly MeterStop[] | undefined;
|
|
140
194
|
target?: number | undefined;
|
|
141
195
|
ticks?: readonly MeterTick[] | undefined;
|
|
142
196
|
color?: string | undefined;
|
|
@@ -152,6 +206,8 @@ export type BarModel = {
|
|
|
152
206
|
captionMode: CaptionMode;
|
|
153
207
|
/** Only in `parts` mode: one caption per part, in order. Empty otherwise. */
|
|
154
208
|
partCaptions: readonly PartCaption[];
|
|
209
|
+
/** The `stops` gradient's colour list; absent without `stops`. */
|
|
210
|
+
stopsCss: string | undefined;
|
|
155
211
|
/** Only on a zoned track: every zone's name, in zone order. Empty otherwise. */
|
|
156
212
|
zoneLabels: readonly ZoneLabel[];
|
|
157
213
|
ticks: readonly TickMark[];
|
|
@@ -169,5 +225,28 @@ export declare function startCaptionText(model: BarModel, override: ReactNode |
|
|
|
169
225
|
export declare function modelBar(input: BarInput): BarModel;
|
|
170
226
|
/** The ring's one arc, as a fraction of the circumference. */
|
|
171
227
|
export declare const ringFraction: (reading: number, min: number, max: number) => number;
|
|
228
|
+
/** One caption on the marks row: its natural width and where it is anchored (`pct`), else its edge. */
|
|
229
|
+
export type MarkItem = {
|
|
230
|
+
width: number;
|
|
231
|
+
pct?: number;
|
|
232
|
+
edge?: 'end';
|
|
233
|
+
};
|
|
234
|
+
/**
|
|
235
|
+
* Where each caption of the marks row starts (px, logical start edge), index-aligned with `items`: an
|
|
236
|
+
* anchored caption is centred on its mark and clamped inside the row, the others sit at the start (or,
|
|
237
|
+
* `edge: 'end'`, the end). Two captions closer than `gap` are pushed apart, in order, the least that
|
|
238
|
+
* clears them, so a caption stays as near its mark as the row allows. `null` when nothing is anchored,
|
|
239
|
+
* the row is unmeasured, a caption is wider than the row, or the captions cannot all clear each other
|
|
240
|
+
* inside the row: the row then flows and wraps instead.
|
|
241
|
+
*/
|
|
242
|
+
export declare function placeMarkCaptions(items: readonly MarkItem[], rowWidth: number, gap: number): number[] | null;
|
|
243
|
+
/**
|
|
244
|
+
* Whether every categorical part's caption fits under its own segment: left-aligned at the part's
|
|
245
|
+
* start and ending before the next part's start (less `gap`) or the row's end. A zero-width part never fits.
|
|
246
|
+
*/
|
|
247
|
+
export declare function partsFitUnder(parts: readonly {
|
|
248
|
+
startPct: number;
|
|
249
|
+
width: number;
|
|
250
|
+
}[], rowWidth: number, gap: number): boolean;
|
|
172
251
|
export {};
|
|
173
252
|
//# sourceMappingURL=meter-model.d.ts.map
|
|
@@ -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;
|
|
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;IACzB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AACD,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IACd;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AACD;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAExE,qGAAqG;AACrG,KAAK,SAAS,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAE9C,wGAAwG;AACxG,eAAO,MAAM,SAAS;;;;CAAiC,CAAA;AAIvD,iHAAiH;AACjH,eAAO,MAAM,aAAa,KAAK,CAAA;AAC/B,eA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
+
function rampStrength(index, count, ramp) {
|
|
8
|
+
if (count <= 1) return ramp.solo;
|
|
9
|
+
return Math.min(RAMP_MAX, ramp.lo + index * Math.max(RAMP_MIN_STEP, ramp.step / (count - 1)));
|
|
10
|
+
}
|
|
11
|
+
function rampFill(base, index, count, ramp) {
|
|
12
|
+
return `color-mix(in srgb, var(--vx-${base}) ${rampStrength(index, count, ramp)}%, transparent)`;
|
|
13
|
+
}
|
|
14
|
+
const mutedFill = (pct) => `color-mix(in srgb, var(--vx-muted) ${pct}%, transparent)`;
|
|
15
|
+
function zoneFill(zone, index, count) {
|
|
16
|
+
if (zone.color !== void 0) return zone.color;
|
|
17
|
+
return zone.tone === "muted" ? mutedFill(MUTED_ZONE) : rampFill("line", index, count, RAMP_ZONE);
|
|
18
|
+
}
|
|
2
19
|
function tickMarks(ticks, min, max, format) {
|
|
3
20
|
const { span } = spanOf(min, max);
|
|
4
21
|
return (ticks ?? []).flatMap(
|
|
@@ -7,11 +24,28 @@ function tickMarks(ticks, min, max, format) {
|
|
|
7
24
|
key: String(i),
|
|
8
25
|
pct: toPct((t.at - min) / span),
|
|
9
26
|
label: t.label,
|
|
27
|
+
caption: t.caption,
|
|
10
28
|
text: `${t.label ?? "Tick"} ${format(t.at)}`
|
|
11
29
|
}
|
|
12
30
|
] : []
|
|
13
31
|
);
|
|
14
32
|
}
|
|
33
|
+
function stopsGradient(stops, min, span) {
|
|
34
|
+
return stops.toSorted((a, b) => a.at - b.at).map((s) => `${s.color} ${toPct(clamp01((s.at - min) / span))}%`).join(", ");
|
|
35
|
+
}
|
|
36
|
+
const ringAngle = (pct) => Math.round(pct * 3.6 * 100) / 100;
|
|
37
|
+
function ringMarks(target, ticks, min, max, format) {
|
|
38
|
+
const { span } = spanOf(min, max);
|
|
39
|
+
const marks = tickMarks(ticks, min, max, format).map((t) => ({
|
|
40
|
+
angle: ringAngle(t.pct),
|
|
41
|
+
text: t.text
|
|
42
|
+
}));
|
|
43
|
+
if (target === void 0 || !Number.isFinite(target) || target < min || target > max) return marks;
|
|
44
|
+
return [
|
|
45
|
+
{ angle: ringAngle(toPct((target - min) / span)), text: `Target ${format(target)}` },
|
|
46
|
+
...marks
|
|
47
|
+
];
|
|
48
|
+
}
|
|
15
49
|
const isReading = (n) => typeof n === "number" && Number.isFinite(n);
|
|
16
50
|
function spanOf(min, max) {
|
|
17
51
|
return max > min ? { span: max - min, valid: true } : { span: 1, valid: false };
|
|
@@ -30,18 +64,22 @@ function normalizeSegments(segments) {
|
|
|
30
64
|
}
|
|
31
65
|
function layoutSegments(segments, span) {
|
|
32
66
|
let cursor = 0;
|
|
67
|
+
const isMuted = (s) => s.tone === "muted" && s.color === void 0 && !s.forecast;
|
|
68
|
+
let prevMuted = false;
|
|
33
69
|
return segments.map((s) => {
|
|
34
70
|
const size = Math.max(0, Math.min(clamp01(s.value / span), 1 - cursor));
|
|
35
71
|
const forecast = s.forecast === true;
|
|
36
72
|
const part = {
|
|
37
73
|
start: cursor,
|
|
38
74
|
size,
|
|
39
|
-
color: forecast ? void 0 : s.color,
|
|
75
|
+
color: forecast ? void 0 : isMuted(s) ? mutedFill(MUTED_PART) : s.color,
|
|
40
76
|
forecast,
|
|
77
|
+
seam: isMuted(s) && prevMuted,
|
|
41
78
|
label: s.label,
|
|
42
79
|
amount: s.value
|
|
43
80
|
};
|
|
44
81
|
cursor += size;
|
|
82
|
+
prevMuted = isMuted(s);
|
|
45
83
|
return part;
|
|
46
84
|
});
|
|
47
85
|
}
|
|
@@ -50,35 +88,39 @@ function findHoldingZone(zones, value) {
|
|
|
50
88
|
return zones.find((z) => value >= z.from && (value < z.to || value === z.to && z.to === end));
|
|
51
89
|
}
|
|
52
90
|
const LABEL_SUBPIXEL = 0.5;
|
|
53
|
-
function placeRowLabels(labels, rowWidth) {
|
|
91
|
+
function placeRowLabels(labels, rowWidth, gap = 0) {
|
|
54
92
|
const shown = labels.map(() => false);
|
|
55
93
|
const short = labels.map(() => false);
|
|
56
94
|
const shift = labels.map(() => 0);
|
|
57
95
|
const kept = [];
|
|
58
|
-
const rank = (l) => l.holding ? 0 : l.span ? 2 : 1;
|
|
96
|
+
const rank = (l) => l.holding ? 0 : l.span ? 3 : l.end ? 2 : 1;
|
|
59
97
|
const order = labels.map((_, i) => i).toSorted((a, b) => rank(labels[a]) - rank(labels[b]));
|
|
60
|
-
const clears = (b) => !kept.some((
|
|
98
|
+
const clears = (b, tick) => !kept.some(({ box: k, tick: kTick }) => {
|
|
99
|
+
const pad = tick || kTick ? gap : 0;
|
|
100
|
+
return b.left < k.right + pad - LABEL_SUBPIXEL && k.left < b.right + pad - LABEL_SUBPIXEL;
|
|
101
|
+
});
|
|
61
102
|
for (const i of order) {
|
|
62
103
|
const label = labels[i];
|
|
63
104
|
const { span } = label;
|
|
105
|
+
const tick = span === void 0 && !label.holding;
|
|
64
106
|
let box = label.box;
|
|
65
107
|
if (label.holding) {
|
|
66
108
|
const width = box.right - box.left;
|
|
67
109
|
const left = Math.max(0, Math.min(box.left, rowWidth - width));
|
|
68
110
|
shift[i] = left - box.left;
|
|
69
111
|
box = { left, right: left + width };
|
|
70
|
-
if (!clears(box)) continue;
|
|
112
|
+
if (!clears(box, false)) continue;
|
|
71
113
|
shown[i] = true;
|
|
72
|
-
kept.push(box);
|
|
114
|
+
kept.push({ box, tick: false });
|
|
73
115
|
continue;
|
|
74
116
|
}
|
|
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);
|
|
117
|
+
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, tick);
|
|
76
118
|
const useShort = !fits(box) && label.short !== void 0 && fits(label.short);
|
|
77
119
|
if (useShort) box = label.short;
|
|
78
120
|
else if (!fits(box)) continue;
|
|
79
121
|
shown[i] = true;
|
|
80
122
|
short[i] = useShort;
|
|
81
|
-
kept.push(box);
|
|
123
|
+
kept.push({ box, tick });
|
|
82
124
|
}
|
|
83
125
|
return { shown, short, shift };
|
|
84
126
|
}
|
|
@@ -93,8 +135,8 @@ function endCaptionText(reading, target, format) {
|
|
|
93
135
|
if (reading > target) return `Target ${format(target)} \xB7 ${format(reading - target)} over`;
|
|
94
136
|
return `Target ${format(target)}`;
|
|
95
137
|
}
|
|
96
|
-
function fillParts(input, span,
|
|
97
|
-
if (
|
|
138
|
+
function fillParts(input, span, marked) {
|
|
139
|
+
if (marked) return [];
|
|
98
140
|
if (input.segments !== void 0) return layoutSegments(input.segments, span);
|
|
99
141
|
const fill = { value: input.reading - input.min, label: "" };
|
|
100
142
|
return layoutSegments([input.color === void 0 ? fill : { ...fill, color: input.color }], span);
|
|
@@ -105,7 +147,8 @@ function partCaptionsOf(parts, format) {
|
|
|
105
147
|
key: String(i),
|
|
106
148
|
label: p.label,
|
|
107
149
|
text: format(p.amount),
|
|
108
|
-
color: p.color
|
|
150
|
+
color: p.color,
|
|
151
|
+
startPct: toPct(p.start)
|
|
109
152
|
}));
|
|
110
153
|
}
|
|
111
154
|
function captionModeOf(segments, zoned, firstForecast) {
|
|
@@ -118,12 +161,13 @@ function startCaptionText(model, override) {
|
|
|
118
161
|
return model.captionMode === "parts" ? null : model.startText;
|
|
119
162
|
}
|
|
120
163
|
function modelBar(input) {
|
|
121
|
-
const { reading, min, max, format, segments, zones, target } = input;
|
|
164
|
+
const { reading, min, max, format, segments, zones, target, stops } = input;
|
|
122
165
|
const ticks = tickMarks(input.ticks, min, max, format);
|
|
123
166
|
const { span } = spanOf(min, max);
|
|
124
167
|
const zoned = zones !== void 0 && zones.length > 0;
|
|
125
168
|
const holding = zoned ? findHoldingZone(zones, reading) : void 0;
|
|
126
|
-
const
|
|
169
|
+
const striped = !zoned && stops !== void 0 && stops.length > 0;
|
|
170
|
+
const parts = fillParts(input, span, zoned || striped);
|
|
127
171
|
const firstForecast = parts.findIndex((p) => p.forecast);
|
|
128
172
|
const forecastLabels = segments?.filter((s) => s.forecast === true).map((s) => `${s.label} ${format(s.value)}`) ?? [];
|
|
129
173
|
const captionMode = captionModeOf(segments, zoned, firstForecast);
|
|
@@ -145,6 +189,7 @@ function modelBar(input) {
|
|
|
145
189
|
forecastText: forecastLabels.length === 0 ? null : input.forecastCaption ?? `Forecast: ${forecastLabels.join(", ")}`,
|
|
146
190
|
captionMode,
|
|
147
191
|
partCaptions,
|
|
192
|
+
stopsCss: striped ? stopsGradient(stops, min, span) : void 0,
|
|
148
193
|
zoneLabels: !zoned ? [] : zones.map((z, i) => {
|
|
149
194
|
const band = zoneBand(z, min, span);
|
|
150
195
|
return {
|
|
@@ -157,7 +202,7 @@ function modelBar(input) {
|
|
|
157
202
|
};
|
|
158
203
|
}),
|
|
159
204
|
ticks,
|
|
160
|
-
markerPct: zoned ? toPct((reading - min) / span) : void 0,
|
|
205
|
+
markerPct: zoned || striped ? toPct((reading - min) / span) : void 0,
|
|
161
206
|
targetPct: target === void 0 ? void 0 : toPct((target - min) / span),
|
|
162
207
|
startText: format(reading),
|
|
163
208
|
endText: endCaptionText(reading, target, format),
|
|
@@ -165,19 +210,59 @@ function modelBar(input) {
|
|
|
165
210
|
};
|
|
166
211
|
}
|
|
167
212
|
const ringFraction = (reading, min, max) => clamp01((reading - min) / spanOf(min, max).span);
|
|
213
|
+
function placeMarkCaptions(items, rowWidth, gap) {
|
|
214
|
+
if (rowWidth <= 0 || !items.some((i) => i.pct !== void 0)) return null;
|
|
215
|
+
if (items.some((i) => i.width > rowWidth)) return null;
|
|
216
|
+
const lefts = items.map((i) => {
|
|
217
|
+
if (i.pct === void 0) return i.edge === "end" ? rowWidth - i.width : 0;
|
|
218
|
+
return Math.max(0, Math.min(rowWidth * i.pct / 100 - i.width / 2, rowWidth - i.width));
|
|
219
|
+
});
|
|
220
|
+
const order = lefts.map((_, i) => i).toSorted((a, b) => (lefts[a] ?? 0) - (lefts[b] ?? 0));
|
|
221
|
+
const widthOf = (i) => items[i]?.width ?? 0;
|
|
222
|
+
for (const [n, i] of order.entries()) {
|
|
223
|
+
const prev = order[n - 1];
|
|
224
|
+
if (prev !== void 0)
|
|
225
|
+
lefts[i] = Math.max(lefts[i] ?? 0, (lefts[prev] ?? 0) + widthOf(prev) + gap);
|
|
226
|
+
}
|
|
227
|
+
for (const [n, i] of order.toReversed().entries()) {
|
|
228
|
+
const next = order.toReversed()[n - 1];
|
|
229
|
+
const limit = next === void 0 ? rowWidth : (lefts[next] ?? 0) - gap;
|
|
230
|
+
lefts[i] = Math.min(lefts[i] ?? 0, limit - widthOf(i));
|
|
231
|
+
}
|
|
232
|
+
const first = order[0];
|
|
233
|
+
return first !== void 0 && (lefts[first] ?? 0) < -LABEL_SUBPIXEL ? null : lefts;
|
|
234
|
+
}
|
|
235
|
+
function partsFitUnder(parts, rowWidth, gap) {
|
|
236
|
+
if (rowWidth <= 0) return false;
|
|
237
|
+
return parts.every((p, i) => {
|
|
238
|
+
const left = rowWidth * p.startPct / 100;
|
|
239
|
+
const next = parts[i + 1];
|
|
240
|
+
const limit = next === void 0 ? rowWidth : rowWidth * next.startPct / 100 - gap;
|
|
241
|
+
return left + p.width <= limit + LABEL_SUBPIXEL;
|
|
242
|
+
});
|
|
243
|
+
}
|
|
168
244
|
export {
|
|
169
245
|
LABEL_SUBPIXEL,
|
|
246
|
+
RAMP_MAX,
|
|
247
|
+
RAMP_MIN_STEP,
|
|
248
|
+
RAMP_ZONE,
|
|
170
249
|
ariaValues,
|
|
171
250
|
findHoldingZone,
|
|
172
251
|
isReading,
|
|
173
252
|
layoutSegments,
|
|
174
253
|
modelBar,
|
|
175
254
|
normalizeSegments,
|
|
255
|
+
partsFitUnder,
|
|
256
|
+
placeMarkCaptions,
|
|
176
257
|
placeRowLabels,
|
|
258
|
+
rampStrength,
|
|
177
259
|
ringFraction,
|
|
260
|
+
ringMarks,
|
|
178
261
|
segmentReading,
|
|
179
262
|
spanOf,
|
|
180
263
|
startCaptionText,
|
|
264
|
+
stopsGradient,
|
|
181
265
|
tickMarks,
|
|
182
|
-
zoneBand
|
|
266
|
+
zoneBand,
|
|
267
|
+
zoneFill
|
|
183
268
|
};
|
|
@@ -13,7 +13,7 @@ export declare function MeterLoading({ label, ring, shell, }: {
|
|
|
13
13
|
}): import("react").JSX.Element;
|
|
14
14
|
export declare function MeterEmpty(props: {
|
|
15
15
|
label: string;
|
|
16
|
-
text: string;
|
|
16
|
+
text: string | undefined;
|
|
17
17
|
ring: boolean;
|
|
18
18
|
shell: Shell;
|
|
19
19
|
}): import("react").JSX.Element;
|
|
@@ -23,6 +23,8 @@ export declare function MeterRing(props: {
|
|
|
23
23
|
min: number;
|
|
24
24
|
max: number;
|
|
25
25
|
color: string | undefined;
|
|
26
|
+
target: number | undefined;
|
|
27
|
+
ticks: readonly MeterTick[] | undefined;
|
|
26
28
|
format: (value: number) => string;
|
|
27
29
|
shell: Shell;
|
|
28
30
|
}): import("react").JSX.Element;
|
|
@@ -35,6 +37,12 @@ export declare function MeterBar(props: {
|
|
|
35
37
|
color: string | undefined;
|
|
36
38
|
segments: readonly MeterSegment[] | undefined;
|
|
37
39
|
zones: readonly MeterZone[] | undefined;
|
|
40
|
+
stops: readonly {
|
|
41
|
+
at: number;
|
|
42
|
+
color: string;
|
|
43
|
+
}[] | undefined;
|
|
44
|
+
track: boolean | undefined;
|
|
45
|
+
markerReading: boolean | undefined;
|
|
38
46
|
target: number | undefined;
|
|
39
47
|
ticks: readonly MeterTick[] | undefined;
|
|
40
48
|
tone: 'muted' | undefined;
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
1
|
+
{"version":3,"file":"meter-parts.d.ts","s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