@pie-element/categorize 14.0.3-next.20261007184841 → 14.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,118 +1,115 @@
1
- import e, { useRef as t } from "react";
2
- import { color as n, useMathName as r } from "@pie-lib/render-ui";
3
- import i from "prop-types";
4
- import a from "debug";
5
- import { styled as o } from "@mui/material/styles";
6
- import { useDraggable as s } from "@dnd-kit/core";
7
- import { uid as c } from "@pie-lib/drag";
8
- import { jsx as l } from "react/jsx-runtime";
9
- import u from "@mui/material/Card";
10
- import d from "@mui/material/CardContent";
11
- import { sanitizeModelHtml as f } from "@pie-element/shared-utils";
1
+ import e from "react";
2
+ import { color as t } from "@pie-lib/render-ui";
3
+ import n from "prop-types";
4
+ import r from "debug";
5
+ import { styled as i } from "@mui/material/styles";
6
+ import { useDraggable as a } from "@dnd-kit/core";
7
+ import { uid as o } from "@pie-lib/drag";
8
+ import { jsx as s } from "react/jsx-runtime";
9
+ import c from "@mui/material/Card";
10
+ import l from "@mui/material/CardContent";
11
+ import { sanitizeModelHtml as u } from "@pie-element/shared-utils";
12
12
  //#region src/delivery/categorize/choice.tsx
13
- a("@pie-ui:categorize:choice");
14
- var p = {
15
- content: i.string.isRequired,
16
- id: i.string
17
- }, m = o("div", { shouldForwardProp: (e) => ![
13
+ r("@pie-ui:categorize:choice");
14
+ var d = {
15
+ content: n.string.isRequired,
16
+ id: n.string
17
+ }, f = i("div", { shouldForwardProp: (e) => ![
18
18
  "isDragging",
19
19
  "disabled",
20
20
  "correct",
21
21
  "isSelected"
22
- ].includes(e) })(({ isDragging: e, disabled: t, correct: r, isSelected: i }) => ({
22
+ ].includes(e) })(({ isDragging: e, disabled: n, correct: r, isSelected: i }) => ({
23
23
  direction: "initial",
24
- cursor: t ? "not-allowed" : e ? "move" : "pointer",
24
+ cursor: n ? "not-allowed" : e ? "move" : "pointer",
25
25
  width: "100%",
26
26
  borderRadius: "6px",
27
- ...i && { border: `solid 2px ${n.buttonFocusOutline()}` },
28
- ...r === !0 && { border: `solid 2px ${n.correct()}` },
29
- ...r === !1 && { border: `solid 2px ${n.incorrect()}` }
30
- })), h = o(u, { shouldForwardProp: (e) => e !== "isSelected" })(({ isSelected: e }) => ({
31
- color: n.text(),
32
- backgroundColor: n.background(),
27
+ ...i && { border: `solid 2px ${t.buttonFocusOutline()}` },
28
+ ...r === !0 && { border: `solid 2px ${t.correct()}` },
29
+ ...r === !1 && { border: `solid 2px ${t.incorrect()}` }
30
+ })), p = i(c, { shouldForwardProp: (e) => e !== "isSelected" })(({ isSelected: e }) => ({
31
+ color: t.text(),
32
+ backgroundColor: t.background(),
33
33
  width: "100%",
34
34
  opacity: e ? .5 : 1
35
- })), g = o(d)(({ theme: e }) => ({
36
- color: n.text(),
37
- backgroundColor: n.v("pie")("background", n.defaults.WHITE),
35
+ })), m = i(l)(({ theme: e }) => ({
36
+ color: t.text(),
37
+ backgroundColor: t.v("pie")("background", t.defaults.WHITE),
38
38
  "&:last-child": { paddingBottom: e.spacing(2) },
39
39
  borderRadius: "4px",
40
40
  border: "1px solid",
41
41
  "& p": { margin: "0px" }
42
- })), _ = class extends e.Component {
42
+ })), h = class extends e.Component {
43
43
  static propTypes = {
44
- ...p,
45
- disabled: i.bool,
46
- correct: i.bool,
47
- isDragging: i.bool,
48
- isSelected: i.bool
44
+ ...d,
45
+ disabled: n.bool,
46
+ correct: n.bool,
47
+ isDragging: n.bool,
48
+ isSelected: n.bool
49
49
  };
50
50
  static defaultProps = {};
51
51
  render() {
52
52
  let { content: e, isDragging: t, disabled: n, correct: r, isSelected: i, showsSelectionBorder: a } = this.props;
53
- return /* @__PURE__ */ l(m, {
53
+ return /* @__PURE__ */ s(f, {
54
54
  isDragging: t,
55
55
  disabled: n,
56
56
  correct: r,
57
57
  isSelected: i,
58
- children: /* @__PURE__ */ l(h, {
58
+ children: /* @__PURE__ */ s(p, {
59
59
  isSelected: i,
60
- children: /* @__PURE__ */ l(g, { dangerouslySetInnerHTML: { __html: f(e) } })
60
+ children: /* @__PURE__ */ s(m, { dangerouslySetInnerHTML: { __html: u(e) } })
61
61
  })
62
62
  });
63
63
  }
64
- }, v = ({ id: e, content: n, disabled: i, correct: a, extraStyle: o, categoryId: c, choiceIndex: u, selectedItem: d, onSelectClick: f }) => {
65
- let p = c === void 0 ? `choice-${e}-board` : `choice-${e}-${c}-${u}`, m = {
64
+ }, g = ({ id: e, content: t, disabled: n, correct: r, extraStyle: i, categoryId: o, choiceIndex: c, selectedItem: l, onSelectClick: u }) => {
65
+ let d = o === void 0 ? `choice-${e}-board` : `choice-${e}-${o}-${c}`, f = {
66
66
  id: e,
67
- categoryId: c,
68
- choiceIndex: u,
69
- value: n,
67
+ categoryId: o,
68
+ choiceIndex: c,
69
+ value: t,
70
70
  itemType: "categorize",
71
71
  type: "choice"
72
- }, { attributes: h, listeners: g, setNodeRef: v, isDragging: y } = s({
73
- id: p,
74
- data: m,
75
- disabled: i
76
- }), b = t(null), x = r(b), S = !!d && d.id === e && d.categoryId === c && d.choiceIndex === u, C = (e) => {
77
- if (!i) {
78
- if (S) {
79
- e.stopPropagation(), f?.(m);
72
+ }, { attributes: p, listeners: m, setNodeRef: g, isDragging: _ } = a({
73
+ id: d,
74
+ data: f,
75
+ disabled: n
76
+ }), v = !!l && l.id === e && l.categoryId === o && l.choiceIndex === c, y = (e) => {
77
+ if (!n) {
78
+ if (v) {
79
+ e.stopPropagation(), u?.(f);
80
80
  return;
81
81
  }
82
- d && c !== void 0 || (e.stopPropagation(), f?.(m));
82
+ l && o !== void 0 || (e.stopPropagation(), u?.(f));
83
83
  }
84
84
  };
85
- return /* @__PURE__ */ l("div", {
86
- ref: (e) => {
87
- b.current = e, v(e);
88
- },
85
+ return /* @__PURE__ */ s("div", {
86
+ ref: g,
89
87
  style: {
90
88
  margin: "4px",
91
- ...o
89
+ ...i
92
90
  },
93
- onClick: C,
94
- ...g,
95
- ...h,
96
- "aria-label": x,
97
- children: /* @__PURE__ */ l(_, {
91
+ onClick: y,
92
+ ...m,
93
+ ...p,
94
+ children: /* @__PURE__ */ s(h, {
98
95
  id: e,
99
- content: n,
100
- disabled: i,
101
- correct: a,
102
- isDragging: y,
103
- isSelected: S
96
+ content: t,
97
+ disabled: n,
98
+ correct: r,
99
+ isDragging: _,
100
+ isSelected: v
104
101
  })
105
102
  });
106
103
  };
107
- v.propTypes = {
108
- ...p,
109
- extraStyle: i.object,
110
- categoryId: i.string,
111
- choiceIndex: i.number,
112
- onRemoveChoice: i.func,
113
- selectedItem: i.object,
114
- onSelectClick: i.func
104
+ g.propTypes = {
105
+ ...d,
106
+ extraStyle: n.object,
107
+ categoryId: n.string,
108
+ choiceIndex: n.number,
109
+ onRemoveChoice: n.func,
110
+ selectedItem: n.object,
111
+ onSelectClick: n.func
115
112
  };
116
- var y = c.withUid(v);
113
+ var _ = o.withUid(g);
117
114
  //#endregion
118
- export { p as ChoiceType, _ as Layout, y as default };
115
+ export { d as ChoiceType, h as Layout, _ as default };