@pie-element/categorize 13.2.0-next.11 → 13.2.0-next.13
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/author.js +2 -0
- package/dist/browser/{alert-dialog-BL9K_lnF.js → alert-dialog-CSSeVh7l.js} +2166 -2164
- package/dist/browser/alert-dialog-CSSeVh7l.js.map +1 -0
- package/dist/browser/author/index.js +23454 -30963
- package/dist/browser/author/index.js.map +1 -1
- package/dist/browser/controller/index.js +1 -1
- package/dist/browser/delivery/index.js +101 -88
- package/dist/browser/delivery/index.js.map +1 -1
- package/dist/browser/{dist-C11U2GIc.js → dist-BRZI5EqS.js} +109 -5
- package/dist/browser/dist-BRZI5EqS.js.map +1 -0
- package/dist/delivery/categorize/index.js +67 -61
- package/dist/index.iife.js +22 -22
- package/package.json +9 -7
- package/dist/browser/alert-dialog-BL9K_lnF.js.map +0 -1
- package/dist/browser/dist-C11U2GIc.js.map +0 -1
|
@@ -10,32 +10,33 @@ import m from "prop-types";
|
|
|
10
10
|
import h from "debug";
|
|
11
11
|
import { styled as g } from "@mui/material/styles";
|
|
12
12
|
import { DragOverlay as _ } from "@dnd-kit/core";
|
|
13
|
-
import v from "@
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import E from "
|
|
18
|
-
import
|
|
13
|
+
import { restrictToFirstScrollableAncestor as v } from "@dnd-kit/modifiers";
|
|
14
|
+
import y from "@pie-lib/correct-answer-toggle";
|
|
15
|
+
import { buildState as b, moveChoiceToCategory as x, removeChoiceFromCategory as S } from "@pie-lib/categorize";
|
|
16
|
+
import { DragProvider as C, uid as w } from "@pie-lib/drag";
|
|
17
|
+
import { jsx as T, jsxs as E } from "react/jsx-runtime";
|
|
18
|
+
import D from "@pie-lib/translator";
|
|
19
|
+
import { AlertDialog as O } from "@pie-lib/config-ui";
|
|
19
20
|
//#region src/delivery/categorize/index.tsx
|
|
20
|
-
function
|
|
21
|
+
function k(e) {
|
|
21
22
|
return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
|
|
22
23
|
}
|
|
23
|
-
function
|
|
24
|
-
return !e ||
|
|
24
|
+
function A(e, t) {
|
|
25
|
+
return !e || k(e) ? e : k(e.default) ? e.default : t && k(e[t]) ? e[t] : t && k(e[t]?.default) ? e[t].default : e;
|
|
25
26
|
}
|
|
26
|
-
var
|
|
27
|
+
var j = A(u, "UiLayout") || A(L.UiLayout, "UiLayout"), M = A(l, "PreviewPrompt") || A(L.PreviewPrompt, "PreviewPrompt"), N = A(s, "Collapsible") || A(L.Collapsible, "Collapsible"), P = A(c, "Feedback") || A(L.Feedback, "Feedback"), F = o, I = F.default, L = I && typeof I == "object" ? I : F, { translator: R } = D, z = h("@pie-ui:categorize"), B = "choices-board", V = 250, H = class extends i.Component {
|
|
27
28
|
static propTypes = { children: m.node };
|
|
28
29
|
containerRef = i.createRef();
|
|
29
30
|
componentDidMount() {
|
|
30
31
|
this.containerRef.current && a(this.containerRef.current);
|
|
31
32
|
}
|
|
32
33
|
render() {
|
|
33
|
-
return /* @__PURE__ */
|
|
34
|
+
return /* @__PURE__ */ T("div", {
|
|
34
35
|
ref: this.containerRef,
|
|
35
36
|
children: this.props.children
|
|
36
37
|
});
|
|
37
38
|
}
|
|
38
|
-
},
|
|
39
|
+
}, U = class extends i.Component {
|
|
39
40
|
static propTypes = {
|
|
40
41
|
model: m.object,
|
|
41
42
|
session: m.shape({ answers: m.arrayOf(m.shape({
|
|
@@ -58,19 +59,19 @@ var A = k(u, "UiLayout") || k(I.UiLayout, "UiLayout"), j = k(l, "PreviewPrompt")
|
|
|
58
59
|
};
|
|
59
60
|
}
|
|
60
61
|
removeChoice = (e) => {
|
|
61
|
-
|
|
62
|
+
z("[removeChoice]: ", e);
|
|
62
63
|
let { onAnswersChange: t, session: n } = this.props;
|
|
63
|
-
t(
|
|
64
|
+
t(S(e.id, e.categoryId, e.choiceIndex, n.answers));
|
|
64
65
|
};
|
|
65
66
|
dropChoice = (e, t) => {
|
|
66
67
|
let { session: n, onAnswersChange: r, model: i } = this.props, { maxChoicesPerCategory: a = 0 } = i || {}, { answers: o = [] } = n || {}, s;
|
|
67
|
-
t ?
|
|
68
|
+
t ? z("[dropChoice] category: ", t.categoryId, "choice: ", t) : z("[dropChoice] category: ", void 0, "choice: ", void 0);
|
|
68
69
|
let c = o.find((t) => t.category === e);
|
|
69
|
-
t && a === 1 && c && c.choices && c.choices.length === 1 ? (s =
|
|
70
|
+
t && a === 1 && c && c.choices && c.choices.length === 1 ? (s = x(t.id, t.categoryId, e, t.choiceIndex, o), s = S(c.choices[0], e, 0, s)) : t && a > 1 && c && c.choices && c.choices.length === a ? (s = t.categoryId ? x(t.id, t.categoryId, t.categoryId, t.choiceIndex, o) : S(t.id, t.categoryId, t.choiceIndex, o), this.setState({ showMaxChoiceAlert: !0 })) : a !== 0 && c && c.choices && c.choices.length > a ? (s = o, this.setState({ showMaxChoiceAlert: !0 })) : s = t ? x(t.id, t.categoryId, e, t.choiceIndex, o) : this.removeChoice(e), t && r(s);
|
|
70
71
|
};
|
|
71
72
|
UNSAFE_componentWillReceiveProps(e) {
|
|
72
73
|
let { model: t } = this.props, { model: n } = e;
|
|
73
|
-
t.note && t.language && t.language !== n.language && t.note ===
|
|
74
|
+
t.note && t.language && t.language !== n.language && t.note === R.t("common:commonCorrectAnswerWithAlternates", { lng: t.language }) && (t.note = R.t("common:commonCorrectAnswerWithAlternates", { lng: n.language })), this.setState({ showCorrect: !1 });
|
|
74
75
|
}
|
|
75
76
|
toggleShowCorrect = () => this.setState({ showCorrect: !this.state.showCorrect }, () => {
|
|
76
77
|
this.props.onShowCorrectToggle();
|
|
@@ -95,46 +96,46 @@ var A = k(u, "UiLayout") || k(I.UiLayout, "UiLayout"), j = k(l, "PreviewPrompt")
|
|
|
95
96
|
};
|
|
96
97
|
existAlternateResponse = (e) => e?.some((e) => e.alternateResponses?.length > 0);
|
|
97
98
|
render() {
|
|
98
|
-
let { model: e, session: r, selectedItem: a, onSelectClick: o, onPlacementClick: s } = this.props, { showCorrect: c, showMaxChoiceAlert: l } = this.state, { choicesPosition: u, extraCSSRules: d, note: m, showNote: h, env: g, language: _, maxChoicesPerCategory:
|
|
99
|
-
flexDirection: this.getPositionDirection(
|
|
99
|
+
let { model: e, session: r, selectedItem: a, onSelectClick: o, onPlacementClick: s } = this.props, { showCorrect: c, showMaxChoiceAlert: l } = this.state, { choicesPosition: u, extraCSSRules: d, note: m, showNote: h, env: g, language: _, maxChoicesPerCategory: v, autoplayAudioEnabled: x, customAudioButton: S } = e, { mode: C, role: w } = g || {}, D = u || "above", k = {
|
|
100
|
+
flexDirection: this.getPositionDirection(D),
|
|
100
101
|
gap: "8px"
|
|
101
|
-
}, { categories: A, choices:
|
|
102
|
-
|
|
103
|
-
let { rowLabels: F, categoriesPerRow: I, correctResponse:
|
|
102
|
+
}, { categories: A, choices: j, correct: N } = b(e.categories, e.choices, c ? e.correctResponse : r.answers, e.correctResponse);
|
|
103
|
+
z("[render] disabled: ", e.disabled);
|
|
104
|
+
let { rowLabels: F, categoriesPerRow: I, correctResponse: L, fontSizeFactor: B } = e, V = A && Math.ceil(A.length / I) || 0, H = this.existAlternateResponse(L) || !1, U = (c || C === "view" && w === "instructor") && h && m && H, W = R.t("translation:categorize:limitMaxChoicesPerCategory", {
|
|
104
105
|
lng: e.language,
|
|
105
|
-
maxChoicesPerCategory:
|
|
106
|
-
}),
|
|
107
|
-
return /* @__PURE__ */
|
|
106
|
+
maxChoicesPerCategory: v
|
|
107
|
+
}), X = R.t("common:warning", { lng: e.language }), Z = R.t("common:cancel", { lng: e.language }), Q = e.rationale && (p(e.rationale) || f(e.rationale));
|
|
108
|
+
return /* @__PURE__ */ E(G, {
|
|
108
109
|
extraCSSRules: d,
|
|
109
110
|
id: "main-container",
|
|
110
111
|
fontSizeFactor: B,
|
|
111
112
|
children: [
|
|
112
|
-
e.teacherInstructions && (p(e.teacherInstructions) || f(e.teacherInstructions)) && /* @__PURE__ */
|
|
113
|
+
e.teacherInstructions && (p(e.teacherInstructions) || f(e.teacherInstructions)) && /* @__PURE__ */ T(i.Fragment, { children: /* @__PURE__ */ T(Y, {
|
|
113
114
|
labels: {
|
|
114
115
|
hidden: "Show Teacher Instructions",
|
|
115
116
|
visible: "Hide Teacher Instructions"
|
|
116
117
|
},
|
|
117
|
-
children: /* @__PURE__ */
|
|
118
|
+
children: /* @__PURE__ */ T(M, { prompt: e.teacherInstructions })
|
|
118
119
|
}) }),
|
|
119
|
-
e.prompt && /* @__PURE__ */
|
|
120
|
+
e.prompt && /* @__PURE__ */ T(M, {
|
|
120
121
|
prompt: e.prompt,
|
|
121
122
|
autoplayAudioEnabled: x,
|
|
122
123
|
customAudioButton: S
|
|
123
124
|
}),
|
|
124
|
-
/* @__PURE__ */
|
|
125
|
-
show: c ||
|
|
125
|
+
/* @__PURE__ */ T(y, {
|
|
126
|
+
show: c || N === !1,
|
|
126
127
|
toggled: c,
|
|
127
128
|
onToggle: this.toggleShowCorrect,
|
|
128
129
|
language: _
|
|
129
130
|
}),
|
|
130
|
-
/* @__PURE__ */ T(
|
|
131
|
+
/* @__PURE__ */ T(q, { children: /* @__PURE__ */ E(J, {
|
|
131
132
|
style: k,
|
|
132
|
-
children: [/* @__PURE__ */
|
|
133
|
+
children: [/* @__PURE__ */ T("div", {
|
|
133
134
|
style: {
|
|
134
135
|
display: "flex",
|
|
135
136
|
flex: 1
|
|
136
137
|
},
|
|
137
|
-
children: /* @__PURE__ */
|
|
138
|
+
children: /* @__PURE__ */ T(n, {
|
|
138
139
|
model: e,
|
|
139
140
|
disabled: e.disabled,
|
|
140
141
|
categories: A,
|
|
@@ -145,42 +146,42 @@ var A = k(u, "UiLayout") || k(I.UiLayout, "UiLayout"), j = k(l, "PreviewPrompt")
|
|
|
145
146
|
onSelectClick: o,
|
|
146
147
|
onPlacementClick: s
|
|
147
148
|
})
|
|
148
|
-
}), /* @__PURE__ */
|
|
149
|
+
}), /* @__PURE__ */ T(t, {
|
|
149
150
|
disabled: e.disabled,
|
|
150
151
|
model: e,
|
|
151
|
-
choices:
|
|
152
|
-
choicePosition:
|
|
152
|
+
choices: j,
|
|
153
|
+
choicePosition: D,
|
|
153
154
|
onDropChoice: this.dropChoice,
|
|
154
155
|
onRemoveChoice: this.removeChoice,
|
|
155
|
-
correct:
|
|
156
|
+
correct: N,
|
|
156
157
|
selectedItem: a,
|
|
157
158
|
onSelectClick: o,
|
|
158
159
|
onPlacementClick: s
|
|
159
160
|
})]
|
|
160
|
-
}),
|
|
161
|
-
U && /* @__PURE__ */
|
|
162
|
-
|
|
161
|
+
}) }),
|
|
162
|
+
U && /* @__PURE__ */ T(K, { dangerouslySetInnerHTML: { __html: m } }),
|
|
163
|
+
Q && /* @__PURE__ */ T(Y, {
|
|
163
164
|
labels: {
|
|
164
165
|
hidden: "Show Rationale",
|
|
165
166
|
visible: "Hide Rationale"
|
|
166
167
|
},
|
|
167
|
-
children: /* @__PURE__ */
|
|
168
|
+
children: /* @__PURE__ */ T(M, { prompt: e.rationale })
|
|
168
169
|
}),
|
|
169
|
-
e.correctness && e.feedback && !c && /* @__PURE__ */
|
|
170
|
+
e.correctness && e.feedback && !c && /* @__PURE__ */ T(P, {
|
|
170
171
|
correctness: e.correctness,
|
|
171
172
|
feedback: e.feedback
|
|
172
173
|
}),
|
|
173
|
-
/* @__PURE__ */
|
|
174
|
-
title:
|
|
175
|
-
text:
|
|
174
|
+
/* @__PURE__ */ T(O, {
|
|
175
|
+
title: X,
|
|
176
|
+
text: W,
|
|
176
177
|
open: l,
|
|
177
|
-
onCloseText:
|
|
178
|
+
onCloseText: Z,
|
|
178
179
|
onClose: () => this.setState({ showMaxChoiceAlert: !1 })
|
|
179
180
|
})
|
|
180
181
|
]
|
|
181
182
|
});
|
|
182
183
|
}
|
|
183
|
-
},
|
|
184
|
+
}, W = class extends i.Component {
|
|
184
185
|
static propTypes = {
|
|
185
186
|
model: m.object,
|
|
186
187
|
session: m.shape({ answers: m.arrayOf(m.shape({
|
|
@@ -193,7 +194,7 @@ var A = k(u, "UiLayout") || k(I.UiLayout, "UiLayout"), j = k(l, "PreviewPrompt")
|
|
|
193
194
|
resumeMathObserver: m.func
|
|
194
195
|
};
|
|
195
196
|
constructor(e) {
|
|
196
|
-
super(e), this.uid =
|
|
197
|
+
super(e), this.uid = w.generateId(), this.state = {
|
|
197
198
|
activeDragItem: null,
|
|
198
199
|
isValidDrop: !1,
|
|
199
200
|
selectedItem: null
|
|
@@ -209,7 +210,7 @@ var A = k(u, "UiLayout") || k(I.UiLayout, "UiLayout"), j = k(l, "PreviewPrompt")
|
|
|
209
210
|
};
|
|
210
211
|
commitPlacement = (e, t) => {
|
|
211
212
|
if (this.categorizeRef) {
|
|
212
|
-
if (t === void 0 || t ===
|
|
213
|
+
if (t === void 0 || t === B) {
|
|
213
214
|
e.categoryId && this.categorizeRef.removeChoice && this.categorizeRef.removeChoice(e);
|
|
214
215
|
return;
|
|
215
216
|
}
|
|
@@ -258,7 +259,7 @@ var A = k(u, "UiLayout") || k(I.UiLayout, "UiLayout"), j = k(l, "PreviewPrompt")
|
|
|
258
259
|
let { selectedItem: t } = this.state;
|
|
259
260
|
t && (this.commitPlacement(t, e), this.cancelSelection(), this.endAnyLiveKeyboardDrag());
|
|
260
261
|
};
|
|
261
|
-
isClickSoonAfterDragEnd = () => Date.now() - this.lastDragEndAt <
|
|
262
|
+
isClickSoonAfterDragEnd = () => Date.now() - this.lastDragEndAt < V;
|
|
262
263
|
onItemClick = (e) => {
|
|
263
264
|
this.isClickSoonAfterDragEnd() || (this.endAnyLiveKeyboardDrag(), this.toggleItemSelection(e));
|
|
264
265
|
};
|
|
@@ -270,7 +271,7 @@ var A = k(u, "UiLayout") || k(I.UiLayout, "UiLayout"), j = k(l, "PreviewPrompt")
|
|
|
270
271
|
if (!t) return null;
|
|
271
272
|
if (t.type === "choice") {
|
|
272
273
|
let r = n.choices?.find((e) => e.id === t.id);
|
|
273
|
-
if (r) return /* @__PURE__ */
|
|
274
|
+
if (r) return /* @__PURE__ */ T(e, {
|
|
274
275
|
id: r.id,
|
|
275
276
|
...r
|
|
276
277
|
}, r.id);
|
|
@@ -279,7 +280,7 @@ var A = k(u, "UiLayout") || k(I.UiLayout, "UiLayout"), j = k(l, "PreviewPrompt")
|
|
|
279
280
|
};
|
|
280
281
|
render() {
|
|
281
282
|
let { isValidDrop: e, selectedItem: t } = this.state, n = e ? null : void 0;
|
|
282
|
-
return /* @__PURE__ */
|
|
283
|
+
return /* @__PURE__ */ T(C, {
|
|
283
284
|
onDragStart: this.onDragStart,
|
|
284
285
|
onDragEnd: this.onDragEnd,
|
|
285
286
|
onDragCancel: this.onDragCancel,
|
|
@@ -289,29 +290,34 @@ var A = k(u, "UiLayout") || k(I.UiLayout, "UiLayout"), j = k(l, "PreviewPrompt")
|
|
|
289
290
|
cancel: ["Escape"],
|
|
290
291
|
end: ["Space", "Enter"]
|
|
291
292
|
},
|
|
292
|
-
|
|
293
|
+
modifiers: [v],
|
|
294
|
+
children: /* @__PURE__ */ E(w.Provider, {
|
|
293
295
|
value: this.uid,
|
|
294
|
-
children: [/* @__PURE__ */
|
|
296
|
+
children: [/* @__PURE__ */ T(U, {
|
|
295
297
|
ref: (e) => this.categorizeRef = e,
|
|
296
298
|
...this.props,
|
|
297
299
|
selectedItem: t,
|
|
298
300
|
onSelectClick: this.onItemClick,
|
|
299
301
|
onPlacementClick: this.onPlacementClick
|
|
300
|
-
}), /* @__PURE__ */
|
|
302
|
+
}), /* @__PURE__ */ T(_, {
|
|
301
303
|
dropAnimation: n,
|
|
302
|
-
children: /* @__PURE__ */
|
|
304
|
+
children: /* @__PURE__ */ T(H, { children: this.renderDragOverlay() })
|
|
303
305
|
})]
|
|
304
306
|
})
|
|
305
307
|
});
|
|
306
308
|
}
|
|
307
|
-
},
|
|
309
|
+
}, G = g(j)({
|
|
308
310
|
color: d.text(),
|
|
309
311
|
backgroundColor: d.background(),
|
|
310
312
|
position: "relative"
|
|
311
|
-
}),
|
|
313
|
+
}), K = g("div")(({ theme: e }) => ({ marginBottom: e.spacing(2) })), q = g("div")(({ theme: e }) => ({
|
|
312
314
|
marginBottom: e.spacing(1),
|
|
315
|
+
maxWidth: "100%",
|
|
316
|
+
overflowX: "auto",
|
|
317
|
+
overflowY: "hidden"
|
|
318
|
+
})), J = g("div")(() => ({
|
|
313
319
|
display: "flex",
|
|
314
|
-
|
|
315
|
-
})),
|
|
320
|
+
minWidth: "min-content"
|
|
321
|
+
})), Y = g(N)(({ theme: e }) => ({ paddingBottom: e.spacing(2) }));
|
|
316
322
|
//#endregion
|
|
317
|
-
export {
|
|
323
|
+
export { U as Categorize, W as default };
|