reactive-md 0.4.0 → 0.4.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 (49) hide show
  1. package/CHANGELOG-ch.md +113 -96
  2. package/CHANGELOG.md +113 -96
  3. package/LICENSE +21 -21
  4. package/README-ch.md +123 -122
  5. package/README-en.md +147 -146
  6. package/README.md +147 -146
  7. package/bin/reactive-md.mjs +1 -1
  8. package/dist-library/reactive-md-react.js +199 -103
  9. package/dist-library/reactive-md.css +1 -1
  10. package/dist-library/reactive-md.js +1 -1
  11. package/dist-library/{runtime-DtjdPXxJ.js → runtime-D3QTVYaz.js} +122 -122
  12. package/dist-standalone/reactive-md-standalone.css +1 -1
  13. package/dist-standalone/reactive-md-standalone.js +1 -1
  14. package/docs/compatibility-ch.md +3 -3
  15. package/docs/compatibility-en.md +3 -3
  16. package/docs/release-0.4.0-ch.md +4 -4
  17. package/docs/release-0.4.0-en.md +4 -4
  18. package/docs/release-0.4.1-ch.md +23 -0
  19. package/docs/release-0.4.1-en.md +23 -0
  20. package/docs/releasing-ch.md +101 -101
  21. package/docs/releasing-en.md +101 -101
  22. package/examples/integration/core/package.json +7 -7
  23. package/examples/integration/react/index.html +12 -12
  24. package/examples/integration/react/main.jsx +21 -21
  25. package/examples/integration/react/package.json +9 -9
  26. package/examples/local/catalog.reactive.md +20 -20
  27. package/examples/local/checklist.reactive.md +32 -32
  28. package/examples/local/comparison.reactive.md +47 -47
  29. package/examples/local/components.reactive.md +44 -44
  30. package/examples/local/counter.reactive.md +7 -7
  31. package/examples/local/diagnostics.reactive.md +54 -54
  32. package/examples/local/diagram.reactive.md +44 -44
  33. package/examples/local/gallery.reactive.md +61 -61
  34. package/examples/local/parameters.reactive.md +36 -36
  35. package/examples/local/planning.reactive.md +24 -24
  36. package/examples/local/pricing.reactive.md +20 -20
  37. package/examples/local/zh/catalog.reactive.md +20 -20
  38. package/examples/local/zh/charts.reactive.md +73 -73
  39. package/examples/local/zh/checklist.reactive.md +32 -32
  40. package/examples/local/zh/comparison.reactive.md +47 -47
  41. package/examples/local/zh/components.reactive.md +44 -44
  42. package/examples/local/zh/counter.reactive.md +7 -7
  43. package/examples/local/zh/diagnostics.reactive.md +54 -54
  44. package/examples/local/zh/diagram.reactive.md +44 -44
  45. package/examples/local/zh/gallery.reactive.md +61 -61
  46. package/examples/local/zh/parameters.reactive.md +36 -36
  47. package/examples/local/zh/planning.reactive.md +24 -24
  48. package/examples/local/zh/pricing.reactive.md +20 -20
  49. package/package.json +91 -90
@@ -1,4 +1,4 @@
1
- import { A as e, I as t, L as n, M as r, N as i, P as a, S as o, T as s, d as c, f as l, g as u, h as d, i as f, m as p, n as m, p as h, s as g, t as _, v, x as y } from "./runtime-DtjdPXxJ.js";
1
+ import { A as e, I as t, L as n, M as r, N as i, P as a, S as o, T as s, d as c, f as l, g as u, h as d, i as f, m as p, n as m, p as h, s as g, t as _, v, x as y } from "./runtime-D3QTVYaz.js";
2
2
  import { Component as b, createContext as x, createElement as S, memo as C, useCallback as w, useContext as T, useEffect as E, useId as D, useMemo as O, useRef as k, useState as A, useSyncExternalStore as j } from "react";
3
3
  import { Fragment as M, jsx as N, jsxs as P } from "react/jsx-runtime";
4
4
  // src/local/math-view.tsx
@@ -844,7 +844,11 @@ function et({ node: e, runtime: t, render: n, mode: r }) {
844
844
  column: e,
845
845
  direction: "desc"
846
846
  } : null);
847
- }, I = (e) => !c || c.column !== e ? "" : c.direction === "asc" ? i(" (ascending)", "(升序)") : i(" (descending)", "(降序)");
847
+ }, I = (e) => !c || c.column !== e ? null : /* @__PURE__ */ N("span", {
848
+ className: "local-visual-sort-marker",
849
+ "aria-hidden": "true",
850
+ children: c.direction === "asc" ? "▲" : "▼"
851
+ });
848
852
  return r === "static" ? /* @__PURE__ */ P(W, {
849
853
  className: "local-visual-table-block local-static-table-block",
850
854
  label: h,
@@ -1121,25 +1125,25 @@ function rt({ node: e, runtime: t, mode: n }) {
1121
1125
  })
1122
1126
  ]
1123
1127
  });
1124
- let s = me / 2, l = -Math.PI / 2, p = [];
1128
+ let s = -Math.PI / 2, l = [];
1125
1129
  B.forEach((e, n) => {
1126
1130
  if (!i && c.has(n)) return;
1127
1131
  let r = t[n];
1128
1132
  if (r <= 0) return;
1129
- let o = r / a * Math.PI * 2, u = l, d = l + o;
1130
- l = d, p.push({
1133
+ let o = r / a * Math.PI * 2, u = s, d = s + o;
1134
+ s = d, l.push({
1131
1135
  key: `donut:${n}`,
1132
1136
  label: e.label,
1133
1137
  value: r,
1134
1138
  start: u,
1135
1139
  end: d,
1136
1140
  color: H[n % H.length],
1137
- x: s,
1138
- y: 140,
1141
+ x: 170,
1142
+ y: 120,
1139
1143
  rowKey: e.keyValue
1140
1144
  });
1141
1145
  });
1142
- let m = u ? r(`${u.label}: ${U(u.value)}`, `${u.label}:${U(u.value)}`) : r("Focus a slice or legend to view values", "聚焦扇区或图例查看数值");
1146
+ let p = u ? r(`${u.label}: ${U(u.value)}`, `${u.label}:${U(u.value)}`) : r("Focus a slice or legend to view values", "聚焦扇区或图例查看数值");
1143
1147
  return /* @__PURE__ */ P(W, {
1144
1148
  className: `local-visual-chart local-visual-chart-donut${i ? " local-static-chart" : ""}`,
1145
1149
  label: g,
@@ -1148,13 +1152,13 @@ function rt({ node: e, runtime: t, mode: n }) {
1148
1152
  className: "local-visual-readout",
1149
1153
  id: h,
1150
1154
  "aria-live": "polite",
1151
- children: m
1155
+ children: p
1152
1156
  }),
1153
1157
  /* @__PURE__ */ N("div", {
1154
1158
  className: "local-visual-svg-wrap",
1155
1159
  children: /* @__PURE__ */ P("svg", {
1156
1160
  className: "local-visual-svg",
1157
- viewBox: `0 0 ${me} 290`,
1161
+ viewBox: "0 0 340 240",
1158
1162
  role: "group",
1159
1163
  "aria-label": r(`${g}, donut chart, ${B.length} items`, `${g},环形图,共 ${B.length} 项`),
1160
1164
  "aria-describedby": i ? void 0 : h,
@@ -1162,19 +1166,19 @@ function rt({ node: e, runtime: t, mode: n }) {
1162
1166
  className: "local-visual-donut-center",
1163
1167
  "aria-hidden": "true",
1164
1168
  children: [/* @__PURE__ */ N("text", {
1165
- x: s,
1166
- y: 138,
1169
+ x: 170,
1170
+ y: 118,
1167
1171
  textAnchor: "middle",
1168
1172
  className: "local-visual-donut-total",
1169
1173
  children: U(a)
1170
1174
  }), /* @__PURE__ */ N("text", {
1171
- x: s,
1172
- y: 158,
1175
+ x: 170,
1176
+ y: 138,
1173
1177
  textAnchor: "middle",
1174
1178
  className: "local-visual-donut-caption",
1175
1179
  children: Fe(ee[0], 14)
1176
1180
  })]
1177
- }), p.map((e) => {
1181
+ }), l.map((e) => {
1178
1182
  let t = w && e.rowKey !== "", n = t && e.rowKey === T, a = {
1179
1183
  key: e.key,
1180
1184
  series: ee[0],
@@ -1200,20 +1204,20 @@ function rt({ node: e, runtime: t, mode: n }) {
1200
1204
  onKeyDown: (n) => {
1201
1205
  t && He(n) ? (n.preventDefault(), O(e.rowKey)) : n.key === "ArrowRight" || n.key === "ArrowDown" ? Ve(n, "[data-chart-mark]", 1) : (n.key === "ArrowLeft" || n.key === "ArrowUp") && Ve(n, "[data-chart-mark]", -1);
1202
1206
  }
1203
- }, c = `local-visual-donut-slice${n ? " is-selected" : ""}`;
1207
+ }, s = `local-visual-donut-slice${n ? " is-selected" : ""}`;
1204
1208
  return e.end - e.start >= Math.PI * 2 - 1e-6 ? /* @__PURE__ */ N("circle", {
1205
- className: c,
1206
- cx: s,
1207
- cy: 140,
1208
- r: 78,
1209
+ className: s,
1210
+ cx: 170,
1211
+ cy: 120,
1212
+ r: 77,
1209
1213
  fill: "none",
1210
1214
  style: { stroke: e.color },
1211
- strokeWidth: 40,
1215
+ strokeWidth: 30,
1212
1216
  ...o,
1213
1217
  children: /* @__PURE__ */ N("title", { children: r(`${e.label}: ${U(e.value)}`, `${e.label}:${U(e.value)}`) })
1214
1218
  }, e.key) : /* @__PURE__ */ N("path", {
1215
- className: c,
1216
- d: nt(s, 140, 98, 58, e.start, e.end),
1219
+ className: s,
1220
+ d: nt(170, 120, 92, 62, e.start, e.end),
1217
1221
  style: { fill: e.color },
1218
1222
  ...o,
1219
1223
  children: /* @__PURE__ */ N("title", { children: r(`${e.label}: ${U(e.value)}`, `${e.label}:${U(e.value)}`) })
@@ -1334,17 +1338,17 @@ function rt({ node: e, runtime: t, mode: n }) {
1334
1338
  ae.forEach((a, o) => {
1335
1339
  let s = n.values[a];
1336
1340
  if (s === null) return;
1337
- let c = fe + ye * i + (ye - e) / 2 + o * t, l = Math.max(1, Math.abs(ge(s) - _e)), u = s >= 0 ? _e - l : _e, d = De(a, n, s, c + t / 2, u + l / 2);
1341
+ let c = fe + ye * i + (ye - e) / 2 + o * t, l = Math.max(1, Math.abs(ge(s) - _e)), u = s >= 0 ? _e - l : _e, d = Math.max(1.5, t - 1), f = Math.min(4, d / 2, l / 2), p = De(a, n, s, c + t / 2, u + l / 2);
1338
1342
  Oe.push(/* @__PURE__ */ N("rect", {
1339
- className: `local-visual-bar${d.selected ? " is-selected" : ""}`,
1343
+ className: `local-visual-bar${p.selected ? " is-selected" : ""}`,
1340
1344
  x: c,
1341
1345
  y: u,
1342
- width: Math.max(1.5, t - 1),
1346
+ width: d,
1343
1347
  height: l,
1344
- rx: 2,
1348
+ rx: f,
1345
1349
  style: { fill: H[a % H.length] },
1346
- ...Ee(d),
1347
- children: /* @__PURE__ */ N("title", { children: r(`${d.series}, ${d.label}: ${U(d.value)}`, `${d.series},${d.label}:${U(d.value)}`) })
1350
+ ...Ee(p),
1351
+ children: /* @__PURE__ */ N("title", { children: r(`${p.series}, ${p.label}: ${U(p.value)}`, `${p.series},${p.label}:${U(p.value)}`) })
1348
1352
  }, `bar-${a}-${n.index}`));
1349
1353
  });
1350
1354
  });
@@ -4839,15 +4843,18 @@ function Pr({ node: e }) {
4839
4843
  label: l,
4840
4844
  value: x
4841
4845
  });
4842
- let S = p.max > p.min ? (_ - p.min) / (p.max - p.min) * 100 : 0, C = m.max > m.min ? (v - m.min) / (m.max - m.min) * 100 : 0, w = (e) => {
4846
+ let S = (e) => p.max > p.min ? 40 + (e - p.min) / (p.max - p.min) * 320 : 200, C = (e) => m.max > m.min ? 360 - (e - m.min) / (m.max - m.min) * 320 : 200, w = S(_), T = C(v), E = S(Sn(0, p.min, p.max)), O = C(Sn(0, m.min, m.max)), A = (e) => {
4847
+ let t = e.step * Math.max(1, Math.ceil((e.max - e.min) / (e.step * 10))), n = Math.min(11, Math.floor((e.max - e.min) / t) + 1);
4848
+ return Array.from({ length: n }, (n, r) => e.min + r * t);
4849
+ }, j = (e) => {
4843
4850
  let t = y.current?.getBoundingClientRect();
4844
4851
  if (!t || t.width === 0 || t.height === 0) return null;
4845
- let n = Sn((e.clientX - t.left) / t.width, 0, 1), r = Sn((e.clientY - t.top) / t.height, 0, 1);
4852
+ let n = Sn(((e.clientX - t.left) / t.width - .1) / .8, 0, 1), r = Sn(((e.clientY - t.top) / t.height - .1) / .8, 0, 1);
4846
4853
  return {
4847
4854
  x: Cn(p.min + n * (p.max - p.min), p.min, p.max, p.step),
4848
4855
  y: Cn(m.min + (1 - r) * (m.max - m.min), m.min, m.max, m.step)
4849
4856
  };
4850
- }, T = (e, t) => {
4857
+ }, M = (e, t) => {
4851
4858
  (e !== _ || t !== v) && o({
4852
4859
  x: e,
4853
4860
  y: t
@@ -4866,79 +4873,168 @@ function Pr({ node: e }) {
4866
4873
  children: l
4867
4874
  }),
4868
4875
  /* @__PURE__ */ P("div", {
4869
- ref: y,
4870
- className: "local-coordinate-pad",
4871
- role: "group",
4872
- "aria-label": i(`${l} drag area`, `${l} 拖拽区`),
4873
- "aria-disabled": u || void 0,
4874
- tabIndex: u ? -1 : 0,
4875
- onKeyDown: (e) => {
4876
- if (u) return;
4877
- let t = _, n = v;
4878
- switch (e.key) {
4879
- case "ArrowLeft":
4880
- t = Cn(_ - p.step, p.min, p.max, p.step);
4881
- break;
4882
- case "ArrowRight":
4883
- t = Cn(_ + p.step, p.min, p.max, p.step);
4884
- break;
4885
- case "ArrowDown":
4886
- n = Cn(v - m.step, m.min, m.max, m.step);
4887
- break;
4888
- case "ArrowUp":
4889
- n = Cn(v + m.step, m.min, m.max, m.step);
4890
- break;
4891
- case "Home":
4892
- t = p.min, n = m.min;
4893
- break;
4894
- case "End":
4895
- t = Cn(p.max, p.min, p.max, p.step), n = Cn(m.max, m.min, m.max, m.step);
4896
- break;
4897
- default: return;
4898
- }
4899
- e.preventDefault(), T(t, n);
4900
- },
4901
- onPointerDown: (e) => {
4902
- if (u) return;
4903
- e.preventDefault(), b.current = !0, y.current?.focus({ preventScroll: !0 });
4904
- try {
4905
- e.currentTarget.setPointerCapture(e.pointerId);
4906
- } catch {}
4907
- let t = w(e);
4908
- t && T(t.x, t.y);
4909
- },
4910
- onPointerMove: (e) => {
4911
- if (!b.current || u) return;
4912
- let t = w(e);
4913
- t && T(t.x, t.y);
4914
- },
4915
- onPointerUp: (e) => {
4916
- b.current = !1;
4917
- try {
4918
- e.currentTarget.releasePointerCapture(e.pointerId);
4919
- } catch {}
4920
- },
4921
- onPointerCancel: () => {
4922
- b.current = !1;
4923
- },
4924
- children: [
4925
- /* @__PURE__ */ N("span", {
4926
- className: "local-coordinate-horizontal",
4927
- "aria-hidden": "true"
4928
- }),
4929
- /* @__PURE__ */ N("span", {
4930
- className: "local-coordinate-vertical",
4931
- "aria-hidden": "true"
4932
- }),
4933
- /* @__PURE__ */ N("span", {
4934
- className: "local-coordinate-dot",
4935
- "aria-hidden": "true",
4936
- style: {
4937
- left: `${S}%`,
4938
- top: `${100 - C}%`
4876
+ className: "local-coordinate-surface",
4877
+ children: [/* @__PURE__ */ N("div", {
4878
+ ref: y,
4879
+ className: "local-coordinate-pad",
4880
+ role: "group",
4881
+ "aria-label": i(`${l} drag area`, `${l} 拖拽区`),
4882
+ "aria-disabled": u || void 0,
4883
+ tabIndex: u ? -1 : 0,
4884
+ onKeyDown: (e) => {
4885
+ if (u) return;
4886
+ let t = _, n = v;
4887
+ switch (e.key) {
4888
+ case "ArrowLeft":
4889
+ t = Cn(_ - p.step, p.min, p.max, p.step);
4890
+ break;
4891
+ case "ArrowRight":
4892
+ t = Cn(_ + p.step, p.min, p.max, p.step);
4893
+ break;
4894
+ case "ArrowDown":
4895
+ n = Cn(v - m.step, m.min, m.max, m.step);
4896
+ break;
4897
+ case "ArrowUp":
4898
+ n = Cn(v + m.step, m.min, m.max, m.step);
4899
+ break;
4900
+ case "Home":
4901
+ t = p.min, n = m.min;
4902
+ break;
4903
+ case "End":
4904
+ t = Cn(p.max, p.min, p.max, p.step), n = Cn(m.max, m.min, m.max, m.step);
4905
+ break;
4906
+ default: return;
4939
4907
  }
4908
+ e.preventDefault(), M(t, n);
4909
+ },
4910
+ onPointerDown: (e) => {
4911
+ if (u) return;
4912
+ e.preventDefault(), b.current = !0, y.current?.focus({ preventScroll: !0 });
4913
+ try {
4914
+ e.currentTarget.setPointerCapture(e.pointerId);
4915
+ } catch {}
4916
+ let t = j(e);
4917
+ t && M(t.x, t.y);
4918
+ },
4919
+ onPointerMove: (e) => {
4920
+ if (!b.current || u) return;
4921
+ let t = j(e);
4922
+ t && M(t.x, t.y);
4923
+ },
4924
+ onPointerUp: (e) => {
4925
+ b.current = !1;
4926
+ try {
4927
+ e.currentTarget.releasePointerCapture(e.pointerId);
4928
+ } catch {}
4929
+ },
4930
+ onPointerCancel: () => {
4931
+ b.current = !1;
4932
+ },
4933
+ children: /* @__PURE__ */ P("svg", {
4934
+ className: "local-coordinate-svg",
4935
+ viewBox: "0 0 400 400",
4936
+ "aria-hidden": "true",
4937
+ focusable: "false",
4938
+ children: [
4939
+ /* @__PURE__ */ N("defs", { children: /* @__PURE__ */ N("marker", {
4940
+ id: `${t}-coordinate-arrow`,
4941
+ markerWidth: "8",
4942
+ markerHeight: "8",
4943
+ refX: "6",
4944
+ refY: "4",
4945
+ orient: "auto",
4946
+ viewBox: "0 0 8 8",
4947
+ children: /* @__PURE__ */ N("path", {
4948
+ className: "local-coordinate-arrow",
4949
+ d: "M1 1 L6 4 L1 7"
4950
+ })
4951
+ }) }),
4952
+ /* @__PURE__ */ P("g", {
4953
+ className: "local-coordinate-grid",
4954
+ children: [
4955
+ /* @__PURE__ */ N("rect", {
4956
+ x: "40",
4957
+ y: "40",
4958
+ width: "320",
4959
+ height: "320"
4960
+ }),
4961
+ A(p).map((e, t) => /* @__PURE__ */ N("line", {
4962
+ x1: S(e),
4963
+ y1: "40",
4964
+ x2: S(e),
4965
+ y2: "360"
4966
+ }, `x-${t}`)),
4967
+ A(m).map((e, t) => /* @__PURE__ */ N("line", {
4968
+ x1: "40",
4969
+ y1: C(e),
4970
+ x2: "360",
4971
+ y2: C(e)
4972
+ }, `y-${t}`))
4973
+ ]
4974
+ }),
4975
+ /* @__PURE__ */ P("g", {
4976
+ className: "local-coordinate-axes",
4977
+ children: [/* @__PURE__ */ N("line", {
4978
+ className: "local-coordinate-horizontal",
4979
+ x1: "26",
4980
+ y1: O,
4981
+ x2: "372",
4982
+ y2: O,
4983
+ markerEnd: `url(#${t}-coordinate-arrow)`
4984
+ }), /* @__PURE__ */ N("line", {
4985
+ className: "local-coordinate-vertical",
4986
+ x1: E,
4987
+ y1: "374",
4988
+ x2: E,
4989
+ y2: "24",
4990
+ markerEnd: `url(#${t}-coordinate-arrow)`
4991
+ })]
4992
+ }),
4993
+ /* @__PURE__ */ P("g", {
4994
+ className: "local-coordinate-axis-label",
4995
+ children: [/* @__PURE__ */ N("text", {
4996
+ x: "358",
4997
+ y: O - 14,
4998
+ children: "x"
4999
+ }), /* @__PURE__ */ N("text", {
5000
+ x: E + 12,
5001
+ y: "40",
5002
+ children: "y"
5003
+ })]
5004
+ }),
5005
+ /* @__PURE__ */ P("g", {
5006
+ className: "local-coordinate-projection",
5007
+ children: [/* @__PURE__ */ N("line", {
5008
+ x1: w,
5009
+ y1: T,
5010
+ x2: w,
5011
+ y2: O
5012
+ }), /* @__PURE__ */ N("line", {
5013
+ x1: w,
5014
+ y1: T,
5015
+ x2: E,
5016
+ y2: T
5017
+ })]
5018
+ }),
5019
+ /* @__PURE__ */ N("circle", {
5020
+ className: "local-coordinate-dot",
5021
+ cx: w,
5022
+ cy: T,
5023
+ r: "10"
5024
+ }),
5025
+ /* @__PURE__ */ N("text", {
5026
+ className: "local-coordinate-value",
5027
+ x: w,
5028
+ y: T > 330 ? T - 22 : T + 30,
5029
+ textAnchor: w < 80 ? "start" : w > 320 ? "end" : "middle",
5030
+ children: `(${_}, ${v})`
5031
+ })
5032
+ ]
4940
5033
  })
4941
- ]
5034
+ }), /* @__PURE__ */ N("span", {
5035
+ className: "local-coordinate-caption",
5036
+ children: i("Draggable coordinate plane", "可拖动的坐标平面")
5037
+ })]
4942
5038
  }),
4943
5039
  /* @__PURE__ */ N("span", {
4944
5040
  className: "md-hint local-hint",