@pie-element/placement-ordering 14.1.2-next.2 → 14.1.2-next.20
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/author/choice-editor.js +2 -2
- package/dist/author/choice-tile.js +3 -2
- package/dist/author/design.js +1 -1
- package/dist/author/index.d.ts +1 -0
- package/dist/author/index.js +5 -2
- package/dist/browser/assets/Symbola-4c507403.woff2 +0 -0
- package/dist/browser/author/index.js +14940 -19583
- package/dist/browser/author/index.js.map +1 -1
- package/dist/browser/{browser-Dbw2uHQ7.js → browser-DMpDEszG.js} +7 -3
- package/dist/browser/browser-DMpDEszG.js.map +1 -0
- package/dist/browser/controller/index.js +140 -55
- package/dist/browser/controller/index.js.map +1 -1
- package/dist/browser/delivery/index.js +474 -325
- package/dist/browser/delivery/index.js.map +1 -1
- package/dist/browser/{dist-D9ARZhQk.js → dist-DCmVXYeO.js} +109 -7
- package/dist/browser/dist-DCmVXYeO.js.map +1 -0
- package/dist/browser/{drag-provider-C4BiCI76.js → drag-provider-LgVkQ5Yi.js} +2219 -2266
- package/dist/browser/drag-provider-LgVkQ5Yi.js.map +1 -0
- package/dist/browser/editor-runtime/assets/Symbola-4c507403.woff2 +0 -0
- package/dist/browser/editor-runtime/author/index.js +19668 -0
- package/dist/browser/editor-runtime/author/index.js.map +1 -0
- package/dist/browser/editor-runtime/browser-0nthm_zo.js +376 -0
- package/dist/browser/editor-runtime/browser-0nthm_zo.js.map +1 -0
- package/dist/browser/editor-runtime/controller/index.js +327 -0
- package/dist/browser/editor-runtime/controller/index.js.map +1 -0
- package/dist/browser/editor-runtime/delivery/index.js +1184 -0
- package/dist/browser/editor-runtime/delivery/index.js.map +1 -0
- package/dist/browser/editor-runtime/dist-DCmVXYeO.js +1528 -0
- package/dist/browser/editor-runtime/dist-DCmVXYeO.js.map +1 -0
- package/dist/browser/editor-runtime/drag-provider-Dpx1BjBS.js +10508 -0
- package/dist/browser/editor-runtime/drag-provider-Dpx1BjBS.js.map +1 -0
- package/dist/controller/scoring.js +3 -3
- package/dist/delivery/index.js +2 -2
- package/dist/delivery/keyboard-coordinates.d.ts +47 -0
- package/dist/delivery/keyboard-coordinates.js +51 -0
- package/dist/delivery/main.js +1 -1
- package/dist/delivery/ordering.js +14 -19
- package/dist/delivery/placement-ordering.d.ts +13 -0
- package/dist/delivery/placement-ordering.js +168 -83
- package/dist/delivery/tile.d.ts +3 -0
- package/dist/delivery/tile.js +75 -61
- package/dist/delivery/tiler.d.ts +6 -0
- package/dist/delivery/tiler.js +6 -3
- package/dist/index.iife.js +35 -35
- package/package.json +36 -25
- package/dist/browser/browser-Dbw2uHQ7.js.map +0 -1
- package/dist/browser/dist-D9ARZhQk.js.map +0 -1
- package/dist/browser/drag-provider-C4BiCI76.js.map +0 -1
- package/dist/browser/placement-ordering.css +0 -2
|
@@ -0,0 +1,1184 @@
|
|
|
1
|
+
import { A as e, C as t, _ as n, b as r, g as i, l as a, r as o, t as s, u as c, v as l } from "../browser-0nthm_zo.js";
|
|
2
|
+
import { Lt as u, Rt as d, T as f, at as p, c as m, ct as h, dt as g, ft as _, l as v, lt as y, mt as b, n as x, ot as S, s as C, st as w, t as ee, u as T, ut as E, v as D } from "../drag-provider-Dpx1BjBS.js";
|
|
3
|
+
import { t as O } from "../dist-DCmVXYeO.js";
|
|
4
|
+
import k, { createElement as A, useRef as j } from "react";
|
|
5
|
+
import { createRoot as M } from "react-dom/client";
|
|
6
|
+
import N from "react-dom";
|
|
7
|
+
import { jsx as P, jsxs as F } from "react/jsx-runtime";
|
|
8
|
+
//#region ../../shared/player-events/dist/index.js
|
|
9
|
+
var I = /* @__PURE__ */ e(s(), 1);
|
|
10
|
+
(class e extends CustomEvent {
|
|
11
|
+
static {
|
|
12
|
+
this.TYPE = "model-set";
|
|
13
|
+
}
|
|
14
|
+
constructor(t, n, r) {
|
|
15
|
+
super(e.TYPE, {
|
|
16
|
+
bubbles: !0,
|
|
17
|
+
composed: !0,
|
|
18
|
+
detail: {
|
|
19
|
+
complete: n,
|
|
20
|
+
component: t,
|
|
21
|
+
hasModel: r
|
|
22
|
+
}
|
|
23
|
+
}), this.component = t, this.complete = n;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
var te = class e extends CustomEvent {
|
|
27
|
+
static {
|
|
28
|
+
this.TYPE = "session-changed";
|
|
29
|
+
}
|
|
30
|
+
constructor(t, n) {
|
|
31
|
+
super(e.TYPE, {
|
|
32
|
+
bubbles: !0,
|
|
33
|
+
composed: !0,
|
|
34
|
+
detail: {
|
|
35
|
+
complete: n,
|
|
36
|
+
component: t
|
|
37
|
+
}
|
|
38
|
+
}), this.component = t, this.complete = n;
|
|
39
|
+
}
|
|
40
|
+
}, L = /* @__PURE__ */ e(u(), 1);
|
|
41
|
+
function R(e, t, n) {
|
|
42
|
+
let r = { ...e };
|
|
43
|
+
return t.top + e.y <= n.top ? r.y = n.top - t.top : t.bottom + e.y >= n.top + n.height && (r.y = n.top + n.height - t.bottom), t.left + e.x <= n.left ? r.x = n.left - t.left : t.right + e.x >= n.left + n.width && (r.x = n.left + n.width - t.right), r;
|
|
44
|
+
}
|
|
45
|
+
var ne = (e) => {
|
|
46
|
+
let { containerNodeRect: t, draggingNodeRect: n, transform: r } = e;
|
|
47
|
+
return !n || !t ? r : R(r, n, t);
|
|
48
|
+
}, z = ({ bgFill: e, fgFill: t }) => /* @__PURE__ */ F("svg", {
|
|
49
|
+
preserveAspectRatio: "xMinYMin meet",
|
|
50
|
+
version: "1.1",
|
|
51
|
+
viewBox: "-283 359 34 35",
|
|
52
|
+
style: { enableBackground: "new -283 359 34 35" },
|
|
53
|
+
children: [
|
|
54
|
+
/* @__PURE__ */ P("circle", {
|
|
55
|
+
cx: "-266",
|
|
56
|
+
cy: "375.9",
|
|
57
|
+
r: "14",
|
|
58
|
+
fill: e
|
|
59
|
+
}),
|
|
60
|
+
/* @__PURE__ */ P("path", {
|
|
61
|
+
d: "M-280.5,375.9c0-8,6.5-14.5,14.5-14.5s14.5,6.5,14.5,14.5s-6.5,14.5-14.5,14.5S-280.5,383.9-280.5,375.9z\n M-279.5,375.9c0,7.4,6.1,13.5,13.5,13.5c7.4,0,13.5-6.1,13.5-13.5s-6.1-13.5-13.5-13.5C-273.4,362.4-279.5,368.5-279.5,375.9z",
|
|
62
|
+
fill: e
|
|
63
|
+
}),
|
|
64
|
+
/* @__PURE__ */ P("polygon", {
|
|
65
|
+
points: "-265.4,383.1 -258.6,377.2 -261.2,374.2 -264.3,376.9 -268.9,368.7 -272.4,370.6",
|
|
66
|
+
fill: t
|
|
67
|
+
})
|
|
68
|
+
]
|
|
69
|
+
});
|
|
70
|
+
z.propTypes = {
|
|
71
|
+
bgFill: L.default.string.isRequired,
|
|
72
|
+
fgFill: L.default.string.isRequired
|
|
73
|
+
};
|
|
74
|
+
var re = ({ bgFill: e, fgFill: t, borderFill: n }) => /* @__PURE__ */ F("svg", {
|
|
75
|
+
preserveAspectRatio: "xMinYMin meet",
|
|
76
|
+
version: "1.1",
|
|
77
|
+
viewBox: "-129.5 127 34 35",
|
|
78
|
+
style: { enableBackground: "new -129.5 127 34 35" },
|
|
79
|
+
children: [
|
|
80
|
+
/* @__PURE__ */ P("path", {
|
|
81
|
+
style: {
|
|
82
|
+
fill: "#D0CAC5",
|
|
83
|
+
stroke: "#E6E3E0",
|
|
84
|
+
strokeWidth: .75,
|
|
85
|
+
strokeMiterlimit: 10
|
|
86
|
+
},
|
|
87
|
+
d: "M-112.9,160.4c-8.5,0-15.5-6.9-15.5-15.5c0-8.5,6.9-15.5,15.5-15.5s15.5,6.9,15.5,15.5\n C-97.4,153.5-104.3,160.4-112.9,160.4z"
|
|
88
|
+
}),
|
|
89
|
+
/* @__PURE__ */ P("path", {
|
|
90
|
+
style: {
|
|
91
|
+
fill: "#B3ABA4",
|
|
92
|
+
stroke: "#CDC7C2",
|
|
93
|
+
strokeWidth: .5,
|
|
94
|
+
strokeMiterlimit: 10
|
|
95
|
+
},
|
|
96
|
+
d: "M-113.2,159c-8,0-14.5-6.5-14.5-14.5s6.5-14.5,14.5-14.5s14.5,6.5,14.5,14.5S-105.2,159-113.2,159z"
|
|
97
|
+
}),
|
|
98
|
+
/* @__PURE__ */ P("circle", {
|
|
99
|
+
cx: "-114.2",
|
|
100
|
+
cy: "143.5",
|
|
101
|
+
r: "14",
|
|
102
|
+
fill: e
|
|
103
|
+
}),
|
|
104
|
+
/* @__PURE__ */ P("path", {
|
|
105
|
+
d: "M-114.2,158c-8,0-14.5-6.5-14.5-14.5s6.5-14.5,14.5-14.5s14.5,6.5,14.5,14.5S-106.2,158-114.2,158z\n M-114.2,130c-7.4,0-13.5,6.1-13.5,13.5s6.1,13.5,13.5,13.5s13.5-6.1,13.5-13.5S-106.8,130-114.2,130z",
|
|
106
|
+
fill: n
|
|
107
|
+
}),
|
|
108
|
+
/* @__PURE__ */ P("polygon", {
|
|
109
|
+
points: "-114.8,150.7 -121.6,144.8 -119,141.8 -115.9,144.5 -111.3,136.3 -107.8,138.2",
|
|
110
|
+
fill: t
|
|
111
|
+
})
|
|
112
|
+
]
|
|
113
|
+
});
|
|
114
|
+
re.propTypes = {
|
|
115
|
+
bgFill: L.default.string.isRequired,
|
|
116
|
+
fgFill: L.default.string.isRequired,
|
|
117
|
+
borderFill: L.default.string.isRequired
|
|
118
|
+
};
|
|
119
|
+
var ie = b("div")(({ size: e }) => ({
|
|
120
|
+
width: e || "25px",
|
|
121
|
+
height: e || "25px"
|
|
122
|
+
})), B = ({ open: e, size: t }) => /* @__PURE__ */ P(ie, {
|
|
123
|
+
size: t,
|
|
124
|
+
children: e ? /* @__PURE__ */ P(z, {
|
|
125
|
+
bgFill: "#bce2ff",
|
|
126
|
+
fgFill: "#1a9cff"
|
|
127
|
+
}) : /* @__PURE__ */ P(re, {
|
|
128
|
+
bgFill: "white",
|
|
129
|
+
fgFill: "#1a9cff",
|
|
130
|
+
borderFill: "#bce2ff"
|
|
131
|
+
})
|
|
132
|
+
});
|
|
133
|
+
B.propTypes = {
|
|
134
|
+
open: L.default.bool,
|
|
135
|
+
size: L.default.string
|
|
136
|
+
}, B.defaultProps = { open: !1 };
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region ../../lib-react/correct-answer-toggle/dist/expander.js
|
|
139
|
+
var ae = "height ease-in 300ms, opacity ease-in 300ms", oe = b("div")(() => ({
|
|
140
|
+
position: "relative",
|
|
141
|
+
height: 0,
|
|
142
|
+
overflow: "hidden",
|
|
143
|
+
display: "flex",
|
|
144
|
+
visibility: "hidden",
|
|
145
|
+
width: 0,
|
|
146
|
+
"&.enter": {
|
|
147
|
+
transition: ae,
|
|
148
|
+
opacity: 1,
|
|
149
|
+
height: "auto",
|
|
150
|
+
width: "auto",
|
|
151
|
+
visibility: "visible",
|
|
152
|
+
minHeight: "25px"
|
|
153
|
+
},
|
|
154
|
+
"&.enter-done": {
|
|
155
|
+
height: "auto",
|
|
156
|
+
visibility: "visible",
|
|
157
|
+
width: "auto",
|
|
158
|
+
minHeight: "25px"
|
|
159
|
+
},
|
|
160
|
+
"&.exit": {
|
|
161
|
+
transition: ae,
|
|
162
|
+
opacity: 0,
|
|
163
|
+
height: 0,
|
|
164
|
+
visibility: "visible",
|
|
165
|
+
width: 0
|
|
166
|
+
},
|
|
167
|
+
"&.exit-done": {
|
|
168
|
+
opacity: 0,
|
|
169
|
+
visibility: "hidden",
|
|
170
|
+
height: 0,
|
|
171
|
+
width: 0
|
|
172
|
+
}
|
|
173
|
+
})), se = (e) => {
|
|
174
|
+
let { show: t, children: n, className: r } = e, i = j(null);
|
|
175
|
+
return /* @__PURE__ */ P(S, {
|
|
176
|
+
nodeRef: i,
|
|
177
|
+
in: t,
|
|
178
|
+
appear: !0,
|
|
179
|
+
mountOnEnter: !1,
|
|
180
|
+
timeout: 300,
|
|
181
|
+
classNames: {
|
|
182
|
+
enter: "enter",
|
|
183
|
+
enterDone: "enter-done",
|
|
184
|
+
exit: "exit",
|
|
185
|
+
exitDone: "exit-done"
|
|
186
|
+
},
|
|
187
|
+
children: /* @__PURE__ */ P(oe, {
|
|
188
|
+
ref: i,
|
|
189
|
+
className: r,
|
|
190
|
+
children: n
|
|
191
|
+
})
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
se.propTypes = {
|
|
195
|
+
show: L.default.bool.isRequired,
|
|
196
|
+
className: L.default.string,
|
|
197
|
+
children: L.default.oneOfType([L.default.arrayOf(L.default.node), L.default.node]).isRequired
|
|
198
|
+
};
|
|
199
|
+
//#endregion
|
|
200
|
+
//#region ../../lib-react/correct-answer-toggle/dist/index.js
|
|
201
|
+
function V(e) {
|
|
202
|
+
return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
|
|
203
|
+
}
|
|
204
|
+
function ce(e, t) {
|
|
205
|
+
return !e || V(e) ? e : V(e.default) ? e.default : t && V(e[t]) ? e[t] : t && V(e[t]?.default) ? e[t].default : e;
|
|
206
|
+
}
|
|
207
|
+
var le = ce(v, "Readable") || ce(ue.Readable, "Readable"), H = x, U = H.default, ue = U && typeof U == "object" ? U : H, { translator: W } = O, de = {
|
|
208
|
+
WebkitTouchCallout: "none",
|
|
209
|
+
WebkitUserSelect: "none",
|
|
210
|
+
KhtmlUserSelect: "none",
|
|
211
|
+
MozUserSelect: "none",
|
|
212
|
+
msUserSelect: "none",
|
|
213
|
+
userSelect: "none"
|
|
214
|
+
}, fe = b("div")(() => ({
|
|
215
|
+
width: "100%",
|
|
216
|
+
cursor: "pointer"
|
|
217
|
+
})), pe = b("div")(() => ({
|
|
218
|
+
margin: "0 auto",
|
|
219
|
+
textAlign: "center",
|
|
220
|
+
display: "flex"
|
|
221
|
+
})), me = b("div")(() => ({
|
|
222
|
+
width: "fit-content",
|
|
223
|
+
minWidth: "140px",
|
|
224
|
+
alignSelf: "center",
|
|
225
|
+
verticalAlign: "middle",
|
|
226
|
+
color: `var(--correct-answer-toggle-label-color, ${w.text()})`,
|
|
227
|
+
fontWeight: "normal",
|
|
228
|
+
...de
|
|
229
|
+
})), G = b("div")(() => ({
|
|
230
|
+
position: "absolute",
|
|
231
|
+
width: "25px",
|
|
232
|
+
"&.enter": { opacity: "0" },
|
|
233
|
+
"&.enter-active": {
|
|
234
|
+
opacity: "1",
|
|
235
|
+
transition: "opacity 0.3s ease-in"
|
|
236
|
+
},
|
|
237
|
+
"&.exit": { opacity: "1" },
|
|
238
|
+
"&.exit-active": {
|
|
239
|
+
opacity: "0",
|
|
240
|
+
transition: "opacity 0.3s ease-in"
|
|
241
|
+
}
|
|
242
|
+
})), he = b("div")(() => ({
|
|
243
|
+
width: "25px",
|
|
244
|
+
marginRight: "5px",
|
|
245
|
+
display: "flex",
|
|
246
|
+
alignItems: "center"
|
|
247
|
+
})), ge = class e extends k.Component {
|
|
248
|
+
static propTypes = {
|
|
249
|
+
onToggle: L.default.func,
|
|
250
|
+
toggled: L.default.bool,
|
|
251
|
+
show: L.default.bool,
|
|
252
|
+
hideMessage: L.default.string,
|
|
253
|
+
showMessage: L.default.string,
|
|
254
|
+
className: L.default.string,
|
|
255
|
+
language: L.default.string
|
|
256
|
+
};
|
|
257
|
+
static defaultProps = {
|
|
258
|
+
showMessage: "Show correct answer",
|
|
259
|
+
hideMessage: "Hide correct answer",
|
|
260
|
+
show: !1,
|
|
261
|
+
toggled: !1
|
|
262
|
+
};
|
|
263
|
+
constructor(t) {
|
|
264
|
+
super(t), this.state = { show: t.show }, this.openIconRef = k.createRef(), this.closedIconRef = k.createRef(), e.defaultProps = {
|
|
265
|
+
...e.defaultProps,
|
|
266
|
+
showMessage: W.t("common:showCorrectAnswer", { lng: t.language }),
|
|
267
|
+
hideMessage: W.t("common:hideCorrectAnswer", { lng: t.language })
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
onClick() {
|
|
271
|
+
this.props.onToggle(!this.props.toggled);
|
|
272
|
+
}
|
|
273
|
+
onTouch(e) {
|
|
274
|
+
e.preventDefault(), this.props.onToggle(!this.props.toggled);
|
|
275
|
+
}
|
|
276
|
+
UNSAFE_componentWillReceiveProps(t) {
|
|
277
|
+
this.setState({ show: t.show }), t.language !== this.props?.language && (e.defaultProps = {
|
|
278
|
+
...e.defaultProps,
|
|
279
|
+
showMessage: W.t("common:showCorrectAnswer", { lng: t.language }),
|
|
280
|
+
hideMessage: W.t("common:hideCorrectAnswer", { lng: t.language })
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
render() {
|
|
284
|
+
let { className: e, toggled: t, hideMessage: n, showMessage: r } = this.props;
|
|
285
|
+
return /* @__PURE__ */ P(fe, {
|
|
286
|
+
className: e,
|
|
287
|
+
children: /* @__PURE__ */ P(se, {
|
|
288
|
+
show: this.state.show,
|
|
289
|
+
children: /* @__PURE__ */ F(pe, {
|
|
290
|
+
onClick: this.onClick.bind(this),
|
|
291
|
+
onTouchEnd: this.onTouch.bind(this),
|
|
292
|
+
children: [/* @__PURE__ */ F(he, { children: [/* @__PURE__ */ P(S, {
|
|
293
|
+
nodeRef: this.openIconRef,
|
|
294
|
+
timeout: 400,
|
|
295
|
+
in: t,
|
|
296
|
+
exit: !t,
|
|
297
|
+
classNames: {
|
|
298
|
+
enter: "enter",
|
|
299
|
+
enterActive: "enter-active",
|
|
300
|
+
exit: "exit",
|
|
301
|
+
exitActive: "exit-active"
|
|
302
|
+
},
|
|
303
|
+
children: /* @__PURE__ */ P(G, {
|
|
304
|
+
ref: this.openIconRef,
|
|
305
|
+
children: /* @__PURE__ */ P(B, { open: t }, "correct-open")
|
|
306
|
+
})
|
|
307
|
+
}), /* @__PURE__ */ P(S, {
|
|
308
|
+
nodeRef: this.closedIconRef,
|
|
309
|
+
timeout: 5e3,
|
|
310
|
+
in: !t,
|
|
311
|
+
exit: t,
|
|
312
|
+
classNames: {
|
|
313
|
+
enter: "enter",
|
|
314
|
+
enterActive: "enter-active",
|
|
315
|
+
exit: "exit",
|
|
316
|
+
exitActive: "exit-active"
|
|
317
|
+
},
|
|
318
|
+
children: /* @__PURE__ */ P(G, {
|
|
319
|
+
ref: this.closedIconRef,
|
|
320
|
+
children: /* @__PURE__ */ P(B, { open: t }, "correct-closed")
|
|
321
|
+
})
|
|
322
|
+
})] }), /* @__PURE__ */ P(le, {
|
|
323
|
+
false: !0,
|
|
324
|
+
children: /* @__PURE__ */ P(me, {
|
|
325
|
+
"aria-hidden": !this.state.show,
|
|
326
|
+
children: t ? n : r
|
|
327
|
+
})
|
|
328
|
+
})]
|
|
329
|
+
})
|
|
330
|
+
})
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
//#endregion
|
|
335
|
+
//#region ../../lib-react/drag/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js
|
|
336
|
+
function _e(e) {
|
|
337
|
+
var t, n, r = "";
|
|
338
|
+
if (typeof e == "string" || typeof e == "number") r += e;
|
|
339
|
+
else if (typeof e == "object") if (Array.isArray(e)) {
|
|
340
|
+
var i = e.length;
|
|
341
|
+
for (t = 0; t < i; t++) e[t] && (n = _e(e[t])) && (r && (r += " "), r += n);
|
|
342
|
+
} else for (n in e) e[n] && (r && (r += " "), r += n);
|
|
343
|
+
return r;
|
|
344
|
+
}
|
|
345
|
+
function ve() {
|
|
346
|
+
for (var e, t, n = 0, r = "", i = arguments.length; n < i; n++) (e = arguments[n]) && (t = _e(e)) && (r && (r += " "), r += t);
|
|
347
|
+
return r;
|
|
348
|
+
}
|
|
349
|
+
//#endregion
|
|
350
|
+
//#region ../../lib-react/drag/dist/placeholder.js
|
|
351
|
+
var ye = b("div")(({ theme: e }) => ({
|
|
352
|
+
"&.placeholder": {
|
|
353
|
+
WebkitTouchCallout: "none",
|
|
354
|
+
WebkitUserSelect: "none",
|
|
355
|
+
KhtmlUserSelect: "none",
|
|
356
|
+
MozUserSelect: "none",
|
|
357
|
+
MsUserSelect: "none",
|
|
358
|
+
userSelect: "none",
|
|
359
|
+
width: "100%",
|
|
360
|
+
height: "100%",
|
|
361
|
+
background: w.white(),
|
|
362
|
+
transition: "background-color 200ms linear, border-color 200ms linear",
|
|
363
|
+
boxSizing: "border-box",
|
|
364
|
+
display: "grid",
|
|
365
|
+
gridRowGap: e.spacing(1),
|
|
366
|
+
gridColumnGap: e.spacing(1),
|
|
367
|
+
padding: e.spacing(1),
|
|
368
|
+
border: `2px dashed ${w.black()}`
|
|
369
|
+
},
|
|
370
|
+
"&.placeholderDisabled": {
|
|
371
|
+
boxShadow: "none",
|
|
372
|
+
background: w.white()
|
|
373
|
+
},
|
|
374
|
+
"&.over": {
|
|
375
|
+
border: `1px solid ${w.border()}`,
|
|
376
|
+
backgroundColor: w.backgroundDark()
|
|
377
|
+
},
|
|
378
|
+
"&.board": {
|
|
379
|
+
padding: e.spacing(1),
|
|
380
|
+
display: "flex",
|
|
381
|
+
flexWrap: "wrap",
|
|
382
|
+
alignItems: "center",
|
|
383
|
+
minHeight: "100px",
|
|
384
|
+
justifyContent: "center",
|
|
385
|
+
overflow: "hidden",
|
|
386
|
+
touchAction: "none",
|
|
387
|
+
backgroundColor: w.surface()
|
|
388
|
+
},
|
|
389
|
+
"&.categorizeBoard": {
|
|
390
|
+
padding: e.spacing(.5),
|
|
391
|
+
display: "flex",
|
|
392
|
+
flexWrap: "wrap",
|
|
393
|
+
alignItems: "center",
|
|
394
|
+
minHeight: "100px",
|
|
395
|
+
justifyContent: "center",
|
|
396
|
+
overflow: "hidden",
|
|
397
|
+
touchAction: "none",
|
|
398
|
+
backgroundColor: w.surface()
|
|
399
|
+
},
|
|
400
|
+
"&.verticalPool": {
|
|
401
|
+
display: "flex",
|
|
402
|
+
flexFlow: "column wrap"
|
|
403
|
+
}
|
|
404
|
+
})), be = (e) => {
|
|
405
|
+
let { children: t, className: n, isOver: r, type: i, grid: a, disabled: o, choiceBoard: s, isCategorize: c, isVerticalPool: l, minHeight: u, extraStyles: d } = e, f = ve("placeholder", o && "placeholderDisabled", r && "over", i, n), p = {};
|
|
406
|
+
if (a && a.columns && (p.gridTemplateColumns = `repeat(${a.columns}, 1fr)`), a && a.rows) {
|
|
407
|
+
let e = a.rowsRepeatValue || "1fr";
|
|
408
|
+
p.gridTemplateRows = `repeat(${a.rows}, ${e})`;
|
|
409
|
+
}
|
|
410
|
+
i === "choice" && (p.border = `1px solid ${w.borderLight()}`, p.background = w.surface());
|
|
411
|
+
let m = c ? "categorizeBoard" : "board";
|
|
412
|
+
return /* @__PURE__ */ P(ye, {
|
|
413
|
+
style: {
|
|
414
|
+
...p,
|
|
415
|
+
minHeight: u,
|
|
416
|
+
...d
|
|
417
|
+
},
|
|
418
|
+
className: ve(s ? m : f, l && "verticalPool"),
|
|
419
|
+
children: t
|
|
420
|
+
});
|
|
421
|
+
};
|
|
422
|
+
be.propTypes = {
|
|
423
|
+
choiceBoard: L.default.bool,
|
|
424
|
+
grid: L.default.shape({
|
|
425
|
+
columns: L.default.number,
|
|
426
|
+
rows: L.default.number,
|
|
427
|
+
rowsRepeatValue: L.default.string
|
|
428
|
+
}),
|
|
429
|
+
children: L.default.oneOfType([L.default.arrayOf(L.default.node), L.default.node]).isRequired,
|
|
430
|
+
className: L.default.string,
|
|
431
|
+
isOver: L.default.bool,
|
|
432
|
+
index: L.default.number,
|
|
433
|
+
type: L.default.string,
|
|
434
|
+
disabled: L.default.bool,
|
|
435
|
+
isCategorize: L.default.bool,
|
|
436
|
+
isVerticalPool: L.default.bool,
|
|
437
|
+
minHeight: L.default.number
|
|
438
|
+
};
|
|
439
|
+
//#endregion
|
|
440
|
+
//#region src/delivery/tile.tsx
|
|
441
|
+
var xe = (0, I.default)("pie-elements:placement-ordering:tile"), Se = b("div")(({ theme: e }) => ({
|
|
442
|
+
width: "100%",
|
|
443
|
+
fontSize: e.typography.fontSize + 4,
|
|
444
|
+
textAlign: "center",
|
|
445
|
+
color: `rgba(${e.palette.common.black}, 0.6)`
|
|
446
|
+
})), Ce = ({ type: e, index: t, isOver: n, disabled: r }) => /* @__PURE__ */ P(be, {
|
|
447
|
+
type: e,
|
|
448
|
+
isOver: n,
|
|
449
|
+
disabled: r,
|
|
450
|
+
children: e === "target" && t !== void 0 && /* @__PURE__ */ P(Se, { children: t })
|
|
451
|
+
});
|
|
452
|
+
Ce.propTypes = {
|
|
453
|
+
type: L.default.string,
|
|
454
|
+
index: L.default.number,
|
|
455
|
+
isOver: L.default.bool,
|
|
456
|
+
disabled: L.default.bool
|
|
457
|
+
};
|
|
458
|
+
var we = b("div")(({ theme: e, isDragging: t, isSelected: n, isOver: r, disabled: i, outcome: a, label: o, type: s }) => ({
|
|
459
|
+
cursor: i ? "not-allowed" : "grab",
|
|
460
|
+
width: "100%",
|
|
461
|
+
height: "100%",
|
|
462
|
+
padding: "10px",
|
|
463
|
+
boxSizing: "border-box",
|
|
464
|
+
overflow: "hidden",
|
|
465
|
+
border: s === "choice" || s === "target" ? `1px solid ${w.border()}` : "1px solid transparent",
|
|
466
|
+
backgroundColor: s === "choice" || s === "target" ? w.background() : "transparent",
|
|
467
|
+
transition: s === "choice" || s === "target" ? "background-color 150ms ease, border-color 150ms ease, opacity 150ms ease" : "none",
|
|
468
|
+
pointerEvents: "none",
|
|
469
|
+
userSelect: "none",
|
|
470
|
+
...(s === "choice" || s === "target") && { "&:hover": {
|
|
471
|
+
backgroundColor: i ? w.background() : w.secondary(),
|
|
472
|
+
borderColor: i ? w.disabled() : e.palette.primary.main,
|
|
473
|
+
transform: i ? "none" : "scale(1.02)"
|
|
474
|
+
} },
|
|
475
|
+
...(s === "choice" || s === "target") && r && !i && {
|
|
476
|
+
opacity: .4,
|
|
477
|
+
backgroundColor: w.primaryLight(),
|
|
478
|
+
borderColor: e.palette.primary.main,
|
|
479
|
+
borderStyle: "dashed",
|
|
480
|
+
transform: "scale(1.05)"
|
|
481
|
+
},
|
|
482
|
+
...(s === "choice" || s === "target") && (t || n) && !i && {
|
|
483
|
+
opacity: .6,
|
|
484
|
+
backgroundColor: w.secondaryLight(),
|
|
485
|
+
transform: "scale(1.05) rotate(2deg)",
|
|
486
|
+
boxShadow: "0 8px 16px rgba(0,0,0,0.2)",
|
|
487
|
+
cursor: "grabbing"
|
|
488
|
+
},
|
|
489
|
+
...(s === "choice" || s === "target") && i && {
|
|
490
|
+
cursor: "not-allowed",
|
|
491
|
+
"&:hover": {
|
|
492
|
+
backgroundColor: w.background(),
|
|
493
|
+
transform: "none"
|
|
494
|
+
}
|
|
495
|
+
},
|
|
496
|
+
...(s === "choice" || s === "target") && a === "incorrect" && { border: `1px solid ${w.incorrect()}` },
|
|
497
|
+
...(s === "choice" || s === "target") && a === "correct" && { border: `1px solid ${w.correct()}` },
|
|
498
|
+
...!o && {
|
|
499
|
+
border: "none",
|
|
500
|
+
"&:hover": { backgroundColor: "unset" }
|
|
501
|
+
}
|
|
502
|
+
})), Te = (e) => {
|
|
503
|
+
let { type: t, isDragging: n, isSelected: r, empty: i, isOver: a, label: o, disabled: s, outcome: c, guideIndex: l } = e;
|
|
504
|
+
return i ? /* @__PURE__ */ P(Ce, {
|
|
505
|
+
type: t,
|
|
506
|
+
index: l,
|
|
507
|
+
isOver: a,
|
|
508
|
+
disabled: s
|
|
509
|
+
}) : /* @__PURE__ */ P(we, {
|
|
510
|
+
type: t,
|
|
511
|
+
isDragging: n,
|
|
512
|
+
isSelected: r,
|
|
513
|
+
isOver: a,
|
|
514
|
+
disabled: s,
|
|
515
|
+
outcome: c,
|
|
516
|
+
label: o,
|
|
517
|
+
dangerouslySetInnerHTML: { __html: o }
|
|
518
|
+
});
|
|
519
|
+
}, K = (e) => {
|
|
520
|
+
let { label: t, type: n, id: r, empty: i, disabled: a, outcome: o, index: s, guideIndex: c, instanceId: l, draggable: u, tileIndex: d, selectedChoice: f, onChoiceClick: p, onPlacementClick: m } = e, h = `tile-${n}-${r ?? "empty"}-${d}-${l}`, v = `drop-${n}-${r ?? "empty"}-${d}-${l}`, y = {
|
|
521
|
+
id: r,
|
|
522
|
+
type: n,
|
|
523
|
+
instanceId: l,
|
|
524
|
+
value: t,
|
|
525
|
+
index: s
|
|
526
|
+
}, { attributes: b, listeners: x, setNodeRef: S, transform: C, isDragging: w } = g({
|
|
527
|
+
id: h,
|
|
528
|
+
data: y,
|
|
529
|
+
disabled: !u || a
|
|
530
|
+
}), { setNodeRef: ee, isOver: T } = _({
|
|
531
|
+
id: v,
|
|
532
|
+
data: y,
|
|
533
|
+
disabled: w
|
|
534
|
+
}), E = !!f && f.type === y.type && f.id === y.id && f.index === y.index, [D, O] = k.useState(!1), A = !!f && !a, j = T || n === "target" && A && D, M = () => {
|
|
535
|
+
a || (n === "choice" ? f?.type === "target" ? m?.(y) : u && p?.(y) : n === "target" && (E ? p?.(y) : f ? m?.(y) : u && p?.(y)));
|
|
536
|
+
}, N = !(u && !a) && !a && A, F = (e) => {
|
|
537
|
+
(e.code === "Space" || e.code === "Enter") && (e.preventDefault(), M());
|
|
538
|
+
}, I = k.useRef(null);
|
|
539
|
+
k.useEffect(() => {
|
|
540
|
+
let e = I.current, t = (e) => {
|
|
541
|
+
e.preventDefault();
|
|
542
|
+
};
|
|
543
|
+
return e && e.addEventListener("touchstart", t, { passive: !1 }), () => {
|
|
544
|
+
e && e.removeEventListener("touchstart", t);
|
|
545
|
+
};
|
|
546
|
+
}, []);
|
|
547
|
+
let te = (e) => {
|
|
548
|
+
I.current = e, S(e), ee(e);
|
|
549
|
+
};
|
|
550
|
+
xe("[render], props: ", e);
|
|
551
|
+
let L = n === "target" ? `target-${s}` : n === "choice" ? `choice-${r}` : null, R = L ? `${l}:${L}` : void 0;
|
|
552
|
+
return /* @__PURE__ */ P("div", {
|
|
553
|
+
ref: te,
|
|
554
|
+
style: {
|
|
555
|
+
transform: C ? `translate3d(${C.x}px, ${C.y}px, 0)` : void 0,
|
|
556
|
+
boxSizing: "border-box",
|
|
557
|
+
overflow: "visible",
|
|
558
|
+
padding: 0,
|
|
559
|
+
margin: 0,
|
|
560
|
+
textAlign: "center",
|
|
561
|
+
pointerEvents: "auto",
|
|
562
|
+
cursor: a ? "not-allowed" : n === "target" && A ? "pointer" : w ? "grabbing" : "grab",
|
|
563
|
+
zIndex: w ? 1e3 : "auto",
|
|
564
|
+
willChange: w ? "transform" : "auto"
|
|
565
|
+
},
|
|
566
|
+
role: N ? "button" : void 0,
|
|
567
|
+
tabIndex: N ? 0 : void 0,
|
|
568
|
+
onKeyDown: N ? F : void 0,
|
|
569
|
+
onClick: M,
|
|
570
|
+
onMouseEnter: () => O(!0),
|
|
571
|
+
onMouseLeave: () => O(!1),
|
|
572
|
+
"data-tile-id": R,
|
|
573
|
+
...u && !a ? {
|
|
574
|
+
...x,
|
|
575
|
+
...b
|
|
576
|
+
} : {},
|
|
577
|
+
children: /* @__PURE__ */ P(Te, {
|
|
578
|
+
label: t,
|
|
579
|
+
id: r,
|
|
580
|
+
empty: i,
|
|
581
|
+
index: s,
|
|
582
|
+
guideIndex: c,
|
|
583
|
+
isOver: j,
|
|
584
|
+
isDragging: w,
|
|
585
|
+
isSelected: E,
|
|
586
|
+
disabled: a,
|
|
587
|
+
outcome: o,
|
|
588
|
+
type: n
|
|
589
|
+
})
|
|
590
|
+
});
|
|
591
|
+
};
|
|
592
|
+
K.propTypes = {
|
|
593
|
+
id: L.default.any,
|
|
594
|
+
label: L.default.string,
|
|
595
|
+
isOver: L.default.bool,
|
|
596
|
+
type: L.default.string,
|
|
597
|
+
empty: L.default.bool,
|
|
598
|
+
disabled: L.default.bool,
|
|
599
|
+
outcome: L.default.string,
|
|
600
|
+
index: L.default.number,
|
|
601
|
+
guideIndex: L.default.number,
|
|
602
|
+
instanceId: L.default.any,
|
|
603
|
+
draggable: L.default.bool,
|
|
604
|
+
tileIndex: L.default.number,
|
|
605
|
+
selectedChoice: L.default.object,
|
|
606
|
+
onChoiceClick: L.default.func,
|
|
607
|
+
onPlacementClick: L.default.func
|
|
608
|
+
};
|
|
609
|
+
//#endregion
|
|
610
|
+
//#region src/delivery/tiler.tsx
|
|
611
|
+
var q = {
|
|
612
|
+
choiceLabel: L.default.string,
|
|
613
|
+
targetLabel: L.default.string,
|
|
614
|
+
disabled: L.default.bool,
|
|
615
|
+
tiles: L.default.array.isRequired,
|
|
616
|
+
tileSize: L.default.string,
|
|
617
|
+
addGuide: L.default.bool,
|
|
618
|
+
selectedChoice: L.default.object,
|
|
619
|
+
onChoiceClick: L.default.func,
|
|
620
|
+
onPlacementClick: L.default.func
|
|
621
|
+
}, Ee = {
|
|
622
|
+
tileSize: "1fr",
|
|
623
|
+
disabled: !1,
|
|
624
|
+
addGuide: !1
|
|
625
|
+
}, De = (e) => {
|
|
626
|
+
let t = (t, n) => (t.instanceId = e.instanceId, t.disabled = e.disabled, t.guideIndex = e.addGuide ? t.index + 1 : void 0, t.tileIndex = n, t.selectedChoice = e.selectedChoice, t.onChoiceClick = e.onChoiceClick, t.onPlacementClick = e.onPlacementClick, e.includeTargets || t.type === "choice" ? /* @__PURE__ */ A(K, {
|
|
627
|
+
...t,
|
|
628
|
+
key: n
|
|
629
|
+
}) : /* @__PURE__ */ A(K, {
|
|
630
|
+
...t,
|
|
631
|
+
label: "",
|
|
632
|
+
key: n
|
|
633
|
+
}));
|
|
634
|
+
return t.propTypes = { ...q }, t;
|
|
635
|
+
}, Oe = b("div")(({ theme: e, includeTargets: t }) => ({
|
|
636
|
+
display: "grid",
|
|
637
|
+
paddingBottom: e.spacing(2),
|
|
638
|
+
...t && { gridGap: "10px" }
|
|
639
|
+
})), ke = b("div")({ textAlign: "center" }), Ae = b("div")({
|
|
640
|
+
textAlign: "center",
|
|
641
|
+
gridRow: "3/4"
|
|
642
|
+
}), je = b("div")(({ includeTargets: e }) => ({
|
|
643
|
+
gridAutoFlow: "column",
|
|
644
|
+
display: "grid",
|
|
645
|
+
...e && { gridGap: "10px" }
|
|
646
|
+
})), Me = b("div")({
|
|
647
|
+
gridColumn: "1/2",
|
|
648
|
+
textAlign: "center"
|
|
649
|
+
}), Ne = b("div")({
|
|
650
|
+
gridColumn: "2/3",
|
|
651
|
+
textAlign: "center"
|
|
652
|
+
}), Pe = class extends k.Component {
|
|
653
|
+
static propTypes = { ...q };
|
|
654
|
+
static defaultProps = { ...Ee };
|
|
655
|
+
render() {
|
|
656
|
+
let { includeTargets: e, choiceLabelEnabled: t, choiceLabel: n, targetLabel: r, tiles: i, tileSize: a } = this.props, o = e ? `auto ${a} auto ${a}` : `auto ${a} auto`, s = e ? i.length / 2 : i.length, c = {
|
|
657
|
+
gridTemplateColumns: e ? `repeat(${s}, ${a})` : `auto repeat(${Math.floor(s / 2) - 1}, ${a} 10px) ${a} auto`,
|
|
658
|
+
gridTemplateRows: o
|
|
659
|
+
}, l = { gridColumn: `1/${s + 1}` };
|
|
660
|
+
return /* @__PURE__ */ F(Oe, {
|
|
661
|
+
includeTargets: e,
|
|
662
|
+
style: c,
|
|
663
|
+
children: [
|
|
664
|
+
/* @__PURE__ */ P(ke, {
|
|
665
|
+
style: l,
|
|
666
|
+
dangerouslySetInnerHTML: { __html: t ? n : "" }
|
|
667
|
+
}),
|
|
668
|
+
e && /* @__PURE__ */ P(Ae, {
|
|
669
|
+
style: l,
|
|
670
|
+
dangerouslySetInnerHTML: { __html: r }
|
|
671
|
+
}),
|
|
672
|
+
i.map(De(this.props))
|
|
673
|
+
]
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
}, Fe = class extends k.Component {
|
|
677
|
+
static propTypes = { ...q };
|
|
678
|
+
static defaultProps = { ...Ee };
|
|
679
|
+
render() {
|
|
680
|
+
let { includeTargets: e, choiceLabelEnabled: t, choiceLabel: n, targetLabel: r, tiles: i, tileSize: a } = this.props, o = e ? 2 : 1, s = e ? i.length / 2 : i.length;
|
|
681
|
+
return /* @__PURE__ */ F(je, {
|
|
682
|
+
includeTargets: e,
|
|
683
|
+
style: {
|
|
684
|
+
gridTemplateColumns: `repeat(${o}, ${a})`,
|
|
685
|
+
gridTemplateRows: e ? `auto repeat(${s}, ${a})` : `auto auto repeat(${Math.floor(s / 2) - 1}, ${a} 10px) ${a} auto`
|
|
686
|
+
},
|
|
687
|
+
children: [
|
|
688
|
+
/* @__PURE__ */ P(Me, { dangerouslySetInnerHTML: { __html: t ? n : "" } }),
|
|
689
|
+
e && /* @__PURE__ */ P(Ne, { dangerouslySetInnerHTML: { __html: r } }),
|
|
690
|
+
i.map(De(this.props))
|
|
691
|
+
]
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
}, Ie = (0, I.default)("pie-elements:placement-ordering:ordering"), Le = (e, t, n) => {
|
|
695
|
+
let r = e.find((e, n) => n === t), i = e.filter((e, n) => n !== t);
|
|
696
|
+
return [
|
|
697
|
+
...i.slice(0, n),
|
|
698
|
+
r,
|
|
699
|
+
...i.slice(n)
|
|
700
|
+
];
|
|
701
|
+
};
|
|
702
|
+
function Re(e, t) {
|
|
703
|
+
let r = n(e.response);
|
|
704
|
+
if (r[t.index] === t.id) r[t.index] = void 0;
|
|
705
|
+
else throw Error(`Tried to remove from index: ${t.index}, but the id doesn't match: array: ${r}, target: ${t.id}`);
|
|
706
|
+
return r;
|
|
707
|
+
}
|
|
708
|
+
function ze(e, t, r) {
|
|
709
|
+
let { response: i, opts: a } = e, o = n(i);
|
|
710
|
+
if (a.includeTargets) return t.type === "choice" && r.type === "target" ? (o[r.index] = t.id, o) : t.type === "target" && r.type === "choice" ? (o[t.index] = void 0, o) : t.type === "target" && r.type === "target" ? (o[r.index] = t.id, o[t.index] = void 0, o) : (Ie("do nothing to the response"), i);
|
|
711
|
+
let s = e.response.findIndex((e) => e !== void 0 && e === t.id), c = e.response.findIndex((e) => e !== void 0 && e === r.id);
|
|
712
|
+
return Ie("fromIndex: ", s, "toIndex:", c), Le(e.response, s, c);
|
|
713
|
+
}
|
|
714
|
+
function J(e, t, n, r) {
|
|
715
|
+
if (r.includeTargets) {
|
|
716
|
+
let i = [];
|
|
717
|
+
for (let r = 0; r < t.length; r++) {
|
|
718
|
+
let a = t[r], o = e.find((e) => a != null && e.id === a), s = n[r], c = Object.assign({
|
|
719
|
+
type: "target",
|
|
720
|
+
index: r,
|
|
721
|
+
empty: o === void 0
|
|
722
|
+
}, o, s, { draggable: o !== void 0 });
|
|
723
|
+
i.push(c);
|
|
724
|
+
}
|
|
725
|
+
return e.map((e) => t.indexOf(e.id) !== -1 && !r.allowSameChoiceInTargets ? {
|
|
726
|
+
type: "choice",
|
|
727
|
+
id: e.id,
|
|
728
|
+
empty: !0,
|
|
729
|
+
droppable: !0,
|
|
730
|
+
draggable: !1
|
|
731
|
+
} : Object.assign({}, e, {
|
|
732
|
+
type: "choice",
|
|
733
|
+
droppable: !1,
|
|
734
|
+
draggable: !0
|
|
735
|
+
})).concat(i);
|
|
736
|
+
} else return t.reduce((t, r, i) => {
|
|
737
|
+
let a = Object.assign({
|
|
738
|
+
type: "empty",
|
|
739
|
+
draggable: !1,
|
|
740
|
+
droppable: !0
|
|
741
|
+
}, e.find((e) => e.id === r), n[i]), o = Object.assign({
|
|
742
|
+
type: "choice",
|
|
743
|
+
draggable: !0,
|
|
744
|
+
droppable: !0
|
|
745
|
+
}, e.find((e) => e.id === r), n[i]);
|
|
746
|
+
return i === 0 && t.push(a), t.push(o, a), t;
|
|
747
|
+
}, []);
|
|
748
|
+
}
|
|
749
|
+
function Be(e, t, n, i) {
|
|
750
|
+
return i = r({ includeTargets: !0 }, i), n ||= [], t = !t || a(t) ? i.includeTargets ? Array(e.length) : c(e, (e) => e.id) : t, {
|
|
751
|
+
choices: e,
|
|
752
|
+
response: t,
|
|
753
|
+
opts: i,
|
|
754
|
+
outcomes: n,
|
|
755
|
+
tiles: J(e, t, n, i)
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
function Ve(e, t) {
|
|
759
|
+
switch (e.type) {
|
|
760
|
+
case "move": {
|
|
761
|
+
let { from: n, to: r } = e, i = ze(t, n, r), a = J(t.choices, i, t.outcomes, t.opts);
|
|
762
|
+
return Object.assign({}, t, {
|
|
763
|
+
response: i,
|
|
764
|
+
tiles: a
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
case "remove": {
|
|
768
|
+
let { target: n } = e, r = Re(t, n), i = J(t.choices, r, t.outcomes, t.opts);
|
|
769
|
+
return Object.assign({}, t, {
|
|
770
|
+
response: r,
|
|
771
|
+
tiles: i
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
return t;
|
|
776
|
+
}
|
|
777
|
+
//#endregion
|
|
778
|
+
//#region src/delivery/utils.ts
|
|
779
|
+
var He = (e, t) => {
|
|
780
|
+
if (!Array.isArray(e) || !Array.isArray(t) || e.length !== t.length) return !1;
|
|
781
|
+
let n = (e) => e.map((e) => JSON.stringify(e)).sort(), r = n(e), i = n(t), a = r.every((e, t) => e === i[t]), o = e.every((e, n) => JSON.stringify(e) === JSON.stringify(t[n]));
|
|
782
|
+
return a && !o;
|
|
783
|
+
}, Ue = (e, { active: t, context: n, currentCoordinates: r }) => {
|
|
784
|
+
let { code: i } = e, a = i === "Tab", o = i === h.Down || i === h.Up || i === h.Left || i === h.Right;
|
|
785
|
+
if (!a && !o) return;
|
|
786
|
+
if (o) return y(e, {
|
|
787
|
+
context: n,
|
|
788
|
+
currentCoordinates: r
|
|
789
|
+
});
|
|
790
|
+
e.preventDefault();
|
|
791
|
+
let { droppableRects: s, droppableContainers: c, collisionRect: l, draggableNodes: u, active: d } = n;
|
|
792
|
+
if (!s || s.size === 0) return r;
|
|
793
|
+
let f = {
|
|
794
|
+
x: (l?.width || 0) / 2,
|
|
795
|
+
y: (l?.height || 0) / 2
|
|
796
|
+
}, p = {
|
|
797
|
+
x: r.x + f.x,
|
|
798
|
+
y: r.y + f.y
|
|
799
|
+
}, m = u?.get(t)?.data?.current?.id, g = d?.rect?.current?.initial, _ = typeof t == "string" ? t.replace(/^tile-/, "drop-") : void 0, v = [], b;
|
|
800
|
+
for (let [e, t] of c) {
|
|
801
|
+
let n = t?.data?.current, r = e === _;
|
|
802
|
+
if (t?.disabled && !r) continue;
|
|
803
|
+
let i = n?.type === "choice" && n?.id === m;
|
|
804
|
+
if (n?.type === "choice" && !i) continue;
|
|
805
|
+
let a = (r ? g : null) || s.get(e);
|
|
806
|
+
if (!a) continue;
|
|
807
|
+
let o = {
|
|
808
|
+
x: a.left + a.width / 2,
|
|
809
|
+
y: a.top + a.height / 2
|
|
810
|
+
}, c = {
|
|
811
|
+
id: e,
|
|
812
|
+
dropPosition: {
|
|
813
|
+
x: a.left,
|
|
814
|
+
y: a.top + a.height / 2 - f.y
|
|
815
|
+
},
|
|
816
|
+
center: o
|
|
817
|
+
};
|
|
818
|
+
i ? b = c : v.push(c);
|
|
819
|
+
}
|
|
820
|
+
if (v.length === 0 && !b) return r;
|
|
821
|
+
let x = e.shiftKey;
|
|
822
|
+
v.sort((e, t) => Math.abs(e.center.y - t.center.y) > 10 ? e.center.y - t.center.y : e.center.x - t.center.x), b && v.push(b);
|
|
823
|
+
let S = 0, C = Infinity;
|
|
824
|
+
for (let e = 0; e < v.length; e++) {
|
|
825
|
+
let t = We(p, v[e].center);
|
|
826
|
+
t < C && (C = t, S = e);
|
|
827
|
+
}
|
|
828
|
+
return v[x ? (S - 1 + v.length) % v.length : (S + 1) % v.length].dropPosition;
|
|
829
|
+
}, We = (e, t) => Math.sqrt((e.x - t.x) ** 2 + (e.y - t.y) ** 2);
|
|
830
|
+
//#endregion
|
|
831
|
+
//#region src/delivery/placement-ordering.tsx
|
|
832
|
+
function Y(e) {
|
|
833
|
+
return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
|
|
834
|
+
}
|
|
835
|
+
function X(e, t) {
|
|
836
|
+
return !e || Y(e) ? e : Y(e.default) ? e.default : t && Y(e[t]) ? e[t] : t && Y(e[t]?.default) ? e[t].default : e;
|
|
837
|
+
}
|
|
838
|
+
var Ge = X(D, "UiLayout") || X($.UiLayout, "UiLayout"), Z = X(T, "PreviewPrompt") || X($.PreviewPrompt, "PreviewPrompt"), Ke = X(p, "Feedback") || X($.Feedback, "Feedback"), qe = X(f, "Collapsible") || X($.Collapsible, "Collapsible"), Je = x, Q = Je.default, $ = Q && typeof Q == "object" ? Q : Je, Ye = 250, Xe = (e, t) => {
|
|
839
|
+
if (!e || !t) return !1;
|
|
840
|
+
let n = t.left + t.width / 2, r = t.top + t.height / 2;
|
|
841
|
+
return n >= e.left && n <= e.right && r >= e.top && r <= e.bottom;
|
|
842
|
+
}, Ze = (e) => e ? {
|
|
843
|
+
keyboardCoordinateGetter: Ue,
|
|
844
|
+
keyboardCodes: {
|
|
845
|
+
start: ["Space", "Enter"],
|
|
846
|
+
cancel: ["Escape"],
|
|
847
|
+
end: ["Space", "Enter"]
|
|
848
|
+
},
|
|
849
|
+
accessibility: { screenReaderInstructions: { draggable: "Press Space or Enter to pick up this answer choice. Once picked up, use Tab or Shift+Tab to cycle through response areas, or use arrow keys to move it freely. Press Space or Enter to drop, or Escape to cancel." } }
|
|
850
|
+
} : {}, { translator: Qe } = O, $e = (0, I.default)("pie-elements:placement-ordering"), et = b("div")({
|
|
851
|
+
color: w.text(),
|
|
852
|
+
backgroundColor: w.background(),
|
|
853
|
+
display: "flex",
|
|
854
|
+
flexDirection: "column",
|
|
855
|
+
alignItems: "center",
|
|
856
|
+
boxSizing: "border-box"
|
|
857
|
+
}), tt = b("div")({
|
|
858
|
+
alignSelf: "stretch",
|
|
859
|
+
maxWidth: "100%",
|
|
860
|
+
overflowX: "auto",
|
|
861
|
+
overflowY: "hidden"
|
|
862
|
+
}), nt = b("div")({
|
|
863
|
+
display: "flex",
|
|
864
|
+
justifyContent: "center",
|
|
865
|
+
minWidth: "min-content"
|
|
866
|
+
}), rt = b("div")(({ theme: e }) => ({ paddingBottom: e.spacing(1) })), it = b("div")(({ theme: e }) => ({ paddingBottom: e.spacing(2) })), at = b(ge)(({ theme: e }) => ({ paddingBottom: e.spacing(1) })), ot = b(qe)(({ theme: e }) => ({
|
|
867
|
+
marginBottom: e.spacing(2),
|
|
868
|
+
alignSelf: "flex-start"
|
|
869
|
+
})), st = (e) => {
|
|
870
|
+
let { tiler: t, ordering: n, onDropChoice: r, onRemoveChoice: i, ...a } = e;
|
|
871
|
+
return /* @__PURE__ */ P(t, {
|
|
872
|
+
...a,
|
|
873
|
+
tiles: n.tiles,
|
|
874
|
+
onDropChoice: (e, t) => r(e, t, n),
|
|
875
|
+
onRemoveChoice: (e) => i(e, n)
|
|
876
|
+
});
|
|
877
|
+
};
|
|
878
|
+
st.propTypes = {
|
|
879
|
+
tiler: L.default.func,
|
|
880
|
+
ordering: L.default.any,
|
|
881
|
+
onDropChoice: L.default.func,
|
|
882
|
+
onRemoveChoice: L.default.func
|
|
883
|
+
};
|
|
884
|
+
var ct = class extends k.Component {
|
|
885
|
+
static propTypes = {
|
|
886
|
+
onSessionChange: L.default.func.isRequired,
|
|
887
|
+
model: L.default.object.isRequired,
|
|
888
|
+
session: L.default.oneOfType([L.default.array.isRequired, L.default.object.isRequired])
|
|
889
|
+
};
|
|
890
|
+
constructor(e) {
|
|
891
|
+
super(e), this.instanceId = i();
|
|
892
|
+
let { value: t, needsReset: n } = this.validateSession(e);
|
|
893
|
+
this.state = {
|
|
894
|
+
showingCorrect: !1,
|
|
895
|
+
selectedChoice: null
|
|
896
|
+
}, this.lastDragEndAt = 0;
|
|
897
|
+
let { model: r } = e || {}, { env: a } = r || {}, { mode: o } = a || {};
|
|
898
|
+
n && o === "gather" && this.props.onSessionChange({
|
|
899
|
+
...e.session,
|
|
900
|
+
value: t
|
|
901
|
+
});
|
|
902
|
+
}
|
|
903
|
+
toggleCorrect = (e) => this.setState({ showingCorrect: e });
|
|
904
|
+
componentDidUpdate() {
|
|
905
|
+
d(N.findDOMNode(this));
|
|
906
|
+
}
|
|
907
|
+
validateSession = ({ model: e, session: t }, n = !1) => {
|
|
908
|
+
let { config: r, choices: i } = e || {}, { includeTargets: a } = r || {}, s = i.map((e) => e.id), { value: c } = t || {}, u;
|
|
909
|
+
if (a) c && c.length !== s.length && (u = !0, c = c.length < s.length ? c.concat(Array(s.length - c.length)) : c.filter((e) => s.includes(e)));
|
|
910
|
+
else {
|
|
911
|
+
if (!c || !c.length || n) c = s;
|
|
912
|
+
else {
|
|
913
|
+
let e = l(s, c), t = l(c, s);
|
|
914
|
+
(e.length || t.length) && (c = s);
|
|
915
|
+
}
|
|
916
|
+
u = !o(t.value, c);
|
|
917
|
+
}
|
|
918
|
+
return u && console.warn("This session is not valid anymore. It will be reset."), {
|
|
919
|
+
value: c,
|
|
920
|
+
needsReset: u
|
|
921
|
+
};
|
|
922
|
+
};
|
|
923
|
+
UNSAFE_componentWillReceiveProps(e) {
|
|
924
|
+
let { model: t = {} } = e || {}, { model: n = {} } = this.props || {}, { correctResponse: r, config: i, choices: a = [], env: o } = t, { includeTargets: s } = i || {}, c = {}, l = n.language && n.language !== t.language, u = n.note && n.note === Qe.t("common:commonCorrectAnswerWithAlternates", { lng: n.language });
|
|
925
|
+
l && u && (n.note = Qe.t("common:commonCorrectAnswerWithAlternates", { lng: t.language })), r || (c.showingCorrect = !1);
|
|
926
|
+
let d = He(a, n.choices), { value: f, needsReset: p } = this.validateSession(e, d), m = {
|
|
927
|
+
...e.session,
|
|
928
|
+
value: f
|
|
929
|
+
}, h = n.config?.includeTargets !== s;
|
|
930
|
+
s && h && (p = !0, delete m.value), this.setState(c, () => {
|
|
931
|
+
let { mode: e } = o || {};
|
|
932
|
+
p && e === "gather" && this.props.onSessionChange(m);
|
|
933
|
+
});
|
|
934
|
+
}
|
|
935
|
+
onDropChoice = (e, t, n) => {
|
|
936
|
+
let { onSessionChange: r, session: i } = this.props, a = n.tiles.find((e) => e.id === t.id && e.type === t.type && e.index === t.index), o = e;
|
|
937
|
+
$e("[onDropChoice] ", a, o);
|
|
938
|
+
let s = Ve({
|
|
939
|
+
type: "move",
|
|
940
|
+
from: a,
|
|
941
|
+
to: o
|
|
942
|
+
}, n);
|
|
943
|
+
r(Object.assign({}, i, { value: s.response }));
|
|
944
|
+
};
|
|
945
|
+
onRemoveChoice = (e, t) => {
|
|
946
|
+
let { onSessionChange: n, session: r } = this.props;
|
|
947
|
+
$e("[onRemoveChoice]", e);
|
|
948
|
+
let i = Ve({
|
|
949
|
+
type: "remove",
|
|
950
|
+
target: e
|
|
951
|
+
}, t);
|
|
952
|
+
n(Object.assign({}, r, { value: i.response }));
|
|
953
|
+
};
|
|
954
|
+
createOrdering = () => {
|
|
955
|
+
let { model: e, session: t } = this.props, { showingCorrect: n } = this.state, { includeTargets: r } = e.config || {
|
|
956
|
+
orientation: "vertical",
|
|
957
|
+
includeTargets: !0
|
|
958
|
+
};
|
|
959
|
+
return n ? Be(e.choices, e.correctResponse, e.correctResponse.map((e) => ({
|
|
960
|
+
id: e,
|
|
961
|
+
outcome: "correct"
|
|
962
|
+
})), {
|
|
963
|
+
includeTargets: r,
|
|
964
|
+
allowSameChoiceInTargets: e.config.allowSameChoiceInTargets
|
|
965
|
+
}) : Be(e.choices, t.value, e.outcomes, {
|
|
966
|
+
includeTargets: r,
|
|
967
|
+
allowSameChoiceInTargets: e.config.allowSameChoiceInTargets
|
|
968
|
+
});
|
|
969
|
+
};
|
|
970
|
+
onDragEnd = (e) => {
|
|
971
|
+
let { over: t, active: n } = e, r = this.createOrdering();
|
|
972
|
+
if (this.cancelSelection(), this.lastDragEndAt = Date.now(), t && n) {
|
|
973
|
+
let e = n.data.current, i = t.data.current;
|
|
974
|
+
if (e && i && i.type === "target") {
|
|
975
|
+
this.onDropChoice(i, e, r), this.focusTile(this.getDestinationSlotId(i));
|
|
976
|
+
return;
|
|
977
|
+
}
|
|
978
|
+
e && i && (this.onDropChoice(i, e, r), this.focusTile(this.getDestinationSlotId(i)));
|
|
979
|
+
} else if (!t && n) {
|
|
980
|
+
let e = n.data.current, t = Xe(n.rect?.current?.initial, n.rect?.current?.translated);
|
|
981
|
+
e && e.type === "target" && !t && (this.onRemoveChoice(e, r), this.focusTile(this.getDestinationSlotId({
|
|
982
|
+
type: "choice",
|
|
983
|
+
id: e.id
|
|
984
|
+
})));
|
|
985
|
+
}
|
|
986
|
+
};
|
|
987
|
+
onDragStart = (e) => {
|
|
988
|
+
let { active: t } = e;
|
|
989
|
+
t?.data?.current && this.selectChoice(t.data.current);
|
|
990
|
+
};
|
|
991
|
+
onDragCancel = () => {
|
|
992
|
+
this.cancelSelection(), this.lastDragEndAt = Date.now();
|
|
993
|
+
};
|
|
994
|
+
isSameChoice = (e, t) => !!e && !!t && e.type === t.type && e.id === t.id && e.index === t.index;
|
|
995
|
+
selectChoice = (e) => {
|
|
996
|
+
this.setState({ selectedChoice: e });
|
|
997
|
+
};
|
|
998
|
+
toggleChoiceSelection = (e) => {
|
|
999
|
+
this.setState((t) => ({ selectedChoice: this.isSameChoice(t.selectedChoice, e) ? null : e }));
|
|
1000
|
+
};
|
|
1001
|
+
cancelSelection = () => {
|
|
1002
|
+
this.setState({ selectedChoice: null });
|
|
1003
|
+
};
|
|
1004
|
+
endAnyLiveKeyboardDrag = () => {
|
|
1005
|
+
document.dispatchEvent(new KeyboardEvent("keydown", {
|
|
1006
|
+
code: "Escape",
|
|
1007
|
+
bubbles: !0,
|
|
1008
|
+
cancelable: !0
|
|
1009
|
+
}));
|
|
1010
|
+
};
|
|
1011
|
+
placeSelectedChoice = (e) => {
|
|
1012
|
+
let { selectedChoice: t } = this.state;
|
|
1013
|
+
if (!t) return;
|
|
1014
|
+
let n = this.createOrdering(), r = this.getDestinationSlotId(e);
|
|
1015
|
+
this.onDropChoice(e, t, n), this.cancelSelection(), this.endAnyLiveKeyboardDrag(), this.lastDragEndAt = Date.now(), this.focusTile(r);
|
|
1016
|
+
};
|
|
1017
|
+
getDestinationSlotId = (e) => e ? e.type === "target" ? `target-${e.index}` : e.type === "choice" ? `choice-${e.id}` : null : null;
|
|
1018
|
+
focusTile = (e) => {
|
|
1019
|
+
if (!e) return;
|
|
1020
|
+
let t = `[data-tile-id="${this.instanceId}:${e}"]`;
|
|
1021
|
+
requestAnimationFrame(() => {
|
|
1022
|
+
requestAnimationFrame(() => {
|
|
1023
|
+
document.querySelector(t)?.focus();
|
|
1024
|
+
});
|
|
1025
|
+
});
|
|
1026
|
+
};
|
|
1027
|
+
isClickSoonAfterDragEnd = () => Date.now() - this.lastDragEndAt < Ye;
|
|
1028
|
+
onChoiceClick = (e) => {
|
|
1029
|
+
this.isClickSoonAfterDragEnd() || this.toggleChoiceSelection(e);
|
|
1030
|
+
};
|
|
1031
|
+
onPlacementClick = (e) => {
|
|
1032
|
+
this.isClickSoonAfterDragEnd() || this.placeSelectedChoice(e);
|
|
1033
|
+
};
|
|
1034
|
+
render() {
|
|
1035
|
+
let { model: e } = this.props, { correctResponse: t, correctness: n, extraCSSRules: r, prompt: i, rationale: a, feedback: o, config: s, note: c, showNote: l, env: u, disabled: d, teacherInstructions: f, language: p } = e, h = t && t.length > 0, { showingCorrect: g } = this.state, _ = s || {
|
|
1036
|
+
orientation: "vertical",
|
|
1037
|
+
includeTargets: !0
|
|
1038
|
+
}, { orientation: v, includeTargets: y } = _, b = v === "vertical", x = this.createOrdering(), { mode: S, role: T } = u || {}, D = b ? Fe : Pe, O = (g || S === "view" && T === "instructor") && l && c, k = a && (m(a) || C(a)), A = f && (m(f) || C(f)), j = {
|
|
1039
|
+
color: w.text(),
|
|
1040
|
+
backgroundColor: w.background(),
|
|
1041
|
+
display: "flex",
|
|
1042
|
+
flexDirection: "column",
|
|
1043
|
+
alignItems: "center",
|
|
1044
|
+
boxSizing: "border-box",
|
|
1045
|
+
width: "100%"
|
|
1046
|
+
}, M = y ? {
|
|
1047
|
+
selectedChoice: this.state.selectedChoice,
|
|
1048
|
+
onChoiceClick: this.onChoiceClick,
|
|
1049
|
+
onPlacementClick: this.onPlacementClick
|
|
1050
|
+
} : {};
|
|
1051
|
+
return /* @__PURE__ */ P(ee, {
|
|
1052
|
+
onDragStart: this.onDragStart,
|
|
1053
|
+
onDragEnd: this.onDragEnd,
|
|
1054
|
+
onDragCancel: this.onDragCancel,
|
|
1055
|
+
collisionDetection: E,
|
|
1056
|
+
modifiers: [ne],
|
|
1057
|
+
...Ze(y),
|
|
1058
|
+
children: /* @__PURE__ */ P(et, { children: /* @__PURE__ */ F(Ge, {
|
|
1059
|
+
extraCSSRules: r,
|
|
1060
|
+
style: j,
|
|
1061
|
+
children: [
|
|
1062
|
+
A && /* @__PURE__ */ P(ot, {
|
|
1063
|
+
labels: {
|
|
1064
|
+
hidden: "Show Teacher Instructions",
|
|
1065
|
+
visible: "Hide Teacher Instructions"
|
|
1066
|
+
},
|
|
1067
|
+
className: "collapsible",
|
|
1068
|
+
children: /* @__PURE__ */ P(Z, { prompt: f })
|
|
1069
|
+
}),
|
|
1070
|
+
/* @__PURE__ */ P(rt, { children: /* @__PURE__ */ P(Z, { prompt: i }) }),
|
|
1071
|
+
/* @__PURE__ */ P(at, {
|
|
1072
|
+
show: h,
|
|
1073
|
+
toggled: g,
|
|
1074
|
+
onToggle: this.toggleCorrect,
|
|
1075
|
+
language: p
|
|
1076
|
+
}),
|
|
1077
|
+
/* @__PURE__ */ P(tt, { children: /* @__PURE__ */ P(nt, { children: /* @__PURE__ */ P(st, {
|
|
1078
|
+
instanceId: this.instanceId,
|
|
1079
|
+
choiceLabel: _.choiceLabel,
|
|
1080
|
+
targetLabel: _.targetLabel,
|
|
1081
|
+
ordering: x,
|
|
1082
|
+
tiler: D,
|
|
1083
|
+
disabled: d,
|
|
1084
|
+
addGuide: _.showOrdering,
|
|
1085
|
+
tileSize: _.tileSize,
|
|
1086
|
+
includeTargets: y,
|
|
1087
|
+
choiceLabelEnabled: e.config && e.config.choiceLabelEnabled,
|
|
1088
|
+
...M
|
|
1089
|
+
}) }) }),
|
|
1090
|
+
O && /* @__PURE__ */ P(it, { dangerouslySetInnerHTML: { __html: c } }),
|
|
1091
|
+
k && /* @__PURE__ */ P(ot, {
|
|
1092
|
+
labels: {
|
|
1093
|
+
hidden: "Show Rationale",
|
|
1094
|
+
visible: "Hide Rationale"
|
|
1095
|
+
},
|
|
1096
|
+
className: "collapsible",
|
|
1097
|
+
children: /* @__PURE__ */ P(Z, { prompt: a })
|
|
1098
|
+
}),
|
|
1099
|
+
!g && /* @__PURE__ */ P(Ke, {
|
|
1100
|
+
correctness: n,
|
|
1101
|
+
feedback: o
|
|
1102
|
+
})
|
|
1103
|
+
]
|
|
1104
|
+
}) })
|
|
1105
|
+
});
|
|
1106
|
+
}
|
|
1107
|
+
}, lt = class extends k.Component {
|
|
1108
|
+
static propTypes = {
|
|
1109
|
+
model: L.default.object.isRequired,
|
|
1110
|
+
session: L.default.oneOfType([L.default.array.isRequired, L.default.object.isRequired]),
|
|
1111
|
+
onSessionChange: L.default.func.isRequired
|
|
1112
|
+
};
|
|
1113
|
+
render() {
|
|
1114
|
+
let { model: e, session: t, onSessionChange: n } = this.props;
|
|
1115
|
+
return /* @__PURE__ */ P(ct, {
|
|
1116
|
+
model: e,
|
|
1117
|
+
session: t,
|
|
1118
|
+
onSessionChange: n
|
|
1119
|
+
});
|
|
1120
|
+
}
|
|
1121
|
+
}, ut = (0, I.default)("pie-elements:placement-ordering"), dt = ({ model: e, session: n }) => {
|
|
1122
|
+
let { config: r } = e, i = (n && t(n.value) || []).length === e.choices.length;
|
|
1123
|
+
return r.includeTargets || i;
|
|
1124
|
+
}, ft = class extends HTMLElement {
|
|
1125
|
+
constructor() {
|
|
1126
|
+
super(), this._root = null, this._mathObserver = null, this._mathRenderPending = !1;
|
|
1127
|
+
}
|
|
1128
|
+
_scheduleMathRender = () => {
|
|
1129
|
+
this._mathRenderPending || (this._mathRenderPending = !0, requestAnimationFrame(() => {
|
|
1130
|
+
this._mathObserver && this._mathObserver.disconnect(), d(this), this._mathRenderPending = !1, setTimeout(() => {
|
|
1131
|
+
this._mathObserver && this._mathObserver.observe(this, {
|
|
1132
|
+
childList: !0,
|
|
1133
|
+
subtree: !0
|
|
1134
|
+
});
|
|
1135
|
+
}, 50);
|
|
1136
|
+
}));
|
|
1137
|
+
};
|
|
1138
|
+
_initMathObserver() {
|
|
1139
|
+
this._mathObserver || (this._mathObserver = new MutationObserver(this._scheduleMathRender), this._mathObserver.observe(this, {
|
|
1140
|
+
childList: !0,
|
|
1141
|
+
subtree: !0
|
|
1142
|
+
}));
|
|
1143
|
+
}
|
|
1144
|
+
_disconnectMathObserver() {
|
|
1145
|
+
this._mathObserver &&= (this._mathObserver.disconnect(), null);
|
|
1146
|
+
}
|
|
1147
|
+
isComplete = (e) => e && t(e).length === this._model.completeLength;
|
|
1148
|
+
sessionChange = (e) => {
|
|
1149
|
+
this._session.value = e.value, this.render(), this.dispatchEvent(new te(this.tagName.toLowerCase(), this._session && this.isComplete(this._session.value)));
|
|
1150
|
+
};
|
|
1151
|
+
set model(e) {
|
|
1152
|
+
this._model = e, this.render(), this.dispatchEvent(new CustomEvent("model-set", {
|
|
1153
|
+
bubbles: !0,
|
|
1154
|
+
detail: { complete: !1 }
|
|
1155
|
+
}));
|
|
1156
|
+
}
|
|
1157
|
+
set session(e) {
|
|
1158
|
+
this._session = e, this.render();
|
|
1159
|
+
}
|
|
1160
|
+
get session() {
|
|
1161
|
+
return this._session;
|
|
1162
|
+
}
|
|
1163
|
+
render() {
|
|
1164
|
+
if (this._model && this._session) {
|
|
1165
|
+
ut("[render] session: ", this._session.value), ut("[render] model: ", this._model), this._initMathObserver();
|
|
1166
|
+
let e = k.createElement(lt, {
|
|
1167
|
+
model: this._model,
|
|
1168
|
+
session: this._session,
|
|
1169
|
+
onSessionChange: this.sessionChange
|
|
1170
|
+
});
|
|
1171
|
+
this._root ||= M(this), this._root.render(e);
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
connectedCallback() {
|
|
1175
|
+
this._initMathObserver(), this.render();
|
|
1176
|
+
}
|
|
1177
|
+
disconnectedCallback() {
|
|
1178
|
+
this._disconnectMathObserver(), this._root &&= (this._root.unmount(), null);
|
|
1179
|
+
}
|
|
1180
|
+
};
|
|
1181
|
+
//#endregion
|
|
1182
|
+
export { ft as default, dt as isValidSession };
|
|
1183
|
+
|
|
1184
|
+
//# sourceMappingURL=index.js.map
|