@pie-element/categorize 13.1.11 → 13.2.0-next.9

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 (169) hide show
  1. package/configure.js +2 -0
  2. package/controller.js +1 -0
  3. package/dist/author/defaults.d.ts +222 -0
  4. package/dist/author/defaults.js +168 -0
  5. package/dist/author/design/builder.d.ts +10 -0
  6. package/dist/author/design/builder.js +24 -0
  7. package/dist/author/design/buttons.d.ts +28 -0
  8. package/dist/author/design/buttons.js +36 -0
  9. package/dist/author/design/categories/RowLabel.d.ts +23 -0
  10. package/dist/author/design/categories/RowLabel.js +47 -0
  11. package/dist/author/design/categories/alternateResponses.d.ts +31 -0
  12. package/dist/author/design/categories/alternateResponses.js +62 -0
  13. package/dist/author/design/categories/category.d.ts +44 -0
  14. package/dist/author/design/categories/category.js +98 -0
  15. package/dist/author/design/categories/choice-preview.d.ts +25 -0
  16. package/dist/author/design/categories/choice-preview.js +60 -0
  17. package/dist/author/design/categories/droppable-placeholder.d.ts +11 -0
  18. package/dist/author/design/categories/droppable-placeholder.js +71 -0
  19. package/dist/author/design/categories/index.d.ts +41 -0
  20. package/dist/author/design/categories/index.js +146 -0
  21. package/dist/author/design/choices/choice.d.ts +11 -0
  22. package/dist/author/design/choices/choice.js +129 -0
  23. package/dist/author/design/choices/config.d.ts +21 -0
  24. package/dist/author/design/choices/config.js +33 -0
  25. package/dist/author/design/choices/index.d.ts +41 -0
  26. package/dist/author/design/choices/index.js +110 -0
  27. package/dist/author/design/header.d.ts +24 -0
  28. package/dist/author/design/header.js +49 -0
  29. package/dist/author/design/index.d.ts +52 -0
  30. package/dist/author/design/index.js +427 -0
  31. package/dist/author/design/input-header.d.ts +39 -0
  32. package/dist/author/design/input-header.js +69 -0
  33. package/dist/author/design/utils.d.ts +9 -0
  34. package/dist/author/design/utils.js +7 -0
  35. package/dist/author/index.d.ts +50 -0
  36. package/dist/author/index.js +87 -0
  37. package/dist/author/main.d.ts +23 -0
  38. package/dist/author/main.js +30 -0
  39. package/dist/author/utils.d.ts +16 -0
  40. package/dist/author/utils.js +17 -0
  41. package/dist/browser/alert-dialog-BL9K_lnF.js +11511 -0
  42. package/dist/browser/alert-dialog-BL9K_lnF.js.map +1 -0
  43. package/dist/browser/author/index.js +43156 -0
  44. package/dist/browser/author/index.js.map +1 -0
  45. package/dist/browser/categorize.css +2 -0
  46. package/dist/browser/controller/index.js +372 -0
  47. package/dist/browser/controller/index.js.map +1 -0
  48. package/dist/browser/delivery/index.js +1205 -0
  49. package/dist/browser/delivery/index.js.map +1 -0
  50. package/dist/browser/dist-C11U2GIc.js +1871 -0
  51. package/dist/browser/dist-C11U2GIc.js.map +1 -0
  52. package/dist/browser/rolldown-runtime-CWhphoD1.js +32 -0
  53. package/dist/controller/defaults.d.ts +33 -0
  54. package/dist/controller/defaults.js +27 -0
  55. package/dist/controller/index.d.ts +62 -0
  56. package/dist/controller/index.js +168 -0
  57. package/dist/controller/utils.d.ts +20 -0
  58. package/dist/controller/utils.js +35 -0
  59. package/dist/delivery/categorize/__tests__/categories.test.d.ts +1 -0
  60. package/dist/delivery/categorize/__tests__/category.test.d.ts +1 -0
  61. package/dist/delivery/categorize/__tests__/choice.test.d.ts +1 -0
  62. package/dist/delivery/categorize/__tests__/choices.test.d.ts +1 -0
  63. package/dist/delivery/categorize/__tests__/droppable-placeholder.test.d.ts +1 -0
  64. package/dist/delivery/categorize/__tests__/grid-content.test.d.ts +1 -0
  65. package/dist/delivery/categorize/__tests__/index.test.d.ts +1 -0
  66. package/dist/delivery/categorize/__tests__/keyboard-coordinates.test.d.ts +1 -0
  67. package/dist/delivery/categorize/categories.d.ts +37 -0
  68. package/dist/delivery/categorize/categories.js +72 -0
  69. package/dist/delivery/categorize/category.d.ts +31 -0
  70. package/dist/delivery/categorize/category.js +55 -0
  71. package/dist/delivery/categorize/choice.d.ts +28 -0
  72. package/dist/delivery/categorize/choice.js +114 -0
  73. package/dist/delivery/categorize/choices.d.ts +42 -0
  74. package/dist/delivery/categorize/choices.js +58 -0
  75. package/dist/delivery/categorize/droppable-placeholder.d.ts +36 -0
  76. package/dist/delivery/categorize/droppable-placeholder.js +77 -0
  77. package/dist/delivery/categorize/grid-content.d.ts +25 -0
  78. package/dist/delivery/categorize/grid-content.js +39 -0
  79. package/dist/delivery/categorize/index.d.ts +70 -0
  80. package/dist/delivery/categorize/index.js +317 -0
  81. package/dist/delivery/categorize/keyboard-coordinates.d.ts +22 -0
  82. package/dist/delivery/categorize/keyboard-coordinates.js +49 -0
  83. package/dist/delivery/index.d.ts +27 -0
  84. package/dist/delivery/index.js +152 -0
  85. package/dist/index.d.ts +1 -0
  86. package/dist/index.iife.d.ts +8 -0
  87. package/dist/index.iife.js +152 -0
  88. package/dist/index.js +2 -0
  89. package/dist/runtime-support.d.ts +12 -0
  90. package/dist/runtime-support.js +12 -0
  91. package/package.json +97 -22
  92. package/CHANGELOG.json +0 -1637
  93. package/CHANGELOG.md +0 -2598
  94. package/LICENSE.md +0 -5
  95. package/README.md +0 -5
  96. package/configure/CHANGELOG.json +0 -1202
  97. package/configure/CHANGELOG.md +0 -2177
  98. package/configure/lib/defaults.js +0 -220
  99. package/configure/lib/defaults.js.map +0 -1
  100. package/configure/lib/design/builder.js +0 -55
  101. package/configure/lib/design/builder.js.map +0 -1
  102. package/configure/lib/design/buttons.js +0 -59
  103. package/configure/lib/design/buttons.js.map +0 -1
  104. package/configure/lib/design/categories/RowLabel.js +0 -66
  105. package/configure/lib/design/categories/RowLabel.js.map +0 -1
  106. package/configure/lib/design/categories/alternateResponses.js +0 -116
  107. package/configure/lib/design/categories/alternateResponses.js.map +0 -1
  108. package/configure/lib/design/categories/category.js +0 -153
  109. package/configure/lib/design/categories/category.js.map +0 -1
  110. package/configure/lib/design/categories/choice-preview.js +0 -79
  111. package/configure/lib/design/categories/choice-preview.js.map +0 -1
  112. package/configure/lib/design/categories/droppable-placeholder.js +0 -93
  113. package/configure/lib/design/categories/droppable-placeholder.js.map +0 -1
  114. package/configure/lib/design/categories/index.js +0 -256
  115. package/configure/lib/design/categories/index.js.map +0 -1
  116. package/configure/lib/design/choices/choice.js +0 -187
  117. package/configure/lib/design/choices/choice.js.map +0 -1
  118. package/configure/lib/design/choices/config.js +0 -58
  119. package/configure/lib/design/choices/config.js.map +0 -1
  120. package/configure/lib/design/choices/index.js +0 -197
  121. package/configure/lib/design/choices/index.js.map +0 -1
  122. package/configure/lib/design/header.js +0 -71
  123. package/configure/lib/design/header.js.map +0 -1
  124. package/configure/lib/design/index.js +0 -741
  125. package/configure/lib/design/index.js.map +0 -1
  126. package/configure/lib/design/input-header.js +0 -105
  127. package/configure/lib/design/input-header.js.map +0 -1
  128. package/configure/lib/design/utils.js +0 -12
  129. package/configure/lib/design/utils.js.map +0 -1
  130. package/configure/lib/index.js +0 -148
  131. package/configure/lib/index.js.map +0 -1
  132. package/configure/lib/main.js +0 -44
  133. package/configure/lib/main.js.map +0 -1
  134. package/configure/lib/utils.js +0 -43
  135. package/configure/lib/utils.js.map +0 -1
  136. package/configure/package.json +0 -32
  137. package/controller/CHANGELOG.json +0 -452
  138. package/controller/CHANGELOG.md +0 -1411
  139. package/controller/lib/defaults.js +0 -31
  140. package/controller/lib/defaults.js.map +0 -1
  141. package/controller/lib/index.js +0 -506
  142. package/controller/lib/index.js.map +0 -1
  143. package/controller/lib/utils.js +0 -69
  144. package/controller/lib/utils.js.map +0 -1
  145. package/controller/package.json +0 -18
  146. package/docs/config-schema.json +0 -2897
  147. package/docs/config-schema.json.md +0 -2138
  148. package/docs/demo/config.js +0 -8
  149. package/docs/demo/generate.js +0 -357
  150. package/docs/demo/index.html +0 -1
  151. package/docs/demo/session.js +0 -12
  152. package/docs/pie-schema.json +0 -1784
  153. package/docs/pie-schema.json.md +0 -1046
  154. package/lib/categorize/categories.js +0 -135
  155. package/lib/categorize/categories.js.map +0 -1
  156. package/lib/categorize/category.js +0 -67
  157. package/lib/categorize/category.js.map +0 -1
  158. package/lib/categorize/choice.js +0 -140
  159. package/lib/categorize/choice.js.map +0 -1
  160. package/lib/categorize/choices.js +0 -99
  161. package/lib/categorize/choices.js.map +0 -1
  162. package/lib/categorize/droppable-placeholder.js +0 -84
  163. package/lib/categorize/droppable-placeholder.js.map +0 -1
  164. package/lib/categorize/grid-content.js +0 -55
  165. package/lib/categorize/grid-content.js.map +0 -1
  166. package/lib/categorize/index.js +0 -450
  167. package/lib/categorize/index.js.map +0 -1
  168. package/lib/index.js +0 -316
  169. package/lib/index.js.map +0 -1
@@ -0,0 +1,427 @@
1
+ import { getPluginProps as e } from "./utils.js";
2
+ import { ChoicePreview as t } from "./categories/choice-preview.js";
3
+ import { Header as n } from "./header.js";
4
+ import { getMaxCategoryChoices as r, multiplePlacements as i } from "../utils.js";
5
+ import { Categories as a } from "./categories/index.js";
6
+ import { AlternateResponses as o } from "./categories/alternateResponses.js";
7
+ import s from "./choices/choice.js";
8
+ import { Choices as c } from "./choices/index.js";
9
+ import { buildAlternateResponses as l, buildCategories as u } from "./builder.js";
10
+ import d from "react";
11
+ import { renderMath as f } from "@pie-element/shared-math-rendering-mathjax";
12
+ import p from "prop-types";
13
+ import { styled as m } from "@mui/material/styles";
14
+ import { DragOverlay as ee } from "@dnd-kit/core";
15
+ import { countInAnswer as h, ensureNoExtraChoicesInAlternate as g, ensureNoExtraChoicesInAnswer as _, moveChoiceToAlternate as v, moveChoiceToCategory as y, removeChoiceFromAlternate as b, removeChoiceFromCategory as x, verifyAllowMultiplePlacements as S } from "@pie-lib/categorize";
16
+ import { DragProvider as te, uid as C } from "@pie-lib/drag";
17
+ import { jsx as w, jsxs as T } from "react/jsx-runtime";
18
+ import E from "@pie-lib/translator";
19
+ import { AlertDialog as ne, FeedbackConfig as re, InputContainer as D, layout as ie, settings as O } from "@pie-lib/config-ui";
20
+ import k from "@pie-lib/editable-html-tip-tap";
21
+ //#region src/author/design/index.tsx
22
+ var { translator: ae } = E, { dropdown: A, Panel: oe, toggle: j, radio: M, numberField: N } = O, { Provider: se } = C, ce = class extends d.Component {
23
+ containerRef = d.createRef();
24
+ componentDidMount() {
25
+ this.containerRef.current && setTimeout(() => f(this.containerRef.current), 0);
26
+ }
27
+ render() {
28
+ return /* @__PURE__ */ w("div", {
29
+ ref: this.containerRef,
30
+ children: this.props.children
31
+ });
32
+ }
33
+ }, le = m(n)(({ theme: e }) => ({ marginBottom: e.spacing(2) })), P = m(D)(({ theme: e }) => ({
34
+ width: "100%",
35
+ paddingTop: e.spacing(1),
36
+ marginTop: e.spacing(1),
37
+ marginBottom: e.spacing(2)
38
+ })), F = m("div")(({ theme: e }) => ({
39
+ fontSize: e.typography.fontSize - 2,
40
+ color: e.palette.error.main,
41
+ paddingTop: e.spacing(1)
42
+ })), I = class extends d.Component {
43
+ static propTypes = {
44
+ configuration: p.object,
45
+ className: p.string,
46
+ onConfigurationChanged: p.func,
47
+ model: p.object.isRequired,
48
+ onChange: p.func.isRequired,
49
+ uid: p.string,
50
+ imageSupport: p.shape({
51
+ add: p.func.isRequired,
52
+ delete: p.func.isRequired
53
+ }),
54
+ uploadSoundSupport: p.shape({
55
+ add: p.func.isRequired,
56
+ delete: p.func.isRequired
57
+ })
58
+ };
59
+ constructor(e) {
60
+ super(e), this.uid = e.uid || C.generateId(), this.state = { activeDragItem: null };
61
+ }
62
+ updateModel = (e) => {
63
+ let { model: t, onChange: n } = this.props, r = {
64
+ ...t,
65
+ ...e
66
+ };
67
+ r.choices = r.choices.map((e) => ({
68
+ ...e,
69
+ categoryCount: this.checkAllowMultiplePlacements(r.allowMultiplePlacementsEnabled, e)
70
+ })), r.correctResponse = _(r.correctResponse || [], r.choices), r.correctResponse = g(r.correctResponse || [], r.choices), r.categories = r.categories.map((e) => ({
71
+ id: e.id,
72
+ label: e.label
73
+ })), r.choices = r.choices.map((e) => ({
74
+ id: e.id,
75
+ content: e.content,
76
+ categoryCount: e.categoryCount
77
+ })), r.maxChoicesPerCategory = r.allowMaxChoicesPerCategory ? r.maxChoicesPerCategory : 0, n(r);
78
+ };
79
+ changeRationale = (e) => {
80
+ let { model: t, onChange: n } = this.props;
81
+ n({
82
+ ...t,
83
+ rationale: e
84
+ });
85
+ };
86
+ changeTeacherInstructions = (e) => {
87
+ let { model: t, onChange: n } = this.props;
88
+ n({
89
+ ...t,
90
+ teacherInstructions: e
91
+ });
92
+ };
93
+ changeFeedback = (e) => {
94
+ this.updateModel({ feedback: e });
95
+ };
96
+ onAddAlternateResponse = () => {
97
+ let { model: { correctResponse: e } } = this.props;
98
+ this.updateModel({ correctResponse: (e || []).map((e) => ({
99
+ ...e,
100
+ alternateResponses: [...e.alternateResponses || [], []]
101
+ })) });
102
+ };
103
+ onPromptChanged = (e) => this.updateModel({ prompt: e });
104
+ onRemoveAlternateResponse = (e) => {
105
+ let { model: { correctResponse: t } } = this.props;
106
+ this.updateModel({ correctResponse: (t || []).map((t) => ({
107
+ ...t,
108
+ alternateResponses: (t.alternateResponses || []).filter((t, n) => n !== e)
109
+ })) });
110
+ };
111
+ countChoiceInCorrectResponse = (e) => {
112
+ let { model: t } = this.props;
113
+ return h(e.id, t.correctResponse);
114
+ };
115
+ checkAllowMultiplePlacements = (e, t) => e === i.enabled ? 0 : e === i.disabled ? 1 : t.categoryCount || 0;
116
+ isAlertModalOpened = () => {
117
+ let { model: e } = this.props, { maxChoicesPerCategory: t = 0 } = e || {}, n = r(e);
118
+ return t !== 0 && n > t;
119
+ };
120
+ onAlertModalCancel = () => {
121
+ let { model: e } = this.props, t = r(e);
122
+ this.updateModel({ maxChoicesPerCategory: t });
123
+ };
124
+ onDragStart = (e) => {
125
+ let { active: t } = e, n = t.data.current;
126
+ this.setState({ activeDragItem: n });
127
+ };
128
+ onDragEnd = ({ active: e, over: t }) => {
129
+ let n = window.scrollX, r = window.scrollY;
130
+ if (this.setState({ activeDragItem: null }), !e) return;
131
+ requestAnimationFrame(() => {
132
+ requestAnimationFrame(() => {
133
+ window.scrollTo(n, r);
134
+ });
135
+ });
136
+ let { model: i } = this.props, { allowAlternateEnabled: a, categories: o = [], choices: s = [] } = i, c = e?.data?.current, l = t?.data?.current;
137
+ if (!c) return;
138
+ 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);
139
+ if (f && (!l || d === "choice")) {
140
+ this.removeChoiceFromSource(c, u, {
141
+ allowAlternateEnabled: a,
142
+ categories: o,
143
+ choices: s
144
+ });
145
+ return;
146
+ }
147
+ if (f && d === "category") return this.moveChoice(m, c.categoryId, l.id, u);
148
+ if (p && d === "category") return this.addChoiceToCategory({ id: c.id }, l.id);
149
+ if (f && d === "category-alternate") return this.moveChoiceInAlternate(m, c.categoryId, l.id, u, l.alternateResponseIndex);
150
+ if (a && p && d === "category-alternate") return this.addChoiceToAlternateCategory({ id: c.id }, l.id, l.alternateResponseIndex);
151
+ };
152
+ removeChoiceFromSource = (e, t, { allowAlternateEnabled: n, categories: r, choices: i }) => {
153
+ if (e.alternateResponseIndex === void 0) {
154
+ this.deleteChoiceFromCategory(e.categoryId, e.choiceId, t);
155
+ return;
156
+ }
157
+ if (!n) return;
158
+ let a = r?.find((t) => t.id === e.categoryId), o = i?.find((t) => t.id === e.choiceId);
159
+ a && o && this.deleteChoiceFromAlternateCategory(a, o, t, e.alternateResponseIndex);
160
+ };
161
+ addChoiceToCategory = (e, t) => {
162
+ let { model: n } = this.props, { choices: i = [], correctResponse: a = [], maxChoicesPerCategory: o = 0 } = n || {}, s = (i || []).find((t) => t.id === e.id), c = y(e.id, void 0, t, 0, a);
163
+ s.categoryCount !== 0 && (c = S(e, t, c));
164
+ let l = r(n);
165
+ this.updateModel({
166
+ correctResponse: c,
167
+ maxChoicesPerCategory: o !== 0 && o < l ? o + 1 : o
168
+ });
169
+ };
170
+ deleteChoiceFromCategory = (e, t, n) => {
171
+ let { model: r } = this.props, i = x(t, e, n, r.correctResponse);
172
+ this.updateModel({ correctResponse: i });
173
+ };
174
+ moveChoice = (e, t, n, i) => {
175
+ let { model: a } = this.props, { choices: o, correctResponse: s = [], maxChoicesPerCategory: c = 0 } = a || {}, l = (o || []).find((t) => t.id === e);
176
+ if (n === t || !l) return;
177
+ l.categoryCount === 0 ? l.categoryCount === 0 && (s = y(l.id, void 0, n, 0, s)) : (s = y(l.id, t, n, i, s), s = S(l, n, s));
178
+ let u = r(a);
179
+ this.updateModel({
180
+ correctResponse: s,
181
+ maxChoicesPerCategory: c !== 0 && c < u ? c + 1 : c
182
+ });
183
+ };
184
+ addChoiceToAlternateCategory = (e, t, n) => {
185
+ let { model: i } = this.props, { correctResponse: a, choices: o, maxChoicesPerCategory: s = 0 } = i, c = o.find((t) => t.id === e.id);
186
+ a.forEach((r) => r.category === t ? (r.alternateResponses = r.alternateResponses || [], r.alternateResponses[n] === void 0 && (r.alternateResponses[n] = []), r.alternateResponses[n].push(e.id), c.categoryCount && c.categoryCount !== 0 && (r.alternateResponses[n] = r.alternateResponses[n].reduce((e, t) => (t === c.id ? e.findIndex((e) => e === c.id) === -1 && e.push(t) : e.push(t), e), [])), r) : (r.alternateResponses[n] && c.categoryCount !== 0 && (r.alternateResponses[n] = r.alternateResponses[n].filter((t) => t !== e.id)), r));
187
+ let l = r(i);
188
+ this.updateModel({
189
+ correctResponse: a,
190
+ maxChoicesPerCategory: s !== 0 && s < l ? s + 1 : s
191
+ });
192
+ };
193
+ moveChoiceInAlternate = (e, t, n, i, a) => {
194
+ let { model: o } = this.props, { choices: s, correctResponse: c = [], maxChoicesPerCategory: l = 0 } = o || {}, u = (s || []).find((t) => t.id === e);
195
+ c = v(e, t, n, i, c, a, u?.categoryCount);
196
+ let d = r(o);
197
+ this.updateModel({
198
+ correctResponse: c,
199
+ maxChoicesPerCategory: l !== 0 && l < d ? l + 1 : l
200
+ });
201
+ };
202
+ deleteChoiceFromAlternateCategory = (e, t, n, r) => {
203
+ let { model: i } = this.props, a = b(t.id, e.id, n, r, i.correctResponse);
204
+ this.updateModel({ correctResponse: a });
205
+ };
206
+ renderDragOverlay = () => {
207
+ let { activeDragItem: e } = this.state, { model: n, configuration: r } = this.props;
208
+ if (!e) return null;
209
+ if (e.type === "choice") {
210
+ let t = n.choices?.find((t) => t.id === e.id);
211
+ return t ? /* @__PURE__ */ w(s, {
212
+ choice: t,
213
+ configuration: r
214
+ }) : null;
215
+ } else if (e.type === "choice-preview" && e.alternateResponseIndex === void 0) {
216
+ let r = n.choices?.find((t) => t.id === e.id);
217
+ return r ? /* @__PURE__ */ w(t, { choice: r }) : null;
218
+ } else if (e.type === "choice-preview" && e.alternateResponseIndex !== void 0) {
219
+ let r = n.choices?.find((t) => t.id === e.id);
220
+ return r ? /* @__PURE__ */ w(t, {
221
+ choice: r,
222
+ alternateResponseIndex: e.alternateResponseIndex
223
+ }) : null;
224
+ }
225
+ return null;
226
+ };
227
+ render() {
228
+ let { configuration: t, imageSupport: n, model: r, uploadSoundSupport: s, onConfigurationChanged: f } = this.props, { allowAlternate: p = {}, allowMultiplePlacements: m = {}, baseInputConfiguration: h = {}, categoriesPerRow: g = {}, choicesPosition: _ = {}, contentDimensions: v = {}, feedback: y = {}, lockChoiceOrder: b = {}, maxImageHeight: x = {}, maxImageWidth: S = {}, maxPlacements: C = {}, minCategoriesPerRow: E = 1, partialScoring: D = {}, prompt: O = {}, rationale: I = {}, scoringType: L = {}, settingsPanelDisabled: ue, spellCheck: R = {}, studentInstructions: z = {}, teacherInstructions: B = {}, withRubric: V = {}, mathMlOptions: H = {}, language: U = {}, languageChoices: W = {}, allowMaxAnswerChoices: de = {} } = t || {}, { allowAlternateEnabled: fe, allowMaxChoicesPerCategory: pe, errors: me, feedbackEnabled: he, maxChoicesPerCategory: ge, promptEnabled: _e, rationaleEnabled: ve, spellCheckEnabled: G, teacherInstructionsEnabled: ye, toolbarEditorPosition: be, extraCSSRules: xe } = r || {}, { prompt: K, rationale: q, teacherInstructions: J } = me || {}, Y = { position: be === "top" ? "top" : "bottom" }, Se = r.config || {};
229
+ Se.choices = Se.choices || {
230
+ label: "",
231
+ columns: 2
232
+ };
233
+ let Ce = u(r.categories || [], r.choices || [], r.correctResponse || []), we = l(r.categories || [], r.choices || [], r.correctResponse || []), X = (() => {
234
+ if (r.allowMultiplePlacementsEnabled != null) return r.allowMultiplePlacementsEnabled;
235
+ let e = (r.correctResponse || []).flatMap((e) => e.choices || []);
236
+ return e.length === new Set(e).size ? i.disabled : i.enabled;
237
+ })(), Z = r.choices.map((e) => (e.correctResponseCount = this.countChoiceInCorrectResponse(e), e.categoryCount = this.checkAllowMultiplePlacements(X, e), e)), Q = S && S.prompt, $ = x && x.prompt, Te = {
238
+ partialScoring: D.settings && j(D.label),
239
+ lockChoiceOrder: b.settings && j(b.label),
240
+ categoriesPerRow: g.settings && N(g.label, {
241
+ label: g.label,
242
+ min: E,
243
+ max: 6
244
+ }),
245
+ choicesPosition: _.settings && M(_.label, [
246
+ "below",
247
+ "above",
248
+ "left",
249
+ "right"
250
+ ]),
251
+ allowMultiplePlacementsEnabled: m.settings && A(m.label, [
252
+ i.enabled,
253
+ i.disabled,
254
+ i.perChoice
255
+ ]),
256
+ maxAnswerChoices: de.settings && N(de.label, {
257
+ label: "",
258
+ min: Z?.length || 0,
259
+ max: 30
260
+ }),
261
+ allowMaxChoicesPerCategory: C.settings && j(C.label),
262
+ maxChoicesPerCategory: pe === !0 && N(C.label, {
263
+ label: "",
264
+ min: 0,
265
+ max: 30
266
+ }),
267
+ promptEnabled: O.settings && j(O.label),
268
+ feedbackEnabled: y.settings && j(y.label),
269
+ allowAlternateEnabled: p.settings && j(p.label),
270
+ "language.enabled": U.settings && j(U.label, !0),
271
+ language: U.settings && U.enabled && A(W.label, W.options)
272
+ }, Ee = {
273
+ teacherInstructionsEnabled: B.settings && j(B.label),
274
+ studentInstructionsEnabled: z.settings && j(z.label),
275
+ rationaleEnabled: I.settings && j(I.label),
276
+ spellCheckEnabled: R.settings && j(R.label),
277
+ scoringType: L.settings && M(L.label, ["auto", "rubric"]),
278
+ rubricEnabled: V?.settings && j(V?.label)
279
+ }, De = this.isAlertModalOpened(), Oe = ae.t("translation:categorize:maxChoicesPerCategoryRestriction", {
280
+ lng: r.language,
281
+ maxChoicesPerCategory: ge
282
+ });
283
+ return /* @__PURE__ */ w(te, {
284
+ onDragStart: this.onDragStart,
285
+ onDragEnd: this.onDragEnd,
286
+ children: /* @__PURE__ */ T(se, {
287
+ value: this.uid,
288
+ children: [/* @__PURE__ */ T(ie.ConfigLayout, {
289
+ extraCSSRules: xe,
290
+ dimensions: v,
291
+ hideSettings: ue,
292
+ settings: /* @__PURE__ */ w(oe, {
293
+ model: {
294
+ ...r,
295
+ allowMultiplePlacementsEnabled: X
296
+ },
297
+ onChangeModel: this.updateModel,
298
+ configuration: t,
299
+ onChangeConfiguration: f,
300
+ groups: {
301
+ Settings: Te,
302
+ Properties: Ee
303
+ },
304
+ modal: /* @__PURE__ */ w(ne, {
305
+ title: "Warning",
306
+ text: Oe,
307
+ open: De,
308
+ onClose: this.onAlertModalCancel
309
+ })
310
+ }),
311
+ children: [
312
+ ye && /* @__PURE__ */ T(P, {
313
+ label: B.label,
314
+ children: [/* @__PURE__ */ w(k, {
315
+ markup: r.teacherInstructions || "",
316
+ onChange: this.changeTeacherInstructions,
317
+ imageSupport: n,
318
+ error: J,
319
+ nonEmpty: !1,
320
+ toolbarOpts: Y,
321
+ pluginProps: e(B?.inputConfiguration, h),
322
+ spellCheck: G,
323
+ maxImageWidth: S && S.teacherInstructions || Q,
324
+ maxImageHeight: x && x.teacherInstructions || $,
325
+ uploadSoundSupport: s,
326
+ languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
327
+ mathMlOptions: H
328
+ }), J && /* @__PURE__ */ w(F, { children: J })]
329
+ }),
330
+ _e && /* @__PURE__ */ T(P, {
331
+ label: O.label,
332
+ children: [/* @__PURE__ */ w(k, {
333
+ markup: r.prompt || "",
334
+ onChange: this.onPromptChanged,
335
+ imageSupport: n,
336
+ error: K,
337
+ nonEmpty: !1,
338
+ disableUnderline: !0,
339
+ toolbarOpts: Y,
340
+ pluginProps: e(O?.inputConfiguration, h),
341
+ spellCheck: G,
342
+ maxImageWidth: S && S.prompt,
343
+ maxImageHeight: x && x.prompt,
344
+ uploadSoundSupport: s,
345
+ languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
346
+ mathMlOptions: H
347
+ }), K && /* @__PURE__ */ w(F, { children: K })]
348
+ }),
349
+ /* @__PURE__ */ w(a, {
350
+ imageSupport: n,
351
+ uploadSoundSupport: s,
352
+ model: r,
353
+ categories: Ce || [],
354
+ onModelChanged: this.updateModel,
355
+ toolbarOpts: Y,
356
+ spellCheck: G,
357
+ configuration: t,
358
+ defaultImageMaxWidth: Q,
359
+ defaultImageMaxHeight: $,
360
+ mathMlOptions: H
361
+ }),
362
+ /* @__PURE__ */ w(c, {
363
+ imageSupport: n,
364
+ uploadSoundSupport: s,
365
+ choices: Z,
366
+ model: {
367
+ ...r,
368
+ allowMultiplePlacementsEnabled: X
369
+ },
370
+ onModelChanged: this.updateModel,
371
+ toolbarOpts: Y,
372
+ spellCheck: G,
373
+ configuration: t,
374
+ defaultImageMaxWidth: Q,
375
+ defaultImageMaxHeight: $
376
+ }),
377
+ fe && /* @__PURE__ */ w(le, {
378
+ label: "Alternate Responses",
379
+ buttonLabel: "ADD AN ALTERNATE RESPONSE",
380
+ onAdd: this.onAddAlternateResponse
381
+ }),
382
+ fe && we.map((e, i) => /* @__PURE__ */ T(d.Fragment, { children: [/* @__PURE__ */ w(le, {
383
+ variant: "subtitle1",
384
+ label: "Alternate Response",
385
+ buttonLabel: "REMOVE ALTERNATE RESPONSE",
386
+ onAdd: () => this.onRemoveAlternateResponse(i)
387
+ }), /* @__PURE__ */ w(o, {
388
+ altIndex: i,
389
+ imageSupport: n,
390
+ model: r,
391
+ configuration: t,
392
+ categories: e,
393
+ onModelChanged: this.updateModel,
394
+ uploadSoundSupport: s,
395
+ mathMlOptions: H
396
+ })] }, i)),
397
+ ve && /* @__PURE__ */ T(P, {
398
+ label: I.label,
399
+ children: [/* @__PURE__ */ w(k, {
400
+ markup: r.rationale || "",
401
+ onChange: this.changeRationale,
402
+ imageSupport: n,
403
+ error: q,
404
+ nonEmpty: !1,
405
+ toolbarOpts: Y,
406
+ pluginProps: e(O?.inputConfiguration, h),
407
+ spellCheck: G,
408
+ maxImageWidth: S && S.rationale || Q,
409
+ maxImageHeight: x && x.rationale || $,
410
+ uploadSoundSupport: s,
411
+ languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
412
+ mathMlOptions: H
413
+ }), q && /* @__PURE__ */ w(F, { children: q })]
414
+ }),
415
+ he && /* @__PURE__ */ w(re, {
416
+ feedback: r.feedback,
417
+ onChange: this.changeFeedback,
418
+ toolbarOpts: Y
419
+ })
420
+ ]
421
+ }), /* @__PURE__ */ w(ee, { children: /* @__PURE__ */ w(ce, { children: this.renderDragOverlay() }) })]
422
+ })
423
+ });
424
+ }
425
+ };
426
+ //#endregion
427
+ export { I as Design, I as default };
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/categorize/configure/src/design/input-header.jsx
3
+ * @auto-generated
4
+ *
5
+ * This file is automatically synced from pie-elements and converted to TypeScript.
6
+ * Manual edits will be overwritten on next sync.
7
+ * To make changes, edit the upstream JavaScript file and run sync again.
8
+ */
9
+ import React from 'react';
10
+ import PropTypes from 'prop-types';
11
+ export declare class InputHeader extends React.Component {
12
+ static propTypes: {
13
+ configuration: PropTypes.Validator<object>;
14
+ deleteFocusedEl: PropTypes.Requireable<(...args: any[]) => any>;
15
+ disabled: PropTypes.Requireable<boolean>;
16
+ focusedEl: PropTypes.Requireable<number>;
17
+ index: PropTypes.Requireable<number>;
18
+ label: PropTypes.Requireable<string>;
19
+ maxImageWidth: PropTypes.Requireable<object>;
20
+ maxImageHeight: PropTypes.Requireable<object>;
21
+ onChange: PropTypes.Requireable<(...args: any[]) => any>;
22
+ onDelete: PropTypes.Requireable<(...args: any[]) => any>;
23
+ imageSupport: PropTypes.Requireable<PropTypes.InferProps<{
24
+ add: PropTypes.Validator<(...args: any[]) => any>;
25
+ delete: PropTypes.Validator<(...args: any[]) => any>;
26
+ }>>;
27
+ uploadSoundSupport: PropTypes.Requireable<PropTypes.InferProps<{
28
+ add: PropTypes.Validator<(...args: any[]) => any>;
29
+ delete: PropTypes.Validator<(...args: any[]) => any>;
30
+ }>>;
31
+ toolbarOpts: PropTypes.Requireable<object>;
32
+ error: PropTypes.Requireable<string>;
33
+ spellCheck: PropTypes.Requireable<boolean>;
34
+ };
35
+ static defaultProps: {};
36
+ constructor(props: any);
37
+ render(): React.JSX.Element;
38
+ }
39
+ export default InputHeader;
@@ -0,0 +1,69 @@
1
+ import { getPluginProps as e } from "./utils.js";
2
+ import t from "react";
3
+ import n from "prop-types";
4
+ import { styled as r } from "@mui/material/styles";
5
+ import { jsx as i } from "react/jsx-runtime";
6
+ import a from "@pie-lib/editable-html-tip-tap";
7
+ //#region src/author/design/input-header.tsx
8
+ var o = r(a)({
9
+ flex: "1",
10
+ maxWidth: "100%"
11
+ }), s = r("div")(({ theme: e }) => ({
12
+ display: "flex",
13
+ justifyContent: "space-between",
14
+ paddingBottom: e.spacing(1)
15
+ })), c = class extends t.Component {
16
+ static propTypes = {
17
+ configuration: n.object.isRequired,
18
+ deleteFocusedEl: n.func,
19
+ disabled: n.bool,
20
+ focusedEl: n.number,
21
+ index: n.number,
22
+ label: n.string,
23
+ maxImageWidth: n.object,
24
+ maxImageHeight: n.object,
25
+ onChange: n.func,
26
+ onDelete: n.func,
27
+ imageSupport: n.shape({
28
+ add: n.func.isRequired,
29
+ delete: n.func.isRequired
30
+ }),
31
+ uploadSoundSupport: n.shape({
32
+ add: n.func.isRequired,
33
+ delete: n.func.isRequired
34
+ }),
35
+ toolbarOpts: n.object,
36
+ error: n.string,
37
+ spellCheck: n.bool
38
+ };
39
+ static defaultProps = {};
40
+ constructor(e) {
41
+ super(e);
42
+ }
43
+ render() {
44
+ let { onChange: t, configuration: n, label: r, deleteFocusedEl: a, disabled: c, imageSupport: l, toolbarOpts: u, spellCheck: d, error: f, maxImageWidth: p, maxImageHeight: m, uploadSoundSupport: h, mathMlOptions: g = {}, focusedEl: _, index: v } = this.props, { headers: y, baseInputConfiguration: b } = n;
45
+ return /* @__PURE__ */ i(s, { children: /* @__PURE__ */ i(o, {
46
+ imageSupport: l,
47
+ disabled: c,
48
+ autoFocus: _ != null && _ === v,
49
+ autoWidthToolbar: !0,
50
+ label: "label",
51
+ markup: r,
52
+ onChange: t,
53
+ pluginProps: e(y?.inputConfiguration, b),
54
+ toolbarOpts: u,
55
+ spellCheck: d,
56
+ error: f,
57
+ maxImageWidth: p,
58
+ maxImageHeight: m,
59
+ uploadSoundSupport: h,
60
+ languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
61
+ onDone: () => {
62
+ a && a();
63
+ },
64
+ mathMlOptions: g
65
+ }) });
66
+ }
67
+ };
68
+ //#endregion
69
+ export { c as InputHeader, c as default };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/categorize/configure/src/design/utils.js
3
+ * @auto-generated
4
+ *
5
+ * This file is automatically synced from pie-elements and converted to TypeScript.
6
+ * Manual edits will be overwritten on next sync.
7
+ * To make changes, edit the upstream JavaScript file and run sync again.
8
+ */
9
+ export declare const getPluginProps: (props?: {}, baseInputConfiguration?: {}) => {};
@@ -0,0 +1,7 @@
1
+ //#region src/author/design/utils.ts
2
+ var e = (e = {}, t = {}) => ({
3
+ ...t,
4
+ ...e
5
+ });
6
+ //#endregion
7
+ export { e as getPluginProps };
@@ -0,0 +1,50 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/categorize/configure/src/index.js
3
+ * @auto-generated
4
+ *
5
+ * This file is automatically synced from pie-elements and converted to TypeScript.
6
+ * Manual edits will be overwritten on next sync.
7
+ * To make changes, edit the upstream JavaScript file and run sync again.
8
+ */
9
+ export default class CategorizeConfigure extends HTMLElement {
10
+ static createDefaultModel: (model?: {}) => {
11
+ allowAlternateEnabled: boolean;
12
+ allowMaxChoicesPerCategory: boolean;
13
+ alternates: never[];
14
+ categories: never[];
15
+ categoriesPerRow: number;
16
+ choices: never[];
17
+ choicesLabel: string;
18
+ choicesPosition: string;
19
+ correctResponse: never[];
20
+ feedbackEnabled: boolean;
21
+ lockChoiceOrder: boolean;
22
+ maxAnswerChoices: number;
23
+ maxChoicesPerCategory: number;
24
+ partialScoring: boolean;
25
+ promptEnabled: boolean;
26
+ rationaleEnabled: boolean;
27
+ rowLabels: string[];
28
+ studentInstructionsEnabled: boolean;
29
+ teacherInstructionsEnabled: boolean;
30
+ toolbarEditorPosition: string;
31
+ minRowHeight: string;
32
+ };
33
+ static disableAlternateResponses: (m: any) => any;
34
+ constructor();
35
+ set model(m: any);
36
+ set configuration(c: any);
37
+ onModelChanged(m: any): void;
38
+ onConfigurationChanged(c: any): void;
39
+ connectedCallback(): void;
40
+ /**
41
+ *
42
+ * @param {done, progress, file} handler
43
+ */
44
+ insertImage(handler: any): void;
45
+ onDeleteImage(src: any, done: any): void;
46
+ insertSound(handler: any): void;
47
+ onDeleteSound(src: any, done: any): void;
48
+ render(): void;
49
+ disconnectedCallback(): void;
50
+ }
@@ -0,0 +1,87 @@
1
+ import { Main as e } from "./main.js";
2
+ import t from "./defaults.js";
3
+ import n from "react";
4
+ import { createRoot as r } from "react-dom/client";
5
+ import { renderMath as i } from "@pie-element/shared-math-rendering-mathjax";
6
+ import { DeleteImageEvent as a, DeleteSoundEvent as o, InsertImageEvent as s, InsertSoundEvent as c, ModelUpdatedEvent as l } from "@pie-element/shared-configure-events";
7
+ //#region src/author/index.ts
8
+ var u = class u extends HTMLElement {
9
+ static createDefaultModel = (e = {}) => ({
10
+ ...t.model,
11
+ ...e
12
+ });
13
+ static disableAlternateResponses = (e) => {
14
+ let { correctResponse: t } = e || {};
15
+ t ||= [];
16
+ let n = t.map((e) => {
17
+ let { alternateResponses: t, ...n } = e;
18
+ return n;
19
+ });
20
+ return {
21
+ ...e,
22
+ correctResponse: n,
23
+ allowAlternateEnabled: !1
24
+ };
25
+ };
26
+ constructor() {
27
+ super(), this._root = null, this._model = u.createDefaultModel(), this._configuration = t.configuration;
28
+ }
29
+ set model(e) {
30
+ this._model = u.createDefaultModel(e), e.choices && e.choices.length >= e.maxAnswerChoices && (this._model.maxAnswerChoices = e.choices.length, console.warn("Max Answer Choices can't be less than choices length!")), this.render();
31
+ }
32
+ set configuration(e) {
33
+ let n = {
34
+ ...t.configuration,
35
+ ...e
36
+ };
37
+ this._configuration = n, n?.language?.enabled ? n?.languageChoices?.options?.length && (this._model.language = n?.languageChoices.options[0].value) : n.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({
38
+ value: this._model.language,
39
+ label: this._model.language
40
+ })) : delete this._model.language, this.render();
41
+ }
42
+ onModelChanged(e) {
43
+ this._model = e, this.render(), this.dispatchEvent(new l(this._model, !1));
44
+ }
45
+ onConfigurationChanged(e) {
46
+ this._configuration = e, this.render();
47
+ }
48
+ connectedCallback() {
49
+ this.render();
50
+ }
51
+ insertImage(e) {
52
+ this.dispatchEvent(new s(e));
53
+ }
54
+ onDeleteImage(e, t) {
55
+ this.dispatchEvent(new a(e, t));
56
+ }
57
+ insertSound(e) {
58
+ this.dispatchEvent(new c(e));
59
+ }
60
+ onDeleteSound(e, t) {
61
+ this.dispatchEvent(new o(e, t));
62
+ }
63
+ render() {
64
+ let t = n.createElement(e, {
65
+ model: this._model,
66
+ configuration: this._configuration,
67
+ onModelChanged: this.onModelChanged.bind(this),
68
+ onConfigurationChanged: this.onConfigurationChanged.bind(this),
69
+ imageSupport: {
70
+ add: this.insertImage.bind(this),
71
+ delete: this.onDeleteImage.bind(this)
72
+ },
73
+ uploadSoundSupport: {
74
+ add: this.insertSound.bind(this),
75
+ delete: this.onDeleteSound.bind(this)
76
+ }
77
+ });
78
+ this._root ||= r(this), this._root.render(t), setTimeout(() => {
79
+ i(this);
80
+ }, 0);
81
+ }
82
+ disconnectedCallback() {
83
+ this._root &&= (this._root.unmount(), null);
84
+ }
85
+ };
86
+ //#endregion
87
+ export { u as default };