@visactor/vtable-calendar 1.23.3-alpha.0 → 1.23.3

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.
@@ -627,28 +627,59 @@
627
627
  }
628
628
  addEventListener(type, listener, options) {
629
629
  if (!listener) return;
630
+ const capture = this._resolveCapture(options),
631
+ once = this._resolveOnce(options),
632
+ listenerTypeMap = this._getOrCreateListenerTypeMap(type),
633
+ wrappedMap = this._getOrCreateWrappedMap(listenerTypeMap, listener);
634
+ if (wrappedMap.has(capture)) return;
630
635
  const wrappedListener = event => {
631
636
  const transformedEvent = this._eventListenerTransformer(event);
632
- "function" == typeof listener ? listener(transformedEvent) : listener.handleEvent && listener.handleEvent(transformedEvent);
637
+ "function" == typeof listener ? listener(transformedEvent) : listener.handleEvent && listener.handleEvent(transformedEvent), once && this._deleteListenerRecord(type, listener, capture);
633
638
  };
634
- this._listenerMap.has(type) || this._listenerMap.set(type, new Map()), this._listenerMap.get(type).set(listener, wrappedListener), this._nativeAddEventListener(type, wrappedListener, options);
639
+ wrappedMap.set(capture, {
640
+ wrappedListener: wrappedListener,
641
+ options: options
642
+ }), this._nativeAddEventListener(type, wrappedListener, options);
635
643
  }
636
644
  removeEventListener(type, listener, options) {
637
- var _a;
645
+ var _a, _b;
638
646
  if (!listener) return;
639
- const wrappedListener = null === (_a = this._listenerMap.get(type)) || void 0 === _a ? void 0 : _a.get(listener);
640
- wrappedListener && (this._nativeRemoveEventListener(type, wrappedListener, options), this._listenerMap.get(type).delete(listener), 0 === this._listenerMap.get(type).size && this._listenerMap.delete(type));
647
+ const capture = this._resolveCapture(options),
648
+ wrappedRecord = null === (_b = null === (_a = this._listenerMap.get(type)) || void 0 === _a ? void 0 : _a.get(listener)) || void 0 === _b ? void 0 : _b.get(capture);
649
+ wrappedRecord && (this._nativeRemoveEventListener(type, wrappedRecord.wrappedListener, capture), this._deleteListenerRecord(type, listener, capture));
641
650
  }
642
651
  dispatchEvent(event) {
643
652
  return this._nativeDispatchEvent(event);
644
653
  }
645
654
  clearAllEventListeners() {
646
- this._listenerMap.forEach((listenersMap, type) => {
647
- listenersMap.forEach((wrappedListener, originalListener) => {
648
- this._nativeRemoveEventListener(type, wrappedListener, void 0);
655
+ this._listenerMap.forEach((listenerMap, type) => {
656
+ listenerMap.forEach(wrappedMap => {
657
+ wrappedMap.forEach((wrappedRecord, capture) => {
658
+ this._nativeRemoveEventListener(type, wrappedRecord.wrappedListener, capture);
659
+ });
649
660
  });
650
661
  }), this._listenerMap.clear();
651
662
  }
663
+ _resolveCapture(options) {
664
+ return "boolean" == typeof options ? options : !!(null == options ? void 0 : options.capture);
665
+ }
666
+ _resolveOnce(options) {
667
+ return "object" == typeof options && !!(null == options ? void 0 : options.once);
668
+ }
669
+ _getOrCreateListenerTypeMap(type) {
670
+ let listenerTypeMap = this._listenerMap.get(type);
671
+ return listenerTypeMap || (listenerTypeMap = new Map(), this._listenerMap.set(type, listenerTypeMap)), listenerTypeMap;
672
+ }
673
+ _getOrCreateWrappedMap(listenerTypeMap, listener) {
674
+ let wrappedMap = listenerTypeMap.get(listener);
675
+ return wrappedMap || (wrappedMap = new Map(), listenerTypeMap.set(listener, wrappedMap)), wrappedMap;
676
+ }
677
+ _deleteListenerRecord(type, listener, capture) {
678
+ const listenerTypeMap = this._listenerMap.get(type);
679
+ if (!listenerTypeMap) return;
680
+ const wrappedMap = listenerTypeMap.get(listener);
681
+ wrappedMap && (wrappedMap.delete(capture), 0 === wrappedMap.size && listenerTypeMap.delete(listener), 0 === listenerTypeMap.size && this._listenerMap.delete(type));
682
+ }
652
683
  _nativeAddEventListener(type, listener, options) {
653
684
  throw new Error("_nativeAddEventListener must be implemented by derived classes");
654
685
  }
@@ -7162,7 +7193,9 @@
7162
7193
  var _a;
7163
7194
  if (event.manager !== this) throw new Error("It is illegal to free an event not managed by this EventManager!");
7164
7195
  const constructor = event.constructor;
7165
- this.eventPool.has(constructor) || this.eventPool.set(constructor, []), null === (_a = this.eventPool.get(constructor)) || void 0 === _a || _a.push(event);
7196
+ this.eventPool.has(constructor) || (this.eventPool.get(constructor).forEach(e => {
7197
+ e.eventPhase = event.NONE, e.currentTarget = null, e.path = [], e.detailPath = [], e.target = null;
7198
+ }), this.eventPool.set(constructor, [])), null === (_a = this.eventPool.get(constructor)) || void 0 === _a || _a.push(event);
7166
7199
  }
7167
7200
  notifyListeners(e, type) {
7168
7201
  const listeners = e.currentTarget._events[type];
@@ -9766,7 +9799,7 @@
9766
9799
  });
9767
9800
  }
9768
9801
  release() {
9769
- this.releaseStatus = "released", this.stopAnimates(), application.graphicService.onRelease(this);
9802
+ this.releaseStatus = "released", this.stopAnimates(), application.graphicService.onRelease(this), super.release();
9770
9803
  }
9771
9804
  _emitCustomEvent(type, context) {
9772
9805
  var _a, _b;
@@ -17173,12 +17206,12 @@
17173
17206
  throw new Error("暂不支持");
17174
17207
  }
17175
17208
  release() {
17176
- var _a, _b;
17209
+ var _a, _b, _d;
17177
17210
  super.release(), this.hooks.beforeRender.unTap("constructor", this.beforeRender), this.hooks.afterRender.unTap("constructor", this.afterRender), this.eventSystem && this.eventSystem.release(), this.layerService.releaseStage(this), this.pluginService.release(), this.forEach(layer => {
17178
17211
  layer.release();
17179
17212
  }), this.interactiveLayer && (this.interactiveLayer.forEachChildren(item => {
17180
17213
  item.setStage && item.setStage(null, null), this.interactiveLayer.removeChild(item);
17181
- }), this.interactiveLayer.release()), this.window.release(), null === (_a = this._ticker) || void 0 === _a || _a.remTimeline(null == this ? void 0 : this.timeline), null === (_b = this._ticker) || void 0 === _b || _b.removeListener("tick", this.afterTickCb), this.renderService.renderTreeRoots = [];
17214
+ }), this.interactiveLayer.release()), this.window.release(), null === (_a = this._ticker) || void 0 === _a || _a.remTimeline(null == this ? void 0 : this.timeline), null === (_b = this._ticker) || void 0 === _b || _b.removeListener("tick", this.afterTickCb), this.params.ticker || null === (_d = this._ticker) || void 0 === _d || _d.release(), this.renderService.renderTreeRoots = [];
17182
17215
  }
17183
17216
  setStage(stage) {}
17184
17217
  dirty(b, matrix) {
@@ -32593,7 +32626,7 @@
32593
32626
  };
32594
32627
  }
32595
32628
  release(all) {
32596
- super.release(all), ("browser" === vglobal.env ? vglobal : this.stage).addEventListener("touchmove", this._handleTouchMove, {
32629
+ super.release(all), ("browser" === vglobal.env ? vglobal : this.stage).removeEventListener("touchmove", this._handleTouchMove, {
32597
32630
  passive: !1
32598
32631
  }), this._clearAllDragEvents();
32599
32632
  }
@@ -33875,6 +33908,7 @@
33875
33908
  };
33876
33909
  }
33877
33910
  on(type, listener) {
33911
+ if (!this.listenersData) return;
33878
33912
  const list = this.listenersData.listeners[type] || (this.listenersData.listeners[type] = []);
33879
33913
  list.push(listener);
33880
33914
  const id = idCount$1++;
@@ -33882,9 +33916,10 @@
33882
33916
  type: type,
33883
33917
  listener: listener,
33884
33918
  remove: () => {
33919
+ if (!this.listenersData) return;
33885
33920
  delete this.listenersData.listenerData[id];
33886
33921
  const index = list.indexOf(listener);
33887
- list.splice(index, 1), this.listenersData.listeners[type].length || delete this.listenersData.listeners[type];
33922
+ list.splice(index, 1), this.listenersData.listeners[type] && !this.listenersData.listeners[type].length && delete this.listenersData.listeners[type];
33888
33923
  }
33889
33924
  }, id;
33890
33925
  }
@@ -56512,7 +56547,7 @@
56512
56547
  }
56513
56548
  constructor(container, options = {}) {
56514
56549
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
56515
- if (super(), this.showFrozenIcon = !0, this._tableBorderWidth_left = 0, this._tableBorderWidth_right = 0, this._tableBorderWidth_top = 0, this._tableBorderWidth_bottom = 0, this.version = "1.23.3-alpha.0", this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200), "node" === Env.mode ? (options = container, container = null) : container instanceof HTMLElement || (options = container, container = container.container ? container.container : null), !container && "node" !== options.mode && !options.canvas) throw new Error("vtable's container is undefined");
56550
+ if (super(), this.showFrozenIcon = !0, this._tableBorderWidth_left = 0, this._tableBorderWidth_right = 0, this._tableBorderWidth_top = 0, this._tableBorderWidth_bottom = 0, this.version = "1.23.3", this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200), "node" === Env.mode ? (options = container, container = null) : container instanceof HTMLElement || (options = container, container = container.container ? container.container : null), !container && "node" !== options.mode && !options.canvas) throw new Error("vtable's container is undefined");
56516
56551
  this.pluginManager = new PluginManager(this, options), this.fireListeners(TABLE_EVENT_TYPE.BEFORE_INIT, {
56517
56552
  options: options,
56518
56553
  container: container
@@ -60255,7 +60290,10 @@
60255
60290
  }
60256
60291
  cancelEdit() {
60257
60292
  var _a, _b, _c, _d;
60258
- this.editingEditor && (null === (_b = (_a = this.editingEditor).exit) || void 0 === _b || _b.call(_a), null === (_d = (_c = this.editingEditor).onEnd) || void 0 === _d || _d.call(_c), this.editingEditor = null);
60293
+ this.editingEditor && (null === (_b = (_a = this.editingEditor).exit) || void 0 === _b || _b.call(_a), null === (_d = (_c = this.editingEditor).onEnd) || void 0 === _d || _d.call(_c), this.editingEditor = null), Object.values(this.cacheLastSelectedCellEditor).forEach(editor => {
60294
+ var _a;
60295
+ return null === (_a = null == editor ? void 0 : editor.onEnd) || void 0 === _a ? void 0 : _a.call(editor);
60296
+ }), this.cacheLastSelectedCellEditor = {};
60259
60297
  }
60260
60298
  release() {
60261
60299
  this.listenersId.forEach(id => {