bkui-vue 2.1.0-dev-beta.1 → 2.1.0-dev-beta.3
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.js +35 -35
- package/dist/index.esm.js +5359 -5348
- package/dist/index.umd.js +39 -39
- package/dist/style.css +1 -1
- package/dist/style.variable.css +1 -1
- package/lib/index.js +1 -1
- package/lib/table/hooks/use-layout.d.ts +2 -1
- package/lib/table/index.js +50 -9
- package/lib/table/table.css +9 -2
- package/lib/table/table.d.ts +26 -0
- package/lib/table/table.less +14 -2
- package/lib/table/table.variable.css +9 -2
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -7,7 +7,8 @@ declare const _default: (props: TablePropTypes, ctx: any) => {
|
|
|
7
7
|
renderFooter: (childrend?: any) => JSX.Element;
|
|
8
8
|
renderFixedBottom: () => JSX.Element;
|
|
9
9
|
getBodyHeight: (height: any) => number;
|
|
10
|
-
setBodyHeight: (height: number, withHeadFoot?: boolean) => void;
|
|
10
|
+
setBodyHeight: (height: number | string, withHeadFoot?: boolean) => void;
|
|
11
|
+
setBodyScrollable: (scrollable: boolean) => void;
|
|
11
12
|
setVirtualBodyHeight: (height: number) => void;
|
|
12
13
|
setFootHeight: (height: number) => void;
|
|
13
14
|
setTranslateX: (val: number) => void;
|
package/lib/table/index.js
CHANGED
|
@@ -6140,6 +6140,13 @@ function use_layout_objectSpread(e) { for (var r = 1; r < arguments.length; r++)
|
|
|
6140
6140
|
var isMaxHeightNumericPx = /^\d+\.?\d*(px)?$/.test("".concat(props.maxHeight));
|
|
6141
6141
|
var needsFixedViewport = props.virtualEnabled || props.height === 'auto' && hasMaxConstraint && isMaxHeightNumericPx;
|
|
6142
6142
|
var bodyHeight = (0,external_vue_namespaceObject.ref)(needsFixedViewport ? '100%' : 'auto');
|
|
6143
|
+
// 当 height=auto + 非像素 maxHeight(如 calc(100vh-180px))时:
|
|
6144
|
+
// Chrome 的 scrollHeight/clientHeight 整数截断会在子像素内容高度下产生虚假滚动条。
|
|
6145
|
+
// 初始设为 false(overflow-y:hidden),JS 检测到内容超出 maxHeight 后再切换为 true(overflow-y:auto)。
|
|
6146
|
+
var bodyScrollable = (0,external_vue_namespaceObject.ref)(!hasMaxConstraint || needsFixedViewport);
|
|
6147
|
+
var setBodyScrollable = function setBodyScrollable(scrollable) {
|
|
6148
|
+
bodyScrollable.value = scrollable;
|
|
6149
|
+
};
|
|
6143
6150
|
var bodyMaxHeight = (0,external_vue_namespaceObject.computed)(function () {
|
|
6144
6151
|
var maxH = tableStyle.value.maxHeight;
|
|
6145
6152
|
if (!maxH || maxH === 'auto' || maxH === undefined) {
|
|
@@ -6152,6 +6159,10 @@ function use_layout_objectSpread(e) { for (var r = 1; r < arguments.length; r++)
|
|
|
6152
6159
|
};
|
|
6153
6160
|
var setBodyHeight = function setBodyHeight(height) {
|
|
6154
6161
|
var withHeadFoot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
6162
|
+
if (typeof height === 'string') {
|
|
6163
|
+
bodyHeight.value = height;
|
|
6164
|
+
return;
|
|
6165
|
+
}
|
|
6155
6166
|
if (withHeadFoot) {
|
|
6156
6167
|
bodyHeight.value = getBodyHeight(height);
|
|
6157
6168
|
return;
|
|
@@ -6250,7 +6261,9 @@ function use_layout_objectSpread(e) { for (var r = 1; r < arguments.length; r++)
|
|
|
6250
6261
|
}, [(0,external_vue_namespaceObject.createVNode)(virtual_render_namespaceObject["default"], {
|
|
6251
6262
|
"ref": refBody,
|
|
6252
6263
|
"height": bodyHeight.value,
|
|
6253
|
-
"class": bodyClass,
|
|
6264
|
+
"class": use_layout_objectSpread(use_layout_objectSpread({}, bodyClass), {}, {
|
|
6265
|
+
'is-overflow-hidden': !bodyScrollable.value
|
|
6266
|
+
}),
|
|
6254
6267
|
"contentClassName": scrollContentClass.value,
|
|
6255
6268
|
"enabled": props.virtualEnabled,
|
|
6256
6269
|
"lineHeight": lineHeight.value,
|
|
@@ -6302,6 +6315,7 @@ function use_layout_objectSpread(e) { for (var r = 1; r < arguments.length; r++)
|
|
|
6302
6315
|
renderFixedBottom: renderFixedBottom,
|
|
6303
6316
|
getBodyHeight: getBodyHeight,
|
|
6304
6317
|
setBodyHeight: setBodyHeight,
|
|
6318
|
+
setBodyScrollable: setBodyScrollable,
|
|
6305
6319
|
setVirtualBodyHeight: setVirtualBodyHeight,
|
|
6306
6320
|
setFootHeight: setFootHeight,
|
|
6307
6321
|
setTranslateX: setTranslateX,
|
|
@@ -8748,8 +8762,11 @@ function use_render_isSlot(s) {
|
|
|
8748
8762
|
var getRowRender = function getRowRender(row, rowIndex, preRow, rowList, rowSpanMap, needRowSpan) {
|
|
8749
8763
|
var isChild = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
8750
8764
|
var rowLength = rowList.length;
|
|
8751
|
-
var
|
|
8752
|
-
|
|
8765
|
+
var rowHeightPx = "".concat(getRowHeight(row, rowIndex), "px");
|
|
8766
|
+
var rowStyle = [].concat(_toConsumableArray(_formatPropAsArray(props.rowStyle, [row, rowIndex])), [props.rowHeight === 'auto' ? {
|
|
8767
|
+
'--row-min-height': rowHeightPx
|
|
8768
|
+
} : {
|
|
8769
|
+
'--row-height': rowHeightPx
|
|
8753
8770
|
}]);
|
|
8754
8771
|
var rowClass = [].concat(_toConsumableArray(_formatPropAsArray(props.rowClass, [row, rowIndex])), ["hover-".concat(props.rowHover), rowIndex % 2 === 1 && props.stripe ? 'stripe-row' : '', props.rowHeight === 'auto' ? 'row-height-auto' : '']);
|
|
8755
8772
|
var rowId = rows.getRowAttribute(row, const_TABLE_ROW_ATTRIBUTE.ROW_UID);
|
|
@@ -9725,6 +9742,7 @@ var useSettings = function useSettings(props, ctx, columns, afterSetting) {
|
|
|
9725
9742
|
renderBody = _useLayout.renderBody,
|
|
9726
9743
|
renderFooter = _useLayout.renderFooter,
|
|
9727
9744
|
setBodyHeight = _useLayout.setBodyHeight,
|
|
9745
|
+
setBodyScrollable = _useLayout.setBodyScrollable,
|
|
9728
9746
|
setFootHeight = _useLayout.setFootHeight,
|
|
9729
9747
|
setDragOffsetX = _useLayout.setDragOffsetX,
|
|
9730
9748
|
setOffsetRight = _useLayout.setOffsetRight,
|
|
@@ -9742,6 +9760,9 @@ var useSettings = function useSettings(props, ctx, columns, afterSetting) {
|
|
|
9742
9760
|
}
|
|
9743
9761
|
return (_refBody$value = refBody.value) === null || _refBody$value === void 0 ? void 0 : _refBody$value.scrollTo.apply(_refBody$value, args);
|
|
9744
9762
|
};
|
|
9763
|
+
if (props.rowHeight === 'auto' && props.virtualEnabled) {
|
|
9764
|
+
console.warn('[BkTable] rowHeight="auto" 与 virtualEnabled 不兼容:虚拟滚动依赖固定行高计算,auto 模式下行高由内容决定,滚动位置将不准确。请勿同时使用。');
|
|
9765
|
+
}
|
|
9745
9766
|
if (typeof props.rowHeight === 'function') {
|
|
9746
9767
|
setLineHeight(function (args) {
|
|
9747
9768
|
return rows.getRowHeight(args.rows[0], args.index);
|
|
@@ -9899,14 +9920,22 @@ var useSettings = function useSettings(props, ctx, columns, afterSetting) {
|
|
|
9899
9920
|
* 滚动容器 (.bk-table-body) 内包含:
|
|
9900
9921
|
* 1. 表头 — 由 showHead 控制是否展示,高度 = headHeight(受 headHeight/thead props) × headerRowCount(多级表头)
|
|
9901
9922
|
* 2. 数据行 — 高度 = 各行行高之和(受 rowHeight prop 和行数据影响)
|
|
9923
|
+
*
|
|
9924
|
+
* rowHeight='auto' 时每行 schema 存储的是估算值(LINE_HEIGHT=42),
|
|
9925
|
+
* 不反映实际渲染高度,故改为从 DOM 读取 scrollHeight 获得真实内容高度。
|
|
9902
9926
|
*/
|
|
9903
9927
|
var getScrollContentHeight = function getScrollContentHeight() {
|
|
9928
|
+
var _refBody$value3;
|
|
9929
|
+
var scrollEl = (_refBody$value3 = refBody.value) === null || _refBody$value3 === void 0 ? void 0 : _refBody$value3.refRoot;
|
|
9930
|
+
if (props.rowHeight === 'auto') {
|
|
9931
|
+
if (scrollEl && scrollEl.scrollHeight > 0) {
|
|
9932
|
+
return scrollEl.scrollHeight;
|
|
9933
|
+
}
|
|
9934
|
+
}
|
|
9904
9935
|
var rowsHeight = rows.getCurrentPageRowsHeight();
|
|
9905
9936
|
var scrollHeaderHeight = props.showHead ? headHeight.value : 0;
|
|
9906
9937
|
var calculatedHeight = rowsHeight + scrollHeaderHeight;
|
|
9907
9938
|
if (rows.pageRowList.length === 0) {
|
|
9908
|
-
var _refBody$value3;
|
|
9909
|
-
var scrollEl = (_refBody$value3 = refBody.value) === null || _refBody$value3 === void 0 ? void 0 : _refBody$value3.refRoot;
|
|
9910
9939
|
if (scrollEl && scrollEl.scrollHeight > calculatedHeight) {
|
|
9911
9940
|
return scrollEl.scrollHeight;
|
|
9912
9941
|
}
|
|
@@ -9943,9 +9972,12 @@ var useSettings = function useSettings(props, ctx, columns, afterSetting) {
|
|
|
9943
9972
|
* 可用空间 = getMaxContainerHeight() - 分页器(paginationHeight) - fixedBottom - 边框
|
|
9944
9973
|
* 由 getBodyHeight 统一计算,内部已根据各 props 动态得出
|
|
9945
9974
|
*
|
|
9946
|
-
*
|
|
9947
|
-
*
|
|
9948
|
-
*
|
|
9975
|
+
* 内容 < 可用空间 → bodyHeight 保持 'auto',由 CSS 自然撑高,避免整数截断导致的伪滚动条
|
|
9976
|
+
* 内容 ≥ 可用空间 → 设置固定 px 高度,触发真实滚动
|
|
9977
|
+
*
|
|
9978
|
+
* 之所以不用 Math.min(contentHeight, availableHeight):
|
|
9979
|
+
* 行高为 auto 时内容高度有小数(如 589.33px),JS scrollHeight 向上取整为 590,
|
|
9980
|
+
* 若强制 bodyHeight = 589(整数),则 clientHeight(589) < scrollHeight(590) 产生假滚动条。
|
|
9949
9981
|
*/
|
|
9950
9982
|
var resolveContentAwareBodyHeight = function resolveContentAwareBodyHeight() {
|
|
9951
9983
|
var containerHeight = getMaxContainerHeight();
|
|
@@ -9953,7 +9985,16 @@ var useSettings = function useSettings(props, ctx, columns, afterSetting) {
|
|
|
9953
9985
|
var contentHeight = getScrollContentHeight();
|
|
9954
9986
|
var availableHeight = getBodyHeight(containerHeight);
|
|
9955
9987
|
if (availableHeight > 0 && contentHeight > 0) {
|
|
9956
|
-
|
|
9988
|
+
if (contentHeight >= availableHeight) {
|
|
9989
|
+
// 内容超出最大高度:固定 body 高度 + 开启 overflow-y:auto,触发真实滚动
|
|
9990
|
+
setBodyScrollable(true);
|
|
9991
|
+
setBodyHeight(availableHeight, false);
|
|
9992
|
+
} else {
|
|
9993
|
+
// 内容未超出:重置为 auto + 关闭 overflow-y(hidden),
|
|
9994
|
+
// 阻止 Chrome scrollHeight/clientHeight 整数截断产生的 1px 虚假滚动条
|
|
9995
|
+
setBodyScrollable(false);
|
|
9996
|
+
setBodyHeight('auto', false);
|
|
9997
|
+
}
|
|
9957
9998
|
return true;
|
|
9958
9999
|
}
|
|
9959
10000
|
return false;
|
package/lib/table/table.css
CHANGED
|
@@ -1117,6 +1117,9 @@
|
|
|
1117
1117
|
.bk-table .bk-table-body.is-bk-scrollbar {
|
|
1118
1118
|
overflow: hidden;
|
|
1119
1119
|
}
|
|
1120
|
+
.bk-table .bk-table-body.is-overflow-hidden {
|
|
1121
|
+
overflow-y: hidden !important;
|
|
1122
|
+
}
|
|
1120
1123
|
.bk-table .bk-table-body-wrapper {
|
|
1121
1124
|
position: relative;
|
|
1122
1125
|
width: 100%;
|
|
@@ -1449,14 +1452,18 @@
|
|
|
1449
1452
|
.bk-table .bk-table-head table tbody tr.row-height-auto td,
|
|
1450
1453
|
.bk-table .bk-table-body table tbody tr.row-height-auto td {
|
|
1451
1454
|
height: auto !important;
|
|
1452
|
-
min-height: var(--row-height);
|
|
1455
|
+
min-height: var(--row-min-height, 42px);
|
|
1453
1456
|
}
|
|
1454
1457
|
.bk-table .bk-table-head table tbody tr.row-height-auto td .cell,
|
|
1455
1458
|
.bk-table .bk-table-body table tbody tr.row-height-auto td .cell {
|
|
1456
1459
|
display: flex;
|
|
1457
1460
|
align-items: center;
|
|
1458
1461
|
height: auto;
|
|
1459
|
-
min-height: calc(var(--row-height) - 4px);
|
|
1462
|
+
min-height: calc(var(--row-min-height, 42px) - 4px);
|
|
1463
|
+
white-space: normal;
|
|
1464
|
+
overflow: visible;
|
|
1465
|
+
text-overflow: unset;
|
|
1466
|
+
word-break: break-word;
|
|
1460
1467
|
line-height: normal;
|
|
1461
1468
|
}
|
|
1462
1469
|
.bk-table .bk-table-head table tbody tr:hover.hover-highlight td:not(.empty-cell),
|
package/lib/table/table.d.ts
CHANGED
|
@@ -12,6 +12,19 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
12
12
|
height: import("vue-types").VueTypeDef<string | number> & {
|
|
13
13
|
default: string | number;
|
|
14
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* 计算 height="auto" + maxHeight 模式下滚动容器的高度
|
|
17
|
+
*
|
|
18
|
+
* 可用空间 = getMaxContainerHeight() - 分页器(paginationHeight) - fixedBottom - 边框
|
|
19
|
+
* 由 getBodyHeight 统一计算,内部已根据各 props 动态得出
|
|
20
|
+
*
|
|
21
|
+
* 内容 < 可用空间 → bodyHeight 保持 'auto',由 CSS 自然撑高,避免整数截断导致的伪滚动条
|
|
22
|
+
* 内容 ≥ 可用空间 → 设置固定 px 高度,触发真实滚动
|
|
23
|
+
*
|
|
24
|
+
* 之所以不用 Math.min(contentHeight, availableHeight):
|
|
25
|
+
* 行高为 auto 时内容高度有小数(如 589.33px),JS scrollHeight 向上取整为 590,
|
|
26
|
+
* 若强制 bodyHeight = 589(整数),则 clientHeight(589) < scrollHeight(590) 产生假滚动条。
|
|
27
|
+
*/
|
|
15
28
|
stripe: import("vue-types").VueTypeValidableDef<boolean> & {
|
|
16
29
|
default: boolean;
|
|
17
30
|
} & {
|
|
@@ -190,6 +203,19 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
190
203
|
height: import("vue-types").VueTypeDef<string | number> & {
|
|
191
204
|
default: string | number;
|
|
192
205
|
};
|
|
206
|
+
/**
|
|
207
|
+
* 计算 height="auto" + maxHeight 模式下滚动容器的高度
|
|
208
|
+
*
|
|
209
|
+
* 可用空间 = getMaxContainerHeight() - 分页器(paginationHeight) - fixedBottom - 边框
|
|
210
|
+
* 由 getBodyHeight 统一计算,内部已根据各 props 动态得出
|
|
211
|
+
*
|
|
212
|
+
* 内容 < 可用空间 → bodyHeight 保持 'auto',由 CSS 自然撑高,避免整数截断导致的伪滚动条
|
|
213
|
+
* 内容 ≥ 可用空间 → 设置固定 px 高度,触发真实滚动
|
|
214
|
+
*
|
|
215
|
+
* 之所以不用 Math.min(contentHeight, availableHeight):
|
|
216
|
+
* 行高为 auto 时内容高度有小数(如 589.33px),JS scrollHeight 向上取整为 590,
|
|
217
|
+
* 若强制 bodyHeight = 589(整数),则 clientHeight(589) < scrollHeight(590) 产生假滚动条。
|
|
218
|
+
*/
|
|
193
219
|
stripe: import("vue-types").VueTypeValidableDef<boolean> & {
|
|
194
220
|
default: boolean;
|
|
195
221
|
} & {
|
package/lib/table/table.less
CHANGED
|
@@ -37,6 +37,12 @@
|
|
|
37
37
|
overflow: hidden;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
// height=auto + 非像素 maxHeight 时,内容未超出 maxHeight:
|
|
41
|
+
// 阻止 Chrome scrollHeight/clientHeight 整数截断产生的 1px 虚假垂直滚动条
|
|
42
|
+
&.is-overflow-hidden {
|
|
43
|
+
overflow-y: hidden !important;
|
|
44
|
+
}
|
|
45
|
+
|
|
40
46
|
}
|
|
41
47
|
|
|
42
48
|
// body overlay wrapper(让 overlay 不参与原生滚动)
|
|
@@ -406,14 +412,20 @@
|
|
|
406
412
|
&.row-height-auto {
|
|
407
413
|
td {
|
|
408
414
|
// 覆盖全局 th, td { height: var(--row-height) },让内容撑起行高
|
|
415
|
+
// auto 模式使用独立的 --row-min-height 变量,语义上明确表示最小高度而非固定高度
|
|
409
416
|
height: auto !important;
|
|
410
|
-
min-height: var(--row-height);
|
|
417
|
+
min-height: var(--row-min-height, 42px);
|
|
411
418
|
|
|
412
419
|
.cell {
|
|
413
420
|
display: flex;
|
|
414
421
|
align-items: center;
|
|
415
422
|
height: auto;
|
|
416
|
-
min-height: calc(var(--row-height) - 4px);
|
|
423
|
+
min-height: calc(var(--row-min-height, 42px) - 4px);
|
|
424
|
+
// 允许文字换行,覆盖全局 white-space: nowrap / overflow: hidden / text-overflow: ellipsis
|
|
425
|
+
white-space: normal;
|
|
426
|
+
overflow: visible;
|
|
427
|
+
text-overflow: unset;
|
|
428
|
+
word-break: break-word;
|
|
417
429
|
line-height: normal;
|
|
418
430
|
}
|
|
419
431
|
}
|
|
@@ -1248,6 +1248,9 @@
|
|
|
1248
1248
|
.bk-table .bk-table-body.is-bk-scrollbar {
|
|
1249
1249
|
overflow: hidden;
|
|
1250
1250
|
}
|
|
1251
|
+
.bk-table .bk-table-body.is-overflow-hidden {
|
|
1252
|
+
overflow-y: hidden !important;
|
|
1253
|
+
}
|
|
1251
1254
|
.bk-table .bk-table-body-wrapper {
|
|
1252
1255
|
position: relative;
|
|
1253
1256
|
width: 100%;
|
|
@@ -1580,14 +1583,18 @@
|
|
|
1580
1583
|
.bk-table .bk-table-head table tbody tr.row-height-auto td,
|
|
1581
1584
|
.bk-table .bk-table-body table tbody tr.row-height-auto td {
|
|
1582
1585
|
height: auto !important;
|
|
1583
|
-
min-height: var(--row-height);
|
|
1586
|
+
min-height: var(--row-min-height, 42px);
|
|
1584
1587
|
}
|
|
1585
1588
|
.bk-table .bk-table-head table tbody tr.row-height-auto td .cell,
|
|
1586
1589
|
.bk-table .bk-table-body table tbody tr.row-height-auto td .cell {
|
|
1587
1590
|
display: flex;
|
|
1588
1591
|
align-items: center;
|
|
1589
1592
|
height: auto;
|
|
1590
|
-
min-height: calc(var(--row-height) - 4px);
|
|
1593
|
+
min-height: calc(var(--row-min-height, 42px) - 4px);
|
|
1594
|
+
white-space: normal;
|
|
1595
|
+
overflow: visible;
|
|
1596
|
+
text-overflow: unset;
|
|
1597
|
+
word-break: break-word;
|
|
1591
1598
|
line-height: normal;
|
|
1592
1599
|
}
|
|
1593
1600
|
.bk-table .bk-table-head table tbody tr:hover.hover-highlight td:not(.empty-cell),
|