@pie-element/categorize 11.3.4-next.3 → 12.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configure/lib/defaults.js +2 -5
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/design/builder.js +15 -33
- package/configure/lib/design/builder.js.map +1 -1
- package/configure/lib/design/buttons.js +41 -95
- package/configure/lib/design/buttons.js.map +1 -1
- package/configure/lib/design/categories/RowLabel.js +32 -45
- package/configure/lib/design/categories/RowLabel.js.map +1 -1
- package/configure/lib/design/categories/alternateResponses.js +96 -251
- package/configure/lib/design/categories/alternateResponses.js.map +1 -1
- package/configure/lib/design/categories/category.js +135 -208
- package/configure/lib/design/categories/category.js.map +1 -1
- package/configure/lib/design/categories/choice-preview.js +61 -126
- package/configure/lib/design/categories/choice-preview.js.map +1 -1
- package/configure/lib/design/categories/droppable-placeholder.js +73 -165
- package/configure/lib/design/categories/droppable-placeholder.js.map +1 -1
- package/configure/lib/design/categories/index.js +195 -384
- package/configure/lib/design/categories/index.js.map +1 -1
- package/configure/lib/design/choices/choice.js +155 -264
- package/configure/lib/design/choices/choice.js.map +1 -1
- package/configure/lib/design/choices/config.js +42 -98
- package/configure/lib/design/choices/config.js.map +1 -1
- package/configure/lib/design/choices/index.js +148 -236
- package/configure/lib/design/choices/index.js.map +1 -1
- package/configure/lib/design/header.js +57 -111
- package/configure/lib/design/header.js.map +1 -1
- package/configure/lib/design/index.js +631 -476
- package/configure/lib/design/index.js.map +1 -1
- package/configure/lib/design/input-header.js +93 -149
- package/configure/lib/design/input-header.js.map +1 -1
- package/configure/lib/design/utils.js +4 -15
- package/configure/lib/design/utils.js.map +1 -1
- package/configure/lib/index.js +120 -183
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/main.js +30 -74
- package/configure/lib/main.js.map +1 -1
- package/configure/lib/utils.js +22 -32
- package/configure/lib/utils.js.map +1 -1
- package/configure/package.json +15 -15
- package/controller/lib/defaults.js +2 -5
- package/controller/lib/defaults.js.map +1 -1
- package/controller/lib/index.js +237 -318
- package/controller/lib/index.js.map +1 -1
- package/controller/lib/utils.js +28 -65
- package/controller/lib/utils.js.map +1 -1
- package/controller/package.json +5 -5
- package/lib/categorize/categories.js +106 -164
- package/lib/categorize/categories.js.map +1 -1
- package/lib/categorize/category.js +73 -123
- package/lib/categorize/category.js.map +1 -1
- package/lib/categorize/choice.js +118 -245
- package/lib/categorize/choice.js.map +1 -1
- package/lib/categorize/choices.js +66 -131
- package/lib/categorize/choices.js.map +1 -1
- package/lib/categorize/droppable-placeholder.js +46 -103
- package/lib/categorize/droppable-placeholder.js.map +1 -1
- package/lib/categorize/grid-content.js +39 -87
- package/lib/categorize/grid-content.js.map +1 -1
- package/lib/categorize/index.js +341 -317
- package/lib/categorize/index.js.map +1 -1
- package/lib/index.js +285 -306
- package/lib/index.js.map +1 -1
- package/package.json +16 -14
- package/esm/configure.js +0 -34401
- package/esm/configure.js.map +0 -1
- package/esm/controller.js +0 -1468
- package/esm/controller.js.map +0 -1
- package/esm/element.js +0 -13134
- package/esm/element.js.map +0 -1
- package/esm/package.json +0 -3
|
@@ -1,445 +1,256 @@
|
|
|
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
|
|
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.Categories = void 0;
|
|
24
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
|
-
|
|
26
9
|
var _react = _interopRequireDefault(require("react"));
|
|
27
|
-
|
|
28
|
-
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
29
|
-
|
|
30
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
31
|
-
|
|
32
|
-
var _styles = require("@material-ui/core/styles");
|
|
33
|
-
|
|
11
|
+
var _styles = require("@mui/material/styles");
|
|
34
12
|
var _configUi = require("@pie-lib/config-ui");
|
|
35
|
-
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
var _Info = _interopRequireDefault(require("@material-ui/icons/Info"));
|
|
39
|
-
|
|
40
|
-
var _Tooltip = _interopRequireDefault(require("@material-ui/core/Tooltip"));
|
|
41
|
-
|
|
13
|
+
var _Info = _interopRequireDefault(require("@mui/icons-material/Info"));
|
|
14
|
+
var _Tooltip = _interopRequireDefault(require("@mui/material/Tooltip"));
|
|
42
15
|
var _categorize = require("@pie-lib/categorize");
|
|
43
|
-
|
|
44
16
|
var _category = _interopRequireDefault(require("./category"));
|
|
45
|
-
|
|
46
17
|
var _header = _interopRequireDefault(require("../header"));
|
|
47
|
-
|
|
48
18
|
var _utils = require("../../utils");
|
|
49
|
-
|
|
50
19
|
var _RowLabel = require("./RowLabel");
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
tooltip: {
|
|
84
|
-
fontSize: theme.typography.fontSize - 2,
|
|
85
|
-
whiteSpace: 'pre',
|
|
86
|
-
maxWidth: '500px'
|
|
87
|
-
},
|
|
88
|
-
errorText: {
|
|
89
|
-
fontSize: theme.typography.fontSize - 2,
|
|
90
|
-
color: theme.palette.error.main,
|
|
91
|
-
paddingTop: theme.spacing.unit / 2
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
var Categories = /*#__PURE__*/function (_React$Component) {
|
|
97
|
-
(0, _inherits2["default"])(Categories, _React$Component);
|
|
98
|
-
|
|
99
|
-
var _super = _createSuper(Categories);
|
|
100
|
-
|
|
101
|
-
function Categories() {
|
|
102
|
-
var _this;
|
|
103
|
-
|
|
104
|
-
(0, _classCallCheck2["default"])(this, Categories);
|
|
105
|
-
|
|
106
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
107
|
-
args[_key] = arguments[_key];
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
111
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
|
|
20
|
+
const CategoriesContainer = (0, _styles.styled)('div')(({
|
|
21
|
+
theme
|
|
22
|
+
}) => ({
|
|
23
|
+
marginBottom: theme.spacing(3)
|
|
24
|
+
}));
|
|
25
|
+
const CategoriesHolder = (0, _styles.styled)('div')(({
|
|
26
|
+
theme
|
|
27
|
+
}) => ({
|
|
28
|
+
display: 'grid',
|
|
29
|
+
gridRowGap: `${theme.spacing(1)}px`,
|
|
30
|
+
gridColumnGap: `${theme.spacing(1)}px`
|
|
31
|
+
}));
|
|
32
|
+
const StyledTooltip = (0, _styles.styled)(_Tooltip.default)(({
|
|
33
|
+
theme
|
|
34
|
+
}) => ({
|
|
35
|
+
'& .MuiTooltip-tooltip': {
|
|
36
|
+
fontSize: theme.typography.fontSize - 2,
|
|
37
|
+
whiteSpace: 'pre',
|
|
38
|
+
maxWidth: '500px'
|
|
39
|
+
}
|
|
40
|
+
}));
|
|
41
|
+
const ErrorText = (0, _styles.styled)('div')(({
|
|
42
|
+
theme
|
|
43
|
+
}) => ({
|
|
44
|
+
fontSize: theme.typography.fontSize - 2,
|
|
45
|
+
color: theme.palette.error.main,
|
|
46
|
+
paddingTop: theme.spacing(0.5)
|
|
47
|
+
}));
|
|
48
|
+
class Categories extends _react.default.Component {
|
|
49
|
+
constructor(...args) {
|
|
50
|
+
super(...args);
|
|
51
|
+
(0, _defineProperty2.default)(this, "state", {
|
|
112
52
|
focusedEl: null
|
|
113
53
|
});
|
|
114
|
-
(0, _defineProperty2
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
id: id,
|
|
54
|
+
(0, _defineProperty2.default)(this, "add", () => {
|
|
55
|
+
const {
|
|
56
|
+
model,
|
|
57
|
+
categories: oldCategories
|
|
58
|
+
} = this.props;
|
|
59
|
+
const {
|
|
60
|
+
categoriesPerRow,
|
|
61
|
+
correctResponse,
|
|
62
|
+
allowAlternateEnabled
|
|
63
|
+
} = model;
|
|
64
|
+
const id = _configUi.choiceUtils.firstAvailableIndex(model.categories.map(a => a.id), 1);
|
|
65
|
+
const data = {
|
|
66
|
+
id,
|
|
128
67
|
label: 'Category ' + id
|
|
129
68
|
};
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
69
|
+
const addRowLabel = model.categories.length % categoriesPerRow === 0;
|
|
70
|
+
const rowLabels = [...model.rowLabels];
|
|
133
71
|
if (addRowLabel) {
|
|
134
72
|
rowLabels.push('');
|
|
135
73
|
}
|
|
136
|
-
|
|
137
|
-
_this.setState({
|
|
74
|
+
this.setState({
|
|
138
75
|
focusedEl: oldCategories.length
|
|
139
|
-
},
|
|
140
|
-
|
|
141
|
-
rowLabels
|
|
76
|
+
}, () => {
|
|
77
|
+
this.props.onModelChanged({
|
|
78
|
+
rowLabels,
|
|
142
79
|
categories: model.categories.concat([data]),
|
|
143
|
-
correctResponse: allowAlternateEnabled ? [
|
|
80
|
+
correctResponse: allowAlternateEnabled ? [...correctResponse, {
|
|
144
81
|
category: id,
|
|
145
82
|
choices: [],
|
|
146
83
|
alternateResponses: []
|
|
147
|
-
}]
|
|
84
|
+
}] : correctResponse
|
|
148
85
|
});
|
|
149
86
|
});
|
|
150
87
|
});
|
|
151
|
-
(0, _defineProperty2
|
|
152
|
-
|
|
88
|
+
(0, _defineProperty2.default)(this, "deleteFocusedEl", () => {
|
|
89
|
+
this.setState({
|
|
153
90
|
focusedEl: null
|
|
154
91
|
});
|
|
155
92
|
});
|
|
156
|
-
(0, _defineProperty2
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
});
|
|
163
|
-
|
|
93
|
+
(0, _defineProperty2.default)(this, "delete", category => {
|
|
94
|
+
const {
|
|
95
|
+
model,
|
|
96
|
+
onModelChanged
|
|
97
|
+
} = this.props;
|
|
98
|
+
const index = model.categories.findIndex(a => a.id === category.id);
|
|
164
99
|
if (index !== -1) {
|
|
165
100
|
model.categories.splice(index, 1);
|
|
166
101
|
model.correctResponse = (0, _categorize.removeCategory)(category.id, model.correctResponse);
|
|
167
102
|
onModelChanged(model);
|
|
168
103
|
}
|
|
169
104
|
});
|
|
170
|
-
(0, _defineProperty2
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
105
|
+
(0, _defineProperty2.default)(this, "change", c => {
|
|
106
|
+
const {
|
|
107
|
+
categories
|
|
108
|
+
} = this.props;
|
|
109
|
+
const index = categories.findIndex(a => a.id === c.id);
|
|
176
110
|
if (index !== -1) {
|
|
177
111
|
categories.splice(index, 1, c);
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
categories: categories
|
|
112
|
+
this.props.onModelChanged({
|
|
113
|
+
categories
|
|
181
114
|
});
|
|
182
115
|
}
|
|
183
116
|
});
|
|
184
|
-
(0, _defineProperty2
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
_ref$choices = _ref.choices,
|
|
191
|
-
choices = _ref$choices === void 0 ? [] : _ref$choices,
|
|
192
|
-
_ref$correctResponse = _ref.correctResponse,
|
|
193
|
-
correctResponse = _ref$correctResponse === void 0 ? [] : _ref$correctResponse,
|
|
194
|
-
_ref$maxChoicesPerCat = _ref.maxChoicesPerCategory,
|
|
195
|
-
maxChoicesPerCategory = _ref$maxChoicesPerCat === void 0 ? 0 : _ref$maxChoicesPerCat;
|
|
196
|
-
|
|
197
|
-
var choice = (choices || []).find(function (choice) {
|
|
198
|
-
return choice.id === addedChoice.id;
|
|
199
|
-
});
|
|
200
|
-
correctResponse = (0, _categorize.moveChoiceToCategory)(addedChoice.id, undefined, categoryId, 0, model.correctResponse); // if multiplePlacements not allowed, ensure the consistency in the other categories
|
|
201
|
-
|
|
202
|
-
if (choice.categoryCount !== 0) {
|
|
203
|
-
correctResponse = (0, _categorize.verifyAllowMultiplePlacements)(addedChoice, categoryId, correctResponse);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
var maxCategoryChoices = (0, _utils.getMaxCategoryChoices)(model); // when maxChoicesPerCategory is set to 0, there is no limit so it should not be updated
|
|
207
|
-
|
|
208
|
-
onModelChanged({
|
|
209
|
-
correctResponse: correctResponse,
|
|
210
|
-
maxChoicesPerCategory: maxChoicesPerCategory !== 0 && maxChoicesPerCategory < maxCategoryChoices ? maxChoicesPerCategory + 1 : maxChoicesPerCategory
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "deleteChoiceFromCategory", function (category, choice, choiceIndex) {
|
|
214
|
-
var _this$props4 = _this.props,
|
|
215
|
-
model = _this$props4.model,
|
|
216
|
-
onModelChanged = _this$props4.onModelChanged;
|
|
217
|
-
var correctResponse = (0, _categorize.removeChoiceFromCategory)(choice.id, category.id, choiceIndex, model.correctResponse);
|
|
218
|
-
onModelChanged({
|
|
219
|
-
correctResponse: correctResponse
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "moveChoice", function (choiceId, from, to, choiceIndex) {
|
|
223
|
-
var _this$props5 = _this.props,
|
|
224
|
-
model = _this$props5.model,
|
|
225
|
-
onModelChanged = _this$props5.onModelChanged;
|
|
226
|
-
|
|
227
|
-
var _ref2 = model || {},
|
|
228
|
-
choices = _ref2.choices,
|
|
229
|
-
_ref2$correctResponse = _ref2.correctResponse,
|
|
230
|
-
correctResponse = _ref2$correctResponse === void 0 ? [] : _ref2$correctResponse,
|
|
231
|
-
_ref2$maxChoicesPerCa = _ref2.maxChoicesPerCategory,
|
|
232
|
-
maxChoicesPerCategory = _ref2$maxChoicesPerCa === void 0 ? 0 : _ref2$maxChoicesPerCa;
|
|
233
|
-
|
|
234
|
-
var choice = (choices || []).find(function (choice) {
|
|
235
|
-
return choice.id === choiceId;
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
if (to === from || !choice) {
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
if (choice.categoryCount !== 0) {
|
|
243
|
-
correctResponse = (0, _categorize.moveChoiceToCategory)(choice.id, from, to, choiceIndex, correctResponse);
|
|
244
|
-
correctResponse = (0, _categorize.verifyAllowMultiplePlacements)(choice, to, correctResponse);
|
|
245
|
-
} else if (choice.categoryCount === 0) {
|
|
246
|
-
correctResponse = (0, _categorize.moveChoiceToCategory)(choice.id, undefined, to, 0, correctResponse);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
var maxCategoryChoices = (0, _utils.getMaxCategoryChoices)(model); // when maxChoicesPerCategory is set to 0, there is no limit so it should not be updated
|
|
250
|
-
|
|
117
|
+
(0, _defineProperty2.default)(this, "deleteChoiceFromCategory", (category, choice, choiceIndex) => {
|
|
118
|
+
const {
|
|
119
|
+
model,
|
|
120
|
+
onModelChanged
|
|
121
|
+
} = this.props;
|
|
122
|
+
const correctResponse = (0, _categorize.removeChoiceFromCategory)(choice.id, category.id, choiceIndex, model.correctResponse);
|
|
251
123
|
onModelChanged({
|
|
252
|
-
correctResponse
|
|
253
|
-
maxChoicesPerCategory: maxChoicesPerCategory !== 0 && maxChoicesPerCategory < maxCategoryChoices ? maxChoicesPerCategory + 1 : maxChoicesPerCategory
|
|
124
|
+
correctResponse
|
|
254
125
|
});
|
|
255
126
|
});
|
|
256
|
-
(0, _defineProperty2
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
127
|
+
(0, _defineProperty2.default)(this, "changeRowLabel", (val, index) => {
|
|
128
|
+
const {
|
|
129
|
+
model
|
|
130
|
+
} = this.props;
|
|
131
|
+
const {
|
|
132
|
+
rowLabels
|
|
133
|
+
} = model;
|
|
134
|
+
const newRowLabels = [...rowLabels];
|
|
261
135
|
if (newRowLabels.length < index) {
|
|
262
136
|
newRowLabels.push(val);
|
|
263
137
|
} else {
|
|
264
138
|
newRowLabels[index] = val;
|
|
265
139
|
}
|
|
266
|
-
|
|
267
|
-
_this.props.onModelChanged({
|
|
140
|
+
this.props.onModelChanged({
|
|
268
141
|
rowLabels: newRowLabels
|
|
269
142
|
});
|
|
270
143
|
});
|
|
271
|
-
return _this;
|
|
272
144
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
}, categories.map(function (category, index) {
|
|
365
|
-
var hasRowLabel = index % categoriesPerRow === 0;
|
|
366
|
-
var rowIndex = index / categoriesPerRow;
|
|
367
|
-
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, {
|
|
368
|
-
key: index
|
|
369
|
-
}, hasRowLabel && /*#__PURE__*/_react["default"].createElement(_RowLabel.RowLabel, {
|
|
370
|
-
categoriesPerRow: categoriesPerRow,
|
|
371
|
-
disabled: false,
|
|
372
|
-
rowIndex: rowIndex,
|
|
373
|
-
markup: rowLabels[rowIndex] || '',
|
|
374
|
-
onChange: function onChange(val) {
|
|
375
|
-
return _this2.changeRowLabel(val, rowIndex);
|
|
376
|
-
},
|
|
377
|
-
imageSupport: imageSupport,
|
|
378
|
-
toolbarOpts: toolbarOpts,
|
|
379
|
-
spellCheck: spellCheck,
|
|
380
|
-
maxImageWidth: maxImageWidth && maxImageWidth.rowLabel || defaultImageMaxWidth,
|
|
381
|
-
maxImageHeight: maxImageHeight && maxImageHeight.rowLabel || defaultImageMaxHeight,
|
|
382
|
-
uploadSoundSupport: uploadSoundSupport,
|
|
383
|
-
mathMlOptions: mathMlOptions,
|
|
384
|
-
configuration: configuration
|
|
385
|
-
}), /*#__PURE__*/_react["default"].createElement(_category["default"], {
|
|
386
|
-
imageSupport: imageSupport,
|
|
387
|
-
focusedEl: _this2.state.focusedEl,
|
|
388
|
-
deleteFocusedEl: _this2.deleteFocusedEl,
|
|
389
|
-
index: index,
|
|
390
|
-
category: category,
|
|
391
|
-
error: categoriesErrors && categoriesErrors[category.id],
|
|
392
|
-
onChange: _this2.change,
|
|
393
|
-
onDelete: function onDelete() {
|
|
394
|
-
return _this2["delete"](category);
|
|
395
|
-
},
|
|
396
|
-
onAddChoice: _this2.addChoiceToCategory,
|
|
397
|
-
onMoveChoice: function onMoveChoice(choiceId, from, to, choiceIndex) {
|
|
398
|
-
return _this2.moveChoice(choiceId, from, to, choiceIndex);
|
|
399
|
-
},
|
|
400
|
-
toolbarOpts: toolbarOpts,
|
|
401
|
-
spellCheck: spellCheck,
|
|
402
|
-
onDeleteChoice: function onDeleteChoice(choice, choiceIndex) {
|
|
403
|
-
return _this2.deleteChoiceFromCategory(category, choice, choiceIndex);
|
|
404
|
-
},
|
|
405
|
-
maxImageWidth: maxImageWidth && maxImageWidth.categoryLabel || defaultImageMaxWidth,
|
|
406
|
-
maxImageHeight: maxImageHeight && maxImageHeight.categoryLabel || defaultImageMaxHeight,
|
|
407
|
-
uploadSoundSupport: uploadSoundSupport,
|
|
408
|
-
configuration: configuration
|
|
409
|
-
}));
|
|
410
|
-
})), associationError && /*#__PURE__*/_react["default"].createElement("div", {
|
|
411
|
-
className: classes.errorText
|
|
412
|
-
}, associationError), categoriesError && /*#__PURE__*/_react["default"].createElement("div", {
|
|
413
|
-
className: classes.errorText
|
|
414
|
-
}, categoriesError));
|
|
415
|
-
}
|
|
416
|
-
}]);
|
|
417
|
-
return Categories;
|
|
418
|
-
}(_react["default"].Component);
|
|
419
|
-
|
|
145
|
+
render() {
|
|
146
|
+
const {
|
|
147
|
+
model,
|
|
148
|
+
categories,
|
|
149
|
+
imageSupport,
|
|
150
|
+
uploadSoundSupport,
|
|
151
|
+
toolbarOpts,
|
|
152
|
+
spellCheck,
|
|
153
|
+
configuration,
|
|
154
|
+
defaultImageMaxHeight,
|
|
155
|
+
defaultImageMaxWidth,
|
|
156
|
+
mathMlOptions = {}
|
|
157
|
+
} = this.props;
|
|
158
|
+
const {
|
|
159
|
+
categoriesPerRow,
|
|
160
|
+
rowLabels,
|
|
161
|
+
errors
|
|
162
|
+
} = model;
|
|
163
|
+
const {
|
|
164
|
+
associationError,
|
|
165
|
+
categoriesError,
|
|
166
|
+
categoriesErrors
|
|
167
|
+
} = errors || {};
|
|
168
|
+
const {
|
|
169
|
+
maxCategories,
|
|
170
|
+
maxImageWidth = {},
|
|
171
|
+
maxImageHeight = {}
|
|
172
|
+
} = configuration || {};
|
|
173
|
+
const holderStyle = {
|
|
174
|
+
gridTemplateColumns: `repeat(${categoriesPerRow}, 1fr)`
|
|
175
|
+
};
|
|
176
|
+
const validationMessage = (0, _utils.generateValidationMessage)(configuration);
|
|
177
|
+
return /*#__PURE__*/_react.default.createElement(CategoriesContainer, null, /*#__PURE__*/_react.default.createElement(_header.default, {
|
|
178
|
+
label: "Categories",
|
|
179
|
+
buttonLabel: "ADD A CATEGORY",
|
|
180
|
+
onAdd: this.add,
|
|
181
|
+
info: /*#__PURE__*/_react.default.createElement(StyledTooltip, {
|
|
182
|
+
disableFocusListener: true,
|
|
183
|
+
disableTouchListener: true,
|
|
184
|
+
placement: 'right',
|
|
185
|
+
title: validationMessage
|
|
186
|
+
}, /*#__PURE__*/_react.default.createElement(_Info.default, {
|
|
187
|
+
fontSize: 'small',
|
|
188
|
+
color: 'primary',
|
|
189
|
+
style: {
|
|
190
|
+
marginLeft: '5px'
|
|
191
|
+
}
|
|
192
|
+
})),
|
|
193
|
+
buttonDisabled: maxCategories && categories && maxCategories === categories.length
|
|
194
|
+
}), /*#__PURE__*/_react.default.createElement(CategoriesHolder, {
|
|
195
|
+
style: holderStyle
|
|
196
|
+
}, categories.map((category, index) => {
|
|
197
|
+
const hasRowLabel = index % categoriesPerRow === 0;
|
|
198
|
+
const rowIndex = index / categoriesPerRow;
|
|
199
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
|
|
200
|
+
key: index
|
|
201
|
+
}, hasRowLabel && /*#__PURE__*/_react.default.createElement(_RowLabel.RowLabel, {
|
|
202
|
+
categoriesPerRow: categoriesPerRow,
|
|
203
|
+
disabled: false,
|
|
204
|
+
rowIndex: rowIndex,
|
|
205
|
+
markup: rowLabels[rowIndex] || '',
|
|
206
|
+
onChange: val => this.changeRowLabel(val, rowIndex),
|
|
207
|
+
imageSupport: imageSupport,
|
|
208
|
+
toolbarOpts: toolbarOpts,
|
|
209
|
+
spellCheck: spellCheck,
|
|
210
|
+
maxImageWidth: maxImageWidth && maxImageWidth.rowLabel || defaultImageMaxWidth,
|
|
211
|
+
maxImageHeight: maxImageHeight && maxImageHeight.rowLabel || defaultImageMaxHeight,
|
|
212
|
+
uploadSoundSupport: uploadSoundSupport,
|
|
213
|
+
mathMlOptions: mathMlOptions,
|
|
214
|
+
configuration: configuration
|
|
215
|
+
}), /*#__PURE__*/_react.default.createElement(_category.default, {
|
|
216
|
+
imageSupport: imageSupport,
|
|
217
|
+
focusedEl: this.state.focusedEl,
|
|
218
|
+
deleteFocusedEl: this.deleteFocusedEl,
|
|
219
|
+
index: index,
|
|
220
|
+
category: category,
|
|
221
|
+
error: categoriesErrors && categoriesErrors[category.id],
|
|
222
|
+
onChange: this.change,
|
|
223
|
+
onDelete: () => this.delete(category),
|
|
224
|
+
toolbarOpts: toolbarOpts,
|
|
225
|
+
spellCheck: spellCheck,
|
|
226
|
+
onDeleteChoice: (choice, choiceIndex) => this.deleteChoiceFromCategory(category, choice, choiceIndex),
|
|
227
|
+
maxImageWidth: maxImageWidth && maxImageWidth.categoryLabel || defaultImageMaxWidth,
|
|
228
|
+
maxImageHeight: maxImageHeight && maxImageHeight.categoryLabel || defaultImageMaxHeight,
|
|
229
|
+
uploadSoundSupport: uploadSoundSupport,
|
|
230
|
+
configuration: configuration,
|
|
231
|
+
alternateResponseIndex: undefined
|
|
232
|
+
}));
|
|
233
|
+
})), associationError && /*#__PURE__*/_react.default.createElement(ErrorText, null, associationError), categoriesError && /*#__PURE__*/_react.default.createElement(ErrorText, null, categoriesError));
|
|
234
|
+
}
|
|
235
|
+
}
|
|
420
236
|
exports.Categories = Categories;
|
|
421
|
-
(0, _defineProperty2
|
|
422
|
-
defaultImageMaxHeight: _propTypes
|
|
423
|
-
defaultImageMaxWidth: _propTypes
|
|
424
|
-
imageSupport: _propTypes
|
|
425
|
-
add: _propTypes
|
|
426
|
-
|
|
237
|
+
(0, _defineProperty2.default)(Categories, "propTypes", {
|
|
238
|
+
defaultImageMaxHeight: _propTypes.default.number,
|
|
239
|
+
defaultImageMaxWidth: _propTypes.default.number,
|
|
240
|
+
imageSupport: _propTypes.default.shape({
|
|
241
|
+
add: _propTypes.default.func.isRequired,
|
|
242
|
+
delete: _propTypes.default.func.isRequired
|
|
427
243
|
}),
|
|
428
|
-
uploadSoundSupport: _propTypes
|
|
429
|
-
add: _propTypes
|
|
430
|
-
|
|
244
|
+
uploadSoundSupport: _propTypes.default.shape({
|
|
245
|
+
add: _propTypes.default.func.isRequired,
|
|
246
|
+
delete: _propTypes.default.func.isRequired
|
|
431
247
|
}),
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
toolbarOpts: _propTypes["default"].object,
|
|
439
|
-
spellCheck: _propTypes["default"].bool
|
|
248
|
+
categories: _propTypes.default.array,
|
|
249
|
+
onModelChanged: _propTypes.default.func,
|
|
250
|
+
model: _propTypes.default.object.isRequired,
|
|
251
|
+
configuration: _propTypes.default.object.isRequired,
|
|
252
|
+
toolbarOpts: _propTypes.default.object,
|
|
253
|
+
spellCheck: _propTypes.default.bool
|
|
440
254
|
});
|
|
441
|
-
|
|
442
|
-
var _default = (0, _styles.withStyles)(styles)(Categories);
|
|
443
|
-
|
|
444
|
-
exports["default"] = _default;
|
|
255
|
+
var _default = exports.default = Categories;
|
|
445
256
|
//# sourceMappingURL=index.js.map
|