@pie-element/explicit-constructed-response 11.4.0-beta.7 → 12.0.0-next.20261002100925

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 (131) hide show
  1. package/author.js +2 -0
  2. package/configure.js +2 -0
  3. package/controller.js +1 -0
  4. package/dist/_virtual/_rolldown/runtime.js +4 -0
  5. package/dist/author/alternateResponses.d.ts +34 -0
  6. package/dist/author/alternateResponses.js +113 -0
  7. package/dist/author/alternateSection.d.ts +58 -0
  8. package/dist/author/alternateSection.js +214 -0
  9. package/dist/author/defaults.d.ts +186 -0
  10. package/dist/author/defaults.js +128 -0
  11. package/dist/author/ecr-toolbar.d.ts +41 -0
  12. package/dist/author/ecr-toolbar.js +100 -0
  13. package/dist/author/index.d.ts +43 -0
  14. package/dist/author/index.js +99 -0
  15. package/dist/author/main.d.ts +38 -0
  16. package/dist/author/main.js +291 -0
  17. package/dist/author/markupUtils.d.ts +14 -0
  18. package/dist/author/markupUtils.js +13 -0
  19. package/dist/author/utils.d.ts +9 -0
  20. package/dist/author/utils.js +7 -0
  21. package/dist/browser/assets/Symbola-4c507403.woff2 +0 -0
  22. package/dist/browser/author/index.js +3381 -0
  23. package/dist/browser/author/index.js.map +1 -0
  24. package/dist/browser/browser-xPiwYICU.js +364 -0
  25. package/dist/browser/browser-xPiwYICU.js.map +1 -0
  26. package/dist/browser/controller/index.js +4152 -0
  27. package/dist/browser/controller/index.js.map +1 -0
  28. package/dist/browser/delivery/index.js +156 -0
  29. package/dist/browser/delivery/index.js.map +1 -0
  30. package/dist/browser/dist-DCmVXYeO.js +1528 -0
  31. package/dist/browser/dist-DCmVXYeO.js.map +1 -0
  32. package/dist/browser/dist-HcoWRT6l.js +41187 -0
  33. package/dist/browser/dist-HcoWRT6l.js.map +1 -0
  34. package/dist/browser/editor-runtime/assets/Symbola-4c507403.woff2 +0 -0
  35. package/dist/browser/editor-runtime/author/index.js +3381 -0
  36. package/dist/browser/editor-runtime/author/index.js.map +1 -0
  37. package/dist/browser/editor-runtime/browser-Dj-HJ-qm.js +364 -0
  38. package/dist/browser/editor-runtime/browser-Dj-HJ-qm.js.map +1 -0
  39. package/dist/browser/editor-runtime/controller/index.js +4152 -0
  40. package/dist/browser/editor-runtime/controller/index.js.map +1 -0
  41. package/dist/browser/editor-runtime/delivery/index.js +156 -0
  42. package/dist/browser/editor-runtime/delivery/index.js.map +1 -0
  43. package/dist/browser/editor-runtime/dist-DCmVXYeO.js +1528 -0
  44. package/dist/browser/editor-runtime/dist-DCmVXYeO.js.map +1 -0
  45. package/dist/browser/editor-runtime/dist-dG5D5e9t.js +24778 -0
  46. package/dist/browser/editor-runtime/dist-dG5D5e9t.js.map +1 -0
  47. package/dist/browser/editor-runtime/main-CfUFuZ3G.js +954 -0
  48. package/dist/browser/editor-runtime/main-CfUFuZ3G.js.map +1 -0
  49. package/dist/browser/editor-runtime/print/index.js +42 -0
  50. package/dist/browser/editor-runtime/print/index.js.map +1 -0
  51. package/dist/browser/main-Dc-VXHKW.js +954 -0
  52. package/dist/browser/main-Dc-VXHKW.js.map +1 -0
  53. package/dist/browser/print/index.js +42 -0
  54. package/dist/browser/print/index.js.map +1 -0
  55. package/dist/controller/defaults.d.ts +25 -0
  56. package/dist/controller/defaults.js +19 -0
  57. package/dist/controller/index.d.ts +64 -0
  58. package/dist/controller/index.js +139 -0
  59. package/dist/delivery/index.d.ts +20 -0
  60. package/dist/delivery/index.js +76 -0
  61. package/dist/delivery/main.d.ts +46 -0
  62. package/dist/delivery/main.js +113 -0
  63. package/dist/explicit-constructed-response.css +2 -0
  64. package/dist/index.d.ts +1 -0
  65. package/dist/index.iife.d.ts +8 -0
  66. package/dist/index.iife.js +357 -0
  67. package/dist/index.js +2 -0
  68. package/dist/node_modules/.bun/he@1.2.0/node_modules/he/he.js +3993 -0
  69. package/dist/print/index.d.ts +15 -0
  70. package/dist/print/index.js +42 -0
  71. package/dist/runtime-support.d.ts +12 -0
  72. package/dist/runtime-support.js +12 -0
  73. package/module/assets/Symbola-4c507403.woff2 +0 -0
  74. package/module/print.js +49847 -0
  75. package/module/print.js.map +1 -0
  76. package/package.json +109 -25
  77. package/print.js +2 -0
  78. package/CHANGELOG.json +0 -1102
  79. package/CHANGELOG.md +0 -2237
  80. package/LICENSE.md +0 -5
  81. package/README.md +0 -1
  82. package/configure/CHANGELOG.json +0 -652
  83. package/configure/CHANGELOG.md +0 -1978
  84. package/configure/lib/__tests__/alternateResponses.test.js +0 -503
  85. package/configure/lib/__tests__/alternateSection.test.js +0 -372
  86. package/configure/lib/__tests__/ecr-toolbar.test.js +0 -214
  87. package/configure/lib/__tests__/main.test.js +0 -470
  88. package/configure/lib/__tests__/markupUtils.test.js +0 -55
  89. package/configure/lib/__tests__/utils.test.js +0 -62
  90. package/configure/lib/alternateResponses.js +0 -199
  91. package/configure/lib/alternateResponses.js.map +0 -1
  92. package/configure/lib/alternateSection.js +0 -329
  93. package/configure/lib/alternateSection.js.map +0 -1
  94. package/configure/lib/defaults.js +0 -184
  95. package/configure/lib/defaults.js.map +0 -1
  96. package/configure/lib/ecr-toolbar.js +0 -181
  97. package/configure/lib/ecr-toolbar.js.map +0 -1
  98. package/configure/lib/index.js +0 -165
  99. package/configure/lib/index.js.map +0 -1
  100. package/configure/lib/main.js +0 -501
  101. package/configure/lib/main.js.map +0 -1
  102. package/configure/lib/markupUtils.js +0 -70
  103. package/configure/lib/markupUtils.js.map +0 -1
  104. package/configure/lib/utils.js +0 -15
  105. package/configure/lib/utils.js.map +0 -1
  106. package/configure/package.json +0 -22
  107. package/controller/CHANGELOG.json +0 -517
  108. package/controller/CHANGELOG.md +0 -1386
  109. package/controller/lib/__tests__/index.spec.js +0 -30
  110. package/controller/lib/__tests__/index.test.js +0 -950
  111. package/controller/lib/defaults.js +0 -23
  112. package/controller/lib/defaults.js.map +0 -1
  113. package/controller/lib/index.js +0 -368
  114. package/controller/lib/index.js.map +0 -1
  115. package/controller/package.json +0 -18
  116. package/docs/config-schema.json +0 -2629
  117. package/docs/config-schema.json.md +0 -1941
  118. package/docs/demo/config.js +0 -8
  119. package/docs/demo/generate.js +0 -20
  120. package/docs/demo/index.html +0 -1
  121. package/docs/demo/pie.manifest.json +0 -11
  122. package/docs/demo/session.js +0 -10
  123. package/docs/pie-schema.json +0 -1130
  124. package/docs/pie-schema.json.md +0 -814
  125. package/lib/__tests__/main.test.js +0 -166
  126. package/lib/index.js +0 -92
  127. package/lib/index.js.map +0 -1
  128. package/lib/main.js +0 -205
  129. package/lib/main.js.map +0 -1
  130. package/lib/print.js +0 -71
  131. package/lib/print.js.map +0 -1
package/author.js ADDED
@@ -0,0 +1,2 @@
1
+ export { default } from './dist/author/index.js';
2
+ export * from './dist/author/index.js';
package/configure.js ADDED
@@ -0,0 +1,2 @@
1
+ export { default } from './dist/author/index.js';
2
+ export * from './dist/author/index.js';
package/controller.js ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/controller/index.js';
@@ -0,0 +1,4 @@
1
+ //#region \0rolldown/runtime.js
2
+ var e = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports);
3
+ //#endregion
4
+ export { e as __commonJSMin };
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/explicit-constructed-response/configure/src/alternateResponses.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 AlternateResponses extends React.Component {
12
+ static propTypes: {
13
+ choicesErrors: PropTypes.Requireable<object>;
14
+ model: PropTypes.Validator<object>;
15
+ onChange: PropTypes.Validator<(...args: any[]) => any>;
16
+ onLengthChange: PropTypes.Validator<(...args: any[]) => any>;
17
+ maxLengthPerChoiceEnabled: PropTypes.Validator<boolean>;
18
+ spellCheck: PropTypes.Requireable<boolean>;
19
+ pluginProps: PropTypes.Requireable<object>;
20
+ };
21
+ state: {
22
+ maxLengthPerChoice: any;
23
+ };
24
+ UNSAFE_componentWillReceiveProps(nextProps: any): void;
25
+ componentDidMount(): void;
26
+ updateChoicesIfNeeded: any;
27
+ getRemainingChoices: any;
28
+ onChoiceChanged: any;
29
+ onChoiceRemoved: any;
30
+ onSectionSelect: any;
31
+ onLengthChanged: any;
32
+ render(): React.JSX.Element;
33
+ }
34
+ export default AlternateResponses;
@@ -0,0 +1,113 @@
1
+ import { AlternateSection as e } from "./alternateSection.js";
2
+ import t from "react";
3
+ import n from "prop-types";
4
+ import { cloneDeep as r, isEqual as i, map as a, reduce as o } from "@pie-element/shared-lodash";
5
+ import { jsx as s, jsxs as c } from "react/jsx-runtime";
6
+ //#region src/author/alternateResponses.tsx
7
+ var l = class extends t.Component {
8
+ static propTypes = {
9
+ choicesErrors: n.object,
10
+ model: n.object.isRequired,
11
+ onChange: n.func.isRequired,
12
+ onLengthChange: n.func.isRequired,
13
+ maxLengthPerChoiceEnabled: n.bool.isRequired,
14
+ spellCheck: n.bool,
15
+ pluginProps: n.object
16
+ };
17
+ state = { maxLengthPerChoice: r(this.props.model.maxLengthPerChoice) };
18
+ UNSAFE_componentWillReceiveProps(e) {
19
+ this.updateChoicesIfNeeded(e);
20
+ }
21
+ componentDidMount() {
22
+ this.updateChoicesIfNeeded(this.props);
23
+ }
24
+ updateChoicesIfNeeded = (e) => {
25
+ if (!this.state.choices || !i(this.state.choices, e.model.choices) || !i(e.model.choices, this.props.model.choices) || this.state.values && Object.keys(this.state.values).length !== Object.keys(this.props.model.choices).length || e.maxLengthPerChoiceEnabled !== this.props.maxLengthPerChoiceEnabled) {
26
+ let { choices: t, maxLengthPerChoice: n } = e.model, i = o(t, (t, n, r) => (n && (e.maxLengthPerChoiceEnabled || n.length > 1) && (t[r] = n[0]), t), {});
27
+ this.setState({
28
+ choices: e.model.choices,
29
+ values: i,
30
+ maxLengthPerChoice: r(n)
31
+ });
32
+ }
33
+ };
34
+ getRemainingChoices = (e) => {
35
+ let { choices: t } = this.state;
36
+ return o(t, (t, n, r) => (n && n.length === 1 && !e && t.push({
37
+ label: n[0].label,
38
+ value: r
39
+ }), t), []);
40
+ };
41
+ onChoiceChanged = (e, t) => {
42
+ let { onChange: n } = this.props, { choices: r } = this.state, i = r[t] || [], a = !i.find((t) => t.value === e.value), o = i.reduce((t, n) => {
43
+ let r = n.value === e.value ? e : n;
44
+ return t.push(r), t;
45
+ }, []);
46
+ a && o.push(e), n({
47
+ ...r,
48
+ [t]: o
49
+ });
50
+ };
51
+ onChoiceRemoved = (e, t) => {
52
+ let { onChange: n } = this.props, { choices: r } = this.state, i = (r[t] || []).reduce((t, n) => (n.value === e || t.push(n), t), []);
53
+ n({
54
+ ...r,
55
+ [t]: i
56
+ });
57
+ };
58
+ onSectionSelect = (e, t) => {
59
+ let { onChange: n } = this.props, { choices: r, values: i } = this.state;
60
+ r[t] && r[t].length > 1 ? e || n({
61
+ ...r,
62
+ [t]: [r[t][0]]
63
+ }) : this.setState({
64
+ choices: {
65
+ ...r,
66
+ [t]: [...r[t], {
67
+ label: "",
68
+ value: "1"
69
+ }]
70
+ },
71
+ values: {
72
+ ...i,
73
+ [t]: r[t][0]
74
+ }
75
+ });
76
+ };
77
+ onLengthChanged = (e, t) => {
78
+ let { model: n, onLengthChange: r } = this.props, { maxLengthPerChoice: i } = n;
79
+ i[t] = e, r(i);
80
+ };
81
+ render() {
82
+ let { choices: t } = this.state, { model: { maxLengthPerChoice: n, maxLengthPerChoiceEnabled: r }, spellCheck: i, choicesErrors: o, pluginProps: l } = this.props;
83
+ return /* @__PURE__ */ c("div", { children: [a(t, (t, a) => {
84
+ if (t && (r || t.length > 1)) {
85
+ let c = this.state.values[a];
86
+ return /* @__PURE__ */ s(e, {
87
+ value: c && c.value,
88
+ errors: o && o[a],
89
+ onSelect: (e) => this.onSectionSelect(e, a),
90
+ choiceChanged: (e) => this.onChoiceChanged(e, a),
91
+ choiceRemoved: (e) => this.onChoiceRemoved(e, a),
92
+ lengthChanged: (e) => this.onLengthChanged(e, a),
93
+ selectChoices: [c],
94
+ choices: t,
95
+ maxLength: n[a],
96
+ showMaxLength: r,
97
+ spellCheck: i,
98
+ pluginProps: l
99
+ }, a);
100
+ }
101
+ }), t && Object.keys(this.state.values).length !== Object.keys(t).length && /* @__PURE__ */ s(e, {
102
+ value: "",
103
+ onSelect: (e) => this.onSectionSelect(e, e.value),
104
+ choiceChanged: (e) => this.onChoiceChanged(e),
105
+ choiceRemoved: (e) => this.onChoiceRemoved(e),
106
+ selectChoices: this.getRemainingChoices(),
107
+ spellCheck: i,
108
+ pluginProps: l
109
+ })] });
110
+ }
111
+ };
112
+ //#endregion
113
+ export { l as AlternateResponses, l as default };
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/explicit-constructed-response/configure/src/alternateSection.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 Choice extends React.Component {
12
+ static propTypes: {
13
+ error: PropTypes.Requireable<string>;
14
+ markup: PropTypes.Requireable<string>;
15
+ onChange: PropTypes.Validator<(...args: any[]) => any>;
16
+ onDelete: PropTypes.Validator<(...args: any[]) => any>;
17
+ value: PropTypes.Requireable<string>;
18
+ spellCheck: PropTypes.Requireable<boolean>;
19
+ showMaxLength: PropTypes.Requireable<boolean>;
20
+ pluginProps: PropTypes.Requireable<object>;
21
+ };
22
+ state: {
23
+ value: any;
24
+ };
25
+ updateText: import("@pie-element/shared-lodash").CancelableFunction<any>;
26
+ UNSAFE_componentWillReceiveProps(nextProps: any): void;
27
+ onChange: any;
28
+ onKeyDown: any;
29
+ render(): React.JSX.Element;
30
+ }
31
+ export declare class AlternateSection extends React.Component {
32
+ static propTypes: {
33
+ choices: PropTypes.Requireable<any[]>;
34
+ selectChoices: PropTypes.Validator<any[]>;
35
+ errors: PropTypes.Requireable<object>;
36
+ onSelect: PropTypes.Validator<(...args: any[]) => any>;
37
+ choiceChanged: PropTypes.Validator<(...args: any[]) => any>;
38
+ lengthChanged: PropTypes.Requireable<(...args: any[]) => any>;
39
+ choiceRemoved: PropTypes.Validator<(...args: any[]) => any>;
40
+ value: PropTypes.Requireable<string>;
41
+ maxLength: PropTypes.Requireable<number>;
42
+ showMaxLength: PropTypes.Requireable<boolean>;
43
+ spellCheck: PropTypes.Requireable<boolean>;
44
+ pluginProps: PropTypes.Requireable<object>;
45
+ };
46
+ state: {};
47
+ UNSAFE_componentWillReceiveProps(nextProps: any): void;
48
+ componentDidMount(): void;
49
+ updateChoicesIfNeeded: any;
50
+ handleSelect: any;
51
+ onAddChoice: any;
52
+ onChoiceChanged: any;
53
+ onRemoveChoice: any;
54
+ getChoicesMaxLength: any;
55
+ changeLength: any;
56
+ render(): React.JSX.Element;
57
+ }
58
+ export default AlternateSection;
@@ -0,0 +1,214 @@
1
+ import { decodeHTML as e, getAdjustedLength as t, stripHtmlTags as n } from "./markupUtils.js";
2
+ import r from "react";
3
+ import i from "prop-types";
4
+ import { debounce as a, isEqual as o, max as s } from "@pie-element/shared-lodash";
5
+ import { color as c } from "@pie-lib/render-ui";
6
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
7
+ import { styled as d } from "@mui/material/styles";
8
+ import f from "@pie-lib/editable-html-tip-tap";
9
+ import p from "@mui/material/Button";
10
+ import m from "@mui/icons-material/Delete";
11
+ import h from "@mui/material/IconButton";
12
+ import g from "@mui/material/MenuItem";
13
+ import _ from "@mui/material/Select";
14
+ import v from "@mui/material/TextField";
15
+ //#region src/author/alternateSection.tsx
16
+ var y = d("div")(({ theme: e }) => ({ marginBottom: e.spacing(.5) })), b = d("div")(({ theme: e }) => ({
17
+ alignItems: "flex-start",
18
+ flexDirection: "column",
19
+ display: "flex",
20
+ paddingTop: e.spacing(2.5),
21
+ "& > *": {
22
+ marginBottom: e.spacing(2.5),
23
+ width: "100%"
24
+ }
25
+ })), x = d(f)(({ theme: e, hasError: t }) => ({
26
+ flex: "1",
27
+ marginRight: e.spacing(2.5),
28
+ ...t && {
29
+ border: `2px solid ${e.palette.error.main}`,
30
+ borderRadius: "6px"
31
+ }
32
+ })), S = d(h)(() => ({ "& svg": { fill: c.text() } })), C = d("div")({
33
+ alignItems: "flex-end",
34
+ display: "flex",
35
+ justifyContent: "space-between",
36
+ width: "100%"
37
+ }), w = d("div")({
38
+ alignItems: "center",
39
+ display: "flex"
40
+ }), T = d(v)(({ theme: e }) => ({
41
+ width: "230px",
42
+ marginRight: e.spacing(2.5),
43
+ "& .MuiInput-underline:before": { borderBottomColor: e.palette.divider },
44
+ "& .MuiInput-underline:hover:not(.Mui-disabled):before": { borderBottomColor: e.palette.text.primary },
45
+ "& .MuiInput-underline:after": { borderBottomColor: e.palette.primary.main }
46
+ })), E = d("div")(({ theme: e }) => ({
47
+ fontSize: e.typography.fontSize - 2,
48
+ color: e.palette.error.main,
49
+ paddingTop: e.spacing(.5)
50
+ })), D = d("div")({
51
+ alignItems: "center",
52
+ display: "flex",
53
+ justifyContent: "space-between"
54
+ }), O = class extends r.Component {
55
+ static propTypes = {
56
+ error: i.string,
57
+ markup: i.string,
58
+ onChange: i.func.isRequired,
59
+ onDelete: i.func.isRequired,
60
+ value: i.string,
61
+ spellCheck: i.bool,
62
+ showMaxLength: i.bool,
63
+ pluginProps: i.object
64
+ };
65
+ state = { value: this.props.markup };
66
+ updateText = a(this.props.onChange, 300);
67
+ UNSAFE_componentWillReceiveProps(e) {
68
+ e.markup && this.setState({ value: e.markup });
69
+ }
70
+ onChange = (e) => {
71
+ let t = n(e);
72
+ this.setState({ value: t }), this.updateText(t);
73
+ };
74
+ onKeyDown = (e) => {
75
+ if (e.key === "Enter") return !0;
76
+ };
77
+ render() {
78
+ let { value: e } = this.state, { onDelete: t, spellCheck: n, error: i, showMaxLength: a, pluginProps: o } = this.props, s = a ? {} : { maxLength: 25 };
79
+ return /* @__PURE__ */ u(r.Fragment, { children: [/* @__PURE__ */ u(D, { children: [/* @__PURE__ */ l(x, {
80
+ hasError: !!i,
81
+ disableUnderline: !0,
82
+ onChange: this.onChange,
83
+ onKeyDown: this.onKeyDown,
84
+ markup: e || "",
85
+ activePlugins: ["languageCharacters"],
86
+ pluginProps: o,
87
+ languageCharactersProps: [{ language: "spanish" }],
88
+ spellCheck: n,
89
+ autoWidthToolbar: !0,
90
+ toolbarOpts: {
91
+ minWidth: "auto",
92
+ isHidden: !!o?.characters?.disabled
93
+ },
94
+ ...s
95
+ }), /* @__PURE__ */ l(S, {
96
+ "aria-label": "delete",
97
+ onClick: t,
98
+ size: "large",
99
+ children: /* @__PURE__ */ l(m, {})
100
+ })] }), i && /* @__PURE__ */ l(E, { children: i })] });
101
+ }
102
+ }, k = class extends r.Component {
103
+ static propTypes = {
104
+ choices: i.array,
105
+ selectChoices: i.array.isRequired,
106
+ errors: i.object,
107
+ onSelect: i.func.isRequired,
108
+ choiceChanged: i.func.isRequired,
109
+ lengthChanged: i.func,
110
+ choiceRemoved: i.func.isRequired,
111
+ value: i.string,
112
+ maxLength: i.number,
113
+ showMaxLength: i.bool,
114
+ spellCheck: i.bool,
115
+ pluginProps: i.object
116
+ };
117
+ state = {};
118
+ UNSAFE_componentWillReceiveProps(e) {
119
+ this.updateChoicesIfNeeded(e);
120
+ }
121
+ componentDidMount() {
122
+ this.updateChoicesIfNeeded(this.props);
123
+ }
124
+ updateChoicesIfNeeded = (e) => {
125
+ (!this.state.choices || !o(e.choices, this.state.choices) || !o(e.choices, this.props.choices)) && this.setState({ choices: e.choices });
126
+ };
127
+ handleSelect = (e) => {
128
+ let { onSelect: t, selectChoices: n } = this.props, { value: r } = e.target;
129
+ t(n.find((e) => e.value === r));
130
+ };
131
+ onAddChoice = () => {
132
+ let { choices: e } = this.state;
133
+ if (e.length && e[e.length - 1].label !== "") {
134
+ let t = s(e.map((e) => parseInt(e.value)).filter((e) => !isNaN(e))) || 0;
135
+ this.setState({ choices: [...e, {
136
+ value: `${t + 1}`,
137
+ label: ""
138
+ }] });
139
+ }
140
+ };
141
+ onChoiceChanged = (n, r, i) => {
142
+ let { choiceChanged: a, lengthChanged: o, maxLength: s, choices: c } = this.props, l = c.map((t) => e(t.label || "").length);
143
+ l[i] = e(r).length;
144
+ let u = Math.max(...l);
145
+ a({
146
+ ...n,
147
+ label: r
148
+ }), (u > s || u + 10 <= s) && o(t(u));
149
+ };
150
+ onRemoveChoice = (e) => {
151
+ let { choiceRemoved: t } = this.props;
152
+ t(e.value);
153
+ };
154
+ getChoicesMaxLength = () => {
155
+ let { choices: t } = this.state;
156
+ if (!t) return 1;
157
+ let n = t.map((t) => e(t.label || "").length);
158
+ return Math.max(...n);
159
+ };
160
+ changeLength = (e) => {
161
+ let { lengthChanged: t } = this.props, n = parseInt(e.target.value, 10), r = this.getChoicesMaxLength();
162
+ n && n >= r && n <= r + 10 && t(n);
163
+ };
164
+ render() {
165
+ let { selectChoices: t, maxLength: n, showMaxLength: r, value: i, spellCheck: a, errors: o, pluginProps: s } = this.props, { choices: c } = this.state, d = this.getChoicesMaxLength();
166
+ return /* @__PURE__ */ u(y, { children: [
167
+ /* @__PURE__ */ u(C, { children: [/* @__PURE__ */ u(_, {
168
+ variant: "standard",
169
+ displayEmpty: !0,
170
+ onChange: this.handleSelect,
171
+ value: i || "",
172
+ readOnly: r,
173
+ MenuProps: { transitionDuration: {
174
+ enter: 225,
175
+ exit: 195
176
+ } },
177
+ children: [/* @__PURE__ */ l(g, {
178
+ value: "",
179
+ children: /* @__PURE__ */ l("em", { children: i ? "Remove selection" : "Select a response" })
180
+ }), t.map((t, n) => /* @__PURE__ */ l(g, {
181
+ value: t?.value,
182
+ children: e(t?.label)
183
+ }, n))]
184
+ }), c && c.length > 0 && /* @__PURE__ */ u(w, { children: [n && r && /* @__PURE__ */ l(T, {
185
+ variant: "standard",
186
+ label: "Maximum length (characters)",
187
+ type: "number",
188
+ inputProps: {
189
+ min: d,
190
+ max: d + 10
191
+ },
192
+ value: n,
193
+ onChange: this.changeLength
194
+ }), /* @__PURE__ */ l(p, {
195
+ variant: "contained",
196
+ color: "primary",
197
+ onClick: this.onAddChoice,
198
+ children: "Add"
199
+ })] })] }),
200
+ o && o[0] && /* @__PURE__ */ l(E, { children: o[0] }),
201
+ /* @__PURE__ */ l(b, { children: c && c.map((e, t) => t > 0 && /* @__PURE__ */ l(O, {
202
+ markup: e.label,
203
+ onChange: (n) => this.onChoiceChanged(e, n, t),
204
+ onDelete: () => this.onRemoveChoice(e),
205
+ spellCheck: a,
206
+ error: o && o[t],
207
+ showMaxLength: r,
208
+ pluginProps: s
209
+ }, t)) })
210
+ ] });
211
+ }
212
+ };
213
+ //#endregion
214
+ export { k as AlternateSection, k as default, O as Choice };
@@ -0,0 +1,186 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/explicit-constructed-response/configure/src/defaults.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
+ declare const _default: {
10
+ model: {
11
+ choices: {};
12
+ displayType: string;
13
+ markup: string;
14
+ maxLengthPerChoiceEnabled: boolean;
15
+ playerSpellCheckEnabled: boolean;
16
+ prompt: string;
17
+ promptEnabled: boolean;
18
+ rationale: string;
19
+ rationaleEnabled: boolean;
20
+ spellCheckEnabled: boolean;
21
+ studentInstructionsEnabled: boolean;
22
+ teacherInstructions: string;
23
+ teacherInstructionsEnabled: boolean;
24
+ toolbarEditorPosition: string;
25
+ responseAreaInputConfiguration: {};
26
+ };
27
+ configuration: {
28
+ baseInputConfiguration: {
29
+ h3: {
30
+ disabled: boolean;
31
+ };
32
+ html: {
33
+ disabled: boolean;
34
+ };
35
+ audio: {
36
+ disabled: boolean;
37
+ };
38
+ video: {
39
+ disabled: boolean;
40
+ };
41
+ image: {
42
+ disabled: boolean;
43
+ };
44
+ textAlign: {
45
+ disabled: boolean;
46
+ };
47
+ showParagraphs: {
48
+ disabled: boolean;
49
+ };
50
+ separateParagraphs: {
51
+ disabled: boolean;
52
+ };
53
+ };
54
+ prompt: {
55
+ settings: boolean;
56
+ label: string;
57
+ inputConfiguration: {
58
+ audio: {
59
+ disabled: boolean;
60
+ };
61
+ video: {
62
+ disabled: boolean;
63
+ };
64
+ image: {
65
+ disabled: boolean;
66
+ };
67
+ };
68
+ required: boolean;
69
+ };
70
+ partialScoring: {
71
+ settings: boolean;
72
+ label: string;
73
+ };
74
+ rationale: {
75
+ settings: boolean;
76
+ label: string;
77
+ inputConfiguration: {
78
+ audio: {
79
+ disabled: boolean;
80
+ };
81
+ video: {
82
+ disabled: boolean;
83
+ };
84
+ image: {
85
+ disabled: boolean;
86
+ };
87
+ };
88
+ required: boolean;
89
+ };
90
+ settingsPanelDisabled: boolean;
91
+ spellCheck: {
92
+ label: string;
93
+ settings: boolean;
94
+ enabled: boolean;
95
+ };
96
+ editSource: {
97
+ label: string;
98
+ settings: boolean;
99
+ enabled: boolean;
100
+ };
101
+ playerSpellCheck: {
102
+ label: string;
103
+ settings: boolean;
104
+ enabled: boolean;
105
+ };
106
+ teacherInstructions: {
107
+ settings: boolean;
108
+ label: string;
109
+ inputConfiguration: {
110
+ audio: {
111
+ disabled: boolean;
112
+ };
113
+ video: {
114
+ disabled: boolean;
115
+ };
116
+ image: {
117
+ disabled: boolean;
118
+ };
119
+ };
120
+ required: boolean;
121
+ };
122
+ template: {
123
+ inputConfiguration: {
124
+ audio: {
125
+ disabled: boolean;
126
+ };
127
+ video: {
128
+ disabled: boolean;
129
+ };
130
+ image: {
131
+ disabled: boolean;
132
+ };
133
+ h3: {
134
+ disabled: boolean;
135
+ };
136
+ blockquote: {
137
+ disabled: boolean;
138
+ };
139
+ };
140
+ };
141
+ maxLengthPerChoice: {
142
+ settings: boolean;
143
+ label: string;
144
+ };
145
+ maxResponseAreas: number;
146
+ maxImageWidth: {
147
+ teacherInstructions: number;
148
+ prompt: number;
149
+ rationale: number;
150
+ };
151
+ maxImageHeight: {
152
+ teacherInstructions: number;
153
+ prompt: number;
154
+ rationale: number;
155
+ };
156
+ withRubric: {
157
+ settings: boolean;
158
+ label: string;
159
+ };
160
+ mathMlOptions: {
161
+ mmlOutput: boolean;
162
+ mmlEditing: boolean;
163
+ };
164
+ language: {
165
+ settings: boolean;
166
+ label: string;
167
+ enabled: boolean;
168
+ };
169
+ languageChoices: {
170
+ label: string;
171
+ options: never[];
172
+ };
173
+ responseAreaInputConfiguration: {
174
+ inputConfiguration: {
175
+ characters: {
176
+ disabled: boolean;
177
+ };
178
+ };
179
+ };
180
+ spanishButton: {
181
+ settings: boolean;
182
+ label: string;
183
+ };
184
+ };
185
+ };
186
+ export default _default;