@pie-element/math-inline 12.1.1-next.147 → 12.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.
Files changed (101) hide show
  1. package/configure.js +2 -0
  2. package/controller.js +1 -0
  3. package/dist/author/configure.d.ts +25 -0
  4. package/dist/author/configure.js +114 -0
  5. package/dist/author/defaults.d.ts +186 -0
  6. package/dist/author/defaults.js +145 -0
  7. package/dist/author/general-config-block.d.ts +35 -0
  8. package/dist/author/general-config-block.js +390 -0
  9. package/dist/author/index.d.ts +61 -0
  10. package/dist/author/index.js +80 -0
  11. package/dist/author/response.d.ts +40 -0
  12. package/dist/author/response.js +238 -0
  13. package/dist/author/utils.d.ts +14 -0
  14. package/dist/author/utils.js +13 -0
  15. package/dist/browser/author/index.js +35601 -0
  16. package/dist/browser/author/index.js.map +1 -0
  17. package/dist/browser/controller/index.js +37791 -0
  18. package/dist/browser/controller/index.js.map +1 -0
  19. package/dist/browser/delivery/index.js +84 -0
  20. package/dist/browser/delivery/index.js.map +1 -0
  21. package/dist/browser/dist--pvq7WNe.js +324 -0
  22. package/dist/browser/dist--pvq7WNe.js.map +1 -0
  23. package/dist/browser/dist-D8taXDhz.js +16748 -0
  24. package/dist/browser/dist-D8taXDhz.js.map +1 -0
  25. package/dist/browser/dist-DiGNNRzu.js +1426 -0
  26. package/dist/browser/dist-DiGNNRzu.js.map +1 -0
  27. package/dist/browser/main-AjqUtC75.js +973 -0
  28. package/dist/browser/main-AjqUtC75.js.map +1 -0
  29. package/dist/browser/math-inline.css +2 -0
  30. package/dist/browser/print/index.js +50 -0
  31. package/dist/browser/print/index.js.map +1 -0
  32. package/dist/controller/defaults.d.ts +44 -0
  33. package/dist/controller/defaults.js +39 -0
  34. package/dist/controller/index.d.ts +22 -0
  35. package/dist/controller/index.js +171 -0
  36. package/dist/controller/utils.d.ts +12 -0
  37. package/dist/controller/utils.js +7 -0
  38. package/dist/delivery/index.d.ts +22 -0
  39. package/dist/delivery/index.js +55 -0
  40. package/dist/delivery/main.d.ts +44 -0
  41. package/dist/delivery/main.js +606 -0
  42. package/dist/delivery/simple-question-block.d.ts +27 -0
  43. package/dist/delivery/simple-question-block.js +94 -0
  44. package/dist/delivery/utils.d.ts +12 -0
  45. package/dist/delivery/utils.js +7 -0
  46. package/dist/index.d.ts +1 -0
  47. package/dist/index.iife.d.ts +8 -0
  48. package/dist/index.iife.js +224 -0
  49. package/dist/index.js +2 -0
  50. package/dist/math-inline.css +2 -0
  51. package/dist/print/index.d.ts +15 -0
  52. package/dist/print/index.js +50 -0
  53. package/dist/runtime-support.d.ts +12 -0
  54. package/dist/runtime-support.js +12 -0
  55. package/package.json +98 -25
  56. package/CHANGELOG.json +0 -2627
  57. package/CHANGELOG.md +0 -2473
  58. package/LICENSE.md +0 -5
  59. package/README.md +0 -3
  60. package/configure/CHANGELOG.json +0 -1652
  61. package/configure/CHANGELOG.md +0 -2101
  62. package/configure/lib/configure.js +0 -186
  63. package/configure/lib/configure.js.map +0 -1
  64. package/configure/lib/defaults.js +0 -185
  65. package/configure/lib/defaults.js.map +0 -1
  66. package/configure/lib/general-config-block.js +0 -525
  67. package/configure/lib/general-config-block.js.map +0 -1
  68. package/configure/lib/index.js +0 -140
  69. package/configure/lib/index.js.map +0 -1
  70. package/configure/lib/response.js +0 -369
  71. package/configure/lib/response.js.map +0 -1
  72. package/configure/lib/utils.js +0 -31
  73. package/configure/lib/utils.js.map +0 -1
  74. package/configure/package.json +0 -29
  75. package/controller/CHANGELOG.json +0 -1002
  76. package/controller/CHANGELOG.md +0 -1536
  77. package/controller/lib/defaults.js +0 -43
  78. package/controller/lib/defaults.js.map +0 -1
  79. package/controller/lib/index.js +0 -383
  80. package/controller/lib/index.js.map +0 -1
  81. package/controller/lib/utils.js +0 -11
  82. package/controller/lib/utils.js.map +0 -1
  83. package/controller/package.json +0 -26
  84. package/docs/config-schema.json +0 -2071
  85. package/docs/config-schema.json.md +0 -1533
  86. package/docs/demo/config.js +0 -8
  87. package/docs/demo/generate.js +0 -41
  88. package/docs/demo/index.html +0 -1
  89. package/docs/demo/session.js +0 -11
  90. package/docs/pie-schema.json +0 -1472
  91. package/docs/pie-schema.json.md +0 -845
  92. package/lib/index.js +0 -94
  93. package/lib/index.js.map +0 -1
  94. package/lib/main.js +0 -1030
  95. package/lib/main.js.map +0 -1
  96. package/lib/print.js +0 -92
  97. package/lib/print.js.map +0 -1
  98. package/lib/simple-question-block.js +0 -148
  99. package/lib/simple-question-block.js.map +0 -1
  100. package/lib/utils.js +0 -11
  101. package/lib/utils.js.map +0 -1
@@ -0,0 +1,390 @@
1
+ import e from "./response.js";
2
+ import { ResponseTypes as t, generateValidationMessage as n, getPluginProps as r } from "./utils.js";
3
+ import * as i from "react";
4
+ import { isEqual as a } from "@pie-element/shared-lodash";
5
+ import o from "prop-types";
6
+ import { applyStaticMath as s, registerEmbed as c } from "@pie-lib/math-input";
7
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
8
+ import { styled as d } from "@mui/material/styles";
9
+ import f from "@mui/material/Tooltip";
10
+ import { MathToolbar as p } from "@pie-lib/math-toolbar";
11
+ import { InputContainer as m } from "@pie-lib/config-ui";
12
+ import h from "@pie-lib/editable-html-tip-tap";
13
+ import g from "@mui/material/InputLabel";
14
+ import _ from "@mui/material/Select";
15
+ import v from "@mui/material/MenuItem";
16
+ import y from "@mui/icons-material/Info";
17
+ //#region src/author/general-config-block.tsx
18
+ var b = !1, x = d("div")({
19
+ display: "flex",
20
+ flexDirection: "column"
21
+ }), S = d(g)({ fontSize: "0.85rem" }), C = d("div")({ fontSize: "1.1rem" }), w = d("div")({
22
+ display: "flex",
23
+ alignItems: "center",
24
+ justifyContent: "space-between"
25
+ }), T = d(m)(({ theme: e }) => ({
26
+ flex: "initial",
27
+ width: "40%",
28
+ marginTop: e.spacing(2),
29
+ marginBottom: e.spacing(2),
30
+ "& > *:not(label)": { marginTop: e.spacing(1) }
31
+ })), ee = d("div")({
32
+ display: "flex",
33
+ flexDirection: "column",
34
+ ".block-container": {
35
+ margin: "8px",
36
+ display: "inline-flex",
37
+ border: "2px solid grey",
38
+ ".mq-cursor": { visibility: "hidden" }
39
+ },
40
+ ".block-container-generic": { margin: "4px" },
41
+ ".block-response": {
42
+ flex: 2,
43
+ color: "grey",
44
+ background: "#f5f5f5",
45
+ fontSize: "0.8rem",
46
+ padding: "4px",
47
+ display: "flex",
48
+ alignItems: "center",
49
+ justifyContent: "center",
50
+ borderRight: "2px solid grey"
51
+ },
52
+ ".block-response-generic": { borderRight: 0 },
53
+ ".response-editor ": {
54
+ display: "flex",
55
+ alignItems: "center",
56
+ justifyContent: "center",
57
+ width: "100%",
58
+ maxWidth: "900px",
59
+ height: "auto",
60
+ minHeight: "130px",
61
+ textAlign: "left",
62
+ padding: "8px"
63
+ },
64
+ ".math-toolbar": { maxWidth: "900px" }
65
+ }), E = d(f)(({ theme: e }) => ({ "& .MuiTooltip-tooltip": {
66
+ fontSize: e.typography.fontSize - 2,
67
+ whiteSpace: "pre-wrap"
68
+ } })), D = d("div")(({ theme: e }) => ({
69
+ fontSize: e.typography.fontSize - 2,
70
+ color: e.palette.error.main,
71
+ paddingTop: e.spacing(1)
72
+ })), O = d(m)(({ theme: e }) => ({
73
+ width: "100%",
74
+ paddingTop: e.spacing(2),
75
+ marginBottom: e.spacing(2)
76
+ })), k = d("div")(({ theme: e }) => ({ marginBottom: e.spacing(2.5) })), A = /{{response}}/gm, j = /\\%response\\%/gm, M = /\\embed\{answerBlock\}\[r\d*\]/g, N = /\\embed\{newLine\}\[\]/g, P = /\\newline/g;
77
+ function F(e) {
78
+ if (e) {
79
+ let t = 1;
80
+ return e.replace(A, () => `\\embed{answerBlock}[r${t++}]`).replace(P, "\\embed{newLine}[]");
81
+ }
82
+ }
83
+ function I(e) {
84
+ if (e) return e.replace(M, () => "{{response}}").replace(j, () => "{{response}}").replace(N, () => "\\newline");
85
+ }
86
+ var L = class extends i.Component {
87
+ static propTypes = {
88
+ model: o.object.isRequired,
89
+ imageSupport: o.object,
90
+ uploadSoundSupport: o.object,
91
+ configuration: o.object,
92
+ onChange: o.func.isRequired,
93
+ promptEnabled: o.bool,
94
+ rationaleEnabled: o.bool,
95
+ toolbarOpts: o.object
96
+ };
97
+ constructor(e) {
98
+ super(e);
99
+ let t = {};
100
+ if (e.model && e.model.expression) {
101
+ let n = 1;
102
+ e.model.expression.replace(A, () => {
103
+ t[`r${n++}`] = { value: "" };
104
+ });
105
+ }
106
+ this.state = {
107
+ showKeypad: !1,
108
+ responseAreas: t,
109
+ responseIdCounter: Object.keys(t).length
110
+ };
111
+ }
112
+ onChange = (e) => (t) => {
113
+ let { model: n, onChange: r } = this.props, i = { ...n };
114
+ typeof t == "object" ? i[e] = t.target.value : i[e] = t, e === "expression" && (i[e] = I(t)), r(i);
115
+ };
116
+ onDone = () => {
117
+ this.setState({ showKeypad: !1 });
118
+ };
119
+ onFocus = () => {
120
+ this.setState({ showKeypad: !0 });
121
+ };
122
+ onPromptFocus = () => {
123
+ this.setState({ showKeypad: !1 });
124
+ };
125
+ UNSAFE_componentWillMount() {
126
+ typeof window < "u" && (b ||= (c("answerBlock", (e) => ({
127
+ htmlString: `
128
+ <div class="block-container block-container-generic">
129
+ <div class="block-response block-response-generic" id="${e}Index">Response</div>
130
+ </div>`,
131
+ text: () => "text",
132
+ latex: () => `\\embed{answerBlock}[${e}]`
133
+ })), !0));
134
+ }
135
+ componentDidMount() {
136
+ this.handleAnswerBlockDomUpdate();
137
+ }
138
+ componentDidUpdate() {
139
+ this.handleAnswerBlockDomUpdate();
140
+ }
141
+ handleAnswerBlockDomUpdate = () => {
142
+ let { model: e } = this.props, t = {};
143
+ if (e && e.expression) {
144
+ let n = 1;
145
+ e.expression.replace(A, () => {
146
+ t[`r${n++}`] = { value: "" };
147
+ });
148
+ }
149
+ a(t, this.state.responseAreas) || this.setState({ responseAreas: t }, () => {
150
+ this.root && Object.keys(t).length && Object.keys(t).forEach((e, t) => {
151
+ let n = this.root.querySelector(`#${e}`), r = this.root.querySelector(`#${e}Index`);
152
+ n && (s(n), r.textContent = `R${t + 1}`);
153
+ });
154
+ });
155
+ };
156
+ onAddResponse = () => {
157
+ let { model: e, onChange: t } = this.props, { responseIdCounter: n } = this.state, r = { ...e }, i = n;
158
+ for (; e.responses.find((e) => e.id === i);) i++;
159
+ let a = {
160
+ id: i,
161
+ validation: "literal",
162
+ answer: "",
163
+ alternates: {}
164
+ };
165
+ r.responses = r.responses.concat(a), t(r), this.setState({ responseIdCounter: a.id });
166
+ };
167
+ onResponseChange = (e, t) => {
168
+ let { model: n, onChange: r } = this.props, i = { ...n };
169
+ i.responses[t] = e, r(i);
170
+ };
171
+ render() {
172
+ let { model: i, imageSupport: a, uploadSoundSupport: o, configuration: s, promptEnabled: c, rationaleEnabled: d, toolbarOpts: f } = this.props, { showKeypad: m } = this.state, { prompt: g, expression: b, equationEditor: A, promptEquationEditor: j = "8", responses: M, responseType: N, rationale: P, spellCheckEnabled: I, errors: L = {} } = i, { baseInputConfiguration: R = {}, rationale: z = {}, prompt: B = {}, ignoreOrder: V = {}, allowTrailingZeros: H = {}, maxResponseAreas: U, maxImageWidth: W = {}, maxImageHeight: G = {}, mathMlOptions: K = {} } = s || {}, te = n(s, i), { prompt: q, rationale: J, responsesErrors: Y, responseAreasError: X } = L, Z = W && W.prompt, Q = G && G.prompt, ne = {
173
+ editor: "response-editor",
174
+ mathToolbar: "math-toolbar"
175
+ }, re = N === t.advanced ? M : M.slice(0, 1), $ = /* @__PURE__ */ l(E, {
176
+ disableFocusListener: !0,
177
+ disableTouchListener: !0,
178
+ placement: "right",
179
+ title: te,
180
+ children: /* @__PURE__ */ l(y, {
181
+ fontSize: "small",
182
+ color: "primary",
183
+ style: { marginLeft: "5px" }
184
+ })
185
+ });
186
+ return /* @__PURE__ */ u(x, {
187
+ ref: (e) => this.root = e || this.root,
188
+ children: [
189
+ c && /* @__PURE__ */ u(O, {
190
+ label: B.label,
191
+ children: [/* @__PURE__ */ l(h, {
192
+ onFocus: this.onPromptFocus,
193
+ markup: g || "",
194
+ onChange: this.onChange("prompt"),
195
+ imageSupport: a,
196
+ nonEmpty: !1,
197
+ error: q,
198
+ toolbarOpts: f,
199
+ pluginProps: r(B?.inputConfiguration, R),
200
+ spellCheck: I,
201
+ maxImageWidth: Z,
202
+ maxImageHeight: Q,
203
+ uploadSoundSupport: o,
204
+ languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
205
+ mathMlOptions: K
206
+ }), q && /* @__PURE__ */ l(D, { children: q })]
207
+ }),
208
+ N === t.advanced && /* @__PURE__ */ u(k, { children: [
209
+ /* @__PURE__ */ u(w, {
210
+ style: { justifyContent: "flex-start" },
211
+ children: [/* @__PURE__ */ l(C, { children: "Define Response" }), $]
212
+ }),
213
+ /* @__PURE__ */ l(T, {
214
+ label: "Response Template Equation Editor",
215
+ children: /* @__PURE__ */ u(_, {
216
+ onChange: this.onChange("promptEquationEditor"),
217
+ value: j,
218
+ MenuProps: { transitionDuration: {
219
+ enter: 225,
220
+ exit: 195
221
+ } },
222
+ children: [
223
+ /* @__PURE__ */ l(v, {
224
+ value: "non-negative-integers",
225
+ children: "Numeric - Non-Negative Integers"
226
+ }),
227
+ /* @__PURE__ */ l(v, {
228
+ value: "integers",
229
+ children: "Numeric - Integers"
230
+ }),
231
+ /* @__PURE__ */ l(v, {
232
+ value: "decimals",
233
+ children: "Numeric - Decimals"
234
+ }),
235
+ /* @__PURE__ */ l(v, {
236
+ value: "fractions",
237
+ children: "Numeric - Fractions"
238
+ }),
239
+ /* @__PURE__ */ l(v, {
240
+ value: 1,
241
+ children: "Grade 1 - 2"
242
+ }),
243
+ /* @__PURE__ */ l(v, {
244
+ value: 3,
245
+ children: "Grade 3 - 5"
246
+ }),
247
+ /* @__PURE__ */ l(v, {
248
+ value: 6,
249
+ children: "Grade 6 - 7"
250
+ }),
251
+ /* @__PURE__ */ l(v, {
252
+ value: 8,
253
+ children: "Grade 8 - HS"
254
+ }),
255
+ /* @__PURE__ */ l(v, {
256
+ value: "geometry",
257
+ children: "Geometry"
258
+ }),
259
+ /* @__PURE__ */ l(v, {
260
+ value: "advanced-algebra",
261
+ children: "Advanced Algebra"
262
+ }),
263
+ /* @__PURE__ */ l(v, {
264
+ value: "statistics",
265
+ children: "Statistics"
266
+ }),
267
+ /* @__PURE__ */ l(v, {
268
+ value: "item-authoring",
269
+ children: "Item Authoring"
270
+ })
271
+ ]
272
+ })
273
+ }, "templateEditorType"),
274
+ /* @__PURE__ */ u(ee, { children: [/* @__PURE__ */ l(S, { children: "RESPONSE TEMPLATE" }), /* @__PURE__ */ l(p, {
275
+ classNames: ne,
276
+ allowAnswerBlock: !0,
277
+ keypadMode: j,
278
+ controlledKeypad: !0,
279
+ showKeypad: m,
280
+ latex: F(b) || "",
281
+ onChange: this.onChange("expression"),
282
+ onFocus: this.onFocus,
283
+ onDone: this.onDone,
284
+ maxResponseAreas: U,
285
+ error: X
286
+ })] }, "templateHolder"),
287
+ X && /* @__PURE__ */ l(D, { children: X })
288
+ ] }),
289
+ /* @__PURE__ */ u(w, {
290
+ style: { justifyContent: "flex-start" },
291
+ children: [/* @__PURE__ */ l(C, { children: "Define Correct Response" }), N === t.simple ? $ : null]
292
+ }),
293
+ /* @__PURE__ */ l(T, {
294
+ label: "Equation Editor",
295
+ children: /* @__PURE__ */ u(_, {
296
+ onChange: this.onChange("equationEditor"),
297
+ value: A,
298
+ MenuProps: { transitionDuration: {
299
+ enter: 225,
300
+ exit: 195
301
+ } },
302
+ children: [
303
+ /* @__PURE__ */ l(v, {
304
+ value: "non-negative-integers",
305
+ children: "Numeric - Non-Negative Integers"
306
+ }),
307
+ /* @__PURE__ */ l(v, {
308
+ value: "integers",
309
+ children: "Numeric - Integers"
310
+ }),
311
+ /* @__PURE__ */ l(v, {
312
+ value: "decimals",
313
+ children: "Numeric - Decimals"
314
+ }),
315
+ /* @__PURE__ */ l(v, {
316
+ value: "fractions",
317
+ children: "Numeric - Fractions"
318
+ }),
319
+ /* @__PURE__ */ l(v, {
320
+ value: 1,
321
+ children: "Grade 1 - 2"
322
+ }),
323
+ /* @__PURE__ */ l(v, {
324
+ value: 3,
325
+ children: "Grade 3 - 5"
326
+ }),
327
+ /* @__PURE__ */ l(v, {
328
+ value: 6,
329
+ children: "Grade 6 - 7"
330
+ }),
331
+ /* @__PURE__ */ l(v, {
332
+ value: 8,
333
+ children: "Grade 8 - HS"
334
+ }),
335
+ /* @__PURE__ */ l(v, {
336
+ value: "geometry",
337
+ children: "Geometry"
338
+ }),
339
+ /* @__PURE__ */ l(v, {
340
+ value: "advanced-algebra",
341
+ children: "Advanced Algebra"
342
+ }),
343
+ /* @__PURE__ */ l(v, {
344
+ value: "statistics",
345
+ children: "Statistics"
346
+ }),
347
+ /* @__PURE__ */ l(v, {
348
+ value: "item-authoring",
349
+ children: "Item Authoring"
350
+ })
351
+ ]
352
+ })
353
+ }),
354
+ re.map((n, r) => /* @__PURE__ */ l(e, {
355
+ mode: A,
356
+ response: n,
357
+ defaultResponse: N === t.simple,
358
+ onResponseChange: this.onResponseChange,
359
+ index: r,
360
+ cIgnoreOrder: V,
361
+ cAllowTrailingZeros: H,
362
+ error: Y && Y[r]
363
+ }, n.id)),
364
+ d && /* @__PURE__ */ u(O, {
365
+ label: z.label,
366
+ children: [/* @__PURE__ */ l(h, {
367
+ markup: P || "",
368
+ onChange: this.onChange("rationale"),
369
+ imageSupport: a,
370
+ nonEmpty: !1,
371
+ error: J,
372
+ toolbarOpts: f,
373
+ pluginProps: r(z?.inputConfiguration, {
374
+ ...R,
375
+ math: { controlledKeypadMode: !1 }
376
+ }),
377
+ spellCheck: I,
378
+ maxImageWidth: W && W.rationale || Z,
379
+ maxImageHeight: G && G.rationale || Q,
380
+ uploadSoundSupport: o,
381
+ languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
382
+ mathMlOptions: K
383
+ }), J && /* @__PURE__ */ l(D, { children: J })]
384
+ })
385
+ ]
386
+ });
387
+ }
388
+ };
389
+ //#endregion
390
+ export { L as default };
@@ -0,0 +1,61 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/math-inline/configure/src/index.js
3
+ * @auto-generated
4
+ *
5
+ * This file is automatically synced from pie-elements and converted to TypeScript.
6
+ * Manual edits will be overwritten on next sync.
7
+ * To make changes, edit the upstream JavaScript file and run sync again.
8
+ */
9
+ export default class MathInlineConfigure extends HTMLElement {
10
+ static createDefaultModel: (model?: {}) => {
11
+ allowTrailingZerosDefault: boolean;
12
+ customKeys: never[];
13
+ equationEditor: string;
14
+ expression: string;
15
+ feedback: {
16
+ correct: {
17
+ default: string;
18
+ type: string;
19
+ };
20
+ incorrect: {
21
+ default: string;
22
+ type: string;
23
+ };
24
+ partial: {
25
+ default: string;
26
+ type: string;
27
+ };
28
+ };
29
+ feedbackEnabled: boolean;
30
+ ignoreOrderDefault: boolean;
31
+ partialScoring: boolean;
32
+ prompt: string;
33
+ promptEnabled: boolean;
34
+ rationale: string;
35
+ rationaleEnabled: boolean;
36
+ responseType: string;
37
+ responses: never[];
38
+ scoringType: string;
39
+ studentInstructionsEnabled: boolean;
40
+ teacherInstructions: string;
41
+ teacherInstructionsEnabled: boolean;
42
+ toolbarEditorPosition: string;
43
+ validationDefault: string;
44
+ };
45
+ constructor();
46
+ set model(m: any);
47
+ set configuration(c: any);
48
+ onModelChanged(model: any): void;
49
+ onConfigurationChanged(c: any): void;
50
+ /**
51
+ *
52
+ * @param {done, progress, file} handler
53
+ */
54
+ insertImage(handler: any): void;
55
+ onDeleteImage(src: any, done: any): void;
56
+ insertSound(handler: any): void;
57
+ onDeleteSound(src: any, done: any): void;
58
+ _render(): void;
59
+ connectedCallback(): void;
60
+ disconnectedCallback(): void;
61
+ }
@@ -0,0 +1,80 @@
1
+ import { Configure as e } from "./configure.js";
2
+ import t from "./defaults.js";
3
+ import n from "react";
4
+ import { createRoot as r } from "react-dom/client";
5
+ import i from "debug";
6
+ import { isEmpty as a } from "@pie-element/shared-lodash";
7
+ import { DeleteImageEvent as o, DeleteSoundEvent as s, InsertImageEvent as c, InsertSoundEvent as l, ModelUpdatedEvent as u } from "@pie-element/shared-configure-events";
8
+ //#region src/author/index.ts
9
+ var d = i("pie-elements:math-inline:configure"), f = class i extends HTMLElement {
10
+ static createDefaultModel = (e = {}) => (a(e.responses) || (e.responses = e.responses.map((e) => ({
11
+ ...e,
12
+ validation: e.validation || t.model.validationDefault,
13
+ allowTrailingZeros: e.allowTrailingZeros || t.model.allowTrailingZerosDefault,
14
+ ignoreOrder: e.ignoreOrder || t.model.ignoreOrderDefault || !1
15
+ }))), {
16
+ ...t.model,
17
+ ...e
18
+ });
19
+ constructor() {
20
+ super(), this._root = null, this._model = i.createDefaultModel(), this._configuration = t.configuration;
21
+ }
22
+ set model(e) {
23
+ this._model = i.createDefaultModel(e), this._render();
24
+ }
25
+ set configuration(e) {
26
+ let n = {
27
+ ...t.configuration,
28
+ ...e
29
+ };
30
+ this._configuration = n, n?.language?.enabled ? n?.languageChoices?.options?.length && (this._model.language = n?.languageChoices.options[0].value) : n.language.settings && this._model.language ? (this._configuration.language.enabled = !0, (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) && (this._configuration.languageChoices.options = []), this._configuration.languageChoices.options.find((e) => e.value === this._model.language) || this._configuration.languageChoices.options.push({
31
+ value: this._model.language,
32
+ label: this._model.language
33
+ })) : delete this._model.language, this._render();
34
+ }
35
+ onModelChanged(e) {
36
+ this._model = e, d("[onModelChanged]: ", this._model), this._render(), this.dispatchEvent(new u(this._model));
37
+ }
38
+ onConfigurationChanged(e) {
39
+ this._configuration = e, this._model && this.onModelChanged(this._model), this._render();
40
+ }
41
+ insertImage(e) {
42
+ this.dispatchEvent(new c(e));
43
+ }
44
+ onDeleteImage(e, t) {
45
+ this.dispatchEvent(new o(e, t));
46
+ }
47
+ insertSound(e) {
48
+ this.dispatchEvent(new l(e));
49
+ }
50
+ onDeleteSound(e, t) {
51
+ this.dispatchEvent(new s(e, t));
52
+ }
53
+ _render() {
54
+ if (this._model) {
55
+ let t = n.createElement(e, {
56
+ onModelChanged: this.onModelChanged.bind(this),
57
+ onConfigurationChanged: this.onConfigurationChanged.bind(this),
58
+ model: this._model,
59
+ configuration: this._configuration,
60
+ imageSupport: {
61
+ add: this.insertImage.bind(this),
62
+ delete: this.onDeleteImage.bind(this)
63
+ },
64
+ uploadSoundSupport: {
65
+ add: this.insertSound.bind(this),
66
+ delete: this.onDeleteSound.bind(this)
67
+ }
68
+ });
69
+ this._root ||= r(this), this._root.render(t);
70
+ }
71
+ }
72
+ connectedCallback() {
73
+ this._render();
74
+ }
75
+ disconnectedCallback() {
76
+ this._root &&= (this._root.unmount(), null);
77
+ }
78
+ };
79
+ //#endregion
80
+ export { f as default };
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/math-inline/configure/src/response.jsx
3
+ * @auto-generated
4
+ *
5
+ * This file is automatically synced from pie-elements and converted to TypeScript.
6
+ * Manual edits will be overwritten on next sync.
7
+ * To make changes, edit the upstream JavaScript file and run sync again.
8
+ */
9
+ import * as React from 'react';
10
+ import PropTypes from 'prop-types';
11
+ declare class Response extends React.Component {
12
+ static propTypes: {
13
+ defaultResponse: PropTypes.Requireable<boolean>;
14
+ error: PropTypes.Requireable<object>;
15
+ mode: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
16
+ index: PropTypes.Requireable<number>;
17
+ onResponseChange: PropTypes.Validator<(...args: any[]) => any>;
18
+ response: PropTypes.Validator<object>;
19
+ cIgnoreOrder: PropTypes.Validator<object>;
20
+ cAllowTrailingZeros: PropTypes.Validator<object>;
21
+ };
22
+ static defaultProps: {
23
+ defaultResponse: boolean;
24
+ mode: string;
25
+ };
26
+ constructor(props: any);
27
+ onChange: (name: any) => (evt: any) => void;
28
+ onConfigChanged: (name: any) => (evt: any) => void;
29
+ onLiteralOptionsChange: (name: any) => () => void;
30
+ onAnswerChange: any;
31
+ onAlternateAnswerChange: (alternateId: any) => (answer: any) => void;
32
+ onAddAlternate: any;
33
+ onRemoveAlternate: (alternateId: any) => () => void;
34
+ onDone: any;
35
+ onFocus: any;
36
+ onAlternateFocus: (alternateId: any) => () => void;
37
+ onAlternateDone: (alternateId: any) => () => void;
38
+ render(): React.JSX.Element;
39
+ }
40
+ export default Response;