@pie-element/categorize 7.7.2-beta.1 → 7.7.2-beta.4
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 +113 -0
- package/configure/lib/defaults.js.map +1 -0
- package/configure/lib/design/builder.js +62 -0
- package/configure/lib/design/builder.js.map +1 -0
- package/configure/lib/design/buttons.js +105 -0
- package/configure/lib/design/buttons.js.map +1 -0
- package/configure/lib/design/categories/RowLabel.js +61 -0
- package/configure/lib/design/categories/RowLabel.js.map +1 -0
- package/configure/lib/design/categories/alternateResponses.js +242 -0
- package/configure/lib/design/categories/alternateResponses.js.map +1 -0
- package/configure/lib/design/categories/category.js +175 -0
- package/configure/lib/design/categories/category.js.map +1 -0
- package/configure/lib/design/categories/choice-preview.js +98 -0
- package/configure/lib/design/categories/choice-preview.js.map +1 -0
- package/configure/lib/design/categories/droppable-placeholder.js +155 -0
- package/configure/lib/design/categories/droppable-placeholder.js.map +1 -0
- package/configure/lib/design/categories/index.js +338 -0
- package/configure/lib/design/categories/index.js.map +1 -0
- package/configure/lib/design/choices/choice.js +243 -0
- package/configure/lib/design/choices/choice.js.map +1 -0
- package/configure/lib/design/choices/config.js +113 -0
- package/configure/lib/design/choices/config.js.map +1 -0
- package/configure/lib/design/choices/index.js +234 -0
- package/configure/lib/design/choices/index.js.map +1 -0
- package/configure/lib/design/header.js +83 -0
- package/configure/lib/design/header.js.map +1 -0
- package/configure/lib/design/index.js +430 -0
- package/configure/lib/design/index.js.map +1 -0
- package/configure/lib/design/input-header.js +138 -0
- package/configure/lib/design/input-header.js.map +1 -0
- package/configure/lib/index.js +115 -0
- package/configure/lib/index.js.map +1 -0
- package/configure/lib/main.js +72 -0
- package/configure/lib/main.js.map +1 -0
- package/configure/lib/utils.js +25 -0
- package/configure/lib/utils.js.map +1 -0
- package/configure/package.json +2 -2
- package/controller/lib/defaults.js +29 -0
- package/controller/lib/defaults.js.map +1 -0
- package/controller/lib/index.js +363 -0
- package/controller/lib/index.js.map +1 -0
- package/controller/lib/utils.js +49 -0
- package/controller/lib/utils.js.map +1 -0
- package/lib/categorize/categories.js +141 -0
- package/lib/categorize/categories.js.map +1 -0
- package/lib/categorize/category.js +106 -0
- package/lib/categorize/category.js.map +1 -0
- package/lib/categorize/choice.js +189 -0
- package/lib/categorize/choice.js.map +1 -0
- package/lib/categorize/choices.js +131 -0
- package/lib/categorize/choices.js.map +1 -0
- package/lib/categorize/droppable-placeholder.js +86 -0
- package/lib/categorize/droppable-placeholder.js.map +1 -0
- package/lib/categorize/grid-content.js +78 -0
- package/lib/categorize/grid-content.js.map +1 -0
- package/lib/categorize/index.js +275 -0
- package/lib/categorize/index.js.map +1 -0
- package/lib/index.js +87 -0
- package/lib/index.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = exports.Categories = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
12
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
13
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
14
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
15
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
+
var _react = _interopRequireDefault(require("react"));
|
|
17
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
18
|
+
var _styles = require("@material-ui/core/styles");
|
|
19
|
+
var _TextField = _interopRequireDefault(require("@material-ui/core/TextField"));
|
|
20
|
+
var _Typography = _interopRequireDefault(require("@material-ui/core/Typography"));
|
|
21
|
+
var _configUi = require("@pie-lib/config-ui");
|
|
22
|
+
var _editableHtml = _interopRequireDefault(require("@pie-lib/editable-html"));
|
|
23
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
24
|
+
var _Info = _interopRequireDefault(require("@material-ui/icons/Info"));
|
|
25
|
+
var _Tooltip = _interopRequireDefault(require("@material-ui/core/Tooltip"));
|
|
26
|
+
var _categorize = require("@pie-lib/categorize");
|
|
27
|
+
var _category = _interopRequireDefault(require("./category"));
|
|
28
|
+
var _header = _interopRequireDefault(require("../header"));
|
|
29
|
+
var _utils = require("../../utils");
|
|
30
|
+
var _RowLabel = require("./RowLabel");
|
|
31
|
+
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); }; }
|
|
32
|
+
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; } }
|
|
33
|
+
var styles = function styles(theme) {
|
|
34
|
+
return {
|
|
35
|
+
categories: {
|
|
36
|
+
marginBottom: theme.spacing.unit
|
|
37
|
+
},
|
|
38
|
+
categoriesHolder: {
|
|
39
|
+
display: 'grid',
|
|
40
|
+
gridRowGap: "".concat(theme.spacing.unit, "px"),
|
|
41
|
+
gridColumnGap: "".concat(theme.spacing.unit, "px")
|
|
42
|
+
},
|
|
43
|
+
row: {
|
|
44
|
+
display: 'grid',
|
|
45
|
+
gridTemplateColumns: 'repeat(2, 1fr)',
|
|
46
|
+
gridColumnGap: "".concat(theme.spacing.unit, "px"),
|
|
47
|
+
alignItems: 'baseline',
|
|
48
|
+
width: '100%',
|
|
49
|
+
marginTop: theme.spacing.unit,
|
|
50
|
+
marginBottom: 2 * theme.spacing.unit
|
|
51
|
+
},
|
|
52
|
+
rowLabel: {
|
|
53
|
+
gridColumn: '1/3'
|
|
54
|
+
},
|
|
55
|
+
rowLabelHolder: {
|
|
56
|
+
width: '100%'
|
|
57
|
+
},
|
|
58
|
+
tooltip: {
|
|
59
|
+
fontSize: '12px',
|
|
60
|
+
whiteSpace: 'pre',
|
|
61
|
+
maxWidth: '500px'
|
|
62
|
+
},
|
|
63
|
+
errorText: {
|
|
64
|
+
fontSize: '12px',
|
|
65
|
+
color: 'red',
|
|
66
|
+
padding: '5px 0'
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
var Categories = /*#__PURE__*/function (_React$Component) {
|
|
71
|
+
(0, _inherits2["default"])(Categories, _React$Component);
|
|
72
|
+
var _super = _createSuper(Categories);
|
|
73
|
+
function Categories() {
|
|
74
|
+
var _this;
|
|
75
|
+
(0, _classCallCheck2["default"])(this, Categories);
|
|
76
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
77
|
+
args[_key] = arguments[_key];
|
|
78
|
+
}
|
|
79
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
80
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
|
|
81
|
+
focusedEl: null
|
|
82
|
+
});
|
|
83
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "add", function () {
|
|
84
|
+
var _this$props = _this.props,
|
|
85
|
+
model = _this$props.model,
|
|
86
|
+
oldCategories = _this$props.categories;
|
|
87
|
+
var categoriesPerRow = model.categoriesPerRow;
|
|
88
|
+
var id = _configUi.choiceUtils.firstAvailableIndex(model.categories.map(function (a) {
|
|
89
|
+
return a.id;
|
|
90
|
+
}), 0);
|
|
91
|
+
var data = {
|
|
92
|
+
id: id,
|
|
93
|
+
label: 'Category ' + id
|
|
94
|
+
};
|
|
95
|
+
var addRowLabel = model.categories.length % categoriesPerRow === 0;
|
|
96
|
+
var rowLabels = (0, _toConsumableArray2["default"])(model.rowLabels);
|
|
97
|
+
if (addRowLabel) {
|
|
98
|
+
rowLabels.push('');
|
|
99
|
+
}
|
|
100
|
+
_this.setState({
|
|
101
|
+
focusedEl: oldCategories.length
|
|
102
|
+
}, function () {
|
|
103
|
+
_this.props.onModelChanged({
|
|
104
|
+
rowLabels: rowLabels,
|
|
105
|
+
categories: model.categories.concat([data])
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "deleteFocusedEl", function () {
|
|
110
|
+
_this.setState({
|
|
111
|
+
focusedEl: null
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "delete", function (category) {
|
|
115
|
+
var _this$props2 = _this.props,
|
|
116
|
+
model = _this$props2.model,
|
|
117
|
+
onModelChanged = _this$props2.onModelChanged;
|
|
118
|
+
var index = model.categories.findIndex(function (a) {
|
|
119
|
+
return a.id === category.id;
|
|
120
|
+
});
|
|
121
|
+
if (index !== -1) {
|
|
122
|
+
model.categories.splice(index, 1);
|
|
123
|
+
model.correctResponse = (0, _categorize.removeCategory)(category.id, model.correctResponse);
|
|
124
|
+
onModelChanged(model);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "change", function (c) {
|
|
128
|
+
var categories = _this.props.categories;
|
|
129
|
+
var index = categories.findIndex(function (a) {
|
|
130
|
+
return a.id === c.id;
|
|
131
|
+
});
|
|
132
|
+
if (index !== -1) {
|
|
133
|
+
categories.splice(index, 1, c);
|
|
134
|
+
_this.props.onModelChanged({
|
|
135
|
+
categories: categories
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "addChoiceToCategory", function (addedChoice, categoryId) {
|
|
140
|
+
var _this$props3 = _this.props,
|
|
141
|
+
model = _this$props3.model,
|
|
142
|
+
onModelChanged = _this$props3.onModelChanged;
|
|
143
|
+
var _ref = model || {},
|
|
144
|
+
_ref$choices = _ref.choices,
|
|
145
|
+
choices = _ref$choices === void 0 ? [] : _ref$choices,
|
|
146
|
+
_ref$correctResponse = _ref.correctResponse,
|
|
147
|
+
correctResponse = _ref$correctResponse === void 0 ? [] : _ref$correctResponse;
|
|
148
|
+
var choice = (choices || []).find(function (choice) {
|
|
149
|
+
return choice.id === addedChoice.id;
|
|
150
|
+
});
|
|
151
|
+
correctResponse = (0, _categorize.moveChoiceToCategory)(addedChoice.id, undefined, categoryId, 0, model.correctResponse);
|
|
152
|
+
// if multiplePlacements not allowed, ensure the consistency in the other categories
|
|
153
|
+
if (choice.categoryCount !== 0) {
|
|
154
|
+
correctResponse = (0, _categorize.verifyAllowMultiplePlacements)(addedChoice, categoryId, correctResponse);
|
|
155
|
+
}
|
|
156
|
+
onModelChanged({
|
|
157
|
+
correctResponse: correctResponse
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "deleteChoiceFromCategory", function (category, choice, choiceIndex) {
|
|
161
|
+
var _this$props4 = _this.props,
|
|
162
|
+
model = _this$props4.model,
|
|
163
|
+
onModelChanged = _this$props4.onModelChanged;
|
|
164
|
+
var correctResponse = (0, _categorize.removeChoiceFromCategory)(choice.id, category.id, choiceIndex, model.correctResponse);
|
|
165
|
+
onModelChanged({
|
|
166
|
+
correctResponse: correctResponse
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "moveChoice", function (choiceId, from, to, choiceIndex) {
|
|
170
|
+
var _this$props5 = _this.props,
|
|
171
|
+
model = _this$props5.model,
|
|
172
|
+
onModelChanged = _this$props5.onModelChanged;
|
|
173
|
+
var _ref2 = model || {},
|
|
174
|
+
choices = _ref2.choices,
|
|
175
|
+
_ref2$correctResponse = _ref2.correctResponse,
|
|
176
|
+
correctResponse = _ref2$correctResponse === void 0 ? [] : _ref2$correctResponse;
|
|
177
|
+
var choice = (choices || []).find(function (choice) {
|
|
178
|
+
return choice.id === choiceId;
|
|
179
|
+
});
|
|
180
|
+
if (to === from || !choice) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (choice.categoryCount !== 0) {
|
|
184
|
+
correctResponse = (0, _categorize.moveChoiceToCategory)(choice.id, from, to, choiceIndex, correctResponse);
|
|
185
|
+
correctResponse = (0, _categorize.verifyAllowMultiplePlacements)(choice, to, correctResponse);
|
|
186
|
+
} else if (choice.categoryCount === 0) {
|
|
187
|
+
correctResponse = (0, _categorize.moveChoiceToCategory)(choice.id, undefined, to, 0, correctResponse);
|
|
188
|
+
}
|
|
189
|
+
onModelChanged({
|
|
190
|
+
correctResponse: correctResponse
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeRowLabel", function (val, index) {
|
|
194
|
+
var model = _this.props.model;
|
|
195
|
+
var rowLabels = model.rowLabels;
|
|
196
|
+
var newRowLabels = (0, _toConsumableArray2["default"])(rowLabels);
|
|
197
|
+
if (newRowLabels.length < index) {
|
|
198
|
+
newRowLabels.push(val);
|
|
199
|
+
} else {
|
|
200
|
+
newRowLabels[index] = val;
|
|
201
|
+
}
|
|
202
|
+
_this.props.onModelChanged({
|
|
203
|
+
rowLabels: newRowLabels
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
return _this;
|
|
207
|
+
}
|
|
208
|
+
(0, _createClass2["default"])(Categories, [{
|
|
209
|
+
key: "render",
|
|
210
|
+
value: function render() {
|
|
211
|
+
var _this2 = this;
|
|
212
|
+
var _this$props6 = this.props,
|
|
213
|
+
model = _this$props6.model,
|
|
214
|
+
classes = _this$props6.classes,
|
|
215
|
+
className = _this$props6.className,
|
|
216
|
+
categories = _this$props6.categories,
|
|
217
|
+
imageSupport = _this$props6.imageSupport,
|
|
218
|
+
uploadSoundSupport = _this$props6.uploadSoundSupport,
|
|
219
|
+
toolbarOpts = _this$props6.toolbarOpts,
|
|
220
|
+
spellCheck = _this$props6.spellCheck,
|
|
221
|
+
configuration = _this$props6.configuration,
|
|
222
|
+
defaultImageMaxHeight = _this$props6.defaultImageMaxHeight,
|
|
223
|
+
defaultImageMaxWidth = _this$props6.defaultImageMaxWidth;
|
|
224
|
+
var categoriesPerRow = model.categoriesPerRow,
|
|
225
|
+
rowLabels = model.rowLabels,
|
|
226
|
+
errors = model.errors;
|
|
227
|
+
var _ref3 = errors || {},
|
|
228
|
+
associationError = _ref3.associationError,
|
|
229
|
+
categoriesError = _ref3.categoriesError,
|
|
230
|
+
categoriesErrors = _ref3.categoriesErrors;
|
|
231
|
+
var _ref4 = configuration || {},
|
|
232
|
+
maxCategories = _ref4.maxCategories,
|
|
233
|
+
_ref4$maxImageWidth = _ref4.maxImageWidth,
|
|
234
|
+
maxImageWidth = _ref4$maxImageWidth === void 0 ? {} : _ref4$maxImageWidth,
|
|
235
|
+
_ref4$maxImageHeight = _ref4.maxImageHeight,
|
|
236
|
+
maxImageHeight = _ref4$maxImageHeight === void 0 ? {} : _ref4$maxImageHeight;
|
|
237
|
+
var holderStyle = {
|
|
238
|
+
gridTemplateColumns: "repeat(".concat(categoriesPerRow, ", 1fr)")
|
|
239
|
+
};
|
|
240
|
+
var validationMessage = (0, _utils.generateValidationMessage)(configuration);
|
|
241
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
242
|
+
className: (0, _classnames["default"])(classes.categories, className)
|
|
243
|
+
}, /*#__PURE__*/_react["default"].createElement(_header["default"], {
|
|
244
|
+
label: "Categories",
|
|
245
|
+
buttonLabel: "ADD A CATEGORY",
|
|
246
|
+
onAdd: this.add,
|
|
247
|
+
info: /*#__PURE__*/_react["default"].createElement(_Tooltip["default"], {
|
|
248
|
+
classes: {
|
|
249
|
+
tooltip: classes.tooltip
|
|
250
|
+
},
|
|
251
|
+
disableFocusListener: true,
|
|
252
|
+
disableTouchListener: true,
|
|
253
|
+
placement: 'right',
|
|
254
|
+
title: validationMessage
|
|
255
|
+
}, /*#__PURE__*/_react["default"].createElement(_Info["default"], {
|
|
256
|
+
fontSize: 'small',
|
|
257
|
+
color: 'primary',
|
|
258
|
+
style: {
|
|
259
|
+
marginLeft: '5px'
|
|
260
|
+
}
|
|
261
|
+
})),
|
|
262
|
+
buttonDisabled: maxCategories && categories && maxCategories === categories.length
|
|
263
|
+
}), associationError && /*#__PURE__*/_react["default"].createElement("div", {
|
|
264
|
+
className: classes.errorText
|
|
265
|
+
}, associationError), categoriesError && /*#__PURE__*/_react["default"].createElement("div", {
|
|
266
|
+
className: classes.errorText
|
|
267
|
+
}, categoriesError), /*#__PURE__*/_react["default"].createElement("div", {
|
|
268
|
+
className: classes.categoriesHolder,
|
|
269
|
+
style: holderStyle
|
|
270
|
+
}, categories.map(function (category, index) {
|
|
271
|
+
var hasRowLabel = index % categoriesPerRow === 0;
|
|
272
|
+
var rowIndex = index / categoriesPerRow;
|
|
273
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, {
|
|
274
|
+
key: index
|
|
275
|
+
}, hasRowLabel && /*#__PURE__*/_react["default"].createElement(_RowLabel.RowLabel, {
|
|
276
|
+
categoriesPerRow: categoriesPerRow,
|
|
277
|
+
disabled: false,
|
|
278
|
+
rowIndex: rowIndex,
|
|
279
|
+
markup: rowLabels[rowIndex] || '',
|
|
280
|
+
onChange: function onChange(val) {
|
|
281
|
+
return _this2.changeRowLabel(val, rowIndex);
|
|
282
|
+
},
|
|
283
|
+
imageSupport: imageSupport,
|
|
284
|
+
toolbarOpts: toolbarOpts,
|
|
285
|
+
spellCheck: spellCheck,
|
|
286
|
+
maxImageWidth: maxImageWidth && maxImageWidth.rowLabel || defaultImageMaxWidth,
|
|
287
|
+
maxImageHeight: maxImageHeight && maxImageHeight.rowLabel || defaultImageMaxHeight,
|
|
288
|
+
uploadSoundSupport: uploadSoundSupport
|
|
289
|
+
}), /*#__PURE__*/_react["default"].createElement(_category["default"], {
|
|
290
|
+
imageSupport: imageSupport,
|
|
291
|
+
focusedEl: _this2.state.focusedEl,
|
|
292
|
+
deleteFocusedEl: _this2.deleteFocusedEl,
|
|
293
|
+
index: index,
|
|
294
|
+
category: category,
|
|
295
|
+
error: categoriesErrors && categoriesErrors[category.id],
|
|
296
|
+
onChange: _this2.change,
|
|
297
|
+
onDelete: function onDelete() {
|
|
298
|
+
return _this2["delete"](category);
|
|
299
|
+
},
|
|
300
|
+
onAddChoice: _this2.addChoiceToCategory,
|
|
301
|
+
onMoveChoice: function onMoveChoice(choiceId, from, to, choiceIndex) {
|
|
302
|
+
return _this2.moveChoice(choiceId, from, to, choiceIndex);
|
|
303
|
+
},
|
|
304
|
+
toolbarOpts: toolbarOpts,
|
|
305
|
+
spellCheck: spellCheck,
|
|
306
|
+
onDeleteChoice: function onDeleteChoice(choice, choiceIndex) {
|
|
307
|
+
return _this2.deleteChoiceFromCategory(category, choice, choiceIndex);
|
|
308
|
+
},
|
|
309
|
+
maxImageWidth: maxImageWidth && maxImageWidth.categoryLabel || defaultImageMaxWidth,
|
|
310
|
+
maxImageHeight: maxImageHeight && maxImageHeight.categoryLabel || defaultImageMaxHeight,
|
|
311
|
+
uploadSoundSupport: uploadSoundSupport
|
|
312
|
+
}));
|
|
313
|
+
})));
|
|
314
|
+
}
|
|
315
|
+
}]);
|
|
316
|
+
return Categories;
|
|
317
|
+
}(_react["default"].Component);
|
|
318
|
+
exports.Categories = Categories;
|
|
319
|
+
(0, _defineProperty2["default"])(Categories, "propTypes", {
|
|
320
|
+
imageSupport: _propTypes["default"].shape({
|
|
321
|
+
add: _propTypes["default"].func.isRequired,
|
|
322
|
+
"delete": _propTypes["default"].func.isRequired
|
|
323
|
+
}),
|
|
324
|
+
uploadSoundSupport: _propTypes["default"].shape({
|
|
325
|
+
add: _propTypes["default"].func.isRequired,
|
|
326
|
+
"delete": _propTypes["default"].func.isRequired
|
|
327
|
+
}),
|
|
328
|
+
classes: _propTypes["default"].object.isRequired,
|
|
329
|
+
className: _propTypes["default"].string,
|
|
330
|
+
categories: _propTypes["default"].array,
|
|
331
|
+
onModelChanged: _propTypes["default"].func,
|
|
332
|
+
model: _propTypes["default"].object.isRequired,
|
|
333
|
+
configuration: _propTypes["default"].object.isRequired,
|
|
334
|
+
toolbarOpts: _propTypes["default"].object
|
|
335
|
+
});
|
|
336
|
+
var _default = (0, _styles.withStyles)(styles)(Categories);
|
|
337
|
+
exports["default"] = _default;
|
|
338
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_propTypes","_styles","_TextField","_Typography","_configUi","_editableHtml","_classnames","_Info","_Tooltip","_categorize","_category","_header","_utils","_RowLabel","_createSuper","Derived","hasNativeReflectConstruct","_isNativeReflectConstruct","_createSuperInternal","Super","_getPrototypeOf2","result","NewTarget","constructor","Reflect","construct","arguments","apply","_possibleConstructorReturn2","sham","Proxy","Boolean","prototype","valueOf","call","e","styles","theme","categories","marginBottom","spacing","unit","categoriesHolder","display","gridRowGap","concat","gridColumnGap","row","gridTemplateColumns","alignItems","width","marginTop","rowLabel","gridColumn","rowLabelHolder","tooltip","fontSize","whiteSpace","maxWidth","errorText","color","padding","Categories","_React$Component","_inherits2","_super","_this","_classCallCheck2","_len","length","args","Array","_key","_defineProperty2","_assertThisInitialized2","focusedEl","_this$props","props","model","oldCategories","categoriesPerRow","id","utils","firstAvailableIndex","map","a","data","label","addRowLabel","rowLabels","_toConsumableArray2","push","setState","onModelChanged","category","_this$props2","index","findIndex","splice","correctResponse","removeCategory","c","addedChoice","categoryId","_this$props3","_ref","_ref$choices","choices","_ref$correctResponse","choice","find","moveChoiceToCategory","undefined","categoryCount","verifyAllowMultiplePlacements","choiceIndex","_this$props4","removeChoiceFromCategory","choiceId","from","to","_this$props5","_ref2","_ref2$correctResponse","val","newRowLabels","_createClass2","key","value","render","_this2","_this$props6","classes","className","imageSupport","uploadSoundSupport","toolbarOpts","spellCheck","configuration","defaultImageMaxHeight","defaultImageMaxWidth","errors","_ref3","associationError","categoriesError","categoriesErrors","_ref4","maxCategories","_ref4$maxImageWidth","maxImageWidth","_ref4$maxImageHeight","maxImageHeight","holderStyle","validationMessage","generateValidationMessage","createElement","classNames","buttonLabel","onAdd","add","info","disableFocusListener","disableTouchListener","placement","title","style","marginLeft","buttonDisabled","hasRowLabel","rowIndex","Fragment","RowLabel","disabled","markup","onChange","changeRowLabel","state","deleteFocusedEl","error","change","onDelete","onAddChoice","addChoiceToCategory","onMoveChoice","moveChoice","onDeleteChoice","deleteChoiceFromCategory","categoryLabel","React","Component","exports","PropTypes","shape","func","isRequired","object","string","array","_default","withStyles"],"sources":["../../../src/design/categories/index.jsx"],"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"],"mappings":";;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,WAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,WAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,KAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,QAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,WAAA,GAAAV,OAAA;AAQA,IAAAW,SAAA,GAAAZ,sBAAA,CAAAC,OAAA;AACA,IAAAY,OAAA,GAAAb,sBAAA,CAAAC,OAAA;AACA,IAAAa,MAAA,GAAAb,OAAA;AACA,IAAAc,SAAA,GAAAd,OAAA;AAAsC,SAAAe,aAAAC,OAAA,QAAAC,yBAAA,GAAAC,yBAAA,oBAAAC,qBAAA,QAAAC,KAAA,OAAAC,gBAAA,aAAAL,OAAA,GAAAM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,CAACC;EACzB,CAAC,CAAC;EACF9D,OAAO,EAAE2D,qBAAS,CAACI,MAAM,CAACD,UAAU;EACpC7D,SAAS,EAAE0D,qBAAS,CAACK,MAAM;EAC3B9J,UAAU,EAAEyJ,qBAAS,CAACM,KAAK;EAC3BxG,cAAc,EAAEkG,qBAAS,CAACE,IAAI;EAC9BnH,KAAK,EAAEiH,qBAAS,CAACI,MAAM,CAACD,UAAU;EAClCxD,aAAa,EAAEqD,qBAAS,CAACI,MAAM,CAACD,UAAU;EAC1C1D,WAAW,EAAEuD,qBAAS,CAACI;AACzB,CAAC;AAAA,IAAAG,QAAA,GA8MY,IAAAC,kBAAU,EAACnK,MAAM,CAAC,CAAC0B,UAAU,CAAC;AAAAgI,OAAA,cAAAQ,QAAA"}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.specTarget = exports.spec = exports["default"] = exports.Choice = void 0;
|
|
8
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
11
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
12
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
13
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
14
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
+
var _react = _interopRequireDefault(require("react"));
|
|
16
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
17
|
+
var _styles = require("@material-ui/core/styles");
|
|
18
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
19
|
+
var _Card = _interopRequireDefault(require("@material-ui/core/Card"));
|
|
20
|
+
var _CardActions = _interopRequireDefault(require("@material-ui/core/CardActions"));
|
|
21
|
+
var _inputHeader = _interopRequireDefault(require("../input-header"));
|
|
22
|
+
var _configUi = require("@pie-lib/config-ui");
|
|
23
|
+
var _buttons = require("../buttons");
|
|
24
|
+
var _DragHandle = _interopRequireDefault(require("@material-ui/icons/DragHandle"));
|
|
25
|
+
var _reactDnd = require("react-dnd");
|
|
26
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
27
|
+
var _drag = require("@pie-lib/drag");
|
|
28
|
+
var _utils = require("../../utils");
|
|
29
|
+
var _flow = _interopRequireDefault(require("lodash/flow"));
|
|
30
|
+
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); }; }
|
|
31
|
+
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; } }
|
|
32
|
+
var log = (0, _debug["default"])('@pie-element:categorize:configure:choice');
|
|
33
|
+
var canDrag = function canDrag(props) {
|
|
34
|
+
if (props.lockChoiceOrder) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
var count = props.choice.categoryCount || 0;
|
|
38
|
+
if (count === 0) {
|
|
39
|
+
return true;
|
|
40
|
+
} else {
|
|
41
|
+
return props.correctResponseCount < count;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var Choice = /*#__PURE__*/function (_React$Component) {
|
|
45
|
+
(0, _inherits2["default"])(Choice, _React$Component);
|
|
46
|
+
var _super = _createSuper(Choice);
|
|
47
|
+
function Choice() {
|
|
48
|
+
var _this;
|
|
49
|
+
(0, _classCallCheck2["default"])(this, Choice);
|
|
50
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
51
|
+
args[_key] = arguments[_key];
|
|
52
|
+
}
|
|
53
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
54
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeContent", function (content) {
|
|
55
|
+
var _this$props = _this.props,
|
|
56
|
+
onChange = _this$props.onChange,
|
|
57
|
+
choice = _this$props.choice;
|
|
58
|
+
choice.content = content;
|
|
59
|
+
onChange(choice);
|
|
60
|
+
});
|
|
61
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeCategoryCount", function () {
|
|
62
|
+
var _this$props2 = _this.props,
|
|
63
|
+
onChange = _this$props2.onChange,
|
|
64
|
+
choice = _this$props2.choice;
|
|
65
|
+
if (choice.categoryCount === 1) {
|
|
66
|
+
choice.categoryCount = 0;
|
|
67
|
+
} else {
|
|
68
|
+
choice.categoryCount = 1;
|
|
69
|
+
}
|
|
70
|
+
onChange(choice);
|
|
71
|
+
});
|
|
72
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "isCheckboxShown", function (allowMultiplePlacements) {
|
|
73
|
+
return allowMultiplePlacements === _utils.multiplePlacements.perChoice;
|
|
74
|
+
});
|
|
75
|
+
return _this;
|
|
76
|
+
}
|
|
77
|
+
(0, _createClass2["default"])(Choice, [{
|
|
78
|
+
key: "render",
|
|
79
|
+
value: function render() {
|
|
80
|
+
var _this$props3 = this.props,
|
|
81
|
+
allowMultiplePlacements = _this$props3.allowMultiplePlacements,
|
|
82
|
+
classes = _this$props3.classes,
|
|
83
|
+
className = _this$props3.className,
|
|
84
|
+
choice = _this$props3.choice,
|
|
85
|
+
deleteFocusedEl = _this$props3.deleteFocusedEl,
|
|
86
|
+
focusedEl = _this$props3.focusedEl,
|
|
87
|
+
index = _this$props3.index,
|
|
88
|
+
onDelete = _this$props3.onDelete,
|
|
89
|
+
connectDropTarget = _this$props3.connectDropTarget,
|
|
90
|
+
connectDragSource = _this$props3.connectDragSource,
|
|
91
|
+
connectDragPreview = _this$props3.connectDragPreview,
|
|
92
|
+
imageSupport = _this$props3.imageSupport,
|
|
93
|
+
spellCheck = _this$props3.spellCheck,
|
|
94
|
+
toolbarOpts = _this$props3.toolbarOpts,
|
|
95
|
+
error = _this$props3.error,
|
|
96
|
+
maxImageWidth = _this$props3.maxImageWidth,
|
|
97
|
+
maxImageHeight = _this$props3.maxImageHeight,
|
|
98
|
+
uploadSoundSupport = _this$props3.uploadSoundSupport;
|
|
99
|
+
var showRemoveAfterPlacing = this.isCheckboxShown(allowMultiplePlacements);
|
|
100
|
+
var draggable = canDrag(this.props);
|
|
101
|
+
return /*#__PURE__*/_react["default"].createElement(_Card["default"], {
|
|
102
|
+
className: (0, _classnames["default"])(classes.choice, className)
|
|
103
|
+
}, /*#__PURE__*/_react["default"].createElement(_CardActions["default"], {
|
|
104
|
+
className: classes.actions
|
|
105
|
+
}, connectDragSource(connectDropTarget( /*#__PURE__*/_react["default"].createElement("span", {
|
|
106
|
+
className: (0, _classnames["default"])(classes.dragHandle, draggable === false && classes.dragDisabled)
|
|
107
|
+
}, /*#__PURE__*/_react["default"].createElement(_DragHandle["default"], {
|
|
108
|
+
color: draggable ? 'primary' : 'disabled'
|
|
109
|
+
}))))), connectDragPreview( /*#__PURE__*/_react["default"].createElement("span", null, /*#__PURE__*/_react["default"].createElement(_inputHeader["default"], {
|
|
110
|
+
imageSupport: imageSupport,
|
|
111
|
+
focusedEl: focusedEl,
|
|
112
|
+
deleteFocusedEl: deleteFocusedEl,
|
|
113
|
+
index: index,
|
|
114
|
+
label: choice.content,
|
|
115
|
+
onChange: this.changeContent,
|
|
116
|
+
onDelete: onDelete,
|
|
117
|
+
toolbarOpts: toolbarOpts,
|
|
118
|
+
spellCheck: spellCheck,
|
|
119
|
+
error: error,
|
|
120
|
+
maxImageWidth: maxImageWidth,
|
|
121
|
+
maxImageHeight: maxImageHeight,
|
|
122
|
+
uploadSoundSupport: uploadSoundSupport
|
|
123
|
+
}), error && /*#__PURE__*/_react["default"].createElement("div", {
|
|
124
|
+
className: classes.errorText
|
|
125
|
+
}, error))), /*#__PURE__*/_react["default"].createElement(_CardActions["default"], {
|
|
126
|
+
className: classes.actions
|
|
127
|
+
}, /*#__PURE__*/_react["default"].createElement(_buttons.DeleteButton, {
|
|
128
|
+
label: 'delete',
|
|
129
|
+
onClick: onDelete
|
|
130
|
+
}), showRemoveAfterPlacing && /*#__PURE__*/_react["default"].createElement(_configUi.Checkbox, {
|
|
131
|
+
mini: true,
|
|
132
|
+
label: 'Remove after placing',
|
|
133
|
+
checked: choice.categoryCount === 1,
|
|
134
|
+
onChange: this.changeCategoryCount
|
|
135
|
+
})));
|
|
136
|
+
}
|
|
137
|
+
}]);
|
|
138
|
+
return Choice;
|
|
139
|
+
}(_react["default"].Component);
|
|
140
|
+
exports.Choice = Choice;
|
|
141
|
+
(0, _defineProperty2["default"])(Choice, "propTypes", {
|
|
142
|
+
allowMultiplePlacements: _propTypes["default"].string,
|
|
143
|
+
classes: _propTypes["default"].object.isRequired,
|
|
144
|
+
className: _propTypes["default"].string,
|
|
145
|
+
choice: _propTypes["default"].object.isRequired,
|
|
146
|
+
deleteFocusedEl: _propTypes["default"].func,
|
|
147
|
+
focusedEl: _propTypes["default"].number,
|
|
148
|
+
index: _propTypes["default"].number,
|
|
149
|
+
lockChoiceOrder: _propTypes["default"].bool,
|
|
150
|
+
onChange: _propTypes["default"].func.isRequired,
|
|
151
|
+
onDelete: _propTypes["default"].func.isRequired,
|
|
152
|
+
connectDragSource: _propTypes["default"].func.isRequired,
|
|
153
|
+
connectDragPreview: _propTypes["default"].func.isRequired,
|
|
154
|
+
correctResponseCount: _propTypes["default"].number.isRequired,
|
|
155
|
+
imageSupport: _propTypes["default"].shape({
|
|
156
|
+
add: _propTypes["default"].func.isRequired,
|
|
157
|
+
"delete": _propTypes["default"].func.isRequired
|
|
158
|
+
}),
|
|
159
|
+
toolbarOpts: _propTypes["default"].object,
|
|
160
|
+
error: _propTypes["default"].string,
|
|
161
|
+
uploadSoundSupport: _propTypes["default"].shape({
|
|
162
|
+
add: _propTypes["default"].func.isRequired,
|
|
163
|
+
"delete": _propTypes["default"].func.isRequired
|
|
164
|
+
})
|
|
165
|
+
});
|
|
166
|
+
(0, _defineProperty2["default"])(Choice, "defaultProps", {});
|
|
167
|
+
var styles = function styles(theme) {
|
|
168
|
+
return {
|
|
169
|
+
actions: {
|
|
170
|
+
padding: 0,
|
|
171
|
+
justifyContent: 'space-between'
|
|
172
|
+
},
|
|
173
|
+
choice: {
|
|
174
|
+
padding: theme.spacing.unit,
|
|
175
|
+
overflow: 'visible'
|
|
176
|
+
},
|
|
177
|
+
dragHandle: {
|
|
178
|
+
cursor: 'move'
|
|
179
|
+
},
|
|
180
|
+
dragDisabled: {
|
|
181
|
+
cursor: 'inherit'
|
|
182
|
+
},
|
|
183
|
+
errorText: {
|
|
184
|
+
fontSize: '11px',
|
|
185
|
+
color: 'red',
|
|
186
|
+
paddingBottom: '5px'
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
var StyledChoice = (0, _styles.withStyles)(styles)(Choice);
|
|
191
|
+
var spec = {
|
|
192
|
+
canDrag: canDrag,
|
|
193
|
+
beginDrag: function beginDrag(props) {
|
|
194
|
+
var out = {
|
|
195
|
+
id: props.choice.id,
|
|
196
|
+
index: props.index
|
|
197
|
+
};
|
|
198
|
+
log('[beginDrag] out:', out);
|
|
199
|
+
return out;
|
|
200
|
+
},
|
|
201
|
+
endDrag: function endDrag(props, monitor) {
|
|
202
|
+
if (!monitor.didDrop()) {
|
|
203
|
+
var item = monitor.getItem();
|
|
204
|
+
if (item.categoryId) {
|
|
205
|
+
log('wasnt droppped - what to do?');
|
|
206
|
+
props.onRemoveChoice(item);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
exports.spec = spec;
|
|
212
|
+
var specTarget = {
|
|
213
|
+
drop: function drop(props, monitor) {
|
|
214
|
+
log('[drop] props: ', props);
|
|
215
|
+
var item = monitor.getItem();
|
|
216
|
+
props.rearrangeChoices(item.index, props.index);
|
|
217
|
+
},
|
|
218
|
+
canDrop: function canDrop(props, monitor) {
|
|
219
|
+
var item = monitor.getItem();
|
|
220
|
+
return props.choice.id !== item.id;
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
exports.specTarget = specTarget;
|
|
224
|
+
var _default = _drag.uid.withUid((0, _flow["default"])((0, _reactDnd.DragSource)(function (_ref) {
|
|
225
|
+
var uid = _ref.uid;
|
|
226
|
+
return uid;
|
|
227
|
+
}, spec, function (connect, monitor) {
|
|
228
|
+
return {
|
|
229
|
+
connectDragSource: connect.dragSource(),
|
|
230
|
+
connectDragPreview: connect.dragPreview(),
|
|
231
|
+
isDragging: monitor.isDragging()
|
|
232
|
+
};
|
|
233
|
+
}), (0, _reactDnd.DropTarget)(function (_ref2) {
|
|
234
|
+
var uid = _ref2.uid;
|
|
235
|
+
return uid;
|
|
236
|
+
}, specTarget, function (connect, monitor) {
|
|
237
|
+
return {
|
|
238
|
+
connectDropTarget: connect.dropTarget(),
|
|
239
|
+
isOver: monitor.isOver()
|
|
240
|
+
};
|
|
241
|
+
}))(StyledChoice));
|
|
242
|
+
exports["default"] = _default;
|
|
243
|
+
//# sourceMappingURL=choice.js.map
|