@agility/plenum-ui 1.1.0 → 1.1.1

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/lib/index.js CHANGED
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var React = require('react');
6
6
  var reactDom = require('react-dom');
7
+ var jsxRuntime = require('react/jsx-runtime');
7
8
 
8
9
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
10
 
@@ -7225,430 +7226,1870 @@ function __spreadArray$1(to, from, pack) {
7225
7226
  return to.concat(ar || Array.prototype.slice.call(from));
7226
7227
  }
7227
7228
 
7228
- let emptyImage;
7229
- function getEmptyImage() {
7230
- if (!emptyImage) {
7231
- emptyImage = new Image();
7232
- emptyImage.src = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
7233
- }
7234
- return emptyImage;
7229
+ /**
7230
+ * Create the React Context
7231
+ */ const DndContext = React.createContext({
7232
+ dragDropManager: undefined
7233
+ });
7234
+
7235
+ /**
7236
+ * Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
7237
+ *
7238
+ * Do not require this module directly! Use normal throw error calls. These messages will be replaced with error codes
7239
+ * during build.
7240
+ * @param {number} code
7241
+ */
7242
+ function formatProdErrorMessage(code) {
7243
+ return "Minified Redux error #" + code + "; visit https://redux.js.org/Errors?code=" + code + " for the full message or " + 'use the non-minified dev environment for full errors. ';
7235
7244
  }
7236
7245
 
7237
- function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
7246
+ // Inlined version of the `symbol-observable` polyfill
7247
+ var $$observable = (function () {
7248
+ return typeof Symbol === 'function' && Symbol.observable || '@@observable';
7249
+ })();
7238
7250
 
7239
- function _unsupportedIterableToArray$1(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(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$1(o, minLen); }
7251
+ /**
7252
+ * These are private action types reserved by Redux.
7253
+ * For any unknown actions, you must return the current state.
7254
+ * If the current state is undefined, you must return the initial state.
7255
+ * Do not reference these action types directly in your code.
7256
+ */
7257
+ var randomString = function randomString() {
7258
+ return Math.random().toString(36).substring(7).split('').join('.');
7259
+ };
7240
7260
 
7241
- function _arrayLikeToArray$1(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; }
7261
+ var ActionTypes = {
7262
+ INIT: "@@redux/INIT" + randomString(),
7263
+ REPLACE: "@@redux/REPLACE" + randomString(),
7264
+ PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
7265
+ return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
7266
+ }
7267
+ };
7242
7268
 
7243
- function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
7269
+ /**
7270
+ * @param {any} obj The object to inspect.
7271
+ * @returns {boolean} True if the argument appears to be a plain object.
7272
+ */
7273
+ function isPlainObject(obj) {
7274
+ if (typeof obj !== 'object' || obj === null) return false;
7275
+ var proto = obj;
7244
7276
 
7245
- 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; }
7277
+ while (Object.getPrototypeOf(proto) !== null) {
7278
+ proto = Object.getPrototypeOf(proto);
7279
+ }
7246
7280
 
7247
- function _classPrivateFieldGet$1(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor$1(receiver, privateMap, "get"); return _classApplyDescriptorGet$1(receiver, descriptor); }
7281
+ return Object.getPrototypeOf(obj) === proto;
7282
+ }
7248
7283
 
7249
- function _classApplyDescriptorGet$1(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
7284
+ // Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of
7285
+ function miniKindOf(val) {
7286
+ if (val === void 0) return 'undefined';
7287
+ if (val === null) return 'null';
7288
+ var type = typeof val;
7250
7289
 
7251
- function _classPrivateFieldSet$1(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor$1(receiver, privateMap, "set"); _classApplyDescriptorSet$1(receiver, descriptor, value); return value; }
7290
+ switch (type) {
7291
+ case 'boolean':
7292
+ case 'string':
7293
+ case 'number':
7294
+ case 'symbol':
7295
+ case 'function':
7296
+ {
7297
+ return type;
7298
+ }
7299
+ }
7252
7300
 
7253
- function _classExtractFieldDescriptor$1(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
7301
+ if (Array.isArray(val)) return 'array';
7302
+ if (isDate(val)) return 'date';
7303
+ if (isError(val)) return 'error';
7304
+ var constructorName = ctorName(val);
7254
7305
 
7255
- function _classApplyDescriptorSet$1(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
7306
+ switch (constructorName) {
7307
+ case 'Symbol':
7308
+ case 'Promise':
7309
+ case 'WeakMap':
7310
+ case 'WeakSet':
7311
+ case 'Map':
7312
+ case 'Set':
7313
+ return constructorName;
7314
+ } // other
7256
7315
 
7257
- var _previews$1 = new WeakMap();
7258
7316
 
7259
- var PreviewListImpl =
7260
- /*private*/
7261
- function PreviewListImpl() {
7262
- var _this = this;
7317
+ return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
7318
+ }
7263
7319
 
7264
- _classCallCheck$1(this, PreviewListImpl);
7320
+ function ctorName(val) {
7321
+ return typeof val.constructor === 'function' ? val.constructor.name : null;
7322
+ }
7265
7323
 
7266
- _previews$1.set(this, {
7267
- writable: true,
7268
- value: void 0
7269
- });
7324
+ function isError(val) {
7325
+ return val instanceof Error || typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number';
7326
+ }
7270
7327
 
7271
- _defineProperty$1(this, "register", function (preview) {
7272
- _classPrivateFieldGet$1(_this, _previews$1).push(preview);
7273
- });
7328
+ function isDate(val) {
7329
+ if (val instanceof Date) return true;
7330
+ return typeof val.toDateString === 'function' && typeof val.getDate === 'function' && typeof val.setDate === 'function';
7331
+ }
7274
7332
 
7275
- _defineProperty$1(this, "unregister", function (preview) {
7276
- var index;
7333
+ function kindOf(val) {
7334
+ var typeOfVal = typeof val;
7277
7335
 
7278
- while ((index = _classPrivateFieldGet$1(_this, _previews$1).indexOf(preview)) !== -1) {
7279
- _classPrivateFieldGet$1(_this, _previews$1).splice(index, 1);
7280
- }
7281
- });
7336
+ if (process.env.NODE_ENV !== 'production') {
7337
+ typeOfVal = miniKindOf(val);
7338
+ }
7282
7339
 
7283
- _defineProperty$1(this, "backendChanged", function (backend) {
7284
- var _iterator = _createForOfIteratorHelper(_classPrivateFieldGet$1(_this, _previews$1)),
7285
- _step;
7340
+ return typeOfVal;
7341
+ }
7286
7342
 
7287
- try {
7288
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
7289
- var preview = _step.value;
7290
- preview.backendChanged(backend);
7291
- }
7292
- } catch (err) {
7293
- _iterator.e(err);
7294
- } finally {
7295
- _iterator.f();
7296
- }
7297
- });
7343
+ /**
7344
+ * @deprecated
7345
+ *
7346
+ * **We recommend using the `configureStore` method
7347
+ * of the `@reduxjs/toolkit` package**, which replaces `createStore`.
7348
+ *
7349
+ * Redux Toolkit is our recommended approach for writing Redux logic today,
7350
+ * including store setup, reducers, data fetching, and more.
7351
+ *
7352
+ * **For more details, please read this Redux docs page:**
7353
+ * **https://redux.js.org/introduction/why-rtk-is-redux-today**
7354
+ *
7355
+ * `configureStore` from Redux Toolkit is an improved version of `createStore` that
7356
+ * simplifies setup and helps avoid common bugs.
7357
+ *
7358
+ * You should not be using the `redux` core package by itself today, except for learning purposes.
7359
+ * The `createStore` method from the core `redux` package will not be removed, but we encourage
7360
+ * all users to migrate to using Redux Toolkit for all Redux code.
7361
+ *
7362
+ * If you want to use `createStore` without this visual deprecation warning, use
7363
+ * the `legacy_createStore` import instead:
7364
+ *
7365
+ * `import { legacy_createStore as createStore} from 'redux'`
7366
+ *
7367
+ */
7298
7368
 
7299
- _classPrivateFieldSet$1(this, _previews$1, []);
7300
- };
7369
+ function createStore(reducer, preloadedState, enhancer) {
7370
+ var _ref2;
7301
7371
 
7302
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
7372
+ if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
7373
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(0) : 'It looks like you are passing several store enhancers to ' + 'createStore(). This is not supported. Instead, compose them ' + 'together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.');
7374
+ }
7303
7375
 
7304
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7376
+ if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
7377
+ enhancer = preloadedState;
7378
+ preloadedState = undefined;
7379
+ }
7305
7380
 
7306
- 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); }
7381
+ if (typeof enhancer !== 'undefined') {
7382
+ if (typeof enhancer !== 'function') {
7383
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(1) : "Expected the enhancer to be a function. Instead, received: '" + kindOf(enhancer) + "'");
7384
+ }
7307
7385
 
7308
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
7386
+ return enhancer(createStore)(reducer, preloadedState);
7387
+ }
7309
7388
 
7310
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7389
+ if (typeof reducer !== 'function') {
7390
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(2) : "Expected the root reducer to be a function. Instead, received: '" + kindOf(reducer) + "'");
7391
+ }
7311
7392
 
7312
- 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; }
7393
+ var currentReducer = reducer;
7394
+ var currentState = preloadedState;
7395
+ var currentListeners = [];
7396
+ var nextListeners = currentListeners;
7397
+ var isDispatching = false;
7398
+ /**
7399
+ * This makes a shallow copy of currentListeners so we can use
7400
+ * nextListeners as a temporary list while dispatching.
7401
+ *
7402
+ * This prevents any bugs around consumers calling
7403
+ * subscribe/unsubscribe in the middle of a dispatch.
7404
+ */
7405
+
7406
+ function ensureCanMutateNextListeners() {
7407
+ if (nextListeners === currentListeners) {
7408
+ nextListeners = currentListeners.slice();
7409
+ }
7410
+ }
7411
+ /**
7412
+ * Reads the state tree managed by the store.
7413
+ *
7414
+ * @returns {any} The current state tree of your application.
7415
+ */
7313
7416
 
7314
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
7315
7417
 
7316
- 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; }
7418
+ function getState() {
7419
+ if (isDispatching) {
7420
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(3) : 'You may not call store.getState() while the reducer is executing. ' + 'The reducer has already received the state as an argument. ' + 'Pass it down from the top reducer instead of reading it from the store.');
7421
+ }
7317
7422
 
7318
- function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
7423
+ return currentState;
7424
+ }
7425
+ /**
7426
+ * Adds a change listener. It will be called any time an action is dispatched,
7427
+ * and some part of the state tree may potentially have changed. You may then
7428
+ * call `getState()` to read the current state tree inside the callback.
7429
+ *
7430
+ * You may call `dispatch()` from a change listener, with the following
7431
+ * caveats:
7432
+ *
7433
+ * 1. The subscriptions are snapshotted just before every `dispatch()` call.
7434
+ * If you subscribe or unsubscribe while the listeners are being invoked, this
7435
+ * will not have any effect on the `dispatch()` that is currently in progress.
7436
+ * However, the next `dispatch()` call, whether nested or not, will use a more
7437
+ * recent snapshot of the subscription list.
7438
+ *
7439
+ * 2. The listener should not expect to see all state changes, as the state
7440
+ * might have been updated multiple times during a nested `dispatch()` before
7441
+ * the listener is called. It is, however, guaranteed that all subscribers
7442
+ * registered before the `dispatch()` started will be called with the latest
7443
+ * state by the time it exits.
7444
+ *
7445
+ * @param {Function} listener A callback to be invoked on every dispatch.
7446
+ * @returns {Function} A function to remove this change listener.
7447
+ */
7448
+
7449
+
7450
+ function subscribe(listener) {
7451
+ if (typeof listener !== 'function') {
7452
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(4) : "Expected the listener to be a function. Instead, received: '" + kindOf(listener) + "'");
7453
+ }
7454
+
7455
+ if (isDispatching) {
7456
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(5) : 'You may not call store.subscribe() while the reducer is executing. ' + 'If you would like to be notified after the store has been updated, subscribe from a ' + 'component and invoke store.getState() in the callback to access the latest state. ' + 'See https://redux.js.org/api/store#subscribelistener for more details.');
7457
+ }
7458
+
7459
+ var isSubscribed = true;
7460
+ ensureCanMutateNextListeners();
7461
+ nextListeners.push(listener);
7462
+ return function unsubscribe() {
7463
+ if (!isSubscribed) {
7464
+ return;
7465
+ }
7319
7466
 
7320
- function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
7467
+ if (isDispatching) {
7468
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(6) : 'You may not unsubscribe from a store listener while the reducer is executing. ' + 'See https://redux.js.org/api/store#subscribelistener for more details.');
7469
+ }
7321
7470
 
7322
- function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
7471
+ isSubscribed = false;
7472
+ ensureCanMutateNextListeners();
7473
+ var index = nextListeners.indexOf(listener);
7474
+ nextListeners.splice(index, 1);
7475
+ currentListeners = null;
7476
+ };
7477
+ }
7478
+ /**
7479
+ * Dispatches an action. It is the only way to trigger a state change.
7480
+ *
7481
+ * The `reducer` function, used to create the store, will be called with the
7482
+ * current state tree and the given `action`. Its return value will
7483
+ * be considered the **next** state of the tree, and the change listeners
7484
+ * will be notified.
7485
+ *
7486
+ * The base implementation only supports plain object actions. If you want to
7487
+ * dispatch a Promise, an Observable, a thunk, or something else, you need to
7488
+ * wrap your store creating function into the corresponding middleware. For
7489
+ * example, see the documentation for the `redux-thunk` package. Even the
7490
+ * middleware will eventually dispatch plain object actions using this method.
7491
+ *
7492
+ * @param {Object} action A plain object representing “what changed”. It is
7493
+ * a good idea to keep actions serializable so you can record and replay user
7494
+ * sessions, or use the time travelling `redux-devtools`. An action must have
7495
+ * a `type` property which may not be `undefined`. It is a good idea to use
7496
+ * string constants for action types.
7497
+ *
7498
+ * @returns {Object} For convenience, the same action object you dispatched.
7499
+ *
7500
+ * Note that, if you use a custom middleware, it may wrap `dispatch()` to
7501
+ * return something else (for example, a Promise you can await).
7502
+ */
7503
+
7504
+
7505
+ function dispatch(action) {
7506
+ if (!isPlainObject(action)) {
7507
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(7) : "Actions must be plain objects. Instead, the actual type was: '" + kindOf(action) + "'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.");
7508
+ }
7509
+
7510
+ if (typeof action.type === 'undefined') {
7511
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(8) : 'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');
7512
+ }
7513
+
7514
+ if (isDispatching) {
7515
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(9) : 'Reducers may not dispatch actions.');
7516
+ }
7323
7517
 
7324
- function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
7518
+ try {
7519
+ isDispatching = true;
7520
+ currentState = currentReducer(currentState, action);
7521
+ } finally {
7522
+ isDispatching = false;
7523
+ }
7325
7524
 
7326
- function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
7525
+ var listeners = currentListeners = nextListeners;
7327
7526
 
7328
- var _current = new WeakMap();
7527
+ for (var i = 0; i < listeners.length; i++) {
7528
+ var listener = listeners[i];
7529
+ listener();
7530
+ }
7329
7531
 
7330
- var _previews = new WeakMap();
7532
+ return action;
7533
+ }
7534
+ /**
7535
+ * Replaces the reducer currently used by the store to calculate the state.
7536
+ *
7537
+ * You might need this if your app implements code splitting and you want to
7538
+ * load some of the reducers dynamically. You might also need this if you
7539
+ * implement a hot reloading mechanism for Redux.
7540
+ *
7541
+ * @param {Function} nextReducer The reducer for the store to use instead.
7542
+ * @returns {void}
7543
+ */
7544
+
7545
+
7546
+ function replaceReducer(nextReducer) {
7547
+ if (typeof nextReducer !== 'function') {
7548
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(10) : "Expected the nextReducer to be a function. Instead, received: '" + kindOf(nextReducer));
7549
+ }
7550
+
7551
+ currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT.
7552
+ // Any reducers that existed in both the new and old rootReducer
7553
+ // will receive the previous state. This effectively populates
7554
+ // the new state tree with any relevant data from the old one.
7555
+
7556
+ dispatch({
7557
+ type: ActionTypes.REPLACE
7558
+ });
7559
+ }
7560
+ /**
7561
+ * Interoperability point for observable/reactive libraries.
7562
+ * @returns {observable} A minimal observable of state changes.
7563
+ * For more information, see the observable proposal:
7564
+ * https://github.com/tc39/proposal-observable
7565
+ */
7566
+
7567
+
7568
+ function observable() {
7569
+ var _ref;
7570
+
7571
+ var outerSubscribe = subscribe;
7572
+ return _ref = {
7573
+ /**
7574
+ * The minimal observable subscription method.
7575
+ * @param {Object} observer Any object that can be used as an observer.
7576
+ * The observer object should have a `next` method.
7577
+ * @returns {subscription} An object with an `unsubscribe` method that can
7578
+ * be used to unsubscribe the observable from the store, and prevent further
7579
+ * emission of values from the observable.
7580
+ */
7581
+ subscribe: function subscribe(observer) {
7582
+ if (typeof observer !== 'object' || observer === null) {
7583
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(11) : "Expected the observer to be an object. Instead, received: '" + kindOf(observer) + "'");
7584
+ }
7331
7585
 
7332
- var _backends = new WeakMap();
7586
+ function observeState() {
7587
+ if (observer.next) {
7588
+ observer.next(getState());
7589
+ }
7590
+ }
7333
7591
 
7334
- var _backendsList = new WeakMap();
7592
+ observeState();
7593
+ var unsubscribe = outerSubscribe(observeState);
7594
+ return {
7595
+ unsubscribe: unsubscribe
7596
+ };
7597
+ }
7598
+ }, _ref[$$observable] = function () {
7599
+ return this;
7600
+ }, _ref;
7601
+ } // When a store is created, an "INIT" action is dispatched so that every
7602
+ // reducer returns their initial state. This effectively populates
7603
+ // the initial state tree.
7335
7604
 
7336
- var _nodes = new WeakMap();
7337
7605
 
7338
- var _createBackend = new WeakMap();
7606
+ dispatch({
7607
+ type: ActionTypes.INIT
7608
+ });
7609
+ return _ref2 = {
7610
+ dispatch: dispatch,
7611
+ subscribe: subscribe,
7612
+ getState: getState,
7613
+ replaceReducer: replaceReducer
7614
+ }, _ref2[$$observable] = observable, _ref2;
7615
+ }
7339
7616
 
7340
- var _addEventListeners = new WeakMap();
7617
+ /**
7618
+ * Prints a warning in the console if it exists.
7619
+ *
7620
+ * @param {String} message The warning message.
7621
+ * @returns {void}
7622
+ */
7623
+ function warning(message) {
7624
+ /* eslint-disable no-console */
7625
+ if (typeof console !== 'undefined' && typeof console.error === 'function') {
7626
+ console.error(message);
7627
+ }
7628
+ /* eslint-enable no-console */
7341
7629
 
7342
- var _removeEventListeners = new WeakMap();
7343
7630
 
7344
- var _backendSwitcher = new WeakMap();
7631
+ try {
7632
+ // This error was thrown as a convenience so that if you enable
7633
+ // "break on all exceptions" in your console,
7634
+ // it would pause the execution at this line.
7635
+ throw new Error(message);
7636
+ } catch (e) {} // eslint-disable-line no-empty
7345
7637
 
7346
- var _callBackend = new WeakMap();
7638
+ }
7347
7639
 
7348
- var _connectBackend = new WeakMap();
7640
+ /*
7641
+ * This is a dummy function to check if the function name has been altered by minification.
7642
+ * If the function has been minified and NODE_ENV !== 'production', warn the user.
7643
+ */
7349
7644
 
7350
- var MultiBackendImpl =
7351
- /*private*/
7645
+ function isCrushed() {}
7352
7646
 
7353
- /*private*/
7647
+ if (process.env.NODE_ENV !== 'production' && typeof isCrushed.name === 'string' && isCrushed.name !== 'isCrushed') {
7648
+ warning('You are currently using minified code outside of NODE_ENV === "production". ' + 'This means that you are running a slower development build of Redux. ' + 'You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify ' + 'or setting mode to production in webpack (https://webpack.js.org/concepts/mode/) ' + 'to ensure you have the correct code for your production build.');
7649
+ }
7354
7650
 
7355
- /*private*/
7651
+ /**
7652
+ * Use invariant() to assert state which your program assumes to be true.
7653
+ *
7654
+ * Provide sprintf-style format (only %s is supported) and arguments
7655
+ * to provide information about what broke and what you were
7656
+ * expecting.
7657
+ *
7658
+ * The invariant message will be stripped in production, but the invariant
7659
+ * will remain to ensure logic does not differ in production.
7660
+ */ function invariant(condition, format, ...args) {
7661
+ if (isProduction()) {
7662
+ if (format === undefined) {
7663
+ throw new Error('invariant requires an error message argument');
7664
+ }
7665
+ }
7666
+ if (!condition) {
7667
+ let error;
7668
+ if (format === undefined) {
7669
+ error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
7670
+ } else {
7671
+ let argIndex = 0;
7672
+ error = new Error(format.replace(/%s/g, function() {
7673
+ return args[argIndex++];
7674
+ }));
7675
+ error.name = 'Invariant Violation';
7676
+ }
7677
+ error.framesToPop = 1 // we don't care about invariant's own frame
7678
+ ;
7679
+ throw error;
7680
+ }
7681
+ }
7682
+ function isProduction() {
7683
+ return typeof process !== 'undefined' && process.env['NODE_ENV'] === 'production';
7684
+ }
7356
7685
 
7357
- /*private*/
7686
+ // cheap lodash replacements
7687
+ /**
7688
+ * drop-in replacement for _.get
7689
+ * @param obj
7690
+ * @param path
7691
+ * @param defaultValue
7692
+ */ function get(obj, path, defaultValue) {
7693
+ return path.split('.').reduce((a, c)=>a && a[c] ? a[c] : defaultValue || null
7694
+ , obj);
7695
+ }
7696
+ /**
7697
+ * drop-in replacement for _.without
7698
+ */ function without$1(items, item) {
7699
+ return items.filter((i)=>i !== item
7700
+ );
7701
+ }
7702
+ /**
7703
+ * drop-in replacement for _.isString
7704
+ * @param input
7705
+ */ function isObject(input) {
7706
+ return typeof input === 'object';
7707
+ }
7708
+ /**
7709
+ * replacement for _.xor
7710
+ * @param itemsA
7711
+ * @param itemsB
7712
+ */ function xor(itemsA, itemsB) {
7713
+ const map = new Map();
7714
+ const insertItem = (item)=>{
7715
+ map.set(item, map.has(item) ? map.get(item) + 1 : 1);
7716
+ };
7717
+ itemsA.forEach(insertItem);
7718
+ itemsB.forEach(insertItem);
7719
+ const result = [];
7720
+ map.forEach((count, key)=>{
7721
+ if (count === 1) {
7722
+ result.push(key);
7723
+ }
7724
+ });
7725
+ return result;
7726
+ }
7727
+ /**
7728
+ * replacement for _.intersection
7729
+ * @param itemsA
7730
+ * @param itemsB
7731
+ */ function intersection(itemsA, itemsB) {
7732
+ return itemsA.filter((t)=>itemsB.indexOf(t) > -1
7733
+ );
7734
+ }
7358
7735
 
7359
- /*private*/
7360
- function MultiBackendImpl(_manager, _context, _options) {
7361
- var _this = this;
7736
+ const INIT_COORDS = 'dnd-core/INIT_COORDS';
7737
+ const BEGIN_DRAG = 'dnd-core/BEGIN_DRAG';
7738
+ const PUBLISH_DRAG_SOURCE = 'dnd-core/PUBLISH_DRAG_SOURCE';
7739
+ const HOVER = 'dnd-core/HOVER';
7740
+ const DROP = 'dnd-core/DROP';
7741
+ const END_DRAG = 'dnd-core/END_DRAG';
7362
7742
 
7363
- _classCallCheck(this, MultiBackendImpl);
7743
+ function setClientOffset(clientOffset, sourceClientOffset) {
7744
+ return {
7745
+ type: INIT_COORDS,
7746
+ payload: {
7747
+ sourceClientOffset: sourceClientOffset || null,
7748
+ clientOffset: clientOffset || null
7749
+ }
7750
+ };
7751
+ }
7364
7752
 
7365
- _current.set(this, {
7366
- writable: true,
7367
- value: void 0
7368
- });
7753
+ const ResetCoordinatesAction = {
7754
+ type: INIT_COORDS,
7755
+ payload: {
7756
+ clientOffset: null,
7757
+ sourceClientOffset: null
7758
+ }
7759
+ };
7760
+ function createBeginDrag(manager) {
7761
+ return function beginDrag(sourceIds = [], options = {
7762
+ publishSource: true
7763
+ }) {
7764
+ const { publishSource =true , clientOffset , getSourceClientOffset , } = options;
7765
+ const monitor = manager.getMonitor();
7766
+ const registry = manager.getRegistry();
7767
+ // Initialize the coordinates using the client offset
7768
+ manager.dispatch(setClientOffset(clientOffset));
7769
+ verifyInvariants$1(sourceIds, monitor, registry);
7770
+ // Get the draggable source
7771
+ const sourceId = getDraggableSource(sourceIds, monitor);
7772
+ if (sourceId == null) {
7773
+ manager.dispatch(ResetCoordinatesAction);
7774
+ return;
7775
+ }
7776
+ // Get the source client offset
7777
+ let sourceClientOffset = null;
7778
+ if (clientOffset) {
7779
+ if (!getSourceClientOffset) {
7780
+ throw new Error('getSourceClientOffset must be defined');
7781
+ }
7782
+ verifyGetSourceClientOffsetIsFunction(getSourceClientOffset);
7783
+ sourceClientOffset = getSourceClientOffset(sourceId);
7784
+ }
7785
+ // Initialize the full coordinates
7786
+ manager.dispatch(setClientOffset(clientOffset, sourceClientOffset));
7787
+ const source = registry.getSource(sourceId);
7788
+ const item = source.beginDrag(monitor, sourceId);
7789
+ // If source.beginDrag returns null, this is an indicator to cancel the drag
7790
+ if (item == null) {
7791
+ return undefined;
7792
+ }
7793
+ verifyItemIsObject(item);
7794
+ registry.pinSource(sourceId);
7795
+ const itemType = registry.getSourceType(sourceId);
7796
+ return {
7797
+ type: BEGIN_DRAG,
7798
+ payload: {
7799
+ itemType,
7800
+ item,
7801
+ sourceId,
7802
+ clientOffset: clientOffset || null,
7803
+ sourceClientOffset: sourceClientOffset || null,
7804
+ isSourcePublic: !!publishSource
7805
+ }
7806
+ };
7807
+ };
7808
+ }
7809
+ function verifyInvariants$1(sourceIds, monitor, registry) {
7810
+ invariant(!monitor.isDragging(), 'Cannot call beginDrag while dragging.');
7811
+ sourceIds.forEach(function(sourceId) {
7812
+ invariant(registry.getSource(sourceId), 'Expected sourceIds to be registered.');
7813
+ });
7814
+ }
7815
+ function verifyGetSourceClientOffsetIsFunction(getSourceClientOffset) {
7816
+ invariant(typeof getSourceClientOffset === 'function', 'When clientOffset is provided, getSourceClientOffset must be a function.');
7817
+ }
7818
+ function verifyItemIsObject(item) {
7819
+ invariant(isObject(item), 'Item must be an object.');
7820
+ }
7821
+ function getDraggableSource(sourceIds, monitor) {
7822
+ let sourceId = null;
7823
+ for(let i = sourceIds.length - 1; i >= 0; i--){
7824
+ if (monitor.canDragSource(sourceIds[i])) {
7825
+ sourceId = sourceIds[i];
7826
+ break;
7827
+ }
7828
+ }
7829
+ return sourceId;
7830
+ }
7369
7831
 
7370
- _previews.set(this, {
7371
- writable: true,
7372
- value: void 0
7373
- });
7832
+ function _defineProperty$6(obj, key, value) {
7833
+ if (key in obj) {
7834
+ Object.defineProperty(obj, key, {
7835
+ value: value,
7836
+ enumerable: true,
7837
+ configurable: true,
7838
+ writable: true
7839
+ });
7840
+ } else {
7841
+ obj[key] = value;
7842
+ }
7843
+ return obj;
7844
+ }
7845
+ function _objectSpread$4(target) {
7846
+ for(var i = 1; i < arguments.length; i++){
7847
+ var source = arguments[i] != null ? arguments[i] : {};
7848
+ var ownKeys = Object.keys(source);
7849
+ if (typeof Object.getOwnPropertySymbols === 'function') {
7850
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
7851
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
7852
+ }));
7853
+ }
7854
+ ownKeys.forEach(function(key) {
7855
+ _defineProperty$6(target, key, source[key]);
7856
+ });
7857
+ }
7858
+ return target;
7859
+ }
7860
+ function createDrop(manager) {
7861
+ return function drop(options = {}) {
7862
+ const monitor = manager.getMonitor();
7863
+ const registry = manager.getRegistry();
7864
+ verifyInvariants(monitor);
7865
+ const targetIds = getDroppableTargets(monitor);
7866
+ // Multiple actions are dispatched here, which is why this doesn't return an action
7867
+ targetIds.forEach((targetId, index)=>{
7868
+ const dropResult = determineDropResult(targetId, index, registry, monitor);
7869
+ const action = {
7870
+ type: DROP,
7871
+ payload: {
7872
+ dropResult: _objectSpread$4({}, options, dropResult)
7873
+ }
7874
+ };
7875
+ manager.dispatch(action);
7876
+ });
7877
+ };
7878
+ }
7879
+ function verifyInvariants(monitor) {
7880
+ invariant(monitor.isDragging(), 'Cannot call drop while not dragging.');
7881
+ invariant(!monitor.didDrop(), 'Cannot call drop twice during one drag operation.');
7882
+ }
7883
+ function determineDropResult(targetId, index, registry, monitor) {
7884
+ const target = registry.getTarget(targetId);
7885
+ let dropResult = target ? target.drop(monitor, targetId) : undefined;
7886
+ verifyDropResultType(dropResult);
7887
+ if (typeof dropResult === 'undefined') {
7888
+ dropResult = index === 0 ? {} : monitor.getDropResult();
7889
+ }
7890
+ return dropResult;
7891
+ }
7892
+ function verifyDropResultType(dropResult) {
7893
+ invariant(typeof dropResult === 'undefined' || isObject(dropResult), 'Drop result must either be an object or undefined.');
7894
+ }
7895
+ function getDroppableTargets(monitor) {
7896
+ const targetIds = monitor.getTargetIds().filter(monitor.canDropOnTarget, monitor);
7897
+ targetIds.reverse();
7898
+ return targetIds;
7899
+ }
7900
+
7901
+ function createEndDrag(manager) {
7902
+ return function endDrag() {
7903
+ const monitor = manager.getMonitor();
7904
+ const registry = manager.getRegistry();
7905
+ verifyIsDragging(monitor);
7906
+ const sourceId = monitor.getSourceId();
7907
+ if (sourceId != null) {
7908
+ const source = registry.getSource(sourceId, true);
7909
+ source.endDrag(monitor, sourceId);
7910
+ registry.unpinSource();
7911
+ }
7912
+ return {
7913
+ type: END_DRAG
7914
+ };
7915
+ };
7916
+ }
7917
+ function verifyIsDragging(monitor) {
7918
+ invariant(monitor.isDragging(), 'Cannot call endDrag while not dragging.');
7919
+ }
7374
7920
 
7375
- _backends.set(this, {
7376
- writable: true,
7377
- value: void 0
7378
- });
7379
-
7380
- _backendsList.set(this, {
7381
- writable: true,
7382
- value: void 0
7383
- });
7384
-
7385
- _nodes.set(this, {
7386
- writable: true,
7387
- value: void 0
7388
- });
7389
-
7390
- _createBackend.set(this, {
7391
- writable: true,
7392
- value: function value(manager, context, backend) {
7393
- var _backend$preview, _backend$skipDispatch;
7394
-
7395
- if (!backend.backend) {
7396
- throw new Error("You must specify a 'backend' property in your Backend entry: ".concat(JSON.stringify(backend)));
7397
- }
7398
-
7399
- var instance = backend.backend(manager, context, backend.options);
7400
- var id = backend.id; // Try to infer an `id` if one doesn't exist
7401
-
7402
- var inferName = !backend.id && instance && instance.constructor;
7921
+ function matchesType(targetType, draggedItemType) {
7922
+ if (draggedItemType === null) {
7923
+ return targetType === null;
7924
+ }
7925
+ return Array.isArray(targetType) ? targetType.some((t)=>t === draggedItemType
7926
+ ) : targetType === draggedItemType;
7927
+ }
7403
7928
 
7404
- if (inferName) {
7405
- id = instance.constructor.name;
7406
- }
7929
+ function createHover(manager) {
7930
+ return function hover(targetIdsArg, { clientOffset } = {}) {
7931
+ verifyTargetIdsIsArray(targetIdsArg);
7932
+ const targetIds = targetIdsArg.slice(0);
7933
+ const monitor = manager.getMonitor();
7934
+ const registry = manager.getRegistry();
7935
+ const draggedItemType = monitor.getItemType();
7936
+ removeNonMatchingTargetIds(targetIds, registry, draggedItemType);
7937
+ checkInvariants(targetIds, monitor, registry);
7938
+ hoverAllTargets(targetIds, monitor, registry);
7939
+ return {
7940
+ type: HOVER,
7941
+ payload: {
7942
+ targetIds,
7943
+ clientOffset: clientOffset || null
7944
+ }
7945
+ };
7946
+ };
7947
+ }
7948
+ function verifyTargetIdsIsArray(targetIdsArg) {
7949
+ invariant(Array.isArray(targetIdsArg), 'Expected targetIds to be an array.');
7950
+ }
7951
+ function checkInvariants(targetIds, monitor, registry) {
7952
+ invariant(monitor.isDragging(), 'Cannot call hover while not dragging.');
7953
+ invariant(!monitor.didDrop(), 'Cannot call hover after drop.');
7954
+ for(let i = 0; i < targetIds.length; i++){
7955
+ const targetId = targetIds[i];
7956
+ invariant(targetIds.lastIndexOf(targetId) === i, 'Expected targetIds to be unique in the passed array.');
7957
+ const target = registry.getTarget(targetId);
7958
+ invariant(target, 'Expected targetIds to be registered.');
7959
+ }
7960
+ }
7961
+ function removeNonMatchingTargetIds(targetIds, registry, draggedItemType) {
7962
+ // Remove those targetIds that don't match the targetType. This
7963
+ // fixes shallow isOver which would only be non-shallow because of
7964
+ // non-matching targets.
7965
+ for(let i = targetIds.length - 1; i >= 0; i--){
7966
+ const targetId = targetIds[i];
7967
+ const targetType = registry.getTargetType(targetId);
7968
+ if (!matchesType(targetType, draggedItemType)) {
7969
+ targetIds.splice(i, 1);
7970
+ }
7971
+ }
7972
+ }
7973
+ function hoverAllTargets(targetIds, monitor, registry) {
7974
+ // Finally call hover on all matching targets.
7975
+ targetIds.forEach(function(targetId) {
7976
+ const target = registry.getTarget(targetId);
7977
+ target.hover(monitor, targetId);
7978
+ });
7979
+ }
7407
7980
 
7408
- if (!id) {
7409
- throw new Error("You must specify an 'id' property in your Backend entry: ".concat(JSON.stringify(backend), "\n see this guide: https://github.com/louisbrunner/dnd-multi-backend/tree/master/packages/react-dnd-multi-backend#migrating-from-5xx"));
7410
- } else if (inferName) {
7411
- console.warn( // eslint-disable-line no-console
7412
- "Deprecation notice: You are using a pipeline which doesn't include backends' 'id'.\n This might be unsupported in the future, please specify 'id' explicitely for every backend.");
7413
- }
7981
+ function createPublishDragSource(manager) {
7982
+ return function publishDragSource() {
7983
+ const monitor = manager.getMonitor();
7984
+ if (monitor.isDragging()) {
7985
+ return {
7986
+ type: PUBLISH_DRAG_SOURCE
7987
+ };
7988
+ }
7989
+ return;
7990
+ };
7991
+ }
7414
7992
 
7415
- if (_classPrivateFieldGet(_this, _backends)[id]) {
7416
- throw new Error("You must specify a unique 'id' property in your Backend entry:\n ".concat(JSON.stringify(backend), " (conflicts with: ").concat(JSON.stringify(_classPrivateFieldGet(_this, _backends)[id]), ")"));
7417
- }
7993
+ function createDragDropActions(manager) {
7994
+ return {
7995
+ beginDrag: createBeginDrag(manager),
7996
+ publishDragSource: createPublishDragSource(manager),
7997
+ hover: createHover(manager),
7998
+ drop: createDrop(manager),
7999
+ endDrag: createEndDrag(manager)
8000
+ };
8001
+ }
7418
8002
 
7419
- return {
7420
- id: id,
7421
- instance: instance,
7422
- preview: (_backend$preview = backend.preview) !== null && _backend$preview !== void 0 ? _backend$preview : false,
7423
- transition: backend.transition,
7424
- skipDispatchOnTransition: (_backend$skipDispatch = backend.skipDispatchOnTransition) !== null && _backend$skipDispatch !== void 0 ? _backend$skipDispatch : false
7425
- };
8003
+ class DragDropManagerImpl {
8004
+ receiveBackend(backend) {
8005
+ this.backend = backend;
7426
8006
  }
7427
- });
7428
-
7429
- _defineProperty(this, "setup", function () {
7430
- if (typeof window === 'undefined') {
7431
- return;
8007
+ getMonitor() {
8008
+ return this.monitor;
7432
8009
  }
7433
-
7434
- if (MultiBackendImpl.isSetUp) {
7435
- throw new Error('Cannot have two MultiBackends at the same time.');
8010
+ getBackend() {
8011
+ return this.backend;
7436
8012
  }
7437
-
7438
- MultiBackendImpl.isSetUp = true;
7439
-
7440
- _classPrivateFieldGet(_this, _addEventListeners).call(_this, window);
7441
-
7442
- _classPrivateFieldGet(_this, _backends)[_classPrivateFieldGet(_this, _current)].instance.setup();
7443
- });
7444
-
7445
- _defineProperty(this, "teardown", function () {
7446
- if (typeof window === 'undefined') {
7447
- return;
8013
+ getRegistry() {
8014
+ return this.monitor.registry;
7448
8015
  }
7449
-
7450
- MultiBackendImpl.isSetUp = false;
7451
-
7452
- _classPrivateFieldGet(_this, _removeEventListeners).call(_this, window);
7453
-
7454
- _classPrivateFieldGet(_this, _backends)[_classPrivateFieldGet(_this, _current)].instance.teardown();
7455
- });
7456
-
7457
- _defineProperty(this, "connectDragSource", function (sourceId, node, options) {
7458
- return _classPrivateFieldGet(_this, _connectBackend).call(_this, 'connectDragSource', sourceId, node, options);
7459
- });
7460
-
7461
- _defineProperty(this, "connectDragPreview", function (sourceId, node, options) {
7462
- return _classPrivateFieldGet(_this, _connectBackend).call(_this, 'connectDragPreview', sourceId, node, options);
7463
- });
7464
-
7465
- _defineProperty(this, "connectDropTarget", function (sourceId, node, options) {
7466
- return _classPrivateFieldGet(_this, _connectBackend).call(_this, 'connectDropTarget', sourceId, node, options);
7467
- });
7468
-
7469
- _defineProperty(this, "profile", function () {
7470
- return _classPrivateFieldGet(_this, _backends)[_classPrivateFieldGet(_this, _current)].instance.profile();
7471
- });
7472
-
7473
- _defineProperty(this, "previewEnabled", function () {
7474
- return _classPrivateFieldGet(_this, _backends)[_classPrivateFieldGet(_this, _current)].preview;
7475
- });
7476
-
7477
- _defineProperty(this, "previewsList", function () {
7478
- return _classPrivateFieldGet(_this, _previews);
7479
- });
7480
-
7481
- _defineProperty(this, "backendsList", function () {
7482
- return _classPrivateFieldGet(_this, _backendsList);
7483
- });
7484
-
7485
- _addEventListeners.set(this, {
7486
- writable: true,
7487
- value: function value(target) {
7488
- _classPrivateFieldGet(_this, _backendsList).forEach(function (backend) {
7489
- if (backend.transition) {
7490
- target.addEventListener(backend.transition.event, _classPrivateFieldGet(_this, _backendSwitcher));
8016
+ getActions() {
8017
+ /* eslint-disable-next-line @typescript-eslint/no-this-alias */ const manager = this;
8018
+ const { dispatch } = this.store;
8019
+ function bindActionCreator(actionCreator) {
8020
+ return (...args)=>{
8021
+ const action = actionCreator.apply(manager, args);
8022
+ if (typeof action !== 'undefined') {
8023
+ dispatch(action);
8024
+ }
8025
+ };
7491
8026
  }
7492
- });
8027
+ const actions = createDragDropActions(this);
8028
+ return Object.keys(actions).reduce((boundActions, key)=>{
8029
+ const action = actions[key];
8030
+ boundActions[key] = bindActionCreator(action);
8031
+ return boundActions;
8032
+ }, {});
8033
+ }
8034
+ dispatch(action) {
8035
+ this.store.dispatch(action);
8036
+ }
8037
+ constructor(store, monitor){
8038
+ this.isSetUp = false;
8039
+ this.handleRefCountChange = ()=>{
8040
+ const shouldSetUp = this.store.getState().refCount > 0;
8041
+ if (this.backend) {
8042
+ if (shouldSetUp && !this.isSetUp) {
8043
+ this.backend.setup();
8044
+ this.isSetUp = true;
8045
+ } else if (!shouldSetUp && this.isSetUp) {
8046
+ this.backend.teardown();
8047
+ this.isSetUp = false;
8048
+ }
8049
+ }
8050
+ };
8051
+ this.store = store;
8052
+ this.monitor = monitor;
8053
+ store.subscribe(this.handleRefCountChange);
7493
8054
  }
7494
- });
8055
+ }
7495
8056
 
7496
- _removeEventListeners.set(this, {
7497
- writable: true,
7498
- value: function value(target) {
7499
- _classPrivateFieldGet(_this, _backendsList).forEach(function (backend) {
7500
- if (backend.transition) {
7501
- target.removeEventListener(backend.transition.event, _classPrivateFieldGet(_this, _backendSwitcher));
7502
- }
7503
- });
8057
+ /**
8058
+ * Coordinate addition
8059
+ * @param a The first coordinate
8060
+ * @param b The second coordinate
8061
+ */ function add(a, b) {
8062
+ return {
8063
+ x: a.x + b.x,
8064
+ y: a.y + b.y
8065
+ };
8066
+ }
8067
+ /**
8068
+ * Coordinate subtraction
8069
+ * @param a The first coordinate
8070
+ * @param b The second coordinate
8071
+ */ function subtract(a, b) {
8072
+ return {
8073
+ x: a.x - b.x,
8074
+ y: a.y - b.y
8075
+ };
8076
+ }
8077
+ /**
8078
+ * Returns the cartesian distance of the drag source component's position, based on its position
8079
+ * at the time when the current drag operation has started, and the movement difference.
8080
+ *
8081
+ * Returns null if no item is being dragged.
8082
+ *
8083
+ * @param state The offset state to compute from
8084
+ */ function getSourceClientOffset(state) {
8085
+ const { clientOffset , initialClientOffset , initialSourceClientOffset } = state;
8086
+ if (!clientOffset || !initialClientOffset || !initialSourceClientOffset) {
8087
+ return null;
7504
8088
  }
7505
- });
7506
-
7507
- _backendSwitcher.set(this, {
7508
- writable: true,
7509
- value: function value(event) {
7510
- var oldBackend = _classPrivateFieldGet(_this, _current);
7511
-
7512
- _classPrivateFieldGet(_this, _backendsList).some(function (backend) {
7513
- if (backend.id !== _classPrivateFieldGet(_this, _current) && backend.transition && backend.transition.check(event)) {
7514
- _classPrivateFieldSet(_this, _current, backend.id);
7515
-
7516
- return true;
7517
- }
8089
+ return subtract(add(clientOffset, initialSourceClientOffset), initialClientOffset);
8090
+ }
8091
+ /**
8092
+ * Determines the x,y offset between the client offset and the initial client offset
8093
+ *
8094
+ * @param state The offset state to compute from
8095
+ */ function getDifferenceFromInitialOffset(state) {
8096
+ const { clientOffset , initialClientOffset } = state;
8097
+ if (!clientOffset || !initialClientOffset) {
8098
+ return null;
8099
+ }
8100
+ return subtract(clientOffset, initialClientOffset);
8101
+ }
7518
8102
 
8103
+ const NONE = [];
8104
+ const ALL = [];
8105
+ NONE.__IS_NONE__ = true;
8106
+ ALL.__IS_ALL__ = true;
8107
+ /**
8108
+ * Determines if the given handler IDs are dirty or not.
8109
+ *
8110
+ * @param dirtyIds The set of dirty handler ids
8111
+ * @param handlerIds The set of handler ids to check
8112
+ */ function areDirty(dirtyIds, handlerIds) {
8113
+ if (dirtyIds === NONE) {
7519
8114
  return false;
7520
- });
7521
-
7522
- if (_classPrivateFieldGet(_this, _current) !== oldBackend) {
7523
- var _event$target;
7524
-
7525
- _classPrivateFieldGet(_this, _backends)[oldBackend].instance.teardown();
7526
-
7527
- Object.keys(_classPrivateFieldGet(_this, _nodes)).forEach(function (id) {
7528
- var _classPrivateFieldGet2;
7529
-
7530
- var node = _classPrivateFieldGet(_this, _nodes)[id];
7531
-
7532
- node.unsubscribe();
7533
- node.unsubscribe = (_classPrivateFieldGet2 = _classPrivateFieldGet(_this, _callBackend)).call.apply(_classPrivateFieldGet2, [_this, node.func].concat(_toConsumableArray(node.args)));
7534
- });
7535
-
7536
- _classPrivateFieldGet(_this, _previews).backendChanged(_this);
7537
-
7538
- var newBackend = _classPrivateFieldGet(_this, _backends)[_classPrivateFieldGet(_this, _current)];
7539
-
7540
- newBackend.instance.setup();
7541
-
7542
- if (newBackend.skipDispatchOnTransition) {
7543
- return;
8115
+ }
8116
+ if (dirtyIds === ALL || typeof handlerIds === 'undefined') {
8117
+ return true;
8118
+ }
8119
+ const commonIds = intersection(handlerIds, dirtyIds);
8120
+ return commonIds.length > 0;
8121
+ }
8122
+
8123
+ class DragDropMonitorImpl {
8124
+ subscribeToStateChange(listener, options = {}) {
8125
+ const { handlerIds } = options;
8126
+ invariant(typeof listener === 'function', 'listener must be a function.');
8127
+ invariant(typeof handlerIds === 'undefined' || Array.isArray(handlerIds), 'handlerIds, when specified, must be an array of strings.');
8128
+ let prevStateId = this.store.getState().stateId;
8129
+ const handleChange = ()=>{
8130
+ const state = this.store.getState();
8131
+ const currentStateId = state.stateId;
8132
+ try {
8133
+ const canSkipListener = currentStateId === prevStateId || currentStateId === prevStateId + 1 && !areDirty(state.dirtyHandlerIds, handlerIds);
8134
+ if (!canSkipListener) {
8135
+ listener();
8136
+ }
8137
+ } finally{
8138
+ prevStateId = currentStateId;
8139
+ }
8140
+ };
8141
+ return this.store.subscribe(handleChange);
8142
+ }
8143
+ subscribeToOffsetChange(listener) {
8144
+ invariant(typeof listener === 'function', 'listener must be a function.');
8145
+ let previousState = this.store.getState().dragOffset;
8146
+ const handleChange = ()=>{
8147
+ const nextState = this.store.getState().dragOffset;
8148
+ if (nextState === previousState) {
8149
+ return;
8150
+ }
8151
+ previousState = nextState;
8152
+ listener();
8153
+ };
8154
+ return this.store.subscribe(handleChange);
8155
+ }
8156
+ canDragSource(sourceId) {
8157
+ if (!sourceId) {
8158
+ return false;
7544
8159
  }
7545
-
7546
- var newEvent = null;
7547
-
7548
- try {
7549
- newEvent = event.constructor(event.type, event);
7550
- } catch (_e) {
7551
- newEvent = document.createEvent('Event');
7552
- newEvent.initEvent(event.type, event.bubbles, event.cancelable);
8160
+ const source = this.registry.getSource(sourceId);
8161
+ invariant(source, `Expected to find a valid source. sourceId=${sourceId}`);
8162
+ if (this.isDragging()) {
8163
+ return false;
7553
8164
  }
7554
-
7555
- (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.dispatchEvent(newEvent);
7556
- }
8165
+ return source.canDrag(this, sourceId);
7557
8166
  }
7558
- });
7559
-
7560
- _callBackend.set(this, {
7561
- writable: true,
7562
- value: function value(func, sourceId, node, options) {
7563
- return _classPrivateFieldGet(_this, _backends)[_classPrivateFieldGet(_this, _current)].instance[func](sourceId, node, options);
8167
+ canDropOnTarget(targetId) {
8168
+ // undefined on initial render
8169
+ if (!targetId) {
8170
+ return false;
8171
+ }
8172
+ const target = this.registry.getTarget(targetId);
8173
+ invariant(target, `Expected to find a valid target. targetId=${targetId}`);
8174
+ if (!this.isDragging() || this.didDrop()) {
8175
+ return false;
8176
+ }
8177
+ const targetType = this.registry.getTargetType(targetId);
8178
+ const draggedItemType = this.getItemType();
8179
+ return matchesType(targetType, draggedItemType) && target.canDrop(this, targetId);
7564
8180
  }
7565
- });
7566
-
7567
- _connectBackend.set(this, {
7568
- writable: true,
7569
- value: function value(func, sourceId, node, options) {
7570
- var nodeId = "".concat(func, "_").concat(sourceId);
7571
-
7572
- var unsubscribe = _classPrivateFieldGet(_this, _callBackend).call(_this, func, sourceId, node, options);
7573
-
7574
- _classPrivateFieldGet(_this, _nodes)[nodeId] = {
7575
- func: func,
7576
- args: [sourceId, node, options],
7577
- unsubscribe: unsubscribe
7578
- };
7579
- return function () {
7580
- _classPrivateFieldGet(_this, _nodes)[nodeId].unsubscribe();
7581
-
7582
- delete _classPrivateFieldGet(_this, _nodes)[nodeId];
7583
- };
8181
+ isDragging() {
8182
+ return Boolean(this.getItemType());
7584
8183
  }
7585
- });
8184
+ isDraggingSource(sourceId) {
8185
+ // undefined on initial render
8186
+ if (!sourceId) {
8187
+ return false;
8188
+ }
8189
+ const source = this.registry.getSource(sourceId, true);
8190
+ invariant(source, `Expected to find a valid source. sourceId=${sourceId}`);
8191
+ if (!this.isDragging() || !this.isSourcePublic()) {
8192
+ return false;
8193
+ }
8194
+ const sourceType = this.registry.getSourceType(sourceId);
8195
+ const draggedItemType = this.getItemType();
8196
+ if (sourceType !== draggedItemType) {
8197
+ return false;
8198
+ }
8199
+ return source.isDragging(this, sourceId);
8200
+ }
8201
+ isOverTarget(targetId, options = {
8202
+ shallow: false
8203
+ }) {
8204
+ // undefined on initial render
8205
+ if (!targetId) {
8206
+ return false;
8207
+ }
8208
+ const { shallow } = options;
8209
+ if (!this.isDragging()) {
8210
+ return false;
8211
+ }
8212
+ const targetType = this.registry.getTargetType(targetId);
8213
+ const draggedItemType = this.getItemType();
8214
+ if (draggedItemType && !matchesType(targetType, draggedItemType)) {
8215
+ return false;
8216
+ }
8217
+ const targetIds = this.getTargetIds();
8218
+ if (!targetIds.length) {
8219
+ return false;
8220
+ }
8221
+ const index = targetIds.indexOf(targetId);
8222
+ if (shallow) {
8223
+ return index === targetIds.length - 1;
8224
+ } else {
8225
+ return index > -1;
8226
+ }
8227
+ }
8228
+ getItemType() {
8229
+ return this.store.getState().dragOperation.itemType;
8230
+ }
8231
+ getItem() {
8232
+ return this.store.getState().dragOperation.item;
8233
+ }
8234
+ getSourceId() {
8235
+ return this.store.getState().dragOperation.sourceId;
8236
+ }
8237
+ getTargetIds() {
8238
+ return this.store.getState().dragOperation.targetIds;
8239
+ }
8240
+ getDropResult() {
8241
+ return this.store.getState().dragOperation.dropResult;
8242
+ }
8243
+ didDrop() {
8244
+ return this.store.getState().dragOperation.didDrop;
8245
+ }
8246
+ isSourcePublic() {
8247
+ return Boolean(this.store.getState().dragOperation.isSourcePublic);
8248
+ }
8249
+ getInitialClientOffset() {
8250
+ return this.store.getState().dragOffset.initialClientOffset;
8251
+ }
8252
+ getInitialSourceClientOffset() {
8253
+ return this.store.getState().dragOffset.initialSourceClientOffset;
8254
+ }
8255
+ getClientOffset() {
8256
+ return this.store.getState().dragOffset.clientOffset;
8257
+ }
8258
+ getSourceClientOffset() {
8259
+ return getSourceClientOffset(this.store.getState().dragOffset);
8260
+ }
8261
+ getDifferenceFromInitialOffset() {
8262
+ return getDifferenceFromInitialOffset(this.store.getState().dragOffset);
8263
+ }
8264
+ constructor(store, registry){
8265
+ this.store = store;
8266
+ this.registry = registry;
8267
+ }
8268
+ }
8269
+
8270
+ // Safari 6 and 6.1 for desktop, iPad, and iPhone are the only browsers that
8271
+ // have WebKitMutationObserver but not un-prefixed MutationObserver.
8272
+ // Must use `global` or `self` instead of `window` to work in both frames and web
8273
+ // workers. `global` is a provision of Browserify, Mr, Mrs, or Mop.
8274
+ /* globals self */ const scope = typeof global !== 'undefined' ? global : self;
8275
+ const BrowserMutationObserver = scope.MutationObserver || scope.WebKitMutationObserver;
8276
+ function makeRequestCallFromTimer(callback) {
8277
+ return function requestCall() {
8278
+ // We dispatch a timeout with a specified delay of 0 for engines that
8279
+ // can reliably accommodate that request. This will usually be snapped
8280
+ // to a 4 milisecond delay, but once we're flushing, there's no delay
8281
+ // between events.
8282
+ const timeoutHandle = setTimeout(handleTimer, 0);
8283
+ // However, since this timer gets frequently dropped in Firefox
8284
+ // workers, we enlist an interval handle that will try to fire
8285
+ // an event 20 times per second until it succeeds.
8286
+ const intervalHandle = setInterval(handleTimer, 50);
8287
+ function handleTimer() {
8288
+ // Whichever timer succeeds will cancel both timers and
8289
+ // execute the callback.
8290
+ clearTimeout(timeoutHandle);
8291
+ clearInterval(intervalHandle);
8292
+ callback();
8293
+ }
8294
+ };
8295
+ }
8296
+ // To request a high priority event, we induce a mutation observer by toggling
8297
+ // the text of a text node between "1" and "-1".
8298
+ function makeRequestCallFromMutationObserver(callback) {
8299
+ let toggle = 1;
8300
+ const observer = new BrowserMutationObserver(callback);
8301
+ const node = document.createTextNode('');
8302
+ observer.observe(node, {
8303
+ characterData: true
8304
+ });
8305
+ return function requestCall() {
8306
+ toggle = -toggle;
8307
+ node.data = toggle;
8308
+ };
8309
+ }
8310
+ const makeRequestCall = typeof BrowserMutationObserver === 'function' ? // reliably everywhere they are implemented.
8311
+ // They are implemented in all modern browsers.
8312
+ //
8313
+ // - Android 4-4.3
8314
+ // - Chrome 26-34
8315
+ // - Firefox 14-29
8316
+ // - Internet Explorer 11
8317
+ // - iPad Safari 6-7.1
8318
+ // - iPhone Safari 7-7.1
8319
+ // - Safari 6-7
8320
+ makeRequestCallFromMutationObserver : // task queue, are implemented in Internet Explorer 10, Safari 5.0-1, and Opera
8321
+ // 11-12, and in web workers in many engines.
8322
+ // Although message channels yield to any queued rendering and IO tasks, they
8323
+ // would be better than imposing the 4ms delay of timers.
8324
+ // However, they do not work reliably in Internet Explorer or Safari.
8325
+ // Internet Explorer 10 is the only browser that has setImmediate but does
8326
+ // not have MutationObservers.
8327
+ // Although setImmediate yields to the browser's renderer, it would be
8328
+ // preferrable to falling back to setTimeout since it does not have
8329
+ // the minimum 4ms penalty.
8330
+ // Unfortunately there appears to be a bug in Internet Explorer 10 Mobile (and
8331
+ // Desktop to a lesser extent) that renders both setImmediate and
8332
+ // MessageChannel useless for the purposes of ASAP.
8333
+ // https://github.com/kriskowal/q/issues/396
8334
+ // Timers are implemented universally.
8335
+ // We fall back to timers in workers in most engines, and in foreground
8336
+ // contexts in the following browsers.
8337
+ // However, note that even this simple case requires nuances to operate in a
8338
+ // broad spectrum of browsers.
8339
+ //
8340
+ // - Firefox 3-13
8341
+ // - Internet Explorer 6-9
8342
+ // - iPad Safari 4.3
8343
+ // - Lynx 2.8.7
8344
+ makeRequestCallFromTimer;
8345
+
8346
+ class AsapQueue {
8347
+ // Use the fastest means possible to execute a task in its own turn, with
8348
+ // priority over other events including IO, animation, reflow, and redraw
8349
+ // events in browsers.
8350
+ //
8351
+ // An exception thrown by a task will permanently interrupt the processing of
8352
+ // subsequent tasks. The higher level `asap` function ensures that if an
8353
+ // exception is thrown by a task, that the task queue will continue flushing as
8354
+ // soon as possible, but if you use `rawAsap` directly, you are responsible to
8355
+ // either ensure that no exceptions are thrown from your task, or to manually
8356
+ // call `rawAsap.requestFlush` if an exception is thrown.
8357
+ enqueueTask(task) {
8358
+ const { queue: q , requestFlush } = this;
8359
+ if (!q.length) {
8360
+ requestFlush();
8361
+ this.flushing = true;
8362
+ }
8363
+ // Equivalent to push, but avoids a function call.
8364
+ q[q.length] = task;
8365
+ }
8366
+ constructor(){
8367
+ this.queue = [];
8368
+ // We queue errors to ensure they are thrown in right order (FIFO).
8369
+ // Array-as-queue is good enough here, since we are just dealing with exceptions.
8370
+ this.pendingErrors = [];
8371
+ // Once a flush has been requested, no further calls to `requestFlush` are
8372
+ // necessary until the next `flush` completes.
8373
+ // @ts-ignore
8374
+ this.flushing = false;
8375
+ // The position of the next task to execute in the task queue. This is
8376
+ // preserved between calls to `flush` so that it can be resumed if
8377
+ // a task throws an exception.
8378
+ this.index = 0;
8379
+ // If a task schedules additional tasks recursively, the task queue can grow
8380
+ // unbounded. To prevent memory exhaustion, the task queue will periodically
8381
+ // truncate already-completed tasks.
8382
+ this.capacity = 1024;
8383
+ // The flush function processes all tasks that have been scheduled with
8384
+ // `rawAsap` unless and until one of those tasks throws an exception.
8385
+ // If a task throws an exception, `flush` ensures that its state will remain
8386
+ // consistent and will resume where it left off when called again.
8387
+ // However, `flush` does not make any arrangements to be called again if an
8388
+ // exception is thrown.
8389
+ this.flush = ()=>{
8390
+ const { queue: q } = this;
8391
+ while(this.index < q.length){
8392
+ const currentIndex = this.index;
8393
+ // Advance the index before calling the task. This ensures that we will
8394
+ // begin flushing on the next task the task throws an error.
8395
+ this.index++;
8396
+ q[currentIndex].call();
8397
+ // Prevent leaking memory for long chains of recursive calls to `asap`.
8398
+ // If we call `asap` within tasks scheduled by `asap`, the queue will
8399
+ // grow, but to avoid an O(n) walk for every task we execute, we don't
8400
+ // shift tasks off the queue after they have been executed.
8401
+ // Instead, we periodically shift 1024 tasks off the queue.
8402
+ if (this.index > this.capacity) {
8403
+ // Manually shift all values starting at the index back to the
8404
+ // beginning of the queue.
8405
+ for(let scan = 0, newLength = q.length - this.index; scan < newLength; scan++){
8406
+ q[scan] = q[scan + this.index];
8407
+ }
8408
+ q.length -= this.index;
8409
+ this.index = 0;
8410
+ }
8411
+ }
8412
+ q.length = 0;
8413
+ this.index = 0;
8414
+ this.flushing = false;
8415
+ };
8416
+ // In a web browser, exceptions are not fatal. However, to avoid
8417
+ // slowing down the queue of pending tasks, we rethrow the error in a
8418
+ // lower priority turn.
8419
+ this.registerPendingError = (err)=>{
8420
+ this.pendingErrors.push(err);
8421
+ this.requestErrorThrow();
8422
+ };
8423
+ // `requestFlush` requests that the high priority event queue be flushed as
8424
+ // soon as possible.
8425
+ // This is useful to prevent an error thrown in a task from stalling the event
8426
+ // queue if the exception handled by Node.js’s
8427
+ // `process.on("uncaughtException")` or by a domain.
8428
+ // `requestFlush` is implemented using a strategy based on data collected from
8429
+ // every available SauceLabs Selenium web driver worker at time of writing.
8430
+ // https://docs.google.com/spreadsheets/d/1mG-5UYGup5qxGdEMWkhP6BWCz053NUb2E1QoUTU16uA/edit#gid=783724593
8431
+ this.requestFlush = makeRequestCall(this.flush);
8432
+ this.requestErrorThrow = makeRequestCallFromTimer(()=>{
8433
+ // Throw first error
8434
+ if (this.pendingErrors.length) {
8435
+ throw this.pendingErrors.shift();
8436
+ }
8437
+ });
8438
+ }
8439
+ } // The message channel technique was discovered by Malte Ubl and was the
8440
+ // original foundation for this library.
8441
+ // http://www.nonblocking.io/2011/06/windownexttick.html
8442
+ // Safari 6.0.5 (at least) intermittently fails to create message ports on a
8443
+ // page's first load. Thankfully, this version of Safari supports
8444
+ // MutationObservers, so we don't need to fall back in that case.
8445
+ // function makeRequestCallFromMessageChannel(callback) {
8446
+ // var channel = new MessageChannel();
8447
+ // channel.port1.onmessage = callback;
8448
+ // return function requestCall() {
8449
+ // channel.port2.postMessage(0);
8450
+ // };
8451
+ // }
8452
+ // For reasons explained above, we are also unable to use `setImmediate`
8453
+ // under any circumstances.
8454
+ // Even if we were, there is another bug in Internet Explorer 10.
8455
+ // It is not sufficient to assign `setImmediate` to `requestFlush` because
8456
+ // `setImmediate` must be called *by name* and therefore must be wrapped in a
8457
+ // closure.
8458
+ // Never forget.
8459
+ // function makeRequestCallFromSetImmediate(callback) {
8460
+ // return function requestCall() {
8461
+ // setImmediate(callback);
8462
+ // };
8463
+ // }
8464
+ // Safari 6.0 has a problem where timers will get lost while the user is
8465
+ // scrolling. This problem does not impact ASAP because Safari 6.0 supports
8466
+ // mutation observers, so that implementation is used instead.
8467
+ // However, if we ever elect to use timers in Safari, the prevalent work-around
8468
+ // is to add a scroll event listener that calls for a flush.
8469
+ // `setTimeout` does not call the passed callback if the delay is less than
8470
+ // approximately 7 in web workers in Firefox 8 through 18, and sometimes not
8471
+ // even then.
8472
+ // This is for `asap.js` only.
8473
+ // Its name will be periodically randomized to break any code that depends on
8474
+ // // its existence.
8475
+ // rawAsap.makeRequestCallFromTimer = makeRequestCallFromTimer
8476
+ // ASAP was originally a nextTick shim included in Q. This was factored out
8477
+ // into this ASAP package. It was later adapted to RSVP which made further
8478
+ // amendments. These decisions, particularly to marginalize MessageChannel and
8479
+ // to capture the MutationObserver implementation in a closure, were integrated
8480
+ // back into ASAP proper.
8481
+ // https://github.com/tildeio/rsvp.js/blob/cddf7232546a9cf858524b75cde6f9edf72620a7/lib/rsvp/asap.js
8482
+
8483
+ // `call`, just like a function.
8484
+ class RawTask {
8485
+ call() {
8486
+ try {
8487
+ this.task && this.task();
8488
+ } catch (error) {
8489
+ this.onError(error);
8490
+ } finally{
8491
+ this.task = null;
8492
+ this.release(this);
8493
+ }
8494
+ }
8495
+ constructor(onError, release){
8496
+ this.onError = onError;
8497
+ this.release = release;
8498
+ this.task = null;
8499
+ }
8500
+ }
7586
8501
 
7587
- if (!_options || !_options.backends || _options.backends.length < 1) {
7588
- throw new Error("You must specify at least one Backend, if you are coming from 2.x.x (or don't understand this error)\n see this guide: https://github.com/louisbrunner/dnd-multi-backend/tree/master/packages/react-dnd-multi-backend#migrating-from-2xx");
7589
- }
8502
+ class TaskFactory {
8503
+ create(task) {
8504
+ const tasks = this.freeTasks;
8505
+ const t1 = tasks.length ? tasks.pop() : new RawTask(this.onError, (t)=>tasks[tasks.length] = t
8506
+ );
8507
+ t1.task = task;
8508
+ return t1;
8509
+ }
8510
+ constructor(onError){
8511
+ this.onError = onError;
8512
+ this.freeTasks = [];
8513
+ }
8514
+ }
7590
8515
 
7591
- _classPrivateFieldSet(this, _previews, new PreviewListImpl());
8516
+ const asapQueue = new AsapQueue();
8517
+ const taskFactory = new TaskFactory(asapQueue.registerPendingError);
8518
+ /**
8519
+ * Calls a task as soon as possible after returning, in its own event, with priority
8520
+ * over other events like animation, reflow, and repaint. An error thrown from an
8521
+ * event will not interrupt, nor even substantially slow down the processing of
8522
+ * other events, but will be rather postponed to a lower priority event.
8523
+ * @param {{call}} task A callable object, typically a function that takes no
8524
+ * arguments.
8525
+ */ function asap(task) {
8526
+ asapQueue.enqueueTask(taskFactory.create(task));
8527
+ }
8528
+
8529
+ const ADD_SOURCE = 'dnd-core/ADD_SOURCE';
8530
+ const ADD_TARGET = 'dnd-core/ADD_TARGET';
8531
+ const REMOVE_SOURCE = 'dnd-core/REMOVE_SOURCE';
8532
+ const REMOVE_TARGET = 'dnd-core/REMOVE_TARGET';
8533
+ function addSource(sourceId) {
8534
+ return {
8535
+ type: ADD_SOURCE,
8536
+ payload: {
8537
+ sourceId
8538
+ }
8539
+ };
8540
+ }
8541
+ function addTarget(targetId) {
8542
+ return {
8543
+ type: ADD_TARGET,
8544
+ payload: {
8545
+ targetId
8546
+ }
8547
+ };
8548
+ }
8549
+ function removeSource(sourceId) {
8550
+ return {
8551
+ type: REMOVE_SOURCE,
8552
+ payload: {
8553
+ sourceId
8554
+ }
8555
+ };
8556
+ }
8557
+ function removeTarget(targetId) {
8558
+ return {
8559
+ type: REMOVE_TARGET,
8560
+ payload: {
8561
+ targetId
8562
+ }
8563
+ };
8564
+ }
7592
8565
 
7593
- _classPrivateFieldSet(this, _backends, {});
8566
+ function validateSourceContract(source) {
8567
+ invariant(typeof source.canDrag === 'function', 'Expected canDrag to be a function.');
8568
+ invariant(typeof source.beginDrag === 'function', 'Expected beginDrag to be a function.');
8569
+ invariant(typeof source.endDrag === 'function', 'Expected endDrag to be a function.');
8570
+ }
8571
+ function validateTargetContract(target) {
8572
+ invariant(typeof target.canDrop === 'function', 'Expected canDrop to be a function.');
8573
+ invariant(typeof target.hover === 'function', 'Expected hover to be a function.');
8574
+ invariant(typeof target.drop === 'function', 'Expected beginDrag to be a function.');
8575
+ }
8576
+ function validateType(type, allowArray) {
8577
+ if (allowArray && Array.isArray(type)) {
8578
+ type.forEach((t)=>validateType(t, false)
8579
+ );
8580
+ return;
8581
+ }
8582
+ invariant(typeof type === 'string' || typeof type === 'symbol', allowArray ? 'Type can only be a string, a symbol, or an array of either.' : 'Type can only be a string or a symbol.');
8583
+ }
7594
8584
 
7595
- _classPrivateFieldSet(this, _backendsList, []);
8585
+ var HandlerRole;
8586
+ (function(HandlerRole) {
8587
+ HandlerRole["SOURCE"] = "SOURCE";
8588
+ HandlerRole["TARGET"] = "TARGET";
8589
+ })(HandlerRole || (HandlerRole = {}));
7596
8590
 
7597
- _options.backends.forEach(function (backend) {
7598
- var backendRecord = _classPrivateFieldGet(_this, _createBackend).call(_this, _manager, _context, backend);
8591
+ let nextUniqueId = 0;
8592
+ function getNextUniqueId() {
8593
+ return nextUniqueId++;
8594
+ }
7599
8595
 
7600
- _classPrivateFieldGet(_this, _backends)[backendRecord.id] = backendRecord;
8596
+ function getNextHandlerId(role) {
8597
+ const id = getNextUniqueId().toString();
8598
+ switch(role){
8599
+ case HandlerRole.SOURCE:
8600
+ return `S${id}`;
8601
+ case HandlerRole.TARGET:
8602
+ return `T${id}`;
8603
+ default:
8604
+ throw new Error(`Unknown Handler Role: ${role}`);
8605
+ }
8606
+ }
8607
+ function parseRoleFromHandlerId(handlerId) {
8608
+ switch(handlerId[0]){
8609
+ case 'S':
8610
+ return HandlerRole.SOURCE;
8611
+ case 'T':
8612
+ return HandlerRole.TARGET;
8613
+ default:
8614
+ throw new Error(`Cannot parse handler ID: ${handlerId}`);
8615
+ }
8616
+ }
8617
+ function mapContainsValue(map, searchValue) {
8618
+ const entries = map.entries();
8619
+ let isDone = false;
8620
+ do {
8621
+ const { done , value: [, value] , } = entries.next();
8622
+ if (value === searchValue) {
8623
+ return true;
8624
+ }
8625
+ isDone = !!done;
8626
+ }while (!isDone)
8627
+ return false;
8628
+ }
8629
+ class HandlerRegistryImpl {
8630
+ addSource(type, source) {
8631
+ validateType(type);
8632
+ validateSourceContract(source);
8633
+ const sourceId = this.addHandler(HandlerRole.SOURCE, type, source);
8634
+ this.store.dispatch(addSource(sourceId));
8635
+ return sourceId;
8636
+ }
8637
+ addTarget(type, target) {
8638
+ validateType(type, true);
8639
+ validateTargetContract(target);
8640
+ const targetId = this.addHandler(HandlerRole.TARGET, type, target);
8641
+ this.store.dispatch(addTarget(targetId));
8642
+ return targetId;
8643
+ }
8644
+ containsHandler(handler) {
8645
+ return mapContainsValue(this.dragSources, handler) || mapContainsValue(this.dropTargets, handler);
8646
+ }
8647
+ getSource(sourceId, includePinned = false) {
8648
+ invariant(this.isSourceId(sourceId), 'Expected a valid source ID.');
8649
+ const isPinned = includePinned && sourceId === this.pinnedSourceId;
8650
+ const source = isPinned ? this.pinnedSource : this.dragSources.get(sourceId);
8651
+ return source;
8652
+ }
8653
+ getTarget(targetId) {
8654
+ invariant(this.isTargetId(targetId), 'Expected a valid target ID.');
8655
+ return this.dropTargets.get(targetId);
8656
+ }
8657
+ getSourceType(sourceId) {
8658
+ invariant(this.isSourceId(sourceId), 'Expected a valid source ID.');
8659
+ return this.types.get(sourceId);
8660
+ }
8661
+ getTargetType(targetId) {
8662
+ invariant(this.isTargetId(targetId), 'Expected a valid target ID.');
8663
+ return this.types.get(targetId);
8664
+ }
8665
+ isSourceId(handlerId) {
8666
+ const role = parseRoleFromHandlerId(handlerId);
8667
+ return role === HandlerRole.SOURCE;
8668
+ }
8669
+ isTargetId(handlerId) {
8670
+ const role = parseRoleFromHandlerId(handlerId);
8671
+ return role === HandlerRole.TARGET;
8672
+ }
8673
+ removeSource(sourceId) {
8674
+ invariant(this.getSource(sourceId), 'Expected an existing source.');
8675
+ this.store.dispatch(removeSource(sourceId));
8676
+ asap(()=>{
8677
+ this.dragSources.delete(sourceId);
8678
+ this.types.delete(sourceId);
8679
+ });
8680
+ }
8681
+ removeTarget(targetId) {
8682
+ invariant(this.getTarget(targetId), 'Expected an existing target.');
8683
+ this.store.dispatch(removeTarget(targetId));
8684
+ this.dropTargets.delete(targetId);
8685
+ this.types.delete(targetId);
8686
+ }
8687
+ pinSource(sourceId) {
8688
+ const source = this.getSource(sourceId);
8689
+ invariant(source, 'Expected an existing source.');
8690
+ this.pinnedSourceId = sourceId;
8691
+ this.pinnedSource = source;
8692
+ }
8693
+ unpinSource() {
8694
+ invariant(this.pinnedSource, 'No source is pinned at the time.');
8695
+ this.pinnedSourceId = null;
8696
+ this.pinnedSource = null;
8697
+ }
8698
+ addHandler(role, type, handler) {
8699
+ const id = getNextHandlerId(role);
8700
+ this.types.set(id, type);
8701
+ if (role === HandlerRole.SOURCE) {
8702
+ this.dragSources.set(id, handler);
8703
+ } else if (role === HandlerRole.TARGET) {
8704
+ this.dropTargets.set(id, handler);
8705
+ }
8706
+ return id;
8707
+ }
8708
+ constructor(store){
8709
+ this.types = new Map();
8710
+ this.dragSources = new Map();
8711
+ this.dropTargets = new Map();
8712
+ this.pinnedSourceId = null;
8713
+ this.pinnedSource = null;
8714
+ this.store = store;
8715
+ }
8716
+ }
7601
8717
 
7602
- _classPrivateFieldGet(_this, _backendsList).push(backendRecord);
7603
- });
8718
+ const strictEquality = (a, b)=>a === b
8719
+ ;
8720
+ /**
8721
+ * Determine if two cartesian coordinate offsets are equal
8722
+ * @param offsetA
8723
+ * @param offsetB
8724
+ */ function areCoordsEqual(offsetA, offsetB) {
8725
+ if (!offsetA && !offsetB) {
8726
+ return true;
8727
+ } else if (!offsetA || !offsetB) {
8728
+ return false;
8729
+ } else {
8730
+ return offsetA.x === offsetB.x && offsetA.y === offsetB.y;
8731
+ }
8732
+ }
8733
+ /**
8734
+ * Determines if two arrays of items are equal
8735
+ * @param a The first array of items
8736
+ * @param b The second array of items
8737
+ */ function areArraysEqual(a, b, isEqual = strictEquality) {
8738
+ if (a.length !== b.length) {
8739
+ return false;
8740
+ }
8741
+ for(let i = 0; i < a.length; ++i){
8742
+ if (!isEqual(a[i], b[i])) {
8743
+ return false;
8744
+ }
8745
+ }
8746
+ return true;
8747
+ }
7604
8748
 
7605
- _classPrivateFieldSet(this, _current, _classPrivateFieldGet(this, _backendsList)[0].id);
8749
+ function reduce$5(// eslint-disable-next-line @typescript-eslint/no-unused-vars
8750
+ _state = NONE, action) {
8751
+ switch(action.type){
8752
+ case HOVER:
8753
+ break;
8754
+ case ADD_SOURCE:
8755
+ case ADD_TARGET:
8756
+ case REMOVE_TARGET:
8757
+ case REMOVE_SOURCE:
8758
+ return NONE;
8759
+ case BEGIN_DRAG:
8760
+ case PUBLISH_DRAG_SOURCE:
8761
+ case END_DRAG:
8762
+ case DROP:
8763
+ default:
8764
+ return ALL;
8765
+ }
8766
+ const { targetIds =[] , prevTargetIds =[] } = action.payload;
8767
+ const result = xor(targetIds, prevTargetIds);
8768
+ const didChange = result.length > 0 || !areArraysEqual(targetIds, prevTargetIds);
8769
+ if (!didChange) {
8770
+ return NONE;
8771
+ }
8772
+ // Check the target ids at the innermost position. If they are valid, add them
8773
+ // to the result
8774
+ const prevInnermostTargetId = prevTargetIds[prevTargetIds.length - 1];
8775
+ const innermostTargetId = targetIds[targetIds.length - 1];
8776
+ if (prevInnermostTargetId !== innermostTargetId) {
8777
+ if (prevInnermostTargetId) {
8778
+ result.push(prevInnermostTargetId);
8779
+ }
8780
+ if (innermostTargetId) {
8781
+ result.push(innermostTargetId);
8782
+ }
8783
+ }
8784
+ return result;
8785
+ }
7606
8786
 
7607
- _classPrivateFieldSet(this, _nodes, {});
8787
+ function _defineProperty$5(obj, key, value) {
8788
+ if (key in obj) {
8789
+ Object.defineProperty(obj, key, {
8790
+ value: value,
8791
+ enumerable: true,
8792
+ configurable: true,
8793
+ writable: true
8794
+ });
8795
+ } else {
8796
+ obj[key] = value;
8797
+ }
8798
+ return obj;
8799
+ }
8800
+ function _objectSpread$3(target) {
8801
+ for(var i = 1; i < arguments.length; i++){
8802
+ var source = arguments[i] != null ? arguments[i] : {};
8803
+ var ownKeys = Object.keys(source);
8804
+ if (typeof Object.getOwnPropertySymbols === 'function') {
8805
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
8806
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
8807
+ }));
8808
+ }
8809
+ ownKeys.forEach(function(key) {
8810
+ _defineProperty$5(target, key, source[key]);
8811
+ });
8812
+ }
8813
+ return target;
8814
+ }
8815
+ const initialState$3 = {
8816
+ initialSourceClientOffset: null,
8817
+ initialClientOffset: null,
8818
+ clientOffset: null
7608
8819
  };
7609
-
7610
- _defineProperty(MultiBackendImpl, "isSetUp", false);
7611
-
7612
- /**
7613
- * Use invariant() to assert state which your program assumes to be true.
7614
- *
7615
- * Provide sprintf-style format (only %s is supported) and arguments
7616
- * to provide information about what broke and what you were
7617
- * expecting.
7618
- *
7619
- * The invariant message will be stripped in production, but the invariant
7620
- * will remain to ensure logic does not differ in production.
7621
- */ function invariant(condition, format, ...args) {
7622
- if (isProduction()) {
7623
- if (format === undefined) {
7624
- throw new Error('invariant requires an error message argument');
8820
+ function reduce$4(state = initialState$3, action) {
8821
+ const { payload } = action;
8822
+ switch(action.type){
8823
+ case INIT_COORDS:
8824
+ case BEGIN_DRAG:
8825
+ return {
8826
+ initialSourceClientOffset: payload.sourceClientOffset,
8827
+ initialClientOffset: payload.clientOffset,
8828
+ clientOffset: payload.clientOffset
8829
+ };
8830
+ case HOVER:
8831
+ if (areCoordsEqual(state.clientOffset, payload.clientOffset)) {
8832
+ return state;
8833
+ }
8834
+ return _objectSpread$3({}, state, {
8835
+ clientOffset: payload.clientOffset
8836
+ });
8837
+ case END_DRAG:
8838
+ case DROP:
8839
+ return initialState$3;
8840
+ default:
8841
+ return state;
8842
+ }
8843
+ }
8844
+
8845
+ function _defineProperty$4(obj, key, value) {
8846
+ if (key in obj) {
8847
+ Object.defineProperty(obj, key, {
8848
+ value: value,
8849
+ enumerable: true,
8850
+ configurable: true,
8851
+ writable: true
8852
+ });
8853
+ } else {
8854
+ obj[key] = value;
8855
+ }
8856
+ return obj;
8857
+ }
8858
+ function _objectSpread$2(target) {
8859
+ for(var i = 1; i < arguments.length; i++){
8860
+ var source = arguments[i] != null ? arguments[i] : {};
8861
+ var ownKeys = Object.keys(source);
8862
+ if (typeof Object.getOwnPropertySymbols === 'function') {
8863
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
8864
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
8865
+ }));
7625
8866
  }
8867
+ ownKeys.forEach(function(key) {
8868
+ _defineProperty$4(target, key, source[key]);
8869
+ });
7626
8870
  }
7627
- if (!condition) {
7628
- let error;
7629
- if (format === undefined) {
7630
- error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
7631
- } else {
7632
- let argIndex = 0;
7633
- error = new Error(format.replace(/%s/g, function() {
7634
- return args[argIndex++];
8871
+ return target;
8872
+ }
8873
+ const initialState$2 = {
8874
+ itemType: null,
8875
+ item: null,
8876
+ sourceId: null,
8877
+ targetIds: [],
8878
+ dropResult: null,
8879
+ didDrop: false,
8880
+ isSourcePublic: null
8881
+ };
8882
+ function reduce$3(state = initialState$2, action) {
8883
+ const { payload } = action;
8884
+ switch(action.type){
8885
+ case BEGIN_DRAG:
8886
+ return _objectSpread$2({}, state, {
8887
+ itemType: payload.itemType,
8888
+ item: payload.item,
8889
+ sourceId: payload.sourceId,
8890
+ isSourcePublic: payload.isSourcePublic,
8891
+ dropResult: null,
8892
+ didDrop: false
8893
+ });
8894
+ case PUBLISH_DRAG_SOURCE:
8895
+ return _objectSpread$2({}, state, {
8896
+ isSourcePublic: true
8897
+ });
8898
+ case HOVER:
8899
+ return _objectSpread$2({}, state, {
8900
+ targetIds: payload.targetIds
8901
+ });
8902
+ case REMOVE_TARGET:
8903
+ if (state.targetIds.indexOf(payload.targetId) === -1) {
8904
+ return state;
8905
+ }
8906
+ return _objectSpread$2({}, state, {
8907
+ targetIds: without$1(state.targetIds, payload.targetId)
8908
+ });
8909
+ case DROP:
8910
+ return _objectSpread$2({}, state, {
8911
+ dropResult: payload.dropResult,
8912
+ didDrop: true,
8913
+ targetIds: []
8914
+ });
8915
+ case END_DRAG:
8916
+ return _objectSpread$2({}, state, {
8917
+ itemType: null,
8918
+ item: null,
8919
+ sourceId: null,
8920
+ dropResult: null,
8921
+ didDrop: false,
8922
+ isSourcePublic: null,
8923
+ targetIds: []
8924
+ });
8925
+ default:
8926
+ return state;
8927
+ }
8928
+ }
8929
+
8930
+ function reduce$2(state = 0, action) {
8931
+ switch(action.type){
8932
+ case ADD_SOURCE:
8933
+ case ADD_TARGET:
8934
+ return state + 1;
8935
+ case REMOVE_SOURCE:
8936
+ case REMOVE_TARGET:
8937
+ return state - 1;
8938
+ default:
8939
+ return state;
8940
+ }
8941
+ }
8942
+
8943
+ function reduce$1(state = 0) {
8944
+ return state + 1;
8945
+ }
8946
+
8947
+ function _defineProperty$3(obj, key, value) {
8948
+ if (key in obj) {
8949
+ Object.defineProperty(obj, key, {
8950
+ value: value,
8951
+ enumerable: true,
8952
+ configurable: true,
8953
+ writable: true
8954
+ });
8955
+ } else {
8956
+ obj[key] = value;
8957
+ }
8958
+ return obj;
8959
+ }
8960
+ function _objectSpread$1(target) {
8961
+ for(var i = 1; i < arguments.length; i++){
8962
+ var source = arguments[i] != null ? arguments[i] : {};
8963
+ var ownKeys = Object.keys(source);
8964
+ if (typeof Object.getOwnPropertySymbols === 'function') {
8965
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
8966
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
7635
8967
  }));
7636
- error.name = 'Invariant Violation';
7637
8968
  }
7638
- error.framesToPop = 1 // we don't care about invariant's own frame
7639
- ;
7640
- throw error;
8969
+ ownKeys.forEach(function(key) {
8970
+ _defineProperty$3(target, key, source[key]);
8971
+ });
7641
8972
  }
8973
+ return target;
7642
8974
  }
7643
- function isProduction() {
7644
- return typeof process !== 'undefined' && process.env['NODE_ENV'] === 'production';
8975
+ function reduce(state = {}, action) {
8976
+ return {
8977
+ dirtyHandlerIds: reduce$5(state.dirtyHandlerIds, {
8978
+ type: action.type,
8979
+ payload: _objectSpread$1({}, action.payload, {
8980
+ prevTargetIds: get(state, 'dragOperation.targetIds', [])
8981
+ })
8982
+ }),
8983
+ dragOffset: reduce$4(state.dragOffset, action),
8984
+ refCount: reduce$2(state.refCount, action),
8985
+ dragOperation: reduce$3(state.dragOperation, action),
8986
+ stateId: reduce$1(state.stateId)
8987
+ };
7645
8988
  }
7646
8989
 
7647
- /**
7648
- * Create the React Context
7649
- */ const DndContext = React.createContext({
7650
- dragDropManager: undefined
8990
+ function createDragDropManager(backendFactory, globalContext = undefined, backendOptions = {}, debugMode = false) {
8991
+ const store = makeStoreInstance(debugMode);
8992
+ const monitor = new DragDropMonitorImpl(store, new HandlerRegistryImpl(store));
8993
+ const manager = new DragDropManagerImpl(store, monitor);
8994
+ const backend = backendFactory(manager, globalContext, backendOptions);
8995
+ manager.receiveBackend(backend);
8996
+ return manager;
8997
+ }
8998
+ function makeStoreInstance(debugMode) {
8999
+ // TODO: if we ever make a react-native version of this,
9000
+ // we'll need to consider how to pull off dev-tooling
9001
+ const reduxDevTools = typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__;
9002
+ return createStore(reduce, debugMode && reduxDevTools && reduxDevTools({
9003
+ name: 'dnd-core',
9004
+ instanceId: 'dnd-core'
9005
+ }));
9006
+ }
9007
+
9008
+ function _objectWithoutProperties(source, excluded) {
9009
+ if (source == null) return {};
9010
+ var target = _objectWithoutPropertiesLoose(source, excluded);
9011
+ var key, i;
9012
+ if (Object.getOwnPropertySymbols) {
9013
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
9014
+ for(i = 0; i < sourceSymbolKeys.length; i++){
9015
+ key = sourceSymbolKeys[i];
9016
+ if (excluded.indexOf(key) >= 0) continue;
9017
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
9018
+ target[key] = source[key];
9019
+ }
9020
+ }
9021
+ return target;
9022
+ }
9023
+ function _objectWithoutPropertiesLoose(source, excluded) {
9024
+ if (source == null) return {};
9025
+ var target = {};
9026
+ var sourceKeys = Object.keys(source);
9027
+ var key, i;
9028
+ for(i = 0; i < sourceKeys.length; i++){
9029
+ key = sourceKeys[i];
9030
+ if (excluded.indexOf(key) >= 0) continue;
9031
+ target[key] = source[key];
9032
+ }
9033
+ return target;
9034
+ }
9035
+ let refCount = 0;
9036
+ const INSTANCE_SYM = Symbol.for('__REACT_DND_CONTEXT_INSTANCE__');
9037
+ var DndProvider = /*#__PURE__*/ React.memo(function DndProvider(_param) {
9038
+ var { children } = _param, props = _objectWithoutProperties(_param, [
9039
+ "children"
9040
+ ]);
9041
+ const [manager, isGlobalInstance] = getDndContextValue(props) // memoized from props
9042
+ ;
9043
+ /**
9044
+ * If the global context was used to store the DND context
9045
+ * then where theres no more references to it we should
9046
+ * clean it up to avoid memory leaks
9047
+ */ React.useEffect(()=>{
9048
+ if (isGlobalInstance) {
9049
+ const context = getGlobalContext();
9050
+ ++refCount;
9051
+ return ()=>{
9052
+ if (--refCount === 0) {
9053
+ context[INSTANCE_SYM] = null;
9054
+ }
9055
+ };
9056
+ }
9057
+ return;
9058
+ }, []);
9059
+ return /*#__PURE__*/ jsxRuntime.jsx(DndContext.Provider, {
9060
+ value: manager,
9061
+ children: children
9062
+ });
7651
9063
  });
9064
+ function getDndContextValue(props) {
9065
+ if ('manager' in props) {
9066
+ const manager = {
9067
+ dragDropManager: props.manager
9068
+ };
9069
+ return [
9070
+ manager,
9071
+ false
9072
+ ];
9073
+ }
9074
+ const manager = createSingletonDndContext(props.backend, props.context, props.options, props.debugMode);
9075
+ const isGlobalInstance = !props.context;
9076
+ return [
9077
+ manager,
9078
+ isGlobalInstance
9079
+ ];
9080
+ }
9081
+ function createSingletonDndContext(backend, context = getGlobalContext(), options, debugMode) {
9082
+ const ctx = context;
9083
+ if (!ctx[INSTANCE_SYM]) {
9084
+ ctx[INSTANCE_SYM] = {
9085
+ dragDropManager: createDragDropManager(backend, context, options, debugMode)
9086
+ };
9087
+ }
9088
+ return ctx[INSTANCE_SYM];
9089
+ }
9090
+ function getGlobalContext() {
9091
+ return typeof global !== 'undefined' ? global : window;
9092
+ }
7652
9093
 
7653
9094
  // do not edit .js files directly - edit src/index.jst
7654
9095
 
@@ -8586,6 +10027,1368 @@ function useRegisteredDropTarget(spec, monitor, connector) {
8586
10027
  ];
8587
10028
  }
8588
10029
 
10030
+ // cheap lodash replacements
10031
+ function memoize(fn) {
10032
+ let result = null;
10033
+ const memoized = ()=>{
10034
+ if (result == null) {
10035
+ result = fn();
10036
+ }
10037
+ return result;
10038
+ };
10039
+ return memoized;
10040
+ }
10041
+ /**
10042
+ * drop-in replacement for _.without
10043
+ */ function without(items, item) {
10044
+ return items.filter((i)=>i !== item
10045
+ );
10046
+ }
10047
+ function union(itemsA, itemsB) {
10048
+ const set = new Set();
10049
+ const insertItem = (item)=>set.add(item)
10050
+ ;
10051
+ itemsA.forEach(insertItem);
10052
+ itemsB.forEach(insertItem);
10053
+ const result = [];
10054
+ set.forEach((key)=>result.push(key)
10055
+ );
10056
+ return result;
10057
+ }
10058
+
10059
+ class EnterLeaveCounter {
10060
+ enter(enteringNode) {
10061
+ const previousLength = this.entered.length;
10062
+ const isNodeEntered = (node)=>this.isNodeInDocument(node) && (!node.contains || node.contains(enteringNode))
10063
+ ;
10064
+ this.entered = union(this.entered.filter(isNodeEntered), [
10065
+ enteringNode
10066
+ ]);
10067
+ return previousLength === 0 && this.entered.length > 0;
10068
+ }
10069
+ leave(leavingNode) {
10070
+ const previousLength = this.entered.length;
10071
+ this.entered = without(this.entered.filter(this.isNodeInDocument), leavingNode);
10072
+ return previousLength > 0 && this.entered.length === 0;
10073
+ }
10074
+ reset() {
10075
+ this.entered = [];
10076
+ }
10077
+ constructor(isNodeInDocument){
10078
+ this.entered = [];
10079
+ this.isNodeInDocument = isNodeInDocument;
10080
+ }
10081
+ }
10082
+
10083
+ class NativeDragSource {
10084
+ initializeExposedProperties() {
10085
+ Object.keys(this.config.exposeProperties).forEach((property)=>{
10086
+ Object.defineProperty(this.item, property, {
10087
+ configurable: true,
10088
+ enumerable: true,
10089
+ get () {
10090
+ // eslint-disable-next-line no-console
10091
+ console.warn(`Browser doesn't allow reading "${property}" until the drop event.`);
10092
+ return null;
10093
+ }
10094
+ });
10095
+ });
10096
+ }
10097
+ loadDataTransfer(dataTransfer) {
10098
+ if (dataTransfer) {
10099
+ const newProperties = {};
10100
+ Object.keys(this.config.exposeProperties).forEach((property)=>{
10101
+ const propertyFn = this.config.exposeProperties[property];
10102
+ if (propertyFn != null) {
10103
+ newProperties[property] = {
10104
+ value: propertyFn(dataTransfer, this.config.matchesTypes),
10105
+ configurable: true,
10106
+ enumerable: true
10107
+ };
10108
+ }
10109
+ });
10110
+ Object.defineProperties(this.item, newProperties);
10111
+ }
10112
+ }
10113
+ canDrag() {
10114
+ return true;
10115
+ }
10116
+ beginDrag() {
10117
+ return this.item;
10118
+ }
10119
+ isDragging(monitor, handle) {
10120
+ return handle === monitor.getSourceId();
10121
+ }
10122
+ endDrag() {
10123
+ // empty
10124
+ }
10125
+ constructor(config){
10126
+ this.config = config;
10127
+ this.item = {};
10128
+ this.initializeExposedProperties();
10129
+ }
10130
+ }
10131
+
10132
+ const FILE = '__NATIVE_FILE__';
10133
+ const URL = '__NATIVE_URL__';
10134
+ const TEXT = '__NATIVE_TEXT__';
10135
+ const HTML = '__NATIVE_HTML__';
10136
+
10137
+ var NativeTypes = /*#__PURE__*/Object.freeze({
10138
+ __proto__: null,
10139
+ FILE: FILE,
10140
+ URL: URL,
10141
+ TEXT: TEXT,
10142
+ HTML: HTML
10143
+ });
10144
+
10145
+ function getDataFromDataTransfer(dataTransfer, typesToTry, defaultValue) {
10146
+ const result = typesToTry.reduce((resultSoFar, typeToTry)=>resultSoFar || dataTransfer.getData(typeToTry)
10147
+ , '');
10148
+ return result != null ? result : defaultValue;
10149
+ }
10150
+
10151
+ const nativeTypesConfig = {
10152
+ [FILE]: {
10153
+ exposeProperties: {
10154
+ files: (dataTransfer)=>Array.prototype.slice.call(dataTransfer.files)
10155
+ ,
10156
+ items: (dataTransfer)=>dataTransfer.items
10157
+ ,
10158
+ dataTransfer: (dataTransfer)=>dataTransfer
10159
+ },
10160
+ matchesTypes: [
10161
+ 'Files'
10162
+ ]
10163
+ },
10164
+ [HTML]: {
10165
+ exposeProperties: {
10166
+ html: (dataTransfer, matchesTypes)=>getDataFromDataTransfer(dataTransfer, matchesTypes, '')
10167
+ ,
10168
+ dataTransfer: (dataTransfer)=>dataTransfer
10169
+ },
10170
+ matchesTypes: [
10171
+ 'Html',
10172
+ 'text/html'
10173
+ ]
10174
+ },
10175
+ [URL]: {
10176
+ exposeProperties: {
10177
+ urls: (dataTransfer, matchesTypes)=>getDataFromDataTransfer(dataTransfer, matchesTypes, '').split('\n')
10178
+ ,
10179
+ dataTransfer: (dataTransfer)=>dataTransfer
10180
+ },
10181
+ matchesTypes: [
10182
+ 'Url',
10183
+ 'text/uri-list'
10184
+ ]
10185
+ },
10186
+ [TEXT]: {
10187
+ exposeProperties: {
10188
+ text: (dataTransfer, matchesTypes)=>getDataFromDataTransfer(dataTransfer, matchesTypes, '')
10189
+ ,
10190
+ dataTransfer: (dataTransfer)=>dataTransfer
10191
+ },
10192
+ matchesTypes: [
10193
+ 'Text',
10194
+ 'text/plain'
10195
+ ]
10196
+ }
10197
+ };
10198
+
10199
+ function createNativeDragSource(type, dataTransfer) {
10200
+ const config = nativeTypesConfig[type];
10201
+ if (!config) {
10202
+ throw new Error(`native type ${type} has no configuration`);
10203
+ }
10204
+ const result = new NativeDragSource(config);
10205
+ result.loadDataTransfer(dataTransfer);
10206
+ return result;
10207
+ }
10208
+ function matchNativeItemType(dataTransfer) {
10209
+ if (!dataTransfer) {
10210
+ return null;
10211
+ }
10212
+ const dataTransferTypes = Array.prototype.slice.call(dataTransfer.types || []);
10213
+ return Object.keys(nativeTypesConfig).filter((nativeItemType)=>{
10214
+ const typeConfig = nativeTypesConfig[nativeItemType];
10215
+ if (!(typeConfig === null || typeConfig === void 0 ? void 0 : typeConfig.matchesTypes)) {
10216
+ return false;
10217
+ }
10218
+ return typeConfig.matchesTypes.some((t)=>dataTransferTypes.indexOf(t) > -1
10219
+ );
10220
+ })[0] || null;
10221
+ }
10222
+
10223
+ const isFirefox = memoize(()=>/firefox/i.test(navigator.userAgent)
10224
+ );
10225
+ const isSafari = memoize(()=>Boolean(window.safari)
10226
+ );
10227
+
10228
+ class MonotonicInterpolant {
10229
+ interpolate(x) {
10230
+ const { xs , ys , c1s , c2s , c3s } = this;
10231
+ // The rightmost point in the dataset should give an exact result
10232
+ let i = xs.length - 1;
10233
+ if (x === xs[i]) {
10234
+ return ys[i];
10235
+ }
10236
+ // Search for the interval x is in, returning the corresponding y if x is one of the original xs
10237
+ let low = 0;
10238
+ let high = c3s.length - 1;
10239
+ let mid;
10240
+ while(low <= high){
10241
+ mid = Math.floor(0.5 * (low + high));
10242
+ const xHere = xs[mid];
10243
+ if (xHere < x) {
10244
+ low = mid + 1;
10245
+ } else if (xHere > x) {
10246
+ high = mid - 1;
10247
+ } else {
10248
+ return ys[mid];
10249
+ }
10250
+ }
10251
+ i = Math.max(0, high);
10252
+ // Interpolate
10253
+ const diff = x - xs[i];
10254
+ const diffSq = diff * diff;
10255
+ return ys[i] + c1s[i] * diff + c2s[i] * diffSq + c3s[i] * diff * diffSq;
10256
+ }
10257
+ constructor(xs, ys){
10258
+ const { length } = xs;
10259
+ // Rearrange xs and ys so that xs is sorted
10260
+ const indexes = [];
10261
+ for(let i = 0; i < length; i++){
10262
+ indexes.push(i);
10263
+ }
10264
+ indexes.sort((a, b)=>xs[a] < xs[b] ? -1 : 1
10265
+ );
10266
+ const dxs = [];
10267
+ const ms = [];
10268
+ let dx;
10269
+ let dy;
10270
+ for(let i1 = 0; i1 < length - 1; i1++){
10271
+ dx = xs[i1 + 1] - xs[i1];
10272
+ dy = ys[i1 + 1] - ys[i1];
10273
+ dxs.push(dx);
10274
+ ms.push(dy / dx);
10275
+ }
10276
+ // Get degree-1 coefficients
10277
+ const c1s = [
10278
+ ms[0]
10279
+ ];
10280
+ for(let i2 = 0; i2 < dxs.length - 1; i2++){
10281
+ const m2 = ms[i2];
10282
+ const mNext = ms[i2 + 1];
10283
+ if (m2 * mNext <= 0) {
10284
+ c1s.push(0);
10285
+ } else {
10286
+ dx = dxs[i2];
10287
+ const dxNext = dxs[i2 + 1];
10288
+ const common = dx + dxNext;
10289
+ c1s.push(3 * common / ((common + dxNext) / m2 + (common + dx) / mNext));
10290
+ }
10291
+ }
10292
+ c1s.push(ms[ms.length - 1]);
10293
+ // Get degree-2 and degree-3 coefficients
10294
+ const c2s = [];
10295
+ const c3s = [];
10296
+ let m;
10297
+ for(let i3 = 0; i3 < c1s.length - 1; i3++){
10298
+ m = ms[i3];
10299
+ const c1 = c1s[i3];
10300
+ const invDx = 1 / dxs[i3];
10301
+ const common = c1 + c1s[i3 + 1] - m - m;
10302
+ c2s.push((m - c1 - common) * invDx);
10303
+ c3s.push(common * invDx * invDx);
10304
+ }
10305
+ this.xs = xs;
10306
+ this.ys = ys;
10307
+ this.c1s = c1s;
10308
+ this.c2s = c2s;
10309
+ this.c3s = c3s;
10310
+ }
10311
+ }
10312
+
10313
+ const ELEMENT_NODE = 1;
10314
+ function getNodeClientOffset(node) {
10315
+ const el = node.nodeType === ELEMENT_NODE ? node : node.parentElement;
10316
+ if (!el) {
10317
+ return null;
10318
+ }
10319
+ const { top , left } = el.getBoundingClientRect();
10320
+ return {
10321
+ x: left,
10322
+ y: top
10323
+ };
10324
+ }
10325
+ function getEventClientOffset(e) {
10326
+ return {
10327
+ x: e.clientX,
10328
+ y: e.clientY
10329
+ };
10330
+ }
10331
+ function isImageNode(node) {
10332
+ var ref;
10333
+ return node.nodeName === 'IMG' && (isFirefox() || !((ref = document.documentElement) === null || ref === void 0 ? void 0 : ref.contains(node)));
10334
+ }
10335
+ function getDragPreviewSize(isImage, dragPreview, sourceWidth, sourceHeight) {
10336
+ let dragPreviewWidth = isImage ? dragPreview.width : sourceWidth;
10337
+ let dragPreviewHeight = isImage ? dragPreview.height : sourceHeight;
10338
+ // Work around @2x coordinate discrepancies in browsers
10339
+ if (isSafari() && isImage) {
10340
+ dragPreviewHeight /= window.devicePixelRatio;
10341
+ dragPreviewWidth /= window.devicePixelRatio;
10342
+ }
10343
+ return {
10344
+ dragPreviewWidth,
10345
+ dragPreviewHeight
10346
+ };
10347
+ }
10348
+ function getDragPreviewOffset(sourceNode, dragPreview, clientOffset, anchorPoint, offsetPoint) {
10349
+ // The browsers will use the image intrinsic size under different conditions.
10350
+ // Firefox only cares if it's an image, but WebKit also wants it to be detached.
10351
+ const isImage = isImageNode(dragPreview);
10352
+ const dragPreviewNode = isImage ? sourceNode : dragPreview;
10353
+ const dragPreviewNodeOffsetFromClient = getNodeClientOffset(dragPreviewNode);
10354
+ const offsetFromDragPreview = {
10355
+ x: clientOffset.x - dragPreviewNodeOffsetFromClient.x,
10356
+ y: clientOffset.y - dragPreviewNodeOffsetFromClient.y
10357
+ };
10358
+ const { offsetWidth: sourceWidth , offsetHeight: sourceHeight } = sourceNode;
10359
+ const { anchorX , anchorY } = anchorPoint;
10360
+ const { dragPreviewWidth , dragPreviewHeight } = getDragPreviewSize(isImage, dragPreview, sourceWidth, sourceHeight);
10361
+ const calculateYOffset = ()=>{
10362
+ const interpolantY = new MonotonicInterpolant([
10363
+ 0,
10364
+ 0.5,
10365
+ 1
10366
+ ], [
10367
+ // Dock to the top
10368
+ offsetFromDragPreview.y,
10369
+ // Align at the center
10370
+ (offsetFromDragPreview.y / sourceHeight) * dragPreviewHeight,
10371
+ // Dock to the bottom
10372
+ offsetFromDragPreview.y + dragPreviewHeight - sourceHeight,
10373
+ ]);
10374
+ let y = interpolantY.interpolate(anchorY);
10375
+ // Work around Safari 8 positioning bug
10376
+ if (isSafari() && isImage) {
10377
+ // We'll have to wait for @3x to see if this is entirely correct
10378
+ y += (window.devicePixelRatio - 1) * dragPreviewHeight;
10379
+ }
10380
+ return y;
10381
+ };
10382
+ const calculateXOffset = ()=>{
10383
+ // Interpolate coordinates depending on anchor point
10384
+ // If you know a simpler way to do this, let me know
10385
+ const interpolantX = new MonotonicInterpolant([
10386
+ 0,
10387
+ 0.5,
10388
+ 1
10389
+ ], [
10390
+ // Dock to the left
10391
+ offsetFromDragPreview.x,
10392
+ // Align at the center
10393
+ (offsetFromDragPreview.x / sourceWidth) * dragPreviewWidth,
10394
+ // Dock to the right
10395
+ offsetFromDragPreview.x + dragPreviewWidth - sourceWidth,
10396
+ ]);
10397
+ return interpolantX.interpolate(anchorX);
10398
+ };
10399
+ // Force offsets if specified in the options.
10400
+ const { offsetX , offsetY } = offsetPoint;
10401
+ const isManualOffsetX = offsetX === 0 || offsetX;
10402
+ const isManualOffsetY = offsetY === 0 || offsetY;
10403
+ return {
10404
+ x: isManualOffsetX ? offsetX : calculateXOffset(),
10405
+ y: isManualOffsetY ? offsetY : calculateYOffset()
10406
+ };
10407
+ }
10408
+
10409
+ class OptionsReader {
10410
+ get window() {
10411
+ if (this.globalContext) {
10412
+ return this.globalContext;
10413
+ } else if (typeof window !== 'undefined') {
10414
+ return window;
10415
+ }
10416
+ return undefined;
10417
+ }
10418
+ get document() {
10419
+ var ref;
10420
+ if ((ref = this.globalContext) === null || ref === void 0 ? void 0 : ref.document) {
10421
+ return this.globalContext.document;
10422
+ } else if (this.window) {
10423
+ return this.window.document;
10424
+ } else {
10425
+ return undefined;
10426
+ }
10427
+ }
10428
+ get rootElement() {
10429
+ var ref;
10430
+ return ((ref = this.optionsArgs) === null || ref === void 0 ? void 0 : ref.rootElement) || this.window;
10431
+ }
10432
+ constructor(globalContext, options){
10433
+ this.ownerDocument = null;
10434
+ this.globalContext = globalContext;
10435
+ this.optionsArgs = options;
10436
+ }
10437
+ }
10438
+
10439
+ function _defineProperty$2(obj, key, value) {
10440
+ if (key in obj) {
10441
+ Object.defineProperty(obj, key, {
10442
+ value: value,
10443
+ enumerable: true,
10444
+ configurable: true,
10445
+ writable: true
10446
+ });
10447
+ } else {
10448
+ obj[key] = value;
10449
+ }
10450
+ return obj;
10451
+ }
10452
+ function _objectSpread(target) {
10453
+ for(var i = 1; i < arguments.length; i++){
10454
+ var source = arguments[i] != null ? arguments[i] : {};
10455
+ var ownKeys = Object.keys(source);
10456
+ if (typeof Object.getOwnPropertySymbols === 'function') {
10457
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
10458
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
10459
+ }));
10460
+ }
10461
+ ownKeys.forEach(function(key) {
10462
+ _defineProperty$2(target, key, source[key]);
10463
+ });
10464
+ }
10465
+ return target;
10466
+ }
10467
+ class HTML5BackendImpl {
10468
+ /**
10469
+ * Generate profiling statistics for the HTML5Backend.
10470
+ */ profile() {
10471
+ var ref, ref1;
10472
+ return {
10473
+ sourcePreviewNodes: this.sourcePreviewNodes.size,
10474
+ sourcePreviewNodeOptions: this.sourcePreviewNodeOptions.size,
10475
+ sourceNodeOptions: this.sourceNodeOptions.size,
10476
+ sourceNodes: this.sourceNodes.size,
10477
+ dragStartSourceIds: ((ref = this.dragStartSourceIds) === null || ref === void 0 ? void 0 : ref.length) || 0,
10478
+ dropTargetIds: this.dropTargetIds.length,
10479
+ dragEnterTargetIds: this.dragEnterTargetIds.length,
10480
+ dragOverTargetIds: ((ref1 = this.dragOverTargetIds) === null || ref1 === void 0 ? void 0 : ref1.length) || 0
10481
+ };
10482
+ }
10483
+ // public for test
10484
+ get window() {
10485
+ return this.options.window;
10486
+ }
10487
+ get document() {
10488
+ return this.options.document;
10489
+ }
10490
+ /**
10491
+ * Get the root element to use for event subscriptions
10492
+ */ get rootElement() {
10493
+ return this.options.rootElement;
10494
+ }
10495
+ setup() {
10496
+ const root = this.rootElement;
10497
+ if (root === undefined) {
10498
+ return;
10499
+ }
10500
+ if (root.__isReactDndBackendSetUp) {
10501
+ throw new Error('Cannot have two HTML5 backends at the same time.');
10502
+ }
10503
+ root.__isReactDndBackendSetUp = true;
10504
+ this.addEventListeners(root);
10505
+ }
10506
+ teardown() {
10507
+ const root = this.rootElement;
10508
+ if (root === undefined) {
10509
+ return;
10510
+ }
10511
+ root.__isReactDndBackendSetUp = false;
10512
+ this.removeEventListeners(this.rootElement);
10513
+ this.clearCurrentDragSourceNode();
10514
+ if (this.asyncEndDragFrameId) {
10515
+ var ref;
10516
+ (ref = this.window) === null || ref === void 0 ? void 0 : ref.cancelAnimationFrame(this.asyncEndDragFrameId);
10517
+ }
10518
+ }
10519
+ connectDragPreview(sourceId, node, options) {
10520
+ this.sourcePreviewNodeOptions.set(sourceId, options);
10521
+ this.sourcePreviewNodes.set(sourceId, node);
10522
+ return ()=>{
10523
+ this.sourcePreviewNodes.delete(sourceId);
10524
+ this.sourcePreviewNodeOptions.delete(sourceId);
10525
+ };
10526
+ }
10527
+ connectDragSource(sourceId, node, options) {
10528
+ this.sourceNodes.set(sourceId, node);
10529
+ this.sourceNodeOptions.set(sourceId, options);
10530
+ const handleDragStart = (e)=>this.handleDragStart(e, sourceId)
10531
+ ;
10532
+ const handleSelectStart = (e)=>this.handleSelectStart(e)
10533
+ ;
10534
+ node.setAttribute('draggable', 'true');
10535
+ node.addEventListener('dragstart', handleDragStart);
10536
+ node.addEventListener('selectstart', handleSelectStart);
10537
+ return ()=>{
10538
+ this.sourceNodes.delete(sourceId);
10539
+ this.sourceNodeOptions.delete(sourceId);
10540
+ node.removeEventListener('dragstart', handleDragStart);
10541
+ node.removeEventListener('selectstart', handleSelectStart);
10542
+ node.setAttribute('draggable', 'false');
10543
+ };
10544
+ }
10545
+ connectDropTarget(targetId, node) {
10546
+ const handleDragEnter = (e)=>this.handleDragEnter(e, targetId)
10547
+ ;
10548
+ const handleDragOver = (e)=>this.handleDragOver(e, targetId)
10549
+ ;
10550
+ const handleDrop = (e)=>this.handleDrop(e, targetId)
10551
+ ;
10552
+ node.addEventListener('dragenter', handleDragEnter);
10553
+ node.addEventListener('dragover', handleDragOver);
10554
+ node.addEventListener('drop', handleDrop);
10555
+ return ()=>{
10556
+ node.removeEventListener('dragenter', handleDragEnter);
10557
+ node.removeEventListener('dragover', handleDragOver);
10558
+ node.removeEventListener('drop', handleDrop);
10559
+ };
10560
+ }
10561
+ addEventListeners(target) {
10562
+ // SSR Fix (https://github.com/react-dnd/react-dnd/pull/813
10563
+ if (!target.addEventListener) {
10564
+ return;
10565
+ }
10566
+ target.addEventListener('dragstart', this.handleTopDragStart);
10567
+ target.addEventListener('dragstart', this.handleTopDragStartCapture, true);
10568
+ target.addEventListener('dragend', this.handleTopDragEndCapture, true);
10569
+ target.addEventListener('dragenter', this.handleTopDragEnter);
10570
+ target.addEventListener('dragenter', this.handleTopDragEnterCapture, true);
10571
+ target.addEventListener('dragleave', this.handleTopDragLeaveCapture, true);
10572
+ target.addEventListener('dragover', this.handleTopDragOver);
10573
+ target.addEventListener('dragover', this.handleTopDragOverCapture, true);
10574
+ target.addEventListener('drop', this.handleTopDrop);
10575
+ target.addEventListener('drop', this.handleTopDropCapture, true);
10576
+ }
10577
+ removeEventListeners(target) {
10578
+ // SSR Fix (https://github.com/react-dnd/react-dnd/pull/813
10579
+ if (!target.removeEventListener) {
10580
+ return;
10581
+ }
10582
+ target.removeEventListener('dragstart', this.handleTopDragStart);
10583
+ target.removeEventListener('dragstart', this.handleTopDragStartCapture, true);
10584
+ target.removeEventListener('dragend', this.handleTopDragEndCapture, true);
10585
+ target.removeEventListener('dragenter', this.handleTopDragEnter);
10586
+ target.removeEventListener('dragenter', this.handleTopDragEnterCapture, true);
10587
+ target.removeEventListener('dragleave', this.handleTopDragLeaveCapture, true);
10588
+ target.removeEventListener('dragover', this.handleTopDragOver);
10589
+ target.removeEventListener('dragover', this.handleTopDragOverCapture, true);
10590
+ target.removeEventListener('drop', this.handleTopDrop);
10591
+ target.removeEventListener('drop', this.handleTopDropCapture, true);
10592
+ }
10593
+ getCurrentSourceNodeOptions() {
10594
+ const sourceId = this.monitor.getSourceId();
10595
+ const sourceNodeOptions = this.sourceNodeOptions.get(sourceId);
10596
+ return _objectSpread({
10597
+ dropEffect: this.altKeyPressed ? 'copy' : 'move'
10598
+ }, sourceNodeOptions || {});
10599
+ }
10600
+ getCurrentDropEffect() {
10601
+ if (this.isDraggingNativeItem()) {
10602
+ // It makes more sense to default to 'copy' for native resources
10603
+ return 'copy';
10604
+ }
10605
+ return this.getCurrentSourceNodeOptions().dropEffect;
10606
+ }
10607
+ getCurrentSourcePreviewNodeOptions() {
10608
+ const sourceId = this.monitor.getSourceId();
10609
+ const sourcePreviewNodeOptions = this.sourcePreviewNodeOptions.get(sourceId);
10610
+ return _objectSpread({
10611
+ anchorX: 0.5,
10612
+ anchorY: 0.5,
10613
+ captureDraggingState: false
10614
+ }, sourcePreviewNodeOptions || {});
10615
+ }
10616
+ isDraggingNativeItem() {
10617
+ const itemType = this.monitor.getItemType();
10618
+ return Object.keys(NativeTypes).some((key)=>NativeTypes[key] === itemType
10619
+ );
10620
+ }
10621
+ beginDragNativeItem(type, dataTransfer) {
10622
+ this.clearCurrentDragSourceNode();
10623
+ this.currentNativeSource = createNativeDragSource(type, dataTransfer);
10624
+ this.currentNativeHandle = this.registry.addSource(type, this.currentNativeSource);
10625
+ this.actions.beginDrag([
10626
+ this.currentNativeHandle
10627
+ ]);
10628
+ }
10629
+ setCurrentDragSourceNode(node) {
10630
+ this.clearCurrentDragSourceNode();
10631
+ this.currentDragSourceNode = node;
10632
+ // A timeout of > 0 is necessary to resolve Firefox issue referenced
10633
+ // See:
10634
+ // * https://github.com/react-dnd/react-dnd/pull/928
10635
+ // * https://github.com/react-dnd/react-dnd/issues/869
10636
+ const MOUSE_MOVE_TIMEOUT = 1000;
10637
+ // Receiving a mouse event in the middle of a dragging operation
10638
+ // means it has ended and the drag source node disappeared from DOM,
10639
+ // so the browser didn't dispatch the dragend event.
10640
+ //
10641
+ // We need to wait before we start listening for mousemove events.
10642
+ // This is needed because the drag preview needs to be drawn or else it fires an 'mousemove' event
10643
+ // immediately in some browsers.
10644
+ //
10645
+ // See:
10646
+ // * https://github.com/react-dnd/react-dnd/pull/928
10647
+ // * https://github.com/react-dnd/react-dnd/issues/869
10648
+ //
10649
+ this.mouseMoveTimeoutTimer = setTimeout(()=>{
10650
+ var ref;
10651
+ return (ref = this.rootElement) === null || ref === void 0 ? void 0 : ref.addEventListener('mousemove', this.endDragIfSourceWasRemovedFromDOM, true);
10652
+ }, MOUSE_MOVE_TIMEOUT);
10653
+ }
10654
+ clearCurrentDragSourceNode() {
10655
+ if (this.currentDragSourceNode) {
10656
+ this.currentDragSourceNode = null;
10657
+ if (this.rootElement) {
10658
+ var ref;
10659
+ (ref = this.window) === null || ref === void 0 ? void 0 : ref.clearTimeout(this.mouseMoveTimeoutTimer || undefined);
10660
+ this.rootElement.removeEventListener('mousemove', this.endDragIfSourceWasRemovedFromDOM, true);
10661
+ }
10662
+ this.mouseMoveTimeoutTimer = null;
10663
+ return true;
10664
+ }
10665
+ return false;
10666
+ }
10667
+ handleDragStart(e, sourceId) {
10668
+ if (e.defaultPrevented) {
10669
+ return;
10670
+ }
10671
+ if (!this.dragStartSourceIds) {
10672
+ this.dragStartSourceIds = [];
10673
+ }
10674
+ this.dragStartSourceIds.unshift(sourceId);
10675
+ }
10676
+ handleDragEnter(_e, targetId) {
10677
+ this.dragEnterTargetIds.unshift(targetId);
10678
+ }
10679
+ handleDragOver(_e, targetId) {
10680
+ if (this.dragOverTargetIds === null) {
10681
+ this.dragOverTargetIds = [];
10682
+ }
10683
+ this.dragOverTargetIds.unshift(targetId);
10684
+ }
10685
+ handleDrop(_e, targetId) {
10686
+ this.dropTargetIds.unshift(targetId);
10687
+ }
10688
+ constructor(manager, globalContext, options){
10689
+ this.sourcePreviewNodes = new Map();
10690
+ this.sourcePreviewNodeOptions = new Map();
10691
+ this.sourceNodes = new Map();
10692
+ this.sourceNodeOptions = new Map();
10693
+ this.dragStartSourceIds = null;
10694
+ this.dropTargetIds = [];
10695
+ this.dragEnterTargetIds = [];
10696
+ this.currentNativeSource = null;
10697
+ this.currentNativeHandle = null;
10698
+ this.currentDragSourceNode = null;
10699
+ this.altKeyPressed = false;
10700
+ this.mouseMoveTimeoutTimer = null;
10701
+ this.asyncEndDragFrameId = null;
10702
+ this.dragOverTargetIds = null;
10703
+ this.lastClientOffset = null;
10704
+ this.hoverRafId = null;
10705
+ this.getSourceClientOffset = (sourceId)=>{
10706
+ const source = this.sourceNodes.get(sourceId);
10707
+ return source && getNodeClientOffset(source) || null;
10708
+ };
10709
+ this.endDragNativeItem = ()=>{
10710
+ if (!this.isDraggingNativeItem()) {
10711
+ return;
10712
+ }
10713
+ this.actions.endDrag();
10714
+ if (this.currentNativeHandle) {
10715
+ this.registry.removeSource(this.currentNativeHandle);
10716
+ }
10717
+ this.currentNativeHandle = null;
10718
+ this.currentNativeSource = null;
10719
+ };
10720
+ this.isNodeInDocument = (node)=>{
10721
+ // Check the node either in the main document or in the current context
10722
+ return Boolean(node && this.document && this.document.body && this.document.body.contains(node));
10723
+ };
10724
+ this.endDragIfSourceWasRemovedFromDOM = ()=>{
10725
+ const node = this.currentDragSourceNode;
10726
+ if (node == null || this.isNodeInDocument(node)) {
10727
+ return;
10728
+ }
10729
+ if (this.clearCurrentDragSourceNode() && this.monitor.isDragging()) {
10730
+ this.actions.endDrag();
10731
+ }
10732
+ this.cancelHover();
10733
+ };
10734
+ this.scheduleHover = (dragOverTargetIds)=>{
10735
+ if (this.hoverRafId === null && typeof requestAnimationFrame !== 'undefined') {
10736
+ this.hoverRafId = requestAnimationFrame(()=>{
10737
+ if (this.monitor.isDragging()) {
10738
+ this.actions.hover(dragOverTargetIds || [], {
10739
+ clientOffset: this.lastClientOffset
10740
+ });
10741
+ }
10742
+ this.hoverRafId = null;
10743
+ });
10744
+ }
10745
+ };
10746
+ this.cancelHover = ()=>{
10747
+ if (this.hoverRafId !== null && typeof cancelAnimationFrame !== 'undefined') {
10748
+ cancelAnimationFrame(this.hoverRafId);
10749
+ this.hoverRafId = null;
10750
+ }
10751
+ };
10752
+ this.handleTopDragStartCapture = ()=>{
10753
+ this.clearCurrentDragSourceNode();
10754
+ this.dragStartSourceIds = [];
10755
+ };
10756
+ this.handleTopDragStart = (e)=>{
10757
+ if (e.defaultPrevented) {
10758
+ return;
10759
+ }
10760
+ const { dragStartSourceIds } = this;
10761
+ this.dragStartSourceIds = null;
10762
+ const clientOffset = getEventClientOffset(e);
10763
+ // Avoid crashing if we missed a drop event or our previous drag died
10764
+ if (this.monitor.isDragging()) {
10765
+ this.actions.endDrag();
10766
+ this.cancelHover();
10767
+ }
10768
+ // Don't publish the source just yet (see why below)
10769
+ this.actions.beginDrag(dragStartSourceIds || [], {
10770
+ publishSource: false,
10771
+ getSourceClientOffset: this.getSourceClientOffset,
10772
+ clientOffset
10773
+ });
10774
+ const { dataTransfer } = e;
10775
+ const nativeType = matchNativeItemType(dataTransfer);
10776
+ if (this.monitor.isDragging()) {
10777
+ if (dataTransfer && typeof dataTransfer.setDragImage === 'function') {
10778
+ // Use custom drag image if user specifies it.
10779
+ // If child drag source refuses drag but parent agrees,
10780
+ // use parent's node as drag image. Neither works in IE though.
10781
+ const sourceId = this.monitor.getSourceId();
10782
+ const sourceNode = this.sourceNodes.get(sourceId);
10783
+ const dragPreview = this.sourcePreviewNodes.get(sourceId) || sourceNode;
10784
+ if (dragPreview) {
10785
+ const { anchorX , anchorY , offsetX , offsetY } = this.getCurrentSourcePreviewNodeOptions();
10786
+ const anchorPoint = {
10787
+ anchorX,
10788
+ anchorY
10789
+ };
10790
+ const offsetPoint = {
10791
+ offsetX,
10792
+ offsetY
10793
+ };
10794
+ const dragPreviewOffset = getDragPreviewOffset(sourceNode, dragPreview, clientOffset, anchorPoint, offsetPoint);
10795
+ dataTransfer.setDragImage(dragPreview, dragPreviewOffset.x, dragPreviewOffset.y);
10796
+ }
10797
+ }
10798
+ try {
10799
+ // Firefox won't drag without setting data
10800
+ dataTransfer === null || dataTransfer === void 0 ? void 0 : dataTransfer.setData('application/json', {});
10801
+ } catch (err) {
10802
+ // IE doesn't support MIME types in setData
10803
+ }
10804
+ // Store drag source node so we can check whether
10805
+ // it is removed from DOM and trigger endDrag manually.
10806
+ this.setCurrentDragSourceNode(e.target);
10807
+ // Now we are ready to publish the drag source.. or are we not?
10808
+ const { captureDraggingState } = this.getCurrentSourcePreviewNodeOptions();
10809
+ if (!captureDraggingState) {
10810
+ // Usually we want to publish it in the next tick so that browser
10811
+ // is able to screenshot the current (not yet dragging) state.
10812
+ //
10813
+ // It also neatly avoids a situation where render() returns null
10814
+ // in the same tick for the source element, and browser freaks out.
10815
+ setTimeout(()=>this.actions.publishDragSource()
10816
+ , 0);
10817
+ } else {
10818
+ // In some cases the user may want to override this behavior, e.g.
10819
+ // to work around IE not supporting custom drag previews.
10820
+ //
10821
+ // When using a custom drag layer, the only way to prevent
10822
+ // the default drag preview from drawing in IE is to screenshot
10823
+ // the dragging state in which the node itself has zero opacity
10824
+ // and height. In this case, though, returning null from render()
10825
+ // will abruptly end the dragging, which is not obvious.
10826
+ //
10827
+ // This is the reason such behavior is strictly opt-in.
10828
+ this.actions.publishDragSource();
10829
+ }
10830
+ } else if (nativeType) {
10831
+ // A native item (such as URL) dragged from inside the document
10832
+ this.beginDragNativeItem(nativeType);
10833
+ } else if (dataTransfer && !dataTransfer.types && (e.target && !e.target.hasAttribute || !e.target.hasAttribute('draggable'))) {
10834
+ // Looks like a Safari bug: dataTransfer.types is null, but there was no draggable.
10835
+ // Just let it drag. It's a native type (URL or text) and will be picked up in
10836
+ // dragenter handler.
10837
+ return;
10838
+ } else {
10839
+ // If by this time no drag source reacted, tell browser not to drag.
10840
+ e.preventDefault();
10841
+ }
10842
+ };
10843
+ this.handleTopDragEndCapture = ()=>{
10844
+ if (this.clearCurrentDragSourceNode() && this.monitor.isDragging()) {
10845
+ // Firefox can dispatch this event in an infinite loop
10846
+ // if dragend handler does something like showing an alert.
10847
+ // Only proceed if we have not handled it already.
10848
+ this.actions.endDrag();
10849
+ }
10850
+ this.cancelHover();
10851
+ };
10852
+ this.handleTopDragEnterCapture = (e)=>{
10853
+ this.dragEnterTargetIds = [];
10854
+ if (this.isDraggingNativeItem()) {
10855
+ var ref;
10856
+ (ref = this.currentNativeSource) === null || ref === void 0 ? void 0 : ref.loadDataTransfer(e.dataTransfer);
10857
+ }
10858
+ const isFirstEnter = this.enterLeaveCounter.enter(e.target);
10859
+ if (!isFirstEnter || this.monitor.isDragging()) {
10860
+ return;
10861
+ }
10862
+ const { dataTransfer } = e;
10863
+ const nativeType = matchNativeItemType(dataTransfer);
10864
+ if (nativeType) {
10865
+ // A native item (such as file or URL) dragged from outside the document
10866
+ this.beginDragNativeItem(nativeType, dataTransfer);
10867
+ }
10868
+ };
10869
+ this.handleTopDragEnter = (e)=>{
10870
+ const { dragEnterTargetIds } = this;
10871
+ this.dragEnterTargetIds = [];
10872
+ if (!this.monitor.isDragging()) {
10873
+ // This is probably a native item type we don't understand.
10874
+ return;
10875
+ }
10876
+ this.altKeyPressed = e.altKey;
10877
+ // If the target changes position as the result of `dragenter`, `dragover` might still
10878
+ // get dispatched despite target being no longer there. The easy solution is to check
10879
+ // whether there actually is a target before firing `hover`.
10880
+ if (dragEnterTargetIds.length > 0) {
10881
+ this.actions.hover(dragEnterTargetIds, {
10882
+ clientOffset: getEventClientOffset(e)
10883
+ });
10884
+ }
10885
+ const canDrop = dragEnterTargetIds.some((targetId)=>this.monitor.canDropOnTarget(targetId)
10886
+ );
10887
+ if (canDrop) {
10888
+ // IE requires this to fire dragover events
10889
+ e.preventDefault();
10890
+ if (e.dataTransfer) {
10891
+ e.dataTransfer.dropEffect = this.getCurrentDropEffect();
10892
+ }
10893
+ }
10894
+ };
10895
+ this.handleTopDragOverCapture = (e)=>{
10896
+ this.dragOverTargetIds = [];
10897
+ if (this.isDraggingNativeItem()) {
10898
+ var ref;
10899
+ (ref = this.currentNativeSource) === null || ref === void 0 ? void 0 : ref.loadDataTransfer(e.dataTransfer);
10900
+ }
10901
+ };
10902
+ this.handleTopDragOver = (e)=>{
10903
+ const { dragOverTargetIds } = this;
10904
+ this.dragOverTargetIds = [];
10905
+ if (!this.monitor.isDragging()) {
10906
+ // This is probably a native item type we don't understand.
10907
+ // Prevent default "drop and blow away the whole document" action.
10908
+ e.preventDefault();
10909
+ if (e.dataTransfer) {
10910
+ e.dataTransfer.dropEffect = 'none';
10911
+ }
10912
+ return;
10913
+ }
10914
+ this.altKeyPressed = e.altKey;
10915
+ this.lastClientOffset = getEventClientOffset(e);
10916
+ this.scheduleHover(dragOverTargetIds);
10917
+ const canDrop = (dragOverTargetIds || []).some((targetId)=>this.monitor.canDropOnTarget(targetId)
10918
+ );
10919
+ if (canDrop) {
10920
+ // Show user-specified drop effect.
10921
+ e.preventDefault();
10922
+ if (e.dataTransfer) {
10923
+ e.dataTransfer.dropEffect = this.getCurrentDropEffect();
10924
+ }
10925
+ } else if (this.isDraggingNativeItem()) {
10926
+ // Don't show a nice cursor but still prevent default
10927
+ // "drop and blow away the whole document" action.
10928
+ e.preventDefault();
10929
+ } else {
10930
+ e.preventDefault();
10931
+ if (e.dataTransfer) {
10932
+ e.dataTransfer.dropEffect = 'none';
10933
+ }
10934
+ }
10935
+ };
10936
+ this.handleTopDragLeaveCapture = (e)=>{
10937
+ if (this.isDraggingNativeItem()) {
10938
+ e.preventDefault();
10939
+ }
10940
+ const isLastLeave = this.enterLeaveCounter.leave(e.target);
10941
+ if (!isLastLeave) {
10942
+ return;
10943
+ }
10944
+ if (this.isDraggingNativeItem()) {
10945
+ setTimeout(()=>this.endDragNativeItem()
10946
+ , 0);
10947
+ }
10948
+ this.cancelHover();
10949
+ };
10950
+ this.handleTopDropCapture = (e)=>{
10951
+ this.dropTargetIds = [];
10952
+ if (this.isDraggingNativeItem()) {
10953
+ var ref;
10954
+ e.preventDefault();
10955
+ (ref = this.currentNativeSource) === null || ref === void 0 ? void 0 : ref.loadDataTransfer(e.dataTransfer);
10956
+ } else if (matchNativeItemType(e.dataTransfer)) {
10957
+ // Dragging some elements, like <a> and <img> may still behave like a native drag event,
10958
+ // even if the current drag event matches a user-defined type.
10959
+ // Stop the default behavior when we're not expecting a native item to be dropped.
10960
+ e.preventDefault();
10961
+ }
10962
+ this.enterLeaveCounter.reset();
10963
+ };
10964
+ this.handleTopDrop = (e)=>{
10965
+ const { dropTargetIds } = this;
10966
+ this.dropTargetIds = [];
10967
+ this.actions.hover(dropTargetIds, {
10968
+ clientOffset: getEventClientOffset(e)
10969
+ });
10970
+ this.actions.drop({
10971
+ dropEffect: this.getCurrentDropEffect()
10972
+ });
10973
+ if (this.isDraggingNativeItem()) {
10974
+ this.endDragNativeItem();
10975
+ } else if (this.monitor.isDragging()) {
10976
+ this.actions.endDrag();
10977
+ }
10978
+ this.cancelHover();
10979
+ };
10980
+ this.handleSelectStart = (e)=>{
10981
+ const target = e.target;
10982
+ // Only IE requires us to explicitly say
10983
+ // we want drag drop operation to start
10984
+ if (typeof target.dragDrop !== 'function') {
10985
+ return;
10986
+ }
10987
+ // Inputs and textareas should be selectable
10988
+ if (target.tagName === 'INPUT' || target.tagName === 'SELECT' || target.tagName === 'TEXTAREA' || target.isContentEditable) {
10989
+ return;
10990
+ }
10991
+ // For other targets, ask IE
10992
+ // to enable drag and drop
10993
+ e.preventDefault();
10994
+ target.dragDrop();
10995
+ };
10996
+ this.options = new OptionsReader(globalContext, options);
10997
+ this.actions = manager.getActions();
10998
+ this.monitor = manager.getMonitor();
10999
+ this.registry = manager.getRegistry();
11000
+ this.enterLeaveCounter = new EnterLeaveCounter(this.isNodeInDocument);
11001
+ }
11002
+ }
11003
+
11004
+ let emptyImage;
11005
+ function getEmptyImage() {
11006
+ if (!emptyImage) {
11007
+ emptyImage = new Image();
11008
+ emptyImage.src = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
11009
+ }
11010
+ return emptyImage;
11011
+ }
11012
+
11013
+ const HTML5Backend = function createBackend(manager, context, options) {
11014
+ return new HTML5BackendImpl(manager, context, options);
11015
+ };
11016
+
11017
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
11018
+
11019
+ function _unsupportedIterableToArray$1(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(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$1(o, minLen); }
11020
+
11021
+ function _arrayLikeToArray$1(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; }
11022
+
11023
+ function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11024
+
11025
+ 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; }
11026
+
11027
+ function _classPrivateFieldGet$1(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor$1(receiver, privateMap, "get"); return _classApplyDescriptorGet$1(receiver, descriptor); }
11028
+
11029
+ function _classApplyDescriptorGet$1(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
11030
+
11031
+ function _classPrivateFieldSet$1(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor$1(receiver, privateMap, "set"); _classApplyDescriptorSet$1(receiver, descriptor, value); return value; }
11032
+
11033
+ function _classExtractFieldDescriptor$1(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
11034
+
11035
+ function _classApplyDescriptorSet$1(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
11036
+
11037
+ var _previews$1 = new WeakMap();
11038
+
11039
+ var PreviewListImpl =
11040
+ /*private*/
11041
+ function PreviewListImpl() {
11042
+ var _this = this;
11043
+
11044
+ _classCallCheck$1(this, PreviewListImpl);
11045
+
11046
+ _previews$1.set(this, {
11047
+ writable: true,
11048
+ value: void 0
11049
+ });
11050
+
11051
+ _defineProperty$1(this, "register", function (preview) {
11052
+ _classPrivateFieldGet$1(_this, _previews$1).push(preview);
11053
+ });
11054
+
11055
+ _defineProperty$1(this, "unregister", function (preview) {
11056
+ var index;
11057
+
11058
+ while ((index = _classPrivateFieldGet$1(_this, _previews$1).indexOf(preview)) !== -1) {
11059
+ _classPrivateFieldGet$1(_this, _previews$1).splice(index, 1);
11060
+ }
11061
+ });
11062
+
11063
+ _defineProperty$1(this, "backendChanged", function (backend) {
11064
+ var _iterator = _createForOfIteratorHelper(_classPrivateFieldGet$1(_this, _previews$1)),
11065
+ _step;
11066
+
11067
+ try {
11068
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
11069
+ var preview = _step.value;
11070
+ preview.backendChanged(backend);
11071
+ }
11072
+ } catch (err) {
11073
+ _iterator.e(err);
11074
+ } finally {
11075
+ _iterator.f();
11076
+ }
11077
+ });
11078
+
11079
+ _classPrivateFieldSet$1(this, _previews$1, []);
11080
+ };
11081
+
11082
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
11083
+
11084
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
11085
+
11086
+ 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); }
11087
+
11088
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
11089
+
11090
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
11091
+
11092
+ 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; }
11093
+
11094
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11095
+
11096
+ 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; }
11097
+
11098
+ function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
11099
+
11100
+ function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
11101
+
11102
+ function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
11103
+
11104
+ function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
11105
+
11106
+ function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
11107
+
11108
+ var _current = new WeakMap();
11109
+
11110
+ var _previews = new WeakMap();
11111
+
11112
+ var _backends = new WeakMap();
11113
+
11114
+ var _backendsList = new WeakMap();
11115
+
11116
+ var _nodes = new WeakMap();
11117
+
11118
+ var _createBackend = new WeakMap();
11119
+
11120
+ var _addEventListeners = new WeakMap();
11121
+
11122
+ var _removeEventListeners = new WeakMap();
11123
+
11124
+ var _backendSwitcher = new WeakMap();
11125
+
11126
+ var _callBackend = new WeakMap();
11127
+
11128
+ var _connectBackend = new WeakMap();
11129
+
11130
+ var MultiBackendImpl =
11131
+ /*private*/
11132
+
11133
+ /*private*/
11134
+
11135
+ /*private*/
11136
+
11137
+ /*private*/
11138
+
11139
+ /*private*/
11140
+ function MultiBackendImpl(_manager, _context, _options) {
11141
+ var _this = this;
11142
+
11143
+ _classCallCheck(this, MultiBackendImpl);
11144
+
11145
+ _current.set(this, {
11146
+ writable: true,
11147
+ value: void 0
11148
+ });
11149
+
11150
+ _previews.set(this, {
11151
+ writable: true,
11152
+ value: void 0
11153
+ });
11154
+
11155
+ _backends.set(this, {
11156
+ writable: true,
11157
+ value: void 0
11158
+ });
11159
+
11160
+ _backendsList.set(this, {
11161
+ writable: true,
11162
+ value: void 0
11163
+ });
11164
+
11165
+ _nodes.set(this, {
11166
+ writable: true,
11167
+ value: void 0
11168
+ });
11169
+
11170
+ _createBackend.set(this, {
11171
+ writable: true,
11172
+ value: function value(manager, context, backend) {
11173
+ var _backend$preview, _backend$skipDispatch;
11174
+
11175
+ if (!backend.backend) {
11176
+ throw new Error("You must specify a 'backend' property in your Backend entry: ".concat(JSON.stringify(backend)));
11177
+ }
11178
+
11179
+ var instance = backend.backend(manager, context, backend.options);
11180
+ var id = backend.id; // Try to infer an `id` if one doesn't exist
11181
+
11182
+ var inferName = !backend.id && instance && instance.constructor;
11183
+
11184
+ if (inferName) {
11185
+ id = instance.constructor.name;
11186
+ }
11187
+
11188
+ if (!id) {
11189
+ throw new Error("You must specify an 'id' property in your Backend entry: ".concat(JSON.stringify(backend), "\n see this guide: https://github.com/louisbrunner/dnd-multi-backend/tree/master/packages/react-dnd-multi-backend#migrating-from-5xx"));
11190
+ } else if (inferName) {
11191
+ console.warn( // eslint-disable-line no-console
11192
+ "Deprecation notice: You are using a pipeline which doesn't include backends' 'id'.\n This might be unsupported in the future, please specify 'id' explicitely for every backend.");
11193
+ }
11194
+
11195
+ if (_classPrivateFieldGet(_this, _backends)[id]) {
11196
+ throw new Error("You must specify a unique 'id' property in your Backend entry:\n ".concat(JSON.stringify(backend), " (conflicts with: ").concat(JSON.stringify(_classPrivateFieldGet(_this, _backends)[id]), ")"));
11197
+ }
11198
+
11199
+ return {
11200
+ id: id,
11201
+ instance: instance,
11202
+ preview: (_backend$preview = backend.preview) !== null && _backend$preview !== void 0 ? _backend$preview : false,
11203
+ transition: backend.transition,
11204
+ skipDispatchOnTransition: (_backend$skipDispatch = backend.skipDispatchOnTransition) !== null && _backend$skipDispatch !== void 0 ? _backend$skipDispatch : false
11205
+ };
11206
+ }
11207
+ });
11208
+
11209
+ _defineProperty(this, "setup", function () {
11210
+ if (typeof window === 'undefined') {
11211
+ return;
11212
+ }
11213
+
11214
+ if (MultiBackendImpl.isSetUp) {
11215
+ throw new Error('Cannot have two MultiBackends at the same time.');
11216
+ }
11217
+
11218
+ MultiBackendImpl.isSetUp = true;
11219
+
11220
+ _classPrivateFieldGet(_this, _addEventListeners).call(_this, window);
11221
+
11222
+ _classPrivateFieldGet(_this, _backends)[_classPrivateFieldGet(_this, _current)].instance.setup();
11223
+ });
11224
+
11225
+ _defineProperty(this, "teardown", function () {
11226
+ if (typeof window === 'undefined') {
11227
+ return;
11228
+ }
11229
+
11230
+ MultiBackendImpl.isSetUp = false;
11231
+
11232
+ _classPrivateFieldGet(_this, _removeEventListeners).call(_this, window);
11233
+
11234
+ _classPrivateFieldGet(_this, _backends)[_classPrivateFieldGet(_this, _current)].instance.teardown();
11235
+ });
11236
+
11237
+ _defineProperty(this, "connectDragSource", function (sourceId, node, options) {
11238
+ return _classPrivateFieldGet(_this, _connectBackend).call(_this, 'connectDragSource', sourceId, node, options);
11239
+ });
11240
+
11241
+ _defineProperty(this, "connectDragPreview", function (sourceId, node, options) {
11242
+ return _classPrivateFieldGet(_this, _connectBackend).call(_this, 'connectDragPreview', sourceId, node, options);
11243
+ });
11244
+
11245
+ _defineProperty(this, "connectDropTarget", function (sourceId, node, options) {
11246
+ return _classPrivateFieldGet(_this, _connectBackend).call(_this, 'connectDropTarget', sourceId, node, options);
11247
+ });
11248
+
11249
+ _defineProperty(this, "profile", function () {
11250
+ return _classPrivateFieldGet(_this, _backends)[_classPrivateFieldGet(_this, _current)].instance.profile();
11251
+ });
11252
+
11253
+ _defineProperty(this, "previewEnabled", function () {
11254
+ return _classPrivateFieldGet(_this, _backends)[_classPrivateFieldGet(_this, _current)].preview;
11255
+ });
11256
+
11257
+ _defineProperty(this, "previewsList", function () {
11258
+ return _classPrivateFieldGet(_this, _previews);
11259
+ });
11260
+
11261
+ _defineProperty(this, "backendsList", function () {
11262
+ return _classPrivateFieldGet(_this, _backendsList);
11263
+ });
11264
+
11265
+ _addEventListeners.set(this, {
11266
+ writable: true,
11267
+ value: function value(target) {
11268
+ _classPrivateFieldGet(_this, _backendsList).forEach(function (backend) {
11269
+ if (backend.transition) {
11270
+ target.addEventListener(backend.transition.event, _classPrivateFieldGet(_this, _backendSwitcher));
11271
+ }
11272
+ });
11273
+ }
11274
+ });
11275
+
11276
+ _removeEventListeners.set(this, {
11277
+ writable: true,
11278
+ value: function value(target) {
11279
+ _classPrivateFieldGet(_this, _backendsList).forEach(function (backend) {
11280
+ if (backend.transition) {
11281
+ target.removeEventListener(backend.transition.event, _classPrivateFieldGet(_this, _backendSwitcher));
11282
+ }
11283
+ });
11284
+ }
11285
+ });
11286
+
11287
+ _backendSwitcher.set(this, {
11288
+ writable: true,
11289
+ value: function value(event) {
11290
+ var oldBackend = _classPrivateFieldGet(_this, _current);
11291
+
11292
+ _classPrivateFieldGet(_this, _backendsList).some(function (backend) {
11293
+ if (backend.id !== _classPrivateFieldGet(_this, _current) && backend.transition && backend.transition.check(event)) {
11294
+ _classPrivateFieldSet(_this, _current, backend.id);
11295
+
11296
+ return true;
11297
+ }
11298
+
11299
+ return false;
11300
+ });
11301
+
11302
+ if (_classPrivateFieldGet(_this, _current) !== oldBackend) {
11303
+ var _event$target;
11304
+
11305
+ _classPrivateFieldGet(_this, _backends)[oldBackend].instance.teardown();
11306
+
11307
+ Object.keys(_classPrivateFieldGet(_this, _nodes)).forEach(function (id) {
11308
+ var _classPrivateFieldGet2;
11309
+
11310
+ var node = _classPrivateFieldGet(_this, _nodes)[id];
11311
+
11312
+ node.unsubscribe();
11313
+ node.unsubscribe = (_classPrivateFieldGet2 = _classPrivateFieldGet(_this, _callBackend)).call.apply(_classPrivateFieldGet2, [_this, node.func].concat(_toConsumableArray(node.args)));
11314
+ });
11315
+
11316
+ _classPrivateFieldGet(_this, _previews).backendChanged(_this);
11317
+
11318
+ var newBackend = _classPrivateFieldGet(_this, _backends)[_classPrivateFieldGet(_this, _current)];
11319
+
11320
+ newBackend.instance.setup();
11321
+
11322
+ if (newBackend.skipDispatchOnTransition) {
11323
+ return;
11324
+ }
11325
+
11326
+ var newEvent = null;
11327
+
11328
+ try {
11329
+ newEvent = event.constructor(event.type, event);
11330
+ } catch (_e) {
11331
+ newEvent = document.createEvent('Event');
11332
+ newEvent.initEvent(event.type, event.bubbles, event.cancelable);
11333
+ }
11334
+
11335
+ (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.dispatchEvent(newEvent);
11336
+ }
11337
+ }
11338
+ });
11339
+
11340
+ _callBackend.set(this, {
11341
+ writable: true,
11342
+ value: function value(func, sourceId, node, options) {
11343
+ return _classPrivateFieldGet(_this, _backends)[_classPrivateFieldGet(_this, _current)].instance[func](sourceId, node, options);
11344
+ }
11345
+ });
11346
+
11347
+ _connectBackend.set(this, {
11348
+ writable: true,
11349
+ value: function value(func, sourceId, node, options) {
11350
+ var nodeId = "".concat(func, "_").concat(sourceId);
11351
+
11352
+ var unsubscribe = _classPrivateFieldGet(_this, _callBackend).call(_this, func, sourceId, node, options);
11353
+
11354
+ _classPrivateFieldGet(_this, _nodes)[nodeId] = {
11355
+ func: func,
11356
+ args: [sourceId, node, options],
11357
+ unsubscribe: unsubscribe
11358
+ };
11359
+ return function () {
11360
+ _classPrivateFieldGet(_this, _nodes)[nodeId].unsubscribe();
11361
+
11362
+ delete _classPrivateFieldGet(_this, _nodes)[nodeId];
11363
+ };
11364
+ }
11365
+ });
11366
+
11367
+ if (!_options || !_options.backends || _options.backends.length < 1) {
11368
+ throw new Error("You must specify at least one Backend, if you are coming from 2.x.x (or don't understand this error)\n see this guide: https://github.com/louisbrunner/dnd-multi-backend/tree/master/packages/react-dnd-multi-backend#migrating-from-2xx");
11369
+ }
11370
+
11371
+ _classPrivateFieldSet(this, _previews, new PreviewListImpl());
11372
+
11373
+ _classPrivateFieldSet(this, _backends, {});
11374
+
11375
+ _classPrivateFieldSet(this, _backendsList, []);
11376
+
11377
+ _options.backends.forEach(function (backend) {
11378
+ var backendRecord = _classPrivateFieldGet(_this, _createBackend).call(_this, _manager, _context, backend);
11379
+
11380
+ _classPrivateFieldGet(_this, _backends)[backendRecord.id] = backendRecord;
11381
+
11382
+ _classPrivateFieldGet(_this, _backendsList).push(backendRecord);
11383
+ });
11384
+
11385
+ _classPrivateFieldSet(this, _current, _classPrivateFieldGet(this, _backendsList)[0].id);
11386
+
11387
+ _classPrivateFieldSet(this, _nodes, {});
11388
+ };
11389
+
11390
+ _defineProperty(MultiBackendImpl, "isSetUp", false);
11391
+
8589
11392
  /******************************************************************************
8590
11393
  Copyright (c) Microsoft Corporation.
8591
11394
 
@@ -9401,25 +12204,26 @@ var TreeView = function (_a, ref) {
9401
12204
  setShowTree(false);
9402
12205
  }
9403
12206
  }, [initialOpen, treeData]);
9404
- return (React__default["default"].createElement(React__default["default"].Fragment, null, showTree && (React__default["default"].createElement(Tree, { ref: ref, tree: list, classes: {
9405
- root: 'pl-0 ml-0 !border-l-0',
9406
- container: 'border-l pl-2 ml-3 border-l-gray-300 relative',
9407
- listItem: 'flex text-sm font-medium rounded-md flex-col',
9408
- dropTarget: 'classes-dropTarget',
9409
- draggingSource: 'classes-draggingSource',
9410
- placeholder: 'bg-purple-500 h-[2px] absolute w-[calc(100%-16px)] left-4'
9411
- }, rootId: 0, onDrop: handleDrop, sort: false, insertDroppableFirst: false, canDrop: function (tree, _a) {
9412
- var dragSource = _a.dragSource, dropTargetId = _a.dropTargetId;
9413
- if ((dragSource === null || dragSource === void 0 ? void 0 : dragSource.parent) === dropTargetId) {
9414
- return true;
9415
- }
9416
- }, initialOpen: openKeys, dropTargetOffset: 5, placeholderRender: function (node, _a) {
9417
- var depth = _a.depth;
9418
- return (React__default["default"].createElement(Placeholder, { node: node, depth: depth }));
9419
- }, render: function (node, _a) {
9420
- var depth = _a.depth, isOpen = _a.isOpen, onToggle = _a.onToggle;
9421
- return (React__default["default"].createElement(CustomNode, { node: node, depth: depth, isOpen: isOpen, onToggle: onToggle, onUpdate: handleUpdateList }));
9422
- } }))));
12207
+ return (React__default["default"].createElement(React__default["default"].Fragment, null,
12208
+ React__default["default"].createElement(DndProvider, { backend: HTML5Backend }, showTree && (React__default["default"].createElement(Tree, { ref: ref, tree: list, classes: {
12209
+ root: 'pl-0 ml-0 !border-l-0',
12210
+ container: 'border-l pl-2 ml-3 border-l-gray-300 relative',
12211
+ listItem: 'flex text-sm font-medium rounded-md flex-col',
12212
+ dropTarget: 'classes-dropTarget',
12213
+ draggingSource: 'classes-draggingSource',
12214
+ placeholder: 'bg-purple-500 h-[2px] absolute w-[calc(100%-16px)] left-4'
12215
+ }, rootId: 0, onDrop: handleDrop, sort: false, insertDroppableFirst: false, canDrop: function (tree, _a) {
12216
+ var dragSource = _a.dragSource, dropTargetId = _a.dropTargetId;
12217
+ if ((dragSource === null || dragSource === void 0 ? void 0 : dragSource.parent) === dropTargetId) {
12218
+ return true;
12219
+ }
12220
+ }, initialOpen: openKeys, dropTargetOffset: 5, placeholderRender: function (node, _a) {
12221
+ var depth = _a.depth;
12222
+ return (React__default["default"].createElement(Placeholder, { node: node, depth: depth }));
12223
+ }, render: function (node, _a) {
12224
+ var depth = _a.depth, isOpen = _a.isOpen, onToggle = _a.onToggle;
12225
+ return (React__default["default"].createElement(CustomNode, { node: node, depth: depth, isOpen: isOpen, onToggle: onToggle, onUpdate: handleUpdateList }));
12226
+ } })))));
9423
12227
  };
9424
12228
  var _TreeView = React.forwardRef(TreeView);
9425
12229