@deot/vc-components 1.0.11 → 1.0.12

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.
@@ -13318,6 +13318,7 @@
13318
13318
  isVisible.value = cursorDown.value;
13319
13319
  };
13320
13320
  const refreshThumb = () => raf(() => {
13321
+ if (!thumb.value) return;
13321
13322
  thumb.value.style[prefixStyle('transform').camel] = `translate${barOptions.value.axis}(${thumbMove.value}px)`;
13322
13323
  });
13323
13324
  const refreshThrottleThumb = throttle$2(refreshThumb, 10);
@@ -20034,6 +20035,7 @@
20034
20035
 
20035
20036
  // 设置data首个元素的在originalData索引值
20036
20037
  const setFirstItemIndex = () => {
20038
+ if (!wrapper.value) return;
20037
20039
  const position = wrapper.value[K.scrollAxis];
20038
20040
  let item;
20039
20041
  for (let i = 0; i < rebuildData.value.length; i++) {
@@ -20214,6 +20216,7 @@
20214
20216
 
20215
20217
  // 图片撑开时,会影响布局, 节流结束后调用
20216
20218
  const handleResize = throttle$1(async () => {
20219
+ if (!wrapper.value) return;
20217
20220
  const isNeedRefreshLayout = rebuildData.value.some(i => !i.isPlaceholder);
20218
20221
  if (isNeedRefreshLayout) {
20219
20222
  const oldFirstItemIndex = firstItemIndex.value;
@@ -20651,88 +20654,65 @@
20651
20654
  }
20652
20655
  });
20653
20656
 
20654
- const parseHeight = (height) => {
20655
- if (typeof height === "number") {
20656
- return height;
20657
+ const parseHeight = (v) => {
20658
+ if (typeof v === "number") {
20659
+ return v;
20657
20660
  }
20658
- if (height && typeof height === "string") {
20659
- if (/^\d+(?:px)?/.test(height)) {
20660
- return parseInt(height, 10);
20661
+ if (v && typeof v === "string") {
20662
+ if (/^\d+(?:px)?/.test(v)) {
20663
+ return parseInt(v, 10);
20661
20664
  }
20662
20665
  throw new VcError("table", "Invalid Height");
20663
20666
  }
20664
20667
  return null;
20665
20668
  };
20666
- const parseWidth = (width) => {
20667
- if (width !== void 0) {
20668
- width = parseInt(width, 10);
20669
- if (isNaN(width)) {
20670
- width = null;
20669
+ const parseWidth = (v) => {
20670
+ if (typeof v === "number") {
20671
+ return v;
20672
+ }
20673
+ let v1;
20674
+ if (typeof v !== "undefined") {
20675
+ v1 = parseInt(v, 10);
20676
+ if (isNaN(v1)) {
20677
+ v1 = null;
20671
20678
  }
20672
20679
  }
20673
- return width;
20680
+ return v1;
20674
20681
  };
20675
- const parseMinWidth = (minWidth) => {
20676
- if (typeof minWidth !== "undefined") {
20677
- minWidth = parseWidth(minWidth);
20678
- if (isNaN(minWidth)) {
20679
- minWidth = 80;
20682
+ const parseMinWidth = (v) => {
20683
+ if (typeof v === "number") {
20684
+ return v;
20685
+ }
20686
+ let v1;
20687
+ if (typeof v !== "undefined") {
20688
+ v1 = parseWidth(v);
20689
+ if (isNaN(v1)) {
20690
+ v = 80;
20680
20691
  }
20681
20692
  }
20682
- return minWidth;
20693
+ return v1;
20683
20694
  };
20684
- const getRowIdentity = (row, rowKey) => {
20695
+ const getRowValue = (row, primaryKey) => {
20685
20696
  if (row.__KEY__) return row.__KEY__;
20686
20697
  if (!row) throw new VcError("table", "row is required when get row identity");
20687
- if (typeof rowKey === "string") {
20688
- if (!rowKey.includes(".")) {
20689
- return row[rowKey];
20698
+ if (typeof primaryKey === "string") {
20699
+ if (!primaryKey.includes(".")) {
20700
+ return row[primaryKey];
20690
20701
  }
20691
- const key = rowKey.split(".");
20702
+ const key = primaryKey.split(".");
20692
20703
  let current = row;
20693
20704
  for (let i = 0; i < key.length; i++) {
20694
20705
  current = current[key[i]];
20695
20706
  }
20696
20707
  return current;
20697
- } else if (typeof rowKey === "function") {
20698
- return rowKey.call(null, row);
20708
+ } else if (typeof primaryKey === "function") {
20709
+ return primaryKey.call(null, row);
20699
20710
  }
20700
20711
  };
20701
- const walkTreeNode = (root, cb, opts = {}) => {
20702
- const {
20703
- childrenKey = "children",
20704
- lazyKey = "hasChildren",
20705
- level: baseLevel = 0
20706
- } = opts;
20707
- const isNil = (array) => !(Array.isArray(array) && array.length);
20708
- function _walker(parent, children, level) {
20709
- cb(parent, children, level);
20710
- children.forEach((item) => {
20711
- if (item[lazyKey]) {
20712
- cb(item, null, level + 1);
20713
- return;
20714
- }
20715
- const $children = item[childrenKey];
20716
- if (!isNil($children)) {
20717
- _walker(item, $children, level + 1);
20718
- }
20719
- });
20720
- }
20721
- root.forEach((item) => {
20722
- if (item[lazyKey]) {
20723
- cb(item, null, baseLevel);
20724
- return;
20725
- }
20726
- const children = item[childrenKey];
20727
- if (!isNil(children)) {
20728
- _walker(item, children, baseLevel);
20729
- }
20730
- });
20731
- };
20732
- const getKeysMap = (array = [], rowKey) => {
20712
+ const getValuesMap = (array = [], primaryKey) => {
20733
20713
  const arrayMap = {};
20734
20714
  array.forEach((row, index) => {
20735
- arrayMap[getRowIdentity(row, rowKey)] = { row, index };
20715
+ arrayMap[getRowValue(row, primaryKey)] = { row, index };
20736
20716
  });
20737
20717
  return arrayMap;
20738
20718
  };
@@ -20745,35 +20725,23 @@
20745
20725
  });
20746
20726
  return column;
20747
20727
  };
20748
- const getColumnByCell = (table, cell) => {
20728
+ const getColumnByCell = (columns, cell) => {
20749
20729
  const matches = (cell.className || "").match(/vc-table_[^\s]+/gm);
20750
20730
  if (matches) {
20751
- return getColumnById(table, matches[0]);
20731
+ return getColumnById(columns, matches[0]);
20752
20732
  }
20753
20733
  return null;
20754
20734
  };
20755
- const getCell = (event) => {
20756
- let cell = event.target;
20735
+ const getCell = (e) => {
20736
+ let cell = e.target;
20757
20737
  while (cell && cell.tagName.toUpperCase() !== "HTML") {
20758
- if (cell.tagName.toUpperCase() === "TD") {
20738
+ if (cell.classList.contains("vc-table__td")) {
20759
20739
  return cell;
20760
20740
  }
20761
20741
  cell = cell.parentNode;
20762
20742
  }
20763
20743
  return null;
20764
20744
  };
20765
- const flattenData = (data, opts = {}) => {
20766
- const result = [];
20767
- data.forEach((item) => {
20768
- if (item.children) {
20769
- const { children, ...rest } = item;
20770
- opts.parent ? result.push(...[opts.cascader ? item : rest, ...flattenData(children, opts)]) : result.push(...flattenData(children));
20771
- } else {
20772
- result.push(item);
20773
- }
20774
- });
20775
- return result;
20776
- };
20777
20745
 
20778
20746
  var lodash$1 = {exports: {}};
20779
20747
 
@@ -37986,29 +37954,115 @@
37986
37954
 
37987
37955
  var lodashExports = requireLodash();
37988
37956
 
37957
+ const getAllColumns = (columns) => {
37958
+ const result = [];
37959
+ columns.forEach((column) => {
37960
+ if (column.children) {
37961
+ result.push(column);
37962
+ result.push(...getAllColumns(column.children));
37963
+ } else {
37964
+ result.push(column);
37965
+ }
37966
+ });
37967
+ return result;
37968
+ };
37969
+ const columnsToRowsEffect = (v) => {
37970
+ let maxLevel = 1;
37971
+ const traverse = (column, parent) => {
37972
+ if (parent) {
37973
+ column.level = parent.level + 1;
37974
+ if (maxLevel < column.level) {
37975
+ maxLevel = column.level;
37976
+ }
37977
+ }
37978
+ if (column.children) {
37979
+ let colSpan = 0;
37980
+ column.children.forEach((subColumn) => {
37981
+ traverse(subColumn, column);
37982
+ colSpan += subColumn.colSpan;
37983
+ });
37984
+ column.colSpan = colSpan;
37985
+ } else {
37986
+ column.colSpan = 1;
37987
+ }
37988
+ };
37989
+ v.forEach((column) => {
37990
+ column.level = 1;
37991
+ traverse(column);
37992
+ });
37993
+ const rows = [];
37994
+ for (let i = 0; i < maxLevel; i++) {
37995
+ rows.push([]);
37996
+ }
37997
+ const allColumns = getAllColumns(v);
37998
+ allColumns.forEach((column) => {
37999
+ if (!column.children) {
38000
+ column.rowSpan = maxLevel - column.level + 1;
38001
+ } else {
38002
+ column.rowSpan = 1;
38003
+ }
38004
+ rows[column.level - 1].push(column);
38005
+ });
38006
+ return rows;
38007
+ };
38008
+ const flattenData = (data, opts = {}) => {
38009
+ const result = [];
38010
+ data.forEach((item) => {
38011
+ if (item.children) {
38012
+ const { children, ...rest } = item;
38013
+ opts.parent ? result.push(...[opts.cascader ? item : rest, ...flattenData(children, opts)]) : result.push(...flattenData(children));
38014
+ } else {
38015
+ result.push(item);
38016
+ }
38017
+ });
38018
+ return result;
38019
+ };
38020
+ const walkTreeNode = (root, cb, opts = {}) => {
38021
+ const {
38022
+ childrenKey = "children",
38023
+ lazyKey = "hasChildren",
38024
+ level: baseLevel = 0
38025
+ } = opts;
38026
+ const isNil = (array) => !(Array.isArray(array) && array.length);
38027
+ function _walker(parent, children, level) {
38028
+ cb(parent, children, level);
38029
+ children.forEach((item) => {
38030
+ if (item[lazyKey]) {
38031
+ cb(item, null, level + 1);
38032
+ return;
38033
+ }
38034
+ const $children = item[childrenKey];
38035
+ if (!isNil($children)) {
38036
+ _walker(item, $children, level + 1);
38037
+ }
38038
+ });
38039
+ }
38040
+ root.forEach((item) => {
38041
+ if (item[lazyKey]) {
38042
+ cb(item, null, baseLevel);
38043
+ return;
38044
+ }
38045
+ const children = item[childrenKey];
38046
+ if (!isNil(children)) {
38047
+ _walker(item, children, baseLevel);
38048
+ }
38049
+ });
38050
+ };
38051
+
37989
38052
  class BaseWatcher {
37990
38053
  states = vue.reactive({
37991
38054
  // 渲染的数据来源,是对 table 中的 data 过滤排序后的结果
37992
38055
  _data: [],
37993
38056
  data: [],
37994
38057
  list: [],
37995
- // 是否包含固定列
37996
- isComplex: false,
37997
- // 列
38058
+ // 表头数据
38059
+ headerRows: [],
38060
+ // 列 动态收集vc-table-column中的columnConfig
37998
38061
  _columns: [],
37999
- // 动态收集vc-table-column中的columnConfig
38000
38062
  originColumns: [],
38001
- // leftFixedColumns, notFixedColumns, rightFixedColumns
38002
- columns: [],
38003
- // 包括 leftFixedLeafColumns,leafColumns,rightFixedLeafColumns
38063
+ notFixedColumns: [],
38004
38064
  leftFixedColumns: [],
38005
38065
  rightFixedColumns: [],
38006
- leafColumns: [],
38007
- leftFixedLeafColumns: [],
38008
- rightFixedLeafColumns: [],
38009
- leafColumnsLength: 0,
38010
- leftFixedLeafColumnsLength: 0,
38011
- rightFixedLeafColumnsLength: 0,
38012
38066
  // 选择
38013
38067
  isAllSelected: false,
38014
38068
  selection: [],
@@ -38030,7 +38084,17 @@
38030
38084
  treeLazyData: [],
38031
38085
  // 源数据展开
38032
38086
  treeLazyColumnIdentifier: "hasChildren",
38033
- treeChildrenColumnName: "children"
38087
+ treeChildrenColumnName: "children",
38088
+ // compputeds
38089
+ isComplex: vue.computed(() => this.states.leftFixedColumns.length > 0 || this.states.rightFixedColumns.length > 0),
38090
+ isGroup: vue.computed(() => this.states.columns.length > this.states.originColumns.length),
38091
+ columns: vue.computed(() => lodashExports.concat(this.states.leftFixedLeafColumns, this.states.leafColumns, this.states.rightFixedLeafColumns)),
38092
+ leafColumns: vue.computed(() => flattenData(this.states.notFixedColumns)),
38093
+ leftFixedLeafColumns: vue.computed(() => flattenData(this.states.leftFixedColumns)),
38094
+ rightFixedLeafColumns: vue.computed(() => flattenData(this.states.rightFixedColumns)),
38095
+ leafColumnsLength: vue.computed(() => this.states.leafColumns.length),
38096
+ leftFixedLeafColumnsLength: vue.computed(() => this.states.leftFixedLeafColumns.length),
38097
+ rightFixedLeafColumnsLength: vue.computed(() => this.states.rightFixedLeafColumns.length)
38034
38098
  });
38035
38099
  }
38036
38100
 
@@ -38041,14 +38105,14 @@
38041
38105
  }
38042
38106
  update() {
38043
38107
  const store = this.store;
38044
- const { rowKey, defaultExpandAll } = this.store.table.props;
38108
+ const { primaryKey, defaultExpandAll } = this.store.table.props;
38045
38109
  const { data = [], expandRows } = store.states;
38046
38110
  if (defaultExpandAll) {
38047
38111
  store.states.expandRows = data.slice();
38048
- } else if (rowKey) {
38049
- const expandRowsMap = getKeysMap(expandRows, rowKey);
38112
+ } else if (primaryKey) {
38113
+ const expandRowsMap = getValuesMap(expandRows, primaryKey);
38050
38114
  store.states.expandRows = data.reduce((prev, row) => {
38051
- const rowId = getRowIdentity(row, rowKey);
38115
+ const rowId = getRowValue(row, primaryKey);
38052
38116
  const rowInfo = expandRowsMap[rowId];
38053
38117
  if (rowInfo) {
38054
38118
  prev.push(row);
@@ -38070,10 +38134,10 @@
38070
38134
  }
38071
38135
  reset(ids) {
38072
38136
  const store = this.store;
38073
- store.checkRowKey();
38074
- const { rowKey } = store.table.props;
38137
+ store.checkPrimaryKey();
38138
+ const { primaryKey } = store.table.props;
38075
38139
  const { data } = store.states;
38076
- const keysMap = getKeysMap(data, rowKey);
38140
+ const keysMap = getValuesMap(data, primaryKey);
38077
38141
  store.states.expandRows = ids.reduce((prev, cur) => {
38078
38142
  const info = keysMap[cur];
38079
38143
  if (info) {
@@ -38083,11 +38147,11 @@
38083
38147
  }, []);
38084
38148
  }
38085
38149
  isExpanded(row) {
38086
- const { rowKey } = this.store.table.props;
38150
+ const { primaryKey } = this.store.table.props;
38087
38151
  const { expandRows = [] } = this.store.states;
38088
- if (rowKey) {
38089
- const expandMap = getKeysMap(expandRows, rowKey);
38090
- return !!expandMap[getRowIdentity(row, rowKey)];
38152
+ if (primaryKey) {
38153
+ const expandMap = getValuesMap(expandRows, primaryKey);
38154
+ return !!expandMap[getRowValue(row, primaryKey)];
38091
38155
  }
38092
38156
  return expandRows.indexOf(row) !== -1;
38093
38157
  }
@@ -38100,22 +38164,22 @@
38100
38164
  }
38101
38165
  reset(id) {
38102
38166
  const store = this.store;
38103
- const { rowKey } = store.table.props;
38104
- store.checkRowKey();
38167
+ const { primaryKey } = store.table.props;
38168
+ store.checkPrimaryKey();
38105
38169
  const { data = [] } = store.states;
38106
- const currentRow = data.find((item) => getRowIdentity(item, rowKey) === id);
38170
+ const currentRow = data.find((item) => getRowValue(item, primaryKey) === id);
38107
38171
  store.states.currentRow = currentRow || null;
38108
38172
  }
38109
38173
  update() {
38110
38174
  const store = this.store;
38111
- const { rowKey } = store.table.props;
38175
+ const { primaryKey } = store.table.props;
38112
38176
  const { data = [], currentRow } = store.states;
38113
38177
  const oldCurrentRow = currentRow;
38114
38178
  if (oldCurrentRow && !data.includes(oldCurrentRow)) {
38115
38179
  let newCurrentRow = null;
38116
- if (rowKey) {
38180
+ if (primaryKey) {
38117
38181
  newCurrentRow = data.find((item) => {
38118
- return getRowIdentity(item, rowKey) === getRowIdentity(oldCurrentRow, rowKey);
38182
+ return getRowValue(item, primaryKey) === getRowValue(oldCurrentRow, primaryKey);
38119
38183
  });
38120
38184
  }
38121
38185
  store.states.currentRow = newCurrentRow;
@@ -38134,8 +38198,8 @@
38134
38198
  * { id: { level, children } }
38135
38199
  */
38136
38200
  normalizedData = vue.computed(() => {
38137
- const { rowKey } = this.store.table.props;
38138
- if (!rowKey) return {};
38201
+ const { primaryKey } = this.store.table.props;
38202
+ if (!primaryKey) return {};
38139
38203
  return this.normalize(this.store.states.data || []);
38140
38204
  });
38141
38205
  /**
@@ -38143,7 +38207,7 @@
38143
38207
  * { id: { children } }
38144
38208
  */
38145
38209
  normalizedLazyNode = vue.computed(() => {
38146
- const { rowKey } = this.store.table.props;
38210
+ const { primaryKey } = this.store.table.props;
38147
38211
  const { treelazyNodeMap, treeLazyColumnIdentifier, treeChildrenColumnName } = this.store.states;
38148
38212
  const keys = Object.keys(treelazyNodeMap);
38149
38213
  const res = {};
@@ -38152,7 +38216,7 @@
38152
38216
  if (treelazyNodeMap[key].length) {
38153
38217
  const item = { children: [] };
38154
38218
  treelazyNodeMap[key].forEach((row) => {
38155
- const id = getRowIdentity(row, rowKey);
38219
+ const id = getRowValue(row, primaryKey);
38156
38220
  item.children.push(id);
38157
38221
  const hasChildren = row[treeLazyColumnIdentifier] || row[treeChildrenColumnName] && row[treeChildrenColumnName].length === 0;
38158
38222
  if (hasChildren && !res[id]) {
@@ -38172,16 +38236,16 @@
38172
38236
  );
38173
38237
  }
38174
38238
  normalize(data) {
38175
- const { rowKey } = this.store.table.props;
38239
+ const { primaryKey } = this.store.table.props;
38176
38240
  const { treeChildrenColumnName, treeLazyColumnIdentifier, treeLazy } = this.store.states;
38177
38241
  const res = {};
38178
38242
  walkTreeNode(
38179
38243
  data,
38180
38244
  (parent, children, level) => {
38181
- const parentId = getRowIdentity(parent, rowKey);
38245
+ const parentId = getRowValue(parent, primaryKey);
38182
38246
  if (Array.isArray(children)) {
38183
38247
  res[parentId] = {
38184
- children: children.map((row) => getRowIdentity(row, rowKey)),
38248
+ children: children.map((row) => getRowValue(row, primaryKey)),
38185
38249
  level
38186
38250
  };
38187
38251
  } else if (treeLazy) {
@@ -38201,7 +38265,7 @@
38201
38265
  }
38202
38266
  // 获取当前展开最大的level
38203
38267
  getMaxLevel() {
38204
- const { rowKey } = this.store.table.props;
38268
+ const { primaryKey } = this.store.table.props;
38205
38269
  const { data, treeData } = this.store.states;
38206
38270
  const levels = data.map((item) => {
38207
38271
  const traverse = (source) => {
@@ -38212,7 +38276,7 @@
38212
38276
  return source.level;
38213
38277
  }
38214
38278
  };
38215
- const id = getRowIdentity(item, rowKey);
38279
+ const id = getRowValue(item, primaryKey);
38216
38280
  return traverse(treeData[id]);
38217
38281
  });
38218
38282
  return max$2(levels) || 0;
@@ -38274,10 +38338,10 @@
38274
38338
  this.update();
38275
38339
  }
38276
38340
  toggle(row, expanded) {
38277
- this.store.checkRowKey();
38278
- const { rowKey } = this.store.table.props;
38341
+ this.store.checkPrimaryKey();
38342
+ const { primaryKey } = this.store.table.props;
38279
38343
  const { treeData } = this.store.states;
38280
- const id = getRowIdentity(row, rowKey);
38344
+ const id = getRowValue(row, primaryKey);
38281
38345
  const data = id && treeData[id];
38282
38346
  if (id && data && "expanded" in data) {
38283
38347
  const oldExpanded = data.expanded;
@@ -38290,10 +38354,10 @@
38290
38354
  }
38291
38355
  }
38292
38356
  loadOrToggle(row) {
38293
- this.store.checkRowKey();
38294
- const { rowKey } = this.store.table.props;
38357
+ this.store.checkPrimaryKey();
38358
+ const { primaryKey } = this.store.table.props;
38295
38359
  const { treeLazy, treeData } = this.store.states;
38296
- const id = getRowIdentity(row, rowKey);
38360
+ const id = getRowValue(row, primaryKey);
38297
38361
  const data = treeData[id];
38298
38362
  if (treeLazy && data && "loaded" in data && !data.loaded) {
38299
38363
  this.loadData(row, id, data);
@@ -38302,9 +38366,9 @@
38302
38366
  }
38303
38367
  }
38304
38368
  loadData(row, key, treeNode) {
38305
- this.store.checkRowKey();
38369
+ this.store.checkPrimaryKey();
38306
38370
  const { table } = this.store;
38307
- const { rowKey } = table.props;
38371
+ const { primaryKey } = table.props;
38308
38372
  const { treelazyNodeMap, treeData, treeChildrenColumnName, treeLazyColumnIdentifier } = this.store.states;
38309
38373
  if (table.props.loadExpand && !treeData[key].loaded) {
38310
38374
  this.store.states.treeData[key].loading = true;
@@ -38319,7 +38383,7 @@
38319
38383
  walkTreeNode(
38320
38384
  data,
38321
38385
  (parent, _, level) => {
38322
- const id = getRowIdentity(parent, rowKey);
38386
+ const id = getRowValue(parent, primaryKey);
38323
38387
  Object.defineProperty(parent, "__KEY__", {
38324
38388
  value: `${level}__${id}`,
38325
38389
  writable: false
@@ -38389,27 +38453,13 @@
38389
38453
  if (!this.store) {
38390
38454
  throw new VcError("table", "Table Layout 必须包含store实例");
38391
38455
  }
38392
- this.updateScroller = this.updateScroller.bind(this);
38393
- this.updateColumns = this.updateColumns.bind(this);
38394
- vue.onMounted(() => {
38395
- this.updateColumns();
38396
- this.updateScroller();
38397
- });
38398
- let __updated__;
38399
- vue.onUpdated(() => {
38400
- if (__updated__) return;
38401
- this.updateColumns();
38402
- this.updateScroller();
38403
- __updated__ = true;
38404
- });
38405
38456
  }
38406
38457
  updateScrollY() {
38407
38458
  const { height, bodyHeight } = this.states;
38408
38459
  if (height === null || bodyHeight === null) return;
38409
- const scroller = this.table.exposed.scroller.value;
38410
- if (this.table.vnode.el && scroller) {
38411
- const body = scroller.$el.querySelector(".vc-table__body");
38412
- this.states.scrollY = body.offsetHeight > bodyHeight;
38460
+ const bodyYWrapper = this.table.exposed.bodyYWrapper.value;
38461
+ if (this.table.vnode.el && bodyYWrapper) {
38462
+ this.states.scrollY = bodyYWrapper.offsetHeight > bodyHeight;
38413
38463
  }
38414
38464
  }
38415
38465
  setHeight(value, prop = "height") {
@@ -38426,18 +38476,6 @@
38426
38476
  setMaxHeight(value) {
38427
38477
  this.setHeight(value, "max-height");
38428
38478
  }
38429
- getFlattenColumns() {
38430
- const flattenColumns = [];
38431
- const columns = this.store.states.columns;
38432
- columns.forEach((column) => {
38433
- if (column.isColumnGroup) {
38434
- flattenColumns.push(...column.columns);
38435
- } else {
38436
- flattenColumns.push(column);
38437
- }
38438
- });
38439
- return flattenColumns;
38440
- }
38441
38479
  updateElsHeight() {
38442
38480
  if (!this.table.exposed.isReady.value) return vue.nextTick(() => this.updateElsHeight());
38443
38481
  const table = this.table.exposed;
@@ -38460,13 +38498,12 @@
38460
38498
  this.states.bodyHeight = tableHeight - headerHeight - footerHeight + (footerWrapper ? 1 : 0);
38461
38499
  }
38462
38500
  this.updateScrollY();
38463
- this.updateScroller();
38464
38501
  }
38465
38502
  updateColumnsWidth() {
38466
38503
  if (IS_SERVER$2) return;
38467
38504
  const bodyWidth = this.table.vnode.el.clientWidth;
38468
38505
  let bodyMinWidth = 0;
38469
- const flattenColumns = this.getFlattenColumns();
38506
+ const flattenColumns = this.store.states.columns;
38470
38507
  const flexColumns = flattenColumns.filter((column) => typeof column.width !== "number");
38471
38508
  const { fit } = this.table.props;
38472
38509
  if (flexColumns.length > 0 && fit) {
@@ -38492,7 +38529,7 @@
38492
38529
  }
38493
38530
  } else {
38494
38531
  this.states.scrollX = true;
38495
- flexColumns.forEach(function(column) {
38532
+ flexColumns.forEach((column) => {
38496
38533
  column.realWidth = column.width || column.minWidth;
38497
38534
  });
38498
38535
  }
@@ -38526,12 +38563,6 @@
38526
38563
  });
38527
38564
  this.states.rightFixedWidth = rightFixedWidth;
38528
38565
  }
38529
- this.updateColumns();
38530
- }
38531
- // v2.x中的 notifyObservers
38532
- updateColumns() {
38533
- }
38534
- updateScroller() {
38535
38566
  }
38536
38567
  }
38537
38568
 
@@ -38541,7 +38572,7 @@
38541
38572
  expand;
38542
38573
  tree;
38543
38574
  layout;
38544
- flattenData = vue.computed(() => {
38575
+ flatData = vue.computed(() => {
38545
38576
  if (this.table.props.expandSelectable) {
38546
38577
  return lodashExports.concat(
38547
38578
  flattenData(this.states.data, { parent: true, cascader: true }),
@@ -38599,7 +38630,7 @@
38599
38630
  this.cleanSelection();
38600
38631
  }
38601
38632
  } else {
38602
- this.checkRowKey();
38633
+ this.checkPrimaryKey();
38603
38634
  this.updateSelectionByRowKey();
38604
38635
  }
38605
38636
  this.updateAllSelected();
@@ -38621,10 +38652,10 @@
38621
38652
  }
38622
38653
  }
38623
38654
  /**
38624
- * 检查 rowKey 是否存在
38655
+ * 检查 primaryKey 是否存在
38625
38656
  */
38626
- checkRowKey() {
38627
- const { rowKey } = this.table.props;
38657
+ checkPrimaryKey() {
38658
+ const { primaryKey } = this.table.props;
38628
38659
  }
38629
38660
  /**
38630
38661
  * states
@@ -38685,22 +38716,20 @@
38685
38716
  updateColumns() {
38686
38717
  const { states } = this;
38687
38718
  const _columns = states._columns || [];
38688
- states.leftFixedColumns = _columns.filter((column) => column.fixed === true || column.fixed === "left");
38689
- states.rightFixedColumns = _columns.filter((column) => column.fixed === "right");
38690
- if (states.leftFixedColumns.length > 0 && _columns[0] && _columns[0].type === "selection" && !_columns[0].fixed) {
38719
+ const leftFixedColumns = _columns.filter((column) => column.fixed === true || column.fixed === "left");
38720
+ const rightFixedColumns = _columns.filter((column) => column.fixed === "right");
38721
+ if (leftFixedColumns.length > 0 && _columns[0] && _columns[0].type === "selection" && !_columns[0].fixed) {
38691
38722
  _columns[0].fixed = true;
38692
- states.leftFixedColumns.unshift(_columns[0]);
38723
+ leftFixedColumns.unshift(_columns[0]);
38693
38724
  }
38694
38725
  const notFixedColumns = _columns.filter((column) => !column.fixed);
38695
- states.originColumns = lodashExports.concat(states.leftFixedColumns, notFixedColumns, states.rightFixedColumns);
38696
- const leafColumns = flattenData(notFixedColumns);
38697
- const leftFixedLeafColumns = flattenData(states.leftFixedColumns);
38698
- const rightFixedLeafColumns = flattenData(states.rightFixedColumns);
38699
- states.leafColumnsLength = leafColumns.length;
38700
- states.leftFixedLeafColumnsLength = leftFixedLeafColumns.length;
38701
- states.rightFixedLeafColumnsLength = rightFixedLeafColumns.length;
38702
- states.columns = lodashExports.concat(leftFixedLeafColumns, leafColumns, rightFixedLeafColumns);
38703
- states.isComplex = states.leftFixedColumns.length > 0 || states.rightFixedColumns.length > 0;
38726
+ const originColumns = lodashExports.concat(leftFixedColumns, notFixedColumns, rightFixedColumns);
38727
+ const headerRows = columnsToRowsEffect(originColumns);
38728
+ states.leftFixedColumns = leftFixedColumns;
38729
+ states.notFixedColumns = notFixedColumns;
38730
+ states.rightFixedColumns = rightFixedColumns;
38731
+ states.originColumns = originColumns;
38732
+ states.headerRows = headerRows;
38704
38733
  }
38705
38734
  // 选择
38706
38735
  isSelected(row) {
@@ -38724,13 +38753,13 @@
38724
38753
  * 清理选择
38725
38754
  */
38726
38755
  cleanSelection() {
38727
- const { rowKey } = this.table.props;
38756
+ const { primaryKey } = this.table.props;
38728
38757
  const { selection = [] } = this.states;
38729
38758
  let deleted;
38730
- if (rowKey) {
38759
+ if (primaryKey) {
38731
38760
  deleted = [];
38732
- const selectedMap = getKeysMap(selection, rowKey);
38733
- const dataMap = getKeysMap(selection, rowKey);
38761
+ const selectedMap = getValuesMap(selection, primaryKey);
38762
+ const dataMap = getValuesMap(selection, primaryKey);
38734
38763
  for (const key in selectedMap) {
38735
38764
  if (hasOwn$1(selectedMap, key) && !dataMap[key]) {
38736
38765
  deleted.push(selectedMap[key].row);
@@ -38738,7 +38767,7 @@
38738
38767
  }
38739
38768
  } else {
38740
38769
  deleted = selection.filter((item) => {
38741
- return !this.flattenData.value.includes(item);
38770
+ return !this.flatData.value.includes(item);
38742
38771
  });
38743
38772
  }
38744
38773
  deleted.forEach((deletedItem) => {
@@ -38799,7 +38828,7 @@
38799
38828
  const value = indeterminate ? !isAllSelected : !(isAllSelected || selection.length);
38800
38829
  this.states.isAllSelected = value;
38801
38830
  let selectionChanged = false;
38802
- this.flattenData.value.forEach((row, index) => {
38831
+ this.flatData.value.forEach((row, index) => {
38803
38832
  if (selectable) {
38804
38833
  if (selectable.call(null, row, index) && this.toggleRowStatus(selection, row, value)) {
38805
38834
  selectionChanged = true;
@@ -38830,11 +38859,11 @@
38830
38859
  this.tree.expand(val);
38831
38860
  }
38832
38861
  updateSelectionByRowKey() {
38833
- const { rowKey } = this.table.props;
38862
+ const { primaryKey } = this.table.props;
38834
38863
  const { selection } = this.states;
38835
- const selectedMap = getKeysMap(selection, rowKey);
38836
- this.states.selection = this.flattenData.value.reduce((prev, row) => {
38837
- const rowId = getRowIdentity(row, rowKey);
38864
+ const selectedMap = getValuesMap(selection, primaryKey);
38865
+ this.states.selection = this.flatData.value.reduce((prev, row) => {
38866
+ const rowId = getRowValue(row, primaryKey);
38838
38867
  const rowInfo = selectedMap[rowId];
38839
38868
  if (rowInfo) {
38840
38869
  prev.push(row);
@@ -38850,7 +38879,7 @@
38850
38879
  }
38851
38880
  let isAllSelected = true;
38852
38881
  let selectedCount = 0;
38853
- const temp = this.flattenData.value;
38882
+ const temp = this.flatData.value;
38854
38883
  for (let i = 0, j = temp.length; i < j; i++) {
38855
38884
  const row = temp[i];
38856
38885
  const isRowSelectable = selectable && selectable.call(null, row, i);
@@ -38965,6 +38994,7 @@
38965
38994
  type
38966
38995
  }) => type === 'default')
38967
38996
  });
38997
+ const wrapper = vue.ref();
38968
38998
  vue.watch(() => props.store.states.hoverRowIndex, (v, oldV) => {
38969
38999
  if (!props.store.states.isComplex || IS_SERVER$2) return;
38970
39000
  raf(() => {
@@ -38975,12 +39005,12 @@
38975
39005
  newRow && addClass(newRow, 'hover-row');
38976
39006
  });
38977
39007
  });
38978
- const getKeyOfRow = (row, index) => {
39008
+ const getValueOfRow = (row, index) => {
38979
39009
  const {
38980
- rowKey
39010
+ primaryKey
38981
39011
  } = table.props;
38982
- if (rowKey) {
38983
- return getRowIdentity(row, rowKey);
39012
+ if (primaryKey) {
39013
+ return getRowValue(row, primaryKey);
38984
39014
  }
38985
39015
  return index;
38986
39016
  };
@@ -39045,7 +39075,7 @@
39045
39075
  return cellStyle;
39046
39076
  };
39047
39077
  const getCellClass = (rowIndex, columnIndex, row, column) => {
39048
- const classes = [column.align, column.className];
39078
+ const classes = [column.realAlign, column.className];
39049
39079
  if (isColumnHidden(columnIndex)) {
39050
39080
  classes.push('is-hidden');
39051
39081
  }
@@ -39105,7 +39135,7 @@
39105
39135
  const cell = getCell(e);
39106
39136
  if (!cell) return;
39107
39137
  const oldHoverState = table.exposed.hoverState.value || {};
39108
- table.emit('cell-mouse-leave', oldHoverState.row, oldHoverState.column, oldHoverState.cell, event);
39138
+ table.emit('cell-mouse-leave', oldHoverState.row, oldHoverState.column, oldHoverState.cell, e);
39109
39139
  };
39110
39140
  const handleMouseEnter = debounce$1(index => {
39111
39141
  props.store.setHoverRow(index);
@@ -39141,7 +39171,7 @@
39141
39171
  const {
39142
39172
  columns
39143
39173
  } = states;
39144
- const key = getKeyOfRow(row, rowIndex);
39174
+ const key = getValueOfRow(row, rowIndex);
39145
39175
  return vue.createVNode("div", {
39146
39176
  "key": key,
39147
39177
  "class": [getRowClass(row, rowIndex), 'vc-table__tr'],
@@ -39205,13 +39235,12 @@
39205
39235
  }
39206
39236
  });
39207
39237
  };
39208
- const wrapper = vue.ref();
39209
39238
  expose({
39210
39239
  wrapper,
39211
39240
  getRootElement: () => instance.vnode.el
39212
39241
  });
39242
+ const layout = table.exposed.layout;
39213
39243
  return () => {
39214
- const layout = table.exposed.layout;
39215
39244
  return vue.createVNode("div", {
39216
39245
  "class": "vc-table__body"
39217
39246
  }, [table.props.height ? vue.createVNode(RecycleList, {
@@ -39256,57 +39285,6 @@
39256
39285
 
39257
39286
  const TableSort = 'div';
39258
39287
  const TableFilter = 'div';
39259
- const getAllColumns = columns => {
39260
- const result = [];
39261
- columns.forEach(column => {
39262
- if (column.children) {
39263
- result.push(column);
39264
- result.push(...getAllColumns(column.children));
39265
- } else {
39266
- result.push(column);
39267
- }
39268
- });
39269
- return result;
39270
- };
39271
- const convertToRows = originColumns => {
39272
- let maxLevel = 1;
39273
- const traverse = (column, parent) => {
39274
- if (parent) {
39275
- column.level = parent.level + 1;
39276
- if (maxLevel < column.level) {
39277
- maxLevel = column.level;
39278
- }
39279
- }
39280
- if (column.children) {
39281
- let colSpan = 0;
39282
- column.children.forEach(subColumn => {
39283
- traverse(subColumn, column);
39284
- colSpan += subColumn.colSpan;
39285
- });
39286
- column.colSpan = colSpan;
39287
- } else {
39288
- column.colSpan = 1;
39289
- }
39290
- };
39291
- originColumns.forEach(column => {
39292
- column.level = 1;
39293
- traverse(column);
39294
- });
39295
- const rows = [];
39296
- for (let i = 0; i < maxLevel; i++) {
39297
- rows.push([]);
39298
- }
39299
- const allColumns = getAllColumns(originColumns);
39300
- allColumns.forEach(column => {
39301
- if (!column.children) {
39302
- column.rowSpan = maxLevel - column.level + 1;
39303
- } else {
39304
- column.rowSpan = 1;
39305
- }
39306
- rows[column.level - 1].push(column);
39307
- });
39308
- return rows;
39309
- };
39310
39288
  const TableHeader = /* @__PURE__ */ vue.defineComponent({
39311
39289
  name: 'vc-table-header',
39312
39290
  props: {
@@ -39333,16 +39311,18 @@
39333
39311
  isAllSelected: 'isAllSelected',
39334
39312
  leftFixedLeafCount: 'leftFixedLeafColumnsLength',
39335
39313
  rightFixedLeafCount: 'rightFixedLeafColumnsLength',
39314
+ isGroup: 'isGroup',
39315
+ headerRows: 'headerRows',
39336
39316
  columnsCount: $states => $states.columns.length,
39337
39317
  leftFixedCount: $states => $states.leftFixedColumns.length,
39338
39318
  rightFixedCount: $states => $states.rightFixedColumns.length
39339
39319
  });
39340
- const isCellHidden = (index, columns) => {
39320
+ const isColumnHidden = index => {
39341
39321
  let start = 0;
39342
39322
  for (let i = 0; i < index; i++) {
39343
- start += columns[i].colSpan;
39323
+ start += states.columns[i].colSpan;
39344
39324
  }
39345
- const after = start + columns[index].colSpan - 1;
39325
+ const after = start + states.columns[index].colSpan - 1;
39346
39326
  if (props.fixed === true || props.fixed === 'left') {
39347
39327
  return after >= states.leftFixedLeafCount;
39348
39328
  } else if (props.fixed === 'right') {
@@ -39351,6 +39331,9 @@
39351
39331
  return after < states.leftFixedLeafCount || start >= states.columnsCount - states.rightFixedLeafCount;
39352
39332
  }
39353
39333
  };
39334
+ const columnsHidden = vue.computed(() => {
39335
+ return states.columns.map((_, index) => isColumnHidden(index));
39336
+ });
39354
39337
  const getHeaderRowStyle = rowIndex => {
39355
39338
  const {
39356
39339
  headerRowStyle
@@ -39391,8 +39374,8 @@
39391
39374
  return headerCellStyle;
39392
39375
  };
39393
39376
  const getHeaderCellClass = (rowIndex, columnIndex, row, column) => {
39394
- const classes = [column.id, column.order, column.headerAlign, column.className, column.labelClass];
39395
- if (rowIndex === 0 && isCellHidden(columnIndex, row)) {
39377
+ const classes = [column.id, column.order, column.realHeaderAlign, column.className, column.labelClass];
39378
+ if (rowIndex === 0 && columnsHidden.value[columnIndex]) {
39396
39379
  classes.push('is-hidden');
39397
39380
  }
39398
39381
  if (!column.children) {
@@ -39532,37 +39515,27 @@
39532
39515
  });
39533
39516
  };
39534
39517
  return () => {
39535
- const {
39536
- originColumns
39537
- } = props.store.states;
39538
- const columnRows = convertToRows(originColumns);
39539
-
39540
- // 是否拥有多级表头
39541
- const isGroup = columnRows.length > 1;
39542
- if (isGroup) table.exposed.isGroup.value = true;
39543
39518
  return vue.createVNode("div", {
39544
39519
  "class": "vc-table__header"
39545
39520
  }, [vue.createVNode("div", {
39546
39521
  "class": [{
39547
- 'is-group': isGroup
39522
+ 'is-group': states.isGroup
39548
39523
  }, 'vc-table__thead']
39549
39524
  }, [
39550
39525
  // renderList
39551
- columnRows.map((columns, rowIndex) => vue.createVNode("div", {
39526
+ states.headerRows.map((columns, rowIndex) => vue.createVNode("div", {
39552
39527
  "style": getHeaderRowStyle(rowIndex),
39553
39528
  "class": [getHeaderRowClass(rowIndex), 'vc-table__tr']
39554
- }, [columns.map((column, cellIndex) => vue.createVNode("div", {
39555
- "colspan": column.colSpan,
39556
- "rowspan": column.rowSpan,
39557
- "onMousemove": $event => handleMouseMove($event, column),
39529
+ }, [columns.map((column, columnIndex) => vue.createVNode("div", {
39530
+ "onMousemove": e => handleMouseMove(e, column),
39558
39531
  "onMouseout": handleMouseOut,
39559
- "onMousedown": $event => handleMouseDown($event, column),
39560
- "onClick": $event => handleHeaderClick($event, column),
39561
- "onContextmenu": $event => handleHeaderContextMenu($event, column),
39562
- "style": [getHeaderCellStyle(rowIndex, cellIndex, columns, column), {
39532
+ "onMousedown": e => handleMouseDown(e, column),
39533
+ "onClick": e => handleHeaderClick(e, column),
39534
+ "onContextmenu": e => handleHeaderContextMenu(e, column),
39535
+ "style": [getHeaderCellStyle(rowIndex, columnIndex, columns, column), {
39563
39536
  width: `${column.realWidth}px`
39564
39537
  }],
39565
- "class": [getHeaderCellClass(rowIndex, cellIndex, columns, column), 'vc-table__th'],
39538
+ "class": [getHeaderCellClass(rowIndex, columnIndex, columns, column), 'vc-table__th'],
39566
39539
  "key": column.id
39567
39540
  }, [vue.createVNode("div", {
39568
39541
  "class": ['vc-table__cell',
@@ -39572,10 +39545,8 @@
39572
39545
  column.labelClass]
39573
39546
  }, [column.renderHeader ? column.renderHeader({
39574
39547
  column,
39575
- $index: cellIndex,
39576
- // index: cellIndex,
39577
- store: props.store,
39578
- _self: instance
39548
+ columnIndex,
39549
+ store: props.store
39579
39550
  }) : column.label, column.tooltip ? vue.createVNode(Icon, {
39580
39551
  "type": "o-info",
39581
39552
  "onMouseenter": e => handleCellMouseEnter(e, column)
@@ -39617,28 +39588,28 @@
39617
39588
  leftFixedCount: $states => $states.leftFixedColumns.length,
39618
39589
  rightFixedCount: $states => $states.rightFixedColumns.length
39619
39590
  });
39620
- const isCellHidden = (index, columns, column) => {
39591
+ const isColumnHidden = (column, index) => {
39621
39592
  if (props.fixed === true || props.fixed === 'left') {
39622
39593
  return index >= states.leftFixedLeafCount;
39623
39594
  } else if (props.fixed === 'right') {
39624
39595
  let before = 0;
39625
39596
  for (let i = 0; i < index; i++) {
39626
- before += columns[i].colSpan;
39597
+ before += states.columns[i].colSpan;
39627
39598
  }
39628
39599
  return before < states.columnsCount - states.rightFixedLeafCount;
39629
39600
  } else if (!props.fixed && column.fixed) {
39630
- // hide cell when footer instance is not fixed and column is fixed
39631
39601
  return true;
39632
39602
  } else {
39633
39603
  return index < states.leftFixedCount || index >= states.columnsCount - states.rightFixedCount;
39634
39604
  }
39635
39605
  };
39636
- const getRowClasses = (column, cellIndex) => {
39637
- const classes = [column.id, column.align, column.labelClass];
39606
+ const columnsHidden = vue.computed(() => states.columns.map(isColumnHidden));
39607
+ const getRowClasses = (column, columnIndex) => {
39608
+ const classes = [column.realAlign, column.labelClass];
39638
39609
  if (column.className) {
39639
39610
  classes.push(column.className);
39640
39611
  }
39641
- if (isCellHidden(cellIndex, states.columns, column)) {
39612
+ if (columnsHidden.value[columnIndex]) {
39642
39613
  classes.push('is-hidden');
39643
39614
  }
39644
39615
  if (!column.children) {
@@ -39646,17 +39617,17 @@
39646
39617
  }
39647
39618
  return classes;
39648
39619
  };
39649
- return () => {
39650
- let sums = [];
39620
+ const sums = vue.computed(() => {
39621
+ let v = [];
39651
39622
  if (props.getSummary) {
39652
- sums = props.getSummary({
39623
+ v = props.getSummary({
39653
39624
  columns: states.columns,
39654
39625
  data: states.data
39655
39626
  });
39656
39627
  } else {
39657
39628
  states.columns.forEach((column, index) => {
39658
39629
  if (index === 0) {
39659
- sums[index] = props.sumText;
39630
+ v[index] = props.sumText;
39660
39631
  return;
39661
39632
  }
39662
39633
  const values = states.data.map(item => Number(item[column.prop]));
@@ -39671,7 +39642,7 @@
39671
39642
  });
39672
39643
  const precision = Math.max.apply(null, precisions);
39673
39644
  if (!notNumber) {
39674
- sums[index] = values.reduce((prev, curr) => {
39645
+ v[index] = values.reduce((prev, curr) => {
39675
39646
  const value = Number(curr);
39676
39647
  if (!isNaN(value)) {
39677
39648
  return parseFloat((prev + curr).toFixed(Math.min(precision, 20)));
@@ -39680,10 +39651,13 @@
39680
39651
  }
39681
39652
  }, 0);
39682
39653
  } else {
39683
- sums[index] = '';
39654
+ v[index] = '';
39684
39655
  }
39685
39656
  });
39686
39657
  }
39658
+ return v;
39659
+ });
39660
+ return () => {
39687
39661
  return vue.createVNode("div", {
39688
39662
  "class": "vc-table__footer",
39689
39663
  "cellspacing": "0",
@@ -39693,17 +39667,15 @@
39693
39667
  "class": "vc-table__tbody"
39694
39668
  }, [vue.createVNode("div", {
39695
39669
  "class": "vc-table__tr"
39696
- }, [states.columns.map((column, cellIndex) => vue.createVNode("div", {
39697
- "key": cellIndex,
39698
- "colspan": column.colSpan,
39699
- "rowspan": column.rowSpan,
39700
- "class": [getRowClasses(column, cellIndex), 'vc-table__td'],
39670
+ }, [states.columns.map((column, columnIndex) => vue.createVNode("div", {
39671
+ "key": columnIndex,
39672
+ "class": [getRowClasses(column, columnIndex), 'vc-table__td'],
39701
39673
  "style": [{
39702
39674
  width: `${column.realWidth}px`
39703
39675
  }]
39704
39676
  }, [vue.createVNode("div", {
39705
39677
  "class": ['vc-table__cell', column.labelClass]
39706
- }, [sums[cellIndex]])]))])])]);
39678
+ }, [sums.value[columnIndex]])]))])])]);
39707
39679
  };
39708
39680
  }
39709
39681
  });
@@ -39731,7 +39703,7 @@
39731
39703
  type: Number,
39732
39704
  default: 10
39733
39705
  },
39734
- rowKey: [String, Function],
39706
+ primaryKey: [String, Function],
39735
39707
  // 是否显示表头
39736
39708
  showHeader: {
39737
39709
  type: Boolean,
@@ -39848,23 +39820,21 @@
39848
39820
  const rightFixedBody = vue.ref(null);
39849
39821
  const rightFixedFooterWrapper = vue.ref(null);
39850
39822
  const resizeProxy = vue.ref(null);
39851
-
39852
- // 是否拥有多级表头, 由table-header控制
39853
- const isGroup = vue.ref(false);
39854
39823
  const scrollPosition = vue.ref('left');
39855
39824
  const hoverState = vue.ref(null);
39856
39825
  const isReady = vue.ref(false);
39857
39826
  const states = useStates({
39858
39827
  columns: 'columns',
39859
39828
  leftFixedColumns: 'leftFixedColumns',
39860
- rightFixedColumns: 'rightFixedColumns'
39829
+ rightFixedColumns: 'rightFixedColumns',
39830
+ isGroup: 'isGroup'
39861
39831
  }, store);
39862
39832
  const classes = vue.computed(() => {
39863
39833
  return {
39864
39834
  'vc-table--fit': props.fit,
39865
39835
  'vc-table--striped': props.stripe,
39866
- 'vc-table--border': props.border || isGroup.value,
39867
- 'vc-table--group': isGroup.value,
39836
+ 'vc-table--border': props.border || states.isGroup,
39837
+ 'vc-table--group': states.isGroup,
39868
39838
  'vc-table--fluid-height': props.maxHeight,
39869
39839
  'vc-table--scrollable-x': layout.states.scrollX,
39870
39840
  'vc-table--scrollable-y': layout.states.scrollY,
@@ -40125,7 +40095,7 @@
40125
40095
  immediate: true
40126
40096
  });
40127
40097
  vue.watch(() => props.currentRowValue, v => {
40128
- if (!props.rowKey) return;
40098
+ if (!props.primaryKey) return;
40129
40099
  store.current.reset(v);
40130
40100
  }, {
40131
40101
  immediate: true
@@ -40154,6 +40124,7 @@
40154
40124
  }, {
40155
40125
  immediate: true
40156
40126
  });
40127
+ const tableId = getUid('table');
40157
40128
  vue.onMounted(() => {
40158
40129
  bindEvents();
40159
40130
  store.updateColumns();
@@ -40164,12 +40135,13 @@
40164
40135
  };
40165
40136
  isReady.value = true;
40166
40137
  });
40167
- vue.onBeforeUnmount(() => {
40138
+ vue.onUnmounted(() => {
40168
40139
  isUnMount = true;
40169
40140
  unbindEvents();
40170
40141
  });
40171
- const tableId = getUid('table');
40172
40142
  expose({
40143
+ bodyXWrapper,
40144
+ bodyYWrapper,
40173
40145
  tableId,
40174
40146
  store,
40175
40147
  layout,
@@ -40339,22 +40311,19 @@
40339
40311
  order: ''
40340
40312
  },
40341
40313
  selection: {
40342
- width: 48,
40343
- minWidth: 48,
40344
- realWidth: 48,
40314
+ width: 60,
40315
+ minWidth: 60,
40345
40316
  order: '',
40346
40317
  className: 'vc-table-column--selection'
40347
40318
  },
40348
40319
  expand: {
40349
- width: 48,
40350
- minWidth: 48,
40351
- realWidth: 48,
40320
+ width: 60,
40321
+ minWidth: 60,
40352
40322
  order: ''
40353
40323
  },
40354
40324
  index: {
40355
- width: 48,
40356
- minWidth: 48,
40357
- realWidth: 48,
40325
+ width: 60,
40326
+ minWidth: 60,
40358
40327
  order: ''
40359
40328
  }
40360
40329
  };
@@ -40521,8 +40490,8 @@
40521
40490
  customClass: String,
40522
40491
  labelClass: String,
40523
40492
  prop: String,
40524
- width: [Number, String],
40525
- minWidth: [Number, String],
40493
+ width: Number,
40494
+ minWidth: Number,
40526
40495
  renderHeader: Function,
40527
40496
  resizable: {
40528
40497
  type: Boolean,
@@ -40594,7 +40563,6 @@
40594
40563
  }, {});
40595
40564
  return result;
40596
40565
  };
40597
-
40598
40566
  /**
40599
40567
  * compose 1
40600
40568
  * 对于特定类型的 column,某些属性不允许设置
@@ -40703,26 +40671,16 @@
40703
40671
  }
40704
40672
  return column;
40705
40673
  };
40706
- const refreshColumnBasicConfig = () => {
40674
+ const registerColumn = () => {
40707
40675
  const defaults = {
40708
40676
  ...cellStarts[props.type],
40709
- type: props.type,
40710
40677
  id: columnId.value,
40711
- align: realAlign.value,
40712
- headerAlign: realHeaderAlign.value,
40713
- prop: props.prop,
40714
- showPopover: props.showPopover,
40715
- // index 列
40716
- index: props.index
40678
+ realAlign,
40679
+ realHeaderAlign
40717
40680
  };
40718
- const basicProps = ['columnKey', 'label', 'customClass', 'labelClass', 'type', 'renderHeader', 'resizable', 'formatter', 'fixed', 'resizable']; // eslint-disable-line
40719
- const selectProps = ['selectable', 'reserveSelection'];
40720
- const sortProps = ['sortable'];
40721
- const filterProps = ['filters', 'filteredValue', 'filterMultiple', 'filter', 'filterIcon', 'filterPopupClass'];
40722
- let column = getPropsData(basicProps, selectProps, sortProps, filterProps);
40723
- column = merge$1(defaults, column);
40724
-
40725
- // 注意 compose 中函数执行的顺序是从右到左
40681
+ let column = merge$1(defaults, getPropsData(Object.keys(props)));
40682
+
40683
+ // minWidth/realWidth/renderHeader
40726
40684
  column = compose(setColumnRenders, setColumnWidth, setColumnForcedProps)(column);
40727
40685
  for (const key in column) {
40728
40686
  if (hasOwn$1(column, key)) {
@@ -40730,11 +40688,17 @@
40730
40688
  }
40731
40689
  }
40732
40690
  };
40733
- const registerComplexWatchers = () => {
40691
+ const registerWatchers = () => {
40692
+ // 赋值
40693
+ Object.keys(props).forEach(k => vue.watch(() => props[k], v => columnConfig[k] = v));
40694
+
40695
+ // 影响布局
40734
40696
  vue.watch(() => props.fixed, () => {
40735
40697
  table.exposed.store.scheduleLayout(true);
40736
40698
  });
40737
- vue.watch(() => realWidth.value, () => {
40699
+ vue.watch(() => realWidth.value, v => {
40700
+ columnConfig['width'] = v;
40701
+ columnConfig['realWidth'] = v;
40738
40702
  table.exposed.store.scheduleLayout(false);
40739
40703
  });
40740
40704
  vue.watch(() => realMinWidth.value, () => {
@@ -40742,10 +40706,9 @@
40742
40706
  });
40743
40707
  };
40744
40708
  vue.onBeforeMount(() => {
40745
- refreshColumnBasicConfig();
40746
- registerComplexWatchers();
40709
+ registerColumn();
40710
+ registerWatchers();
40747
40711
  });
40748
- vue.onUpdated(refreshColumnBasicConfig);
40749
40712
  vue.onMounted(() => {
40750
40713
  const children = isSubColumn ? parent.vnode.el.children : parent.exposed.hiddenColumns.value.children;
40751
40714
 
@@ -40773,7 +40736,8 @@
40773
40736
  const renderDefault = slots?.default?.({
40774
40737
  row: {},
40775
40738
  column: {},
40776
- $index: -1
40739
+ columnIndex: -1,
40740
+ rowIndex: -1
40777
40741
  });
40778
40742
  if (renderDefault instanceof Array) {
40779
40743
  for (const childNode of renderDefault) {