k-vtable 1.0.33 → 1.0.34

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/vtable.js CHANGED
@@ -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) {
@@ -21499,7 +21532,7 @@
21499
21532
  this._sliderRenderBounds = null, this._sliderLimitRange = null;
21500
21533
  }
21501
21534
  release(all) {
21502
- super.release(all), ("browser" === vglobal.env ? vglobal : this.stage).addEventListener("touchmove", this._handleTouchMove, {
21535
+ super.release(all), ("browser" === vglobal.env ? vglobal : this.stage).removeEventListener("touchmove", this._handleTouchMove, {
21503
21536
  passive: !1
21504
21537
  }), this._clearDragEvents();
21505
21538
  }
@@ -23082,17 +23115,21 @@
23082
23115
  } = this.attribute.label;
23083
23116
  textStyle = isFunction$3(textStyle) ? merge({}, DEFAULT_AXIS_THEME.label.style, textStyle(tickDatum, index, tickData, layer)) : textStyle;
23084
23117
  const labelAlign = this.getLabelAlign(vector, inside, textStyle.angle);
23085
- return textStyle = merge(labelAlign, textStyle), isFunction$3(textStyle.text) && (textStyle.text = textStyle.text({
23118
+ textStyle = merge(labelAlign, textStyle), isFunction$3(textStyle.text) && (textStyle.text = textStyle.text({
23086
23119
  label: tickDatum.label,
23087
23120
  value: tickDatum.rawValue,
23088
23121
  index: tickDatum.index,
23089
23122
  layer: layer
23090
- })), Object.assign(Object.assign(Object.assign({}, this.getLabelPosition(point, vector, textContent, textStyle)), {
23123
+ }));
23124
+ let reactStyle = textStyle.react;
23125
+ return isFunction$3(reactStyle) && (reactStyle = reactStyle(tickDatum, index, tickData, layer)), Object.assign(Object.assign(Object.assign(Object.assign({}, this.getLabelPosition(point, vector, textContent, textStyle)), {
23091
23126
  text: null != text ? text : textContent,
23092
23127
  _originText: tickDatum.label,
23093
23128
  lineHeight: null == textStyle ? void 0 : textStyle.fontSize,
23094
23129
  type: type
23095
- }), textStyle);
23130
+ }), textStyle), {
23131
+ react: reactStyle
23132
+ });
23096
23133
  }
23097
23134
  getLabelPosition(point, vector, text, style) {
23098
23135
  return point;
@@ -24121,6 +24158,8 @@
24121
24158
  this.status === STATUS$1.RUNNING && (this.tickCounts++, this.timelines.forEach(timeline => {
24122
24159
  timeline.tick(delta);
24123
24160
  }), this.emit("tick", delta));
24161
+ }, this._handleGraphTick = () => {
24162
+ this.initHandler(!1);
24124
24163
  }, this.init(), this.lastFrameTime = -1, this.tickCounts = 0, this.stage = stage, this.autoStop = !0, this.interval = 16, this.computeTimeOffsetAndJitter();
24125
24164
  }
24126
24165
  bindStage(stage) {
@@ -24130,9 +24169,7 @@
24130
24169
  this.timeOffset = Math.floor(Math.random() * this.interval), this._jitter = Math.min(Math.max(.2 * this.interval, 6), .7 * this.interval);
24131
24170
  }
24132
24171
  init() {
24133
- this.interval = 16, this.status = STATUS$1.INITIAL, application.global.hooks.onSetEnv.tap("graph-ticker", () => {
24134
- this.initHandler(!1);
24135
- }), application.global.env && this.initHandler(!1);
24172
+ this.interval = 16, this.status = STATUS$1.INITIAL, application.global.hooks.onSetEnv.tap("graph-ticker", this._handleGraphTick), application.global.env && this.initHandler(!1);
24136
24173
  }
24137
24174
  addTimeline(timeline) {
24138
24175
  this.timelines.push(timeline);
@@ -24205,7 +24242,7 @@
24205
24242
  }
24206
24243
  release() {
24207
24244
  var _a;
24208
- this.stop(), this.timelines = [], null === (_a = this.tickerHandler) || void 0 === _a || _a.release(), this.tickerHandler = null, this.lastFrameTime = -1;
24245
+ this.stop(), this.timelines = [], null === (_a = this.tickerHandler) || void 0 === _a || _a.release(), this.tickerHandler = null, this.lastFrameTime = -1, application.global.hooks.onSetEnv.unTap("graph-ticker", this._handleGraphTick);
24209
24246
  }
24210
24247
  checkSkip(delta) {
24211
24248
  var _a, _b, _c;
@@ -32684,7 +32721,7 @@
32684
32721
  };
32685
32722
  }
32686
32723
  release(all) {
32687
- super.release(all), ("browser" === vglobal.env ? vglobal : this.stage).addEventListener("touchmove", this._handleTouchMove, {
32724
+ super.release(all), ("browser" === vglobal.env ? vglobal : this.stage).removeEventListener("touchmove", this._handleTouchMove, {
32688
32725
  passive: !1
32689
32726
  }), this._clearAllDragEvents();
32690
32727
  }
@@ -55292,6 +55329,10 @@
55292
55329
  let maxHeight = 0;
55293
55330
  for (let col = 0; col < this.table.frozenColCount; col++) {
55294
55331
  const colGroup = this.table.scenegraph.getColGroup(col);
55332
+ if (!colGroup) {
55333
+ this.table.scenegraph.rowHeaderGroup.setAttribute('height', maxHeight);
55334
+ return;
55335
+ }
55295
55336
  this.table.isListTable() ? 'body' : 'rowHeader';
55296
55337
  const { height } = createComplexColumn(colGroup, col, colGroup.attribute.width, this.currentRow + 1, endRow, this.table.scenegraph.mergeMap, this.table.defaultRowHeight, this.table);
55297
55338
  maxHeight = Math.max(maxHeight, height);
@@ -71297,6 +71338,7 @@
71297
71338
  class BaseTable extends EventTarget$1 {
71298
71339
  internalProps;
71299
71340
  showFrozenIcon = true;
71341
+ _scrollToRowCorrectTimer = null;
71300
71342
  padding;
71301
71343
  globalDropDownMenu;
71302
71344
  tableNoFrameWidth;
@@ -71331,7 +71373,7 @@
71331
71373
  return TABLE_EVENT_TYPE;
71332
71374
  }
71333
71375
  options;
71334
- version = "1.0.33";
71376
+ version = "1.0.34";
71335
71377
  pagination;
71336
71378
  id = `VTable${Date.now()}`;
71337
71379
  headerStyleCache;
@@ -72929,6 +72971,10 @@
72929
72971
  if (this.isReleased) {
72930
72972
  return;
72931
72973
  }
72974
+ if (this._scrollToRowCorrectTimer) {
72975
+ clearTimeout(this._scrollToRowCorrectTimer);
72976
+ this._scrollToRowCorrectTimer = null;
72977
+ }
72932
72978
  internalProps.tooltipHandler?.release?.();
72933
72979
  internalProps.menuHandler?.release?.();
72934
72980
  super.release?.();
@@ -74526,12 +74572,31 @@
74526
74572
  getGroupTitleLevel(col, row) {
74527
74573
  return undefined;
74528
74574
  }
74575
+ _scheduleScrollToRowCorrect(row, delay = 0) {
74576
+ this._scrollToRowCorrectTimer = setTimeout(() => {
74577
+ const drawRange = this.getDrawRange();
74578
+ const frozenHeight = this.getFrozenRowsHeight();
74579
+ const targetScrollTop = Math.max(0, Math.min(this.getRowsHeight(0, row) - frozenHeight, this.getAllRowsHeight() - drawRange.height));
74580
+ if (targetScrollTop !== this.scrollTop) {
74581
+ this.scrollTop = targetScrollTop;
74582
+ }
74583
+ }, delay);
74584
+ }
74529
74585
  scrollToRow(row, animationOption) {
74586
+ if (!isNumber$2(row) || this.rowCount <= 0) {
74587
+ return;
74588
+ }
74589
+ const targetRow = Math.min(Math.max(Math.floor(row), 0), this.rowCount - 1);
74530
74590
  if (!animationOption) {
74531
- this.scrollToCell({ row });
74591
+ this.scrollToCell({ row: targetRow });
74592
+ this._scheduleScrollToRowCorrect(targetRow);
74532
74593
  return;
74533
74594
  }
74534
- this.animationManager.scrollTo({ row }, animationOption);
74595
+ const duration = !isBoolean$2(animationOption) ? animationOption?.duration ?? 3000 : 3000;
74596
+ this.animationManager.scrollTo({ row: targetRow }, animationOption);
74597
+ this._scrollToRowCorrectTimer = setTimeout(() => {
74598
+ this.scrollToRow(targetRow, false);
74599
+ }, duration);
74535
74600
  }
74536
74601
  scrollToCol(col, animationOption) {
74537
74602
  if (!animationOption) {
@@ -95094,7 +95159,7 @@
95094
95159
  }
95095
95160
 
95096
95161
  registerForVrender();
95097
- const version = "1.0.33";
95162
+ const version = "1.0.34";
95098
95163
  function getIcons() {
95099
95164
  return get$2();
95100
95165
  }