@mezzanine-ui/react 1.0.0-beta.3 → 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/AutoComplete/AutoComplete.d.ts +23 -0
- package/AutoComplete/AutoComplete.js +23 -9
- 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/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/Dropdown/Dropdown.d.ts +17 -0
- package/Dropdown/Dropdown.js +6 -2
- package/Dropdown/DropdownItem.d.ts +10 -0
- package/Dropdown/DropdownItem.js +37 -8
- package/Dropdown/DropdownItemCard.d.ts +2 -2
- package/Dropdown/DropdownItemCard.js +11 -8
- 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/Input/Input.d.ts +6 -4
- package/Input/Input.js +28 -10
- package/Input/index.d.ts +1 -1
- package/Modal/MediaPreviewModal.d.ts +54 -0
- package/Modal/MediaPreviewModal.js +158 -0
- package/Modal/Modal.js +1 -1
- package/Modal/index.d.ts +2 -0
- package/Modal/index.js +1 -0
- package/Navigation/Navigation.js +6 -5
- package/Navigation/NavigationOption.d.ts +6 -2
- package/Navigation/NavigationOption.js +19 -9
- 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/NotificationCenter/NotificationCenter.d.ts +1 -1
- package/NotificationCenter/NotificationCenter.js +34 -14
- package/NotificationCenter/NotificationCenterDrawer.d.ts +20 -0
- package/PageHeader/PageHeader.d.ts +32 -25
- package/PageHeader/PageHeader.js +49 -35
- 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/typings.d.ts +6 -1
- package/Selection/Selection.js +1 -1
- package/Selection/SelectionGroup.d.ts +28 -0
- 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/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 +58 -24
- 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/Transition/Slide.d.ts +9 -2
- package/Transition/Slide.js +7 -4
- package/Tree/TreeNode.js +1 -1
- package/index.d.ts +4 -2
- package/index.js +6 -3
- package/package.json +6 -4
- package/Navigation/CollapsedMenu.d.ts +0 -6
- package/Navigation/CollapsedMenu.js +0 -16
- package/PageToolbar/PageToolbar.d.ts +0 -110
- 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 -157
- package/Table/components/TableDragHandleCell.d.ts +0 -11
- package/Table/components/TableDragHandleCell.js +0 -44
|
@@ -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, tableClasses, EXPANSION_KEY, EXPANSION_COLUMN_WIDTH,
|
|
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: [renderExpandCell(),
|
|
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;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useState, useCallback, useMemo } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { DRAG_OR_PIN_HANDLE_COLUMN_WIDTH, EXPANSION_COLUMN_WIDTH } from '@mezzanine-ui/core/table';
|
|
4
4
|
|
|
5
|
-
function useTableExpansion({ expandable,
|
|
5
|
+
function useTableExpansion({ expandable, hasDragOrPinHandle, }) {
|
|
6
6
|
const [internalExpandedKeys, setInternalExpandedKeys] = useState([]);
|
|
7
7
|
const { expandedRowKeys: expandedRowKeysProp, onExpand, onExpandedRowsChange, } = expandable || {};
|
|
8
8
|
const isControlled = expandedRowKeysProp !== undefined;
|
|
@@ -25,12 +25,12 @@ function useTableExpansion({ expandable, hasDragHandle, }) {
|
|
|
25
25
|
}, [expandedRowKeys, isControlled, onExpand, onExpandedRowsChange]);
|
|
26
26
|
const expansionLeftPadding = useMemo(() => {
|
|
27
27
|
let padding = 0;
|
|
28
|
-
if (
|
|
29
|
-
padding +=
|
|
28
|
+
if (hasDragOrPinHandle)
|
|
29
|
+
padding += DRAG_OR_PIN_HANDLE_COLUMN_WIDTH;
|
|
30
30
|
if (expandable)
|
|
31
31
|
padding += EXPANSION_COLUMN_WIDTH;
|
|
32
32
|
return padding;
|
|
33
|
-
}, [expandable,
|
|
33
|
+
}, [expandable, hasDragOrPinHandle]);
|
|
34
34
|
if (!expandable) {
|
|
35
35
|
return undefined;
|
|
36
36
|
}
|
|
@@ -9,12 +9,16 @@ export interface FixedOffsetInfo {
|
|
|
9
9
|
export interface UseTableFixedOffsetsReturn {
|
|
10
10
|
/** Get offset info for a specific column by key */
|
|
11
11
|
getColumnOffset: (key: string) => FixedOffsetInfo | null;
|
|
12
|
-
/** Get offset info for drag handle column */
|
|
13
|
-
|
|
12
|
+
/** Get offset info for drag or pin handle column */
|
|
13
|
+
getDragOrPinHandleOffset: () => FixedOffsetInfo | null;
|
|
14
14
|
/** Get offset info for selection column */
|
|
15
15
|
getSelectionOffset: () => FixedOffsetInfo | null;
|
|
16
16
|
/** Get offset info for expansion column */
|
|
17
17
|
getExpansionOffset: () => FixedOffsetInfo | null;
|
|
18
|
+
/** Get offset info for toggleable column */
|
|
19
|
+
getToggleableOffset: () => FixedOffsetInfo | null;
|
|
20
|
+
/** Get offset info for collectable column */
|
|
21
|
+
getCollectableOffset: () => FixedOffsetInfo | null;
|
|
18
22
|
/** Check if a column should show shadow based on scroll position */
|
|
19
23
|
shouldShowShadow: (key: string, scrollLeft: number, containerWidth: number) => boolean;
|
|
20
24
|
}
|