@pie-element/categorize 13.1.2-next.5 → 13.1.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.
Files changed (158) hide show
  1. package/CHANGELOG.json +1637 -0
  2. package/CHANGELOG.md +2550 -0
  3. package/LICENSE.md +5 -0
  4. package/README.md +5 -0
  5. package/configure/CHANGELOG.json +1202 -0
  6. package/configure/CHANGELOG.md +2131 -0
  7. package/configure/lib/defaults.js +222 -0
  8. package/configure/lib/defaults.js.map +1 -0
  9. package/configure/lib/design/builder.js +55 -0
  10. package/configure/lib/design/builder.js.map +1 -0
  11. package/configure/lib/design/buttons.js +59 -0
  12. package/configure/lib/design/buttons.js.map +1 -0
  13. package/configure/lib/design/categories/RowLabel.js +66 -0
  14. package/configure/lib/design/categories/RowLabel.js.map +1 -0
  15. package/configure/lib/design/categories/alternateResponses.js +116 -0
  16. package/configure/lib/design/categories/alternateResponses.js.map +1 -0
  17. package/configure/lib/design/categories/category.js +153 -0
  18. package/configure/lib/design/categories/category.js.map +1 -0
  19. package/configure/lib/design/categories/choice-preview.js +79 -0
  20. package/configure/lib/design/categories/choice-preview.js.map +1 -0
  21. package/configure/lib/design/categories/droppable-placeholder.js +93 -0
  22. package/configure/lib/design/categories/droppable-placeholder.js.map +1 -0
  23. package/configure/lib/design/categories/index.js +256 -0
  24. package/configure/lib/design/categories/index.js.map +1 -0
  25. package/configure/lib/design/choices/choice.js +187 -0
  26. package/configure/lib/design/choices/choice.js.map +1 -0
  27. package/configure/lib/design/choices/config.js +58 -0
  28. package/configure/lib/design/choices/config.js.map +1 -0
  29. package/configure/lib/design/choices/index.js +197 -0
  30. package/configure/lib/design/choices/index.js.map +1 -0
  31. package/configure/lib/design/header.js +71 -0
  32. package/configure/lib/design/header.js.map +1 -0
  33. package/configure/lib/design/index.js +727 -0
  34. package/configure/lib/design/index.js.map +1 -0
  35. package/configure/lib/design/input-header.js +105 -0
  36. package/configure/lib/design/input-header.js.map +1 -0
  37. package/configure/lib/design/utils.js +12 -0
  38. package/configure/lib/design/utils.js.map +1 -0
  39. package/configure/lib/index.js +147 -0
  40. package/configure/lib/index.js.map +1 -0
  41. package/configure/lib/main.js +44 -0
  42. package/configure/lib/main.js.map +1 -0
  43. package/configure/lib/utils.js +43 -0
  44. package/configure/lib/utils.js.map +1 -0
  45. package/configure/package.json +32 -0
  46. package/controller/CHANGELOG.json +452 -0
  47. package/controller/CHANGELOG.md +1384 -0
  48. package/controller/lib/defaults.js +33 -0
  49. package/controller/lib/defaults.js.map +1 -0
  50. package/controller/lib/index.js +493 -0
  51. package/controller/lib/index.js.map +1 -0
  52. package/controller/lib/utils.js +69 -0
  53. package/controller/lib/utils.js.map +1 -0
  54. package/controller/package.json +18 -0
  55. package/docs/config-schema.json +2897 -0
  56. package/docs/config-schema.json.md +2138 -0
  57. package/docs/demo/config.js +8 -0
  58. package/docs/demo/generate.js +357 -0
  59. package/docs/demo/index.html +1 -0
  60. package/docs/demo/session.js +12 -0
  61. package/docs/pie-schema.json +1784 -0
  62. package/docs/pie-schema.json.md +1046 -0
  63. package/lib/categorize/categories.js +135 -0
  64. package/lib/categorize/categories.js.map +1 -0
  65. package/lib/categorize/category.js +67 -0
  66. package/lib/categorize/category.js.map +1 -0
  67. package/lib/categorize/choice.js +140 -0
  68. package/lib/categorize/choice.js.map +1 -0
  69. package/lib/categorize/choices.js +99 -0
  70. package/lib/categorize/choices.js.map +1 -0
  71. package/lib/categorize/droppable-placeholder.js +84 -0
  72. package/lib/categorize/droppable-placeholder.js.map +1 -0
  73. package/lib/categorize/grid-content.js +55 -0
  74. package/lib/categorize/grid-content.js.map +1 -0
  75. package/lib/categorize/index.js +450 -0
  76. package/lib/categorize/index.js.map +1 -0
  77. package/lib/index.js +316 -0
  78. package/lib/index.js.map +1 -0
  79. package/package.json +22 -85
  80. package/configure.js +0 -2
  81. package/controller.js +0 -1
  82. package/dist/author/defaults.d.ts +0 -223
  83. package/dist/author/defaults.js +0 -170
  84. package/dist/author/design/builder.d.ts +0 -10
  85. package/dist/author/design/builder.js +0 -24
  86. package/dist/author/design/buttons.d.ts +0 -28
  87. package/dist/author/design/buttons.js +0 -36
  88. package/dist/author/design/categories/RowLabel.d.ts +0 -23
  89. package/dist/author/design/categories/RowLabel.js +0 -47
  90. package/dist/author/design/categories/alternateResponses.d.ts +0 -31
  91. package/dist/author/design/categories/alternateResponses.js +0 -62
  92. package/dist/author/design/categories/category.d.ts +0 -44
  93. package/dist/author/design/categories/category.js +0 -98
  94. package/dist/author/design/categories/choice-preview.d.ts +0 -25
  95. package/dist/author/design/categories/choice-preview.js +0 -60
  96. package/dist/author/design/categories/droppable-placeholder.d.ts +0 -11
  97. package/dist/author/design/categories/droppable-placeholder.js +0 -71
  98. package/dist/author/design/categories/index.d.ts +0 -41
  99. package/dist/author/design/categories/index.js +0 -146
  100. package/dist/author/design/choices/choice.d.ts +0 -11
  101. package/dist/author/design/choices/choice.js +0 -129
  102. package/dist/author/design/choices/config.d.ts +0 -21
  103. package/dist/author/design/choices/config.js +0 -33
  104. package/dist/author/design/choices/index.d.ts +0 -41
  105. package/dist/author/design/choices/index.js +0 -110
  106. package/dist/author/design/header.d.ts +0 -24
  107. package/dist/author/design/header.js +0 -49
  108. package/dist/author/design/index.d.ts +0 -52
  109. package/dist/author/design/index.js +0 -417
  110. package/dist/author/design/input-header.d.ts +0 -39
  111. package/dist/author/design/input-header.js +0 -69
  112. package/dist/author/design/utils.d.ts +0 -9
  113. package/dist/author/design/utils.js +0 -7
  114. package/dist/author/index.d.ts +0 -51
  115. package/dist/author/index.js +0 -87
  116. package/dist/author/main.d.ts +0 -23
  117. package/dist/author/main.js +0 -30
  118. package/dist/author/utils.d.ts +0 -16
  119. package/dist/author/utils.js +0 -17
  120. package/dist/browser/author/index.js +0 -2041
  121. package/dist/browser/author/index.js.map +0 -1
  122. package/dist/browser/categorize.css +0 -2
  123. package/dist/browser/controller/index.js +0 -299
  124. package/dist/browser/controller/index.js.map +0 -1
  125. package/dist/browser/delivery/index.js +0 -1051
  126. package/dist/browser/delivery/index.js.map +0 -1
  127. package/dist/browser/dist-7UsF60Ks.js +0 -55705
  128. package/dist/browser/dist-7UsF60Ks.js.map +0 -1
  129. package/dist/browser/dist-DnGF41FP.js +0 -1958
  130. package/dist/browser/dist-DnGF41FP.js.map +0 -1
  131. package/dist/controller/defaults.d.ts +0 -34
  132. package/dist/controller/defaults.js +0 -29
  133. package/dist/controller/index.d.ts +0 -61
  134. package/dist/controller/index.js +0 -155
  135. package/dist/controller/utils.d.ts +0 -20
  136. package/dist/controller/utils.js +0 -35
  137. package/dist/delivery/categorize/categories.d.ts +0 -34
  138. package/dist/delivery/categorize/categories.js +0 -66
  139. package/dist/delivery/categorize/category.d.ts +0 -28
  140. package/dist/delivery/categorize/category.js +0 -48
  141. package/dist/delivery/categorize/choice.d.ts +0 -27
  142. package/dist/delivery/categorize/choice.js +0 -94
  143. package/dist/delivery/categorize/choices.d.ts +0 -39
  144. package/dist/delivery/categorize/choices.js +0 -51
  145. package/dist/delivery/categorize/droppable-placeholder.d.ts +0 -32
  146. package/dist/delivery/categorize/droppable-placeholder.js +0 -64
  147. package/dist/delivery/categorize/grid-content.d.ts +0 -25
  148. package/dist/delivery/categorize/grid-content.js +0 -39
  149. package/dist/delivery/categorize/index.d.ts +0 -57
  150. package/dist/delivery/categorize/index.js +0 -260
  151. package/dist/delivery/index.d.ts +0 -27
  152. package/dist/delivery/index.js +0 -152
  153. package/dist/index.d.ts +0 -1
  154. package/dist/index.iife.d.ts +0 -8
  155. package/dist/index.iife.js +0 -152
  156. package/dist/index.js +0 -2
  157. package/dist/runtime-support.d.ts +0 -12
  158. package/dist/runtime-support.js +0 -12
@@ -1,2041 +0,0 @@
1
- import { D as e, M as t, O as n, a as r, b as i, c as a, d as o, i as s, l as c, n as l, o as u, r as d, s as f, u as p } from "../dist-DnGF41FP.js";
2
- import { $ as m, A as h, B as g, D as _, E as v, F as y, H as b, I as x, J as ee, L as S, M as C, N as te, P as w, Q as T, R as E, U as D, V as ne, W as re, X as ie, Y as ae, Z as oe, _ as se, a as ce, b as O, c as k, d as A, et as le, f as j, g as ue, h as de, i as fe, k as M, l as pe, m as N, n as P, nt as me, o as he, p as ge, q as F, r as I, rt as L, s as R, t as z, tt as _e, u as ve, v as ye, y as B, z as be } from "../dist-7UsF60Ks.js";
3
- import * as V from "react";
4
- import H from "react";
5
- import { createRoot as U } from "react-dom/client";
6
- import { jsx as W, jsxs as G } from "react/jsx-runtime";
7
- //#region ../../lib-react/drag/dist/draggable-choice.js
8
- var K = /* @__PURE__ */ t(le(), 1), xe = F("div")(({ theme: e }) => ({
9
- backgroundColor: e.palette.background.paper,
10
- border: `solid 1px ${me[400]}`,
11
- padding: e.spacing(1),
12
- minHeight: "30px",
13
- minWidth: e.spacing(20),
14
- maxWidth: e.spacing(75),
15
- cursor: "grab",
16
- "& p": { margin: 0 },
17
- "& p *": { margin: 0 },
18
- "&:active": { cursor: "grabbing" }
19
- }));
20
- function q({ choice: e, children: t, className: n, disabled: r, category: i, alternateResponseIndex: a, choiceIndex: o, onRemoveChoice: s, type: c, id: l }) {
21
- let { attributes: u, listeners: d, setNodeRef: f, isDragging: p } = ye({
22
- id: l || e.id,
23
- disabled: r,
24
- categoryId: i?.id,
25
- alternateResponseIndex: a,
26
- data: {
27
- id: e.id,
28
- value: e.value,
29
- choiceId: e.id,
30
- from: i?.id,
31
- categoryId: i?.id,
32
- alternateResponseIndex: a,
33
- choiceIndex: o,
34
- onRemoveChoice: s,
35
- type: c
36
- }
37
- });
38
- return /* @__PURE__ */ W(xe, {
39
- ref: f,
40
- className: n,
41
- isDragging: p,
42
- ...u,
43
- ...d,
44
- children: t
45
- });
46
- }
47
- q.propTypes = {
48
- choice: K.default.shape({
49
- id: K.default.oneOfType([K.default.string, K.default.number]).isRequired,
50
- value: K.default.any
51
- }).isRequired,
52
- children: K.default.oneOfType([K.default.arrayOf(K.default.node), K.default.node]),
53
- className: K.default.string,
54
- disabled: K.default.bool,
55
- category: K.default.shape({ id: K.default.oneOfType([K.default.string, K.default.number]) }),
56
- alternateResponseIndex: K.default.number,
57
- choiceIndex: K.default.number,
58
- onRemoveChoice: K.default.func,
59
- type: K.default.string,
60
- id: K.default.string
61
- };
62
- //#endregion
63
- //#region ../../../node_modules/.bun/@mui+material@7.3.11+eb26afe407ed7030/node_modules/@mui/material/esm/CardActions/cardActionsClasses.js
64
- function Se(e) {
65
- return T("MuiCardActions", e);
66
- }
67
- oe("MuiCardActions", ["root", "spacing"]);
68
- //#endregion
69
- //#region ../../../node_modules/.bun/@mui+material@7.3.11+eb26afe407ed7030/node_modules/@mui/material/esm/CardActions/CardActions.js
70
- var Ce = (e) => {
71
- let { classes: t, disableSpacing: n } = e;
72
- return ae({ root: ["root", !n && "spacing"] }, Se, t);
73
- }, we = F("div", {
74
- name: "MuiCardActions",
75
- slot: "Root",
76
- overridesResolver: (e, t) => {
77
- let { ownerState: n } = e;
78
- return [t.root, !n.disableSpacing && t.spacing];
79
- }
80
- })({
81
- display: "flex",
82
- alignItems: "center",
83
- padding: 8,
84
- variants: [{
85
- props: { disableSpacing: !1 },
86
- style: { "& > :not(style) ~ :not(style)": { marginLeft: 8 } }
87
- }]
88
- }), Te = /*#__PURE__*/ V.forwardRef(function(e, t) {
89
- let n = re({
90
- props: e,
91
- name: "MuiCardActions"
92
- }), { disableSpacing: r = !1, className: i, ...a } = n, o = {
93
- ...n,
94
- disableSpacing: r
95
- };
96
- return /*#__PURE__*/ W(we, {
97
- className: m(Ce(o).root, i),
98
- ownerState: o,
99
- ref: t,
100
- ...a
101
- });
102
- });
103
- //#endregion
104
- //#region ../../../node_modules/.bun/@mui+material@7.3.11+eb26afe407ed7030/node_modules/@mui/material/esm/Tooltip/tooltipClasses.js
105
- function Ee(e) {
106
- return T("MuiTooltip", e);
107
- }
108
- var J = oe("MuiTooltip", [
109
- "popper",
110
- "popperInteractive",
111
- "popperArrow",
112
- "popperClose",
113
- "tooltip",
114
- "tooltipArrow",
115
- "touch",
116
- "tooltipPlacementLeft",
117
- "tooltipPlacementRight",
118
- "tooltipPlacementTop",
119
- "tooltipPlacementBottom",
120
- "arrow"
121
- ]);
122
- //#endregion
123
- //#region ../../../node_modules/.bun/@mui+material@7.3.11+eb26afe407ed7030/node_modules/@mui/material/esm/Tooltip/Tooltip.js
124
- function De(e) {
125
- return Math.round(e * 1e5) / 1e5;
126
- }
127
- var Oe = (e) => {
128
- let { classes: t, disableInteractive: n, arrow: r, touch: i, placement: a } = e;
129
- return ae({
130
- popper: [
131
- "popper",
132
- !n && "popperInteractive",
133
- r && "popperArrow"
134
- ],
135
- tooltip: [
136
- "tooltip",
137
- r && "tooltipArrow",
138
- i && "touch",
139
- `tooltipPlacement${x(a.split("-")[0])}`
140
- ],
141
- arrow: ["arrow"]
142
- }, Ee, t);
143
- }, ke = F(A, {
144
- name: "MuiTooltip",
145
- slot: "Popper",
146
- overridesResolver: (e, t) => {
147
- let { ownerState: n } = e;
148
- return [
149
- t.popper,
150
- !n.disableInteractive && t.popperInteractive,
151
- n.arrow && t.popperArrow,
152
- !n.open && t.popperClose
153
- ];
154
- }
155
- })(E(({ theme: e }) => ({
156
- zIndex: (e.vars || e).zIndex.tooltip,
157
- pointerEvents: "none",
158
- variants: [
159
- {
160
- props: ({ ownerState: e }) => !e.disableInteractive,
161
- style: { pointerEvents: "auto" }
162
- },
163
- {
164
- props: ({ open: e }) => !e,
165
- style: { pointerEvents: "none" }
166
- },
167
- {
168
- props: ({ ownerState: e }) => e.arrow,
169
- style: {
170
- [`&[data-popper-placement*="bottom"] .${J.arrow}`]: {
171
- top: 0,
172
- marginTop: "-0.71em",
173
- "&::before": { transformOrigin: "0 100%" }
174
- },
175
- [`&[data-popper-placement*="top"] .${J.arrow}`]: {
176
- bottom: 0,
177
- marginBottom: "-0.71em",
178
- "&::before": { transformOrigin: "100% 0" }
179
- },
180
- [`&[data-popper-placement*="right"] .${J.arrow}`]: {
181
- height: "1em",
182
- width: "0.71em",
183
- "&::before": { transformOrigin: "100% 100%" }
184
- },
185
- [`&[data-popper-placement*="left"] .${J.arrow}`]: {
186
- height: "1em",
187
- width: "0.71em",
188
- "&::before": { transformOrigin: "0 0" }
189
- }
190
- }
191
- },
192
- {
193
- props: ({ ownerState: e }) => e.arrow && !e.isRtl,
194
- style: { [`&[data-popper-placement*="right"] .${J.arrow}`]: {
195
- left: 0,
196
- marginLeft: "-0.71em"
197
- } }
198
- },
199
- {
200
- props: ({ ownerState: e }) => e.arrow && !!e.isRtl,
201
- style: { [`&[data-popper-placement*="right"] .${J.arrow}`]: {
202
- right: 0,
203
- marginRight: "-0.71em"
204
- } }
205
- },
206
- {
207
- props: ({ ownerState: e }) => e.arrow && !e.isRtl,
208
- style: { [`&[data-popper-placement*="left"] .${J.arrow}`]: {
209
- right: 0,
210
- marginRight: "-0.71em"
211
- } }
212
- },
213
- {
214
- props: ({ ownerState: e }) => e.arrow && !!e.isRtl,
215
- style: { [`&[data-popper-placement*="left"] .${J.arrow}`]: {
216
- left: 0,
217
- marginLeft: "-0.71em"
218
- } }
219
- }
220
- ]
221
- }))), Ae = F("div", {
222
- name: "MuiTooltip",
223
- slot: "Tooltip",
224
- overridesResolver: (e, t) => {
225
- let { ownerState: n } = e;
226
- return [
227
- t.tooltip,
228
- n.touch && t.touch,
229
- n.arrow && t.tooltipArrow,
230
- t[`tooltipPlacement${x(n.placement.split("-")[0])}`]
231
- ];
232
- }
233
- })(E(({ theme: e }) => ({
234
- backgroundColor: e.vars ? e.vars.palette.Tooltip.bg : e.alpha(e.palette.grey[700], .92),
235
- borderRadius: (e.vars || e).shape.borderRadius,
236
- color: (e.vars || e).palette.common.white,
237
- fontFamily: e.typography.fontFamily,
238
- padding: "4px 8px",
239
- fontSize: e.typography.pxToRem(11),
240
- maxWidth: 300,
241
- margin: 2,
242
- wordWrap: "break-word",
243
- fontWeight: e.typography.fontWeightMedium,
244
- [`.${J.popper}[data-popper-placement*="left"] &`]: { transformOrigin: "right center" },
245
- [`.${J.popper}[data-popper-placement*="right"] &`]: { transformOrigin: "left center" },
246
- [`.${J.popper}[data-popper-placement*="top"] &`]: {
247
- transformOrigin: "center bottom",
248
- marginBottom: "14px"
249
- },
250
- [`.${J.popper}[data-popper-placement*="bottom"] &`]: {
251
- transformOrigin: "center top",
252
- marginTop: "14px"
253
- },
254
- variants: [
255
- {
256
- props: ({ ownerState: e }) => e.arrow,
257
- style: {
258
- position: "relative",
259
- margin: 0
260
- }
261
- },
262
- {
263
- props: ({ ownerState: e }) => e.touch,
264
- style: {
265
- padding: "8px 16px",
266
- fontSize: e.typography.pxToRem(14),
267
- lineHeight: `${De(16 / 14)}em`,
268
- fontWeight: e.typography.fontWeightRegular
269
- }
270
- },
271
- {
272
- props: ({ ownerState: e }) => !e.isRtl,
273
- style: {
274
- [`.${J.popper}[data-popper-placement*="left"] &`]: { marginRight: "14px" },
275
- [`.${J.popper}[data-popper-placement*="right"] &`]: { marginLeft: "14px" }
276
- }
277
- },
278
- {
279
- props: ({ ownerState: e }) => !e.isRtl && e.touch,
280
- style: {
281
- [`.${J.popper}[data-popper-placement*="left"] &`]: { marginRight: "24px" },
282
- [`.${J.popper}[data-popper-placement*="right"] &`]: { marginLeft: "24px" }
283
- }
284
- },
285
- {
286
- props: ({ ownerState: e }) => !!e.isRtl,
287
- style: {
288
- [`.${J.popper}[data-popper-placement*="left"] &`]: { marginLeft: "14px" },
289
- [`.${J.popper}[data-popper-placement*="right"] &`]: { marginRight: "14px" }
290
- }
291
- },
292
- {
293
- props: ({ ownerState: e }) => !!e.isRtl && e.touch,
294
- style: {
295
- [`.${J.popper}[data-popper-placement*="left"] &`]: { marginLeft: "24px" },
296
- [`.${J.popper}[data-popper-placement*="right"] &`]: { marginRight: "24px" }
297
- }
298
- },
299
- {
300
- props: ({ ownerState: e }) => e.touch,
301
- style: { [`.${J.popper}[data-popper-placement*="top"] &`]: { marginBottom: "24px" } }
302
- },
303
- {
304
- props: ({ ownerState: e }) => e.touch,
305
- style: { [`.${J.popper}[data-popper-placement*="bottom"] &`]: { marginTop: "24px" } }
306
- }
307
- ]
308
- }))), je = F("span", {
309
- name: "MuiTooltip",
310
- slot: "Arrow"
311
- })(E(({ theme: e }) => ({
312
- overflow: "hidden",
313
- position: "absolute",
314
- width: "1em",
315
- height: "0.71em",
316
- boxSizing: "border-box",
317
- color: e.vars ? e.vars.palette.Tooltip.bg : e.alpha(e.palette.grey[700], .9),
318
- "&::before": {
319
- content: "\"\"",
320
- margin: "auto",
321
- display: "block",
322
- width: "100%",
323
- height: "100%",
324
- backgroundColor: "currentColor",
325
- transform: "rotate(45deg)"
326
- }
327
- }))), Me = !1, Ne = new b(), Pe = {
328
- x: 0,
329
- y: 0
330
- };
331
- function Fe(e, t) {
332
- return (n, ...r) => {
333
- t && t(n, ...r), e(n, ...r);
334
- };
335
- }
336
- var Ie = /*#__PURE__*/ V.forwardRef(function(e, t) {
337
- let n = re({
338
- props: e,
339
- name: "MuiTooltip"
340
- }), { arrow: r = !1, children: i, classes: a, components: o = {}, componentsProps: s = {}, describeChild: c = !1, disableFocusListener: l = !1, disableHoverListener: u = !1, disableInteractive: d = !1, disableTouchListener: f = !1, enterDelay: p = 100, enterNextDelay: _ = 0, enterTouchDelay: v = 700, followCursor: y = !1, id: b, leaveDelay: x = 0, leaveTouchDelay: T = 1500, onClose: E, onOpen: ae, open: oe, placement: se = "bottom", PopperComponent: ce, PopperProps: O = {}, slotProps: k = {}, slots: le = {}, title: j, TransitionComponent: ue, TransitionProps: de, ...fe } = n, M = /*#__PURE__*/ V.isValidElement(i) ? i : /*#__PURE__*/ W("span", { children: i }), pe = ee(), N = ie(), [P, me] = V.useState(), [he, ge] = V.useState(null), F = V.useRef(!1), I = d || y, L = D(), R = D(), z = D(), _e = D(), [ve, ye] = te({
341
- controlled: oe,
342
- default: !1,
343
- name: "Tooltip",
344
- state: "open"
345
- }), B = ve, H = w(b), U = V.useRef(), K = C(() => {
346
- U.current !== void 0 && (document.body.style.WebkitUserSelect = U.current, U.current = void 0), _e.clear();
347
- });
348
- V.useEffect(() => K, [K]);
349
- let xe = (e) => {
350
- Ne.clear(), Me = !0, ye(!0), ae && !B && ae(e);
351
- }, q = C((e) => {
352
- Ne.start(800 + x, () => {
353
- Me = !1;
354
- }), ye(!1), E && B && E(e), L.start(pe.transitions.duration.shortest, () => {
355
- F.current = !1;
356
- });
357
- }), Se = (e) => {
358
- F.current && e.type !== "touchstart" || (P && P.removeAttribute("title"), R.clear(), z.clear(), p || Me && _ ? R.start(Me ? _ : p, () => {
359
- xe(e);
360
- }) : xe(e));
361
- }, Ce = (e) => {
362
- R.clear(), z.start(x, () => {
363
- q(e);
364
- });
365
- }, [, we] = V.useState(!1), Te = (e) => {
366
- let t = e?.target ?? P;
367
- if (!t || !h(t)) {
368
- we(!1);
369
- let n = e ?? new Event("blur");
370
- !e && t && (Object.defineProperty(n, "target", { value: t }), Object.defineProperty(n, "currentTarget", { value: t })), Ce(n);
371
- }
372
- }, Ee = (e) => {
373
- P || me(e.currentTarget), h(e.target) && (we(!0), Se(e));
374
- }, J = (e) => {
375
- F.current = !0;
376
- let t = M.props;
377
- t.onTouchStart && t.onTouchStart(e);
378
- }, De = (e) => {
379
- J(e), z.clear(), L.clear(), K(), U.current = document.body.style.WebkitUserSelect, document.body.style.WebkitUserSelect = "none", _e.start(v, () => {
380
- document.body.style.WebkitUserSelect = U.current, Se(e);
381
- });
382
- }, Ie = (e) => {
383
- M.props.onTouchEnd && M.props.onTouchEnd(e), K(), z.start(T, () => {
384
- q(e);
385
- });
386
- };
387
- V.useEffect(() => {
388
- if (!B) return;
389
- function e(e) {
390
- e.key === "Escape" && q(e);
391
- }
392
- return document.addEventListener("keydown", e), () => {
393
- document.removeEventListener("keydown", e);
394
- };
395
- }, [q, B]);
396
- let Le = g(ne(M), me, t);
397
- !j && j !== 0 && (B = !1);
398
- let Re = V.useRef(), ze = (e) => {
399
- let t = M.props;
400
- t.onMouseMove && t.onMouseMove(e), Pe = {
401
- x: e.clientX,
402
- y: e.clientY
403
- }, Re.current && Re.current.update();
404
- }, Y = {}, Be = typeof j == "string";
405
- c ? (Y.title = !B && Be && !u ? j : null, Y["aria-describedby"] = B ? H : null) : (Y["aria-label"] = Be ? j : null, Y["aria-labelledby"] = B && !Be ? H : null);
406
- let X = {
407
- ...Y,
408
- ...fe,
409
- ...M.props,
410
- className: m(fe.className, M.props.className),
411
- onTouchStart: J,
412
- ref: Le,
413
- ...y ? { onMouseMove: ze } : {}
414
- }, Ve = {};
415
- f || (X.onTouchStart = De, X.onTouchEnd = Ie), u || (X.onMouseOver = Fe(Se, X.onMouseOver), X.onMouseLeave = Fe(Ce, X.onMouseLeave), I || (Ve.onMouseOver = Se, Ve.onMouseLeave = Ce)), l || (X.onFocus = Fe(Ee, X.onFocus), X.onBlur = Fe(Te, X.onBlur), I || (Ve.onFocus = Ee, Ve.onBlur = Te));
416
- let Z = {
417
- ...n,
418
- isRtl: N,
419
- arrow: r,
420
- disableInteractive: I,
421
- placement: se,
422
- PopperComponentProp: ce,
423
- touch: F.current
424
- }, He = typeof k.popper == "function" ? k.popper(Z) : k.popper, Ue = V.useMemo(() => {
425
- let e = [{
426
- name: "arrow",
427
- enabled: !!he,
428
- options: {
429
- element: he,
430
- padding: 4
431
- }
432
- }];
433
- return O.popperOptions?.modifiers && (e = e.concat(O.popperOptions.modifiers)), He?.popperOptions?.modifiers && (e = e.concat(He.popperOptions.modifiers)), {
434
- ...O.popperOptions,
435
- ...He?.popperOptions,
436
- modifiers: e
437
- };
438
- }, [
439
- he,
440
- O.popperOptions,
441
- He?.popperOptions
442
- ]), We = Oe(Z), Ge = typeof k.transition == "function" ? k.transition(Z) : k.transition, Ke = {
443
- slots: {
444
- popper: o.Popper,
445
- transition: o.Transition ?? ue,
446
- tooltip: o.Tooltip,
447
- arrow: o.Arrow,
448
- ...le
449
- },
450
- slotProps: {
451
- arrow: k.arrow ?? s.arrow,
452
- popper: {
453
- ...O,
454
- ...He ?? s.popper
455
- },
456
- tooltip: k.tooltip ?? s.tooltip,
457
- transition: {
458
- ...de,
459
- ...Ge ?? s.transition
460
- }
461
- }
462
- }, [qe, Je] = S("popper", {
463
- elementType: ke,
464
- externalForwardedProps: Ke,
465
- ownerState: Z,
466
- className: m(We.popper, O?.className)
467
- }), [Ye, Xe] = S("transition", {
468
- elementType: be,
469
- externalForwardedProps: Ke,
470
- ownerState: Z
471
- }), [Ze, Qe] = S("tooltip", {
472
- elementType: Ae,
473
- className: We.tooltip,
474
- externalForwardedProps: Ke,
475
- ownerState: Z
476
- }), [$e, et] = S("arrow", {
477
- elementType: je,
478
- className: We.arrow,
479
- externalForwardedProps: Ke,
480
- ownerState: Z,
481
- ref: ge
482
- });
483
- return /*#__PURE__*/ G(V.Fragment, { children: [/*#__PURE__*/ V.cloneElement(M, X), /*#__PURE__*/ W(qe, {
484
- as: ce ?? A,
485
- placement: se,
486
- anchorEl: y ? { getBoundingClientRect: () => ({
487
- top: Pe.y,
488
- left: Pe.x,
489
- right: Pe.x,
490
- bottom: Pe.y,
491
- width: 0,
492
- height: 0
493
- }) } : P,
494
- popperRef: Re,
495
- open: P ? B : !1,
496
- id: H,
497
- transition: !0,
498
- ...Ve,
499
- ...Je,
500
- popperOptions: Ue,
501
- children: ({ TransitionProps: e }) => /*#__PURE__*/ W(Ye, {
502
- timeout: pe.transitions.duration.shorter,
503
- ...e,
504
- ...Xe,
505
- children: /*#__PURE__*/ G(Ze, {
506
- ...Qe,
507
- children: [j, r ? /*#__PURE__*/ W($e, { ...et }) : null]
508
- })
509
- })
510
- })] });
511
- }), Le = class e extends CustomEvent {
512
- static {
513
- this.TYPE = "model.updated";
514
- }
515
- constructor(t, n = !1) {
516
- super(e.TYPE, {
517
- bubbles: !0,
518
- detail: {
519
- update: t,
520
- reset: n
521
- }
522
- }), this.update = t, this.reset = n;
523
- }
524
- }, Re = class e extends CustomEvent {
525
- static {
526
- this.TYPE = "delete.image";
527
- }
528
- constructor(t, n) {
529
- super(e.TYPE, {
530
- bubbles: !0,
531
- detail: {
532
- src: t,
533
- done: n
534
- }
535
- }), this.src = t, this.done = n;
536
- }
537
- }, ze = class e extends CustomEvent {
538
- static {
539
- this.TYPE = "insert.image";
540
- }
541
- constructor(t) {
542
- super(e.TYPE, {
543
- bubbles: !0,
544
- detail: t
545
- }), this.handler = t;
546
- }
547
- }, Y = class e extends CustomEvent {
548
- static {
549
- this.TYPE = "delete.sound";
550
- }
551
- constructor(t, n) {
552
- super(e.TYPE, {
553
- bubbles: !0,
554
- detail: {
555
- src: t,
556
- done: n
557
- }
558
- }), this.src = t, this.done = n;
559
- }
560
- }, Be = class e extends CustomEvent {
561
- static {
562
- this.TYPE = "insert.sound";
563
- }
564
- constructor(t) {
565
- super(e.TYPE, {
566
- bubbles: !0,
567
- detail: t
568
- }), this.handler = t;
569
- }
570
- }, X = (e = {}, t = {}) => ({
571
- ...t,
572
- ...e
573
- }), Ve = y(/*#__PURE__*/ W("path", { d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m1 15h-2v-6h2zm0-8h-2V7h2z" }), "Info"), Z = F(R)({
574
- flex: "1",
575
- maxWidth: "100%"
576
- }), He = F("div")(({ theme: e }) => ({
577
- display: "flex",
578
- justifyContent: "space-between",
579
- paddingBottom: e.spacing(1)
580
- })), Ue = class extends H.Component {
581
- static propTypes = {
582
- configuration: K.default.object.isRequired,
583
- deleteFocusedEl: K.default.func,
584
- disabled: K.default.bool,
585
- focusedEl: K.default.number,
586
- index: K.default.number,
587
- label: K.default.string,
588
- maxImageWidth: K.default.object,
589
- maxImageHeight: K.default.object,
590
- onChange: K.default.func,
591
- onDelete: K.default.func,
592
- imageSupport: K.default.shape({
593
- add: K.default.func.isRequired,
594
- delete: K.default.func.isRequired
595
- }),
596
- uploadSoundSupport: K.default.shape({
597
- add: K.default.func.isRequired,
598
- delete: K.default.func.isRequired
599
- }),
600
- toolbarOpts: K.default.object,
601
- error: K.default.string,
602
- spellCheck: K.default.bool
603
- };
604
- static defaultProps = {};
605
- constructor(e) {
606
- super(e);
607
- }
608
- render() {
609
- let { onChange: e, configuration: t, label: n, deleteFocusedEl: r, disabled: i, imageSupport: a, toolbarOpts: o, spellCheck: s, error: c, maxImageWidth: l, maxImageHeight: u, uploadSoundSupport: d, mathMlOptions: f = {}, focusedEl: p, index: m } = this.props, { headers: h, baseInputConfiguration: g } = t;
610
- return /* @__PURE__ */ W(He, { children: /* @__PURE__ */ W(Z, {
611
- imageSupport: a,
612
- disabled: i,
613
- autoFocus: p != null && p === m,
614
- autoWidthToolbar: !0,
615
- label: "label",
616
- markup: n,
617
- onChange: e,
618
- pluginProps: X(h?.inputConfiguration, g),
619
- toolbarOpts: o,
620
- spellCheck: s,
621
- error: c,
622
- maxImageWidth: l,
623
- maxImageHeight: u,
624
- uploadSoundSupport: d,
625
- languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
626
- onDone: () => {
627
- r && r();
628
- },
629
- mathMlOptions: f
630
- }) });
631
- }
632
- }, We = F(M)(({ theme: e }) => ({ height: e.spacing(4) })), Ge = class extends H.Component {
633
- static propTypes = {
634
- label: K.default.string,
635
- onClick: K.default.func,
636
- disabled: K.default.bool
637
- };
638
- static defaultProps = { label: "Add" };
639
- render() {
640
- let { label: e, onClick: t, disabled: n } = this.props;
641
- return /* @__PURE__ */ W(We, {
642
- onClick: t,
643
- disabled: n,
644
- size: "small",
645
- variant: "contained",
646
- color: "primary",
647
- children: e
648
- });
649
- }
650
- }, Ke = F(M)({
651
- margin: 0,
652
- padding: 0
653
- }), qe = ({ label: e, onClick: t, disabled: n }) => /* @__PURE__ */ W(Ke, {
654
- onClick: t,
655
- size: "small",
656
- color: "primary",
657
- disabled: n,
658
- children: e
659
- }), Je = y(/*#__PURE__*/ W("path", { d: "M7 11v2h10v-2zm5-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8" }), "RemoveCircleOutline");
660
- //#endregion
661
- //#region src/author/design/categories/choice-preview.tsx
662
- function Ye(e) {
663
- return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
664
- }
665
- function Xe(e, t) {
666
- return !e || Ye(e) ? e : Ye(e.default) ? e.default : t && Ye(e[t]) ? e[t] : t && Ye(e[t]?.default) ? e[t].default : e;
667
- }
668
- var Ze = Xe(_, "HtmlAndMath") || Xe(et.HtmlAndMath, "HtmlAndMath"), Qe = O, $e = Qe.default, et = $e && typeof $e == "object" ? $e : Qe, tt = F("div")({
669
- position: "relative",
670
- overflow: "auto",
671
- touchAction: "none"
672
- }), nt = F(ge)({
673
- position: "absolute",
674
- right: 0,
675
- top: 0,
676
- color: `${_e.tertiary()} !important`
677
- }), rt = class extends H.Component {
678
- static propTypes = {
679
- alternateResponseIndex: K.default.number,
680
- category: K.default.object,
681
- choice: K.default.object.isRequired,
682
- choiceIndex: K.default.number,
683
- onDelete: K.default.func
684
- };
685
- static defaultProps = { onDelete: () => {} };
686
- delete = () => {
687
- let { onDelete: e, choice: t } = this.props;
688
- e(t);
689
- };
690
- render() {
691
- let { alternateResponseIndex: e, category: t, choice: n, choiceIndex: r } = this.props, i = t && t.id, a = e === void 0 ? `${n.id}-${i}-${r}` : `${n.id}-${i}-${r}-alt-${e}`;
692
- return /* @__PURE__ */ G(tt, { children: [n ? /* @__PURE__ */ W(q, {
693
- alternateResponseIndex: e,
694
- category: t,
695
- choice: n,
696
- choiceIndex: r,
697
- onRemoveChoice: this.delete,
698
- type: "choice-preview",
699
- id: a,
700
- categoryId: i,
701
- children: /* @__PURE__ */ W(Ze, { html: n?.content })
702
- }) : null, /* @__PURE__ */ W(nt, {
703
- "aria-label": "delete",
704
- onClick: this.delete,
705
- size: "large",
706
- children: /* @__PURE__ */ W(Je, {})
707
- })] });
708
- }
709
- }, it = /* @__PURE__ */ t(n(), 1);
710
- (0, it.default)("@pie-element:categorize:configure");
711
- var at = F("div")(({ theme: e }) => ({
712
- display: "flex",
713
- alignItems: "center",
714
- justifyContent: "center",
715
- fontSize: e.typography.fontSize - 2,
716
- color: `rgba(${e.palette.common.black}, 0.4)`,
717
- width: "100%",
718
- height: "100%"
719
- })), ot = () => /* @__PURE__ */ W(at, { children: "Drag your correct answers here" }), st = ({ alternateResponseIndex: e, category: t, choices: n, onDeleteChoice: r }) => /* @__PURE__ */ W(H.Fragment, { children: (n || []).map((n, i) => n && /* @__PURE__ */ W(rt, {
720
- alternateResponseIndex: e,
721
- category: t,
722
- choice: n,
723
- choiceIndex: i,
724
- onDelete: (e) => r(e, i)
725
- }, i)) });
726
- st.propTypes = {
727
- alternateResponseIndex: K.default.number,
728
- category: K.default.object,
729
- choices: K.default.array,
730
- onDeleteChoice: K.default.func
731
- };
732
- var ct = ({ alternateResponseIndex: e, category: t, choices: n, onDeleteChoice: r, categoryId: i, isAlternate: a }) => {
733
- let { setNodeRef: o, isOver: s } = B({
734
- id: `${i}-${a ? "alternate" : "standard"}`,
735
- data: {
736
- accepts: ["choice", "choice-preview"],
737
- alternateResponseIndex: e,
738
- categoryId: i,
739
- type: a ? "category-alternate" : "category",
740
- id: i
741
- }
742
- });
743
- return /* @__PURE__ */ W("div", {
744
- ref: o,
745
- children: /* @__PURE__ */ W(ue, {
746
- isOver: s,
747
- extraStyles: {
748
- width: "100%",
749
- minHeight: "100px",
750
- height: "auto"
751
- },
752
- children: (n || []).length === 0 ? /* @__PURE__ */ W(ot, {}) : /* @__PURE__ */ W(st, {
753
- alternateResponseIndex: e,
754
- category: t,
755
- choices: n,
756
- onDeleteChoice: r
757
- })
758
- })
759
- });
760
- };
761
- ct.propTypes = {
762
- alternateResponseIndex: K.default.number,
763
- category: K.default.object,
764
- choices: K.default.array,
765
- onDeleteChoice: K.default.func,
766
- categoryId: K.default.string.isRequired,
767
- isAlternate: K.default.bool
768
- };
769
- var lt = N.withUid(ct), ut = F(ve, { shouldForwardProp: (e) => e !== "isDuplicated" })(({ theme: e, isDuplicated: t }) => ({
770
- minWidth: "196px",
771
- padding: e.spacing(1),
772
- overflow: "visible",
773
- ...t && { border: "1px solid red" }
774
- })), dt = F(Te)(({ theme: e }) => ({ padding: `${e.spacing(1)} 0 0` })), ft = F("div")(({ theme: e }) => ({
775
- padding: e.spacing(2),
776
- "& p": { margin: 0 }
777
- })), pt = F("div")(({ theme: e }) => ({
778
- fontSize: e.typography.fontSize - 2,
779
- color: e.palette.error.main,
780
- paddingBottom: e.spacing(1)
781
- })), mt = class extends H.Component {
782
- static propTypes = {
783
- alternateResponseIndex: K.default.number,
784
- category: K.default.object.isRequired,
785
- configuration: K.default.object.isRequired,
786
- defaultImageMaxHeight: K.default.number,
787
- defaultImageMaxWidth: K.default.number,
788
- deleteFocusedEl: K.default.func,
789
- focusedEl: K.default.number,
790
- index: K.default.number,
791
- error: K.default.string,
792
- isDuplicated: K.default.bool,
793
- maxImageWidth: K.default.object,
794
- maxImageHeight: K.default.object,
795
- onChange: K.default.func,
796
- onDelete: K.default.func,
797
- onDeleteChoice: K.default.func,
798
- imageSupport: K.default.shape({
799
- add: K.default.func.isRequired,
800
- delete: K.default.func.isRequired
801
- }),
802
- toolbarOpts: K.default.object,
803
- spellCheck: K.default.bool,
804
- uploadSoundSupport: K.default.shape({
805
- add: K.default.func.isRequired,
806
- delete: K.default.func.isRequired
807
- }),
808
- isAlternate: K.default.bool
809
- };
810
- static defaultProps = {};
811
- changeLabel = (e) => {
812
- let { category: t, onChange: n } = this.props;
813
- t.label = e, n(t);
814
- };
815
- render() {
816
- let { alternateResponseIndex: e, category: t, configuration: n, deleteFocusedEl: r, focusedEl: i, index: a, error: o, isDuplicated: s, onDelete: c, onDeleteChoice: l, imageSupport: u, spellCheck: d, toolbarOpts: f, maxImageWidth: p, maxImageHeight: m, uploadSoundSupport: h, mathMlOptions: g = {} } = this.props;
817
- return /* @__PURE__ */ G(ut, {
818
- isDuplicated: s,
819
- children: [
820
- /* @__PURE__ */ G("span", { children: [e || e === 0 ? /* @__PURE__ */ W(ft, { dangerouslySetInnerHTML: { __html: t.label } }) : /* @__PURE__ */ W(Ue, {
821
- label: t.label,
822
- focusedEl: i,
823
- deleteFocusedEl: r,
824
- index: a,
825
- disabled: !!e || e === 0,
826
- error: o,
827
- onChange: this.changeLabel,
828
- onDelete: c,
829
- imageSupport: u,
830
- toolbarOpts: f,
831
- spellCheck: d,
832
- maxImageWidth: p,
833
- maxImageHeight: m,
834
- uploadSoundSupport: h,
835
- mathMlOptions: g,
836
- configuration: n
837
- }), o && /* @__PURE__ */ W(pt, { children: o })] }),
838
- /* @__PURE__ */ W(lt, {
839
- alternateResponseIndex: e,
840
- category: t,
841
- choices: t.choices,
842
- onDeleteChoice: l,
843
- categoryId: t.id,
844
- extraStyles: { minHeight: "100px" },
845
- isAlternate: this.props.isAlternate
846
- }),
847
- c && /* @__PURE__ */ W(dt, { children: /* @__PURE__ */ W(qe, {
848
- label: "delete",
849
- onClick: c
850
- }) })
851
- ]
852
- });
853
- }
854
- }, ht = F("div")(({ theme: e }) => ({
855
- display: "flex",
856
- justifyContent: "space-between",
857
- marginBottom: e.spacing(1)
858
- })), gt = F("div")({
859
- display: "flex",
860
- alignItems: "center"
861
- }), _t = F(Ie)(({ theme: e }) => ({ "& .MuiTooltip-tooltip": {
862
- fontSize: e.typography.fontSize - 2,
863
- whiteSpace: "pre",
864
- maxWidth: "500px"
865
- } })), vt = class extends H.Component {
866
- static propTypes = {
867
- buttonLabel: K.default.string,
868
- onAdd: K.default.func.isRequired,
869
- label: K.default.string.isRequired,
870
- info: K.default.any,
871
- buttonDisabled: K.default.bool,
872
- variant: K.default.string,
873
- tooltip: K.default.string
874
- };
875
- static defaultProps = {};
876
- render() {
877
- let { onAdd: e, label: t, buttonLabel: n, info: r, buttonDisabled: i, variant: a, tooltip: o } = this.props;
878
- return /* @__PURE__ */ G(ht, { children: [/* @__PURE__ */ G(gt, { children: [/* @__PURE__ */ W(j, {
879
- variant: a || "title",
880
- children: t
881
- }), r] }), /* @__PURE__ */ W(_t, {
882
- title: o || "",
883
- enterTouchDelay: 50,
884
- leaveTouchDelay: 3e3,
885
- children: /* @__PURE__ */ W("span", { children: /* @__PURE__ */ W(Ge, {
886
- onClick: e,
887
- label: n,
888
- disabled: i
889
- }) })
890
- })] });
891
- }
892
- }, yt = (e) => {
893
- let { minChoices: t, maxChoices: n, maxCategories: r } = e || {};
894
- return t ||= 1, "Validation requirements:" + ("\nThe choices content should not be empty and should be unique.\nThere should be at least 1 " + (r ? `and at most ${r} ` : "") + "category" + (r ? "s" : "") + " defined." + (t ? `\nThere should be at least ${t} choices defined.` : "") + (n ? `\nNo more than ${n} choices should be defined.` : "") + "\nAt least one token should be assigned to at least one category.");
895
- }, Q = {
896
- enabled: "Yes",
897
- disabled: "No",
898
- perChoice: "Set Per Choice"
899
- }, bt = (e) => (e || []).reduce((e, t) => Math.max(e, t.length), 0), xt = (e) => {
900
- let { correctResponse: t = [] } = e || {};
901
- return t.reduce((e, t) => {
902
- let n = t?.choices?.length || 0, r = t?.alternateResponses || [], i = Math.max(n, bt(r));
903
- return i > e ? i : e;
904
- }, 0);
905
- };
906
- //#endregion
907
- //#region src/author/design/categories/RowLabel.tsx
908
- function St(e) {
909
- return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
910
- }
911
- function Ct(e, t) {
912
- return !e || St(e) ? e : St(e.default) ? e.default : t && St(e[t]) ? e[t] : t && St(e[t]?.default) ? e[t].default : e;
913
- }
914
- var wt = Ct(v, "InputContainer") || Ct(Dt.InputContainer, "InputContainer"), Tt = O, Et = Tt.default, Dt = Et && typeof Et == "object" ? Et : Tt, Ot = F(wt)(({ theme: e }) => ({
915
- width: "100%",
916
- paddingTop: e.spacing(1),
917
- marginTop: e.spacing(1)
918
- })), kt = ({ categoriesPerRow: e, configuration: t, disabled: n, markup: r, imageSupport: i, onChange: a, toolbarOpts: o, spellCheck: s, maxImageWidth: c, maxImageHeight: l, uploadSoundSupport: u, mathMlOptions: d = {} }) => {
919
- let { rowLabels: f, baseInputConfiguration: p } = t;
920
- return /* @__PURE__ */ W("div", {
921
- style: {
922
- gridColumn: `1/${e + 1}`,
923
- width: "100%"
924
- },
925
- children: /* @__PURE__ */ W(Ot, {
926
- label: "Row Label",
927
- children: /* @__PURE__ */ W(R, {
928
- disabled: n,
929
- markup: r,
930
- onChange: a,
931
- imageSupport: i,
932
- nonEmpty: !1,
933
- toolbarOpts: o,
934
- pluginProps: X(f?.inputConfiguration, p),
935
- spellCheck: s,
936
- maxImageWidth: c,
937
- maxImageHeight: l,
938
- uploadSoundSupport: u,
939
- languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
940
- mathMlOptions: d
941
- })
942
- })
943
- });
944
- }, At = F("div")(({ theme: e }) => ({ marginBottom: e.spacing(3) })), jt = F("div")(({ theme: e }) => ({
945
- display: "grid",
946
- gridRowGap: e.spacing(1),
947
- gridColumnGap: e.spacing(1)
948
- })), Mt = F(Ie)(({ theme: e }) => ({ "& .MuiTooltip-tooltip": {
949
- fontSize: e.typography.fontSize - 2,
950
- whiteSpace: "pre",
951
- maxWidth: "500px"
952
- } })), Nt = F("div")(({ theme: e }) => ({
953
- fontSize: e.typography.fontSize - 2,
954
- color: e.palette.error.main,
955
- paddingTop: e.spacing(.5)
956
- })), Pt = class extends H.Component {
957
- static propTypes = {
958
- defaultImageMaxHeight: K.default.number,
959
- defaultImageMaxWidth: K.default.number,
960
- imageSupport: K.default.shape({
961
- add: K.default.func.isRequired,
962
- delete: K.default.func.isRequired
963
- }),
964
- uploadSoundSupport: K.default.shape({
965
- add: K.default.func.isRequired,
966
- delete: K.default.func.isRequired
967
- }),
968
- categories: K.default.array,
969
- onModelChanged: K.default.func,
970
- model: K.default.object.isRequired,
971
- configuration: K.default.object.isRequired,
972
- toolbarOpts: K.default.object,
973
- spellCheck: K.default.bool
974
- };
975
- state = { focusedEl: null };
976
- add = () => {
977
- let { model: e, categories: t } = this.props, { categoriesPerRow: n, correctResponse: r, allowAlternateEnabled: i } = e, a = I.firstAvailableIndex(e.categories.map((e) => e.id), 1), o = {
978
- id: a,
979
- label: "Category " + a
980
- }, s = e.categories.length % n === 0, c = [...e.rowLabels];
981
- s && c.push(""), this.setState({ focusedEl: t.length }, () => {
982
- this.props.onModelChanged({
983
- rowLabels: c,
984
- categories: e.categories.concat([o]),
985
- correctResponse: i ? [...r, {
986
- category: a,
987
- choices: [],
988
- alternateResponses: []
989
- }] : r
990
- });
991
- });
992
- };
993
- deleteFocusedEl = () => {
994
- this.setState({ focusedEl: null });
995
- };
996
- delete = (e) => {
997
- let { model: t, onModelChanged: n } = this.props, r = t.categories.findIndex((t) => t.id === e.id);
998
- r !== -1 && (t.categories.splice(r, 1), t.correctResponse = f(e.id, t.correctResponse), n(t));
999
- };
1000
- change = (e) => {
1001
- let { categories: t } = this.props, n = t.findIndex((t) => t.id === e.id);
1002
- n !== -1 && (t.splice(n, 1, e), this.props.onModelChanged({ categories: t }));
1003
- };
1004
- deleteChoiceFromCategory = (e, t, n) => {
1005
- let { model: r, onModelChanged: i } = this.props;
1006
- i({ correctResponse: c(t.id, e.id, n, r.correctResponse) });
1007
- };
1008
- changeRowLabel = (e, t) => {
1009
- let { model: n } = this.props, { rowLabels: r } = n, i = [...r];
1010
- i.length < t ? i.push(e) : i[t] = e, this.props.onModelChanged({ rowLabels: i });
1011
- };
1012
- render() {
1013
- let { model: e, categories: t, imageSupport: n, uploadSoundSupport: r, toolbarOpts: i, spellCheck: a, configuration: o, defaultImageMaxHeight: s, defaultImageMaxWidth: c, mathMlOptions: l = {} } = this.props, { categoriesPerRow: u, rowLabels: d, errors: f } = e, { associationError: p, categoriesError: m, categoriesErrors: h } = f || {}, { maxCategories: g, maxImageWidth: _ = {}, maxImageHeight: v = {} } = o || {}, y = { gridTemplateColumns: `repeat(${u}, 1fr)` }, b = yt(o);
1014
- return /* @__PURE__ */ G(At, { children: [
1015
- /* @__PURE__ */ W(vt, {
1016
- label: "Categories",
1017
- buttonLabel: "ADD A CATEGORY",
1018
- onAdd: this.add,
1019
- info: /* @__PURE__ */ W(Mt, {
1020
- disableFocusListener: !0,
1021
- disableTouchListener: !0,
1022
- placement: "right",
1023
- title: b,
1024
- children: /* @__PURE__ */ W(Ve, {
1025
- fontSize: "small",
1026
- color: "primary",
1027
- style: { marginLeft: "5px" }
1028
- })
1029
- }),
1030
- buttonDisabled: g && t && g === t.length
1031
- }),
1032
- /* @__PURE__ */ W(jt, {
1033
- style: y,
1034
- children: t.map((e, t) => {
1035
- let f = t % u === 0, p = t / u;
1036
- return /* @__PURE__ */ G(H.Fragment, { children: [f && /* @__PURE__ */ W(kt, {
1037
- categoriesPerRow: u,
1038
- disabled: !1,
1039
- rowIndex: p,
1040
- markup: d[p] || "",
1041
- onChange: (e) => this.changeRowLabel(e, p),
1042
- imageSupport: n,
1043
- toolbarOpts: i,
1044
- spellCheck: a,
1045
- maxImageWidth: _ && _.rowLabel || c,
1046
- maxImageHeight: v && v.rowLabel || s,
1047
- uploadSoundSupport: r,
1048
- mathMlOptions: l,
1049
- configuration: o
1050
- }), /* @__PURE__ */ W(mt, {
1051
- imageSupport: n,
1052
- focusedEl: this.state.focusedEl,
1053
- deleteFocusedEl: this.deleteFocusedEl,
1054
- index: t,
1055
- category: e,
1056
- error: h && h[e.id],
1057
- onChange: this.change,
1058
- onDelete: () => this.delete(e),
1059
- toolbarOpts: i,
1060
- spellCheck: a,
1061
- onDeleteChoice: (t, n) => this.deleteChoiceFromCategory(e, t, n),
1062
- maxImageWidth: _ && _.categoryLabel || c,
1063
- maxImageHeight: v && v.categoryLabel || s,
1064
- uploadSoundSupport: r,
1065
- configuration: o,
1066
- alternateResponseIndex: void 0
1067
- })] }, t);
1068
- })
1069
- }),
1070
- p && /* @__PURE__ */ W(Nt, { children: p }),
1071
- m && /* @__PURE__ */ W(Nt, { children: m })
1072
- ] });
1073
- }
1074
- }, Ft = F("div")(({ theme: e }) => ({ marginBottom: e.spacing(2.5) })), It = F("div")(({ theme: e }) => ({
1075
- display: "grid",
1076
- gridRowGap: e.spacing(1),
1077
- gridColumnGap: e.spacing(1)
1078
- })), Lt = F("div")({ gridColumn: "1 / 3" }), Rt = class extends H.Component {
1079
- static propTypes = {
1080
- altIndex: K.default.number.isRequired,
1081
- configuration: K.default.object,
1082
- imageSupport: K.default.shape({
1083
- add: K.default.func.isRequired,
1084
- delete: K.default.func.isRequired
1085
- }),
1086
- categories: K.default.array,
1087
- onModelChanged: K.default.func,
1088
- model: K.default.object.isRequired,
1089
- uploadSoundSupport: K.default.shape({
1090
- add: K.default.func.isRequired,
1091
- delete: K.default.func.isRequired
1092
- }),
1093
- spellCheck: K.default.bool
1094
- };
1095
- deleteChoiceFromCategory = (e, t, n) => {
1096
- let { model: r, altIndex: i, onModelChanged: a } = this.props;
1097
- a({ correctResponse: o(t.id, e.id, n, i, r.correctResponse) });
1098
- };
1099
- render() {
1100
- let { altIndex: e, model: t, configuration: n, categories: r, imageSupport: i, spellCheck: a, uploadSoundSupport: o, mathMlOptions: s = {} } = this.props, { categoriesPerRow: c, errors: l, rowLabels: u } = t, { duplicateAlternate: d } = l || {}, f = { gridTemplateColumns: `repeat(${c}, 1fr)` }, p = d ? d.index === e : !1;
1101
- return /* @__PURE__ */ W(Ft, { children: /* @__PURE__ */ W(It, {
1102
- style: f,
1103
- children: r.map((t, r) => {
1104
- let l = r % c === 0, f = r / c;
1105
- return /* @__PURE__ */ G(H.Fragment, { children: [l && /* @__PURE__ */ W(Lt, {
1106
- style: {
1107
- gridColumn: `1/${c + 1}`,
1108
- width: "100%"
1109
- },
1110
- dangerouslySetInnerHTML: { __html: u[f] || "" }
1111
- }), /* @__PURE__ */ W(mt, {
1112
- alternateResponseIndex: e,
1113
- imageSupport: i,
1114
- isDuplicated: p && d.category === t.id,
1115
- category: t,
1116
- spellCheck: a,
1117
- onDeleteChoice: (e, n) => this.deleteChoiceFromCategory(t, e, n),
1118
- uploadSoundSupport: o,
1119
- mathMlOptions: s,
1120
- configuration: n,
1121
- isAlternate: !0
1122
- }, r)] }, r);
1123
- })
1124
- }) });
1125
- }
1126
- }, zt = y(/*#__PURE__*/ W("path", { d: "M20 9H4v2h16zM4 15h16v-2H4z" }), "DragHandle");
1127
- //#endregion
1128
- //#region src/author/design/choices/choice.tsx
1129
- (0, it.default)("@pie-element:categorize:configure:choice");
1130
- var Bt = (e) => {
1131
- if (e.lockChoiceOrder) return !0;
1132
- let t = e.choice.categoryCount || 0;
1133
- return t === 0 ? !0 : e.correctResponseCount < t;
1134
- }, Vt = F(ve)(({ theme: e }) => ({
1135
- minWidth: "196px",
1136
- padding: e.spacing(1),
1137
- overflow: "visible"
1138
- })), Ht = F(Te)({
1139
- padding: 0,
1140
- justifyContent: "space-between"
1141
- }), Ut = F("span", { shouldForwardProp: (e) => e !== "draggable" })(({ draggable: e }) => ({
1142
- cursor: e ? "move" : "inherit",
1143
- touchAction: "none"
1144
- })), Wt = F("div")(({ theme: e }) => ({
1145
- fontSize: e.typography.fontSize - 2,
1146
- color: e.palette.error.main,
1147
- paddingBottom: e.spacing(1)
1148
- })), Gt = ({ allowMultiplePlacements: e, configuration: t, choice: n, deleteFocusedEl: r, focusedEl: i, index: a, onDelete: o, onChange: s, correctResponseCount: c, lockChoiceOrder: l, imageSupport: u, spellCheck: d, toolbarOpts: f, error: p, maxImageWidth: m, maxImageHeight: h, uploadSoundSupport: g }) => {
1149
- let _ = Bt({
1150
- choice: n,
1151
- correctResponseCount: c,
1152
- lockChoiceOrder: l
1153
- }), { attributes: v, listeners: y, setNodeRef: b, isDragging: x } = ye({
1154
- id: `choice-${n.id}`,
1155
- data: {
1156
- id: n.id,
1157
- index: a,
1158
- type: "choice"
1159
- },
1160
- disabled: !_
1161
- }), { setNodeRef: ee } = B({
1162
- id: `choice-drop-${n.id}`,
1163
- data: {
1164
- id: n.id,
1165
- index: a,
1166
- type: "choice"
1167
- }
1168
- }), S = (e) => {
1169
- n.content = e, s(n);
1170
- }, C = () => {
1171
- n.categoryCount === 1 ? n.categoryCount = 0 : n.categoryCount = 1, s(n);
1172
- }, te = ((e) => e === Q.perChoice)(e);
1173
- return /* @__PURE__ */ G(Vt, {
1174
- ref: (e) => {
1175
- b(e), ee(e);
1176
- },
1177
- style: { opacity: x ? .5 : 1 },
1178
- children: [
1179
- /* @__PURE__ */ W(Ht, { children: /* @__PURE__ */ W(Ut, {
1180
- draggable: _,
1181
- ...v,
1182
- ...y,
1183
- children: /* @__PURE__ */ W(zt, { color: _ ? "primary" : "disabled" })
1184
- }) }),
1185
- /* @__PURE__ */ W(Ue, {
1186
- imageSupport: u,
1187
- focusedEl: i,
1188
- deleteFocusedEl: r,
1189
- index: a,
1190
- label: n.content,
1191
- onChange: S,
1192
- onDelete: o,
1193
- toolbarOpts: f,
1194
- spellCheck: d,
1195
- error: p,
1196
- maxImageWidth: m,
1197
- maxImageHeight: h,
1198
- uploadSoundSupport: g,
1199
- configuration: t
1200
- }),
1201
- p && /* @__PURE__ */ W(Wt, { children: p }),
1202
- /* @__PURE__ */ G(Ht, { children: [/* @__PURE__ */ W(qe, {
1203
- label: "delete",
1204
- onClick: o
1205
- }), te && /* @__PURE__ */ W(ce, {
1206
- mini: !0,
1207
- label: "Remove after placing",
1208
- checked: n.categoryCount === 1,
1209
- onChange: C
1210
- })] })
1211
- ]
1212
- });
1213
- };
1214
- Gt.propTypes = {
1215
- allowMultiplePlacements: K.default.string,
1216
- configuration: K.default.object.isRequired,
1217
- choice: K.default.object.isRequired,
1218
- deleteFocusedEl: K.default.func,
1219
- focusedEl: K.default.number,
1220
- index: K.default.number,
1221
- lockChoiceOrder: K.default.bool,
1222
- maxImageHeight: K.default.object,
1223
- maxImageWidth: K.default.object,
1224
- onChange: K.default.func.isRequired,
1225
- onDelete: K.default.func.isRequired,
1226
- correctResponseCount: K.default.number.isRequired,
1227
- imageSupport: K.default.shape({
1228
- add: K.default.func.isRequired,
1229
- delete: K.default.func.isRequired
1230
- }),
1231
- toolbarOpts: K.default.object,
1232
- error: K.default.string,
1233
- uploadSoundSupport: K.default.shape({
1234
- add: K.default.func.isRequired,
1235
- delete: K.default.func.isRequired
1236
- }),
1237
- spellCheck: K.default.bool,
1238
- rearrangeChoices: K.default.func
1239
- };
1240
- var Kt = N.withUid(Gt), qt = F("div")(({ theme: e }) => ({
1241
- paddingTop: e.spacing(1),
1242
- marginBottom: e.spacing(1)
1243
- })), Jt = F(pe)({ width: "100%" }), Yt = class extends H.Component {
1244
- static propTypes = {
1245
- config: K.default.object,
1246
- onModelChanged: K.default.func,
1247
- spellCheck: K.default.bool
1248
- };
1249
- static defaultProps = {};
1250
- changeLabel = ({ target: e }) => {
1251
- this.props.onModelChanged({ choicesLabel: e.value });
1252
- };
1253
- render() {
1254
- let { config: e, spellCheck: t } = this.props;
1255
- return /* @__PURE__ */ W(qt, { children: /* @__PURE__ */ W(Jt, {
1256
- InputLabelProps: { shrink: !0 },
1257
- variant: "outlined",
1258
- label: "Label",
1259
- value: e.choicesLabel,
1260
- onChange: this.changeLabel,
1261
- spellCheck: t
1262
- }) });
1263
- }
1264
- }, Xt = F("div")(({ theme: e }) => ({ marginBottom: e.spacing(2.5) })), Zt = F("div")(({ theme: e }) => ({
1265
- paddingTop: e.spacing(1),
1266
- paddingBottom: e.spacing(1),
1267
- display: "grid",
1268
- gridRowGap: e.spacing(1),
1269
- gridColumnGap: e.spacing(1)
1270
- })), Qt = F("div")(({ theme: e }) => ({
1271
- fontSize: e.typography.fontSize - 2,
1272
- color: e.palette.error.main,
1273
- paddingTop: e.spacing(.5)
1274
- })), $t = class extends H.Component {
1275
- static propTypes = {
1276
- model: K.default.object.isRequired,
1277
- configuration: K.default.object.isRequired,
1278
- choices: K.default.array.isRequired,
1279
- defaultImageMaxWidth: K.default.number,
1280
- defaultImageMaxHeight: K.default.number,
1281
- onModelChanged: K.default.func.isRequired,
1282
- imageSupport: K.default.shape({
1283
- add: K.default.func.isRequired,
1284
- delete: K.default.func.isRequired
1285
- }),
1286
- uploadSoundSupport: K.default.shape({
1287
- add: K.default.func.isRequired,
1288
- delete: K.default.func.isRequired
1289
- }),
1290
- toolbarOpts: K.default.object,
1291
- spellCheck: K.default.bool
1292
- };
1293
- static defaultProps = {};
1294
- state = { focusedEl: null };
1295
- changeChoice = (e) => {
1296
- let { choices: t, onModelChanged: n } = this.props, r = t.findIndex((t) => t.id === e.id);
1297
- r !== -1 && (t.splice(r, 1, e), n({ choices: t }));
1298
- };
1299
- allChoicesHaveCount = (e) => {
1300
- let { choices: t } = this.props;
1301
- return Array.isArray(t) && t.every((t) => t.categoryCount === e);
1302
- };
1303
- addChoice = () => {
1304
- let { onModelChanged: e, model: t, choices: n } = this.props, { maxAnswerChoices: r } = t || {};
1305
- if (r && t.choices?.length >= r) return;
1306
- let i = I.firstAvailableIndex(t.choices.map((e) => e.id), 1), a = {
1307
- id: i,
1308
- content: "Choice " + i
1309
- };
1310
- this.setState({ focusedEl: n.length }, () => {
1311
- e({ choices: t.choices.concat([a]) });
1312
- });
1313
- };
1314
- deleteFocusedEl = () => {
1315
- this.setState({ focusedEl: null });
1316
- };
1317
- deleteChoice = (e) => {
1318
- let { model: t, onModelChanged: n } = this.props, i = t.choices.findIndex((t) => t.id === e.id);
1319
- i !== -1 && (t.choices.splice(i, 1), t.correctResponse = r(e.id, t.correctResponse), n(t));
1320
- };
1321
- render() {
1322
- let { focusedEl: e } = this.state, { choices: t, model: n, imageSupport: r, uploadSoundSupport: i, onModelChanged: a, spellCheck: o, toolbarOpts: s, configuration: c, defaultImageMaxWidth: l, defaultImageMaxHeight: u } = this.props, { errors: d, allowMultiplePlacementsEnabled: f, lockChoiceOrder: p, maxAnswerChoices: m } = n, { choicesError: h, choicesErrors: g } = d || {}, { maxImageWidth: _ = {}, maxImageHeight: v = {} } = c || {}, y = { gridTemplateColumns: `repeat(${n.categoriesPerRow}, 1fr)` }, b = m && t?.length >= m ? `Only ${m} allowed maximum` : "";
1323
- return /* @__PURE__ */ G(Xt, { children: [
1324
- /* @__PURE__ */ W(vt, {
1325
- label: "Choices",
1326
- buttonLabel: "ADD A CHOICE",
1327
- onAdd: this.addChoice,
1328
- buttonDisabled: m && t && t?.length >= m,
1329
- tooltip: b
1330
- }),
1331
- /* @__PURE__ */ W(Yt, {
1332
- config: n,
1333
- onModelChanged: a,
1334
- spellCheck: o
1335
- }),
1336
- /* @__PURE__ */ W(Zt, {
1337
- style: y,
1338
- children: t.map((t, n) => /* @__PURE__ */ W(Kt, {
1339
- choice: t,
1340
- focusedEl: e,
1341
- deleteFocusedEl: this.deleteFocusedEl,
1342
- correctResponseCount: t.correctResponseCount,
1343
- allowMultiplePlacements: f,
1344
- lockChoiceOrder: p,
1345
- index: n,
1346
- imageSupport: r,
1347
- onChange: this.changeChoice,
1348
- onDelete: () => this.deleteChoice(t),
1349
- toolbarOpts: s,
1350
- spellCheck: o,
1351
- error: g && g[t.id],
1352
- maxImageWidth: _ && _.choice || l,
1353
- maxImageHeight: v && v.choice || u,
1354
- uploadSoundSupport: i,
1355
- configuration: c
1356
- }, t.id))
1357
- }),
1358
- h && /* @__PURE__ */ W(Qt, { children: h })
1359
- ] });
1360
- }
1361
- }, en = (e, t, n) => i(e).map((e) => {
1362
- let r = n.find((t) => t.category === e.id);
1363
- return r && (e.choices = (r.choices || []).map((e) => {
1364
- let n = t.find((t) => t.id === e);
1365
- if (n) return Object.assign({}, {
1366
- id: n.id,
1367
- content: n.content
1368
- });
1369
- })), e;
1370
- }), tn = (e, t, n) => !e.alternateResponses || e.alternateResponses.length === 0 ? [] : (e.alternateResponses[n] || []).map((e) => t.find((t) => t.id === e)), nn = (e, t, n) => {
1371
- let r = n.reduce((e, t) => t.alternateResponses && t.alternateResponses.length >= e ? t.alternateResponses.length : e, 0);
1372
- return Array(r).fill(0).map((r, i) => n.map((n, r) => {
1373
- let a = e[r];
1374
- return {
1375
- id: a.id,
1376
- label: a.label,
1377
- choices: tn(n, t, i)
1378
- };
1379
- }));
1380
- }, { translator: rn } = e, { dropdown: an, Panel: on, toggle: $, radio: sn, numberField: cn } = P, { Provider: ln } = N, un = class extends H.Component {
1381
- containerRef = H.createRef();
1382
- componentDidMount() {
1383
- this.containerRef.current && setTimeout(() => L(this.containerRef.current), 0);
1384
- }
1385
- render() {
1386
- return /* @__PURE__ */ W("div", {
1387
- ref: this.containerRef,
1388
- children: this.props.children
1389
- });
1390
- }
1391
- }, dn = F(vt)(({ theme: e }) => ({ marginBottom: e.spacing(2) })), fn = F(z)(({ theme: e }) => ({
1392
- width: "100%",
1393
- paddingTop: e.spacing(1),
1394
- marginTop: e.spacing(1),
1395
- marginBottom: e.spacing(2)
1396
- })), pn = F("div")(({ theme: e }) => ({
1397
- fontSize: e.typography.fontSize - 2,
1398
- color: e.palette.error.main,
1399
- paddingTop: e.spacing(1)
1400
- })), mn = class extends H.Component {
1401
- static propTypes = {
1402
- configuration: K.default.object,
1403
- className: K.default.string,
1404
- onConfigurationChanged: K.default.func,
1405
- model: K.default.object.isRequired,
1406
- onChange: K.default.func.isRequired,
1407
- uid: K.default.string,
1408
- imageSupport: K.default.shape({
1409
- add: K.default.func.isRequired,
1410
- delete: K.default.func.isRequired
1411
- }),
1412
- uploadSoundSupport: K.default.shape({
1413
- add: K.default.func.isRequired,
1414
- delete: K.default.func.isRequired
1415
- })
1416
- };
1417
- constructor(e) {
1418
- super(e), this.uid = e.uid || N.generateId(), this.state = { activeDragItem: null };
1419
- }
1420
- updateModel = (e) => {
1421
- let { model: t, onChange: n } = this.props, r = {
1422
- ...t,
1423
- ...e
1424
- };
1425
- r.choices = r.choices.map((e) => ({
1426
- ...e,
1427
- categoryCount: this.checkAllowMultiplePlacements(r.allowMultiplePlacementsEnabled, e)
1428
- })), r.correctResponse = u(r.correctResponse || [], r.choices), r.correctResponse = a(r.correctResponse || [], r.choices), r.categories = r.categories.map((e) => ({
1429
- id: e.id,
1430
- label: e.label
1431
- })), r.choices = r.choices.map((e) => ({
1432
- id: e.id,
1433
- content: e.content,
1434
- categoryCount: e.categoryCount
1435
- })), r.maxChoicesPerCategory = r.allowMaxChoicesPerCategory ? r.maxChoicesPerCategory : 0, n(r);
1436
- };
1437
- changeRationale = (e) => {
1438
- let { model: t, onChange: n } = this.props;
1439
- n({
1440
- ...t,
1441
- rationale: e
1442
- });
1443
- };
1444
- changeTeacherInstructions = (e) => {
1445
- let { model: t, onChange: n } = this.props;
1446
- n({
1447
- ...t,
1448
- teacherInstructions: e
1449
- });
1450
- };
1451
- changeFeedback = (e) => {
1452
- this.updateModel({ feedback: e });
1453
- };
1454
- onAddAlternateResponse = () => {
1455
- let { model: { correctResponse: e } } = this.props;
1456
- this.updateModel({ correctResponse: (e || []).map((e) => ({
1457
- ...e,
1458
- alternateResponses: [...e.alternateResponses || [], []]
1459
- })) });
1460
- };
1461
- onPromptChanged = (e) => this.updateModel({ prompt: e });
1462
- onRemoveAlternateResponse = (e) => {
1463
- let { model: { correctResponse: t } } = this.props;
1464
- this.updateModel({ correctResponse: (t || []).map((t) => ({
1465
- ...t,
1466
- alternateResponses: (t.alternateResponses || []).filter((t, n) => n !== e)
1467
- })) });
1468
- };
1469
- countChoiceInCorrectResponse = (e) => {
1470
- let { model: t } = this.props;
1471
- return s(e.id, t.correctResponse);
1472
- };
1473
- checkAllowMultiplePlacements = (e, t) => e === Q.enabled ? 0 : e === Q.disabled ? 1 : t.categoryCount || 0;
1474
- isAlertModalOpened = () => {
1475
- let { model: e } = this.props, { maxChoicesPerCategory: t = 0 } = e || {}, n = xt(e);
1476
- return t === 0 ? !1 : n > t;
1477
- };
1478
- onAlertModalCancel = () => {
1479
- let { model: e } = this.props, t = xt(e);
1480
- this.updateModel({ maxChoicesPerCategory: t });
1481
- };
1482
- onDragStart = (e) => {
1483
- let { active: t } = e, n = t.data.current;
1484
- this.setState({ activeDragItem: n });
1485
- };
1486
- onDragEnd = ({ active: e, over: t }) => {
1487
- let n = window.scrollX, r = window.scrollY;
1488
- if (this.setState({ activeDragItem: null }), !e) return;
1489
- requestAnimationFrame(() => {
1490
- requestAnimationFrame(() => {
1491
- window.scrollTo(n, r);
1492
- });
1493
- });
1494
- let { model: i } = this.props, { allowAlternateEnabled: a, categories: o = [], choices: s = [] } = i, c = e?.data?.current, l = t?.data?.current;
1495
- if (!c) return;
1496
- let u = c.choiceIndex || 0, d = l?.type, f = c.type === "choice-preview", p = c.type === "choice", m = c.choice?.id || (typeof c.id == "string" ? c.id.split("-")[0] : c.id);
1497
- if (f && (!l || d === "choice")) {
1498
- this.removeChoiceFromSource(c, u, {
1499
- allowAlternateEnabled: a,
1500
- categories: o,
1501
- choices: s
1502
- });
1503
- return;
1504
- }
1505
- if (f && d === "category") return this.moveChoice(m, c.categoryId, l.id, u);
1506
- if (p && d === "category") return this.addChoiceToCategory({ id: c.id }, l.id);
1507
- if (f && d === "category-alternate") return this.moveChoiceInAlternate(m, c.categoryId, l.id, u, l.alternateResponseIndex);
1508
- if (a && p && d === "category-alternate") return this.addChoiceToAlternateCategory({ id: c.id }, l.id, l.alternateResponseIndex);
1509
- };
1510
- removeChoiceFromSource = (e, t, { allowAlternateEnabled: n, categories: r, choices: i }) => {
1511
- if (e.alternateResponseIndex === void 0) {
1512
- this.deleteChoiceFromCategory(e.categoryId, e.choiceId, t);
1513
- return;
1514
- }
1515
- if (!n) return;
1516
- let a = r?.find((t) => t.id === e.categoryId), o = i?.find((t) => t.id === e.choiceId);
1517
- a && o && this.deleteChoiceFromAlternateCategory(a, o, t, e.alternateResponseIndex);
1518
- };
1519
- addChoiceToCategory = (e, t) => {
1520
- let { model: n } = this.props, { choices: r = [], correctResponse: i = [], maxChoicesPerCategory: a = 0 } = n || {}, o = (r || []).find((t) => t.id === e.id), s = d(e.id, void 0, t, 0, i);
1521
- o.categoryCount !== 0 && (s = l(e, t, s));
1522
- let c = xt(n);
1523
- this.updateModel({
1524
- correctResponse: s,
1525
- maxChoicesPerCategory: a !== 0 && a < c ? a + 1 : a
1526
- });
1527
- };
1528
- deleteChoiceFromCategory = (e, t, n) => {
1529
- let { model: r } = this.props, i = c(t, e, n, r.correctResponse);
1530
- this.updateModel({ correctResponse: i });
1531
- };
1532
- moveChoice = (e, t, n, r) => {
1533
- let { model: i } = this.props, { choices: a, correctResponse: o = [], maxChoicesPerCategory: s = 0 } = i || {}, c = (a || []).find((t) => t.id === e);
1534
- if (n === t || !c) return;
1535
- c.categoryCount === 0 ? c.categoryCount === 0 && (o = d(c.id, void 0, n, 0, o)) : (o = d(c.id, t, n, r, o), o = l(c, n, o));
1536
- let u = xt(i);
1537
- this.updateModel({
1538
- correctResponse: o,
1539
- maxChoicesPerCategory: s !== 0 && s < u ? s + 1 : s
1540
- });
1541
- };
1542
- addChoiceToAlternateCategory = (e, t, n) => {
1543
- let { model: r } = this.props, { correctResponse: i, choices: a, maxChoicesPerCategory: o = 0 } = r, s = a.find((t) => t.id === e.id);
1544
- i.forEach((r) => r.category === t ? (r.alternateResponses = r.alternateResponses || [], r.alternateResponses[n] === void 0 && (r.alternateResponses[n] = []), r.alternateResponses[n].push(e.id), s.categoryCount && s.categoryCount !== 0 && (r.alternateResponses[n] = r.alternateResponses[n].reduce((e, t) => (t === s.id ? e.findIndex((e) => e === s.id) === -1 && e.push(t) : e.push(t), e), [])), r) : (r.alternateResponses[n] && s.categoryCount !== 0 && (r.alternateResponses[n] = r.alternateResponses[n].filter((t) => t !== e.id)), r));
1545
- let c = xt(r);
1546
- this.updateModel({
1547
- correctResponse: i,
1548
- maxChoicesPerCategory: o !== 0 && o < c ? o + 1 : o
1549
- });
1550
- };
1551
- moveChoiceInAlternate = (e, t, n, r, i) => {
1552
- let { model: a } = this.props, { choices: o, correctResponse: s = [], maxChoicesPerCategory: c = 0 } = a || {}, l = (o || []).find((t) => t.id === e);
1553
- s = p(e, t, n, r, s, i, l?.categoryCount);
1554
- let u = xt(a);
1555
- this.updateModel({
1556
- correctResponse: s,
1557
- maxChoicesPerCategory: c !== 0 && c < u ? c + 1 : c
1558
- });
1559
- };
1560
- deleteChoiceFromAlternateCategory = (e, t, n, r) => {
1561
- let { model: i } = this.props, a = o(t.id, e.id, n, r, i.correctResponse);
1562
- this.updateModel({ correctResponse: a });
1563
- };
1564
- renderDragOverlay = () => {
1565
- let { activeDragItem: e } = this.state, { model: t, configuration: n } = this.props;
1566
- if (!e) return null;
1567
- if (e.type === "choice") {
1568
- let r = t.choices?.find((t) => t.id === e.id);
1569
- return r ? /* @__PURE__ */ W(Kt, {
1570
- choice: r,
1571
- configuration: n
1572
- }) : null;
1573
- } else if (e.type === "choice-preview" && e.alternateResponseIndex === void 0) {
1574
- let n = t.choices?.find((t) => t.id === e.id);
1575
- return n ? /* @__PURE__ */ W(rt, { choice: n }) : null;
1576
- } else if (e.type === "choice-preview" && e.alternateResponseIndex !== void 0) {
1577
- let n = t.choices?.find((t) => t.id === e.id);
1578
- return n ? /* @__PURE__ */ W(rt, {
1579
- choice: n,
1580
- alternateResponseIndex: e.alternateResponseIndex
1581
- }) : null;
1582
- }
1583
- return null;
1584
- };
1585
- render() {
1586
- let { configuration: e, imageSupport: t, model: n, uploadSoundSupport: r, onConfigurationChanged: i } = this.props, { allowAlternate: a = {}, allowMultiplePlacements: o = {}, baseInputConfiguration: s = {}, categoriesPerRow: c = {}, choicesPosition: l = {}, contentDimensions: u = {}, feedback: d = {}, lockChoiceOrder: f = {}, maxImageHeight: p = {}, maxImageWidth: m = {}, maxPlacements: h = {}, minCategoriesPerRow: g = 1, partialScoring: _ = {}, prompt: v = {}, rationale: y = {}, scoringType: b = {}, settingsPanelDisabled: x, spellCheck: ee = {}, studentInstructions: S = {}, teacherInstructions: C = {}, withRubric: te = {}, mathMlOptions: w = {}, language: T = {}, languageChoices: E = {}, allowMaxAnswerChoices: D = {} } = e || {}, { allowAlternateEnabled: ne, allowMaxChoicesPerCategory: re, errors: ie, feedbackEnabled: ae, maxChoicesPerCategory: oe, promptEnabled: ce, rationaleEnabled: O, spellCheckEnabled: A, teacherInstructionsEnabled: le, toolbarEditorPosition: j, extraCSSRules: ue } = n || {}, { prompt: M, rationale: pe, teacherInstructions: N } = ie || {}, P = { position: j === "top" ? "top" : "bottom" }, me = n.config || {};
1587
- me.choices = me.choices || {
1588
- label: "",
1589
- columns: 2
1590
- };
1591
- let ge = en(n.categories || [], n.choices || [], n.correctResponse || []), F = nn(n.categories || [], n.choices || [], n.correctResponse || []), I = n.choices.map((e) => (e.correctResponseCount = this.countChoiceInCorrectResponse(e), e.categoryCount = this.checkAllowMultiplePlacements(n.allowMultiplePlacementsEnabled, e), e)), L = m && m.prompt, z = p && p.prompt, _e = {
1592
- partialScoring: _.settings && $(_.label),
1593
- lockChoiceOrder: f.settings && $(f.label),
1594
- categoriesPerRow: c.settings && cn(c.label, {
1595
- label: c.label,
1596
- min: g,
1597
- max: 6
1598
- }),
1599
- choicesPosition: l.settings && sn(l.label, [
1600
- "below",
1601
- "above",
1602
- "left",
1603
- "right"
1604
- ]),
1605
- allowMultiplePlacementsEnabled: o.settings && an(o.label, [
1606
- Q.enabled,
1607
- Q.disabled,
1608
- Q.perChoice
1609
- ]),
1610
- maxAnswerChoices: D.settings && cn(D.label, {
1611
- label: "",
1612
- min: I?.length || 0,
1613
- max: 30
1614
- }),
1615
- allowMaxChoicesPerCategory: h.settings && $(h.label),
1616
- maxChoicesPerCategory: re === !0 && cn(h.label, {
1617
- label: "",
1618
- min: 0,
1619
- max: 30
1620
- }),
1621
- promptEnabled: v.settings && $(v.label),
1622
- feedbackEnabled: d.settings && $(d.label),
1623
- allowAlternateEnabled: a.settings && $(a.label),
1624
- "language.enabled": T.settings && $(T.label, !0),
1625
- language: T.settings && T.enabled && an(E.label, E.options)
1626
- }, ve = {
1627
- teacherInstructionsEnabled: C.settings && $(C.label),
1628
- studentInstructionsEnabled: S.settings && $(S.label),
1629
- rationaleEnabled: y.settings && $(y.label),
1630
- spellCheckEnabled: ee.settings && $(ee.label),
1631
- scoringType: b.settings && sn(b.label, ["auto", "rubric"]),
1632
- rubricEnabled: te?.settings && $(te?.label)
1633
- }, ye = this.isAlertModalOpened(), B = rn.t("translation:categorize:maxChoicesPerCategoryRestriction", {
1634
- lng: n.language,
1635
- maxChoicesPerCategory: oe
1636
- });
1637
- return /* @__PURE__ */ W(de, {
1638
- onDragStart: this.onDragStart,
1639
- onDragEnd: this.onDragEnd,
1640
- children: /* @__PURE__ */ G(ln, {
1641
- value: this.uid,
1642
- children: [/* @__PURE__ */ G(fe.ConfigLayout, {
1643
- extraCSSRules: ue,
1644
- dimensions: u,
1645
- hideSettings: x,
1646
- settings: /* @__PURE__ */ W(on, {
1647
- model: n,
1648
- onChangeModel: this.updateModel,
1649
- configuration: e,
1650
- onChangeConfiguration: i,
1651
- groups: {
1652
- Settings: _e,
1653
- Properties: ve
1654
- },
1655
- modal: /* @__PURE__ */ W(k, {
1656
- title: "Warning",
1657
- text: B,
1658
- open: ye,
1659
- onClose: this.onAlertModalCancel
1660
- })
1661
- }),
1662
- children: [
1663
- le && /* @__PURE__ */ G(fn, {
1664
- label: C.label,
1665
- children: [/* @__PURE__ */ W(R, {
1666
- markup: n.teacherInstructions || "",
1667
- onChange: this.changeTeacherInstructions,
1668
- imageSupport: t,
1669
- error: N,
1670
- nonEmpty: !1,
1671
- toolbarOpts: P,
1672
- pluginProps: X(C?.inputConfiguration, s),
1673
- spellCheck: A,
1674
- maxImageWidth: m && m.teacherInstructions || L,
1675
- maxImageHeight: p && p.teacherInstructions || z,
1676
- uploadSoundSupport: r,
1677
- languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
1678
- mathMlOptions: w
1679
- }), N && /* @__PURE__ */ W(pn, { children: N })]
1680
- }),
1681
- ce && /* @__PURE__ */ G(fn, {
1682
- label: v.label,
1683
- children: [/* @__PURE__ */ W(R, {
1684
- markup: n.prompt || "",
1685
- onChange: this.onPromptChanged,
1686
- imageSupport: t,
1687
- error: M,
1688
- nonEmpty: !1,
1689
- disableUnderline: !0,
1690
- toolbarOpts: P,
1691
- pluginProps: X(v?.inputConfiguration, s),
1692
- spellCheck: A,
1693
- maxImageWidth: m && m.prompt,
1694
- maxImageHeight: p && p.prompt,
1695
- uploadSoundSupport: r,
1696
- languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
1697
- mathMlOptions: w
1698
- }), M && /* @__PURE__ */ W(pn, { children: M })]
1699
- }),
1700
- /* @__PURE__ */ W(Pt, {
1701
- imageSupport: t,
1702
- uploadSoundSupport: r,
1703
- model: n,
1704
- categories: ge || [],
1705
- onModelChanged: this.updateModel,
1706
- toolbarOpts: P,
1707
- spellCheck: A,
1708
- configuration: e,
1709
- defaultImageMaxWidth: L,
1710
- defaultImageMaxHeight: z,
1711
- mathMlOptions: w
1712
- }),
1713
- /* @__PURE__ */ W($t, {
1714
- imageSupport: t,
1715
- uploadSoundSupport: r,
1716
- choices: I,
1717
- model: n,
1718
- onModelChanged: this.updateModel,
1719
- toolbarOpts: P,
1720
- spellCheck: A,
1721
- configuration: e,
1722
- defaultImageMaxWidth: L,
1723
- defaultImageMaxHeight: z
1724
- }),
1725
- ne && /* @__PURE__ */ W(dn, {
1726
- label: "Alternate Responses",
1727
- buttonLabel: "ADD AN ALTERNATE RESPONSE",
1728
- onAdd: this.onAddAlternateResponse
1729
- }),
1730
- ne && F.map((i, a) => /* @__PURE__ */ G(H.Fragment, { children: [/* @__PURE__ */ W(dn, {
1731
- variant: "subtitle1",
1732
- label: "Alternate Response",
1733
- buttonLabel: "REMOVE ALTERNATE RESPONSE",
1734
- onAdd: () => this.onRemoveAlternateResponse(a)
1735
- }), /* @__PURE__ */ W(Rt, {
1736
- altIndex: a,
1737
- imageSupport: t,
1738
- model: n,
1739
- configuration: e,
1740
- categories: i,
1741
- onModelChanged: this.updateModel,
1742
- uploadSoundSupport: r,
1743
- mathMlOptions: w
1744
- })] }, a)),
1745
- O && /* @__PURE__ */ G(fn, {
1746
- label: y.label,
1747
- children: [/* @__PURE__ */ W(R, {
1748
- markup: n.rationale || "",
1749
- onChange: this.changeRationale,
1750
- imageSupport: t,
1751
- error: pe,
1752
- nonEmpty: !1,
1753
- toolbarOpts: P,
1754
- pluginProps: X(v?.inputConfiguration, s),
1755
- spellCheck: A,
1756
- maxImageWidth: m && m.rationale || L,
1757
- maxImageHeight: p && p.rationale || z,
1758
- uploadSoundSupport: r,
1759
- languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
1760
- mathMlOptions: w
1761
- }), pe && /* @__PURE__ */ W(pn, { children: pe })]
1762
- }),
1763
- ae && /* @__PURE__ */ W(he, {
1764
- feedback: n.feedback,
1765
- onChange: this.changeFeedback,
1766
- toolbarOpts: P
1767
- })
1768
- ]
1769
- }), /* @__PURE__ */ W(se, { children: /* @__PURE__ */ W(un, { children: this.renderDragOverlay() }) })]
1770
- })
1771
- });
1772
- }
1773
- }, hn = class extends H.Component {
1774
- static propTypes = {
1775
- configuration: K.default.object,
1776
- onConfigurationChanged: K.default.func,
1777
- model: K.default.object.isRequired,
1778
- onModelChanged: K.default.func.isRequired,
1779
- imageSupport: K.default.object,
1780
- uploadSoundSupport: K.default.object
1781
- };
1782
- static defaultProps = {};
1783
- render() {
1784
- let { model: e, onModelChanged: t, configuration: n, onConfigurationChanged: r, imageSupport: i, uploadSoundSupport: a } = this.props;
1785
- return /* @__PURE__ */ W(mn, {
1786
- imageSupport: i,
1787
- uploadSoundSupport: a,
1788
- title: "Design",
1789
- model: e,
1790
- configuration: n,
1791
- onChange: t,
1792
- onConfigurationChanged: r
1793
- });
1794
- }
1795
- }, gn = {
1796
- model: {
1797
- allowAlternateEnabled: !0,
1798
- allowMaxChoicesPerCategory: !1,
1799
- allowMultiplePlacementsEnabled: Q.enabled,
1800
- alternates: [],
1801
- categories: [],
1802
- categoriesPerRow: 2,
1803
- choices: [],
1804
- choicesLabel: "",
1805
- choicesPosition: "below",
1806
- correctResponse: [],
1807
- feedbackEnabled: !1,
1808
- lockChoiceOrder: !0,
1809
- maxAnswerChoices: 6,
1810
- maxChoicesPerCategory: 0,
1811
- partialScoring: !0,
1812
- promptEnabled: !0,
1813
- rationaleEnabled: !0,
1814
- rowLabels: [""],
1815
- studentInstructionsEnabled: !0,
1816
- teacherInstructionsEnabled: !0,
1817
- toolbarEditorPosition: "bottom",
1818
- minRowHeight: "80px"
1819
- },
1820
- configuration: {
1821
- baseInputConfiguration: {
1822
- h3: { disabled: !0 },
1823
- audio: { disabled: !1 },
1824
- video: { disabled: !1 },
1825
- image: { disabled: !1 },
1826
- textAlign: { disabled: !0 },
1827
- showParagraphs: { disabled: !1 },
1828
- separateParagraphs: { disabled: !0 }
1829
- },
1830
- spellCheck: {
1831
- label: "Spellcheck",
1832
- settings: !1,
1833
- enabled: !0
1834
- },
1835
- feedback: {
1836
- settings: !0,
1837
- label: "Feedback",
1838
- enabled: !0
1839
- },
1840
- lockChoiceOrder: {
1841
- settings: !0,
1842
- label: "Lock Choice Order"
1843
- },
1844
- choicesPosition: {
1845
- settings: !0,
1846
- label: "Choices Position"
1847
- },
1848
- allowMultiplePlacements: {
1849
- settings: !0,
1850
- label: "Allow Multiple Placements"
1851
- },
1852
- maxPlacements: {
1853
- settings: !0,
1854
- label: "Max choices per category"
1855
- },
1856
- allowAlternate: {
1857
- settings: !0,
1858
- label: "Allow Alternate Correct Answers"
1859
- },
1860
- categoriesPerRow: {
1861
- settings: !0,
1862
- label: "Categories per row"
1863
- },
1864
- partialScoring: {
1865
- settings: !1,
1866
- label: "Allow Partial Scoring"
1867
- },
1868
- prompt: {
1869
- settings: !0,
1870
- label: "Prompt",
1871
- required: !1,
1872
- inputConfiguration: {
1873
- audio: { disabled: !1 },
1874
- video: { disabled: !1 },
1875
- image: { disabled: !1 }
1876
- }
1877
- },
1878
- rationale: {
1879
- settings: !0,
1880
- label: "Rationale",
1881
- required: !1,
1882
- inputConfiguration: {
1883
- audio: { disabled: !1 },
1884
- video: { disabled: !1 },
1885
- image: { disabled: !1 }
1886
- }
1887
- },
1888
- scoringType: {
1889
- settings: !1,
1890
- label: "Scoring Type"
1891
- },
1892
- settingsPanelDisabled: !1,
1893
- studentInstructions: {
1894
- settings: !1,
1895
- label: "Student Instructions"
1896
- },
1897
- teacherInstructions: {
1898
- settings: !0,
1899
- label: "Teacher Instructions",
1900
- required: !1,
1901
- inputConfiguration: {
1902
- audio: { disabled: !1 },
1903
- video: { disabled: !1 },
1904
- image: { disabled: !1 }
1905
- }
1906
- },
1907
- headers: { inputConfiguration: {
1908
- audio: { disabled: !0 },
1909
- video: { disabled: !0 },
1910
- image: { disabled: !1 }
1911
- } },
1912
- rowLabels: { inputConfiguration: {
1913
- audio: { disabled: !1 },
1914
- video: { disabled: !1 },
1915
- image: { disabled: !1 }
1916
- } },
1917
- toolbarEditorPosition: {
1918
- settings: !1,
1919
- label: "Toolbar Editor Position"
1920
- },
1921
- maxImageWidth: {
1922
- teacherInstructions: 300,
1923
- prompt: 300,
1924
- rationale: 300,
1925
- rowLabel: 200,
1926
- categoryLabel: 260,
1927
- choices: 240
1928
- },
1929
- maxImageHeight: {
1930
- teacherInstructions: 300,
1931
- prompt: 300,
1932
- rationale: 300,
1933
- rowLabel: 100,
1934
- categoryLabel: 100,
1935
- choices: 150
1936
- },
1937
- withRubric: {
1938
- settings: !1,
1939
- label: "Add Rubric"
1940
- },
1941
- minCategoriesPerRow: 1,
1942
- allowMaxAnswerChoices: {
1943
- settings: !0,
1944
- label: "Max answer choices"
1945
- },
1946
- mathMlOptions: {
1947
- mmlOutput: !1,
1948
- mmlEditing: !1
1949
- },
1950
- language: {
1951
- settings: !1,
1952
- label: "Specify Language",
1953
- enabled: !1
1954
- },
1955
- languageChoices: {
1956
- label: "Language Choices",
1957
- options: []
1958
- }
1959
- }
1960
- }, _n = class e extends HTMLElement {
1961
- static createDefaultModel = (e = {}) => ({
1962
- ...gn.model,
1963
- ...e
1964
- });
1965
- static disableAlternateResponses = (e) => {
1966
- let { correctResponse: t } = e || {};
1967
- t ||= [];
1968
- let n = t.map((e) => {
1969
- let { alternateResponses: t, ...n } = e;
1970
- return n;
1971
- });
1972
- return {
1973
- ...e,
1974
- correctResponse: n,
1975
- allowAlternateEnabled: !1
1976
- };
1977
- };
1978
- constructor() {
1979
- super(), this._root = null, this._model = e.createDefaultModel(), this._configuration = gn.configuration;
1980
- }
1981
- set model(t) {
1982
- this._model = e.createDefaultModel(t), t.choices && t.choices.length >= t.maxAnswerChoices && (this._model.maxAnswerChoices = t.choices.length, console.warn("Max Answer Choices can't be less than choices length!")), this.render();
1983
- }
1984
- set configuration(e) {
1985
- let t = {
1986
- ...gn.configuration,
1987
- ...e
1988
- };
1989
- this._configuration = t, t?.language?.enabled ? t?.languageChoices?.options?.length && (this._model.language = t?.languageChoices.options[0].value) : t.language.settings && this._model.language ? (this._configuration.language.enabled = !0, (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) && (this._configuration.languageChoices.options = []), this._configuration.languageChoices.options.find((e) => e.value === this._model.language) || this._configuration.languageChoices.options.push({
1990
- value: this._model.language,
1991
- label: this._model.language
1992
- })) : delete this._model.language, this.render();
1993
- }
1994
- onModelChanged(e) {
1995
- this._model = e, this.render(), this.dispatchEvent(new Le(this._model, !1));
1996
- }
1997
- onConfigurationChanged(e) {
1998
- this._configuration = e, this.render();
1999
- }
2000
- connectedCallback() {
2001
- this.render();
2002
- }
2003
- insertImage(e) {
2004
- this.dispatchEvent(new ze(e));
2005
- }
2006
- onDeleteImage(e, t) {
2007
- this.dispatchEvent(new Re(e, t));
2008
- }
2009
- insertSound(e) {
2010
- this.dispatchEvent(new Be(e));
2011
- }
2012
- onDeleteSound(e, t) {
2013
- this.dispatchEvent(new Y(e, t));
2014
- }
2015
- render() {
2016
- let e = H.createElement(hn, {
2017
- model: this._model,
2018
- configuration: this._configuration,
2019
- onModelChanged: this.onModelChanged.bind(this),
2020
- onConfigurationChanged: this.onConfigurationChanged.bind(this),
2021
- imageSupport: {
2022
- add: this.insertImage.bind(this),
2023
- delete: this.onDeleteImage.bind(this)
2024
- },
2025
- uploadSoundSupport: {
2026
- add: this.insertSound.bind(this),
2027
- delete: this.onDeleteSound.bind(this)
2028
- }
2029
- });
2030
- this._root ||= U(this), this._root.render(e), setTimeout(() => {
2031
- L(this);
2032
- }, 0);
2033
- }
2034
- disconnectedCallback() {
2035
- this._root && this._root.unmount();
2036
- }
2037
- };
2038
- //#endregion
2039
- export { _n as default };
2040
-
2041
- //# sourceMappingURL=index.js.map