@pie-element/categorize 7.7.2-beta.0 → 7.7.2-beta.3

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 (60) hide show
  1. package/configure/package.json +2 -2
  2. package/package.json +2 -2
  3. package/configure/lib/defaults.js +0 -115
  4. package/configure/lib/defaults.js.map +0 -1
  5. package/configure/lib/design/builder.js +0 -74
  6. package/configure/lib/design/builder.js.map +0 -1
  7. package/configure/lib/design/buttons.js +0 -127
  8. package/configure/lib/design/buttons.js.map +0 -1
  9. package/configure/lib/design/categories/RowLabel.js +0 -68
  10. package/configure/lib/design/categories/RowLabel.js.map +0 -1
  11. package/configure/lib/design/categories/alternateResponses.js +0 -284
  12. package/configure/lib/design/categories/alternateResponses.js.map +0 -1
  13. package/configure/lib/design/categories/category.js +0 -205
  14. package/configure/lib/design/categories/category.js.map +0 -1
  15. package/configure/lib/design/categories/choice-preview.js +0 -128
  16. package/configure/lib/design/categories/choice-preview.js.map +0 -1
  17. package/configure/lib/design/categories/droppable-placeholder.js +0 -187
  18. package/configure/lib/design/categories/droppable-placeholder.js.map +0 -1
  19. package/configure/lib/design/categories/index.js +0 -396
  20. package/configure/lib/design/categories/index.js.map +0 -1
  21. package/configure/lib/design/choices/choice.js +0 -287
  22. package/configure/lib/design/choices/choice.js.map +0 -1
  23. package/configure/lib/design/choices/config.js +0 -146
  24. package/configure/lib/design/choices/config.js.map +0 -1
  25. package/configure/lib/design/choices/index.js +0 -277
  26. package/configure/lib/design/choices/index.js.map +0 -1
  27. package/configure/lib/design/header.js +0 -106
  28. package/configure/lib/design/header.js.map +0 -1
  29. package/configure/lib/design/index.js +0 -475
  30. package/configure/lib/design/index.js.map +0 -1
  31. package/configure/lib/design/input-header.js +0 -162
  32. package/configure/lib/design/input-header.js.map +0 -1
  33. package/configure/lib/index.js +0 -139
  34. package/configure/lib/index.js.map +0 -1
  35. package/configure/lib/main.js +0 -94
  36. package/configure/lib/main.js.map +0 -1
  37. package/configure/lib/utils.js +0 -27
  38. package/configure/lib/utils.js.map +0 -1
  39. package/controller/lib/defaults.js +0 -31
  40. package/controller/lib/defaults.js.map +0 -1
  41. package/controller/lib/index.js +0 -434
  42. package/controller/lib/index.js.map +0 -1
  43. package/controller/lib/utils.js +0 -60
  44. package/controller/lib/utils.js.map +0 -1
  45. package/lib/categorize/categories.js +0 -165
  46. package/lib/categorize/categories.js.map +0 -1
  47. package/lib/categorize/category.js +0 -134
  48. package/lib/categorize/category.js.map +0 -1
  49. package/lib/categorize/choice.js +0 -226
  50. package/lib/categorize/choice.js.map +0 -1
  51. package/lib/categorize/choices.js +0 -160
  52. package/lib/categorize/choices.js.map +0 -1
  53. package/lib/categorize/droppable-placeholder.js +0 -110
  54. package/lib/categorize/droppable-placeholder.js.map +0 -1
  55. package/lib/categorize/grid-content.js +0 -103
  56. package/lib/categorize/grid-content.js.map +0 -1
  57. package/lib/categorize/index.js +0 -324
  58. package/lib/categorize/index.js.map +0 -1
  59. package/lib/index.js +0 -110
  60. package/lib/index.js.map +0 -1
@@ -1,396 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports["default"] = exports.Categories = 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
-
24
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
25
-
26
- var _react = _interopRequireDefault(require("react"));
27
-
28
- var _propTypes = _interopRequireDefault(require("prop-types"));
29
-
30
- var _styles = require("@material-ui/core/styles");
31
-
32
- var _TextField = _interopRequireDefault(require("@material-ui/core/TextField"));
33
-
34
- var _Typography = _interopRequireDefault(require("@material-ui/core/Typography"));
35
-
36
- var _configUi = require("@pie-lib/config-ui");
37
-
38
- var _editableHtml = _interopRequireDefault(require("@pie-lib/editable-html"));
39
-
40
- var _classnames = _interopRequireDefault(require("classnames"));
41
-
42
- var _Info = _interopRequireDefault(require("@material-ui/icons/Info"));
43
-
44
- var _Tooltip = _interopRequireDefault(require("@material-ui/core/Tooltip"));
45
-
46
- var _categorize = require("@pie-lib/categorize");
47
-
48
- var _category = _interopRequireDefault(require("./category"));
49
-
50
- var _header = _interopRequireDefault(require("../header"));
51
-
52
- var _utils = require("../../utils");
53
-
54
- var _RowLabel = require("./RowLabel");
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 styles = function styles(theme) {
61
- return {
62
- categories: {
63
- marginBottom: theme.spacing.unit
64
- },
65
- categoriesHolder: {
66
- display: 'grid',
67
- gridRowGap: "".concat(theme.spacing.unit, "px"),
68
- gridColumnGap: "".concat(theme.spacing.unit, "px")
69
- },
70
- row: {
71
- display: 'grid',
72
- gridTemplateColumns: 'repeat(2, 1fr)',
73
- gridColumnGap: "".concat(theme.spacing.unit, "px"),
74
- alignItems: 'baseline',
75
- width: '100%',
76
- marginTop: theme.spacing.unit,
77
- marginBottom: 2 * theme.spacing.unit
78
- },
79
- rowLabel: {
80
- gridColumn: '1/3'
81
- },
82
- rowLabelHolder: {
83
- width: '100%'
84
- },
85
- tooltip: {
86
- fontSize: '12px',
87
- whiteSpace: 'pre',
88
- maxWidth: '500px'
89
- },
90
- errorText: {
91
- fontSize: '12px',
92
- color: 'red',
93
- padding: '5px 0'
94
- }
95
- };
96
- };
97
-
98
- var Categories = /*#__PURE__*/function (_React$Component) {
99
- (0, _inherits2["default"])(Categories, _React$Component);
100
-
101
- var _super = _createSuper(Categories);
102
-
103
- function Categories() {
104
- var _this;
105
-
106
- (0, _classCallCheck2["default"])(this, Categories);
107
-
108
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
109
- args[_key] = arguments[_key];
110
- }
111
-
112
- _this = _super.call.apply(_super, [this].concat(args));
113
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
114
- focusedEl: null
115
- });
116
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "add", function () {
117
- var _this$props = _this.props,
118
- model = _this$props.model,
119
- oldCategories = _this$props.categories;
120
- var categoriesPerRow = model.categoriesPerRow;
121
-
122
- var id = _configUi.choiceUtils.firstAvailableIndex(model.categories.map(function (a) {
123
- return a.id;
124
- }), 0);
125
-
126
- var data = {
127
- id: id,
128
- label: 'Category ' + id
129
- };
130
- var addRowLabel = model.categories.length % categoriesPerRow === 0;
131
- var rowLabels = (0, _toConsumableArray2["default"])(model.rowLabels);
132
-
133
- if (addRowLabel) {
134
- rowLabels.push('');
135
- }
136
-
137
- _this.setState({
138
- focusedEl: oldCategories.length
139
- }, function () {
140
- _this.props.onModelChanged({
141
- rowLabels: rowLabels,
142
- categories: model.categories.concat([data])
143
- });
144
- });
145
- });
146
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "deleteFocusedEl", function () {
147
- _this.setState({
148
- focusedEl: null
149
- });
150
- });
151
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "delete", function (category) {
152
- var _this$props2 = _this.props,
153
- model = _this$props2.model,
154
- onModelChanged = _this$props2.onModelChanged;
155
- var index = model.categories.findIndex(function (a) {
156
- return a.id === category.id;
157
- });
158
-
159
- if (index !== -1) {
160
- model.categories.splice(index, 1);
161
- model.correctResponse = (0, _categorize.removeCategory)(category.id, model.correctResponse);
162
- onModelChanged(model);
163
- }
164
- });
165
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "change", function (c) {
166
- var categories = _this.props.categories;
167
- var index = categories.findIndex(function (a) {
168
- return a.id === c.id;
169
- });
170
-
171
- if (index !== -1) {
172
- categories.splice(index, 1, c);
173
-
174
- _this.props.onModelChanged({
175
- categories: categories
176
- });
177
- }
178
- });
179
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "addChoiceToCategory", function (addedChoice, categoryId) {
180
- var _this$props3 = _this.props,
181
- model = _this$props3.model,
182
- onModelChanged = _this$props3.onModelChanged;
183
-
184
- var _ref = model || {},
185
- _ref$choices = _ref.choices,
186
- choices = _ref$choices === void 0 ? [] : _ref$choices,
187
- _ref$correctResponse = _ref.correctResponse,
188
- correctResponse = _ref$correctResponse === void 0 ? [] : _ref$correctResponse;
189
-
190
- var choice = (choices || []).find(function (choice) {
191
- return choice.id === addedChoice.id;
192
- });
193
- correctResponse = (0, _categorize.moveChoiceToCategory)(addedChoice.id, undefined, categoryId, 0, model.correctResponse); // if multiplePlacements not allowed, ensure the consistency in the other categories
194
-
195
- if (choice.categoryCount !== 0) {
196
- correctResponse = (0, _categorize.verifyAllowMultiplePlacements)(addedChoice, categoryId, correctResponse);
197
- }
198
-
199
- onModelChanged({
200
- correctResponse: correctResponse
201
- });
202
- });
203
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "deleteChoiceFromCategory", function (category, choice, choiceIndex) {
204
- var _this$props4 = _this.props,
205
- model = _this$props4.model,
206
- onModelChanged = _this$props4.onModelChanged;
207
- var correctResponse = (0, _categorize.removeChoiceFromCategory)(choice.id, category.id, choiceIndex, model.correctResponse);
208
- onModelChanged({
209
- correctResponse: correctResponse
210
- });
211
- });
212
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "moveChoice", function (choiceId, from, to, choiceIndex) {
213
- var _this$props5 = _this.props,
214
- model = _this$props5.model,
215
- onModelChanged = _this$props5.onModelChanged;
216
-
217
- var _ref2 = model || {},
218
- choices = _ref2.choices,
219
- _ref2$correctResponse = _ref2.correctResponse,
220
- correctResponse = _ref2$correctResponse === void 0 ? [] : _ref2$correctResponse;
221
-
222
- var choice = (choices || []).find(function (choice) {
223
- return choice.id === choiceId;
224
- });
225
-
226
- if (to === from || !choice) {
227
- return;
228
- }
229
-
230
- if (choice.categoryCount !== 0) {
231
- correctResponse = (0, _categorize.moveChoiceToCategory)(choice.id, from, to, choiceIndex, correctResponse);
232
- correctResponse = (0, _categorize.verifyAllowMultiplePlacements)(choice, to, correctResponse);
233
- } else if (choice.categoryCount === 0) {
234
- correctResponse = (0, _categorize.moveChoiceToCategory)(choice.id, undefined, to, 0, correctResponse);
235
- }
236
-
237
- onModelChanged({
238
- correctResponse: correctResponse
239
- });
240
- });
241
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeRowLabel", function (val, index) {
242
- var model = _this.props.model;
243
- var rowLabels = model.rowLabels;
244
- var newRowLabels = (0, _toConsumableArray2["default"])(rowLabels);
245
-
246
- if (newRowLabels.length < index) {
247
- newRowLabels.push(val);
248
- } else {
249
- newRowLabels[index] = val;
250
- }
251
-
252
- _this.props.onModelChanged({
253
- rowLabels: newRowLabels
254
- });
255
- });
256
- return _this;
257
- }
258
-
259
- (0, _createClass2["default"])(Categories, [{
260
- key: "render",
261
- value: function render() {
262
- var _this2 = this;
263
-
264
- var _this$props6 = this.props,
265
- model = _this$props6.model,
266
- classes = _this$props6.classes,
267
- className = _this$props6.className,
268
- categories = _this$props6.categories,
269
- imageSupport = _this$props6.imageSupport,
270
- uploadSoundSupport = _this$props6.uploadSoundSupport,
271
- toolbarOpts = _this$props6.toolbarOpts,
272
- spellCheck = _this$props6.spellCheck,
273
- configuration = _this$props6.configuration,
274
- defaultImageMaxHeight = _this$props6.defaultImageMaxHeight,
275
- defaultImageMaxWidth = _this$props6.defaultImageMaxWidth;
276
- var categoriesPerRow = model.categoriesPerRow,
277
- rowLabels = model.rowLabels,
278
- errors = model.errors;
279
-
280
- var _ref3 = errors || {},
281
- associationError = _ref3.associationError,
282
- categoriesError = _ref3.categoriesError,
283
- categoriesErrors = _ref3.categoriesErrors;
284
-
285
- var _ref4 = configuration || {},
286
- maxCategories = _ref4.maxCategories,
287
- _ref4$maxImageWidth = _ref4.maxImageWidth,
288
- maxImageWidth = _ref4$maxImageWidth === void 0 ? {} : _ref4$maxImageWidth,
289
- _ref4$maxImageHeight = _ref4.maxImageHeight,
290
- maxImageHeight = _ref4$maxImageHeight === void 0 ? {} : _ref4$maxImageHeight;
291
-
292
- var holderStyle = {
293
- gridTemplateColumns: "repeat(".concat(categoriesPerRow, ", 1fr)")
294
- };
295
- var validationMessage = (0, _utils.generateValidationMessage)(configuration);
296
- return /*#__PURE__*/_react["default"].createElement("div", {
297
- className: (0, _classnames["default"])(classes.categories, className)
298
- }, /*#__PURE__*/_react["default"].createElement(_header["default"], {
299
- label: "Categories",
300
- buttonLabel: "ADD A CATEGORY",
301
- onAdd: this.add,
302
- info: /*#__PURE__*/_react["default"].createElement(_Tooltip["default"], {
303
- classes: {
304
- tooltip: classes.tooltip
305
- },
306
- disableFocusListener: true,
307
- disableTouchListener: true,
308
- placement: 'right',
309
- title: validationMessage
310
- }, /*#__PURE__*/_react["default"].createElement(_Info["default"], {
311
- fontSize: 'small',
312
- color: 'primary',
313
- style: {
314
- marginLeft: '5px'
315
- }
316
- })),
317
- buttonDisabled: maxCategories && categories && maxCategories === categories.length
318
- }), associationError && /*#__PURE__*/_react["default"].createElement("div", {
319
- className: classes.errorText
320
- }, associationError), categoriesError && /*#__PURE__*/_react["default"].createElement("div", {
321
- className: classes.errorText
322
- }, categoriesError), /*#__PURE__*/_react["default"].createElement("div", {
323
- className: classes.categoriesHolder,
324
- style: holderStyle
325
- }, categories.map(function (category, index) {
326
- var hasRowLabel = index % categoriesPerRow === 0;
327
- var rowIndex = index / categoriesPerRow;
328
- return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, {
329
- key: index
330
- }, hasRowLabel && /*#__PURE__*/_react["default"].createElement(_RowLabel.RowLabel, {
331
- categoriesPerRow: categoriesPerRow,
332
- disabled: false,
333
- rowIndex: rowIndex,
334
- markup: rowLabels[rowIndex] || '',
335
- onChange: function onChange(val) {
336
- return _this2.changeRowLabel(val, rowIndex);
337
- },
338
- imageSupport: imageSupport,
339
- toolbarOpts: toolbarOpts,
340
- spellCheck: spellCheck,
341
- maxImageWidth: maxImageWidth && maxImageWidth.rowLabel || defaultImageMaxWidth,
342
- maxImageHeight: maxImageHeight && maxImageHeight.rowLabel || defaultImageMaxHeight,
343
- uploadSoundSupport: uploadSoundSupport
344
- }), /*#__PURE__*/_react["default"].createElement(_category["default"], {
345
- imageSupport: imageSupport,
346
- focusedEl: _this2.state.focusedEl,
347
- deleteFocusedEl: _this2.deleteFocusedEl,
348
- index: index,
349
- category: category,
350
- error: categoriesErrors && categoriesErrors[category.id],
351
- onChange: _this2.change,
352
- onDelete: function onDelete() {
353
- return _this2["delete"](category);
354
- },
355
- onAddChoice: _this2.addChoiceToCategory,
356
- onMoveChoice: function onMoveChoice(choiceId, from, to, choiceIndex) {
357
- return _this2.moveChoice(choiceId, from, to, choiceIndex);
358
- },
359
- toolbarOpts: toolbarOpts,
360
- spellCheck: spellCheck,
361
- onDeleteChoice: function onDeleteChoice(choice, choiceIndex) {
362
- return _this2.deleteChoiceFromCategory(category, choice, choiceIndex);
363
- },
364
- maxImageWidth: maxImageWidth && maxImageWidth.categoryLabel || defaultImageMaxWidth,
365
- maxImageHeight: maxImageHeight && maxImageHeight.categoryLabel || defaultImageMaxHeight,
366
- uploadSoundSupport: uploadSoundSupport
367
- }));
368
- })));
369
- }
370
- }]);
371
- return Categories;
372
- }(_react["default"].Component);
373
-
374
- exports.Categories = Categories;
375
- (0, _defineProperty2["default"])(Categories, "propTypes", {
376
- imageSupport: _propTypes["default"].shape({
377
- add: _propTypes["default"].func.isRequired,
378
- "delete": _propTypes["default"].func.isRequired
379
- }),
380
- uploadSoundSupport: _propTypes["default"].shape({
381
- add: _propTypes["default"].func.isRequired,
382
- "delete": _propTypes["default"].func.isRequired
383
- }),
384
- classes: _propTypes["default"].object.isRequired,
385
- className: _propTypes["default"].string,
386
- categories: _propTypes["default"].array,
387
- onModelChanged: _propTypes["default"].func,
388
- model: _propTypes["default"].object.isRequired,
389
- configuration: _propTypes["default"].object.isRequired,
390
- toolbarOpts: _propTypes["default"].object
391
- });
392
-
393
- var _default = (0, _styles.withStyles)(styles)(Categories);
394
-
395
- exports["default"] = _default;
396
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/design/categories/index.jsx"],"names":["styles","theme","categories","marginBottom","spacing","unit","categoriesHolder","display","gridRowGap","gridColumnGap","row","gridTemplateColumns","alignItems","width","marginTop","rowLabel","gridColumn","rowLabelHolder","tooltip","fontSize","whiteSpace","maxWidth","errorText","color","padding","Categories","focusedEl","props","model","oldCategories","categoriesPerRow","id","utils","firstAvailableIndex","map","a","data","label","addRowLabel","length","rowLabels","push","setState","onModelChanged","concat","category","index","findIndex","splice","correctResponse","c","addedChoice","categoryId","choices","choice","find","undefined","categoryCount","choiceIndex","choiceId","from","to","val","newRowLabels","classes","className","imageSupport","uploadSoundSupport","toolbarOpts","spellCheck","configuration","defaultImageMaxHeight","defaultImageMaxWidth","errors","associationError","categoriesError","categoriesErrors","maxCategories","maxImageWidth","maxImageHeight","holderStyle","validationMessage","add","marginLeft","hasRowLabel","rowIndex","changeRowLabel","state","deleteFocusedEl","change","addChoiceToCategory","moveChoice","deleteChoiceFromCategory","categoryLabel","React","Component","PropTypes","shape","func","isRequired","object","string","array"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAQA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzBC,IAAAA,UAAU,EAAE;AACVC,MAAAA,YAAY,EAAEF,KAAK,CAACG,OAAN,CAAcC;AADlB,KADa;AAIzBC,IAAAA,gBAAgB,EAAE;AAChBC,MAAAA,OAAO,EAAE,MADO;AAEhBC,MAAAA,UAAU,YAAKP,KAAK,CAACG,OAAN,CAAcC,IAAnB,OAFM;AAGhBI,MAAAA,aAAa,YAAKR,KAAK,CAACG,OAAN,CAAcC,IAAnB;AAHG,KAJO;AASzBK,IAAAA,GAAG,EAAE;AACHH,MAAAA,OAAO,EAAE,MADN;AAEHI,MAAAA,mBAAmB,EAAE,gBAFlB;AAGHF,MAAAA,aAAa,YAAKR,KAAK,CAACG,OAAN,CAAcC,IAAnB,OAHV;AAIHO,MAAAA,UAAU,EAAE,UAJT;AAKHC,MAAAA,KAAK,EAAE,MALJ;AAMHC,MAAAA,SAAS,EAAEb,KAAK,CAACG,OAAN,CAAcC,IANtB;AAOHF,MAAAA,YAAY,EAAE,IAAIF,KAAK,CAACG,OAAN,CAAcC;AAP7B,KAToB;AAkBzBU,IAAAA,QAAQ,EAAE;AACRC,MAAAA,UAAU,EAAE;AADJ,KAlBe;AAqBzBC,IAAAA,cAAc,EAAE;AACdJ,MAAAA,KAAK,EAAE;AADO,KArBS;AAwBzBK,IAAAA,OAAO,EAAE;AACPC,MAAAA,QAAQ,EAAE,MADH;AA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EAAmByB,UAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport TextField from '@material-ui/core/TextField';\nimport Typography from '@material-ui/core/Typography';\nimport { choiceUtils as utils } from '@pie-lib/config-ui';\nimport EditableHtml from '@pie-lib/editable-html';\nimport classNames from 'classnames';\nimport Info from '@material-ui/icons/Info';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport {\n moveChoiceToAlternate,\n moveChoiceToCategory,\n removeCategory,\n removeChoiceFromCategory,\n verifyAllowMultiplePlacements,\n} from '@pie-lib/categorize';\n\nimport Category from './category';\nimport Header from '../header';\nimport { generateValidationMessage } from '../../utils';\nimport { RowLabel } from './RowLabel';\n\nconst styles = (theme) => ({\n categories: {\n marginBottom: theme.spacing.unit,\n },\n categoriesHolder: {\n display: 'grid',\n gridRowGap: `${theme.spacing.unit}px`,\n gridColumnGap: `${theme.spacing.unit}px`,\n },\n row: {\n display: 'grid',\n gridTemplateColumns: 'repeat(2, 1fr)',\n gridColumnGap: `${theme.spacing.unit}px`,\n alignItems: 'baseline',\n width: '100%',\n marginTop: theme.spacing.unit,\n marginBottom: 2 * theme.spacing.unit,\n },\n rowLabel: {\n gridColumn: '1/3',\n },\n rowLabelHolder: {\n width: '100%',\n },\n tooltip: {\n fontSize: '12px',\n whiteSpace: 'pre',\n maxWidth: '500px',\n },\n errorText: {\n fontSize: '12px',\n color: 'red',\n padding: '5px 0',\n },\n});\n\nexport class Categories extends React.Component {\n static propTypes = {\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired,\n }),\n uploadSoundSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired,\n }),\n classes: PropTypes.object.isRequired,\n className: PropTypes.string,\n categories: PropTypes.array,\n onModelChanged: PropTypes.func,\n model: PropTypes.object.isRequired,\n configuration: PropTypes.object.isRequired,\n toolbarOpts: PropTypes.object,\n };\n\n state = {\n focusedEl: null,\n };\n\n add = () => {\n const { model, categories: oldCategories } = this.props;\n const { categoriesPerRow } = model;\n const id = utils.firstAvailableIndex(\n model.categories.map((a) => a.id),\n 0,\n );\n const data = { id, label: 'Category ' + id };\n const addRowLabel = model.categories.length % categoriesPerRow === 0;\n const rowLabels = [...model.rowLabels];\n\n if (addRowLabel) {\n rowLabels.push('');\n }\n\n this.setState(\n {\n focusedEl: oldCategories.length,\n },\n () => {\n this.props.onModelChanged({\n rowLabels,\n categories: model.categories.concat([data]),\n });\n },\n );\n };\n\n deleteFocusedEl = () => {\n this.setState({\n focusedEl: null,\n });\n };\n\n delete = (category) => {\n const { model, onModelChanged } = this.props;\n const index = model.categories.findIndex((a) => a.id === category.id);\n\n if (index !== -1) {\n model.categories.splice(index, 1);\n model.correctResponse = removeCategory(category.id, model.correctResponse);\n onModelChanged(model);\n }\n };\n\n change = (c) => {\n const { categories } = this.props;\n const index = categories.findIndex((a) => a.id === c.id);\n\n if (index !== -1) {\n categories.splice(index, 1, c);\n this.props.onModelChanged({ categories });\n }\n };\n\n addChoiceToCategory = (addedChoice, categoryId) => {\n const { model, onModelChanged } = this.props;\n let { choices = [], correctResponse = [] } = model || {};\n const choice = (choices || []).find((choice) => choice.id === addedChoice.id);\n correctResponse = moveChoiceToCategory(addedChoice.id, undefined, categoryId, 0, model.correctResponse);\n // if multiplePlacements not allowed, ensure the consistency in the other categories\n if (choice.categoryCount !== 0) {\n correctResponse = verifyAllowMultiplePlacements(addedChoice, categoryId, correctResponse);\n }\n onModelChanged({ correctResponse });\n };\n\n deleteChoiceFromCategory = (category, choice, choiceIndex) => {\n const { model, onModelChanged } = this.props;\n const correctResponse = removeChoiceFromCategory(choice.id, category.id, choiceIndex, model.correctResponse);\n\n onModelChanged({ correctResponse });\n };\n\n moveChoice = (choiceId, from, to, choiceIndex) => {\n const { model, onModelChanged } = this.props;\n let { choices, correctResponse = [] } = model || {};\n const choice = (choices || []).find((choice) => choice.id === choiceId);\n if (to === from || !choice) {\n return;\n }\n if (choice.categoryCount !== 0) {\n correctResponse = moveChoiceToCategory(choice.id, from, to, choiceIndex, correctResponse);\n correctResponse = verifyAllowMultiplePlacements(choice, to, correctResponse);\n } else if (choice.categoryCount === 0) {\n correctResponse = moveChoiceToCategory(choice.id, undefined, to, 0, correctResponse);\n }\n onModelChanged({ correctResponse });\n };\n\n changeRowLabel = (val, index) => {\n const { model } = this.props;\n const { rowLabels } = model;\n const newRowLabels = [...rowLabels];\n\n if (newRowLabels.length < index) {\n newRowLabels.push(val);\n } else {\n newRowLabels[index] = val;\n }\n\n this.props.onModelChanged({\n rowLabels: newRowLabels,\n });\n };\n\n render() {\n const {\n model,\n classes,\n className,\n categories,\n imageSupport,\n uploadSoundSupport,\n toolbarOpts,\n spellCheck,\n configuration,\n defaultImageMaxHeight,\n defaultImageMaxWidth,\n } = this.props;\n\n const { categoriesPerRow, rowLabels, errors } = model;\n const { associationError, categoriesError, categoriesErrors } = errors || {};\n const { maxCategories, maxImageWidth = {}, maxImageHeight = {} } = configuration || {};\n const holderStyle = {\n gridTemplateColumns: `repeat(${categoriesPerRow}, 1fr)`,\n };\n\n const validationMessage = generateValidationMessage(configuration);\n\n return (\n <div className={classNames(classes.categories, className)}>\n <Header\n label=\"Categories\"\n buttonLabel=\"ADD A CATEGORY\"\n onAdd={this.add}\n info={\n <Tooltip\n classes={{ tooltip: classes.tooltip }}\n disableFocusListener\n disableTouchListener\n placement={'right'}\n title={validationMessage}\n >\n <Info fontSize={'small'} color={'primary'} style={{ marginLeft: '5px' }} />\n </Tooltip>\n }\n buttonDisabled={maxCategories && categories && maxCategories === categories.length}\n />\n {associationError && <div className={classes.errorText}>{associationError}</div>}\n {categoriesError && <div className={classes.errorText}>{categoriesError}</div>}\n <div className={classes.categoriesHolder} style={holderStyle}>\n {categories.map((category, index) => {\n const hasRowLabel = index % categoriesPerRow === 0;\n const rowIndex = index / categoriesPerRow;\n\n return (\n <React.Fragment key={index}>\n {hasRowLabel && (\n <RowLabel\n categoriesPerRow={categoriesPerRow}\n disabled={false}\n rowIndex={rowIndex}\n markup={rowLabels[rowIndex] || ''}\n onChange={(val) => this.changeRowLabel(val, rowIndex)}\n imageSupport={imageSupport}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheck}\n maxImageWidth={(maxImageWidth && maxImageWidth.rowLabel) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.rowLabel) || defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n />\n )}\n <Category\n imageSupport={imageSupport}\n focusedEl={this.state.focusedEl}\n deleteFocusedEl={this.deleteFocusedEl}\n index={index}\n category={category}\n error={categoriesErrors && categoriesErrors[category.id]}\n onChange={this.change}\n onDelete={() => this.delete(category)}\n onAddChoice={this.addChoiceToCategory}\n onMoveChoice={(choiceId, from, to, choiceIndex) => this.moveChoice(choiceId, from, to, choiceIndex)}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheck}\n onDeleteChoice={(choice, choiceIndex) => this.deleteChoiceFromCategory(category, choice, choiceIndex)}\n maxImageWidth={(maxImageWidth && maxImageWidth.categoryLabel) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.categoryLabel) || defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n />\n </React.Fragment>\n );\n })}\n </div>\n </div>\n );\n }\n}\n\nexport default withStyles(styles)(Categories);\n"],"file":"index.js"}