@pie-element/placement-ordering 15.0.2-next.20261007003844 → 15.0.2

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.
@@ -16,18 +16,19 @@ import { jsx as w, jsxs as T } from "react/jsx-runtime";
16
16
  import E from "@pie-lib/translator";
17
17
  import D from "@pie-lib/correct-answer-toggle";
18
18
  import { DragProvider as O, createDragCollision as k } from "@pie-lib/drag";
19
+ import { sanitizeModelHtml as A } from "@pie-element/shared-utils";
19
20
  //#region src/delivery/placement-ordering.tsx
20
- function A(e) {
21
+ function j(e) {
21
22
  return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
22
23
  }
23
- function j(e, t) {
24
- return !e || A(e) ? e : A(e.default) ? e.default : t && A(e[t]) ? e[t] : t && A(e[t]?.default) ? e[t].default : e;
24
+ function M(e, t) {
25
+ return !e || j(e) ? e : j(e.default) ? e.default : t && j(e[t]) ? e[t] : t && j(e[t]?.default) ? e[t].default : e;
25
26
  }
26
- var M = j(y, "UiLayout") || j(R.UiLayout, "UiLayout"), N = j(v, "PreviewPrompt") || j(R.PreviewPrompt, "PreviewPrompt"), P = j(_, "Feedback") || j(R.Feedback, "Feedback"), F = j(g, "Collapsible") || j(R.Collapsible, "Collapsible"), I = h, L = I.default, R = L && typeof L == "object" ? L : I, z = 250, B = (e, t) => {
27
+ var N = M(y, "UiLayout") || M(z.UiLayout, "UiLayout"), P = M(v, "PreviewPrompt") || M(z.PreviewPrompt, "PreviewPrompt"), F = M(_, "Feedback") || M(z.Feedback, "Feedback"), I = M(g, "Collapsible") || M(z.Collapsible, "Collapsible"), L = h, R = L.default, z = R && typeof R == "object" ? R : L, B = 250, V = (e, t) => {
27
28
  if (!e || !t) return !1;
28
29
  let n = t.left + t.width / 2, r = t.top + t.height / 2;
29
30
  return n >= e.left && n <= e.right && r >= e.top && r <= e.bottom;
30
- }, V = (e, t, n) => {
31
+ }, ee = (e, t, n) => {
31
32
  let { initial: r, translated: i } = e || {};
32
33
  if (!r || !t || typeof n?.clientX != "number") return i;
33
34
  let a = t.x - n.clientX, o = t.y - n.clientY;
@@ -62,7 +63,7 @@ var M = j(y, "UiLayout") || j(R.UiLayout, "UiLayout"), N = j(v, "PreviewPrompt")
62
63
  display: "flex",
63
64
  justifyContent: "center",
64
65
  minWidth: "min-content"
65
- }), J = p("div")(({ theme: e }) => ({ paddingBottom: e.spacing(1) })), Y = p("div")(({ theme: e }) => ({ paddingBottom: e.spacing(2) })), X = p(D)(({ theme: e }) => ({ paddingBottom: e.spacing(1) })), Z = p(F)(({ theme: e }) => ({
66
+ }), J = p("div")(({ theme: e }) => ({ paddingBottom: e.spacing(1) })), Y = p("div")(({ theme: e }) => ({ paddingBottom: e.spacing(2) })), X = p(D)(({ theme: e }) => ({ paddingBottom: e.spacing(1) })), Z = p(I)(({ theme: e }) => ({
66
67
  marginBottom: e.spacing(2),
67
68
  alignSelf: "flex-start"
68
69
  })), Q = (e) => {
@@ -176,7 +177,7 @@ var $ = class extends o.Component {
176
177
  }
177
178
  e && r && (this.onDropChoice(r, e, i), this.focusTile(this.getDestinationSlotId(r)));
178
179
  } else if (!t && n) {
179
- let e = n.data.current, t = n.rect?.current, a = V(t, this.dragCollision.lastPointer(), r), o = B(t?.initial, a);
180
+ let e = n.data.current, t = n.rect?.current, a = ee(t, this.dragCollision.lastPointer(), r), o = V(t?.initial, a);
180
181
  e && e.type === "target" && !o && (this.onRemoveChoice(e, i), this.focusTile(this.getDestinationSlotId({
181
182
  type: "choice",
182
183
  id: e.id
@@ -223,7 +224,7 @@ var $ = class extends o.Component {
223
224
  });
224
225
  });
225
226
  };
226
- isClickSoonAfterDragEnd = () => Date.now() - this.lastDragEndAt < z;
227
+ isClickSoonAfterDragEnd = () => Date.now() - this.lastDragEndAt < B;
227
228
  onChoiceClick = (e) => {
228
229
  this.isClickSoonAfterDragEnd() || this.toggleChoiceSelection(e);
229
230
  };
@@ -234,7 +235,7 @@ var $ = class extends o.Component {
234
235
  let { model: n } = this.props, { correctResponse: r, correctness: i, extraCSSRules: a, prompt: o, rationale: s, feedback: c, config: l, note: u, showNote: d, env: f, disabled: p, teacherInstructions: h, language: g } = n, _ = r && r.length > 0, { showingCorrect: v } = this.state, y = l || {
235
236
  orientation: "vertical",
236
237
  includeTargets: !0
237
- }, { orientation: x, includeTargets: E } = y, D = x === "vertical", k = this.createOrdering(), { mode: A, role: j } = f || {}, F = D ? t : e, I = (v || A === "view" && j === "instructor") && d && u, L = s && (C(s) || S(s)), R = h && (C(h) || S(h)), z = {
238
+ }, { orientation: x, includeTargets: E } = y, D = x === "vertical", k = this.createOrdering(), { mode: j, role: M } = f || {}, I = D ? t : e, L = (v || j === "view" && M === "instructor") && d && u, R = s && (C(s) || S(s)), z = h && (C(h) || S(h)), B = {
238
239
  color: b.text(),
239
240
  backgroundColor: b.background(),
240
241
  display: "flex",
@@ -242,7 +243,7 @@ var $ = class extends o.Component {
242
243
  alignItems: "center",
243
244
  boxSizing: "border-box",
244
245
  width: "100%"
245
- }, B = E ? {
246
+ }, V = E ? {
246
247
  selectedChoice: this.state.selectedChoice,
247
248
  onChoiceClick: this.onChoiceClick,
248
249
  onPlacementClick: this.onPlacementClick
@@ -254,19 +255,19 @@ var $ = class extends o.Component {
254
255
  collisionDetection: this.dragCollision.collisionDetection,
255
256
  modifiers: [m],
256
257
  ...H(E),
257
- children: /* @__PURE__ */ w(G, { children: /* @__PURE__ */ T(M, {
258
+ children: /* @__PURE__ */ w(G, { children: /* @__PURE__ */ T(N, {
258
259
  extraCSSRules: a,
259
- style: z,
260
+ style: B,
260
261
  children: [
261
- R && /* @__PURE__ */ w(Z, {
262
+ z && /* @__PURE__ */ w(Z, {
262
263
  labels: {
263
264
  hidden: U.t("common:showTeacherInstructions", { lng: g }),
264
265
  visible: U.t("common:hideTeacherInstructions", { lng: g })
265
266
  },
266
267
  className: "collapsible",
267
- children: /* @__PURE__ */ w(N, { prompt: h })
268
+ children: /* @__PURE__ */ w(P, { prompt: h })
268
269
  }),
269
- /* @__PURE__ */ w(J, { children: /* @__PURE__ */ w(N, { prompt: o }) }),
270
+ /* @__PURE__ */ w(J, { children: /* @__PURE__ */ w(P, { prompt: o }) }),
270
271
  /* @__PURE__ */ w(X, {
271
272
  show: _,
272
273
  toggled: v,
@@ -278,24 +279,24 @@ var $ = class extends o.Component {
278
279
  choiceLabel: y.choiceLabel,
279
280
  targetLabel: y.targetLabel,
280
281
  ordering: k,
281
- tiler: F,
282
+ tiler: I,
282
283
  disabled: p,
283
284
  addGuide: y.showOrdering,
284
285
  tileSize: y.tileSize,
285
286
  includeTargets: E,
286
287
  choiceLabelEnabled: n.config && n.config.choiceLabelEnabled,
287
- ...B
288
+ ...V
288
289
  }) }) }),
289
- I && /* @__PURE__ */ w(Y, { dangerouslySetInnerHTML: { __html: u } }),
290
- L && /* @__PURE__ */ w(Z, {
290
+ L && /* @__PURE__ */ w(Y, { dangerouslySetInnerHTML: { __html: A(u) } }),
291
+ R && /* @__PURE__ */ w(Z, {
291
292
  labels: {
292
293
  hidden: U.t("common:showRationale", { lng: g }),
293
294
  visible: U.t("common:hideRationale", { lng: g })
294
295
  },
295
296
  className: "collapsible",
296
- children: /* @__PURE__ */ w(N, { prompt: s })
297
+ children: /* @__PURE__ */ w(P, { prompt: s })
297
298
  }),
298
- !v && /* @__PURE__ */ w(P, {
299
+ !v && /* @__PURE__ */ w(F, {
299
300
  correctness: i,
300
301
  feedback: c
301
302
  })
@@ -6,25 +6,26 @@ import { color as i } from "@pie-lib/render-ui";
6
6
  import { jsx as a } from "react/jsx-runtime";
7
7
  import { PlaceHolder as o } from "@pie-lib/drag";
8
8
  import { useDraggable as s, useDroppable as c } from "@dnd-kit/core";
9
+ import { sanitizeModelHtml as l } from "@pie-element/shared-utils";
9
10
  //#region src/delivery/tile.tsx
10
- var l = t("pie-elements:placement-ordering:tile"), u = r("div")(({ theme: e }) => ({
11
+ var u = t("pie-elements:placement-ordering:tile"), d = r("div")(({ theme: e }) => ({
11
12
  width: "100%",
12
13
  fontSize: e.typography.fontSize + 4,
13
14
  textAlign: "center",
14
15
  color: "inherit"
15
- })), d = ({ type: e, index: t, isOver: n, disabled: r }) => /* @__PURE__ */ a(o, {
16
+ })), f = ({ type: e, index: t, isOver: n, disabled: r }) => /* @__PURE__ */ a(o, {
16
17
  type: e,
17
18
  isOver: n,
18
19
  disabled: r,
19
- children: e === "target" && t !== void 0 && /* @__PURE__ */ a(u, { children: t })
20
+ children: e === "target" && t !== void 0 && /* @__PURE__ */ a(d, { children: t })
20
21
  });
21
- d.propTypes = {
22
+ f.propTypes = {
22
23
  type: n.string,
23
24
  index: n.number,
24
25
  isOver: n.bool,
25
26
  disabled: n.bool
26
27
  };
27
- var f = r("div")(({ theme: e, isDragging: t, isSelected: n, isOver: r, disabled: a, outcome: o, label: s, type: c }) => ({
28
+ var p = r("div")(({ theme: e, isDragging: t, isSelected: n, isOver: r, disabled: a, outcome: o, label: s, type: c }) => ({
28
29
  cursor: a ? "not-allowed" : "grab",
29
30
  width: "100%",
30
31
  height: "100%",
@@ -68,25 +69,25 @@ var f = r("div")(({ theme: e, isDragging: t, isSelected: n, isOver: r, disabled:
68
69
  border: "none",
69
70
  "&:hover": { backgroundColor: "unset" }
70
71
  }
71
- })), p = (e) => {
72
- let { type: t, isDragging: n, isSelected: r, empty: i, isOver: o, label: s, disabled: c, outcome: l, guideIndex: u } = e;
73
- return i ? /* @__PURE__ */ a(d, {
72
+ })), m = (e) => {
73
+ let { type: t, isDragging: n, isSelected: r, empty: i, isOver: o, label: s, disabled: c, outcome: u, guideIndex: d } = e;
74
+ return i ? /* @__PURE__ */ a(f, {
74
75
  type: t,
75
- index: u,
76
+ index: d,
76
77
  isOver: o,
77
78
  disabled: c
78
- }) : /* @__PURE__ */ a(f, {
79
+ }) : /* @__PURE__ */ a(p, {
79
80
  type: t,
80
81
  isDragging: n,
81
82
  isSelected: r,
82
83
  isOver: o,
83
84
  disabled: c,
84
- outcome: l,
85
+ outcome: u,
85
86
  label: s,
86
- dangerouslySetInnerHTML: { __html: s }
87
+ dangerouslySetInnerHTML: { __html: l(s) }
87
88
  });
88
- }, m = (t) => {
89
- let { label: n, type: r, id: i, empty: o, disabled: u, outcome: d, index: f, guideIndex: m, instanceId: h, draggable: g, tileIndex: _, selectedChoice: v, onChoiceClick: y, onPlacementClick: b } = t, x = `tile-${r}-${i ?? "empty"}-${_}-${h}`, S = `drop-${r}-${i ?? "empty"}-${_}-${h}`, C = {
89
+ }, h = (t) => {
90
+ let { label: n, type: r, id: i, empty: o, disabled: l, outcome: d, index: f, guideIndex: p, instanceId: h, draggable: g, tileIndex: _, selectedChoice: v, onChoiceClick: y, onPlacementClick: b } = t, x = `tile-${r}-${i ?? "empty"}-${_}-${h}`, S = `drop-${r}-${i ?? "empty"}-${_}-${h}`, C = {
90
91
  id: i,
91
92
  type: r,
92
93
  instanceId: h,
@@ -95,14 +96,14 @@ var f = r("div")(({ theme: e, isDragging: t, isSelected: n, isOver: r, disabled:
95
96
  }, { attributes: w, listeners: T, setNodeRef: E, transform: D, isDragging: O } = s({
96
97
  id: x,
97
98
  data: C,
98
- disabled: !g || u
99
+ disabled: !g || l
99
100
  }), { setNodeRef: k, isOver: A } = c({
100
101
  id: S,
101
102
  data: C,
102
103
  disabled: O
103
- }), j = !!v && v.type === C.type && v.id === C.id && v.index === C.index, [M, N] = e.useState(!1), P = !!v && !u, F = A || r === "target" && P && M, I = () => {
104
- u || (r === "choice" ? v?.type === "target" ? b?.(C) : g && y?.(C) : r === "target" && (j ? y?.(C) : v ? b?.(C) : g && y?.(C)));
105
- }, L = !(g && !u) && !u && P, R = (e) => {
104
+ }), j = !!v && v.type === C.type && v.id === C.id && v.index === C.index, [M, N] = e.useState(!1), P = !!v && !l, F = A || r === "target" && P && M, I = () => {
105
+ l || (r === "choice" ? v?.type === "target" ? b?.(C) : g && y?.(C) : r === "target" && (j ? y?.(C) : v ? b?.(C) : g && y?.(C)));
106
+ }, L = !(g && !l) && !l && P, R = (e) => {
106
107
  (e.code === "Space" || e.code === "Enter") && (e.preventDefault(), I());
107
108
  }, z = e.useRef(null);
108
109
  e.useEffect(() => {
@@ -116,7 +117,7 @@ var f = r("div")(({ theme: e, isDragging: t, isSelected: n, isOver: r, disabled:
116
117
  let B = (e) => {
117
118
  z.current = e, E(e), k(e);
118
119
  };
119
- l("[render], props: ", t);
120
+ u("[render], props: ", t);
120
121
  let V = r === "target" ? `target-${f}` : r === "choice" ? `choice-${i}` : null, H = V ? `${h}:${V}` : void 0;
121
122
  return /* @__PURE__ */ a("div", {
122
123
  ref: B,
@@ -128,7 +129,7 @@ var f = r("div")(({ theme: e, isDragging: t, isSelected: n, isOver: r, disabled:
128
129
  margin: 0,
129
130
  textAlign: "center",
130
131
  pointerEvents: "auto",
131
- cursor: u ? "not-allowed" : r === "target" && P ? "pointer" : O ? "grabbing" : "grab",
132
+ cursor: l ? "not-allowed" : r === "target" && P ? "pointer" : O ? "grabbing" : "grab",
132
133
  zIndex: O ? 1e3 : "auto",
133
134
  willChange: O ? "transform" : "auto"
134
135
  },
@@ -139,26 +140,26 @@ var f = r("div")(({ theme: e, isDragging: t, isSelected: n, isOver: r, disabled:
139
140
  onMouseEnter: () => N(!0),
140
141
  onMouseLeave: () => N(!1),
141
142
  "data-tile-id": H,
142
- ...g && !u ? {
143
+ ...g && !l ? {
143
144
  ...T,
144
145
  ...w
145
146
  } : {},
146
- children: /* @__PURE__ */ a(p, {
147
+ children: /* @__PURE__ */ a(m, {
147
148
  label: n,
148
149
  id: i,
149
150
  empty: o,
150
151
  index: f,
151
- guideIndex: m,
152
+ guideIndex: p,
152
153
  isOver: F,
153
154
  isDragging: O,
154
155
  isSelected: j,
155
- disabled: u,
156
+ disabled: l,
156
157
  outcome: d,
157
158
  type: r
158
159
  })
159
160
  });
160
161
  };
161
- m.propTypes = {
162
+ h.propTypes = {
162
163
  id: n.any,
163
164
  label: n.string,
164
165
  isOver: n.bool,
@@ -176,4 +177,4 @@ m.propTypes = {
176
177
  onPlacementClick: n.func
177
178
  };
178
179
  //#endregion
179
- export { m as Tile, m as default };
180
+ export { h as Tile, h as default };
@@ -3,8 +3,9 @@ import t, { createElement as n } from "react";
3
3
  import r from "prop-types";
4
4
  import { styled as i } from "@mui/material/styles";
5
5
  import { jsx as a, jsxs as o } from "react/jsx-runtime";
6
+ import { sanitizeModelHtml as s } from "@pie-element/shared-utils";
6
7
  //#region src/delivery/tiler.tsx
7
- var s = {
8
+ var c = {
8
9
  choiceLabel: r.string,
9
10
  targetLabel: r.string,
10
11
  disabled: r.bool,
@@ -14,11 +15,11 @@ var s = {
14
15
  selectedChoice: r.object,
15
16
  onChoiceClick: r.func,
16
17
  onPlacementClick: r.func
17
- }, c = {
18
+ }, l = {
18
19
  tileSize: "1fr",
19
20
  disabled: !1,
20
21
  addGuide: !1
21
- }, l = (t) => {
22
+ }, u = (t) => {
22
23
  let r = (r, i) => (r.instanceId = t.instanceId, r.disabled = t.disabled, r.guideIndex = t.addGuide ? r.index + 1 : void 0, r.tileIndex = i, r.selectedChoice = t.selectedChoice, r.onChoiceClick = t.onChoiceClick, r.onPlacementClick = t.onPlacementClick, t.includeTargets || r.type === "choice" ? /* @__PURE__ */ n(e, {
23
24
  ...r,
24
25
  key: i
@@ -27,66 +28,66 @@ var s = {
27
28
  label: "",
28
29
  key: i
29
30
  }));
30
- return r.propTypes = { ...s }, r;
31
- }, u = i("div")(({ theme: e, includeTargets: t }) => ({
31
+ return r.propTypes = { ...c }, r;
32
+ }, d = i("div")(({ theme: e, includeTargets: t }) => ({
32
33
  display: "grid",
33
34
  paddingBottom: e.spacing(2),
34
35
  ...t && { gridGap: "10px" }
35
- })), d = i("div")({ textAlign: "center" }), f = i("div")({
36
+ })), f = i("div")({ textAlign: "center" }), p = i("div")({
36
37
  textAlign: "center",
37
38
  gridRow: "3/4"
38
- }), p = i("div")(({ includeTargets: e }) => ({
39
+ }), m = i("div")(({ includeTargets: e }) => ({
39
40
  gridAutoFlow: "column",
40
41
  display: "grid",
41
42
  ...e && { gridGap: "10px" }
42
- })), m = i("div")({
43
+ })), h = i("div")({
43
44
  gridColumn: "1/2",
44
45
  textAlign: "center"
45
- }), h = i("div")({
46
+ }), g = i("div")({
46
47
  gridColumn: "2/3",
47
48
  textAlign: "center"
48
- }), g = class extends t.Component {
49
- static propTypes = { ...s };
50
- static defaultProps = { ...c };
49
+ }), _ = class extends t.Component {
50
+ static propTypes = { ...c };
51
+ static defaultProps = { ...l };
51
52
  render() {
52
- let { includeTargets: e, choiceLabelEnabled: t, choiceLabel: n, targetLabel: r, tiles: i, tileSize: s } = this.props, c = e ? `auto ${s} auto ${s}` : `auto ${s} auto`, p = e ? i.length / 2 : i.length, m = {
53
- gridTemplateColumns: e ? `repeat(${p}, ${s})` : `auto repeat(${Math.floor(p / 2) - 1}, ${s} 10px) ${s} auto`,
54
- gridTemplateRows: c
55
- }, h = { gridColumn: `1/${p + 1}` };
56
- return /* @__PURE__ */ o(u, {
53
+ let { includeTargets: e, choiceLabelEnabled: t, choiceLabel: n, targetLabel: r, tiles: i, tileSize: c } = this.props, l = e ? `auto ${c} auto ${c}` : `auto ${c} auto`, m = e ? i.length / 2 : i.length, h = {
54
+ gridTemplateColumns: e ? `repeat(${m}, ${c})` : `auto repeat(${Math.floor(m / 2) - 1}, ${c} 10px) ${c} auto`,
55
+ gridTemplateRows: l
56
+ }, g = { gridColumn: `1/${m + 1}` };
57
+ return /* @__PURE__ */ o(d, {
57
58
  includeTargets: e,
58
- style: m,
59
+ style: h,
59
60
  children: [
60
- /* @__PURE__ */ a(d, {
61
- style: h,
62
- dangerouslySetInnerHTML: { __html: t ? n : "" }
61
+ /* @__PURE__ */ a(f, {
62
+ style: g,
63
+ dangerouslySetInnerHTML: { __html: s(t ? n : "") }
63
64
  }),
64
- e && /* @__PURE__ */ a(f, {
65
- style: h,
66
- dangerouslySetInnerHTML: { __html: r }
65
+ e && /* @__PURE__ */ a(p, {
66
+ style: g,
67
+ dangerouslySetInnerHTML: { __html: s(r) }
67
68
  }),
68
- i.map(l(this.props))
69
+ i.map(u(this.props))
69
70
  ]
70
71
  });
71
72
  }
72
- }, _ = class extends t.Component {
73
- static propTypes = { ...s };
74
- static defaultProps = { ...c };
73
+ }, v = class extends t.Component {
74
+ static propTypes = { ...c };
75
+ static defaultProps = { ...l };
75
76
  render() {
76
- let { includeTargets: e, choiceLabelEnabled: t, choiceLabel: n, targetLabel: r, tiles: i, tileSize: s } = this.props, c = e ? 2 : 1, u = e ? i.length / 2 : i.length;
77
- return /* @__PURE__ */ o(p, {
77
+ let { includeTargets: e, choiceLabelEnabled: t, choiceLabel: n, targetLabel: r, tiles: i, tileSize: c } = this.props, l = e ? 2 : 1, d = e ? i.length / 2 : i.length;
78
+ return /* @__PURE__ */ o(m, {
78
79
  includeTargets: e,
79
80
  style: {
80
- gridTemplateColumns: `repeat(${c}, ${s})`,
81
- gridTemplateRows: e ? `auto repeat(${u}, ${s})` : `auto auto repeat(${Math.floor(u / 2) - 1}, ${s} 10px) ${s} auto`
81
+ gridTemplateColumns: `repeat(${l}, ${c})`,
82
+ gridTemplateRows: e ? `auto repeat(${d}, ${c})` : `auto auto repeat(${Math.floor(d / 2) - 1}, ${c} 10px) ${c} auto`
82
83
  },
83
84
  children: [
84
- /* @__PURE__ */ a(m, { dangerouslySetInnerHTML: { __html: t ? n : "" } }),
85
- e && /* @__PURE__ */ a(h, { dangerouslySetInnerHTML: { __html: r } }),
86
- i.map(l(this.props))
85
+ /* @__PURE__ */ a(h, { dangerouslySetInnerHTML: { __html: s(t ? n : "") } }),
86
+ e && /* @__PURE__ */ a(g, { dangerouslySetInnerHTML: { __html: s(r) } }),
87
+ i.map(u(this.props))
87
88
  ]
88
89
  });
89
90
  }
90
91
  };
91
92
  //#endregion
92
- export { g as HorizontalTiler, _ as VerticalTiler };
93
+ export { _ as HorizontalTiler, v as VerticalTiler };