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