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

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.
@@ -41544,8 +41544,10 @@
41544
41544
  function setCheckedState(col, row, field, checked, state) {
41545
41545
  const recordIndex = state.table.getRecordShowIndexByCell(col, row);
41546
41546
  if (recordIndex >= 0) {
41547
- const dataIndex = state.table.dataSource.getIndexKey(recordIndex);
41548
- state.checkedState[dataIndex] || (state.checkedState[dataIndex] = {}), state.checkedState[dataIndex][field] = checked;
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
+ });
41549
41551
  }
41550
41552
  }
41551
41553
  function setHeaderCheckedState(field, checked, state) {
@@ -41559,21 +41561,23 @@
41559
41561
  if (state.table.isHeader(col, row)) {
41560
41562
  if (isValid$1(state.headerCheckedState[field])) return state.headerCheckedState[field];
41561
41563
  if ("function" == typeof checked) return;
41562
- if (isValid$1(checked)) state.headerCheckedState[field] = checked;else if ((null === (_a = state.checkedState) || void 0 === _a ? void 0 : _a.length) > 0) {
41564
+ if (isValid$1(checked)) state.headerCheckedState[field] = checked;else if ((null === (_a = state.checkedState) || void 0 === _a ? void 0 : _a.size) > 0) {
41563
41565
  return state.updateHeaderCheckedState(field, col, row);
41564
41566
  }
41565
41567
  return state.headerCheckedState[field];
41566
41568
  }
41567
41569
  const recordIndex = state.table.getRecordShowIndexByCell(col, row);
41568
41570
  if (recordIndex >= 0) {
41569
- const dataIndex = state.table.dataSource.getIndexKey(recordIndex);
41570
- if (isValid$1(null === (_b = state.checkedState[dataIndex]) || void 0 === _b ? void 0 : _b[field])) return state.checkedState[dataIndex][field];
41571
- state.checkedState[dataIndex] || (state.checkedState[dataIndex] = {}), state.checkedState[dataIndex][field] = checked;
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
+ });
41572
41576
  }
41573
41577
  return checked;
41574
41578
  }
41575
41579
  function initCheckedState(records, state) {
41576
- state.checkedState = [], state.headerCheckedState = {}, state.radioState = {};
41580
+ state.checkedState.clear(), state.headerCheckedState = {}, state.radioState = {};
41577
41581
  let isNeedInitHeaderCheckedStateFromRecord = !1;
41578
41582
  if (state._checkboxCellTypeFields = [], state._headerCheckFuncs = {}, state.table.internalProps.layoutMap.headerObjects.forEach((hd, index) => {
41579
41583
  if ("checkbox" === hd.headerType) {
@@ -41584,46 +41588,29 @@
41584
41588
  for (let i = 0; i < state.table.leftRowSeriesNumberCount; i++) state.headerCheckedState[`_vtable_rowSeries_number_${i}`] = !1, state._checkboxCellTypeFields.push(`_vtable_rowSeries_number_${i}`);
41585
41589
  isNeedInitHeaderCheckedStateFromRecord = !0;
41586
41590
  }
41587
- isNeedInitHeaderCheckedStateFromRecord && (null == records || records.forEach((record, index) => {
41588
- state._checkboxCellTypeFields.forEach(field => {
41589
- const value = record[field];
41590
- let isChecked;
41591
- if (isObject$4(value) ? isChecked = value.checked : "boolean" == typeof value && (isChecked = value), null == isChecked) {
41592
- const headerCheckFunc = state._headerCheckFuncs[field];
41593
- if (headerCheckFunc) {
41594
- const cellAddr = state.table.getCellAddrByFieldRecord(field, index);
41595
- isChecked = getOrApply(headerCheckFunc, {
41596
- col: cellAddr.col,
41597
- row: cellAddr.row,
41598
- table: state.table,
41599
- context: null,
41600
- value: value
41601
- });
41602
- }
41603
- }
41604
- state.checkedState[index] || (state.checkedState[index] = {}), state.checkedState[index][field] = isChecked;
41605
- });
41606
- }));
41591
+ isNeedInitHeaderCheckedStateFromRecord && initRecordCheckState(state);
41607
41592
  }
41608
41593
  function updateHeaderCheckedState(field, state, col, row) {
41609
- const allChecked = state.checkedState.every((check_state, index) => {
41610
- const tableIndex = state.table.getTableIndexByRecordIndex(index);
41611
- return !!(state.table.transpose ? state.table.getCustomMerge(tableIndex, row) : state.table.getCustomMerge(col, tableIndex)) || !0 === (null == check_state ? void 0 : check_state[field]);
41612
- });
41613
- if (allChecked) return state.headerCheckedState[field] = !0, allChecked;
41614
- if (state.checkedState.every((check_state, index) => {
41615
- const tableIndex = state.table.getTableIndexByRecordIndex(index);
41616
- return !!(state.table.transpose ? state.table.getCustomMerge(tableIndex, row) : state.table.getCustomMerge(col, tableIndex)) || !1 === (null == check_state ? void 0 : check_state[field]);
41617
- })) return state.headerCheckedState[field] = !1, !1;
41618
- return !!state.checkedState.find(check_state => !0 === (null == check_state ? void 0 : check_state[field])) && (state.headerCheckedState[field] = "indeterminate", "indeterminate");
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");
41619
41604
  }
41620
41605
  function initLeftRecordsCheckState(records, state) {
41621
- for (let index = state.checkedState.length; index < records.length; index++) {
41606
+ for (let index = state.checkedState.size; index < records.length; index++) {
41622
41607
  const record = records[index];
41623
41608
  state._checkboxCellTypeFields.forEach(field => {
41624
41609
  const value = record[field];
41625
41610
  let isChecked;
41626
- isObject$4(value) ? isChecked = value.checked : "boolean" == typeof value && (isChecked = value), state.checkedState[index] || (state.checkedState[index] = {}), state.checkedState[index][field] = 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;
41627
41614
  });
41628
41615
  }
41629
41616
  }
@@ -41656,14 +41643,35 @@
41656
41643
  checkedState: checkedState,
41657
41644
  table: table
41658
41645
  } = state;
41659
- 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) {
41660
- const sourceRecord = checkedState[sourceIndex];
41661
- for (let i = sourceIndex; i > targetIndex; i--) checkedState[i] = checkedState[i - 1];
41662
- checkedState[targetIndex] = sourceRecord;
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);
41663
41666
  } else if (sourceIndex < targetIndex) {
41664
- const sourceRecord = checkedState[sourceIndex];
41665
- for (let i = sourceIndex; i < targetIndex; i++) checkedState[i] = checkedState[i + 1];
41666
- checkedState[targetIndex] = sourceRecord;
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);
41667
41675
  }
41668
41676
  }
41669
41677
  function getGroupCheckboxState(table) {
@@ -41675,10 +41683,37 @@
41675
41683
  const {
41676
41684
  vtableOriginIndex: vtableOriginIndex
41677
41685
  } = dataSource.getRawRecord(indexArr);
41678
- result[vtableOriginIndex] = table.stateManager.checkedState[indexArr];
41686
+ result[vtableOriginIndex] = table.stateManager.checkedState.get(indexArr.toString());
41679
41687
  }
41680
41688
  }), result;
41681
41689
  }
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
+ }
41682
41717
 
41683
41718
  function updateResizeRow(xInTable, yInTable, state) {
41684
41719
  xInTable = Math.ceil(xInTable), yInTable = Math.ceil(yInTable);
@@ -41766,7 +41801,7 @@
41766
41801
 
41767
41802
  class StateManager {
41768
41803
  constructor(table) {
41769
- this.fastScrolling = !1, this.checkedState = [], this.headerCheckedState = {}, this._checkboxCellTypeFields = [], this._headerCheckFuncs = {}, this.radioState = {}, this.resetInteractionState = debounce(state => {
41804
+ this.fastScrolling = !1, this.checkedState = new Map(), this.headerCheckedState = {}, this._checkboxCellTypeFields = [], this._headerCheckFuncs = {}, this.radioState = {}, this.resetInteractionState = debounce(state => {
41770
41805
  this.updateInteractionState(null != state ? state : InteractionState.default);
41771
41806
  }, 100), this.table = table, this.initState(), this.updateVerticalScrollBar = this.updateVerticalScrollBar.bind(this), this.updateHorizontalScrollBar = this.updateHorizontalScrollBar.bind(this);
41772
41807
  }
@@ -42446,7 +42481,7 @@
42446
42481
  return syncRadioState(col, row, field, radioType, indexInCell, isChecked, this);
42447
42482
  }
42448
42483
  changeCheckboxAndRadioOrder(sourceIndex, targetIndex) {
42449
- this.checkedState.length && changeCheckboxOrder(sourceIndex, targetIndex, this), this.radioState.length && changeRadioOrder(sourceIndex, targetIndex, this);
42484
+ this.checkedState.size && changeCheckboxOrder(sourceIndex, targetIndex, this), this.radioState.length && changeRadioOrder(sourceIndex, targetIndex, this);
42450
42485
  }
42451
42486
  setCustomSelectRanges(customSelectRanges) {
42452
42487
  deletaCustomSelectRanges(this), addCustomSelectRanges(customSelectRanges, this);
@@ -46372,7 +46407,7 @@
46372
46407
  constructor(container) {
46373
46408
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
46374
46409
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
46375
- if (super(), this.showFrozenIcon = !0, this.version = "1.13.2", 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");
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");
46376
46411
  const {
46377
46412
  frozenColCount = 0,
46378
46413
  frozenRowCount: frozenRowCount,
@@ -50574,11 +50609,11 @@
50574
50609
  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();
50575
50610
  }
50576
50611
  getCheckboxState(field) {
50577
- if (this.stateManager.checkedState.length < this.rowCount - this.columnHeaderLevelCount && this.stateManager.initLeftRecordsCheckState(this.records), isValid$1(field)) {
50578
- let stateArr = this.stateManager.checkedState;
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();
50579
50614
  return this.options.groupBy && (stateArr = getGroupCheckboxState(this)), stateArr.map(state => state[field]);
50580
50615
  }
50581
- return this.stateManager.checkedState;
50616
+ return new Array(...this.stateManager.checkedState.values());
50582
50617
  }
50583
50618
  getCellCheckboxState(col, row) {
50584
50619
  var _a;
@@ -50586,8 +50621,8 @@
50586
50621
  field = null == define ? void 0 : define.field,
50587
50622
  cellType = this.getCellType(col, row);
50588
50623
  if (isValid$1(field) && "checkbox" === cellType) {
50589
- const dataIndex = this.dataSource.getIndexKey(this.getRecordShowIndexByCell(col, row));
50590
- return null === (_a = this.stateManager.checkedState[dataIndex]) || void 0 === _a ? void 0 : _a[field];
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];
50591
50626
  }
50592
50627
  }
50593
50628
  getRadioState(field) {