@pie-element/categorize 13.2.0-beta.0 → 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 (202) 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 -2551
  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 -2130
  98. package/configure/lib/__tests__/main.test.js +0 -100
  99. package/configure/lib/__tests__/utils.js +0 -39
  100. package/configure/lib/defaults.js +0 -220
  101. package/configure/lib/defaults.js.map +0 -1
  102. package/configure/lib/design/__tests__/builder.test.js +0 -34
  103. package/configure/lib/design/__tests__/buttons.test.js +0 -36
  104. package/configure/lib/design/__tests__/header.test.js +0 -37
  105. package/configure/lib/design/__tests__/index.test.js +0 -269
  106. package/configure/lib/design/__tests__/input-header.test.js +0 -41
  107. package/configure/lib/design/builder.js +0 -55
  108. package/configure/lib/design/builder.js.map +0 -1
  109. package/configure/lib/design/buttons.js +0 -59
  110. package/configure/lib/design/buttons.js.map +0 -1
  111. package/configure/lib/design/categories/RowLabel.js +0 -66
  112. package/configure/lib/design/categories/RowLabel.js.map +0 -1
  113. package/configure/lib/design/categories/__tests__/alternateResponses.test.js +0 -93
  114. package/configure/lib/design/categories/__tests__/category.test.js +0 -65
  115. package/configure/lib/design/categories/__tests__/choice-preview.test.js +0 -52
  116. package/configure/lib/design/categories/__tests__/droppable-placeholder.test.js +0 -63
  117. package/configure/lib/design/categories/__tests__/index.test.js +0 -91
  118. package/configure/lib/design/categories/alternateResponses.js +0 -116
  119. package/configure/lib/design/categories/alternateResponses.js.map +0 -1
  120. package/configure/lib/design/categories/category.js +0 -153
  121. package/configure/lib/design/categories/category.js.map +0 -1
  122. package/configure/lib/design/categories/choice-preview.js +0 -79
  123. package/configure/lib/design/categories/choice-preview.js.map +0 -1
  124. package/configure/lib/design/categories/droppable-placeholder.js +0 -93
  125. package/configure/lib/design/categories/droppable-placeholder.js.map +0 -1
  126. package/configure/lib/design/categories/index.js +0 -256
  127. package/configure/lib/design/categories/index.js.map +0 -1
  128. package/configure/lib/design/choices/__tests__/choice.test.js +0 -62
  129. package/configure/lib/design/choices/__tests__/config.test.js +0 -66
  130. package/configure/lib/design/choices/__tests__/index.test.js +0 -70
  131. package/configure/lib/design/choices/choice.js +0 -187
  132. package/configure/lib/design/choices/choice.js.map +0 -1
  133. package/configure/lib/design/choices/config.js +0 -58
  134. package/configure/lib/design/choices/config.js.map +0 -1
  135. package/configure/lib/design/choices/index.js +0 -197
  136. package/configure/lib/design/choices/index.js.map +0 -1
  137. package/configure/lib/design/header.js +0 -71
  138. package/configure/lib/design/header.js.map +0 -1
  139. package/configure/lib/design/index.js +0 -741
  140. package/configure/lib/design/index.js.map +0 -1
  141. package/configure/lib/design/input-header.js +0 -105
  142. package/configure/lib/design/input-header.js.map +0 -1
  143. package/configure/lib/design/utils.js +0 -12
  144. package/configure/lib/design/utils.js.map +0 -1
  145. package/configure/lib/index.js +0 -148
  146. package/configure/lib/index.js.map +0 -1
  147. package/configure/lib/main.js +0 -44
  148. package/configure/lib/main.js.map +0 -1
  149. package/configure/lib/utils.js +0 -43
  150. package/configure/lib/utils.js.map +0 -1
  151. package/configure/package.json +0 -32
  152. package/controller/CHANGELOG.json +0 -452
  153. package/controller/CHANGELOG.md +0 -1384
  154. package/controller/lib/__tests__/index.test.js +0 -526
  155. package/controller/lib/defaults.js +0 -31
  156. package/controller/lib/defaults.js.map +0 -1
  157. package/controller/lib/index.js +0 -506
  158. package/controller/lib/index.js.map +0 -1
  159. package/controller/lib/utils.js +0 -69
  160. package/controller/lib/utils.js.map +0 -1
  161. package/controller/package.json +0 -18
  162. package/docs/config-schema.json +0 -2897
  163. package/docs/config-schema.json.md +0 -2138
  164. package/docs/demo/.pie/.configure/package.json +0 -10
  165. package/docs/demo/.pie/.configure/yarn.lock +0 -2122
  166. package/docs/demo/.pie/.controllers/package.json +0 -10
  167. package/docs/demo/.pie/.controllers/yarn.lock +0 -110
  168. package/docs/demo/.pie/info.entry.js +0 -89
  169. package/docs/demo/.pie/info.webpack.config.js +0 -119
  170. package/docs/demo/.pie/package.json +0 -10
  171. package/docs/demo/.pie/yarn.lock +0 -2137
  172. package/docs/demo/config.js +0 -8
  173. package/docs/demo/generate.js +0 -357
  174. package/docs/demo/index.html +0 -1
  175. package/docs/demo/pie.manifest.json +0 -11
  176. package/docs/demo/session.js +0 -12
  177. package/docs/pie-schema.json +0 -1784
  178. package/docs/pie-schema.json.md +0 -1046
  179. package/lib/__tests__/index.test.js +0 -197
  180. package/lib/categorize/__tests__/categories.test.js +0 -138
  181. package/lib/categorize/__tests__/category.test.js +0 -137
  182. package/lib/categorize/__tests__/choice.test.js +0 -88
  183. package/lib/categorize/__tests__/choices.test.js +0 -118
  184. package/lib/categorize/__tests__/droppable-placeholder.test.js +0 -96
  185. package/lib/categorize/__tests__/grid-content.test.js +0 -48
  186. package/lib/categorize/__tests__/index.test.js +0 -250
  187. package/lib/categorize/categories.js +0 -135
  188. package/lib/categorize/categories.js.map +0 -1
  189. package/lib/categorize/category.js +0 -67
  190. package/lib/categorize/category.js.map +0 -1
  191. package/lib/categorize/choice.js +0 -140
  192. package/lib/categorize/choice.js.map +0 -1
  193. package/lib/categorize/choices.js +0 -99
  194. package/lib/categorize/choices.js.map +0 -1
  195. package/lib/categorize/droppable-placeholder.js +0 -84
  196. package/lib/categorize/droppable-placeholder.js.map +0 -1
  197. package/lib/categorize/grid-content.js +0 -55
  198. package/lib/categorize/grid-content.js.map +0 -1
  199. package/lib/categorize/index.js +0 -450
  200. package/lib/categorize/index.js.map +0 -1
  201. package/lib/index.js +0 -316
  202. package/lib/index.js.map +0 -1
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/categorize/src/categorize/choices.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
+ import { ChoiceType } from './choice.js';
12
+ export { ChoiceType };
13
+ export declare class Choices extends React.Component {
14
+ static propTypes: {
15
+ choices: PropTypes.Requireable<(NonNullable<PropTypes.InferProps<{
16
+ content: PropTypes.Validator<string>;
17
+ id: PropTypes.Requireable<string>;
18
+ }> | PropTypes.InferProps<{
19
+ empty: PropTypes.Requireable<boolean>;
20
+ }> | null | undefined> | null | undefined)[]>;
21
+ model: PropTypes.Requireable<PropTypes.InferProps<{
22
+ categoriesPerRow: PropTypes.Requireable<number>;
23
+ choicesLabel: PropTypes.Requireable<string>;
24
+ }>>;
25
+ disabled: PropTypes.Requireable<boolean>;
26
+ choicePosition: PropTypes.Requireable<string>;
27
+ onDropChoice: PropTypes.Requireable<(...args: any[]) => any>;
28
+ onRemoveChoice: PropTypes.Requireable<(...args: any[]) => any>;
29
+ correct: any;
30
+ selectedItem: PropTypes.Requireable<object>;
31
+ onSelectClick: PropTypes.Requireable<(...args: any[]) => any>;
32
+ onPlacementClick: PropTypes.Requireable<(...args: any[]) => any>;
33
+ };
34
+ static defaultProps: {
35
+ model: {
36
+ categoriesPerRow: number;
37
+ choicesLabel: string;
38
+ };
39
+ };
40
+ render(): React.JSX.Element;
41
+ }
42
+ export default Choices;
@@ -0,0 +1,58 @@
1
+ import e, { ChoiceType as t } from "./choice.js";
2
+ import n from "./droppable-placeholder.js";
3
+ import r from "react";
4
+ import i from "prop-types";
5
+ import { styled as a } from "@mui/material/styles";
6
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
7
+ //#region src/delivery/categorize/choices.tsx
8
+ var c = a("div")({
9
+ flex: 1,
10
+ touchAction: "none"
11
+ }), l = a("div")(({ theme: e }) => ({
12
+ margin: "0 auto",
13
+ textAlign: "center",
14
+ paddingTop: e.spacing(1)
15
+ })), u = class extends r.Component {
16
+ static propTypes = {
17
+ choices: i.arrayOf(i.oneOfType([i.shape(t), i.shape({ empty: i.bool })])),
18
+ model: i.shape({
19
+ categoriesPerRow: i.number,
20
+ choicesLabel: i.string
21
+ }),
22
+ disabled: i.bool,
23
+ choicePosition: i.string,
24
+ onDropChoice: i.func,
25
+ onRemoveChoice: i.func,
26
+ correct: i.boolean,
27
+ selectedItem: i.object,
28
+ onSelectClick: i.func,
29
+ onPlacementClick: i.func
30
+ };
31
+ static defaultProps = { model: {
32
+ categoriesPerRow: 1,
33
+ choicesLabel: ""
34
+ } };
35
+ render() {
36
+ let { choices: t = [], model: r, disabled: i, onDropChoice: a, onRemoveChoice: u, choicePosition: d, correct: f, selectedItem: p, onSelectClick: m, onPlacementClick: h } = this.props, g = { textAlign: "center" };
37
+ return d === "left" && (g.direction = "rtl"), /* @__PURE__ */ o(c, { children: /* @__PURE__ */ s(n, {
38
+ id: "choices-board",
39
+ onDropChoice: a,
40
+ onRemoveChoice: u,
41
+ disabled: i,
42
+ style: { background: "none" },
43
+ choiceBoard: !0,
44
+ correct: f,
45
+ selectedItem: p,
46
+ onPlacementClick: h,
47
+ children: [r.choicesLabel && r.choicesLabel !== "" && /* @__PURE__ */ o(l, { dangerouslySetInnerHTML: { __html: r.choicesLabel } }), t.map((t, n) => t.empty ? /* @__PURE__ */ o("div", {}, n) : /* @__PURE__ */ o(e, {
48
+ disabled: i,
49
+ extraStyle: { maxWidth: `${95 / r.categoriesPerRow}%` },
50
+ selectedItem: p,
51
+ onSelectClick: m,
52
+ ...t
53
+ }, n))]
54
+ }) });
55
+ }
56
+ };
57
+ //#endregion
58
+ export { t as ChoiceType, u as Choices, u as default };
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/categorize/src/categorize/droppable-placeholder.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
+ declare const DroppablePlaceholder: {
12
+ ({ children, grid, disabled, choiceBoard, minRowHeight, id, correct, selectedItem, onPlacementClick, }: {
13
+ children: any;
14
+ grid: any;
15
+ disabled: any;
16
+ choiceBoard: any;
17
+ minRowHeight: any;
18
+ id: any;
19
+ correct: any;
20
+ selectedItem: any;
21
+ onPlacementClick: any;
22
+ }): React.JSX.Element;
23
+ propTypes: {
24
+ choiceBoard: PropTypes.Requireable<boolean>;
25
+ children: PropTypes.Validator<NonNullable<PropTypes.ReactNodeLike>>;
26
+ grid: PropTypes.Requireable<object>;
27
+ disabled: PropTypes.Requireable<boolean>;
28
+ minRowHeight: PropTypes.Requireable<string>;
29
+ onDropChoice: PropTypes.Requireable<(...args: any[]) => any>;
30
+ id: PropTypes.Validator<string>;
31
+ correct: PropTypes.Requireable<boolean>;
32
+ selectedItem: PropTypes.Requireable<object>;
33
+ onPlacementClick: PropTypes.Requireable<(...args: any[]) => any>;
34
+ };
35
+ };
36
+ export default DroppablePlaceholder;
@@ -0,0 +1,77 @@
1
+ import { useState as e } from "react";
2
+ import { color as t } from "@pie-lib/render-ui";
3
+ import n from "prop-types";
4
+ import r from "debug";
5
+ import { useTheme as i } from "@mui/material/styles";
6
+ import { useDroppable as a } from "@dnd-kit/core";
7
+ import { PlaceHolder as o } from "@pie-lib/drag";
8
+ import { jsx as s } from "react/jsx-runtime";
9
+ //#region src/delivery/categorize/droppable-placeholder.tsx
10
+ r("@pie-ui:categorize:droppable-placeholder");
11
+ var c = ({ children: n, grid: r, disabled: c, choiceBoard: l, minRowHeight: u, id: d, correct: f, selectedItem: p, onPlacementClick: m }) => {
12
+ let h = i(), [g, _] = e(!1), { setNodeRef: v, isOver: y } = a({
13
+ id: d,
14
+ data: {
15
+ itemType: "categorize",
16
+ categoryId: d
17
+ },
18
+ disabled: c
19
+ }), b = !!p, x = y || b && g && !c, S = !c, C = () => {
20
+ c || !p || m?.(d);
21
+ }, w = (e) => {
22
+ e.target === e.currentTarget && (e.code === "Space" || e.code === "Enter") && (e.preventDefault(), C());
23
+ }, T = {
24
+ padding: h.spacing(.5),
25
+ borderRadius: h.spacing(.5),
26
+ gridColumnGap: 0,
27
+ gridRowGap: 0,
28
+ display: "flex",
29
+ flexWrap: "wrap",
30
+ justifyContent: "center",
31
+ alignItems: "center",
32
+ alignContent: "flex-start",
33
+ width: "100%",
34
+ height: "100%",
35
+ ...f === !1 && !l && { border: `solid 2px ${t.incorrect()}` },
36
+ ...f === !0 && !l && { border: `solid 2px ${t.correct()}` }
37
+ };
38
+ return /* @__PURE__ */ s("div", {
39
+ ref: v,
40
+ role: S ? "button" : void 0,
41
+ tabIndex: S ? 0 : -1,
42
+ onClick: C,
43
+ onKeyDown: S ? w : void 0,
44
+ onMouseEnter: () => _(!0),
45
+ onMouseLeave: () => _(!1),
46
+ style: {
47
+ flex: 1,
48
+ minHeight: u || "80px",
49
+ position: "relative",
50
+ touchAction: "none",
51
+ ...b && !c && { cursor: "pointer" }
52
+ },
53
+ children: /* @__PURE__ */ s(o, {
54
+ isOver: x,
55
+ grid: r,
56
+ disabled: c,
57
+ choiceBoard: l,
58
+ isCategorize: !0,
59
+ extraStyles: T,
60
+ children: n
61
+ })
62
+ });
63
+ };
64
+ c.propTypes = {
65
+ choiceBoard: n.bool,
66
+ children: n.node.isRequired,
67
+ grid: n.object,
68
+ disabled: n.bool,
69
+ minRowHeight: n.string,
70
+ onDropChoice: n.func,
71
+ id: n.string.isRequired,
72
+ correct: n.bool,
73
+ selectedItem: n.object,
74
+ onPlacementClick: n.func
75
+ };
76
+ //#endregion
77
+ export { c as default };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/categorize/src/categorize/grid-content.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 GridContent extends React.Component {
12
+ static propTypes: {
13
+ className: PropTypes.Requireable<string>;
14
+ children: PropTypes.Validator<NonNullable<NonNullable<PropTypes.ReactNodeLike>>>;
15
+ columns: PropTypes.Requireable<number>;
16
+ rows: PropTypes.Requireable<number>;
17
+ extraStyle: PropTypes.Requireable<object>;
18
+ };
19
+ static defaultProps: {
20
+ columns: number;
21
+ rows: number;
22
+ };
23
+ render(): React.JSX.Element;
24
+ }
25
+ export default GridContent;
@@ -0,0 +1,39 @@
1
+ import e from "react";
2
+ import t from "prop-types";
3
+ import { styled as n } from "@mui/material/styles";
4
+ import { jsx as r } from "react/jsx-runtime";
5
+ //#region src/delivery/categorize/grid-content.tsx
6
+ var i = class extends e.Component {
7
+ static propTypes = {
8
+ className: t.string,
9
+ children: t.oneOfType([t.arrayOf(t.node), t.node]).isRequired,
10
+ columns: t.number,
11
+ rows: t.number,
12
+ extraStyle: t.object
13
+ };
14
+ static defaultProps = {
15
+ columns: 2,
16
+ rows: 2
17
+ };
18
+ render() {
19
+ let { className: e, children: t, columns: n, extraStyle: i, rows: o } = this.props;
20
+ return /* @__PURE__ */ r(a, {
21
+ style: {
22
+ gridTemplateColumns: `repeat(${n}, 1fr)`,
23
+ gridTemplateRows: o === 2 ? "auto 1fr" : `repeat(${o}, auto)`,
24
+ ...i
25
+ },
26
+ className: e,
27
+ children: t
28
+ });
29
+ }
30
+ }, a = n("div")(({ theme: e }) => ({
31
+ display: "grid",
32
+ columnGap: e.spacing(1),
33
+ gridColumnGap: e.spacing(1),
34
+ rowGap: e.spacing(1),
35
+ gridRowGap: e.spacing(1),
36
+ gridAutoRows: "1fr"
37
+ }));
38
+ //#endregion
39
+ export { i as GridContent, i as default };
@@ -0,0 +1,70 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/categorize/src/categorize/index.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 Categorize extends React.Component {
12
+ static propTypes: {
13
+ model: PropTypes.Requireable<object>;
14
+ session: PropTypes.Requireable<PropTypes.InferProps<{
15
+ answers: PropTypes.Requireable<(PropTypes.InferProps<{
16
+ choice: PropTypes.Requireable<string>;
17
+ category: PropTypes.Requireable<string>;
18
+ }> | null | undefined)[]>;
19
+ }>>;
20
+ onAnswersChange: PropTypes.Validator<(...args: any[]) => any>;
21
+ onShowCorrectToggle: PropTypes.Validator<(...args: any[]) => any>;
22
+ pauseMathObserver: PropTypes.Requireable<(...args: any[]) => any>;
23
+ resumeMathObserver: PropTypes.Requireable<(...args: any[]) => any>;
24
+ selectedItem: PropTypes.Requireable<object>;
25
+ onSelectClick: PropTypes.Requireable<(...args: any[]) => any>;
26
+ onPlacementClick: PropTypes.Requireable<(...args: any[]) => any>;
27
+ };
28
+ static defaultProps: {
29
+ disabled: boolean;
30
+ };
31
+ constructor(props: any);
32
+ removeChoice: any;
33
+ dropChoice: any;
34
+ UNSAFE_componentWillReceiveProps(nextProps: any): void;
35
+ toggleShowCorrect: () => void;
36
+ getPositionDirection: any;
37
+ existAlternateResponse: (correctResponse: any) => any;
38
+ render(): React.JSX.Element;
39
+ }
40
+ declare class CategorizeProvider extends React.Component {
41
+ static propTypes: {
42
+ model: PropTypes.Requireable<object>;
43
+ session: PropTypes.Requireable<PropTypes.InferProps<{
44
+ answers: PropTypes.Requireable<(PropTypes.InferProps<{
45
+ choice: PropTypes.Requireable<string>;
46
+ category: PropTypes.Requireable<string>;
47
+ }> | null | undefined)[]>;
48
+ }>>;
49
+ onAnswersChange: PropTypes.Validator<(...args: any[]) => any>;
50
+ onShowCorrectToggle: PropTypes.Validator<(...args: any[]) => any>;
51
+ pauseMathObserver: PropTypes.Requireable<(...args: any[]) => any>;
52
+ resumeMathObserver: PropTypes.Requireable<(...args: any[]) => any>;
53
+ };
54
+ constructor(props: any);
55
+ onDragStart: any;
56
+ commitPlacement: any;
57
+ onDragEnd: any;
58
+ onDragCancel: any;
59
+ isSameItem: (a: any, b: any) => boolean;
60
+ toggleItemSelection: any;
61
+ cancelSelection: any;
62
+ endAnyLiveKeyboardDrag: any;
63
+ placeSelectedItem: any;
64
+ isClickSoonAfterDragEnd: () => boolean;
65
+ onItemClick: any;
66
+ onPlacementClick: any;
67
+ renderDragOverlay: any;
68
+ render(): React.JSX.Element;
69
+ }
70
+ export default CategorizeProvider;
@@ -0,0 +1,317 @@
1
+ import e from "./choice.js";
2
+ import { Choices as t } from "./choices.js";
3
+ import { Categories as n } from "./categories.js";
4
+ import { closestDroppableKeyboardCoordinates as r } from "./keyboard-coordinates.js";
5
+ import i from "react";
6
+ import { renderMath as a } from "@pie-element/shared-math-rendering-mathjax";
7
+ import * as o from "@pie-lib/render-ui";
8
+ import { Collapsible as s, Feedback as c, PreviewPrompt as l, UiLayout as u, color as d, hasMedia as f, hasText as p } from "@pie-lib/render-ui";
9
+ import m from "prop-types";
10
+ import h from "debug";
11
+ import { styled as g } from "@mui/material/styles";
12
+ import { DragOverlay as _ } from "@dnd-kit/core";
13
+ import v from "@pie-lib/correct-answer-toggle";
14
+ import { buildState as y, moveChoiceToCategory as b, removeChoiceFromCategory as x } from "@pie-lib/categorize";
15
+ import { DragProvider as S, uid as C } from "@pie-lib/drag";
16
+ import { jsx as w, jsxs as T } from "react/jsx-runtime";
17
+ import E from "@pie-lib/translator";
18
+ import { AlertDialog as D } from "@pie-lib/config-ui";
19
+ //#region src/delivery/categorize/index.tsx
20
+ function O(e) {
21
+ return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
22
+ }
23
+ function k(e, t) {
24
+ return !e || O(e) ? e : O(e.default) ? e.default : t && O(e[t]) ? e[t] : t && O(e[t]?.default) ? e[t].default : e;
25
+ }
26
+ var A = k(u, "UiLayout") || k(I.UiLayout, "UiLayout"), j = k(l, "PreviewPrompt") || k(I.PreviewPrompt, "PreviewPrompt"), M = k(s, "Collapsible") || k(I.Collapsible, "Collapsible"), N = k(c, "Feedback") || k(I.Feedback, "Feedback"), P = o, F = P.default, I = F && typeof F == "object" ? F : P, { translator: L } = E, R = h("@pie-ui:categorize"), z = "choices-board", B = 250, V = class extends i.Component {
27
+ static propTypes = { children: m.node };
28
+ containerRef = i.createRef();
29
+ componentDidMount() {
30
+ this.containerRef.current && a(this.containerRef.current);
31
+ }
32
+ render() {
33
+ return /* @__PURE__ */ w("div", {
34
+ ref: this.containerRef,
35
+ children: this.props.children
36
+ });
37
+ }
38
+ }, H = class extends i.Component {
39
+ static propTypes = {
40
+ model: m.object,
41
+ session: m.shape({ answers: m.arrayOf(m.shape({
42
+ choice: m.string,
43
+ category: m.string
44
+ })) }),
45
+ onAnswersChange: m.func.isRequired,
46
+ onShowCorrectToggle: m.func.isRequired,
47
+ pauseMathObserver: m.func,
48
+ resumeMathObserver: m.func,
49
+ selectedItem: m.object,
50
+ onSelectClick: m.func,
51
+ onPlacementClick: m.func
52
+ };
53
+ static defaultProps = { disabled: !1 };
54
+ constructor(e) {
55
+ super(e), this.state = {
56
+ showCorrect: !1,
57
+ showMaxChoiceAlert: !1
58
+ };
59
+ }
60
+ removeChoice = (e) => {
61
+ R("[removeChoice]: ", e);
62
+ let { onAnswersChange: t, session: n } = this.props;
63
+ t(x(e.id, e.categoryId, e.choiceIndex, n.answers));
64
+ };
65
+ dropChoice = (e, t) => {
66
+ let { session: n, onAnswersChange: r, model: i } = this.props, { maxChoicesPerCategory: a = 0 } = i || {}, { answers: o = [] } = n || {}, s;
67
+ t ? R("[dropChoice] category: ", t.categoryId, "choice: ", t) : R("[dropChoice] category: ", void 0, "choice: ", void 0);
68
+ let c = o.find((t) => t.category === e);
69
+ t && a === 1 && c && c.choices && c.choices.length === 1 ? (s = b(t.id, t.categoryId, e, t.choiceIndex, o), s = x(c.choices[0], e, 0, s)) : t && a > 1 && c && c.choices && c.choices.length === a ? (s = t.categoryId ? b(t.id, t.categoryId, t.categoryId, t.choiceIndex, o) : x(t.id, t.categoryId, t.choiceIndex, o), this.setState({ showMaxChoiceAlert: !0 })) : a !== 0 && c && c.choices && c.choices.length > a ? (s = o, this.setState({ showMaxChoiceAlert: !0 })) : s = t ? b(t.id, t.categoryId, e, t.choiceIndex, o) : this.removeChoice(e), t && r(s);
70
+ };
71
+ UNSAFE_componentWillReceiveProps(e) {
72
+ let { model: t } = this.props, { model: n } = e;
73
+ t.note && t.language && t.language !== n.language && t.note === L.t("common:commonCorrectAnswerWithAlternates", { lng: t.language }) && (t.note = L.t("common:commonCorrectAnswerWithAlternates", { lng: n.language })), this.setState({ showCorrect: !1 });
74
+ }
75
+ toggleShowCorrect = () => this.setState({ showCorrect: !this.state.showCorrect }, () => {
76
+ this.props.onShowCorrectToggle();
77
+ });
78
+ getPositionDirection = (e) => {
79
+ let t;
80
+ switch (e) {
81
+ case "left":
82
+ t = "row-reverse";
83
+ break;
84
+ case "right":
85
+ t = "row";
86
+ break;
87
+ case "below":
88
+ t = "column";
89
+ break;
90
+ default:
91
+ t = "column-reverse";
92
+ break;
93
+ }
94
+ return t;
95
+ };
96
+ existAlternateResponse = (e) => e?.some((e) => e.alternateResponses?.length > 0);
97
+ render() {
98
+ let { model: e, session: r, selectedItem: a, onSelectClick: o, onPlacementClick: s } = this.props, { showCorrect: c, showMaxChoiceAlert: l } = this.state, { choicesPosition: u, extraCSSRules: d, note: m, showNote: h, env: g, language: _, maxChoicesPerCategory: b, autoplayAudioEnabled: x, customAudioButton: S } = e, { mode: C, role: E } = g || {}, O = u || "above", k = {
99
+ flexDirection: this.getPositionDirection(O),
100
+ gap: "8px"
101
+ }, { categories: A, choices: M, correct: P } = y(e.categories, e.choices, c ? e.correctResponse : r.answers, e.correctResponse);
102
+ R("[render] disabled: ", e.disabled);
103
+ let { rowLabels: F, categoriesPerRow: I, correctResponse: z, fontSizeFactor: B } = e, V = A && Math.ceil(A.length / I) || 0, H = this.existAlternateResponse(z) || !1, U = (c || C === "view" && E === "instructor") && h && m && H, J = L.t("translation:categorize:limitMaxChoicesPerCategory", {
104
+ lng: e.language,
105
+ maxChoicesPerCategory: b
106
+ }), Y = L.t("common:warning", { lng: e.language }), X = L.t("common:cancel", { lng: e.language }), Z = e.rationale && (p(e.rationale) || f(e.rationale));
107
+ return /* @__PURE__ */ T(W, {
108
+ extraCSSRules: d,
109
+ id: "main-container",
110
+ fontSizeFactor: B,
111
+ children: [
112
+ e.teacherInstructions && (p(e.teacherInstructions) || f(e.teacherInstructions)) && /* @__PURE__ */ w(i.Fragment, { children: /* @__PURE__ */ w(q, {
113
+ labels: {
114
+ hidden: "Show Teacher Instructions",
115
+ visible: "Hide Teacher Instructions"
116
+ },
117
+ children: /* @__PURE__ */ w(j, { prompt: e.teacherInstructions })
118
+ }) }),
119
+ e.prompt && /* @__PURE__ */ w(j, {
120
+ prompt: e.prompt,
121
+ autoplayAudioEnabled: x,
122
+ customAudioButton: S
123
+ }),
124
+ /* @__PURE__ */ w(v, {
125
+ show: c || P === !1,
126
+ toggled: c,
127
+ onToggle: this.toggleShowCorrect,
128
+ language: _
129
+ }),
130
+ /* @__PURE__ */ T(K, {
131
+ style: k,
132
+ children: [/* @__PURE__ */ w("div", {
133
+ style: {
134
+ display: "flex",
135
+ flex: 1
136
+ },
137
+ children: /* @__PURE__ */ w(n, {
138
+ model: e,
139
+ disabled: e.disabled,
140
+ categories: A,
141
+ onDropChoice: this.dropChoice,
142
+ onRemoveChoice: this.removeChoice,
143
+ rowLabels: (F || []).slice(0, V),
144
+ selectedItem: a,
145
+ onSelectClick: o,
146
+ onPlacementClick: s
147
+ })
148
+ }), /* @__PURE__ */ w(t, {
149
+ disabled: e.disabled,
150
+ model: e,
151
+ choices: M,
152
+ choicePosition: O,
153
+ onDropChoice: this.dropChoice,
154
+ onRemoveChoice: this.removeChoice,
155
+ correct: P,
156
+ selectedItem: a,
157
+ onSelectClick: o,
158
+ onPlacementClick: s
159
+ })]
160
+ }),
161
+ U && /* @__PURE__ */ w(G, { dangerouslySetInnerHTML: { __html: m } }),
162
+ Z && /* @__PURE__ */ w(q, {
163
+ labels: {
164
+ hidden: "Show Rationale",
165
+ visible: "Hide Rationale"
166
+ },
167
+ children: /* @__PURE__ */ w(j, { prompt: e.rationale })
168
+ }),
169
+ e.correctness && e.feedback && !c && /* @__PURE__ */ w(N, {
170
+ correctness: e.correctness,
171
+ feedback: e.feedback
172
+ }),
173
+ /* @__PURE__ */ w(D, {
174
+ title: Y,
175
+ text: J,
176
+ open: l,
177
+ onCloseText: X,
178
+ onClose: () => this.setState({ showMaxChoiceAlert: !1 })
179
+ })
180
+ ]
181
+ });
182
+ }
183
+ }, U = class extends i.Component {
184
+ static propTypes = {
185
+ model: m.object,
186
+ session: m.shape({ answers: m.arrayOf(m.shape({
187
+ choice: m.string,
188
+ category: m.string
189
+ })) }),
190
+ onAnswersChange: m.func.isRequired,
191
+ onShowCorrectToggle: m.func.isRequired,
192
+ pauseMathObserver: m.func,
193
+ resumeMathObserver: m.func
194
+ };
195
+ constructor(e) {
196
+ super(e), this.uid = C.generateId(), this.state = {
197
+ activeDragItem: null,
198
+ isValidDrop: !1,
199
+ selectedItem: null
200
+ }, this.lastDragEndAt = 0, this.isInternalDragCancel = !1;
201
+ }
202
+ onDragStart = (e) => {
203
+ let { active: t } = e, { pauseMathObserver: n } = this.props;
204
+ n && n(), t?.data?.current && this.setState({
205
+ activeDragItem: t.data.current,
206
+ isValidDrop: !1,
207
+ selectedItem: t.data.current
208
+ });
209
+ };
210
+ commitPlacement = (e, t) => {
211
+ if (this.categorizeRef) {
212
+ if (t === void 0 || t === z) {
213
+ e.categoryId && this.categorizeRef.removeChoice && this.categorizeRef.removeChoice(e);
214
+ return;
215
+ }
216
+ this.categorizeRef.dropChoice && this.categorizeRef.dropChoice(t, e);
217
+ }
218
+ };
219
+ onDragEnd = (e) => {
220
+ let { active: t, over: n } = e, { resumeMathObserver: r } = this.props, i = t?.data?.current, a = n?.data?.current, o = n && t && i && i.type === "choice" && a && a.itemType === "categorize";
221
+ if (this.setState({
222
+ activeDragItem: null,
223
+ isValidDrop: o,
224
+ selectedItem: null
225
+ }), r && r(), this.lastDragEndAt = Date.now(), !t || !i || i.type !== "choice") return;
226
+ let s = {
227
+ id: i.id,
228
+ categoryId: i.categoryId,
229
+ choiceIndex: i.choiceIndex,
230
+ value: i.value,
231
+ itemType: i.itemType
232
+ };
233
+ this.commitPlacement(s, n ? n.id : void 0);
234
+ };
235
+ onDragCancel = () => {
236
+ let { resumeMathObserver: e } = this.props;
237
+ this.setState({
238
+ activeDragItem: null,
239
+ isValidDrop: !1,
240
+ selectedItem: null
241
+ }), e && e(), this.isInternalDragCancel ? this.isInternalDragCancel = !1 : this.lastDragEndAt = Date.now();
242
+ };
243
+ isSameItem = (e, t) => !!e && !!t && e.id === t.id && e.categoryId === t.categoryId && e.choiceIndex === t.choiceIndex;
244
+ toggleItemSelection = (e) => {
245
+ this.setState((t) => ({ selectedItem: this.isSameItem(t.selectedItem, e) ? null : e }));
246
+ };
247
+ cancelSelection = () => {
248
+ this.setState({ selectedItem: null });
249
+ };
250
+ endAnyLiveKeyboardDrag = () => {
251
+ this.state.activeDragItem && (this.isInternalDragCancel = !0, document.dispatchEvent(new KeyboardEvent("keydown", {
252
+ code: "Escape",
253
+ bubbles: !0,
254
+ cancelable: !0
255
+ })), this.isInternalDragCancel = !1);
256
+ };
257
+ placeSelectedItem = (e) => {
258
+ let { selectedItem: t } = this.state;
259
+ t && (this.commitPlacement(t, e), this.cancelSelection(), this.endAnyLiveKeyboardDrag());
260
+ };
261
+ isClickSoonAfterDragEnd = () => Date.now() - this.lastDragEndAt < B;
262
+ onItemClick = (e) => {
263
+ this.isClickSoonAfterDragEnd() || (this.endAnyLiveKeyboardDrag(), this.toggleItemSelection(e));
264
+ };
265
+ onPlacementClick = (e) => {
266
+ this.isClickSoonAfterDragEnd() || this.placeSelectedItem(e);
267
+ };
268
+ renderDragOverlay = () => {
269
+ let { activeDragItem: t } = this.state, { model: n } = this.props;
270
+ if (!t) return null;
271
+ if (t.type === "choice") {
272
+ let r = n.choices?.find((e) => e.id === t.id);
273
+ if (r) return /* @__PURE__ */ w(e, {
274
+ id: r.id,
275
+ ...r
276
+ }, r.id);
277
+ }
278
+ return null;
279
+ };
280
+ render() {
281
+ let { isValidDrop: e, selectedItem: t } = this.state, n = e ? null : void 0;
282
+ return /* @__PURE__ */ w(S, {
283
+ onDragStart: this.onDragStart,
284
+ onDragEnd: this.onDragEnd,
285
+ onDragCancel: this.onDragCancel,
286
+ keyboardCoordinateGetter: r,
287
+ keyboardCodes: {
288
+ start: ["Space", "Enter"],
289
+ cancel: ["Escape"],
290
+ end: ["Space", "Enter"]
291
+ },
292
+ children: /* @__PURE__ */ T(C.Provider, {
293
+ value: this.uid,
294
+ children: [/* @__PURE__ */ w(H, {
295
+ ref: (e) => this.categorizeRef = e,
296
+ ...this.props,
297
+ selectedItem: t,
298
+ onSelectClick: this.onItemClick,
299
+ onPlacementClick: this.onPlacementClick
300
+ }), /* @__PURE__ */ w(_, {
301
+ dropAnimation: n,
302
+ children: /* @__PURE__ */ w(V, { children: this.renderDragOverlay() })
303
+ })]
304
+ })
305
+ });
306
+ }
307
+ }, W = g(A)({
308
+ color: d.text(),
309
+ backgroundColor: d.background(),
310
+ position: "relative"
311
+ }), G = g("div")(({ theme: e }) => ({ marginBottom: e.spacing(2) })), K = g("div")(({ theme: e }) => ({
312
+ marginBottom: e.spacing(1),
313
+ display: "flex",
314
+ flexDirection: "column"
315
+ })), q = g(M)(({ theme: e }) => ({ paddingBottom: e.spacing(2) }));
316
+ //#endregion
317
+ export { H as Categorize, U as default };