@rkmodules/rules 0.0.62 → 0.0.64

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