@pie-element/match 12.1.2-next.5 → 12.1.2-next.6

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.
@@ -21,4 +21,4 @@ var s = i(a)({
21
21
  }
22
22
  };
23
23
  //#endregion
24
- export { l as default };
24
+ export { l as AddRowButton, l as default };
@@ -1,31 +1,32 @@
1
1
  import { getPluginProps as e } from "./utils.js";
2
- import t from "../node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js";
3
- import n from "./add-row.js";
2
+ import { clsx as t } from "../node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js";
3
+ import { AddRowButton as n } from "./add-row.js";
4
4
  import r from "./row.js";
5
5
  import * as i from "react";
6
6
  import a from "prop-types";
7
- import { jsx as o, jsxs as s } from "react/jsx-runtime";
8
- import c from "@mui/material/Typography";
9
- import { styled as l } from "@mui/material/styles";
10
- import { set as u } from "@pie-element/shared-lodash";
11
- import d from "debug";
12
- import f, { DEFAULT_PLUGINS as p } from "@pie-lib/editable-html-tip-tap";
13
- import { DragProvider as m } from "@pie-lib/drag";
7
+ import { color as o } from "@pie-lib/render-ui";
8
+ import { jsx as s, jsxs as c } from "react/jsx-runtime";
9
+ import l from "@mui/material/Typography";
10
+ import { styled as u } from "@mui/material/styles";
11
+ import { set as d } from "@pie-element/shared-lodash";
12
+ import f from "debug";
13
+ import p, { DEFAULT_PLUGINS as m } from "@pie-lib/editable-html-tip-tap";
14
+ import { DragProvider as h } from "@pie-lib/drag";
14
15
  //#region src/author/answer-config-block.tsx
15
- var h = d("pie-elements:match:configure"), g = l("div")(({ theme: e }) => ({
16
+ var g = f("pie-elements:match:configure"), _ = u("div")(({ theme: e }) => ({
16
17
  marginBottom: e.spacing(2.5),
17
18
  display: "flex",
18
19
  flexDirection: "column"
19
- })), _ = l("div")(({ theme: e }) => ({
20
+ })), v = u("div")(({ theme: e }) => ({
20
21
  display: "flex",
21
22
  alignItems: "center",
22
23
  flex: 1,
23
24
  width: "100%",
24
- borderBottom: `2px solid ${e.palette.grey.A100}`,
25
+ borderBottom: `2px solid ${o.border()}`,
25
26
  paddingBottom: e.spacing(2),
26
27
  marginTop: e.spacing(2),
27
28
  marginBottom: e.spacing(1)
28
- })), v = l("div")(({ theme: e }) => ({
29
+ })), y = u("div")(({ theme: e }) => ({
29
30
  flex: 1,
30
31
  display: "flex",
31
32
  justifyContent: "center",
@@ -36,26 +37,26 @@ var h = d("pie-elements:match:configure"), g = l("div")(({ theme: e }) => ({
36
37
  padding: `0 ${e.spacing(1)}`,
37
38
  textAlign: "center"
38
39
  }
39
- })), y = l("div")(({ theme: e }) => ({
40
+ })), b = u("div")(({ theme: e }) => ({
40
41
  flex: .5,
41
42
  minWidth: "45px",
42
43
  padding: `0 ${e.spacing(1)}`
43
- })), b = l("div")({
44
+ })), x = u("div")({
44
45
  display: "flex",
45
46
  flexDirection: "column"
46
- }), x = l("div")(({ theme: e }) => ({
47
+ }), S = u("div")(({ theme: e }) => ({
47
48
  fontSize: e.typography.fontSize - 2,
48
49
  color: e.palette.error.main,
49
50
  paddingTop: `${e.spacing(1)} !important`,
50
51
  width: "fit-content !important"
51
- })), S = l("div")(({ theme: e }) => ({
52
+ })), C = u("div")(({ theme: e }) => ({
52
53
  fontSize: e.typography.fontSize - 2,
53
54
  color: e.palette.error.main,
54
55
  paddingBottom: e.spacing(1)
55
- })), C = l("div")(({ theme: e }) => ({
56
+ })), w = u("div")(({ theme: e }) => ({
56
57
  "& .marginBottom": { marginBottom: e.typography.fontSize - 2 + e.spacing(1) },
57
58
  "& .headerInput": { "& > div": { fontWeight: "bold" } }
58
- })), w = class extends i.Component {
59
+ })), T = class extends i.Component {
59
60
  static propTypes = {
60
61
  model: a.object.isRequired,
61
62
  configuration: a.object.isRequired,
@@ -79,7 +80,7 @@ var h = d("pie-elements:match:configure"), g = l("div")(({ theme: e }) => ({
79
80
  let r = t.data.current, i = n.data.current;
80
81
  if (r?.type === "row" && i?.type === "row") {
81
82
  let e = r.index, t = i.index, { model: n, onChange: a } = this.props, o = { ...n }, s = o.rows || [];
82
- h("[moveRow]: ", e, t);
83
+ g("[moveRow]: ", e, t);
83
84
  let { movedRow: c, remainingRows: l } = s.reduce((t, n, r) => (r === e ? t.movedRow = n : t.remainingRows.push(n), t), {
84
85
  movedRow: null,
85
86
  remainingRows: []
@@ -88,12 +89,12 @@ var h = d("pie-elements:match:configure"), g = l("div")(({ theme: e }) => ({
88
89
  c,
89
90
  ...l.slice(t)
90
91
  ];
91
- h("update: ", u), o.rows = u, a(o);
92
+ g("update: ", u), o.rows = u, a(o);
92
93
  }
93
94
  };
94
95
  onChange = (e, t) => ({ target: n }) => {
95
96
  let { model: r, onChange: i } = this.props, a;
96
- a = t ? n.checked : n.value, u(r, e, a), i(r, e);
97
+ a = t ? n.checked : n.value, d(r, e, a), i(r, e);
97
98
  };
98
99
  onHeaderChange = (e) => (t) => {
99
100
  let { model: n, onChange: r } = this.props, i = { ...n };
@@ -104,20 +105,20 @@ var h = d("pie-elements:match:configure"), g = l("div")(({ theme: e }) => ({
104
105
  i.headers[e] = t, r(i);
105
106
  };
106
107
  render() {
107
- let { model: i, onAddRow: a, imageSupport: l, configuration: u, toolbarOpts: d, spellCheck: h, uploadSoundSupport: w } = this.props, { baseInputConfiguration: T = {}, headers: E = {}, rows: D = {}, maxImageWidth: O = {}, maxImageHeight: k = {}, mathMlOptions: A = {}, minQuestions: j } = u || {}, { errors: M } = i || {}, { correctResponseError: N, rowsErrors: P, columnsErrors: F, noOfRowsError: I, columnsLengthError: L } = M || {}, R = (p || []).filter((e) => e !== "table" && e !== "bulleted-list" && e !== "numbered-list"), z = O && O.prompt, B = k && k.prompt;
108
- return /* @__PURE__ */ o(C, { children: /* @__PURE__ */ o(m, {
108
+ let { model: i, onAddRow: a, imageSupport: o, configuration: u, toolbarOpts: d, spellCheck: f, uploadSoundSupport: g } = this.props, { baseInputConfiguration: T = {}, headers: E = {}, rows: D = {}, maxImageWidth: O = {}, maxImageHeight: k = {}, mathMlOptions: A = {}, minQuestions: j } = u || {}, { errors: M } = i || {}, { correctResponseError: N, rowsErrors: P, columnsErrors: F, noOfRowsError: I, columnsLengthError: L } = M || {}, R = (m || []).filter((e) => e !== "table" && e !== "bulleted-list" && e !== "numbered-list"), z = O && O.prompt, B = k && k.prompt;
109
+ return /* @__PURE__ */ s(w, { children: /* @__PURE__ */ s(h, {
109
110
  onDragEnd: this.moveRow,
110
- children: /* @__PURE__ */ s(g, { children: [/* @__PURE__ */ o(c, {
111
+ children: /* @__PURE__ */ c(_, { children: [/* @__PURE__ */ s(l, {
111
112
  type: "body1",
112
113
  component: "div",
113
114
  children: "Click on the labels to edit or remove. Set the correct answers by clicking each correct answer per row."
114
- }), /* @__PURE__ */ s(b, {
115
+ }), /* @__PURE__ */ c(x, {
115
116
  style: u.width ? {
116
117
  width: u.width,
117
118
  overflow: "scroll"
118
119
  } : {},
119
120
  children: [
120
- /* @__PURE__ */ s(_, { children: [E.settings && (i.headers || []).map((n, r) => /* @__PURE__ */ s(v, {
121
+ /* @__PURE__ */ c(v, { children: [E.settings && (i.headers || []).map((n, r) => /* @__PURE__ */ c(y, {
121
122
  className: t({ questionText: r === 0 }),
122
123
  sx: r === 0 ? {
123
124
  flex: 2,
@@ -132,7 +133,7 @@ var h = d("pie-elements:match:configure"), g = l("div")(({ theme: e }) => ({
132
133
  minWidth: "200px"
133
134
  }
134
135
  } : {},
135
- children: [/* @__PURE__ */ o(f, {
136
+ children: [/* @__PURE__ */ s(p, {
136
137
  onChange: this.onHeaderChange(r),
137
138
  markup: n,
138
139
  className: F && !F[r] ? "marginBottom" : "headerInput",
@@ -140,37 +141,37 @@ var h = d("pie-elements:match:configure"), g = l("div")(({ theme: e }) => ({
140
141
  activePlugins: R,
141
142
  pluginProps: e(E?.inputConfiguration, T),
142
143
  autoWidthToolbar: !0,
143
- spellCheck: h,
144
- uploadSoundSupport: w,
144
+ spellCheck: f,
145
+ uploadSoundSupport: g,
145
146
  languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
146
147
  error: F && F[r]
147
- }), F && F[r] && /* @__PURE__ */ o(x, { children: F[r] })]
148
- }, r)), /* @__PURE__ */ o(y, {})] }),
149
- i.rows.map((t, n) => /* @__PURE__ */ o(r, {
148
+ }), F && F[r] && /* @__PURE__ */ s(S, { children: F[r] })]
149
+ }, r)), /* @__PURE__ */ s(b, {})] }),
150
+ i.rows.map((t, n) => /* @__PURE__ */ s(r, {
150
151
  model: i,
151
152
  row: t,
152
153
  idx: n,
153
154
  onDeleteRow: this.props.onDeleteRow,
154
155
  onChange: this.props.onChange,
155
- imageSupport: l,
156
+ imageSupport: o,
156
157
  toolbarOpts: d,
157
- spellCheck: h,
158
+ spellCheck: f,
158
159
  error: P?.[t.id],
159
160
  maxImageWidth: O && O.rowTitles || z,
160
161
  maxImageHeight: k && k.rowTitles || B,
161
- uploadSoundSupport: w,
162
+ uploadSoundSupport: g,
162
163
  mathMlOptions: A,
163
164
  minQuestions: j,
164
165
  inputConfiguration: e(D?.inputConfiguration, T)
165
166
  }, n)),
166
- N && /* @__PURE__ */ o(S, { children: N }),
167
- I && /* @__PURE__ */ o(S, { children: I }),
168
- L && /* @__PURE__ */ o(S, { children: L }),
169
- /* @__PURE__ */ o(n, { onAddClick: a })
167
+ N && /* @__PURE__ */ s(C, { children: N }),
168
+ I && /* @__PURE__ */ s(C, { children: I }),
169
+ L && /* @__PURE__ */ s(C, { children: L }),
170
+ /* @__PURE__ */ s(n, { onAddClick: a })
170
171
  ]
171
172
  })] })
172
173
  }) });
173
174
  }
174
175
  };
175
176
  //#endregion
176
- export { w as default };
177
+ export { T as default };
@@ -40,5 +40,6 @@ export default class MatchConfigure extends HTMLElement {
40
40
  insertSound(handler: any): void;
41
41
  onDeleteSound(src: any, done: any): void;
42
42
  _render(): void;
43
+ connectedCallback(): void;
43
44
  disconnectedCallback(): void;
44
45
  }
@@ -68,8 +68,11 @@ var p = s("pie-elements:match:configure"), m = class s extends HTMLElement {
68
68
  this._root ||= r(this), this._root.render(t);
69
69
  }
70
70
  }
71
+ connectedCallback() {
72
+ this._render();
73
+ }
71
74
  disconnectedCallback() {
72
- this._root && this._root.unmount();
75
+ this._root &&= (this._root.unmount(), null);
73
76
  }
74
77
  };
75
78
  //#endregion
@@ -13,28 +13,28 @@ import m from "@mui/icons-material/Delete";
13
13
  import { useDraggable as h, useDroppable as g } from "@dnd-kit/core";
14
14
  //#region src/author/row.tsx
15
15
  s("@pie-element:categorize:configure:choice");
16
- var _ = o("span")({ cursor: "move" }), v = o("div")(({ theme: e }) => ({
16
+ var _ = !1, v = o("span")({ cursor: "move" }), y = o("div")(({ theme: e }) => ({
17
17
  marginTop: e.spacing(2),
18
18
  display: "flex",
19
19
  alignItems: "center",
20
20
  flex: 1
21
- })), y = o("div")(({ theme: e }) => ({
21
+ })), b = o("div")(({ theme: e }) => ({
22
22
  flex: 1,
23
23
  display: "flex",
24
24
  justifyContent: "center",
25
25
  alignItems: "center",
26
26
  minWidth: "120px",
27
27
  padding: `0 ${e.spacing(1)}`
28
- })), b = o(a)(({ theme: e, error: t }) => ({
28
+ })), x = o(a)(({ theme: e, error: t }) => ({
29
29
  "& input": { width: "100% !important" },
30
30
  "&.MuiRadio-root": { color: `${t ? e.palette.error.main : n.tertiary()} !important` }
31
- })), x = o("div")(({ theme: e }) => ({
31
+ })), S = o("div")(({ theme: e }) => ({
32
32
  flex: .5,
33
33
  display: "flex",
34
34
  justifyContent: "center",
35
35
  minWidth: "45px",
36
36
  padding: `0 ${e.spacing(1)}`
37
- })), S = o(y)(({ theme: e }) => ({
37
+ })), C = o(b)(({ theme: e }) => ({
38
38
  flex: 2,
39
39
  display: "flex",
40
40
  justifyContent: "flex-start",
@@ -44,16 +44,16 @@ var _ = o("span")({ cursor: "move" }), v = o("div")(({ theme: e }) => ({
44
44
  minWidth: "200px",
45
45
  marginRight: e.spacing(1),
46
46
  "&> div": { width: "100%" }
47
- })), C = o("hr")(({ theme: e }) => ({
47
+ })), w = o("hr")(({ theme: e }) => ({
48
48
  marginTop: e.spacing(2),
49
49
  border: 0,
50
- borderTop: `2px solid ${e.palette.grey.A100}`,
50
+ borderTop: `2px solid ${n.border()}`,
51
51
  width: "100%"
52
- })), w = o("div")(({ theme: e }) => ({
52
+ })), T = o("div")(({ theme: e }) => ({
53
53
  fontSize: e.typography.fontSize - 2,
54
54
  color: e.palette.error.main,
55
55
  paddingTop: e.spacing(1)
56
- })), T = class extends e.Component {
56
+ })), E = class extends e.Component {
57
57
  static propTypes = {
58
58
  model: t.object.isRequired,
59
59
  row: t.object.isRequired,
@@ -100,20 +100,24 @@ var _ = o("span")({ cursor: "move" }), v = o("div")(({ theme: e }) => ({
100
100
  text: `There should be at least ${r} question row` + (r > 1 ? "s" : "") + "."
101
101
  } }) : n(e);
102
102
  };
103
- onMouseDownOnHandle = () => {};
104
- onMouseUpOnHandle = () => {};
103
+ onMouseDownOnHandle = () => {
104
+ _ = !0;
105
+ };
106
+ onMouseUpOnHandle = () => {
107
+ _ = !1;
108
+ };
105
109
  render() {
106
- let { imageSupport: e, model: t, row: n, idx: a, inputConfiguration: o = {}, toolbarOpts: s, spellCheck: h, error: g, maxImageWidth: T, maxImageHeight: E, uploadSoundSupport: D, mathMlOptions: O = {} } = this.props, { dialog: k } = this.state, A = (d || []).filter((e) => e !== "bulleted-list" && e !== "numbered-list");
110
+ let { imageSupport: e, model: t, row: n, idx: a, inputConfiguration: o = {}, toolbarOpts: s, spellCheck: h, error: g, maxImageWidth: _, maxImageHeight: E, uploadSoundSupport: D, mathMlOptions: O = {} } = this.props, { dialog: k } = this.state, A = (d || []).filter((e) => e !== "bulleted-list" && e !== "numbered-list");
107
111
  return /* @__PURE__ */ i("div", {
108
112
  style: { width: "100%" },
109
113
  children: [
110
- /* @__PURE__ */ r(_, {
114
+ /* @__PURE__ */ r(v, {
111
115
  itemID: "handle",
112
116
  onMouseDown: this.onMouseDownOnHandle,
113
117
  children: /* @__PURE__ */ r(f, { color: "primary" })
114
118
  }),
115
- /* @__PURE__ */ i(v, { children: [
116
- /* @__PURE__ */ r(S, { children: /* @__PURE__ */ r(u, {
119
+ /* @__PURE__ */ i(y, { children: [
120
+ /* @__PURE__ */ r(C, { children: /* @__PURE__ */ r(u, {
117
121
  imageSupport: e,
118
122
  autoWidthToolbar: !0,
119
123
  disableUnderline: !0,
@@ -124,14 +128,14 @@ var _ = o("span")({ cursor: "move" }), v = o("div")(({ theme: e }) => ({
124
128
  toolbarOpts: s,
125
129
  activePlugins: A,
126
130
  spellCheck: h,
127
- maxImageWidth: T,
131
+ maxImageWidth: _,
128
132
  maxImageHeight: E,
129
133
  uploadSoundSupport: D,
130
134
  languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
131
135
  error: g && g !== "No correct response defined.",
132
136
  mathMlOptions: O
133
137
  }) }),
134
- n.values.map((e, n) => /* @__PURE__ */ r(y, { children: t.choiceMode === "radio" ? /* @__PURE__ */ r(b, {
138
+ n.values.map((e, n) => /* @__PURE__ */ r(b, { children: t.choiceMode === "radio" ? /* @__PURE__ */ r(x, {
135
139
  error: g?.includes("No correct response defined."),
136
140
  onChange: this.onRowValueChange(a, n),
137
141
  checked: e === !0
@@ -141,15 +145,15 @@ var _ = o("span")({ cursor: "move" }), v = o("div")(({ theme: e }) => ({
141
145
  label: "",
142
146
  error: g?.includes("No correct response defined.")
143
147
  }) }, n)),
144
- /* @__PURE__ */ r(x, { children: /* @__PURE__ */ r(p, {
148
+ /* @__PURE__ */ r(S, { children: /* @__PURE__ */ r(p, {
145
149
  onClick: this.onDeleteRow(a),
146
150
  "aria-label": "Delete",
147
151
  size: "large",
148
152
  children: /* @__PURE__ */ r(m, {})
149
153
  }) })
150
154
  ] }),
151
- g && /* @__PURE__ */ r(w, { children: g }),
152
- /* @__PURE__ */ r(C, {}),
155
+ g && /* @__PURE__ */ r(T, { children: g }),
156
+ /* @__PURE__ */ r(w, {}),
153
157
  /* @__PURE__ */ r(c, {
154
158
  open: k.open,
155
159
  title: "Warning",
@@ -160,7 +164,7 @@ var _ = o("span")({ cursor: "move" }), v = o("div")(({ theme: e }) => ({
160
164
  });
161
165
  }
162
166
  };
163
- function E(e) {
167
+ function D(e) {
164
168
  let { attributes: t, listeners: n, setNodeRef: i, transform: a, transition: o, isDragging: s } = h({
165
169
  id: `row-${e.row.id}`,
166
170
  data: {
@@ -196,9 +200,9 @@ function E(e) {
196
200
  t.closest("[contenteditable]") || t.closest("input") || t.closest("textarea") || t.isContentEditable || n?.onPointerDown?.(e);
197
201
  },
198
202
  ...t,
199
- children: /* @__PURE__ */ r(T, { ...e })
203
+ children: /* @__PURE__ */ r(E, { ...e })
200
204
  })
201
205
  });
202
206
  }
203
207
  //#endregion
204
- export { E as default };
208
+ export { E as Row, _ as canDrag, D as default };