@pie-element/explicit-constructed-response 11.1.2-next.2 → 11.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 (108) hide show
  1. package/CHANGELOG.json +1102 -0
  2. package/CHANGELOG.md +2194 -0
  3. package/LICENSE.md +5 -0
  4. package/README.md +1 -0
  5. package/configure/CHANGELOG.json +652 -0
  6. package/configure/CHANGELOG.md +1935 -0
  7. package/configure/lib/alternateResponses.js +199 -0
  8. package/configure/lib/alternateResponses.js.map +1 -0
  9. package/configure/lib/alternateSection.js +329 -0
  10. package/configure/lib/alternateSection.js.map +1 -0
  11. package/configure/lib/defaults.js +184 -0
  12. package/configure/lib/defaults.js.map +1 -0
  13. package/configure/lib/ecr-toolbar.js +181 -0
  14. package/configure/lib/ecr-toolbar.js.map +1 -0
  15. package/configure/lib/index.js +161 -0
  16. package/configure/lib/index.js.map +1 -0
  17. package/configure/lib/main.js +501 -0
  18. package/configure/lib/main.js.map +1 -0
  19. package/configure/lib/markupUtils.js +70 -0
  20. package/configure/lib/markupUtils.js.map +1 -0
  21. package/configure/lib/utils.js +15 -0
  22. package/configure/lib/utils.js.map +1 -0
  23. package/configure/package.json +22 -0
  24. package/controller/CHANGELOG.json +517 -0
  25. package/controller/CHANGELOG.md +1344 -0
  26. package/controller/lib/defaults.js +23 -0
  27. package/controller/lib/defaults.js.map +1 -0
  28. package/controller/lib/index.js +368 -0
  29. package/controller/lib/index.js.map +1 -0
  30. package/controller/package.json +18 -0
  31. package/docs/config-schema.json +2629 -0
  32. package/docs/config-schema.json.md +1941 -0
  33. package/docs/demo/config.js +8 -0
  34. package/docs/demo/generate.js +20 -0
  35. package/docs/demo/index.html +1 -0
  36. package/docs/demo/session.js +10 -0
  37. package/docs/pie-schema.json +1130 -0
  38. package/docs/pie-schema.json.md +814 -0
  39. package/lib/index.js +91 -0
  40. package/lib/index.js.map +1 -0
  41. package/lib/main.js +205 -0
  42. package/lib/main.js.map +1 -0
  43. package/lib/print.js +71 -0
  44. package/lib/print.js.map +1 -0
  45. package/module/configure.js +1 -0
  46. package/module/controller.js +6534 -0
  47. package/module/demo.js +45 -0
  48. package/module/element.js +1 -0
  49. package/module/index.html +21 -0
  50. package/module/manifest.json +18 -0
  51. package/module/print-demo.js +83 -0
  52. package/module/print.html +18 -0
  53. package/module/print.js +1 -0
  54. package/package.json +25 -92
  55. package/configure.js +0 -2
  56. package/controller.js +0 -1
  57. package/dist/_virtual/_rolldown/runtime.js +0 -4
  58. package/dist/author/alternateResponses.d.ts +0 -34
  59. package/dist/author/alternateResponses.js +0 -113
  60. package/dist/author/alternateSection.d.ts +0 -58
  61. package/dist/author/alternateSection.js +0 -213
  62. package/dist/author/defaults.d.ts +0 -186
  63. package/dist/author/defaults.js +0 -128
  64. package/dist/author/ecr-toolbar.d.ts +0 -41
  65. package/dist/author/ecr-toolbar.js +0 -100
  66. package/dist/author/index.d.ts +0 -42
  67. package/dist/author/index.js +0 -96
  68. package/dist/author/main.d.ts +0 -38
  69. package/dist/author/main.js +0 -291
  70. package/dist/author/markupUtils.d.ts +0 -14
  71. package/dist/author/markupUtils.js +0 -13
  72. package/dist/author/utils.d.ts +0 -9
  73. package/dist/author/utils.js +0 -7
  74. package/dist/browser/author/index.js +0 -3378
  75. package/dist/browser/author/index.js.map +0 -1
  76. package/dist/browser/browser-BC3WygxE.js +0 -360
  77. package/dist/browser/browser-BC3WygxE.js.map +0 -1
  78. package/dist/browser/controller/index.js +0 -4152
  79. package/dist/browser/controller/index.js.map +0 -1
  80. package/dist/browser/delivery/index.js +0 -96
  81. package/dist/browser/delivery/index.js.map +0 -1
  82. package/dist/browser/dist-B5QyKMGD.js +0 -45663
  83. package/dist/browser/dist-B5QyKMGD.js.map +0 -1
  84. package/dist/browser/dist-D9ARZhQk.js +0 -1426
  85. package/dist/browser/dist-D9ARZhQk.js.map +0 -1
  86. package/dist/browser/explicit-constructed-response.css +0 -2
  87. package/dist/browser/main-Czk7a-Zt.js +0 -959
  88. package/dist/browser/main-Czk7a-Zt.js.map +0 -1
  89. package/dist/browser/print/index.js +0 -40
  90. package/dist/browser/print/index.js.map +0 -1
  91. package/dist/controller/defaults.d.ts +0 -25
  92. package/dist/controller/defaults.js +0 -19
  93. package/dist/controller/index.d.ts +0 -64
  94. package/dist/controller/index.js +0 -139
  95. package/dist/delivery/index.d.ts +0 -20
  96. package/dist/delivery/index.js +0 -66
  97. package/dist/delivery/main.d.ts +0 -48
  98. package/dist/delivery/main.js +0 -115
  99. package/dist/explicit-constructed-response.css +0 -2
  100. package/dist/index.d.ts +0 -1
  101. package/dist/index.iife.d.ts +0 -8
  102. package/dist/index.iife.js +0 -393
  103. package/dist/index.js +0 -2
  104. package/dist/node_modules/.bun/he@1.2.0/node_modules/he/he.js +0 -3993
  105. package/dist/print/index.d.ts +0 -15
  106. package/dist/print/index.js +0 -40
  107. package/dist/runtime-support.d.ts +0 -12
  108. package/dist/runtime-support.js +0 -12
@@ -1,41 +0,0 @@
1
- /**
2
- * @synced-from pie-elements/packages/explicit-constructed-response/configure/src/ecr-toolbar.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 ECRToolbar extends React.Component {
12
- static propTypes: {
13
- correctChoice: PropTypes.Requireable<object>;
14
- node: PropTypes.Requireable<object>;
15
- pos: PropTypes.Requireable<number>;
16
- onDone: PropTypes.Requireable<(...args: any[]) => any>;
17
- onChangeResponse: PropTypes.Validator<(...args: any[]) => any>;
18
- onToolbarDone: PropTypes.Validator<(...args: any[]) => any>;
19
- value: PropTypes.Requireable<PropTypes.InferProps<{
20
- change: PropTypes.Validator<(...args: any[]) => any>;
21
- document: PropTypes.Requireable<PropTypes.InferProps<{
22
- getNextText: PropTypes.Validator<(...args: any[]) => any>;
23
- }>>;
24
- }>>;
25
- editor: PropTypes.Requireable<object>;
26
- maxLengthPerChoiceEnabled: PropTypes.Requireable<boolean>;
27
- pluginProps: PropTypes.Requireable<object>;
28
- spellCheck: PropTypes.Requireable<boolean>;
29
- };
30
- state: {
31
- markup: string;
32
- toolbarStyle: {};
33
- };
34
- componentDidMount(): void;
35
- onDone: any;
36
- onRespAreaChange: any;
37
- onKeyDown: any;
38
- onBlur: any;
39
- render(): React.JSX.Element;
40
- }
41
- export default ECRToolbar;
@@ -1,100 +0,0 @@
1
- import { stripHtmlTags as e } from "./markupUtils.js";
2
- import t from "react";
3
- import n from "prop-types";
4
- import { jsx as r } from "react/jsx-runtime";
5
- import { styled as i } from "@mui/material/styles";
6
- import a from "@pie-lib/editable-html-tip-tap";
7
- //#region src/author/ecr-toolbar.tsx
8
- var o = i(a)(({ theme: e }) => ({
9
- backgroundColor: e.palette.common.white,
10
- outline: "none",
11
- lineHeight: "15px"
12
- })), s = class extends t.Component {
13
- static propTypes = {
14
- correctChoice: n.object,
15
- node: n.object,
16
- pos: n.number,
17
- onDone: n.func,
18
- onChangeResponse: n.func.isRequired,
19
- onToolbarDone: n.func.isRequired,
20
- value: n.shape({
21
- change: n.func.isRequired,
22
- document: n.shape({ getNextText: n.func.isRequired })
23
- }),
24
- editor: n.object,
25
- maxLengthPerChoiceEnabled: n.bool,
26
- pluginProps: n.object,
27
- spellCheck: n.bool
28
- };
29
- state = {
30
- markup: "",
31
- toolbarStyle: {}
32
- };
33
- componentDidMount() {
34
- let { correctChoice: e, node: t, editor: n } = this.props, r = e || {}, i = n.view.nodeDOM(n.state.selection.from);
35
- if (i?.nodeType === 1) {
36
- let e = i.getBoundingClientRect(), t = i.closest(".tiptap").getBoundingClientRect();
37
- e.top - t.top, e.left - t.left, this.setState({
38
- markup: r.label,
39
- toolbarStyle: {
40
- position: "absolute",
41
- top: 0,
42
- left: 0,
43
- width: `${e.width - 4}px`
44
- }
45
- });
46
- }
47
- }
48
- onDone = (t) => {
49
- let { editor: n, node: r, onToolbarDone: i, onChangeResponse: a, pos: o } = this.props, s = e(t);
50
- this.setState({ markup: s });
51
- let { tr: c } = n.state, l = c.doc.nodeAt(o);
52
- if (!l || l.isText || !l.isAtom || !l.isInline) return !1;
53
- c.setNodeMarkup(o, void 0, {
54
- ...r.attrs,
55
- value: s
56
- }), n.view.dispatch(c), i(!0), a(s);
57
- };
58
- onRespAreaChange = (e) => {
59
- this.setState({ respAreaMarkup: e });
60
- };
61
- onKeyDown = (e) => e.key === "Enter";
62
- onBlur = () => {
63
- this.clickedInside &&= !1;
64
- };
65
- render() {
66
- let { maxLengthPerChoiceEnabled: e, pluginProps: t, spellCheck: n } = this.props, { markup: i, toolbarStyle: a } = this.state, s = e ? {} : { maxLength: 25 };
67
- return /* @__PURE__ */ r("div", {
68
- style: a,
69
- children: /* @__PURE__ */ r(o, {
70
- autoFocus: !0,
71
- disableUnderline: !0,
72
- onChange: (e) => {
73
- this.preventDone || this.onRespAreaChange(e);
74
- },
75
- onDone: (e) => {
76
- this.preventDone || this.onDone(e);
77
- },
78
- onBlur: (e) => {
79
- this.preventDone = e.relatedTarget && e.relatedTarget.closest(".insert-character-dialog"), this.onBlur(e);
80
- },
81
- onKeyDown: this.onKeyDown,
82
- markup: i || "",
83
- activePlugins: ["languageCharacters"],
84
- pluginProps: t,
85
- languageCharactersProps: [{ language: "spanish" }],
86
- minHeight: "15px",
87
- maxHeight: "15px",
88
- spellCheck: n,
89
- autoWidthToolbar: !0,
90
- toolbarOpts: {
91
- minWidth: "auto",
92
- isHidden: !!t?.characters?.disabled
93
- },
94
- ...s
95
- })
96
- });
97
- }
98
- };
99
- //#endregion
100
- export { s as default };
@@ -1,42 +0,0 @@
1
- /**
2
- * @synced-from pie-elements/packages/explicit-constructed-response/configure/src/index.js
3
- * @auto-generated
4
- *
5
- * This file is automatically synced from pie-elements and converted to TypeScript.
6
- * Manual edits will be overwritten on next sync.
7
- * To make changes, edit the upstream JavaScript file and run sync again.
8
- */
9
- export default class ExplicitConstructedResponse extends HTMLElement {
10
- static prepareModel: (model?: {}) => {
11
- slateMarkup: any;
12
- markup: string;
13
- choices: {};
14
- displayType: string;
15
- maxLengthPerChoiceEnabled: boolean;
16
- playerSpellCheckEnabled: boolean;
17
- prompt: string;
18
- promptEnabled: boolean;
19
- rationale: string;
20
- rationaleEnabled: boolean;
21
- spellCheckEnabled: boolean;
22
- studentInstructionsEnabled: boolean;
23
- teacherInstructions: string;
24
- teacherInstructionsEnabled: boolean;
25
- toolbarEditorPosition: string;
26
- responseAreaInputConfiguration: {};
27
- };
28
- constructor();
29
- set model(s: any);
30
- set configuration(c: any);
31
- set disableSidePanel(s: any);
32
- dispatchModelUpdated(reset: any): void;
33
- onModelChanged: any;
34
- onConfigurationChanged: any;
35
- /** @param {done, progress, file} handler */
36
- insertImage(handler: any): void;
37
- onDeleteImage(src: any, done: any): void;
38
- insertSound(handler: any): void;
39
- onDeleteSound(src: any, done: any): void;
40
- _render(): void;
41
- disconnectedCallback(): void;
42
- }
@@ -1,96 +0,0 @@
1
- import { createSlateMarkup as e, processMarkup as t } from "./markupUtils.js";
2
- import n from "./main.js";
3
- import r from "./defaults.js";
4
- import i from "react";
5
- import { createRoot as a } from "react-dom/client";
6
- import { defaults as o, isArray as s } from "@pie-element/shared-lodash";
7
- import c from "debug";
8
- import { DeleteImageEvent as l, DeleteSoundEvent as u, InsertImageEvent as d, InsertSoundEvent as f, ModelUpdatedEvent as p } from "@pie-element/shared-configure-events";
9
- //#region src/author/index.ts
10
- var m = c("explicit-constructed-response:configure"), h = class c extends HTMLElement {
11
- static prepareModel = (n = {}) => {
12
- let i = {
13
- ...r.model,
14
- ...n
15
- }, a = i.slateMarkup || e(i.markup, i.choices), o = t(a);
16
- return i.choices && Object.keys(i.choices).forEach((e) => {
17
- s(i.choices[e]) && (i.choices[e] = (i.choices[e] || []).map((e, t) => e.value ? e : (m("Choice does not contain \"value\" property, which is required.", e), {
18
- value: `${t}`,
19
- ...e
20
- })));
21
- }), {
22
- ...i,
23
- slateMarkup: a,
24
- markup: o
25
- };
26
- };
27
- constructor() {
28
- super(), this._root = null, this._model = c.prepareModel(), this._configuration = r.configuration;
29
- }
30
- set model(e) {
31
- this._model = c.prepareModel(e), this._model.responseAreaInputConfiguration && (this._model.responseAreaInputConfiguration = this._configuration.responseAreaInputConfiguration?.inputConfiguration), this._render();
32
- }
33
- set configuration(e) {
34
- this._configuration = o(e, r.configuration), e.language?.enabled ? e.languageChoices?.options?.length && (this._model.language = e.languageChoices.options[0].value) : e.language.settings && this._model.language ? (this._configuration.language.enabled = !0, (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) && (this._configuration.languageChoices.options = []), this._configuration.languageChoices.options.find((e) => e.value === this._model.language) || this._configuration.languageChoices.options.push({
35
- value: this._model.language,
36
- label: this._model.language
37
- })) : delete this._model.language, this._render();
38
- }
39
- set disableSidePanel(e) {
40
- this._disableSidePanel = e, this._render();
41
- }
42
- dispatchModelUpdated(e) {
43
- let t = !!e;
44
- this.dispatchEvent(new p(this._model, t));
45
- }
46
- onModelChanged = (e, t) => {
47
- this._model = c.prepareModel({
48
- ...this._model,
49
- ...e
50
- }), this._render(), this.dispatchModelUpdated(t);
51
- };
52
- onConfigurationChanged = (e) => {
53
- this._configuration = e;
54
- let t = this._configuration?.responseAreaInputConfiguration?.inputConfiguration;
55
- this._model = {
56
- ...this._model,
57
- responseAreaInputConfiguration: t
58
- }, this.onModelChanged(this._model);
59
- };
60
- insertImage(e) {
61
- this.dispatchEvent(new d(e));
62
- }
63
- onDeleteImage(e, t) {
64
- this.dispatchEvent(new l(e, t));
65
- }
66
- insertSound(e) {
67
- this.dispatchEvent(new f(e));
68
- }
69
- onDeleteSound(e, t) {
70
- this.dispatchEvent(new u(e, t));
71
- }
72
- _render() {
73
- m("_render");
74
- let e = i.createElement(n, {
75
- model: this._model,
76
- configuration: this._configuration,
77
- onModelChanged: this.onModelChanged,
78
- onConfigurationChanged: this.onConfigurationChanged,
79
- disableSidePanel: this._disableSidePanel,
80
- imageSupport: {
81
- add: this.insertImage.bind(this),
82
- delete: this.onDeleteImage.bind(this)
83
- },
84
- uploadSoundSupport: {
85
- add: this.insertSound.bind(this),
86
- delete: this.onDeleteSound.bind(this)
87
- }
88
- });
89
- this._root ||= a(this), this._root.render(e);
90
- }
91
- disconnectedCallback() {
92
- this._root && this._root.unmount();
93
- }
94
- };
95
- //#endregion
96
- export { h as default };
@@ -1,38 +0,0 @@
1
- /**
2
- * @synced-from pie-elements/packages/explicit-constructed-response/configure/src/main.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 Main extends React.Component {
12
- static propTypes: {
13
- configuration: PropTypes.Validator<object>;
14
- model: PropTypes.Validator<object>;
15
- disableSidePanel: PropTypes.Requireable<boolean>;
16
- onModelChanged: PropTypes.Validator<(...args: any[]) => any>;
17
- onConfigurationChanged: PropTypes.Validator<(...args: any[]) => any>;
18
- imageSupport: PropTypes.Requireable<PropTypes.InferProps<{
19
- add: PropTypes.Validator<(...args: any[]) => any>;
20
- delete: PropTypes.Validator<(...args: any[]) => any>;
21
- }>>;
22
- uploadSoundSupport: PropTypes.Requireable<object>;
23
- };
24
- state: {};
25
- componentDidMount(): void;
26
- onModelChange: any;
27
- onPromptChanged: any;
28
- onRationaleChanged: any;
29
- onTeacherInstructionsChanged: any;
30
- onMarkupChanged: any;
31
- onResponsesChanged: any;
32
- onLengthChanged: any;
33
- onChangeResponse: any;
34
- onChange: any;
35
- onHandleAreaChange: import("@pie-element/shared-lodash").CancelableFunction<(nodes: any) => void>;
36
- render(): React.JSX.Element;
37
- }
38
- export default Main;
@@ -1,291 +0,0 @@
1
- import { decodeHTML as e, getAdjustedLength as t } from "./markupUtils.js";
2
- import n from "./ecr-toolbar.js";
3
- import r from "./alternateResponses.js";
4
- import { generateValidationMessage as i } from "./utils.js";
5
- import a from "react";
6
- import o from "prop-types";
7
- import { cloneDeep as s, isEmpty as c, pick as l, throttle as u } from "@pie-element/shared-lodash";
8
- import { jsx as d, jsxs as f } from "react/jsx-runtime";
9
- import { styled as p } from "@mui/material/styles";
10
- import m, { ALL_PLUGINS as ee } from "@pie-lib/editable-html-tip-tap";
11
- import { InputContainer as h, layout as te, settings as g } from "@pie-lib/config-ui";
12
- import _ from "@mui/material/Typography";
13
- import ne from "@mui/icons-material/Info";
14
- import v from "@mui/material/Tooltip";
15
- //#region src/author/main.tsx
16
- var { toggle: y, Panel: re, dropdown: ie } = g, b = p(h)(({ theme: e }) => ({
17
- width: "100%",
18
- paddingTop: e.spacing(1),
19
- marginTop: e.spacing(2),
20
- marginBottom: e.spacing(2)
21
- })), ae = p(m)(({ theme: e }) => ({
22
- minHeight: "100px",
23
- paddingTop: e.spacing(1),
24
- width: "100%",
25
- "& [data-slate-editor=\"true\"]": { minHeight: "100px" }
26
- })), oe = p(_)(({ theme: e }) => ({ fontSize: e.typography.fontSize + 2 })), x = p(v)(({ theme: e }) => ({ "& .MuiTooltip-tooltip": {
27
- fontSize: e.typography.fontSize - 2,
28
- whiteSpace: "pre",
29
- maxWidth: "500px"
30
- } })), S = p("div")(({ theme: e }) => ({
31
- fontSize: e.typography.fontSize - 2,
32
- color: e.palette.error.main,
33
- paddingTop: e.spacing(1)
34
- })), se = p("div")({
35
- display: "flex",
36
- alignItems: "center"
37
- }), ce = p(_)(({ theme: e }) => ({
38
- fontSize: e.typography.fontSize + 2,
39
- marginTop: e.spacing(3),
40
- marginBottom: e.spacing(1)
41
- })), C = (e) => {
42
- let t = document.createElement("div");
43
- return t.innerHTML = e.trim(), t;
44
- }, w = class extends a.Component {
45
- static propTypes = {
46
- configuration: o.object.isRequired,
47
- model: o.object.isRequired,
48
- disableSidePanel: o.bool,
49
- onModelChanged: o.func.isRequired,
50
- onConfigurationChanged: o.func.isRequired,
51
- imageSupport: o.shape({
52
- add: o.func.isRequired,
53
- delete: o.func.isRequired
54
- }),
55
- uploadSoundSupport: o.object
56
- };
57
- state = {};
58
- componentDidMount() {
59
- let { model: { slateMarkup: n, choices: r, maxLengthPerChoice: i = [] }, onModelChanged: a } = this.props, o = !i.length;
60
- this.setState({ markup: n }), Object.values(r).forEach((n, r) => {
61
- let a = n.map((t) => e(t.label || "").length), s = Math.max(...a);
62
- (o || !i[r] || i[r] < s || i[r] > s + 10) && (i[r] = t(s));
63
- }), a({ maxLengthPerChoice: i });
64
- }
65
- onModelChange = (e) => {
66
- this.props.onModelChanged({ ...e });
67
- };
68
- onPromptChanged = (e) => {
69
- this.props.onModelChanged({ prompt: e });
70
- };
71
- onRationaleChanged = (e) => {
72
- this.props.onModelChanged({ rationale: e });
73
- };
74
- onTeacherInstructionsChanged = (e) => {
75
- let { onModelChanged: t } = this.props;
76
- t({ teacherInstructions: e });
77
- };
78
- onMarkupChanged = (e) => {
79
- this.props.onModelChanged({ slateMarkup: e });
80
- };
81
- onResponsesChanged = (e) => {
82
- this.props.onModelChanged({ choices: e });
83
- };
84
- onLengthChanged = (e) => {
85
- let { onModelChanged: t } = this.props;
86
- t({ maxLengthPerChoice: e });
87
- };
88
- onChangeResponse = (n, r) => {
89
- let { model: i, onModelChanged: a } = this.props, { choices: o } = i, { maxLengthPerChoice: s } = i, c = e(r || "").length;
90
- if (!o[n] || !o[n].length) {
91
- o[n] = [{
92
- label: r || "",
93
- value: "0"
94
- }];
95
- let e = n > s.length ? n - s.length : 0;
96
- s = [...s, ...Array(e).fill(1)], s.splice(n, 0, t(c));
97
- } else o[n][0].label = r || "", s && (s[n] < c || s[n] > c + 10) && (s[n] = t(c));
98
- a({
99
- choices: o,
100
- maxLengthPerChoice: s
101
- });
102
- };
103
- onChange = (e) => {
104
- let { model: { choices: t, maxLengthPerChoice: n }, onModelChanged: r } = this.props, i = C(e), a = i.querySelectorAll("[data-type=\"explicit_constructed_response\"]"), o = {}, c = [];
105
- a.forEach((e, r) => {
106
- let i = s(t[e.dataset.index]);
107
- i && (i[0] = {
108
- label: e.dataset.value || "",
109
- value: "0"
110
- }, c[r] = n[e.dataset.index]), o[r] = i, e.dataset.index = r;
111
- }), this.setState({ cachedChoices: void 0 }, () => r({
112
- choices: o,
113
- slateMarkup: i.innerHTML,
114
- maxLengthPerChoice: c
115
- }));
116
- };
117
- onHandleAreaChange = u((e) => {
118
- let { model: { choices: t }, onModelChanged: n } = this.props, { cachedChoices: r } = this.state;
119
- if (!e) return;
120
- let i = t ? s(t) : {}, a = r ? s(r) : {};
121
- e.forEach((e) => {
122
- let t = e.index;
123
- !i[t] && a[t] ? (Object.assign(i, l(a, t)), Object.prototype.hasOwnProperty.call(a, t) && delete a[t]) : (Object.assign(a, l(i, t)), Object.prototype.hasOwnProperty.call(i, t) && delete i[t]);
124
- }), this.setState({ cachedChoices: a }, () => n({ choices: i }));
125
- }, 500, {
126
- trailing: !1,
127
- leading: !0
128
- });
129
- render() {
130
- let { model: e, configuration: t, onConfigurationChanged: a, imageSupport: o, uploadSoundSupport: s } = this.props, { baseInputConfiguration: l = {}, contentDimensions: u = {}, maxImageWidth: p = {}, maxImageHeight: h = {}, maxLengthPerChoice: g = {}, maxResponseAreas: _, partialScoring: v = {}, playerSpellCheck: C = {}, prompt: w = {}, rationale: T = {}, template: le = {}, settingsPanelDisabled: E, spellCheck: D = {}, editSource: O = {}, teacherInstructions: k = {}, withRubric: A = {}, mathMlOptions: j = {}, language: M = {}, languageChoices: N = {}, spanishButton: P = {}, responseAreaInputConfiguration: F = {} } = t || {}, { errors: I, extraCSSRules: L, maxLengthPerChoiceEnabled: R, promptEnabled: z, rationaleEnabled: B, spellCheckEnabled: V, teacherInstructionsEnabled: H, toolbarEditorPosition: U } = e || {}, { choices: W = {}, prompt: G, rationale: K, responseAreas: q, teacherInstructions: J } = I || {}, Y = i(t), X = p && p.prompt, Z = h && h.prompt, Q = { position: U === "top" ? "top" : "bottom" }, ue = {
131
- partialScoring: v.settings && y(v.label),
132
- maxLengthPerChoiceEnabled: g.settings && y(g.label),
133
- "language.enabled": M.settings && y(M.label, !0),
134
- language: M.settings && M.enabled && ie(N.label, N.options),
135
- "responseAreaInputConfiguration.inputConfiguration.characters.disabled": P.settings && y(P.label, !0)
136
- }, de = {
137
- teacherInstructionsEnabled: k.settings && y(k.label),
138
- rationaleEnabled: T.settings && y(T.label),
139
- promptEnabled: w.settings && y(w.label),
140
- spellCheckEnabled: D.settings && y(D.label),
141
- playerSpellCheckEnabled: C.settings && y(C.label),
142
- rubricEnabled: A?.settings && y(A?.label),
143
- "editSource.enabled": O?.settings && y(O.label, !0)
144
- }, $ = (e = {}) => ({
145
- ...l,
146
- ...e
147
- });
148
- return /* @__PURE__ */ f(te.ConfigLayout, {
149
- extraCSSRules: L,
150
- dimensions: u,
151
- hideSettings: E,
152
- settings: /* @__PURE__ */ d(re, {
153
- model: e,
154
- configuration: t,
155
- onChangeModel: (e) => this.onModelChange(e),
156
- onChangeConfiguration: (e) => a(e, !0),
157
- groups: {
158
- Settings: ue,
159
- Properties: de
160
- }
161
- }),
162
- children: [
163
- H && /* @__PURE__ */ f(b, {
164
- label: k.label,
165
- children: [/* @__PURE__ */ d(m, {
166
- className: "prompt",
167
- markup: e.teacherInstructions || "",
168
- onChange: this.onTeacherInstructionsChanged,
169
- imageSupport: o,
170
- nonEmpty: !1,
171
- error: J,
172
- toolbarOpts: Q,
173
- pluginProps: $(k?.inputConfiguration),
174
- spellCheck: V,
175
- maxImageWidth: p && p.teacherInstructions || X,
176
- maxImageHeight: h && h.teacherInstructions || Z,
177
- uploadSoundSupport: s,
178
- languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
179
- mathMlOptions: j,
180
- autoWidthToolbar: !0
181
- }), J && /* @__PURE__ */ d(S, { children: J })]
182
- }),
183
- z && /* @__PURE__ */ f(b, {
184
- label: w.label,
185
- children: [/* @__PURE__ */ d(m, {
186
- className: "prompt",
187
- markup: e.prompt,
188
- onChange: this.onPromptChanged,
189
- imageSupport: o,
190
- nonEmpty: !1,
191
- disableUnderline: !0,
192
- error: G,
193
- toolbarOpts: Q,
194
- pluginProps: $(w?.inputConfiguration),
195
- spellCheck: V,
196
- maxImageWidth: X,
197
- maxImageHeight: Z,
198
- uploadSoundSupport: s,
199
- languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
200
- mathMlOptions: j,
201
- autoWidthToolbar: !0
202
- }), G && /* @__PURE__ */ d(S, { children: G })]
203
- }),
204
- /* @__PURE__ */ f(se, { children: [/* @__PURE__ */ d(oe, {
205
- component: "div",
206
- children: "Define Template, Choices, and Correct Responses"
207
- }), /* @__PURE__ */ d(x, {
208
- disableFocusListener: !0,
209
- disableTouchListener: !0,
210
- placement: "right",
211
- title: Y,
212
- children: /* @__PURE__ */ d(ne, {
213
- fontSize: "small",
214
- color: "primary",
215
- style: { marginLeft: "8px" }
216
- })
217
- })] }),
218
- /* @__PURE__ */ d(ae, {
219
- activePlugins: ee,
220
- toolbarOpts: { position: "top" },
221
- spellCheck: V,
222
- pluginProps: $(le?.inputConfiguration),
223
- responseAreaProps: {
224
- type: "explicit-constructed-response",
225
- options: { duplicates: !0 },
226
- maxResponseAreas: _,
227
- respAreaToolbar: (e, t, r) => {
228
- let [i, a] = e, { model: o } = this.props, s = (o.choices[i.attrs.index] || [])[0];
229
- return () => /* @__PURE__ */ d(n, {
230
- onChangeResponse: (e) => this.onChangeResponse(i.attrs.index, e),
231
- node: i,
232
- pos: a,
233
- editor: t,
234
- onToolbarDone: r,
235
- correctChoice: s,
236
- maxLengthPerChoiceEnabled: R,
237
- pluginProps: $(F?.inputConfiguration)
238
- });
239
- },
240
- error: () => W,
241
- onHandleAreaChange: this.onHandleAreaChange
242
- },
243
- markup: e.slateMarkup,
244
- onChange: this.onChange,
245
- imageSupport: o,
246
- disableImageAlignmentButtons: !0,
247
- onBlur: this.onBlur,
248
- disabled: !1,
249
- highlightShape: !1,
250
- error: q,
251
- uploadSoundSupport: s,
252
- languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
253
- mathMlOptions: j,
254
- autoWidthToolbar: !0
255
- }),
256
- q && /* @__PURE__ */ d(S, { children: q }),
257
- !c(e.choices) && /* @__PURE__ */ d(ce, { children: `Define Alternates ${R ? "and Character Limits" : ""}` }),
258
- /* @__PURE__ */ d(r, {
259
- model: e,
260
- onChange: this.onResponsesChanged,
261
- onLengthChange: this.onLengthChanged,
262
- maxLengthPerChoiceEnabled: R,
263
- spellCheck: V,
264
- choicesErrors: W,
265
- pluginProps: $(F?.inputConfiguration)
266
- }),
267
- B && /* @__PURE__ */ f(b, {
268
- label: T.label,
269
- children: [/* @__PURE__ */ d(m, {
270
- className: "prompt",
271
- markup: e.rationale || "",
272
- onChange: this.onRationaleChanged,
273
- imageSupport: o,
274
- error: K,
275
- toolbarOpts: Q,
276
- pluginProps: $(T?.inputConfiguration),
277
- spellCheck: V,
278
- maxImageWidth: p && p.rationale || X,
279
- maxImageHeight: h && h.rationale || Z,
280
- uploadSoundSupport: s,
281
- languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
282
- mathMlOptions: j,
283
- autoWidthToolbar: !0
284
- }), K && /* @__PURE__ */ d(S, { children: K })]
285
- })
286
- ]
287
- });
288
- }
289
- };
290
- //#endregion
291
- export { w as default };
@@ -1,14 +0,0 @@
1
- /**
2
- * @synced-from pie-elements/packages/explicit-constructed-response/configure/src/markupUtils.js
3
- * @auto-generated
4
- *
5
- * This file is automatically synced from pie-elements and converted to TypeScript.
6
- * Manual edits will be overwritten on next sync.
7
- * To make changes, edit the upstream JavaScript file and run sync again.
8
- */
9
- export declare const removeUnwantedCharacters: (markup: any) => any;
10
- export declare const processMarkup: (markup: any) => string;
11
- export declare const createSlateMarkup: (markup: any, choices: any) => any;
12
- export declare const getAdjustedLength: (length: any) => any;
13
- export declare const stripHtmlTags: (markup: any) => string;
14
- export declare const decodeHTML: (html: any) => string;
@@ -1,13 +0,0 @@
1
- import { escape as e } from "@pie-element/shared-lodash";
2
- //#region src/author/markupUtils.tsx
3
- var t = "imes|riangle|an|heta|herefore", n = "throot|parallel|cong|approx|eq|e|sim", r = RegExp(`(\\t(?!${t}))|(\\n(?!${n}))|(\\\\t(?!${t}))|(\\\\n(?!${n}))`, "g"), i = (e) => e.replace(r, "").replace(/\\"/g, "\"").replace(/\\\//g, "/"), a = (e = "") => {
4
- let t = document.createElement("div");
5
- return t.innerHTML = e.trim(), t;
6
- }, o = (e) => {
7
- let t = a(i(e || "") || ""), n = 0;
8
- return t.querySelectorAll("[data-type=\"explicit_constructed_response\"]").forEach((e) => {
9
- e.replaceWith(`{{${n++}}}`);
10
- }), t.innerHTML;
11
- }, s = /\{\{(\d+)\}\}/g, c = (t, n) => t ? i(t).replace(s, (t, r) => `<span data-type="explicit_constructed_response" data-index="${r}" data-value="${e(n[r][0].label || "")}"></span>`) : "", l = (e) => e <= 2 ? e + 2 : e <= 4 ? e + 3 : e <= 6 ? e + 4 : e + 5, u = (e) => typeof e == "string" ? e.replace(/<\/?[^>]+(>|$)/g, "") : "", d = (e) => new DOMParser().parseFromString(e, "text/html").body.textContent || "";
12
- //#endregion
13
- export { c as createSlateMarkup, d as decodeHTML, l as getAdjustedLength, o as processMarkup, u as stripHtmlTags };
@@ -1,9 +0,0 @@
1
- /**
2
- * @synced-from pie-elements/packages/explicit-constructed-response/configure/src/utils.js
3
- * @auto-generated
4
- *
5
- * This file is automatically synced from pie-elements and converted to TypeScript.
6
- * Manual edits will be overwritten on next sync.
7
- * To make changes, edit the upstream JavaScript file and run sync again.
8
- */
9
- export declare const generateValidationMessage: (config: any) => string;
@@ -1,7 +0,0 @@
1
- //#region src/author/utils.ts
2
- var e = (e) => {
3
- let { maxResponseAreas: t } = e;
4
- return "Validation requirements:" + ("\nCorrect answers should not be blank.\nEach answer defined for a response area should be unique.\nThere should be at least 1 " + (t ? `and at most ${t} ` : "") + "response area" + (t ? "s" : "") + " defined.");
5
- };
6
- //#endregion
7
- export { e as generateValidationMessage };