@mechane-ai/elements 0.49.0 → 0.49.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.
Files changed (87) hide show
  1. package/README.md +40 -2
  2. package/dist/{article-yyNPg6VU.js → article-CRlhq9oA.js} +531 -463
  3. package/dist/article.js +1 -1
  4. package/dist/catalog.json +29 -1
  5. package/dist/{categorical-values-DCznViFp.js → categorical-values-BYP_R5gS.js} +13 -13
  6. package/dist/charts/cartesian.js +1 -1
  7. package/dist/charts/comparison.js +1 -1
  8. package/dist/charts/distribution.js +1 -1
  9. package/dist/charts/figure.js +12 -12
  10. package/dist/charts/graph.js +1 -1
  11. package/dist/charts/hierarchy.js +1 -1
  12. package/dist/charts/image.js +1 -1
  13. package/dist/charts/matrix.js +1 -1
  14. package/dist/charts/plot.js +4 -4
  15. package/dist/charts/relationship.js +1 -1
  16. package/dist/charts/text.js +1 -1
  17. package/dist/charts/timeline.js +1 -1
  18. package/dist/charts/trend.js +1 -1
  19. package/dist/charts.js +7 -7
  20. package/dist/{dumbbell-plot-CMv9llfd.js → dumbbell-plot-B-Tn7ewW.js} +45 -45
  21. package/dist/{embedding-map-DC-lgzCq.js → embedding-map-Bljn-A5q.js} +528 -528
  22. package/dist/figure-frame-CEijciL7.js +289 -0
  23. package/dist/{image-grid-DHqtj_zs.js → image-grid-mrG5u9oE.js} +47 -47
  24. package/dist/kits/evaluation.js +3 -3
  25. package/dist/kits/interpretability.js +6 -6
  26. package/dist/kits/operations.js +3 -3
  27. package/dist/kits/research.js +2 -2
  28. package/dist/kits/training.js +2 -2
  29. package/dist/lesson/spec.js +11 -11
  30. package/dist/lesson.js +4 -4
  31. package/dist/mdx.js +4 -4
  32. package/dist/packages/charts/src/figure/caption-scope.d.ts +12 -0
  33. package/dist/packages/charts/src/figure/figure-frame.d.ts +2 -1
  34. package/dist/packages/charts/src/index.d.ts +2 -0
  35. package/dist/packages/teaching/src/article/article-context.d.ts +2 -0
  36. package/dist/packages/teaching/src/article/article-layout.stylex.d.ts +13 -0
  37. package/dist/packages/teaching/src/article/article.d.ts +6 -1
  38. package/dist/packages/teaching/src/article/figure.d.ts +20 -3
  39. package/dist/packages/teaching/src/article/index.d.ts +1 -1
  40. package/dist/packages/teaching/src/article/view-essay.d.ts +2 -1
  41. package/dist/packages/teaching/src/lesson/define-lesson.d.ts +4 -0
  42. package/dist/packages/teaching/src/lesson/index.d.ts +2 -2
  43. package/dist/packages/teaching/src/lesson/lesson-player.d.ts +19 -3
  44. package/dist/packages/teaching/src/lesson/lesson-store.d.ts +2 -0
  45. package/dist/packages/teaching/src/lesson/playback.d.ts +9 -6
  46. package/dist/packages/teaching/src/lesson/use-lesson.d.ts +7 -2
  47. package/dist/packages/teaching/src/scene/plane/plane-labels.d.ts +4 -1
  48. package/dist/packages/teaching/src/scene/plane/scene-point.d.ts +5 -6
  49. package/dist/packages/teaching/src/scene/scene-geometry.d.ts +1 -1
  50. package/dist/packages/teaching/src/scene/scene-node.d.ts +4 -1
  51. package/dist/packages/teaching/src/scene/scene-validate.d.ts +6 -0
  52. package/dist/packages/teaching/src/scene/scene-wire.d.ts +6 -1
  53. package/dist/packages/teaching/src/scene/scene.d.ts +1 -1
  54. package/dist/packages/teaching/src/scene/shapes/cell-grid.d.ts +5 -1
  55. package/dist/packages/teaching/src/scene/shapes/scene-cells.d.ts +1 -1
  56. package/dist/packages/teaching/src/scene/shapes/scene-slot.d.ts +1 -1
  57. package/dist/packages/teaching/src/time/tween.d.ts +2 -0
  58. package/dist/{param-BE3VMSkH.js → param-BdqTpZER.js} +166 -99
  59. package/dist/{plot-layout-Bqe4-0qZ.js → plot-layout-B2xRt-_k.js} +144 -130
  60. package/dist/{plot-surface-DON6WUmk.js → plot-surface-0cKFwtws.js} +1 -1
  61. package/dist/{reference-lines-hjuD1rRZ.js → reference-lines-nSxcZVF5.js} +1 -1
  62. package/dist/{scene-BP0Ue0R5.js → scene-BwJKueD6.js} +1227 -1125
  63. package/dist/scene.js +1 -1
  64. package/dist/{slope-chart-C8eeSgL4.js → slope-chart-CGTYbFxi.js} +179 -179
  65. package/dist/styles2.css +69 -14
  66. package/dist/{time-series-BL933QyA.js → time-series-Dh8y5ba0.js} +952 -948
  67. package/dist/{token-heatmap-BB65awva.js → token-heatmap-BTrZ3-N4.js} +84 -84
  68. package/dist/{token-predictions-Pa8eUGan.js → token-predictions-CUe4junQ.js} +126 -126
  69. package/dist/{transport-DzyxVXbL.js → transport-4V9rfYHN.js} +278 -233
  70. package/dist/{tree-diagram-DJhKBiia.js → tree-diagram-Dpqmo-fh.js} +115 -115
  71. package/dist/{treemap-CxxgABUg.js → treemap-BUSaVD3m.js} +27 -27
  72. package/dist/use-tween-BsaEO862.js +10 -0
  73. package/dist/{violin-plot-CoAEF_7Z.js → violin-plot-BxaLwdRi.js} +123 -123
  74. package/dist/{waterfall-DdoEXEkT.js → waterfall-CcDMdKec.js} +39 -39
  75. package/package.json +1 -1
  76. package/recipes/counting-cards.tsx +3 -3
  77. package/skills/review-explainer/SKILL.md +2 -1
  78. package/skills/upgrade-elements/references/releases.md +61 -0
  79. package/skills/use-elements/SKILL.md +3 -1
  80. package/skills/use-elements/references/styling.md +23 -0
  81. package/skills/use-elements/references/teaching.md +13 -0
  82. package/skills/write-explainer/references/article.md +50 -2
  83. package/skills/write-explainer/references/lesson.md +18 -9
  84. package/skills/write-explainer/references/scene-parts.md +17 -12
  85. package/skills/write-explainer/references/scene.md +25 -3
  86. package/dist/figure-frame-BjFzbl3m.js +0 -270
  87. package/dist/use-tween-5HZ55_9d.js +0 -72
@@ -1,15 +1,15 @@
1
1
  import { c as e } from "./src-9EJskqB_.js";
2
- import { A as t, O as n, S as r, f as i, k as a, l as o, s, w as c } from "./plot-layout-Bqe4-0qZ.js";
2
+ import { A as t, E as n, M as r, S as i, f as a, j as o, l as s, s as c } from "./plot-layout-B2xRt-_k.js";
3
3
  import { i as l } from "./chart-link-AE_xuxiP.js";
4
4
  import { a as u } from "./tone-scope-DKiSw-JR.js";
5
5
  import { n as d, r as f } from "./figure-format-B8kRZMlo.js";
6
6
  import { a as p, o as m, r as ee } from "./scale-C2xgZyZN.js";
7
7
  import { t as h } from "./chart-cursor-1mFd48Jc.js";
8
- import { i as g, l as te, n as ne, r as re, t as _ } from "./figure-frame-BjFzbl3m.js";
8
+ import { i as g, l as te, n as ne, r as re, t as _ } from "./figure-frame-CEijciL7.js";
9
9
  import { n as ie } from "./plot-width-D3hTycYX.js";
10
10
  import { t as v } from "./plot-axes-D5S9BnBa.js";
11
11
  import { a as y, c as ae, f as oe, r as se } from "./plot-marks-FVsbFkUs.js";
12
- import { n as ce, r as le, t as ue } from "./plot-surface-DON6WUmk.js";
12
+ import { n as ce, r as le, t as ue } from "./plot-surface-0cKFwtws.js";
13
13
  import { t as de } from "./locate-Bcg3QcP4.js";
14
14
  import * as fe from "@stylexjs/stylex";
15
15
  import { useId as pe } from "react";
@@ -42,7 +42,7 @@ var D = {
42
42
  $$css: !0
43
43
  } };
44
44
  function z(e) {
45
- return o({
45
+ return s({
46
46
  width: Infinity,
47
47
  valueLabels: e,
48
48
  hasXTitle: !0,
@@ -62,28 +62,28 @@ function Ee(e, t) {
62
62
  }
63
63
  });
64
64
  }
65
- function De({ lanes: e, events: n, markers: r, domain: i, zone: a }) {
65
+ function De({ lanes: e, events: t, markers: n, domain: i, zone: a }) {
66
66
  let o = m(i);
67
67
  if (o !== void 0) return o;
68
68
  if (a === void 0) return "A function time format needs a timeZone beside it, so the axis ticks fall on that zone.";
69
- if (e.length > D.lanes || n.length > D.events) return `This strip draws at most ${D.lanes} lanes and ${D.events} events. Supply a shorter window.`;
70
- if (!t(e) || !t(n) || !t(r)) return "Lanes, events and markers must each have unique identifiers.";
71
- let s = new Set(e.map((e) => e.id)), c = n.find((e) => !s.has(e.laneId));
69
+ if (e.length > D.lanes || t.length > D.events) return `This strip draws at most ${D.lanes} lanes and ${D.events} events. Supply a shorter window.`;
70
+ if (!r(e) || !r(t) || !r(n)) return "Lanes, events and markers must each have unique identifiers.";
71
+ let s = new Set(e.map((e) => e.id)), c = t.find((e) => !s.has(e.laneId));
72
72
  if (c !== void 0) return `Event ${c.id} names lane ${c.laneId}, which is not supplied.`;
73
- let l = n.find((e) => {
73
+ let l = t.find((e) => {
74
74
  let t = e.end !== void 0 && (p(e.end, i) || e.end <= e.start);
75
75
  return p(e.start, i) || t;
76
76
  });
77
- return l === void 0 ? r.some((e) => p(e.at, i)) ? "A marker lies outside the domain." : void 0 : `Event ${l.id} must start inside the domain and, when it has an end, end after its start inside the domain.`;
77
+ return l === void 0 ? n.some((e) => p(e.at, i)) ? "A marker lies outside the domain." : void 0 : `Event ${l.id} must start inside the domain and, when it has an end, end after its start inside the domain.`;
78
78
  }
79
79
  function B(e) {
80
- let { lanes: t, events: f, domain: p, markers: m = [], gutterWidth: S, timeFormat: C, timeZone: ge, selected: w, onSelectedChange: T, ..._e } = e, { emptyLabel: E = "No events in this window.", ...D } = _e, { locale: P, title: F } = D, I = le("compact"), L = pe(), R = u(), we = l();
80
+ let { lanes: r, events: f, domain: p, markers: m = [], gutterWidth: S, timeFormat: C, timeZone: ge, selected: w, onSelectedChange: T, ..._e } = e, { emptyLabel: E = "No events in this window.", ...D } = _e, { locale: P, title: F } = D, I = le("compact"), L = pe(), R = u(), we = l();
81
81
  if (D.status === "loading") return /* @__PURE__ */ b(g, {
82
82
  ...D,
83
83
  height: "compact"
84
84
  });
85
85
  let z = typeof C == "function" ? ge : C.timeZone, B = De({
86
- lanes: t,
86
+ lanes: r,
87
87
  events: f,
88
88
  markers: m,
89
89
  domain: p,
@@ -100,9 +100,9 @@ function B(e) {
100
100
  format: C
101
101
  });
102
102
  }
103
- let H = o({
103
+ let H = s({
104
104
  width: I.width,
105
- valueLabels: t.map((e) => e.label),
105
+ valueLabels: r.map((e) => e.label),
106
106
  hasXTitle: !0,
107
107
  hasYTitle: !1
108
108
  }), U = S === void 0 ? H : {
@@ -131,17 +131,17 @@ function B(e) {
131
131
  track: e.laneId,
132
132
  start: e.end === void 0 ? e.start - Y * N : e.start,
133
133
  end: e.end === void 0 ? e.start + Y * N : Math.max(e.end, e.start + ke)
134
- }))), je = t.map((e) => Math.max(1, ...f.flatMap((t) => t.laneId === e.id ? [(Ae.get(t.id)?.lane ?? 0) + 1] : []))), Me = t.flatMap((e, t) => Array.from({ length: je[t] ?? 1 }, (t, n) => ({
134
+ }))), je = r.map((e) => Math.max(1, ...f.flatMap((t) => t.laneId === e.id ? [(Ae.get(t.id)?.lane ?? 0) + 1] : []))), Me = r.flatMap((e, t) => Array.from({ length: je[t] ?? 1 }, (t, n) => ({
135
135
  laneId: e.id,
136
136
  row: n
137
- }))), Ne = J + Me.length * O + t.length * k * 2 + U.bottom, X = s({
137
+ }))), Ne = J + Me.length * O + r.length * k * 2 + U.bottom, X = c({
138
138
  width: I.width,
139
139
  height: Ne,
140
140
  margins: {
141
141
  ...U,
142
142
  top: J
143
143
  }
144
- }), Z = t.map((e, t) => {
144
+ }), Z = r.map((e, t) => {
145
145
  let n = Me.findIndex((t) => t.laneId === e.id), r = X.top + t * k * 2 + n * O;
146
146
  return {
147
147
  lane: e,
@@ -149,7 +149,7 @@ function B(e) {
149
149
  start: r,
150
150
  end: r + (je[t] ?? 1) * O + 12
151
151
  };
152
- }), Pe = i({
152
+ }), Pe = a({
153
153
  domain: p,
154
154
  length: X.innerWidth,
155
155
  timeFormat: C,
@@ -166,15 +166,15 @@ function B(e) {
166
166
  })), Q = f.map((e, t) => ({
167
167
  event: e,
168
168
  index: t
169
- })).toSorted((e, t) => e.event.start === t.event.start ? e.index - t.index : e.event.start - t.event.start).map((e) => e.event).map((e, n) => {
170
- let r = Z.find((t) => t.lane.id === e.laneId), i = r?.index ?? 0, a = t[i], o = Ae.get(e.id)?.lane ?? 0, s = (r?.start ?? X.top) + k + (o + N) * O, c = G.position(e.start), l = e.end === void 0 ? c : Math.max(c + ye, G.position(e.end)), u = e.tone ?? R({
169
+ })).toSorted((e, t) => e.event.start === t.event.start ? e.index - t.index : e.event.start - t.event.start).map((e) => e.event).map((e, t) => {
170
+ let n = Z.find((t) => t.lane.id === e.laneId), i = n?.index ?? 0, a = r[i], o = Ae.get(e.id)?.lane ?? 0, s = (n?.start ?? X.top) + k + (o + N) * O, c = G.position(e.start), l = e.end === void 0 ? c : Math.max(c + ye, G.position(e.end)), u = e.tone ?? R({
171
171
  id: e.laneId,
172
172
  tone: a?.tone,
173
173
  index: i
174
174
  });
175
175
  return {
176
176
  event: e,
177
- rank: n,
177
+ rank: t,
178
178
  laneIndex: i,
179
179
  laneLabel: a?.label ?? e.laneId,
180
180
  x1: c,
@@ -193,7 +193,7 @@ function B(e) {
193
193
  e.detail
194
194
  ].filter((e) => e !== void 0).join(" · ")
195
195
  };
196
- }), Le = 1 / (t.length * 2 + 1), Re = de({
196
+ }), Le = 1 / (r.length * 2 + 1), Re = de({
197
197
  marks: Q.map((e) => ({
198
198
  id: e.event.id,
199
199
  x: (e.x1 + e.x2) * N,
@@ -206,7 +206,7 @@ function B(e) {
206
206
  let t = e.x / e.width * X.width, n = e.y / e.height * X.height;
207
207
  return Q.findLast((e) => t >= e.x1 - A - xe && t <= e.x2 + A + xe && Math.abs(n - e.y) <= O * N)?.event.id ?? Re(e);
208
208
  }
209
- return /* @__PURE__ */ b(c, {
209
+ return /* @__PURE__ */ b(n, {
210
210
  ...we,
211
211
  items: $,
212
212
  place: (e) => {
@@ -221,19 +221,19 @@ function B(e) {
221
221
  locate: ze,
222
222
  selected: w ?? null,
223
223
  onSelect: T,
224
- render: (e, { inspected: t, cursor: i }) => {
225
- let o = Q.find((e) => e.event.id === i);
224
+ render: (e, { inspected: n, cursor: r }) => {
225
+ let a = Q.find((e) => e.event.id === r);
226
226
  return /* @__PURE__ */ b(ne, {
227
227
  ...D,
228
228
  figure: e,
229
- footer: f.length === 0 ? void 0 : /* @__PURE__ */ b(r, {
229
+ footer: f.length === 0 ? void 0 : /* @__PURE__ */ b(i, {
230
230
  id: L,
231
- children: n($, t)
231
+ children: t($, n)
232
232
  }),
233
233
  children: f.length === 0 ? /* @__PURE__ */ b(_, { children: E }) : /* @__PURE__ */ x(he, { children: [/* @__PURE__ */ x(ce, {
234
234
  plotRef: I.ref,
235
235
  box: X,
236
- label: a({
236
+ label: o({
237
237
  title: F,
238
238
  marks: "events",
239
239
  isSelectable: T !== void 0
@@ -261,7 +261,7 @@ function B(e) {
261
261
  y: e.y,
262
262
  radius: A,
263
263
  tone: e.tone,
264
- isInspected: t === e.event.id,
264
+ isInspected: n === e.event.id,
265
265
  isSelected: w === e.event.id
266
266
  }, e.event.id) : /* @__PURE__ */ b(se, {
267
267
  x: e.x1,
@@ -269,7 +269,7 @@ function B(e) {
269
269
  width: e.x2 - e.x1,
270
270
  height: ve,
271
271
  tone: e.tone,
272
- isInspected: t === e.event.id,
272
+ isInspected: n === e.event.id,
273
273
  isSelected: w === e.event.id
274
274
  }, e.event.id))
275
275
  }),
@@ -288,8 +288,8 @@ function B(e) {
288
288
  children: n
289
289
  })] }, e.id);
290
290
  }),
291
- o !== void 0 && /* @__PURE__ */ b(h, {
292
- x: (o.x1 + o.x2) * N,
291
+ a !== void 0 && /* @__PURE__ */ b(h, {
292
+ x: (a.x1 + a.x2) * N,
293
293
  top: X.top,
294
294
  bottom: X.bottom,
295
295
  width: Ce
@@ -489,16 +489,16 @@ function K({ items: t, start: n, end: r, rowLabel: i, summaryLabel: a, emptyLabe
489
489
  children: oe
490
490
  });
491
491
  }
492
- function q({ items: e, start: n, end: r }) {
493
- if (!Number.isFinite(n) || !Number.isFinite(r) || !Number.isFinite(r - n) || r < n) return "The timing domain must have finite, ordered endpoints.";
494
- if (!t(e)) return "Timing records must have unique identifiers.";
495
- for (let t of e) {
496
- let e = t.geometry;
492
+ function q({ items: e, start: t, end: n }) {
493
+ if (!Number.isFinite(t) || !Number.isFinite(n) || !Number.isFinite(n - t) || n < t) return "The timing domain must have finite, ordered endpoints.";
494
+ if (!r(e)) return "Timing records must have unique identifiers.";
495
+ for (let r of e) {
496
+ let e = r.geometry;
497
497
  if (e.kind === "interval") {
498
498
  if (!Number.isFinite(e.start) || !Number.isFinite(e.end) || e.end < e.start) return "Timing intervals must have finite, ordered endpoints.";
499
- if (e.start < n || e.end > r) return "Timing intervals must fit inside the supplied domain.";
499
+ if (e.start < t || e.end > n) return "Timing intervals must fit inside the supplied domain.";
500
500
  }
501
- if (e.kind === "point" && (!Number.isFinite(e.at) || e.at < n || e.at > r)) return "Timing points must be finite and fit inside the supplied domain.";
501
+ if (e.kind === "point" && (!Number.isFinite(e.at) || e.at < t || e.at > n)) return "Timing points must be finite and fit inside the supplied domain.";
502
502
  }
503
503
  }
504
504
  function Oe({ geometry: e, scale: t }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mechane-ai/elements",
3
- "version": "0.49.0",
3
+ "version": "0.49.1",
4
4
  "description": "Elements by Mechane — React components for applications, AI interfaces, and analytical graphics",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -592,9 +592,9 @@ export const countingEssay = (
592
592
  caption="The dealt cards, on the table or counted by suit."
593
593
  description="The deal scene, or a stacked bar chart with one bar per suit, where each dealt card becomes one segment of its suit's bar."
594
594
  reads={['dealt']}
595
+ footer={<ParamChoice name="arrangement" />}
595
596
  >
596
597
  <CountedCards />
597
- <ParamChoice name="arrangement" />
598
598
  </Figure>
599
599
  </Beat>
600
600
  <Beat id="practice">
@@ -602,14 +602,14 @@ export const countingEssay = (
602
602
  Play the deal with the weight at <Param name="trust" />. At card <Value name="dealt" /> the model gives the next
603
603
  suit <Value name="chance" />, a surprise of <Value name="surprise" />.
604
604
  </p>
605
+ <Playback name="dealt" pace="slow" />
605
606
  <Figure
606
607
  id="deal-run"
607
608
  caption="The deal played card by card, and the model’s surprise at each card."
608
609
  description="Play controls, the deal scene and a curve of the model's surprise at each of the twelve cards, against a flat line at two bits for an even guess."
609
610
  reads={['dealt', 'trust']}
611
+ header={<Transport for="dealt" />}
610
612
  >
611
- <Playback name="dealt" pace="slow" />
612
- <Transport for="dealt" />
613
613
  <DealScene />
614
614
  <SurpriseCurve />
615
615
  </Figure>
@@ -52,7 +52,8 @@ In order of what matters most to a learner:
52
52
  11. **Narrow width.** At 360 pixels the prose and controls fit, and a scene scrolls inside its own frame rather than the
53
53
  page.
54
54
  12. **Keyboard.** Every `Param` takes arrow keys; each scene and chart is one Tab stop whose arrow keys reach every
55
- labelled object; a draggable `ScenePoint` moves with the arrow keys; in the present view Right, Space and Left move.
55
+ labelled object; a draggable `ScenePoint` is its own Tab stop, a slider the arrow keys move; a pressable card turns
56
+ on Enter or Space; in the present view Right, Space and Left move.
56
57
 
57
58
  ## 3. Read the code once
58
59
 
@@ -2,6 +2,67 @@
2
2
 
3
3
  Newest first. Each section lists what an application must change, then what it may adopt.
4
4
 
5
+ ## 0.49.1
6
+
7
+ Fixes from the first essay ported onto the teaching layers. No import changes. An essay written for 0.48 type checks
8
+ unchanged; it prints less and behaves differently in the places below.
9
+
10
+ ### Behavior to check
11
+
12
+ - **A chart or scene inside an article `Figure` no longer prints its title or description.** The `Figure` caption names
13
+ the figure, and the chart's `title` stays its accessible name. Remove any caption you shortened to avoid the
14
+ repetition, and move words a reader needs from a chart `description` into the caption or the prose.
15
+ - **A turned-away face is not rendered.** A `SceneNode` or `SceneCard` draws only the face toward the reader, so a
16
+ face-down card has no rank or suit in its text or its accessible name. A face with rich content remounts after a turn.
17
+ A card's `id` still reaches the page: keep it free of the rank and suit when the card may be face down.
18
+ - **`ScenePoint` with `sets` or `onMove` is a slider.** It is its own Tab stop with `role="slider"`, moves on the step
19
+ grid with the arrow keys, takes ten steps with Shift or Page Up and Page Down, and goes to the ends with Home and End.
20
+ It no longer moves while it is the plot's arrow-key cursor.
21
+ - **Scenes are narrower before they scroll.** A wire now asks for the room its stroke, text and arrow need, not a fixed
22
+ 64 px. Remove a `minWidth` you set to stop a small diagram scrolling on a phone.
23
+ - **`SceneSlot` `isActive` only marks the slot.** Other objects no longer recede.
24
+ - **A pointer press that acts leaves nothing dimmed.** In a `Scene` with `onSelectedChange`, pressing an object with a
25
+ pointer no longer fades the others. The arrow-key cursor keeps its emphasis.
26
+ - **`SceneCells` column labels wrap** above their column and a long word overhangs instead of being cut.
27
+ - **The essay's text column keeps its measure** at wide widths. A beat's paragraphs were up to 93 characters wide and
28
+ are 68 again.
29
+ - **`Transport` and `ParamSlider` grow** to fill a flex row. A `ParamSlider` wraps below 12rem of room.
30
+ - **No scene text is under 12 px.** Small card corners and token captions were 11 px.
31
+
32
+ ### Adopt
33
+
34
+ - **`Article` `hasContents={false}`** leaves the contents list out at every width, for a host with its own navigation.
35
+ Control the beat through `lessonProps`.
36
+ - **Framed figures.** The article `Figure` takes `header` and `footer` strips for a figure's own controls and draws one
37
+ hairline frame around the strips and the visual. `isFramed` frames a figure that has no controls. The strips are inert
38
+ in the static view and the sheet.
39
+ - **`resetBeat`.** `useLesson(lesson).resetBeat(beat)` returns one beat's params to their opening values in one change.
40
+ A beat owns the params its states name, or the ones listed in its new `params` field. `reset()` and `show()` still act
41
+ on the whole lesson.
42
+ - **Timed and eased playback.** `Playback` `pace` also takes `{ run: 'short' | 'regular' | 'long', isEased? }`: the
43
+ whole range plays in 2, 5 or 10 seconds on the shared clock, with an ease-out when asked.
44
+ - **Pressable scene parts.** `Scene` `onSelectedChange` with `selected={null}` makes a press an action, such as turning
45
+ a card over. The new `labels.press` says what a press does in the plot's accessible name.
46
+ - **`SceneWire` `bend`** bows a wire off its line by a signed number of pixels, to pass a node that sits between its
47
+ ends.
48
+ - **`SceneCells` cell `tone` and `isMuted`** color one cell with a chart tone or gray it out.
49
+ - **`CaptionScope` and `useIsCaptioned`** from `/charts` are what the article `Figure` uses. A custom captioned
50
+ container wraps its charts in `CaptionScope` to get the same rule.
51
+
52
+ ## 0.49
53
+
54
+ A research kit with the form, text and layout parts it needed. Nothing to change.
55
+
56
+ ### Adopt
57
+
58
+ - **A research kit.** `/kits/research` has `FindingCard`, `MilestonePath`, `SpecimenDiff` and `WorkHeartbeat`, for
59
+ tracking research milestones, paired specimen diffs, work reports and findings.
60
+ - **`TokenInput`** from `/forms`, with `fromText`, `toText`, `toLabel` and `defaultCodec`.
61
+ - **`TextMatch`** from `/content`, with `matchRanges`, `matchSegments` and `fuzzyScore`.
62
+ - **`FigureGrid` and `SidebarBrand`** from `/layout`.
63
+ - **Types:** `PanelProps` from the root entry, `MetricChange` from `/collections`, `ScatterDiagonal` from
64
+ `/charts/cartesian` and `LensLayerGroup` from `/kits/interpretability`.
65
+
5
66
  ## 0.48
6
67
 
7
68
  Elements has a teaching family: lessons, diagrams with identity, explorable essays and tutor tools. It adds six entries
@@ -31,7 +31,9 @@ callbacks. Do not guess a prop from another library. The same index is at `@mech
31
31
 
32
32
  - Import `@mechane-ai/elements/styles.css` once at the app entry. Ordinary React apps need no StyleX compiler.
33
33
  - Spread `themeProps.light` or `themeProps.dark` from `/theme` onto the document root, so portaled menus and dialogs
34
- inherit the theme. The app stores the preference.
34
+ inherit the theme. The app stores the preference. The spread is a `className`: a later `className` on the same element
35
+ replaces it silently, so give the theme its own element or join the class names (see
36
+ [styling](references/styling.md)).
35
37
  - Mount one `Toaster` from `/feedback` at the root when the app reports outcomes with `toast`.
36
38
  - Supply the app's own reset and fonts. See [styling](references/styling.md) for layers, tokens and a nonce policy.
37
39
 
@@ -18,6 +18,29 @@ export function Document({ isDark, children }: { readonly isDark: boolean; reado
18
18
  Apply the theme to the document root so portaled menus, dialogs and tooltips inherit it. The application stores the
19
19
  preference; there is no theme provider. A themed wrapper suits an isolated preview only.
20
20
 
21
+ `themeProps.dark` is a `className` and a `style`. Spread with your own styles, the later `className` wins and the theme
22
+ is lost without an error: `{...themeProps.dark} {...stylex.props(styles.root)}` leaves the page half dark. Put the theme
23
+ on an element of its own, or join both class names and styles:
24
+
25
+ ```tsx
26
+ import { themeProps } from '@mechane-ai/elements/theme';
27
+ import * as stylex from '@stylexjs/stylex';
28
+ import type { ReactNode } from 'react';
29
+
30
+ const styles = stylex.create({ root: { minHeight: '100dvh' } });
31
+
32
+ export function ThemedRoot({ isDark, children }: { readonly isDark: boolean; readonly children: ReactNode }) {
33
+ const theme = themeProps[isDark ? 'dark' : 'light'];
34
+ const own = stylex.props(styles.root);
35
+
36
+ return (
37
+ <div className={`${theme.className ?? ''} ${own.className ?? ''}`} style={{ ...theme.style, ...own.style }}>
38
+ {children}
39
+ </div>
40
+ );
41
+ }
42
+ ```
43
+
21
44
  ## Appearance comes from the components
22
45
 
23
46
  - Choose a named `variant`, `tone` or `density`. There is no size, padding or radius prop.
@@ -16,6 +16,19 @@ The ideas, in one breath: one lesson store holds every value the reader, the app
16
16
  object with a stable id eases to its new props by itself, so you describe states and never write an animation; an
17
17
  article renders the same beats as a scrolling essay, a presentation, a static page and a beat sheet.
18
18
 
19
+ ## Four things a port gets wrong
20
+
21
+ - `show` and `reset` act on the whole lesson. A figure's Reset button calls `resetBeat(beat)`, which returns only the
22
+ params that beat owns (its `params`, or those its states set) to their opening values.
23
+ - A host whose own rail lists the beats holds the beat through `Article`'s `lessonProps` (`beat` and `onBeatChange`) and
24
+ sets `hasContents={false}`, so the page has one contents list.
25
+ - A figure's controls go in the article `Figure`'s `header` or `footer`, which frame it. A chart or scene inside keeps
26
+ its title only as its accessible name; the caption is printed, so do not repeat the beat heading in it.
27
+ - A card that turns, or a node that acts, when pressed needs no click handler of its own: give the `Scene`
28
+ `selected={null}` and `onSelectedChange={(id) => ...}`. A press, or Enter or Space on the keyboard cursor, calls it
29
+ with the labelled object's id. A face-down `SceneCard` renders only its back, so keep its id free of its rank and
30
+ suit.
31
+
19
32
  ## When to switch skills
20
33
 
21
34
  - Asked to explain a topic, a paper or a result interactively: follow the `plan-lesson` skill before writing a
@@ -15,6 +15,7 @@ arranges the same children four ways. It renders the `Lesson`, a `ChartLink` and
15
15
  | `storageKey` | Keeps the values and the reader's progress across visits. |
16
16
  | `progress`, `defaultProgress`, `onProgressChange` | The reader's predictions, challenges, hints and visits, if the application holds them. |
17
17
  | `lessonProps` | Passed to the `Lesson`: controlled values, beat and step, `shouldSyncUrl`. |
18
+ | `hasContents` | `false` leaves the contents list out, when the host's own navigation lists the beats. |
18
19
  | `labels` | The article's own words, with English defaults. |
19
20
 
20
21
  ## Markup the article reads
@@ -34,7 +35,16 @@ components to look inside them. So:
34
35
 
35
36
  - `Beat`: `id` and children. Its title, tutor notes, reveal steps and states come from the lesson.
36
37
  - `Figure`: `id` (unique, and different from every beat id), `caption`, `description` (the figure in words, printed in
37
- the static view), `reads`, `size` (`'wide'`, the default, reaches into the margin; `'text'` keeps the column).
38
+ the static view), `reads`, `size` (`'wide'`, the default, reaches into the margin; `'text'` keeps the column), and
39
+ `header` and `footer` for the figure's controls. Either one sets the figure in a hairline frame with a strip above or
40
+ below the visual; put a `Transport` in `header` and a `ParamChoice` or a reset button in `footer`, never loose under
41
+ the figure. `isFramed` frames a figure with no controls; if one figure in an essay is framed, frame them all. A figure
42
+ with a strip is always framed, and `isFramed={false}` with one is an authoring error. The static view and the sheet
43
+ keep the strips but make them inert. A chart with a `report` frame inside keeps its own border, and the figure draws
44
+ no second one.
45
+ - A chart or scene inside a `Figure` keeps its `title` as its accessible name but prints neither the title nor its
46
+ description: the caption is what the reader sees. So never repeat the beat heading in the caption or the title. The
47
+ beat heading names the idea, the caption says what to look at, and the title names the drawing for a screen reader.
38
48
  - `FigureReference`: `to`, a figure id. Writes "Figure 2" as a link. Never write a figure number by hand.
39
49
  - `Reveal`: `at`, a reveal step from 0 up to the beat's declared `steps`. It hides content only in the present view; the
40
50
  other views show everything. `useRevealed(at)` gives the same answer to a figure that reveals its own parts: true in
@@ -134,6 +144,44 @@ export function BiasArticle({ view, math }: { readonly view: ArticleView; readon
134
144
  }
135
145
  ```
136
146
 
147
+ ## A host that holds the beat
148
+
149
+ An application whose own navigation lists the beats, such as a rail in an `AppShell`, holds the beat and passes it in
150
+ through `lessonProps`. Give `Article` `hasContents={false}` so the reader sees one list, not two. The text keeps its
151
+ measure.
152
+
153
+ ```tsx
154
+ import { Article } from '@mechane-ai/elements/article';
155
+ import type { ReactNode } from 'react';
156
+ import { lesson } from './lesson.ts';
157
+
158
+ type BeatId = (typeof lesson.beats)[number]['id'];
159
+
160
+ export function HostedEssay({
161
+ beat,
162
+ onBeat,
163
+ children,
164
+ }: {
165
+ readonly beat: BeatId;
166
+ readonly onBeat: (beat: BeatId) => void;
167
+ readonly children: ReactNode;
168
+ }): ReactNode {
169
+ return (
170
+ <Article
171
+ lesson={lesson}
172
+ locale="en-US"
173
+ title="A neuron is a weighted vote"
174
+ hasContents={false}
175
+ lessonProps={{ beat, onBeatChange: (next) => next !== null && onBeat(next) }}
176
+ >
177
+ {children}
178
+ </Article>
179
+ );
180
+ }
181
+ ```
182
+
183
+ Scrolling a beat into view reports it through `onBeatChange`, and a beat the host sets scrolls into view.
184
+
137
185
  ## The four views
138
186
 
139
187
  The same children, arranged four ways. In the essay starter, `?view=present`, `?view=static` and `?view=sheet` choose
@@ -141,7 +189,7 @@ one.
141
189
 
142
190
  | View | What it is |
143
191
  | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
144
- | `article` | The scrolling essay, with a contents list that follows the reading position and sets the lesson's beat. |
192
+ | `article` | The scrolling essay, with a contents list that follows the reading position and sets the lesson's beat. Below 1,120 px the list folds into a sticky bar, which never covers a focused control or a linked target. |
145
193
  | `present` | One beat at a time, opened at its first declared state each time the presenter reaches it. Right or Space runs `next` (the next reveal step, then the next beat); Left goes back. A `Scrolly` shows its figure beside its steps, which are walked before the reveal steps. |
146
194
  | `static` | Every beat open at its first state, every reveal shown, each figure followed by its description, no motion. |
147
195
  | `sheet` | Every beat at each of its states, read-only and scaled to fit its cell, with its tutor notes, then "Checks". |
@@ -13,8 +13,9 @@ const lesson = defineLesson({ id, title, params, derived, beats });
13
13
  `{ id, label }`) and toggle (`value`) params, each with a `label`.
14
14
  - `derived`: `{ label, format, from }`. `from` receives the params and the derived values declared above it, typed, and
15
15
  returns a number. Keep it pure: no randomness, no time, no fetch.
16
- - `beats`: `{ id, title, goal?, misconception?, hints?, steps?, states? }`. Goals, misconceptions and hints are tutor
17
- notes; the reader never sees them. `states` are `{ id, label, values }`, where `values` set params only.
16
+ - `beats`: `{ id, title, goal?, misconception?, hints?, steps?, states?, params? }`. Goals, misconceptions and hints are
17
+ tutor notes; the reader never sees them. `states` are `{ id, label, values }`, where `values` set params only.
18
+ `params` names the params the beat owns, which `resetBeat` resets; left out, they are the params its states set.
18
19
  - It throws a named `Error` for a bad definition, at module load, so a mistake fails before anything renders.
19
20
  - The result carries `defaults`, `initial` (params and derived values at the opening), `compute(values)` and `reads`
20
21
  (the names each derived value reads, found by running it). `lessonGraph(lesson)` gives the same as nodes and edges.
@@ -76,7 +77,8 @@ the untyped form for parts that work in any lesson.
76
77
  | `set(name, value, origin?)` | Sets one param. A value outside its range or options **throws**. |
77
78
  | `setMany(values, origin?)` | Sets several params in one change. |
78
79
  | `show(stateId, origin?)` | Shows a declared state as the whole picture, looking in the current beat first. |
79
- | `reset()` | Every param back to its opening value. |
80
+ | `reset(origin?)` | Every param of the whole lesson back to its opening value. |
81
+ | `resetBeat(beat, origin?)` | Only the params that beat owns back to their opening values, in one change. |
80
82
  | `beat`, `step` | Where the reader is. |
81
83
  | `goTo(beat, step?)`, `next()`, `previous()` | Move. `next` reveals the next step, then goes to the next beat. |
82
84
  | `locale`, `lesson` | The lesson's locale and definition. |
@@ -87,20 +89,25 @@ draw states too. Elsewhere, only `show`, a `ScrollyStep` with `state` and a tuto
87
89
  is the whole picture: a param it does not name takes the value the lesson opened with, so a state looks the same live,
88
90
  on the sheet and in a tour. To change some params and keep the rest, use `setMany`.
89
91
 
92
+ `show` and `reset` act on the whole lesson. A Reset button under one beat's figure that calls `reset` also clears what
93
+ the reader set in every other beat; give it `resetBeat('that-beat')`. It reports the reason `reset`, like `reset`, and
94
+ stops a player that moves one of the beat's params. When a beat's states set a shared param, such as a temperature every
95
+ beat reads, list the beat's own params in `params` so its reset leaves the shared one alone.
96
+
90
97
  A control of yours that calls `set` keeps the value on the param's step and inside its range, and passes the event's
91
98
  details as the origin so the change reports a reader's source:
92
99
  `set('bias', bias, { reason: details.reason, event: details.event })`. A draggable `ScenePoint` needs no handler: its
93
100
  `sets` prop writes the params for it.
94
101
 
95
102
  ```tsx
96
- /** A button that shows a declared state, and one that resets. */
103
+ /** A button that shows a declared state, and one that resets this beat's params. */
97
104
  export function StateButtons(): ReactNode {
98
- const { show, reset, beat, next } = useLesson(lesson);
105
+ const { show, resetBeat, beat, next } = useLesson(lesson);
99
106
 
100
107
  return (
101
108
  <>
102
109
  <Button onClick={() => show('skeptic')}>Show a skeptical neuron</Button>
103
- <Button onClick={() => reset()}>Start again</Button>
110
+ <Button onClick={(event) => resetBeat('bias', { reason: 'reset', event: event.nativeEvent })}>Start again</Button>
104
111
  <Button onClick={() => next()}>{beat === 'learning' ? 'Done' : 'Next'}</Button>
105
112
  </>
106
113
  );
@@ -121,9 +128,11 @@ A name the lesson does not declare draws a short inline error in the danger colo
121
128
 
122
129
  ## Time
123
130
 
124
- `<Playback name from? to? pace? isLooping? />` drives a number param one step at a time on the shared clock. It renders
125
- nothing. `pace` is `'fast'`, `'regular'` or `'slow'`. It pauses when the tab is hidden or the reader moves the value,
126
- and with reduced motion `play` jumps to the end.
131
+ `<Playback name from? to? pace? isLooping? />` drives a number param on the shared clock. It renders nothing. `pace` is
132
+ `'fast'` (12 steps a second), `'regular'` (6) or `'slow'` (2), or a timed run: `{ run: 'short' | 'regular' | 'long' }`
133
+ crosses the whole range in 2, 5 or 10 seconds however many steps it has, so a 320-step training run fits in `long`. Add
134
+ `isEased: true` for a run that starts fast and settles, such as a blend. It pauses when the tab is hidden or the reader
135
+ moves the value, and with reduced motion `play` jumps to the end.
127
136
 
128
137
  `<Transport for="name" labels? />` plays, pauses, steps and scrubs it. Every `Playback` needs a `Transport` the reader
129
138
  can reach, or the beat sheet flags it. `usePlayback(name)` returns `{ isPlaying, play, pause, toggle, stepBy, seek }`
@@ -12,12 +12,13 @@ For a scene whose box is a coordinate plane. All positions and values are in dat
12
12
  label. Leave the axes out of a diagram whose positions mean nothing.
13
13
  - `SceneCurve`: `of` (a function of x) or `points` (`[x, y]` pairs, x increasing), `resolution`, `fillTo`, `isDashed`
14
14
  for a modelled curve, `thickness`. A new `of` eases from the old shape.
15
- - `ScenePoint`: `at`, `text`, and `sets` to make it draggable and movable by the arrow keys. `sets` names the number
16
- params its position writes, as `{ x: 'bias' }`; a move sets them in one change, on each param's step grid and inside
17
- its range. `along` (`'x'`, `'y'` or a function of x) limits the move, and a point bound on one axis moves along it.
18
- `snap` sets the step of an axis no param owns. The point stays at `at`, read from the lesson. Reach for
19
- `onMove(position, details)` only when a move is not a plain param write, and set a lesson param there, never component
20
- state.
15
+ - `ScenePoint`: `at`, `text`, and `sets` to make it a slider: the reader drags it, or reaches it with Tab and moves it
16
+ with the arrow keys, Home and End, and it speaks each bound value in its param's format. On a point that sets `x` and
17
+ `y`, Left and Right move x and Up and Down move y. `sets` names the number params its position writes, as
18
+ `{ x: 'bias' }`; a move sets them in one change, on each param's step grid and inside its range. `along` (`'x'`, `'y'`
19
+ or a function of x) limits the move, and a point bound on one axis moves along it. `snap` sets the step of an axis no
20
+ param owns. The point stays at `at`, read from the lesson. Reach for `onMove(position, details)` only when a move is
21
+ not a plain param write, and set a lesson param there, never component state.
21
22
  - `SceneVector`: `to`, `from` (defaults to the origin), `text`, `isDashed` for a step not yet taken.
22
23
  - `SceneProjection`: `of` (a point's id) or `at`, dashed lines to both axes with the values written there.
23
24
  - `SceneRegion`: one of `between` (two x values), `above`, `below` (a y value) or `points` (a polygon). Keep it pale.
@@ -63,14 +64,17 @@ export function ConfidenceScene(): ReactNode {
63
64
  - `SceneCard`: `rank` (`'A'`, `'2'` to `'10'`, `'J'`, `'Q'`, `'K'`) with `suit` (`'heart'`, `'diamond'`, `'spade'`,
64
65
  `'club'`) for a playing card, or `text` for a generic card. `isFaceUp` turns it over (default true), `lift` raises it,
65
66
  `tilt` leans it, `size` is `'small'`, `'medium'` or `'large'`, and `children` go on the face, even a chart. Its tone
66
- defaults to its suit's (`suitTones`), and its back stays neutral so it hides the suit. A face-down playing card reads
67
- "A card, face down" unless you give it a `label`. Place it with `at`, or list it in one `SceneStack`.
67
+ defaults to its suit's (`suitTones`), and its back stays neutral so it hides the suit. A face-down card renders only
68
+ its back and reads "A card, face down", so leave out `label` and keep its `id` free of its rank and suit. To turn it
69
+ when pressed, give the `Scene` `selected={null}` and `onSelectedChange` (see the scene reference). Place it with `at`,
70
+ or list it in one `SceneStack`.
68
71
  - `SceneStack`: `id`, `at`, `cards` (ids, bottom of a pile first), `layout` (`'pile'`, `'fan'`, `'row'`, `'column'`),
69
72
  `gap`, `size`, `stagger`. Move a card between stacks by moving its id from one list to the other. `stagger`
70
73
  (`'short'`, `'regular'`, `'long'`) deals in turn: cards that arrive or move in the same update start that step apart,
71
74
  in stack order, and a lone card starts at once. Use it, not a card's `delay`, to deal. A card in two stacks, or a card
72
75
  with no place, shows an error.
73
- - `SceneSlot`: an empty bay a card is dealt to, with `text`, `size` and `isActive` for the one that matters now.
76
+ - `SceneSlot`: an empty bay a card is dealt to, with `text`, `size` and `isActive` for the one that matters now. A
77
+ slot's `isActive` only draws its outline and tint; nothing else recedes.
74
78
 
75
79
  A deal is two lists of ids. Changing the hand moves the cards, flips them and deals them in turn, with no motion code:
76
80
 
@@ -111,9 +115,10 @@ export function HandScene(): ReactNode {
111
115
 
112
116
  `SceneCells` draws a small vector or matrix: `values` (a flat list is one row; a list of lists is a matrix) or `cells`
113
117
  (`{ id?, text?, value?, label? }` rows), `direction`, `format`, `palette` (`'sequential'` or `'diverging'`) with
114
- `domain`, `rowLabels`, `columnLabels`, `highlight` (`{ row?, column? }`) and `size`. A cell's id is
115
- `${id}.${row}.${column}`, so a wire or callout can name one. Changed values ease. For a large grid with axes, use the
116
- `Matrix` chart.
118
+ `domain`, `rowLabels`, `columnLabels` (they wrap, and a long word overhangs rather than being cut), `highlight`
119
+ (`{ row?, column? }`) and `size`. A cell also takes `tone`, such as its suit's hue, and `isMuted` to gray one already
120
+ dealt. A cell's id is `${id}.${row}.${column}`, so a wire or callout can name one. Changed values ease. For a large grid
121
+ with axes, use the `Matrix` chart.
117
122
 
118
123
  ```tsx
119
124
  /** The weights and the bias as cells, shaded around zero. */