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