@visactor/vtable-calendar 1.13.3-alpha.0 → 1.13.3-alpha.10

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.
@@ -32503,24 +32503,6 @@
32503
32503
  cursor: "pointer"
32504
32504
  };
32505
32505
  },
32506
- get loading() {
32507
- return {
32508
- type: "image",
32509
- src: "https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/VTable/media/loading-circle.gif",
32510
- width: collapse_size,
32511
- height: collapse_size,
32512
- name: "loading",
32513
- positionType: IconPosition.contentLeft,
32514
- marginLeft: 0,
32515
- marginRight: 4,
32516
- hover: {
32517
- width: collapse_size_2,
32518
- height: collapse_size_2,
32519
- bgColor: "rgba(101, 117, 168, 0.1)"
32520
- },
32521
- isGif: !0
32522
- };
32523
- },
32524
32506
  get drillDown() {
32525
32507
  return {
32526
32508
  name: "drillDown",
@@ -41544,10 +41526,8 @@
41544
41526
  function setCheckedState(col, row, field, checked, state) {
41545
41527
  const recordIndex = state.table.getRecordShowIndexByCell(col, row);
41546
41528
  if (recordIndex >= 0) {
41547
- const dataIndex = state.table.dataSource.getIndexKey(recordIndex).toString();
41548
- state.checkedState.has(dataIndex) ? state.checkedState.get(dataIndex)[field] = checked : state.checkedState.set(dataIndex, {
41549
- [field]: checked
41550
- });
41529
+ const dataIndex = state.table.dataSource.getIndexKey(recordIndex);
41530
+ state.checkedState[dataIndex] || (state.checkedState[dataIndex] = {}), state.checkedState[dataIndex][field] = checked;
41551
41531
  }
41552
41532
  }
41553
41533
  function setHeaderCheckedState(field, checked, state) {
@@ -41561,23 +41541,21 @@
41561
41541
  if (state.table.isHeader(col, row)) {
41562
41542
  if (isValid$1(state.headerCheckedState[field])) return state.headerCheckedState[field];
41563
41543
  if ("function" == typeof checked) return;
41564
- if (isValid$1(checked)) state.headerCheckedState[field] = checked;else if ((null === (_a = state.checkedState) || void 0 === _a ? void 0 : _a.size) > 0) {
41544
+ if (isValid$1(checked)) state.headerCheckedState[field] = checked;else if ((null === (_a = state.checkedState) || void 0 === _a ? void 0 : _a.length) > 0) {
41565
41545
  return state.updateHeaderCheckedState(field, col, row);
41566
41546
  }
41567
41547
  return state.headerCheckedState[field];
41568
41548
  }
41569
41549
  const recordIndex = state.table.getRecordShowIndexByCell(col, row);
41570
41550
  if (recordIndex >= 0) {
41571
- const dataIndex = state.table.dataSource.getIndexKey(recordIndex).toString();
41572
- if (isValid$1(null === (_b = state.checkedState.get(dataIndex)) || void 0 === _b ? void 0 : _b[field])) return state.checkedState.get(dataIndex)[field];
41573
- state.checkedState.has(dataIndex) ? state.checkedState.get(dataIndex)[field] = checked : state.checkedState.set(dataIndex, {
41574
- [field]: checked
41575
- });
41551
+ const dataIndex = state.table.dataSource.getIndexKey(recordIndex);
41552
+ if (isValid$1(null === (_b = state.checkedState[dataIndex]) || void 0 === _b ? void 0 : _b[field])) return state.checkedState[dataIndex][field];
41553
+ state.checkedState[dataIndex] || (state.checkedState[dataIndex] = {}), state.checkedState[dataIndex][field] = checked;
41576
41554
  }
41577
41555
  return checked;
41578
41556
  }
41579
41557
  function initCheckedState(records, state) {
41580
- state.checkedState.clear(), state.headerCheckedState = {}, state.radioState = {};
41558
+ state.checkedState = [], state.headerCheckedState = {}, state.radioState = {};
41581
41559
  let isNeedInitHeaderCheckedStateFromRecord = !1;
41582
41560
  if (state._checkboxCellTypeFields = [], state._headerCheckFuncs = {}, state.table.internalProps.layoutMap.headerObjects.forEach((hd, index) => {
41583
41561
  if ("checkbox" === hd.headerType) {
@@ -41588,29 +41566,46 @@
41588
41566
  for (let i = 0; i < state.table.leftRowSeriesNumberCount; i++) state.headerCheckedState[`_vtable_rowSeries_number_${i}`] = !1, state._checkboxCellTypeFields.push(`_vtable_rowSeries_number_${i}`);
41589
41567
  isNeedInitHeaderCheckedStateFromRecord = !0;
41590
41568
  }
41591
- isNeedInitHeaderCheckedStateFromRecord && initRecordCheckState(state);
41569
+ isNeedInitHeaderCheckedStateFromRecord && (null == records || records.forEach((record, index) => {
41570
+ state._checkboxCellTypeFields.forEach(field => {
41571
+ const value = record[field];
41572
+ let isChecked;
41573
+ if (isObject$4(value) ? isChecked = value.checked : "boolean" == typeof value && (isChecked = value), null == isChecked) {
41574
+ const headerCheckFunc = state._headerCheckFuncs[field];
41575
+ if (headerCheckFunc) {
41576
+ const cellAddr = state.table.getCellAddrByFieldRecord(field, index);
41577
+ isChecked = getOrApply(headerCheckFunc, {
41578
+ col: cellAddr.col,
41579
+ row: cellAddr.row,
41580
+ table: state.table,
41581
+ context: null,
41582
+ value: value
41583
+ });
41584
+ }
41585
+ }
41586
+ state.checkedState[index] || (state.checkedState[index] = {}), state.checkedState[index][field] = isChecked;
41587
+ });
41588
+ }));
41592
41589
  }
41593
41590
  function updateHeaderCheckedState(field, state, col, row) {
41594
- let allChecked = !0,
41595
- allUnChecked = !0,
41596
- hasChecked = !1;
41597
- return state.checkedState.forEach((check_state, index) => {
41598
- index = index.includes(",") ? index.split(",").map(item => Number(item)) : Number(index);
41599
- const tableIndex = state.table.getTableIndexByRecordIndex(index),
41600
- mergeCell = state.table.transpose ? state.table.getCustomMerge(tableIndex, row) : state.table.getCustomMerge(col, tableIndex),
41601
- data = state.table.dataSource.get(index);
41602
- mergeCell || data.vtableMerge || (!0 !== (null == check_state ? void 0 : check_state[field]) ? allChecked = !1 : (allUnChecked = !1, hasChecked = !0));
41603
- }), allChecked ? (state.headerCheckedState[field] = !0, allChecked) : allUnChecked ? (state.headerCheckedState[field] = !1, !1) : !!hasChecked && (state.headerCheckedState[field] = "indeterminate", "indeterminate");
41591
+ const allChecked = state.checkedState.every((check_state, index) => {
41592
+ const tableIndex = state.table.getTableIndexByRecordIndex(index);
41593
+ return !!(state.table.transpose ? state.table.getCustomMerge(tableIndex, row) : state.table.getCustomMerge(col, tableIndex)) || !0 === (null == check_state ? void 0 : check_state[field]);
41594
+ });
41595
+ if (allChecked) return state.headerCheckedState[field] = !0, allChecked;
41596
+ if (state.checkedState.every((check_state, index) => {
41597
+ const tableIndex = state.table.getTableIndexByRecordIndex(index);
41598
+ return !!(state.table.transpose ? state.table.getCustomMerge(tableIndex, row) : state.table.getCustomMerge(col, tableIndex)) || !1 === (null == check_state ? void 0 : check_state[field]);
41599
+ })) return state.headerCheckedState[field] = !1, !1;
41600
+ return !!state.checkedState.find(check_state => !0 === (null == check_state ? void 0 : check_state[field])) && (state.headerCheckedState[field] = "indeterminate", "indeterminate");
41604
41601
  }
41605
41602
  function initLeftRecordsCheckState(records, state) {
41606
- for (let index = state.checkedState.size; index < records.length; index++) {
41603
+ for (let index = state.checkedState.length; index < records.length; index++) {
41607
41604
  const record = records[index];
41608
41605
  state._checkboxCellTypeFields.forEach(field => {
41609
41606
  const value = record[field];
41610
41607
  let isChecked;
41611
- isObject$4(value) ? isChecked = value.checked : "boolean" == typeof value && (isChecked = value);
41612
- const dataIndex = index.toString();
41613
- state.checkedState.get(dataIndex) || state.checkedState.set(dataIndex, {}), state.checkedState.get(dataIndex)[field] = isChecked;
41608
+ isObject$4(value) ? isChecked = value.checked : "boolean" == typeof value && (isChecked = value), state.checkedState[index] || (state.checkedState[index] = {}), state.checkedState[index][field] = isChecked;
41614
41609
  });
41615
41610
  }
41616
41611
  }
@@ -41643,35 +41638,14 @@
41643
41638
  checkedState: checkedState,
41644
41639
  table: table
41645
41640
  } = state;
41646
- let source, target;
41647
- if (table.internalProps.transpose ? (sourceIndex = table.getRecordShowIndexByCell(sourceIndex, 0), targetIndex = table.getRecordShowIndexByCell(targetIndex, 0)) : (source = table.getRecordIndexByCell(0, sourceIndex), target = table.getRecordIndexByCell(0, targetIndex)), isNumber$2(source) && isNumber$2(target)) {
41648
- if (sourceIndex > targetIndex) {
41649
- const sourceRecord = checkedState.get(sourceIndex.toString());
41650
- for (let i = sourceIndex; i > targetIndex; i--) checkedState.set(i.toString(), checkedState.get((i - 1).toString()));
41651
- checkedState.set(targetIndex.toString(), sourceRecord);
41652
- } else if (sourceIndex < targetIndex) {
41653
- const sourceRecord = checkedState.get(sourceIndex.toString());
41654
- for (let i = sourceIndex; i < targetIndex; i++) checkedState.set(i.toString(), checkedState.get((i + 1).toString()));
41655
- checkedState.set(targetIndex.toString(), sourceRecord);
41656
- }
41657
- } else if (isArray$1(source) && isArray$1(target)) if ((sourceIndex = source[source.length - 1]) > (targetIndex = target[target.length - 1])) {
41658
- const sourceRecord = checkedState.get(source.toString());
41659
- for (let i = sourceIndex; i > targetIndex; i--) {
41660
- const now = [...source];
41661
- now[now.length - 1] = i;
41662
- const last = [...source];
41663
- last[last.length - 1] = i - 1, checkedState.set(now.toString(), checkedState.get(last.toString()));
41664
- }
41665
- checkedState.set(target.toString(), sourceRecord);
41641
+ if (table.internalProps.transpose ? (sourceIndex = table.getRecordShowIndexByCell(sourceIndex, 0), targetIndex = table.getRecordShowIndexByCell(targetIndex, 0)) : (sourceIndex = table.getRecordShowIndexByCell(0, sourceIndex), targetIndex = table.getRecordShowIndexByCell(0, targetIndex)), sourceIndex > targetIndex) {
41642
+ const sourceRecord = checkedState[sourceIndex];
41643
+ for (let i = sourceIndex; i > targetIndex; i--) checkedState[i] = checkedState[i - 1];
41644
+ checkedState[targetIndex] = sourceRecord;
41666
41645
  } else if (sourceIndex < targetIndex) {
41667
- const sourceRecord = checkedState.get(source.toString());
41668
- for (let i = sourceIndex; i < targetIndex; i++) {
41669
- const now = [...source];
41670
- now[now.length - 1] = i;
41671
- const next = [...source];
41672
- next[next.length - 1] = i + 1, checkedState.set(now.toString(), checkedState.get(next.toString()));
41673
- }
41674
- checkedState.set(target.toString(), sourceRecord);
41646
+ const sourceRecord = checkedState[sourceIndex];
41647
+ for (let i = sourceIndex; i < targetIndex; i++) checkedState[i] = checkedState[i + 1];
41648
+ checkedState[targetIndex] = sourceRecord;
41675
41649
  }
41676
41650
  }
41677
41651
  function getGroupCheckboxState(table) {
@@ -41683,37 +41657,10 @@
41683
41657
  const {
41684
41658
  vtableOriginIndex: vtableOriginIndex
41685
41659
  } = dataSource.getRawRecord(indexArr);
41686
- result[vtableOriginIndex] = table.stateManager.checkedState.get(indexArr.toString());
41660
+ result[vtableOriginIndex] = table.stateManager.checkedState[indexArr];
41687
41661
  }
41688
41662
  }), result;
41689
41663
  }
41690
- function initRecordCheckState(state) {
41691
- const table = state.table,
41692
- start = table.internalProps.transpose ? table.rowHeaderLevelCount : table.columnHeaderLevelCount,
41693
- end = table.internalProps.transpose ? table.colCount : table.rowCount;
41694
- for (let index = 0; index + start < end; index++) {
41695
- const record = table.dataSource.get(index);
41696
- state._checkboxCellTypeFields.forEach(field => {
41697
- const value = record[field];
41698
- let isChecked;
41699
- if (isObject$4(value) ? isChecked = value.checked : "boolean" == typeof value && (isChecked = value), null == isChecked) {
41700
- const headerCheckFunc = state._headerCheckFuncs[field];
41701
- if (headerCheckFunc) {
41702
- const cellAddr = state.table.getCellAddrByFieldRecord(field, index);
41703
- isChecked = getOrApply(headerCheckFunc, {
41704
- col: cellAddr.col,
41705
- row: cellAddr.row,
41706
- table: state.table,
41707
- context: null,
41708
- value: value
41709
- });
41710
- }
41711
- }
41712
- const dataIndex = state.table.dataSource.getIndexKey(index).toString();
41713
- state.checkedState.get(dataIndex) || state.checkedState.set(dataIndex, {}), state.checkedState.get(dataIndex)[field] = isChecked;
41714
- });
41715
- }
41716
- }
41717
41664
 
41718
41665
  function updateResizeRow(xInTable, yInTable, state) {
41719
41666
  xInTable = Math.ceil(xInTable), yInTable = Math.ceil(yInTable);
@@ -41801,7 +41748,7 @@
41801
41748
 
41802
41749
  class StateManager {
41803
41750
  constructor(table) {
41804
- this.fastScrolling = !1, this.checkedState = new Map(), this.headerCheckedState = {}, this._checkboxCellTypeFields = [], this._headerCheckFuncs = {}, this.radioState = {}, this.resetInteractionState = debounce(state => {
41751
+ this.fastScrolling = !1, this.checkedState = [], this.headerCheckedState = {}, this._checkboxCellTypeFields = [], this._headerCheckFuncs = {}, this.radioState = {}, this.resetInteractionState = debounce(state => {
41805
41752
  this.updateInteractionState(null != state ? state : InteractionState.default);
41806
41753
  }, 100), this.table = table, this.initState(), this.updateVerticalScrollBar = this.updateVerticalScrollBar.bind(this), this.updateHorizontalScrollBar = this.updateHorizontalScrollBar.bind(this);
41807
41754
  }
@@ -42481,7 +42428,7 @@
42481
42428
  return syncRadioState(col, row, field, radioType, indexInCell, isChecked, this);
42482
42429
  }
42483
42430
  changeCheckboxAndRadioOrder(sourceIndex, targetIndex) {
42484
- this.checkedState.size && changeCheckboxOrder(sourceIndex, targetIndex, this), this.radioState.length && changeRadioOrder(sourceIndex, targetIndex, this);
42431
+ this.checkedState.length && changeCheckboxOrder(sourceIndex, targetIndex, this), this.radioState.length && changeRadioOrder(sourceIndex, targetIndex, this);
42485
42432
  }
42486
42433
  setCustomSelectRanges(customSelectRanges) {
42487
42434
  deletaCustomSelectRanges(this), addCustomSelectRanges(customSelectRanges, this);
@@ -45533,13 +45480,15 @@
45533
45480
  })(candCol, right);
45534
45481
  }
45535
45482
  function getTargetRowAt(absoluteY, _this) {
45483
+ var _a;
45536
45484
  if (0 === absoluteY) return {
45537
45485
  top: 0,
45538
45486
  row: 0,
45539
45487
  bottom: 0,
45540
45488
  height: 0
45541
45489
  };
45542
- const candRow = computeTargetRowByY(absoluteY, _this),
45490
+ const floorOrRound = !0 === (null === (_a = _this.options.customConfig) || void 0 === _a ? void 0 : _a._disableColumnAndRowSizeRound) ? Math.floor : Math.round,
45491
+ candRow = computeTargetRowByY(absoluteY, _this),
45543
45492
  bottom = _this.getRowsHeight(0, candRow);
45544
45493
  return absoluteY >= bottom ? ((startRow, startBottom) => {
45545
45494
  let top = startBottom - _this.getRowHeight(startRow);
@@ -45549,7 +45498,7 @@
45549
45498
  for (let row = startRow; row < rowCount; row++) {
45550
45499
  const height = _this.getRowHeight(row),
45551
45500
  bottom = top + height;
45552
- if (Math.round(top) <= Math.round(absoluteY) && Math.round(absoluteY) < Math.round(bottom)) return {
45501
+ if (floorOrRound(top) <= floorOrRound(absoluteY) && floorOrRound(absoluteY) < floorOrRound(bottom)) return {
45553
45502
  top: top,
45554
45503
  row: row,
45555
45504
  bottom: bottom,
@@ -45563,7 +45512,7 @@
45563
45512
  for (let row = startRow; row >= 0; row--) {
45564
45513
  const height = _this.getRowHeight(row),
45565
45514
  top = bottom - height;
45566
- if (Math.round(top) <= Math.round(absoluteY) && Math.round(absoluteY) < Math.round(bottom)) return {
45515
+ if (floorOrRound(top) <= floorOrRound(absoluteY) && floorOrRound(absoluteY) < floorOrRound(bottom)) return {
45567
45516
  top: top,
45568
45517
  row: row,
45569
45518
  bottom: bottom,
@@ -46407,7 +46356,7 @@
46407
46356
  constructor(container) {
46408
46357
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
46409
46358
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
46410
- if (super(), this.showFrozenIcon = !0, this.version = "1.13.3-alpha.0", this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200), !container && "node" !== options.mode && !options.canvas) throw new Error("vtable's container is undefined");
46359
+ if (super(), this.showFrozenIcon = !0, this.version = "1.13.3-alpha.10", this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200), !container && "node" !== options.mode && !options.canvas) throw new Error("vtable's container is undefined");
46411
46360
  const {
46412
46361
  frozenColCount = 0,
46413
46362
  frozenRowCount: frozenRowCount,
@@ -50609,11 +50558,11 @@
50609
50558
  this.scenegraph.clearCells(), this.sortState ? (this.dataSource.updateFilterRulesForSorted(filterRules), sortRecords(this)) : this.dataSource.updateFilterRules(filterRules), this.refreshRowColCount(), this.stateManager.initCheckedState(this.records), this.scenegraph.createSceneGraph();
50610
50559
  }
50611
50560
  getCheckboxState(field) {
50612
- if (this.stateManager.checkedState.size < this.rowCount - this.columnHeaderLevelCount && this.stateManager.initLeftRecordsCheckState(this.records), isValid$1(field)) {
50613
- let stateArr = this.stateManager.checkedState.values();
50561
+ if (this.stateManager.checkedState.length < this.rowCount - this.columnHeaderLevelCount && this.stateManager.initLeftRecordsCheckState(this.records), isValid$1(field)) {
50562
+ let stateArr = this.stateManager.checkedState;
50614
50563
  return this.options.groupBy && (stateArr = getGroupCheckboxState(this)), stateArr.map(state => state[field]);
50615
50564
  }
50616
- return new Array(...this.stateManager.checkedState.values());
50565
+ return this.stateManager.checkedState;
50617
50566
  }
50618
50567
  getCellCheckboxState(col, row) {
50619
50568
  var _a;
@@ -50621,8 +50570,8 @@
50621
50570
  field = null == define ? void 0 : define.field,
50622
50571
  cellType = this.getCellType(col, row);
50623
50572
  if (isValid$1(field) && "checkbox" === cellType) {
50624
- const dataIndex = this.dataSource.getIndexKey(this.getRecordShowIndexByCell(col, row)).toString();
50625
- return null === (_a = this.stateManager.checkedState.get(dataIndex)) || void 0 === _a ? void 0 : _a[field];
50573
+ const dataIndex = this.dataSource.getIndexKey(this.getRecordShowIndexByCell(col, row));
50574
+ return null === (_a = this.stateManager.checkedState[dataIndex]) || void 0 === _a ? void 0 : _a[field];
50626
50575
  }
50627
50576
  }
50628
50577
  getRadioState(field) {