@pie-element/inline-dropdown 11.0.4-next.20261011174919 → 11.0.4

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.
@@ -4,83 +4,67 @@ import n from "./response-area.js";
4
4
  import r from "react";
5
5
  import { renderMath as i } from "@pie-element/shared-math-rendering-mathjax";
6
6
  import a from "react-dom";
7
- import o from "prop-types";
8
- import { cloneDeep as s, isEmpty as c, isEqual as l, isUndefined as u, max as d, reduce as f } from "@pie-element/shared-lodash";
9
- import { color as p } from "@pie-lib/render-ui";
10
- import { jsx as m, jsxs as h } from "react/jsx-runtime";
11
- import { styled as g } from "@mui/material/styles";
12
- import _, { ALL_PLUGINS as v, deleteInlineDropdownByIndex as y } from "@pie-lib/editable-html-tip-tap";
13
- import { AlertDialog as ee, InputContainer as b, layout as te, settings as x } from "@pie-lib/config-ui";
14
- import S from "@mui/material/Tooltip";
15
- import C from "@mui/material/Typography";
16
- import w from "@mui/material/Accordion";
17
- import ne from "@mui/material/AccordionSummary";
18
- import T from "@mui/material/AccordionDetails";
19
- import E from "@mui/icons-material/ExpandMore";
20
- import re from "@mui/icons-material/Info";
7
+ import { cloneDeep as o, isEmpty as s, isEqual as c, isUndefined as l, max as u, reduce as d } from "@pie-element/shared-lodash";
8
+ import { color as f } from "@pie-lib/render-ui";
9
+ import { jsx as p, jsxs as m } from "react/jsx-runtime";
10
+ import { styled as h } from "@mui/material/styles";
11
+ import g, { ALL_PLUGINS as ee, deleteInlineDropdownByIndex as _ } from "@pie-lib/editable-html-tip-tap";
12
+ import { AlertDialog as te, InputContainer as v, layout as y, settings as b } from "@pie-lib/config-ui";
13
+ import x from "@mui/material/Tooltip";
14
+ import S from "@mui/material/Typography";
15
+ import ne from "@mui/material/Accordion";
16
+ import re from "@mui/material/AccordionSummary";
17
+ import C from "@mui/material/AccordionDetails";
18
+ import w from "@mui/icons-material/ExpandMore";
19
+ import T from "@mui/icons-material/Info";
21
20
  //#region src/author/main.tsx
22
- var { toggle: D, Panel: ie, dropdown: ae } = x, O = g(b)(({ theme: e }) => ({
21
+ var { toggle: E, Panel: D, dropdown: ie } = b, O = h(v)(({ theme: e }) => ({
23
22
  width: "100%",
24
23
  paddingTop: e.spacing(2),
25
24
  marginBottom: e.spacing(2)
26
- })), oe = g(b)(({ theme: e }) => ({
25
+ })), ae = h(v)(({ theme: e }) => ({
27
26
  width: "100%",
28
27
  paddingTop: e.spacing(.5),
29
28
  marginBottom: e.spacing(2)
30
- })), k = g(C)(({ theme: e }) => ({
29
+ })), k = h(S)(({ theme: e }) => ({
31
30
  fontSize: e.typography.fontSize + 2,
32
31
  marginRight: e.spacing(1)
33
- })), se = g("span")(({ theme: e }) => ({
32
+ })), oe = h("span")(({ theme: e }) => ({
34
33
  display: "flex",
35
34
  alignItems: "center",
36
35
  whiteSpace: "break-spaces",
37
- color: p.disabled(),
36
+ color: f.disabled(),
38
37
  padding: 0,
39
38
  fontSize: e.typography.fontSize - 2,
40
39
  lineHeight: 1
41
- })), A = g("div")(({ theme: e }) => ({ marginBottom: e.spacing(2.5) })), j = g(T)({
40
+ })), se = h("div")(({ theme: e }) => ({ marginBottom: e.spacing(2.5) })), A = h(C)({
42
41
  display: "block",
43
42
  paddingTop: 0,
44
43
  paddingBottom: 0
45
- }), M = g("div")(({ theme: e }) => ({
44
+ }), j = h("div")(({ theme: e }) => ({
46
45
  display: "flex",
47
46
  alignItems: "center",
48
47
  marginBottom: e.spacing(1)
49
- })), N = g(S)(({ theme: e }) => ({ "& .MuiTooltip-tooltip": {
48
+ })), M = h(x)(({ theme: e }) => ({ "& .MuiTooltip-tooltip": {
50
49
  fontSize: e.typography.fontSize - 2,
51
50
  whiteSpace: "pre",
52
51
  maxWidth: "500px"
53
- } })), P = g("div")(({ theme: e }) => ({
52
+ } })), N = h("div")(({ theme: e }) => ({
54
53
  fontSize: e.typography.fontSize - 2,
55
54
  color: e.palette.error.main,
56
55
  paddingTop: e.spacing(1)
57
- })), F = (e) => {
56
+ })), P = (e) => {
58
57
  let t = document.createElement("div");
59
58
  return t.innerHTML = (e || "").trim(), t;
60
- }, I = class extends r.Component {
61
- static propTypes = {
62
- configuration: o.object.isRequired,
63
- model: o.object.isRequired,
64
- disableSidePanel: o.bool,
65
- onModelChanged: o.func.isRequired,
66
- onConfigurationChanged: o.func.isRequired,
67
- imageSupport: o.shape({
68
- add: o.func.isRequired,
69
- delete: o.func.isRequired
70
- }),
71
- uploadSoundSupport: o.shape({
72
- add: o.func.isRequired,
73
- delete: o.func.isRequired
74
- })
75
- };
59
+ }, F = class extends r.Component {
76
60
  state = { warning: { open: !1 } };
77
61
  componentDidMount() {
78
62
  let { model: { choices: e } } = this.props;
79
- this.setState({ respAreaChoices: s(e) });
63
+ this.setState({ respAreaChoices: o(e) });
80
64
  }
81
65
  UNSAFE_componentWillReceiveProps(e) {
82
66
  let t = {};
83
- (!l(e.model.choices, this.props.model.choices) || !l(e.model.choices, this.state.respAreaChoices)) && (t.respAreaChoices = s(e.model.choices)), c(t) || this.setState(t);
67
+ (!c(e.model.choices, this.props.model.choices) || !c(e.model.choices, this.state.respAreaChoices)) && (t.respAreaChoices = o(e.model.choices)), s(t) || this.setState(t);
84
68
  }
85
69
  componentDidUpdate() {
86
70
  i(a.findDOMNode(this));
@@ -120,31 +104,31 @@ var { toggle: D, Panel: ie, dropdown: ae } = x, O = g(b)(({ theme: e }) => ({
120
104
  } });
121
105
  };
122
106
  validateResponseAreaClose = (e, t, n, r, i) => {
123
- let { respAreaChoices: a } = this.state, o = e.attrs.index, s = a[o] || [];
107
+ let a = this.state.respAreaChoices, o = e.attrs.index, s = a[o] || [];
124
108
  if (!(s.length < 2 || !s.find((e) => e.correct))) {
125
109
  r();
126
110
  return;
127
111
  }
128
112
  n._holdInlineDropdownToolbarIndex = o, this.onCheck(() => {
129
- delete n._holdInlineDropdownToolbarIndex, y(n, o, t), r();
113
+ delete n._holdInlineDropdownToolbarIndex, _(n, o, t), r();
130
114
  }, i);
131
115
  };
132
116
  onChange = (e) => {
133
- let { respAreaChoices: t } = this.state, n = F(e), r = n.querySelectorAll("[data-type=\"inline_dropdown\"]"), i = {};
117
+ let t = this.state.respAreaChoices, n = P(e), r = n.querySelectorAll("[data-type=\"inline_dropdown\"]"), i = {};
134
118
  r.forEach((e) => {
135
119
  i[e.dataset.index] = e.dataset.value || "";
136
120
  });
137
- let a = f(t, (e, n, r) => (u(i[r]) || (e[r] = t[r]), e), {}), o = {};
121
+ let a = d(t, (e, n, r) => (l(i[r]) || (e[r] = t[r]), e), {}), s = {};
138
122
  r.forEach((e, t) => {
139
123
  let n = a[e.dataset.index];
140
- n && (o[t] = n), e.dataset.index = t;
124
+ n && (s[t] = n), e.dataset.index = `${t}`;
141
125
  }), this.onModelChange({
142
- choices: s(o),
126
+ choices: o(s),
143
127
  slateMarkup: n.innerHTML
144
128
  });
145
129
  };
146
130
  onAddChoice = (e, t, n) => {
147
- let { respAreaChoices: r } = this.state, { maxResponseAreaChoices: i } = this.props.configuration, a = (e) => this.setState({ warning: {
131
+ let r = this.state.respAreaChoices, { maxResponseAreaChoices: i } = this.props.configuration, a = (e) => this.setState({ warning: {
148
132
  open: !0,
149
133
  text: e,
150
134
  onClose: void 0,
@@ -162,39 +146,39 @@ var { toggle: D, Panel: ie, dropdown: ae } = x, O = g(b)(({ theme: e }) => ({
162
146
  }
163
147
  if (n >= 0 && r[e]?.[n]) r[e][n].label = t;
164
148
  else {
165
- let n = r[e] && d(r[e].map((e) => parseInt(e.value)).filter((e) => !isNaN(e))) || 0;
149
+ let n = r[e] && u(r[e].map((e) => parseInt(e.value)).filter((e) => !isNaN(e))) || 0;
166
150
  r[e].push({
167
151
  label: t,
168
152
  value: `${n + 1}`,
169
153
  correct: !1
170
154
  });
171
155
  }
172
- this.onModelChange({ choices: s(r) });
156
+ this.onModelChange({ choices: o(r) });
173
157
  };
174
158
  onRemoveChoice = (e, t) => {
175
- let { respAreaChoices: n } = this.state;
176
- n[e].splice(t, 1), this.onModelChange({ choices: s(n) });
159
+ let n = this.state.respAreaChoices;
160
+ n[e].splice(t, 1), this.onModelChange({ choices: o(n) });
177
161
  };
178
162
  onSelectChoice = (e, t) => {
179
- let { respAreaChoices: n } = this.state;
163
+ let n = this.state.respAreaChoices;
180
164
  n[e] = n[e].map((e, n) => ({
181
165
  ...e,
182
166
  correct: n === t
183
- })), this.onModelChange({ choices: s(n) });
167
+ })), this.onModelChange({ choices: o(n) });
184
168
  };
185
169
  render() {
186
- let { warning: i } = this.state, { model: a, configuration: o, onConfigurationChanged: s, imageSupport: c, uploadSoundSupport: l } = this.props, { baseInputConfiguration: u = {}, choiceRationale: d = {}, contentDimensions: f = {}, lockChoiceOrder: p = {}, maxResponseAreas: g, maxImageWidth: y = {}, maxImageHeight: b = {}, partialScoring: x = {}, prompt: S = {}, rationale: C = {}, settingsPanelDisabled: T, spellCheck: F = {}, teacherInstructions: I = {}, template: ce = {}, withRubric: L = {}, mathMlOptions: R = {}, language: z = {}, languageChoices: B = {}, responseAreaInputConfiguration: V = {} } = o || {}, { choiceRationaleEnabled: H, choices: U, errors: W, extraCSSRules: le, promptEnabled: ue, rationaleEnabled: de, spellCheckEnabled: G, teacherInstructionsEnabled: fe, toolbarEditorPosition: pe } = a || {}, { prompt: K, rationale: q, responseAreasError: J, responseAreaChoicesError: me, teacherInstructions: Y } = W || {}, X = y && y.prompt, Z = b && b.prompt, he = () => (Object.keys(U) || []).map((e, t) => /* @__PURE__ */ m(A, { children: /* @__PURE__ */ h(w, {
170
+ let { warning: i } = this.state, { model: a, configuration: o, onConfigurationChanged: s, imageSupport: c, uploadSoundSupport: l } = this.props, { baseInputConfiguration: u = {}, choiceRationale: d = {}, contentDimensions: f = {}, lockChoiceOrder: h = {}, maxResponseAreas: _, maxImageWidth: v = {}, maxImageHeight: b = {}, partialScoring: x = {}, prompt: S = {}, rationale: C = {}, settingsPanelDisabled: P, spellCheck: F = {}, teacherInstructions: I = {}, template: ce = {}, withRubric: L = {}, mathMlOptions: R = {}, language: z = {}, languageChoices: B = {}, responseAreaInputConfiguration: V = {} } = o || {}, { choiceRationaleEnabled: H, choices: U, errors: W, promptEnabled: le, rationaleEnabled: ue, spellCheckEnabled: G, teacherInstructionsEnabled: de, toolbarEditorPosition: fe } = a || {}, { prompt: K, rationale: q, responseAreasError: J, responseAreaChoicesError: pe, teacherInstructions: Y } = W || {}, X = v && v.prompt, Z = b && b.prompt, me = () => (Object.keys(U) || []).map((e, t) => /* @__PURE__ */ p(se, { children: /* @__PURE__ */ m(ne, {
187
171
  slotProps: { transition: { timeout: {
188
172
  enter: 225,
189
173
  exit: 195
190
174
  } } },
191
- children: [/* @__PURE__ */ m(ne, {
192
- expandIcon: /* @__PURE__ */ m(E, {}),
193
- children: /* @__PURE__ */ m(k, {
175
+ children: [/* @__PURE__ */ p(re, {
176
+ expandIcon: /* @__PURE__ */ p(w, {}),
177
+ children: /* @__PURE__ */ p(k, {
194
178
  component: "div",
195
179
  children: `Rationale for response area #${t + 1}`
196
180
  })
197
- }), /* @__PURE__ */ m(j, { children: (U[e] || []).map((t) => /* @__PURE__ */ h(r.Fragment, { children: [/* @__PURE__ */ m(se, { dangerouslySetInnerHTML: { __html: `${C.label} for ${t.label} (${t.correct ? "correct" : "incorrect"})` } }), /* @__PURE__ */ m(oe, { children: /* @__PURE__ */ m(_, {
181
+ }), /* @__PURE__ */ p(A, { children: (U[e] || []).map((t) => /* @__PURE__ */ m(r.Fragment, { children: [/* @__PURE__ */ p(oe, { dangerouslySetInnerHTML: { __html: `${C.label} for ${t.label} (${t.correct ? "correct" : "incorrect"})` } }), /* @__PURE__ */ p(ae, { children: /* @__PURE__ */ p(g, {
198
182
  markup: t.rationale || "",
199
183
  spellCheck: G,
200
184
  pluginProps: $(C?.inputConfiguration),
@@ -203,48 +187,48 @@ var { toggle: D, Panel: ie, dropdown: ae } = x, O = g(b)(({ theme: e }) => ({
203
187
  rationale: n
204
188
  }),
205
189
  imageSupport: c,
206
- maxImageWidth: y && y.rationale || X,
190
+ maxImageWidth: v && v.rationale || X,
207
191
  maxImageHeight: b && b.rationale || Z,
208
192
  uploadSoundSupport: l,
209
193
  mathMlOptions: R
210
194
  }) })] }, t.label)) })]
211
- }) }, e)), Q = { position: pe === "top" ? "top" : "bottom" }, ge = e(o), _e = {
212
- partialScoring: x.settings && D(x.label),
213
- lockChoiceOrder: p.settings && D(p.label),
214
- "language.enabled": z.settings && D(z.label, !0),
215
- language: z.settings && z.enabled && ae(B.label, B.options)
216
- }, ve = {
217
- teacherInstructionsEnabled: I.settings && D(I.label),
218
- rationaleEnabled: C.settings && D(C.label),
219
- choiceRationaleEnabled: d.settings && D(d.label),
220
- promptEnabled: S.settings && D(S.label),
221
- spellCheckEnabled: F.settings && D(F.label),
222
- rubricEnabled: L?.settings && D(L?.label)
195
+ }) }, e)), Q = { position: fe === "top" ? "top" : "bottom" }, he = e(o), ge = {
196
+ partialScoring: x.settings && E(x.label),
197
+ lockChoiceOrder: h.settings && E(h.label),
198
+ "language.enabled": z.settings && E(z.label, !0),
199
+ language: z.settings && z.enabled && ie(B.label, B.options)
200
+ }, _e = {
201
+ teacherInstructionsEnabled: I.settings && E(I.label),
202
+ rationaleEnabled: C.settings && E(C.label),
203
+ choiceRationaleEnabled: d.settings && E(d.label),
204
+ promptEnabled: S.settings && E(S.label),
205
+ spellCheckEnabled: F.settings && E(F.label),
206
+ rubricEnabled: L?.settings && E(L?.label)
223
207
  }, $ = (e = {}) => ({
224
208
  ...u,
225
209
  ...e
226
210
  });
227
- return /* @__PURE__ */ h(te.ConfigLayout, {
211
+ return /* @__PURE__ */ m(y.ConfigLayout, {
228
212
  extraCSSRules: {
229
213
  names: ["red", "blue"],
230
214
  rules: "\n .red {\n color: red !important;\n }\n\n .blue {\n color: blue !important;\n }\n "
231
215
  },
232
216
  dimensions: f,
233
- hideSettings: T,
234
- settings: /* @__PURE__ */ m(ie, {
217
+ hideSettings: P,
218
+ settings: /* @__PURE__ */ p(D, {
235
219
  model: a,
236
220
  configuration: o,
237
221
  onChangeModel: (e) => this.onModelChange(e),
238
222
  onChangeConfiguration: (e) => s(e, !0),
239
223
  groups: {
240
- Settings: _e,
241
- Properties: ve
224
+ Settings: ge,
225
+ Properties: _e
242
226
  }
243
227
  }),
244
228
  children: [
245
- fe && /* @__PURE__ */ h(O, {
229
+ de && /* @__PURE__ */ m(O, {
246
230
  label: I.label,
247
- children: [/* @__PURE__ */ m(_, {
231
+ children: [/* @__PURE__ */ p(g, {
248
232
  markup: a.teacherInstructions || "",
249
233
  onChange: this.onTeacherInstructionsChanged,
250
234
  imageSupport: c,
@@ -253,16 +237,16 @@ var { toggle: D, Panel: ie, dropdown: ae } = x, O = g(b)(({ theme: e }) => ({
253
237
  toolbarOpts: Q,
254
238
  pluginProps: $(I?.inputConfiguration),
255
239
  spellCheck: G,
256
- maxImageWidth: y && y.teacherInstructions || X,
240
+ maxImageWidth: v && v.teacherInstructions || X,
257
241
  maxImageHeight: b && b.teacherInstructions || Z,
258
242
  uploadSoundSupport: l,
259
243
  languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
260
244
  mathMlOptions: R
261
- }), Y && /* @__PURE__ */ m(P, { children: Y })]
245
+ }), Y && /* @__PURE__ */ p(N, { children: Y })]
262
246
  }),
263
- ue && /* @__PURE__ */ h(O, {
247
+ le && /* @__PURE__ */ m(O, {
264
248
  label: S.label,
265
- children: [/* @__PURE__ */ m(_, {
249
+ children: [/* @__PURE__ */ p(g, {
266
250
  markup: a.prompt,
267
251
  onChange: this.onPromptChanged,
268
252
  imageSupport: c,
@@ -277,27 +261,27 @@ var { toggle: D, Panel: ie, dropdown: ae } = x, O = g(b)(({ theme: e }) => ({
277
261
  uploadSoundSupport: l,
278
262
  languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
279
263
  mathMlOptions: R
280
- }), K && /* @__PURE__ */ m(P, { children: K })]
264
+ }), K && /* @__PURE__ */ p(N, { children: K })]
281
265
  }),
282
- /* @__PURE__ */ h(M, { children: [/* @__PURE__ */ m(k, {
266
+ /* @__PURE__ */ m(j, { children: [/* @__PURE__ */ p(k, {
283
267
  component: "div",
284
268
  children: "Define Template, Choices, and Correct Responses"
285
- }), /* @__PURE__ */ m(N, {
269
+ }), /* @__PURE__ */ p(M, {
286
270
  disableFocusListener: !0,
287
271
  disableTouchListener: !0,
288
272
  placement: "right",
289
- title: ge,
290
- children: /* @__PURE__ */ m(re, {
273
+ title: he,
274
+ children: /* @__PURE__ */ p(T, {
291
275
  fontSize: "small",
292
276
  color: "primary"
293
277
  })
294
278
  })] }),
295
- /* @__PURE__ */ m(n, {
279
+ /* @__PURE__ */ p(n, {
296
280
  responseAreasError: J,
297
- responseAreaChoicesError: me,
281
+ responseAreaChoicesError: pe,
298
282
  editableHtmlProps: {
299
283
  pluginProps: $(ce?.inputConfiguration),
300
- activePlugins: v,
284
+ activePlugins: ee,
301
285
  toolbarOpts: { position: "top" },
302
286
  extraCSSRules: {
303
287
  names: ["red", "blue"],
@@ -306,13 +290,13 @@ var { toggle: D, Panel: ie, dropdown: ae } = x, O = g(b)(({ theme: e }) => ({
306
290
  responseAreaProps: {
307
291
  type: "inline-dropdown",
308
292
  options: { duplicates: !0 },
309
- maxResponseAreas: g,
293
+ maxResponseAreas: _,
310
294
  onToolbarCloseRequest: ([e, t], n, r, i) => {
311
295
  this.validateResponseAreaClose(e, t, n, r, i);
312
296
  },
313
297
  respAreaToolbar: (e, n, r) => {
314
- let [i, a] = e, { respAreaChoices: o } = this.state;
315
- return (e) => /* @__PURE__ */ m(t, {
298
+ let [i, a] = e, o = this.state.respAreaChoices;
299
+ return (e) => /* @__PURE__ */ p(t, {
316
300
  ...e,
317
301
  onAddChoice: this.onAddChoice,
318
302
  onRemoveChoice: (e) => this.onRemoveChoice(i.attrs.index, e),
@@ -343,10 +327,10 @@ var { toggle: D, Panel: ie, dropdown: ae } = x, O = g(b)(({ theme: e }) => ({
343
327
  mathMlOptions: R
344
328
  }
345
329
  }),
346
- H && he(),
347
- de && /* @__PURE__ */ h(O, {
330
+ H && me(),
331
+ ue && /* @__PURE__ */ m(O, {
348
332
  label: C.label,
349
- children: [/* @__PURE__ */ m(_, {
333
+ children: [/* @__PURE__ */ p(g, {
350
334
  markup: a.rationale || "",
351
335
  onChange: this.onRationaleChanged,
352
336
  imageSupport: c,
@@ -354,14 +338,14 @@ var { toggle: D, Panel: ie, dropdown: ae } = x, O = g(b)(({ theme: e }) => ({
354
338
  toolbarOpts: Q,
355
339
  pluginProps: $(C?.inputConfiguration),
356
340
  spellCheck: G,
357
- maxImageWidth: y && y.rationale || X,
341
+ maxImageWidth: v && v.rationale || X,
358
342
  maxImageHeight: b && b.rationale || Z,
359
343
  uploadSoundSupport: l,
360
344
  languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
361
345
  mathMlOptions: R
362
- }), q && /* @__PURE__ */ m(P, { children: q })]
346
+ }), q && /* @__PURE__ */ p(N, { children: q })]
363
347
  }),
364
- /* @__PURE__ */ m(ee, {
348
+ /* @__PURE__ */ p(te, {
365
349
  open: i.open,
366
350
  title: "Warning",
367
351
  text: i.text,
@@ -376,4 +360,4 @@ var { toggle: D, Panel: ie, dropdown: ae } = x, O = g(b)(({ theme: e }) => ({
376
360
  }
377
361
  };
378
362
  //#endregion
379
- export { I as Main, I as default };
363
+ export { F as Main, F as default };