@pie-lib/mask-markup 0.1.0
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/_virtual/_rolldown/runtime.js +4 -0
- package/dist/choices/choice.d.ts +24 -0
- package/dist/choices/choice.d.ts.map +1 -0
- package/dist/choices/choice.js +77 -0
- package/dist/choices/index.d.ts +26 -0
- package/dist/choices/index.d.ts.map +1 -0
- package/dist/choices/index.js +49 -0
- package/dist/componentize.d.ts +13 -0
- package/dist/componentize.d.ts.map +1 -0
- package/dist/componentize.js +4 -0
- package/dist/components/blank.d.ts +39 -0
- package/dist/components/blank.d.ts.map +1 -0
- package/dist/components/blank.js +236 -0
- package/dist/components/correct-input.d.ts +11 -0
- package/dist/components/correct-input.d.ts.map +1 -0
- package/dist/components/dropdown.d.ts +38 -0
- package/dist/components/dropdown.d.ts.map +1 -0
- package/dist/components/dropdown.js +309 -0
- package/dist/components/input.d.ts +37 -0
- package/dist/components/input.d.ts.map +1 -0
- package/dist/constructed-response.d.ts +24 -0
- package/dist/constructed-response.d.ts.map +1 -0
- package/dist/constructed-response.js +55 -0
- package/dist/customizable.d.ts +24 -0
- package/dist/customizable.d.ts.map +1 -0
- package/dist/customizable.js +8 -0
- package/dist/drag-in-the-blank.d.ts +38 -0
- package/dist/drag-in-the-blank.d.ts.map +1 -0
- package/dist/drag-in-the-blank.js +164 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/inline-dropdown.d.ts +24 -0
- package/dist/inline-dropdown.d.ts.map +1 -0
- package/dist/inline-dropdown.js +24 -0
- package/dist/mask.d.ts +31 -0
- package/dist/mask.d.ts.map +1 -0
- package/dist/mask.js +98 -0
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/index.js +17 -0
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/cssPrefix.js +9 -0
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/cssUnitless.js +26 -0
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/hasOwn.js +11 -0
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/isFunction.js +11 -0
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/isObject.js +11 -0
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/prefixInfo.js +24 -0
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/prefixProperties.js +32 -0
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/prefixer.js +29 -0
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/camelize.js +14 -0
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/hyphenRe.js +8 -0
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/hyphenate.js +12 -0
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/separate.js +11 -0
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/toLowerFirst.js +10 -0
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/toUpperFirst.js +10 -0
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/toStyleObject.js +55 -0
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/toStyleString.js +16 -0
- package/dist/serialization.d.ts +35 -0
- package/dist/serialization.d.ts.map +1 -0
- package/dist/serialization.js +132 -0
- package/dist/with-mask.d.ts +35 -0
- package/dist/with-mask.d.ts.map +1 -0
- package/dist/with-mask.js +45 -0
- package/package.json +44 -0
- package/src/choices/choice.tsx +107 -0
- package/src/choices/index.tsx +74 -0
- package/src/componentize.tsx +23 -0
- package/src/components/blank.tsx +396 -0
- package/src/components/correct-input.tsx +92 -0
- package/src/components/dropdown.tsx +448 -0
- package/src/components/input.tsx +58 -0
- package/src/constructed-response.tsx +91 -0
- package/src/customizable.tsx +44 -0
- package/src/drag-in-the-blank.tsx +251 -0
- package/src/index.ts +26 -0
- package/src/inline-dropdown.tsx +39 -0
- package/src/mask.tsx +178 -0
- package/src/serialization.ts +270 -0
- package/src/with-mask.tsx +85 -0
|
@@ -0,0 +1,309 @@
|
|
|
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 { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
6
|
+
import * as s from "@pie-lib/render-ui";
|
|
7
|
+
import { InlineMenu as c, color as l } from "@pie-lib/render-ui";
|
|
8
|
+
import u from "@mui/material/Button";
|
|
9
|
+
import d from "@mui/material/InputLabel";
|
|
10
|
+
import f from "@mui/material/MenuItem";
|
|
11
|
+
import p from "@mui/icons-material/ArrowDropDown";
|
|
12
|
+
import m from "@mui/icons-material/ArrowDropUp";
|
|
13
|
+
import h from "@mui/icons-material/Close";
|
|
14
|
+
import g from "@mui/icons-material/Check";
|
|
15
|
+
//#region src/components/dropdown.tsx
|
|
16
|
+
function _(e) {
|
|
17
|
+
return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
|
|
18
|
+
}
|
|
19
|
+
function v(e, t) {
|
|
20
|
+
return !e || _(e) ? e : _(e.default) ? e.default : t && _(e[t]) ? e[t] : t && _(e[t]?.default) ? e[t].default : e;
|
|
21
|
+
}
|
|
22
|
+
var y = v(c, "InlineMenu") || v(S.InlineMenu, "InlineMenu"), b = s, x = b.default, S = x && typeof x == "object" ? x : b, C = n(u)(() => ({
|
|
23
|
+
color: l.text(),
|
|
24
|
+
border: `1px solid ${l.borderGray()}`,
|
|
25
|
+
borderRadius: "4px",
|
|
26
|
+
justifyContent: "space-between",
|
|
27
|
+
backgroundColor: l.background(),
|
|
28
|
+
position: "relative",
|
|
29
|
+
height: "45px",
|
|
30
|
+
width: "fit-content",
|
|
31
|
+
margin: "2px",
|
|
32
|
+
textTransform: "none",
|
|
33
|
+
"& span": { paddingRight: "5px" },
|
|
34
|
+
"& svg": {
|
|
35
|
+
position: "absolute",
|
|
36
|
+
right: 0,
|
|
37
|
+
top: "calc(50% - 12px)",
|
|
38
|
+
pointerEvents: "none",
|
|
39
|
+
color: l.text(),
|
|
40
|
+
marginLeft: "5px"
|
|
41
|
+
},
|
|
42
|
+
"&.Mui-focused": {
|
|
43
|
+
outline: `3px solid ${l.tertiary()}`,
|
|
44
|
+
outlineOffset: "2px",
|
|
45
|
+
borderWidth: "3px"
|
|
46
|
+
},
|
|
47
|
+
"&.disabledCorrect": {
|
|
48
|
+
borderWidth: "2px",
|
|
49
|
+
borderColor: l.correct(),
|
|
50
|
+
color: `${l.text()} !important`
|
|
51
|
+
},
|
|
52
|
+
"&.disabledIncorrect": {
|
|
53
|
+
borderWidth: "2px",
|
|
54
|
+
borderColor: l.incorrectWithIcon(),
|
|
55
|
+
color: `${l.text()} !important`
|
|
56
|
+
}
|
|
57
|
+
})), w = n(y)(() => ({
|
|
58
|
+
backgroundColor: l.background(),
|
|
59
|
+
border: `1px solid ${l.correct()} !important`,
|
|
60
|
+
"&:hover": {
|
|
61
|
+
border: `1px solid ${l.text()} `,
|
|
62
|
+
borderColor: "initial"
|
|
63
|
+
},
|
|
64
|
+
"&:focus": {
|
|
65
|
+
border: `1px solid ${l.text()}`,
|
|
66
|
+
borderColor: "initial"
|
|
67
|
+
},
|
|
68
|
+
"& .MuiList-root": { padding: 0 }
|
|
69
|
+
})), T = n(f)(() => ({
|
|
70
|
+
height: 24,
|
|
71
|
+
overflow: "hidden",
|
|
72
|
+
fontSize: "1rem",
|
|
73
|
+
fontWeight: 400,
|
|
74
|
+
fontFamily: "inherit",
|
|
75
|
+
lineHeight: "1.5em",
|
|
76
|
+
whiteSpace: "nowrap",
|
|
77
|
+
color: l.text(),
|
|
78
|
+
backgroundColor: l.background(),
|
|
79
|
+
"&.Mui-focusVisible": {
|
|
80
|
+
outline: `3px solid ${l.tertiary()}`,
|
|
81
|
+
outlineOffset: "-1px",
|
|
82
|
+
color: l.text(),
|
|
83
|
+
backgroundColor: l.background()
|
|
84
|
+
},
|
|
85
|
+
"&:hover": {
|
|
86
|
+
color: l.text(),
|
|
87
|
+
backgroundColor: l.dropdownBackground()
|
|
88
|
+
},
|
|
89
|
+
boxSizing: "border-box",
|
|
90
|
+
padding: "25px",
|
|
91
|
+
borderRadius: "4px",
|
|
92
|
+
"&.selected": {
|
|
93
|
+
color: `${l.text()} !important`,
|
|
94
|
+
backgroundColor: `${l.background()} !important`,
|
|
95
|
+
"&:hover": {
|
|
96
|
+
color: l.text(),
|
|
97
|
+
backgroundColor: `${l.dropdownBackground()} !important`
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
})), E = n("span")(() => ({ fontSize: "max(1rem, 14px)" })), D = n("span")(() => ({
|
|
101
|
+
fontSize: "max(1rem, 14px)",
|
|
102
|
+
position: "absolute",
|
|
103
|
+
right: "10px"
|
|
104
|
+
})), O = n(d)(() => ({
|
|
105
|
+
position: "absolute",
|
|
106
|
+
left: "-10000px",
|
|
107
|
+
top: "auto",
|
|
108
|
+
width: "1px",
|
|
109
|
+
height: "1px",
|
|
110
|
+
overflow: "hidden"
|
|
111
|
+
})), k = n(g)(() => ({
|
|
112
|
+
color: `${l.white()} !important`,
|
|
113
|
+
position: "absolute",
|
|
114
|
+
top: "-8px !important",
|
|
115
|
+
left: "-8px",
|
|
116
|
+
marginLeft: "0 !important",
|
|
117
|
+
borderRadius: "50%",
|
|
118
|
+
fontSize: "16px",
|
|
119
|
+
padding: "2px",
|
|
120
|
+
"&.correct": { backgroundColor: l.correct() },
|
|
121
|
+
"&.incorrect": { backgroundColor: l.incorrectWithIcon() }
|
|
122
|
+
})), A = n(h)(() => ({
|
|
123
|
+
color: `${l.white()} !important`,
|
|
124
|
+
position: "absolute",
|
|
125
|
+
top: "-8px !important",
|
|
126
|
+
left: "-8px",
|
|
127
|
+
marginLeft: "0 !important",
|
|
128
|
+
borderRadius: "50%",
|
|
129
|
+
fontSize: "16px",
|
|
130
|
+
padding: "2px",
|
|
131
|
+
"&.correct": { backgroundColor: l.correct() },
|
|
132
|
+
"&.incorrect": { backgroundColor: l.incorrectWithIcon() }
|
|
133
|
+
})), j = class extends e.Component {
|
|
134
|
+
static propTypes = {
|
|
135
|
+
id: t.string,
|
|
136
|
+
value: t.string,
|
|
137
|
+
disabled: t.bool,
|
|
138
|
+
onChange: t.func,
|
|
139
|
+
correct: t.bool,
|
|
140
|
+
choices: t.arrayOf(t.shape({
|
|
141
|
+
value: t.string,
|
|
142
|
+
label: t.string
|
|
143
|
+
})),
|
|
144
|
+
showCorrectAnswer: t.bool,
|
|
145
|
+
singleQuery: t.bool,
|
|
146
|
+
correctValue: t.string
|
|
147
|
+
};
|
|
148
|
+
constructor(t) {
|
|
149
|
+
super(t), this.state = {
|
|
150
|
+
anchorEl: null,
|
|
151
|
+
highlightedOptionId: null,
|
|
152
|
+
menuWidth: null,
|
|
153
|
+
previewValue: null
|
|
154
|
+
}, this.hiddenRef = e.createRef(), this.buttonRef = e.createRef(), this.previewRef = e.createRef(), this.elementRefs = [];
|
|
155
|
+
}
|
|
156
|
+
componentDidMount() {
|
|
157
|
+
this.hiddenRef.current && this.state.menuWidth === null && this.setState({ menuWidth: this.hiddenRef.current.clientWidth });
|
|
158
|
+
}
|
|
159
|
+
componentDidUpdate(e, t) {
|
|
160
|
+
let n = this.hiddenRef.current;
|
|
161
|
+
if (!t.anchorEl && this.state.anchorEl && this.elementRefs.forEach((e) => {
|
|
162
|
+
if (!e) return;
|
|
163
|
+
let t = e.querySelector("[data-latex], [data-raw]"), n = e.querySelector("mjx-container"), i = e.querySelector("[data-math-handled=\"true\"]");
|
|
164
|
+
t && (!i || !n) && r(e);
|
|
165
|
+
}), n) {
|
|
166
|
+
let e = n.clientWidth;
|
|
167
|
+
e !== this.state.menuWidth && (this.elementRefs.forEach((e) => {
|
|
168
|
+
e && r(e);
|
|
169
|
+
}), r(n), this.setState({ menuWidth: e }));
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
handleClick = (e) => this.setState({ anchorEl: e.currentTarget });
|
|
173
|
+
handleClose = () => {
|
|
174
|
+
let { value: e } = this.props;
|
|
175
|
+
this.setState({
|
|
176
|
+
anchorEl: null,
|
|
177
|
+
previewValue: null,
|
|
178
|
+
highlightedOptionId: null
|
|
179
|
+
}), !e && this.previewRef.current && (this.previewRef.current.innerHTML = "");
|
|
180
|
+
};
|
|
181
|
+
handleHighlight = (e) => {
|
|
182
|
+
let t = { highlightedOptionId: `dropdown-option-${this.props.id}-${e}` };
|
|
183
|
+
this.props.value || (t.previewValue = this.props.choices[e].value), this.setState(t);
|
|
184
|
+
};
|
|
185
|
+
handleSelect = (e, t) => {
|
|
186
|
+
this.props.onChange(this.props.id, e), this.handleHighlight(t), this.handleClose();
|
|
187
|
+
};
|
|
188
|
+
handleHover = (e) => {
|
|
189
|
+
if (this.props.value) return;
|
|
190
|
+
let t = `dropdown-option-${this.props.id}-${e}`, n = this.state.previewValue;
|
|
191
|
+
this.setState({
|
|
192
|
+
highlightedOptionId: t,
|
|
193
|
+
previewValue: n
|
|
194
|
+
}, () => {
|
|
195
|
+
let t = this.elementRefs[e], n = this.previewRef.current;
|
|
196
|
+
t && n && (n.innerHTML = t.innerHTML);
|
|
197
|
+
});
|
|
198
|
+
};
|
|
199
|
+
getLabel(e, t) {
|
|
200
|
+
let n = (e || []).find((e) => e.value === t);
|
|
201
|
+
return n ? n.label.trim() : void 0;
|
|
202
|
+
}
|
|
203
|
+
render() {
|
|
204
|
+
let { id: e, correct: t, disabled: n, value: r, choices: s, showCorrectAnswer: c, singleQuery: l, correctValue: u } = this.props, { anchorEl: d } = this.state, f = !!d, h = `dropdown-button-${e}`, g = `dropdown-menu-${e}`, _ = `dropdown-value-${e}`, v;
|
|
205
|
+
this.elementRefs = [], n && t !== void 0 && (v = t || c ? "disabledCorrect" : "disabledIncorrect");
|
|
206
|
+
let y = parseInt(e, 10) + 1, b = l ? "Query-label" : `Query-label-${y}`, x = l ? "Query" : `Query ${y}`, S = null;
|
|
207
|
+
return n && t !== void 0 && (S = t || c ? /* @__PURE__ */ a(k, { className: "correct" }) : /* @__PURE__ */ a(A, { className: "incorrect" })), /* @__PURE__ */ o(i, { children: [
|
|
208
|
+
/* @__PURE__ */ a("div", {
|
|
209
|
+
ref: this.hiddenRef,
|
|
210
|
+
style: {
|
|
211
|
+
position: "absolute",
|
|
212
|
+
visibility: "hidden",
|
|
213
|
+
top: 0,
|
|
214
|
+
left: 0
|
|
215
|
+
},
|
|
216
|
+
tabIndex: -1,
|
|
217
|
+
"aria-hidden": "true",
|
|
218
|
+
children: (s || []).map((e, t) => /* @__PURE__ */ a(T, {
|
|
219
|
+
tabIndex: -1,
|
|
220
|
+
"aria-hidden": "true",
|
|
221
|
+
children: /* @__PURE__ */ a(E, { dangerouslySetInnerHTML: { __html: e.label } })
|
|
222
|
+
}, t))
|
|
223
|
+
}),
|
|
224
|
+
/* @__PURE__ */ a(O, {
|
|
225
|
+
id: b,
|
|
226
|
+
tabIndex: -1,
|
|
227
|
+
"aria-hidden": "true",
|
|
228
|
+
children: x
|
|
229
|
+
}),
|
|
230
|
+
/* @__PURE__ */ o(C, {
|
|
231
|
+
ref: this.buttonRef,
|
|
232
|
+
style: {
|
|
233
|
+
...this.state.menuWidth && { minWidth: `calc(${this.state.menuWidth}px + 8px)` },
|
|
234
|
+
borderWidth: f ? "2px" : "1px",
|
|
235
|
+
transition: "border-width 0.2s ease-in-out"
|
|
236
|
+
},
|
|
237
|
+
"aria-controls": f ? g : void 0,
|
|
238
|
+
"aria-haspopup": "listbox",
|
|
239
|
+
"aria-expanded": f ? "true" : void 0,
|
|
240
|
+
"aria-activedescendant": this.state.highlightedOptionId,
|
|
241
|
+
onClick: this.handleClick,
|
|
242
|
+
className: v,
|
|
243
|
+
disabled: n,
|
|
244
|
+
id: h,
|
|
245
|
+
role: "combobox",
|
|
246
|
+
"aria-label": `Select an option for ${x}`,
|
|
247
|
+
"aria-labelledby": _,
|
|
248
|
+
children: [
|
|
249
|
+
S,
|
|
250
|
+
/* @__PURE__ */ a(E, {
|
|
251
|
+
id: _,
|
|
252
|
+
ref: this.previewRef,
|
|
253
|
+
dangerouslySetInnerHTML: { __html: u || (f && this.state.previewValue ? this.getLabel(s, this.state.previewValue) : this.getLabel(s, r) || "") }
|
|
254
|
+
}),
|
|
255
|
+
a(f ? m : p, {})
|
|
256
|
+
]
|
|
257
|
+
}),
|
|
258
|
+
/* @__PURE__ */ a(w, {
|
|
259
|
+
id: g,
|
|
260
|
+
anchorEl: d,
|
|
261
|
+
keepMounted: !0,
|
|
262
|
+
open: f,
|
|
263
|
+
onClose: this.handleClose,
|
|
264
|
+
getContentAnchorEl: null,
|
|
265
|
+
anchorOrigin: {
|
|
266
|
+
vertical: "bottom",
|
|
267
|
+
horizontal: "left"
|
|
268
|
+
},
|
|
269
|
+
transformOrigin: {
|
|
270
|
+
vertical: "top",
|
|
271
|
+
horizontal: "left"
|
|
272
|
+
},
|
|
273
|
+
transitionDuration: {
|
|
274
|
+
enter: 225,
|
|
275
|
+
exit: 195
|
|
276
|
+
},
|
|
277
|
+
slotProps: {
|
|
278
|
+
paper: this.state.menuWidth ? { style: {
|
|
279
|
+
minWidth: this.state.menuWidth,
|
|
280
|
+
padding: "4px"
|
|
281
|
+
} } : void 0,
|
|
282
|
+
list: {
|
|
283
|
+
"aria-labelledby": h,
|
|
284
|
+
role: "listbox",
|
|
285
|
+
disablePadding: !0
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
children: (s || []).map((t, n) => {
|
|
289
|
+
let i = `dropdown-option-${e}-${n}`;
|
|
290
|
+
return /* @__PURE__ */ o(T, {
|
|
291
|
+
id: i,
|
|
292
|
+
className: t.value === r ? "selected" : "",
|
|
293
|
+
value: t.value,
|
|
294
|
+
onClick: () => this.handleSelect(t.value, n),
|
|
295
|
+
role: "option",
|
|
296
|
+
"aria-selected": this.state.highlightedOptionId === i ? "true" : void 0,
|
|
297
|
+
onMouseOver: () => this.handleHover(n),
|
|
298
|
+
children: [/* @__PURE__ */ a(E, {
|
|
299
|
+
ref: (e) => this.elementRefs[n] = e,
|
|
300
|
+
dangerouslySetInnerHTML: { __html: t.label }
|
|
301
|
+
}), /* @__PURE__ */ a(D, { dangerouslySetInnerHTML: { __html: t.value === r ? " ✓" : "" } })]
|
|
302
|
+
}, `${t.label}-${n}`);
|
|
303
|
+
})
|
|
304
|
+
})
|
|
305
|
+
] });
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
//#endregion
|
|
309
|
+
export { j as default };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-lib/packages/mask-markup/src/components/input.jsx
|
|
3
|
+
* @auto-generated
|
|
4
|
+
*
|
|
5
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
+
* Manual edits will be overwritten on next sync.
|
|
7
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
+
*/
|
|
9
|
+
import PropTypes from 'prop-types';
|
|
10
|
+
declare const Input: {
|
|
11
|
+
({ disabled, correct, charactersLimit, id, isConstructedResponse, value, onChange, showCorrectAnswer, spellCheck, width, }: {
|
|
12
|
+
disabled: any;
|
|
13
|
+
correct: any;
|
|
14
|
+
charactersLimit: any;
|
|
15
|
+
id: any;
|
|
16
|
+
isConstructedResponse: any;
|
|
17
|
+
value: any;
|
|
18
|
+
onChange: any;
|
|
19
|
+
showCorrectAnswer: any;
|
|
20
|
+
spellCheck: any;
|
|
21
|
+
width: any;
|
|
22
|
+
}): JSX.Element;
|
|
23
|
+
propTypes: {
|
|
24
|
+
id: PropTypes.Requireable<string>;
|
|
25
|
+
value: PropTypes.Requireable<string>;
|
|
26
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
27
|
+
disabled: PropTypes.Requireable<boolean>;
|
|
28
|
+
spellCheck: PropTypes.Requireable<boolean>;
|
|
29
|
+
correct: PropTypes.Requireable<boolean>;
|
|
30
|
+
showCorrectAnswer: PropTypes.Requireable<boolean>;
|
|
31
|
+
charactersLimit: PropTypes.Requireable<number>;
|
|
32
|
+
width: PropTypes.Requireable<number>;
|
|
33
|
+
isConstructedResponse: PropTypes.Requireable<boolean>;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
export default Input;
|
|
37
|
+
//# sourceMappingURL=input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/components/input.tsx"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAGH,OAAO,SAAS,MAAM,YAAY,CAAC;AAGnC,QAAA,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;CA4BV,CAAC;AAeF,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-lib/packages/mask-markup/src/constructed-response.jsx
|
|
3
|
+
* @auto-generated
|
|
4
|
+
*
|
|
5
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
+
* Manual edits will be overwritten on next sync.
|
|
7
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
+
*/
|
|
9
|
+
declare const _default: {
|
|
10
|
+
new (props: any): {
|
|
11
|
+
componentDidUpdate(prevProps: any): void;
|
|
12
|
+
render(): JSX.Element;
|
|
13
|
+
};
|
|
14
|
+
propTypes: {
|
|
15
|
+
markup: import("prop-types").Requireable<string>;
|
|
16
|
+
layout: import("prop-types").Requireable<object>;
|
|
17
|
+
value: import("prop-types").Requireable<object>;
|
|
18
|
+
onChange: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
19
|
+
customMarkMarkupComponent: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
20
|
+
elementType: import("prop-types").Requireable<string>;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export default _default;
|
|
24
|
+
//# sourceMappingURL=constructed-response.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constructed-response.d.ts","sourceRoot":"","sources":["../src/constructed-response.tsx"],"names":[],"mappings":"AACA;;;;;;;GAOG;;;;;;;;;;;;;;;AAkFH,wBAA8C"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { withMask as e } from "./with-mask.js";
|
|
2
|
+
import "react";
|
|
3
|
+
import { styled as t } from "@mui/material/styles";
|
|
4
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
5
|
+
import { color as r } from "@pie-lib/render-ui";
|
|
6
|
+
import i from "classnames";
|
|
7
|
+
import a from "@pie-lib/editable-html-tip-tap";
|
|
8
|
+
//#region src/constructed-response.tsx
|
|
9
|
+
var o = t(a)(() => ({
|
|
10
|
+
display: "inline-block",
|
|
11
|
+
verticalAlign: "middle",
|
|
12
|
+
margin: "4px",
|
|
13
|
+
borderRadius: "4px",
|
|
14
|
+
border: `1px solid ${r.black()}`,
|
|
15
|
+
"&.correct": { border: `1px solid ${r.correct()}` },
|
|
16
|
+
"&.incorrect": { border: `1px solid ${r.incorrect()}` }
|
|
17
|
+
})), s = e("input", (e) => (t, r) => {
|
|
18
|
+
let { adjustedLimit: a, disabled: s, feedback: c, showCorrectAnswer: l, maxLength: u, spellCheck: d, pluginProps: f, onChange: p } = e, m = t.data?.dataset || {};
|
|
19
|
+
if (m.component === "input") {
|
|
20
|
+
let h = (e.choices && m && e.choices[m.id] || [])[0], g = l ? h && h.label : r[m.id] || "", _ = u && u[m.id], v = c && c[m.id], y = l || v === "correct", b = !l && v === "incorrect";
|
|
21
|
+
return /* @__PURE__ */ n(o, {
|
|
22
|
+
id: m.id,
|
|
23
|
+
disabled: l || s,
|
|
24
|
+
disableUnderline: !0,
|
|
25
|
+
onChange: (e) => {
|
|
26
|
+
p({
|
|
27
|
+
...r,
|
|
28
|
+
[m.id]: e
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
markup: g || "",
|
|
32
|
+
charactersLimit: a ? _ : 25,
|
|
33
|
+
activePlugins: ["languageCharacters"],
|
|
34
|
+
pluginProps: f,
|
|
35
|
+
languageCharactersProps: [{ language: "spanish" }],
|
|
36
|
+
spellCheck: d,
|
|
37
|
+
adjustWidthForLimit: !0,
|
|
38
|
+
onKeyDown: (e) => {
|
|
39
|
+
if (e.key === "Enter" || e.keyCode === 13) return !0;
|
|
40
|
+
},
|
|
41
|
+
autoWidthToolbar: !0,
|
|
42
|
+
toolbarOpts: {
|
|
43
|
+
minWidth: "auto",
|
|
44
|
+
noBorder: !0,
|
|
45
|
+
isHidden: !!f?.characters?.disabled
|
|
46
|
+
},
|
|
47
|
+
className: i({
|
|
48
|
+
correct: y,
|
|
49
|
+
incorrect: b
|
|
50
|
+
})
|
|
51
|
+
}, `${t.type}-input-${m.id}`);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
//#endregion
|
|
55
|
+
export { s as default };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-lib/packages/mask-markup/src/customizable.jsx
|
|
3
|
+
* @auto-generated
|
|
4
|
+
*
|
|
5
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
+
* Manual edits will be overwritten on next sync.
|
|
7
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
+
*/
|
|
9
|
+
declare const _default: {
|
|
10
|
+
new (props: any): {
|
|
11
|
+
componentDidUpdate(prevProps: any): void;
|
|
12
|
+
render(): JSX.Element;
|
|
13
|
+
};
|
|
14
|
+
propTypes: {
|
|
15
|
+
markup: import("prop-types").Requireable<string>;
|
|
16
|
+
layout: import("prop-types").Requireable<object>;
|
|
17
|
+
value: import("prop-types").Requireable<object>;
|
|
18
|
+
onChange: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
19
|
+
customMarkMarkupComponent: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
20
|
+
elementType: import("prop-types").Requireable<string>;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export default _default;
|
|
24
|
+
//# sourceMappingURL=customizable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customizable.d.ts","sourceRoot":"","sources":["../src/customizable.tsx"],"names":[],"mappings":"AACA;;;;;;;GAOG;;;;;;;;;;;;;;;AAMH,wBA6BG"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { withMask as e } from "./with-mask.js";
|
|
2
|
+
//#region src/customizable.tsx
|
|
3
|
+
var t = e("input", (e) => (t, n, r) => {
|
|
4
|
+
let i = t.data && t.data.dataset || {};
|
|
5
|
+
if (i.component === "input") return e.customMarkMarkupComponent(i.id);
|
|
6
|
+
});
|
|
7
|
+
//#endregion
|
|
8
|
+
export { t as default };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-lib/packages/mask-markup/src/drag-in-the-blank.jsx
|
|
3
|
+
* @auto-generated
|
|
4
|
+
*
|
|
5
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
+
* Manual edits will be overwritten on next sync.
|
|
7
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import PropTypes from 'prop-types';
|
|
11
|
+
export default class DragInTheBlank extends React.Component {
|
|
12
|
+
constructor(props: any);
|
|
13
|
+
static propTypes: {
|
|
14
|
+
markup: PropTypes.Requireable<string>;
|
|
15
|
+
layout: PropTypes.Requireable<object>;
|
|
16
|
+
choicesPosition: PropTypes.Requireable<string>;
|
|
17
|
+
choices: PropTypes.Requireable<any[]>;
|
|
18
|
+
value: PropTypes.Requireable<object>;
|
|
19
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
20
|
+
duplicates: PropTypes.Requireable<boolean>;
|
|
21
|
+
disabled: PropTypes.Requireable<boolean>;
|
|
22
|
+
feedback: PropTypes.Requireable<object>;
|
|
23
|
+
correctResponse: PropTypes.Requireable<object>;
|
|
24
|
+
showCorrectAnswer: PropTypes.Requireable<boolean>;
|
|
25
|
+
emptyResponseAreaWidth: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
26
|
+
emptyResponseAreaHeight: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
27
|
+
instanceId: PropTypes.Requireable<string>;
|
|
28
|
+
};
|
|
29
|
+
static defaultProps: {
|
|
30
|
+
instanceId: string;
|
|
31
|
+
};
|
|
32
|
+
handleDragStart: any;
|
|
33
|
+
renderDragOverlay: any;
|
|
34
|
+
handleDragEnd: any;
|
|
35
|
+
getPositionDirection: any;
|
|
36
|
+
render(): JSX.Element;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=drag-in-the-blank.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drag-in-the-blank.d.ts","sourceRoot":"","sources":["../src/drag-in-the-blank.tsx"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,SAAS,MAAM,YAAY,CAAC;AAqDnC,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,KAAK,CAAC,SAAS;gBAC7C,KAAK,KAAA;IAQjB,MAAM,CAAC,SAAS;;;;;;;;;;;;;;;MAed;IAEF,MAAM,CAAC,YAAY;;MAEjB;IAEF,eAAe,EAAE,GAAG,CASlB;IAEF,iBAAiB,EAAE,GAAG,CAepB;IAEF,aAAa,EAAE,GAAG,CAuChB;IAEF,oBAAoB,EAAE,GAAG,CAyBvB;IAEF,MAAM;CA4DP"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { withMask as e } from "./with-mask.js";
|
|
2
|
+
import t from "./choices/choice.js";
|
|
3
|
+
import n from "./choices/index.js";
|
|
4
|
+
import r from "./components/blank.js";
|
|
5
|
+
import i from "react";
|
|
6
|
+
import a from "prop-types";
|
|
7
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
8
|
+
import { DragProvider as c } from "@pie-lib/drag";
|
|
9
|
+
import { DragOverlay as l, rectIntersection as u } from "@dnd-kit/core";
|
|
10
|
+
//#region src/drag-in-the-blank.tsx
|
|
11
|
+
var d = e("blank", (e) => (t, n, i) => {
|
|
12
|
+
let a = t.data?.dataset || {};
|
|
13
|
+
if (a.component === "blank") {
|
|
14
|
+
let { disabled: s, duplicates: c, correctResponse: l, feedback: u, showCorrectAnswer: d, emptyResponseAreaWidth: f, emptyResponseAreaHeight: p, instanceId: m, isDragging: h } = e, g = d ? l[a.id] : n[a.id], _ = g && e.choices.find((e) => e.id === g);
|
|
15
|
+
return /* @__PURE__ */ o(r, {
|
|
16
|
+
correct: d || u && u[a.id],
|
|
17
|
+
disabled: s,
|
|
18
|
+
duplicates: c,
|
|
19
|
+
choice: _,
|
|
20
|
+
id: a.id,
|
|
21
|
+
emptyResponseAreaWidth: f,
|
|
22
|
+
emptyResponseAreaHeight: p,
|
|
23
|
+
onChange: (e, t) => {
|
|
24
|
+
let r = { ...n };
|
|
25
|
+
t === void 0 ? delete r[e] : r[e] = t, i(r);
|
|
26
|
+
},
|
|
27
|
+
instanceId: m,
|
|
28
|
+
isDragging: h
|
|
29
|
+
}, `${t.type}-${a.id}`);
|
|
30
|
+
}
|
|
31
|
+
}), f = class extends i.Component {
|
|
32
|
+
constructor(e) {
|
|
33
|
+
super(e), this.state = {
|
|
34
|
+
activeDragItem: null,
|
|
35
|
+
dropAnimation: void 0
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
static propTypes = {
|
|
39
|
+
markup: a.string,
|
|
40
|
+
layout: a.object,
|
|
41
|
+
choicesPosition: a.string,
|
|
42
|
+
choices: a.array,
|
|
43
|
+
value: a.object,
|
|
44
|
+
onChange: a.func,
|
|
45
|
+
duplicates: a.bool,
|
|
46
|
+
disabled: a.bool,
|
|
47
|
+
feedback: a.object,
|
|
48
|
+
correctResponse: a.object,
|
|
49
|
+
showCorrectAnswer: a.bool,
|
|
50
|
+
emptyResponseAreaWidth: a.oneOfType([a.string, a.number]),
|
|
51
|
+
emptyResponseAreaHeight: a.oneOfType([a.string, a.number]),
|
|
52
|
+
instanceId: a.string
|
|
53
|
+
};
|
|
54
|
+
static defaultProps = { instanceId: "drag-in-the-blank" };
|
|
55
|
+
handleDragStart = (e) => {
|
|
56
|
+
let { active: t } = e;
|
|
57
|
+
t?.data?.current && this.setState({
|
|
58
|
+
activeDragItem: t.data.current,
|
|
59
|
+
dropAnimation: void 0
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
renderDragOverlay = () => {
|
|
63
|
+
let { activeDragItem: e } = this.state;
|
|
64
|
+
return e && e.type === "MaskBlank" ? /* @__PURE__ */ o(t, {
|
|
65
|
+
disabled: e.disabled,
|
|
66
|
+
choice: e.choice,
|
|
67
|
+
instanceId: e.instanceId
|
|
68
|
+
}) : null;
|
|
69
|
+
};
|
|
70
|
+
handleDragEnd = (e) => {
|
|
71
|
+
let { active: t, over: n } = e, { onChange: r, value: i } = this.props, a = t?.data?.current, o = n?.data?.current, s = !!t && !!n && a?.type === "MaskBlank" && o?.accepts?.includes("MaskBlank");
|
|
72
|
+
if (this.setState({
|
|
73
|
+
activeDragItem: null,
|
|
74
|
+
dropAnimation: s ? null : void 0
|
|
75
|
+
}), !s || !r) return;
|
|
76
|
+
let c = a, l = o.id;
|
|
77
|
+
if (o.toChoiceBoard === !0) {
|
|
78
|
+
if (!c.fromChoice && c.id) {
|
|
79
|
+
let e = { ...i };
|
|
80
|
+
delete e[c.id], r(e);
|
|
81
|
+
}
|
|
82
|
+
} else if (c.fromChoice === !0) {
|
|
83
|
+
if (l && l !== "drag-in-the-blank-droppable") {
|
|
84
|
+
let e = { ...i };
|
|
85
|
+
e[l] = c.choice.id, r(e);
|
|
86
|
+
}
|
|
87
|
+
} else if (c.id && c.id !== l) {
|
|
88
|
+
let e = { ...i };
|
|
89
|
+
e[l] = c.choice.id, delete e[c.id], r(e);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
getPositionDirection = (e) => {
|
|
93
|
+
let t, n, r;
|
|
94
|
+
switch (e) {
|
|
95
|
+
case "left":
|
|
96
|
+
t = "row", r = "center";
|
|
97
|
+
break;
|
|
98
|
+
case "right":
|
|
99
|
+
t = "row-reverse", n = "flex-end", r = "center";
|
|
100
|
+
break;
|
|
101
|
+
case "below":
|
|
102
|
+
t = "column-reverse";
|
|
103
|
+
break;
|
|
104
|
+
default:
|
|
105
|
+
t = "column";
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
flexDirection: t,
|
|
110
|
+
justifyContent: n,
|
|
111
|
+
alignItems: r
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
render() {
|
|
115
|
+
let { markup: e, duplicates: t, value: r, onChange: i, choicesPosition: a, choices: f, correctResponse: p, disabled: m, feedback: h, showCorrectAnswer: g, emptyResponseAreaWidth: _, emptyResponseAreaHeight: v, layout: y, instanceId: b } = this.props, x = a || "below", S = {
|
|
116
|
+
display: "flex",
|
|
117
|
+
minWidth: "100px",
|
|
118
|
+
...this.getPositionDirection(x)
|
|
119
|
+
};
|
|
120
|
+
return /* @__PURE__ */ o(c, {
|
|
121
|
+
onDragStart: this.handleDragStart,
|
|
122
|
+
onDragEnd: this.handleDragEnd,
|
|
123
|
+
collisionDetection: u,
|
|
124
|
+
children: /* @__PURE__ */ s("div", {
|
|
125
|
+
ref: (e) => this.rootRef = e,
|
|
126
|
+
style: S,
|
|
127
|
+
children: [
|
|
128
|
+
/* @__PURE__ */ o(n, {
|
|
129
|
+
choicePosition: x,
|
|
130
|
+
choices: f,
|
|
131
|
+
value: r,
|
|
132
|
+
duplicates: t,
|
|
133
|
+
disabled: m,
|
|
134
|
+
instanceId: b
|
|
135
|
+
}),
|
|
136
|
+
/* @__PURE__ */ o(d, {
|
|
137
|
+
elementType: "drag-in-the-blank",
|
|
138
|
+
markup: e,
|
|
139
|
+
layout: y,
|
|
140
|
+
value: r,
|
|
141
|
+
choices: f,
|
|
142
|
+
onChange: i,
|
|
143
|
+
disabled: m,
|
|
144
|
+
duplicates: t,
|
|
145
|
+
feedback: h,
|
|
146
|
+
correctResponse: p,
|
|
147
|
+
showCorrectAnswer: g,
|
|
148
|
+
emptyResponseAreaWidth: _,
|
|
149
|
+
emptyResponseAreaHeight: v,
|
|
150
|
+
instanceId: b,
|
|
151
|
+
isDragging: !!this.state.activeDragItem
|
|
152
|
+
}),
|
|
153
|
+
/* @__PURE__ */ o(l, {
|
|
154
|
+
style: { pointerEvents: "none" },
|
|
155
|
+
dropAnimation: this.state.dropAnimation,
|
|
156
|
+
children: this.renderDragOverlay()
|
|
157
|
+
})
|
|
158
|
+
]
|
|
159
|
+
})
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
//#endregion
|
|
164
|
+
export { f as default };
|