@pie-element/match-list 7.1.2-next.11 → 7.1.2-next.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/delivery/index.js +1488 -1464
- package/dist/browser/delivery/index.js.map +1 -1
- package/dist/delivery/answer.js +3 -1
- package/dist/delivery/main.d.ts +2 -0
- package/dist/delivery/main.js +80 -60
- package/dist/index.iife.js +22 -22
- package/package.json +4 -4
package/dist/delivery/answer.js
CHANGED
|
@@ -139,7 +139,7 @@ function y(e) {
|
|
|
139
139
|
if (h) {
|
|
140
140
|
let t = () => {
|
|
141
141
|
l || (N ? f?.(g) : d ? p?.(y) : s && f?.(g));
|
|
142
|
-
}, n = !s && !l;
|
|
142
|
+
}, n = !s && !l && j;
|
|
143
143
|
return /* @__PURE__ */ c("div", {
|
|
144
144
|
ref: D,
|
|
145
145
|
role: "button",
|
|
@@ -160,6 +160,7 @@ function y(e) {
|
|
|
160
160
|
ref: S,
|
|
161
161
|
...x,
|
|
162
162
|
...b,
|
|
163
|
+
"data-tile-id": `${r}:${m}`,
|
|
163
164
|
style: {
|
|
164
165
|
transform: P,
|
|
165
166
|
transition: w
|
|
@@ -180,6 +181,7 @@ function y(e) {
|
|
|
180
181
|
ref: S,
|
|
181
182
|
...x,
|
|
182
183
|
...b,
|
|
184
|
+
"data-tile-id": `${r}:${m}`,
|
|
183
185
|
onClick: F,
|
|
184
186
|
style: {
|
|
185
187
|
transform: P,
|
package/dist/delivery/main.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export declare class Main extends React.Component {
|
|
|
21
21
|
onDragCancel: any;
|
|
22
22
|
placeAnswer: any;
|
|
23
23
|
onPlaceAnswer: any;
|
|
24
|
+
getDestinationDragId: any;
|
|
25
|
+
focusTile: any;
|
|
24
26
|
isSameAnswer: (a: any, b: any) => boolean;
|
|
25
27
|
selectAnswer: any;
|
|
26
28
|
toggleAnswerSelection: any;
|
package/dist/delivery/main.js
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
1
|
import { closestDroppableKeyboardCoordinates as e } from "./keyboard-coordinates.js";
|
|
2
|
-
import { Answer as t } from "./answer.js";
|
|
3
|
-
import { AnswerArea as
|
|
4
|
-
import { ChoicesList as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { swap as
|
|
8
|
-
import { DndContext as
|
|
9
|
-
import { restrictToFirstScrollableAncestor as
|
|
10
|
-
import
|
|
11
|
-
import * as
|
|
12
|
-
import { Feedback as
|
|
13
|
-
import { jsx as
|
|
14
|
-
import { styled as
|
|
15
|
-
import { findKey as
|
|
2
|
+
import { Answer as t, buildDragId as n } from "./answer.js";
|
|
3
|
+
import { AnswerArea as r } from "./answer-area.js";
|
|
4
|
+
import { ChoicesList as i } from "./choices-list.js";
|
|
5
|
+
import a from "react";
|
|
6
|
+
import o from "prop-types";
|
|
7
|
+
import { swap as s } from "@pie-lib/drag";
|
|
8
|
+
import { DndContext as c, DragOverlay as l, KeyboardCode as u, KeyboardSensor as d, PointerSensor as f, rectIntersection as p } from "@dnd-kit/core";
|
|
9
|
+
import { restrictToFirstScrollableAncestor as m } from "@dnd-kit/modifiers";
|
|
10
|
+
import h from "@pie-lib/correct-answer-toggle";
|
|
11
|
+
import * as g from "@pie-lib/render-ui";
|
|
12
|
+
import { Feedback as _, PreviewPrompt as v, color as y } from "@pie-lib/render-ui";
|
|
13
|
+
import { jsx as b, jsxs as x } from "react/jsx-runtime";
|
|
14
|
+
import { styled as S } from "@mui/material/styles";
|
|
15
|
+
import { findKey as C, isUndefined as w, uniqueId as T } from "@pie-element/shared-lodash";
|
|
16
16
|
//#region src/delivery/main.tsx
|
|
17
|
-
function
|
|
17
|
+
function E(e) {
|
|
18
18
|
return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
return !e ||
|
|
20
|
+
function D(e, t) {
|
|
21
|
+
return !e || E(e) ? e : E(e.default) ? e.default : t && E(e[t]) ? e[t] : t && E(e[t]?.default) ? e[t].default : e;
|
|
22
22
|
}
|
|
23
|
-
var
|
|
24
|
-
sensor:
|
|
23
|
+
var O = D(v, "PreviewPrompt") || D(M.PreviewPrompt, "PreviewPrompt"), k = D(_, "Feedback") || D(M.Feedback, "Feedback"), A = g, j = A.default, M = j && typeof j == "object" ? j : A, N = 250, P = [{
|
|
24
|
+
sensor: f,
|
|
25
25
|
options: { activationConstraint: { distance: 8 } }
|
|
26
26
|
}, {
|
|
27
|
-
sensor:
|
|
27
|
+
sensor: d,
|
|
28
28
|
options: {
|
|
29
29
|
coordinateGetter: e,
|
|
30
30
|
keyboardCodes: {
|
|
31
|
-
start: [
|
|
32
|
-
cancel: [
|
|
33
|
-
end: [
|
|
31
|
+
start: [u.Space, u.Enter],
|
|
32
|
+
cancel: [u.Esc],
|
|
33
|
+
end: [u.Space, u.Enter]
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
}],
|
|
36
|
+
}], F = S("div")({
|
|
37
37
|
display: "flex",
|
|
38
38
|
flexDirection: "column",
|
|
39
39
|
justifyContent: "center",
|
|
40
|
-
color:
|
|
41
|
-
backgroundColor:
|
|
42
|
-
}),
|
|
40
|
+
color: y.text(),
|
|
41
|
+
backgroundColor: y.background()
|
|
42
|
+
}), I = S("div")({
|
|
43
43
|
width: "100%",
|
|
44
44
|
overflowX: "auto",
|
|
45
45
|
overflowY: "hidden"
|
|
46
|
-
}),
|
|
46
|
+
}), L = S("div")({
|
|
47
47
|
display: "flex",
|
|
48
48
|
flexDirection: "column",
|
|
49
49
|
minWidth: "min-content"
|
|
50
|
-
}),
|
|
50
|
+
}), R = class extends a.Component {
|
|
51
51
|
static propTypes = {
|
|
52
|
-
session:
|
|
53
|
-
onSessionChange:
|
|
54
|
-
model:
|
|
55
|
-
prompt:
|
|
52
|
+
session: o.object.isRequired,
|
|
53
|
+
onSessionChange: o.func,
|
|
54
|
+
model: o.object.isRequired,
|
|
55
|
+
prompt: o.string
|
|
56
56
|
};
|
|
57
57
|
constructor(e) {
|
|
58
|
-
super(e), this.instanceId =
|
|
58
|
+
super(e), this.instanceId = T(), this.state = {
|
|
59
59
|
showCorrectAnswer: !1,
|
|
60
60
|
draggingElement: null,
|
|
61
61
|
selectedAnswer: null
|
|
@@ -88,20 +88,20 @@ var D = E(_, "PreviewPrompt") || E(j.PreviewPrompt, "PreviewPrompt"), O = E(g, "
|
|
|
88
88
|
placeAnswer = (e, t) => {
|
|
89
89
|
if (!e || !t) return;
|
|
90
90
|
let { session: n, onSessionChange: r, model: i } = this.props, { config: { duplicates: a } } = i;
|
|
91
|
-
if (
|
|
91
|
+
if (w(n.value) && (n.value = {}), t.type === "choices-pool" && e.promptId !== void 0) {
|
|
92
92
|
n.value[e.promptId] = void 0, r(n);
|
|
93
93
|
return;
|
|
94
94
|
}
|
|
95
|
-
let
|
|
95
|
+
let o = e.id, c = e.promptId;
|
|
96
96
|
if (t.type === "drop-zone" && t.promptId != null) {
|
|
97
97
|
let i = t.promptId;
|
|
98
98
|
if (e.type === "choice" && i !== void 0) {
|
|
99
|
-
let e =
|
|
100
|
-
e && !a ? n.value =
|
|
99
|
+
let e = C(n.value, (e) => e === o);
|
|
100
|
+
e && !a ? n.value = s(n.value, e, i) : n.value[i] = o;
|
|
101
101
|
} else if (e.type === "target" && c != null && c !== i) if (n.value[i] != null && !a) {
|
|
102
102
|
let e = n.value[i];
|
|
103
|
-
n.value[i] =
|
|
104
|
-
} else n.value[i] =
|
|
103
|
+
n.value[i] = o, n.value[c] = e;
|
|
104
|
+
} else n.value[i] = o, delete n.value[c];
|
|
105
105
|
r(n);
|
|
106
106
|
}
|
|
107
107
|
};
|
|
@@ -110,7 +110,25 @@ var D = E(_, "PreviewPrompt") || E(j.PreviewPrompt, "PreviewPrompt"), O = E(g, "
|
|
|
110
110
|
let { active: t, over: n } = e;
|
|
111
111
|
if (!t) return;
|
|
112
112
|
let r = t.data.current, i = n?.data.current;
|
|
113
|
-
|
|
113
|
+
if (!r) return;
|
|
114
|
+
let a = this.getDestinationDragId(r, i);
|
|
115
|
+
this.placeAnswer(r, i), this.cancelSelection(), this.lastDragEndAt = Date.now(), this.focusTile(a);
|
|
116
|
+
};
|
|
117
|
+
getDestinationDragId = (e, t) => !e || !t ? null : t.type === "choices-pool" && e.promptId !== void 0 ? n({
|
|
118
|
+
type: "choice",
|
|
119
|
+
id: e.id
|
|
120
|
+
}) : t.type === "drop-zone" && t.promptId != null ? n({
|
|
121
|
+
type: "target",
|
|
122
|
+
promptId: t.promptId
|
|
123
|
+
}) : null;
|
|
124
|
+
focusTile = (e) => {
|
|
125
|
+
if (!e) return;
|
|
126
|
+
let t = `[data-tile-id="${this.instanceId}:${e}"]`;
|
|
127
|
+
requestAnimationFrame(() => {
|
|
128
|
+
requestAnimationFrame(() => {
|
|
129
|
+
document.querySelector(t)?.focus();
|
|
130
|
+
});
|
|
131
|
+
});
|
|
114
132
|
};
|
|
115
133
|
isSameAnswer = (e, t) => !!e && !!t && e.type === t.type && e.id === t.id && e.promptId === t.promptId;
|
|
116
134
|
selectAnswer = (e) => {
|
|
@@ -131,9 +149,11 @@ var D = E(_, "PreviewPrompt") || E(j.PreviewPrompt, "PreviewPrompt"), O = E(g, "
|
|
|
131
149
|
};
|
|
132
150
|
placeSelectedAnswer = (e) => {
|
|
133
151
|
let { selectedAnswer: t } = this.state;
|
|
134
|
-
|
|
152
|
+
if (!t) return;
|
|
153
|
+
let n = this.getDestinationDragId(t, e);
|
|
154
|
+
this.placeAnswer(t, e), this.cancelSelection(), this.endAnyLiveKeyboardDrag(), this.lastDragEndAt = Date.now(), this.focusTile(n);
|
|
135
155
|
};
|
|
136
|
-
isClickSoonAfterDragEnd = () => Date.now() - this.lastDragEndAt <
|
|
156
|
+
isClickSoonAfterDragEnd = () => Date.now() - this.lastDragEndAt < N;
|
|
137
157
|
onChoiceClick = (e) => {
|
|
138
158
|
this.isClickSoonAfterDragEnd() || this.toggleAnswerSelection(e);
|
|
139
159
|
};
|
|
@@ -145,7 +165,7 @@ var D = E(_, "PreviewPrompt") || E(j.PreviewPrompt, "PreviewPrompt"), O = E(g, "
|
|
|
145
165
|
};
|
|
146
166
|
renderDragOverlay = () => {
|
|
147
167
|
let { draggingElement: e } = this.state;
|
|
148
|
-
return e ? /* @__PURE__ */
|
|
168
|
+
return e ? /* @__PURE__ */ b(t, {
|
|
149
169
|
id: e.id,
|
|
150
170
|
title: e.value,
|
|
151
171
|
disabled: !1,
|
|
@@ -158,53 +178,53 @@ var D = E(_, "PreviewPrompt") || E(j.PreviewPrompt, "PreviewPrompt"), O = E(g, "
|
|
|
158
178
|
}) : null;
|
|
159
179
|
};
|
|
160
180
|
render() {
|
|
161
|
-
let { showCorrectAnswer: e } = this.state, { model: t, session:
|
|
162
|
-
return /* @__PURE__ */
|
|
163
|
-
sensors:
|
|
164
|
-
collisionDetection:
|
|
181
|
+
let { showCorrectAnswer: e } = this.state, { model: t, session: n } = this.props, { config: a, mode: o } = t, { prompt: s, language: u } = a;
|
|
182
|
+
return /* @__PURE__ */ x(c, {
|
|
183
|
+
sensors: P,
|
|
184
|
+
collisionDetection: p,
|
|
165
185
|
onDragStart: this.onDragStart,
|
|
166
186
|
onDragEnd: this.onPlaceAnswer,
|
|
167
187
|
onDragCancel: this.onDragCancel,
|
|
168
|
-
modifiers: [
|
|
188
|
+
modifiers: [m],
|
|
169
189
|
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. You can also click an answer choice to select it, then click a response area to place it there." } },
|
|
170
|
-
children: [/* @__PURE__ */
|
|
171
|
-
/* @__PURE__ */
|
|
190
|
+
children: [/* @__PURE__ */ x(F, { children: [
|
|
191
|
+
/* @__PURE__ */ b(O, {
|
|
172
192
|
className: "prompt",
|
|
173
|
-
prompt:
|
|
193
|
+
prompt: s
|
|
174
194
|
}),
|
|
175
|
-
/* @__PURE__ */
|
|
195
|
+
/* @__PURE__ */ b(h, {
|
|
176
196
|
show: o === "evaluate",
|
|
177
197
|
toggled: e,
|
|
178
198
|
onToggle: this.toggleShowCorrect,
|
|
179
199
|
language: u
|
|
180
200
|
}),
|
|
181
|
-
/* @__PURE__ */
|
|
201
|
+
/* @__PURE__ */ b(I, { children: /* @__PURE__ */ x(L, { children: [/* @__PURE__ */ b(r, {
|
|
182
202
|
instanceId: this.instanceId,
|
|
183
203
|
model: t,
|
|
184
|
-
session:
|
|
204
|
+
session: n,
|
|
185
205
|
onRemoveAnswer: (e) => this.onRemoveAnswer(e),
|
|
186
206
|
disabled: o !== "gather",
|
|
187
207
|
showCorrect: e,
|
|
188
208
|
selectedAnswer: this.state.selectedAnswer,
|
|
189
209
|
onChoiceClick: this.onChoiceClick,
|
|
190
210
|
onPlacementClick: this.onPlacementClick
|
|
191
|
-
}), /* @__PURE__ */
|
|
211
|
+
}), /* @__PURE__ */ b(i, {
|
|
192
212
|
instanceId: this.instanceId,
|
|
193
213
|
model: t,
|
|
194
|
-
session:
|
|
214
|
+
session: n,
|
|
195
215
|
disabled: o !== "gather",
|
|
196
216
|
onRemoveAnswer: (e) => this.onRemoveAnswer(e),
|
|
197
217
|
selectedAnswer: this.state.selectedAnswer,
|
|
198
218
|
onChoiceClick: this.onChoiceClick,
|
|
199
219
|
onPlacementClick: this.onPlacementClick
|
|
200
220
|
})] }) }),
|
|
201
|
-
t.correctness && t.feedback && !e && /* @__PURE__ */
|
|
221
|
+
t.correctness && t.feedback && !e && /* @__PURE__ */ b(k, {
|
|
202
222
|
correctness: t.correctness.correctness,
|
|
203
223
|
feedback: t.feedback
|
|
204
224
|
})
|
|
205
|
-
] }), /* @__PURE__ */
|
|
225
|
+
] }), /* @__PURE__ */ b(l, { children: this.renderDragOverlay() })]
|
|
206
226
|
});
|
|
207
227
|
}
|
|
208
228
|
};
|
|
209
229
|
//#endregion
|
|
210
|
-
export {
|
|
230
|
+
export { R as Main, R as default };
|