@visactor/vtable-sheet 1.26.3-alpha.0 → 1.26.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.
@@ -43572,13 +43572,20 @@
43572
43572
  return parse$3(font);
43573
43573
  }
43574
43574
 
43575
- function getQuadProps(paddingOrigin) {
43575
+ function normalizeQuadArray(values) {
43576
+ return 0 === values.length ? [0, 0, 0, 0] : 1 === values.length ? [values[0], values[0], values[0], values[0]] : 2 === values.length ? [values[0], values[1], values[0], values[1]] : 3 === values.length ? [values[0], values[1], values[2], values[1]] : [values[0], values[1], values[2], values[3]];
43577
+ }
43578
+ function parseStringQuad(padding) {
43579
+ const tokens = padding.trim().split(/\s+/),
43580
+ values = tokens.map(token => Number.parseFloat(token)).filter(value => Number.isFinite(value));
43581
+ return values.length === tokens.length && values.length > 0 ? normalizeQuadArray(values) : [padding, padding, padding, padding];
43582
+ }
43583
+ function normalizePaddingObject(paddingOrigin) {
43576
43584
  var _a, _b, _c, _d;
43577
- if (isNumber$2(paddingOrigin) || isString$2(paddingOrigin) || isArray$8(paddingOrigin)) {
43578
- let padding = parsePadding(paddingOrigin);
43579
- return "number" == typeof padding || "string" == typeof padding ? padding = [padding, padding, padding, padding] : Array.isArray(padding) && (padding = padding.slice(0)), padding;
43580
- }
43581
- return paddingOrigin && (isFinite(paddingOrigin.bottom) || isFinite(paddingOrigin.left) || isFinite(paddingOrigin.right) || isFinite(paddingOrigin.top)) ? [null !== (_a = paddingOrigin.top) && void 0 !== _a ? _a : 0, null !== (_b = paddingOrigin.right) && void 0 !== _b ? _b : 0, null !== (_c = paddingOrigin.bottom) && void 0 !== _c ? _c : 0, null !== (_d = paddingOrigin.left) && void 0 !== _d ? _d : 0] : [0, 0, 0, 0];
43585
+ return Number.isFinite(paddingOrigin.bottom) || Number.isFinite(paddingOrigin.left) || Number.isFinite(paddingOrigin.right) || Number.isFinite(paddingOrigin.top) ? [null !== (_a = paddingOrigin.top) && void 0 !== _a ? _a : 0, null !== (_b = paddingOrigin.right) && void 0 !== _b ? _b : 0, null !== (_c = paddingOrigin.bottom) && void 0 !== _c ? _c : 0, null !== (_d = paddingOrigin.left) && void 0 !== _d ? _d : 0] : [0, 0, 0, 0];
43586
+ }
43587
+ function getQuadProps(paddingOrigin) {
43588
+ return Array.isArray(paddingOrigin) ? normalizeQuadArray(paddingOrigin.slice(0, 4)) : "number" == typeof paddingOrigin && Number.isFinite(paddingOrigin) ? [paddingOrigin, paddingOrigin, paddingOrigin, paddingOrigin] : "string" == typeof paddingOrigin ? parseStringQuad(paddingOrigin) : paddingOrigin && "object" == typeof paddingOrigin ? normalizePaddingObject(paddingOrigin) : [0, 0, 0, 0];
43582
43589
  }
43583
43590
 
43584
43591
  const TYPE_PAREN = 0,
@@ -44605,7 +44612,7 @@
44605
44612
  col: null !== (_b = null == range ? void 0 : range.start.col) && void 0 !== _b ? _b : col,
44606
44613
  row: null !== (_c = null == range ? void 0 : range.start.row) && void 0 !== _c ? _c : row,
44607
44614
  dataValue: table.getCellOriginValue(col, row),
44608
- value: table.getCellValue(col, row) || "",
44615
+ value: table.getCellValue(col, row),
44609
44616
  rect: {
44610
44617
  left: 0,
44611
44618
  top: 0,
@@ -44627,7 +44634,7 @@
44627
44634
  col: col,
44628
44635
  row: row,
44629
44636
  dataValue: table.getCellOriginValue(col, row),
44630
- value: table.getCellValue(col, row) || "",
44637
+ value: table.getCellValue(col, row),
44631
44638
  rect: {
44632
44639
  left: 0,
44633
44640
  top: 0,
@@ -46616,7 +46623,7 @@
46616
46623
  col: null !== (_b = null == cellRange ? void 0 : cellRange.start.col) && void 0 !== _b ? _b : col,
46617
46624
  row: null !== (_c = null == cellRange ? void 0 : cellRange.start.row) && void 0 !== _c ? _c : row,
46618
46625
  dataValue: table.getCellOriginValue(col, row),
46619
- value: table.getCellValue(col, row) || "",
46626
+ value: table.getCellValue(col, row),
46620
46627
  rect: getCellRect$1(col, row, table),
46621
46628
  table: table,
46622
46629
  originCol: col,
@@ -50797,7 +50804,7 @@
50797
50804
  col: null !== (_b = null == cellRange ? void 0 : cellRange.start.col) && void 0 !== _b ? _b : col,
50798
50805
  row: null !== (_c = null == cellRange ? void 0 : cellRange.start.row) && void 0 !== _c ? _c : row,
50799
50806
  dataValue: table.getCellOriginValue(col, row),
50800
- value: table.getCellValue(col, row) || "",
50807
+ value: table.getCellValue(col, row),
50801
50808
  rect: getCellRect(col, row, table),
50802
50809
  table: table,
50803
50810
  originCol: col,
@@ -53044,7 +53051,8 @@
53044
53051
  for (let col = table.colCount - currentRightFrozenCol - 1; col >= table.colCount - distRightFrozenCol; col--) {
53045
53052
  insertBefore(rightFrozenGroup, scene.getColGroup(col), rightFrozenGroup.firstChild);
53046
53053
  insertBefore(rightTopCornerGroup, scene.getColGroup(col, !0), rightTopCornerGroup.firstChild);
53047
- insertBefore(rightBottomCornerGroup, scene.getColGroupInBottom(col), rightBottomCornerGroup.firstChild);
53054
+ const bottomColGroup = scene.getColGroupInBottom(col);
53055
+ bottomColGroup && insertBefore(rightBottomCornerGroup, bottomColGroup, rightBottomCornerGroup.firstChild);
53048
53056
  }
53049
53057
  let x = 0;
53050
53058
  rightFrozenGroup.forEachChildren(columnGroup => {
@@ -53061,7 +53069,10 @@
53061
53069
  const headerColGroup = scene.getColGroupInRightTopCorner(col);
53062
53070
  headerColGroup.setAttribute("x", colHeaderGroup.lastChild.attribute.x + table.getColWidth(colHeaderGroup.lastChild.col)), colHeaderGroup.appendChild(headerColGroup);
53063
53071
  const bottomColGroup = scene.getColGroupInRightBottomCorner(col);
53064
- bottomColGroup.setAttribute("x", bottomFrozenGroup.lastChild.attribute.x + table.getColWidth(bottomFrozenGroup.lastChild.col)), bottomFrozenGroup.appendChild(bottomColGroup);
53072
+ if (bottomColGroup) {
53073
+ const lastBottomColGroup = bottomFrozenGroup.lastChild;
53074
+ bottomColGroup.setAttribute("x", lastBottomColGroup ? lastBottomColGroup.attribute.x + table.getColWidth(lastBottomColGroup.col) : 0), bottomFrozenGroup.appendChild(bottomColGroup);
53075
+ }
53065
53076
  }
53066
53077
  let x = 0;
53067
53078
  rightFrozenGroup.forEachChildren(columnGroup => {
@@ -57550,70 +57561,73 @@
57550
57561
  });
57551
57562
  }), table.scenegraph.tableGroup.addEventListener("pointerup", e => {
57552
57563
  var _a, _b, _c, _d, _e, _f, _g, _h;
57553
- if (0 === e.button) {
57554
- if ("grabing" === stateManager.interactionState) {
57555
- if (stateManager.updateInteractionState(InteractionState.default), stateManager.isResizeCol()) endResizeCol(table);else if (stateManager.isResizeRow()) endResizeRow(table);else if (stateManager.isMoveCol()) {
57556
- const endMoveColSuccess = table.stateManager.endMoveCol();
57557
- fireMoveColEventListeners(table, endMoveColSuccess, e.nativeEvent);
57558
- } else if (stateManager.isSelecting()) {
57559
- table.stateManager.endSelectCells(), table.stateManager.isFillHandle() && table.stateManager.endFillSelect();
57560
- const eventArgsSet = getEventArgsSet(e);
57561
- if (table.eventManager.isDraging && eventArgsSet.eventArgs && table.hasListeners(TABLE_EVENT_TYPE.DRAG_SELECT_END)) {
57562
- const cellsEvent = {
57563
- event: e.nativeEvent,
57564
- cells: [],
57565
- col: eventArgsSet.eventArgs.target.col,
57566
- row: eventArgsSet.eventArgs.target.row,
57567
- scaleRatio: table.canvas.getBoundingClientRect().width / table.canvas.offsetWidth,
57568
- target: null === (_a = null == eventArgsSet ? void 0 : eventArgsSet.eventArgs) || void 0 === _a ? void 0 : _a.target,
57569
- mergeCellInfo: null === (_b = eventArgsSet.eventArgs) || void 0 === _b ? void 0 : _b.mergeInfo
57570
- };
57571
- cellsEvent.cells = table.getSelectedCellInfos(), table.fireListeners(TABLE_EVENT_TYPE.DRAG_SELECT_END, cellsEvent);
57572
- }
57573
- }
57574
- } else stateManager.interactionState === InteractionState.scrolling && stateManager.updateInteractionState(InteractionState.default);
57575
- if (!table.eventManager.isDraging) {
57564
+ if (0 !== e.button) return;
57565
+ const endedResizeCol = stateManager.isResizeCol(),
57566
+ endedResizeRow = stateManager.isResizeRow(),
57567
+ endedMoveCol = stateManager.isMoveCol(),
57568
+ shouldSkipClickCell = endedResizeCol || endedResizeRow;
57569
+ if ("grabing" === stateManager.interactionState) {
57570
+ if (stateManager.updateInteractionState(InteractionState.default), endedResizeCol) endResizeCol(table);else if (endedResizeRow) endResizeRow(table);else if (endedMoveCol) {
57571
+ const endMoveColSuccess = table.stateManager.endMoveCol();
57572
+ fireMoveColEventListeners(table, endMoveColSuccess, e.nativeEvent);
57573
+ } else if (stateManager.isSelecting()) {
57574
+ table.stateManager.endSelectCells(), table.stateManager.isFillHandle() && table.stateManager.endFillSelect();
57576
57575
  const eventArgsSet = getEventArgsSet(e);
57577
- if (!eventManager.isTouchMove && 0 === e.button && eventArgsSet.eventArgs && table.hasListeners(TABLE_EVENT_TYPE.CLICK_CELL)) {
57578
- const {
57579
- col: col,
57580
- row: row
57581
- } = eventArgsSet.eventArgs,
57582
- cellInfo = table.getCellInfo(col, row);
57583
- let icon, position;
57584
- if (null === (_c = eventArgsSet.eventArgs) || void 0 === _c ? void 0 : _c.target) {
57585
- const iconInfo = getIconAndPositionFromTarget(null === (_d = eventArgsSet.eventArgs) || void 0 === _d ? void 0 : _d.target);
57586
- iconInfo && (icon = iconInfo.icon, position = iconInfo.position);
57587
- }
57588
- const cellsEvent = Object.assign(Object.assign({}, cellInfo), {
57576
+ if (table.eventManager.isDraging && eventArgsSet.eventArgs && table.hasListeners(TABLE_EVENT_TYPE.DRAG_SELECT_END)) {
57577
+ const cellsEvent = {
57589
57578
  event: e.nativeEvent,
57590
- federatedEvent: e,
57591
57579
  cells: [],
57592
- targetIcon: icon ? {
57593
- name: icon.name,
57594
- position: position,
57595
- funcType: icon.attribute.funcType
57596
- } : void 0,
57597
- target: null === (_e = null == eventArgsSet ? void 0 : eventArgsSet.eventArgs) || void 0 === _e ? void 0 : _e.target,
57598
- mergeCellInfo: null === (_f = eventArgsSet.eventArgs) || void 0 === _f ? void 0 : _f.mergeInfo
57599
- });
57600
- table.fireListeners(TABLE_EVENT_TYPE.CLICK_CELL, cellsEvent);
57580
+ col: eventArgsSet.eventArgs.target.col,
57581
+ row: eventArgsSet.eventArgs.target.row,
57582
+ scaleRatio: table.canvas.getBoundingClientRect().width / table.canvas.offsetWidth,
57583
+ target: null === (_a = null == eventArgsSet ? void 0 : eventArgsSet.eventArgs) || void 0 === _a ? void 0 : _a.target,
57584
+ mergeCellInfo: null === (_b = eventArgsSet.eventArgs) || void 0 === _b ? void 0 : _b.mergeInfo
57585
+ };
57586
+ cellsEvent.cells = table.getSelectedCellInfos(), table.fireListeners(TABLE_EVENT_TYPE.DRAG_SELECT_END, cellsEvent);
57601
57587
  }
57602
57588
  }
57603
- if (table.hasListeners(TABLE_EVENT_TYPE.MOUSEUP_CELL)) {
57604
- const eventArgsSet = getEventArgsSet(e);
57605
- eventArgsSet.eventArgs && table.fireListeners(TABLE_EVENT_TYPE.MOUSEUP_CELL, {
57606
- col: eventArgsSet.eventArgs.col,
57607
- row: eventArgsSet.eventArgs.row,
57589
+ } else stateManager.interactionState === InteractionState.scrolling && stateManager.updateInteractionState(InteractionState.default);
57590
+ if (!table.eventManager.isDraging && !shouldSkipClickCell) {
57591
+ const eventArgsSet = getEventArgsSet(e);
57592
+ if (!eventManager.isTouchMove && 0 === e.button && eventArgsSet.eventArgs && table.hasListeners(TABLE_EVENT_TYPE.CLICK_CELL)) {
57593
+ const {
57594
+ col: col,
57595
+ row: row
57596
+ } = eventArgsSet.eventArgs,
57597
+ cellInfo = table.getCellInfo(col, row);
57598
+ let icon, position;
57599
+ if (null === (_c = eventArgsSet.eventArgs) || void 0 === _c ? void 0 : _c.target) {
57600
+ const iconInfo = getIconAndPositionFromTarget(null === (_d = eventArgsSet.eventArgs) || void 0 === _d ? void 0 : _d.target);
57601
+ iconInfo && (icon = iconInfo.icon, position = iconInfo.position);
57602
+ }
57603
+ const cellsEvent = Object.assign(Object.assign({}, cellInfo), {
57608
57604
  event: e.nativeEvent,
57609
- target: null === (_g = null == eventArgsSet ? void 0 : eventArgsSet.eventArgs) || void 0 === _g ? void 0 : _g.target,
57610
- mergeCellInfo: null === (_h = eventArgsSet.eventArgs) || void 0 === _h ? void 0 : _h.mergeInfo
57605
+ federatedEvent: e,
57606
+ cells: [],
57607
+ targetIcon: icon ? {
57608
+ name: icon.name,
57609
+ position: position,
57610
+ funcType: icon.attribute.funcType
57611
+ } : void 0,
57612
+ target: null === (_e = null == eventArgsSet ? void 0 : eventArgsSet.eventArgs) || void 0 === _e ? void 0 : _e.target,
57613
+ mergeCellInfo: null === (_f = eventArgsSet.eventArgs) || void 0 === _f ? void 0 : _f.mergeInfo
57611
57614
  });
57615
+ table.fireListeners(TABLE_EVENT_TYPE.CLICK_CELL, cellsEvent);
57612
57616
  }
57613
- setTimeout(() => {
57614
- eventManager.isDown = !1, eventManager.isTouchdown = !1, eventManager.isTouchMove = !1, eventManager.isDraging = !1, eventManager.touchMovePoints = [];
57615
- }, 0);
57616
57617
  }
57618
+ if (table.hasListeners(TABLE_EVENT_TYPE.MOUSEUP_CELL)) {
57619
+ const eventArgsSet = getEventArgsSet(e);
57620
+ eventArgsSet.eventArgs && table.fireListeners(TABLE_EVENT_TYPE.MOUSEUP_CELL, {
57621
+ col: eventArgsSet.eventArgs.col,
57622
+ row: eventArgsSet.eventArgs.row,
57623
+ event: e.nativeEvent,
57624
+ target: null === (_g = null == eventArgsSet ? void 0 : eventArgsSet.eventArgs) || void 0 === _g ? void 0 : _g.target,
57625
+ mergeCellInfo: null === (_h = eventArgsSet.eventArgs) || void 0 === _h ? void 0 : _h.mergeInfo
57626
+ });
57627
+ }
57628
+ setTimeout(() => {
57629
+ eventManager.isDown = !1, eventManager.isTouchdown = !1, eventManager.isTouchMove = !1, eventManager.isDraging = !1, eventManager.touchMovePoints = [];
57630
+ }, 0);
57617
57631
  }), table.scenegraph.tableGroup.addEventListener("rightdown", e => {
57618
57632
  var _a, _b, _c, _d, _e, _f, _g, _h;
57619
57633
  const eventArgsSet = getEventArgsSet(e);
@@ -61431,7 +61445,7 @@
61431
61445
  }
61432
61446
  constructor(container, options = {}) {
61433
61447
  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;
61434
- if (super(), this.showFrozenIcon = !0, this._scrollToRowCorrectTimer = null, this._tableBorderWidth_left = 0, this._tableBorderWidth_right = 0, this._tableBorderWidth_top = 0, this._tableBorderWidth_bottom = 0, this.version = "1.26.2", this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200), "undefined" != typeof window) {
61448
+ if (super(), this.showFrozenIcon = !0, this._scrollToRowCorrectTimer = null, this._tableBorderWidth_left = 0, this._tableBorderWidth_right = 0, this._tableBorderWidth_top = 0, this._tableBorderWidth_bottom = 0, this.version = "1.26.3", this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200), "undefined" != typeof window) {
61435
61449
  const g = window;
61436
61450
  g[this.id] = this;
61437
61451
  const registry = g.__vtable__ || (g.__vtable__ = {
@@ -63644,16 +63658,17 @@
63644
63658
  }
63645
63659
  scrollToRow(row, animationOption) {
63646
63660
  var _a;
63647
- const targetRow = Math.min(Math.max(Math.floor(row), 0), this.rowCount - 1);
63661
+ const targetRow = Math.min(Math.max(row, 0), this.rowCount - 1),
63662
+ targetRowInt = Math.floor(targetRow);
63648
63663
  if (this.clearCorrectTimer(), !animationOption) return this.scrollToCell({
63649
- row: targetRow
63650
- }), void this._scheduleScrollToRowCorrect(targetRow);
63664
+ row: targetRowInt
63665
+ }), void this._scheduleScrollToRowCorrect(targetRowInt);
63651
63666
  const duration = isBoolean$2(animationOption) ? 3e3 : null !== (_a = null == animationOption ? void 0 : animationOption.duration) && void 0 !== _a ? _a : 3e3;
63652
63667
  this.animationManager.scrollTo({
63653
63668
  row: targetRow
63654
- }, animationOption), this._scrollToRowCorrectTimer = setTimeout(() => {
63655
- this.scrollToRow(targetRow, !1);
63656
- }, duration);
63669
+ }, animationOption), targetRowInt === targetRow && (this._scrollToRowCorrectTimer = setTimeout(() => {
63670
+ this.scrollToRow(targetRowInt, !1);
63671
+ }, duration));
63657
63672
  }
63658
63673
  scrollToCol(col, animationOption) {
63659
63674
  animationOption ? this.animationManager.scrollTo({
@@ -87769,7 +87784,7 @@
87769
87784
  return this.element;
87770
87785
  }
87771
87786
  targetIsOnEditor(target) {
87772
- return target === this.element || target === this.sheet.formulaUIManager.formulaInput;
87787
+ return target === this.element || target === this.sheet?.formulaUIManager.formulaInput;
87773
87788
  }
87774
87789
  createElement() {
87775
87790
  super.createElement();
@@ -87801,7 +87816,10 @@
87801
87816
  return;
87802
87817
  }
87803
87818
  const value = this.element.value;
87804
- this.sheet.formulaUIManager.formulaInput.value = value;
87819
+ const formulaInput = this.sheet.formulaUIManager.formulaInput;
87820
+ if (formulaInput) {
87821
+ formulaInput.value = value;
87822
+ }
87805
87823
  const highlightManager = this.sheet.formulaManager.cellHighlightManager;
87806
87824
  if (highlightManager) {
87807
87825
  if (value.startsWith('=')) {
@@ -91299,6 +91317,28 @@
91299
91317
  }
91300
91318
  }
91301
91319
 
91320
+ const normalizeColumnsField = (columns, startFieldIndex = 0) => {
91321
+ if (!columns?.length) {
91322
+ return startFieldIndex;
91323
+ }
91324
+ let fieldIndex = startFieldIndex;
91325
+ columns.forEach(column => {
91326
+ const childColumns = column
91327
+ .columns;
91328
+ if (childColumns?.length) {
91329
+ fieldIndex = normalizeColumnsField(childColumns, fieldIndex);
91330
+ return;
91331
+ }
91332
+ if (!isValid$2(column.field)) {
91333
+ column.field = fieldIndex;
91334
+ }
91335
+ if (!isValid$2(column.key)) {
91336
+ column.key = column.field;
91337
+ }
91338
+ fieldIndex++;
91339
+ });
91340
+ return fieldIndex;
91341
+ };
91302
91342
  class WorkSheet {
91303
91343
  options;
91304
91344
  container;
@@ -91426,10 +91466,7 @@
91426
91466
  this.options.columns = [];
91427
91467
  }
91428
91468
  else {
91429
- for (let i = 0; i < this.options.columns.length; i++) {
91430
- this.options.columns[i].field = i;
91431
- this.options.columns[i].key = i;
91432
- }
91469
+ normalizeColumnsField(this.options.columns);
91433
91470
  }
91434
91471
  if (!this.options.data) {
91435
91472
  this.options.data = [];
@@ -96192,7 +96229,7 @@
96192
96229
  importStyle();
96193
96230
  }
96194
96231
 
96195
- const version = "1.26.2";
96232
+ const version = "1.26.3";
96196
96233
  importStyles();
96197
96234
 
96198
96235
  exports.TYPES = index;