@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,13 +1,12 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { memo, useMemo } from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { DRAG_OR_PIN_HANDLE_COLUMN_WIDTH, SELECTION_COLUMN_WIDTH, EXPANSION_COLUMN_WIDTH, DRAG_OR_PIN_HANDLE_KEY, EXPANSION_KEY, SELECTION_KEY } from '@mezzanine-ui/core/table';
|
|
5
5
|
import { useTableContext, useTableDataContext, useTableSuperContext } from '../TableContext.js';
|
|
6
6
|
import { calculateColumnWidths, shouldCalculateWidths } from '../utils/calculateColumnWidths.js';
|
|
7
7
|
|
|
8
|
-
const TableColGroupInner = memo(function TableColGroup(
|
|
9
|
-
const {
|
|
10
|
-
const { columnState, draggable, expansion, isInsideExpandedContentArea, selection, } = useTableContext();
|
|
8
|
+
const TableColGroupInner = memo(function TableColGroup() {
|
|
9
|
+
const { columnState, draggable, expansion, isInsideExpandedContentArea, pinnable, selection, } = useTableContext();
|
|
11
10
|
const { columns } = useTableDataContext();
|
|
12
11
|
const { containerWidth, getResizedColumnWidth: getParentResizedColumnWidth } = useTableSuperContext();
|
|
13
12
|
// For nested tables, use parent's resized widths; for root tables, use own
|
|
@@ -19,14 +18,14 @@ const TableColGroupInner = memo(function TableColGroup(props) {
|
|
|
19
18
|
// Calculate action columns total width
|
|
20
19
|
const actionColumnsWidth = useMemo(() => {
|
|
21
20
|
let width = 0;
|
|
22
|
-
if (draggable === null || draggable === void 0 ? void 0 : draggable.enabled)
|
|
23
|
-
width +=
|
|
21
|
+
if ((draggable === null || draggable === void 0 ? void 0 : draggable.enabled) || (pinnable === null || pinnable === void 0 ? void 0 : pinnable.enabled))
|
|
22
|
+
width += DRAG_OR_PIN_HANDLE_COLUMN_WIDTH;
|
|
24
23
|
if (selection)
|
|
25
24
|
width += SELECTION_COLUMN_WIDTH;
|
|
26
25
|
if (expansion)
|
|
27
26
|
width += EXPANSION_COLUMN_WIDTH;
|
|
28
27
|
return width;
|
|
29
|
-
}, [draggable === null || draggable === void 0 ? void 0 : draggable.enabled, expansion, selection]);
|
|
28
|
+
}, [draggable === null || draggable === void 0 ? void 0 : draggable.enabled, expansion, pinnable === null || pinnable === void 0 ? void 0 : pinnable.enabled, selection]);
|
|
30
29
|
// Calculate resolved widths for all columns (only for root tables)
|
|
31
30
|
const resolvedWidths = useMemo(() => {
|
|
32
31
|
if (!enableWidthCalculation) {
|
|
@@ -47,22 +46,22 @@ const TableColGroupInner = memo(function TableColGroup(props) {
|
|
|
47
46
|
]);
|
|
48
47
|
const renderCols = () => {
|
|
49
48
|
const cols = [];
|
|
50
|
-
if (draggable === null || draggable === void 0 ? void 0 : draggable.enabled) {
|
|
51
|
-
cols.push(jsx("col", {
|
|
52
|
-
maxWidth:
|
|
53
|
-
minWidth:
|
|
54
|
-
width:
|
|
55
|
-
} },
|
|
49
|
+
if ((draggable === null || draggable === void 0 ? void 0 : draggable.enabled) || (pinnable === null || pinnable === void 0 ? void 0 : pinnable.enabled)) {
|
|
50
|
+
cols.push(jsx("col", { style: {
|
|
51
|
+
maxWidth: DRAG_OR_PIN_HANDLE_COLUMN_WIDTH,
|
|
52
|
+
minWidth: DRAG_OR_PIN_HANDLE_COLUMN_WIDTH,
|
|
53
|
+
width: DRAG_OR_PIN_HANDLE_COLUMN_WIDTH,
|
|
54
|
+
} }, DRAG_OR_PIN_HANDLE_KEY));
|
|
56
55
|
}
|
|
57
56
|
if (expansion) {
|
|
58
|
-
cols.push(jsx("col", {
|
|
57
|
+
cols.push(jsx("col", { style: {
|
|
59
58
|
maxWidth: EXPANSION_COLUMN_WIDTH,
|
|
60
59
|
minWidth: EXPANSION_COLUMN_WIDTH,
|
|
61
60
|
width: EXPANSION_COLUMN_WIDTH,
|
|
62
61
|
} }, EXPANSION_KEY));
|
|
63
62
|
}
|
|
64
63
|
if (selection) {
|
|
65
|
-
cols.push(jsx("col", {
|
|
64
|
+
cols.push(jsx("col", { style: {
|
|
66
65
|
maxWidth: SELECTION_COLUMN_WIDTH,
|
|
67
66
|
minWidth: SELECTION_COLUMN_WIDTH,
|
|
68
67
|
width: SELECTION_COLUMN_WIDTH,
|
|
@@ -97,7 +96,7 @@ const TableColGroupInner = memo(function TableColGroup(props) {
|
|
|
97
96
|
});
|
|
98
97
|
return cols;
|
|
99
98
|
};
|
|
100
|
-
return jsx("colgroup", {
|
|
99
|
+
return jsx("colgroup", { children: renderCols() });
|
|
101
100
|
});
|
|
102
101
|
const TableColGroup = TableColGroupInner;
|
|
103
102
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type TableDataSource } from '@mezzanine-ui/core/table';
|
|
2
|
+
export interface TableCollectableCellProps<T extends TableDataSource = TableDataSource> {
|
|
3
|
+
className?: string;
|
|
4
|
+
fixed?: boolean;
|
|
5
|
+
fixedOffset?: number;
|
|
6
|
+
isHeader?: boolean;
|
|
7
|
+
/** Row record - required when isHeader is false */
|
|
8
|
+
record?: T;
|
|
9
|
+
showShadow?: boolean;
|
|
10
|
+
/** Explicit width for dragging state */
|
|
11
|
+
width?: number;
|
|
12
|
+
}
|
|
13
|
+
declare const ForwardedTableCollectableCell: <T extends TableDataSource = TableDataSource>(props: TableCollectableCellProps<T> & {
|
|
14
|
+
ref?: React.ForwardedRef<HTMLTableCellElement>;
|
|
15
|
+
}) => React.ReactElement;
|
|
16
|
+
export declare const TableCollectableCell: typeof ForwardedTableCollectableCell;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { memo, forwardRef, useCallback } from 'react';
|
|
4
|
+
import { getRowKey, tableClasses } from '@mezzanine-ui/core/table';
|
|
5
|
+
import { StarFilledIcon, StarOutlineIcon } from '@mezzanine-ui/icons';
|
|
6
|
+
import { useTableContext } from '../TableContext.js';
|
|
7
|
+
import Skeleton from '../../Skeleton/Skeleton.js';
|
|
8
|
+
import Icon from '../../Icon/Icon.js';
|
|
9
|
+
import cx from 'clsx';
|
|
10
|
+
|
|
11
|
+
function TableCollectableCellInner(props, ref) {
|
|
12
|
+
var _a, _b, _c;
|
|
13
|
+
const { collectable, loading } = useTableContext();
|
|
14
|
+
const { className, fixed = false, fixedOffset = 0, record, showShadow = false, width, } = props;
|
|
15
|
+
const cellStyle = {};
|
|
16
|
+
// Apply explicit width for dragging state
|
|
17
|
+
if (width !== undefined) {
|
|
18
|
+
cellStyle.width = width;
|
|
19
|
+
cellStyle.minWidth = width;
|
|
20
|
+
cellStyle.maxWidth = width;
|
|
21
|
+
cellStyle.flexShrink = 0;
|
|
22
|
+
}
|
|
23
|
+
if (fixed) {
|
|
24
|
+
cellStyle['--fixed-end-offset'] =
|
|
25
|
+
`${fixedOffset}px`;
|
|
26
|
+
}
|
|
27
|
+
const rowKey = record ? getRowKey(record) : '';
|
|
28
|
+
const isCollected = (_a = collectable === null || collectable === void 0 ? void 0 : collectable.collectedRowKeys.includes(rowKey)) !== null && _a !== void 0 ? _a : false;
|
|
29
|
+
const isDisabled = record
|
|
30
|
+
? ((_c = (_b = collectable === null || collectable === void 0 ? void 0 : collectable.isRowDisabled) === null || _b === void 0 ? void 0 : _b.call(collectable, record)) !== null && _c !== void 0 ? _c : false)
|
|
31
|
+
: false;
|
|
32
|
+
const handleCollectClick = useCallback(() => {
|
|
33
|
+
if (!collectable || !record || isDisabled)
|
|
34
|
+
return;
|
|
35
|
+
collectable.onCollectChange(record, !isCollected);
|
|
36
|
+
}, [collectable, isCollected, isDisabled, record]);
|
|
37
|
+
const renderChild = () => {
|
|
38
|
+
if (loading) {
|
|
39
|
+
return jsx(Skeleton, { variant: "body-highlight", width: "100%" });
|
|
40
|
+
}
|
|
41
|
+
return (jsx("button", { "aria-disabled": isDisabled, "aria-label": isCollected ? 'Remove from collection' : 'Add to collection', "aria-pressed": isCollected, className: cx(tableClasses.collectHandleIcon, {
|
|
42
|
+
[`${tableClasses.collectHandleIcon}--disabled`]: isDisabled,
|
|
43
|
+
}), disabled: isDisabled, onClick: handleCollectClick, type: "button", children: jsx(Icon, { color: isCollected ? 'brand' : 'neutral', icon: isCollected ? StarFilledIcon : StarOutlineIcon }) }));
|
|
44
|
+
};
|
|
45
|
+
return (jsx("td", { className: cx(tableClasses.cell, {
|
|
46
|
+
[tableClasses.cellFixed]: fixed,
|
|
47
|
+
[tableClasses.cellFixedEnd]: fixed,
|
|
48
|
+
[tableClasses.cellFixedShadow]: showShadow,
|
|
49
|
+
}, className), ref: ref, style: cellStyle, children: renderChild() }));
|
|
50
|
+
}
|
|
51
|
+
const ForwardedTableCollectableCell = forwardRef(TableCollectableCellInner);
|
|
52
|
+
const TableCollectableCell = memo(ForwardedTableCollectableCell);
|
|
53
|
+
|
|
54
|
+
export { TableCollectableCell };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type TableDataSource } from '@mezzanine-ui/core/table';
|
|
2
|
+
export interface TableDragOrPinHandleCellProps<T extends TableDataSource = TableDataSource> {
|
|
3
|
+
className?: string;
|
|
4
|
+
dragHandleProps?: Record<string, unknown>;
|
|
5
|
+
fixed?: boolean;
|
|
6
|
+
fixedOffset?: number;
|
|
7
|
+
isHeader?: boolean;
|
|
8
|
+
/** The mode of this cell: 'drag' for drag handle, 'pin' for pin handle */
|
|
9
|
+
mode: 'drag' | 'pin';
|
|
10
|
+
/** Row record - required when mode is 'pin' and isHeader is false */
|
|
11
|
+
record?: T;
|
|
12
|
+
showShadow?: boolean;
|
|
13
|
+
/** Explicit width for dragging state */
|
|
14
|
+
width?: number;
|
|
15
|
+
}
|
|
16
|
+
declare const ForwardedTableDragOrPinHandleCell: <T extends TableDataSource = TableDataSource>(props: TableDragOrPinHandleCellProps<T> & {
|
|
17
|
+
ref?: React.ForwardedRef<HTMLTableCellElement>;
|
|
18
|
+
}) => React.ReactElement;
|
|
19
|
+
export declare const TableDragOrPinHandleCell: typeof ForwardedTableDragOrPinHandleCell;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { memo, forwardRef, useCallback } from 'react';
|
|
4
|
+
import { getRowKey, tableClasses } from '@mezzanine-ui/core/table';
|
|
5
|
+
import { DotDragVerticalIcon, PinFilledIcon, PinIcon } from '@mezzanine-ui/icons';
|
|
6
|
+
import { useTableContext } from '../TableContext.js';
|
|
7
|
+
import Skeleton from '../../Skeleton/Skeleton.js';
|
|
8
|
+
import Icon from '../../Icon/Icon.js';
|
|
9
|
+
import cx from 'clsx';
|
|
10
|
+
|
|
11
|
+
function TableDragOrPinHandleCellInner(props, ref) {
|
|
12
|
+
var _a;
|
|
13
|
+
const { loading, pinnable } = useTableContext();
|
|
14
|
+
const { className, dragHandleProps, fixed = false, fixedOffset = 0, isHeader = false, mode, record, showShadow = false, width, } = props;
|
|
15
|
+
const CellComponent = isHeader ? 'th' : 'td';
|
|
16
|
+
const cellStyle = {};
|
|
17
|
+
// Apply explicit width for dragging state
|
|
18
|
+
if (width !== undefined) {
|
|
19
|
+
cellStyle.width = width;
|
|
20
|
+
cellStyle.minWidth = width;
|
|
21
|
+
cellStyle.maxWidth = width;
|
|
22
|
+
cellStyle.flexShrink = 0;
|
|
23
|
+
}
|
|
24
|
+
if (fixed) {
|
|
25
|
+
cellStyle['--fixed-start-offset'] =
|
|
26
|
+
`${fixedOffset}px`;
|
|
27
|
+
}
|
|
28
|
+
const rowKey = record ? getRowKey(record) : '';
|
|
29
|
+
const isPinned = (_a = pinnable === null || pinnable === void 0 ? void 0 : pinnable.pinnedRowKeys.includes(rowKey)) !== null && _a !== void 0 ? _a : false;
|
|
30
|
+
const handlePinClick = useCallback(() => {
|
|
31
|
+
if (!pinnable || !record)
|
|
32
|
+
return;
|
|
33
|
+
pinnable.onPinChange(record, !isPinned);
|
|
34
|
+
}, [isPinned, pinnable, record]);
|
|
35
|
+
const renderChild = () => {
|
|
36
|
+
if (isHeader) {
|
|
37
|
+
// Header cell is always empty
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
if (loading) {
|
|
41
|
+
return jsx(Skeleton, { variant: "body-highlight", width: "100%" });
|
|
42
|
+
}
|
|
43
|
+
if (mode === 'drag') {
|
|
44
|
+
return (jsx("span", { className: tableClasses.dragOrPinHandle, ...dragHandleProps, children: jsx(Icon, { color: "neutral", icon: DotDragVerticalIcon }) }));
|
|
45
|
+
}
|
|
46
|
+
// Pin mode
|
|
47
|
+
return (jsx("button", { "aria-label": isPinned ? 'Unpin row' : 'Pin row', "aria-pressed": isPinned, className: cx(tableClasses.dragOrPinHandle, tableClasses.pinHandleIcon), onClick: handlePinClick, type: "button", children: jsx(Icon, { color: isPinned ? 'brand' : 'neutral', icon: isPinned ? PinFilledIcon : PinIcon }) }));
|
|
48
|
+
};
|
|
49
|
+
return (jsx(CellComponent, { className: cx(isHeader ? tableClasses.headerCell : tableClasses.cell, tableClasses.dragOrPinHandleCell, {
|
|
50
|
+
[tableClasses.cellFixed]: fixed,
|
|
51
|
+
[tableClasses.cellFixedStart]: fixed,
|
|
52
|
+
[tableClasses.cellFixedShadow]: showShadow,
|
|
53
|
+
}, className), ref: ref, scope: isHeader ? 'col' : undefined, style: cellStyle, children: renderChild() }));
|
|
54
|
+
}
|
|
55
|
+
const ForwardedTableDragOrPinHandleCell = forwardRef(TableDragOrPinHandleCellInner);
|
|
56
|
+
const TableDragOrPinHandleCell = memo(ForwardedTableDragOrPinHandleCell);
|
|
57
|
+
|
|
58
|
+
export { TableDragOrPinHandleCell };
|
|
@@ -7,8 +7,9 @@ import { Table } from '../Table.js';
|
|
|
7
7
|
import cx from 'clsx';
|
|
8
8
|
|
|
9
9
|
const TableExpandedRowInner = forwardRef(function TableExpandedRow(props, ref) {
|
|
10
|
+
var _a, _b, _c;
|
|
10
11
|
const { className, record, style } = props;
|
|
11
|
-
const { expansion, draggable, selection } = useTableContext();
|
|
12
|
+
const { expansion, draggable, selection, transitionState } = useTableContext();
|
|
12
13
|
const { columns } = useTableDataContext();
|
|
13
14
|
// Calculate total column span
|
|
14
15
|
const totalColSpan = useMemo(() => {
|
|
@@ -24,6 +25,10 @@ const TableExpandedRowInner = forwardRef(function TableExpandedRow(props, ref) {
|
|
|
24
25
|
}, [columns.length, expansion, draggable === null || draggable === void 0 ? void 0 : draggable.enabled, selection]);
|
|
25
26
|
const rowKey = getRowKey(record);
|
|
26
27
|
const isExpanded = expansion === null || expansion === void 0 ? void 0 : expansion.isRowExpanded(rowKey);
|
|
28
|
+
// Check transition states for the parent row
|
|
29
|
+
const isAdding = (_a = transitionState === null || transitionState === void 0 ? void 0 : transitionState.addingKeys.has(rowKey)) !== null && _a !== void 0 ? _a : false;
|
|
30
|
+
const isDeleting = (_b = transitionState === null || transitionState === void 0 ? void 0 : transitionState.deletingKeys.has(rowKey)) !== null && _b !== void 0 ? _b : false;
|
|
31
|
+
const isFadingOut = (_c = transitionState === null || transitionState === void 0 ? void 0 : transitionState.fadingOutKeys.has(rowKey)) !== null && _c !== void 0 ? _c : false;
|
|
27
32
|
const { config } = expansion || {};
|
|
28
33
|
const { expandedRowRender } = config || {};
|
|
29
34
|
const childNeededProps = useMemo(() => ({
|
|
@@ -36,7 +41,11 @@ const TableExpandedRowInner = forwardRef(function TableExpandedRow(props, ref) {
|
|
|
36
41
|
return null;
|
|
37
42
|
const children = expandedRowRender(record);
|
|
38
43
|
const clonedChild = cloneElement(children);
|
|
39
|
-
return (jsx("tr", { className: cx(tableClasses.expandedRow,
|
|
44
|
+
return (jsx("tr", { className: cx(tableClasses.expandedRow, {
|
|
45
|
+
[tableClasses.expandedRowAdding]: isAdding,
|
|
46
|
+
[tableClasses.expandedRowDeleting]: isDeleting,
|
|
47
|
+
[tableClasses.expandedRowFadingOut]: isFadingOut,
|
|
48
|
+
}, className), "data-row-key": `${rowKey}-expanded`, ref: ref, style: style, children: jsx("td", { className: tableClasses.expandedRowCell, colSpan: totalColSpan, style: { paddingLeft: expansion === null || expansion === void 0 ? void 0 : expansion.expansionLeftPadding }, children: jsx("div", { className: tableClasses.expandedContent, children: clonedChild.type === Table
|
|
40
49
|
? cloneElement(clonedChild, {
|
|
41
50
|
...childNeededProps.table,
|
|
42
51
|
})
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
3
|
import { memo, forwardRef } from 'react';
|
|
4
|
-
import { tableClasses,
|
|
4
|
+
import { tableClasses, DRAG_OR_PIN_HANDLE_KEY, EXPANSION_KEY, SELECTION_KEY, getCellAlignClass } from '@mezzanine-ui/core/table';
|
|
5
5
|
import { QuestionOutlineIcon, CaretUpIcon, CaretDownIcon } from '@mezzanine-ui/icons';
|
|
6
6
|
import { useTableContext, useTableDataContext, useTableSuperContext } from '../TableContext.js';
|
|
7
|
-
import {
|
|
7
|
+
import { TableDragOrPinHandleCell } from './TableDragOrPinHandleCell.js';
|
|
8
8
|
import { TableExpandCell } from './TableExpandCell.js';
|
|
9
9
|
import { TableResizeHandle } from './TableResizeHandle.js';
|
|
10
10
|
import { TableSelectionCell } from './TableSelectionCell.js';
|
|
@@ -14,7 +14,7 @@ import Icon from '../../Icon/Icon.js';
|
|
|
14
14
|
import cx from 'clsx';
|
|
15
15
|
|
|
16
16
|
const TableHeaderInner = forwardRef(function TableHeader(_, ref) {
|
|
17
|
-
const { draggable, expansion, fixedOffsets, resizable, selection, sorting, } = useTableContext();
|
|
17
|
+
const { draggable, expansion, fixedOffsets, pinnable, resizable, selection, sorting, } = useTableContext();
|
|
18
18
|
const { columns } = useTableDataContext();
|
|
19
19
|
const { containerWidth, scrollLeft } = useTableSuperContext();
|
|
20
20
|
const parseFixed = (fixed) => {
|
|
@@ -24,15 +24,17 @@ const TableHeaderInner = forwardRef(function TableHeader(_, ref) {
|
|
|
24
24
|
return 'end';
|
|
25
25
|
return null;
|
|
26
26
|
};
|
|
27
|
-
const
|
|
27
|
+
const renderDragOrPinHandleHeader = () => {
|
|
28
28
|
var _a;
|
|
29
|
-
|
|
29
|
+
const hasDragOrPinHandle = (draggable === null || draggable === void 0 ? void 0 : draggable.enabled) || (pinnable === null || pinnable === void 0 ? void 0 : pinnable.enabled);
|
|
30
|
+
if (!hasDragOrPinHandle)
|
|
30
31
|
return null;
|
|
31
|
-
const offsetInfo = fixedOffsets === null || fixedOffsets === void 0 ? void 0 : fixedOffsets.
|
|
32
|
-
const isFixed = !!draggable.fixed;
|
|
32
|
+
const offsetInfo = fixedOffsets === null || fixedOffsets === void 0 ? void 0 : fixedOffsets.getDragOrPinHandleOffset();
|
|
33
|
+
const isFixed = !!(draggable === null || draggable === void 0 ? void 0 : draggable.fixed) || !!(pinnable === null || pinnable === void 0 ? void 0 : pinnable.fixed);
|
|
33
34
|
const showShadow = isFixed &&
|
|
34
|
-
(fixedOffsets === null || fixedOffsets === void 0 ? void 0 : fixedOffsets.shouldShowShadow(
|
|
35
|
-
|
|
35
|
+
(fixedOffsets === null || fixedOffsets === void 0 ? void 0 : fixedOffsets.shouldShowShadow(DRAG_OR_PIN_HANDLE_KEY, scrollLeft !== null && scrollLeft !== void 0 ? scrollLeft : 0, containerWidth !== null && containerWidth !== void 0 ? containerWidth : 0));
|
|
36
|
+
const mode = (draggable === null || draggable === void 0 ? void 0 : draggable.enabled) ? 'drag' : 'pin';
|
|
37
|
+
return (jsx(TableDragOrPinHandleCell, { fixed: isFixed, fixedOffset: (_a = offsetInfo === null || offsetInfo === void 0 ? void 0 : offsetInfo.offset) !== null && _a !== void 0 ? _a : 0, isHeader: true, mode: mode, showShadow: showShadow !== null && showShadow !== void 0 ? showShadow : false }));
|
|
36
38
|
};
|
|
37
39
|
const renderSelectionHeader = () => {
|
|
38
40
|
var _a, _b, _c;
|
|
@@ -115,7 +117,7 @@ const TableHeaderInner = forwardRef(function TableHeader(_, ref) {
|
|
|
115
117
|
}, column.className, column.headerClassName), scope: "col", style: cellStyle, children: [jsxs("div", { className: tableClasses.headerCellContent, children: [jsxs("div", { className: cx(tableClasses.headerCellActions, alignClass), children: [jsx("span", { className: tableClasses.headerCellTitle, children: column.title }), renderHelpIcon(column), renderSortIcon(column)] }), jsx(TableColumnTitleMenu, { column: column })] }), resizable && (jsx(TableResizeHandle, { column: column, columnIndex: columnIndex }))] }, column.key));
|
|
116
118
|
});
|
|
117
119
|
};
|
|
118
|
-
return (jsx("thead", { className: cx(tableClasses.header), ref: ref, children: jsxs("tr", { children: [
|
|
120
|
+
return (jsx("thead", { className: cx(tableClasses.header), ref: ref, children: jsxs("tr", { children: [renderDragOrPinHandleHeader(), renderExpandHeader(), renderSelectionHeader(), renderHeaderCells()] }) }));
|
|
119
121
|
});
|
|
120
122
|
const TableHeader = memo(TableHeaderInner);
|
|
121
123
|
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { memo, forwardRef, useMemo, useCallback } from 'react';
|
|
4
|
-
import { getRowKey,
|
|
4
|
+
import { getRowKey, TOGGLEABLE_COLUMN_WIDTH, COLLECTABLE_COLUMN_WIDTH, tableClasses, EXPANSION_KEY, EXPANSION_COLUMN_WIDTH, DRAG_OR_PIN_HANDLE_KEY, DRAG_OR_PIN_HANDLE_COLUMN_WIDTH, SELECTION_KEY, SELECTION_COLUMN_WIDTH, TOGGLEABLE_KEY, COLLECTABLE_KEY, TABLE_ACTIONS_KEY } from '@mezzanine-ui/core/table';
|
|
5
5
|
import { calculateColumnWidths } from '../utils/calculateColumnWidths.js';
|
|
6
6
|
import { useTableContext, useTableDataContext, useTableSuperContext } from '../TableContext.js';
|
|
7
7
|
import { TableActionsCell } from './TableActionsCell.js';
|
|
8
8
|
import { TableCell } from './TableCell.js';
|
|
9
|
-
import {
|
|
9
|
+
import { TableCollectableCell } from './TableCollectableCell.js';
|
|
10
|
+
import { TableDragOrPinHandleCell } from './TableDragOrPinHandleCell.js';
|
|
10
11
|
import { TableExpandCell } from './TableExpandCell.js';
|
|
11
12
|
import { TableSelectionCell } from './TableSelectionCell.js';
|
|
13
|
+
import { TableToggleableCell } from './TableToggleableCell.js';
|
|
12
14
|
import { composeRefs } from '../../utils/composeRefs.js';
|
|
13
15
|
import cx from 'clsx';
|
|
14
16
|
|
|
@@ -22,7 +24,7 @@ const parseFixed = (fixed) => {
|
|
|
22
24
|
const TableRowInner = forwardRef(function TableRow(props, ref) {
|
|
23
25
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
24
26
|
const { className, draggableProvided, record, rowIndex, style } = props;
|
|
25
|
-
const { actions, draggable, expansion, fixedOffsets, highlight, rowHeight, selection, separatorAtRowIndexes, transitionState, zebraStriping, } = useTableContext();
|
|
27
|
+
const { actions, collectable, draggable, expansion, fixedOffsets, highlight, pinnable, rowHeight, selection, separatorAtRowIndexes, toggleable, transitionState, zebraStriping, } = useTableContext();
|
|
26
28
|
const { columns } = useTableDataContext();
|
|
27
29
|
const isDragging = useMemo(() => {
|
|
28
30
|
var _a;
|
|
@@ -44,16 +46,21 @@ const TableRowInner = forwardRef(function TableRow(props, ref) {
|
|
|
44
46
|
const isFadingOut = (_o = transitionState === null || transitionState === void 0 ? void 0 : transitionState.fadingOutKeys.has(rowKey)) !== null && _o !== void 0 ? _o : false;
|
|
45
47
|
// Calculate column widths when dragging (since position: fixed breaks colgroup)
|
|
46
48
|
const draggingColumnWidths = useMemo(() => {
|
|
49
|
+
var _a;
|
|
47
50
|
if (!isDragging || !containerWidth)
|
|
48
51
|
return null;
|
|
49
52
|
// Calculate action columns total width
|
|
50
53
|
let actionColumnsWidth = 0;
|
|
51
|
-
if (draggable === null || draggable === void 0 ? void 0 : draggable.enabled)
|
|
52
|
-
actionColumnsWidth +=
|
|
54
|
+
if ((draggable === null || draggable === void 0 ? void 0 : draggable.enabled) || (pinnable === null || pinnable === void 0 ? void 0 : pinnable.enabled))
|
|
55
|
+
actionColumnsWidth += DRAG_OR_PIN_HANDLE_COLUMN_WIDTH;
|
|
53
56
|
if (selection)
|
|
54
57
|
actionColumnsWidth += SELECTION_COLUMN_WIDTH;
|
|
55
58
|
if (expansion)
|
|
56
59
|
actionColumnsWidth += EXPANSION_COLUMN_WIDTH;
|
|
60
|
+
if (toggleable === null || toggleable === void 0 ? void 0 : toggleable.enabled)
|
|
61
|
+
actionColumnsWidth += (_a = toggleable.minWidth) !== null && _a !== void 0 ? _a : TOGGLEABLE_COLUMN_WIDTH;
|
|
62
|
+
if (collectable === null || collectable === void 0 ? void 0 : collectable.enabled)
|
|
63
|
+
actionColumnsWidth += COLLECTABLE_COLUMN_WIDTH;
|
|
57
64
|
return calculateColumnWidths({
|
|
58
65
|
actionColumnsWidth,
|
|
59
66
|
columns,
|
|
@@ -64,10 +71,14 @@ const TableRowInner = forwardRef(function TableRow(props, ref) {
|
|
|
64
71
|
isDragging,
|
|
65
72
|
containerWidth,
|
|
66
73
|
columns,
|
|
74
|
+
collectable === null || collectable === void 0 ? void 0 : collectable.enabled,
|
|
67
75
|
draggable === null || draggable === void 0 ? void 0 : draggable.enabled,
|
|
68
76
|
expansion,
|
|
69
77
|
getResizedColumnWidth,
|
|
78
|
+
pinnable === null || pinnable === void 0 ? void 0 : pinnable.enabled,
|
|
70
79
|
selection,
|
|
80
|
+
toggleable === null || toggleable === void 0 ? void 0 : toggleable.enabled,
|
|
81
|
+
toggleable === null || toggleable === void 0 ? void 0 : toggleable.minWidth,
|
|
71
82
|
]);
|
|
72
83
|
// Check if this row should be highlighted based on highlight mode
|
|
73
84
|
const isRowHighlighted = useMemo(() => {
|
|
@@ -87,15 +98,19 @@ const TableRowInner = forwardRef(function TableRow(props, ref) {
|
|
|
87
98
|
const handleMouseLeave = useCallback(() => {
|
|
88
99
|
highlight === null || highlight === void 0 ? void 0 : highlight.setHoveredCell(null, null);
|
|
89
100
|
}, [highlight]);
|
|
90
|
-
const
|
|
101
|
+
const renderDragOrPinHandleCell = () => {
|
|
91
102
|
var _a;
|
|
92
|
-
|
|
103
|
+
const isDragMode = draggable === null || draggable === void 0 ? void 0 : draggable.enabled;
|
|
104
|
+
const isPinMode = pinnable === null || pinnable === void 0 ? void 0 : pinnable.enabled;
|
|
105
|
+
if (!isDragMode && !isPinMode)
|
|
93
106
|
return null;
|
|
94
|
-
const offsetInfo = fixedOffsets === null || fixedOffsets === void 0 ? void 0 : fixedOffsets.
|
|
95
|
-
const isFixed = !!draggable.fixed;
|
|
107
|
+
const offsetInfo = fixedOffsets === null || fixedOffsets === void 0 ? void 0 : fixedOffsets.getDragOrPinHandleOffset();
|
|
108
|
+
const isFixed = isDragMode ? !!(draggable === null || draggable === void 0 ? void 0 : draggable.fixed) : !!(pinnable === null || pinnable === void 0 ? void 0 : pinnable.fixed);
|
|
96
109
|
const showShadow = isFixed &&
|
|
97
|
-
(fixedOffsets === null || fixedOffsets === void 0 ? void 0 : fixedOffsets.shouldShowShadow(
|
|
98
|
-
return (jsx(
|
|
110
|
+
(fixedOffsets === null || fixedOffsets === void 0 ? void 0 : fixedOffsets.shouldShowShadow(DRAG_OR_PIN_HANDLE_KEY, scrollLeft !== null && scrollLeft !== void 0 ? scrollLeft : 0, containerWidth !== null && containerWidth !== void 0 ? containerWidth : 0));
|
|
111
|
+
return (jsx(TableDragOrPinHandleCell, { dragHandleProps: isDragMode
|
|
112
|
+
? draggableProvided === null || draggableProvided === void 0 ? void 0 : draggableProvided.dragHandleProps
|
|
113
|
+
: undefined, fixed: isFixed, fixedOffset: (_a = offsetInfo === null || offsetInfo === void 0 ? void 0 : offsetInfo.offset) !== null && _a !== void 0 ? _a : 0, mode: isDragMode ? 'drag' : 'pin', record: record, showShadow: showShadow !== null && showShadow !== void 0 ? showShadow : false, width: isDragging ? DRAG_OR_PIN_HANDLE_COLUMN_WIDTH : undefined }));
|
|
99
114
|
};
|
|
100
115
|
const renderSelectionCell = () => {
|
|
101
116
|
var _a, _b;
|
|
@@ -124,13 +139,23 @@ const TableRowInner = forwardRef(function TableRow(props, ref) {
|
|
|
124
139
|
};
|
|
125
140
|
const renderCells = () => {
|
|
126
141
|
return columns.map((column, columnIndex) => {
|
|
127
|
-
var _a;
|
|
142
|
+
var _a, _b, _c;
|
|
128
143
|
const fixedPos = parseFixed(column.fixed);
|
|
129
144
|
const offsetInfo = fixedOffsets === null || fixedOffsets === void 0 ? void 0 : fixedOffsets.getColumnOffset(column.key);
|
|
130
145
|
const offset = (_a = offsetInfo === null || offsetInfo === void 0 ? void 0 : offsetInfo.offset) !== null && _a !== void 0 ? _a : 0;
|
|
131
146
|
// Show shadow based on scroll position and sticky state
|
|
132
147
|
const showShadow = !!fixedPos &&
|
|
133
148
|
(fixedOffsets === null || fixedOffsets === void 0 ? void 0 : fixedOffsets.shouldShowShadow(column.key, scrollLeft !== null && scrollLeft !== void 0 ? scrollLeft : 0, containerWidth !== null && containerWidth !== void 0 ? containerWidth : 0));
|
|
149
|
+
// Render toggleable cell for TOGGLEABLE_KEY column
|
|
150
|
+
if (column.key === TOGGLEABLE_KEY && (toggleable === null || toggleable === void 0 ? void 0 : toggleable.enabled)) {
|
|
151
|
+
const toggleableOffsetInfo = fixedOffsets === null || fixedOffsets === void 0 ? void 0 : fixedOffsets.getToggleableOffset();
|
|
152
|
+
return (jsx(TableToggleableCell, { fixed: !!toggleable.fixed, fixedOffset: (_b = toggleableOffsetInfo === null || toggleableOffsetInfo === void 0 ? void 0 : toggleableOffsetInfo.offset) !== null && _b !== void 0 ? _b : 0, record: record, showShadow: showShadow !== null && showShadow !== void 0 ? showShadow : false, width: isDragging ? column.width : undefined }, column.key));
|
|
153
|
+
}
|
|
154
|
+
// Render collectable cell for COLLECTABLE_KEY column
|
|
155
|
+
if (column.key === COLLECTABLE_KEY && (collectable === null || collectable === void 0 ? void 0 : collectable.enabled)) {
|
|
156
|
+
const collectableOffsetInfo = fixedOffsets === null || fixedOffsets === void 0 ? void 0 : fixedOffsets.getCollectableOffset();
|
|
157
|
+
return (jsx(TableCollectableCell, { fixed: !!collectable.fixed, fixedOffset: (_c = collectableOffsetInfo === null || collectableOffsetInfo === void 0 ? void 0 : collectableOffsetInfo.offset) !== null && _c !== void 0 ? _c : 0, record: record, showShadow: showShadow !== null && showShadow !== void 0 ? showShadow : false, width: isDragging ? column.width : undefined }, column.key));
|
|
158
|
+
}
|
|
134
159
|
// Render actions cell for TABLE_ACTIONS_KEY column
|
|
135
160
|
if (column.key === TABLE_ACTIONS_KEY && actions) {
|
|
136
161
|
return (jsx(TableActionsCell, { actions: actions, className: column.className, columnIndex: columnIndex, fixed: fixedPos !== null && fixedPos !== void 0 ? fixedPos : undefined, fixedOffset: offset, record: record, rowIndex: rowIndex, showShadow: showShadow !== null && showShadow !== void 0 ? showShadow : false, width: draggingColumnWidths === null || draggingColumnWidths === void 0 ? void 0 : draggingColumnWidths.get(column.key) }, column.key));
|
|
@@ -153,7 +178,7 @@ const TableRowInner = forwardRef(function TableRow(props, ref) {
|
|
|
153
178
|
[tableClasses.bodyRowSelected]: isSelected,
|
|
154
179
|
[tableClasses.bodyRowSeparator]: isSeparatorRow,
|
|
155
180
|
[tableClasses.bodyRowZebra]: isZebraRow,
|
|
156
|
-
}, className), "data-index": rowIndex, "data-row-key": rowKey, onMouseLeave: handleMouseLeave, ref: rowRef, tabIndex: 0, ...draggableProvided === null || draggableProvided === void 0 ? void 0 : draggableProvided.draggableProps, style: resolvedStyle, children: [
|
|
181
|
+
}, className), "data-index": rowIndex, "data-row-key": rowKey, onMouseLeave: handleMouseLeave, ref: rowRef, tabIndex: 0, ...draggableProvided === null || draggableProvided === void 0 ? void 0 : draggableProvided.draggableProps, style: resolvedStyle, children: [renderExpandCell(), renderDragOrPinHandleCell(), renderSelectionCell(), renderCells()] }));
|
|
157
182
|
});
|
|
158
183
|
const TableRow = memo(TableRowInner);
|
|
159
184
|
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { memo, forwardRef } from 'react';
|
|
4
4
|
import { tableClasses } from '@mezzanine-ui/core/table';
|
|
5
|
-
import Checkbox from '../../Checkbox/Checkbox.js';
|
|
6
5
|
import { useTableContext } from '../TableContext.js';
|
|
7
6
|
import Skeleton from '../../Skeleton/Skeleton.js';
|
|
8
7
|
import Radio from '../../Radio/Radio.js';
|
|
8
|
+
import Checkbox from '../../Checkbox/Checkbox.js';
|
|
9
9
|
import cx from 'clsx';
|
|
10
10
|
|
|
11
11
|
const TableSelectionCellInner = forwardRef(function TableSelectionCell(props, ref) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type TableDataSource } from '@mezzanine-ui/core/table';
|
|
2
|
+
export interface TableToggleableCellProps<T extends TableDataSource = TableDataSource> {
|
|
3
|
+
className?: string;
|
|
4
|
+
fixed?: boolean;
|
|
5
|
+
fixedOffset?: number;
|
|
6
|
+
/** Row record - required when isHeader is false */
|
|
7
|
+
record?: T;
|
|
8
|
+
showShadow?: boolean;
|
|
9
|
+
/** Explicit width for dragging state */
|
|
10
|
+
width?: number;
|
|
11
|
+
}
|
|
12
|
+
declare const ForwardedTableToggleableCell: <T extends TableDataSource = TableDataSource>(props: TableToggleableCellProps<T> & {
|
|
13
|
+
ref?: React.ForwardedRef<HTMLTableCellElement>;
|
|
14
|
+
}) => React.ReactElement;
|
|
15
|
+
export declare const TableToggleableCell: typeof ForwardedTableToggleableCell;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { memo, forwardRef, useCallback } from 'react';
|
|
4
|
+
import { getRowKey, tableClasses } from '@mezzanine-ui/core/table';
|
|
5
|
+
import { useTableContext } from '../TableContext.js';
|
|
6
|
+
import Skeleton from '../../Skeleton/Skeleton.js';
|
|
7
|
+
import Toggle from '../../Toggle/Toggle.js';
|
|
8
|
+
import cx from 'clsx';
|
|
9
|
+
|
|
10
|
+
function TableToggleableCellInner(props, ref) {
|
|
11
|
+
var _a, _b, _c;
|
|
12
|
+
const { loading, toggleable } = useTableContext();
|
|
13
|
+
const { className, fixed = false, fixedOffset = 0, record, showShadow = false, width, } = props;
|
|
14
|
+
const cellStyle = {};
|
|
15
|
+
// Apply explicit width for dragging state
|
|
16
|
+
if (width !== undefined) {
|
|
17
|
+
cellStyle.width = width;
|
|
18
|
+
cellStyle.minWidth = width;
|
|
19
|
+
cellStyle.maxWidth = width;
|
|
20
|
+
cellStyle.flexShrink = 0;
|
|
21
|
+
}
|
|
22
|
+
if (fixed) {
|
|
23
|
+
cellStyle['--fixed-end-offset'] =
|
|
24
|
+
`${fixedOffset}px`;
|
|
25
|
+
}
|
|
26
|
+
const rowKey = record ? getRowKey(record) : '';
|
|
27
|
+
const isToggled = (_a = toggleable === null || toggleable === void 0 ? void 0 : toggleable.toggledRowKeys.includes(rowKey)) !== null && _a !== void 0 ? _a : false;
|
|
28
|
+
const isDisabled = record
|
|
29
|
+
? ((_c = (_b = toggleable === null || toggleable === void 0 ? void 0 : toggleable.isRowDisabled) === null || _b === void 0 ? void 0 : _b.call(toggleable, record)) !== null && _c !== void 0 ? _c : false)
|
|
30
|
+
: false;
|
|
31
|
+
const handleToggleChange = useCallback(() => {
|
|
32
|
+
if (!toggleable || !record || isDisabled)
|
|
33
|
+
return;
|
|
34
|
+
toggleable.onToggleChange(record, !isToggled);
|
|
35
|
+
}, [isDisabled, isToggled, record, toggleable]);
|
|
36
|
+
const renderChild = () => {
|
|
37
|
+
if (loading) {
|
|
38
|
+
return jsx(Skeleton, { variant: "body-highlight", width: "100%" });
|
|
39
|
+
}
|
|
40
|
+
return (jsx(Toggle, { checked: isToggled, disabled: isDisabled, onChange: handleToggleChange, size: "sub" }));
|
|
41
|
+
};
|
|
42
|
+
return (jsx("td", { className: cx(tableClasses.cell, {
|
|
43
|
+
[tableClasses.cellFixed]: fixed,
|
|
44
|
+
[tableClasses.cellFixedEnd]: fixed,
|
|
45
|
+
[tableClasses.cellFixedShadow]: showShadow,
|
|
46
|
+
}, className), ref: ref, style: cellStyle, children: renderChild() }));
|
|
47
|
+
}
|
|
48
|
+
const ForwardedTableToggleableCell = forwardRef(TableToggleableCellInner);
|
|
49
|
+
const TableToggleableCell = memo(ForwardedTableToggleableCell);
|
|
50
|
+
|
|
51
|
+
export { TableToggleableCell };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { TableActionsCell, type TableActionsCellProps, } from './TableActionsCell';
|
|
2
2
|
export { TableBody, type TableBodyProps } from './TableBody';
|
|
3
3
|
export { TableCell, type TableCellProps } from './TableCell';
|
|
4
|
-
export { TableColGroup
|
|
4
|
+
export { TableColGroup } from './TableColGroup';
|
|
5
|
+
export { TableDragOrPinHandleCell, type TableDragOrPinHandleCellProps, } from './TableDragOrPinHandleCell';
|
|
5
6
|
export { TableExpandCell, type TableExpandCellProps } from './TableExpandCell';
|
|
6
7
|
export { TableExpandedRow, type TableExpandedRowProps, } from './TableExpandedRow';
|
|
7
8
|
export { TableHeader, type TableHeaderProps } from './TableHeader';
|
|
@@ -9,3 +10,5 @@ export { TablePagination, type TablePaginationProps } from './TablePagination';
|
|
|
9
10
|
export { TableResizeHandle, type TableResizeHandleProps, } from './TableResizeHandle';
|
|
10
11
|
export { TableRow, type TableRowProps } from './TableRow';
|
|
11
12
|
export { TableSelectionCell, type TableSelectionCellProps, } from './TableSelectionCell';
|
|
13
|
+
export { TableToggleableCell, type TableToggleableCellProps, } from './TableToggleableCell';
|
|
14
|
+
export { TableCollectableCell, type TableCollectableCellProps, } from './TableCollectableCell';
|
|
@@ -2,6 +2,7 @@ export { TableActionsCell } from './TableActionsCell.js';
|
|
|
2
2
|
export { TableBody } from './TableBody.js';
|
|
3
3
|
export { TableCell } from './TableCell.js';
|
|
4
4
|
export { TableColGroup } from './TableColGroup.js';
|
|
5
|
+
export { TableDragOrPinHandleCell } from './TableDragOrPinHandleCell.js';
|
|
5
6
|
export { TableExpandCell } from './TableExpandCell.js';
|
|
6
7
|
export { TableExpandedRow } from './TableExpandedRow.js';
|
|
7
8
|
export { TableHeader } from './TableHeader.js';
|
|
@@ -9,3 +10,5 @@ export { TablePagination } from './TablePagination.js';
|
|
|
9
10
|
export { TableResizeHandle } from './TableResizeHandle.js';
|
|
10
11
|
export { TableRow } from './TableRow.js';
|
|
11
12
|
export { TableSelectionCell } from './TableSelectionCell.js';
|
|
13
|
+
export { TableToggleableCell } from './TableToggleableCell.js';
|
|
14
|
+
export { TableCollectableCell } from './TableCollectableCell.js';
|
package/Table/hooks/typings.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export interface ActionColumnConfig {
|
|
2
|
-
/** Whether drag handle column exists */
|
|
3
|
-
|
|
4
|
-
/** Whether drag handle is fixed */
|
|
5
|
-
|
|
2
|
+
/** Whether drag or pin handle column exists */
|
|
3
|
+
hasDragOrPinHandle: boolean;
|
|
4
|
+
/** Whether drag or pin handle is fixed */
|
|
5
|
+
dragOrPinHandleFixed: boolean;
|
|
6
|
+
/** The type of drag or pin handle: 'drag' or 'pin' */
|
|
7
|
+
dragOrPinHandleType?: 'drag' | 'pin';
|
|
6
8
|
/** Whether selection column exists */
|
|
7
9
|
hasSelection: boolean;
|
|
8
10
|
/** Whether selection is fixed */
|
|
@@ -11,4 +13,16 @@ export interface ActionColumnConfig {
|
|
|
11
13
|
hasExpansion: boolean;
|
|
12
14
|
/** Whether expansion is fixed */
|
|
13
15
|
expansionFixed: boolean;
|
|
16
|
+
/** Whether toggleable column exists */
|
|
17
|
+
hasToggleable: boolean;
|
|
18
|
+
/** The minimum width of the toggleable column */
|
|
19
|
+
toggleableMinWidth: number;
|
|
20
|
+
/** Whether toggleable is fixed */
|
|
21
|
+
toggleableFixed: boolean;
|
|
22
|
+
/** Whether collectable column exists */
|
|
23
|
+
hasCollectable: boolean;
|
|
24
|
+
/** The minimum width of the collectable column */
|
|
25
|
+
collectableMinWidth: number;
|
|
26
|
+
/** Whether collectable is fixed */
|
|
27
|
+
collectableFixed: boolean;
|
|
14
28
|
}
|
|
@@ -2,6 +2,6 @@ import { type TableDataSource, type TableExpandable } from '@mezzanine-ui/core/t
|
|
|
2
2
|
import type { TableExpansionState } from '../TableContext';
|
|
3
3
|
export interface UseTableExpansionOptions<T extends TableDataSource> {
|
|
4
4
|
expandable?: TableExpandable<T>;
|
|
5
|
-
|
|
5
|
+
hasDragOrPinHandle: boolean;
|
|
6
6
|
}
|
|
7
|
-
export declare function useTableExpansion<T extends TableDataSource>({ expandable,
|
|
7
|
+
export declare function useTableExpansion<T extends TableDataSource>({ expandable, hasDragOrPinHandle, }: UseTableExpansionOptions<T>): TableExpansionState<T> | undefined;
|