@pie-element/match-list 7.1.2-next.1 → 7.1.2-next.11

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.
@@ -1,19 +1,19 @@
1
- import e from "react";
2
- import t from "debug";
3
- import n from "prop-types";
4
- import { PlaceHolder as r } from "@pie-lib/drag";
5
- import { useDraggable as i, useDroppable as a } from "@dnd-kit/core";
6
- import { color as o } from "@pie-lib/render-ui";
7
- import { jsx as s } from "react/jsx-runtime";
8
- import { styled as c } from "@mui/material/styles";
9
- import { isEmpty as l } from "@pie-element/shared-lodash";
1
+ import e, { useState as t } from "react";
2
+ import n from "debug";
3
+ import r from "prop-types";
4
+ import { PlaceHolder as i } from "@pie-lib/drag";
5
+ import { useDraggable as a, useDroppable as o } from "@dnd-kit/core";
6
+ import { color as s } from "@pie-lib/render-ui";
7
+ import { jsx as c } from "react/jsx-runtime";
8
+ import { styled as l } from "@mui/material/styles";
9
+ import { isEmpty as u } from "@pie-element/shared-lodash";
10
10
  //#region src/delivery/answer.tsx
11
- var u = t("pie-elements:match-title:answer"), d = c("div")(({ theme: e }) => ({
11
+ var d = n("pie-elements:match-title:answer"), f = l("div")(({ theme: e }) => ({
12
12
  width: "100%",
13
13
  fontSize: "18px",
14
14
  textAlign: "center",
15
15
  color: `rgba(${e.palette.common.black}, 0.6)`
16
- })), f = ({ index: e, isOver: t, disabled: n, type: i }) => /* @__PURE__ */ s(r, {
16
+ })), p = ({ index: e, isOver: t, disabled: n, type: r }) => /* @__PURE__ */ c(i, {
17
17
  extraStyles: {
18
18
  display: "flex",
19
19
  padding: "0",
@@ -23,19 +23,19 @@ var u = t("pie-elements:match-title:answer"), d = c("div")(({ theme: e }) => ({
23
23
  },
24
24
  disabled: n,
25
25
  isOver: t,
26
- type: i,
27
- children: e !== void 0 && /* @__PURE__ */ s(d, { children: e })
26
+ type: r,
27
+ children: e !== void 0 && /* @__PURE__ */ c(f, { children: e })
28
28
  });
29
- f.propTypes = {
30
- index: n.number,
31
- isOver: n.bool,
32
- disabled: n.bool,
33
- type: n.string
29
+ p.propTypes = {
30
+ index: r.number,
31
+ isOver: r.bool,
32
+ disabled: r.bool,
33
+ type: r.string
34
34
  };
35
- var p = c("div")(({ theme: e, isDragging: t, isOver: n, disabled: r, outcome: i }) => ({
36
- color: o.text(),
37
- backgroundColor: o.white(),
38
- border: `1px solid ${i === "correct" ? o.correct() : i === "incorrect" ? o.incorrect() : e.palette.grey[400]}`,
35
+ var m = l("div")(({ isDragging: e, isSelected: t, isOver: n, disabled: r, outcome: i }) => ({
36
+ color: s.text(),
37
+ backgroundColor: s.white(),
38
+ border: `1px solid ${i === "correct" ? s.correct() : i === "incorrect" ? s.incorrect() : s.border()}`,
39
39
  cursor: r ? "not-allowed" : "pointer",
40
40
  width: "100%",
41
41
  padding: "10px",
@@ -43,43 +43,45 @@ var p = c("div")(({ theme: e, isDragging: t, isOver: n, disabled: r, outcome: i
43
43
  overflow: "hidden",
44
44
  transition: "opacity 200ms linear",
45
45
  wordBreak: "break-word",
46
- opacity: t && !r ? .5 : n && !r ? .2 : 1,
46
+ opacity: (e || t) && !r ? .5 : n && !r ? .2 : 1,
47
47
  touchAction: "none"
48
- })), m = (e) => {
49
- let { isDragging: t, isOver: n, title: r, disabled: i, empty: a, outcome: o, guideIndex: c, type: l } = e;
50
- return a ? /* @__PURE__ */ s(f, {
51
- index: c,
52
- isOver: n,
53
- disabled: i,
54
- type: l
55
- }) : /* @__PURE__ */ s(p, {
48
+ })), h = (e) => {
49
+ let { isDragging: t, isSelected: n, isOver: r, title: i, disabled: a, empty: o, outcome: s, guideIndex: l, type: u } = e;
50
+ return o ? /* @__PURE__ */ c(p, {
51
+ index: l,
52
+ isOver: r,
53
+ disabled: a,
54
+ type: u
55
+ }) : /* @__PURE__ */ c(m, {
56
56
  isDragging: t,
57
- isOver: n,
58
- disabled: i,
59
- outcome: o,
60
- dangerouslySetInnerHTML: { __html: r }
57
+ isSelected: n,
58
+ isOver: r,
59
+ disabled: a,
60
+ outcome: s,
61
+ dangerouslySetInnerHTML: { __html: i }
61
62
  });
62
- }, h = c("div")(({ correct: e, theme: t }) => ({
63
+ }, g = l("div")(({ correct: e, isSelected: t, isDragging: n, theme: r }) => ({
63
64
  boxSizing: "border-box",
64
65
  minHeight: 40,
65
66
  minWidth: "200px",
66
67
  overflow: "hidden",
67
- margin: t.spacing(.5),
68
+ margin: r.spacing(.5),
68
69
  padding: "0px",
69
70
  textAlign: "center",
70
71
  height: "initial",
71
- border: e === !0 ? `1px solid var(--feedback-correct-bg-color, ${o.correct()})` : e === !1 ? `1px solid var(--feedback-incorrect-bg-color, ${o.incorrect()})` : "none"
72
- })), g = class extends e.Component {
72
+ border: e === !0 ? `1px solid var(--feedback-correct-bg-color, ${s.correct()})` : e === !1 ? `1px solid var(--feedback-incorrect-bg-color, ${s.incorrect()})` : t && !n ? `2px solid ${s.buttonFocusOutline()}` : "none"
73
+ })), _ = class extends e.Component {
73
74
  static propTypes = {
74
- className: n.string,
75
- isDragging: n.bool,
76
- id: n.any,
77
- title: n.string,
78
- isOver: n.bool,
79
- empty: n.bool,
80
- type: n.string,
81
- disabled: n.bool,
82
- correct: n.bool
75
+ className: r.string,
76
+ isDragging: r.bool,
77
+ isSelected: r.bool,
78
+ id: r.any,
79
+ title: r.string,
80
+ isOver: r.bool,
81
+ empty: r.bool,
82
+ type: r.string,
83
+ disabled: r.bool,
84
+ correct: r.bool
83
85
  };
84
86
  componentDidMount() {
85
87
  this.ref && this.ref.addEventListener("touchstart", this.handleTouchStart, { passive: !0 });
@@ -89,88 +91,122 @@ var p = c("div")(({ theme: e, isDragging: t, isOver: n, disabled: r, outcome: i
89
91
  }
90
92
  handleTouchStart = (e) => {};
91
93
  render() {
92
- let { id: e, title: t, isDragging: n = !1, className: r, disabled: i, isOver: a = !1, type: o, correct: c } = this.props;
93
- return u("[render], props: ", this.props), /* @__PURE__ */ s(h, {
94
- correct: c,
95
- className: r,
94
+ let { id: e, title: t, isDragging: n = !1, isSelected: r = !1, className: i, disabled: a, isOver: o = !1, type: s, correct: l } = this.props;
95
+ return d("[render], props: ", this.props), /* @__PURE__ */ c(g, {
96
+ correct: l,
97
+ isSelected: r,
98
+ isDragging: n,
99
+ className: i,
96
100
  ref: (e) => this.ref = e,
97
- children: /* @__PURE__ */ s(m, {
101
+ children: /* @__PURE__ */ c(h, {
98
102
  title: t,
99
103
  id: e,
100
- isOver: a,
101
- empty: l(t),
104
+ isOver: o,
105
+ empty: u(t),
102
106
  isDragging: n,
103
- disabled: i,
104
- type: o
107
+ isSelected: r,
108
+ disabled: a,
109
+ type: s
105
110
  })
106
111
  });
107
112
  }
108
- };
109
- function _(e) {
110
- let { id: t, instanceId: n, promptId: r, draggable: o = !0, disabled: c = !1, type: l } = e, u = `${l || "answer"}-${t}`, d = r == null ? void 0 : `drop-${r}`, { attributes: f, listeners: p, setNodeRef: m, transform: h, transition: _, isDragging: v } = i({
111
- id: u,
112
- data: {
113
- type: l || "answer",
114
- id: t,
115
- instanceId: n,
116
- value: e.title,
117
- promptId: r
118
- },
119
- disabled: !o || c
120
- }), y = a({
121
- id: d,
122
- data: d ? {
123
- type: "drop-zone",
124
- promptId: r,
125
- instanceId: n
126
- } : void 0,
127
- disabled: c || !d
128
- }), b = y.setNodeRef, x = y.isOver, S = h ? `translate3d(${h.x}px, ${h.y}px, 0)` : void 0;
129
- return d ? /* @__PURE__ */ s("div", {
130
- ref: b,
131
- style: {
132
- flex: 1,
133
- transform: S,
134
- transition: _,
135
- opacity: v ? .5 : 1,
136
- backgroundColor: x ? "rgba(0,0,0,0.05)" : "transparent"
137
- },
138
- children: /* @__PURE__ */ s("div", {
139
- ref: m,
140
- ...p,
141
- ...f,
142
- children: /* @__PURE__ */ s(g, {
143
- ...e,
144
- isDragging: v,
145
- isOver: x
113
+ }, v = ({ type: e, id: t, promptId: n }) => n == null ? `${e || "answer"}-${t}` : `${e || "answer"}-prompt-${n}`;
114
+ function y(e) {
115
+ let { id: n, instanceId: r, promptId: i, draggable: s = !0, disabled: l = !1, type: u, selectedAnswer: d, onSelectClick: f, onPlacementClick: p } = e, m = v({
116
+ type: u,
117
+ id: n,
118
+ promptId: i
119
+ }), h = i == null ? void 0 : `drop-${i}`, g = {
120
+ type: u || "answer",
121
+ id: n,
122
+ instanceId: r,
123
+ value: e.title,
124
+ promptId: i
125
+ }, y = h ? {
126
+ type: "drop-zone",
127
+ promptId: i,
128
+ instanceId: r
129
+ } : void 0, { attributes: b, listeners: x, setNodeRef: S, transform: C, transition: w, isDragging: T } = a({
130
+ id: m,
131
+ data: g,
132
+ disabled: !s || l,
133
+ attributes: { tabIndex: s && !l ? 0 : -1 }
134
+ }), E = o({
135
+ id: h,
136
+ data: y,
137
+ disabled: l || !h
138
+ }), D = E.setNodeRef, O = E.isOver, [k, A] = t(!1), j = !!d, M = O || j && k && !l, N = !!d && d.type === g.type && d.id === g.id && d.promptId === g.promptId, P = C ? `translate3d(${C.x}px, ${C.y}px, 0)` : void 0;
139
+ if (h) {
140
+ let t = () => {
141
+ l || (N ? f?.(g) : d ? p?.(y) : s && f?.(g));
142
+ }, n = !s && !l;
143
+ return /* @__PURE__ */ c("div", {
144
+ ref: D,
145
+ role: "button",
146
+ tabIndex: n ? 0 : -1,
147
+ onClick: t,
148
+ onKeyDown: n ? (e) => {
149
+ (e.code === "Space" || e.code === "Enter") && (e.preventDefault(), t());
150
+ } : void 0,
151
+ onMouseEnter: () => A(!0),
152
+ onMouseLeave: () => A(!1),
153
+ style: {
154
+ flex: 1,
155
+ opacity: T ? .5 : 1,
156
+ backgroundColor: T || N || M ? "rgba(0,0,0,0.05)" : "transparent",
157
+ cursor: j && !l ? "pointer" : void 0
158
+ },
159
+ children: /* @__PURE__ */ c("div", {
160
+ ref: S,
161
+ ...x,
162
+ ...b,
163
+ style: {
164
+ transform: P,
165
+ transition: w
166
+ },
167
+ children: /* @__PURE__ */ c(_, {
168
+ ...e,
169
+ isDragging: T,
170
+ isSelected: N,
171
+ isOver: M
172
+ })
146
173
  })
147
- })
148
- }) : /* @__PURE__ */ s("div", {
149
- ref: m,
150
- ...p,
151
- ...f,
174
+ });
175
+ }
176
+ let F = (e) => {
177
+ l || (e.stopPropagation(), f?.(g));
178
+ };
179
+ return /* @__PURE__ */ c("div", {
180
+ ref: S,
181
+ ...x,
182
+ ...b,
183
+ onClick: F,
152
184
  style: {
153
- transform: S,
154
- transition: _,
155
- cursor: c ? "not-allowed" : "grab",
156
- opacity: v ? .5 : 1,
157
- touchAction: o && !c ? "none" : "auto"
185
+ transform: P,
186
+ transition: w,
187
+ cursor: l ? "not-allowed" : "grab",
188
+ opacity: T ? .5 : 1,
189
+ touchAction: s && !l ? "none" : "auto"
158
190
  },
159
- children: /* @__PURE__ */ s(g, {
191
+ children: /* @__PURE__ */ c(_, {
160
192
  ...e,
161
- isDragging: v,
193
+ isDragging: T,
194
+ isSelected: N,
162
195
  isOver: !1
163
196
  })
164
197
  });
165
198
  }
166
- _.propTypes = {
167
- id: n.any,
168
- instanceId: n.string,
169
- promptId: n.any,
170
- title: n.string,
171
- draggable: n.bool,
172
- disabled: n.bool,
173
- type: n.string
199
+ y.propTypes = {
200
+ id: r.any,
201
+ instanceId: r.string,
202
+ promptId: r.any,
203
+ title: r.string,
204
+ draggable: r.bool,
205
+ disabled: r.bool,
206
+ type: r.string,
207
+ selectedAnswer: r.object,
208
+ onSelectClick: r.func,
209
+ onPlacementClick: r.func
174
210
  };
175
211
  //#endregion
176
- export { g as Answer, _ as default };
212
+ export { _ as Answer, v as buildDragId, y as default };
@@ -1,35 +1,36 @@
1
1
  import e from "react";
2
2
  import t from "prop-types";
3
- import { jsx as n, jsxs as r } from "react/jsx-runtime";
4
- import { styled as i } from "@mui/material/styles";
5
- import a from "@mui/icons-material/ArrowDropDown";
3
+ import { color as n } from "@pie-lib/render-ui";
4
+ import { jsx as r, jsxs as i } from "react/jsx-runtime";
5
+ import { styled as a } from "@mui/material/styles";
6
+ import o from "@mui/icons-material/ArrowDropDown";
6
7
  //#region src/delivery/arrow.tsx
7
- var o = i("div")({
8
+ var s = a("div")({
8
9
  display: "inline-block",
9
10
  position: "relative",
10
11
  width: "100%"
11
- }), s = i("span")(({ theme: e, isRight: t }) => ({
12
- backgroundColor: e.palette.grey[500],
13
- bottom: t ? 20 : 19,
12
+ }), c = a("span")(({ isRight: e }) => ({
13
+ backgroundColor: n.border(),
14
+ bottom: e ? 20 : 19,
14
15
  content: "\"\"",
15
16
  display: "block",
16
17
  height: 1,
17
18
  left: 20,
18
19
  position: "absolute",
19
20
  width: "100%"
20
- })), c = class extends e.Component {
21
+ })), l = class extends e.Component {
21
22
  static propTypes = { direction: t.string };
22
23
  render() {
23
24
  let { direction: e } = this.props;
24
- return /* @__PURE__ */ r(o, {
25
+ return /* @__PURE__ */ i(s, {
25
26
  style: e === "left" ? {} : { transform: "rotate(180deg)" },
26
- children: [/* @__PURE__ */ n(a, { style: {
27
+ children: [/* @__PURE__ */ r(o, { style: {
27
28
  transform: "rotate(90deg)",
28
- color: "#979797",
29
+ color: n.border(),
29
30
  fontSize: 40
30
- } }), /* @__PURE__ */ n(s, { isRight: e !== "left" })]
31
+ } }), /* @__PURE__ */ r(c, { isRight: e !== "left" })]
31
32
  });
32
33
  }
33
34
  };
34
35
  //#endregion
35
- export { c as default };
36
+ export { l as Arrow, l as default };
@@ -15,6 +15,9 @@ export declare class ChoicesList extends React.Component {
15
15
  model: PropTypes.Validator<object>;
16
16
  disabled: PropTypes.Validator<boolean>;
17
17
  onRemoveAnswer: PropTypes.Requireable<(...args: any[]) => any>;
18
+ selectedAnswer: PropTypes.Requireable<object>;
19
+ onChoiceClick: PropTypes.Requireable<(...args: any[]) => any>;
20
+ onPlacementClick: PropTypes.Requireable<(...args: any[]) => any>;
18
21
  };
19
22
  render(): React.JSX.Element;
20
23
  }
@@ -1,5 +1,5 @@
1
1
  import e from "./answer.js";
2
- import t from "./droppable-placeholder.js";
2
+ import { DroppablePlaceholder as t } from "./droppable-placeholder.js";
3
3
  import n from "react";
4
4
  import r from "prop-types";
5
5
  import { jsx as i } from "react/jsx-runtime";
@@ -12,24 +12,30 @@ var l = a("div")(({ theme: e }) => ({ marginBottom: e.spacing(2) })), u = class
12
12
  instanceId: r.string.isRequired,
13
13
  model: r.object.isRequired,
14
14
  disabled: r.bool.isRequired,
15
- onRemoveAnswer: r.func
15
+ onRemoveAnswer: r.func,
16
+ selectedAnswer: r.object,
17
+ onChoiceClick: r.func,
18
+ onPlacementClick: r.func
16
19
  };
17
20
  render() {
18
- let { model: n, disabled: r, session: a, instanceId: u, onRemoveAnswer: d } = this.props, { config: f } = n, { duplicates: p } = f;
21
+ let { model: n, disabled: r, session: a, instanceId: u, onRemoveAnswer: d, selectedAnswer: f, onChoiceClick: p, onPlacementClick: m } = this.props, { config: h } = n, { duplicates: g } = h;
19
22
  return /* @__PURE__ */ i(l, { children: /* @__PURE__ */ i(t, {
20
23
  id: "choices-pool",
21
24
  disabled: r,
22
25
  onRemoveAnswer: d,
23
- children: f.answers.filter((e) => p || s(a) || !a.value || c(o(a.value, (t) => t === e.id))).map((t) => /* @__PURE__ */ i(e, {
26
+ onPlacementClick: m,
27
+ children: h.answers.filter((e) => g || s(a) || !a.value || c(o(a.value, (t) => t === e.id))).map((t) => /* @__PURE__ */ i(e, {
24
28
  instanceId: u,
25
29
  draggable: !0,
26
30
  disabled: r,
27
31
  session: a,
28
32
  type: "choice",
33
+ selectedAnswer: f,
34
+ onSelectClick: p,
29
35
  ...t
30
36
  }, t.id))
31
37
  }) });
32
38
  }
33
39
  };
34
40
  //#endregion
35
- export { u as default };
41
+ export { u as ChoicesList, u as default };
@@ -8,17 +8,19 @@
8
8
  */
9
9
  import React from 'react';
10
10
  import PropTypes from 'prop-types';
11
- export declare function DroppablePlaceholder({ id, disabled, children, ...rest }: {
11
+ export declare function DroppablePlaceholder({ id, disabled, children, onPlacementClick, ...rest }: {
12
12
  [x: string]: any;
13
13
  id: any;
14
14
  disabled: any;
15
15
  children: any;
16
+ onPlacementClick: any;
16
17
  }): React.JSX.Element;
17
18
  export declare namespace DroppablePlaceholder {
18
19
  var propTypes: {
19
20
  id: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
20
21
  disabled: PropTypes.Requireable<boolean>;
21
22
  children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
23
+ onPlacementClick: PropTypes.Requireable<(...args: any[]) => any>;
22
24
  };
23
25
  }
24
26
  export default DroppablePlaceholder;
@@ -16,16 +16,19 @@ var a = i("div")(({ theme: e }) => ({
16
16
  minHeight: 50,
17
17
  transition: "background-color 200ms ease"
18
18
  }));
19
- function o({ id: e, disabled: i, children: o, ...s }) {
20
- let { setNodeRef: c, isOver: l } = n({
19
+ function o({ id: e, disabled: i, children: o, onPlacementClick: s, ...c }) {
20
+ let { setNodeRef: l, isOver: u } = n({
21
21
  id: e || "choices-pool",
22
22
  data: { type: "choices-pool" },
23
23
  disabled: i
24
24
  });
25
25
  return /* @__PURE__ */ r(a, {
26
- ref: c,
27
- style: { backgroundColor: l ? "rgba(0,0,0,0.05)" : "transparent" },
28
- ...s,
26
+ ref: l,
27
+ onClick: () => {
28
+ i || s?.({ type: "choices-pool" });
29
+ },
30
+ style: { backgroundColor: u ? "rgba(0,0,0,0.05)" : "transparent" },
31
+ ...c,
29
32
  children: /* @__PURE__ */ r(t, {
30
33
  id: e,
31
34
  disabled: i,
@@ -36,7 +39,8 @@ function o({ id: e, disabled: i, children: o, ...s }) {
36
39
  o.propTypes = {
37
40
  id: e.oneOfType([e.string, e.number]),
38
41
  disabled: e.bool,
39
- children: e.node
42
+ children: e.node,
43
+ onPlacementClick: e.func
40
44
  };
41
45
  //#endregion
42
- export { o as default };
46
+ export { o as DroppablePlaceholder, o as default };
@@ -1,4 +1,4 @@
1
- import e from "./main.js";
1
+ import { Main as e } from "./main.js";
2
2
  import t from "react";
3
3
  import { createRoot as n } from "react-dom/client";
4
4
  import r from "debug";
@@ -42,7 +42,7 @@ var o = r("pie-ui:graph-lines"), s = (e, t) => {
42
42
  });
43
43
  }
44
44
  disconnectedCallback() {
45
- this._root && this._root.unmount();
45
+ this._root &&= (this._root.unmount(), null);
46
46
  }
47
47
  };
48
48
  //#endregion
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/match-list/src/keyboard-coordinates.js
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
+ /**
10
+ * Custom keyboard coordinate getter for non-sortable drag-and-drop.
11
+ *
12
+ * Tab/Shift+Tab cycle the dragged item directly onto the next/previous droppable
13
+ * (response area or the choices pool), in DOM order, placing the dragged item's own
14
+ * top-left corner at the target's center-left point. Arrow keys are left doing plain
15
+ * free-form movement (nudging the dragged item by a fixed step, same as dnd-kit's own
16
+ * default keyboard behavior) rather than jumping between droppables — collision
17
+ * detection (rectIntersection) still picks up whatever the item ends up actually
18
+ * overlapping.
19
+ */
20
+ export declare const closestDroppableKeyboardCoordinates: (event: any, { active, context, currentCoordinates }: {
21
+ active: any;
22
+ context: any;
23
+ currentCoordinates: any;
24
+ }) => any;
@@ -0,0 +1,63 @@
1
+ import { KeyboardCode as e } from "@dnd-kit/core";
2
+ //#region src/delivery/keyboard-coordinates.ts
3
+ var t = 25, n = (n, { active: i, context: a, currentCoordinates: o }) => {
4
+ let { code: s } = n, c = s === "Tab", l = s === e.Down || s === e.Up || s === e.Left || s === e.Right;
5
+ if (!c && !l) return;
6
+ if (n.preventDefault(), l) switch (s) {
7
+ case e.Down: return {
8
+ ...o,
9
+ y: o.y + t
10
+ };
11
+ case e.Up: return {
12
+ ...o,
13
+ y: o.y - t
14
+ };
15
+ case e.Right: return {
16
+ ...o,
17
+ x: o.x + t
18
+ };
19
+ case e.Left: return {
20
+ ...o,
21
+ x: o.x - t
22
+ };
23
+ default: return o;
24
+ }
25
+ let { droppableRects: u, droppableContainers: d, collisionRect: f } = a;
26
+ if (!u || u.size === 0) return o;
27
+ let p = i?.data?.current, m = p?.promptId == null ? void 0 : `drop-${p.promptId}`, h = [];
28
+ for (let [e, t] of d) {
29
+ if (t?.disabled || e === m) continue;
30
+ let n = t?.node?.current?.getBoundingClientRect() ?? u.get(e);
31
+ if (!n) continue;
32
+ let r = {
33
+ x: n.left + n.width / 2,
34
+ y: n.top + n.height / 2
35
+ }, i = f?.height ?? 0, a = {
36
+ x: n.left,
37
+ y: n.top + n.height / 2 - i / 2
38
+ };
39
+ h.push({
40
+ id: e,
41
+ rect: n,
42
+ dropPosition: a,
43
+ center: r
44
+ });
45
+ }
46
+ if (h.length === 0) return o;
47
+ let g = n.shiftKey;
48
+ h.sort((e, t) => Math.abs(e.center.y - t.center.y) > 10 ? e.center.y - t.center.y : e.center.x - t.center.x);
49
+ let _ = f ? {
50
+ x: f.left + f.width / 2,
51
+ y: f.top + f.height / 2
52
+ } : o, v = h.findIndex((e) => _.x >= e.rect.left && _.x <= e.rect.right && _.y >= e.rect.top && _.y <= e.rect.bottom);
53
+ if (v === -1) {
54
+ let e = Infinity;
55
+ for (let t = 0; t < h.length; t++) {
56
+ let n = r(o, h[t].dropPosition);
57
+ n < e && (e = n, v = t);
58
+ }
59
+ }
60
+ return h[g ? (v - 1 + h.length) % h.length : (v + 1) % h.length].dropPosition;
61
+ }, r = (e, t) => Math.sqrt((e.x - t.x) ** 2 + (e.y - t.y) ** 2);
62
+ //#endregion
63
+ export { n as closestDroppableKeyboardCoordinates };
@@ -18,7 +18,18 @@ export declare class Main extends React.Component {
18
18
  constructor(props: any);
19
19
  onRemoveAnswer(id: any): void;
20
20
  onDragStart: any;
21
+ onDragCancel: any;
22
+ placeAnswer: any;
21
23
  onPlaceAnswer: any;
24
+ isSameAnswer: (a: any, b: any) => boolean;
25
+ selectAnswer: any;
26
+ toggleAnswerSelection: any;
27
+ cancelSelection: any;
28
+ endAnyLiveKeyboardDrag: any;
29
+ placeSelectedAnswer: any;
30
+ isClickSoonAfterDragEnd: () => boolean;
31
+ onChoiceClick: any;
32
+ onPlacementClick: any;
22
33
  toggleShowCorrect: any;
23
34
  renderDragOverlay: any;
24
35
  render(): React.JSX.Element;