@pie-element/multi-trait-rubric 6.3.4-next.3 → 7.0.0-beta.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 (44) hide show
  1. package/CHANGELOG.md +0 -11
  2. package/configure/CHANGELOG.md +0 -11
  3. package/configure/lib/common.js +375 -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 +199 -264
  18. package/configure/lib/traitsHeader.js.map +1 -1
  19. package/configure/lib/utils.js +43 -74
  20. package/configure/lib/utils.js.map +1 -1
  21. package/configure/package.json +12 -9
  22. package/controller/lib/defaults.js +2 -3
  23. package/controller/lib/defaults.js.map +1 -1
  24. package/controller/lib/index.js +66 -123
  25. package/controller/lib/index.js.map +1 -1
  26. package/controller/lib/utils.js +1 -3
  27. package/controller/lib/utils.js.map +1 -1
  28. package/controller/package.json +1 -1
  29. package/lib/index.js +40 -77
  30. package/lib/index.js.map +1 -1
  31. package/lib/main.js +99 -140
  32. package/lib/main.js.map +1 -1
  33. package/lib/scale.js +217 -299
  34. package/lib/scale.js.map +1 -1
  35. package/lib/trait.js +51 -71
  36. package/lib/trait.js.map +1 -1
  37. package/package.json +10 -8
  38. package/esm/configure.js +0 -30404
  39. package/esm/configure.js.map +0 -1
  40. package/esm/controller.js +0 -176
  41. package/esm/controller.js.map +0 -1
  42. package/esm/element.js +0 -11204
  43. package/esm/element.js.map +0 -1
  44. package/esm/package.json +0 -3
@@ -1,95 +1,36 @@
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.Scale = void 0;
9
-
10
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
-
12
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
-
14
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
-
16
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
17
-
18
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
19
-
20
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
21
-
22
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
23
-
7
+ exports.default = exports.Scale = void 0;
24
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
25
-
26
9
  var _react = _interopRequireDefault(require("react"));
27
-
28
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
29
-
30
- var _styles = require("@material-ui/core/styles");
31
-
32
- var _ArrowBackIos = _interopRequireDefault(require("@material-ui/icons/ArrowBackIos"));
33
-
34
- var _ArrowForwardIos = _interopRequireDefault(require("@material-ui/icons/ArrowForwardIos"));
35
-
11
+ var _styles = require("@mui/material/styles");
12
+ var _ArrowBackIos = _interopRequireDefault(require("@mui/icons-material/ArrowBackIos"));
13
+ var _ArrowForwardIos = _interopRequireDefault(require("@mui/icons-material/ArrowForwardIos"));
36
14
  var _drag = require("@pie-lib/drag");
37
-
38
- var _renderUi = require("@pie-lib/render-ui");
39
-
40
15
  var _traitsHeader = _interopRequireDefault(require("./traitsHeader"));
41
-
42
16
  var _trait = _interopRequireDefault(require("./trait"));
43
-
44
17
  var _common = require("./common");
45
-
46
18
  var _modals = require("./modals");
47
-
48
- 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); }; }
49
-
50
- 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; } }
51
-
52
- var AdjustedBlockWidth = _common.BlockWidth + 2 * 8; // 8 is padding
53
-
54
- var styles = function styles(theme) {
55
- return {
56
- scaleWrapper: {
57
- display: 'flex',
58
- flexDirection: 'column',
59
- wordBreak: 'break-word',
60
- position: 'relative',
61
- marginBottom: theme.spacing.unit * 2.5
62
- },
63
- maxPoints: {
64
- width: '300px',
65
- marginTop: theme.spacing.unit * 2,
66
- marginBottom: theme.spacing.unit * 4
67
- },
68
- trait: {
69
- background: _renderUi.color.secondaryBackground(),
70
- marginTop: theme.spacing.unit * 2,
71
- marginBottom: theme.spacing.unit * 2,
72
- padding: theme.spacing.unit * 2
73
- }
74
- };
75
- };
76
-
77
- var Scale = /*#__PURE__*/function (_React$Component) {
78
- (0, _inherits2["default"])(Scale, _React$Component);
79
-
80
- var _super = _createSuper(Scale);
81
-
82
- function Scale() {
83
- var _this;
84
-
85
- (0, _classCallCheck2["default"])(this, Scale);
86
-
87
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
88
- args[_key] = arguments[_key];
89
- }
90
-
91
- _this = _super.call.apply(_super, [this].concat(args));
92
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
19
+ const AdjustedBlockWidth = _common.BlockWidth + 2 * 8; // 8 is padding
20
+
21
+ const ScaleWrapper = (0, _styles.styled)('div')(({
22
+ theme
23
+ }) => ({
24
+ display: 'flex',
25
+ flexDirection: 'column',
26
+ wordBreak: 'break-word',
27
+ position: 'relative',
28
+ marginBottom: theme.spacing(2.5)
29
+ }));
30
+ class Scale extends _react.default.Component {
31
+ constructor(...args) {
32
+ super(...args);
33
+ (0, _defineProperty2.default)(this, "state", {
93
34
  showDecreaseMaxPointsDialog: false,
94
35
  showDeleteScaleDialog: false,
95
36
  showDeleteTraitDialog: false,
@@ -99,28 +40,27 @@ var Scale = /*#__PURE__*/function (_React$Component) {
99
40
  showInfoDialog: false,
100
41
  infoDialogText: ''
101
42
  });
102
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "set", function (newState) {
103
- return _this.setState(newState);
104
- });
105
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "updateMaxPointsFieldValue", function (_ref) {
106
- var target = _ref.target;
107
-
108
- var _ref2 = _this.props || {},
109
- scale = _ref2.scale,
110
- scaleIndex = _ref2.scaleIndex,
111
- onScaleChanged = _ref2.onScaleChanged;
112
-
113
- var maxPoints = scale.maxPoints;
114
- var numberValue = parseInt(target.value, 10);
115
-
116
- _this.setState({
43
+ (0, _defineProperty2.default)(this, "set", newState => this.setState(newState));
44
+ // Max Points
45
+ (0, _defineProperty2.default)(this, "updateMaxPointsFieldValue", ({
46
+ target
47
+ }) => {
48
+ const {
49
+ scale,
50
+ scaleIndex,
51
+ onScaleChanged
52
+ } = this.props || {};
53
+ const {
54
+ maxPoints
55
+ } = scale;
56
+ const numberValue = parseInt(target.value, 10);
57
+ this.setState({
117
58
  currentPosition: 0,
118
59
  showLeft: false,
119
- showRight: _this.secondaryBlockRef && _this.secondaryBlockRef.scrollWidth - _this.secondaryBlockRef.offsetWidth
60
+ showRight: this.secondaryBlockRef && this.secondaryBlockRef.scrollWidth - this.secondaryBlockRef.offsetWidth
120
61
  });
121
-
122
62
  if (numberValue < maxPoints) {
123
- _this.showDecreaseMaxPointsModal({
63
+ this.showDecreaseMaxPointsModal({
124
64
  newMaxPoints: numberValue
125
65
  });
126
66
  } else {
@@ -129,428 +69,383 @@ var Scale = /*#__PURE__*/function (_React$Component) {
129
69
  });
130
70
  }
131
71
  });
132
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "showDecreaseMaxPointsModal", function (_ref3) {
133
- var newMaxPoints = _ref3.newMaxPoints;
134
- return _this.set({
135
- showDecreaseMaxPointsDialog: true,
136
- newMaxPoints: newMaxPoints
137
- });
138
- });
139
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "hideDecreaseMaxPointsModal", function () {
140
- return _this.set({
141
- showDecreaseMaxPointsDialog: false,
142
- newMaxPoints: undefined
143
- });
144
- });
145
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeMaxPoints", function () {
146
- var _ref4 = _this.state || {},
147
- newMaxPoints = _ref4.newMaxPoints;
148
-
149
- var _ref5 = _this.props || {},
150
- scaleIndex = _ref5.scaleIndex,
151
- onScaleChanged = _ref5.onScaleChanged;
152
-
72
+ (0, _defineProperty2.default)(this, "showDecreaseMaxPointsModal", ({
73
+ newMaxPoints
74
+ }) => this.set({
75
+ showDecreaseMaxPointsDialog: true,
76
+ newMaxPoints
77
+ }));
78
+ (0, _defineProperty2.default)(this, "hideDecreaseMaxPointsModal", () => this.set({
79
+ showDecreaseMaxPointsDialog: false,
80
+ newMaxPoints: undefined
81
+ }));
82
+ (0, _defineProperty2.default)(this, "changeMaxPoints", () => {
83
+ const {
84
+ newMaxPoints
85
+ } = this.state || {};
86
+ const {
87
+ scaleIndex,
88
+ onScaleChanged
89
+ } = this.props || {};
153
90
  if (newMaxPoints) {
154
91
  onScaleChanged(scaleIndex, {
155
92
  maxPoints: newMaxPoints
156
93
  });
157
94
  }
158
-
159
- _this.hideDecreaseMaxPointsModal();
160
- });
161
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "showDeleteScaleModal", function () {
162
- return _this.set({
163
- showDeleteScaleDialog: true
164
- });
165
- });
166
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "hideDeleteScaleModal", function () {
167
- return _this.set({
168
- showDeleteScaleDialog: false
169
- });
95
+ this.hideDecreaseMaxPointsModal();
170
96
  });
171
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "deleteScale", function () {
172
- var _ref6 = _this.props || {},
173
- scaleIndex = _ref6.scaleIndex,
174
- onScaleRemoved = _ref6.onScaleRemoved;
175
-
176
- _this.hideDeleteScaleModal();
177
-
97
+ // Delete Scale
98
+ (0, _defineProperty2.default)(this, "showDeleteScaleModal", () => this.set({
99
+ showDeleteScaleDialog: true
100
+ }));
101
+ (0, _defineProperty2.default)(this, "hideDeleteScaleModal", () => this.set({
102
+ showDeleteScaleDialog: false
103
+ }));
104
+ (0, _defineProperty2.default)(this, "deleteScale", () => {
105
+ const {
106
+ scaleIndex,
107
+ onScaleRemoved
108
+ } = this.props || {};
109
+ this.hideDeleteScaleModal();
178
110
  onScaleRemoved(scaleIndex);
179
111
  });
180
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "showDeleteTraitModal", function (traitToDeleteIndex) {
181
- return _this.set({
182
- showDeleteTraitDialog: true,
183
- traitToDeleteIndex: traitToDeleteIndex
184
- });
185
- });
186
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "hideDeleteTraitModal", function () {
187
- return _this.set({
188
- showDeleteTraitDialog: false,
189
- traitToDeleteIndex: undefined
190
- });
191
- });
192
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onTraitRemoved", function () {
193
- var traitToDeleteIndex = _this.state.traitToDeleteIndex;
194
-
195
- var _ref7 = _this.props || {},
196
- scale = _ref7.scale,
197
- scaleIndex = _ref7.scaleIndex,
198
- onScaleChanged = _ref7.onScaleChanged,
199
- minNoOfTraits = _ref7.minNoOfTraits;
200
-
201
- var _ref8 = scale || {},
202
- traits = _ref8.traits,
203
- traitLabel = _ref8.traitLabel;
204
-
112
+ // Delete Trait
113
+ (0, _defineProperty2.default)(this, "showDeleteTraitModal", traitToDeleteIndex => this.set({
114
+ showDeleteTraitDialog: true,
115
+ traitToDeleteIndex
116
+ }));
117
+ (0, _defineProperty2.default)(this, "hideDeleteTraitModal", () => this.set({
118
+ showDeleteTraitDialog: false,
119
+ traitToDeleteIndex: undefined
120
+ }));
121
+ (0, _defineProperty2.default)(this, "onTraitRemoved", () => {
122
+ const {
123
+ traitToDeleteIndex
124
+ } = this.state;
125
+ const {
126
+ scale,
127
+ scaleIndex,
128
+ onScaleChanged,
129
+ minNoOfTraits
130
+ } = this.props || {};
131
+ let {
132
+ traits,
133
+ traitLabel
134
+ } = scale || {};
205
135
  if (traitToDeleteIndex < 0 || traitToDeleteIndex >= traits.length) return;
206
-
207
136
  if (traits.length === minNoOfTraits) {
208
- _this.set({
209
- infoDialogText: "There can't be less than ".concat(minNoOfTraits, " ").concat((traitLabel || 'trait').toLowerCase(), "s."),
137
+ this.set({
138
+ infoDialogText: `There can't be less than ${minNoOfTraits} ${(traitLabel || 'trait').toLowerCase()}s.`,
210
139
  showInfoDialog: true
211
140
  });
212
-
213
141
  return false;
214
142
  }
215
-
216
- traits = [].concat((0, _toConsumableArray2["default"])(traits.slice(0, traitToDeleteIndex)), (0, _toConsumableArray2["default"])(traits.slice(traitToDeleteIndex + 1)));
143
+ traits = [...traits.slice(0, traitToDeleteIndex), ...traits.slice(traitToDeleteIndex + 1)];
217
144
  onScaleChanged(scaleIndex, {
218
- traits: traits
145
+ traits
219
146
  });
220
-
221
- _this.hideDeleteTraitModal();
147
+ this.hideDeleteTraitModal();
222
148
  });
223
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onTraitAdded", function () {
224
- var _ref9 = _this.props || {},
225
- scale = _ref9.scale,
226
- scaleIndex = _ref9.scaleIndex,
227
- onScaleChanged = _ref9.onScaleChanged,
228
- maxNoOfTraits = _ref9.maxNoOfTraits;
229
-
230
- var _ref10 = scale || {},
231
- traits = _ref10.traits,
232
- scorePointsLabels = _ref10.scorePointsLabels;
233
-
149
+ (0, _defineProperty2.default)(this, "onTraitAdded", () => {
150
+ const {
151
+ scale,
152
+ scaleIndex,
153
+ onScaleChanged,
154
+ maxNoOfTraits
155
+ } = this.props || {};
156
+ const {
157
+ traits,
158
+ scorePointsLabels
159
+ } = scale || {};
234
160
  if (traits.length === maxNoOfTraits) {
235
- _this.set({
236
- infoDialogText: "There can't be more than ".concat(maxNoOfTraits, " scales."),
161
+ this.set({
162
+ infoDialogText: `There can't be more than ${maxNoOfTraits} scales.`,
237
163
  showInfoDialog: true
238
164
  });
239
-
240
165
  return false;
241
166
  }
242
-
243
167
  traits.push({
244
168
  name: '',
245
169
  description: '',
246
170
  standards: [],
247
171
  scorePointsDescriptors: Array.from({
248
172
  length: scorePointsLabels.length
249
- }, function () {
250
- return '';
251
- })
173
+ }, () => '')
252
174
  });
253
175
  onScaleChanged(scaleIndex, {
254
- traits: traits
176
+ traits
255
177
  });
256
178
  });
257
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onTraitChanged", function (traitIndex, trait) {
258
- var _ref11 = _this.props || {},
259
- scale = _ref11.scale,
260
- scaleIndex = _ref11.scaleIndex,
261
- onScaleChanged = _ref11.onScaleChanged;
262
-
263
- var _ref12 = scale || {},
264
- traits = _ref12.traits;
265
-
179
+ (0, _defineProperty2.default)(this, "onTraitChanged", (traitIndex, trait) => {
180
+ const {
181
+ scale,
182
+ scaleIndex,
183
+ onScaleChanged
184
+ } = this.props || {};
185
+ const {
186
+ traits
187
+ } = scale || {};
266
188
  if (traitIndex >= 0 && traitIndex < traits.length) {
267
189
  traits[traitIndex] = trait;
268
190
  onScaleChanged(scaleIndex, {
269
- traits: traits
191
+ traits
270
192
  });
271
193
  }
272
194
  });
273
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onTraitDropped", function (source, newIndex) {
274
- var _ref13 = _this.props || {},
275
- scale = _ref13.scale,
276
- scaleIndex = _ref13.scaleIndex,
277
- onScaleChanged = _ref13.onScaleChanged;
278
-
279
- var _ref14 = scale || {},
280
- traits = _ref14.traits;
281
-
282
- var oldIndex = source.index;
283
- var cup = traits[oldIndex];
284
- var remainingTraits = traits.filter(function (item, index) {
285
- return index !== oldIndex;
286
- });
287
- var newTraits = [].concat((0, _toConsumableArray2["default"])(remainingTraits.slice(0, newIndex)), [cup], (0, _toConsumableArray2["default"])(remainingTraits.slice(newIndex)));
288
- onScaleChanged(scaleIndex, {
289
- traits: newTraits
290
- });
195
+ (0, _defineProperty2.default)(this, "onTraitDropped", event => {
196
+ const {
197
+ active,
198
+ over
199
+ } = event;
200
+ if (!over || !active) return;
201
+ const activeData = active.data.current;
202
+ const overData = over.data.current;
203
+ if (activeData?.type === 'trait' && overData?.type === 'trait') {
204
+ const oldIndex = activeData.index;
205
+ const newIndex = overData.index;
206
+ if (oldIndex === newIndex) return;
207
+ const {
208
+ scale,
209
+ scaleIndex,
210
+ onScaleChanged
211
+ } = this.props || {};
212
+ const {
213
+ traits
214
+ } = scale || {};
215
+ const cup = traits[oldIndex];
216
+ const remainingTraits = traits.filter((item, index) => index !== oldIndex);
217
+ const newTraits = [...remainingTraits.slice(0, newIndex), cup, ...remainingTraits.slice(newIndex)];
218
+ onScaleChanged(scaleIndex, {
219
+ traits: newTraits
220
+ });
221
+ }
291
222
  });
292
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "decreasePosition", function () {
293
- var currentPosition = _this.state.currentPosition;
294
- var decreasedPosition = currentPosition - (currentPosition === AdjustedBlockWidth / 2 ? AdjustedBlockWidth / 2 : AdjustedBlockWidth);
295
-
296
- _this.setState({
223
+ (0, _defineProperty2.default)(this, "decreasePosition", () => {
224
+ const {
225
+ currentPosition
226
+ } = this.state;
227
+ const decreasedPosition = currentPosition - (currentPosition === AdjustedBlockWidth / 2 ? AdjustedBlockWidth / 2 : AdjustedBlockWidth);
228
+ this.setState({
297
229
  currentPosition: decreasedPosition,
298
- showRight: decreasedPosition < _this.secondaryBlockRef.scrollWidth - _this.secondaryBlockRef.offsetWidth,
230
+ showRight: decreasedPosition < this.secondaryBlockRef.scrollWidth - this.secondaryBlockRef.offsetWidth,
299
231
  showLeft: decreasedPosition > 0
300
232
  });
301
233
  });
302
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "increasePosition", function () {
303
- var currentPosition = _this.state.currentPosition;
304
- var increasedPosition = currentPosition + (currentPosition === 0 ? AdjustedBlockWidth / 2 : AdjustedBlockWidth);
305
-
306
- _this.setState({
234
+ (0, _defineProperty2.default)(this, "increasePosition", () => {
235
+ const {
236
+ currentPosition
237
+ } = this.state;
238
+ const increasedPosition = currentPosition + (currentPosition === 0 ? AdjustedBlockWidth / 2 : AdjustedBlockWidth);
239
+ this.setState({
307
240
  currentPosition: increasedPosition,
308
- showRight: increasedPosition < _this.secondaryBlockRef.scrollWidth - _this.secondaryBlockRef.offsetWidth,
241
+ showRight: increasedPosition < this.secondaryBlockRef.scrollWidth - this.secondaryBlockRef.offsetWidth,
309
242
  showLeft: increasedPosition > 0
310
243
  });
311
244
  });
312
- return _this;
313
245
  }
314
-
315
- (0, _createClass2["default"])(Scale, [{
316
- key: "componentDidMount",
317
- value: function componentDidMount() {
318
- if (this.state.showRight === null && this.secondaryBlockRef) {
319
- this.setState({
320
- showRight: this.secondaryBlockRef.scrollWidth - this.secondaryBlockRef.offsetWidth
321
- });
322
- }
246
+ componentDidMount() {
247
+ if (this.state.showRight === null && this.secondaryBlockRef) {
248
+ this.setState({
249
+ showRight: this.secondaryBlockRef.scrollWidth - this.secondaryBlockRef.offsetWidth
250
+ });
323
251
  }
324
- }, {
325
- key: "componentDidUpdate",
326
- value: function componentDidUpdate(prevProps) {
327
- if (prevProps.scale.maxPoints !== this.props.scale.maxPoints || prevProps.showDescription !== this.props.showDescription || prevProps.excludeZero !== this.props.excludeZero) {
328
- this.setState({
329
- showRight: this.secondaryBlockRef.scrollWidth - this.secondaryBlockRef.offsetWidth
330
- });
331
- }
252
+ }
253
+ componentDidUpdate(prevProps) {
254
+ if (prevProps.scale.maxPoints !== this.props.scale.maxPoints || prevProps.showDescription !== this.props.showDescription || prevProps.excludeZero !== this.props.excludeZero) {
255
+ this.setState({
256
+ showRight: this.secondaryBlockRef.scrollWidth - this.secondaryBlockRef.offsetWidth
257
+ });
332
258
  }
333
- }, {
334
- key: "UNSAFE_componentWillReceiveProps",
335
- value: function UNSAFE_componentWillReceiveProps(nextProps) {
336
- if (nextProps.excludeZero !== this.props.excludeZero || nextProps.showStandards !== this.props.showStandards || nextProps.showDescription !== this.props.showDescription) {
337
- this.setState({
338
- currentPosition: 0,
339
- showLeft: false,
340
- showRight: this.secondaryBlockRef && this.secondaryBlockRef.scrollWidth - this.secondaryBlockRef.offsetWidth
341
- });
342
- }
343
- } // Max Points
344
-
345
- }, {
346
- key: "render",
347
- value: function render() {
348
- var _this2 = this;
349
-
350
- var _ref15 = this.props || {},
351
- classes = _ref15.classes,
352
- errors = _ref15.errors,
353
- scale = _ref15.scale,
354
- scaleIndex = _ref15.scaleIndex,
355
- showStandards = _ref15.showStandards,
356
- onScaleChanged = _ref15.onScaleChanged,
357
- excludeZero = _ref15.excludeZero,
358
- showDescription = _ref15.showDescription,
359
- showLevelTagInput = _ref15.showLevelTagInput,
360
- showScorePointLabels = _ref15.showScorePointLabels,
361
- enableDragAndDrop = _ref15.enableDragAndDrop,
362
- spellCheck = _ref15.spellCheck,
363
- width = _ref15.width,
364
- uploadSoundSupport = _ref15.uploadSoundSupport,
365
- maxPointsEnabled = _ref15.maxPointsEnabled,
366
- _ref15$mathMlOptions = _ref15.mathMlOptions,
367
- mathMlOptions = _ref15$mathMlOptions === void 0 ? {} : _ref15$mathMlOptions,
368
- maxMaxPoints = _ref15.maxMaxPoints,
369
- _ref15$expandedPlugin = _ref15.expandedPluginProps,
370
- expandedPluginProps = _ref15$expandedPlugin === void 0 ? {} : _ref15$expandedPlugin,
371
- _ref15$labelPluginPro = _ref15.labelPluginProps,
372
- labelPluginProps = _ref15$labelPluginPro === void 0 ? {} : _ref15$labelPluginPro,
373
- _ref15$imageSupport = _ref15.imageSupport,
374
- imageSupport = _ref15$imageSupport === void 0 ? {} : _ref15$imageSupport;
375
-
376
- var _ref16 = scale || {},
377
- maxPoints = _ref16.maxPoints,
378
- scorePointsLabels = _ref16.scorePointsLabels,
379
- traitLabel = _ref16.traitLabel,
380
- traits = _ref16.traits;
381
-
382
- var _this$state = this.state,
383
- showDecreaseMaxPointsDialog = _this$state.showDecreaseMaxPointsDialog,
384
- showDeleteScaleDialog = _this$state.showDeleteScaleDialog,
385
- showDeleteTraitDialog = _this$state.showDeleteTraitDialog,
386
- currentPosition = _this$state.currentPosition,
387
- showRight = _this$state.showRight,
388
- showLeft = _this$state.showLeft,
389
- showInfoDialog = _this$state.showInfoDialog,
390
- infoDialogText = _this$state.infoDialogText;
391
-
392
- var _ref17 = errors || {},
393
- traitsErrors = _ref17.traitsErrors,
394
- scorePointsErrors = _ref17.scorePointsErrors;
395
-
396
- var currentScaleTraitsErrors = traitsErrors && traitsErrors[scaleIndex] || {};
397
- var currentScalePointsLabelsErrors = scorePointsErrors && scorePointsErrors[scaleIndex] || {};
398
- var scorePointsValues = [];
399
- var secondaryBlockWidth = parseInt(width) - _common.DragHandleSpace - _common.PrimaryBlockWidth || 320; // 320 is minWidth
400
- // determining the score points values
401
-
402
- for (var pointValue = maxPoints; pointValue >= excludeZero ? 1 : 0; pointValue -= 1) {
403
- scorePointsValues.push(pointValue);
259
+ }
260
+ UNSAFE_componentWillReceiveProps(nextProps) {
261
+ if (nextProps.excludeZero !== this.props.excludeZero || nextProps.showStandards !== this.props.showStandards || nextProps.showDescription !== this.props.showDescription) {
262
+ this.setState({
263
+ currentPosition: 0,
264
+ showLeft: false,
265
+ showRight: this.secondaryBlockRef && this.secondaryBlockRef.scrollWidth - this.secondaryBlockRef.offsetWidth
266
+ });
267
+ }
268
+ }
269
+ render() {
270
+ const {
271
+ errors,
272
+ scale,
273
+ scaleIndex,
274
+ showStandards,
275
+ onScaleChanged,
276
+ excludeZero,
277
+ showDescription,
278
+ showLevelTagInput,
279
+ showScorePointLabels,
280
+ enableDragAndDrop,
281
+ spellCheck,
282
+ width,
283
+ uploadSoundSupport,
284
+ maxPointsEnabled,
285
+ mathMlOptions = {},
286
+ maxMaxPoints,
287
+ expandedPluginProps = {},
288
+ labelPluginProps = {},
289
+ imageSupport = {}
290
+ } = this.props || {};
291
+ const {
292
+ maxPoints,
293
+ scorePointsLabels,
294
+ traitLabel,
295
+ traits
296
+ } = scale || {};
297
+ const {
298
+ showDecreaseMaxPointsDialog,
299
+ showDeleteScaleDialog,
300
+ showDeleteTraitDialog,
301
+ currentPosition,
302
+ showRight,
303
+ showLeft,
304
+ showInfoDialog,
305
+ infoDialogText
306
+ } = this.state;
307
+ const {
308
+ traitsErrors,
309
+ scorePointsErrors
310
+ } = errors || {};
311
+ const currentScaleTraitsErrors = traitsErrors && traitsErrors[scaleIndex] || {};
312
+ const currentScalePointsLabelsErrors = scorePointsErrors && scorePointsErrors[scaleIndex] || {};
313
+ const scorePointsValues = [];
314
+ const secondaryBlockWidth = parseInt(width) - _common.DragHandleSpace - _common.PrimaryBlockWidth || 320; // 320 is minWidth
315
+
316
+ // determining the score points values
317
+ for (let pointValue = maxPoints; pointValue >= excludeZero ? 1 : 0; pointValue -= 1) {
318
+ scorePointsValues.push(pointValue);
319
+ }
320
+ return /*#__PURE__*/_react.default.createElement(_drag.DragProvider, {
321
+ onDragEnd: this.onTraitDropped
322
+ }, /*#__PURE__*/_react.default.createElement(ScaleWrapper, {
323
+ key: `scale-${scaleIndex}`,
324
+ ref: ref => {
325
+ this.scaleWrapper = ref;
404
326
  }
405
-
406
- return /*#__PURE__*/_react["default"].createElement("div", {
407
- key: "scale-".concat(scaleIndex),
408
- className: classes.scaleWrapper,
409
- ref: function ref(_ref18) {
410
- _this2.scaleWrapper = _ref18;
411
- }
412
- }, /*#__PURE__*/_react["default"].createElement(_traitsHeader["default"], {
413
- setSecondaryBlockRef: function setSecondaryBlockRef(ref) {
414
- if (ref) {
415
- _this2.secondaryBlockRef = ref;
416
- }
417
- },
418
- key: 'header-key',
419
- errors: currentScalePointsLabelsErrors,
420
- traitLabel: traitLabel,
421
- scorePointsValues: scorePointsValues,
422
- scorePointsLabels: scorePointsLabels,
423
- onScaleChange: function onScaleChange(params) {
424
- return onScaleChanged(scaleIndex, params);
425
- },
426
- onTraitLabelChange: function onTraitLabelChange(label) {
427
- return onScaleChanged(scaleIndex, {
428
- traitLabel: label
429
- });
430
- },
431
- showStandards: showStandards,
432
- showDescription: showDescription,
433
- showLevelTagInput: showLevelTagInput,
434
- showScorePointLabels: showScorePointLabels,
435
- maxPoints: maxPoints,
436
- updateMaxPointsFieldValue: this.updateMaxPointsFieldValue,
437
- scaleIndex: scaleIndex,
438
- showDeleteScaleModal: this.showDeleteScaleModal,
439
- currentPosition: currentPosition,
440
- secondaryBlockWidth: secondaryBlockWidth,
441
- spellCheck: spellCheck,
442
- uploadSoundSupport: uploadSoundSupport,
443
- maxPointsEnabled: maxPointsEnabled,
444
- mathMlOptions: mathMlOptions,
445
- maxMaxPoints: maxMaxPoints,
446
- expandedPluginProps: expandedPluginProps,
447
- labelPluginProps: labelPluginProps,
448
- imageSupport: imageSupport
449
- }), traits.map(function (trait, index) {
450
- return /*#__PURE__*/_react["default"].createElement(_trait["default"], {
451
- key: index,
452
- index: index,
453
- error: currentScaleTraitsErrors && currentScaleTraitsErrors[index],
454
- trait: trait,
455
- traitLabel: traitLabel || 'Trait',
456
- scorePointsValues: scorePointsValues,
457
- scorePointsLabels: scorePointsLabels,
458
- onTraitRemoved: function onTraitRemoved() {
459
- return _this2.showDeleteTraitModal(index);
460
- },
461
- onTraitChanged: function onTraitChanged(trait) {
462
- return _this2.onTraitChanged(index, trait);
463
- },
464
- onTraitDropped: _this2.onTraitDropped,
465
- showStandards: showStandards,
466
- showDescription: showDescription,
467
- maxPoints: maxPoints,
468
- currentPosition: currentPosition,
469
- enableDragAndDrop: enableDragAndDrop,
470
- secondaryBlockWidth: secondaryBlockWidth,
471
- spellCheck: spellCheck,
472
- uploadSoundSupport: uploadSoundSupport,
473
- mathMlOptions: mathMlOptions,
474
- expandedPluginProps: expandedPluginProps,
475
- labelPluginProps: labelPluginProps,
476
- imageSupport: imageSupport
477
- });
478
- }), /*#__PURE__*/_react["default"].createElement(_common.Arrow, {
479
- width: "".concat(AdjustedBlockWidth / 2, "px"),
480
- show: showLeft,
481
- onClick: this.decreasePosition,
482
- left: "".concat(_common.PrimaryBlockWidth, "px"),
483
- showLevelTagInput: showLevelTagInput
484
- }, /*#__PURE__*/_react["default"].createElement(_ArrowBackIos["default"], null)), /*#__PURE__*/_react["default"].createElement(_common.Arrow, {
485
- width: "".concat(AdjustedBlockWidth / 2, "px"),
486
- show: showRight,
487
- onClick: this.increasePosition,
488
- showLevelTagInput: showLevelTagInput
489
- }, /*#__PURE__*/_react["default"].createElement(_ArrowForwardIos["default"], null)), /*#__PURE__*/_react["default"].createElement(_common.MultiTraitButton, {
490
- onClick: this.onTraitAdded
491
- }, /*#__PURE__*/_react["default"].createElement("div", {
492
- dangerouslySetInnerHTML: {
493
- __html: "Add ".concat(traitLabel || ' Trait')
327
+ }, /*#__PURE__*/_react.default.createElement(_traitsHeader.default, {
328
+ setSecondaryBlockRef: ref => {
329
+ if (ref) {
330
+ this.secondaryBlockRef = ref;
494
331
  }
495
- })), /*#__PURE__*/_react["default"].createElement(_modals.DecreaseMaxPoints, {
496
- open: !!showDecreaseMaxPointsDialog,
497
- deleteScorePoints: this.changeMaxPoints,
498
- cancel: this.hideDecreaseMaxPointsModal
499
- }), /*#__PURE__*/_react["default"].createElement(_modals.DeleteScale, {
500
- open: !!showDeleteScaleDialog,
501
- scaleIndex: scaleIndex,
502
- deleteScale: this.deleteScale,
503
- cancel: this.hideDeleteScaleModal
504
- }), /*#__PURE__*/_react["default"].createElement(_modals.DeleteTrait, {
505
- open: !!showDeleteTraitDialog,
506
- deleteTrait: this.onTraitRemoved,
507
- cancel: this.hideDeleteTraitModal,
508
- traitLabel: traitLabel.toLowerCase()
509
- }), /*#__PURE__*/_react["default"].createElement(_modals.InfoDialog, {
510
- open: showInfoDialog,
511
- text: infoDialogText,
512
- onClose: function onClose() {
513
- return _this2.set({
514
- showInfoDialog: false
515
- });
516
- }
517
- }));
518
- }
519
- }]);
520
- return Scale;
521
- }(_react["default"].Component);
522
-
332
+ },
333
+ key: 'header-key',
334
+ errors: currentScalePointsLabelsErrors,
335
+ traitLabel: traitLabel,
336
+ scorePointsValues: scorePointsValues,
337
+ scorePointsLabels: scorePointsLabels,
338
+ onScaleChange: params => onScaleChanged(scaleIndex, params),
339
+ onTraitLabelChange: label => onScaleChanged(scaleIndex, {
340
+ traitLabel: label
341
+ }),
342
+ showStandards: showStandards,
343
+ showDescription: showDescription,
344
+ showLevelTagInput: showLevelTagInput,
345
+ showScorePointLabels: showScorePointLabels,
346
+ maxPoints: maxPoints,
347
+ updateMaxPointsFieldValue: this.updateMaxPointsFieldValue,
348
+ scaleIndex: scaleIndex,
349
+ showDeleteScaleModal: this.showDeleteScaleModal,
350
+ currentPosition: currentPosition,
351
+ secondaryBlockWidth: secondaryBlockWidth,
352
+ spellCheck: spellCheck,
353
+ uploadSoundSupport: uploadSoundSupport,
354
+ maxPointsEnabled: maxPointsEnabled,
355
+ mathMlOptions: mathMlOptions,
356
+ maxMaxPoints: maxMaxPoints,
357
+ expandedPluginProps: expandedPluginProps,
358
+ labelPluginProps: labelPluginProps,
359
+ imageSupport: imageSupport
360
+ }), traits.map((trait, index) => /*#__PURE__*/_react.default.createElement(_trait.default, {
361
+ key: index,
362
+ index: index,
363
+ error: currentScaleTraitsErrors && currentScaleTraitsErrors[index],
364
+ trait: trait,
365
+ traitLabel: traitLabel || 'Trait',
366
+ scorePointsValues: scorePointsValues,
367
+ scorePointsLabels: scorePointsLabels,
368
+ onTraitRemoved: () => this.showDeleteTraitModal(index),
369
+ onTraitChanged: trait => this.onTraitChanged(index, trait),
370
+ showStandards: showStandards,
371
+ showDescription: showDescription,
372
+ maxPoints: maxPoints,
373
+ currentPosition: currentPosition,
374
+ enableDragAndDrop: enableDragAndDrop,
375
+ secondaryBlockWidth: secondaryBlockWidth,
376
+ spellCheck: spellCheck,
377
+ uploadSoundSupport: uploadSoundSupport,
378
+ mathMlOptions: mathMlOptions,
379
+ expandedPluginProps: expandedPluginProps,
380
+ labelPluginProps: labelPluginProps,
381
+ imageSupport: imageSupport
382
+ })), /*#__PURE__*/_react.default.createElement(_common.Arrow, {
383
+ width: `${AdjustedBlockWidth / 2}px`,
384
+ show: showLeft,
385
+ onClick: this.decreasePosition,
386
+ left: `${_common.PrimaryBlockWidth}px`,
387
+ showLevelTagInput: showLevelTagInput
388
+ }, /*#__PURE__*/_react.default.createElement(_ArrowBackIos.default, null)), /*#__PURE__*/_react.default.createElement(_common.Arrow, {
389
+ width: `${AdjustedBlockWidth / 2}px`,
390
+ show: showRight,
391
+ onClick: this.increasePosition,
392
+ showLevelTagInput: showLevelTagInput
393
+ }, /*#__PURE__*/_react.default.createElement(_ArrowForwardIos.default, null)), /*#__PURE__*/_react.default.createElement(_common.MultiTraitButton, {
394
+ onClick: this.onTraitAdded
395
+ }, /*#__PURE__*/_react.default.createElement("div", {
396
+ dangerouslySetInnerHTML: {
397
+ __html: `Add ${traitLabel || ' Trait'}`
398
+ }
399
+ })), /*#__PURE__*/_react.default.createElement(_modals.DecreaseMaxPoints, {
400
+ open: !!showDecreaseMaxPointsDialog,
401
+ deleteScorePoints: this.changeMaxPoints,
402
+ cancel: this.hideDecreaseMaxPointsModal
403
+ }), /*#__PURE__*/_react.default.createElement(_modals.DeleteScale, {
404
+ open: !!showDeleteScaleDialog,
405
+ scaleIndex: scaleIndex,
406
+ deleteScale: this.deleteScale,
407
+ cancel: this.hideDeleteScaleModal
408
+ }), /*#__PURE__*/_react.default.createElement(_modals.DeleteTrait, {
409
+ open: !!showDeleteTraitDialog,
410
+ deleteTrait: this.onTraitRemoved,
411
+ cancel: this.hideDeleteTraitModal,
412
+ traitLabel: traitLabel.toLowerCase()
413
+ }), /*#__PURE__*/_react.default.createElement(_modals.InfoDialog, {
414
+ open: showInfoDialog,
415
+ text: infoDialogText,
416
+ onClose: () => this.set({
417
+ showInfoDialog: false
418
+ })
419
+ })));
420
+ }
421
+ }
523
422
  exports.Scale = Scale;
524
423
  Scale.propTypes = {
525
- classes: _propTypes["default"].object,
526
- errors: _propTypes["default"].object,
527
- scale: _propTypes["default"].shape({
528
- maxPoints: _propTypes["default"].number,
529
- scorePointsLabels: _propTypes["default"].arrayOf(_propTypes["default"].string),
530
- traitLabel: _propTypes["default"].string,
531
- traits: _propTypes["default"].arrayOf(_propTypes["default"].shape({
532
- name: _propTypes["default"].string,
533
- standards: _propTypes["default"].arrayOf(_propTypes["default"].string),
534
- scorePointsDescriptors: _propTypes["default"].arrayOf(_propTypes["default"].string),
535
- description: _propTypes["default"].string
424
+ errors: _propTypes.default.object,
425
+ scale: _propTypes.default.shape({
426
+ maxPoints: _propTypes.default.number,
427
+ scorePointsLabels: _propTypes.default.arrayOf(_propTypes.default.string),
428
+ traitLabel: _propTypes.default.string,
429
+ traits: _propTypes.default.arrayOf(_propTypes.default.shape({
430
+ name: _propTypes.default.string,
431
+ standards: _propTypes.default.arrayOf(_propTypes.default.string),
432
+ scorePointsDescriptors: _propTypes.default.arrayOf(_propTypes.default.string),
433
+ description: _propTypes.default.string
536
434
  }))
537
435
  }),
538
- width: _propTypes["default"].string,
539
- excludeZero: _propTypes["default"].bool,
540
- scaleIndex: _propTypes["default"].number,
541
- onScaleChanged: _propTypes["default"].func,
542
- onScaleRemoved: _propTypes["default"].func,
543
- showStandards: _propTypes["default"].bool,
544
- showLevelTagInput: _propTypes["default"].bool,
545
- showDescription: _propTypes["default"].bool,
546
- uploadSoundSupport: _propTypes["default"].object,
547
- showScorePointLabels: _propTypes["default"].bool,
548
- enableDragAndDrop: _propTypes["default"].bool,
549
- expandedPluginProps: _propTypes["default"].object,
550
- labelPluginProps: _propTypes["default"].object
436
+ width: _propTypes.default.string,
437
+ excludeZero: _propTypes.default.bool,
438
+ scaleIndex: _propTypes.default.number,
439
+ onScaleChanged: _propTypes.default.func,
440
+ onScaleRemoved: _propTypes.default.func,
441
+ showStandards: _propTypes.default.bool,
442
+ showLevelTagInput: _propTypes.default.bool,
443
+ showDescription: _propTypes.default.bool,
444
+ uploadSoundSupport: _propTypes.default.object,
445
+ showScorePointLabels: _propTypes.default.bool,
446
+ enableDragAndDrop: _propTypes.default.bool,
447
+ expandedPluginProps: _propTypes.default.object,
448
+ labelPluginProps: _propTypes.default.object
551
449
  };
552
-
553
- var _default = (0, _drag.withDragContext)((0, _styles.withStyles)(styles)(Scale));
554
-
555
- exports["default"] = _default;
450
+ var _default = exports.default = Scale;
556
451
  //# sourceMappingURL=scale.js.map