@pie-element/multi-trait-rubric 6.1.0 → 6.2.0-mui-update.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/configure/CHANGELOG.md +11 -0
  3. package/configure/lib/common.js +379 -534
  4. package/configure/lib/common.js.map +1 -1
  5. package/configure/lib/defaults.js +35 -6
  6. package/configure/lib/defaults.js.map +1 -1
  7. package/configure/lib/index.js +96 -162
  8. package/configure/lib/index.js.map +1 -1
  9. package/configure/lib/main.js +346 -437
  10. package/configure/lib/main.js.map +1 -1
  11. package/configure/lib/modals.js +178 -333
  12. package/configure/lib/modals.js.map +1 -1
  13. package/configure/lib/scale.js +358 -463
  14. package/configure/lib/scale.js.map +1 -1
  15. package/configure/lib/trait.js +253 -358
  16. package/configure/lib/trait.js.map +1 -1
  17. package/configure/lib/traitsHeader.js +201 -264
  18. package/configure/lib/traitsHeader.js.map +1 -1
  19. package/configure/lib/utils.js +42 -73
  20. package/configure/lib/utils.js.map +1 -1
  21. package/configure/package.json +12 -9
  22. package/controller/CHANGELOG.md +8 -0
  23. package/controller/lib/defaults.js +2 -3
  24. package/controller/lib/defaults.js.map +1 -1
  25. package/controller/lib/index.js +66 -123
  26. package/controller/lib/index.js.map +1 -1
  27. package/controller/lib/utils.js +1 -3
  28. package/controller/lib/utils.js.map +1 -1
  29. package/controller/package.json +1 -1
  30. package/lib/index.js +40 -77
  31. package/lib/index.js.map +1 -1
  32. package/lib/main.js +99 -140
  33. package/lib/main.js.map +1 -1
  34. package/lib/scale.js +217 -299
  35. package/lib/scale.js.map +1 -1
  36. package/lib/trait.js +51 -71
  37. package/lib/trait.js.map +1 -1
  38. package/package.json +15 -8
  39. package/LICENSE.md +0 -5
@@ -1,89 +1,49 @@
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.Main = void 0;
9
-
7
+ exports.default = exports.Main = void 0;
10
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
-
12
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
13
-
14
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
15
-
16
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
17
-
18
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
19
-
20
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
21
-
22
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
23
-
24
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
25
-
26
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
27
-
28
10
  var _react = _interopRequireDefault(require("react"));
29
-
30
11
  var _propTypes = _interopRequireDefault(require("prop-types"));
31
-
32
12
  var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
33
-
34
13
  var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
35
-
36
14
  var _debounce = _interopRequireDefault(require("lodash/debounce"));
37
-
38
- var _styles = require("@material-ui/core/styles");
39
-
40
- var _drag = require("@pie-lib/drag");
41
-
15
+ var _styles = require("@mui/material/styles");
42
16
  var _configUi = require("@pie-lib/config-ui");
43
-
44
17
  var _scale = _interopRequireDefault(require("./scale"));
45
-
46
18
  var _common = require("./common");
47
-
48
19
  var _modals = require("./modals");
49
-
50
20
  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
- var MIN_WIDTH = '650px';
63
-
64
- var styles = function styles(theme) {
65
- return {
66
- design: {
67
- fontFamily: 'Cerebri Sans',
68
- fontSize: theme.typography.fontSize
69
- }
70
- };
71
- };
72
-
73
- var ShowModal = function ShowModal(_ref) {
74
- var showExcludeZeroDialog = _ref.showExcludeZeroDialog,
75
- excludeZero = _ref.excludeZero,
76
- changeExcludeZero = _ref.changeExcludeZero,
77
- cancel = _ref.cancel;
78
-
21
+ const {
22
+ Panel,
23
+ toggle
24
+ } = _configUi.settings;
25
+ const MIN_WIDTH = '650px';
26
+ const StyledDiv = (0, _styles.styled)('div')(({
27
+ theme
28
+ }) => ({
29
+ fontFamily: 'Cerebri Sans',
30
+ fontSize: theme.typography.fontSize,
31
+ padding: '16px 0'
32
+ }));
33
+ const ShowModal = ({
34
+ showExcludeZeroDialog,
35
+ excludeZero,
36
+ changeExcludeZero,
37
+ cancel
38
+ }) => {
79
39
  if (showExcludeZeroDialog && !excludeZero) {
80
- return /*#__PURE__*/_react["default"].createElement(_modals.ExcludeZeroDialog, {
40
+ return /*#__PURE__*/_react.default.createElement(_modals.ExcludeZeroDialog, {
81
41
  open: showExcludeZeroDialog && !excludeZero,
82
42
  changeExcludeZero: changeExcludeZero,
83
43
  cancel: cancel
84
44
  });
85
45
  } else if (showExcludeZeroDialog && excludeZero) {
86
- return /*#__PURE__*/_react["default"].createElement(_modals.IncludeZeroDialog, {
46
+ return /*#__PURE__*/_react.default.createElement(_modals.IncludeZeroDialog, {
87
47
  open: showExcludeZeroDialog && excludeZero,
88
48
  changeExcludeZero: changeExcludeZero,
89
49
  cancel: cancel
@@ -92,25 +52,16 @@ var ShowModal = function ShowModal(_ref) {
92
52
  return null;
93
53
  }
94
54
  };
95
-
96
55
  ShowModal.propTypes = {
97
- showExcludeZeroDialog: _propTypes["default"].bool,
98
- excludeZero: _propTypes["default"].bool,
99
- changeExcludeZero: _propTypes["default"].func,
100
- cancel: _propTypes["default"].func
56
+ showExcludeZeroDialog: _propTypes.default.bool,
57
+ excludeZero: _propTypes.default.bool,
58
+ changeExcludeZero: _propTypes.default.func,
59
+ cancel: _propTypes.default.func
101
60
  };
102
-
103
- var Main = /*#__PURE__*/function (_React$Component) {
104
- (0, _inherits2["default"])(Main, _React$Component);
105
-
106
- var _super = _createSuper(Main);
107
-
108
- function Main(props) {
109
- var _this;
110
-
111
- (0, _classCallCheck2["default"])(this, Main);
112
- _this = _super.call(this, props);
113
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
61
+ class Main extends _react.default.Component {
62
+ constructor(props) {
63
+ super(props);
64
+ (0, _defineProperty2.default)(this, "state", {
114
65
  showDecreaseMaxPointsDialog: false,
115
66
  showDeleteScaleDialog: false,
116
67
  showDeleteTraitDialog: false,
@@ -119,428 +70,386 @@ var Main = /*#__PURE__*/function (_React$Component) {
119
70
  infoDialogText: '',
120
71
  adjustedWidth: MIN_WIDTH,
121
72
  initialUpdateCompleted: false // flag to track the initial update of the div width
122
-
123
73
  });
124
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "updateDivWidthDebounced", (0, _debounce["default"])(function () {
125
- return _this.updateDivWidth();
126
- }, 50));
127
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onScaleAdded", function () {
128
- var _scales$;
129
-
130
- var _this$props = _this.props,
131
- model = _this$props.model,
132
- onModelChanged = _this$props.onModelChanged,
133
- configuration = _this$props.configuration;
134
-
135
- var _ref2 = model || {},
136
- scales = _ref2.scales,
137
- excludeZero = _ref2.excludeZero;
138
-
139
- var _ref3 = configuration || {},
140
- maxNoOfScales = _ref3.maxNoOfScales;
141
-
142
- var _ref4 = configuration || '',
143
- defaultTraitLabel = _ref4.defaultTraitLabel;
144
-
74
+ (0, _defineProperty2.default)(this, "updateDivWidthDebounced", (0, _debounce.default)(() => this.updateDivWidth(), 50));
75
+ (0, _defineProperty2.default)(this, "onScaleAdded", () => {
76
+ const {
77
+ model,
78
+ onModelChanged,
79
+ configuration
80
+ } = this.props;
81
+ let {
82
+ scales,
83
+ excludeZero
84
+ } = model || {};
85
+ const {
86
+ maxNoOfScales
87
+ } = configuration || {};
88
+ let {
89
+ defaultTraitLabel
90
+ } = configuration || '';
145
91
  if (!scales.length) {
146
92
  scales = [];
147
- } // if no default trait label is defined, take the trait label of the first scale
148
-
149
-
150
- defaultTraitLabel = typeof defaultTraitLabel === 'string' ? defaultTraitLabel : ((_scales$ = scales[0]) === null || _scales$ === void 0 ? void 0 : _scales$.traitLabel) || '';
93
+ }
151
94
 
95
+ // if no default trait label is defined, take the trait label of the first scale
96
+ defaultTraitLabel = typeof defaultTraitLabel === 'string' ? defaultTraitLabel : scales[0]?.traitLabel || '';
152
97
  if (scales.length === maxNoOfScales) {
153
- _this.set({
154
- infoDialogText: "There can't be more than ".concat(maxNoOfScales, " scales."),
98
+ this.set({
99
+ infoDialogText: `There can't be more than ${maxNoOfScales} scales.`,
155
100
  showInfoDialog: true
156
101
  });
157
-
158
102
  return false;
159
103
  }
160
-
161
104
  scales.push({
162
105
  maxPoints: 1,
163
106
  scorePointsLabels: excludeZero ? [''] : ['', ''],
164
107
  traitLabel: defaultTraitLabel,
165
108
  traits: []
166
109
  });
167
- onModelChanged(_objectSpread(_objectSpread({}, model), {}, {
168
- scales: scales
169
- }));
110
+ onModelChanged({
111
+ ...model,
112
+ scales
113
+ });
170
114
  });
171
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onScaleChanged", function (scaleIndex, params) {
172
- var _this$props2 = _this.props,
173
- model = _this$props2.model,
174
- onModelChanged = _this$props2.onModelChanged;
175
- var scales = (0, _cloneDeep["default"])((model || {}).scales);
176
- if (scaleIndex < 0 || scaleIndex >= scales.length || (0, _isEmpty["default"])(params)) return false;
177
- Object.keys(params).forEach(function (key) {
115
+ (0, _defineProperty2.default)(this, "onScaleChanged", (scaleIndex, params) => {
116
+ const {
117
+ model,
118
+ onModelChanged
119
+ } = this.props;
120
+ let scales = (0, _cloneDeep.default)((model || {}).scales);
121
+ if (scaleIndex < 0 || scaleIndex >= scales.length || (0, _isEmpty.default)(params)) return false;
122
+ Object.keys(params).forEach(key => {
178
123
  scales[scaleIndex][key] = params[key];
179
124
  });
180
-
181
125
  if (model.excludeZero && params.maxPoints === 1) {
182
126
  // excludeZero should be false and disabled when maxPoints is 1 for any scale
183
127
  model.excludeZero = false;
184
128
  scales = (0, _utils.addOrRemoveScaleColumn)(scales, _modals.excludeZeroTypes.add0);
185
129
  }
186
-
187
- onModelChanged(_objectSpread(_objectSpread({}, model), {}, {
188
- scales: scales
189
- }));
130
+ onModelChanged({
131
+ ...model,
132
+ scales
133
+ });
190
134
  });
191
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onScaleRemoved", function (scaleIndex) {
192
- var _this$props3 = _this.props,
193
- model = _this$props3.model,
194
- onModelChanged = _this$props3.onModelChanged,
195
- configuration = _this$props3.configuration;
196
-
197
- var _ref5 = model || {},
198
- scales = _ref5.scales;
199
-
200
- var _ref6 = configuration || {},
201
- minNoOfScales = _ref6.minNoOfScales;
202
-
135
+ (0, _defineProperty2.default)(this, "onScaleRemoved", scaleIndex => {
136
+ const {
137
+ model,
138
+ onModelChanged,
139
+ configuration
140
+ } = this.props;
141
+ let {
142
+ scales
143
+ } = model || {};
144
+ const {
145
+ minNoOfScales
146
+ } = configuration || {};
203
147
  if (scaleIndex < 0 || scaleIndex >= scales.length) return false;
204
-
205
148
  if (scales.length === minNoOfScales) {
206
- _this.set({
207
- infoDialogText: "There can't be less than ".concat(minNoOfScales, " scales."),
149
+ this.set({
150
+ infoDialogText: `There can't be less than ${minNoOfScales} scales.`,
208
151
  showInfoDialog: true
209
152
  });
210
-
211
153
  return false;
212
154
  }
213
-
214
- scales = [].concat((0, _toConsumableArray2["default"])(scales.slice(0, scaleIndex)), (0, _toConsumableArray2["default"])(scales.slice(scaleIndex + 1)));
215
- onModelChanged(_objectSpread(_objectSpread({}, model), {}, {
216
- scales: scales
217
- }));
155
+ scales = [...scales.slice(0, scaleIndex), ...scales.slice(scaleIndex + 1)];
156
+ onModelChanged({
157
+ ...model,
158
+ scales
159
+ });
218
160
  });
219
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onHalfScoringChanged", function () {
220
- var _this$props4 = _this.props,
221
- model = _this$props4.model,
222
- onModelChanged = _this$props4.onModelChanged;
223
-
224
- var _ref7 = model || {},
225
- halfScoring = _ref7.halfScoring;
226
-
227
- onModelChanged(_objectSpread(_objectSpread({}, model), {}, {
161
+ (0, _defineProperty2.default)(this, "onHalfScoringChanged", () => {
162
+ const {
163
+ model,
164
+ onModelChanged
165
+ } = this.props;
166
+ let {
167
+ halfScoring
168
+ } = model || {};
169
+ onModelChanged({
170
+ ...model,
228
171
  halfScoring: !halfScoring
229
- }));
172
+ });
230
173
  });
231
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onVisibleToStudentChanged", function () {
232
- var _this$props5 = _this.props,
233
- model = _this$props5.model,
234
- onModelChanged = _this$props5.onModelChanged;
235
-
236
- var _ref8 = model || {},
237
- visibleToStudent = _ref8.visibleToStudent;
238
-
239
- onModelChanged(_objectSpread(_objectSpread({}, model), {}, {
174
+ (0, _defineProperty2.default)(this, "onVisibleToStudentChanged", () => {
175
+ const {
176
+ model,
177
+ onModelChanged
178
+ } = this.props;
179
+ let {
180
+ visibleToStudent
181
+ } = model || {};
182
+ onModelChanged({
183
+ ...model,
240
184
  visibleToStudent: !visibleToStudent
241
- }));
242
- });
243
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "set", function (newState) {
244
- return _this.setState(newState);
185
+ });
245
186
  });
246
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeShowScorePointLabels", function () {
247
- var _ref9 = _this.props || {},
248
- model = _ref9.model,
249
- onModelChanged = _ref9.onModelChanged;
250
-
251
- var _ref10 = model || {},
252
- pointLabels = _ref10.pointLabels;
253
-
187
+ (0, _defineProperty2.default)(this, "set", newState => this.setState(newState));
188
+ (0, _defineProperty2.default)(this, "changeShowScorePointLabels", () => {
189
+ const {
190
+ model,
191
+ onModelChanged
192
+ } = this.props || {};
193
+ let {
194
+ pointLabels
195
+ } = model || {};
254
196
  pointLabels = !pointLabels;
255
- onModelChanged(_objectSpread(_objectSpread({}, model), {}, {
256
- pointLabels: pointLabels
257
- }));
197
+ onModelChanged({
198
+ ...model,
199
+ pointLabels
200
+ });
258
201
  });
259
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeShowDescription", function () {
260
- var _ref11 = _this.props || {},
261
- model = _ref11.model,
262
- onModelChanged = _ref11.onModelChanged;
263
-
264
- var _ref12 = model || {},
265
- description = _ref12.description;
266
-
202
+ (0, _defineProperty2.default)(this, "changeShowDescription", () => {
203
+ const {
204
+ model,
205
+ onModelChanged
206
+ } = this.props || {};
207
+ let {
208
+ description
209
+ } = model || {};
267
210
  description = !description;
268
- onModelChanged(_objectSpread(_objectSpread({}, model), {}, {
269
- description: description
270
- }));
211
+ onModelChanged({
212
+ ...model,
213
+ description
214
+ });
271
215
  });
272
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeShowStandards", function () {
273
- var _ref13 = _this.props || {},
274
- model = _ref13.model,
275
- onModelChanged = _ref13.onModelChanged;
276
-
277
- var _ref14 = model || {},
278
- standards = _ref14.standards;
279
-
216
+ (0, _defineProperty2.default)(this, "changeShowStandards", () => {
217
+ const {
218
+ model,
219
+ onModelChanged
220
+ } = this.props || {};
221
+ let {
222
+ standards
223
+ } = model || {};
280
224
  standards = !standards;
281
- onModelChanged(_objectSpread(_objectSpread({}, model), {}, {
282
- standards: standards
283
- }));
284
- });
285
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "showToggleExcludeZeroModal", function () {
286
- return _this.set({
287
- showExcludeZeroDialog: true
225
+ onModelChanged({
226
+ ...model,
227
+ standards
288
228
  });
289
229
  });
290
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "hideToggleExcludeZeroModal", function () {
291
- _this.set({
230
+ // Exclude Zero
231
+ (0, _defineProperty2.default)(this, "showToggleExcludeZeroModal", () => this.set({
232
+ showExcludeZeroDialog: true
233
+ }));
234
+ (0, _defineProperty2.default)(this, "hideToggleExcludeZeroModal", () => {
235
+ this.set({
292
236
  showExcludeZeroDialog: false
293
237
  });
294
238
  });
295
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onCloseInfoDialog", function () {
296
- return _this.set({
297
- showInfoDialog: false
298
- });
299
- });
300
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeExcludeZero", function (excludeZeroType) {
301
- var _ref15 = _this.props || {},
302
- model = _ref15.model,
303
- onModelChanged = _ref15.onModelChanged;
304
-
305
- var _ref16 = model || {},
306
- scales = _ref16.scales;
307
-
308
- var _ref17 = model || {},
309
- excludeZero = _ref17.excludeZero;
310
-
239
+ (0, _defineProperty2.default)(this, "onCloseInfoDialog", () => this.set({
240
+ showInfoDialog: false
241
+ }));
242
+ (0, _defineProperty2.default)(this, "changeExcludeZero", excludeZeroType => {
243
+ const {
244
+ model,
245
+ onModelChanged
246
+ } = this.props || {};
247
+ const {
248
+ scales
249
+ } = model || {};
250
+ let {
251
+ excludeZero
252
+ } = model || {};
311
253
  if (!scales || !scales.length) return;
312
254
  excludeZero = !excludeZero;
313
- var newScales = (0, _utils.addOrRemoveScaleColumn)(scales, excludeZeroType);
314
- onModelChanged(_objectSpread(_objectSpread({}, model), {}, {
255
+ const newScales = (0, _utils.addOrRemoveScaleColumn)(scales, excludeZeroType);
256
+ onModelChanged({
257
+ ...model,
315
258
  scales: newScales,
316
- excludeZero: excludeZero
317
- }));
318
-
319
- _this.hideToggleExcludeZeroModal();
259
+ excludeZero
260
+ });
261
+ this.hideToggleExcludeZeroModal();
320
262
  });
321
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onModelChanged", function (updatedModel, updatedProperty) {
322
- var _ref18 = _this.props || {},
323
- onModelChanged = _ref18.onModelChanged;
324
-
263
+ (0, _defineProperty2.default)(this, "onModelChanged", (updatedModel, updatedProperty) => {
264
+ const {
265
+ onModelChanged
266
+ } = this.props || {};
325
267
  if (updatedProperty === 'excludeZero') {
326
- _this.showToggleExcludeZeroModal();
268
+ this.showToggleExcludeZeroModal();
327
269
  } else {
328
270
  onModelChanged(updatedModel);
329
271
  }
330
272
  });
331
- _this.divRef = /*#__PURE__*/_react["default"].createRef();
332
- _this.updateDivWidth = _this.updateDivWidth.bind((0, _assertThisInitialized2["default"])(_this));
333
- return _this;
273
+ this.divRef = /*#__PURE__*/_react.default.createRef();
274
+ this.updateDivWidth = this.updateDivWidth.bind(this);
334
275
  }
276
+ componentDidMount() {
277
+ window.addEventListener('resize', this.updateDivWidthDebounced);
278
+ window.addEventListener('load', this.updateDivWidth);
335
279
 
336
- (0, _createClass2["default"])(Main, [{
337
- key: "componentDidMount",
338
- value: function componentDidMount() {
339
- window.addEventListener('resize', this.updateDivWidthDebounced);
340
- window.addEventListener('load', this.updateDivWidth); // delay updateDivWidth to avoid having this.divRef.current = null at first load
341
-
342
- setTimeout(this.updateDivWidth, 0);
343
- }
344
- }, {
345
- key: "componentWillUnmount",
346
- value: function componentWillUnmount() {
347
- window.removeEventListener('resize', this.updateDivWidthDebounced);
348
- window.removeEventListener('load', this.updateDivWidth);
280
+ // delay updateDivWidth to avoid having this.divRef.current = null at first load
281
+ setTimeout(this.updateDivWidth, 0);
282
+ }
283
+ componentWillUnmount() {
284
+ window.removeEventListener('resize', this.updateDivWidthDebounced);
285
+ window.removeEventListener('load', this.updateDivWidth);
286
+ }
287
+ componentDidUpdate() {
288
+ if (!this.state.initialUpdateCompleted) {
289
+ this.updateDivWidth();
290
+ this.setState({
291
+ initialUpdateCompleted: true
292
+ });
349
293
  }
350
- }, {
351
- key: "componentDidUpdate",
352
- value: function componentDidUpdate() {
353
- if (!this.state.initialUpdateCompleted) {
354
- this.updateDivWidth();
355
- this.setState({
356
- initialUpdateCompleted: true
294
+ }
295
+ updateDivWidth() {
296
+ if (this.divRef && this.divRef.current) {
297
+ const divWidth = this.divRef.current.offsetWidth;
298
+ if (divWidth !== this.state.adjustedWidth) {
299
+ this.set({
300
+ adjustedWidth: divWidth
357
301
  });
358
302
  }
359
303
  }
360
- }, {
361
- key: "updateDivWidth",
362
- value: function updateDivWidth() {
363
- if (this.divRef && this.divRef.current) {
364
- var divWidth = this.divRef.current.offsetWidth;
365
-
366
- if (divWidth !== this.state.adjustedWidth) {
367
- this.set({
368
- adjustedWidth: divWidth
369
- });
370
- }
371
- }
372
- }
373
- }, {
374
- key: "render",
375
- value: function render() {
376
- var _this2 = this;
377
-
378
- var _ref19 = this.props || {},
379
- model = _ref19.model,
380
- configuration = _ref19.configuration,
381
- onConfigurationChanged = _ref19.onConfigurationChanged,
382
- uploadSoundSupport = _ref19.uploadSoundSupport,
383
- imageSupport = _ref19.imageSupport;
384
-
385
- var _ref20 = configuration || {},
386
- addScale = _ref20.addScale,
387
- _ref20$baseInputConfi = _ref20.baseInputConfiguration,
388
- baseInputConfiguration = _ref20$baseInputConfi === void 0 ? {} : _ref20$baseInputConfi,
389
- dragAndDrop = _ref20.dragAndDrop,
390
- _ref20$contentDimensi = _ref20.contentDimensions,
391
- contentDimensions = _ref20$contentDimensi === void 0 ? {} : _ref20$contentDimensi,
392
- showDescription = _ref20.showDescription,
393
- showExcludeZero = _ref20.showExcludeZero,
394
- showLevelTagInput = _ref20.showLevelTagInput,
395
- showStandards = _ref20.showStandards,
396
- showHalfScoring = _ref20.showHalfScoring,
397
- showMaxPoint = _ref20.showMaxPoint,
398
- showScorePointLabels = _ref20.showScorePointLabels,
399
- showVisibleToStudent = _ref20.showVisibleToStudent,
400
- _ref20$spellCheck = _ref20.spellCheck,
401
- spellCheck = _ref20$spellCheck === void 0 ? {} : _ref20$spellCheck,
402
- settingsPanelDisabled = _ref20.settingsPanelDisabled,
403
- maxNoOfTraits = _ref20.maxNoOfTraits,
404
- minNoOfTraits = _ref20.minNoOfTraits,
405
- width = _ref20.width,
406
- _ref20$mathMlOptions = _ref20.mathMlOptions,
407
- mathMlOptions = _ref20$mathMlOptions === void 0 ? {} : _ref20$mathMlOptions,
408
- maxMaxPoints = _ref20.maxMaxPoints,
409
- _ref20$expandedInput = _ref20.expandedInput,
410
- expandedInput = _ref20$expandedInput === void 0 ? {} : _ref20$expandedInput,
411
- _ref20$labelInput = _ref20.labelInput,
412
- labelInput = _ref20$labelInput === void 0 ? {} : _ref20$labelInput;
413
-
414
- var _ref21 = model || {},
415
- errors = _ref21.errors,
416
- extraCSSRules = _ref21.extraCSSRules,
417
- scales = _ref21.scales,
418
- excludeZero = _ref21.excludeZero,
419
- description = _ref21.description,
420
- pointLabels = _ref21.pointLabels,
421
- standards = _ref21.standards,
422
- spellCheckEnabled = _ref21.spellCheckEnabled,
423
- maxPointsEnabled = _ref21.maxPointsEnabled,
424
- addScaleEnabled = _ref21.addScaleEnabled;
425
-
426
- var _ref22 = this.state || {},
427
- showExcludeZeroDialog = _ref22.showExcludeZeroDialog,
428
- showInfoDialog = _ref22.showInfoDialog,
429
- infoDialogText = _ref22.infoDialogText,
430
- adjustedWidth = _ref22.adjustedWidth; // excludeZero should be false and disabled when maxPoints is 1 for any scale
431
-
432
-
433
- var disabledExcludeZero = scales === null || scales === void 0 ? void 0 : scales.some(function (scale) {
434
- return scale.maxPoints === 1;
435
- });
436
- var panelSettings = {
437
- standards: showStandards.settings && toggle(showStandards.label),
438
- 'showLevelTagInput.enabled': showLevelTagInput.settings && toggle(showLevelTagInput.label, true),
439
- visibleToStudent: showVisibleToStudent.settings && toggle(showVisibleToStudent.label),
440
- excludeZero: showExcludeZero.settings && toggle(showExcludeZero.label, false, disabledExcludeZero),
441
- halfScoring: showHalfScoring.settings && toggle(showHalfScoring.label),
442
- 'dragAndDrop.enabled': dragAndDrop.settings && toggle(dragAndDrop.label, true)
443
- };
444
- var panelProperties = {
445
- description: showDescription.settings && toggle(showDescription.label),
446
- pointLabels: showScorePointLabels.settings && toggle(showScorePointLabels.label),
447
- spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
448
- maxPointsEnabled: showMaxPoint.settings && toggle(showMaxPoint.label),
449
- addScaleEnabled: addScale.settings && toggle(addScale.label)
450
- };
451
-
452
- var getPluginProps = function getPluginProps(props) {
453
- return Object.assign(_objectSpread({}, baseInputConfiguration), props || {});
454
- };
455
-
456
- return /*#__PURE__*/_react["default"].createElement(_configUi.layout.ConfigLayout, {
457
- extraCSSRules: extraCSSRules,
458
- dimensions: contentDimensions,
459
- hideSettings: settingsPanelDisabled,
460
- settings: /*#__PURE__*/_react["default"].createElement(Panel, {
461
- model: model,
462
- onChangeModel: this.onModelChanged,
463
- configuration: configuration,
464
- onChangeConfiguration: onConfigurationChanged,
465
- groups: {
466
- Settings: panelSettings,
467
- Properties: panelProperties
468
- },
469
- modal: /*#__PURE__*/_react["default"].createElement(ShowModal, {
470
- showExcludeZeroDialog: showExcludeZeroDialog,
471
- excludeZero: excludeZero,
472
- changeExcludeZero: this.changeExcludeZero,
473
- cancel: this.hideToggleExcludeZeroModal
474
- })
475
- })
476
- }, /*#__PURE__*/_react["default"].createElement("div", {
477
- style: {
478
- width: '100%'
304
+ }
305
+ render() {
306
+ const {
307
+ model,
308
+ configuration,
309
+ onConfigurationChanged,
310
+ uploadSoundSupport,
311
+ imageSupport
312
+ } = this.props || {};
313
+ const {
314
+ addScale,
315
+ baseInputConfiguration = {},
316
+ dragAndDrop,
317
+ contentDimensions = {},
318
+ showDescription,
319
+ showExcludeZero,
320
+ showLevelTagInput,
321
+ showStandards,
322
+ showHalfScoring,
323
+ showMaxPoint,
324
+ showScorePointLabels,
325
+ showVisibleToStudent,
326
+ spellCheck = {},
327
+ settingsPanelDisabled,
328
+ maxNoOfTraits,
329
+ minNoOfTraits,
330
+ width,
331
+ mathMlOptions = {},
332
+ maxMaxPoints,
333
+ expandedInput = {},
334
+ labelInput = {}
335
+ } = configuration || {};
336
+ const {
337
+ errors,
338
+ extraCSSRules,
339
+ scales,
340
+ excludeZero,
341
+ description,
342
+ pointLabels,
343
+ standards,
344
+ spellCheckEnabled,
345
+ maxPointsEnabled,
346
+ addScaleEnabled
347
+ } = model || {};
348
+ const {
349
+ showExcludeZeroDialog,
350
+ showInfoDialog,
351
+ infoDialogText,
352
+ adjustedWidth
353
+ } = this.state || {};
354
+
355
+ // excludeZero should be false and disabled when maxPoints is 1 for any scale
356
+ const disabledExcludeZero = scales?.some(scale => scale.maxPoints === 1);
357
+ const panelSettings = {
358
+ standards: showStandards.settings && toggle(showStandards.label),
359
+ 'showLevelTagInput.enabled': showLevelTagInput.settings && toggle(showLevelTagInput.label, true),
360
+ visibleToStudent: showVisibleToStudent.settings && toggle(showVisibleToStudent.label),
361
+ excludeZero: showExcludeZero.settings && toggle(showExcludeZero.label, false, disabledExcludeZero),
362
+ halfScoring: showHalfScoring.settings && toggle(showHalfScoring.label),
363
+ 'dragAndDrop.enabled': dragAndDrop.settings && toggle(dragAndDrop.label, true)
364
+ };
365
+ const panelProperties = {
366
+ description: showDescription.settings && toggle(showDescription.label),
367
+ pointLabels: showScorePointLabels.settings && toggle(showScorePointLabels.label),
368
+ spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
369
+ maxPointsEnabled: showMaxPoint.settings && toggle(showMaxPoint.label),
370
+ addScaleEnabled: addScale.settings && toggle(addScale.label)
371
+ };
372
+ const getPluginProps = props => {
373
+ return Object.assign({
374
+ ...baseInputConfiguration
375
+ }, props || {});
376
+ };
377
+ return /*#__PURE__*/_react.default.createElement(_configUi.layout.ConfigLayout, {
378
+ extraCSSRules: extraCSSRules,
379
+ dimensions: contentDimensions,
380
+ hideSettings: settingsPanelDisabled,
381
+ settings: /*#__PURE__*/_react.default.createElement(Panel, {
382
+ model: model,
383
+ onChangeModel: this.onModelChanged,
384
+ configuration: configuration,
385
+ onChangeConfiguration: onConfigurationChanged,
386
+ groups: {
387
+ Settings: panelSettings,
388
+ Properties: panelProperties
479
389
  },
480
- ref: this.divRef
481
- }), /*#__PURE__*/_react["default"].createElement("div", {
482
- style: {
483
- width: width || adjustedWidth
484
- }
485
- }, (scales || []).map(function (scale, scaleIndex) {
486
- return /*#__PURE__*/_react["default"].createElement(_scale["default"], (0, _extends2["default"])({
487
- key: "scale-".concat(scaleIndex),
488
- scale: scale,
489
- scaleIndex: scaleIndex,
490
- errors: errors,
491
- onScaleRemoved: _this2.onScaleRemoved,
492
- onScaleChanged: _this2.onScaleChanged,
493
- showStandards: standards,
494
- showScorePointLabels: pointLabels,
495
- showDescription: description,
496
- showLevelTagInput: showLevelTagInput.enabled,
390
+ modal: /*#__PURE__*/_react.default.createElement(ShowModal, {
391
+ showExcludeZeroDialog: showExcludeZeroDialog,
497
392
  excludeZero: excludeZero,
498
- enableDragAndDrop: dragAndDrop.enabled,
499
- spellCheck: spellCheckEnabled,
500
- width: adjustedWidth,
501
- uploadSoundSupport: uploadSoundSupport,
502
- maxPointsEnabled: maxPointsEnabled,
503
- maxNoOfTraits: maxNoOfTraits,
504
- minNoOfTraits: minNoOfTraits,
505
- imageSupport: imageSupport
506
- }, _this2.props, {
507
- classes: {},
508
- mathMlOptions: mathMlOptions,
509
- maxMaxPoints: maxMaxPoints,
510
- expandedPluginProps: getPluginProps(expandedInput === null || expandedInput === void 0 ? void 0 : expandedInput.inputConfiguration),
511
- labelPluginProps: getPluginProps(labelInput === null || labelInput === void 0 ? void 0 : labelInput.inputConfiguration)
512
- }));
513
- }), addScaleEnabled && /*#__PURE__*/_react["default"].createElement(_common.MultiTraitButton, {
514
- onClick: this.onScaleAdded
515
- }, "Add Scale")), /*#__PURE__*/_react["default"].createElement(_modals.InfoDialog, {
516
- open: showInfoDialog,
517
- text: infoDialogText,
518
- onClose: function onClose() {
519
- return _this2.set({
520
- showInfoDialog: false
521
- });
522
- }
523
- }));
524
- }
525
- }]);
526
- return Main;
527
- }(_react["default"].Component);
528
-
393
+ changeExcludeZero: this.changeExcludeZero,
394
+ cancel: this.hideToggleExcludeZeroModal
395
+ })
396
+ })
397
+ }, /*#__PURE__*/_react.default.createElement("div", {
398
+ style: {
399
+ width: '100%'
400
+ },
401
+ ref: this.divRef
402
+ }), /*#__PURE__*/_react.default.createElement(StyledDiv, {
403
+ style: {
404
+ width: width || adjustedWidth
405
+ }
406
+ }, (scales || []).map((scale, scaleIndex) => /*#__PURE__*/_react.default.createElement(_scale.default, (0, _extends2.default)({
407
+ key: `scale-${scaleIndex}`,
408
+ scale: scale,
409
+ scaleIndex: scaleIndex,
410
+ errors: errors,
411
+ onScaleRemoved: this.onScaleRemoved,
412
+ onScaleChanged: this.onScaleChanged,
413
+ showStandards: standards,
414
+ showScorePointLabels: pointLabels,
415
+ showDescription: description,
416
+ showLevelTagInput: showLevelTagInput.enabled,
417
+ excludeZero: excludeZero,
418
+ enableDragAndDrop: dragAndDrop.enabled,
419
+ spellCheck: spellCheckEnabled,
420
+ width: adjustedWidth,
421
+ uploadSoundSupport: uploadSoundSupport,
422
+ maxPointsEnabled: maxPointsEnabled,
423
+ maxNoOfTraits: maxNoOfTraits,
424
+ minNoOfTraits: minNoOfTraits,
425
+ imageSupport: imageSupport
426
+ }, this.props, {
427
+ mathMlOptions: mathMlOptions,
428
+ maxMaxPoints: maxMaxPoints,
429
+ expandedPluginProps: getPluginProps(expandedInput?.inputConfiguration),
430
+ labelPluginProps: getPluginProps(labelInput?.inputConfiguration)
431
+ }))), addScaleEnabled && /*#__PURE__*/_react.default.createElement(_common.MultiTraitButton, {
432
+ onClick: this.onScaleAdded
433
+ }, "Add Scale")), /*#__PURE__*/_react.default.createElement(_modals.InfoDialog, {
434
+ open: showInfoDialog,
435
+ text: infoDialogText,
436
+ onClose: () => this.set({
437
+ showInfoDialog: false
438
+ })
439
+ }));
440
+ }
441
+ }
529
442
  exports.Main = Main;
530
443
  Main.propTypes = {
531
- classes: _propTypes["default"].object,
532
- model: _propTypes["default"].object,
533
- uploadSoundSupport: _propTypes["default"].object,
534
- configuration: _propTypes["default"].object,
535
- onModelChanged: _propTypes["default"].func,
536
- onConfigurationChanged: _propTypes["default"].func,
537
- imageSupport: _propTypes["default"].shape({
538
- add: _propTypes["default"].func.isRequired,
539
- "delete": _propTypes["default"].func.isRequired
444
+ model: _propTypes.default.object,
445
+ uploadSoundSupport: _propTypes.default.object,
446
+ configuration: _propTypes.default.object,
447
+ onModelChanged: _propTypes.default.func,
448
+ onConfigurationChanged: _propTypes.default.func,
449
+ imageSupport: _propTypes.default.shape({
450
+ add: _propTypes.default.func.isRequired,
451
+ delete: _propTypes.default.func.isRequired
540
452
  })
541
453
  };
542
-
543
- var _default = (0, _drag.withDragContext)((0, _styles.withStyles)(styles)(Main));
544
-
545
- exports["default"] = _default;
454
+ var _default = exports.default = Main;
546
455
  //# sourceMappingURL=main.js.map