@pie-element/match-list 8.0.3-next.20261007184841 → 8.0.3

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,20 +1,20 @@
1
- import e, { useRef as t, useState as n } from "react";
2
- import r from "debug";
3
- import i from "prop-types";
4
- import { PlaceHolder as a } from "@pie-lib/drag";
5
- import { useDraggable as o, useDroppable as s } from "@dnd-kit/core";
6
- import { color as c, useMathName as l } from "@pie-lib/render-ui";
7
- import { jsx as u } from "react/jsx-runtime";
8
- import { styled as d } from "@mui/material/styles";
9
- import { isEmpty as f } from "@pie-element/shared-lodash";
10
- import { sanitizeModelHtml as p } from "@pie-element/shared-utils";
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
+ import { sanitizeModelHtml as d } from "@pie-element/shared-utils";
11
11
  //#region src/delivery/answer.tsx
12
- var m = r("pie-elements:match-title:answer"), h = c.v("pie"), g = d("div")(() => ({
12
+ var f = n("pie-elements:match-title:answer"), p = s.v("pie"), m = l("div")(() => ({
13
13
  width: "100%",
14
14
  fontSize: "18px",
15
15
  textAlign: "center",
16
16
  color: "inherit"
17
- })), _ = ({ index: e, isOver: t, disabled: n, type: r }) => /* @__PURE__ */ u(a, {
17
+ })), h = ({ index: e, isOver: t, disabled: n, type: r }) => /* @__PURE__ */ c(i, {
18
18
  extraStyles: {
19
19
  display: "flex",
20
20
  padding: "0",
@@ -25,18 +25,18 @@ var m = r("pie-elements:match-title:answer"), h = c.v("pie"), g = d("div")(() =>
25
25
  disabled: n,
26
26
  isOver: t,
27
27
  type: r,
28
- children: e !== void 0 && /* @__PURE__ */ u(g, { children: e })
28
+ children: e !== void 0 && /* @__PURE__ */ c(m, { children: e })
29
29
  });
30
- _.propTypes = {
31
- index: i.number,
32
- isOver: i.bool,
33
- disabled: i.bool,
34
- type: i.string
30
+ h.propTypes = {
31
+ index: r.number,
32
+ isOver: r.bool,
33
+ disabled: r.bool,
34
+ type: r.string
35
35
  };
36
- var v = d("div")(({ isDragging: e, isSelected: t, isOver: n, disabled: r, outcome: i }) => ({
37
- color: c.text(),
38
- backgroundColor: h("background", c.defaults.WHITE),
39
- border: `1px solid ${i === "correct" ? c.correct() : i === "incorrect" ? c.incorrect() : c.border()}`,
36
+ var g = l("div")(({ isDragging: e, isSelected: t, isOver: n, disabled: r, outcome: i }) => ({
37
+ color: s.text(),
38
+ backgroundColor: p("background", s.defaults.WHITE),
39
+ border: `1px solid ${i === "correct" ? s.correct() : i === "incorrect" ? s.incorrect() : s.border()}`,
40
40
  cursor: r ? "not-allowed" : "pointer",
41
41
  width: "100%",
42
42
  padding: "10px",
@@ -46,22 +46,22 @@ var v = d("div")(({ isDragging: e, isSelected: t, isOver: n, disabled: r, outcom
46
46
  wordBreak: "break-word",
47
47
  opacity: (e || t) && !r ? .5 : n && !r ? .2 : 1,
48
48
  touchAction: "none"
49
- })), y = (e) => {
50
- let { isDragging: t, isSelected: n, isOver: r, title: i, disabled: a, empty: o, outcome: s, guideIndex: c, type: l } = e;
51
- return o ? /* @__PURE__ */ u(_, {
52
- index: c,
49
+ })), _ = (e) => {
50
+ let { isDragging: t, isSelected: n, isOver: r, title: i, disabled: a, empty: o, outcome: s, guideIndex: l, type: u } = e;
51
+ return o ? /* @__PURE__ */ c(h, {
52
+ index: l,
53
53
  isOver: r,
54
54
  disabled: a,
55
- type: l
56
- }) : /* @__PURE__ */ u(v, {
55
+ type: u
56
+ }) : /* @__PURE__ */ c(g, {
57
57
  isDragging: t,
58
58
  isSelected: n,
59
59
  isOver: r,
60
60
  disabled: a,
61
61
  outcome: s,
62
- dangerouslySetInnerHTML: { __html: p(i) }
62
+ dangerouslySetInnerHTML: { __html: d(i) }
63
63
  });
64
- }, b = d("div")(({ correct: e, isSelected: t, isDragging: n, theme: r }) => ({
64
+ }, v = l("div")(({ correct: e, isSelected: t, isDragging: n, theme: r }) => ({
65
65
  boxSizing: "border-box",
66
66
  minHeight: 40,
67
67
  minWidth: "200px",
@@ -70,19 +70,19 @@ var v = d("div")(({ isDragging: e, isSelected: t, isOver: n, disabled: r, outcom
70
70
  padding: "0px",
71
71
  textAlign: "center",
72
72
  height: "initial",
73
- border: e === !0 ? `1px solid ${c.correct()}` : e === !1 ? `1px solid ${c.incorrect()}` : t && !n ? `2px solid ${c.buttonFocusOutline()}` : "none"
74
- })), x = class extends e.Component {
73
+ border: e === !0 ? `1px solid ${s.correct()}` : e === !1 ? `1px solid ${s.incorrect()}` : t && !n ? `2px solid ${s.buttonFocusOutline()}` : "none"
74
+ })), y = class extends e.Component {
75
75
  static propTypes = {
76
- className: i.string,
77
- isDragging: i.bool,
78
- isSelected: i.bool,
79
- id: i.any,
80
- title: i.string,
81
- isOver: i.bool,
82
- empty: i.bool,
83
- type: i.string,
84
- disabled: i.bool,
85
- correct: i.bool
76
+ className: r.string,
77
+ isDragging: r.bool,
78
+ isSelected: r.bool,
79
+ id: r.any,
80
+ title: r.string,
81
+ isOver: r.bool,
82
+ empty: r.bool,
83
+ type: r.string,
84
+ disabled: r.bool,
85
+ correct: r.bool
86
86
  };
87
87
  componentDidMount() {
88
88
  this.ref && this.ref.addEventListener("touchstart", this.handleTouchStart, { passive: !0 });
@@ -92,18 +92,18 @@ var v = d("div")(({ isDragging: e, isSelected: t, isOver: n, disabled: r, outcom
92
92
  }
93
93
  handleTouchStart = (e) => {};
94
94
  render() {
95
- let { id: e, title: t, isDragging: n = !1, isSelected: r = !1, className: i, disabled: a, isOver: o = !1, type: s, correct: c } = this.props;
96
- return m("[render], props: ", this.props), /* @__PURE__ */ u(b, {
97
- correct: c,
95
+ let { id: e, title: t, isDragging: n = !1, isSelected: r = !1, className: i, disabled: a, isOver: o = !1, type: s, correct: l } = this.props;
96
+ return f("[render], props: ", this.props), /* @__PURE__ */ c(v, {
97
+ correct: l,
98
98
  isSelected: r,
99
99
  isDragging: n,
100
100
  className: i,
101
101
  ref: (e) => this.ref = e,
102
- children: /* @__PURE__ */ u(y, {
102
+ children: /* @__PURE__ */ c(_, {
103
103
  title: t,
104
104
  id: e,
105
105
  isOver: o,
106
- empty: f(t),
106
+ empty: u(t),
107
107
  isDragging: n,
108
108
  isSelected: r,
109
109
  disabled: a,
@@ -111,113 +111,107 @@ var v = d("div")(({ isDragging: e, isSelected: t, isOver: n, disabled: r, outcom
111
111
  })
112
112
  });
113
113
  }
114
- }, S = ({ type: e, id: t, promptId: n }) => n == null ? `${e || "answer"}-${t}` : `${e || "answer"}-prompt-${n}`;
115
- function C(e) {
116
- let { id: r, instanceId: i, promptId: a, labelId: c, draggable: d = !0, disabled: f = !1, type: p, selectedAnswer: m, onSelectClick: h, onPlacementClick: g } = e, _ = S({
117
- type: p,
118
- id: r,
119
- promptId: a
120
- }), v = a == null ? void 0 : `drop-${a}`, y = {
121
- type: p || "answer",
122
- id: r,
123
- instanceId: i,
114
+ }, b = ({ type: e, id: t, promptId: n }) => n == null ? `${e || "answer"}-${t}` : `${e || "answer"}-prompt-${n}`;
115
+ function x(e) {
116
+ let { id: n, instanceId: r, promptId: i, labelId: s, draggable: l = !0, disabled: u = !1, type: d, selectedAnswer: f, onSelectClick: p, onPlacementClick: m } = e, h = b({
117
+ type: d,
118
+ id: n,
119
+ promptId: i
120
+ }), g = i == null ? void 0 : `drop-${i}`, _ = {
121
+ type: d || "answer",
122
+ id: n,
123
+ instanceId: r,
124
124
  value: e.title,
125
- promptId: a
126
- }, b = v ? {
125
+ promptId: i
126
+ }, v = g ? {
127
127
  type: "drop-zone",
128
- promptId: a,
129
- instanceId: i
130
- } : void 0, { attributes: C, listeners: w, setNodeRef: T, transform: E, transition: D, isDragging: O } = o({
131
- id: _,
132
- data: y,
133
- disabled: !d || f,
134
- attributes: { tabIndex: d && !f ? 0 : -1 }
135
- }), k = t(null), A = l(k), j = (e) => {
136
- k.current = e, T(e);
137
- }, M = s({
138
- id: v,
139
- data: b,
140
- disabled: f || !v
141
- }), N = M.setNodeRef, P = M.isOver, [F, I] = n(!1), L = !!m, R = P || L && F && !f, z = !!m && m.type === y.type && m.id === y.id && m.promptId === y.promptId, B = E ? `translate3d(${E.x}px, ${E.y}px, 0)` : void 0;
142
- if (v) {
128
+ promptId: i,
129
+ instanceId: r
130
+ } : void 0, { attributes: x, listeners: S, setNodeRef: C, transform: w, transition: T, isDragging: E } = a({
131
+ id: h,
132
+ data: _,
133
+ disabled: !l || u,
134
+ attributes: { tabIndex: l && !u ? 0 : -1 }
135
+ }), D = o({
136
+ id: g,
137
+ data: v,
138
+ disabled: u || !g
139
+ }), O = D.setNodeRef, k = D.isOver, [A, j] = t(!1), M = !!f, N = k || M && A && !u, P = !!f && f.type === _.type && f.id === _.id && f.promptId === _.promptId, F = w ? `translate3d(${w.x}px, ${w.y}px, 0)` : void 0;
140
+ if (g) {
143
141
  let t = () => {
144
- f || (z ? h?.(y) : m ? g?.(b) : d && h?.(y));
145
- }, n = !d && !f && L;
146
- return /* @__PURE__ */ u("div", {
147
- ref: N,
142
+ u || (P ? p?.(_) : f ? m?.(v) : l && p?.(_));
143
+ }, n = !l && !u && M;
144
+ return /* @__PURE__ */ c("div", {
145
+ ref: O,
148
146
  role: n ? "button" : "group",
149
- "aria-labelledby": c,
147
+ "aria-labelledby": s,
150
148
  tabIndex: n ? 0 : -1,
151
149
  onClick: t,
152
150
  onKeyDown: n ? (e) => {
153
151
  (e.code === "Space" || e.code === "Enter") && (e.preventDefault(), t());
154
152
  } : void 0,
155
- onMouseEnter: () => I(!0),
156
- onMouseLeave: () => I(!1),
153
+ onMouseEnter: () => j(!0),
154
+ onMouseLeave: () => j(!1),
157
155
  style: {
158
156
  flex: 1,
159
- opacity: O ? .5 : 1,
160
- backgroundColor: O || z || R ? "rgba(0,0,0,0.05)" : "transparent",
161
- cursor: L && !f ? "pointer" : void 0
157
+ opacity: E ? .5 : 1,
158
+ backgroundColor: E || P || N ? "rgba(0,0,0,0.05)" : "transparent",
159
+ cursor: M && !u ? "pointer" : void 0
162
160
  },
163
- children: /* @__PURE__ */ u("div", {
164
- ref: j,
165
- ...w,
166
- ...d && !f ? {
167
- ...C,
168
- "aria-label": A
169
- } : {},
170
- "data-tile-id": `${i}:${_}`,
161
+ children: /* @__PURE__ */ c("div", {
162
+ ref: C,
163
+ ...S,
164
+ ...l && !u ? x : {},
165
+ "data-tile-id": `${r}:${h}`,
171
166
  style: {
172
- transform: B,
173
- transition: D
167
+ transform: F,
168
+ transition: T
174
169
  },
175
- children: /* @__PURE__ */ u(x, {
170
+ children: /* @__PURE__ */ c(y, {
176
171
  ...e,
177
- isDragging: O,
178
- isSelected: z,
179
- isOver: R
172
+ isDragging: E,
173
+ isSelected: P,
174
+ isOver: N
180
175
  })
181
176
  })
182
177
  });
183
178
  }
184
- let V = (e) => {
185
- f || (e.stopPropagation(), h?.(y));
179
+ let I = (e) => {
180
+ u || (e.stopPropagation(), p?.(_));
186
181
  };
187
- return /* @__PURE__ */ u("div", {
188
- ref: j,
189
- ...w,
190
- ...C,
191
- "aria-label": A,
192
- "data-tile-id": `${i}:${_}`,
193
- onClick: V,
182
+ return /* @__PURE__ */ c("div", {
183
+ ref: C,
184
+ ...S,
185
+ ...x,
186
+ "data-tile-id": `${r}:${h}`,
187
+ onClick: I,
194
188
  style: {
195
- transform: B,
196
- transition: D,
197
- cursor: f ? "not-allowed" : "grab",
198
- opacity: O ? .5 : 1,
199
- touchAction: d && !f ? "none" : "auto"
189
+ transform: F,
190
+ transition: T,
191
+ cursor: u ? "not-allowed" : "grab",
192
+ opacity: E ? .5 : 1,
193
+ touchAction: l && !u ? "none" : "auto"
200
194
  },
201
- children: /* @__PURE__ */ u(x, {
195
+ children: /* @__PURE__ */ c(y, {
202
196
  ...e,
203
- isDragging: O,
204
- isSelected: z,
197
+ isDragging: E,
198
+ isSelected: P,
205
199
  isOver: !1
206
200
  })
207
201
  });
208
202
  }
209
- C.propTypes = {
210
- id: i.any,
211
- instanceId: i.string,
212
- promptId: i.any,
213
- labelId: i.string,
214
- title: i.string,
215
- draggable: i.bool,
216
- disabled: i.bool,
217
- type: i.string,
218
- selectedAnswer: i.object,
219
- onSelectClick: i.func,
220
- onPlacementClick: i.func
203
+ x.propTypes = {
204
+ id: r.any,
205
+ instanceId: r.string,
206
+ promptId: r.any,
207
+ labelId: r.string,
208
+ title: r.string,
209
+ draggable: r.bool,
210
+ disabled: r.bool,
211
+ type: r.string,
212
+ selectedAnswer: r.object,
213
+ onSelectClick: r.func,
214
+ onPlacementClick: r.func
221
215
  };
222
216
  //#endregion
223
- export { x as Answer, S as buildDragId, C as default };
217
+ export { y as Answer, b as buildDragId, x as default };