@deot/vc 1.0.11 → 1.0.13

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.
@@ -24844,7 +24844,7 @@
24844
24844
  });
24845
24845
  const COMPONENT_NAME$1T = "vc-alert";
24846
24846
  const THEME_MAP = {
24847
- info: ["#5495f6", "#91d5ff", "#e6f7ff"],
24847
+ info: ["#2B72FD", "#91d5ff", "#e6f7ff"],
24848
24848
  success: ["#52c41a", "#b7eb8f", "#f6ffed"],
24849
24849
  error: ["#ed4014", "#ffb08f", "#fbe9e9"],
24850
24850
  warning: ["#ffbf00", "#ffe58f", "#fffbe6"]
@@ -31721,6 +31721,7 @@
31721
31721
  isVisible.value = cursorDown.value;
31722
31722
  };
31723
31723
  const refreshThumb = () => raf(() => {
31724
+ if (!thumb.value) return;
31724
31725
  thumb.value.style[prefixStyle("transform").camel] = `translate${barOptions.value.axis}(${thumbMove.value}px)`;
31725
31726
  });
31726
31727
  const refreshThrottleThumb = throttle$2(refreshThumb, 10);
@@ -35560,7 +35561,7 @@
35560
35561
  color: {
35561
35562
  type: [Object, String],
35562
35563
  default: () => ({
35563
- normal: "#5495f6",
35564
+ normal: "#2B72FD",
35564
35565
  success: "#52c41a",
35565
35566
  error: "#f5222d"
35566
35567
  })
@@ -36513,6 +36514,7 @@
36513
36514
  columnFillSize.value = sizes.map((i) => contentMaxSize.value - i);
36514
36515
  };
36515
36516
  const setFirstItemIndex = () => {
36517
+ if (!wrapper.value) return;
36516
36518
  const position = wrapper.value[K.scrollAxis];
36517
36519
  let item;
36518
36520
  for (let i = 0; i < rebuildData.value.length; i++) {
@@ -36677,6 +36679,7 @@
36677
36679
  await refreshLayout(0, rebuildData.value.length);
36678
36680
  };
36679
36681
  const handleResize = throttle$1(async () => {
36682
+ if (!wrapper.value) return;
36680
36683
  const isNeedRefreshLayout = rebuildData.value.some((i) => !i.isPlaceholder);
36681
36684
  if (isNeedRefreshLayout) {
36682
36685
  const oldFirstItemIndex = firstItemIndex.value;
@@ -36705,6 +36708,8 @@
36705
36708
  });
36706
36709
  if (!originalData.length) {
36707
36710
  rebuildData.value = [];
36711
+ } else {
36712
+ rebuildData.value = originalData.slice();
36708
36713
  }
36709
36714
  offsetPageSize.value = 0;
36710
36715
  await refreshLayout(0, originalData.length);
@@ -37080,88 +37085,65 @@
37080
37085
  };
37081
37086
  }
37082
37087
  });
37083
- const parseHeight = (height) => {
37084
- if (typeof height === "number") {
37085
- return height;
37088
+ const parseHeight = (v) => {
37089
+ if (typeof v === "number") {
37090
+ return v;
37086
37091
  }
37087
- if (height && typeof height === "string") {
37088
- if (/^\d+(?:px)?/.test(height)) {
37089
- return parseInt(height, 10);
37092
+ if (v && typeof v === "string") {
37093
+ if (/^\d+(?:px)?/.test(v)) {
37094
+ return parseInt(v, 10);
37090
37095
  }
37091
37096
  throw new VcError("table", "Invalid Height");
37092
37097
  }
37093
37098
  return null;
37094
37099
  };
37095
- const parseWidth = (width) => {
37096
- if (width !== void 0) {
37097
- width = parseInt(width, 10);
37098
- if (isNaN(width)) {
37099
- width = null;
37100
+ const parseWidth = (v) => {
37101
+ if (typeof v === "number") {
37102
+ return v;
37103
+ }
37104
+ let v1;
37105
+ if (typeof v !== "undefined") {
37106
+ v1 = parseInt(v, 10);
37107
+ if (isNaN(v1)) {
37108
+ v1 = null;
37100
37109
  }
37101
37110
  }
37102
- return width;
37111
+ return v1;
37103
37112
  };
37104
- const parseMinWidth = (minWidth) => {
37105
- if (typeof minWidth !== "undefined") {
37106
- minWidth = parseWidth(minWidth);
37107
- if (isNaN(minWidth)) {
37108
- minWidth = 80;
37113
+ const parseMinWidth = (v) => {
37114
+ if (typeof v === "number") {
37115
+ return v;
37116
+ }
37117
+ let v1;
37118
+ if (typeof v !== "undefined") {
37119
+ v1 = parseWidth(v);
37120
+ if (isNaN(v1)) {
37121
+ v = 80;
37109
37122
  }
37110
37123
  }
37111
- return minWidth;
37124
+ return v1;
37112
37125
  };
37113
- const getRowIdentity = (row, rowKey) => {
37126
+ const getRowValue = (row, primaryKey) => {
37114
37127
  if (row.__KEY__) return row.__KEY__;
37115
37128
  if (!row) throw new VcError("table", "row is required when get row identity");
37116
- if (typeof rowKey === "string") {
37117
- if (!rowKey.includes(".")) {
37118
- return row[rowKey];
37129
+ if (typeof primaryKey === "string") {
37130
+ if (!primaryKey.includes(".")) {
37131
+ return row[primaryKey];
37119
37132
  }
37120
- const key = rowKey.split(".");
37133
+ const key = primaryKey.split(".");
37121
37134
  let current = row;
37122
37135
  for (let i = 0; i < key.length; i++) {
37123
37136
  current = current[key[i]];
37124
37137
  }
37125
37138
  return current;
37126
- } else if (typeof rowKey === "function") {
37127
- return rowKey.call(null, row);
37139
+ } else if (typeof primaryKey === "function") {
37140
+ return primaryKey.call(null, row);
37128
37141
  }
37129
37142
  };
37130
- const walkTreeNode = (root, cb, opts = {}) => {
37131
- const {
37132
- childrenKey = "children",
37133
- lazyKey = "hasChildren",
37134
- level: baseLevel = 0
37135
- } = opts;
37136
- const isNil = (array) => !(Array.isArray(array) && array.length);
37137
- function _walker(parent, children, level) {
37138
- cb(parent, children, level);
37139
- children.forEach((item) => {
37140
- if (item[lazyKey]) {
37141
- cb(item, null, level + 1);
37142
- return;
37143
- }
37144
- const $children = item[childrenKey];
37145
- if (!isNil($children)) {
37146
- _walker(item, $children, level + 1);
37147
- }
37148
- });
37149
- }
37150
- root.forEach((item) => {
37151
- if (item[lazyKey]) {
37152
- cb(item, null, baseLevel);
37153
- return;
37154
- }
37155
- const children = item[childrenKey];
37156
- if (!isNil(children)) {
37157
- _walker(item, children, baseLevel);
37158
- }
37159
- });
37160
- };
37161
- const getKeysMap = (array = [], rowKey) => {
37143
+ const getValuesMap = (array = [], primaryKey) => {
37162
37144
  const arrayMap = {};
37163
37145
  array.forEach((row, index) => {
37164
- arrayMap[getRowIdentity(row, rowKey)] = { row, index };
37146
+ arrayMap[getRowValue(row, primaryKey)] = { row, index };
37165
37147
  });
37166
37148
  return arrayMap;
37167
37149
  };
@@ -37174,23 +37156,74 @@
37174
37156
  });
37175
37157
  return column;
37176
37158
  };
37177
- const getColumnByCell = (table, cell) => {
37159
+ const getColumnByCell = (columns, cell) => {
37178
37160
  const matches = (cell.className || "").match(/vc-table_[^\s]+/gm);
37179
37161
  if (matches) {
37180
- return getColumnById(table, matches[0]);
37162
+ return getColumnById(columns, matches[0]);
37181
37163
  }
37182
37164
  return null;
37183
37165
  };
37184
- const getCell = (event2) => {
37185
- let cell = event2.target;
37166
+ const getCell = (e) => {
37167
+ let cell = e.target;
37186
37168
  while (cell && cell.tagName.toUpperCase() !== "HTML") {
37187
- if (cell.tagName.toUpperCase() === "TD") {
37169
+ if (cell.classList.contains("vc-table__td")) {
37188
37170
  return cell;
37189
37171
  }
37190
37172
  cell = cell.parentNode;
37191
37173
  }
37192
37174
  return null;
37193
37175
  };
37176
+ const getAllColumns = (columns) => {
37177
+ const result = [];
37178
+ columns.forEach((column) => {
37179
+ if (column.children) {
37180
+ result.push(column);
37181
+ result.push(...getAllColumns(column.children));
37182
+ } else {
37183
+ result.push(column);
37184
+ }
37185
+ });
37186
+ return result;
37187
+ };
37188
+ const columnsToRowsEffect = (v) => {
37189
+ let maxLevel = 1;
37190
+ const traverse = (column, parent) => {
37191
+ if (parent) {
37192
+ column.level = parent.level + 1;
37193
+ if (maxLevel < column.level) {
37194
+ maxLevel = column.level;
37195
+ }
37196
+ }
37197
+ if (column.children) {
37198
+ let colSpan = 0;
37199
+ column.children.forEach((subColumn) => {
37200
+ traverse(subColumn, column);
37201
+ colSpan += subColumn.colSpan;
37202
+ });
37203
+ column.colSpan = colSpan;
37204
+ } else {
37205
+ column.colSpan = 1;
37206
+ }
37207
+ };
37208
+ v.forEach((column) => {
37209
+ column.level = 1;
37210
+ traverse(column);
37211
+ });
37212
+ const rows = [];
37213
+ for (let i = 0; i < maxLevel; i++) {
37214
+ rows.push([]);
37215
+ }
37216
+ const allColumns = getAllColumns(v);
37217
+ allColumns.forEach((column) => {
37218
+ if (!column.children) {
37219
+ column.rowSpan = maxLevel - column.level + 1;
37220
+ } else {
37221
+ column.rowSpan = 1;
37222
+ }
37223
+ rows[column.level - 1].push(column);
37224
+ });
37225
+ return rows;
37226
+ };
37194
37227
  const flattenData = (data, opts = {}) => {
37195
37228
  const result = [];
37196
37229
  data.forEach((item) => {
@@ -37203,29 +37236,51 @@
37203
37236
  });
37204
37237
  return result;
37205
37238
  };
37239
+ const walkTreeNode = (root, cb, opts = {}) => {
37240
+ const {
37241
+ childrenKey = "children",
37242
+ lazyKey = "hasChildren",
37243
+ level: baseLevel = 0
37244
+ } = opts;
37245
+ const isNil = (array) => !(Array.isArray(array) && array.length);
37246
+ function _walker(parent, children, level) {
37247
+ cb(parent, children, level);
37248
+ children.forEach((item) => {
37249
+ if (item[lazyKey]) {
37250
+ cb(item, null, level + 1);
37251
+ return;
37252
+ }
37253
+ const $children = item[childrenKey];
37254
+ if (!isNil($children)) {
37255
+ _walker(item, $children, level + 1);
37256
+ }
37257
+ });
37258
+ }
37259
+ root.forEach((item) => {
37260
+ if (item[lazyKey]) {
37261
+ cb(item, null, baseLevel);
37262
+ return;
37263
+ }
37264
+ const children = item[childrenKey];
37265
+ if (!isNil(children)) {
37266
+ _walker(item, children, baseLevel);
37267
+ }
37268
+ });
37269
+ };
37206
37270
  class BaseWatcher {
37207
37271
  states = vue.reactive({
37208
37272
  // 渲染的数据来源,是对 table 中的 data 过滤排序后的结果
37209
37273
  _data: [],
37210
37274
  data: [],
37211
37275
  list: [],
37212
- // 是否包含固定列
37213
- isComplex: false,
37214
- // 列
37276
+ // 表头数据
37277
+ headerRows: [],
37278
+ // 列 动态收集vc-table-column中的columnConfig
37215
37279
  _columns: [],
37216
- // 动态收集vc-table-column中的columnConfig
37217
37280
  originColumns: [],
37218
- // leftFixedColumns, notFixedColumns, rightFixedColumns
37219
- columns: [],
37220
- // 包括 leftFixedLeafColumns,leafColumns,rightFixedLeafColumns
37281
+ notFixedColumns: [],
37221
37282
  leftFixedColumns: [],
37222
37283
  rightFixedColumns: [],
37223
- leafColumns: [],
37224
- leftFixedLeafColumns: [],
37225
- rightFixedLeafColumns: [],
37226
- leafColumnsLength: 0,
37227
- leftFixedLeafColumnsLength: 0,
37228
- rightFixedLeafColumnsLength: 0,
37229
37284
  // 选择
37230
37285
  isAllSelected: false,
37231
37286
  selection: [],
@@ -37247,7 +37302,17 @@
37247
37302
  treeLazyData: [],
37248
37303
  // 源数据展开
37249
37304
  treeLazyColumnIdentifier: "hasChildren",
37250
- treeChildrenColumnName: "children"
37305
+ treeChildrenColumnName: "children",
37306
+ // compputeds
37307
+ isComplex: vue.computed(() => this.states.leftFixedColumns.length > 0 || this.states.rightFixedColumns.length > 0),
37308
+ isGroup: vue.computed(() => this.states.columns.length > this.states.originColumns.length),
37309
+ columns: vue.computed(() => lodashExports.concat(this.states.leftFixedLeafColumns, this.states.leafColumns, this.states.rightFixedLeafColumns)),
37310
+ leafColumns: vue.computed(() => flattenData(this.states.notFixedColumns)),
37311
+ leftFixedLeafColumns: vue.computed(() => flattenData(this.states.leftFixedColumns)),
37312
+ rightFixedLeafColumns: vue.computed(() => flattenData(this.states.rightFixedColumns)),
37313
+ leafColumnsLength: vue.computed(() => this.states.leafColumns.length),
37314
+ leftFixedLeafColumnsLength: vue.computed(() => this.states.leftFixedLeafColumns.length),
37315
+ rightFixedLeafColumnsLength: vue.computed(() => this.states.rightFixedLeafColumns.length)
37251
37316
  });
37252
37317
  }
37253
37318
  class Expand {
@@ -37257,14 +37322,14 @@
37257
37322
  }
37258
37323
  update() {
37259
37324
  const store = this.store;
37260
- const { rowKey, defaultExpandAll } = this.store.table.props;
37325
+ const { primaryKey, defaultExpandAll } = this.store.table.props;
37261
37326
  const { data = [], expandRows } = store.states;
37262
37327
  if (defaultExpandAll) {
37263
37328
  store.states.expandRows = data.slice();
37264
- } else if (rowKey) {
37265
- const expandRowsMap = getKeysMap(expandRows, rowKey);
37329
+ } else if (primaryKey) {
37330
+ const expandRowsMap = getValuesMap(expandRows, primaryKey);
37266
37331
  store.states.expandRows = data.reduce((prev, row) => {
37267
- const rowId = getRowIdentity(row, rowKey);
37332
+ const rowId = getRowValue(row, primaryKey);
37268
37333
  const rowInfo = expandRowsMap[rowId];
37269
37334
  if (rowInfo) {
37270
37335
  prev.push(row);
@@ -37286,10 +37351,10 @@
37286
37351
  }
37287
37352
  reset(ids) {
37288
37353
  const store = this.store;
37289
- store.checkRowKey();
37290
- const { rowKey } = store.table.props;
37354
+ store.checkPrimaryKey();
37355
+ const { primaryKey } = store.table.props;
37291
37356
  const { data } = store.states;
37292
- const keysMap = getKeysMap(data, rowKey);
37357
+ const keysMap = getValuesMap(data, primaryKey);
37293
37358
  store.states.expandRows = ids.reduce((prev, cur) => {
37294
37359
  const info2 = keysMap[cur];
37295
37360
  if (info2) {
@@ -37299,11 +37364,11 @@
37299
37364
  }, []);
37300
37365
  }
37301
37366
  isExpanded(row) {
37302
- const { rowKey } = this.store.table.props;
37367
+ const { primaryKey } = this.store.table.props;
37303
37368
  const { expandRows = [] } = this.store.states;
37304
- if (rowKey) {
37305
- const expandMap = getKeysMap(expandRows, rowKey);
37306
- return !!expandMap[getRowIdentity(row, rowKey)];
37369
+ if (primaryKey) {
37370
+ const expandMap = getValuesMap(expandRows, primaryKey);
37371
+ return !!expandMap[getRowValue(row, primaryKey)];
37307
37372
  }
37308
37373
  return expandRows.indexOf(row) !== -1;
37309
37374
  }
@@ -37315,22 +37380,22 @@
37315
37380
  }
37316
37381
  reset(id) {
37317
37382
  const store = this.store;
37318
- const { rowKey } = store.table.props;
37319
- store.checkRowKey();
37383
+ const { primaryKey } = store.table.props;
37384
+ store.checkPrimaryKey();
37320
37385
  const { data = [] } = store.states;
37321
- const currentRow = data.find((item) => getRowIdentity(item, rowKey) === id);
37386
+ const currentRow = data.find((item) => getRowValue(item, primaryKey) === id);
37322
37387
  store.states.currentRow = currentRow || null;
37323
37388
  }
37324
37389
  update() {
37325
37390
  const store = this.store;
37326
- const { rowKey } = store.table.props;
37391
+ const { primaryKey } = store.table.props;
37327
37392
  const { data = [], currentRow } = store.states;
37328
37393
  const oldCurrentRow = currentRow;
37329
37394
  if (oldCurrentRow && !data.includes(oldCurrentRow)) {
37330
37395
  let newCurrentRow = null;
37331
- if (rowKey) {
37396
+ if (primaryKey) {
37332
37397
  newCurrentRow = data.find((item) => {
37333
- return getRowIdentity(item, rowKey) === getRowIdentity(oldCurrentRow, rowKey);
37398
+ return getRowValue(item, primaryKey) === getRowValue(oldCurrentRow, primaryKey);
37334
37399
  });
37335
37400
  }
37336
37401
  store.states.currentRow = newCurrentRow;
@@ -37348,8 +37413,8 @@
37348
37413
  * { id: { level, children } }
37349
37414
  */
37350
37415
  normalizedData = vue.computed(() => {
37351
- const { rowKey } = this.store.table.props;
37352
- if (!rowKey) return {};
37416
+ const { primaryKey } = this.store.table.props;
37417
+ if (!primaryKey) return {};
37353
37418
  return this.normalize(this.store.states.data || []);
37354
37419
  });
37355
37420
  /**
@@ -37357,7 +37422,7 @@
37357
37422
  * { id: { children } }
37358
37423
  */
37359
37424
  normalizedLazyNode = vue.computed(() => {
37360
- const { rowKey } = this.store.table.props;
37425
+ const { primaryKey } = this.store.table.props;
37361
37426
  const { treelazyNodeMap, treeLazyColumnIdentifier, treeChildrenColumnName } = this.store.states;
37362
37427
  const keys = Object.keys(treelazyNodeMap);
37363
37428
  const res = {};
@@ -37366,7 +37431,7 @@
37366
37431
  if (treelazyNodeMap[key].length) {
37367
37432
  const item = { children: [] };
37368
37433
  treelazyNodeMap[key].forEach((row) => {
37369
- const id = getRowIdentity(row, rowKey);
37434
+ const id = getRowValue(row, primaryKey);
37370
37435
  item.children.push(id);
37371
37436
  const hasChildren = row[treeLazyColumnIdentifier] || row[treeChildrenColumnName] && row[treeChildrenColumnName].length === 0;
37372
37437
  if (hasChildren && !res[id]) {
@@ -37386,16 +37451,16 @@
37386
37451
  );
37387
37452
  }
37388
37453
  normalize(data) {
37389
- const { rowKey } = this.store.table.props;
37454
+ const { primaryKey } = this.store.table.props;
37390
37455
  const { treeChildrenColumnName, treeLazyColumnIdentifier, treeLazy } = this.store.states;
37391
37456
  const res = {};
37392
37457
  walkTreeNode(
37393
37458
  data,
37394
37459
  (parent, children, level) => {
37395
- const parentId = getRowIdentity(parent, rowKey);
37460
+ const parentId = getRowValue(parent, primaryKey);
37396
37461
  if (Array.isArray(children)) {
37397
37462
  res[parentId] = {
37398
- children: children.map((row) => getRowIdentity(row, rowKey)),
37463
+ children: children.map((row) => getRowValue(row, primaryKey)),
37399
37464
  level
37400
37465
  };
37401
37466
  } else if (treeLazy) {
@@ -37415,7 +37480,7 @@
37415
37480
  }
37416
37481
  // 获取当前展开最大的level
37417
37482
  getMaxLevel() {
37418
- const { rowKey } = this.store.table.props;
37483
+ const { primaryKey } = this.store.table.props;
37419
37484
  const { data, treeData } = this.store.states;
37420
37485
  const levels = data.map((item) => {
37421
37486
  const traverse = (source) => {
@@ -37426,7 +37491,7 @@
37426
37491
  return source.level;
37427
37492
  }
37428
37493
  };
37429
- const id = getRowIdentity(item, rowKey);
37494
+ const id = getRowValue(item, primaryKey);
37430
37495
  return traverse(treeData[id]);
37431
37496
  });
37432
37497
  return max$2(levels) || 0;
@@ -37488,10 +37553,10 @@
37488
37553
  this.update();
37489
37554
  }
37490
37555
  toggle(row, expanded) {
37491
- this.store.checkRowKey();
37492
- const { rowKey } = this.store.table.props;
37556
+ this.store.checkPrimaryKey();
37557
+ const { primaryKey } = this.store.table.props;
37493
37558
  const { treeData } = this.store.states;
37494
- const id = getRowIdentity(row, rowKey);
37559
+ const id = getRowValue(row, primaryKey);
37495
37560
  const data = id && treeData[id];
37496
37561
  if (id && data && "expanded" in data) {
37497
37562
  const oldExpanded = data.expanded;
@@ -37504,10 +37569,10 @@
37504
37569
  }
37505
37570
  }
37506
37571
  loadOrToggle(row) {
37507
- this.store.checkRowKey();
37508
- const { rowKey } = this.store.table.props;
37572
+ this.store.checkPrimaryKey();
37573
+ const { primaryKey } = this.store.table.props;
37509
37574
  const { treeLazy, treeData } = this.store.states;
37510
- const id = getRowIdentity(row, rowKey);
37575
+ const id = getRowValue(row, primaryKey);
37511
37576
  const data = treeData[id];
37512
37577
  if (treeLazy && data && "loaded" in data && !data.loaded) {
37513
37578
  this.loadData(row, id, data);
@@ -37516,9 +37581,9 @@
37516
37581
  }
37517
37582
  }
37518
37583
  loadData(row, key, treeNode) {
37519
- this.store.checkRowKey();
37584
+ this.store.checkPrimaryKey();
37520
37585
  const { table } = this.store;
37521
- const { rowKey } = table.props;
37586
+ const { primaryKey } = table.props;
37522
37587
  const { treelazyNodeMap, treeData, treeChildrenColumnName, treeLazyColumnIdentifier } = this.store.states;
37523
37588
  if (table.props.loadExpand && !treeData[key].loaded) {
37524
37589
  this.store.states.treeData[key].loading = true;
@@ -37533,7 +37598,7 @@
37533
37598
  walkTreeNode(
37534
37599
  data,
37535
37600
  (parent, _, level) => {
37536
- const id = getRowIdentity(parent, rowKey);
37601
+ const id = getRowValue(parent, primaryKey);
37537
37602
  Object.defineProperty(parent, "__KEY__", {
37538
37603
  value: `${level}__${id}`,
37539
37604
  writable: false
@@ -37602,27 +37667,13 @@
37602
37667
  if (!this.store) {
37603
37668
  throw new VcError("table", "Table Layout 必须包含store实例");
37604
37669
  }
37605
- this.updateScroller = this.updateScroller.bind(this);
37606
- this.updateColumns = this.updateColumns.bind(this);
37607
- vue.onMounted(() => {
37608
- this.updateColumns();
37609
- this.updateScroller();
37610
- });
37611
- let __updated__;
37612
- vue.onUpdated(() => {
37613
- if (__updated__) return;
37614
- this.updateColumns();
37615
- this.updateScroller();
37616
- __updated__ = true;
37617
- });
37618
37670
  }
37619
37671
  updateScrollY() {
37620
37672
  const { height, bodyHeight } = this.states;
37621
37673
  if (height === null || bodyHeight === null) return;
37622
- const scroller = this.table.exposed.scroller.value;
37623
- if (this.table.vnode.el && scroller) {
37624
- const body = scroller.$el.querySelector(".vc-table__body");
37625
- this.states.scrollY = body.offsetHeight > bodyHeight;
37674
+ const bodyYWrapper = this.table.exposed.bodyYWrapper.value;
37675
+ if (this.table.vnode.el && bodyYWrapper) {
37676
+ this.states.scrollY = bodyYWrapper.offsetHeight > bodyHeight;
37626
37677
  }
37627
37678
  }
37628
37679
  setHeight(value, prop = "height") {
@@ -37639,18 +37690,6 @@
37639
37690
  setMaxHeight(value) {
37640
37691
  this.setHeight(value, "max-height");
37641
37692
  }
37642
- getFlattenColumns() {
37643
- const flattenColumns = [];
37644
- const columns = this.store.states.columns;
37645
- columns.forEach((column) => {
37646
- if (column.isColumnGroup) {
37647
- flattenColumns.push(...column.columns);
37648
- } else {
37649
- flattenColumns.push(column);
37650
- }
37651
- });
37652
- return flattenColumns;
37653
- }
37654
37693
  updateElsHeight() {
37655
37694
  if (!this.table.exposed.isReady.value) return vue.nextTick(() => this.updateElsHeight());
37656
37695
  const table = this.table.exposed;
@@ -37673,13 +37712,12 @@
37673
37712
  this.states.bodyHeight = tableHeight - headerHeight - footerHeight + (footerWrapper ? 1 : 0);
37674
37713
  }
37675
37714
  this.updateScrollY();
37676
- this.updateScroller();
37677
37715
  }
37678
37716
  updateColumnsWidth() {
37679
37717
  if (IS_SERVER$3) return;
37680
37718
  const bodyWidth = this.table.vnode.el.clientWidth;
37681
37719
  let bodyMinWidth = 0;
37682
- const flattenColumns = this.getFlattenColumns();
37720
+ const flattenColumns = this.store.states.columns;
37683
37721
  const flexColumns = flattenColumns.filter((column) => typeof column.width !== "number");
37684
37722
  const { fit } = this.table.props;
37685
37723
  if (flexColumns.length > 0 && fit) {
@@ -37705,7 +37743,7 @@
37705
37743
  }
37706
37744
  } else {
37707
37745
  this.states.scrollX = true;
37708
- flexColumns.forEach(function(column) {
37746
+ flexColumns.forEach((column) => {
37709
37747
  column.realWidth = column.width || column.minWidth;
37710
37748
  });
37711
37749
  }
@@ -37739,12 +37777,6 @@
37739
37777
  });
37740
37778
  this.states.rightFixedWidth = rightFixedWidth;
37741
37779
  }
37742
- this.updateColumns();
37743
- }
37744
- // v2.x中的 notifyObservers
37745
- updateColumns() {
37746
- }
37747
- updateScroller() {
37748
37780
  }
37749
37781
  }
37750
37782
  class Store extends BaseWatcher {
@@ -37753,7 +37785,7 @@
37753
37785
  expand;
37754
37786
  tree;
37755
37787
  layout;
37756
- flattenData = vue.computed(() => {
37788
+ flatData = vue.computed(() => {
37757
37789
  if (this.table.props.expandSelectable) {
37758
37790
  return lodashExports.concat(
37759
37791
  flattenData(this.states.data, { parent: true, cascader: true }),
@@ -37784,17 +37816,24 @@
37784
37816
  const dataInstanceChanged = this.states._data !== data;
37785
37817
  this.states._data = data;
37786
37818
  this.states.data = data;
37819
+ const caches = /* @__PURE__ */ new Map();
37820
+ this.states.list.forEach((item) => {
37821
+ item.rows.forEach((row) => {
37822
+ caches.set(row.data, row);
37823
+ });
37824
+ });
37787
37825
  this.states.list = data.reduce((pre, row, index) => {
37826
+ const cache = caches.get(row) || { heightMap: {} };
37788
37827
  pre.push({
37789
37828
  rows: [
37790
37829
  {
37791
37830
  index,
37792
37831
  data: row,
37793
- height: "",
37832
+ height: cache.height || "",
37794
37833
  heightMap: {
37795
- left: "",
37796
- main: "",
37797
- right: ""
37834
+ left: cache.heightMap.left || "",
37835
+ main: cache.heightMap.main || "",
37836
+ right: cache.heightMap.right || ""
37798
37837
  }
37799
37838
  }
37800
37839
  ],
@@ -37802,6 +37841,7 @@
37802
37841
  });
37803
37842
  return pre;
37804
37843
  }, []);
37844
+ caches.clear();
37805
37845
  this.current.update();
37806
37846
  this.expand.update();
37807
37847
  if (!this.states.reserveSelection) {
@@ -37811,7 +37851,7 @@
37811
37851
  this.cleanSelection();
37812
37852
  }
37813
37853
  } else {
37814
- this.checkRowKey();
37854
+ this.checkPrimaryKey();
37815
37855
  this.updateSelectionByRowKey();
37816
37856
  }
37817
37857
  this.updateAllSelected();
@@ -37833,10 +37873,10 @@
37833
37873
  }
37834
37874
  }
37835
37875
  /**
37836
- * 检查 rowKey 是否存在
37876
+ * 检查 primaryKey 是否存在
37837
37877
  */
37838
- checkRowKey() {
37839
- const { rowKey } = this.table.props;
37878
+ checkPrimaryKey() {
37879
+ const { primaryKey } = this.table.props;
37840
37880
  }
37841
37881
  /**
37842
37882
  * states
@@ -37897,22 +37937,20 @@
37897
37937
  updateColumns() {
37898
37938
  const { states } = this;
37899
37939
  const _columns = states._columns || [];
37900
- states.leftFixedColumns = _columns.filter((column) => column.fixed === true || column.fixed === "left");
37901
- states.rightFixedColumns = _columns.filter((column) => column.fixed === "right");
37902
- if (states.leftFixedColumns.length > 0 && _columns[0] && _columns[0].type === "selection" && !_columns[0].fixed) {
37940
+ const leftFixedColumns = _columns.filter((column) => column.fixed === true || column.fixed === "left");
37941
+ const rightFixedColumns = _columns.filter((column) => column.fixed === "right");
37942
+ if (leftFixedColumns.length > 0 && _columns[0] && _columns[0].type === "selection" && !_columns[0].fixed) {
37903
37943
  _columns[0].fixed = true;
37904
- states.leftFixedColumns.unshift(_columns[0]);
37944
+ leftFixedColumns.unshift(_columns[0]);
37905
37945
  }
37906
37946
  const notFixedColumns = _columns.filter((column) => !column.fixed);
37907
- states.originColumns = lodashExports.concat(states.leftFixedColumns, notFixedColumns, states.rightFixedColumns);
37908
- const leafColumns = flattenData(notFixedColumns);
37909
- const leftFixedLeafColumns = flattenData(states.leftFixedColumns);
37910
- const rightFixedLeafColumns = flattenData(states.rightFixedColumns);
37911
- states.leafColumnsLength = leafColumns.length;
37912
- states.leftFixedLeafColumnsLength = leftFixedLeafColumns.length;
37913
- states.rightFixedLeafColumnsLength = rightFixedLeafColumns.length;
37914
- states.columns = lodashExports.concat(leftFixedLeafColumns, leafColumns, rightFixedLeafColumns);
37915
- states.isComplex = states.leftFixedColumns.length > 0 || states.rightFixedColumns.length > 0;
37947
+ const originColumns = lodashExports.concat(leftFixedColumns, notFixedColumns, rightFixedColumns);
37948
+ const headerRows = columnsToRowsEffect(originColumns);
37949
+ states.leftFixedColumns = leftFixedColumns;
37950
+ states.notFixedColumns = notFixedColumns;
37951
+ states.rightFixedColumns = rightFixedColumns;
37952
+ states.originColumns = originColumns;
37953
+ states.headerRows = headerRows;
37916
37954
  }
37917
37955
  // 选择
37918
37956
  isSelected(row) {
@@ -37936,13 +37974,13 @@
37936
37974
  * 清理选择
37937
37975
  */
37938
37976
  cleanSelection() {
37939
- const { rowKey } = this.table.props;
37940
- const { selection = [] } = this.states;
37977
+ const { primaryKey } = this.table.props;
37978
+ const { selection = [], data } = this.states;
37941
37979
  let deleted;
37942
- if (rowKey) {
37980
+ if (primaryKey) {
37943
37981
  deleted = [];
37944
- const selectedMap = getKeysMap(selection, rowKey);
37945
- const dataMap = getKeysMap(selection, rowKey);
37982
+ const selectedMap = getValuesMap(selection, primaryKey);
37983
+ const dataMap = getValuesMap(data, primaryKey);
37946
37984
  for (const key in selectedMap) {
37947
37985
  if (hasOwn$1(selectedMap, key) && !dataMap[key]) {
37948
37986
  deleted.push(selectedMap[key].row);
@@ -37950,7 +37988,7 @@
37950
37988
  }
37951
37989
  } else {
37952
37990
  deleted = selection.filter((item) => {
37953
- return !this.flattenData.value.includes(item);
37991
+ return !this.flatData.value.includes(item);
37954
37992
  });
37955
37993
  }
37956
37994
  deleted.forEach((deletedItem) => {
@@ -38011,7 +38049,7 @@
38011
38049
  const value = indeterminate ? !isAllSelected : !(isAllSelected || selection.length);
38012
38050
  this.states.isAllSelected = value;
38013
38051
  let selectionChanged = false;
38014
- this.flattenData.value.forEach((row, index) => {
38052
+ this.flatData.value.forEach((row, index) => {
38015
38053
  if (selectable) {
38016
38054
  if (selectable.call(null, row, index) && this.toggleRowStatus(selection, row, value)) {
38017
38055
  selectionChanged = true;
@@ -38042,11 +38080,11 @@
38042
38080
  this.tree.expand(val);
38043
38081
  }
38044
38082
  updateSelectionByRowKey() {
38045
- const { rowKey } = this.table.props;
38083
+ const { primaryKey } = this.table.props;
38046
38084
  const { selection } = this.states;
38047
- const selectedMap = getKeysMap(selection, rowKey);
38048
- this.states.selection = this.flattenData.value.reduce((prev, row) => {
38049
- const rowId = getRowIdentity(row, rowKey);
38085
+ const selectedMap = getValuesMap(selection, primaryKey);
38086
+ this.states.selection = this.flatData.value.reduce((prev, row) => {
38087
+ const rowId = getRowValue(row, primaryKey);
38050
38088
  const rowInfo = selectedMap[rowId];
38051
38089
  if (rowInfo) {
38052
38090
  prev.push(row);
@@ -38062,7 +38100,7 @@
38062
38100
  }
38063
38101
  let isAllSelected = true;
38064
38102
  let selectedCount = 0;
38065
- const temp = this.flattenData.value;
38103
+ const temp = this.flatData.value;
38066
38104
  for (let i = 0, j = temp.length; i < j; i++) {
38067
38105
  const row = temp[i];
38068
38106
  const isRowSelectable = selectable && selectable.call(null, row, i);
@@ -38113,8 +38151,10 @@
38113
38151
  const NormalList = /* @__PURE__ */ vue.defineComponent({
38114
38152
  name: COMPONENT_NAME$h,
38115
38153
  props: {
38116
- data: Array,
38117
- default: () => []
38154
+ data: {
38155
+ type: Array,
38156
+ default: () => []
38157
+ }
38118
38158
  },
38119
38159
  emits: ["row-resize"],
38120
38160
  setup(props2, {
@@ -38155,7 +38195,7 @@
38155
38195
  expose
38156
38196
  }) {
38157
38197
  const instance = vue.getCurrentInstance();
38158
- const table = getInstance$1("table", "tableId");
38198
+ const table = vue.inject("vc-table");
38159
38199
  const states = useStates({
38160
38200
  data: "data",
38161
38201
  list: "list",
@@ -38172,6 +38212,7 @@
38172
38212
  type
38173
38213
  }) => type === "default")
38174
38214
  });
38215
+ const wrapper = vue.ref();
38175
38216
  vue.watch(() => props2.store.states.hoverRowIndex, (v, oldV) => {
38176
38217
  if (!props2.store.states.isComplex || IS_SERVER$3) return;
38177
38218
  raf(() => {
@@ -38182,12 +38223,12 @@
38182
38223
  newRow && addClass(newRow, "hover-row");
38183
38224
  });
38184
38225
  });
38185
- const getKeyOfRow = (row, index) => {
38226
+ const getValueOfRow = (row, index) => {
38186
38227
  const {
38187
- rowKey
38228
+ primaryKey
38188
38229
  } = table.props;
38189
- if (rowKey) {
38190
- return getRowIdentity(row, rowKey);
38230
+ if (primaryKey) {
38231
+ return getRowValue(row, primaryKey);
38191
38232
  }
38192
38233
  return index;
38193
38234
  };
@@ -38252,7 +38293,7 @@
38252
38293
  return cellStyle;
38253
38294
  };
38254
38295
  const getCellClass = (rowIndex, columnIndex, row, column) => {
38255
- const classes = [column.align, column.className];
38296
+ const classes = [column.realAlign, column.className];
38256
38297
  if (isColumnHidden(columnIndex)) {
38257
38298
  classes.push("is-hidden");
38258
38299
  }
@@ -38278,7 +38319,7 @@
38278
38319
  column,
38279
38320
  row
38280
38321
  };
38281
- table.exposed.hoverState.value = hoverState;
38322
+ table.hoverState.value = hoverState;
38282
38323
  table.emit("cell-mouse-enter", hoverState.row, hoverState.column, hoverState.cell, e);
38283
38324
  }
38284
38325
  const cellChild = e.target.querySelector(".vc-table__cell");
@@ -38307,8 +38348,8 @@
38307
38348
  const handleCellMouseLeave = (e) => {
38308
38349
  const cell = getCell(e);
38309
38350
  if (!cell) return;
38310
- const oldHoverState = table.exposed.hoverState.value || {};
38311
- table.emit("cell-mouse-leave", oldHoverState.row, oldHoverState.column, oldHoverState.cell, event);
38351
+ const oldHoverState = table.hoverState.value || {};
38352
+ table.emit("cell-mouse-leave", oldHoverState.row, oldHoverState.column, oldHoverState.cell, e);
38312
38353
  };
38313
38354
  const handleMouseEnter = debounce$1((index) => {
38314
38355
  props2.store.setHoverRow(index);
@@ -38344,7 +38385,8 @@
38344
38385
  const {
38345
38386
  columns
38346
38387
  } = states;
38347
- const key = getKeyOfRow(row, rowIndex);
38388
+ const key = getValueOfRow(row, rowIndex);
38389
+ const selected = props2.store.isSelected(row);
38348
38390
  return vue.createVNode("div", {
38349
38391
  "key": key,
38350
38392
  "class": [getRowClass(row, rowIndex), "vc-table__tr"],
@@ -38365,10 +38407,12 @@
38365
38407
  };
38366
38408
  if (columnsHidden.value[columnIndex]) {
38367
38409
  return vue.createVNode("div", {
38410
+ "key": column.id,
38368
38411
  "style": [sizeStyle]
38369
38412
  }, null);
38370
38413
  }
38371
38414
  return vue.createVNode("div", {
38415
+ "key": column.id,
38372
38416
  "style": [getCellStyle(rowIndex, columnIndex, row, column), sizeStyle],
38373
38417
  "class": [getCellClass(rowIndex, columnIndex, row, column), "vc-table__td"],
38374
38418
  "onMouseenter": (e) => handleCellMouseEnter(e, row),
@@ -38378,7 +38422,8 @@
38378
38422
  column,
38379
38423
  rowIndex,
38380
38424
  columnIndex,
38381
- store: props2.store
38425
+ store: props2.store,
38426
+ selected
38382
38427
  })]);
38383
38428
  })]);
38384
38429
  };
@@ -38408,13 +38453,12 @@
38408
38453
  }
38409
38454
  });
38410
38455
  };
38411
- const wrapper = vue.ref();
38412
38456
  expose({
38413
38457
  wrapper,
38414
38458
  getRootElement: () => instance.vnode.el
38415
38459
  });
38460
+ const layout = table.layout;
38416
38461
  return () => {
38417
- const layout = table.exposed.layout;
38418
38462
  return vue.createVNode("div", {
38419
38463
  "class": "vc-table__body"
38420
38464
  }, [table.props.height ? vue.createVNode(RecycleList, {
@@ -38423,7 +38467,7 @@
38423
38467
  "disabled": true,
38424
38468
  "class": "vc-table__tbody",
38425
38469
  "scrollerOptions": {
38426
- barTo: `.${table.exposed.tableId}`,
38470
+ barTo: `.${table.tableId}`,
38427
38471
  native: false,
38428
38472
  always: false,
38429
38473
  showBar: !props2.fixed,
@@ -38459,57 +38503,6 @@
38459
38503
  });
38460
38504
  const TableSort = "div";
38461
38505
  const TableFilter = "div";
38462
- const getAllColumns = (columns) => {
38463
- const result = [];
38464
- columns.forEach((column) => {
38465
- if (column.children) {
38466
- result.push(column);
38467
- result.push(...getAllColumns(column.children));
38468
- } else {
38469
- result.push(column);
38470
- }
38471
- });
38472
- return result;
38473
- };
38474
- const convertToRows = (originColumns) => {
38475
- let maxLevel = 1;
38476
- const traverse = (column, parent) => {
38477
- if (parent) {
38478
- column.level = parent.level + 1;
38479
- if (maxLevel < column.level) {
38480
- maxLevel = column.level;
38481
- }
38482
- }
38483
- if (column.children) {
38484
- let colSpan = 0;
38485
- column.children.forEach((subColumn) => {
38486
- traverse(subColumn, column);
38487
- colSpan += subColumn.colSpan;
38488
- });
38489
- column.colSpan = colSpan;
38490
- } else {
38491
- column.colSpan = 1;
38492
- }
38493
- };
38494
- originColumns.forEach((column) => {
38495
- column.level = 1;
38496
- traverse(column);
38497
- });
38498
- const rows = [];
38499
- for (let i = 0; i < maxLevel; i++) {
38500
- rows.push([]);
38501
- }
38502
- const allColumns = getAllColumns(originColumns);
38503
- allColumns.forEach((column) => {
38504
- if (!column.children) {
38505
- column.rowSpan = maxLevel - column.level + 1;
38506
- } else {
38507
- column.rowSpan = 1;
38508
- }
38509
- rows[column.level - 1].push(column);
38510
- });
38511
- return rows;
38512
- };
38513
38506
  const TableHeader = /* @__PURE__ */ vue.defineComponent({
38514
38507
  name: "vc-table-header",
38515
38508
  props: {
@@ -38526,7 +38519,7 @@
38526
38519
  }
38527
38520
  },
38528
38521
  setup(props2) {
38529
- const table = getInstance$1("table", "tableId");
38522
+ const table = vue.inject("vc-table");
38530
38523
  const instance = vue.getCurrentInstance();
38531
38524
  const draggingColumn = vue.ref(null);
38532
38525
  const dragging = vue.ref(false);
@@ -38536,16 +38529,18 @@
38536
38529
  isAllSelected: "isAllSelected",
38537
38530
  leftFixedLeafCount: "leftFixedLeafColumnsLength",
38538
38531
  rightFixedLeafCount: "rightFixedLeafColumnsLength",
38532
+ isGroup: "isGroup",
38533
+ headerRows: "headerRows",
38539
38534
  columnsCount: ($states) => $states.columns.length,
38540
38535
  leftFixedCount: ($states) => $states.leftFixedColumns.length,
38541
38536
  rightFixedCount: ($states) => $states.rightFixedColumns.length
38542
38537
  });
38543
- const isCellHidden = (index, columns) => {
38538
+ const isColumnHidden = (index) => {
38544
38539
  let start = 0;
38545
38540
  for (let i = 0; i < index; i++) {
38546
- start += columns[i].colSpan;
38541
+ start += states.columns[i].colSpan;
38547
38542
  }
38548
- const after = start + columns[index].colSpan - 1;
38543
+ const after = start + states.columns[index].colSpan - 1;
38549
38544
  if (props2.fixed === true || props2.fixed === "left") {
38550
38545
  return after >= states.leftFixedLeafCount;
38551
38546
  } else if (props2.fixed === "right") {
@@ -38554,6 +38549,9 @@
38554
38549
  return after < states.leftFixedLeafCount || start >= states.columnsCount - states.rightFixedLeafCount;
38555
38550
  }
38556
38551
  };
38552
+ const columnsHidden = vue.computed(() => {
38553
+ return states.columns.map((_, index) => isColumnHidden(index));
38554
+ });
38557
38555
  const getHeaderRowStyle = (rowIndex) => {
38558
38556
  const {
38559
38557
  headerRowStyle
@@ -38594,8 +38592,8 @@
38594
38592
  return headerCellStyle;
38595
38593
  };
38596
38594
  const getHeaderCellClass = (rowIndex, columnIndex, row, column) => {
38597
- const classes = [column.id, column.order, column.headerAlign, column.className, column.labelClass];
38598
- if (rowIndex === 0 && isCellHidden(columnIndex, row)) {
38595
+ const classes = [column.id, column.order, column.realHeaderAlign, column.className, column.labelClass];
38596
+ if (rowIndex === 0 && columnsHidden.value[columnIndex]) {
38599
38597
  classes.push("is-hidden");
38600
38598
  }
38601
38599
  if (!column.children) {
@@ -38627,7 +38625,7 @@
38627
38625
  if (column.children && column.children.length > 0) return;
38628
38626
  if (draggingColumn.value && props2.border) {
38629
38627
  dragging.value = true;
38630
- table.exposed.resizeProxyVisible.value = true;
38628
+ table.resizeProxyVisible.value = true;
38631
38629
  const tableEl = table.vnode.el;
38632
38630
  const tableLeft = tableEl.getBoundingClientRect().left;
38633
38631
  const columnEl = instance.vnode.el.querySelector(`.vc-table__th.${column.id}`);
@@ -38640,7 +38638,7 @@
38640
38638
  startColumnLeft: columnRect.left - tableLeft,
38641
38639
  tableLeft
38642
38640
  };
38643
- const resizeProxy = table.exposed.resizeProxy.value;
38641
+ const resizeProxy = table.resizeProxy.value;
38644
38642
  resizeProxy.style.left = dragState.value.startLeft + "px";
38645
38643
  document.onselectstart = () => false;
38646
38644
  document.ondragstart = () => false;
@@ -38734,35 +38732,27 @@
38734
38732
  });
38735
38733
  };
38736
38734
  return () => {
38737
- const {
38738
- originColumns
38739
- } = props2.store.states;
38740
- const columnRows = convertToRows(originColumns);
38741
- const isGroup = columnRows.length > 1;
38742
- if (isGroup) table.exposed.isGroup.value = true;
38743
38735
  return vue.createVNode("div", {
38744
38736
  "class": "vc-table__header"
38745
38737
  }, [vue.createVNode("div", {
38746
38738
  "class": [{
38747
- "is-group": isGroup
38739
+ "is-group": states.isGroup
38748
38740
  }, "vc-table__thead"]
38749
38741
  }, [
38750
38742
  // renderList
38751
- columnRows.map((columns, rowIndex) => vue.createVNode("div", {
38743
+ states.headerRows.map((columns, rowIndex) => vue.createVNode("div", {
38752
38744
  "style": getHeaderRowStyle(rowIndex),
38753
38745
  "class": [getHeaderRowClass(rowIndex), "vc-table__tr"]
38754
- }, [columns.map((column, cellIndex) => vue.createVNode("div", {
38755
- "colspan": column.colSpan,
38756
- "rowspan": column.rowSpan,
38757
- "onMousemove": ($event) => handleMouseMove($event, column),
38746
+ }, [columns.map((column, columnIndex) => vue.createVNode("div", {
38747
+ "onMousemove": (e) => handleMouseMove(e, column),
38758
38748
  "onMouseout": handleMouseOut,
38759
- "onMousedown": ($event) => handleMouseDown($event, column),
38760
- "onClick": ($event) => handleHeaderClick($event, column),
38761
- "onContextmenu": ($event) => handleHeaderContextMenu($event, column),
38762
- "style": [getHeaderCellStyle(rowIndex, cellIndex, columns, column), {
38749
+ "onMousedown": (e) => handleMouseDown(e, column),
38750
+ "onClick": (e) => handleHeaderClick(e, column),
38751
+ "onContextmenu": (e) => handleHeaderContextMenu(e, column),
38752
+ "style": [getHeaderCellStyle(rowIndex, columnIndex, columns, column), {
38763
38753
  width: `${column.realWidth}px`
38764
38754
  }],
38765
- "class": [getHeaderCellClass(rowIndex, cellIndex, columns, column), "vc-table__th"],
38755
+ "class": [getHeaderCellClass(rowIndex, columnIndex, columns, column), "vc-table__th"],
38766
38756
  "key": column.id
38767
38757
  }, [vue.createVNode("div", {
38768
38758
  "class": [
@@ -38774,10 +38764,8 @@
38774
38764
  ]
38775
38765
  }, [column.renderHeader ? column.renderHeader({
38776
38766
  column,
38777
- $index: cellIndex,
38778
- // index: cellIndex,
38779
- store: props2.store,
38780
- _self: instance
38767
+ columnIndex,
38768
+ store: props2.store
38781
38769
  }) : column.label, column.tooltip ? vue.createVNode(Icon, {
38782
38770
  "type": "o-info",
38783
38771
  "onMouseenter": (e) => handleCellMouseEnter(e, column)
@@ -38819,13 +38807,13 @@
38819
38807
  leftFixedCount: ($states) => $states.leftFixedColumns.length,
38820
38808
  rightFixedCount: ($states) => $states.rightFixedColumns.length
38821
38809
  });
38822
- const isCellHidden = (index, columns, column) => {
38810
+ const isColumnHidden = (column, index) => {
38823
38811
  if (props2.fixed === true || props2.fixed === "left") {
38824
38812
  return index >= states.leftFixedLeafCount;
38825
38813
  } else if (props2.fixed === "right") {
38826
38814
  let before = 0;
38827
38815
  for (let i = 0; i < index; i++) {
38828
- before += columns[i].colSpan;
38816
+ before += states.columns[i].colSpan;
38829
38817
  }
38830
38818
  return before < states.columnsCount - states.rightFixedLeafCount;
38831
38819
  } else if (!props2.fixed && column.fixed) {
@@ -38834,12 +38822,13 @@
38834
38822
  return index < states.leftFixedCount || index >= states.columnsCount - states.rightFixedCount;
38835
38823
  }
38836
38824
  };
38837
- const getRowClasses = (column, cellIndex) => {
38838
- const classes = [column.id, column.align, column.labelClass];
38825
+ const columnsHidden = vue.computed(() => states.columns.map(isColumnHidden));
38826
+ const getRowClasses = (column, columnIndex) => {
38827
+ const classes = [column.realAlign, column.labelClass];
38839
38828
  if (column.className) {
38840
38829
  classes.push(column.className);
38841
38830
  }
38842
- if (isCellHidden(cellIndex, states.columns, column)) {
38831
+ if (columnsHidden.value[columnIndex]) {
38843
38832
  classes.push("is-hidden");
38844
38833
  }
38845
38834
  if (!column.children) {
@@ -38847,17 +38836,17 @@
38847
38836
  }
38848
38837
  return classes;
38849
38838
  };
38850
- return () => {
38851
- let sums = [];
38839
+ const sums = vue.computed(() => {
38840
+ let v = [];
38852
38841
  if (props2.getSummary) {
38853
- sums = props2.getSummary({
38842
+ v = props2.getSummary({
38854
38843
  columns: states.columns,
38855
38844
  data: states.data
38856
38845
  });
38857
38846
  } else {
38858
38847
  states.columns.forEach((column, index) => {
38859
38848
  if (index === 0) {
38860
- sums[index] = props2.sumText;
38849
+ v[index] = props2.sumText;
38861
38850
  return;
38862
38851
  }
38863
38852
  const values = states.data.map((item) => Number(item[column.prop]));
@@ -38872,7 +38861,7 @@
38872
38861
  });
38873
38862
  const precision = Math.max.apply(null, precisions);
38874
38863
  if (!notNumber) {
38875
- sums[index] = values.reduce((prev, curr) => {
38864
+ v[index] = values.reduce((prev, curr) => {
38876
38865
  const value = Number(curr);
38877
38866
  if (!isNaN(value)) {
38878
38867
  return parseFloat((prev + curr).toFixed(Math.min(precision, 20)));
@@ -38881,10 +38870,13 @@
38881
38870
  }
38882
38871
  }, 0);
38883
38872
  } else {
38884
- sums[index] = "";
38873
+ v[index] = "";
38885
38874
  }
38886
38875
  });
38887
38876
  }
38877
+ return v;
38878
+ });
38879
+ return () => {
38888
38880
  return vue.createVNode("div", {
38889
38881
  "class": "vc-table__footer",
38890
38882
  "cellspacing": "0",
@@ -38894,17 +38886,15 @@
38894
38886
  "class": "vc-table__tbody"
38895
38887
  }, [vue.createVNode("div", {
38896
38888
  "class": "vc-table__tr"
38897
- }, [states.columns.map((column, cellIndex) => vue.createVNode("div", {
38898
- "key": cellIndex,
38899
- "colspan": column.colSpan,
38900
- "rowspan": column.rowSpan,
38901
- "class": [getRowClasses(column, cellIndex), "vc-table__td"],
38889
+ }, [states.columns.map((column, columnIndex) => vue.createVNode("div", {
38890
+ "key": columnIndex,
38891
+ "class": [getRowClasses(column, columnIndex), "vc-table__td"],
38902
38892
  "style": [{
38903
38893
  width: `${column.realWidth}px`
38904
38894
  }]
38905
38895
  }, [vue.createVNode("div", {
38906
38896
  "class": ["vc-table__cell", column.labelClass]
38907
- }, [sums[cellIndex]])]))])])]);
38897
+ }, [sums.value[columnIndex]])]))])])]);
38908
38898
  };
38909
38899
  }
38910
38900
  });
@@ -38931,7 +38921,7 @@
38931
38921
  type: Number,
38932
38922
  default: 10
38933
38923
  },
38934
- rowKey: [String, Function],
38924
+ primaryKey: [String, Function],
38935
38925
  // 是否显示表头
38936
38926
  showHeader: {
38937
38927
  type: Boolean,
@@ -39005,7 +38995,8 @@
39005
38995
  emits: ["select", "select-all", "selection-change", "cell-mouse-enter", "cell-mouse-leave", "cell-click", "cell-dblclick", "row-click", "row-contextmenu", "row-dblclick", "header-click", "header-contextmenu", "current-change", "header-dragend ", "expand-change", "sort-change"],
39006
38996
  setup(props2, {
39007
38997
  slots,
39008
- expose
38998
+ expose,
38999
+ emit
39009
39000
  }) {
39010
39001
  const instance = vue.getCurrentInstance();
39011
39002
  const store = new Store({
@@ -39041,21 +39032,21 @@
39041
39032
  const rightFixedBody = vue.ref(null);
39042
39033
  const rightFixedFooterWrapper = vue.ref(null);
39043
39034
  const resizeProxy = vue.ref(null);
39044
- const isGroup = vue.ref(false);
39045
39035
  const scrollPosition = vue.ref("left");
39046
39036
  const hoverState = vue.ref(null);
39047
39037
  const isReady = vue.ref(false);
39048
39038
  const states = useStates({
39049
39039
  columns: "columns",
39050
39040
  leftFixedColumns: "leftFixedColumns",
39051
- rightFixedColumns: "rightFixedColumns"
39041
+ rightFixedColumns: "rightFixedColumns",
39042
+ isGroup: "isGroup"
39052
39043
  }, store);
39053
39044
  const classes = vue.computed(() => {
39054
39045
  return {
39055
39046
  "vc-table--fit": props2.fit,
39056
39047
  "vc-table--striped": props2.stripe,
39057
- "vc-table--border": props2.border || isGroup.value,
39058
- "vc-table--group": isGroup.value,
39048
+ "vc-table--border": props2.border || states.isGroup,
39049
+ "vc-table--group": states.isGroup,
39059
39050
  "vc-table--fluid-height": props2.maxHeight,
39060
39051
  "vc-table--scrollable-x": layout.states.scrollX,
39061
39052
  "vc-table--scrollable-y": layout.states.scrollY,
@@ -39299,13 +39290,13 @@
39299
39290
  immediate: true
39300
39291
  });
39301
39292
  vue.watch(() => props2.currentRowValue, (v) => {
39302
- if (!props2.rowKey) return;
39293
+ if (!props2.primaryKey) return;
39303
39294
  store.current.reset(v);
39304
39295
  }, {
39305
39296
  immediate: true
39306
39297
  });
39307
- vue.watch(() => props2.data, (v) => {
39308
- store.setData(v);
39298
+ vue.watch(() => [props2.data, props2.data.length], () => {
39299
+ store.setData(props2.data);
39309
39300
  isReady.value && vue.nextTick(refreshLayout);
39310
39301
  }, {
39311
39302
  immediate: true
@@ -39326,6 +39317,7 @@
39326
39317
  }, {
39327
39318
  immediate: true
39328
39319
  });
39320
+ const tableId = getUid("table");
39329
39321
  vue.onMounted(() => {
39330
39322
  bindEvents();
39331
39323
  store.updateColumns();
@@ -39336,12 +39328,13 @@
39336
39328
  };
39337
39329
  isReady.value = true;
39338
39330
  });
39339
- vue.onBeforeUnmount(() => {
39331
+ vue.onUnmounted(() => {
39340
39332
  isUnMount = true;
39341
39333
  unbindEvents();
39342
39334
  });
39343
- const tableId = getUid("table");
39344
- expose({
39335
+ const exposed = {
39336
+ bodyXWrapper,
39337
+ bodyYWrapper,
39345
39338
  tableId,
39346
39339
  store,
39347
39340
  layout,
@@ -39361,8 +39354,12 @@
39361
39354
  isReady,
39362
39355
  hoverState,
39363
39356
  renderExpanded,
39364
- hiddenColumns
39365
- });
39357
+ hiddenColumns,
39358
+ props: props2,
39359
+ emit
39360
+ };
39361
+ expose(exposed);
39362
+ vue.provide("vc-table", exposed);
39366
39363
  return () => {
39367
39364
  return vue.createVNode("div", {
39368
39365
  "class": [classes.value, tableId, "vc-table"],
@@ -39510,22 +39507,19 @@
39510
39507
  order: ""
39511
39508
  },
39512
39509
  selection: {
39513
- width: 48,
39514
- minWidth: 48,
39515
- realWidth: 48,
39510
+ width: 60,
39511
+ minWidth: 60,
39516
39512
  order: "",
39517
39513
  className: "vc-table-column--selection"
39518
39514
  },
39519
39515
  expand: {
39520
- width: 48,
39521
- minWidth: 48,
39522
- realWidth: 48,
39516
+ width: 60,
39517
+ minWidth: 60,
39523
39518
  order: ""
39524
39519
  },
39525
39520
  index: {
39526
- width: 48,
39527
- minWidth: 48,
39528
- realWidth: 48,
39521
+ width: 60,
39522
+ minWidth: 60,
39529
39523
  order: ""
39530
39524
  }
39531
39525
  };
@@ -39549,10 +39543,11 @@
39549
39543
  column,
39550
39544
  store,
39551
39545
  rowIndex,
39552
- level
39546
+ level,
39547
+ selected
39553
39548
  }) {
39554
39549
  return vue.withDirectives(vue.createVNode(Checkbox, {
39555
- "modelValue": store.isSelected(row),
39550
+ "modelValue": selected,
39556
39551
  "disabled": column.selectable ? !column.selectable.call(null, row, rowIndex) : false,
39557
39552
  "onChange": () => store.rowSelectedChanged(row),
39558
39553
  "onClick": (e) => e.stopPropagation()
@@ -39685,8 +39680,8 @@
39685
39680
  customClass: String,
39686
39681
  labelClass: String,
39687
39682
  prop: String,
39688
- width: [Number, String],
39689
- minWidth: [Number, String],
39683
+ width: Number,
39684
+ minWidth: Number,
39690
39685
  renderHeader: Function,
39691
39686
  resizable: {
39692
39687
  type: Boolean,
@@ -39720,14 +39715,13 @@
39720
39715
  tooltip: [String, Function]
39721
39716
  },
39722
39717
  setup(props2, {
39723
- slots,
39724
- expose
39718
+ slots
39725
39719
  }) {
39726
39720
  const instance = vue.getCurrentInstance();
39727
- const table = getInstance$1("table", "tableId");
39728
- const parent = getInstance$1("table-column", "columnId") || table;
39721
+ const table = vue.inject("vc-table");
39722
+ const parent = vue.inject("vc-table-column", table);
39729
39723
  const isSubColumn = table !== parent;
39730
- const columnId = vue.ref((parent.exposed.tableId || parent.exposed.columnId) + getUid("column"));
39724
+ const columnId = vue.ref((parent.tableId || parent.columnId) + getUid("column"));
39731
39725
  const realWidth = vue.computed(() => {
39732
39726
  return parseWidth(props2.width);
39733
39727
  });
@@ -39791,7 +39785,7 @@
39791
39785
  column.renderCell = (data) => vue.createVNode("div", {
39792
39786
  "class": "vc-table__cell"
39793
39787
  }, [originRenderCell(data)]);
39794
- table.exposed.renderExpanded.value = (data) => {
39788
+ table.renderExpanded.value = (data) => {
39795
39789
  return slots.default ? slots.default(data) : slots.default;
39796
39790
  };
39797
39791
  } else {
@@ -39808,7 +39802,7 @@
39808
39802
  class: "vc-table__cell",
39809
39803
  style: {}
39810
39804
  };
39811
- if (!isEmpty$1(table.exposed.store.states.treeData) && !prefix2 && data.isExpandColumn) {
39805
+ if (!isEmpty$1(table.store.states.treeData) && !prefix2 && data.isExpandColumn) {
39812
39806
  prefix2 = vue.createVNode("span", {
39813
39807
  "class": "vc-table-un-expand__indent"
39814
39808
  }, null);
@@ -39828,24 +39822,14 @@
39828
39822
  }
39829
39823
  return column;
39830
39824
  };
39831
- const refreshColumnBasicConfig = () => {
39825
+ const registerColumn = () => {
39832
39826
  const defaults2 = {
39833
39827
  ...cellStarts[props2.type],
39834
- type: props2.type,
39835
39828
  id: columnId.value,
39836
- align: realAlign.value,
39837
- headerAlign: realHeaderAlign.value,
39838
- prop: props2.prop,
39839
- showPopover: props2.showPopover,
39840
- // index 列
39841
- index: props2.index
39829
+ realAlign,
39830
+ realHeaderAlign
39842
39831
  };
39843
- const basicProps = ["columnKey", "label", "customClass", "labelClass", "type", "renderHeader", "resizable", "formatter", "fixed", "resizable"];
39844
- const selectProps = ["selectable", "reserveSelection"];
39845
- const sortProps = ["sortable"];
39846
- const filterProps = ["filters", "filteredValue", "filterMultiple", "filter", "filterIcon", "filterPopupClass"];
39847
- let column = getPropsData(basicProps, selectProps, sortProps, filterProps);
39848
- column = merge$1(defaults2, column);
39832
+ let column = merge$1(defaults2, getPropsData(Object.keys(props2)));
39849
39833
  column = compose(setColumnRenders, setColumnWidth, setColumnForcedProps)(column);
39850
39834
  for (const key in column) {
39851
39835
  if (hasOwn$1(column, key)) {
@@ -39853,32 +39837,34 @@
39853
39837
  }
39854
39838
  }
39855
39839
  };
39856
- const registerComplexWatchers = () => {
39840
+ const registerWatchers = () => {
39841
+ Object.keys(props2).forEach((k) => vue.watch(() => props2[k], (v) => columnConfig[k] = v));
39857
39842
  vue.watch(() => props2.fixed, () => {
39858
- table.exposed.store.scheduleLayout(true);
39843
+ table.store.scheduleLayout(true);
39859
39844
  });
39860
- vue.watch(() => realWidth.value, () => {
39861
- table.exposed.store.scheduleLayout(false);
39845
+ vue.watch(() => realWidth.value, (v) => {
39846
+ columnConfig["width"] = v;
39847
+ columnConfig["realWidth"] = v;
39848
+ table.store.scheduleLayout(false);
39862
39849
  });
39863
39850
  vue.watch(() => realMinWidth.value, () => {
39864
- table.exposed.store.scheduleLayout(false);
39851
+ table.store.scheduleLayout(false);
39865
39852
  });
39866
39853
  };
39867
39854
  vue.onBeforeMount(() => {
39868
- refreshColumnBasicConfig();
39869
- registerComplexWatchers();
39855
+ registerColumn();
39856
+ registerWatchers();
39870
39857
  });
39871
- vue.onUpdated(refreshColumnBasicConfig);
39872
39858
  vue.onMounted(() => {
39873
- const children = isSubColumn ? parent.vnode.el.children : parent.exposed.hiddenColumns.value.children;
39859
+ const children = isSubColumn ? parent.vnode.el.children : parent.hiddenColumns.value.children;
39874
39860
  const columnIndex = [...children].indexOf(instance.vnode.el);
39875
- table.exposed.store.insertColumn(columnConfig, columnIndex, isSubColumn && parent.exposed.columnConfig);
39861
+ table.store.insertColumn(columnConfig, columnIndex, isSubColumn && parent.columnConfig);
39876
39862
  });
39877
39863
  vue.onUnmounted(() => {
39878
39864
  if (!instance.parent) return;
39879
- table.exposed.store.removeColumn(columnConfig, isSubColumn && parent.exposed.columnConfig);
39865
+ table.store.removeColumn(columnConfig, isSubColumn && parent.columnConfig);
39880
39866
  });
39881
- expose({
39867
+ vue.provide("vc-table-column", {
39882
39868
  columnId,
39883
39869
  columnConfig
39884
39870
  });
@@ -39888,7 +39874,8 @@
39888
39874
  const renderDefault = slots?.default?.({
39889
39875
  row: {},
39890
39876
  column: {},
39891
- $index: -1
39877
+ columnIndex: -1,
39878
+ rowIndex: -1
39892
39879
  });
39893
39880
  if (renderDefault instanceof Array) {
39894
39881
  for (const childNode of renderDefault) {