@pie-element/match-list 7.1.2-next.7 → 7.1.2-next.9

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.
@@ -93,8 +93,8 @@ var d = 200, f = s("div")({
93
93
  selectedAnswer: s,
94
94
  onSelectClick: l,
95
95
  onPlacementClick: u
96
- }, v)
97
- ] }, v)) });
96
+ })
97
+ ] }, _)) });
98
98
  }
99
99
  };
100
100
  //#endregion
@@ -26,6 +26,11 @@ export declare class Answer extends React.Component {
26
26
  handleTouchStart: any;
27
27
  render(): React.JSX.Element;
28
28
  }
29
+ export declare const buildDragId: ({ type, id, promptId }: {
30
+ type: any;
31
+ id: any;
32
+ promptId: any;
33
+ }) => string;
29
34
  declare function DragAndDropAnswer(props: any): React.JSX.Element;
30
35
  declare namespace DragAndDropAnswer {
31
36
  var propTypes: {
@@ -60,16 +60,16 @@ var m = l("div")(({ isDragging: e, isSelected: t, isOver: n, disabled: r, outcom
60
60
  outcome: s,
61
61
  dangerouslySetInnerHTML: { __html: i }
62
62
  });
63
- }, g = l("div")(({ correct: e, theme: t }) => ({
63
+ }, g = l("div")(({ correct: e, isSelected: t, isDragging: n, theme: r }) => ({
64
64
  boxSizing: "border-box",
65
65
  minHeight: 40,
66
66
  minWidth: "200px",
67
67
  overflow: "hidden",
68
- margin: t.spacing(.5),
68
+ margin: r.spacing(.5),
69
69
  padding: "0px",
70
70
  textAlign: "center",
71
71
  height: "initial",
72
- border: e === !0 ? `1px solid var(--feedback-correct-bg-color, ${s.correct()})` : e === !1 ? `1px solid var(--feedback-incorrect-bg-color, ${s.incorrect()})` : "none"
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
73
  })), _ = class extends e.Component {
74
74
  static propTypes = {
75
75
  className: r.string,
@@ -94,6 +94,8 @@ var m = l("div")(({ isDragging: e, isSelected: t, isOver: n, disabled: r, outcom
94
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
95
  return d("[render], props: ", this.props), /* @__PURE__ */ c(g, {
96
96
  correct: l,
97
+ isSelected: r,
98
+ isDragging: n,
97
99
  className: i,
98
100
  ref: (e) => this.ref = e,
99
101
  children: /* @__PURE__ */ c(h, {
@@ -108,89 +110,93 @@ var m = l("div")(({ isDragging: e, isSelected: t, isOver: n, disabled: r, outcom
108
110
  })
109
111
  });
110
112
  }
111
- };
112
- function v(e) {
113
- let { id: n, instanceId: r, promptId: i, draggable: s = !0, disabled: l = !1, type: u, selectedAnswer: d, onSelectClick: f, onPlacementClick: p } = e, m = `${u || "answer"}-${n}`, h = i == null ? void 0 : `drop-${i}`, g = {
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 = {
114
120
  type: u || "answer",
115
121
  id: n,
116
122
  instanceId: r,
117
123
  value: e.title,
118
124
  promptId: i
119
- }, v = h ? {
125
+ }, y = h ? {
120
126
  type: "drop-zone",
121
127
  promptId: i,
122
128
  instanceId: r
123
- } : void 0, { attributes: y, listeners: b, setNodeRef: x, transform: S, transition: C, isDragging: w } = a({
129
+ } : void 0, { attributes: b, listeners: x, setNodeRef: S, transform: C, transition: w, isDragging: T } = a({
124
130
  id: m,
125
131
  data: g,
126
132
  disabled: !s || l,
127
133
  attributes: { tabIndex: s && !l ? 0 : -1 }
128
- }), T = o({
134
+ }), E = o({
129
135
  id: h,
130
- data: v,
136
+ data: y,
131
137
  disabled: l || !h
132
- }), E = T.setNodeRef, D = T.isOver, [O, k] = t(!1), A = !!d, j = D || A && O && !l, M = !!d && d.type === g.type && d.id === g.id && d.promptId === g.promptId, N = S ? `translate3d(${S.x}px, ${S.y}px, 0)` : void 0;
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;
133
139
  if (h) {
134
140
  let t = () => {
135
- l || (M ? f?.(g) : d ? p?.(v) : s && f?.(g));
141
+ l || (N ? f?.(g) : d ? p?.(y) : s && f?.(g));
136
142
  }, n = !s && !l;
137
143
  return /* @__PURE__ */ c("div", {
138
- ref: E,
144
+ ref: D,
139
145
  role: "button",
140
146
  tabIndex: n ? 0 : -1,
141
147
  onClick: t,
142
148
  onKeyDown: n ? (e) => {
143
149
  (e.code === "Space" || e.code === "Enter") && (e.preventDefault(), t());
144
150
  } : void 0,
145
- onMouseEnter: () => k(!0),
146
- onMouseLeave: () => k(!1),
151
+ onMouseEnter: () => A(!0),
152
+ onMouseLeave: () => A(!1),
147
153
  style: {
148
154
  flex: 1,
149
- opacity: w || M ? .5 : 1,
150
- backgroundColor: w || M || j ? "rgba(0,0,0,0.05)" : "transparent",
151
- cursor: A && !l ? "pointer" : void 0
155
+ opacity: T ? .5 : 1,
156
+ backgroundColor: T || N || M ? "rgba(0,0,0,0.05)" : "transparent",
157
+ cursor: j && !l ? "pointer" : void 0
152
158
  },
153
159
  children: /* @__PURE__ */ c("div", {
154
- ref: x,
160
+ ref: S,
161
+ ...x,
155
162
  ...b,
156
- ...y,
157
163
  style: {
158
- transform: N,
159
- transition: C
164
+ transform: P,
165
+ transition: w
160
166
  },
161
167
  children: /* @__PURE__ */ c(_, {
162
168
  ...e,
163
- isDragging: w,
164
- isSelected: M,
165
- isOver: j
169
+ isDragging: T,
170
+ isSelected: N,
171
+ isOver: M
166
172
  })
167
173
  })
168
174
  });
169
175
  }
170
- let P = (e) => {
176
+ let F = (e) => {
171
177
  l || (e.stopPropagation(), f?.(g));
172
178
  };
173
179
  return /* @__PURE__ */ c("div", {
174
- ref: x,
180
+ ref: S,
181
+ ...x,
175
182
  ...b,
176
- ...y,
177
- onClick: P,
183
+ onClick: F,
178
184
  style: {
179
- transform: N,
180
- transition: C,
185
+ transform: P,
186
+ transition: w,
181
187
  cursor: l ? "not-allowed" : "grab",
182
- opacity: w || M ? .5 : 1,
188
+ opacity: T ? .5 : 1,
183
189
  touchAction: s && !l ? "none" : "auto"
184
190
  },
185
191
  children: /* @__PURE__ */ c(_, {
186
192
  ...e,
187
- isDragging: w,
188
- isSelected: M,
193
+ isDragging: T,
194
+ isSelected: N,
189
195
  isOver: !1
190
196
  })
191
197
  });
192
198
  }
193
- v.propTypes = {
199
+ y.propTypes = {
194
200
  id: r.any,
195
201
  instanceId: r.string,
196
202
  promptId: r.any,
@@ -203,4 +209,4 @@ v.propTypes = {
203
209
  onPlacementClick: r.func
204
210
  };
205
211
  //#endregion
206
- export { _ as Answer, v as default };
212
+ export { _ as Answer, v as buildDragId, y as default };
@@ -27,19 +27,19 @@ var t = 25, n = (n, { active: i, context: a, currentCoordinates: o }) => {
27
27
  let p = i?.data?.current, m = p?.promptId == null ? void 0 : `drop-${p.promptId}`, h = [];
28
28
  for (let [e, t] of d) {
29
29
  if (t?.disabled || e === m) continue;
30
- let n = u.get(e);
30
+ let n = t?.node?.current?.getBoundingClientRect() ?? u.get(e);
31
31
  if (!n) continue;
32
32
  let r = {
33
33
  x: n.left + n.width / 2,
34
34
  y: n.top + n.height / 2
35
- }, i = {
35
+ }, i = f?.height ?? 0, a = {
36
36
  x: n.left,
37
- y: n.top + n.height / 2
37
+ y: n.top + n.height / 2 - i / 2
38
38
  };
39
39
  h.push({
40
40
  id: e,
41
41
  rect: n,
42
- dropPosition: i,
42
+ dropPosition: a,
43
43
  center: r
44
44
  });
45
45
  }
@@ -98,13 +98,10 @@ var D = E(_, "PreviewPrompt") || E(j.PreviewPrompt, "PreviewPrompt"), O = E(g, "
98
98
  if (e.type === "choice" && i !== void 0) {
99
99
  let e = S(n.value, (e) => e === s);
100
100
  e && !a ? n.value = o(n.value, e, i) : n.value[i] = s;
101
- } else if (e.type === "target" && c != null && c !== i) {
102
- let e = n.value[i] != null;
103
- if (e && !a) {
104
- let e = n.value[i];
105
- n.value[i] = s, n.value[c] = e;
106
- } else e || (n.value[i] = s, delete n.value[c]);
107
- }
101
+ } else if (e.type === "target" && c != null && c !== i) if (n.value[i] != null && !a) {
102
+ let e = n.value[i];
103
+ n.value[i] = s, n.value[c] = e;
104
+ } else n.value[i] = s, delete n.value[c];
108
105
  r(n);
109
106
  }
110
107
  };