@mechane-ai/elements 0.42.0 → 0.43.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 +32 -32
  2. package/dist/catalog.json +89 -1
  3. package/dist/{categorical-values-B6lGI7BH.js → categorical-values-DzhbfZ5w.js} +2 -2
  4. package/dist/{chart-frame-D0enjyj9.js → chart-frame-9dQQNF3F.js} +73 -21
  5. package/dist/{chart-input-D4_Awave.js → chart-input-DT0STflx.js} +1 -1
  6. package/dist/{chart-navigation-D4-pdgpj.js → chart-navigation-BAbb5PV9.js} +56 -32
  7. package/dist/charts/cartesian.js +1696 -547
  8. package/dist/charts/distribution.js +4 -4
  9. package/dist/charts/graph.js +442 -75
  10. package/dist/charts/hierarchy.js +4 -4
  11. package/dist/charts/matrix.js +231 -62
  12. package/dist/charts/timeline.js +2 -2
  13. package/dist/charts.js +1 -1
  14. package/dist/label-spacing-BncjePGb.js +6 -0
  15. package/dist/packages/charts/src/cartesian/bar-chart.d.ts +15 -3
  16. package/dist/packages/charts/src/cartesian/bar-data.d.ts +43 -0
  17. package/dist/packages/charts/src/cartesian/bar-overlays.d.ts +32 -0
  18. package/dist/packages/charts/src/cartesian/bridge-chart.d.ts +29 -0
  19. package/dist/packages/charts/src/cartesian/bridge-data.d.ts +40 -0
  20. package/dist/packages/charts/src/cartesian/index.d.ts +7 -2
  21. package/dist/packages/charts/src/cartesian/reference-lines.d.ts +34 -0
  22. package/dist/packages/charts/src/cartesian/sparkline.d.ts +10 -1
  23. package/dist/packages/charts/src/cartesian/time-series-bands.d.ts +66 -0
  24. package/dist/packages/charts/src/cartesian/time-series-data.d.ts +11 -1
  25. package/dist/packages/charts/src/cartesian/time-series-overlays.d.ts +35 -0
  26. package/dist/packages/charts/src/cartesian/time-series.d.ts +6 -1
  27. package/dist/packages/charts/src/chart-inspection.d.ts +3 -1
  28. package/dist/packages/charts/src/chart-navigation.d.ts +3 -1
  29. package/dist/packages/charts/src/chart-series-marker.d.ts +8 -1
  30. package/dist/packages/charts/src/chart-surface.d.ts +2 -0
  31. package/dist/packages/charts/src/chart-theme.d.ts +26 -0
  32. package/dist/packages/charts/src/graph/flow-diagram.d.ts +26 -0
  33. package/dist/packages/charts/src/graph/flow-layout.d.ts +70 -0
  34. package/dist/packages/charts/src/graph/index.d.ts +2 -0
  35. package/dist/packages/charts/src/index.d.ts +1 -1
  36. package/dist/packages/charts/src/label-spacing.d.ts +15 -0
  37. package/dist/packages/charts/src/matrix/matrix-cells.d.ts +4 -0
  38. package/dist/packages/charts/src/matrix/matrix-strip.d.ts +20 -0
  39. package/dist/packages/charts/src/matrix/matrix-types.d.ts +21 -0
  40. package/dist/packages/charts/src/matrix/matrix.d.ts +8 -19
  41. package/dist/{plot-width-BQQS-mw9.js → plot-width-DzCmthQW.js} +28 -0
  42. package/dist/styles2.css +115 -0
  43. package/package.json +1 -1
  44. package/recipes/allocation-report.tsx +115 -0
@@ -1,8 +1,8 @@
1
1
  import { c as e } from "../src-BpvnBWrF.js";
2
2
  import { r as t } from "../tokens.stylex-dF5CACEJ.js";
3
- import { n, r, t as i } from "../chart-input-D4_Awave.js";
4
- import { a, i as o, n as s, t as c } from "../chart-navigation-D4-pdgpj.js";
5
- import { i as l, n as u } from "../chart-frame-D0enjyj9.js";
3
+ import { n, r, t as i } from "../chart-input-DT0STflx.js";
4
+ import { a, i as o, n as s, t as c } from "../chart-navigation-BAbb5PV9.js";
5
+ import { i as l, n as u } from "../chart-frame-9dQQNF3F.js";
6
6
  import * as d from "@stylexjs/stylex";
7
7
  import { Button as f } from "@ui-sdk/react/button";
8
8
  import { jsx as p, jsxs as m } from "react/jsx-runtime";
@@ -72,11 +72,157 @@ function S({ label: e, domain: t, palette: n, formatValue: r }) {
72
72
  ]
73
73
  });
74
74
  }
75
+ function C(e, t, n) {
76
+ switch (e.kind) {
77
+ case "masked": return "×";
78
+ case "missing": return "—";
79
+ case "value": return n ? "!" : t.length <= 6 ? t : e.value === 0 ? "0" : "•";
80
+ }
81
+ }
82
+ function w(e, t, n) {
83
+ if (e === void 0) return "Not supplied";
84
+ switch (e.kind) {
85
+ case "value": return `${n(e.value)}${_(e.value, t) ? "" : " (outside domain)"}`;
86
+ case "masked": return `Masked: ${e.reason}`;
87
+ case "missing": return `Missing: ${e.reason}`;
88
+ }
89
+ }
90
+ // packages/charts/src/matrix/matrix-strip.tsx
91
+ var T = {
92
+ k1xSpc: "xrvj5dj",
93
+ kumcoG: "xqketvx",
94
+ k1C7PZ: "xuwhhnn",
95
+ khm7nJ: "x1hm1d26",
96
+ kGNEyG: "x6s0dn4",
97
+ k7Eaqz: "xeuugli",
98
+ kMv6JI: "x1hz01jw",
99
+ $$css: !0
100
+ }, E = {
101
+ kKwaWg: "x1e87kdn",
102
+ $$css: !0
103
+ }, D = {
104
+ grid: (e) => [T, { "--x-gridTemplateColumns": `minmax(48px, max-content) repeat(${e}, minmax(14px, 1fr))` == null ? void 0 : `minmax(48px, max-content) repeat(${e}, minmax(14px, 1fr))` }],
105
+ cell: {
106
+ k1xSpc: "x78zum5",
107
+ kGNEyG: "x6s0dn4",
108
+ kjj79g: "xl56j7k",
109
+ kB7OPa: "x9f619",
110
+ kzqmXN: "xh8yej3",
111
+ kZKoxP: "x17rw0jw x1ilzfib",
112
+ kogj98: "x1ghz6dp",
113
+ kmVPX3: "x1717udv",
114
+ kMzoRj: "xmkeg23",
115
+ ksu8eU: "x1y0btm7",
116
+ kVAM5u: "x1ey3b81",
117
+ kWkggS: "xpvm0e4",
118
+ kMwMTN: "x153jb6y",
119
+ kMv6JI: "x1hz01jw",
120
+ kGuDYH: "xy8obcc",
121
+ kLWn49: "xo5v014",
122
+ $$css: !0
123
+ },
124
+ measured: (e) => [E, { "--x-backgroundImage": `linear-gradient(${e}, ${e})` == null ? void 0 : `linear-gradient(${e}, ${e})` }],
125
+ empty: {
126
+ kWkggS: "x1r7kqkb",
127
+ $$css: !0
128
+ },
129
+ dashed: {
130
+ ksu8eU: "xbsl7fq",
131
+ kVAM5u: "xqrc7c3",
132
+ kWkggS: "x1r7kqkb",
133
+ $$css: !0
134
+ },
135
+ interactive: {
136
+ kkrTdU: "x1ypdohk",
137
+ k3XXqK: "x1t137rt",
138
+ kUjPgX: "xqd9x96",
139
+ $$css: !0
140
+ },
141
+ inspected: {
142
+ kMeerF: "x12ei19c",
143
+ kjBf7l: "xx9gdjd",
144
+ k3XXqK: "xaatb59",
145
+ kInvED: "x2ssjo2",
146
+ $$css: !0
147
+ },
148
+ selected: {
149
+ kMeerF: "x12ei19c",
150
+ kjBf7l: "xj5pgkc",
151
+ k3XXqK: "xaatb59",
152
+ kInvED: "x2ssjo2",
153
+ $$css: !0
154
+ }
155
+ };
156
+ function O({ cell: e, domain: t, palette: n }) {
157
+ if (e === void 0) return [D.empty];
158
+ switch (e.kind) {
159
+ case "masked": return [D.empty];
160
+ case "missing": return [D.dashed];
161
+ case "value": return _(e.value, t) ? [D.measured(v(e.value, {
162
+ domain: t,
163
+ palette: n
164
+ }))] : [D.dashed];
165
+ }
166
+ }
167
+ function k({ cell: e, text: t, domain: n }) {
168
+ return e === void 0 ? "·" : e.kind === "value" && _(e.value, n) ? "" : C(e, t, e.kind === "value");
169
+ }
170
+ function A({ rows: e, columns: t, cellAt: n, coordinateId: r, inspectedId: i, onInspect: a, domain: o, palette: s, formatValue: c, selection: l }) {
171
+ return /* @__PURE__ */ m("div", {
172
+ ...d.props(D.grid(t.length)),
173
+ children: [
174
+ /* @__PURE__ */ p("span", { "aria-hidden": !0 }),
175
+ t.map((e) => /* @__PURE__ */ p("span", {
176
+ "aria-hidden": !0,
177
+ title: e.label,
178
+ className: "xeuugli xb3r6kr xbrixnn xuxw1ft x2b8uid x153jb6y xy8obcc xas2l8k",
179
+ children: e.axisLabel ?? e.label
180
+ }, e.id)),
181
+ e.map((e) => /* @__PURE__ */ m("div", {
182
+ className: "xjp7ctv",
183
+ children: [/* @__PURE__ */ p("span", {
184
+ "aria-hidden": !0,
185
+ title: e.label,
186
+ className: "x18qnofl xb3r6kr xlyipyv xuxw1ft x1fa0jp5 xbixft xy8obcc xas2l8k",
187
+ children: e.label
188
+ }), t.map((t) => {
189
+ let u = n(e.id, t.id), m = u?.id ?? r(e.id, t.id), h = w(u, o, c), g = `${e.label}, ${t.label}: ${h}`, _ = u !== void 0 && l?.selectedId === u.id, v = d.props(D.cell, ...O({
190
+ cell: u,
191
+ domain: o,
192
+ palette: s
193
+ }), l !== void 0 && u !== void 0 && D.interactive, i === m && D.inspected, _ && D.selected), y = k({
194
+ cell: u,
195
+ text: h,
196
+ domain: o
197
+ });
198
+ return l === void 0 || u === void 0 ? /* @__PURE__ */ p("span", {
199
+ role: "img",
200
+ "aria-label": g,
201
+ title: g,
202
+ onPointerEnter: () => a(m),
203
+ ...v,
204
+ children: y
205
+ }, t.id) : /* @__PURE__ */ p(f, {
206
+ type: "button",
207
+ tabIndex: -1,
208
+ "aria-label": g,
209
+ title: g,
210
+ "aria-pressed": _,
211
+ onPointerEnter: () => a(m),
212
+ onClick: () => l.onSelect(u.id),
213
+ ...v,
214
+ children: y
215
+ }, t.id);
216
+ })]
217
+ }, e.id))
218
+ ]
219
+ });
220
+ }
75
221
  // packages/charts/src/matrix/matrix.tsx
76
- var C = {
222
+ var j = {
77
223
  kKwaWg: "x1e87kdn",
78
224
  $$css: !0
79
- }, w = {
225
+ }, M = {
80
226
  value: {
81
227
  k1xSpc: "x78zum5",
82
228
  kGNEyG: "x6s0dn4",
@@ -115,7 +261,7 @@ var C = {
115
261
  kInvED: "x2ssjo2",
116
262
  $$css: !0
117
263
  },
118
- measured: (e) => [C, { "--x-backgroundImage": `linear-gradient(${e}, ${e})` == null ? void 0 : `linear-gradient(${e}, ${e})` }],
264
+ measured: (e) => [j, { "--x-backgroundImage": `linear-gradient(${e}, ${e})` == null ? void 0 : `linear-gradient(${e}, ${e})` }],
119
265
  missing: {
120
266
  kMwMTN: "x153jb6y",
121
267
  kWkggS: "x1r7kqkb",
@@ -127,36 +273,58 @@ var C = {
127
273
  kWkggS: "x1r7kqkb",
128
274
  $$css: !0
129
275
  }
130
- }, T = {
276
+ };
277
+ function N(e, t) {
278
+ return JSON.stringify([e, t]);
279
+ }
280
+ var P = {
131
281
  value: void 0,
132
- masked: w.masked,
133
- missing: w.missing
134
- }, E = 4096, D = 6;
135
- function O({ title: e, report: t, description: n, rows: r, columns: o, cells: d, domain: f, palette: h, valueLabel: g, formatValue: v, selection: y, emptyLabel: b }) {
136
- let x = c({
282
+ masked: M.masked,
283
+ missing: M.missing
284
+ }, F = 4096;
285
+ function I({ title: e, report: t, description: n, rows: r, columns: o, cells: d, domain: f, palette: h, valueLabel: g, formatValue: v, selection: y, emptyLabel: b, variant: x = "values" }) {
286
+ let C = x === "strip";
287
+ function T(e, t) {
288
+ return d.find((n) => n.rowId === e && n.columnId === t);
289
+ }
290
+ let E = r.flatMap((e) => o.map((t) => {
291
+ let n = T(e.id, t.id);
292
+ return {
293
+ id: n?.id ?? N(e.id, t.id),
294
+ label: `${e.label} → ${t.label}: ${w(n, f, v)}`
295
+ };
296
+ })), D = c({
137
297
  title: e,
138
- selection: y,
139
- items: d.map((e) => ({
298
+ selection: C && y !== void 0 ? {
299
+ ...y,
300
+ onSelect: O
301
+ } : y,
302
+ columnCount: C ? o.length : void 0,
303
+ items: C ? E : d.map((e) => ({
140
304
  id: e.id,
141
- label: `${r.find((t) => t.id === e.rowId)?.label ?? e.rowId} → ${o.find((t) => t.id === e.columnId)?.label ?? e.columnId}: ${j(e, f, v)}`
305
+ label: `${r.find((t) => t.id === e.rowId)?.label ?? e.rowId} → ${o.find((t) => t.id === e.columnId)?.label ?? e.columnId}: ${w(e, f, v)}`
142
306
  }))
143
- }), C = M({
307
+ });
308
+ function O(e) {
309
+ d.some((t) => t.id === e) && y?.onSelect(e);
310
+ }
311
+ let k = R({
144
312
  rows: r,
145
313
  columns: o,
146
314
  cells: d,
147
315
  domain: f,
148
316
  palette: h
149
317
  });
150
- if (C !== null) return /* @__PURE__ */ p(i, {
318
+ if (k !== null) return /* @__PURE__ */ p(i, {
151
319
  title: e,
152
320
  report: t,
153
321
  description: n,
154
- message: C
322
+ message: k
155
323
  });
156
- let w = /* @__PURE__ */ new Map();
324
+ let j = /* @__PURE__ */ new Map();
157
325
  for (let e of d) {
158
- let t = w.get(e.rowId) ?? /* @__PURE__ */ new Map();
159
- t.set(e.columnId, e), w.set(e.rowId, t);
326
+ let t = j.get(e.rowId) ?? /* @__PURE__ */ new Map();
327
+ t.set(e.columnId, e), j.set(e.rowId, t);
160
328
  }
161
329
  return /* @__PURE__ */ p(u, {
162
330
  title: e,
@@ -179,12 +347,13 @@ function O({ title: e, report: t, description: n, rows: r, columns: o, cells: d,
179
347
  d.some((e) => e.kind === "missing") && /* @__PURE__ */ p("li", { children: "— Missing" }),
180
348
  d.length < r.length * o.length && /* @__PURE__ */ p("li", { children: "· Not supplied" }),
181
349
  d.some((e) => e.kind === "value" && !_(e.value, f)) && /* @__PURE__ */ p("li", { children: "! Outside domain" }),
182
- d.some((e) => e.kind === "value" && v(e.value).length > D) && /* @__PURE__ */ p("li", { children: "• Inspect a cell for its exact value" })
350
+ C && /* @__PURE__ */ p("li", { children: "Inspect a cell for its exact value" }),
351
+ !C && d.some((e) => e.kind === "value" && v(e.value).length > 6) && /* @__PURE__ */ p("li", { children: "• Inspect a cell for its exact value" })
183
352
  ]
184
353
  }),
185
354
  /* @__PURE__ */ p(l, {
186
- id: x.id,
187
- children: x.label ?? "\xA0"
355
+ id: D.id,
356
+ children: D.label ?? "\xA0"
188
357
  }),
189
358
  /* @__PURE__ */ p(a, {
190
359
  label: `${e} cells`,
@@ -197,7 +366,7 @@ function O({ title: e, report: t, description: n, rows: r, columns: o, cells: d,
197
366
  }],
198
367
  rows: r.flatMap((e) => o.map((t) => ({
199
368
  id: JSON.stringify([e.id, t.id]),
200
- values: [`${e.label} → ${t.label}`, j(w.get(e.id)?.get(t.id), f, v)]
369
+ values: [`${e.label} → ${t.label}`, w(j.get(e.id)?.get(t.id), f, v)]
201
370
  })))
202
371
  })
203
372
  ]
@@ -205,8 +374,23 @@ function O({ title: e, report: t, description: n, rows: r, columns: o, cells: d,
205
374
  children: r.length === 0 || o.length === 0 ? /* @__PURE__ */ p("p", {
206
375
  className: "x1ghz6dp x153jb6y xtqrqnz x1778rvt",
207
376
  children: b
377
+ }) : C ? /* @__PURE__ */ p(s, {
378
+ ...D.props,
379
+ className: "xysyzu8 x14eurpq xeuugli x1t137rt x13qnu6 x19rmrnh x9v5kkp x1bqaal x10dazmo",
380
+ children: /* @__PURE__ */ p(A, {
381
+ rows: r,
382
+ columns: o,
383
+ cellAt: (e, t) => j.get(e)?.get(t),
384
+ coordinateId: N,
385
+ inspectedId: D.label === void 0 ? void 0 : D.activeId,
386
+ onInspect: D.inspect,
387
+ domain: f,
388
+ palette: h,
389
+ formatValue: v,
390
+ selection: y
391
+ })
208
392
  }) : /* @__PURE__ */ p(s, {
209
- ...x.props,
393
+ ...D.props,
210
394
  className: "xysyzu8 x14eurpq xeuugli x1t137rt x13qnu6 x19rmrnh x9v5kkp x1bqaal",
211
395
  children: /* @__PURE__ */ m("table", {
212
396
  className: "x1vathgz x1jkpq5q xezivpi x1hz01jw",
@@ -230,15 +414,15 @@ function O({ title: e, report: t, description: n, rows: r, columns: o, cells: d,
230
414
  children: e.label
231
415
  })
232
416
  }), o.map((t) => {
233
- let n = w.get(e.id)?.get(t.id);
417
+ let n = j.get(e.id)?.get(t.id);
234
418
  return /* @__PURE__ */ p("td", {
235
419
  onPointerEnter: () => {
236
- n !== void 0 && x.inspect(n.id);
420
+ n !== void 0 && D.inspect(n.id);
237
421
  },
238
422
  className: "x1717udv x100vrsf x1ff4b4a x2b8uid",
239
- children: /* @__PURE__ */ p(k, {
423
+ children: /* @__PURE__ */ p(L, {
240
424
  cell: n,
241
- isInspected: x.label !== void 0 && x.activeId === n?.id,
425
+ isInspected: D.label !== void 0 && D.activeId === n?.id,
242
426
  label: `${e.label}, ${t.label}`,
243
427
  domain: f,
244
428
  palette: h,
@@ -251,7 +435,7 @@ function O({ title: e, report: t, description: n, rows: r, columns: o, cells: d,
251
435
  })
252
436
  });
253
437
  }
254
- function k({ cell: e, isInspected: t, label: n, domain: r, palette: i, formatValue: a, selection: o }) {
438
+ function L({ cell: e, isInspected: t, label: n, domain: r, palette: i, formatValue: a, selection: o }) {
255
439
  if (e === void 0) return /* @__PURE__ */ p("span", {
256
440
  role: "img",
257
441
  "aria-label": `${n}: not supplied`,
@@ -259,10 +443,10 @@ function k({ cell: e, isInspected: t, label: n, domain: r, palette: i, formatVal
259
443
  className: "x78zum5 x6s0dn4 xl56j7k x100vrsf x1ff4b4a x1vqgdyp x992rv9 x9f619 xmkeg23 x1ey3b81 x1717udv x1hz01jw xy8obcc xj57cvi xas2l8k xss6m8b x153jb6y x1r7kqkb xbsl7fq",
260
444
  children: "·"
261
445
  });
262
- let s = e.kind === "value" && !_(e.value, r), c = j(e, r, a), l = `${n}: ${c}`, u = e.kind === "value" && !s ? v(e.value, {
446
+ let s = e.kind === "value" && !_(e.value, r), c = w(e, r, a), l = `${n}: ${c}`, u = e.kind === "value" && !s ? v(e.value, {
263
447
  domain: r,
264
448
  palette: i
265
- }) : void 0, m = d.props(w.value, T[e.kind], u !== void 0 && w.measured(u), s && w.missing, o !== void 0 && w.interactive, (t || o?.selectedId === e.id) && w.selected), h = A(e, c, s), g = e.kind === "value" ? /* @__PURE__ */ p("span", {
449
+ }) : void 0, m = d.props(M.value, P[e.kind], u !== void 0 && M.measured(u), s && M.missing, o !== void 0 && M.interactive, (t || o?.selectedId === e.id) && M.selected), h = C(e, c, s), g = e.kind === "value" ? /* @__PURE__ */ p("span", {
266
450
  className: "xpvm0e4 x1r97e56",
267
451
  children: h
268
452
  }) : h;
@@ -283,28 +467,13 @@ function k({ cell: e, isInspected: t, label: n, domain: r, palette: i, formatVal
283
467
  children: g
284
468
  });
285
469
  }
286
- function A(e, t, n) {
287
- switch (e.kind) {
288
- case "masked": return "×";
289
- case "missing": return "—";
290
- case "value": return n ? "!" : t.length <= D ? t : e.value === 0 ? "0" : "•";
291
- }
292
- }
293
- function j(e, t, n) {
294
- if (e === void 0) return "Not supplied";
295
- switch (e.kind) {
296
- case "value": return `${n(e.value)}${_(e.value, t) ? "" : " (outside domain)"}`;
297
- case "masked": return `Masked: ${e.reason}`;
298
- case "missing": return `Missing: ${e.reason}`;
299
- }
300
- }
301
- function M({ rows: e, columns: t, cells: r, domain: i, palette: a }) {
470
+ function R({ rows: e, columns: t, cells: r, domain: i, palette: a }) {
302
471
  let o = g({
303
472
  domain: i,
304
473
  palette: a
305
474
  });
306
475
  if (o !== null) return o;
307
- if (e.length * t.length > 4096 || r.length > 4096) return `This matrix exceeds the ${E}-cell render limit. Supply a smaller, labelled window.`;
476
+ if (e.length * t.length > 4096 || r.length > 4096) return `This matrix exceeds the ${F}-cell render limit. Supply a smaller, labelled window.`;
308
477
  let s = new Set(e.map((e) => e.id)), c = new Set(t.map((e) => e.id));
309
478
  if (!n(e) || !n(t) || !n(r)) return "Matrix rows, columns, and cells must have unique identifiers.";
310
479
  let l = /* @__PURE__ */ new Map();
@@ -318,7 +487,7 @@ function M({ rows: e, columns: t, cells: r, domain: i, palette: a }) {
318
487
  return null;
319
488
  }
320
489
  // packages/charts/src/matrix/token-heatmap.tsx
321
- var N = {
490
+ var z = {
322
491
  token: {
323
492
  k1xSpc: "xt0psk2",
324
493
  kmVPX3: "x1717udv",
@@ -363,16 +532,16 @@ var N = {
363
532
  kInvED: "x1y3gkto",
364
533
  $$css: !0
365
534
  }
366
- }, P = 2048;
367
- function F({ title: e, report: t, description: n, tokens: r, domain: s, palette: h, valueLabel: g, formatValue: y, selection: b, emptyLabel: x }) {
535
+ }, B = 2048;
536
+ function V({ title: e, report: t, description: n, tokens: r, domain: s, palette: h, valueLabel: g, formatValue: y, selection: b, emptyLabel: x }) {
368
537
  let C = r.map((e) => ({
369
538
  id: e.id,
370
- label: `Token ${e.index}, ${JSON.stringify(e.text)}, ${g}: ${I(e, s, y)}`
539
+ label: `Token ${e.index}, ${JSON.stringify(e.text)}, ${g}: ${H(e, s, y)}`
371
540
  })), w = c({
372
541
  title: e,
373
542
  items: C,
374
543
  selection: b
375
- }), T = L({
544
+ }), T = U({
376
545
  tokens: r,
377
546
  domain: s,
378
547
  palette: h
@@ -400,10 +569,10 @@ function F({ title: e, report: t, description: n, tokens: r, domain: s, palette:
400
569
  ...w.props,
401
570
  className: "x1ghz6dp xbixft xiard35 xtqrqnz x1778rvt x126k92a xj0a0fe",
402
571
  children: r.map((e) => {
403
- let t = w.label !== void 0 && w.activeId === e.id, n = e.score !== null && !_(e.score, s), r = `Token ${e.index}, ${JSON.stringify(e.text)}, ${g}: ${I(e, s, y)}`, i = d.props(N.token, e.score === null || n ? N.missing : N.color(v(e.score, {
572
+ let t = w.label !== void 0 && w.activeId === e.id, n = e.score !== null && !_(e.score, s), r = `Token ${e.index}, ${JSON.stringify(e.text)}, ${g}: ${H(e, s, y)}`, i = d.props(z.token, e.score === null || n ? z.missing : z.color(v(e.score, {
404
573
  domain: s,
405
574
  palette: h
406
- })), b !== void 0 && N.interactive, (b?.selectedId === e.id || t) && N.selected);
575
+ })), b !== void 0 && z.interactive, (b?.selectedId === e.id || t) && z.selected);
407
576
  return b === void 0 ? /* @__PURE__ */ p("span", {
408
577
  title: r,
409
578
  onPointerEnter: () => w.inspect(e.id),
@@ -441,7 +610,7 @@ function F({ title: e, report: t, description: n, tokens: r, domain: s, palette:
441
610
  values: [
442
611
  String(e.index),
443
612
  JSON.stringify(e.text),
444
- I(e, s, y)
613
+ H(e, s, y)
445
614
  ]
446
615
  }))
447
616
  })]
@@ -452,17 +621,17 @@ function F({ title: e, report: t, description: n, tokens: r, domain: s, palette:
452
621
  message: T
453
622
  });
454
623
  }
455
- function I(e, t, n) {
624
+ function H(e, t, n) {
456
625
  return e.score === null ? "Unavailable" : `${n(e.score)}${_(e.score, t) ? "" : " (outside domain)"}`;
457
626
  }
458
- function L({ tokens: e, domain: t, palette: r }) {
627
+ function U({ tokens: e, domain: t, palette: r }) {
459
628
  let i = g({
460
629
  domain: t,
461
630
  palette: r
462
631
  });
463
- return i === null ? e.length > 2048 ? `This token view exceeds the ${P}-token render limit. Supply a smaller, labelled window.` : !n(e) || new Set(e.map((e) => e.index)).size !== e.length ? "Tokens must have unique identifiers and supplied indices." : e.some((e) => {
632
+ return i === null ? e.length > 2048 ? `This token view exceeds the ${B}-token render limit. Supply a smaller, labelled window.` : !n(e) || new Set(e.map((e) => e.index)).size !== e.length ? "Tokens must have unique identifiers and supplied indices." : e.some((e) => {
464
633
  let t = !Number.isSafeInteger(e.index) || e.index < 0, n = e.score !== null && !Number.isFinite(e.score);
465
634
  return t || n;
466
635
  }) ? "Token indices must be nonnegative integers and measured scores must be finite. Use null for unavailable scores." : null : i;
467
636
  }
468
- export { S as ColorLegend, P as MAX_HEATMAP_TOKENS, E as MAX_MATRIX_CELLS, O as Matrix, F as TokenHeatmap };
637
+ export { S as ColorLegend, B as MAX_HEATMAP_TOKENS, F as MAX_MATRIX_CELLS, I as Matrix, V as TokenHeatmap };
@@ -1,6 +1,6 @@
1
1
  import { c as e } from "../src-DcW_gMX8.js";
2
- import { n as t } from "../chart-frame-D0enjyj9.js";
3
- import { n, t as r } from "../chart-input-D4_Awave.js";
2
+ import { n as t } from "../chart-frame-9dQQNF3F.js";
3
+ import { n, t as r } from "../chart-input-DT0STflx.js";
4
4
  import * as i from "@stylexjs/stylex";
5
5
  import { Button as a } from "@ui-sdk/react/button";
6
6
  import { jsx as o, jsxs as s } from "react/jsx-runtime";
package/dist/charts.js CHANGED
@@ -1,3 +1,3 @@
1
- import { a as e, n as t, r as n } from "./chart-frame-D0enjyj9.js";
1
+ import { a as e, n as t, r as n } from "./chart-frame-9dQQNF3F.js";
2
2
  import { c as r } from "./src-BpvnBWrF.js";
3
3
  export { t as ChartFrame, n as ChartLegend, e as ChartSeriesMarker, r as chartToneColors };
@@ -0,0 +1,6 @@
1
+ // packages/charts/src/label-spacing.ts
2
+ function e({ positions: e, gap: t, start: n, end: r }) {
3
+ let i = e.length - 1, a = e.map((r, i) => Math.max(n + i * t, ...e.slice(0, i + 1).map((e, n) => e + (i - n) * t))), o = a.map((e, n) => Math.min(r - (i - n) * t, ...a.slice(n).map((e, n) => e - n * t)));
4
+ return o.map((e, r) => Math.max(n + r * t, ...o.slice(0, r + 1).map((e, n) => e + (r - n) * t)));
5
+ }
6
+ export { e as t };
@@ -1,7 +1,8 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import type { ChartSelection, ChartSeriesReport } from '../chart-frame.tsx';
3
- import type { BarComposition, BarSeries } from './bar-data.ts';
4
- export type { BarSeries, BarBucket, BarComposition } from './bar-data.ts';
3
+ import type { BarAnnotation, BarComposition, BarMarker, BarSeries } from './bar-data.ts';
4
+ import type { ChartReferenceLine } from './reference-lines.tsx';
5
+ export type { BarSeries, BarBucket, BarComposition, BarMarker, BarAnnotation } from './bar-data.ts';
5
6
  export type BarChartProps = {
6
7
  readonly title: string;
7
8
  readonly description?: ReactNode;
@@ -20,10 +21,21 @@ export type BarChartProps = {
20
21
  readonly highlightedSeriesId?: string | undefined;
21
22
  readonly selection?: ChartSelection | undefined;
22
23
  readonly height?: number | undefined;
24
+ /** Labelled values drawn across the plot, such as a target or an average. They join every category's readout. */
25
+ readonly referenceLines?: ReadonlyArray<ChartReferenceLine> | undefined;
26
+ /** Ticks or whiskers drawn on each bar of a series, listed in the legend and the readout. */
27
+ readonly markers?: ReadonlyArray<BarMarker> | undefined;
28
+ /** Short notes above chosen bars. Notes for a category also join its readout and exact values. */
29
+ readonly annotations?: ReadonlyArray<BarAnnotation> | undefined;
30
+ /**
31
+ * Recedes every other category so these stand out, without changing selection or inspection. Emphasis is visual only;
32
+ * explain it with an annotation or the description.
33
+ */
34
+ readonly emphasizedCategoryIds?: ReadonlyArray<string> | undefined;
23
35
  };
24
36
  export type BarChartPlaceholderProps = Pick<BarChartProps, 'description' | 'height' | 'report'> & {
25
37
  readonly title?: string | undefined;
26
38
  readonly series?: ReadonlyArray<Pick<BarSeries, 'id' | 'label' | 'tone'>> | undefined;
27
39
  };
28
40
  export declare function BarChartPlaceholder({ title, description, report, series, height, }: BarChartPlaceholderProps): ReactNode;
29
- export declare function BarChart({ title, description, report, categories, series, domain, mode, formatValue, formatTick, highlightedSeriesId, selection, height, composition, }: BarChartProps): ReactNode;
41
+ export declare function BarChart({ title, description, report, categories, series, domain, mode, formatValue, formatTick, highlightedSeriesId, selection, height, composition, referenceLines, markers, annotations, emphasizedCategoryIds, }: BarChartProps): ReactNode;
@@ -28,4 +28,47 @@ type CompositionInput = {
28
28
  readonly domain: readonly [number, number];
29
29
  };
30
30
  export declare function validateComposition({ composition, series, categoryIds, domain, }: CompositionInput): string | undefined;
31
+ /**
32
+ * A second value drawn on each bar of one series, on the value axis rather than the stack. A tick marks one value, such
33
+ * as the highest month against an average. A range draws a whisker between two supplied bounds.
34
+ */
35
+ export type BarMarker = {
36
+ readonly id: string;
37
+ readonly label: string;
38
+ /** The bar series whose bar width the marker spans. A stacked chart spans the whole stack. */
39
+ readonly seriesId: string;
40
+ /** Absent means the neutral tone. */
41
+ readonly tone?: ChartTone | undefined;
42
+ } & ({
43
+ readonly kind: 'tick';
44
+ readonly values: ReadonlyArray<number | null>;
45
+ } | {
46
+ readonly kind: 'range';
47
+ readonly lower: ReadonlyArray<number | null>;
48
+ readonly upper: ReadonlyArray<number | null>;
49
+ });
50
+ /** A short visible note above one bar, such as "Peak". Long text belongs in the description. */
51
+ export type BarAnnotation = {
52
+ readonly id: string;
53
+ readonly categoryId: string;
54
+ readonly label: string;
55
+ /** Places the note above this series' bar in a grouped chart. Absent means above the category's tallest mark. */
56
+ readonly seriesId?: string | undefined;
57
+ };
58
+ type OverlayInput = {
59
+ readonly markers: ReadonlyArray<BarMarker>;
60
+ readonly annotations: ReadonlyArray<BarAnnotation>;
61
+ readonly emphasizedCategoryIds: ReadonlyArray<string>;
62
+ readonly seriesIds: ReadonlyArray<string>;
63
+ readonly categoryIds: ReadonlyArray<string>;
64
+ readonly domain: readonly [number, number];
65
+ };
66
+ export declare function validateBarOverlays({ markers, annotations, emphasizedCategoryIds, seriesIds, categoryIds, domain, }: OverlayInput): string | undefined;
67
+ export declare function markerValueLabel({ marker, index, formatValue, }: {
68
+ readonly marker: BarMarker;
69
+ readonly index: number;
70
+ readonly formatValue: (value: number) => string;
71
+ }): string;
72
+ /** The highest value a marker draws at one category, so an annotation can clear it. */
73
+ export declare function markerPeak(marker: BarMarker, index: number): number | null;
31
74
  export {};
@@ -0,0 +1,32 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { BarMarker } from './bar-data.ts';
3
+ /** The horizontal extent of one series' bar within a category. */
4
+ export type BarSpan = {
5
+ readonly x: number;
6
+ readonly width: number;
7
+ };
8
+ type BarMarkersProps = {
9
+ readonly markers: ReadonlyArray<BarMarker>;
10
+ readonly categoryIds: ReadonlyArray<string>;
11
+ readonly span: (categoryId: string, seriesId: string) => BarSpan;
12
+ /** The top of the decorated bar, which a tick's stem joins. Null leaves the tick without a stem. */
13
+ readonly barTop: (categoryIndex: number, seriesId: string) => number | null;
14
+ readonly y: (value: number) => number;
15
+ readonly isReceded: (categoryId: string) => boolean;
16
+ };
17
+ export type PlacedAnnotation = {
18
+ readonly id: string;
19
+ readonly label: string;
20
+ readonly x: number;
21
+ readonly y: number;
22
+ readonly isReceded: boolean;
23
+ };
24
+ /** Draws each marker's tick or whisker over its bar with a surface halo, so it reads on the bar and on the canvas. */
25
+ export declare function BarMarkers({ markers, categoryIds, span, barTop, y, isReceded }: BarMarkersProps): ReactNode;
26
+ /** Centers each note above its anchor and keeps it inside the plot's horizontal bounds. */
27
+ export declare function BarAnnotations({ annotations, left, right, }: {
28
+ readonly annotations: ReadonlyArray<PlacedAnnotation>;
29
+ readonly left: number;
30
+ readonly right: number;
31
+ }): ReactNode;
32
+ export {};
@@ -0,0 +1,29 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { ChartReport, ChartSelection } from '../chart-frame.tsx';
3
+ import type { BridgeStep } from './bridge-data.ts';
4
+ import type { ChartReferenceLine } from './reference-lines.tsx';
5
+ export type { BridgeStep } from './bridge-data.ts';
6
+ export type BridgeChartProps = {
7
+ readonly title: string;
8
+ readonly description?: ReactNode;
9
+ readonly report?: ChartReport | undefined;
10
+ readonly steps: ReadonlyArray<BridgeStep>;
11
+ /** Formats totals and running levels exactly, for labels, inspection and accessible values. */
12
+ readonly formatValue: (value: number) => string;
13
+ /** Formats a signed change. Absent prefixes the formatted magnitude with + or −. */
14
+ readonly formatChange?: ((value: number) => string) | undefined;
15
+ /** Formats compact value-axis ticks. Absent uses `formatValue`. */
16
+ readonly formatTick?: ((value: number) => string) | undefined;
17
+ /** A fixed value domain shared with related charts. Absent fits zero and every running total. */
18
+ readonly domain?: readonly [number, number] | undefined;
19
+ /** Labelled values drawn across the plot, such as a target for the final total. */
20
+ readonly referenceLines?: ReadonlyArray<ChartReferenceLine> | undefined;
21
+ readonly selection?: ChartSelection | undefined;
22
+ readonly height?: number | undefined;
23
+ };
24
+ /**
25
+ * Explains how a starting total becomes a result through signed changes, such as an amount and the deductions that
26
+ * leave a remainder. Columns float from the running total, and dashed connectors carry it to the next step. Use
27
+ * BarChart for independent categories and BreakdownBar for parts of one total; the application supplies every change.
28
+ */
29
+ export declare function BridgeChart({ title, description, report, steps, formatValue, formatChange, formatTick, domain, referenceLines, selection, height, }: BridgeChartProps): ReactNode;
@@ -0,0 +1,40 @@
1
+ import type { ChartTone } from '../../../foundations/src/chart-tones.ts';
2
+ /**
3
+ * One column of a bridge; the first is the start total. A change adds its signed value to the running total, and a
4
+ * missing change leaves later levels unknown. A total shows the running total so far, such as a subtotal or the
5
+ * result.
6
+ */
7
+ export type BridgeStep = {
8
+ readonly id: string;
9
+ /** The full name used in inspection and exact values. */
10
+ readonly label: string;
11
+ /** A concise axis label, such as "Rent". Absent uses the label. */
12
+ readonly axisLabel?: string | undefined;
13
+ /** Absent means neutral totals, positive increases and negative decreases. */
14
+ readonly tone?: ChartTone | undefined;
15
+ } & ({
16
+ readonly kind: 'start';
17
+ readonly value: number;
18
+ } | {
19
+ readonly kind: 'change';
20
+ readonly value: number | null;
21
+ } | {
22
+ readonly kind: 'total';
23
+ readonly value?: never;
24
+ });
25
+ /** A step positioned on the value axis. A null level means an earlier missing change made it unknown. */
26
+ export type BridgeLevel = {
27
+ readonly step: BridgeStep;
28
+ readonly from: number | null;
29
+ readonly to: number | null;
30
+ readonly tone: ChartTone;
31
+ };
32
+ /** Stacks the supplied changes into running levels; totals start at zero and missing changes stay unknown. */
33
+ export declare function bridgeLevels(steps: ReadonlyArray<BridgeStep>): ReadonlyArray<BridgeLevel>;
34
+ type ValueDomain = readonly [number, number];
35
+ export declare function bridgeDomain(levels: ReadonlyArray<BridgeLevel>): ValueDomain;
36
+ export declare function validateBridge({ steps, domain, }: {
37
+ readonly steps: ReadonlyArray<BridgeStep>;
38
+ readonly domain?: ValueDomain | undefined;
39
+ }): string | undefined;
40
+ export {};