@pie-lib/mask-markup 4.0.3-next.20261007064237 → 4.0.3-next.20261007175429
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/__tests__/math-control-names.test.d.ts +1 -0
- package/dist/choices/choice.js +26 -25
- package/dist/components/blank.js +69 -64
- package/dist/components/dropdown.js +129 -112
- package/package.json +6 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/choices/choice.js
CHANGED
|
@@ -6,15 +6,15 @@ import { sanitizeModelHtml as a } from "@pie-element/shared-utils";
|
|
|
6
6
|
import { jsx as o } from "react/jsx-runtime";
|
|
7
7
|
import { useDraggable as s } from "@dnd-kit/core";
|
|
8
8
|
import c from "@mui/material/Chip";
|
|
9
|
-
import { color as l } from "@pie-lib/render-ui";
|
|
9
|
+
import { color as l, useMathName as u } from "@pie-lib/render-ui";
|
|
10
10
|
//#region src/choices/choice.tsx
|
|
11
|
-
var
|
|
11
|
+
var d = "MaskBlank", f = r("span")(({ theme: e, disabled: t }) => ({
|
|
12
12
|
border: `solid 0px ${e.palette.primary.main}`,
|
|
13
13
|
margin: e.spacing(.5),
|
|
14
14
|
transform: "translate(0, 0)",
|
|
15
15
|
display: "inline-flex",
|
|
16
16
|
...t && {}
|
|
17
|
-
})),
|
|
17
|
+
})), p = r(c)(({ selected: e }) => ({
|
|
18
18
|
backgroundColor: l.v("pie")("background", l.defaults.WHITE),
|
|
19
19
|
border: e ? `solid 2px ${l.buttonFocusOutline()}` : `1px solid ${l.text()}`,
|
|
20
20
|
opacity: e ? .7 : 1,
|
|
@@ -32,7 +32,7 @@ var u = "MaskBlank", d = r("span")(({ theme: e, disabled: t }) => ({
|
|
|
32
32
|
paddingTop: "12px",
|
|
33
33
|
paddingBottom: "12px",
|
|
34
34
|
"&.Mui-disabled": { opacity: 1 }
|
|
35
|
-
})),
|
|
35
|
+
})), m = r("span")(() => ({
|
|
36
36
|
whiteSpace: "normal",
|
|
37
37
|
"& img": {
|
|
38
38
|
display: "block",
|
|
@@ -41,49 +41,50 @@ var u = "MaskBlank", d = r("span")(({ theme: e, disabled: t }) => ({
|
|
|
41
41
|
"& mjx-frac": { fontSize: "120% !important" },
|
|
42
42
|
"& mjx-mn:has(~ mjx-mfrac), mjx-mfrac ~ mjx-mn": { fontSize: "120% !important" }
|
|
43
43
|
}));
|
|
44
|
-
function
|
|
45
|
-
let
|
|
44
|
+
function h({ choice: n, disabled: r, instanceId: c, selectedItem: l, onSelectClick: h }) {
|
|
45
|
+
let g = t(null), _ = u(g), { attributes: v, listeners: y, setNodeRef: b, isDragging: x } = s({
|
|
46
46
|
id: `choice-${n.id}`,
|
|
47
47
|
data: {
|
|
48
48
|
choice: n,
|
|
49
49
|
instanceId: c,
|
|
50
50
|
fromChoice: !0,
|
|
51
|
-
type:
|
|
51
|
+
type: d
|
|
52
52
|
},
|
|
53
53
|
disabled: r
|
|
54
54
|
});
|
|
55
55
|
e(() => {
|
|
56
|
-
i(
|
|
56
|
+
i(g.current);
|
|
57
57
|
}, [n.value]);
|
|
58
|
-
let
|
|
59
|
-
return /* @__PURE__ */ o(
|
|
60
|
-
ref:
|
|
61
|
-
style:
|
|
62
|
-
width:
|
|
63
|
-
height:
|
|
58
|
+
let S = !!l && l.fromChoice === !0 && l.choice.id === n.id;
|
|
59
|
+
return /* @__PURE__ */ o(f, {
|
|
60
|
+
ref: b,
|
|
61
|
+
style: x ? {
|
|
62
|
+
width: g.current?.offsetWidth || 90,
|
|
63
|
+
height: g.current?.offsetHeight || 32
|
|
64
64
|
} : {},
|
|
65
65
|
disabled: r,
|
|
66
|
-
selected:
|
|
66
|
+
selected: S,
|
|
67
67
|
onClick: (e) => {
|
|
68
|
-
r || (e.stopPropagation(),
|
|
68
|
+
r || (e.stopPropagation(), h?.({
|
|
69
69
|
choice: n,
|
|
70
70
|
instanceId: c,
|
|
71
71
|
fromChoice: !0,
|
|
72
|
-
type:
|
|
72
|
+
type: d
|
|
73
73
|
}));
|
|
74
74
|
},
|
|
75
|
-
...
|
|
76
|
-
...
|
|
77
|
-
|
|
75
|
+
...y,
|
|
76
|
+
...v,
|
|
77
|
+
"aria-label": _,
|
|
78
|
+
children: /* @__PURE__ */ o(p, {
|
|
78
79
|
clickable: !1,
|
|
79
80
|
disabled: r,
|
|
80
|
-
selected:
|
|
81
|
-
ref:
|
|
82
|
-
label: /* @__PURE__ */ o(
|
|
81
|
+
selected: S,
|
|
82
|
+
ref: g,
|
|
83
|
+
label: /* @__PURE__ */ o(m, { dangerouslySetInnerHTML: { __html: a(n.value) } })
|
|
83
84
|
})
|
|
84
85
|
});
|
|
85
86
|
}
|
|
86
|
-
|
|
87
|
+
h.propTypes = {
|
|
87
88
|
choice: n.object.isRequired,
|
|
88
89
|
disabled: n.bool,
|
|
89
90
|
instanceId: n.oneOfType([n.string, n.number]),
|
|
@@ -91,4 +92,4 @@ m.propTypes = {
|
|
|
91
92
|
onSelectClick: n.func
|
|
92
93
|
};
|
|
93
94
|
//#endregion
|
|
94
|
-
export {
|
|
95
|
+
export { d as DRAG_TYPE, h as default };
|
package/dist/components/blank.js
CHANGED
|
@@ -8,13 +8,13 @@ import { sanitizeModelHtml as l } from "@pie-element/shared-utils";
|
|
|
8
8
|
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
9
9
|
import { useDraggable as f, useDroppable as p } from "@dnd-kit/core";
|
|
10
10
|
import m from "@mui/material/Chip";
|
|
11
|
-
import { color as h } from "@pie-lib/render-ui";
|
|
12
|
-
import
|
|
13
|
-
import { grey as
|
|
11
|
+
import { color as h, useMathName as g } from "@pie-lib/render-ui";
|
|
12
|
+
import _ from "@pie-lib/translator";
|
|
13
|
+
import { grey as v } from "@mui/material/colors";
|
|
14
14
|
//#region src/components/blank.tsx
|
|
15
|
-
var { translator:
|
|
15
|
+
var { translator: y } = _;
|
|
16
16
|
c("pie-lib:mask-markup:blank");
|
|
17
|
-
var
|
|
17
|
+
var b = o("span")(({ dragged: e, over: t, selected: n, showsPointerCursor: r }) => ({
|
|
18
18
|
border: `solid 0px ${h.primary()}`,
|
|
19
19
|
display: "inline-flex",
|
|
20
20
|
whiteSpace: "nowrap",
|
|
@@ -23,10 +23,10 @@ var y = o("span")(({ dragged: e, over: t, selected: n, showsPointerCursor: r })
|
|
|
23
23
|
...t && { whiteSpace: "nowrap" },
|
|
24
24
|
...(e || n) && { opacity: .5 },
|
|
25
25
|
...r && { "&:hover": { cursor: "pointer" } }
|
|
26
|
-
})),
|
|
26
|
+
})), x = o("span")({
|
|
27
27
|
display: "inline-flex",
|
|
28
28
|
touchAction: "none"
|
|
29
|
-
}),
|
|
29
|
+
}), S = o(m)(() => ({
|
|
30
30
|
backgroundColor: h.background(),
|
|
31
31
|
border: `2px dashed ${h.text()}`,
|
|
32
32
|
touchAction: "none",
|
|
@@ -41,13 +41,13 @@ var y = o("span")(({ dragged: e, over: t, selected: n, showsPointerCursor: r })
|
|
|
41
41
|
overflow: "hidden"
|
|
42
42
|
},
|
|
43
43
|
"&.parentOver": {
|
|
44
|
-
border: `1px solid ${
|
|
45
|
-
backgroundColor: `${
|
|
44
|
+
border: `1px solid ${v[500]}`,
|
|
45
|
+
backgroundColor: `${v[300]}`
|
|
46
46
|
},
|
|
47
47
|
"&.correct": { border: `solid 1px ${h.correct()}` },
|
|
48
48
|
"&.incorrect": { border: `solid 1px ${h.incorrect()}` },
|
|
49
49
|
"&.Mui-disabled": { opacity: 1 }
|
|
50
|
-
})),
|
|
50
|
+
})), C = o("span")(() => ({
|
|
51
51
|
whiteSpace: "normal",
|
|
52
52
|
pointerEvents: "none",
|
|
53
53
|
"& img": {
|
|
@@ -76,8 +76,8 @@ var y = o("span")(({ dragged: e, over: t, selected: n, showsPointerCursor: r })
|
|
|
76
76
|
transform: "translateY(-50%)"
|
|
77
77
|
}
|
|
78
78
|
}));
|
|
79
|
-
function
|
|
80
|
-
let _ = r(null), v = r(null), y = r(null), b = r(!1), [
|
|
79
|
+
function w({ disabled: a, choice: o, isOver: c, isDragging: f, dragItem: p, correct: m, emptyResponseAreaWidth: h, emptyResponseAreaHeight: g }) {
|
|
80
|
+
let _ = r(null), v = r(null), y = r(null), b = r(!1), [x, w] = i({
|
|
81
81
|
height: 0,
|
|
82
82
|
width: 0
|
|
83
83
|
}), T = () => {
|
|
@@ -106,8 +106,8 @@ function C({ disabled: a, choice: o, isOver: c, isDragging: f, dragItem: p, corr
|
|
|
106
106
|
}, k = () => {
|
|
107
107
|
let e = isNaN(parseFloat(h)) ? 0 : parseFloat(h), t = isNaN(parseFloat(g)) ? 0 : parseFloat(g);
|
|
108
108
|
return {
|
|
109
|
-
height:
|
|
110
|
-
width:
|
|
109
|
+
height: x.height || t,
|
|
110
|
+
width: x.width || e,
|
|
111
111
|
...e ? {} : { minWidth: 90 },
|
|
112
112
|
...t ? {} : { minHeight: 32 }
|
|
113
113
|
};
|
|
@@ -149,12 +149,12 @@ function C({ disabled: a, choice: o, isOver: c, isDragging: f, dragItem: p, corr
|
|
|
149
149
|
width: y.current?.width,
|
|
150
150
|
height: y.current?.height
|
|
151
151
|
} : k();
|
|
152
|
-
return /* @__PURE__ */ u(
|
|
152
|
+
return /* @__PURE__ */ u(S, {
|
|
153
153
|
clickable: !1,
|
|
154
154
|
disabled: a,
|
|
155
155
|
ref: _,
|
|
156
156
|
component: "span",
|
|
157
|
-
label: /* @__PURE__ */ d(t.Fragment, { children: [/* @__PURE__ */ u(
|
|
157
|
+
label: /* @__PURE__ */ d(t.Fragment, { children: [/* @__PURE__ */ u(C, {
|
|
158
158
|
ref: v,
|
|
159
159
|
draggable: !0,
|
|
160
160
|
className: e({
|
|
@@ -162,7 +162,7 @@ function C({ disabled: a, choice: o, isOver: c, isDragging: f, dragItem: p, corr
|
|
|
162
162
|
hidden: A
|
|
163
163
|
}),
|
|
164
164
|
dangerouslySetInnerHTML: { __html: l(j) }
|
|
165
|
-
}), A && /* @__PURE__ */ u(
|
|
165
|
+
}), A && /* @__PURE__ */ u(C, {
|
|
166
166
|
draggable: !0,
|
|
167
167
|
className: e({
|
|
168
168
|
over: c,
|
|
@@ -180,10 +180,10 @@ function C({ disabled: a, choice: o, isOver: c, isDragging: f, dragItem: p, corr
|
|
|
180
180
|
style: M
|
|
181
181
|
});
|
|
182
182
|
}
|
|
183
|
-
|
|
183
|
+
w.defaultProps = {
|
|
184
184
|
emptyResponseAreaWidth: 0,
|
|
185
185
|
emptyResponseAreaHeight: 0
|
|
186
|
-
},
|
|
186
|
+
}, w.propTypes = {
|
|
187
187
|
id: a.oneOfType([a.string, a.number]),
|
|
188
188
|
disabled: a.bool,
|
|
189
189
|
duplicates: a.bool,
|
|
@@ -196,70 +196,75 @@ C.defaultProps = {
|
|
|
196
196
|
emptyResponseAreaHeight: a.oneOfType([a.string, a.number]),
|
|
197
197
|
instanceId: a.string
|
|
198
198
|
};
|
|
199
|
-
function
|
|
200
|
-
let [
|
|
199
|
+
function T({ id: e, disabled: t, duplicates: n, choice: a, correct: o, onChange: s, emptyResponseAreaWidth: c, emptyResponseAreaHeight: l, instanceId: d, language: m, selectedItem: h, onSelectClick: _, onPlacementClick: v }) {
|
|
200
|
+
let [S, C] = i(!1), T = r(null), E = g(T), D = {
|
|
201
201
|
id: e,
|
|
202
|
-
choice:
|
|
203
|
-
instanceId:
|
|
202
|
+
choice: a,
|
|
203
|
+
instanceId: d,
|
|
204
204
|
fromChoice: !1,
|
|
205
205
|
type: "MaskBlank"
|
|
206
|
-
}, { attributes:
|
|
206
|
+
}, { attributes: O, listeners: k, setNodeRef: A, isDragging: j } = f({
|
|
207
207
|
id: `mask-blank-drag-${e}`,
|
|
208
|
-
disabled: t || !
|
|
209
|
-
data:
|
|
210
|
-
attributes: { tabIndex:
|
|
211
|
-
}), { setNodeRef:
|
|
208
|
+
disabled: t || !a,
|
|
209
|
+
data: D,
|
|
210
|
+
attributes: { tabIndex: a && !t ? 0 : -1 }
|
|
211
|
+
}), { setNodeRef: M, isOver: N, active: P } = p({
|
|
212
212
|
id: `mask-blank-drop-${e}`,
|
|
213
213
|
data: {
|
|
214
214
|
id: e,
|
|
215
215
|
accepts: ["MaskBlank"],
|
|
216
|
-
instanceId:
|
|
216
|
+
instanceId: d
|
|
217
217
|
}
|
|
218
|
-
}),
|
|
219
|
-
t || (
|
|
220
|
-
},
|
|
221
|
-
(e.code === "Space" || e.code === "Enter") && (e.preventDefault(),
|
|
222
|
-
},
|
|
223
|
-
return /* @__PURE__ */ u(
|
|
224
|
-
ref:
|
|
225
|
-
role:
|
|
226
|
-
"aria-label":
|
|
227
|
-
lng:
|
|
218
|
+
}), F = !!h && h.fromChoice === !1 && h.id === e, I = () => {
|
|
219
|
+
t || (F ? _?.(D) : h ? v?.(e) : a && _?.(D));
|
|
220
|
+
}, L = !a && !t, R = !!a && !t, z = (e) => {
|
|
221
|
+
(e.code === "Space" || e.code === "Enter") && (e.preventDefault(), I());
|
|
222
|
+
}, B = !!h, V = P ? N : N || B && S && !t;
|
|
223
|
+
return /* @__PURE__ */ u(b, {
|
|
224
|
+
ref: M,
|
|
225
|
+
role: L ? "button" : "group",
|
|
226
|
+
"aria-label": y.t("dragInTheBlank.blank", {
|
|
227
|
+
lng: m,
|
|
228
228
|
index: Number(e) + 1
|
|
229
229
|
}),
|
|
230
|
-
tabIndex:
|
|
231
|
-
onClick:
|
|
232
|
-
onKeyDown:
|
|
233
|
-
onMouseEnter: () =>
|
|
234
|
-
onMouseLeave: () =>
|
|
235
|
-
dragged:
|
|
236
|
-
over:
|
|
237
|
-
selected:
|
|
238
|
-
showsPointerCursor:
|
|
239
|
-
children: /* @__PURE__ */ u(
|
|
240
|
-
ref:
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
230
|
+
tabIndex: L ? 0 : -1,
|
|
231
|
+
onClick: I,
|
|
232
|
+
onKeyDown: L ? z : void 0,
|
|
233
|
+
onMouseEnter: () => C(!0),
|
|
234
|
+
onMouseLeave: () => C(!1),
|
|
235
|
+
dragged: j,
|
|
236
|
+
over: V,
|
|
237
|
+
selected: F,
|
|
238
|
+
showsPointerCursor: B && !t,
|
|
239
|
+
children: /* @__PURE__ */ u(x, {
|
|
240
|
+
ref: (e) => {
|
|
241
|
+
T.current = e, A(e);
|
|
242
|
+
},
|
|
243
|
+
...R ? {
|
|
244
|
+
...O,
|
|
245
|
+
"aria-label": E
|
|
246
|
+
} : {},
|
|
247
|
+
...k,
|
|
248
|
+
children: /* @__PURE__ */ u(w, {
|
|
244
249
|
id: e,
|
|
245
250
|
disabled: t,
|
|
246
251
|
duplicates: n,
|
|
247
|
-
choice:
|
|
248
|
-
isOver:
|
|
249
|
-
dragItem:
|
|
250
|
-
correct:
|
|
251
|
-
onChange:
|
|
252
|
-
emptyResponseAreaWidth:
|
|
253
|
-
emptyResponseAreaHeight:
|
|
254
|
-
instanceId:
|
|
252
|
+
choice: a,
|
|
253
|
+
isOver: V,
|
|
254
|
+
dragItem: P?.data?.current,
|
|
255
|
+
correct: o,
|
|
256
|
+
onChange: s,
|
|
257
|
+
emptyResponseAreaWidth: c,
|
|
258
|
+
emptyResponseAreaHeight: l,
|
|
259
|
+
instanceId: d
|
|
255
260
|
})
|
|
256
261
|
})
|
|
257
262
|
});
|
|
258
263
|
}
|
|
259
|
-
|
|
264
|
+
T.defaultProps = {
|
|
260
265
|
emptyResponseAreaWidth: 0,
|
|
261
266
|
emptyResponseAreaHeight: 0
|
|
262
|
-
},
|
|
267
|
+
}, T.propTypes = {
|
|
263
268
|
id: a.oneOfType([a.string, a.number]),
|
|
264
269
|
disabled: a.bool,
|
|
265
270
|
duplicates: a.bool,
|
|
@@ -275,4 +280,4 @@ w.defaultProps = {
|
|
|
275
280
|
onPlacementClick: a.func
|
|
276
281
|
};
|
|
277
282
|
//#endregion
|
|
278
|
-
export {
|
|
283
|
+
export { T as default };
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import e from "react";
|
|
2
|
-
import
|
|
3
|
-
import { styled as
|
|
4
|
-
import { renderMath as
|
|
5
|
-
import { sanitizeModelHtml as
|
|
6
|
-
import { Fragment as
|
|
7
|
-
import * as
|
|
8
|
-
import { InlineMenu as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
1
|
+
import e, { useRef as t } from "react";
|
|
2
|
+
import n from "prop-types";
|
|
3
|
+
import { styled as r } from "@mui/material/styles";
|
|
4
|
+
import { renderMath as i } from "@pie-element/shared-math-rendering-mathjax";
|
|
5
|
+
import { sanitizeModelHtml as a } from "@pie-element/shared-utils";
|
|
6
|
+
import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
7
|
+
import * as l from "@pie-lib/render-ui";
|
|
8
|
+
import { InlineMenu as u, MathName as d, color as f, createUniqueId as p, useMathName as m } from "@pie-lib/render-ui";
|
|
9
|
+
import h from "@pie-lib/translator";
|
|
10
|
+
import g from "@mui/material/Button";
|
|
11
|
+
import _ from "@mui/material/InputLabel";
|
|
12
|
+
import v from "@mui/material/MenuItem";
|
|
13
|
+
import y from "@mui/icons-material/ArrowDropDown";
|
|
14
|
+
import b from "@mui/icons-material/ArrowDropUp";
|
|
15
|
+
import x from "@mui/icons-material/Close";
|
|
16
|
+
import S from "@mui/icons-material/Check";
|
|
17
17
|
//#region src/components/dropdown.tsx
|
|
18
|
-
function
|
|
18
|
+
function C(e) {
|
|
19
19
|
return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
return !e ||
|
|
21
|
+
function w(e, t) {
|
|
22
|
+
return !e || C(e) ? e : C(e.default) ? e.default : t && C(e[t]) ? e[t] : t && C(e[t]?.default) ? e[t].default : e;
|
|
23
23
|
}
|
|
24
|
-
var
|
|
25
|
-
color:
|
|
26
|
-
border: `1px solid ${
|
|
24
|
+
var T = w(u, "InlineMenu") || w(O.InlineMenu, "InlineMenu"), E = l, D = E.default, O = D && typeof D == "object" ? D : E, { translator: k } = h, A = f.v("pie"), j = r(g)(() => ({
|
|
25
|
+
color: f.text(),
|
|
26
|
+
border: `1px solid ${f.borderGray()}`,
|
|
27
27
|
borderRadius: "4px",
|
|
28
28
|
justifyContent: "space-between",
|
|
29
|
-
backgroundColor:
|
|
29
|
+
backgroundColor: f.background(),
|
|
30
30
|
position: "relative",
|
|
31
31
|
height: "45px",
|
|
32
32
|
width: "fit-content",
|
|
@@ -38,29 +38,29 @@ var S = x(l, "InlineMenu") || x(T.InlineMenu, "InlineMenu"), C = c, w = C.defaul
|
|
|
38
38
|
right: "4px",
|
|
39
39
|
top: "calc(50% - 12px)",
|
|
40
40
|
pointerEvents: "none",
|
|
41
|
-
color:
|
|
41
|
+
color: f.text(),
|
|
42
42
|
marginLeft: "5px"
|
|
43
43
|
},
|
|
44
44
|
"&.Mui-focusVisible": {
|
|
45
|
-
outline: `3px solid ${
|
|
45
|
+
outline: `3px solid ${f.tertiary()}`,
|
|
46
46
|
outlineOffset: "2px",
|
|
47
47
|
borderWidth: "3px"
|
|
48
48
|
},
|
|
49
|
-
"&.Mui-disabled": { color:
|
|
49
|
+
"&.Mui-disabled": { color: f.disabledText() },
|
|
50
50
|
"&.disabledCorrect": {
|
|
51
51
|
borderWidth: "2px",
|
|
52
|
-
borderColor:
|
|
53
|
-
color: `${
|
|
52
|
+
borderColor: f.correct(),
|
|
53
|
+
color: `${f.text()} !important`
|
|
54
54
|
},
|
|
55
55
|
"&.disabledIncorrect": {
|
|
56
56
|
borderWidth: "2px",
|
|
57
|
-
borderColor:
|
|
58
|
-
color: `${
|
|
57
|
+
borderColor: f.incorrectWithIcon(),
|
|
58
|
+
color: `${f.text()} !important`
|
|
59
59
|
}
|
|
60
|
-
})),
|
|
61
|
-
"& .MuiPaper-root": { backgroundColor:
|
|
60
|
+
})), M = r(T)(() => ({
|
|
61
|
+
"& .MuiPaper-root": { backgroundColor: A("background", f.defaults.WHITE) },
|
|
62
62
|
"& .MuiList-root": { padding: 0 }
|
|
63
|
-
})),
|
|
63
|
+
})), N = r(v)(() => ({
|
|
64
64
|
height: 24,
|
|
65
65
|
overflow: "hidden",
|
|
66
66
|
fontSize: "1rem",
|
|
@@ -68,42 +68,42 @@ var S = x(l, "InlineMenu") || x(T.InlineMenu, "InlineMenu"), C = c, w = C.defaul
|
|
|
68
68
|
fontFamily: "inherit",
|
|
69
69
|
lineHeight: "1.5em",
|
|
70
70
|
whiteSpace: "nowrap",
|
|
71
|
-
color:
|
|
72
|
-
backgroundColor:
|
|
71
|
+
color: f.text(),
|
|
72
|
+
backgroundColor: f.background(),
|
|
73
73
|
"&.Mui-focusVisible": {
|
|
74
|
-
outline: `3px solid ${
|
|
74
|
+
outline: `3px solid ${f.tertiary()}`,
|
|
75
75
|
outlineOffset: "-1px",
|
|
76
|
-
color:
|
|
77
|
-
backgroundColor:
|
|
76
|
+
color: f.text(),
|
|
77
|
+
backgroundColor: f.background()
|
|
78
78
|
},
|
|
79
79
|
"&:hover": {
|
|
80
|
-
color:
|
|
81
|
-
backgroundColor:
|
|
80
|
+
color: f.text(),
|
|
81
|
+
backgroundColor: f.dropdownBackground()
|
|
82
82
|
},
|
|
83
83
|
boxSizing: "border-box",
|
|
84
84
|
padding: "16px 8px",
|
|
85
85
|
borderRadius: "4px",
|
|
86
86
|
"&.selected": {
|
|
87
|
-
color: `${
|
|
88
|
-
backgroundColor: `${
|
|
87
|
+
color: `${f.text()} !important`,
|
|
88
|
+
backgroundColor: `${f.background()} !important`,
|
|
89
89
|
"&:hover": {
|
|
90
|
-
color:
|
|
91
|
-
backgroundColor: `${
|
|
90
|
+
color: f.text(),
|
|
91
|
+
backgroundColor: `${f.dropdownBackground()} !important`
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
})),
|
|
94
|
+
})), P = r("span")(() => ({ fontSize: "max(1rem, 14px)" })), F = r("span")(() => ({
|
|
95
95
|
fontSize: "max(1rem, 14px)",
|
|
96
96
|
flexShrink: 0,
|
|
97
97
|
paddingLeft: "8px"
|
|
98
|
-
})),
|
|
98
|
+
})), I = r(_)(() => ({
|
|
99
99
|
position: "absolute",
|
|
100
100
|
left: "-10000px",
|
|
101
101
|
top: "auto",
|
|
102
102
|
width: "1px",
|
|
103
103
|
height: "1px",
|
|
104
104
|
overflow: "hidden"
|
|
105
|
-
})),
|
|
106
|
-
color: `${
|
|
105
|
+
})), L = r(S)(() => ({
|
|
106
|
+
color: `${f.white()} !important`,
|
|
107
107
|
position: "absolute",
|
|
108
108
|
top: "-8px !important",
|
|
109
109
|
left: "-8px",
|
|
@@ -111,10 +111,10 @@ var S = x(l, "InlineMenu") || x(T.InlineMenu, "InlineMenu"), C = c, w = C.defaul
|
|
|
111
111
|
borderRadius: "50%",
|
|
112
112
|
fontSize: "16px",
|
|
113
113
|
padding: "2px",
|
|
114
|
-
"&.correct": { backgroundColor:
|
|
115
|
-
"&.incorrect": { backgroundColor:
|
|
116
|
-
})),
|
|
117
|
-
color: `${
|
|
114
|
+
"&.correct": { backgroundColor: f.correct() },
|
|
115
|
+
"&.incorrect": { backgroundColor: f.incorrectWithIcon() }
|
|
116
|
+
})), R = r(x)(() => ({
|
|
117
|
+
color: `${f.white()} !important`,
|
|
118
118
|
position: "absolute",
|
|
119
119
|
top: "-8px !important",
|
|
120
120
|
left: "-8px",
|
|
@@ -122,23 +122,36 @@ var S = x(l, "InlineMenu") || x(T.InlineMenu, "InlineMenu"), C = c, w = C.defaul
|
|
|
122
122
|
borderRadius: "50%",
|
|
123
123
|
fontSize: "16px",
|
|
124
124
|
padding: "2px",
|
|
125
|
-
"&.correct": { backgroundColor:
|
|
126
|
-
"&.incorrect": { backgroundColor:
|
|
127
|
-
})),
|
|
125
|
+
"&.correct": { backgroundColor: f.correct() },
|
|
126
|
+
"&.incorrect": { backgroundColor: f.incorrectWithIcon() }
|
|
127
|
+
})), z = ({ label: e, selected: n, labelRef: r, ...i }) => {
|
|
128
|
+
let o = t(null), l = m(o);
|
|
129
|
+
return /* @__PURE__ */ c(N, {
|
|
130
|
+
...i,
|
|
131
|
+
selected: n,
|
|
132
|
+
"aria-label": l,
|
|
133
|
+
children: [/* @__PURE__ */ s(P, {
|
|
134
|
+
ref: (e) => {
|
|
135
|
+
o.current = e, r(e);
|
|
136
|
+
},
|
|
137
|
+
dangerouslySetInnerHTML: { __html: a(e) }
|
|
138
|
+
}), /* @__PURE__ */ s(F, { dangerouslySetInnerHTML: { __html: n ? " ✓" : "" } })]
|
|
139
|
+
});
|
|
140
|
+
}, B = class extends e.Component {
|
|
128
141
|
static propTypes = {
|
|
129
|
-
id:
|
|
130
|
-
value:
|
|
131
|
-
disabled:
|
|
132
|
-
onChange:
|
|
133
|
-
correct:
|
|
134
|
-
choices:
|
|
135
|
-
value:
|
|
136
|
-
label:
|
|
142
|
+
id: n.string,
|
|
143
|
+
value: n.string,
|
|
144
|
+
disabled: n.bool,
|
|
145
|
+
onChange: n.func,
|
|
146
|
+
correct: n.bool,
|
|
147
|
+
choices: n.arrayOf(n.shape({
|
|
148
|
+
value: n.string,
|
|
149
|
+
label: n.string
|
|
137
150
|
})),
|
|
138
|
-
showCorrectAnswer:
|
|
139
|
-
singleQuery:
|
|
140
|
-
correctValue:
|
|
141
|
-
language:
|
|
151
|
+
showCorrectAnswer: n.bool,
|
|
152
|
+
singleQuery: n.bool,
|
|
153
|
+
correctValue: n.string,
|
|
154
|
+
language: n.string
|
|
142
155
|
};
|
|
143
156
|
constructor(t) {
|
|
144
157
|
super(t), this.state = {
|
|
@@ -146,7 +159,7 @@ var S = x(l, "InlineMenu") || x(T.InlineMenu, "InlineMenu"), C = c, w = C.defaul
|
|
|
146
159
|
highlightedOptionId: null,
|
|
147
160
|
menuWidth: null,
|
|
148
161
|
previewValue: null
|
|
149
|
-
}, this.hiddenRef = e.createRef(), this.buttonRef = e.createRef(), this.previewRef = e.createRef(), this.elementRefs = [], this.idPrefix =
|
|
162
|
+
}, this.hiddenRef = e.createRef(), this.buttonRef = e.createRef(), this.previewRef = e.createRef(), this.elementRefs = [], this.idPrefix = p(`dropdown-${t.id}`);
|
|
150
163
|
}
|
|
151
164
|
optionId = (e) => `${this.idPrefix}-option-${e}`;
|
|
152
165
|
componentDidMount() {
|
|
@@ -156,13 +169,13 @@ var S = x(l, "InlineMenu") || x(T.InlineMenu, "InlineMenu"), C = c, w = C.defaul
|
|
|
156
169
|
let n = this.hiddenRef.current;
|
|
157
170
|
if (!t.anchorEl && this.state.anchorEl && this.elementRefs.forEach((e) => {
|
|
158
171
|
if (!e) return;
|
|
159
|
-
let t = e.querySelector("[data-latex], [data-raw]"), n = e.querySelector("mjx-container"),
|
|
160
|
-
t && (!
|
|
172
|
+
let t = e.querySelector("[data-latex], [data-raw]"), n = e.querySelector("mjx-container"), r = e.querySelector("[data-math-handled=\"true\"]");
|
|
173
|
+
t && (!r || !n) && i(e);
|
|
161
174
|
}), n) {
|
|
162
175
|
let e = n.clientWidth;
|
|
163
176
|
e !== this.state.menuWidth && (this.elementRefs.forEach((e) => {
|
|
164
|
-
e &&
|
|
165
|
-
}),
|
|
177
|
+
e && i(e);
|
|
178
|
+
}), i(n), this.setState({ menuWidth: e }));
|
|
166
179
|
}
|
|
167
180
|
}
|
|
168
181
|
handleClick = (e) => {
|
|
@@ -207,14 +220,14 @@ var S = x(l, "InlineMenu") || x(T.InlineMenu, "InlineMenu"), C = c, w = C.defaul
|
|
|
207
220
|
return n ? n.label.trim() : void 0;
|
|
208
221
|
}
|
|
209
222
|
render() {
|
|
210
|
-
let { id: e, correct: t, disabled: n, value: r, choices:
|
|
211
|
-
this.elementRefs = [], n && t !== void 0 && (
|
|
212
|
-
let
|
|
213
|
-
lng:
|
|
214
|
-
index:
|
|
215
|
-
}),
|
|
216
|
-
return n && t !== void 0 && (
|
|
217
|
-
/* @__PURE__ */
|
|
223
|
+
let { id: e, correct: t, disabled: n, value: r, choices: i, showCorrectAnswer: l, singleQuery: u, correctValue: f, language: p } = this.props, { anchorEl: m } = this.state, h = !!m, g = `${this.idPrefix}-button`, _ = `${this.idPrefix}-menu`, v = `${this.idPrefix}-listbox`, x = `${this.idPrefix}-value`, S = `${this.idPrefix}-value-name`, C;
|
|
224
|
+
this.elementRefs = [], n && t !== void 0 && (C = t || l ? "disabledCorrect" : "disabledIncorrect");
|
|
225
|
+
let w = parseInt(e, 10) + 1, T = `${this.idPrefix}-query-label`, E = u ? k.t("inlineDropdown.query", { lng: p }) : k.t("inlineDropdown.queryNumber", {
|
|
226
|
+
lng: p,
|
|
227
|
+
index: w
|
|
228
|
+
}), D = null;
|
|
229
|
+
return n && t !== void 0 && (D = t || l ? /* @__PURE__ */ s(L, { className: "correct" }) : /* @__PURE__ */ s(R, { className: "incorrect" })), /* @__PURE__ */ c(o, { children: [
|
|
230
|
+
/* @__PURE__ */ s("div", {
|
|
218
231
|
ref: this.hiddenRef,
|
|
219
232
|
style: {
|
|
220
233
|
position: "absolute",
|
|
@@ -224,50 +237,56 @@ var S = x(l, "InlineMenu") || x(T.InlineMenu, "InlineMenu"), C = c, w = C.defaul
|
|
|
224
237
|
},
|
|
225
238
|
tabIndex: -1,
|
|
226
239
|
"aria-hidden": "true",
|
|
227
|
-
children: (
|
|
240
|
+
children: (i || []).map((e, t) => /* @__PURE__ */ s(N, {
|
|
228
241
|
tabIndex: -1,
|
|
229
242
|
"aria-hidden": "true",
|
|
230
|
-
children: /* @__PURE__ */
|
|
243
|
+
children: /* @__PURE__ */ s(P, { dangerouslySetInnerHTML: { __html: a(e.label) } })
|
|
231
244
|
}, t))
|
|
232
245
|
}),
|
|
233
|
-
/* @__PURE__ */
|
|
234
|
-
id:
|
|
246
|
+
/* @__PURE__ */ s(I, {
|
|
247
|
+
id: T,
|
|
235
248
|
tabIndex: -1,
|
|
236
249
|
"aria-hidden": "true",
|
|
237
|
-
children:
|
|
250
|
+
children: E
|
|
238
251
|
}),
|
|
239
|
-
/* @__PURE__ */ s(
|
|
252
|
+
/* @__PURE__ */ s(d, { children: (e, t) => /* @__PURE__ */ c(o, { children: [/* @__PURE__ */ c(j, {
|
|
240
253
|
ref: this.buttonRef,
|
|
241
254
|
style: {
|
|
242
255
|
...this.state.menuWidth && { minWidth: `calc(${this.state.menuWidth}px + 8px)` },
|
|
243
|
-
borderWidth:
|
|
256
|
+
borderWidth: h ? "2px" : "1px",
|
|
244
257
|
transition: "border-width 0.2s ease-in-out"
|
|
245
258
|
},
|
|
246
|
-
"aria-controls":
|
|
259
|
+
"aria-controls": h ? v : void 0,
|
|
247
260
|
"aria-haspopup": "listbox",
|
|
248
|
-
"aria-expanded":
|
|
261
|
+
"aria-expanded": h ? "true" : "false",
|
|
249
262
|
"aria-activedescendant": this.state.highlightedOptionId,
|
|
250
263
|
onClick: this.handleClick,
|
|
251
|
-
className:
|
|
264
|
+
className: C,
|
|
252
265
|
disabled: n,
|
|
253
|
-
id:
|
|
266
|
+
id: g,
|
|
254
267
|
role: "combobox",
|
|
255
|
-
"aria-labelledby": `${
|
|
268
|
+
"aria-labelledby": `${T} ${e ? S : x}`,
|
|
256
269
|
children: [
|
|
257
|
-
|
|
258
|
-
/* @__PURE__ */
|
|
259
|
-
id:
|
|
260
|
-
ref:
|
|
261
|
-
|
|
270
|
+
D,
|
|
271
|
+
/* @__PURE__ */ s(P, {
|
|
272
|
+
id: x,
|
|
273
|
+
ref: (e) => {
|
|
274
|
+
this.previewRef.current = e, t.current = e;
|
|
275
|
+
},
|
|
276
|
+
dangerouslySetInnerHTML: { __html: a(f || (h && this.state.previewValue ? this.getLabel(i, this.state.previewValue) : this.getLabel(i, r) || "")) }
|
|
262
277
|
}),
|
|
263
|
-
|
|
278
|
+
s(h ? b : y, {})
|
|
264
279
|
]
|
|
265
|
-
}),
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
280
|
+
}), e ? /* @__PURE__ */ s("span", {
|
|
281
|
+
id: S,
|
|
282
|
+
hidden: !0,
|
|
283
|
+
children: e
|
|
284
|
+
}) : null] }) }),
|
|
285
|
+
/* @__PURE__ */ s(M, {
|
|
286
|
+
id: _,
|
|
287
|
+
anchorEl: m,
|
|
269
288
|
keepMounted: !0,
|
|
270
|
-
open:
|
|
289
|
+
open: h,
|
|
271
290
|
onClose: this.handleClose,
|
|
272
291
|
getContentAnchorEl: null,
|
|
273
292
|
anchorOrigin: {
|
|
@@ -288,15 +307,15 @@ var S = x(l, "InlineMenu") || x(T.InlineMenu, "InlineMenu"), C = c, w = C.defaul
|
|
|
288
307
|
padding: "4px"
|
|
289
308
|
} } : void 0,
|
|
290
309
|
list: {
|
|
291
|
-
id:
|
|
292
|
-
"aria-labelledby":
|
|
310
|
+
id: v,
|
|
311
|
+
"aria-labelledby": T,
|
|
293
312
|
role: "listbox",
|
|
294
313
|
disablePadding: !0
|
|
295
314
|
}
|
|
296
315
|
},
|
|
297
|
-
children: (
|
|
316
|
+
children: (i || []).map((e, t) => {
|
|
298
317
|
let n = this.optionId(t);
|
|
299
|
-
return /* @__PURE__ */ s(
|
|
318
|
+
return /* @__PURE__ */ s(z, {
|
|
300
319
|
id: n,
|
|
301
320
|
className: e.value === r ? "selected" : "",
|
|
302
321
|
selected: e.value === r,
|
|
@@ -305,10 +324,8 @@ var S = x(l, "InlineMenu") || x(T.InlineMenu, "InlineMenu"), C = c, w = C.defaul
|
|
|
305
324
|
role: "option",
|
|
306
325
|
"aria-selected": this.state.highlightedOptionId === n ? "true" : void 0,
|
|
307
326
|
onMouseOver: () => this.handleHover(t),
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
dangerouslySetInnerHTML: { __html: i(e.label) }
|
|
311
|
-
}), /* @__PURE__ */ o(M, { dangerouslySetInnerHTML: { __html: e.value === r ? " ✓" : "" } })]
|
|
327
|
+
label: e.label,
|
|
328
|
+
labelRef: (e) => this.elementRefs[t] = e
|
|
312
329
|
}, `${e.label}-${t}`);
|
|
313
330
|
})
|
|
314
331
|
})
|
|
@@ -316,4 +333,4 @@ var S = x(l, "InlineMenu") || x(T.InlineMenu, "InlineMenu"), C = c, w = C.defaul
|
|
|
316
333
|
}
|
|
317
334
|
};
|
|
318
335
|
//#endregion
|
|
319
|
-
export {
|
|
336
|
+
export { B as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-lib/mask-markup",
|
|
3
|
-
"version": "4.0.3-next.
|
|
3
|
+
"version": "4.0.3-next.20261007175429",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,16 +12,16 @@
|
|
|
12
12
|
"@emotion/styled": "^11.14.1",
|
|
13
13
|
"@mui/icons-material": "^7.3.4",
|
|
14
14
|
"@mui/material": "^7.3.4",
|
|
15
|
-
"@pie-element/shared-utils": "0.1.3-next.
|
|
16
|
-
"@pie-lib/drag": "5.0.3-next.
|
|
17
|
-
"@pie-lib/editable-html-tip-tap": "3.0.3-next.
|
|
18
|
-
"@pie-lib/render-ui": "8.0.3-next.
|
|
15
|
+
"@pie-element/shared-utils": "0.1.3-next.20261007075859",
|
|
16
|
+
"@pie-lib/drag": "5.0.3-next.20261007175429",
|
|
17
|
+
"@pie-lib/editable-html-tip-tap": "3.0.3-next.20261007175429",
|
|
18
|
+
"@pie-lib/render-ui": "8.0.3-next.20261007175429",
|
|
19
19
|
"@pie-lib/translator": "5.0.2-next.20261006160832",
|
|
20
20
|
"debug": "^4.1.1",
|
|
21
21
|
"prop-types": "^15.7.2",
|
|
22
22
|
"to-style": "^1.3.3",
|
|
23
23
|
"@dnd-kit/core": "^6.3.1",
|
|
24
|
-
"@pie-element/shared-math-rendering-mathjax": "0.1.4-next.
|
|
24
|
+
"@pie-element/shared-math-rendering-mathjax": "0.1.4-next.20261007175429",
|
|
25
25
|
"@pie-element/shared-lodash": "0.1.3-next.20261006160832",
|
|
26
26
|
"clsx": "^2.1.1"
|
|
27
27
|
},
|