@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
package/Table/Table.d.ts
CHANGED
|
@@ -1,123 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
3
|
-
import type { TableTransitionState } from './hooks/useTableDataSource';
|
|
4
|
-
import { TablePaginationProps } from './components/TablePagination';
|
|
5
|
-
import type { EmptyProps } from '../Empty';
|
|
6
|
-
export interface TableBaseProps<T extends TableDataSource = TableDataSource> extends Omit<NativeElementPropsWithoutKeyAndRef<'table'>, 'children' | 'draggable' | 'summary' | 'onChange'> {
|
|
7
|
-
/** Data source */
|
|
8
|
-
dataSource: T[];
|
|
9
|
-
/** Props for Empty component when no data */
|
|
10
|
-
emptyProps?: EmptyProps & {
|
|
11
|
-
height?: number | string;
|
|
12
|
-
};
|
|
13
|
-
/** Expandable row configuration */
|
|
14
|
-
expandable?: TableExpandable<T>;
|
|
15
|
-
/**
|
|
16
|
-
* Whether the table should stretch to fill its container width.
|
|
17
|
-
* When true, the table will always be 100% width of its container.
|
|
18
|
-
* Note: If the sum of all column widths is less than the table width,
|
|
19
|
-
* columns will be proportionally stretched to fill the remaining space.
|
|
20
|
-
* @default false
|
|
21
|
-
*/
|
|
22
|
-
fullWidth?: boolean;
|
|
23
|
-
/** Highlight mode for hover effects
|
|
24
|
-
* @default 'row'
|
|
25
|
-
*/
|
|
26
|
-
highlight?: HighlightMode;
|
|
27
|
-
/** Loading state */
|
|
28
|
-
loading?: boolean;
|
|
29
|
-
/** Number of rows to display when loading */
|
|
30
|
-
loadingRowsCount?: number;
|
|
31
|
-
/** Minimum height of the table */
|
|
32
|
-
minHeight?: number | string;
|
|
33
|
-
/**
|
|
34
|
-
* Whether the table is nested inside an expanded row content area
|
|
35
|
-
*/
|
|
36
|
-
nested?: boolean;
|
|
37
|
-
/** Pagination configuration */
|
|
38
|
-
pagination?: TablePaginationProps;
|
|
39
|
-
/**
|
|
40
|
-
* Row height preset token.
|
|
41
|
-
*/
|
|
42
|
-
rowHeightPreset?: 'base' | 'condensed' | 'detailed' | 'roomy';
|
|
43
|
-
/** Row selection configuration */
|
|
44
|
-
rowSelection?: TableRowSelection<T>;
|
|
45
|
-
/** Row indexes where a separator border should be displayed */
|
|
46
|
-
separatorAtRowIndexes?: number[];
|
|
47
|
-
/** Show header row */
|
|
48
|
-
showHeader?: boolean;
|
|
49
|
-
/** Custom size variant
|
|
50
|
-
* @default 'main'
|
|
51
|
-
*/
|
|
52
|
-
size?: TableSize;
|
|
53
|
-
/** Whether to enable sticky header
|
|
54
|
-
* @default true
|
|
55
|
-
*/
|
|
56
|
-
sticky?: boolean;
|
|
57
|
-
/** Transition state for row add/remove animations (from useTableDataSource hook) */
|
|
58
|
-
transitionState?: TableTransitionState;
|
|
59
|
-
/** Enable zebra striping for alternating row backgrounds */
|
|
60
|
-
zebraStriping?: boolean;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Props when resizable is enabled.
|
|
64
|
-
* Requires minWidth on all columns.
|
|
65
|
-
*/
|
|
66
|
-
export interface TableResizableProps<T extends TableDataSource = TableDataSource> extends TableBaseProps<T> {
|
|
67
|
-
/** Actions column configuration - minWidth required when resizable */
|
|
68
|
-
actions?: TableActionsWithMinWidth<T>;
|
|
69
|
-
/** Column configuration - minWidth required for each column when resizable */
|
|
70
|
-
columns: TableColumnWithMinWidth<T>[];
|
|
71
|
-
/**
|
|
72
|
-
* Whether columns are resizable by user interaction
|
|
73
|
-
*/
|
|
74
|
-
resizable: true;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Props when resizable is disabled or not specified.
|
|
78
|
-
*/
|
|
79
|
-
export interface TableNonResizableProps<T extends TableDataSource = TableDataSource> extends TableBaseProps<T> {
|
|
80
|
-
/** Actions column configuration */
|
|
81
|
-
actions?: TableActions<T>;
|
|
82
|
-
/** Column configuration */
|
|
83
|
-
columns: TableColumn<T>[];
|
|
84
|
-
/**
|
|
85
|
-
* Whether columns are resizable by user interaction
|
|
86
|
-
* @default false
|
|
87
|
-
*/
|
|
88
|
-
resizable?: false;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Props when virtualized scrolling is enabled.
|
|
92
|
-
* Draggable is not allowed in this mode.
|
|
93
|
-
*/
|
|
94
|
-
export type TableVirtualizedProps<T extends TableDataSource = TableDataSource> = (TableResizableProps<T> | TableNonResizableProps<T>) & {
|
|
95
|
-
/** Draggable row configuration - not available when virtualized is enabled */
|
|
96
|
-
draggable?: never;
|
|
97
|
-
/** Scroll configuration with virtualized enabled */
|
|
98
|
-
scroll: TableScroll & {
|
|
99
|
-
virtualized: true;
|
|
100
|
-
y: number | string;
|
|
101
|
-
};
|
|
102
|
-
};
|
|
103
|
-
/**
|
|
104
|
-
* Props when virtualized scrolling is disabled or not specified.
|
|
105
|
-
* Draggable is allowed in this mode.
|
|
106
|
-
*/
|
|
107
|
-
export type TableNonVirtualizedProps<T extends TableDataSource = TableDataSource> = (TableResizableProps<T> | TableNonResizableProps<T>) & {
|
|
108
|
-
/** Draggable row configuration */
|
|
109
|
-
draggable?: TableDraggable<T>;
|
|
110
|
-
/** Scroll configuration for scrolling (virtualized defaults to false) */
|
|
111
|
-
scroll?: TableScroll & {
|
|
112
|
-
virtualized?: false;
|
|
113
|
-
};
|
|
114
|
-
};
|
|
115
|
-
/**
|
|
116
|
-
* TableProps - discriminated union to ensure draggable and virtualized
|
|
117
|
-
* scrolling are mutually exclusive at the type level, and resizable
|
|
118
|
-
* requires minWidth on all columns.
|
|
119
|
-
*/
|
|
120
|
-
export type TableProps<T extends TableDataSource = TableDataSource> = TableVirtualizedProps<T> | TableNonVirtualizedProps<T>;
|
|
1
|
+
import { type TableDataSource } from '@mezzanine-ui/core/table';
|
|
2
|
+
import type { TableProps } from './typings';
|
|
121
3
|
/**
|
|
122
4
|
* Table is a high-performance data table component with support for
|
|
123
5
|
* virtual scrolling, column resizing, fixed columns, row selection,
|
package/Table/Table.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
3
|
import { forwardRef, useRef, useMemo, useState, useCallback, useEffect } from 'react';
|
|
4
4
|
import throttle from 'lodash/throttle';
|
|
5
|
-
import { TABLE_ACTIONS_KEY, tableClasses } from '@mezzanine-ui/core/table';
|
|
5
|
+
import { TOGGLEABLE_COLUMN_WIDTH, TOGGLEABLE_KEY, COLLECTABLE_COLUMN_WIDTH, COLLECTABLE_KEY, TABLE_ACTIONS_KEY, tableClasses } from '@mezzanine-ui/core/table';
|
|
6
6
|
import { DragDropContext, Droppable } from '@hello-pangea/dnd';
|
|
7
7
|
import { TableSuperContext, TableContext, TableDataContext } from './TableContext.js';
|
|
8
8
|
import { TableBody } from './components/TableBody.js';
|
|
@@ -19,10 +19,11 @@ import { getNumericCSSVariablePixelValue } from '../utils/get-css-variable-value
|
|
|
19
19
|
import { spacingPrefix } from '@mezzanine-ui/system/spacing';
|
|
20
20
|
import TableBulkActions from './components/TableBulkActions.js';
|
|
21
21
|
import { useComposeRefs } from '../hooks/useComposeRefs.js';
|
|
22
|
+
import Scrollbar from '../Scrollbar/Scrollbar.js';
|
|
22
23
|
import cx from 'clsx';
|
|
23
24
|
|
|
24
25
|
function TableInner(props, ref) {
|
|
25
|
-
const { actions, className, columns, dataSource, draggable, emptyProps, expandable, fullWidth = false, highlight = 'row', loading = false, loadingRowsCount = 10, minHeight, nested = false, pagination, resizable = false, rowHeightPreset = 'base', rowSelection, scroll, showHeader = true, size = 'main', sticky = true, style, transitionState, zebraStriping, separatorAtRowIndexes, ...restProps } = props;
|
|
26
|
+
const { actions, className, columns, dataSource, draggable, emptyProps, expandable, fullWidth = false, highlight = 'row', loading = false, loadingRowsCount = 10, minHeight, nested = false, pagination, pinnable, resizable = false, rowHeightPreset = 'base', rowSelection, scroll, showHeader = true, size = 'main', sticky = true, style, toggleable, collectable, transitionState, zebraStriping, separatorAtRowIndexes, ...restProps } = props;
|
|
26
27
|
const hostRef = useRef(null);
|
|
27
28
|
const composedHostRef = useComposeRefs([ref, hostRef]);
|
|
28
29
|
/** Feature: Loading */
|
|
@@ -71,19 +72,50 @@ function TableInner(props, ref) {
|
|
|
71
72
|
columns,
|
|
72
73
|
});
|
|
73
74
|
/** Feature: Actions column */
|
|
74
|
-
const
|
|
75
|
-
var _a;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
75
|
+
const columnsWithRightControls = useMemo(() => {
|
|
76
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
77
|
+
const result = [...columns];
|
|
78
|
+
// Add toggleable column (rightControl area - after data columns)
|
|
79
|
+
if (toggleable === null || toggleable === void 0 ? void 0 : toggleable.enabled) {
|
|
80
|
+
const toggleableColumn = {
|
|
81
|
+
align: (_a = toggleable.align) !== null && _a !== void 0 ? _a : 'start',
|
|
82
|
+
ellipsis: false,
|
|
83
|
+
fixed: toggleable.fixed ? 'end' : undefined,
|
|
84
|
+
key: TOGGLEABLE_KEY,
|
|
85
|
+
render: () => null, // Placeholder, actual rendering is handled in TableRow
|
|
86
|
+
title: toggleable.title,
|
|
87
|
+
width: (_b = toggleable.minWidth) !== null && _b !== void 0 ? _b : TOGGLEABLE_COLUMN_WIDTH,
|
|
88
|
+
minWidth: (_c = toggleable.minWidth) !== null && _c !== void 0 ? _c : TOGGLEABLE_COLUMN_WIDTH,
|
|
89
|
+
};
|
|
90
|
+
result.push(toggleableColumn);
|
|
91
|
+
}
|
|
92
|
+
// Add collectable column (rightControl area - after toggleable)
|
|
93
|
+
if (collectable === null || collectable === void 0 ? void 0 : collectable.enabled) {
|
|
94
|
+
const collectableColumn = {
|
|
95
|
+
align: (_d = collectable.align) !== null && _d !== void 0 ? _d : 'start',
|
|
96
|
+
ellipsis: false,
|
|
97
|
+
fixed: collectable.fixed ? 'end' : undefined,
|
|
98
|
+
key: COLLECTABLE_KEY,
|
|
99
|
+
render: () => null, // Placeholder, actual rendering is handled in TableRow
|
|
100
|
+
title: collectable.title,
|
|
101
|
+
width: (_e = collectable === null || collectable === void 0 ? void 0 : collectable.minWidth) !== null && _e !== void 0 ? _e : COLLECTABLE_COLUMN_WIDTH,
|
|
102
|
+
minWidth: (_f = collectable === null || collectable === void 0 ? void 0 : collectable.minWidth) !== null && _f !== void 0 ? _f : COLLECTABLE_COLUMN_WIDTH,
|
|
103
|
+
};
|
|
104
|
+
result.push(collectableColumn);
|
|
105
|
+
}
|
|
106
|
+
// Add actions column (rightmost)
|
|
107
|
+
if (actions) {
|
|
108
|
+
const actionsColumn = {
|
|
109
|
+
...actions,
|
|
110
|
+
align: (_g = actions.align) !== null && _g !== void 0 ? _g : 'end',
|
|
111
|
+
ellipsis: false,
|
|
112
|
+
key: TABLE_ACTIONS_KEY,
|
|
113
|
+
render: () => null, // Placeholder, actual rendering is handled in TableRow
|
|
114
|
+
};
|
|
115
|
+
result.push(actionsColumn);
|
|
116
|
+
}
|
|
117
|
+
return result;
|
|
118
|
+
}, [actions, collectable, columns, toggleable]);
|
|
87
119
|
/** Feature: Row selection */
|
|
88
120
|
const selectionState = useTableSelection({
|
|
89
121
|
dataSource,
|
|
@@ -92,27 +124,54 @@ function TableInner(props, ref) {
|
|
|
92
124
|
/** Feature: Expansion */
|
|
93
125
|
const expansionState = useTableExpansion({
|
|
94
126
|
expandable,
|
|
95
|
-
|
|
127
|
+
hasDragOrPinHandle: !!(draggable === null || draggable === void 0 ? void 0 : draggable.enabled) || !!(pinnable === null || pinnable === void 0 ? void 0 : pinnable.enabled),
|
|
96
128
|
});
|
|
97
129
|
/** Feature: Column resized */
|
|
98
130
|
const columnState = useTableResizedColumns();
|
|
99
131
|
/** Feature: Scroll and dimensions calculation */
|
|
100
|
-
const { containerWidth,
|
|
132
|
+
const { containerWidth, handleScrollbarScroll, handleViewportReady, isContainerReady, isScrollingHorizontally, scrollLeft, containerRef: scrollContainerRef, } = useTableScroll({
|
|
101
133
|
enabled: !nested,
|
|
102
134
|
});
|
|
103
135
|
const virtualScrollEnabled = useMemo(() => !!((scroll === null || scroll === void 0 ? void 0 : scroll.virtualized) && (scroll === null || scroll === void 0 ? void 0 : scroll.y)), [scroll === null || scroll === void 0 ? void 0 : scroll.virtualized, scroll === null || scroll === void 0 ? void 0 : scroll.y]);
|
|
104
136
|
/** Feature: Column fixed */
|
|
105
|
-
const actionConfig = useMemo(() =>
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
137
|
+
const actionConfig = useMemo(() => {
|
|
138
|
+
var _a, _b;
|
|
139
|
+
return ({
|
|
140
|
+
hasDragOrPinHandle: !!(draggable === null || draggable === void 0 ? void 0 : draggable.enabled) || !!(pinnable === null || pinnable === void 0 ? void 0 : pinnable.enabled),
|
|
141
|
+
dragOrPinHandleFixed: !!(draggable === null || draggable === void 0 ? void 0 : draggable.fixed) || !!(pinnable === null || pinnable === void 0 ? void 0 : pinnable.fixed),
|
|
142
|
+
dragOrPinHandleType: (draggable === null || draggable === void 0 ? void 0 : draggable.enabled)
|
|
143
|
+
? 'drag'
|
|
144
|
+
: (pinnable === null || pinnable === void 0 ? void 0 : pinnable.enabled)
|
|
145
|
+
? 'pin'
|
|
146
|
+
: undefined,
|
|
147
|
+
hasExpansion: !!expandable,
|
|
148
|
+
expansionFixed: !!(expandable === null || expandable === void 0 ? void 0 : expandable.fixed),
|
|
149
|
+
hasSelection: !!rowSelection,
|
|
150
|
+
selectionFixed: !!(rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.fixed),
|
|
151
|
+
hasToggleable: !!(toggleable === null || toggleable === void 0 ? void 0 : toggleable.enabled),
|
|
152
|
+
toggleableMinWidth: (_a = toggleable === null || toggleable === void 0 ? void 0 : toggleable.minWidth) !== null && _a !== void 0 ? _a : TOGGLEABLE_COLUMN_WIDTH,
|
|
153
|
+
toggleableFixed: !!(toggleable === null || toggleable === void 0 ? void 0 : toggleable.fixed),
|
|
154
|
+
hasCollectable: !!(collectable === null || collectable === void 0 ? void 0 : collectable.enabled),
|
|
155
|
+
collectableMinWidth: (_b = collectable === null || collectable === void 0 ? void 0 : collectable.minWidth) !== null && _b !== void 0 ? _b : COLLECTABLE_COLUMN_WIDTH,
|
|
156
|
+
collectableFixed: !!(collectable === null || collectable === void 0 ? void 0 : collectable.fixed),
|
|
157
|
+
});
|
|
158
|
+
}, [
|
|
159
|
+
collectable === null || collectable === void 0 ? void 0 : collectable.enabled,
|
|
160
|
+
collectable === null || collectable === void 0 ? void 0 : collectable.minWidth,
|
|
161
|
+
collectable === null || collectable === void 0 ? void 0 : collectable.fixed,
|
|
162
|
+
draggable === null || draggable === void 0 ? void 0 : draggable.enabled,
|
|
163
|
+
draggable === null || draggable === void 0 ? void 0 : draggable.fixed,
|
|
164
|
+
pinnable === null || pinnable === void 0 ? void 0 : pinnable.enabled,
|
|
165
|
+
pinnable === null || pinnable === void 0 ? void 0 : pinnable.fixed,
|
|
166
|
+
expandable,
|
|
167
|
+
rowSelection,
|
|
168
|
+
toggleable === null || toggleable === void 0 ? void 0 : toggleable.enabled,
|
|
169
|
+
toggleable === null || toggleable === void 0 ? void 0 : toggleable.minWidth,
|
|
170
|
+
toggleable === null || toggleable === void 0 ? void 0 : toggleable.fixed,
|
|
171
|
+
]);
|
|
113
172
|
const fixedOffsetsState = useTableFixedOffsets({
|
|
114
173
|
actionConfig,
|
|
115
|
-
columns:
|
|
174
|
+
columns: columnsWithRightControls,
|
|
116
175
|
getResizedColumnWidth: columnState.getResizedColumnWidth,
|
|
117
176
|
});
|
|
118
177
|
/** Feature: Drag n Drop */
|
|
@@ -139,60 +198,96 @@ function TableInner(props, ref) {
|
|
|
139
198
|
fixed: draggable.fixed,
|
|
140
199
|
}
|
|
141
200
|
: undefined, [draggable]);
|
|
201
|
+
const pinnableState = useMemo(() => pinnable
|
|
202
|
+
? {
|
|
203
|
+
enabled: pinnable.enabled,
|
|
204
|
+
fixed: pinnable.fixed,
|
|
205
|
+
pinnedRowKeys: pinnable.pinnedRowKeys,
|
|
206
|
+
onPinChange: pinnable.onPinChange,
|
|
207
|
+
}
|
|
208
|
+
: undefined, [pinnable]);
|
|
209
|
+
const toggleableState = useMemo(() => toggleable
|
|
210
|
+
? {
|
|
211
|
+
enabled: toggleable.enabled,
|
|
212
|
+
fixed: toggleable.fixed,
|
|
213
|
+
isRowDisabled: toggleable.isRowDisabled,
|
|
214
|
+
onToggleChange: toggleable.onToggleChange,
|
|
215
|
+
title: toggleable.title,
|
|
216
|
+
toggledRowKeys: toggleable.toggledRowKeys,
|
|
217
|
+
}
|
|
218
|
+
: undefined, [toggleable]);
|
|
219
|
+
const collectableState = useMemo(() => collectable
|
|
220
|
+
? {
|
|
221
|
+
enabled: collectable.enabled,
|
|
222
|
+
collectedRowKeys: collectable.collectedRowKeys,
|
|
223
|
+
fixed: collectable.fixed,
|
|
224
|
+
isRowDisabled: collectable.isRowDisabled,
|
|
225
|
+
onCollectChange: collectable.onCollectChange,
|
|
226
|
+
title: collectable.title,
|
|
227
|
+
}
|
|
228
|
+
: undefined, [collectable]);
|
|
142
229
|
/** Context values */
|
|
143
230
|
const contextValue = useMemo(() => ({
|
|
144
231
|
actions: actions,
|
|
232
|
+
collectable: collectableState,
|
|
145
233
|
columnState,
|
|
146
234
|
dataSource: dataSourceForRender,
|
|
147
235
|
draggable: draggableState,
|
|
148
236
|
emptyProps,
|
|
149
237
|
expansion: expansionState,
|
|
150
238
|
fixedOffsets: fixedOffsetsState,
|
|
151
|
-
resizable,
|
|
152
|
-
rowHeight,
|
|
153
239
|
highlight: highlightValue,
|
|
154
|
-
|
|
240
|
+
isContainerReady,
|
|
155
241
|
isInsideExpandedContentArea: nested,
|
|
242
|
+
isScrollingHorizontally: isScrollingHorizontally,
|
|
156
243
|
loading,
|
|
157
244
|
pagination: pagination || undefined,
|
|
245
|
+
pinnable: pinnableState,
|
|
246
|
+
resizable,
|
|
247
|
+
rowHeight,
|
|
158
248
|
scroll,
|
|
159
249
|
scrollContainerRef,
|
|
160
250
|
selection: selectionState,
|
|
161
|
-
size,
|
|
162
251
|
separatorAtRowIndexes,
|
|
252
|
+
size,
|
|
163
253
|
sorting: sortingState,
|
|
254
|
+
toggleable: toggleableState,
|
|
164
255
|
transitionState,
|
|
165
256
|
virtualScrollEnabled,
|
|
166
257
|
zebraStriping,
|
|
167
258
|
}), [
|
|
168
259
|
actions,
|
|
260
|
+
collectableState,
|
|
169
261
|
columnState,
|
|
170
262
|
dataSourceForRender,
|
|
171
263
|
draggableState,
|
|
172
264
|
emptyProps,
|
|
173
265
|
expansionState,
|
|
174
266
|
fixedOffsetsState,
|
|
175
|
-
resizable,
|
|
176
|
-
rowHeight,
|
|
177
267
|
highlightValue,
|
|
268
|
+
isContainerReady,
|
|
269
|
+
isScrollingHorizontally,
|
|
178
270
|
loading,
|
|
271
|
+
nested,
|
|
179
272
|
pagination,
|
|
273
|
+
pinnableState,
|
|
274
|
+
resizable,
|
|
275
|
+
rowHeight,
|
|
180
276
|
scroll,
|
|
181
277
|
scrollContainerRef,
|
|
182
|
-
isScrollingHorizontally,
|
|
183
278
|
selectionState,
|
|
279
|
+
separatorAtRowIndexes,
|
|
184
280
|
size,
|
|
185
281
|
sortingState,
|
|
282
|
+
toggleableState,
|
|
186
283
|
transitionState,
|
|
187
284
|
virtualScrollEnabled,
|
|
188
285
|
zebraStriping,
|
|
189
|
-
separatorAtRowIndexes,
|
|
190
|
-
nested,
|
|
191
286
|
]);
|
|
192
287
|
const dataContextValue = useMemo(() => ({
|
|
193
|
-
columns:
|
|
288
|
+
columns: columnsWithRightControls,
|
|
194
289
|
dataSource,
|
|
195
|
-
}), [
|
|
290
|
+
}), [columnsWithRightControls, dataSource]);
|
|
196
291
|
const superContextValue = useMemo(() => {
|
|
197
292
|
var _a;
|
|
198
293
|
return ({
|
|
@@ -200,7 +295,8 @@ function TableInner(props, ref) {
|
|
|
200
295
|
getResizedColumnWidth: columnState.getResizedColumnWidth,
|
|
201
296
|
scrollLeft: scrollLeft,
|
|
202
297
|
expansionLeftPadding: (_a = expansionState === null || expansionState === void 0 ? void 0 : expansionState.expansionLeftPadding) !== null && _a !== void 0 ? _a : 0,
|
|
203
|
-
|
|
298
|
+
hasDragOrPinHandleFixed: (!!(draggable === null || draggable === void 0 ? void 0 : draggable.enabled) && draggable.fixed) ||
|
|
299
|
+
(!!(pinnable === null || pinnable === void 0 ? void 0 : pinnable.enabled) && pinnable.fixed),
|
|
204
300
|
});
|
|
205
301
|
}, [
|
|
206
302
|
scrollLeft,
|
|
@@ -209,22 +305,17 @@ function TableInner(props, ref) {
|
|
|
209
305
|
columnState.getResizedColumnWidth,
|
|
210
306
|
draggable === null || draggable === void 0 ? void 0 : draggable.enabled,
|
|
211
307
|
draggable === null || draggable === void 0 ? void 0 : draggable.fixed,
|
|
308
|
+
pinnable === null || pinnable === void 0 ? void 0 : pinnable.enabled,
|
|
309
|
+
pinnable === null || pinnable === void 0 ? void 0 : pinnable.fixed,
|
|
212
310
|
]);
|
|
213
311
|
/** Computed styles */
|
|
214
312
|
const scrollContainerStyle = useMemo(() => {
|
|
215
313
|
const containerStyle = {};
|
|
216
|
-
if (scroll === null || scroll === void 0 ? void 0 : scroll.y) {
|
|
217
|
-
containerStyle.maxHeight = scroll.y;
|
|
218
|
-
}
|
|
219
|
-
if (nested) {
|
|
220
|
-
containerStyle.position = 'unset';
|
|
221
|
-
containerStyle.overflow = 'unset';
|
|
222
|
-
}
|
|
223
314
|
if (minHeight) {
|
|
224
315
|
containerStyle.minHeight = minHeight;
|
|
225
316
|
}
|
|
226
317
|
return containerStyle;
|
|
227
|
-
}, [
|
|
318
|
+
}, [minHeight]);
|
|
228
319
|
const tableStyle = useMemo(() => {
|
|
229
320
|
const baseStyle = {};
|
|
230
321
|
if (fullWidth) {
|
|
@@ -234,12 +325,18 @@ function TableInner(props, ref) {
|
|
|
234
325
|
}, [fullWidth]);
|
|
235
326
|
/** Scroll Container Ref */
|
|
236
327
|
const droppableInnerRefSetter = useRef(null);
|
|
237
|
-
|
|
238
|
-
|
|
328
|
+
// Handler for Scrollbar's onViewportReady - composes with handleViewportReady and droppable innerRef
|
|
329
|
+
const handleScrollbarViewportReady = useCallback((viewport, instance) => {
|
|
330
|
+
handleViewportReady(viewport, instance);
|
|
331
|
+
// Also set droppable innerRef to viewport element for DnD
|
|
239
332
|
if (droppableInnerRefSetter.current) {
|
|
240
|
-
droppableInnerRefSetter.current(
|
|
333
|
+
droppableInnerRefSetter.current(viewport);
|
|
241
334
|
}
|
|
242
|
-
}, [
|
|
335
|
+
}, [handleViewportReady]);
|
|
336
|
+
// Scrollbar events for OverlayScrollbars
|
|
337
|
+
const scrollbarEvents = useMemo(() => ({
|
|
338
|
+
scroll: handleScrollbarScroll,
|
|
339
|
+
}), [handleScrollbarScroll]);
|
|
243
340
|
/** Feature: bulk actions */
|
|
244
341
|
const bulkActionsConfig = useMemo(() => {
|
|
245
342
|
if (!selectionState || selectionState.mode !== 'checkbox') {
|
|
@@ -314,9 +411,7 @@ function TableInner(props, ref) {
|
|
|
314
411
|
else {
|
|
315
412
|
droppableInnerRefSetter.current = null;
|
|
316
413
|
}
|
|
317
|
-
return (jsx(TableContext.Provider, { value: contextValue, children: jsx(TableDataContext.Provider, { value: dataContextValue, children: jsxs("div", { className: cx(tableClasses.host, className), ref: composedHostRef, style: style, ...restProps, children: [jsx(
|
|
318
|
-
[tableClasses.sticky]: !!sticky,
|
|
319
|
-
}), onScroll: handleScroll, ref: droppableProvided ? composedScrollContainerRef : setContainerRef, style: scrollContainerStyle, children: jsxs("table", { className: cx(tableClasses.root, size === 'sub' ? tableClasses.sub : tableClasses.main), style: tableStyle, children: [jsx(TableColGroup, {}), showHeader && jsx(TableHeader, {}), jsx(TableBody, {}), (droppableProvided === null || droppableProvided === void 0 ? void 0 : droppableProvided.placeholder) ? (jsx("tbody", { children: droppableProvided.placeholder })) : null] }) }), pagination && (jsx(TablePagination, { ...pagination, ref: paginationRef })), (bulkActionsConfig === null || bulkActionsConfig === void 0 ? void 0 : bulkActionsConfig.enabled) ? (jsx(TableBulkActions, { bulkActions: bulkActionsConfig.bulkActions, isFixed: isBulkActionsFixed, onClearSelection: bulkActionsConfig.onClearSelection, selectedRowKeys: bulkActionsConfig.selectedRowKeys })) : null] }) }) }));
|
|
414
|
+
return (jsx(TableContext.Provider, { value: contextValue, children: jsx(TableDataContext.Provider, { value: dataContextValue, children: jsxs("div", { className: cx(tableClasses.host, className), ref: composedHostRef, style: style, ...restProps, children: [jsx(Scrollbar, { ...droppableProvided === null || droppableProvided === void 0 ? void 0 : droppableProvided.droppableProps, className: sticky ? tableClasses.sticky : undefined, defer: false, disabled: nested, events: scrollbarEvents, onViewportReady: handleScrollbarViewportReady, style: scrollContainerStyle, maxHeight: scroll === null || scroll === void 0 ? void 0 : scroll.y, children: jsxs("table", { className: cx(tableClasses.root, size === 'sub' ? tableClasses.sub : tableClasses.main), style: tableStyle, children: [jsx(TableColGroup, {}), showHeader && jsx(TableHeader, {}), jsx(TableBody, {}), (droppableProvided === null || droppableProvided === void 0 ? void 0 : droppableProvided.placeholder) ? (jsx("tbody", { children: droppableProvided.placeholder })) : null] }) }), pagination && (jsx(TablePagination, { ...pagination, ref: paginationRef })), (bulkActionsConfig === null || bulkActionsConfig === void 0 ? void 0 : bulkActionsConfig.enabled) ? (jsx(TableBulkActions, { bulkActions: bulkActionsConfig.bulkActions, isFixed: isBulkActionsFixed, onClearSelection: bulkActionsConfig.onClearSelection, selectedRowKeys: bulkActionsConfig.selectedRowKeys })) : null] }) }) }));
|
|
320
415
|
};
|
|
321
416
|
if (nested) {
|
|
322
417
|
return renderMainTable();
|
package/Table/TableContext.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HighlightMode, TableSize, TableActionsBase, TableColumn, TableDataSource, TableExpandable, TableRowSelection, TableScroll, TableSelectionMode } from '@mezzanine-ui/core/table';
|
|
1
|
+
import type { HighlightMode, TableSize, TableActionsBase, TableColumn, TableDataSource, TableExpandable, TableRowSelection, TableScroll, TableSelectionMode, TableCollectable, TableToggleable, TablePinnable, TableDraggable } from '@mezzanine-ui/core/table';
|
|
2
2
|
import type { EmptyProps } from '../Empty';
|
|
3
3
|
import type { PaginationProps } from '../Pagination';
|
|
4
4
|
import type { UseTableFixedOffsetsReturn } from './hooks/useTableFixedOffsets';
|
|
@@ -32,11 +32,6 @@ export interface TableResizedColumnState {
|
|
|
32
32
|
getResizedColumnWidth: (key: string) => number | undefined;
|
|
33
33
|
setResizedColumnWidth: (key: string, width: number) => void;
|
|
34
34
|
}
|
|
35
|
-
/** Draggable state */
|
|
36
|
-
export interface TableDraggableState {
|
|
37
|
-
enabled: boolean;
|
|
38
|
-
fixed?: boolean | 'start';
|
|
39
|
-
}
|
|
40
35
|
/** Highlight state for hover effects */
|
|
41
36
|
export interface TableHighlightState {
|
|
42
37
|
columnIndex: number | null;
|
|
@@ -47,30 +42,34 @@ export interface TableHighlightState {
|
|
|
47
42
|
/** Main table context */
|
|
48
43
|
export interface TableContextValue<T extends TableDataSource = TableDataSource> {
|
|
49
44
|
actions?: TableActionsBase<T>;
|
|
45
|
+
collectable?: TableCollectable<T>;
|
|
50
46
|
columnState?: TableResizedColumnState;
|
|
51
47
|
dataSource: T[];
|
|
52
|
-
draggable?:
|
|
48
|
+
draggable?: Omit<TableDraggable<T>, 'onDragEnd'>;
|
|
53
49
|
emptyProps?: EmptyProps & {
|
|
54
50
|
height?: number | string;
|
|
55
51
|
};
|
|
56
52
|
expansion?: TableExpansionState<T>;
|
|
57
53
|
fixedOffsets?: UseTableFixedOffsetsReturn;
|
|
58
|
-
resizable?: boolean;
|
|
59
|
-
rowHeight: number;
|
|
60
54
|
highlight?: TableHighlightState;
|
|
55
|
+
isContainerReady?: boolean;
|
|
56
|
+
isInsideExpandedContentArea?: boolean;
|
|
61
57
|
isScrollingHorizontally?: boolean;
|
|
62
58
|
loading?: boolean;
|
|
63
59
|
pagination?: PaginationProps;
|
|
64
|
-
|
|
60
|
+
pinnable?: TablePinnable;
|
|
61
|
+
resizable?: boolean;
|
|
62
|
+
rowHeight: number;
|
|
65
63
|
scroll?: TableScroll;
|
|
66
64
|
scrollContainerRef?: React.RefObject<HTMLDivElement | null>;
|
|
67
65
|
selection?: TableSelectionState<T>;
|
|
68
66
|
separatorAtRowIndexes?: number[];
|
|
67
|
+
size?: TableSize;
|
|
69
68
|
sorting?: TableSortingState;
|
|
69
|
+
toggleable?: TableToggleable<T>;
|
|
70
70
|
transitionState?: TableTransitionState;
|
|
71
71
|
virtualScrollEnabled?: boolean;
|
|
72
72
|
zebraStriping?: boolean;
|
|
73
|
-
isInsideExpandedContentArea?: boolean;
|
|
74
73
|
}
|
|
75
74
|
export declare const TableContext: import("react").Context<TableContextValue<TableDataSource> | null>;
|
|
76
75
|
export declare function useTableContext<T extends TableDataSource = TableDataSource>(): TableContextValue<T>;
|
|
@@ -86,7 +85,7 @@ export interface TableSuperContextValue {
|
|
|
86
85
|
getResizedColumnWidth?: (key: string) => number | undefined;
|
|
87
86
|
scrollLeft?: number;
|
|
88
87
|
expansionLeftPadding?: number;
|
|
89
|
-
|
|
88
|
+
hasDragOrPinHandleFixed?: boolean;
|
|
90
89
|
}
|
|
91
90
|
export declare const TableSuperContext: import("react").Context<TableSuperContextValue | null>;
|
|
92
91
|
export declare function useTableSuperContext(): TableSuperContextValue;
|
|
@@ -4,7 +4,8 @@ import { memo, forwardRef, useMemo } from 'react';
|
|
|
4
4
|
import { getCellAlignClass, tableClasses } from '@mezzanine-ui/core/table';
|
|
5
5
|
import { useTableContext } from '../TableContext.js';
|
|
6
6
|
import Button from '../../Button/Button.js';
|
|
7
|
-
import
|
|
7
|
+
import { DotHorizontalIcon } from '@mezzanine-ui/icons';
|
|
8
|
+
import Dropdown from '../../Dropdown/Dropdown.js';
|
|
8
9
|
import cx from 'clsx';
|
|
9
10
|
|
|
10
11
|
const TableActionsCellInner = forwardRef(function TableActionsCell(props, ref) {
|
|
@@ -67,10 +68,17 @@ const TableActionsCellInner = forwardRef(function TableActionsCell(props, ref) {
|
|
|
67
68
|
[tableClasses.cellFixedShadow]: showShadow,
|
|
68
69
|
[tableClasses.cellFixedStart]: fixed === 'start',
|
|
69
70
|
[tableClasses.cellHighlight]: isCellHighlighted,
|
|
70
|
-
}, className), onMouseEnter: handleMouseEnter, ref: ref, style: cellStyle, children: jsx("div", { className: cx(tableClasses.cellContent, alignClass), children: jsx(
|
|
71
|
-
var _a, _b, _c, _d;
|
|
71
|
+
}, className), onMouseEnter: handleMouseEnter, ref: ref, style: cellStyle, children: jsx("div", { className: cx(tableClasses.cellContent, alignClass), children: jsx("div", { className: tableClasses.actionsCell, children: actionItems.map((item, actionIndex) => {
|
|
72
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
72
73
|
const isDisabled = (_b = (_a = item.disabled) === null || _a === void 0 ? void 0 : _a.call(item, record)) !== null && _b !== void 0 ? _b : false;
|
|
73
|
-
|
|
74
|
+
const baseKey = `${item.name || 'name'}-${((_c = item.icon) === null || _c === void 0 ? void 0 : _c.name) || 'icon'}-${rowIndex}-${actionIndex}`;
|
|
75
|
+
if (item.type === 'dropdown') {
|
|
76
|
+
const dropdownItem = item;
|
|
77
|
+
return (jsx(Dropdown, { type: "default", maxHeight: dropdownItem.maxHeight, onSelect: (option) => dropdownItem.onSelect(option, record, rowIndex), options: dropdownItem.options, placement: (_d = dropdownItem.placement) !== null && _d !== void 0 ? _d : 'bottom-end', children: jsx(Button, { iconType: "icon-only", icon: (_e = dropdownItem === null || dropdownItem === void 0 ? void 0 : dropdownItem.icon) !== null && _e !== void 0 ? _e : DotHorizontalIcon, size: "sub", type: "button", variant: (_f = dropdownItem.variant) !== null && _f !== void 0 ? _f : 'base-text-link', children: dropdownItem.name }) }, baseKey));
|
|
78
|
+
}
|
|
79
|
+
// Default to button type
|
|
80
|
+
const buttonItem = item;
|
|
81
|
+
return (jsx(Button, { disabled: isDisabled, icon: buttonItem.icon, iconType: buttonItem.iconType, onClick: () => buttonItem.onClick(record, rowIndex), size: "sub", type: "button", variant: (_g = buttonItem.variant) !== null && _g !== void 0 ? _g : actions.variant, children: buttonItem.name }, baseKey));
|
|
74
82
|
}) }) }) }));
|
|
75
83
|
});
|
|
76
84
|
const TableActionsCell = memo(TableActionsCellInner);
|
|
@@ -13,7 +13,7 @@ import Fade from '../../Transition/Fade.js';
|
|
|
13
13
|
import cx from 'clsx';
|
|
14
14
|
|
|
15
15
|
const TableBodyInner = forwardRef(function TableBody(_, ref) {
|
|
16
|
-
const { dataSource, draggable, emptyProps, expansion, loading, scrollContainerRef, selection, size, virtualScrollEnabled, } = useTableContext();
|
|
16
|
+
const { dataSource, draggable, emptyProps, expansion, isContainerReady, loading, scrollContainerRef, selection, size, virtualScrollEnabled, } = useTableContext();
|
|
17
17
|
const { columns } = useTableDataContext();
|
|
18
18
|
/** Feature: Empty State */
|
|
19
19
|
const isEmpty = useMemo(() => !dataSource.length, [dataSource.length]);
|
|
@@ -21,6 +21,7 @@ const TableBodyInner = forwardRef(function TableBody(_, ref) {
|
|
|
21
21
|
const virtualization = useTableVirtualization({
|
|
22
22
|
dataSource,
|
|
23
23
|
enabled: virtualScrollEnabled,
|
|
24
|
+
isContainerReady,
|
|
24
25
|
isRowExpanded: expansion === null || expansion === void 0 ? void 0 : expansion.isRowExpanded,
|
|
25
26
|
scrollContainerRef: scrollContainerRef,
|
|
26
27
|
});
|
|
@@ -20,25 +20,7 @@ function TableBulkActions(props) {
|
|
|
20
20
|
: `${selectedRowKeys.length} item${selectedRowKeys.length > 1 ? 's' : ''} selected`;
|
|
21
21
|
return (jsxs("div", { className: cx(tableClasses.bulkActions, className, {
|
|
22
22
|
[tableClasses.bulkActionsFixed]: isFixed,
|
|
23
|
-
}), children: [jsx("div", { className: tableClasses.bulkActionsSelectionSummary, children: jsx(Button, { icon: {
|
|
24
|
-
position: 'trailing',
|
|
25
|
-
src: CloseIcon,
|
|
26
|
-
}, onClick: onClearSelection, size: "sub", type: "button", variant: "inverse", children: label }) }), jsxs("div", { className: tableClasses.bulkActionsActionArea, children: [mainActions.map((action, index) => (jsx(Button, { icon: action.icon
|
|
27
|
-
? {
|
|
28
|
-
position: 'leading',
|
|
29
|
-
src: action.icon,
|
|
30
|
-
}
|
|
31
|
-
: undefined, onClick: () => action.onClick(selectedRowKeys, selectedRows), size: "sub", type: "button", variant: "inverse-ghost", children: action.label }, `main-action-${index}`))), destructiveAction && (jsxs(Fragment, { children: [jsx("div", { className: tableClasses.bulkActionsSeparator }), jsx(Button, { icon: destructiveAction.icon
|
|
32
|
-
? {
|
|
33
|
-
position: 'leading',
|
|
34
|
-
src: destructiveAction.icon,
|
|
35
|
-
}
|
|
36
|
-
: undefined, onClick: () => destructiveAction.onClick(selectedRowKeys, selectedRows), size: "sub", type: "button", variant: "destructive-ghost", children: destructiveAction.label })] })), overflowAction && (jsxs(Fragment, { children: [jsx("div", { className: tableClasses.bulkActionsSeparator }), jsx(Dropdown, { maxHeight: overflowAction.maxHeight, onSelect: (option) => overflowAction.onSelect(option, selectedRowKeys, selectedRows), options: overflowAction.options, placement: (_a = overflowAction.placement) !== null && _a !== void 0 ? _a : 'top', children: jsx(Button, { size: "sub", type: "button", variant: "inverse-ghost", icon: overflowAction.icon
|
|
37
|
-
? {
|
|
38
|
-
position: 'leading',
|
|
39
|
-
src: overflowAction.icon,
|
|
40
|
-
}
|
|
41
|
-
: undefined, children: overflowAction.label }) })] }))] })] }));
|
|
23
|
+
}), children: [jsx("div", { className: tableClasses.bulkActionsSelectionSummary, children: jsx(Button, { iconType: "trailing", icon: CloseIcon, onClick: onClearSelection, size: "sub", type: "button", variant: "inverse", children: label }) }), jsxs("div", { className: tableClasses.bulkActionsActionArea, children: [mainActions.map((action, index) => (jsx(Button, { iconType: "leading", icon: action.icon, onClick: () => action.onClick(selectedRowKeys, selectedRows), size: "sub", type: "button", variant: "inverse-ghost", children: action.label }, `main-action-${index}`))), destructiveAction && (jsxs(Fragment, { children: [jsx("div", { className: tableClasses.bulkActionsSeparator }), jsx(Button, { iconType: "leading", icon: destructiveAction.icon, onClick: () => destructiveAction.onClick(selectedRowKeys, selectedRows), size: "sub", type: "button", variant: "destructive-ghost", children: destructiveAction.label })] })), overflowAction && (jsxs(Fragment, { children: [jsx("div", { className: tableClasses.bulkActionsSeparator }), jsx(Dropdown, { maxHeight: overflowAction.maxHeight, onSelect: (option) => overflowAction.onSelect(option, selectedRowKeys, selectedRows), options: overflowAction.options, placement: (_a = overflowAction.placement) !== null && _a !== void 0 ? _a : 'top', children: jsx(Button, { size: "sub", type: "button", variant: "inverse-ghost", iconType: "leading", icon: overflowAction.icon, children: overflowAction.label }) })] }))] })] }));
|
|
42
24
|
}
|
|
43
25
|
|
|
44
26
|
export { TableBulkActions as default };
|