@pie-element/categorize 13.1.2-next.2 → 13.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/CHANGELOG.json +1637 -0
  2. package/CHANGELOG.md +2542 -0
  3. package/LICENSE.md +5 -0
  4. package/README.md +5 -0
  5. package/configure/CHANGELOG.json +1202 -0
  6. package/configure/CHANGELOG.md +2125 -0
  7. package/configure/lib/defaults.js +222 -0
  8. package/configure/lib/defaults.js.map +1 -0
  9. package/configure/lib/design/builder.js +55 -0
  10. package/configure/lib/design/builder.js.map +1 -0
  11. package/configure/lib/design/buttons.js +59 -0
  12. package/configure/lib/design/buttons.js.map +1 -0
  13. package/configure/lib/design/categories/RowLabel.js +66 -0
  14. package/configure/lib/design/categories/RowLabel.js.map +1 -0
  15. package/configure/lib/design/categories/alternateResponses.js +116 -0
  16. package/configure/lib/design/categories/alternateResponses.js.map +1 -0
  17. package/configure/lib/design/categories/category.js +153 -0
  18. package/configure/lib/design/categories/category.js.map +1 -0
  19. package/configure/lib/design/categories/choice-preview.js +79 -0
  20. package/configure/lib/design/categories/choice-preview.js.map +1 -0
  21. package/configure/lib/design/categories/droppable-placeholder.js +93 -0
  22. package/configure/lib/design/categories/droppable-placeholder.js.map +1 -0
  23. package/configure/lib/design/categories/index.js +256 -0
  24. package/configure/lib/design/categories/index.js.map +1 -0
  25. package/configure/lib/design/choices/choice.js +187 -0
  26. package/configure/lib/design/choices/choice.js.map +1 -0
  27. package/configure/lib/design/choices/config.js +58 -0
  28. package/configure/lib/design/choices/config.js.map +1 -0
  29. package/configure/lib/design/choices/index.js +197 -0
  30. package/configure/lib/design/choices/index.js.map +1 -0
  31. package/configure/lib/design/header.js +71 -0
  32. package/configure/lib/design/header.js.map +1 -0
  33. package/configure/lib/design/index.js +727 -0
  34. package/configure/lib/design/index.js.map +1 -0
  35. package/configure/lib/design/input-header.js +105 -0
  36. package/configure/lib/design/input-header.js.map +1 -0
  37. package/configure/lib/design/utils.js +12 -0
  38. package/configure/lib/design/utils.js.map +1 -0
  39. package/configure/lib/index.js +147 -0
  40. package/configure/lib/index.js.map +1 -0
  41. package/configure/lib/main.js +44 -0
  42. package/configure/lib/main.js.map +1 -0
  43. package/configure/lib/utils.js +43 -0
  44. package/configure/lib/utils.js.map +1 -0
  45. package/configure/package.json +32 -0
  46. package/controller/CHANGELOG.json +452 -0
  47. package/controller/CHANGELOG.md +1377 -0
  48. package/controller/lib/defaults.js +33 -0
  49. package/controller/lib/defaults.js.map +1 -0
  50. package/controller/lib/index.js +479 -0
  51. package/controller/lib/index.js.map +1 -0
  52. package/controller/lib/utils.js +69 -0
  53. package/controller/lib/utils.js.map +1 -0
  54. package/controller/package.json +18 -0
  55. package/docs/config-schema.json +2897 -0
  56. package/docs/config-schema.json.md +2138 -0
  57. package/docs/demo/config.js +8 -0
  58. package/docs/demo/generate.js +357 -0
  59. package/docs/demo/index.html +1 -0
  60. package/docs/demo/session.js +12 -0
  61. package/docs/pie-schema.json +1784 -0
  62. package/docs/pie-schema.json.md +1046 -0
  63. package/lib/categorize/categories.js +135 -0
  64. package/lib/categorize/categories.js.map +1 -0
  65. package/lib/categorize/category.js +67 -0
  66. package/lib/categorize/category.js.map +1 -0
  67. package/lib/categorize/choice.js +140 -0
  68. package/lib/categorize/choice.js.map +1 -0
  69. package/lib/categorize/choices.js +99 -0
  70. package/lib/categorize/choices.js.map +1 -0
  71. package/lib/categorize/droppable-placeholder.js +84 -0
  72. package/lib/categorize/droppable-placeholder.js.map +1 -0
  73. package/lib/categorize/grid-content.js +55 -0
  74. package/lib/categorize/grid-content.js.map +1 -0
  75. package/lib/categorize/index.js +450 -0
  76. package/lib/categorize/index.js.map +1 -0
  77. package/lib/index.js +316 -0
  78. package/lib/index.js.map +1 -0
  79. package/package.json +22 -85
  80. package/configure.js +0 -2
  81. package/controller.js +0 -1
  82. package/dist/author/defaults.d.ts +0 -223
  83. package/dist/author/defaults.js +0 -170
  84. package/dist/author/design/builder.d.ts +0 -10
  85. package/dist/author/design/builder.js +0 -24
  86. package/dist/author/design/buttons.d.ts +0 -28
  87. package/dist/author/design/buttons.js +0 -36
  88. package/dist/author/design/categories/RowLabel.d.ts +0 -23
  89. package/dist/author/design/categories/RowLabel.js +0 -47
  90. package/dist/author/design/categories/alternateResponses.d.ts +0 -31
  91. package/dist/author/design/categories/alternateResponses.js +0 -62
  92. package/dist/author/design/categories/category.d.ts +0 -44
  93. package/dist/author/design/categories/category.js +0 -98
  94. package/dist/author/design/categories/choice-preview.d.ts +0 -25
  95. package/dist/author/design/categories/choice-preview.js +0 -60
  96. package/dist/author/design/categories/droppable-placeholder.d.ts +0 -11
  97. package/dist/author/design/categories/droppable-placeholder.js +0 -71
  98. package/dist/author/design/categories/index.d.ts +0 -41
  99. package/dist/author/design/categories/index.js +0 -146
  100. package/dist/author/design/choices/choice.d.ts +0 -11
  101. package/dist/author/design/choices/choice.js +0 -129
  102. package/dist/author/design/choices/config.d.ts +0 -21
  103. package/dist/author/design/choices/config.js +0 -33
  104. package/dist/author/design/choices/index.d.ts +0 -41
  105. package/dist/author/design/choices/index.js +0 -110
  106. package/dist/author/design/header.d.ts +0 -24
  107. package/dist/author/design/header.js +0 -49
  108. package/dist/author/design/index.d.ts +0 -52
  109. package/dist/author/design/index.js +0 -417
  110. package/dist/author/design/input-header.d.ts +0 -39
  111. package/dist/author/design/input-header.js +0 -69
  112. package/dist/author/design/utils.d.ts +0 -9
  113. package/dist/author/design/utils.js +0 -7
  114. package/dist/author/index.d.ts +0 -51
  115. package/dist/author/index.js +0 -87
  116. package/dist/author/main.d.ts +0 -23
  117. package/dist/author/main.js +0 -30
  118. package/dist/author/utils.d.ts +0 -16
  119. package/dist/author/utils.js +0 -17
  120. package/dist/browser/author/index.js +0 -2041
  121. package/dist/browser/author/index.js.map +0 -1
  122. package/dist/browser/categorize.css +0 -2
  123. package/dist/browser/controller/index.js +0 -299
  124. package/dist/browser/controller/index.js.map +0 -1
  125. package/dist/browser/delivery/index.js +0 -1051
  126. package/dist/browser/delivery/index.js.map +0 -1
  127. package/dist/browser/dist-BINEJ0Vp.js +0 -1954
  128. package/dist/browser/dist-BINEJ0Vp.js.map +0 -1
  129. package/dist/browser/dist-DDCLQ8jp.js +0 -49802
  130. package/dist/browser/dist-DDCLQ8jp.js.map +0 -1
  131. package/dist/controller/defaults.d.ts +0 -34
  132. package/dist/controller/defaults.js +0 -29
  133. package/dist/controller/index.d.ts +0 -61
  134. package/dist/controller/index.js +0 -155
  135. package/dist/controller/utils.d.ts +0 -20
  136. package/dist/controller/utils.js +0 -35
  137. package/dist/delivery/categorize/categories.d.ts +0 -34
  138. package/dist/delivery/categorize/categories.js +0 -66
  139. package/dist/delivery/categorize/category.d.ts +0 -28
  140. package/dist/delivery/categorize/category.js +0 -48
  141. package/dist/delivery/categorize/choice.d.ts +0 -27
  142. package/dist/delivery/categorize/choice.js +0 -94
  143. package/dist/delivery/categorize/choices.d.ts +0 -39
  144. package/dist/delivery/categorize/choices.js +0 -51
  145. package/dist/delivery/categorize/droppable-placeholder.d.ts +0 -32
  146. package/dist/delivery/categorize/droppable-placeholder.js +0 -64
  147. package/dist/delivery/categorize/grid-content.d.ts +0 -25
  148. package/dist/delivery/categorize/grid-content.js +0 -39
  149. package/dist/delivery/categorize/index.d.ts +0 -57
  150. package/dist/delivery/categorize/index.js +0 -260
  151. package/dist/delivery/index.d.ts +0 -27
  152. package/dist/delivery/index.js +0 -152
  153. package/dist/index.d.ts +0 -1
  154. package/dist/index.iife.d.ts +0 -8
  155. package/dist/index.iife.js +0 -152
  156. package/dist/index.js +0 -2
  157. package/dist/runtime-support.d.ts +0 -12
  158. package/dist/runtime-support.js +0 -12
@@ -1,51 +0,0 @@
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
- };
28
- static defaultProps = { model: {
29
- categoriesPerRow: 1,
30
- choicesLabel: ""
31
- } };
32
- render() {
33
- let { choices: t = [], model: r, disabled: i, onDropChoice: a, onRemoveChoice: u, choicePosition: d, correct: f } = this.props, p = { textAlign: "center" };
34
- return d === "left" && (p.direction = "rtl"), /* @__PURE__ */ o(c, { children: /* @__PURE__ */ s(n, {
35
- id: "choices-board",
36
- onDropChoice: a,
37
- onRemoveChoice: u,
38
- disabled: i,
39
- style: { background: "none" },
40
- choiceBoard: !0,
41
- correct: f,
42
- 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, {
43
- disabled: i,
44
- extraStyle: { maxWidth: `${95 / r.categoriesPerRow}%` },
45
- ...t
46
- }, n))]
47
- }) });
48
- }
49
- };
50
- //#endregion
51
- export { u as default };
@@ -1,32 +0,0 @@
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 }: {
13
- children: any;
14
- grid: any;
15
- disabled: any;
16
- choiceBoard: any;
17
- minRowHeight: any;
18
- id: any;
19
- correct: any;
20
- }): React.JSX.Element;
21
- propTypes: {
22
- choiceBoard: PropTypes.Requireable<boolean>;
23
- children: PropTypes.Validator<NonNullable<PropTypes.ReactNodeLike>>;
24
- grid: PropTypes.Requireable<object>;
25
- disabled: PropTypes.Requireable<boolean>;
26
- minRowHeight: PropTypes.Requireable<string>;
27
- onDropChoice: PropTypes.Requireable<(...args: any[]) => any>;
28
- id: PropTypes.Validator<string>;
29
- correct: PropTypes.Requireable<boolean>;
30
- };
31
- };
32
- export default DroppablePlaceholder;
@@ -1,64 +0,0 @@
1
- import "react";
2
- import { color as e } from "@pie-lib/render-ui";
3
- import t from "prop-types";
4
- import n from "debug";
5
- import { useTheme as r } from "@mui/material/styles";
6
- import { useDroppable as i } from "@dnd-kit/core";
7
- import { PlaceHolder as a } from "@pie-lib/drag";
8
- import { jsx as o } from "react/jsx-runtime";
9
- //#region src/delivery/categorize/droppable-placeholder.tsx
10
- n("@pie-ui:categorize:droppable-placeholder");
11
- var s = ({ children: t, grid: n, disabled: s, choiceBoard: c, minRowHeight: l, id: u, correct: d }) => {
12
- let f = r(), { setNodeRef: p, isOver: m } = i({
13
- id: u,
14
- data: {
15
- itemType: "categorize",
16
- categoryId: u
17
- },
18
- disabled: s
19
- }), h = {
20
- padding: f.spacing(.5),
21
- borderRadius: f.spacing(.5),
22
- gridColumnGap: 0,
23
- gridRowGap: 0,
24
- display: "flex",
25
- flexWrap: "wrap",
26
- justifyContent: "center",
27
- alignItems: "center",
28
- alignContent: "flex-start",
29
- width: "100%",
30
- height: "100%",
31
- ...d === !1 && !c && { border: `solid 2px ${e.incorrect()}` },
32
- ...d === !0 && !c && { border: `solid 2px ${e.correct()}` }
33
- };
34
- return /* @__PURE__ */ o("div", {
35
- ref: p,
36
- style: {
37
- flex: 1,
38
- minHeight: l || "80px",
39
- position: "relative",
40
- touchAction: "none"
41
- },
42
- children: /* @__PURE__ */ o(a, {
43
- isOver: m,
44
- grid: n,
45
- disabled: s,
46
- choiceBoard: c,
47
- isCategorize: !0,
48
- extraStyles: h,
49
- children: t
50
- })
51
- });
52
- };
53
- s.propTypes = {
54
- choiceBoard: t.bool,
55
- children: t.node.isRequired,
56
- grid: t.object,
57
- disabled: t.bool,
58
- minRowHeight: t.string,
59
- onDropChoice: t.func,
60
- id: t.string.isRequired,
61
- correct: t.bool
62
- };
63
- //#endregion
64
- export { s as default };
@@ -1,25 +0,0 @@
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;
@@ -1,39 +0,0 @@
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 default };
@@ -1,57 +0,0 @@
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
- };
25
- static defaultProps: {
26
- disabled: boolean;
27
- };
28
- constructor(props: any);
29
- removeChoice: any;
30
- dropChoice: any;
31
- UNSAFE_componentWillReceiveProps(nextProps: any): void;
32
- toggleShowCorrect: () => void;
33
- getPositionDirection: any;
34
- existAlternateResponse: (correctResponse: any) => any;
35
- render(): React.JSX.Element;
36
- }
37
- declare class CategorizeProvider extends React.Component {
38
- static propTypes: {
39
- model: PropTypes.Requireable<object>;
40
- session: PropTypes.Requireable<PropTypes.InferProps<{
41
- answers: PropTypes.Requireable<(PropTypes.InferProps<{
42
- choice: PropTypes.Requireable<string>;
43
- category: PropTypes.Requireable<string>;
44
- }> | null | undefined)[]>;
45
- }>>;
46
- onAnswersChange: PropTypes.Validator<(...args: any[]) => any>;
47
- onShowCorrectToggle: PropTypes.Validator<(...args: any[]) => any>;
48
- pauseMathObserver: PropTypes.Requireable<(...args: any[]) => any>;
49
- resumeMathObserver: PropTypes.Requireable<(...args: any[]) => any>;
50
- };
51
- constructor(props: any);
52
- onDragStart: any;
53
- onDragEnd: any;
54
- renderDragOverlay: any;
55
- render(): React.JSX.Element;
56
- }
57
- export default CategorizeProvider;
@@ -1,260 +0,0 @@
1
- import e from "./choice.js";
2
- import t from "./choices.js";
3
- import n from "./categories.js";
4
- import r from "react";
5
- import { renderMath as i } from "@pie-element/shared-math-rendering-mathjax";
6
- import * as a from "@pie-lib/render-ui";
7
- import { Collapsible as o, Feedback as s, PreviewPrompt as c, UiLayout as l, color as u, hasMedia as d, hasText as f } from "@pie-lib/render-ui";
8
- import p from "prop-types";
9
- import m from "debug";
10
- import { styled as h } from "@mui/material/styles";
11
- import { DragOverlay as g } from "@dnd-kit/core";
12
- import _ from "@pie-lib/correct-answer-toggle";
13
- import { buildState as v, moveChoiceToCategory as y, removeChoiceFromCategory as b } from "@pie-lib/categorize";
14
- import { DragProvider as x, uid as S } from "@pie-lib/drag";
15
- import { jsx as C, jsxs as w } from "react/jsx-runtime";
16
- import T from "@pie-lib/translator";
17
- import { AlertDialog as E } from "@pie-lib/config-ui";
18
- //#region src/delivery/categorize/index.tsx
19
- function D(e) {
20
- return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
21
- }
22
- function O(e, t) {
23
- return !e || D(e) ? e : D(e.default) ? e.default : t && D(e[t]) ? e[t] : t && D(e[t]?.default) ? e[t].default : e;
24
- }
25
- var k = O(l, "UiLayout") || O(F.UiLayout, "UiLayout"), A = O(c, "PreviewPrompt") || O(F.PreviewPrompt, "PreviewPrompt"), j = O(o, "Collapsible") || O(F.Collapsible, "Collapsible"), M = O(s, "Feedback") || O(F.Feedback, "Feedback"), N = a, P = N.default, F = P && typeof P == "object" ? P : N, { translator: I } = T, L = m("@pie-ui:categorize"), R = class extends r.Component {
26
- static propTypes = { children: p.node };
27
- containerRef = r.createRef();
28
- componentDidMount() {
29
- this.containerRef.current && i(this.containerRef.current);
30
- }
31
- render() {
32
- return /* @__PURE__ */ C("div", {
33
- ref: this.containerRef,
34
- children: this.props.children
35
- });
36
- }
37
- }, z = class extends r.Component {
38
- static propTypes = {
39
- model: p.object,
40
- session: p.shape({ answers: p.arrayOf(p.shape({
41
- choice: p.string,
42
- category: p.string
43
- })) }),
44
- onAnswersChange: p.func.isRequired,
45
- onShowCorrectToggle: p.func.isRequired,
46
- pauseMathObserver: p.func,
47
- resumeMathObserver: p.func
48
- };
49
- static defaultProps = { disabled: !1 };
50
- constructor(e) {
51
- super(e), this.state = {
52
- showCorrect: !1,
53
- showMaxChoiceAlert: !1
54
- };
55
- }
56
- removeChoice = (e) => {
57
- L("[removeChoice]: ", e);
58
- let { onAnswersChange: t, session: n } = this.props;
59
- t(b(e.id, e.categoryId, e.choiceIndex, n.answers));
60
- };
61
- dropChoice = (e, t) => {
62
- let { session: n, onAnswersChange: r, model: i } = this.props, { maxChoicesPerCategory: a = 0 } = i || {}, { answers: o = [] } = n || {}, s;
63
- t ? L("[dropChoice] category: ", t.categoryId, "choice: ", t) : L("[dropChoice] category: ", void 0, "choice: ", void 0);
64
- let c = o.find((t) => t.category === e);
65
- t && a === 1 && c && c.choices && c.choices.length === 1 ? (s = y(t.id, t.categoryId, e, t.choiceIndex, o), s = b(c.choices[0], e, 0, s)) : t && a > 1 && c && c.choices && c.choices.length === a ? (s = t.categoryId ? y(t.id, t.categoryId, t.categoryId, t.choiceIndex, o) : b(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 ? y(t.id, t.categoryId, e, t.choiceIndex, o) : this.removeChoice(e), t && r(s);
66
- };
67
- UNSAFE_componentWillReceiveProps(e) {
68
- let { model: t } = this.props, { model: n } = e;
69
- t.note && t.language && t.language !== n.language && t.note === I.t("common:commonCorrectAnswerWithAlternates", { lng: t.language }) && (t.note = I.t("common:commonCorrectAnswerWithAlternates", { lng: n.language })), this.setState({ showCorrect: !1 });
70
- }
71
- toggleShowCorrect = () => this.setState({ showCorrect: !this.state.showCorrect }, () => {
72
- this.props.onShowCorrectToggle();
73
- });
74
- getPositionDirection = (e) => {
75
- let t;
76
- switch (e) {
77
- case "left":
78
- t = "row-reverse";
79
- break;
80
- case "right":
81
- t = "row";
82
- break;
83
- case "below":
84
- t = "column";
85
- break;
86
- default:
87
- t = "column-reverse";
88
- break;
89
- }
90
- return t;
91
- };
92
- existAlternateResponse = (e) => e?.some((e) => e.alternateResponses?.length > 0);
93
- render() {
94
- let { model: e, session: i } = this.props, { showCorrect: a, showMaxChoiceAlert: o } = this.state, { choicesPosition: s, extraCSSRules: c, note: l, showNote: u, env: p, language: m, maxChoicesPerCategory: h, autoplayAudioEnabled: g, customAudioButton: y } = e, { mode: b, role: x } = p || {}, S = s || "above", T = {
95
- flexDirection: this.getPositionDirection(S),
96
- gap: "8px"
97
- }, { categories: D, choices: O, correct: k } = v(e.categories, e.choices, a ? e.correctResponse : i.answers, e.correctResponse);
98
- L("[render] disabled: ", e.disabled);
99
- let { rowLabels: j, categoriesPerRow: N, correctResponse: P, fontSizeFactor: F } = e, R = D && Math.ceil(D.length / N) || 0, z = this.existAlternateResponse(P) || !1, B = (a || b === "view" && x === "instructor") && u && l && z, G = I.t("translation:categorize:limitMaxChoicesPerCategory", {
100
- lng: e.language,
101
- maxChoicesPerCategory: h
102
- }), K = I.t("common:warning", { lng: e.language }), q = I.t("common:cancel", { lng: e.language }), J = e.rationale && (f(e.rationale) || d(e.rationale));
103
- return /* @__PURE__ */ w(V, {
104
- extraCSSRules: c,
105
- id: "main-container",
106
- fontSizeFactor: F,
107
- children: [
108
- e.teacherInstructions && (f(e.teacherInstructions) || d(e.teacherInstructions)) && /* @__PURE__ */ C(r.Fragment, { children: /* @__PURE__ */ C(W, {
109
- labels: {
110
- hidden: "Show Teacher Instructions",
111
- visible: "Hide Teacher Instructions"
112
- },
113
- children: /* @__PURE__ */ C(A, { prompt: e.teacherInstructions })
114
- }) }),
115
- e.prompt && /* @__PURE__ */ C(A, {
116
- prompt: e.prompt,
117
- autoplayAudioEnabled: g,
118
- customAudioButton: y
119
- }),
120
- /* @__PURE__ */ C(_, {
121
- show: a || k === !1,
122
- toggled: a,
123
- onToggle: this.toggleShowCorrect,
124
- language: m
125
- }),
126
- /* @__PURE__ */ w(U, {
127
- style: T,
128
- children: [/* @__PURE__ */ C("div", {
129
- style: {
130
- display: "flex",
131
- flex: 1
132
- },
133
- children: /* @__PURE__ */ C(n, {
134
- model: e,
135
- disabled: e.disabled,
136
- categories: D,
137
- onDropChoice: this.dropChoice,
138
- onRemoveChoice: this.removeChoice,
139
- rowLabels: (j || []).slice(0, R)
140
- })
141
- }), /* @__PURE__ */ C(t, {
142
- disabled: e.disabled,
143
- model: e,
144
- choices: O,
145
- choicePosition: S,
146
- onDropChoice: this.dropChoice,
147
- onRemoveChoice: this.removeChoice,
148
- correct: k
149
- })]
150
- }),
151
- B && /* @__PURE__ */ C(H, { dangerouslySetInnerHTML: { __html: l } }),
152
- J && /* @__PURE__ */ C(W, {
153
- labels: {
154
- hidden: "Show Rationale",
155
- visible: "Hide Rationale"
156
- },
157
- children: /* @__PURE__ */ C(A, { prompt: e.rationale })
158
- }),
159
- e.correctness && e.feedback && !a && /* @__PURE__ */ C(M, {
160
- correctness: e.correctness,
161
- feedback: e.feedback
162
- }),
163
- /* @__PURE__ */ C(E, {
164
- title: K,
165
- text: G,
166
- open: o,
167
- onCloseText: q,
168
- onClose: () => this.setState({ showMaxChoiceAlert: !1 })
169
- })
170
- ]
171
- });
172
- }
173
- }, B = class extends r.Component {
174
- static propTypes = {
175
- model: p.object,
176
- session: p.shape({ answers: p.arrayOf(p.shape({
177
- choice: p.string,
178
- category: p.string
179
- })) }),
180
- onAnswersChange: p.func.isRequired,
181
- onShowCorrectToggle: p.func.isRequired,
182
- pauseMathObserver: p.func,
183
- resumeMathObserver: p.func
184
- };
185
- constructor(e) {
186
- super(e), this.uid = S.generateId(), this.state = {
187
- activeDragItem: null,
188
- isValidDrop: !1
189
- };
190
- }
191
- onDragStart = (e) => {
192
- let { active: t } = e, { pauseMathObserver: n } = this.props;
193
- n && n(), t?.data?.current && this.setState({
194
- activeDragItem: t.data.current,
195
- isValidDrop: !1
196
- });
197
- };
198
- onDragEnd = (e) => {
199
- 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";
200
- if (this.setState({
201
- activeDragItem: null,
202
- isValidDrop: o
203
- }), r && r(), !t || !i || i.type !== "choice") return;
204
- let s = {
205
- id: i.id,
206
- categoryId: i.categoryId,
207
- choiceIndex: i.choiceIndex,
208
- value: i.value,
209
- itemType: i.itemType
210
- };
211
- if (!n) {
212
- this.categorizeRef && this.categorizeRef.removeChoice && i.categoryId && this.categorizeRef.removeChoice(s);
213
- return;
214
- }
215
- if (n.id === "choices-board") {
216
- this.categorizeRef && this.categorizeRef.removeChoice && i.categoryId && this.categorizeRef.removeChoice(s);
217
- return;
218
- }
219
- this.categorizeRef && this.categorizeRef.dropChoice && this.categorizeRef.dropChoice(n.id, s);
220
- };
221
- renderDragOverlay = () => {
222
- let { activeDragItem: t } = this.state, { model: n } = this.props;
223
- if (!t) return null;
224
- if (t.type === "choice") {
225
- let r = n.choices?.find((e) => e.id === t.id);
226
- if (r) return /* @__PURE__ */ C(e, {
227
- id: r.id,
228
- ...r
229
- }, r.id);
230
- }
231
- return null;
232
- };
233
- render() {
234
- let { isValidDrop: e } = this.state, t = e ? null : void 0;
235
- return /* @__PURE__ */ C(x, {
236
- onDragStart: this.onDragStart,
237
- onDragEnd: this.onDragEnd,
238
- children: /* @__PURE__ */ w(S.Provider, {
239
- value: this.uid,
240
- children: [/* @__PURE__ */ C(z, {
241
- ref: (e) => this.categorizeRef = e,
242
- ...this.props
243
- }), /* @__PURE__ */ C(g, {
244
- dropAnimation: t,
245
- children: /* @__PURE__ */ C(R, { children: this.renderDragOverlay() })
246
- })]
247
- })
248
- });
249
- }
250
- }, V = h(k)({
251
- color: u.text(),
252
- backgroundColor: u.background(),
253
- position: "relative"
254
- }), H = h("div")(({ theme: e }) => ({ marginBottom: e.spacing(2) })), U = h("div")(({ theme: e }) => ({
255
- marginBottom: e.spacing(1),
256
- display: "flex",
257
- flexDirection: "column"
258
- })), W = h(j)(({ theme: e }) => ({ paddingBottom: e.spacing(2) }));
259
- //#endregion
260
- export { B as default };
@@ -1,27 +0,0 @@
1
- /**
2
- * @synced-from pie-elements/packages/categorize/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 Categorize extends HTMLElement {
10
- constructor();
11
- _scheduleMathRender: any;
12
- _initMathObserver(): void;
13
- _disconnectMathObserver(): void;
14
- pauseMathObserver: any;
15
- resumeMathObserver: any;
16
- set model(m: any);
17
- isComplete(): any;
18
- set session(s: any);
19
- get session(): any;
20
- eliminateBlindAnswersFromSession(): void;
21
- changeAnswers(answers: any): void;
22
- onShowCorrectToggle(): void;
23
- _createAudioInfoToast(): HTMLDivElement;
24
- connectedCallback(): void;
25
- disconnectedCallback(): void;
26
- render(): void;
27
- }