@pie-element/select-text 11.3.4-next.0 → 12.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,507 +1,407 @@
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
-
10
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
-
12
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
-
14
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
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
-
7
+ exports.default = exports.Design = void 0;
22
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
-
24
9
  var _react = _interopRequireDefault(require("react"));
25
-
26
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
27
-
28
- var _TextField = _interopRequireDefault(require("@material-ui/core/TextField"));
29
-
30
- var _styles = require("@material-ui/core/styles");
31
-
11
+ var _TextField = _interopRequireDefault(require("@mui/material/TextField"));
12
+ var _styles = require("@mui/material/styles");
32
13
  var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
33
-
34
14
  var _debounce = _interopRequireDefault(require("lodash/debounce"));
35
-
36
15
  var _textSelect = require("@pie-lib/text-select");
37
-
38
16
  var _configUi = require("@pie-lib/config-ui");
39
-
40
- var _Chip = _interopRequireDefault(require("@material-ui/core/Chip"));
41
-
42
- var _Info = _interopRequireDefault(require("@material-ui/icons/Info"));
43
-
17
+ var _Chip = _interopRequireDefault(require("@mui/material/Chip"));
18
+ var _Info = _interopRequireDefault(require("@mui/icons-material/Info"));
44
19
  var _debug = _interopRequireDefault(require("debug"));
45
-
46
20
  var _editableHtml = _interopRequireDefault(require("@pie-lib/editable-html"));
47
-
48
- var _Tooltip = _interopRequireDefault(require("@material-ui/core/Tooltip"));
49
-
21
+ var _Tooltip = _interopRequireDefault(require("@mui/material/Tooltip"));
50
22
  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 Panel = _configUi.settings.Panel,
61
- toggle = _configUi.settings.toggle,
62
- radio = _configUi.settings.radio,
63
- dropdown = _configUi.settings.dropdown;
64
- var log = (0, _debug["default"])('@pie-element:select-text:configure');
65
-
66
- var Design = /*#__PURE__*/function (_React$Component) {
67
- (0, _inherits2["default"])(Design, _React$Component);
68
-
69
- var _super = _createSuper(Design);
70
-
71
- function Design(props) {
72
- var _this;
73
-
74
- (0, _classCallCheck2["default"])(this, Design);
75
- _this = _super.call(this, props);
76
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "updateText", (0, _debounce["default"])(function (val) {
77
- _this.apply(function (u) {
23
+ const {
24
+ Panel,
25
+ toggle,
26
+ radio,
27
+ dropdown
28
+ } = _configUi.settings;
29
+ const StyledInputContainer = (0, _styles.styled)(_configUi.InputContainer)(({
30
+ theme
31
+ }) => ({
32
+ width: '100%',
33
+ paddingTop: theme.spacing(2),
34
+ marginBottom: theme.spacing(2)
35
+ }));
36
+ const StyledEditableHtml = (0, _styles.styled)(_editableHtml.default)({
37
+ width: '100%'
38
+ });
39
+ const ErrorText = (0, _styles.styled)('div')(({
40
+ theme
41
+ }) => ({
42
+ fontSize: theme.typography.fontSize - 2,
43
+ color: theme.palette.error.main,
44
+ paddingTop: theme.spacing(1)
45
+ }));
46
+ const StyledTextField = (0, _styles.styled)(_TextField.default)({
47
+ width: '100%'
48
+ });
49
+ const TokenizerContainer = (0, _styles.styled)(_configUi.InputContainer)(({
50
+ theme
51
+ }) => ({
52
+ paddingRight: 0,
53
+ marginRight: 0,
54
+ position: 'relative',
55
+ '&:after': {
56
+ position: 'absolute',
57
+ bottom: 0,
58
+ left: 0,
59
+ right: 0,
60
+ height: '1px',
61
+ content: '""',
62
+ backgroundColor: theme.palette.primary.main
63
+ },
64
+ marginBottom: theme.spacing(1)
65
+ }));
66
+ const StyledTooltip = (0, _styles.styled)(_Tooltip.default)(({
67
+ theme
68
+ }) => ({
69
+ '& .MuiTooltip-tooltip': {
70
+ fontSize: theme.typography.fontSize - 2,
71
+ whiteSpace: 'pre',
72
+ maxWidth: '500px'
73
+ }
74
+ }));
75
+ const StyledTokenizer = (0, _styles.styled)(_textSelect.Tokenizer)(({
76
+ theme
77
+ }) => ({
78
+ marginTop: theme.spacing(2)
79
+ }));
80
+ const StyledChip = (0, _styles.styled)(_Chip.default)(({
81
+ theme
82
+ }) => ({
83
+ marginTop: theme.spacing(0.5),
84
+ marginRight: theme.spacing(2)
85
+ }));
86
+ const TokensDetails = (0, _styles.styled)('div')(({
87
+ theme
88
+ }) => ({
89
+ display: 'flex',
90
+ alignItems: 'center',
91
+ flexWrap: 'wrap',
92
+ marginBottom: theme.spacing(2.5)
93
+ }));
94
+ const StyledNumberTextField = (0, _styles.styled)(_configUi.NumberTextField)(({
95
+ theme
96
+ }) => ({
97
+ width: '180px',
98
+ margin: `${theme.spacing(0.5)}px auto 0`
99
+ }));
100
+ const log = (0, _debug.default)('@pie-element:select-text:configure');
101
+ class Design extends _react.default.Component {
102
+ constructor(props) {
103
+ super(props);
104
+ (0, _defineProperty2.default)(this, "updateText", (0, _debounce.default)(val => {
105
+ this.apply(u => {
78
106
  u.text = val;
79
107
  u.tokens = [];
80
108
  });
81
109
  }, 200));
82
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeText", function (event) {
83
- return _this.updateText(event.target.value);
84
- });
85
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeTokens", function (tokens, mode) {
86
- _this.apply(function (u) {
110
+ (0, _defineProperty2.default)(this, "changeText", event => this.updateText(event.target.value));
111
+ (0, _defineProperty2.default)(this, "changeTokens", (tokens, mode) => {
112
+ this.apply(u => {
87
113
  u.tokens = tokens;
88
114
  u.mode = mode;
89
- var correctTokenCount = tokens.filter(function (t) {
90
- return t.correct;
91
- }).length;
92
- var max = isFinite(u.maxSelections) ? u.maxSelections : 0;
115
+ const correctTokenCount = tokens.filter(t => t.correct).length;
116
+ const max = isFinite(u.maxSelections) ? u.maxSelections : 0;
93
117
  u.maxSelections = Math.max(max, correctTokenCount);
94
118
  });
95
119
  });
96
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeMaxSelections", function (event, max) {
97
- _this.apply(function (u) {
98
- return u.maxSelections = max;
99
- });
120
+ (0, _defineProperty2.default)(this, "changeMaxSelections", (event, max) => {
121
+ this.apply(u => u.maxSelections = max);
100
122
  });
101
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "apply", function (fn) {
102
- var _this$props = _this.props,
103
- onModelChanged = _this$props.onModelChanged,
104
- model = _this$props.model;
105
- var update = (0, _cloneDeep["default"])(model);
123
+ (0, _defineProperty2.default)(this, "apply", fn => {
124
+ const {
125
+ onModelChanged,
126
+ model
127
+ } = this.props;
128
+ const update = (0, _cloneDeep.default)(model);
106
129
  fn(update);
107
130
  onModelChanged(update);
108
131
  });
109
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeFeedback", function (feedback) {
110
- _this.apply(function (u) {
111
- return u.feedback = feedback;
112
- });
132
+ (0, _defineProperty2.default)(this, "changeFeedback", feedback => {
133
+ this.apply(u => u.feedback = feedback);
113
134
  });
114
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changePartialScoring", function (partialScoring) {
115
- var _this$props2 = _this.props,
116
- onModelChanged = _this$props2.onModelChanged,
117
- model = _this$props2.model;
118
- var update = (0, _cloneDeep["default"])(model);
135
+ (0, _defineProperty2.default)(this, "changePartialScoring", partialScoring => {
136
+ const {
137
+ onModelChanged,
138
+ model
139
+ } = this.props;
140
+ const update = (0, _cloneDeep.default)(model);
119
141
  update.partialScoring = partialScoring;
120
142
  onModelChanged(update);
121
143
  });
122
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onPromptChanged", function (prompt) {
123
- var _this$props3 = _this.props,
124
- onModelChanged = _this$props3.onModelChanged,
125
- model = _this$props3.model;
126
- var update = (0, _cloneDeep["default"])(model);
144
+ (0, _defineProperty2.default)(this, "onPromptChanged", prompt => {
145
+ const {
146
+ onModelChanged,
147
+ model
148
+ } = this.props;
149
+ const update = (0, _cloneDeep.default)(model);
127
150
  update.prompt = prompt;
128
151
  onModelChanged(update);
129
152
  });
130
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onTeacherInstructionsChanged", function (teacherInstructions) {
131
- var _this$props4 = _this.props,
132
- onModelChanged = _this$props4.onModelChanged,
133
- model = _this$props4.model;
134
- var update = (0, _cloneDeep["default"])(model);
153
+ (0, _defineProperty2.default)(this, "onTeacherInstructionsChanged", teacherInstructions => {
154
+ const {
155
+ onModelChanged,
156
+ model
157
+ } = this.props;
158
+ const update = (0, _cloneDeep.default)(model);
135
159
  update.teacherInstructions = teacherInstructions;
136
160
  onModelChanged(update);
137
161
  });
138
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onRationaleChanged", function (rationale) {
139
- var _this$props5 = _this.props,
140
- onModelChanged = _this$props5.onModelChanged,
141
- model = _this$props5.model;
142
- onModelChanged(_objectSpread(_objectSpread({}, model), {}, {
143
- rationale: rationale
144
- }));
162
+ (0, _defineProperty2.default)(this, "onRationaleChanged", rationale => {
163
+ const {
164
+ onModelChanged,
165
+ model
166
+ } = this.props;
167
+ onModelChanged({
168
+ ...model,
169
+ rationale
170
+ });
145
171
  });
146
- var _model = _this.props.model;
147
- _this.state = {
172
+ const {
173
+ model: _model
174
+ } = this.props;
175
+ this.state = {
148
176
  text: _model && _model.text || ''
149
177
  };
150
- return _this;
151
178
  }
152
-
153
- (0, _createClass2["default"])(Design, [{
154
- key: "UNSAFE_componentWillReceiveProps",
155
- value: function UNSAFE_componentWillReceiveProps(nProps) {
156
- var model = nProps.model;
157
-
158
- if (model && model.text) {
159
- this.setState({
160
- text: model.text
161
- });
162
- }
179
+ UNSAFE_componentWillReceiveProps(nProps) {
180
+ const {
181
+ model
182
+ } = nProps;
183
+ if (model && model.text) {
184
+ this.setState({
185
+ text: model.text
186
+ });
163
187
  }
164
- }, {
165
- key: "render",
166
- value: function render() {
167
- var _configuration$teache, _configuration$prompt, _configuration$ration;
168
-
169
- var textValue = this.state.text;
170
- var _this$props6 = this.props,
171
- classes = _this$props6.classes,
172
- configuration = _this$props6.configuration,
173
- imageSupport = _this$props6.imageSupport,
174
- model = _this$props6.model,
175
- onConfigurationChanged = _this$props6.onConfigurationChanged,
176
- onModelChanged = _this$props6.onModelChanged,
177
- uploadSoundSupport = _this$props6.uploadSoundSupport;
178
-
179
- var _ref = configuration || {},
180
- _ref$baseInputConfigu = _ref.baseInputConfiguration,
181
- baseInputConfiguration = _ref$baseInputConfigu === void 0 ? {} : _ref$baseInputConfigu,
182
- _ref$correctAnswer = _ref.correctAnswer,
183
- correctAnswer = _ref$correctAnswer === void 0 ? {} : _ref$correctAnswer,
184
- _ref$contentDimension = _ref.contentDimensions,
185
- contentDimensions = _ref$contentDimension === void 0 ? {} : _ref$contentDimension,
186
- _ref$feedback = _ref.feedback,
187
- feedback = _ref$feedback === void 0 ? {} : _ref$feedback,
188
- _ref$highlightChoices = _ref.highlightChoices,
189
- highlightChoices = _ref$highlightChoices === void 0 ? {} : _ref$highlightChoices,
190
- _ref$mode = _ref.mode,
191
- mode = _ref$mode === void 0 ? {} : _ref$mode,
192
- _ref$partialScoring = _ref.partialScoring,
193
- partialScoring = _ref$partialScoring === void 0 ? {} : _ref$partialScoring,
194
- _ref$prompt = _ref.prompt,
195
- prompt = _ref$prompt === void 0 ? {} : _ref$prompt,
196
- _ref$rationale = _ref.rationale,
197
- rationale = _ref$rationale === void 0 ? {} : _ref$rationale,
198
- _ref$selectionCount = _ref.selectionCount,
199
- selectionCount = _ref$selectionCount === void 0 ? {} : _ref$selectionCount,
200
- _ref$selections = _ref.selections,
201
- selections = _ref$selections === void 0 ? {} : _ref$selections,
202
- settingsPanelDisabled = _ref.settingsPanelDisabled,
203
- _ref$scoringType = _ref.scoringType,
204
- scoringType = _ref$scoringType === void 0 ? {} : _ref$scoringType,
205
- _ref$spellCheck = _ref.spellCheck,
206
- spellCheck = _ref$spellCheck === void 0 ? {} : _ref$spellCheck,
207
- _ref$studentInstructi = _ref.studentInstructions,
208
- studentInstructions = _ref$studentInstructi === void 0 ? {} : _ref$studentInstructi,
209
- _ref$teacherInstructi = _ref.teacherInstructions,
210
- teacherInstructions = _ref$teacherInstructi === void 0 ? {} : _ref$teacherInstructi,
211
- _ref$text = _ref.text,
212
- text = _ref$text === void 0 ? {} : _ref$text,
213
- _ref$tokens = _ref.tokens,
214
- tokens = _ref$tokens === void 0 ? {} : _ref$tokens,
215
- _ref$maxImageWidth = _ref.maxImageWidth,
216
- maxImageWidth = _ref$maxImageWidth === void 0 ? {} : _ref$maxImageWidth,
217
- _ref$maxImageHeight = _ref.maxImageHeight,
218
- maxImageHeight = _ref$maxImageHeight === void 0 ? {} : _ref$maxImageHeight,
219
- _ref$withRubric = _ref.withRubric,
220
- withRubric = _ref$withRubric === void 0 ? {} : _ref$withRubric,
221
- _ref$mathMlOptions = _ref.mathMlOptions,
222
- mathMlOptions = _ref$mathMlOptions === void 0 ? {} : _ref$mathMlOptions,
223
- _ref$language = _ref.language,
224
- language = _ref$language === void 0 ? {} : _ref$language,
225
- _ref$languageChoices = _ref.languageChoices,
226
- languageChoices = _ref$languageChoices === void 0 ? {} : _ref$languageChoices;
227
-
228
- var _ref2 = model || {},
229
- errors = _ref2.errors,
230
- extraCSSRules = _ref2.extraCSSRules,
231
- feedbackEnabled = _ref2.feedbackEnabled,
232
- promptEnabled = _ref2.promptEnabled,
233
- rationaleEnabled = _ref2.rationaleEnabled,
234
- spellCheckEnabled = _ref2.spellCheckEnabled,
235
- teacherInstructionsEnabled = _ref2.teacherInstructionsEnabled,
236
- toolbarEditorPosition = _ref2.toolbarEditorPosition;
237
-
238
- var _ref3 = errors || {},
239
- promptError = _ref3.prompt,
240
- rationaleError = _ref3.rationale,
241
- selectionsError = _ref3.selectionsError,
242
- teacherInstructionsError = _ref3.teacherInstructions,
243
- tokensError = _ref3.tokensError;
244
-
245
- var validationMessage = (0, _utils.generateValidationMessage)(configuration);
246
- var defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
247
- var defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
248
- var tokensModel = model.tokens;
249
- tokensModel = tokensModel || [];
250
- var toolbarOpts = {
251
- position: toolbarEditorPosition === 'top' ? 'top' : 'bottom'
252
- };
253
- log('[render] maxSelections:', model.maxSelections);
254
- var panelSettings = {
255
- partialScoring: partialScoring.settings && toggle(partialScoring.label),
256
- highlightChoices: highlightChoices.settings && toggle(highlightChoices.label),
257
- feedbackEnabled: feedback.settings && toggle(feedback.label),
258
- 'language.enabled': language.settings && toggle(language.label, true),
259
- language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options)
260
- };
261
- var panelProperties = {
262
- teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
263
- studentInstructionsEnabled: studentInstructions.settings && toggle(studentInstructions.label),
264
- promptEnabled: prompt.settings && toggle(prompt.label),
265
- rationaleEnabled: rationale.settings && toggle(rationale.label),
266
- spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
267
- scoringType: scoringType.settings && radio(scoringType.label, ['auto', 'rubric']),
268
- rubricEnabled: (withRubric === null || withRubric === void 0 ? void 0 : withRubric.settings) && toggle(withRubric === null || withRubric === void 0 ? void 0 : withRubric.label)
269
- };
270
-
271
- var getPluginProps = function getPluginProps() {
272
- var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
273
- return _objectSpread(_objectSpread({}, baseInputConfiguration), props);
274
- };
275
-
276
- return /*#__PURE__*/_react["default"].createElement(_configUi.layout.ConfigLayout, {
277
- extraCSSRules: extraCSSRules,
278
- dimensions: contentDimensions,
279
- hideSettings: settingsPanelDisabled,
280
- settings: /*#__PURE__*/_react["default"].createElement(Panel, {
281
- model: model,
282
- configuration: configuration,
283
- onChangeModel: function onChangeModel(model) {
284
- return onModelChanged(model);
285
- },
286
- onChangeConfiguration: onConfigurationChanged,
287
- groups: {
288
- Settings: panelSettings,
289
- Properties: panelProperties
290
- }
291
- })
292
- }, teacherInstructionsEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
293
- label: teacherInstructions.label,
294
- className: classes.promptHolder
295
- }, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
296
- className: classes.prompt,
297
- markup: model.teacherInstructions || '',
298
- onChange: this.onTeacherInstructionsChanged,
299
- imageSupport: imageSupport,
300
- nonEmpty: false,
301
- error: teacherInstructionsError,
302
- toolbarOpts: toolbarOpts,
303
- pluginProps: getPluginProps(configuration === null || configuration === void 0 ? void 0 : (_configuration$teache = configuration.teacherInstructions) === null || _configuration$teache === void 0 ? void 0 : _configuration$teache.inputConfiguration),
304
- spellCheck: spellCheckEnabled,
305
- maxImageWidth: maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth,
306
- maxImageHeight: maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight,
307
- uploadSoundSupport: uploadSoundSupport,
308
- languageCharactersProps: [{
309
- language: 'spanish'
310
- }, {
311
- language: 'special'
312
- }],
313
- mathMlOptions: mathMlOptions
314
- }), teacherInstructionsError && /*#__PURE__*/_react["default"].createElement("div", {
315
- className: classes.errorText
316
- }, teacherInstructionsError)), promptEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
317
- label: prompt.label || '',
318
- className: classes.promptHolder
319
- }, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
320
- className: classes.prompt,
321
- markup: model.prompt,
322
- onChange: this.onPromptChanged,
323
- imageSupport: imageSupport,
324
- error: promptError,
325
- toolbarOpts: toolbarOpts,
326
- pluginProps: getPluginProps(configuration === null || configuration === void 0 ? void 0 : (_configuration$prompt = configuration.prompt) === null || _configuration$prompt === void 0 ? void 0 : _configuration$prompt.inputConfiguration),
327
- spellCheck: spellCheckEnabled,
328
- maxImageWidth: defaultImageMaxWidth,
329
- maxImageHeight: defaultImageMaxHeight,
330
- uploadSoundSupport: uploadSoundSupport,
331
- languageCharactersProps: [{
332
- language: 'spanish'
333
- }, {
334
- language: 'special'
335
- }],
336
- mathMlOptions: mathMlOptions
337
- }), promptError && /*#__PURE__*/_react["default"].createElement("div", {
338
- className: classes.errorText
339
- }, promptError)), text.settings && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
340
- label: text.label || '',
341
- className: classes.promptHolder
342
- }, /*#__PURE__*/_react["default"].createElement(_TextField["default"], {
343
- className: classes.input,
344
- multiline: true,
345
- defaultValue: textValue,
346
- onChange: this.changeText,
347
- spellCheck: spellCheckEnabled
348
- })), tokens.settings && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
349
- label: tokens.label || '',
350
- className: classes.tokenizerContainer
351
- }, /*#__PURE__*/_react["default"].createElement(_Tooltip["default"], {
352
- classes: {
353
- tooltip: classes.tooltip
354
- },
355
- disableFocusListener: true,
356
- disableTouchListener: true,
357
- placement: 'right',
358
- title: validationMessage
359
- }, /*#__PURE__*/_react["default"].createElement(_Info["default"], {
360
- fontSize: 'small',
361
- color: 'primary',
362
- style: {
363
- position: 'absolute',
364
- left: '48px',
365
- top: '-3px'
188
+ }
189
+ render() {
190
+ const {
191
+ text: textValue
192
+ } = this.state;
193
+ const {
194
+ configuration,
195
+ imageSupport,
196
+ model,
197
+ onConfigurationChanged,
198
+ onModelChanged,
199
+ uploadSoundSupport
200
+ } = this.props;
201
+ const {
202
+ baseInputConfiguration = {},
203
+ correctAnswer = {},
204
+ contentDimensions = {},
205
+ feedback = {},
206
+ highlightChoices = {},
207
+ mode = {},
208
+ partialScoring = {},
209
+ prompt = {},
210
+ rationale = {},
211
+ selectionCount = {},
212
+ selections = {},
213
+ settingsPanelDisabled,
214
+ scoringType = {},
215
+ spellCheck = {},
216
+ studentInstructions = {},
217
+ teacherInstructions = {},
218
+ text = {},
219
+ tokens = {},
220
+ maxImageWidth = {},
221
+ maxImageHeight = {},
222
+ withRubric = {},
223
+ mathMlOptions = {},
224
+ language = {},
225
+ languageChoices = {}
226
+ } = configuration || {};
227
+ const {
228
+ errors,
229
+ extraCSSRules,
230
+ feedbackEnabled,
231
+ promptEnabled,
232
+ rationaleEnabled,
233
+ spellCheckEnabled,
234
+ teacherInstructionsEnabled,
235
+ toolbarEditorPosition
236
+ } = model || {};
237
+ const {
238
+ prompt: promptError,
239
+ rationale: rationaleError,
240
+ selectionsError,
241
+ teacherInstructions: teacherInstructionsError,
242
+ tokensError
243
+ } = errors || {};
244
+ const validationMessage = (0, _utils.generateValidationMessage)(configuration);
245
+ const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
246
+ const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
247
+ let {
248
+ tokens: tokensModel
249
+ } = model;
250
+ tokensModel = tokensModel || [];
251
+ const toolbarOpts = {
252
+ position: toolbarEditorPosition === 'top' ? 'top' : 'bottom'
253
+ };
254
+ log('[render] maxSelections:', model.maxSelections);
255
+ const panelSettings = {
256
+ partialScoring: partialScoring.settings && toggle(partialScoring.label),
257
+ highlightChoices: highlightChoices.settings && toggle(highlightChoices.label),
258
+ feedbackEnabled: feedback.settings && toggle(feedback.label),
259
+ 'language.enabled': language.settings && toggle(language.label, true),
260
+ language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options)
261
+ };
262
+ const panelProperties = {
263
+ teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
264
+ studentInstructionsEnabled: studentInstructions.settings && toggle(studentInstructions.label),
265
+ promptEnabled: prompt.settings && toggle(prompt.label),
266
+ rationaleEnabled: rationale.settings && toggle(rationale.label),
267
+ spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
268
+ scoringType: scoringType.settings && radio(scoringType.label, ['auto', 'rubric']),
269
+ rubricEnabled: withRubric?.settings && toggle(withRubric?.label)
270
+ };
271
+ const getPluginProps = (props = {}) => ({
272
+ ...baseInputConfiguration,
273
+ ...props
274
+ });
275
+ return /*#__PURE__*/_react.default.createElement(_configUi.layout.ConfigLayout, {
276
+ extraCSSRules: extraCSSRules,
277
+ dimensions: contentDimensions,
278
+ hideSettings: settingsPanelDisabled,
279
+ settings: /*#__PURE__*/_react.default.createElement(Panel, {
280
+ model: model,
281
+ configuration: configuration,
282
+ onChangeModel: model => onModelChanged(model),
283
+ onChangeConfiguration: onConfigurationChanged,
284
+ groups: {
285
+ Settings: panelSettings,
286
+ Properties: panelProperties
366
287
  }
367
- })), /*#__PURE__*/_react["default"].createElement(_textSelect.Tokenizer, {
368
- className: classes.tokenizer,
369
- text: model.text,
370
- tokens: tokensModel,
371
- onChange: this.changeTokens
372
- })), tokensError && /*#__PURE__*/_react["default"].createElement("div", {
373
- className: classes.errorText
374
- }, tokensError), selectionsError && /*#__PURE__*/_react["default"].createElement("div", {
375
- className: classes.errorText
376
- }, selectionsError), /*#__PURE__*/_react["default"].createElement("div", {
377
- className: classes.tokensDetails
378
- }, mode.settings && /*#__PURE__*/_react["default"].createElement(_Chip["default"], {
379
- label: "".concat(mode.label, ": ").concat(model.mode ? model.mode : 'None'),
380
- className: classes.chip
381
- }), selections.settings && /*#__PURE__*/_react["default"].createElement(_Chip["default"], {
382
- label: "".concat(selections.label, ": ").concat(tokensModel.length),
383
- className: classes.chip
384
- }), correctAnswer.settings && /*#__PURE__*/_react["default"].createElement(_Chip["default"], {
385
- label: "".concat(correctAnswer.label, ": ").concat(tokensModel.filter(function (t) {
386
- return t.correct;
387
- }).length),
388
- className: classes.chip
389
- }), selectionCount.settings && /*#__PURE__*/_react["default"].createElement(_configUi.NumberTextField, {
390
- min: tokensModel.filter(function (t) {
391
- return t.correct;
392
- }).length || 0,
393
- label: "".concat(selectionCount.label, " (0:any)"),
394
- max: tokensModel.length,
395
- value: model.maxSelections,
396
- onChange: this.changeMaxSelections,
397
- className: classes.numberField
398
- })), rationaleEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
399
- label: rationale.label || '',
400
- className: classes.promptHolder
401
- }, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
402
- className: classes.prompt,
403
- markup: model.rationale || '',
404
- onChange: this.onRationaleChanged,
405
- imageSupport: imageSupport,
406
- error: rationaleError,
407
- toolbarOpts: toolbarOpts,
408
- pluginProps: getPluginProps(configuration === null || configuration === void 0 ? void 0 : (_configuration$ration = configuration.rationale) === null || _configuration$ration === void 0 ? void 0 : _configuration$ration.inputConfiguration),
409
- spellCheck: spellCheckEnabled,
410
- maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
411
- maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight,
412
- uploadSoundSupport: uploadSoundSupport,
413
- languageCharactersProps: [{
414
- language: 'spanish'
415
- }, {
416
- language: 'special'
417
- }],
418
- mathMlOptions: mathMlOptions
419
- }), rationaleError && /*#__PURE__*/_react["default"].createElement("div", {
420
- className: classes.errorText
421
- }, rationaleError)), feedbackEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.FeedbackConfig, {
422
- feedback: model.feedback,
423
- onChange: this.changeFeedback,
424
- toolbarOpts: toolbarOpts
425
- }));
426
- }
427
- }]);
428
- return Design;
429
- }(_react["default"].Component);
430
-
288
+ })
289
+ }, teacherInstructionsEnabled && /*#__PURE__*/_react.default.createElement(StyledInputContainer, {
290
+ label: teacherInstructions.label
291
+ }, /*#__PURE__*/_react.default.createElement(StyledEditableHtml, {
292
+ markup: model.teacherInstructions || '',
293
+ onChange: this.onTeacherInstructionsChanged,
294
+ imageSupport: imageSupport,
295
+ nonEmpty: false,
296
+ error: teacherInstructionsError,
297
+ toolbarOpts: toolbarOpts,
298
+ pluginProps: getPluginProps(configuration?.teacherInstructions?.inputConfiguration),
299
+ spellCheck: spellCheckEnabled,
300
+ maxImageWidth: maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth,
301
+ maxImageHeight: maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight,
302
+ uploadSoundSupport: uploadSoundSupport,
303
+ languageCharactersProps: [{
304
+ language: 'spanish'
305
+ }, {
306
+ language: 'special'
307
+ }],
308
+ mathMlOptions: mathMlOptions
309
+ }), teacherInstructionsError && /*#__PURE__*/_react.default.createElement(ErrorText, null, teacherInstructionsError)), promptEnabled && /*#__PURE__*/_react.default.createElement(StyledInputContainer, {
310
+ label: prompt.label || ''
311
+ }, /*#__PURE__*/_react.default.createElement(StyledEditableHtml, {
312
+ markup: model.prompt,
313
+ onChange: this.onPromptChanged,
314
+ imageSupport: imageSupport,
315
+ error: promptError,
316
+ toolbarOpts: toolbarOpts,
317
+ pluginProps: getPluginProps(configuration?.prompt?.inputConfiguration),
318
+ spellCheck: spellCheckEnabled,
319
+ maxImageWidth: defaultImageMaxWidth,
320
+ maxImageHeight: defaultImageMaxHeight,
321
+ uploadSoundSupport: uploadSoundSupport,
322
+ languageCharactersProps: [{
323
+ language: 'spanish'
324
+ }, {
325
+ language: 'special'
326
+ }],
327
+ mathMlOptions: mathMlOptions
328
+ }), promptError && /*#__PURE__*/_react.default.createElement(ErrorText, null, promptError)), text.settings && /*#__PURE__*/_react.default.createElement(StyledInputContainer, {
329
+ label: text.label || ''
330
+ }, /*#__PURE__*/_react.default.createElement(StyledTextField, {
331
+ variant: "standard",
332
+ multiline: true,
333
+ defaultValue: textValue,
334
+ onChange: this.changeText,
335
+ spellCheck: spellCheckEnabled
336
+ })), tokens.settings && /*#__PURE__*/_react.default.createElement(TokenizerContainer, {
337
+ label: tokens.label || ''
338
+ }, /*#__PURE__*/_react.default.createElement(StyledTooltip, {
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
+ position: 'absolute',
348
+ left: '48px',
349
+ top: '-3px'
350
+ }
351
+ })), /*#__PURE__*/_react.default.createElement(StyledTokenizer, {
352
+ text: model.text,
353
+ tokens: tokensModel,
354
+ onChange: this.changeTokens
355
+ })), tokensError && /*#__PURE__*/_react.default.createElement(ErrorText, null, tokensError), selectionsError && /*#__PURE__*/_react.default.createElement(ErrorText, null, selectionsError), /*#__PURE__*/_react.default.createElement(TokensDetails, null, mode.settings && /*#__PURE__*/_react.default.createElement(StyledChip, {
356
+ label: `${mode.label}: ${model.mode ? model.mode : 'None'}`
357
+ }), selections.settings && /*#__PURE__*/_react.default.createElement(StyledChip, {
358
+ label: `${selections.label}: ${tokensModel.length}`
359
+ }), correctAnswer.settings && /*#__PURE__*/_react.default.createElement(StyledChip, {
360
+ label: `${correctAnswer.label}: ${tokensModel.filter(t => t.correct).length}`
361
+ }), selectionCount.settings && /*#__PURE__*/_react.default.createElement(StyledNumberTextField, {
362
+ min: tokensModel.filter(t => t.correct).length || 0,
363
+ label: `${selectionCount.label} (0:any)`,
364
+ max: tokensModel.length,
365
+ value: model.maxSelections,
366
+ onChange: this.changeMaxSelections
367
+ })), rationaleEnabled && /*#__PURE__*/_react.default.createElement(StyledInputContainer, {
368
+ label: rationale.label || ''
369
+ }, /*#__PURE__*/_react.default.createElement(StyledEditableHtml, {
370
+ markup: model.rationale || '',
371
+ onChange: this.onRationaleChanged,
372
+ imageSupport: imageSupport,
373
+ error: rationaleError,
374
+ toolbarOpts: toolbarOpts,
375
+ pluginProps: getPluginProps(configuration?.rationale?.inputConfiguration),
376
+ spellCheck: spellCheckEnabled,
377
+ maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
378
+ maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight,
379
+ uploadSoundSupport: uploadSoundSupport,
380
+ languageCharactersProps: [{
381
+ language: 'spanish'
382
+ }, {
383
+ language: 'special'
384
+ }],
385
+ mathMlOptions: mathMlOptions
386
+ }), rationaleError && /*#__PURE__*/_react.default.createElement(ErrorText, null, rationaleError)), feedbackEnabled && /*#__PURE__*/_react.default.createElement(_configUi.FeedbackConfig, {
387
+ feedback: model.feedback,
388
+ onChange: this.changeFeedback,
389
+ toolbarOpts: toolbarOpts
390
+ }));
391
+ }
392
+ }
431
393
  exports.Design = Design;
432
- (0, _defineProperty2["default"])(Design, "propTypes", {
433
- model: _propTypes["default"].object.isRequired,
434
- configuration: _propTypes["default"].object.isRequired,
435
- classes: _propTypes["default"].object.isRequired,
436
- onModelChanged: _propTypes["default"].func.isRequired,
437
- onConfigurationChanged: _propTypes["default"].func.isRequired,
438
- imageSupport: _propTypes["default"].shape({
439
- add: _propTypes["default"].func.isRequired,
440
- "delete": _propTypes["default"].func.isRequired
394
+ (0, _defineProperty2.default)(Design, "propTypes", {
395
+ model: _propTypes.default.object.isRequired,
396
+ configuration: _propTypes.default.object.isRequired,
397
+ onModelChanged: _propTypes.default.func.isRequired,
398
+ onConfigurationChanged: _propTypes.default.func.isRequired,
399
+ imageSupport: _propTypes.default.shape({
400
+ add: _propTypes.default.func.isRequired,
401
+ delete: _propTypes.default.func.isRequired
441
402
  }),
442
- uploadSoundSupport: _propTypes["default"].object
403
+ uploadSoundSupport: _propTypes.default.object
443
404
  });
444
- (0, _defineProperty2["default"])(Design, "defaultProps", {});
445
-
446
- var _default = (0, _styles.withStyles)(function (theme) {
447
- return {
448
- tokenizerContainer: {
449
- paddingRight: 0,
450
- marginRight: 0,
451
- '&:after': {
452
- position: 'absolute',
453
- bottom: 0,
454
- left: 0,
455
- right: 0,
456
- height: '1px',
457
- content: '""',
458
- backgroundColor: theme.palette.primary.main
459
- },
460
- marginBottom: theme.spacing.unit
461
- },
462
- chip: {
463
- marginTop: theme.spacing.unit / 2,
464
- marginRight: theme.spacing.unit * 2
465
- },
466
- input: {
467
- width: '100%'
468
- },
469
- tokenizer: {
470
- marginTop: theme.spacing.unit * 2
471
- },
472
- mainOpts: {
473
- width: '100%',
474
- justifyContent: 'space-between',
475
- display: 'flex',
476
- alignItems: 'baseline'
477
- },
478
- promptHolder: {
479
- width: '100%',
480
- paddingTop: theme.spacing.unit * 2,
481
- marginBottom: theme.spacing.unit * 2
482
- },
483
- tokensDetails: {
484
- display: 'flex',
485
- alignItems: 'center',
486
- flexWrap: 'wrap',
487
- marginBottom: theme.spacing.unit * 2.5
488
- },
489
- numberField: {
490
- width: '180px',
491
- margin: "".concat(theme.spacing.unit / 2, "px auto 0")
492
- },
493
- tooltip: {
494
- fontSize: theme.typography.fontSize - 2,
495
- whiteSpace: 'pre',
496
- maxWidth: '500px'
497
- },
498
- errorText: {
499
- fontSize: theme.typography.fontSize - 2,
500
- color: theme.palette.error.main,
501
- paddingTop: theme.spacing.unit
502
- }
503
- };
504
- })(Design);
505
-
506
- exports["default"] = _default;
405
+ (0, _defineProperty2.default)(Design, "defaultProps", {});
406
+ var _default = exports.default = Design;
507
407
  //# sourceMappingURL=design.js.map