@pie-element/math-templated 7.1.1-next.12 → 7.1.2
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/CHANGELOG.json +1 -0
- package/CHANGELOG.md +1144 -0
- package/LICENSE.md +5 -0
- package/README.md +0 -0
- package/configure/CHANGELOG.json +1 -0
- package/configure/CHANGELOG.md +1021 -0
- package/configure/lib/defaults.js +172 -0
- package/configure/lib/defaults.js.map +1 -0
- package/configure/lib/design.js +546 -0
- package/configure/lib/design.js.map +1 -0
- package/configure/lib/index.js +169 -0
- package/configure/lib/index.js.map +1 -0
- package/configure/lib/markupUtils.js +39 -0
- package/configure/lib/markupUtils.js.map +1 -0
- package/configure/lib/response.js +394 -0
- package/configure/lib/response.js.map +1 -0
- package/configure/lib/utils.js +15 -0
- package/configure/lib/utils.js.map +1 -0
- package/configure/package.json +26 -0
- package/controller/CHANGELOG.json +1 -0
- package/controller/CHANGELOG.md +874 -0
- package/controller/lib/defaults.js +28 -0
- package/controller/lib/defaults.js.map +1 -0
- package/controller/lib/index.js +360 -0
- package/controller/lib/index.js.map +1 -0
- package/controller/package.json +17 -0
- package/docs/config-schema.json +2251 -0
- package/docs/config-schema.json.md +1658 -0
- package/docs/demo/config.js +8 -0
- package/docs/demo/generate.js +42 -0
- package/docs/demo/index.html +1 -0
- package/docs/demo/session.js +14 -0
- package/docs/pie-schema.json +1231 -0
- package/docs/pie-schema.json.md +894 -0
- package/lib/index.js +76 -0
- package/lib/index.js.map +1 -0
- package/lib/main.js +877 -0
- package/lib/main.js.map +1 -0
- package/lib/print.js +88 -0
- package/lib/print.js.map +1 -0
- package/module/configure.js +1 -0
- package/module/controller.js +3711 -0
- package/module/demo.js +67 -0
- package/module/element.js +1 -0
- package/module/index.html +21 -0
- package/module/manifest.json +22 -0
- package/module/print-demo.js +105 -0
- package/module/print.html +18 -0
- package/module/print.js +1 -0
- package/package.json +22 -93
- package/configure.js +0 -2
- package/controller.js +0 -1
- package/dist/author/defaults.d.ts +0 -173
- package/dist/author/defaults.js +0 -123
- package/dist/author/design.d.ts +0 -35
- package/dist/author/design.js +0 -360
- package/dist/author/index.d.ts +0 -42
- package/dist/author/index.js +0 -97
- package/dist/author/markupUtils.d.ts +0 -11
- package/dist/author/markupUtils.js +0 -10
- package/dist/author/response.d.ts +0 -41
- package/dist/author/response.js +0 -238
- package/dist/author/utils.d.ts +0 -9
- package/dist/author/utils.js +0 -7
- package/dist/browser/author/index.js +0 -31954
- package/dist/browser/author/index.js.map +0 -1
- package/dist/browser/browser-DJA4OL8j.js +0 -331
- package/dist/browser/browser-DJA4OL8j.js.map +0 -1
- package/dist/browser/controller/index.js +0 -37731
- package/dist/browser/controller/index.js.map +0 -1
- package/dist/browser/delivery/index.js +0 -81
- package/dist/browser/delivery/index.js.map +0 -1
- package/dist/browser/dist-Csid0rBE.js +0 -17046
- package/dist/browser/dist-Csid0rBE.js.map +0 -1
- package/dist/browser/dist-D9ARZhQk.js +0 -1426
- package/dist/browser/dist-D9ARZhQk.js.map +0 -1
- package/dist/browser/main-I_wWeaur.js +0 -1274
- package/dist/browser/main-I_wWeaur.js.map +0 -1
- package/dist/browser/math-templated.css +0 -2
- package/dist/browser/print/index.js +0 -47
- package/dist/browser/print/index.js.map +0 -1
- package/dist/controller/defaults.d.ts +0 -29
- package/dist/controller/defaults.js +0 -23
- package/dist/controller/index.d.ts +0 -45
- package/dist/controller/index.js +0 -154
- package/dist/delivery/index.d.ts +0 -20
- package/dist/delivery/index.js +0 -51
- package/dist/delivery/main.d.ts +0 -40
- package/dist/delivery/main.js +0 -492
- package/dist/index.d.ts +0 -1
- package/dist/index.iife.d.ts +0 -8
- package/dist/index.iife.js +0 -205
- package/dist/index.js +0 -2
- package/dist/math-templated.css +0 -2
- package/dist/print/index.d.ts +0 -15
- package/dist/print/index.js +0 -47
- package/dist/runtime-support.d.ts +0 -12
- package/dist/runtime-support.js +0 -12
package/dist/delivery/main.js
DELETED
|
@@ -1,492 +0,0 @@
|
|
|
1
|
-
import e from "react";
|
|
2
|
-
import t from "prop-types";
|
|
3
|
-
import { isEmpty as n, isEqual as r } from "@pie-element/shared-lodash";
|
|
4
|
-
import { styled as i } from "@mui/material/styles";
|
|
5
|
-
import a from "@mui/material/Tooltip";
|
|
6
|
-
import { HorizontalKeypad as o, applyStaticMath as s, mq as c, registerEmbed as l, updateSpans as u } from "@pie-lib/math-input";
|
|
7
|
-
import * as d from "@pie-lib/render-ui";
|
|
8
|
-
import { Collapsible as f, PreviewPrompt as p, Readable as m, UiLayout as h, color as g, hasMedia as _, hasText as v } from "@pie-lib/render-ui";
|
|
9
|
-
import { jsx as y, jsxs as b } from "react/jsx-runtime";
|
|
10
|
-
import { renderMath as x } from "@pie-element/shared-math-rendering-mathjax";
|
|
11
|
-
import { Customizable as S } from "@pie-lib/mask-markup";
|
|
12
|
-
import C from "@pie-lib/correct-answer-toggle";
|
|
13
|
-
import w from "react-dom";
|
|
14
|
-
//#region src/delivery/main.tsx
|
|
15
|
-
function T(e) {
|
|
16
|
-
return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
|
|
17
|
-
}
|
|
18
|
-
function E(e, t) {
|
|
19
|
-
return !e || T(e) ? e : T(e.default) ? e.default : t && T(e[t]) ? e[t] : t && T(e[t]?.default) ? e[t].default : e;
|
|
20
|
-
}
|
|
21
|
-
var D = E(h, "UiLayout") || E(N.UiLayout, "UiLayout"), O = E(p, "PreviewPrompt") || E(N.PreviewPrompt, "PreviewPrompt"), k = E(m, "Readable") || E(N.Readable, "Readable"), A = E(f, "Collapsible") || E(N.Collapsible, "Collapsible"), j = d, M = j.default, N = M && typeof M == "object" ? M : j, P = i(D)({
|
|
22
|
-
color: g.text(),
|
|
23
|
-
backgroundColor: g.background(),
|
|
24
|
-
display: "inline-block"
|
|
25
|
-
}), F = i("div")({
|
|
26
|
-
width: "100%",
|
|
27
|
-
position: "relative",
|
|
28
|
-
backgroundColor: g.background(),
|
|
29
|
-
color: g.text()
|
|
30
|
-
}), I = i("div")(({ theme: e }) => ({ marginBottom: e.spacing(2) })), L = i("div")(({ theme: e }) => ({ marginBottom: e.spacing(2) })), R = i("div")({
|
|
31
|
-
position: "relative",
|
|
32
|
-
"& > div > div": {
|
|
33
|
-
display: "flex",
|
|
34
|
-
alignItems: "baseline",
|
|
35
|
-
flexWrap: "wrap"
|
|
36
|
-
},
|
|
37
|
-
"& .mq-overarrow-inner": {
|
|
38
|
-
border: "none !important",
|
|
39
|
-
padding: "0 !important"
|
|
40
|
-
},
|
|
41
|
-
"& .mq-overarrow-inner-right": { display: "none !important" },
|
|
42
|
-
"& .mq-overarrow-inner-left": { display: "none !important" },
|
|
43
|
-
"& .mq-overarrow.mq-arrow-both": {
|
|
44
|
-
minWidth: "1.23em",
|
|
45
|
-
"& *": { lineHeight: "1 !important" },
|
|
46
|
-
"&:before": {
|
|
47
|
-
top: "-0.4em",
|
|
48
|
-
left: "-1px"
|
|
49
|
-
},
|
|
50
|
-
"&:after": {
|
|
51
|
-
top: "-2.4em",
|
|
52
|
-
right: "-1px"
|
|
53
|
-
},
|
|
54
|
-
"&.mq-empty:after": { top: "-0.45em" }
|
|
55
|
-
},
|
|
56
|
-
"& .mq-overarrow.mq-arrow-right": { "&:before": {
|
|
57
|
-
top: "-0.4em",
|
|
58
|
-
right: "-1px"
|
|
59
|
-
} },
|
|
60
|
-
"& .mq-longdiv-inner": {
|
|
61
|
-
borderTop: "1px solid !important",
|
|
62
|
-
paddingTop: "1.5px !important"
|
|
63
|
-
},
|
|
64
|
-
"& .mq-parallelogram": { lineHeight: .85 }
|
|
65
|
-
}), z = i("div")(({ theme: e, $incorrect: t, $correct: n, $showCorrectness: r, $correctAnswerShown: i }) => ({
|
|
66
|
-
maxWidth: "fit-content",
|
|
67
|
-
...t && { borderColor: `${g.incorrect()} !important` },
|
|
68
|
-
...n && { borderColor: `${g.correct()} !important` },
|
|
69
|
-
...r && { border: "2px solid" },
|
|
70
|
-
...i && {
|
|
71
|
-
padding: e.spacing(1),
|
|
72
|
-
letterSpacing: "0.5px"
|
|
73
|
-
},
|
|
74
|
-
"& > .mq-math-mode": {
|
|
75
|
-
"& > .mq-root-block": { "& > .mq-editable-field": {
|
|
76
|
-
minWidth: "10px",
|
|
77
|
-
padding: e.spacing(.25)
|
|
78
|
-
} },
|
|
79
|
-
"& sup": { top: 0 }
|
|
80
|
-
}
|
|
81
|
-
})), B = i(c.Static)({ "& > .mq-root-block": { "& > .mq-editable-field": { borderColor: g.text() } } }), V = i("div")(({ theme: e }) => ({
|
|
82
|
-
zIndex: 10,
|
|
83
|
-
minWidth: "400px",
|
|
84
|
-
marginTop: e.spacing(2)
|
|
85
|
-
})), H = i("div")(({ theme: e }) => ({
|
|
86
|
-
marginBottom: e.spacing(1),
|
|
87
|
-
pointerEvents: "none"
|
|
88
|
-
})), U = i("h2")({
|
|
89
|
-
position: "absolute",
|
|
90
|
-
left: "-10000px",
|
|
91
|
-
top: "auto",
|
|
92
|
-
width: "1px",
|
|
93
|
-
height: "1px",
|
|
94
|
-
overflow: "hidden"
|
|
95
|
-
}), W = i("div")(({ theme: e }) => ({ marginBottom: e.spacing(2) })), G = i(C)(({ theme: e }) => ({
|
|
96
|
-
color: g.text(),
|
|
97
|
-
marginBottom: e.spacing(2)
|
|
98
|
-
}));
|
|
99
|
-
if (typeof document < "u") {
|
|
100
|
-
let e = "math-templated-main-styles";
|
|
101
|
-
if (!document.getElementById(e)) {
|
|
102
|
-
let t = document.createElement("style");
|
|
103
|
-
t.id = e, t.textContent = `
|
|
104
|
-
.block-container {
|
|
105
|
-
margin: 8px !important;
|
|
106
|
-
display: inline-flex;
|
|
107
|
-
border: 2px solid grey !important;
|
|
108
|
-
}
|
|
109
|
-
.block-response {
|
|
110
|
-
flex: 2;
|
|
111
|
-
color: grey;
|
|
112
|
-
background: rgba(0, 0, 0, 0.04);
|
|
113
|
-
font-size: 0.8rem !important;
|
|
114
|
-
padding: 4px !important;
|
|
115
|
-
display: flex;
|
|
116
|
-
align-items: center;
|
|
117
|
-
justify-content: center;
|
|
118
|
-
border-right: 2px solid #bdbdbd !important;
|
|
119
|
-
}
|
|
120
|
-
.block-math {
|
|
121
|
-
color: ${g.text()};
|
|
122
|
-
background-color: ${g.background()};
|
|
123
|
-
padding: 4px !important;
|
|
124
|
-
display: flex;
|
|
125
|
-
align-items: center;
|
|
126
|
-
justify-content: center;
|
|
127
|
-
flex: 8;
|
|
128
|
-
}
|
|
129
|
-
.block-math > .mq-math-mode > .mq-hasCursor > .mq-cursor {
|
|
130
|
-
display: none;
|
|
131
|
-
}
|
|
132
|
-
.correct {
|
|
133
|
-
border-color: ${g.correct()} !important;
|
|
134
|
-
}
|
|
135
|
-
.incorrect {
|
|
136
|
-
border-color: ${g.incorrect()} !important;
|
|
137
|
-
}
|
|
138
|
-
`, document.head.appendChild(t);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
var K = !1, q = /(\{\{\d+\}\})/gm, J = 6, Y = 8, X = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
142
|
-
function Z(e = []) {
|
|
143
|
-
return e.map((e) => ({
|
|
144
|
-
name: e,
|
|
145
|
-
latex: e,
|
|
146
|
-
write: e,
|
|
147
|
-
label: e
|
|
148
|
-
}));
|
|
149
|
-
}
|
|
150
|
-
function Q(e = [], t) {
|
|
151
|
-
return Math.floor(e.length / 5) * 30 + (t === "miscellaneous" ? 600 : 500);
|
|
152
|
-
}
|
|
153
|
-
function ee(e) {
|
|
154
|
-
return e.split(q).filter((e) => e);
|
|
155
|
-
}
|
|
156
|
-
function te(e, t) {
|
|
157
|
-
let { responses: n, disabled: r, markup: i, printMode: a, alwaysShowCorrect: o } = e || {};
|
|
158
|
-
if (i) return t.showCorrect ? Object.keys(n || {}).reduce((e, t) => (e[t] = n?.[t]?.answer, e), {}) : ee(i).reduce((e, n) => {
|
|
159
|
-
if (n.match(q)) {
|
|
160
|
-
let i = $.getResponseKey(n), s = t.session.answers[`r${i}`];
|
|
161
|
-
if (a && !o) {
|
|
162
|
-
let t = "\\ \\ ".repeat(30) + "\\embed{newLine}[] ";
|
|
163
|
-
return {
|
|
164
|
-
...e,
|
|
165
|
-
[i]: `\\MathQuillMathField[r${i}]{${t.repeat(3)}}`
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
return r ? {
|
|
169
|
-
...e,
|
|
170
|
-
[i]: `\\embed{answerBlock}[r${i}]`
|
|
171
|
-
} : {
|
|
172
|
-
...e,
|
|
173
|
-
[i]: `\\MathQuillMathField[r${i}]{${s && s.value || ""}}`
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
return e;
|
|
177
|
-
}, {});
|
|
178
|
-
}
|
|
179
|
-
var ne = {
|
|
180
|
-
name: "smartHorizontalPlacement",
|
|
181
|
-
enabled: !0,
|
|
182
|
-
phase: "main",
|
|
183
|
-
requires: ["popperOffsets"],
|
|
184
|
-
fn: ({ state: e }) => {
|
|
185
|
-
let t = e.modifiersData.popperOffsets;
|
|
186
|
-
if (!t) return;
|
|
187
|
-
let n = window.innerWidth || document.documentElement.clientWidth, r = e.rects.popper.width, i = e.elements.reference.getBoundingClientRect().left, a = e.elements.popper?.offsetParent, o = a?.getBoundingClientRect?.() || { left: 0 }, s = a?.scrollLeft || 0, c = i - o.left + s, l = c - i, u = l + Y, d = l + n - r - Y;
|
|
188
|
-
i + r <= n ? t.x = c : t.x = c - r, d < u ? t.x = u : t.x = Math.min(Math.max(t.x, u), d);
|
|
189
|
-
}
|
|
190
|
-
}, $ = class i extends e.Component {
|
|
191
|
-
static getResponseKey = (e) => (e || "").replaceAll("{{", "").replaceAll("}}", "");
|
|
192
|
-
static propTypes = {
|
|
193
|
-
session: t.object.isRequired,
|
|
194
|
-
onSessionChange: t.func,
|
|
195
|
-
model: t.object.isRequired
|
|
196
|
-
};
|
|
197
|
-
constructor(t) {
|
|
198
|
-
super(t);
|
|
199
|
-
let n = {}, { model: r, session: a } = t || {}, { markup: o, alwaysShowCorrect: s } = r || {}, { answers: c } = a || {};
|
|
200
|
-
o && (o || "").replace(q, (e) => {
|
|
201
|
-
let t = i.getResponseKey(e), r = c && c[`r${t}`];
|
|
202
|
-
n[`r${t}`] = { value: r?.value || "" };
|
|
203
|
-
}), this.state = {
|
|
204
|
-
session: {
|
|
205
|
-
...t.session,
|
|
206
|
-
answers: n
|
|
207
|
-
},
|
|
208
|
-
activeAnswerBlock: "",
|
|
209
|
-
showCorrect: s || !1,
|
|
210
|
-
tooltipContainerRef: e.createRef()
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
UNSAFE_componentWillMount() {
|
|
214
|
-
typeof window < "u" && (K ||= (l("answerBlock", (e) => ({
|
|
215
|
-
htmlString: `<div class="block-container">
|
|
216
|
-
<div class="block-response" id="${e}Index">R</div>
|
|
217
|
-
<div class="block-math">
|
|
218
|
-
<span id="${e}"></span>
|
|
219
|
-
</div>
|
|
220
|
-
</div>`,
|
|
221
|
-
text: () => "text",
|
|
222
|
-
latex: () => `\\embed{answerBlock}[${e}]`
|
|
223
|
-
})), !0));
|
|
224
|
-
}
|
|
225
|
-
handleAnswerBlockDomUpdate = () => {
|
|
226
|
-
let { model: e } = this.props, { session: t, showCorrect: n } = this.state, r = t.answers;
|
|
227
|
-
this.root && e.disabled && !n && Object.keys(r).forEach((t) => {
|
|
228
|
-
let n = this.root.querySelector(`#${t}`), i = this.root.querySelector(`#${t}Index`);
|
|
229
|
-
if (n) {
|
|
230
|
-
let a = r[t];
|
|
231
|
-
s(n, a && a.value || ""), e.view && (n.parentElement.parentElement.classList.remove("correct"), n.parentElement.parentElement.classList.remove("incorrect")), i.textContent = "R";
|
|
232
|
-
}
|
|
233
|
-
}), x(this.root);
|
|
234
|
-
};
|
|
235
|
-
UNSAFE_componentWillReceiveProps(e) {
|
|
236
|
-
let { model: t } = this.props, { model: n = {} } = e || {}, { markup: a = "", env: o = {} } = t || {}, { markup: s = "", env: c = {}, alwaysShowCorrect: l = !1 } = n, u = (e) => e && e.mode === "evaluate";
|
|
237
|
-
(!u(o) || !u(c)) && this.setState((e) => ({
|
|
238
|
-
...e.session,
|
|
239
|
-
showCorrect: !1
|
|
240
|
-
})), l && this.setState({ showCorrect: !0 });
|
|
241
|
-
let d = a.match(q), f = s.match(q);
|
|
242
|
-
if (!r(d, f)) {
|
|
243
|
-
let e = {}, t = this.state.session.answers;
|
|
244
|
-
(f || []).forEach((n) => {
|
|
245
|
-
let r = i.getResponseKey(n), a = t && t[`r${r}`];
|
|
246
|
-
e[`r${r}`] = { value: a?.value || "" };
|
|
247
|
-
}), this.setState((t) => ({ session: {
|
|
248
|
-
...t.session,
|
|
249
|
-
answers: e
|
|
250
|
-
} }), () => {
|
|
251
|
-
this.props.onSessionChange(this.state.session), this.handleAnswerBlockDomUpdate();
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
shouldComponentUpdate(e, t) {
|
|
256
|
-
let n = r(this.props.model, e.model), i = r(this.state, t);
|
|
257
|
-
return !n || !i;
|
|
258
|
-
}
|
|
259
|
-
componentDidMount() {
|
|
260
|
-
this.handleAnswerBlockDomUpdate(), setTimeout(() => x(this.root), 100);
|
|
261
|
-
}
|
|
262
|
-
componentDidUpdate() {
|
|
263
|
-
this.handleAnswerBlockDomUpdate();
|
|
264
|
-
}
|
|
265
|
-
onSubFieldFocus = (e) => {
|
|
266
|
-
let t = Array.from(this.root?.querySelectorAll(".mq-editable-field") || []).map((e) => ({
|
|
267
|
-
el: e,
|
|
268
|
-
left: e.scrollLeft,
|
|
269
|
-
top: e.scrollTop
|
|
270
|
-
})), n = () => {
|
|
271
|
-
t.forEach(({ el: e, left: t, top: n }) => {
|
|
272
|
-
e.scrollLeft = t, e.scrollTop = n;
|
|
273
|
-
});
|
|
274
|
-
};
|
|
275
|
-
this.setState({ activeAnswerBlock: e }, () => {
|
|
276
|
-
n(), requestAnimationFrame(n), setTimeout(n, 0);
|
|
277
|
-
});
|
|
278
|
-
};
|
|
279
|
-
toNodeData = (e) => {
|
|
280
|
-
if (!e) return;
|
|
281
|
-
let { type: t, value: n } = e;
|
|
282
|
-
return t === "command" || t === "cursor" ? e : t === "answer" ? {
|
|
283
|
-
type: "answer",
|
|
284
|
-
...e
|
|
285
|
-
} : n === "clear" ? { type: "clear" } : {
|
|
286
|
-
type: "write",
|
|
287
|
-
value: n
|
|
288
|
-
};
|
|
289
|
-
};
|
|
290
|
-
setInput = (e) => {
|
|
291
|
-
this.input = e;
|
|
292
|
-
};
|
|
293
|
-
onClick = (e) => {
|
|
294
|
-
let t = this.toNodeData(e);
|
|
295
|
-
t.type === "clear" ? this.input.clear() : t.type === "command" ? Array.isArray(t.value) ? t.value.forEach((e) => {
|
|
296
|
-
this.input.cmd(e);
|
|
297
|
-
}) : this.input.cmd(t.value) : t.type === "cursor" ? this.input.keystroke(t.value) : this.input.write(t.value);
|
|
298
|
-
let n = this.input?.el?.() || this.root, r = [], i = n;
|
|
299
|
-
for (; i && i !== document.body && i !== document.documentElement;) (i.scrollWidth > i.clientWidth || i.scrollHeight > i.clientHeight) && r.push(i), i = i.parentElement;
|
|
300
|
-
document.scrollingElement && r.push(document.scrollingElement);
|
|
301
|
-
let a = r.map((e) => ({
|
|
302
|
-
el: e,
|
|
303
|
-
left: e.scrollLeft,
|
|
304
|
-
top: e.scrollTop
|
|
305
|
-
})), o = {
|
|
306
|
-
x: window.scrollX,
|
|
307
|
-
y: window.scrollY
|
|
308
|
-
}, s = () => {
|
|
309
|
-
a.forEach(({ el: e, left: t, top: n }) => {
|
|
310
|
-
e.scrollLeft = t, e.scrollTop = n;
|
|
311
|
-
}), window.scrollTo(o.x, o.y);
|
|
312
|
-
};
|
|
313
|
-
this.input.focus(), s(), requestAnimationFrame(s), setTimeout(s, 0);
|
|
314
|
-
};
|
|
315
|
-
callOnSessionChange = () => {
|
|
316
|
-
let { onSessionChange: e } = this.props;
|
|
317
|
-
e && e(this.state.session);
|
|
318
|
-
};
|
|
319
|
-
toggleShowCorrect = (e) => {
|
|
320
|
-
this.setState({ showCorrect: e }, this.handleAnswerBlockDomUpdate);
|
|
321
|
-
};
|
|
322
|
-
subFieldChanged = (e, t) => {
|
|
323
|
-
u(), e && this.setState((n) => ({ session: {
|
|
324
|
-
...n.session,
|
|
325
|
-
answers: {
|
|
326
|
-
...n.session.answers,
|
|
327
|
-
[e]: { value: t }
|
|
328
|
-
}
|
|
329
|
-
} }), this.callOnSessionChange);
|
|
330
|
-
};
|
|
331
|
-
getFieldName = (e, t) => {
|
|
332
|
-
let { answers: n } = this.state.session;
|
|
333
|
-
if (Object.keys(n || {}).length) return Object.keys(n).find((n) => {
|
|
334
|
-
let r = t[n];
|
|
335
|
-
return r && r.id == e.id;
|
|
336
|
-
});
|
|
337
|
-
};
|
|
338
|
-
onBlur = (e) => {
|
|
339
|
-
let { relatedTarget: t, currentTarget: n } = e || {};
|
|
340
|
-
function r(e, t = 0) {
|
|
341
|
-
if (!e || t >= 16) return null;
|
|
342
|
-
let n = e.offsetParent;
|
|
343
|
-
return n ? n.getAttribute("role") === "tooltip" ? n : r(n, t + 1) : null;
|
|
344
|
-
}
|
|
345
|
-
function i(e, t = 0) {
|
|
346
|
-
if (!e || t >= 4) return null;
|
|
347
|
-
let n = e?.children?.[0];
|
|
348
|
-
return n ? n.attributes && n.attributes["data-keypad"] ? n : i(n, t + 1) : null;
|
|
349
|
-
}
|
|
350
|
-
let a = r(t), o = a ? i(a) : null;
|
|
351
|
-
(!t || !n || !o?.attributes["data-keypad"]) && this.setState({ activeAnswerBlock: "" });
|
|
352
|
-
};
|
|
353
|
-
setTooltipRef(e) {
|
|
354
|
-
setTimeout(() => {
|
|
355
|
-
if (e && X) {
|
|
356
|
-
let e = document.querySelector("[role='tooltip']");
|
|
357
|
-
e && e.firstChild.setAttribute("tabindex", "-1");
|
|
358
|
-
}
|
|
359
|
-
}, 1);
|
|
360
|
-
}
|
|
361
|
-
renderTeacherInstructions = () => {
|
|
362
|
-
let { model: e } = this.props, { teacherInstructions: t, animationsDisabled: n } = e || {}, r = t && (v(t) || _(t)), i = /* @__PURE__ */ y(O, {
|
|
363
|
-
defaultClassName: "teacher-instructions",
|
|
364
|
-
prompt: t
|
|
365
|
-
});
|
|
366
|
-
return r && /* @__PURE__ */ y(L, { children: n ? i : /* @__PURE__ */ y(A, {
|
|
367
|
-
labels: {
|
|
368
|
-
hidden: "Show Teacher Instructions",
|
|
369
|
-
visible: "Hide Teacher Instructions"
|
|
370
|
-
},
|
|
371
|
-
children: i
|
|
372
|
-
}) });
|
|
373
|
-
};
|
|
374
|
-
renderRationale = () => {
|
|
375
|
-
let { model: e } = this.props, { rationale: t, animationsDisabled: n } = e || {}, r = /* @__PURE__ */ y(O, { prompt: t });
|
|
376
|
-
return t && (v(t) || _(t)) && /* @__PURE__ */ y(L, { children: n ? r : /* @__PURE__ */ y(A, {
|
|
377
|
-
labels: {
|
|
378
|
-
hidden: "Show Rationale",
|
|
379
|
-
visible: "Hide Rationale"
|
|
380
|
-
},
|
|
381
|
-
children: r
|
|
382
|
-
}) });
|
|
383
|
-
};
|
|
384
|
-
renderPlayerContent = () => {
|
|
385
|
-
let { model: e } = this.props, { activeAnswerBlock: t, showCorrect: r, session: i, tooltipContainerRef: s } = this.state, { correctness: c, disabled: l, view: u, responses: d, equationEditor: f, customKeys: p, feedback: m, env: { mode: h } = {}, printMode: g, alwaysShowCorrect: _ } = e || {}, v = n(d), b = Z(p), x = te(e, this.state) || "", C = g && !_;
|
|
386
|
-
return /* @__PURE__ */ y(R, { children: /* @__PURE__ */ y(S, {
|
|
387
|
-
disabled: l,
|
|
388
|
-
markup: e.markup,
|
|
389
|
-
value: {},
|
|
390
|
-
customMarkMarkupComponent: (e) => {
|
|
391
|
-
let n = h === "evaluate" && m && m[e], d = /* @__PURE__ */ y(B, {
|
|
392
|
-
ref: (e) => {
|
|
393
|
-
this.mqStatic = e || this.mqStatic;
|
|
394
|
-
},
|
|
395
|
-
latex: x[e],
|
|
396
|
-
onSubFieldChange: this.subFieldChanged,
|
|
397
|
-
getFieldName: this.getFieldName,
|
|
398
|
-
setInput: this.setInput,
|
|
399
|
-
onSubFieldFocus: this.onSubFieldFocus,
|
|
400
|
-
onBlur: this.onBlur
|
|
401
|
-
});
|
|
402
|
-
return /* @__PURE__ */ y(z, {
|
|
403
|
-
ref: s,
|
|
404
|
-
$incorrect: !v && !n && !r,
|
|
405
|
-
$correct: !v && (n || r),
|
|
406
|
-
$showCorrectness: !v && l && c && !u,
|
|
407
|
-
$correctAnswerShown: r,
|
|
408
|
-
children: /* @__PURE__ */ y(a, {
|
|
409
|
-
ref: (e) => this.setTooltipRef(e),
|
|
410
|
-
enterTouchDelay: 0,
|
|
411
|
-
interactive: !0,
|
|
412
|
-
open: t === `r${e}`,
|
|
413
|
-
slotProps: {
|
|
414
|
-
popper: {
|
|
415
|
-
container: s?.current || void 0,
|
|
416
|
-
placement: "bottom-start",
|
|
417
|
-
sx: {
|
|
418
|
-
backgroundColor: "transparent",
|
|
419
|
-
width: "auto",
|
|
420
|
-
opacity: 1,
|
|
421
|
-
"& .MuiTooltip-arrow": { display: "none" }
|
|
422
|
-
},
|
|
423
|
-
modifiers: [
|
|
424
|
-
{
|
|
425
|
-
name: "preventOverflow",
|
|
426
|
-
enabled: !1
|
|
427
|
-
},
|
|
428
|
-
{
|
|
429
|
-
name: "flip",
|
|
430
|
-
enabled: !1
|
|
431
|
-
},
|
|
432
|
-
ne
|
|
433
|
-
]
|
|
434
|
-
},
|
|
435
|
-
tooltip: { sx: {
|
|
436
|
-
fontSize: "initial",
|
|
437
|
-
backgroundColor: "transparent",
|
|
438
|
-
width: "auto",
|
|
439
|
-
maxWidth: "none",
|
|
440
|
-
marginTop: 0,
|
|
441
|
-
paddingTop: 0,
|
|
442
|
-
boxShadow: "none"
|
|
443
|
-
} }
|
|
444
|
-
},
|
|
445
|
-
title: Object.keys(i.answers).map((e) => e === t && !(r || l) && /* @__PURE__ */ y(V, {
|
|
446
|
-
"data-keypad": !0,
|
|
447
|
-
style: { width: Q(b, f) },
|
|
448
|
-
children: /* @__PURE__ */ y(o, {
|
|
449
|
-
additionalKeys: b,
|
|
450
|
-
mode: f || J,
|
|
451
|
-
onClick: this.onClick
|
|
452
|
-
})
|
|
453
|
-
}, e) || null),
|
|
454
|
-
children: y(C ? H : "div", { children: d })
|
|
455
|
-
})
|
|
456
|
-
});
|
|
457
|
-
}
|
|
458
|
-
}) });
|
|
459
|
-
};
|
|
460
|
-
render() {
|
|
461
|
-
let { model: e } = this.props, { showCorrect: t } = this.state, { prompt: r, env: { mode: i, role: a } = {}, extraCSSRules: o, correctness: s, responses: c, language: l, showNote: u, note: d } = e || {}, f = !n(c) && s && s.correctness !== "correct", p = (t || i === "view" && a === "instructor") && u && d;
|
|
462
|
-
return /* @__PURE__ */ y(P, {
|
|
463
|
-
extraCSSRules: o,
|
|
464
|
-
ref: (e) => {
|
|
465
|
-
let t = w.findDOMNode(e);
|
|
466
|
-
this.root = t || this.root;
|
|
467
|
-
},
|
|
468
|
-
children: /* @__PURE__ */ b(F, { children: [
|
|
469
|
-
i === "gather" && /* @__PURE__ */ y(U, { children: "Math Equation Response Question" }),
|
|
470
|
-
/* @__PURE__ */ y(F, { children: f && /* @__PURE__ */ y(G, {
|
|
471
|
-
language: l,
|
|
472
|
-
show: !0,
|
|
473
|
-
toggled: t,
|
|
474
|
-
onToggle: this.toggleShowCorrect
|
|
475
|
-
}) }),
|
|
476
|
-
this.renderTeacherInstructions(),
|
|
477
|
-
r && /* @__PURE__ */ y(I, { children: /* @__PURE__ */ y(O, { prompt: r }) }),
|
|
478
|
-
/* @__PURE__ */ y(k, {
|
|
479
|
-
false: !0,
|
|
480
|
-
children: this.renderPlayerContent()
|
|
481
|
-
}),
|
|
482
|
-
p && /* @__PURE__ */ y(W, {
|
|
483
|
-
className: "note",
|
|
484
|
-
dangerouslySetInnerHTML: { __html: d }
|
|
485
|
-
}),
|
|
486
|
-
this.renderRationale()
|
|
487
|
-
] })
|
|
488
|
-
});
|
|
489
|
-
}
|
|
490
|
-
};
|
|
491
|
-
//#endregion
|
|
492
|
-
export { $ as default };
|
package/dist/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './delivery/index.js';
|
package/dist/index.iife.d.ts
DELETED