basalt-ui 2.27.1 → 2.28.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 +111 -0
- package/MIGRATING.md +172 -12
- package/agent/rules/basalt-batteries.md +1 -1
- package/agent/rules/basalt-mantine.md +1 -1
- package/agent/rules/basalt-tokens.md +2 -2
- package/agent/skills/basalt-design/SKILL.md +1 -1
- package/agent/skills/basalt-design/references/catalogue.md +40 -36
- package/agent/skills/basalt-design/references/recipes.md +47 -0
- package/configs/oxlint-basalt.json +2 -1
- package/configs/oxlint-plugin.js +110 -2
- package/configs/oxlint-plugin.test.ts +99 -4
- package/dist/agent/chat/thread-message.d.ts +1 -160
- package/dist/agent/chat/thread-message.d.ts.map +1 -1
- package/dist/agent/chat/thread-message.js +7 -162
- package/dist/agent/chat/virtualize.d.ts +5 -5
- package/dist/charts/ChartCard.d.ts +5 -2
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +46 -13
- package/dist/charts/Lines.d.ts.map +1 -1
- package/dist/charts/Lines.js +11 -4
- package/dist/charts/Sparkline.d.ts +9 -2
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/Sparkline.js +104 -41
- package/dist/charts/chart-box.module.css +69 -3
- package/dist/charts/chart-box.module.css.d.ts +5 -0
- package/dist/charts/chart-card.module.css +12 -4
- package/dist/charts/chart-card.module.css.d.ts +1 -0
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +21 -19
- package/dist/charts/labels.d.ts +13 -3
- package/dist/charts/labels.d.ts.map +1 -1
- package/dist/charts/labels.js +131 -20
- package/dist/charts/legend.d.ts.map +1 -1
- package/dist/charts/legend.js +1 -1
- package/dist/charts/ref-label.d.ts +31 -8
- package/dist/charts/ref-label.d.ts.map +1 -1
- package/dist/charts/ref-label.js +40 -9
- package/dist/charts/sparkline.module.css +6 -0
- package/dist/charts/state.d.ts +3 -3
- package/dist/charts/state.d.ts.map +1 -1
- package/dist/charts/state.js +20 -2
- package/dist/cli/shot/capture.d.ts +6 -1
- package/dist/cli/shot/capture.d.ts.map +1 -1
- package/dist/cli/shot/capture.js +18 -5
- package/dist/common/empty-copy.d.ts +16 -0
- package/dist/common/empty-copy.d.ts.map +1 -0
- package/dist/common/empty-copy.js +9 -0
- package/dist/common/virtual-rows.d.ts +196 -0
- package/dist/common/virtual-rows.d.ts.map +1 -0
- package/dist/common/virtual-rows.js +290 -0
- package/dist/controls/controls.module.css +33 -1
- package/dist/controls/controls.module.css.d.ts +2 -0
- package/dist/controls/enum-filter.d.ts.map +1 -1
- package/dist/controls/enum-filter.js +8 -2
- package/dist/controls/filter-pill.d.ts +27 -3
- package/dist/controls/filter-pill.d.ts.map +1 -1
- package/dist/controls/filter-pill.js +15 -4
- package/dist/controls/form-layout.d.ts +9 -3
- package/dist/controls/form-layout.d.ts.map +1 -1
- package/dist/controls/form-layout.js +74 -12
- package/dist/controls/form-layout.module.css +112 -7
- package/dist/controls/form-layout.module.css.d.ts +1 -0
- package/dist/controls/multi-select-filter.d.ts +2 -2
- package/dist/controls/multi-select-filter.d.ts.map +1 -1
- package/dist/controls/multi-select-filter.js +12 -6
- package/dist/controls/range-filter.d.ts +1 -1
- package/dist/controls/range-filter.d.ts.map +1 -1
- package/dist/controls/range-filter.js +8 -2
- package/dist/dashboard/bar-list.d.ts +1 -1
- package/dist/dashboard/bar-list.d.ts.map +1 -1
- package/dist/dashboard/bar-list.js +6 -2
- package/dist/dashboard/bar-list.module.css +0 -2
- package/dist/dashboard/board-nav.d.ts +22 -0
- package/dist/dashboard/board-nav.d.ts.map +1 -0
- package/dist/dashboard/board-nav.js +49 -0
- package/dist/dashboard/board.d.ts +52 -0
- package/dist/dashboard/board.d.ts.map +1 -0
- package/dist/dashboard/board.js +228 -0
- package/dist/dashboard/board.module.css +160 -0
- package/dist/dashboard/board.module.css.d.ts +26 -0
- package/dist/dashboard/empty-state.d.ts +3 -3
- package/dist/dashboard/empty-state.d.ts.map +1 -1
- package/dist/dashboard/empty-state.js +13 -6
- package/dist/dashboard/event-list-model.d.ts +51 -0
- package/dist/dashboard/event-list-model.d.ts.map +1 -0
- package/dist/dashboard/event-list-model.js +72 -0
- package/dist/dashboard/event-list-rows.d.ts +23 -0
- package/dist/dashboard/event-list-rows.d.ts.map +1 -0
- package/dist/dashboard/event-list-rows.js +93 -0
- package/dist/dashboard/event-list-scroll.d.ts +27 -0
- package/dist/dashboard/event-list-scroll.d.ts.map +1 -0
- package/dist/dashboard/event-list-scroll.js +103 -0
- package/dist/dashboard/event-list-skeleton.d.ts +10 -0
- package/dist/dashboard/event-list-skeleton.d.ts.map +1 -0
- package/dist/dashboard/event-list-skeleton.js +36 -0
- package/dist/dashboard/event-list.d.ts +65 -0
- package/dist/dashboard/event-list.d.ts.map +1 -0
- package/dist/dashboard/event-list.js +178 -0
- package/dist/dashboard/event-list.module.css +283 -0
- package/dist/dashboard/event-list.module.css.d.ts +33 -0
- package/dist/dashboard/index.d.ts +2 -0
- package/dist/dashboard/index.d.ts.map +1 -1
- package/dist/dashboard/index.js +4 -0
- package/dist/dashboard/meter-parts.d.ts.map +1 -1
- package/dist/dashboard/meter-parts.js +5 -3
- package/dist/dashboard/meter.module.css +2 -1
- package/dist/dashboard/query-state.js +1 -1
- package/dist/dashboard/settings-section.d.ts +4 -1
- package/dist/dashboard/settings-section.d.ts.map +1 -1
- package/dist/dashboard/settings-section.js +1 -1
- package/dist/dashboard/settings-section.module.css +19 -4
- package/dist/dashboard/stat-card-parts.d.ts +5 -1
- package/dist/dashboard/stat-card-parts.d.ts.map +1 -1
- package/dist/dashboard/stat-card-parts.js +8 -3
- package/dist/dashboard/stat-card.d.ts.map +1 -1
- package/dist/dashboard/stat-card.js +26 -7
- package/dist/dashboard/stat-card.module.css +31 -7
- package/dist/dashboard/stat-card.module.css.d.ts +3 -0
- package/dist/dashboard/stat-strip.js +1 -1
- package/dist/dashboard/stat-strip.module.css +4 -1
- package/dist/dashboard/widget-header.d.ts.map +1 -1
- package/dist/dashboard/widget-header.js +15 -2
- package/dist/dashboard/widget-header.module.css +17 -1
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/shell/app-main.module.css +18 -0
- package/dist/styles.css +46 -8
- package/dist/surfaces.d.ts +2 -2
- package/dist/surfaces.d.ts.map +1 -1
- package/dist/surfaces.js +8 -2
- package/dist/table/cell-kinds.d.ts +44 -0
- package/dist/table/cell-kinds.d.ts.map +1 -0
- package/dist/table/cell-kinds.js +169 -0
- package/dist/table/cell-kinds.module.css +55 -0
- package/dist/table/cell-kinds.module.css.d.ts +15 -0
- package/dist/table/data-table-fold.d.ts +147 -0
- package/dist/table/data-table-fold.d.ts.map +1 -0
- package/dist/table/data-table-fold.js +288 -0
- package/dist/table/data-table-state.d.ts +10 -3
- package/dist/table/data-table-state.d.ts.map +1 -1
- package/dist/table/data-table-state.js +11 -6
- package/dist/table/data-table.d.ts +11 -26
- package/dist/table/data-table.d.ts.map +1 -1
- package/dist/table/data-table.js +354 -254
- package/dist/table/data-table.module.css +210 -3
- package/dist/table/data-table.module.css.d.ts +12 -0
- package/dist/table/table-features.d.ts +34 -4
- package/dist/table/table-features.d.ts.map +1 -1
- package/dist/table/table-features.js +10 -0
- package/dist/theme/card-inset.module.css +35 -0
- package/dist/theme/controls.module.css +32 -0
- package/dist/theme/ctl-theme.d.ts.map +1 -1
- package/dist/theme/ctl-theme.js +5 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +14 -10
- package/dist/tokens/core.d.ts +1 -0
- package/dist/tokens/core.d.ts.map +1 -1
- package/dist/tokens/core.js +1 -0
- package/dist/tokens/derive.js +1 -1
- package/dist/tokens/palette.d.ts +2 -1
- package/dist/tokens/palette.d.ts.map +1 -1
- package/llms.txt +34 -5
- package/package.json +1 -1
- package/src/agent/chat/thread-message.tsx +10 -403
- package/src/agent/chat/virtualize.ts +5 -5
- package/src/charts/ChartCard.tsx +79 -17
- package/src/charts/Lines.tsx +13 -4
- package/src/charts/Sparkline.tsx +131 -45
- package/src/charts/chart-box.module.css +69 -3
- package/src/charts/chart-box.module.css.d.ts +5 -0
- package/src/charts/chart-card.module.css +12 -4
- package/src/charts/chart-card.module.css.d.ts +1 -0
- package/src/charts/compile.ts +24 -20
- package/src/charts/labels.ts +175 -24
- package/src/charts/legend.tsx +3 -2
- package/src/charts/ref-label.ts +86 -17
- package/src/charts/sparkline.module.css +6 -0
- package/src/charts/state.tsx +36 -7
- package/src/cli/shot/capture.ts +29 -6
- package/src/common/empty-copy.ts +17 -0
- package/src/common/virtual-rows.tsx +682 -0
- package/src/controls/controls.module.css +33 -1
- package/src/controls/controls.module.css.d.ts +2 -0
- package/src/controls/enum-filter.tsx +8 -2
- package/src/controls/filter-pill.tsx +80 -27
- package/src/controls/form-layout.module.css +112 -7
- package/src/controls/form-layout.module.css.d.ts +1 -0
- package/src/controls/form-layout.tsx +115 -22
- package/src/controls/multi-select-filter.tsx +22 -11
- package/src/controls/range-filter.tsx +9 -3
- package/src/dashboard/bar-list.module.css +0 -2
- package/src/dashboard/bar-list.tsx +8 -5
- package/src/dashboard/board-nav.ts +67 -0
- package/src/dashboard/board.module.css +160 -0
- package/src/dashboard/board.module.css.d.ts +26 -0
- package/src/dashboard/board.tsx +394 -0
- package/src/dashboard/empty-state.tsx +16 -9
- package/src/dashboard/event-list-model.ts +113 -0
- package/src/dashboard/event-list-rows.tsx +120 -0
- package/src/dashboard/event-list-scroll.ts +145 -0
- package/src/dashboard/event-list-skeleton.tsx +58 -0
- package/src/dashboard/event-list.module.css +283 -0
- package/src/dashboard/event-list.module.css.d.ts +33 -0
- package/src/dashboard/event-list.tsx +309 -0
- package/src/dashboard/index.ts +2 -0
- package/src/dashboard/meter-parts.tsx +9 -2
- package/src/dashboard/meter.module.css +2 -1
- package/src/dashboard/query-state.tsx +1 -1
- package/src/dashboard/settings-section.module.css +19 -4
- package/src/dashboard/settings-section.tsx +7 -2
- package/src/dashboard/stat-card-parts.tsx +20 -3
- package/src/dashboard/stat-card.module.css +31 -7
- package/src/dashboard/stat-card.module.css.d.ts +3 -0
- package/src/dashboard/stat-card.tsx +25 -6
- package/src/dashboard/stat-strip.module.css +4 -1
- package/src/dashboard/stat-strip.tsx +1 -1
- package/src/dashboard/widget-header.module.css +17 -1
- package/src/dashboard/widget-header.tsx +29 -5
- package/src/guard/index.ts +2 -0
- package/src/index.ts +4 -0
- package/src/shell/app-main.module.css +18 -0
- package/src/styles.css +46 -8
- package/src/surfaces.ts +7 -1
- package/src/table/cell-kinds.module.css +55 -0
- package/src/table/cell-kinds.module.css.d.ts +15 -0
- package/src/table/cell-kinds.tsx +234 -0
- package/src/table/data-table-fold.tsx +514 -0
- package/src/table/data-table-state.ts +24 -13
- package/src/table/data-table.module.css +210 -3
- package/src/table/data-table.module.css.d.ts +12 -0
- package/src/table/data-table.tsx +406 -359
- package/src/table/table-features.ts +44 -4
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +2 -66
- package/src/theme/card-inset.module.css +35 -0
- package/src/theme/controls.module.css +32 -0
- package/src/theme/ctl-theme.tsx +8 -0
- package/src/theme/index.ts +12 -8
- package/src/tokens/core.ts +1 -0
- package/src/tokens/derive.ts +1 -1
- package/src/tokens/palette.ts +4 -1
package/dist/charts/Sparkline.js
CHANGED
|
@@ -2,6 +2,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { dot } from "@tanstack/charts/dot";
|
|
3
3
|
import { decorative } from "@tanstack/charts/mark/decorative";
|
|
4
4
|
import { lineY } from "@tanstack/charts/line";
|
|
5
|
+
import { rect } from "@tanstack/charts/rect";
|
|
5
6
|
import { ruleY } from "@tanstack/charts/rule";
|
|
6
7
|
import { scaleBand } from "@tanstack/charts/scales/band";
|
|
7
8
|
import { scaleLinear } from "@tanstack/charts/scales/linear";
|
|
@@ -27,6 +28,10 @@ const READOUT_GAP = 8;
|
|
|
27
28
|
const LINE_INSET = 3;
|
|
28
29
|
const SHORT_BOX = 36;
|
|
29
30
|
const MUTED_LINE = alpha(VX.muted, 0.35);
|
|
31
|
+
const ZONE_X = {
|
|
32
|
+
zx: { channel: "x", scale: scaleLinear().domain([0, 1]), axis: false }
|
|
33
|
+
};
|
|
34
|
+
const BAND_FILL = alpha(VX.neutral, 0.2);
|
|
30
35
|
const REFERENCE_LABEL_DX = 3;
|
|
31
36
|
const LINE_PX_PER_POINT = 1;
|
|
32
37
|
const BAR_PX_PER_BAR = 2;
|
|
@@ -124,44 +129,67 @@ function poolSparkline(rows, width, mark) {
|
|
|
124
129
|
if (width <= 0 || rows.length <= Math.max(cap, mark === "bar" ? 1 : 2)) return rows;
|
|
125
130
|
return mark === "bar" ? poolBar(rows, cap) : poolLine(rows, cap);
|
|
126
131
|
}
|
|
127
|
-
function frameOf([lo, hi], mark, count, hasEnd) {
|
|
132
|
+
function frameOf([lo, hi], mark, count, hasEnd, banded = false) {
|
|
128
133
|
if (mark === "bar") return { x: [0, count], y: [Math.min(lo, 0), Math.max(hi, 0) || 1] };
|
|
129
|
-
const pad = (hi - lo) * 0.1 || 1;
|
|
134
|
+
const pad = (hi - lo) * (banded ? 0.25 : 0.1) || 1;
|
|
130
135
|
const xPad = hasEnd ? (count - 1) * 0.04 || 0.5 : 0;
|
|
131
136
|
return { x: [-xPad, Math.max(count - 1, 1) + xPad], y: [lo - pad, hi + pad] };
|
|
132
137
|
}
|
|
133
|
-
function compileSparkline(source, extentOf, mark, color, emphasisColor, reference, referenceLabel) {
|
|
134
|
-
const frame = frameOf(extentOf, mark, source.length, emphasisColor !== null);
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
y: (v) => v,
|
|
149
|
-
text: () => referenceLabel,
|
|
150
|
-
fill: VX.ink2,
|
|
151
|
-
fontSize: VX.text.micro,
|
|
152
|
-
anchor: "start",
|
|
153
|
-
dx: REFERENCE_LABEL_DX,
|
|
154
|
-
dy: referenceLabelPlacement({
|
|
155
|
-
value: reference,
|
|
156
|
-
domain: frame.y,
|
|
157
|
-
height,
|
|
158
|
-
inset: mark === "bar" ? 0 : LINE_INSET,
|
|
159
|
-
fontSize: VX.text.micro
|
|
160
|
-
}).dy
|
|
161
|
-
})
|
|
162
|
-
)
|
|
163
|
-
]
|
|
138
|
+
function compileSparkline(source, extentOf, mark, color, emphasisColor, reference, referenceLabel, band, bandEdges) {
|
|
139
|
+
const frame = frameOf(extentOf, mark, source.length, emphasisColor !== null, bandEdges);
|
|
140
|
+
const bandMark = () => band === null ? [] : [
|
|
141
|
+
decorative(
|
|
142
|
+
rect([band], {
|
|
143
|
+
id: "band",
|
|
144
|
+
x1: () => 0,
|
|
145
|
+
x2: () => 1,
|
|
146
|
+
xScale: "zx",
|
|
147
|
+
y1: "from",
|
|
148
|
+
y2: "to",
|
|
149
|
+
fill: BAND_FILL,
|
|
150
|
+
inset: 0
|
|
151
|
+
})
|
|
152
|
+
)
|
|
164
153
|
];
|
|
154
|
+
const referenceMark = (height, width, rows) => {
|
|
155
|
+
if (reference === null) return [];
|
|
156
|
+
const place = referenceLabel === void 0 ? null : referenceLabelPlacement({
|
|
157
|
+
value: reference,
|
|
158
|
+
domain: frame.y,
|
|
159
|
+
height,
|
|
160
|
+
width,
|
|
161
|
+
inset: mark === "bar" ? 0 : LINE_INSET,
|
|
162
|
+
fontSize: VX.text.micro,
|
|
163
|
+
label: referenceLabel,
|
|
164
|
+
line: mark === "bar" ? void 0 : rows.flatMap(
|
|
165
|
+
(r) => r.v === null ? [] : [{ fx: (r.i - frame.x[0]) / (frame.x[1] - frame.x[0]), y: r.v }]
|
|
166
|
+
)
|
|
167
|
+
});
|
|
168
|
+
return [
|
|
169
|
+
ruleY([reference], {
|
|
170
|
+
id: "reference",
|
|
171
|
+
stroke: VX.line,
|
|
172
|
+
strokeOpacity: 1,
|
|
173
|
+
strokeWidth: 1,
|
|
174
|
+
strokeDasharray: DASH
|
|
175
|
+
}),
|
|
176
|
+
...referenceLabel === void 0 || place === null ? [] : [
|
|
177
|
+
decorative(
|
|
178
|
+
text([reference], {
|
|
179
|
+
id: "reference-label",
|
|
180
|
+
x: () => place.end === "end" ? frame.x[1] : mark === "bar" ? 0 : frame.x[0],
|
|
181
|
+
y: (v) => v,
|
|
182
|
+
text: () => referenceLabel,
|
|
183
|
+
fill: VX.ink2,
|
|
184
|
+
fontSize: VX.text.micro,
|
|
185
|
+
anchor: place.end,
|
|
186
|
+
dx: place.end === "end" ? -REFERENCE_LABEL_DX : REFERENCE_LABEL_DX,
|
|
187
|
+
dy: place.dy
|
|
188
|
+
})
|
|
189
|
+
)
|
|
190
|
+
]
|
|
191
|
+
];
|
|
192
|
+
};
|
|
165
193
|
return {
|
|
166
194
|
// A bar's hover is the bar and the readout chip: no engine point marker (bar chrome only, as
|
|
167
195
|
// `Bars`).
|
|
@@ -172,7 +200,8 @@ function compileSparkline(source, extentOf, mark, color, emphasisColor, referenc
|
|
|
172
200
|
if (mark === "bar") {
|
|
173
201
|
return {
|
|
174
202
|
marks: [
|
|
175
|
-
...
|
|
203
|
+
...bandMark(),
|
|
204
|
+
...referenceMark(height, width, rows),
|
|
176
205
|
barMark(rows, {
|
|
177
206
|
id: "bars",
|
|
178
207
|
x: "i",
|
|
@@ -185,6 +214,8 @@ function compileSparkline(source, extentOf, mark, color, emphasisColor, referenc
|
|
|
185
214
|
scale: scaleBand().domain(rows.map((r) => r.i)).padding(BAR_GAP),
|
|
186
215
|
axis: false
|
|
187
216
|
},
|
|
217
|
+
// The band spans the whole plot, outer half-bars included: a unit scale, not the band x.
|
|
218
|
+
...ZONE_X,
|
|
188
219
|
y: {
|
|
189
220
|
scale: scaleLinear().domain(frame.y),
|
|
190
221
|
axis: false
|
|
@@ -197,7 +228,8 @@ function compileSparkline(source, extentOf, mark, color, emphasisColor, referenc
|
|
|
197
228
|
}
|
|
198
229
|
return {
|
|
199
230
|
marks: [
|
|
200
|
-
...
|
|
231
|
+
...bandMark(),
|
|
232
|
+
...referenceMark(height, width, rows),
|
|
201
233
|
lineY(rows, {
|
|
202
234
|
id: "line",
|
|
203
235
|
x: "i",
|
|
@@ -217,6 +249,7 @@ function compileSparkline(source, extentOf, mark, color, emphasisColor, referenc
|
|
|
217
249
|
scale: scaleLinear().domain(frame.x),
|
|
218
250
|
axis: false
|
|
219
251
|
},
|
|
252
|
+
...ZONE_X,
|
|
220
253
|
y: { scale: scaleLinear().domain(frame.y), axis: false }
|
|
221
254
|
},
|
|
222
255
|
theme: CHART_THEME,
|
|
@@ -369,6 +402,7 @@ function Sparkline(props) {
|
|
|
369
402
|
state,
|
|
370
403
|
reference,
|
|
371
404
|
referenceLabel,
|
|
405
|
+
band,
|
|
372
406
|
format = defaultNumberFormat,
|
|
373
407
|
labels,
|
|
374
408
|
className,
|
|
@@ -380,6 +414,8 @@ function Sparkline(props) {
|
|
|
380
414
|
const [keyed, setKeyed] = useState(null);
|
|
381
415
|
const active = hover ?? keyed;
|
|
382
416
|
const readoutRef = useRef(null);
|
|
417
|
+
const bandFrom = band?.from;
|
|
418
|
+
const bandTo = band?.to;
|
|
383
419
|
const model = useMemo(() => {
|
|
384
420
|
const rows2 = data.map((d, i) => ({
|
|
385
421
|
i,
|
|
@@ -389,15 +425,33 @@ function Sparkline(props) {
|
|
|
389
425
|
if (range === null) return null;
|
|
390
426
|
const at2 = reference === "mean" ? meanOf(rows2) : reference ?? null;
|
|
391
427
|
const ref = at2 !== null && Number.isFinite(at2) ? at2 : null;
|
|
392
|
-
const
|
|
428
|
+
const bandSpan = bandFrom !== void 0 && bandTo !== void 0 && Number.isFinite(bandFrom + bandTo) && bandFrom !== bandTo ? { from: Math.min(bandFrom, bandTo), to: Math.max(bandFrom, bandTo) } : null;
|
|
429
|
+
const edges = [ref, bandSpan?.from, bandSpan?.to].filter(
|
|
430
|
+
(v) => typeof v === "number"
|
|
431
|
+
);
|
|
432
|
+
const full = [
|
|
433
|
+
Math.min(range[0], ...edges),
|
|
434
|
+
Math.max(range[1], ...edges)
|
|
435
|
+
];
|
|
393
436
|
const end = emphasizeLast ? emphasisColor : null;
|
|
437
|
+
const bandEdges = full[0] < range[0] || full[1] > range[1];
|
|
394
438
|
return {
|
|
395
439
|
rows: rows2,
|
|
396
440
|
moments: momentsOf(data),
|
|
397
|
-
frame: frameOf(full, mark, rows2.length, end !== null),
|
|
398
|
-
definition: compileSparkline(
|
|
441
|
+
frame: frameOf(full, mark, rows2.length, end !== null, bandSpan !== null && bandEdges),
|
|
442
|
+
definition: compileSparkline(
|
|
443
|
+
rows2,
|
|
444
|
+
full,
|
|
445
|
+
mark,
|
|
446
|
+
color,
|
|
447
|
+
end,
|
|
448
|
+
ref,
|
|
449
|
+
referenceLabel,
|
|
450
|
+
bandSpan,
|
|
451
|
+
bandSpan !== null && bandEdges
|
|
452
|
+
)
|
|
399
453
|
};
|
|
400
|
-
}, [data, mark, color, emphasizeLast, emphasisColor, reference, referenceLabel]);
|
|
454
|
+
}, [data, mark, color, emphasizeLast, emphasisColor, reference, referenceLabel, bandFrom, bandTo]);
|
|
401
455
|
const resolved = resolveChartState(state);
|
|
402
456
|
const rows = model?.rows;
|
|
403
457
|
const interactive = resolved === null && model !== null;
|
|
@@ -478,6 +532,7 @@ function Sparkline(props) {
|
|
|
478
532
|
{
|
|
479
533
|
"data-basalt-sparkline": "",
|
|
480
534
|
...hosted && { "data-basalt-hosted": "" },
|
|
535
|
+
...shown && { "data-basalt-readout": "" },
|
|
481
536
|
role: "presentation",
|
|
482
537
|
className: cx(classes.root, className),
|
|
483
538
|
style: { width: width ?? "100%", height, minWidth: 0, ...style },
|
|
@@ -490,7 +545,15 @@ function Sparkline(props) {
|
|
|
490
545
|
setKeyed(null);
|
|
491
546
|
},
|
|
492
547
|
children: [
|
|
493
|
-
resolved !== null && /* @__PURE__ */ jsx(
|
|
548
|
+
resolved !== null && /* @__PURE__ */ jsx(
|
|
549
|
+
ChartPlaceholder,
|
|
550
|
+
{
|
|
551
|
+
state,
|
|
552
|
+
height,
|
|
553
|
+
compact: true,
|
|
554
|
+
ghost: mark === "bar" ? "bars" : "line"
|
|
555
|
+
}
|
|
556
|
+
),
|
|
494
557
|
resolved === null && model !== null && /* @__PURE__ */ jsx(
|
|
495
558
|
ChartEngine,
|
|
496
559
|
{
|
|
@@ -501,7 +564,7 @@ function Sparkline(props) {
|
|
|
501
564
|
coarse: false
|
|
502
565
|
}
|
|
503
566
|
),
|
|
504
|
-
at !== null && // One layer on the plot rect (inside a line's margin): the dot and the readout take their
|
|
567
|
+
shown && at !== null && // One layer on the plot rect (inside a line's margin): the dot and the readout take their
|
|
505
568
|
// fractions of the same box, so both land where the mark did. A bar has no dot: the bar
|
|
506
569
|
// is the marker.
|
|
507
570
|
/* @__PURE__ */ jsxs("span", { "aria-hidden": "true", className: classes.layer, style: layerStyle, children: [
|
|
@@ -125,6 +125,16 @@
|
|
|
125
125
|
stroke-linejoin: round;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
.ghostBand {
|
|
129
|
+
flex: 1 1 0;
|
|
130
|
+
min-width: 0;
|
|
131
|
+
align-self: stretch;
|
|
132
|
+
/* The loaded strip is one row above its axis labels: the row keeps their room. */
|
|
133
|
+
margin-bottom: var(--basalt-ghost-band-axis, 1.5rem);
|
|
134
|
+
border-radius: 3px;
|
|
135
|
+
background: color-mix(in srgb, var(--vx-ink) 18%, var(--vx-surface-panel));
|
|
136
|
+
}
|
|
137
|
+
|
|
128
138
|
.ghostBar {
|
|
129
139
|
flex: 1 1 0;
|
|
130
140
|
min-width: 0;
|
|
@@ -132,6 +142,46 @@
|
|
|
132
142
|
background: color-mix(in srgb, var(--vx-ink) 18%, var(--vx-surface-panel));
|
|
133
143
|
}
|
|
134
144
|
|
|
145
|
+
/*
|
|
146
|
+
* The empty body (SPEC § 6.11): a ring-edged tile (one inset ring, set inline in `state.tsx` so the divider ledger does not read it as a rule; card radius) filling the chart's
|
|
147
|
+
* own box, so the D37 height holds, with its copy centred: the title at `sm` 500, the size of the
|
|
148
|
+
* host's own title in every chart host, and one muted line. `EmptyState`'s section anatomy, in plain CSS
|
|
149
|
+
* because `src/charts/**` is Mantine-free.
|
|
150
|
+
*/
|
|
151
|
+
.emptyTile {
|
|
152
|
+
box-sizing: border-box;
|
|
153
|
+
display: flex;
|
|
154
|
+
flex-direction: column;
|
|
155
|
+
align-items: center;
|
|
156
|
+
justify-content: center;
|
|
157
|
+
gap: var(--vx-space-stack-xs, 0.25rem);
|
|
158
|
+
width: 100%;
|
|
159
|
+
height: 100%;
|
|
160
|
+
padding: var(--vx-space-stack-md) var(--vx-space-stack-lg);
|
|
161
|
+
overflow: hidden;
|
|
162
|
+
text-align: center;
|
|
163
|
+
border-radius: var(--vx-radius-card);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.emptyCopy {
|
|
167
|
+
display: flex;
|
|
168
|
+
flex-direction: column;
|
|
169
|
+
align-items: center;
|
|
170
|
+
gap: var(--vx-space-stack-xs, 0.25rem);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.emptyTitle {
|
|
174
|
+
font-size: var(--vx-text-sm);
|
|
175
|
+
font-weight: 500;
|
|
176
|
+
color: var(--vx-ink);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.emptyText {
|
|
180
|
+
max-width: 22.5rem;
|
|
181
|
+
font-size: var(--vx-text-sm);
|
|
182
|
+
color: var(--vx-muted);
|
|
183
|
+
}
|
|
184
|
+
|
|
135
185
|
/*
|
|
136
186
|
* The engine paints its tooltip rows as a grid of `.55rem | minmax(0, 1fr) | auto` with inline
|
|
137
187
|
* styles and `overflow-wrap: anywhere` on the card, so a narrow tooltip (a 390 viewport, a pointer
|
|
@@ -167,6 +217,14 @@
|
|
|
167
217
|
var(--vx-surface-elevated) !important;
|
|
168
218
|
}
|
|
169
219
|
|
|
220
|
+
/* The engine focuses the plot's `svg.ts-chart` (tabindex 0), not the `.basalt-chart` wrapper
|
|
221
|
+
* `styles.css` rings, so the UA's `auto` ring paints (a 5px white double ring in dark): the same
|
|
222
|
+
* 2px accent ring at the same offset, which the slotted chip clears (`SLOT_RING_CLEARANCE`). */
|
|
223
|
+
:global(.basalt-chart .ts-chart:focus-visible) {
|
|
224
|
+
outline: 2px solid var(--vx-accent);
|
|
225
|
+
outline-offset: calc(0.125rem * var(--mantine-scale));
|
|
226
|
+
}
|
|
227
|
+
|
|
170
228
|
/*
|
|
171
229
|
* A slotted `Bars` (`data-basalt-slot`, set by `compile.ts`) is a micro-visual: its tooltip is the
|
|
172
230
|
* Sparkline's one-line chip, `<value> · <x label>` in the line the host reserves above the plot. The
|
|
@@ -179,15 +237,15 @@
|
|
|
179
237
|
align-items: center;
|
|
180
238
|
box-sizing: border-box;
|
|
181
239
|
width: max-content;
|
|
182
|
-
/* The line the cell reserves (1.125rem) less the focus ring's clearance (2px outline + 0.125rem offset), so
|
|
240
|
+
/* The line the cell reserves (1.125rem) less the focus ring's clearance (2px outline + 0.125rem offset) and 1px of air, so
|
|
183
241
|
* the chip sits clear of the ring and still inside the reserve. */
|
|
184
|
-
block-size: calc(1.125rem - 0.
|
|
242
|
+
block-size: calc(1.125rem - 0.3125rem);
|
|
185
243
|
padding: 0 4px !important;
|
|
186
244
|
overflow: hidden;
|
|
187
245
|
font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
|
|
188
246
|
font-variant-numeric: lining-nums;
|
|
189
247
|
font-size: var(--vx-text-xs);
|
|
190
|
-
line-height: calc(1.125rem - 0.
|
|
248
|
+
line-height: calc(1.125rem - 0.3125rem - 2px);
|
|
191
249
|
white-space: nowrap !important;
|
|
192
250
|
border-radius: var(--vx-radius-ctrl) !important;
|
|
193
251
|
/* theme-allow css-raw-surface — the chip is flat, like the Sparkline's, not a floating panel */
|
|
@@ -213,6 +271,14 @@
|
|
|
213
271
|
display: none;
|
|
214
272
|
}
|
|
215
273
|
|
|
274
|
+
/* The engine's series swatch is a block above the figure: it stacks the row taller than the chip and the
|
|
275
|
+
* figure's lower half falls under the chip's `overflow: hidden`. `!important`: the engine sets the
|
|
276
|
+
* swatch's `display` with a rule this one cannot out-rank by specificity alone (measured: the swatch
|
|
277
|
+
* stayed `block` under a plain selector). */
|
|
278
|
+
:global(.ts-chart-tooltip[data-basalt-slot] .ts-chart-tooltip__swatch) {
|
|
279
|
+
display: none !important;
|
|
280
|
+
}
|
|
281
|
+
|
|
216
282
|
:global(.ts-chart-tooltip[data-basalt-slot] .ts-chart-tooltip__title) {
|
|
217
283
|
display: block !important;
|
|
218
284
|
flex: 0 1 auto;
|
|
@@ -11,6 +11,11 @@ declare const classes: {
|
|
|
11
11
|
readonly grow: string
|
|
12
12
|
readonly ghost: string
|
|
13
13
|
readonly ghostLine: string
|
|
14
|
+
readonly ghostBand: string
|
|
14
15
|
readonly ghostBar: string
|
|
16
|
+
readonly emptyTile: string
|
|
17
|
+
readonly emptyCopy: string
|
|
18
|
+
readonly emptyTitle: string
|
|
19
|
+
readonly emptyText: string
|
|
15
20
|
}
|
|
16
21
|
export default classes
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* ChartCard's header inset, by the card's own inline size (W10 SSR contract). A card under 480px
|
|
3
|
-
* trims the header's top inset: the
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* is CONTAINER_CLASSES.regular (`breakpoint-literals.test.ts`).
|
|
3
|
+
* trims the header's top inset: the chart below is sized by the 160–420px law, so a narrow card is
|
|
4
|
+
* a short one. Decided in CSS, not from a post-hydration height measurement, so the server HTML is
|
|
5
|
+
* the hydrated header. The literal is CONTAINER_CLASSES.regular (`breakpoint-literals.test.ts`).
|
|
7
6
|
*/
|
|
8
7
|
|
|
9
8
|
.header {
|
|
@@ -129,3 +128,12 @@
|
|
|
129
128
|
border-radius: 3px;
|
|
130
129
|
background: color-mix(in srgb, var(--vx-ink) 18%, var(--vx-surface-panel));
|
|
131
130
|
}
|
|
131
|
+
|
|
132
|
+
/* A pending `BandStrip` card keeps the room of the legend row the loaded strip carries under its box:
|
|
133
|
+
* the chart root's 6px gap plus one legend line (`micro` x 1.35 and the 2px entry border, `legend.tsx`).
|
|
134
|
+
* The legend shows from 240px, the same container class the chart picks it by. */
|
|
135
|
+
@container basalt-card (min-width: 240px) {
|
|
136
|
+
.legendReserve {
|
|
137
|
+
padding-bottom: calc(6px + var(--vx-text-micro) * 1.35 + 2px);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/charts/compile.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAEV,iCAAiC,EAClC,MAAM,iCAAiC,CAAA;AACxC,OAAO,KAAK,EAGV,aAAa,EAEb,yBAAyB,EACzB,eAAe,IAAI,gBAAgB,EACnC,UAAU,EACV,yBAAyB,EAE1B,MAAM,6BAA6B,CAAA;AAIpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/charts/compile.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAEV,iCAAiC,EAClC,MAAM,iCAAiC,CAAA;AACxC,OAAO,KAAK,EAGV,aAAa,EAEb,yBAAyB,EACzB,eAAe,IAAI,gBAAgB,EACnC,UAAU,EACV,yBAAyB,EAE1B,MAAM,6BAA6B,CAAA;AAIpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAQ5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAG/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAE3C,OAAO,KAAK,EACV,UAAU,EACV,mBAAmB,EAEnB,WAAW,EACX,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,EAAE,OAAO,CAAC,CA6BvD;AAED,+FAA+F;AAC/F,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,KAAG,MAAgC,CAAA;AAE/E,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,aAAa,CAYxE;AAKD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,SAAS,QAAQ,EAAE,EAC1B,MAAM,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,GACjC,aAAa,GAAG,IAAI,CAuBtB;AA6aD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAO9D;AAkID;;;;;GAKG;AACH;qGACqG;AACrG,KAAK,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;AA2BxC;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,WAAW,EAChB,MAAM,EAAE,OAAO,EACf,GAAG,EAAE,iCAAiC,EACtC,IAAI,GAAE,OAAgB,GACrB,IAAI,CA4EN;AA0ED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,EAClD,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,GAC1B,mBAAmB,CA2HrB"}
|
package/dist/charts/compile.js
CHANGED
|
@@ -15,6 +15,7 @@ import { cursorBinding, followerOptions, quietWhileFollowing } from "./cursor.js
|
|
|
15
15
|
import { cursorDots } from "./marks.js";
|
|
16
16
|
import { bucketTicks, strideEvery } from "./ticks.js";
|
|
17
17
|
import { MAIN_PANE, plotAccess, plotContext } from "./plot-context.js";
|
|
18
|
+
import { claimedLabelBoxes } from "./labels.js";
|
|
18
19
|
import { refLabelPosition } from "./ref-label.js";
|
|
19
20
|
import { resolveContainerClass } from "../tokens/size-classes.js";
|
|
20
21
|
import { resolveYDomain, xScaleFor, xZoneFractions, yScaleFor } from "./scales.js";
|
|
@@ -454,7 +455,8 @@ const refLabelMark = (r, i, ctx) => {
|
|
|
454
455
|
plotHeight: ctx.plotHeight,
|
|
455
456
|
label: r.label ?? "",
|
|
456
457
|
fontSize: VX.text.micro,
|
|
457
|
-
series: ctx.lines(r.axis)
|
|
458
|
+
series: ctx.lines(r.axis),
|
|
459
|
+
claimed: startFirst ? [] : ctx.claimed
|
|
458
460
|
});
|
|
459
461
|
const atStart = position.startsWith("start");
|
|
460
462
|
return decorative(
|
|
@@ -607,7 +609,7 @@ const slotAnchor = (points, { plot }) => {
|
|
|
607
609
|
return { x: (Math.min(...xs) + Math.max(...xs)) / 2, y: plot.y };
|
|
608
610
|
};
|
|
609
611
|
const SLOT_TOOLTIP_PLACEMENT = ["top"];
|
|
610
|
-
const SLOT_RING_CLEARANCE = 2 + 2;
|
|
612
|
+
const SLOT_RING_CLEARANCE = 2 + 2 + 1;
|
|
611
613
|
const TIP_CHROME = 30;
|
|
612
614
|
const TIP_ROW = 18;
|
|
613
615
|
const TIP_TOP_AIR = 4;
|
|
@@ -800,24 +802,23 @@ function compileCartesian(input) {
|
|
|
800
802
|
const cls = resolveContainerClass(width);
|
|
801
803
|
const axes = axesAt(cls);
|
|
802
804
|
const access = plotAccess(definition, input.plot, MAIN_PANE);
|
|
803
|
-
const
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
access
|
|
819
|
-
)
|
|
805
|
+
const plot = plotContext(
|
|
806
|
+
{
|
|
807
|
+
rows,
|
|
808
|
+
visible,
|
|
809
|
+
highlighted: input.highlighted ?? null,
|
|
810
|
+
containerClass: cls,
|
|
811
|
+
width,
|
|
812
|
+
height,
|
|
813
|
+
data: input.data,
|
|
814
|
+
xFraction: model.fraction,
|
|
815
|
+
y2: axes.right ? "y2" : void 0,
|
|
816
|
+
yDomain: axes.left.domain,
|
|
817
|
+
y2Domain: axes.right?.domain
|
|
818
|
+
},
|
|
819
|
+
access
|
|
820
820
|
);
|
|
821
|
+
const kindMarks = input.marks(plot);
|
|
821
822
|
const under = underlayMarks(input, model, axes);
|
|
822
823
|
const over = refLineMarks(input, axes, () => {
|
|
823
824
|
access.read();
|
|
@@ -826,6 +827,7 @@ function compileCartesian(input) {
|
|
|
826
827
|
plotWidth: size?.width ?? width,
|
|
827
828
|
plotHeight: size?.height ?? height,
|
|
828
829
|
lines: linesOn,
|
|
830
|
+
claimed: claimedLabelBoxes(plot),
|
|
829
831
|
axes,
|
|
830
832
|
model
|
|
831
833
|
};
|
package/dist/charts/labels.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LabelBox } from './ref-label.js';
|
|
1
2
|
import type { ChartMarks, ChartSeries, ChartX, PlotContext, PlotRow } from './types.js';
|
|
2
3
|
export type EndLabelAnchor = 'start' | 'end';
|
|
3
4
|
/** Which side of its line a flipped label sits: away from the line's last segment. */
|
|
@@ -23,13 +24,20 @@ export type EndLabel<T, X extends ChartX> = {
|
|
|
23
24
|
anchor: EndLabelAnchor;
|
|
24
25
|
/** Only a flipped label (left of its point) can meet its own line; it takes the clear side. */
|
|
25
26
|
side: EndLabelSide;
|
|
26
|
-
/** A vertical shift in px (negative is up) that keeps this label clear of its neighbours. */
|
|
27
|
+
/** A vertical shift in px (negative is up) that keeps this label clear of its neighbours and the lines. */
|
|
27
28
|
nudge: number;
|
|
29
|
+
/** The room the drawn label takes, for a reference caption to keep clear of. */
|
|
30
|
+
box: LabelBox;
|
|
28
31
|
};
|
|
32
|
+
/** Records the boxes the end labels of `plot` take (once per plot, by `Lines`). */
|
|
33
|
+
export declare function claimLabelBoxes(plot: object, boxes: readonly LabelBox[]): void;
|
|
34
|
+
/** The boxes {@link claimLabelBoxes} recorded for `plot`: what a reference caption avoids. */
|
|
35
|
+
export declare function claimedLabelBoxes(plot: object): readonly LabelBox[];
|
|
29
36
|
/**
|
|
30
37
|
* Pushes labels apart: `ys` are the labels' heights in px from the plot's bottom, returned as the
|
|
31
38
|
* shift each needs (positive is up) so no two sit closer than {@link END_LABEL_MIN_GAP} and the
|
|
32
|
-
* lowest and the topmost stay {@link END_LABEL_EDGE} inside the plot
|
|
39
|
+
* lowest and the topmost stay {@link END_LABEL_EDGE} inside the plot; a stack too tall for the plot
|
|
40
|
+
* shrinks its gap to fit. Order is kept.
|
|
33
41
|
*/
|
|
34
42
|
export declare function spreadLabels(ys: readonly number[], plotHeight: number): number[];
|
|
35
43
|
/**
|
|
@@ -39,7 +47,9 @@ export declare function spreadLabels(ys: readonly number[], plotHeight: number):
|
|
|
39
47
|
* dropped. A series whose last point the plot's own x scale cannot place, or places outside the plot
|
|
40
48
|
* (`plot.xFraction` outside [0, 1]: clipped by a narrower `xDomain`), has no label.
|
|
41
49
|
*/
|
|
42
|
-
export declare function endLabelPlan<T, X extends ChartX>(plot: PlotContext<T, X>, lines: readonly ChartSeries<T>[], naming?: LinesNaming
|
|
50
|
+
export declare function endLabelPlan<T, X extends ChartX>(plot: PlotContext<T, X>, lines: readonly ChartSeries<T>[], naming?: LinesNaming,
|
|
51
|
+
/** The values of the reference lines on the left axis: rules a label must not sit on. */
|
|
52
|
+
rules?: readonly number[]): EndLabel<T, X>[];
|
|
43
53
|
/** The offset of a label from its point: right of it, level; or left of it, above or below. */
|
|
44
54
|
export declare function endLabelOffset(anchor: EndLabelAnchor, side?: EndLabelSide): {
|
|
45
55
|
dx: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"labels.d.ts","sourceRoot":"","sources":["../../src/charts/labels.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"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