@mezzanine-ui/react 1.0.0-beta.2 → 1.0.0-beta.4
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/Anchor/Anchor.d.ts +51 -18
- package/Anchor/Anchor.js +15 -15
- package/Anchor/AnchorGroup.d.ts +34 -0
- package/Anchor/AnchorGroup.js +37 -0
- package/Anchor/AnchorItem.d.ts +30 -0
- package/Anchor/AnchorItem.js +65 -0
- package/Anchor/index.d.ts +2 -0
- package/Anchor/index.js +1 -0
- package/Anchor/utils.d.ts +13 -0
- package/Anchor/utils.js +95 -0
- package/AutoComplete/AutoComplete.d.ts +217 -0
- package/AutoComplete/AutoComplete.js +433 -0
- package/AutoComplete/index.d.ts +2 -0
- package/AutoComplete/index.js +1 -0
- package/AutoComplete/useAutoCompleteCreation.d.ts +33 -0
- package/AutoComplete/useAutoCompleteCreation.js +201 -0
- package/AutoComplete/useAutoCompleteKeyboard.d.ts +31 -0
- package/AutoComplete/useAutoCompleteKeyboard.js +149 -0
- package/AutoComplete/useAutoCompleteSearch.d.ts +16 -0
- package/AutoComplete/useAutoCompleteSearch.js +69 -0
- package/AutoComplete/useCreationTracker.d.ts +17 -0
- package/AutoComplete/useCreationTracker.js +47 -0
- package/Breadcrumb/Breadcrumb.js +16 -21
- package/Breadcrumb/BreadcrumbDropdown.d.ts +11 -0
- package/Breadcrumb/BreadcrumbDropdown.js +22 -0
- package/Breadcrumb/BreadcrumbItem.d.ts +2 -3
- package/Breadcrumb/BreadcrumbItem.js +13 -31
- package/Breadcrumb/BreadcrumbOverflowMenu.d.ts +7 -0
- package/Breadcrumb/BreadcrumbOverflowMenu.js +77 -0
- package/Breadcrumb/BreadcrumbOverflowMenuDropdown.d.ts +11 -0
- package/Breadcrumb/BreadcrumbOverflowMenuDropdown.js +21 -0
- package/Breadcrumb/BreadcrumbOverflowMenuItem.d.ts +3 -0
- package/Breadcrumb/BreadcrumbOverflowMenuItem.js +27 -0
- package/Breadcrumb/typings.d.ts +21 -39
- package/Button/Button.js +13 -11
- package/Button/index.d.ts +1 -1
- package/Button/typings.d.ts +27 -4
- package/Checkbox/index.d.ts +4 -5
- package/Checkbox/index.js +1 -5
- package/ContentHeader/ContentHeader.d.ts +160 -0
- package/ContentHeader/ContentHeader.js +54 -0
- package/ContentHeader/index.d.ts +2 -0
- package/ContentHeader/index.js +1 -0
- package/ContentHeader/utils.d.ts +23 -0
- package/ContentHeader/utils.js +215 -0
- package/Description/Description.d.ts +12 -22
- package/Description/Description.js +4 -24
- package/Dropdown/Dropdown.d.ts +46 -1
- package/Dropdown/Dropdown.js +99 -14
- package/Dropdown/DropdownAction.d.ts +1 -1
- package/Dropdown/DropdownAction.js +1 -4
- package/Dropdown/DropdownItem.d.ts +28 -1
- package/Dropdown/DropdownItem.js +56 -14
- package/Dropdown/DropdownItemCard.d.ts +2 -2
- package/Dropdown/DropdownItemCard.js +20 -16
- package/Dropdown/DropdownStatus.js +29 -0
- package/Dropdown/dropdownKeydownHandler.d.ts +2 -1
- package/Dropdown/dropdownKeydownHandler.js +73 -0
- package/Dropdown/highlightText.js +5 -1
- package/Dropdown/shortcutTextHandler.d.ts +24 -0
- package/Dropdown/shortcutTextHandler.js +171 -0
- package/Empty/Empty.js +2 -1
- package/Empty/icons/EmptyMainNotificationIcon.d.ts +4 -0
- package/Empty/icons/EmptyMainNotificationIcon.js +9 -0
- package/Empty/typings.d.ts +2 -2
- package/FilterArea/Filter.d.ts +32 -0
- package/FilterArea/Filter.js +23 -0
- package/FilterArea/FilterArea.d.ts +58 -0
- package/FilterArea/FilterArea.js +31 -0
- package/FilterArea/FilterLine.d.ts +11 -0
- package/FilterArea/FilterLine.js +13 -0
- package/FilterArea/index.d.ts +6 -0
- package/FilterArea/index.js +3 -0
- package/Form/FormField.js +3 -1
- package/Input/Input.d.ts +35 -7
- package/Input/Input.js +48 -14
- package/Input/index.d.ts +1 -1
- package/Modal/MediaPreviewModal.d.ts +54 -0
- package/Modal/MediaPreviewModal.js +158 -0
- package/Modal/Modal.d.ts +103 -11
- package/Modal/Modal.js +14 -9
- package/Modal/ModalBodyForVerification.d.ts +59 -0
- package/Modal/ModalBodyForVerification.js +99 -0
- package/Modal/ModalControl.d.ts +2 -2
- package/Modal/ModalControl.js +1 -1
- package/Modal/ModalFooter.d.ts +119 -1
- package/Modal/ModalFooter.js +15 -3
- package/Modal/ModalHeader.d.ts +26 -7
- package/Modal/ModalHeader.js +33 -7
- package/Modal/index.d.ts +6 -5
- package/Modal/index.js +2 -2
- package/Modal/useModalContainer.d.ts +12 -3
- package/Modal/useModalContainer.js +28 -6
- package/Navigation/Navigation.d.ts +7 -2
- package/Navigation/Navigation.js +36 -35
- package/Navigation/NavigationHeader.d.ts +4 -0
- package/Navigation/NavigationHeader.js +3 -2
- package/Navigation/NavigationOption.d.ts +8 -3
- package/Navigation/NavigationOption.js +46 -11
- package/Navigation/NavigationOptionCategory.js +1 -0
- package/Navigation/NavigationOverflowMenu.d.ts +6 -0
- package/Navigation/NavigationOverflowMenu.js +90 -0
- package/Navigation/NavigationOverflowMenuOption.d.ts +7 -0
- package/Navigation/NavigationOverflowMenuOption.js +68 -0
- package/Navigation/NavigationUserMenu.d.ts +4 -2
- package/Navigation/NavigationUserMenu.js +13 -5
- package/Navigation/context.d.ts +3 -2
- package/Navigation/useVisibleItems.d.ts +5 -0
- package/Navigation/useVisibleItems.js +54 -0
- package/NotificationCenter/NotificationCenter.d.ts +124 -0
- package/NotificationCenter/NotificationCenter.js +279 -0
- package/NotificationCenter/NotificationCenterDrawer.d.ts +109 -0
- package/NotificationCenter/index.d.ts +3 -0
- package/NotificationCenter/index.js +1 -0
- package/PageFooter/PageFooter.d.ts +19 -9
- package/PageFooter/PageFooter.js +10 -10
- package/PageHeader/PageHeader.d.ts +32 -25
- package/PageHeader/PageHeader.js +49 -43
- package/ResultState/ResultState.d.ts +9 -0
- package/ResultState/ResultState.js +36 -4
- package/Scrollbar/Scrollbar.d.ts +9 -0
- package/Scrollbar/Scrollbar.js +78 -0
- package/Scrollbar/index.d.ts +2 -0
- package/Scrollbar/index.js +1 -0
- package/Scrollbar/typings.d.ts +47 -0
- package/Select/SelectTrigger.js +5 -4
- package/Select/index.d.ts +0 -2
- package/Select/index.js +0 -1
- package/Select/typings.d.ts +6 -1
- package/Selection/Selection.js +1 -1
- package/Selection/SelectionGroup.d.ts +28 -0
- package/Slider/useSlider.js +1 -1
- package/Table/Table.d.ts +2 -120
- package/Table/Table.js +148 -53
- package/Table/TableContext.d.ts +11 -12
- package/Table/components/TableActionsCell.js +12 -4
- package/Table/components/TableBody.js +2 -1
- package/Table/components/TableBulkActions.js +1 -19
- package/Table/components/TableColGroup.d.ts +1 -4
- package/Table/components/TableColGroup.js +15 -16
- package/Table/components/TableCollectableCell.d.ts +17 -0
- package/Table/components/TableCollectableCell.js +54 -0
- package/Table/components/TableDragOrPinHandleCell.d.ts +20 -0
- package/Table/components/TableDragOrPinHandleCell.js +58 -0
- package/Table/components/TableExpandedRow.js +11 -2
- package/Table/components/TableHeader.js +12 -10
- package/Table/components/TableRow.js +38 -13
- package/Table/components/TableSelectionCell.js +1 -1
- package/Table/components/TableToggleableCell.d.ts +16 -0
- package/Table/components/TableToggleableCell.js +51 -0
- package/Table/components/index.d.ts +4 -1
- package/Table/components/index.js +3 -0
- package/Table/hooks/typings.d.ts +18 -4
- package/Table/hooks/useTableExpansion.d.ts +2 -2
- package/Table/hooks/useTableExpansion.js +5 -5
- package/Table/hooks/useTableFixedOffsets.d.ts +6 -2
- package/Table/hooks/useTableFixedOffsets.js +60 -26
- package/Table/hooks/useTableScroll.d.ts +9 -3
- package/Table/hooks/useTableScroll.js +34 -7
- package/Table/hooks/useTableVirtualization.d.ts +2 -1
- package/Table/hooks/useTableVirtualization.js +2 -8
- package/Table/index.d.ts +4 -3
- package/Table/index.js +3 -0
- package/Table/typings.d.ts +172 -0
- package/Table/utils/useTableRowSelection.js +13 -5
- package/Tag/TagGroup.d.ts +3 -0
- package/Tag/index.d.ts +2 -0
- package/Tag/index.js +1 -0
- package/Transition/Slide.d.ts +9 -2
- package/Transition/Slide.js +7 -4
- package/Tree/TreeNode.js +1 -1
- package/Upload/UploadPictureCard.js +1 -1
- package/index.d.ts +37 -21
- package/index.js +25 -11
- package/package.json +6 -4
- package/Modal/ModalActions.d.ts +0 -9
- package/Modal/ModalActions.js +0 -20
- package/Modal/ModalBody.d.ts +0 -7
- package/Modal/ModalBody.js +0 -14
- package/Notification/Notification.d.ts +0 -54
- package/Notification/Notification.js +0 -76
- package/Notification/index.d.ts +0 -3
- package/Notification/index.js +0 -1
- package/PageToolbar/PageToolbar.d.ts +0 -114
- package/PageToolbar/PageToolbar.js +0 -23
- package/PageToolbar/index.d.ts +0 -2
- package/PageToolbar/index.js +0 -1
- package/PageToolbar/utils.d.ts +0 -23
- package/PageToolbar/utils.js +0 -165
- package/Select/AutoComplete.d.ts +0 -107
- package/Select/AutoComplete.js +0 -114
- package/Table/components/TableDragHandleCell.d.ts +0 -11
- package/Table/components/TableDragHandleCell.js +0 -44
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useState, useCallback, useMemo } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { DRAG_OR_PIN_HANDLE_COLUMN_WIDTH, EXPANSION_COLUMN_WIDTH } from '@mezzanine-ui/core/table';
|
|
4
4
|
|
|
5
|
-
function useTableExpansion({ expandable,
|
|
5
|
+
function useTableExpansion({ expandable, hasDragOrPinHandle, }) {
|
|
6
6
|
const [internalExpandedKeys, setInternalExpandedKeys] = useState([]);
|
|
7
7
|
const { expandedRowKeys: expandedRowKeysProp, onExpand, onExpandedRowsChange, } = expandable || {};
|
|
8
8
|
const isControlled = expandedRowKeysProp !== undefined;
|
|
@@ -25,12 +25,12 @@ function useTableExpansion({ expandable, hasDragHandle, }) {
|
|
|
25
25
|
}, [expandedRowKeys, isControlled, onExpand, onExpandedRowsChange]);
|
|
26
26
|
const expansionLeftPadding = useMemo(() => {
|
|
27
27
|
let padding = 0;
|
|
28
|
-
if (
|
|
29
|
-
padding +=
|
|
28
|
+
if (hasDragOrPinHandle)
|
|
29
|
+
padding += DRAG_OR_PIN_HANDLE_COLUMN_WIDTH;
|
|
30
30
|
if (expandable)
|
|
31
31
|
padding += EXPANSION_COLUMN_WIDTH;
|
|
32
32
|
return padding;
|
|
33
|
-
}, [expandable,
|
|
33
|
+
}, [expandable, hasDragOrPinHandle]);
|
|
34
34
|
if (!expandable) {
|
|
35
35
|
return undefined;
|
|
36
36
|
}
|
|
@@ -9,12 +9,16 @@ export interface FixedOffsetInfo {
|
|
|
9
9
|
export interface UseTableFixedOffsetsReturn {
|
|
10
10
|
/** Get offset info for a specific column by key */
|
|
11
11
|
getColumnOffset: (key: string) => FixedOffsetInfo | null;
|
|
12
|
-
/** Get offset info for drag handle column */
|
|
13
|
-
|
|
12
|
+
/** Get offset info for drag or pin handle column */
|
|
13
|
+
getDragOrPinHandleOffset: () => FixedOffsetInfo | null;
|
|
14
14
|
/** Get offset info for selection column */
|
|
15
15
|
getSelectionOffset: () => FixedOffsetInfo | null;
|
|
16
16
|
/** Get offset info for expansion column */
|
|
17
17
|
getExpansionOffset: () => FixedOffsetInfo | null;
|
|
18
|
+
/** Get offset info for toggleable column */
|
|
19
|
+
getToggleableOffset: () => FixedOffsetInfo | null;
|
|
20
|
+
/** Get offset info for collectable column */
|
|
21
|
+
getCollectableOffset: () => FixedOffsetInfo | null;
|
|
18
22
|
/** Check if a column should show shadow based on scroll position */
|
|
19
23
|
shouldShowShadow: (key: string, scrollLeft: number, containerWidth: number) => boolean;
|
|
20
24
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useState, useEffect, useCallback, useMemo } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { DRAG_OR_PIN_HANDLE_KEY, DRAG_OR_PIN_HANDLE_COLUMN_WIDTH, EXPANSION_KEY, EXPANSION_COLUMN_WIDTH, SELECTION_KEY, SELECTION_COLUMN_WIDTH, TOGGLEABLE_KEY, COLLECTABLE_KEY } from '@mezzanine-ui/core/table';
|
|
4
4
|
import { useTableSuperContext } from '../TableContext.js';
|
|
5
5
|
|
|
6
6
|
const parseFixed = (fixed) => {
|
|
@@ -11,15 +11,15 @@ const parseFixed = (fixed) => {
|
|
|
11
11
|
return null;
|
|
12
12
|
};
|
|
13
13
|
function useTableFixedOffsets(props) {
|
|
14
|
-
const { expansionLeftPadding = 0,
|
|
14
|
+
const { expansionLeftPadding = 0, hasDragOrPinHandleFixed: parentHasDragOrPinHandleFixed, } = useTableSuperContext();
|
|
15
15
|
const { actionConfig, columns, getResizedColumnWidth } = props;
|
|
16
16
|
// Store measured widths
|
|
17
17
|
const [measuredWidths, setMeasuredWidths] = useState(new Map());
|
|
18
|
-
const {
|
|
18
|
+
const { hasDragOrPinHandle, hasExpansion, hasSelection, hasToggleable, hasCollectable, dragOrPinHandleFixed, expansionFixed, selectionFixed, toggleableMinWidth, toggleableFixed, collectableMinWidth, collectableFixed, } = actionConfig;
|
|
19
19
|
useEffect(() => {
|
|
20
20
|
const innerMap = new Map();
|
|
21
|
-
if (
|
|
22
|
-
innerMap.set(
|
|
21
|
+
if (hasDragOrPinHandle || parentHasDragOrPinHandleFixed) {
|
|
22
|
+
innerMap.set(DRAG_OR_PIN_HANDLE_KEY, DRAG_OR_PIN_HANDLE_COLUMN_WIDTH);
|
|
23
23
|
}
|
|
24
24
|
if (hasExpansion) {
|
|
25
25
|
innerMap.set(EXPANSION_KEY, EXPANSION_COLUMN_WIDTH);
|
|
@@ -27,8 +27,23 @@ function useTableFixedOffsets(props) {
|
|
|
27
27
|
if (hasSelection) {
|
|
28
28
|
innerMap.set(SELECTION_KEY, SELECTION_COLUMN_WIDTH);
|
|
29
29
|
}
|
|
30
|
+
if (hasToggleable) {
|
|
31
|
+
innerMap.set(TOGGLEABLE_KEY, toggleableMinWidth);
|
|
32
|
+
}
|
|
33
|
+
if (hasCollectable) {
|
|
34
|
+
innerMap.set(COLLECTABLE_KEY, collectableMinWidth);
|
|
35
|
+
}
|
|
30
36
|
setMeasuredWidths(innerMap);
|
|
31
|
-
}, [
|
|
37
|
+
}, [
|
|
38
|
+
hasDragOrPinHandle,
|
|
39
|
+
hasExpansion,
|
|
40
|
+
hasSelection,
|
|
41
|
+
hasToggleable,
|
|
42
|
+
hasCollectable,
|
|
43
|
+
parentHasDragOrPinHandleFixed,
|
|
44
|
+
toggleableMinWidth,
|
|
45
|
+
collectableMinWidth,
|
|
46
|
+
]);
|
|
32
47
|
// Get width for a column (prioritize measured, then computed, then defined, then fallback)
|
|
33
48
|
const getWidth = useCallback((key, fallback = 0) => {
|
|
34
49
|
// Get static widths first
|
|
@@ -52,12 +67,13 @@ function useTableFixedOffsets(props) {
|
|
|
52
67
|
const { fixedEndKeys, fixedStartKeys } = useMemo(() => {
|
|
53
68
|
const startKeys = [];
|
|
54
69
|
const endKeys = [];
|
|
55
|
-
if ((hasDragHandle && dragHandleFixed) || parentHasDragHandleFixed) {
|
|
56
|
-
startKeys.push(DRAG_HANDLE_KEY);
|
|
57
|
-
}
|
|
58
70
|
if (hasExpansion && expansionFixed) {
|
|
59
71
|
startKeys.push(EXPANSION_KEY);
|
|
60
72
|
}
|
|
73
|
+
if ((hasDragOrPinHandle && dragOrPinHandleFixed) ||
|
|
74
|
+
parentHasDragOrPinHandleFixed) {
|
|
75
|
+
startKeys.push(DRAG_OR_PIN_HANDLE_KEY);
|
|
76
|
+
}
|
|
61
77
|
if (hasSelection && selectionFixed) {
|
|
62
78
|
startKeys.push(SELECTION_KEY);
|
|
63
79
|
}
|
|
@@ -72,14 +88,14 @@ function useTableFixedOffsets(props) {
|
|
|
72
88
|
});
|
|
73
89
|
return { fixedEndKeys: endKeys, fixedStartKeys: startKeys };
|
|
74
90
|
}, [
|
|
75
|
-
|
|
76
|
-
|
|
91
|
+
hasDragOrPinHandle,
|
|
92
|
+
dragOrPinHandleFixed,
|
|
77
93
|
hasExpansion,
|
|
78
94
|
expansionFixed,
|
|
79
95
|
hasSelection,
|
|
80
96
|
selectionFixed,
|
|
81
97
|
columns,
|
|
82
|
-
|
|
98
|
+
parentHasDragOrPinHandleFixed,
|
|
83
99
|
]);
|
|
84
100
|
// Calculate all fixed offsets
|
|
85
101
|
const fixedOffsets = useMemo(() => {
|
|
@@ -106,12 +122,12 @@ function useTableFixedOffsets(props) {
|
|
|
106
122
|
}, [fixedEndKeys, fixedStartKeys, getWidth]);
|
|
107
123
|
const allColumnKeys = useMemo(() => {
|
|
108
124
|
const keys = [];
|
|
109
|
-
if (hasDragHandle) {
|
|
110
|
-
keys.push(DRAG_HANDLE_KEY);
|
|
111
|
-
}
|
|
112
125
|
if (hasExpansion) {
|
|
113
126
|
keys.push(EXPANSION_KEY);
|
|
114
127
|
}
|
|
128
|
+
if (hasDragOrPinHandle) {
|
|
129
|
+
keys.push(DRAG_OR_PIN_HANDLE_KEY);
|
|
130
|
+
}
|
|
115
131
|
if (hasSelection) {
|
|
116
132
|
keys.push(SELECTION_KEY);
|
|
117
133
|
}
|
|
@@ -119,7 +135,7 @@ function useTableFixedOffsets(props) {
|
|
|
119
135
|
keys.push(column.key);
|
|
120
136
|
});
|
|
121
137
|
return keys;
|
|
122
|
-
}, [
|
|
138
|
+
}, [hasDragOrPinHandle, hasSelection, hasExpansion, columns]);
|
|
123
139
|
const originalPositions = useMemo(() => {
|
|
124
140
|
const positions = new Map();
|
|
125
141
|
let currentPosition = 0;
|
|
@@ -199,39 +215,57 @@ function useTableFixedOffsets(props) {
|
|
|
199
215
|
var _a, _b;
|
|
200
216
|
return ((_b = (_a = fixedOffsets.startOffsets.get(key)) !== null && _a !== void 0 ? _a : fixedOffsets.endOffsets.get(key)) !== null && _b !== void 0 ? _b : null);
|
|
201
217
|
}, [fixedOffsets]);
|
|
202
|
-
const
|
|
218
|
+
const getDragOrPinHandleOffset = useCallback(() => {
|
|
203
219
|
var _a;
|
|
204
|
-
if (!
|
|
220
|
+
if (!hasDragOrPinHandle || !dragOrPinHandleFixed) {
|
|
205
221
|
return null;
|
|
206
222
|
}
|
|
207
|
-
return (_a = fixedOffsets.startOffsets.get(
|
|
208
|
-
}, [
|
|
223
|
+
return (_a = fixedOffsets.startOffsets.get(DRAG_OR_PIN_HANDLE_KEY)) !== null && _a !== void 0 ? _a : null;
|
|
224
|
+
}, [hasDragOrPinHandle, dragOrPinHandleFixed, fixedOffsets]);
|
|
209
225
|
const getSelectionOffset = useCallback(() => {
|
|
210
226
|
var _a;
|
|
211
|
-
if (!
|
|
227
|
+
if (!hasSelection || !selectionFixed) {
|
|
212
228
|
return null;
|
|
213
229
|
}
|
|
214
230
|
return (_a = fixedOffsets.startOffsets.get(SELECTION_KEY)) !== null && _a !== void 0 ? _a : null;
|
|
215
|
-
}, [
|
|
231
|
+
}, [hasSelection, selectionFixed, fixedOffsets]);
|
|
216
232
|
const getExpansionOffset = useCallback(() => {
|
|
217
233
|
var _a;
|
|
218
|
-
if (!
|
|
234
|
+
if (!hasExpansion || !expansionFixed) {
|
|
219
235
|
return null;
|
|
220
236
|
}
|
|
221
237
|
return (_a = fixedOffsets.startOffsets.get(EXPANSION_KEY)) !== null && _a !== void 0 ? _a : null;
|
|
222
|
-
}, [
|
|
238
|
+
}, [hasExpansion, expansionFixed, fixedOffsets]);
|
|
239
|
+
const getToggleableOffset = useCallback(() => {
|
|
240
|
+
var _a;
|
|
241
|
+
if (!hasToggleable || !toggleableFixed) {
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
return (_a = fixedOffsets.endOffsets.get(TOGGLEABLE_KEY)) !== null && _a !== void 0 ? _a : null;
|
|
245
|
+
}, [hasToggleable, toggleableFixed, fixedOffsets]);
|
|
246
|
+
const getCollectableOffset = useCallback(() => {
|
|
247
|
+
var _a;
|
|
248
|
+
if (!hasCollectable || !collectableFixed) {
|
|
249
|
+
return null;
|
|
250
|
+
}
|
|
251
|
+
return (_a = fixedOffsets.endOffsets.get(COLLECTABLE_KEY)) !== null && _a !== void 0 ? _a : null;
|
|
252
|
+
}, [hasCollectable, collectableFixed, fixedOffsets]);
|
|
223
253
|
// Memoize return object to prevent unnecessary re-renders
|
|
224
254
|
return useMemo(() => ({
|
|
255
|
+
getCollectableOffset,
|
|
225
256
|
getColumnOffset,
|
|
226
|
-
|
|
257
|
+
getDragOrPinHandleOffset,
|
|
227
258
|
getExpansionOffset,
|
|
228
259
|
getSelectionOffset,
|
|
260
|
+
getToggleableOffset,
|
|
229
261
|
shouldShowShadow,
|
|
230
262
|
}), [
|
|
263
|
+
getCollectableOffset,
|
|
231
264
|
getColumnOffset,
|
|
232
|
-
|
|
265
|
+
getDragOrPinHandleOffset,
|
|
233
266
|
getExpansionOffset,
|
|
234
267
|
getSelectionOffset,
|
|
268
|
+
getToggleableOffset,
|
|
235
269
|
shouldShowShadow,
|
|
236
270
|
]);
|
|
237
271
|
}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
+
import type { OverlayScrollbars } from 'overlayscrollbars';
|
|
1
2
|
export interface UseTableScrollReturn {
|
|
2
3
|
/** Container width (viewport width) */
|
|
3
4
|
containerWidth: number;
|
|
4
|
-
|
|
5
|
+
/** OverlayScrollbars scroll event handler */
|
|
6
|
+
handleScrollbarScroll: (instance: OverlayScrollbars, event: Event) => void;
|
|
7
|
+
/** Handler to be passed to Scrollbar's onViewportReady prop */
|
|
8
|
+
handleViewportReady: (viewport: HTMLDivElement, instance?: OverlayScrollbars) => void;
|
|
9
|
+
/** Whether the scroll container ref has been set and is ready */
|
|
10
|
+
isContainerReady: boolean;
|
|
5
11
|
isScrollingHorizontally: boolean;
|
|
6
12
|
scrollLeft: number;
|
|
7
|
-
/** Ref object for internal use */
|
|
13
|
+
/** Ref object for internal use - points to the actual scrolling element */
|
|
8
14
|
containerRef: React.RefObject<HTMLDivElement | null>;
|
|
9
|
-
/** Callback ref setter
|
|
15
|
+
/** Callback ref setter for disabled Scrollbar fallback (plain div) */
|
|
10
16
|
setContainerRef: (element: HTMLDivElement | null) => void;
|
|
11
17
|
}
|
|
12
18
|
export declare function useTableScroll({ enabled, }: {
|
|
@@ -5,6 +5,7 @@ function useTableScroll({ enabled, }) {
|
|
|
5
5
|
const [isScrollingHorizontally, setIsScrollingHorizontally] = useState(false);
|
|
6
6
|
const [scrollLeft, setScrollLeft] = useState(0);
|
|
7
7
|
const [containerWidth, setContainerWidth] = useState(0);
|
|
8
|
+
const [isContainerReady, setIsContainerReady] = useState(false);
|
|
8
9
|
const containerRef = useRef(null);
|
|
9
10
|
const resizeObserverRef = useRef(null);
|
|
10
11
|
const measureDimensions = useCallback(() => {
|
|
@@ -13,8 +14,8 @@ function useTableScroll({ enabled, }) {
|
|
|
13
14
|
setContainerWidth((prev) => prev !== newContainerWidth ? newContainerWidth : prev);
|
|
14
15
|
}
|
|
15
16
|
}, []);
|
|
16
|
-
//
|
|
17
|
-
const
|
|
17
|
+
// Setup ResizeObserver on an element
|
|
18
|
+
const setupResizeObserver = useCallback((element) => {
|
|
18
19
|
// Clean up previous observer
|
|
19
20
|
if (resizeObserverRef.current) {
|
|
20
21
|
resizeObserverRef.current.disconnect();
|
|
@@ -22,6 +23,8 @@ function useTableScroll({ enabled, }) {
|
|
|
22
23
|
}
|
|
23
24
|
containerRef.current = element;
|
|
24
25
|
if (element && enabled) {
|
|
26
|
+
// Mark container as ready
|
|
27
|
+
setIsContainerReady(true);
|
|
25
28
|
// Measure immediately
|
|
26
29
|
measureDimensions();
|
|
27
30
|
// Set up ResizeObserver
|
|
@@ -31,8 +34,28 @@ function useTableScroll({ enabled, }) {
|
|
|
31
34
|
resizeObserverRef.current.observe(element);
|
|
32
35
|
}
|
|
33
36
|
}, [enabled, measureDimensions]);
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
// Callback ref for disabled Scrollbar (plain div) fallback
|
|
38
|
+
const setContainerRef = useCallback((element) => {
|
|
39
|
+
if (element) {
|
|
40
|
+
setupResizeObserver(element);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
// Clean up when element is removed
|
|
44
|
+
if (resizeObserverRef.current) {
|
|
45
|
+
resizeObserverRef.current.disconnect();
|
|
46
|
+
resizeObserverRef.current = null;
|
|
47
|
+
}
|
|
48
|
+
containerRef.current = null;
|
|
49
|
+
setIsContainerReady(false);
|
|
50
|
+
}
|
|
51
|
+
}, [setupResizeObserver]);
|
|
52
|
+
// Handler for Scrollbar's onViewportReady - receives the viewport element
|
|
53
|
+
const handleViewportReady = useCallback((viewport) => {
|
|
54
|
+
setupResizeObserver(viewport);
|
|
55
|
+
}, [setupResizeObserver]);
|
|
56
|
+
// OverlayScrollbars scroll event handler
|
|
57
|
+
const handleScrollbarScroll = useCallback((_instance, event) => {
|
|
58
|
+
const target = event.target;
|
|
36
59
|
const newScrollLeft = target.scrollLeft;
|
|
37
60
|
setScrollLeft(newScrollLeft);
|
|
38
61
|
setIsScrollingHorizontally(newScrollLeft > 0);
|
|
@@ -46,15 +69,19 @@ function useTableScroll({ enabled, }) {
|
|
|
46
69
|
};
|
|
47
70
|
}, []);
|
|
48
71
|
return useMemo(() => ({
|
|
72
|
+
containerRef,
|
|
49
73
|
containerWidth,
|
|
50
|
-
|
|
74
|
+
handleScrollbarScroll,
|
|
75
|
+
handleViewportReady,
|
|
76
|
+
isContainerReady,
|
|
51
77
|
isScrollingHorizontally,
|
|
52
78
|
scrollLeft,
|
|
53
|
-
containerRef,
|
|
54
79
|
setContainerRef,
|
|
55
80
|
}), [
|
|
56
81
|
containerWidth,
|
|
57
|
-
|
|
82
|
+
handleScrollbarScroll,
|
|
83
|
+
handleViewportReady,
|
|
84
|
+
isContainerReady,
|
|
58
85
|
isScrollingHorizontally,
|
|
59
86
|
scrollLeft,
|
|
60
87
|
setContainerRef,
|
|
@@ -3,6 +3,7 @@ import { type TableDataSource } from '@mezzanine-ui/core/table';
|
|
|
3
3
|
export interface UseTableVirtualizationOptions<T extends TableDataSource> {
|
|
4
4
|
dataSource: T[];
|
|
5
5
|
enabled?: boolean;
|
|
6
|
+
isContainerReady?: boolean;
|
|
6
7
|
isRowExpanded?: (key: string) => boolean;
|
|
7
8
|
overscan?: number;
|
|
8
9
|
scrollContainerRef: React.RefObject<HTMLDivElement | null>;
|
|
@@ -19,4 +20,4 @@ export interface UseTableVirtualizationReturn {
|
|
|
19
20
|
totalSize: number;
|
|
20
21
|
virtualItems: VirtualItem[];
|
|
21
22
|
}
|
|
22
|
-
export declare function useTableVirtualization<T extends TableDataSource>({ dataSource, enabled, isRowExpanded, overscan, scrollContainerRef, }: UseTableVirtualizationOptions<T>): UseTableVirtualizationReturn | null;
|
|
23
|
+
export declare function useTableVirtualization<T extends TableDataSource>({ dataSource, enabled, isContainerReady, isRowExpanded, overscan, scrollContainerRef, }: UseTableVirtualizationOptions<T>): UseTableVirtualizationReturn | null;
|
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { useRef, useCallback, useEffect, useMemo } from 'react';
|
|
3
3
|
import { useVirtualizer } from '@tanstack/react-virtual';
|
|
4
4
|
import { getRowKey } from '@mezzanine-ui/core/table';
|
|
5
5
|
import { useTableContext } from '../TableContext.js';
|
|
6
6
|
|
|
7
|
-
function useTableVirtualization({ dataSource, enabled = true, isRowExpanded, overscan = 5, scrollContainerRef, }) {
|
|
7
|
+
function useTableVirtualization({ dataSource, enabled = true, isContainerReady = false, isRowExpanded, overscan = 5, scrollContainerRef, }) {
|
|
8
8
|
var _a, _b, _c, _d;
|
|
9
9
|
const { rowHeight } = useTableContext();
|
|
10
|
-
const [isContainerReady, setIsContainerReady] = useState(false);
|
|
11
10
|
const expandedRowHeightsRef = useRef(new Map());
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
if (scrollContainerRef.current && enabled) {
|
|
14
|
-
setIsContainerReady(true);
|
|
15
|
-
}
|
|
16
|
-
}, [scrollContainerRef, enabled]);
|
|
17
11
|
// Estimate size callback that accounts for expanded rows
|
|
18
12
|
const estimateSize = useCallback((index) => {
|
|
19
13
|
const record = dataSource[index];
|
package/Table/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { TABLE_ACTIONS_KEY, tableClasses as classes, getCellAlignClass, getRowKey, type ColumnAlign, type FixedType, type HighlightMode, type SortOrder, type TableActionItem, type TableActions, type TableActionsBase, type TableActionsWithMinWidth, type TableBulkActions, type TableBulkGeneralAction, type TableBulkOverflowAction, type TableColumnBase, type TableColumnBaseWithMinWidthRequired, type TableColumn, type TableColumnTitleMenu, type TableColumnWithDataIndex, type TableColumnWithDataIndexAndMinWidth, type TableColumnWithMinWidth, type TableColumnWithRender, type TableColumnWithRenderAndMinWidth, type TableDataSource, type TableDataSourceWithId, type TableDataSourceWithKey, type TableDraggable, type TableExpandable, type TableRecord, type TableRowSelection, type TableRowSelectionBase, type TableRowSelectionCheckbox, type TableRowSelectionRadio, type TableScroll, type TableSelectionMode, type TableSize, } from '@mezzanine-ui/core/table';
|
|
2
|
-
export { default
|
|
3
|
-
export {
|
|
1
|
+
export { TABLE_ACTIONS_KEY, tableClasses as classes, getCellAlignClass, getRowKey, type ColumnAlign, type FixedType, type HighlightMode, type SortOrder, type TableActionItem, type TableActions, type TableActionsBase, type TableActionsWithMinWidth, type TableBulkActions, type TableBulkGeneralAction, type TableBulkOverflowAction, type TableColumnBase, type TableColumnBaseWithMinWidthRequired, type TableColumn, type TableColumnTitleMenu, type TableColumnWithDataIndex, type TableColumnWithDataIndexAndMinWidth, type TableColumnWithMinWidth, type TableColumnWithRender, type TableColumnWithRenderAndMinWidth, type TableDataSource, type TableDataSourceWithId, type TableDataSourceWithKey, type TableCollectable, type TableDraggable, type TableExpandable, type TablePinnable, type TableRecord, type TableToggleable, type TableRowSelection, type TableRowSelectionBase, type TableRowSelectionCheckbox, type TableRowSelectionRadio, type TableScroll, type TableSelectionMode, type TableSize, } from '@mezzanine-ui/core/table';
|
|
2
|
+
export { default } from './Table';
|
|
3
|
+
export type { TableBaseProps, TableDraggableOnlyProps, TableNoDragOrPinProps, TableNonResizableProps, TableNonVirtualizedProps, TablePinnableOnlyProps, TableProps, TableResizableProps, TableVirtualizedProps, } from './typings';
|
|
4
|
+
export { TableContext, TableDataContext, TableSuperContext, useTableContext, useTableDataContext, useTableSuperContext, type TableResizedColumnState, type TableContextValue, type TableDataContextValue, type TableHighlightState, type TableExpansionState, type TableSelectionState, type TableSortingState, } from './TableContext';
|
|
4
5
|
export { type UpdateDataSourceOptions, type UseTableDataSourceOptions, type TableTransitionState, } from './hooks';
|
|
5
6
|
export * from './hooks';
|
|
6
7
|
export * from './components';
|
package/Table/index.js
CHANGED
|
@@ -13,6 +13,7 @@ export { TableActionsCell } from './components/TableActionsCell.js';
|
|
|
13
13
|
export { TableBody } from './components/TableBody.js';
|
|
14
14
|
export { TableCell } from './components/TableCell.js';
|
|
15
15
|
export { TableColGroup } from './components/TableColGroup.js';
|
|
16
|
+
export { TableDragOrPinHandleCell } from './components/TableDragOrPinHandleCell.js';
|
|
16
17
|
export { TableExpandCell } from './components/TableExpandCell.js';
|
|
17
18
|
export { TableExpandedRow } from './components/TableExpandedRow.js';
|
|
18
19
|
export { TableHeader } from './components/TableHeader.js';
|
|
@@ -20,5 +21,7 @@ export { TablePagination } from './components/TablePagination.js';
|
|
|
20
21
|
export { TableResizeHandle } from './components/TableResizeHandle.js';
|
|
21
22
|
export { TableRow } from './components/TableRow.js';
|
|
22
23
|
export { TableSelectionCell } from './components/TableSelectionCell.js';
|
|
24
|
+
export { TableToggleableCell } from './components/TableToggleableCell.js';
|
|
25
|
+
export { TableCollectableCell } from './components/TableCollectableCell.js';
|
|
23
26
|
export { calculateColumnWidths, clampWidth } from './utils/calculateColumnWidths.js';
|
|
24
27
|
export { useTableRowSelection } from './utils/useTableRowSelection.js';
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import type { HighlightMode, TableActions, TableActionsWithMinWidth, TableCollectable, TableColumn, TableColumnWithMinWidth, TableDataSource, TableDraggable, TableExpandable, TablePinnable, TableRowSelection, TableScroll, TableSize, TableToggleable } from '@mezzanine-ui/core/table';
|
|
2
|
+
import type { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
3
|
+
import type { EmptyProps } from '../Empty';
|
|
4
|
+
import type { TablePaginationProps } from './components/TablePagination';
|
|
5
|
+
import type { TableTransitionState } from './hooks/useTableDataSource';
|
|
6
|
+
/**
|
|
7
|
+
* Base props shared by all Table variants.
|
|
8
|
+
*/
|
|
9
|
+
export interface TableBaseProps<T extends TableDataSource = TableDataSource> extends Omit<NativeElementPropsWithoutKeyAndRef<'table'>, 'children' | 'draggable' | 'summary' | 'onChange'> {
|
|
10
|
+
/** Data source */
|
|
11
|
+
dataSource: T[];
|
|
12
|
+
/** Props for Empty component when no data */
|
|
13
|
+
emptyProps?: EmptyProps & {
|
|
14
|
+
height?: number | string;
|
|
15
|
+
};
|
|
16
|
+
/** Expandable row configuration */
|
|
17
|
+
expandable?: TableExpandable<T>;
|
|
18
|
+
/** Collectable row configuration (star/favorite functionality) */
|
|
19
|
+
collectable?: TableCollectable<T>;
|
|
20
|
+
/**
|
|
21
|
+
* Whether the table should stretch to fill its container width.
|
|
22
|
+
* When true, the table will always be 100% width of its container.
|
|
23
|
+
* Note: If the sum of all column widths is less than the table width,
|
|
24
|
+
* columns will be proportionally stretched to fill the remaining space.
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
fullWidth?: boolean;
|
|
28
|
+
/** Highlight mode for hover effects
|
|
29
|
+
* @default 'row'
|
|
30
|
+
*/
|
|
31
|
+
highlight?: HighlightMode;
|
|
32
|
+
/** Loading state */
|
|
33
|
+
loading?: boolean;
|
|
34
|
+
/** Number of rows to display when loading */
|
|
35
|
+
loadingRowsCount?: number;
|
|
36
|
+
/** Minimum height of the table */
|
|
37
|
+
minHeight?: number | string;
|
|
38
|
+
/**
|
|
39
|
+
* Whether the table is nested inside an expanded row content area
|
|
40
|
+
*/
|
|
41
|
+
nested?: boolean;
|
|
42
|
+
/** Pagination configuration */
|
|
43
|
+
pagination?: TablePaginationProps;
|
|
44
|
+
/**
|
|
45
|
+
* Row height preset token.
|
|
46
|
+
*/
|
|
47
|
+
rowHeightPreset?: 'base' | 'condensed' | 'detailed' | 'roomy';
|
|
48
|
+
/** Row selection configuration */
|
|
49
|
+
rowSelection?: TableRowSelection<T>;
|
|
50
|
+
/** Row indexes where a separator border should be displayed */
|
|
51
|
+
separatorAtRowIndexes?: number[];
|
|
52
|
+
/** Show header row */
|
|
53
|
+
showHeader?: boolean;
|
|
54
|
+
/** Custom size variant
|
|
55
|
+
* @default 'main'
|
|
56
|
+
*/
|
|
57
|
+
size?: TableSize;
|
|
58
|
+
/** Whether to enable sticky header
|
|
59
|
+
* @default true
|
|
60
|
+
*/
|
|
61
|
+
sticky?: boolean;
|
|
62
|
+
/** Toggleable row configuration */
|
|
63
|
+
toggleable?: TableToggleable<T>;
|
|
64
|
+
/** Transition state for row add/remove animations (from useTableDataSource hook) */
|
|
65
|
+
transitionState?: TableTransitionState;
|
|
66
|
+
/** Enable zebra striping for alternating row backgrounds */
|
|
67
|
+
zebraStriping?: boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Props when resizable is enabled.
|
|
71
|
+
* Requires minWidth on all columns.
|
|
72
|
+
*/
|
|
73
|
+
export interface TableResizableProps<T extends TableDataSource = TableDataSource> extends TableBaseProps<T> {
|
|
74
|
+
/** Actions column configuration - minWidth required when resizable */
|
|
75
|
+
actions?: TableActionsWithMinWidth<T>;
|
|
76
|
+
/** Column configuration - minWidth required for each column when resizable */
|
|
77
|
+
columns: TableColumnWithMinWidth<T>[];
|
|
78
|
+
/**
|
|
79
|
+
* Whether columns are resizable by user interaction
|
|
80
|
+
*/
|
|
81
|
+
resizable: true;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Props when resizable is disabled or not specified.
|
|
85
|
+
*/
|
|
86
|
+
export interface TableNonResizableProps<T extends TableDataSource = TableDataSource> extends TableBaseProps<T> {
|
|
87
|
+
/** Actions column configuration */
|
|
88
|
+
actions?: TableActions<T>;
|
|
89
|
+
/** Column configuration */
|
|
90
|
+
columns: TableColumn<T>[];
|
|
91
|
+
/**
|
|
92
|
+
* Whether columns are resizable by user interaction
|
|
93
|
+
* @default false
|
|
94
|
+
*/
|
|
95
|
+
resizable?: false;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Props when draggable is enabled.
|
|
99
|
+
* Pinnable is not allowed when draggable is enabled.
|
|
100
|
+
*/
|
|
101
|
+
export type TableDraggableOnlyProps<T extends TableDataSource = TableDataSource> = {
|
|
102
|
+
/** Draggable row configuration */
|
|
103
|
+
draggable: TableDraggable<T>;
|
|
104
|
+
/** Not available when draggable is enabled */
|
|
105
|
+
pinnable?: never;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Props when pinnable is enabled.
|
|
109
|
+
* Draggable is not allowed when pinnable is enabled.
|
|
110
|
+
*/
|
|
111
|
+
export type TablePinnableOnlyProps<T extends TableDataSource = TableDataSource> = {
|
|
112
|
+
/** Not available when pinnable is enabled */
|
|
113
|
+
draggable?: never;
|
|
114
|
+
/** Pinnable row configuration */
|
|
115
|
+
pinnable: TablePinnable<T>;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Props when neither draggable nor pinnable is enabled.
|
|
119
|
+
*/
|
|
120
|
+
export type TableNoDragOrPinProps = {
|
|
121
|
+
/** Draggable row configuration */
|
|
122
|
+
draggable?: undefined;
|
|
123
|
+
/** Pinnable row configuration */
|
|
124
|
+
pinnable?: undefined;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Combined drag or pin props - discriminated union.
|
|
128
|
+
*/
|
|
129
|
+
export type TableDragOrPinProps<T extends TableDataSource = TableDataSource> = TableDraggableOnlyProps<T> | TablePinnableOnlyProps<T> | TableNoDragOrPinProps;
|
|
130
|
+
/**
|
|
131
|
+
* Props when virtualized scrolling is enabled.
|
|
132
|
+
* Draggable is not allowed in this mode, but pinnable is allowed.
|
|
133
|
+
*/
|
|
134
|
+
export type TableVirtualizedScrollProps = {
|
|
135
|
+
/** Draggable row configuration - not available when virtualized is enabled */
|
|
136
|
+
draggable?: never;
|
|
137
|
+
/** Scroll configuration with virtualized enabled */
|
|
138
|
+
scroll: TableScroll & {
|
|
139
|
+
virtualized: true;
|
|
140
|
+
y: number | string;
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Props when virtualized scrolling is disabled or not specified.
|
|
145
|
+
* Both draggable and pinnable are allowed.
|
|
146
|
+
*/
|
|
147
|
+
export type TableNonVirtualizedScrollProps = {
|
|
148
|
+
/** Scroll configuration for scrolling (virtualized defaults to false) */
|
|
149
|
+
scroll?: TableScroll & {
|
|
150
|
+
virtualized?: false;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Props when virtualized scrolling is enabled.
|
|
155
|
+
* Draggable is not allowed, but pinnable is allowed.
|
|
156
|
+
*/
|
|
157
|
+
export type TableVirtualizedProps<T extends TableDataSource = TableDataSource> = (TableResizableProps<T> | TableNonResizableProps<T>) & TableVirtualizedScrollProps & {
|
|
158
|
+
/** Pinnable row configuration - allowed with virtualized */
|
|
159
|
+
pinnable?: TablePinnable<T>;
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Props when virtualized scrolling is disabled or not specified.
|
|
163
|
+
* Draggable and pinnable are mutually exclusive.
|
|
164
|
+
*/
|
|
165
|
+
export type TableNonVirtualizedProps<T extends TableDataSource = TableDataSource> = (TableResizableProps<T> | TableNonResizableProps<T>) & TableNonVirtualizedScrollProps & TableDragOrPinProps<T>;
|
|
166
|
+
/**
|
|
167
|
+
* TableProps - discriminated union to ensure:
|
|
168
|
+
* 1. Draggable and virtualized scrolling are mutually exclusive
|
|
169
|
+
* 2. Draggable and pinnable are mutually exclusive (they share the same column position)
|
|
170
|
+
* 3. Resizable requires minWidth on all columns
|
|
171
|
+
*/
|
|
172
|
+
export type TableProps<T extends TableDataSource = TableDataSource> = TableVirtualizedProps<T> | TableNonVirtualizedProps<T>;
|
|
@@ -8,15 +8,23 @@ function useTableRowSelection(props) {
|
|
|
8
8
|
const { getSubData } = props;
|
|
9
9
|
const [selectedKeys, setSelectedKeys] = useState([]);
|
|
10
10
|
const parentSelectedKeys = useMemo(() => selectedKeys.map((item) => item.key), [selectedKeys]);
|
|
11
|
-
const parentOnChange = useCallback((_,
|
|
12
|
-
setSelectedKeys(selectedRows.map((row) => {
|
|
11
|
+
const parentOnChange = useCallback((_, selectedRow, selectedRows) => {
|
|
12
|
+
setSelectedKeys((prev) => selectedRows.map((row) => {
|
|
13
|
+
const isCurrentSelectedRow = row.key === (selectedRow === null || selectedRow === void 0 ? void 0 : selectedRow.key);
|
|
13
14
|
const subData = getSubData(row);
|
|
14
15
|
const pk = getRowKey(row);
|
|
16
|
+
const subKeys = (() => {
|
|
17
|
+
var _a;
|
|
18
|
+
if (isCurrentSelectedRow) {
|
|
19
|
+
return (subData === null || subData === void 0 ? void 0 : subData.length)
|
|
20
|
+
? subData.map((subRow) => getRowKey(subRow))
|
|
21
|
+
: undefined;
|
|
22
|
+
}
|
|
23
|
+
return (_a = prev.find((item) => item.key === pk)) === null || _a === void 0 ? void 0 : _a.subKeys;
|
|
24
|
+
})();
|
|
15
25
|
return {
|
|
16
26
|
key: pk,
|
|
17
|
-
subKeys
|
|
18
|
-
? subData.map((subRow) => getRowKey(subRow))
|
|
19
|
-
: undefined,
|
|
27
|
+
subKeys,
|
|
20
28
|
};
|
|
21
29
|
}));
|
|
22
30
|
}, [getSubData]);
|
package/Tag/TagGroup.d.ts
CHANGED
|
@@ -6,6 +6,9 @@ import { TransitionImplementationChildProps } from '../Transition';
|
|
|
6
6
|
type TagElement = ReactElement<TagProps & TransitionImplementationChildProps, typeof Tag>;
|
|
7
7
|
type OverflowCounterTagElement = ReactElement<OverflowCounterTagProps & TransitionImplementationChildProps, typeof OverflowCounterTag>;
|
|
8
8
|
type TagGroupChild = TagElement | OverflowCounterTagElement;
|
|
9
|
+
export type TagGroupProps = Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'children'> & {
|
|
10
|
+
children: TagGroupChild | TagGroupChild[];
|
|
11
|
+
};
|
|
9
12
|
declare const TagGroup: import("react").ForwardRefExoticComponent<Omit<NativeElementPropsWithoutKeyAndRef<"div">, "children"> & {
|
|
10
13
|
children: TagGroupChild | TagGroupChild[];
|
|
11
14
|
} & import("react").RefAttributes<HTMLDivElement>>;
|
package/Tag/index.d.ts
CHANGED
package/Tag/index.js
CHANGED
package/Transition/Slide.d.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { TransitionImplementationProps } from './Transition';
|
|
2
|
-
export type
|
|
2
|
+
export type SlideFrom = 'right' | 'top';
|
|
3
|
+
export interface SlideProps extends TransitionImplementationProps {
|
|
4
|
+
/**
|
|
5
|
+
* The position of child element will enter from.
|
|
6
|
+
* @default 'right'
|
|
7
|
+
*/
|
|
8
|
+
from?: SlideFrom;
|
|
9
|
+
}
|
|
3
10
|
/**
|
|
4
11
|
* The react component for `mezzanine` transition slide in/out.
|
|
5
12
|
*/
|
|
6
|
-
declare const Slide: import("react").ForwardRefExoticComponent<
|
|
13
|
+
declare const Slide: import("react").ForwardRefExoticComponent<SlideProps & import("react").RefAttributes<HTMLElement>>;
|
|
7
14
|
export default Slide;
|