@pie-element/inline-dropdown 10.1.1 → 10.1.2-next.1
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/configure.js +2 -0
- package/controller.js +1 -0
- package/dist/author/defaults.d.ts +194 -0
- package/dist/author/defaults.js +130 -0
- package/dist/author/index.d.ts +43 -0
- package/dist/author/index.js +83 -0
- package/dist/author/inline-dropdown-toolbar.d.ts +48 -0
- package/dist/author/inline-dropdown-toolbar.js +268 -0
- package/dist/author/main.d.ts +49 -0
- package/dist/author/main.js +379 -0
- package/dist/author/markupUtils.d.ts +12 -0
- package/dist/author/markupUtils.js +23 -0
- package/dist/author/response-area.d.ts +20 -0
- package/dist/author/response-area.js +32 -0
- package/dist/author/utils.d.ts +10 -0
- package/dist/author/utils.js +10 -0
- package/dist/browser/Close-CMvmRhfL.js +9024 -0
- package/dist/browser/Close-CMvmRhfL.js.map +1 -0
- package/dist/browser/author/index.js +40578 -0
- package/dist/browser/author/index.js.map +1 -0
- package/dist/browser/controller/index.js +196 -0
- package/dist/browser/controller/index.js.map +1 -0
- package/dist/browser/delivery/index.js +2714 -0
- package/dist/browser/delivery/index.js.map +1 -0
- package/dist/browser/dist-CAsDMEWi.js +133 -0
- package/dist/browser/dist-CAsDMEWi.js.map +1 -0
- package/dist/browser/inline-dropdown.css +2 -0
- package/dist/controller/defaults.d.ts +27 -0
- package/dist/controller/defaults.js +21 -0
- package/dist/controller/index.d.ts +54 -0
- package/dist/controller/index.js +124 -0
- package/dist/controller/utils.d.ts +12 -0
- package/dist/controller/utils.js +13 -0
- package/dist/delivery/index.d.ts +20 -0
- package/dist/delivery/index.js +60 -0
- package/dist/delivery/inline-dropdown.d.ts +38 -0
- package/dist/delivery/inline-dropdown.js +109 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.iife.d.ts +8 -0
- package/dist/index.iife.js +148 -0
- package/dist/index.js +2 -0
- package/dist/runtime-support.d.ts +12 -0
- package/dist/runtime-support.js +12 -0
- package/package.json +86 -21
- package/CHANGELOG.json +0 -1082
- package/CHANGELOG.md +0 -2185
- package/LICENSE.md +0 -5
- package/README.md +0 -1
- package/configure/CHANGELOG.json +0 -647
- package/configure/CHANGELOG.md +0 -1942
- package/configure/lib/defaults.js +0 -192
- package/configure/lib/defaults.js.map +0 -1
- package/configure/lib/index.js +0 -135
- package/configure/lib/index.js.map +0 -1
- package/configure/lib/inline-dropdown-toolbar.js +0 -457
- package/configure/lib/inline-dropdown-toolbar.js.map +0 -1
- package/configure/lib/main.js +0 -603
- package/configure/lib/main.js.map +0 -1
- package/configure/lib/markupUtils.js +0 -50
- package/configure/lib/markupUtils.js.map +0 -1
- package/configure/lib/response-area.js +0 -48
- package/configure/lib/response-area.js.map +0 -1
- package/configure/lib/utils.js +0 -22
- package/configure/lib/utils.js.map +0 -1
- package/configure/package.json +0 -24
- package/controller/CHANGELOG.json +0 -467
- package/controller/CHANGELOG.md +0 -1283
- package/controller/lib/defaults.js +0 -25
- package/controller/lib/defaults.js.map +0 -1
- package/controller/lib/index.js +0 -295
- package/controller/lib/index.js.map +0 -1
- package/controller/lib/utils.js +0 -32
- package/controller/lib/utils.js.map +0 -1
- package/controller/package.json +0 -16
- package/docs/config-schema.json +0 -2854
- package/docs/config-schema.json.md +0 -2106
- package/docs/demo/config.js +0 -8
- package/docs/demo/generate.js +0 -76
- package/docs/demo/index.html +0 -1
- package/docs/demo/session.js +0 -11
- package/docs/pie-schema.json +0 -1152
- package/docs/pie-schema.json.md +0 -814
- package/lib/index.js +0 -85
- package/lib/index.js.map +0 -1
- package/lib/inline-dropdown.js +0 -176
- package/lib/inline-dropdown.js.map +0 -1
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { getPluginProps as e } from "./utils.js";
|
|
2
|
+
import t from "react";
|
|
3
|
+
import { renderMath as n } from "@pie-element/shared-math-rendering-mathjax";
|
|
4
|
+
import r from "react-dom";
|
|
5
|
+
import i from "prop-types";
|
|
6
|
+
import { isEmpty as a, isEqual as o } from "@pie-element/shared-lodash";
|
|
7
|
+
import { color as s } from "@pie-lib/render-ui";
|
|
8
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
9
|
+
import { styled as u } from "@mui/material/styles";
|
|
10
|
+
import d from "@pie-lib/editable-html-tip-tap";
|
|
11
|
+
import f from "@mui/icons-material/Add";
|
|
12
|
+
import p from "@mui/icons-material/Check";
|
|
13
|
+
import m from "@mui/icons-material/Close";
|
|
14
|
+
import h from "@mui/icons-material/Edit";
|
|
15
|
+
import g from "@mui/material/IconButton";
|
|
16
|
+
//#region src/author/inline-dropdown-toolbar.tsx
|
|
17
|
+
var _ = u("div")(({ theme: e }) => ({
|
|
18
|
+
display: "flex",
|
|
19
|
+
alignItems: "flex-start",
|
|
20
|
+
position: "relative",
|
|
21
|
+
background: e.palette.common.white,
|
|
22
|
+
borderBottom: `1px solid ${e.palette.grey[400]}`,
|
|
23
|
+
"&:last-child": { borderRadius: "0 0 4px 4px" }
|
|
24
|
+
})), v = u("div")(({ theme: e }) => ({
|
|
25
|
+
display: "flex",
|
|
26
|
+
justifyContent: "center",
|
|
27
|
+
color: e.palette.common.white,
|
|
28
|
+
fontSize: e.typography.fontSize,
|
|
29
|
+
fontStyle: "normal",
|
|
30
|
+
position: "absolute",
|
|
31
|
+
transform: "translate(0, -50%)",
|
|
32
|
+
backgroundColor: s.correct(),
|
|
33
|
+
borderRadius: "50%",
|
|
34
|
+
top: e.spacing(2),
|
|
35
|
+
left: e.spacing(1),
|
|
36
|
+
zIndex: 3
|
|
37
|
+
})), y = u("div")(({ theme: e, correct: t }) => ({
|
|
38
|
+
flex: 1,
|
|
39
|
+
padding: e.spacing(.75),
|
|
40
|
+
paddingLeft: e.spacing(3.5),
|
|
41
|
+
...t && { background: s.correctSecondary() },
|
|
42
|
+
"& p": { margin: 0 }
|
|
43
|
+
})), b = u("div")(({ theme: e }) => ({
|
|
44
|
+
margin: e.spacing(.5),
|
|
45
|
+
display: "flex"
|
|
46
|
+
})), x = u(g)(({ theme: e }) => ({
|
|
47
|
+
fontSize: e.typography.fontSize,
|
|
48
|
+
padding: e.spacing(.5),
|
|
49
|
+
color: e.palette.common.black
|
|
50
|
+
})), S = class extends t.Component {
|
|
51
|
+
static propTypes = {
|
|
52
|
+
correct: i.bool.isRequired,
|
|
53
|
+
onClick: i.func.isRequired,
|
|
54
|
+
onRemoveChoice: i.func.isRequired,
|
|
55
|
+
onEditChoice: i.func.isRequired,
|
|
56
|
+
value: i.string.isRequired
|
|
57
|
+
};
|
|
58
|
+
onRemoveClick = (e) => {
|
|
59
|
+
let { onRemoveChoice: t } = this.props;
|
|
60
|
+
e.preventDefault(), e.stopPropagation(), t();
|
|
61
|
+
};
|
|
62
|
+
onEditClick = (e) => {
|
|
63
|
+
let { onEditChoice: t } = this.props;
|
|
64
|
+
e.preventDefault(), e.stopPropagation(), t();
|
|
65
|
+
};
|
|
66
|
+
render() {
|
|
67
|
+
let { correct: e, onClick: t, value: n } = this.props;
|
|
68
|
+
return /* @__PURE__ */ l(_, { children: [
|
|
69
|
+
e && /* @__PURE__ */ c(v, {
|
|
70
|
+
onClick: t,
|
|
71
|
+
children: /* @__PURE__ */ c(p, { fontSize: "inherit" })
|
|
72
|
+
}),
|
|
73
|
+
/* @__PURE__ */ c(y, {
|
|
74
|
+
correct: e,
|
|
75
|
+
onClick: t,
|
|
76
|
+
dangerouslySetInnerHTML: { __html: n }
|
|
77
|
+
}),
|
|
78
|
+
/* @__PURE__ */ l(b, { children: [/* @__PURE__ */ c(x, {
|
|
79
|
+
onClick: this.onEditClick,
|
|
80
|
+
size: "small",
|
|
81
|
+
"aria-label": "Edit",
|
|
82
|
+
children: /* @__PURE__ */ c(h, { fontSize: "inherit" })
|
|
83
|
+
}), /* @__PURE__ */ c(x, {
|
|
84
|
+
onClick: this.onRemoveClick,
|
|
85
|
+
size: "small",
|
|
86
|
+
"aria-label": "Remove",
|
|
87
|
+
children: /* @__PURE__ */ c(m, { fontSize: "inherit" })
|
|
88
|
+
})] })
|
|
89
|
+
] });
|
|
90
|
+
}
|
|
91
|
+
}, C = (e) => {
|
|
92
|
+
let t = document.createElement("div");
|
|
93
|
+
return t.innerHTML = (e || "").trim(), t;
|
|
94
|
+
}, w = u("div")(({ theme: e }) => ({
|
|
95
|
+
boxShadow: e.shadows[2],
|
|
96
|
+
borderRadius: "4px",
|
|
97
|
+
width: "400px"
|
|
98
|
+
})), T = u(d)(({ theme: e }) => ({
|
|
99
|
+
borderRadius: "4px",
|
|
100
|
+
backgroundColor: e.palette.common.white,
|
|
101
|
+
"& [data-slate-editor=\"true\"]": { minHeight: "initial !important" }
|
|
102
|
+
})), E = u(g)(({ theme: e }) => ({
|
|
103
|
+
fontSize: e.typography.fontSize + 2,
|
|
104
|
+
padding: e.spacing(.5),
|
|
105
|
+
color: e.palette.common.black,
|
|
106
|
+
position: "absolute",
|
|
107
|
+
top: "50%",
|
|
108
|
+
right: e.spacing(2),
|
|
109
|
+
transform: "translate(0, -50%)"
|
|
110
|
+
})), D = u("div")({
|
|
111
|
+
display: "flex",
|
|
112
|
+
flexDirection: "column",
|
|
113
|
+
"& > div:last-child": { border: "none" }
|
|
114
|
+
}), O = u("div")(({ theme: e }) => ({
|
|
115
|
+
padding: e.spacing(.5),
|
|
116
|
+
position: "relative"
|
|
117
|
+
})), k = class extends t.Component {
|
|
118
|
+
static propTypes = {
|
|
119
|
+
node: i.object,
|
|
120
|
+
pos: i.number,
|
|
121
|
+
uploadSoundSupport: i.object,
|
|
122
|
+
onDone: i.func,
|
|
123
|
+
choices: i.array,
|
|
124
|
+
onAddChoice: i.func.isRequired,
|
|
125
|
+
editorCallback: i.func,
|
|
126
|
+
onRemoveChoice: i.func.isRequired,
|
|
127
|
+
onSelectChoice: i.func.isRequired,
|
|
128
|
+
onToolbarDone: i.func.isRequired,
|
|
129
|
+
editor: i.object,
|
|
130
|
+
spellCheck: i.bool
|
|
131
|
+
};
|
|
132
|
+
clickedInside = !1;
|
|
133
|
+
preventDone = !1;
|
|
134
|
+
state = {
|
|
135
|
+
respAreaMarkup: "",
|
|
136
|
+
editedChoiceIndex: -1
|
|
137
|
+
};
|
|
138
|
+
componentDidMount() {
|
|
139
|
+
let { editor: e } = this.props, t = e.view.nodeDOM(e.state.selection.from);
|
|
140
|
+
if (t?.nodeType === 1) {
|
|
141
|
+
let e = t.getBoundingClientRect(), n = t.closest(".tiptap").getBoundingClientRect(), r = e.top - e.height, i = e.left - n.left;
|
|
142
|
+
this.setState({ toolbarStyle: {
|
|
143
|
+
position: "absolute",
|
|
144
|
+
top: `${r + e.height + 40}px`,
|
|
145
|
+
left: `${i + 25}px`
|
|
146
|
+
} });
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
componentDidUpdate() {
|
|
150
|
+
n(r.findDOMNode(this));
|
|
151
|
+
}
|
|
152
|
+
componentWillUnmount() {
|
|
153
|
+
this.commitPendingEdit();
|
|
154
|
+
}
|
|
155
|
+
commitPendingEdit = () => {
|
|
156
|
+
let { editedChoiceIndex: e } = this.state;
|
|
157
|
+
e < 0 || !this.editorRef?.getHTML || (this.preventDone = !1, this.onDone(this.editorRef.getHTML() || ""));
|
|
158
|
+
};
|
|
159
|
+
onRespAreaChange = (e) => {
|
|
160
|
+
this.setState({ respAreaMarkup: e });
|
|
161
|
+
};
|
|
162
|
+
onAddChoice = () => {
|
|
163
|
+
let { editor: e } = this.props, { tr: t } = e.state;
|
|
164
|
+
t.isDone = !0, e.view.dispatch(t);
|
|
165
|
+
};
|
|
166
|
+
onDone = (e) => {
|
|
167
|
+
let { choices: t, node: n, editor: r, onAddChoice: i, onToolbarDone: o } = this.props, { editedChoiceIndex: s } = this.state, c = C(e).textContent.trim();
|
|
168
|
+
s >= 0 && t?.[s]?.correct && r.commands.updateAttributes("inline_dropdown", { value: e }), a(c) || (i(n.attrs.index, e, s), r.commands.refreshResponseArea()), this.setState({ editedChoiceIndex: -1 });
|
|
169
|
+
};
|
|
170
|
+
onSelectChoice = (e, t) => {
|
|
171
|
+
let { node: n, editor: r, onToolbarDone: i, onSelectChoice: a } = this.props;
|
|
172
|
+
r.commands.updateAttributes("inline_dropdown", { value: e }), a(t), r.commands.refreshResponseArea();
|
|
173
|
+
};
|
|
174
|
+
onRemoveChoice = (e, t) => {
|
|
175
|
+
let { node: n, editor: r, onToolbarDone: i, onRemoveChoice: a } = this.props;
|
|
176
|
+
o(e, n.attrs.value) && r.commands.updateAttributes("inline_dropdown", { value: null }), a(t), r.commands.refreshResponseArea();
|
|
177
|
+
};
|
|
178
|
+
onEditChoice = (e, t) => {
|
|
179
|
+
let { editedChoiceIndex: n } = this.state;
|
|
180
|
+
if (this.clickedInside = !0, this.preventDone = !0, n >= 0) {
|
|
181
|
+
let e = this.editorRef.getHTML() || "";
|
|
182
|
+
this.onDone(e);
|
|
183
|
+
}
|
|
184
|
+
this.onRespAreaChange(e), this.setState({ editedChoiceIndex: t });
|
|
185
|
+
};
|
|
186
|
+
onKeyDown = (e) => {
|
|
187
|
+
if (e.key === "Enter") {
|
|
188
|
+
let e = this.editorRef.getHTML() || "";
|
|
189
|
+
return this.onDone(e), this.preventDone = !0, !0;
|
|
190
|
+
}
|
|
191
|
+
return !1;
|
|
192
|
+
};
|
|
193
|
+
onBlur = () => {
|
|
194
|
+
if (this.clickedInside) {
|
|
195
|
+
this.clickedInside = !1;
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
let { editedChoiceIndex: e } = this.state;
|
|
199
|
+
if (e >= 0) {
|
|
200
|
+
this.commitPendingEdit();
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
this.onAddChoice();
|
|
204
|
+
};
|
|
205
|
+
onClickInside = () => {
|
|
206
|
+
this.clickedInside = !0;
|
|
207
|
+
};
|
|
208
|
+
render() {
|
|
209
|
+
let { choices: t, spellCheck: n, uploadSoundSupport: r, mathMlOptions: i = {}, baseInputConfiguration: a = {}, responseAreaInputConfiguration: o = {} } = this.props, { respAreaMarkup: s, toolbarStyle: u } = this.state;
|
|
210
|
+
return u ? /* @__PURE__ */ l(w, {
|
|
211
|
+
"data-inline-dropdown-toolbar": "",
|
|
212
|
+
style: {
|
|
213
|
+
...u,
|
|
214
|
+
backgroundColor: "#E0E1E6",
|
|
215
|
+
zIndex: 1
|
|
216
|
+
},
|
|
217
|
+
onMouseDown: this.onClickInside,
|
|
218
|
+
children: [/* @__PURE__ */ l(O, { children: [/* @__PURE__ */ c(T, {
|
|
219
|
+
editorRef: (e) => {
|
|
220
|
+
e && (this.editorRef = e, this.props.editorCallback?.(e));
|
|
221
|
+
},
|
|
222
|
+
autoFocus: !0,
|
|
223
|
+
autoSave: !0,
|
|
224
|
+
toolbarOpts: {
|
|
225
|
+
position: "top",
|
|
226
|
+
alwaysVisible: !1,
|
|
227
|
+
showDone: !1,
|
|
228
|
+
doneOn: "blur"
|
|
229
|
+
},
|
|
230
|
+
markup: s,
|
|
231
|
+
onKeyDown: this.onKeyDown,
|
|
232
|
+
languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
|
|
233
|
+
onChange: (e) => {
|
|
234
|
+
this.preventDone || this.onRespAreaChange(e);
|
|
235
|
+
},
|
|
236
|
+
onDone: (e) => {
|
|
237
|
+
if (this.preventDone) {
|
|
238
|
+
this.preventDone = !1;
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
this.onDone(e);
|
|
242
|
+
},
|
|
243
|
+
onBlur: (e) => {
|
|
244
|
+
let t = !!(e.relatedTarget && e.relatedTarget.closest(".insert-character-dialog")), n = !!(e.relatedTarget && e.relatedTarget.closest("[aria-label=\"Done\"]"));
|
|
245
|
+
e.relatedTarget && (this.preventDone = t || n, (t || n) && (this.clickedInside = !0)), this.onBlur();
|
|
246
|
+
},
|
|
247
|
+
placeholder: "Add Choice",
|
|
248
|
+
pluginProps: e(o?.inputConfiguration, a),
|
|
249
|
+
spellCheck: n,
|
|
250
|
+
uploadSoundSupport: r,
|
|
251
|
+
mathMlOptions: i
|
|
252
|
+
}), /* @__PURE__ */ c(E, {
|
|
253
|
+
onClick: () => this.onAddChoice(),
|
|
254
|
+
size: "small",
|
|
255
|
+
"aria-label": "Add",
|
|
256
|
+
children: /* @__PURE__ */ c(f, { fontSize: "inherit" })
|
|
257
|
+
})] }), t && /* @__PURE__ */ c(D, { children: t.map(({ label: e, correct: t }, n) => /* @__PURE__ */ c(S, {
|
|
258
|
+
onClick: () => this.onSelectChoice(e, n),
|
|
259
|
+
onRemoveChoice: () => this.onRemoveChoice(e, n),
|
|
260
|
+
onEditChoice: () => this.onEditChoice(e, n),
|
|
261
|
+
value: e,
|
|
262
|
+
correct: t
|
|
263
|
+
}, n)) })]
|
|
264
|
+
}) : null;
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
//#endregion
|
|
268
|
+
export { k as default };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-elements/packages/inline-dropdown/configure/src/main.jsx
|
|
3
|
+
* @auto-generated
|
|
4
|
+
*
|
|
5
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
+
* Manual edits will be overwritten on next sync.
|
|
7
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import PropTypes from 'prop-types';
|
|
11
|
+
export declare class Main extends React.Component {
|
|
12
|
+
static propTypes: {
|
|
13
|
+
configuration: PropTypes.Validator<object>;
|
|
14
|
+
model: PropTypes.Validator<object>;
|
|
15
|
+
disableSidePanel: PropTypes.Requireable<boolean>;
|
|
16
|
+
onModelChanged: PropTypes.Validator<(...args: any[]) => any>;
|
|
17
|
+
onConfigurationChanged: PropTypes.Validator<(...args: any[]) => any>;
|
|
18
|
+
imageSupport: PropTypes.Requireable<PropTypes.InferProps<{
|
|
19
|
+
add: PropTypes.Validator<(...args: any[]) => any>;
|
|
20
|
+
delete: PropTypes.Validator<(...args: any[]) => any>;
|
|
21
|
+
}>>;
|
|
22
|
+
uploadSoundSupport: PropTypes.Requireable<PropTypes.InferProps<{
|
|
23
|
+
add: PropTypes.Validator<(...args: any[]) => any>;
|
|
24
|
+
delete: PropTypes.Validator<(...args: any[]) => any>;
|
|
25
|
+
}>>;
|
|
26
|
+
};
|
|
27
|
+
state: {
|
|
28
|
+
warning: {
|
|
29
|
+
open: boolean;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
componentDidMount(): void;
|
|
33
|
+
UNSAFE_componentWillReceiveProps(nProps: any): void;
|
|
34
|
+
componentDidUpdate(): void;
|
|
35
|
+
onModelChange: any;
|
|
36
|
+
onPromptChanged: any;
|
|
37
|
+
onRationaleChanged: any;
|
|
38
|
+
onChoiceRationaleChanged: any;
|
|
39
|
+
onTeacherInstructionsChanged: any;
|
|
40
|
+
onMarkupChanged: any;
|
|
41
|
+
onCheck: any;
|
|
42
|
+
validateResponseAreaClose: any;
|
|
43
|
+
onChange: any;
|
|
44
|
+
onAddChoice: any;
|
|
45
|
+
onRemoveChoice: any;
|
|
46
|
+
onSelectChoice: any;
|
|
47
|
+
render(): React.JSX.Element;
|
|
48
|
+
}
|
|
49
|
+
export default Main;
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
import { generateValidationMessage as e } from "./utils.js";
|
|
2
|
+
import t from "./inline-dropdown-toolbar.js";
|
|
3
|
+
import n from "./response-area.js";
|
|
4
|
+
import r from "react";
|
|
5
|
+
import { renderMath as i } from "@pie-element/shared-math-rendering-mathjax";
|
|
6
|
+
import a from "react-dom";
|
|
7
|
+
import o from "prop-types";
|
|
8
|
+
import { cloneDeep as s, isEmpty as c, isEqual as l, isUndefined as u, max as d, reduce as f } from "@pie-element/shared-lodash";
|
|
9
|
+
import { color as p } from "@pie-lib/render-ui";
|
|
10
|
+
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
11
|
+
import { styled as g } from "@mui/material/styles";
|
|
12
|
+
import _, { ALL_PLUGINS as v, deleteInlineDropdownByIndex as y } from "@pie-lib/editable-html-tip-tap";
|
|
13
|
+
import { AlertDialog as ee, InputContainer as b, layout as te, settings as x } from "@pie-lib/config-ui";
|
|
14
|
+
import S from "@mui/material/Tooltip";
|
|
15
|
+
import C from "@mui/material/Typography";
|
|
16
|
+
import w from "@mui/material/Accordion";
|
|
17
|
+
import ne from "@mui/material/AccordionSummary";
|
|
18
|
+
import T from "@mui/material/AccordionDetails";
|
|
19
|
+
import E from "@mui/icons-material/ExpandMore";
|
|
20
|
+
import re from "@mui/icons-material/Info";
|
|
21
|
+
//#region src/author/main.tsx
|
|
22
|
+
var { toggle: D, Panel: ie, dropdown: ae } = x, O = g(b)(({ theme: e }) => ({
|
|
23
|
+
width: "100%",
|
|
24
|
+
paddingTop: e.spacing(2),
|
|
25
|
+
marginBottom: e.spacing(2)
|
|
26
|
+
})), oe = g(b)(({ theme: e }) => ({
|
|
27
|
+
width: "100%",
|
|
28
|
+
paddingTop: e.spacing(.5),
|
|
29
|
+
marginBottom: e.spacing(2)
|
|
30
|
+
})), k = g(C)(({ theme: e }) => ({
|
|
31
|
+
fontSize: e.typography.fontSize + 2,
|
|
32
|
+
marginRight: e.spacing(1)
|
|
33
|
+
})), se = g("span")(({ theme: e }) => ({
|
|
34
|
+
display: "flex",
|
|
35
|
+
alignItems: "center",
|
|
36
|
+
whiteSpace: "break-spaces",
|
|
37
|
+
color: p.disabled(),
|
|
38
|
+
padding: 0,
|
|
39
|
+
fontSize: e.typography.fontSize - 2,
|
|
40
|
+
lineHeight: 1
|
|
41
|
+
})), A = g("div")(({ theme: e }) => ({ marginBottom: e.spacing(2.5) })), j = g(T)({
|
|
42
|
+
display: "block",
|
|
43
|
+
paddingTop: 0,
|
|
44
|
+
paddingBottom: 0
|
|
45
|
+
}), M = g("div")(({ theme: e }) => ({
|
|
46
|
+
display: "flex",
|
|
47
|
+
alignItems: "center",
|
|
48
|
+
marginBottom: e.spacing(1)
|
|
49
|
+
})), N = g(S)(({ theme: e }) => ({ "& .MuiTooltip-tooltip": {
|
|
50
|
+
fontSize: e.typography.fontSize - 2,
|
|
51
|
+
whiteSpace: "pre",
|
|
52
|
+
maxWidth: "500px"
|
|
53
|
+
} })), P = g("div")(({ theme: e }) => ({
|
|
54
|
+
fontSize: e.typography.fontSize - 2,
|
|
55
|
+
color: e.palette.error.main,
|
|
56
|
+
paddingTop: e.spacing(1)
|
|
57
|
+
})), F = (e) => {
|
|
58
|
+
let t = document.createElement("div");
|
|
59
|
+
return t.innerHTML = (e || "").trim(), t;
|
|
60
|
+
}, I = class extends r.Component {
|
|
61
|
+
static propTypes = {
|
|
62
|
+
configuration: o.object.isRequired,
|
|
63
|
+
model: o.object.isRequired,
|
|
64
|
+
disableSidePanel: o.bool,
|
|
65
|
+
onModelChanged: o.func.isRequired,
|
|
66
|
+
onConfigurationChanged: o.func.isRequired,
|
|
67
|
+
imageSupport: o.shape({
|
|
68
|
+
add: o.func.isRequired,
|
|
69
|
+
delete: o.func.isRequired
|
|
70
|
+
}),
|
|
71
|
+
uploadSoundSupport: o.shape({
|
|
72
|
+
add: o.func.isRequired,
|
|
73
|
+
delete: o.func.isRequired
|
|
74
|
+
})
|
|
75
|
+
};
|
|
76
|
+
state = { warning: { open: !1 } };
|
|
77
|
+
componentDidMount() {
|
|
78
|
+
let { model: { choices: e } } = this.props;
|
|
79
|
+
this.setState({ respAreaChoices: s(e) });
|
|
80
|
+
}
|
|
81
|
+
UNSAFE_componentWillReceiveProps(e) {
|
|
82
|
+
let t = {};
|
|
83
|
+
(!l(e.model.choices, this.props.model.choices) || !l(e.model.choices, this.state.respAreaChoices)) && (t.respAreaChoices = s(e.model.choices)), c(t) || this.setState(t);
|
|
84
|
+
}
|
|
85
|
+
componentDidUpdate() {
|
|
86
|
+
i(a.findDOMNode(this));
|
|
87
|
+
}
|
|
88
|
+
onModelChange = (e) => {
|
|
89
|
+
this.props.onModelChanged({
|
|
90
|
+
...this.props.model,
|
|
91
|
+
...e
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
onPromptChanged = (e) => {
|
|
95
|
+
this.onModelChange({ prompt: e });
|
|
96
|
+
};
|
|
97
|
+
onRationaleChanged = (e) => {
|
|
98
|
+
this.onModelChange({ rationale: e });
|
|
99
|
+
};
|
|
100
|
+
onChoiceRationaleChanged = (e, t) => {
|
|
101
|
+
let { model: n } = this.props, r = n.choices && n.choices[e] && n.choices[e].findIndex((e) => e.label === t.label && e.value === t.value);
|
|
102
|
+
n.choices[e] && n.choices[e].splice(r, 1, t), this.onModelChange(n);
|
|
103
|
+
};
|
|
104
|
+
onTeacherInstructionsChanged = (e) => {
|
|
105
|
+
this.onModelChange({ teacherInstructions: e });
|
|
106
|
+
};
|
|
107
|
+
onMarkupChanged = (e) => {
|
|
108
|
+
this.onModelChange({ slateMarkup: e });
|
|
109
|
+
};
|
|
110
|
+
onCheck = (e, t) => {
|
|
111
|
+
this.setState({ warning: {
|
|
112
|
+
open: !0,
|
|
113
|
+
text: "Response areas with under 2 options or with no correct answers will be discarded.",
|
|
114
|
+
onClose: () => {
|
|
115
|
+
this.setState({ warning: { open: !1 } }, t);
|
|
116
|
+
},
|
|
117
|
+
onConfirm: () => {
|
|
118
|
+
this.setState({ warning: { open: !1 } }, e);
|
|
119
|
+
}
|
|
120
|
+
} });
|
|
121
|
+
};
|
|
122
|
+
validateResponseAreaClose = (e, t, n, r, i) => {
|
|
123
|
+
let { respAreaChoices: a } = this.state, o = e.attrs.index, s = a[o] || [];
|
|
124
|
+
if (!(s.length < 2 || !s.find((e) => e.correct))) {
|
|
125
|
+
r();
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
n._holdInlineDropdownToolbarIndex = o, this.onCheck(() => {
|
|
129
|
+
delete n._holdInlineDropdownToolbarIndex, y(n, o, t), r();
|
|
130
|
+
}, i);
|
|
131
|
+
};
|
|
132
|
+
onChange = (e) => {
|
|
133
|
+
let { respAreaChoices: t } = this.state, n = F(e), r = n.querySelectorAll("[data-type=\"inline_dropdown\"]"), i = {};
|
|
134
|
+
r.forEach((e) => {
|
|
135
|
+
i[e.dataset.index] = e.dataset.value || "";
|
|
136
|
+
});
|
|
137
|
+
let a = f(t, (e, n, r) => (u(i[r]) || (e[r] = t[r]), e), {}), o = {};
|
|
138
|
+
r.forEach((e, t) => {
|
|
139
|
+
let n = a[e.dataset.index];
|
|
140
|
+
n && (o[t] = n), e.dataset.index = t;
|
|
141
|
+
}), this.onModelChange({
|
|
142
|
+
choices: s(o),
|
|
143
|
+
slateMarkup: n.innerHTML
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
onAddChoice = (e, t, n) => {
|
|
147
|
+
let { respAreaChoices: r } = this.state, { maxResponseAreaChoices: i } = this.props.configuration, a = (e) => this.setState({ warning: {
|
|
148
|
+
open: !0,
|
|
149
|
+
text: e,
|
|
150
|
+
onClose: void 0,
|
|
151
|
+
onConfirm: () => {
|
|
152
|
+
this.setState({ warning: { open: !1 } });
|
|
153
|
+
}
|
|
154
|
+
} });
|
|
155
|
+
if (r[e] && r[e].length >= i) {
|
|
156
|
+
a(`There are only ${i} answers allowed per choice.`);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (r[e] || (r[e] = []), (r[e] || []).find((e, r) => e.label === t && r !== n)) {
|
|
160
|
+
a("Duplicate answers are not allowed.");
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
if (n >= 0 && r[e]?.[n]) r[e][n].label = t;
|
|
164
|
+
else {
|
|
165
|
+
let n = r[e] && d(r[e].map((e) => parseInt(e.value)).filter((e) => !isNaN(e))) || 0;
|
|
166
|
+
r[e].push({
|
|
167
|
+
label: t,
|
|
168
|
+
value: `${n + 1}`,
|
|
169
|
+
correct: !1
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
this.onModelChange({ choices: s(r) });
|
|
173
|
+
};
|
|
174
|
+
onRemoveChoice = (e, t) => {
|
|
175
|
+
let { respAreaChoices: n } = this.state;
|
|
176
|
+
n[e].splice(t, 1), this.onModelChange({ choices: s(n) });
|
|
177
|
+
};
|
|
178
|
+
onSelectChoice = (e, t) => {
|
|
179
|
+
let { respAreaChoices: n } = this.state;
|
|
180
|
+
n[e] = n[e].map((e, n) => ({
|
|
181
|
+
...e,
|
|
182
|
+
correct: n === t
|
|
183
|
+
})), this.onModelChange({ choices: s(n) });
|
|
184
|
+
};
|
|
185
|
+
render() {
|
|
186
|
+
let { warning: i } = this.state, { model: a, configuration: o, onConfigurationChanged: s, imageSupport: c, uploadSoundSupport: l } = this.props, { baseInputConfiguration: u = {}, choiceRationale: d = {}, contentDimensions: f = {}, lockChoiceOrder: p = {}, maxResponseAreas: g, maxImageWidth: y = {}, maxImageHeight: b = {}, partialScoring: x = {}, prompt: S = {}, rationale: C = {}, settingsPanelDisabled: T, spellCheck: F = {}, teacherInstructions: I = {}, template: ce = {}, withRubric: L = {}, mathMlOptions: R = {}, language: z = {}, languageChoices: B = {}, responseAreaInputConfiguration: V = {} } = o || {}, { choiceRationaleEnabled: H, choices: U, errors: W, extraCSSRules: le, promptEnabled: ue, rationaleEnabled: de, spellCheckEnabled: G, teacherInstructionsEnabled: fe, toolbarEditorPosition: pe } = a || {}, { prompt: K, rationale: q, responseAreasError: J, responseAreaChoicesError: me, teacherInstructions: Y } = W || {}, X = y && y.prompt, Z = b && b.prompt, he = () => (Object.keys(U) || []).map((e, t) => /* @__PURE__ */ m(A, { children: /* @__PURE__ */ h(w, {
|
|
187
|
+
slotProps: { transition: { timeout: {
|
|
188
|
+
enter: 225,
|
|
189
|
+
exit: 195
|
|
190
|
+
} } },
|
|
191
|
+
children: [/* @__PURE__ */ m(ne, {
|
|
192
|
+
expandIcon: /* @__PURE__ */ m(E, {}),
|
|
193
|
+
children: /* @__PURE__ */ m(k, {
|
|
194
|
+
component: "div",
|
|
195
|
+
children: `Rationale for response area #${t + 1}`
|
|
196
|
+
})
|
|
197
|
+
}), /* @__PURE__ */ m(j, { children: (U[e] || []).map((t) => /* @__PURE__ */ h(r.Fragment, { children: [/* @__PURE__ */ m(se, { dangerouslySetInnerHTML: { __html: `${C.label} for ${t.label} (${t.correct ? "correct" : "incorrect"})` } }), /* @__PURE__ */ m(oe, { children: /* @__PURE__ */ m(_, {
|
|
198
|
+
markup: t.rationale || "",
|
|
199
|
+
spellCheck: G,
|
|
200
|
+
pluginProps: $(C?.inputConfiguration),
|
|
201
|
+
onChange: (n) => this.onChoiceRationaleChanged(e, {
|
|
202
|
+
...t,
|
|
203
|
+
rationale: n
|
|
204
|
+
}),
|
|
205
|
+
imageSupport: c,
|
|
206
|
+
maxImageWidth: y && y.rationale || X,
|
|
207
|
+
maxImageHeight: b && b.rationale || Z,
|
|
208
|
+
uploadSoundSupport: l,
|
|
209
|
+
mathMlOptions: R
|
|
210
|
+
}) })] }, t.label)) })]
|
|
211
|
+
}) }, e)), Q = { position: pe === "top" ? "top" : "bottom" }, ge = e(o), _e = {
|
|
212
|
+
partialScoring: x.settings && D(x.label),
|
|
213
|
+
lockChoiceOrder: p.settings && D(p.label),
|
|
214
|
+
"language.enabled": z.settings && D(z.label, !0),
|
|
215
|
+
language: z.settings && z.enabled && ae(B.label, B.options)
|
|
216
|
+
}, ve = {
|
|
217
|
+
teacherInstructionsEnabled: I.settings && D(I.label),
|
|
218
|
+
rationaleEnabled: C.settings && D(C.label),
|
|
219
|
+
choiceRationaleEnabled: d.settings && D(d.label),
|
|
220
|
+
promptEnabled: S.settings && D(S.label),
|
|
221
|
+
spellCheckEnabled: F.settings && D(F.label),
|
|
222
|
+
rubricEnabled: L?.settings && D(L?.label)
|
|
223
|
+
}, $ = (e = {}) => ({
|
|
224
|
+
...u,
|
|
225
|
+
...e
|
|
226
|
+
});
|
|
227
|
+
return /* @__PURE__ */ h(te.ConfigLayout, {
|
|
228
|
+
extraCSSRules: {
|
|
229
|
+
names: ["red", "blue"],
|
|
230
|
+
rules: "\n .red {\n color: red !important;\n }\n\n .blue {\n color: blue !important;\n }\n "
|
|
231
|
+
},
|
|
232
|
+
dimensions: f,
|
|
233
|
+
hideSettings: T,
|
|
234
|
+
settings: /* @__PURE__ */ m(ie, {
|
|
235
|
+
model: a,
|
|
236
|
+
configuration: o,
|
|
237
|
+
onChangeModel: (e) => this.onModelChange(e),
|
|
238
|
+
onChangeConfiguration: (e) => s(e, !0),
|
|
239
|
+
groups: {
|
|
240
|
+
Settings: _e,
|
|
241
|
+
Properties: ve
|
|
242
|
+
}
|
|
243
|
+
}),
|
|
244
|
+
children: [
|
|
245
|
+
fe && /* @__PURE__ */ h(O, {
|
|
246
|
+
label: I.label,
|
|
247
|
+
children: [/* @__PURE__ */ m(_, {
|
|
248
|
+
markup: a.teacherInstructions || "",
|
|
249
|
+
onChange: this.onTeacherInstructionsChanged,
|
|
250
|
+
imageSupport: c,
|
|
251
|
+
nonEmpty: !1,
|
|
252
|
+
error: Y,
|
|
253
|
+
toolbarOpts: Q,
|
|
254
|
+
pluginProps: $(I?.inputConfiguration),
|
|
255
|
+
spellCheck: G,
|
|
256
|
+
maxImageWidth: y && y.teacherInstructions || X,
|
|
257
|
+
maxImageHeight: b && b.teacherInstructions || Z,
|
|
258
|
+
uploadSoundSupport: l,
|
|
259
|
+
languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
|
|
260
|
+
mathMlOptions: R
|
|
261
|
+
}), Y && /* @__PURE__ */ m(P, { children: Y })]
|
|
262
|
+
}),
|
|
263
|
+
ue && /* @__PURE__ */ h(O, {
|
|
264
|
+
label: S.label,
|
|
265
|
+
children: [/* @__PURE__ */ m(_, {
|
|
266
|
+
markup: a.prompt,
|
|
267
|
+
onChange: this.onPromptChanged,
|
|
268
|
+
imageSupport: c,
|
|
269
|
+
nonEmpty: !1,
|
|
270
|
+
disableUnderline: !0,
|
|
271
|
+
error: K,
|
|
272
|
+
toolbarOpts: Q,
|
|
273
|
+
pluginProps: $(S?.inputConfiguration),
|
|
274
|
+
spellCheck: G,
|
|
275
|
+
maxImageWidth: X,
|
|
276
|
+
maxImageHeight: Z,
|
|
277
|
+
uploadSoundSupport: l,
|
|
278
|
+
languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
|
|
279
|
+
mathMlOptions: R
|
|
280
|
+
}), K && /* @__PURE__ */ m(P, { children: K })]
|
|
281
|
+
}),
|
|
282
|
+
/* @__PURE__ */ h(M, { children: [/* @__PURE__ */ m(k, {
|
|
283
|
+
component: "div",
|
|
284
|
+
children: "Define Template, Choices, and Correct Responses"
|
|
285
|
+
}), /* @__PURE__ */ m(N, {
|
|
286
|
+
disableFocusListener: !0,
|
|
287
|
+
disableTouchListener: !0,
|
|
288
|
+
placement: "right",
|
|
289
|
+
title: ge,
|
|
290
|
+
children: /* @__PURE__ */ m(re, {
|
|
291
|
+
fontSize: "small",
|
|
292
|
+
color: "primary"
|
|
293
|
+
})
|
|
294
|
+
})] }),
|
|
295
|
+
/* @__PURE__ */ m(n, {
|
|
296
|
+
responseAreasError: J,
|
|
297
|
+
responseAreaChoicesError: me,
|
|
298
|
+
editableHtmlProps: {
|
|
299
|
+
pluginProps: $(ce?.inputConfiguration),
|
|
300
|
+
activePlugins: v,
|
|
301
|
+
toolbarOpts: { position: "top" },
|
|
302
|
+
extraCSSRules: {
|
|
303
|
+
names: ["red", "blue"],
|
|
304
|
+
rules: "\n .red {\n color: red !important;\n }\n\n .blue {\n color: blue !important;\n }\n "
|
|
305
|
+
},
|
|
306
|
+
responseAreaProps: {
|
|
307
|
+
type: "inline-dropdown",
|
|
308
|
+
options: { duplicates: !0 },
|
|
309
|
+
maxResponseAreas: g,
|
|
310
|
+
onToolbarCloseRequest: ([e, t], n, r, i) => {
|
|
311
|
+
this.validateResponseAreaClose(e, t, n, r, i);
|
|
312
|
+
},
|
|
313
|
+
respAreaToolbar: (e, n, r) => {
|
|
314
|
+
let [i, a] = e, { respAreaChoices: o } = this.state;
|
|
315
|
+
return (e) => /* @__PURE__ */ m(t, {
|
|
316
|
+
...e,
|
|
317
|
+
onAddChoice: this.onAddChoice,
|
|
318
|
+
onRemoveChoice: (e) => this.onRemoveChoice(i.attrs.index, e),
|
|
319
|
+
onSelectChoice: (e) => this.onSelectChoice(i.attrs.index, e),
|
|
320
|
+
node: i,
|
|
321
|
+
pos: a,
|
|
322
|
+
editor: n,
|
|
323
|
+
onToolbarDone: r,
|
|
324
|
+
choices: o[i.attrs.index],
|
|
325
|
+
spellCheck: G,
|
|
326
|
+
uploadSoundSupport: l,
|
|
327
|
+
mathMlOptions: R,
|
|
328
|
+
baseInputConfiguration: u,
|
|
329
|
+
responseAreaInputConfiguration: V
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
},
|
|
333
|
+
spellCheck: G,
|
|
334
|
+
markup: a.slateMarkup || "",
|
|
335
|
+
onChange: this.onChange,
|
|
336
|
+
imageSupport: c,
|
|
337
|
+
disableImageAlignmentButtons: !0,
|
|
338
|
+
disabled: !1,
|
|
339
|
+
highlightShape: !1,
|
|
340
|
+
error: J,
|
|
341
|
+
uploadSoundSupport: l,
|
|
342
|
+
languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
|
|
343
|
+
mathMlOptions: R
|
|
344
|
+
}
|
|
345
|
+
}),
|
|
346
|
+
H && he(),
|
|
347
|
+
de && /* @__PURE__ */ h(O, {
|
|
348
|
+
label: C.label,
|
|
349
|
+
children: [/* @__PURE__ */ m(_, {
|
|
350
|
+
markup: a.rationale || "",
|
|
351
|
+
onChange: this.onRationaleChanged,
|
|
352
|
+
imageSupport: c,
|
|
353
|
+
error: q,
|
|
354
|
+
toolbarOpts: Q,
|
|
355
|
+
pluginProps: $(C?.inputConfiguration),
|
|
356
|
+
spellCheck: G,
|
|
357
|
+
maxImageWidth: y && y.rationale || X,
|
|
358
|
+
maxImageHeight: b && b.rationale || Z,
|
|
359
|
+
uploadSoundSupport: l,
|
|
360
|
+
languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
|
|
361
|
+
mathMlOptions: R
|
|
362
|
+
}), q && /* @__PURE__ */ m(P, { children: q })]
|
|
363
|
+
}),
|
|
364
|
+
/* @__PURE__ */ m(ee, {
|
|
365
|
+
open: i.open,
|
|
366
|
+
title: "Warning",
|
|
367
|
+
text: i.text,
|
|
368
|
+
onClose: i.onClose,
|
|
369
|
+
onConfirm: i.onConfirm,
|
|
370
|
+
disableAutoFocus: !0,
|
|
371
|
+
disableEnforceFocus: !0,
|
|
372
|
+
disableRestoreFocus: !0
|
|
373
|
+
})
|
|
374
|
+
]
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
//#endregion
|
|
379
|
+
export { I as default };
|