@are-visual/virtual-table 0.5.2 → 0.7.0
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/index.d.ts +5 -2
- package/index.esm.js +25 -23
- package/index.esm.js.map +1 -1
- package/middleware/column-resize/index.d.ts +2 -1
- package/middleware/empty/index.d.ts +2 -1
- package/middleware/expandable/index.d.ts +3 -2
- package/middleware/horizontal-scroll-bar/index.d.ts +2 -1
- package/middleware/loading/index.js +1 -1
- package/middleware/selection/index.d.ts +3 -2
- package/middleware/summary/index.d.ts +18 -5
- package/middleware/summary/index.js +30 -6
- package/middleware/summary/index.js.map +1 -1
- package/middleware/summary/styles.css +2 -2
- package/middleware/summary/styles.scss +4 -2
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Key, ReactNode, HTMLAttributes, TdHTMLAttributes, DetailedHTMLProps, RefObject, ReactElement, CSSProperties, Ref, RefAttributes } from 'react';
|
|
3
3
|
|
|
4
4
|
type ScrollElement = HTMLElement | Window;
|
|
5
5
|
declare function getScrollParent(el: Element, root?: ScrollElement | null | undefined): ScrollElement;
|
|
@@ -75,10 +75,12 @@ interface MiddlewareContext<T> extends Readonly<NecessaryProps<T>> {
|
|
|
75
75
|
readonly bodyRef: RefObject<HTMLTableSectionElement>;
|
|
76
76
|
readonly getScroller: () => ScrollElement | undefined;
|
|
77
77
|
readonly getOffsetTop: () => number;
|
|
78
|
+
[key: string]: unknown;
|
|
78
79
|
}
|
|
79
80
|
interface MiddlewareResult<T> extends MiddlewareContext<T>, MiddlewareRenders {
|
|
80
81
|
rowClassName?: (record: T, index: number) => string;
|
|
81
82
|
onRow?: OnRowType<T>;
|
|
83
|
+
[key: string]: unknown;
|
|
82
84
|
}
|
|
83
85
|
type Middleware<T> = (context: MiddlewareContext<T>) => MiddlewareResult<T>;
|
|
84
86
|
interface RenderOptions<T = any> {
|
|
@@ -340,4 +342,5 @@ type PossibleRef<T> = Ref<T> | undefined;
|
|
|
340
342
|
declare function mergeRefs<T>(...refs: PossibleRef<T>[]): (node: T | null) => void;
|
|
341
343
|
declare function useMergedRef<T>(...refs: PossibleRef<T>[]): (node: T | null) => void;
|
|
342
344
|
|
|
343
|
-
export {
|
|
345
|
+
export { _default$2 as Colgroup, TablePipeline, _default as VirtualTable, _default$3 as VirtualTableCell, _default$1 as VirtualTableRow, createMiddleware, findLastIndex, getKey, getRelativeOffsetTop, getRowKey, getScrollElement, getScrollParent, getScrollTop, isDocument, isRoot, isValidFixed, isValidFixedLeft, isValidFixedRight, isWindow, mergeRefs, onResize, useColumnSizes, useContainerSize, useHorizontalScrollContext, useMergedRef, useShallowMemo, useStableFn, useTablePipeline, useTableRowManager, useTableSticky };
|
|
346
|
+
export type { AlignType, AnyObject, ColumnDescriptor, ColumnExtra, ColumnType, ContainerSizeState, FixedType, HorizontalScrollContextState, MergedMiddlewareRender, Middleware, MiddlewareContext, MiddlewareRender, MiddlewareRenderBody, MiddlewareRenderBodyContent, MiddlewareRenderBodyRoot, MiddlewareRenderBodyWrapper, MiddlewareRenderCell, MiddlewareRenderContent, MiddlewareRenderHeader, MiddlewareRenderHeaderCell, MiddlewareRenderHeaderRoot, MiddlewareRenderHeaderRow, MiddlewareRenderHeaderWrapper, MiddlewareRenderRoot, MiddlewareRenderRow, MiddlewareRenders, MiddlewareResult, OnRowType, PipelineRender, PipelineRenderOptions, ScrollElement, StickyContextState, TableColumnsContextType, TableRowManagerContextType, UseTablePipelineOptions, CellProps as VirtualTableCellProps, VirtualTableCoreProps as VirtualTableProps, RowProps as VirtualTableRowProps };
|
package/index.esm.js
CHANGED
|
@@ -15,7 +15,7 @@ function _objectWithoutPropertiesLoose(r, e) {
|
|
|
15
15
|
if (null == r) return {};
|
|
16
16
|
var t = {};
|
|
17
17
|
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
18
|
-
if (e.
|
|
18
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
19
19
|
t[n] = r[n];
|
|
20
20
|
}
|
|
21
21
|
return t;
|
|
@@ -251,7 +251,7 @@ function getTableCellContent(index, data, column) {
|
|
|
251
251
|
}
|
|
252
252
|
return render(rowData[dataIndex], data, index);
|
|
253
253
|
}
|
|
254
|
-
return (_render = render == null ?
|
|
254
|
+
return (_render = render == null ? void 0 : render(data, data, index)) != null ? _render : null;
|
|
255
255
|
}
|
|
256
256
|
function Cell(props) {
|
|
257
257
|
var _onCell;
|
|
@@ -268,7 +268,7 @@ function Cell(props) {
|
|
|
268
268
|
var key = getKey(column);
|
|
269
269
|
var _useTableSticky = useTableSticky(),
|
|
270
270
|
stickySizes = _useTableSticky.size;
|
|
271
|
-
var _ref = (_onCell = onCell == null ?
|
|
271
|
+
var _ref = (_onCell = onCell == null ? void 0 : onCell(rowData, rowIndex)) != null ? _onCell : {},
|
|
272
272
|
extraClassName = _ref.className,
|
|
273
273
|
extraStyle = _ref.style,
|
|
274
274
|
colSpan = _ref.colSpan,
|
|
@@ -285,6 +285,7 @@ function Cell(props) {
|
|
|
285
285
|
left: isValidFixedLeft(fixed) ? stickySizes.get(key) : undefined,
|
|
286
286
|
right: isValidFixedRight(fixed) ? stickySizes.get(key) : undefined
|
|
287
287
|
}),
|
|
288
|
+
"data-col-key": key,
|
|
288
289
|
children: getTableCellContent(rowIndex, rowData, column)
|
|
289
290
|
})), renderCell, {
|
|
290
291
|
column: column
|
|
@@ -342,7 +343,7 @@ function isElement(node) {
|
|
|
342
343
|
}
|
|
343
344
|
function getScrollParent(el, root) {
|
|
344
345
|
var _el$ownerDocument$def;
|
|
345
|
-
if (root ===
|
|
346
|
+
if (root === void 0) {
|
|
346
347
|
root = window;
|
|
347
348
|
}
|
|
348
349
|
var node = el;
|
|
@@ -568,7 +569,7 @@ function useStableFn(callback) {
|
|
|
568
569
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
569
570
|
args[_key] = arguments[_key];
|
|
570
571
|
}
|
|
571
|
-
return fn.current == null ?
|
|
572
|
+
return fn.current == null ? void 0 : fn.current.apply(fn, args);
|
|
572
573
|
}, []);
|
|
573
574
|
return stableFn;
|
|
574
575
|
}
|
|
@@ -586,7 +587,7 @@ function createMiddleware(hook) {
|
|
|
586
587
|
options[_key] = arguments[_key];
|
|
587
588
|
}
|
|
588
589
|
var useMiddleware = function useMiddleware(ctx) {
|
|
589
|
-
return hook.apply(
|
|
590
|
+
return hook.apply(void 0, [ctx].concat(options));
|
|
590
591
|
};
|
|
591
592
|
if (isShallowEqual(options, cache.options)) {
|
|
592
593
|
var _cache$current;
|
|
@@ -711,7 +712,7 @@ var TablePipeline = /*#__PURE__*/function () {
|
|
|
711
712
|
});
|
|
712
713
|
if (rowClassNameFunctions.length > 0) {
|
|
713
714
|
context.current.rowClassName = function (record, index) {
|
|
714
|
-
return clsx.apply(
|
|
715
|
+
return clsx.apply(void 0, rowClassNameFunctions.map(function (fn) {
|
|
715
716
|
return fn(record, index);
|
|
716
717
|
}));
|
|
717
718
|
};
|
|
@@ -744,7 +745,7 @@ function useTablePipeline(options) {
|
|
|
744
745
|
}, []);
|
|
745
746
|
if (use != null) {
|
|
746
747
|
var _extraPipeline$hooks;
|
|
747
|
-
var nextHooks = shakeUnsafeHooks([].concat(use, (_extraPipeline$hooks = extraPipeline == null ?
|
|
748
|
+
var nextHooks = shakeUnsafeHooks([].concat(use, (_extraPipeline$hooks = extraPipeline == null ? void 0 : extraPipeline.hooks) != null ? _extraPipeline$hooks : []));
|
|
748
749
|
if (!shallowEqualArrays(cached.current.hooks, nextHooks)) {
|
|
749
750
|
var pipeline = new TablePipeline();
|
|
750
751
|
pipeline.setHooks(nextHooks);
|
|
@@ -793,11 +794,12 @@ function Row(props) {
|
|
|
793
794
|
}
|
|
794
795
|
return isValidFixedRight(x.column.fixed);
|
|
795
796
|
});
|
|
796
|
-
var _ref = (_onRow = onRow == null ?
|
|
797
|
+
var _ref = (_onRow = onRow == null ? void 0 : onRow(rowData, rowIndex)) != null ? _onRow : {},
|
|
797
798
|
extraClassName = _ref.className,
|
|
798
799
|
extraProps = _objectWithoutPropertiesLoose(_ref, _excluded2);
|
|
799
800
|
return pipelineRender(jsx("tr", _extends({}, rest, extraProps, {
|
|
800
801
|
className: clsx('virtual-table-row', className, extraClassName),
|
|
802
|
+
"data-row-index": rowIndex,
|
|
801
803
|
ref: function ref(node) {
|
|
802
804
|
if (node == null) return;
|
|
803
805
|
// 小心陷阱:当 table 父元素为 display: none 时,依然会触发 updateRowHeight 函数,并设置高度为 0
|
|
@@ -848,7 +850,7 @@ function useMergedRef() {
|
|
|
848
850
|
refs[_key2] = arguments[_key2];
|
|
849
851
|
}
|
|
850
852
|
// eslint-disable-next-line react-compiler/react-compiler
|
|
851
|
-
return useCallback(mergeRefs.apply(
|
|
853
|
+
return useCallback(mergeRefs.apply(void 0, refs), refs);
|
|
852
854
|
}
|
|
853
855
|
|
|
854
856
|
function onResize(target, callback) {
|
|
@@ -929,7 +931,7 @@ function useRowVirtualize(options) {
|
|
|
929
931
|
// 布局信息(也就是锚点元素需要的信息,top,bottom,height,index)
|
|
930
932
|
var rowRects = useRef([]);
|
|
931
933
|
var updateRowRectList = function updateRowRectList(shouldSkip) {
|
|
932
|
-
if (shouldSkip ===
|
|
934
|
+
if (shouldSkip === void 0) {
|
|
933
935
|
shouldSkip = false;
|
|
934
936
|
}
|
|
935
937
|
if (shouldSkip && rowRects.current.length > 0) {
|
|
@@ -1138,7 +1140,7 @@ function TableBody(props) {
|
|
|
1138
1140
|
var bodyContent = pipelineRender(dataSource.map(function (e, rowIndex) {
|
|
1139
1141
|
var key = getRowKey(e, rowKey);
|
|
1140
1142
|
return jsx(Row$1, {
|
|
1141
|
-
className: clsx(rowClassName == null ?
|
|
1143
|
+
className: clsx(rowClassName == null ? void 0 : rowClassName(e, rowIndex)),
|
|
1142
1144
|
rowIndex: rowIndex + startIndex,
|
|
1143
1145
|
rowData: e,
|
|
1144
1146
|
columns: columnDescriptor,
|
|
@@ -1287,7 +1289,7 @@ var TableHeader = function TableHeader(props) {
|
|
|
1287
1289
|
return null;
|
|
1288
1290
|
}
|
|
1289
1291
|
var isLast = getKey(lastColumn) === key;
|
|
1290
|
-
var _ref = (_column$onHeaderCell = column.onHeaderCell == null ?
|
|
1292
|
+
var _ref = (_column$onHeaderCell = column.onHeaderCell == null ? void 0 : column.onHeaderCell(column, index)) != null ? _column$onHeaderCell : {},
|
|
1291
1293
|
thClassName = _ref.className,
|
|
1292
1294
|
thStyle = _ref.style,
|
|
1293
1295
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
@@ -1389,7 +1391,7 @@ function useColumnVirtualize(options) {
|
|
|
1389
1391
|
bodyWrapper = options.bodyWrapper,
|
|
1390
1392
|
columnWidths = options.columnWidths,
|
|
1391
1393
|
_options$disabled = options.disabled,
|
|
1392
|
-
disabled = _options$disabled ===
|
|
1394
|
+
disabled = _options$disabled === void 0 ? false : _options$disabled;
|
|
1393
1395
|
var lastFixedLeftIndex = findLastFixedLeftIndex(rawColumns);
|
|
1394
1396
|
var firstFixedRightIndex = findFirstFixedRightIndex(rawColumns);
|
|
1395
1397
|
var leftKey = lastFixedLeftIndex > -1 ? getKey(rawColumns[lastFixedLeftIndex]) : null;
|
|
@@ -1639,24 +1641,24 @@ function VirtualTableCore(props, ref) {
|
|
|
1639
1641
|
rawColumns = props.columns,
|
|
1640
1642
|
rawData = props.dataSource,
|
|
1641
1643
|
_props$rowKey = props.rowKey,
|
|
1642
|
-
rawRowKey = _props$rowKey ===
|
|
1644
|
+
rawRowKey = _props$rowKey === void 0 ? 'key' : _props$rowKey,
|
|
1643
1645
|
_props$estimatedRowHe = props.estimatedRowHeight,
|
|
1644
|
-
estimatedRowHeight = _props$estimatedRowHe ===
|
|
1646
|
+
estimatedRowHeight = _props$estimatedRowHe === void 0 ? 46 : _props$estimatedRowHe,
|
|
1645
1647
|
estimatedColumnWidth = props.estimatedColumnWidth,
|
|
1646
1648
|
_props$overscanRows = props.overscanRows,
|
|
1647
|
-
overscanRows = _props$overscanRows ===
|
|
1649
|
+
overscanRows = _props$overscanRows === void 0 ? 5 : _props$overscanRows,
|
|
1648
1650
|
_props$overscanColumn = props.overscanColumns,
|
|
1649
|
-
overscanColumns = _props$overscanColumn ===
|
|
1651
|
+
overscanColumns = _props$overscanColumn === void 0 ? 3 : _props$overscanColumn,
|
|
1650
1652
|
stickyHeader = props.stickyHeader,
|
|
1651
1653
|
_props$defaultColumnW = props.defaultColumnWidth,
|
|
1652
|
-
defaultColumnWidth = _props$defaultColumnW ===
|
|
1654
|
+
defaultColumnWidth = _props$defaultColumnW === void 0 ? 100 : _props$defaultColumnW,
|
|
1653
1655
|
_props$pipeline = props.pipeline,
|
|
1654
|
-
pipeline = _props$pipeline ===
|
|
1656
|
+
pipeline = _props$pipeline === void 0 ? TablePipeline.defaultPipeline : _props$pipeline,
|
|
1655
1657
|
rawRowClassName = props.rowClassName,
|
|
1656
1658
|
onRow = props.onRow,
|
|
1657
1659
|
getOffsetTopImpl = props.getOffsetTop,
|
|
1658
1660
|
_props$virtualHeader = props.virtualHeader,
|
|
1659
|
-
virtualHeader = _props$virtualHeader ===
|
|
1661
|
+
virtualHeader = _props$virtualHeader === void 0 ? true : _props$virtualHeader;
|
|
1660
1662
|
var rootNode = useRef(null);
|
|
1661
1663
|
var headerWrapperRef = useRef(null);
|
|
1662
1664
|
var bodyWrapperRef = useRef(null);
|
|
@@ -1746,10 +1748,10 @@ function VirtualTableCore(props, ref) {
|
|
|
1746
1748
|
}),
|
|
1747
1749
|
columns = _useColumnVirtualize.columns;
|
|
1748
1750
|
var onRowClassName = useCallback(function (record, index) {
|
|
1749
|
-
return clsx(rawRowClassName == null ?
|
|
1751
|
+
return clsx(rawRowClassName == null ? void 0 : rawRowClassName(record, index), rowClassName == null ? void 0 : rowClassName(record, index));
|
|
1750
1752
|
}, [rawRowClassName, rowClassName]);
|
|
1751
1753
|
var onRowProps = useCallback(function (record, index) {
|
|
1752
|
-
return _extends({}, onRow == null ?
|
|
1754
|
+
return _extends({}, onRow == null ? void 0 : onRow(record, index), onPipelineRow == null ? void 0 : onPipelineRow(record, index));
|
|
1753
1755
|
}, [onPipelineRow, onRow]);
|
|
1754
1756
|
var hasFixedLeftColumn = pipelineColumns.some(function (x) {
|
|
1755
1757
|
return isValidFixedLeft(x.fixed);
|