@rc-component/listy 1.1.0 → 1.2.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/es/GroupHeader.d.ts +1 -0
- package/es/GroupHeader.js +2 -1
- package/es/List.d.ts +7 -0
- package/es/RawList/index.js +18 -9
- package/es/VirtualList/index.js +16 -6
- package/es/VirtualList/useStickyGroupHeader.d.ts +2 -0
- package/es/VirtualList/useStickyGroupHeader.js +9 -2
- package/es/index.d.ts +1 -1
- package/lib/GroupHeader.d.ts +1 -0
- package/lib/GroupHeader.js +2 -1
- package/lib/List.d.ts +7 -0
- package/lib/RawList/index.js +18 -9
- package/lib/VirtualList/index.js +16 -6
- package/lib/VirtualList/useStickyGroupHeader.d.ts +2 -0
- package/lib/VirtualList/useStickyGroupHeader.js +9 -2
- package/lib/index.d.ts +1 -1
- package/package.json +1 -1
package/es/GroupHeader.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export interface GroupHeaderProps<T, K extends React.Key = React.Key> {
|
|
|
7
7
|
prefixCls: string;
|
|
8
8
|
fixed?: boolean;
|
|
9
9
|
sticky?: boolean;
|
|
10
|
+
className?: string;
|
|
10
11
|
style?: React.CSSProperties;
|
|
11
12
|
}
|
|
12
13
|
declare const GroupHeaderWithRef: <T, K extends React.Key = React.Key>(props: GroupHeaderProps<T, K> & {
|
package/es/GroupHeader.js
CHANGED
|
@@ -12,6 +12,7 @@ function GroupHeader(props, ref) {
|
|
|
12
12
|
prefixCls,
|
|
13
13
|
fixed,
|
|
14
14
|
sticky,
|
|
15
|
+
className: customClassName,
|
|
15
16
|
style
|
|
16
17
|
} = props;
|
|
17
18
|
|
|
@@ -19,7 +20,7 @@ function GroupHeader(props, ref) {
|
|
|
19
20
|
const className = clsx(`${prefixCls}-group-header`, {
|
|
20
21
|
[`${prefixCls}-group-header-sticky`]: sticky,
|
|
21
22
|
[`${prefixCls}-group-header-fixed`]: fixed
|
|
22
|
-
});
|
|
23
|
+
}, customClassName);
|
|
23
24
|
|
|
24
25
|
// ============================== Render ==============================
|
|
25
26
|
return /*#__PURE__*/React.createElement("div", {
|
package/es/List.d.ts
CHANGED
|
@@ -2,6 +2,9 @@ import * as React from 'react';
|
|
|
2
2
|
import type { Group } from './hooks/useGroupSegments';
|
|
3
3
|
export type RowKey<T> = keyof T | ((item: T) => React.Key);
|
|
4
4
|
export type ScrollAlign = 'top' | 'bottom' | 'auto';
|
|
5
|
+
export type ListySemanticName = 'root' | 'item' | 'groupHeader';
|
|
6
|
+
export type ListyClassNames = Partial<Record<ListySemanticName, string>>;
|
|
7
|
+
export type ListyStyles = Partial<Record<ListySemanticName, React.CSSProperties>>;
|
|
5
8
|
export interface GroupScrollToConfig {
|
|
6
9
|
groupKey: React.Key;
|
|
7
10
|
align?: ScrollAlign;
|
|
@@ -29,6 +32,8 @@ export interface ListyProps<T, K extends React.Key = React.Key> {
|
|
|
29
32
|
virtual?: boolean;
|
|
30
33
|
prefixCls?: string;
|
|
31
34
|
rowKey: RowKey<T>;
|
|
35
|
+
classNames?: ListyClassNames;
|
|
36
|
+
styles?: ListyStyles;
|
|
32
37
|
onScroll?: React.UIEventHandler<HTMLElement>;
|
|
33
38
|
itemRender: (item: T, index: number) => React.ReactNode;
|
|
34
39
|
}
|
|
@@ -40,6 +45,8 @@ export interface ListComponentProps<T, K extends React.Key = React.Key> {
|
|
|
40
45
|
group?: Group<T, K>;
|
|
41
46
|
prefixCls: string;
|
|
42
47
|
rowKey: RowKey<T>;
|
|
48
|
+
classNames?: ListyClassNames;
|
|
49
|
+
styles?: ListyStyles;
|
|
43
50
|
onScroll?: React.UIEventHandler<HTMLElement>;
|
|
44
51
|
itemRender: (item: T, index: number) => React.ReactNode;
|
|
45
52
|
}
|
package/es/RawList/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import clsx from 'clsx';
|
|
3
4
|
import { useEvent } from '@rc-component/util';
|
|
4
5
|
import GroupHeader from "../GroupHeader";
|
|
5
6
|
import useGroupSegments from "../hooks/useGroupSegments";
|
|
@@ -17,7 +18,9 @@ function RawList(props, ref) {
|
|
|
17
18
|
onScroll,
|
|
18
19
|
prefixCls,
|
|
19
20
|
rowKey,
|
|
20
|
-
sticky
|
|
21
|
+
sticky,
|
|
22
|
+
classNames,
|
|
23
|
+
styles
|
|
21
24
|
} = props;
|
|
22
25
|
|
|
23
26
|
// =============================== Refs ===============================
|
|
@@ -43,12 +46,15 @@ function RawList(props, ref) {
|
|
|
43
46
|
const scrollTargetProps = getScrollTargetProps(key);
|
|
44
47
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
45
48
|
key: key,
|
|
46
|
-
className: `${prefixCls}-item`,
|
|
47
|
-
style:
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
className: clsx(`${prefixCls}-item`, classNames?.item),
|
|
50
|
+
style: {
|
|
51
|
+
...styles?.item,
|
|
52
|
+
...(sticky && groupKey !== undefined ? {
|
|
53
|
+
scrollMarginTop: `var(--${prefixCls}-item-scroll-margin-top, 0px)`
|
|
54
|
+
} : undefined)
|
|
55
|
+
}
|
|
50
56
|
}, scrollTargetProps), itemRender(item, index));
|
|
51
|
-
}, [getItemKey, getScrollTargetProps, itemRender, prefixCls, sticky]);
|
|
57
|
+
}, [classNames?.item, getItemKey, getScrollTargetProps, itemRender, prefixCls, sticky, styles?.item]);
|
|
52
58
|
|
|
53
59
|
// ============================= Content ==============================
|
|
54
60
|
const rawContent = group ? Array.from(groupData, ([groupKey, groupItems]) => {
|
|
@@ -63,7 +69,9 @@ function RawList(props, ref) {
|
|
|
63
69
|
groupKey: groupKey,
|
|
64
70
|
groupItems: currentGroupItems,
|
|
65
71
|
prefixCls: prefixCls,
|
|
66
|
-
sticky: sticky
|
|
72
|
+
sticky: sticky,
|
|
73
|
+
className: classNames?.groupHeader,
|
|
74
|
+
style: styles?.groupHeader
|
|
67
75
|
}), groupItems.map(({
|
|
68
76
|
item,
|
|
69
77
|
index
|
|
@@ -77,11 +85,12 @@ function RawList(props, ref) {
|
|
|
77
85
|
// ============================== Render ==============================
|
|
78
86
|
return /*#__PURE__*/React.createElement("div", {
|
|
79
87
|
ref: holderRef,
|
|
80
|
-
className: prefixCls,
|
|
88
|
+
className: clsx(prefixCls, classNames?.root),
|
|
81
89
|
style: {
|
|
82
90
|
maxHeight: height,
|
|
83
91
|
overflowY: height === undefined ? undefined : 'auto',
|
|
84
|
-
overflowAnchor: 'none'
|
|
92
|
+
overflowAnchor: 'none',
|
|
93
|
+
...styles?.root
|
|
85
94
|
},
|
|
86
95
|
onScroll: onScroll
|
|
87
96
|
}, rawContent);
|
package/es/VirtualList/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import clsx from 'clsx';
|
|
2
3
|
import RcVirtualList from '@rc-component/virtual-list';
|
|
3
4
|
import { useEvent } from '@rc-component/util';
|
|
4
5
|
import GroupHeader from "../GroupHeader";
|
|
@@ -19,7 +20,9 @@ function VirtualList(props, ref) {
|
|
|
19
20
|
onScroll,
|
|
20
21
|
prefixCls,
|
|
21
22
|
rowKey,
|
|
22
|
-
sticky
|
|
23
|
+
sticky,
|
|
24
|
+
classNames,
|
|
25
|
+
styles
|
|
23
26
|
} = props;
|
|
24
27
|
|
|
25
28
|
// =============================== Refs ===============================
|
|
@@ -117,7 +120,9 @@ function VirtualList(props, ref) {
|
|
|
117
120
|
groupKeys,
|
|
118
121
|
groupKeyToItems,
|
|
119
122
|
prefixCls,
|
|
120
|
-
listRef
|
|
123
|
+
listRef,
|
|
124
|
+
headerClassName: classNames?.groupHeader,
|
|
125
|
+
headerStyle: styles?.groupHeader
|
|
121
126
|
});
|
|
122
127
|
|
|
123
128
|
// ============================ Render Row ============================
|
|
@@ -127,9 +132,11 @@ function VirtualList(props, ref) {
|
|
|
127
132
|
group: group,
|
|
128
133
|
groupKey: groupKey,
|
|
129
134
|
groupItems: groupItems,
|
|
130
|
-
prefixCls: prefixCls
|
|
135
|
+
prefixCls: prefixCls,
|
|
136
|
+
className: classNames?.groupHeader,
|
|
137
|
+
style: styles?.groupHeader
|
|
131
138
|
});
|
|
132
|
-
}, [group, groupKeyToItems, prefixCls]);
|
|
139
|
+
}, [classNames?.groupHeader, group, groupKeyToItems, prefixCls, styles?.groupHeader]);
|
|
133
140
|
|
|
134
141
|
// ============================== Render ==============================
|
|
135
142
|
return /*#__PURE__*/React.createElement(RcVirtualList, {
|
|
@@ -142,9 +149,12 @@ function VirtualList(props, ref) {
|
|
|
142
149
|
onScroll: onScroll,
|
|
143
150
|
prefixCls: prefixCls,
|
|
144
151
|
virtual: true,
|
|
145
|
-
extraRender: extraRender
|
|
152
|
+
extraRender: extraRender,
|
|
153
|
+
className: classNames?.root,
|
|
154
|
+
style: styles?.root
|
|
146
155
|
}, row => row.type === 'header' ? renderHeaderRow(row.groupKey) : /*#__PURE__*/React.createElement("div", {
|
|
147
|
-
className: `${prefixCls}-item
|
|
156
|
+
className: clsx(`${prefixCls}-item`, classNames?.item),
|
|
157
|
+
style: styles?.item
|
|
148
158
|
}, itemRender(row.item, row.index)));
|
|
149
159
|
}
|
|
150
160
|
const VirtualListWithRef = /*#__PURE__*/React.forwardRef(VirtualList);
|
|
@@ -9,6 +9,8 @@ export interface StickyHeaderParams<T, K extends React.Key = React.Key> {
|
|
|
9
9
|
groupKeyToItems: Map<K, T[]>;
|
|
10
10
|
prefixCls: string;
|
|
11
11
|
listRef: React.RefObject<RcVirtualListRef | null>;
|
|
12
|
+
headerClassName?: string;
|
|
13
|
+
headerStyle?: React.CSSProperties;
|
|
12
14
|
}
|
|
13
15
|
export default function useStickyGroupHeader<T, K extends React.Key = React.Key>(params: StickyHeaderParams<T, K>): (info: ExtraRenderInfo) => React.JSX.Element;
|
|
14
16
|
export {};
|
|
@@ -32,7 +32,9 @@ export default function useStickyGroupHeader(params) {
|
|
|
32
32
|
groupKeys,
|
|
33
33
|
groupKeyToItems,
|
|
34
34
|
prefixCls,
|
|
35
|
-
listRef
|
|
35
|
+
listRef,
|
|
36
|
+
headerClassName,
|
|
37
|
+
headerStyle
|
|
36
38
|
} = params;
|
|
37
39
|
|
|
38
40
|
// ============================ Extra Render ==========================
|
|
@@ -71,11 +73,16 @@ export default function useStickyGroupHeader(params) {
|
|
|
71
73
|
groupKey: currGroupKey,
|
|
72
74
|
groupItems: groupItems,
|
|
73
75
|
prefixCls: prefixCls,
|
|
76
|
+
className: headerClassName
|
|
77
|
+
// `top` is the computed sticky-push offset and must win over any
|
|
78
|
+
// user-supplied top in headerStyle, or the sticky behavior breaks.
|
|
79
|
+
,
|
|
74
80
|
style: {
|
|
81
|
+
...headerStyle,
|
|
75
82
|
top
|
|
76
83
|
}
|
|
77
84
|
})));
|
|
78
|
-
}, [enabled, group, groupKeys, groupKeyToItems, prefixCls, listRef]);
|
|
85
|
+
}, [enabled, group, groupKeys, groupKeyToItems, prefixCls, listRef, headerClassName, headerStyle]);
|
|
79
86
|
|
|
80
87
|
// ============================== Return ==============================
|
|
81
88
|
return extraRender;
|
package/es/index.d.ts
CHANGED
package/lib/GroupHeader.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export interface GroupHeaderProps<T, K extends React.Key = React.Key> {
|
|
|
7
7
|
prefixCls: string;
|
|
8
8
|
fixed?: boolean;
|
|
9
9
|
sticky?: boolean;
|
|
10
|
+
className?: string;
|
|
10
11
|
style?: React.CSSProperties;
|
|
11
12
|
}
|
|
12
13
|
declare const GroupHeaderWithRef: <T, K extends React.Key = React.Key>(props: GroupHeaderProps<T, K> & {
|
package/lib/GroupHeader.js
CHANGED
|
@@ -20,6 +20,7 @@ function GroupHeader(props, ref) {
|
|
|
20
20
|
prefixCls,
|
|
21
21
|
fixed,
|
|
22
22
|
sticky,
|
|
23
|
+
className: customClassName,
|
|
23
24
|
style
|
|
24
25
|
} = props;
|
|
25
26
|
|
|
@@ -27,7 +28,7 @@ function GroupHeader(props, ref) {
|
|
|
27
28
|
const className = (0, _clsx.default)(`${prefixCls}-group-header`, {
|
|
28
29
|
[`${prefixCls}-group-header-sticky`]: sticky,
|
|
29
30
|
[`${prefixCls}-group-header-fixed`]: fixed
|
|
30
|
-
});
|
|
31
|
+
}, customClassName);
|
|
31
32
|
|
|
32
33
|
// ============================== Render ==============================
|
|
33
34
|
return /*#__PURE__*/React.createElement("div", {
|
package/lib/List.d.ts
CHANGED
|
@@ -2,6 +2,9 @@ import * as React from 'react';
|
|
|
2
2
|
import type { Group } from './hooks/useGroupSegments';
|
|
3
3
|
export type RowKey<T> = keyof T | ((item: T) => React.Key);
|
|
4
4
|
export type ScrollAlign = 'top' | 'bottom' | 'auto';
|
|
5
|
+
export type ListySemanticName = 'root' | 'item' | 'groupHeader';
|
|
6
|
+
export type ListyClassNames = Partial<Record<ListySemanticName, string>>;
|
|
7
|
+
export type ListyStyles = Partial<Record<ListySemanticName, React.CSSProperties>>;
|
|
5
8
|
export interface GroupScrollToConfig {
|
|
6
9
|
groupKey: React.Key;
|
|
7
10
|
align?: ScrollAlign;
|
|
@@ -29,6 +32,8 @@ export interface ListyProps<T, K extends React.Key = React.Key> {
|
|
|
29
32
|
virtual?: boolean;
|
|
30
33
|
prefixCls?: string;
|
|
31
34
|
rowKey: RowKey<T>;
|
|
35
|
+
classNames?: ListyClassNames;
|
|
36
|
+
styles?: ListyStyles;
|
|
32
37
|
onScroll?: React.UIEventHandler<HTMLElement>;
|
|
33
38
|
itemRender: (item: T, index: number) => React.ReactNode;
|
|
34
39
|
}
|
|
@@ -40,6 +45,8 @@ export interface ListComponentProps<T, K extends React.Key = React.Key> {
|
|
|
40
45
|
group?: Group<T, K>;
|
|
41
46
|
prefixCls: string;
|
|
42
47
|
rowKey: RowKey<T>;
|
|
48
|
+
classNames?: ListyClassNames;
|
|
49
|
+
styles?: ListyStyles;
|
|
43
50
|
onScroll?: React.UIEventHandler<HTMLElement>;
|
|
44
51
|
itemRender: (item: T, index: number) => React.ReactNode;
|
|
45
52
|
}
|
package/lib/RawList/index.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _clsx = _interopRequireDefault(require("clsx"));
|
|
8
9
|
var _util = require("@rc-component/util");
|
|
9
10
|
var _GroupHeader = _interopRequireDefault(require("../GroupHeader"));
|
|
10
11
|
var _useGroupSegments = _interopRequireDefault(require("../hooks/useGroupSegments"));
|
|
@@ -25,7 +26,9 @@ function RawList(props, ref) {
|
|
|
25
26
|
onScroll,
|
|
26
27
|
prefixCls,
|
|
27
28
|
rowKey,
|
|
28
|
-
sticky
|
|
29
|
+
sticky,
|
|
30
|
+
classNames,
|
|
31
|
+
styles
|
|
29
32
|
} = props;
|
|
30
33
|
|
|
31
34
|
// =============================== Refs ===============================
|
|
@@ -51,12 +54,15 @@ function RawList(props, ref) {
|
|
|
51
54
|
const scrollTargetProps = getScrollTargetProps(key);
|
|
52
55
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
53
56
|
key: key,
|
|
54
|
-
className: `${prefixCls}-item`,
|
|
55
|
-
style:
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
className: (0, _clsx.default)(`${prefixCls}-item`, classNames?.item),
|
|
58
|
+
style: {
|
|
59
|
+
...styles?.item,
|
|
60
|
+
...(sticky && groupKey !== undefined ? {
|
|
61
|
+
scrollMarginTop: `var(--${prefixCls}-item-scroll-margin-top, 0px)`
|
|
62
|
+
} : undefined)
|
|
63
|
+
}
|
|
58
64
|
}, scrollTargetProps), itemRender(item, index));
|
|
59
|
-
}, [getItemKey, getScrollTargetProps, itemRender, prefixCls, sticky]);
|
|
65
|
+
}, [classNames?.item, getItemKey, getScrollTargetProps, itemRender, prefixCls, sticky, styles?.item]);
|
|
60
66
|
|
|
61
67
|
// ============================= Content ==============================
|
|
62
68
|
const rawContent = group ? Array.from(groupData, ([groupKey, groupItems]) => {
|
|
@@ -71,7 +77,9 @@ function RawList(props, ref) {
|
|
|
71
77
|
groupKey: groupKey,
|
|
72
78
|
groupItems: currentGroupItems,
|
|
73
79
|
prefixCls: prefixCls,
|
|
74
|
-
sticky: sticky
|
|
80
|
+
sticky: sticky,
|
|
81
|
+
className: classNames?.groupHeader,
|
|
82
|
+
style: styles?.groupHeader
|
|
75
83
|
}), groupItems.map(({
|
|
76
84
|
item,
|
|
77
85
|
index
|
|
@@ -85,11 +93,12 @@ function RawList(props, ref) {
|
|
|
85
93
|
// ============================== Render ==============================
|
|
86
94
|
return /*#__PURE__*/React.createElement("div", {
|
|
87
95
|
ref: holderRef,
|
|
88
|
-
className: prefixCls,
|
|
96
|
+
className: (0, _clsx.default)(prefixCls, classNames?.root),
|
|
89
97
|
style: {
|
|
90
98
|
maxHeight: height,
|
|
91
99
|
overflowY: height === undefined ? undefined : 'auto',
|
|
92
|
-
overflowAnchor: 'none'
|
|
100
|
+
overflowAnchor: 'none',
|
|
101
|
+
...styles?.root
|
|
93
102
|
},
|
|
94
103
|
onScroll: onScroll
|
|
95
104
|
}, rawContent);
|
package/lib/VirtualList/index.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _clsx = _interopRequireDefault(require("clsx"));
|
|
8
9
|
var _virtualList = _interopRequireDefault(require("@rc-component/virtual-list"));
|
|
9
10
|
var _util = require("@rc-component/util");
|
|
10
11
|
var _GroupHeader = _interopRequireDefault(require("../GroupHeader"));
|
|
@@ -27,7 +28,9 @@ function VirtualList(props, ref) {
|
|
|
27
28
|
onScroll,
|
|
28
29
|
prefixCls,
|
|
29
30
|
rowKey,
|
|
30
|
-
sticky
|
|
31
|
+
sticky,
|
|
32
|
+
classNames,
|
|
33
|
+
styles
|
|
31
34
|
} = props;
|
|
32
35
|
|
|
33
36
|
// =============================== Refs ===============================
|
|
@@ -125,7 +128,9 @@ function VirtualList(props, ref) {
|
|
|
125
128
|
groupKeys,
|
|
126
129
|
groupKeyToItems,
|
|
127
130
|
prefixCls,
|
|
128
|
-
listRef
|
|
131
|
+
listRef,
|
|
132
|
+
headerClassName: classNames?.groupHeader,
|
|
133
|
+
headerStyle: styles?.groupHeader
|
|
129
134
|
});
|
|
130
135
|
|
|
131
136
|
// ============================ Render Row ============================
|
|
@@ -135,9 +140,11 @@ function VirtualList(props, ref) {
|
|
|
135
140
|
group: group,
|
|
136
141
|
groupKey: groupKey,
|
|
137
142
|
groupItems: groupItems,
|
|
138
|
-
prefixCls: prefixCls
|
|
143
|
+
prefixCls: prefixCls,
|
|
144
|
+
className: classNames?.groupHeader,
|
|
145
|
+
style: styles?.groupHeader
|
|
139
146
|
});
|
|
140
|
-
}, [group, groupKeyToItems, prefixCls]);
|
|
147
|
+
}, [classNames?.groupHeader, group, groupKeyToItems, prefixCls, styles?.groupHeader]);
|
|
141
148
|
|
|
142
149
|
// ============================== Render ==============================
|
|
143
150
|
return /*#__PURE__*/React.createElement(_virtualList.default, {
|
|
@@ -150,9 +157,12 @@ function VirtualList(props, ref) {
|
|
|
150
157
|
onScroll: onScroll,
|
|
151
158
|
prefixCls: prefixCls,
|
|
152
159
|
virtual: true,
|
|
153
|
-
extraRender: extraRender
|
|
160
|
+
extraRender: extraRender,
|
|
161
|
+
className: classNames?.root,
|
|
162
|
+
style: styles?.root
|
|
154
163
|
}, row => row.type === 'header' ? renderHeaderRow(row.groupKey) : /*#__PURE__*/React.createElement("div", {
|
|
155
|
-
className: `${prefixCls}-item
|
|
164
|
+
className: (0, _clsx.default)(`${prefixCls}-item`, classNames?.item),
|
|
165
|
+
style: styles?.item
|
|
156
166
|
}, itemRender(row.item, row.index)));
|
|
157
167
|
}
|
|
158
168
|
const VirtualListWithRef = /*#__PURE__*/React.forwardRef(VirtualList);
|
|
@@ -9,6 +9,8 @@ export interface StickyHeaderParams<T, K extends React.Key = React.Key> {
|
|
|
9
9
|
groupKeyToItems: Map<K, T[]>;
|
|
10
10
|
prefixCls: string;
|
|
11
11
|
listRef: React.RefObject<RcVirtualListRef | null>;
|
|
12
|
+
headerClassName?: string;
|
|
13
|
+
headerStyle?: React.CSSProperties;
|
|
12
14
|
}
|
|
13
15
|
export default function useStickyGroupHeader<T, K extends React.Key = React.Key>(params: StickyHeaderParams<T, K>): (info: ExtraRenderInfo) => React.JSX.Element;
|
|
14
16
|
export {};
|
|
@@ -40,7 +40,9 @@ function useStickyGroupHeader(params) {
|
|
|
40
40
|
groupKeys,
|
|
41
41
|
groupKeyToItems,
|
|
42
42
|
prefixCls,
|
|
43
|
-
listRef
|
|
43
|
+
listRef,
|
|
44
|
+
headerClassName,
|
|
45
|
+
headerStyle
|
|
44
46
|
} = params;
|
|
45
47
|
|
|
46
48
|
// ============================ Extra Render ==========================
|
|
@@ -79,11 +81,16 @@ function useStickyGroupHeader(params) {
|
|
|
79
81
|
groupKey: currGroupKey,
|
|
80
82
|
groupItems: groupItems,
|
|
81
83
|
prefixCls: prefixCls,
|
|
84
|
+
className: headerClassName
|
|
85
|
+
// `top` is the computed sticky-push offset and must win over any
|
|
86
|
+
// user-supplied top in headerStyle, or the sticky behavior breaks.
|
|
87
|
+
,
|
|
82
88
|
style: {
|
|
89
|
+
...headerStyle,
|
|
83
90
|
top
|
|
84
91
|
}
|
|
85
92
|
})));
|
|
86
|
-
}, [enabled, group, groupKeys, groupKeyToItems, prefixCls, listRef]);
|
|
93
|
+
}, [enabled, group, groupKeys, groupKeyToItems, prefixCls, listRef, headerClassName, headerStyle]);
|
|
87
94
|
|
|
88
95
|
// ============================== Return ==============================
|
|
89
96
|
return extraRender;
|
package/lib/index.d.ts
CHANGED