@pie-lib/math-input-mathlive 2.0.4-next.20261202133946 → 2.0.4-next.20261202142832

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.
@@ -1,10 +1,10 @@
1
1
  // \0rolldown/runtime.js
2
2
  var e = Object.defineProperty, t = (t, n) => {
3
- let r = {};
3
+ let r = Object.setPrototypeOf({}, null);
4
4
  for (var i in t) e(r, i, {
5
5
  get: t[i],
6
6
  enumerable: !0
7
7
  });
8
- return n || e(r, Symbol.toStringTag, { value: "Module" }), r;
8
+ return n & 1 || e(r, Symbol.toStringTag, { value: "Module" }), n & 2 ? r : Object.preventExtensions(r);
9
9
  };
10
10
  export { t as __exportAll };
@@ -1,8 +1,8 @@
1
- import { keysForGrade as e, normalizeAdditionalKeys as t } from "./keys/grades.js";
2
- import { extendKeySet as n } from "./keys/utils.js";
3
- import { KeyPad as r } from "./keypad/index.js";
4
- import i from "react";
5
- import a from "prop-types";
1
+ import e from "react";
2
+ import t from "prop-types";
3
+ import { keysForGrade as n, normalizeAdditionalKeys as r } from "./keys/grades.js";
4
+ import { extendKeySet as i } from "./keys/utils.js";
5
+ import { KeyPad as a } from "./keypad/index.js";
6
6
  import { jsx as o } from "react/jsx-runtime";
7
7
  // src/horizontal-keypad.tsx
8
8
  var s = (e) => {
@@ -15,17 +15,17 @@ var s = (e) => {
15
15
  type: "cursor",
16
16
  value: e.keystroke
17
17
  };
18
- }, c = class extends i.Component {
18
+ }, c = class extends e.Component {
19
19
  static propTypes = {
20
- className: a.string,
21
- controlledKeypadMode: a.bool,
22
- mode: a.oneOfType([a.string, a.number]),
23
- layoutForKeyPad: a.object,
24
- onClick: a.func.isRequired,
25
- onFocus: a.func,
26
- noDecimal: a.bool,
27
- additionalKeys: a.array,
28
- setKeypadInteraction: a.func
20
+ className: t.string,
21
+ controlledKeypadMode: t.bool,
22
+ mode: t.oneOfType([t.string, t.number]),
23
+ layoutForKeyPad: t.object,
24
+ onClick: t.func.isRequired,
25
+ onFocus: t.func,
26
+ noDecimal: t.bool,
27
+ additionalKeys: t.array,
28
+ setKeypadInteraction: t.func
29
29
  };
30
30
  static defaultProps = {
31
31
  mode: "scientific",
@@ -36,16 +36,16 @@ var s = (e) => {
36
36
  this.props.onClick(s(e));
37
37
  };
38
38
  render() {
39
- let { mode: i, onFocus: a, controlledKeypadMode: s, noDecimal: c, className: l, additionalKeys: u, layoutForKeyPad: d, setKeypadInteraction: f } = this.props, p = t(u);
40
- return /* @__PURE__ */ o(r, {
39
+ let { mode: e, onFocus: t, controlledKeypadMode: s, noDecimal: c, className: l, additionalKeys: u, layoutForKeyPad: d, setKeypadInteraction: f } = this.props, p = r(u);
40
+ return /* @__PURE__ */ o(a, {
41
41
  className: l,
42
42
  controlledKeypadMode: s,
43
- onFocus: a,
43
+ onFocus: t,
44
44
  noDecimal: c,
45
45
  layoutForKeyPad: d,
46
- additionalKeys: n(e(i), p),
46
+ additionalKeys: i(n(e), p),
47
47
  onPress: this.keypadPress,
48
- mode: i,
48
+ mode: e,
49
49
  setKeypadInteraction: f
50
50
  });
51
51
  }
@@ -1,9 +1,9 @@
1
- import e from "./en-US.js";
2
- import { defineCatalogs as t } from "@pie-element/shared-i18n";
1
+ import { defineCatalogs as e } from "@pie-element/shared-i18n";
2
+ import t from "./en-US.js";
3
3
  // src/i18n/index.ts
4
- var n = t({
4
+ var n = e({
5
5
  packageName: "@pie-lib/math-input-mathlive",
6
- source: e,
6
+ source: t,
7
7
  loaders: {
8
8
  es: () => import(
9
9
  /* webpackMode: "eager" */
@@ -1,24 +1,24 @@
1
- import { baseSet as e } from "../keys/index.js";
2
- import { sortKeys as t } from "./keys-layout.js";
3
- import { commonKeyboardStyles as n, rootIndexStyles as r } from "../mf/common-styles.js";
4
- import { latexToMarkup as i, loadMathLive as a } from "../mathlive-instance.js";
5
- import { fixLongDivisionWhenReady as o } from "../longdiv.js";
6
- import { KEYPAD_ATTRIBUTE as s } from "../mf/inactive-caret.js";
7
- import { flatten as c } from "@pie-element/shared-lodash";
8
- import l from "react";
9
- import u from "prop-types";
10
- import { styled as d } from "@mui/material/styles";
11
- import f from "debug";
12
- import { jsx as p } from "react/jsx-runtime";
13
- import m from "@mui/material/Button";
14
- import h from "@mui/material/IconButton";
15
- import { color as g } from "@pie-lib/render-ui";
1
+ import e from "react";
2
+ import t from "prop-types";
3
+ import n from "@mui/material/Button";
4
+ import r from "@mui/material/IconButton";
5
+ import { styled as i } from "@mui/material/styles";
6
+ import a from "debug";
7
+ import { flatten as o } from "@pie-element/shared-lodash";
8
+ import { color as s } from "@pie-lib/render-ui";
9
+ import { baseSet as c } from "../keys/index.js";
10
+ import { sortKeys as l } from "./keys-layout.js";
11
+ import { commonKeyboardStyles as u, rootIndexStyles as d } from "../mf/common-styles.js";
12
+ import { latexToMarkup as f, loadMathLive as p } from "../mathlive-instance.js";
13
+ import { fixLongDivisionWhenReady as m } from "../longdiv.js";
14
+ import { KEYPAD_ATTRIBUTE as h } from "../mf/inactive-caret.js";
15
+ import { jsx as g } from "react/jsx-runtime";
16
16
  // src/keypad/index.tsx
17
- var _ = f("pie-lib:math-input-mathlive:keypad"), v = () => [g.text(), g.keypadInk()], y = () => ({ "& .MuiTouchRipple-root": { color: `rgb(from ${g.text()} min(r, 255 - r) min(g, 255 - g) min(b, 255 - b))` } }), b = () => ({ "&.Mui-focusVisible": {
18
- outline: `2px solid ${g.focusOutline()}`,
17
+ var _ = a("pie-lib:math-input-mathlive:keypad"), v = () => [s.text(), s.keypadInk()], y = () => ({ "& .MuiTouchRipple-root": { color: `rgb(from ${s.text()} min(r, 255 - r) min(g, 255 - g) min(b, 255 - b))` } }), b = () => ({ "&.Mui-focusVisible": {
18
+ outline: `2px solid ${s.focusOutline()}`,
19
19
  outlineOffset: "-2px",
20
- boxShadow: `inset 0 0 0 4px ${g.v("pie")("background", g.defaults.WHITE)}`
21
- } }), x = ["\\parallel"], S = "skewX(-15deg)", C = "0.03em currentColor", w = 1.25, T = d("span", { shouldForwardProp: (e) => e !== "slanted" })(({ slanted: e }) => ({
20
+ boxShadow: `inset 0 0 0 4px ${s.v("pie")("background", s.defaults.WHITE)}`
21
+ } }), x = ["\\parallel"], S = "skewX(-15deg)", C = "0.03em currentColor", w = 1.25, T = i("span", { shouldForwardProp: (e) => e !== "slanted" })(({ slanted: e }) => ({
22
22
  ...e && {
23
23
  transform: `${S} scaleY(${w})`,
24
24
  "& *": { WebkitTextStroke: C }
@@ -31,7 +31,7 @@ var _ = f("pie-lib:math-input-mathlive:keypad"), v = () => [g.text(), g.keypadIn
31
31
  lineHeight: 1,
32
32
  maxWidth: "100%",
33
33
  overflow: "hidden",
34
- "& .ML__placeholder": { backgroundColor: g.keypadEmptyPlaceholder ? g.keypadEmptyPlaceholder() : void 0 },
34
+ "& .ML__placeholder": { backgroundColor: s.keypadEmptyPlaceholder ? s.keypadEmptyPlaceholder() : void 0 },
35
35
  "& [data-pie-empty]": { opacity: .5 },
36
36
  "&:has(.ML__mfrac)": { paddingTop: "0.25em" },
37
37
  "& .ML__mfrac:has([data-pie-empty]) .ML__frac-line": {
@@ -40,38 +40,38 @@ var _ = f("pie-lib:math-input-mathlive:keypad"), v = () => [g.text(), g.keypadIn
40
40
  },
41
41
  "& .ML__mfrac:has([data-pie-empty]):not(:has(.ML__center ~ .ML__center [data-pie-empty])) .ML__frac-line": { top: "0.13em" },
42
42
  "& .ML__mfrac:has([data-pie-empty]):not(:only-child) .ML__frac-line": { top: "0.1em" },
43
- ...r
44
- })), E = class e extends l.Component {
43
+ ...d
44
+ })), E = class n extends e.Component {
45
45
  static propTypes = {
46
- latex: u.string.isRequired,
47
- decorative: u.bool
46
+ latex: t.string.isRequired,
47
+ decorative: t.bool
48
48
  };
49
- constructor(e) {
50
- super(e), this.state = { markup: i(e.latex) }, this.labelRef = l.createRef();
49
+ constructor(t) {
50
+ super(t), this.state = { markup: f(t.latex) }, this.labelRef = e.createRef();
51
51
  }
52
52
  async componentDidMount() {
53
53
  if (this.state.markup) {
54
- o(this.labelRef.current);
54
+ m(this.labelRef.current);
55
55
  return;
56
56
  }
57
- if (await a(), this.unmounted) return;
58
- let t = i(this.props.latex);
59
- t ? this.setState({ markup: t }) : e.warned || (e.warned = !0, _("MathLive unavailable - keypad labels are falling back to raw latex"));
57
+ if (await p(), this.unmounted) return;
58
+ let e = f(this.props.latex);
59
+ e ? this.setState({ markup: e }) : n.warned || (n.warned = !0, _("MathLive unavailable - keypad labels are falling back to raw latex"));
60
60
  }
61
61
  componentDidUpdate(e, t) {
62
- e.latex !== this.props.latex && this.setState({ markup: i(this.props.latex) }), this.state.markup !== (t && t.markup) && o(this.labelRef.current);
62
+ e.latex !== this.props.latex && this.setState({ markup: f(this.props.latex) }), this.state.markup !== (t && t.markup) && m(this.labelRef.current);
63
63
  }
64
64
  componentWillUnmount() {
65
65
  this.unmounted = !0;
66
66
  }
67
67
  render() {
68
68
  let { markup: e } = this.state, t = this.props.decorative ? "true" : void 0;
69
- return e ? /* @__PURE__ */ p(T, {
69
+ return e ? /* @__PURE__ */ g(T, {
70
70
  ref: this.labelRef,
71
71
  "aria-hidden": t,
72
72
  slanted: x.includes(this.props.latex),
73
73
  dangerouslySetInnerHTML: { __html: e }
74
- }) : /* @__PURE__ */ p(T, {
74
+ }) : /* @__PURE__ */ g(T, {
75
75
  "aria-hidden": t,
76
76
  slanted: x.includes(this.props.latex),
77
77
  children: this.props.latex
@@ -81,8 +81,8 @@ var _ = f("pie-lib:math-input-mathlive:keypad"), v = () => [g.text(), g.keypadIn
81
81
  gridTemplateColumns: `repeat(${e.columns}, minmax(min-content, 150px))`,
82
82
  gridTemplateRows: `repeat(${e.rows}, minmax(40px, 60px))`,
83
83
  gridAutoFlow: "initial"
84
- } : {}, O = d("div")(() => ({
85
- ...n,
84
+ } : {}, O = i("div")(() => ({
85
+ ...u,
86
86
  width: "100%",
87
87
  display: "grid",
88
88
  gridTemplateRows: "repeat(5, minmax(40px, 60px))",
@@ -98,9 +98,9 @@ var _ = f("pie-lib:math-input-mathlive:keypad"), v = () => [g.text(), g.keypadIn
98
98
  "& *": { fontFamily: "Roboto, Helvetica, Arial, sans-serif !important" }
99
99
  }
100
100
  })), k = (e) => ({
101
- backgroundColor: e === "operators" ? g.keypadButtonOperator() : g.keypadButton(),
102
- "&:hover": { backgroundColor: e === "operators" ? g.keypadButtonOperatorHover() : g.keypadButtonHover() }
103
- }), A = d(m)(({ category: e, isDelete: t, isComma: n, isDot: r }) => ({
101
+ backgroundColor: e === "operators" ? s.keypadButtonOperator() : s.keypadButton(),
102
+ "&:hover": { backgroundColor: e === "operators" ? s.keypadButtonOperatorHover() : s.keypadButtonHover() }
103
+ }), A = i(n)(({ category: e, isDelete: t, isComma: n, isDot: r }) => ({
104
104
  minWidth: "auto",
105
105
  textTransform: "none",
106
106
  fontSize: n || r ? "200% !important" : "140% !important",
@@ -111,7 +111,7 @@ var _ = f("pie-lib:math-input-mathlive:keypad"), v = () => [g.text(), g.keypadIn
111
111
  ...t && { fontFamily: "Roboto, Helvetica, Arial, sans-serif !important" },
112
112
  ...y(),
113
113
  ...b()
114
- })), j = d(m)(({ category: e }) => ({
114
+ })), j = i(n)(({ category: e }) => ({
115
115
  textTransform: "none",
116
116
  padding: 0,
117
117
  margin: 0,
@@ -121,33 +121,33 @@ var _ = f("pie-lib:math-input-mathlive:keypad"), v = () => [g.text(), g.keypadIn
121
121
  ...k(e),
122
122
  ...y(),
123
123
  ...b()
124
- })), M = d(h)(({ category: e }) => ({
124
+ })), M = i(r)(({ category: e }) => ({
125
125
  minWidth: "auto",
126
126
  ...k(e),
127
127
  borderRadius: 0,
128
128
  "& .icon": { height: "30px" }
129
- })), N = class extends l.Component {
129
+ })), N = class extends e.Component {
130
130
  static propTypes = {
131
- className: u.string,
132
- controlledKeypadMode: u.bool,
133
- baseSet: u.array,
134
- additionalKeys: u.array,
135
- layoutForKeyPad: u.object,
136
- onPress: u.func.isRequired,
137
- onFocus: u.func,
138
- noDecimal: u.bool,
139
- setKeypadInteraction: u.func,
140
- mode: u.oneOfType([u.string, u.number])
131
+ className: t.string,
132
+ controlledKeypadMode: t.bool,
133
+ baseSet: t.array,
134
+ additionalKeys: t.array,
135
+ layoutForKeyPad: t.object,
136
+ onPress: t.func.isRequired,
137
+ onFocus: t.func,
138
+ noDecimal: t.bool,
139
+ setKeypadInteraction: t.func,
140
+ mode: t.oneOfType([t.string, t.number])
141
141
  };
142
142
  static defaultProps = {
143
- baseSet: e,
143
+ baseSet: c,
144
144
  noDecimal: !1
145
145
  };
146
- constructor(e) {
147
- super(e), this.keypadRef = l.createRef();
146
+ constructor(t) {
147
+ super(t), this.keypadRef = e.createRef();
148
148
  }
149
149
  componentDidMount() {
150
- a();
150
+ p();
151
151
  let e = this.keypadRef?.current, t = e?.closest(".main-container"), n = e?.closest(".pie-toolbar");
152
152
  if (this.props.controlledKeypadMode && t && n) {
153
153
  let e = t.getBoundingClientRect(), r = n.getBoundingClientRect(), i = e.top + e.height - (r.top + r.height);
@@ -172,7 +172,7 @@ var _ = f("pie-lib:math-input-mathlive:keypad"), v = () => [g.text(), g.keypadIn
172
172
  buttonClick = (e) => {
173
173
  _("[buttonClick]", e), this.props.onPress(e);
174
174
  };
175
- flowKeys = (e, n) => c([...t(e), ...t(n)]);
175
+ flowKeys = (e, t) => o([...l(e), ...l(t)]);
176
176
  keyIsNotAllowed = (e) => {
177
177
  let { noDecimal: t } = this.props;
178
178
  return !!((e.write === "." && e.label === "." || e.write === "," && e.label === ",") && t);
@@ -185,19 +185,19 @@ var _ = f("pie-lib:math-input-mathlive:keypad"), v = () => [g.text(), g.keypadIn
185
185
  "fractions",
186
186
  "item-authoring",
187
187
  "language"
188
- ].includes(a), c = o ? this.flowKeys([], n || []) : this.flowKeys(t, n || []), l = c.length % 5 ? 1 : 0, u = {
189
- gridTemplateColumns: `repeat(${Math.floor(c.length / 5) + l}, minmax(min-content, 150px))`,
188
+ ].includes(a), s = o ? this.flowKeys([], n || []) : this.flowKeys(t, n || []), c = s.length % 5 ? 1 : 0, l = {
189
+ gridTemplateColumns: `repeat(${Math.floor(s.length / 5) + c}, minmax(min-content, 150px))`,
190
190
  ...D(r)
191
191
  };
192
- return /* @__PURE__ */ p(O, {
192
+ return /* @__PURE__ */ g(O, {
193
193
  ref: this.keypadRef,
194
- [s]: "",
194
+ [h]: "",
195
195
  className: [e, a].filter(Boolean).join(" "),
196
- style: u,
196
+ style: l,
197
197
  onFocus: i,
198
- children: c.map((e, t) => {
199
- if (!e) return /* @__PURE__ */ p("span", {}, `empty-${t}`);
200
- if (!(e.label || e.latex || e.icon || e.command || e.keystroke || e.write || e.type || e.actions || e.extraProps)) return /* @__PURE__ */ p(A, {
198
+ children: s.map((e, t) => {
199
+ if (!e) return /* @__PURE__ */ g("span", {}, `empty-${t}`);
200
+ if (!(e.label || e.latex || e.icon || e.command || e.keystroke || e.write || e.type || e.actions || e.extraProps)) return /* @__PURE__ */ g(A, {
201
201
  disabled: !0,
202
202
  "aria-hidden": "true",
203
203
  tabIndex: -1,
@@ -207,18 +207,18 @@ var _ = f("pie-lib:math-input-mathlive:keypad"), v = () => [g.text(), g.keypadIn
207
207
  ...e.actions || {},
208
208
  ...e.extraProps || {}
209
209
  }, a = this.buttonClick.bind(this, e), s = this.keyIsNotAllowed(e), c = e.ariaLabel ? e.ariaLabel : e.name || e.label;
210
- if (e.latex) return /* @__PURE__ */ p(j, {
210
+ if (e.latex) return /* @__PURE__ */ g(j, {
211
211
  onClick: a,
212
212
  disabled: s,
213
213
  category: r,
214
214
  "aria-label": c,
215
215
  ...i,
216
- children: /* @__PURE__ */ p(E, {
216
+ children: /* @__PURE__ */ g(E, {
217
217
  latex: e.latex,
218
218
  decorative: !!c
219
219
  })
220
220
  }, n);
221
- if (e.label) return /* @__PURE__ */ p(A, {
221
+ if (e.label) return /* @__PURE__ */ g(A, {
222
222
  onClick: a,
223
223
  disabled: s,
224
224
  category: r,
@@ -230,14 +230,14 @@ var _ = f("pie-lib:math-input-mathlive:keypad"), v = () => [g.text(), g.keypadIn
230
230
  children: e.label
231
231
  }, n);
232
232
  let l = e.icon ? e.icon : "div";
233
- return /* @__PURE__ */ p(M, {
233
+ return /* @__PURE__ */ g(M, {
234
234
  tabIndex: "-1",
235
235
  onClick: a,
236
236
  disabled: s,
237
237
  category: r,
238
238
  size: "large",
239
239
  ...i,
240
- children: /* @__PURE__ */ p(l, { className: "icon" })
240
+ children: /* @__PURE__ */ g(l, { className: "icon" })
241
241
  }, n);
242
242
  })
243
243
  });
package/dist/longdiv.js CHANGED
@@ -4,7 +4,7 @@ var t = e("pie-lib:math-input-mathlive:longdiv"), n = (e, t) => {
4
4
  let n = RegExp(`(?:^|;)\\s*${t}:\\s*(-?[\\d.]+)em`).exec(e || "");
5
5
  return n ? parseFloat(n[1]) : 0;
6
6
  }, r = (e, t) => e && Array.from(e.children || []).find((e) => e.tagName.toLowerCase() === t), i = (e) => {
7
- let t = -Infinity;
7
+ let t = -1e400;
8
8
  return e.querySelectorAll("*").forEach((e) => {
9
9
  if (e.children.length || e.classList && e.classList.contains("ML__caret")) return;
10
10
  let n = e.getBoundingClientRect();
@@ -1,23 +1,23 @@
1
- import { baseSet as e } from "./keys/index.js";
2
- import { KeyPad as t } from "./keypad/index.js";
3
- import { Input as n } from "./mf/input.js";
4
- import { keyToAction as r } from "./latex-bridge.js";
5
- import i from "react";
6
- import a from "prop-types";
7
- import { styled as o } from "@mui/material/styles";
8
- import s from "debug";
1
+ import e from "react";
2
+ import t from "prop-types";
3
+ import { styled as n } from "@mui/material/styles";
4
+ import r from "debug";
5
+ import { baseSet as i } from "./keys/index.js";
6
+ import { KeyPad as a } from "./keypad/index.js";
7
+ import { Input as o } from "./mf/input.js";
8
+ import { keyToAction as s } from "./latex-bridge.js";
9
9
  import { jsx as c, jsxs as l } from "react/jsx-runtime";
10
10
  // src/math-input.tsx
11
- var u = s("pie-lib:math-input-mathlive"), d = "rgba(0, 0, 0, 0.23)", f = o("div")(({ theme: e, focused: t }) => ({
11
+ var u = r("pie-lib:math-input-mathlive"), d = "rgba(0, 0, 0, 0.23)", f = n("div")(({ theme: e, focused: t }) => ({
12
12
  borderRadius: "4px",
13
13
  border: `solid 1px ${t ? e.palette.primary.main : d}`,
14
14
  marginTop: e.spacing(1),
15
15
  marginBottom: e.spacing(1),
16
16
  transition: "border 200ms linear"
17
- })), p = o("div")({
17
+ })), p = n("div")({
18
18
  width: "100%",
19
19
  display: "flex"
20
- }), m = o(n)(({ theme: e }) => ({
20
+ }), m = n(o)(({ theme: e }) => ({
21
21
  width: "100%",
22
22
  transition: "border 200ms linear",
23
23
  padding: e.spacing(1),
@@ -25,13 +25,13 @@ var u = s("pie-lib:math-input-mathlive"), d = "rgba(0, 0, 0, 0.23)", f = o("div"
25
25
  outline: "none",
26
26
  boxShadow: "none"
27
27
  }
28
- })), h = class extends i.Component {
28
+ })), h = class extends e.Component {
29
29
  static propTypes = {
30
- className: a.string,
31
- keyset: a.array,
32
- displayMode: a.oneOf(["block", "block-on-focus"]),
33
- latex: a.string,
34
- onChange: a.func
30
+ className: t.string,
31
+ keyset: t.array,
32
+ displayMode: t.oneOf(["block", "block-on-focus"]),
33
+ latex: t.string,
34
+ onChange: t.func
35
35
  };
36
36
  static defaultProps = {
37
37
  keyset: [],
@@ -42,7 +42,7 @@ var u = s("pie-lib:math-input-mathlive"), d = "rgba(0, 0, 0, 0.23)", f = o("div"
42
42
  }
43
43
  keypadPress = (e) => {
44
44
  if (u("[keypadPress] key:", e), !this.input) return;
45
- let t = r(e);
45
+ let t = s(e);
46
46
  t && (t.type === "command" ? this.input.keystroke(t.value) : this.input.write(t.value));
47
47
  };
48
48
  inputFocus = () => this.setState({ focused: !0 });
@@ -52,19 +52,19 @@ var u = s("pie-lib:math-input-mathlive"), d = "rgba(0, 0, 0, 0.23)", f = o("div"
52
52
  t && e !== this.props.latex && (u("[changeLatex]", e, this.props.latex), t(e));
53
53
  };
54
54
  render() {
55
- let { className: n, keyset: r, latex: i } = this.props, { focused: a } = this.state;
55
+ let { className: e, keyset: t, latex: n } = this.props, { focused: r } = this.state;
56
56
  return /* @__PURE__ */ l(f, {
57
- className: n,
58
- focused: a,
57
+ className: e,
58
+ focused: r,
59
59
  children: [/* @__PURE__ */ c(m, {
60
60
  innerRef: (e) => this.input = e,
61
61
  onFocus: this.inputFocus,
62
62
  onBlur: this.inputBlur,
63
- latex: i,
63
+ latex: n,
64
64
  onChange: this.changeLatex
65
- }), /* @__PURE__ */ c(p, { children: /* @__PURE__ */ c(t, {
66
- baseSet: e,
67
- additionalKeys: r,
65
+ }), /* @__PURE__ */ c(p, { children: /* @__PURE__ */ c(a, {
66
+ baseSet: i,
67
+ additionalKeys: t,
68
68
  onPress: this.keypadPress
69
69
  }) })]
70
70
  });
@@ -1,10 +1,10 @@
1
- import { toAccessibleLatex as e, toMathLive as t, withVisibleEmptySlots as n } from "./latex-bridge.js";
2
- import { PARALLEL_CSS as r, ROOT_INDEX_CSS as i } from "./mf/common-styles.js";
3
- import { fixLongDivisionWhenReady as a } from "./longdiv.js";
4
- import { KEYPAD_CARET_CSS as o } from "./mf/inactive-caret.js";
5
- import s from "debug";
1
+ import e from "debug";
2
+ import { toAccessibleLatex as t, toMathLive as n, withVisibleEmptySlots as r } from "./latex-bridge.js";
3
+ import { PARALLEL_CSS as i, ROOT_INDEX_CSS as a } from "./mf/common-styles.js";
4
+ import { fixLongDivisionWhenReady as o } from "./longdiv.js";
5
+ import { KEYPAD_CARET_CSS as s } from "./mf/inactive-caret.js";
6
6
  // src/mathlive-instance.ts
7
- var c = s("pie-lib:math-input-mathlive:instance"), l, u, d = (e) => {
7
+ var c = e("pie-lib:math-input-mathlive:instance"), l, u, d = (e) => {
8
8
  if (!e || /^(?:[a-z+]+:)?\/\//i.test(e)) return e;
9
9
  try {
10
10
  return new URL(e, document.baseURI).href;
@@ -44,7 +44,7 @@ var c = s("pie-lib:math-input-mathlive:instance"), l, u, d = (e) => {
44
44
  "content:\"\";position:absolute;left:50%;top:12%;height:76%;",
45
45
  "border-right:2px solid var(--_caret-color, currentColor);",
46
46
  "animation:ML__caret-blink 1.05s step-end forwards infinite}"
47
- ].join(""), C = "url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 522' preserveAspectRatio='none'%3E%3Crect y='241' width='100' height='40'/%3E%3C/svg%3E\") 0 0/100% 100% no-repeat", w = `.ML__latex .overline>.ML__vlist-t>.ML__vlist-r>.ML__vlist>span:has(>.overline-line){top:-4.07em !important}.ML__latex .overline:has(>.ML__vlist-t>.ML__vlist-r>.ML__vlist>span>span[style*="height:0.9em"])>.ML__vlist-t>.ML__vlist-r>.ML__vlist>span:has(>.overline-line){top:-4.1em !important}.ML__latex .overline{position:relative;top:-0.06em}.ML__latex .overline>.ML__vlist-t>.ML__vlist-r>.ML__vlist>span:has(>span[style*="height:0.9em"]){top:-2.97em !important}.ML__latex .overline .overline-line{position:relative}.ML__latex .overline .overline-line:before{content:"";display:block;position:absolute;left:0;right:0;top:-0.241em;height:0.522em !important;border:0 !important;background:currentColor;-webkit-mask:${C};mask:${C}}.ML__latex .overline .overline-line:after{display:none !important}.ML__latex:has(.overline)>.ML__strut{height:1.37em !important}`, T = ".ML__latex .ML__center:has(.ML__stretchy){margin-left:0 !important}" + i + r + w + ".ML__latex .ML__mfrac:has(.ML__vlist>.ML__center:first-child span[style*=\"height:0.9em\"]) .ML__frac-line{position:relative;top:-0.025em}.ML__latex .ML__mfrac:not(:has(span[style*=\"height:0.9em\"])) .ML__frac-line{position:relative;top:0.04em}" + S + o, E = (e) => {
47
+ ].join(""), C = "url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 522' preserveAspectRatio='none'%3E%3Crect y='241' width='100' height='40'/%3E%3C/svg%3E\") 0 0/100% 100% no-repeat", w = `.ML__latex .overline>.ML__vlist-t>.ML__vlist-r>.ML__vlist>span:has(>.overline-line){top:-4.07em !important}.ML__latex .overline:has(>.ML__vlist-t>.ML__vlist-r>.ML__vlist>span>span[style*="height:0.9em"])>.ML__vlist-t>.ML__vlist-r>.ML__vlist>span:has(>.overline-line){top:-4.1em !important}.ML__latex .overline{position:relative;top:-0.06em}.ML__latex .overline>.ML__vlist-t>.ML__vlist-r>.ML__vlist>span:has(>span[style*="height:0.9em"]){top:-2.97em !important}.ML__latex .overline .overline-line{position:relative}.ML__latex .overline .overline-line:before{content:"";display:block;position:absolute;left:0;right:0;top:-0.241em;height:0.522em !important;border:0 !important;background:currentColor;-webkit-mask:${C};mask:${C}}.ML__latex .overline .overline-line:after{display:none !important}.ML__latex:has(.overline)>.ML__strut{height:1.37em !important}`, T = ".ML__latex .ML__center:has(.ML__stretchy){margin-left:0 !important}" + a + i + w + ".ML__latex .ML__mfrac:has(.ML__vlist>.ML__center:first-child span[style*=\"height:0.9em\"]) .ML__frac-line{position:relative;top:-0.025em}.ML__latex .ML__mfrac:not(:has(span[style*=\"height:0.9em\"])) .ML__frac-line{position:relative;top:0.04em}" + S + s, E = (e) => {
48
48
  if (!e || typeof e.addEventListener != "function") return;
49
49
  let t = () => {
50
50
  let t = "";
@@ -116,40 +116,40 @@ function P(e, t) {
116
116
  latex: r
117
117
  });
118
118
  }
119
- function F(e, r, i = {}) {
119
+ function F(e, t, i = {}) {
120
120
  if (!e || typeof window > "u") return;
121
- let o = r ?? e.textContent, s = M() || A();
121
+ let a = t ?? e.textContent, s = M() || A();
122
122
  if (!s) c("applyStaticMath called before MathLive loaded - deferring until it is ready"), j().then((t) => {
123
- t && e.isConnected !== !1 && F(e, o, i);
123
+ t && e.isConnected !== !1 && F(e, a, i);
124
124
  });
125
- else return e.innerHTML = s.convertLatexToMarkup(n(t(o)), { macros: {
125
+ else return e.innerHTML = s.convertLatexToMarkup(r(n(a)), { macros: {
126
126
  ...N(),
127
127
  ...i.macros || {}
128
- } }), a(e), e;
128
+ } }), o(e), e;
129
129
  }
130
- function I(e, r = {}) {
130
+ function I(e, t = {}) {
131
131
  let i = M() || A();
132
132
  if (!i || !e) return "";
133
133
  try {
134
- return i.convertLatexToMarkup(n(t(e)), {
135
- ...r,
134
+ return i.convertLatexToMarkup(r(n(e)), {
135
+ ...t,
136
136
  macros: {
137
137
  ...N(),
138
- ...r.macros || {}
138
+ ...t.macros || {}
139
139
  }
140
140
  });
141
141
  } catch (t) {
142
142
  return c("convertLatexToMarkup failed for \"%s\": %s", e, t.message), "";
143
143
  }
144
144
  }
145
- function L(n) {
145
+ function L(e) {
146
146
  let r = M();
147
- if (!r?.convertLatexToMathMl || !n) return "";
147
+ if (!r?.convertLatexToMathMl || !e) return "";
148
148
  try {
149
- let i = r.convertLatexToMathMl(e(t(n)));
149
+ let i = r.convertLatexToMathMl(t(n(e)));
150
150
  return i ? `<math xmlns="http://www.w3.org/1998/Math/MathML">${i}</math>` : "";
151
- } catch (e) {
152
- return c("convertLatexToMathMl failed for \"%s\": %s", n, e.message), "";
151
+ } catch (t) {
152
+ return c("convertLatexToMathMl failed for \"%s\": %s", e, t.message), "";
153
153
  }
154
154
  }
155
155
  function R(e) {
package/dist/mf/input.js CHANGED
@@ -1,16 +1,16 @@
1
- import { applyShadowStyles as e, createMathField as t, loadMathLive as n, trackPlaceholderCaret as r } from "../mathlive-instance.js";
2
- import { describeMathField as i, labelMathField as a } from "./field-label.js";
3
- import { KEYSTROKES as o, fromMathLive as s, keyToAction as c, toMathLive as l } from "../latex-bridge.js";
4
- import { trackWholeAtomSelection as u } from "../selection.js";
5
- import { trackLongDivision as d } from "../longdiv.js";
6
- import { keepCaretWhileKeypadFocused as f } from "./inactive-caret.js";
7
- import p from "react";
8
- import m from "prop-types";
9
- import { styled as h } from "@mui/material/styles";
10
- import g from "debug";
1
+ import e from "react";
2
+ import t from "prop-types";
3
+ import { styled as n } from "@mui/material/styles";
4
+ import r from "debug";
5
+ import { applyShadowStyles as i, createMathField as a, loadMathLive as o, trackPlaceholderCaret as s } from "../mathlive-instance.js";
6
+ import { describeMathField as c, labelMathField as l } from "./field-label.js";
7
+ import { KEYSTROKES as u, fromMathLive as d, keyToAction as f, toMathLive as p } from "../latex-bridge.js";
8
+ import { trackWholeAtomSelection as m } from "../selection.js";
9
+ import { trackLongDivision as h } from "../longdiv.js";
10
+ import { keepCaretWhileKeypadFocused as g } from "./inactive-caret.js";
11
11
  import { jsx as _ } from "react/jsx-runtime";
12
12
  // src/mf/input.tsx
13
- var v = /* @__PURE__ */ new Set(["[Tab]", "shift+[Tab]"]), y = (e = []) => e.filter(({ key: e, ifMode: t }) => !(v.has(e) && t !== "latex")), b = g("pie-lib:math-input-mathlive:input"), x = /([0-9])\\ (\\frac\{[^{}]*\}\{(?:\\placeholder\{\})?\})/, S = h("span")({
13
+ var v = /* @__PURE__ */ new Set(["[Tab]", "shift+[Tab]"]), y = (e = []) => e.filter(({ key: e, ifMode: t }) => !(v.has(e) && t !== "latex")), b = r("pie-lib:math-input-mathlive:input"), x = /([0-9])\\ (\\frac\{[^{}]*\}\{(?:\\placeholder\{\})?\})/, S = n("span")({
14
14
  display: "inline-block",
15
15
  "& math-field": {
16
16
  display: "block",
@@ -18,32 +18,32 @@ var v = /* @__PURE__ */ new Set(["[Tab]", "shift+[Tab]"]), y = (e = []) => e.fil
18
18
  },
19
19
  "& math-field::part(virtual-keyboard-toggle)": { display: "none" },
20
20
  "& math-field::part(menu-toggle)": { display: "none" }
21
- }), C = class extends p.Component {
21
+ }), C = class extends e.Component {
22
22
  static propTypes = {
23
- className: m.string,
24
- latex: m.string,
25
- onChange: m.func,
26
- onClick: m.func,
27
- onFocus: m.func,
28
- onBlur: m.func,
29
- language: m.string,
30
- ariaDescribedBy: m.string,
31
- readOnly: m.bool,
32
- innerRef: m.func
23
+ className: t.string,
24
+ latex: t.string,
25
+ onChange: t.func,
26
+ onClick: t.func,
27
+ onFocus: t.func,
28
+ onBlur: t.func,
29
+ language: t.string,
30
+ ariaDescribedBy: t.string,
31
+ readOnly: t.bool,
32
+ innerRef: t.func
33
33
  };
34
- relabel = () => a(this.mathField, this.props.language);
35
- constructor(e) {
36
- super(e), this.holderRef = p.createRef(), this.lastEmitted = void 0;
34
+ relabel = () => l(this.mathField, this.props.language);
35
+ constructor(t) {
36
+ super(t), this.holderRef = e.createRef(), this.lastEmitted = void 0;
37
37
  }
38
38
  async componentDidMount() {
39
- let o = this.mountGeneration = (this.mountGeneration || 0) + 1, s = await n();
40
- o === this.mountGeneration && s?.MathfieldElement && this.holderRef.current && !this.mathField && (this.mathField = t(s), a(this.mathField, this.props.language, this.relabel), i(this.mathField, this.props.ariaDescribedBy), this.mathField.value = l(this.props.latex || ""), this.lastEmitted = this.props.latex, this.props.readOnly && (this.mathField.readOnly = !0), this.mathField.mathVirtualKeyboardPolicy = "manual", this.mathField.mathModeSpace = "\\ ", this.mathField.smartSuperscript = !1, this.mathField.popoverPolicy = "off", e(this.mathField), this.untrackCaret = r(this.mathField), this.untrackSelection = u(this.mathField), this.untrackLongDivision = d(this.mathField), this.stopKeepingCaret = f(this.mathField), this.mathField.addEventListener("input", this.onInputEdit), this.holderRef.current.replaceChildren(this.mathField), a(this.mathField, this.props.language, this.relabel), this.mathField.keybindings = y(this.mathField.keybindings), this.props.innerRef && this.props.innerRef(this), this.pendingFocus && (this.pendingFocus = !1, this.mathField.focus()));
39
+ let e = this.mountGeneration = (this.mountGeneration || 0) + 1, t = await o();
40
+ e === this.mountGeneration && t?.MathfieldElement && this.holderRef.current && !this.mathField && (this.mathField = a(t), l(this.mathField, this.props.language, this.relabel), c(this.mathField, this.props.ariaDescribedBy), this.mathField.value = p(this.props.latex || ""), this.lastEmitted = this.props.latex, this.props.readOnly && (this.mathField.readOnly = !0), this.mathField.mathVirtualKeyboardPolicy = "manual", this.mathField.mathModeSpace = "\\ ", this.mathField.smartSuperscript = !1, this.mathField.popoverPolicy = "off", i(this.mathField), this.untrackCaret = s(this.mathField), this.untrackSelection = m(this.mathField), this.untrackLongDivision = h(this.mathField), this.stopKeepingCaret = g(this.mathField), this.mathField.addEventListener("input", this.onInputEdit), this.holderRef.current.replaceChildren(this.mathField), l(this.mathField, this.props.language, this.relabel), this.mathField.keybindings = y(this.mathField.keybindings), this.props.innerRef && this.props.innerRef(this), this.pendingFocus && (this.pendingFocus = !1, this.mathField.focus()));
41
41
  }
42
42
  componentDidUpdate(e) {
43
43
  if (!this.mathField) return;
44
44
  let { latex: t, readOnly: n, language: r } = this.props;
45
- if (r !== e.language && a(this.mathField, r, this.relabel), this.props.ariaDescribedBy !== e.ariaDescribedBy && i(this.mathField, this.props.ariaDescribedBy), n !== e.readOnly && (this.mathField.readOnly = !!n), t != null && t !== this.lastEmitted) {
46
- let e = l(t);
45
+ if (r !== e.language && l(this.mathField, r, this.relabel), this.props.ariaDescribedBy !== e.ariaDescribedBy && c(this.mathField, this.props.ariaDescribedBy), n !== e.readOnly && (this.mathField.readOnly = !!n), t != null && t !== this.lastEmitted) {
46
+ let e = p(t);
47
47
  e !== this.mathField.value && (this.mathField.value = e);
48
48
  }
49
49
  }
@@ -53,11 +53,11 @@ var v = /* @__PURE__ */ new Set(["[Tab]", "shift+[Tab]"]), y = (e = []) => e.fil
53
53
  onInputEdit = () => {
54
54
  let { onChange: e } = this.props;
55
55
  if (!this.mathField) return;
56
- let t = s(this.mathField.getValue("latex"));
56
+ let t = d(this.mathField.getValue("latex"));
57
57
  this.lastEmitted = t, e && e(t);
58
58
  };
59
59
  latex() {
60
- return this.mathField ? s(this.mathField.getValue("latex")) : "";
60
+ return this.mathField ? d(this.mathField.getValue("latex")) : "";
61
61
  }
62
62
  get element() {
63
63
  return this.mathField;
@@ -71,7 +71,7 @@ var v = /* @__PURE__ */ new Set(["[Tab]", "shift+[Tab]"]), y = (e = []) => e.fil
71
71
  };
72
72
  }
73
73
  setLatex(e) {
74
- this.mathField && (this.mathField.value = l(e || ""));
74
+ this.mathField && (this.mathField.value = p(e || ""));
75
75
  }
76
76
  clear() {
77
77
  return this.mathField && (this.mathField.value = "", this.onInputEdit()), "";
@@ -94,12 +94,12 @@ var v = /* @__PURE__ */ new Set(["[Tab]", "shift+[Tab]"]), y = (e = []) => e.fil
94
94
  }
95
95
  command(e) {
96
96
  if (b("command: ", e), !this.mathField) return "";
97
- let t = c({ command: e });
97
+ let t = f({ command: e });
98
98
  return t && this.mathField.insert(t.value, { focus: !0 }), this.mathField.focus(), this.latex();
99
99
  }
100
100
  keystroke(e) {
101
101
  if (b("keystroke: ", e), !this.mathField) return "";
102
- let t = o[e] || e;
102
+ let t = u[e] || e;
103
103
  try {
104
104
  this.mathField.executeCommand(t);
105
105
  } catch (t) {
package/dist/mf/static.js CHANGED
@@ -1,20 +1,20 @@
1
- import { applyShadowStyles as e, createMathField as t, latexToMarkup as n, latexToMathMl as r, loadMathLive as i, trackPlaceholderCaret as a } from "../mathlive-instance.js";
2
- import { fixLongDivisionWhenReady as o, trackLongDivision as s } from "../longdiv.js";
3
- import { keepCaretWhileKeypadFocused as c } from "./inactive-caret.js";
4
- import { describeMathField as l, labelMathField as u } from "./field-label.js";
5
- import { KEYSTROKES as d, fieldIds as f, fieldTemplate as p, fieldValues as m, fromMathLive as h, inlineFields as g, keyToAction as _, toMathLive as v } from "../latex-bridge.js";
6
- import { parallelStyles as y, placeholderStyles as b, rootIndexStyles as x } from "./common-styles.js";
7
- import S from "react";
8
- import C from "prop-types";
9
- import { styled as w } from "@mui/material/styles";
10
- import T from "debug";
1
+ import e from "react";
2
+ import t from "prop-types";
3
+ import { styled as n } from "@mui/material/styles";
4
+ import r from "debug";
5
+ import { applyShadowStyles as i, createMathField as a, latexToMarkup as o, latexToMathMl as s, loadMathLive as c, trackPlaceholderCaret as l } from "../mathlive-instance.js";
6
+ import { fixLongDivisionWhenReady as u, trackLongDivision as d } from "../longdiv.js";
7
+ import { keepCaretWhileKeypadFocused as f } from "./inactive-caret.js";
8
+ import { describeMathField as p, labelMathField as m } from "./field-label.js";
9
+ import { KEYSTROKES as h, fieldIds as g, fieldTemplate as _, fieldValues as v, fromMathLive as y, inlineFields as b, keyToAction as x, toMathLive as S } from "../latex-bridge.js";
10
+ import { parallelStyles as C, placeholderStyles as w, rootIndexStyles as T } from "./common-styles.js";
11
11
  import { jsx as E } from "react/jsx-runtime";
12
12
  // src/mf/static.tsx
13
- var D = T("pie-lib:math-input-mathlive:static"), O = "position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0", k = w("span")({
13
+ var D = r("pie-lib:math-input-mathlive:static"), O = "position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0", k = n("span")({
14
14
  display: "inline-block",
15
- ...b,
16
- ...x,
17
- ...y,
15
+ ...w,
16
+ ...T,
17
+ ...C,
18
18
  "& math-field": {
19
19
  display: "inline-block",
20
20
  border: "none",
@@ -22,38 +22,38 @@ var D = T("pie-lib:math-input-mathlive:static"), O = "position:absolute;width:1p
22
22
  },
23
23
  "& math-field::part(virtual-keyboard-toggle)": { display: "none" },
24
24
  "& math-field::part(menu-toggle)": { display: "none" }
25
- }), A = class extends S.Component {
25
+ }), A = class extends e.Component {
26
26
  static propTypes = {
27
- latex: C.string.isRequired,
28
- className: C.string,
29
- onFocus: C.func,
30
- onBlur: C.func,
31
- language: C.string,
32
- ariaDescribedBy: C.string,
33
- getFieldName: C.func,
34
- onSubFieldChange: C.func,
35
- onSubFieldFocus: C.func,
36
- setInput: C.func
27
+ latex: t.string.isRequired,
28
+ className: t.string,
29
+ onFocus: t.func,
30
+ onBlur: t.func,
31
+ language: t.string,
32
+ ariaDescribedBy: t.string,
33
+ getFieldName: t.func,
34
+ onSubFieldChange: t.func,
35
+ onSubFieldFocus: t.func,
36
+ setInput: t.func
37
37
  };
38
38
  static defaultProps = { getFieldName: () => {} };
39
- relabel = () => u(this.mathField, this.props.language);
40
- constructor(e) {
41
- super(e), this.holderRef = S.createRef(), this.state = { markup: "" }, this.promptValues = {};
39
+ relabel = () => m(this.mathField, this.props.language);
40
+ constructor(t) {
41
+ super(t), this.holderRef = e.createRef(), this.state = { markup: "" }, this.promptValues = {};
42
42
  }
43
43
  componentDidMount() {
44
44
  this.mount();
45
45
  }
46
46
  async mount() {
47
- let n = this.mountGeneration = (this.mountGeneration || 0) + 1;
47
+ let e = this.mountGeneration = (this.mountGeneration || 0) + 1;
48
48
  if (this.interactive = this.isInteractive(), !this.interactive) {
49
- await i(), n === this.mountGeneration && this.renderMarkup();
49
+ await c(), e === this.mountGeneration && this.renderMarkup();
50
50
  return;
51
51
  }
52
- let r = await i();
53
- n === this.mountGeneration && r?.MathfieldElement && this.holderRef.current && !this.mathField && (this.mathField = t(r), u(this.mathField, this.props.language, this.relabel), l(this.mathField, this.props.ariaDescribedBy), this.mathField.readOnly = !0, this.mathField.mathVirtualKeyboardPolicy = "manual", this.mathField.mathModeSpace = "\\ ", this.mathField.smartSuperscript = !1, this.mathField.popoverPolicy = "off", this.mathField.value = v(this.props.latex), e(this.mathField), this.untrackCaret = a(this.mathField), this.untrackLongDivision = s(this.mathField), this.stopKeepingCaret = c(this.mathField), this.mathField.addEventListener("input", this.onPromptInput), this.mathField.addEventListener("pointerdown", this.onPointerDown, !0), this.mathField.addEventListener("focusin", this.onPromptFocus), this.mathField.addEventListener("selection-change", this.onSelectionChange), this.mathField.addEventListener("keydown", this.onKeyDown), this.holderRef.current.replaceChildren(this.mathField), u(this.mathField, this.props.language, this.relabel), this.parkCaret(), this.createLiveRegion());
52
+ let t = await c();
53
+ e === this.mountGeneration && t?.MathfieldElement && this.holderRef.current && !this.mathField && (this.mathField = a(t), m(this.mathField, this.props.language, this.relabel), p(this.mathField, this.props.ariaDescribedBy), this.mathField.readOnly = !0, this.mathField.mathVirtualKeyboardPolicy = "manual", this.mathField.mathModeSpace = "\\ ", this.mathField.smartSuperscript = !1, this.mathField.popoverPolicy = "off", this.mathField.value = S(this.props.latex), i(this.mathField), this.untrackCaret = l(this.mathField), this.untrackLongDivision = d(this.mathField), this.stopKeepingCaret = f(this.mathField), this.mathField.addEventListener("input", this.onPromptInput), this.mathField.addEventListener("pointerdown", this.onPointerDown, !0), this.mathField.addEventListener("focusin", this.onPromptFocus), this.mathField.addEventListener("selection-change", this.onSelectionChange), this.mathField.addEventListener("keydown", this.onKeyDown), this.holderRef.current.replaceChildren(this.mathField), m(this.mathField, this.props.language, this.relabel), this.parkCaret(), this.createLiveRegion());
54
54
  }
55
55
  componentDidUpdate(e, t) {
56
- !this.mathField && this.state.markup !== (t && t.markup) && o(this.holderRef.current), this.mathField && e.language !== this.props.language && u(this.mathField, this.props.language, this.relabel), this.mathField && e.ariaDescribedBy !== this.props.ariaDescribedBy && l(this.mathField, this.props.ariaDescribedBy), e.latex !== this.props.latex && (this.isInteractive() === this.interactive ? this.mathField ? p(this.props.latex) === p(e.latex) ? this.syncPrompts() : (this.mathField.value = v(this.props.latex), this.parkCaret()) : this.renderMarkup() : (this.unmountField(), this.setState({ markup: "" }), this.mount()));
56
+ !this.mathField && this.state.markup !== (t && t.markup) && u(this.holderRef.current), this.mathField && e.language !== this.props.language && m(this.mathField, this.props.language, this.relabel), this.mathField && e.ariaDescribedBy !== this.props.ariaDescribedBy && p(this.mathField, this.props.ariaDescribedBy), e.latex !== this.props.latex && (this.isInteractive() === this.interactive ? this.mathField ? _(this.props.latex) === _(e.latex) ? this.syncPrompts() : (this.mathField.value = S(this.props.latex), this.parkCaret()) : this.renderMarkup() : (this.unmountField(), this.setState({ markup: "" }), this.mount()));
57
57
  }
58
58
  parkCaret() {
59
59
  if (!this.mathField || this.mathField.hasFocus?.()) return;
@@ -61,10 +61,10 @@ var D = T("pie-lib:math-input-mathlive:static"), O = "position:absolute;width:1p
61
61
  t && (this.mathField.selection = { ranges: [[t[0], t[0]]] });
62
62
  }
63
63
  syncPrompts() {
64
- let e = m(this.props.latex);
64
+ let e = v(this.props.latex);
65
65
  Object.keys(e).forEach((t) => {
66
66
  let n = e[t];
67
- n !== this.promptValues[t] && n !== h(this.mathField.getPromptValue(t)) && (this.mathField.setPromptValue(t, v(n), {}), this.promptValues[t] = n);
67
+ n !== this.promptValues[t] && n !== y(this.mathField.getPromptValue(t)) && (this.mathField.setPromptValue(t, S(n), {}), this.promptValues[t] = n);
68
68
  });
69
69
  }
70
70
  componentWillUnmount() {
@@ -102,21 +102,21 @@ var D = T("pie-lib:math-input-mathlive:static"), O = "position:absolute;width:1p
102
102
  };
103
103
  isInteractive() {
104
104
  let e = this.props.latex || "";
105
- return f(e).length > 0 || e.indexOf("\\placeholder") !== -1;
105
+ return g(e).length > 0 || e.indexOf("\\placeholder") !== -1;
106
106
  }
107
107
  renderMarkup() {
108
- let e = n(this.props.latex), t = e && r(this.props.latex), i = t ? `<span aria-hidden="true">${e}</span><span style="${O}">${t}</span>` : e;
109
- i !== this.state.markup && this.setState({ markup: i });
108
+ let e = o(this.props.latex), t = e && s(this.props.latex), n = t ? `<span aria-hidden="true">${e}</span><span style="${O}">${t}</span>` : e;
109
+ n !== this.state.markup && this.setState({ markup: n });
110
110
  }
111
111
  values() {
112
112
  if (!this.mathField) return {};
113
113
  let e = {};
114
114
  return (this.mathField.getPrompts() || []).forEach((t) => {
115
- e[t] = h(this.mathField.getPromptValue(t));
115
+ e[t] = y(this.mathField.getPromptValue(t));
116
116
  }), e;
117
117
  }
118
118
  latex() {
119
- return this.mathField ? g(this.props.latex, this.values()) : "";
119
+ return this.mathField ? b(this.props.latex, this.values()) : "";
120
120
  }
121
121
  selectPrompt(e) {
122
122
  this.promptContaining(this.mathField.position) !== e && this.focusPrompt(e);
@@ -129,12 +129,12 @@ var D = T("pie-lib:math-input-mathlive:static"), O = "position:absolute;width:1p
129
129
  id: e,
130
130
  write: (e) => t((t) => (Array.isArray(e) ? e : [e]).forEach((e) => t.insert(e, { focus: !0 }))),
131
131
  cmd: (e) => t((t) => {
132
- let n = _({ command: e });
132
+ let n = x({ command: e });
133
133
  n && t.insert(n.value, { focus: !0 });
134
134
  }),
135
135
  keystroke: (e) => t((t) => {
136
136
  try {
137
- t.executeCommand(d[e] || e);
137
+ t.executeCommand(h[e] || e);
138
138
  } catch (t) {
139
139
  D("unknown keystroke/selector \"%s\": %s", e, t && t.message);
140
140
  }
@@ -146,7 +146,7 @@ var D = T("pie-lib:math-input-mathlive:static"), O = "position:absolute;width:1p
146
146
  this.mathField && (this.mathField.focus(), this.selectPrompt(e));
147
147
  },
148
148
  el: () => this.mathField,
149
- latex: (t) => this.mathField ? t === void 0 ? h(this.mathField.getPromptValue(e)) : (this.mathField.setPromptValue(e, v(t), {}), t) : ""
149
+ latex: (t) => this.mathField ? t === void 0 ? y(this.mathField.getPromptValue(e)) : (this.mathField.setPromptValue(e, S(t), {}), t) : ""
150
150
  };
151
151
  }
152
152
  get innerFields() {
package/dist/selection.js CHANGED
@@ -3,7 +3,7 @@ import e from "debug";
3
3
  var t = e("pie-lib:math-input-mathlive:selection"), n = (e, t, n, r) => {
4
4
  let i = (e) => n(e) || {}, a = (e) => i(e).depth || 0, o = (e) => a(e) > 0 && i(e).latex === "";
5
5
  if (t < e && ([e, t] = [t, e]), t - e < 1) return [e, t];
6
- let s = Infinity;
6
+ let s = 1e400;
7
7
  for (let n = e; n <= t; n++) s = Math.min(s, a(n));
8
8
  for (let n = e + 1; n <= t; n++) if (a(n) === s && o(n)) {
9
9
  --s;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-lib/math-input-mathlive",
3
- "version": "2.0.4-next.20261202133946",
3
+ "version": "2.0.4-next.20261202142832",
4
4
  "description": "MathLive-based math input (drop-in alternative to @pie-lib/math-input)",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -16,9 +16,9 @@
16
16
  "debug": "^4.1.1",
17
17
  "mathlive": "0.111.4",
18
18
  "prop-types": "^15.7.2",
19
- "@pie-element/shared-lodash": "0.1.7-next.20261202133946",
20
- "@pie-lib/render-ui": "8.0.11-next.20261202133946",
21
- "@pie-element/shared-i18n": "0.1.6-next.20261202133946"
19
+ "@pie-element/shared-lodash": "0.1.7-next.20261202142832",
20
+ "@pie-lib/render-ui": "8.0.11-next.20261202142832",
21
+ "@pie-element/shared-i18n": "0.1.6-next.20261202142832"
22
22
  },
23
23
  "type": "module",
24
24
  "main": "./dist/index.js",