@pie-element/math-templated 7.1.1-next.15 → 7.1.1-next.16

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,4 +1,4 @@
1
- import e from "./response.js";
1
+ import { Response as e } from "./response.js";
2
2
  import { createSlateMarkup as t, processMarkup as n } from "./markupUtils.js";
3
3
  import { generateValidationMessage as r } from "./utils.js";
4
4
  import i from "react";
@@ -10,46 +10,46 @@ import { jsx as d, jsxs as f } from "react/jsx-runtime";
10
10
  import p from "@mui/material/Typography";
11
11
  import m from "@mui/material/Select";
12
12
  import h from "@mui/material/MenuItem";
13
- import ee from "@mui/icons-material/Info";
14
- import { InputContainer as g, layout as te, settings as _ } from "@pie-lib/config-ui";
15
- import v, { ALL_PLUGINS as ne } from "@pie-lib/editable-html-tip-tap";
13
+ import g from "@mui/icons-material/Info";
14
+ import { InputContainer as _, layout as ee, settings as v } from "@pie-lib/config-ui";
15
+ import y, { ALL_PLUGINS as b } from "@pie-lib/editable-html-tip-tap";
16
16
  //#region src/author/design.tsx
17
- var { dropdown: y } = _, { Panel: re, toggle: b } = _, x = l(g)(({ theme: e }) => ({
17
+ var { dropdown: te } = v, { Panel: ne, toggle: x } = v, S = l(_)(({ theme: e }) => ({
18
18
  width: "100%",
19
19
  paddingTop: e.spacing(2),
20
20
  marginBottom: e.spacing(2)
21
- })), S = l(v)({ width: "100%" }), C = l("div")(({ theme: e }) => ({
21
+ })), C = l(y)({ width: "100%" }), w = l("div")(({ theme: e }) => ({
22
22
  color: e.palette.error.main,
23
23
  fontSize: "0.75rem",
24
24
  marginTop: e.spacing(1)
25
- })), ie = l("div")(({ theme: e }) => ({
25
+ })), T = l("div")(({ theme: e }) => ({
26
26
  color: e.palette.error.main,
27
27
  fontSize: "0.75rem",
28
28
  marginBottom: e.spacing(1)
29
- })), ae = l(v)(({ theme: e }) => ({
29
+ })), re = l(y)(({ theme: e }) => ({
30
30
  width: "100%",
31
31
  marginTop: e.spacing(2),
32
32
  marginBottom: e.spacing(3)
33
- })), oe = l(g)(({ theme: e }) => ({
33
+ })), ie = l(_)(({ theme: e }) => ({
34
34
  width: "100%",
35
35
  marginTop: e.spacing(2),
36
36
  "& > *:not(label)": { marginTop: e.spacing(1) },
37
37
  marginBottom: e.spacing(2)
38
- })), se = l(m)({ width: "100%" }), w = l(p)(({ theme: e }) => ({
38
+ })), ae = l(m)({ width: "100%" }), E = l(p)(({ theme: e }) => ({
39
39
  fontSize: e.typography.fontSize * 1.25,
40
40
  fontWeight: "bold"
41
- })), T = l("div")({
41
+ })), D = l("div")({
42
42
  display: "flex",
43
43
  alignItems: "center",
44
44
  gap: "8px"
45
- }), E = l(u)(({ theme: e }) => ({ "& .MuiTooltip-tooltip": {
45
+ }), oe = l(u)(({ theme: e }) => ({ "& .MuiTooltip-tooltip": {
46
46
  fontSize: e.typography.fontSize - 2,
47
47
  whiteSpace: "pre",
48
48
  maxWidth: "500px"
49
- } })), D = (e) => {
49
+ } })), O = (e) => {
50
50
  let t = document.createElement("div");
51
51
  return t.innerHTML = e.trim(), t;
52
- }, O = class extends i.Component {
52
+ }, k = class extends i.Component {
53
53
  static propTypes = {
54
54
  model: a.object.isRequired,
55
55
  configuration: a.object.isRequired,
@@ -99,7 +99,7 @@ var { dropdown: y } = _, { Panel: re, toggle: b } = _, x = l(g)(({ theme: e }) =
99
99
  });
100
100
  };
101
101
  onChange = (e) => {
102
- let { model: { responses: t, validationDefault: r, allowTrailingZerosDefault: i, ignoreOrderDefault: a }, onModelChanged: o } = this.props, s = {}, c = D(e);
102
+ let { model: { responses: t, validationDefault: r, allowTrailingZerosDefault: i, ignoreOrderDefault: a }, onModelChanged: o } = this.props, s = {}, c = O(e);
103
103
  c.querySelectorAll("[data-type=\"math_templated\"]").forEach((e, n) => {
104
104
  let { value: o, index: c } = e.dataset;
105
105
  o || (e.dataset.value = ""), s[n] = t[c] || {
@@ -150,26 +150,26 @@ var { dropdown: y } = _, { Panel: re, toggle: b } = _, x = l(g)(({ theme: e }) =
150
150
  (!t || !n || !o?.attributes["data-keypad"]) && this.setState({ activeAnswerBlock: "" });
151
151
  };
152
152
  render() {
153
- let { configuration: t, imageSupport: n, model: i, onConfigurationChanged: a, onModelChanged: o, uploadSoundSupport: s } = this.props, { baseInputConfiguration: c = {}, contentDimensions: l = {}, prompt: u = {}, rationale: p = {}, settingsPanelDisabled: m, teacherInstructions: g = {}, language: _ = {}, languageChoices: v = {}, spellCheck: D = {}, playerSpellCheck: O = {}, maxImageWidth: k = {}, maxImageHeight: A = {}, mathMlOptions: j = {}, template: ce = {}, editSource: M = {}, ignoreOrder: le = {}, allowTrailingZeros: ue = {}, partialScoring: N = {}, maxResponseAreas: P } = t || {}, { errors: F, extraCSSRules: I, promptEnabled: L, rationaleEnabled: R, spellCheckEnabled: z, teacherInstructionsEnabled: B, toolbarEditorPosition: V, responses: H, equationEditor: U } = i || {}, { prompt: W, rationale: G, responseAreas: K, teacherInstructions: q, responses: J = {} } = F || {}, Y = r(t), de = {
154
- "language.enabled": _.settings && b(_.label, !0),
155
- language: _.settings && _.enabled && y(v.label, v.options)
153
+ let { configuration: t, imageSupport: n, model: i, onConfigurationChanged: a, onModelChanged: o, uploadSoundSupport: s } = this.props, { baseInputConfiguration: c = {}, contentDimensions: l = {}, prompt: u = {}, rationale: p = {}, settingsPanelDisabled: m, teacherInstructions: _ = {}, language: v = {}, languageChoices: y = {}, spellCheck: O = {}, playerSpellCheck: k = {}, maxImageWidth: A = {}, maxImageHeight: j = {}, mathMlOptions: M = {}, template: se = {}, editSource: N = {}, ignoreOrder: ce = {}, allowTrailingZeros: le = {}, partialScoring: P = {}, maxResponseAreas: F } = t || {}, { errors: I, extraCSSRules: L, promptEnabled: R, rationaleEnabled: z, spellCheckEnabled: B, teacherInstructionsEnabled: V, toolbarEditorPosition: H, responses: U, equationEditor: W } = i || {}, { prompt: G, rationale: K, responseAreas: q, teacherInstructions: J, responses: Y = {} } = I || {}, ue = r(t), de = {
154
+ "language.enabled": v.settings && x(v.label, !0),
155
+ language: v.settings && v.enabled && te(y.label, y.options)
156
156
  }, fe = {
157
- teacherInstructionsEnabled: g.settings && b(g.label),
158
- rationaleEnabled: p.settings && b(p.label),
159
- promptEnabled: u.settings && b(u.label),
160
- spellCheckEnabled: D.settings && b(D.label),
161
- playerSpellCheckEnabled: O.settings && b(O.label),
162
- "editSource.enabled": M?.settings && b(M.label, !0),
163
- partialScoring: N.settings && b(N.label)
164
- }, X = k && k.prompt, Z = A && A.prompt, Q = { position: V === "top" ? "top" : "bottom" }, $ = (e = {}, t = {}) => ({
157
+ teacherInstructionsEnabled: _.settings && x(_.label),
158
+ rationaleEnabled: p.settings && x(p.label),
159
+ promptEnabled: u.settings && x(u.label),
160
+ spellCheckEnabled: O.settings && x(O.label),
161
+ playerSpellCheckEnabled: k.settings && x(k.label),
162
+ "editSource.enabled": N?.settings && x(N.label, !0),
163
+ partialScoring: P.settings && x(P.label)
164
+ }, X = A && A.prompt, Z = j && j.prompt, Q = { position: H === "top" ? "top" : "bottom" }, $ = (e = {}, t = {}) => ({
165
165
  ...t,
166
166
  ...e
167
167
  });
168
- return /* @__PURE__ */ f(te.ConfigLayout, {
169
- extraCSSRules: I,
168
+ return /* @__PURE__ */ f(ee.ConfigLayout, {
169
+ extraCSSRules: L,
170
170
  dimensions: l,
171
171
  hideSettings: m,
172
- settings: /* @__PURE__ */ d(re, {
172
+ settings: /* @__PURE__ */ d(ne, {
173
173
  model: i,
174
174
  configuration: t,
175
175
  onChangeModel: (e) => o(e),
@@ -180,67 +180,67 @@ var { dropdown: y } = _, { Panel: re, toggle: b } = _, x = l(g)(({ theme: e }) =
180
180
  }
181
181
  }),
182
182
  children: [
183
- B && /* @__PURE__ */ f(x, {
184
- label: g.label,
185
- children: [/* @__PURE__ */ d(S, {
183
+ V && /* @__PURE__ */ f(S, {
184
+ label: _.label,
185
+ children: [/* @__PURE__ */ d(C, {
186
186
  markup: i.teacherInstructions || "",
187
187
  onChange: (e) => this.handleChange("teacherInstructions", e),
188
188
  imageSupport: n,
189
189
  nonEmpty: !1,
190
- error: q,
190
+ error: J,
191
191
  toolbarOpts: Q,
192
- pluginProps: $(g?.inputConfiguration, c),
193
- spellCheck: z,
194
- maxImageWidth: k && k.teacherInstructions || X,
195
- maxImageHeight: A && A.teacherInstructions || Z,
192
+ pluginProps: $(_?.inputConfiguration, c),
193
+ spellCheck: B,
194
+ maxImageWidth: A && A.teacherInstructions || X,
195
+ maxImageHeight: j && j.teacherInstructions || Z,
196
196
  uploadSoundSupport: s,
197
197
  languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
198
- mathMlOptions: j
199
- }), q && /* @__PURE__ */ d(C, { children: q })]
198
+ mathMlOptions: M
199
+ }), J && /* @__PURE__ */ d(w, { children: J })]
200
200
  }),
201
- L && /* @__PURE__ */ f(x, {
201
+ R && /* @__PURE__ */ f(S, {
202
202
  label: u.label,
203
- children: [/* @__PURE__ */ d(S, {
203
+ children: [/* @__PURE__ */ d(C, {
204
204
  markup: i.prompt,
205
205
  onChange: (e) => this.handleChange("prompt", e),
206
206
  imageSupport: n,
207
207
  nonEmpty: !1,
208
208
  disableUnderline: !0,
209
- error: W,
209
+ error: G,
210
210
  toolbarOpts: Q,
211
- pluginProps: $(g?.inputConfiguration, c),
212
- spellCheck: z,
211
+ pluginProps: $(_?.inputConfiguration, c),
212
+ spellCheck: B,
213
213
  maxImageWidth: X,
214
214
  maxImageHeight: Z,
215
215
  uploadSoundSupport: s,
216
216
  languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
217
- mathMlOptions: j
218
- }), W && /* @__PURE__ */ d(C, { children: W })]
217
+ mathMlOptions: M
218
+ }), G && /* @__PURE__ */ d(w, { children: G })]
219
219
  }),
220
- /* @__PURE__ */ f(T, { children: [/* @__PURE__ */ d(w, {
220
+ /* @__PURE__ */ f(D, { children: [/* @__PURE__ */ d(E, {
221
221
  component: "div",
222
222
  children: "Response Template"
223
- }), /* @__PURE__ */ d(E, {
223
+ }), /* @__PURE__ */ d(oe, {
224
224
  disableFocusListener: !0,
225
225
  disableTouchListener: !0,
226
226
  placement: "right",
227
- title: Y,
228
- children: /* @__PURE__ */ d(ee, {
227
+ title: ue,
228
+ children: /* @__PURE__ */ d(g, {
229
229
  fontSize: "small",
230
230
  color: "primary"
231
231
  })
232
232
  })] }),
233
- /* @__PURE__ */ d(ae, {
234
- activePlugins: ne,
233
+ /* @__PURE__ */ d(re, {
234
+ activePlugins: b,
235
235
  toolbarOpts: { position: "top" },
236
- spellCheck: z,
237
- pluginProps: $(ce?.inputConfiguration, c),
236
+ spellCheck: B,
237
+ pluginProps: $(se?.inputConfiguration, c),
238
238
  responseAreaProps: {
239
239
  type: "math-templated",
240
240
  respAreaToolbar: null,
241
- error: () => J,
241
+ error: () => Y,
242
242
  onHandleAreaChange: this.onHandleAreaChange,
243
- maxResponseAreas: P
243
+ maxResponseAreas: F
244
244
  },
245
245
  markup: i.slateMarkup,
246
246
  onChange: this.onChange,
@@ -249,22 +249,22 @@ var { dropdown: y } = _, { Panel: re, toggle: b } = _, x = l(g)(({ theme: e }) =
249
249
  onBlur: this.onBlur,
250
250
  disabled: !1,
251
251
  highlightShape: !1,
252
- error: K,
252
+ error: q,
253
253
  uploadSoundSupport: s,
254
254
  languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
255
- mathMlOptions: j
255
+ mathMlOptions: M
256
256
  }),
257
- K && /* @__PURE__ */ d(ie, { children: K }),
258
- /* @__PURE__ */ d(w, { children: "Define Response" }),
259
- /* @__PURE__ */ d(oe, {
257
+ q && /* @__PURE__ */ d(T, { children: q }),
258
+ /* @__PURE__ */ d(E, { children: "Define Response" }),
259
+ /* @__PURE__ */ d(ie, {
260
260
  label: "Response Template Equation Editor",
261
- children: /* @__PURE__ */ f(se, {
261
+ children: /* @__PURE__ */ f(ae, {
262
262
  MenuProps: { transitionDuration: {
263
263
  enter: 225,
264
264
  exit: 195
265
265
  } },
266
266
  onChange: (e) => this.handleChange("equationEditor", e.target.value),
267
- value: U,
267
+ value: W,
268
268
  children: [
269
269
  /* @__PURE__ */ d(h, {
270
270
  value: "non-negative-integers",
@@ -317,44 +317,44 @@ var { dropdown: y } = _, { Panel: re, toggle: b } = _, x = l(g)(({ theme: e }) =
317
317
  ]
318
318
  })
319
319
  }),
320
- Object.keys(H || {}).map((t, n) => {
321
- let r = H[n];
320
+ Object.keys(U || {}).map((t, n) => {
321
+ let r = U[n];
322
322
  return r ? /* @__PURE__ */ d(e, {
323
323
  responseKey: n,
324
- mode: U,
324
+ mode: W,
325
325
  response: r,
326
326
  onResponseChange: this.onResponseChange,
327
327
  onResponseDone: this.onResponseDone,
328
328
  index: n,
329
- cIgnoreOrder: le,
330
- cAllowTrailingZeros: ue,
331
- error: J && J[n]
329
+ cIgnoreOrder: ce,
330
+ cAllowTrailingZeros: le,
331
+ error: Y && Y[n]
332
332
  }, n) : null;
333
333
  }),
334
- R && /* @__PURE__ */ f(x, {
334
+ z && /* @__PURE__ */ f(S, {
335
335
  label: p.label,
336
- children: [/* @__PURE__ */ d(S, {
336
+ children: [/* @__PURE__ */ d(C, {
337
337
  markup: i.rationale || "",
338
338
  onChange: (e) => this.handleChange("rationale", e),
339
339
  imageSupport: n,
340
340
  nonEmpty: !1,
341
- error: G,
341
+ error: K,
342
342
  toolbarOpts: Q,
343
343
  pluginProps: $(p?.inputConfiguration, {
344
344
  ...c,
345
345
  math: { controlledKeypadMode: !1 }
346
346
  }),
347
- spellCheck: z,
348
- maxImageWidth: k && k.rationale || X,
349
- maxImageHeight: A && A.rationale || Z,
347
+ spellCheck: B,
348
+ maxImageWidth: A && A.rationale || X,
349
+ maxImageHeight: j && j.rationale || Z,
350
350
  uploadSoundSupport: s,
351
351
  languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
352
- mathMlOptions: j
353
- }), G && /* @__PURE__ */ d(C, { children: G })]
352
+ mathMlOptions: M
353
+ }), K && /* @__PURE__ */ d(w, { children: K })]
354
354
  })
355
355
  ]
356
356
  });
357
357
  }
358
358
  };
359
359
  //#endregion
360
- export { O as default };
360
+ export { k as Design, k as default };
@@ -38,5 +38,6 @@ export default class MathTemplateConfigure extends HTMLElement {
38
38
  insertSound(handler: any): void;
39
39
  onDeleteSound(src: any, done: any): void;
40
40
  _render(): void;
41
+ connectedCallback(): void;
41
42
  disconnectedCallback(): void;
42
43
  }
@@ -1,5 +1,5 @@
1
1
  import { createSlateMarkup as e, processMarkup as t } from "./markupUtils.js";
2
- import n from "./design.js";
2
+ import { Design as n } from "./design.js";
3
3
  import r from "./defaults.js";
4
4
  import i from "react";
5
5
  import { createRoot as a } from "react-dom/client";
@@ -89,8 +89,11 @@ var m = c("math-templated:configure"), h = class c extends HTMLElement {
89
89
  });
90
90
  this._root ||= a(this), this._root.render(e);
91
91
  }
92
+ connectedCallback() {
93
+ this._render();
94
+ }
92
95
  disconnectedCallback() {
93
- this._root && this._root.unmount();
96
+ this._root &&= (this._root.unmount(), null);
94
97
  }
95
98
  };
96
99
  //#endregion
@@ -7,4 +7,4 @@ var e = "imes|riangle|an|heta|herefore", t = "throot|parallel|cong|approx|eq|e|s
7
7
  return t.querySelectorAll("[data-type=\"math_templated\"]").forEach((e) => e.replaceWith(`{{${e.dataset.index}}}`)), t.innerHTML;
8
8
  }, o = /\{\{(\d+)\}\}/g, s = (e, t) => e ? r(e).replace(o, (e, n) => `<span data-type="math_templated" data-index="${n}" data-value="${t[n]?.answer || ""}"></span>`) : "";
9
9
  //#endregion
10
- export { s as createSlateMarkup, a as processMarkup };
10
+ export { s as createSlateMarkup, a as processMarkup, r as removeUnwantedCharacters };
@@ -21,7 +21,7 @@ var y = n(d)(({ theme: e }) => ({
21
21
  marginBottom: e.spacing(2.5),
22
22
  width: "100%",
23
23
  minWidth: "548px",
24
- border: `1px solid ${e.palette.grey[700]}`,
24
+ border: `1px solid ${r.borderDark()}`,
25
25
  display: "flex",
26
26
  flexDirection: "column",
27
27
  justifyContent: "space-between"
@@ -36,20 +36,20 @@ var y = n(d)(({ theme: e }) => ({
36
36
  display: "flex",
37
37
  alignItems: "center",
38
38
  justifyContent: "space-between"
39
- }), T = n("div")({ display: "flex" }), E = n(p)(({ theme: e }) => ({
40
- border: `1px solid ${e.palette.grey.A400}`,
39
+ }), T = n("div")({ display: "flex" }), E = n(p)(() => ({
40
+ border: `1px solid ${r.border()}`,
41
41
  color: r.text()
42
42
  })), D = n(_)(({ theme: e }) => ({ marginLeft: e.spacing(1) })), O = n("div")(({ theme: e }) => ({
43
43
  fontSize: e.typography.fontSize - 2,
44
44
  color: e.palette.error.main,
45
45
  paddingTop: e.spacing(1)
46
- })), k = n("div")(({ theme: e }) => ({
47
- background: e.palette.grey.A100,
48
- color: e.palette.grey.A700,
46
+ })), k = n("div")(() => ({
47
+ background: r.backgroundDark(),
48
+ color: r.text(),
49
49
  display: "inline",
50
50
  minWidth: "50px",
51
51
  padding: "8px",
52
- border: "1px solid #C0C3CF"
52
+ border: `1px solid ${r.border()}`
53
53
  })), A = n("div")({
54
54
  display: "flex",
55
55
  justifyContent: "space-between",
@@ -235,4 +235,4 @@ var M = class extends e.Component {
235
235
  }
236
236
  };
237
237
  //#endregion
238
- export { M as default };
238
+ export { M as Response, M as default };