@pie-element/placement-ordering 12.3.4-next.0 → 13.0.0-beta.0

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.
@@ -1,494 +1,428 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
- exports["default"] = exports.Design = void 0;
9
-
7
+ exports.default = exports.Design = void 0;
10
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
-
12
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
-
14
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
-
16
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
-
18
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
19
-
20
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
-
22
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
-
24
- var _configUi = require("@pie-lib/config-ui");
25
-
26
- var _editableHtml = _interopRequireDefault(require("@pie-lib/editable-html"));
27
-
28
- var _styles = require("@material-ui/core/styles");
29
-
30
- var _drag = require("@pie-lib/drag");
31
-
32
- var _Info = _interopRequireDefault(require("@material-ui/icons/Info"));
33
-
34
- var _Tooltip = _interopRequireDefault(require("@material-ui/core/Tooltip"));
35
-
10
+ var _react = _interopRequireDefault(require("react"));
11
+ var _propTypes = _interopRequireDefault(require("prop-types"));
36
12
  var _debug = _interopRequireDefault(require("debug"));
37
-
38
13
  var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
39
-
40
14
  var _nestedProperty = require("nested-property");
41
-
42
- var _propTypes = _interopRequireDefault(require("prop-types"));
43
-
44
- var _react = _interopRequireDefault(require("react"));
45
-
46
15
  var _pluralize = _interopRequireDefault(require("pluralize"));
47
-
16
+ var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
17
+ var _styles = require("@mui/material/styles");
18
+ var _Info = _interopRequireDefault(require("@mui/icons-material/Info"));
19
+ var _Tooltip = _interopRequireDefault(require("@mui/material/Tooltip"));
20
+ var _configUi = require("@pie-lib/config-ui");
21
+ var _editableHtml = _interopRequireDefault(require("@pie-lib/editable-html"));
22
+ var _drag = require("@pie-lib/drag");
48
23
  var _choiceEditor = _interopRequireDefault(require("./choice-editor"));
49
-
50
24
  var _utils = require("./utils");
51
-
52
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
53
-
54
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
55
-
56
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
57
-
58
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
59
-
60
- var log = (0, _debug["default"])('@pie-element:placement-ordering:design');
61
- var Panel = _configUi.settings.Panel,
62
- toggle = _configUi.settings.toggle,
63
- radio = _configUi.settings.radio,
64
- dropdown = _configUi.settings.dropdown;
65
-
66
- var getSingularAndPlural = function getSingularAndPlural(label) {
67
- return !_pluralize["default"].isPlural(label) ? {
68
- singularLabel: label,
69
- pluralLabel: (0, _pluralize["default"])(label)
70
- } : {
71
- singularLabel: _pluralize["default"].singular(label),
72
- pluralLabel: label
73
- };
25
+ const log = (0, _debug.default)('@pie-element:placement-ordering:design');
26
+ const {
27
+ Panel,
28
+ toggle,
29
+ radio,
30
+ dropdown
31
+ } = _configUi.settings;
32
+ const getSingularAndPlural = label => !_pluralize.default.isPlural(label) ? {
33
+ singularLabel: label,
34
+ pluralLabel: (0, _pluralize.default)(label)
35
+ } : {
36
+ singularLabel: _pluralize.default.singular(label),
37
+ pluralLabel: label
74
38
  };
75
-
76
- var Design = /*#__PURE__*/function (_React$Component) {
77
- (0, _inherits2["default"])(Design, _React$Component);
78
-
79
- var _super = _createSuper(Design);
80
-
81
- function Design(props) {
82
- var _this;
83
-
84
- (0, _classCallCheck2["default"])(this, Design);
85
- _this = _super.call(this, props);
86
-
87
- _this.applyUpdate = function (modelFn) {
88
- var _this$props = _this.props,
89
- model = _this$props.model,
90
- onModelChanged = _this$props.onModelChanged;
91
- var update = modelFn((0, _cloneDeep["default"])(model));
39
+ const StyledInputContainer = (0, _styles.styled)(_configUi.InputContainer)(({
40
+ theme
41
+ }) => ({
42
+ width: '100%',
43
+ paddingTop: theme.spacing(2),
44
+ marginBottom: theme.spacing(2)
45
+ }));
46
+ const StyledRow = (0, _styles.styled)('div')({
47
+ display: 'grid',
48
+ gridAutoFlow: 'column',
49
+ gridAutoColumns: '1fr',
50
+ gridGap: '8px'
51
+ });
52
+ const StyledChoicesWrapper = (0, _styles.styled)(_configUi.FormSection)(({
53
+ theme
54
+ }) => ({
55
+ marginTop: 0,
56
+ marginBottom: theme.spacing(2.5)
57
+ }));
58
+ const InlineFlexContainer = (0, _styles.styled)('div')({
59
+ display: 'inline-flex',
60
+ position: 'absolute'
61
+ });
62
+ const ErrorText = (0, _styles.styled)('div')(({
63
+ theme
64
+ }) => ({
65
+ fontSize: theme.typography.fontSize - 2,
66
+ color: theme.palette.error.main,
67
+ paddingTop: theme.spacing(1)
68
+ }));
69
+ class Design extends _react.default.Component {
70
+ constructor(props) {
71
+ super(props);
72
+ (0, _defineProperty2.default)(this, "onDragEnd", (event, ordering) => {
73
+ const {
74
+ active,
75
+ over
76
+ } = event;
77
+ if (!over || !active) {
78
+ return;
79
+ }
80
+ const target = over.data.current;
81
+ const source = active.data.current;
82
+ const rawFrom = ordering.tiles.find(t => t.id === source.id && t.type === source.type);
83
+ const rawTo = target;
84
+ const from = {
85
+ ...rawFrom,
86
+ index: (0, _utils.normalizeIndex)(rawFrom, ordering)
87
+ };
88
+ const to = {
89
+ ...rawTo,
90
+ index: (0, _utils.normalizeIndex)(rawTo, ordering)
91
+ };
92
+ const {
93
+ response,
94
+ choices: updatedChoices
95
+ } = (0, _utils.updateResponseOrChoices)(ordering.response, ordering.choices, from, to);
96
+ this.onChoiceEditorChange(updatedChoices, response);
97
+ });
98
+ this.applyUpdate = modelFn => {
99
+ const {
100
+ model,
101
+ onModelChanged
102
+ } = this.props;
103
+ const update = modelFn((0, _cloneDeep.default)(model));
92
104
  onModelChanged(update);
93
105
  };
94
-
95
- _this.changeHandler = function (modelPath, valuePath) {
96
- return function (value) {
106
+ this.changeHandler = (modelPath, valuePath) => {
107
+ return value => {
97
108
  log('[changeHandler] value: ', value);
98
- var v = valuePath ? (0, _nestedProperty.get)(value, valuePath) : value;
99
-
100
- _this.applyUpdate(function (model) {
109
+ const v = valuePath ? (0, _nestedProperty.get)(value, valuePath) : value;
110
+ this.applyUpdate(model => {
101
111
  (0, _nestedProperty.set)(model, modelPath, v);
102
112
  return model;
103
113
  });
104
114
  };
105
115
  };
106
-
107
- _this.onPromptChange = _this.changeHandler('prompt');
108
- _this.onTeacherInstructionsChange = _this.changeHandler('teacherInstructions');
109
- _this.onRationaleChange = _this.changeHandler('rationale');
110
- _this.onChoiceAreaLabelChange = _this.changeHandler('choiceLabel', 'target.value');
111
- _this.onAnswerAreaLabelChange = _this.changeHandler('targetLabel', 'target.value');
112
- _this.onFeedbackChange = _this.changeHandler('feedback');
113
-
114
- _this.onChoiceEditorChange = function (choices, correctResponse) {
115
- var _this$props2 = _this.props,
116
- model = _this$props2.model,
117
- onModelChanged = _this$props2.onModelChanged;
118
- var update = (0, _cloneDeep["default"])(model);
116
+ this.onPromptChange = this.changeHandler('prompt');
117
+ this.onTeacherInstructionsChange = this.changeHandler('teacherInstructions');
118
+ this.onRationaleChange = this.changeHandler('rationale');
119
+ this.onChoiceAreaLabelChange = this.changeHandler('choiceLabel', 'target.value');
120
+ this.onAnswerAreaLabelChange = this.changeHandler('targetLabel', 'target.value');
121
+ this.onFeedbackChange = this.changeHandler('feedback');
122
+ this.onChoiceEditorChange = (choices, correctResponse) => {
123
+ const {
124
+ model,
125
+ onModelChanged
126
+ } = this.props;
127
+ const update = (0, _cloneDeep.default)(model);
119
128
  update.choices = choices;
120
129
  update.correctResponse = correctResponse;
121
130
  onModelChanged(update);
122
131
  };
123
-
124
- return _this;
125
132
  }
126
-
127
- (0, _createClass2["default"])(Design, [{
128
- key: "componentDidMount",
129
- value: function componentDidMount() {
130
- var _ref = this.props || {},
131
- model = _ref.model,
132
- onModelChanged = _ref.onModelChanged;
133
-
134
- var _ref2 = model || {},
135
- feedback = _ref2.feedback;
136
-
137
- var update = (0, _cloneDeep["default"])(model); // requirement made in PD-2182
138
-
139
- if (!feedback) {
140
- update.feedbackEnabled = false;
141
- onModelChanged(update);
142
- }
133
+ componentDidMount() {
134
+ const {
135
+ model,
136
+ onModelChanged
137
+ } = this.props || {};
138
+ const {
139
+ feedback
140
+ } = model || {};
141
+ const update = (0, _cloneDeep.default)(model);
142
+
143
+ // requirement made in PD-2182
144
+ if (!feedback) {
145
+ update.feedbackEnabled = false;
146
+ onModelChanged(update);
143
147
  }
144
- }, {
145
- key: "render",
146
- value: function render() {
147
- var _this$props3 = this.props,
148
- model = _this$props3.model,
149
- classes = _this$props3.classes,
150
- imageSupport = _this$props3.imageSupport,
151
- uploadSoundSupport = _this$props3.uploadSoundSupport,
152
- onModelChanged = _this$props3.onModelChanged,
153
- configuration = _this$props3.configuration,
154
- onConfigurationChanged = _this$props3.onConfigurationChanged;
155
-
156
- var _ref3 = configuration || {},
157
- _ref3$baseInputConfig = _ref3.baseInputConfiguration,
158
- baseInputConfiguration = _ref3$baseInputConfig === void 0 ? {} : _ref3$baseInputConfig,
159
- _ref3$choiceLabel = _ref3.choiceLabel,
160
- choiceLabel = _ref3$choiceLabel === void 0 ? {} : _ref3$choiceLabel,
161
- _ref3$choices = _ref3.choices,
162
- choices = _ref3$choices === void 0 ? {} : _ref3$choices,
163
- _ref3$contentDimensio = _ref3.contentDimensions,
164
- contentDimensions = _ref3$contentDimensio === void 0 ? {} : _ref3$contentDimensio,
165
- _ref3$feedback = _ref3.feedback,
166
- feedback = _ref3$feedback === void 0 ? {} : _ref3$feedback,
167
- _ref3$prompt = _ref3.prompt,
168
- prompt = _ref3$prompt === void 0 ? {} : _ref3$prompt,
169
- _ref3$placementArea = _ref3.placementArea,
170
- placementArea = _ref3$placementArea === void 0 ? {} : _ref3$placementArea,
171
- _ref3$maxImageWidth = _ref3.maxImageWidth,
172
- maxImageWidth = _ref3$maxImageWidth === void 0 ? {} : _ref3$maxImageWidth,
173
- _ref3$maxImageHeight = _ref3.maxImageHeight,
174
- maxImageHeight = _ref3$maxImageHeight === void 0 ? {} : _ref3$maxImageHeight,
175
- _ref3$numberedGuides = _ref3.numberedGuides,
176
- numberedGuides = _ref3$numberedGuides === void 0 ? {} : _ref3$numberedGuides,
177
- _ref3$orientation = _ref3.orientation,
178
- orientation = _ref3$orientation === void 0 ? {} : _ref3$orientation,
179
- _ref3$partialScoring = _ref3.partialScoring,
180
- partialScoring = _ref3$partialScoring === void 0 ? {} : _ref3$partialScoring,
181
- _ref3$rationale = _ref3.rationale,
182
- rationale = _ref3$rationale === void 0 ? {} : _ref3$rationale,
183
- _ref3$removeTilesAfte = _ref3.removeTilesAfterPlacing,
184
- removeTilesAfterPlacing = _ref3$removeTilesAfte === void 0 ? {} : _ref3$removeTilesAfte,
185
- settingsPanelDisabled = _ref3.settingsPanelDisabled,
186
- _ref3$studentInstruct = _ref3.studentInstructions,
187
- studentInstructions = _ref3$studentInstruct === void 0 ? {} : _ref3$studentInstruct,
188
- _ref3$spellCheck = _ref3.spellCheck,
189
- spellCheck = _ref3$spellCheck === void 0 ? {} : _ref3$spellCheck,
190
- _ref3$scoringType = _ref3.scoringType,
191
- scoringType = _ref3$scoringType === void 0 ? {} : _ref3$scoringType,
192
- _ref3$targetLabel = _ref3.targetLabel,
193
- targetLabel = _ref3$targetLabel === void 0 ? {} : _ref3$targetLabel,
194
- _ref3$teacherInstruct = _ref3.teacherInstructions,
195
- teacherInstructions = _ref3$teacherInstruct === void 0 ? {} : _ref3$teacherInstruct,
196
- _ref3$withRubric = _ref3.withRubric,
197
- withRubric = _ref3$withRubric === void 0 ? {} : _ref3$withRubric,
198
- _ref3$mathMlOptions = _ref3.mathMlOptions,
199
- mathMlOptions = _ref3$mathMlOptions === void 0 ? {} : _ref3$mathMlOptions,
200
- _ref3$language = _ref3.language,
201
- language = _ref3$language === void 0 ? {} : _ref3$language,
202
- _ref3$languageChoices = _ref3.languageChoices,
203
- languageChoices = _ref3$languageChoices === void 0 ? {} : _ref3$languageChoices;
204
-
205
- var _ref4 = model || {},
206
- choiceLabelEnabled = _ref4.choiceLabelEnabled,
207
- errors = _ref4.errors,
208
- extraCSSRules = _ref4.extraCSSRules,
209
- feedbackEnabled = _ref4.feedbackEnabled,
210
- promptEnabled = _ref4.promptEnabled,
211
- rationaleEnabled = _ref4.rationaleEnabled,
212
- spellCheckEnabled = _ref4.spellCheckEnabled,
213
- teacherInstructionsEnabled = _ref4.teacherInstructionsEnabled,
214
- toolbarEditorPosition = _ref4.toolbarEditorPosition;
215
-
216
- var _ref5 = errors || {},
217
- promptError = _ref5.prompt,
218
- rationaleError = _ref5.rationale,
219
- teacherInstructionsError = _ref5.teacherInstructions;
220
-
221
- var validationMessage = (0, _utils.generateValidationMessage)();
222
-
223
- var _ref6 = (choices === null || choices === void 0 ? void 0 : choices.label) && getSingularAndPlural(choices.label) || {},
224
- _ref6$singularLabel = _ref6.singularLabel,
225
- singularLabel = _ref6$singularLabel === void 0 ? '' : _ref6$singularLabel,
226
- _ref6$pluralLabel = _ref6.pluralLabel,
227
- pluralLabel = _ref6$pluralLabel === void 0 ? '' : _ref6$pluralLabel;
228
-
229
- var defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
230
- var defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
231
- var maxChoicesImageWidth = maxImageWidth && model.placementArea ? maxImageWidth.choicesWithPlacementArea : maxImageWidth.choicesWithoutPlacementArea || defaultImageMaxWidth;
232
- var maxChoicesImageHeight = maxImageHeight && maxImageHeight.choices || defaultImageMaxHeight;
233
- var toolbarOpts = {
234
- position: toolbarEditorPosition === 'top' ? 'top' : 'bottom'
235
- };
236
- var panelSettings = {
237
- choiceLabelEnabled: choiceLabel.settings && toggle(choiceLabel.label),
238
- placementArea: placementArea.settings && toggle(placementArea.label),
239
- numberedGuides: numberedGuides.settings && model.placementArea && toggle(numberedGuides.label),
240
- orientation: orientation.settings && radio(orientation.label, ['vertical', 'horizontal']),
241
- removeTilesAfterPlacing: removeTilesAfterPlacing.settings && toggle(removeTilesAfterPlacing.label),
242
- partialScoring: partialScoring.settings && toggle(partialScoring.label),
243
- feedbackEnabled: feedback.settings && toggle(feedback.label),
244
- 'language.enabled': language.settings && toggle(language.label, true),
245
- language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options)
246
- };
247
- var panelProperties = {
248
- teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
249
- studentInstructionsEnabled: studentInstructions.settings && toggle(studentInstructions.label),
250
- rationaleEnabled: rationale.settings && toggle(rationale.label),
251
- promptEnabled: prompt.settings && toggle(prompt.label),
252
- spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
253
- scoringType: scoringType.settings && radio(scoringType.label, ['auto', 'rubric']),
254
- rubricEnabled: (withRubric === null || withRubric === void 0 ? void 0 : withRubric.settings) && toggle(withRubric === null || withRubric === void 0 ? void 0 : withRubric.label)
255
- };
256
-
257
- var getPluginProps = function getPluginProps() {
258
- var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
259
- return _objectSpread(_objectSpread({}, baseInputConfiguration), props);
260
- };
261
-
262
- return /*#__PURE__*/_react["default"].createElement(_configUi.layout.ConfigLayout, {
263
- extraCSSRules: extraCSSRules,
264
- dimensions: contentDimensions,
265
- hideSettings: settingsPanelDisabled,
266
- settings: /*#__PURE__*/_react["default"].createElement(Panel, {
267
- model: model,
268
- configuration: configuration,
269
- onChangeModel: function onChangeModel(model) {
270
- return onModelChanged(model);
271
- },
272
- onChangeConfiguration: function onChangeConfiguration(configuration) {
273
- return onConfigurationChanged(configuration, true);
274
- },
275
- groups: {
276
- Settings: panelSettings,
277
- Properties: panelProperties
278
- }
279
- })
280
- }, teacherInstructionsEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
281
- label: teacherInstructions.label,
282
- className: classes.promptHolder
283
- }, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
284
- className: classes.prompt,
285
- markup: model.teacherInstructions || '',
286
- onChange: this.onTeacherInstructionsChange,
287
- imageSupport: imageSupport,
288
- nonEmpty: false,
289
- error: teacherInstructionsError,
290
- toolbarOpts: toolbarOpts,
291
- pluginProps: getPluginProps(teacherInstructions === null || teacherInstructions === void 0 ? void 0 : teacherInstructions.inputConfiguration),
292
- spellCheck: spellCheckEnabled,
293
- maxImageWidth: maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth,
294
- maxImageHeight: maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight,
295
- uploadSoundSupport: uploadSoundSupport,
296
- languageCharactersProps: [{
297
- language: 'spanish'
298
- }, {
299
- language: 'special'
300
- }],
301
- mathMlOptions: mathMlOptions
302
- }), teacherInstructionsError && /*#__PURE__*/_react["default"].createElement("div", {
303
- className: classes.errorText
304
- }, teacherInstructionsError)), promptEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
305
- label: prompt && prompt.label,
306
- className: classes.promptHolder
307
- }, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
308
- className: classes.prompt,
309
- markup: model.prompt,
310
- onChange: this.onPromptChange,
311
- imageSupport: imageSupport,
312
- error: promptError,
313
- toolbarOpts: toolbarOpts,
314
- pluginProps: getPluginProps(prompt === null || prompt === void 0 ? void 0 : prompt.inputConfiguration),
315
- spellCheck: spellCheckEnabled,
316
- maxImageWidth: maxImageWidth && maxImageWidth.prompt,
317
- maxImageHeight: maxImageHeight && maxImageHeight.prompt,
318
- uploadSoundSupport: uploadSoundSupport,
319
- languageCharactersProps: [{
320
- language: 'spanish'
321
- }, {
322
- language: 'special'
323
- }],
324
- mathMlOptions: mathMlOptions
325
- }), promptError && /*#__PURE__*/_react["default"].createElement("div", {
326
- className: classes.errorText
327
- }, promptError)), /*#__PURE__*/_react["default"].createElement(_configUi.FormSection, {
328
- className: classes.choicesWrapper,
329
- label: "Define ".concat(pluralLabel),
330
- labelExtraStyle: {
331
- display: 'inline-flex'
148
+ }
149
+ render() {
150
+ const {
151
+ model,
152
+ imageSupport,
153
+ uploadSoundSupport,
154
+ onModelChanged,
155
+ configuration,
156
+ onConfigurationChanged
157
+ } = this.props;
158
+ const {
159
+ baseInputConfiguration = {},
160
+ choiceLabel = {},
161
+ choices = {},
162
+ contentDimensions = {},
163
+ feedback = {},
164
+ prompt = {},
165
+ placementArea = {},
166
+ maxImageWidth = {},
167
+ maxImageHeight = {},
168
+ numberedGuides = {},
169
+ orientation = {},
170
+ partialScoring = {},
171
+ rationale = {},
172
+ removeTilesAfterPlacing = {},
173
+ settingsPanelDisabled,
174
+ studentInstructions = {},
175
+ spellCheck = {},
176
+ scoringType = {},
177
+ targetLabel = {},
178
+ teacherInstructions = {},
179
+ withRubric = {},
180
+ mathMlOptions = {},
181
+ language = {},
182
+ languageChoices = {}
183
+ } = configuration || {};
184
+ const {
185
+ choiceLabelEnabled,
186
+ errors,
187
+ extraCSSRules,
188
+ feedbackEnabled,
189
+ promptEnabled,
190
+ rationaleEnabled,
191
+ spellCheckEnabled,
192
+ teacherInstructionsEnabled,
193
+ toolbarEditorPosition,
194
+ correctResponse
195
+ } = model || {};
196
+ const {
197
+ prompt: promptError,
198
+ rationale: rationaleError,
199
+ teacherInstructions: teacherInstructionsError
200
+ } = errors || {};
201
+ const ordering = {
202
+ choices: model.choices,
203
+ response: !correctResponse || (0, _isEmpty.default)(correctResponse) ? new Array(model.choices.length) : correctResponse,
204
+ tiles: (0, _utils.buildTiles)(model.choices, correctResponse)
205
+ };
206
+ const validationMessage = (0, _utils.generateValidationMessage)();
207
+ const {
208
+ singularLabel = '',
209
+ pluralLabel = ''
210
+ } = choices?.label && getSingularAndPlural(choices.label) || {};
211
+ const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
212
+ const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
213
+ const maxChoicesImageWidth = maxImageWidth && model.placementArea ? maxImageWidth.choicesWithPlacementArea : maxImageWidth.choicesWithoutPlacementArea || defaultImageMaxWidth;
214
+ const maxChoicesImageHeight = maxImageHeight && maxImageHeight.choices || defaultImageMaxHeight;
215
+ const toolbarOpts = {
216
+ position: toolbarEditorPosition === 'top' ? 'top' : 'bottom'
217
+ };
218
+ const panelSettings = {
219
+ choiceLabelEnabled: choiceLabel.settings && toggle(choiceLabel.label),
220
+ placementArea: placementArea.settings && toggle(placementArea.label),
221
+ numberedGuides: numberedGuides.settings && model.placementArea && toggle(numberedGuides.label),
222
+ orientation: orientation.settings && radio(orientation.label, ['vertical', 'horizontal']),
223
+ removeTilesAfterPlacing: removeTilesAfterPlacing.settings && toggle(removeTilesAfterPlacing.label),
224
+ partialScoring: partialScoring.settings && toggle(partialScoring.label),
225
+ feedbackEnabled: feedback.settings && toggle(feedback.label),
226
+ 'language.enabled': language.settings && toggle(language.label, true),
227
+ language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options)
228
+ };
229
+ const panelProperties = {
230
+ teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
231
+ studentInstructionsEnabled: studentInstructions.settings && toggle(studentInstructions.label),
232
+ rationaleEnabled: rationale.settings && toggle(rationale.label),
233
+ promptEnabled: prompt.settings && toggle(prompt.label),
234
+ spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
235
+ scoringType: scoringType.settings && radio(scoringType.label, ['auto', 'rubric']),
236
+ rubricEnabled: withRubric?.settings && toggle(withRubric?.label)
237
+ };
238
+ const getPluginProps = (props = {}) => ({
239
+ ...baseInputConfiguration,
240
+ ...props
241
+ });
242
+ return /*#__PURE__*/_react.default.createElement(_drag.DragProvider, {
243
+ onDragEnd: event => this.onDragEnd(event, ordering)
244
+ }, /*#__PURE__*/_react.default.createElement(_configUi.layout.ConfigLayout, {
245
+ extraCSSRules: extraCSSRules,
246
+ dimensions: contentDimensions,
247
+ hideSettings: settingsPanelDisabled,
248
+ settings: /*#__PURE__*/_react.default.createElement(Panel, {
249
+ model: model,
250
+ configuration: configuration,
251
+ onChangeModel: model => onModelChanged(model),
252
+ onChangeConfiguration: configuration => onConfigurationChanged(configuration, true),
253
+ groups: {
254
+ Settings: panelSettings,
255
+ Properties: panelProperties
332
256
  }
333
- }, /*#__PURE__*/_react["default"].createElement("div", {
334
- className: classes.inlineFlexContainer
335
- }, /*#__PURE__*/_react["default"].createElement(_Tooltip["default"], {
336
- classes: {
337
- tooltip: classes.tooltip
338
- },
339
- disableFocusListener: true,
340
- disableTouchListener: true,
341
- placement: 'right',
342
- title: validationMessage
343
- }, /*#__PURE__*/_react["default"].createElement(_Info["default"], {
344
- fontSize: 'small',
345
- color: 'primary',
346
- style: {
347
- marginLeft: '8px'
257
+ })
258
+ }, teacherInstructionsEnabled && /*#__PURE__*/_react.default.createElement(StyledInputContainer, {
259
+ label: teacherInstructions.label
260
+ }, /*#__PURE__*/_react.default.createElement(_editableHtml.default, {
261
+ className: "prompt",
262
+ markup: model.teacherInstructions || '',
263
+ onChange: this.onTeacherInstructionsChange,
264
+ imageSupport: imageSupport,
265
+ nonEmpty: false,
266
+ error: teacherInstructionsError,
267
+ toolbarOpts: toolbarOpts,
268
+ pluginProps: getPluginProps(teacherInstructions?.inputConfiguration),
269
+ spellCheck: spellCheckEnabled,
270
+ maxImageWidth: maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth,
271
+ maxImageHeight: maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight,
272
+ uploadSoundSupport: uploadSoundSupport,
273
+ languageCharactersProps: [{
274
+ language: 'spanish'
275
+ }, {
276
+ language: 'special'
277
+ }],
278
+ mathMlOptions: mathMlOptions
279
+ }), teacherInstructionsError && /*#__PURE__*/_react.default.createElement("div", {
280
+ className: "errorText"
281
+ }, teacherInstructionsError)), promptEnabled && /*#__PURE__*/_react.default.createElement(StyledInputContainer, {
282
+ label: prompt && prompt.label
283
+ }, /*#__PURE__*/_react.default.createElement(_editableHtml.default, {
284
+ className: "prompt",
285
+ markup: model.prompt,
286
+ onChange: this.onPromptChange,
287
+ imageSupport: imageSupport,
288
+ error: promptError,
289
+ toolbarOpts: toolbarOpts,
290
+ pluginProps: getPluginProps(prompt?.inputConfiguration),
291
+ spellCheck: spellCheckEnabled,
292
+ maxImageWidth: maxImageWidth && maxImageWidth.prompt,
293
+ maxImageHeight: maxImageHeight && maxImageHeight.prompt,
294
+ uploadSoundSupport: uploadSoundSupport,
295
+ languageCharactersProps: [{
296
+ language: 'spanish'
297
+ }, {
298
+ language: 'special'
299
+ }],
300
+ mathMlOptions: mathMlOptions
301
+ }), promptError && /*#__PURE__*/_react.default.createElement("div", {
302
+ className: "errorText"
303
+ }, promptError)), /*#__PURE__*/_react.default.createElement(StyledChoicesWrapper, {
304
+ label: `Define ${pluralLabel}`,
305
+ labelExtraStyle: {
306
+ display: 'inline-flex'
307
+ }
308
+ }, /*#__PURE__*/_react.default.createElement(InlineFlexContainer, null, /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
309
+ slotProps: {
310
+ tooltip: {
311
+ sx: {
312
+ fontSize: 14,
313
+ whiteSpace: 'pre',
314
+ maxWidth: '500px'
315
+ }
348
316
  }
349
- }))), /*#__PURE__*/_react["default"].createElement("div", {
350
- className: classes.row
351
- }, choiceLabelEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
352
- label: choiceLabel && choiceLabel.label && "".concat(singularLabel, " label"),
353
- className: classes.promptHolder
354
- }, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], (0, _extends2["default"])({}, model.placementArea && {
355
- autoWidthToolbar: true
317
+ },
318
+ disableFocusListener: true,
319
+ disableTouchListener: true,
320
+ placement: 'right',
321
+ title: validationMessage
322
+ }, /*#__PURE__*/_react.default.createElement(_Info.default, {
323
+ fontSize: 'small',
324
+ color: 'primary',
325
+ style: {
326
+ marginLeft: '8px'
327
+ }
328
+ }))), /*#__PURE__*/_react.default.createElement(StyledRow, null, choiceLabelEnabled && /*#__PURE__*/_react.default.createElement(StyledInputContainer, {
329
+ label: choiceLabel && choiceLabel.label && `${singularLabel} label`
330
+ }, /*#__PURE__*/_react.default.createElement(_editableHtml.default, (0, _extends2.default)({}, model.placementArea && {
331
+ autoWidthToolbar: true
332
+ }, {
333
+ className: "prompt",
334
+ markup: model.choiceLabel,
335
+ onChange: this.onChoiceAreaLabelChange,
336
+ toolbarOpts: toolbarOpts,
337
+ pluginProps: getPluginProps(choiceLabel?.inputConfiguration),
338
+ spellCheck: spellCheckEnabled,
339
+ maxImageWidth: maxChoicesImageWidth,
340
+ maxImageHeight: maxChoicesImageHeight,
341
+ uploadSoundSupport: uploadSoundSupport,
342
+ languageCharactersProps: [{
343
+ language: 'spanish'
356
344
  }, {
357
- className: classes.prompt,
358
- markup: model.choiceLabel,
359
- onChange: this.onChoiceAreaLabelChange,
360
- toolbarOpts: toolbarOpts,
361
- pluginProps: getPluginProps(choiceLabel === null || choiceLabel === void 0 ? void 0 : choiceLabel.inputConfiguration),
362
- spellCheck: spellCheckEnabled,
363
- maxImageWidth: maxChoicesImageWidth,
364
- maxImageHeight: maxChoicesImageHeight,
365
- uploadSoundSupport: uploadSoundSupport,
366
- languageCharactersProps: [{
367
- language: 'spanish'
368
- }, {
369
- language: 'special'
370
- }],
371
- mathMlOptions: mathMlOptions
372
- }))), targetLabel.settings && model.placementArea && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
373
- label: targetLabel && targetLabel.label && targetLabel.label,
374
- className: classes.promptHolder
375
- }, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
376
- autoWidthToolbar: true,
377
- className: classes.prompt,
378
- markup: model.targetLabel,
379
- onChange: this.onAnswerAreaLabelChange,
380
- toolbarOpts: toolbarOpts,
381
- spellCheck: spellCheckEnabled,
382
- maxImageWidth: maxImageWidth && maxImageWidth.choicesWithPlacementArea || defaultImageMaxWidth,
383
- maxImageHeight: maxChoicesImageHeight,
384
- uploadSoundSupport: uploadSoundSupport,
385
- languageCharactersProps: [{
386
- language: 'spanish'
387
- }, {
388
- language: 'special'
389
- }],
390
- mathMlOptions: mathMlOptions
391
- }))), choices.settings && /*#__PURE__*/_react["default"].createElement(_choiceEditor["default"], {
392
- correctResponse: model.correctResponse,
393
- choices: model.choices,
394
- onChange: this.onChoiceEditorChange,
395
- imageSupport: imageSupport,
396
- toolbarOpts: toolbarOpts,
397
- pluginProps: getPluginProps(choices === null || choices === void 0 ? void 0 : choices.inputConfiguration),
398
- choicesLabel: choices.label,
399
- placementArea: model.placementArea,
400
- singularChoiceLabel: singularLabel,
401
- pluralChoiceLabel: pluralLabel,
402
- spellCheck: spellCheckEnabled,
403
- maxImageWidth: maxChoicesImageWidth,
404
- maxImageHeight: maxChoicesImageHeight,
405
- errors: errors || {},
406
- mathMlOptions: mathMlOptions
407
- })), rationaleEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
408
- label: rationale.label,
409
- className: classes.promptHolder
410
- }, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
411
- className: classes.prompt,
412
- markup: model.rationale || '',
413
- onChange: this.onRationaleChange,
414
- imageSupport: imageSupport,
415
- error: rationaleError,
416
- toolbarOpts: toolbarOpts,
417
- pluginProps: getPluginProps(rationale === null || rationale === void 0 ? void 0 : rationale.inputConfiguration),
418
- spellCheck: spellCheckEnabled,
419
- maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
420
- maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight,
421
- uploadSoundSupport: uploadSoundSupport,
422
- languageCharactersProps: [{
423
- language: 'spanish'
424
- }, {
425
- language: 'special'
426
- }],
427
- mathMlOptions: mathMlOptions
428
- }), rationaleError && /*#__PURE__*/_react["default"].createElement("div", {
429
- className: classes.errorText
430
- }, rationaleError)), feedbackEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.FeedbackConfig, {
431
- feedback: model.feedback,
432
- onChange: this.onFeedbackChange,
433
- imageSupport: imageSupport,
434
- toolbarOpts: toolbarOpts
435
- }));
436
- }
437
- }]);
438
- return Design;
439
- }(_react["default"].Component);
440
-
345
+ language: 'special'
346
+ }],
347
+ mathMlOptions: mathMlOptions
348
+ }))), targetLabel.settings && model.placementArea && /*#__PURE__*/_react.default.createElement(StyledInputContainer, {
349
+ label: targetLabel && targetLabel.label && targetLabel.label
350
+ }, /*#__PURE__*/_react.default.createElement(_editableHtml.default, {
351
+ autoWidthToolbar: true,
352
+ className: "prompt",
353
+ markup: model.targetLabel,
354
+ onChange: this.onAnswerAreaLabelChange,
355
+ toolbarOpts: toolbarOpts,
356
+ spellCheck: spellCheckEnabled,
357
+ maxImageWidth: maxImageWidth && maxImageWidth.choicesWithPlacementArea || defaultImageMaxWidth,
358
+ maxImageHeight: maxChoicesImageHeight,
359
+ uploadSoundSupport: uploadSoundSupport,
360
+ languageCharactersProps: [{
361
+ language: 'spanish'
362
+ }, {
363
+ language: 'special'
364
+ }],
365
+ mathMlOptions: mathMlOptions
366
+ }))), choices.settings && /*#__PURE__*/_react.default.createElement(_choiceEditor.default, {
367
+ correctResponse: correctResponse,
368
+ choices: model.choices,
369
+ onChange: this.onChoiceEditorChange,
370
+ imageSupport: imageSupport,
371
+ toolbarOpts: toolbarOpts,
372
+ pluginProps: getPluginProps(choices?.inputConfiguration),
373
+ choicesLabel: choices.label,
374
+ placementArea: model.placementArea,
375
+ singularChoiceLabel: singularLabel,
376
+ pluralChoiceLabel: pluralLabel,
377
+ spellCheck: spellCheckEnabled,
378
+ maxImageWidth: maxChoicesImageWidth,
379
+ maxImageHeight: maxChoicesImageHeight,
380
+ errors: errors || {},
381
+ mathMlOptions: mathMlOptions,
382
+ ordering: ordering
383
+ })), rationaleEnabled && /*#__PURE__*/_react.default.createElement(StyledInputContainer, {
384
+ label: rationale.label
385
+ }, /*#__PURE__*/_react.default.createElement(_editableHtml.default, {
386
+ className: "prompt",
387
+ markup: model.rationale || '',
388
+ onChange: this.onRationaleChange,
389
+ imageSupport: imageSupport,
390
+ error: rationaleError,
391
+ toolbarOpts: toolbarOpts,
392
+ pluginProps: getPluginProps(rationale?.inputConfiguration),
393
+ spellCheck: spellCheckEnabled,
394
+ maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
395
+ maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight,
396
+ uploadSoundSupport: uploadSoundSupport,
397
+ languageCharactersProps: [{
398
+ language: 'spanish'
399
+ }, {
400
+ language: 'special'
401
+ }],
402
+ mathMlOptions: mathMlOptions
403
+ }), rationaleError && /*#__PURE__*/_react.default.createElement(ErrorText, null, rationaleError)), feedbackEnabled && /*#__PURE__*/_react.default.createElement(_configUi.FeedbackConfig, {
404
+ feedback: model.feedback,
405
+ onChange: this.onFeedbackChange,
406
+ imageSupport: imageSupport,
407
+ toolbarOpts: toolbarOpts
408
+ })));
409
+ }
410
+ }
441
411
  exports.Design = Design;
442
- (0, _defineProperty2["default"])(Design, "propTypes", {
443
- uploadSoundSupport: _propTypes["default"].object
412
+ (0, _defineProperty2.default)(Design, "propTypes", {
413
+ uploadSoundSupport: _propTypes.default.object
444
414
  });
445
- (0, _defineProperty2["default"])(Design, "defaultProps", {});
415
+ (0, _defineProperty2.default)(Design, "defaultProps", {});
446
416
  Design.defaultProps = {
447
- onModelChanged: function onModelChanged() {},
448
- onConfigurationChanged: function onConfigurationChanged() {}
417
+ onModelChanged: () => {},
418
+ onConfigurationChanged: () => {}
449
419
  };
450
420
  Design.propTypes = {
451
- model: _propTypes["default"].object.isRequired,
452
- configuration: _propTypes["default"].object.isRequired,
453
- onModelChanged: _propTypes["default"].func,
454
- onConfigurationChanged: _propTypes["default"].func,
455
- classes: _propTypes["default"].object.isRequired,
456
- imageSupport: _propTypes["default"].object
421
+ model: _propTypes.default.object.isRequired,
422
+ configuration: _propTypes.default.object.isRequired,
423
+ onModelChanged: _propTypes.default.func,
424
+ onConfigurationChanged: _propTypes.default.func,
425
+ imageSupport: _propTypes.default.object
457
426
  };
458
-
459
- var _default = (0, _drag.withDragContext)((0, _styles.withStyles)(function (theme) {
460
- return {
461
- promptHolder: {
462
- width: '100%',
463
- paddingTop: theme.spacing.unit * 2,
464
- marginBottom: theme.spacing.unit * 2
465
- },
466
- row: {
467
- display: 'grid',
468
- gridAutoFlow: 'column',
469
- gridAutoColumns: '1fr',
470
- gridGap: '8px'
471
- },
472
- choicesWrapper: {
473
- marginTop: 0,
474
- marginBottom: theme.spacing.unit * 2.5
475
- },
476
- tooltip: {
477
- fontSize: theme.typography.fontSize - 2,
478
- whiteSpace: 'pre',
479
- maxWidth: '500px'
480
- },
481
- inlineFlexContainer: {
482
- display: 'inline-flex',
483
- position: 'absolute'
484
- },
485
- errorText: {
486
- fontSize: theme.typography.fontSize - 2,
487
- color: theme.palette.error.main,
488
- paddingTop: theme.spacing.unit
489
- }
490
- };
491
- })(Design));
492
-
493
- exports["default"] = _default;
427
+ var _default = exports.default = Design;
494
428
  //# sourceMappingURL=design.js.map