@pie-element/categorize 11.0.5-esm.1 → 11.1.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/CHANGELOG.md +8 -0
- package/configure/CHANGELOG.md +8 -0
- package/configure/package.json +8 -8
- package/controller/CHANGELOG.md +8 -0
- package/controller/package.json +5 -5
- package/package.json +10 -27
- package/esm/configure.js +0 -5025
- package/esm/configure.js.map +0 -1
- package/esm/controller.js +0 -456
- package/esm/controller.js.map +0 -1
- package/esm/element.js +0 -3118
- package/esm/element.js.map +0 -1
- package/module/configure.js +0 -1
- package/module/controller.js +0 -6076
- package/module/demo.js +0 -382
- package/module/element.js +0 -1
- package/module/index.html +0 -21
- package/module/manifest.json +0 -22
- package/module/print-demo.js +0 -420
- package/module/print.html +0 -18
package/esm/configure.js
DELETED
|
@@ -1,5025 +0,0 @@
|
|
|
1
|
-
import React, { createContext, isValidElement, cloneElement, createRef, Component } from 'react';
|
|
2
|
-
import ReactDOM from 'react-dom';
|
|
3
|
-
import { ModelUpdatedEvent, InsertImageEvent, DeleteImageEvent, InsertSoundEvent, DeleteSoundEvent } from '@pie-framework/pie-configure-events';
|
|
4
|
-
import { renderMath } from '@pie-lib/math-rendering';
|
|
5
|
-
import PropTypes from 'prop-types';
|
|
6
|
-
import { withStyles } from '@material-ui/core/styles';
|
|
7
|
-
import { choiceUtils, Checkbox, layout, AlertDialog, InputContainer as InputContainer$1, FeedbackConfig, settings } from '@pie-lib/config-ui';
|
|
8
|
-
import { removeCategory, moveChoiceToCategory, verifyAllowMultiplePlacements, removeChoiceFromCategory, moveChoiceToAlternate, removeChoiceFromAlternate, removeAllChoices, rearrangeChoices, ensureNoExtraChoicesInAnswer, ensureNoExtraChoicesInAlternate, countInAnswer } from '@pie-lib/categorize';
|
|
9
|
-
import EditableHtml from '@pie-lib/editable-html';
|
|
10
|
-
import { Choice as Choice$2, PlaceHolder as PlaceHolder$1, uid, withDragContext } from '@pie-lib/drag';
|
|
11
|
-
import classNames from 'classnames';
|
|
12
|
-
import require$$3 from '@material-ui/core/SvgIcon';
|
|
13
|
-
import Tooltip from '@material-ui/core/Tooltip';
|
|
14
|
-
import Card from '@material-ui/core/Card';
|
|
15
|
-
import CardActions from '@material-ui/core/CardActions';
|
|
16
|
-
import Button from '@material-ui/core/Button';
|
|
17
|
-
import '@material-ui/core/Divider';
|
|
18
|
-
import IconButton from '@material-ui/core/IconButton';
|
|
19
|
-
import { HtmlAndMath, color, InputContainer } from '@pie-lib/render-ui';
|
|
20
|
-
import debug from 'debug';
|
|
21
|
-
import { jsx } from 'react/jsx-runtime';
|
|
22
|
-
import Typography from '@material-ui/core/Typography';
|
|
23
|
-
import flow from 'lodash/flow';
|
|
24
|
-
import TextField from '@material-ui/core/TextField';
|
|
25
|
-
import cloneDeep from 'lodash/cloneDeep';
|
|
26
|
-
import Translator from '@pie-lib/translator';
|
|
27
|
-
|
|
28
|
-
function _extends() {
|
|
29
|
-
_extends = Object.assign || function (target) {
|
|
30
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
31
|
-
var source = arguments[i];
|
|
32
|
-
|
|
33
|
-
for (var key in source) {
|
|
34
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
35
|
-
target[key] = source[key];
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return target;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
return _extends.apply(this, arguments);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
47
|
-
if (source == null) return {};
|
|
48
|
-
var target = {};
|
|
49
|
-
var sourceKeys = Object.keys(source);
|
|
50
|
-
var key, i;
|
|
51
|
-
|
|
52
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
53
|
-
key = sourceKeys[i];
|
|
54
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
55
|
-
target[key] = source[key];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return target;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const getPluginProps = (props = {}, baseInputConfiguration = {}) => _extends({}, baseInputConfiguration, props);
|
|
62
|
-
|
|
63
|
-
var Info = {};
|
|
64
|
-
|
|
65
|
-
var interopRequireDefault = {exports: {}};
|
|
66
|
-
|
|
67
|
-
(function (module) {
|
|
68
|
-
function _interopRequireDefault(obj) {
|
|
69
|
-
return obj && obj.__esModule ? obj : {
|
|
70
|
-
"default": obj
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
75
|
-
}(interopRequireDefault));
|
|
76
|
-
|
|
77
|
-
var createSvgIcon$1 = {};
|
|
78
|
-
|
|
79
|
-
var pure$1 = {};
|
|
80
|
-
|
|
81
|
-
var shouldUpdate$1 = {};
|
|
82
|
-
|
|
83
|
-
var inheritsLoose = {exports: {}};
|
|
84
|
-
|
|
85
|
-
var setPrototypeOf = {exports: {}};
|
|
86
|
-
|
|
87
|
-
(function (module) {
|
|
88
|
-
function _setPrototypeOf(o, p) {
|
|
89
|
-
module.exports = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
90
|
-
o.__proto__ = p;
|
|
91
|
-
return o;
|
|
92
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
93
|
-
return _setPrototypeOf(o, p);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
97
|
-
}(setPrototypeOf));
|
|
98
|
-
|
|
99
|
-
(function (module) {
|
|
100
|
-
var setPrototypeOf$1 = setPrototypeOf.exports;
|
|
101
|
-
|
|
102
|
-
function _inheritsLoose(subClass, superClass) {
|
|
103
|
-
subClass.prototype = Object.create(superClass.prototype);
|
|
104
|
-
subClass.prototype.constructor = subClass;
|
|
105
|
-
setPrototypeOf$1(subClass, superClass);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
module.exports = _inheritsLoose, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
109
|
-
}(inheritsLoose));
|
|
110
|
-
|
|
111
|
-
var setDisplayName$1 = {};
|
|
112
|
-
|
|
113
|
-
var setStatic$1 = {};
|
|
114
|
-
|
|
115
|
-
setStatic$1.__esModule = true;
|
|
116
|
-
setStatic$1.default = void 0;
|
|
117
|
-
|
|
118
|
-
var setStatic = function setStatic(key, value) {
|
|
119
|
-
return function (BaseComponent) {
|
|
120
|
-
/* eslint-disable no-param-reassign */
|
|
121
|
-
BaseComponent[key] = value;
|
|
122
|
-
/* eslint-enable no-param-reassign */
|
|
123
|
-
|
|
124
|
-
return BaseComponent;
|
|
125
|
-
};
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
var _default$a = setStatic;
|
|
129
|
-
setStatic$1.default = _default$a;
|
|
130
|
-
|
|
131
|
-
var _interopRequireDefault$8 = interopRequireDefault.exports;
|
|
132
|
-
|
|
133
|
-
setDisplayName$1.__esModule = true;
|
|
134
|
-
setDisplayName$1.default = void 0;
|
|
135
|
-
|
|
136
|
-
var _setStatic = _interopRequireDefault$8(setStatic$1);
|
|
137
|
-
|
|
138
|
-
var setDisplayName = function setDisplayName(displayName) {
|
|
139
|
-
return (0, _setStatic.default)('displayName', displayName);
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
var _default$9 = setDisplayName;
|
|
143
|
-
setDisplayName$1.default = _default$9;
|
|
144
|
-
|
|
145
|
-
var wrapDisplayName$1 = {};
|
|
146
|
-
|
|
147
|
-
var getDisplayName$1 = {};
|
|
148
|
-
|
|
149
|
-
getDisplayName$1.__esModule = true;
|
|
150
|
-
getDisplayName$1.default = void 0;
|
|
151
|
-
|
|
152
|
-
var getDisplayName = function getDisplayName(Component) {
|
|
153
|
-
if (typeof Component === 'string') {
|
|
154
|
-
return Component;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
if (!Component) {
|
|
158
|
-
return undefined;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return Component.displayName || Component.name || 'Component';
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
var _default$8 = getDisplayName;
|
|
165
|
-
getDisplayName$1.default = _default$8;
|
|
166
|
-
|
|
167
|
-
var _interopRequireDefault$7 = interopRequireDefault.exports;
|
|
168
|
-
|
|
169
|
-
wrapDisplayName$1.__esModule = true;
|
|
170
|
-
wrapDisplayName$1.default = void 0;
|
|
171
|
-
|
|
172
|
-
var _getDisplayName = _interopRequireDefault$7(getDisplayName$1);
|
|
173
|
-
|
|
174
|
-
var wrapDisplayName = function wrapDisplayName(BaseComponent, hocName) {
|
|
175
|
-
return hocName + "(" + (0, _getDisplayName.default)(BaseComponent) + ")";
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
var _default$7 = wrapDisplayName;
|
|
179
|
-
wrapDisplayName$1.default = _default$7;
|
|
180
|
-
|
|
181
|
-
var _interopRequireDefault$6 = interopRequireDefault.exports;
|
|
182
|
-
|
|
183
|
-
shouldUpdate$1.__esModule = true;
|
|
184
|
-
shouldUpdate$1.default = void 0;
|
|
185
|
-
|
|
186
|
-
var _inheritsLoose2 = _interopRequireDefault$6(inheritsLoose.exports);
|
|
187
|
-
|
|
188
|
-
var _react$4 = React;
|
|
189
|
-
|
|
190
|
-
var _setDisplayName$1 = _interopRequireDefault$6(setDisplayName$1);
|
|
191
|
-
|
|
192
|
-
var _wrapDisplayName$1 = _interopRequireDefault$6(wrapDisplayName$1);
|
|
193
|
-
|
|
194
|
-
var shouldUpdate = function shouldUpdate(test) {
|
|
195
|
-
return function (BaseComponent) {
|
|
196
|
-
var factory = (0, _react$4.createFactory)(BaseComponent);
|
|
197
|
-
|
|
198
|
-
var ShouldUpdate =
|
|
199
|
-
/*#__PURE__*/
|
|
200
|
-
function (_Component) {
|
|
201
|
-
(0, _inheritsLoose2.default)(ShouldUpdate, _Component);
|
|
202
|
-
|
|
203
|
-
function ShouldUpdate() {
|
|
204
|
-
return _Component.apply(this, arguments) || this;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
var _proto = ShouldUpdate.prototype;
|
|
208
|
-
|
|
209
|
-
_proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
|
|
210
|
-
return test(this.props, nextProps);
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
_proto.render = function render() {
|
|
214
|
-
return factory(this.props);
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
return ShouldUpdate;
|
|
218
|
-
}(_react$4.Component);
|
|
219
|
-
|
|
220
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
221
|
-
return (0, _setDisplayName$1.default)((0, _wrapDisplayName$1.default)(BaseComponent, 'shouldUpdate'))(ShouldUpdate);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
return ShouldUpdate;
|
|
225
|
-
};
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
var _default$6 = shouldUpdate;
|
|
229
|
-
shouldUpdate$1.default = _default$6;
|
|
230
|
-
|
|
231
|
-
var shallowEqual$2 = {};
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
|
235
|
-
*
|
|
236
|
-
* This source code is licensed under the MIT license found in the
|
|
237
|
-
* LICENSE file in the root directory of this source tree.
|
|
238
|
-
*
|
|
239
|
-
* @typechecks
|
|
240
|
-
*
|
|
241
|
-
*/
|
|
242
|
-
|
|
243
|
-
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
247
|
-
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
248
|
-
*/
|
|
249
|
-
function is(x, y) {
|
|
250
|
-
// SameValue algorithm
|
|
251
|
-
if (x === y) {
|
|
252
|
-
// Steps 1-5, 7-10
|
|
253
|
-
// Steps 6.b-6.e: +0 != -0
|
|
254
|
-
// Added the nonzero y check to make Flow happy, but it is redundant
|
|
255
|
-
return x !== 0 || y !== 0 || 1 / x === 1 / y;
|
|
256
|
-
} else {
|
|
257
|
-
// Step 6.a: NaN == NaN
|
|
258
|
-
return x !== x && y !== y;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* Performs equality by iterating through keys on an object and returning false
|
|
264
|
-
* when any key has values which are not strictly equal between the arguments.
|
|
265
|
-
* Returns true when the values of all keys are strictly equal.
|
|
266
|
-
*/
|
|
267
|
-
function shallowEqual$1(objA, objB) {
|
|
268
|
-
if (is(objA, objB)) {
|
|
269
|
-
return true;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
|
|
273
|
-
return false;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
var keysA = Object.keys(objA);
|
|
277
|
-
var keysB = Object.keys(objB);
|
|
278
|
-
|
|
279
|
-
if (keysA.length !== keysB.length) {
|
|
280
|
-
return false;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
// Test for A's keys different from B.
|
|
284
|
-
for (var i = 0; i < keysA.length; i++) {
|
|
285
|
-
if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
|
|
286
|
-
return false;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
return true;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
var shallowEqual_1 = shallowEqual$1;
|
|
294
|
-
|
|
295
|
-
var _interopRequireDefault$5 = interopRequireDefault.exports;
|
|
296
|
-
|
|
297
|
-
shallowEqual$2.__esModule = true;
|
|
298
|
-
shallowEqual$2.default = void 0;
|
|
299
|
-
|
|
300
|
-
var _shallowEqual$1 = _interopRequireDefault$5(shallowEqual_1);
|
|
301
|
-
|
|
302
|
-
var _default$5 = _shallowEqual$1.default;
|
|
303
|
-
shallowEqual$2.default = _default$5;
|
|
304
|
-
|
|
305
|
-
var _interopRequireDefault$4 = interopRequireDefault.exports;
|
|
306
|
-
|
|
307
|
-
pure$1.__esModule = true;
|
|
308
|
-
pure$1.default = void 0;
|
|
309
|
-
|
|
310
|
-
var _shouldUpdate = _interopRequireDefault$4(shouldUpdate$1);
|
|
311
|
-
|
|
312
|
-
var _shallowEqual = _interopRequireDefault$4(shallowEqual$2);
|
|
313
|
-
|
|
314
|
-
var _setDisplayName = _interopRequireDefault$4(setDisplayName$1);
|
|
315
|
-
|
|
316
|
-
var _wrapDisplayName = _interopRequireDefault$4(wrapDisplayName$1);
|
|
317
|
-
|
|
318
|
-
var pure = function pure(BaseComponent) {
|
|
319
|
-
var hoc = (0, _shouldUpdate.default)(function (props, nextProps) {
|
|
320
|
-
return !(0, _shallowEqual.default)(props, nextProps);
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
324
|
-
return (0, _setDisplayName.default)((0, _wrapDisplayName.default)(BaseComponent, 'pure'))(hoc(BaseComponent));
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
return hoc(BaseComponent);
|
|
328
|
-
};
|
|
329
|
-
|
|
330
|
-
var _default$4 = pure;
|
|
331
|
-
pure$1.default = _default$4;
|
|
332
|
-
|
|
333
|
-
var _interopRequireDefault$3 = interopRequireDefault.exports;
|
|
334
|
-
|
|
335
|
-
Object.defineProperty(createSvgIcon$1, "__esModule", {
|
|
336
|
-
value: true
|
|
337
|
-
});
|
|
338
|
-
createSvgIcon$1.default = void 0;
|
|
339
|
-
|
|
340
|
-
var _react$3 = _interopRequireDefault$3(React);
|
|
341
|
-
|
|
342
|
-
var _pure = _interopRequireDefault$3(pure$1);
|
|
343
|
-
|
|
344
|
-
var _SvgIcon = _interopRequireDefault$3(require$$3);
|
|
345
|
-
|
|
346
|
-
function createSvgIcon(path, displayName) {
|
|
347
|
-
var Icon = function Icon(props) {
|
|
348
|
-
return _react$3.default.createElement(_SvgIcon.default, props, path);
|
|
349
|
-
};
|
|
350
|
-
|
|
351
|
-
Icon.displayName = "".concat(displayName, "Icon");
|
|
352
|
-
Icon = (0, _pure.default)(Icon);
|
|
353
|
-
Icon.muiName = 'SvgIcon';
|
|
354
|
-
return Icon;
|
|
355
|
-
}
|
|
356
|
-
var _default$3 = createSvgIcon;
|
|
357
|
-
createSvgIcon$1.default = _default$3;
|
|
358
|
-
|
|
359
|
-
var _interopRequireDefault$2 = interopRequireDefault.exports;
|
|
360
|
-
|
|
361
|
-
Object.defineProperty(Info, "__esModule", {
|
|
362
|
-
value: true
|
|
363
|
-
});
|
|
364
|
-
var default_1$2 = Info.default = void 0;
|
|
365
|
-
|
|
366
|
-
var _react$2 = _interopRequireDefault$2(React);
|
|
367
|
-
|
|
368
|
-
var _createSvgIcon$2 = _interopRequireDefault$2(createSvgIcon$1);
|
|
369
|
-
|
|
370
|
-
var _default$2 = (0, _createSvgIcon$2.default)(_react$2.default.createElement(_react$2.default.Fragment, null, _react$2.default.createElement("path", {
|
|
371
|
-
fill: "none",
|
|
372
|
-
d: "M0 0h24v24H0z"
|
|
373
|
-
}), _react$2.default.createElement("path", {
|
|
374
|
-
d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"
|
|
375
|
-
})), 'Info');
|
|
376
|
-
|
|
377
|
-
default_1$2 = Info.default = _default$2;
|
|
378
|
-
|
|
379
|
-
class InputHeader extends React.Component {
|
|
380
|
-
constructor(props) {
|
|
381
|
-
super(props);
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
componentDidMount() {
|
|
385
|
-
const {
|
|
386
|
-
focusedEl,
|
|
387
|
-
index
|
|
388
|
-
} = this.props;
|
|
389
|
-
|
|
390
|
-
if (focusedEl && index && focusedEl === index) {
|
|
391
|
-
this.inputRef.focus('end', null, true);
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
render() {
|
|
396
|
-
const {
|
|
397
|
-
onChange,
|
|
398
|
-
configuration,
|
|
399
|
-
label,
|
|
400
|
-
classes,
|
|
401
|
-
className,
|
|
402
|
-
deleteFocusedEl,
|
|
403
|
-
disabled,
|
|
404
|
-
imageSupport,
|
|
405
|
-
toolbarOpts,
|
|
406
|
-
spellCheck,
|
|
407
|
-
error,
|
|
408
|
-
maxImageWidth,
|
|
409
|
-
maxImageHeight,
|
|
410
|
-
uploadSoundSupport,
|
|
411
|
-
mathMlOptions = {}
|
|
412
|
-
} = this.props;
|
|
413
|
-
const {
|
|
414
|
-
headers,
|
|
415
|
-
baseInputConfiguration
|
|
416
|
-
} = configuration;
|
|
417
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
418
|
-
className: classNames(classes.inputHeader, className)
|
|
419
|
-
}, /*#__PURE__*/React.createElement(EditableHtml, {
|
|
420
|
-
imageSupport: imageSupport,
|
|
421
|
-
disabled: disabled,
|
|
422
|
-
ref: ref => this.inputRef = ref,
|
|
423
|
-
autoWidthToolbar: true,
|
|
424
|
-
label: 'label',
|
|
425
|
-
markup: label,
|
|
426
|
-
onChange: onChange,
|
|
427
|
-
className: classes.editor,
|
|
428
|
-
pluginProps: getPluginProps(headers == null ? void 0 : headers.inputConfiguration, baseInputConfiguration),
|
|
429
|
-
toolbarOpts: toolbarOpts,
|
|
430
|
-
spellCheck: spellCheck,
|
|
431
|
-
error: error,
|
|
432
|
-
maxImageWidth: maxImageWidth,
|
|
433
|
-
maxImageHeight: maxImageHeight,
|
|
434
|
-
uploadSoundSupport: uploadSoundSupport,
|
|
435
|
-
languageCharactersProps: [{
|
|
436
|
-
language: 'spanish'
|
|
437
|
-
}, {
|
|
438
|
-
language: 'special'
|
|
439
|
-
}],
|
|
440
|
-
onDone: () => {
|
|
441
|
-
deleteFocusedEl && deleteFocusedEl();
|
|
442
|
-
},
|
|
443
|
-
mathMlOptions: mathMlOptions
|
|
444
|
-
}));
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
}
|
|
448
|
-
InputHeader.propTypes = {
|
|
449
|
-
classes: PropTypes.object.isRequired,
|
|
450
|
-
className: PropTypes.string,
|
|
451
|
-
configuration: PropTypes.object.isRequired,
|
|
452
|
-
deleteFocusedEl: PropTypes.func,
|
|
453
|
-
disabled: PropTypes.bool,
|
|
454
|
-
focusedEl: PropTypes.number,
|
|
455
|
-
index: PropTypes.number,
|
|
456
|
-
label: PropTypes.string,
|
|
457
|
-
maxImageWidth: PropTypes.object,
|
|
458
|
-
maxImageHeight: PropTypes.object,
|
|
459
|
-
onChange: PropTypes.func,
|
|
460
|
-
onDelete: PropTypes.func,
|
|
461
|
-
imageSupport: PropTypes.shape({
|
|
462
|
-
add: PropTypes.func.isRequired,
|
|
463
|
-
delete: PropTypes.func.isRequired
|
|
464
|
-
}),
|
|
465
|
-
uploadSoundSupport: PropTypes.shape({
|
|
466
|
-
add: PropTypes.func.isRequired,
|
|
467
|
-
delete: PropTypes.func.isRequired
|
|
468
|
-
}),
|
|
469
|
-
toolbarOpts: PropTypes.object,
|
|
470
|
-
error: PropTypes.string,
|
|
471
|
-
spellCheck: PropTypes.bool
|
|
472
|
-
};
|
|
473
|
-
InputHeader.defaultProps = {};
|
|
474
|
-
|
|
475
|
-
const styles$d = theme => ({
|
|
476
|
-
editor: {
|
|
477
|
-
flex: '1',
|
|
478
|
-
paddingBottom: theme.spacing.unit,
|
|
479
|
-
maxWidth: '100%'
|
|
480
|
-
},
|
|
481
|
-
iconButtonRoot: {
|
|
482
|
-
width: 'auto',
|
|
483
|
-
height: 'auto'
|
|
484
|
-
},
|
|
485
|
-
inputHeader: {
|
|
486
|
-
display: 'flex',
|
|
487
|
-
justifyContent: 'space-between'
|
|
488
|
-
}
|
|
489
|
-
});
|
|
490
|
-
|
|
491
|
-
var InputHeader$1 = withStyles(styles$d)(InputHeader);
|
|
492
|
-
|
|
493
|
-
class RawAddButton extends React.Component {
|
|
494
|
-
render() {
|
|
495
|
-
const {
|
|
496
|
-
classes,
|
|
497
|
-
className,
|
|
498
|
-
label,
|
|
499
|
-
onClick,
|
|
500
|
-
disabled
|
|
501
|
-
} = this.props;
|
|
502
|
-
return /*#__PURE__*/React.createElement(Button, {
|
|
503
|
-
onClick: onClick,
|
|
504
|
-
disabled: disabled,
|
|
505
|
-
className: classNames(classes.addButton, className),
|
|
506
|
-
size: "small",
|
|
507
|
-
variant: "contained",
|
|
508
|
-
color: "primary"
|
|
509
|
-
}, label);
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
}
|
|
513
|
-
RawAddButton.propTypes = {
|
|
514
|
-
classes: PropTypes.object.isRequired,
|
|
515
|
-
className: PropTypes.string,
|
|
516
|
-
label: PropTypes.string,
|
|
517
|
-
onClick: PropTypes.func,
|
|
518
|
-
disabled: PropTypes.bool
|
|
519
|
-
};
|
|
520
|
-
RawAddButton.defaultProps = {
|
|
521
|
-
label: 'Add'
|
|
522
|
-
};
|
|
523
|
-
|
|
524
|
-
const styles$c = theme => ({
|
|
525
|
-
addButton: {
|
|
526
|
-
height: theme.spacing.unit * 4
|
|
527
|
-
}
|
|
528
|
-
});
|
|
529
|
-
|
|
530
|
-
const AddButton = withStyles(styles$c)(RawAddButton);
|
|
531
|
-
const DeleteButton = withStyles(() => ({
|
|
532
|
-
deleteButton: {
|
|
533
|
-
margin: 0,
|
|
534
|
-
padding: 0
|
|
535
|
-
}
|
|
536
|
-
}))(({
|
|
537
|
-
classes,
|
|
538
|
-
label,
|
|
539
|
-
onClick,
|
|
540
|
-
disabled
|
|
541
|
-
}) => /*#__PURE__*/React.createElement(Button, {
|
|
542
|
-
className: classes.deleteButton,
|
|
543
|
-
onClick: onClick,
|
|
544
|
-
size: "small",
|
|
545
|
-
color: "primary",
|
|
546
|
-
disabled: disabled
|
|
547
|
-
}, label));
|
|
548
|
-
|
|
549
|
-
var RemoveCircleOutline = {};
|
|
550
|
-
|
|
551
|
-
var _interopRequireDefault$1 = interopRequireDefault.exports;
|
|
552
|
-
|
|
553
|
-
Object.defineProperty(RemoveCircleOutline, "__esModule", {
|
|
554
|
-
value: true
|
|
555
|
-
});
|
|
556
|
-
var default_1$1 = RemoveCircleOutline.default = void 0;
|
|
557
|
-
|
|
558
|
-
var _react$1 = _interopRequireDefault$1(React);
|
|
559
|
-
|
|
560
|
-
var _createSvgIcon$1 = _interopRequireDefault$1(createSvgIcon$1);
|
|
561
|
-
|
|
562
|
-
var _default$1 = (0, _createSvgIcon$1.default)(_react$1.default.createElement(_react$1.default.Fragment, null, _react$1.default.createElement("path", {
|
|
563
|
-
fill: "none",
|
|
564
|
-
d: "M0 0h24v24H0z"
|
|
565
|
-
}), _react$1.default.createElement("path", {
|
|
566
|
-
d: "M7 11v2h10v-2H7zm5-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"
|
|
567
|
-
})), 'RemoveCircleOutline');
|
|
568
|
-
|
|
569
|
-
default_1$1 = RemoveCircleOutline.default = _default$1;
|
|
570
|
-
|
|
571
|
-
class ChoicePreview extends React.Component {
|
|
572
|
-
constructor(...args) {
|
|
573
|
-
super(...args);
|
|
574
|
-
|
|
575
|
-
this.delete = () => {
|
|
576
|
-
const {
|
|
577
|
-
onDelete,
|
|
578
|
-
choice
|
|
579
|
-
} = this.props;
|
|
580
|
-
onDelete(choice);
|
|
581
|
-
};
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
render() {
|
|
585
|
-
const {
|
|
586
|
-
alternateResponseIndex,
|
|
587
|
-
category,
|
|
588
|
-
classes,
|
|
589
|
-
className,
|
|
590
|
-
choice,
|
|
591
|
-
choiceIndex
|
|
592
|
-
} = this.props;
|
|
593
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
594
|
-
className: classNames(classes.choicePreview, className)
|
|
595
|
-
}, choice ? /*#__PURE__*/React.createElement(Choice$2, {
|
|
596
|
-
alternateResponseIndex: alternateResponseIndex,
|
|
597
|
-
category: category,
|
|
598
|
-
choice: choice,
|
|
599
|
-
choiceIndex: choiceIndex,
|
|
600
|
-
className: classes.overflowChoice,
|
|
601
|
-
onRemoveChoice: () => this.delete()
|
|
602
|
-
}, /*#__PURE__*/React.createElement(HtmlAndMath, {
|
|
603
|
-
html: choice == null ? void 0 : choice.content,
|
|
604
|
-
className: `${classes.breakWord}`
|
|
605
|
-
}), /*#__PURE__*/React.createElement(IconButton, {
|
|
606
|
-
"aria-label": "delete",
|
|
607
|
-
className: classNames(classes.delete, classes.customColor),
|
|
608
|
-
onClick: this.delete
|
|
609
|
-
}, /*#__PURE__*/React.createElement(default_1$1, null))) : null);
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
}
|
|
613
|
-
ChoicePreview.propTypes = {
|
|
614
|
-
alternateResponseIndex: PropTypes.number,
|
|
615
|
-
category: PropTypes.object,
|
|
616
|
-
classes: PropTypes.object.isRequired,
|
|
617
|
-
className: PropTypes.string,
|
|
618
|
-
choice: PropTypes.object.isRequired,
|
|
619
|
-
choiceIndex: PropTypes.number,
|
|
620
|
-
onDelete: PropTypes.func.isRequired
|
|
621
|
-
};
|
|
622
|
-
ChoicePreview.defaultProps = {};
|
|
623
|
-
|
|
624
|
-
const styles$b = () => ({
|
|
625
|
-
choicePreview: {
|
|
626
|
-
position: 'relative',
|
|
627
|
-
overflow: 'auto'
|
|
628
|
-
},
|
|
629
|
-
delete: {
|
|
630
|
-
position: 'absolute',
|
|
631
|
-
right: 0,
|
|
632
|
-
top: 0
|
|
633
|
-
},
|
|
634
|
-
breakWord: {
|
|
635
|
-
maxWidth: '90%',
|
|
636
|
-
wordBreak: 'break-all'
|
|
637
|
-
},
|
|
638
|
-
customColor: {
|
|
639
|
-
color: `${color.tertiary()} !important`
|
|
640
|
-
},
|
|
641
|
-
overflowChoice: {
|
|
642
|
-
overflow: 'auto'
|
|
643
|
-
}
|
|
644
|
-
});
|
|
645
|
-
|
|
646
|
-
var ChoicePreview$1 = withStyles(styles$b)(ChoicePreview);
|
|
647
|
-
|
|
648
|
-
/**
|
|
649
|
-
* Create the React Context
|
|
650
|
-
*/
|
|
651
|
-
|
|
652
|
-
var DndContext = createContext({
|
|
653
|
-
dragDropManager: undefined
|
|
654
|
-
});
|
|
655
|
-
|
|
656
|
-
/**
|
|
657
|
-
* Use invariant() to assert state which your program assumes to be true.
|
|
658
|
-
*
|
|
659
|
-
* Provide sprintf-style format (only %s is supported) and arguments
|
|
660
|
-
* to provide information about what broke and what you were
|
|
661
|
-
* expecting.
|
|
662
|
-
*
|
|
663
|
-
* The invariant message will be stripped in production, but the invariant
|
|
664
|
-
* will remain to ensure logic does not differ in production.
|
|
665
|
-
*/
|
|
666
|
-
function invariant(condition, format) {
|
|
667
|
-
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
668
|
-
args[_key - 2] = arguments[_key];
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
672
|
-
if (format === undefined) {
|
|
673
|
-
throw new Error('invariant requires an error message argument');
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
if (!condition) {
|
|
678
|
-
var error;
|
|
679
|
-
|
|
680
|
-
if (format === undefined) {
|
|
681
|
-
error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
|
|
682
|
-
} else {
|
|
683
|
-
var argIndex = 0;
|
|
684
|
-
error = new Error(format.replace(/%s/g, function () {
|
|
685
|
-
return args[argIndex++];
|
|
686
|
-
}));
|
|
687
|
-
error.name = 'Invariant Violation';
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
error.framesToPop = 1; // we don't care about invariant's own frame
|
|
691
|
-
|
|
692
|
-
throw error;
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
function _classCallCheck$7(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
697
|
-
|
|
698
|
-
function _defineProperties$7(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
699
|
-
|
|
700
|
-
function _createClass$7(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$7(Constructor.prototype, protoProps); if (staticProps) _defineProperties$7(Constructor, staticProps); return Constructor; }
|
|
701
|
-
|
|
702
|
-
function _defineProperty$7(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
703
|
-
var isCallingCanDrag = false;
|
|
704
|
-
var isCallingIsDragging = false;
|
|
705
|
-
var DragSourceMonitorImpl = /*#__PURE__*/function () {
|
|
706
|
-
function DragSourceMonitorImpl(manager) {
|
|
707
|
-
_classCallCheck$7(this, DragSourceMonitorImpl);
|
|
708
|
-
|
|
709
|
-
_defineProperty$7(this, "internalMonitor", void 0);
|
|
710
|
-
|
|
711
|
-
_defineProperty$7(this, "sourceId", null);
|
|
712
|
-
|
|
713
|
-
this.internalMonitor = manager.getMonitor();
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
_createClass$7(DragSourceMonitorImpl, [{
|
|
717
|
-
key: "receiveHandlerId",
|
|
718
|
-
value: function receiveHandlerId(sourceId) {
|
|
719
|
-
this.sourceId = sourceId;
|
|
720
|
-
}
|
|
721
|
-
}, {
|
|
722
|
-
key: "getHandlerId",
|
|
723
|
-
value: function getHandlerId() {
|
|
724
|
-
return this.sourceId;
|
|
725
|
-
}
|
|
726
|
-
}, {
|
|
727
|
-
key: "canDrag",
|
|
728
|
-
value: function canDrag() {
|
|
729
|
-
invariant(!isCallingCanDrag, 'You may not call monitor.canDrag() inside your canDrag() implementation. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source-monitor');
|
|
730
|
-
|
|
731
|
-
try {
|
|
732
|
-
isCallingCanDrag = true;
|
|
733
|
-
return this.internalMonitor.canDragSource(this.sourceId);
|
|
734
|
-
} finally {
|
|
735
|
-
isCallingCanDrag = false;
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
}, {
|
|
739
|
-
key: "isDragging",
|
|
740
|
-
value: function isDragging() {
|
|
741
|
-
if (!this.sourceId) {
|
|
742
|
-
return false;
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
invariant(!isCallingIsDragging, 'You may not call monitor.isDragging() inside your isDragging() implementation. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source-monitor');
|
|
746
|
-
|
|
747
|
-
try {
|
|
748
|
-
isCallingIsDragging = true;
|
|
749
|
-
return this.internalMonitor.isDraggingSource(this.sourceId);
|
|
750
|
-
} finally {
|
|
751
|
-
isCallingIsDragging = false;
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
}, {
|
|
755
|
-
key: "subscribeToStateChange",
|
|
756
|
-
value: function subscribeToStateChange(listener, options) {
|
|
757
|
-
return this.internalMonitor.subscribeToStateChange(listener, options);
|
|
758
|
-
}
|
|
759
|
-
}, {
|
|
760
|
-
key: "isDraggingSource",
|
|
761
|
-
value: function isDraggingSource(sourceId) {
|
|
762
|
-
return this.internalMonitor.isDraggingSource(sourceId);
|
|
763
|
-
}
|
|
764
|
-
}, {
|
|
765
|
-
key: "isOverTarget",
|
|
766
|
-
value: function isOverTarget(targetId, options) {
|
|
767
|
-
return this.internalMonitor.isOverTarget(targetId, options);
|
|
768
|
-
}
|
|
769
|
-
}, {
|
|
770
|
-
key: "getTargetIds",
|
|
771
|
-
value: function getTargetIds() {
|
|
772
|
-
return this.internalMonitor.getTargetIds();
|
|
773
|
-
}
|
|
774
|
-
}, {
|
|
775
|
-
key: "isSourcePublic",
|
|
776
|
-
value: function isSourcePublic() {
|
|
777
|
-
return this.internalMonitor.isSourcePublic();
|
|
778
|
-
}
|
|
779
|
-
}, {
|
|
780
|
-
key: "getSourceId",
|
|
781
|
-
value: function getSourceId() {
|
|
782
|
-
return this.internalMonitor.getSourceId();
|
|
783
|
-
}
|
|
784
|
-
}, {
|
|
785
|
-
key: "subscribeToOffsetChange",
|
|
786
|
-
value: function subscribeToOffsetChange(listener) {
|
|
787
|
-
return this.internalMonitor.subscribeToOffsetChange(listener);
|
|
788
|
-
}
|
|
789
|
-
}, {
|
|
790
|
-
key: "canDragSource",
|
|
791
|
-
value: function canDragSource(sourceId) {
|
|
792
|
-
return this.internalMonitor.canDragSource(sourceId);
|
|
793
|
-
}
|
|
794
|
-
}, {
|
|
795
|
-
key: "canDropOnTarget",
|
|
796
|
-
value: function canDropOnTarget(targetId) {
|
|
797
|
-
return this.internalMonitor.canDropOnTarget(targetId);
|
|
798
|
-
}
|
|
799
|
-
}, {
|
|
800
|
-
key: "getItemType",
|
|
801
|
-
value: function getItemType() {
|
|
802
|
-
return this.internalMonitor.getItemType();
|
|
803
|
-
}
|
|
804
|
-
}, {
|
|
805
|
-
key: "getItem",
|
|
806
|
-
value: function getItem() {
|
|
807
|
-
return this.internalMonitor.getItem();
|
|
808
|
-
}
|
|
809
|
-
}, {
|
|
810
|
-
key: "getDropResult",
|
|
811
|
-
value: function getDropResult() {
|
|
812
|
-
return this.internalMonitor.getDropResult();
|
|
813
|
-
}
|
|
814
|
-
}, {
|
|
815
|
-
key: "didDrop",
|
|
816
|
-
value: function didDrop() {
|
|
817
|
-
return this.internalMonitor.didDrop();
|
|
818
|
-
}
|
|
819
|
-
}, {
|
|
820
|
-
key: "getInitialClientOffset",
|
|
821
|
-
value: function getInitialClientOffset() {
|
|
822
|
-
return this.internalMonitor.getInitialClientOffset();
|
|
823
|
-
}
|
|
824
|
-
}, {
|
|
825
|
-
key: "getInitialSourceClientOffset",
|
|
826
|
-
value: function getInitialSourceClientOffset() {
|
|
827
|
-
return this.internalMonitor.getInitialSourceClientOffset();
|
|
828
|
-
}
|
|
829
|
-
}, {
|
|
830
|
-
key: "getSourceClientOffset",
|
|
831
|
-
value: function getSourceClientOffset() {
|
|
832
|
-
return this.internalMonitor.getSourceClientOffset();
|
|
833
|
-
}
|
|
834
|
-
}, {
|
|
835
|
-
key: "getClientOffset",
|
|
836
|
-
value: function getClientOffset() {
|
|
837
|
-
return this.internalMonitor.getClientOffset();
|
|
838
|
-
}
|
|
839
|
-
}, {
|
|
840
|
-
key: "getDifferenceFromInitialOffset",
|
|
841
|
-
value: function getDifferenceFromInitialOffset() {
|
|
842
|
-
return this.internalMonitor.getDifferenceFromInitialOffset();
|
|
843
|
-
}
|
|
844
|
-
}]);
|
|
845
|
-
|
|
846
|
-
return DragSourceMonitorImpl;
|
|
847
|
-
}();
|
|
848
|
-
|
|
849
|
-
function _classCallCheck$6(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
850
|
-
|
|
851
|
-
function _defineProperties$6(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
852
|
-
|
|
853
|
-
function _createClass$6(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$6(Constructor.prototype, protoProps); if (staticProps) _defineProperties$6(Constructor, staticProps); return Constructor; }
|
|
854
|
-
|
|
855
|
-
function _defineProperty$6(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
856
|
-
var isCallingCanDrop = false;
|
|
857
|
-
var DropTargetMonitorImpl = /*#__PURE__*/function () {
|
|
858
|
-
function DropTargetMonitorImpl(manager) {
|
|
859
|
-
_classCallCheck$6(this, DropTargetMonitorImpl);
|
|
860
|
-
|
|
861
|
-
_defineProperty$6(this, "internalMonitor", void 0);
|
|
862
|
-
|
|
863
|
-
_defineProperty$6(this, "targetId", null);
|
|
864
|
-
|
|
865
|
-
this.internalMonitor = manager.getMonitor();
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
_createClass$6(DropTargetMonitorImpl, [{
|
|
869
|
-
key: "receiveHandlerId",
|
|
870
|
-
value: function receiveHandlerId(targetId) {
|
|
871
|
-
this.targetId = targetId;
|
|
872
|
-
}
|
|
873
|
-
}, {
|
|
874
|
-
key: "getHandlerId",
|
|
875
|
-
value: function getHandlerId() {
|
|
876
|
-
return this.targetId;
|
|
877
|
-
}
|
|
878
|
-
}, {
|
|
879
|
-
key: "subscribeToStateChange",
|
|
880
|
-
value: function subscribeToStateChange(listener, options) {
|
|
881
|
-
return this.internalMonitor.subscribeToStateChange(listener, options);
|
|
882
|
-
}
|
|
883
|
-
}, {
|
|
884
|
-
key: "canDrop",
|
|
885
|
-
value: function canDrop() {
|
|
886
|
-
// Cut out early if the target id has not been set. This should prevent errors
|
|
887
|
-
// where the user has an older version of dnd-core like in
|
|
888
|
-
// https://github.com/react-dnd/react-dnd/issues/1310
|
|
889
|
-
if (!this.targetId) {
|
|
890
|
-
return false;
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
invariant(!isCallingCanDrop, 'You may not call monitor.canDrop() inside your canDrop() implementation. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target-monitor');
|
|
894
|
-
|
|
895
|
-
try {
|
|
896
|
-
isCallingCanDrop = true;
|
|
897
|
-
return this.internalMonitor.canDropOnTarget(this.targetId);
|
|
898
|
-
} finally {
|
|
899
|
-
isCallingCanDrop = false;
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
}, {
|
|
903
|
-
key: "isOver",
|
|
904
|
-
value: function isOver(options) {
|
|
905
|
-
if (!this.targetId) {
|
|
906
|
-
return false;
|
|
907
|
-
}
|
|
908
|
-
|
|
909
|
-
return this.internalMonitor.isOverTarget(this.targetId, options);
|
|
910
|
-
}
|
|
911
|
-
}, {
|
|
912
|
-
key: "getItemType",
|
|
913
|
-
value: function getItemType() {
|
|
914
|
-
return this.internalMonitor.getItemType();
|
|
915
|
-
}
|
|
916
|
-
}, {
|
|
917
|
-
key: "getItem",
|
|
918
|
-
value: function getItem() {
|
|
919
|
-
return this.internalMonitor.getItem();
|
|
920
|
-
}
|
|
921
|
-
}, {
|
|
922
|
-
key: "getDropResult",
|
|
923
|
-
value: function getDropResult() {
|
|
924
|
-
return this.internalMonitor.getDropResult();
|
|
925
|
-
}
|
|
926
|
-
}, {
|
|
927
|
-
key: "didDrop",
|
|
928
|
-
value: function didDrop() {
|
|
929
|
-
return this.internalMonitor.didDrop();
|
|
930
|
-
}
|
|
931
|
-
}, {
|
|
932
|
-
key: "getInitialClientOffset",
|
|
933
|
-
value: function getInitialClientOffset() {
|
|
934
|
-
return this.internalMonitor.getInitialClientOffset();
|
|
935
|
-
}
|
|
936
|
-
}, {
|
|
937
|
-
key: "getInitialSourceClientOffset",
|
|
938
|
-
value: function getInitialSourceClientOffset() {
|
|
939
|
-
return this.internalMonitor.getInitialSourceClientOffset();
|
|
940
|
-
}
|
|
941
|
-
}, {
|
|
942
|
-
key: "getSourceClientOffset",
|
|
943
|
-
value: function getSourceClientOffset() {
|
|
944
|
-
return this.internalMonitor.getSourceClientOffset();
|
|
945
|
-
}
|
|
946
|
-
}, {
|
|
947
|
-
key: "getClientOffset",
|
|
948
|
-
value: function getClientOffset() {
|
|
949
|
-
return this.internalMonitor.getClientOffset();
|
|
950
|
-
}
|
|
951
|
-
}, {
|
|
952
|
-
key: "getDifferenceFromInitialOffset",
|
|
953
|
-
value: function getDifferenceFromInitialOffset() {
|
|
954
|
-
return this.internalMonitor.getDifferenceFromInitialOffset();
|
|
955
|
-
}
|
|
956
|
-
}]);
|
|
957
|
-
|
|
958
|
-
return DropTargetMonitorImpl;
|
|
959
|
-
}();
|
|
960
|
-
|
|
961
|
-
function throwIfCompositeComponentElement(element) {
|
|
962
|
-
// Custom components can no longer be wrapped directly in React DnD 2.0
|
|
963
|
-
// so that we don't need to depend on findDOMNode() from react-dom.
|
|
964
|
-
if (typeof element.type === 'string') {
|
|
965
|
-
return;
|
|
966
|
-
}
|
|
967
|
-
|
|
968
|
-
var displayName = element.type.displayName || element.type.name || 'the component';
|
|
969
|
-
throw new Error('Only native element nodes can now be passed to React DnD connectors.' + "You can either wrap ".concat(displayName, " into a <div>, or turn it into a ") + 'drag source or a drop target itself.');
|
|
970
|
-
}
|
|
971
|
-
|
|
972
|
-
function wrapHookToRecognizeElement(hook) {
|
|
973
|
-
return function () {
|
|
974
|
-
var elementOrNode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
975
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
976
|
-
|
|
977
|
-
// When passed a node, call the hook straight away.
|
|
978
|
-
if (!isValidElement(elementOrNode)) {
|
|
979
|
-
var node = elementOrNode;
|
|
980
|
-
hook(node, options); // return the node so it can be chained (e.g. when within callback refs
|
|
981
|
-
// <div ref={node => connectDragSource(connectDropTarget(node))}/>
|
|
982
|
-
|
|
983
|
-
return node;
|
|
984
|
-
} // If passed a ReactElement, clone it and attach this function as a ref.
|
|
985
|
-
// This helps us achieve a neat API where user doesn't even know that refs
|
|
986
|
-
// are being used under the hood.
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
var element = elementOrNode;
|
|
990
|
-
throwIfCompositeComponentElement(element); // When no options are passed, use the hook directly
|
|
991
|
-
|
|
992
|
-
var ref = options ? function (node) {
|
|
993
|
-
return hook(node, options);
|
|
994
|
-
} : hook;
|
|
995
|
-
return cloneWithRef(element, ref);
|
|
996
|
-
};
|
|
997
|
-
}
|
|
998
|
-
|
|
999
|
-
function wrapConnectorHooks(hooks) {
|
|
1000
|
-
var wrappedHooks = {};
|
|
1001
|
-
Object.keys(hooks).forEach(function (key) {
|
|
1002
|
-
var hook = hooks[key]; // ref objects should be passed straight through without wrapping
|
|
1003
|
-
|
|
1004
|
-
if (key.endsWith('Ref')) {
|
|
1005
|
-
wrappedHooks[key] = hooks[key];
|
|
1006
|
-
} else {
|
|
1007
|
-
var wrappedHook = wrapHookToRecognizeElement(hook);
|
|
1008
|
-
|
|
1009
|
-
wrappedHooks[key] = function () {
|
|
1010
|
-
return wrappedHook;
|
|
1011
|
-
};
|
|
1012
|
-
}
|
|
1013
|
-
});
|
|
1014
|
-
return wrappedHooks;
|
|
1015
|
-
}
|
|
1016
|
-
|
|
1017
|
-
function setRef(ref, node) {
|
|
1018
|
-
if (typeof ref === 'function') {
|
|
1019
|
-
ref(node);
|
|
1020
|
-
} else {
|
|
1021
|
-
ref.current = node;
|
|
1022
|
-
}
|
|
1023
|
-
}
|
|
1024
|
-
|
|
1025
|
-
function cloneWithRef(element, newRef) {
|
|
1026
|
-
var previousRef = element.ref;
|
|
1027
|
-
invariant(typeof previousRef !== 'string', 'Cannot connect React DnD to an element with an existing string ref. ' + 'Please convert it to use a callback ref instead, or wrap it into a <span> or <div>. ' + 'Read more: https://reactjs.org/docs/refs-and-the-dom.html#callback-refs');
|
|
1028
|
-
|
|
1029
|
-
if (!previousRef) {
|
|
1030
|
-
// When there is no ref on the element, use the new ref directly
|
|
1031
|
-
return cloneElement(element, {
|
|
1032
|
-
ref: newRef
|
|
1033
|
-
});
|
|
1034
|
-
} else {
|
|
1035
|
-
return cloneElement(element, {
|
|
1036
|
-
ref: function ref(node) {
|
|
1037
|
-
setRef(previousRef, node);
|
|
1038
|
-
setRef(newRef, node);
|
|
1039
|
-
}
|
|
1040
|
-
});
|
|
1041
|
-
}
|
|
1042
|
-
}
|
|
1043
|
-
|
|
1044
|
-
function _typeof$2(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$2 = function _typeof(obj) { return typeof obj; }; } else { _typeof$2 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$2(obj); }
|
|
1045
|
-
|
|
1046
|
-
function isRef(obj) {
|
|
1047
|
-
return (// eslint-disable-next-line no-prototype-builtins
|
|
1048
|
-
obj !== null && _typeof$2(obj) === 'object' && Object.prototype.hasOwnProperty.call(obj, 'current')
|
|
1049
|
-
);
|
|
1050
|
-
}
|
|
1051
|
-
|
|
1052
|
-
function shallowEqual(objA, objB, compare, compareContext) {
|
|
1053
|
-
var compareResult = compare ? compare.call(compareContext, objA, objB) : void 0;
|
|
1054
|
-
|
|
1055
|
-
if (compareResult !== void 0) {
|
|
1056
|
-
return !!compareResult;
|
|
1057
|
-
}
|
|
1058
|
-
|
|
1059
|
-
if (objA === objB) {
|
|
1060
|
-
return true;
|
|
1061
|
-
}
|
|
1062
|
-
|
|
1063
|
-
if (typeof objA !== 'object' || !objA || typeof objB !== 'object' || !objB) {
|
|
1064
|
-
return false;
|
|
1065
|
-
}
|
|
1066
|
-
|
|
1067
|
-
var keysA = Object.keys(objA);
|
|
1068
|
-
var keysB = Object.keys(objB);
|
|
1069
|
-
|
|
1070
|
-
if (keysA.length !== keysB.length) {
|
|
1071
|
-
return false;
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1074
|
-
var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB); // Test for A's keys different from B.
|
|
1075
|
-
|
|
1076
|
-
for (var idx = 0; idx < keysA.length; idx++) {
|
|
1077
|
-
var key = keysA[idx];
|
|
1078
|
-
|
|
1079
|
-
if (!bHasOwnProperty(key)) {
|
|
1080
|
-
return false;
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
var valueA = objA[key];
|
|
1084
|
-
var valueB = objB[key];
|
|
1085
|
-
compareResult = compare ? compare.call(compareContext, valueA, valueB, key) : void 0;
|
|
1086
|
-
|
|
1087
|
-
if (compareResult === false || compareResult === void 0 && valueA !== valueB) {
|
|
1088
|
-
return false;
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
|
|
1092
|
-
return true;
|
|
1093
|
-
}
|
|
1094
|
-
|
|
1095
|
-
function _classCallCheck$5(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
1096
|
-
|
|
1097
|
-
function _defineProperties$5(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
1098
|
-
|
|
1099
|
-
function _createClass$5(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$5(Constructor.prototype, protoProps); if (staticProps) _defineProperties$5(Constructor, staticProps); return Constructor; }
|
|
1100
|
-
|
|
1101
|
-
function _defineProperty$5(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
1102
|
-
var SourceConnector = /*#__PURE__*/function () {
|
|
1103
|
-
// The drop target may either be attached via ref or connect function
|
|
1104
|
-
// The drag preview may either be attached via ref or connect function
|
|
1105
|
-
function SourceConnector(backend) {
|
|
1106
|
-
var _this = this;
|
|
1107
|
-
|
|
1108
|
-
_classCallCheck$5(this, SourceConnector);
|
|
1109
|
-
|
|
1110
|
-
_defineProperty$5(this, "hooks", wrapConnectorHooks({
|
|
1111
|
-
dragSource: function dragSource(node, options) {
|
|
1112
|
-
_this.clearDragSource();
|
|
1113
|
-
|
|
1114
|
-
_this.dragSourceOptions = options || null;
|
|
1115
|
-
|
|
1116
|
-
if (isRef(node)) {
|
|
1117
|
-
_this.dragSourceRef = node;
|
|
1118
|
-
} else {
|
|
1119
|
-
_this.dragSourceNode = node;
|
|
1120
|
-
}
|
|
1121
|
-
|
|
1122
|
-
_this.reconnectDragSource();
|
|
1123
|
-
},
|
|
1124
|
-
dragPreview: function dragPreview(node, options) {
|
|
1125
|
-
_this.clearDragPreview();
|
|
1126
|
-
|
|
1127
|
-
_this.dragPreviewOptions = options || null;
|
|
1128
|
-
|
|
1129
|
-
if (isRef(node)) {
|
|
1130
|
-
_this.dragPreviewRef = node;
|
|
1131
|
-
} else {
|
|
1132
|
-
_this.dragPreviewNode = node;
|
|
1133
|
-
}
|
|
1134
|
-
|
|
1135
|
-
_this.reconnectDragPreview();
|
|
1136
|
-
}
|
|
1137
|
-
}));
|
|
1138
|
-
|
|
1139
|
-
_defineProperty$5(this, "handlerId", null);
|
|
1140
|
-
|
|
1141
|
-
_defineProperty$5(this, "dragSourceRef", null);
|
|
1142
|
-
|
|
1143
|
-
_defineProperty$5(this, "dragSourceNode", void 0);
|
|
1144
|
-
|
|
1145
|
-
_defineProperty$5(this, "dragSourceOptionsInternal", null);
|
|
1146
|
-
|
|
1147
|
-
_defineProperty$5(this, "dragSourceUnsubscribe", void 0);
|
|
1148
|
-
|
|
1149
|
-
_defineProperty$5(this, "dragPreviewRef", null);
|
|
1150
|
-
|
|
1151
|
-
_defineProperty$5(this, "dragPreviewNode", void 0);
|
|
1152
|
-
|
|
1153
|
-
_defineProperty$5(this, "dragPreviewOptionsInternal", null);
|
|
1154
|
-
|
|
1155
|
-
_defineProperty$5(this, "dragPreviewUnsubscribe", void 0);
|
|
1156
|
-
|
|
1157
|
-
_defineProperty$5(this, "lastConnectedHandlerId", null);
|
|
1158
|
-
|
|
1159
|
-
_defineProperty$5(this, "lastConnectedDragSource", null);
|
|
1160
|
-
|
|
1161
|
-
_defineProperty$5(this, "lastConnectedDragSourceOptions", null);
|
|
1162
|
-
|
|
1163
|
-
_defineProperty$5(this, "lastConnectedDragPreview", null);
|
|
1164
|
-
|
|
1165
|
-
_defineProperty$5(this, "lastConnectedDragPreviewOptions", null);
|
|
1166
|
-
|
|
1167
|
-
_defineProperty$5(this, "backend", void 0);
|
|
1168
|
-
|
|
1169
|
-
this.backend = backend;
|
|
1170
|
-
}
|
|
1171
|
-
|
|
1172
|
-
_createClass$5(SourceConnector, [{
|
|
1173
|
-
key: "receiveHandlerId",
|
|
1174
|
-
value: function receiveHandlerId(newHandlerId) {
|
|
1175
|
-
if (this.handlerId === newHandlerId) {
|
|
1176
|
-
return;
|
|
1177
|
-
}
|
|
1178
|
-
|
|
1179
|
-
this.handlerId = newHandlerId;
|
|
1180
|
-
this.reconnect();
|
|
1181
|
-
}
|
|
1182
|
-
}, {
|
|
1183
|
-
key: "connectTarget",
|
|
1184
|
-
get: function get() {
|
|
1185
|
-
return this.dragSource;
|
|
1186
|
-
}
|
|
1187
|
-
}, {
|
|
1188
|
-
key: "dragSourceOptions",
|
|
1189
|
-
get: function get() {
|
|
1190
|
-
return this.dragSourceOptionsInternal;
|
|
1191
|
-
},
|
|
1192
|
-
set: function set(options) {
|
|
1193
|
-
this.dragSourceOptionsInternal = options;
|
|
1194
|
-
}
|
|
1195
|
-
}, {
|
|
1196
|
-
key: "dragPreviewOptions",
|
|
1197
|
-
get: function get() {
|
|
1198
|
-
return this.dragPreviewOptionsInternal;
|
|
1199
|
-
},
|
|
1200
|
-
set: function set(options) {
|
|
1201
|
-
this.dragPreviewOptionsInternal = options;
|
|
1202
|
-
}
|
|
1203
|
-
}, {
|
|
1204
|
-
key: "reconnect",
|
|
1205
|
-
value: function reconnect() {
|
|
1206
|
-
this.reconnectDragSource();
|
|
1207
|
-
this.reconnectDragPreview();
|
|
1208
|
-
}
|
|
1209
|
-
}, {
|
|
1210
|
-
key: "reconnectDragSource",
|
|
1211
|
-
value: function reconnectDragSource() {
|
|
1212
|
-
var dragSource = this.dragSource; // if nothing has changed then don't resubscribe
|
|
1213
|
-
|
|
1214
|
-
var didChange = this.didHandlerIdChange() || this.didConnectedDragSourceChange() || this.didDragSourceOptionsChange();
|
|
1215
|
-
|
|
1216
|
-
if (didChange) {
|
|
1217
|
-
this.disconnectDragSource();
|
|
1218
|
-
}
|
|
1219
|
-
|
|
1220
|
-
if (!this.handlerId) {
|
|
1221
|
-
return;
|
|
1222
|
-
}
|
|
1223
|
-
|
|
1224
|
-
if (!dragSource) {
|
|
1225
|
-
this.lastConnectedDragSource = dragSource;
|
|
1226
|
-
return;
|
|
1227
|
-
}
|
|
1228
|
-
|
|
1229
|
-
if (didChange) {
|
|
1230
|
-
this.lastConnectedHandlerId = this.handlerId;
|
|
1231
|
-
this.lastConnectedDragSource = dragSource;
|
|
1232
|
-
this.lastConnectedDragSourceOptions = this.dragSourceOptions;
|
|
1233
|
-
this.dragSourceUnsubscribe = this.backend.connectDragSource(this.handlerId, dragSource, this.dragSourceOptions);
|
|
1234
|
-
}
|
|
1235
|
-
}
|
|
1236
|
-
}, {
|
|
1237
|
-
key: "reconnectDragPreview",
|
|
1238
|
-
value: function reconnectDragPreview() {
|
|
1239
|
-
var dragPreview = this.dragPreview; // if nothing has changed then don't resubscribe
|
|
1240
|
-
|
|
1241
|
-
var didChange = this.didHandlerIdChange() || this.didConnectedDragPreviewChange() || this.didDragPreviewOptionsChange();
|
|
1242
|
-
|
|
1243
|
-
if (didChange) {
|
|
1244
|
-
this.disconnectDragPreview();
|
|
1245
|
-
}
|
|
1246
|
-
|
|
1247
|
-
if (!this.handlerId) {
|
|
1248
|
-
return;
|
|
1249
|
-
}
|
|
1250
|
-
|
|
1251
|
-
if (!dragPreview) {
|
|
1252
|
-
this.lastConnectedDragPreview = dragPreview;
|
|
1253
|
-
return;
|
|
1254
|
-
}
|
|
1255
|
-
|
|
1256
|
-
if (didChange) {
|
|
1257
|
-
this.lastConnectedHandlerId = this.handlerId;
|
|
1258
|
-
this.lastConnectedDragPreview = dragPreview;
|
|
1259
|
-
this.lastConnectedDragPreviewOptions = this.dragPreviewOptions;
|
|
1260
|
-
this.dragPreviewUnsubscribe = this.backend.connectDragPreview(this.handlerId, dragPreview, this.dragPreviewOptions);
|
|
1261
|
-
}
|
|
1262
|
-
}
|
|
1263
|
-
}, {
|
|
1264
|
-
key: "didHandlerIdChange",
|
|
1265
|
-
value: function didHandlerIdChange() {
|
|
1266
|
-
return this.lastConnectedHandlerId !== this.handlerId;
|
|
1267
|
-
}
|
|
1268
|
-
}, {
|
|
1269
|
-
key: "didConnectedDragSourceChange",
|
|
1270
|
-
value: function didConnectedDragSourceChange() {
|
|
1271
|
-
return this.lastConnectedDragSource !== this.dragSource;
|
|
1272
|
-
}
|
|
1273
|
-
}, {
|
|
1274
|
-
key: "didConnectedDragPreviewChange",
|
|
1275
|
-
value: function didConnectedDragPreviewChange() {
|
|
1276
|
-
return this.lastConnectedDragPreview !== this.dragPreview;
|
|
1277
|
-
}
|
|
1278
|
-
}, {
|
|
1279
|
-
key: "didDragSourceOptionsChange",
|
|
1280
|
-
value: function didDragSourceOptionsChange() {
|
|
1281
|
-
return !shallowEqual(this.lastConnectedDragSourceOptions, this.dragSourceOptions);
|
|
1282
|
-
}
|
|
1283
|
-
}, {
|
|
1284
|
-
key: "didDragPreviewOptionsChange",
|
|
1285
|
-
value: function didDragPreviewOptionsChange() {
|
|
1286
|
-
return !shallowEqual(this.lastConnectedDragPreviewOptions, this.dragPreviewOptions);
|
|
1287
|
-
}
|
|
1288
|
-
}, {
|
|
1289
|
-
key: "disconnectDragSource",
|
|
1290
|
-
value: function disconnectDragSource() {
|
|
1291
|
-
if (this.dragSourceUnsubscribe) {
|
|
1292
|
-
this.dragSourceUnsubscribe();
|
|
1293
|
-
this.dragSourceUnsubscribe = undefined;
|
|
1294
|
-
}
|
|
1295
|
-
}
|
|
1296
|
-
}, {
|
|
1297
|
-
key: "disconnectDragPreview",
|
|
1298
|
-
value: function disconnectDragPreview() {
|
|
1299
|
-
if (this.dragPreviewUnsubscribe) {
|
|
1300
|
-
this.dragPreviewUnsubscribe();
|
|
1301
|
-
this.dragPreviewUnsubscribe = undefined;
|
|
1302
|
-
this.dragPreviewNode = null;
|
|
1303
|
-
this.dragPreviewRef = null;
|
|
1304
|
-
}
|
|
1305
|
-
}
|
|
1306
|
-
}, {
|
|
1307
|
-
key: "dragSource",
|
|
1308
|
-
get: function get() {
|
|
1309
|
-
return this.dragSourceNode || this.dragSourceRef && this.dragSourceRef.current;
|
|
1310
|
-
}
|
|
1311
|
-
}, {
|
|
1312
|
-
key: "dragPreview",
|
|
1313
|
-
get: function get() {
|
|
1314
|
-
return this.dragPreviewNode || this.dragPreviewRef && this.dragPreviewRef.current;
|
|
1315
|
-
}
|
|
1316
|
-
}, {
|
|
1317
|
-
key: "clearDragSource",
|
|
1318
|
-
value: function clearDragSource() {
|
|
1319
|
-
this.dragSourceNode = null;
|
|
1320
|
-
this.dragSourceRef = null;
|
|
1321
|
-
}
|
|
1322
|
-
}, {
|
|
1323
|
-
key: "clearDragPreview",
|
|
1324
|
-
value: function clearDragPreview() {
|
|
1325
|
-
this.dragPreviewNode = null;
|
|
1326
|
-
this.dragPreviewRef = null;
|
|
1327
|
-
}
|
|
1328
|
-
}]);
|
|
1329
|
-
|
|
1330
|
-
return SourceConnector;
|
|
1331
|
-
}();
|
|
1332
|
-
|
|
1333
|
-
function _classCallCheck$4(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
1334
|
-
|
|
1335
|
-
function _defineProperties$4(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
1336
|
-
|
|
1337
|
-
function _createClass$4(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$4(Constructor.prototype, protoProps); if (staticProps) _defineProperties$4(Constructor, staticProps); return Constructor; }
|
|
1338
|
-
|
|
1339
|
-
function _defineProperty$4(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
1340
|
-
var TargetConnector = /*#__PURE__*/function () {
|
|
1341
|
-
// The drop target may either be attached via ref or connect function
|
|
1342
|
-
function TargetConnector(backend) {
|
|
1343
|
-
var _this = this;
|
|
1344
|
-
|
|
1345
|
-
_classCallCheck$4(this, TargetConnector);
|
|
1346
|
-
|
|
1347
|
-
_defineProperty$4(this, "hooks", wrapConnectorHooks({
|
|
1348
|
-
dropTarget: function dropTarget(node, options) {
|
|
1349
|
-
_this.clearDropTarget();
|
|
1350
|
-
|
|
1351
|
-
_this.dropTargetOptions = options;
|
|
1352
|
-
|
|
1353
|
-
if (isRef(node)) {
|
|
1354
|
-
_this.dropTargetRef = node;
|
|
1355
|
-
} else {
|
|
1356
|
-
_this.dropTargetNode = node;
|
|
1357
|
-
}
|
|
1358
|
-
|
|
1359
|
-
_this.reconnect();
|
|
1360
|
-
}
|
|
1361
|
-
}));
|
|
1362
|
-
|
|
1363
|
-
_defineProperty$4(this, "handlerId", null);
|
|
1364
|
-
|
|
1365
|
-
_defineProperty$4(this, "dropTargetRef", null);
|
|
1366
|
-
|
|
1367
|
-
_defineProperty$4(this, "dropTargetNode", void 0);
|
|
1368
|
-
|
|
1369
|
-
_defineProperty$4(this, "dropTargetOptionsInternal", null);
|
|
1370
|
-
|
|
1371
|
-
_defineProperty$4(this, "unsubscribeDropTarget", void 0);
|
|
1372
|
-
|
|
1373
|
-
_defineProperty$4(this, "lastConnectedHandlerId", null);
|
|
1374
|
-
|
|
1375
|
-
_defineProperty$4(this, "lastConnectedDropTarget", null);
|
|
1376
|
-
|
|
1377
|
-
_defineProperty$4(this, "lastConnectedDropTargetOptions", null);
|
|
1378
|
-
|
|
1379
|
-
_defineProperty$4(this, "backend", void 0);
|
|
1380
|
-
|
|
1381
|
-
this.backend = backend;
|
|
1382
|
-
}
|
|
1383
|
-
|
|
1384
|
-
_createClass$4(TargetConnector, [{
|
|
1385
|
-
key: "connectTarget",
|
|
1386
|
-
get: function get() {
|
|
1387
|
-
return this.dropTarget;
|
|
1388
|
-
}
|
|
1389
|
-
}, {
|
|
1390
|
-
key: "reconnect",
|
|
1391
|
-
value: function reconnect() {
|
|
1392
|
-
// if nothing has changed then don't resubscribe
|
|
1393
|
-
var didChange = this.didHandlerIdChange() || this.didDropTargetChange() || this.didOptionsChange();
|
|
1394
|
-
|
|
1395
|
-
if (didChange) {
|
|
1396
|
-
this.disconnectDropTarget();
|
|
1397
|
-
}
|
|
1398
|
-
|
|
1399
|
-
var dropTarget = this.dropTarget;
|
|
1400
|
-
|
|
1401
|
-
if (!this.handlerId) {
|
|
1402
|
-
return;
|
|
1403
|
-
}
|
|
1404
|
-
|
|
1405
|
-
if (!dropTarget) {
|
|
1406
|
-
this.lastConnectedDropTarget = dropTarget;
|
|
1407
|
-
return;
|
|
1408
|
-
}
|
|
1409
|
-
|
|
1410
|
-
if (didChange) {
|
|
1411
|
-
this.lastConnectedHandlerId = this.handlerId;
|
|
1412
|
-
this.lastConnectedDropTarget = dropTarget;
|
|
1413
|
-
this.lastConnectedDropTargetOptions = this.dropTargetOptions;
|
|
1414
|
-
this.unsubscribeDropTarget = this.backend.connectDropTarget(this.handlerId, dropTarget, this.dropTargetOptions);
|
|
1415
|
-
}
|
|
1416
|
-
}
|
|
1417
|
-
}, {
|
|
1418
|
-
key: "receiveHandlerId",
|
|
1419
|
-
value: function receiveHandlerId(newHandlerId) {
|
|
1420
|
-
if (newHandlerId === this.handlerId) {
|
|
1421
|
-
return;
|
|
1422
|
-
}
|
|
1423
|
-
|
|
1424
|
-
this.handlerId = newHandlerId;
|
|
1425
|
-
this.reconnect();
|
|
1426
|
-
}
|
|
1427
|
-
}, {
|
|
1428
|
-
key: "dropTargetOptions",
|
|
1429
|
-
get: function get() {
|
|
1430
|
-
return this.dropTargetOptionsInternal;
|
|
1431
|
-
},
|
|
1432
|
-
set: function set(options) {
|
|
1433
|
-
this.dropTargetOptionsInternal = options;
|
|
1434
|
-
}
|
|
1435
|
-
}, {
|
|
1436
|
-
key: "didHandlerIdChange",
|
|
1437
|
-
value: function didHandlerIdChange() {
|
|
1438
|
-
return this.lastConnectedHandlerId !== this.handlerId;
|
|
1439
|
-
}
|
|
1440
|
-
}, {
|
|
1441
|
-
key: "didDropTargetChange",
|
|
1442
|
-
value: function didDropTargetChange() {
|
|
1443
|
-
return this.lastConnectedDropTarget !== this.dropTarget;
|
|
1444
|
-
}
|
|
1445
|
-
}, {
|
|
1446
|
-
key: "didOptionsChange",
|
|
1447
|
-
value: function didOptionsChange() {
|
|
1448
|
-
return !shallowEqual(this.lastConnectedDropTargetOptions, this.dropTargetOptions);
|
|
1449
|
-
}
|
|
1450
|
-
}, {
|
|
1451
|
-
key: "disconnectDropTarget",
|
|
1452
|
-
value: function disconnectDropTarget() {
|
|
1453
|
-
if (this.unsubscribeDropTarget) {
|
|
1454
|
-
this.unsubscribeDropTarget();
|
|
1455
|
-
this.unsubscribeDropTarget = undefined;
|
|
1456
|
-
}
|
|
1457
|
-
}
|
|
1458
|
-
}, {
|
|
1459
|
-
key: "dropTarget",
|
|
1460
|
-
get: function get() {
|
|
1461
|
-
return this.dropTargetNode || this.dropTargetRef && this.dropTargetRef.current;
|
|
1462
|
-
}
|
|
1463
|
-
}, {
|
|
1464
|
-
key: "clearDropTarget",
|
|
1465
|
-
value: function clearDropTarget() {
|
|
1466
|
-
this.dropTargetRef = null;
|
|
1467
|
-
this.dropTargetNode = null;
|
|
1468
|
-
}
|
|
1469
|
-
}]);
|
|
1470
|
-
|
|
1471
|
-
return TargetConnector;
|
|
1472
|
-
}();
|
|
1473
|
-
|
|
1474
|
-
function registerTarget(type, target, manager) {
|
|
1475
|
-
var registry = manager.getRegistry();
|
|
1476
|
-
var targetId = registry.addTarget(type, target);
|
|
1477
|
-
return [targetId, function () {
|
|
1478
|
-
return registry.removeTarget(targetId);
|
|
1479
|
-
}];
|
|
1480
|
-
}
|
|
1481
|
-
function registerSource(type, source, manager) {
|
|
1482
|
-
var registry = manager.getRegistry();
|
|
1483
|
-
var sourceId = registry.addSource(type, source);
|
|
1484
|
-
return [sourceId, function () {
|
|
1485
|
-
return registry.removeSource(sourceId);
|
|
1486
|
-
}];
|
|
1487
|
-
}
|
|
1488
|
-
|
|
1489
|
-
function _typeof$1(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$1 = function _typeof(obj) { return typeof obj; }; } else { _typeof$1 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$1(obj); }
|
|
1490
|
-
|
|
1491
|
-
function getDecoratedComponent(instanceRef) {
|
|
1492
|
-
var currentRef = instanceRef.current;
|
|
1493
|
-
|
|
1494
|
-
if (currentRef == null) {
|
|
1495
|
-
return null;
|
|
1496
|
-
} else if (currentRef.decoratedRef) {
|
|
1497
|
-
// go through the private field in decorateHandler to avoid the invariant hit
|
|
1498
|
-
return currentRef.decoratedRef.current;
|
|
1499
|
-
} else {
|
|
1500
|
-
return currentRef;
|
|
1501
|
-
}
|
|
1502
|
-
}
|
|
1503
|
-
function isClassComponent(Component) {
|
|
1504
|
-
return Component && Component.prototype && typeof Component.prototype.render === 'function';
|
|
1505
|
-
}
|
|
1506
|
-
function isRefForwardingComponent(C) {
|
|
1507
|
-
var _item$$$typeof;
|
|
1508
|
-
|
|
1509
|
-
var item = C;
|
|
1510
|
-
return (item === null || item === void 0 ? void 0 : (_item$$$typeof = item.$$typeof) === null || _item$$$typeof === void 0 ? void 0 : _item$$$typeof.toString()) === 'Symbol(react.forward_ref)';
|
|
1511
|
-
}
|
|
1512
|
-
function isRefable(C) {
|
|
1513
|
-
return isClassComponent(C) || isRefForwardingComponent(C);
|
|
1514
|
-
}
|
|
1515
|
-
function checkDecoratorArguments(functionName, signature) {
|
|
1516
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1517
|
-
for (var i = 0; i < (arguments.length <= 2 ? 0 : arguments.length - 2); i++) {
|
|
1518
|
-
var arg = i + 2 < 2 || arguments.length <= i + 2 ? undefined : arguments[i + 2];
|
|
1519
|
-
|
|
1520
|
-
if (arg && arg.prototype && arg.prototype.render) {
|
|
1521
|
-
// eslint-disable-next-line no-console
|
|
1522
|
-
console.error('You seem to be applying the arguments in the wrong order. ' + "It should be ".concat(functionName, "(").concat(signature, ")(Component), not the other way around. ") + 'Read more: http://react-dnd.github.io/react-dnd/docs/troubleshooting#you-seem-to-be-applying-the-arguments-in-the-wrong-order');
|
|
1523
|
-
return;
|
|
1524
|
-
}
|
|
1525
|
-
}
|
|
1526
|
-
}
|
|
1527
|
-
}
|
|
1528
|
-
function isFunction(input) {
|
|
1529
|
-
return typeof input === 'function';
|
|
1530
|
-
}
|
|
1531
|
-
function noop() {// noop
|
|
1532
|
-
}
|
|
1533
|
-
|
|
1534
|
-
function isObjectLike(input) {
|
|
1535
|
-
return _typeof$1(input) === 'object' && input !== null;
|
|
1536
|
-
}
|
|
1537
|
-
|
|
1538
|
-
function isPlainObject(input) {
|
|
1539
|
-
if (!isObjectLike(input)) {
|
|
1540
|
-
return false;
|
|
1541
|
-
}
|
|
1542
|
-
|
|
1543
|
-
if (Object.getPrototypeOf(input) === null) {
|
|
1544
|
-
return true;
|
|
1545
|
-
}
|
|
1546
|
-
|
|
1547
|
-
var proto = input;
|
|
1548
|
-
|
|
1549
|
-
while (Object.getPrototypeOf(proto) !== null) {
|
|
1550
|
-
proto = Object.getPrototypeOf(proto);
|
|
1551
|
-
}
|
|
1552
|
-
|
|
1553
|
-
return Object.getPrototypeOf(input) === proto;
|
|
1554
|
-
}
|
|
1555
|
-
function isValidType(type, allowArray) {
|
|
1556
|
-
return typeof type === 'string' || _typeof$1(type) === 'symbol' || !!allowArray && Array.isArray(type) && type.every(function (t) {
|
|
1557
|
-
return isValidType(t, false);
|
|
1558
|
-
});
|
|
1559
|
-
}
|
|
1560
|
-
|
|
1561
|
-
function _classCallCheck$3(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
1562
|
-
|
|
1563
|
-
function _defineProperties$3(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
1564
|
-
|
|
1565
|
-
function _createClass$3(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$3(Constructor.prototype, protoProps); if (staticProps) _defineProperties$3(Constructor, staticProps); return Constructor; }
|
|
1566
|
-
|
|
1567
|
-
function _defineProperty$3(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
1568
|
-
/**
|
|
1569
|
-
* Provides a set of static methods for creating Disposables.
|
|
1570
|
-
* @param {Function} action Action to run during the first call to dispose.
|
|
1571
|
-
* The action is guaranteed to be run at most once.
|
|
1572
|
-
*/
|
|
1573
|
-
|
|
1574
|
-
var Disposable = /*#__PURE__*/function () {
|
|
1575
|
-
function Disposable(action) {
|
|
1576
|
-
_classCallCheck$3(this, Disposable);
|
|
1577
|
-
|
|
1578
|
-
_defineProperty$3(this, "isDisposed", false);
|
|
1579
|
-
|
|
1580
|
-
_defineProperty$3(this, "action", void 0);
|
|
1581
|
-
|
|
1582
|
-
this.action = isFunction(action) ? action : noop;
|
|
1583
|
-
}
|
|
1584
|
-
/** Performs the task of cleaning up resources. */
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
_createClass$3(Disposable, [{
|
|
1588
|
-
key: "dispose",
|
|
1589
|
-
value: function dispose() {
|
|
1590
|
-
if (!this.isDisposed) {
|
|
1591
|
-
this.action();
|
|
1592
|
-
this.isDisposed = true;
|
|
1593
|
-
}
|
|
1594
|
-
}
|
|
1595
|
-
}], [{
|
|
1596
|
-
key: "isDisposable",
|
|
1597
|
-
value:
|
|
1598
|
-
/**
|
|
1599
|
-
* Gets the disposable that does nothing when disposed.
|
|
1600
|
-
*/
|
|
1601
|
-
|
|
1602
|
-
/**
|
|
1603
|
-
* Validates whether the given object is a disposable
|
|
1604
|
-
* @param {Object} Object to test whether it has a dispose method
|
|
1605
|
-
* @returns {Boolean} true if a disposable object, else false.
|
|
1606
|
-
*/
|
|
1607
|
-
function isDisposable(d) {
|
|
1608
|
-
return Boolean(d && isFunction(d.dispose));
|
|
1609
|
-
}
|
|
1610
|
-
}, {
|
|
1611
|
-
key: "_fixup",
|
|
1612
|
-
value: function _fixup(result) {
|
|
1613
|
-
return Disposable.isDisposable(result) ? result : Disposable.empty;
|
|
1614
|
-
}
|
|
1615
|
-
/**
|
|
1616
|
-
* Creates a disposable object that invokes the specified action when disposed.
|
|
1617
|
-
* @param {Function} dispose Action to run during the first call to dispose.
|
|
1618
|
-
* The action is guaranteed to be run at most once.
|
|
1619
|
-
* @return {Disposable} The disposable object that runs the given action upon disposal.
|
|
1620
|
-
*/
|
|
1621
|
-
|
|
1622
|
-
}, {
|
|
1623
|
-
key: "create",
|
|
1624
|
-
value: function create(action) {
|
|
1625
|
-
return new Disposable(action);
|
|
1626
|
-
}
|
|
1627
|
-
}]);
|
|
1628
|
-
|
|
1629
|
-
return Disposable;
|
|
1630
|
-
}();
|
|
1631
|
-
/**
|
|
1632
|
-
* Represents a group of disposable resources that are disposed together.
|
|
1633
|
-
* @constructor
|
|
1634
|
-
*/
|
|
1635
|
-
|
|
1636
|
-
_defineProperty$3(Disposable, "empty", {
|
|
1637
|
-
dispose: noop
|
|
1638
|
-
});
|
|
1639
|
-
|
|
1640
|
-
var CompositeDisposable = /*#__PURE__*/function () {
|
|
1641
|
-
function CompositeDisposable() {
|
|
1642
|
-
_classCallCheck$3(this, CompositeDisposable);
|
|
1643
|
-
|
|
1644
|
-
_defineProperty$3(this, "isDisposed", false);
|
|
1645
|
-
|
|
1646
|
-
_defineProperty$3(this, "disposables", void 0);
|
|
1647
|
-
|
|
1648
|
-
for (var _len = arguments.length, disposables = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1649
|
-
disposables[_key] = arguments[_key];
|
|
1650
|
-
}
|
|
1651
|
-
|
|
1652
|
-
this.disposables = disposables;
|
|
1653
|
-
}
|
|
1654
|
-
/**
|
|
1655
|
-
* Adds a disposable to the CompositeDisposable or disposes the disposable if the CompositeDisposable is disposed.
|
|
1656
|
-
* @param {Any} item Disposable to add.
|
|
1657
|
-
*/
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
_createClass$3(CompositeDisposable, [{
|
|
1661
|
-
key: "add",
|
|
1662
|
-
value: function add(item) {
|
|
1663
|
-
if (this.isDisposed) {
|
|
1664
|
-
item.dispose();
|
|
1665
|
-
} else {
|
|
1666
|
-
this.disposables.push(item);
|
|
1667
|
-
}
|
|
1668
|
-
}
|
|
1669
|
-
/**
|
|
1670
|
-
* Removes and disposes the first occurrence of a disposable from the CompositeDisposable.
|
|
1671
|
-
* @param {Any} item Disposable to remove.
|
|
1672
|
-
* @returns {Boolean} true if found; false otherwise.
|
|
1673
|
-
*/
|
|
1674
|
-
|
|
1675
|
-
}, {
|
|
1676
|
-
key: "remove",
|
|
1677
|
-
value: function remove(item) {
|
|
1678
|
-
var shouldDispose = false;
|
|
1679
|
-
|
|
1680
|
-
if (!this.isDisposed) {
|
|
1681
|
-
var idx = this.disposables.indexOf(item);
|
|
1682
|
-
|
|
1683
|
-
if (idx !== -1) {
|
|
1684
|
-
shouldDispose = true;
|
|
1685
|
-
this.disposables.splice(idx, 1);
|
|
1686
|
-
item.dispose();
|
|
1687
|
-
}
|
|
1688
|
-
}
|
|
1689
|
-
|
|
1690
|
-
return shouldDispose;
|
|
1691
|
-
}
|
|
1692
|
-
/**
|
|
1693
|
-
* Disposes all disposables in the group and removes them from the group but
|
|
1694
|
-
* does not dispose the CompositeDisposable.
|
|
1695
|
-
*/
|
|
1696
|
-
|
|
1697
|
-
}, {
|
|
1698
|
-
key: "clear",
|
|
1699
|
-
value: function clear() {
|
|
1700
|
-
if (!this.isDisposed) {
|
|
1701
|
-
var len = this.disposables.length;
|
|
1702
|
-
var currentDisposables = new Array(len);
|
|
1703
|
-
|
|
1704
|
-
for (var i = 0; i < len; i++) {
|
|
1705
|
-
currentDisposables[i] = this.disposables[i];
|
|
1706
|
-
}
|
|
1707
|
-
|
|
1708
|
-
this.disposables = [];
|
|
1709
|
-
|
|
1710
|
-
for (var _i = 0; _i < len; _i++) {
|
|
1711
|
-
currentDisposables[_i].dispose();
|
|
1712
|
-
}
|
|
1713
|
-
}
|
|
1714
|
-
}
|
|
1715
|
-
/**
|
|
1716
|
-
* Disposes all disposables in the group and removes them from the group.
|
|
1717
|
-
*/
|
|
1718
|
-
|
|
1719
|
-
}, {
|
|
1720
|
-
key: "dispose",
|
|
1721
|
-
value: function dispose() {
|
|
1722
|
-
if (!this.isDisposed) {
|
|
1723
|
-
this.isDisposed = true;
|
|
1724
|
-
var len = this.disposables.length;
|
|
1725
|
-
var currentDisposables = new Array(len);
|
|
1726
|
-
|
|
1727
|
-
for (var i = 0; i < len; i++) {
|
|
1728
|
-
currentDisposables[i] = this.disposables[i];
|
|
1729
|
-
}
|
|
1730
|
-
|
|
1731
|
-
this.disposables = [];
|
|
1732
|
-
|
|
1733
|
-
for (var _i2 = 0; _i2 < len; _i2++) {
|
|
1734
|
-
currentDisposables[_i2].dispose();
|
|
1735
|
-
}
|
|
1736
|
-
}
|
|
1737
|
-
}
|
|
1738
|
-
}]);
|
|
1739
|
-
|
|
1740
|
-
return CompositeDisposable;
|
|
1741
|
-
}();
|
|
1742
|
-
/**
|
|
1743
|
-
* Represents a disposable resource whose underlying disposable resource can
|
|
1744
|
-
* be replaced by another disposable resource, causing automatic disposal of
|
|
1745
|
-
* the previous underlying disposable resource.
|
|
1746
|
-
*/
|
|
1747
|
-
|
|
1748
|
-
var SerialDisposable = /*#__PURE__*/function () {
|
|
1749
|
-
function SerialDisposable() {
|
|
1750
|
-
_classCallCheck$3(this, SerialDisposable);
|
|
1751
|
-
|
|
1752
|
-
_defineProperty$3(this, "isDisposed", false);
|
|
1753
|
-
|
|
1754
|
-
_defineProperty$3(this, "current", void 0);
|
|
1755
|
-
}
|
|
1756
|
-
|
|
1757
|
-
_createClass$3(SerialDisposable, [{
|
|
1758
|
-
key: "getDisposable",
|
|
1759
|
-
value:
|
|
1760
|
-
/**
|
|
1761
|
-
* Gets the underlying disposable.
|
|
1762
|
-
* @returns {Any} the underlying disposable.
|
|
1763
|
-
*/
|
|
1764
|
-
function getDisposable() {
|
|
1765
|
-
return this.current;
|
|
1766
|
-
}
|
|
1767
|
-
}, {
|
|
1768
|
-
key: "setDisposable",
|
|
1769
|
-
value: function setDisposable(value) {
|
|
1770
|
-
var shouldDispose = this.isDisposed;
|
|
1771
|
-
|
|
1772
|
-
if (!shouldDispose) {
|
|
1773
|
-
var old = this.current;
|
|
1774
|
-
this.current = value;
|
|
1775
|
-
|
|
1776
|
-
if (old) {
|
|
1777
|
-
old.dispose();
|
|
1778
|
-
}
|
|
1779
|
-
}
|
|
1780
|
-
|
|
1781
|
-
if (shouldDispose && value) {
|
|
1782
|
-
value.dispose();
|
|
1783
|
-
}
|
|
1784
|
-
}
|
|
1785
|
-
/** Performs the task of cleaning up resources. */
|
|
1786
|
-
|
|
1787
|
-
}, {
|
|
1788
|
-
key: "dispose",
|
|
1789
|
-
value: function dispose() {
|
|
1790
|
-
if (!this.isDisposed) {
|
|
1791
|
-
this.isDisposed = true;
|
|
1792
|
-
var old = this.current;
|
|
1793
|
-
this.current = undefined;
|
|
1794
|
-
|
|
1795
|
-
if (old) {
|
|
1796
|
-
old.dispose();
|
|
1797
|
-
}
|
|
1798
|
-
}
|
|
1799
|
-
}
|
|
1800
|
-
}]);
|
|
1801
|
-
|
|
1802
|
-
return SerialDisposable;
|
|
1803
|
-
}();
|
|
1804
|
-
|
|
1805
|
-
var reactIs$1 = {exports: {}};
|
|
1806
|
-
|
|
1807
|
-
var reactIs_production_min = {};
|
|
1808
|
-
|
|
1809
|
-
/** @license React v16.13.1
|
|
1810
|
-
* react-is.production.min.js
|
|
1811
|
-
*
|
|
1812
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
1813
|
-
*
|
|
1814
|
-
* This source code is licensed under the MIT license found in the
|
|
1815
|
-
* LICENSE file in the root directory of this source tree.
|
|
1816
|
-
*/
|
|
1817
|
-
var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b?
|
|
1818
|
-
Symbol.for("react.suspense_list"):60120,r=b?Symbol.for("react.memo"):60115,t=b?Symbol.for("react.lazy"):60116,v=b?Symbol.for("react.block"):60121,w=b?Symbol.for("react.fundamental"):60117,x=b?Symbol.for("react.responder"):60118,y=b?Symbol.for("react.scope"):60119;
|
|
1819
|
-
function z(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case t:case r:case h:return a;default:return u}}case d:return u}}}function A(a){return z(a)===m}reactIs_production_min.AsyncMode=l;reactIs_production_min.ConcurrentMode=m;reactIs_production_min.ContextConsumer=k;reactIs_production_min.ContextProvider=h;reactIs_production_min.Element=c;reactIs_production_min.ForwardRef=n;reactIs_production_min.Fragment=e;reactIs_production_min.Lazy=t;reactIs_production_min.Memo=r;reactIs_production_min.Portal=d;
|
|
1820
|
-
reactIs_production_min.Profiler=g;reactIs_production_min.StrictMode=f;reactIs_production_min.Suspense=p;reactIs_production_min.isAsyncMode=function(a){return A(a)||z(a)===l};reactIs_production_min.isConcurrentMode=A;reactIs_production_min.isContextConsumer=function(a){return z(a)===k};reactIs_production_min.isContextProvider=function(a){return z(a)===h};reactIs_production_min.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===c};reactIs_production_min.isForwardRef=function(a){return z(a)===n};reactIs_production_min.isFragment=function(a){return z(a)===e};reactIs_production_min.isLazy=function(a){return z(a)===t};
|
|
1821
|
-
reactIs_production_min.isMemo=function(a){return z(a)===r};reactIs_production_min.isPortal=function(a){return z(a)===d};reactIs_production_min.isProfiler=function(a){return z(a)===g};reactIs_production_min.isStrictMode=function(a){return z(a)===f};reactIs_production_min.isSuspense=function(a){return z(a)===p};
|
|
1822
|
-
reactIs_production_min.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||a===q||"object"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n||a.$$typeof===w||a.$$typeof===x||a.$$typeof===y||a.$$typeof===v)};reactIs_production_min.typeOf=z;
|
|
1823
|
-
|
|
1824
|
-
var reactIs_development = {};
|
|
1825
|
-
|
|
1826
|
-
/** @license React v16.13.1
|
|
1827
|
-
* react-is.development.js
|
|
1828
|
-
*
|
|
1829
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
1830
|
-
*
|
|
1831
|
-
* This source code is licensed under the MIT license found in the
|
|
1832
|
-
* LICENSE file in the root directory of this source tree.
|
|
1833
|
-
*/
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
if (process.env.NODE_ENV !== "production") {
|
|
1838
|
-
(function() {
|
|
1839
|
-
|
|
1840
|
-
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
|
1841
|
-
// nor polyfill, then a plain number is used for performance.
|
|
1842
|
-
var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
|
1843
|
-
var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
|
1844
|
-
var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
|
1845
|
-
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
|
1846
|
-
var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
|
1847
|
-
var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
|
1848
|
-
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
|
1849
|
-
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
|
|
1850
|
-
// (unstable) APIs that have been removed. Can we remove the symbols?
|
|
1851
|
-
|
|
1852
|
-
var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
|
|
1853
|
-
var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
|
|
1854
|
-
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
|
1855
|
-
var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
|
|
1856
|
-
var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
|
|
1857
|
-
var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
|
|
1858
|
-
var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
|
|
1859
|
-
var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
|
|
1860
|
-
var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
|
|
1861
|
-
var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
|
|
1862
|
-
var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
|
|
1863
|
-
|
|
1864
|
-
function isValidElementType(type) {
|
|
1865
|
-
return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
|
|
1866
|
-
type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
|
|
1867
|
-
}
|
|
1868
|
-
|
|
1869
|
-
function typeOf(object) {
|
|
1870
|
-
if (typeof object === 'object' && object !== null) {
|
|
1871
|
-
var $$typeof = object.$$typeof;
|
|
1872
|
-
|
|
1873
|
-
switch ($$typeof) {
|
|
1874
|
-
case REACT_ELEMENT_TYPE:
|
|
1875
|
-
var type = object.type;
|
|
1876
|
-
|
|
1877
|
-
switch (type) {
|
|
1878
|
-
case REACT_ASYNC_MODE_TYPE:
|
|
1879
|
-
case REACT_CONCURRENT_MODE_TYPE:
|
|
1880
|
-
case REACT_FRAGMENT_TYPE:
|
|
1881
|
-
case REACT_PROFILER_TYPE:
|
|
1882
|
-
case REACT_STRICT_MODE_TYPE:
|
|
1883
|
-
case REACT_SUSPENSE_TYPE:
|
|
1884
|
-
return type;
|
|
1885
|
-
|
|
1886
|
-
default:
|
|
1887
|
-
var $$typeofType = type && type.$$typeof;
|
|
1888
|
-
|
|
1889
|
-
switch ($$typeofType) {
|
|
1890
|
-
case REACT_CONTEXT_TYPE:
|
|
1891
|
-
case REACT_FORWARD_REF_TYPE:
|
|
1892
|
-
case REACT_LAZY_TYPE:
|
|
1893
|
-
case REACT_MEMO_TYPE:
|
|
1894
|
-
case REACT_PROVIDER_TYPE:
|
|
1895
|
-
return $$typeofType;
|
|
1896
|
-
|
|
1897
|
-
default:
|
|
1898
|
-
return $$typeof;
|
|
1899
|
-
}
|
|
1900
|
-
|
|
1901
|
-
}
|
|
1902
|
-
|
|
1903
|
-
case REACT_PORTAL_TYPE:
|
|
1904
|
-
return $$typeof;
|
|
1905
|
-
}
|
|
1906
|
-
}
|
|
1907
|
-
|
|
1908
|
-
return undefined;
|
|
1909
|
-
} // AsyncMode is deprecated along with isAsyncMode
|
|
1910
|
-
|
|
1911
|
-
var AsyncMode = REACT_ASYNC_MODE_TYPE;
|
|
1912
|
-
var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
|
|
1913
|
-
var ContextConsumer = REACT_CONTEXT_TYPE;
|
|
1914
|
-
var ContextProvider = REACT_PROVIDER_TYPE;
|
|
1915
|
-
var Element = REACT_ELEMENT_TYPE;
|
|
1916
|
-
var ForwardRef = REACT_FORWARD_REF_TYPE;
|
|
1917
|
-
var Fragment = REACT_FRAGMENT_TYPE;
|
|
1918
|
-
var Lazy = REACT_LAZY_TYPE;
|
|
1919
|
-
var Memo = REACT_MEMO_TYPE;
|
|
1920
|
-
var Portal = REACT_PORTAL_TYPE;
|
|
1921
|
-
var Profiler = REACT_PROFILER_TYPE;
|
|
1922
|
-
var StrictMode = REACT_STRICT_MODE_TYPE;
|
|
1923
|
-
var Suspense = REACT_SUSPENSE_TYPE;
|
|
1924
|
-
var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated
|
|
1925
|
-
|
|
1926
|
-
function isAsyncMode(object) {
|
|
1927
|
-
{
|
|
1928
|
-
if (!hasWarnedAboutDeprecatedIsAsyncMode) {
|
|
1929
|
-
hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
|
|
1930
|
-
|
|
1931
|
-
console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
|
|
1932
|
-
}
|
|
1933
|
-
}
|
|
1934
|
-
|
|
1935
|
-
return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
|
|
1936
|
-
}
|
|
1937
|
-
function isConcurrentMode(object) {
|
|
1938
|
-
return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
|
|
1939
|
-
}
|
|
1940
|
-
function isContextConsumer(object) {
|
|
1941
|
-
return typeOf(object) === REACT_CONTEXT_TYPE;
|
|
1942
|
-
}
|
|
1943
|
-
function isContextProvider(object) {
|
|
1944
|
-
return typeOf(object) === REACT_PROVIDER_TYPE;
|
|
1945
|
-
}
|
|
1946
|
-
function isElement(object) {
|
|
1947
|
-
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
1948
|
-
}
|
|
1949
|
-
function isForwardRef(object) {
|
|
1950
|
-
return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
|
1951
|
-
}
|
|
1952
|
-
function isFragment(object) {
|
|
1953
|
-
return typeOf(object) === REACT_FRAGMENT_TYPE;
|
|
1954
|
-
}
|
|
1955
|
-
function isLazy(object) {
|
|
1956
|
-
return typeOf(object) === REACT_LAZY_TYPE;
|
|
1957
|
-
}
|
|
1958
|
-
function isMemo(object) {
|
|
1959
|
-
return typeOf(object) === REACT_MEMO_TYPE;
|
|
1960
|
-
}
|
|
1961
|
-
function isPortal(object) {
|
|
1962
|
-
return typeOf(object) === REACT_PORTAL_TYPE;
|
|
1963
|
-
}
|
|
1964
|
-
function isProfiler(object) {
|
|
1965
|
-
return typeOf(object) === REACT_PROFILER_TYPE;
|
|
1966
|
-
}
|
|
1967
|
-
function isStrictMode(object) {
|
|
1968
|
-
return typeOf(object) === REACT_STRICT_MODE_TYPE;
|
|
1969
|
-
}
|
|
1970
|
-
function isSuspense(object) {
|
|
1971
|
-
return typeOf(object) === REACT_SUSPENSE_TYPE;
|
|
1972
|
-
}
|
|
1973
|
-
|
|
1974
|
-
reactIs_development.AsyncMode = AsyncMode;
|
|
1975
|
-
reactIs_development.ConcurrentMode = ConcurrentMode;
|
|
1976
|
-
reactIs_development.ContextConsumer = ContextConsumer;
|
|
1977
|
-
reactIs_development.ContextProvider = ContextProvider;
|
|
1978
|
-
reactIs_development.Element = Element;
|
|
1979
|
-
reactIs_development.ForwardRef = ForwardRef;
|
|
1980
|
-
reactIs_development.Fragment = Fragment;
|
|
1981
|
-
reactIs_development.Lazy = Lazy;
|
|
1982
|
-
reactIs_development.Memo = Memo;
|
|
1983
|
-
reactIs_development.Portal = Portal;
|
|
1984
|
-
reactIs_development.Profiler = Profiler;
|
|
1985
|
-
reactIs_development.StrictMode = StrictMode;
|
|
1986
|
-
reactIs_development.Suspense = Suspense;
|
|
1987
|
-
reactIs_development.isAsyncMode = isAsyncMode;
|
|
1988
|
-
reactIs_development.isConcurrentMode = isConcurrentMode;
|
|
1989
|
-
reactIs_development.isContextConsumer = isContextConsumer;
|
|
1990
|
-
reactIs_development.isContextProvider = isContextProvider;
|
|
1991
|
-
reactIs_development.isElement = isElement;
|
|
1992
|
-
reactIs_development.isForwardRef = isForwardRef;
|
|
1993
|
-
reactIs_development.isFragment = isFragment;
|
|
1994
|
-
reactIs_development.isLazy = isLazy;
|
|
1995
|
-
reactIs_development.isMemo = isMemo;
|
|
1996
|
-
reactIs_development.isPortal = isPortal;
|
|
1997
|
-
reactIs_development.isProfiler = isProfiler;
|
|
1998
|
-
reactIs_development.isStrictMode = isStrictMode;
|
|
1999
|
-
reactIs_development.isSuspense = isSuspense;
|
|
2000
|
-
reactIs_development.isValidElementType = isValidElementType;
|
|
2001
|
-
reactIs_development.typeOf = typeOf;
|
|
2002
|
-
})();
|
|
2003
|
-
}
|
|
2004
|
-
|
|
2005
|
-
if (process.env.NODE_ENV === 'production') {
|
|
2006
|
-
reactIs$1.exports = reactIs_production_min;
|
|
2007
|
-
} else {
|
|
2008
|
-
reactIs$1.exports = reactIs_development;
|
|
2009
|
-
}
|
|
2010
|
-
|
|
2011
|
-
var reactIs = reactIs$1.exports;
|
|
2012
|
-
|
|
2013
|
-
/**
|
|
2014
|
-
* Copyright 2015, Yahoo! Inc.
|
|
2015
|
-
* Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
|
|
2016
|
-
*/
|
|
2017
|
-
var REACT_STATICS = {
|
|
2018
|
-
childContextTypes: true,
|
|
2019
|
-
contextType: true,
|
|
2020
|
-
contextTypes: true,
|
|
2021
|
-
defaultProps: true,
|
|
2022
|
-
displayName: true,
|
|
2023
|
-
getDefaultProps: true,
|
|
2024
|
-
getDerivedStateFromError: true,
|
|
2025
|
-
getDerivedStateFromProps: true,
|
|
2026
|
-
mixins: true,
|
|
2027
|
-
propTypes: true,
|
|
2028
|
-
type: true
|
|
2029
|
-
};
|
|
2030
|
-
var KNOWN_STATICS = {
|
|
2031
|
-
name: true,
|
|
2032
|
-
length: true,
|
|
2033
|
-
prototype: true,
|
|
2034
|
-
caller: true,
|
|
2035
|
-
callee: true,
|
|
2036
|
-
arguments: true,
|
|
2037
|
-
arity: true
|
|
2038
|
-
};
|
|
2039
|
-
var FORWARD_REF_STATICS = {
|
|
2040
|
-
'$$typeof': true,
|
|
2041
|
-
render: true,
|
|
2042
|
-
defaultProps: true,
|
|
2043
|
-
displayName: true,
|
|
2044
|
-
propTypes: true
|
|
2045
|
-
};
|
|
2046
|
-
var MEMO_STATICS = {
|
|
2047
|
-
'$$typeof': true,
|
|
2048
|
-
compare: true,
|
|
2049
|
-
defaultProps: true,
|
|
2050
|
-
displayName: true,
|
|
2051
|
-
propTypes: true,
|
|
2052
|
-
type: true
|
|
2053
|
-
};
|
|
2054
|
-
var TYPE_STATICS = {};
|
|
2055
|
-
TYPE_STATICS[reactIs.ForwardRef] = FORWARD_REF_STATICS;
|
|
2056
|
-
TYPE_STATICS[reactIs.Memo] = MEMO_STATICS;
|
|
2057
|
-
|
|
2058
|
-
function getStatics(component) {
|
|
2059
|
-
// React v16.11 and below
|
|
2060
|
-
if (reactIs.isMemo(component)) {
|
|
2061
|
-
return MEMO_STATICS;
|
|
2062
|
-
} // React v16.12 and above
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
return TYPE_STATICS[component['$$typeof']] || REACT_STATICS;
|
|
2066
|
-
}
|
|
2067
|
-
|
|
2068
|
-
var defineProperty = Object.defineProperty;
|
|
2069
|
-
var getOwnPropertyNames = Object.getOwnPropertyNames;
|
|
2070
|
-
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
2071
|
-
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
2072
|
-
var getPrototypeOf = Object.getPrototypeOf;
|
|
2073
|
-
var objectPrototype = Object.prototype;
|
|
2074
|
-
function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) {
|
|
2075
|
-
if (typeof sourceComponent !== 'string') {
|
|
2076
|
-
// don't hoist over string (html) components
|
|
2077
|
-
if (objectPrototype) {
|
|
2078
|
-
var inheritedComponent = getPrototypeOf(sourceComponent);
|
|
2079
|
-
|
|
2080
|
-
if (inheritedComponent && inheritedComponent !== objectPrototype) {
|
|
2081
|
-
hoistNonReactStatics(targetComponent, inheritedComponent, blacklist);
|
|
2082
|
-
}
|
|
2083
|
-
}
|
|
2084
|
-
|
|
2085
|
-
var keys = getOwnPropertyNames(sourceComponent);
|
|
2086
|
-
|
|
2087
|
-
if (getOwnPropertySymbols) {
|
|
2088
|
-
keys = keys.concat(getOwnPropertySymbols(sourceComponent));
|
|
2089
|
-
}
|
|
2090
|
-
|
|
2091
|
-
var targetStatics = getStatics(targetComponent);
|
|
2092
|
-
var sourceStatics = getStatics(sourceComponent);
|
|
2093
|
-
|
|
2094
|
-
for (var i = 0; i < keys.length; ++i) {
|
|
2095
|
-
var key = keys[i];
|
|
2096
|
-
|
|
2097
|
-
if (!KNOWN_STATICS[key] && !(blacklist && blacklist[key]) && !(sourceStatics && sourceStatics[key]) && !(targetStatics && targetStatics[key])) {
|
|
2098
|
-
var descriptor = getOwnPropertyDescriptor(sourceComponent, key);
|
|
2099
|
-
|
|
2100
|
-
try {
|
|
2101
|
-
// Avoid failures from read-only properties
|
|
2102
|
-
defineProperty(targetComponent, key, descriptor);
|
|
2103
|
-
} catch (e) {}
|
|
2104
|
-
}
|
|
2105
|
-
}
|
|
2106
|
-
}
|
|
2107
|
-
|
|
2108
|
-
return targetComponent;
|
|
2109
|
-
}
|
|
2110
|
-
|
|
2111
|
-
var hoistNonReactStatics_cjs = hoistNonReactStatics;
|
|
2112
|
-
|
|
2113
|
-
var hoistStatics = hoistNonReactStatics_cjs;
|
|
2114
|
-
|
|
2115
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
2116
|
-
|
|
2117
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2118
|
-
|
|
2119
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
2120
|
-
|
|
2121
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
2122
|
-
|
|
2123
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
2124
|
-
|
|
2125
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
2126
|
-
|
|
2127
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
2128
|
-
|
|
2129
|
-
function _classCallCheck$2(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2130
|
-
|
|
2131
|
-
function _defineProperties$2(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
2132
|
-
|
|
2133
|
-
function _createClass$2(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$2(Constructor.prototype, protoProps); if (staticProps) _defineProperties$2(Constructor, staticProps); return Constructor; }
|
|
2134
|
-
|
|
2135
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
2136
|
-
|
|
2137
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
2138
|
-
|
|
2139
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
2140
|
-
|
|
2141
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
2142
|
-
|
|
2143
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
2144
|
-
|
|
2145
|
-
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; } }
|
|
2146
|
-
|
|
2147
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
2148
|
-
|
|
2149
|
-
function _defineProperty$2(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2150
|
-
function decorateHandler(_ref) {
|
|
2151
|
-
var DecoratedComponent = _ref.DecoratedComponent,
|
|
2152
|
-
createHandler = _ref.createHandler,
|
|
2153
|
-
createMonitor = _ref.createMonitor,
|
|
2154
|
-
createConnector = _ref.createConnector,
|
|
2155
|
-
registerHandler = _ref.registerHandler,
|
|
2156
|
-
containerDisplayName = _ref.containerDisplayName,
|
|
2157
|
-
getType = _ref.getType,
|
|
2158
|
-
collect = _ref.collect,
|
|
2159
|
-
options = _ref.options;
|
|
2160
|
-
var _options$arePropsEqua = options.arePropsEqual,
|
|
2161
|
-
arePropsEqual = _options$arePropsEqua === void 0 ? shallowEqual : _options$arePropsEqua;
|
|
2162
|
-
var Decorated = DecoratedComponent;
|
|
2163
|
-
var displayName = DecoratedComponent.displayName || DecoratedComponent.name || 'Component';
|
|
2164
|
-
|
|
2165
|
-
var DragDropContainer = /*#__PURE__*/function (_Component) {
|
|
2166
|
-
_inherits(DragDropContainer, _Component);
|
|
2167
|
-
|
|
2168
|
-
var _super = _createSuper(DragDropContainer);
|
|
2169
|
-
|
|
2170
|
-
function DragDropContainer(props) {
|
|
2171
|
-
var _this;
|
|
2172
|
-
|
|
2173
|
-
_classCallCheck$2(this, DragDropContainer);
|
|
2174
|
-
|
|
2175
|
-
_this = _super.call(this, props);
|
|
2176
|
-
|
|
2177
|
-
_defineProperty$2(_assertThisInitialized(_this), "decoratedRef", createRef());
|
|
2178
|
-
|
|
2179
|
-
_defineProperty$2(_assertThisInitialized(_this), "handlerId", void 0);
|
|
2180
|
-
|
|
2181
|
-
_defineProperty$2(_assertThisInitialized(_this), "manager", void 0);
|
|
2182
|
-
|
|
2183
|
-
_defineProperty$2(_assertThisInitialized(_this), "handlerMonitor", void 0);
|
|
2184
|
-
|
|
2185
|
-
_defineProperty$2(_assertThisInitialized(_this), "handlerConnector", void 0);
|
|
2186
|
-
|
|
2187
|
-
_defineProperty$2(_assertThisInitialized(_this), "handler", void 0);
|
|
2188
|
-
|
|
2189
|
-
_defineProperty$2(_assertThisInitialized(_this), "disposable", void 0);
|
|
2190
|
-
|
|
2191
|
-
_defineProperty$2(_assertThisInitialized(_this), "currentType", void 0);
|
|
2192
|
-
|
|
2193
|
-
_defineProperty$2(_assertThisInitialized(_this), "handleChange", function () {
|
|
2194
|
-
var nextState = _this.getCurrentState();
|
|
2195
|
-
|
|
2196
|
-
if (!shallowEqual(nextState, _this.state)) {
|
|
2197
|
-
_this.setState(nextState);
|
|
2198
|
-
}
|
|
2199
|
-
});
|
|
2200
|
-
|
|
2201
|
-
_this.disposable = new SerialDisposable();
|
|
2202
|
-
|
|
2203
|
-
_this.receiveProps(props);
|
|
2204
|
-
|
|
2205
|
-
_this.dispose();
|
|
2206
|
-
|
|
2207
|
-
return _this;
|
|
2208
|
-
}
|
|
2209
|
-
|
|
2210
|
-
_createClass$2(DragDropContainer, [{
|
|
2211
|
-
key: "getHandlerId",
|
|
2212
|
-
value: function getHandlerId() {
|
|
2213
|
-
return this.handlerId;
|
|
2214
|
-
}
|
|
2215
|
-
}, {
|
|
2216
|
-
key: "getDecoratedComponentInstance",
|
|
2217
|
-
value: function getDecoratedComponentInstance() {
|
|
2218
|
-
invariant(this.decoratedRef.current, 'In order to access an instance of the decorated component, it must either be a class component or use React.forwardRef()');
|
|
2219
|
-
return this.decoratedRef.current;
|
|
2220
|
-
}
|
|
2221
|
-
}, {
|
|
2222
|
-
key: "shouldComponentUpdate",
|
|
2223
|
-
value: function shouldComponentUpdate(nextProps, nextState) {
|
|
2224
|
-
return !arePropsEqual(nextProps, this.props) || !shallowEqual(nextState, this.state);
|
|
2225
|
-
}
|
|
2226
|
-
}, {
|
|
2227
|
-
key: "componentDidMount",
|
|
2228
|
-
value: function componentDidMount() {
|
|
2229
|
-
this.disposable = new SerialDisposable();
|
|
2230
|
-
this.currentType = undefined;
|
|
2231
|
-
this.receiveProps(this.props);
|
|
2232
|
-
this.handleChange();
|
|
2233
|
-
}
|
|
2234
|
-
}, {
|
|
2235
|
-
key: "componentDidUpdate",
|
|
2236
|
-
value: function componentDidUpdate(prevProps) {
|
|
2237
|
-
if (!arePropsEqual(this.props, prevProps)) {
|
|
2238
|
-
this.receiveProps(this.props);
|
|
2239
|
-
this.handleChange();
|
|
2240
|
-
}
|
|
2241
|
-
}
|
|
2242
|
-
}, {
|
|
2243
|
-
key: "componentWillUnmount",
|
|
2244
|
-
value: function componentWillUnmount() {
|
|
2245
|
-
this.dispose();
|
|
2246
|
-
}
|
|
2247
|
-
}, {
|
|
2248
|
-
key: "receiveProps",
|
|
2249
|
-
value: function receiveProps(props) {
|
|
2250
|
-
if (!this.handler) {
|
|
2251
|
-
return;
|
|
2252
|
-
}
|
|
2253
|
-
|
|
2254
|
-
this.handler.receiveProps(props);
|
|
2255
|
-
this.receiveType(getType(props));
|
|
2256
|
-
}
|
|
2257
|
-
}, {
|
|
2258
|
-
key: "receiveType",
|
|
2259
|
-
value: function receiveType(type) {
|
|
2260
|
-
if (!this.handlerMonitor || !this.manager || !this.handlerConnector) {
|
|
2261
|
-
return;
|
|
2262
|
-
}
|
|
2263
|
-
|
|
2264
|
-
if (type === this.currentType) {
|
|
2265
|
-
return;
|
|
2266
|
-
}
|
|
2267
|
-
|
|
2268
|
-
this.currentType = type;
|
|
2269
|
-
|
|
2270
|
-
var _registerHandler = registerHandler(type, this.handler, this.manager),
|
|
2271
|
-
_registerHandler2 = _slicedToArray(_registerHandler, 2),
|
|
2272
|
-
handlerId = _registerHandler2[0],
|
|
2273
|
-
unregister = _registerHandler2[1];
|
|
2274
|
-
|
|
2275
|
-
this.handlerId = handlerId;
|
|
2276
|
-
this.handlerMonitor.receiveHandlerId(handlerId);
|
|
2277
|
-
this.handlerConnector.receiveHandlerId(handlerId);
|
|
2278
|
-
var globalMonitor = this.manager.getMonitor();
|
|
2279
|
-
var unsubscribe = globalMonitor.subscribeToStateChange(this.handleChange, {
|
|
2280
|
-
handlerIds: [handlerId]
|
|
2281
|
-
});
|
|
2282
|
-
this.disposable.setDisposable(new CompositeDisposable(new Disposable(unsubscribe), new Disposable(unregister)));
|
|
2283
|
-
}
|
|
2284
|
-
}, {
|
|
2285
|
-
key: "dispose",
|
|
2286
|
-
value: function dispose() {
|
|
2287
|
-
this.disposable.dispose();
|
|
2288
|
-
|
|
2289
|
-
if (this.handlerConnector) {
|
|
2290
|
-
this.handlerConnector.receiveHandlerId(null);
|
|
2291
|
-
}
|
|
2292
|
-
}
|
|
2293
|
-
}, {
|
|
2294
|
-
key: "getCurrentState",
|
|
2295
|
-
value: function getCurrentState() {
|
|
2296
|
-
if (!this.handlerConnector) {
|
|
2297
|
-
return {};
|
|
2298
|
-
}
|
|
2299
|
-
|
|
2300
|
-
var nextState = collect(this.handlerConnector.hooks, this.handlerMonitor, this.props);
|
|
2301
|
-
|
|
2302
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2303
|
-
invariant(isPlainObject(nextState), 'Expected `collect` specified as the second argument to ' + '%s for %s to return a plain object of props to inject. ' + 'Instead, received %s.', containerDisplayName, displayName, nextState);
|
|
2304
|
-
}
|
|
2305
|
-
|
|
2306
|
-
return nextState;
|
|
2307
|
-
}
|
|
2308
|
-
}, {
|
|
2309
|
-
key: "render",
|
|
2310
|
-
value: function render() {
|
|
2311
|
-
var _this2 = this;
|
|
2312
|
-
|
|
2313
|
-
return jsx(DndContext.Consumer, {
|
|
2314
|
-
children: function children(_ref2) {
|
|
2315
|
-
var dragDropManager = _ref2.dragDropManager;
|
|
2316
|
-
|
|
2317
|
-
_this2.receiveDragDropManager(dragDropManager);
|
|
2318
|
-
|
|
2319
|
-
if (typeof requestAnimationFrame !== 'undefined') {
|
|
2320
|
-
requestAnimationFrame(function () {
|
|
2321
|
-
var _this2$handlerConnect;
|
|
2322
|
-
|
|
2323
|
-
return (_this2$handlerConnect = _this2.handlerConnector) === null || _this2$handlerConnect === void 0 ? void 0 : _this2$handlerConnect.reconnect();
|
|
2324
|
-
});
|
|
2325
|
-
}
|
|
2326
|
-
|
|
2327
|
-
return jsx(Decorated, Object.assign({}, _this2.props, _this2.getCurrentState(), {
|
|
2328
|
-
// NOTE: if Decorated is a Function Component, decoratedRef will not be populated unless it's a refforwarding component.
|
|
2329
|
-
ref: isRefable(Decorated) ? _this2.decoratedRef : null
|
|
2330
|
-
}), void 0);
|
|
2331
|
-
}
|
|
2332
|
-
}, void 0);
|
|
2333
|
-
}
|
|
2334
|
-
}, {
|
|
2335
|
-
key: "receiveDragDropManager",
|
|
2336
|
-
value: function receiveDragDropManager(dragDropManager) {
|
|
2337
|
-
if (this.manager !== undefined) {
|
|
2338
|
-
return;
|
|
2339
|
-
}
|
|
2340
|
-
|
|
2341
|
-
invariant(dragDropManager !== undefined, 'Could not find the drag and drop manager in the context of %s. ' + 'Make sure to render a DndProvider component in your top-level component. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/troubleshooting#could-not-find-the-drag-and-drop-manager-in-the-context', displayName, displayName);
|
|
2342
|
-
|
|
2343
|
-
if (dragDropManager === undefined) {
|
|
2344
|
-
return;
|
|
2345
|
-
}
|
|
2346
|
-
|
|
2347
|
-
this.manager = dragDropManager;
|
|
2348
|
-
this.handlerMonitor = createMonitor(dragDropManager);
|
|
2349
|
-
this.handlerConnector = createConnector(dragDropManager.getBackend());
|
|
2350
|
-
this.handler = createHandler(this.handlerMonitor, this.decoratedRef);
|
|
2351
|
-
}
|
|
2352
|
-
}]);
|
|
2353
|
-
|
|
2354
|
-
return DragDropContainer;
|
|
2355
|
-
}(Component);
|
|
2356
|
-
|
|
2357
|
-
_defineProperty$2(DragDropContainer, "DecoratedComponent", DecoratedComponent);
|
|
2358
|
-
|
|
2359
|
-
_defineProperty$2(DragDropContainer, "displayName", "".concat(containerDisplayName, "(").concat(displayName, ")"));
|
|
2360
|
-
|
|
2361
|
-
return hoistStatics(DragDropContainer, DecoratedComponent);
|
|
2362
|
-
}
|
|
2363
|
-
|
|
2364
|
-
function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2365
|
-
|
|
2366
|
-
function _defineProperties$1(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
2367
|
-
|
|
2368
|
-
function _createClass$1(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$1(Constructor.prototype, protoProps); if (staticProps) _defineProperties$1(Constructor, staticProps); return Constructor; }
|
|
2369
|
-
|
|
2370
|
-
function _defineProperty$1(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2371
|
-
var ALLOWED_SPEC_METHODS$1 = ['canDrag', 'beginDrag', 'isDragging', 'endDrag'];
|
|
2372
|
-
var REQUIRED_SPEC_METHODS = ['beginDrag'];
|
|
2373
|
-
|
|
2374
|
-
var SourceImpl = /*#__PURE__*/function () {
|
|
2375
|
-
function SourceImpl(spec, monitor, ref) {
|
|
2376
|
-
var _this = this;
|
|
2377
|
-
|
|
2378
|
-
_classCallCheck$1(this, SourceImpl);
|
|
2379
|
-
|
|
2380
|
-
_defineProperty$1(this, "props", null);
|
|
2381
|
-
|
|
2382
|
-
_defineProperty$1(this, "spec", void 0);
|
|
2383
|
-
|
|
2384
|
-
_defineProperty$1(this, "monitor", void 0);
|
|
2385
|
-
|
|
2386
|
-
_defineProperty$1(this, "ref", void 0);
|
|
2387
|
-
|
|
2388
|
-
_defineProperty$1(this, "beginDrag", function () {
|
|
2389
|
-
if (!_this.props) {
|
|
2390
|
-
return;
|
|
2391
|
-
}
|
|
2392
|
-
|
|
2393
|
-
var item = _this.spec.beginDrag(_this.props, _this.monitor, _this.ref.current);
|
|
2394
|
-
|
|
2395
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2396
|
-
invariant(isPlainObject(item), 'beginDrag() must return a plain object that represents the dragged item. ' + 'Instead received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', item);
|
|
2397
|
-
}
|
|
2398
|
-
|
|
2399
|
-
return item;
|
|
2400
|
-
});
|
|
2401
|
-
|
|
2402
|
-
this.spec = spec;
|
|
2403
|
-
this.monitor = monitor;
|
|
2404
|
-
this.ref = ref;
|
|
2405
|
-
}
|
|
2406
|
-
|
|
2407
|
-
_createClass$1(SourceImpl, [{
|
|
2408
|
-
key: "receiveProps",
|
|
2409
|
-
value: function receiveProps(props) {
|
|
2410
|
-
this.props = props;
|
|
2411
|
-
}
|
|
2412
|
-
}, {
|
|
2413
|
-
key: "canDrag",
|
|
2414
|
-
value: function canDrag() {
|
|
2415
|
-
if (!this.props) {
|
|
2416
|
-
return false;
|
|
2417
|
-
}
|
|
2418
|
-
|
|
2419
|
-
if (!this.spec.canDrag) {
|
|
2420
|
-
return true;
|
|
2421
|
-
}
|
|
2422
|
-
|
|
2423
|
-
return this.spec.canDrag(this.props, this.monitor);
|
|
2424
|
-
}
|
|
2425
|
-
}, {
|
|
2426
|
-
key: "isDragging",
|
|
2427
|
-
value: function isDragging(globalMonitor, sourceId) {
|
|
2428
|
-
if (!this.props) {
|
|
2429
|
-
return false;
|
|
2430
|
-
}
|
|
2431
|
-
|
|
2432
|
-
if (!this.spec.isDragging) {
|
|
2433
|
-
return sourceId === globalMonitor.getSourceId();
|
|
2434
|
-
}
|
|
2435
|
-
|
|
2436
|
-
return this.spec.isDragging(this.props, this.monitor);
|
|
2437
|
-
}
|
|
2438
|
-
}, {
|
|
2439
|
-
key: "endDrag",
|
|
2440
|
-
value: function endDrag() {
|
|
2441
|
-
if (!this.props) {
|
|
2442
|
-
return;
|
|
2443
|
-
}
|
|
2444
|
-
|
|
2445
|
-
if (!this.spec.endDrag) {
|
|
2446
|
-
return;
|
|
2447
|
-
}
|
|
2448
|
-
|
|
2449
|
-
this.spec.endDrag(this.props, this.monitor, getDecoratedComponent(this.ref));
|
|
2450
|
-
}
|
|
2451
|
-
}]);
|
|
2452
|
-
|
|
2453
|
-
return SourceImpl;
|
|
2454
|
-
}();
|
|
2455
|
-
|
|
2456
|
-
function createSourceFactory(spec) {
|
|
2457
|
-
Object.keys(spec).forEach(function (key) {
|
|
2458
|
-
invariant(ALLOWED_SPEC_METHODS$1.indexOf(key) > -1, 'Expected the drag source specification to only have ' + 'some of the following keys: %s. ' + 'Instead received a specification with an unexpected "%s" key. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', ALLOWED_SPEC_METHODS$1.join(', '), key);
|
|
2459
|
-
invariant(typeof spec[key] === 'function', 'Expected %s in the drag source specification to be a function. ' + 'Instead received a specification with %s: %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', key, key, spec[key]);
|
|
2460
|
-
});
|
|
2461
|
-
REQUIRED_SPEC_METHODS.forEach(function (key) {
|
|
2462
|
-
invariant(typeof spec[key] === 'function', 'Expected %s in the drag source specification to be a function. ' + 'Instead received a specification with %s: %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', key, key, spec[key]);
|
|
2463
|
-
});
|
|
2464
|
-
return function createSource(monitor, ref) {
|
|
2465
|
-
return new SourceImpl(spec, monitor, ref);
|
|
2466
|
-
};
|
|
2467
|
-
}
|
|
2468
|
-
|
|
2469
|
-
/**
|
|
2470
|
-
* Decorates a component as a dragsource
|
|
2471
|
-
* @param type The dragsource type
|
|
2472
|
-
* @param spec The drag source specification
|
|
2473
|
-
* @param collect The props collector function
|
|
2474
|
-
* @param options DnD options
|
|
2475
|
-
*/
|
|
2476
|
-
|
|
2477
|
-
function DragSource(type, spec, collect) {
|
|
2478
|
-
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
2479
|
-
checkDecoratorArguments('DragSource', 'type, spec, collect[, options]', type, spec, collect, options);
|
|
2480
|
-
var getType = type;
|
|
2481
|
-
|
|
2482
|
-
if (typeof type !== 'function') {
|
|
2483
|
-
invariant(isValidType(type), 'Expected "type" provided as the first argument to DragSource to be ' + 'a string, or a function that returns a string given the current props. ' + 'Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', type);
|
|
2484
|
-
|
|
2485
|
-
getType = function getType() {
|
|
2486
|
-
return type;
|
|
2487
|
-
};
|
|
2488
|
-
}
|
|
2489
|
-
|
|
2490
|
-
invariant(isPlainObject(spec), 'Expected "spec" provided as the second argument to DragSource to be ' + 'a plain object. Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', spec);
|
|
2491
|
-
var createSource = createSourceFactory(spec);
|
|
2492
|
-
invariant(typeof collect === 'function', 'Expected "collect" provided as the third argument to DragSource to be ' + 'a function that returns a plain object of props to inject. ' + 'Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', collect);
|
|
2493
|
-
invariant(isPlainObject(options), 'Expected "options" provided as the fourth argument to DragSource to be ' + 'a plain object when specified. ' + 'Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', collect);
|
|
2494
|
-
return function decorateSource(DecoratedComponent) {
|
|
2495
|
-
return decorateHandler({
|
|
2496
|
-
containerDisplayName: 'DragSource',
|
|
2497
|
-
createHandler: createSource,
|
|
2498
|
-
registerHandler: registerSource,
|
|
2499
|
-
createConnector: function createConnector(backend) {
|
|
2500
|
-
return new SourceConnector(backend);
|
|
2501
|
-
},
|
|
2502
|
-
createMonitor: function createMonitor(manager) {
|
|
2503
|
-
return new DragSourceMonitorImpl(manager);
|
|
2504
|
-
},
|
|
2505
|
-
DecoratedComponent: DecoratedComponent,
|
|
2506
|
-
getType: getType,
|
|
2507
|
-
collect: collect,
|
|
2508
|
-
options: options
|
|
2509
|
-
});
|
|
2510
|
-
};
|
|
2511
|
-
}
|
|
2512
|
-
|
|
2513
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2514
|
-
|
|
2515
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
2516
|
-
|
|
2517
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
2518
|
-
|
|
2519
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2520
|
-
var ALLOWED_SPEC_METHODS = ['canDrop', 'hover', 'drop'];
|
|
2521
|
-
|
|
2522
|
-
var TargetImpl = /*#__PURE__*/function () {
|
|
2523
|
-
function TargetImpl(spec, monitor, ref) {
|
|
2524
|
-
_classCallCheck(this, TargetImpl);
|
|
2525
|
-
|
|
2526
|
-
_defineProperty(this, "props", null);
|
|
2527
|
-
|
|
2528
|
-
_defineProperty(this, "spec", void 0);
|
|
2529
|
-
|
|
2530
|
-
_defineProperty(this, "monitor", void 0);
|
|
2531
|
-
|
|
2532
|
-
_defineProperty(this, "ref", void 0);
|
|
2533
|
-
|
|
2534
|
-
this.spec = spec;
|
|
2535
|
-
this.monitor = monitor;
|
|
2536
|
-
this.ref = ref;
|
|
2537
|
-
}
|
|
2538
|
-
|
|
2539
|
-
_createClass(TargetImpl, [{
|
|
2540
|
-
key: "receiveProps",
|
|
2541
|
-
value: function receiveProps(props) {
|
|
2542
|
-
this.props = props;
|
|
2543
|
-
}
|
|
2544
|
-
}, {
|
|
2545
|
-
key: "receiveMonitor",
|
|
2546
|
-
value: function receiveMonitor(monitor) {
|
|
2547
|
-
this.monitor = monitor;
|
|
2548
|
-
}
|
|
2549
|
-
}, {
|
|
2550
|
-
key: "canDrop",
|
|
2551
|
-
value: function canDrop() {
|
|
2552
|
-
if (!this.spec.canDrop) {
|
|
2553
|
-
return true;
|
|
2554
|
-
}
|
|
2555
|
-
|
|
2556
|
-
return this.spec.canDrop(this.props, this.monitor);
|
|
2557
|
-
}
|
|
2558
|
-
}, {
|
|
2559
|
-
key: "hover",
|
|
2560
|
-
value: function hover() {
|
|
2561
|
-
if (!this.spec.hover || !this.props) {
|
|
2562
|
-
return;
|
|
2563
|
-
}
|
|
2564
|
-
|
|
2565
|
-
this.spec.hover(this.props, this.monitor, getDecoratedComponent(this.ref));
|
|
2566
|
-
}
|
|
2567
|
-
}, {
|
|
2568
|
-
key: "drop",
|
|
2569
|
-
value: function drop() {
|
|
2570
|
-
if (!this.spec.drop) {
|
|
2571
|
-
return undefined;
|
|
2572
|
-
}
|
|
2573
|
-
|
|
2574
|
-
var dropResult = this.spec.drop(this.props, this.monitor, this.ref.current);
|
|
2575
|
-
|
|
2576
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2577
|
-
invariant(typeof dropResult === 'undefined' || isPlainObject(dropResult), 'drop() must either return undefined, or an object that represents the drop result. ' + 'Instead received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', dropResult);
|
|
2578
|
-
}
|
|
2579
|
-
|
|
2580
|
-
return dropResult;
|
|
2581
|
-
}
|
|
2582
|
-
}]);
|
|
2583
|
-
|
|
2584
|
-
return TargetImpl;
|
|
2585
|
-
}();
|
|
2586
|
-
|
|
2587
|
-
function createTargetFactory(spec) {
|
|
2588
|
-
Object.keys(spec).forEach(function (key) {
|
|
2589
|
-
invariant(ALLOWED_SPEC_METHODS.indexOf(key) > -1, 'Expected the drop target specification to only have ' + 'some of the following keys: %s. ' + 'Instead received a specification with an unexpected "%s" key. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', ALLOWED_SPEC_METHODS.join(', '), key);
|
|
2590
|
-
invariant(typeof spec[key] === 'function', 'Expected %s in the drop target specification to be a function. ' + 'Instead received a specification with %s: %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', key, key, spec[key]);
|
|
2591
|
-
});
|
|
2592
|
-
return function createTarget(monitor, ref) {
|
|
2593
|
-
return new TargetImpl(spec, monitor, ref);
|
|
2594
|
-
};
|
|
2595
|
-
}
|
|
2596
|
-
|
|
2597
|
-
/**
|
|
2598
|
-
* @param type The accepted target type
|
|
2599
|
-
* @param spec The DropTarget specification
|
|
2600
|
-
* @param collect The props collector function
|
|
2601
|
-
* @param options Options
|
|
2602
|
-
*/
|
|
2603
|
-
|
|
2604
|
-
function DropTarget(type, spec, collect) {
|
|
2605
|
-
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
2606
|
-
checkDecoratorArguments('DropTarget', 'type, spec, collect[, options]', type, spec, collect, options);
|
|
2607
|
-
var getType = type;
|
|
2608
|
-
|
|
2609
|
-
if (typeof type !== 'function') {
|
|
2610
|
-
invariant(isValidType(type, true), 'Expected "type" provided as the first argument to DropTarget to be ' + 'a string, an array of strings, or a function that returns either given ' + 'the current props. Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', type);
|
|
2611
|
-
|
|
2612
|
-
getType = function getType() {
|
|
2613
|
-
return type;
|
|
2614
|
-
};
|
|
2615
|
-
}
|
|
2616
|
-
|
|
2617
|
-
invariant(isPlainObject(spec), 'Expected "spec" provided as the second argument to DropTarget to be ' + 'a plain object. Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', spec);
|
|
2618
|
-
var createTarget = createTargetFactory(spec);
|
|
2619
|
-
invariant(typeof collect === 'function', 'Expected "collect" provided as the third argument to DropTarget to be ' + 'a function that returns a plain object of props to inject. ' + 'Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', collect);
|
|
2620
|
-
invariant(isPlainObject(options), 'Expected "options" provided as the fourth argument to DropTarget to be ' + 'a plain object when specified. ' + 'Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', collect);
|
|
2621
|
-
return function decorateTarget(DecoratedComponent) {
|
|
2622
|
-
return decorateHandler({
|
|
2623
|
-
containerDisplayName: 'DropTarget',
|
|
2624
|
-
createHandler: createTarget,
|
|
2625
|
-
registerHandler: registerTarget,
|
|
2626
|
-
createMonitor: function createMonitor(manager) {
|
|
2627
|
-
return new DropTargetMonitorImpl(manager);
|
|
2628
|
-
},
|
|
2629
|
-
createConnector: function createConnector(backend) {
|
|
2630
|
-
return new TargetConnector(backend);
|
|
2631
|
-
},
|
|
2632
|
-
DecoratedComponent: DecoratedComponent,
|
|
2633
|
-
getType: getType,
|
|
2634
|
-
collect: collect,
|
|
2635
|
-
options: options
|
|
2636
|
-
});
|
|
2637
|
-
};
|
|
2638
|
-
}
|
|
2639
|
-
|
|
2640
|
-
const log$1 = debug('@pie-element:categorize:configure');
|
|
2641
|
-
const Helper = withStyles(theme => ({
|
|
2642
|
-
helper: {
|
|
2643
|
-
display: 'flex',
|
|
2644
|
-
alignItems: 'center',
|
|
2645
|
-
fontSize: theme.typography.fontSize - 2,
|
|
2646
|
-
color: `rgba(${theme.palette.common.black}, 0.4)`,
|
|
2647
|
-
width: '100%',
|
|
2648
|
-
height: '100%'
|
|
2649
|
-
}
|
|
2650
|
-
}))(({
|
|
2651
|
-
classes
|
|
2652
|
-
}) => /*#__PURE__*/React.createElement("div", {
|
|
2653
|
-
className: classes.helper
|
|
2654
|
-
}, "Drag your correct answers here"));
|
|
2655
|
-
|
|
2656
|
-
const Previews = ({
|
|
2657
|
-
alternateResponseIndex,
|
|
2658
|
-
category,
|
|
2659
|
-
choices,
|
|
2660
|
-
onDeleteChoice
|
|
2661
|
-
}) => /*#__PURE__*/React.createElement(React.Fragment, null, choices.map((c, index) => c && /*#__PURE__*/React.createElement(ChoicePreview$1, {
|
|
2662
|
-
alternateResponseIndex: alternateResponseIndex,
|
|
2663
|
-
category: category,
|
|
2664
|
-
choice: c,
|
|
2665
|
-
key: index,
|
|
2666
|
-
choiceIndex: index,
|
|
2667
|
-
onDelete: choice => onDeleteChoice(choice, index)
|
|
2668
|
-
})));
|
|
2669
|
-
|
|
2670
|
-
Previews.propTypes = {
|
|
2671
|
-
alternateResponseIndex: PropTypes.number,
|
|
2672
|
-
category: PropTypes.object,
|
|
2673
|
-
choices: PropTypes.array,
|
|
2674
|
-
onDeleteChoice: PropTypes.func
|
|
2675
|
-
};
|
|
2676
|
-
class DroppablePlaceHolder extends React.Component {
|
|
2677
|
-
render() {
|
|
2678
|
-
const {
|
|
2679
|
-
alternateResponseIndex,
|
|
2680
|
-
isOver,
|
|
2681
|
-
category,
|
|
2682
|
-
choices,
|
|
2683
|
-
classes,
|
|
2684
|
-
className,
|
|
2685
|
-
connectDropTarget,
|
|
2686
|
-
onDeleteChoice
|
|
2687
|
-
} = this.props;
|
|
2688
|
-
return connectDropTarget( /*#__PURE__*/React.createElement("div", {
|
|
2689
|
-
className: classNames(classes.droppablePlaceholder, className)
|
|
2690
|
-
}, /*#__PURE__*/React.createElement(PlaceHolder$1, {
|
|
2691
|
-
isOver: isOver,
|
|
2692
|
-
className: classes.placeHolder
|
|
2693
|
-
}, (choices || []).length === 0 ? /*#__PURE__*/React.createElement(Helper, null) : /*#__PURE__*/React.createElement(Previews, {
|
|
2694
|
-
alternateResponseIndex: alternateResponseIndex,
|
|
2695
|
-
category: category,
|
|
2696
|
-
choices: choices,
|
|
2697
|
-
onDeleteChoice: onDeleteChoice
|
|
2698
|
-
}))));
|
|
2699
|
-
}
|
|
2700
|
-
|
|
2701
|
-
}
|
|
2702
|
-
DroppablePlaceHolder.propTypes = {
|
|
2703
|
-
alternateResponseIndex: PropTypes.number,
|
|
2704
|
-
category: PropTypes.object,
|
|
2705
|
-
classes: PropTypes.object.isRequired,
|
|
2706
|
-
className: PropTypes.string,
|
|
2707
|
-
connectDropTarget: PropTypes.func.isRequired,
|
|
2708
|
-
choices: PropTypes.array,
|
|
2709
|
-
onDropChoice: PropTypes.func.isRequired,
|
|
2710
|
-
onMoveChoice: PropTypes.func,
|
|
2711
|
-
isOver: PropTypes.bool,
|
|
2712
|
-
onDeleteChoice: PropTypes.func,
|
|
2713
|
-
categoryId: PropTypes.string.isRequired
|
|
2714
|
-
};
|
|
2715
|
-
DroppablePlaceHolder.defaultProps = {};
|
|
2716
|
-
|
|
2717
|
-
const styles$a = () => ({
|
|
2718
|
-
droppablePlaceholder: {
|
|
2719
|
-
minHeight: '100px'
|
|
2720
|
-
},
|
|
2721
|
-
placeHolder: {
|
|
2722
|
-
width: '100%',
|
|
2723
|
-
minHeight: '100px',
|
|
2724
|
-
height: 'auto'
|
|
2725
|
-
}
|
|
2726
|
-
});
|
|
2727
|
-
|
|
2728
|
-
const Styled = withStyles(styles$a)(DroppablePlaceHolder);
|
|
2729
|
-
const spec$1 = {
|
|
2730
|
-
drop: (props, monitor) => {
|
|
2731
|
-
log$1('[drop] props: ', props);
|
|
2732
|
-
const item = monitor.getItem();
|
|
2733
|
-
|
|
2734
|
-
if (item.from && item.alternateResponseIndex === props.alternateResponseIndex) {
|
|
2735
|
-
props.onMoveChoice(item.choiceId, item.from, props.categoryId, item.choiceIndex, item.alternateResponseIndex);
|
|
2736
|
-
} else if (!item.from) {
|
|
2737
|
-
// avoid dropping choice when user tries to move it to an alternate with other index
|
|
2738
|
-
props.onDropChoice(item, props.categoryId);
|
|
2739
|
-
}
|
|
2740
|
-
},
|
|
2741
|
-
canDrop: (props
|
|
2742
|
-
/*, monitor*/
|
|
2743
|
-
) => {
|
|
2744
|
-
return !props.disabled;
|
|
2745
|
-
}
|
|
2746
|
-
};
|
|
2747
|
-
const WithTarget = DropTarget(({
|
|
2748
|
-
uid
|
|
2749
|
-
}) => uid, spec$1, (connect, monitor) => ({
|
|
2750
|
-
connectDropTarget: connect.dropTarget(),
|
|
2751
|
-
isOver: monitor.isOver()
|
|
2752
|
-
}))(Styled);
|
|
2753
|
-
var PlaceHolder = uid.withUid(WithTarget);
|
|
2754
|
-
|
|
2755
|
-
class Category extends React.Component {
|
|
2756
|
-
constructor(...args) {
|
|
2757
|
-
super(...args);
|
|
2758
|
-
|
|
2759
|
-
this.changeLabel = l => {
|
|
2760
|
-
const {
|
|
2761
|
-
category,
|
|
2762
|
-
onChange
|
|
2763
|
-
} = this.props;
|
|
2764
|
-
category.label = l;
|
|
2765
|
-
onChange(category);
|
|
2766
|
-
};
|
|
2767
|
-
}
|
|
2768
|
-
|
|
2769
|
-
render() {
|
|
2770
|
-
const {
|
|
2771
|
-
alternateResponseIndex,
|
|
2772
|
-
category,
|
|
2773
|
-
classes,
|
|
2774
|
-
className,
|
|
2775
|
-
configuration,
|
|
2776
|
-
deleteFocusedEl,
|
|
2777
|
-
focusedEl,
|
|
2778
|
-
index,
|
|
2779
|
-
error,
|
|
2780
|
-
isDuplicated,
|
|
2781
|
-
onDelete,
|
|
2782
|
-
onDeleteChoice,
|
|
2783
|
-
onAddChoice,
|
|
2784
|
-
onMoveChoice,
|
|
2785
|
-
imageSupport,
|
|
2786
|
-
spellCheck,
|
|
2787
|
-
toolbarOpts,
|
|
2788
|
-
maxImageWidth,
|
|
2789
|
-
maxImageHeight,
|
|
2790
|
-
uploadSoundSupport,
|
|
2791
|
-
mathMlOptions = {}
|
|
2792
|
-
} = this.props;
|
|
2793
|
-
const isCategoryHeaderDisabled = !!alternateResponseIndex || alternateResponseIndex === 0;
|
|
2794
|
-
return /*#__PURE__*/React.createElement(Card, {
|
|
2795
|
-
className: classNames(classes.category, className, {
|
|
2796
|
-
[classes.duplicateError]: isDuplicated
|
|
2797
|
-
})
|
|
2798
|
-
}, /*#__PURE__*/React.createElement("span", null, !isCategoryHeaderDisabled ? /*#__PURE__*/React.createElement(InputHeader$1, {
|
|
2799
|
-
label: category.label,
|
|
2800
|
-
focusedEl: focusedEl,
|
|
2801
|
-
deleteFocusedEl: deleteFocusedEl,
|
|
2802
|
-
index: index,
|
|
2803
|
-
disabled: !!alternateResponseIndex || alternateResponseIndex === 0,
|
|
2804
|
-
error: error,
|
|
2805
|
-
onChange: this.changeLabel,
|
|
2806
|
-
onDelete: onDelete,
|
|
2807
|
-
imageSupport: imageSupport,
|
|
2808
|
-
toolbarOpts: toolbarOpts,
|
|
2809
|
-
spellCheck: spellCheck,
|
|
2810
|
-
maxImageWidth: maxImageWidth,
|
|
2811
|
-
maxImageHeight: maxImageHeight,
|
|
2812
|
-
uploadSoundSupport: uploadSoundSupport,
|
|
2813
|
-
mathMlOptions: mathMlOptions,
|
|
2814
|
-
configuration: configuration
|
|
2815
|
-
}) : /*#__PURE__*/React.createElement("div", {
|
|
2816
|
-
className: classes.categoryHeader,
|
|
2817
|
-
dangerouslySetInnerHTML: {
|
|
2818
|
-
__html: category.label
|
|
2819
|
-
}
|
|
2820
|
-
}), error && /*#__PURE__*/React.createElement("div", {
|
|
2821
|
-
className: classes.errorText
|
|
2822
|
-
}, error)), /*#__PURE__*/React.createElement(PlaceHolder, {
|
|
2823
|
-
className: classes.placeHolder,
|
|
2824
|
-
alternateResponseIndex: alternateResponseIndex,
|
|
2825
|
-
category: category,
|
|
2826
|
-
choices: category.choices,
|
|
2827
|
-
onDeleteChoice: onDeleteChoice,
|
|
2828
|
-
onDropChoice: onAddChoice,
|
|
2829
|
-
onMoveChoice: onMoveChoice,
|
|
2830
|
-
categoryId: category.id
|
|
2831
|
-
}), onDelete && /*#__PURE__*/React.createElement(CardActions, {
|
|
2832
|
-
className: classes.actions
|
|
2833
|
-
}, /*#__PURE__*/React.createElement(DeleteButton, {
|
|
2834
|
-
label: 'delete',
|
|
2835
|
-
onClick: onDelete
|
|
2836
|
-
})));
|
|
2837
|
-
}
|
|
2838
|
-
|
|
2839
|
-
}
|
|
2840
|
-
Category.propTypes = {
|
|
2841
|
-
alternateResponseIndex: PropTypes.number,
|
|
2842
|
-
classes: PropTypes.object.isRequired,
|
|
2843
|
-
className: PropTypes.string,
|
|
2844
|
-
category: PropTypes.object.isRequired,
|
|
2845
|
-
configuration: PropTypes.object.isRequired,
|
|
2846
|
-
defaultImageMaxHeight: PropTypes.number,
|
|
2847
|
-
defaultImageMaxWidth: PropTypes.number,
|
|
2848
|
-
deleteFocusedEl: PropTypes.func,
|
|
2849
|
-
focusedEl: PropTypes.number,
|
|
2850
|
-
index: PropTypes.number,
|
|
2851
|
-
error: PropTypes.string,
|
|
2852
|
-
isDuplicated: PropTypes.bool,
|
|
2853
|
-
maxImageWidth: PropTypes.object,
|
|
2854
|
-
maxImageHeight: PropTypes.object,
|
|
2855
|
-
onChange: PropTypes.func,
|
|
2856
|
-
onDelete: PropTypes.func,
|
|
2857
|
-
onDeleteChoice: PropTypes.func,
|
|
2858
|
-
onAddChoice: PropTypes.func,
|
|
2859
|
-
onMoveChoice: PropTypes.func,
|
|
2860
|
-
imageSupport: PropTypes.shape({
|
|
2861
|
-
add: PropTypes.func.isRequired,
|
|
2862
|
-
delete: PropTypes.func.isRequired
|
|
2863
|
-
}),
|
|
2864
|
-
toolbarOpts: PropTypes.object,
|
|
2865
|
-
spellCheck: PropTypes.bool,
|
|
2866
|
-
uploadSoundSupport: PropTypes.shape({
|
|
2867
|
-
add: PropTypes.func.isRequired,
|
|
2868
|
-
delete: PropTypes.func.isRequired
|
|
2869
|
-
})
|
|
2870
|
-
};
|
|
2871
|
-
Category.defaultProps = {};
|
|
2872
|
-
|
|
2873
|
-
const styles$9 = theme => ({
|
|
2874
|
-
placeHolder: {
|
|
2875
|
-
minHeight: '100px'
|
|
2876
|
-
},
|
|
2877
|
-
deleteButton: {
|
|
2878
|
-
margin: 0
|
|
2879
|
-
},
|
|
2880
|
-
actions: {
|
|
2881
|
-
padding: 0,
|
|
2882
|
-
paddingBottom: 0,
|
|
2883
|
-
paddingTop: theme.spacing.unit
|
|
2884
|
-
},
|
|
2885
|
-
iconButtonRoot: {
|
|
2886
|
-
width: 'auto',
|
|
2887
|
-
height: 'auto'
|
|
2888
|
-
},
|
|
2889
|
-
header: {
|
|
2890
|
-
display: 'flex',
|
|
2891
|
-
justifyContent: 'space-between'
|
|
2892
|
-
},
|
|
2893
|
-
category: {
|
|
2894
|
-
minWidth: '196px',
|
|
2895
|
-
padding: theme.spacing.unit,
|
|
2896
|
-
overflow: 'visible'
|
|
2897
|
-
},
|
|
2898
|
-
categoryHeader: {
|
|
2899
|
-
padding: theme.spacing.unit * 2,
|
|
2900
|
-
'& p': {
|
|
2901
|
-
margin: 0
|
|
2902
|
-
}
|
|
2903
|
-
},
|
|
2904
|
-
duplicateError: {
|
|
2905
|
-
border: '1px solid red'
|
|
2906
|
-
},
|
|
2907
|
-
errorText: {
|
|
2908
|
-
fontSize: theme.typography.fontSize - 2,
|
|
2909
|
-
color: theme.palette.error.main,
|
|
2910
|
-
paddingBottom: theme.spacing.unit
|
|
2911
|
-
},
|
|
2912
|
-
editor: {
|
|
2913
|
-
flex: '1',
|
|
2914
|
-
paddingBottom: theme.spacing.unit * 2
|
|
2915
|
-
}
|
|
2916
|
-
});
|
|
2917
|
-
|
|
2918
|
-
var Category$1 = withStyles(styles$9)(Category);
|
|
2919
|
-
|
|
2920
|
-
class Header extends React.Component {
|
|
2921
|
-
render() {
|
|
2922
|
-
const {
|
|
2923
|
-
classes,
|
|
2924
|
-
className,
|
|
2925
|
-
onAdd,
|
|
2926
|
-
label,
|
|
2927
|
-
buttonLabel,
|
|
2928
|
-
info,
|
|
2929
|
-
buttonDisabled,
|
|
2930
|
-
variant,
|
|
2931
|
-
tooltip
|
|
2932
|
-
} = this.props;
|
|
2933
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
2934
|
-
className: classNames(classes.header, className)
|
|
2935
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
2936
|
-
className: classes.titleContainer
|
|
2937
|
-
}, /*#__PURE__*/React.createElement(Typography, {
|
|
2938
|
-
variant: variant || 'title',
|
|
2939
|
-
className: classes.title
|
|
2940
|
-
}, label), info), /*#__PURE__*/React.createElement(Tooltip, {
|
|
2941
|
-
title: tooltip || '',
|
|
2942
|
-
classes: {
|
|
2943
|
-
tooltip: classes.tooltip
|
|
2944
|
-
},
|
|
2945
|
-
enterTouchDelay: 50 // Appear quickly after a touch
|
|
2946
|
-
,
|
|
2947
|
-
leaveTouchDelay: 3000 // Stay visible for 3 seconds
|
|
2948
|
-
|
|
2949
|
-
}, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(AddButton, {
|
|
2950
|
-
onClick: onAdd,
|
|
2951
|
-
label: buttonLabel,
|
|
2952
|
-
disabled: buttonDisabled
|
|
2953
|
-
}))));
|
|
2954
|
-
}
|
|
2955
|
-
|
|
2956
|
-
}
|
|
2957
|
-
Header.propTypes = {
|
|
2958
|
-
classes: PropTypes.object.isRequired,
|
|
2959
|
-
className: PropTypes.string,
|
|
2960
|
-
buttonLabel: PropTypes.string,
|
|
2961
|
-
onAdd: PropTypes.func.isRequired,
|
|
2962
|
-
label: PropTypes.string.isRequired,
|
|
2963
|
-
info: PropTypes.any,
|
|
2964
|
-
buttonDisabled: PropTypes.bool,
|
|
2965
|
-
variant: PropTypes.string,
|
|
2966
|
-
tooltip: PropTypes.string
|
|
2967
|
-
};
|
|
2968
|
-
Header.defaultProps = {};
|
|
2969
|
-
|
|
2970
|
-
const styles$8 = theme => ({
|
|
2971
|
-
header: {
|
|
2972
|
-
display: 'flex',
|
|
2973
|
-
justifyContent: 'space-between',
|
|
2974
|
-
marginBottom: theme.spacing.unit
|
|
2975
|
-
},
|
|
2976
|
-
titleContainer: {
|
|
2977
|
-
display: 'flex',
|
|
2978
|
-
alignItems: 'center'
|
|
2979
|
-
},
|
|
2980
|
-
tooltip: {
|
|
2981
|
-
fontSize: theme.typography.fontSize - 2,
|
|
2982
|
-
whiteSpace: 'pre',
|
|
2983
|
-
maxWidth: '500px'
|
|
2984
|
-
}
|
|
2985
|
-
});
|
|
2986
|
-
|
|
2987
|
-
var Header$1 = withStyles(styles$8)(Header);
|
|
2988
|
-
|
|
2989
|
-
const generateValidationMessage = config => {
|
|
2990
|
-
let {
|
|
2991
|
-
minChoices,
|
|
2992
|
-
maxChoices,
|
|
2993
|
-
maxCategories
|
|
2994
|
-
} = config || {};
|
|
2995
|
-
minChoices = minChoices || 1;
|
|
2996
|
-
const validationMessage = '\nThe choices content should ' + 'not be empty and should be unique.\nThere should be at least 1 ' + (maxCategories ? `and at most ${maxCategories} ` : '') + 'category' + (maxCategories ? 's' : '') + ' defined.' + (minChoices ? `\nThere should be at least ${minChoices} choices defined.` : '') + (maxChoices ? `\nNo more than ${maxChoices} choices should be defined.` : '') + '\nAt least one token should be assigned to at least one category.';
|
|
2997
|
-
return 'Validation requirements:' + validationMessage;
|
|
2998
|
-
}; // used in controller too, for consistency modify it there too
|
|
2999
|
-
|
|
3000
|
-
const multiplePlacements = {
|
|
3001
|
-
enabled: 'Yes',
|
|
3002
|
-
disabled: 'No',
|
|
3003
|
-
perChoice: 'Set Per Choice'
|
|
3004
|
-
}; // Find the length of the largest array from an array
|
|
3005
|
-
|
|
3006
|
-
const maxLength = array => (array || []).reduce((max, arr) => {
|
|
3007
|
-
return Math.max(max, arr.length);
|
|
3008
|
-
}, 0);
|
|
3009
|
-
const getMaxCategoryChoices = model => {
|
|
3010
|
-
const {
|
|
3011
|
-
correctResponse = []
|
|
3012
|
-
} = model || {};
|
|
3013
|
-
return correctResponse.reduce((max, correctRes) => {
|
|
3014
|
-
var _correctRes$choices;
|
|
3015
|
-
|
|
3016
|
-
const correctRespLength = (correctRes == null ? void 0 : (_correctRes$choices = correctRes.choices) == null ? void 0 : _correctRes$choices.length) || 0;
|
|
3017
|
-
const alternates = (correctRes == null ? void 0 : correctRes.alternateResponses) || [];
|
|
3018
|
-
const maxChoices = Math.max(correctRespLength, maxLength(alternates));
|
|
3019
|
-
return maxChoices > max ? maxChoices : max;
|
|
3020
|
-
}, 0);
|
|
3021
|
-
};
|
|
3022
|
-
|
|
3023
|
-
const styles$7 = theme => ({
|
|
3024
|
-
rowLabel: {
|
|
3025
|
-
gridColumn: '1/3'
|
|
3026
|
-
},
|
|
3027
|
-
rowLabelHolder: {
|
|
3028
|
-
paddingTop: theme.spacing.unit * 2,
|
|
3029
|
-
width: '100%'
|
|
3030
|
-
}
|
|
3031
|
-
});
|
|
3032
|
-
|
|
3033
|
-
const RowLabel = withStyles(styles$7)(({
|
|
3034
|
-
categoriesPerRow,
|
|
3035
|
-
classes,
|
|
3036
|
-
configuration,
|
|
3037
|
-
disabled,
|
|
3038
|
-
markup,
|
|
3039
|
-
imageSupport,
|
|
3040
|
-
onChange,
|
|
3041
|
-
toolbarOpts,
|
|
3042
|
-
spellCheck,
|
|
3043
|
-
maxImageWidth,
|
|
3044
|
-
maxImageHeight,
|
|
3045
|
-
uploadSoundSupport,
|
|
3046
|
-
mathMlOptions: _mathMlOptions = {}
|
|
3047
|
-
}) => {
|
|
3048
|
-
const {
|
|
3049
|
-
rowLabels,
|
|
3050
|
-
baseInputConfiguration
|
|
3051
|
-
} = configuration;
|
|
3052
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
3053
|
-
style: {
|
|
3054
|
-
gridColumn: `1/${categoriesPerRow + 1}`,
|
|
3055
|
-
width: '100%'
|
|
3056
|
-
}
|
|
3057
|
-
}, /*#__PURE__*/React.createElement(InputContainer, {
|
|
3058
|
-
label: "Row Label",
|
|
3059
|
-
className: classes.rowLabelHolder
|
|
3060
|
-
}, /*#__PURE__*/React.createElement(EditableHtml, {
|
|
3061
|
-
disabled: disabled,
|
|
3062
|
-
markup: markup,
|
|
3063
|
-
onChange: onChange,
|
|
3064
|
-
imageSupport: imageSupport,
|
|
3065
|
-
nonEmpty: false,
|
|
3066
|
-
toolbarOpts: toolbarOpts,
|
|
3067
|
-
pluginProps: getPluginProps(rowLabels == null ? void 0 : rowLabels.inputConfiguration, baseInputConfiguration),
|
|
3068
|
-
spellCheck: spellCheck,
|
|
3069
|
-
maxImageWidth: maxImageWidth,
|
|
3070
|
-
maxImageHeight: maxImageHeight,
|
|
3071
|
-
uploadSoundSupport: uploadSoundSupport,
|
|
3072
|
-
languageCharactersProps: [{
|
|
3073
|
-
language: 'spanish'
|
|
3074
|
-
}, {
|
|
3075
|
-
language: 'special'
|
|
3076
|
-
}],
|
|
3077
|
-
mathMlOptions: _mathMlOptions
|
|
3078
|
-
})));
|
|
3079
|
-
});
|
|
3080
|
-
|
|
3081
|
-
const styles$6 = theme => ({
|
|
3082
|
-
categories: {
|
|
3083
|
-
marginBottom: theme.spacing.unit * 3
|
|
3084
|
-
},
|
|
3085
|
-
categoriesHolder: {
|
|
3086
|
-
display: 'grid',
|
|
3087
|
-
gridRowGap: `${theme.spacing.unit}px`,
|
|
3088
|
-
gridColumnGap: `${theme.spacing.unit}px`
|
|
3089
|
-
},
|
|
3090
|
-
row: {
|
|
3091
|
-
display: 'grid',
|
|
3092
|
-
gridTemplateColumns: 'repeat(2, 1fr)',
|
|
3093
|
-
gridColumnGap: `${theme.spacing.unit}px`,
|
|
3094
|
-
alignItems: 'baseline',
|
|
3095
|
-
width: '100%',
|
|
3096
|
-
marginTop: theme.spacing.unit,
|
|
3097
|
-
marginBottom: 2 * theme.spacing.unit
|
|
3098
|
-
},
|
|
3099
|
-
rowLabel: {
|
|
3100
|
-
gridColumn: '1/3'
|
|
3101
|
-
},
|
|
3102
|
-
rowLabelHolder: {
|
|
3103
|
-
width: '100%'
|
|
3104
|
-
},
|
|
3105
|
-
tooltip: {
|
|
3106
|
-
fontSize: theme.typography.fontSize - 2,
|
|
3107
|
-
whiteSpace: 'pre',
|
|
3108
|
-
maxWidth: '500px'
|
|
3109
|
-
},
|
|
3110
|
-
errorText: {
|
|
3111
|
-
fontSize: theme.typography.fontSize - 2,
|
|
3112
|
-
color: theme.palette.error.main,
|
|
3113
|
-
paddingTop: theme.spacing.unit / 2
|
|
3114
|
-
}
|
|
3115
|
-
});
|
|
3116
|
-
|
|
3117
|
-
class Categories extends React.Component {
|
|
3118
|
-
constructor(...args) {
|
|
3119
|
-
super(...args);
|
|
3120
|
-
this.state = {
|
|
3121
|
-
focusedEl: null
|
|
3122
|
-
};
|
|
3123
|
-
|
|
3124
|
-
this.add = () => {
|
|
3125
|
-
const {
|
|
3126
|
-
model,
|
|
3127
|
-
categories: oldCategories
|
|
3128
|
-
} = this.props;
|
|
3129
|
-
const {
|
|
3130
|
-
categoriesPerRow,
|
|
3131
|
-
correctResponse,
|
|
3132
|
-
allowAlternateEnabled
|
|
3133
|
-
} = model;
|
|
3134
|
-
const id = choiceUtils.firstAvailableIndex(model.categories.map(a => a.id), 1);
|
|
3135
|
-
const data = {
|
|
3136
|
-
id,
|
|
3137
|
-
label: 'Category ' + id
|
|
3138
|
-
};
|
|
3139
|
-
const addRowLabel = model.categories.length % categoriesPerRow === 0;
|
|
3140
|
-
const rowLabels = [...model.rowLabels];
|
|
3141
|
-
|
|
3142
|
-
if (addRowLabel) {
|
|
3143
|
-
rowLabels.push('');
|
|
3144
|
-
}
|
|
3145
|
-
|
|
3146
|
-
this.setState({
|
|
3147
|
-
focusedEl: oldCategories.length
|
|
3148
|
-
}, () => {
|
|
3149
|
-
this.props.onModelChanged({
|
|
3150
|
-
rowLabels,
|
|
3151
|
-
categories: model.categories.concat([data]),
|
|
3152
|
-
correctResponse: allowAlternateEnabled ? [...correctResponse, {
|
|
3153
|
-
category: id,
|
|
3154
|
-
choices: [],
|
|
3155
|
-
alternateResponses: []
|
|
3156
|
-
}] : correctResponse
|
|
3157
|
-
});
|
|
3158
|
-
});
|
|
3159
|
-
};
|
|
3160
|
-
|
|
3161
|
-
this.deleteFocusedEl = () => {
|
|
3162
|
-
this.setState({
|
|
3163
|
-
focusedEl: null
|
|
3164
|
-
});
|
|
3165
|
-
};
|
|
3166
|
-
|
|
3167
|
-
this.delete = category => {
|
|
3168
|
-
const {
|
|
3169
|
-
model,
|
|
3170
|
-
onModelChanged
|
|
3171
|
-
} = this.props;
|
|
3172
|
-
const index = model.categories.findIndex(a => a.id === category.id);
|
|
3173
|
-
|
|
3174
|
-
if (index !== -1) {
|
|
3175
|
-
model.categories.splice(index, 1);
|
|
3176
|
-
model.correctResponse = removeCategory(category.id, model.correctResponse);
|
|
3177
|
-
onModelChanged(model);
|
|
3178
|
-
}
|
|
3179
|
-
};
|
|
3180
|
-
|
|
3181
|
-
this.change = c => {
|
|
3182
|
-
const {
|
|
3183
|
-
categories
|
|
3184
|
-
} = this.props;
|
|
3185
|
-
const index = categories.findIndex(a => a.id === c.id);
|
|
3186
|
-
|
|
3187
|
-
if (index !== -1) {
|
|
3188
|
-
categories.splice(index, 1, c);
|
|
3189
|
-
this.props.onModelChanged({
|
|
3190
|
-
categories
|
|
3191
|
-
});
|
|
3192
|
-
}
|
|
3193
|
-
};
|
|
3194
|
-
|
|
3195
|
-
this.addChoiceToCategory = (addedChoice, categoryId) => {
|
|
3196
|
-
const {
|
|
3197
|
-
model,
|
|
3198
|
-
onModelChanged
|
|
3199
|
-
} = this.props;
|
|
3200
|
-
let {
|
|
3201
|
-
choices = [],
|
|
3202
|
-
correctResponse = [],
|
|
3203
|
-
maxChoicesPerCategory = 0
|
|
3204
|
-
} = model || {};
|
|
3205
|
-
const choice = (choices || []).find(choice => choice.id === addedChoice.id);
|
|
3206
|
-
correctResponse = moveChoiceToCategory(addedChoice.id, undefined, categoryId, 0, model.correctResponse); // if multiplePlacements not allowed, ensure the consistency in the other categories
|
|
3207
|
-
|
|
3208
|
-
if (choice.categoryCount !== 0) {
|
|
3209
|
-
correctResponse = verifyAllowMultiplePlacements(addedChoice, categoryId, correctResponse);
|
|
3210
|
-
}
|
|
3211
|
-
|
|
3212
|
-
const maxCategoryChoices = getMaxCategoryChoices(model); // when maxChoicesPerCategory is set to 0, there is no limit so it should not be updated
|
|
3213
|
-
|
|
3214
|
-
onModelChanged({
|
|
3215
|
-
correctResponse,
|
|
3216
|
-
maxChoicesPerCategory: maxChoicesPerCategory !== 0 && maxChoicesPerCategory < maxCategoryChoices ? maxChoicesPerCategory + 1 : maxChoicesPerCategory
|
|
3217
|
-
});
|
|
3218
|
-
};
|
|
3219
|
-
|
|
3220
|
-
this.deleteChoiceFromCategory = (category, choice, choiceIndex) => {
|
|
3221
|
-
const {
|
|
3222
|
-
model,
|
|
3223
|
-
onModelChanged
|
|
3224
|
-
} = this.props;
|
|
3225
|
-
const correctResponse = removeChoiceFromCategory(choice.id, category.id, choiceIndex, model.correctResponse);
|
|
3226
|
-
onModelChanged({
|
|
3227
|
-
correctResponse
|
|
3228
|
-
});
|
|
3229
|
-
};
|
|
3230
|
-
|
|
3231
|
-
this.moveChoice = (choiceId, from, to, choiceIndex) => {
|
|
3232
|
-
const {
|
|
3233
|
-
model,
|
|
3234
|
-
onModelChanged
|
|
3235
|
-
} = this.props;
|
|
3236
|
-
let {
|
|
3237
|
-
choices,
|
|
3238
|
-
correctResponse = [],
|
|
3239
|
-
maxChoicesPerCategory = 0
|
|
3240
|
-
} = model || {};
|
|
3241
|
-
const choice = (choices || []).find(choice => choice.id === choiceId);
|
|
3242
|
-
|
|
3243
|
-
if (to === from || !choice) {
|
|
3244
|
-
return;
|
|
3245
|
-
}
|
|
3246
|
-
|
|
3247
|
-
if (choice.categoryCount !== 0) {
|
|
3248
|
-
correctResponse = moveChoiceToCategory(choice.id, from, to, choiceIndex, correctResponse);
|
|
3249
|
-
correctResponse = verifyAllowMultiplePlacements(choice, to, correctResponse);
|
|
3250
|
-
} else if (choice.categoryCount === 0) {
|
|
3251
|
-
correctResponse = moveChoiceToCategory(choice.id, undefined, to, 0, correctResponse);
|
|
3252
|
-
}
|
|
3253
|
-
|
|
3254
|
-
const maxCategoryChoices = getMaxCategoryChoices(model); // when maxChoicesPerCategory is set to 0, there is no limit so it should not be updated
|
|
3255
|
-
|
|
3256
|
-
onModelChanged({
|
|
3257
|
-
correctResponse,
|
|
3258
|
-
maxChoicesPerCategory: maxChoicesPerCategory !== 0 && maxChoicesPerCategory < maxCategoryChoices ? maxChoicesPerCategory + 1 : maxChoicesPerCategory
|
|
3259
|
-
});
|
|
3260
|
-
};
|
|
3261
|
-
|
|
3262
|
-
this.changeRowLabel = (val, index) => {
|
|
3263
|
-
const {
|
|
3264
|
-
model
|
|
3265
|
-
} = this.props;
|
|
3266
|
-
const {
|
|
3267
|
-
rowLabels
|
|
3268
|
-
} = model;
|
|
3269
|
-
const newRowLabels = [...rowLabels];
|
|
3270
|
-
|
|
3271
|
-
if (newRowLabels.length < index) {
|
|
3272
|
-
newRowLabels.push(val);
|
|
3273
|
-
} else {
|
|
3274
|
-
newRowLabels[index] = val;
|
|
3275
|
-
}
|
|
3276
|
-
|
|
3277
|
-
this.props.onModelChanged({
|
|
3278
|
-
rowLabels: newRowLabels
|
|
3279
|
-
});
|
|
3280
|
-
};
|
|
3281
|
-
}
|
|
3282
|
-
|
|
3283
|
-
componentDidMount() {
|
|
3284
|
-
try {
|
|
3285
|
-
// eslint-disable-next-line react/no-find-dom-node
|
|
3286
|
-
const domNode = ReactDOM.findDOMNode(this);
|
|
3287
|
-
renderMath(domNode);
|
|
3288
|
-
} catch (e) {
|
|
3289
|
-
// Added try-catch block to handle "Unable to find node on an unmounted component" error from tests, thrown because of the usage of shallow
|
|
3290
|
-
console.error('DOM not mounted');
|
|
3291
|
-
}
|
|
3292
|
-
}
|
|
3293
|
-
|
|
3294
|
-
componentDidUpdate() {
|
|
3295
|
-
try {
|
|
3296
|
-
// eslint-disable-next-line react/no-find-dom-node
|
|
3297
|
-
const domNode = ReactDOM.findDOMNode(this);
|
|
3298
|
-
renderMath(domNode);
|
|
3299
|
-
} catch (e) {
|
|
3300
|
-
// Added try-catch block to handle "Unable to find node on an unmounted component" error from tests, thrown because of the usage of shallow
|
|
3301
|
-
console.error('DOM not mounted');
|
|
3302
|
-
}
|
|
3303
|
-
}
|
|
3304
|
-
|
|
3305
|
-
render() {
|
|
3306
|
-
const {
|
|
3307
|
-
model,
|
|
3308
|
-
classes,
|
|
3309
|
-
className,
|
|
3310
|
-
categories,
|
|
3311
|
-
imageSupport,
|
|
3312
|
-
uploadSoundSupport,
|
|
3313
|
-
toolbarOpts,
|
|
3314
|
-
spellCheck,
|
|
3315
|
-
configuration,
|
|
3316
|
-
defaultImageMaxHeight,
|
|
3317
|
-
defaultImageMaxWidth,
|
|
3318
|
-
mathMlOptions = {}
|
|
3319
|
-
} = this.props;
|
|
3320
|
-
const {
|
|
3321
|
-
categoriesPerRow,
|
|
3322
|
-
rowLabels,
|
|
3323
|
-
errors
|
|
3324
|
-
} = model;
|
|
3325
|
-
const {
|
|
3326
|
-
associationError,
|
|
3327
|
-
categoriesError,
|
|
3328
|
-
categoriesErrors
|
|
3329
|
-
} = errors || {};
|
|
3330
|
-
const {
|
|
3331
|
-
maxCategories,
|
|
3332
|
-
maxImageWidth = {},
|
|
3333
|
-
maxImageHeight = {}
|
|
3334
|
-
} = configuration || {};
|
|
3335
|
-
const holderStyle = {
|
|
3336
|
-
gridTemplateColumns: `repeat(${categoriesPerRow}, 1fr)`
|
|
3337
|
-
};
|
|
3338
|
-
const validationMessage = generateValidationMessage(configuration);
|
|
3339
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
3340
|
-
className: classNames(classes.categories, className)
|
|
3341
|
-
}, /*#__PURE__*/React.createElement(Header$1, {
|
|
3342
|
-
label: "Categories",
|
|
3343
|
-
buttonLabel: "ADD A CATEGORY",
|
|
3344
|
-
onAdd: this.add,
|
|
3345
|
-
info: /*#__PURE__*/React.createElement(Tooltip, {
|
|
3346
|
-
classes: {
|
|
3347
|
-
tooltip: classes.tooltip
|
|
3348
|
-
},
|
|
3349
|
-
disableFocusListener: true,
|
|
3350
|
-
disableTouchListener: true,
|
|
3351
|
-
placement: 'right',
|
|
3352
|
-
title: validationMessage
|
|
3353
|
-
}, /*#__PURE__*/React.createElement(default_1$2, {
|
|
3354
|
-
fontSize: 'small',
|
|
3355
|
-
color: 'primary',
|
|
3356
|
-
style: {
|
|
3357
|
-
marginLeft: '5px'
|
|
3358
|
-
}
|
|
3359
|
-
})),
|
|
3360
|
-
buttonDisabled: maxCategories && categories && maxCategories === categories.length
|
|
3361
|
-
}), /*#__PURE__*/React.createElement("div", {
|
|
3362
|
-
className: classes.categoriesHolder,
|
|
3363
|
-
style: holderStyle
|
|
3364
|
-
}, categories.map((category, index) => {
|
|
3365
|
-
const hasRowLabel = index % categoriesPerRow === 0;
|
|
3366
|
-
const rowIndex = index / categoriesPerRow;
|
|
3367
|
-
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
3368
|
-
key: index
|
|
3369
|
-
}, hasRowLabel && /*#__PURE__*/React.createElement(RowLabel, {
|
|
3370
|
-
categoriesPerRow: categoriesPerRow,
|
|
3371
|
-
disabled: false,
|
|
3372
|
-
rowIndex: rowIndex,
|
|
3373
|
-
markup: rowLabels[rowIndex] || '',
|
|
3374
|
-
onChange: val => this.changeRowLabel(val, rowIndex),
|
|
3375
|
-
imageSupport: imageSupport,
|
|
3376
|
-
toolbarOpts: toolbarOpts,
|
|
3377
|
-
spellCheck: spellCheck,
|
|
3378
|
-
maxImageWidth: maxImageWidth && maxImageWidth.rowLabel || defaultImageMaxWidth,
|
|
3379
|
-
maxImageHeight: maxImageHeight && maxImageHeight.rowLabel || defaultImageMaxHeight,
|
|
3380
|
-
uploadSoundSupport: uploadSoundSupport,
|
|
3381
|
-
mathMlOptions: mathMlOptions,
|
|
3382
|
-
configuration: configuration
|
|
3383
|
-
}), /*#__PURE__*/React.createElement(Category$1, {
|
|
3384
|
-
imageSupport: imageSupport,
|
|
3385
|
-
focusedEl: this.state.focusedEl,
|
|
3386
|
-
deleteFocusedEl: this.deleteFocusedEl,
|
|
3387
|
-
index: index,
|
|
3388
|
-
category: category,
|
|
3389
|
-
error: categoriesErrors && categoriesErrors[category.id],
|
|
3390
|
-
onChange: this.change,
|
|
3391
|
-
onDelete: () => this.delete(category),
|
|
3392
|
-
onAddChoice: this.addChoiceToCategory,
|
|
3393
|
-
onMoveChoice: (choiceId, from, to, choiceIndex) => this.moveChoice(choiceId, from, to, choiceIndex),
|
|
3394
|
-
toolbarOpts: toolbarOpts,
|
|
3395
|
-
spellCheck: spellCheck,
|
|
3396
|
-
onDeleteChoice: (choice, choiceIndex) => this.deleteChoiceFromCategory(category, choice, choiceIndex),
|
|
3397
|
-
maxImageWidth: maxImageWidth && maxImageWidth.categoryLabel || defaultImageMaxWidth,
|
|
3398
|
-
maxImageHeight: maxImageHeight && maxImageHeight.categoryLabel || defaultImageMaxHeight,
|
|
3399
|
-
uploadSoundSupport: uploadSoundSupport,
|
|
3400
|
-
configuration: configuration
|
|
3401
|
-
}));
|
|
3402
|
-
})), associationError && /*#__PURE__*/React.createElement("div", {
|
|
3403
|
-
className: classes.errorText
|
|
3404
|
-
}, associationError), categoriesError && /*#__PURE__*/React.createElement("div", {
|
|
3405
|
-
className: classes.errorText
|
|
3406
|
-
}, categoriesError));
|
|
3407
|
-
}
|
|
3408
|
-
|
|
3409
|
-
}
|
|
3410
|
-
Categories.propTypes = {
|
|
3411
|
-
defaultImageMaxHeight: PropTypes.number,
|
|
3412
|
-
defaultImageMaxWidth: PropTypes.number,
|
|
3413
|
-
imageSupport: PropTypes.shape({
|
|
3414
|
-
add: PropTypes.func.isRequired,
|
|
3415
|
-
delete: PropTypes.func.isRequired
|
|
3416
|
-
}),
|
|
3417
|
-
uploadSoundSupport: PropTypes.shape({
|
|
3418
|
-
add: PropTypes.func.isRequired,
|
|
3419
|
-
delete: PropTypes.func.isRequired
|
|
3420
|
-
}),
|
|
3421
|
-
classes: PropTypes.object.isRequired,
|
|
3422
|
-
className: PropTypes.string,
|
|
3423
|
-
categories: PropTypes.array,
|
|
3424
|
-
onModelChanged: PropTypes.func,
|
|
3425
|
-
model: PropTypes.object.isRequired,
|
|
3426
|
-
configuration: PropTypes.object.isRequired,
|
|
3427
|
-
toolbarOpts: PropTypes.object,
|
|
3428
|
-
spellCheck: PropTypes.bool
|
|
3429
|
-
};
|
|
3430
|
-
var Categories$1 = withStyles(styles$6)(Categories);
|
|
3431
|
-
|
|
3432
|
-
const styles$5 = theme => ({
|
|
3433
|
-
categories: {
|
|
3434
|
-
marginBottom: theme.spacing.unit * 2.5
|
|
3435
|
-
},
|
|
3436
|
-
categoriesHolder: {
|
|
3437
|
-
display: 'grid',
|
|
3438
|
-
gridRowGap: `${theme.spacing.unit}px`,
|
|
3439
|
-
gridColumnGap: `${theme.spacing.unit}px`
|
|
3440
|
-
},
|
|
3441
|
-
row: {
|
|
3442
|
-
display: 'grid',
|
|
3443
|
-
gridTemplateColumns: 'repeat(2, 1fr)',
|
|
3444
|
-
gridColumnGap: `${theme.spacing.unit}px`,
|
|
3445
|
-
alignItems: 'baseline',
|
|
3446
|
-
width: '100%',
|
|
3447
|
-
marginTop: theme.spacing.unit,
|
|
3448
|
-
marginBottom: 2 * theme.spacing.unit
|
|
3449
|
-
},
|
|
3450
|
-
rowLabel: {
|
|
3451
|
-
gridColumn: '1/3'
|
|
3452
|
-
}
|
|
3453
|
-
});
|
|
3454
|
-
|
|
3455
|
-
class AlternateResponses extends React.Component {
|
|
3456
|
-
constructor(...args) {
|
|
3457
|
-
super(...args);
|
|
3458
|
-
|
|
3459
|
-
this.addChoiceToCategory = (addedChoice, categoryId) => {
|
|
3460
|
-
const {
|
|
3461
|
-
altIndex,
|
|
3462
|
-
model: {
|
|
3463
|
-
correctResponse,
|
|
3464
|
-
choices,
|
|
3465
|
-
maxChoicesPerCategory = 0
|
|
3466
|
-
},
|
|
3467
|
-
onModelChanged
|
|
3468
|
-
} = this.props;
|
|
3469
|
-
const choice = choices.find(c => c.id === addedChoice.id);
|
|
3470
|
-
correctResponse.forEach(a => {
|
|
3471
|
-
if (a.category === categoryId) {
|
|
3472
|
-
a.alternateResponses = a.alternateResponses || [];
|
|
3473
|
-
|
|
3474
|
-
if (!a.alternateResponses[altIndex]) {
|
|
3475
|
-
a.alternateResponses[altIndex] = [];
|
|
3476
|
-
}
|
|
3477
|
-
|
|
3478
|
-
a.alternateResponses[altIndex].push(addedChoice.id);
|
|
3479
|
-
|
|
3480
|
-
if (choice.categoryCount && choice.categoryCount !== 0) {
|
|
3481
|
-
a.alternateResponses[altIndex] = a.alternateResponses[altIndex].reduce((acc, currentValue) => {
|
|
3482
|
-
if (currentValue === choice.id) {
|
|
3483
|
-
const foundIndex = acc.findIndex(c => c === choice.id);
|
|
3484
|
-
|
|
3485
|
-
if (foundIndex === -1) {
|
|
3486
|
-
acc.push(currentValue);
|
|
3487
|
-
}
|
|
3488
|
-
} else {
|
|
3489
|
-
acc.push(currentValue);
|
|
3490
|
-
}
|
|
3491
|
-
|
|
3492
|
-
return acc;
|
|
3493
|
-
}, []);
|
|
3494
|
-
}
|
|
3495
|
-
|
|
3496
|
-
return a;
|
|
3497
|
-
} else {
|
|
3498
|
-
if (a.alternateResponses[altIndex] && choice.categoryCount !== 0) {
|
|
3499
|
-
a.alternateResponses[altIndex] = a.alternateResponses[altIndex].filter(c => c !== addedChoice.id);
|
|
3500
|
-
return a;
|
|
3501
|
-
}
|
|
3502
|
-
}
|
|
3503
|
-
|
|
3504
|
-
return a;
|
|
3505
|
-
});
|
|
3506
|
-
const maxCategoryChoices = getMaxCategoryChoices(this.props.model); // when maxChoicesPerCategory is set to 0, there is no limit so it should not be updated
|
|
3507
|
-
|
|
3508
|
-
onModelChanged({
|
|
3509
|
-
correctResponse,
|
|
3510
|
-
maxChoicesPerCategory: maxChoicesPerCategory !== 0 && maxChoicesPerCategory < maxCategoryChoices ? maxChoicesPerCategory + 1 : maxChoicesPerCategory
|
|
3511
|
-
});
|
|
3512
|
-
};
|
|
3513
|
-
|
|
3514
|
-
this.moveChoice = (choiceId, from, to, choiceIndex, alternateIndex) => {
|
|
3515
|
-
const {
|
|
3516
|
-
model,
|
|
3517
|
-
onModelChanged
|
|
3518
|
-
} = this.props;
|
|
3519
|
-
let {
|
|
3520
|
-
choices,
|
|
3521
|
-
correctResponse = [],
|
|
3522
|
-
maxChoicesPerCategory = 0
|
|
3523
|
-
} = model || {};
|
|
3524
|
-
const choice = (choices || []).find(choice => choice.id === choiceId);
|
|
3525
|
-
correctResponse = moveChoiceToAlternate(choiceId, from, to, choiceIndex, correctResponse, alternateIndex, choice == null ? void 0 : choice.categoryCount);
|
|
3526
|
-
const maxCategoryChoices = getMaxCategoryChoices(this.props.model); // when maxChoicesPerCategory is set to 0, there is no limit so it should not be updated
|
|
3527
|
-
|
|
3528
|
-
onModelChanged({
|
|
3529
|
-
correctResponse,
|
|
3530
|
-
maxChoicesPerCategory: maxChoicesPerCategory !== 0 && maxChoicesPerCategory < maxCategoryChoices ? maxChoicesPerCategory + 1 : maxChoicesPerCategory
|
|
3531
|
-
});
|
|
3532
|
-
};
|
|
3533
|
-
|
|
3534
|
-
this.deleteChoiceFromCategory = (category, choice, choiceIndex) => {
|
|
3535
|
-
const {
|
|
3536
|
-
model,
|
|
3537
|
-
altIndex,
|
|
3538
|
-
onModelChanged
|
|
3539
|
-
} = this.props;
|
|
3540
|
-
const correctResponse = removeChoiceFromAlternate(choice.id, category.id, choiceIndex, altIndex, model.correctResponse);
|
|
3541
|
-
onModelChanged({
|
|
3542
|
-
correctResponse
|
|
3543
|
-
});
|
|
3544
|
-
};
|
|
3545
|
-
}
|
|
3546
|
-
|
|
3547
|
-
render() {
|
|
3548
|
-
const {
|
|
3549
|
-
altIndex,
|
|
3550
|
-
model,
|
|
3551
|
-
configuration,
|
|
3552
|
-
classes,
|
|
3553
|
-
className,
|
|
3554
|
-
categories,
|
|
3555
|
-
imageSupport,
|
|
3556
|
-
spellCheck,
|
|
3557
|
-
uploadSoundSupport,
|
|
3558
|
-
mathMlOptions = {}
|
|
3559
|
-
} = this.props;
|
|
3560
|
-
const {
|
|
3561
|
-
categoriesPerRow,
|
|
3562
|
-
errors,
|
|
3563
|
-
rowLabels
|
|
3564
|
-
} = model;
|
|
3565
|
-
const {
|
|
3566
|
-
duplicateAlternate
|
|
3567
|
-
} = errors || {};
|
|
3568
|
-
const holderStyle = {
|
|
3569
|
-
gridTemplateColumns: `repeat(${categoriesPerRow}, 1fr)`
|
|
3570
|
-
};
|
|
3571
|
-
const isDuplicated = duplicateAlternate ? duplicateAlternate.index === altIndex : false;
|
|
3572
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
3573
|
-
className: classNames(classes.categories, className)
|
|
3574
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
3575
|
-
className: classes.categoriesHolder,
|
|
3576
|
-
style: holderStyle
|
|
3577
|
-
}, categories.map((category, index) => {
|
|
3578
|
-
const hasRowLabel = index % categoriesPerRow === 0;
|
|
3579
|
-
const rowIndex = index / categoriesPerRow;
|
|
3580
|
-
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
3581
|
-
key: index
|
|
3582
|
-
}, hasRowLabel && /*#__PURE__*/React.createElement("div", {
|
|
3583
|
-
style: {
|
|
3584
|
-
gridColumn: `1/${categoriesPerRow + 1}`,
|
|
3585
|
-
width: '100%'
|
|
3586
|
-
},
|
|
3587
|
-
className: classes.rowLabel,
|
|
3588
|
-
dangerouslySetInnerHTML: {
|
|
3589
|
-
__html: rowLabels[rowIndex] || ''
|
|
3590
|
-
}
|
|
3591
|
-
}), /*#__PURE__*/React.createElement(Category$1, {
|
|
3592
|
-
key: index,
|
|
3593
|
-
alternateResponseIndex: altIndex,
|
|
3594
|
-
imageSupport: imageSupport,
|
|
3595
|
-
isDuplicated: isDuplicated && duplicateAlternate.category === category.id,
|
|
3596
|
-
category: category,
|
|
3597
|
-
spellCheck: spellCheck,
|
|
3598
|
-
onAddChoice: this.addChoiceToCategory,
|
|
3599
|
-
onDeleteChoice: (choice, choiceIndex) => this.deleteChoiceFromCategory(category, choice, choiceIndex),
|
|
3600
|
-
onMoveChoice: (choiceId, from, to, choiceIndex, alternateIndex) => this.moveChoice(choiceId, from, to, choiceIndex, alternateIndex),
|
|
3601
|
-
uploadSoundSupport: uploadSoundSupport,
|
|
3602
|
-
mathMlOptions: mathMlOptions,
|
|
3603
|
-
configuration: configuration
|
|
3604
|
-
}));
|
|
3605
|
-
})));
|
|
3606
|
-
}
|
|
3607
|
-
|
|
3608
|
-
}
|
|
3609
|
-
AlternateResponses.propTypes = {
|
|
3610
|
-
altIndex: PropTypes.number.isRequired,
|
|
3611
|
-
configuration: PropTypes.object,
|
|
3612
|
-
imageSupport: PropTypes.shape({
|
|
3613
|
-
add: PropTypes.func.isRequired,
|
|
3614
|
-
delete: PropTypes.func.isRequired
|
|
3615
|
-
}),
|
|
3616
|
-
classes: PropTypes.object.isRequired,
|
|
3617
|
-
className: PropTypes.string,
|
|
3618
|
-
categories: PropTypes.array,
|
|
3619
|
-
onModelChanged: PropTypes.func,
|
|
3620
|
-
model: PropTypes.object.isRequired,
|
|
3621
|
-
uploadSoundSupport: PropTypes.shape({
|
|
3622
|
-
add: PropTypes.func.isRequired,
|
|
3623
|
-
delete: PropTypes.func.isRequired
|
|
3624
|
-
}),
|
|
3625
|
-
spellCheck: PropTypes.bool
|
|
3626
|
-
};
|
|
3627
|
-
var AlternateResponses$1 = withStyles(styles$5)(AlternateResponses);
|
|
3628
|
-
|
|
3629
|
-
var DragHandle = {};
|
|
3630
|
-
|
|
3631
|
-
var _interopRequireDefault = interopRequireDefault.exports;
|
|
3632
|
-
|
|
3633
|
-
Object.defineProperty(DragHandle, "__esModule", {
|
|
3634
|
-
value: true
|
|
3635
|
-
});
|
|
3636
|
-
var default_1 = DragHandle.default = void 0;
|
|
3637
|
-
|
|
3638
|
-
var _react = _interopRequireDefault(React);
|
|
3639
|
-
|
|
3640
|
-
var _createSvgIcon = _interopRequireDefault(createSvgIcon$1);
|
|
3641
|
-
|
|
3642
|
-
var _default = (0, _createSvgIcon.default)(_react.default.createElement(_react.default.Fragment, null, _react.default.createElement("defs", null, _react.default.createElement("path", {
|
|
3643
|
-
id: "a",
|
|
3644
|
-
d: "M0 0h24v24H0V0z"
|
|
3645
|
-
})), _react.default.createElement("path", {
|
|
3646
|
-
d: "M20 9H4v2h16V9zM4 15h16v-2H4v2z"
|
|
3647
|
-
})), 'DragHandle');
|
|
3648
|
-
|
|
3649
|
-
default_1 = DragHandle.default = _default;
|
|
3650
|
-
|
|
3651
|
-
const log = debug('@pie-element:categorize:configure:choice');
|
|
3652
|
-
|
|
3653
|
-
const canDrag = props => {
|
|
3654
|
-
if (props.lockChoiceOrder) {
|
|
3655
|
-
return true;
|
|
3656
|
-
}
|
|
3657
|
-
|
|
3658
|
-
const count = props.choice.categoryCount || 0;
|
|
3659
|
-
|
|
3660
|
-
if (count === 0) {
|
|
3661
|
-
return true;
|
|
3662
|
-
} else {
|
|
3663
|
-
return props.correctResponseCount < count;
|
|
3664
|
-
}
|
|
3665
|
-
};
|
|
3666
|
-
|
|
3667
|
-
class Choice extends React.Component {
|
|
3668
|
-
constructor(...args) {
|
|
3669
|
-
super(...args);
|
|
3670
|
-
|
|
3671
|
-
this.changeContent = content => {
|
|
3672
|
-
const {
|
|
3673
|
-
onChange,
|
|
3674
|
-
choice
|
|
3675
|
-
} = this.props;
|
|
3676
|
-
choice.content = content;
|
|
3677
|
-
onChange(choice);
|
|
3678
|
-
};
|
|
3679
|
-
|
|
3680
|
-
this.changeCategoryCount = () => {
|
|
3681
|
-
const {
|
|
3682
|
-
onChange,
|
|
3683
|
-
choice
|
|
3684
|
-
} = this.props;
|
|
3685
|
-
|
|
3686
|
-
if (choice.categoryCount === 1) {
|
|
3687
|
-
choice.categoryCount = 0;
|
|
3688
|
-
} else {
|
|
3689
|
-
choice.categoryCount = 1;
|
|
3690
|
-
}
|
|
3691
|
-
|
|
3692
|
-
onChange(choice);
|
|
3693
|
-
};
|
|
3694
|
-
|
|
3695
|
-
this.isCheckboxShown = allowMultiplePlacements => allowMultiplePlacements === multiplePlacements.perChoice;
|
|
3696
|
-
}
|
|
3697
|
-
|
|
3698
|
-
render() {
|
|
3699
|
-
const {
|
|
3700
|
-
allowMultiplePlacements,
|
|
3701
|
-
classes,
|
|
3702
|
-
className,
|
|
3703
|
-
configuration,
|
|
3704
|
-
choice,
|
|
3705
|
-
deleteFocusedEl,
|
|
3706
|
-
focusedEl,
|
|
3707
|
-
index,
|
|
3708
|
-
onDelete,
|
|
3709
|
-
connectDropTarget,
|
|
3710
|
-
connectDragSource,
|
|
3711
|
-
connectDragPreview,
|
|
3712
|
-
imageSupport,
|
|
3713
|
-
spellCheck,
|
|
3714
|
-
toolbarOpts,
|
|
3715
|
-
error,
|
|
3716
|
-
maxImageWidth,
|
|
3717
|
-
maxImageHeight,
|
|
3718
|
-
uploadSoundSupport
|
|
3719
|
-
} = this.props;
|
|
3720
|
-
const showRemoveAfterPlacing = this.isCheckboxShown(allowMultiplePlacements);
|
|
3721
|
-
const draggable = canDrag(this.props);
|
|
3722
|
-
return /*#__PURE__*/React.createElement(Card, {
|
|
3723
|
-
className: classNames(classes.choice, className)
|
|
3724
|
-
}, /*#__PURE__*/React.createElement(CardActions, {
|
|
3725
|
-
className: classes.actions
|
|
3726
|
-
}, connectDragSource(connectDropTarget( /*#__PURE__*/React.createElement("span", {
|
|
3727
|
-
className: classNames(classes.dragHandle, draggable === false && classes.dragDisabled)
|
|
3728
|
-
}, /*#__PURE__*/React.createElement(default_1, {
|
|
3729
|
-
color: draggable ? 'primary' : 'disabled'
|
|
3730
|
-
}))))), connectDragPreview( /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(InputHeader$1, {
|
|
3731
|
-
imageSupport: imageSupport,
|
|
3732
|
-
focusedEl: focusedEl,
|
|
3733
|
-
deleteFocusedEl: deleteFocusedEl,
|
|
3734
|
-
index: index,
|
|
3735
|
-
label: choice.content,
|
|
3736
|
-
onChange: this.changeContent,
|
|
3737
|
-
onDelete: onDelete,
|
|
3738
|
-
toolbarOpts: toolbarOpts,
|
|
3739
|
-
spellCheck: spellCheck,
|
|
3740
|
-
error: error,
|
|
3741
|
-
maxImageWidth: maxImageWidth,
|
|
3742
|
-
maxImageHeight: maxImageHeight,
|
|
3743
|
-
uploadSoundSupport: uploadSoundSupport,
|
|
3744
|
-
configuration: configuration
|
|
3745
|
-
}), error && /*#__PURE__*/React.createElement("div", {
|
|
3746
|
-
className: classes.errorText
|
|
3747
|
-
}, error))), /*#__PURE__*/React.createElement(CardActions, {
|
|
3748
|
-
className: classes.actions
|
|
3749
|
-
}, /*#__PURE__*/React.createElement(DeleteButton, {
|
|
3750
|
-
label: 'delete',
|
|
3751
|
-
onClick: onDelete
|
|
3752
|
-
}), showRemoveAfterPlacing && /*#__PURE__*/React.createElement(Checkbox, {
|
|
3753
|
-
mini: true,
|
|
3754
|
-
label: 'Remove after placing',
|
|
3755
|
-
checked: choice.categoryCount === 1,
|
|
3756
|
-
onChange: this.changeCategoryCount
|
|
3757
|
-
})));
|
|
3758
|
-
}
|
|
3759
|
-
|
|
3760
|
-
}
|
|
3761
|
-
Choice.propTypes = {
|
|
3762
|
-
allowMultiplePlacements: PropTypes.string,
|
|
3763
|
-
classes: PropTypes.object.isRequired,
|
|
3764
|
-
className: PropTypes.string,
|
|
3765
|
-
configuration: PropTypes.object.isRequired,
|
|
3766
|
-
choice: PropTypes.object.isRequired,
|
|
3767
|
-
connectDropTarget: PropTypes.func,
|
|
3768
|
-
deleteFocusedEl: PropTypes.func,
|
|
3769
|
-
focusedEl: PropTypes.number,
|
|
3770
|
-
index: PropTypes.number,
|
|
3771
|
-
lockChoiceOrder: PropTypes.bool,
|
|
3772
|
-
maxImageHeight: PropTypes.object,
|
|
3773
|
-
maxImageWidth: PropTypes.object,
|
|
3774
|
-
onChange: PropTypes.func.isRequired,
|
|
3775
|
-
onDelete: PropTypes.func.isRequired,
|
|
3776
|
-
connectDragSource: PropTypes.func.isRequired,
|
|
3777
|
-
connectDragPreview: PropTypes.func.isRequired,
|
|
3778
|
-
correctResponseCount: PropTypes.number.isRequired,
|
|
3779
|
-
imageSupport: PropTypes.shape({
|
|
3780
|
-
add: PropTypes.func.isRequired,
|
|
3781
|
-
delete: PropTypes.func.isRequired
|
|
3782
|
-
}),
|
|
3783
|
-
toolbarOpts: PropTypes.object,
|
|
3784
|
-
error: PropTypes.string,
|
|
3785
|
-
uploadSoundSupport: PropTypes.shape({
|
|
3786
|
-
add: PropTypes.func.isRequired,
|
|
3787
|
-
delete: PropTypes.func.isRequired
|
|
3788
|
-
}),
|
|
3789
|
-
spellCheck: PropTypes.bool
|
|
3790
|
-
};
|
|
3791
|
-
Choice.defaultProps = {};
|
|
3792
|
-
|
|
3793
|
-
const styles$4 = theme => ({
|
|
3794
|
-
actions: {
|
|
3795
|
-
padding: 0,
|
|
3796
|
-
justifyContent: 'space-between'
|
|
3797
|
-
},
|
|
3798
|
-
choice: {
|
|
3799
|
-
minWidth: '196px',
|
|
3800
|
-
padding: theme.spacing.unit,
|
|
3801
|
-
overflow: 'visible'
|
|
3802
|
-
},
|
|
3803
|
-
dragHandle: {
|
|
3804
|
-
cursor: 'move'
|
|
3805
|
-
},
|
|
3806
|
-
dragDisabled: {
|
|
3807
|
-
cursor: 'inherit'
|
|
3808
|
-
},
|
|
3809
|
-
errorText: {
|
|
3810
|
-
fontSize: theme.typography.fontSize - 2,
|
|
3811
|
-
color: theme.palette.error.main,
|
|
3812
|
-
paddingBottom: theme.spacing.unit
|
|
3813
|
-
}
|
|
3814
|
-
});
|
|
3815
|
-
|
|
3816
|
-
const StyledChoice = withStyles(styles$4)(Choice);
|
|
3817
|
-
const spec = {
|
|
3818
|
-
canDrag,
|
|
3819
|
-
beginDrag: props => {
|
|
3820
|
-
const out = {
|
|
3821
|
-
id: props.choice.id,
|
|
3822
|
-
index: props.index
|
|
3823
|
-
};
|
|
3824
|
-
log('[beginDrag] out:', out);
|
|
3825
|
-
return out;
|
|
3826
|
-
},
|
|
3827
|
-
endDrag: (props, monitor) => {
|
|
3828
|
-
if (!monitor.didDrop()) {
|
|
3829
|
-
const item = monitor.getItem();
|
|
3830
|
-
|
|
3831
|
-
if (item.categoryId) {
|
|
3832
|
-
log('wasnt droppped - what to do?');
|
|
3833
|
-
props.onRemoveChoice(item);
|
|
3834
|
-
}
|
|
3835
|
-
}
|
|
3836
|
-
}
|
|
3837
|
-
};
|
|
3838
|
-
const specTarget = {
|
|
3839
|
-
drop: (props, monitor) => {
|
|
3840
|
-
log('[drop] props: ', props);
|
|
3841
|
-
const item = monitor.getItem();
|
|
3842
|
-
props.rearrangeChoices(item.index, props.index);
|
|
3843
|
-
},
|
|
3844
|
-
canDrop: (props, monitor) => {
|
|
3845
|
-
const item = monitor.getItem();
|
|
3846
|
-
return props.choice.id !== item.id;
|
|
3847
|
-
}
|
|
3848
|
-
};
|
|
3849
|
-
var Choice$1 = uid.withUid(flow(DragSource(({
|
|
3850
|
-
uid
|
|
3851
|
-
}) => uid, spec, (connect, monitor) => ({
|
|
3852
|
-
connectDragSource: connect.dragSource(),
|
|
3853
|
-
connectDragPreview: connect.dragPreview(),
|
|
3854
|
-
isDragging: monitor.isDragging()
|
|
3855
|
-
})), DropTarget(({
|
|
3856
|
-
uid
|
|
3857
|
-
}) => uid, specTarget, (connect, monitor) => ({
|
|
3858
|
-
connectDropTarget: connect.dropTarget(),
|
|
3859
|
-
isOver: monitor.isOver()
|
|
3860
|
-
})))(StyledChoice));
|
|
3861
|
-
|
|
3862
|
-
class Config extends React.Component {
|
|
3863
|
-
constructor(...args) {
|
|
3864
|
-
super(...args);
|
|
3865
|
-
|
|
3866
|
-
this.changeLabel = ({
|
|
3867
|
-
target
|
|
3868
|
-
}) => {
|
|
3869
|
-
this.props.onModelChanged({
|
|
3870
|
-
choicesLabel: target.value
|
|
3871
|
-
});
|
|
3872
|
-
};
|
|
3873
|
-
}
|
|
3874
|
-
|
|
3875
|
-
render() {
|
|
3876
|
-
const {
|
|
3877
|
-
classes,
|
|
3878
|
-
className,
|
|
3879
|
-
config,
|
|
3880
|
-
spellCheck
|
|
3881
|
-
} = this.props;
|
|
3882
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
3883
|
-
className: classNames(classes.config, className)
|
|
3884
|
-
}, /*#__PURE__*/React.createElement(TextField, {
|
|
3885
|
-
className: classes.label,
|
|
3886
|
-
InputLabelProps: {
|
|
3887
|
-
shrink: true
|
|
3888
|
-
},
|
|
3889
|
-
variant: "outlined",
|
|
3890
|
-
label: "Label",
|
|
3891
|
-
value: config.choicesLabel,
|
|
3892
|
-
onChange: this.changeLabel,
|
|
3893
|
-
spellCheck: spellCheck
|
|
3894
|
-
}));
|
|
3895
|
-
}
|
|
3896
|
-
|
|
3897
|
-
}
|
|
3898
|
-
Config.propTypes = {
|
|
3899
|
-
classes: PropTypes.object.isRequired,
|
|
3900
|
-
className: PropTypes.string,
|
|
3901
|
-
config: PropTypes.object,
|
|
3902
|
-
onModelChanged: PropTypes.func,
|
|
3903
|
-
spellCheck: PropTypes.bool
|
|
3904
|
-
};
|
|
3905
|
-
Config.defaultProps = {};
|
|
3906
|
-
|
|
3907
|
-
const styles$3 = theme => ({
|
|
3908
|
-
config: {
|
|
3909
|
-
paddingTop: theme.spacing.unit,
|
|
3910
|
-
marginBottom: theme.spacing.unit
|
|
3911
|
-
},
|
|
3912
|
-
label: {
|
|
3913
|
-
width: '100%'
|
|
3914
|
-
}
|
|
3915
|
-
});
|
|
3916
|
-
|
|
3917
|
-
var Config$1 = withStyles(styles$3)(Config);
|
|
3918
|
-
|
|
3919
|
-
class Choices extends React.Component {
|
|
3920
|
-
constructor(...args) {
|
|
3921
|
-
super(...args);
|
|
3922
|
-
this.state = {
|
|
3923
|
-
focusedEl: null
|
|
3924
|
-
};
|
|
3925
|
-
|
|
3926
|
-
this.changeChoice = choice => {
|
|
3927
|
-
const {
|
|
3928
|
-
choices,
|
|
3929
|
-
onModelChanged
|
|
3930
|
-
} = this.props;
|
|
3931
|
-
const index = choices.findIndex(h => h.id === choice.id);
|
|
3932
|
-
|
|
3933
|
-
if (index !== -1) {
|
|
3934
|
-
choices.splice(index, 1, choice);
|
|
3935
|
-
onModelChanged({
|
|
3936
|
-
choices
|
|
3937
|
-
});
|
|
3938
|
-
}
|
|
3939
|
-
};
|
|
3940
|
-
|
|
3941
|
-
this.allChoicesHaveCount = count => {
|
|
3942
|
-
const {
|
|
3943
|
-
choices
|
|
3944
|
-
} = this.props;
|
|
3945
|
-
return Array.isArray(choices) && choices.every(c => c.categoryCount === count);
|
|
3946
|
-
};
|
|
3947
|
-
|
|
3948
|
-
this.addChoice = () => {
|
|
3949
|
-
var _model$choices;
|
|
3950
|
-
|
|
3951
|
-
const {
|
|
3952
|
-
onModelChanged,
|
|
3953
|
-
model,
|
|
3954
|
-
choices: oldChoices
|
|
3955
|
-
} = this.props;
|
|
3956
|
-
let {
|
|
3957
|
-
maxAnswerChoices
|
|
3958
|
-
} = model || {};
|
|
3959
|
-
|
|
3960
|
-
if (maxAnswerChoices && ((_model$choices = model.choices) == null ? void 0 : _model$choices.length) >= maxAnswerChoices) {
|
|
3961
|
-
return;
|
|
3962
|
-
}
|
|
3963
|
-
|
|
3964
|
-
const id = choiceUtils.firstAvailableIndex(model.choices.map(a => a.id), 1);
|
|
3965
|
-
const data = {
|
|
3966
|
-
id,
|
|
3967
|
-
content: 'Choice ' + id
|
|
3968
|
-
};
|
|
3969
|
-
this.setState({
|
|
3970
|
-
focusedEl: oldChoices.length
|
|
3971
|
-
}, () => {
|
|
3972
|
-
onModelChanged({
|
|
3973
|
-
choices: model.choices.concat([data])
|
|
3974
|
-
});
|
|
3975
|
-
});
|
|
3976
|
-
};
|
|
3977
|
-
|
|
3978
|
-
this.deleteFocusedEl = () => {
|
|
3979
|
-
this.setState({
|
|
3980
|
-
focusedEl: null
|
|
3981
|
-
});
|
|
3982
|
-
};
|
|
3983
|
-
|
|
3984
|
-
this.deleteChoice = choice => {
|
|
3985
|
-
const {
|
|
3986
|
-
model,
|
|
3987
|
-
onModelChanged
|
|
3988
|
-
} = this.props;
|
|
3989
|
-
const index = model.choices.findIndex(a => a.id === choice.id);
|
|
3990
|
-
|
|
3991
|
-
if (index !== -1) {
|
|
3992
|
-
model.choices.splice(index, 1);
|
|
3993
|
-
model.correctResponse = removeAllChoices(choice.id, model.correctResponse);
|
|
3994
|
-
onModelChanged(model);
|
|
3995
|
-
}
|
|
3996
|
-
};
|
|
3997
|
-
|
|
3998
|
-
this.rearrangeChoices = (indexFrom, indexTo) => {
|
|
3999
|
-
const {
|
|
4000
|
-
model,
|
|
4001
|
-
onModelChanged
|
|
4002
|
-
} = this.props || {};
|
|
4003
|
-
let {
|
|
4004
|
-
choices
|
|
4005
|
-
} = model || [];
|
|
4006
|
-
choices = rearrangeChoices(choices, indexFrom, indexTo);
|
|
4007
|
-
onModelChanged({
|
|
4008
|
-
choices
|
|
4009
|
-
});
|
|
4010
|
-
};
|
|
4011
|
-
}
|
|
4012
|
-
|
|
4013
|
-
render() {
|
|
4014
|
-
const {
|
|
4015
|
-
focusedEl
|
|
4016
|
-
} = this.state;
|
|
4017
|
-
const {
|
|
4018
|
-
classes,
|
|
4019
|
-
className,
|
|
4020
|
-
choices,
|
|
4021
|
-
model,
|
|
4022
|
-
imageSupport,
|
|
4023
|
-
uploadSoundSupport,
|
|
4024
|
-
onModelChanged,
|
|
4025
|
-
spellCheck,
|
|
4026
|
-
toolbarOpts,
|
|
4027
|
-
configuration,
|
|
4028
|
-
defaultImageMaxWidth,
|
|
4029
|
-
defaultImageMaxHeight
|
|
4030
|
-
} = this.props;
|
|
4031
|
-
const {
|
|
4032
|
-
errors,
|
|
4033
|
-
allowMultiplePlacementsEnabled,
|
|
4034
|
-
lockChoiceOrder,
|
|
4035
|
-
maxAnswerChoices
|
|
4036
|
-
} = model;
|
|
4037
|
-
const {
|
|
4038
|
-
choicesError,
|
|
4039
|
-
choicesErrors
|
|
4040
|
-
} = errors || {};
|
|
4041
|
-
const {
|
|
4042
|
-
maxImageWidth = {},
|
|
4043
|
-
maxImageHeight = {}
|
|
4044
|
-
} = configuration || {};
|
|
4045
|
-
const choiceHolderStyle = {
|
|
4046
|
-
gridTemplateColumns: `repeat(${model.categoriesPerRow}, 1fr)`
|
|
4047
|
-
};
|
|
4048
|
-
const addChoiceButtonTooltip = maxAnswerChoices && (choices == null ? void 0 : choices.length) >= maxAnswerChoices ? `Only ${maxAnswerChoices} allowed maximum` : '';
|
|
4049
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
4050
|
-
className: classNames(classes.choices, className)
|
|
4051
|
-
}, /*#__PURE__*/React.createElement(Header$1, {
|
|
4052
|
-
label: "Choices",
|
|
4053
|
-
buttonLabel: "ADD A CHOICE",
|
|
4054
|
-
onAdd: this.addChoice,
|
|
4055
|
-
buttonDisabled: maxAnswerChoices && choices && (choices == null ? void 0 : choices.length) >= maxAnswerChoices,
|
|
4056
|
-
tooltip: addChoiceButtonTooltip
|
|
4057
|
-
}), /*#__PURE__*/React.createElement(Config$1, {
|
|
4058
|
-
config: model,
|
|
4059
|
-
onModelChanged: onModelChanged,
|
|
4060
|
-
spellCheck: spellCheck
|
|
4061
|
-
}), /*#__PURE__*/React.createElement("div", {
|
|
4062
|
-
className: classes.choiceHolder,
|
|
4063
|
-
style: choiceHolderStyle
|
|
4064
|
-
}, choices.map((h, index) => {
|
|
4065
|
-
return /*#__PURE__*/React.createElement(Choice$1, {
|
|
4066
|
-
choice: h,
|
|
4067
|
-
focusedEl: focusedEl,
|
|
4068
|
-
deleteFocusedEl: this.deleteFocusedEl,
|
|
4069
|
-
correctResponseCount: h.correctResponseCount,
|
|
4070
|
-
allowMultiplePlacements: allowMultiplePlacementsEnabled,
|
|
4071
|
-
lockChoiceOrder: lockChoiceOrder,
|
|
4072
|
-
index: index,
|
|
4073
|
-
key: index,
|
|
4074
|
-
imageSupport: imageSupport,
|
|
4075
|
-
onChange: this.changeChoice,
|
|
4076
|
-
onDelete: () => this.deleteChoice(h),
|
|
4077
|
-
rearrangeChoices: (indexFrom, indexTo) => this.rearrangeChoices(indexFrom, indexTo),
|
|
4078
|
-
toolbarOpts: toolbarOpts,
|
|
4079
|
-
spellCheck: spellCheck,
|
|
4080
|
-
error: choicesErrors && choicesErrors[h.id],
|
|
4081
|
-
maxImageWidth: maxImageWidth && maxImageWidth.choice || defaultImageMaxWidth,
|
|
4082
|
-
maxImageHeight: maxImageHeight && maxImageHeight.choice || defaultImageMaxHeight,
|
|
4083
|
-
uploadSoundSupport: uploadSoundSupport,
|
|
4084
|
-
configuration: configuration
|
|
4085
|
-
});
|
|
4086
|
-
})), choicesError && /*#__PURE__*/React.createElement("div", {
|
|
4087
|
-
className: classes.errorText
|
|
4088
|
-
}, choicesError));
|
|
4089
|
-
}
|
|
4090
|
-
|
|
4091
|
-
}
|
|
4092
|
-
Choices.propTypes = {
|
|
4093
|
-
model: PropTypes.object.isRequired,
|
|
4094
|
-
configuration: PropTypes.object.isRequired,
|
|
4095
|
-
classes: PropTypes.object.isRequired,
|
|
4096
|
-
className: PropTypes.string,
|
|
4097
|
-
choices: PropTypes.array.isRequired,
|
|
4098
|
-
defaultImageMaxWidth: PropTypes.number,
|
|
4099
|
-
defaultImageMaxHeight: PropTypes.number,
|
|
4100
|
-
onModelChanged: PropTypes.func.isRequired,
|
|
4101
|
-
imageSupport: PropTypes.shape({
|
|
4102
|
-
add: PropTypes.func.isRequired,
|
|
4103
|
-
delete: PropTypes.func.isRequired
|
|
4104
|
-
}),
|
|
4105
|
-
uploadSoundSupport: PropTypes.shape({
|
|
4106
|
-
add: PropTypes.func.isRequired,
|
|
4107
|
-
delete: PropTypes.func.isRequired
|
|
4108
|
-
}),
|
|
4109
|
-
toolbarOpts: PropTypes.object,
|
|
4110
|
-
spellCheck: PropTypes.bool
|
|
4111
|
-
};
|
|
4112
|
-
Choices.defaultProps = {};
|
|
4113
|
-
|
|
4114
|
-
const styles$2 = theme => ({
|
|
4115
|
-
choiceHolder: {
|
|
4116
|
-
paddingTop: theme.spacing.unit,
|
|
4117
|
-
paddingBottom: theme.spacing.unit,
|
|
4118
|
-
display: 'grid',
|
|
4119
|
-
gridRowGap: `${theme.spacing.unit}px`,
|
|
4120
|
-
gridColumnGap: `${theme.spacing.unit}px`
|
|
4121
|
-
},
|
|
4122
|
-
choices: {
|
|
4123
|
-
marginBottom: theme.spacing.unit * 2.5
|
|
4124
|
-
},
|
|
4125
|
-
errorText: {
|
|
4126
|
-
fontSize: theme.typography.fontSize - 2,
|
|
4127
|
-
color: theme.palette.error.main,
|
|
4128
|
-
paddingTop: theme.spacing.unit / 2
|
|
4129
|
-
}
|
|
4130
|
-
});
|
|
4131
|
-
|
|
4132
|
-
var Choices$1 = withStyles(styles$2)(Choices);
|
|
4133
|
-
|
|
4134
|
-
const buildCategories = (categories, choices, correctResponse) => {
|
|
4135
|
-
const clonedCategories = cloneDeep(categories);
|
|
4136
|
-
return clonedCategories.map(category => {
|
|
4137
|
-
const cr = correctResponse.find(cr => cr.category === category.id);
|
|
4138
|
-
|
|
4139
|
-
if (cr) {
|
|
4140
|
-
category.choices = (cr.choices || []).map(choiceId => {
|
|
4141
|
-
const choice = choices.find(h => h.id === choiceId);
|
|
4142
|
-
|
|
4143
|
-
if (choice) {
|
|
4144
|
-
return Object.assign({}, {
|
|
4145
|
-
id: choice.id,
|
|
4146
|
-
content: choice.content
|
|
4147
|
-
});
|
|
4148
|
-
}
|
|
4149
|
-
});
|
|
4150
|
-
}
|
|
4151
|
-
|
|
4152
|
-
return category;
|
|
4153
|
-
});
|
|
4154
|
-
};
|
|
4155
|
-
|
|
4156
|
-
const getChoices = (cat, choices, index) => {
|
|
4157
|
-
if (!cat.alternateResponses || cat.alternateResponses.length === 0) {
|
|
4158
|
-
return [];
|
|
4159
|
-
}
|
|
4160
|
-
|
|
4161
|
-
return (cat.alternateResponses[index] || []).map(alt => {
|
|
4162
|
-
return choices.find(ch => ch.id === alt);
|
|
4163
|
-
});
|
|
4164
|
-
};
|
|
4165
|
-
|
|
4166
|
-
const buildAlternateResponses = (categories, choices, correctResponse) => {
|
|
4167
|
-
const mostAlternates = correctResponse.reduce((mostAlt, cat) => {
|
|
4168
|
-
if (cat.alternateResponses && cat.alternateResponses.length >= mostAlt) {
|
|
4169
|
-
return cat.alternateResponses.length;
|
|
4170
|
-
}
|
|
4171
|
-
|
|
4172
|
-
return mostAlt;
|
|
4173
|
-
}, 0);
|
|
4174
|
-
const alternatesArray = new Array(mostAlternates).fill(0);
|
|
4175
|
-
return alternatesArray.map((val, index) => {
|
|
4176
|
-
return correctResponse.map((cat, catIndex) => {
|
|
4177
|
-
const currentCategory = categories[catIndex];
|
|
4178
|
-
return {
|
|
4179
|
-
id: currentCategory.id,
|
|
4180
|
-
label: currentCategory.label,
|
|
4181
|
-
choices: getChoices(cat, choices, index)
|
|
4182
|
-
};
|
|
4183
|
-
});
|
|
4184
|
-
});
|
|
4185
|
-
};
|
|
4186
|
-
|
|
4187
|
-
const {
|
|
4188
|
-
translator
|
|
4189
|
-
} = Translator;
|
|
4190
|
-
const {
|
|
4191
|
-
dropdown,
|
|
4192
|
-
Panel,
|
|
4193
|
-
toggle,
|
|
4194
|
-
radio,
|
|
4195
|
-
numberField
|
|
4196
|
-
} = settings;
|
|
4197
|
-
const {
|
|
4198
|
-
Provider: IdProvider
|
|
4199
|
-
} = uid;
|
|
4200
|
-
class Design extends React.Component {
|
|
4201
|
-
constructor(_props) {
|
|
4202
|
-
super(_props);
|
|
4203
|
-
|
|
4204
|
-
this.updateModel = props => {
|
|
4205
|
-
const {
|
|
4206
|
-
model,
|
|
4207
|
-
onChange
|
|
4208
|
-
} = this.props;
|
|
4209
|
-
|
|
4210
|
-
const updatedModel = _extends({}, model, props);
|
|
4211
|
-
|
|
4212
|
-
updatedModel.choices = updatedModel.choices.map(c => _extends({}, c, {
|
|
4213
|
-
categoryCount: this.checkAllowMultiplePlacements(updatedModel.allowMultiplePlacementsEnabled, c)
|
|
4214
|
-
})); //Ensure that there are no extra choices in correctResponse, if the user has decided that only one choice may be used.
|
|
4215
|
-
|
|
4216
|
-
updatedModel.correctResponse = ensureNoExtraChoicesInAnswer(updatedModel.correctResponse || [], updatedModel.choices); //Ensure that there are no extra choices in alternate responses, if the user has decided that only one choice may be used.
|
|
4217
|
-
|
|
4218
|
-
updatedModel.correctResponse = ensureNoExtraChoicesInAlternate(updatedModel.correctResponse || [], updatedModel.choices); //clean categories
|
|
4219
|
-
|
|
4220
|
-
updatedModel.categories = updatedModel.categories.map(c => ({
|
|
4221
|
-
id: c.id,
|
|
4222
|
-
label: c.label
|
|
4223
|
-
}));
|
|
4224
|
-
updatedModel.choices = updatedModel.choices.map(h => ({
|
|
4225
|
-
id: h.id,
|
|
4226
|
-
content: h.content,
|
|
4227
|
-
categoryCount: h.categoryCount
|
|
4228
|
-
})); // ensure that maxChoicesPerCategory is reset if author switch back the corresponding switch (allowMaxChoicesPerCategory)
|
|
4229
|
-
|
|
4230
|
-
updatedModel.maxChoicesPerCategory = updatedModel.allowMaxChoicesPerCategory ? updatedModel.maxChoicesPerCategory : 0;
|
|
4231
|
-
onChange(updatedModel);
|
|
4232
|
-
};
|
|
4233
|
-
|
|
4234
|
-
this.changeRationale = rationale => {
|
|
4235
|
-
const {
|
|
4236
|
-
model,
|
|
4237
|
-
onChange
|
|
4238
|
-
} = this.props;
|
|
4239
|
-
onChange(_extends({}, model, {
|
|
4240
|
-
rationale
|
|
4241
|
-
}));
|
|
4242
|
-
};
|
|
4243
|
-
|
|
4244
|
-
this.changeTeacherInstructions = teacherInstructions => {
|
|
4245
|
-
const {
|
|
4246
|
-
model,
|
|
4247
|
-
onChange
|
|
4248
|
-
} = this.props;
|
|
4249
|
-
onChange(_extends({}, model, {
|
|
4250
|
-
teacherInstructions
|
|
4251
|
-
}));
|
|
4252
|
-
};
|
|
4253
|
-
|
|
4254
|
-
this.changeFeedback = feedback => {
|
|
4255
|
-
this.updateModel({
|
|
4256
|
-
feedback
|
|
4257
|
-
});
|
|
4258
|
-
};
|
|
4259
|
-
|
|
4260
|
-
this.onAddAlternateResponse = () => {
|
|
4261
|
-
const {
|
|
4262
|
-
model: {
|
|
4263
|
-
correctResponse
|
|
4264
|
-
}
|
|
4265
|
-
} = this.props;
|
|
4266
|
-
this.updateModel({
|
|
4267
|
-
correctResponse: (correctResponse || []).map(cr => _extends({}, cr, {
|
|
4268
|
-
alternateResponses: [...(cr.alternateResponses || []), []]
|
|
4269
|
-
}))
|
|
4270
|
-
});
|
|
4271
|
-
};
|
|
4272
|
-
|
|
4273
|
-
this.onPromptChanged = prompt => this.updateModel({
|
|
4274
|
-
prompt
|
|
4275
|
-
});
|
|
4276
|
-
|
|
4277
|
-
this.onRemoveAlternateResponse = index => {
|
|
4278
|
-
const {
|
|
4279
|
-
model: {
|
|
4280
|
-
correctResponse
|
|
4281
|
-
}
|
|
4282
|
-
} = this.props;
|
|
4283
|
-
this.updateModel({
|
|
4284
|
-
correctResponse: (correctResponse || []).map(cr => _extends({}, cr, {
|
|
4285
|
-
alternateResponses: (cr.alternateResponses || []).filter((alt, altIndex) => altIndex !== index)
|
|
4286
|
-
}))
|
|
4287
|
-
});
|
|
4288
|
-
};
|
|
4289
|
-
|
|
4290
|
-
this.countChoiceInCorrectResponse = choice => {
|
|
4291
|
-
const {
|
|
4292
|
-
model
|
|
4293
|
-
} = this.props;
|
|
4294
|
-
return countInAnswer(choice.id, model.correctResponse);
|
|
4295
|
-
};
|
|
4296
|
-
|
|
4297
|
-
this.checkAllowMultiplePlacements = (allowMultiplePlacements, c) => {
|
|
4298
|
-
if (allowMultiplePlacements === multiplePlacements.enabled) {
|
|
4299
|
-
return 0;
|
|
4300
|
-
}
|
|
4301
|
-
|
|
4302
|
-
if (allowMultiplePlacements === multiplePlacements.disabled) {
|
|
4303
|
-
return 1;
|
|
4304
|
-
}
|
|
4305
|
-
|
|
4306
|
-
return c.categoryCount || 0;
|
|
4307
|
-
};
|
|
4308
|
-
|
|
4309
|
-
this.isAlertModalOpened = () => {
|
|
4310
|
-
const {
|
|
4311
|
-
model
|
|
4312
|
-
} = this.props;
|
|
4313
|
-
const {
|
|
4314
|
-
maxChoicesPerCategory = 0
|
|
4315
|
-
} = model || {};
|
|
4316
|
-
const maxChoices = getMaxCategoryChoices(model); // when maxChoicesPerCategory is set to 0, there is no limit so modal should not be opened
|
|
4317
|
-
|
|
4318
|
-
return maxChoicesPerCategory !== 0 ? maxChoices > maxChoicesPerCategory : false;
|
|
4319
|
-
};
|
|
4320
|
-
|
|
4321
|
-
this.onAlertModalCancel = () => {
|
|
4322
|
-
const {
|
|
4323
|
-
model
|
|
4324
|
-
} = this.props;
|
|
4325
|
-
const maxChoices = getMaxCategoryChoices(model);
|
|
4326
|
-
this.updateModel({
|
|
4327
|
-
maxChoicesPerCategory: maxChoices
|
|
4328
|
-
});
|
|
4329
|
-
};
|
|
4330
|
-
|
|
4331
|
-
this.uid = _props.uid || uid.generateId();
|
|
4332
|
-
}
|
|
4333
|
-
|
|
4334
|
-
render() {
|
|
4335
|
-
const {
|
|
4336
|
-
classes,
|
|
4337
|
-
configuration,
|
|
4338
|
-
imageSupport,
|
|
4339
|
-
model,
|
|
4340
|
-
uploadSoundSupport,
|
|
4341
|
-
onConfigurationChanged
|
|
4342
|
-
} = this.props;
|
|
4343
|
-
const {
|
|
4344
|
-
allowAlternate = {},
|
|
4345
|
-
allowMultiplePlacements = {},
|
|
4346
|
-
baseInputConfiguration = {},
|
|
4347
|
-
categoriesPerRow = {},
|
|
4348
|
-
choicesPosition = {},
|
|
4349
|
-
contentDimensions = {},
|
|
4350
|
-
feedback = {},
|
|
4351
|
-
lockChoiceOrder = {},
|
|
4352
|
-
maxImageHeight = {},
|
|
4353
|
-
maxImageWidth = {},
|
|
4354
|
-
maxPlacements = {},
|
|
4355
|
-
minCategoriesPerRow = 1,
|
|
4356
|
-
partialScoring = {},
|
|
4357
|
-
prompt = {},
|
|
4358
|
-
rationale = {},
|
|
4359
|
-
scoringType = {},
|
|
4360
|
-
settingsPanelDisabled,
|
|
4361
|
-
spellCheck = {},
|
|
4362
|
-
studentInstructions = {},
|
|
4363
|
-
teacherInstructions = {},
|
|
4364
|
-
withRubric = {},
|
|
4365
|
-
mathMlOptions = {},
|
|
4366
|
-
language = {},
|
|
4367
|
-
languageChoices = {},
|
|
4368
|
-
allowMaxAnswerChoices = {}
|
|
4369
|
-
} = configuration || {};
|
|
4370
|
-
const {
|
|
4371
|
-
allowAlternateEnabled,
|
|
4372
|
-
allowMaxChoicesPerCategory,
|
|
4373
|
-
errors,
|
|
4374
|
-
feedbackEnabled,
|
|
4375
|
-
maxChoicesPerCategory,
|
|
4376
|
-
promptEnabled,
|
|
4377
|
-
rationaleEnabled,
|
|
4378
|
-
spellCheckEnabled,
|
|
4379
|
-
teacherInstructionsEnabled,
|
|
4380
|
-
toolbarEditorPosition,
|
|
4381
|
-
extraCSSRules
|
|
4382
|
-
} = model || {};
|
|
4383
|
-
const {
|
|
4384
|
-
prompt: promptError,
|
|
4385
|
-
rationale: rationaleError,
|
|
4386
|
-
teacherInstructions: teacherInstructionsError
|
|
4387
|
-
} = errors || {};
|
|
4388
|
-
const toolbarOpts = {
|
|
4389
|
-
position: toolbarEditorPosition === 'top' ? 'top' : 'bottom'
|
|
4390
|
-
};
|
|
4391
|
-
const config = model.config || {};
|
|
4392
|
-
config.choices = config.choices || {
|
|
4393
|
-
label: '',
|
|
4394
|
-
columns: 2
|
|
4395
|
-
};
|
|
4396
|
-
const categories = buildCategories(model.categories || [], model.choices || [], model.correctResponse || []);
|
|
4397
|
-
const alternateResponses = buildAlternateResponses(model.categories || [], model.choices || [], model.correctResponse || []);
|
|
4398
|
-
const choices = model.choices.map(c => {
|
|
4399
|
-
c.correctResponseCount = this.countChoiceInCorrectResponse(c); // ensure categoryCount is set even though updatedModel hasn't been called
|
|
4400
|
-
|
|
4401
|
-
c.categoryCount = this.checkAllowMultiplePlacements(model.allowMultiplePlacementsEnabled, c);
|
|
4402
|
-
return c;
|
|
4403
|
-
});
|
|
4404
|
-
const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
|
|
4405
|
-
const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
|
|
4406
|
-
const panelSettings = {
|
|
4407
|
-
partialScoring: partialScoring.settings && toggle(partialScoring.label),
|
|
4408
|
-
lockChoiceOrder: lockChoiceOrder.settings && toggle(lockChoiceOrder.label),
|
|
4409
|
-
categoriesPerRow: categoriesPerRow.settings && numberField(categoriesPerRow.label, {
|
|
4410
|
-
label: categoriesPerRow.label,
|
|
4411
|
-
min: minCategoriesPerRow,
|
|
4412
|
-
max: 6
|
|
4413
|
-
}),
|
|
4414
|
-
choicesPosition: choicesPosition.settings && radio(choicesPosition.label, ['below', 'above', 'left', 'right']),
|
|
4415
|
-
allowMultiplePlacementsEnabled: allowMultiplePlacements.settings && dropdown(allowMultiplePlacements.label, [multiplePlacements.enabled, multiplePlacements.disabled, multiplePlacements.perChoice]),
|
|
4416
|
-
maxAnswerChoices: allowMaxAnswerChoices.settings && numberField(allowMaxAnswerChoices.label, {
|
|
4417
|
-
label: '',
|
|
4418
|
-
min: (choices == null ? void 0 : choices.length) || 0,
|
|
4419
|
-
max: 30
|
|
4420
|
-
}),
|
|
4421
|
-
allowMaxChoicesPerCategory: maxPlacements.settings && toggle(maxPlacements.label),
|
|
4422
|
-
maxChoicesPerCategory: allowMaxChoicesPerCategory === true && numberField(maxPlacements.label, {
|
|
4423
|
-
label: '',
|
|
4424
|
-
min: 0,
|
|
4425
|
-
max: 30
|
|
4426
|
-
}),
|
|
4427
|
-
promptEnabled: prompt.settings && toggle(prompt.label),
|
|
4428
|
-
feedbackEnabled: feedback.settings && toggle(feedback.label),
|
|
4429
|
-
allowAlternateEnabled: allowAlternate.settings && toggle(allowAlternate.label),
|
|
4430
|
-
'language.enabled': language.settings && toggle(language.label, true),
|
|
4431
|
-
language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options)
|
|
4432
|
-
};
|
|
4433
|
-
const panelProperties = {
|
|
4434
|
-
teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
|
|
4435
|
-
studentInstructionsEnabled: studentInstructions.settings && toggle(studentInstructions.label),
|
|
4436
|
-
rationaleEnabled: rationale.settings && toggle(rationale.label),
|
|
4437
|
-
spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
|
|
4438
|
-
scoringType: scoringType.settings && radio(scoringType.label, ['auto', 'rubric']),
|
|
4439
|
-
rubricEnabled: (withRubric == null ? void 0 : withRubric.settings) && toggle(withRubric == null ? void 0 : withRubric.label)
|
|
4440
|
-
};
|
|
4441
|
-
const isOpened = this.isAlertModalOpened();
|
|
4442
|
-
const alertMaxChoicesMsg = translator.t('translation:categorize:maxChoicesPerCategoryRestriction', {
|
|
4443
|
-
lng: model.language,
|
|
4444
|
-
maxChoicesPerCategory
|
|
4445
|
-
});
|
|
4446
|
-
return /*#__PURE__*/React.createElement(IdProvider, {
|
|
4447
|
-
value: this.uid
|
|
4448
|
-
}, /*#__PURE__*/React.createElement(layout.ConfigLayout, {
|
|
4449
|
-
extraCSSRules: extraCSSRules,
|
|
4450
|
-
dimensions: contentDimensions,
|
|
4451
|
-
hideSettings: settingsPanelDisabled,
|
|
4452
|
-
settings: /*#__PURE__*/React.createElement(Panel, {
|
|
4453
|
-
model: model,
|
|
4454
|
-
onChangeModel: this.updateModel,
|
|
4455
|
-
configuration: configuration,
|
|
4456
|
-
onChangeConfiguration: onConfigurationChanged,
|
|
4457
|
-
groups: {
|
|
4458
|
-
Settings: panelSettings,
|
|
4459
|
-
Properties: panelProperties
|
|
4460
|
-
},
|
|
4461
|
-
modal: /*#__PURE__*/React.createElement(AlertDialog, {
|
|
4462
|
-
title: 'Warning',
|
|
4463
|
-
text: alertMaxChoicesMsg,
|
|
4464
|
-
open: isOpened,
|
|
4465
|
-
onClose: this.onAlertModalCancel
|
|
4466
|
-
})
|
|
4467
|
-
})
|
|
4468
|
-
}, teacherInstructionsEnabled && /*#__PURE__*/React.createElement(InputContainer$1, {
|
|
4469
|
-
label: teacherInstructions.label,
|
|
4470
|
-
className: classes.inputContainer
|
|
4471
|
-
}, /*#__PURE__*/React.createElement(EditableHtml, {
|
|
4472
|
-
className: classes.input,
|
|
4473
|
-
markup: model.teacherInstructions || '',
|
|
4474
|
-
onChange: this.changeTeacherInstructions,
|
|
4475
|
-
imageSupport: imageSupport,
|
|
4476
|
-
error: teacherInstructionsError,
|
|
4477
|
-
nonEmpty: false,
|
|
4478
|
-
toolbarOpts: toolbarOpts,
|
|
4479
|
-
pluginProps: getPluginProps(teacherInstructions == null ? void 0 : teacherInstructions.inputConfiguration, baseInputConfiguration),
|
|
4480
|
-
spellCheck: spellCheckEnabled,
|
|
4481
|
-
maxImageWidth: maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth,
|
|
4482
|
-
maxImageHeight: maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight,
|
|
4483
|
-
uploadSoundSupport: uploadSoundSupport,
|
|
4484
|
-
languageCharactersProps: [{
|
|
4485
|
-
language: 'spanish'
|
|
4486
|
-
}, {
|
|
4487
|
-
language: 'special'
|
|
4488
|
-
}],
|
|
4489
|
-
mathMlOptions: mathMlOptions
|
|
4490
|
-
}), teacherInstructionsError && /*#__PURE__*/React.createElement("div", {
|
|
4491
|
-
className: classes.errorText
|
|
4492
|
-
}, teacherInstructionsError)), promptEnabled && /*#__PURE__*/React.createElement(InputContainer$1, {
|
|
4493
|
-
label: prompt.label,
|
|
4494
|
-
className: classes.inputContainer
|
|
4495
|
-
}, /*#__PURE__*/React.createElement(EditableHtml, {
|
|
4496
|
-
className: classes.input,
|
|
4497
|
-
markup: model.prompt || '',
|
|
4498
|
-
onChange: this.onPromptChanged,
|
|
4499
|
-
imageSupport: imageSupport,
|
|
4500
|
-
error: promptError,
|
|
4501
|
-
nonEmpty: false,
|
|
4502
|
-
disableUnderline: true,
|
|
4503
|
-
toolbarOpts: toolbarOpts,
|
|
4504
|
-
pluginProps: getPluginProps(prompt == null ? void 0 : prompt.inputConfiguration, baseInputConfiguration),
|
|
4505
|
-
spellCheck: spellCheckEnabled,
|
|
4506
|
-
maxImageWidth: maxImageWidth && maxImageWidth.prompt,
|
|
4507
|
-
maxImageHeight: maxImageHeight && maxImageHeight.prompt,
|
|
4508
|
-
uploadSoundSupport: uploadSoundSupport,
|
|
4509
|
-
languageCharactersProps: [{
|
|
4510
|
-
language: 'spanish'
|
|
4511
|
-
}, {
|
|
4512
|
-
language: 'special'
|
|
4513
|
-
}],
|
|
4514
|
-
mathMlOptions: mathMlOptions
|
|
4515
|
-
}), promptError && /*#__PURE__*/React.createElement("div", {
|
|
4516
|
-
className: classes.errorText
|
|
4517
|
-
}, promptError)), /*#__PURE__*/React.createElement(Categories$1, {
|
|
4518
|
-
imageSupport: imageSupport,
|
|
4519
|
-
uploadSoundSupport: uploadSoundSupport,
|
|
4520
|
-
model: model,
|
|
4521
|
-
categories: categories || [],
|
|
4522
|
-
onModelChanged: this.updateModel,
|
|
4523
|
-
toolbarOpts: toolbarOpts,
|
|
4524
|
-
spellCheck: spellCheckEnabled,
|
|
4525
|
-
configuration: configuration,
|
|
4526
|
-
defaultImageMaxWidth: defaultImageMaxWidth,
|
|
4527
|
-
defaultImageMaxHeight: defaultImageMaxHeight,
|
|
4528
|
-
mathMlOptions: mathMlOptions
|
|
4529
|
-
}), /*#__PURE__*/React.createElement(Choices$1, {
|
|
4530
|
-
imageSupport: imageSupport,
|
|
4531
|
-
uploadSoundSupport: uploadSoundSupport,
|
|
4532
|
-
choices: choices,
|
|
4533
|
-
model: model,
|
|
4534
|
-
onModelChanged: this.updateModel,
|
|
4535
|
-
toolbarOpts: toolbarOpts,
|
|
4536
|
-
spellCheck: spellCheckEnabled,
|
|
4537
|
-
configuration: configuration,
|
|
4538
|
-
defaultImageMaxWidth: defaultImageMaxWidth,
|
|
4539
|
-
defaultImageMaxHeight: defaultImageMaxHeight
|
|
4540
|
-
}), allowAlternateEnabled && /*#__PURE__*/React.createElement(Header$1, {
|
|
4541
|
-
className: classes.alternatesHeader,
|
|
4542
|
-
label: "Alternate Responses",
|
|
4543
|
-
buttonLabel: "ADD AN ALTERNATE RESPONSE",
|
|
4544
|
-
onAdd: this.onAddAlternateResponse
|
|
4545
|
-
}), allowAlternateEnabled && alternateResponses.map((categoriesList, index) => {
|
|
4546
|
-
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
4547
|
-
key: index
|
|
4548
|
-
}, /*#__PURE__*/React.createElement(Header$1, {
|
|
4549
|
-
className: classes.alternatesHeader,
|
|
4550
|
-
variant: 'subtitle1',
|
|
4551
|
-
label: "Alternate Response",
|
|
4552
|
-
buttonLabel: "REMOVE ALTERNATE RESPONSE",
|
|
4553
|
-
onAdd: () => this.onRemoveAlternateResponse(index)
|
|
4554
|
-
}), /*#__PURE__*/React.createElement(AlternateResponses$1, {
|
|
4555
|
-
altIndex: index,
|
|
4556
|
-
imageSupport: imageSupport,
|
|
4557
|
-
model: model,
|
|
4558
|
-
configuration: configuration,
|
|
4559
|
-
categories: categoriesList,
|
|
4560
|
-
onModelChanged: this.updateModel,
|
|
4561
|
-
uploadSoundSupport: uploadSoundSupport,
|
|
4562
|
-
mathMlOptions: mathMlOptions
|
|
4563
|
-
}));
|
|
4564
|
-
}), rationaleEnabled && /*#__PURE__*/React.createElement(InputContainer$1, {
|
|
4565
|
-
label: rationale.label,
|
|
4566
|
-
className: classes.inputContainer
|
|
4567
|
-
}, /*#__PURE__*/React.createElement(EditableHtml, {
|
|
4568
|
-
className: classes.input,
|
|
4569
|
-
markup: model.rationale || '',
|
|
4570
|
-
onChange: this.changeRationale,
|
|
4571
|
-
imageSupport: imageSupport,
|
|
4572
|
-
error: rationaleError,
|
|
4573
|
-
nonEmpty: false,
|
|
4574
|
-
toolbarOpts: toolbarOpts,
|
|
4575
|
-
pluginProps: getPluginProps(prompt == null ? void 0 : prompt.inputConfiguration, baseInputConfiguration),
|
|
4576
|
-
spellCheck: spellCheckEnabled,
|
|
4577
|
-
maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
|
|
4578
|
-
maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight,
|
|
4579
|
-
uploadSoundSupport: uploadSoundSupport,
|
|
4580
|
-
languageCharactersProps: [{
|
|
4581
|
-
language: 'spanish'
|
|
4582
|
-
}, {
|
|
4583
|
-
language: 'special'
|
|
4584
|
-
}],
|
|
4585
|
-
mathMlOptions: mathMlOptions
|
|
4586
|
-
}), rationaleError && /*#__PURE__*/React.createElement("div", {
|
|
4587
|
-
className: classes.errorText
|
|
4588
|
-
}, rationaleError)), feedbackEnabled && /*#__PURE__*/React.createElement(FeedbackConfig, {
|
|
4589
|
-
feedback: model.feedback,
|
|
4590
|
-
onChange: this.changeFeedback,
|
|
4591
|
-
toolbarOpts: toolbarOpts
|
|
4592
|
-
})));
|
|
4593
|
-
}
|
|
4594
|
-
|
|
4595
|
-
}
|
|
4596
|
-
Design.propTypes = {
|
|
4597
|
-
classes: PropTypes.object.isRequired,
|
|
4598
|
-
configuration: PropTypes.object,
|
|
4599
|
-
className: PropTypes.string,
|
|
4600
|
-
onConfigurationChanged: PropTypes.func,
|
|
4601
|
-
model: PropTypes.object.isRequired,
|
|
4602
|
-
onChange: PropTypes.func.isRequired,
|
|
4603
|
-
uid: PropTypes.string,
|
|
4604
|
-
imageSupport: PropTypes.shape({
|
|
4605
|
-
add: PropTypes.func.isRequired,
|
|
4606
|
-
delete: PropTypes.func.isRequired
|
|
4607
|
-
}),
|
|
4608
|
-
uploadSoundSupport: PropTypes.shape({
|
|
4609
|
-
add: PropTypes.func.isRequired,
|
|
4610
|
-
delete: PropTypes.func.isRequired
|
|
4611
|
-
})
|
|
4612
|
-
};
|
|
4613
|
-
|
|
4614
|
-
const styles$1 = theme => ({
|
|
4615
|
-
alternatesHeader: {
|
|
4616
|
-
marginBottom: theme.spacing.unit * 2
|
|
4617
|
-
},
|
|
4618
|
-
text: {
|
|
4619
|
-
paddingTop: theme.spacing.unit * 2,
|
|
4620
|
-
paddingBottom: theme.spacing.unit * 2
|
|
4621
|
-
},
|
|
4622
|
-
inputContainer: {
|
|
4623
|
-
width: '100%',
|
|
4624
|
-
paddingTop: theme.spacing.unit * 2,
|
|
4625
|
-
marginBottom: theme.spacing.unit * 2
|
|
4626
|
-
},
|
|
4627
|
-
title: {
|
|
4628
|
-
marginBottom: theme.spacing.unit * 4
|
|
4629
|
-
},
|
|
4630
|
-
errorText: {
|
|
4631
|
-
fontSize: theme.typography.fontSize - 2,
|
|
4632
|
-
color: theme.palette.error.main,
|
|
4633
|
-
paddingTop: theme.spacing.unit
|
|
4634
|
-
}
|
|
4635
|
-
});
|
|
4636
|
-
|
|
4637
|
-
var Design$1 = withDragContext(withStyles(styles$1)(Design));
|
|
4638
|
-
|
|
4639
|
-
class Main extends React.Component {
|
|
4640
|
-
render() {
|
|
4641
|
-
const {
|
|
4642
|
-
model,
|
|
4643
|
-
onModelChanged,
|
|
4644
|
-
configuration,
|
|
4645
|
-
onConfigurationChanged,
|
|
4646
|
-
imageSupport,
|
|
4647
|
-
uploadSoundSupport
|
|
4648
|
-
} = this.props;
|
|
4649
|
-
return /*#__PURE__*/React.createElement(Design$1, {
|
|
4650
|
-
imageSupport: imageSupport,
|
|
4651
|
-
uploadSoundSupport: uploadSoundSupport,
|
|
4652
|
-
title: "Design",
|
|
4653
|
-
model: model,
|
|
4654
|
-
configuration: configuration,
|
|
4655
|
-
onChange: onModelChanged,
|
|
4656
|
-
onConfigurationChanged: onConfigurationChanged
|
|
4657
|
-
});
|
|
4658
|
-
}
|
|
4659
|
-
|
|
4660
|
-
}
|
|
4661
|
-
Main.propTypes = {
|
|
4662
|
-
classes: PropTypes.object.isRequired,
|
|
4663
|
-
configuration: PropTypes.object,
|
|
4664
|
-
className: PropTypes.string,
|
|
4665
|
-
onConfigurationChanged: PropTypes.func,
|
|
4666
|
-
model: PropTypes.object.isRequired,
|
|
4667
|
-
onModelChanged: PropTypes.func.isRequired,
|
|
4668
|
-
imageSupport: PropTypes.object,
|
|
4669
|
-
uploadSoundSupport: PropTypes.object
|
|
4670
|
-
};
|
|
4671
|
-
Main.defaultProps = {};
|
|
4672
|
-
|
|
4673
|
-
const styles = () => ({});
|
|
4674
|
-
|
|
4675
|
-
var Main$1 = withStyles(styles)(Main);
|
|
4676
|
-
|
|
4677
|
-
var defaults = {
|
|
4678
|
-
model: {
|
|
4679
|
-
allowAlternateEnabled: true,
|
|
4680
|
-
allowMaxChoicesPerCategory: false,
|
|
4681
|
-
allowMultiplePlacementsEnabled: multiplePlacements.enabled,
|
|
4682
|
-
alternates: [],
|
|
4683
|
-
categories: [],
|
|
4684
|
-
categoriesPerRow: 2,
|
|
4685
|
-
choices: [],
|
|
4686
|
-
choicesLabel: '',
|
|
4687
|
-
choicesPosition: 'below',
|
|
4688
|
-
correctResponse: [],
|
|
4689
|
-
feedbackEnabled: false,
|
|
4690
|
-
lockChoiceOrder: true,
|
|
4691
|
-
maxAnswerChoices: 6,
|
|
4692
|
-
maxChoicesPerCategory: 0,
|
|
4693
|
-
partialScoring: true,
|
|
4694
|
-
promptEnabled: true,
|
|
4695
|
-
rationaleEnabled: true,
|
|
4696
|
-
rowLabels: [''],
|
|
4697
|
-
studentInstructionsEnabled: true,
|
|
4698
|
-
teacherInstructionsEnabled: true,
|
|
4699
|
-
toolbarEditorPosition: 'bottom',
|
|
4700
|
-
minRowHeight: '80px'
|
|
4701
|
-
},
|
|
4702
|
-
configuration: {
|
|
4703
|
-
baseInputConfiguration: {
|
|
4704
|
-
audio: {
|
|
4705
|
-
disabled: false
|
|
4706
|
-
},
|
|
4707
|
-
video: {
|
|
4708
|
-
disabled: false
|
|
4709
|
-
},
|
|
4710
|
-
image: {
|
|
4711
|
-
disabled: false
|
|
4712
|
-
},
|
|
4713
|
-
textAlign: {
|
|
4714
|
-
disabled: true
|
|
4715
|
-
},
|
|
4716
|
-
showParagraphs: {
|
|
4717
|
-
disabled: false
|
|
4718
|
-
},
|
|
4719
|
-
separateParagraphs: {
|
|
4720
|
-
disabled: true
|
|
4721
|
-
}
|
|
4722
|
-
},
|
|
4723
|
-
spellCheck: {
|
|
4724
|
-
label: 'Spellcheck',
|
|
4725
|
-
settings: false,
|
|
4726
|
-
enabled: true
|
|
4727
|
-
},
|
|
4728
|
-
feedback: {
|
|
4729
|
-
settings: true,
|
|
4730
|
-
label: 'Feedback',
|
|
4731
|
-
enabled: true
|
|
4732
|
-
},
|
|
4733
|
-
lockChoiceOrder: {
|
|
4734
|
-
settings: true,
|
|
4735
|
-
label: 'Lock Choice Order'
|
|
4736
|
-
},
|
|
4737
|
-
choicesPosition: {
|
|
4738
|
-
settings: true,
|
|
4739
|
-
label: 'Choices Position'
|
|
4740
|
-
},
|
|
4741
|
-
allowMultiplePlacements: {
|
|
4742
|
-
settings: true,
|
|
4743
|
-
label: 'Allow Multiple Placements'
|
|
4744
|
-
},
|
|
4745
|
-
maxPlacements: {
|
|
4746
|
-
settings: true,
|
|
4747
|
-
label: 'Max choices per category'
|
|
4748
|
-
},
|
|
4749
|
-
allowAlternate: {
|
|
4750
|
-
settings: true,
|
|
4751
|
-
label: 'Allow Alternate Correct Answers'
|
|
4752
|
-
},
|
|
4753
|
-
categoriesPerRow: {
|
|
4754
|
-
settings: true,
|
|
4755
|
-
label: 'Categories per row'
|
|
4756
|
-
},
|
|
4757
|
-
partialScoring: {
|
|
4758
|
-
settings: false,
|
|
4759
|
-
label: 'Allow Partial Scoring'
|
|
4760
|
-
},
|
|
4761
|
-
prompt: {
|
|
4762
|
-
settings: true,
|
|
4763
|
-
label: 'Prompt',
|
|
4764
|
-
required: false,
|
|
4765
|
-
inputConfiguration: {
|
|
4766
|
-
audio: {
|
|
4767
|
-
disabled: false
|
|
4768
|
-
},
|
|
4769
|
-
video: {
|
|
4770
|
-
disabled: false
|
|
4771
|
-
},
|
|
4772
|
-
image: {
|
|
4773
|
-
disabled: false
|
|
4774
|
-
}
|
|
4775
|
-
}
|
|
4776
|
-
},
|
|
4777
|
-
rationale: {
|
|
4778
|
-
settings: true,
|
|
4779
|
-
label: 'Rationale',
|
|
4780
|
-
required: false,
|
|
4781
|
-
inputConfiguration: {
|
|
4782
|
-
audio: {
|
|
4783
|
-
disabled: false
|
|
4784
|
-
},
|
|
4785
|
-
video: {
|
|
4786
|
-
disabled: false
|
|
4787
|
-
},
|
|
4788
|
-
image: {
|
|
4789
|
-
disabled: false
|
|
4790
|
-
}
|
|
4791
|
-
}
|
|
4792
|
-
},
|
|
4793
|
-
scoringType: {
|
|
4794
|
-
settings: false,
|
|
4795
|
-
label: 'Scoring Type'
|
|
4796
|
-
},
|
|
4797
|
-
settingsPanelDisabled: false,
|
|
4798
|
-
studentInstructions: {
|
|
4799
|
-
settings: false,
|
|
4800
|
-
label: 'Student Instructions'
|
|
4801
|
-
},
|
|
4802
|
-
teacherInstructions: {
|
|
4803
|
-
settings: true,
|
|
4804
|
-
label: 'Teacher Instructions',
|
|
4805
|
-
required: false,
|
|
4806
|
-
inputConfiguration: {
|
|
4807
|
-
audio: {
|
|
4808
|
-
disabled: false
|
|
4809
|
-
},
|
|
4810
|
-
video: {
|
|
4811
|
-
disabled: false
|
|
4812
|
-
},
|
|
4813
|
-
image: {
|
|
4814
|
-
disabled: false
|
|
4815
|
-
}
|
|
4816
|
-
}
|
|
4817
|
-
},
|
|
4818
|
-
headers: {
|
|
4819
|
-
inputConfiguration: {
|
|
4820
|
-
audio: {
|
|
4821
|
-
disabled: true
|
|
4822
|
-
},
|
|
4823
|
-
video: {
|
|
4824
|
-
disabled: true
|
|
4825
|
-
},
|
|
4826
|
-
image: {
|
|
4827
|
-
disabled: false
|
|
4828
|
-
}
|
|
4829
|
-
}
|
|
4830
|
-
},
|
|
4831
|
-
rowLabels: {
|
|
4832
|
-
inputConfiguration: {
|
|
4833
|
-
audio: {
|
|
4834
|
-
disabled: false
|
|
4835
|
-
},
|
|
4836
|
-
video: {
|
|
4837
|
-
disabled: false
|
|
4838
|
-
},
|
|
4839
|
-
image: {
|
|
4840
|
-
disabled: false
|
|
4841
|
-
}
|
|
4842
|
-
}
|
|
4843
|
-
},
|
|
4844
|
-
toolbarEditorPosition: {
|
|
4845
|
-
settings: false,
|
|
4846
|
-
label: 'Toolbar Editor Position'
|
|
4847
|
-
},
|
|
4848
|
-
maxImageWidth: {
|
|
4849
|
-
teacherInstructions: 300,
|
|
4850
|
-
prompt: 300,
|
|
4851
|
-
rationale: 300,
|
|
4852
|
-
rowLabel: 200,
|
|
4853
|
-
categoryLabel: 260,
|
|
4854
|
-
choices: 240
|
|
4855
|
-
},
|
|
4856
|
-
maxImageHeight: {
|
|
4857
|
-
teacherInstructions: 300,
|
|
4858
|
-
prompt: 300,
|
|
4859
|
-
rationale: 300,
|
|
4860
|
-
rowLabel: 100,
|
|
4861
|
-
categoryLabel: 100,
|
|
4862
|
-
choices: 150
|
|
4863
|
-
},
|
|
4864
|
-
withRubric: {
|
|
4865
|
-
settings: false,
|
|
4866
|
-
label: 'Add Rubric'
|
|
4867
|
-
},
|
|
4868
|
-
minCategoriesPerRow: 1,
|
|
4869
|
-
allowMaxAnswerChoices: {
|
|
4870
|
-
settings: true,
|
|
4871
|
-
label: 'Max answer choices'
|
|
4872
|
-
},
|
|
4873
|
-
mathMlOptions: {
|
|
4874
|
-
mmlOutput: false,
|
|
4875
|
-
mmlEditing: false
|
|
4876
|
-
},
|
|
4877
|
-
language: {
|
|
4878
|
-
settings: false,
|
|
4879
|
-
label: 'Specify Language',
|
|
4880
|
-
enabled: false
|
|
4881
|
-
},
|
|
4882
|
-
languageChoices: {
|
|
4883
|
-
label: 'Language Choices',
|
|
4884
|
-
options: []
|
|
4885
|
-
}
|
|
4886
|
-
}
|
|
4887
|
-
};
|
|
4888
|
-
|
|
4889
|
-
const _excluded = ["alternateResponses"];
|
|
4890
|
-
class CategorizeConfigure extends HTMLElement {
|
|
4891
|
-
// PD-2960: make sure we don't have alternates in model or possibility to add them (temporary solution)
|
|
4892
|
-
// this function is used in controller, too
|
|
4893
|
-
constructor() {
|
|
4894
|
-
super();
|
|
4895
|
-
this._model = CategorizeConfigure.createDefaultModel();
|
|
4896
|
-
this._configuration = defaults.configuration;
|
|
4897
|
-
}
|
|
4898
|
-
|
|
4899
|
-
set model(m) {
|
|
4900
|
-
this._model = CategorizeConfigure.createDefaultModel(m);
|
|
4901
|
-
|
|
4902
|
-
if (m.choices && m.choices.length >= m.maxAnswerChoices) {
|
|
4903
|
-
this._model.maxAnswerChoices = m.choices.length;
|
|
4904
|
-
console.warn("Max Answer Choices can't be less than choices length!");
|
|
4905
|
-
}
|
|
4906
|
-
|
|
4907
|
-
this.render();
|
|
4908
|
-
}
|
|
4909
|
-
|
|
4910
|
-
set configuration(c) {
|
|
4911
|
-
var _newConfiguration$lan;
|
|
4912
|
-
|
|
4913
|
-
const newConfiguration = _extends({}, defaults.configuration, c);
|
|
4914
|
-
|
|
4915
|
-
this._configuration = newConfiguration; // if language:enabled is true, then the corresponding default item model should include a language value;
|
|
4916
|
-
// if it is false, then the language field should be omitted from the item model.
|
|
4917
|
-
// if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,
|
|
4918
|
-
// then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).
|
|
4919
|
-
|
|
4920
|
-
if (newConfiguration != null && (_newConfiguration$lan = newConfiguration.language) != null && _newConfiguration$lan.enabled) {
|
|
4921
|
-
var _newConfiguration$lan2, _newConfiguration$lan3;
|
|
4922
|
-
|
|
4923
|
-
if (newConfiguration != null && (_newConfiguration$lan2 = newConfiguration.languageChoices) != null && (_newConfiguration$lan3 = _newConfiguration$lan2.options) != null && _newConfiguration$lan3.length) {
|
|
4924
|
-
this._model.language = newConfiguration == null ? void 0 : newConfiguration.languageChoices.options[0].value;
|
|
4925
|
-
}
|
|
4926
|
-
} else if (newConfiguration.language.settings && this._model.language) {
|
|
4927
|
-
this._configuration.language.enabled = true;
|
|
4928
|
-
|
|
4929
|
-
if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {
|
|
4930
|
-
this._configuration.languageChoices.options = [];
|
|
4931
|
-
} // check if the language is already included in the languageChoices.options array
|
|
4932
|
-
// and if not, then add it.
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
if (!this._configuration.languageChoices.options.find(option => option.value === this._model.language)) {
|
|
4936
|
-
this._configuration.languageChoices.options.push({
|
|
4937
|
-
value: this._model.language,
|
|
4938
|
-
label: this._model.language
|
|
4939
|
-
});
|
|
4940
|
-
}
|
|
4941
|
-
} else {
|
|
4942
|
-
delete this._model.language;
|
|
4943
|
-
}
|
|
4944
|
-
|
|
4945
|
-
this.render();
|
|
4946
|
-
}
|
|
4947
|
-
|
|
4948
|
-
onModelChanged(m) {
|
|
4949
|
-
this._model = m;
|
|
4950
|
-
this.render();
|
|
4951
|
-
this.dispatchEvent(new ModelUpdatedEvent(this._model, false));
|
|
4952
|
-
}
|
|
4953
|
-
|
|
4954
|
-
onConfigurationChanged(c) {
|
|
4955
|
-
this._configuration = c;
|
|
4956
|
-
this.render();
|
|
4957
|
-
}
|
|
4958
|
-
|
|
4959
|
-
connectedCallback() {
|
|
4960
|
-
this.render();
|
|
4961
|
-
}
|
|
4962
|
-
/**
|
|
4963
|
-
*
|
|
4964
|
-
* @param {done, progress, file} handler
|
|
4965
|
-
*/
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
insertImage(handler) {
|
|
4969
|
-
this.dispatchEvent(new InsertImageEvent(handler));
|
|
4970
|
-
}
|
|
4971
|
-
|
|
4972
|
-
onDeleteImage(src, done) {
|
|
4973
|
-
this.dispatchEvent(new DeleteImageEvent(src, done));
|
|
4974
|
-
}
|
|
4975
|
-
|
|
4976
|
-
insertSound(handler) {
|
|
4977
|
-
this.dispatchEvent(new InsertSoundEvent(handler));
|
|
4978
|
-
}
|
|
4979
|
-
|
|
4980
|
-
onDeleteSound(src, done) {
|
|
4981
|
-
this.dispatchEvent(new DeleteSoundEvent(src, done));
|
|
4982
|
-
}
|
|
4983
|
-
|
|
4984
|
-
render() {
|
|
4985
|
-
const el = /*#__PURE__*/React.createElement(Main$1, {
|
|
4986
|
-
model: this._model,
|
|
4987
|
-
configuration: this._configuration,
|
|
4988
|
-
onModelChanged: this.onModelChanged.bind(this),
|
|
4989
|
-
onConfigurationChanged: this.onConfigurationChanged.bind(this),
|
|
4990
|
-
imageSupport: {
|
|
4991
|
-
add: this.insertImage.bind(this),
|
|
4992
|
-
delete: this.onDeleteImage.bind(this)
|
|
4993
|
-
},
|
|
4994
|
-
uploadSoundSupport: {
|
|
4995
|
-
add: this.insertSound.bind(this),
|
|
4996
|
-
delete: this.onDeleteSound.bind(this)
|
|
4997
|
-
}
|
|
4998
|
-
});
|
|
4999
|
-
ReactDOM.render(el, this, () => {
|
|
5000
|
-
renderMath(this);
|
|
5001
|
-
});
|
|
5002
|
-
}
|
|
5003
|
-
|
|
5004
|
-
}
|
|
5005
|
-
|
|
5006
|
-
CategorizeConfigure.createDefaultModel = (model = {}) => _extends({}, defaults.model, model);
|
|
5007
|
-
|
|
5008
|
-
CategorizeConfigure.disableAlternateResponses = m => {
|
|
5009
|
-
let {
|
|
5010
|
-
correctResponse
|
|
5011
|
-
} = m || {};
|
|
5012
|
-
correctResponse = correctResponse || [];
|
|
5013
|
-
const mappedCorrectResponse = correctResponse.map(cr => {
|
|
5014
|
-
const response = _objectWithoutPropertiesLoose(cr, _excluded);
|
|
5015
|
-
|
|
5016
|
-
return response;
|
|
5017
|
-
});
|
|
5018
|
-
return _extends({}, m, {
|
|
5019
|
-
correctResponse: mappedCorrectResponse,
|
|
5020
|
-
allowAlternateEnabled: false
|
|
5021
|
-
});
|
|
5022
|
-
};
|
|
5023
|
-
|
|
5024
|
-
export { CategorizeConfigure as default };
|
|
5025
|
-
//# sourceMappingURL=configure.js.map
|