@rkmodules/rules 0.0.62 → 0.0.63

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/dist/index.cjs.js CHANGED
@@ -8,7 +8,6 @@ var classNames = require('classnames');
8
8
  var rcin = require('rc-input-number');
9
9
  var zustand = require('zustand');
10
10
  var middleware = require('zustand/middleware');
11
- var reactDndHtml5Backend = require('react-dnd-html5-backend');
12
11
  var jsxRuntime = require('react/jsx-runtime');
13
12
 
14
13
  /******************************************************************************
@@ -2091,7 +2090,7 @@ function isProduction() {
2091
2090
  }
2092
2091
  /**
2093
2092
  * drop-in replacement for _.without
2094
- */ function without(items, item) {
2093
+ */ function without$1(items, item) {
2095
2094
  return items.filter((i)=>i !== item
2096
2095
  );
2097
2096
  }
@@ -2225,7 +2224,7 @@ function getDraggableSource(sourceIds, monitor) {
2225
2224
  return sourceId;
2226
2225
  }
2227
2226
 
2228
- function _defineProperty$3(obj, key, value) {
2227
+ function _defineProperty$4(obj, key, value) {
2229
2228
  if (key in obj) {
2230
2229
  Object.defineProperty(obj, key, {
2231
2230
  value: value,
@@ -2238,7 +2237,7 @@ function _defineProperty$3(obj, key, value) {
2238
2237
  }
2239
2238
  return obj;
2240
2239
  }
2241
- function _objectSpread$3(target) {
2240
+ function _objectSpread$4(target) {
2242
2241
  for(var i = 1; i < arguments.length; i++){
2243
2242
  var source = arguments[i] != null ? arguments[i] : {};
2244
2243
  var ownKeys = Object.keys(source);
@@ -2248,7 +2247,7 @@ function _objectSpread$3(target) {
2248
2247
  }));
2249
2248
  }
2250
2249
  ownKeys.forEach(function(key) {
2251
- _defineProperty$3(target, key, source[key]);
2250
+ _defineProperty$4(target, key, source[key]);
2252
2251
  });
2253
2252
  }
2254
2253
  return target;
@@ -2265,7 +2264,7 @@ function createDrop(manager) {
2265
2264
  const action = {
2266
2265
  type: DROP,
2267
2266
  payload: {
2268
- dropResult: _objectSpread$3({}, options, dropResult)
2267
+ dropResult: _objectSpread$4({}, options, dropResult)
2269
2268
  }
2270
2269
  };
2271
2270
  manager.dispatch(action);
@@ -3180,7 +3179,7 @@ _state = NONE, action) {
3180
3179
  return result;
3181
3180
  }
3182
3181
 
3183
- function _defineProperty$2(obj, key, value) {
3182
+ function _defineProperty$3(obj, key, value) {
3184
3183
  if (key in obj) {
3185
3184
  Object.defineProperty(obj, key, {
3186
3185
  value: value,
@@ -3193,7 +3192,7 @@ function _defineProperty$2(obj, key, value) {
3193
3192
  }
3194
3193
  return obj;
3195
3194
  }
3196
- function _objectSpread$2(target) {
3195
+ function _objectSpread$3(target) {
3197
3196
  for(var i = 1; i < arguments.length; i++){
3198
3197
  var source = arguments[i] != null ? arguments[i] : {};
3199
3198
  var ownKeys = Object.keys(source);
@@ -3203,7 +3202,7 @@ function _objectSpread$2(target) {
3203
3202
  }));
3204
3203
  }
3205
3204
  ownKeys.forEach(function(key) {
3206
- _defineProperty$2(target, key, source[key]);
3205
+ _defineProperty$3(target, key, source[key]);
3207
3206
  });
3208
3207
  }
3209
3208
  return target;
@@ -3227,7 +3226,7 @@ function reduce$4(state = initialState$1, action) {
3227
3226
  if (areCoordsEqual(state.clientOffset, payload.clientOffset)) {
3228
3227
  return state;
3229
3228
  }
3230
- return _objectSpread$2({}, state, {
3229
+ return _objectSpread$3({}, state, {
3231
3230
  clientOffset: payload.clientOffset
3232
3231
  });
3233
3232
  case END_DRAG:
@@ -3238,7 +3237,7 @@ function reduce$4(state = initialState$1, action) {
3238
3237
  }
3239
3238
  }
3240
3239
 
3241
- function _defineProperty$1(obj, key, value) {
3240
+ function _defineProperty$2(obj, key, value) {
3242
3241
  if (key in obj) {
3243
3242
  Object.defineProperty(obj, key, {
3244
3243
  value: value,
@@ -3251,7 +3250,7 @@ function _defineProperty$1(obj, key, value) {
3251
3250
  }
3252
3251
  return obj;
3253
3252
  }
3254
- function _objectSpread$1(target) {
3253
+ function _objectSpread$2(target) {
3255
3254
  for(var i = 1; i < arguments.length; i++){
3256
3255
  var source = arguments[i] != null ? arguments[i] : {};
3257
3256
  var ownKeys = Object.keys(source);
@@ -3261,7 +3260,7 @@ function _objectSpread$1(target) {
3261
3260
  }));
3262
3261
  }
3263
3262
  ownKeys.forEach(function(key) {
3264
- _defineProperty$1(target, key, source[key]);
3263
+ _defineProperty$2(target, key, source[key]);
3265
3264
  });
3266
3265
  }
3267
3266
  return target;
@@ -3279,7 +3278,7 @@ function reduce$3(state = initialState, action) {
3279
3278
  const { payload } = action;
3280
3279
  switch(action.type){
3281
3280
  case BEGIN_DRAG:
3282
- return _objectSpread$1({}, state, {
3281
+ return _objectSpread$2({}, state, {
3283
3282
  itemType: payload.itemType,
3284
3283
  item: payload.item,
3285
3284
  sourceId: payload.sourceId,
@@ -3288,28 +3287,28 @@ function reduce$3(state = initialState, action) {
3288
3287
  didDrop: false
3289
3288
  });
3290
3289
  case PUBLISH_DRAG_SOURCE:
3291
- return _objectSpread$1({}, state, {
3290
+ return _objectSpread$2({}, state, {
3292
3291
  isSourcePublic: true
3293
3292
  });
3294
3293
  case HOVER:
3295
- return _objectSpread$1({}, state, {
3294
+ return _objectSpread$2({}, state, {
3296
3295
  targetIds: payload.targetIds
3297
3296
  });
3298
3297
  case REMOVE_TARGET:
3299
3298
  if (state.targetIds.indexOf(payload.targetId) === -1) {
3300
3299
  return state;
3301
3300
  }
3302
- return _objectSpread$1({}, state, {
3303
- targetIds: without(state.targetIds, payload.targetId)
3301
+ return _objectSpread$2({}, state, {
3302
+ targetIds: without$1(state.targetIds, payload.targetId)
3304
3303
  });
3305
3304
  case DROP:
3306
- return _objectSpread$1({}, state, {
3305
+ return _objectSpread$2({}, state, {
3307
3306
  dropResult: payload.dropResult,
3308
3307
  didDrop: true,
3309
3308
  targetIds: []
3310
3309
  });
3311
3310
  case END_DRAG:
3312
- return _objectSpread$1({}, state, {
3311
+ return _objectSpread$2({}, state, {
3313
3312
  itemType: null,
3314
3313
  item: null,
3315
3314
  sourceId: null,
@@ -3340,7 +3339,7 @@ function reduce$1(state = 0) {
3340
3339
  return state + 1;
3341
3340
  }
3342
3341
 
3343
- function _defineProperty(obj, key, value) {
3342
+ function _defineProperty$1(obj, key, value) {
3344
3343
  if (key in obj) {
3345
3344
  Object.defineProperty(obj, key, {
3346
3345
  value: value,
@@ -3353,7 +3352,7 @@ function _defineProperty(obj, key, value) {
3353
3352
  }
3354
3353
  return obj;
3355
3354
  }
3356
- function _objectSpread(target) {
3355
+ function _objectSpread$1(target) {
3357
3356
  for(var i = 1; i < arguments.length; i++){
3358
3357
  var source = arguments[i] != null ? arguments[i] : {};
3359
3358
  var ownKeys = Object.keys(source);
@@ -3363,7 +3362,7 @@ function _objectSpread(target) {
3363
3362
  }));
3364
3363
  }
3365
3364
  ownKeys.forEach(function(key) {
3366
- _defineProperty(target, key, source[key]);
3365
+ _defineProperty$1(target, key, source[key]);
3367
3366
  });
3368
3367
  }
3369
3368
  return target;
@@ -3372,7 +3371,7 @@ function reduce(state = {}, action) {
3372
3371
  return {
3373
3372
  dirtyHandlerIds: reduce$5(state.dirtyHandlerIds, {
3374
3373
  type: action.type,
3375
- payload: _objectSpread({}, action.payload, {
3374
+ payload: _objectSpread$1({}, action.payload, {
3376
3375
  prevTargetIds: get(state, 'dragOperation.targetIds', [])
3377
3376
  })
3378
3377
  }),
@@ -5144,9 +5143,987 @@ function useFunction(engine, fn, mount) {
5144
5143
  }); }, [builtFn, run, result]);
5145
5144
  }
5146
5145
 
5146
+ // cheap lodash replacements
5147
+ function memoize(fn) {
5148
+ let result = null;
5149
+ const memoized = ()=>{
5150
+ if (result == null) {
5151
+ result = fn();
5152
+ }
5153
+ return result;
5154
+ };
5155
+ return memoized;
5156
+ }
5157
+ /**
5158
+ * drop-in replacement for _.without
5159
+ */ function without(items, item) {
5160
+ return items.filter((i)=>i !== item
5161
+ );
5162
+ }
5163
+ function union(itemsA, itemsB) {
5164
+ const set = new Set();
5165
+ const insertItem = (item)=>set.add(item)
5166
+ ;
5167
+ itemsA.forEach(insertItem);
5168
+ itemsB.forEach(insertItem);
5169
+ const result = [];
5170
+ set.forEach((key)=>result.push(key)
5171
+ );
5172
+ return result;
5173
+ }
5174
+
5175
+ class EnterLeaveCounter {
5176
+ enter(enteringNode) {
5177
+ const previousLength = this.entered.length;
5178
+ const isNodeEntered = (node)=>this.isNodeInDocument(node) && (!node.contains || node.contains(enteringNode))
5179
+ ;
5180
+ this.entered = union(this.entered.filter(isNodeEntered), [
5181
+ enteringNode
5182
+ ]);
5183
+ return previousLength === 0 && this.entered.length > 0;
5184
+ }
5185
+ leave(leavingNode) {
5186
+ const previousLength = this.entered.length;
5187
+ this.entered = without(this.entered.filter(this.isNodeInDocument), leavingNode);
5188
+ return previousLength > 0 && this.entered.length === 0;
5189
+ }
5190
+ reset() {
5191
+ this.entered = [];
5192
+ }
5193
+ constructor(isNodeInDocument){
5194
+ this.entered = [];
5195
+ this.isNodeInDocument = isNodeInDocument;
5196
+ }
5197
+ }
5198
+
5199
+ class NativeDragSource {
5200
+ initializeExposedProperties() {
5201
+ Object.keys(this.config.exposeProperties).forEach((property)=>{
5202
+ Object.defineProperty(this.item, property, {
5203
+ configurable: true,
5204
+ enumerable: true,
5205
+ get () {
5206
+ // eslint-disable-next-line no-console
5207
+ console.warn(`Browser doesn't allow reading "${property}" until the drop event.`);
5208
+ return null;
5209
+ }
5210
+ });
5211
+ });
5212
+ }
5213
+ loadDataTransfer(dataTransfer) {
5214
+ if (dataTransfer) {
5215
+ const newProperties = {};
5216
+ Object.keys(this.config.exposeProperties).forEach((property)=>{
5217
+ const propertyFn = this.config.exposeProperties[property];
5218
+ if (propertyFn != null) {
5219
+ newProperties[property] = {
5220
+ value: propertyFn(dataTransfer, this.config.matchesTypes),
5221
+ configurable: true,
5222
+ enumerable: true
5223
+ };
5224
+ }
5225
+ });
5226
+ Object.defineProperties(this.item, newProperties);
5227
+ }
5228
+ }
5229
+ canDrag() {
5230
+ return true;
5231
+ }
5232
+ beginDrag() {
5233
+ return this.item;
5234
+ }
5235
+ isDragging(monitor, handle) {
5236
+ return handle === monitor.getSourceId();
5237
+ }
5238
+ endDrag() {
5239
+ // empty
5240
+ }
5241
+ constructor(config){
5242
+ this.config = config;
5243
+ this.item = {};
5244
+ this.initializeExposedProperties();
5245
+ }
5246
+ }
5247
+
5248
+ const FILE = '__NATIVE_FILE__';
5249
+ const URL = '__NATIVE_URL__';
5250
+ const TEXT = '__NATIVE_TEXT__';
5251
+ const HTML = '__NATIVE_HTML__';
5252
+
5253
+ var NativeTypes = /*#__PURE__*/Object.freeze({
5254
+ __proto__: null,
5255
+ FILE: FILE,
5256
+ HTML: HTML,
5257
+ TEXT: TEXT,
5258
+ URL: URL
5259
+ });
5260
+
5261
+ function getDataFromDataTransfer(dataTransfer, typesToTry, defaultValue) {
5262
+ const result = typesToTry.reduce((resultSoFar, typeToTry)=>resultSoFar || dataTransfer.getData(typeToTry)
5263
+ , '');
5264
+ return result != null ? result : defaultValue;
5265
+ }
5266
+
5267
+ const nativeTypesConfig = {
5268
+ [FILE]: {
5269
+ exposeProperties: {
5270
+ files: (dataTransfer)=>Array.prototype.slice.call(dataTransfer.files)
5271
+ ,
5272
+ items: (dataTransfer)=>dataTransfer.items
5273
+ ,
5274
+ dataTransfer: (dataTransfer)=>dataTransfer
5275
+ },
5276
+ matchesTypes: [
5277
+ 'Files'
5278
+ ]
5279
+ },
5280
+ [HTML]: {
5281
+ exposeProperties: {
5282
+ html: (dataTransfer, matchesTypes)=>getDataFromDataTransfer(dataTransfer, matchesTypes, '')
5283
+ ,
5284
+ dataTransfer: (dataTransfer)=>dataTransfer
5285
+ },
5286
+ matchesTypes: [
5287
+ 'Html',
5288
+ 'text/html'
5289
+ ]
5290
+ },
5291
+ [URL]: {
5292
+ exposeProperties: {
5293
+ urls: (dataTransfer, matchesTypes)=>getDataFromDataTransfer(dataTransfer, matchesTypes, '').split('\n')
5294
+ ,
5295
+ dataTransfer: (dataTransfer)=>dataTransfer
5296
+ },
5297
+ matchesTypes: [
5298
+ 'Url',
5299
+ 'text/uri-list'
5300
+ ]
5301
+ },
5302
+ [TEXT]: {
5303
+ exposeProperties: {
5304
+ text: (dataTransfer, matchesTypes)=>getDataFromDataTransfer(dataTransfer, matchesTypes, '')
5305
+ ,
5306
+ dataTransfer: (dataTransfer)=>dataTransfer
5307
+ },
5308
+ matchesTypes: [
5309
+ 'Text',
5310
+ 'text/plain'
5311
+ ]
5312
+ }
5313
+ };
5314
+
5315
+ function createNativeDragSource(type, dataTransfer) {
5316
+ const config = nativeTypesConfig[type];
5317
+ if (!config) {
5318
+ throw new Error(`native type ${type} has no configuration`);
5319
+ }
5320
+ const result = new NativeDragSource(config);
5321
+ result.loadDataTransfer(dataTransfer);
5322
+ return result;
5323
+ }
5324
+ function matchNativeItemType(dataTransfer) {
5325
+ if (!dataTransfer) {
5326
+ return null;
5327
+ }
5328
+ const dataTransferTypes = Array.prototype.slice.call(dataTransfer.types || []);
5329
+ return Object.keys(nativeTypesConfig).filter((nativeItemType)=>{
5330
+ const typeConfig = nativeTypesConfig[nativeItemType];
5331
+ if (!(typeConfig === null || typeConfig === void 0 ? void 0 : typeConfig.matchesTypes)) {
5332
+ return false;
5333
+ }
5334
+ return typeConfig.matchesTypes.some((t)=>dataTransferTypes.indexOf(t) > -1
5335
+ );
5336
+ })[0] || null;
5337
+ }
5338
+
5339
+ const isFirefox = memoize(()=>/firefox/i.test(navigator.userAgent)
5340
+ );
5341
+ const isSafari = memoize(()=>Boolean(window.safari)
5342
+ );
5343
+
5344
+ class MonotonicInterpolant {
5345
+ interpolate(x) {
5346
+ const { xs , ys , c1s , c2s , c3s } = this;
5347
+ // The rightmost point in the dataset should give an exact result
5348
+ let i = xs.length - 1;
5349
+ if (x === xs[i]) {
5350
+ return ys[i];
5351
+ }
5352
+ // Search for the interval x is in, returning the corresponding y if x is one of the original xs
5353
+ let low = 0;
5354
+ let high = c3s.length - 1;
5355
+ let mid;
5356
+ while(low <= high){
5357
+ mid = Math.floor(0.5 * (low + high));
5358
+ const xHere = xs[mid];
5359
+ if (xHere < x) {
5360
+ low = mid + 1;
5361
+ } else if (xHere > x) {
5362
+ high = mid - 1;
5363
+ } else {
5364
+ return ys[mid];
5365
+ }
5366
+ }
5367
+ i = Math.max(0, high);
5368
+ // Interpolate
5369
+ const diff = x - xs[i];
5370
+ const diffSq = diff * diff;
5371
+ return ys[i] + c1s[i] * diff + c2s[i] * diffSq + c3s[i] * diff * diffSq;
5372
+ }
5373
+ constructor(xs, ys){
5374
+ const { length } = xs;
5375
+ // Rearrange xs and ys so that xs is sorted
5376
+ const indexes = [];
5377
+ for(let i = 0; i < length; i++){
5378
+ indexes.push(i);
5379
+ }
5380
+ indexes.sort((a, b)=>xs[a] < xs[b] ? -1 : 1
5381
+ );
5382
+ const dxs = [];
5383
+ const ms = [];
5384
+ let dx;
5385
+ let dy;
5386
+ for(let i1 = 0; i1 < length - 1; i1++){
5387
+ dx = xs[i1 + 1] - xs[i1];
5388
+ dy = ys[i1 + 1] - ys[i1];
5389
+ dxs.push(dx);
5390
+ ms.push(dy / dx);
5391
+ }
5392
+ // Get degree-1 coefficients
5393
+ const c1s = [
5394
+ ms[0]
5395
+ ];
5396
+ for(let i2 = 0; i2 < dxs.length - 1; i2++){
5397
+ const m2 = ms[i2];
5398
+ const mNext = ms[i2 + 1];
5399
+ if (m2 * mNext <= 0) {
5400
+ c1s.push(0);
5401
+ } else {
5402
+ dx = dxs[i2];
5403
+ const dxNext = dxs[i2 + 1];
5404
+ const common = dx + dxNext;
5405
+ c1s.push(3 * common / ((common + dxNext) / m2 + (common + dx) / mNext));
5406
+ }
5407
+ }
5408
+ c1s.push(ms[ms.length - 1]);
5409
+ // Get degree-2 and degree-3 coefficients
5410
+ const c2s = [];
5411
+ const c3s = [];
5412
+ let m;
5413
+ for(let i3 = 0; i3 < c1s.length - 1; i3++){
5414
+ m = ms[i3];
5415
+ const c1 = c1s[i3];
5416
+ const invDx = 1 / dxs[i3];
5417
+ const common = c1 + c1s[i3 + 1] - m - m;
5418
+ c2s.push((m - c1 - common) * invDx);
5419
+ c3s.push(common * invDx * invDx);
5420
+ }
5421
+ this.xs = xs;
5422
+ this.ys = ys;
5423
+ this.c1s = c1s;
5424
+ this.c2s = c2s;
5425
+ this.c3s = c3s;
5426
+ }
5427
+ }
5428
+
5429
+ const ELEMENT_NODE = 1;
5430
+ function getNodeClientOffset(node) {
5431
+ const el = node.nodeType === ELEMENT_NODE ? node : node.parentElement;
5432
+ if (!el) {
5433
+ return null;
5434
+ }
5435
+ const { top , left } = el.getBoundingClientRect();
5436
+ return {
5437
+ x: left,
5438
+ y: top
5439
+ };
5440
+ }
5441
+ function getEventClientOffset(e) {
5442
+ return {
5443
+ x: e.clientX,
5444
+ y: e.clientY
5445
+ };
5446
+ }
5447
+ function isImageNode(node) {
5448
+ var ref;
5449
+ return node.nodeName === 'IMG' && (isFirefox() || !((ref = document.documentElement) === null || ref === void 0 ? void 0 : ref.contains(node)));
5450
+ }
5451
+ function getDragPreviewSize(isImage, dragPreview, sourceWidth, sourceHeight) {
5452
+ let dragPreviewWidth = isImage ? dragPreview.width : sourceWidth;
5453
+ let dragPreviewHeight = isImage ? dragPreview.height : sourceHeight;
5454
+ // Work around @2x coordinate discrepancies in browsers
5455
+ if (isSafari() && isImage) {
5456
+ dragPreviewHeight /= window.devicePixelRatio;
5457
+ dragPreviewWidth /= window.devicePixelRatio;
5458
+ }
5459
+ return {
5460
+ dragPreviewWidth,
5461
+ dragPreviewHeight
5462
+ };
5463
+ }
5464
+ function getDragPreviewOffset(sourceNode, dragPreview, clientOffset, anchorPoint, offsetPoint) {
5465
+ // The browsers will use the image intrinsic size under different conditions.
5466
+ // Firefox only cares if it's an image, but WebKit also wants it to be detached.
5467
+ const isImage = isImageNode(dragPreview);
5468
+ const dragPreviewNode = isImage ? sourceNode : dragPreview;
5469
+ const dragPreviewNodeOffsetFromClient = getNodeClientOffset(dragPreviewNode);
5470
+ const offsetFromDragPreview = {
5471
+ x: clientOffset.x - dragPreviewNodeOffsetFromClient.x,
5472
+ y: clientOffset.y - dragPreviewNodeOffsetFromClient.y
5473
+ };
5474
+ const { offsetWidth: sourceWidth , offsetHeight: sourceHeight } = sourceNode;
5475
+ const { anchorX , anchorY } = anchorPoint;
5476
+ const { dragPreviewWidth , dragPreviewHeight } = getDragPreviewSize(isImage, dragPreview, sourceWidth, sourceHeight);
5477
+ const calculateYOffset = ()=>{
5478
+ const interpolantY = new MonotonicInterpolant([
5479
+ 0,
5480
+ 0.5,
5481
+ 1
5482
+ ], [
5483
+ // Dock to the top
5484
+ offsetFromDragPreview.y,
5485
+ // Align at the center
5486
+ (offsetFromDragPreview.y / sourceHeight) * dragPreviewHeight,
5487
+ // Dock to the bottom
5488
+ offsetFromDragPreview.y + dragPreviewHeight - sourceHeight,
5489
+ ]);
5490
+ let y = interpolantY.interpolate(anchorY);
5491
+ // Work around Safari 8 positioning bug
5492
+ if (isSafari() && isImage) {
5493
+ // We'll have to wait for @3x to see if this is entirely correct
5494
+ y += (window.devicePixelRatio - 1) * dragPreviewHeight;
5495
+ }
5496
+ return y;
5497
+ };
5498
+ const calculateXOffset = ()=>{
5499
+ // Interpolate coordinates depending on anchor point
5500
+ // If you know a simpler way to do this, let me know
5501
+ const interpolantX = new MonotonicInterpolant([
5502
+ 0,
5503
+ 0.5,
5504
+ 1
5505
+ ], [
5506
+ // Dock to the left
5507
+ offsetFromDragPreview.x,
5508
+ // Align at the center
5509
+ (offsetFromDragPreview.x / sourceWidth) * dragPreviewWidth,
5510
+ // Dock to the right
5511
+ offsetFromDragPreview.x + dragPreviewWidth - sourceWidth,
5512
+ ]);
5513
+ return interpolantX.interpolate(anchorX);
5514
+ };
5515
+ // Force offsets if specified in the options.
5516
+ const { offsetX , offsetY } = offsetPoint;
5517
+ const isManualOffsetX = offsetX === 0 || offsetX;
5518
+ const isManualOffsetY = offsetY === 0 || offsetY;
5519
+ return {
5520
+ x: isManualOffsetX ? offsetX : calculateXOffset(),
5521
+ y: isManualOffsetY ? offsetY : calculateYOffset()
5522
+ };
5523
+ }
5524
+
5525
+ class OptionsReader {
5526
+ get window() {
5527
+ if (this.globalContext) {
5528
+ return this.globalContext;
5529
+ } else if (typeof window !== 'undefined') {
5530
+ return window;
5531
+ }
5532
+ return undefined;
5533
+ }
5534
+ get document() {
5535
+ var ref;
5536
+ if ((ref = this.globalContext) === null || ref === void 0 ? void 0 : ref.document) {
5537
+ return this.globalContext.document;
5538
+ } else if (this.window) {
5539
+ return this.window.document;
5540
+ } else {
5541
+ return undefined;
5542
+ }
5543
+ }
5544
+ get rootElement() {
5545
+ var ref;
5546
+ return ((ref = this.optionsArgs) === null || ref === void 0 ? void 0 : ref.rootElement) || this.window;
5547
+ }
5548
+ constructor(globalContext, options){
5549
+ this.ownerDocument = null;
5550
+ this.globalContext = globalContext;
5551
+ this.optionsArgs = options;
5552
+ }
5553
+ }
5554
+
5555
+ function _defineProperty(obj, key, value) {
5556
+ if (key in obj) {
5557
+ Object.defineProperty(obj, key, {
5558
+ value: value,
5559
+ enumerable: true,
5560
+ configurable: true,
5561
+ writable: true
5562
+ });
5563
+ } else {
5564
+ obj[key] = value;
5565
+ }
5566
+ return obj;
5567
+ }
5568
+ function _objectSpread(target) {
5569
+ for(var i = 1; i < arguments.length; i++){
5570
+ var source = arguments[i] != null ? arguments[i] : {};
5571
+ var ownKeys = Object.keys(source);
5572
+ if (typeof Object.getOwnPropertySymbols === 'function') {
5573
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
5574
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
5575
+ }));
5576
+ }
5577
+ ownKeys.forEach(function(key) {
5578
+ _defineProperty(target, key, source[key]);
5579
+ });
5580
+ }
5581
+ return target;
5582
+ }
5583
+ class HTML5BackendImpl {
5584
+ /**
5585
+ * Generate profiling statistics for the HTML5Backend.
5586
+ */ profile() {
5587
+ var ref, ref1;
5588
+ return {
5589
+ sourcePreviewNodes: this.sourcePreviewNodes.size,
5590
+ sourcePreviewNodeOptions: this.sourcePreviewNodeOptions.size,
5591
+ sourceNodeOptions: this.sourceNodeOptions.size,
5592
+ sourceNodes: this.sourceNodes.size,
5593
+ dragStartSourceIds: ((ref = this.dragStartSourceIds) === null || ref === void 0 ? void 0 : ref.length) || 0,
5594
+ dropTargetIds: this.dropTargetIds.length,
5595
+ dragEnterTargetIds: this.dragEnterTargetIds.length,
5596
+ dragOverTargetIds: ((ref1 = this.dragOverTargetIds) === null || ref1 === void 0 ? void 0 : ref1.length) || 0
5597
+ };
5598
+ }
5599
+ // public for test
5600
+ get window() {
5601
+ return this.options.window;
5602
+ }
5603
+ get document() {
5604
+ return this.options.document;
5605
+ }
5606
+ /**
5607
+ * Get the root element to use for event subscriptions
5608
+ */ get rootElement() {
5609
+ return this.options.rootElement;
5610
+ }
5611
+ setup() {
5612
+ const root = this.rootElement;
5613
+ if (root === undefined) {
5614
+ return;
5615
+ }
5616
+ if (root.__isReactDndBackendSetUp) {
5617
+ throw new Error('Cannot have two HTML5 backends at the same time.');
5618
+ }
5619
+ root.__isReactDndBackendSetUp = true;
5620
+ this.addEventListeners(root);
5621
+ }
5622
+ teardown() {
5623
+ const root = this.rootElement;
5624
+ if (root === undefined) {
5625
+ return;
5626
+ }
5627
+ root.__isReactDndBackendSetUp = false;
5628
+ this.removeEventListeners(this.rootElement);
5629
+ this.clearCurrentDragSourceNode();
5630
+ if (this.asyncEndDragFrameId) {
5631
+ var ref;
5632
+ (ref = this.window) === null || ref === void 0 ? void 0 : ref.cancelAnimationFrame(this.asyncEndDragFrameId);
5633
+ }
5634
+ }
5635
+ connectDragPreview(sourceId, node, options) {
5636
+ this.sourcePreviewNodeOptions.set(sourceId, options);
5637
+ this.sourcePreviewNodes.set(sourceId, node);
5638
+ return ()=>{
5639
+ this.sourcePreviewNodes.delete(sourceId);
5640
+ this.sourcePreviewNodeOptions.delete(sourceId);
5641
+ };
5642
+ }
5643
+ connectDragSource(sourceId, node, options) {
5644
+ this.sourceNodes.set(sourceId, node);
5645
+ this.sourceNodeOptions.set(sourceId, options);
5646
+ const handleDragStart = (e)=>this.handleDragStart(e, sourceId)
5647
+ ;
5648
+ const handleSelectStart = (e)=>this.handleSelectStart(e)
5649
+ ;
5650
+ node.setAttribute('draggable', 'true');
5651
+ node.addEventListener('dragstart', handleDragStart);
5652
+ node.addEventListener('selectstart', handleSelectStart);
5653
+ return ()=>{
5654
+ this.sourceNodes.delete(sourceId);
5655
+ this.sourceNodeOptions.delete(sourceId);
5656
+ node.removeEventListener('dragstart', handleDragStart);
5657
+ node.removeEventListener('selectstart', handleSelectStart);
5658
+ node.setAttribute('draggable', 'false');
5659
+ };
5660
+ }
5661
+ connectDropTarget(targetId, node) {
5662
+ const handleDragEnter = (e)=>this.handleDragEnter(e, targetId)
5663
+ ;
5664
+ const handleDragOver = (e)=>this.handleDragOver(e, targetId)
5665
+ ;
5666
+ const handleDrop = (e)=>this.handleDrop(e, targetId)
5667
+ ;
5668
+ node.addEventListener('dragenter', handleDragEnter);
5669
+ node.addEventListener('dragover', handleDragOver);
5670
+ node.addEventListener('drop', handleDrop);
5671
+ return ()=>{
5672
+ node.removeEventListener('dragenter', handleDragEnter);
5673
+ node.removeEventListener('dragover', handleDragOver);
5674
+ node.removeEventListener('drop', handleDrop);
5675
+ };
5676
+ }
5677
+ addEventListeners(target) {
5678
+ // SSR Fix (https://github.com/react-dnd/react-dnd/pull/813
5679
+ if (!target.addEventListener) {
5680
+ return;
5681
+ }
5682
+ target.addEventListener('dragstart', this.handleTopDragStart);
5683
+ target.addEventListener('dragstart', this.handleTopDragStartCapture, true);
5684
+ target.addEventListener('dragend', this.handleTopDragEndCapture, true);
5685
+ target.addEventListener('dragenter', this.handleTopDragEnter);
5686
+ target.addEventListener('dragenter', this.handleTopDragEnterCapture, true);
5687
+ target.addEventListener('dragleave', this.handleTopDragLeaveCapture, true);
5688
+ target.addEventListener('dragover', this.handleTopDragOver);
5689
+ target.addEventListener('dragover', this.handleTopDragOverCapture, true);
5690
+ target.addEventListener('drop', this.handleTopDrop);
5691
+ target.addEventListener('drop', this.handleTopDropCapture, true);
5692
+ }
5693
+ removeEventListeners(target) {
5694
+ // SSR Fix (https://github.com/react-dnd/react-dnd/pull/813
5695
+ if (!target.removeEventListener) {
5696
+ return;
5697
+ }
5698
+ target.removeEventListener('dragstart', this.handleTopDragStart);
5699
+ target.removeEventListener('dragstart', this.handleTopDragStartCapture, true);
5700
+ target.removeEventListener('dragend', this.handleTopDragEndCapture, true);
5701
+ target.removeEventListener('dragenter', this.handleTopDragEnter);
5702
+ target.removeEventListener('dragenter', this.handleTopDragEnterCapture, true);
5703
+ target.removeEventListener('dragleave', this.handleTopDragLeaveCapture, true);
5704
+ target.removeEventListener('dragover', this.handleTopDragOver);
5705
+ target.removeEventListener('dragover', this.handleTopDragOverCapture, true);
5706
+ target.removeEventListener('drop', this.handleTopDrop);
5707
+ target.removeEventListener('drop', this.handleTopDropCapture, true);
5708
+ }
5709
+ getCurrentSourceNodeOptions() {
5710
+ const sourceId = this.monitor.getSourceId();
5711
+ const sourceNodeOptions = this.sourceNodeOptions.get(sourceId);
5712
+ return _objectSpread({
5713
+ dropEffect: this.altKeyPressed ? 'copy' : 'move'
5714
+ }, sourceNodeOptions || {});
5715
+ }
5716
+ getCurrentDropEffect() {
5717
+ if (this.isDraggingNativeItem()) {
5718
+ // It makes more sense to default to 'copy' for native resources
5719
+ return 'copy';
5720
+ }
5721
+ return this.getCurrentSourceNodeOptions().dropEffect;
5722
+ }
5723
+ getCurrentSourcePreviewNodeOptions() {
5724
+ const sourceId = this.monitor.getSourceId();
5725
+ const sourcePreviewNodeOptions = this.sourcePreviewNodeOptions.get(sourceId);
5726
+ return _objectSpread({
5727
+ anchorX: 0.5,
5728
+ anchorY: 0.5,
5729
+ captureDraggingState: false
5730
+ }, sourcePreviewNodeOptions || {});
5731
+ }
5732
+ isDraggingNativeItem() {
5733
+ const itemType = this.monitor.getItemType();
5734
+ return Object.keys(NativeTypes).some((key)=>NativeTypes[key] === itemType
5735
+ );
5736
+ }
5737
+ beginDragNativeItem(type, dataTransfer) {
5738
+ this.clearCurrentDragSourceNode();
5739
+ this.currentNativeSource = createNativeDragSource(type, dataTransfer);
5740
+ this.currentNativeHandle = this.registry.addSource(type, this.currentNativeSource);
5741
+ this.actions.beginDrag([
5742
+ this.currentNativeHandle
5743
+ ]);
5744
+ }
5745
+ setCurrentDragSourceNode(node) {
5746
+ this.clearCurrentDragSourceNode();
5747
+ this.currentDragSourceNode = node;
5748
+ // A timeout of > 0 is necessary to resolve Firefox issue referenced
5749
+ // See:
5750
+ // * https://github.com/react-dnd/react-dnd/pull/928
5751
+ // * https://github.com/react-dnd/react-dnd/issues/869
5752
+ const MOUSE_MOVE_TIMEOUT = 1000;
5753
+ // Receiving a mouse event in the middle of a dragging operation
5754
+ // means it has ended and the drag source node disappeared from DOM,
5755
+ // so the browser didn't dispatch the dragend event.
5756
+ //
5757
+ // We need to wait before we start listening for mousemove events.
5758
+ // This is needed because the drag preview needs to be drawn or else it fires an 'mousemove' event
5759
+ // immediately in some browsers.
5760
+ //
5761
+ // See:
5762
+ // * https://github.com/react-dnd/react-dnd/pull/928
5763
+ // * https://github.com/react-dnd/react-dnd/issues/869
5764
+ //
5765
+ this.mouseMoveTimeoutTimer = setTimeout(()=>{
5766
+ var ref;
5767
+ return (ref = this.rootElement) === null || ref === void 0 ? void 0 : ref.addEventListener('mousemove', this.endDragIfSourceWasRemovedFromDOM, true);
5768
+ }, MOUSE_MOVE_TIMEOUT);
5769
+ }
5770
+ clearCurrentDragSourceNode() {
5771
+ if (this.currentDragSourceNode) {
5772
+ this.currentDragSourceNode = null;
5773
+ if (this.rootElement) {
5774
+ var ref;
5775
+ (ref = this.window) === null || ref === void 0 ? void 0 : ref.clearTimeout(this.mouseMoveTimeoutTimer || undefined);
5776
+ this.rootElement.removeEventListener('mousemove', this.endDragIfSourceWasRemovedFromDOM, true);
5777
+ }
5778
+ this.mouseMoveTimeoutTimer = null;
5779
+ return true;
5780
+ }
5781
+ return false;
5782
+ }
5783
+ handleDragStart(e, sourceId) {
5784
+ if (e.defaultPrevented) {
5785
+ return;
5786
+ }
5787
+ if (!this.dragStartSourceIds) {
5788
+ this.dragStartSourceIds = [];
5789
+ }
5790
+ this.dragStartSourceIds.unshift(sourceId);
5791
+ }
5792
+ handleDragEnter(_e, targetId) {
5793
+ this.dragEnterTargetIds.unshift(targetId);
5794
+ }
5795
+ handleDragOver(_e, targetId) {
5796
+ if (this.dragOverTargetIds === null) {
5797
+ this.dragOverTargetIds = [];
5798
+ }
5799
+ this.dragOverTargetIds.unshift(targetId);
5800
+ }
5801
+ handleDrop(_e, targetId) {
5802
+ this.dropTargetIds.unshift(targetId);
5803
+ }
5804
+ constructor(manager, globalContext, options){
5805
+ this.sourcePreviewNodes = new Map();
5806
+ this.sourcePreviewNodeOptions = new Map();
5807
+ this.sourceNodes = new Map();
5808
+ this.sourceNodeOptions = new Map();
5809
+ this.dragStartSourceIds = null;
5810
+ this.dropTargetIds = [];
5811
+ this.dragEnterTargetIds = [];
5812
+ this.currentNativeSource = null;
5813
+ this.currentNativeHandle = null;
5814
+ this.currentDragSourceNode = null;
5815
+ this.altKeyPressed = false;
5816
+ this.mouseMoveTimeoutTimer = null;
5817
+ this.asyncEndDragFrameId = null;
5818
+ this.dragOverTargetIds = null;
5819
+ this.lastClientOffset = null;
5820
+ this.hoverRafId = null;
5821
+ this.getSourceClientOffset = (sourceId)=>{
5822
+ const source = this.sourceNodes.get(sourceId);
5823
+ return source && getNodeClientOffset(source) || null;
5824
+ };
5825
+ this.endDragNativeItem = ()=>{
5826
+ if (!this.isDraggingNativeItem()) {
5827
+ return;
5828
+ }
5829
+ this.actions.endDrag();
5830
+ if (this.currentNativeHandle) {
5831
+ this.registry.removeSource(this.currentNativeHandle);
5832
+ }
5833
+ this.currentNativeHandle = null;
5834
+ this.currentNativeSource = null;
5835
+ };
5836
+ this.isNodeInDocument = (node)=>{
5837
+ // Check the node either in the main document or in the current context
5838
+ return Boolean(node && this.document && this.document.body && this.document.body.contains(node));
5839
+ };
5840
+ this.endDragIfSourceWasRemovedFromDOM = ()=>{
5841
+ const node = this.currentDragSourceNode;
5842
+ if (node == null || this.isNodeInDocument(node)) {
5843
+ return;
5844
+ }
5845
+ if (this.clearCurrentDragSourceNode() && this.monitor.isDragging()) {
5846
+ this.actions.endDrag();
5847
+ }
5848
+ this.cancelHover();
5849
+ };
5850
+ this.scheduleHover = (dragOverTargetIds)=>{
5851
+ if (this.hoverRafId === null && typeof requestAnimationFrame !== 'undefined') {
5852
+ this.hoverRafId = requestAnimationFrame(()=>{
5853
+ if (this.monitor.isDragging()) {
5854
+ this.actions.hover(dragOverTargetIds || [], {
5855
+ clientOffset: this.lastClientOffset
5856
+ });
5857
+ }
5858
+ this.hoverRafId = null;
5859
+ });
5860
+ }
5861
+ };
5862
+ this.cancelHover = ()=>{
5863
+ if (this.hoverRafId !== null && typeof cancelAnimationFrame !== 'undefined') {
5864
+ cancelAnimationFrame(this.hoverRafId);
5865
+ this.hoverRafId = null;
5866
+ }
5867
+ };
5868
+ this.handleTopDragStartCapture = ()=>{
5869
+ this.clearCurrentDragSourceNode();
5870
+ this.dragStartSourceIds = [];
5871
+ };
5872
+ this.handleTopDragStart = (e)=>{
5873
+ if (e.defaultPrevented) {
5874
+ return;
5875
+ }
5876
+ const { dragStartSourceIds } = this;
5877
+ this.dragStartSourceIds = null;
5878
+ const clientOffset = getEventClientOffset(e);
5879
+ // Avoid crashing if we missed a drop event or our previous drag died
5880
+ if (this.monitor.isDragging()) {
5881
+ this.actions.endDrag();
5882
+ this.cancelHover();
5883
+ }
5884
+ // Don't publish the source just yet (see why below)
5885
+ this.actions.beginDrag(dragStartSourceIds || [], {
5886
+ publishSource: false,
5887
+ getSourceClientOffset: this.getSourceClientOffset,
5888
+ clientOffset
5889
+ });
5890
+ const { dataTransfer } = e;
5891
+ const nativeType = matchNativeItemType(dataTransfer);
5892
+ if (this.monitor.isDragging()) {
5893
+ if (dataTransfer && typeof dataTransfer.setDragImage === 'function') {
5894
+ // Use custom drag image if user specifies it.
5895
+ // If child drag source refuses drag but parent agrees,
5896
+ // use parent's node as drag image. Neither works in IE though.
5897
+ const sourceId = this.monitor.getSourceId();
5898
+ const sourceNode = this.sourceNodes.get(sourceId);
5899
+ const dragPreview = this.sourcePreviewNodes.get(sourceId) || sourceNode;
5900
+ if (dragPreview) {
5901
+ const { anchorX , anchorY , offsetX , offsetY } = this.getCurrentSourcePreviewNodeOptions();
5902
+ const anchorPoint = {
5903
+ anchorX,
5904
+ anchorY
5905
+ };
5906
+ const offsetPoint = {
5907
+ offsetX,
5908
+ offsetY
5909
+ };
5910
+ const dragPreviewOffset = getDragPreviewOffset(sourceNode, dragPreview, clientOffset, anchorPoint, offsetPoint);
5911
+ dataTransfer.setDragImage(dragPreview, dragPreviewOffset.x, dragPreviewOffset.y);
5912
+ }
5913
+ }
5914
+ try {
5915
+ // Firefox won't drag without setting data
5916
+ dataTransfer === null || dataTransfer === void 0 ? void 0 : dataTransfer.setData('application/json', {});
5917
+ } catch (err) {
5918
+ // IE doesn't support MIME types in setData
5919
+ }
5920
+ // Store drag source node so we can check whether
5921
+ // it is removed from DOM and trigger endDrag manually.
5922
+ this.setCurrentDragSourceNode(e.target);
5923
+ // Now we are ready to publish the drag source.. or are we not?
5924
+ const { captureDraggingState } = this.getCurrentSourcePreviewNodeOptions();
5925
+ if (!captureDraggingState) {
5926
+ // Usually we want to publish it in the next tick so that browser
5927
+ // is able to screenshot the current (not yet dragging) state.
5928
+ //
5929
+ // It also neatly avoids a situation where render() returns null
5930
+ // in the same tick for the source element, and browser freaks out.
5931
+ setTimeout(()=>this.actions.publishDragSource()
5932
+ , 0);
5933
+ } else {
5934
+ // In some cases the user may want to override this behavior, e.g.
5935
+ // to work around IE not supporting custom drag previews.
5936
+ //
5937
+ // When using a custom drag layer, the only way to prevent
5938
+ // the default drag preview from drawing in IE is to screenshot
5939
+ // the dragging state in which the node itself has zero opacity
5940
+ // and height. In this case, though, returning null from render()
5941
+ // will abruptly end the dragging, which is not obvious.
5942
+ //
5943
+ // This is the reason such behavior is strictly opt-in.
5944
+ this.actions.publishDragSource();
5945
+ }
5946
+ } else if (nativeType) {
5947
+ // A native item (such as URL) dragged from inside the document
5948
+ this.beginDragNativeItem(nativeType);
5949
+ } else if (dataTransfer && !dataTransfer.types && (e.target && !e.target.hasAttribute || !e.target.hasAttribute('draggable'))) {
5950
+ // Looks like a Safari bug: dataTransfer.types is null, but there was no draggable.
5951
+ // Just let it drag. It's a native type (URL or text) and will be picked up in
5952
+ // dragenter handler.
5953
+ return;
5954
+ } else {
5955
+ // If by this time no drag source reacted, tell browser not to drag.
5956
+ e.preventDefault();
5957
+ }
5958
+ };
5959
+ this.handleTopDragEndCapture = ()=>{
5960
+ if (this.clearCurrentDragSourceNode() && this.monitor.isDragging()) {
5961
+ // Firefox can dispatch this event in an infinite loop
5962
+ // if dragend handler does something like showing an alert.
5963
+ // Only proceed if we have not handled it already.
5964
+ this.actions.endDrag();
5965
+ }
5966
+ this.cancelHover();
5967
+ };
5968
+ this.handleTopDragEnterCapture = (e)=>{
5969
+ this.dragEnterTargetIds = [];
5970
+ if (this.isDraggingNativeItem()) {
5971
+ var ref;
5972
+ (ref = this.currentNativeSource) === null || ref === void 0 ? void 0 : ref.loadDataTransfer(e.dataTransfer);
5973
+ }
5974
+ const isFirstEnter = this.enterLeaveCounter.enter(e.target);
5975
+ if (!isFirstEnter || this.monitor.isDragging()) {
5976
+ return;
5977
+ }
5978
+ const { dataTransfer } = e;
5979
+ const nativeType = matchNativeItemType(dataTransfer);
5980
+ if (nativeType) {
5981
+ // A native item (such as file or URL) dragged from outside the document
5982
+ this.beginDragNativeItem(nativeType, dataTransfer);
5983
+ }
5984
+ };
5985
+ this.handleTopDragEnter = (e)=>{
5986
+ const { dragEnterTargetIds } = this;
5987
+ this.dragEnterTargetIds = [];
5988
+ if (!this.monitor.isDragging()) {
5989
+ // This is probably a native item type we don't understand.
5990
+ return;
5991
+ }
5992
+ this.altKeyPressed = e.altKey;
5993
+ // If the target changes position as the result of `dragenter`, `dragover` might still
5994
+ // get dispatched despite target being no longer there. The easy solution is to check
5995
+ // whether there actually is a target before firing `hover`.
5996
+ if (dragEnterTargetIds.length > 0) {
5997
+ this.actions.hover(dragEnterTargetIds, {
5998
+ clientOffset: getEventClientOffset(e)
5999
+ });
6000
+ }
6001
+ const canDrop = dragEnterTargetIds.some((targetId)=>this.monitor.canDropOnTarget(targetId)
6002
+ );
6003
+ if (canDrop) {
6004
+ // IE requires this to fire dragover events
6005
+ e.preventDefault();
6006
+ if (e.dataTransfer) {
6007
+ e.dataTransfer.dropEffect = this.getCurrentDropEffect();
6008
+ }
6009
+ }
6010
+ };
6011
+ this.handleTopDragOverCapture = (e)=>{
6012
+ this.dragOverTargetIds = [];
6013
+ if (this.isDraggingNativeItem()) {
6014
+ var ref;
6015
+ (ref = this.currentNativeSource) === null || ref === void 0 ? void 0 : ref.loadDataTransfer(e.dataTransfer);
6016
+ }
6017
+ };
6018
+ this.handleTopDragOver = (e)=>{
6019
+ const { dragOverTargetIds } = this;
6020
+ this.dragOverTargetIds = [];
6021
+ if (!this.monitor.isDragging()) {
6022
+ // This is probably a native item type we don't understand.
6023
+ // Prevent default "drop and blow away the whole document" action.
6024
+ e.preventDefault();
6025
+ if (e.dataTransfer) {
6026
+ e.dataTransfer.dropEffect = 'none';
6027
+ }
6028
+ return;
6029
+ }
6030
+ this.altKeyPressed = e.altKey;
6031
+ this.lastClientOffset = getEventClientOffset(e);
6032
+ this.scheduleHover(dragOverTargetIds);
6033
+ const canDrop = (dragOverTargetIds || []).some((targetId)=>this.monitor.canDropOnTarget(targetId)
6034
+ );
6035
+ if (canDrop) {
6036
+ // Show user-specified drop effect.
6037
+ e.preventDefault();
6038
+ if (e.dataTransfer) {
6039
+ e.dataTransfer.dropEffect = this.getCurrentDropEffect();
6040
+ }
6041
+ } else if (this.isDraggingNativeItem()) {
6042
+ // Don't show a nice cursor but still prevent default
6043
+ // "drop and blow away the whole document" action.
6044
+ e.preventDefault();
6045
+ } else {
6046
+ e.preventDefault();
6047
+ if (e.dataTransfer) {
6048
+ e.dataTransfer.dropEffect = 'none';
6049
+ }
6050
+ }
6051
+ };
6052
+ this.handleTopDragLeaveCapture = (e)=>{
6053
+ if (this.isDraggingNativeItem()) {
6054
+ e.preventDefault();
6055
+ }
6056
+ const isLastLeave = this.enterLeaveCounter.leave(e.target);
6057
+ if (!isLastLeave) {
6058
+ return;
6059
+ }
6060
+ if (this.isDraggingNativeItem()) {
6061
+ setTimeout(()=>this.endDragNativeItem()
6062
+ , 0);
6063
+ }
6064
+ this.cancelHover();
6065
+ };
6066
+ this.handleTopDropCapture = (e)=>{
6067
+ this.dropTargetIds = [];
6068
+ if (this.isDraggingNativeItem()) {
6069
+ var ref;
6070
+ e.preventDefault();
6071
+ (ref = this.currentNativeSource) === null || ref === void 0 ? void 0 : ref.loadDataTransfer(e.dataTransfer);
6072
+ } else if (matchNativeItemType(e.dataTransfer)) {
6073
+ // Dragging some elements, like <a> and <img> may still behave like a native drag event,
6074
+ // even if the current drag event matches a user-defined type.
6075
+ // Stop the default behavior when we're not expecting a native item to be dropped.
6076
+ e.preventDefault();
6077
+ }
6078
+ this.enterLeaveCounter.reset();
6079
+ };
6080
+ this.handleTopDrop = (e)=>{
6081
+ const { dropTargetIds } = this;
6082
+ this.dropTargetIds = [];
6083
+ this.actions.hover(dropTargetIds, {
6084
+ clientOffset: getEventClientOffset(e)
6085
+ });
6086
+ this.actions.drop({
6087
+ dropEffect: this.getCurrentDropEffect()
6088
+ });
6089
+ if (this.isDraggingNativeItem()) {
6090
+ this.endDragNativeItem();
6091
+ } else if (this.monitor.isDragging()) {
6092
+ this.actions.endDrag();
6093
+ }
6094
+ this.cancelHover();
6095
+ };
6096
+ this.handleSelectStart = (e)=>{
6097
+ const target = e.target;
6098
+ // Only IE requires us to explicitly say
6099
+ // we want drag drop operation to start
6100
+ if (typeof target.dragDrop !== 'function') {
6101
+ return;
6102
+ }
6103
+ // Inputs and textareas should be selectable
6104
+ if (target.tagName === 'INPUT' || target.tagName === 'SELECT' || target.tagName === 'TEXTAREA' || target.isContentEditable) {
6105
+ return;
6106
+ }
6107
+ // For other targets, ask IE
6108
+ // to enable drag and drop
6109
+ e.preventDefault();
6110
+ target.dragDrop();
6111
+ };
6112
+ this.options = new OptionsReader(globalContext, options);
6113
+ this.actions = manager.getActions();
6114
+ this.monitor = manager.getMonitor();
6115
+ this.registry = manager.getRegistry();
6116
+ this.enterLeaveCounter = new EnterLeaveCounter(this.isNodeInDocument);
6117
+ }
6118
+ }
6119
+
6120
+ const HTML5Backend = function createBackend(manager, context, options) {
6121
+ return new HTML5BackendImpl(manager, context, options);
6122
+ };
6123
+
5147
6124
  function DDContext(_a) {
5148
6125
  var children = _a.children;
5149
- return React.createElement(DndProvider, { backend: reactDndHtml5Backend.HTML5Backend }, children);
6126
+ return React.createElement(DndProvider, { backend: HTML5Backend }, children);
5150
6127
  }
5151
6128
 
5152
6129
  exports.DDContext = DDContext;