@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.
package/dist/index.cjs CHANGED
@@ -8008,6 +8008,7 @@ const Track = /* @__PURE__ */ vue.defineComponent({
8008
8008
  isVisible.value = cursorDown.value;
8009
8009
  };
8010
8010
  const refreshThumb = () => Utils.raf(() => {
8011
+ if (!thumb.value) return;
8011
8012
  thumb.value.style[$__namespace.prefixStyle('transform').camel] = `translate${barOptions.value.axis}(${thumbMove.value}px)`;
8012
8013
  });
8013
8014
  const refreshThrottleThumb = lodashEs.throttle(refreshThumb, 10);
@@ -13168,6 +13169,7 @@ const RecycleList = /* @__PURE__ */ vue.defineComponent({
13168
13169
 
13169
13170
  // 设置data首个元素的在originalData索引值
13170
13171
  const setFirstItemIndex = () => {
13172
+ if (!wrapper.value) return;
13171
13173
  const position = wrapper.value[K.scrollAxis];
13172
13174
  let item;
13173
13175
  for (let i = 0; i < rebuildData.value.length; i++) {
@@ -13348,6 +13350,7 @@ const RecycleList = /* @__PURE__ */ vue.defineComponent({
13348
13350
 
13349
13351
  // 图片撑开时,会影响布局, 节流结束后调用
13350
13352
  const handleResize = Utils.throttle(async () => {
13353
+ if (!wrapper.value) return;
13351
13354
  const isNeedRefreshLayout = rebuildData.value.some(i => !i.isPlaceholder);
13352
13355
  if (isNeedRefreshLayout) {
13353
13356
  const oldFirstItemIndex = firstItemIndex.value;
@@ -13785,88 +13788,65 @@ const MSwitch = /* @__PURE__ */ vue.defineComponent({
13785
13788
  }
13786
13789
  });
13787
13790
 
13788
- const parseHeight = (height) => {
13789
- if (typeof height === "number") {
13790
- return height;
13791
+ const parseHeight = (v) => {
13792
+ if (typeof v === "number") {
13793
+ return v;
13791
13794
  }
13792
- if (height && typeof height === "string") {
13793
- if (/^\d+(?:px)?/.test(height)) {
13794
- return parseInt(height, 10);
13795
+ if (v && typeof v === "string") {
13796
+ if (/^\d+(?:px)?/.test(v)) {
13797
+ return parseInt(v, 10);
13795
13798
  }
13796
13799
  throw new VcError("table", "Invalid Height");
13797
13800
  }
13798
13801
  return null;
13799
13802
  };
13800
- const parseWidth = (width) => {
13801
- if (width !== void 0) {
13802
- width = parseInt(width, 10);
13803
- if (isNaN(width)) {
13804
- width = null;
13803
+ const parseWidth = (v) => {
13804
+ if (typeof v === "number") {
13805
+ return v;
13806
+ }
13807
+ let v1;
13808
+ if (typeof v !== "undefined") {
13809
+ v1 = parseInt(v, 10);
13810
+ if (isNaN(v1)) {
13811
+ v1 = null;
13805
13812
  }
13806
13813
  }
13807
- return width;
13814
+ return v1;
13808
13815
  };
13809
- const parseMinWidth = (minWidth) => {
13810
- if (typeof minWidth !== "undefined") {
13811
- minWidth = parseWidth(minWidth);
13812
- if (isNaN(minWidth)) {
13813
- minWidth = 80;
13816
+ const parseMinWidth = (v) => {
13817
+ if (typeof v === "number") {
13818
+ return v;
13819
+ }
13820
+ let v1;
13821
+ if (typeof v !== "undefined") {
13822
+ v1 = parseWidth(v);
13823
+ if (isNaN(v1)) {
13824
+ v = 80;
13814
13825
  }
13815
13826
  }
13816
- return minWidth;
13827
+ return v1;
13817
13828
  };
13818
- const getRowIdentity = (row, rowKey) => {
13829
+ const getRowValue = (row, primaryKey) => {
13819
13830
  if (row.__KEY__) return row.__KEY__;
13820
13831
  if (!row) throw new VcError("table", "row is required when get row identity");
13821
- if (typeof rowKey === "string") {
13822
- if (!rowKey.includes(".")) {
13823
- return row[rowKey];
13832
+ if (typeof primaryKey === "string") {
13833
+ if (!primaryKey.includes(".")) {
13834
+ return row[primaryKey];
13824
13835
  }
13825
- const key = rowKey.split(".");
13836
+ const key = primaryKey.split(".");
13826
13837
  let current = row;
13827
13838
  for (let i = 0; i < key.length; i++) {
13828
13839
  current = current[key[i]];
13829
13840
  }
13830
13841
  return current;
13831
- } else if (typeof rowKey === "function") {
13832
- return rowKey.call(null, row);
13842
+ } else if (typeof primaryKey === "function") {
13843
+ return primaryKey.call(null, row);
13833
13844
  }
13834
13845
  };
13835
- const walkTreeNode = (root, cb, opts = {}) => {
13836
- const {
13837
- childrenKey = "children",
13838
- lazyKey = "hasChildren",
13839
- level: baseLevel = 0
13840
- } = opts;
13841
- const isNil = (array) => !(Array.isArray(array) && array.length);
13842
- function _walker(parent, children, level) {
13843
- cb(parent, children, level);
13844
- children.forEach((item) => {
13845
- if (item[lazyKey]) {
13846
- cb(item, null, level + 1);
13847
- return;
13848
- }
13849
- const $children = item[childrenKey];
13850
- if (!isNil($children)) {
13851
- _walker(item, $children, level + 1);
13852
- }
13853
- });
13854
- }
13855
- root.forEach((item) => {
13856
- if (item[lazyKey]) {
13857
- cb(item, null, baseLevel);
13858
- return;
13859
- }
13860
- const children = item[childrenKey];
13861
- if (!isNil(children)) {
13862
- _walker(item, children, baseLevel);
13863
- }
13864
- });
13865
- };
13866
- const getKeysMap = (array = [], rowKey) => {
13846
+ const getValuesMap = (array = [], primaryKey) => {
13867
13847
  const arrayMap = {};
13868
13848
  array.forEach((row, index) => {
13869
- arrayMap[getRowIdentity(row, rowKey)] = { row, index };
13849
+ arrayMap[getRowValue(row, primaryKey)] = { row, index };
13870
13850
  });
13871
13851
  return arrayMap;
13872
13852
  };
@@ -13879,23 +13859,75 @@ const getColumnById = (columns, columnId) => {
13879
13859
  });
13880
13860
  return column;
13881
13861
  };
13882
- const getColumnByCell = (table, cell) => {
13862
+ const getColumnByCell = (columns, cell) => {
13883
13863
  const matches = (cell.className || "").match(/vc-table_[^\s]+/gm);
13884
13864
  if (matches) {
13885
- return getColumnById(table, matches[0]);
13865
+ return getColumnById(columns, matches[0]);
13886
13866
  }
13887
13867
  return null;
13888
13868
  };
13889
- const getCell = (event) => {
13890
- let cell = event.target;
13869
+ const getCell = (e) => {
13870
+ let cell = e.target;
13891
13871
  while (cell && cell.tagName.toUpperCase() !== "HTML") {
13892
- if (cell.tagName.toUpperCase() === "TD") {
13872
+ if (cell.classList.contains("vc-table__td")) {
13893
13873
  return cell;
13894
13874
  }
13895
13875
  cell = cell.parentNode;
13896
13876
  }
13897
13877
  return null;
13898
13878
  };
13879
+
13880
+ const getAllColumns = (columns) => {
13881
+ const result = [];
13882
+ columns.forEach((column) => {
13883
+ if (column.children) {
13884
+ result.push(column);
13885
+ result.push(...getAllColumns(column.children));
13886
+ } else {
13887
+ result.push(column);
13888
+ }
13889
+ });
13890
+ return result;
13891
+ };
13892
+ const columnsToRowsEffect = (v) => {
13893
+ let maxLevel = 1;
13894
+ const traverse = (column, parent) => {
13895
+ if (parent) {
13896
+ column.level = parent.level + 1;
13897
+ if (maxLevel < column.level) {
13898
+ maxLevel = column.level;
13899
+ }
13900
+ }
13901
+ if (column.children) {
13902
+ let colSpan = 0;
13903
+ column.children.forEach((subColumn) => {
13904
+ traverse(subColumn, column);
13905
+ colSpan += subColumn.colSpan;
13906
+ });
13907
+ column.colSpan = colSpan;
13908
+ } else {
13909
+ column.colSpan = 1;
13910
+ }
13911
+ };
13912
+ v.forEach((column) => {
13913
+ column.level = 1;
13914
+ traverse(column);
13915
+ });
13916
+ const rows = [];
13917
+ for (let i = 0; i < maxLevel; i++) {
13918
+ rows.push([]);
13919
+ }
13920
+ const allColumns = getAllColumns(v);
13921
+ allColumns.forEach((column) => {
13922
+ if (!column.children) {
13923
+ column.rowSpan = maxLevel - column.level + 1;
13924
+ } else {
13925
+ column.rowSpan = 1;
13926
+ }
13927
+ rows[column.level - 1].push(column);
13928
+ });
13929
+ return rows;
13930
+ };
13899
13931
  const flattenData = (data, opts = {}) => {
13900
13932
  const result = [];
13901
13933
  data.forEach((item) => {
@@ -13908,6 +13940,37 @@ const flattenData = (data, opts = {}) => {
13908
13940
  });
13909
13941
  return result;
13910
13942
  };
13943
+ const walkTreeNode = (root, cb, opts = {}) => {
13944
+ const {
13945
+ childrenKey = "children",
13946
+ lazyKey = "hasChildren",
13947
+ level: baseLevel = 0
13948
+ } = opts;
13949
+ const isNil = (array) => !(Array.isArray(array) && array.length);
13950
+ function _walker(parent, children, level) {
13951
+ cb(parent, children, level);
13952
+ children.forEach((item) => {
13953
+ if (item[lazyKey]) {
13954
+ cb(item, null, level + 1);
13955
+ return;
13956
+ }
13957
+ const $children = item[childrenKey];
13958
+ if (!isNil($children)) {
13959
+ _walker(item, $children, level + 1);
13960
+ }
13961
+ });
13962
+ }
13963
+ root.forEach((item) => {
13964
+ if (item[lazyKey]) {
13965
+ cb(item, null, baseLevel);
13966
+ return;
13967
+ }
13968
+ const children = item[childrenKey];
13969
+ if (!isNil(children)) {
13970
+ _walker(item, children, baseLevel);
13971
+ }
13972
+ });
13973
+ };
13911
13974
 
13912
13975
  class BaseWatcher {
13913
13976
  states = vue.reactive({
@@ -13915,23 +13978,14 @@ class BaseWatcher {
13915
13978
  _data: [],
13916
13979
  data: [],
13917
13980
  list: [],
13918
- // 是否包含固定列
13919
- isComplex: false,
13920
- // 列
13981
+ // 表头数据
13982
+ headerRows: [],
13983
+ // 列 动态收集vc-table-column中的columnConfig
13921
13984
  _columns: [],
13922
- // 动态收集vc-table-column中的columnConfig
13923
13985
  originColumns: [],
13924
- // leftFixedColumns, notFixedColumns, rightFixedColumns
13925
- columns: [],
13926
- // 包括 leftFixedLeafColumns,leafColumns,rightFixedLeafColumns
13986
+ notFixedColumns: [],
13927
13987
  leftFixedColumns: [],
13928
13988
  rightFixedColumns: [],
13929
- leafColumns: [],
13930
- leftFixedLeafColumns: [],
13931
- rightFixedLeafColumns: [],
13932
- leafColumnsLength: 0,
13933
- leftFixedLeafColumnsLength: 0,
13934
- rightFixedLeafColumnsLength: 0,
13935
13989
  // 选择
13936
13990
  isAllSelected: false,
13937
13991
  selection: [],
@@ -13953,7 +14007,17 @@ class BaseWatcher {
13953
14007
  treeLazyData: [],
13954
14008
  // 源数据展开
13955
14009
  treeLazyColumnIdentifier: "hasChildren",
13956
- treeChildrenColumnName: "children"
14010
+ treeChildrenColumnName: "children",
14011
+ // compputeds
14012
+ isComplex: vue.computed(() => this.states.leftFixedColumns.length > 0 || this.states.rightFixedColumns.length > 0),
14013
+ isGroup: vue.computed(() => this.states.columns.length > this.states.originColumns.length),
14014
+ columns: vue.computed(() => lodash.concat(this.states.leftFixedLeafColumns, this.states.leafColumns, this.states.rightFixedLeafColumns)),
14015
+ leafColumns: vue.computed(() => flattenData(this.states.notFixedColumns)),
14016
+ leftFixedLeafColumns: vue.computed(() => flattenData(this.states.leftFixedColumns)),
14017
+ rightFixedLeafColumns: vue.computed(() => flattenData(this.states.rightFixedColumns)),
14018
+ leafColumnsLength: vue.computed(() => this.states.leafColumns.length),
14019
+ leftFixedLeafColumnsLength: vue.computed(() => this.states.leftFixedLeafColumns.length),
14020
+ rightFixedLeafColumnsLength: vue.computed(() => this.states.rightFixedLeafColumns.length)
13957
14021
  });
13958
14022
  }
13959
14023
 
@@ -13964,14 +14028,14 @@ class Expand {
13964
14028
  }
13965
14029
  update() {
13966
14030
  const store = this.store;
13967
- const { rowKey, defaultExpandAll } = this.store.table.props;
14031
+ const { primaryKey, defaultExpandAll } = this.store.table.props;
13968
14032
  const { data = [], expandRows } = store.states;
13969
14033
  if (defaultExpandAll) {
13970
14034
  store.states.expandRows = data.slice();
13971
- } else if (rowKey) {
13972
- const expandRowsMap = getKeysMap(expandRows, rowKey);
14035
+ } else if (primaryKey) {
14036
+ const expandRowsMap = getValuesMap(expandRows, primaryKey);
13973
14037
  store.states.expandRows = data.reduce((prev, row) => {
13974
- const rowId = getRowIdentity(row, rowKey);
14038
+ const rowId = getRowValue(row, primaryKey);
13975
14039
  const rowInfo = expandRowsMap[rowId];
13976
14040
  if (rowInfo) {
13977
14041
  prev.push(row);
@@ -13993,10 +14057,10 @@ class Expand {
13993
14057
  }
13994
14058
  reset(ids) {
13995
14059
  const store = this.store;
13996
- store.checkRowKey();
13997
- const { rowKey } = store.table.props;
14060
+ store.checkPrimaryKey();
14061
+ const { primaryKey } = store.table.props;
13998
14062
  const { data } = store.states;
13999
- const keysMap = getKeysMap(data, rowKey);
14063
+ const keysMap = getValuesMap(data, primaryKey);
14000
14064
  store.states.expandRows = ids.reduce((prev, cur) => {
14001
14065
  const info = keysMap[cur];
14002
14066
  if (info) {
@@ -14006,11 +14070,11 @@ class Expand {
14006
14070
  }, []);
14007
14071
  }
14008
14072
  isExpanded(row) {
14009
- const { rowKey } = this.store.table.props;
14073
+ const { primaryKey } = this.store.table.props;
14010
14074
  const { expandRows = [] } = this.store.states;
14011
- if (rowKey) {
14012
- const expandMap = getKeysMap(expandRows, rowKey);
14013
- return !!expandMap[getRowIdentity(row, rowKey)];
14075
+ if (primaryKey) {
14076
+ const expandMap = getValuesMap(expandRows, primaryKey);
14077
+ return !!expandMap[getRowValue(row, primaryKey)];
14014
14078
  }
14015
14079
  return expandRows.indexOf(row) !== -1;
14016
14080
  }
@@ -14023,22 +14087,22 @@ class Current {
14023
14087
  }
14024
14088
  reset(id) {
14025
14089
  const store = this.store;
14026
- const { rowKey } = store.table.props;
14027
- store.checkRowKey();
14090
+ const { primaryKey } = store.table.props;
14091
+ store.checkPrimaryKey();
14028
14092
  const { data = [] } = store.states;
14029
- const currentRow = data.find((item) => getRowIdentity(item, rowKey) === id);
14093
+ const currentRow = data.find((item) => getRowValue(item, primaryKey) === id);
14030
14094
  store.states.currentRow = currentRow || null;
14031
14095
  }
14032
14096
  update() {
14033
14097
  const store = this.store;
14034
- const { rowKey } = store.table.props;
14098
+ const { primaryKey } = store.table.props;
14035
14099
  const { data = [], currentRow } = store.states;
14036
14100
  const oldCurrentRow = currentRow;
14037
14101
  if (oldCurrentRow && !data.includes(oldCurrentRow)) {
14038
14102
  let newCurrentRow = null;
14039
- if (rowKey) {
14103
+ if (primaryKey) {
14040
14104
  newCurrentRow = data.find((item) => {
14041
- return getRowIdentity(item, rowKey) === getRowIdentity(oldCurrentRow, rowKey);
14105
+ return getRowValue(item, primaryKey) === getRowValue(oldCurrentRow, primaryKey);
14042
14106
  });
14043
14107
  }
14044
14108
  store.states.currentRow = newCurrentRow;
@@ -14057,8 +14121,8 @@ let Tree$1 = class Tree {
14057
14121
  * { id: { level, children } }
14058
14122
  */
14059
14123
  normalizedData = vue.computed(() => {
14060
- const { rowKey } = this.store.table.props;
14061
- if (!rowKey) return {};
14124
+ const { primaryKey } = this.store.table.props;
14125
+ if (!primaryKey) return {};
14062
14126
  return this.normalize(this.store.states.data || []);
14063
14127
  });
14064
14128
  /**
@@ -14066,7 +14130,7 @@ let Tree$1 = class Tree {
14066
14130
  * { id: { children } }
14067
14131
  */
14068
14132
  normalizedLazyNode = vue.computed(() => {
14069
- const { rowKey } = this.store.table.props;
14133
+ const { primaryKey } = this.store.table.props;
14070
14134
  const { treelazyNodeMap, treeLazyColumnIdentifier, treeChildrenColumnName } = this.store.states;
14071
14135
  const keys = Object.keys(treelazyNodeMap);
14072
14136
  const res = {};
@@ -14075,7 +14139,7 @@ let Tree$1 = class Tree {
14075
14139
  if (treelazyNodeMap[key].length) {
14076
14140
  const item = { children: [] };
14077
14141
  treelazyNodeMap[key].forEach((row) => {
14078
- const id = getRowIdentity(row, rowKey);
14142
+ const id = getRowValue(row, primaryKey);
14079
14143
  item.children.push(id);
14080
14144
  const hasChildren = row[treeLazyColumnIdentifier] || row[treeChildrenColumnName] && row[treeChildrenColumnName].length === 0;
14081
14145
  if (hasChildren && !res[id]) {
@@ -14095,16 +14159,16 @@ let Tree$1 = class Tree {
14095
14159
  );
14096
14160
  }
14097
14161
  normalize(data) {
14098
- const { rowKey } = this.store.table.props;
14162
+ const { primaryKey } = this.store.table.props;
14099
14163
  const { treeChildrenColumnName, treeLazyColumnIdentifier, treeLazy } = this.store.states;
14100
14164
  const res = {};
14101
14165
  walkTreeNode(
14102
14166
  data,
14103
14167
  (parent, children, level) => {
14104
- const parentId = getRowIdentity(parent, rowKey);
14168
+ const parentId = getRowValue(parent, primaryKey);
14105
14169
  if (Array.isArray(children)) {
14106
14170
  res[parentId] = {
14107
- children: children.map((row) => getRowIdentity(row, rowKey)),
14171
+ children: children.map((row) => getRowValue(row, primaryKey)),
14108
14172
  level
14109
14173
  };
14110
14174
  } else if (treeLazy) {
@@ -14124,7 +14188,7 @@ let Tree$1 = class Tree {
14124
14188
  }
14125
14189
  // 获取当前展开最大的level
14126
14190
  getMaxLevel() {
14127
- const { rowKey } = this.store.table.props;
14191
+ const { primaryKey } = this.store.table.props;
14128
14192
  const { data, treeData } = this.store.states;
14129
14193
  const levels = data.map((item) => {
14130
14194
  const traverse = (source) => {
@@ -14135,7 +14199,7 @@ let Tree$1 = class Tree {
14135
14199
  return source.level;
14136
14200
  }
14137
14201
  };
14138
- const id = getRowIdentity(item, rowKey);
14202
+ const id = getRowValue(item, primaryKey);
14139
14203
  return traverse(treeData[id]);
14140
14204
  });
14141
14205
  return lodashEs.max(levels) || 0;
@@ -14197,10 +14261,10 @@ let Tree$1 = class Tree {
14197
14261
  this.update();
14198
14262
  }
14199
14263
  toggle(row, expanded) {
14200
- this.store.checkRowKey();
14201
- const { rowKey } = this.store.table.props;
14264
+ this.store.checkPrimaryKey();
14265
+ const { primaryKey } = this.store.table.props;
14202
14266
  const { treeData } = this.store.states;
14203
- const id = getRowIdentity(row, rowKey);
14267
+ const id = getRowValue(row, primaryKey);
14204
14268
  const data = id && treeData[id];
14205
14269
  if (id && data && "expanded" in data) {
14206
14270
  const oldExpanded = data.expanded;
@@ -14213,10 +14277,10 @@ let Tree$1 = class Tree {
14213
14277
  }
14214
14278
  }
14215
14279
  loadOrToggle(row) {
14216
- this.store.checkRowKey();
14217
- const { rowKey } = this.store.table.props;
14280
+ this.store.checkPrimaryKey();
14281
+ const { primaryKey } = this.store.table.props;
14218
14282
  const { treeLazy, treeData } = this.store.states;
14219
- const id = getRowIdentity(row, rowKey);
14283
+ const id = getRowValue(row, primaryKey);
14220
14284
  const data = treeData[id];
14221
14285
  if (treeLazy && data && "loaded" in data && !data.loaded) {
14222
14286
  this.loadData(row, id, data);
@@ -14225,9 +14289,9 @@ let Tree$1 = class Tree {
14225
14289
  }
14226
14290
  }
14227
14291
  loadData(row, key, treeNode) {
14228
- this.store.checkRowKey();
14292
+ this.store.checkPrimaryKey();
14229
14293
  const { table } = this.store;
14230
- const { rowKey } = table.props;
14294
+ const { primaryKey } = table.props;
14231
14295
  const { treelazyNodeMap, treeData, treeChildrenColumnName, treeLazyColumnIdentifier } = this.store.states;
14232
14296
  if (table.props.loadExpand && !treeData[key].loaded) {
14233
14297
  this.store.states.treeData[key].loading = true;
@@ -14242,7 +14306,7 @@ let Tree$1 = class Tree {
14242
14306
  walkTreeNode(
14243
14307
  data,
14244
14308
  (parent, _, level) => {
14245
- const id = getRowIdentity(parent, rowKey);
14309
+ const id = getRowValue(parent, primaryKey);
14246
14310
  Object.defineProperty(parent, "__KEY__", {
14247
14311
  value: `${level}__${id}`,
14248
14312
  writable: false
@@ -14312,27 +14376,13 @@ class Layout {
14312
14376
  if (!this.store) {
14313
14377
  throw new VcError("table", "Table Layout 必须包含store实例");
14314
14378
  }
14315
- this.updateScroller = this.updateScroller.bind(this);
14316
- this.updateColumns = this.updateColumns.bind(this);
14317
- vue.onMounted(() => {
14318
- this.updateColumns();
14319
- this.updateScroller();
14320
- });
14321
- let __updated__;
14322
- vue.onUpdated(() => {
14323
- if (__updated__) return;
14324
- this.updateColumns();
14325
- this.updateScroller();
14326
- __updated__ = true;
14327
- });
14328
14379
  }
14329
14380
  updateScrollY() {
14330
14381
  const { height, bodyHeight } = this.states;
14331
14382
  if (height === null || bodyHeight === null) return;
14332
- const scroller = this.table.exposed.scroller.value;
14333
- if (this.table.vnode.el && scroller) {
14334
- const body = scroller.$el.querySelector(".vc-table__body");
14335
- this.states.scrollY = body.offsetHeight > bodyHeight;
14383
+ const bodyYWrapper = this.table.exposed.bodyYWrapper.value;
14384
+ if (this.table.vnode.el && bodyYWrapper) {
14385
+ this.states.scrollY = bodyYWrapper.offsetHeight > bodyHeight;
14336
14386
  }
14337
14387
  }
14338
14388
  setHeight(value, prop = "height") {
@@ -14349,18 +14399,6 @@ class Layout {
14349
14399
  setMaxHeight(value) {
14350
14400
  this.setHeight(value, "max-height");
14351
14401
  }
14352
- getFlattenColumns() {
14353
- const flattenColumns = [];
14354
- const columns = this.store.states.columns;
14355
- columns.forEach((column) => {
14356
- if (column.isColumnGroup) {
14357
- flattenColumns.push(...column.columns);
14358
- } else {
14359
- flattenColumns.push(column);
14360
- }
14361
- });
14362
- return flattenColumns;
14363
- }
14364
14402
  updateElsHeight() {
14365
14403
  if (!this.table.exposed.isReady.value) return vue.nextTick(() => this.updateElsHeight());
14366
14404
  const table = this.table.exposed;
@@ -14383,13 +14421,12 @@ class Layout {
14383
14421
  this.states.bodyHeight = tableHeight - headerHeight - footerHeight + (footerWrapper ? 1 : 0);
14384
14422
  }
14385
14423
  this.updateScrollY();
14386
- this.updateScroller();
14387
14424
  }
14388
14425
  updateColumnsWidth() {
14389
14426
  if (vcShared.IS_SERVER) return;
14390
14427
  const bodyWidth = this.table.vnode.el.clientWidth;
14391
14428
  let bodyMinWidth = 0;
14392
- const flattenColumns = this.getFlattenColumns();
14429
+ const flattenColumns = this.store.states.columns;
14393
14430
  const flexColumns = flattenColumns.filter((column) => typeof column.width !== "number");
14394
14431
  const { fit } = this.table.props;
14395
14432
  if (flexColumns.length > 0 && fit) {
@@ -14415,7 +14452,7 @@ class Layout {
14415
14452
  }
14416
14453
  } else {
14417
14454
  this.states.scrollX = true;
14418
- flexColumns.forEach(function(column) {
14455
+ flexColumns.forEach((column) => {
14419
14456
  column.realWidth = column.width || column.minWidth;
14420
14457
  });
14421
14458
  }
@@ -14449,12 +14486,6 @@ class Layout {
14449
14486
  });
14450
14487
  this.states.rightFixedWidth = rightFixedWidth;
14451
14488
  }
14452
- this.updateColumns();
14453
- }
14454
- // v2.x中的 notifyObservers
14455
- updateColumns() {
14456
- }
14457
- updateScroller() {
14458
14489
  }
14459
14490
  }
14460
14491
 
@@ -14464,7 +14495,7 @@ class Store extends BaseWatcher {
14464
14495
  expand;
14465
14496
  tree;
14466
14497
  layout;
14467
- flattenData = vue.computed(() => {
14498
+ flatData = vue.computed(() => {
14468
14499
  if (this.table.props.expandSelectable) {
14469
14500
  return lodash.concat(
14470
14501
  flattenData(this.states.data, { parent: true, cascader: true }),
@@ -14522,7 +14553,7 @@ class Store extends BaseWatcher {
14522
14553
  this.cleanSelection();
14523
14554
  }
14524
14555
  } else {
14525
- this.checkRowKey();
14556
+ this.checkPrimaryKey();
14526
14557
  this.updateSelectionByRowKey();
14527
14558
  }
14528
14559
  this.updateAllSelected();
@@ -14544,10 +14575,10 @@ class Store extends BaseWatcher {
14544
14575
  }
14545
14576
  }
14546
14577
  /**
14547
- * 检查 rowKey 是否存在
14578
+ * 检查 primaryKey 是否存在
14548
14579
  */
14549
- checkRowKey() {
14550
- const { rowKey } = this.table.props;
14580
+ checkPrimaryKey() {
14581
+ const { primaryKey } = this.table.props;
14551
14582
  }
14552
14583
  /**
14553
14584
  * states
@@ -14608,22 +14639,20 @@ class Store extends BaseWatcher {
14608
14639
  updateColumns() {
14609
14640
  const { states } = this;
14610
14641
  const _columns = states._columns || [];
14611
- states.leftFixedColumns = _columns.filter((column) => column.fixed === true || column.fixed === "left");
14612
- states.rightFixedColumns = _columns.filter((column) => column.fixed === "right");
14613
- if (states.leftFixedColumns.length > 0 && _columns[0] && _columns[0].type === "selection" && !_columns[0].fixed) {
14642
+ const leftFixedColumns = _columns.filter((column) => column.fixed === true || column.fixed === "left");
14643
+ const rightFixedColumns = _columns.filter((column) => column.fixed === "right");
14644
+ if (leftFixedColumns.length > 0 && _columns[0] && _columns[0].type === "selection" && !_columns[0].fixed) {
14614
14645
  _columns[0].fixed = true;
14615
- states.leftFixedColumns.unshift(_columns[0]);
14646
+ leftFixedColumns.unshift(_columns[0]);
14616
14647
  }
14617
14648
  const notFixedColumns = _columns.filter((column) => !column.fixed);
14618
- states.originColumns = lodash.concat(states.leftFixedColumns, notFixedColumns, states.rightFixedColumns);
14619
- const leafColumns = flattenData(notFixedColumns);
14620
- const leftFixedLeafColumns = flattenData(states.leftFixedColumns);
14621
- const rightFixedLeafColumns = flattenData(states.rightFixedColumns);
14622
- states.leafColumnsLength = leafColumns.length;
14623
- states.leftFixedLeafColumnsLength = leftFixedLeafColumns.length;
14624
- states.rightFixedLeafColumnsLength = rightFixedLeafColumns.length;
14625
- states.columns = lodash.concat(leftFixedLeafColumns, leafColumns, rightFixedLeafColumns);
14626
- states.isComplex = states.leftFixedColumns.length > 0 || states.rightFixedColumns.length > 0;
14649
+ const originColumns = lodash.concat(leftFixedColumns, notFixedColumns, rightFixedColumns);
14650
+ const headerRows = columnsToRowsEffect(originColumns);
14651
+ states.leftFixedColumns = leftFixedColumns;
14652
+ states.notFixedColumns = notFixedColumns;
14653
+ states.rightFixedColumns = rightFixedColumns;
14654
+ states.originColumns = originColumns;
14655
+ states.headerRows = headerRows;
14627
14656
  }
14628
14657
  // 选择
14629
14658
  isSelected(row) {
@@ -14647,13 +14676,13 @@ class Store extends BaseWatcher {
14647
14676
  * 清理选择
14648
14677
  */
14649
14678
  cleanSelection() {
14650
- const { rowKey } = this.table.props;
14679
+ const { primaryKey } = this.table.props;
14651
14680
  const { selection = [] } = this.states;
14652
14681
  let deleted;
14653
- if (rowKey) {
14682
+ if (primaryKey) {
14654
14683
  deleted = [];
14655
- const selectedMap = getKeysMap(selection, rowKey);
14656
- const dataMap = getKeysMap(selection, rowKey);
14684
+ const selectedMap = getValuesMap(selection, primaryKey);
14685
+ const dataMap = getValuesMap(selection, primaryKey);
14657
14686
  for (const key in selectedMap) {
14658
14687
  if (Utils.hasOwn(selectedMap, key) && !dataMap[key]) {
14659
14688
  deleted.push(selectedMap[key].row);
@@ -14661,7 +14690,7 @@ class Store extends BaseWatcher {
14661
14690
  }
14662
14691
  } else {
14663
14692
  deleted = selection.filter((item) => {
14664
- return !this.flattenData.value.includes(item);
14693
+ return !this.flatData.value.includes(item);
14665
14694
  });
14666
14695
  }
14667
14696
  deleted.forEach((deletedItem) => {
@@ -14722,7 +14751,7 @@ class Store extends BaseWatcher {
14722
14751
  const value = indeterminate ? !isAllSelected : !(isAllSelected || selection.length);
14723
14752
  this.states.isAllSelected = value;
14724
14753
  let selectionChanged = false;
14725
- this.flattenData.value.forEach((row, index) => {
14754
+ this.flatData.value.forEach((row, index) => {
14726
14755
  if (selectable) {
14727
14756
  if (selectable.call(null, row, index) && this.toggleRowStatus(selection, row, value)) {
14728
14757
  selectionChanged = true;
@@ -14753,11 +14782,11 @@ class Store extends BaseWatcher {
14753
14782
  this.tree.expand(val);
14754
14783
  }
14755
14784
  updateSelectionByRowKey() {
14756
- const { rowKey } = this.table.props;
14785
+ const { primaryKey } = this.table.props;
14757
14786
  const { selection } = this.states;
14758
- const selectedMap = getKeysMap(selection, rowKey);
14759
- this.states.selection = this.flattenData.value.reduce((prev, row) => {
14760
- const rowId = getRowIdentity(row, rowKey);
14787
+ const selectedMap = getValuesMap(selection, primaryKey);
14788
+ this.states.selection = this.flatData.value.reduce((prev, row) => {
14789
+ const rowId = getRowValue(row, primaryKey);
14761
14790
  const rowInfo = selectedMap[rowId];
14762
14791
  if (rowInfo) {
14763
14792
  prev.push(row);
@@ -14773,7 +14802,7 @@ class Store extends BaseWatcher {
14773
14802
  }
14774
14803
  let isAllSelected = true;
14775
14804
  let selectedCount = 0;
14776
- const temp = this.flattenData.value;
14805
+ const temp = this.flatData.value;
14777
14806
  for (let i = 0, j = temp.length; i < j; i++) {
14778
14807
  const row = temp[i];
14779
14808
  const isRowSelectable = selectable && selectable.call(null, row, i);
@@ -14888,6 +14917,7 @@ const TableBody = /* @__PURE__ */ vue.defineComponent({
14888
14917
  type
14889
14918
  }) => type === 'default')
14890
14919
  });
14920
+ const wrapper = vue.ref();
14891
14921
  vue.watch(() => props.store.states.hoverRowIndex, (v, oldV) => {
14892
14922
  if (!props.store.states.isComplex || vcShared.IS_SERVER) return;
14893
14923
  Utils.raf(() => {
@@ -14898,12 +14928,12 @@ const TableBody = /* @__PURE__ */ vue.defineComponent({
14898
14928
  newRow && $.addClass(newRow, 'hover-row');
14899
14929
  });
14900
14930
  });
14901
- const getKeyOfRow = (row, index) => {
14931
+ const getValueOfRow = (row, index) => {
14902
14932
  const {
14903
- rowKey
14933
+ primaryKey
14904
14934
  } = table.props;
14905
- if (rowKey) {
14906
- return getRowIdentity(row, rowKey);
14935
+ if (primaryKey) {
14936
+ return getRowValue(row, primaryKey);
14907
14937
  }
14908
14938
  return index;
14909
14939
  };
@@ -14968,7 +14998,7 @@ const TableBody = /* @__PURE__ */ vue.defineComponent({
14968
14998
  return cellStyle;
14969
14999
  };
14970
15000
  const getCellClass = (rowIndex, columnIndex, row, column) => {
14971
- const classes = [column.align, column.className];
15001
+ const classes = [column.realAlign, column.className];
14972
15002
  if (isColumnHidden(columnIndex)) {
14973
15003
  classes.push('is-hidden');
14974
15004
  }
@@ -15028,7 +15058,7 @@ const TableBody = /* @__PURE__ */ vue.defineComponent({
15028
15058
  const cell = getCell(e);
15029
15059
  if (!cell) return;
15030
15060
  const oldHoverState = table.exposed.hoverState.value || {};
15031
- table.emit('cell-mouse-leave', oldHoverState.row, oldHoverState.column, oldHoverState.cell, event);
15061
+ table.emit('cell-mouse-leave', oldHoverState.row, oldHoverState.column, oldHoverState.cell, e);
15032
15062
  };
15033
15063
  const handleMouseEnter = lodashEs.debounce(index => {
15034
15064
  props.store.setHoverRow(index);
@@ -15064,7 +15094,7 @@ const TableBody = /* @__PURE__ */ vue.defineComponent({
15064
15094
  const {
15065
15095
  columns
15066
15096
  } = states;
15067
- const key = getKeyOfRow(row, rowIndex);
15097
+ const key = getValueOfRow(row, rowIndex);
15068
15098
  return vue.createVNode("div", {
15069
15099
  "key": key,
15070
15100
  "class": [getRowClass(row, rowIndex), 'vc-table__tr'],
@@ -15128,13 +15158,12 @@ const TableBody = /* @__PURE__ */ vue.defineComponent({
15128
15158
  }
15129
15159
  });
15130
15160
  };
15131
- const wrapper = vue.ref();
15132
15161
  expose({
15133
15162
  wrapper,
15134
15163
  getRootElement: () => instance.vnode.el
15135
15164
  });
15165
+ const layout = table.exposed.layout;
15136
15166
  return () => {
15137
- const layout = table.exposed.layout;
15138
15167
  return vue.createVNode("div", {
15139
15168
  "class": "vc-table__body"
15140
15169
  }, [table.props.height ? vue.createVNode(RecycleList, {
@@ -15179,57 +15208,6 @@ const TableBody = /* @__PURE__ */ vue.defineComponent({
15179
15208
 
15180
15209
  const TableSort = 'div';
15181
15210
  const TableFilter = 'div';
15182
- const getAllColumns = columns => {
15183
- const result = [];
15184
- columns.forEach(column => {
15185
- if (column.children) {
15186
- result.push(column);
15187
- result.push(...getAllColumns(column.children));
15188
- } else {
15189
- result.push(column);
15190
- }
15191
- });
15192
- return result;
15193
- };
15194
- const convertToRows = originColumns => {
15195
- let maxLevel = 1;
15196
- const traverse = (column, parent) => {
15197
- if (parent) {
15198
- column.level = parent.level + 1;
15199
- if (maxLevel < column.level) {
15200
- maxLevel = column.level;
15201
- }
15202
- }
15203
- if (column.children) {
15204
- let colSpan = 0;
15205
- column.children.forEach(subColumn => {
15206
- traverse(subColumn, column);
15207
- colSpan += subColumn.colSpan;
15208
- });
15209
- column.colSpan = colSpan;
15210
- } else {
15211
- column.colSpan = 1;
15212
- }
15213
- };
15214
- originColumns.forEach(column => {
15215
- column.level = 1;
15216
- traverse(column);
15217
- });
15218
- const rows = [];
15219
- for (let i = 0; i < maxLevel; i++) {
15220
- rows.push([]);
15221
- }
15222
- const allColumns = getAllColumns(originColumns);
15223
- allColumns.forEach(column => {
15224
- if (!column.children) {
15225
- column.rowSpan = maxLevel - column.level + 1;
15226
- } else {
15227
- column.rowSpan = 1;
15228
- }
15229
- rows[column.level - 1].push(column);
15230
- });
15231
- return rows;
15232
- };
15233
15211
  const TableHeader = /* @__PURE__ */ vue.defineComponent({
15234
15212
  name: 'vc-table-header',
15235
15213
  props: {
@@ -15256,16 +15234,18 @@ const TableHeader = /* @__PURE__ */ vue.defineComponent({
15256
15234
  isAllSelected: 'isAllSelected',
15257
15235
  leftFixedLeafCount: 'leftFixedLeafColumnsLength',
15258
15236
  rightFixedLeafCount: 'rightFixedLeafColumnsLength',
15237
+ isGroup: 'isGroup',
15238
+ headerRows: 'headerRows',
15259
15239
  columnsCount: $states => $states.columns.length,
15260
15240
  leftFixedCount: $states => $states.leftFixedColumns.length,
15261
15241
  rightFixedCount: $states => $states.rightFixedColumns.length
15262
15242
  });
15263
- const isCellHidden = (index, columns) => {
15243
+ const isColumnHidden = index => {
15264
15244
  let start = 0;
15265
15245
  for (let i = 0; i < index; i++) {
15266
- start += columns[i].colSpan;
15246
+ start += states.columns[i].colSpan;
15267
15247
  }
15268
- const after = start + columns[index].colSpan - 1;
15248
+ const after = start + states.columns[index].colSpan - 1;
15269
15249
  if (props.fixed === true || props.fixed === 'left') {
15270
15250
  return after >= states.leftFixedLeafCount;
15271
15251
  } else if (props.fixed === 'right') {
@@ -15274,6 +15254,9 @@ const TableHeader = /* @__PURE__ */ vue.defineComponent({
15274
15254
  return after < states.leftFixedLeafCount || start >= states.columnsCount - states.rightFixedLeafCount;
15275
15255
  }
15276
15256
  };
15257
+ const columnsHidden = vue.computed(() => {
15258
+ return states.columns.map((_, index) => isColumnHidden(index));
15259
+ });
15277
15260
  const getHeaderRowStyle = rowIndex => {
15278
15261
  const {
15279
15262
  headerRowStyle
@@ -15314,8 +15297,8 @@ const TableHeader = /* @__PURE__ */ vue.defineComponent({
15314
15297
  return headerCellStyle;
15315
15298
  };
15316
15299
  const getHeaderCellClass = (rowIndex, columnIndex, row, column) => {
15317
- const classes = [column.id, column.order, column.headerAlign, column.className, column.labelClass];
15318
- if (rowIndex === 0 && isCellHidden(columnIndex, row)) {
15300
+ const classes = [column.id, column.order, column.realHeaderAlign, column.className, column.labelClass];
15301
+ if (rowIndex === 0 && columnsHidden.value[columnIndex]) {
15319
15302
  classes.push('is-hidden');
15320
15303
  }
15321
15304
  if (!column.children) {
@@ -15455,37 +15438,27 @@ const TableHeader = /* @__PURE__ */ vue.defineComponent({
15455
15438
  });
15456
15439
  };
15457
15440
  return () => {
15458
- const {
15459
- originColumns
15460
- } = props.store.states;
15461
- const columnRows = convertToRows(originColumns);
15462
-
15463
- // 是否拥有多级表头
15464
- const isGroup = columnRows.length > 1;
15465
- if (isGroup) table.exposed.isGroup.value = true;
15466
15441
  return vue.createVNode("div", {
15467
15442
  "class": "vc-table__header"
15468
15443
  }, [vue.createVNode("div", {
15469
15444
  "class": [{
15470
- 'is-group': isGroup
15445
+ 'is-group': states.isGroup
15471
15446
  }, 'vc-table__thead']
15472
15447
  }, [
15473
15448
  // renderList
15474
- columnRows.map((columns, rowIndex) => vue.createVNode("div", {
15449
+ states.headerRows.map((columns, rowIndex) => vue.createVNode("div", {
15475
15450
  "style": getHeaderRowStyle(rowIndex),
15476
15451
  "class": [getHeaderRowClass(rowIndex), 'vc-table__tr']
15477
- }, [columns.map((column, cellIndex) => vue.createVNode("div", {
15478
- "colspan": column.colSpan,
15479
- "rowspan": column.rowSpan,
15480
- "onMousemove": $event => handleMouseMove($event, column),
15452
+ }, [columns.map((column, columnIndex) => vue.createVNode("div", {
15453
+ "onMousemove": e => handleMouseMove(e, column),
15481
15454
  "onMouseout": handleMouseOut,
15482
- "onMousedown": $event => handleMouseDown($event, column),
15483
- "onClick": $event => handleHeaderClick($event, column),
15484
- "onContextmenu": $event => handleHeaderContextMenu($event, column),
15485
- "style": [getHeaderCellStyle(rowIndex, cellIndex, columns, column), {
15455
+ "onMousedown": e => handleMouseDown(e, column),
15456
+ "onClick": e => handleHeaderClick(e, column),
15457
+ "onContextmenu": e => handleHeaderContextMenu(e, column),
15458
+ "style": [getHeaderCellStyle(rowIndex, columnIndex, columns, column), {
15486
15459
  width: `${column.realWidth}px`
15487
15460
  }],
15488
- "class": [getHeaderCellClass(rowIndex, cellIndex, columns, column), 'vc-table__th'],
15461
+ "class": [getHeaderCellClass(rowIndex, columnIndex, columns, column), 'vc-table__th'],
15489
15462
  "key": column.id
15490
15463
  }, [vue.createVNode("div", {
15491
15464
  "class": ['vc-table__cell',
@@ -15495,10 +15468,8 @@ const TableHeader = /* @__PURE__ */ vue.defineComponent({
15495
15468
  column.labelClass]
15496
15469
  }, [column.renderHeader ? column.renderHeader({
15497
15470
  column,
15498
- $index: cellIndex,
15499
- // index: cellIndex,
15500
- store: props.store,
15501
- _self: instance
15471
+ columnIndex,
15472
+ store: props.store
15502
15473
  }) : column.label, column.tooltip ? vue.createVNode(Icon, {
15503
15474
  "type": "o-info",
15504
15475
  "onMouseenter": e => handleCellMouseEnter(e, column)
@@ -15540,28 +15511,28 @@ const TableFooter = /* @__PURE__ */ vue.defineComponent({
15540
15511
  leftFixedCount: $states => $states.leftFixedColumns.length,
15541
15512
  rightFixedCount: $states => $states.rightFixedColumns.length
15542
15513
  });
15543
- const isCellHidden = (index, columns, column) => {
15514
+ const isColumnHidden = (column, index) => {
15544
15515
  if (props.fixed === true || props.fixed === 'left') {
15545
15516
  return index >= states.leftFixedLeafCount;
15546
15517
  } else if (props.fixed === 'right') {
15547
15518
  let before = 0;
15548
15519
  for (let i = 0; i < index; i++) {
15549
- before += columns[i].colSpan;
15520
+ before += states.columns[i].colSpan;
15550
15521
  }
15551
15522
  return before < states.columnsCount - states.rightFixedLeafCount;
15552
15523
  } else if (!props.fixed && column.fixed) {
15553
- // hide cell when footer instance is not fixed and column is fixed
15554
15524
  return true;
15555
15525
  } else {
15556
15526
  return index < states.leftFixedCount || index >= states.columnsCount - states.rightFixedCount;
15557
15527
  }
15558
15528
  };
15559
- const getRowClasses = (column, cellIndex) => {
15560
- const classes = [column.id, column.align, column.labelClass];
15529
+ const columnsHidden = vue.computed(() => states.columns.map(isColumnHidden));
15530
+ const getRowClasses = (column, columnIndex) => {
15531
+ const classes = [column.realAlign, column.labelClass];
15561
15532
  if (column.className) {
15562
15533
  classes.push(column.className);
15563
15534
  }
15564
- if (isCellHidden(cellIndex, states.columns, column)) {
15535
+ if (columnsHidden.value[columnIndex]) {
15565
15536
  classes.push('is-hidden');
15566
15537
  }
15567
15538
  if (!column.children) {
@@ -15569,17 +15540,17 @@ const TableFooter = /* @__PURE__ */ vue.defineComponent({
15569
15540
  }
15570
15541
  return classes;
15571
15542
  };
15572
- return () => {
15573
- let sums = [];
15543
+ const sums = vue.computed(() => {
15544
+ let v = [];
15574
15545
  if (props.getSummary) {
15575
- sums = props.getSummary({
15546
+ v = props.getSummary({
15576
15547
  columns: states.columns,
15577
15548
  data: states.data
15578
15549
  });
15579
15550
  } else {
15580
15551
  states.columns.forEach((column, index) => {
15581
15552
  if (index === 0) {
15582
- sums[index] = props.sumText;
15553
+ v[index] = props.sumText;
15583
15554
  return;
15584
15555
  }
15585
15556
  const values = states.data.map(item => Number(item[column.prop]));
@@ -15594,7 +15565,7 @@ const TableFooter = /* @__PURE__ */ vue.defineComponent({
15594
15565
  });
15595
15566
  const precision = Math.max.apply(null, precisions);
15596
15567
  if (!notNumber) {
15597
- sums[index] = values.reduce((prev, curr) => {
15568
+ v[index] = values.reduce((prev, curr) => {
15598
15569
  const value = Number(curr);
15599
15570
  if (!isNaN(value)) {
15600
15571
  return parseFloat((prev + curr).toFixed(Math.min(precision, 20)));
@@ -15603,10 +15574,13 @@ const TableFooter = /* @__PURE__ */ vue.defineComponent({
15603
15574
  }
15604
15575
  }, 0);
15605
15576
  } else {
15606
- sums[index] = '';
15577
+ v[index] = '';
15607
15578
  }
15608
15579
  });
15609
15580
  }
15581
+ return v;
15582
+ });
15583
+ return () => {
15610
15584
  return vue.createVNode("div", {
15611
15585
  "class": "vc-table__footer",
15612
15586
  "cellspacing": "0",
@@ -15616,17 +15590,15 @@ const TableFooter = /* @__PURE__ */ vue.defineComponent({
15616
15590
  "class": "vc-table__tbody"
15617
15591
  }, [vue.createVNode("div", {
15618
15592
  "class": "vc-table__tr"
15619
- }, [states.columns.map((column, cellIndex) => vue.createVNode("div", {
15620
- "key": cellIndex,
15621
- "colspan": column.colSpan,
15622
- "rowspan": column.rowSpan,
15623
- "class": [getRowClasses(column, cellIndex), 'vc-table__td'],
15593
+ }, [states.columns.map((column, columnIndex) => vue.createVNode("div", {
15594
+ "key": columnIndex,
15595
+ "class": [getRowClasses(column, columnIndex), 'vc-table__td'],
15624
15596
  "style": [{
15625
15597
  width: `${column.realWidth}px`
15626
15598
  }]
15627
15599
  }, [vue.createVNode("div", {
15628
15600
  "class": ['vc-table__cell', column.labelClass]
15629
- }, [sums[cellIndex]])]))])])]);
15601
+ }, [sums.value[columnIndex]])]))])])]);
15630
15602
  };
15631
15603
  }
15632
15604
  });
@@ -15654,7 +15626,7 @@ const props$c = {
15654
15626
  type: Number,
15655
15627
  default: 10
15656
15628
  },
15657
- rowKey: [String, Function],
15629
+ primaryKey: [String, Function],
15658
15630
  // 是否显示表头
15659
15631
  showHeader: {
15660
15632
  type: Boolean,
@@ -15771,23 +15743,21 @@ const Table = /* @__PURE__ */ vue.defineComponent({
15771
15743
  const rightFixedBody = vue.ref(null);
15772
15744
  const rightFixedFooterWrapper = vue.ref(null);
15773
15745
  const resizeProxy = vue.ref(null);
15774
-
15775
- // 是否拥有多级表头, 由table-header控制
15776
- const isGroup = vue.ref(false);
15777
15746
  const scrollPosition = vue.ref('left');
15778
15747
  const hoverState = vue.ref(null);
15779
15748
  const isReady = vue.ref(false);
15780
15749
  const states = useStates({
15781
15750
  columns: 'columns',
15782
15751
  leftFixedColumns: 'leftFixedColumns',
15783
- rightFixedColumns: 'rightFixedColumns'
15752
+ rightFixedColumns: 'rightFixedColumns',
15753
+ isGroup: 'isGroup'
15784
15754
  }, store);
15785
15755
  const classes = vue.computed(() => {
15786
15756
  return {
15787
15757
  'vc-table--fit': props.fit,
15788
15758
  'vc-table--striped': props.stripe,
15789
- 'vc-table--border': props.border || isGroup.value,
15790
- 'vc-table--group': isGroup.value,
15759
+ 'vc-table--border': props.border || states.isGroup,
15760
+ 'vc-table--group': states.isGroup,
15791
15761
  'vc-table--fluid-height': props.maxHeight,
15792
15762
  'vc-table--scrollable-x': layout.states.scrollX,
15793
15763
  'vc-table--scrollable-y': layout.states.scrollY,
@@ -16048,7 +16018,7 @@ const Table = /* @__PURE__ */ vue.defineComponent({
16048
16018
  immediate: true
16049
16019
  });
16050
16020
  vue.watch(() => props.currentRowValue, v => {
16051
- if (!props.rowKey) return;
16021
+ if (!props.primaryKey) return;
16052
16022
  store.current.reset(v);
16053
16023
  }, {
16054
16024
  immediate: true
@@ -16077,6 +16047,7 @@ const Table = /* @__PURE__ */ vue.defineComponent({
16077
16047
  }, {
16078
16048
  immediate: true
16079
16049
  });
16050
+ const tableId = Utils.getUid('table');
16080
16051
  vue.onMounted(() => {
16081
16052
  bindEvents();
16082
16053
  store.updateColumns();
@@ -16087,12 +16058,13 @@ const Table = /* @__PURE__ */ vue.defineComponent({
16087
16058
  };
16088
16059
  isReady.value = true;
16089
16060
  });
16090
- vue.onBeforeUnmount(() => {
16061
+ vue.onUnmounted(() => {
16091
16062
  isUnMount = true;
16092
16063
  unbindEvents();
16093
16064
  });
16094
- const tableId = Utils.getUid('table');
16095
16065
  expose({
16066
+ bodyXWrapper,
16067
+ bodyYWrapper,
16096
16068
  tableId,
16097
16069
  store,
16098
16070
  layout,
@@ -16262,22 +16234,19 @@ const cellStarts = {
16262
16234
  order: ''
16263
16235
  },
16264
16236
  selection: {
16265
- width: 48,
16266
- minWidth: 48,
16267
- realWidth: 48,
16237
+ width: 60,
16238
+ minWidth: 60,
16268
16239
  order: '',
16269
16240
  className: 'vc-table-column--selection'
16270
16241
  },
16271
16242
  expand: {
16272
- width: 48,
16273
- minWidth: 48,
16274
- realWidth: 48,
16243
+ width: 60,
16244
+ minWidth: 60,
16275
16245
  order: ''
16276
16246
  },
16277
16247
  index: {
16278
- width: 48,
16279
- minWidth: 48,
16280
- realWidth: 48,
16248
+ width: 60,
16249
+ minWidth: 60,
16281
16250
  order: ''
16282
16251
  }
16283
16252
  };
@@ -16444,8 +16413,8 @@ const TableColumn = /* @__PURE__ */ vue.defineComponent({
16444
16413
  customClass: String,
16445
16414
  labelClass: String,
16446
16415
  prop: String,
16447
- width: [Number, String],
16448
- minWidth: [Number, String],
16416
+ width: Number,
16417
+ minWidth: Number,
16449
16418
  renderHeader: Function,
16450
16419
  resizable: {
16451
16420
  type: Boolean,
@@ -16517,7 +16486,6 @@ const TableColumn = /* @__PURE__ */ vue.defineComponent({
16517
16486
  }, {});
16518
16487
  return result;
16519
16488
  };
16520
-
16521
16489
  /**
16522
16490
  * compose 1
16523
16491
  * 对于特定类型的 column,某些属性不允许设置
@@ -16626,26 +16594,16 @@ const TableColumn = /* @__PURE__ */ vue.defineComponent({
16626
16594
  }
16627
16595
  return column;
16628
16596
  };
16629
- const refreshColumnBasicConfig = () => {
16597
+ const registerColumn = () => {
16630
16598
  const defaults = {
16631
16599
  ...cellStarts[props.type],
16632
- type: props.type,
16633
16600
  id: columnId.value,
16634
- align: realAlign.value,
16635
- headerAlign: realHeaderAlign.value,
16636
- prop: props.prop,
16637
- showPopover: props.showPopover,
16638
- // index 列
16639
- index: props.index
16601
+ realAlign,
16602
+ realHeaderAlign
16640
16603
  };
16641
- const basicProps = ['columnKey', 'label', 'customClass', 'labelClass', 'type', 'renderHeader', 'resizable', 'formatter', 'fixed', 'resizable']; // eslint-disable-line
16642
- const selectProps = ['selectable', 'reserveSelection'];
16643
- const sortProps = ['sortable'];
16644
- const filterProps = ['filters', 'filteredValue', 'filterMultiple', 'filter', 'filterIcon', 'filterPopupClass'];
16645
- let column = getPropsData(basicProps, selectProps, sortProps, filterProps);
16646
- column = lodashEs.merge(defaults, column);
16647
-
16648
- // 注意 compose 中函数执行的顺序是从右到左
16604
+ let column = lodashEs.merge(defaults, getPropsData(Object.keys(props)));
16605
+
16606
+ // minWidth/realWidth/renderHeader
16649
16607
  column = helperFp.compose(setColumnRenders, setColumnWidth, setColumnForcedProps)(column);
16650
16608
  for (const key in column) {
16651
16609
  if (Utils.hasOwn(column, key)) {
@@ -16653,11 +16611,17 @@ const TableColumn = /* @__PURE__ */ vue.defineComponent({
16653
16611
  }
16654
16612
  }
16655
16613
  };
16656
- const registerComplexWatchers = () => {
16614
+ const registerWatchers = () => {
16615
+ // 赋值
16616
+ Object.keys(props).forEach(k => vue.watch(() => props[k], v => columnConfig[k] = v));
16617
+
16618
+ // 影响布局
16657
16619
  vue.watch(() => props.fixed, () => {
16658
16620
  table.exposed.store.scheduleLayout(true);
16659
16621
  });
16660
- vue.watch(() => realWidth.value, () => {
16622
+ vue.watch(() => realWidth.value, v => {
16623
+ columnConfig['width'] = v;
16624
+ columnConfig['realWidth'] = v;
16661
16625
  table.exposed.store.scheduleLayout(false);
16662
16626
  });
16663
16627
  vue.watch(() => realMinWidth.value, () => {
@@ -16665,10 +16629,9 @@ const TableColumn = /* @__PURE__ */ vue.defineComponent({
16665
16629
  });
16666
16630
  };
16667
16631
  vue.onBeforeMount(() => {
16668
- refreshColumnBasicConfig();
16669
- registerComplexWatchers();
16632
+ registerColumn();
16633
+ registerWatchers();
16670
16634
  });
16671
- vue.onUpdated(refreshColumnBasicConfig);
16672
16635
  vue.onMounted(() => {
16673
16636
  const children = isSubColumn ? parent.vnode.el.children : parent.exposed.hiddenColumns.value.children;
16674
16637
 
@@ -16696,7 +16659,8 @@ const TableColumn = /* @__PURE__ */ vue.defineComponent({
16696
16659
  const renderDefault = slots?.default?.({
16697
16660
  row: {},
16698
16661
  column: {},
16699
- $index: -1
16662
+ columnIndex: -1,
16663
+ rowIndex: -1
16700
16664
  });
16701
16665
  if (renderDefault instanceof Array) {
16702
16666
  for (const childNode of renderDefault) {