bkui-vue 2.0.1-beta.28 → 2.0.1-beta.28.table.1

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/lib/index.js CHANGED
@@ -4,5 +4,5 @@ export { default } from './preset';
4
4
  export * from './config-provider';
5
5
  export * from './directives';
6
6
  export * as plugins from './plugins';
7
- export const version = "2.0.1-beta.28";
7
+ export const version = "2.0.1-beta.28.table.1";
8
8
  window.__bkui_vue_version__ = version;
@@ -1,16 +1,19 @@
1
1
  import { IEmptyObject } from '../const';
2
- import { Column, Settings, TablePropTypes } from '../props';
2
+ import { Column, IHeadGroup, Settings, TablePropTypes } from '../props';
3
3
  declare const useColumns: (props: TablePropTypes) => {
4
4
  needColSpan: import("vue").ComputedRef<boolean>;
5
5
  needRowSpan: import("vue").ComputedRef<boolean>;
6
6
  tableColumnSchema: WeakMap<object, any> & Omit<WeakMap<object, any>, keyof WeakMap<any, any>>;
7
7
  tableColumnList: any[];
8
8
  visibleColumns: Column[];
9
- debounceUpdateColumns: import("lodash").DebouncedFunc<(columns: any) => void>;
9
+ debounceUpdateColumns: import("lodash").DebouncedFunc<(columns: any, onComplete?: any) => void>;
10
10
  sortColumns: any[];
11
11
  filterColumns: any[];
12
+ columnGroup: Column[][];
13
+ columnGroupMap: WeakMap<Column, IHeadGroup>;
12
14
  clearColumnSort: () => void;
13
15
  formatColumns: () => void;
16
+ flatColumnTemplate: (cols: Column[]) => any[];
14
17
  isHiddenColumn: (col: Column) => any;
15
18
  getColumnId: (col: Column) => any;
16
19
  getColumnOrderWidth: (col: Column, orders?: string[]) => number;
@@ -33,6 +36,7 @@ declare const useColumns: (props: TablePropTypes) => {
33
36
  getColumnRefAttribute: (col: Column | IEmptyObject, attributeName: string) => any;
34
37
  getColumnCalcWidth: (column: Column) => any;
35
38
  getColumnWidth: (column: Column) => any;
39
+ getGroupAttribute: (group: Column) => IHeadGroup;
36
40
  resolveEventListener: (col: Column) => Record<string, (...args: any[]) => void> & {
37
41
  [x: string]: (e: MouseEvent) => void;
38
42
  };
@@ -9,6 +9,7 @@ declare const _default: ({ props, columns, rows, ctx, column, index, }: {
9
9
  column: Column;
10
10
  index: number;
11
11
  rows: UseRows;
12
+ rowIndex: number;
12
13
  }) => {
13
14
  getTH: () => JSX.Element;
14
15
  };
@@ -13,6 +13,7 @@ declare const _default: (props: TablePropTypes, ctx: any) => {
13
13
  setFixedColumns: (values: Column[]) => void;
14
14
  setOffsetRight: () => void;
15
15
  setLineHeight: (val: number) => void;
16
+ setHeaderRowCount: (val: number) => void;
16
17
  initRootStyleVars: () => void;
17
18
  refRoot: Ref<HTMLElement>;
18
19
  refHead: Ref<HTMLElement>;
@@ -18423,50 +18423,64 @@ function v4(options, buf, offset) {
18423
18423
  }
18424
18424
  return columnCache.get(ctx);
18425
18425
  };
18426
- var resolveChildNode = function resolveChildNode(node) {
18427
- var _node$type, _node$type2, _node$component;
18428
- if (!node || ((_node$type = node.type) === null || _node$type === void 0 ? void 0 : _node$type.name) === 'Table') {
18429
- return;
18430
- }
18431
- if (((_node$type2 = node.type) === null || _node$type2 === void 0 ? void 0 : _node$type2.name) === 'TableColumn') {
18432
- var _node$props$render, _node$children;
18433
- var resolveProp = Object.assign({
18434
- index: columnIndex
18435
- }, copyProps(node.props), {
18436
- field: node.props.prop || node.props.field,
18437
- render: (_node$props$render = node.props.render) !== null && _node$props$render !== void 0 ? _node$props$render : (_node$children = node.children) === null || _node$children === void 0 ? void 0 : _node$children["default"],
18438
- uniqueId: getNodeCtxUid(node)
18439
- });
18440
- if (!columns.some(function (col) {
18441
- return col.uniqueId === resolveProp.uniqueId;
18442
- })) {
18443
- columns.push((0,external_vue_namespaceObject.unref)(resolveProp));
18444
- columnIndex = columnIndex + 1;
18445
- }
18446
- return;
18447
- }
18426
+ var resolveNodeChilren = function resolveNodeChilren(node, rootNode, isColumnRoot) {
18427
+ var _node$component;
18448
18428
  if (node !== null && node !== void 0 && (_node$component = node.component) !== null && _node$component !== void 0 && _node$component.subTree) {
18449
18429
  var _node$component2;
18450
- resolveChildNode(node === null || node === void 0 || (_node$component2 = node.component) === null || _node$component2 === void 0 ? void 0 : _node$component2.subTree);
18430
+ resolveChildNode(node === null || node === void 0 || (_node$component2 = node.component) === null || _node$component2 === void 0 ? void 0 : _node$component2.subTree, rootNode);
18451
18431
  return;
18452
18432
  }
18453
18433
  if (typeof node === 'function') {
18454
18434
  return node();
18455
18435
  }
18456
18436
  if (Array.isArray(node)) {
18457
- node.forEach(resolveChildNode);
18437
+ node.forEach(function (c) {
18438
+ return resolveChildNode(c, rootNode);
18439
+ });
18458
18440
  return;
18459
18441
  }
18460
18442
  if (Array.isArray(node === null || node === void 0 ? void 0 : node.children)) {
18461
- node.children.forEach(resolveChildNode);
18443
+ node.children.forEach(function (c) {
18444
+ return resolveChildNode(c, rootNode);
18445
+ });
18462
18446
  return;
18463
18447
  }
18464
- if ((0,external_vue_namespaceObject.isVNode)(node) && node !== null && node !== void 0 && node.children && typeof_typeof(node === null || node === void 0 ? void 0 : node.children) === 'object') {
18448
+ if (!isColumnRoot && (0,external_vue_namespaceObject.isVNode)(node) && node !== null && node !== void 0 && node.children && typeof_typeof(node === null || node === void 0 ? void 0 : node.children) === 'object') {
18465
18449
  Object.keys(node.children).forEach(function (key) {
18466
- return resolveChildNode(node.children[key]);
18450
+ return resolveChildNode(node.children[key], rootNode);
18451
+ });
18452
+ return;
18453
+ }
18454
+ };
18455
+ var resolveChildNode = function resolveChildNode(node, parent) {
18456
+ var _node$type, _node$type2;
18457
+ var rootNode = parent;
18458
+ if (!node || ((_node$type = node.type) === null || _node$type === void 0 ? void 0 : _node$type.name) === 'Table') {
18459
+ return;
18460
+ }
18461
+ if (((_node$type2 = node.type) === null || _node$type2 === void 0 ? void 0 : _node$type2.name) === 'TableColumn') {
18462
+ var _node$props$render, _node$children, _parent$children;
18463
+ var resolveProp = Object.assign({
18464
+ index: columnIndex
18465
+ }, copyProps(node.props), {
18466
+ field: node.props.prop || node.props.field,
18467
+ render: (_node$props$render = node.props.render) !== null && _node$props$render !== void 0 ? _node$props$render : (_node$children = node.children) === null || _node$children === void 0 ? void 0 : _node$children["default"],
18468
+ uniqueId: getNodeCtxUid(node),
18469
+ children: []
18467
18470
  });
18471
+ var targetColumns = (_parent$children = parent === null || parent === void 0 ? void 0 : parent.children) !== null && _parent$children !== void 0 ? _parent$children : columns;
18472
+ if (!targetColumns.some(function (col) {
18473
+ return col.uniqueId === resolveProp.uniqueId;
18474
+ })) {
18475
+ targetColumns.push(resolveProp);
18476
+ columnIndex = columnIndex + 1;
18477
+ if (node.children) {
18478
+ resolveNodeChilren(node, resolveProp, true);
18479
+ }
18480
+ }
18468
18481
  return;
18469
18482
  }
18483
+ resolveNodeChilren(node, rootNode);
18470
18484
  };
18471
18485
  var resolveColumns = function resolveColumns(children) {
18472
18486
  columns.length = 0;
@@ -18482,7 +18496,9 @@ function v4(options, buf, offset) {
18482
18496
  resolveChildNode((_ghostBody$component2 = ghostBody.component) === null || _ghostBody$component2 === void 0 ? void 0 : _ghostBody$component2.subTree);
18483
18497
  } else {
18484
18498
  var _ghostBody$children$d, _ghostBody$children, _ghostBody$children$d2;
18485
- ((_ghostBody$children$d = (_ghostBody$children = ghostBody.children) === null || _ghostBody$children === void 0 || (_ghostBody$children$d2 = _ghostBody$children["default"]) === null || _ghostBody$children$d2 === void 0 ? void 0 : _ghostBody$children$d2.call(_ghostBody$children)) !== null && _ghostBody$children$d !== void 0 ? _ghostBody$children$d : []).forEach(resolveChildNode);
18499
+ ((_ghostBody$children$d = (_ghostBody$children = ghostBody.children) === null || _ghostBody$children === void 0 || (_ghostBody$children$d2 = _ghostBody$children["default"]) === null || _ghostBody$children$d2 === void 0 ? void 0 : _ghostBody$children$d2.call(_ghostBody$children)) !== null && _ghostBody$children$d !== void 0 ? _ghostBody$children$d : []).forEach(function (c) {
18500
+ return resolveChildNode(c);
18501
+ });
18486
18502
  }
18487
18503
  }
18488
18504
  columns.sort(function (col1, col2) {
@@ -20043,6 +20059,8 @@ var useColumns = function useColumns(props) {
20043
20059
  var uuid = esm_browser_v4();
20044
20060
  var sortColumns = (0,external_vue_namespaceObject.reactive)([]);
20045
20061
  var filterColumns = (0,external_vue_namespaceObject.reactive)([]);
20062
+ var columnGroup = (0,external_vue_namespaceObject.reactive)([]);
20063
+ var columnGroupMap = new WeakMap();
20046
20064
  /**
20047
20065
  * 用来记录列的排序状态
20048
20066
  * @param col
@@ -20252,6 +20270,81 @@ var useColumns = function useColumns(props) {
20252
20270
  };
20253
20271
  return filterFn;
20254
20272
  };
20273
+ /**
20274
+ * 格式化Column嵌套配置,支持多表头设置
20275
+ * @param cols
20276
+ */
20277
+ var flatColumnTemplate = function flatColumnTemplate(cols) {
20278
+ columnGroup.length = 0;
20279
+ var maxDepth = 0;
20280
+ var targetColumns = [];
20281
+ var getMaxDepth = function getMaxDepth(root) {
20282
+ var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
20283
+ if (root.length && maxDepth < depth) {
20284
+ maxDepth = depth;
20285
+ }
20286
+ root.forEach(function (col) {
20287
+ var _col$children;
20288
+ return getMaxDepth((_col$children = col.children) !== null && _col$children !== void 0 ? _col$children : [], depth + 1);
20289
+ });
20290
+ };
20291
+ getMaxDepth(cols);
20292
+ var updateParentThColspan = function updateParentThColspan(col, count) {
20293
+ if (col) {
20294
+ var colMap = columnGroupMap.get(col);
20295
+ colMap.thColspan = colMap.thColspan + count;
20296
+ colMap.offsetLeft = colMap.offsetLeft + count;
20297
+ updateParentThColspan(colMap.parent, count);
20298
+ }
20299
+ };
20300
+ var foreachAllColumns = function foreachAllColumns(column, depth, parent, left) {
20301
+ var _col$children$length, _col$children2, _col$children$length2, _col$children3, _col$children$length3, _col$children4, _col$children$length4, _col$children5, _col$children6;
20302
+ var col = (0,external_vue_namespaceObject.toRaw)(column);
20303
+ var leftColumnCount = left;
20304
+ if (columnGroup[depth] === undefined) {
20305
+ columnGroup[depth] = [];
20306
+ }
20307
+ var isGroup = !!((_col$children$length = (_col$children2 = col.children) === null || _col$children2 === void 0 ? void 0 : _col$children2.length) !== null && _col$children$length !== void 0 ? _col$children$length : false);
20308
+ if (!((_col$children$length2 = (_col$children3 = col.children) === null || _col$children3 === void 0 ? void 0 : _col$children3.length) !== null && _col$children$length2 !== void 0 ? _col$children$length2 : false)) {
20309
+ targetColumns.push(col);
20310
+ }
20311
+ if (!columnGroupMap.has(col)) {
20312
+ columnGroupMap.set(col, {
20313
+ thColspan: 1,
20314
+ thRowspan: 1,
20315
+ isGroup: isGroup,
20316
+ offsetLeft: left
20317
+ });
20318
+ }
20319
+ var colMap = columnGroupMap.get(col);
20320
+ var childLength = (_col$children$length3 = (_col$children4 = col.children) === null || _col$children4 === void 0 ? void 0 : _col$children4.length) !== null && _col$children$length3 !== void 0 ? _col$children$length3 : 0;
20321
+ var thColspan = (_col$children$length4 = (_col$children5 = col.children) === null || _col$children5 === void 0 ? void 0 : _col$children5.length) !== null && _col$children$length4 !== void 0 ? _col$children$length4 : 1;
20322
+ var thRowspan = childLength > 0 ? 1 : maxDepth - depth;
20323
+ var offsetLeft = leftColumnCount + (childLength > 0 ? childLength - 1 : 0);
20324
+ Object.assign(colMap, {
20325
+ thColspan: thColspan > 0 ? thColspan : 1,
20326
+ parent: parent,
20327
+ thRowspan: thRowspan,
20328
+ offsetLeft: offsetLeft
20329
+ });
20330
+ columnGroup[depth].push(col);
20331
+ if (thColspan > 1) {
20332
+ updateParentThColspan(parent, thColspan - 1);
20333
+ }
20334
+ (_col$children6 = col.children) === null || _col$children6 === void 0 || _col$children6.forEach(function (c, index) {
20335
+ leftColumnCount = leftColumnCount + foreachAllColumns(c, depth + 1, col, leftColumnCount + index);
20336
+ });
20337
+ return childLength > 0 ? childLength - 1 : 0;
20338
+ };
20339
+ var leftColumnCount = 0;
20340
+ cols.forEach(function (col, index) {
20341
+ leftColumnCount = leftColumnCount + foreachAllColumns(col, 0, null, leftColumnCount + index);
20342
+ });
20343
+ return targetColumns;
20344
+ };
20345
+ var getGroupAttribute = function getGroupAttribute(group) {
20346
+ return columnGroupMap.get(group);
20347
+ };
20255
20348
  /**
20256
20349
  * Format columns
20257
20350
  * @param columns
@@ -20336,11 +20429,12 @@ var useColumns = function useColumns(props) {
20336
20429
  };
20337
20430
  setColumnAttribute(col, COLUMN_ATTRIBUTE.COL_RECT, target);
20338
20431
  };
20339
- var debounceUpdateColumns = (0,lodash.debounce)(function (columns) {
20432
+ var debounceUpdateColumns = (0,lodash.debounce)(function (columns, onComplete) {
20340
20433
  tableColumnList.length = 0;
20341
- tableColumnList.push.apply(tableColumnList, _toConsumableArray(columns));
20434
+ tableColumnList.push.apply(tableColumnList, _toConsumableArray(flatColumnTemplate(columns)));
20342
20435
  formatColumns();
20343
20436
  setVisibleColumns();
20437
+ onComplete === null || onComplete === void 0 || onComplete();
20344
20438
  });
20345
20439
  var setColumnIsHidden = function setColumnIsHidden(column) {
20346
20440
  var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
@@ -20494,13 +20588,6 @@ var useColumns = function useColumns(props) {
20494
20588
  }
20495
20589
  setColumnAttribute(column, COLUMN_ATTRIBUTE.COL_SORT_ACTIVE, active);
20496
20590
  };
20497
- (0,external_vue_namespaceObject.watch)(function () {
20498
- return [props.columns];
20499
- }, function () {
20500
- debounceUpdateColumns(props.columns);
20501
- }, {
20502
- immediate: true
20503
- });
20504
20591
  /**
20505
20592
  * 清理列排序
20506
20593
  * @param reset 是否重置表格数据
@@ -20520,8 +20607,11 @@ var useColumns = function useColumns(props) {
20520
20607
  debounceUpdateColumns: debounceUpdateColumns,
20521
20608
  sortColumns: sortColumns,
20522
20609
  filterColumns: filterColumns,
20610
+ columnGroup: columnGroup,
20611
+ columnGroupMap: columnGroupMap,
20523
20612
  clearColumnSort: clearColumnSort,
20524
20613
  formatColumns: formatColumns,
20614
+ flatColumnTemplate: flatColumnTemplate,
20525
20615
  isHiddenColumn: isHiddenColumn,
20526
20616
  getColumnId: getColumnId,
20527
20617
  getColumnOrderWidth: getColumnOrderWidth,
@@ -20534,6 +20624,7 @@ var useColumns = function useColumns(props) {
20534
20624
  getColumnRefAttribute: getColumnRefAttribute,
20535
20625
  getColumnCalcWidth: getColumnCalcWidth,
20536
20626
  getColumnWidth: getColumnWidth,
20627
+ getGroupAttribute: getGroupAttribute,
20537
20628
  resolveEventListener: resolveEventListener,
20538
20629
  setColumnIsHidden: setColumnIsHidden,
20539
20630
  setColumnResizeWidth: setColumnResizeWidth,
@@ -20997,6 +21088,7 @@ function use_layout_objectSpread(e) { for (var r = 1; r < arguments.length; r++)
20997
21088
  var layout = (0,external_vue_namespaceObject.reactive)({});
20998
21089
  var fixedColumns = (0,external_vue_namespaceObject.reactive)([]);
20999
21090
  var lineHeight = (0,external_vue_namespaceObject.ref)((_props$rowHeight = props.rowHeight) !== null && _props$rowHeight !== void 0 ? _props$rowHeight : LINE_HEIGHT);
21091
+ var headerRowCount = (0,external_vue_namespaceObject.ref)(1);
21000
21092
  var fixedBottomHeight = (0,external_vue_namespaceObject.computed)(function () {
21001
21093
  var _props$fixedBottom, _props$fixedBottom$he, _props$fixedBottom2, _props$fixedBottom$he2, _props$fixedBottom3;
21002
21094
  return ((_props$fixedBottom = props.fixedBottom) === null || _props$fixedBottom === void 0 ? void 0 : _props$fixedBottom.position) === 'relative' ? (_props$fixedBottom$he = (_props$fixedBottom2 = props.fixedBottom) === null || _props$fixedBottom2 === void 0 ? void 0 : _props$fixedBottom2.height) !== null && _props$fixedBottom$he !== void 0 ? _props$fixedBottom$he : LINE_HEIGHT : (_props$fixedBottom$he2 = (_props$fixedBottom3 = props.fixedBottom) === null || _props$fixedBottom3 === void 0 ? void 0 : _props$fixedBottom3.height) !== null && _props$fixedBottom$he2 !== void 0 ? _props$fixedBottom$he2 : 0;
@@ -21016,7 +21108,7 @@ function use_layout_objectSpread(e) { for (var r = 1; r < arguments.length; r++)
21016
21108
  };
21017
21109
  });
21018
21110
  var headClass = (0,external_vue_namespaceObject.computed)(function () {
21019
- return (0,shared_namespaceObject.classes)(defineProperty_defineProperty(defineProperty_defineProperty({}, resolveClassName('table-head'), true), 'has-settings', !!props.settings));
21111
+ return (0,shared_namespaceObject.classes)(defineProperty_defineProperty(defineProperty_defineProperty(defineProperty_defineProperty({}, resolveClassName('table-head'), true), 'has-settings', !!props.settings), 'has-group', headerRowCount.value > 1));
21020
21112
  });
21021
21113
  var setFixedColumnShawdow = function setFixedColumnShawdow() {
21022
21114
  var _refRoot$value, _refRoot$value2;
@@ -21038,6 +21130,9 @@ function use_layout_objectSpread(e) { for (var r = 1; r < arguments.length; r++)
21038
21130
  translateX.value = val;
21039
21131
  setRootStyleVars();
21040
21132
  };
21133
+ var setHeaderRowCount = function setHeaderRowCount(val) {
21134
+ headerRowCount.value = val;
21135
+ };
21041
21136
  var setTranslateY = function setTranslateY(val) {
21042
21137
  translateY.value = val;
21043
21138
  setRootStyleVars();
@@ -21056,7 +21151,7 @@ function use_layout_objectSpread(e) { for (var r = 1; r < arguments.length; r++)
21056
21151
  };
21057
21152
  var config = resolveHeadConfig(props);
21058
21153
  var headHeight = (0,external_vue_namespaceObject.computed)(function () {
21059
- return resolvePropVal(config, 'height', ['thead']);
21154
+ return resolvePropVal(config, 'height', ['thead']) * headerRowCount.value;
21060
21155
  });
21061
21156
  var headStyle = (0,external_vue_namespaceObject.computed)(function () {
21062
21157
  var _props$thead$color, _props$thead;
@@ -21262,6 +21357,7 @@ function use_layout_objectSpread(e) { for (var r = 1; r < arguments.length; r++)
21262
21357
  setFixedColumns: setFixedColumns,
21263
21358
  setOffsetRight: setOffsetRight,
21264
21359
  setLineHeight: setLineHeight,
21360
+ setHeaderRowCount: setHeaderRowCount,
21265
21361
  initRootStyleVars: initRootStyleVars,
21266
21362
  refRoot: refRoot,
21267
21363
  refHead: refHead,
@@ -22556,6 +22652,7 @@ function use_head_isSlot(s) {
22556
22652
  index = _ref.index;
22557
22653
  var sortType = (0,external_vue_namespaceObject.ref)(columns.getColumnAttribute(column, COLUMN_ATTRIBUTE.COL_SORT_TYPE));
22558
22654
  var sortActive = (0,external_vue_namespaceObject.ref)(columns.getColumnAttribute(column, COLUMN_ATTRIBUTE.COL_SORT_ACTIVE));
22655
+ var rawColumn = (0,external_vue_namespaceObject.toRaw)(column);
22559
22656
  /**
22560
22657
  * 点击排序事件
22561
22658
  * @param sortFn 排序函数
@@ -22732,14 +22829,36 @@ function use_head_isSlot(s) {
22732
22829
  var headStyle = Object.assign(columns.getFixedStlye(column), {
22733
22830
  '--background-color': DEF_COLOR[(_props$thead$color = (_props$thead = props.thead) === null || _props$thead === void 0 ? void 0 : _props$thead.color) !== null && _props$thead$color !== void 0 ? _props$thead$color : IHeadColor.DEF1]
22734
22831
  });
22735
- var classList = [columns.getHeadColumnClass(column, index), columns.getColumnCustomClass(column), column.align || props.headerAlign || props.align];
22832
+ var group = columns.getGroupAttribute(rawColumn);
22833
+ var classList = (0,external_vue_namespaceObject.computed)(function () {
22834
+ return [columns.getHeadColumnClass(column, index), columns.getColumnCustomClass(column), column.align || props.headerAlign || props.align, {
22835
+ 'is-last-child': (group === null || group === void 0 ? void 0 : group.offsetLeft) + 1 === columns.visibleColumns.length
22836
+ }];
22837
+ });
22838
+ var groupClass = (0,external_vue_namespaceObject.computed)(function () {
22839
+ return classList.value.concat([{
22840
+ 'is-head-group': group === null || group === void 0 ? void 0 : group.isGroup,
22841
+ 'is-head-group-child': !!(group !== null && group !== void 0 && group.parent)
22842
+ }]);
22843
+ });
22844
+ var getGroupRender = function getGroupRender() {
22845
+ return resolvePropVal(column, 'label', [index, column]);
22846
+ };
22736
22847
  var getTH = function getTH() {
22848
+ if (group !== null && group !== void 0 && group.isGroup) {
22849
+ return (0,external_vue_namespaceObject.createVNode)("th", {
22850
+ "style": headStyle,
22851
+ "class": groupClass.value,
22852
+ "colspan": group === null || group === void 0 ? void 0 : group.thColspan,
22853
+ "rowspan": group === null || group === void 0 ? void 0 : group.thRowspan
22854
+ }, [getGroupRender()]);
22855
+ }
22737
22856
  return (0,external_vue_namespaceObject.createVNode)("th", (0,external_vue_namespaceObject.mergeProps)({
22738
22857
  "style": headStyle,
22739
- "class": classList,
22740
- "colspan": 1,
22858
+ "class": classList.value,
22859
+ "colspan": group === null || group === void 0 ? void 0 : group.thColspan,
22741
22860
  "data-id": columns.getColumnId(column),
22742
- "rowspan": 1,
22861
+ "rowspan": group === null || group === void 0 ? void 0 : group.thRowspan,
22743
22862
  "onClick": function onClick() {
22744
22863
  return handleColumnHeadClick();
22745
22864
  }
@@ -22930,21 +23049,20 @@ function use_render_isSlot(s) {
22930
23049
  };
22931
23050
  return (0,external_vue_namespaceObject.createVNode)(external_vue_namespaceObject.Fragment, null, [(0,external_vue_namespaceObject.createVNode)("thead", {
22932
23051
  "style": rowStyle
22933
- }, [(0,external_vue_namespaceObject.createVNode)(table_row, null, {
22934
- "default": function _default() {
22935
- return [(0,external_vue_namespaceObject.createVNode)("tr", null, [columns.visibleColumns.map(function (column, index) {
22936
- var _useHead = use_head({
22937
- props: props,
22938
- ctx: ctx,
22939
- columns: columns,
22940
- column: column,
22941
- index: index,
22942
- rows: rows
22943
- }),
22944
- getTH = _useHead.getTH;
22945
- return getTH();
22946
- })])];
22947
- }
23052
+ }, [columns.columnGroup.map(function (cols, rowIndex) {
23053
+ return (0,external_vue_namespaceObject.createVNode)("tr", null, [cols.map(function (column, index) {
23054
+ var _useHead = use_head({
23055
+ props: props,
23056
+ ctx: ctx,
23057
+ columns: columns,
23058
+ column: column,
23059
+ index: index,
23060
+ rows: rows,
23061
+ rowIndex: rowIndex
23062
+ }),
23063
+ getTH = _useHead.getTH;
23064
+ return getTH();
23065
+ })]);
22948
23066
  })])]);
22949
23067
  };
22950
23068
  var renderColumns = function renderColumns() {
@@ -23952,6 +24070,7 @@ var useSettings = function useSettings(props, ctx, columns, afterSetting) {
23952
24070
  setFootHeight = _useLayout.setFootHeight,
23953
24071
  setDragOffsetX = _useLayout.setDragOffsetX,
23954
24072
  setOffsetRight = _useLayout.setOffsetRight,
24073
+ setHeaderRowCount = _useLayout.setHeaderRowCount,
23955
24074
  refBody = _useLayout.refBody,
23956
24075
  refRoot = _useLayout.refRoot;
23957
24076
  /**
@@ -23986,7 +24105,9 @@ var useSettings = function useSettings(props, ctx, columns, afterSetting) {
23986
24105
  var initTableColumns = function initTableColumns() {
23987
24106
  var _instance$subTree$chi, _instance$subTree;
23988
24107
  var children = (_instance$subTree$chi = (_instance$subTree = instance.subTree) === null || _instance$subTree === void 0 ? void 0 : _instance$subTree.children) !== null && _instance$subTree$chi !== void 0 ? _instance$subTree$chi : [];
23989
- columns.debounceUpdateColumns(resolveColumns(children));
24108
+ columns.debounceUpdateColumns(resolveColumns(children), function () {
24109
+ setHeaderRowCount(columns.columnGroup.length);
24110
+ });
23990
24111
  };
23991
24112
  (0,external_vue_namespaceObject.provide)(PROVIDE_KEY_INIT_COL, initTableColumns);
23992
24113
  var _useFixedColumn = use_fixed_column(props, columns),
@@ -24093,6 +24214,15 @@ var useSettings = function useSettings(props, ctx, columns, afterSetting) {
24093
24214
  observerResizing.value = false;
24094
24215
  });
24095
24216
  });
24217
+ (0,external_vue_namespaceObject.watch)(function () {
24218
+ return [props.columns];
24219
+ }, function () {
24220
+ columns.debounceUpdateColumns(props.columns, function () {
24221
+ setHeaderRowCount(columns.columnGroup.length);
24222
+ });
24223
+ }, {
24224
+ immediate: true
24225
+ });
24096
24226
  (0,external_vue_namespaceObject.watch)(function () {
24097
24227
  return [dragOffsetX.value];
24098
24228
  }, function () {
@@ -162,8 +162,16 @@ export type IDraggableRowOption = {
162
162
  icon?: JSX.Element;
163
163
  width?: number;
164
164
  };
165
+ export type IHeadGroup = {
166
+ thColspan: number;
167
+ thRowspan: number;
168
+ isGroup: boolean;
169
+ parent?: IHeadGroup;
170
+ label?: string;
171
+ offsetLeft?: number;
172
+ };
165
173
  export type Column = {
166
- label: LabelFunctionString;
174
+ label?: LabelFunctionString;
167
175
  field?: LabelFunctionString;
168
176
  render?: RenderFunctionString;
169
177
  renderHead?: RenderFunctionString;
@@ -184,6 +192,7 @@ export type Column = {
184
192
  prop?: LabelFunctionString;
185
193
  index?: number;
186
194
  explain?: IColumnExplain;
195
+ children?: Column[];
187
196
  };
188
197
  export declare const IColumnProp: import("vue-types").VueTypeDef<Column>;
189
198
  export type Thead = {
@@ -1504,6 +1504,15 @@
1504
1504
  background-color: var(--background-color);
1505
1505
  height: var(--row-height);
1506
1506
  }
1507
+ .bk-table .bk-table-head.has-group .is-head-group {
1508
+ border-bottom: 1px solid var(--table-border-color);
1509
+ }
1510
+ .bk-table .bk-table-head.has-group th {
1511
+ border-right: 1px solid var(--table-border-color);
1512
+ }
1513
+ .bk-table .bk-table-head.has-group th.is-last-child {
1514
+ border-right: none;
1515
+ }
1507
1516
  .bk-table .bk-table-head .col-resize-drag {
1508
1517
  position: absolute;
1509
1518
  top: 0;
@@ -1576,6 +1585,9 @@
1576
1585
  .bk-table.bordered-col .bk-table-head {
1577
1586
  border-right: 1px solid var(--table-border-color);
1578
1587
  }
1588
+ .bk-table.bordered-col .bk-table-head .is-head-group {
1589
+ border-bottom: 1px solid var(--table-border-color);
1590
+ }
1579
1591
  .bk-table.bordered-col th {
1580
1592
  border-right: 1px solid var(--table-border-color);
1581
1593
  }
@@ -308,6 +308,20 @@
308
308
  background-color: var(--background-color);
309
309
  height: var(--row-height);
310
310
 
311
+ &.has-group {
312
+ .is-head-group {
313
+ border-bottom: 1px solid @table-border-color;
314
+ }
315
+
316
+ th {
317
+ border-right: 1px solid @table-border-color;
318
+
319
+ &.is-last-child {
320
+ border-right: none;
321
+ }
322
+ }
323
+ }
324
+
311
325
  .col-resize-drag {
312
326
  position: absolute;
313
327
  top: 0;
@@ -406,6 +420,9 @@
406
420
  &.bordered-col {
407
421
  .@{bk-prefix}-table-head {
408
422
  border-right: 1px solid @table-border-color;
423
+ .is-head-group {
424
+ border-bottom: 1px solid @table-border-color;
425
+ }
409
426
  }
410
427
  th {
411
428
  border-right: 1px solid @table-border-color;
@@ -1894,6 +1894,15 @@
1894
1894
  background-color: var(--background-color);
1895
1895
  height: var(--row-height);
1896
1896
  }
1897
+ .bk-table .bk-table-head.has-group .is-head-group {
1898
+ border-bottom: 1px solid var(--table-border-color);
1899
+ }
1900
+ .bk-table .bk-table-head.has-group th {
1901
+ border-right: 1px solid var(--table-border-color);
1902
+ }
1903
+ .bk-table .bk-table-head.has-group th.is-last-child {
1904
+ border-right: none;
1905
+ }
1897
1906
  .bk-table .bk-table-head .col-resize-drag {
1898
1907
  position: absolute;
1899
1908
  top: 0;
@@ -1966,6 +1975,9 @@
1966
1975
  .bk-table.bordered-col .bk-table-head {
1967
1976
  border-right: 1px solid var(--table-border-color);
1968
1977
  }
1978
+ .bk-table.bordered-col .bk-table-head .is-head-group {
1979
+ border-bottom: 1px solid var(--table-border-color);
1980
+ }
1969
1981
  .bk-table.bordered-col th {
1970
1982
  border-right: 1px solid var(--table-border-color);
1971
1983
  }
@@ -6,7 +6,7 @@ import { Column, GroupColumn, ISortPropShape, TablePropTypes } from './props';
6
6
  * @param args 如果是函数,传递参数
7
7
  * @returns
8
8
  */
9
- export declare const resolvePropVal: (prop: any, key: string | string[], args: any[]) => any;
9
+ export declare const resolvePropVal: (prop: Record<string, unknown>, key: string | string[], args: unknown[]) => any;
10
10
  /**
11
11
  * 处理Props中的ActiveColumn,解析为统一的数组格式
12
12
  * @param props
@@ -159,4 +159,4 @@ export declare const getRawData: (data: any) => any;
159
159
  * @param parentVal
160
160
  * @returns
161
161
  */
162
- export declare const getNumberOrPercentValue: (val: string | number, parentVal?: number) => number;
162
+ export declare const getNumberOrPercentValue: (val: number | string, parentVal?: number) => number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkui-vue",
3
- "version": "2.0.1-beta.28",
3
+ "version": "2.0.1-beta.28.table.1",
4
4
  "workspaces": [
5
5
  "packages/**",
6
6
  "scripts/cli",