@pie-element/math-inline 12.1.1-next.39 → 12.1.1-next.42

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 (123) hide show
  1. package/author.js +2 -0
  2. package/configure.js +2 -0
  3. package/controller.js +1 -0
  4. package/dist/author/configure.d.ts +25 -0
  5. package/dist/author/configure.js +114 -0
  6. package/dist/author/defaults.d.ts +186 -0
  7. package/dist/author/defaults.js +145 -0
  8. package/dist/author/general-config-block.d.ts +35 -0
  9. package/dist/author/general-config-block.js +390 -0
  10. package/dist/author/index.d.ts +61 -0
  11. package/dist/author/index.js +80 -0
  12. package/dist/author/response.d.ts +40 -0
  13. package/dist/author/response.js +238 -0
  14. package/dist/author/utils.d.ts +14 -0
  15. package/dist/author/utils.js +13 -0
  16. package/dist/browser/assets/Symbola-4c507403.woff2 +0 -0
  17. package/dist/browser/author/index.js +28235 -0
  18. package/dist/browser/author/index.js.map +1 -0
  19. package/dist/browser/controller/index.js +37791 -0
  20. package/dist/browser/controller/index.js.map +1 -0
  21. package/dist/browser/delivery/index.js +134 -0
  22. package/dist/browser/delivery/index.js.map +1 -0
  23. package/dist/browser/dist--pvq7WNe.js +324 -0
  24. package/dist/browser/dist--pvq7WNe.js.map +1 -0
  25. package/dist/browser/dist-CuWXpGIy.js +16888 -0
  26. package/dist/browser/dist-CuWXpGIy.js.map +1 -0
  27. package/dist/browser/dist-DCmVXYeO.js +1528 -0
  28. package/dist/browser/dist-DCmVXYeO.js.map +1 -0
  29. package/dist/browser/editor-runtime/assets/Symbola-4c507403.woff2 +0 -0
  30. package/dist/browser/editor-runtime/author/index.js +11826 -0
  31. package/dist/browser/editor-runtime/author/index.js.map +1 -0
  32. package/dist/browser/editor-runtime/controller/index.js +37791 -0
  33. package/dist/browser/editor-runtime/controller/index.js.map +1 -0
  34. package/dist/browser/editor-runtime/delivery/index.js +134 -0
  35. package/dist/browser/editor-runtime/delivery/index.js.map +1 -0
  36. package/dist/browser/editor-runtime/dist-CiHbVK7d.js +324 -0
  37. package/dist/browser/editor-runtime/dist-CiHbVK7d.js.map +1 -0
  38. package/dist/browser/editor-runtime/dist-DCmVXYeO.js +1528 -0
  39. package/dist/browser/editor-runtime/dist-DCmVXYeO.js.map +1 -0
  40. package/dist/browser/editor-runtime/dist-L9vrtTkN.js +16888 -0
  41. package/dist/browser/editor-runtime/dist-L9vrtTkN.js.map +1 -0
  42. package/dist/browser/editor-runtime/main-WltpU9HP.js +973 -0
  43. package/dist/browser/editor-runtime/main-WltpU9HP.js.map +1 -0
  44. package/dist/browser/editor-runtime/print/index.js +52 -0
  45. package/dist/browser/editor-runtime/print/index.js.map +1 -0
  46. package/dist/browser/main-CKdHiINt.js +973 -0
  47. package/dist/browser/main-CKdHiINt.js.map +1 -0
  48. package/dist/browser/print/index.js +52 -0
  49. package/dist/browser/print/index.js.map +1 -0
  50. package/dist/controller/defaults.d.ts +44 -0
  51. package/dist/controller/defaults.js +39 -0
  52. package/dist/controller/index.d.ts +22 -0
  53. package/dist/controller/index.js +171 -0
  54. package/dist/controller/utils.d.ts +12 -0
  55. package/dist/controller/utils.js +7 -0
  56. package/dist/delivery/index.d.ts +22 -0
  57. package/dist/delivery/index.js +54 -0
  58. package/dist/delivery/main.d.ts +44 -0
  59. package/dist/delivery/main.js +606 -0
  60. package/dist/delivery/simple-question-block.d.ts +27 -0
  61. package/dist/delivery/simple-question-block.js +94 -0
  62. package/dist/delivery/utils.d.ts +12 -0
  63. package/dist/delivery/utils.js +7 -0
  64. package/dist/index.d.ts +1 -0
  65. package/dist/index.iife.d.ts +8 -0
  66. package/dist/index.iife.js +224 -0
  67. package/dist/index.js +2 -0
  68. package/dist/math-inline.css +2 -0
  69. package/dist/print/index.d.ts +15 -0
  70. package/dist/print/index.js +52 -0
  71. package/dist/runtime-support.d.ts +12 -0
  72. package/dist/runtime-support.js +12 -0
  73. package/module/assets/Symbola-4c507403.woff2 +0 -0
  74. package/module/print.js +25525 -0
  75. package/module/print.js.map +1 -0
  76. package/package.json +110 -26
  77. package/print.js +2 -0
  78. package/CHANGELOG.json +0 -2627
  79. package/CHANGELOG.md +0 -2473
  80. package/LICENSE.md +0 -5
  81. package/README.md +0 -3
  82. package/configure/CHANGELOG.json +0 -1652
  83. package/configure/CHANGELOG.md +0 -2101
  84. package/configure/lib/configure.js +0 -186
  85. package/configure/lib/configure.js.map +0 -1
  86. package/configure/lib/defaults.js +0 -185
  87. package/configure/lib/defaults.js.map +0 -1
  88. package/configure/lib/general-config-block.js +0 -525
  89. package/configure/lib/general-config-block.js.map +0 -1
  90. package/configure/lib/index.js +0 -136
  91. package/configure/lib/index.js.map +0 -1
  92. package/configure/lib/response.js +0 -369
  93. package/configure/lib/response.js.map +0 -1
  94. package/configure/lib/utils.js +0 -31
  95. package/configure/lib/utils.js.map +0 -1
  96. package/configure/package.json +0 -29
  97. package/controller/CHANGELOG.json +0 -1002
  98. package/controller/CHANGELOG.md +0 -1536
  99. package/controller/lib/defaults.js +0 -43
  100. package/controller/lib/defaults.js.map +0 -1
  101. package/controller/lib/index.js +0 -383
  102. package/controller/lib/index.js.map +0 -1
  103. package/controller/lib/utils.js +0 -11
  104. package/controller/lib/utils.js.map +0 -1
  105. package/controller/package.json +0 -26
  106. package/docs/config-schema.json +0 -2071
  107. package/docs/config-schema.json.md +0 -1533
  108. package/docs/demo/config.js +0 -8
  109. package/docs/demo/generate.js +0 -41
  110. package/docs/demo/index.html +0 -1
  111. package/docs/demo/session.js +0 -11
  112. package/docs/pie-schema.json +0 -1472
  113. package/docs/pie-schema.json.md +0 -845
  114. package/lib/index.js +0 -93
  115. package/lib/index.js.map +0 -1
  116. package/lib/main.js +0 -1030
  117. package/lib/main.js.map +0 -1
  118. package/lib/print.js +0 -92
  119. package/lib/print.js.map +0 -1
  120. package/lib/simple-question-block.js +0 -148
  121. package/lib/simple-question-block.js.map +0 -1
  122. package/lib/utils.js +0 -11
  123. package/lib/utils.js.map +0 -1
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/math-inline/src/main.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 React from 'react';
10
+ import PropTypes from 'prop-types';
11
+ export declare class Main extends React.Component {
12
+ static propTypes: {
13
+ session: PropTypes.Validator<object>;
14
+ onSessionChange: PropTypes.Requireable<(...args: any[]) => any>;
15
+ model: PropTypes.Validator<object>;
16
+ };
17
+ constructor(props: any);
18
+ UNSAFE_componentWillMount(): void;
19
+ handleAnswerBlockDomUpdate: any;
20
+ countResponseOccurrences(expression: any): any;
21
+ UNSAFE_componentWillReceiveProps(nextProps: any): void;
22
+ shouldComponentUpdate(nextProps: any, nextState: any): boolean;
23
+ componentDidMount(): void;
24
+ componentDidUpdate(prevProps: any, prevState: any): void;
25
+ updateAria: any;
26
+ focusFirstKeypadElement: any;
27
+ handleKeyDown: any;
28
+ onSubFieldFocus: any;
29
+ cleanupKeyDownListener: any;
30
+ componentWillUnmount(): void;
31
+ onDone: any;
32
+ onSimpleResponseChange: any;
33
+ toNodeData: any;
34
+ setInput: any;
35
+ onClick: any;
36
+ callOnSessionChange: any;
37
+ toggleShowCorrect: any;
38
+ subFieldChanged: any;
39
+ getFieldName: any;
40
+ onBlur: any;
41
+ setTooltipRef(ref: any): void;
42
+ render(): React.JSX.Element | null;
43
+ }
44
+ export default Main;
@@ -0,0 +1,606 @@
1
+ import { ResponseTypes as e } from "./utils.js";
2
+ import { SimpleQuestionBlock as t } from "./simple-question-block.js";
3
+ import n from "react";
4
+ import r from "prop-types";
5
+ import i from "@pie-lib/correct-answer-toggle";
6
+ import { HorizontalKeypad as a, applyStaticMath as o, mq as s, registerEmbed as c, updateSpans as l } from "@pie-lib/math-input";
7
+ import * as u from "@pie-lib/render-ui";
8
+ import { Collapsible as d, Feedback 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 { styled as S } from "@mui/material/styles";
12
+ import C from "@mui/material/Tooltip";
13
+ import { isEmpty as ee, isEqual as w } from "@pie-element/shared-lodash";
14
+ import T from "@pie-lib/translator";
15
+ import E from "react-dom";
16
+ //#region src/delivery/main.tsx
17
+ function D(e) {
18
+ return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
19
+ }
20
+ function O(e, t) {
21
+ return !e || D(e) ? e : D(e.default) ? e.default : t && D(e[t]) ? e[t] : t && D(e[t]?.default) ? e[t].default : e;
22
+ }
23
+ var k = O(h, "UiLayout") || O(P.UiLayout, "UiLayout"), A = O(p, "PreviewPrompt") || O(P.PreviewPrompt, "PreviewPrompt"), te = O(m, "Readable") || O(P.Readable, "Readable"), j = O(d, "Collapsible") || O(P.Collapsible, "Collapsible"), ne = O(f, "Feedback") || O(P.Feedback, "Feedback"), M = u, N = M.default, P = N && typeof N == "object" ? N : M, { translator: F } = T, I = !1, L = /\\newline/g, R = /{{response}}/gm, re = 6, z = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
24
+ function ie(e = []) {
25
+ return e.map((e) => ({
26
+ name: e,
27
+ latex: e,
28
+ write: e,
29
+ label: e
30
+ }));
31
+ }
32
+ function B(e, t) {
33
+ let n = e;
34
+ for (; n !== null;) {
35
+ if (t && n === t) return !0;
36
+ n = n.parentNode;
37
+ }
38
+ return !1;
39
+ }
40
+ function ae(e = [], t) {
41
+ return Math.floor(e.length / 5) * 30 + (t === "miscellaneous" ? 600 : 500);
42
+ }
43
+ function oe(e, t) {
44
+ let { config: n, disabled: r } = e || {}, { expression: i, responses: a, printMode: o, alwaysShowCorrect: s } = n || {};
45
+ if (n && i) {
46
+ let e = i;
47
+ if (t.showCorrect) return a && a.length && a[0].answer;
48
+ let n = 1;
49
+ return (e || "").replace(R, function() {
50
+ let e = t.session.answers[`r${n}`];
51
+ if (o && !s) {
52
+ let e = "\\ \\ ".repeat(30) + "\\newline ";
53
+ return `\\MathQuillMathField[r${n++}]{${e.repeat(3)}}`;
54
+ }
55
+ return r ? `\\embed{answerBlock}[r${n++}]` : `\\MathQuillMathField[r${n++}]{${e && e.value || ""}}`;
56
+ }).replace(L, "\\embed{newLine}[]");
57
+ }
58
+ }
59
+ function V(e, t) {
60
+ let n = {};
61
+ if (t.config && t.config.expression) {
62
+ let r = 1;
63
+ (t.config.expression || "").replace(R, () => {
64
+ n[`r${r}`] = { value: e && e.answers && e.answers[`r${r}`] && e.answers[`r${r}`].value || "" }, r += 1;
65
+ });
66
+ }
67
+ return n;
68
+ }
69
+ var H = class extends n.Component {
70
+ static propTypes = {
71
+ session: r.object.isRequired,
72
+ onSessionChange: r.func,
73
+ model: r.object.isRequired
74
+ };
75
+ constructor(e) {
76
+ super(e);
77
+ let { model: t, session: r } = e, i = V(r, t);
78
+ this.state = {
79
+ session: {
80
+ ...e.session,
81
+ answers: i
82
+ },
83
+ activeAnswerBlock: "",
84
+ showCorrect: this.props.model.config.alwaysShowCorrect || !1,
85
+ tooltipContainerRef: n.createRef()
86
+ };
87
+ }
88
+ UNSAFE_componentWillMount() {
89
+ typeof window < "u" && (I ||= (c("answerBlock", (e) => {
90
+ let t = U();
91
+ return {
92
+ htmlString: `<div class="${t.blockContainer}">
93
+ <div class="${t.blockResponse}" id="${e}Index">R</div>
94
+ <div class="${t.blockMath}">
95
+ <span id="${e}"></span>
96
+ </div>
97
+ </div>`,
98
+ text: () => "text",
99
+ latex: () => `\\embed{answerBlock}[${e}]`
100
+ };
101
+ }), !0));
102
+ }
103
+ handleAnswerBlockDomUpdate = () => {
104
+ let { model: e } = this.props, { session: t, showCorrect: n } = this.state, r = t.answers;
105
+ this.root && e.disabled && !n && Object.keys(r).forEach((t) => {
106
+ let n = this.root.querySelector(`#${t}`), i = this.root.querySelector(`#${t}Index`);
107
+ if (n) {
108
+ let a = r[t];
109
+ o(n, a && a.value || ""), e.view && (n.parentElement.parentElement.classList.remove("correct"), n.parentElement.parentElement.classList.remove("incorrect")), i.textContent = "R";
110
+ }
111
+ }), x(this.root);
112
+ };
113
+ countResponseOccurrences(e) {
114
+ let t = e?.match(/\{\{response\}\}/g);
115
+ return t ? t.length : 0;
116
+ }
117
+ UNSAFE_componentWillReceiveProps(e) {
118
+ let { config: t } = this.props.model, { config: n = {} } = e.model || {}, { session: r } = this.props, { session: i = {} } = e || {};
119
+ if (r && i && !w(r.answers, i.answers) && this.setState({ session: {
120
+ ...i,
121
+ answers: V(i, this.props.model)
122
+ } }), t.note && t.language && t.language !== n.language && t.note === F.t("mathInline.primaryCorrectWithAlternates", { lng: t.language }) && (t.note = F.t("mathInline.primaryCorrectWithAlternates", { lng: n.language })), (t.env && t.env.mode !== "evaluate" || n.env && n.env.mode !== "evaluate") && this.setState({
123
+ ...this.state.session,
124
+ showCorrect: !1
125
+ }), n.alwaysShowCorrect && this.setState({ showCorrect: !0 }), this.countResponseOccurrences(t.expression) < this.countResponseOccurrences(n.expression) && setTimeout(() => this.updateAria(), 100), t && t.responses && t.responses.length !== n.responses.length || !t && n && n.responses || t && n && t.expression !== n.expression) {
126
+ let e = {}, t = this.state.session.answers, r = 1;
127
+ (n.expression || "").replace(R, () => {
128
+ e[`r${r}`] = { value: t && t[`r${r}`] && t[`r${r}`].value || "" }, r++;
129
+ }), this.setState((t) => ({ session: {
130
+ ...t.session,
131
+ completeAnswer: this.mqStatic && this.mqStatic.mathField.latex(),
132
+ answers: e
133
+ } }), this.handleAnswerBlockDomUpdate);
134
+ }
135
+ }
136
+ shouldComponentUpdate(e, t) {
137
+ let n = w(this.props.model, e.model), r = w(this.state, t);
138
+ return !n || !r;
139
+ }
140
+ componentDidMount() {
141
+ this.handleAnswerBlockDomUpdate(), this.updateAria(), setTimeout(() => x(this.root), 100);
142
+ }
143
+ componentDidUpdate(e, t) {
144
+ this.handleAnswerBlockDomUpdate(), e.model?.config?.responseType !== this.props.model?.config?.responseType && this.updateAria();
145
+ }
146
+ updateAria = () => {
147
+ this.root && (this.root.querySelectorAll(".mq-selectable").forEach((e) => e.setAttribute("aria-hidden", "true")), this.root.querySelectorAll("textarea").forEach((e, t) => {
148
+ e.setAttribute("aria-label", "Enter answer.");
149
+ let n = `instructions-${t}`, r = e.closest(".mq-textarea");
150
+ if (r) {
151
+ let t = r.querySelector(`#${n}`);
152
+ t || (t = document.createElement("span"), t.id = n, t.className = "sr-only", t.textContent = "This field supports both keypad and keyboard input. Use the keyboard to access and interact with the on-screen math keypad, which accepts LaTeX markup. Use the down arrow key to open the keypad and navigate its buttons. Use the escape key to close the keypad and return to the input field.", r.insertBefore(t, e)), e.setAttribute("aria-describedby", n);
153
+ }
154
+ }));
155
+ };
156
+ focusFirstKeypadElement = () => {
157
+ setTimeout(() => {
158
+ let e = document.querySelector("[data-keypad]");
159
+ if (e) {
160
+ let t = e.querySelector("button, [role='button']");
161
+ t && t.focus();
162
+ }
163
+ }, 0);
164
+ };
165
+ handleKeyDown = (e, t) => {
166
+ let n = B(e.target, this.root), r = this.mqStatic && this.mqStatic.inputRef?.current ? this.mqStatic.inputRef?.current.contains(document.activeElement) : document.activeElement?.getAttribute("aria-label") === "Enter answer.", { key: i, type: a } = e;
167
+ r && (i === "ArrowDown" || a === "click" || a === "touchstart") ? this.state.activeAnswerBlock !== t && n && (this.cleanupKeyDownListener(), this.setState({ activeAnswerBlock: t }, () => {
168
+ this.onSubFieldFocus(t), i === "ArrowDown" && this.focusFirstKeypadElement();
169
+ })) : e.key === "Escape" && this.setState({ activeAnswerBlock: "" });
170
+ };
171
+ onSubFieldFocus = (e) => {
172
+ this.handleEvent || (this.handleEvent = (t) => {
173
+ this.handleKeyDown(t, e);
174
+ }, document.addEventListener("keydown", this.handleEvent), document.addEventListener("click", this.handleEvent), document.addEventListener("touchstart", this.handleEvent));
175
+ };
176
+ cleanupKeyDownListener = () => {
177
+ this.handleEvent &&= (document.removeEventListener("keydown", this.handleEvent), document.removeEventListener("click", this.handleEvent), document.removeEventListener("touchstart", this.handleEvent), null);
178
+ };
179
+ componentWillUnmount() {
180
+ this.cleanupKeyDownListener && this.cleanupKeyDownListener();
181
+ }
182
+ onDone = () => {};
183
+ onSimpleResponseChange = (e) => {
184
+ this.setState((t) => ({ session: {
185
+ ...t.session,
186
+ response: e
187
+ } }), this.callOnSessionChange);
188
+ };
189
+ toNodeData = (e) => {
190
+ if (!e) return;
191
+ let { type: t, value: n } = e;
192
+ return t === "command" || t === "cursor" ? e : t === "answer" ? {
193
+ type: "answer",
194
+ ...e
195
+ } : n === "clear" ? { type: "clear" } : {
196
+ type: "write",
197
+ value: n
198
+ };
199
+ };
200
+ setInput = (e) => {
201
+ this.input = e;
202
+ };
203
+ onClick = (e) => {
204
+ let t = window.scrollX, n = window.scrollY, r = this.toNodeData(e);
205
+ r.type === "clear" ? this.input.clear() : r.type === "command" ? Array.isArray(r.value) ? r.value.forEach((e) => {
206
+ this.input.cmd(e);
207
+ }) : this.input.cmd(r.value) : r.type === "cursor" ? this.input.keystroke(r.value) : this.input.write(r.value), this.input.focus(), requestAnimationFrame(() => {
208
+ window.scrollTo(t, n), requestAnimationFrame(() => window.scrollTo(t, n));
209
+ });
210
+ };
211
+ callOnSessionChange = () => {
212
+ let { onSessionChange: e } = this.props;
213
+ e && e(this.state.session);
214
+ };
215
+ toggleShowCorrect = (e) => {
216
+ this.setState({ showCorrect: e }, this.handleAnswerBlockDomUpdate);
217
+ };
218
+ subFieldChanged = (e, t) => {
219
+ if (l(), e) {
220
+ let n = window.scrollX, r = window.scrollY;
221
+ this.setState((n) => ({ session: {
222
+ ...n.session,
223
+ completeAnswer: this.mqStatic && this.mqStatic.mathField.latex(),
224
+ answers: {
225
+ ...n.session.answers,
226
+ [e]: { value: t }
227
+ }
228
+ } }), () => {
229
+ this.callOnSessionChange(), requestAnimationFrame(() => {
230
+ window.scrollTo(n, r);
231
+ });
232
+ });
233
+ }
234
+ };
235
+ getFieldName = (e, t) => {
236
+ let { answers: n } = this.state.session;
237
+ if (Object.keys(n || {}).length) return Object.keys(n).find((n) => {
238
+ let r = t[n];
239
+ return r && r.id == e.id;
240
+ });
241
+ };
242
+ onBlur = (e) => {
243
+ let { relatedTarget: t, currentTarget: n } = e || {}, r = n && n.closest("[role=tooltip]");
244
+ function i(e, t = 0) {
245
+ if (!e || t >= 16) return null;
246
+ let n = e.offsetParent;
247
+ return n ? n.getAttribute("role") === "tooltip" ? n : i(n, t + 1) : null;
248
+ }
249
+ function a(e, t = 0) {
250
+ if (!e || t >= 4) return null;
251
+ let n = e?.children?.[0];
252
+ return n ? n.attributes && n.attributes["data-keypad"] ? n : a(n, t + 1) : null;
253
+ }
254
+ let o = i(t), s = o ? a(o) : null;
255
+ (!t || !n || !s?.attributes["data-keypad"]) && (r || this.setState({ activeAnswerBlock: "" }));
256
+ };
257
+ setTooltipRef(e) {
258
+ setTimeout(() => {
259
+ if (e && z) {
260
+ let e = document.querySelector("[role='tooltip']");
261
+ e && e.firstChild.setAttribute("tabindex", "-1");
262
+ }
263
+ }, 1);
264
+ }
265
+ render() {
266
+ let { model: n } = this.props, { activeAnswerBlock: r, showCorrect: i, session: o, tooltipContainerRef: c } = this.state, { config: l, correctness: u, disabled: d, extraCSSRules: f, view: p, teacherInstructions: m, rationale: h, feedback: x, animationsDisabled: S, printMode: w, alwaysShowCorrect: T, language: D } = n || {};
267
+ if (!l) return null;
268
+ let { showNote: O, note: k, prompt: M, responses: N, responseType: P, equationEditor: I, customKeys: L, id: R, env: { mode: z, role: B } = {} } = l || {}, V = (i || z === "view" && B === "instructor") && O && k, H = ee(N), U = !H && u && u.correctness !== "correct", ge = d && u, q = ie(L), J = u && u.correct, Y = oe(n, this.state) || "", X = d && !u, _e = w && !T, Z = h && (v(h) || _(h)), Q = m && (v(m) || _(m)), ve = /* @__PURE__ */ y(pe, { children: /* @__PURE__ */ y(s.Static, {
269
+ className: "static-math",
270
+ ref: (e) => {
271
+ e && (this.mqStatic = e);
272
+ },
273
+ latex: Y,
274
+ onSubFieldChange: this.subFieldChanged,
275
+ getFieldName: this.getFieldName,
276
+ setInput: this.setInput,
277
+ onSubFieldFocus: this.onSubFieldFocus,
278
+ onBlur: this.onBlur
279
+ }) }), $ = /* @__PURE__ */ b(G, { children: [
280
+ z === "gather" && /* @__PURE__ */ y(me, { children: "Math Equation Response Question" }),
281
+ X && Q && (S ? /* @__PURE__ */ y("div", { dangerouslySetInnerHTML: { __html: m } }) : /* @__PURE__ */ y(K, {
282
+ labels: {
283
+ hidden: "Show Teacher Instructions",
284
+ visible: "Hide Teacher Instructions"
285
+ },
286
+ children: /* @__PURE__ */ y("div", { dangerouslySetInnerHTML: { __html: m } })
287
+ })),
288
+ M && /* @__PURE__ */ y(ce, { children: /* @__PURE__ */ y(A, { prompt: M }) }),
289
+ _e ? ve : /* @__PURE__ */ y(te, {
290
+ false: !0,
291
+ children: /* @__PURE__ */ b(fe, {
292
+ tabIndex: 0,
293
+ children: [P === e.simple && /* @__PURE__ */ y(t, {
294
+ onSimpleResponseChange: this.onSimpleResponseChange,
295
+ showCorrect: i,
296
+ emptyResponse: H,
297
+ model: n,
298
+ session: o,
299
+ onSubFieldFocus: this.onSubFieldFocus,
300
+ showKeypad: !!r
301
+ }), P === e.advanced && /* @__PURE__ */ y(de, {
302
+ ref: c,
303
+ isIncorrect: !H && !J && !i,
304
+ isCorrect: !H && (J || i),
305
+ showCorrectness: !H && d && u && !p,
306
+ correctAnswerShown: i,
307
+ printCorrect: w && T,
308
+ children: /* @__PURE__ */ y(C, {
309
+ ref: (e) => this.setTooltipRef(e),
310
+ enterTouchDelay: 0,
311
+ interactive: !0,
312
+ open: !!r,
313
+ slotProps: {
314
+ popper: {
315
+ container: c?.current || void 0,
316
+ placement: "bottom-start",
317
+ sx: {
318
+ backgroundColor: "transparent",
319
+ width: "650px",
320
+ opacity: 1,
321
+ "& .MuiTooltip-arrow": { display: "none" }
322
+ },
323
+ modifiers: [
324
+ {
325
+ name: "offset",
326
+ options: { offset: [0, 8] }
327
+ },
328
+ {
329
+ name: "preventOverflow",
330
+ enabled: !0,
331
+ options: {
332
+ boundary: "viewport",
333
+ padding: 8
334
+ }
335
+ },
336
+ {
337
+ name: "computeStyles",
338
+ options: {
339
+ adaptive: !0,
340
+ gpuAcceleration: !0
341
+ }
342
+ },
343
+ {
344
+ name: "flip",
345
+ enabled: !1
346
+ }
347
+ ]
348
+ },
349
+ tooltip: { sx: {
350
+ fontSize: "initial",
351
+ backgroundColor: "transparent",
352
+ width: "600px",
353
+ marginTop: 0,
354
+ paddingTop: 0,
355
+ boxShadow: "none"
356
+ } }
357
+ },
358
+ title: Object.keys(o.answers).map((e) => e === r && !(i || d) && /* @__PURE__ */ y(ue, {
359
+ "data-keypad": !0,
360
+ style: { width: ae(q, I) },
361
+ children: /* @__PURE__ */ y(a, {
362
+ additionalKeys: q,
363
+ mode: I || re,
364
+ onClick: this.onClick
365
+ })
366
+ }, e) || null),
367
+ children: /* @__PURE__ */ y("div", { children: /* @__PURE__ */ y(s.Static, {
368
+ className: "static-math",
369
+ ref: (e) => {
370
+ e && (this.mqStatic = e);
371
+ },
372
+ latex: Y,
373
+ onSubFieldChange: this.subFieldChanged,
374
+ getFieldName: this.getFieldName,
375
+ setInput: this.setInput,
376
+ onSubFieldFocus: this.onSubFieldFocus,
377
+ onBlur: this.onBlur
378
+ }) })
379
+ })
380
+ })]
381
+ })
382
+ }),
383
+ X && V && /* @__PURE__ */ y(le, { dangerouslySetInnerHTML: { __html: `<strong>Note:</strong> ${k}` } }),
384
+ X && Z && (S ? /* @__PURE__ */ y("div", { dangerouslySetInnerHTML: { __html: h } }) : /* @__PURE__ */ y(j, {
385
+ labels: {
386
+ hidden: "Show Rationale",
387
+ visible: "Hide Rationale"
388
+ },
389
+ children: /* @__PURE__ */ y("div", { dangerouslySetInnerHTML: { __html: h } })
390
+ }))
391
+ ] });
392
+ return ge && (U || Q || Z || x) ? /* @__PURE__ */ y(W, {
393
+ extraCSSRules: f,
394
+ ref: (e) => {
395
+ let t = E.findDOMNode(e);
396
+ this.root = t || this.root;
397
+ },
398
+ children: /* @__PURE__ */ y(se, {
399
+ interactive: !0,
400
+ enterTouchDelay: 0,
401
+ placement: "bottom-start",
402
+ slotProps: {
403
+ tooltip: { sx: (e) => ({
404
+ background: `${g.primaryLight()} !important`,
405
+ color: g.text(),
406
+ padding: e.spacing(2),
407
+ border: `1px solid ${g.secondary()}`,
408
+ fontSize: "16px",
409
+ "& :not(.MathJax) > table tr": { "&:nth-child(2n)": { backgroundColor: "unset !important" } }
410
+ }) },
411
+ popper: {
412
+ sx: { opacity: 1 },
413
+ modifiers: [{
414
+ name: "offset",
415
+ options: { offset: [0, 2] }
416
+ }]
417
+ }
418
+ },
419
+ title: /* @__PURE__ */ b("div", { children: [
420
+ /* @__PURE__ */ y(G, { children: U && /* @__PURE__ */ y(he, {
421
+ language: D,
422
+ show: !0,
423
+ toggled: i,
424
+ onToggle: this.toggleShowCorrect
425
+ }) }),
426
+ Q && /* @__PURE__ */ y(K, {
427
+ labels: {
428
+ hidden: "Show Teacher Instructions",
429
+ visible: "Hide Teacher Instructions"
430
+ },
431
+ children: /* @__PURE__ */ y(A, { prompt: m })
432
+ }, "collapsible-teacher-instructions"),
433
+ V && v(k) && /* @__PURE__ */ y(K, {
434
+ labels: {
435
+ hidden: F.t("common:showNote", { lng: D }),
436
+ visible: F.t("common:hideNote", { lng: D })
437
+ },
438
+ children: /* @__PURE__ */ y(A, { prompt: k })
439
+ }, "collapsible-note"),
440
+ Z && /* @__PURE__ */ y(K, {
441
+ labels: {
442
+ hidden: "Show Rationale",
443
+ visible: "Hide Rationale"
444
+ },
445
+ children: /* @__PURE__ */ y(A, { prompt: h })
446
+ }, "collapsible-rationale"),
447
+ x && /* @__PURE__ */ y(ne, {
448
+ correctness: u.correctness,
449
+ feedback: x
450
+ })
451
+ ] }),
452
+ children: $
453
+ })
454
+ }) : /* @__PURE__ */ y(W, {
455
+ id: R,
456
+ extraCSSRules: f,
457
+ ref: (e) => {
458
+ let t = E.findDOMNode(e);
459
+ this.root = t || this.root;
460
+ },
461
+ children: $
462
+ });
463
+ }
464
+ }, U = () => ({
465
+ blockContainer: "block-container",
466
+ blockResponse: "block-response",
467
+ blockMath: "block-math"
468
+ });
469
+ if (typeof document < "u") {
470
+ let e = "math-inline-block-styles";
471
+ if (!document.getElementById(e)) {
472
+ let t = document.createElement("style");
473
+ t.id = e, t.textContent = `
474
+ .block-container {
475
+ margin: 8px !important;
476
+ display: inline-flex;
477
+ border: 2px solid grey !important;
478
+ }
479
+ .block-response {
480
+ color: grey;
481
+ background: #f5f5f5;
482
+ font-size: 0.8rem !important;
483
+ padding: 4px !important;
484
+ display: flex;
485
+ align-items: center;
486
+ justify-content: center;
487
+ border-right: 2px solid #bdbdbd !important;
488
+ flex-shrink: 0;
489
+ flex-grow: 0;
490
+ flex-basis: auto;
491
+ }
492
+ .block-math {
493
+ color: ${g.text()};
494
+ background-color: ${g.background()};
495
+ padding: 4px !important;
496
+ display: flex;
497
+ align-items: center;
498
+ justify-content: center;
499
+ flex-grow: 1;
500
+ }
501
+ .block-math > .mq-math-mode > .mq-hasCursor > .mq-cursor {
502
+ display: none;
503
+ }
504
+ .sr-only {
505
+ position: absolute;
506
+ left: -10000px;
507
+ top: auto;
508
+ width: 1px;
509
+ height: 1px;
510
+ overflow: hidden;
511
+ }
512
+ .static-math > .mq-root-block > .mq-editable-field {
513
+ border-color: ${g.text()};
514
+ }
515
+ `, document.head.appendChild(t);
516
+ }
517
+ }
518
+ var W = S(k)(() => ({
519
+ color: g.text(),
520
+ backgroundColor: g.background(),
521
+ display: "inline-block"
522
+ })), se = S(C)({}), ce = S("div")(({ theme: e }) => ({ marginBottom: e.spacing(2) })), G = S("div")({
523
+ width: "100%",
524
+ position: "relative",
525
+ backgroundColor: g.background(),
526
+ color: g.text()
527
+ }), le = S("div")(({ theme: e }) => ({ paddingBottom: e.spacing(2) })), K = S(j)(({ theme: e }) => ({ marginBottom: e.spacing(2) })), ue = S("div")(({ theme: e }) => ({
528
+ zIndex: 10,
529
+ minWidth: "400px",
530
+ marginTop: e.spacing(2)
531
+ })), de = S("div", { shouldForwardProp: (e) => ![
532
+ "isIncorrect",
533
+ "isCorrect",
534
+ "showCorrectness",
535
+ "correctAnswerShown",
536
+ "printCorrect"
537
+ ].includes(e) })(({ theme: e, isIncorrect: t, isCorrect: n, showCorrectness: r, correctAnswerShown: i, printCorrect: a }) => {
538
+ let o = t ? g.incorrect() : n ? g.correct() : void 0;
539
+ return {
540
+ maxWidth: "fit-content",
541
+ padding: e.spacing(.25),
542
+ ...r && { border: o ? `2px solid ${o} !important` : "2px solid" },
543
+ ...!r && o && { borderColor: `${o} !important` },
544
+ ...i && {
545
+ padding: e.spacing(1),
546
+ letterSpacing: "0.5px"
547
+ },
548
+ ...a && { border: `2px solid ${g.correct()} !important` },
549
+ "& .mq-math-mode": {
550
+ "& .mq-root-block": {
551
+ paddingRight: "0 !important",
552
+ paddingLeft: "0 !important",
553
+ "& .mq-editable-field": {
554
+ minWidth: "10px",
555
+ padding: e.spacing(.4)
556
+ }
557
+ },
558
+ "& sup": { top: 0 }
559
+ }
560
+ };
561
+ }), fe = S("div")({
562
+ position: "relative",
563
+ "& .mq-overarrow-inner": {
564
+ border: "none !important",
565
+ padding: "0 !important"
566
+ },
567
+ "& .mq-overarrow-inner-right": { display: "none !important" },
568
+ "& .mq-overarrow-inner-left": { display: "none !important" },
569
+ "& .mq-overarrow.mq-arrow-both": {
570
+ minWidth: "1.23em",
571
+ "& *": { lineHeight: "1 !important" },
572
+ "&:before": {
573
+ top: "-0.4em",
574
+ left: "-1px"
575
+ },
576
+ "&:after": {
577
+ top: "-2.4em",
578
+ right: "-1px"
579
+ },
580
+ "&.mq-empty:after": { top: "-0.45em" }
581
+ },
582
+ "& .mq-overarrow.mq-arrow-right": { "&:before": {
583
+ top: "-0.4em",
584
+ right: "-1px"
585
+ } },
586
+ "& .mq-longdiv-inner": {
587
+ borderTop: "1px solid !important",
588
+ paddingTop: "1.5px !important"
589
+ },
590
+ "& .mq-parallelogram": { lineHeight: .85 }
591
+ }), pe = S("div")(({ theme: e }) => ({
592
+ marginBottom: e.spacing(1),
593
+ pointerEvents: "none"
594
+ })), me = S("h2")({
595
+ position: "absolute",
596
+ left: "-10000px",
597
+ top: "auto",
598
+ width: "1px",
599
+ height: "1px",
600
+ overflow: "hidden"
601
+ }), he = S(i)(({ theme: e }) => ({
602
+ color: g.text(),
603
+ marginBottom: e.spacing(2)
604
+ }));
605
+ //#endregion
606
+ export { H as Main, H as default };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/math-inline/src/simple-question-block.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 React from 'react';
10
+ import PropTypes from 'prop-types';
11
+ export declare class SimpleQuestionBlock extends React.Component {
12
+ static propTypes: {
13
+ onSimpleResponseChange: PropTypes.Requireable<(...args: any[]) => any>;
14
+ model: PropTypes.Validator<object>;
15
+ emptyResponse: PropTypes.Requireable<boolean>;
16
+ session: PropTypes.Validator<object>;
17
+ showCorrect: PropTypes.Requireable<boolean>;
18
+ onSubFieldFocus: PropTypes.Validator<(...args: any[]) => any>;
19
+ showKeypad: PropTypes.Validator<boolean>;
20
+ };
21
+ constructor(props: any);
22
+ mathToolBarContainsTarget: (e: any) => boolean;
23
+ handleClick: any;
24
+ onFocus: any;
25
+ render(): React.JSX.Element | undefined;
26
+ }
27
+ export default SimpleQuestionBlock;