@pie-element/categorize 11.0.5-esm.1 → 11.2.0-mui-update.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 +81 -0
- package/configure/CHANGELOG.md +74 -0
- package/configure/lib/defaults.js +2 -5
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/design/builder.js +15 -33
- package/configure/lib/design/builder.js.map +1 -1
- package/configure/lib/design/buttons.js +44 -95
- package/configure/lib/design/buttons.js.map +1 -1
- package/configure/lib/design/categories/RowLabel.js +32 -45
- package/configure/lib/design/categories/RowLabel.js.map +1 -1
- package/configure/lib/design/categories/alternateResponses.js +102 -251
- package/configure/lib/design/categories/alternateResponses.js.map +1 -1
- package/configure/lib/design/categories/category.js +138 -208
- package/configure/lib/design/categories/category.js.map +1 -1
- package/configure/lib/design/categories/choice-preview.js +59 -126
- package/configure/lib/design/categories/choice-preview.js.map +1 -1
- package/configure/lib/design/categories/droppable-placeholder.js +76 -165
- package/configure/lib/design/categories/droppable-placeholder.js.map +1 -1
- package/configure/lib/design/categories/index.js +199 -384
- package/configure/lib/design/categories/index.js.map +1 -1
- package/configure/lib/design/choices/choice.js +160 -263
- package/configure/lib/design/choices/choice.js.map +1 -1
- package/configure/lib/design/choices/config.js +46 -98
- package/configure/lib/design/choices/config.js.map +1 -1
- package/configure/lib/design/choices/index.js +152 -236
- package/configure/lib/design/choices/index.js.map +1 -1
- package/configure/lib/design/header.js +62 -111
- package/configure/lib/design/header.js.map +1 -1
- package/configure/lib/design/index.js +632 -476
- package/configure/lib/design/index.js.map +1 -1
- package/configure/lib/design/input-header.js +97 -149
- package/configure/lib/design/input-header.js.map +1 -1
- package/configure/lib/design/utils.js +4 -15
- package/configure/lib/design/utils.js.map +1 -1
- package/configure/lib/index.js +120 -183
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/main.js +31 -74
- package/configure/lib/main.js.map +1 -1
- package/configure/lib/utils.js +22 -32
- package/configure/lib/utils.js.map +1 -1
- package/configure/package.json +15 -14
- package/controller/CHANGELOG.md +62 -0
- package/controller/lib/defaults.js +2 -5
- package/controller/lib/defaults.js.map +1 -1
- package/controller/lib/index.js +238 -315
- package/controller/lib/index.js.map +1 -1
- package/controller/lib/utils.js +40 -31
- package/controller/lib/utils.js.map +1 -1
- package/controller/package.json +5 -5
- package/lib/categorize/categories.js +110 -164
- package/lib/categorize/categories.js.map +1 -1
- package/lib/categorize/category.js +72 -122
- package/lib/categorize/category.js.map +1 -1
- package/lib/categorize/choice.js +116 -245
- package/lib/categorize/choice.js.map +1 -1
- package/lib/categorize/choices.js +66 -131
- package/lib/categorize/choices.js.map +1 -1
- package/lib/categorize/droppable-placeholder.js +49 -103
- package/lib/categorize/droppable-placeholder.js.map +1 -1
- package/lib/categorize/grid-content.js +39 -87
- package/lib/categorize/grid-content.js.map +1 -1
- package/lib/categorize/index.js +341 -316
- package/lib/categorize/index.js.map +1 -1
- package/lib/index.js +286 -271
- package/lib/index.js.map +1 -1
- package/package.json +17 -31
- package/LICENSE.md +0 -5
- package/esm/configure.js +0 -5025
- package/esm/configure.js.map +0 -1
- package/esm/controller.js +0 -456
- package/esm/controller.js.map +0 -1
- package/esm/element.js +0 -3118
- package/esm/element.js.map +0 -1
- package/module/configure.js +0 -1
- package/module/controller.js +0 -6076
- package/module/demo.js +0 -382
- package/module/element.js +0 -1
- package/module/index.html +0 -21
- package/module/manifest.json +0 -22
- package/module/print-demo.js +0 -420
- package/module/print.html +0 -18
package/esm/element.js
DELETED
|
@@ -1,3118 +0,0 @@
|
|
|
1
|
-
import React, { createContext, isValidElement, cloneElement, createRef, Component } from 'react';
|
|
2
|
-
import ReactDOM from 'react-dom';
|
|
3
|
-
import { renderMath } from '@pie-lib/math-rendering';
|
|
4
|
-
import { color, hasText, hasMedia, UiLayout, Collapsible, PreviewPrompt, Feedback, EnableAudioAutoplayImage } from '@pie-lib/render-ui';
|
|
5
|
-
import { ModelSetEvent, SessionChangedEvent } from '@pie-framework/pie-player-events';
|
|
6
|
-
import PropTypes from 'prop-types';
|
|
7
|
-
import { withStyles } from '@material-ui/core/styles';
|
|
8
|
-
import classNames from 'classnames';
|
|
9
|
-
import { uid, PlaceHolder as PlaceHolder$1, withDragContext } from '@pie-lib/drag';
|
|
10
|
-
import Card from '@material-ui/core/Card';
|
|
11
|
-
import CardContent from '@material-ui/core/CardContent';
|
|
12
|
-
import debug from 'debug';
|
|
13
|
-
import { jsx } from 'react/jsx-runtime';
|
|
14
|
-
import CorrectAnswerToggle from '@pie-lib/correct-answer-toggle';
|
|
15
|
-
import { removeChoiceFromCategory, moveChoiceToCategory, buildState } from '@pie-lib/categorize';
|
|
16
|
-
import Translator from '@pie-lib/translator';
|
|
17
|
-
import { AlertDialog } from '@pie-lib/config-ui';
|
|
18
|
-
|
|
19
|
-
function _extends() {
|
|
20
|
-
_extends = Object.assign || function (target) {
|
|
21
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
22
|
-
var source = arguments[i];
|
|
23
|
-
|
|
24
|
-
for (var key in source) {
|
|
25
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
26
|
-
target[key] = source[key];
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return target;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
return _extends.apply(this, arguments);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Create the React Context
|
|
39
|
-
*/
|
|
40
|
-
|
|
41
|
-
var DndContext = createContext({
|
|
42
|
-
dragDropManager: undefined
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Use invariant() to assert state which your program assumes to be true.
|
|
47
|
-
*
|
|
48
|
-
* Provide sprintf-style format (only %s is supported) and arguments
|
|
49
|
-
* to provide information about what broke and what you were
|
|
50
|
-
* expecting.
|
|
51
|
-
*
|
|
52
|
-
* The invariant message will be stripped in production, but the invariant
|
|
53
|
-
* will remain to ensure logic does not differ in production.
|
|
54
|
-
*/
|
|
55
|
-
function invariant(condition, format) {
|
|
56
|
-
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
57
|
-
args[_key - 2] = arguments[_key];
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
61
|
-
if (format === undefined) {
|
|
62
|
-
throw new Error('invariant requires an error message argument');
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (!condition) {
|
|
67
|
-
var error;
|
|
68
|
-
|
|
69
|
-
if (format === undefined) {
|
|
70
|
-
error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
|
|
71
|
-
} else {
|
|
72
|
-
var argIndex = 0;
|
|
73
|
-
error = new Error(format.replace(/%s/g, function () {
|
|
74
|
-
return args[argIndex++];
|
|
75
|
-
}));
|
|
76
|
-
error.name = 'Invariant Violation';
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
error.framesToPop = 1; // we don't care about invariant's own frame
|
|
80
|
-
|
|
81
|
-
throw error;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function _classCallCheck$7(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
86
|
-
|
|
87
|
-
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); } }
|
|
88
|
-
|
|
89
|
-
function _createClass$7(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$7(Constructor.prototype, protoProps); if (staticProps) _defineProperties$7(Constructor, staticProps); return Constructor; }
|
|
90
|
-
|
|
91
|
-
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; }
|
|
92
|
-
var isCallingCanDrag = false;
|
|
93
|
-
var isCallingIsDragging = false;
|
|
94
|
-
var DragSourceMonitorImpl = /*#__PURE__*/function () {
|
|
95
|
-
function DragSourceMonitorImpl(manager) {
|
|
96
|
-
_classCallCheck$7(this, DragSourceMonitorImpl);
|
|
97
|
-
|
|
98
|
-
_defineProperty$7(this, "internalMonitor", void 0);
|
|
99
|
-
|
|
100
|
-
_defineProperty$7(this, "sourceId", null);
|
|
101
|
-
|
|
102
|
-
this.internalMonitor = manager.getMonitor();
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
_createClass$7(DragSourceMonitorImpl, [{
|
|
106
|
-
key: "receiveHandlerId",
|
|
107
|
-
value: function receiveHandlerId(sourceId) {
|
|
108
|
-
this.sourceId = sourceId;
|
|
109
|
-
}
|
|
110
|
-
}, {
|
|
111
|
-
key: "getHandlerId",
|
|
112
|
-
value: function getHandlerId() {
|
|
113
|
-
return this.sourceId;
|
|
114
|
-
}
|
|
115
|
-
}, {
|
|
116
|
-
key: "canDrag",
|
|
117
|
-
value: function canDrag() {
|
|
118
|
-
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');
|
|
119
|
-
|
|
120
|
-
try {
|
|
121
|
-
isCallingCanDrag = true;
|
|
122
|
-
return this.internalMonitor.canDragSource(this.sourceId);
|
|
123
|
-
} finally {
|
|
124
|
-
isCallingCanDrag = false;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}, {
|
|
128
|
-
key: "isDragging",
|
|
129
|
-
value: function isDragging() {
|
|
130
|
-
if (!this.sourceId) {
|
|
131
|
-
return false;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
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');
|
|
135
|
-
|
|
136
|
-
try {
|
|
137
|
-
isCallingIsDragging = true;
|
|
138
|
-
return this.internalMonitor.isDraggingSource(this.sourceId);
|
|
139
|
-
} finally {
|
|
140
|
-
isCallingIsDragging = false;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}, {
|
|
144
|
-
key: "subscribeToStateChange",
|
|
145
|
-
value: function subscribeToStateChange(listener, options) {
|
|
146
|
-
return this.internalMonitor.subscribeToStateChange(listener, options);
|
|
147
|
-
}
|
|
148
|
-
}, {
|
|
149
|
-
key: "isDraggingSource",
|
|
150
|
-
value: function isDraggingSource(sourceId) {
|
|
151
|
-
return this.internalMonitor.isDraggingSource(sourceId);
|
|
152
|
-
}
|
|
153
|
-
}, {
|
|
154
|
-
key: "isOverTarget",
|
|
155
|
-
value: function isOverTarget(targetId, options) {
|
|
156
|
-
return this.internalMonitor.isOverTarget(targetId, options);
|
|
157
|
-
}
|
|
158
|
-
}, {
|
|
159
|
-
key: "getTargetIds",
|
|
160
|
-
value: function getTargetIds() {
|
|
161
|
-
return this.internalMonitor.getTargetIds();
|
|
162
|
-
}
|
|
163
|
-
}, {
|
|
164
|
-
key: "isSourcePublic",
|
|
165
|
-
value: function isSourcePublic() {
|
|
166
|
-
return this.internalMonitor.isSourcePublic();
|
|
167
|
-
}
|
|
168
|
-
}, {
|
|
169
|
-
key: "getSourceId",
|
|
170
|
-
value: function getSourceId() {
|
|
171
|
-
return this.internalMonitor.getSourceId();
|
|
172
|
-
}
|
|
173
|
-
}, {
|
|
174
|
-
key: "subscribeToOffsetChange",
|
|
175
|
-
value: function subscribeToOffsetChange(listener) {
|
|
176
|
-
return this.internalMonitor.subscribeToOffsetChange(listener);
|
|
177
|
-
}
|
|
178
|
-
}, {
|
|
179
|
-
key: "canDragSource",
|
|
180
|
-
value: function canDragSource(sourceId) {
|
|
181
|
-
return this.internalMonitor.canDragSource(sourceId);
|
|
182
|
-
}
|
|
183
|
-
}, {
|
|
184
|
-
key: "canDropOnTarget",
|
|
185
|
-
value: function canDropOnTarget(targetId) {
|
|
186
|
-
return this.internalMonitor.canDropOnTarget(targetId);
|
|
187
|
-
}
|
|
188
|
-
}, {
|
|
189
|
-
key: "getItemType",
|
|
190
|
-
value: function getItemType() {
|
|
191
|
-
return this.internalMonitor.getItemType();
|
|
192
|
-
}
|
|
193
|
-
}, {
|
|
194
|
-
key: "getItem",
|
|
195
|
-
value: function getItem() {
|
|
196
|
-
return this.internalMonitor.getItem();
|
|
197
|
-
}
|
|
198
|
-
}, {
|
|
199
|
-
key: "getDropResult",
|
|
200
|
-
value: function getDropResult() {
|
|
201
|
-
return this.internalMonitor.getDropResult();
|
|
202
|
-
}
|
|
203
|
-
}, {
|
|
204
|
-
key: "didDrop",
|
|
205
|
-
value: function didDrop() {
|
|
206
|
-
return this.internalMonitor.didDrop();
|
|
207
|
-
}
|
|
208
|
-
}, {
|
|
209
|
-
key: "getInitialClientOffset",
|
|
210
|
-
value: function getInitialClientOffset() {
|
|
211
|
-
return this.internalMonitor.getInitialClientOffset();
|
|
212
|
-
}
|
|
213
|
-
}, {
|
|
214
|
-
key: "getInitialSourceClientOffset",
|
|
215
|
-
value: function getInitialSourceClientOffset() {
|
|
216
|
-
return this.internalMonitor.getInitialSourceClientOffset();
|
|
217
|
-
}
|
|
218
|
-
}, {
|
|
219
|
-
key: "getSourceClientOffset",
|
|
220
|
-
value: function getSourceClientOffset() {
|
|
221
|
-
return this.internalMonitor.getSourceClientOffset();
|
|
222
|
-
}
|
|
223
|
-
}, {
|
|
224
|
-
key: "getClientOffset",
|
|
225
|
-
value: function getClientOffset() {
|
|
226
|
-
return this.internalMonitor.getClientOffset();
|
|
227
|
-
}
|
|
228
|
-
}, {
|
|
229
|
-
key: "getDifferenceFromInitialOffset",
|
|
230
|
-
value: function getDifferenceFromInitialOffset() {
|
|
231
|
-
return this.internalMonitor.getDifferenceFromInitialOffset();
|
|
232
|
-
}
|
|
233
|
-
}]);
|
|
234
|
-
|
|
235
|
-
return DragSourceMonitorImpl;
|
|
236
|
-
}();
|
|
237
|
-
|
|
238
|
-
function _classCallCheck$6(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
239
|
-
|
|
240
|
-
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); } }
|
|
241
|
-
|
|
242
|
-
function _createClass$6(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$6(Constructor.prototype, protoProps); if (staticProps) _defineProperties$6(Constructor, staticProps); return Constructor; }
|
|
243
|
-
|
|
244
|
-
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; }
|
|
245
|
-
var isCallingCanDrop = false;
|
|
246
|
-
var DropTargetMonitorImpl = /*#__PURE__*/function () {
|
|
247
|
-
function DropTargetMonitorImpl(manager) {
|
|
248
|
-
_classCallCheck$6(this, DropTargetMonitorImpl);
|
|
249
|
-
|
|
250
|
-
_defineProperty$6(this, "internalMonitor", void 0);
|
|
251
|
-
|
|
252
|
-
_defineProperty$6(this, "targetId", null);
|
|
253
|
-
|
|
254
|
-
this.internalMonitor = manager.getMonitor();
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
_createClass$6(DropTargetMonitorImpl, [{
|
|
258
|
-
key: "receiveHandlerId",
|
|
259
|
-
value: function receiveHandlerId(targetId) {
|
|
260
|
-
this.targetId = targetId;
|
|
261
|
-
}
|
|
262
|
-
}, {
|
|
263
|
-
key: "getHandlerId",
|
|
264
|
-
value: function getHandlerId() {
|
|
265
|
-
return this.targetId;
|
|
266
|
-
}
|
|
267
|
-
}, {
|
|
268
|
-
key: "subscribeToStateChange",
|
|
269
|
-
value: function subscribeToStateChange(listener, options) {
|
|
270
|
-
return this.internalMonitor.subscribeToStateChange(listener, options);
|
|
271
|
-
}
|
|
272
|
-
}, {
|
|
273
|
-
key: "canDrop",
|
|
274
|
-
value: function canDrop() {
|
|
275
|
-
// Cut out early if the target id has not been set. This should prevent errors
|
|
276
|
-
// where the user has an older version of dnd-core like in
|
|
277
|
-
// https://github.com/react-dnd/react-dnd/issues/1310
|
|
278
|
-
if (!this.targetId) {
|
|
279
|
-
return false;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
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');
|
|
283
|
-
|
|
284
|
-
try {
|
|
285
|
-
isCallingCanDrop = true;
|
|
286
|
-
return this.internalMonitor.canDropOnTarget(this.targetId);
|
|
287
|
-
} finally {
|
|
288
|
-
isCallingCanDrop = false;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}, {
|
|
292
|
-
key: "isOver",
|
|
293
|
-
value: function isOver(options) {
|
|
294
|
-
if (!this.targetId) {
|
|
295
|
-
return false;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
return this.internalMonitor.isOverTarget(this.targetId, options);
|
|
299
|
-
}
|
|
300
|
-
}, {
|
|
301
|
-
key: "getItemType",
|
|
302
|
-
value: function getItemType() {
|
|
303
|
-
return this.internalMonitor.getItemType();
|
|
304
|
-
}
|
|
305
|
-
}, {
|
|
306
|
-
key: "getItem",
|
|
307
|
-
value: function getItem() {
|
|
308
|
-
return this.internalMonitor.getItem();
|
|
309
|
-
}
|
|
310
|
-
}, {
|
|
311
|
-
key: "getDropResult",
|
|
312
|
-
value: function getDropResult() {
|
|
313
|
-
return this.internalMonitor.getDropResult();
|
|
314
|
-
}
|
|
315
|
-
}, {
|
|
316
|
-
key: "didDrop",
|
|
317
|
-
value: function didDrop() {
|
|
318
|
-
return this.internalMonitor.didDrop();
|
|
319
|
-
}
|
|
320
|
-
}, {
|
|
321
|
-
key: "getInitialClientOffset",
|
|
322
|
-
value: function getInitialClientOffset() {
|
|
323
|
-
return this.internalMonitor.getInitialClientOffset();
|
|
324
|
-
}
|
|
325
|
-
}, {
|
|
326
|
-
key: "getInitialSourceClientOffset",
|
|
327
|
-
value: function getInitialSourceClientOffset() {
|
|
328
|
-
return this.internalMonitor.getInitialSourceClientOffset();
|
|
329
|
-
}
|
|
330
|
-
}, {
|
|
331
|
-
key: "getSourceClientOffset",
|
|
332
|
-
value: function getSourceClientOffset() {
|
|
333
|
-
return this.internalMonitor.getSourceClientOffset();
|
|
334
|
-
}
|
|
335
|
-
}, {
|
|
336
|
-
key: "getClientOffset",
|
|
337
|
-
value: function getClientOffset() {
|
|
338
|
-
return this.internalMonitor.getClientOffset();
|
|
339
|
-
}
|
|
340
|
-
}, {
|
|
341
|
-
key: "getDifferenceFromInitialOffset",
|
|
342
|
-
value: function getDifferenceFromInitialOffset() {
|
|
343
|
-
return this.internalMonitor.getDifferenceFromInitialOffset();
|
|
344
|
-
}
|
|
345
|
-
}]);
|
|
346
|
-
|
|
347
|
-
return DropTargetMonitorImpl;
|
|
348
|
-
}();
|
|
349
|
-
|
|
350
|
-
function throwIfCompositeComponentElement(element) {
|
|
351
|
-
// Custom components can no longer be wrapped directly in React DnD 2.0
|
|
352
|
-
// so that we don't need to depend on findDOMNode() from react-dom.
|
|
353
|
-
if (typeof element.type === 'string') {
|
|
354
|
-
return;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
var displayName = element.type.displayName || element.type.name || 'the component';
|
|
358
|
-
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.');
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
function wrapHookToRecognizeElement(hook) {
|
|
362
|
-
return function () {
|
|
363
|
-
var elementOrNode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
364
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
365
|
-
|
|
366
|
-
// When passed a node, call the hook straight away.
|
|
367
|
-
if (!isValidElement(elementOrNode)) {
|
|
368
|
-
var node = elementOrNode;
|
|
369
|
-
hook(node, options); // return the node so it can be chained (e.g. when within callback refs
|
|
370
|
-
// <div ref={node => connectDragSource(connectDropTarget(node))}/>
|
|
371
|
-
|
|
372
|
-
return node;
|
|
373
|
-
} // If passed a ReactElement, clone it and attach this function as a ref.
|
|
374
|
-
// This helps us achieve a neat API where user doesn't even know that refs
|
|
375
|
-
// are being used under the hood.
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
var element = elementOrNode;
|
|
379
|
-
throwIfCompositeComponentElement(element); // When no options are passed, use the hook directly
|
|
380
|
-
|
|
381
|
-
var ref = options ? function (node) {
|
|
382
|
-
return hook(node, options);
|
|
383
|
-
} : hook;
|
|
384
|
-
return cloneWithRef(element, ref);
|
|
385
|
-
};
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
function wrapConnectorHooks(hooks) {
|
|
389
|
-
var wrappedHooks = {};
|
|
390
|
-
Object.keys(hooks).forEach(function (key) {
|
|
391
|
-
var hook = hooks[key]; // ref objects should be passed straight through without wrapping
|
|
392
|
-
|
|
393
|
-
if (key.endsWith('Ref')) {
|
|
394
|
-
wrappedHooks[key] = hooks[key];
|
|
395
|
-
} else {
|
|
396
|
-
var wrappedHook = wrapHookToRecognizeElement(hook);
|
|
397
|
-
|
|
398
|
-
wrappedHooks[key] = function () {
|
|
399
|
-
return wrappedHook;
|
|
400
|
-
};
|
|
401
|
-
}
|
|
402
|
-
});
|
|
403
|
-
return wrappedHooks;
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
function setRef(ref, node) {
|
|
407
|
-
if (typeof ref === 'function') {
|
|
408
|
-
ref(node);
|
|
409
|
-
} else {
|
|
410
|
-
ref.current = node;
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
function cloneWithRef(element, newRef) {
|
|
415
|
-
var previousRef = element.ref;
|
|
416
|
-
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');
|
|
417
|
-
|
|
418
|
-
if (!previousRef) {
|
|
419
|
-
// When there is no ref on the element, use the new ref directly
|
|
420
|
-
return cloneElement(element, {
|
|
421
|
-
ref: newRef
|
|
422
|
-
});
|
|
423
|
-
} else {
|
|
424
|
-
return cloneElement(element, {
|
|
425
|
-
ref: function ref(node) {
|
|
426
|
-
setRef(previousRef, node);
|
|
427
|
-
setRef(newRef, node);
|
|
428
|
-
}
|
|
429
|
-
});
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
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); }
|
|
434
|
-
|
|
435
|
-
function isRef(obj) {
|
|
436
|
-
return (// eslint-disable-next-line no-prototype-builtins
|
|
437
|
-
obj !== null && _typeof$2(obj) === 'object' && Object.prototype.hasOwnProperty.call(obj, 'current')
|
|
438
|
-
);
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
function shallowEqual(objA, objB, compare, compareContext) {
|
|
442
|
-
var compareResult = compare ? compare.call(compareContext, objA, objB) : void 0;
|
|
443
|
-
|
|
444
|
-
if (compareResult !== void 0) {
|
|
445
|
-
return !!compareResult;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
if (objA === objB) {
|
|
449
|
-
return true;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
if (typeof objA !== 'object' || !objA || typeof objB !== 'object' || !objB) {
|
|
453
|
-
return false;
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
var keysA = Object.keys(objA);
|
|
457
|
-
var keysB = Object.keys(objB);
|
|
458
|
-
|
|
459
|
-
if (keysA.length !== keysB.length) {
|
|
460
|
-
return false;
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB); // Test for A's keys different from B.
|
|
464
|
-
|
|
465
|
-
for (var idx = 0; idx < keysA.length; idx++) {
|
|
466
|
-
var key = keysA[idx];
|
|
467
|
-
|
|
468
|
-
if (!bHasOwnProperty(key)) {
|
|
469
|
-
return false;
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
var valueA = objA[key];
|
|
473
|
-
var valueB = objB[key];
|
|
474
|
-
compareResult = compare ? compare.call(compareContext, valueA, valueB, key) : void 0;
|
|
475
|
-
|
|
476
|
-
if (compareResult === false || compareResult === void 0 && valueA !== valueB) {
|
|
477
|
-
return false;
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
return true;
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
function _classCallCheck$5(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
485
|
-
|
|
486
|
-
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); } }
|
|
487
|
-
|
|
488
|
-
function _createClass$5(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$5(Constructor.prototype, protoProps); if (staticProps) _defineProperties$5(Constructor, staticProps); return Constructor; }
|
|
489
|
-
|
|
490
|
-
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; }
|
|
491
|
-
var SourceConnector = /*#__PURE__*/function () {
|
|
492
|
-
// The drop target may either be attached via ref or connect function
|
|
493
|
-
// The drag preview may either be attached via ref or connect function
|
|
494
|
-
function SourceConnector(backend) {
|
|
495
|
-
var _this = this;
|
|
496
|
-
|
|
497
|
-
_classCallCheck$5(this, SourceConnector);
|
|
498
|
-
|
|
499
|
-
_defineProperty$5(this, "hooks", wrapConnectorHooks({
|
|
500
|
-
dragSource: function dragSource(node, options) {
|
|
501
|
-
_this.clearDragSource();
|
|
502
|
-
|
|
503
|
-
_this.dragSourceOptions = options || null;
|
|
504
|
-
|
|
505
|
-
if (isRef(node)) {
|
|
506
|
-
_this.dragSourceRef = node;
|
|
507
|
-
} else {
|
|
508
|
-
_this.dragSourceNode = node;
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
_this.reconnectDragSource();
|
|
512
|
-
},
|
|
513
|
-
dragPreview: function dragPreview(node, options) {
|
|
514
|
-
_this.clearDragPreview();
|
|
515
|
-
|
|
516
|
-
_this.dragPreviewOptions = options || null;
|
|
517
|
-
|
|
518
|
-
if (isRef(node)) {
|
|
519
|
-
_this.dragPreviewRef = node;
|
|
520
|
-
} else {
|
|
521
|
-
_this.dragPreviewNode = node;
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
_this.reconnectDragPreview();
|
|
525
|
-
}
|
|
526
|
-
}));
|
|
527
|
-
|
|
528
|
-
_defineProperty$5(this, "handlerId", null);
|
|
529
|
-
|
|
530
|
-
_defineProperty$5(this, "dragSourceRef", null);
|
|
531
|
-
|
|
532
|
-
_defineProperty$5(this, "dragSourceNode", void 0);
|
|
533
|
-
|
|
534
|
-
_defineProperty$5(this, "dragSourceOptionsInternal", null);
|
|
535
|
-
|
|
536
|
-
_defineProperty$5(this, "dragSourceUnsubscribe", void 0);
|
|
537
|
-
|
|
538
|
-
_defineProperty$5(this, "dragPreviewRef", null);
|
|
539
|
-
|
|
540
|
-
_defineProperty$5(this, "dragPreviewNode", void 0);
|
|
541
|
-
|
|
542
|
-
_defineProperty$5(this, "dragPreviewOptionsInternal", null);
|
|
543
|
-
|
|
544
|
-
_defineProperty$5(this, "dragPreviewUnsubscribe", void 0);
|
|
545
|
-
|
|
546
|
-
_defineProperty$5(this, "lastConnectedHandlerId", null);
|
|
547
|
-
|
|
548
|
-
_defineProperty$5(this, "lastConnectedDragSource", null);
|
|
549
|
-
|
|
550
|
-
_defineProperty$5(this, "lastConnectedDragSourceOptions", null);
|
|
551
|
-
|
|
552
|
-
_defineProperty$5(this, "lastConnectedDragPreview", null);
|
|
553
|
-
|
|
554
|
-
_defineProperty$5(this, "lastConnectedDragPreviewOptions", null);
|
|
555
|
-
|
|
556
|
-
_defineProperty$5(this, "backend", void 0);
|
|
557
|
-
|
|
558
|
-
this.backend = backend;
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
_createClass$5(SourceConnector, [{
|
|
562
|
-
key: "receiveHandlerId",
|
|
563
|
-
value: function receiveHandlerId(newHandlerId) {
|
|
564
|
-
if (this.handlerId === newHandlerId) {
|
|
565
|
-
return;
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
this.handlerId = newHandlerId;
|
|
569
|
-
this.reconnect();
|
|
570
|
-
}
|
|
571
|
-
}, {
|
|
572
|
-
key: "connectTarget",
|
|
573
|
-
get: function get() {
|
|
574
|
-
return this.dragSource;
|
|
575
|
-
}
|
|
576
|
-
}, {
|
|
577
|
-
key: "dragSourceOptions",
|
|
578
|
-
get: function get() {
|
|
579
|
-
return this.dragSourceOptionsInternal;
|
|
580
|
-
},
|
|
581
|
-
set: function set(options) {
|
|
582
|
-
this.dragSourceOptionsInternal = options;
|
|
583
|
-
}
|
|
584
|
-
}, {
|
|
585
|
-
key: "dragPreviewOptions",
|
|
586
|
-
get: function get() {
|
|
587
|
-
return this.dragPreviewOptionsInternal;
|
|
588
|
-
},
|
|
589
|
-
set: function set(options) {
|
|
590
|
-
this.dragPreviewOptionsInternal = options;
|
|
591
|
-
}
|
|
592
|
-
}, {
|
|
593
|
-
key: "reconnect",
|
|
594
|
-
value: function reconnect() {
|
|
595
|
-
this.reconnectDragSource();
|
|
596
|
-
this.reconnectDragPreview();
|
|
597
|
-
}
|
|
598
|
-
}, {
|
|
599
|
-
key: "reconnectDragSource",
|
|
600
|
-
value: function reconnectDragSource() {
|
|
601
|
-
var dragSource = this.dragSource; // if nothing has changed then don't resubscribe
|
|
602
|
-
|
|
603
|
-
var didChange = this.didHandlerIdChange() || this.didConnectedDragSourceChange() || this.didDragSourceOptionsChange();
|
|
604
|
-
|
|
605
|
-
if (didChange) {
|
|
606
|
-
this.disconnectDragSource();
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
if (!this.handlerId) {
|
|
610
|
-
return;
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
if (!dragSource) {
|
|
614
|
-
this.lastConnectedDragSource = dragSource;
|
|
615
|
-
return;
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
if (didChange) {
|
|
619
|
-
this.lastConnectedHandlerId = this.handlerId;
|
|
620
|
-
this.lastConnectedDragSource = dragSource;
|
|
621
|
-
this.lastConnectedDragSourceOptions = this.dragSourceOptions;
|
|
622
|
-
this.dragSourceUnsubscribe = this.backend.connectDragSource(this.handlerId, dragSource, this.dragSourceOptions);
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
}, {
|
|
626
|
-
key: "reconnectDragPreview",
|
|
627
|
-
value: function reconnectDragPreview() {
|
|
628
|
-
var dragPreview = this.dragPreview; // if nothing has changed then don't resubscribe
|
|
629
|
-
|
|
630
|
-
var didChange = this.didHandlerIdChange() || this.didConnectedDragPreviewChange() || this.didDragPreviewOptionsChange();
|
|
631
|
-
|
|
632
|
-
if (didChange) {
|
|
633
|
-
this.disconnectDragPreview();
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
if (!this.handlerId) {
|
|
637
|
-
return;
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
if (!dragPreview) {
|
|
641
|
-
this.lastConnectedDragPreview = dragPreview;
|
|
642
|
-
return;
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
if (didChange) {
|
|
646
|
-
this.lastConnectedHandlerId = this.handlerId;
|
|
647
|
-
this.lastConnectedDragPreview = dragPreview;
|
|
648
|
-
this.lastConnectedDragPreviewOptions = this.dragPreviewOptions;
|
|
649
|
-
this.dragPreviewUnsubscribe = this.backend.connectDragPreview(this.handlerId, dragPreview, this.dragPreviewOptions);
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
}, {
|
|
653
|
-
key: "didHandlerIdChange",
|
|
654
|
-
value: function didHandlerIdChange() {
|
|
655
|
-
return this.lastConnectedHandlerId !== this.handlerId;
|
|
656
|
-
}
|
|
657
|
-
}, {
|
|
658
|
-
key: "didConnectedDragSourceChange",
|
|
659
|
-
value: function didConnectedDragSourceChange() {
|
|
660
|
-
return this.lastConnectedDragSource !== this.dragSource;
|
|
661
|
-
}
|
|
662
|
-
}, {
|
|
663
|
-
key: "didConnectedDragPreviewChange",
|
|
664
|
-
value: function didConnectedDragPreviewChange() {
|
|
665
|
-
return this.lastConnectedDragPreview !== this.dragPreview;
|
|
666
|
-
}
|
|
667
|
-
}, {
|
|
668
|
-
key: "didDragSourceOptionsChange",
|
|
669
|
-
value: function didDragSourceOptionsChange() {
|
|
670
|
-
return !shallowEqual(this.lastConnectedDragSourceOptions, this.dragSourceOptions);
|
|
671
|
-
}
|
|
672
|
-
}, {
|
|
673
|
-
key: "didDragPreviewOptionsChange",
|
|
674
|
-
value: function didDragPreviewOptionsChange() {
|
|
675
|
-
return !shallowEqual(this.lastConnectedDragPreviewOptions, this.dragPreviewOptions);
|
|
676
|
-
}
|
|
677
|
-
}, {
|
|
678
|
-
key: "disconnectDragSource",
|
|
679
|
-
value: function disconnectDragSource() {
|
|
680
|
-
if (this.dragSourceUnsubscribe) {
|
|
681
|
-
this.dragSourceUnsubscribe();
|
|
682
|
-
this.dragSourceUnsubscribe = undefined;
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
}, {
|
|
686
|
-
key: "disconnectDragPreview",
|
|
687
|
-
value: function disconnectDragPreview() {
|
|
688
|
-
if (this.dragPreviewUnsubscribe) {
|
|
689
|
-
this.dragPreviewUnsubscribe();
|
|
690
|
-
this.dragPreviewUnsubscribe = undefined;
|
|
691
|
-
this.dragPreviewNode = null;
|
|
692
|
-
this.dragPreviewRef = null;
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
}, {
|
|
696
|
-
key: "dragSource",
|
|
697
|
-
get: function get() {
|
|
698
|
-
return this.dragSourceNode || this.dragSourceRef && this.dragSourceRef.current;
|
|
699
|
-
}
|
|
700
|
-
}, {
|
|
701
|
-
key: "dragPreview",
|
|
702
|
-
get: function get() {
|
|
703
|
-
return this.dragPreviewNode || this.dragPreviewRef && this.dragPreviewRef.current;
|
|
704
|
-
}
|
|
705
|
-
}, {
|
|
706
|
-
key: "clearDragSource",
|
|
707
|
-
value: function clearDragSource() {
|
|
708
|
-
this.dragSourceNode = null;
|
|
709
|
-
this.dragSourceRef = null;
|
|
710
|
-
}
|
|
711
|
-
}, {
|
|
712
|
-
key: "clearDragPreview",
|
|
713
|
-
value: function clearDragPreview() {
|
|
714
|
-
this.dragPreviewNode = null;
|
|
715
|
-
this.dragPreviewRef = null;
|
|
716
|
-
}
|
|
717
|
-
}]);
|
|
718
|
-
|
|
719
|
-
return SourceConnector;
|
|
720
|
-
}();
|
|
721
|
-
|
|
722
|
-
function _classCallCheck$4(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
723
|
-
|
|
724
|
-
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); } }
|
|
725
|
-
|
|
726
|
-
function _createClass$4(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$4(Constructor.prototype, protoProps); if (staticProps) _defineProperties$4(Constructor, staticProps); return Constructor; }
|
|
727
|
-
|
|
728
|
-
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; }
|
|
729
|
-
var TargetConnector = /*#__PURE__*/function () {
|
|
730
|
-
// The drop target may either be attached via ref or connect function
|
|
731
|
-
function TargetConnector(backend) {
|
|
732
|
-
var _this = this;
|
|
733
|
-
|
|
734
|
-
_classCallCheck$4(this, TargetConnector);
|
|
735
|
-
|
|
736
|
-
_defineProperty$4(this, "hooks", wrapConnectorHooks({
|
|
737
|
-
dropTarget: function dropTarget(node, options) {
|
|
738
|
-
_this.clearDropTarget();
|
|
739
|
-
|
|
740
|
-
_this.dropTargetOptions = options;
|
|
741
|
-
|
|
742
|
-
if (isRef(node)) {
|
|
743
|
-
_this.dropTargetRef = node;
|
|
744
|
-
} else {
|
|
745
|
-
_this.dropTargetNode = node;
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
_this.reconnect();
|
|
749
|
-
}
|
|
750
|
-
}));
|
|
751
|
-
|
|
752
|
-
_defineProperty$4(this, "handlerId", null);
|
|
753
|
-
|
|
754
|
-
_defineProperty$4(this, "dropTargetRef", null);
|
|
755
|
-
|
|
756
|
-
_defineProperty$4(this, "dropTargetNode", void 0);
|
|
757
|
-
|
|
758
|
-
_defineProperty$4(this, "dropTargetOptionsInternal", null);
|
|
759
|
-
|
|
760
|
-
_defineProperty$4(this, "unsubscribeDropTarget", void 0);
|
|
761
|
-
|
|
762
|
-
_defineProperty$4(this, "lastConnectedHandlerId", null);
|
|
763
|
-
|
|
764
|
-
_defineProperty$4(this, "lastConnectedDropTarget", null);
|
|
765
|
-
|
|
766
|
-
_defineProperty$4(this, "lastConnectedDropTargetOptions", null);
|
|
767
|
-
|
|
768
|
-
_defineProperty$4(this, "backend", void 0);
|
|
769
|
-
|
|
770
|
-
this.backend = backend;
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
_createClass$4(TargetConnector, [{
|
|
774
|
-
key: "connectTarget",
|
|
775
|
-
get: function get() {
|
|
776
|
-
return this.dropTarget;
|
|
777
|
-
}
|
|
778
|
-
}, {
|
|
779
|
-
key: "reconnect",
|
|
780
|
-
value: function reconnect() {
|
|
781
|
-
// if nothing has changed then don't resubscribe
|
|
782
|
-
var didChange = this.didHandlerIdChange() || this.didDropTargetChange() || this.didOptionsChange();
|
|
783
|
-
|
|
784
|
-
if (didChange) {
|
|
785
|
-
this.disconnectDropTarget();
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
var dropTarget = this.dropTarget;
|
|
789
|
-
|
|
790
|
-
if (!this.handlerId) {
|
|
791
|
-
return;
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
if (!dropTarget) {
|
|
795
|
-
this.lastConnectedDropTarget = dropTarget;
|
|
796
|
-
return;
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
if (didChange) {
|
|
800
|
-
this.lastConnectedHandlerId = this.handlerId;
|
|
801
|
-
this.lastConnectedDropTarget = dropTarget;
|
|
802
|
-
this.lastConnectedDropTargetOptions = this.dropTargetOptions;
|
|
803
|
-
this.unsubscribeDropTarget = this.backend.connectDropTarget(this.handlerId, dropTarget, this.dropTargetOptions);
|
|
804
|
-
}
|
|
805
|
-
}
|
|
806
|
-
}, {
|
|
807
|
-
key: "receiveHandlerId",
|
|
808
|
-
value: function receiveHandlerId(newHandlerId) {
|
|
809
|
-
if (newHandlerId === this.handlerId) {
|
|
810
|
-
return;
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
this.handlerId = newHandlerId;
|
|
814
|
-
this.reconnect();
|
|
815
|
-
}
|
|
816
|
-
}, {
|
|
817
|
-
key: "dropTargetOptions",
|
|
818
|
-
get: function get() {
|
|
819
|
-
return this.dropTargetOptionsInternal;
|
|
820
|
-
},
|
|
821
|
-
set: function set(options) {
|
|
822
|
-
this.dropTargetOptionsInternal = options;
|
|
823
|
-
}
|
|
824
|
-
}, {
|
|
825
|
-
key: "didHandlerIdChange",
|
|
826
|
-
value: function didHandlerIdChange() {
|
|
827
|
-
return this.lastConnectedHandlerId !== this.handlerId;
|
|
828
|
-
}
|
|
829
|
-
}, {
|
|
830
|
-
key: "didDropTargetChange",
|
|
831
|
-
value: function didDropTargetChange() {
|
|
832
|
-
return this.lastConnectedDropTarget !== this.dropTarget;
|
|
833
|
-
}
|
|
834
|
-
}, {
|
|
835
|
-
key: "didOptionsChange",
|
|
836
|
-
value: function didOptionsChange() {
|
|
837
|
-
return !shallowEqual(this.lastConnectedDropTargetOptions, this.dropTargetOptions);
|
|
838
|
-
}
|
|
839
|
-
}, {
|
|
840
|
-
key: "disconnectDropTarget",
|
|
841
|
-
value: function disconnectDropTarget() {
|
|
842
|
-
if (this.unsubscribeDropTarget) {
|
|
843
|
-
this.unsubscribeDropTarget();
|
|
844
|
-
this.unsubscribeDropTarget = undefined;
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
}, {
|
|
848
|
-
key: "dropTarget",
|
|
849
|
-
get: function get() {
|
|
850
|
-
return this.dropTargetNode || this.dropTargetRef && this.dropTargetRef.current;
|
|
851
|
-
}
|
|
852
|
-
}, {
|
|
853
|
-
key: "clearDropTarget",
|
|
854
|
-
value: function clearDropTarget() {
|
|
855
|
-
this.dropTargetRef = null;
|
|
856
|
-
this.dropTargetNode = null;
|
|
857
|
-
}
|
|
858
|
-
}]);
|
|
859
|
-
|
|
860
|
-
return TargetConnector;
|
|
861
|
-
}();
|
|
862
|
-
|
|
863
|
-
function registerTarget(type, target, manager) {
|
|
864
|
-
var registry = manager.getRegistry();
|
|
865
|
-
var targetId = registry.addTarget(type, target);
|
|
866
|
-
return [targetId, function () {
|
|
867
|
-
return registry.removeTarget(targetId);
|
|
868
|
-
}];
|
|
869
|
-
}
|
|
870
|
-
function registerSource(type, source, manager) {
|
|
871
|
-
var registry = manager.getRegistry();
|
|
872
|
-
var sourceId = registry.addSource(type, source);
|
|
873
|
-
return [sourceId, function () {
|
|
874
|
-
return registry.removeSource(sourceId);
|
|
875
|
-
}];
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
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); }
|
|
879
|
-
|
|
880
|
-
function getDecoratedComponent(instanceRef) {
|
|
881
|
-
var currentRef = instanceRef.current;
|
|
882
|
-
|
|
883
|
-
if (currentRef == null) {
|
|
884
|
-
return null;
|
|
885
|
-
} else if (currentRef.decoratedRef) {
|
|
886
|
-
// go through the private field in decorateHandler to avoid the invariant hit
|
|
887
|
-
return currentRef.decoratedRef.current;
|
|
888
|
-
} else {
|
|
889
|
-
return currentRef;
|
|
890
|
-
}
|
|
891
|
-
}
|
|
892
|
-
function isClassComponent(Component) {
|
|
893
|
-
return Component && Component.prototype && typeof Component.prototype.render === 'function';
|
|
894
|
-
}
|
|
895
|
-
function isRefForwardingComponent(C) {
|
|
896
|
-
var _item$$$typeof;
|
|
897
|
-
|
|
898
|
-
var item = C;
|
|
899
|
-
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)';
|
|
900
|
-
}
|
|
901
|
-
function isRefable(C) {
|
|
902
|
-
return isClassComponent(C) || isRefForwardingComponent(C);
|
|
903
|
-
}
|
|
904
|
-
function checkDecoratorArguments(functionName, signature) {
|
|
905
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
906
|
-
for (var i = 0; i < (arguments.length <= 2 ? 0 : arguments.length - 2); i++) {
|
|
907
|
-
var arg = i + 2 < 2 || arguments.length <= i + 2 ? undefined : arguments[i + 2];
|
|
908
|
-
|
|
909
|
-
if (arg && arg.prototype && arg.prototype.render) {
|
|
910
|
-
// eslint-disable-next-line no-console
|
|
911
|
-
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');
|
|
912
|
-
return;
|
|
913
|
-
}
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
}
|
|
917
|
-
function isFunction(input) {
|
|
918
|
-
return typeof input === 'function';
|
|
919
|
-
}
|
|
920
|
-
function noop() {// noop
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
function isObjectLike(input) {
|
|
924
|
-
return _typeof$1(input) === 'object' && input !== null;
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
function isPlainObject(input) {
|
|
928
|
-
if (!isObjectLike(input)) {
|
|
929
|
-
return false;
|
|
930
|
-
}
|
|
931
|
-
|
|
932
|
-
if (Object.getPrototypeOf(input) === null) {
|
|
933
|
-
return true;
|
|
934
|
-
}
|
|
935
|
-
|
|
936
|
-
var proto = input;
|
|
937
|
-
|
|
938
|
-
while (Object.getPrototypeOf(proto) !== null) {
|
|
939
|
-
proto = Object.getPrototypeOf(proto);
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
return Object.getPrototypeOf(input) === proto;
|
|
943
|
-
}
|
|
944
|
-
function isValidType(type, allowArray) {
|
|
945
|
-
return typeof type === 'string' || _typeof$1(type) === 'symbol' || !!allowArray && Array.isArray(type) && type.every(function (t) {
|
|
946
|
-
return isValidType(t, false);
|
|
947
|
-
});
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
function _classCallCheck$3(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
951
|
-
|
|
952
|
-
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); } }
|
|
953
|
-
|
|
954
|
-
function _createClass$3(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$3(Constructor.prototype, protoProps); if (staticProps) _defineProperties$3(Constructor, staticProps); return Constructor; }
|
|
955
|
-
|
|
956
|
-
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; }
|
|
957
|
-
/**
|
|
958
|
-
* Provides a set of static methods for creating Disposables.
|
|
959
|
-
* @param {Function} action Action to run during the first call to dispose.
|
|
960
|
-
* The action is guaranteed to be run at most once.
|
|
961
|
-
*/
|
|
962
|
-
|
|
963
|
-
var Disposable = /*#__PURE__*/function () {
|
|
964
|
-
function Disposable(action) {
|
|
965
|
-
_classCallCheck$3(this, Disposable);
|
|
966
|
-
|
|
967
|
-
_defineProperty$3(this, "isDisposed", false);
|
|
968
|
-
|
|
969
|
-
_defineProperty$3(this, "action", void 0);
|
|
970
|
-
|
|
971
|
-
this.action = isFunction(action) ? action : noop;
|
|
972
|
-
}
|
|
973
|
-
/** Performs the task of cleaning up resources. */
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
_createClass$3(Disposable, [{
|
|
977
|
-
key: "dispose",
|
|
978
|
-
value: function dispose() {
|
|
979
|
-
if (!this.isDisposed) {
|
|
980
|
-
this.action();
|
|
981
|
-
this.isDisposed = true;
|
|
982
|
-
}
|
|
983
|
-
}
|
|
984
|
-
}], [{
|
|
985
|
-
key: "isDisposable",
|
|
986
|
-
value:
|
|
987
|
-
/**
|
|
988
|
-
* Gets the disposable that does nothing when disposed.
|
|
989
|
-
*/
|
|
990
|
-
|
|
991
|
-
/**
|
|
992
|
-
* Validates whether the given object is a disposable
|
|
993
|
-
* @param {Object} Object to test whether it has a dispose method
|
|
994
|
-
* @returns {Boolean} true if a disposable object, else false.
|
|
995
|
-
*/
|
|
996
|
-
function isDisposable(d) {
|
|
997
|
-
return Boolean(d && isFunction(d.dispose));
|
|
998
|
-
}
|
|
999
|
-
}, {
|
|
1000
|
-
key: "_fixup",
|
|
1001
|
-
value: function _fixup(result) {
|
|
1002
|
-
return Disposable.isDisposable(result) ? result : Disposable.empty;
|
|
1003
|
-
}
|
|
1004
|
-
/**
|
|
1005
|
-
* Creates a disposable object that invokes the specified action when disposed.
|
|
1006
|
-
* @param {Function} dispose Action to run during the first call to dispose.
|
|
1007
|
-
* The action is guaranteed to be run at most once.
|
|
1008
|
-
* @return {Disposable} The disposable object that runs the given action upon disposal.
|
|
1009
|
-
*/
|
|
1010
|
-
|
|
1011
|
-
}, {
|
|
1012
|
-
key: "create",
|
|
1013
|
-
value: function create(action) {
|
|
1014
|
-
return new Disposable(action);
|
|
1015
|
-
}
|
|
1016
|
-
}]);
|
|
1017
|
-
|
|
1018
|
-
return Disposable;
|
|
1019
|
-
}();
|
|
1020
|
-
/**
|
|
1021
|
-
* Represents a group of disposable resources that are disposed together.
|
|
1022
|
-
* @constructor
|
|
1023
|
-
*/
|
|
1024
|
-
|
|
1025
|
-
_defineProperty$3(Disposable, "empty", {
|
|
1026
|
-
dispose: noop
|
|
1027
|
-
});
|
|
1028
|
-
|
|
1029
|
-
var CompositeDisposable = /*#__PURE__*/function () {
|
|
1030
|
-
function CompositeDisposable() {
|
|
1031
|
-
_classCallCheck$3(this, CompositeDisposable);
|
|
1032
|
-
|
|
1033
|
-
_defineProperty$3(this, "isDisposed", false);
|
|
1034
|
-
|
|
1035
|
-
_defineProperty$3(this, "disposables", void 0);
|
|
1036
|
-
|
|
1037
|
-
for (var _len = arguments.length, disposables = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1038
|
-
disposables[_key] = arguments[_key];
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
|
-
this.disposables = disposables;
|
|
1042
|
-
}
|
|
1043
|
-
/**
|
|
1044
|
-
* Adds a disposable to the CompositeDisposable or disposes the disposable if the CompositeDisposable is disposed.
|
|
1045
|
-
* @param {Any} item Disposable to add.
|
|
1046
|
-
*/
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
_createClass$3(CompositeDisposable, [{
|
|
1050
|
-
key: "add",
|
|
1051
|
-
value: function add(item) {
|
|
1052
|
-
if (this.isDisposed) {
|
|
1053
|
-
item.dispose();
|
|
1054
|
-
} else {
|
|
1055
|
-
this.disposables.push(item);
|
|
1056
|
-
}
|
|
1057
|
-
}
|
|
1058
|
-
/**
|
|
1059
|
-
* Removes and disposes the first occurrence of a disposable from the CompositeDisposable.
|
|
1060
|
-
* @param {Any} item Disposable to remove.
|
|
1061
|
-
* @returns {Boolean} true if found; false otherwise.
|
|
1062
|
-
*/
|
|
1063
|
-
|
|
1064
|
-
}, {
|
|
1065
|
-
key: "remove",
|
|
1066
|
-
value: function remove(item) {
|
|
1067
|
-
var shouldDispose = false;
|
|
1068
|
-
|
|
1069
|
-
if (!this.isDisposed) {
|
|
1070
|
-
var idx = this.disposables.indexOf(item);
|
|
1071
|
-
|
|
1072
|
-
if (idx !== -1) {
|
|
1073
|
-
shouldDispose = true;
|
|
1074
|
-
this.disposables.splice(idx, 1);
|
|
1075
|
-
item.dispose();
|
|
1076
|
-
}
|
|
1077
|
-
}
|
|
1078
|
-
|
|
1079
|
-
return shouldDispose;
|
|
1080
|
-
}
|
|
1081
|
-
/**
|
|
1082
|
-
* Disposes all disposables in the group and removes them from the group but
|
|
1083
|
-
* does not dispose the CompositeDisposable.
|
|
1084
|
-
*/
|
|
1085
|
-
|
|
1086
|
-
}, {
|
|
1087
|
-
key: "clear",
|
|
1088
|
-
value: function clear() {
|
|
1089
|
-
if (!this.isDisposed) {
|
|
1090
|
-
var len = this.disposables.length;
|
|
1091
|
-
var currentDisposables = new Array(len);
|
|
1092
|
-
|
|
1093
|
-
for (var i = 0; i < len; i++) {
|
|
1094
|
-
currentDisposables[i] = this.disposables[i];
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
|
-
this.disposables = [];
|
|
1098
|
-
|
|
1099
|
-
for (var _i = 0; _i < len; _i++) {
|
|
1100
|
-
currentDisposables[_i].dispose();
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
|
-
}
|
|
1104
|
-
/**
|
|
1105
|
-
* Disposes all disposables in the group and removes them from the group.
|
|
1106
|
-
*/
|
|
1107
|
-
|
|
1108
|
-
}, {
|
|
1109
|
-
key: "dispose",
|
|
1110
|
-
value: function dispose() {
|
|
1111
|
-
if (!this.isDisposed) {
|
|
1112
|
-
this.isDisposed = true;
|
|
1113
|
-
var len = this.disposables.length;
|
|
1114
|
-
var currentDisposables = new Array(len);
|
|
1115
|
-
|
|
1116
|
-
for (var i = 0; i < len; i++) {
|
|
1117
|
-
currentDisposables[i] = this.disposables[i];
|
|
1118
|
-
}
|
|
1119
|
-
|
|
1120
|
-
this.disposables = [];
|
|
1121
|
-
|
|
1122
|
-
for (var _i2 = 0; _i2 < len; _i2++) {
|
|
1123
|
-
currentDisposables[_i2].dispose();
|
|
1124
|
-
}
|
|
1125
|
-
}
|
|
1126
|
-
}
|
|
1127
|
-
}]);
|
|
1128
|
-
|
|
1129
|
-
return CompositeDisposable;
|
|
1130
|
-
}();
|
|
1131
|
-
/**
|
|
1132
|
-
* Represents a disposable resource whose underlying disposable resource can
|
|
1133
|
-
* be replaced by another disposable resource, causing automatic disposal of
|
|
1134
|
-
* the previous underlying disposable resource.
|
|
1135
|
-
*/
|
|
1136
|
-
|
|
1137
|
-
var SerialDisposable = /*#__PURE__*/function () {
|
|
1138
|
-
function SerialDisposable() {
|
|
1139
|
-
_classCallCheck$3(this, SerialDisposable);
|
|
1140
|
-
|
|
1141
|
-
_defineProperty$3(this, "isDisposed", false);
|
|
1142
|
-
|
|
1143
|
-
_defineProperty$3(this, "current", void 0);
|
|
1144
|
-
}
|
|
1145
|
-
|
|
1146
|
-
_createClass$3(SerialDisposable, [{
|
|
1147
|
-
key: "getDisposable",
|
|
1148
|
-
value:
|
|
1149
|
-
/**
|
|
1150
|
-
* Gets the underlying disposable.
|
|
1151
|
-
* @returns {Any} the underlying disposable.
|
|
1152
|
-
*/
|
|
1153
|
-
function getDisposable() {
|
|
1154
|
-
return this.current;
|
|
1155
|
-
}
|
|
1156
|
-
}, {
|
|
1157
|
-
key: "setDisposable",
|
|
1158
|
-
value: function setDisposable(value) {
|
|
1159
|
-
var shouldDispose = this.isDisposed;
|
|
1160
|
-
|
|
1161
|
-
if (!shouldDispose) {
|
|
1162
|
-
var old = this.current;
|
|
1163
|
-
this.current = value;
|
|
1164
|
-
|
|
1165
|
-
if (old) {
|
|
1166
|
-
old.dispose();
|
|
1167
|
-
}
|
|
1168
|
-
}
|
|
1169
|
-
|
|
1170
|
-
if (shouldDispose && value) {
|
|
1171
|
-
value.dispose();
|
|
1172
|
-
}
|
|
1173
|
-
}
|
|
1174
|
-
/** Performs the task of cleaning up resources. */
|
|
1175
|
-
|
|
1176
|
-
}, {
|
|
1177
|
-
key: "dispose",
|
|
1178
|
-
value: function dispose() {
|
|
1179
|
-
if (!this.isDisposed) {
|
|
1180
|
-
this.isDisposed = true;
|
|
1181
|
-
var old = this.current;
|
|
1182
|
-
this.current = undefined;
|
|
1183
|
-
|
|
1184
|
-
if (old) {
|
|
1185
|
-
old.dispose();
|
|
1186
|
-
}
|
|
1187
|
-
}
|
|
1188
|
-
}
|
|
1189
|
-
}]);
|
|
1190
|
-
|
|
1191
|
-
return SerialDisposable;
|
|
1192
|
-
}();
|
|
1193
|
-
|
|
1194
|
-
var reactIs$1 = {exports: {}};
|
|
1195
|
-
|
|
1196
|
-
var reactIs_production_min = {};
|
|
1197
|
-
|
|
1198
|
-
/** @license React v16.13.1
|
|
1199
|
-
* react-is.production.min.js
|
|
1200
|
-
*
|
|
1201
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
1202
|
-
*
|
|
1203
|
-
* This source code is licensed under the MIT license found in the
|
|
1204
|
-
* LICENSE file in the root directory of this source tree.
|
|
1205
|
-
*/
|
|
1206
|
-
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?
|
|
1207
|
-
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;
|
|
1208
|
-
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;
|
|
1209
|
-
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};
|
|
1210
|
-
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};
|
|
1211
|
-
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;
|
|
1212
|
-
|
|
1213
|
-
var reactIs_development = {};
|
|
1214
|
-
|
|
1215
|
-
/** @license React v16.13.1
|
|
1216
|
-
* react-is.development.js
|
|
1217
|
-
*
|
|
1218
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
1219
|
-
*
|
|
1220
|
-
* This source code is licensed under the MIT license found in the
|
|
1221
|
-
* LICENSE file in the root directory of this source tree.
|
|
1222
|
-
*/
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
if (process.env.NODE_ENV !== "production") {
|
|
1227
|
-
(function() {
|
|
1228
|
-
|
|
1229
|
-
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
|
1230
|
-
// nor polyfill, then a plain number is used for performance.
|
|
1231
|
-
var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
|
1232
|
-
var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
|
1233
|
-
var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
|
1234
|
-
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
|
1235
|
-
var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
|
1236
|
-
var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
|
1237
|
-
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
|
1238
|
-
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
|
|
1239
|
-
// (unstable) APIs that have been removed. Can we remove the symbols?
|
|
1240
|
-
|
|
1241
|
-
var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
|
|
1242
|
-
var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
|
|
1243
|
-
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
|
1244
|
-
var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
|
|
1245
|
-
var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
|
|
1246
|
-
var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
|
|
1247
|
-
var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
|
|
1248
|
-
var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
|
|
1249
|
-
var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
|
|
1250
|
-
var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
|
|
1251
|
-
var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
|
|
1252
|
-
|
|
1253
|
-
function isValidElementType(type) {
|
|
1254
|
-
return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
|
|
1255
|
-
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);
|
|
1256
|
-
}
|
|
1257
|
-
|
|
1258
|
-
function typeOf(object) {
|
|
1259
|
-
if (typeof object === 'object' && object !== null) {
|
|
1260
|
-
var $$typeof = object.$$typeof;
|
|
1261
|
-
|
|
1262
|
-
switch ($$typeof) {
|
|
1263
|
-
case REACT_ELEMENT_TYPE:
|
|
1264
|
-
var type = object.type;
|
|
1265
|
-
|
|
1266
|
-
switch (type) {
|
|
1267
|
-
case REACT_ASYNC_MODE_TYPE:
|
|
1268
|
-
case REACT_CONCURRENT_MODE_TYPE:
|
|
1269
|
-
case REACT_FRAGMENT_TYPE:
|
|
1270
|
-
case REACT_PROFILER_TYPE:
|
|
1271
|
-
case REACT_STRICT_MODE_TYPE:
|
|
1272
|
-
case REACT_SUSPENSE_TYPE:
|
|
1273
|
-
return type;
|
|
1274
|
-
|
|
1275
|
-
default:
|
|
1276
|
-
var $$typeofType = type && type.$$typeof;
|
|
1277
|
-
|
|
1278
|
-
switch ($$typeofType) {
|
|
1279
|
-
case REACT_CONTEXT_TYPE:
|
|
1280
|
-
case REACT_FORWARD_REF_TYPE:
|
|
1281
|
-
case REACT_LAZY_TYPE:
|
|
1282
|
-
case REACT_MEMO_TYPE:
|
|
1283
|
-
case REACT_PROVIDER_TYPE:
|
|
1284
|
-
return $$typeofType;
|
|
1285
|
-
|
|
1286
|
-
default:
|
|
1287
|
-
return $$typeof;
|
|
1288
|
-
}
|
|
1289
|
-
|
|
1290
|
-
}
|
|
1291
|
-
|
|
1292
|
-
case REACT_PORTAL_TYPE:
|
|
1293
|
-
return $$typeof;
|
|
1294
|
-
}
|
|
1295
|
-
}
|
|
1296
|
-
|
|
1297
|
-
return undefined;
|
|
1298
|
-
} // AsyncMode is deprecated along with isAsyncMode
|
|
1299
|
-
|
|
1300
|
-
var AsyncMode = REACT_ASYNC_MODE_TYPE;
|
|
1301
|
-
var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
|
|
1302
|
-
var ContextConsumer = REACT_CONTEXT_TYPE;
|
|
1303
|
-
var ContextProvider = REACT_PROVIDER_TYPE;
|
|
1304
|
-
var Element = REACT_ELEMENT_TYPE;
|
|
1305
|
-
var ForwardRef = REACT_FORWARD_REF_TYPE;
|
|
1306
|
-
var Fragment = REACT_FRAGMENT_TYPE;
|
|
1307
|
-
var Lazy = REACT_LAZY_TYPE;
|
|
1308
|
-
var Memo = REACT_MEMO_TYPE;
|
|
1309
|
-
var Portal = REACT_PORTAL_TYPE;
|
|
1310
|
-
var Profiler = REACT_PROFILER_TYPE;
|
|
1311
|
-
var StrictMode = REACT_STRICT_MODE_TYPE;
|
|
1312
|
-
var Suspense = REACT_SUSPENSE_TYPE;
|
|
1313
|
-
var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated
|
|
1314
|
-
|
|
1315
|
-
function isAsyncMode(object) {
|
|
1316
|
-
{
|
|
1317
|
-
if (!hasWarnedAboutDeprecatedIsAsyncMode) {
|
|
1318
|
-
hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
|
|
1319
|
-
|
|
1320
|
-
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.');
|
|
1321
|
-
}
|
|
1322
|
-
}
|
|
1323
|
-
|
|
1324
|
-
return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
|
|
1325
|
-
}
|
|
1326
|
-
function isConcurrentMode(object) {
|
|
1327
|
-
return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
|
|
1328
|
-
}
|
|
1329
|
-
function isContextConsumer(object) {
|
|
1330
|
-
return typeOf(object) === REACT_CONTEXT_TYPE;
|
|
1331
|
-
}
|
|
1332
|
-
function isContextProvider(object) {
|
|
1333
|
-
return typeOf(object) === REACT_PROVIDER_TYPE;
|
|
1334
|
-
}
|
|
1335
|
-
function isElement(object) {
|
|
1336
|
-
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
1337
|
-
}
|
|
1338
|
-
function isForwardRef(object) {
|
|
1339
|
-
return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
|
1340
|
-
}
|
|
1341
|
-
function isFragment(object) {
|
|
1342
|
-
return typeOf(object) === REACT_FRAGMENT_TYPE;
|
|
1343
|
-
}
|
|
1344
|
-
function isLazy(object) {
|
|
1345
|
-
return typeOf(object) === REACT_LAZY_TYPE;
|
|
1346
|
-
}
|
|
1347
|
-
function isMemo(object) {
|
|
1348
|
-
return typeOf(object) === REACT_MEMO_TYPE;
|
|
1349
|
-
}
|
|
1350
|
-
function isPortal(object) {
|
|
1351
|
-
return typeOf(object) === REACT_PORTAL_TYPE;
|
|
1352
|
-
}
|
|
1353
|
-
function isProfiler(object) {
|
|
1354
|
-
return typeOf(object) === REACT_PROFILER_TYPE;
|
|
1355
|
-
}
|
|
1356
|
-
function isStrictMode(object) {
|
|
1357
|
-
return typeOf(object) === REACT_STRICT_MODE_TYPE;
|
|
1358
|
-
}
|
|
1359
|
-
function isSuspense(object) {
|
|
1360
|
-
return typeOf(object) === REACT_SUSPENSE_TYPE;
|
|
1361
|
-
}
|
|
1362
|
-
|
|
1363
|
-
reactIs_development.AsyncMode = AsyncMode;
|
|
1364
|
-
reactIs_development.ConcurrentMode = ConcurrentMode;
|
|
1365
|
-
reactIs_development.ContextConsumer = ContextConsumer;
|
|
1366
|
-
reactIs_development.ContextProvider = ContextProvider;
|
|
1367
|
-
reactIs_development.Element = Element;
|
|
1368
|
-
reactIs_development.ForwardRef = ForwardRef;
|
|
1369
|
-
reactIs_development.Fragment = Fragment;
|
|
1370
|
-
reactIs_development.Lazy = Lazy;
|
|
1371
|
-
reactIs_development.Memo = Memo;
|
|
1372
|
-
reactIs_development.Portal = Portal;
|
|
1373
|
-
reactIs_development.Profiler = Profiler;
|
|
1374
|
-
reactIs_development.StrictMode = StrictMode;
|
|
1375
|
-
reactIs_development.Suspense = Suspense;
|
|
1376
|
-
reactIs_development.isAsyncMode = isAsyncMode;
|
|
1377
|
-
reactIs_development.isConcurrentMode = isConcurrentMode;
|
|
1378
|
-
reactIs_development.isContextConsumer = isContextConsumer;
|
|
1379
|
-
reactIs_development.isContextProvider = isContextProvider;
|
|
1380
|
-
reactIs_development.isElement = isElement;
|
|
1381
|
-
reactIs_development.isForwardRef = isForwardRef;
|
|
1382
|
-
reactIs_development.isFragment = isFragment;
|
|
1383
|
-
reactIs_development.isLazy = isLazy;
|
|
1384
|
-
reactIs_development.isMemo = isMemo;
|
|
1385
|
-
reactIs_development.isPortal = isPortal;
|
|
1386
|
-
reactIs_development.isProfiler = isProfiler;
|
|
1387
|
-
reactIs_development.isStrictMode = isStrictMode;
|
|
1388
|
-
reactIs_development.isSuspense = isSuspense;
|
|
1389
|
-
reactIs_development.isValidElementType = isValidElementType;
|
|
1390
|
-
reactIs_development.typeOf = typeOf;
|
|
1391
|
-
})();
|
|
1392
|
-
}
|
|
1393
|
-
|
|
1394
|
-
if (process.env.NODE_ENV === 'production') {
|
|
1395
|
-
reactIs$1.exports = reactIs_production_min;
|
|
1396
|
-
} else {
|
|
1397
|
-
reactIs$1.exports = reactIs_development;
|
|
1398
|
-
}
|
|
1399
|
-
|
|
1400
|
-
var reactIs = reactIs$1.exports;
|
|
1401
|
-
|
|
1402
|
-
/**
|
|
1403
|
-
* Copyright 2015, Yahoo! Inc.
|
|
1404
|
-
* Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
|
|
1405
|
-
*/
|
|
1406
|
-
var REACT_STATICS = {
|
|
1407
|
-
childContextTypes: true,
|
|
1408
|
-
contextType: true,
|
|
1409
|
-
contextTypes: true,
|
|
1410
|
-
defaultProps: true,
|
|
1411
|
-
displayName: true,
|
|
1412
|
-
getDefaultProps: true,
|
|
1413
|
-
getDerivedStateFromError: true,
|
|
1414
|
-
getDerivedStateFromProps: true,
|
|
1415
|
-
mixins: true,
|
|
1416
|
-
propTypes: true,
|
|
1417
|
-
type: true
|
|
1418
|
-
};
|
|
1419
|
-
var KNOWN_STATICS = {
|
|
1420
|
-
name: true,
|
|
1421
|
-
length: true,
|
|
1422
|
-
prototype: true,
|
|
1423
|
-
caller: true,
|
|
1424
|
-
callee: true,
|
|
1425
|
-
arguments: true,
|
|
1426
|
-
arity: true
|
|
1427
|
-
};
|
|
1428
|
-
var FORWARD_REF_STATICS = {
|
|
1429
|
-
'$$typeof': true,
|
|
1430
|
-
render: true,
|
|
1431
|
-
defaultProps: true,
|
|
1432
|
-
displayName: true,
|
|
1433
|
-
propTypes: true
|
|
1434
|
-
};
|
|
1435
|
-
var MEMO_STATICS = {
|
|
1436
|
-
'$$typeof': true,
|
|
1437
|
-
compare: true,
|
|
1438
|
-
defaultProps: true,
|
|
1439
|
-
displayName: true,
|
|
1440
|
-
propTypes: true,
|
|
1441
|
-
type: true
|
|
1442
|
-
};
|
|
1443
|
-
var TYPE_STATICS = {};
|
|
1444
|
-
TYPE_STATICS[reactIs.ForwardRef] = FORWARD_REF_STATICS;
|
|
1445
|
-
TYPE_STATICS[reactIs.Memo] = MEMO_STATICS;
|
|
1446
|
-
|
|
1447
|
-
function getStatics(component) {
|
|
1448
|
-
// React v16.11 and below
|
|
1449
|
-
if (reactIs.isMemo(component)) {
|
|
1450
|
-
return MEMO_STATICS;
|
|
1451
|
-
} // React v16.12 and above
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
return TYPE_STATICS[component['$$typeof']] || REACT_STATICS;
|
|
1455
|
-
}
|
|
1456
|
-
|
|
1457
|
-
var defineProperty = Object.defineProperty;
|
|
1458
|
-
var getOwnPropertyNames = Object.getOwnPropertyNames;
|
|
1459
|
-
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
1460
|
-
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
1461
|
-
var getPrototypeOf = Object.getPrototypeOf;
|
|
1462
|
-
var objectPrototype = Object.prototype;
|
|
1463
|
-
function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) {
|
|
1464
|
-
if (typeof sourceComponent !== 'string') {
|
|
1465
|
-
// don't hoist over string (html) components
|
|
1466
|
-
if (objectPrototype) {
|
|
1467
|
-
var inheritedComponent = getPrototypeOf(sourceComponent);
|
|
1468
|
-
|
|
1469
|
-
if (inheritedComponent && inheritedComponent !== objectPrototype) {
|
|
1470
|
-
hoistNonReactStatics(targetComponent, inheritedComponent, blacklist);
|
|
1471
|
-
}
|
|
1472
|
-
}
|
|
1473
|
-
|
|
1474
|
-
var keys = getOwnPropertyNames(sourceComponent);
|
|
1475
|
-
|
|
1476
|
-
if (getOwnPropertySymbols) {
|
|
1477
|
-
keys = keys.concat(getOwnPropertySymbols(sourceComponent));
|
|
1478
|
-
}
|
|
1479
|
-
|
|
1480
|
-
var targetStatics = getStatics(targetComponent);
|
|
1481
|
-
var sourceStatics = getStatics(sourceComponent);
|
|
1482
|
-
|
|
1483
|
-
for (var i = 0; i < keys.length; ++i) {
|
|
1484
|
-
var key = keys[i];
|
|
1485
|
-
|
|
1486
|
-
if (!KNOWN_STATICS[key] && !(blacklist && blacklist[key]) && !(sourceStatics && sourceStatics[key]) && !(targetStatics && targetStatics[key])) {
|
|
1487
|
-
var descriptor = getOwnPropertyDescriptor(sourceComponent, key);
|
|
1488
|
-
|
|
1489
|
-
try {
|
|
1490
|
-
// Avoid failures from read-only properties
|
|
1491
|
-
defineProperty(targetComponent, key, descriptor);
|
|
1492
|
-
} catch (e) {}
|
|
1493
|
-
}
|
|
1494
|
-
}
|
|
1495
|
-
}
|
|
1496
|
-
|
|
1497
|
-
return targetComponent;
|
|
1498
|
-
}
|
|
1499
|
-
|
|
1500
|
-
var hoistNonReactStatics_cjs = hoistNonReactStatics;
|
|
1501
|
-
|
|
1502
|
-
var hoistStatics = hoistNonReactStatics_cjs;
|
|
1503
|
-
|
|
1504
|
-
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); }
|
|
1505
|
-
|
|
1506
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
1507
|
-
|
|
1508
|
-
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."); }
|
|
1509
|
-
|
|
1510
|
-
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); }
|
|
1511
|
-
|
|
1512
|
-
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; }
|
|
1513
|
-
|
|
1514
|
-
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; }
|
|
1515
|
-
|
|
1516
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
1517
|
-
|
|
1518
|
-
function _classCallCheck$2(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
1519
|
-
|
|
1520
|
-
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); } }
|
|
1521
|
-
|
|
1522
|
-
function _createClass$2(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$2(Constructor.prototype, protoProps); if (staticProps) _defineProperties$2(Constructor, staticProps); return Constructor; }
|
|
1523
|
-
|
|
1524
|
-
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); }
|
|
1525
|
-
|
|
1526
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
1527
|
-
|
|
1528
|
-
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); }; }
|
|
1529
|
-
|
|
1530
|
-
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); }
|
|
1531
|
-
|
|
1532
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
1533
|
-
|
|
1534
|
-
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; } }
|
|
1535
|
-
|
|
1536
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
1537
|
-
|
|
1538
|
-
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; }
|
|
1539
|
-
function decorateHandler(_ref) {
|
|
1540
|
-
var DecoratedComponent = _ref.DecoratedComponent,
|
|
1541
|
-
createHandler = _ref.createHandler,
|
|
1542
|
-
createMonitor = _ref.createMonitor,
|
|
1543
|
-
createConnector = _ref.createConnector,
|
|
1544
|
-
registerHandler = _ref.registerHandler,
|
|
1545
|
-
containerDisplayName = _ref.containerDisplayName,
|
|
1546
|
-
getType = _ref.getType,
|
|
1547
|
-
collect = _ref.collect,
|
|
1548
|
-
options = _ref.options;
|
|
1549
|
-
var _options$arePropsEqua = options.arePropsEqual,
|
|
1550
|
-
arePropsEqual = _options$arePropsEqua === void 0 ? shallowEqual : _options$arePropsEqua;
|
|
1551
|
-
var Decorated = DecoratedComponent;
|
|
1552
|
-
var displayName = DecoratedComponent.displayName || DecoratedComponent.name || 'Component';
|
|
1553
|
-
|
|
1554
|
-
var DragDropContainer = /*#__PURE__*/function (_Component) {
|
|
1555
|
-
_inherits(DragDropContainer, _Component);
|
|
1556
|
-
|
|
1557
|
-
var _super = _createSuper(DragDropContainer);
|
|
1558
|
-
|
|
1559
|
-
function DragDropContainer(props) {
|
|
1560
|
-
var _this;
|
|
1561
|
-
|
|
1562
|
-
_classCallCheck$2(this, DragDropContainer);
|
|
1563
|
-
|
|
1564
|
-
_this = _super.call(this, props);
|
|
1565
|
-
|
|
1566
|
-
_defineProperty$2(_assertThisInitialized(_this), "decoratedRef", createRef());
|
|
1567
|
-
|
|
1568
|
-
_defineProperty$2(_assertThisInitialized(_this), "handlerId", void 0);
|
|
1569
|
-
|
|
1570
|
-
_defineProperty$2(_assertThisInitialized(_this), "manager", void 0);
|
|
1571
|
-
|
|
1572
|
-
_defineProperty$2(_assertThisInitialized(_this), "handlerMonitor", void 0);
|
|
1573
|
-
|
|
1574
|
-
_defineProperty$2(_assertThisInitialized(_this), "handlerConnector", void 0);
|
|
1575
|
-
|
|
1576
|
-
_defineProperty$2(_assertThisInitialized(_this), "handler", void 0);
|
|
1577
|
-
|
|
1578
|
-
_defineProperty$2(_assertThisInitialized(_this), "disposable", void 0);
|
|
1579
|
-
|
|
1580
|
-
_defineProperty$2(_assertThisInitialized(_this), "currentType", void 0);
|
|
1581
|
-
|
|
1582
|
-
_defineProperty$2(_assertThisInitialized(_this), "handleChange", function () {
|
|
1583
|
-
var nextState = _this.getCurrentState();
|
|
1584
|
-
|
|
1585
|
-
if (!shallowEqual(nextState, _this.state)) {
|
|
1586
|
-
_this.setState(nextState);
|
|
1587
|
-
}
|
|
1588
|
-
});
|
|
1589
|
-
|
|
1590
|
-
_this.disposable = new SerialDisposable();
|
|
1591
|
-
|
|
1592
|
-
_this.receiveProps(props);
|
|
1593
|
-
|
|
1594
|
-
_this.dispose();
|
|
1595
|
-
|
|
1596
|
-
return _this;
|
|
1597
|
-
}
|
|
1598
|
-
|
|
1599
|
-
_createClass$2(DragDropContainer, [{
|
|
1600
|
-
key: "getHandlerId",
|
|
1601
|
-
value: function getHandlerId() {
|
|
1602
|
-
return this.handlerId;
|
|
1603
|
-
}
|
|
1604
|
-
}, {
|
|
1605
|
-
key: "getDecoratedComponentInstance",
|
|
1606
|
-
value: function getDecoratedComponentInstance() {
|
|
1607
|
-
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()');
|
|
1608
|
-
return this.decoratedRef.current;
|
|
1609
|
-
}
|
|
1610
|
-
}, {
|
|
1611
|
-
key: "shouldComponentUpdate",
|
|
1612
|
-
value: function shouldComponentUpdate(nextProps, nextState) {
|
|
1613
|
-
return !arePropsEqual(nextProps, this.props) || !shallowEqual(nextState, this.state);
|
|
1614
|
-
}
|
|
1615
|
-
}, {
|
|
1616
|
-
key: "componentDidMount",
|
|
1617
|
-
value: function componentDidMount() {
|
|
1618
|
-
this.disposable = new SerialDisposable();
|
|
1619
|
-
this.currentType = undefined;
|
|
1620
|
-
this.receiveProps(this.props);
|
|
1621
|
-
this.handleChange();
|
|
1622
|
-
}
|
|
1623
|
-
}, {
|
|
1624
|
-
key: "componentDidUpdate",
|
|
1625
|
-
value: function componentDidUpdate(prevProps) {
|
|
1626
|
-
if (!arePropsEqual(this.props, prevProps)) {
|
|
1627
|
-
this.receiveProps(this.props);
|
|
1628
|
-
this.handleChange();
|
|
1629
|
-
}
|
|
1630
|
-
}
|
|
1631
|
-
}, {
|
|
1632
|
-
key: "componentWillUnmount",
|
|
1633
|
-
value: function componentWillUnmount() {
|
|
1634
|
-
this.dispose();
|
|
1635
|
-
}
|
|
1636
|
-
}, {
|
|
1637
|
-
key: "receiveProps",
|
|
1638
|
-
value: function receiveProps(props) {
|
|
1639
|
-
if (!this.handler) {
|
|
1640
|
-
return;
|
|
1641
|
-
}
|
|
1642
|
-
|
|
1643
|
-
this.handler.receiveProps(props);
|
|
1644
|
-
this.receiveType(getType(props));
|
|
1645
|
-
}
|
|
1646
|
-
}, {
|
|
1647
|
-
key: "receiveType",
|
|
1648
|
-
value: function receiveType(type) {
|
|
1649
|
-
if (!this.handlerMonitor || !this.manager || !this.handlerConnector) {
|
|
1650
|
-
return;
|
|
1651
|
-
}
|
|
1652
|
-
|
|
1653
|
-
if (type === this.currentType) {
|
|
1654
|
-
return;
|
|
1655
|
-
}
|
|
1656
|
-
|
|
1657
|
-
this.currentType = type;
|
|
1658
|
-
|
|
1659
|
-
var _registerHandler = registerHandler(type, this.handler, this.manager),
|
|
1660
|
-
_registerHandler2 = _slicedToArray(_registerHandler, 2),
|
|
1661
|
-
handlerId = _registerHandler2[0],
|
|
1662
|
-
unregister = _registerHandler2[1];
|
|
1663
|
-
|
|
1664
|
-
this.handlerId = handlerId;
|
|
1665
|
-
this.handlerMonitor.receiveHandlerId(handlerId);
|
|
1666
|
-
this.handlerConnector.receiveHandlerId(handlerId);
|
|
1667
|
-
var globalMonitor = this.manager.getMonitor();
|
|
1668
|
-
var unsubscribe = globalMonitor.subscribeToStateChange(this.handleChange, {
|
|
1669
|
-
handlerIds: [handlerId]
|
|
1670
|
-
});
|
|
1671
|
-
this.disposable.setDisposable(new CompositeDisposable(new Disposable(unsubscribe), new Disposable(unregister)));
|
|
1672
|
-
}
|
|
1673
|
-
}, {
|
|
1674
|
-
key: "dispose",
|
|
1675
|
-
value: function dispose() {
|
|
1676
|
-
this.disposable.dispose();
|
|
1677
|
-
|
|
1678
|
-
if (this.handlerConnector) {
|
|
1679
|
-
this.handlerConnector.receiveHandlerId(null);
|
|
1680
|
-
}
|
|
1681
|
-
}
|
|
1682
|
-
}, {
|
|
1683
|
-
key: "getCurrentState",
|
|
1684
|
-
value: function getCurrentState() {
|
|
1685
|
-
if (!this.handlerConnector) {
|
|
1686
|
-
return {};
|
|
1687
|
-
}
|
|
1688
|
-
|
|
1689
|
-
var nextState = collect(this.handlerConnector.hooks, this.handlerMonitor, this.props);
|
|
1690
|
-
|
|
1691
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1692
|
-
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);
|
|
1693
|
-
}
|
|
1694
|
-
|
|
1695
|
-
return nextState;
|
|
1696
|
-
}
|
|
1697
|
-
}, {
|
|
1698
|
-
key: "render",
|
|
1699
|
-
value: function render() {
|
|
1700
|
-
var _this2 = this;
|
|
1701
|
-
|
|
1702
|
-
return jsx(DndContext.Consumer, {
|
|
1703
|
-
children: function children(_ref2) {
|
|
1704
|
-
var dragDropManager = _ref2.dragDropManager;
|
|
1705
|
-
|
|
1706
|
-
_this2.receiveDragDropManager(dragDropManager);
|
|
1707
|
-
|
|
1708
|
-
if (typeof requestAnimationFrame !== 'undefined') {
|
|
1709
|
-
requestAnimationFrame(function () {
|
|
1710
|
-
var _this2$handlerConnect;
|
|
1711
|
-
|
|
1712
|
-
return (_this2$handlerConnect = _this2.handlerConnector) === null || _this2$handlerConnect === void 0 ? void 0 : _this2$handlerConnect.reconnect();
|
|
1713
|
-
});
|
|
1714
|
-
}
|
|
1715
|
-
|
|
1716
|
-
return jsx(Decorated, Object.assign({}, _this2.props, _this2.getCurrentState(), {
|
|
1717
|
-
// NOTE: if Decorated is a Function Component, decoratedRef will not be populated unless it's a refforwarding component.
|
|
1718
|
-
ref: isRefable(Decorated) ? _this2.decoratedRef : null
|
|
1719
|
-
}), void 0);
|
|
1720
|
-
}
|
|
1721
|
-
}, void 0);
|
|
1722
|
-
}
|
|
1723
|
-
}, {
|
|
1724
|
-
key: "receiveDragDropManager",
|
|
1725
|
-
value: function receiveDragDropManager(dragDropManager) {
|
|
1726
|
-
if (this.manager !== undefined) {
|
|
1727
|
-
return;
|
|
1728
|
-
}
|
|
1729
|
-
|
|
1730
|
-
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);
|
|
1731
|
-
|
|
1732
|
-
if (dragDropManager === undefined) {
|
|
1733
|
-
return;
|
|
1734
|
-
}
|
|
1735
|
-
|
|
1736
|
-
this.manager = dragDropManager;
|
|
1737
|
-
this.handlerMonitor = createMonitor(dragDropManager);
|
|
1738
|
-
this.handlerConnector = createConnector(dragDropManager.getBackend());
|
|
1739
|
-
this.handler = createHandler(this.handlerMonitor, this.decoratedRef);
|
|
1740
|
-
}
|
|
1741
|
-
}]);
|
|
1742
|
-
|
|
1743
|
-
return DragDropContainer;
|
|
1744
|
-
}(Component);
|
|
1745
|
-
|
|
1746
|
-
_defineProperty$2(DragDropContainer, "DecoratedComponent", DecoratedComponent);
|
|
1747
|
-
|
|
1748
|
-
_defineProperty$2(DragDropContainer, "displayName", "".concat(containerDisplayName, "(").concat(displayName, ")"));
|
|
1749
|
-
|
|
1750
|
-
return hoistStatics(DragDropContainer, DecoratedComponent);
|
|
1751
|
-
}
|
|
1752
|
-
|
|
1753
|
-
function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
1754
|
-
|
|
1755
|
-
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); } }
|
|
1756
|
-
|
|
1757
|
-
function _createClass$1(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$1(Constructor.prototype, protoProps); if (staticProps) _defineProperties$1(Constructor, staticProps); return Constructor; }
|
|
1758
|
-
|
|
1759
|
-
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; }
|
|
1760
|
-
var ALLOWED_SPEC_METHODS$1 = ['canDrag', 'beginDrag', 'isDragging', 'endDrag'];
|
|
1761
|
-
var REQUIRED_SPEC_METHODS = ['beginDrag'];
|
|
1762
|
-
|
|
1763
|
-
var SourceImpl = /*#__PURE__*/function () {
|
|
1764
|
-
function SourceImpl(spec, monitor, ref) {
|
|
1765
|
-
var _this = this;
|
|
1766
|
-
|
|
1767
|
-
_classCallCheck$1(this, SourceImpl);
|
|
1768
|
-
|
|
1769
|
-
_defineProperty$1(this, "props", null);
|
|
1770
|
-
|
|
1771
|
-
_defineProperty$1(this, "spec", void 0);
|
|
1772
|
-
|
|
1773
|
-
_defineProperty$1(this, "monitor", void 0);
|
|
1774
|
-
|
|
1775
|
-
_defineProperty$1(this, "ref", void 0);
|
|
1776
|
-
|
|
1777
|
-
_defineProperty$1(this, "beginDrag", function () {
|
|
1778
|
-
if (!_this.props) {
|
|
1779
|
-
return;
|
|
1780
|
-
}
|
|
1781
|
-
|
|
1782
|
-
var item = _this.spec.beginDrag(_this.props, _this.monitor, _this.ref.current);
|
|
1783
|
-
|
|
1784
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1785
|
-
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);
|
|
1786
|
-
}
|
|
1787
|
-
|
|
1788
|
-
return item;
|
|
1789
|
-
});
|
|
1790
|
-
|
|
1791
|
-
this.spec = spec;
|
|
1792
|
-
this.monitor = monitor;
|
|
1793
|
-
this.ref = ref;
|
|
1794
|
-
}
|
|
1795
|
-
|
|
1796
|
-
_createClass$1(SourceImpl, [{
|
|
1797
|
-
key: "receiveProps",
|
|
1798
|
-
value: function receiveProps(props) {
|
|
1799
|
-
this.props = props;
|
|
1800
|
-
}
|
|
1801
|
-
}, {
|
|
1802
|
-
key: "canDrag",
|
|
1803
|
-
value: function canDrag() {
|
|
1804
|
-
if (!this.props) {
|
|
1805
|
-
return false;
|
|
1806
|
-
}
|
|
1807
|
-
|
|
1808
|
-
if (!this.spec.canDrag) {
|
|
1809
|
-
return true;
|
|
1810
|
-
}
|
|
1811
|
-
|
|
1812
|
-
return this.spec.canDrag(this.props, this.monitor);
|
|
1813
|
-
}
|
|
1814
|
-
}, {
|
|
1815
|
-
key: "isDragging",
|
|
1816
|
-
value: function isDragging(globalMonitor, sourceId) {
|
|
1817
|
-
if (!this.props) {
|
|
1818
|
-
return false;
|
|
1819
|
-
}
|
|
1820
|
-
|
|
1821
|
-
if (!this.spec.isDragging) {
|
|
1822
|
-
return sourceId === globalMonitor.getSourceId();
|
|
1823
|
-
}
|
|
1824
|
-
|
|
1825
|
-
return this.spec.isDragging(this.props, this.monitor);
|
|
1826
|
-
}
|
|
1827
|
-
}, {
|
|
1828
|
-
key: "endDrag",
|
|
1829
|
-
value: function endDrag() {
|
|
1830
|
-
if (!this.props) {
|
|
1831
|
-
return;
|
|
1832
|
-
}
|
|
1833
|
-
|
|
1834
|
-
if (!this.spec.endDrag) {
|
|
1835
|
-
return;
|
|
1836
|
-
}
|
|
1837
|
-
|
|
1838
|
-
this.spec.endDrag(this.props, this.monitor, getDecoratedComponent(this.ref));
|
|
1839
|
-
}
|
|
1840
|
-
}]);
|
|
1841
|
-
|
|
1842
|
-
return SourceImpl;
|
|
1843
|
-
}();
|
|
1844
|
-
|
|
1845
|
-
function createSourceFactory(spec) {
|
|
1846
|
-
Object.keys(spec).forEach(function (key) {
|
|
1847
|
-
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);
|
|
1848
|
-
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]);
|
|
1849
|
-
});
|
|
1850
|
-
REQUIRED_SPEC_METHODS.forEach(function (key) {
|
|
1851
|
-
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]);
|
|
1852
|
-
});
|
|
1853
|
-
return function createSource(monitor, ref) {
|
|
1854
|
-
return new SourceImpl(spec, monitor, ref);
|
|
1855
|
-
};
|
|
1856
|
-
}
|
|
1857
|
-
|
|
1858
|
-
/**
|
|
1859
|
-
* Decorates a component as a dragsource
|
|
1860
|
-
* @param type The dragsource type
|
|
1861
|
-
* @param spec The drag source specification
|
|
1862
|
-
* @param collect The props collector function
|
|
1863
|
-
* @param options DnD options
|
|
1864
|
-
*/
|
|
1865
|
-
|
|
1866
|
-
function DragSource(type, spec, collect) {
|
|
1867
|
-
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
1868
|
-
checkDecoratorArguments('DragSource', 'type, spec, collect[, options]', type, spec, collect, options);
|
|
1869
|
-
var getType = type;
|
|
1870
|
-
|
|
1871
|
-
if (typeof type !== 'function') {
|
|
1872
|
-
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);
|
|
1873
|
-
|
|
1874
|
-
getType = function getType() {
|
|
1875
|
-
return type;
|
|
1876
|
-
};
|
|
1877
|
-
}
|
|
1878
|
-
|
|
1879
|
-
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);
|
|
1880
|
-
var createSource = createSourceFactory(spec);
|
|
1881
|
-
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);
|
|
1882
|
-
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);
|
|
1883
|
-
return function decorateSource(DecoratedComponent) {
|
|
1884
|
-
return decorateHandler({
|
|
1885
|
-
containerDisplayName: 'DragSource',
|
|
1886
|
-
createHandler: createSource,
|
|
1887
|
-
registerHandler: registerSource,
|
|
1888
|
-
createConnector: function createConnector(backend) {
|
|
1889
|
-
return new SourceConnector(backend);
|
|
1890
|
-
},
|
|
1891
|
-
createMonitor: function createMonitor(manager) {
|
|
1892
|
-
return new DragSourceMonitorImpl(manager);
|
|
1893
|
-
},
|
|
1894
|
-
DecoratedComponent: DecoratedComponent,
|
|
1895
|
-
getType: getType,
|
|
1896
|
-
collect: collect,
|
|
1897
|
-
options: options
|
|
1898
|
-
});
|
|
1899
|
-
};
|
|
1900
|
-
}
|
|
1901
|
-
|
|
1902
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
1903
|
-
|
|
1904
|
-
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); } }
|
|
1905
|
-
|
|
1906
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
1907
|
-
|
|
1908
|
-
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; }
|
|
1909
|
-
var ALLOWED_SPEC_METHODS = ['canDrop', 'hover', 'drop'];
|
|
1910
|
-
|
|
1911
|
-
var TargetImpl = /*#__PURE__*/function () {
|
|
1912
|
-
function TargetImpl(spec, monitor, ref) {
|
|
1913
|
-
_classCallCheck(this, TargetImpl);
|
|
1914
|
-
|
|
1915
|
-
_defineProperty(this, "props", null);
|
|
1916
|
-
|
|
1917
|
-
_defineProperty(this, "spec", void 0);
|
|
1918
|
-
|
|
1919
|
-
_defineProperty(this, "monitor", void 0);
|
|
1920
|
-
|
|
1921
|
-
_defineProperty(this, "ref", void 0);
|
|
1922
|
-
|
|
1923
|
-
this.spec = spec;
|
|
1924
|
-
this.monitor = monitor;
|
|
1925
|
-
this.ref = ref;
|
|
1926
|
-
}
|
|
1927
|
-
|
|
1928
|
-
_createClass(TargetImpl, [{
|
|
1929
|
-
key: "receiveProps",
|
|
1930
|
-
value: function receiveProps(props) {
|
|
1931
|
-
this.props = props;
|
|
1932
|
-
}
|
|
1933
|
-
}, {
|
|
1934
|
-
key: "receiveMonitor",
|
|
1935
|
-
value: function receiveMonitor(monitor) {
|
|
1936
|
-
this.monitor = monitor;
|
|
1937
|
-
}
|
|
1938
|
-
}, {
|
|
1939
|
-
key: "canDrop",
|
|
1940
|
-
value: function canDrop() {
|
|
1941
|
-
if (!this.spec.canDrop) {
|
|
1942
|
-
return true;
|
|
1943
|
-
}
|
|
1944
|
-
|
|
1945
|
-
return this.spec.canDrop(this.props, this.monitor);
|
|
1946
|
-
}
|
|
1947
|
-
}, {
|
|
1948
|
-
key: "hover",
|
|
1949
|
-
value: function hover() {
|
|
1950
|
-
if (!this.spec.hover || !this.props) {
|
|
1951
|
-
return;
|
|
1952
|
-
}
|
|
1953
|
-
|
|
1954
|
-
this.spec.hover(this.props, this.monitor, getDecoratedComponent(this.ref));
|
|
1955
|
-
}
|
|
1956
|
-
}, {
|
|
1957
|
-
key: "drop",
|
|
1958
|
-
value: function drop() {
|
|
1959
|
-
if (!this.spec.drop) {
|
|
1960
|
-
return undefined;
|
|
1961
|
-
}
|
|
1962
|
-
|
|
1963
|
-
var dropResult = this.spec.drop(this.props, this.monitor, this.ref.current);
|
|
1964
|
-
|
|
1965
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1966
|
-
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);
|
|
1967
|
-
}
|
|
1968
|
-
|
|
1969
|
-
return dropResult;
|
|
1970
|
-
}
|
|
1971
|
-
}]);
|
|
1972
|
-
|
|
1973
|
-
return TargetImpl;
|
|
1974
|
-
}();
|
|
1975
|
-
|
|
1976
|
-
function createTargetFactory(spec) {
|
|
1977
|
-
Object.keys(spec).forEach(function (key) {
|
|
1978
|
-
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);
|
|
1979
|
-
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]);
|
|
1980
|
-
});
|
|
1981
|
-
return function createTarget(monitor, ref) {
|
|
1982
|
-
return new TargetImpl(spec, monitor, ref);
|
|
1983
|
-
};
|
|
1984
|
-
}
|
|
1985
|
-
|
|
1986
|
-
/**
|
|
1987
|
-
* @param type The accepted target type
|
|
1988
|
-
* @param spec The DropTarget specification
|
|
1989
|
-
* @param collect The props collector function
|
|
1990
|
-
* @param options Options
|
|
1991
|
-
*/
|
|
1992
|
-
|
|
1993
|
-
function DropTarget(type, spec, collect) {
|
|
1994
|
-
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
1995
|
-
checkDecoratorArguments('DropTarget', 'type, spec, collect[, options]', type, spec, collect, options);
|
|
1996
|
-
var getType = type;
|
|
1997
|
-
|
|
1998
|
-
if (typeof type !== 'function') {
|
|
1999
|
-
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);
|
|
2000
|
-
|
|
2001
|
-
getType = function getType() {
|
|
2002
|
-
return type;
|
|
2003
|
-
};
|
|
2004
|
-
}
|
|
2005
|
-
|
|
2006
|
-
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);
|
|
2007
|
-
var createTarget = createTargetFactory(spec);
|
|
2008
|
-
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);
|
|
2009
|
-
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);
|
|
2010
|
-
return function decorateTarget(DecoratedComponent) {
|
|
2011
|
-
return decorateHandler({
|
|
2012
|
-
containerDisplayName: 'DropTarget',
|
|
2013
|
-
createHandler: createTarget,
|
|
2014
|
-
registerHandler: registerTarget,
|
|
2015
|
-
createMonitor: function createMonitor(manager) {
|
|
2016
|
-
return new DropTargetMonitorImpl(manager);
|
|
2017
|
-
},
|
|
2018
|
-
createConnector: function createConnector(backend) {
|
|
2019
|
-
return new TargetConnector(backend);
|
|
2020
|
-
},
|
|
2021
|
-
DecoratedComponent: DecoratedComponent,
|
|
2022
|
-
getType: getType,
|
|
2023
|
-
collect: collect,
|
|
2024
|
-
options: options
|
|
2025
|
-
});
|
|
2026
|
-
};
|
|
2027
|
-
}
|
|
2028
|
-
|
|
2029
|
-
const log$2 = debug('@pie-ui:categorize:choice');
|
|
2030
|
-
const ChoiceType = {
|
|
2031
|
-
content: PropTypes.string.isRequired,
|
|
2032
|
-
id: PropTypes.string
|
|
2033
|
-
};
|
|
2034
|
-
class Layout extends React.Component {
|
|
2035
|
-
render() {
|
|
2036
|
-
const {
|
|
2037
|
-
classes,
|
|
2038
|
-
className,
|
|
2039
|
-
content,
|
|
2040
|
-
isDragging,
|
|
2041
|
-
disabled,
|
|
2042
|
-
correct
|
|
2043
|
-
} = this.props;
|
|
2044
|
-
const rootNames = classNames(correct === true && 'correct', correct === false && 'incorrect', classes.choice, isDragging && classes.dragging, disabled && classes.disabled, className);
|
|
2045
|
-
const cardNames = classNames(classes.card);
|
|
2046
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
2047
|
-
className: rootNames
|
|
2048
|
-
}, /*#__PURE__*/React.createElement(Card, {
|
|
2049
|
-
className: cardNames
|
|
2050
|
-
}, /*#__PURE__*/React.createElement(CardContent, {
|
|
2051
|
-
classes: {
|
|
2052
|
-
root: classes.cardRoot
|
|
2053
|
-
},
|
|
2054
|
-
dangerouslySetInnerHTML: {
|
|
2055
|
-
__html: content
|
|
2056
|
-
}
|
|
2057
|
-
})));
|
|
2058
|
-
}
|
|
2059
|
-
|
|
2060
|
-
}
|
|
2061
|
-
Layout.propTypes = _extends({}, ChoiceType, {
|
|
2062
|
-
classes: PropTypes.object.isRequired,
|
|
2063
|
-
className: PropTypes.string,
|
|
2064
|
-
disabled: PropTypes.bool,
|
|
2065
|
-
correct: PropTypes.bool
|
|
2066
|
-
});
|
|
2067
|
-
Layout.defaultProps = {};
|
|
2068
|
-
|
|
2069
|
-
const styles$5 = theme => ({
|
|
2070
|
-
choice: {
|
|
2071
|
-
direction: 'initial',
|
|
2072
|
-
cursor: 'pointer',
|
|
2073
|
-
width: '100%',
|
|
2074
|
-
'&.correct': {
|
|
2075
|
-
border: `solid 2px ${color.correct()}`
|
|
2076
|
-
},
|
|
2077
|
-
'&.incorrect': {
|
|
2078
|
-
border: `solid 2px ${color.incorrect()}`
|
|
2079
|
-
},
|
|
2080
|
-
borderRadius: '6px'
|
|
2081
|
-
},
|
|
2082
|
-
cardRoot: {
|
|
2083
|
-
color: color.text(),
|
|
2084
|
-
backgroundColor: color.white(),
|
|
2085
|
-
'&:last-child': {
|
|
2086
|
-
paddingBottom: theme.spacing.unit * 2
|
|
2087
|
-
},
|
|
2088
|
-
borderRadius: '4px',
|
|
2089
|
-
border: '1px solid'
|
|
2090
|
-
},
|
|
2091
|
-
disabled: {
|
|
2092
|
-
cursor: 'not-allowed',
|
|
2093
|
-
opacity: '0.6'
|
|
2094
|
-
},
|
|
2095
|
-
dragging: {
|
|
2096
|
-
cursor: 'move'
|
|
2097
|
-
},
|
|
2098
|
-
card: {
|
|
2099
|
-
color: color.text(),
|
|
2100
|
-
backgroundColor: color.background(),
|
|
2101
|
-
width: '100%',
|
|
2102
|
-
// Added for touch devices, for image content.
|
|
2103
|
-
// This will prevent the context menu from appearing and not allowing other interactions with the image.
|
|
2104
|
-
pointerEvents: 'none'
|
|
2105
|
-
}
|
|
2106
|
-
});
|
|
2107
|
-
|
|
2108
|
-
const Styled = withStyles(styles$5)(Layout);
|
|
2109
|
-
class Choice extends React.Component {
|
|
2110
|
-
constructor(...args) {
|
|
2111
|
-
super(...args);
|
|
2112
|
-
|
|
2113
|
-
this.handleTouchStart = e => {
|
|
2114
|
-
e.preventDefault();
|
|
2115
|
-
};
|
|
2116
|
-
}
|
|
2117
|
-
|
|
2118
|
-
componentDidMount() {
|
|
2119
|
-
if (this.ref) {
|
|
2120
|
-
this.ref.addEventListener('touchstart', this.handleTouchStart, {
|
|
2121
|
-
passive: false
|
|
2122
|
-
});
|
|
2123
|
-
}
|
|
2124
|
-
}
|
|
2125
|
-
|
|
2126
|
-
componentWillUnmount() {
|
|
2127
|
-
if (this.ref) {
|
|
2128
|
-
this.ref.removeEventListener('touchstart', this.handleTouchStart);
|
|
2129
|
-
}
|
|
2130
|
-
}
|
|
2131
|
-
|
|
2132
|
-
render() {
|
|
2133
|
-
const {
|
|
2134
|
-
connectDragSource,
|
|
2135
|
-
id,
|
|
2136
|
-
content,
|
|
2137
|
-
disabled,
|
|
2138
|
-
isDragging,
|
|
2139
|
-
correct,
|
|
2140
|
-
extraStyle
|
|
2141
|
-
} = this.props;
|
|
2142
|
-
return connectDragSource( /*#__PURE__*/React.createElement("div", {
|
|
2143
|
-
style: _extends({
|
|
2144
|
-
margin: '4px'
|
|
2145
|
-
}, extraStyle),
|
|
2146
|
-
ref: ref => this.ref = ref,
|
|
2147
|
-
draggable: !disabled
|
|
2148
|
-
}, /*#__PURE__*/React.createElement(Styled, {
|
|
2149
|
-
id: id,
|
|
2150
|
-
content: content,
|
|
2151
|
-
disabled: disabled,
|
|
2152
|
-
correct: correct,
|
|
2153
|
-
isDragging: isDragging
|
|
2154
|
-
})));
|
|
2155
|
-
}
|
|
2156
|
-
|
|
2157
|
-
}
|
|
2158
|
-
Choice.propTypes = _extends({}, ChoiceType, {
|
|
2159
|
-
extraStyle: PropTypes.object,
|
|
2160
|
-
connectDragSource: PropTypes.func.isRequired
|
|
2161
|
-
});
|
|
2162
|
-
const spec$1 = {
|
|
2163
|
-
canDrag: props => !props.disabled,
|
|
2164
|
-
beginDrag: props => {
|
|
2165
|
-
const out = {
|
|
2166
|
-
id: props.id,
|
|
2167
|
-
categoryId: props.categoryId,
|
|
2168
|
-
choiceIndex: props.choiceIndex,
|
|
2169
|
-
value: props.content,
|
|
2170
|
-
itemType: 'categorize'
|
|
2171
|
-
};
|
|
2172
|
-
log$2('[beginDrag] out:', out);
|
|
2173
|
-
return out;
|
|
2174
|
-
},
|
|
2175
|
-
endDrag: (props, monitor) => {
|
|
2176
|
-
if (!monitor.didDrop()) {
|
|
2177
|
-
const item = monitor.getItem();
|
|
2178
|
-
|
|
2179
|
-
if (item.categoryId) {
|
|
2180
|
-
log$2('wasnt droppped - what to do?');
|
|
2181
|
-
props.onRemoveChoice(item);
|
|
2182
|
-
}
|
|
2183
|
-
}
|
|
2184
|
-
}
|
|
2185
|
-
};
|
|
2186
|
-
const DraggableChoice = DragSource(({
|
|
2187
|
-
uid
|
|
2188
|
-
}) => uid, spec$1, (connect, monitor) => ({
|
|
2189
|
-
connectDragSource: connect.dragSource(),
|
|
2190
|
-
isDragging: monitor.isDragging()
|
|
2191
|
-
}))(Choice);
|
|
2192
|
-
var Choice$1 = uid.withUid(DraggableChoice);
|
|
2193
|
-
|
|
2194
|
-
const log$1 = debug('@pie-ui:categorize:droppable-placeholder');
|
|
2195
|
-
class DroppablePlaceholder extends React.Component {
|
|
2196
|
-
render() {
|
|
2197
|
-
const {
|
|
2198
|
-
children,
|
|
2199
|
-
connectDropTarget,
|
|
2200
|
-
isOver,
|
|
2201
|
-
className,
|
|
2202
|
-
grid,
|
|
2203
|
-
disabled,
|
|
2204
|
-
choiceBoard,
|
|
2205
|
-
minRowHeight
|
|
2206
|
-
} = this.props;
|
|
2207
|
-
return connectDropTarget( /*#__PURE__*/React.createElement("div", {
|
|
2208
|
-
style: {
|
|
2209
|
-
flex: 1,
|
|
2210
|
-
minHeight: minRowHeight || '80px'
|
|
2211
|
-
}
|
|
2212
|
-
}, /*#__PURE__*/React.createElement(PlaceHolder$1, {
|
|
2213
|
-
className: className,
|
|
2214
|
-
isOver: isOver,
|
|
2215
|
-
grid: grid,
|
|
2216
|
-
disabled: disabled,
|
|
2217
|
-
choiceBoard: choiceBoard,
|
|
2218
|
-
isCategorize: true
|
|
2219
|
-
}, children)));
|
|
2220
|
-
}
|
|
2221
|
-
|
|
2222
|
-
}
|
|
2223
|
-
DroppablePlaceholder.propTypes = {
|
|
2224
|
-
choiceBoard: PropTypes.bool,
|
|
2225
|
-
connectDropTarget: PropTypes.func.isRequired,
|
|
2226
|
-
isOver: PropTypes.bool,
|
|
2227
|
-
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
|
|
2228
|
-
className: PropTypes.string,
|
|
2229
|
-
grid: PropTypes.object,
|
|
2230
|
-
disabled: PropTypes.bool,
|
|
2231
|
-
minRowHeight: PropTypes.string
|
|
2232
|
-
};
|
|
2233
|
-
const spec = {
|
|
2234
|
-
drop: (props, monitor) => {
|
|
2235
|
-
log$1('[drop] props: ', props);
|
|
2236
|
-
const item = monitor.getItem();
|
|
2237
|
-
props.onDropChoice(item);
|
|
2238
|
-
},
|
|
2239
|
-
canDrop: (props
|
|
2240
|
-
/*, monitor*/
|
|
2241
|
-
) => {
|
|
2242
|
-
return !props.disabled;
|
|
2243
|
-
}
|
|
2244
|
-
};
|
|
2245
|
-
const WithTarget = DropTarget(({
|
|
2246
|
-
uid
|
|
2247
|
-
}) => uid, spec, (connect, monitor) => ({
|
|
2248
|
-
connectDropTarget: connect.dropTarget(),
|
|
2249
|
-
isOver: monitor.isOver()
|
|
2250
|
-
}))(DroppablePlaceholder);
|
|
2251
|
-
var PlaceHolder = uid.withUid(WithTarget);
|
|
2252
|
-
|
|
2253
|
-
const Blank = () => /*#__PURE__*/React.createElement("div", null);
|
|
2254
|
-
|
|
2255
|
-
class Choices extends React.Component {
|
|
2256
|
-
render() {
|
|
2257
|
-
const {
|
|
2258
|
-
classes,
|
|
2259
|
-
choices = [],
|
|
2260
|
-
model,
|
|
2261
|
-
disabled,
|
|
2262
|
-
onDropChoice,
|
|
2263
|
-
onRemoveChoice,
|
|
2264
|
-
choicePosition
|
|
2265
|
-
} = this.props;
|
|
2266
|
-
|
|
2267
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
2268
|
-
className: classes.wrapper
|
|
2269
|
-
}, /*#__PURE__*/React.createElement(PlaceHolder, {
|
|
2270
|
-
onDropChoice: onDropChoice,
|
|
2271
|
-
onRemoveChoice: onRemoveChoice,
|
|
2272
|
-
disabled: disabled,
|
|
2273
|
-
style: {
|
|
2274
|
-
background: 'none'
|
|
2275
|
-
},
|
|
2276
|
-
choiceBoard: true
|
|
2277
|
-
}, model.choicesLabel && model.choicesLabel !== '' && /*#__PURE__*/React.createElement("div", {
|
|
2278
|
-
className: classes.labelHolder,
|
|
2279
|
-
dangerouslySetInnerHTML: {
|
|
2280
|
-
__html: model.choicesLabel
|
|
2281
|
-
}
|
|
2282
|
-
}), choices.map((c, index) => {
|
|
2283
|
-
return c.empty ? /*#__PURE__*/React.createElement(Blank, {
|
|
2284
|
-
key: index
|
|
2285
|
-
}) : /*#__PURE__*/React.createElement(Choice$1, _extends({
|
|
2286
|
-
disabled: disabled,
|
|
2287
|
-
className: classes.choice,
|
|
2288
|
-
key: index,
|
|
2289
|
-
extraStyle: {
|
|
2290
|
-
maxWidth: `${95 / model.categoriesPerRow}%`
|
|
2291
|
-
}
|
|
2292
|
-
}, c));
|
|
2293
|
-
})));
|
|
2294
|
-
}
|
|
2295
|
-
|
|
2296
|
-
}
|
|
2297
|
-
Choices.propTypes = {
|
|
2298
|
-
classes: PropTypes.object.isRequired,
|
|
2299
|
-
choices: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.shape(ChoiceType), PropTypes.shape({
|
|
2300
|
-
empty: PropTypes.bool
|
|
2301
|
-
})])),
|
|
2302
|
-
model: PropTypes.shape({
|
|
2303
|
-
categoriesPerRow: PropTypes.number,
|
|
2304
|
-
choicesLabel: PropTypes.string
|
|
2305
|
-
}),
|
|
2306
|
-
disabled: PropTypes.bool,
|
|
2307
|
-
choicePosition: PropTypes.string,
|
|
2308
|
-
onDropChoice: PropTypes.func,
|
|
2309
|
-
onRemoveChoice: PropTypes.func
|
|
2310
|
-
};
|
|
2311
|
-
Choices.defaultProps = {
|
|
2312
|
-
model: {
|
|
2313
|
-
categoriesPerRow: 1,
|
|
2314
|
-
choicesLabel: ''
|
|
2315
|
-
}
|
|
2316
|
-
};
|
|
2317
|
-
|
|
2318
|
-
const styles$4 = theme => ({
|
|
2319
|
-
wrapper: {
|
|
2320
|
-
flex: 1,
|
|
2321
|
-
touchAction: 'none'
|
|
2322
|
-
},
|
|
2323
|
-
choices: {
|
|
2324
|
-
padding: theme.spacing.unit / 2,
|
|
2325
|
-
display: 'flex',
|
|
2326
|
-
justifyContent: 'center',
|
|
2327
|
-
alignItems: 'center'
|
|
2328
|
-
},
|
|
2329
|
-
labelHolder: {
|
|
2330
|
-
margin: '0 auto',
|
|
2331
|
-
textAlign: 'center',
|
|
2332
|
-
paddingTop: theme.spacing.unit
|
|
2333
|
-
}
|
|
2334
|
-
});
|
|
2335
|
-
|
|
2336
|
-
var Choices$1 = withStyles(styles$4)(Choices);
|
|
2337
|
-
|
|
2338
|
-
class GridContent extends React.Component {
|
|
2339
|
-
render() {
|
|
2340
|
-
const {
|
|
2341
|
-
classes,
|
|
2342
|
-
className,
|
|
2343
|
-
children,
|
|
2344
|
-
columns,
|
|
2345
|
-
extraStyle,
|
|
2346
|
-
rows
|
|
2347
|
-
} = this.props;
|
|
2348
|
-
|
|
2349
|
-
const style = _extends({
|
|
2350
|
-
gridTemplateColumns: `repeat(${columns}, 1fr)`,
|
|
2351
|
-
gridTemplateRows: rows === 2 ? 'auto 1fr' : `repeat(${rows}, auto)`
|
|
2352
|
-
}, extraStyle);
|
|
2353
|
-
|
|
2354
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
2355
|
-
style: style,
|
|
2356
|
-
className: classNames(classes.gridContent, className)
|
|
2357
|
-
}, children);
|
|
2358
|
-
}
|
|
2359
|
-
|
|
2360
|
-
}
|
|
2361
|
-
GridContent.propTypes = {
|
|
2362
|
-
classes: PropTypes.object.isRequired,
|
|
2363
|
-
className: PropTypes.string,
|
|
2364
|
-
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
|
|
2365
|
-
columns: PropTypes.number,
|
|
2366
|
-
rows: PropTypes.number,
|
|
2367
|
-
extraStyle: PropTypes.object
|
|
2368
|
-
};
|
|
2369
|
-
GridContent.defaultProps = {
|
|
2370
|
-
columns: 2,
|
|
2371
|
-
rows: 2
|
|
2372
|
-
};
|
|
2373
|
-
|
|
2374
|
-
const styles$3 = theme => ({
|
|
2375
|
-
gridContent: {
|
|
2376
|
-
display: 'grid',
|
|
2377
|
-
columnGap: `${theme.spacing.unit}px`,
|
|
2378
|
-
gridColumnGap: `${theme.spacing.unit}px`,
|
|
2379
|
-
rowGap: `${theme.spacing.unit}px`,
|
|
2380
|
-
gridRowGap: `${theme.spacing.unit}px`,
|
|
2381
|
-
gridAutoRows: '1fr'
|
|
2382
|
-
}
|
|
2383
|
-
});
|
|
2384
|
-
|
|
2385
|
-
var GridContent$1 = withStyles(styles$3)(GridContent);
|
|
2386
|
-
|
|
2387
|
-
const CategoryType = {
|
|
2388
|
-
id: PropTypes.string.isRequired,
|
|
2389
|
-
categoryId: PropTypes.string
|
|
2390
|
-
};
|
|
2391
|
-
class Category extends React.Component {
|
|
2392
|
-
render() {
|
|
2393
|
-
const {
|
|
2394
|
-
classes,
|
|
2395
|
-
className,
|
|
2396
|
-
choices = [],
|
|
2397
|
-
disabled,
|
|
2398
|
-
onDropChoice,
|
|
2399
|
-
onRemoveChoice,
|
|
2400
|
-
id,
|
|
2401
|
-
correct,
|
|
2402
|
-
minRowHeight
|
|
2403
|
-
} = this.props;
|
|
2404
|
-
const names = classNames(classes.category, className);
|
|
2405
|
-
const placeholderNames = classNames(classes.placeholder, correct === false && classes.incorrect, correct === true && classes.correct);
|
|
2406
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
2407
|
-
className: names
|
|
2408
|
-
}, /*#__PURE__*/React.createElement(PlaceHolder, {
|
|
2409
|
-
onDropChoice: onDropChoice,
|
|
2410
|
-
disabled: disabled,
|
|
2411
|
-
className: placeholderNames,
|
|
2412
|
-
minRowHeight: minRowHeight
|
|
2413
|
-
}, choices.map((c, index) => /*#__PURE__*/React.createElement(Choice$1, _extends({
|
|
2414
|
-
onRemoveChoice: onRemoveChoice,
|
|
2415
|
-
disabled: disabled,
|
|
2416
|
-
key: index,
|
|
2417
|
-
choiceIndex: index,
|
|
2418
|
-
categoryId: id
|
|
2419
|
-
}, c)))));
|
|
2420
|
-
}
|
|
2421
|
-
|
|
2422
|
-
}
|
|
2423
|
-
Category.propTypes = _extends({}, CategoryType, {
|
|
2424
|
-
className: PropTypes.string,
|
|
2425
|
-
disabled: PropTypes.bool,
|
|
2426
|
-
classes: PropTypes.object.isRequired,
|
|
2427
|
-
onDropChoice: PropTypes.func,
|
|
2428
|
-
onRemoveChoice: PropTypes.func,
|
|
2429
|
-
minRowHeight: PropTypes.string
|
|
2430
|
-
});
|
|
2431
|
-
Category.defaultProps = {};
|
|
2432
|
-
|
|
2433
|
-
const styles$2 = theme => ({
|
|
2434
|
-
incorrect: {
|
|
2435
|
-
border: `solid 2px ${color.incorrect()}`
|
|
2436
|
-
},
|
|
2437
|
-
correct: {
|
|
2438
|
-
border: `solid 2px ${color.correct()}`
|
|
2439
|
-
},
|
|
2440
|
-
placeholder: {
|
|
2441
|
-
padding: theme.spacing.unit / 2,
|
|
2442
|
-
borderRadius: theme.spacing.unit / 2,
|
|
2443
|
-
gridColumnGap: 0,
|
|
2444
|
-
gridRowGap: 0,
|
|
2445
|
-
display: 'flex',
|
|
2446
|
-
flexWrap: 'wrap',
|
|
2447
|
-
justifyContent: 'center',
|
|
2448
|
-
alignItems: 'center',
|
|
2449
|
-
alignContent: 'flex-start'
|
|
2450
|
-
},
|
|
2451
|
-
category: {
|
|
2452
|
-
display: 'flex',
|
|
2453
|
-
flexDirection: 'column',
|
|
2454
|
-
flex: 2
|
|
2455
|
-
}
|
|
2456
|
-
});
|
|
2457
|
-
|
|
2458
|
-
var Category$1 = withStyles(styles$2)(Category);
|
|
2459
|
-
|
|
2460
|
-
class Categories extends React.Component {
|
|
2461
|
-
render() {
|
|
2462
|
-
const {
|
|
2463
|
-
classes,
|
|
2464
|
-
categories,
|
|
2465
|
-
model,
|
|
2466
|
-
disabled,
|
|
2467
|
-
onDropChoice,
|
|
2468
|
-
onRemoveChoice,
|
|
2469
|
-
rowLabels
|
|
2470
|
-
} = this.props;
|
|
2471
|
-
const {
|
|
2472
|
-
categoriesPerRow,
|
|
2473
|
-
minRowHeight
|
|
2474
|
-
} = model; // split categories into an array of arrays (inner array),
|
|
2475
|
-
// where each inner array represents how many categories should be displayed on one row
|
|
2476
|
-
|
|
2477
|
-
const chunkedCategories = [];
|
|
2478
|
-
const cats = categories || [];
|
|
2479
|
-
|
|
2480
|
-
for (let i = 0; i < cats.length; i += categoriesPerRow) {
|
|
2481
|
-
chunkedCategories.push(cats.slice(i, i + categoriesPerRow));
|
|
2482
|
-
}
|
|
2483
|
-
|
|
2484
|
-
const hasNonEmptyString = array => {
|
|
2485
|
-
let found = false;
|
|
2486
|
-
(array || []).forEach(element => {
|
|
2487
|
-
if (typeof element === 'string' && element.trim() !== '' && element.trim() !== '<div></div>') {
|
|
2488
|
-
found = true;
|
|
2489
|
-
}
|
|
2490
|
-
});
|
|
2491
|
-
return found;
|
|
2492
|
-
};
|
|
2493
|
-
|
|
2494
|
-
return /*#__PURE__*/React.createElement(GridContent$1, {
|
|
2495
|
-
columns: categoriesPerRow,
|
|
2496
|
-
className: classes.categories,
|
|
2497
|
-
rows: Math.ceil(categories.length / categoriesPerRow) * 2
|
|
2498
|
-
}, chunkedCategories.map((cat, rowIndex) => {
|
|
2499
|
-
let items = []; // for each inner array of categories, create a row with category titles
|
|
2500
|
-
// first cell of row has to be the row label
|
|
2501
|
-
|
|
2502
|
-
cat.forEach((c, columnIndex) => {
|
|
2503
|
-
items.push( /*#__PURE__*/React.createElement("div", {
|
|
2504
|
-
style: {
|
|
2505
|
-
display: 'flex'
|
|
2506
|
-
}
|
|
2507
|
-
}, columnIndex === 0 && hasNonEmptyString(rowLabels) ? /*#__PURE__*/React.createElement("div", {
|
|
2508
|
-
key: rowIndex,
|
|
2509
|
-
className: classes.rowLabel,
|
|
2510
|
-
dangerouslySetInnerHTML: {
|
|
2511
|
-
__html: rowLabels[rowIndex] || ''
|
|
2512
|
-
}
|
|
2513
|
-
}) : null, /*#__PURE__*/React.createElement("div", {
|
|
2514
|
-
className: classes.categoryWrapper
|
|
2515
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
2516
|
-
className: classes.label,
|
|
2517
|
-
key: `category-label-${rowIndex}-${columnIndex}`,
|
|
2518
|
-
dangerouslySetInnerHTML: {
|
|
2519
|
-
__html: c.label
|
|
2520
|
-
}
|
|
2521
|
-
}), /*#__PURE__*/React.createElement(Category$1, _extends({
|
|
2522
|
-
minRowHeight: minRowHeight,
|
|
2523
|
-
onDropChoice: h => onDropChoice(c.id, h),
|
|
2524
|
-
onRemoveChoice: onRemoveChoice,
|
|
2525
|
-
disabled: disabled,
|
|
2526
|
-
className: classes.category,
|
|
2527
|
-
key: `category-element-${rowIndex}-${columnIndex}`
|
|
2528
|
-
}, c)))));
|
|
2529
|
-
}); // if the last row has fewer categories than max on a row, fill the spaces with divs
|
|
2530
|
-
|
|
2531
|
-
items = items.concat(Array(categoriesPerRow - cat.length).fill( /*#__PURE__*/React.createElement("div", null)).map((value, index) => /*#__PURE__*/React.createElement("div", {
|
|
2532
|
-
key: `fill-space-final-${index}`
|
|
2533
|
-
})));
|
|
2534
|
-
return items;
|
|
2535
|
-
}));
|
|
2536
|
-
}
|
|
2537
|
-
|
|
2538
|
-
}
|
|
2539
|
-
Categories.propTypes = {
|
|
2540
|
-
classes: PropTypes.object.isRequired,
|
|
2541
|
-
categories: PropTypes.arrayOf(PropTypes.shape(CategoryType)),
|
|
2542
|
-
model: PropTypes.shape({
|
|
2543
|
-
categoriesPerRow: PropTypes.number
|
|
2544
|
-
}),
|
|
2545
|
-
disabled: PropTypes.bool,
|
|
2546
|
-
onDropChoice: PropTypes.func.isRequired,
|
|
2547
|
-
onRemoveChoice: PropTypes.func.isRequired,
|
|
2548
|
-
rowLabels: PropTypes.array
|
|
2549
|
-
};
|
|
2550
|
-
Categories.defaultProps = {
|
|
2551
|
-
model: {
|
|
2552
|
-
categoriesPerRow: 1
|
|
2553
|
-
}
|
|
2554
|
-
};
|
|
2555
|
-
|
|
2556
|
-
const styles$1 = theme => ({
|
|
2557
|
-
categories: {
|
|
2558
|
-
flex: 1
|
|
2559
|
-
},
|
|
2560
|
-
label: {
|
|
2561
|
-
color: color.text(),
|
|
2562
|
-
backgroundColor: color.background(),
|
|
2563
|
-
textAlign: 'center',
|
|
2564
|
-
paddingTop: theme.spacing.unit
|
|
2565
|
-
},
|
|
2566
|
-
rowLabel: {
|
|
2567
|
-
alignItems: 'center',
|
|
2568
|
-
display: 'flex',
|
|
2569
|
-
justifyContent: 'center',
|
|
2570
|
-
flex: 0.5,
|
|
2571
|
-
marginRight: '12px'
|
|
2572
|
-
},
|
|
2573
|
-
categoryWrapper: {
|
|
2574
|
-
display: 'flex',
|
|
2575
|
-
flex: '2',
|
|
2576
|
-
flexDirection: 'column'
|
|
2577
|
-
}
|
|
2578
|
-
});
|
|
2579
|
-
|
|
2580
|
-
var Categories$1 = withStyles(styles$1)(Categories);
|
|
2581
|
-
|
|
2582
|
-
const {
|
|
2583
|
-
translator
|
|
2584
|
-
} = Translator;
|
|
2585
|
-
const log = debug('@pie-ui:categorize');
|
|
2586
|
-
class Categorize$1 extends React.Component {
|
|
2587
|
-
constructor(props) {
|
|
2588
|
-
super(props);
|
|
2589
|
-
|
|
2590
|
-
this.removeChoice = c => {
|
|
2591
|
-
log('[removeChoice]: ', c);
|
|
2592
|
-
const {
|
|
2593
|
-
onAnswersChange,
|
|
2594
|
-
session
|
|
2595
|
-
} = this.props;
|
|
2596
|
-
const answers = removeChoiceFromCategory(c.id, c.categoryId, c.choiceIndex, session.answers);
|
|
2597
|
-
onAnswersChange(answers);
|
|
2598
|
-
};
|
|
2599
|
-
|
|
2600
|
-
this.dropChoice = (categoryId, draggedChoice) => {
|
|
2601
|
-
const {
|
|
2602
|
-
session,
|
|
2603
|
-
onAnswersChange,
|
|
2604
|
-
model
|
|
2605
|
-
} = this.props;
|
|
2606
|
-
const {
|
|
2607
|
-
maxChoicesPerCategory = 0
|
|
2608
|
-
} = model || {};
|
|
2609
|
-
const {
|
|
2610
|
-
answers = []
|
|
2611
|
-
} = session || {};
|
|
2612
|
-
let newAnswers;
|
|
2613
|
-
|
|
2614
|
-
if (draggedChoice) {
|
|
2615
|
-
log('[dropChoice] category: ', draggedChoice.categoryId, 'choice: ', draggedChoice);
|
|
2616
|
-
} else {
|
|
2617
|
-
log('[dropChoice] category: ', undefined, 'choice: ', undefined);
|
|
2618
|
-
}
|
|
2619
|
-
|
|
2620
|
-
const answer = answers.find(answer => answer.category === categoryId); // treat special case to replace the existing choice with the new one when maxChoicesPerCategory = 1
|
|
2621
|
-
|
|
2622
|
-
if (draggedChoice && maxChoicesPerCategory === 1 && answer && answer.choices && answer.choices.length === 1) {
|
|
2623
|
-
newAnswers = moveChoiceToCategory(draggedChoice.id, draggedChoice.categoryId, categoryId, draggedChoice.choiceIndex, answers);
|
|
2624
|
-
newAnswers = removeChoiceFromCategory(answer.choices[0], categoryId, 0, answers);
|
|
2625
|
-
} // treat special case when there are as many choices as maxChoicesPerCategory is
|
|
2626
|
-
else if (draggedChoice && maxChoicesPerCategory > 1 && answer && answer.choices && answer.choices.length === maxChoicesPerCategory) {
|
|
2627
|
-
newAnswers = draggedChoice.categoryId ? moveChoiceToCategory(draggedChoice.id, draggedChoice.categoryId, draggedChoice.categoryId, draggedChoice.choiceIndex, answers) : removeChoiceFromCategory(draggedChoice.id, draggedChoice.categoryId, draggedChoice.choiceIndex, answers);
|
|
2628
|
-
this.setState({
|
|
2629
|
-
showMaxChoiceAlert: true
|
|
2630
|
-
});
|
|
2631
|
-
} // treat special case when there are more choices that maxChoicesPerCategory is (testing purpose in pits)
|
|
2632
|
-
else if (maxChoicesPerCategory !== 0 && answer && answer.choices && answer.choices.length > maxChoicesPerCategory) {
|
|
2633
|
-
newAnswers = answers;
|
|
2634
|
-
this.setState({
|
|
2635
|
-
showMaxChoiceAlert: true
|
|
2636
|
-
});
|
|
2637
|
-
} else {
|
|
2638
|
-
newAnswers = draggedChoice ? moveChoiceToCategory(draggedChoice.id, draggedChoice.categoryId, categoryId, draggedChoice.choiceIndex, answers) : this.removeChoice(categoryId);
|
|
2639
|
-
}
|
|
2640
|
-
|
|
2641
|
-
if (draggedChoice) {
|
|
2642
|
-
onAnswersChange(newAnswers);
|
|
2643
|
-
}
|
|
2644
|
-
};
|
|
2645
|
-
|
|
2646
|
-
this.toggleShowCorrect = () => this.setState({
|
|
2647
|
-
showCorrect: !this.state.showCorrect
|
|
2648
|
-
}, () => {
|
|
2649
|
-
this.props.onShowCorrectToggle();
|
|
2650
|
-
});
|
|
2651
|
-
|
|
2652
|
-
this.getPositionDirection = choicePosition => {
|
|
2653
|
-
let flexDirection;
|
|
2654
|
-
|
|
2655
|
-
switch (choicePosition) {
|
|
2656
|
-
case 'left':
|
|
2657
|
-
flexDirection = 'row-reverse';
|
|
2658
|
-
break;
|
|
2659
|
-
|
|
2660
|
-
case 'right':
|
|
2661
|
-
flexDirection = 'row';
|
|
2662
|
-
break;
|
|
2663
|
-
|
|
2664
|
-
case 'below':
|
|
2665
|
-
flexDirection = 'column';
|
|
2666
|
-
break;
|
|
2667
|
-
|
|
2668
|
-
default:
|
|
2669
|
-
// above
|
|
2670
|
-
flexDirection = 'column-reverse';
|
|
2671
|
-
break;
|
|
2672
|
-
}
|
|
2673
|
-
|
|
2674
|
-
return flexDirection;
|
|
2675
|
-
};
|
|
2676
|
-
|
|
2677
|
-
this.existAlternateResponse = correctResponse => correctResponse == null ? void 0 : correctResponse.some(correctRes => {
|
|
2678
|
-
var _correctRes$alternate;
|
|
2679
|
-
|
|
2680
|
-
return ((_correctRes$alternate = correctRes.alternateResponses) == null ? void 0 : _correctRes$alternate.length) > 0;
|
|
2681
|
-
});
|
|
2682
|
-
|
|
2683
|
-
this.state = {
|
|
2684
|
-
showCorrect: false,
|
|
2685
|
-
showMaxChoiceAlert: false
|
|
2686
|
-
};
|
|
2687
|
-
}
|
|
2688
|
-
|
|
2689
|
-
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
2690
|
-
const {
|
|
2691
|
-
model
|
|
2692
|
-
} = this.props;
|
|
2693
|
-
const {
|
|
2694
|
-
model: nextModel
|
|
2695
|
-
} = nextProps; // check if the note is the default one for prev language and change to the default one for new language
|
|
2696
|
-
// this check is necessary in order to diferanciate between default and authour defined note
|
|
2697
|
-
// and only change between languages for default ones
|
|
2698
|
-
|
|
2699
|
-
if (model.note && model.language && model.language !== nextModel.language && model.note === translator.t('common:commonCorrectAnswerWithAlternates', {
|
|
2700
|
-
lng: model.language
|
|
2701
|
-
})) {
|
|
2702
|
-
model.note = translator.t('common:commonCorrectAnswerWithAlternates', {
|
|
2703
|
-
lng: nextModel.language
|
|
2704
|
-
});
|
|
2705
|
-
}
|
|
2706
|
-
|
|
2707
|
-
this.setState({
|
|
2708
|
-
showCorrect: false
|
|
2709
|
-
});
|
|
2710
|
-
}
|
|
2711
|
-
|
|
2712
|
-
render() {
|
|
2713
|
-
const {
|
|
2714
|
-
classes,
|
|
2715
|
-
model,
|
|
2716
|
-
session
|
|
2717
|
-
} = this.props;
|
|
2718
|
-
const {
|
|
2719
|
-
showCorrect,
|
|
2720
|
-
showMaxChoiceAlert
|
|
2721
|
-
} = this.state;
|
|
2722
|
-
const {
|
|
2723
|
-
choicesPosition,
|
|
2724
|
-
extraCSSRules,
|
|
2725
|
-
note,
|
|
2726
|
-
showNote,
|
|
2727
|
-
env,
|
|
2728
|
-
language,
|
|
2729
|
-
maxChoicesPerCategory,
|
|
2730
|
-
autoplayAudioEnabled,
|
|
2731
|
-
customAudioButton
|
|
2732
|
-
} = model;
|
|
2733
|
-
const {
|
|
2734
|
-
mode,
|
|
2735
|
-
role
|
|
2736
|
-
} = env || {};
|
|
2737
|
-
const choicePosition = choicesPosition || 'above';
|
|
2738
|
-
const style = {
|
|
2739
|
-
flexDirection: this.getPositionDirection(choicePosition),
|
|
2740
|
-
gap: '8px'
|
|
2741
|
-
};
|
|
2742
|
-
const {
|
|
2743
|
-
categories,
|
|
2744
|
-
choices,
|
|
2745
|
-
correct
|
|
2746
|
-
} = buildState(model.categories, model.choices, showCorrect ? model.correctResponse : session.answers, model.correctResponse);
|
|
2747
|
-
log('[render] disabled: ', model.disabled);
|
|
2748
|
-
const {
|
|
2749
|
-
rowLabels,
|
|
2750
|
-
categoriesPerRow,
|
|
2751
|
-
correctResponse,
|
|
2752
|
-
fontSizeFactor
|
|
2753
|
-
} = model;
|
|
2754
|
-
const nbOfRows = categories && Math.ceil(categories.length / categoriesPerRow) || 0;
|
|
2755
|
-
const existAlternate = this.existAlternateResponse(correctResponse) || false;
|
|
2756
|
-
const displayNote = (showCorrect || mode === 'view' && role === 'instructor') && showNote && note && existAlternate;
|
|
2757
|
-
const alertMessage = translator.t('translation:categorize:limitMaxChoicesPerCategory', {
|
|
2758
|
-
lng: model.language,
|
|
2759
|
-
maxChoicesPerCategory
|
|
2760
|
-
});
|
|
2761
|
-
const alertTitle = translator.t('common:warning', {
|
|
2762
|
-
lng: model.language
|
|
2763
|
-
});
|
|
2764
|
-
const onCloseText = translator.t('common:cancel', {
|
|
2765
|
-
lng: model.language
|
|
2766
|
-
});
|
|
2767
|
-
const showRationale = model.rationale && (hasText(model.rationale) || hasMedia(model.rationale));
|
|
2768
|
-
const showTeacherInstructions = model.teacherInstructions && (hasText(model.teacherInstructions) || hasMedia(model.teacherInstructions));
|
|
2769
|
-
return /*#__PURE__*/React.createElement(UiLayout, {
|
|
2770
|
-
extraCSSRules: extraCSSRules,
|
|
2771
|
-
id: 'main-container',
|
|
2772
|
-
className: classes.mainContainer,
|
|
2773
|
-
fontSizeFactor: fontSizeFactor
|
|
2774
|
-
}, showTeacherInstructions && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Collapsible, {
|
|
2775
|
-
labels: {
|
|
2776
|
-
hidden: 'Show Teacher Instructions',
|
|
2777
|
-
visible: 'Hide Teacher Instructions'
|
|
2778
|
-
},
|
|
2779
|
-
className: classes.collapsible
|
|
2780
|
-
}, /*#__PURE__*/React.createElement(PreviewPrompt, {
|
|
2781
|
-
prompt: model.teacherInstructions
|
|
2782
|
-
}))), model.prompt && /*#__PURE__*/React.createElement(PreviewPrompt, {
|
|
2783
|
-
prompt: model.prompt,
|
|
2784
|
-
autoplayAudioEnabled: autoplayAudioEnabled,
|
|
2785
|
-
customAudioButton: customAudioButton
|
|
2786
|
-
}), /*#__PURE__*/React.createElement(CorrectAnswerToggle, {
|
|
2787
|
-
show: showCorrect || correct === false,
|
|
2788
|
-
toggled: showCorrect,
|
|
2789
|
-
onToggle: this.toggleShowCorrect,
|
|
2790
|
-
language: language
|
|
2791
|
-
}), /*#__PURE__*/React.createElement("div", {
|
|
2792
|
-
className: classes.categorize,
|
|
2793
|
-
style: style
|
|
2794
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
2795
|
-
style: {
|
|
2796
|
-
display: 'flex',
|
|
2797
|
-
flex: 1
|
|
2798
|
-
}
|
|
2799
|
-
}, /*#__PURE__*/React.createElement(Categories$1, {
|
|
2800
|
-
model: model,
|
|
2801
|
-
disabled: model.disabled,
|
|
2802
|
-
categories: categories,
|
|
2803
|
-
onDropChoice: this.dropChoice,
|
|
2804
|
-
onRemoveChoice: this.removeChoice,
|
|
2805
|
-
rowLabels: (rowLabels || []).slice(0, nbOfRows)
|
|
2806
|
-
})), /*#__PURE__*/React.createElement(Choices$1, {
|
|
2807
|
-
disabled: model.disabled,
|
|
2808
|
-
model: model,
|
|
2809
|
-
choices: choices,
|
|
2810
|
-
choicePosition: choicePosition,
|
|
2811
|
-
onDropChoice: this.dropChoice,
|
|
2812
|
-
onRemoveChoice: this.removeChoice
|
|
2813
|
-
})), displayNote && /*#__PURE__*/React.createElement("div", {
|
|
2814
|
-
className: classes.note,
|
|
2815
|
-
dangerouslySetInnerHTML: {
|
|
2816
|
-
__html: note
|
|
2817
|
-
}
|
|
2818
|
-
}), showRationale && /*#__PURE__*/React.createElement(Collapsible, {
|
|
2819
|
-
labels: {
|
|
2820
|
-
hidden: 'Show Rationale',
|
|
2821
|
-
visible: 'Hide Rationale'
|
|
2822
|
-
},
|
|
2823
|
-
className: classes.collapsible
|
|
2824
|
-
}, /*#__PURE__*/React.createElement(PreviewPrompt, {
|
|
2825
|
-
prompt: model.rationale
|
|
2826
|
-
})), model.correctness && model.feedback && !showCorrect && /*#__PURE__*/React.createElement(Feedback, {
|
|
2827
|
-
correctness: model.correctness,
|
|
2828
|
-
feedback: model.feedback
|
|
2829
|
-
}), /*#__PURE__*/React.createElement(AlertDialog, {
|
|
2830
|
-
title: alertTitle,
|
|
2831
|
-
text: alertMessage,
|
|
2832
|
-
open: showMaxChoiceAlert,
|
|
2833
|
-
onCloseText: onCloseText,
|
|
2834
|
-
onClose: () => this.setState({
|
|
2835
|
-
showMaxChoiceAlert: false
|
|
2836
|
-
})
|
|
2837
|
-
}));
|
|
2838
|
-
}
|
|
2839
|
-
|
|
2840
|
-
}
|
|
2841
|
-
Categorize$1.propTypes = {
|
|
2842
|
-
classes: PropTypes.object.isRequired,
|
|
2843
|
-
model: PropTypes.object,
|
|
2844
|
-
session: PropTypes.shape({
|
|
2845
|
-
answers: PropTypes.arrayOf(PropTypes.shape({
|
|
2846
|
-
choice: PropTypes.string,
|
|
2847
|
-
category: PropTypes.string
|
|
2848
|
-
}))
|
|
2849
|
-
}),
|
|
2850
|
-
onAnswersChange: PropTypes.func.isRequired,
|
|
2851
|
-
onShowCorrectToggle: PropTypes.func.isRequired
|
|
2852
|
-
};
|
|
2853
|
-
Categorize$1.defaultProps = {
|
|
2854
|
-
disabled: false
|
|
2855
|
-
};
|
|
2856
|
-
|
|
2857
|
-
class CategorizeProvider extends React.Component {
|
|
2858
|
-
constructor(props) {
|
|
2859
|
-
super(props);
|
|
2860
|
-
this.uid = uid.generateId();
|
|
2861
|
-
}
|
|
2862
|
-
|
|
2863
|
-
render() {
|
|
2864
|
-
return /*#__PURE__*/React.createElement(uid.Provider, {
|
|
2865
|
-
value: this.uid
|
|
2866
|
-
}, /*#__PURE__*/React.createElement(Categorize$1, this.props));
|
|
2867
|
-
}
|
|
2868
|
-
|
|
2869
|
-
}
|
|
2870
|
-
|
|
2871
|
-
const styles = theme => ({
|
|
2872
|
-
mainContainer: {
|
|
2873
|
-
color: color.text(),
|
|
2874
|
-
backgroundColor: color.background(),
|
|
2875
|
-
position: 'relative'
|
|
2876
|
-
},
|
|
2877
|
-
note: {
|
|
2878
|
-
marginBottom: theme.spacing.unit * 2
|
|
2879
|
-
},
|
|
2880
|
-
categorize: {
|
|
2881
|
-
marginBottom: theme.spacing.unit,
|
|
2882
|
-
display: 'flex',
|
|
2883
|
-
flexDirection: 'column'
|
|
2884
|
-
},
|
|
2885
|
-
collapsible: {
|
|
2886
|
-
paddingBottom: theme.spacing.unit * 2
|
|
2887
|
-
}
|
|
2888
|
-
});
|
|
2889
|
-
|
|
2890
|
-
var CategorizeComponent = withDragContext(withStyles(styles)(CategorizeProvider));
|
|
2891
|
-
|
|
2892
|
-
class Categorize extends HTMLElement {
|
|
2893
|
-
set model(m) {
|
|
2894
|
-
this._model = m;
|
|
2895
|
-
this.eliminateBlindAnswersFromSession();
|
|
2896
|
-
this.dispatchEvent(new ModelSetEvent(this.tagName.toLowerCase(), this.isComplete(), !!this._model)); // reset the audioInitialized to false since the model changed, and we might need to reinitialize the audio
|
|
2897
|
-
|
|
2898
|
-
this._audioInitialized = false;
|
|
2899
|
-
this.render();
|
|
2900
|
-
}
|
|
2901
|
-
|
|
2902
|
-
isComplete() {
|
|
2903
|
-
const {
|
|
2904
|
-
autoplayAudioEnabled,
|
|
2905
|
-
completeAudioEnabled
|
|
2906
|
-
} = this._model || {};
|
|
2907
|
-
const elementContext = this; // check audio completion if audio settings are enabled and audio actually exists
|
|
2908
|
-
|
|
2909
|
-
if (autoplayAudioEnabled && completeAudioEnabled && !this.audioComplete) {
|
|
2910
|
-
if (elementContext) {
|
|
2911
|
-
const audio = elementContext.querySelector('audio');
|
|
2912
|
-
const isInsidePrompt = audio && audio.closest('#preview-prompt'); // only require audio completion if audio exists and is inside the prompt
|
|
2913
|
-
|
|
2914
|
-
if (audio && isInsidePrompt) {
|
|
2915
|
-
return false;
|
|
2916
|
-
}
|
|
2917
|
-
}
|
|
2918
|
-
}
|
|
2919
|
-
|
|
2920
|
-
if (!this._session || !this._session.answers) {
|
|
2921
|
-
return false;
|
|
2922
|
-
}
|
|
2923
|
-
|
|
2924
|
-
if (!Array.isArray(this._session.answers)) {
|
|
2925
|
-
return false;
|
|
2926
|
-
}
|
|
2927
|
-
|
|
2928
|
-
return this._session.answers.some(answer => answer.choices && answer.choices.length > 0);
|
|
2929
|
-
}
|
|
2930
|
-
|
|
2931
|
-
set session(s) {
|
|
2932
|
-
if (s && !s.answers) {
|
|
2933
|
-
s.answers = [];
|
|
2934
|
-
}
|
|
2935
|
-
|
|
2936
|
-
this._session = s;
|
|
2937
|
-
this.render();
|
|
2938
|
-
}
|
|
2939
|
-
|
|
2940
|
-
get session() {
|
|
2941
|
-
return this._session;
|
|
2942
|
-
}
|
|
2943
|
-
|
|
2944
|
-
eliminateBlindAnswersFromSession() {
|
|
2945
|
-
const {
|
|
2946
|
-
answers = []
|
|
2947
|
-
} = this._session || {};
|
|
2948
|
-
const {
|
|
2949
|
-
choices = []
|
|
2950
|
-
} = this._model || {};
|
|
2951
|
-
const mappedChoices = choices.map(c => c.id) || [];
|
|
2952
|
-
const filteredAnswers = answers.map(answer => {
|
|
2953
|
-
const answerChoices = (answer == null ? void 0 : answer.choices) || [];
|
|
2954
|
-
answer.choices = answerChoices.filter(c => mappedChoices.includes(c));
|
|
2955
|
-
return answer;
|
|
2956
|
-
});
|
|
2957
|
-
|
|
2958
|
-
if (filteredAnswers.length > 0) {
|
|
2959
|
-
this.changeAnswers(filteredAnswers);
|
|
2960
|
-
}
|
|
2961
|
-
}
|
|
2962
|
-
|
|
2963
|
-
changeAnswers(answers) {
|
|
2964
|
-
this._session.answers = answers;
|
|
2965
|
-
this._session.selector = 'Mouse';
|
|
2966
|
-
this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), this.isComplete()));
|
|
2967
|
-
this.render();
|
|
2968
|
-
}
|
|
2969
|
-
|
|
2970
|
-
onShowCorrectToggle() {
|
|
2971
|
-
renderMath(this);
|
|
2972
|
-
}
|
|
2973
|
-
|
|
2974
|
-
_createAudioInfoToast() {
|
|
2975
|
-
const info = document.createElement('div');
|
|
2976
|
-
info.id = 'play-audio-info';
|
|
2977
|
-
Object.assign(info.style, {
|
|
2978
|
-
position: 'absolute',
|
|
2979
|
-
top: 0,
|
|
2980
|
-
width: '100%',
|
|
2981
|
-
height: '100%',
|
|
2982
|
-
display: 'flex',
|
|
2983
|
-
justifyContent: 'center',
|
|
2984
|
-
alignItems: 'center',
|
|
2985
|
-
background: 'white',
|
|
2986
|
-
zIndex: '1000',
|
|
2987
|
-
cursor: 'pointer'
|
|
2988
|
-
});
|
|
2989
|
-
const img = document.createElement('img');
|
|
2990
|
-
img.src = EnableAudioAutoplayImage;
|
|
2991
|
-
img.alt = 'Click anywhere to enable audio autoplay';
|
|
2992
|
-
img.width = 500;
|
|
2993
|
-
img.height = 300;
|
|
2994
|
-
info.appendChild(img);
|
|
2995
|
-
return info;
|
|
2996
|
-
}
|
|
2997
|
-
|
|
2998
|
-
connectedCallback() {
|
|
2999
|
-
// Observation: audio in Chrome will have the autoplay attribute,
|
|
3000
|
-
// while other browsers will not have the autoplay attribute and will need a user interaction to play the audio
|
|
3001
|
-
// This workaround fixes the issue of audio being cached and played on any user interaction in Safari and Firefox
|
|
3002
|
-
const observer = new MutationObserver((mutationsList, observer) => {
|
|
3003
|
-
mutationsList.forEach(mutation => {
|
|
3004
|
-
if (mutation.type === 'childList') {
|
|
3005
|
-
if (this._audioInitialized) return;
|
|
3006
|
-
const audio = this.querySelector('audio');
|
|
3007
|
-
const isInsidePrompt = audio && audio.closest('#preview-prompt');
|
|
3008
|
-
if (!this._model) return;
|
|
3009
|
-
if (!this._model.autoplayAudioEnabled) return;
|
|
3010
|
-
if (audio && !isInsidePrompt) return;
|
|
3011
|
-
if (!audio) return;
|
|
3012
|
-
|
|
3013
|
-
const info = this._createAudioInfoToast();
|
|
3014
|
-
|
|
3015
|
-
const container = this.querySelector('#main-container');
|
|
3016
|
-
|
|
3017
|
-
const enableAudio = () => {
|
|
3018
|
-
if (this.querySelector('#play-audio-info')) {
|
|
3019
|
-
audio.play();
|
|
3020
|
-
container.removeChild(info);
|
|
3021
|
-
}
|
|
3022
|
-
|
|
3023
|
-
document.removeEventListener('click', enableAudio);
|
|
3024
|
-
}; // if the audio is paused, it means the user has not interacted with the page yet and the audio will not play
|
|
3025
|
-
// FIX FOR SAFARI: play with a slight delay to check if autoplay was blocked
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
setTimeout(() => {
|
|
3029
|
-
if (audio.paused && !this.querySelector('#play-audio-info')) {
|
|
3030
|
-
// add info message as a toast to enable audio playback
|
|
3031
|
-
container.appendChild(info);
|
|
3032
|
-
document.addEventListener('click', enableAudio);
|
|
3033
|
-
} else {
|
|
3034
|
-
document.removeEventListener('click', enableAudio);
|
|
3035
|
-
}
|
|
3036
|
-
}, 500); // we need to listen for the playing event to remove the toast in case the audio plays because of re-rendering
|
|
3037
|
-
|
|
3038
|
-
const handlePlaying = () => {
|
|
3039
|
-
//timestamp when auto-played audio started playing
|
|
3040
|
-
this._session.audioStartTime = this._session.audioStartTime || new Date().getTime();
|
|
3041
|
-
const info = this.querySelector('#play-audio-info');
|
|
3042
|
-
|
|
3043
|
-
if (info) {
|
|
3044
|
-
container.removeChild(info);
|
|
3045
|
-
}
|
|
3046
|
-
|
|
3047
|
-
audio.removeEventListener('playing', handlePlaying);
|
|
3048
|
-
};
|
|
3049
|
-
|
|
3050
|
-
audio.addEventListener('playing', handlePlaying); // we need to listen for the ended event to update the isComplete state
|
|
3051
|
-
|
|
3052
|
-
const handleEnded = () => {
|
|
3053
|
-
//timestamp when auto-played audio completed playing
|
|
3054
|
-
this._session.audioEndTime = this._session.audioEndTime || new Date().getTime();
|
|
3055
|
-
let {
|
|
3056
|
-
audioStartTime,
|
|
3057
|
-
audioEndTime,
|
|
3058
|
-
waitTime
|
|
3059
|
-
} = this._session;
|
|
3060
|
-
|
|
3061
|
-
if (!waitTime && audioStartTime && audioEndTime) {
|
|
3062
|
-
// waitTime is elapsed time the user waited for auto-played audio to finish
|
|
3063
|
-
this._session.waitTime = audioEndTime - audioStartTime;
|
|
3064
|
-
}
|
|
3065
|
-
|
|
3066
|
-
this.audioComplete = true;
|
|
3067
|
-
this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), this.isComplete()));
|
|
3068
|
-
audio.removeEventListener('ended', handleEnded);
|
|
3069
|
-
};
|
|
3070
|
-
|
|
3071
|
-
audio.addEventListener('ended', handleEnded); // store references to remove later
|
|
3072
|
-
|
|
3073
|
-
this._audio = audio;
|
|
3074
|
-
this._handlePlaying = handlePlaying;
|
|
3075
|
-
this._handleEnded = handleEnded;
|
|
3076
|
-
this._enableAudio = enableAudio; // set to true to prevent multiple initializations
|
|
3077
|
-
|
|
3078
|
-
this._audioInitialized = true;
|
|
3079
|
-
observer.disconnect();
|
|
3080
|
-
}
|
|
3081
|
-
});
|
|
3082
|
-
});
|
|
3083
|
-
observer.observe(this, {
|
|
3084
|
-
childList: true,
|
|
3085
|
-
subtree: true
|
|
3086
|
-
});
|
|
3087
|
-
}
|
|
3088
|
-
|
|
3089
|
-
disconnectedCallback() {
|
|
3090
|
-
document.removeEventListener('click', this._enableAudio);
|
|
3091
|
-
|
|
3092
|
-
if (this._audio) {
|
|
3093
|
-
this._audio.removeEventListener('playing', this._handlePlaying);
|
|
3094
|
-
|
|
3095
|
-
this._audio.removeEventListener('ended', this._handleEnded);
|
|
3096
|
-
|
|
3097
|
-
this._audio = null;
|
|
3098
|
-
}
|
|
3099
|
-
}
|
|
3100
|
-
|
|
3101
|
-
render() {
|
|
3102
|
-
if (this._model && this._session) {
|
|
3103
|
-
const el = /*#__PURE__*/React.createElement(CategorizeComponent, {
|
|
3104
|
-
model: this._model,
|
|
3105
|
-
session: this._session,
|
|
3106
|
-
onAnswersChange: this.changeAnswers.bind(this),
|
|
3107
|
-
onShowCorrectToggle: this.onShowCorrectToggle.bind(this)
|
|
3108
|
-
});
|
|
3109
|
-
ReactDOM.render(el, this, () => {
|
|
3110
|
-
renderMath(this);
|
|
3111
|
-
});
|
|
3112
|
-
}
|
|
3113
|
-
}
|
|
3114
|
-
|
|
3115
|
-
}
|
|
3116
|
-
|
|
3117
|
-
export { Categorize as default };
|
|
3118
|
-
//# sourceMappingURL=element.js.map
|