@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.
@@ -1 +1 @@
1
- {"version":3,"file":"DragndropPlugin.d.ts","sourceRoot":"","sources":["../src/DragndropPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,eAAe,EACf,gBAAgB,EACjB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAiD,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAI3F,qBACa,eAAgB,YAAW,eAAe;IACrD,MAAM,CAAC,GAAG,SAAe;IAGzB,SAAS,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAG/C,OAAO,CAAC,gBAAgB,CAAmB;IAG3C,OAAO,CAAC,sBAAsB,CAAyB;IAEvD,KAAK,CAAC,gBAAgB,EAAE,gBAAgB;CAuFzC"}
1
+ {"version":3,"file":"DragndropPlugin.d.ts","sourceRoot":"","sources":["../src/DragndropPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,eAAe,EACf,gBAAgB,EACjB,MAAM,SAAS,CAAC;AACjB,OAAO,EAIL,iBAAiB,EAElB,MAAM,SAAS,CAAC;AAGjB,qBACa,eAAgB,YAAW,eAAe;IACrD,MAAM,CAAC,GAAG,SAAe;IAGzB,SAAS,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAG/C,OAAO,CAAC,gBAAgB,CAAmB;IAG3C,OAAO,CAAC,sBAAsB,CAAyB;IAEvD,KAAK,CAAC,gBAAgB,EAAE,gBAAgB;CAuFzC"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import type { RendererPlugin } from '@antv/g';
2
- import type { Syringe } from 'mana-syringe';
1
+ import type { RendererPlugin, Syringe } from '@antv/g';
3
2
  import { DragndropPluginOptions } from './tokens';
4
3
  export declare class Plugin implements RendererPlugin {
5
4
  private options;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAG5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAMlD,qBAAa,MAAO,YAAW,cAAc;IAG/B,OAAO,CAAC,OAAO;IAF3B,IAAI,SAAe;gBAEC,OAAO,GAAE,OAAO,CAAC,sBAAsB,CAAM;IAEjE,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,GAAG,IAAI;IASxC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,GAAG,IAAI;CAI5C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAGvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAMlD,qBAAa,MAAO,YAAW,cAAc;IAG/B,OAAO,CAAC,OAAO;IAF3B,IAAI,SAAe;gBAEC,OAAO,GAAE,OAAO,CAAC,sBAAsB,CAAM;IAEjE,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,GAAG,IAAI;IASxC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,GAAG,IAAI;CAI5C"}
package/dist/index.esm.js CHANGED
@@ -1,32 +1,5 @@
1
- import { Syringe, inject, singleton, Module } from 'mana-syringe';
1
+ import { Syringe, inject, SceneGraphService, RenderingContext, singleton, RenderingPluginContribution, Module } from '@antv/g';
2
2
  import { __decorate, __metadata } from 'tslib';
3
- import { SceneGraphService, RenderingContext, RenderingPluginContribution } from '@antv/g';
4
-
5
- function ownKeys(object, enumerableOnly) {
6
- var keys = Object.keys(object);
7
-
8
- if (Object.getOwnPropertySymbols) {
9
- var symbols = Object.getOwnPropertySymbols(object);
10
- enumerableOnly && (symbols = symbols.filter(function (sym) {
11
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
12
- })), keys.push.apply(keys, symbols);
13
- }
14
-
15
- return keys;
16
- }
17
-
18
- function _objectSpread2(target) {
19
- for (var i = 1; i < arguments.length; i++) {
20
- var source = null != arguments[i] ? arguments[i] : {};
21
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
22
- _defineProperty(target, key, source[key]);
23
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
24
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
25
- });
26
- }
27
-
28
- return target;
29
- }
30
3
 
31
4
  function _regeneratorRuntime() {
32
5
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
@@ -409,44 +382,22 @@ function _asyncToGenerator(fn) {
409
382
  };
410
383
  }
411
384
 
412
- function _classCallCheck(instance, Constructor) {
413
- if (!(instance instanceof Constructor)) {
414
- throw new TypeError("Cannot call a class as a function");
415
- }
416
- }
385
+ function _extends() {
386
+ _extends = Object.assign || function (target) {
387
+ for (var i = 1; i < arguments.length; i++) {
388
+ var source = arguments[i];
417
389
 
418
- function _defineProperties(target, props) {
419
- for (var i = 0; i < props.length; i++) {
420
- var descriptor = props[i];
421
- descriptor.enumerable = descriptor.enumerable || false;
422
- descriptor.configurable = true;
423
- if ("value" in descriptor) descriptor.writable = true;
424
- Object.defineProperty(target, descriptor.key, descriptor);
425
- }
426
- }
427
-
428
- function _createClass(Constructor, protoProps, staticProps) {
429
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
430
- if (staticProps) _defineProperties(Constructor, staticProps);
431
- Object.defineProperty(Constructor, "prototype", {
432
- writable: false
433
- });
434
- return Constructor;
435
- }
390
+ for (var key in source) {
391
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
392
+ target[key] = source[key];
393
+ }
394
+ }
395
+ }
436
396
 
437
- function _defineProperty(obj, key, value) {
438
- if (key in obj) {
439
- Object.defineProperty(obj, key, {
440
- value: value,
441
- enumerable: true,
442
- configurable: true,
443
- writable: true
444
- });
445
- } else {
446
- obj[key] = value;
447
- }
397
+ return target;
398
+ };
448
399
 
449
- return obj;
400
+ return _extends.apply(this, arguments);
450
401
  }
451
402
 
452
403
  var DragndropPluginOptions = Syringe.defineToken('DragndropPluginOptions');
@@ -456,140 +407,137 @@ var _class;
456
407
  var DragndropPlugin_1;
457
408
  var DragndropPlugin = DragndropPlugin_1 = (_class = /*#__PURE__*/function () {
458
409
  function DragndropPlugin() {
459
- _classCallCheck(this, DragndropPlugin);
460
-
461
410
  this.sceneGraphService = void 0;
462
411
  this.renderingContext = void 0;
463
412
  this.dragndropPluginOptions = void 0;
464
413
  }
465
414
 
466
- _createClass(DragndropPlugin, [{
467
- key: "apply",
468
- value: function apply(renderingService) {
469
- var _this = this;
470
-
471
- var document = this.renderingContext.root.ownerDocument;
472
- var overlap = this.dragndropPluginOptions.overlap;
473
-
474
- var handlePointerdown = function handlePointerdown(event) {
475
- var target = event.target;
476
-
477
- if (target.getAttribute('draggable')) {
478
- // @ts-ignore
479
- var onMouseMove = /*#__PURE__*/function () {
480
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
481
- var pointerEventsOldValue, point, elemBelow, droppableBelow;
482
- return _regeneratorRuntime().wrap(function _callee$(_context) {
483
- while (1) {
484
- switch (_context.prev = _context.next) {
485
- case 0:
486
- // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/drag_event
487
- event.type = 'drag';
488
- target.dispatchEvent(event); // prevent from picking the dragging element
489
-
490
- pointerEventsOldValue = target.style.pointerEvents;
491
- target.style.pointerEvents = 'none';
492
- point = overlap === 'pointer' ? [event.canvasX, event.canvasY] : target.getBounds().center;
493
- _context.next = 7;
494
- return document.elementFromPoint(point[0], point[1]);
495
-
496
- case 7:
497
- elemBelow = _context.sent;
498
- target.style.pointerEvents = pointerEventsOldValue;
499
-
500
- if (elemBelow) {
501
- _context.next = 11;
502
- break;
415
+ var _proto = DragndropPlugin.prototype;
416
+
417
+ _proto.apply = function apply(renderingService) {
418
+ var _this = this;
419
+
420
+ var document = this.renderingContext.root.ownerDocument;
421
+ var overlap = this.dragndropPluginOptions.overlap;
422
+
423
+ var handlePointerdown = function handlePointerdown(event) {
424
+ var target = event.target;
425
+
426
+ if (target.getAttribute('draggable')) {
427
+ // @ts-ignore
428
+ var onMouseMove = /*#__PURE__*/function () {
429
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
430
+ var pointerEventsOldValue, point, elemBelow, droppableBelow;
431
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
432
+ while (1) {
433
+ switch (_context.prev = _context.next) {
434
+ case 0:
435
+ // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/drag_event
436
+ event.type = 'drag';
437
+ target.dispatchEvent(event); // prevent from picking the dragging element
438
+
439
+ pointerEventsOldValue = target.style.pointerEvents;
440
+ target.style.pointerEvents = 'none';
441
+ point = overlap === 'pointer' ? [event.canvasX, event.canvasY] : target.getBounds().center;
442
+ _context.next = 7;
443
+ return document.elementFromPoint(point[0], point[1]);
444
+
445
+ case 7:
446
+ elemBelow = _context.sent;
447
+ target.style.pointerEvents = pointerEventsOldValue;
448
+
449
+ if (elemBelow) {
450
+ _context.next = 11;
451
+ break;
452
+ }
453
+
454
+ return _context.abrupt("return");
455
+
456
+ case 11:
457
+ droppableBelow = (elemBelow === null || elemBelow === void 0 ? void 0 : elemBelow.closest('[droppable=true]')) || null;
458
+
459
+ if (currentDroppable !== droppableBelow) {
460
+ if (currentDroppable) {
461
+ // null when we were not over a droppable before this event
462
+ // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragleave_event
463
+ event.type = 'dragleave';
464
+ event.target = currentDroppable;
465
+ currentDroppable.dispatchEvent(event);
503
466
  }
504
467
 
505
- return _context.abrupt("return");
506
-
507
- case 11:
508
- droppableBelow = (elemBelow === null || elemBelow === void 0 ? void 0 : elemBelow.closest('[droppable=true]')) || null;
509
-
510
- if (currentDroppable !== droppableBelow) {
511
- if (currentDroppable) {
512
- // null when we were not over a droppable before this event
513
- // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragleave_event
514
- event.type = 'dragleave';
515
- event.target = currentDroppable;
516
- currentDroppable.dispatchEvent(event);
517
- }
518
-
519
- if (droppableBelow) {
520
- // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragleave_event
521
- event.type = 'dragenter';
522
- event.target = droppableBelow;
523
- droppableBelow.dispatchEvent(event);
524
- }
525
-
526
- currentDroppable = droppableBelow;
527
-
528
- if (currentDroppable) {
529
- // null if we're not coming over a droppable now
530
- // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragover_event
531
- event.type = 'dragover';
532
- event.target = currentDroppable;
533
- currentDroppable.dispatchEvent(event);
534
- }
468
+ if (droppableBelow) {
469
+ // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragleave_event
470
+ event.type = 'dragenter';
471
+ event.target = droppableBelow;
472
+ droppableBelow.dispatchEvent(event);
535
473
  }
536
474
 
537
- case 13:
538
- case "end":
539
- return _context.stop();
540
- }
541
- }
542
- }, _callee);
543
- }));
475
+ currentDroppable = droppableBelow;
544
476
 
545
- return function onMouseMove(_x) {
546
- return _ref.apply(this, arguments);
547
- };
548
- }();
477
+ if (currentDroppable) {
478
+ // null if we're not coming over a droppable now
479
+ // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragover_event
480
+ event.type = 'dragover';
481
+ event.target = currentDroppable;
482
+ currentDroppable.dispatchEvent(event);
483
+ }
484
+ }
549
485
 
550
- // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragstart_event
551
- event.type = 'dragstart';
486
+ case 13:
487
+ case "end":
488
+ return _context.stop();
489
+ }
490
+ }
491
+ }, _callee);
492
+ }));
493
+
494
+ return function onMouseMove(_x) {
495
+ return _ref.apply(this, arguments);
496
+ };
497
+ }();
498
+
499
+ // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragstart_event
500
+ event.type = 'dragstart';
501
+ target.dispatchEvent(event);
502
+ var currentDroppable = null;
503
+ document.addEventListener('pointermove', onMouseMove);
504
+ target.addEventListener('pointerup', function () {
505
+ // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragend_event
506
+ event.type = 'dragend';
552
507
  target.dispatchEvent(event);
553
- var currentDroppable = null;
554
- document.addEventListener('pointermove', onMouseMove);
555
- target.addEventListener('pointerup', function () {
556
- // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/dragend_event
557
- event.type = 'dragend';
558
- target.dispatchEvent(event);
559
-
560
- if (currentDroppable) {
561
- // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/drop_event
562
- event.type = 'drop';
563
- event.target = currentDroppable;
564
- currentDroppable.dispatchEvent(event);
565
- }
566
508
 
567
- document.removeEventListener('pointermove', onMouseMove);
568
- }, {
569
- once: true
570
- });
571
- }
572
- };
509
+ if (currentDroppable) {
510
+ // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/drop_event
511
+ event.type = 'drop';
512
+ event.target = currentDroppable;
513
+ currentDroppable.dispatchEvent(event);
514
+ }
573
515
 
574
- renderingService.hooks.init.tapPromise(DragndropPlugin_1.tag, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
575
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
576
- while (1) {
577
- switch (_context2.prev = _context2.next) {
578
- case 0:
579
- _this.renderingContext.root.addEventListener('pointerdown', handlePointerdown);
516
+ document.removeEventListener('pointermove', onMouseMove);
517
+ }, {
518
+ once: true
519
+ });
520
+ }
521
+ };
580
522
 
581
- case 1:
582
- case "end":
583
- return _context2.stop();
584
- }
523
+ renderingService.hooks.init.tapPromise(DragndropPlugin_1.tag, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
524
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
525
+ while (1) {
526
+ switch (_context2.prev = _context2.next) {
527
+ case 0:
528
+ _this.renderingContext.root.addEventListener('pointerdown', handlePointerdown);
529
+
530
+ case 1:
531
+ case "end":
532
+ return _context2.stop();
585
533
  }
586
- }, _callee2);
587
- })));
588
- renderingService.hooks.destroy.tap(DragndropPlugin_1.tag, function () {
589
- _this.renderingContext.root.removeEventListener('pointerdown', handlePointerdown);
590
- });
591
- }
592
- }]);
534
+ }
535
+ }, _callee2);
536
+ })));
537
+ renderingService.hooks.destroy.tap(DragndropPlugin_1.tag, function () {
538
+ _this.renderingContext.root.removeEventListener('pointerdown', handlePointerdown);
539
+ });
540
+ };
593
541
 
594
542
  return DragndropPlugin;
595
543
  }(), _class.tag = 'Dragndrop', _class);
@@ -608,33 +556,31 @@ var containerModule = Module(function (register) {
608
556
  register(DragndropPlugin);
609
557
  });
610
558
  var Plugin = /*#__PURE__*/function () {
611
- function Plugin() {
612
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
613
-
614
- _classCallCheck(this, Plugin);
559
+ function Plugin(options) {
560
+ if (options === void 0) {
561
+ options = {};
562
+ }
615
563
 
616
564
  this.options = void 0;
617
565
  this.name = 'dragndrop';
618
566
  this.options = options;
619
567
  }
620
568
 
621
- _createClass(Plugin, [{
622
- key: "init",
623
- value: function init(container) {
624
- container.register(DragndropPluginOptions, {
625
- useValue: _objectSpread2({
626
- overlap: 'pointer'
627
- }, this.options)
628
- });
629
- container.load(containerModule, true);
630
- }
631
- }, {
632
- key: "destroy",
633
- value: function destroy(container) {
634
- container.remove(DragndropPluginOptions);
635
- container.unload(containerModule);
636
- }
637
- }]);
569
+ var _proto = Plugin.prototype;
570
+
571
+ _proto.init = function init(container) {
572
+ container.register(DragndropPluginOptions, {
573
+ useValue: _extends({
574
+ overlap: 'pointer'
575
+ }, this.options)
576
+ });
577
+ container.load(containerModule, true);
578
+ };
579
+
580
+ _proto.destroy = function destroy(container) {
581
+ container.remove(DragndropPluginOptions);
582
+ container.unload(containerModule);
583
+ };
638
584
 
639
585
  return Plugin;
640
586
  }();