@mechane-ai/elements 0.47.0 → 0.48.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 (204) hide show
  1. package/README.md +288 -5
  2. package/bin/mechane-elements-catalog.mjs +104 -12
  3. package/dist/article-BXZr10QQ.js +1904 -0
  4. package/dist/article.js +1 -0
  5. package/dist/catalog.json +1389 -75
  6. package/dist/{categorical-values-DdfGIowV.js → categorical-values-BpVq8cFj.js} +1 -1
  7. package/dist/{cells--Bd1fQFR.js → cells-xVmnQ9oQ.js} +1 -1
  8. package/dist/charts/cartesian.js +1 -1
  9. package/dist/charts/cells.js +1 -1
  10. package/dist/charts/comparison.js +1 -1
  11. package/dist/charts/distribution.js +1 -1
  12. package/dist/charts/figure.js +12 -12
  13. package/dist/charts/graph.js +1 -1
  14. package/dist/charts/hierarchy.js +1 -1
  15. package/dist/charts/image.js +1 -1
  16. package/dist/charts/matrix.js +3 -2
  17. package/dist/charts/plot.js +4 -4
  18. package/dist/charts/relationship.js +1 -1
  19. package/dist/charts/text.js +1 -1
  20. package/dist/charts/timeline.js +1 -1
  21. package/dist/charts/trend.js +1 -1
  22. package/dist/charts.js +2 -2
  23. package/dist/clock-DSm5lkNE.js +16 -0
  24. package/dist/collections.js +1 -1
  25. package/dist/describe-lesson-BmREzDpt.js +175 -0
  26. package/dist/{dumbbell-plot-B2ZTgQaI.js → dumbbell-plot-DQdTxDeO.js} +6 -5
  27. package/dist/{embedding-map-CGM_k6lC.js → embedding-map-CF-J-8JW.js} +5 -5
  28. package/dist/{figure-frame-wRkIEAwe.js → figure-frame-BJ3REgTA.js} +1 -1
  29. package/dist/forms.js +1 -1
  30. package/dist/{image-grid-CVA4SOy_.js → image-grid-Dl2sjIMB.js} +3 -3
  31. package/dist/kits/evaluation.js +5 -5
  32. package/dist/kits/interpretability.js +9 -9
  33. package/dist/kits/operations.js +4 -4
  34. package/dist/kits/training.js +4 -4
  35. package/dist/lesson/agent.js +811 -0
  36. package/dist/lesson/spec.js +661 -0
  37. package/dist/lesson.js +5 -0
  38. package/dist/mdx.js +227 -0
  39. package/dist/packages/charts/src/matrix/index.d.ts +1 -0
  40. package/dist/packages/charts/src/plot/plot-marks.d.ts +7 -3
  41. package/dist/packages/teaching/src/agent/index.d.ts +11 -0
  42. package/dist/packages/teaching/src/agent/learner-trace.d.ts +84 -0
  43. package/dist/packages/teaching/src/agent/lesson-bridge.d.ts +59 -0
  44. package/dist/packages/teaching/src/agent/lesson-tour.d.ts +63 -0
  45. package/dist/packages/teaching/src/agent/tutor-tools.d.ts +86 -0
  46. package/dist/packages/teaching/src/article/article-checks.d.ts +9 -0
  47. package/dist/packages/teaching/src/article/article-context.d.ts +49 -0
  48. package/dist/packages/teaching/src/article/article-error.d.ts +12 -0
  49. package/dist/packages/teaching/src/article/article-labels.d.ts +54 -0
  50. package/dist/packages/teaching/src/article/article-layout.stylex.d.ts +14 -0
  51. package/dist/packages/teaching/src/article/article-outline.d.ts +9 -0
  52. package/dist/packages/teaching/src/article/article.d.ts +42 -0
  53. package/dist/packages/teaching/src/article/beat-steps.d.ts +18 -0
  54. package/dist/packages/teaching/src/article/beat.d.ts +16 -0
  55. package/dist/packages/teaching/src/article/challenge.d.ts +29 -0
  56. package/dist/packages/teaching/src/article/exercise-styles.d.ts +76 -0
  57. package/dist/packages/teaching/src/article/figure.d.ts +51 -0
  58. package/dist/packages/teaching/src/article/index.d.ts +31 -0
  59. package/dist/packages/teaching/src/article/lesson-values.d.ts +5 -0
  60. package/dist/packages/teaching/src/article/notes.d.ts +36 -0
  61. package/dist/packages/teaching/src/article/outline-types.d.ts +73 -0
  62. package/dist/packages/teaching/src/article/predict.d.ts +58 -0
  63. package/dist/packages/teaching/src/article/progress-store.d.ts +64 -0
  64. package/dist/packages/teaching/src/article/scrolly.d.ts +26 -0
  65. package/dist/packages/{kits/src/explainers → teaching/src/article}/term.d.ts +8 -2
  66. package/dist/packages/teaching/src/article/tex.d.ts +12 -0
  67. package/dist/packages/teaching/src/article/view-essay.d.ts +13 -0
  68. package/dist/packages/teaching/src/article/view-present.d.ts +8 -0
  69. package/dist/packages/teaching/src/article/view-sheet.d.ts +7 -0
  70. package/dist/packages/teaching/src/article/view-static.d.ts +7 -0
  71. package/dist/packages/teaching/src/article/walk.d.ts +34 -0
  72. package/dist/packages/teaching/src/lesson/define-lesson.d.ts +136 -0
  73. package/dist/packages/teaching/src/lesson/index.d.ts +24 -0
  74. package/dist/packages/teaching/src/lesson/inline-choice.d.ts +12 -0
  75. package/dist/packages/teaching/src/lesson/lesson-context.d.ts +18 -0
  76. package/dist/packages/teaching/src/lesson/lesson-error.d.ts +12 -0
  77. package/dist/packages/teaching/src/lesson/lesson-locale.d.ts +4 -0
  78. package/dist/packages/teaching/src/lesson/lesson-persistence.d.ts +17 -0
  79. package/dist/packages/teaching/src/lesson/lesson-player.d.ts +51 -0
  80. package/dist/packages/teaching/src/lesson/lesson-store.d.ts +84 -0
  81. package/dist/packages/teaching/src/lesson/lesson.d.ts +39 -0
  82. package/dist/packages/teaching/src/lesson/param-controls.d.ts +14 -0
  83. package/dist/packages/teaching/src/lesson/param.d.ts +34 -0
  84. package/dist/packages/teaching/src/lesson/playback.d.ts +42 -0
  85. package/dist/packages/teaching/src/lesson/transport.d.ts +19 -0
  86. package/dist/packages/teaching/src/lesson/use-lesson.d.ts +36 -0
  87. package/dist/packages/teaching/src/mdx/essay-components.d.ts +79 -0
  88. package/dist/packages/teaching/src/mdx/essay-markdown.d.ts +41 -0
  89. package/dist/packages/teaching/src/mdx/essay.d.ts +32 -0
  90. package/dist/packages/teaching/src/mdx/index.d.ts +9 -0
  91. package/dist/packages/teaching/src/mdx/requested-view.d.ts +6 -0
  92. package/dist/packages/teaching/src/scene/flow/flow-layout.d.ts +38 -0
  93. package/dist/packages/teaching/src/scene/flow/flow-pulse.d.ts +16 -0
  94. package/dist/packages/teaching/src/scene/flow/scene-flow.d.ts +81 -0
  95. package/dist/packages/teaching/src/scene/index.d.ts +77 -0
  96. package/dist/packages/teaching/src/scene/morph/morph-scope.d.ts +28 -0
  97. package/dist/packages/teaching/src/scene/plane/plane-hit.d.ts +22 -0
  98. package/dist/packages/teaching/src/scene/plane/plane-label.d.ts +23 -0
  99. package/dist/packages/teaching/src/scene/plane/plane-labels.d.ts +42 -0
  100. package/dist/packages/teaching/src/scene/plane/plane-math.d.ts +45 -0
  101. package/dist/packages/teaching/src/scene/plane/scene-axes.d.ts +30 -0
  102. package/dist/packages/teaching/src/scene/plane/scene-curve.d.ts +42 -0
  103. package/dist/packages/teaching/src/scene/plane/scene-point.d.ts +59 -0
  104. package/dist/packages/teaching/src/scene/plane/scene-projection.d.ts +27 -0
  105. package/dist/packages/teaching/src/scene/plane/scene-region.d.ts +38 -0
  106. package/dist/packages/teaching/src/scene/plane/scene-rule.d.ts +35 -0
  107. package/dist/packages/teaching/src/scene/plane/scene-vector.d.ts +39 -0
  108. package/dist/packages/teaching/src/scene/scene-bracket.d.ts +24 -0
  109. package/dist/packages/teaching/src/scene/scene-callout.d.ts +26 -0
  110. package/dist/packages/teaching/src/scene/scene-context.d.ts +179 -0
  111. package/dist/packages/teaching/src/scene/scene-custom.d.ts +31 -0
  112. package/dist/packages/teaching/src/scene/scene-geometry.d.ts +181 -0
  113. package/dist/packages/teaching/src/scene/scene-group.d.ts +28 -0
  114. package/dist/packages/teaching/src/scene/scene-highlight.d.ts +19 -0
  115. package/dist/packages/teaching/src/scene/scene-layer.d.ts +16 -0
  116. package/dist/packages/teaching/src/scene/scene-node.d.ts +67 -0
  117. package/dist/packages/teaching/src/scene/scene-obstacles.d.ts +27 -0
  118. package/dist/packages/teaching/src/scene/scene-registry.d.ts +79 -0
  119. package/dist/packages/teaching/src/scene/scene-stagger.d.ts +43 -0
  120. package/dist/packages/teaching/src/scene/scene-style.d.ts +14 -0
  121. package/dist/packages/teaching/src/scene/scene-validate.d.ts +65 -0
  122. package/dist/packages/teaching/src/scene/scene-wire.d.ts +45 -0
  123. package/dist/packages/teaching/src/scene/scene.d.ts +36 -0
  124. package/dist/packages/teaching/src/scene/shapes/cell-color.d.ts +11 -0
  125. package/dist/packages/teaching/src/scene/shapes/cell-grid.d.ts +69 -0
  126. package/dist/packages/teaching/src/scene/shapes/scene-card.d.ts +114 -0
  127. package/dist/packages/teaching/src/scene/shapes/scene-cells.d.ts +84 -0
  128. package/dist/packages/teaching/src/scene/shapes/scene-slot.d.ts +37 -0
  129. package/dist/packages/teaching/src/scene/shapes/scene-stack.d.ts +46 -0
  130. package/dist/packages/teaching/src/scene/shapes/scene-token.d.ts +63 -0
  131. package/dist/packages/teaching/src/scene/shapes/scene-tokens.d.ts +40 -0
  132. package/dist/packages/teaching/src/scene/shapes/stack-book.d.ts +35 -0
  133. package/dist/packages/teaching/src/scene/shapes/stack-layout.d.ts +63 -0
  134. package/dist/packages/teaching/src/scene/shapes/token-layout.d.ts +39 -0
  135. package/dist/packages/teaching/src/spec/advice.d.ts +23 -0
  136. package/dist/packages/teaching/src/spec/chart-names.d.ts +2 -0
  137. package/dist/packages/teaching/src/spec/describe-lesson.d.ts +85 -0
  138. package/dist/packages/teaching/src/spec/explainer-guide.d.ts +21 -0
  139. package/dist/packages/teaching/src/spec/findings.d.ts +39 -0
  140. package/dist/packages/teaching/src/spec/index.d.ts +14 -0
  141. package/dist/packages/teaching/src/spec/lesson-plan.d.ts +43 -0
  142. package/dist/packages/teaching/src/spec/validate-plan.d.ts +11 -0
  143. package/dist/packages/teaching/src/time/clock.d.ts +7 -0
  144. package/dist/packages/teaching/src/time/tween.d.ts +19 -0
  145. package/dist/packages/teaching/src/time/use-tween.d.ts +6 -0
  146. package/dist/param-CqKUTHaO.js +450 -0
  147. package/dist/{plot-layout-BEuoOHbs.js → plot-layout-CZVSJ-le.js} +2 -1
  148. package/dist/{plot-marks-A64v7aTw.js → plot-marks-uozcbOIX.js} +15 -12
  149. package/dist/{plot-surface-CJTIqtck.js → plot-surface-CbVBvgqZ.js} +1 -1
  150. package/dist/{reference-lines-CWA8VeUR.js → reference-lines-BDcttOp0.js} +2 -2
  151. package/dist/scene-0z2gbaDE.js +4938 -0
  152. package/dist/scene.js +1 -0
  153. package/dist/{slope-chart-DT22h_ym.js → slope-chart-BKVEAVCs.js} +5 -5
  154. package/dist/{src-1EHkSFS-.js → src-BD6xlvDt.js} +2 -2
  155. package/dist/{src-D5NXRJZe.js → src-Dcfq8vE4.js} +1 -1
  156. package/dist/styles2.css +475 -18
  157. package/dist/{time-series-IB3CB93O.js → time-series-BgzGNOk0.js} +12 -10
  158. package/dist/{token-heatmap-C00DnoNO.js → token-heatmap-BrW1OsKD.js} +2 -2
  159. package/dist/{token-predictions-Cxx29iDr.js → token-predictions-yerq_Oet.js} +4 -4
  160. package/dist/transport-BJweqDPj.js +715 -0
  161. package/dist/{tree-diagram-DsckNKaW.js → tree-diagram-D09BRqE-.js} +4 -4
  162. package/dist/{treemap-9_DpLCW9.js → treemap-CW4WsJNL.js} +4 -4
  163. package/dist/use-tween-5HZ55_9d.js +72 -0
  164. package/dist/{violin-plot-BhPHKXsN.js → violin-plot-DrtPZ1-T.js} +5 -4
  165. package/dist/{waterfall-CGksuTy5.js → waterfall-DYLSnGjm.js} +4 -4
  166. package/package.json +26 -5
  167. package/recipes/counting-cards.tsx +656 -0
  168. package/recipes/explorable-essay.tsx +172 -0
  169. package/skills/extend-elements/SKILL.md +21 -0
  170. package/skills/plan-lesson/SKILL.md +86 -0
  171. package/skills/plan-lesson/references/plan-format.md +114 -0
  172. package/skills/plan-lesson/references/worked-plan.md +171 -0
  173. package/skills/review-elements/SKILL.md +4 -2
  174. package/skills/review-explainer/SKILL.md +97 -0
  175. package/skills/upgrade-elements/references/releases.md +65 -0
  176. package/skills/use-elements/SKILL.md +18 -16
  177. package/skills/use-elements/references/kits.md +2 -20
  178. package/skills/use-elements/references/teaching.md +36 -0
  179. package/skills/write-explainer/SKILL.md +112 -0
  180. package/skills/write-explainer/references/article.md +164 -0
  181. package/skills/write-explainer/references/lesson.md +148 -0
  182. package/skills/write-explainer/references/mdx.md +78 -0
  183. package/skills/write-explainer/references/scene-parts.md +273 -0
  184. package/skills/write-explainer/references/scene.md +168 -0
  185. package/skills/write-explainer/references/tutor.md +104 -0
  186. package/skills/write-explainer/references/worked-essay.md +459 -0
  187. package/templates/essay/AGENTS.md +14 -0
  188. package/templates/essay/README.md +59 -0
  189. package/templates/essay/index.html +17 -0
  190. package/templates/essay/package.template.json +21 -0
  191. package/templates/essay/plan.json +96 -0
  192. package/templates/essay/src/essay.mdx +97 -0
  193. package/templates/essay/src/figures.tsx +92 -0
  194. package/templates/essay/src/lesson.ts +83 -0
  195. package/templates/essay/src/main.tsx +53 -0
  196. package/templates/essay/src/mdx.d.ts +7 -0
  197. package/templates/essay/tsconfig.template.json +15 -0
  198. package/templates/essay/vite.config.template.txt +8 -0
  199. package/dist/kits/explainers.js +0 -452
  200. package/dist/packages/kits/src/explainers/figures.d.ts +0 -31
  201. package/dist/packages/kits/src/explainers/index.d.ts +0 -8
  202. package/dist/packages/kits/src/explainers/story-steps.d.ts +0 -46
  203. /package/dist/packages/{kits/src/explainers → teaching/src/article}/linked-target.d.ts +0 -0
  204. /package/dist/packages/{kits/src/explainers → teaching/src/lesson}/bound-value.d.ts +0 -0
@@ -1,452 +0,0 @@
1
- import { r as e } from "../figure-format-B8kRZMlo.js";
2
- import { n as t, t as n } from "../chart-link-AE_xuxiP.js";
3
- import { T as r } from "../src-CpdJlDhO.js";
4
- import { a as i } from "../src-1EHkSFS-.js";
5
- import { t as a } from "../chart-tones-ei3BC2AL.js";
6
- import { i as o } from "../tone-scope-DKiSw-JR.js";
7
- import { r as s } from "../tokens.stylex-dF5CACEJ.js";
8
- import * as c from "@stylexjs/stylex";
9
- import { createParts as l } from "@ui-sdk/react/primitive";
10
- import { createContext as u, useContext as d, useId as f, useState as p } from "react";
11
- import { bindDrag as m, createChange as h, definePrimitive as g, dispatch as _, dragThreshold as v, isRTL as y } from "@ui-sdk/core";
12
- import { Fragment as b, jsx as x, jsxs as S } from "react/jsx-runtime";
13
- import { clamp as C, fractionOf as w, scrubTo as T, stepBy as E, stepFromKey as D, stepValue as O, valueAt as k } from "@ui-sdk/core/number";
14
- // packages/kits/src/explainers/bound-value.tsx
15
- var A = 240, j = {
16
- step: .01,
17
- large: .1,
18
- small: .001
19
- }, M = [
20
- "ArrowLeft",
21
- "ArrowRight",
22
- "ArrowUp",
23
- "ArrowDown",
24
- "PageUp",
25
- "PageDown",
26
- "Home",
27
- "End"
28
- ];
29
- function N({ min: e, max: t, step: n }) {
30
- return {
31
- min: e,
32
- max: t,
33
- step: n
34
- };
35
- }
36
- function P(e, t) {
37
- let n = N(t);
38
- return T(k(C(e, 0, 1), n, t.scale ?? "linear"), n).value;
39
- }
40
- function F(e, t, n) {
41
- if (t.bound !== void 0) return t.bound === "min" ? n.min : n.max;
42
- let r = N(n), i = P(w(e, r, "log") + t.direction * j[t.size], n);
43
- return i === e ? O(e, t.direction, r) : i;
44
- }
45
- var I = g({
46
- name: "bound-value",
47
- options: {
48
- value: "number",
49
- defaultValue: "number",
50
- onValueChange: "callback",
51
- min: "number",
52
- max: "number",
53
- step: "number",
54
- scale: "string",
55
- describe: "value"
56
- },
57
- controlled: ["value"],
58
- state: (e) => ({
59
- value: e.value ?? e.defaultValue ?? e.min,
60
- isDragging: !1
61
- }),
62
- sync: (e) => e.value === void 0 ? {} : { value: e.value },
63
- api: (e) => {
64
- let { store: t } = e, n = h(e), r = null;
65
- e.onDestroy(() => r?.());
66
- function i(e, r, i) {
67
- return e !== t.get().value && n("value", e, i === void 0 ? { reason: r } : {
68
- reason: r,
69
- event: i
70
- });
71
- }
72
- return {
73
- describe: (t) => e.options().describe(t),
74
- setValue(t) {
75
- let { min: n, max: r } = e.options(), a = Number(t);
76
- if (!Number.isFinite(a) || a < n || a > r) throw Error(`Give a number between ${n} and ${r}.`);
77
- return i(T(a, N(e.options())).value, "imperative");
78
- },
79
- keydown(n, r) {
80
- let a = D(n, { dir: y(r) ? "rtl" : "ltr" });
81
- if (a === null || n.defaultPrevented) return;
82
- n.preventDefault();
83
- let o = e.options(), { value: s } = t.get();
84
- i(o.scale === "log" ? F(s, a, o) : E(s, a, N(o)), "step-key", n);
85
- },
86
- pointerdown(n, a) {
87
- if (n.button !== 0) return;
88
- r?.();
89
- let o = t.get().value, s = y(a) ? -1 : 1, c = w(o, N(e.options()), e.options().scale ?? "linear"), l = 0;
90
- r = m(a, n, {
91
- threshold: v,
92
- cancelOnEscape: !0,
93
- onStart: () => {
94
- t.set({ isDragging: !0 });
95
- },
96
- onMove: ({ movementX: t, event: n }) => {
97
- l += t * s, i(P(c + l / A, e.options()), "drag", n);
98
- },
99
- onEnd: (e, n) => {
100
- t.set({ isDragging: !1 }), n && i(o, "drag", e);
101
- }
102
- });
103
- }
104
- };
105
- },
106
- slots: (e) => ({ root: e({
107
- role: "slider",
108
- focus: "tab-stop",
109
- keys: [...M],
110
- state: (e, { api: t }) => ({
111
- text: t.describe(e.value),
112
- isDragging: e.isDragging
113
- }),
114
- attrs: (e, { api: t }) => ({
115
- tabindex: "0",
116
- "aria-valuenow": String(e.value),
117
- "aria-valuetext": t.describe(e.value),
118
- "data-dragging": e.isDragging ? "" : void 0
119
- }),
120
- on: {
121
- keydown: (e, { api: t, el: n }) => {
122
- n !== void 0 && t.keydown(e, n);
123
- },
124
- pointerdown: (e, { api: t, el: n }) => {
125
- n !== void 0 && t.pointerdown(e, n);
126
- }
127
- }
128
- }) }),
129
- agent: { actions: ["setValue"] }
130
- }), L = l(I, { root: "span" }).Root;
131
- function R({ min: e, max: t, step: n, scale: r, value: i }) {
132
- if (!Number.isFinite(e) || !Number.isFinite(t) || e >= t) return "BoundValue needs finite bounds with min below max.";
133
- if (!Number.isFinite(n) || n < 0) return "BoundValue needs a step of zero or more.";
134
- if (r === "log" && e <= 0) return "A log BoundValue needs a min above zero.";
135
- if (i !== void 0 && !(Number.isFinite(i) && i >= e && i <= t)) return `BoundValue ${i} lies outside ${e} to ${t}.`;
136
- }
137
- function z({ label: t, locale: n, format: r, ...i }) {
138
- let a = R(i);
139
- return a === void 0 ? /* @__PURE__ */ x(L, {
140
- ...i,
141
- describe: (t) => e({
142
- value: t,
143
- locale: n,
144
- format: r
145
- }),
146
- "aria-label": t,
147
- "aria-valuemin": i.min,
148
- "aria-valuemax": i.max,
149
- "aria-orientation": "horizontal",
150
- className: "xt0psk2 x1ok0vyi xbixft xss6m8b xk4h15q xuxw1ft x7eptgl x87ps6o xx69xxh xujl8zx xi2nhp4 xewurvo x11xz5oc x1jdncgf xif5pkx x81ozek xxxv2na x13qnu6 x9v5kkp x19rmrnh x7s97pk",
151
- render: (e, { text: t }) => /* @__PURE__ */ x("span", {
152
- ...e,
153
- children: t
154
- })
155
- }) : /* @__PURE__ */ x("span", {
156
- className: "xr5kp14 x1b5ytql",
157
- children: a
158
- });
159
- }
160
- // packages/kits/src/explainers/figures.tsx
161
- var B = u(void 0);
162
- function V(e) {
163
- let t = d(B)?.indexOf(e) ?? -1;
164
- return t === -1 ? void 0 : t + 1;
165
- }
166
- function H(e) {
167
- return `Unknown figure "${e}": add it to the explainer's figures`;
168
- }
169
- function U({ figures: e, children: t }) {
170
- return /* @__PURE__ */ x(B, {
171
- value: e,
172
- children: t
173
- });
174
- }
175
- function W({ id: e, caption: t, children: n }) {
176
- let r = V(e);
177
- return /* @__PURE__ */ S("figure", {
178
- id: e,
179
- className: "xrvj5dj x1hnptsi xeuugli x1ghz6dp xqalb56",
180
- children: [n, /* @__PURE__ */ x("figcaption", {
181
- className: "x1ghz6dp x153jb6y x1hz01jw xy8obcc xas2l8k xj0a0fe",
182
- children: r === void 0 ? /* @__PURE__ */ x("span", {
183
- className: "xr5kp14 x1b5ytql",
184
- children: H(e)
185
- }) : /* @__PURE__ */ S(b, { children: [
186
- /* @__PURE__ */ x("span", {
187
- className: "xbixft x1b5ytql",
188
- children: `Figure ${r}.`
189
- }),
190
- " ",
191
- t
192
- ] })
193
- })]
194
- });
195
- }
196
- function G({ to: e }) {
197
- let t = V(e);
198
- return t === void 0 ? /* @__PURE__ */ x("span", {
199
- className: "xr5kp14 x1b5ytql",
200
- children: H(e)
201
- }) : /* @__PURE__ */ x("a", {
202
- href: `#${encodeURIComponent(e)}`,
203
- className: "x1heor9g xujl8zx xibglb1 x1ohr1zr x1ok0vyi xd636jy x13qnu6 x9v5kkp x19rmrnh x7s97pk",
204
- children: `Figure ${t}`
205
- });
206
- }
207
- // packages/kits/src/explainers/story-steps.tsx
208
- var K = {
209
- back: "Back",
210
- next: "Next",
211
- step: "Step",
212
- of: "of"
213
- };
214
- function q(e, t) {
215
- if (e.length === 0) return "StorySteps needs at least one step.";
216
- if (new Set(e.map((e) => e.id)).size !== e.length) return "Every step needs its own id.";
217
- if (t !== void 0 && !e.some((e) => e.id === t)) return `Unknown step "${t}".`;
218
- }
219
- function J({ steps: e, step: a, defaultStep: o, onStepChange: s, label: c = "Steps", labels: l, children: u }) {
220
- let d = {
221
- ...K,
222
- ...l
223
- }, [m, h] = p(o ?? e[0]?.id), g = a ?? m, v = e.findIndex((e) => e.id === g), y = e[v], b = t(), [C, w] = p(y?.inspected ?? null), [T, E] = p(y?.id), D = f();
224
- b === void 0 && y !== void 0 && y.id !== T && (E(y.id), w(y.inspected ?? null));
225
- let O = q(e, g);
226
- if (O !== void 0 || y === void 0) return /* @__PURE__ */ x("p", {
227
- className: "x1ghz6dp xr5kp14 x1hz01jw xtqrqnz",
228
- children: O ?? "StorySteps has no step to show."
229
- });
230
- let k = e[v - 1], A = e[v + 1];
231
- function j(e, t) {
232
- h(e.id), b?.inspect(e.inspected ?? null, t);
233
- }
234
- function M(e, t, n) {
235
- e !== void 0 && (_({ options: () => ({ onStepChange: s }) }, "onStepChange", e.id, {
236
- reason: t,
237
- event: n
238
- }) || j(e, {
239
- reason: "item-press",
240
- event: n
241
- }));
242
- }
243
- let N = `${d.step} ${v + 1} ${d.of} ${e.length}`, P = /* @__PURE__ */ S("div", {
244
- className: "x78zum5 x1a02dak x1cy8zhl x1j825kq xeuugli",
245
- children: [/* @__PURE__ */ S("section", {
246
- "aria-label": c,
247
- className: "xrvj5dj x1n8ia3y x1iyjqo2 xs83m0k x5z4jtk xeuugli x1hz01jw xbixft",
248
- children: [
249
- /* @__PURE__ */ x("p", {
250
- className: "x1ghz6dp x153jb6y xy8obcc xas2l8k xss6m8b",
251
- children: N
252
- }),
253
- /* @__PURE__ */ S("div", {
254
- id: D,
255
- "aria-live": "polite",
256
- className: "xrvj5dj x1hnptsi xeuugli",
257
- children: [/* @__PURE__ */ x("p", {
258
- className: "x1ghz6dp x1i2cqwi x4fansv x1b5ytql",
259
- children: y.title
260
- }), /* @__PURE__ */ x("div", {
261
- className: "x1ghz6dp x12myhf4 x1ytb0s6 xj0a0fe",
262
- children: y.body
263
- })]
264
- }),
265
- /* @__PURE__ */ S("div", {
266
- className: "x78zum5 x1a02dak x6s0dn4 x1hnptsi xeuugli",
267
- children: [
268
- /* @__PURE__ */ x(r, {
269
- density: "compact",
270
- disabled: k === void 0,
271
- focusableWhenDisabled: !0,
272
- "aria-controls": D,
273
- onClick: (e) => M(k, "previous-press", e.nativeEvent),
274
- children: d.back
275
- }),
276
- /* @__PURE__ */ x(i.Root, {
277
- value: y.id,
278
- "aria-label": `${c}: ${N}`,
279
- onValueChange: (t, n) => {
280
- let r = e.find((e) => e.id === t);
281
- s?.(t, n), r !== void 0 && !n.canceled && j(r, {
282
- reason: n.reason === "list-navigation" ? "list-navigation" : "item-press",
283
- event: n.event
284
- });
285
- },
286
- children: e.map((e, t) => /* @__PURE__ */ x(i.Item, {
287
- value: e.id,
288
- "aria-label": `${t + 1}. ${e.title}`,
289
- children: t + 1
290
- }, e.id))
291
- }),
292
- /* @__PURE__ */ x(r, {
293
- density: "compact",
294
- disabled: A === void 0,
295
- focusableWhenDisabled: !0,
296
- "aria-controls": D,
297
- onClick: (e) => M(A, "next-press", e.nativeEvent),
298
- children: d.next
299
- })
300
- ]
301
- })
302
- ]
303
- }), /* @__PURE__ */ x("div", {
304
- className: "xrvj5dj x1j825kq xgyuaek xs83m0k xnp8db0 xeuugli",
305
- children: u
306
- })]
307
- });
308
- return b === void 0 ? /* @__PURE__ */ x(n, {
309
- inspected: C,
310
- onInspectedChange: (e, t) => {
311
- t.canceled || w(e);
312
- },
313
- children: P
314
- }) : P;
315
- }
316
- // packages/kits/src/explainers/linked-target.ts
317
- function Y(e) {
318
- let n = t(), r = n?.inspected === e;
319
- function i(t, r) {
320
- n?.inspected === e && n.inspect(null, {
321
- reason: r,
322
- event: t
323
- });
324
- }
325
- function a(t) {
326
- n?.inspect(e, {
327
- reason: "item-press",
328
- event: t
329
- });
330
- }
331
- return {
332
- isInspected: r,
333
- handlers: {
334
- onPointerEnter: (t) => {
335
- t.pointerType === "mouse" && n?.inspect(e, {
336
- reason: "item-hover",
337
- event: t.nativeEvent
338
- });
339
- },
340
- onPointerLeave: (e) => {
341
- e.pointerType === "mouse" && i(e.nativeEvent, "item-hover");
342
- },
343
- onFocus: (t) => n?.inspect(e, {
344
- reason: "focus-in",
345
- event: t.nativeEvent
346
- }),
347
- onBlur: (e) => i(e.nativeEvent, "focus-out"),
348
- onClick: (e) => a(e.nativeEvent)
349
- },
350
- press: a
351
- };
352
- }
353
- // packages/kits/src/explainers/term.tsx
354
- var X = "Highlights it in the figures.", Z = /* @__PURE__ */ new Set(["Enter", " "]), ee = {
355
- k1xSpc: "xt0psk2",
356
- kogj98: "x1ghz6dp",
357
- kmVPX3: "x1717udv",
358
- kMzoRj: "xc342km",
359
- kaIpWk: "x1ok0vyi",
360
- kWkggS: "xjbqb8w",
361
- kMwMTN: "x1heor9g",
362
- kMv6JI: "xjb2p0i",
363
- kGuDYH: "x1qlqyl8",
364
- k63SB2: "x1pd3egz",
365
- kLWn49: "x15bjb6t",
366
- k9WMMc: "x16tdsg8",
367
- kkrTdU: "x1ypdohk",
368
- kMnn75: "xujl8zx",
369
- kmVMDM: "xi2nhp4",
370
- kNySMw: "xewurvo",
371
- kcSHmL: "x1jdncgf",
372
- kPJHz1: "x13qnu6",
373
- k7shQP: "x9v5kkp",
374
- kZs9gx: "x19rmrnh",
375
- kiEn40: "x7s97pk",
376
- $$css: !0
377
- }, te = {
378
- kmVMDM: "x6ur5ct",
379
- kWkggS: "xl8spv7",
380
- $$css: !0
381
- }, ne = {
382
- kjVXCG: "x73je2i",
383
- kfJifR: "xhr4kjn",
384
- kDwRjp: "xbraz4a",
385
- kkrTdU: "x1ypdohk",
386
- k3XXqK: "x1t137rt",
387
- kGEFZS: "x1rvwdm5",
388
- kM8Kxi: "x17g5ih3",
389
- $$css: !0
390
- }, Q = {
391
- term: (e) => [
392
- ee,
393
- {
394
- k1TLXF: e == null ? e : "xnv2ixb",
395
- $$css: !0
396
- },
397
- { "--x-textDecorationColor": e ?? void 0 }
398
- ],
399
- inspected: (e) => [te, { "--x-backgroundColor": `color-mix(in srgb, ${e} 16%, transparent)` == null ? void 0 : `color-mix(in srgb, ${e} 16%, transparent)` }],
400
- part: (e) => [
401
- ne,
402
- {
403
- kMwMTN: e == null ? e : "x14rh7hd",
404
- $$css: !0
405
- },
406
- { "--x-color": e ?? void 0 }
407
- ],
408
- partInspected: {
409
- kfJifR: "xqjr0vm",
410
- kDwRjp: "x19cei4z",
411
- $$css: !0
412
- }
413
- };
414
- function $(e, t) {
415
- let n = o(e);
416
- return n === void 0 ? t : a[n];
417
- }
418
- function re({ inspects: e, children: t }) {
419
- let { isInspected: n, handlers: r } = Y(e), i = $(e, s.muted), a = f();
420
- return /* @__PURE__ */ S(b, { children: [/* @__PURE__ */ x("button", {
421
- type: "button",
422
- "aria-describedby": a,
423
- ...r,
424
- ...c.props(Q.term(i), n && Q.inspected(i)),
425
- children: t
426
- }), /* @__PURE__ */ x("span", {
427
- id: a,
428
- hidden: !0,
429
- children: X
430
- })] });
431
- }
432
- function ie({ inspects: e, label: t, children: n }) {
433
- let { isInspected: r, handlers: i, press: a } = Y(e), o = $(e, s.muted), l = f();
434
- function u(e) {
435
- Z.has(e.key) && (e.preventDefault(), a(e.nativeEvent));
436
- }
437
- return /* @__PURE__ */ S("g", {
438
- role: "button",
439
- tabIndex: 0,
440
- "aria-label": t,
441
- "aria-describedby": l,
442
- "data-inspected": r ? "" : void 0,
443
- ...i,
444
- onKeyDown: u,
445
- ...c.props(Q.part(o), r && Q.partInspected),
446
- children: [/* @__PURE__ */ x("desc", {
447
- id: l,
448
- children: X
449
- }), n]
450
- });
451
- }
452
- export { z as BoundValue, ie as DiagramPart, U as Explainer, G as FigureReference, W as NumberedFigure, J as StorySteps, re as Term };
@@ -1,31 +0,0 @@
1
- import type { ReactNode } from 'react';
2
- export type ExplainerProps = {
3
- /** The id of every numbered figure, in reading order. Numbers come from this list, so server and browser agree. */
4
- readonly figures: ReadonlyArray<string>;
5
- /** The article: prose, figures and references in any arrangement. */
6
- readonly children: ReactNode;
7
- };
8
- /**
9
- * A long page whose figures are numbered and referred to by number, like a paper. List the figure ids in reading order;
10
- * each `NumberedFigure` shows its number and each `FigureReference` links to it.
11
- */
12
- export declare function Explainer({ figures, children }: ExplainerProps): ReactNode;
13
- export type NumberedFigureProps = {
14
- /** The figure's id in the explainer's list. It is also the element id, so `#id` links land on the figure. */
15
- readonly id: string;
16
- /** What the reader should see in the figure, after its number. */
17
- readonly caption: ReactNode;
18
- /** The chart, diagram or image. */
19
- readonly children: ReactNode;
20
- };
21
- /**
22
- * A chart or diagram with its number and caption below it: "Figure 2. Loss falls faster for the wide run." A figure the
23
- * explainer does not list says so in place of its number.
24
- */
25
- export declare function NumberedFigure({ id, caption, children }: NumberedFigureProps): ReactNode;
26
- export type FigureReferenceProps = {
27
- /** The id of the figure the reference points to. */
28
- readonly to: string;
29
- };
30
- /** "Figure 2" in prose, as a link that moves the reader to that figure. An unknown id shows an error in its place. */
31
- export declare function FigureReference({ to }: FigureReferenceProps): ReactNode;
@@ -1,8 +0,0 @@
1
- export type { BoundValueChangeDetails, BoundValueProps, BoundValueScale } from './bound-value.tsx';
2
- export { BoundValue } from './bound-value.tsx';
3
- export type { ExplainerProps, FigureReferenceProps, NumberedFigureProps } from './figures.tsx';
4
- export { Explainer, FigureReference, NumberedFigure } from './figures.tsx';
5
- export type { StoryStep, StoryStepChangeDetails, StoryStepsLabels, StoryStepsProps } from './story-steps.tsx';
6
- export { StorySteps } from './story-steps.tsx';
7
- export type { DiagramPartProps, TermProps } from './term.tsx';
8
- export { DiagramPart, Term } from './term.tsx';
@@ -1,46 +0,0 @@
1
- import type { ChangeDetails } from '@ui-sdk/core';
2
- import type { SegmentedControlValueChangeReason } from '@ui-sdk/core/segmented-control';
3
- import type { ReactNode } from 'react';
4
- /** One observation in a walk through the figures. */
5
- export type StoryStep = {
6
- readonly id: string;
7
- readonly title: string;
8
- /** The explanation: a few sentences, which may hold `Term`s and `FigureReference`s. */
9
- readonly body: ReactNode;
10
- /**
11
- * The record this step talks about, which every linked figure inspects while the step is shown. The reader can still
12
- * inspect freely, and the next step points the figures again.
13
- */
14
- readonly inspected?: string | null | undefined;
15
- };
16
- /** Why the step changed: Back or Next, a press on a step's number, or an arrow key on the numbers. */
17
- export type StoryStepChangeDetails = ChangeDetails<SegmentedControlValueChangeReason | 'previous-press' | 'next-press'>;
18
- /** The words of the step controls. The position reads "Step 2 of 5": `step`, the number, `of`, the count. */
19
- export type StoryStepsLabels = {
20
- readonly back: string;
21
- readonly next: string;
22
- readonly step: string;
23
- readonly of: string;
24
- };
25
- export type StoryStepsProps = {
26
- /**
27
- * Back, Next and the step numbers move between steps, and the arrow keys move along the numbers. Nothing advances on
28
- * its own.
29
- */
30
- readonly steps: ReadonlyArray<StoryStep>;
31
- /** The id of the step shown, when the application holds it. */
32
- readonly step?: string | undefined;
33
- readonly defaultStep?: string | undefined;
34
- readonly onStepChange?: ((step: string, details: StoryStepChangeDetails) => void) | undefined;
35
- /** Names the walk for assistive technology, such as "How the runs differ". */
36
- readonly label?: string | undefined;
37
- readonly labels?: Partial<StoryStepsLabels> | undefined;
38
- /** The figures the steps talk about. They share one inspection with the steps. */
39
- readonly children: ReactNode;
40
- };
41
- /**
42
- * An explanation told in steps beside its figures, like a guided reading of a chart, where each step points every
43
- * linked figure at the record it talks about. Inside an enclosing `ChartLink`, such as one around a whole article, it
44
- * points that link on each move instead of keeping its own. Terms anywhere on the page then reach the same figures.
45
- */
46
- export declare function StorySteps({ steps, step, defaultStep, onStepChange, label, labels, children, }: StoryStepsProps): ReactNode;