@antv/g-plugin-dragndrop 1.0.3 → 1.0.5-alpha.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/dist/DragndropPlugin.d.ts.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +148 -202
- package/dist/index.js +154 -208
- package/dist/index.umd.js +157 -210
- package/dist/index.umd.min.js +2 -2
- package/dist/tokens.d.ts +1 -1
- package/dist/tokens.d.ts.map +1 -1
- package/package.json +3 -4
package/dist/index.umd.js
CHANGED
|
@@ -1,34 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.G = global.G || {}, global.G.Dragndrop = {}), global.window.G
|
|
5
|
-
}(this, (function (exports,
|
|
6
|
-
|
|
7
|
-
function ownKeys(object, enumerableOnly) {
|
|
8
|
-
var keys = Object.keys(object);
|
|
9
|
-
|
|
10
|
-
if (Object.getOwnPropertySymbols) {
|
|
11
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
12
|
-
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
13
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
14
|
-
})), keys.push.apply(keys, symbols);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return keys;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function _objectSpread2(target) {
|
|
21
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
22
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
23
|
-
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
24
|
-
_defineProperty(target, key, source[key]);
|
|
25
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
26
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return target;
|
|
31
|
-
}
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@antv/g')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@antv/g'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.G = global.G || {}, global.G.Dragndrop = {}), global.window.G));
|
|
5
|
+
}(this, (function (exports, g) { 'use strict';
|
|
32
6
|
|
|
33
7
|
function _regeneratorRuntime() {
|
|
34
8
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
@@ -411,44 +385,22 @@
|
|
|
411
385
|
};
|
|
412
386
|
}
|
|
413
387
|
|
|
414
|
-
function
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
function _defineProperties(target, props) {
|
|
421
|
-
for (var i = 0; i < props.length; i++) {
|
|
422
|
-
var descriptor = props[i];
|
|
423
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
424
|
-
descriptor.configurable = true;
|
|
425
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
426
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
427
|
-
}
|
|
428
|
-
}
|
|
388
|
+
function _extends() {
|
|
389
|
+
_extends = Object.assign || function (target) {
|
|
390
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
391
|
+
var source = arguments[i];
|
|
429
392
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
return Constructor;
|
|
437
|
-
}
|
|
393
|
+
for (var key in source) {
|
|
394
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
395
|
+
target[key] = source[key];
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
438
399
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
Object.defineProperty(obj, key, {
|
|
442
|
-
value: value,
|
|
443
|
-
enumerable: true,
|
|
444
|
-
configurable: true,
|
|
445
|
-
writable: true
|
|
446
|
-
});
|
|
447
|
-
} else {
|
|
448
|
-
obj[key] = value;
|
|
449
|
-
}
|
|
400
|
+
return target;
|
|
401
|
+
};
|
|
450
402
|
|
|
451
|
-
return
|
|
403
|
+
return _extends.apply(this, arguments);
|
|
452
404
|
}
|
|
453
405
|
|
|
454
406
|
/******************************************************************************
|
|
@@ -477,192 +429,187 @@
|
|
|
477
429
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
478
430
|
}
|
|
479
431
|
|
|
480
|
-
var DragndropPluginOptions =
|
|
432
|
+
var DragndropPluginOptions = g.Syringe.defineToken('DragndropPluginOptions');
|
|
481
433
|
|
|
482
434
|
var _class;
|
|
483
435
|
|
|
484
436
|
var DragndropPlugin_1;
|
|
485
437
|
var DragndropPlugin = DragndropPlugin_1 = (_class = /*#__PURE__*/function () {
|
|
486
438
|
function DragndropPlugin() {
|
|
487
|
-
_classCallCheck(this, DragndropPlugin);
|
|
488
|
-
|
|
489
439
|
this.sceneGraphService = void 0;
|
|
490
440
|
this.renderingContext = void 0;
|
|
491
441
|
this.dragndropPluginOptions = void 0;
|
|
492
442
|
}
|
|
493
443
|
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
444
|
+
var _proto = DragndropPlugin.prototype;
|
|
445
|
+
|
|
446
|
+
_proto.apply = function apply(renderingService) {
|
|
447
|
+
var _this = this;
|
|
448
|
+
|
|
449
|
+
var document = this.renderingContext.root.ownerDocument;
|
|
450
|
+
var overlap = this.dragndropPluginOptions.overlap;
|
|
451
|
+
|
|
452
|
+
var handlePointerdown = function handlePointerdown(event) {
|
|
453
|
+
var target = event.target;
|
|
454
|
+
|
|
455
|
+
if (target.getAttribute('draggable')) {
|
|
456
|
+
// @ts-ignore
|
|
457
|
+
var onMouseMove = /*#__PURE__*/function () {
|
|
458
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
|
|
459
|
+
var pointerEventsOldValue, point, elemBelow, droppableBelow;
|
|
460
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
461
|
+
while (1) {
|
|
462
|
+
switch (_context.prev = _context.next) {
|
|
463
|
+
case 0:
|
|
464
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/drag_event
|
|
465
|
+
event.type = 'drag';
|
|
466
|
+
target.dispatchEvent(event); // prevent from picking the dragging element
|
|
467
|
+
|
|
468
|
+
pointerEventsOldValue = target.style.pointerEvents;
|
|
469
|
+
target.style.pointerEvents = 'none';
|
|
470
|
+
point = overlap === 'pointer' ? [event.canvasX, event.canvasY] : target.getBounds().center;
|
|
471
|
+
_context.next = 7;
|
|
472
|
+
return document.elementFromPoint(point[0], point[1]);
|
|
473
|
+
|
|
474
|
+
case 7:
|
|
475
|
+
elemBelow = _context.sent;
|
|
476
|
+
target.style.pointerEvents = pointerEventsOldValue;
|
|
477
|
+
|
|
478
|
+
if (elemBelow) {
|
|
479
|
+
_context.next = 11;
|
|
480
|
+
break;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
return _context.abrupt("return");
|
|
484
|
+
|
|
485
|
+
case 11:
|
|
486
|
+
droppableBelow = (elemBelow === null || elemBelow === void 0 ? void 0 : elemBelow.closest('[droppable=true]')) || null;
|
|
487
|
+
|
|
488
|
+
if (currentDroppable !== droppableBelow) {
|
|
489
|
+
if (currentDroppable) {
|
|
490
|
+
// null when we were not over a droppable before this event
|
|
491
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragleave_event
|
|
492
|
+
event.type = 'dragleave';
|
|
493
|
+
event.target = currentDroppable;
|
|
494
|
+
currentDroppable.dispatchEvent(event);
|
|
531
495
|
}
|
|
532
496
|
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
if (currentDroppable !== droppableBelow) {
|
|
539
|
-
if (currentDroppable) {
|
|
540
|
-
// null when we were not over a droppable before this event
|
|
541
|
-
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragleave_event
|
|
542
|
-
event.type = 'dragleave';
|
|
543
|
-
event.target = currentDroppable;
|
|
544
|
-
currentDroppable.dispatchEvent(event);
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
if (droppableBelow) {
|
|
548
|
-
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragleave_event
|
|
549
|
-
event.type = 'dragenter';
|
|
550
|
-
event.target = droppableBelow;
|
|
551
|
-
droppableBelow.dispatchEvent(event);
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
currentDroppable = droppableBelow;
|
|
555
|
-
|
|
556
|
-
if (currentDroppable) {
|
|
557
|
-
// null if we're not coming over a droppable now
|
|
558
|
-
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragover_event
|
|
559
|
-
event.type = 'dragover';
|
|
560
|
-
event.target = currentDroppable;
|
|
561
|
-
currentDroppable.dispatchEvent(event);
|
|
562
|
-
}
|
|
497
|
+
if (droppableBelow) {
|
|
498
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragleave_event
|
|
499
|
+
event.type = 'dragenter';
|
|
500
|
+
event.target = droppableBelow;
|
|
501
|
+
droppableBelow.dispatchEvent(event);
|
|
563
502
|
}
|
|
564
503
|
|
|
565
|
-
|
|
566
|
-
case "end":
|
|
567
|
-
return _context.stop();
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
}, _callee);
|
|
571
|
-
}));
|
|
504
|
+
currentDroppable = droppableBelow;
|
|
572
505
|
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
506
|
+
if (currentDroppable) {
|
|
507
|
+
// null if we're not coming over a droppable now
|
|
508
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragover_event
|
|
509
|
+
event.type = 'dragover';
|
|
510
|
+
event.target = currentDroppable;
|
|
511
|
+
currentDroppable.dispatchEvent(event);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
577
514
|
|
|
578
|
-
|
|
579
|
-
|
|
515
|
+
case 13:
|
|
516
|
+
case "end":
|
|
517
|
+
return _context.stop();
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
}, _callee);
|
|
521
|
+
}));
|
|
522
|
+
|
|
523
|
+
return function onMouseMove(_x) {
|
|
524
|
+
return _ref.apply(this, arguments);
|
|
525
|
+
};
|
|
526
|
+
}();
|
|
527
|
+
|
|
528
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragstart_event
|
|
529
|
+
event.type = 'dragstart';
|
|
530
|
+
target.dispatchEvent(event);
|
|
531
|
+
var currentDroppable = null;
|
|
532
|
+
document.addEventListener('pointermove', onMouseMove);
|
|
533
|
+
target.addEventListener('pointerup', function () {
|
|
534
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragend_event
|
|
535
|
+
event.type = 'dragend';
|
|
580
536
|
target.dispatchEvent(event);
|
|
581
|
-
var currentDroppable = null;
|
|
582
|
-
document.addEventListener('pointermove', onMouseMove);
|
|
583
|
-
target.addEventListener('pointerup', function () {
|
|
584
|
-
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragend_event
|
|
585
|
-
event.type = 'dragend';
|
|
586
|
-
target.dispatchEvent(event);
|
|
587
|
-
|
|
588
|
-
if (currentDroppable) {
|
|
589
|
-
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/drop_event
|
|
590
|
-
event.type = 'drop';
|
|
591
|
-
event.target = currentDroppable;
|
|
592
|
-
currentDroppable.dispatchEvent(event);
|
|
593
|
-
}
|
|
594
537
|
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
538
|
+
if (currentDroppable) {
|
|
539
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/drop_event
|
|
540
|
+
event.type = 'drop';
|
|
541
|
+
event.target = currentDroppable;
|
|
542
|
+
currentDroppable.dispatchEvent(event);
|
|
543
|
+
}
|
|
601
544
|
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
545
|
+
document.removeEventListener('pointermove', onMouseMove);
|
|
546
|
+
}, {
|
|
547
|
+
once: true
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
};
|
|
608
551
|
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
552
|
+
renderingService.hooks.init.tapPromise(DragndropPlugin_1.tag, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
553
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
554
|
+
while (1) {
|
|
555
|
+
switch (_context2.prev = _context2.next) {
|
|
556
|
+
case 0:
|
|
557
|
+
_this.renderingContext.root.addEventListener('pointerdown', handlePointerdown);
|
|
558
|
+
|
|
559
|
+
case 1:
|
|
560
|
+
case "end":
|
|
561
|
+
return _context2.stop();
|
|
613
562
|
}
|
|
614
|
-
}
|
|
615
|
-
})
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
}
|
|
620
|
-
}
|
|
563
|
+
}
|
|
564
|
+
}, _callee2);
|
|
565
|
+
})));
|
|
566
|
+
renderingService.hooks.destroy.tap(DragndropPlugin_1.tag, function () {
|
|
567
|
+
_this.renderingContext.root.removeEventListener('pointerdown', handlePointerdown);
|
|
568
|
+
});
|
|
569
|
+
};
|
|
621
570
|
|
|
622
571
|
return DragndropPlugin;
|
|
623
572
|
}(), _class.tag = 'Dragndrop', _class);
|
|
624
573
|
|
|
625
|
-
__decorate([
|
|
574
|
+
__decorate([g.inject(g.SceneGraphService), __metadata("design:type", Object)], DragndropPlugin.prototype, "sceneGraphService", void 0);
|
|
626
575
|
|
|
627
|
-
__decorate([
|
|
576
|
+
__decorate([g.inject(g.RenderingContext), __metadata("design:type", Object)], DragndropPlugin.prototype, "renderingContext", void 0);
|
|
628
577
|
|
|
629
|
-
__decorate([
|
|
578
|
+
__decorate([g.inject(DragndropPluginOptions), __metadata("design:type", Object)], DragndropPlugin.prototype, "dragndropPluginOptions", void 0);
|
|
630
579
|
|
|
631
|
-
DragndropPlugin = DragndropPlugin_1 = __decorate([
|
|
580
|
+
DragndropPlugin = DragndropPlugin_1 = __decorate([g.singleton({
|
|
632
581
|
contrib: g.RenderingPluginContribution
|
|
633
582
|
})], DragndropPlugin);
|
|
634
583
|
|
|
635
|
-
var containerModule =
|
|
584
|
+
var containerModule = g.Module(function (register) {
|
|
636
585
|
register(DragndropPlugin);
|
|
637
586
|
});
|
|
638
587
|
var Plugin = /*#__PURE__*/function () {
|
|
639
|
-
function Plugin() {
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
588
|
+
function Plugin(options) {
|
|
589
|
+
if (options === void 0) {
|
|
590
|
+
options = {};
|
|
591
|
+
}
|
|
643
592
|
|
|
644
593
|
this.options = void 0;
|
|
645
594
|
this.name = 'dragndrop';
|
|
646
595
|
this.options = options;
|
|
647
596
|
}
|
|
648
597
|
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
}
|
|
665
|
-
}]);
|
|
598
|
+
var _proto = Plugin.prototype;
|
|
599
|
+
|
|
600
|
+
_proto.init = function init(container) {
|
|
601
|
+
container.register(DragndropPluginOptions, {
|
|
602
|
+
useValue: _extends({
|
|
603
|
+
overlap: 'pointer'
|
|
604
|
+
}, this.options)
|
|
605
|
+
});
|
|
606
|
+
container.load(containerModule, true);
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
_proto.destroy = function destroy(container) {
|
|
610
|
+
container.remove(DragndropPluginOptions);
|
|
611
|
+
container.unload(containerModule);
|
|
612
|
+
};
|
|
666
613
|
|
|
667
614
|
return Plugin;
|
|
668
615
|
}();
|
package/dist/index.umd.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@antv/g")):"function"==typeof define&&define.amd?define(["exports","@antv/g"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).G=t.G||{},t.G.Dragndrop={}),t.window.G)}(this,(function(t,e){"use strict";function r(){
|
|
2
2
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
3
|
-
i=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",c=n.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function s(t,e,r,n){var o=Object.create((e&&e.prototype instanceof p?e:p).prototype),i=new j(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return P()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=O(a,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=f(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,i),o}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var l={};function p(){}function h(){}function d(){}var v={};u(v,o,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(L([])));g&&g!==e&&r.call(g,o)&&(v=g);var m=d.prototype=p.prototype=Object.create(v);function w(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){function n(o,i,a,c){var u=f(t[o],t,i);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==typeof l&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function O(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,O(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=f(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function x(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function L(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:P}}function P(){return{value:void 0,done:!0}}return h.prototype=d,u(m,"constructor",d),u(d,"constructor",h),h.displayName=u(d,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,u(t,c,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},w(b.prototype),u(b.prototype,a,(function(){return this})),t.AsyncIterator=b,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new b(s(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(m),u(m,c,"Generator"),u(m,o,(function(){return this})),u(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=L,j.prototype={constructor:j,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(this.prev>=i.tryLoc){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(i.catchLoc>this.prev)return n(i.catchLoc,!0);if(i.finallyLoc>this.prev)return n(i.finallyLoc)}else if(c){if(i.catchLoc>this.prev)return n(i.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(i.finallyLoc>this.prev)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(this.prev>=o.tryLoc&&r.call(o,"finallyLoc")&&o.finallyLoc>this.prev){var i=o;break}}i&&("break"===t||"continue"===t)&&e>=i.tryLoc&&i.finallyLoc>=e&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:L(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function a(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function c(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function c(t){a(i,n,o,c,u,"next",t)}function u(t){a(i,n,o,c,u,"throw",t)}c(void 0)}))}}function u(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){for(var r=0;e.length>r;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function f(t,e,r){return e&&s(t.prototype,e),r&&s(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function l(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function p(t,e,r,n){var o,i=arguments.length,a=3>i?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,r,n);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(a=(3>i?o(a):i>3?o(e,r,a):o(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a}function h(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}var d,v,y=e.Syringe.defineToken("DragndropPluginOptions"),g=(d=function(){function t(){u(this,t),this.sceneGraphService=void 0,this.renderingContext=void 0,this.dragndropPluginOptions=void 0}return f(t,[{key:"apply",value:function(t){var e=this,r=this.renderingContext.root.ownerDocument,n=this.dragndropPluginOptions.overlap,o=function(t){var e=t.target;if(e.getAttribute("draggable")){var o=function(){var t=c(i().mark((function t(o){var c,u,s,f;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o.type="drag",e.dispatchEvent(o),c=e.style.pointerEvents,e.style.pointerEvents="none",u="pointer"===n?[o.canvasX,o.canvasY]:e.getBounds().center,t.next=7,r.elementFromPoint(u[0],u[1]);case 7:if(s=t.sent,e.style.pointerEvents=c,s){t.next=11;break}return t.abrupt("return");case 11:f=(null==s?void 0:s.closest("[droppable=true]"))||null,a!==f&&(a&&(o.type="dragleave",o.target=a,a.dispatchEvent(o)),f&&(o.type="dragenter",o.target=f,f.dispatchEvent(o)),(a=f)&&(o.type="dragover",o.target=a,a.dispatchEvent(o)));case 13:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();t.type="dragstart",e.dispatchEvent(t);var a=null;r.addEventListener("pointermove",o),e.addEventListener("pointerup",(function(){t.type="dragend",e.dispatchEvent(t),a&&(t.type="drop",t.target=a,a.dispatchEvent(t)),r.removeEventListener("pointermove",o)}),{once:!0})}};t.hooks.init.tapPromise(v.tag,c(i().mark((function t(){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.renderingContext.root.addEventListener("pointerdown",o);case 1:case"end":return t.stop()}}),t)})))),t.hooks.destroy.tap(v.tag,(function(){e.renderingContext.root.removeEventListener("pointerdown",o)}))}}]),t}(),d.tag="Dragndrop",v=d);p([e.inject(r.SceneGraphService),h("design:type",Object)],g.prototype,"sceneGraphService",void 0),p([e.inject(r.RenderingContext),h("design:type",Object)],g.prototype,"renderingContext",void 0),p([e.inject(y),h("design:type",Object)],g.prototype,"dragndropPluginOptions",void 0),g=v=p([e.singleton({contrib:r.RenderingPluginContribution})],g);var m=e.Module((function(t){t(g)})),w=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};u(this,t),this.options=void 0,this.name="dragndrop",this.options=e}return f(t,[{key:"init",value:function(t){t.register(y,{useValue:o({overlap:"pointer"},this.options)}),t.load(m,!0)}},{key:"destroy",value:function(t){t.remove(y),t.unload(m)}}]),t}();t.Plugin=w,Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
3
|
+
r=function(){return t};var t={},e=Object.prototype,n=e.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function s(t,e,r,n){var o=Object.create((e&&e.prototype instanceof l?e:l).prototype),i=new O(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return P()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=x(a,r);if(c){if(c===p)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=f(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===p)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,i),o}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var p={};function l(){}function h(){}function d(){}var v={};u(v,i,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(j([])));g&&g!==e&&n.call(g,i)&&(v=g);var m=d.prototype=l.prototype=Object.create(v);function w(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){function r(o,i,a,c){var u=f(t[o],t,i);if("throw"!==u.type){var s=u.arg,p=s.value;return p&&"object"==typeof p&&n.call(p,"__await")?e.resolve(p.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(p).then((function(t){s.value=t,a(s)}),(function(t){return r("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,n){function i(){return new e((function(e,o){r(t,n,e,o)}))}return o=o?o.then(i,i):i()}}function x(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method))return p;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var n=f(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,p;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function j(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:P}}function P(){return{value:void 0,done:!0}}return h.prototype=d,u(m,"constructor",d),u(d,"constructor",h),h.displayName=u(d,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,u(t,c,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},w(b.prototype),u(b.prototype,a,(function(){return this})),t.AsyncIterator=b,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new b(s(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(m),u(m,c,"Generator"),u(m,i,(function(){return this})),u(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=j,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(L),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(this.prev>=i.tryLoc){var c=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(c&&u){if(i.catchLoc>this.prev)return r(i.catchLoc,!0);if(i.finallyLoc>this.prev)return r(i.finallyLoc)}else if(c){if(i.catchLoc>this.prev)return r(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(i.finallyLoc>this.prev)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(this.prev>=o.tryLoc&&n.call(o,"finallyLoc")&&o.finallyLoc>this.prev){var i=o;break}}i&&("break"===t||"continue"===t)&&e>=i.tryLoc&&i.finallyLoc>=e&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,p):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),p},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),L(r),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;L(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},t}function n(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function o(t){return function(){var e=this,r=arguments;return new Promise((function(o,i){var a=t.apply(e,r);function c(t){n(a,o,i,c,u,"next",t)}function u(t){n(a,o,i,c,u,"throw",t)}c(void 0)}))}}function i(){return i=Object.assign||function(t){for(var e=1;arguments.length>e;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},i.apply(this,arguments)}function a(t,e,r,n){var o,i=arguments.length,a=3>i?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,r,n);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(a=(3>i?o(a):i>3?o(e,r,a):o(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a}function c(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}var u,s,f=e.Syringe.defineToken("DragndropPluginOptions"),p=(u=function(){function t(){this.sceneGraphService=void 0,this.renderingContext=void 0,this.dragndropPluginOptions=void 0}return t.prototype.apply=function(t){var e=this,n=this.renderingContext.root.ownerDocument,i=this.dragndropPluginOptions.overlap,a=function(t){var e=t.target;if(e.getAttribute("draggable")){var a=function(){var t=o(r().mark((function t(o){var a,u,s,f;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o.type="drag",e.dispatchEvent(o),a=e.style.pointerEvents,e.style.pointerEvents="none",u="pointer"===i?[o.canvasX,o.canvasY]:e.getBounds().center,t.next=7,n.elementFromPoint(u[0],u[1]);case 7:if(s=t.sent,e.style.pointerEvents=a,s){t.next=11;break}return t.abrupt("return");case 11:f=(null==s?void 0:s.closest("[droppable=true]"))||null,c!==f&&(c&&(o.type="dragleave",o.target=c,c.dispatchEvent(o)),f&&(o.type="dragenter",o.target=f,f.dispatchEvent(o)),(c=f)&&(o.type="dragover",o.target=c,c.dispatchEvent(o)));case 13:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();t.type="dragstart",e.dispatchEvent(t);var c=null;n.addEventListener("pointermove",a),e.addEventListener("pointerup",(function(){t.type="dragend",e.dispatchEvent(t),c&&(t.type="drop",t.target=c,c.dispatchEvent(t)),n.removeEventListener("pointermove",a)}),{once:!0})}};t.hooks.init.tapPromise(s.tag,o(r().mark((function t(){return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.renderingContext.root.addEventListener("pointerdown",a);case 1:case"end":return t.stop()}}),t)})))),t.hooks.destroy.tap(s.tag,(function(){e.renderingContext.root.removeEventListener("pointerdown",a)}))},t}(),u.tag="Dragndrop",s=u);a([e.inject(e.SceneGraphService),c("design:type",Object)],p.prototype,"sceneGraphService",void 0),a([e.inject(e.RenderingContext),c("design:type",Object)],p.prototype,"renderingContext",void 0),a([e.inject(f),c("design:type",Object)],p.prototype,"dragndropPluginOptions",void 0),p=s=a([e.singleton({contrib:e.RenderingPluginContribution})],p);var l=e.Module((function(t){t(p)}));t.Plugin=function(){function t(t){void 0===t&&(t={}),this.options=void 0,this.name="dragndrop",this.options=t}var e=t.prototype;return e.init=function(t){t.register(f,{useValue:i({overlap:"pointer"},this.options)}),t.load(l,!0)},e.destroy=function(t){t.remove(f),t.unload(l)},t}(),Object.defineProperty(t,"__esModule",{value:!0})}));
|
package/dist/tokens.d.ts
CHANGED
package/dist/tokens.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,eAAO,MAAM,sBAAsB,sBAAgD,CAAC;AAEpF,MAAM,WAAW,sBAAsB;IACrC;;;;;OAKG;IACH,OAAO,EAAE,SAAS,GAAG,QAAQ,CAAC;CAC/B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/g-plugin-dragndrop",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5-alpha.1",
|
|
4
4
|
"description": "A G plugin for Drag n Drop implemented with PointerEvents",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antv",
|
|
@@ -33,11 +33,10 @@
|
|
|
33
33
|
"@types/jest": "^25.0.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@antv/g": "^5.0.1"
|
|
37
|
-
"mana-syringe": "^0.3.0"
|
|
36
|
+
"@antv/g": "^5.0.1"
|
|
38
37
|
},
|
|
39
38
|
"publishConfig": {
|
|
40
39
|
"access": "public"
|
|
41
40
|
},
|
|
42
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "a57232cfdc74aaf0a9812feea28d5b7c8ca243a8"
|
|
43
42
|
}
|