@pie-lib/math-input 0.1.1-next.0 → 0.1.1-next.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.
package/dist/index.d.ts CHANGED
@@ -13,4 +13,6 @@ import HorizontalKeypad from './horizontal-keypad';
13
13
  import * as mq from './mq';
14
14
  declare const addBrackets: (s: any) => any;
15
15
  declare const removeBrackets: (s: any) => any;
16
- export { keysForGrade, addBrackets, removeBrackets, keys, HorizontalKeypad, mq, updateSpans };
16
+ declare const registerEmbed: (name: any, factory: any) => void;
17
+ declare const applyStaticMath: (element: any, latex?: string) => any;
18
+ export { keysForGrade, addBrackets, removeBrackets, keys, HorizontalKeypad, mq, updateSpans, registerEmbed, applyStaticMath, };
package/dist/index.js CHANGED
@@ -3,7 +3,17 @@ import { updateSpans as t } from "./updateSpans.js";
3
3
  import { keys_exports as n } from "./keys/index.js";
4
4
  import r from "./horizontal-keypad.js";
5
5
  import { mq_exports as i } from "./mq/index.js";
6
+ import a from "@pie-framework/mathquill";
6
7
  //#region src/index.tsx
7
- var a = (e) => e.indexOf("\\(") === 0 ? e : `\\(${e}`, o = (e) => e.indexOf("\\)") === e.length - 2 ? e : `${e}\\)`, s = (e) => e.indexOf("\\(") === 0 ? e.substring(2) : e, c = (e) => e.indexOf("\\)") === e.length - 2 ? e.substring(0, e.length - 2) : e, l = (e) => o(a(e)), u = (e) => c(s(e));
8
+ var o = (e) => e.indexOf("\\(") === 0 ? e : `\\(${e}`, s = (e) => e.indexOf("\\)") === e.length - 2 ? e : `${e}\\)`, c = (e) => e.indexOf("\\(") === 0 ? e.substring(2) : e, l = (e) => e.indexOf("\\)") === e.length - 2 ? e.substring(0, e.length - 2) : e, u = (e) => s(o(e)), d = (e) => l(c(e)), f = () => typeof window > "u" ? null : a.getInterface(2), p = (e, t) => {
9
+ let n = f();
10
+ n?.registerEmbed && n.registerEmbed(e, t);
11
+ }, m = (e, n = "") => {
12
+ let r = f();
13
+ if (!r?.StaticMath || !e) return null;
14
+ e.textContent = "";
15
+ let i = r.StaticMath(e);
16
+ return typeof i?.latex == "function" && i.latex(n), t(e), i;
17
+ };
8
18
  //#endregion
9
- export { r as HorizontalKeypad, l as addBrackets, n as keys, e as keysForGrade, i as mq, u as removeBrackets, t as updateSpans };
19
+ export { r as HorizontalKeypad, u as addBrackets, m as applyStaticMath, n as keys, e as keysForGrade, i as mq, p as registerEmbed, d as removeBrackets, t as updateSpans };
@@ -23,8 +23,12 @@ export default class AccessibleKeypad extends React.Component {
23
23
  componentWillUnmount(): void;
24
24
  handleKeypadInteraction: () => void;
25
25
  keyIsNotAllowed: (key: any) => any;
26
- flowKeys: (base: any, extras: any) => any;
27
- toRenderModel: () => any;
26
+ flowKeys: (base: any, extras: any) => unknown[];
27
+ toRenderModel: () => {
28
+ id: string;
29
+ ariaLabel: string;
30
+ key: any;
31
+ }[];
28
32
  pressKey: (definition: any) => void;
29
33
  moveFocus: (nextIndex: any) => void;
30
34
  onButtonKeyDown: (event: any, index: any) => void;
@@ -2,7 +2,7 @@ import { baseSet as e } from "../keys/index.js";
2
2
  import { commonMqKeyboardStyles as t } from "../mq/common-mq-styles.js";
3
3
  import { getAriaLabel as n } from "./model.js";
4
4
  import { sortKeys as r } from "./keys-layout.js";
5
- import { flatten as i } from "lodash-es";
5
+ import { flatten as i } from "@pie-element/shared-lodash";
6
6
  import a from "react";
7
7
  import o from "prop-types";
8
8
  import s from "@mui/material/Button";
@@ -12,4 +12,4 @@
12
12
  * Expects an array of rows.
13
13
  * @param {} keys
14
14
  */
15
- export declare const sortKeys: (keys: any) => any;
15
+ export declare const sortKeys: (keys: any) => unknown[][];
@@ -1,4 +1,4 @@
1
- import { times as e, zip as t } from "lodash-es";
1
+ import { times as e, zip as t } from "@pie-element/shared-lodash";
2
2
  //#region src/keypad/keys-layout.ts
3
3
  var n = (n) => (e(5 - n.length, () => n.push([])), t.apply(null, n));
4
4
  //#endregion
@@ -6,5 +6,18 @@
6
6
  * Manual edits will be overwritten on next sync.
7
7
  * To make changes, edit the upstream JavaScript file and run sync again.
8
8
  */
9
- declare const _default: any;
9
+ declare const _default: {
10
+ comma: {
11
+ name: string;
12
+ label: string;
13
+ write: string;
14
+ category: string;
15
+ };
16
+ decimalPoint: {
17
+ name: string;
18
+ label: string;
19
+ write: string;
20
+ category: string;
21
+ };
22
+ };
10
23
  export default _default;
@@ -1,4 +1,4 @@
1
- import { times as e } from "lodash-es";
1
+ import { times as e } from "@pie-element/shared-lodash";
2
2
  //#region src/keys/digits.ts
3
3
  var t = {
4
4
  0: "zero",
@@ -1,4 +1,4 @@
1
- import { flatten as e, times as t } from "lodash-es";
1
+ import { flatten as e, times as t } from "@pie-element/shared-lodash";
2
2
  //#region src/keys/utils.ts
3
3
  var n = (e) => (t) => ({
4
4
  ...t,
package/dist/mq/input.js CHANGED
@@ -1,21 +1,21 @@
1
1
  import { registerLineBreak as e } from "./custom-elements.js";
2
- import t from "react";
3
- import n from "prop-types";
4
- import { styled as r } from "@mui/material/styles";
5
- import i from "debug";
6
- import { jsx as a } from "react/jsx-runtime";
7
- import o from "@pie-framework/mathquill";
2
+ import t from "@pie-framework/mathquill";
3
+ import n from "react";
4
+ import r from "prop-types";
5
+ import { styled as i } from "@mui/material/styles";
6
+ import a from "debug";
7
+ import { jsx as o } from "react/jsx-runtime";
8
8
  //#region src/mq/input.tsx
9
9
  var s;
10
- typeof window < "u" && (s = o.getInterface(2), s && s.registerEmbed && e(s));
11
- var c = i("math-input:mq:input"), l = r("span")({}), u = class extends t.Component {
10
+ typeof window < "u" && (s = t.getInterface(2), s && s.registerEmbed && e(s));
11
+ var c = a("math-input:mq:input"), l = i("span")({}), u = class extends n.Component {
12
12
  static propTypes = {
13
- className: n.string,
14
- onClick: n.func,
15
- onChange: n.func,
16
- latex: n.string,
17
- onFocus: n.func,
18
- onBlur: n.func
13
+ className: r.string,
14
+ onClick: r.func,
15
+ onChange: r.func,
16
+ latex: r.string,
17
+ onFocus: r.func,
18
+ onBlur: r.func
19
19
  };
20
20
  componentDidMount() {
21
21
  if (!s) throw Error("MQ is not defined - but component has mounted?");
@@ -69,7 +69,7 @@ var c = i("math-input:mq:input"), l = r("span")({}), u = class extends t.Compone
69
69
  }
70
70
  render() {
71
71
  let { onFocus: e, onBlur: t, className: n } = this.props;
72
- return /* @__PURE__ */ a(l, {
72
+ return /* @__PURE__ */ o(l, {
73
73
  className: n,
74
74
  onKeyDown: this.onKeyPress,
75
75
  onClick: this.onClick,
package/dist/mq/static.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { updateSpans as e } from "../updateSpans.js";
2
- import t from "react";
3
- import n from "prop-types";
4
- import r from "debug";
5
- import { jsx as i } from "react/jsx-runtime";
6
- import a from "@pie-framework/mathquill";
2
+ import t from "@pie-framework/mathquill";
3
+ import n from "react";
4
+ import r from "prop-types";
5
+ import i from "debug";
6
+ import { jsx as a } from "react/jsx-runtime";
7
7
  //#region src/mq/static.tsx
8
8
  var o;
9
- typeof window < "u" && (o = a.getInterface(2));
10
- var s = r("pie-lib:math-input:mq:static"), c = /\\MathQuillMathField\[r\d*\]\{(.*?)\}/g, l = / /g;
9
+ typeof window < "u" && (o = t.getInterface(2));
10
+ var s = i("pie-lib:math-input:mq:static"), c = /\\MathQuillMathField\[r\d*\]\{(.*?)\}/g, l = / /g;
11
11
  function u(e = "") {
12
12
  return e.replace(l, "");
13
13
  }
@@ -16,16 +16,16 @@ function d(e) {
16
16
  for (let n = 0; n < (e || "").length; n++) e[n] === "{" && t++;
17
17
  return t;
18
18
  }
19
- var f = class extends t.Component {
19
+ var f = class extends n.Component {
20
20
  static propTypes = {
21
- latex: n.string.isRequired,
22
- onFocus: n.func,
23
- onBlur: n.func,
24
- className: n.string,
25
- getFieldName: n.func,
26
- onSubFieldChange: n.func,
27
- onSubFieldFocus: n.func,
28
- setInput: n.func
21
+ latex: r.string.isRequired,
22
+ onFocus: r.func,
23
+ onBlur: r.func,
24
+ className: r.string,
25
+ getFieldName: r.func,
26
+ onSubFieldChange: r.func,
27
+ onSubFieldFocus: r.func,
28
+ setInput: r.func
29
29
  };
30
30
  static defaultProps = { getFieldName: () => {} };
31
31
  constructor(e) {
@@ -34,7 +34,7 @@ var f = class extends t.Component {
34
34
  previousLatex: "",
35
35
  inputSource: null,
36
36
  isDeleteKeyPressed: !1
37
- }, this.inputRef = t.createRef();
37
+ }, this.inputRef = n.createRef();
38
38
  }
39
39
  componentDidMount() {
40
40
  this.update(), e(), this.createLiveRegion(), this.addEventListeners();
@@ -130,7 +130,7 @@ var f = class extends t.Component {
130
130
  };
131
131
  render() {
132
132
  let { onBlur: e, className: t } = this.props;
133
- return /* @__PURE__ */ i("span", {
133
+ return /* @__PURE__ */ a("span", {
134
134
  className: t,
135
135
  onFocus: this.onFocus,
136
136
  onBlur: e,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-lib/math-input",
3
- "version": "0.1.1-next.0",
3
+ "version": "0.1.1-next.1",
4
4
  "description": "React implementation of @pie-lib/math-input synced from pie-lib",
5
5
  "dependencies": {
6
6
  "@emotion/react": "^11.14.0",
@@ -12,7 +12,7 @@
12
12
  "@pie-element/shared-math-rendering-mathjax": "0.1.0",
13
13
  "@pie-lib/render-ui": "6.1.1-next.0",
14
14
  "debug": "^4.1.1",
15
- "lodash-es": "^4.17.23",
15
+ "@pie-element/shared-lodash": "0.1.1-next.0",
16
16
  "prop-types": "^15.7.2",
17
17
  "react": "^18.2.0"
18
18
  },