@hi-ui/table 4.7.0-alpha.0 → 4.7.0-alpha.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/cjs/BaseTable.js +4 -2
- package/lib/cjs/TheadContent.js +5 -1
- package/lib/cjs/hooks/use-col-width.js +2 -4
- package/lib/cjs/use-table.js +2 -4
- package/lib/esm/BaseTable.js +4 -2
- package/lib/esm/TheadContent.js +5 -1
- package/lib/esm/hooks/use-col-width.js +2 -4
- package/lib/esm/use-table.js +2 -4
- package/lib/types/BaseTable.d.ts +6 -0
- package/lib/types/context.d.ts +4 -1
- package/lib/types/hooks/use-col-width.d.ts +1 -3
- package/lib/types/use-table.d.ts +1 -6
- package/package.json +1 -1
package/lib/cjs/BaseTable.js
CHANGED
|
@@ -75,7 +75,8 @@ var BaseTable = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
75
75
|
emptyContent = _a.emptyContent,
|
|
76
76
|
virtual = _a.virtual,
|
|
77
77
|
needDoubleTable = _a.needDoubleTable,
|
|
78
|
-
|
|
78
|
+
onResizeStop = _a.onResizeStop,
|
|
79
|
+
rest = tslib.__rest(_a, ["prefixCls", "role", "className", "columns", "data", "striped", "bordered", "rowExpandable", "defaultExpandedEmbedRowKeys", "expandedEmbedRowKeys", "onEmbedExpand", "expandedRender", "size", "extra", "onRow", "onHeaderRow", "stickyFooter", "stickyFooterBottom", "fixedColumnTrigger", "emptyContent", "virtual", "needDoubleTable", "onResizeStop"]);
|
|
79
80
|
// ********************** 内嵌式面板 *********************** //
|
|
80
81
|
var _useEmbedExpand = useEmbedExpand.useEmbedExpand({
|
|
81
82
|
defaultExpandedEmbedRowKeys: defaultExpandedEmbedRowKeys,
|
|
@@ -283,7 +284,8 @@ var BaseTable = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
283
284
|
hasAvgColumn: hasAvgColumn,
|
|
284
285
|
sumRow: sumRow,
|
|
285
286
|
hasSumColumn: hasSumColumn,
|
|
286
|
-
virtual: virtual
|
|
287
|
+
virtual: virtual,
|
|
288
|
+
onResizeStop: onResizeStop
|
|
287
289
|
})
|
|
288
290
|
}, renderTable()), renderFreezeShadow()), tableFooter);
|
|
289
291
|
});
|
package/lib/cjs/TheadContent.js
CHANGED
|
@@ -43,7 +43,8 @@ var TheadContent = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
43
43
|
onColumnResizable = _useTableContext.onColumnResizable,
|
|
44
44
|
getStickyColProps = _useTableContext.getStickyColProps,
|
|
45
45
|
showColMenu = _useTableContext.showColMenu,
|
|
46
|
-
setHeaderTableElement = _useTableContext.setHeaderTableElement
|
|
46
|
+
setHeaderTableElement = _useTableContext.setHeaderTableElement,
|
|
47
|
+
_onResizeStop = _useTableContext.onResizeStop;
|
|
47
48
|
var activeColumnKeysAction = useCheckState.useCheckState();
|
|
48
49
|
return /*#__PURE__*/React__default["default"].createElement("thead", Object.assign({}, rest), groupedColumns.map(function (cols, colsIndex) {
|
|
49
50
|
return /*#__PURE__*/React__default["default"].createElement("tr", {
|
|
@@ -100,6 +101,9 @@ var TheadContent = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
100
101
|
width: colWidths[colIndex],
|
|
101
102
|
onResize: function onResize(evt, options) {
|
|
102
103
|
onColumnResizable(evt, options, colIndex);
|
|
104
|
+
},
|
|
105
|
+
onResizeStop: function onResizeStop(evt, options) {
|
|
106
|
+
_onResizeStop === null || _onResizeStop === void 0 ? void 0 : _onResizeStop(evt, options === null || options === void 0 ? void 0 : options.size, colIndex, colWidths);
|
|
103
107
|
}
|
|
104
108
|
}, cell)) : cell;
|
|
105
109
|
}));
|
|
@@ -25,8 +25,7 @@ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
|
25
25
|
var useColWidth = function useColWidth(_ref) {
|
|
26
26
|
var resizable = _ref.resizable,
|
|
27
27
|
columns = _ref.columns,
|
|
28
|
-
virtual = _ref.virtual
|
|
29
|
-
onResize = _ref.onResize;
|
|
28
|
+
virtual = _ref.virtual;
|
|
30
29
|
var measureRowElementRef = React__default["default"].useRef(null);
|
|
31
30
|
// 是否重新设置过表格每列宽度
|
|
32
31
|
var hasResetWidths = React__default["default"].useRef(false);
|
|
@@ -209,10 +208,9 @@ var useColWidth = function useColWidth(_ref) {
|
|
|
209
208
|
}
|
|
210
209
|
nextColWidths[index] = nextWidth;
|
|
211
210
|
nextColWidths[index + 1] = anotherWidth;
|
|
212
|
-
onResize === null || onResize === void 0 ? void 0 : onResize(evt, size, index, nextColWidths);
|
|
213
211
|
return nextColWidths;
|
|
214
212
|
});
|
|
215
|
-
}, [minColWidth
|
|
213
|
+
}, [minColWidth]);
|
|
216
214
|
var getColgroupProps = React__default["default"].useCallback(function (column, index) {
|
|
217
215
|
var width = colWidths[index] || undefined;
|
|
218
216
|
return {
|
package/lib/cjs/use-table.js
CHANGED
|
@@ -91,8 +91,7 @@ var useTable = function useTable(_a) {
|
|
|
91
91
|
scrollbar = _a.scrollbar,
|
|
92
92
|
rowClassName = _a.rowClassName,
|
|
93
93
|
cellClassName = _a.cellClassName,
|
|
94
|
-
|
|
95
|
-
rootProps = tslib.__rest(_a, ["data", "columns", "defaultFixedToColumn", "fixedToColumn", "onFixedToColumn", "scrollWidth", "resizable", "errorRowKeys", "highlightedColKeys", "highlightedRowKeys", "showColHighlight", "showRowHighlight", "highlightRowOnDoubleClick", "defaultExpandedRowKeys", "expandedRowKeys", "onExpand", "defaultExpandAll", "onLoadChildren", "maxHeight", "sticky", "stickyTop", "draggable", "onDragStart", "onDrop", "onDropEnd", "showColMenu", "rowSelection", "cellRender", "footerRender", "fieldKey", "virtual", "scrollbar", "rowClassName", "cellClassName", "onResize"]);
|
|
94
|
+
rootProps = tslib.__rest(_a, ["data", "columns", "defaultFixedToColumn", "fixedToColumn", "onFixedToColumn", "scrollWidth", "resizable", "errorRowKeys", "highlightedColKeys", "highlightedRowKeys", "showColHighlight", "showRowHighlight", "highlightRowOnDoubleClick", "defaultExpandedRowKeys", "expandedRowKeys", "onExpand", "defaultExpandAll", "onLoadChildren", "maxHeight", "sticky", "stickyTop", "draggable", "onDragStart", "onDrop", "onDropEnd", "showColMenu", "rowSelection", "cellRender", "footerRender", "fieldKey", "virtual", "scrollbar", "rowClassName", "cellClassName"]);
|
|
96
95
|
/**
|
|
97
96
|
* 获取 key 字段值
|
|
98
97
|
*/
|
|
@@ -184,8 +183,7 @@ var useTable = function useTable(_a) {
|
|
|
184
183
|
data: data,
|
|
185
184
|
columns: columns,
|
|
186
185
|
resizable: resizable,
|
|
187
|
-
virtual: virtual
|
|
188
|
-
onResize: onResize
|
|
186
|
+
virtual: virtual
|
|
189
187
|
}),
|
|
190
188
|
measureRowElementRef = _useColWidth.measureRowElementRef,
|
|
191
189
|
getColgroupProps = _useColWidth.getColgroupProps,
|
package/lib/esm/BaseTable.js
CHANGED
|
@@ -62,7 +62,8 @@ var BaseTable = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
62
62
|
emptyContent = _a.emptyContent,
|
|
63
63
|
virtual = _a.virtual,
|
|
64
64
|
needDoubleTable = _a.needDoubleTable,
|
|
65
|
-
|
|
65
|
+
onResizeStop = _a.onResizeStop,
|
|
66
|
+
rest = __rest(_a, ["prefixCls", "role", "className", "columns", "data", "striped", "bordered", "rowExpandable", "defaultExpandedEmbedRowKeys", "expandedEmbedRowKeys", "onEmbedExpand", "expandedRender", "size", "extra", "onRow", "onHeaderRow", "stickyFooter", "stickyFooterBottom", "fixedColumnTrigger", "emptyContent", "virtual", "needDoubleTable", "onResizeStop"]);
|
|
66
67
|
// ********************** 内嵌式面板 *********************** //
|
|
67
68
|
var _useEmbedExpand = useEmbedExpand({
|
|
68
69
|
defaultExpandedEmbedRowKeys: defaultExpandedEmbedRowKeys,
|
|
@@ -270,7 +271,8 @@ var BaseTable = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
270
271
|
hasAvgColumn: hasAvgColumn,
|
|
271
272
|
sumRow: sumRow,
|
|
272
273
|
hasSumColumn: hasSumColumn,
|
|
273
|
-
virtual: virtual
|
|
274
|
+
virtual: virtual,
|
|
275
|
+
onResizeStop: onResizeStop
|
|
274
276
|
})
|
|
275
277
|
}, renderTable()), renderFreezeShadow()), tableFooter);
|
|
276
278
|
});
|
package/lib/esm/TheadContent.js
CHANGED
|
@@ -31,7 +31,8 @@ var TheadContent = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
31
31
|
onColumnResizable = _useTableContext.onColumnResizable,
|
|
32
32
|
getStickyColProps = _useTableContext.getStickyColProps,
|
|
33
33
|
showColMenu = _useTableContext.showColMenu,
|
|
34
|
-
setHeaderTableElement = _useTableContext.setHeaderTableElement
|
|
34
|
+
setHeaderTableElement = _useTableContext.setHeaderTableElement,
|
|
35
|
+
_onResizeStop = _useTableContext.onResizeStop;
|
|
35
36
|
var activeColumnKeysAction = useCheckState();
|
|
36
37
|
return /*#__PURE__*/React__default.createElement("thead", Object.assign({}, rest), groupedColumns.map(function (cols, colsIndex) {
|
|
37
38
|
return /*#__PURE__*/React__default.createElement("tr", {
|
|
@@ -88,6 +89,9 @@ var TheadContent = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
88
89
|
width: colWidths[colIndex],
|
|
89
90
|
onResize: function onResize(evt, options) {
|
|
90
91
|
onColumnResizable(evt, options, colIndex);
|
|
92
|
+
},
|
|
93
|
+
onResizeStop: function onResizeStop(evt, options) {
|
|
94
|
+
_onResizeStop === null || _onResizeStop === void 0 ? void 0 : _onResizeStop(evt, options === null || options === void 0 ? void 0 : options.size, colIndex, colWidths);
|
|
91
95
|
}
|
|
92
96
|
}, cell)) : cell;
|
|
93
97
|
}));
|
|
@@ -13,8 +13,7 @@ import { useUpdateEffect } from '@hi-ui/use-update-effect';
|
|
|
13
13
|
var useColWidth = function useColWidth(_ref) {
|
|
14
14
|
var resizable = _ref.resizable,
|
|
15
15
|
columns = _ref.columns,
|
|
16
|
-
virtual = _ref.virtual
|
|
17
|
-
onResize = _ref.onResize;
|
|
16
|
+
virtual = _ref.virtual;
|
|
18
17
|
var measureRowElementRef = React__default.useRef(null);
|
|
19
18
|
// 是否重新设置过表格每列宽度
|
|
20
19
|
var hasResetWidths = React__default.useRef(false);
|
|
@@ -197,10 +196,9 @@ var useColWidth = function useColWidth(_ref) {
|
|
|
197
196
|
}
|
|
198
197
|
nextColWidths[index] = nextWidth;
|
|
199
198
|
nextColWidths[index + 1] = anotherWidth;
|
|
200
|
-
onResize === null || onResize === void 0 ? void 0 : onResize(evt, size, index, nextColWidths);
|
|
201
199
|
return nextColWidths;
|
|
202
200
|
});
|
|
203
|
-
}, [minColWidth
|
|
201
|
+
}, [minColWidth]);
|
|
204
202
|
var getColgroupProps = React__default.useCallback(function (column, index) {
|
|
205
203
|
var width = colWidths[index] || undefined;
|
|
206
204
|
return {
|
package/lib/esm/use-table.js
CHANGED
|
@@ -79,8 +79,7 @@ var useTable = function useTable(_a) {
|
|
|
79
79
|
scrollbar = _a.scrollbar,
|
|
80
80
|
rowClassName = _a.rowClassName,
|
|
81
81
|
cellClassName = _a.cellClassName,
|
|
82
|
-
|
|
83
|
-
rootProps = __rest(_a, ["data", "columns", "defaultFixedToColumn", "fixedToColumn", "onFixedToColumn", "scrollWidth", "resizable", "errorRowKeys", "highlightedColKeys", "highlightedRowKeys", "showColHighlight", "showRowHighlight", "highlightRowOnDoubleClick", "defaultExpandedRowKeys", "expandedRowKeys", "onExpand", "defaultExpandAll", "onLoadChildren", "maxHeight", "sticky", "stickyTop", "draggable", "onDragStart", "onDrop", "onDropEnd", "showColMenu", "rowSelection", "cellRender", "footerRender", "fieldKey", "virtual", "scrollbar", "rowClassName", "cellClassName", "onResize"]);
|
|
82
|
+
rootProps = __rest(_a, ["data", "columns", "defaultFixedToColumn", "fixedToColumn", "onFixedToColumn", "scrollWidth", "resizable", "errorRowKeys", "highlightedColKeys", "highlightedRowKeys", "showColHighlight", "showRowHighlight", "highlightRowOnDoubleClick", "defaultExpandedRowKeys", "expandedRowKeys", "onExpand", "defaultExpandAll", "onLoadChildren", "maxHeight", "sticky", "stickyTop", "draggable", "onDragStart", "onDrop", "onDropEnd", "showColMenu", "rowSelection", "cellRender", "footerRender", "fieldKey", "virtual", "scrollbar", "rowClassName", "cellClassName"]);
|
|
84
83
|
/**
|
|
85
84
|
* 获取 key 字段值
|
|
86
85
|
*/
|
|
@@ -172,8 +171,7 @@ var useTable = function useTable(_a) {
|
|
|
172
171
|
data: data,
|
|
173
172
|
columns: columns,
|
|
174
173
|
resizable: resizable,
|
|
175
|
-
virtual: virtual
|
|
176
|
-
onResize: onResize
|
|
174
|
+
virtual: virtual
|
|
177
175
|
}),
|
|
178
176
|
measureRowElementRef = _useColWidth.measureRowElementRef,
|
|
179
177
|
getColgroupProps = _useColWidth.getColgroupProps,
|
package/lib/types/BaseTable.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { HiBaseHTMLProps, HiBaseSizeEnum } from '@hi-ui/core';
|
|
|
3
3
|
import { TableExtra, TableColumnItem, TableOnRowReturn } from './types';
|
|
4
4
|
import { UseTableProps } from './use-table';
|
|
5
5
|
import { UseEmbedExpandProps } from './hooks/use-embed-expand';
|
|
6
|
+
import { ResizeCallbackData } from 'react-resizable';
|
|
6
7
|
export declare const EMBED_DATA_KEY: string;
|
|
7
8
|
export declare const BaseTable: React.ForwardRefExoticComponent<BaseTableProps & React.RefAttributes<HTMLDivElement | null>>;
|
|
8
9
|
export interface BaseTableProps extends Omit<HiBaseHTMLProps<'div'>, 'onDrop' | 'draggable' | 'onDragStart'>, UseTableProps, UseEmbedExpandProps {
|
|
@@ -45,6 +46,11 @@ export interface BaseTableProps extends Omit<HiBaseHTMLProps<'div'>, 'onDrop' |
|
|
|
45
46
|
fixedColumnTrigger?: 'auto' | 'always';
|
|
46
47
|
/**
|
|
47
48
|
* 是否需要使用双表格
|
|
49
|
+
* @private
|
|
48
50
|
*/
|
|
49
51
|
needDoubleTable?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* resizable 模式下,列宽变化后触发的回调
|
|
54
|
+
*/
|
|
55
|
+
onResizeStop?: (evt: React.SyntheticEvent, size: ResizeCallbackData['size'], index: number, columnsWidth: number[]) => void;
|
|
50
56
|
}
|
package/lib/types/context.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { SyntheticEvent } from 'react';
|
|
2
2
|
import { TableOnRowReturn } from './types';
|
|
3
|
+
import { ResizeCallbackData } from 'react-resizable';
|
|
3
4
|
export declare const TableProvider: import("react").Provider<(Omit<{
|
|
4
5
|
getColgroupProps: (column: import("./types").FlattedTableColumnItemData, index: number) => {
|
|
5
6
|
style: {
|
|
@@ -114,6 +115,7 @@ export declare const TableProvider: import("react").Provider<(Omit<{
|
|
|
114
115
|
onRow?: ((rowData: Record<string, any> | null, index: number) => TableOnRowReturn) | undefined;
|
|
115
116
|
striped: boolean;
|
|
116
117
|
virtual?: boolean | undefined;
|
|
118
|
+
onResizeStop?: ((evt: SyntheticEvent, size: ResizeCallbackData['size'], index: number, columnsWidth: number[]) => void) | undefined;
|
|
117
119
|
}) | null>;
|
|
118
120
|
export declare const useTableContext: () => Omit<{
|
|
119
121
|
getColgroupProps: (column: import("./types").FlattedTableColumnItemData, index: number) => {
|
|
@@ -229,4 +231,5 @@ export declare const useTableContext: () => Omit<{
|
|
|
229
231
|
onRow?: ((rowData: Record<string, any> | null, index: number) => TableOnRowReturn) | undefined;
|
|
230
232
|
striped: boolean;
|
|
231
233
|
virtual?: boolean | undefined;
|
|
234
|
+
onResizeStop?: ((evt: SyntheticEvent, size: ResizeCallbackData['size'], index: number, columnsWidth: number[]) => void) | undefined;
|
|
232
235
|
};
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FlattedTableColumnItemData, TableColumnItem, TableRowRecord } from '../types';
|
|
3
|
-
|
|
4
|
-
export declare const useColWidth: ({ resizable, data, columns, virtual, onResize, }: {
|
|
3
|
+
export declare const useColWidth: ({ resizable, data, columns, virtual, }: {
|
|
5
4
|
resizable: boolean;
|
|
6
5
|
data: TableRowRecord[];
|
|
7
6
|
columns: TableColumnItem[];
|
|
8
7
|
virtual?: boolean | undefined;
|
|
9
|
-
onResize?: ((e: React.SyntheticEvent, data: ResizeCallbackData, index: number, columnsWidth: number[]) => void) | undefined;
|
|
10
8
|
}) => {
|
|
11
9
|
measureRowElementRef: React.MutableRefObject<HTMLTableRowElement | null>;
|
|
12
10
|
onColumnResizable: (evt: any, { size }: any, index: number) => void;
|
package/lib/types/use-table.d.ts
CHANGED
|
@@ -2,8 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { PaginationProps } from '@hi-ui/pagination';
|
|
3
3
|
import { ScrollbarProps } from '@hi-ui/scrollbar';
|
|
4
4
|
import { TableColumnItem, TableFrozenColumnOptions, TableRowEventData, TableRowSelection, FlattedTableColumnItemData, FlattedTableRowData } from './types';
|
|
5
|
-
|
|
6
|
-
export declare const useTable: ({ data, columns: columnsProp, defaultFixedToColumn, fixedToColumn: fixedToColumnProp, onFixedToColumn, scrollWidth, resizable, errorRowKeys, highlightedColKeys: highlightedColKeysProp, highlightedRowKeys: highlightedRowKeysProp, showColHighlight, showRowHighlight, highlightRowOnDoubleClick, defaultExpandedRowKeys, expandedRowKeys: expandRowKeysProp, onExpand, defaultExpandAll, onLoadChildren, maxHeight, sticky, stickyTop, draggable, onDragStart, onDrop: onDropProp, onDropEnd, showColMenu, rowSelection, cellRender, footerRender, fieldKey, virtual, scrollbar, rowClassName, cellClassName, onResize, ...rootProps }: UseTableProps) => {
|
|
5
|
+
export declare const useTable: ({ data, columns: columnsProp, defaultFixedToColumn, fixedToColumn: fixedToColumnProp, onFixedToColumn, scrollWidth, resizable, errorRowKeys, highlightedColKeys: highlightedColKeysProp, highlightedRowKeys: highlightedRowKeysProp, showColHighlight, showRowHighlight, highlightRowOnDoubleClick, defaultExpandedRowKeys, expandedRowKeys: expandRowKeysProp, onExpand, defaultExpandAll, onLoadChildren, maxHeight, sticky, stickyTop, draggable, onDragStart, onDrop: onDropProp, onDropEnd, showColMenu, rowSelection, cellRender, footerRender, fieldKey, virtual, scrollbar, rowClassName, cellClassName, ...rootProps }: UseTableProps) => {
|
|
7
6
|
getColgroupProps: (column: FlattedTableColumnItemData, index: number) => {
|
|
8
7
|
style: {
|
|
9
8
|
width: number | undefined;
|
|
@@ -297,9 +296,5 @@ export interface UseTableProps {
|
|
|
297
296
|
* 设置单元格类名
|
|
298
297
|
*/
|
|
299
298
|
cellClassName?: (record: Record<string, any>, column: Record<string, any>, index: number) => string;
|
|
300
|
-
/**
|
|
301
|
-
* resizable 模式下,设置列宽变化时触发的回调
|
|
302
|
-
*/
|
|
303
|
-
onResize?: (e: React.SyntheticEvent, data: ResizeCallbackData, index: number, columnsWidth: number[]) => void;
|
|
304
299
|
}
|
|
305
300
|
export declare type UseTableReturn = ReturnType<typeof useTable>;
|