@pie-element/placement-ordering 12.0.2-esm.0 → 12.2.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 +24 -0
- package/configure/CHANGELOG.md +19 -0
- package/configure/package.json +5 -5
- package/controller/CHANGELOG.md +19 -0
- package/controller/package.json +4 -4
- package/lib/tile.js +0 -1
- package/lib/tile.js.map +1 -1
- package/package.json +8 -25
- package/esm/configure.css +0 -847
- package/esm/configure.js +0 -4020
- package/esm/configure.js.map +0 -1
- package/esm/controller.css +0 -847
- package/esm/controller.js +0 -924
- package/esm/controller.js.map +0 -1
- package/esm/element.css +0 -847
- package/esm/element.js +0 -3108
- package/esm/element.js.map +0 -1
package/esm/configure.js
DELETED
|
@@ -1,4020 +0,0 @@
|
|
|
1
|
-
import { InsertImageEvent, DeleteImageEvent, ModelUpdatedEvent, InsertSoundEvent, DeleteSoundEvent } from '@pie-framework/pie-configure-events';
|
|
2
|
-
import { AlertDialog, layout, InputContainer as InputContainer$1, FormSection, FeedbackConfig, settings } from '@pie-lib/config-ui';
|
|
3
|
-
import EditableHtml, { DEFAULT_PLUGINS } from '@pie-lib/editable-html';
|
|
4
|
-
import { withStyles } from '@material-ui/core/styles';
|
|
5
|
-
import { withDragContext } from '@pie-lib/drag';
|
|
6
|
-
import Info from '@material-ui/icons/Info';
|
|
7
|
-
import Tooltip from '@material-ui/core/Tooltip';
|
|
8
|
-
import debug from 'debug';
|
|
9
|
-
import cloneDeep from 'lodash/cloneDeep';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
11
|
-
import React, { createContext, isValidElement, cloneElement, createRef, Component } from 'react';
|
|
12
|
-
import CardActions from '@material-ui/core/CardActions';
|
|
13
|
-
import DragHandle from '@material-ui/icons/DragHandle';
|
|
14
|
-
import classNames from 'classnames';
|
|
15
|
-
import IconButton from '@material-ui/core/IconButton';
|
|
16
|
-
import RemoveCircle from '@material-ui/icons/RemoveCircle';
|
|
17
|
-
import { color, InputContainer } from '@pie-lib/render-ui';
|
|
18
|
-
import { jsx } from 'react/jsx-runtime';
|
|
19
|
-
import isEmpty from 'lodash/isEmpty';
|
|
20
|
-
import uniqueId from 'lodash/uniqueId';
|
|
21
|
-
import shuffle from 'lodash/shuffle';
|
|
22
|
-
import isEqual from 'lodash/isEqual';
|
|
23
|
-
import Button from '@material-ui/core/Button';
|
|
24
|
-
import ReactDOM from 'react-dom';
|
|
25
|
-
import defaults from 'lodash/defaults';
|
|
26
|
-
|
|
27
|
-
function _extends() {
|
|
28
|
-
_extends = Object.assign || function (target) {
|
|
29
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
30
|
-
var source = arguments[i];
|
|
31
|
-
|
|
32
|
-
for (var key in source) {
|
|
33
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
34
|
-
target[key] = source[key];
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return target;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
return _extends.apply(this, arguments);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
46
|
-
|
|
47
|
-
function commonjsRequire (path) {
|
|
48
|
-
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* @license nested-property https://github.com/cosmosio/nested-property
|
|
53
|
-
*
|
|
54
|
-
* The MIT License (MIT)
|
|
55
|
-
*
|
|
56
|
-
* Copyright (c) 2014-2015 Olivier Scherrer <pode.fr@gmail.com>
|
|
57
|
-
*/
|
|
58
|
-
|
|
59
|
-
var nestedProperty = {
|
|
60
|
-
set: setNestedProperty,
|
|
61
|
-
get: getNestedProperty,
|
|
62
|
-
has: hasNestedProperty,
|
|
63
|
-
hasOwn: function (object, property, options) {
|
|
64
|
-
return this.has(object, property, options || {own: true});
|
|
65
|
-
},
|
|
66
|
-
isIn: isInNestedProperty
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Get the property of an object nested in one or more objects
|
|
71
|
-
* given an object such as a.b.c.d = 5, getNestedProperty(a, "b.c.d") will return 5.
|
|
72
|
-
* @param {Object} object the object to get the property from
|
|
73
|
-
* @param {String} property the path to the property as a string
|
|
74
|
-
* @returns the object or the the property value if found
|
|
75
|
-
*/
|
|
76
|
-
function getNestedProperty(object, property) {
|
|
77
|
-
if (object && typeof object == "object") {
|
|
78
|
-
if (typeof property == "string" && property !== "") {
|
|
79
|
-
var split = property.split(".");
|
|
80
|
-
return split.reduce(function (obj, prop) {
|
|
81
|
-
return obj && obj[prop];
|
|
82
|
-
}, object);
|
|
83
|
-
} else if (typeof property == "number") {
|
|
84
|
-
return object[property];
|
|
85
|
-
} else {
|
|
86
|
-
return object;
|
|
87
|
-
}
|
|
88
|
-
} else {
|
|
89
|
-
return object;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Tell if a nested object has a given property (or array a given index)
|
|
95
|
-
* given an object such as a.b.c.d = 5, hasNestedProperty(a, "b.c.d") will return true.
|
|
96
|
-
* It also returns true if the property is in the prototype chain.
|
|
97
|
-
* @param {Object} object the object to get the property from
|
|
98
|
-
* @param {String} property the path to the property as a string
|
|
99
|
-
* @param {Object} options:
|
|
100
|
-
* - own: set to reject properties from the prototype
|
|
101
|
-
* @returns true if has (property in object), false otherwise
|
|
102
|
-
*/
|
|
103
|
-
function hasNestedProperty(object, property, options) {
|
|
104
|
-
options = options || {};
|
|
105
|
-
|
|
106
|
-
if (object && typeof object == "object") {
|
|
107
|
-
if (typeof property == "string" && property !== "") {
|
|
108
|
-
var split = property.split(".");
|
|
109
|
-
return split.reduce(function (obj, prop, idx, array) {
|
|
110
|
-
if (idx == array.length - 1) {
|
|
111
|
-
if (options.own) {
|
|
112
|
-
return !!(obj && obj.hasOwnProperty(prop));
|
|
113
|
-
} else {
|
|
114
|
-
return !!(obj !== null && typeof obj == "object" && prop in obj);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return obj && obj[prop];
|
|
118
|
-
}, object);
|
|
119
|
-
} else if (typeof property == "number") {
|
|
120
|
-
return property in object;
|
|
121
|
-
} else {
|
|
122
|
-
return false;
|
|
123
|
-
}
|
|
124
|
-
} else {
|
|
125
|
-
return false;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Set the property of an object nested in one or more objects
|
|
131
|
-
* If the property doesn't exist, it gets created.
|
|
132
|
-
* @param {Object} object
|
|
133
|
-
* @param {String} property
|
|
134
|
-
* @param value the value to set
|
|
135
|
-
* @returns object if no assignment was made or the value if the assignment was made
|
|
136
|
-
*/
|
|
137
|
-
function setNestedProperty(object, property, value) {
|
|
138
|
-
if (object && typeof object == "object") {
|
|
139
|
-
if (typeof property == "string" && property !== "") {
|
|
140
|
-
var split = property.split(".");
|
|
141
|
-
return split.reduce(function (obj, prop, idx) {
|
|
142
|
-
obj[prop] = obj[prop] || {};
|
|
143
|
-
if (split.length == (idx + 1)) {
|
|
144
|
-
obj[prop] = value;
|
|
145
|
-
}
|
|
146
|
-
return obj[prop];
|
|
147
|
-
}, object);
|
|
148
|
-
} else if (typeof property == "number") {
|
|
149
|
-
object[property] = value;
|
|
150
|
-
return object[property];
|
|
151
|
-
} else {
|
|
152
|
-
return object;
|
|
153
|
-
}
|
|
154
|
-
} else {
|
|
155
|
-
return object;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Tell if an object is on the path to a nested property
|
|
161
|
-
* If the object is on the path, and the path exists, it returns true, and false otherwise.
|
|
162
|
-
* @param {Object} object to get the nested property from
|
|
163
|
-
* @param {String} property name of the nested property
|
|
164
|
-
* @param {Object} objectInPath the object to check
|
|
165
|
-
* @param {Object} options:
|
|
166
|
-
* - validPath: return false if the path is invalid, even if the object is in the path
|
|
167
|
-
* @returns {boolean} true if the object is on the path
|
|
168
|
-
*/
|
|
169
|
-
function isInNestedProperty(object, property, objectInPath, options) {
|
|
170
|
-
options = options || {};
|
|
171
|
-
|
|
172
|
-
if (object && typeof object == "object") {
|
|
173
|
-
if (typeof property == "string" && property !== "") {
|
|
174
|
-
var split = property.split("."),
|
|
175
|
-
isIn = false,
|
|
176
|
-
pathExists;
|
|
177
|
-
|
|
178
|
-
pathExists = !!split.reduce(function (obj, prop) {
|
|
179
|
-
isIn = isIn || obj === objectInPath || (!!obj && obj[prop] === objectInPath);
|
|
180
|
-
return obj && obj[prop];
|
|
181
|
-
}, object);
|
|
182
|
-
|
|
183
|
-
if (options.validPath) {
|
|
184
|
-
return isIn && pathExists;
|
|
185
|
-
} else {
|
|
186
|
-
return isIn;
|
|
187
|
-
}
|
|
188
|
-
} else {
|
|
189
|
-
return false;
|
|
190
|
-
}
|
|
191
|
-
} else {
|
|
192
|
-
return false;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
var pluralize$1 = {exports: {}};
|
|
197
|
-
|
|
198
|
-
/* global define */
|
|
199
|
-
|
|
200
|
-
(function (module, exports) {
|
|
201
|
-
(function (root, pluralize) {
|
|
202
|
-
/* istanbul ignore else */
|
|
203
|
-
if (typeof commonjsRequire === 'function' && 'object' === 'object' && 'object' === 'object') {
|
|
204
|
-
// Node.
|
|
205
|
-
module.exports = pluralize();
|
|
206
|
-
} else {
|
|
207
|
-
// Browser global.
|
|
208
|
-
root.pluralize = pluralize();
|
|
209
|
-
}
|
|
210
|
-
})(commonjsGlobal, function () {
|
|
211
|
-
// Rule storage - pluralize and singularize need to be run sequentially,
|
|
212
|
-
// while other rules can be optimized using an object for instant lookups.
|
|
213
|
-
var pluralRules = [];
|
|
214
|
-
var singularRules = [];
|
|
215
|
-
var uncountables = {};
|
|
216
|
-
var irregularPlurals = {};
|
|
217
|
-
var irregularSingles = {};
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Sanitize a pluralization rule to a usable regular expression.
|
|
221
|
-
*
|
|
222
|
-
* @param {(RegExp|string)} rule
|
|
223
|
-
* @return {RegExp}
|
|
224
|
-
*/
|
|
225
|
-
function sanitizeRule (rule) {
|
|
226
|
-
if (typeof rule === 'string') {
|
|
227
|
-
return new RegExp('^' + rule + '$', 'i');
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
return rule;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Pass in a word token to produce a function that can replicate the case on
|
|
235
|
-
* another word.
|
|
236
|
-
*
|
|
237
|
-
* @param {string} word
|
|
238
|
-
* @param {string} token
|
|
239
|
-
* @return {Function}
|
|
240
|
-
*/
|
|
241
|
-
function restoreCase (word, token) {
|
|
242
|
-
// Tokens are an exact match.
|
|
243
|
-
if (word === token) return token;
|
|
244
|
-
|
|
245
|
-
// Lower cased words. E.g. "hello".
|
|
246
|
-
if (word === word.toLowerCase()) return token.toLowerCase();
|
|
247
|
-
|
|
248
|
-
// Upper cased words. E.g. "WHISKY".
|
|
249
|
-
if (word === word.toUpperCase()) return token.toUpperCase();
|
|
250
|
-
|
|
251
|
-
// Title cased words. E.g. "Title".
|
|
252
|
-
if (word[0] === word[0].toUpperCase()) {
|
|
253
|
-
return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase();
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
// Lower cased words. E.g. "test".
|
|
257
|
-
return token.toLowerCase();
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* Interpolate a regexp string.
|
|
262
|
-
*
|
|
263
|
-
* @param {string} str
|
|
264
|
-
* @param {Array} args
|
|
265
|
-
* @return {string}
|
|
266
|
-
*/
|
|
267
|
-
function interpolate (str, args) {
|
|
268
|
-
return str.replace(/\$(\d{1,2})/g, function (match, index) {
|
|
269
|
-
return args[index] || '';
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Replace a word using a rule.
|
|
275
|
-
*
|
|
276
|
-
* @param {string} word
|
|
277
|
-
* @param {Array} rule
|
|
278
|
-
* @return {string}
|
|
279
|
-
*/
|
|
280
|
-
function replace (word, rule) {
|
|
281
|
-
return word.replace(rule[0], function (match, index) {
|
|
282
|
-
var result = interpolate(rule[1], arguments);
|
|
283
|
-
|
|
284
|
-
if (match === '') {
|
|
285
|
-
return restoreCase(word[index - 1], result);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
return restoreCase(match, result);
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* Sanitize a word by passing in the word and sanitization rules.
|
|
294
|
-
*
|
|
295
|
-
* @param {string} token
|
|
296
|
-
* @param {string} word
|
|
297
|
-
* @param {Array} rules
|
|
298
|
-
* @return {string}
|
|
299
|
-
*/
|
|
300
|
-
function sanitizeWord (token, word, rules) {
|
|
301
|
-
// Empty string or doesn't need fixing.
|
|
302
|
-
if (!token.length || uncountables.hasOwnProperty(token)) {
|
|
303
|
-
return word;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
var len = rules.length;
|
|
307
|
-
|
|
308
|
-
// Iterate over the sanitization rules and use the first one to match.
|
|
309
|
-
while (len--) {
|
|
310
|
-
var rule = rules[len];
|
|
311
|
-
|
|
312
|
-
if (rule[0].test(word)) return replace(word, rule);
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
return word;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* Replace a word with the updated word.
|
|
320
|
-
*
|
|
321
|
-
* @param {Object} replaceMap
|
|
322
|
-
* @param {Object} keepMap
|
|
323
|
-
* @param {Array} rules
|
|
324
|
-
* @return {Function}
|
|
325
|
-
*/
|
|
326
|
-
function replaceWord (replaceMap, keepMap, rules) {
|
|
327
|
-
return function (word) {
|
|
328
|
-
// Get the correct token and case restoration functions.
|
|
329
|
-
var token = word.toLowerCase();
|
|
330
|
-
|
|
331
|
-
// Check against the keep object map.
|
|
332
|
-
if (keepMap.hasOwnProperty(token)) {
|
|
333
|
-
return restoreCase(word, token);
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
// Check against the replacement map for a direct word replacement.
|
|
337
|
-
if (replaceMap.hasOwnProperty(token)) {
|
|
338
|
-
return restoreCase(word, replaceMap[token]);
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
// Run all the rules against the word.
|
|
342
|
-
return sanitizeWord(token, word, rules);
|
|
343
|
-
};
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
/**
|
|
347
|
-
* Check if a word is part of the map.
|
|
348
|
-
*/
|
|
349
|
-
function checkWord (replaceMap, keepMap, rules, bool) {
|
|
350
|
-
return function (word) {
|
|
351
|
-
var token = word.toLowerCase();
|
|
352
|
-
|
|
353
|
-
if (keepMap.hasOwnProperty(token)) return true;
|
|
354
|
-
if (replaceMap.hasOwnProperty(token)) return false;
|
|
355
|
-
|
|
356
|
-
return sanitizeWord(token, token, rules) === token;
|
|
357
|
-
};
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
/**
|
|
361
|
-
* Pluralize or singularize a word based on the passed in count.
|
|
362
|
-
*
|
|
363
|
-
* @param {string} word The word to pluralize
|
|
364
|
-
* @param {number} count How many of the word exist
|
|
365
|
-
* @param {boolean} inclusive Whether to prefix with the number (e.g. 3 ducks)
|
|
366
|
-
* @return {string}
|
|
367
|
-
*/
|
|
368
|
-
function pluralize (word, count, inclusive) {
|
|
369
|
-
var pluralized = count === 1
|
|
370
|
-
? pluralize.singular(word) : pluralize.plural(word);
|
|
371
|
-
|
|
372
|
-
return (inclusive ? count + ' ' : '') + pluralized;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
/**
|
|
376
|
-
* Pluralize a word.
|
|
377
|
-
*
|
|
378
|
-
* @type {Function}
|
|
379
|
-
*/
|
|
380
|
-
pluralize.plural = replaceWord(
|
|
381
|
-
irregularSingles, irregularPlurals, pluralRules
|
|
382
|
-
);
|
|
383
|
-
|
|
384
|
-
/**
|
|
385
|
-
* Check if a word is plural.
|
|
386
|
-
*
|
|
387
|
-
* @type {Function}
|
|
388
|
-
*/
|
|
389
|
-
pluralize.isPlural = checkWord(
|
|
390
|
-
irregularSingles, irregularPlurals, pluralRules
|
|
391
|
-
);
|
|
392
|
-
|
|
393
|
-
/**
|
|
394
|
-
* Singularize a word.
|
|
395
|
-
*
|
|
396
|
-
* @type {Function}
|
|
397
|
-
*/
|
|
398
|
-
pluralize.singular = replaceWord(
|
|
399
|
-
irregularPlurals, irregularSingles, singularRules
|
|
400
|
-
);
|
|
401
|
-
|
|
402
|
-
/**
|
|
403
|
-
* Check if a word is singular.
|
|
404
|
-
*
|
|
405
|
-
* @type {Function}
|
|
406
|
-
*/
|
|
407
|
-
pluralize.isSingular = checkWord(
|
|
408
|
-
irregularPlurals, irregularSingles, singularRules
|
|
409
|
-
);
|
|
410
|
-
|
|
411
|
-
/**
|
|
412
|
-
* Add a pluralization rule to the collection.
|
|
413
|
-
*
|
|
414
|
-
* @param {(string|RegExp)} rule
|
|
415
|
-
* @param {string} replacement
|
|
416
|
-
*/
|
|
417
|
-
pluralize.addPluralRule = function (rule, replacement) {
|
|
418
|
-
pluralRules.push([sanitizeRule(rule), replacement]);
|
|
419
|
-
};
|
|
420
|
-
|
|
421
|
-
/**
|
|
422
|
-
* Add a singularization rule to the collection.
|
|
423
|
-
*
|
|
424
|
-
* @param {(string|RegExp)} rule
|
|
425
|
-
* @param {string} replacement
|
|
426
|
-
*/
|
|
427
|
-
pluralize.addSingularRule = function (rule, replacement) {
|
|
428
|
-
singularRules.push([sanitizeRule(rule), replacement]);
|
|
429
|
-
};
|
|
430
|
-
|
|
431
|
-
/**
|
|
432
|
-
* Add an uncountable word rule.
|
|
433
|
-
*
|
|
434
|
-
* @param {(string|RegExp)} word
|
|
435
|
-
*/
|
|
436
|
-
pluralize.addUncountableRule = function (word) {
|
|
437
|
-
if (typeof word === 'string') {
|
|
438
|
-
uncountables[word.toLowerCase()] = true;
|
|
439
|
-
return;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
// Set singular and plural references for the word.
|
|
443
|
-
pluralize.addPluralRule(word, '$0');
|
|
444
|
-
pluralize.addSingularRule(word, '$0');
|
|
445
|
-
};
|
|
446
|
-
|
|
447
|
-
/**
|
|
448
|
-
* Add an irregular word definition.
|
|
449
|
-
*
|
|
450
|
-
* @param {string} single
|
|
451
|
-
* @param {string} plural
|
|
452
|
-
*/
|
|
453
|
-
pluralize.addIrregularRule = function (single, plural) {
|
|
454
|
-
plural = plural.toLowerCase();
|
|
455
|
-
single = single.toLowerCase();
|
|
456
|
-
|
|
457
|
-
irregularSingles[single] = plural;
|
|
458
|
-
irregularPlurals[plural] = single;
|
|
459
|
-
};
|
|
460
|
-
|
|
461
|
-
/**
|
|
462
|
-
* Irregular rules.
|
|
463
|
-
*/
|
|
464
|
-
[
|
|
465
|
-
// Pronouns.
|
|
466
|
-
['I', 'we'],
|
|
467
|
-
['me', 'us'],
|
|
468
|
-
['he', 'they'],
|
|
469
|
-
['she', 'they'],
|
|
470
|
-
['them', 'them'],
|
|
471
|
-
['myself', 'ourselves'],
|
|
472
|
-
['yourself', 'yourselves'],
|
|
473
|
-
['itself', 'themselves'],
|
|
474
|
-
['herself', 'themselves'],
|
|
475
|
-
['himself', 'themselves'],
|
|
476
|
-
['themself', 'themselves'],
|
|
477
|
-
['is', 'are'],
|
|
478
|
-
['was', 'were'],
|
|
479
|
-
['has', 'have'],
|
|
480
|
-
['this', 'these'],
|
|
481
|
-
['that', 'those'],
|
|
482
|
-
// Words ending in with a consonant and `o`.
|
|
483
|
-
['echo', 'echoes'],
|
|
484
|
-
['dingo', 'dingoes'],
|
|
485
|
-
['volcano', 'volcanoes'],
|
|
486
|
-
['tornado', 'tornadoes'],
|
|
487
|
-
['torpedo', 'torpedoes'],
|
|
488
|
-
// Ends with `us`.
|
|
489
|
-
['genus', 'genera'],
|
|
490
|
-
['viscus', 'viscera'],
|
|
491
|
-
// Ends with `ma`.
|
|
492
|
-
['stigma', 'stigmata'],
|
|
493
|
-
['stoma', 'stomata'],
|
|
494
|
-
['dogma', 'dogmata'],
|
|
495
|
-
['lemma', 'lemmata'],
|
|
496
|
-
['schema', 'schemata'],
|
|
497
|
-
['anathema', 'anathemata'],
|
|
498
|
-
// Other irregular rules.
|
|
499
|
-
['ox', 'oxen'],
|
|
500
|
-
['axe', 'axes'],
|
|
501
|
-
['die', 'dice'],
|
|
502
|
-
['yes', 'yeses'],
|
|
503
|
-
['foot', 'feet'],
|
|
504
|
-
['eave', 'eaves'],
|
|
505
|
-
['goose', 'geese'],
|
|
506
|
-
['tooth', 'teeth'],
|
|
507
|
-
['quiz', 'quizzes'],
|
|
508
|
-
['human', 'humans'],
|
|
509
|
-
['proof', 'proofs'],
|
|
510
|
-
['carve', 'carves'],
|
|
511
|
-
['valve', 'valves'],
|
|
512
|
-
['looey', 'looies'],
|
|
513
|
-
['thief', 'thieves'],
|
|
514
|
-
['groove', 'grooves'],
|
|
515
|
-
['pickaxe', 'pickaxes'],
|
|
516
|
-
['passerby', 'passersby']
|
|
517
|
-
].forEach(function (rule) {
|
|
518
|
-
return pluralize.addIrregularRule(rule[0], rule[1]);
|
|
519
|
-
});
|
|
520
|
-
|
|
521
|
-
/**
|
|
522
|
-
* Pluralization rules.
|
|
523
|
-
*/
|
|
524
|
-
[
|
|
525
|
-
[/s?$/i, 's'],
|
|
526
|
-
[/[^\u0000-\u007F]$/i, '$0'],
|
|
527
|
-
[/([^aeiou]ese)$/i, '$1'],
|
|
528
|
-
[/(ax|test)is$/i, '$1es'],
|
|
529
|
-
[/(alias|[^aou]us|t[lm]as|gas|ris)$/i, '$1es'],
|
|
530
|
-
[/(e[mn]u)s?$/i, '$1s'],
|
|
531
|
-
[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, '$1'],
|
|
532
|
-
[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, '$1i'],
|
|
533
|
-
[/(alumn|alg|vertebr)(?:a|ae)$/i, '$1ae'],
|
|
534
|
-
[/(seraph|cherub)(?:im)?$/i, '$1im'],
|
|
535
|
-
[/(her|at|gr)o$/i, '$1oes'],
|
|
536
|
-
[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i, '$1a'],
|
|
537
|
-
[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i, '$1a'],
|
|
538
|
-
[/sis$/i, 'ses'],
|
|
539
|
-
[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, '$1$2ves'],
|
|
540
|
-
[/([^aeiouy]|qu)y$/i, '$1ies'],
|
|
541
|
-
[/([^ch][ieo][ln])ey$/i, '$1ies'],
|
|
542
|
-
[/(x|ch|ss|sh|zz)$/i, '$1es'],
|
|
543
|
-
[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, '$1ices'],
|
|
544
|
-
[/\b((?:tit)?m|l)(?:ice|ouse)$/i, '$1ice'],
|
|
545
|
-
[/(pe)(?:rson|ople)$/i, '$1ople'],
|
|
546
|
-
[/(child)(?:ren)?$/i, '$1ren'],
|
|
547
|
-
[/eaux$/i, '$0'],
|
|
548
|
-
[/m[ae]n$/i, 'men'],
|
|
549
|
-
['thou', 'you']
|
|
550
|
-
].forEach(function (rule) {
|
|
551
|
-
return pluralize.addPluralRule(rule[0], rule[1]);
|
|
552
|
-
});
|
|
553
|
-
|
|
554
|
-
/**
|
|
555
|
-
* Singularization rules.
|
|
556
|
-
*/
|
|
557
|
-
[
|
|
558
|
-
[/s$/i, ''],
|
|
559
|
-
[/(ss)$/i, '$1'],
|
|
560
|
-
[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i, '$1fe'],
|
|
561
|
-
[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, '$1f'],
|
|
562
|
-
[/ies$/i, 'y'],
|
|
563
|
-
[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i, '$1ie'],
|
|
564
|
-
[/\b(mon|smil)ies$/i, '$1ey'],
|
|
565
|
-
[/\b((?:tit)?m|l)ice$/i, '$1ouse'],
|
|
566
|
-
[/(seraph|cherub)im$/i, '$1'],
|
|
567
|
-
[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i, '$1'],
|
|
568
|
-
[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i, '$1sis'],
|
|
569
|
-
[/(movie|twelve|abuse|e[mn]u)s$/i, '$1'],
|
|
570
|
-
[/(test)(?:is|es)$/i, '$1is'],
|
|
571
|
-
[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, '$1us'],
|
|
572
|
-
[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i, '$1um'],
|
|
573
|
-
[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, '$1on'],
|
|
574
|
-
[/(alumn|alg|vertebr)ae$/i, '$1a'],
|
|
575
|
-
[/(cod|mur|sil|vert|ind)ices$/i, '$1ex'],
|
|
576
|
-
[/(matr|append)ices$/i, '$1ix'],
|
|
577
|
-
[/(pe)(rson|ople)$/i, '$1rson'],
|
|
578
|
-
[/(child)ren$/i, '$1'],
|
|
579
|
-
[/(eau)x?$/i, '$1'],
|
|
580
|
-
[/men$/i, 'man']
|
|
581
|
-
].forEach(function (rule) {
|
|
582
|
-
return pluralize.addSingularRule(rule[0], rule[1]);
|
|
583
|
-
});
|
|
584
|
-
|
|
585
|
-
/**
|
|
586
|
-
* Uncountable rules.
|
|
587
|
-
*/
|
|
588
|
-
[
|
|
589
|
-
// Singular words with no plurals.
|
|
590
|
-
'adulthood',
|
|
591
|
-
'advice',
|
|
592
|
-
'agenda',
|
|
593
|
-
'aid',
|
|
594
|
-
'aircraft',
|
|
595
|
-
'alcohol',
|
|
596
|
-
'ammo',
|
|
597
|
-
'analytics',
|
|
598
|
-
'anime',
|
|
599
|
-
'athletics',
|
|
600
|
-
'audio',
|
|
601
|
-
'bison',
|
|
602
|
-
'blood',
|
|
603
|
-
'bream',
|
|
604
|
-
'buffalo',
|
|
605
|
-
'butter',
|
|
606
|
-
'carp',
|
|
607
|
-
'cash',
|
|
608
|
-
'chassis',
|
|
609
|
-
'chess',
|
|
610
|
-
'clothing',
|
|
611
|
-
'cod',
|
|
612
|
-
'commerce',
|
|
613
|
-
'cooperation',
|
|
614
|
-
'corps',
|
|
615
|
-
'debris',
|
|
616
|
-
'diabetes',
|
|
617
|
-
'digestion',
|
|
618
|
-
'elk',
|
|
619
|
-
'energy',
|
|
620
|
-
'equipment',
|
|
621
|
-
'excretion',
|
|
622
|
-
'expertise',
|
|
623
|
-
'firmware',
|
|
624
|
-
'flounder',
|
|
625
|
-
'fun',
|
|
626
|
-
'gallows',
|
|
627
|
-
'garbage',
|
|
628
|
-
'graffiti',
|
|
629
|
-
'hardware',
|
|
630
|
-
'headquarters',
|
|
631
|
-
'health',
|
|
632
|
-
'herpes',
|
|
633
|
-
'highjinks',
|
|
634
|
-
'homework',
|
|
635
|
-
'housework',
|
|
636
|
-
'information',
|
|
637
|
-
'jeans',
|
|
638
|
-
'justice',
|
|
639
|
-
'kudos',
|
|
640
|
-
'labour',
|
|
641
|
-
'literature',
|
|
642
|
-
'machinery',
|
|
643
|
-
'mackerel',
|
|
644
|
-
'mail',
|
|
645
|
-
'media',
|
|
646
|
-
'mews',
|
|
647
|
-
'moose',
|
|
648
|
-
'music',
|
|
649
|
-
'mud',
|
|
650
|
-
'manga',
|
|
651
|
-
'news',
|
|
652
|
-
'only',
|
|
653
|
-
'personnel',
|
|
654
|
-
'pike',
|
|
655
|
-
'plankton',
|
|
656
|
-
'pliers',
|
|
657
|
-
'police',
|
|
658
|
-
'pollution',
|
|
659
|
-
'premises',
|
|
660
|
-
'rain',
|
|
661
|
-
'research',
|
|
662
|
-
'rice',
|
|
663
|
-
'salmon',
|
|
664
|
-
'scissors',
|
|
665
|
-
'series',
|
|
666
|
-
'sewage',
|
|
667
|
-
'shambles',
|
|
668
|
-
'shrimp',
|
|
669
|
-
'software',
|
|
670
|
-
'species',
|
|
671
|
-
'staff',
|
|
672
|
-
'swine',
|
|
673
|
-
'tennis',
|
|
674
|
-
'traffic',
|
|
675
|
-
'transportation',
|
|
676
|
-
'trout',
|
|
677
|
-
'tuna',
|
|
678
|
-
'wealth',
|
|
679
|
-
'welfare',
|
|
680
|
-
'whiting',
|
|
681
|
-
'wildebeest',
|
|
682
|
-
'wildlife',
|
|
683
|
-
'you',
|
|
684
|
-
/pok[eé]mon$/i,
|
|
685
|
-
// Regexes.
|
|
686
|
-
/[^aeiou]ese$/i, // "chinese", "japanese"
|
|
687
|
-
/deer$/i, // "deer", "reindeer"
|
|
688
|
-
/fish$/i, // "fish", "blowfish", "angelfish"
|
|
689
|
-
/measles$/i,
|
|
690
|
-
/o[iu]s$/i, // "carnivorous"
|
|
691
|
-
/pox$/i, // "chickpox", "smallpox"
|
|
692
|
-
/sheep$/i
|
|
693
|
-
].forEach(pluralize.addUncountableRule);
|
|
694
|
-
|
|
695
|
-
return pluralize;
|
|
696
|
-
});
|
|
697
|
-
}(pluralize$1));
|
|
698
|
-
|
|
699
|
-
var pluralize = pluralize$1.exports;
|
|
700
|
-
|
|
701
|
-
/**
|
|
702
|
-
* Create the React Context
|
|
703
|
-
*/
|
|
704
|
-
|
|
705
|
-
var DndContext = createContext({
|
|
706
|
-
dragDropManager: undefined
|
|
707
|
-
});
|
|
708
|
-
|
|
709
|
-
/**
|
|
710
|
-
* Use invariant() to assert state which your program assumes to be true.
|
|
711
|
-
*
|
|
712
|
-
* Provide sprintf-style format (only %s is supported) and arguments
|
|
713
|
-
* to provide information about what broke and what you were
|
|
714
|
-
* expecting.
|
|
715
|
-
*
|
|
716
|
-
* The invariant message will be stripped in production, but the invariant
|
|
717
|
-
* will remain to ensure logic does not differ in production.
|
|
718
|
-
*/
|
|
719
|
-
function invariant(condition, format) {
|
|
720
|
-
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
721
|
-
args[_key - 2] = arguments[_key];
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
725
|
-
if (format === undefined) {
|
|
726
|
-
throw new Error('invariant requires an error message argument');
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
if (!condition) {
|
|
731
|
-
var error;
|
|
732
|
-
|
|
733
|
-
if (format === undefined) {
|
|
734
|
-
error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
|
|
735
|
-
} else {
|
|
736
|
-
var argIndex = 0;
|
|
737
|
-
error = new Error(format.replace(/%s/g, function () {
|
|
738
|
-
return args[argIndex++];
|
|
739
|
-
}));
|
|
740
|
-
error.name = 'Invariant Violation';
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
error.framesToPop = 1; // we don't care about invariant's own frame
|
|
744
|
-
|
|
745
|
-
throw error;
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
function _classCallCheck$7(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
750
|
-
|
|
751
|
-
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); } }
|
|
752
|
-
|
|
753
|
-
function _createClass$7(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$7(Constructor.prototype, protoProps); if (staticProps) _defineProperties$7(Constructor, staticProps); return Constructor; }
|
|
754
|
-
|
|
755
|
-
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; }
|
|
756
|
-
var isCallingCanDrag = false;
|
|
757
|
-
var isCallingIsDragging = false;
|
|
758
|
-
var DragSourceMonitorImpl = /*#__PURE__*/function () {
|
|
759
|
-
function DragSourceMonitorImpl(manager) {
|
|
760
|
-
_classCallCheck$7(this, DragSourceMonitorImpl);
|
|
761
|
-
|
|
762
|
-
_defineProperty$7(this, "internalMonitor", void 0);
|
|
763
|
-
|
|
764
|
-
_defineProperty$7(this, "sourceId", null);
|
|
765
|
-
|
|
766
|
-
this.internalMonitor = manager.getMonitor();
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
_createClass$7(DragSourceMonitorImpl, [{
|
|
770
|
-
key: "receiveHandlerId",
|
|
771
|
-
value: function receiveHandlerId(sourceId) {
|
|
772
|
-
this.sourceId = sourceId;
|
|
773
|
-
}
|
|
774
|
-
}, {
|
|
775
|
-
key: "getHandlerId",
|
|
776
|
-
value: function getHandlerId() {
|
|
777
|
-
return this.sourceId;
|
|
778
|
-
}
|
|
779
|
-
}, {
|
|
780
|
-
key: "canDrag",
|
|
781
|
-
value: function canDrag() {
|
|
782
|
-
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');
|
|
783
|
-
|
|
784
|
-
try {
|
|
785
|
-
isCallingCanDrag = true;
|
|
786
|
-
return this.internalMonitor.canDragSource(this.sourceId);
|
|
787
|
-
} finally {
|
|
788
|
-
isCallingCanDrag = false;
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
}, {
|
|
792
|
-
key: "isDragging",
|
|
793
|
-
value: function isDragging() {
|
|
794
|
-
if (!this.sourceId) {
|
|
795
|
-
return false;
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
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');
|
|
799
|
-
|
|
800
|
-
try {
|
|
801
|
-
isCallingIsDragging = true;
|
|
802
|
-
return this.internalMonitor.isDraggingSource(this.sourceId);
|
|
803
|
-
} finally {
|
|
804
|
-
isCallingIsDragging = false;
|
|
805
|
-
}
|
|
806
|
-
}
|
|
807
|
-
}, {
|
|
808
|
-
key: "subscribeToStateChange",
|
|
809
|
-
value: function subscribeToStateChange(listener, options) {
|
|
810
|
-
return this.internalMonitor.subscribeToStateChange(listener, options);
|
|
811
|
-
}
|
|
812
|
-
}, {
|
|
813
|
-
key: "isDraggingSource",
|
|
814
|
-
value: function isDraggingSource(sourceId) {
|
|
815
|
-
return this.internalMonitor.isDraggingSource(sourceId);
|
|
816
|
-
}
|
|
817
|
-
}, {
|
|
818
|
-
key: "isOverTarget",
|
|
819
|
-
value: function isOverTarget(targetId, options) {
|
|
820
|
-
return this.internalMonitor.isOverTarget(targetId, options);
|
|
821
|
-
}
|
|
822
|
-
}, {
|
|
823
|
-
key: "getTargetIds",
|
|
824
|
-
value: function getTargetIds() {
|
|
825
|
-
return this.internalMonitor.getTargetIds();
|
|
826
|
-
}
|
|
827
|
-
}, {
|
|
828
|
-
key: "isSourcePublic",
|
|
829
|
-
value: function isSourcePublic() {
|
|
830
|
-
return this.internalMonitor.isSourcePublic();
|
|
831
|
-
}
|
|
832
|
-
}, {
|
|
833
|
-
key: "getSourceId",
|
|
834
|
-
value: function getSourceId() {
|
|
835
|
-
return this.internalMonitor.getSourceId();
|
|
836
|
-
}
|
|
837
|
-
}, {
|
|
838
|
-
key: "subscribeToOffsetChange",
|
|
839
|
-
value: function subscribeToOffsetChange(listener) {
|
|
840
|
-
return this.internalMonitor.subscribeToOffsetChange(listener);
|
|
841
|
-
}
|
|
842
|
-
}, {
|
|
843
|
-
key: "canDragSource",
|
|
844
|
-
value: function canDragSource(sourceId) {
|
|
845
|
-
return this.internalMonitor.canDragSource(sourceId);
|
|
846
|
-
}
|
|
847
|
-
}, {
|
|
848
|
-
key: "canDropOnTarget",
|
|
849
|
-
value: function canDropOnTarget(targetId) {
|
|
850
|
-
return this.internalMonitor.canDropOnTarget(targetId);
|
|
851
|
-
}
|
|
852
|
-
}, {
|
|
853
|
-
key: "getItemType",
|
|
854
|
-
value: function getItemType() {
|
|
855
|
-
return this.internalMonitor.getItemType();
|
|
856
|
-
}
|
|
857
|
-
}, {
|
|
858
|
-
key: "getItem",
|
|
859
|
-
value: function getItem() {
|
|
860
|
-
return this.internalMonitor.getItem();
|
|
861
|
-
}
|
|
862
|
-
}, {
|
|
863
|
-
key: "getDropResult",
|
|
864
|
-
value: function getDropResult() {
|
|
865
|
-
return this.internalMonitor.getDropResult();
|
|
866
|
-
}
|
|
867
|
-
}, {
|
|
868
|
-
key: "didDrop",
|
|
869
|
-
value: function didDrop() {
|
|
870
|
-
return this.internalMonitor.didDrop();
|
|
871
|
-
}
|
|
872
|
-
}, {
|
|
873
|
-
key: "getInitialClientOffset",
|
|
874
|
-
value: function getInitialClientOffset() {
|
|
875
|
-
return this.internalMonitor.getInitialClientOffset();
|
|
876
|
-
}
|
|
877
|
-
}, {
|
|
878
|
-
key: "getInitialSourceClientOffset",
|
|
879
|
-
value: function getInitialSourceClientOffset() {
|
|
880
|
-
return this.internalMonitor.getInitialSourceClientOffset();
|
|
881
|
-
}
|
|
882
|
-
}, {
|
|
883
|
-
key: "getSourceClientOffset",
|
|
884
|
-
value: function getSourceClientOffset() {
|
|
885
|
-
return this.internalMonitor.getSourceClientOffset();
|
|
886
|
-
}
|
|
887
|
-
}, {
|
|
888
|
-
key: "getClientOffset",
|
|
889
|
-
value: function getClientOffset() {
|
|
890
|
-
return this.internalMonitor.getClientOffset();
|
|
891
|
-
}
|
|
892
|
-
}, {
|
|
893
|
-
key: "getDifferenceFromInitialOffset",
|
|
894
|
-
value: function getDifferenceFromInitialOffset() {
|
|
895
|
-
return this.internalMonitor.getDifferenceFromInitialOffset();
|
|
896
|
-
}
|
|
897
|
-
}]);
|
|
898
|
-
|
|
899
|
-
return DragSourceMonitorImpl;
|
|
900
|
-
}();
|
|
901
|
-
|
|
902
|
-
function _classCallCheck$6(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
903
|
-
|
|
904
|
-
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); } }
|
|
905
|
-
|
|
906
|
-
function _createClass$6(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$6(Constructor.prototype, protoProps); if (staticProps) _defineProperties$6(Constructor, staticProps); return Constructor; }
|
|
907
|
-
|
|
908
|
-
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; }
|
|
909
|
-
var isCallingCanDrop = false;
|
|
910
|
-
var DropTargetMonitorImpl = /*#__PURE__*/function () {
|
|
911
|
-
function DropTargetMonitorImpl(manager) {
|
|
912
|
-
_classCallCheck$6(this, DropTargetMonitorImpl);
|
|
913
|
-
|
|
914
|
-
_defineProperty$6(this, "internalMonitor", void 0);
|
|
915
|
-
|
|
916
|
-
_defineProperty$6(this, "targetId", null);
|
|
917
|
-
|
|
918
|
-
this.internalMonitor = manager.getMonitor();
|
|
919
|
-
}
|
|
920
|
-
|
|
921
|
-
_createClass$6(DropTargetMonitorImpl, [{
|
|
922
|
-
key: "receiveHandlerId",
|
|
923
|
-
value: function receiveHandlerId(targetId) {
|
|
924
|
-
this.targetId = targetId;
|
|
925
|
-
}
|
|
926
|
-
}, {
|
|
927
|
-
key: "getHandlerId",
|
|
928
|
-
value: function getHandlerId() {
|
|
929
|
-
return this.targetId;
|
|
930
|
-
}
|
|
931
|
-
}, {
|
|
932
|
-
key: "subscribeToStateChange",
|
|
933
|
-
value: function subscribeToStateChange(listener, options) {
|
|
934
|
-
return this.internalMonitor.subscribeToStateChange(listener, options);
|
|
935
|
-
}
|
|
936
|
-
}, {
|
|
937
|
-
key: "canDrop",
|
|
938
|
-
value: function canDrop() {
|
|
939
|
-
// Cut out early if the target id has not been set. This should prevent errors
|
|
940
|
-
// where the user has an older version of dnd-core like in
|
|
941
|
-
// https://github.com/react-dnd/react-dnd/issues/1310
|
|
942
|
-
if (!this.targetId) {
|
|
943
|
-
return false;
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
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');
|
|
947
|
-
|
|
948
|
-
try {
|
|
949
|
-
isCallingCanDrop = true;
|
|
950
|
-
return this.internalMonitor.canDropOnTarget(this.targetId);
|
|
951
|
-
} finally {
|
|
952
|
-
isCallingCanDrop = false;
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
}, {
|
|
956
|
-
key: "isOver",
|
|
957
|
-
value: function isOver(options) {
|
|
958
|
-
if (!this.targetId) {
|
|
959
|
-
return false;
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
return this.internalMonitor.isOverTarget(this.targetId, options);
|
|
963
|
-
}
|
|
964
|
-
}, {
|
|
965
|
-
key: "getItemType",
|
|
966
|
-
value: function getItemType() {
|
|
967
|
-
return this.internalMonitor.getItemType();
|
|
968
|
-
}
|
|
969
|
-
}, {
|
|
970
|
-
key: "getItem",
|
|
971
|
-
value: function getItem() {
|
|
972
|
-
return this.internalMonitor.getItem();
|
|
973
|
-
}
|
|
974
|
-
}, {
|
|
975
|
-
key: "getDropResult",
|
|
976
|
-
value: function getDropResult() {
|
|
977
|
-
return this.internalMonitor.getDropResult();
|
|
978
|
-
}
|
|
979
|
-
}, {
|
|
980
|
-
key: "didDrop",
|
|
981
|
-
value: function didDrop() {
|
|
982
|
-
return this.internalMonitor.didDrop();
|
|
983
|
-
}
|
|
984
|
-
}, {
|
|
985
|
-
key: "getInitialClientOffset",
|
|
986
|
-
value: function getInitialClientOffset() {
|
|
987
|
-
return this.internalMonitor.getInitialClientOffset();
|
|
988
|
-
}
|
|
989
|
-
}, {
|
|
990
|
-
key: "getInitialSourceClientOffset",
|
|
991
|
-
value: function getInitialSourceClientOffset() {
|
|
992
|
-
return this.internalMonitor.getInitialSourceClientOffset();
|
|
993
|
-
}
|
|
994
|
-
}, {
|
|
995
|
-
key: "getSourceClientOffset",
|
|
996
|
-
value: function getSourceClientOffset() {
|
|
997
|
-
return this.internalMonitor.getSourceClientOffset();
|
|
998
|
-
}
|
|
999
|
-
}, {
|
|
1000
|
-
key: "getClientOffset",
|
|
1001
|
-
value: function getClientOffset() {
|
|
1002
|
-
return this.internalMonitor.getClientOffset();
|
|
1003
|
-
}
|
|
1004
|
-
}, {
|
|
1005
|
-
key: "getDifferenceFromInitialOffset",
|
|
1006
|
-
value: function getDifferenceFromInitialOffset() {
|
|
1007
|
-
return this.internalMonitor.getDifferenceFromInitialOffset();
|
|
1008
|
-
}
|
|
1009
|
-
}]);
|
|
1010
|
-
|
|
1011
|
-
return DropTargetMonitorImpl;
|
|
1012
|
-
}();
|
|
1013
|
-
|
|
1014
|
-
function throwIfCompositeComponentElement(element) {
|
|
1015
|
-
// Custom components can no longer be wrapped directly in React DnD 2.0
|
|
1016
|
-
// so that we don't need to depend on findDOMNode() from react-dom.
|
|
1017
|
-
if (typeof element.type === 'string') {
|
|
1018
|
-
return;
|
|
1019
|
-
}
|
|
1020
|
-
|
|
1021
|
-
var displayName = element.type.displayName || element.type.name || 'the component';
|
|
1022
|
-
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.');
|
|
1023
|
-
}
|
|
1024
|
-
|
|
1025
|
-
function wrapHookToRecognizeElement(hook) {
|
|
1026
|
-
return function () {
|
|
1027
|
-
var elementOrNode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
1028
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
1029
|
-
|
|
1030
|
-
// When passed a node, call the hook straight away.
|
|
1031
|
-
if (!isValidElement(elementOrNode)) {
|
|
1032
|
-
var node = elementOrNode;
|
|
1033
|
-
hook(node, options); // return the node so it can be chained (e.g. when within callback refs
|
|
1034
|
-
// <div ref={node => connectDragSource(connectDropTarget(node))}/>
|
|
1035
|
-
|
|
1036
|
-
return node;
|
|
1037
|
-
} // If passed a ReactElement, clone it and attach this function as a ref.
|
|
1038
|
-
// This helps us achieve a neat API where user doesn't even know that refs
|
|
1039
|
-
// are being used under the hood.
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
var element = elementOrNode;
|
|
1043
|
-
throwIfCompositeComponentElement(element); // When no options are passed, use the hook directly
|
|
1044
|
-
|
|
1045
|
-
var ref = options ? function (node) {
|
|
1046
|
-
return hook(node, options);
|
|
1047
|
-
} : hook;
|
|
1048
|
-
return cloneWithRef(element, ref);
|
|
1049
|
-
};
|
|
1050
|
-
}
|
|
1051
|
-
|
|
1052
|
-
function wrapConnectorHooks(hooks) {
|
|
1053
|
-
var wrappedHooks = {};
|
|
1054
|
-
Object.keys(hooks).forEach(function (key) {
|
|
1055
|
-
var hook = hooks[key]; // ref objects should be passed straight through without wrapping
|
|
1056
|
-
|
|
1057
|
-
if (key.endsWith('Ref')) {
|
|
1058
|
-
wrappedHooks[key] = hooks[key];
|
|
1059
|
-
} else {
|
|
1060
|
-
var wrappedHook = wrapHookToRecognizeElement(hook);
|
|
1061
|
-
|
|
1062
|
-
wrappedHooks[key] = function () {
|
|
1063
|
-
return wrappedHook;
|
|
1064
|
-
};
|
|
1065
|
-
}
|
|
1066
|
-
});
|
|
1067
|
-
return wrappedHooks;
|
|
1068
|
-
}
|
|
1069
|
-
|
|
1070
|
-
function setRef(ref, node) {
|
|
1071
|
-
if (typeof ref === 'function') {
|
|
1072
|
-
ref(node);
|
|
1073
|
-
} else {
|
|
1074
|
-
ref.current = node;
|
|
1075
|
-
}
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
function cloneWithRef(element, newRef) {
|
|
1079
|
-
var previousRef = element.ref;
|
|
1080
|
-
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');
|
|
1081
|
-
|
|
1082
|
-
if (!previousRef) {
|
|
1083
|
-
// When there is no ref on the element, use the new ref directly
|
|
1084
|
-
return cloneElement(element, {
|
|
1085
|
-
ref: newRef
|
|
1086
|
-
});
|
|
1087
|
-
} else {
|
|
1088
|
-
return cloneElement(element, {
|
|
1089
|
-
ref: function ref(node) {
|
|
1090
|
-
setRef(previousRef, node);
|
|
1091
|
-
setRef(newRef, node);
|
|
1092
|
-
}
|
|
1093
|
-
});
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
|
-
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); }
|
|
1098
|
-
|
|
1099
|
-
function isRef(obj) {
|
|
1100
|
-
return (// eslint-disable-next-line no-prototype-builtins
|
|
1101
|
-
obj !== null && _typeof$2(obj) === 'object' && Object.prototype.hasOwnProperty.call(obj, 'current')
|
|
1102
|
-
);
|
|
1103
|
-
}
|
|
1104
|
-
|
|
1105
|
-
function shallowEqual(objA, objB, compare, compareContext) {
|
|
1106
|
-
var compareResult = compare ? compare.call(compareContext, objA, objB) : void 0;
|
|
1107
|
-
|
|
1108
|
-
if (compareResult !== void 0) {
|
|
1109
|
-
return !!compareResult;
|
|
1110
|
-
}
|
|
1111
|
-
|
|
1112
|
-
if (objA === objB) {
|
|
1113
|
-
return true;
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
if (typeof objA !== 'object' || !objA || typeof objB !== 'object' || !objB) {
|
|
1117
|
-
return false;
|
|
1118
|
-
}
|
|
1119
|
-
|
|
1120
|
-
var keysA = Object.keys(objA);
|
|
1121
|
-
var keysB = Object.keys(objB);
|
|
1122
|
-
|
|
1123
|
-
if (keysA.length !== keysB.length) {
|
|
1124
|
-
return false;
|
|
1125
|
-
}
|
|
1126
|
-
|
|
1127
|
-
var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB); // Test for A's keys different from B.
|
|
1128
|
-
|
|
1129
|
-
for (var idx = 0; idx < keysA.length; idx++) {
|
|
1130
|
-
var key = keysA[idx];
|
|
1131
|
-
|
|
1132
|
-
if (!bHasOwnProperty(key)) {
|
|
1133
|
-
return false;
|
|
1134
|
-
}
|
|
1135
|
-
|
|
1136
|
-
var valueA = objA[key];
|
|
1137
|
-
var valueB = objB[key];
|
|
1138
|
-
compareResult = compare ? compare.call(compareContext, valueA, valueB, key) : void 0;
|
|
1139
|
-
|
|
1140
|
-
if (compareResult === false || compareResult === void 0 && valueA !== valueB) {
|
|
1141
|
-
return false;
|
|
1142
|
-
}
|
|
1143
|
-
}
|
|
1144
|
-
|
|
1145
|
-
return true;
|
|
1146
|
-
}
|
|
1147
|
-
|
|
1148
|
-
function _classCallCheck$5(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
1149
|
-
|
|
1150
|
-
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); } }
|
|
1151
|
-
|
|
1152
|
-
function _createClass$5(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$5(Constructor.prototype, protoProps); if (staticProps) _defineProperties$5(Constructor, staticProps); return Constructor; }
|
|
1153
|
-
|
|
1154
|
-
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; }
|
|
1155
|
-
var SourceConnector = /*#__PURE__*/function () {
|
|
1156
|
-
// The drop target may either be attached via ref or connect function
|
|
1157
|
-
// The drag preview may either be attached via ref or connect function
|
|
1158
|
-
function SourceConnector(backend) {
|
|
1159
|
-
var _this = this;
|
|
1160
|
-
|
|
1161
|
-
_classCallCheck$5(this, SourceConnector);
|
|
1162
|
-
|
|
1163
|
-
_defineProperty$5(this, "hooks", wrapConnectorHooks({
|
|
1164
|
-
dragSource: function dragSource(node, options) {
|
|
1165
|
-
_this.clearDragSource();
|
|
1166
|
-
|
|
1167
|
-
_this.dragSourceOptions = options || null;
|
|
1168
|
-
|
|
1169
|
-
if (isRef(node)) {
|
|
1170
|
-
_this.dragSourceRef = node;
|
|
1171
|
-
} else {
|
|
1172
|
-
_this.dragSourceNode = node;
|
|
1173
|
-
}
|
|
1174
|
-
|
|
1175
|
-
_this.reconnectDragSource();
|
|
1176
|
-
},
|
|
1177
|
-
dragPreview: function dragPreview(node, options) {
|
|
1178
|
-
_this.clearDragPreview();
|
|
1179
|
-
|
|
1180
|
-
_this.dragPreviewOptions = options || null;
|
|
1181
|
-
|
|
1182
|
-
if (isRef(node)) {
|
|
1183
|
-
_this.dragPreviewRef = node;
|
|
1184
|
-
} else {
|
|
1185
|
-
_this.dragPreviewNode = node;
|
|
1186
|
-
}
|
|
1187
|
-
|
|
1188
|
-
_this.reconnectDragPreview();
|
|
1189
|
-
}
|
|
1190
|
-
}));
|
|
1191
|
-
|
|
1192
|
-
_defineProperty$5(this, "handlerId", null);
|
|
1193
|
-
|
|
1194
|
-
_defineProperty$5(this, "dragSourceRef", null);
|
|
1195
|
-
|
|
1196
|
-
_defineProperty$5(this, "dragSourceNode", void 0);
|
|
1197
|
-
|
|
1198
|
-
_defineProperty$5(this, "dragSourceOptionsInternal", null);
|
|
1199
|
-
|
|
1200
|
-
_defineProperty$5(this, "dragSourceUnsubscribe", void 0);
|
|
1201
|
-
|
|
1202
|
-
_defineProperty$5(this, "dragPreviewRef", null);
|
|
1203
|
-
|
|
1204
|
-
_defineProperty$5(this, "dragPreviewNode", void 0);
|
|
1205
|
-
|
|
1206
|
-
_defineProperty$5(this, "dragPreviewOptionsInternal", null);
|
|
1207
|
-
|
|
1208
|
-
_defineProperty$5(this, "dragPreviewUnsubscribe", void 0);
|
|
1209
|
-
|
|
1210
|
-
_defineProperty$5(this, "lastConnectedHandlerId", null);
|
|
1211
|
-
|
|
1212
|
-
_defineProperty$5(this, "lastConnectedDragSource", null);
|
|
1213
|
-
|
|
1214
|
-
_defineProperty$5(this, "lastConnectedDragSourceOptions", null);
|
|
1215
|
-
|
|
1216
|
-
_defineProperty$5(this, "lastConnectedDragPreview", null);
|
|
1217
|
-
|
|
1218
|
-
_defineProperty$5(this, "lastConnectedDragPreviewOptions", null);
|
|
1219
|
-
|
|
1220
|
-
_defineProperty$5(this, "backend", void 0);
|
|
1221
|
-
|
|
1222
|
-
this.backend = backend;
|
|
1223
|
-
}
|
|
1224
|
-
|
|
1225
|
-
_createClass$5(SourceConnector, [{
|
|
1226
|
-
key: "receiveHandlerId",
|
|
1227
|
-
value: function receiveHandlerId(newHandlerId) {
|
|
1228
|
-
if (this.handlerId === newHandlerId) {
|
|
1229
|
-
return;
|
|
1230
|
-
}
|
|
1231
|
-
|
|
1232
|
-
this.handlerId = newHandlerId;
|
|
1233
|
-
this.reconnect();
|
|
1234
|
-
}
|
|
1235
|
-
}, {
|
|
1236
|
-
key: "connectTarget",
|
|
1237
|
-
get: function get() {
|
|
1238
|
-
return this.dragSource;
|
|
1239
|
-
}
|
|
1240
|
-
}, {
|
|
1241
|
-
key: "dragSourceOptions",
|
|
1242
|
-
get: function get() {
|
|
1243
|
-
return this.dragSourceOptionsInternal;
|
|
1244
|
-
},
|
|
1245
|
-
set: function set(options) {
|
|
1246
|
-
this.dragSourceOptionsInternal = options;
|
|
1247
|
-
}
|
|
1248
|
-
}, {
|
|
1249
|
-
key: "dragPreviewOptions",
|
|
1250
|
-
get: function get() {
|
|
1251
|
-
return this.dragPreviewOptionsInternal;
|
|
1252
|
-
},
|
|
1253
|
-
set: function set(options) {
|
|
1254
|
-
this.dragPreviewOptionsInternal = options;
|
|
1255
|
-
}
|
|
1256
|
-
}, {
|
|
1257
|
-
key: "reconnect",
|
|
1258
|
-
value: function reconnect() {
|
|
1259
|
-
this.reconnectDragSource();
|
|
1260
|
-
this.reconnectDragPreview();
|
|
1261
|
-
}
|
|
1262
|
-
}, {
|
|
1263
|
-
key: "reconnectDragSource",
|
|
1264
|
-
value: function reconnectDragSource() {
|
|
1265
|
-
var dragSource = this.dragSource; // if nothing has changed then don't resubscribe
|
|
1266
|
-
|
|
1267
|
-
var didChange = this.didHandlerIdChange() || this.didConnectedDragSourceChange() || this.didDragSourceOptionsChange();
|
|
1268
|
-
|
|
1269
|
-
if (didChange) {
|
|
1270
|
-
this.disconnectDragSource();
|
|
1271
|
-
}
|
|
1272
|
-
|
|
1273
|
-
if (!this.handlerId) {
|
|
1274
|
-
return;
|
|
1275
|
-
}
|
|
1276
|
-
|
|
1277
|
-
if (!dragSource) {
|
|
1278
|
-
this.lastConnectedDragSource = dragSource;
|
|
1279
|
-
return;
|
|
1280
|
-
}
|
|
1281
|
-
|
|
1282
|
-
if (didChange) {
|
|
1283
|
-
this.lastConnectedHandlerId = this.handlerId;
|
|
1284
|
-
this.lastConnectedDragSource = dragSource;
|
|
1285
|
-
this.lastConnectedDragSourceOptions = this.dragSourceOptions;
|
|
1286
|
-
this.dragSourceUnsubscribe = this.backend.connectDragSource(this.handlerId, dragSource, this.dragSourceOptions);
|
|
1287
|
-
}
|
|
1288
|
-
}
|
|
1289
|
-
}, {
|
|
1290
|
-
key: "reconnectDragPreview",
|
|
1291
|
-
value: function reconnectDragPreview() {
|
|
1292
|
-
var dragPreview = this.dragPreview; // if nothing has changed then don't resubscribe
|
|
1293
|
-
|
|
1294
|
-
var didChange = this.didHandlerIdChange() || this.didConnectedDragPreviewChange() || this.didDragPreviewOptionsChange();
|
|
1295
|
-
|
|
1296
|
-
if (didChange) {
|
|
1297
|
-
this.disconnectDragPreview();
|
|
1298
|
-
}
|
|
1299
|
-
|
|
1300
|
-
if (!this.handlerId) {
|
|
1301
|
-
return;
|
|
1302
|
-
}
|
|
1303
|
-
|
|
1304
|
-
if (!dragPreview) {
|
|
1305
|
-
this.lastConnectedDragPreview = dragPreview;
|
|
1306
|
-
return;
|
|
1307
|
-
}
|
|
1308
|
-
|
|
1309
|
-
if (didChange) {
|
|
1310
|
-
this.lastConnectedHandlerId = this.handlerId;
|
|
1311
|
-
this.lastConnectedDragPreview = dragPreview;
|
|
1312
|
-
this.lastConnectedDragPreviewOptions = this.dragPreviewOptions;
|
|
1313
|
-
this.dragPreviewUnsubscribe = this.backend.connectDragPreview(this.handlerId, dragPreview, this.dragPreviewOptions);
|
|
1314
|
-
}
|
|
1315
|
-
}
|
|
1316
|
-
}, {
|
|
1317
|
-
key: "didHandlerIdChange",
|
|
1318
|
-
value: function didHandlerIdChange() {
|
|
1319
|
-
return this.lastConnectedHandlerId !== this.handlerId;
|
|
1320
|
-
}
|
|
1321
|
-
}, {
|
|
1322
|
-
key: "didConnectedDragSourceChange",
|
|
1323
|
-
value: function didConnectedDragSourceChange() {
|
|
1324
|
-
return this.lastConnectedDragSource !== this.dragSource;
|
|
1325
|
-
}
|
|
1326
|
-
}, {
|
|
1327
|
-
key: "didConnectedDragPreviewChange",
|
|
1328
|
-
value: function didConnectedDragPreviewChange() {
|
|
1329
|
-
return this.lastConnectedDragPreview !== this.dragPreview;
|
|
1330
|
-
}
|
|
1331
|
-
}, {
|
|
1332
|
-
key: "didDragSourceOptionsChange",
|
|
1333
|
-
value: function didDragSourceOptionsChange() {
|
|
1334
|
-
return !shallowEqual(this.lastConnectedDragSourceOptions, this.dragSourceOptions);
|
|
1335
|
-
}
|
|
1336
|
-
}, {
|
|
1337
|
-
key: "didDragPreviewOptionsChange",
|
|
1338
|
-
value: function didDragPreviewOptionsChange() {
|
|
1339
|
-
return !shallowEqual(this.lastConnectedDragPreviewOptions, this.dragPreviewOptions);
|
|
1340
|
-
}
|
|
1341
|
-
}, {
|
|
1342
|
-
key: "disconnectDragSource",
|
|
1343
|
-
value: function disconnectDragSource() {
|
|
1344
|
-
if (this.dragSourceUnsubscribe) {
|
|
1345
|
-
this.dragSourceUnsubscribe();
|
|
1346
|
-
this.dragSourceUnsubscribe = undefined;
|
|
1347
|
-
}
|
|
1348
|
-
}
|
|
1349
|
-
}, {
|
|
1350
|
-
key: "disconnectDragPreview",
|
|
1351
|
-
value: function disconnectDragPreview() {
|
|
1352
|
-
if (this.dragPreviewUnsubscribe) {
|
|
1353
|
-
this.dragPreviewUnsubscribe();
|
|
1354
|
-
this.dragPreviewUnsubscribe = undefined;
|
|
1355
|
-
this.dragPreviewNode = null;
|
|
1356
|
-
this.dragPreviewRef = null;
|
|
1357
|
-
}
|
|
1358
|
-
}
|
|
1359
|
-
}, {
|
|
1360
|
-
key: "dragSource",
|
|
1361
|
-
get: function get() {
|
|
1362
|
-
return this.dragSourceNode || this.dragSourceRef && this.dragSourceRef.current;
|
|
1363
|
-
}
|
|
1364
|
-
}, {
|
|
1365
|
-
key: "dragPreview",
|
|
1366
|
-
get: function get() {
|
|
1367
|
-
return this.dragPreviewNode || this.dragPreviewRef && this.dragPreviewRef.current;
|
|
1368
|
-
}
|
|
1369
|
-
}, {
|
|
1370
|
-
key: "clearDragSource",
|
|
1371
|
-
value: function clearDragSource() {
|
|
1372
|
-
this.dragSourceNode = null;
|
|
1373
|
-
this.dragSourceRef = null;
|
|
1374
|
-
}
|
|
1375
|
-
}, {
|
|
1376
|
-
key: "clearDragPreview",
|
|
1377
|
-
value: function clearDragPreview() {
|
|
1378
|
-
this.dragPreviewNode = null;
|
|
1379
|
-
this.dragPreviewRef = null;
|
|
1380
|
-
}
|
|
1381
|
-
}]);
|
|
1382
|
-
|
|
1383
|
-
return SourceConnector;
|
|
1384
|
-
}();
|
|
1385
|
-
|
|
1386
|
-
function _classCallCheck$4(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
1387
|
-
|
|
1388
|
-
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); } }
|
|
1389
|
-
|
|
1390
|
-
function _createClass$4(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$4(Constructor.prototype, protoProps); if (staticProps) _defineProperties$4(Constructor, staticProps); return Constructor; }
|
|
1391
|
-
|
|
1392
|
-
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; }
|
|
1393
|
-
var TargetConnector = /*#__PURE__*/function () {
|
|
1394
|
-
// The drop target may either be attached via ref or connect function
|
|
1395
|
-
function TargetConnector(backend) {
|
|
1396
|
-
var _this = this;
|
|
1397
|
-
|
|
1398
|
-
_classCallCheck$4(this, TargetConnector);
|
|
1399
|
-
|
|
1400
|
-
_defineProperty$4(this, "hooks", wrapConnectorHooks({
|
|
1401
|
-
dropTarget: function dropTarget(node, options) {
|
|
1402
|
-
_this.clearDropTarget();
|
|
1403
|
-
|
|
1404
|
-
_this.dropTargetOptions = options;
|
|
1405
|
-
|
|
1406
|
-
if (isRef(node)) {
|
|
1407
|
-
_this.dropTargetRef = node;
|
|
1408
|
-
} else {
|
|
1409
|
-
_this.dropTargetNode = node;
|
|
1410
|
-
}
|
|
1411
|
-
|
|
1412
|
-
_this.reconnect();
|
|
1413
|
-
}
|
|
1414
|
-
}));
|
|
1415
|
-
|
|
1416
|
-
_defineProperty$4(this, "handlerId", null);
|
|
1417
|
-
|
|
1418
|
-
_defineProperty$4(this, "dropTargetRef", null);
|
|
1419
|
-
|
|
1420
|
-
_defineProperty$4(this, "dropTargetNode", void 0);
|
|
1421
|
-
|
|
1422
|
-
_defineProperty$4(this, "dropTargetOptionsInternal", null);
|
|
1423
|
-
|
|
1424
|
-
_defineProperty$4(this, "unsubscribeDropTarget", void 0);
|
|
1425
|
-
|
|
1426
|
-
_defineProperty$4(this, "lastConnectedHandlerId", null);
|
|
1427
|
-
|
|
1428
|
-
_defineProperty$4(this, "lastConnectedDropTarget", null);
|
|
1429
|
-
|
|
1430
|
-
_defineProperty$4(this, "lastConnectedDropTargetOptions", null);
|
|
1431
|
-
|
|
1432
|
-
_defineProperty$4(this, "backend", void 0);
|
|
1433
|
-
|
|
1434
|
-
this.backend = backend;
|
|
1435
|
-
}
|
|
1436
|
-
|
|
1437
|
-
_createClass$4(TargetConnector, [{
|
|
1438
|
-
key: "connectTarget",
|
|
1439
|
-
get: function get() {
|
|
1440
|
-
return this.dropTarget;
|
|
1441
|
-
}
|
|
1442
|
-
}, {
|
|
1443
|
-
key: "reconnect",
|
|
1444
|
-
value: function reconnect() {
|
|
1445
|
-
// if nothing has changed then don't resubscribe
|
|
1446
|
-
var didChange = this.didHandlerIdChange() || this.didDropTargetChange() || this.didOptionsChange();
|
|
1447
|
-
|
|
1448
|
-
if (didChange) {
|
|
1449
|
-
this.disconnectDropTarget();
|
|
1450
|
-
}
|
|
1451
|
-
|
|
1452
|
-
var dropTarget = this.dropTarget;
|
|
1453
|
-
|
|
1454
|
-
if (!this.handlerId) {
|
|
1455
|
-
return;
|
|
1456
|
-
}
|
|
1457
|
-
|
|
1458
|
-
if (!dropTarget) {
|
|
1459
|
-
this.lastConnectedDropTarget = dropTarget;
|
|
1460
|
-
return;
|
|
1461
|
-
}
|
|
1462
|
-
|
|
1463
|
-
if (didChange) {
|
|
1464
|
-
this.lastConnectedHandlerId = this.handlerId;
|
|
1465
|
-
this.lastConnectedDropTarget = dropTarget;
|
|
1466
|
-
this.lastConnectedDropTargetOptions = this.dropTargetOptions;
|
|
1467
|
-
this.unsubscribeDropTarget = this.backend.connectDropTarget(this.handlerId, dropTarget, this.dropTargetOptions);
|
|
1468
|
-
}
|
|
1469
|
-
}
|
|
1470
|
-
}, {
|
|
1471
|
-
key: "receiveHandlerId",
|
|
1472
|
-
value: function receiveHandlerId(newHandlerId) {
|
|
1473
|
-
if (newHandlerId === this.handlerId) {
|
|
1474
|
-
return;
|
|
1475
|
-
}
|
|
1476
|
-
|
|
1477
|
-
this.handlerId = newHandlerId;
|
|
1478
|
-
this.reconnect();
|
|
1479
|
-
}
|
|
1480
|
-
}, {
|
|
1481
|
-
key: "dropTargetOptions",
|
|
1482
|
-
get: function get() {
|
|
1483
|
-
return this.dropTargetOptionsInternal;
|
|
1484
|
-
},
|
|
1485
|
-
set: function set(options) {
|
|
1486
|
-
this.dropTargetOptionsInternal = options;
|
|
1487
|
-
}
|
|
1488
|
-
}, {
|
|
1489
|
-
key: "didHandlerIdChange",
|
|
1490
|
-
value: function didHandlerIdChange() {
|
|
1491
|
-
return this.lastConnectedHandlerId !== this.handlerId;
|
|
1492
|
-
}
|
|
1493
|
-
}, {
|
|
1494
|
-
key: "didDropTargetChange",
|
|
1495
|
-
value: function didDropTargetChange() {
|
|
1496
|
-
return this.lastConnectedDropTarget !== this.dropTarget;
|
|
1497
|
-
}
|
|
1498
|
-
}, {
|
|
1499
|
-
key: "didOptionsChange",
|
|
1500
|
-
value: function didOptionsChange() {
|
|
1501
|
-
return !shallowEqual(this.lastConnectedDropTargetOptions, this.dropTargetOptions);
|
|
1502
|
-
}
|
|
1503
|
-
}, {
|
|
1504
|
-
key: "disconnectDropTarget",
|
|
1505
|
-
value: function disconnectDropTarget() {
|
|
1506
|
-
if (this.unsubscribeDropTarget) {
|
|
1507
|
-
this.unsubscribeDropTarget();
|
|
1508
|
-
this.unsubscribeDropTarget = undefined;
|
|
1509
|
-
}
|
|
1510
|
-
}
|
|
1511
|
-
}, {
|
|
1512
|
-
key: "dropTarget",
|
|
1513
|
-
get: function get() {
|
|
1514
|
-
return this.dropTargetNode || this.dropTargetRef && this.dropTargetRef.current;
|
|
1515
|
-
}
|
|
1516
|
-
}, {
|
|
1517
|
-
key: "clearDropTarget",
|
|
1518
|
-
value: function clearDropTarget() {
|
|
1519
|
-
this.dropTargetRef = null;
|
|
1520
|
-
this.dropTargetNode = null;
|
|
1521
|
-
}
|
|
1522
|
-
}]);
|
|
1523
|
-
|
|
1524
|
-
return TargetConnector;
|
|
1525
|
-
}();
|
|
1526
|
-
|
|
1527
|
-
function registerTarget(type, target, manager) {
|
|
1528
|
-
var registry = manager.getRegistry();
|
|
1529
|
-
var targetId = registry.addTarget(type, target);
|
|
1530
|
-
return [targetId, function () {
|
|
1531
|
-
return registry.removeTarget(targetId);
|
|
1532
|
-
}];
|
|
1533
|
-
}
|
|
1534
|
-
function registerSource(type, source, manager) {
|
|
1535
|
-
var registry = manager.getRegistry();
|
|
1536
|
-
var sourceId = registry.addSource(type, source);
|
|
1537
|
-
return [sourceId, function () {
|
|
1538
|
-
return registry.removeSource(sourceId);
|
|
1539
|
-
}];
|
|
1540
|
-
}
|
|
1541
|
-
|
|
1542
|
-
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); }
|
|
1543
|
-
|
|
1544
|
-
function getDecoratedComponent(instanceRef) {
|
|
1545
|
-
var currentRef = instanceRef.current;
|
|
1546
|
-
|
|
1547
|
-
if (currentRef == null) {
|
|
1548
|
-
return null;
|
|
1549
|
-
} else if (currentRef.decoratedRef) {
|
|
1550
|
-
// go through the private field in decorateHandler to avoid the invariant hit
|
|
1551
|
-
return currentRef.decoratedRef.current;
|
|
1552
|
-
} else {
|
|
1553
|
-
return currentRef;
|
|
1554
|
-
}
|
|
1555
|
-
}
|
|
1556
|
-
function isClassComponent(Component) {
|
|
1557
|
-
return Component && Component.prototype && typeof Component.prototype.render === 'function';
|
|
1558
|
-
}
|
|
1559
|
-
function isRefForwardingComponent(C) {
|
|
1560
|
-
var _item$$$typeof;
|
|
1561
|
-
|
|
1562
|
-
var item = C;
|
|
1563
|
-
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)';
|
|
1564
|
-
}
|
|
1565
|
-
function isRefable(C) {
|
|
1566
|
-
return isClassComponent(C) || isRefForwardingComponent(C);
|
|
1567
|
-
}
|
|
1568
|
-
function checkDecoratorArguments(functionName, signature) {
|
|
1569
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1570
|
-
for (var i = 0; i < (arguments.length <= 2 ? 0 : arguments.length - 2); i++) {
|
|
1571
|
-
var arg = i + 2 < 2 || arguments.length <= i + 2 ? undefined : arguments[i + 2];
|
|
1572
|
-
|
|
1573
|
-
if (arg && arg.prototype && arg.prototype.render) {
|
|
1574
|
-
// eslint-disable-next-line no-console
|
|
1575
|
-
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');
|
|
1576
|
-
return;
|
|
1577
|
-
}
|
|
1578
|
-
}
|
|
1579
|
-
}
|
|
1580
|
-
}
|
|
1581
|
-
function isFunction(input) {
|
|
1582
|
-
return typeof input === 'function';
|
|
1583
|
-
}
|
|
1584
|
-
function noop() {// noop
|
|
1585
|
-
}
|
|
1586
|
-
|
|
1587
|
-
function isObjectLike(input) {
|
|
1588
|
-
return _typeof$1(input) === 'object' && input !== null;
|
|
1589
|
-
}
|
|
1590
|
-
|
|
1591
|
-
function isPlainObject(input) {
|
|
1592
|
-
if (!isObjectLike(input)) {
|
|
1593
|
-
return false;
|
|
1594
|
-
}
|
|
1595
|
-
|
|
1596
|
-
if (Object.getPrototypeOf(input) === null) {
|
|
1597
|
-
return true;
|
|
1598
|
-
}
|
|
1599
|
-
|
|
1600
|
-
var proto = input;
|
|
1601
|
-
|
|
1602
|
-
while (Object.getPrototypeOf(proto) !== null) {
|
|
1603
|
-
proto = Object.getPrototypeOf(proto);
|
|
1604
|
-
}
|
|
1605
|
-
|
|
1606
|
-
return Object.getPrototypeOf(input) === proto;
|
|
1607
|
-
}
|
|
1608
|
-
function isValidType(type, allowArray) {
|
|
1609
|
-
return typeof type === 'string' || _typeof$1(type) === 'symbol' || !!allowArray && Array.isArray(type) && type.every(function (t) {
|
|
1610
|
-
return isValidType(t, false);
|
|
1611
|
-
});
|
|
1612
|
-
}
|
|
1613
|
-
|
|
1614
|
-
function _classCallCheck$3(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
1615
|
-
|
|
1616
|
-
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); } }
|
|
1617
|
-
|
|
1618
|
-
function _createClass$3(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$3(Constructor.prototype, protoProps); if (staticProps) _defineProperties$3(Constructor, staticProps); return Constructor; }
|
|
1619
|
-
|
|
1620
|
-
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; }
|
|
1621
|
-
/**
|
|
1622
|
-
* Provides a set of static methods for creating Disposables.
|
|
1623
|
-
* @param {Function} action Action to run during the first call to dispose.
|
|
1624
|
-
* The action is guaranteed to be run at most once.
|
|
1625
|
-
*/
|
|
1626
|
-
|
|
1627
|
-
var Disposable = /*#__PURE__*/function () {
|
|
1628
|
-
function Disposable(action) {
|
|
1629
|
-
_classCallCheck$3(this, Disposable);
|
|
1630
|
-
|
|
1631
|
-
_defineProperty$3(this, "isDisposed", false);
|
|
1632
|
-
|
|
1633
|
-
_defineProperty$3(this, "action", void 0);
|
|
1634
|
-
|
|
1635
|
-
this.action = isFunction(action) ? action : noop;
|
|
1636
|
-
}
|
|
1637
|
-
/** Performs the task of cleaning up resources. */
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
_createClass$3(Disposable, [{
|
|
1641
|
-
key: "dispose",
|
|
1642
|
-
value: function dispose() {
|
|
1643
|
-
if (!this.isDisposed) {
|
|
1644
|
-
this.action();
|
|
1645
|
-
this.isDisposed = true;
|
|
1646
|
-
}
|
|
1647
|
-
}
|
|
1648
|
-
}], [{
|
|
1649
|
-
key: "isDisposable",
|
|
1650
|
-
value:
|
|
1651
|
-
/**
|
|
1652
|
-
* Gets the disposable that does nothing when disposed.
|
|
1653
|
-
*/
|
|
1654
|
-
|
|
1655
|
-
/**
|
|
1656
|
-
* Validates whether the given object is a disposable
|
|
1657
|
-
* @param {Object} Object to test whether it has a dispose method
|
|
1658
|
-
* @returns {Boolean} true if a disposable object, else false.
|
|
1659
|
-
*/
|
|
1660
|
-
function isDisposable(d) {
|
|
1661
|
-
return Boolean(d && isFunction(d.dispose));
|
|
1662
|
-
}
|
|
1663
|
-
}, {
|
|
1664
|
-
key: "_fixup",
|
|
1665
|
-
value: function _fixup(result) {
|
|
1666
|
-
return Disposable.isDisposable(result) ? result : Disposable.empty;
|
|
1667
|
-
}
|
|
1668
|
-
/**
|
|
1669
|
-
* Creates a disposable object that invokes the specified action when disposed.
|
|
1670
|
-
* @param {Function} dispose Action to run during the first call to dispose.
|
|
1671
|
-
* The action is guaranteed to be run at most once.
|
|
1672
|
-
* @return {Disposable} The disposable object that runs the given action upon disposal.
|
|
1673
|
-
*/
|
|
1674
|
-
|
|
1675
|
-
}, {
|
|
1676
|
-
key: "create",
|
|
1677
|
-
value: function create(action) {
|
|
1678
|
-
return new Disposable(action);
|
|
1679
|
-
}
|
|
1680
|
-
}]);
|
|
1681
|
-
|
|
1682
|
-
return Disposable;
|
|
1683
|
-
}();
|
|
1684
|
-
/**
|
|
1685
|
-
* Represents a group of disposable resources that are disposed together.
|
|
1686
|
-
* @constructor
|
|
1687
|
-
*/
|
|
1688
|
-
|
|
1689
|
-
_defineProperty$3(Disposable, "empty", {
|
|
1690
|
-
dispose: noop
|
|
1691
|
-
});
|
|
1692
|
-
|
|
1693
|
-
var CompositeDisposable = /*#__PURE__*/function () {
|
|
1694
|
-
function CompositeDisposable() {
|
|
1695
|
-
_classCallCheck$3(this, CompositeDisposable);
|
|
1696
|
-
|
|
1697
|
-
_defineProperty$3(this, "isDisposed", false);
|
|
1698
|
-
|
|
1699
|
-
_defineProperty$3(this, "disposables", void 0);
|
|
1700
|
-
|
|
1701
|
-
for (var _len = arguments.length, disposables = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1702
|
-
disposables[_key] = arguments[_key];
|
|
1703
|
-
}
|
|
1704
|
-
|
|
1705
|
-
this.disposables = disposables;
|
|
1706
|
-
}
|
|
1707
|
-
/**
|
|
1708
|
-
* Adds a disposable to the CompositeDisposable or disposes the disposable if the CompositeDisposable is disposed.
|
|
1709
|
-
* @param {Any} item Disposable to add.
|
|
1710
|
-
*/
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
_createClass$3(CompositeDisposable, [{
|
|
1714
|
-
key: "add",
|
|
1715
|
-
value: function add(item) {
|
|
1716
|
-
if (this.isDisposed) {
|
|
1717
|
-
item.dispose();
|
|
1718
|
-
} else {
|
|
1719
|
-
this.disposables.push(item);
|
|
1720
|
-
}
|
|
1721
|
-
}
|
|
1722
|
-
/**
|
|
1723
|
-
* Removes and disposes the first occurrence of a disposable from the CompositeDisposable.
|
|
1724
|
-
* @param {Any} item Disposable to remove.
|
|
1725
|
-
* @returns {Boolean} true if found; false otherwise.
|
|
1726
|
-
*/
|
|
1727
|
-
|
|
1728
|
-
}, {
|
|
1729
|
-
key: "remove",
|
|
1730
|
-
value: function remove(item) {
|
|
1731
|
-
var shouldDispose = false;
|
|
1732
|
-
|
|
1733
|
-
if (!this.isDisposed) {
|
|
1734
|
-
var idx = this.disposables.indexOf(item);
|
|
1735
|
-
|
|
1736
|
-
if (idx !== -1) {
|
|
1737
|
-
shouldDispose = true;
|
|
1738
|
-
this.disposables.splice(idx, 1);
|
|
1739
|
-
item.dispose();
|
|
1740
|
-
}
|
|
1741
|
-
}
|
|
1742
|
-
|
|
1743
|
-
return shouldDispose;
|
|
1744
|
-
}
|
|
1745
|
-
/**
|
|
1746
|
-
* Disposes all disposables in the group and removes them from the group but
|
|
1747
|
-
* does not dispose the CompositeDisposable.
|
|
1748
|
-
*/
|
|
1749
|
-
|
|
1750
|
-
}, {
|
|
1751
|
-
key: "clear",
|
|
1752
|
-
value: function clear() {
|
|
1753
|
-
if (!this.isDisposed) {
|
|
1754
|
-
var len = this.disposables.length;
|
|
1755
|
-
var currentDisposables = new Array(len);
|
|
1756
|
-
|
|
1757
|
-
for (var i = 0; i < len; i++) {
|
|
1758
|
-
currentDisposables[i] = this.disposables[i];
|
|
1759
|
-
}
|
|
1760
|
-
|
|
1761
|
-
this.disposables = [];
|
|
1762
|
-
|
|
1763
|
-
for (var _i = 0; _i < len; _i++) {
|
|
1764
|
-
currentDisposables[_i].dispose();
|
|
1765
|
-
}
|
|
1766
|
-
}
|
|
1767
|
-
}
|
|
1768
|
-
/**
|
|
1769
|
-
* Disposes all disposables in the group and removes them from the group.
|
|
1770
|
-
*/
|
|
1771
|
-
|
|
1772
|
-
}, {
|
|
1773
|
-
key: "dispose",
|
|
1774
|
-
value: function dispose() {
|
|
1775
|
-
if (!this.isDisposed) {
|
|
1776
|
-
this.isDisposed = true;
|
|
1777
|
-
var len = this.disposables.length;
|
|
1778
|
-
var currentDisposables = new Array(len);
|
|
1779
|
-
|
|
1780
|
-
for (var i = 0; i < len; i++) {
|
|
1781
|
-
currentDisposables[i] = this.disposables[i];
|
|
1782
|
-
}
|
|
1783
|
-
|
|
1784
|
-
this.disposables = [];
|
|
1785
|
-
|
|
1786
|
-
for (var _i2 = 0; _i2 < len; _i2++) {
|
|
1787
|
-
currentDisposables[_i2].dispose();
|
|
1788
|
-
}
|
|
1789
|
-
}
|
|
1790
|
-
}
|
|
1791
|
-
}]);
|
|
1792
|
-
|
|
1793
|
-
return CompositeDisposable;
|
|
1794
|
-
}();
|
|
1795
|
-
/**
|
|
1796
|
-
* Represents a disposable resource whose underlying disposable resource can
|
|
1797
|
-
* be replaced by another disposable resource, causing automatic disposal of
|
|
1798
|
-
* the previous underlying disposable resource.
|
|
1799
|
-
*/
|
|
1800
|
-
|
|
1801
|
-
var SerialDisposable = /*#__PURE__*/function () {
|
|
1802
|
-
function SerialDisposable() {
|
|
1803
|
-
_classCallCheck$3(this, SerialDisposable);
|
|
1804
|
-
|
|
1805
|
-
_defineProperty$3(this, "isDisposed", false);
|
|
1806
|
-
|
|
1807
|
-
_defineProperty$3(this, "current", void 0);
|
|
1808
|
-
}
|
|
1809
|
-
|
|
1810
|
-
_createClass$3(SerialDisposable, [{
|
|
1811
|
-
key: "getDisposable",
|
|
1812
|
-
value:
|
|
1813
|
-
/**
|
|
1814
|
-
* Gets the underlying disposable.
|
|
1815
|
-
* @returns {Any} the underlying disposable.
|
|
1816
|
-
*/
|
|
1817
|
-
function getDisposable() {
|
|
1818
|
-
return this.current;
|
|
1819
|
-
}
|
|
1820
|
-
}, {
|
|
1821
|
-
key: "setDisposable",
|
|
1822
|
-
value: function setDisposable(value) {
|
|
1823
|
-
var shouldDispose = this.isDisposed;
|
|
1824
|
-
|
|
1825
|
-
if (!shouldDispose) {
|
|
1826
|
-
var old = this.current;
|
|
1827
|
-
this.current = value;
|
|
1828
|
-
|
|
1829
|
-
if (old) {
|
|
1830
|
-
old.dispose();
|
|
1831
|
-
}
|
|
1832
|
-
}
|
|
1833
|
-
|
|
1834
|
-
if (shouldDispose && value) {
|
|
1835
|
-
value.dispose();
|
|
1836
|
-
}
|
|
1837
|
-
}
|
|
1838
|
-
/** Performs the task of cleaning up resources. */
|
|
1839
|
-
|
|
1840
|
-
}, {
|
|
1841
|
-
key: "dispose",
|
|
1842
|
-
value: function dispose() {
|
|
1843
|
-
if (!this.isDisposed) {
|
|
1844
|
-
this.isDisposed = true;
|
|
1845
|
-
var old = this.current;
|
|
1846
|
-
this.current = undefined;
|
|
1847
|
-
|
|
1848
|
-
if (old) {
|
|
1849
|
-
old.dispose();
|
|
1850
|
-
}
|
|
1851
|
-
}
|
|
1852
|
-
}
|
|
1853
|
-
}]);
|
|
1854
|
-
|
|
1855
|
-
return SerialDisposable;
|
|
1856
|
-
}();
|
|
1857
|
-
|
|
1858
|
-
var reactIs$1 = {exports: {}};
|
|
1859
|
-
|
|
1860
|
-
var reactIs_production_min = {};
|
|
1861
|
-
|
|
1862
|
-
/** @license React v16.13.1
|
|
1863
|
-
* react-is.production.min.js
|
|
1864
|
-
*
|
|
1865
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
1866
|
-
*
|
|
1867
|
-
* This source code is licensed under the MIT license found in the
|
|
1868
|
-
* LICENSE file in the root directory of this source tree.
|
|
1869
|
-
*/
|
|
1870
|
-
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?
|
|
1871
|
-
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;
|
|
1872
|
-
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;
|
|
1873
|
-
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};
|
|
1874
|
-
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};
|
|
1875
|
-
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;
|
|
1876
|
-
|
|
1877
|
-
var reactIs_development = {};
|
|
1878
|
-
|
|
1879
|
-
/** @license React v16.13.1
|
|
1880
|
-
* react-is.development.js
|
|
1881
|
-
*
|
|
1882
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
1883
|
-
*
|
|
1884
|
-
* This source code is licensed under the MIT license found in the
|
|
1885
|
-
* LICENSE file in the root directory of this source tree.
|
|
1886
|
-
*/
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
if (process.env.NODE_ENV !== "production") {
|
|
1891
|
-
(function() {
|
|
1892
|
-
|
|
1893
|
-
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
|
1894
|
-
// nor polyfill, then a plain number is used for performance.
|
|
1895
|
-
var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
|
1896
|
-
var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
|
1897
|
-
var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
|
1898
|
-
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
|
1899
|
-
var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
|
1900
|
-
var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
|
1901
|
-
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
|
1902
|
-
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
|
|
1903
|
-
// (unstable) APIs that have been removed. Can we remove the symbols?
|
|
1904
|
-
|
|
1905
|
-
var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
|
|
1906
|
-
var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
|
|
1907
|
-
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
|
1908
|
-
var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
|
|
1909
|
-
var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
|
|
1910
|
-
var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
|
|
1911
|
-
var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
|
|
1912
|
-
var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
|
|
1913
|
-
var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
|
|
1914
|
-
var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
|
|
1915
|
-
var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
|
|
1916
|
-
|
|
1917
|
-
function isValidElementType(type) {
|
|
1918
|
-
return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
|
|
1919
|
-
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);
|
|
1920
|
-
}
|
|
1921
|
-
|
|
1922
|
-
function typeOf(object) {
|
|
1923
|
-
if (typeof object === 'object' && object !== null) {
|
|
1924
|
-
var $$typeof = object.$$typeof;
|
|
1925
|
-
|
|
1926
|
-
switch ($$typeof) {
|
|
1927
|
-
case REACT_ELEMENT_TYPE:
|
|
1928
|
-
var type = object.type;
|
|
1929
|
-
|
|
1930
|
-
switch (type) {
|
|
1931
|
-
case REACT_ASYNC_MODE_TYPE:
|
|
1932
|
-
case REACT_CONCURRENT_MODE_TYPE:
|
|
1933
|
-
case REACT_FRAGMENT_TYPE:
|
|
1934
|
-
case REACT_PROFILER_TYPE:
|
|
1935
|
-
case REACT_STRICT_MODE_TYPE:
|
|
1936
|
-
case REACT_SUSPENSE_TYPE:
|
|
1937
|
-
return type;
|
|
1938
|
-
|
|
1939
|
-
default:
|
|
1940
|
-
var $$typeofType = type && type.$$typeof;
|
|
1941
|
-
|
|
1942
|
-
switch ($$typeofType) {
|
|
1943
|
-
case REACT_CONTEXT_TYPE:
|
|
1944
|
-
case REACT_FORWARD_REF_TYPE:
|
|
1945
|
-
case REACT_LAZY_TYPE:
|
|
1946
|
-
case REACT_MEMO_TYPE:
|
|
1947
|
-
case REACT_PROVIDER_TYPE:
|
|
1948
|
-
return $$typeofType;
|
|
1949
|
-
|
|
1950
|
-
default:
|
|
1951
|
-
return $$typeof;
|
|
1952
|
-
}
|
|
1953
|
-
|
|
1954
|
-
}
|
|
1955
|
-
|
|
1956
|
-
case REACT_PORTAL_TYPE:
|
|
1957
|
-
return $$typeof;
|
|
1958
|
-
}
|
|
1959
|
-
}
|
|
1960
|
-
|
|
1961
|
-
return undefined;
|
|
1962
|
-
} // AsyncMode is deprecated along with isAsyncMode
|
|
1963
|
-
|
|
1964
|
-
var AsyncMode = REACT_ASYNC_MODE_TYPE;
|
|
1965
|
-
var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
|
|
1966
|
-
var ContextConsumer = REACT_CONTEXT_TYPE;
|
|
1967
|
-
var ContextProvider = REACT_PROVIDER_TYPE;
|
|
1968
|
-
var Element = REACT_ELEMENT_TYPE;
|
|
1969
|
-
var ForwardRef = REACT_FORWARD_REF_TYPE;
|
|
1970
|
-
var Fragment = REACT_FRAGMENT_TYPE;
|
|
1971
|
-
var Lazy = REACT_LAZY_TYPE;
|
|
1972
|
-
var Memo = REACT_MEMO_TYPE;
|
|
1973
|
-
var Portal = REACT_PORTAL_TYPE;
|
|
1974
|
-
var Profiler = REACT_PROFILER_TYPE;
|
|
1975
|
-
var StrictMode = REACT_STRICT_MODE_TYPE;
|
|
1976
|
-
var Suspense = REACT_SUSPENSE_TYPE;
|
|
1977
|
-
var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated
|
|
1978
|
-
|
|
1979
|
-
function isAsyncMode(object) {
|
|
1980
|
-
{
|
|
1981
|
-
if (!hasWarnedAboutDeprecatedIsAsyncMode) {
|
|
1982
|
-
hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
|
|
1983
|
-
|
|
1984
|
-
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.');
|
|
1985
|
-
}
|
|
1986
|
-
}
|
|
1987
|
-
|
|
1988
|
-
return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
|
|
1989
|
-
}
|
|
1990
|
-
function isConcurrentMode(object) {
|
|
1991
|
-
return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
|
|
1992
|
-
}
|
|
1993
|
-
function isContextConsumer(object) {
|
|
1994
|
-
return typeOf(object) === REACT_CONTEXT_TYPE;
|
|
1995
|
-
}
|
|
1996
|
-
function isContextProvider(object) {
|
|
1997
|
-
return typeOf(object) === REACT_PROVIDER_TYPE;
|
|
1998
|
-
}
|
|
1999
|
-
function isElement(object) {
|
|
2000
|
-
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
2001
|
-
}
|
|
2002
|
-
function isForwardRef(object) {
|
|
2003
|
-
return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
|
2004
|
-
}
|
|
2005
|
-
function isFragment(object) {
|
|
2006
|
-
return typeOf(object) === REACT_FRAGMENT_TYPE;
|
|
2007
|
-
}
|
|
2008
|
-
function isLazy(object) {
|
|
2009
|
-
return typeOf(object) === REACT_LAZY_TYPE;
|
|
2010
|
-
}
|
|
2011
|
-
function isMemo(object) {
|
|
2012
|
-
return typeOf(object) === REACT_MEMO_TYPE;
|
|
2013
|
-
}
|
|
2014
|
-
function isPortal(object) {
|
|
2015
|
-
return typeOf(object) === REACT_PORTAL_TYPE;
|
|
2016
|
-
}
|
|
2017
|
-
function isProfiler(object) {
|
|
2018
|
-
return typeOf(object) === REACT_PROFILER_TYPE;
|
|
2019
|
-
}
|
|
2020
|
-
function isStrictMode(object) {
|
|
2021
|
-
return typeOf(object) === REACT_STRICT_MODE_TYPE;
|
|
2022
|
-
}
|
|
2023
|
-
function isSuspense(object) {
|
|
2024
|
-
return typeOf(object) === REACT_SUSPENSE_TYPE;
|
|
2025
|
-
}
|
|
2026
|
-
|
|
2027
|
-
reactIs_development.AsyncMode = AsyncMode;
|
|
2028
|
-
reactIs_development.ConcurrentMode = ConcurrentMode;
|
|
2029
|
-
reactIs_development.ContextConsumer = ContextConsumer;
|
|
2030
|
-
reactIs_development.ContextProvider = ContextProvider;
|
|
2031
|
-
reactIs_development.Element = Element;
|
|
2032
|
-
reactIs_development.ForwardRef = ForwardRef;
|
|
2033
|
-
reactIs_development.Fragment = Fragment;
|
|
2034
|
-
reactIs_development.Lazy = Lazy;
|
|
2035
|
-
reactIs_development.Memo = Memo;
|
|
2036
|
-
reactIs_development.Portal = Portal;
|
|
2037
|
-
reactIs_development.Profiler = Profiler;
|
|
2038
|
-
reactIs_development.StrictMode = StrictMode;
|
|
2039
|
-
reactIs_development.Suspense = Suspense;
|
|
2040
|
-
reactIs_development.isAsyncMode = isAsyncMode;
|
|
2041
|
-
reactIs_development.isConcurrentMode = isConcurrentMode;
|
|
2042
|
-
reactIs_development.isContextConsumer = isContextConsumer;
|
|
2043
|
-
reactIs_development.isContextProvider = isContextProvider;
|
|
2044
|
-
reactIs_development.isElement = isElement;
|
|
2045
|
-
reactIs_development.isForwardRef = isForwardRef;
|
|
2046
|
-
reactIs_development.isFragment = isFragment;
|
|
2047
|
-
reactIs_development.isLazy = isLazy;
|
|
2048
|
-
reactIs_development.isMemo = isMemo;
|
|
2049
|
-
reactIs_development.isPortal = isPortal;
|
|
2050
|
-
reactIs_development.isProfiler = isProfiler;
|
|
2051
|
-
reactIs_development.isStrictMode = isStrictMode;
|
|
2052
|
-
reactIs_development.isSuspense = isSuspense;
|
|
2053
|
-
reactIs_development.isValidElementType = isValidElementType;
|
|
2054
|
-
reactIs_development.typeOf = typeOf;
|
|
2055
|
-
})();
|
|
2056
|
-
}
|
|
2057
|
-
|
|
2058
|
-
if (process.env.NODE_ENV === 'production') {
|
|
2059
|
-
reactIs$1.exports = reactIs_production_min;
|
|
2060
|
-
} else {
|
|
2061
|
-
reactIs$1.exports = reactIs_development;
|
|
2062
|
-
}
|
|
2063
|
-
|
|
2064
|
-
var reactIs = reactIs$1.exports;
|
|
2065
|
-
|
|
2066
|
-
/**
|
|
2067
|
-
* Copyright 2015, Yahoo! Inc.
|
|
2068
|
-
* Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
|
|
2069
|
-
*/
|
|
2070
|
-
var REACT_STATICS = {
|
|
2071
|
-
childContextTypes: true,
|
|
2072
|
-
contextType: true,
|
|
2073
|
-
contextTypes: true,
|
|
2074
|
-
defaultProps: true,
|
|
2075
|
-
displayName: true,
|
|
2076
|
-
getDefaultProps: true,
|
|
2077
|
-
getDerivedStateFromError: true,
|
|
2078
|
-
getDerivedStateFromProps: true,
|
|
2079
|
-
mixins: true,
|
|
2080
|
-
propTypes: true,
|
|
2081
|
-
type: true
|
|
2082
|
-
};
|
|
2083
|
-
var KNOWN_STATICS = {
|
|
2084
|
-
name: true,
|
|
2085
|
-
length: true,
|
|
2086
|
-
prototype: true,
|
|
2087
|
-
caller: true,
|
|
2088
|
-
callee: true,
|
|
2089
|
-
arguments: true,
|
|
2090
|
-
arity: true
|
|
2091
|
-
};
|
|
2092
|
-
var FORWARD_REF_STATICS = {
|
|
2093
|
-
'$$typeof': true,
|
|
2094
|
-
render: true,
|
|
2095
|
-
defaultProps: true,
|
|
2096
|
-
displayName: true,
|
|
2097
|
-
propTypes: true
|
|
2098
|
-
};
|
|
2099
|
-
var MEMO_STATICS = {
|
|
2100
|
-
'$$typeof': true,
|
|
2101
|
-
compare: true,
|
|
2102
|
-
defaultProps: true,
|
|
2103
|
-
displayName: true,
|
|
2104
|
-
propTypes: true,
|
|
2105
|
-
type: true
|
|
2106
|
-
};
|
|
2107
|
-
var TYPE_STATICS = {};
|
|
2108
|
-
TYPE_STATICS[reactIs.ForwardRef] = FORWARD_REF_STATICS;
|
|
2109
|
-
TYPE_STATICS[reactIs.Memo] = MEMO_STATICS;
|
|
2110
|
-
|
|
2111
|
-
function getStatics(component) {
|
|
2112
|
-
// React v16.11 and below
|
|
2113
|
-
if (reactIs.isMemo(component)) {
|
|
2114
|
-
return MEMO_STATICS;
|
|
2115
|
-
} // React v16.12 and above
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
return TYPE_STATICS[component['$$typeof']] || REACT_STATICS;
|
|
2119
|
-
}
|
|
2120
|
-
|
|
2121
|
-
var defineProperty = Object.defineProperty;
|
|
2122
|
-
var getOwnPropertyNames = Object.getOwnPropertyNames;
|
|
2123
|
-
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
2124
|
-
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
2125
|
-
var getPrototypeOf = Object.getPrototypeOf;
|
|
2126
|
-
var objectPrototype = Object.prototype;
|
|
2127
|
-
function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) {
|
|
2128
|
-
if (typeof sourceComponent !== 'string') {
|
|
2129
|
-
// don't hoist over string (html) components
|
|
2130
|
-
if (objectPrototype) {
|
|
2131
|
-
var inheritedComponent = getPrototypeOf(sourceComponent);
|
|
2132
|
-
|
|
2133
|
-
if (inheritedComponent && inheritedComponent !== objectPrototype) {
|
|
2134
|
-
hoistNonReactStatics(targetComponent, inheritedComponent, blacklist);
|
|
2135
|
-
}
|
|
2136
|
-
}
|
|
2137
|
-
|
|
2138
|
-
var keys = getOwnPropertyNames(sourceComponent);
|
|
2139
|
-
|
|
2140
|
-
if (getOwnPropertySymbols) {
|
|
2141
|
-
keys = keys.concat(getOwnPropertySymbols(sourceComponent));
|
|
2142
|
-
}
|
|
2143
|
-
|
|
2144
|
-
var targetStatics = getStatics(targetComponent);
|
|
2145
|
-
var sourceStatics = getStatics(sourceComponent);
|
|
2146
|
-
|
|
2147
|
-
for (var i = 0; i < keys.length; ++i) {
|
|
2148
|
-
var key = keys[i];
|
|
2149
|
-
|
|
2150
|
-
if (!KNOWN_STATICS[key] && !(blacklist && blacklist[key]) && !(sourceStatics && sourceStatics[key]) && !(targetStatics && targetStatics[key])) {
|
|
2151
|
-
var descriptor = getOwnPropertyDescriptor(sourceComponent, key);
|
|
2152
|
-
|
|
2153
|
-
try {
|
|
2154
|
-
// Avoid failures from read-only properties
|
|
2155
|
-
defineProperty(targetComponent, key, descriptor);
|
|
2156
|
-
} catch (e) {}
|
|
2157
|
-
}
|
|
2158
|
-
}
|
|
2159
|
-
}
|
|
2160
|
-
|
|
2161
|
-
return targetComponent;
|
|
2162
|
-
}
|
|
2163
|
-
|
|
2164
|
-
var hoistNonReactStatics_cjs = hoistNonReactStatics;
|
|
2165
|
-
|
|
2166
|
-
var hoistStatics = hoistNonReactStatics_cjs;
|
|
2167
|
-
|
|
2168
|
-
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); }
|
|
2169
|
-
|
|
2170
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2171
|
-
|
|
2172
|
-
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."); }
|
|
2173
|
-
|
|
2174
|
-
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); }
|
|
2175
|
-
|
|
2176
|
-
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; }
|
|
2177
|
-
|
|
2178
|
-
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; }
|
|
2179
|
-
|
|
2180
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
2181
|
-
|
|
2182
|
-
function _classCallCheck$2(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2183
|
-
|
|
2184
|
-
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); } }
|
|
2185
|
-
|
|
2186
|
-
function _createClass$2(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$2(Constructor.prototype, protoProps); if (staticProps) _defineProperties$2(Constructor, staticProps); return Constructor; }
|
|
2187
|
-
|
|
2188
|
-
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); }
|
|
2189
|
-
|
|
2190
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
2191
|
-
|
|
2192
|
-
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); }; }
|
|
2193
|
-
|
|
2194
|
-
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); }
|
|
2195
|
-
|
|
2196
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
2197
|
-
|
|
2198
|
-
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; } }
|
|
2199
|
-
|
|
2200
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
2201
|
-
|
|
2202
|
-
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; }
|
|
2203
|
-
function decorateHandler(_ref) {
|
|
2204
|
-
var DecoratedComponent = _ref.DecoratedComponent,
|
|
2205
|
-
createHandler = _ref.createHandler,
|
|
2206
|
-
createMonitor = _ref.createMonitor,
|
|
2207
|
-
createConnector = _ref.createConnector,
|
|
2208
|
-
registerHandler = _ref.registerHandler,
|
|
2209
|
-
containerDisplayName = _ref.containerDisplayName,
|
|
2210
|
-
getType = _ref.getType,
|
|
2211
|
-
collect = _ref.collect,
|
|
2212
|
-
options = _ref.options;
|
|
2213
|
-
var _options$arePropsEqua = options.arePropsEqual,
|
|
2214
|
-
arePropsEqual = _options$arePropsEqua === void 0 ? shallowEqual : _options$arePropsEqua;
|
|
2215
|
-
var Decorated = DecoratedComponent;
|
|
2216
|
-
var displayName = DecoratedComponent.displayName || DecoratedComponent.name || 'Component';
|
|
2217
|
-
|
|
2218
|
-
var DragDropContainer = /*#__PURE__*/function (_Component) {
|
|
2219
|
-
_inherits(DragDropContainer, _Component);
|
|
2220
|
-
|
|
2221
|
-
var _super = _createSuper(DragDropContainer);
|
|
2222
|
-
|
|
2223
|
-
function DragDropContainer(props) {
|
|
2224
|
-
var _this;
|
|
2225
|
-
|
|
2226
|
-
_classCallCheck$2(this, DragDropContainer);
|
|
2227
|
-
|
|
2228
|
-
_this = _super.call(this, props);
|
|
2229
|
-
|
|
2230
|
-
_defineProperty$2(_assertThisInitialized(_this), "decoratedRef", createRef());
|
|
2231
|
-
|
|
2232
|
-
_defineProperty$2(_assertThisInitialized(_this), "handlerId", void 0);
|
|
2233
|
-
|
|
2234
|
-
_defineProperty$2(_assertThisInitialized(_this), "manager", void 0);
|
|
2235
|
-
|
|
2236
|
-
_defineProperty$2(_assertThisInitialized(_this), "handlerMonitor", void 0);
|
|
2237
|
-
|
|
2238
|
-
_defineProperty$2(_assertThisInitialized(_this), "handlerConnector", void 0);
|
|
2239
|
-
|
|
2240
|
-
_defineProperty$2(_assertThisInitialized(_this), "handler", void 0);
|
|
2241
|
-
|
|
2242
|
-
_defineProperty$2(_assertThisInitialized(_this), "disposable", void 0);
|
|
2243
|
-
|
|
2244
|
-
_defineProperty$2(_assertThisInitialized(_this), "currentType", void 0);
|
|
2245
|
-
|
|
2246
|
-
_defineProperty$2(_assertThisInitialized(_this), "handleChange", function () {
|
|
2247
|
-
var nextState = _this.getCurrentState();
|
|
2248
|
-
|
|
2249
|
-
if (!shallowEqual(nextState, _this.state)) {
|
|
2250
|
-
_this.setState(nextState);
|
|
2251
|
-
}
|
|
2252
|
-
});
|
|
2253
|
-
|
|
2254
|
-
_this.disposable = new SerialDisposable();
|
|
2255
|
-
|
|
2256
|
-
_this.receiveProps(props);
|
|
2257
|
-
|
|
2258
|
-
_this.dispose();
|
|
2259
|
-
|
|
2260
|
-
return _this;
|
|
2261
|
-
}
|
|
2262
|
-
|
|
2263
|
-
_createClass$2(DragDropContainer, [{
|
|
2264
|
-
key: "getHandlerId",
|
|
2265
|
-
value: function getHandlerId() {
|
|
2266
|
-
return this.handlerId;
|
|
2267
|
-
}
|
|
2268
|
-
}, {
|
|
2269
|
-
key: "getDecoratedComponentInstance",
|
|
2270
|
-
value: function getDecoratedComponentInstance() {
|
|
2271
|
-
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()');
|
|
2272
|
-
return this.decoratedRef.current;
|
|
2273
|
-
}
|
|
2274
|
-
}, {
|
|
2275
|
-
key: "shouldComponentUpdate",
|
|
2276
|
-
value: function shouldComponentUpdate(nextProps, nextState) {
|
|
2277
|
-
return !arePropsEqual(nextProps, this.props) || !shallowEqual(nextState, this.state);
|
|
2278
|
-
}
|
|
2279
|
-
}, {
|
|
2280
|
-
key: "componentDidMount",
|
|
2281
|
-
value: function componentDidMount() {
|
|
2282
|
-
this.disposable = new SerialDisposable();
|
|
2283
|
-
this.currentType = undefined;
|
|
2284
|
-
this.receiveProps(this.props);
|
|
2285
|
-
this.handleChange();
|
|
2286
|
-
}
|
|
2287
|
-
}, {
|
|
2288
|
-
key: "componentDidUpdate",
|
|
2289
|
-
value: function componentDidUpdate(prevProps) {
|
|
2290
|
-
if (!arePropsEqual(this.props, prevProps)) {
|
|
2291
|
-
this.receiveProps(this.props);
|
|
2292
|
-
this.handleChange();
|
|
2293
|
-
}
|
|
2294
|
-
}
|
|
2295
|
-
}, {
|
|
2296
|
-
key: "componentWillUnmount",
|
|
2297
|
-
value: function componentWillUnmount() {
|
|
2298
|
-
this.dispose();
|
|
2299
|
-
}
|
|
2300
|
-
}, {
|
|
2301
|
-
key: "receiveProps",
|
|
2302
|
-
value: function receiveProps(props) {
|
|
2303
|
-
if (!this.handler) {
|
|
2304
|
-
return;
|
|
2305
|
-
}
|
|
2306
|
-
|
|
2307
|
-
this.handler.receiveProps(props);
|
|
2308
|
-
this.receiveType(getType(props));
|
|
2309
|
-
}
|
|
2310
|
-
}, {
|
|
2311
|
-
key: "receiveType",
|
|
2312
|
-
value: function receiveType(type) {
|
|
2313
|
-
if (!this.handlerMonitor || !this.manager || !this.handlerConnector) {
|
|
2314
|
-
return;
|
|
2315
|
-
}
|
|
2316
|
-
|
|
2317
|
-
if (type === this.currentType) {
|
|
2318
|
-
return;
|
|
2319
|
-
}
|
|
2320
|
-
|
|
2321
|
-
this.currentType = type;
|
|
2322
|
-
|
|
2323
|
-
var _registerHandler = registerHandler(type, this.handler, this.manager),
|
|
2324
|
-
_registerHandler2 = _slicedToArray(_registerHandler, 2),
|
|
2325
|
-
handlerId = _registerHandler2[0],
|
|
2326
|
-
unregister = _registerHandler2[1];
|
|
2327
|
-
|
|
2328
|
-
this.handlerId = handlerId;
|
|
2329
|
-
this.handlerMonitor.receiveHandlerId(handlerId);
|
|
2330
|
-
this.handlerConnector.receiveHandlerId(handlerId);
|
|
2331
|
-
var globalMonitor = this.manager.getMonitor();
|
|
2332
|
-
var unsubscribe = globalMonitor.subscribeToStateChange(this.handleChange, {
|
|
2333
|
-
handlerIds: [handlerId]
|
|
2334
|
-
});
|
|
2335
|
-
this.disposable.setDisposable(new CompositeDisposable(new Disposable(unsubscribe), new Disposable(unregister)));
|
|
2336
|
-
}
|
|
2337
|
-
}, {
|
|
2338
|
-
key: "dispose",
|
|
2339
|
-
value: function dispose() {
|
|
2340
|
-
this.disposable.dispose();
|
|
2341
|
-
|
|
2342
|
-
if (this.handlerConnector) {
|
|
2343
|
-
this.handlerConnector.receiveHandlerId(null);
|
|
2344
|
-
}
|
|
2345
|
-
}
|
|
2346
|
-
}, {
|
|
2347
|
-
key: "getCurrentState",
|
|
2348
|
-
value: function getCurrentState() {
|
|
2349
|
-
if (!this.handlerConnector) {
|
|
2350
|
-
return {};
|
|
2351
|
-
}
|
|
2352
|
-
|
|
2353
|
-
var nextState = collect(this.handlerConnector.hooks, this.handlerMonitor, this.props);
|
|
2354
|
-
|
|
2355
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2356
|
-
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);
|
|
2357
|
-
}
|
|
2358
|
-
|
|
2359
|
-
return nextState;
|
|
2360
|
-
}
|
|
2361
|
-
}, {
|
|
2362
|
-
key: "render",
|
|
2363
|
-
value: function render() {
|
|
2364
|
-
var _this2 = this;
|
|
2365
|
-
|
|
2366
|
-
return jsx(DndContext.Consumer, {
|
|
2367
|
-
children: function children(_ref2) {
|
|
2368
|
-
var dragDropManager = _ref2.dragDropManager;
|
|
2369
|
-
|
|
2370
|
-
_this2.receiveDragDropManager(dragDropManager);
|
|
2371
|
-
|
|
2372
|
-
if (typeof requestAnimationFrame !== 'undefined') {
|
|
2373
|
-
requestAnimationFrame(function () {
|
|
2374
|
-
var _this2$handlerConnect;
|
|
2375
|
-
|
|
2376
|
-
return (_this2$handlerConnect = _this2.handlerConnector) === null || _this2$handlerConnect === void 0 ? void 0 : _this2$handlerConnect.reconnect();
|
|
2377
|
-
});
|
|
2378
|
-
}
|
|
2379
|
-
|
|
2380
|
-
return jsx(Decorated, Object.assign({}, _this2.props, _this2.getCurrentState(), {
|
|
2381
|
-
// NOTE: if Decorated is a Function Component, decoratedRef will not be populated unless it's a refforwarding component.
|
|
2382
|
-
ref: isRefable(Decorated) ? _this2.decoratedRef : null
|
|
2383
|
-
}), void 0);
|
|
2384
|
-
}
|
|
2385
|
-
}, void 0);
|
|
2386
|
-
}
|
|
2387
|
-
}, {
|
|
2388
|
-
key: "receiveDragDropManager",
|
|
2389
|
-
value: function receiveDragDropManager(dragDropManager) {
|
|
2390
|
-
if (this.manager !== undefined) {
|
|
2391
|
-
return;
|
|
2392
|
-
}
|
|
2393
|
-
|
|
2394
|
-
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);
|
|
2395
|
-
|
|
2396
|
-
if (dragDropManager === undefined) {
|
|
2397
|
-
return;
|
|
2398
|
-
}
|
|
2399
|
-
|
|
2400
|
-
this.manager = dragDropManager;
|
|
2401
|
-
this.handlerMonitor = createMonitor(dragDropManager);
|
|
2402
|
-
this.handlerConnector = createConnector(dragDropManager.getBackend());
|
|
2403
|
-
this.handler = createHandler(this.handlerMonitor, this.decoratedRef);
|
|
2404
|
-
}
|
|
2405
|
-
}]);
|
|
2406
|
-
|
|
2407
|
-
return DragDropContainer;
|
|
2408
|
-
}(Component);
|
|
2409
|
-
|
|
2410
|
-
_defineProperty$2(DragDropContainer, "DecoratedComponent", DecoratedComponent);
|
|
2411
|
-
|
|
2412
|
-
_defineProperty$2(DragDropContainer, "displayName", "".concat(containerDisplayName, "(").concat(displayName, ")"));
|
|
2413
|
-
|
|
2414
|
-
return hoistStatics(DragDropContainer, DecoratedComponent);
|
|
2415
|
-
}
|
|
2416
|
-
|
|
2417
|
-
function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2418
|
-
|
|
2419
|
-
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); } }
|
|
2420
|
-
|
|
2421
|
-
function _createClass$1(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$1(Constructor.prototype, protoProps); if (staticProps) _defineProperties$1(Constructor, staticProps); return Constructor; }
|
|
2422
|
-
|
|
2423
|
-
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; }
|
|
2424
|
-
var ALLOWED_SPEC_METHODS$1 = ['canDrag', 'beginDrag', 'isDragging', 'endDrag'];
|
|
2425
|
-
var REQUIRED_SPEC_METHODS = ['beginDrag'];
|
|
2426
|
-
|
|
2427
|
-
var SourceImpl = /*#__PURE__*/function () {
|
|
2428
|
-
function SourceImpl(spec, monitor, ref) {
|
|
2429
|
-
var _this = this;
|
|
2430
|
-
|
|
2431
|
-
_classCallCheck$1(this, SourceImpl);
|
|
2432
|
-
|
|
2433
|
-
_defineProperty$1(this, "props", null);
|
|
2434
|
-
|
|
2435
|
-
_defineProperty$1(this, "spec", void 0);
|
|
2436
|
-
|
|
2437
|
-
_defineProperty$1(this, "monitor", void 0);
|
|
2438
|
-
|
|
2439
|
-
_defineProperty$1(this, "ref", void 0);
|
|
2440
|
-
|
|
2441
|
-
_defineProperty$1(this, "beginDrag", function () {
|
|
2442
|
-
if (!_this.props) {
|
|
2443
|
-
return;
|
|
2444
|
-
}
|
|
2445
|
-
|
|
2446
|
-
var item = _this.spec.beginDrag(_this.props, _this.monitor, _this.ref.current);
|
|
2447
|
-
|
|
2448
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2449
|
-
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);
|
|
2450
|
-
}
|
|
2451
|
-
|
|
2452
|
-
return item;
|
|
2453
|
-
});
|
|
2454
|
-
|
|
2455
|
-
this.spec = spec;
|
|
2456
|
-
this.monitor = monitor;
|
|
2457
|
-
this.ref = ref;
|
|
2458
|
-
}
|
|
2459
|
-
|
|
2460
|
-
_createClass$1(SourceImpl, [{
|
|
2461
|
-
key: "receiveProps",
|
|
2462
|
-
value: function receiveProps(props) {
|
|
2463
|
-
this.props = props;
|
|
2464
|
-
}
|
|
2465
|
-
}, {
|
|
2466
|
-
key: "canDrag",
|
|
2467
|
-
value: function canDrag() {
|
|
2468
|
-
if (!this.props) {
|
|
2469
|
-
return false;
|
|
2470
|
-
}
|
|
2471
|
-
|
|
2472
|
-
if (!this.spec.canDrag) {
|
|
2473
|
-
return true;
|
|
2474
|
-
}
|
|
2475
|
-
|
|
2476
|
-
return this.spec.canDrag(this.props, this.monitor);
|
|
2477
|
-
}
|
|
2478
|
-
}, {
|
|
2479
|
-
key: "isDragging",
|
|
2480
|
-
value: function isDragging(globalMonitor, sourceId) {
|
|
2481
|
-
if (!this.props) {
|
|
2482
|
-
return false;
|
|
2483
|
-
}
|
|
2484
|
-
|
|
2485
|
-
if (!this.spec.isDragging) {
|
|
2486
|
-
return sourceId === globalMonitor.getSourceId();
|
|
2487
|
-
}
|
|
2488
|
-
|
|
2489
|
-
return this.spec.isDragging(this.props, this.monitor);
|
|
2490
|
-
}
|
|
2491
|
-
}, {
|
|
2492
|
-
key: "endDrag",
|
|
2493
|
-
value: function endDrag() {
|
|
2494
|
-
if (!this.props) {
|
|
2495
|
-
return;
|
|
2496
|
-
}
|
|
2497
|
-
|
|
2498
|
-
if (!this.spec.endDrag) {
|
|
2499
|
-
return;
|
|
2500
|
-
}
|
|
2501
|
-
|
|
2502
|
-
this.spec.endDrag(this.props, this.monitor, getDecoratedComponent(this.ref));
|
|
2503
|
-
}
|
|
2504
|
-
}]);
|
|
2505
|
-
|
|
2506
|
-
return SourceImpl;
|
|
2507
|
-
}();
|
|
2508
|
-
|
|
2509
|
-
function createSourceFactory(spec) {
|
|
2510
|
-
Object.keys(spec).forEach(function (key) {
|
|
2511
|
-
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);
|
|
2512
|
-
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]);
|
|
2513
|
-
});
|
|
2514
|
-
REQUIRED_SPEC_METHODS.forEach(function (key) {
|
|
2515
|
-
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]);
|
|
2516
|
-
});
|
|
2517
|
-
return function createSource(monitor, ref) {
|
|
2518
|
-
return new SourceImpl(spec, monitor, ref);
|
|
2519
|
-
};
|
|
2520
|
-
}
|
|
2521
|
-
|
|
2522
|
-
/**
|
|
2523
|
-
* Decorates a component as a dragsource
|
|
2524
|
-
* @param type The dragsource type
|
|
2525
|
-
* @param spec The drag source specification
|
|
2526
|
-
* @param collect The props collector function
|
|
2527
|
-
* @param options DnD options
|
|
2528
|
-
*/
|
|
2529
|
-
|
|
2530
|
-
function DragSource(type, spec, collect) {
|
|
2531
|
-
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
2532
|
-
checkDecoratorArguments('DragSource', 'type, spec, collect[, options]', type, spec, collect, options);
|
|
2533
|
-
var getType = type;
|
|
2534
|
-
|
|
2535
|
-
if (typeof type !== 'function') {
|
|
2536
|
-
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);
|
|
2537
|
-
|
|
2538
|
-
getType = function getType() {
|
|
2539
|
-
return type;
|
|
2540
|
-
};
|
|
2541
|
-
}
|
|
2542
|
-
|
|
2543
|
-
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);
|
|
2544
|
-
var createSource = createSourceFactory(spec);
|
|
2545
|
-
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);
|
|
2546
|
-
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);
|
|
2547
|
-
return function decorateSource(DecoratedComponent) {
|
|
2548
|
-
return decorateHandler({
|
|
2549
|
-
containerDisplayName: 'DragSource',
|
|
2550
|
-
createHandler: createSource,
|
|
2551
|
-
registerHandler: registerSource,
|
|
2552
|
-
createConnector: function createConnector(backend) {
|
|
2553
|
-
return new SourceConnector(backend);
|
|
2554
|
-
},
|
|
2555
|
-
createMonitor: function createMonitor(manager) {
|
|
2556
|
-
return new DragSourceMonitorImpl(manager);
|
|
2557
|
-
},
|
|
2558
|
-
DecoratedComponent: DecoratedComponent,
|
|
2559
|
-
getType: getType,
|
|
2560
|
-
collect: collect,
|
|
2561
|
-
options: options
|
|
2562
|
-
});
|
|
2563
|
-
};
|
|
2564
|
-
}
|
|
2565
|
-
|
|
2566
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2567
|
-
|
|
2568
|
-
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); } }
|
|
2569
|
-
|
|
2570
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
2571
|
-
|
|
2572
|
-
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; }
|
|
2573
|
-
var ALLOWED_SPEC_METHODS = ['canDrop', 'hover', 'drop'];
|
|
2574
|
-
|
|
2575
|
-
var TargetImpl = /*#__PURE__*/function () {
|
|
2576
|
-
function TargetImpl(spec, monitor, ref) {
|
|
2577
|
-
_classCallCheck(this, TargetImpl);
|
|
2578
|
-
|
|
2579
|
-
_defineProperty(this, "props", null);
|
|
2580
|
-
|
|
2581
|
-
_defineProperty(this, "spec", void 0);
|
|
2582
|
-
|
|
2583
|
-
_defineProperty(this, "monitor", void 0);
|
|
2584
|
-
|
|
2585
|
-
_defineProperty(this, "ref", void 0);
|
|
2586
|
-
|
|
2587
|
-
this.spec = spec;
|
|
2588
|
-
this.monitor = monitor;
|
|
2589
|
-
this.ref = ref;
|
|
2590
|
-
}
|
|
2591
|
-
|
|
2592
|
-
_createClass(TargetImpl, [{
|
|
2593
|
-
key: "receiveProps",
|
|
2594
|
-
value: function receiveProps(props) {
|
|
2595
|
-
this.props = props;
|
|
2596
|
-
}
|
|
2597
|
-
}, {
|
|
2598
|
-
key: "receiveMonitor",
|
|
2599
|
-
value: function receiveMonitor(monitor) {
|
|
2600
|
-
this.monitor = monitor;
|
|
2601
|
-
}
|
|
2602
|
-
}, {
|
|
2603
|
-
key: "canDrop",
|
|
2604
|
-
value: function canDrop() {
|
|
2605
|
-
if (!this.spec.canDrop) {
|
|
2606
|
-
return true;
|
|
2607
|
-
}
|
|
2608
|
-
|
|
2609
|
-
return this.spec.canDrop(this.props, this.monitor);
|
|
2610
|
-
}
|
|
2611
|
-
}, {
|
|
2612
|
-
key: "hover",
|
|
2613
|
-
value: function hover() {
|
|
2614
|
-
if (!this.spec.hover || !this.props) {
|
|
2615
|
-
return;
|
|
2616
|
-
}
|
|
2617
|
-
|
|
2618
|
-
this.spec.hover(this.props, this.monitor, getDecoratedComponent(this.ref));
|
|
2619
|
-
}
|
|
2620
|
-
}, {
|
|
2621
|
-
key: "drop",
|
|
2622
|
-
value: function drop() {
|
|
2623
|
-
if (!this.spec.drop) {
|
|
2624
|
-
return undefined;
|
|
2625
|
-
}
|
|
2626
|
-
|
|
2627
|
-
var dropResult = this.spec.drop(this.props, this.monitor, this.ref.current);
|
|
2628
|
-
|
|
2629
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2630
|
-
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);
|
|
2631
|
-
}
|
|
2632
|
-
|
|
2633
|
-
return dropResult;
|
|
2634
|
-
}
|
|
2635
|
-
}]);
|
|
2636
|
-
|
|
2637
|
-
return TargetImpl;
|
|
2638
|
-
}();
|
|
2639
|
-
|
|
2640
|
-
function createTargetFactory(spec) {
|
|
2641
|
-
Object.keys(spec).forEach(function (key) {
|
|
2642
|
-
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);
|
|
2643
|
-
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]);
|
|
2644
|
-
});
|
|
2645
|
-
return function createTarget(monitor, ref) {
|
|
2646
|
-
return new TargetImpl(spec, monitor, ref);
|
|
2647
|
-
};
|
|
2648
|
-
}
|
|
2649
|
-
|
|
2650
|
-
/**
|
|
2651
|
-
* @param type The accepted target type
|
|
2652
|
-
* @param spec The DropTarget specification
|
|
2653
|
-
* @param collect The props collector function
|
|
2654
|
-
* @param options Options
|
|
2655
|
-
*/
|
|
2656
|
-
|
|
2657
|
-
function DropTarget(type, spec, collect) {
|
|
2658
|
-
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
2659
|
-
checkDecoratorArguments('DropTarget', 'type, spec, collect[, options]', type, spec, collect, options);
|
|
2660
|
-
var getType = type;
|
|
2661
|
-
|
|
2662
|
-
if (typeof type !== 'function') {
|
|
2663
|
-
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);
|
|
2664
|
-
|
|
2665
|
-
getType = function getType() {
|
|
2666
|
-
return type;
|
|
2667
|
-
};
|
|
2668
|
-
}
|
|
2669
|
-
|
|
2670
|
-
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);
|
|
2671
|
-
var createTarget = createTargetFactory(spec);
|
|
2672
|
-
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);
|
|
2673
|
-
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);
|
|
2674
|
-
return function decorateTarget(DecoratedComponent) {
|
|
2675
|
-
return decorateHandler({
|
|
2676
|
-
containerDisplayName: 'DropTarget',
|
|
2677
|
-
createHandler: createTarget,
|
|
2678
|
-
registerHandler: registerTarget,
|
|
2679
|
-
createMonitor: function createMonitor(manager) {
|
|
2680
|
-
return new DropTargetMonitorImpl(manager);
|
|
2681
|
-
},
|
|
2682
|
-
createConnector: function createConnector(backend) {
|
|
2683
|
-
return new TargetConnector(backend);
|
|
2684
|
-
},
|
|
2685
|
-
DecoratedComponent: DecoratedComponent,
|
|
2686
|
-
getType: getType,
|
|
2687
|
-
collect: collect,
|
|
2688
|
-
options: options
|
|
2689
|
-
});
|
|
2690
|
-
};
|
|
2691
|
-
}
|
|
2692
|
-
|
|
2693
|
-
const log$2 = debug('@pie-element:placement-ordering:configure:choice-tile');
|
|
2694
|
-
class ChoiceTile extends React.Component {
|
|
2695
|
-
constructor(...args) {
|
|
2696
|
-
super(...args);
|
|
2697
|
-
|
|
2698
|
-
this.onLabelChange = label => {
|
|
2699
|
-
const {
|
|
2700
|
-
choice,
|
|
2701
|
-
onChoiceChange
|
|
2702
|
-
} = this.props;
|
|
2703
|
-
choice.label = label;
|
|
2704
|
-
onChoiceChange(choice);
|
|
2705
|
-
};
|
|
2706
|
-
}
|
|
2707
|
-
|
|
2708
|
-
render() {
|
|
2709
|
-
const {
|
|
2710
|
-
choice: {
|
|
2711
|
-
label,
|
|
2712
|
-
editable,
|
|
2713
|
-
type
|
|
2714
|
-
},
|
|
2715
|
-
isDragging,
|
|
2716
|
-
connectDragSource,
|
|
2717
|
-
connectDropTarget,
|
|
2718
|
-
classes,
|
|
2719
|
-
onDelete,
|
|
2720
|
-
imageSupport,
|
|
2721
|
-
spellCheck,
|
|
2722
|
-
toolbarOpts,
|
|
2723
|
-
pluginProps,
|
|
2724
|
-
maxImageWidth,
|
|
2725
|
-
maxImageHeight,
|
|
2726
|
-
error,
|
|
2727
|
-
mathMlOptions = {}
|
|
2728
|
-
} = this.props;
|
|
2729
|
-
const dragSourceOpts = {}; //dropEffect: moveOnDrag ? 'move' : 'copy'};
|
|
2730
|
-
|
|
2731
|
-
const filteredDefaultPlugins = (DEFAULT_PLUGINS || []).filter(p => p !== 'bulleted-list' && p !== 'numbered-list');
|
|
2732
|
-
const opacity = isDragging ? 0 : 1;
|
|
2733
|
-
const markup = /*#__PURE__*/React.createElement("div", {
|
|
2734
|
-
className: classes.choiceTile,
|
|
2735
|
-
style: {
|
|
2736
|
-
opacity: opacity,
|
|
2737
|
-
width: '100%'
|
|
2738
|
-
}
|
|
2739
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
2740
|
-
style: {
|
|
2741
|
-
width: '100%',
|
|
2742
|
-
display: 'flex'
|
|
2743
|
-
}
|
|
2744
|
-
}, /*#__PURE__*/React.createElement(CardActions, null, /*#__PURE__*/React.createElement("span", {
|
|
2745
|
-
className: classNames(classes.dragHandle)
|
|
2746
|
-
}, /*#__PURE__*/React.createElement(DragHandle, {
|
|
2747
|
-
className: classes.actions
|
|
2748
|
-
}))), /*#__PURE__*/React.createElement(EditableHtml, {
|
|
2749
|
-
disabled: !editable,
|
|
2750
|
-
className: classNames(classes.prompt, !editable && classes.targetPrompt),
|
|
2751
|
-
placeholder: type !== 'target' && !label.includes('data-latex') ? 'Enter a choice' : '',
|
|
2752
|
-
markup: label,
|
|
2753
|
-
imageSupport: imageSupport || undefined,
|
|
2754
|
-
onChange: this.onLabelChange,
|
|
2755
|
-
pluginProps: pluginProps,
|
|
2756
|
-
toolbarOpts: toolbarOpts,
|
|
2757
|
-
activePlugins: filteredDefaultPlugins,
|
|
2758
|
-
spellCheck: spellCheck,
|
|
2759
|
-
autoWidthToolbar: true,
|
|
2760
|
-
maxImageWidth: maxImageWidth,
|
|
2761
|
-
maxImageHeight: maxImageHeight,
|
|
2762
|
-
languageCharactersProps: [{
|
|
2763
|
-
language: 'spanish'
|
|
2764
|
-
}, {
|
|
2765
|
-
language: 'special'
|
|
2766
|
-
}],
|
|
2767
|
-
error: editable && error,
|
|
2768
|
-
mathMlOptions: mathMlOptions
|
|
2769
|
-
}), editable && /*#__PURE__*/React.createElement("div", {
|
|
2770
|
-
className: classes.controls
|
|
2771
|
-
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
2772
|
-
className: classes.customColor,
|
|
2773
|
-
onClick: onDelete
|
|
2774
|
-
}, /*#__PURE__*/React.createElement(RemoveCircle, {
|
|
2775
|
-
classes: {
|
|
2776
|
-
root: classes.removeCircle
|
|
2777
|
-
}
|
|
2778
|
-
})))), editable && error && /*#__PURE__*/React.createElement("div", {
|
|
2779
|
-
className: classes.errorText
|
|
2780
|
-
}, error));
|
|
2781
|
-
return connectDragSource(connectDropTarget( /*#__PURE__*/React.createElement("div", null, markup)), dragSourceOpts);
|
|
2782
|
-
}
|
|
2783
|
-
|
|
2784
|
-
}
|
|
2785
|
-
ChoiceTile.propTypes = {
|
|
2786
|
-
connectDragSource: PropTypes.func.isRequired,
|
|
2787
|
-
connectDropTarget: PropTypes.func.isRequired,
|
|
2788
|
-
isDragging: PropTypes.bool.isRequired,
|
|
2789
|
-
id: PropTypes.any,
|
|
2790
|
-
maxImageHeight: PropTypes.object,
|
|
2791
|
-
maxImageWidth: PropTypes.object,
|
|
2792
|
-
label: PropTypes.string,
|
|
2793
|
-
isOver: PropTypes.bool,
|
|
2794
|
-
classes: PropTypes.object.isRequired,
|
|
2795
|
-
type: PropTypes.string,
|
|
2796
|
-
empty: PropTypes.bool,
|
|
2797
|
-
disabled: PropTypes.bool,
|
|
2798
|
-
outcome: PropTypes.object,
|
|
2799
|
-
index: PropTypes.number,
|
|
2800
|
-
imageSupport: PropTypes.shape({
|
|
2801
|
-
add: PropTypes.func.isRequired,
|
|
2802
|
-
delete: PropTypes.func.isRequired
|
|
2803
|
-
}),
|
|
2804
|
-
choice: PropTypes.object,
|
|
2805
|
-
choices: PropTypes.array.isRequired,
|
|
2806
|
-
onChoiceChange: PropTypes.func.isRequired,
|
|
2807
|
-
onDelete: PropTypes.func.isRequired,
|
|
2808
|
-
toolbarOpts: PropTypes.object,
|
|
2809
|
-
pluginProps: PropTypes.object,
|
|
2810
|
-
choicesLabel: PropTypes.string,
|
|
2811
|
-
error: PropTypes.string,
|
|
2812
|
-
spellCheck: PropTypes.bool
|
|
2813
|
-
};
|
|
2814
|
-
const Styled = withStyles(theme => ({
|
|
2815
|
-
removeCircle: {
|
|
2816
|
-
fill: theme.palette.error[500]
|
|
2817
|
-
},
|
|
2818
|
-
choiceTile: {
|
|
2819
|
-
cursor: 'move',
|
|
2820
|
-
backgroundColor: theme.palette.common.white,
|
|
2821
|
-
margin: `${theme.spacing.unit}px 0`,
|
|
2822
|
-
display: 'flex',
|
|
2823
|
-
flexDirection: 'column'
|
|
2824
|
-
},
|
|
2825
|
-
controls: {
|
|
2826
|
-
display: 'flex',
|
|
2827
|
-
justifyContent: 'flex-end'
|
|
2828
|
-
},
|
|
2829
|
-
prompt: {
|
|
2830
|
-
width: '80%',
|
|
2831
|
-
border: 'none',
|
|
2832
|
-
borderRadius: '4px'
|
|
2833
|
-
},
|
|
2834
|
-
targetPrompt: {
|
|
2835
|
-
backgroundColor: theme.palette.error['A100']
|
|
2836
|
-
},
|
|
2837
|
-
actions: {
|
|
2838
|
-
color: theme.palette.error[400]
|
|
2839
|
-
},
|
|
2840
|
-
errorText: {
|
|
2841
|
-
fontSize: theme.typography.fontSize - 2,
|
|
2842
|
-
color: theme.palette.error.main,
|
|
2843
|
-
marginLeft: theme.spacing.unit * 5,
|
|
2844
|
-
marginTop: theme.spacing.unit
|
|
2845
|
-
},
|
|
2846
|
-
correctOrder: {
|
|
2847
|
-
position: 'absolute',
|
|
2848
|
-
top: 0,
|
|
2849
|
-
fontSize: theme.typography.fontSize - 2,
|
|
2850
|
-
color: color.disabled()
|
|
2851
|
-
},
|
|
2852
|
-
customColor: {
|
|
2853
|
-
color: `${color.tertiary()} !important`
|
|
2854
|
-
}
|
|
2855
|
-
}))(ChoiceTile);
|
|
2856
|
-
const NAME = 'choice-config';
|
|
2857
|
-
const choiceSource = {
|
|
2858
|
-
beginDrag(props) {
|
|
2859
|
-
return {
|
|
2860
|
-
id: props.choice.id,
|
|
2861
|
-
index: props.index,
|
|
2862
|
-
type: props.choice.type,
|
|
2863
|
-
instanceId: props.choice.instanceId
|
|
2864
|
-
};
|
|
2865
|
-
}
|
|
2866
|
-
|
|
2867
|
-
};
|
|
2868
|
-
const StyledSource = DragSource(NAME, choiceSource, (connect, monitor) => ({
|
|
2869
|
-
connectDragSource: connect.dragSource(),
|
|
2870
|
-
isDragging: monitor.isDragging()
|
|
2871
|
-
}))(Styled);
|
|
2872
|
-
const choiceTarget = {
|
|
2873
|
-
hover() {
|
|
2874
|
-
log$2('[hover]');
|
|
2875
|
-
},
|
|
2876
|
-
|
|
2877
|
-
drop(props, monitor) {
|
|
2878
|
-
const item = monitor.getItem();
|
|
2879
|
-
log$2('[drop] item: ', item, 'didDrop?', monitor.didDrop());
|
|
2880
|
-
props.onDropChoice(item, props.index);
|
|
2881
|
-
}
|
|
2882
|
-
|
|
2883
|
-
};
|
|
2884
|
-
const StyledSourceAndTarget = DropTarget(NAME, choiceTarget, (connect, monitor) => ({
|
|
2885
|
-
connectDropTarget: connect.dropTarget(),
|
|
2886
|
-
isOver: monitor.isOver()
|
|
2887
|
-
}))(StyledSource);
|
|
2888
|
-
|
|
2889
|
-
function findFreeChoiceSlot(choices) {
|
|
2890
|
-
let slot = 1;
|
|
2891
|
-
const ids = choices.map(c => c.id);
|
|
2892
|
-
|
|
2893
|
-
while (ids.includes(`c${slot}`)) {
|
|
2894
|
-
slot++;
|
|
2895
|
-
}
|
|
2896
|
-
|
|
2897
|
-
return slot;
|
|
2898
|
-
}
|
|
2899
|
-
|
|
2900
|
-
const log$1 = debug('@pie-element:placement-ordering:configure:choice-editor');
|
|
2901
|
-
|
|
2902
|
-
function updateResponseOrChoices(response, choices, from, to) {
|
|
2903
|
-
const {
|
|
2904
|
-
type: fromType,
|
|
2905
|
-
index: fromIndex
|
|
2906
|
-
} = from;
|
|
2907
|
-
const {
|
|
2908
|
-
type: toType,
|
|
2909
|
-
index: placeAtIndex
|
|
2910
|
-
} = to;
|
|
2911
|
-
|
|
2912
|
-
if (fromType === 'target' && toType === 'target') {
|
|
2913
|
-
const updatedResponse = cloneDeep(response) || [];
|
|
2914
|
-
const {
|
|
2915
|
-
movedItem,
|
|
2916
|
-
remainingItems
|
|
2917
|
-
} = updatedResponse.reduce((acc, item, index) => {
|
|
2918
|
-
if (index === fromIndex) {
|
|
2919
|
-
acc.movedItem = item;
|
|
2920
|
-
} else {
|
|
2921
|
-
acc.remainingItems.push(item);
|
|
2922
|
-
}
|
|
2923
|
-
|
|
2924
|
-
return acc;
|
|
2925
|
-
}, {
|
|
2926
|
-
movedItem: null,
|
|
2927
|
-
remainingItems: []
|
|
2928
|
-
});
|
|
2929
|
-
return {
|
|
2930
|
-
response: [...remainingItems.slice(0, placeAtIndex), movedItem, ...remainingItems.slice(placeAtIndex)],
|
|
2931
|
-
choices
|
|
2932
|
-
};
|
|
2933
|
-
}
|
|
2934
|
-
|
|
2935
|
-
if (fromType === 'choice' && toType === 'choice') {
|
|
2936
|
-
const updatedChoices = cloneDeep(choices) || [];
|
|
2937
|
-
const {
|
|
2938
|
-
movedItem,
|
|
2939
|
-
remainingItems,
|
|
2940
|
-
toIndex
|
|
2941
|
-
} = updatedChoices.reduce((acc, item, index) => {
|
|
2942
|
-
if (item.id === from.id) {
|
|
2943
|
-
acc.movedItem = item;
|
|
2944
|
-
} else {
|
|
2945
|
-
acc.remainingItems.push(item);
|
|
2946
|
-
}
|
|
2947
|
-
|
|
2948
|
-
if (item.id === to.id) {
|
|
2949
|
-
acc.toIndex = index;
|
|
2950
|
-
}
|
|
2951
|
-
|
|
2952
|
-
return acc;
|
|
2953
|
-
}, {
|
|
2954
|
-
movedItem: null,
|
|
2955
|
-
remainingItems: [],
|
|
2956
|
-
toIndex: null
|
|
2957
|
-
});
|
|
2958
|
-
return {
|
|
2959
|
-
response,
|
|
2960
|
-
choices: [...remainingItems.slice(0, toIndex), movedItem, ...remainingItems.slice(toIndex)]
|
|
2961
|
-
};
|
|
2962
|
-
}
|
|
2963
|
-
|
|
2964
|
-
return {
|
|
2965
|
-
response,
|
|
2966
|
-
choices
|
|
2967
|
-
};
|
|
2968
|
-
}
|
|
2969
|
-
|
|
2970
|
-
function buildTiles(choices, response, instanceId) {
|
|
2971
|
-
const targets = response.map((r, index) => {
|
|
2972
|
-
const respId = r && r.id;
|
|
2973
|
-
const choice = choices.find(c => respId !== undefined && respId !== null && c.id === respId);
|
|
2974
|
-
return _extends({
|
|
2975
|
-
type: 'target',
|
|
2976
|
-
instanceId
|
|
2977
|
-
}, choice, {
|
|
2978
|
-
draggable: true,
|
|
2979
|
-
index,
|
|
2980
|
-
editable: false
|
|
2981
|
-
});
|
|
2982
|
-
});
|
|
2983
|
-
const processedChoices = choices.map(m => {
|
|
2984
|
-
return Object.assign({}, m, {
|
|
2985
|
-
type: 'choice',
|
|
2986
|
-
droppable: false,
|
|
2987
|
-
draggable: true,
|
|
2988
|
-
instanceId,
|
|
2989
|
-
editable: true
|
|
2990
|
-
});
|
|
2991
|
-
});
|
|
2992
|
-
return processedChoices.concat(targets);
|
|
2993
|
-
}
|
|
2994
|
-
|
|
2995
|
-
class ChoiceEditor extends React.Component {
|
|
2996
|
-
constructor(props) {
|
|
2997
|
-
super(props);
|
|
2998
|
-
this.state = {
|
|
2999
|
-
warning: {
|
|
3000
|
-
open: false
|
|
3001
|
-
}
|
|
3002
|
-
};
|
|
3003
|
-
this.instanceId = uniqueId();
|
|
3004
|
-
|
|
3005
|
-
this.onChoiceChange = choice => {
|
|
3006
|
-
const {
|
|
3007
|
-
choices,
|
|
3008
|
-
onChange,
|
|
3009
|
-
correctResponse
|
|
3010
|
-
} = this.props;
|
|
3011
|
-
const index = choices.findIndex(c => c.id === choice.id);
|
|
3012
|
-
choices.splice(index, 1, _extends({}, choices[index], {
|
|
3013
|
-
label: choice.label
|
|
3014
|
-
}));
|
|
3015
|
-
onChange(choices, correctResponse);
|
|
3016
|
-
};
|
|
3017
|
-
|
|
3018
|
-
this.onDelete = choice => {
|
|
3019
|
-
const {
|
|
3020
|
-
choices,
|
|
3021
|
-
onChange,
|
|
3022
|
-
correctResponse,
|
|
3023
|
-
choicesLabel
|
|
3024
|
-
} = this.props;
|
|
3025
|
-
|
|
3026
|
-
if (choices && choices.length === 3) {
|
|
3027
|
-
this.setState({
|
|
3028
|
-
warning: {
|
|
3029
|
-
open: true,
|
|
3030
|
-
text: `There have to be at least 3 ${choicesLabel}.`
|
|
3031
|
-
}
|
|
3032
|
-
});
|
|
3033
|
-
} else {
|
|
3034
|
-
const updatedChoices = choices.filter(c => c.id !== choice.id);
|
|
3035
|
-
const updatedCorrectResponse = correctResponse.filter(v => v.id !== choice.id);
|
|
3036
|
-
onChange(updatedChoices, updatedCorrectResponse);
|
|
3037
|
-
}
|
|
3038
|
-
};
|
|
3039
|
-
|
|
3040
|
-
this.addChoice = () => {
|
|
3041
|
-
const {
|
|
3042
|
-
choices,
|
|
3043
|
-
correctResponse,
|
|
3044
|
-
onChange,
|
|
3045
|
-
choicesLabel
|
|
3046
|
-
} = this.props;
|
|
3047
|
-
|
|
3048
|
-
if (choices && choices.length === 10) {
|
|
3049
|
-
this.setState({
|
|
3050
|
-
warning: {
|
|
3051
|
-
open: true,
|
|
3052
|
-
text: `There can be maximum 10 ${choicesLabel}.`
|
|
3053
|
-
}
|
|
3054
|
-
});
|
|
3055
|
-
} else {
|
|
3056
|
-
const freeId = findFreeChoiceSlot(choices);
|
|
3057
|
-
const id = `c${freeId}`;
|
|
3058
|
-
const newChoice = {
|
|
3059
|
-
id,
|
|
3060
|
-
label: ''
|
|
3061
|
-
};
|
|
3062
|
-
const newCorrectResponse = {
|
|
3063
|
-
id,
|
|
3064
|
-
|
|
3065
|
-
/**
|
|
3066
|
-
* Note: weights are not configurable in the existing component
|
|
3067
|
-
* so we'll want do disable this in the controller and ignore it for now.
|
|
3068
|
-
*/
|
|
3069
|
-
weight: 0
|
|
3070
|
-
};
|
|
3071
|
-
const updatedChoices = choices.concat([newChoice]);
|
|
3072
|
-
const updatedCorrectResponse = correctResponse.concat([newCorrectResponse]);
|
|
3073
|
-
onChange(updatedChoices, updatedCorrectResponse);
|
|
3074
|
-
}
|
|
3075
|
-
};
|
|
3076
|
-
|
|
3077
|
-
this.shuffleChoices = () => {
|
|
3078
|
-
const {
|
|
3079
|
-
onChange,
|
|
3080
|
-
choices,
|
|
3081
|
-
correctResponse,
|
|
3082
|
-
placementArea
|
|
3083
|
-
} = this.props;
|
|
3084
|
-
let shuffled = shuffle(choices); // if placementArea is disabled, make sure we don't shuffle choices in the correct order
|
|
3085
|
-
|
|
3086
|
-
const shuffledCorrect = !placementArea && isEqual(shuffled.map(item => item.id), correctResponse.map(item => item.id));
|
|
3087
|
-
|
|
3088
|
-
if (shuffledCorrect) {
|
|
3089
|
-
const shuffledTwice = shuffle(shuffled);
|
|
3090
|
-
onChange(shuffledTwice, correctResponse);
|
|
3091
|
-
} else {
|
|
3092
|
-
onChange(shuffled, correctResponse);
|
|
3093
|
-
}
|
|
3094
|
-
};
|
|
3095
|
-
|
|
3096
|
-
this.onDropChoice = (ordering, target, source) => {
|
|
3097
|
-
const {
|
|
3098
|
-
onChange
|
|
3099
|
-
} = this.props;
|
|
3100
|
-
const from = ordering.tiles.find(t => t.id === source.id && t.type === source.type);
|
|
3101
|
-
const to = target;
|
|
3102
|
-
log$1('[onDropChoice] ', from, to);
|
|
3103
|
-
const {
|
|
3104
|
-
response,
|
|
3105
|
-
choices
|
|
3106
|
-
} = updateResponseOrChoices(ordering.response, ordering.choices, from, to);
|
|
3107
|
-
onChange(choices, response);
|
|
3108
|
-
};
|
|
3109
|
-
}
|
|
3110
|
-
|
|
3111
|
-
render() {
|
|
3112
|
-
const {
|
|
3113
|
-
classes,
|
|
3114
|
-
correctResponse,
|
|
3115
|
-
choices,
|
|
3116
|
-
imageSupport,
|
|
3117
|
-
toolbarOpts,
|
|
3118
|
-
pluginProps,
|
|
3119
|
-
singularChoiceLabel,
|
|
3120
|
-
pluralChoiceLabel,
|
|
3121
|
-
choicesLabel,
|
|
3122
|
-
spellCheck,
|
|
3123
|
-
maxImageWidth,
|
|
3124
|
-
maxImageHeight,
|
|
3125
|
-
errors,
|
|
3126
|
-
mathMlOptions = {}
|
|
3127
|
-
} = this.props;
|
|
3128
|
-
const {
|
|
3129
|
-
warning
|
|
3130
|
-
} = this.state;
|
|
3131
|
-
const {
|
|
3132
|
-
choicesErrors,
|
|
3133
|
-
orderError
|
|
3134
|
-
} = errors || {};
|
|
3135
|
-
const ordering = {
|
|
3136
|
-
choices,
|
|
3137
|
-
response: !correctResponse || isEmpty(correctResponse) ? new Array(choices.length) : correctResponse,
|
|
3138
|
-
tiles: buildTiles(choices, correctResponse, this.instanceId)
|
|
3139
|
-
};
|
|
3140
|
-
const vTilerStyle = {
|
|
3141
|
-
gridTemplateColumns: 'repeat(2, 1fr)',
|
|
3142
|
-
gridTemplateRows: `repeat(${choices.length}, 1fr)`
|
|
3143
|
-
};
|
|
3144
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
3145
|
-
className: classes.choiceEditor
|
|
3146
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
3147
|
-
className: classes.vtiler,
|
|
3148
|
-
style: {
|
|
3149
|
-
gridTemplateColumns: 'repeat(2, 1fr)'
|
|
3150
|
-
}
|
|
3151
|
-
}, /*#__PURE__*/React.createElement(InputContainer, {
|
|
3152
|
-
label: `Student ${choicesLabel || 'Choices'}`,
|
|
3153
|
-
className: classes.columnLabel
|
|
3154
|
-
}), /*#__PURE__*/React.createElement(InputContainer, {
|
|
3155
|
-
label: "Correct Order",
|
|
3156
|
-
className: classes.columnLabel
|
|
3157
|
-
})), /*#__PURE__*/React.createElement("div", {
|
|
3158
|
-
className: classes.vtiler,
|
|
3159
|
-
style: vTilerStyle
|
|
3160
|
-
}, ordering.tiles.map((choice, index) => /*#__PURE__*/React.createElement(StyledSourceAndTarget, {
|
|
3161
|
-
choice: choice,
|
|
3162
|
-
index: index,
|
|
3163
|
-
key: index,
|
|
3164
|
-
imageSupport: imageSupport,
|
|
3165
|
-
onDelete: this.onDelete.bind(this, choice),
|
|
3166
|
-
onChoiceChange: this.onChoiceChange,
|
|
3167
|
-
onDropChoice: (source, index) => this.onDropChoice(ordering, choice, source, index),
|
|
3168
|
-
toolbarOpts: toolbarOpts,
|
|
3169
|
-
pluginProps: pluginProps,
|
|
3170
|
-
choices: choices,
|
|
3171
|
-
choicesLabel: choicesLabel,
|
|
3172
|
-
spellCheck: spellCheck,
|
|
3173
|
-
maxImageWidth: maxImageWidth,
|
|
3174
|
-
maxImageHeight: maxImageHeight,
|
|
3175
|
-
error: (choicesErrors == null ? void 0 : choicesErrors[choice.id]) || orderError && ' ' || null,
|
|
3176
|
-
mathMlOptions: mathMlOptions
|
|
3177
|
-
}))), orderError && /*#__PURE__*/React.createElement("div", {
|
|
3178
|
-
className: classes.errorText
|
|
3179
|
-
}, orderError), /*#__PURE__*/React.createElement("div", {
|
|
3180
|
-
className: classes.controls
|
|
3181
|
-
}, /*#__PURE__*/React.createElement(Button, {
|
|
3182
|
-
onClick: this.shuffleChoices,
|
|
3183
|
-
size: "small",
|
|
3184
|
-
variant: "contained",
|
|
3185
|
-
color: "default",
|
|
3186
|
-
classes: {
|
|
3187
|
-
root: classes.addButtonRoot,
|
|
3188
|
-
label: classes.addButtonLabel
|
|
3189
|
-
}
|
|
3190
|
-
}, `SHUFFLE ${pluralChoiceLabel}`.toUpperCase()), /*#__PURE__*/React.createElement(Button, {
|
|
3191
|
-
onClick: this.addChoice,
|
|
3192
|
-
size: "small",
|
|
3193
|
-
variant: "contained",
|
|
3194
|
-
color: "default",
|
|
3195
|
-
classes: {
|
|
3196
|
-
root: classes.addButtonRoot,
|
|
3197
|
-
label: classes.addButtonLabel
|
|
3198
|
-
}
|
|
3199
|
-
}, `ADD ${singularChoiceLabel}`.toUpperCase())), /*#__PURE__*/React.createElement(AlertDialog, {
|
|
3200
|
-
open: warning.open,
|
|
3201
|
-
title: "Warning",
|
|
3202
|
-
text: warning.text,
|
|
3203
|
-
onConfirm: () => this.setState({
|
|
3204
|
-
warning: {
|
|
3205
|
-
open: false
|
|
3206
|
-
}
|
|
3207
|
-
})
|
|
3208
|
-
}));
|
|
3209
|
-
}
|
|
3210
|
-
|
|
3211
|
-
}
|
|
3212
|
-
|
|
3213
|
-
ChoiceEditor.propTypes = {
|
|
3214
|
-
classes: PropTypes.object.isRequired,
|
|
3215
|
-
correctResponse: PropTypes.array.isRequired,
|
|
3216
|
-
choices: PropTypes.array.isRequired,
|
|
3217
|
-
onChange: PropTypes.func.isRequired,
|
|
3218
|
-
imageSupport: PropTypes.shape({
|
|
3219
|
-
add: PropTypes.func.isRequired,
|
|
3220
|
-
delete: PropTypes.func.isRequired
|
|
3221
|
-
}),
|
|
3222
|
-
maxImageHeight: PropTypes.object,
|
|
3223
|
-
maxImageWidth: PropTypes.object,
|
|
3224
|
-
toolbarOpts: PropTypes.object,
|
|
3225
|
-
pluginProps: PropTypes.object,
|
|
3226
|
-
placementArea: PropTypes.bool,
|
|
3227
|
-
singularChoiceLabel: PropTypes.string,
|
|
3228
|
-
pluralChoiceLabel: PropTypes.string,
|
|
3229
|
-
choicesLabel: PropTypes.string,
|
|
3230
|
-
errors: PropTypes.object,
|
|
3231
|
-
spellCheck: PropTypes.bool
|
|
3232
|
-
};
|
|
3233
|
-
|
|
3234
|
-
const styles = theme => ({
|
|
3235
|
-
allToggle: {},
|
|
3236
|
-
choiceEditor: {},
|
|
3237
|
-
controls: {
|
|
3238
|
-
display: 'flex',
|
|
3239
|
-
alignItems: 'center',
|
|
3240
|
-
justifyContent: 'space-between'
|
|
3241
|
-
},
|
|
3242
|
-
root: {
|
|
3243
|
-
width: '30px',
|
|
3244
|
-
height: '30px',
|
|
3245
|
-
fill: theme.palette.primary[500]
|
|
3246
|
-
},
|
|
3247
|
-
addButtonRoot: {
|
|
3248
|
-
marginTop: theme.spacing.unit * 2.5,
|
|
3249
|
-
paddingHorizontal: theme.spacing.unit * 1.5
|
|
3250
|
-
},
|
|
3251
|
-
addButtonLabel: {
|
|
3252
|
-
transition: 'opacity 200ms linear',
|
|
3253
|
-
'&:hover': {
|
|
3254
|
-
opacity: 0.3
|
|
3255
|
-
}
|
|
3256
|
-
},
|
|
3257
|
-
vtiler: {
|
|
3258
|
-
gridAutoFlow: 'column',
|
|
3259
|
-
display: 'grid',
|
|
3260
|
-
gridGap: '10px',
|
|
3261
|
-
alignItems: 'center'
|
|
3262
|
-
},
|
|
3263
|
-
columnLabel: {
|
|
3264
|
-
width: '100%',
|
|
3265
|
-
paddingTop: theme.spacing.unit * 2
|
|
3266
|
-
},
|
|
3267
|
-
errorText: {
|
|
3268
|
-
fontSize: theme.typography.fontSize - 2,
|
|
3269
|
-
color: theme.palette.error.main,
|
|
3270
|
-
paddingTop: theme.spacing.unit
|
|
3271
|
-
}
|
|
3272
|
-
});
|
|
3273
|
-
|
|
3274
|
-
var ChoiceEditor$1 = withStyles(styles)(ChoiceEditor);
|
|
3275
|
-
|
|
3276
|
-
const generateValidationMessage = () => {
|
|
3277
|
-
const answersMessage = '\nThere should be at least 3 tokens.' + '\nThe tokens should not be empty and should be unique.' + '\nThe correct ordering should not be identical to the initial ordering.';
|
|
3278
|
-
return 'Validation requirements:' + answersMessage;
|
|
3279
|
-
};
|
|
3280
|
-
|
|
3281
|
-
const log = debug('@pie-element:placement-ordering:design');
|
|
3282
|
-
const {
|
|
3283
|
-
Panel,
|
|
3284
|
-
toggle,
|
|
3285
|
-
radio,
|
|
3286
|
-
dropdown
|
|
3287
|
-
} = settings;
|
|
3288
|
-
|
|
3289
|
-
const getSingularAndPlural = label => !pluralize.isPlural(label) ? {
|
|
3290
|
-
singularLabel: label,
|
|
3291
|
-
pluralLabel: pluralize(label)
|
|
3292
|
-
} : {
|
|
3293
|
-
singularLabel: pluralize.singular(label),
|
|
3294
|
-
pluralLabel: label
|
|
3295
|
-
};
|
|
3296
|
-
|
|
3297
|
-
class Design extends React.Component {
|
|
3298
|
-
constructor(props) {
|
|
3299
|
-
super(props);
|
|
3300
|
-
|
|
3301
|
-
this.applyUpdate = modelFn => {
|
|
3302
|
-
const {
|
|
3303
|
-
model,
|
|
3304
|
-
onModelChanged
|
|
3305
|
-
} = this.props;
|
|
3306
|
-
const update = modelFn(cloneDeep(model));
|
|
3307
|
-
onModelChanged(update);
|
|
3308
|
-
};
|
|
3309
|
-
|
|
3310
|
-
this.changeHandler = (modelPath, valuePath) => {
|
|
3311
|
-
return value => {
|
|
3312
|
-
log('[changeHandler] value: ', value);
|
|
3313
|
-
const v = valuePath ? nestedProperty.get(value, valuePath) : value;
|
|
3314
|
-
this.applyUpdate(model => {
|
|
3315
|
-
nestedProperty.set(model, modelPath, v);
|
|
3316
|
-
return model;
|
|
3317
|
-
});
|
|
3318
|
-
};
|
|
3319
|
-
};
|
|
3320
|
-
|
|
3321
|
-
this.onPromptChange = this.changeHandler('prompt');
|
|
3322
|
-
this.onTeacherInstructionsChange = this.changeHandler('teacherInstructions');
|
|
3323
|
-
this.onRationaleChange = this.changeHandler('rationale');
|
|
3324
|
-
this.onChoiceAreaLabelChange = this.changeHandler('choiceLabel', 'target.value');
|
|
3325
|
-
this.onAnswerAreaLabelChange = this.changeHandler('targetLabel', 'target.value');
|
|
3326
|
-
this.onFeedbackChange = this.changeHandler('feedback');
|
|
3327
|
-
|
|
3328
|
-
this.onChoiceEditorChange = (choices, correctResponse) => {
|
|
3329
|
-
const {
|
|
3330
|
-
model,
|
|
3331
|
-
onModelChanged
|
|
3332
|
-
} = this.props;
|
|
3333
|
-
const update = cloneDeep(model);
|
|
3334
|
-
update.choices = choices;
|
|
3335
|
-
update.correctResponse = correctResponse;
|
|
3336
|
-
onModelChanged(update);
|
|
3337
|
-
};
|
|
3338
|
-
}
|
|
3339
|
-
|
|
3340
|
-
componentDidMount() {
|
|
3341
|
-
const {
|
|
3342
|
-
model,
|
|
3343
|
-
onModelChanged
|
|
3344
|
-
} = this.props || {};
|
|
3345
|
-
const {
|
|
3346
|
-
feedback
|
|
3347
|
-
} = model || {};
|
|
3348
|
-
const update = cloneDeep(model); // requirement made in PD-2182
|
|
3349
|
-
|
|
3350
|
-
if (!feedback) {
|
|
3351
|
-
update.feedbackEnabled = false;
|
|
3352
|
-
onModelChanged(update);
|
|
3353
|
-
}
|
|
3354
|
-
}
|
|
3355
|
-
|
|
3356
|
-
render() {
|
|
3357
|
-
const {
|
|
3358
|
-
model,
|
|
3359
|
-
classes,
|
|
3360
|
-
imageSupport,
|
|
3361
|
-
uploadSoundSupport,
|
|
3362
|
-
onModelChanged,
|
|
3363
|
-
configuration,
|
|
3364
|
-
onConfigurationChanged
|
|
3365
|
-
} = this.props;
|
|
3366
|
-
const {
|
|
3367
|
-
baseInputConfiguration = {},
|
|
3368
|
-
choiceLabel = {},
|
|
3369
|
-
choices = {},
|
|
3370
|
-
contentDimensions = {},
|
|
3371
|
-
feedback = {},
|
|
3372
|
-
prompt = {},
|
|
3373
|
-
placementArea = {},
|
|
3374
|
-
maxImageWidth = {},
|
|
3375
|
-
maxImageHeight = {},
|
|
3376
|
-
numberedGuides = {},
|
|
3377
|
-
orientation = {},
|
|
3378
|
-
partialScoring = {},
|
|
3379
|
-
rationale = {},
|
|
3380
|
-
removeTilesAfterPlacing = {},
|
|
3381
|
-
settingsPanelDisabled,
|
|
3382
|
-
studentInstructions = {},
|
|
3383
|
-
spellCheck = {},
|
|
3384
|
-
scoringType = {},
|
|
3385
|
-
targetLabel = {},
|
|
3386
|
-
teacherInstructions = {},
|
|
3387
|
-
withRubric = {},
|
|
3388
|
-
mathMlOptions = {},
|
|
3389
|
-
language = {},
|
|
3390
|
-
languageChoices = {}
|
|
3391
|
-
} = configuration || {};
|
|
3392
|
-
const {
|
|
3393
|
-
choiceLabelEnabled,
|
|
3394
|
-
errors,
|
|
3395
|
-
extraCSSRules,
|
|
3396
|
-
feedbackEnabled,
|
|
3397
|
-
promptEnabled,
|
|
3398
|
-
rationaleEnabled,
|
|
3399
|
-
spellCheckEnabled,
|
|
3400
|
-
teacherInstructionsEnabled,
|
|
3401
|
-
toolbarEditorPosition
|
|
3402
|
-
} = model || {};
|
|
3403
|
-
const {
|
|
3404
|
-
prompt: promptError,
|
|
3405
|
-
rationale: rationaleError,
|
|
3406
|
-
teacherInstructions: teacherInstructionsError
|
|
3407
|
-
} = errors || {};
|
|
3408
|
-
const validationMessage = generateValidationMessage();
|
|
3409
|
-
const {
|
|
3410
|
-
singularLabel = '',
|
|
3411
|
-
pluralLabel = ''
|
|
3412
|
-
} = (choices == null ? void 0 : choices.label) && getSingularAndPlural(choices.label) || {};
|
|
3413
|
-
const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
|
|
3414
|
-
const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
|
|
3415
|
-
const maxChoicesImageWidth = maxImageWidth && model.placementArea ? maxImageWidth.choicesWithPlacementArea : maxImageWidth.choicesWithoutPlacementArea || defaultImageMaxWidth;
|
|
3416
|
-
const maxChoicesImageHeight = maxImageHeight && maxImageHeight.choices || defaultImageMaxHeight;
|
|
3417
|
-
const toolbarOpts = {
|
|
3418
|
-
position: toolbarEditorPosition === 'top' ? 'top' : 'bottom'
|
|
3419
|
-
};
|
|
3420
|
-
const panelSettings = {
|
|
3421
|
-
choiceLabelEnabled: choiceLabel.settings && toggle(choiceLabel.label),
|
|
3422
|
-
placementArea: placementArea.settings && toggle(placementArea.label),
|
|
3423
|
-
numberedGuides: numberedGuides.settings && model.placementArea && toggle(numberedGuides.label),
|
|
3424
|
-
orientation: orientation.settings && radio(orientation.label, ['vertical', 'horizontal']),
|
|
3425
|
-
removeTilesAfterPlacing: removeTilesAfterPlacing.settings && toggle(removeTilesAfterPlacing.label),
|
|
3426
|
-
partialScoring: partialScoring.settings && toggle(partialScoring.label),
|
|
3427
|
-
feedbackEnabled: feedback.settings && toggle(feedback.label),
|
|
3428
|
-
'language.enabled': language.settings && toggle(language.label, true),
|
|
3429
|
-
language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options)
|
|
3430
|
-
};
|
|
3431
|
-
const panelProperties = {
|
|
3432
|
-
teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
|
|
3433
|
-
studentInstructionsEnabled: studentInstructions.settings && toggle(studentInstructions.label),
|
|
3434
|
-
rationaleEnabled: rationale.settings && toggle(rationale.label),
|
|
3435
|
-
promptEnabled: prompt.settings && toggle(prompt.label),
|
|
3436
|
-
spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
|
|
3437
|
-
scoringType: scoringType.settings && radio(scoringType.label, ['auto', 'rubric']),
|
|
3438
|
-
rubricEnabled: (withRubric == null ? void 0 : withRubric.settings) && toggle(withRubric == null ? void 0 : withRubric.label)
|
|
3439
|
-
};
|
|
3440
|
-
|
|
3441
|
-
const getPluginProps = (props = {}) => _extends({}, baseInputConfiguration, props);
|
|
3442
|
-
|
|
3443
|
-
return /*#__PURE__*/React.createElement(layout.ConfigLayout, {
|
|
3444
|
-
extraCSSRules: extraCSSRules,
|
|
3445
|
-
dimensions: contentDimensions,
|
|
3446
|
-
hideSettings: settingsPanelDisabled,
|
|
3447
|
-
settings: /*#__PURE__*/React.createElement(Panel, {
|
|
3448
|
-
model: model,
|
|
3449
|
-
configuration: configuration,
|
|
3450
|
-
onChangeModel: model => onModelChanged(model),
|
|
3451
|
-
onChangeConfiguration: configuration => onConfigurationChanged(configuration, true),
|
|
3452
|
-
groups: {
|
|
3453
|
-
Settings: panelSettings,
|
|
3454
|
-
Properties: panelProperties
|
|
3455
|
-
}
|
|
3456
|
-
})
|
|
3457
|
-
}, teacherInstructionsEnabled && /*#__PURE__*/React.createElement(InputContainer$1, {
|
|
3458
|
-
label: teacherInstructions.label,
|
|
3459
|
-
className: classes.promptHolder
|
|
3460
|
-
}, /*#__PURE__*/React.createElement(EditableHtml, {
|
|
3461
|
-
className: classes.prompt,
|
|
3462
|
-
markup: model.teacherInstructions || '',
|
|
3463
|
-
onChange: this.onTeacherInstructionsChange,
|
|
3464
|
-
imageSupport: imageSupport,
|
|
3465
|
-
nonEmpty: false,
|
|
3466
|
-
error: teacherInstructionsError,
|
|
3467
|
-
toolbarOpts: toolbarOpts,
|
|
3468
|
-
pluginProps: getPluginProps(teacherInstructions == null ? void 0 : teacherInstructions.inputConfiguration),
|
|
3469
|
-
spellCheck: spellCheckEnabled,
|
|
3470
|
-
maxImageWidth: maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth,
|
|
3471
|
-
maxImageHeight: maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight,
|
|
3472
|
-
uploadSoundSupport: uploadSoundSupport,
|
|
3473
|
-
languageCharactersProps: [{
|
|
3474
|
-
language: 'spanish'
|
|
3475
|
-
}, {
|
|
3476
|
-
language: 'special'
|
|
3477
|
-
}],
|
|
3478
|
-
mathMlOptions: mathMlOptions
|
|
3479
|
-
}), teacherInstructionsError && /*#__PURE__*/React.createElement("div", {
|
|
3480
|
-
className: classes.errorText
|
|
3481
|
-
}, teacherInstructionsError)), promptEnabled && /*#__PURE__*/React.createElement(InputContainer$1, {
|
|
3482
|
-
label: prompt && prompt.label,
|
|
3483
|
-
className: classes.promptHolder
|
|
3484
|
-
}, /*#__PURE__*/React.createElement(EditableHtml, {
|
|
3485
|
-
className: classes.prompt,
|
|
3486
|
-
markup: model.prompt,
|
|
3487
|
-
onChange: this.onPromptChange,
|
|
3488
|
-
imageSupport: imageSupport,
|
|
3489
|
-
error: promptError,
|
|
3490
|
-
toolbarOpts: toolbarOpts,
|
|
3491
|
-
pluginProps: getPluginProps(prompt == null ? void 0 : prompt.inputConfiguration),
|
|
3492
|
-
spellCheck: spellCheckEnabled,
|
|
3493
|
-
maxImageWidth: maxImageWidth && maxImageWidth.prompt,
|
|
3494
|
-
maxImageHeight: maxImageHeight && maxImageHeight.prompt,
|
|
3495
|
-
uploadSoundSupport: uploadSoundSupport,
|
|
3496
|
-
languageCharactersProps: [{
|
|
3497
|
-
language: 'spanish'
|
|
3498
|
-
}, {
|
|
3499
|
-
language: 'special'
|
|
3500
|
-
}],
|
|
3501
|
-
mathMlOptions: mathMlOptions
|
|
3502
|
-
}), promptError && /*#__PURE__*/React.createElement("div", {
|
|
3503
|
-
className: classes.errorText
|
|
3504
|
-
}, promptError)), /*#__PURE__*/React.createElement(FormSection, {
|
|
3505
|
-
className: classes.choicesWrapper,
|
|
3506
|
-
label: `Define ${pluralLabel}`,
|
|
3507
|
-
labelExtraStyle: {
|
|
3508
|
-
display: 'inline-flex'
|
|
3509
|
-
}
|
|
3510
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
3511
|
-
className: classes.inlineFlexContainer
|
|
3512
|
-
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
3513
|
-
classes: {
|
|
3514
|
-
tooltip: classes.tooltip
|
|
3515
|
-
},
|
|
3516
|
-
disableFocusListener: true,
|
|
3517
|
-
disableTouchListener: true,
|
|
3518
|
-
placement: 'right',
|
|
3519
|
-
title: validationMessage
|
|
3520
|
-
}, /*#__PURE__*/React.createElement(Info, {
|
|
3521
|
-
fontSize: 'small',
|
|
3522
|
-
color: 'primary',
|
|
3523
|
-
style: {
|
|
3524
|
-
marginLeft: '8px'
|
|
3525
|
-
}
|
|
3526
|
-
}))), /*#__PURE__*/React.createElement("div", {
|
|
3527
|
-
className: classes.row
|
|
3528
|
-
}, choiceLabelEnabled && /*#__PURE__*/React.createElement(InputContainer$1, {
|
|
3529
|
-
label: choiceLabel && choiceLabel.label && `${singularLabel} label`,
|
|
3530
|
-
className: classes.promptHolder
|
|
3531
|
-
}, /*#__PURE__*/React.createElement(EditableHtml, _extends({}, model.placementArea && {
|
|
3532
|
-
autoWidthToolbar: true
|
|
3533
|
-
}, {
|
|
3534
|
-
className: classes.prompt,
|
|
3535
|
-
markup: model.choiceLabel,
|
|
3536
|
-
onChange: this.onChoiceAreaLabelChange,
|
|
3537
|
-
toolbarOpts: toolbarOpts,
|
|
3538
|
-
pluginProps: getPluginProps(choiceLabel == null ? void 0 : choiceLabel.inputConfiguration),
|
|
3539
|
-
spellCheck: spellCheckEnabled,
|
|
3540
|
-
maxImageWidth: maxChoicesImageWidth,
|
|
3541
|
-
maxImageHeight: maxChoicesImageHeight,
|
|
3542
|
-
uploadSoundSupport: uploadSoundSupport,
|
|
3543
|
-
languageCharactersProps: [{
|
|
3544
|
-
language: 'spanish'
|
|
3545
|
-
}, {
|
|
3546
|
-
language: 'special'
|
|
3547
|
-
}],
|
|
3548
|
-
mathMlOptions: mathMlOptions
|
|
3549
|
-
}))), targetLabel.settings && model.placementArea && /*#__PURE__*/React.createElement(InputContainer$1, {
|
|
3550
|
-
label: targetLabel && targetLabel.label && targetLabel.label,
|
|
3551
|
-
className: classes.promptHolder
|
|
3552
|
-
}, /*#__PURE__*/React.createElement(EditableHtml, {
|
|
3553
|
-
autoWidthToolbar: true,
|
|
3554
|
-
className: classes.prompt,
|
|
3555
|
-
markup: model.targetLabel,
|
|
3556
|
-
onChange: this.onAnswerAreaLabelChange,
|
|
3557
|
-
toolbarOpts: toolbarOpts,
|
|
3558
|
-
spellCheck: spellCheckEnabled,
|
|
3559
|
-
maxImageWidth: maxImageWidth && maxImageWidth.choicesWithPlacementArea || defaultImageMaxWidth,
|
|
3560
|
-
maxImageHeight: maxChoicesImageHeight,
|
|
3561
|
-
uploadSoundSupport: uploadSoundSupport,
|
|
3562
|
-
languageCharactersProps: [{
|
|
3563
|
-
language: 'spanish'
|
|
3564
|
-
}, {
|
|
3565
|
-
language: 'special'
|
|
3566
|
-
}],
|
|
3567
|
-
mathMlOptions: mathMlOptions
|
|
3568
|
-
}))), choices.settings && /*#__PURE__*/React.createElement(ChoiceEditor$1, {
|
|
3569
|
-
correctResponse: model.correctResponse,
|
|
3570
|
-
choices: model.choices,
|
|
3571
|
-
onChange: this.onChoiceEditorChange,
|
|
3572
|
-
imageSupport: imageSupport,
|
|
3573
|
-
toolbarOpts: toolbarOpts,
|
|
3574
|
-
pluginProps: getPluginProps(choices == null ? void 0 : choices.inputConfiguration),
|
|
3575
|
-
choicesLabel: choices.label,
|
|
3576
|
-
placementArea: model.placementArea,
|
|
3577
|
-
singularChoiceLabel: singularLabel,
|
|
3578
|
-
pluralChoiceLabel: pluralLabel,
|
|
3579
|
-
spellCheck: spellCheckEnabled,
|
|
3580
|
-
maxImageWidth: maxChoicesImageWidth,
|
|
3581
|
-
maxImageHeight: maxChoicesImageHeight,
|
|
3582
|
-
errors: errors || {},
|
|
3583
|
-
mathMlOptions: mathMlOptions
|
|
3584
|
-
})), rationaleEnabled && /*#__PURE__*/React.createElement(InputContainer$1, {
|
|
3585
|
-
label: rationale.label,
|
|
3586
|
-
className: classes.promptHolder
|
|
3587
|
-
}, /*#__PURE__*/React.createElement(EditableHtml, {
|
|
3588
|
-
className: classes.prompt,
|
|
3589
|
-
markup: model.rationale || '',
|
|
3590
|
-
onChange: this.onRationaleChange,
|
|
3591
|
-
imageSupport: imageSupport,
|
|
3592
|
-
error: rationaleError,
|
|
3593
|
-
toolbarOpts: toolbarOpts,
|
|
3594
|
-
pluginProps: getPluginProps(rationale == null ? void 0 : rationale.inputConfiguration),
|
|
3595
|
-
spellCheck: spellCheckEnabled,
|
|
3596
|
-
maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
|
|
3597
|
-
maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight,
|
|
3598
|
-
uploadSoundSupport: uploadSoundSupport,
|
|
3599
|
-
languageCharactersProps: [{
|
|
3600
|
-
language: 'spanish'
|
|
3601
|
-
}, {
|
|
3602
|
-
language: 'special'
|
|
3603
|
-
}],
|
|
3604
|
-
mathMlOptions: mathMlOptions
|
|
3605
|
-
}), rationaleError && /*#__PURE__*/React.createElement("div", {
|
|
3606
|
-
className: classes.errorText
|
|
3607
|
-
}, rationaleError)), feedbackEnabled && /*#__PURE__*/React.createElement(FeedbackConfig, {
|
|
3608
|
-
feedback: model.feedback,
|
|
3609
|
-
onChange: this.onFeedbackChange,
|
|
3610
|
-
imageSupport: imageSupport,
|
|
3611
|
-
toolbarOpts: toolbarOpts
|
|
3612
|
-
}));
|
|
3613
|
-
}
|
|
3614
|
-
|
|
3615
|
-
}
|
|
3616
|
-
Design.propTypes = {
|
|
3617
|
-
uploadSoundSupport: PropTypes.object
|
|
3618
|
-
};
|
|
3619
|
-
Design.defaultProps = {};
|
|
3620
|
-
Design.defaultProps = {
|
|
3621
|
-
onModelChanged: () => {},
|
|
3622
|
-
onConfigurationChanged: () => {}
|
|
3623
|
-
};
|
|
3624
|
-
Design.propTypes = {
|
|
3625
|
-
model: PropTypes.object.isRequired,
|
|
3626
|
-
configuration: PropTypes.object.isRequired,
|
|
3627
|
-
onModelChanged: PropTypes.func,
|
|
3628
|
-
onConfigurationChanged: PropTypes.func,
|
|
3629
|
-
classes: PropTypes.object.isRequired,
|
|
3630
|
-
imageSupport: PropTypes.object
|
|
3631
|
-
};
|
|
3632
|
-
var Main = withDragContext(withStyles(theme => ({
|
|
3633
|
-
promptHolder: {
|
|
3634
|
-
width: '100%',
|
|
3635
|
-
paddingTop: theme.spacing.unit * 2,
|
|
3636
|
-
marginBottom: theme.spacing.unit * 2
|
|
3637
|
-
},
|
|
3638
|
-
row: {
|
|
3639
|
-
display: 'grid',
|
|
3640
|
-
gridAutoFlow: 'column',
|
|
3641
|
-
gridAutoColumns: '1fr',
|
|
3642
|
-
gridGap: '8px'
|
|
3643
|
-
},
|
|
3644
|
-
choicesWrapper: {
|
|
3645
|
-
marginTop: 0,
|
|
3646
|
-
marginBottom: theme.spacing.unit * 2.5
|
|
3647
|
-
},
|
|
3648
|
-
tooltip: {
|
|
3649
|
-
fontSize: theme.typography.fontSize - 2,
|
|
3650
|
-
whiteSpace: 'pre',
|
|
3651
|
-
maxWidth: '500px'
|
|
3652
|
-
},
|
|
3653
|
-
inlineFlexContainer: {
|
|
3654
|
-
display: 'inline-flex',
|
|
3655
|
-
position: 'absolute'
|
|
3656
|
-
},
|
|
3657
|
-
errorText: {
|
|
3658
|
-
fontSize: theme.typography.fontSize - 2,
|
|
3659
|
-
color: theme.palette.error.main,
|
|
3660
|
-
paddingTop: theme.spacing.unit
|
|
3661
|
-
}
|
|
3662
|
-
}))(Design));
|
|
3663
|
-
|
|
3664
|
-
/** NOTE: teacherInstructions, studentInstructions, rationale & scoringType
|
|
3665
|
-
* functionalities are not defined yet - the value for those can belong to
|
|
3666
|
-
* model or to configuration
|
|
3667
|
-
*/
|
|
3668
|
-
var defaultValues = {
|
|
3669
|
-
model: {
|
|
3670
|
-
choiceLabel: '',
|
|
3671
|
-
choiceLabelEnabled: true,
|
|
3672
|
-
choices: [],
|
|
3673
|
-
correctResponse: [],
|
|
3674
|
-
feedbackEnabled: false,
|
|
3675
|
-
numberedGuides: false,
|
|
3676
|
-
orientation: 'vertical',
|
|
3677
|
-
partialScoring: true,
|
|
3678
|
-
placementArea: false,
|
|
3679
|
-
prompt: '',
|
|
3680
|
-
promptEnabled: true,
|
|
3681
|
-
rationale: '',
|
|
3682
|
-
rationaleEnabled: true,
|
|
3683
|
-
removeTilesAfterPlacing: true,
|
|
3684
|
-
scoringType: 'auto',
|
|
3685
|
-
studentInstructionsEnabled: true,
|
|
3686
|
-
targetLabel: '',
|
|
3687
|
-
teacherInstructions: '',
|
|
3688
|
-
teacherInstructionsEnabled: true,
|
|
3689
|
-
toolbarEditorPosition: 'bottom'
|
|
3690
|
-
},
|
|
3691
|
-
configuration: {
|
|
3692
|
-
baseInputConfiguration: {
|
|
3693
|
-
audio: {
|
|
3694
|
-
disabled: false
|
|
3695
|
-
},
|
|
3696
|
-
video: {
|
|
3697
|
-
disabled: false
|
|
3698
|
-
},
|
|
3699
|
-
image: {
|
|
3700
|
-
disabled: false
|
|
3701
|
-
},
|
|
3702
|
-
textAlign: {
|
|
3703
|
-
disabled: true
|
|
3704
|
-
},
|
|
3705
|
-
showParagraphs: {
|
|
3706
|
-
disabled: false
|
|
3707
|
-
},
|
|
3708
|
-
separateParagraphs: {
|
|
3709
|
-
disabled: true
|
|
3710
|
-
}
|
|
3711
|
-
},
|
|
3712
|
-
choiceLabel: {
|
|
3713
|
-
settings: true,
|
|
3714
|
-
label: 'Choice label',
|
|
3715
|
-
inputConfiguration: {
|
|
3716
|
-
audio: {
|
|
3717
|
-
disabled: false
|
|
3718
|
-
},
|
|
3719
|
-
video: {
|
|
3720
|
-
disabled: false
|
|
3721
|
-
},
|
|
3722
|
-
image: {
|
|
3723
|
-
disabled: false
|
|
3724
|
-
}
|
|
3725
|
-
}
|
|
3726
|
-
},
|
|
3727
|
-
choices: {
|
|
3728
|
-
settings: true,
|
|
3729
|
-
label: 'Choices',
|
|
3730
|
-
inputConfiguration: {
|
|
3731
|
-
audio: {
|
|
3732
|
-
disabled: true
|
|
3733
|
-
},
|
|
3734
|
-
video: {
|
|
3735
|
-
disabled: true
|
|
3736
|
-
},
|
|
3737
|
-
image: {
|
|
3738
|
-
disabled: true
|
|
3739
|
-
}
|
|
3740
|
-
}
|
|
3741
|
-
},
|
|
3742
|
-
feedback: {
|
|
3743
|
-
settings: true,
|
|
3744
|
-
label: 'Feedback',
|
|
3745
|
-
enabled: true
|
|
3746
|
-
},
|
|
3747
|
-
prompt: {
|
|
3748
|
-
settings: true,
|
|
3749
|
-
label: 'Item Stem',
|
|
3750
|
-
required: false,
|
|
3751
|
-
inputConfiguration: {
|
|
3752
|
-
audio: {
|
|
3753
|
-
disabled: false
|
|
3754
|
-
},
|
|
3755
|
-
video: {
|
|
3756
|
-
disabled: false
|
|
3757
|
-
},
|
|
3758
|
-
image: {
|
|
3759
|
-
disabled: false
|
|
3760
|
-
}
|
|
3761
|
-
}
|
|
3762
|
-
},
|
|
3763
|
-
numberedGuides: {
|
|
3764
|
-
settings: true,
|
|
3765
|
-
label: 'Numbered guides'
|
|
3766
|
-
},
|
|
3767
|
-
orientation: {
|
|
3768
|
-
settings: true,
|
|
3769
|
-
label: 'Orientation'
|
|
3770
|
-
},
|
|
3771
|
-
partialScoring: {
|
|
3772
|
-
settings: false,
|
|
3773
|
-
label: 'Allow Partial Scoring'
|
|
3774
|
-
},
|
|
3775
|
-
placementArea: {
|
|
3776
|
-
settings: true,
|
|
3777
|
-
label: 'Placement Area'
|
|
3778
|
-
},
|
|
3779
|
-
rationale: {
|
|
3780
|
-
settings: true,
|
|
3781
|
-
label: 'Rationale',
|
|
3782
|
-
required: false,
|
|
3783
|
-
inputConfiguration: {
|
|
3784
|
-
audio: {
|
|
3785
|
-
disabled: false
|
|
3786
|
-
},
|
|
3787
|
-
video: {
|
|
3788
|
-
disabled: false
|
|
3789
|
-
},
|
|
3790
|
-
image: {
|
|
3791
|
-
disabled: false
|
|
3792
|
-
}
|
|
3793
|
-
}
|
|
3794
|
-
},
|
|
3795
|
-
removeTilesAfterPlacing: {
|
|
3796
|
-
settings: false,
|
|
3797
|
-
label: 'Remove Tiles after placing'
|
|
3798
|
-
},
|
|
3799
|
-
settingsPanelDisabled: false,
|
|
3800
|
-
scoringType: {
|
|
3801
|
-
settings: false,
|
|
3802
|
-
label: 'Scoring Type'
|
|
3803
|
-
},
|
|
3804
|
-
studentInstructions: {
|
|
3805
|
-
settings: false,
|
|
3806
|
-
label: 'Student Instructions'
|
|
3807
|
-
},
|
|
3808
|
-
targetLabel: {
|
|
3809
|
-
settings: true,
|
|
3810
|
-
label: 'Target label'
|
|
3811
|
-
},
|
|
3812
|
-
spellCheck: {
|
|
3813
|
-
label: 'Spellcheck',
|
|
3814
|
-
settings: false,
|
|
3815
|
-
enabled: true
|
|
3816
|
-
},
|
|
3817
|
-
teacherInstructions: {
|
|
3818
|
-
settings: true,
|
|
3819
|
-
label: 'Teacher Instructions',
|
|
3820
|
-
required: false,
|
|
3821
|
-
inputConfiguration: {
|
|
3822
|
-
audio: {
|
|
3823
|
-
disabled: false
|
|
3824
|
-
},
|
|
3825
|
-
video: {
|
|
3826
|
-
disabled: false
|
|
3827
|
-
},
|
|
3828
|
-
image: {
|
|
3829
|
-
disabled: false
|
|
3830
|
-
}
|
|
3831
|
-
}
|
|
3832
|
-
},
|
|
3833
|
-
maxImageWidth: {
|
|
3834
|
-
teacherInstructions: 300,
|
|
3835
|
-
prompt: 300,
|
|
3836
|
-
rationale: 300,
|
|
3837
|
-
choicesWithPlacementArea: 240,
|
|
3838
|
-
choicesWithoutPlacementArea: 300
|
|
3839
|
-
},
|
|
3840
|
-
maxImageHeight: {
|
|
3841
|
-
teacherInstructions: 300,
|
|
3842
|
-
prompt: 300,
|
|
3843
|
-
rationale: 300,
|
|
3844
|
-
choices: 150
|
|
3845
|
-
},
|
|
3846
|
-
withRubric: {
|
|
3847
|
-
settings: false,
|
|
3848
|
-
label: 'Add Rubric'
|
|
3849
|
-
},
|
|
3850
|
-
mathMlOptions: {
|
|
3851
|
-
mmlOutput: false,
|
|
3852
|
-
mmlEditing: false
|
|
3853
|
-
},
|
|
3854
|
-
language: {
|
|
3855
|
-
settings: false,
|
|
3856
|
-
label: 'Specify Language',
|
|
3857
|
-
enabled: false
|
|
3858
|
-
},
|
|
3859
|
-
languageChoices: {
|
|
3860
|
-
label: 'Language Choices',
|
|
3861
|
-
options: []
|
|
3862
|
-
}
|
|
3863
|
-
}
|
|
3864
|
-
};
|
|
3865
|
-
|
|
3866
|
-
const prepareCustomizationObject = (config, model) => {
|
|
3867
|
-
const configuration = defaults(config, defaultValues.configuration);
|
|
3868
|
-
return {
|
|
3869
|
-
configuration,
|
|
3870
|
-
model
|
|
3871
|
-
};
|
|
3872
|
-
};
|
|
3873
|
-
|
|
3874
|
-
const addWeightToCorrectResponse = correctResponse => correctResponse && correctResponse.map(correct => {
|
|
3875
|
-
// if weight is set
|
|
3876
|
-
if (correct.weight !== undefined) {
|
|
3877
|
-
return {
|
|
3878
|
-
id: correct.id,
|
|
3879
|
-
weight: correct.weight
|
|
3880
|
-
};
|
|
3881
|
-
} else {
|
|
3882
|
-
return {
|
|
3883
|
-
id: correct.id || correct,
|
|
3884
|
-
weight: 0
|
|
3885
|
-
};
|
|
3886
|
-
}
|
|
3887
|
-
});
|
|
3888
|
-
/**
|
|
3889
|
-
* assuming that the correct response will be set via ui, not via config,
|
|
3890
|
-
* correctResponse (if not set) will be initialized with choices default order
|
|
3891
|
-
*/
|
|
3892
|
-
|
|
3893
|
-
class PlacementOrdering extends HTMLElement {
|
|
3894
|
-
constructor() {
|
|
3895
|
-
super();
|
|
3896
|
-
this._model = PlacementOrdering.createDefaultModel();
|
|
3897
|
-
this._configuration = defaultValues.configuration;
|
|
3898
|
-
|
|
3899
|
-
this.onModelChanged = (model, resetSession) => {
|
|
3900
|
-
this._model = model;
|
|
3901
|
-
|
|
3902
|
-
this._rerender();
|
|
3903
|
-
|
|
3904
|
-
this.dispatchUpdate(resetSession);
|
|
3905
|
-
};
|
|
3906
|
-
|
|
3907
|
-
this.onConfigurationChanged = configuration => {
|
|
3908
|
-
this._configuration = prepareCustomizationObject(configuration).configuration;
|
|
3909
|
-
this.onModelChanged(this._model);
|
|
3910
|
-
|
|
3911
|
-
this._rerender();
|
|
3912
|
-
};
|
|
3913
|
-
|
|
3914
|
-
this.insertImage = handler => {
|
|
3915
|
-
this.dispatchEvent(new InsertImageEvent(handler));
|
|
3916
|
-
};
|
|
3917
|
-
|
|
3918
|
-
this.deleteImage = (src, done) => {
|
|
3919
|
-
this.dispatchEvent(new DeleteImageEvent(src, done));
|
|
3920
|
-
};
|
|
3921
|
-
}
|
|
3922
|
-
|
|
3923
|
-
dispatchUpdate(reset) {
|
|
3924
|
-
this.dispatchEvent(new ModelUpdatedEvent(this._model, reset));
|
|
3925
|
-
}
|
|
3926
|
-
|
|
3927
|
-
set model(s) {
|
|
3928
|
-
this._model = PlacementOrdering.createDefaultModel(s);
|
|
3929
|
-
|
|
3930
|
-
this._rerender();
|
|
3931
|
-
}
|
|
3932
|
-
|
|
3933
|
-
set configuration(c) {
|
|
3934
|
-
var _newConfiguration$lan;
|
|
3935
|
-
|
|
3936
|
-
const info = prepareCustomizationObject(c, this._model);
|
|
3937
|
-
this.onModelChanged(info.model);
|
|
3938
|
-
|
|
3939
|
-
const newConfiguration = _extends({}, defaultValues.configuration, info.configuration);
|
|
3940
|
-
|
|
3941
|
-
this._configuration = newConfiguration; // if language:enabled is true, then the corresponding default item model should include a language value;
|
|
3942
|
-
// if it is false, then the language field should be omitted from the item model.
|
|
3943
|
-
// if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,
|
|
3944
|
-
// then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).
|
|
3945
|
-
|
|
3946
|
-
if (newConfiguration != null && (_newConfiguration$lan = newConfiguration.language) != null && _newConfiguration$lan.enabled) {
|
|
3947
|
-
var _newConfiguration$lan2, _newConfiguration$lan3;
|
|
3948
|
-
|
|
3949
|
-
if (newConfiguration != null && (_newConfiguration$lan2 = newConfiguration.languageChoices) != null && (_newConfiguration$lan3 = _newConfiguration$lan2.options) != null && _newConfiguration$lan3.length) {
|
|
3950
|
-
this._model.language = newConfiguration == null ? void 0 : newConfiguration.languageChoices.options[0].value;
|
|
3951
|
-
}
|
|
3952
|
-
} else if (newConfiguration.language.settings && this._model.language) {
|
|
3953
|
-
this._configuration.language.enabled = true;
|
|
3954
|
-
|
|
3955
|
-
if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {
|
|
3956
|
-
this._configuration.languageChoices.options = [];
|
|
3957
|
-
} // check if the language is already included in the languageChoices.options array
|
|
3958
|
-
// and if not, then add it.
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
if (!this._configuration.languageChoices.options.find(option => option.value === this._model.language)) {
|
|
3962
|
-
this._configuration.languageChoices.options.push({
|
|
3963
|
-
value: this._model.language,
|
|
3964
|
-
label: this._model.language
|
|
3965
|
-
});
|
|
3966
|
-
}
|
|
3967
|
-
} else {
|
|
3968
|
-
delete this._model.language;
|
|
3969
|
-
}
|
|
3970
|
-
|
|
3971
|
-
this._rerender();
|
|
3972
|
-
}
|
|
3973
|
-
|
|
3974
|
-
insertSound(handler) {
|
|
3975
|
-
this.dispatchEvent(new InsertSoundEvent(handler));
|
|
3976
|
-
}
|
|
3977
|
-
|
|
3978
|
-
onDeleteSound(src, done) {
|
|
3979
|
-
this.dispatchEvent(new DeleteSoundEvent(src, done));
|
|
3980
|
-
}
|
|
3981
|
-
|
|
3982
|
-
_rerender() {
|
|
3983
|
-
let element = /*#__PURE__*/React.createElement(Main, {
|
|
3984
|
-
model: this._model,
|
|
3985
|
-
configuration: this._configuration,
|
|
3986
|
-
onModelChanged: this.onModelChanged,
|
|
3987
|
-
onConfigurationChanged: this.onConfigurationChanged,
|
|
3988
|
-
imageSupport: {
|
|
3989
|
-
add: this.insertImage,
|
|
3990
|
-
delete: this.deleteImage
|
|
3991
|
-
},
|
|
3992
|
-
uploadSoundSupport: {
|
|
3993
|
-
add: this.insertSound.bind(this),
|
|
3994
|
-
delete: this.onDeleteSound.bind(this)
|
|
3995
|
-
}
|
|
3996
|
-
});
|
|
3997
|
-
ReactDOM.render(element, this);
|
|
3998
|
-
}
|
|
3999
|
-
|
|
4000
|
-
}
|
|
4001
|
-
|
|
4002
|
-
PlacementOrdering.createDefaultModel = (model = {}) => {
|
|
4003
|
-
const mapChoicesToReturnCorrectResponse = choices => choices && choices.map(ch => ({
|
|
4004
|
-
id: ch.id,
|
|
4005
|
-
weight: 0
|
|
4006
|
-
}));
|
|
4007
|
-
|
|
4008
|
-
let correctResponse = addWeightToCorrectResponse(model.correctResponse) || mapChoicesToReturnCorrectResponse(model.choices);
|
|
4009
|
-
|
|
4010
|
-
const defaultModel = _extends({}, defaultValues.model, model);
|
|
4011
|
-
|
|
4012
|
-
if (correctResponse) {
|
|
4013
|
-
defaultModel.correctResponse = correctResponse;
|
|
4014
|
-
}
|
|
4015
|
-
|
|
4016
|
-
return defaultModel;
|
|
4017
|
-
};
|
|
4018
|
-
|
|
4019
|
-
export { addWeightToCorrectResponse, PlacementOrdering as default };
|
|
4020
|
-
//# sourceMappingURL=configure.js.map
|