@pie-element/math-inline 12.1.1-next.21 → 12.1.1-next.22
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/author/general-config-block.js +71 -71
- package/dist/browser/delivery/index.js +66 -16
- package/dist/browser/delivery/index.js.map +1 -1
- package/dist/delivery/index.js +9 -10
- package/dist/delivery/main.js +125 -125
- package/dist/index.iife.js +44 -44
- package/dist/print/index.js +6 -6
- package/package.json +2 -2
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import e from "./response.js";
|
|
2
2
|
import { ResponseTypes as t, generateValidationMessage as n, getPluginProps as r } from "./utils.js";
|
|
3
3
|
import * as i from "react";
|
|
4
|
-
import
|
|
5
|
-
import o from "
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import f from "@
|
|
4
|
+
import a from "prop-types";
|
|
5
|
+
import { applyStaticMath as o, registerEmbed as s } from "@pie-lib/math-input";
|
|
6
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
7
|
+
import { styled as u } from "@mui/material/styles";
|
|
8
|
+
import d from "@mui/material/Tooltip";
|
|
9
|
+
import { isEqual as f } from "@pie-element/shared-lodash";
|
|
10
10
|
import { MathToolbar as p } from "@pie-lib/math-toolbar";
|
|
11
11
|
import { InputContainer as m } from "@pie-lib/config-ui";
|
|
12
12
|
import h from "@pie-lib/editable-html-tip-tap";
|
|
@@ -15,20 +15,20 @@ import _ from "@mui/material/Select";
|
|
|
15
15
|
import v from "@mui/material/MenuItem";
|
|
16
16
|
import y from "@mui/icons-material/Info";
|
|
17
17
|
//#region src/author/general-config-block.tsx
|
|
18
|
-
var b = !1, x =
|
|
18
|
+
var b = !1, x = u("div")({
|
|
19
19
|
display: "flex",
|
|
20
20
|
flexDirection: "column"
|
|
21
|
-
}), S =
|
|
21
|
+
}), S = u(g)({ fontSize: "0.85rem" }), C = u("div")({ fontSize: "1.1rem" }), w = u("div")({
|
|
22
22
|
display: "flex",
|
|
23
23
|
alignItems: "center",
|
|
24
24
|
justifyContent: "space-between"
|
|
25
|
-
}), T =
|
|
25
|
+
}), T = u(m)(({ theme: e }) => ({
|
|
26
26
|
flex: "initial",
|
|
27
27
|
width: "40%",
|
|
28
28
|
marginTop: e.spacing(2),
|
|
29
29
|
marginBottom: e.spacing(2),
|
|
30
30
|
"& > *:not(label)": { marginTop: e.spacing(1) }
|
|
31
|
-
})), ee =
|
|
31
|
+
})), ee = u("div")({
|
|
32
32
|
display: "flex",
|
|
33
33
|
flexDirection: "column",
|
|
34
34
|
".block-container": {
|
|
@@ -62,18 +62,18 @@ var b = !1, x = d("div")({
|
|
|
62
62
|
padding: "8px"
|
|
63
63
|
},
|
|
64
64
|
".math-toolbar": { maxWidth: "900px" }
|
|
65
|
-
}), E = d
|
|
65
|
+
}), E = u(d)(({ theme: e }) => ({ "& .MuiTooltip-tooltip": {
|
|
66
66
|
fontSize: e.typography.fontSize - 2,
|
|
67
67
|
whiteSpace: "pre-wrap"
|
|
68
|
-
} })), D =
|
|
68
|
+
} })), D = u("div")(({ theme: e }) => ({
|
|
69
69
|
fontSize: e.typography.fontSize - 2,
|
|
70
70
|
color: e.palette.error.main,
|
|
71
71
|
paddingTop: e.spacing(1)
|
|
72
|
-
})), O =
|
|
72
|
+
})), O = u(m)(({ theme: e }) => ({
|
|
73
73
|
width: "100%",
|
|
74
74
|
paddingTop: e.spacing(2),
|
|
75
75
|
marginBottom: e.spacing(2)
|
|
76
|
-
})), k =
|
|
76
|
+
})), k = u("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
77
|
function F(e) {
|
|
78
78
|
if (e) {
|
|
79
79
|
let t = 1;
|
|
@@ -85,14 +85,14 @@ function I(e) {
|
|
|
85
85
|
}
|
|
86
86
|
var L = class extends i.Component {
|
|
87
87
|
static propTypes = {
|
|
88
|
-
model:
|
|
89
|
-
imageSupport:
|
|
90
|
-
uploadSoundSupport:
|
|
91
|
-
configuration:
|
|
92
|
-
onChange:
|
|
93
|
-
promptEnabled:
|
|
94
|
-
rationaleEnabled:
|
|
95
|
-
toolbarOpts:
|
|
88
|
+
model: a.object.isRequired,
|
|
89
|
+
imageSupport: a.object,
|
|
90
|
+
uploadSoundSupport: a.object,
|
|
91
|
+
configuration: a.object,
|
|
92
|
+
onChange: a.func.isRequired,
|
|
93
|
+
promptEnabled: a.bool,
|
|
94
|
+
rationaleEnabled: a.bool,
|
|
95
|
+
toolbarOpts: a.object
|
|
96
96
|
};
|
|
97
97
|
constructor(e) {
|
|
98
98
|
super(e);
|
|
@@ -123,7 +123,7 @@ var L = class extends i.Component {
|
|
|
123
123
|
this.setState({ showKeypad: !1 });
|
|
124
124
|
};
|
|
125
125
|
UNSAFE_componentWillMount() {
|
|
126
|
-
typeof window < "u" && (b ||= (
|
|
126
|
+
typeof window < "u" && (b ||= (s("answerBlock", (e) => ({
|
|
127
127
|
htmlString: `
|
|
128
128
|
<div class="block-container block-container-generic">
|
|
129
129
|
<div class="block-response block-response-generic" id="${e}Index">Response</div>
|
|
@@ -146,10 +146,10 @@ var L = class extends i.Component {
|
|
|
146
146
|
t[`r${n++}`] = { value: "" };
|
|
147
147
|
});
|
|
148
148
|
}
|
|
149
|
-
|
|
149
|
+
f(t, this.state.responseAreas) || this.setState({ responseAreas: t }, () => {
|
|
150
150
|
this.root && Object.keys(t).length && Object.keys(t).forEach((e, t) => {
|
|
151
151
|
let n = this.root.querySelector(`#${e}`), r = this.root.querySelector(`#${e}Index`);
|
|
152
|
-
n && (
|
|
152
|
+
n && (o(n), r.textContent = `R${t + 1}`);
|
|
153
153
|
});
|
|
154
154
|
});
|
|
155
155
|
};
|
|
@@ -169,26 +169,26 @@ var L = class extends i.Component {
|
|
|
169
169
|
i.responses[t] = e, r(i);
|
|
170
170
|
};
|
|
171
171
|
render() {
|
|
172
|
-
let { model: i, imageSupport: a, uploadSoundSupport: o, configuration: s, promptEnabled:
|
|
172
|
+
let { model: i, imageSupport: a, uploadSoundSupport: o, configuration: s, promptEnabled: u, 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
173
|
editor: "response-editor",
|
|
174
174
|
mathToolbar: "math-toolbar"
|
|
175
|
-
}, re = N === t.advanced ? M : M.slice(0, 1), $ = /* @__PURE__ */
|
|
175
|
+
}, re = N === t.advanced ? M : M.slice(0, 1), $ = /* @__PURE__ */ c(E, {
|
|
176
176
|
disableFocusListener: !0,
|
|
177
177
|
disableTouchListener: !0,
|
|
178
178
|
placement: "right",
|
|
179
179
|
title: te,
|
|
180
|
-
children: /* @__PURE__ */
|
|
180
|
+
children: /* @__PURE__ */ c(y, {
|
|
181
181
|
fontSize: "small",
|
|
182
182
|
color: "primary",
|
|
183
183
|
style: { marginLeft: "5px" }
|
|
184
184
|
})
|
|
185
185
|
});
|
|
186
|
-
return /* @__PURE__ */
|
|
186
|
+
return /* @__PURE__ */ l(x, {
|
|
187
187
|
ref: (e) => this.root = e || this.root,
|
|
188
188
|
children: [
|
|
189
|
-
|
|
189
|
+
u && /* @__PURE__ */ l(O, {
|
|
190
190
|
label: B.label,
|
|
191
|
-
children: [/* @__PURE__ */
|
|
191
|
+
children: [/* @__PURE__ */ c(h, {
|
|
192
192
|
onFocus: this.onPromptFocus,
|
|
193
193
|
markup: g || "",
|
|
194
194
|
onChange: this.onChange("prompt"),
|
|
@@ -203,16 +203,16 @@ var L = class extends i.Component {
|
|
|
203
203
|
uploadSoundSupport: o,
|
|
204
204
|
languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
|
|
205
205
|
mathMlOptions: K
|
|
206
|
-
}), q && /* @__PURE__ */
|
|
206
|
+
}), q && /* @__PURE__ */ c(D, { children: q })]
|
|
207
207
|
}),
|
|
208
|
-
N === t.advanced && /* @__PURE__ */
|
|
209
|
-
/* @__PURE__ */
|
|
208
|
+
N === t.advanced && /* @__PURE__ */ l(k, { children: [
|
|
209
|
+
/* @__PURE__ */ l(w, {
|
|
210
210
|
style: { justifyContent: "flex-start" },
|
|
211
|
-
children: [/* @__PURE__ */
|
|
211
|
+
children: [/* @__PURE__ */ c(C, { children: "Define Response" }), $]
|
|
212
212
|
}),
|
|
213
|
-
/* @__PURE__ */
|
|
213
|
+
/* @__PURE__ */ c(T, {
|
|
214
214
|
label: "Response Template Equation Editor",
|
|
215
|
-
children: /* @__PURE__ */
|
|
215
|
+
children: /* @__PURE__ */ l(_, {
|
|
216
216
|
onChange: this.onChange("promptEquationEditor"),
|
|
217
217
|
value: j,
|
|
218
218
|
MenuProps: { transitionDuration: {
|
|
@@ -220,58 +220,58 @@ var L = class extends i.Component {
|
|
|
220
220
|
exit: 195
|
|
221
221
|
} },
|
|
222
222
|
children: [
|
|
223
|
-
/* @__PURE__ */
|
|
223
|
+
/* @__PURE__ */ c(v, {
|
|
224
224
|
value: "non-negative-integers",
|
|
225
225
|
children: "Numeric - Non-Negative Integers"
|
|
226
226
|
}),
|
|
227
|
-
/* @__PURE__ */
|
|
227
|
+
/* @__PURE__ */ c(v, {
|
|
228
228
|
value: "integers",
|
|
229
229
|
children: "Numeric - Integers"
|
|
230
230
|
}),
|
|
231
|
-
/* @__PURE__ */
|
|
231
|
+
/* @__PURE__ */ c(v, {
|
|
232
232
|
value: "decimals",
|
|
233
233
|
children: "Numeric - Decimals"
|
|
234
234
|
}),
|
|
235
|
-
/* @__PURE__ */
|
|
235
|
+
/* @__PURE__ */ c(v, {
|
|
236
236
|
value: "fractions",
|
|
237
237
|
children: "Numeric - Fractions"
|
|
238
238
|
}),
|
|
239
|
-
/* @__PURE__ */
|
|
239
|
+
/* @__PURE__ */ c(v, {
|
|
240
240
|
value: 1,
|
|
241
241
|
children: "Grade 1 - 2"
|
|
242
242
|
}),
|
|
243
|
-
/* @__PURE__ */
|
|
243
|
+
/* @__PURE__ */ c(v, {
|
|
244
244
|
value: 3,
|
|
245
245
|
children: "Grade 3 - 5"
|
|
246
246
|
}),
|
|
247
|
-
/* @__PURE__ */
|
|
247
|
+
/* @__PURE__ */ c(v, {
|
|
248
248
|
value: 6,
|
|
249
249
|
children: "Grade 6 - 7"
|
|
250
250
|
}),
|
|
251
|
-
/* @__PURE__ */
|
|
251
|
+
/* @__PURE__ */ c(v, {
|
|
252
252
|
value: 8,
|
|
253
253
|
children: "Grade 8 - HS"
|
|
254
254
|
}),
|
|
255
|
-
/* @__PURE__ */
|
|
255
|
+
/* @__PURE__ */ c(v, {
|
|
256
256
|
value: "geometry",
|
|
257
257
|
children: "Geometry"
|
|
258
258
|
}),
|
|
259
|
-
/* @__PURE__ */
|
|
259
|
+
/* @__PURE__ */ c(v, {
|
|
260
260
|
value: "advanced-algebra",
|
|
261
261
|
children: "Advanced Algebra"
|
|
262
262
|
}),
|
|
263
|
-
/* @__PURE__ */
|
|
263
|
+
/* @__PURE__ */ c(v, {
|
|
264
264
|
value: "statistics",
|
|
265
265
|
children: "Statistics"
|
|
266
266
|
}),
|
|
267
|
-
/* @__PURE__ */
|
|
267
|
+
/* @__PURE__ */ c(v, {
|
|
268
268
|
value: "item-authoring",
|
|
269
269
|
children: "Item Authoring"
|
|
270
270
|
})
|
|
271
271
|
]
|
|
272
272
|
})
|
|
273
273
|
}, "templateEditorType"),
|
|
274
|
-
/* @__PURE__ */
|
|
274
|
+
/* @__PURE__ */ l(ee, { children: [/* @__PURE__ */ c(S, { children: "RESPONSE TEMPLATE" }), /* @__PURE__ */ c(p, {
|
|
275
275
|
classNames: ne,
|
|
276
276
|
allowAnswerBlock: !0,
|
|
277
277
|
keypadMode: j,
|
|
@@ -284,15 +284,15 @@ var L = class extends i.Component {
|
|
|
284
284
|
maxResponseAreas: U,
|
|
285
285
|
error: X
|
|
286
286
|
})] }, "templateHolder"),
|
|
287
|
-
X && /* @__PURE__ */
|
|
287
|
+
X && /* @__PURE__ */ c(D, { children: X })
|
|
288
288
|
] }),
|
|
289
|
-
/* @__PURE__ */
|
|
289
|
+
/* @__PURE__ */ l(w, {
|
|
290
290
|
style: { justifyContent: "flex-start" },
|
|
291
|
-
children: [/* @__PURE__ */
|
|
291
|
+
children: [/* @__PURE__ */ c(C, { children: "Define Correct Response" }), N === t.simple ? $ : null]
|
|
292
292
|
}),
|
|
293
|
-
/* @__PURE__ */
|
|
293
|
+
/* @__PURE__ */ c(T, {
|
|
294
294
|
label: "Equation Editor",
|
|
295
|
-
children: /* @__PURE__ */
|
|
295
|
+
children: /* @__PURE__ */ l(_, {
|
|
296
296
|
onChange: this.onChange("equationEditor"),
|
|
297
297
|
value: A,
|
|
298
298
|
MenuProps: { transitionDuration: {
|
|
@@ -300,58 +300,58 @@ var L = class extends i.Component {
|
|
|
300
300
|
exit: 195
|
|
301
301
|
} },
|
|
302
302
|
children: [
|
|
303
|
-
/* @__PURE__ */
|
|
303
|
+
/* @__PURE__ */ c(v, {
|
|
304
304
|
value: "non-negative-integers",
|
|
305
305
|
children: "Numeric - Non-Negative Integers"
|
|
306
306
|
}),
|
|
307
|
-
/* @__PURE__ */
|
|
307
|
+
/* @__PURE__ */ c(v, {
|
|
308
308
|
value: "integers",
|
|
309
309
|
children: "Numeric - Integers"
|
|
310
310
|
}),
|
|
311
|
-
/* @__PURE__ */
|
|
311
|
+
/* @__PURE__ */ c(v, {
|
|
312
312
|
value: "decimals",
|
|
313
313
|
children: "Numeric - Decimals"
|
|
314
314
|
}),
|
|
315
|
-
/* @__PURE__ */
|
|
315
|
+
/* @__PURE__ */ c(v, {
|
|
316
316
|
value: "fractions",
|
|
317
317
|
children: "Numeric - Fractions"
|
|
318
318
|
}),
|
|
319
|
-
/* @__PURE__ */
|
|
319
|
+
/* @__PURE__ */ c(v, {
|
|
320
320
|
value: 1,
|
|
321
321
|
children: "Grade 1 - 2"
|
|
322
322
|
}),
|
|
323
|
-
/* @__PURE__ */
|
|
323
|
+
/* @__PURE__ */ c(v, {
|
|
324
324
|
value: 3,
|
|
325
325
|
children: "Grade 3 - 5"
|
|
326
326
|
}),
|
|
327
|
-
/* @__PURE__ */
|
|
327
|
+
/* @__PURE__ */ c(v, {
|
|
328
328
|
value: 6,
|
|
329
329
|
children: "Grade 6 - 7"
|
|
330
330
|
}),
|
|
331
|
-
/* @__PURE__ */
|
|
331
|
+
/* @__PURE__ */ c(v, {
|
|
332
332
|
value: 8,
|
|
333
333
|
children: "Grade 8 - HS"
|
|
334
334
|
}),
|
|
335
|
-
/* @__PURE__ */
|
|
335
|
+
/* @__PURE__ */ c(v, {
|
|
336
336
|
value: "geometry",
|
|
337
337
|
children: "Geometry"
|
|
338
338
|
}),
|
|
339
|
-
/* @__PURE__ */
|
|
339
|
+
/* @__PURE__ */ c(v, {
|
|
340
340
|
value: "advanced-algebra",
|
|
341
341
|
children: "Advanced Algebra"
|
|
342
342
|
}),
|
|
343
|
-
/* @__PURE__ */
|
|
343
|
+
/* @__PURE__ */ c(v, {
|
|
344
344
|
value: "statistics",
|
|
345
345
|
children: "Statistics"
|
|
346
346
|
}),
|
|
347
|
-
/* @__PURE__ */
|
|
347
|
+
/* @__PURE__ */ c(v, {
|
|
348
348
|
value: "item-authoring",
|
|
349
349
|
children: "Item Authoring"
|
|
350
350
|
})
|
|
351
351
|
]
|
|
352
352
|
})
|
|
353
353
|
}),
|
|
354
|
-
re.map((n, r) => /* @__PURE__ */
|
|
354
|
+
re.map((n, r) => /* @__PURE__ */ c(e, {
|
|
355
355
|
mode: A,
|
|
356
356
|
response: n,
|
|
357
357
|
defaultResponse: N === t.simple,
|
|
@@ -361,9 +361,9 @@ var L = class extends i.Component {
|
|
|
361
361
|
cAllowTrailingZeros: H,
|
|
362
362
|
error: Y && Y[r]
|
|
363
363
|
}, n.id)),
|
|
364
|
-
d && /* @__PURE__ */
|
|
364
|
+
d && /* @__PURE__ */ l(O, {
|
|
365
365
|
label: z.label,
|
|
366
|
-
children: [/* @__PURE__ */
|
|
366
|
+
children: [/* @__PURE__ */ c(h, {
|
|
367
367
|
markup: P || "",
|
|
368
368
|
onChange: this.onChange("rationale"),
|
|
369
369
|
imageSupport: a,
|
|
@@ -380,7 +380,7 @@ var L = class extends i.Component {
|
|
|
380
380
|
uploadSoundSupport: o,
|
|
381
381
|
languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
|
|
382
382
|
mathMlOptions: K
|
|
383
|
-
}), J && /* @__PURE__ */
|
|
383
|
+
}), J && /* @__PURE__ */ c(D, { children: J })]
|
|
384
384
|
})
|
|
385
385
|
]
|
|
386
386
|
});
|
|
@@ -1,9 +1,59 @@
|
|
|
1
|
-
import { p as e,
|
|
2
|
-
import { t as
|
|
3
|
-
import
|
|
4
|
-
import { createRoot as
|
|
1
|
+
import { p as e, y as t } from "../dist--pvq7WNe.js";
|
|
2
|
+
import { t as n } from "../main-m39H1gPw.js";
|
|
3
|
+
import r from "react";
|
|
4
|
+
import { createRoot as i } from "react-dom/client";
|
|
5
5
|
//#region ../../shared/player-events/dist/index.js
|
|
6
|
-
var
|
|
6
|
+
var a = /* @__PURE__ */ t(e(), 1), o = "commitPendingSession", s = /* @__PURE__ */ new WeakMap();
|
|
7
|
+
function c(e, t) {
|
|
8
|
+
let n = s.get(e);
|
|
9
|
+
n || (n = /* @__PURE__ */ new Set(), s.set(e, n)), n.add(t);
|
|
10
|
+
}
|
|
11
|
+
function l(e) {
|
|
12
|
+
return Object.getOwnPropertyDescriptor(e, o) !== void 0;
|
|
13
|
+
}
|
|
14
|
+
function u(e) {
|
|
15
|
+
if (l(e)) return;
|
|
16
|
+
let t = e[o];
|
|
17
|
+
Object.defineProperty(e, o, {
|
|
18
|
+
value: () => {
|
|
19
|
+
if (typeof t == "function") try {
|
|
20
|
+
t.call(e);
|
|
21
|
+
} catch {}
|
|
22
|
+
f(e);
|
|
23
|
+
},
|
|
24
|
+
configurable: !0,
|
|
25
|
+
enumerable: !1,
|
|
26
|
+
writable: !0
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function d(e, t, n = {}) {
|
|
30
|
+
let r = n.delayMs, i = typeof r == "function" ? r : () => r ?? 0, a = n.maxWaitMs, o = null, s = null, l = !1, d = () => {
|
|
31
|
+
o !== null && (clearTimeout(o), o = null), s !== null && (clearTimeout(s), s = null);
|
|
32
|
+
}, f = () => {
|
|
33
|
+
d(), l && (l = !1, t());
|
|
34
|
+
}, p = {
|
|
35
|
+
notify() {
|
|
36
|
+
l = !0, o !== null && clearTimeout(o), o = setTimeout(f, Math.max(0, i())), a !== void 0 && s === null && (s = setTimeout(f, Math.max(0, a)));
|
|
37
|
+
},
|
|
38
|
+
flush() {
|
|
39
|
+
if (!l) {
|
|
40
|
+
d();
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
f();
|
|
45
|
+
} catch (e) {
|
|
46
|
+
console.warn("[session-notifier] a committed session-changed dispatch threw", e);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
return c(e, p), u(e), p;
|
|
51
|
+
}
|
|
52
|
+
function f(e) {
|
|
53
|
+
let t = s.get(e);
|
|
54
|
+
if (t) for (let e of [...t]) e.flush();
|
|
55
|
+
}
|
|
56
|
+
var p = class e extends CustomEvent {
|
|
7
57
|
static {
|
|
8
58
|
this.TYPE = "model-set";
|
|
9
59
|
}
|
|
@@ -18,7 +68,7 @@ var o = /* @__PURE__ */ n(e(), 1), s = class e extends CustomEvent {
|
|
|
18
68
|
}
|
|
19
69
|
}), this.component = t, this.complete = n;
|
|
20
70
|
}
|
|
21
|
-
},
|
|
71
|
+
}, m = class e extends CustomEvent {
|
|
22
72
|
static {
|
|
23
73
|
this.TYPE = "session-changed";
|
|
24
74
|
}
|
|
@@ -32,11 +82,11 @@ var o = /* @__PURE__ */ n(e(), 1), s = class e extends CustomEvent {
|
|
|
32
82
|
}
|
|
33
83
|
}), this.component = t, this.complete = n;
|
|
34
84
|
}
|
|
35
|
-
},
|
|
85
|
+
}, h = { configuration: {} }, g = (0, a.default)("pie-ui:math-inline"), _ = class extends HTMLElement {
|
|
36
86
|
constructor() {
|
|
37
|
-
super(), this._root = null, this._configuration =
|
|
38
|
-
this.dispatchEvent(new
|
|
39
|
-
}, 1e3);
|
|
87
|
+
super(), this._root = null, this._configuration = h.configuration, this._sessionNotifier = d(this, () => {
|
|
88
|
+
this.dispatchEvent(new m(this.tagName.toLowerCase(), !0));
|
|
89
|
+
}, { delayMs: 1e3 }), this.sessionChangedEventCaller = () => this._sessionNotifier.notify();
|
|
40
90
|
}
|
|
41
91
|
setLangAttribute() {
|
|
42
92
|
let e = this._model && typeof this._model.language ? this._model.language : "", t = e ? e.slice(0, 2) : "en";
|
|
@@ -45,7 +95,7 @@ var o = /* @__PURE__ */ n(e(), 1), s = class e extends CustomEvent {
|
|
|
45
95
|
n && n.setAttribute("lang", t);
|
|
46
96
|
}
|
|
47
97
|
set model(e) {
|
|
48
|
-
this._model = e, this.dispatchEvent(new
|
|
98
|
+
this._model = e, this.dispatchEvent(new p(this._model, !0, !!this._model)), this.setLangAttribute(), this._render();
|
|
49
99
|
}
|
|
50
100
|
set session(e) {
|
|
51
101
|
this._session = e, this._render();
|
|
@@ -59,26 +109,26 @@ var o = /* @__PURE__ */ n(e(), 1), s = class e extends CustomEvent {
|
|
|
59
109
|
sessionChanged(e) {
|
|
60
110
|
Object.keys(e).map((t) => {
|
|
61
111
|
this._session[t] = e[t];
|
|
62
|
-
}), this.sessionChangedEventCaller(),
|
|
112
|
+
}), this.sessionChangedEventCaller(), g("session: ", this._session);
|
|
63
113
|
}
|
|
64
114
|
connectedCallback() {
|
|
65
115
|
this.setAttribute("aria-label", "Math Response Question"), this.setAttribute("role", "region"), this._render();
|
|
66
116
|
}
|
|
67
117
|
_render() {
|
|
68
118
|
if (!this._model || !this._session) return;
|
|
69
|
-
let e =
|
|
119
|
+
let e = r.createElement(n, {
|
|
70
120
|
model: this._model,
|
|
71
121
|
session: this._session,
|
|
72
122
|
configuration: this._configuration,
|
|
73
123
|
onSessionChange: this.sessionChanged.bind(this)
|
|
74
124
|
});
|
|
75
|
-
this._root ||=
|
|
125
|
+
this._root ||= i(this), this._root.render(e);
|
|
76
126
|
}
|
|
77
127
|
disconnectedCallback() {
|
|
78
|
-
this._root &&= (this._root.unmount(), null);
|
|
128
|
+
f(this), this._root &&= (this._root.unmount(), null);
|
|
79
129
|
}
|
|
80
130
|
};
|
|
81
131
|
//#endregion
|
|
82
|
-
export {
|
|
132
|
+
export { n as Component, _ as default };
|
|
83
133
|
|
|
84
134
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../../shared/player-events/dist/index.js","../../../src/delivery/index.ts"],"sourcesContent":["//#region src/
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../../shared/player-events/dist/index.js","../../../src/delivery/index.ts"],"sourcesContent":["//#region src/session-notifier.ts\nvar e = \"commitPendingSession\", t = /* @__PURE__ */ new WeakMap();\nfunction n(e, n) {\n\tlet r = t.get(e);\n\tr || (r = /* @__PURE__ */ new Set(), t.set(e, r)), r.add(n);\n}\nfunction r(t) {\n\treturn Object.getOwnPropertyDescriptor(t, e) !== void 0;\n}\nfunction i(t) {\n\tif (r(t)) return;\n\tlet n = t[e];\n\tObject.defineProperty(t, e, {\n\t\tvalue: () => {\n\t\t\tif (typeof n == \"function\") try {\n\t\t\t\tn.call(t);\n\t\t\t} catch {}\n\t\t\to(t);\n\t\t},\n\t\tconfigurable: !0,\n\t\tenumerable: !1,\n\t\twritable: !0\n\t});\n}\nfunction a(e, t, r = {}) {\n\tlet a = r.delayMs, o = typeof a == \"function\" ? a : () => a ?? 0, s = r.maxWaitMs, c = null, l = null, u = !1, d = () => {\n\t\tc !== null && (clearTimeout(c), c = null), l !== null && (clearTimeout(l), l = null);\n\t}, f = () => {\n\t\td(), u && (u = !1, t());\n\t}, p = {\n\t\tnotify() {\n\t\t\tu = !0, c !== null && clearTimeout(c), c = setTimeout(f, Math.max(0, o())), s !== void 0 && l === null && (l = setTimeout(f, Math.max(0, s)));\n\t\t},\n\t\tflush() {\n\t\t\tif (!u) {\n\t\t\t\td();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tf();\n\t\t\t} catch (e) {\n\t\t\t\tconsole.warn(\"[session-notifier] a committed session-changed dispatch threw\", e);\n\t\t\t}\n\t\t}\n\t};\n\treturn n(e, p), i(e), p;\n}\nfunction o(e) {\n\tlet n = t.get(e);\n\tif (n) for (let e of [...n]) e.flush();\n}\n//#endregion\n//#region src/index.ts\nvar s = class e extends CustomEvent {\n\tstatic {\n\t\tthis.TYPE = \"model-set\";\n\t}\n\tconstructor(t, n, r) {\n\t\tsuper(e.TYPE, {\n\t\t\tbubbles: !0,\n\t\t\tcomposed: !0,\n\t\t\tdetail: {\n\t\t\t\tcomplete: n,\n\t\t\t\tcomponent: t,\n\t\t\t\thasModel: r\n\t\t\t}\n\t\t}), this.component = t, this.complete = n;\n\t}\n}, c = class e extends CustomEvent {\n\tstatic {\n\t\tthis.TYPE = \"session-changed\";\n\t}\n\tconstructor(t, n) {\n\t\tsuper(e.TYPE, {\n\t\t\tbubbles: !0,\n\t\t\tcomposed: !0,\n\t\t\tdetail: {\n\t\t\t\tcomplete: n,\n\t\t\t\tcomponent: t\n\t\t\t}\n\t\t}), this.component = t, this.complete = n;\n\t}\n};\n//#endregion\nexport { s as ModelSetEvent, e as SESSION_COMMIT_METHOD, c as SessionChangedEvent, a as createSessionNotifier, o as flushSessionNotifiers };\n","// @ts-nocheck\n/**\n * @synced-from pie-elements/packages/math-inline/src/index.js\n * @auto-generated\n *\n * This file is automatically synced from pie-elements and converted to TypeScript.\n * Manual edits will be overwritten on next sync.\n * To make changes, edit the upstream JavaScript file and run sync again.\n */\n\nimport React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport debug from 'debug';\nimport {\n ModelSetEvent,\n SessionChangedEvent,\n createSessionNotifier,\n flushSessionNotifiers,\n} from '@pie-element/shared-player-events';\n\n// Inlined from configure/lib/defaults (configure/ not synced - ESM-incompatible)\nconst defaults = {\n configuration: {\n // Minimal configuration for student-facing UI\n // Full authoring configuration is only needed in the configure package\n } as any\n};;\nimport Main from './main.js';\n\nconst log = debug('pie-ui:math-inline');\n\nexport { Main as Component };\n\nexport default class MathInline extends HTMLElement {\n constructor() {\n super();\n this._root = null;\n this._configuration = defaults.configuration;\n // Session state is already written synchronously in `sessionChanged`; only\n // this dispatch is coalesced, and `disconnectedCallback` flushes it.\n this._sessionNotifier = createSessionNotifier(\n this,\n () => {\n this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), true));\n },\n { delayMs: 1000 },\n );\n this.sessionChangedEventCaller = () => this._sessionNotifier.notify();\n }\n\n setLangAttribute() {\n const language = this._model && typeof this._model.language ? this._model.language : '';\n const lang = language ? language.slice(0, 2) : 'en';\n this.setAttribute('lang', lang);\n\n // set the lang attribute for the nearest parent div with class 'player-container' for MPI items as per PD-2483\n const playerContainer = this.closest('.player-container');\n if (playerContainer) {\n playerContainer.setAttribute('lang', lang);\n }\n }\n\n set model(m) {\n this._model = m;\n this.dispatchEvent(new ModelSetEvent(this._model, true, !!this._model));\n this.setLangAttribute();\n this._render();\n }\n\n set session(s) {\n this._session = s;\n this._render();\n }\n\n get session() {\n return this._session;\n }\n\n set configuration(c) {\n this._configuration = c;\n this._render();\n }\n\n sessionChanged(s) {\n Object.keys(s).map((key) => {\n this._session[key] = s[key];\n });\n\n this.sessionChangedEventCaller();\n log('session: ', this._session);\n }\n\n connectedCallback() {\n this.setAttribute('aria-label', 'Math Response Question');\n this.setAttribute('role', 'region');\n\n this._render();\n }\n\n _render() {\n if (!this._model || !this._session) {\n return;\n }\n\n const el = React.createElement(Main, {\n model: this._model,\n session: this._session,\n configuration: this._configuration,\n onSessionChange: this.sessionChanged.bind(this),\n });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(el);\n }\n\n disconnectedCallback() {\n flushSessionNotifiers(this);\n\n if (this._root) {\n this._root.unmount();\n this._root = null;\n }\n }\n}\n"],"mappings":";;;;;mCACI,IAAI,wBAAwB,oBAAoB,IAAI,QAAQ;AAChE,SAAS,EAAE,GAAG,GAAG;CAChB,IAAI,IAAI,EAAE,IAAI,CAAC;CACf,MAAM,oBAAoB,IAAI,IAAI,GAAG,EAAE,IAAI,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC;AAC3D;AACA,SAAS,EAAE,GAAG;CACb,OAAO,OAAO,yBAAyB,GAAG,CAAC,MAAM,KAAK;AACvD;AACA,SAAS,EAAE,GAAG;CACb,IAAI,EAAE,CAAC,GAAG;CACV,IAAI,IAAI,EAAE;CACV,OAAO,eAAe,GAAG,GAAG;EAC3B,aAAa;GACZ,IAAI,OAAO,KAAK,YAAY,IAAI;IAC/B,EAAE,KAAK,CAAC;GACT,QAAQ,CAAC;GACT,EAAE,CAAC;EACJ;EACA,cAAc,CAAC;EACf,YAAY,CAAC;EACb,UAAU,CAAC;CACZ,CAAC;AACF;AACA,SAAS,EAAE,GAAG,GAAG,IAAI,CAAC,GAAG;CACxB,IAAI,IAAI,EAAE,SAAS,IAAI,OAAO,KAAK,aAAa,UAAU,KAAK,GAAG,IAAI,EAAE,WAAW,IAAI,MAAM,IAAI,MAAM,IAAI,CAAC,GAAG,UAAU;EACxH,MAAM,SAAS,aAAa,CAAC,GAAG,IAAI,OAAO,MAAM,SAAS,aAAa,CAAC,GAAG,IAAI;CAChF,GAAG,UAAU;EACZ,EAAE,GAA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,KAAK;GACZ,SAAS,KAAK;GACd,eAAe,KAAK;GACpB,iBAAiB,KAAK,eAAe,KAAK,IAAI;EAChD,CAAC;EAKD,AAHA,AACE,KAAK,UAAQ,EAAW,IAAI,GAE9B,KAAK,MAAM,OAAO,CAAE;CACtB;CAEA,uBAAuB;EAGrB,AAFA,EAAsB,IAAI,GAE1B,AAEE,KAAK,WADL,KAAK,MAAM,QAAQ,GACN;CAEjB;AACF"}
|
package/dist/delivery/index.js
CHANGED
|
@@ -2,14 +2,13 @@ import { Main as e } from "./main.js";
|
|
|
2
2
|
import t from "react";
|
|
3
3
|
import { createRoot as n } from "react-dom/client";
|
|
4
4
|
import r from "debug";
|
|
5
|
-
import {
|
|
6
|
-
import { ModelSetEvent as a, SessionChangedEvent as o } from "@pie-element/shared-player-events";
|
|
5
|
+
import { ModelSetEvent as i, SessionChangedEvent as a, createSessionNotifier as o, flushSessionNotifiers as s } from "@pie-element/shared-player-events";
|
|
7
6
|
//#region src/delivery/index.ts
|
|
8
|
-
var
|
|
7
|
+
var c = { configuration: {} }, l = r("pie-ui:math-inline"), u = class extends HTMLElement {
|
|
9
8
|
constructor() {
|
|
10
|
-
super(), this._root = null, this._configuration =
|
|
11
|
-
this.dispatchEvent(new
|
|
12
|
-
}, 1e3);
|
|
9
|
+
super(), this._root = null, this._configuration = c.configuration, this._sessionNotifier = o(this, () => {
|
|
10
|
+
this.dispatchEvent(new a(this.tagName.toLowerCase(), !0));
|
|
11
|
+
}, { delayMs: 1e3 }), this.sessionChangedEventCaller = () => this._sessionNotifier.notify();
|
|
13
12
|
}
|
|
14
13
|
setLangAttribute() {
|
|
15
14
|
let e = this._model && typeof this._model.language ? this._model.language : "", t = e ? e.slice(0, 2) : "en";
|
|
@@ -18,7 +17,7 @@ var s = { configuration: {} }, c = r("pie-ui:math-inline"), l = class extends HT
|
|
|
18
17
|
n && n.setAttribute("lang", t);
|
|
19
18
|
}
|
|
20
19
|
set model(e) {
|
|
21
|
-
this._model = e, this.dispatchEvent(new
|
|
20
|
+
this._model = e, this.dispatchEvent(new i(this._model, !0, !!this._model)), this.setLangAttribute(), this._render();
|
|
22
21
|
}
|
|
23
22
|
set session(e) {
|
|
24
23
|
this._session = e, this._render();
|
|
@@ -32,7 +31,7 @@ var s = { configuration: {} }, c = r("pie-ui:math-inline"), l = class extends HT
|
|
|
32
31
|
sessionChanged(e) {
|
|
33
32
|
Object.keys(e).map((t) => {
|
|
34
33
|
this._session[t] = e[t];
|
|
35
|
-
}), this.sessionChangedEventCaller(),
|
|
34
|
+
}), this.sessionChangedEventCaller(), l("session: ", this._session);
|
|
36
35
|
}
|
|
37
36
|
connectedCallback() {
|
|
38
37
|
this.setAttribute("aria-label", "Math Response Question"), this.setAttribute("role", "region"), this._render();
|
|
@@ -48,8 +47,8 @@ var s = { configuration: {} }, c = r("pie-ui:math-inline"), l = class extends HT
|
|
|
48
47
|
this._root ||= n(this), this._root.render(r);
|
|
49
48
|
}
|
|
50
49
|
disconnectedCallback() {
|
|
51
|
-
this._root &&= (this._root.unmount(), null);
|
|
50
|
+
s(this), this._root &&= (this._root.unmount(), null);
|
|
52
51
|
}
|
|
53
52
|
};
|
|
54
53
|
//#endregion
|
|
55
|
-
export { e as Component,
|
|
54
|
+
export { e as Component, u as default };
|