@carto/ps-react-ui 4.11.3 → 4.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat.js +962 -733
- package/dist/chat.js.map +1 -1
- package/dist/csv-item-hH_Gt7ur.js +32 -0
- package/dist/csv-item-hH_Gt7ur.js.map +1 -0
- package/dist/{echart-BMPpj7n_.js → echart-Bdvbfx9s.js} +2 -2
- package/dist/echart-Bdvbfx9s.js.map +1 -0
- package/dist/{option-builders-F-c9ELi1.js → option-builders-DPeoyQaM.js} +41 -33
- package/dist/option-builders-DPeoyQaM.js.map +1 -0
- package/dist/png-item-9dNbB37T.js +57 -0
- package/dist/png-item-9dNbB37T.js.map +1 -0
- package/dist/table-B3ZWWhJt.js +383 -0
- package/dist/table-B3ZWWhJt.js.map +1 -0
- package/dist/types/chat/containers/chat-footer.d.ts +1 -1
- package/dist/types/chat/containers/styles.d.ts +79 -12
- package/dist/types/chat/index.d.ts +1 -1
- package/dist/types/chat/types.d.ts +21 -0
- package/dist/types/chat/use-typewriter.d.ts +5 -3
- package/dist/types/widgets/utils/chart-config/index.d.ts +1 -1
- package/dist/types/widgets-v2/actions/download/constants.d.ts +12 -0
- package/dist/types/widgets-v2/actions/download/csv-item.d.ts +38 -0
- package/dist/types/widgets-v2/actions/download/icons.d.ts +6 -0
- package/dist/types/widgets-v2/actions/download/index.d.ts +3 -1
- package/dist/types/widgets-v2/actions/index.d.ts +1 -1
- package/dist/types/widgets-v2/pie/skeleton.d.ts +9 -0
- package/dist/widgets/bar.js +1 -1
- package/dist/widgets/histogram.js +1 -1
- package/dist/widgets/pie.js +1 -1
- package/dist/widgets/scatterplot.js +5 -5
- package/dist/widgets/timeseries.js +1 -1
- package/dist/widgets/utils.js +1 -1
- package/dist/widgets-v2/actions.js +40 -36
- package/dist/widgets-v2/actions.js.map +1 -1
- package/dist/widgets-v2/bar.js +69 -76
- package/dist/widgets-v2/bar.js.map +1 -1
- package/dist/widgets-v2/category.js +50 -55
- package/dist/widgets-v2/category.js.map +1 -1
- package/dist/widgets-v2/echart.js +1 -1
- package/dist/widgets-v2/formula.js +37 -43
- package/dist/widgets-v2/formula.js.map +1 -1
- package/dist/widgets-v2/histogram.js +141 -147
- package/dist/widgets-v2/histogram.js.map +1 -1
- package/dist/widgets-v2/markdown.js +18 -17
- package/dist/widgets-v2/markdown.js.map +1 -1
- package/dist/widgets-v2/pie.js +174 -126
- package/dist/widgets-v2/pie.js.map +1 -1
- package/dist/widgets-v2/scatterplot.js +156 -166
- package/dist/widgets-v2/scatterplot.js.map +1 -1
- package/dist/widgets-v2/spread.js +36 -41
- package/dist/widgets-v2/spread.js.map +1 -1
- package/dist/widgets-v2/table.js +46 -55
- package/dist/widgets-v2/table.js.map +1 -1
- package/dist/widgets-v2/timeseries.js +83 -89
- package/dist/widgets-v2/timeseries.js.map +1 -1
- package/dist/widgets-v2.js +3 -3
- package/package.json +1 -1
- package/src/chat/bubbles/styles.ts +5 -1
- package/src/chat/containers/chat-content.tsx +4 -1
- package/src/chat/containers/chat-footer.test.tsx +59 -0
- package/src/chat/containers/chat-footer.tsx +124 -36
- package/src/chat/containers/styles.ts +107 -16
- package/src/chat/feedback/styles.ts +11 -4
- package/src/chat/index.ts +1 -0
- package/src/chat/types.ts +22 -0
- package/src/chat/use-typewriter.ts +32 -24
- package/src/widgets/utils/chart-config/index.ts +1 -0
- package/src/widgets/utils/chart-config/option-builders.test.ts +34 -0
- package/src/widgets/utils/chart-config/option-builders.ts +21 -0
- package/src/widgets-v2/actions/download/constants.ts +14 -0
- package/src/widgets-v2/actions/download/csv-item.test.tsx +77 -0
- package/src/widgets-v2/actions/download/csv-item.tsx +71 -0
- package/src/widgets-v2/actions/download/icons.tsx +10 -1
- package/src/widgets-v2/actions/download/index.ts +3 -1
- package/src/widgets-v2/actions/download/png-item.tsx +2 -1
- package/src/widgets-v2/actions/index.ts +5 -0
- package/src/widgets-v2/bar/download.tsx +16 -22
- package/src/widgets-v2/bar/options.ts +3 -2
- package/src/widgets-v2/category/download.test.ts +9 -0
- package/src/widgets-v2/category/download.ts +16 -20
- package/src/widgets-v2/echart/edge-label-clamp.ts +7 -4
- package/src/widgets-v2/formula/download.tsx +23 -29
- package/src/widgets-v2/histogram/download.ts +22 -26
- package/src/widgets-v2/histogram/options.ts +3 -2
- package/src/widgets-v2/markdown/{download.ts → download.tsx} +5 -2
- package/src/widgets-v2/pie/download.ts +16 -20
- package/src/widgets-v2/pie/skeleton.test.tsx +6 -3
- package/src/widgets-v2/pie/skeleton.tsx +69 -7
- package/src/widgets-v2/scatterplot/download.ts +16 -20
- package/src/widgets-v2/scatterplot/options.ts +3 -6
- package/src/widgets-v2/spread/download.ts +23 -27
- package/src/widgets-v2/table/download.test.ts +10 -0
- package/src/widgets-v2/table/download.ts +11 -15
- package/src/widgets-v2/table/helpers.test.ts +19 -0
- package/src/widgets-v2/table/helpers.ts +7 -12
- package/src/widgets-v2/timeseries/download.ts +36 -40
- package/src/widgets-v2/timeseries/options.ts +3 -2
- package/dist/echart-BMPpj7n_.js.map +0 -1
- package/dist/option-builders-F-c9ELi1.js.map +0 -1
- package/dist/png-item-BE9uEqlD.js +0 -45
- package/dist/png-item-BE9uEqlD.js.map +0 -1
- package/dist/table-C9IMbTr0.js +0 -385
- package/dist/table-C9IMbTr0.js.map +0 -1
- package/dist/types/chat/feedback/styles.d.ts +0 -211
- package/dist/types/widgets/utils/chart-config/option-builders.d.ts +0 -124
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { n as A, d as
|
|
3
|
-
import { jsxs as O, jsx as
|
|
4
|
-
import { c as
|
|
1
|
+
import * as R from "echarts";
|
|
2
|
+
import { n as A, h as _, d as z, g as Y, c as q, f as H } from "../option-builders-DPeoyQaM.js";
|
|
3
|
+
import { jsxs as O, jsx as d } from "react/jsx-runtime";
|
|
4
|
+
import { c as U } from "react/compiler-runtime";
|
|
5
5
|
import { Box as S, Skeleton as b } from "@mui/material";
|
|
6
6
|
import "../widget-store-Bw5zRUGg.js";
|
|
7
7
|
import "zustand/shallow";
|
|
@@ -21,11 +21,11 @@ import "zustand/vanilla";
|
|
|
21
21
|
import "zustand/middleware";
|
|
22
22
|
import "zustand/react/shallow";
|
|
23
23
|
import { Z as B } from "../transforms-Cdx4fkU5.js";
|
|
24
|
-
import { m as
|
|
25
|
-
import { p as
|
|
26
|
-
import {
|
|
27
|
-
import { b as
|
|
28
|
-
function
|
|
24
|
+
import { m as V, r as W } from "../resolve-theme-color-BdojIw0K.js";
|
|
25
|
+
import { p as J } from "../data-zoom-layout-CkVnm6ej.js";
|
|
26
|
+
import { b as Q } from "../png-item-9dNbB37T.js";
|
|
27
|
+
import { b as X } from "../csv-item-hH_Gt7ur.js";
|
|
28
|
+
function ee({
|
|
29
29
|
theme: e,
|
|
30
30
|
formatter: i,
|
|
31
31
|
labelFormatter: r
|
|
@@ -37,7 +37,7 @@ function X({
|
|
|
37
37
|
top: parseInt(e.spacing(3)),
|
|
38
38
|
right: parseInt(e.spacing(1)),
|
|
39
39
|
// Default: no legend. Merger bumps this when there are >1 series.
|
|
40
|
-
...
|
|
40
|
+
...q(!1, e),
|
|
41
41
|
containLabel: !0
|
|
42
42
|
},
|
|
43
43
|
tooltip: {
|
|
@@ -53,13 +53,13 @@ function X({
|
|
|
53
53
|
axisPointer: {
|
|
54
54
|
type: "line"
|
|
55
55
|
},
|
|
56
|
-
position:
|
|
57
|
-
formatter:
|
|
56
|
+
position: Y(e),
|
|
57
|
+
formatter: N(i, r)
|
|
58
58
|
},
|
|
59
59
|
// Legend styling baked here; `show` is toggled by the merger based on
|
|
60
60
|
// series count.
|
|
61
61
|
legend: {
|
|
62
|
-
...
|
|
62
|
+
...z({
|
|
63
63
|
hasLegend: !1
|
|
64
64
|
})
|
|
65
65
|
},
|
|
@@ -78,6 +78,7 @@ function X({
|
|
|
78
78
|
show: !1
|
|
79
79
|
},
|
|
80
80
|
axisLabel: {
|
|
81
|
+
..._(e),
|
|
81
82
|
padding: [parseInt(e.spacing(0.5)), 0, 0, 0],
|
|
82
83
|
margin: 0,
|
|
83
84
|
hideOverlap: !0,
|
|
@@ -103,8 +104,7 @@ function X({
|
|
|
103
104
|
}
|
|
104
105
|
},
|
|
105
106
|
axisLabel: {
|
|
106
|
-
|
|
107
|
-
fontFamily: e.typography.overlineDelicate?.fontFamily,
|
|
107
|
+
..._(e),
|
|
108
108
|
margin: parseInt(e.spacing(1)),
|
|
109
109
|
show: !0,
|
|
110
110
|
showMaxLabel: !0,
|
|
@@ -116,35 +116,35 @@ function X({
|
|
|
116
116
|
}
|
|
117
117
|
};
|
|
118
118
|
}
|
|
119
|
-
function
|
|
119
|
+
function Oe(e) {
|
|
120
120
|
const {
|
|
121
121
|
theme: i,
|
|
122
122
|
formatter: r,
|
|
123
123
|
labelFormatter: c,
|
|
124
124
|
optionsOverride: a
|
|
125
|
-
} = e, o = e.series,
|
|
126
|
-
return (t,
|
|
125
|
+
} = e, o = e.series, y = e.smooth ?? !0, f = e.area ?? !1, l = e.selection, s = l && l.length > 0 ? new Set(l) : null, m = (t) => t instanceof Date ? t.getTime() : t;
|
|
126
|
+
return (t, x, Z) => {
|
|
127
127
|
if (t == null) {
|
|
128
|
-
const n =
|
|
128
|
+
const n = ee({
|
|
129
129
|
theme: i,
|
|
130
130
|
formatter: r,
|
|
131
131
|
labelFormatter: c
|
|
132
132
|
});
|
|
133
|
-
return a ?
|
|
133
|
+
return a ? V(n, a) : n;
|
|
134
134
|
}
|
|
135
|
-
const w = Array.isArray(
|
|
135
|
+
const w = Array.isArray(x) ? x : [];
|
|
136
136
|
if (w.length === 0)
|
|
137
137
|
return {
|
|
138
138
|
...t,
|
|
139
139
|
dataset: [],
|
|
140
140
|
series: []
|
|
141
141
|
};
|
|
142
|
-
const
|
|
143
|
-
let
|
|
144
|
-
const D =
|
|
142
|
+
const L = w.length > 1, v = Array.isArray(t.series) ? t.series : [], F = v[0] ?? {}, j = typeof t.yAxis == "object" && !Array.isArray(t.yAxis) ? t.yAxis : {}, k = typeof t.grid == "object" && !Array.isArray(t.grid) ? t.grid : {}, P = typeof t.tooltip == "object" && !Array.isArray(t.tooltip) ? t.tooltip : {}, $ = typeof t.legend == "object" && !Array.isArray(t.legend) ? t.legend : {}, I = Z?.formatter;
|
|
143
|
+
let C = 0, T = 1;
|
|
144
|
+
const D = J(t.dataZoom, L), E = typeof k.bottom == "number" ? k.bottom : 24, M = L ? 56 : E, G = D ? M + B.sliderHeight + B.sliderGap : M, K = {
|
|
145
145
|
color: (n) => {
|
|
146
|
-
const
|
|
147
|
-
return !
|
|
146
|
+
const h = n.value?.name, p = n.color;
|
|
147
|
+
return !s || h == null || s.has(m(h)) ? p : R.color.modifyAlpha(p, 0.15);
|
|
148
148
|
}
|
|
149
149
|
};
|
|
150
150
|
return {
|
|
@@ -152,71 +152,71 @@ function Ie(e) {
|
|
|
152
152
|
dataset: w.map((n) => ({
|
|
153
153
|
source: n
|
|
154
154
|
})),
|
|
155
|
-
series: w.map((n,
|
|
156
|
-
const
|
|
155
|
+
series: w.map((n, g) => {
|
|
156
|
+
const h = v[g] ?? F, p = W(i, o?.[g]?.color);
|
|
157
157
|
return {
|
|
158
|
-
...typeof
|
|
158
|
+
...typeof h == "object" ? h : {},
|
|
159
159
|
type: "line",
|
|
160
|
-
datasetIndex:
|
|
161
|
-
name: o?.[
|
|
160
|
+
datasetIndex: g,
|
|
161
|
+
name: o?.[g]?.name ?? `Series ${g + 1}`,
|
|
162
162
|
encode: {
|
|
163
163
|
x: "name",
|
|
164
164
|
y: "value"
|
|
165
165
|
},
|
|
166
|
-
smooth:
|
|
166
|
+
smooth: y,
|
|
167
167
|
// When a selection is active, surface markers so the per-point
|
|
168
168
|
// color callback has something to dim — a continuous line would
|
|
169
169
|
// hide the visual selection feedback.
|
|
170
|
-
showSymbol:
|
|
171
|
-
...
|
|
170
|
+
showSymbol: s != null,
|
|
171
|
+
...f ? {
|
|
172
172
|
areaStyle: {}
|
|
173
173
|
} : {},
|
|
174
174
|
emphasis: {
|
|
175
175
|
focus: "series"
|
|
176
176
|
},
|
|
177
|
-
itemStyle:
|
|
178
|
-
...
|
|
179
|
-
color:
|
|
177
|
+
itemStyle: K,
|
|
178
|
+
...p ? {
|
|
179
|
+
color: p,
|
|
180
180
|
lineStyle: {
|
|
181
|
-
color:
|
|
181
|
+
color: p
|
|
182
182
|
}
|
|
183
183
|
} : {}
|
|
184
184
|
};
|
|
185
185
|
}),
|
|
186
186
|
legend: {
|
|
187
|
-
|
|
188
|
-
show:
|
|
187
|
+
...$,
|
|
188
|
+
show: L
|
|
189
189
|
},
|
|
190
190
|
grid: {
|
|
191
|
-
...
|
|
192
|
-
bottom:
|
|
191
|
+
...k,
|
|
192
|
+
bottom: G
|
|
193
193
|
},
|
|
194
194
|
...D ? {
|
|
195
195
|
dataZoom: D
|
|
196
196
|
} : {},
|
|
197
197
|
yAxis: {
|
|
198
|
-
...
|
|
199
|
-
min: (n) => (
|
|
200
|
-
max: (n) => (
|
|
198
|
+
...j,
|
|
199
|
+
min: (n) => (C = n.min < 0 ? A(n.min) : 0, C),
|
|
200
|
+
max: (n) => (T = n.max <= 0 ? 1 : A(n.max), T),
|
|
201
201
|
axisLabel: {
|
|
202
|
-
...
|
|
203
|
-
formatter: (n) => n !==
|
|
202
|
+
...j.axisLabel ?? {},
|
|
203
|
+
formatter: (n) => n !== T && n !== C || n === 0 ? "" : I ? I(n) : String(n)
|
|
204
204
|
}
|
|
205
205
|
},
|
|
206
206
|
tooltip: {
|
|
207
207
|
...P,
|
|
208
|
-
formatter:
|
|
208
|
+
formatter: N(I, c)
|
|
209
209
|
}
|
|
210
210
|
};
|
|
211
211
|
};
|
|
212
212
|
}
|
|
213
|
-
function
|
|
214
|
-
return
|
|
215
|
-
const c = r.value, a = c?.value, o = typeof a == "number" && e ? e(a) : a ?? "",
|
|
213
|
+
function N(e, i) {
|
|
214
|
+
return H((r) => {
|
|
215
|
+
const c = r.value, a = c?.value, o = typeof a == "number" && e ? e(a) : a ?? "", y = typeof r.marker == "string" ? r.marker : "", f = r.seriesName ? `${r.seriesName}: ` : "", l = c?.name ?? r.name, s = i && l != null ? i(l instanceof Date ? l : new Date(l)) : l ?? "";
|
|
216
216
|
return {
|
|
217
|
-
name: String(
|
|
218
|
-
seriesName:
|
|
219
|
-
marker:
|
|
217
|
+
name: String(s),
|
|
218
|
+
seriesName: f,
|
|
219
|
+
marker: y,
|
|
220
220
|
value: o
|
|
221
221
|
};
|
|
222
222
|
});
|
|
@@ -277,68 +277,62 @@ const u = {
|
|
|
277
277
|
}) => e(1.5)
|
|
278
278
|
}
|
|
279
279
|
};
|
|
280
|
-
function
|
|
281
|
-
const e =
|
|
280
|
+
function ve() {
|
|
281
|
+
const e = U(2);
|
|
282
282
|
let i;
|
|
283
283
|
e[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (i = /* @__PURE__ */ O(S, { sx: u.graph, children: [
|
|
284
|
-
/* @__PURE__ */
|
|
285
|
-
/* @__PURE__ */
|
|
286
|
-
/* @__PURE__ */
|
|
284
|
+
/* @__PURE__ */ d(b, { variant: "rectangular", sx: u.segmentA }),
|
|
285
|
+
/* @__PURE__ */ d(b, { variant: "rectangular", sx: u.segmentB }),
|
|
286
|
+
/* @__PURE__ */ d(b, { variant: "rectangular", sx: u.segmentC })
|
|
287
287
|
] }), e[0] = i) : i = e[0];
|
|
288
288
|
let r;
|
|
289
289
|
return e[1] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (r = /* @__PURE__ */ O(S, { sx: u.container, children: [
|
|
290
290
|
i,
|
|
291
|
-
/* @__PURE__ */
|
|
291
|
+
/* @__PURE__ */ d(S, { sx: u.legend, children: [0, 1].map(te) })
|
|
292
292
|
] }), e[1] = r) : r = e[1], r;
|
|
293
293
|
}
|
|
294
|
-
function
|
|
294
|
+
function te(e) {
|
|
295
295
|
return /* @__PURE__ */ O(S, { sx: u.legendItem, children: [
|
|
296
|
-
/* @__PURE__ */
|
|
297
|
-
/* @__PURE__ */
|
|
296
|
+
/* @__PURE__ */ d(b, { variant: "circular", width: 8, height: 8 }),
|
|
297
|
+
/* @__PURE__ */ d(b, { width: 48, height: 8 })
|
|
298
298
|
] }, `legend-${e}`);
|
|
299
299
|
}
|
|
300
|
-
function
|
|
300
|
+
function je(e) {
|
|
301
301
|
const i = [];
|
|
302
302
|
return e.getCaptureEl && i.push(Q({
|
|
303
303
|
filename: e.filename,
|
|
304
304
|
getCaptureEl: e.getCaptureEl,
|
|
305
305
|
pixelRatio: e.pngPixelRatio,
|
|
306
306
|
backgroundColor: e.pngBackgroundColor
|
|
307
|
-
})), i.push({
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
resolve: () => {
|
|
307
|
+
})), i.push(X({
|
|
308
|
+
filename: e.filename,
|
|
309
|
+
getRows: () => {
|
|
311
310
|
const r = e.getData(), c = r.length, a = [], o = /* @__PURE__ */ new Set();
|
|
312
311
|
for (const s of r)
|
|
313
|
-
for (const
|
|
314
|
-
const
|
|
315
|
-
o.has(
|
|
312
|
+
for (const m of s) {
|
|
313
|
+
const t = String(m.name);
|
|
314
|
+
o.has(t) || (o.add(t), a.push(m.name));
|
|
316
315
|
}
|
|
317
|
-
const
|
|
316
|
+
const y = r.map((s) => new Map(s.map((m) => [String(m.name), m.value]))), f = ["time"];
|
|
318
317
|
for (let s = 0; s < c; s++)
|
|
319
|
-
|
|
320
|
-
const l = [
|
|
318
|
+
f.push(e.seriesNames?.[s] ?? `series_${s + 1}`);
|
|
319
|
+
const l = [f];
|
|
321
320
|
for (const s of a) {
|
|
322
|
-
const
|
|
323
|
-
for (const
|
|
324
|
-
l.push(
|
|
321
|
+
const m = [re(s)], t = String(s);
|
|
322
|
+
for (const x of y) m.push(x.get(t) ?? "");
|
|
323
|
+
l.push(m);
|
|
325
324
|
}
|
|
326
|
-
|
|
327
|
-
return Promise.resolve({
|
|
328
|
-
url: m.url,
|
|
329
|
-
filename: `${e.filename}.csv`,
|
|
330
|
-
revoke: m.revoke
|
|
331
|
-
});
|
|
325
|
+
return l;
|
|
332
326
|
}
|
|
333
|
-
}), i;
|
|
327
|
+
})), i;
|
|
334
328
|
}
|
|
335
|
-
function
|
|
329
|
+
function re(e) {
|
|
336
330
|
return e instanceof Date ? e.toISOString() : typeof e == "number" ? new Date(e).toISOString() : e;
|
|
337
331
|
}
|
|
338
332
|
export {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
333
|
+
ve as TimeseriesSkeleton,
|
|
334
|
+
je as createTimeseriesDownloadConfig,
|
|
335
|
+
Oe as createTimeseriesOptionFactory,
|
|
336
|
+
ee as timeseriesOptions
|
|
343
337
|
};
|
|
344
338
|
//# sourceMappingURL=timeseries.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeseries.js","sources":["../../src/widgets-v2/timeseries/options.ts","../../src/widgets-v2/timeseries/skeleton.tsx","../../src/widgets-v2/timeseries/download.ts"],"sourcesContent":["import type { EChartsOption } from 'echarts'\nimport * as echarts from 'echarts'\nimport type { CallbackDataParams } from 'echarts/types/dist/shared'\nimport {\n buildGridConfig,\n buildLegendConfig,\n createTooltipFormatter,\n createTooltipPositioner,\n niceNum,\n} from '../../widgets/utils/chart-config'\nimport { ZOOM_LAYOUT } from '../actions/zoom-toggle'\nimport type { OptionFactory } from '../echart'\nimport { mergeOptions, resolveThemeColor } from '../utils'\nimport { positionDataZoomForLegend } from '../utils/data-zoom-layout'\nimport type {\n TimeseriesEChartsOption,\n TimeseriesOptionFactoryInput,\n TimeseriesOptionsInput,\n TimeseriesWidgetData,\n} from './types'\n\n/**\n * Builds the **structural** ECharts option for a timeseries widget —\n * time x-axis, value y-axis, themed tooltip, themed legend, CARTO color\n * palette. Mirrors {@link import('../bar/options').barOptions} so all\n * four ECharts widgets share v1 look-and-feel.\n *\n * Intentional deviations from bar (timeseries-specific):\n * - **X-axis is `type: 'time'`** (not 'category'). ECharts handles\n * uneven sample spacing and zoom-level-aware label formatting.\n * `labelFormatter` is wrapped so the consumer sees a `Date`, not\n * a numeric timestamp.\n * - **Tooltip body reads `{ name, value }` rows**, same as bar, but\n * the `name` may arrive as `Date | number | string`. The\n * `labelFormatter` receives a `Date` regardless.\n *\n * Intentionally data-agnostic: no series, no dataset, no `legend.show`\n * (those depend on data and are added by the option factory's merge\n * phase via {@link createTimeseriesOptionFactory}).\n */\nexport function timeseriesOptions({\n theme,\n formatter,\n labelFormatter,\n}: TimeseriesOptionsInput): TimeseriesEChartsOption {\n // Closure shared between yAxis min/max callbacks and the label formatter,\n // so only the rounded extents are labelled (matches v1 + bar).\n let niceMin = 0\n let niceMax = 1\n\n return {\n grid: {\n left: parseInt(theme.spacing(1)),\n top: parseInt(theme.spacing(3)),\n right: parseInt(theme.spacing(1)),\n // Default: no legend. Merger bumps this when there are >1 series.\n ...buildGridConfig(false, theme),\n containLabel: true,\n },\n tooltip: {\n trigger: 'axis',\n backgroundColor: theme.palette.grey[900],\n borderWidth: 0,\n padding: [parseInt(theme.spacing(1)), parseInt(theme.spacing(1))],\n textStyle: {\n color: theme.palette.common.white,\n fontSize: 11,\n fontFamily: theme.typography.caption.fontFamily,\n },\n axisPointer: { type: 'line' },\n position: createTooltipPositioner(theme),\n formatter: buildTimeseriesTooltipFormatter(formatter, labelFormatter),\n },\n // Legend styling baked here; `show` is toggled by the merger based on\n // series count.\n legend: {\n ...buildLegendConfig({ hasLegend: false }),\n },\n axisPointer: { lineStyle: { color: theme.palette.grey[400] } },\n color: [\n theme.palette.secondary.main,\n ...Object.values(\n (theme.palette as { qualitative?: { bold?: Record<string, string> } })\n .qualitative?.bold ?? {},\n ),\n ],\n xAxis: {\n type: 'time',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n padding: [parseInt(theme.spacing(0.5)), 0, 0, 0],\n margin: 0,\n hideOverlap: true,\n ...(labelFormatter && {\n formatter: (value: number) => labelFormatter(new Date(value)),\n }),\n },\n },\n yAxis: {\n type: 'value',\n min: (extent: { min: number }) => {\n niceMin = extent.min < 0 ? niceNum(extent.min) : 0\n return niceMin\n },\n max: (extent: { min: number; max: number }) => {\n niceMax = extent.max <= 0 ? 1 : niceNum(extent.max)\n return niceMax\n },\n axisLine: { show: false },\n axisTick: { show: false },\n splitLine: {\n show: true,\n lineStyle: { color: theme.palette.black?.[4] ?? theme.palette.divider },\n },\n axisLabel: {\n fontSize: theme.typography.overlineDelicate?.fontSize,\n fontFamily: theme.typography.overlineDelicate?.fontFamily,\n margin: parseInt(theme.spacing(1)),\n show: true,\n showMaxLabel: true,\n showMinLabel: true,\n verticalAlign: 'bottom',\n inside: true,\n formatter: (value: number) => {\n if (value !== niceMax && value !== niceMin) return ''\n if (value === 0) return ''\n return formatter ? formatter(value) : String(value)\n },\n },\n },\n } as TimeseriesEChartsOption\n}\n\n/**\n * Returns the timeseries widget's {@link OptionFactory} — one closure\n * that owns BOTH phases of option construction:\n *\n * - **Structural phase** (`option == null`) — builds the theme-aware\n * structural option via {@link timeseriesOptions}, optionally merging\n * the consumer-supplied `optionsOverride`. Called once by Provider to\n * seed `rawOptions` in the store.\n * - **Merge phase** (`option != null`) — fuses post-pipeline `state.data`\n * (`TimeseriesWidgetData`) into the option via the dataset API: one\n * dataset per series, each series referencing its dataset by index,\n * encoded by `name` (x — time) and `value` (y). Mirrors {@link import('../bar/options').createBarOptionFactory}:\n * series-template merge for `addStack`, reactive formatters from\n * `ctx`, `niceNum`-rounded y-axis bounds at fusion time, and\n * `positionDataZoomForLegend` layout for ZoomToggle sliders.\n */\nexport function createTimeseriesOptionFactory(\n options: TimeseriesOptionFactoryInput,\n): OptionFactory {\n const { theme, formatter, labelFormatter, optionsOverride } = options\n const series = options.series\n const smooth = options.smooth ?? true\n const area = options.area ?? false\n const selection = options.selection\n const selectionSet =\n selection && selection.length > 0\n ? new Set<string | number>(selection)\n : null\n // `name` may be Date | number | string. Normalize to the same type the\n // selection is keyed on (Date → ms) so Set lookups match.\n const normalizeName = (n: Date | number | string): string | number =>\n n instanceof Date ? n.getTime() : n\n return (option, data, ctx) => {\n if (option == null) {\n const structural = timeseriesOptions({ theme, formatter, labelFormatter })\n return optionsOverride\n ? (mergeOptions(\n structural as unknown as Record<string, unknown>,\n optionsOverride as Partial<Record<string, unknown>>,\n ) as EChartsOption)\n : structural\n }\n\n const seriesArr = Array.isArray(data) ? (data as TimeseriesWidgetData) : []\n if (seriesArr.length === 0) {\n return { ...option, dataset: [], series: [] }\n }\n const hasLegend = seriesArr.length > 1\n const seriesTemplates = Array.isArray(option.series) ? option.series : []\n const broadcastTemplate = seriesTemplates[0] ?? {}\n const baseYAxis =\n typeof option.yAxis === 'object' && !Array.isArray(option.yAxis)\n ? option.yAxis\n : {}\n const baseGrid =\n typeof option.grid === 'object' && !Array.isArray(option.grid)\n ? option.grid\n : {}\n const baseTooltip =\n typeof option.tooltip === 'object' && !Array.isArray(option.tooltip)\n ? option.tooltip\n : {}\n const baseLegend =\n typeof option.legend === 'object' && !Array.isArray(option.legend)\n ? option.legend\n : {}\n\n // Reactive (live store) formatter from ctx — distinct from the\n // closure-time `formatter` captured for the structural-build branch\n // above. RelativeData can install a percent formatter on the store\n // after the factory was constructed; the merge phase reads `ctx` to\n // pick that up. `labelFormatter` (Date → string) is structural-only —\n // not relativizable — so the merge branch reads the closure-time value.\n const liveFormatter = ctx?.formatter\n\n // Closure shared between the yAxis min/max callbacks and the label\n // formatter, so only the rounded extents are labelled (matches v1 +\n // bar). Delegating the extent to ECharts (rather than precomputing\n // scalars from the raw data) keeps stacked lines inside the plot: when\n // StackToggle marks the series, ECharts feeds the *post-stack* extent\n // to these callbacks, so `niceNum` rounds the stacked total.\n let niceMin = 0\n let niceMax = 1\n\n // Zoom slider layout: when ZoomToggle has installed `dataZoom`, push the\n // slider above the legend (if any) and reserve room in the grid below.\n const dataZoomLayout = positionDataZoomForLegend(option.dataZoom, hasLegend)\n const fallbackBottom =\n typeof baseGrid.bottom === 'number' ? baseGrid.bottom : 24\n const baseBottom = hasLegend ? 56 : fallbackBottom\n const gridBottom = dataZoomLayout\n ? baseBottom + ZOOM_LAYOUT.sliderHeight + ZOOM_LAYOUT.sliderGap\n : baseBottom\n\n // Dim non-selected points via `series.itemStyle.color`. Per-row\n // `itemStyle` on dataset object-rows is silently ignored when\n // `series.encode` is in play.\n //\n // We *always* emit `itemStyle.color` (a passthrough when nothing is\n // selected), not conditionally — dropping the key between renders\n // would let ECharts' default merge keep the previous callback alive\n // and points would stay dimmed forever after an external clear.\n // Always emitting lets normal merge swap the callback in place, no\n // `replaceMerge` and no entry-animation flash on selection on/off.\n const dimItemStyle = {\n color: (params: CallbackDataParams) => {\n const datum = params.value as\n | { name?: Date | number | string }\n | undefined\n const raw = datum?.name\n const base = params.color as string\n if (!selectionSet || raw == null) return base\n return selectionSet.has(normalizeName(raw))\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n },\n }\n\n return {\n ...option,\n dataset: seriesArr.map((s) => ({ source: s as readonly object[] })),\n series: seriesArr.map((_, i) => {\n const template =\n (seriesTemplates[i] as object | undefined) ??\n (broadcastTemplate as object)\n // For line series, set BOTH `series[i].color` (legend swatch +\n // markers) AND `series[i].lineStyle.color` (the line itself) so\n // the override paints everywhere a series has a colour slot.\n const overrideColor = resolveThemeColor(theme, series?.[i]?.color)\n return {\n ...(typeof template === 'object' ? template : {}),\n type: 'line' as const,\n datasetIndex: i,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n encode: { x: 'name', y: 'value' },\n smooth,\n // When a selection is active, surface markers so the per-point\n // color callback has something to dim — a continuous line would\n // hide the visual selection feedback.\n showSymbol: selectionSet != null,\n ...(area ? { areaStyle: {} } : {}),\n emphasis: { focus: 'series' },\n itemStyle: dimItemStyle,\n ...(overrideColor\n ? { color: overrideColor, lineStyle: { color: overrideColor } }\n : {}),\n }\n }),\n legend: { ...baseLegend, show: hasLegend },\n grid: { ...baseGrid, bottom: gridBottom },\n ...(dataZoomLayout ? { dataZoom: dataZoomLayout } : {}),\n yAxis: {\n ...baseYAxis,\n min: (extent: { min: number }) => {\n niceMin = extent.min < 0 ? niceNum(extent.min) : 0\n return niceMin\n },\n max: (extent: { min: number; max: number }) => {\n niceMax = extent.max <= 0 ? 1 : niceNum(extent.max)\n return niceMax\n },\n axisLabel: {\n ...((baseYAxis as { axisLabel?: object }).axisLabel ?? {}),\n formatter: (value: number) => {\n if (value !== niceMax && value !== niceMin) return ''\n if (value === 0) return ''\n return liveFormatter ? liveFormatter(value) : String(value)\n },\n },\n } as EChartsOption['yAxis'],\n tooltip: {\n ...baseTooltip,\n formatter: buildTimeseriesTooltipFormatter(\n liveFormatter,\n labelFormatter,\n ),\n },\n } as EChartsOption\n }\n}\n\n/**\n * Tooltip formatter for the timeseries `{ name, value }` row shape.\n * `name` arrives as `Date | number | string` (the time-axis stores the\n * raw value the consumer supplied). The consumer's `labelFormatter`\n * expects a `Date`, so we coerce non-Date values via `new Date(...)`\n * before invoking it.\n */\nfunction buildTimeseriesTooltipFormatter(\n formatter: ((value: number) => string) | undefined,\n labelFormatter: ((value: Date) => string) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const row = item.value as\n | { name?: Date | number | string; value?: number }\n | undefined\n const raw = row?.value\n const formattedValue =\n typeof raw === 'number' && formatter ? formatter(raw) : (raw ?? '')\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n const rawName = row?.name ?? item.name\n const name =\n labelFormatter && rawName != null\n ? labelFormatter(rawName instanceof Date ? rawName : new Date(rawName))\n : (rawName ?? '')\n return { name: String(name), seriesName, marker, value: formattedValue }\n })\n}\n","import { Box, Skeleton } from '@mui/material'\nimport type { SxProps, Theme } from '@mui/material'\n\nconst styles = {\n container: {\n display: 'flex',\n flexDirection: 'column',\n justifyContent: 'space-between',\n gap: ({ spacing }) => spacing(1),\n height: ({ spacing }) => spacing(38),\n },\n graph: {\n position: 'relative',\n flex: '1 1 auto',\n width: '100%',\n },\n segmentA: {\n position: 'absolute',\n left: 0,\n right: '70%',\n top: '60%',\n height: 4,\n },\n segmentB: {\n position: 'absolute',\n left: '25%',\n right: '40%',\n top: '35%',\n height: 4,\n },\n segmentC: {\n position: 'absolute',\n left: '55%',\n right: 0,\n top: '50%',\n height: 4,\n },\n legend: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(2),\n height: ({ spacing }) => spacing(5),\n },\n legendItem: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(1.5),\n },\n} satisfies Record<string, SxProps<Theme>>\n\n/**\n * Loading state for the Timeseries widget. Mirrors a line chart's\n * silhouette — three thin horizontal segments at staggered offsets to\n * suggest a moving line, plus a 2-dot legend stub. Sibling-consistent\n * with Bar / Histogram / Scatter skeletons (column-flex container with\n * legend strip below).\n */\nexport function TimeseriesSkeleton() {\n return (\n <Box sx={styles.container}>\n <Box sx={styles.graph}>\n <Skeleton variant='rectangular' sx={styles.segmentA} />\n <Skeleton variant='rectangular' sx={styles.segmentB} />\n <Skeleton variant='rectangular' sx={styles.segmentC} />\n </Box>\n <Box sx={styles.legend}>\n {[0, 1].map((i) => (\n <Box key={`legend-${i}`} sx={styles.legendItem}>\n <Skeleton variant='circular' width={8} height={8} />\n <Skeleton width={48} height={8} />\n </Box>\n ))}\n </Box>\n </Box>\n )\n}\n","import {\n buildPngDownloadItem,\n downloadToCSV,\n type DownloadItem,\n} from '../actions/download'\nimport type { TimeseriesWidgetData } from './types'\n\n/**\n * Download menu items for the Timeseries widget. Always includes a CSV\n * item with `time, series_1, series_2, …` columns (one row per unique time\n * across all series; ISO-8601 strings for `Date`/numeric times). When\n * `getCaptureEl` is supplied, prepends a PNG item that rasterises the\n * captured element via `html2canvas`.\n */\nexport function createTimeseriesDownloadConfig(args: {\n filename: string\n getData: () => TimeseriesWidgetData\n seriesNames?: readonly string[]\n getCaptureEl?: () => HTMLElement | null\n pngPixelRatio?: number\n pngBackgroundColor?: string | null\n}): DownloadItem[] {\n const items: DownloadItem[] = []\n if (args.getCaptureEl) {\n items.push(\n buildPngDownloadItem({\n filename: args.filename,\n getCaptureEl: args.getCaptureEl,\n pixelRatio: args.pngPixelRatio,\n backgroundColor: args.pngBackgroundColor,\n }),\n )\n }\n items.push({\n id: 'csv',\n label: 'Download as CSV',\n resolve: () => {\n const data = args.getData()\n const seriesCount = data.length\n\n // Collect every unique time, preserving insertion order.\n const timeKeys: (Date | number | string)[] = []\n const seenKeys = new Set<string>()\n for (const series of data) {\n for (const point of series) {\n const key = String(point.name)\n if (!seenKeys.has(key)) {\n seenKeys.add(key)\n timeKeys.push(point.name)\n }\n }\n }\n\n // Build a quick lookup per series for O(rows × series) emit.\n const lookups = data.map(\n (series) => new Map(series.map((p) => [String(p.name), p.value])),\n )\n\n const header: unknown[] = ['time']\n for (let i = 0; i < seriesCount; i++) {\n header.push(args.seriesNames?.[i] ?? `series_${i + 1}`)\n }\n const rows: unknown[][] = [header]\n for (const key of timeKeys) {\n const row: unknown[] = [formatTime(key)]\n const lookupKey = String(key)\n for (const lookup of lookups) row.push(lookup.get(lookupKey) ?? '')\n rows.push(row)\n }\n\n const handle = downloadToCSV(rows)\n return Promise.resolve({\n url: handle.url,\n filename: `${args.filename}.csv`,\n revoke: handle.revoke,\n })\n },\n })\n return items\n}\n\nfunction formatTime(v: Date | number | string): string {\n if (v instanceof Date) return v.toISOString()\n if (typeof v === 'number') return new Date(v).toISOString()\n return v\n}\n"],"names":["timeseriesOptions","theme","formatter","labelFormatter","niceMin","niceMax","grid","left","parseInt","spacing","top","right","buildGridConfig","containLabel","tooltip","trigger","backgroundColor","palette","grey","borderWidth","padding","textStyle","color","common","white","fontSize","fontFamily","typography","caption","axisPointer","type","position","createTooltipPositioner","buildTimeseriesTooltipFormatter","legend","buildLegendConfig","hasLegend","lineStyle","secondary","main","Object","values","qualitative","bold","xAxis","axisLine","show","axisTick","axisLabel","margin","hideOverlap","value","Date","yAxis","min","extent","niceNum","max","splitLine","black","divider","overlineDelicate","showMaxLabel","showMinLabel","verticalAlign","inside","String","createTimeseriesOptionFactory","options","optionsOverride","series","smooth","area","selection","selectionSet","length","Set","normalizeName","n","getTime","option","data","ctx","structural","mergeOptions","seriesArr","Array","isArray","dataset","seriesTemplates","broadcastTemplate","baseYAxis","baseGrid","baseTooltip","baseLegend","liveFormatter","dataZoomLayout","positionDataZoomForLegend","dataZoom","fallbackBottom","bottom","baseBottom","gridBottom","ZOOM_LAYOUT","sliderHeight","sliderGap","dimItemStyle","params","raw","name","base","has","echarts","modifyAlpha","map","s","source","_","i","template","overrideColor","resolveThemeColor","datasetIndex","encode","x","y","showSymbol","areaStyle","emphasis","focus","itemStyle","createTooltipFormatter","item","row","formattedValue","marker","seriesName","rawName","styles","container","display","flexDirection","justifyContent","gap","height","graph","flex","width","segmentA","segmentB","segmentC","alignItems","legendItem","TimeseriesSkeleton","$","_c","t0","Symbol","for","jsxs","Box","jsx","Skeleton","t1","_temp","createTimeseriesDownloadConfig","args","items","getCaptureEl","push","buildPngDownloadItem","filename","pixelRatio","pngPixelRatio","pngBackgroundColor","id","label","resolve","getData","seriesCount","timeKeys","seenKeys","point","key","add","lookups","Map","p","header","seriesNames","rows","formatTime","lookupKey","lookup","get","handle","downloadToCSV","Promise","url","revoke","v","toISOString"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCO,SAASA,EAAkB;AAAA,EAChCC,OAAAA;AAAAA,EACAC,WAAAA;AAAAA,EACAC,gBAAAA;AACsB,GAA4B;AAGlD,MAAIC,IAAU,GACVC,IAAU;AAEd,SAAO;AAAA,IACLC,MAAM;AAAA,MACJC,MAAMC,SAASP,EAAMQ,QAAQ,CAAC,CAAC;AAAA,MAC/BC,KAAKF,SAASP,EAAMQ,QAAQ,CAAC,CAAC;AAAA,MAC9BE,OAAOH,SAASP,EAAMQ,QAAQ,CAAC,CAAC;AAAA;AAAA,MAEhC,GAAGG,EAAgB,IAAOX,CAAK;AAAA,MAC/BY,cAAc;AAAA,IAAA;AAAA,IAEhBC,SAAS;AAAA,M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C,CAAG;AAAA,MACf;AAEA,YAAM8D,IAASC,EAAcN,CAAI;AACjC,aAAOO,QAAQpB,QAAQ;AAAA,QACrBqB,KAAKH,EAAOG;AAAAA,QACZ3B,UAAU,GAAGL,EAAKK,QAAQ;AAAA,QAC1B4B,QAAQJ,EAAOI;AAAAA,MAAAA,CAChB;AAAA,IACH;AAAA,EAAA,CACD,GACMhC;AACT;AAEA,SAASwB,GAAWS,GAAmC;AACrD,SAAIA,aAAapJ,OAAaoJ,EAAEC,YAAAA,IAC5B,OAAOD,KAAM,WAAiB,IAAIpJ,KAAKoJ,CAAC,EAAEC,YAAAA,IACvCD;AACT;"}
|
|
1
|
+
{"version":3,"file":"timeseries.js","sources":["../../src/widgets-v2/timeseries/options.ts","../../src/widgets-v2/timeseries/skeleton.tsx","../../src/widgets-v2/timeseries/download.ts"],"sourcesContent":["import type { EChartsOption } from 'echarts'\nimport * as echarts from 'echarts'\nimport type { CallbackDataParams } from 'echarts/types/dist/shared'\nimport {\n buildAxisLabelStyle,\n buildGridConfig,\n buildLegendConfig,\n createTooltipFormatter,\n createTooltipPositioner,\n niceNum,\n} from '../../widgets/utils/chart-config'\nimport { ZOOM_LAYOUT } from '../actions/zoom-toggle'\nimport type { OptionFactory } from '../echart'\nimport { mergeOptions, resolveThemeColor } from '../utils'\nimport { positionDataZoomForLegend } from '../utils/data-zoom-layout'\nimport type {\n TimeseriesEChartsOption,\n TimeseriesOptionFactoryInput,\n TimeseriesOptionsInput,\n TimeseriesWidgetData,\n} from './types'\n\n/**\n * Builds the **structural** ECharts option for a timeseries widget —\n * time x-axis, value y-axis, themed tooltip, themed legend, CARTO color\n * palette. Mirrors {@link import('../bar/options').barOptions} so all\n * four ECharts widgets share v1 look-and-feel.\n *\n * Intentional deviations from bar (timeseries-specific):\n * - **X-axis is `type: 'time'`** (not 'category'). ECharts handles\n * uneven sample spacing and zoom-level-aware label formatting.\n * `labelFormatter` is wrapped so the consumer sees a `Date`, not\n * a numeric timestamp.\n * - **Tooltip body reads `{ name, value }` rows**, same as bar, but\n * the `name` may arrive as `Date | number | string`. The\n * `labelFormatter` receives a `Date` regardless.\n *\n * Intentionally data-agnostic: no series, no dataset, no `legend.show`\n * (those depend on data and are added by the option factory's merge\n * phase via {@link createTimeseriesOptionFactory}).\n */\nexport function timeseriesOptions({\n theme,\n formatter,\n labelFormatter,\n}: TimeseriesOptionsInput): TimeseriesEChartsOption {\n // Closure shared between yAxis min/max callbacks and the label formatter,\n // so only the rounded extents are labelled (matches v1 + bar).\n let niceMin = 0\n let niceMax = 1\n\n return {\n grid: {\n left: parseInt(theme.spacing(1)),\n top: parseInt(theme.spacing(3)),\n right: parseInt(theme.spacing(1)),\n // Default: no legend. Merger bumps this when there are >1 series.\n ...buildGridConfig(false, theme),\n containLabel: true,\n },\n tooltip: {\n trigger: 'axis',\n backgroundColor: theme.palette.grey[900],\n borderWidth: 0,\n padding: [parseInt(theme.spacing(1)), parseInt(theme.spacing(1))],\n textStyle: {\n color: theme.palette.common.white,\n fontSize: 11,\n fontFamily: theme.typography.caption.fontFamily,\n },\n axisPointer: { type: 'line' },\n position: createTooltipPositioner(theme),\n formatter: buildTimeseriesTooltipFormatter(formatter, labelFormatter),\n },\n // Legend styling baked here; `show` is toggled by the merger based on\n // series count.\n legend: {\n ...buildLegendConfig({ hasLegend: false }),\n },\n axisPointer: { lineStyle: { color: theme.palette.grey[400] } },\n color: [\n theme.palette.secondary.main,\n ...Object.values(\n (theme.palette as { qualitative?: { bold?: Record<string, string> } })\n .qualitative?.bold ?? {},\n ),\n ],\n xAxis: {\n type: 'time',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n ...buildAxisLabelStyle(theme),\n padding: [parseInt(theme.spacing(0.5)), 0, 0, 0],\n margin: 0,\n hideOverlap: true,\n ...(labelFormatter && {\n formatter: (value: number) => labelFormatter(new Date(value)),\n }),\n },\n },\n yAxis: {\n type: 'value',\n min: (extent: { min: number }) => {\n niceMin = extent.min < 0 ? niceNum(extent.min) : 0\n return niceMin\n },\n max: (extent: { min: number; max: number }) => {\n niceMax = extent.max <= 0 ? 1 : niceNum(extent.max)\n return niceMax\n },\n axisLine: { show: false },\n axisTick: { show: false },\n splitLine: {\n show: true,\n lineStyle: { color: theme.palette.black?.[4] ?? theme.palette.divider },\n },\n axisLabel: {\n ...buildAxisLabelStyle(theme),\n margin: parseInt(theme.spacing(1)),\n show: true,\n showMaxLabel: true,\n showMinLabel: true,\n verticalAlign: 'bottom',\n inside: true,\n formatter: (value: number) => {\n if (value !== niceMax && value !== niceMin) return ''\n if (value === 0) return ''\n return formatter ? formatter(value) : String(value)\n },\n },\n },\n } as TimeseriesEChartsOption\n}\n\n/**\n * Returns the timeseries widget's {@link OptionFactory} — one closure\n * that owns BOTH phases of option construction:\n *\n * - **Structural phase** (`option == null`) — builds the theme-aware\n * structural option via {@link timeseriesOptions}, optionally merging\n * the consumer-supplied `optionsOverride`. Called once by Provider to\n * seed `rawOptions` in the store.\n * - **Merge phase** (`option != null`) — fuses post-pipeline `state.data`\n * (`TimeseriesWidgetData`) into the option via the dataset API: one\n * dataset per series, each series referencing its dataset by index,\n * encoded by `name` (x — time) and `value` (y). Mirrors {@link import('../bar/options').createBarOptionFactory}:\n * series-template merge for `addStack`, reactive formatters from\n * `ctx`, `niceNum`-rounded y-axis bounds at fusion time, and\n * `positionDataZoomForLegend` layout for ZoomToggle sliders.\n */\nexport function createTimeseriesOptionFactory(\n options: TimeseriesOptionFactoryInput,\n): OptionFactory {\n const { theme, formatter, labelFormatter, optionsOverride } = options\n const series = options.series\n const smooth = options.smooth ?? true\n const area = options.area ?? false\n const selection = options.selection\n const selectionSet =\n selection && selection.length > 0\n ? new Set<string | number>(selection)\n : null\n // `name` may be Date | number | string. Normalize to the same type the\n // selection is keyed on (Date → ms) so Set lookups match.\n const normalizeName = (n: Date | number | string): string | number =>\n n instanceof Date ? n.getTime() : n\n return (option, data, ctx) => {\n if (option == null) {\n const structural = timeseriesOptions({ theme, formatter, labelFormatter })\n return optionsOverride\n ? (mergeOptions(\n structural as unknown as Record<string, unknown>,\n optionsOverride as Partial<Record<string, unknown>>,\n ) as EChartsOption)\n : structural\n }\n\n const seriesArr = Array.isArray(data) ? (data as TimeseriesWidgetData) : []\n if (seriesArr.length === 0) {\n return { ...option, dataset: [], series: [] }\n }\n const hasLegend = seriesArr.length > 1\n const seriesTemplates = Array.isArray(option.series) ? option.series : []\n const broadcastTemplate = seriesTemplates[0] ?? {}\n const baseYAxis =\n typeof option.yAxis === 'object' && !Array.isArray(option.yAxis)\n ? option.yAxis\n : {}\n const baseGrid =\n typeof option.grid === 'object' && !Array.isArray(option.grid)\n ? option.grid\n : {}\n const baseTooltip =\n typeof option.tooltip === 'object' && !Array.isArray(option.tooltip)\n ? option.tooltip\n : {}\n const baseLegend =\n typeof option.legend === 'object' && !Array.isArray(option.legend)\n ? option.legend\n : {}\n\n // Reactive (live store) formatter from ctx — distinct from the\n // closure-time `formatter` captured for the structural-build branch\n // above. RelativeData can install a percent formatter on the store\n // after the factory was constructed; the merge phase reads `ctx` to\n // pick that up. `labelFormatter` (Date → string) is structural-only —\n // not relativizable — so the merge branch reads the closure-time value.\n const liveFormatter = ctx?.formatter\n\n // Closure shared between the yAxis min/max callbacks and the label\n // formatter, so only the rounded extents are labelled (matches v1 +\n // bar). Delegating the extent to ECharts (rather than precomputing\n // scalars from the raw data) keeps stacked lines inside the plot: when\n // StackToggle marks the series, ECharts feeds the *post-stack* extent\n // to these callbacks, so `niceNum` rounds the stacked total.\n let niceMin = 0\n let niceMax = 1\n\n // Zoom slider layout: when ZoomToggle has installed `dataZoom`, push the\n // slider above the legend (if any) and reserve room in the grid below.\n const dataZoomLayout = positionDataZoomForLegend(option.dataZoom, hasLegend)\n const fallbackBottom =\n typeof baseGrid.bottom === 'number' ? baseGrid.bottom : 24\n const baseBottom = hasLegend ? 56 : fallbackBottom\n const gridBottom = dataZoomLayout\n ? baseBottom + ZOOM_LAYOUT.sliderHeight + ZOOM_LAYOUT.sliderGap\n : baseBottom\n\n // Dim non-selected points via `series.itemStyle.color`. Per-row\n // `itemStyle` on dataset object-rows is silently ignored when\n // `series.encode` is in play.\n //\n // We *always* emit `itemStyle.color` (a passthrough when nothing is\n // selected), not conditionally — dropping the key between renders\n // would let ECharts' default merge keep the previous callback alive\n // and points would stay dimmed forever after an external clear.\n // Always emitting lets normal merge swap the callback in place, no\n // `replaceMerge` and no entry-animation flash on selection on/off.\n const dimItemStyle = {\n color: (params: CallbackDataParams) => {\n const datum = params.value as\n | { name?: Date | number | string }\n | undefined\n const raw = datum?.name\n const base = params.color as string\n if (!selectionSet || raw == null) return base\n return selectionSet.has(normalizeName(raw))\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n },\n }\n\n return {\n ...option,\n dataset: seriesArr.map((s) => ({ source: s as readonly object[] })),\n series: seriesArr.map((_, i) => {\n const template =\n (seriesTemplates[i] as object | undefined) ??\n (broadcastTemplate as object)\n // For line series, set BOTH `series[i].color` (legend swatch +\n // markers) AND `series[i].lineStyle.color` (the line itself) so\n // the override paints everywhere a series has a colour slot.\n const overrideColor = resolveThemeColor(theme, series?.[i]?.color)\n return {\n ...(typeof template === 'object' ? template : {}),\n type: 'line' as const,\n datasetIndex: i,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n encode: { x: 'name', y: 'value' },\n smooth,\n // When a selection is active, surface markers so the per-point\n // color callback has something to dim — a continuous line would\n // hide the visual selection feedback.\n showSymbol: selectionSet != null,\n ...(area ? { areaStyle: {} } : {}),\n emphasis: { focus: 'series' },\n itemStyle: dimItemStyle,\n ...(overrideColor\n ? { color: overrideColor, lineStyle: { color: overrideColor } }\n : {}),\n }\n }),\n legend: { ...baseLegend, show: hasLegend },\n grid: { ...baseGrid, bottom: gridBottom },\n ...(dataZoomLayout ? { dataZoom: dataZoomLayout } : {}),\n yAxis: {\n ...baseYAxis,\n min: (extent: { min: number }) => {\n niceMin = extent.min < 0 ? niceNum(extent.min) : 0\n return niceMin\n },\n max: (extent: { min: number; max: number }) => {\n niceMax = extent.max <= 0 ? 1 : niceNum(extent.max)\n return niceMax\n },\n axisLabel: {\n ...((baseYAxis as { axisLabel?: object }).axisLabel ?? {}),\n formatter: (value: number) => {\n if (value !== niceMax && value !== niceMin) return ''\n if (value === 0) return ''\n return liveFormatter ? liveFormatter(value) : String(value)\n },\n },\n } as EChartsOption['yAxis'],\n tooltip: {\n ...baseTooltip,\n formatter: buildTimeseriesTooltipFormatter(\n liveFormatter,\n labelFormatter,\n ),\n },\n } as EChartsOption\n }\n}\n\n/**\n * Tooltip formatter for the timeseries `{ name, value }` row shape.\n * `name` arrives as `Date | number | string` (the time-axis stores the\n * raw value the consumer supplied). The consumer's `labelFormatter`\n * expects a `Date`, so we coerce non-Date values via `new Date(...)`\n * before invoking it.\n */\nfunction buildTimeseriesTooltipFormatter(\n formatter: ((value: number) => string) | undefined,\n labelFormatter: ((value: Date) => string) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const row = item.value as\n | { name?: Date | number | string; value?: number }\n | undefined\n const raw = row?.value\n const formattedValue =\n typeof raw === 'number' && formatter ? formatter(raw) : (raw ?? '')\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n const rawName = row?.name ?? item.name\n const name =\n labelFormatter && rawName != null\n ? labelFormatter(rawName instanceof Date ? rawName : new Date(rawName))\n : (rawName ?? '')\n return { name: String(name), seriesName, marker, value: formattedValue }\n })\n}\n","import { Box, Skeleton } from '@mui/material'\nimport type { SxProps, Theme } from '@mui/material'\n\nconst styles = {\n container: {\n display: 'flex',\n flexDirection: 'column',\n justifyContent: 'space-between',\n gap: ({ spacing }) => spacing(1),\n height: ({ spacing }) => spacing(38),\n },\n graph: {\n position: 'relative',\n flex: '1 1 auto',\n width: '100%',\n },\n segmentA: {\n position: 'absolute',\n left: 0,\n right: '70%',\n top: '60%',\n height: 4,\n },\n segmentB: {\n position: 'absolute',\n left: '25%',\n right: '40%',\n top: '35%',\n height: 4,\n },\n segmentC: {\n position: 'absolute',\n left: '55%',\n right: 0,\n top: '50%',\n height: 4,\n },\n legend: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(2),\n height: ({ spacing }) => spacing(5),\n },\n legendItem: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(1.5),\n },\n} satisfies Record<string, SxProps<Theme>>\n\n/**\n * Loading state for the Timeseries widget. Mirrors a line chart's\n * silhouette — three thin horizontal segments at staggered offsets to\n * suggest a moving line, plus a 2-dot legend stub. Sibling-consistent\n * with Bar / Histogram / Scatter skeletons (column-flex container with\n * legend strip below).\n */\nexport function TimeseriesSkeleton() {\n return (\n <Box sx={styles.container}>\n <Box sx={styles.graph}>\n <Skeleton variant='rectangular' sx={styles.segmentA} />\n <Skeleton variant='rectangular' sx={styles.segmentB} />\n <Skeleton variant='rectangular' sx={styles.segmentC} />\n </Box>\n <Box sx={styles.legend}>\n {[0, 1].map((i) => (\n <Box key={`legend-${i}`} sx={styles.legendItem}>\n <Skeleton variant='circular' width={8} height={8} />\n <Skeleton width={48} height={8} />\n </Box>\n ))}\n </Box>\n </Box>\n )\n}\n","import {\n buildCsvDownloadItem,\n buildPngDownloadItem,\n type DownloadItem,\n} from '../actions/download'\nimport type { TimeseriesWidgetData } from './types'\n\n/**\n * Download menu items for the Timeseries widget. Always includes a CSV\n * item with `time, series_1, series_2, …` columns (one row per unique time\n * across all series; ISO-8601 strings for `Date`/numeric times). When\n * `getCaptureEl` is supplied, prepends a PNG item that rasterises the\n * captured element via `html2canvas`.\n */\nexport function createTimeseriesDownloadConfig(args: {\n filename: string\n getData: () => TimeseriesWidgetData\n seriesNames?: readonly string[]\n getCaptureEl?: () => HTMLElement | null\n pngPixelRatio?: number\n pngBackgroundColor?: string | null\n}): DownloadItem[] {\n const items: DownloadItem[] = []\n if (args.getCaptureEl) {\n items.push(\n buildPngDownloadItem({\n filename: args.filename,\n getCaptureEl: args.getCaptureEl,\n pixelRatio: args.pngPixelRatio,\n backgroundColor: args.pngBackgroundColor,\n }),\n )\n }\n items.push(\n buildCsvDownloadItem({\n filename: args.filename,\n getRows: () => {\n const data = args.getData()\n const seriesCount = data.length\n\n // Collect every unique time, preserving insertion order.\n const timeKeys: (Date | number | string)[] = []\n const seenKeys = new Set<string>()\n for (const series of data) {\n for (const point of series) {\n const key = String(point.name)\n if (!seenKeys.has(key)) {\n seenKeys.add(key)\n timeKeys.push(point.name)\n }\n }\n }\n\n // Build a quick lookup per series for O(rows × series) emit.\n const lookups = data.map(\n (series) => new Map(series.map((p) => [String(p.name), p.value])),\n )\n\n const header: unknown[] = ['time']\n for (let i = 0; i < seriesCount; i++) {\n header.push(args.seriesNames?.[i] ?? `series_${i + 1}`)\n }\n const rows: unknown[][] = [header]\n for (const key of timeKeys) {\n const row: unknown[] = [formatTime(key)]\n const lookupKey = String(key)\n for (const lookup of lookups) row.push(lookup.get(lookupKey) ?? '')\n rows.push(row)\n }\n\n return rows\n },\n }),\n )\n return items\n}\n\nfunction formatTime(v: Date | number | string): string {\n if (v instanceof Date) return v.toISOString()\n if (typeof v === 'number') return new Date(v).toISOString()\n return v\n}\n"],"names":["timeseriesOptions","theme","formatter","labelFormatter","niceMin","niceMax","grid","left","parseInt","spacing","top","right","buildGridConfig","containLabel","tooltip","trigger","backgroundColor","palette","grey","borderWidth","padding","textStyle","color","common","white","fontSize","fontFamily","typography","caption","axisPointer","type","position","createTooltipPositioner","buildTimeseriesTooltipFormatter","legend","buildLegendConfig","hasLegend","lineStyle","secondary","main","Object","values","qualitative","bold","xAxis","axisLine","show","axisTick","axisLabel","buildAxisLabelStyle","margin","hideOverlap","value","Date","yAxis","min","extent","niceNum","max","splitLine","black","divider","showMaxLabel","showMinLabel","verticalAlign","inside","String","createTimeseriesOptionFactory","options","optionsOverride","series","smooth","area","selection","selectionSet","length","Set","normalizeName","n","getTime","option","data","ctx","structural","mergeOptions","seriesArr","Array","isArray","dataset","seriesTemplates","broadcastTemplate","baseYAxis","baseGrid","baseTooltip","baseLegend","liveFormatter","dataZoomLayout","positionDataZoomForLegend","dataZoom","fallbackBottom","bottom","baseBottom","gridBottom","ZOOM_LAYOUT","sliderHeight","sliderGap","dimItemStyle","params","raw","name","base","has","echarts","modifyAlpha","map","s","source","_","i","template","overrideColor","resolveThemeColor","datasetIndex","encode","x","y","showSymbol","areaStyle","emphasis","focus","itemStyle","createTooltipFormatter","item","row","formattedValue","marker","seriesName","rawName","styles","container","display","flexDirection","justifyContent","gap","height","graph","flex","width","segmentA","segmentB","segmentC","alignItems","legendItem","TimeseriesSkeleton","$","_c","t0","Symbol","for","jsxs","Box","jsx","Skeleton","t1","_temp","createTimeseriesDownloadConfig","args","items","getCaptureEl","push","buildPngDownloadItem","filename","pixelRatio","pngPixelRatio","pngBackgroundColor","buildCsvDownloadItem","getRows","getData","seriesCount","timeKeys","seenKeys","point","key","add","lookups","Map","p","header","seriesNames","rows","formatTime","lookupKey","lookup","get","v","toISOString"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCO,SAASA,GAAkB;AAAA,EAChCC,OAAAA;AAAAA,EACAC,WAAAA;AAAAA,EACAC,gBAAAA;AACsB,GAA4B;AAGlD,MAAIC,IAAU,GACVC,IAAU;AAEd,SAAO;AAAA,IACLC,MAAM;AAAA,MACJC,MAAMC,SAASP,EAAMQ,QAAQ,CAAC,CAAC;AAAA,MAC/BC,KAAKF,SAASP,EAAMQ,QAAQ,CAAC,CAAC;AAAA,MAC9BE,OAAOH,SAASP,EAAMQ,QAAQ,CAAC,CAAC;AAAA;AAAA,MAEhC,GAAGG,EAAgB,IAAOX,CAAK;AAAA,MAC/BY,cAAc;AAAA,IAAA;AAAA,IAEhBC,SAAS;AAAA,MACPC,SAAS;AAAA,MACTC,iBAAiBf,EAAMgB,QAAQC,KAAK,GAAG;AAAA,MACvCC,aAAa;AAAA,MACbC,SAAS,CAACZ,SAASP,EAAMQ,QAAQ,CAAC,CAAC,GAAGD,SAASP,EAAMQ,QAA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C,EAAEC,YAAAA,IACvCD;AACT;"}
|
package/dist/widgets-v2.js
CHANGED
|
@@ -13,8 +13,8 @@ import "./lasso-tool-CDFj4zKY.js";
|
|
|
13
13
|
import "./cjs-D4KH3azB.js";
|
|
14
14
|
import { T as Xe } from "./tooltip-BDnrRKrp.js";
|
|
15
15
|
import "@carto/ps-utils";
|
|
16
|
-
import { o as Ze, a as Ke, E as Ye } from "./echart-
|
|
17
|
-
import { D as Wn } from "./echart-
|
|
16
|
+
import { o as Ze, a as Ke, E as Ye } from "./echart-Bdvbfx9s.js";
|
|
17
|
+
import { D as Wn } from "./echart-Bdvbfx9s.js";
|
|
18
18
|
import { a as Je, b as Qe, M as et } from "./markdown-BD1jcknS.js";
|
|
19
19
|
import { C as tt, L as nt, F as ot, j as rt, R as it, B as lt, Z as st, m as at, n as ct, l as dt, k as ft } from "./change-column-DjjwoPt1.js";
|
|
20
20
|
import "html2canvas";
|
|
@@ -23,7 +23,7 @@ import "react-markdown";
|
|
|
23
23
|
import { b as ut, a as gt } from "./spread-DYNpzgh_.js";
|
|
24
24
|
import { a as ht, R as yt } from "./range-l4fNHLEg.js";
|
|
25
25
|
import { f as xt, C as bt } from "./category-Dnd2_j0x.js";
|
|
26
|
-
import { c as vt, T as St } from "./table-
|
|
26
|
+
import { c as vt, T as St } from "./table-B3ZWWhJt.js";
|
|
27
27
|
function wt(t) {
|
|
28
28
|
const e = T(31), {
|
|
29
29
|
id: n,
|
package/package.json
CHANGED
|
@@ -10,10 +10,14 @@ ChatMessageOverflow.displayName = 'ChatMessageOverflow'
|
|
|
10
10
|
|
|
11
11
|
export const styles = {
|
|
12
12
|
agentMessageContainer: (theme: Theme) => ({
|
|
13
|
+
...theme.typography.body2,
|
|
13
14
|
width: '100%',
|
|
14
15
|
display: 'flex',
|
|
15
16
|
flexDirection: 'column',
|
|
16
17
|
alignItems: 'flex-start',
|
|
18
|
+
// Separate the stacked turn blocks (tools → answer text → actions) per the
|
|
19
|
+
// Figma "Chat Turn" spec (gap-8).
|
|
20
|
+
gap: theme.spacing(1),
|
|
17
21
|
paddingRight: theme.spacing(4),
|
|
18
22
|
'& + .PsChat--agent-message': {
|
|
19
23
|
marginTop: theme.spacing(1),
|
|
@@ -84,7 +88,7 @@ export const styles = {
|
|
|
84
88
|
padding: ({ spacing }) => spacing(0.75, 1.5),
|
|
85
89
|
borderRadius: ({ spacing }) => spacing(2, 2, 0.25, 2),
|
|
86
90
|
border: ({ palette }) => `1px solid ${palette.divider}`,
|
|
87
|
-
backgroundColor: ({ palette }) => palette.background.
|
|
91
|
+
backgroundColor: ({ palette }) => palette.background.paper,
|
|
88
92
|
color: ({ palette }) => palette.text.primary,
|
|
89
93
|
width: 'fit-content',
|
|
90
94
|
},
|
|
@@ -93,7 +93,10 @@ export const ChatContent = forwardRef<ChatContentRef, ChatContentProps>(
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
const mo = new MutationObserver(() => {
|
|
96
|
-
|
|
96
|
+
// Plain `?? =` rather than `??=`: the React Compiler can't yet lower
|
|
97
|
+
// logical-assignment operators, and bailing out would drop memoization
|
|
98
|
+
// for this scroll container (which re-renders on every message).
|
|
99
|
+
rafId = rafId ?? requestAnimationFrame(check)
|
|
97
100
|
})
|
|
98
101
|
mo.observe(root, {
|
|
99
102
|
childList: true,
|
|
@@ -31,4 +31,63 @@ describe('ChatFooter', () => {
|
|
|
31
31
|
fireEvent.change(input, { target: { value: 'hello' } })
|
|
32
32
|
expect(onChange).toHaveBeenCalledWith('hello')
|
|
33
33
|
})
|
|
34
|
+
|
|
35
|
+
const MODELS = [
|
|
36
|
+
{ value: 'gpt-4o', label: 'gpt-4o' },
|
|
37
|
+
{ value: 'gemini-2.5-pro', label: 'gemini-2.5-pro' },
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
test('no model selector when models is empty/undefined', () => {
|
|
41
|
+
render(<ChatFooter {...defaultProps} />)
|
|
42
|
+
expect(screen.queryByLabelText('Select model')).toBeNull()
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
test('no model selector when only one model is available', () => {
|
|
46
|
+
render(
|
|
47
|
+
<ChatFooter
|
|
48
|
+
{...defaultProps}
|
|
49
|
+
models={[{ value: 'gpt-4o', label: 'gpt-4o' }]}
|
|
50
|
+
selectedModel='gpt-4o'
|
|
51
|
+
/>,
|
|
52
|
+
)
|
|
53
|
+
expect(screen.queryByLabelText('Select model')).toBeNull()
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
test('renders the selected model label', () => {
|
|
57
|
+
render(
|
|
58
|
+
<ChatFooter {...defaultProps} models={MODELS} selectedModel='gpt-4o' />,
|
|
59
|
+
)
|
|
60
|
+
const trigger = screen.getByLabelText('Select model')
|
|
61
|
+
expect(trigger.textContent).toContain('gpt-4o')
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
test('opens the menu and fires onModelChange', () => {
|
|
65
|
+
const onModelChange = vi.fn()
|
|
66
|
+
render(
|
|
67
|
+
<ChatFooter
|
|
68
|
+
{...defaultProps}
|
|
69
|
+
models={MODELS}
|
|
70
|
+
selectedModel='gpt-4o'
|
|
71
|
+
onModelChange={onModelChange}
|
|
72
|
+
/>,
|
|
73
|
+
)
|
|
74
|
+
fireEvent.click(screen.getByLabelText('Select model'))
|
|
75
|
+
fireEvent.click(screen.getByRole('menuitem', { name: 'gemini-2.5-pro' }))
|
|
76
|
+
expect(onModelChange).toHaveBeenCalledWith('gemini-2.5-pro')
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
test('model selector is disabled while generating', () => {
|
|
80
|
+
render(
|
|
81
|
+
<ChatFooter
|
|
82
|
+
{...defaultProps}
|
|
83
|
+
models={MODELS}
|
|
84
|
+
selectedModel='gpt-4o'
|
|
85
|
+
isGenerating
|
|
86
|
+
onStop={vi.fn()}
|
|
87
|
+
/>,
|
|
88
|
+
)
|
|
89
|
+
expect(
|
|
90
|
+
screen.getByLabelText('Select model').hasAttribute('disabled'),
|
|
91
|
+
).toBeTruthy()
|
|
92
|
+
})
|
|
34
93
|
})
|