@pie-lib/mask-markup 4.1.1-next.20261015154938 → 4.1.1-next.20261016161500
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { rectIntersection as e } from "@dnd-kit/core";
|
|
2
|
+
//#region src/collision-detection.ts
|
|
3
|
+
var t = (e) => e.data?.droppableContainer?.data?.current, n = (e) => t(e)?.toChoiceBoard === !0, r = (e, t, n) => Math.hypot(Math.max(e.left - t, 0, t - e.right), Math.max(e.top - n, 0, n - e.bottom)), i = (i) => {
|
|
4
|
+
let { collisionRect: a, droppableRects: o, pointerCoordinates: s, active: c } = i, l = e(i), u = c?.data?.current, d = u?.fromChoice === !1 ? u.id : void 0, f = (e) => d !== void 0 && t(e)?.id === d, p = l.filter((e) => !n(e) && !f(e));
|
|
5
|
+
if (p.length > 0) {
|
|
6
|
+
let e = s?.x ?? a.left + a.width / 2, t = s?.y ?? a.top + a.height / 2, n = (n) => {
|
|
7
|
+
let i = o.get(n.id);
|
|
8
|
+
return i ? r(i, e, t) : Infinity;
|
|
9
|
+
};
|
|
10
|
+
return [...p].sort((e, t) => n(e) - n(t));
|
|
11
|
+
}
|
|
12
|
+
let m = l.filter(n);
|
|
13
|
+
return m.length > 0 ? m : l;
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { i as blanksFirst };
|
|
@@ -58,7 +58,10 @@ var S = c, C = S.default, w = C && typeof C == "object" ? C : S, T = x(l, "Inlin
|
|
|
58
58
|
color: `${u.text()} !important`
|
|
59
59
|
}
|
|
60
60
|
})), k = n(T)(() => ({
|
|
61
|
-
"& .MuiPaper-root": {
|
|
61
|
+
"& .MuiPaper-root": {
|
|
62
|
+
backgroundColor: D("background", u.defaults.WHITE),
|
|
63
|
+
border: `1px solid ${u.borderGray()}`
|
|
64
|
+
},
|
|
62
65
|
"& .MuiList-root": { padding: 0 }
|
|
63
66
|
})), A = n(h)(() => ({
|
|
64
67
|
height: 24,
|
|
@@ -3,20 +3,21 @@ import t from "./choices/choice.js";
|
|
|
3
3
|
import n from "./choices/index.js";
|
|
4
4
|
import r from "./components/blank.js";
|
|
5
5
|
import { closestDroppableKeyboardCoordinates as i } from "./keyboard-coordinates.js";
|
|
6
|
-
import a from "
|
|
7
|
-
import o from "
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
6
|
+
import { blanksFirst as a } from "./collision-detection.js";
|
|
7
|
+
import o from "react";
|
|
8
|
+
import s from "prop-types";
|
|
9
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
10
|
+
import { DragProvider as u } from "@pie-lib/drag";
|
|
11
|
+
import { DragOverlay as d } from "@dnd-kit/core";
|
|
11
12
|
//#region src/drag-in-the-blank.tsx
|
|
12
13
|
var f = 250, p = e("blank", (e) => (t, n, i) => {
|
|
13
14
|
let a = t.data?.dataset || {};
|
|
14
15
|
if (a.component === "blank") {
|
|
15
|
-
let { disabled: o, duplicates:
|
|
16
|
-
return /* @__PURE__ */
|
|
16
|
+
let { disabled: o, duplicates: s, correctResponse: l, feedback: u, showCorrectAnswer: d, emptyResponseAreaWidth: f, emptyResponseAreaHeight: p, instanceId: m, isDragging: h, language: g, selectedItem: _, onSelectClick: v, onPlacementClick: y } = e, b = d ? l[a.id] : n[a.id], x = b && e.choices.find((e) => e.id === b);
|
|
17
|
+
return /* @__PURE__ */ c(r, {
|
|
17
18
|
correct: d || u && u[a.id],
|
|
18
19
|
disabled: o,
|
|
19
|
-
duplicates:
|
|
20
|
+
duplicates: s,
|
|
20
21
|
choice: x,
|
|
21
22
|
id: a.id,
|
|
22
23
|
emptyResponseAreaWidth: f,
|
|
@@ -33,7 +34,7 @@ var f = 250, p = e("blank", (e) => (t, n, i) => {
|
|
|
33
34
|
onPlacementClick: y
|
|
34
35
|
}, `${t.type}-${a.id}`);
|
|
35
36
|
}
|
|
36
|
-
}), m = class extends
|
|
37
|
+
}), m = class extends o.Component {
|
|
37
38
|
constructor(e) {
|
|
38
39
|
super(e), this.state = {
|
|
39
40
|
activeDragItem: null,
|
|
@@ -42,21 +43,21 @@ var f = 250, p = e("blank", (e) => (t, n, i) => {
|
|
|
42
43
|
}, this.lastDragEndAt = 0;
|
|
43
44
|
}
|
|
44
45
|
static propTypes = {
|
|
45
|
-
markup:
|
|
46
|
-
layout:
|
|
47
|
-
choicesPosition:
|
|
48
|
-
choices:
|
|
49
|
-
value:
|
|
50
|
-
onChange:
|
|
51
|
-
duplicates:
|
|
52
|
-
disabled:
|
|
53
|
-
feedback:
|
|
54
|
-
correctResponse:
|
|
55
|
-
showCorrectAnswer:
|
|
56
|
-
emptyResponseAreaWidth:
|
|
57
|
-
emptyResponseAreaHeight:
|
|
58
|
-
instanceId:
|
|
59
|
-
language:
|
|
46
|
+
markup: s.string,
|
|
47
|
+
layout: s.object,
|
|
48
|
+
choicesPosition: s.string,
|
|
49
|
+
choices: s.array,
|
|
50
|
+
value: s.object,
|
|
51
|
+
onChange: s.func,
|
|
52
|
+
duplicates: s.bool,
|
|
53
|
+
disabled: s.bool,
|
|
54
|
+
feedback: s.object,
|
|
55
|
+
correctResponse: s.object,
|
|
56
|
+
showCorrectAnswer: s.bool,
|
|
57
|
+
emptyResponseAreaWidth: s.oneOfType([s.string, s.number]),
|
|
58
|
+
emptyResponseAreaHeight: s.oneOfType([s.string, s.number]),
|
|
59
|
+
instanceId: s.string,
|
|
60
|
+
language: s.string
|
|
60
61
|
};
|
|
61
62
|
static defaultProps = { instanceId: "drag-in-the-blank" };
|
|
62
63
|
handleDragStart = (e) => {
|
|
@@ -69,7 +70,7 @@ var f = 250, p = e("blank", (e) => (t, n, i) => {
|
|
|
69
70
|
};
|
|
70
71
|
renderDragOverlay = () => {
|
|
71
72
|
let { activeDragItem: e } = this.state;
|
|
72
|
-
return e && e.type === "MaskBlank" ? /* @__PURE__ */
|
|
73
|
+
return e && e.type === "MaskBlank" ? /* @__PURE__ */ c(t, {
|
|
73
74
|
disabled: e.disabled,
|
|
74
75
|
choice: e.choice,
|
|
75
76
|
instanceId: e.instanceId
|
|
@@ -157,27 +158,27 @@ var f = 250, p = e("blank", (e) => (t, n, i) => {
|
|
|
157
158
|
};
|
|
158
159
|
};
|
|
159
160
|
render() {
|
|
160
|
-
let { markup: e, duplicates: t, value: r, onChange:
|
|
161
|
+
let { markup: e, duplicates: t, value: r, onChange: o, choicesPosition: s, choices: f, correctResponse: m, disabled: h, feedback: g, showCorrectAnswer: _, emptyResponseAreaWidth: v, emptyResponseAreaHeight: y, layout: b, instanceId: x, language: S } = this.props, C = s || "below", w = {
|
|
161
162
|
display: "flex",
|
|
162
163
|
minWidth: "100px",
|
|
163
164
|
...this.getPositionDirection(C)
|
|
164
165
|
};
|
|
165
|
-
return /* @__PURE__ */
|
|
166
|
+
return /* @__PURE__ */ c(u, {
|
|
166
167
|
onDragStart: this.handleDragStart,
|
|
167
168
|
onDragEnd: this.handleDragEnd,
|
|
168
169
|
onDragCancel: this.onDragCancel,
|
|
169
|
-
collisionDetection:
|
|
170
|
+
collisionDetection: a,
|
|
170
171
|
keyboardCoordinateGetter: i,
|
|
171
172
|
keyboardCodes: {
|
|
172
173
|
start: ["Space", "Enter"],
|
|
173
174
|
cancel: ["Escape"],
|
|
174
175
|
end: ["Space", "Enter"]
|
|
175
176
|
},
|
|
176
|
-
children: /* @__PURE__ */
|
|
177
|
+
children: /* @__PURE__ */ l("div", {
|
|
177
178
|
ref: (e) => this.rootRef = e,
|
|
178
179
|
style: w,
|
|
179
180
|
children: [
|
|
180
|
-
/* @__PURE__ */
|
|
181
|
+
/* @__PURE__ */ c(n, {
|
|
181
182
|
choicePosition: C,
|
|
182
183
|
choices: f,
|
|
183
184
|
value: r,
|
|
@@ -188,13 +189,13 @@ var f = 250, p = e("blank", (e) => (t, n, i) => {
|
|
|
188
189
|
onSelectClick: this.onItemClick,
|
|
189
190
|
onPlacementClick: this.onPlacementClick
|
|
190
191
|
}),
|
|
191
|
-
/* @__PURE__ */
|
|
192
|
+
/* @__PURE__ */ c(p, {
|
|
192
193
|
elementType: "drag-in-the-blank",
|
|
193
194
|
markup: e,
|
|
194
195
|
layout: b,
|
|
195
196
|
value: r,
|
|
196
197
|
choices: f,
|
|
197
|
-
onChange:
|
|
198
|
+
onChange: o,
|
|
198
199
|
disabled: h,
|
|
199
200
|
duplicates: t,
|
|
200
201
|
feedback: g,
|
|
@@ -209,7 +210,7 @@ var f = 250, p = e("blank", (e) => (t, n, i) => {
|
|
|
209
210
|
onSelectClick: this.onItemClick,
|
|
210
211
|
onPlacementClick: this.onPlacementClick
|
|
211
212
|
}),
|
|
212
|
-
/* @__PURE__ */
|
|
213
|
+
/* @__PURE__ */ c(d, {
|
|
213
214
|
style: { pointerEvents: "none" },
|
|
214
215
|
dropAnimation: this.state.dropAnimation,
|
|
215
216
|
children: this.renderDragOverlay()
|