one-design-next 0.0.50 → 0.0.51
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/table/index.d.ts +12 -1
- package/dist/table/index.js +19 -4
- package/dist/table/style/index.css +26 -0
- package/package.json +1 -1
package/dist/table/index.d.ts
CHANGED
|
@@ -93,6 +93,17 @@ export interface TableProps<T = Record<string, unknown>> extends Omit<RcTablePro
|
|
|
93
93
|
colIndex: number;
|
|
94
94
|
}) => ReturnType<NonNullable<RcColumnType<T>['onHeaderCell']>> | void;
|
|
95
95
|
popoverIcon?: (typeof iconNames)[number];
|
|
96
|
+
/**
|
|
97
|
+
* 是否启用虚拟滚动。启用时需要同时设置 scroll.y 为数值(表示可视区域高度)。
|
|
98
|
+
* 当数据量较大时(如超过 1000 行),推荐开启虚拟滚动以提升性能。
|
|
99
|
+
*/
|
|
100
|
+
virtual?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* 虚拟滚动每行高度(px),用于计算可视区域内显示的行数。
|
|
103
|
+
* 仅在 virtual 为 true 时生效。
|
|
104
|
+
* @default 24
|
|
105
|
+
*/
|
|
106
|
+
listItemHeight?: number;
|
|
96
107
|
}
|
|
97
|
-
declare const Table: <T extends Record<string, unknown> = Record<string, unknown>>({ dataSource, columns, bordered, striped, loading, rowExpansion, rowSelection, sortBgVisible, getCellProps, getHeaderCellProps, popoverIcon: globalPopoverIcon, className, style, emptyText, ...props }: TableProps<T>) => React.JSX.Element;
|
|
108
|
+
declare const Table: <T extends Record<string, unknown> = Record<string, unknown>>({ dataSource, columns, bordered, striped, loading, rowExpansion, rowSelection, sortBgVisible, getCellProps, getHeaderCellProps, popoverIcon: globalPopoverIcon, className, style, emptyText, virtual, listItemHeight, ...props }: TableProps<T>) => React.JSX.Element;
|
|
98
109
|
export default Table;
|
package/dist/table/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
var _excluded = ["dataSource", "columns", "bordered", "striped", "loading", "rowExpansion", "rowSelection", "sortBgVisible", "getCellProps", "getHeaderCellProps", "popoverIcon", "className", "style", "emptyText"],
|
|
2
|
+
var _excluded = ["dataSource", "columns", "bordered", "striped", "loading", "rowExpansion", "rowSelection", "sortBgVisible", "getCellProps", "getHeaderCellProps", "popoverIcon", "className", "style", "emptyText", "virtual", "listItemHeight"],
|
|
3
3
|
_excluded2 = ["onSort", "title", "popover", "popoverProps", "popoverIcon"],
|
|
4
4
|
_excluded3 = ["onSort", "filters", "filteredValue", "filterMultiple", "onFilter", "onFilterChange", "title", "popover", "popoverProps", "popoverIcon", "ellipsisPopoverProps", "sortOrder", "render"];
|
|
5
5
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -16,7 +16,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
16
16
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
17
17
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
18
18
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
19
|
-
import RcTable from 'rc-table';
|
|
19
|
+
import RcTable, { VirtualTable as RcVirtualTable } from 'rc-table';
|
|
20
20
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
21
21
|
import Button from "../button";
|
|
22
22
|
import Checkbox from "../checkbox";
|
|
@@ -113,6 +113,7 @@ var FilterComponent = function FilterComponent(_ref) {
|
|
|
113
113
|
}, "\u786E\u5B9A")));
|
|
114
114
|
};
|
|
115
115
|
var Table = function Table(_ref2) {
|
|
116
|
+
var _props$scroll, _props$scroll2;
|
|
116
117
|
var dataSource = _ref2.dataSource,
|
|
117
118
|
columns = _ref2.columns,
|
|
118
119
|
_ref2$bordered = _ref2.bordered,
|
|
@@ -131,6 +132,8 @@ var Table = function Table(_ref2) {
|
|
|
131
132
|
className = _ref2.className,
|
|
132
133
|
style = _ref2.style,
|
|
133
134
|
emptyText = _ref2.emptyText,
|
|
135
|
+
virtual = _ref2.virtual,
|
|
136
|
+
listItemHeight = _ref2.listItemHeight,
|
|
134
137
|
props = _objectWithoutProperties(_ref2, _excluded);
|
|
135
138
|
// 渲染带 popover 的标题
|
|
136
139
|
var renderTitleWithPopover = function renderTitleWithPopover(titleContent, popover, popoverProps, popoverIcon) {
|
|
@@ -492,6 +495,12 @@ var Table = function Table(_ref2) {
|
|
|
492
495
|
// 1. 行选择
|
|
493
496
|
// 2. 行展开
|
|
494
497
|
var trClickable = (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.selectOnRowClick) || (rowExpansion === null || rowExpansion === void 0 ? void 0 : rowExpansion.expandOnRowClick);
|
|
498
|
+
|
|
499
|
+
// 虚拟模式使用 RcVirtualTable,否则使用 RcTable。
|
|
500
|
+
// 由于两者 props 类型存在差异(VirtualTableProps 重新定义了 scroll),
|
|
501
|
+
// 这里统一断言为 RcTable 类型,虚拟模式的专属 props 通过末尾的 spread 覆盖传入。
|
|
502
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
503
|
+
var TableComponent = virtual ? RcVirtualTable : RcTable;
|
|
495
504
|
return /*#__PURE__*/React.createElement("div", {
|
|
496
505
|
ref: tableRef,
|
|
497
506
|
"data-odn-table": true,
|
|
@@ -501,7 +510,7 @@ var Table = function Table(_ref2) {
|
|
|
501
510
|
"data-odn-table-loading": loading,
|
|
502
511
|
className: className,
|
|
503
512
|
style: style
|
|
504
|
-
}, /*#__PURE__*/React.createElement(
|
|
513
|
+
}, /*#__PURE__*/React.createElement(TableComponent, _extends({
|
|
505
514
|
prefixCls: "odn-table",
|
|
506
515
|
data: dataSource,
|
|
507
516
|
columns: finalColumns,
|
|
@@ -857,6 +866,12 @@ var Table = function Table(_ref2) {
|
|
|
857
866
|
offset: "1",
|
|
858
867
|
stopColor: "#C4C7CC"
|
|
859
868
|
})))), "\u6570\u636E\u4E3A\u7A7A")
|
|
860
|
-
}, props
|
|
869
|
+
}, props, virtual ? {
|
|
870
|
+
scroll: {
|
|
871
|
+
x: (_props$scroll = props.scroll) === null || _props$scroll === void 0 ? void 0 : _props$scroll.x,
|
|
872
|
+
y: (_props$scroll2 = props.scroll) === null || _props$scroll2 === void 0 ? void 0 : _props$scroll2.y
|
|
873
|
+
},
|
|
874
|
+
listItemHeight: listItemHeight
|
|
875
|
+
} : {})));
|
|
861
876
|
};
|
|
862
877
|
export default Table;
|
|
@@ -342,4 +342,30 @@ tr > .odn-table-cell:last-child {
|
|
|
342
342
|
height: 0;
|
|
343
343
|
overflow: hidden;
|
|
344
344
|
pointer-events: none;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.odn-table-placeholder .odn-table-expanded-row-fixed {
|
|
348
|
+
width: 100% !important;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
.odn-table-tbody-virtual {
|
|
352
|
+
font-size: var(--odn-font-size);
|
|
353
|
+
line-height: var(--odn-line-height);
|
|
354
|
+
}
|
|
355
|
+
.odn-table-tbody-virtual .odn-table-row {
|
|
356
|
+
display: flex;
|
|
357
|
+
}
|
|
358
|
+
.odn-table-tbody-virtual .odn-table-row-extra {
|
|
359
|
+
position: absolute;
|
|
360
|
+
display: flex;
|
|
361
|
+
}
|
|
362
|
+
.odn-table-tbody-virtual .odn-table-cell {
|
|
363
|
+
box-sizing: border-box;
|
|
364
|
+
border-bottom: 1px solid var(--odn-table-border-color);
|
|
365
|
+
}
|
|
366
|
+
.odn-table-tbody-virtual .odn-table-row > .odn-table-cell:first-child {
|
|
367
|
+
padding-left: var(--odn-table-cell-first-padding-x-start);
|
|
368
|
+
}
|
|
369
|
+
.odn-table-tbody-virtual .odn-table-row > .odn-table-cell:last-child {
|
|
370
|
+
padding-right: var(--odn-table-cell-last-padding-x-end);
|
|
345
371
|
}
|