@mechane-ai/elements 0.5.1 → 0.7.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.
Files changed (44) hide show
  1. package/README.md +4 -2
  2. package/dist/ai.js +24 -23
  3. package/dist/assets/stylex.css +32 -4
  4. package/dist/{categorical-values-BfAEQUd0.js → categorical-values-75J0TUkR.js} +2 -2
  5. package/dist/{chart-frame-bX0VLC_W.js → chart-frame--DOsZKwP.js} +1 -1
  6. package/dist/{chart-input--VSrlMl-.js → chart-input-C-g586YE.js} +2 -2
  7. package/dist/charts/cartesian.js +203 -141
  8. package/dist/charts/distribution.js +2 -2
  9. package/dist/charts/graph.js +2 -2
  10. package/dist/charts/hierarchy.js +3 -3
  11. package/dist/charts/matrix.js +2 -2
  12. package/dist/charts/timeline.js +1 -1
  13. package/dist/charts.js +1 -1
  14. package/dist/{code-block-BiMcfdlB.js → code-block-D0Jmsj7w.js} +1 -1
  15. package/dist/collections.js +99 -87
  16. package/dist/content/code.js +1 -1
  17. package/dist/content/diff.js +2 -2
  18. package/dist/content/link.js +1 -1
  19. package/dist/content/markdown.js +2 -2
  20. package/dist/content/tree.js +2 -2
  21. package/dist/{content-link-Bm-Td5wm.js → content-link-HLYu0cmz.js} +1 -1
  22. package/dist/content.js +2 -2
  23. package/dist/feedback.js +1 -1
  24. package/dist/forms/dates.js +1 -1
  25. package/dist/forms.js +1 -1
  26. package/dist/index.js +1 -1
  27. package/dist/layout.js +77 -35
  28. package/dist/navigation/commands.js +1 -1
  29. package/dist/packages/ai/src/prompt-input.d.ts +2 -1
  30. package/dist/packages/charts/src/cartesian/bar-chart.d.ts +1 -0
  31. package/dist/packages/collections/src/data-table.d.ts +3 -2
  32. package/dist/packages/core/src/text.d.ts +4 -2
  33. package/dist/packages/forms/src/field-styles.d.ts +12 -0
  34. package/dist/packages/forms/src/form-controls.d.ts +1 -1
  35. package/dist/packages/forms/src/forms.d.ts +5 -3
  36. package/dist/packages/layout/src/focus-page.d.ts +4 -0
  37. package/dist/packages/layout/src/index.d.ts +2 -0
  38. package/dist/packages/layout/src/workbench.d.ts +12 -0
  39. package/dist/{pierre-tree-LY7PGy-7.js → pierre-tree-DVybsnm4.js} +2 -2
  40. package/dist/{src-CbJTK9oP.js → src-B_DCatpY.js} +1 -1
  41. package/dist/{src-CbYaLvhD.js → src-BkCsvZGi.js} +6 -2
  42. package/dist/{src-CjnbzSgq.js → src-DjTM64tN.js} +183 -170
  43. package/package.json +1 -1
  44. package/styles.css +2 -2
@@ -1,9 +1,9 @@
1
- import { i as e, n as t, r as n, t as r } from "../categorical-values-BfAEQUd0.js";
2
- import { a as i, i as a, n as o, o as s, r as c, t as l } from "../chart-frame-bX0VLC_W.js";
3
- import { n as u, r as d, t as f } from "../chart-input--VSrlMl-.js";
1
+ import { i as e, n as t, r as n, t as r } from "../categorical-values-75J0TUkR.js";
2
+ import { a as i, i as a, n as o, o as s, r as c, t as l } from "../chart-frame--DOsZKwP.js";
3
+ import { n as u, r as d, t as f } from "../chart-input-C-g586YE.js";
4
4
  import { t as p } from "../plot-width--OgdohB5.js";
5
- import { b as m } from "../src-CbYaLvhD.js";
6
- import { h } from "../src-CjnbzSgq.js";
5
+ import { b as m } from "../src-BkCsvZGi.js";
6
+ import { h } from "../src-DjTM64tN.js";
7
7
  import { colors as g } from "../tokens.js";
8
8
  import * as _ from "@stylexjs/stylex";
9
9
  import { useEffect as v, useId as y, useMemo as b, useRef as x, useState as S } from "react";
@@ -14,8 +14,8 @@ import { AreaClosed as O, Bar as k, LinePath as A } from "@visx/shape";
14
14
  var ee = { plot: {
15
15
  kqGvvJ: "x1we84gm",
16
16
  $$css: !0
17
- } };
18
- function j({ categories: e, series: n, domain: r, mode: i }) {
17
+ } }, j = /* @__PURE__ */ new Set(["Enter", " "]);
18
+ function M({ categories: e, series: n, domain: r, mode: i }) {
19
19
  if (e.length > t.items || n.length > t.series) return `Choose a window with at most ${t.items} categories and ${t.series} series.`;
20
20
  if (!d(r) || r[0] > 0 || r[1] < 0) return "The bar domain must be finite, increasing, and include zero.";
21
21
  if (!u(e) || !u(n)) return "Bar categories and series require unique identifiers.";
@@ -28,92 +28,154 @@ function j({ categories: e, series: n, domain: r, mode: i }) {
28
28
  }
29
29
  if (i === "stacked" && e.some((e, t) => n.reduce((e, n) => e + (n.values[t] ?? 0), 0) > r[1])) return "Stacked bar totals must fit the supplied domain.";
30
30
  }
31
- function M({ title: e, description: t, categories: o, series: u, domain: d, mode: m = "grouped", formatValue: h, selection: g, height: v = 200 }) {
32
- let y = j({
31
+ function N({ title: e, description: t, categories: o, series: u, domain: d, mode: m = "grouped", formatValue: h, selection: g, height: v = 200 }) {
32
+ let b = M({
33
33
  categories: o,
34
34
  series: u,
35
35
  domain: d,
36
36
  mode: m
37
- }), { ref: b, width: x } = p();
38
- if (y !== void 0 || !Number.isFinite(v) || v < 48) return /* @__PURE__ */ w(f, {
37
+ }), { ref: x, width: O } = p(), A = y(), [N, P] = S(), F = o.findIndex((e) => e.id === N?.id), I = o[F];
38
+ if (b !== void 0 || !Number.isFinite(v) || v < 48) return /* @__PURE__ */ w(f, {
39
39
  title: e,
40
40
  description: t,
41
- message: y ?? "Chart height must be at least 48 pixels."
41
+ message: b ?? "Chart height must be at least 48 pixels."
42
42
  });
43
- let S = v - 28, C = D({
43
+ let L = v - 28, R = D({
44
44
  domain: [...d],
45
- range: [S, 12]
46
- }), O = Math.max(52, ...C.ticks(3).map((e) => h(e).length * 7 + 12)), A = Math.max(O + 1, x - 16), M = E({
45
+ range: [L, 12]
46
+ }), z = Math.max(52, ...R.ticks(3).map((e) => h(e).length * 7 + 12)), B = Math.max(z + 1, O - 16), V = E({
47
47
  domain: o.map((e) => e.id),
48
- range: [O, A],
48
+ range: [z, B],
49
49
  padding: .3
50
- }), N = E({
50
+ }), H = E({
51
51
  domain: u.map((e) => e.id),
52
- range: [0, M.bandwidth()],
52
+ range: [0, V.bandwidth()],
53
53
  padding: .08
54
- }), P = Math.max(1, Math.ceil(56 / M.step())), F = Math.max(1, Math.floor(M.step() * P / 12) - 1), I = u.map((e, t) => ({
54
+ }), U = Math.min(120, Math.max(40, ...o.map((e) => (e.axisLabel ?? e.label).length * 7))), W = Math.max(1, Math.ceil((U + 16) / V.step())), G = Math.max(1, Math.floor((V.step() * W - 16) / 7)), K = u.map((e, t) => ({
55
55
  id: e.id,
56
56
  label: e.label,
57
57
  tone: n(e.tone, t)
58
58
  }));
59
+ function q(e) {
60
+ let t = e.currentTarget.getBoundingClientRect(), n = (e.clientX - t.left) / t.width * O, r = Math.floor((n - z) / V.step()), i = o[Math.max(0, Math.min(o.length - 1, r))];
61
+ i !== void 0 && P({
62
+ id: i.id,
63
+ source: "pointer"
64
+ });
65
+ }
66
+ function J(e) {
67
+ if (e.altKey || e.ctrlKey || e.metaKey) return;
68
+ if (e.key === "Escape") {
69
+ e.preventDefault(), e.stopPropagation(), P(void 0);
70
+ return;
71
+ }
72
+ if (j.has(e.key)) {
73
+ I !== void 0 && g !== void 0 && (e.preventDefault(), g.onSelect(I.id));
74
+ return;
75
+ }
76
+ let t = {
77
+ ArrowRight: Math.min(o.length - 1, F + 1),
78
+ ArrowLeft: Math.max(0, F - 1),
79
+ Home: 0,
80
+ End: o.length - 1
81
+ }[e.key], n = t === void 0 ? void 0 : o[t];
82
+ n !== void 0 && (e.preventDefault(), P({
83
+ id: n.id,
84
+ source: "keyboard"
85
+ }));
86
+ }
59
87
  return /* @__PURE__ */ T(c, {
60
88
  title: e,
61
89
  description: t,
62
90
  children: [
63
- /* @__PURE__ */ w(a, { items: I }),
91
+ /* @__PURE__ */ w(a, { items: K }),
64
92
  /* @__PURE__ */ w("div", {
65
- ref: b,
93
+ ref: x,
66
94
  ..._.props(i.plot, ee.plot),
67
95
  children: o.length === 0 || u.length === 0 ? /* @__PURE__ */ w("p", {
68
96
  className: "x153jb6y x1ghz6dp xy8obcc",
69
97
  children: "No categories"
70
98
  }) : /* @__PURE__ */ T("svg", {
71
99
  role: "img",
72
- "aria-label": e,
73
- viewBox: `0 0 ${x} ${v}`,
100
+ "aria-label": `${e}. Use arrow keys to inspect categories.${g === void 0 ? "" : " Press Enter to select."}`,
101
+ "aria-describedby": A,
102
+ tabIndex: 0,
103
+ viewBox: `0 0 ${O} ${v}`,
74
104
  height: v,
75
- ..._.props(i.svg),
76
- children: [C.ticks(3).map((e) => /* @__PURE__ */ T("g", { children: [/* @__PURE__ */ w("line", {
77
- x1: O,
78
- x2: A,
79
- y1: C(e),
80
- y2: C(e),
81
- ..._.props(i.grid)
82
- }), /* @__PURE__ */ w("text", {
83
- x: O - 8,
84
- y: C(e),
85
- textAnchor: "end",
86
- dominantBaseline: "middle",
87
- ..._.props(i.label),
88
- children: h(e)
89
- })] }, e)), o.map((e, t) => /* @__PURE__ */ T("g", { children: [u.map((r, a) => {
90
- let o = r.values[t];
91
- if (o == null) return null;
92
- let c = m === "stacked" ? u.slice(0, a).reduce((e, n) => e + (n.values[t] ?? 0), 0) : 0, l = C(c), d = C(c + o);
93
- return /* @__PURE__ */ w(k, {
94
- x: (M(e.id) ?? O) + (m === "stacked" ? 0 : N(r.id) ?? 0),
95
- y: Math.min(l, d),
96
- width: m === "stacked" ? M.bandwidth() : N.bandwidth(),
97
- height: Math.max(+(o === 0), Math.abs(d - l)),
98
- fill: s[n(r.tone, a)],
99
- ..._.props(g?.selectedId === e.id && i.selected),
100
- children: /* @__PURE__ */ T("title", { children: [
101
- e.label,
102
- " · ",
103
- r.label,
104
- ": ",
105
- h(o)
106
- ] })
107
- }, r.id);
108
- }), t % P === 0 && /* @__PURE__ */ w("text", {
109
- x: (M(e.id) ?? O) + M.bandwidth() / 2,
110
- y: v - 4,
111
- textAnchor: "middle",
112
- ..._.props(i.label),
113
- children: e.label.length > F ? `${e.label.slice(0, F)}…` : e.label
114
- })] }, e.id))]
105
+ onKeyDown: J,
106
+ onPointerMove: (e) => {
107
+ e.pointerType === "mouse" && q(e);
108
+ },
109
+ onPointerDown: q,
110
+ onPointerLeave: (e) => {
111
+ e.pointerType === "mouse" && N?.source === "pointer" && P(void 0);
112
+ },
113
+ onBlur: () => P(void 0),
114
+ onClick: () => {
115
+ I !== void 0 && g?.onSelect(I.id);
116
+ },
117
+ ..._.props(i.svg, i.focus),
118
+ children: [
119
+ I !== void 0 && /* @__PURE__ */ w("rect", {
120
+ x: (V(I.id) ?? z) - (V.step() - V.bandwidth()) / 2,
121
+ y: 12,
122
+ width: V.step(),
123
+ height: L - 12,
124
+ className: "x2wnxhi"
125
+ }),
126
+ R.ticks(3).map((e) => /* @__PURE__ */ T("g", { children: [/* @__PURE__ */ w("line", {
127
+ x1: z,
128
+ x2: B,
129
+ y1: R(e),
130
+ y2: R(e),
131
+ ..._.props(i.grid)
132
+ }), /* @__PURE__ */ w("text", {
133
+ x: z - 8,
134
+ y: R(e),
135
+ textAnchor: "end",
136
+ dominantBaseline: "middle",
137
+ ..._.props(i.label),
138
+ children: h(e)
139
+ })] }, e)),
140
+ o.map((e, t) => {
141
+ let r = e.axisLabel ?? e.label;
142
+ return /* @__PURE__ */ T("g", { children: [u.map((r, a) => {
143
+ let o = r.values[t];
144
+ if (o == null) return null;
145
+ let c = m === "stacked" ? u.slice(0, a).reduce((e, n) => e + (n.values[t] ?? 0), 0) : 0, l = R(c), d = R(c + o), f = g?.selectedId === e.id || I?.id === e.id;
146
+ return /* @__PURE__ */ w(k, {
147
+ x: (V(e.id) ?? z) + (m === "stacked" ? 0 : H(r.id) ?? 0),
148
+ y: Math.min(l, d),
149
+ width: m === "stacked" ? V.bandwidth() : H.bandwidth(),
150
+ height: Math.max(+(o === 0), Math.abs(d - l)),
151
+ fill: s[n(r.tone, a)],
152
+ ..._.props(f && i.selected)
153
+ }, r.id);
154
+ }), t % W === 0 && /* @__PURE__ */ w("text", {
155
+ x: (V(e.id) ?? z) + V.bandwidth() / 2,
156
+ y: v - 4,
157
+ textAnchor: "middle",
158
+ ..._.props(i.label),
159
+ children: r.length > G ? `${r.slice(0, G - 1)}…` : r
160
+ })] }, e.id);
161
+ })
162
+ ]
115
163
  })
116
164
  }),
165
+ o.length > 0 && u.length > 0 && /* @__PURE__ */ w("div", {
166
+ id: A,
167
+ "aria-live": N?.source === "keyboard" ? "polite" : "off",
168
+ className: "x78zum5 x1a02dak x1n8ia3y x1mqbd49 xy8obcc xas2l8k xss6m8b",
169
+ children: I === void 0 ? /* @__PURE__ */ w("span", {
170
+ className: "x153jb6y x1ghz6dp xy8obcc",
171
+ children: "Point, tap, or use the arrow keys to inspect values."
172
+ }) : /* @__PURE__ */ T(C, { children: [/* @__PURE__ */ w("span", { children: I.label }), u.map((e) => /* @__PURE__ */ T("span", { children: [
173
+ e.label,
174
+ ":",
175
+ " ",
176
+ e.values[F] === null || e.values[F] === void 0 ? "Unavailable" : h(e.values[F])
177
+ ] }, e.id))] })
178
+ }),
117
179
  /* @__PURE__ */ w(l, { children: /* @__PURE__ */ w(r, {
118
180
  items: o.map((e, t) => ({
119
181
  id: e.id,
@@ -127,12 +189,12 @@ function M({ title: e, description: t, categories: o, series: u, domain: d, mode
127
189
  });
128
190
  }
129
191
  // packages/charts/src/cartesian/breakdown-bar.tsx
130
- var N = {
192
+ var P = {
131
193
  kzqmXN: "x5lhr3w",
132
194
  kZKoxP: "x5yr21d",
133
195
  $$css: !0
134
- }, P = { segment: (e, t) => [
135
- N,
196
+ }, F = { segment: (e, t) => [
197
+ P,
136
198
  {
137
199
  kWkggS: t == null ? t : "xl8spv7",
138
200
  $$css: !0
@@ -142,7 +204,7 @@ var N = {
142
204
  "--x-backgroundColor": t ?? void 0
143
205
  }
144
206
  ] };
145
- function F({ title: t, description: i, items: a, total: o, formatValue: l, selection: u }) {
207
+ function I({ title: t, description: i, items: a, total: o, formatValue: l, selection: u }) {
146
208
  let d = e(a), p = a.reduce((e, t) => e + (t.value ?? 0), 0), m = 2 ** -52 * Math.max(p, o, 1) * a.length;
147
209
  return d === void 0 ? !Number.isFinite(o) || o < 0 || p - o > m ? /* @__PURE__ */ w(f, {
148
210
  title: t,
@@ -158,7 +220,7 @@ function F({ title: t, description: i, items: a, total: o, formatValue: l, selec
158
220
  /* @__PURE__ */ w("div", {
159
221
  "aria-hidden": !0,
160
222
  className: "x78zum5 x170jfvy xb3r6kr x1r7kqkb xmkeg23 x1y0btm7 x1ey3b81 x1jfksii",
161
- children: a.map((e, t) => e.value === null ? null : /* @__PURE__ */ w("span", { ..._.props(P.segment(o === 0 ? 0 : e.value / o * 100, s[n(e.tone, t)])) }, e.id))
223
+ children: a.map((e, t) => e.value === null ? null : /* @__PURE__ */ w("span", { ..._.props(F.segment(o === 0 ? 0 : e.value / o * 100, s[n(e.tone, t)])) }, e.id))
162
224
  }),
163
225
  /* @__PURE__ */ w(r, {
164
226
  items: a.map((e, t) => ({
@@ -186,12 +248,12 @@ function F({ title: t, description: i, items: a, total: o, formatValue: l, selec
186
248
  });
187
249
  }
188
250
  // packages/charts/src/cartesian/scatter-plot.tsx
189
- var I = 260, L = 56, R = 20, z = 12, B = 1e3, V = {
251
+ var L = 260, R = 56, z = 20, B = 12, V = 1e3, H = {
190
252
  kzqmXN: "x1xc55vz",
191
253
  kZKoxP: "xdk7pt",
192
254
  kaIpWk: "x16rqkct",
193
255
  $$css: !0
194
- }, H = {
256
+ }, U = {
195
257
  brush: {
196
258
  kFalU9: "xx69xxh",
197
259
  kkrTdU: "xsid9ct",
@@ -228,7 +290,7 @@ var I = 260, L = 56, R = 20, z = 12, B = 1e3, V = {
228
290
  "--x-top": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(t)
229
291
  }],
230
292
  dot: (e) => [
231
- V,
293
+ H,
232
294
  {
233
295
  kWkggS: e == null ? e : "xl8spv7",
234
296
  $$css: !0
@@ -243,8 +305,8 @@ var I = 260, L = 56, R = 20, z = 12, B = 1e3, V = {
243
305
  $$css: !0
244
306
  }
245
307
  };
246
- function U(e) {
247
- let { title: t, description: n, points: r, xDomain: i, yDomain: a, xLabel: u, yLabel: d, formatX: m, formatY: h, selection: g, rangeSelection: v, emptyLabel: y } = e, { ref: b, width: x } = p(), S = K(e);
308
+ function W(e) {
309
+ let { title: t, description: n, points: r, xDomain: i, yDomain: a, xLabel: u, yLabel: d, formatX: m, formatY: h, selection: g, rangeSelection: v, emptyLabel: y } = e, { ref: b, width: x } = p(), S = q(e);
248
310
  if (S !== null) return /* @__PURE__ */ w(f, {
249
311
  title: t,
250
312
  description: n,
@@ -252,10 +314,10 @@ function U(e) {
252
314
  });
253
315
  let C = D({
254
316
  domain: [...i],
255
- range: [L, Math.max(L, x - R)]
317
+ range: [R, Math.max(R, x - z)]
256
318
  }), E = D({
257
319
  domain: [...a],
258
- range: [216, z]
320
+ range: [216, B]
259
321
  });
260
322
  return /* @__PURE__ */ T(c, {
261
323
  title: t,
@@ -267,7 +329,7 @@ function U(e) {
267
329
  }) : /* @__PURE__ */ T("div", {
268
330
  ref: b,
269
331
  className: "x1n2onr6 xeuugli",
270
- children: [/* @__PURE__ */ w(W, {
332
+ children: [/* @__PURE__ */ w(G, {
271
333
  width: x,
272
334
  scaleX: C,
273
335
  scaleY: E,
@@ -280,15 +342,15 @@ function U(e) {
280
342
  "aria-label": `${e.label}, ${u}: ${m(e.x)}, ${d}: ${h(e.y)}`,
281
343
  "aria-pressed": g.selectedId === e.id,
282
344
  onClick: () => g.onSelect(e.id),
283
- ..._.props(H.target, H.location(C(e.x), E(e.y))),
345
+ ..._.props(U.target, U.location(C(e.x), E(e.y))),
284
346
  children: /* @__PURE__ */ w("span", {
285
347
  "aria-hidden": !0,
286
- ..._.props(H.dot(s[e.tone]), g.selectedId === e.id && H.selected)
348
+ ..._.props(U.dot(s[e.tone]), g.selectedId === e.id && U.selected)
287
349
  })
288
350
  }, e.id))
289
351
  })]
290
352
  }),
291
- v !== void 0 && /* @__PURE__ */ w(G, {
353
+ v !== void 0 && /* @__PURE__ */ w(K, {
292
354
  ...e,
293
355
  rangeSelection: v
294
356
  }),
@@ -308,7 +370,7 @@ function U(e) {
308
370
  ]
309
371
  });
310
372
  }
311
- function W({ width: e, scaleX: t, scaleY: n, points: r, xLabel: a, yLabel: o, formatX: c, formatY: l, selection: u, rangeSelection: d }) {
373
+ function G({ width: e, scaleX: t, scaleY: n, points: r, xLabel: a, yLabel: o, formatX: c, formatY: l, selection: u, rangeSelection: d }) {
312
374
  let f = y(), [p, m] = S(null), h = p === null ? d?.value : {
313
375
  x: [Math.min(p.start.x, p.end.x), Math.max(p.start.x, p.end.x)],
314
376
  y: [Math.min(p.start.y, p.end.y), Math.max(p.start.y, p.end.y)]
@@ -317,13 +379,13 @@ function W({ width: e, scaleX: t, scaleY: n, points: r, xLabel: a, yLabel: o, fo
317
379
  let i = r.currentTarget.getBoundingClientRect();
318
380
  return {
319
381
  x: t.copy().clamp(!0).invert((r.clientX - i.left) / i.width * e),
320
- y: n.copy().clamp(!0).invert((r.clientY - i.top) / i.height * I)
382
+ y: n.copy().clamp(!0).invert((r.clientY - i.top) / i.height * L)
321
383
  };
322
384
  }
323
385
  function v(t) {
324
386
  if (d === void 0 || t.button !== 0 || t.pointerType === "touch") return;
325
- let n = t.currentTarget.getBoundingClientRect(), r = (t.clientX - n.left) / n.width * e, i = (t.clientY - n.top) / n.height * I;
326
- if (r < L || r > e - R || i < z || i > 216) return;
387
+ let n = t.currentTarget.getBoundingClientRect(), r = (t.clientX - n.left) / n.width * e, i = (t.clientY - n.top) / n.height * L;
388
+ if (r < R || r > e - z || i < B || i > 216) return;
327
389
  let a = g(t);
328
390
  t.currentTarget.setPointerCapture(t.pointerId), m({
329
391
  start: a,
@@ -347,29 +409,29 @@ function W({ width: e, scaleX: t, scaleY: n, points: r, xLabel: a, yLabel: o, fo
347
409
  }
348
410
  return /* @__PURE__ */ T("svg", {
349
411
  width: e,
350
- height: I,
351
- viewBox: `0 0 ${e} ${I}`,
412
+ height: L,
413
+ viewBox: `0 0 ${e} ${L}`,
352
414
  "aria-hidden": !0,
353
415
  onPointerDown: v,
354
416
  onPointerMove: b,
355
417
  onPointerUp: x,
356
418
  onPointerCancel: () => m(null),
357
419
  onLostPointerCapture: () => m(null),
358
- ..._.props(i.svg, d !== void 0 && H.brush),
420
+ ..._.props(i.svg, d !== void 0 && U.brush),
359
421
  children: [
360
422
  /* @__PURE__ */ w("defs", { children: /* @__PURE__ */ w("clipPath", {
361
423
  id: f,
362
424
  children: /* @__PURE__ */ w("rect", {
363
- x: L,
364
- y: z,
365
- width: Math.max(0, e - L - R),
425
+ x: R,
426
+ y: B,
427
+ width: Math.max(0, e - R - z),
366
428
  height: 204
367
429
  })
368
430
  }) }),
369
431
  t.ticks(5).map((e) => /* @__PURE__ */ T("g", { children: [/* @__PURE__ */ w("line", {
370
432
  x1: t(e),
371
433
  x2: t(e),
372
- y1: z,
434
+ y1: B,
373
435
  y2: 216,
374
436
  ..._.props(i.grid)
375
437
  }), /* @__PURE__ */ w("text", {
@@ -380,8 +442,8 @@ function W({ width: e, scaleX: t, scaleY: n, points: r, xLabel: a, yLabel: o, fo
380
442
  children: c(e)
381
443
  })] }, e)),
382
444
  n.ticks(4).map((t) => /* @__PURE__ */ T("g", { children: [/* @__PURE__ */ w("line", {
383
- x1: L,
384
- x2: e - R,
445
+ x1: R,
446
+ x2: e - z,
385
447
  y1: n(t),
386
448
  y2: n(t),
387
449
  ..._.props(i.grid)
@@ -393,7 +455,7 @@ function W({ width: e, scaleX: t, scaleY: n, points: r, xLabel: a, yLabel: o, fo
393
455
  children: l(t)
394
456
  })] }, t)),
395
457
  /* @__PURE__ */ w("text", {
396
- x: (L + e - R) / 2,
458
+ x: (R + e - z) / 2,
397
459
  y: 256,
398
460
  textAnchor: "middle",
399
461
  ..._.props(i.label),
@@ -425,7 +487,7 @@ function W({ width: e, scaleX: t, scaleY: n, points: r, xLabel: a, yLabel: o, fo
425
487
  ]
426
488
  });
427
489
  }
428
- function G({ rangeSelection: e, xDomain: t, yDomain: n, xLabel: r, yLabel: i, formatX: a, formatY: o }) {
490
+ function K({ rangeSelection: e, xDomain: t, yDomain: n, xLabel: r, yLabel: i, formatX: a, formatY: o }) {
429
491
  let s = e.value ?? {
430
492
  x: t,
431
493
  y: n
@@ -510,9 +572,9 @@ function G({ rangeSelection: e, xDomain: t, yDomain: n, xLabel: r, yLabel: i, fo
510
572
  ]
511
573
  });
512
574
  }
513
- function K({ points: e, xDomain: t, yDomain: n, rangeSelection: r }) {
575
+ function q({ points: e, xDomain: t, yDomain: n, rangeSelection: r }) {
514
576
  if (!d(t) || !d(n)) return "Scatter domains must contain finite, increasing endpoints.";
515
- if (e.length > 1e3) return `This plot exceeds the ${B}-point render limit. Supply a smaller, labelled sample.`;
577
+ if (e.length > 1e3) return `This plot exceeds the ${V}-point render limit. Supply a smaller, labelled sample.`;
516
578
  if (!u(e)) return "Scatter points must have unique identifiers.";
517
579
  if (e.some((e) => !Number.isFinite(e.x) || !Number.isFinite(e.y))) return "Scatter coordinates must be finite.";
518
580
  if (e.some((e) => {
@@ -523,13 +585,13 @@ function K({ points: e, xDomain: t, yDomain: n, rangeSelection: r }) {
523
585
  let i = Number.isFinite(r.xStep) && r.xStep > 0 && r.xStep <= t[1] - t[0], a = Number.isFinite(r.yStep) && r.yStep > 0 && r.yStep <= n[1] - n[0];
524
586
  if (!i || !a) return "Range selection steps must be finite, positive, and no larger than their domain span.";
525
587
  let o = r.value;
526
- return o === null ? null : !q(o.x, t) || !q(o.y, n) ? "The selected range must have finite, ordered bounds inside the declared domain." : null;
588
+ return o === null ? null : !J(o.x, t) || !J(o.y, n) ? "The selected range must have finite, ordered bounds inside the declared domain." : null;
527
589
  }
528
- function q(e, t) {
590
+ function J(e, t) {
529
591
  return !e.every(Number.isFinite) || e[0] > e[1] ? !1 : e[0] >= t[0] && e[1] <= t[1];
530
592
  }
531
593
  // packages/charts/src/cartesian/time-series-data.ts
532
- var J = {
594
+ var Y = {
533
595
  series: 12,
534
596
  pointsPerSeries: 2e3,
535
597
  markers: 200,
@@ -544,11 +606,11 @@ var J = {
544
606
  ];
545
607
  function re({ series: e, isStacked: t, markers: n }) {
546
608
  let r = e[0]?.points.map((e) => e.timestamp) ?? [];
547
- if (e.length > J.series || r.length > J.pointsPerSeries || n.length > J.markers) return `Choose a window with at most ${J.series} series, ${J.pointsPerSeries} observations per series, and ${J.markers} markers.`;
609
+ if (e.length > Y.series || r.length > Y.pointsPerSeries || n.length > Y.markers) return `Choose a window with at most ${Y.series} series, ${Y.pointsPerSeries} observations per series, and ${Y.markers} markers.`;
548
610
  if (!u(e) || !u(n)) return "Series and markers require unique identifiers.";
549
611
  for (let n of e) {
550
612
  if (n.points.length !== r.length) return "Every series must supply the same observation timestamps.";
551
- let e = se({
613
+ let e = X({
552
614
  points: n.points,
553
615
  timestamps: r,
554
616
  isStacked: t
@@ -609,7 +671,7 @@ function oe(e, t) {
609
671
  };
610
672
  });
611
673
  }
612
- function se({ points: e, timestamps: t, isStacked: n }) {
674
+ function X({ points: e, timestamps: t, isStacked: n }) {
613
675
  for (let [r, i] of e.entries()) {
614
676
  let a = e[r - 1], o = a !== void 0 && i.timestamp <= a.timestamp;
615
677
  if (!Number.isFinite(i.timestamp) || i.timestamp !== t[r] || o) return "Observation timestamps must be finite, aligned, and strictly increasing.";
@@ -618,7 +680,7 @@ function se({ points: e, timestamps: t, isStacked: n }) {
618
680
  }
619
681
  }
620
682
  // packages/charts/src/cartesian/time-series-line.tsx
621
- function ce({ series: e, x: t, y: n, inspectedTimestamp: r, pointRadius: a = 3 }) {
683
+ function se({ series: e, x: t, y: n, inspectedTimestamp: r, pointRadius: a = 3 }) {
622
684
  return /* @__PURE__ */ T(C, { children: [/* @__PURE__ */ w(A, {
623
685
  data: [...e.points],
624
686
  defined: (e) => e.value !== null,
@@ -638,8 +700,8 @@ function ce({ series: e, x: t, y: n, inspectedTimestamp: r, pointRadius: a = 3 }
638
700
  }, r.timestamp))] });
639
701
  }
640
702
  // packages/charts/src/cartesian/sparkline.tsx
641
- function Y({ title: e, summary: t, unit: n, timestampUnit: r, series: i, valueDomain: a }) {
642
- let o = y(), s = y(), c = le({
703
+ function ce({ title: e, summary: t, unit: n, timestampUnit: r, series: i, valueDomain: a }) {
704
+ let o = y(), s = y(), c = Z({
643
705
  title: e,
644
706
  summary: t,
645
707
  unit: n,
@@ -692,7 +754,7 @@ function Y({ title: e, summary: t, unit: n, timestampUnit: r, series: i, valueDo
692
754
  "."
693
755
  ]
694
756
  }),
695
- m !== void 0 && /* @__PURE__ */ w(ce, {
757
+ m !== void 0 && /* @__PURE__ */ w(se, {
696
758
  series: m,
697
759
  x: f,
698
760
  y: p,
@@ -701,7 +763,7 @@ function Y({ title: e, summary: t, unit: n, timestampUnit: r, series: i, valueDo
701
763
  ]
702
764
  });
703
765
  }
704
- function le({ title: e, summary: t, unit: n, series: r, valueDomain: i }) {
766
+ function Z({ title: e, summary: t, unit: n, series: r, valueDomain: i }) {
705
767
  if (e.trim() === "" || t.trim() === "" || n.trim() === "") return "A trend requires a title, a readable summary, and a value unit.";
706
768
  if (!d(i)) return "The displayed value domain must have finite, increasing bounds.";
707
769
  let a = re({
@@ -713,7 +775,7 @@ function le({ title: e, summary: t, unit: n, series: r, valueDomain: i }) {
713
775
  if (r.points.some((e) => e.value !== null && (e.value < i[0] || e.value > i[1]))) return "Every recorded value must be inside the declared value domain.";
714
776
  }
715
777
  // packages/charts/src/cartesian/time-series.tsx
716
- var ue = { plot: {
778
+ var le = { plot: {
717
779
  k7Eaqz: "xeuugli",
718
780
  kInvED: "x1hl8ikr",
719
781
  kZs9gx: "x19rmrnh",
@@ -721,21 +783,21 @@ var ue = { plot: {
721
783
  kPJHz1: "x13qnu6",
722
784
  $$css: !0
723
785
  } };
724
- function X(e) {
786
+ function ue(e) {
725
787
  return /* @__PURE__ */ w($, {
726
788
  ...e,
727
789
  kind: "line",
728
790
  stacked: !1
729
791
  });
730
792
  }
731
- function Z({ stacked: e = !1, ...t }) {
793
+ function Q({ stacked: e = !1, ...t }) {
732
794
  return /* @__PURE__ */ w($, {
733
795
  ...t,
734
796
  kind: "area",
735
797
  stacked: e
736
798
  });
737
799
  }
738
- function Q({ charts: e, ...t }) {
800
+ function de({ charts: e, ...t }) {
739
801
  let n = x(null), [r, i] = S(), a = JSON.stringify(e.map((e) => [
740
802
  e.id,
741
803
  e.title,
@@ -755,9 +817,9 @@ function Q({ charts: e, ...t }) {
755
817
  title: "Small multiples",
756
818
  message: "Charts need unique identifiers and aligned observation timestamps."
757
819
  });
758
- if (e.length > J.panels) return /* @__PURE__ */ w(f, {
820
+ if (e.length > Y.panels) return /* @__PURE__ */ w(f, {
759
821
  title: "Small multiples",
760
- message: `Choose at most ${J.panels} panels.`
822
+ message: `Choose at most ${Y.panels} panels.`
761
823
  });
762
824
  if (e.length === 0) return /* @__PURE__ */ w(c, {
763
825
  title: "Small multiples",
@@ -827,27 +889,27 @@ function $({ title: e, description: t, series: n, timestampUnit: r, formatTimest
827
889
  children: "No observations"
828
890
  })
829
891
  });
830
- let W = m - 28, G = N[0]?.timestamp ?? 0, K = N.at(-1)?.timestamp ?? G, q = M.flatMap((e) => e.points.flatMap((e) => e.value === null ? [] : [e.value + e.base])), J = E === "area" ? Math.min(0, ...q) : Math.min(...q), te = E === "area" ? Math.max(0, ...q) : Math.max(...q), ne = q.length === 0 ? 0 : J, se = q.length === 0 ? 1 : te, Y = D({
831
- domain: [...ae(ne, se, E === "area")],
892
+ let W = m - 28, G = N[0]?.timestamp ?? 0, K = N.at(-1)?.timestamp ?? G, q = M.flatMap((e) => e.points.flatMap((e) => e.value === null ? [] : [e.value + e.base])), J = E === "area" ? Math.min(0, ...q) : Math.min(...q), Y = E === "area" ? Math.max(0, ...q) : Math.max(...q), te = q.length === 0 ? 0 : J, ne = q.length === 0 ? 1 : Y, X = D({
893
+ domain: [...ae(te, ne, E === "area")],
832
894
  range: [W, 12]
833
- }), le = Y.ticks(3), X = ee ?? Math.max(52, ...le.map((e) => u(e).length * 7 + 12)), Z = Math.max(X + 1, F - 16), Q = D({
895
+ }), ce = X.ticks(3), Z = ee ?? Math.max(52, ...ce.map((e) => u(e).length * 7 + 12)), ue = Math.max(Z + 1, F - 16), Q = D({
834
896
  domain: [...ae(G, K)],
835
- range: [X, Z]
897
+ range: [Z, ue]
836
898
  });
837
- function $(e) {
899
+ function de(e) {
838
900
  let t = I?.getBoundingClientRect();
839
901
  if (t === void 0) return;
840
902
  let n = Q.invert(e - t.left), r = N.find((e, t) => {
841
903
  let r = N[t + 1];
842
904
  return r === void 0 || n <= e.timestamp + (r.timestamp - e.timestamp) / 2;
843
905
  });
844
- r !== void 0 && de({
906
+ r !== void 0 && $({
845
907
  signature: B,
846
908
  timestamp: r.timestamp,
847
909
  source: "pointer"
848
910
  });
849
911
  }
850
- function de(e) {
912
+ function $(e) {
851
913
  A === void 0 ? z(e) : A.onChange(e);
852
914
  }
853
915
  function fe(e) {
@@ -859,7 +921,7 @@ function $({ title: e, description: t, series: n, timestampUnit: r, formatTimest
859
921
  };
860
922
  switch (e.key) {
861
923
  case "Escape":
862
- e.preventDefault(), de(void 0);
924
+ e.preventDefault(), $(void 0);
863
925
  break;
864
926
  case "ArrowRight":
865
927
  case "ArrowLeft":
@@ -867,7 +929,7 @@ function $({ title: e, description: t, series: n, timestampUnit: r, formatTimest
867
929
  case "End": {
868
930
  e.preventDefault();
869
931
  let t = N[n[e.key]];
870
- t !== void 0 && de({
932
+ t !== void 0 && $({
871
933
  signature: B,
872
934
  timestamp: t.timestamp,
873
935
  source: "keyboard"
@@ -903,20 +965,20 @@ function $({ title: e, description: t, series: n, timestampUnit: r, formatTimest
903
965
  height: m,
904
966
  onKeyDown: fe,
905
967
  onPointerMove: (e) => {
906
- e.pointerType === "mouse" && $(e.clientX);
968
+ e.pointerType === "mouse" && de(e.clientX);
907
969
  },
908
- onPointerDown: (e) => $(e.clientX),
909
- ..._.props(i.svg, ue.plot),
970
+ onPointerDown: (e) => de(e.clientX),
971
+ ..._.props(i.svg, le.plot),
910
972
  children: [
911
- le.map((e) => /* @__PURE__ */ T("g", { children: [/* @__PURE__ */ w("line", {
912
- x1: X,
913
- x2: Z,
914
- y1: Y(e),
915
- y2: Y(e),
973
+ ce.map((e) => /* @__PURE__ */ T("g", { children: [/* @__PURE__ */ w("line", {
974
+ x1: Z,
975
+ x2: ue,
976
+ y1: X(e),
977
+ y2: X(e),
916
978
  ..._.props(i.grid)
917
979
  }), /* @__PURE__ */ w("text", {
918
- x: X - 8,
919
- y: Y(e),
980
+ x: Z - 8,
981
+ y: X(e),
920
982
  textAnchor: "end",
921
983
  dominantBaseline: "middle",
922
984
  ..._.props(i.label),
@@ -926,15 +988,15 @@ function $({ title: e, description: t, series: n, timestampUnit: r, formatTimest
926
988
  data: [...e.points],
927
989
  defined: (e) => e.value !== null,
928
990
  x: (e) => Q(e.timestamp),
929
- y0: (e) => Y(e.base),
930
- y1: (e) => Y((e.value ?? 0) + e.base),
931
- yScale: Y,
991
+ y0: (e) => X(e.base),
992
+ y1: (e) => X((e.value ?? 0) + e.base),
993
+ yScale: X,
932
994
  fill: s[e.tone],
933
995
  fillOpacity: k ? .65 : .15
934
- }), /* @__PURE__ */ w(ce, {
996
+ }), /* @__PURE__ */ w(se, {
935
997
  series: e,
936
998
  x: Q,
937
- y: Y,
999
+ y: X,
938
1000
  inspectedTimestamp: V?.timestamp
939
1001
  })] }, e.id)),
940
1002
  d.map((e) => /* @__PURE__ */ T("g", { children: [e.kind === "time" ? /* @__PURE__ */ w("line", {
@@ -945,7 +1007,7 @@ function $({ title: e, description: t, series: n, timestampUnit: r, formatTimest
945
1007
  className: "xhq4mlf x1ntoi03 x13efnbd"
946
1008
  }) : /* @__PURE__ */ w("circle", {
947
1009
  cx: Q(e.timestamp),
948
- cy: Y(e.value + (M.find((t) => t.id === e.seriesId)?.points.find((t) => t.timestamp === e.timestamp)?.base ?? 0)),
1010
+ cy: X(e.value + (M.find((t) => t.id === e.seriesId)?.points.find((t) => t.timestamp === e.timestamp)?.base ?? 0)),
949
1011
  r: 4,
950
1012
  fill: g.surface,
951
1013
  ..._.props(i.selected)
@@ -958,13 +1020,13 @@ function $({ title: e, description: t, series: n, timestampUnit: r, formatTimest
958
1020
  className: "xhq4mlf x1ntoi03 x13efnbd"
959
1021
  }),
960
1022
  /* @__PURE__ */ w("text", {
961
- x: X,
1023
+ x: Z,
962
1024
  y: m - 4,
963
1025
  ..._.props(i.label),
964
1026
  children: o(G)
965
1027
  }),
966
1028
  K !== G && /* @__PURE__ */ w("text", {
967
- x: Z,
1029
+ x: ue,
968
1030
  y: m - 4,
969
1031
  textAnchor: "end",
970
1032
  ..._.props(i.label),
@@ -1037,4 +1099,4 @@ function $({ title: e, description: t, series: n, timestampUnit: r, formatTimest
1037
1099
  })
1038
1100
  });
1039
1101
  }
1040
- export { Z as AreaChart, M as BarChart, F as BreakdownBar, X as LineChart, B as MAX_SCATTER_POINTS, U as ScatterPlot, Q as SmallMultiples, Y as Sparkline, J as timeSeriesLimits };
1102
+ export { Q as AreaChart, N as BarChart, I as BreakdownBar, ue as LineChart, V as MAX_SCATTER_POINTS, W as ScatterPlot, de as SmallMultiples, ce as Sparkline, Y as timeSeriesLimits };