@pie-element/explicit-constructed-response 11.2.2-beta.7 → 11.2.2-beta.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.
- package/CHANGELOG.md +8 -0
- package/configure/CHANGELOG.md +8 -0
- package/configure/package.json +3 -3
- package/controller/CHANGELOG.md +8 -0
- package/controller/package.json +1 -1
- package/package.json +3 -3
- package/configure/lib/alternateResponses.js +0 -199
- package/configure/lib/alternateResponses.js.map +0 -1
- package/configure/lib/alternateSection.js +0 -329
- package/configure/lib/alternateSection.js.map +0 -1
- package/configure/lib/defaults.js +0 -184
- package/configure/lib/defaults.js.map +0 -1
- package/configure/lib/ecr-toolbar.js +0 -181
- package/configure/lib/ecr-toolbar.js.map +0 -1
- package/configure/lib/index.js +0 -165
- package/configure/lib/index.js.map +0 -1
- package/configure/lib/main.js +0 -501
- package/configure/lib/main.js.map +0 -1
- package/configure/lib/markupUtils.js +0 -70
- package/configure/lib/markupUtils.js.map +0 -1
- package/configure/lib/utils.js +0 -15
- package/configure/lib/utils.js.map +0 -1
- package/controller/lib/defaults.js +0 -23
- package/controller/lib/defaults.js.map +0 -1
- package/controller/lib/index.js +0 -368
- package/controller/lib/index.js.map +0 -1
- package/lib/index.js +0 -92
- package/lib/index.js.map +0 -1
- package/lib/main.js +0 -205
- package/lib/main.js.map +0 -1
- package/lib/print.js +0 -71
- package/lib/print.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [11.2.2-beta.9](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response@11.2.2-beta.8...@pie-element/explicit-constructed-response@11.2.2-beta.9) (2026-10-05)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-element/explicit-constructed-response
|
|
9
|
+
|
|
10
|
+
## [11.2.2-beta.8](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response@11.2.2-beta.7...@pie-element/explicit-constructed-response@11.2.2-beta.8) (2026-09-29)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @pie-element/explicit-constructed-response
|
|
13
|
+
|
|
6
14
|
## [11.2.2-beta.7](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response@11.2.2-beta.6...@pie-element/explicit-constructed-response@11.2.2-beta.7) (2026-09-24)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @pie-element/explicit-constructed-response
|
package/configure/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [10.4.0-beta.15](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-configure@10.4.0-beta.14...@pie-element/explicit-constructed-response-configure@10.4.0-beta.15) (2026-10-05)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-element/explicit-constructed-response-configure
|
|
9
|
+
|
|
10
|
+
# [10.4.0-beta.14](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-configure@10.4.0-beta.13...@pie-element/explicit-constructed-response-configure@10.4.0-beta.14) (2026-09-29)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @pie-element/explicit-constructed-response-configure
|
|
13
|
+
|
|
6
14
|
# [10.4.0-beta.13](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-configure@10.4.0-beta.12...@pie-element/explicit-constructed-response-configure@10.4.0-beta.13) (2026-09-24)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @pie-element/explicit-constructed-response-configure
|
package/configure/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/explicit-constructed-response-configure",
|
|
3
|
-
"version": "10.4.0-beta.
|
|
3
|
+
"version": "10.4.0-beta.15",
|
|
4
4
|
"private": true,
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"modue": "src/index.js",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"@mui/icons-material": "^7.3.4",
|
|
11
11
|
"@mui/material": "^7.3.4",
|
|
12
12
|
"@pie-framework/pie-configure-events": "^1.3.0",
|
|
13
|
-
"@pie-lib/config-ui": "13.0.22-beta.
|
|
14
|
-
"@pie-lib/editable-html-tip-tap": "2.1.20-beta.
|
|
13
|
+
"@pie-lib/config-ui": "13.0.22-beta.4",
|
|
14
|
+
"@pie-lib/editable-html-tip-tap": "2.1.20-beta.4",
|
|
15
15
|
"classnames": "^2.2.6",
|
|
16
16
|
"debug": "^4.1.1",
|
|
17
17
|
"lodash-es": "^4.17.23",
|
package/controller/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [8.4.0-beta.15](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-controller@8.4.0-beta.14...@pie-element/explicit-constructed-response-controller@8.4.0-beta.15) (2026-10-05)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-element/explicit-constructed-response-controller
|
|
9
|
+
|
|
10
|
+
# [8.4.0-beta.14](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-controller@8.4.0-beta.13...@pie-element/explicit-constructed-response-controller@8.4.0-beta.14) (2026-09-29)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @pie-element/explicit-constructed-response-controller
|
|
13
|
+
|
|
6
14
|
# [8.4.0-beta.13](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-controller@8.4.0-beta.12...@pie-element/explicit-constructed-response-controller@8.4.0-beta.13) (2026-09-24)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @pie-element/explicit-constructed-response-controller
|
package/controller/package.json
CHANGED
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "11.2.2-beta.
|
|
7
|
+
"version": "11.2.2-beta.9",
|
|
8
8
|
"description": "",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"postpublish": "../../scripts/postpublish"
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"@mui/material": "^7.3.4",
|
|
17
17
|
"@pie-framework/pie-player-events": "^0.1.0",
|
|
18
18
|
"@pie-lib/correct-answer-toggle": "4.0.5",
|
|
19
|
-
"@pie-lib/mask-markup": "3.1.6-beta.
|
|
19
|
+
"@pie-lib/mask-markup": "3.1.6-beta.4",
|
|
20
20
|
"@pie-lib/math-rendering": "5.1.0",
|
|
21
21
|
"@pie-lib/render-ui": "6.1.3",
|
|
22
22
|
"@pie-lib/translator": "4.0.2",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"author": "",
|
|
31
31
|
"license": "ISC",
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "32a5f5323ce51e20c15145518e8f6e45f2a87cf2",
|
|
33
33
|
"main": "lib/index.js",
|
|
34
34
|
"module": "src/index.js",
|
|
35
35
|
"exports": {
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = exports.AlternateResponses = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
var _lodashEs = require("lodash-es");
|
|
12
|
-
var _alternateSection = _interopRequireDefault(require("./alternateSection"));
|
|
13
|
-
class AlternateResponses extends _react.default.Component {
|
|
14
|
-
constructor(...args) {
|
|
15
|
-
super(...args);
|
|
16
|
-
(0, _defineProperty2.default)(this, "state", {
|
|
17
|
-
maxLengthPerChoice: (0, _lodashEs.cloneDeep)(this.props.model.maxLengthPerChoice)
|
|
18
|
-
});
|
|
19
|
-
(0, _defineProperty2.default)(this, "updateChoicesIfNeeded", props => {
|
|
20
|
-
if (!this.state.choices || !(0, _lodashEs.isEqual)(this.state.choices, props.model.choices) || !(0, _lodashEs.isEqual)(props.model.choices, this.props.model.choices) || this.state.values && Object.keys(this.state.values).length !== Object.keys(this.props.model.choices).length || props.maxLengthPerChoiceEnabled !== this.props.maxLengthPerChoiceEnabled) {
|
|
21
|
-
const {
|
|
22
|
-
choices,
|
|
23
|
-
maxLengthPerChoice
|
|
24
|
-
} = props.model;
|
|
25
|
-
const selectedValues = (0, _lodashEs.reduce)(choices, (obj, c, key) => {
|
|
26
|
-
// if maxLengthPerChoiceEnabled is true, we display all the choices
|
|
27
|
-
if (c && (props.maxLengthPerChoiceEnabled || c.length > 1)) {
|
|
28
|
-
obj[key] = c[0];
|
|
29
|
-
}
|
|
30
|
-
return obj;
|
|
31
|
-
}, {});
|
|
32
|
-
this.setState({
|
|
33
|
-
choices: props.model.choices,
|
|
34
|
-
values: selectedValues,
|
|
35
|
-
maxLengthPerChoice: (0, _lodashEs.cloneDeep)(maxLengthPerChoice)
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
(0, _defineProperty2.default)(this, "getRemainingChoices", valueKey => {
|
|
40
|
-
const {
|
|
41
|
-
choices
|
|
42
|
-
} = this.state;
|
|
43
|
-
return (0, _lodashEs.reduce)(choices, (arr, c, key) => {
|
|
44
|
-
if (c && c.length === 1 && !valueKey) {
|
|
45
|
-
arr.push({
|
|
46
|
-
label: c[0].label,
|
|
47
|
-
value: key
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
return arr;
|
|
51
|
-
}, []);
|
|
52
|
-
});
|
|
53
|
-
(0, _defineProperty2.default)(this, "onChoiceChanged", (choice, key) => {
|
|
54
|
-
const {
|
|
55
|
-
onChange
|
|
56
|
-
} = this.props;
|
|
57
|
-
const {
|
|
58
|
-
choices
|
|
59
|
-
} = this.state;
|
|
60
|
-
const sectionChoices = choices[key] || [];
|
|
61
|
-
const isNew = !sectionChoices.find(c => c.value === choice.value);
|
|
62
|
-
const newChoices = sectionChoices.reduce((arr, c) => {
|
|
63
|
-
const newVal = c.value === choice.value ? choice : c;
|
|
64
|
-
arr.push(newVal);
|
|
65
|
-
return arr;
|
|
66
|
-
}, []);
|
|
67
|
-
if (isNew) {
|
|
68
|
-
newChoices.push(choice);
|
|
69
|
-
}
|
|
70
|
-
onChange({
|
|
71
|
-
...choices,
|
|
72
|
-
[key]: newChoices
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
(0, _defineProperty2.default)(this, "onChoiceRemoved", (value, section) => {
|
|
76
|
-
const {
|
|
77
|
-
onChange
|
|
78
|
-
} = this.props;
|
|
79
|
-
const {
|
|
80
|
-
choices
|
|
81
|
-
} = this.state;
|
|
82
|
-
const sectionChoices = choices[section] || [];
|
|
83
|
-
const newChoices = sectionChoices.reduce((arr, c) => {
|
|
84
|
-
if (c.value === value) {
|
|
85
|
-
return arr;
|
|
86
|
-
}
|
|
87
|
-
arr.push(c);
|
|
88
|
-
return arr;
|
|
89
|
-
}, []);
|
|
90
|
-
onChange({
|
|
91
|
-
...choices,
|
|
92
|
-
[section]: newChoices
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
(0, _defineProperty2.default)(this, "onSectionSelect", (choice, key) => {
|
|
96
|
-
const {
|
|
97
|
-
onChange
|
|
98
|
-
} = this.props;
|
|
99
|
-
const {
|
|
100
|
-
choices,
|
|
101
|
-
values
|
|
102
|
-
} = this.state;
|
|
103
|
-
if (choices[key] && choices[key].length > 1) {
|
|
104
|
-
if (!choice) {
|
|
105
|
-
onChange({
|
|
106
|
-
...choices,
|
|
107
|
-
[key]: [choices[key][0]]
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
} else {
|
|
111
|
-
this.setState({
|
|
112
|
-
choices: {
|
|
113
|
-
...choices,
|
|
114
|
-
[key]: [...choices[key], {
|
|
115
|
-
label: '',
|
|
116
|
-
value: '1'
|
|
117
|
-
}]
|
|
118
|
-
},
|
|
119
|
-
values: {
|
|
120
|
-
...values,
|
|
121
|
-
[key]: choices[key][0]
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
(0, _defineProperty2.default)(this, "onLengthChanged", (value, key) => {
|
|
127
|
-
const {
|
|
128
|
-
model,
|
|
129
|
-
onLengthChange
|
|
130
|
-
} = this.props;
|
|
131
|
-
const {
|
|
132
|
-
maxLengthPerChoice
|
|
133
|
-
} = model;
|
|
134
|
-
maxLengthPerChoice[key] = value;
|
|
135
|
-
onLengthChange(maxLengthPerChoice);
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
139
|
-
this.updateChoicesIfNeeded(nextProps);
|
|
140
|
-
}
|
|
141
|
-
componentDidMount() {
|
|
142
|
-
this.updateChoicesIfNeeded(this.props);
|
|
143
|
-
}
|
|
144
|
-
render() {
|
|
145
|
-
const {
|
|
146
|
-
choices
|
|
147
|
-
} = this.state;
|
|
148
|
-
const {
|
|
149
|
-
model: {
|
|
150
|
-
maxLengthPerChoice,
|
|
151
|
-
maxLengthPerChoiceEnabled
|
|
152
|
-
},
|
|
153
|
-
spellCheck,
|
|
154
|
-
choicesErrors,
|
|
155
|
-
pluginProps
|
|
156
|
-
} = this.props;
|
|
157
|
-
return /*#__PURE__*/_react.default.createElement("div", null, (0, _lodashEs.map)(choices, (c, key) => {
|
|
158
|
-
// if maxLengthPerChoiceEnabled is true, we display all the choices
|
|
159
|
-
if (c && (maxLengthPerChoiceEnabled || c.length > 1)) {
|
|
160
|
-
const selected = this.state.values[key];
|
|
161
|
-
return /*#__PURE__*/_react.default.createElement(_alternateSection.default, {
|
|
162
|
-
key: key,
|
|
163
|
-
value: selected && selected.value,
|
|
164
|
-
errors: choicesErrors && choicesErrors[key],
|
|
165
|
-
onSelect: choice => this.onSectionSelect(choice, key),
|
|
166
|
-
choiceChanged: choice => this.onChoiceChanged(choice, key),
|
|
167
|
-
choiceRemoved: value => this.onChoiceRemoved(value, key),
|
|
168
|
-
lengthChanged: value => this.onLengthChanged(value, key),
|
|
169
|
-
selectChoices: [selected],
|
|
170
|
-
choices: c,
|
|
171
|
-
maxLength: maxLengthPerChoice[key],
|
|
172
|
-
showMaxLength: maxLengthPerChoiceEnabled,
|
|
173
|
-
spellCheck: spellCheck,
|
|
174
|
-
pluginProps: pluginProps
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
}), choices && Object.keys(this.state.values).length !== Object.keys(choices).length && /*#__PURE__*/_react.default.createElement(_alternateSection.default, {
|
|
178
|
-
value: "",
|
|
179
|
-
onSelect: choice => this.onSectionSelect(choice, choice.value),
|
|
180
|
-
choiceChanged: choice => this.onChoiceChanged(choice),
|
|
181
|
-
choiceRemoved: value => this.onChoiceRemoved(value),
|
|
182
|
-
selectChoices: this.getRemainingChoices(),
|
|
183
|
-
spellCheck: spellCheck,
|
|
184
|
-
pluginProps: pluginProps
|
|
185
|
-
}));
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
exports.AlternateResponses = AlternateResponses;
|
|
189
|
-
(0, _defineProperty2.default)(AlternateResponses, "propTypes", {
|
|
190
|
-
choicesErrors: _propTypes.default.object,
|
|
191
|
-
model: _propTypes.default.object.isRequired,
|
|
192
|
-
onChange: _propTypes.default.func.isRequired,
|
|
193
|
-
onLengthChange: _propTypes.default.func.isRequired,
|
|
194
|
-
maxLengthPerChoiceEnabled: _propTypes.default.bool.isRequired,
|
|
195
|
-
spellCheck: _propTypes.default.bool,
|
|
196
|
-
pluginProps: _propTypes.default.object
|
|
197
|
-
});
|
|
198
|
-
var _default = exports.default = AlternateResponses;
|
|
199
|
-
//# sourceMappingURL=alternateResponses.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"alternateResponses.js","names":["_react","_interopRequireDefault","require","_propTypes","_lodashEs","_alternateSection","AlternateResponses","React","Component","constructor","args","_defineProperty2","default","maxLengthPerChoice","cloneDeep","props","model","state","choices","isEqual","values","Object","keys","length","maxLengthPerChoiceEnabled","selectedValues","reduce","obj","c","key","setState","valueKey","arr","push","label","value","choice","onChange","sectionChoices","isNew","find","newChoices","newVal","section","onLengthChange","UNSAFE_componentWillReceiveProps","nextProps","updateChoicesIfNeeded","componentDidMount","render","spellCheck","choicesErrors","pluginProps","createElement","map","selected","errors","onSelect","onSectionSelect","choiceChanged","onChoiceChanged","choiceRemoved","onChoiceRemoved","lengthChanged","onLengthChanged","selectChoices","maxLength","showMaxLength","getRemainingChoices","exports","PropTypes","object","isRequired","func","bool","_default"],"sources":["../src/alternateResponses.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { cloneDeep, isEqual, map, reduce } from 'lodash-es';\n\nimport AlternateSection from './alternateSection';\n\nexport class AlternateResponses extends React.Component {\n static propTypes = {\n choicesErrors: PropTypes.object,\n model: PropTypes.object.isRequired,\n onChange: PropTypes.func.isRequired,\n onLengthChange: PropTypes.func.isRequired,\n maxLengthPerChoiceEnabled: PropTypes.bool.isRequired,\n spellCheck: PropTypes.bool,\n pluginProps: PropTypes.object,\n };\n\n state = { maxLengthPerChoice: cloneDeep(this.props.model.maxLengthPerChoice) };\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n this.updateChoicesIfNeeded(nextProps);\n }\n\n componentDidMount() {\n this.updateChoicesIfNeeded(this.props);\n }\n\n updateChoicesIfNeeded = (props) => {\n if (\n !this.state.choices ||\n !isEqual(this.state.choices, props.model.choices) ||\n !isEqual(props.model.choices, this.props.model.choices) ||\n (this.state.values && Object.keys(this.state.values).length !== Object.keys(this.props.model.choices).length) ||\n props.maxLengthPerChoiceEnabled !== this.props.maxLengthPerChoiceEnabled\n ) {\n const { choices, maxLengthPerChoice } = props.model;\n\n const selectedValues = reduce(\n choices,\n (obj, c, key) => {\n // if maxLengthPerChoiceEnabled is true, we display all the choices\n if (c && (props.maxLengthPerChoiceEnabled || c.length > 1)) {\n obj[key] = c[0];\n }\n\n return obj;\n },\n {},\n );\n\n this.setState({\n choices: props.model.choices,\n values: selectedValues,\n maxLengthPerChoice: cloneDeep(maxLengthPerChoice),\n });\n }\n };\n\n getRemainingChoices = (valueKey) => {\n const { choices } = this.state;\n\n return reduce(\n choices,\n (arr, c, key) => {\n if (c && c.length === 1 && !valueKey) {\n arr.push({\n label: c[0].label,\n value: key,\n });\n }\n\n return arr;\n },\n [],\n );\n };\n\n onChoiceChanged = (choice, key) => {\n const { onChange } = this.props;\n const { choices } = this.state;\n const sectionChoices = choices[key] || [];\n\n const isNew = !sectionChoices.find((c) => c.value === choice.value);\n\n const newChoices = sectionChoices.reduce((arr, c) => {\n const newVal = c.value === choice.value ? choice : c;\n\n arr.push(newVal);\n\n return arr;\n }, []);\n\n if (isNew) {\n newChoices.push(choice);\n }\n\n onChange({\n ...choices,\n [key]: newChoices,\n });\n };\n\n onChoiceRemoved = (value, section) => {\n const { onChange } = this.props;\n const { choices } = this.state;\n const sectionChoices = choices[section] || [];\n\n const newChoices = sectionChoices.reduce((arr, c) => {\n if (c.value === value) {\n return arr;\n }\n\n arr.push(c);\n\n return arr;\n }, []);\n\n onChange({\n ...choices,\n [section]: newChoices,\n });\n };\n\n onSectionSelect = (choice, key) => {\n const { onChange } = this.props;\n const { choices, values } = this.state;\n\n if (choices[key] && choices[key].length > 1) {\n if (!choice) {\n onChange({\n ...choices,\n [key]: [choices[key][0]],\n });\n }\n } else {\n this.setState({\n choices: {\n ...choices,\n [key]: [\n ...choices[key],\n {\n label: '',\n value: '1',\n },\n ],\n },\n values: {\n ...values,\n [key]: choices[key][0],\n },\n });\n }\n };\n\n onLengthChanged = (value, key) => {\n const { model, onLengthChange } = this.props;\n const { maxLengthPerChoice } = model;\n\n maxLengthPerChoice[key] = value;\n onLengthChange(maxLengthPerChoice);\n };\n\n render() {\n const { choices } = this.state;\n const {\n model: { maxLengthPerChoice, maxLengthPerChoiceEnabled },\n spellCheck,\n choicesErrors,\n pluginProps,\n } = this.props;\n\n return (\n <div>\n {map(choices, (c, key) => {\n // if maxLengthPerChoiceEnabled is true, we display all the choices\n if (c && (maxLengthPerChoiceEnabled || c.length > 1)) {\n const selected = this.state.values[key];\n\n return (\n <AlternateSection\n key={key}\n value={selected && selected.value}\n errors={choicesErrors && choicesErrors[key]}\n onSelect={(choice) => this.onSectionSelect(choice, key)}\n choiceChanged={(choice) => this.onChoiceChanged(choice, key)}\n choiceRemoved={(value) => this.onChoiceRemoved(value, key)}\n lengthChanged={(value) => this.onLengthChanged(value, key)}\n selectChoices={[selected]}\n choices={c}\n maxLength={maxLengthPerChoice[key]}\n showMaxLength={maxLengthPerChoiceEnabled}\n spellCheck={spellCheck}\n pluginProps={pluginProps}\n />\n );\n }\n })}\n\n {choices && Object.keys(this.state.values).length !== Object.keys(choices).length && (\n <AlternateSection\n value=\"\"\n onSelect={(choice) => this.onSectionSelect(choice, choice.value)}\n choiceChanged={(choice) => this.onChoiceChanged(choice)}\n choiceRemoved={(value) => this.onChoiceRemoved(value)}\n selectChoices={this.getRemainingChoices()}\n spellCheck={spellCheck}\n pluginProps={pluginProps}\n />\n )}\n </div>\n );\n }\n}\n\nexport default AlternateResponses;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAEA,IAAAG,iBAAA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AAAyC,aAAA,CAAChD,iBAAA,CAAAO,OAAgB;MACfuB,KAAK,EAAC,EAAE;MACRsB,QAAQ,EAAGrB,MAAM,IAAK,IAAI,CAACsB,eAAe,CAACtB,MAAM,EAAEA,MAAM,CAACD,KAAK,CAAE;MACjEwB,aAAa,EAAGvB,MAAM,IAAK,IAAI,CAACwB,eAAe,CAACxB,MAAM,CAAE;MACxDyB,aAAa,EAAG1B,KAAK,IAAK,IAAI,CAAC2B,eAAe,CAAC3B,KAAK,CAAE;MACtD8B,aAAa,EAAE,IAAI,CAACG,mBAAmB,CAAC,CAAE;MAC1ClB,UAAU,EAAEA,UAAW;MACvBE,WAAW,EAAEA;IAAY,CAC1B,CAEA,CAAC;EAEV;AACF;AAACiB,OAAA,CAAA/D,kBAAA,GAAAA,kBAAA;AAAA,IAAAK,gBAAA,CAAAC,OAAA,EA9MYN,kBAAkB,eACV;EACjB6C,aAAa,EAAEmB,kBAAS,CAACC,MAAM;EAC/BvD,KAAK,EAAEsD,kBAAS,CAACC,MAAM,CAACC,UAAU;EAClCnC,QAAQ,EAAEiC,kBAAS,CAACG,IAAI,CAACD,UAAU;EACnC5B,cAAc,EAAE0B,kBAAS,CAACG,IAAI,CAACD,UAAU;EACzChD,yBAAyB,EAAE8C,kBAAS,CAACI,IAAI,CAACF,UAAU;EACpDtB,UAAU,EAAEoB,kBAAS,CAACI,IAAI;EAC1BtB,WAAW,EAAEkB,kBAAS,CAACC;AACzB,CAAC;AAAA,IAAAI,QAAA,GAAAN,OAAA,CAAAzD,OAAA,GAuMYN,kBAAkB","ignoreList":[]}
|
|
@@ -1,329 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = exports.Choice = exports.AlternateSection = void 0;
|
|
8
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
-
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
|
-
var _lodashEs = require("lodash-es");
|
|
13
|
-
var _Button = _interopRequireDefault(require("@mui/material/Button"));
|
|
14
|
-
var _Delete = _interopRequireDefault(require("@mui/icons-material/Delete"));
|
|
15
|
-
var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
|
|
16
|
-
var _MenuItem = _interopRequireDefault(require("@mui/material/MenuItem"));
|
|
17
|
-
var _Select = _interopRequireDefault(require("@mui/material/Select"));
|
|
18
|
-
var _TextField = _interopRequireDefault(require("@mui/material/TextField"));
|
|
19
|
-
var _styles = require("@mui/material/styles");
|
|
20
|
-
var _editableHtmlTipTap = _interopRequireDefault(require("@pie-lib/editable-html-tip-tap"));
|
|
21
|
-
var _markupUtils = require("./markupUtils");
|
|
22
|
-
const DesignContainer = (0, _styles.styled)('div')(({
|
|
23
|
-
theme
|
|
24
|
-
}) => ({
|
|
25
|
-
marginBottom: theme.spacing(0.5)
|
|
26
|
-
}));
|
|
27
|
-
const AltChoices = (0, _styles.styled)('div')(({
|
|
28
|
-
theme
|
|
29
|
-
}) => ({
|
|
30
|
-
alignItems: 'flex-start',
|
|
31
|
-
flexDirection: 'column',
|
|
32
|
-
display: 'flex',
|
|
33
|
-
paddingTop: theme.spacing(2.5),
|
|
34
|
-
'& > *': {
|
|
35
|
-
marginBottom: theme.spacing(2.5),
|
|
36
|
-
width: '100%'
|
|
37
|
-
}
|
|
38
|
-
}));
|
|
39
|
-
const StyledEditableHtml = (0, _styles.styled)(_editableHtmlTipTap.default)(({
|
|
40
|
-
theme,
|
|
41
|
-
hasError
|
|
42
|
-
}) => ({
|
|
43
|
-
flex: '1',
|
|
44
|
-
marginRight: theme.spacing(2.5),
|
|
45
|
-
...(hasError && {
|
|
46
|
-
border: `2px solid ${theme.palette.error.main}`,
|
|
47
|
-
borderRadius: '6px'
|
|
48
|
-
})
|
|
49
|
-
}));
|
|
50
|
-
const StyledDeleteButton = (0, _styles.styled)(_IconButton.default)(({
|
|
51
|
-
theme
|
|
52
|
-
}) => ({
|
|
53
|
-
'& svg': {
|
|
54
|
-
fill: theme.palette.grey[600]
|
|
55
|
-
}
|
|
56
|
-
}));
|
|
57
|
-
const SelectContainer = (0, _styles.styled)('div')({
|
|
58
|
-
alignItems: 'flex-end',
|
|
59
|
-
display: 'flex',
|
|
60
|
-
justifyContent: 'space-between',
|
|
61
|
-
width: '100%'
|
|
62
|
-
});
|
|
63
|
-
const RightContainer = (0, _styles.styled)('div')({
|
|
64
|
-
alignItems: 'center',
|
|
65
|
-
display: 'flex'
|
|
66
|
-
});
|
|
67
|
-
const LengthField = (0, _styles.styled)(_TextField.default)(({
|
|
68
|
-
theme
|
|
69
|
-
}) => ({
|
|
70
|
-
width: '230px',
|
|
71
|
-
marginRight: theme.spacing(2.5),
|
|
72
|
-
'& .MuiInput-underline:before': {
|
|
73
|
-
borderBottomColor: theme.palette.divider
|
|
74
|
-
},
|
|
75
|
-
'& .MuiInput-underline:hover:not(.Mui-disabled):before': {
|
|
76
|
-
borderBottomColor: theme.palette.text.primary
|
|
77
|
-
},
|
|
78
|
-
'& .MuiInput-underline:after': {
|
|
79
|
-
borderBottomColor: theme.palette.primary.main
|
|
80
|
-
}
|
|
81
|
-
}));
|
|
82
|
-
const ErrorText = (0, _styles.styled)('div')(({
|
|
83
|
-
theme
|
|
84
|
-
}) => ({
|
|
85
|
-
fontSize: theme.typography.fontSize - 2,
|
|
86
|
-
color: theme.palette.error.main,
|
|
87
|
-
paddingTop: theme.spacing(0.5)
|
|
88
|
-
}));
|
|
89
|
-
const ChoiceWrapper = (0, _styles.styled)('div')({
|
|
90
|
-
alignItems: 'center',
|
|
91
|
-
display: 'flex',
|
|
92
|
-
justifyContent: 'space-between'
|
|
93
|
-
});
|
|
94
|
-
class Choice extends _react.default.Component {
|
|
95
|
-
constructor(...args) {
|
|
96
|
-
super(...args);
|
|
97
|
-
(0, _defineProperty2.default)(this, "state", {
|
|
98
|
-
value: this.props.markup
|
|
99
|
-
});
|
|
100
|
-
(0, _defineProperty2.default)(this, "updateText", (0, _lodashEs.debounce)(this.props.onChange, 300));
|
|
101
|
-
(0, _defineProperty2.default)(this, "onChange", e => {
|
|
102
|
-
const strippedValue = (0, _markupUtils.stripHtmlTags)(e);
|
|
103
|
-
this.setState({
|
|
104
|
-
value: strippedValue
|
|
105
|
-
});
|
|
106
|
-
this.updateText(strippedValue);
|
|
107
|
-
});
|
|
108
|
-
(0, _defineProperty2.default)(this, "onKeyDown", event => {
|
|
109
|
-
if (event.key === 'Enter') {
|
|
110
|
-
return true;
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
115
|
-
if (nextProps.markup) {
|
|
116
|
-
this.setState({
|
|
117
|
-
value: nextProps.markup
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
render() {
|
|
122
|
-
const {
|
|
123
|
-
value
|
|
124
|
-
} = this.state;
|
|
125
|
-
const {
|
|
126
|
-
onDelete,
|
|
127
|
-
spellCheck,
|
|
128
|
-
error,
|
|
129
|
-
showMaxLength,
|
|
130
|
-
pluginProps
|
|
131
|
-
} = this.props;
|
|
132
|
-
const inputProps = showMaxLength ? {} : {
|
|
133
|
-
maxLength: 25
|
|
134
|
-
};
|
|
135
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(ChoiceWrapper, null, /*#__PURE__*/_react.default.createElement(StyledEditableHtml, (0, _extends2.default)({
|
|
136
|
-
hasError: !!error,
|
|
137
|
-
disableUnderline: true,
|
|
138
|
-
onChange: this.onChange,
|
|
139
|
-
onKeyDown: this.onKeyDown,
|
|
140
|
-
markup: value || '',
|
|
141
|
-
activePlugins: ['languageCharacters'],
|
|
142
|
-
pluginProps: pluginProps,
|
|
143
|
-
languageCharactersProps: [{
|
|
144
|
-
language: 'spanish'
|
|
145
|
-
}],
|
|
146
|
-
spellCheck: spellCheck,
|
|
147
|
-
autoWidthToolbar: true,
|
|
148
|
-
toolbarOpts: {
|
|
149
|
-
minWidth: 'auto',
|
|
150
|
-
isHidden: !!pluginProps?.characters?.disabled
|
|
151
|
-
}
|
|
152
|
-
}, inputProps)), /*#__PURE__*/_react.default.createElement(StyledDeleteButton, {
|
|
153
|
-
"aria-label": "delete",
|
|
154
|
-
onClick: onDelete,
|
|
155
|
-
size: "large"
|
|
156
|
-
}, /*#__PURE__*/_react.default.createElement(_Delete.default, null))), error && /*#__PURE__*/_react.default.createElement(ErrorText, null, error));
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
exports.Choice = Choice;
|
|
160
|
-
(0, _defineProperty2.default)(Choice, "propTypes", {
|
|
161
|
-
error: _propTypes.default.string,
|
|
162
|
-
markup: _propTypes.default.string,
|
|
163
|
-
onChange: _propTypes.default.func.isRequired,
|
|
164
|
-
onDelete: _propTypes.default.func.isRequired,
|
|
165
|
-
value: _propTypes.default.string,
|
|
166
|
-
spellCheck: _propTypes.default.bool,
|
|
167
|
-
showMaxLength: _propTypes.default.bool,
|
|
168
|
-
pluginProps: _propTypes.default.object
|
|
169
|
-
});
|
|
170
|
-
class AlternateSection extends _react.default.Component {
|
|
171
|
-
constructor(...args) {
|
|
172
|
-
super(...args);
|
|
173
|
-
(0, _defineProperty2.default)(this, "state", {});
|
|
174
|
-
(0, _defineProperty2.default)(this, "updateChoicesIfNeeded", props => {
|
|
175
|
-
if (!this.state.choices || !(0, _lodashEs.isEqual)(props.choices, this.state.choices) || !(0, _lodashEs.isEqual)(props.choices, this.props.choices)) {
|
|
176
|
-
this.setState({
|
|
177
|
-
choices: props.choices
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
(0, _defineProperty2.default)(this, "handleSelect", e => {
|
|
182
|
-
const {
|
|
183
|
-
onSelect,
|
|
184
|
-
selectChoices
|
|
185
|
-
} = this.props;
|
|
186
|
-
const {
|
|
187
|
-
value
|
|
188
|
-
} = e.target;
|
|
189
|
-
onSelect(selectChoices.find(c => c.value === value));
|
|
190
|
-
});
|
|
191
|
-
(0, _defineProperty2.default)(this, "onAddChoice", () => {
|
|
192
|
-
const {
|
|
193
|
-
choices
|
|
194
|
-
} = this.state;
|
|
195
|
-
if (choices.length && choices[choices.length - 1].label !== '') {
|
|
196
|
-
const value = (0, _lodashEs.max)(choices.map(c => parseInt(c.value)).filter(id => !isNaN(id))) || 0;
|
|
197
|
-
this.setState({
|
|
198
|
-
choices: [...choices, {
|
|
199
|
-
value: `${value + 1}`,
|
|
200
|
-
label: ''
|
|
201
|
-
}]
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
(0, _defineProperty2.default)(this, "onChoiceChanged", (choice, value, index) => {
|
|
206
|
-
const {
|
|
207
|
-
choiceChanged,
|
|
208
|
-
lengthChanged,
|
|
209
|
-
maxLength,
|
|
210
|
-
choices
|
|
211
|
-
} = this.props;
|
|
212
|
-
const labelLengthsArr = choices.map(choice => (0, _markupUtils.decodeHTML)(choice.label || '').length);
|
|
213
|
-
labelLengthsArr[index] = (0, _markupUtils.decodeHTML)(value).length;
|
|
214
|
-
const newLength = Math.max(...labelLengthsArr);
|
|
215
|
-
choiceChanged({
|
|
216
|
-
...choice,
|
|
217
|
-
label: value
|
|
218
|
-
});
|
|
219
|
-
if (newLength > maxLength || newLength + 10 <= maxLength) {
|
|
220
|
-
lengthChanged((0, _markupUtils.getAdjustedLength)(newLength));
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
|
-
(0, _defineProperty2.default)(this, "onRemoveChoice", choice => {
|
|
224
|
-
const {
|
|
225
|
-
choiceRemoved
|
|
226
|
-
} = this.props;
|
|
227
|
-
choiceRemoved(choice.value);
|
|
228
|
-
});
|
|
229
|
-
(0, _defineProperty2.default)(this, "getChoicesMaxLength", () => {
|
|
230
|
-
const {
|
|
231
|
-
choices
|
|
232
|
-
} = this.state;
|
|
233
|
-
if (!choices) {
|
|
234
|
-
return 1;
|
|
235
|
-
}
|
|
236
|
-
const labelLengthsArr = choices.map(choice => (0, _markupUtils.decodeHTML)(choice.label || '').length);
|
|
237
|
-
return Math.max(...labelLengthsArr);
|
|
238
|
-
});
|
|
239
|
-
(0, _defineProperty2.default)(this, "changeLength", event => {
|
|
240
|
-
const {
|
|
241
|
-
lengthChanged
|
|
242
|
-
} = this.props;
|
|
243
|
-
const numberValue = parseInt(event.target.value, 10);
|
|
244
|
-
const minLength = this.getChoicesMaxLength();
|
|
245
|
-
if (numberValue && numberValue >= minLength && numberValue <= minLength + 10) {
|
|
246
|
-
lengthChanged(numberValue);
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
251
|
-
this.updateChoicesIfNeeded(nextProps);
|
|
252
|
-
}
|
|
253
|
-
componentDidMount() {
|
|
254
|
-
this.updateChoicesIfNeeded(this.props);
|
|
255
|
-
}
|
|
256
|
-
render() {
|
|
257
|
-
const {
|
|
258
|
-
selectChoices,
|
|
259
|
-
maxLength,
|
|
260
|
-
showMaxLength,
|
|
261
|
-
value,
|
|
262
|
-
spellCheck,
|
|
263
|
-
errors,
|
|
264
|
-
pluginProps
|
|
265
|
-
} = this.props;
|
|
266
|
-
const {
|
|
267
|
-
choices
|
|
268
|
-
} = this.state;
|
|
269
|
-
const minLength = this.getChoicesMaxLength();
|
|
270
|
-
return /*#__PURE__*/_react.default.createElement(DesignContainer, null, /*#__PURE__*/_react.default.createElement(SelectContainer, null, /*#__PURE__*/_react.default.createElement(_Select.default, {
|
|
271
|
-
variant: "standard",
|
|
272
|
-
displayEmpty: true,
|
|
273
|
-
onChange: this.handleSelect,
|
|
274
|
-
value: value || '',
|
|
275
|
-
readOnly: showMaxLength,
|
|
276
|
-
MenuProps: {
|
|
277
|
-
transitionDuration: {
|
|
278
|
-
enter: 225,
|
|
279
|
-
exit: 195
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
}, /*#__PURE__*/_react.default.createElement(_MenuItem.default, {
|
|
283
|
-
value: ""
|
|
284
|
-
}, /*#__PURE__*/_react.default.createElement("em", null, value ? 'Remove selection' : 'Select a response')), selectChoices.map((c, index) => /*#__PURE__*/_react.default.createElement(_MenuItem.default, {
|
|
285
|
-
key: index,
|
|
286
|
-
value: c?.value
|
|
287
|
-
}, (0, _markupUtils.decodeHTML)(c?.label)))), choices && choices.length > 0 && /*#__PURE__*/_react.default.createElement(RightContainer, null, maxLength && showMaxLength && /*#__PURE__*/_react.default.createElement(LengthField, {
|
|
288
|
-
variant: "standard",
|
|
289
|
-
label: "Maximum length (characters)",
|
|
290
|
-
type: "number",
|
|
291
|
-
inputProps: {
|
|
292
|
-
min: minLength,
|
|
293
|
-
max: minLength + 10
|
|
294
|
-
},
|
|
295
|
-
value: maxLength,
|
|
296
|
-
onChange: this.changeLength
|
|
297
|
-
}), /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
298
|
-
variant: "contained",
|
|
299
|
-
color: "primary",
|
|
300
|
-
onClick: this.onAddChoice
|
|
301
|
-
}, "Add"))), errors && errors[0] && /*#__PURE__*/_react.default.createElement(ErrorText, null, errors[0]), /*#__PURE__*/_react.default.createElement(AltChoices, null, choices && choices.map((c, index) => index > 0 && /*#__PURE__*/_react.default.createElement(Choice, {
|
|
302
|
-
key: index,
|
|
303
|
-
markup: c.label,
|
|
304
|
-
onChange: val => this.onChoiceChanged(c, val, index),
|
|
305
|
-
onDelete: () => this.onRemoveChoice(c),
|
|
306
|
-
spellCheck: spellCheck,
|
|
307
|
-
error: errors && errors[index],
|
|
308
|
-
showMaxLength: showMaxLength,
|
|
309
|
-
pluginProps: pluginProps
|
|
310
|
-
}))));
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
exports.AlternateSection = AlternateSection;
|
|
314
|
-
(0, _defineProperty2.default)(AlternateSection, "propTypes", {
|
|
315
|
-
choices: _propTypes.default.array,
|
|
316
|
-
selectChoices: _propTypes.default.array.isRequired,
|
|
317
|
-
errors: _propTypes.default.object,
|
|
318
|
-
onSelect: _propTypes.default.func.isRequired,
|
|
319
|
-
choiceChanged: _propTypes.default.func.isRequired,
|
|
320
|
-
lengthChanged: _propTypes.default.func,
|
|
321
|
-
choiceRemoved: _propTypes.default.func.isRequired,
|
|
322
|
-
value: _propTypes.default.string,
|
|
323
|
-
maxLength: _propTypes.default.number,
|
|
324
|
-
showMaxLength: _propTypes.default.bool,
|
|
325
|
-
spellCheck: _propTypes.default.bool,
|
|
326
|
-
pluginProps: _propTypes.default.object
|
|
327
|
-
});
|
|
328
|
-
var _default = exports.default = AlternateSection;
|
|
329
|
-
//# sourceMappingURL=alternateSection.js.map
|