@pie-element/placement-ordering 15.0.3-next.20261007184841 → 15.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.
@@ -2,30 +2,30 @@ import e from "react";
2
2
  import t from "debug";
3
3
  import n from "prop-types";
4
4
  import { styled as r } from "@mui/material/styles";
5
- import { color as i, useMathName as a } from "@pie-lib/render-ui";
6
- import { jsx as o } from "react/jsx-runtime";
7
- import { PlaceHolder as s } from "@pie-lib/drag";
8
- import { useDraggable as c, useDroppable as l } from "@dnd-kit/core";
9
- import { sanitizeModelHtml as u } from "@pie-element/shared-utils";
5
+ import { color as i } from "@pie-lib/render-ui";
6
+ import { jsx as a } from "react/jsx-runtime";
7
+ import { PlaceHolder as o } from "@pie-lib/drag";
8
+ import { useDraggable as s, useDroppable as c } from "@dnd-kit/core";
9
+ import { sanitizeModelHtml as l } from "@pie-element/shared-utils";
10
10
  //#region src/delivery/tile.tsx
11
- var d = t("pie-elements:placement-ordering:tile"), f = r("div")(({ theme: e }) => ({
11
+ var u = t("pie-elements:placement-ordering:tile"), d = r("div")(({ theme: e }) => ({
12
12
  width: "100%",
13
13
  fontSize: e.typography.fontSize + 4,
14
14
  textAlign: "center",
15
15
  color: "inherit"
16
- })), p = ({ type: e, index: t, isOver: n, disabled: r }) => /* @__PURE__ */ o(s, {
16
+ })), f = ({ type: e, index: t, isOver: n, disabled: r }) => /* @__PURE__ */ a(o, {
17
17
  type: e,
18
18
  isOver: n,
19
19
  disabled: r,
20
- children: e === "target" && t !== void 0 && /* @__PURE__ */ o(f, { children: t })
20
+ children: e === "target" && t !== void 0 && /* @__PURE__ */ a(d, { children: t })
21
21
  });
22
- p.propTypes = {
22
+ f.propTypes = {
23
23
  type: n.string,
24
24
  index: n.number,
25
25
  isOver: n.bool,
26
26
  disabled: n.bool
27
27
  };
28
- var m = 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 }) => ({
29
29
  cursor: a ? "not-allowed" : "grab",
30
30
  width: "100%",
31
31
  height: "100%",
@@ -69,98 +69,97 @@ var m = r("div")(({ theme: e, isDragging: t, isSelected: n, isOver: r, disabled:
69
69
  border: "none",
70
70
  "&:hover": { backgroundColor: "unset" }
71
71
  }
72
- })), h = (e) => {
73
- let { type: t, isDragging: n, isSelected: r, empty: i, isOver: a, label: s, disabled: c, outcome: l, guideIndex: d } = e;
74
- return i ? /* @__PURE__ */ o(p, {
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, {
75
75
  type: t,
76
76
  index: d,
77
- isOver: a,
77
+ isOver: o,
78
78
  disabled: c
79
- }) : /* @__PURE__ */ o(m, {
79
+ }) : /* @__PURE__ */ a(p, {
80
80
  type: t,
81
81
  isDragging: n,
82
82
  isSelected: r,
83
- isOver: a,
83
+ isOver: o,
84
84
  disabled: c,
85
- outcome: l,
85
+ outcome: u,
86
86
  label: s,
87
- dangerouslySetInnerHTML: { __html: u(s) }
87
+ dangerouslySetInnerHTML: { __html: l(s) }
88
88
  });
89
- }, g = (t) => {
90
- let { label: n, type: r, id: i, empty: s, disabled: u, outcome: f, index: p, guideIndex: m, instanceId: g, draggable: _, tileIndex: v, selectedChoice: y, onChoiceClick: b, onPlacementClick: x } = t, S = `tile-${r}-${i ?? "empty"}-${v}-${g}`, C = `drop-${r}-${i ?? "empty"}-${v}-${g}`, w = {
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 = {
91
91
  id: i,
92
92
  type: r,
93
- instanceId: g,
93
+ instanceId: h,
94
94
  value: n,
95
- index: p
96
- }, { attributes: T, listeners: E, setNodeRef: D, transform: O, isDragging: k } = c({
95
+ index: f
96
+ }, { attributes: w, listeners: T, setNodeRef: E, transform: D, isDragging: O } = s({
97
+ id: x,
98
+ data: C,
99
+ disabled: !g || l
100
+ }), { setNodeRef: k, isOver: A } = c({
97
101
  id: S,
98
- data: w,
99
- disabled: !_ || u
100
- }), { setNodeRef: A, isOver: j } = l({
101
- id: C,
102
- data: w,
103
- disabled: k
104
- }), M = !!y && y.type === w.type && y.id === w.id && y.index === w.index, [N, P] = e.useState(!1), F = !!y && !u, I = j || r === "target" && F && N, L = () => {
105
- u || (r === "choice" ? y?.type === "target" ? x?.(w) : _ && b?.(w) : r === "target" && (M ? b?.(w) : y ? x?.(w) : _ && b?.(w)));
106
- }, R = _ && !u, z = !R && !u && F, B = (e) => {
107
- (e.code === "Space" || e.code === "Enter") && (e.preventDefault(), L());
108
- }, V = e.useRef(null), H = a(V);
102
+ data: C,
103
+ disabled: O
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) => {
107
+ (e.code === "Space" || e.code === "Enter") && (e.preventDefault(), I());
108
+ }, z = e.useRef(null);
109
109
  e.useEffect(() => {
110
- let e = V.current, t = (e) => {
110
+ let e = z.current, t = (e) => {
111
111
  e.preventDefault();
112
112
  };
113
113
  return e && e.addEventListener("touchstart", t, { passive: !1 }), () => {
114
114
  e && e.removeEventListener("touchstart", t);
115
115
  };
116
116
  }, []);
117
- let U = (e) => {
118
- V.current = e, D(e), A(e);
117
+ let B = (e) => {
118
+ z.current = e, E(e), k(e);
119
119
  };
120
- d("[render], props: ", t);
121
- let W = r === "target" ? `target-${p}` : r === "choice" ? `choice-${i}` : null, G = W ? `${g}:${W}` : void 0;
122
- return /* @__PURE__ */ o("div", {
123
- ref: U,
120
+ u("[render], props: ", t);
121
+ let V = r === "target" ? `target-${f}` : r === "choice" ? `choice-${i}` : null, H = V ? `${h}:${V}` : void 0;
122
+ return /* @__PURE__ */ a("div", {
123
+ ref: B,
124
124
  style: {
125
- transform: O ? `translate3d(${O.x}px, ${O.y}px, 0)` : void 0,
125
+ transform: D ? `translate3d(${D.x}px, ${D.y}px, 0)` : void 0,
126
126
  boxSizing: "border-box",
127
127
  overflow: "visible",
128
128
  padding: 0,
129
129
  margin: 0,
130
130
  textAlign: "center",
131
131
  pointerEvents: "auto",
132
- cursor: u ? "not-allowed" : r === "target" && F ? "pointer" : k ? "grabbing" : "grab",
133
- zIndex: k ? 1e3 : "auto",
134
- willChange: k ? "transform" : "auto"
132
+ cursor: l ? "not-allowed" : r === "target" && P ? "pointer" : O ? "grabbing" : "grab",
133
+ zIndex: O ? 1e3 : "auto",
134
+ willChange: O ? "transform" : "auto"
135
135
  },
136
- role: z ? "button" : void 0,
137
- tabIndex: z ? 0 : void 0,
138
- onKeyDown: z ? B : void 0,
139
- onClick: L,
140
- onMouseEnter: () => P(!0),
141
- onMouseLeave: () => P(!1),
142
- "data-tile-id": G,
143
- "aria-label": R || z ? H : void 0,
144
- ...R ? {
145
- ...E,
146
- ...T
136
+ role: L ? "button" : void 0,
137
+ tabIndex: L ? 0 : void 0,
138
+ onKeyDown: L ? R : void 0,
139
+ onClick: I,
140
+ onMouseEnter: () => N(!0),
141
+ onMouseLeave: () => N(!1),
142
+ "data-tile-id": H,
143
+ ...g && !l ? {
144
+ ...T,
145
+ ...w
147
146
  } : {},
148
- children: /* @__PURE__ */ o(h, {
147
+ children: /* @__PURE__ */ a(m, {
149
148
  label: n,
150
149
  id: i,
151
- empty: s,
152
- index: p,
153
- guideIndex: m,
154
- isOver: I,
155
- isDragging: k,
156
- isSelected: M,
157
- disabled: u,
158
- outcome: f,
150
+ empty: o,
151
+ index: f,
152
+ guideIndex: p,
153
+ isOver: F,
154
+ isDragging: O,
155
+ isSelected: j,
156
+ disabled: l,
157
+ outcome: d,
159
158
  type: r
160
159
  })
161
160
  });
162
161
  };
163
- g.propTypes = {
162
+ h.propTypes = {
164
163
  id: n.any,
165
164
  label: n.string,
166
165
  isOver: n.bool,
@@ -178,4 +177,4 @@ g.propTypes = {
178
177
  onPlacementClick: n.func
179
178
  };
180
179
  //#endregion
181
- export { g as Tile, g as default };
180
+ export { h as Tile, h as default };