@mezzanine-ui/react 1.0.0-alpha.0 → 1.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/Breadcrumb/Breadcrumb.js +40 -12
  2. package/Breadcrumb/typings.d.ts +8 -3
  3. package/Drawer/Drawer.d.ts +47 -6
  4. package/Drawer/Drawer.js +36 -11
  5. package/Empty/Empty.js +26 -3
  6. package/Empty/typings.d.ts +16 -7
  7. package/PageHeader/PageHeader.d.ts +5 -1
  8. package/PageHeader/PageHeader.js +8 -3
  9. package/PageToolbar/PageToolbar.d.ts +73 -26
  10. package/PageToolbar/PageToolbar.js +10 -101
  11. package/PageToolbar/utils.d.ts +23 -0
  12. package/PageToolbar/utils.js +165 -0
  13. package/Pagination/PaginationItem.js +1 -3
  14. package/Pagination/usePagination.js +0 -18
  15. package/Radio/Radio.d.ts +36 -3
  16. package/Radio/Radio.js +21 -11
  17. package/Radio/RadioGroup.d.ts +36 -7
  18. package/Radio/RadioGroup.js +5 -4
  19. package/Radio/RadioGroupContext.d.ts +2 -1
  20. package/Radio/index.d.ts +3 -3
  21. package/Tab/Tab.d.ts +32 -0
  22. package/Tab/Tab.js +57 -0
  23. package/Tab/TabItem.d.ts +27 -0
  24. package/Tab/TabItem.js +18 -0
  25. package/Tab/index.d.ts +4 -0
  26. package/Tab/index.js +2 -0
  27. package/Table/Table.d.ts +75 -94
  28. package/Table/Table.js +216 -161
  29. package/Table/TableContext.d.ts +114 -51
  30. package/Table/TableContext.js +21 -3
  31. package/Table/components/TableBody.d.ts +5 -0
  32. package/Table/components/TableBody.js +102 -0
  33. package/Table/components/TableCell.d.ts +17 -0
  34. package/Table/components/TableCell.js +74 -0
  35. package/Table/components/TableColGroup.d.ts +4 -0
  36. package/Table/components/TableColGroup.js +206 -0
  37. package/Table/components/TableDragHandleCell.d.ts +9 -0
  38. package/Table/components/TableDragHandleCell.js +37 -0
  39. package/Table/components/TableExpandCell.d.ts +11 -0
  40. package/Table/components/TableExpandCell.js +44 -0
  41. package/Table/components/TableExpandedRow.d.ts +9 -0
  42. package/Table/components/TableExpandedRow.js +46 -0
  43. package/Table/components/TableHeader.d.ts +4 -0
  44. package/Table/components/TableHeader.js +125 -0
  45. package/Table/components/TablePagination.d.ts +3 -0
  46. package/Table/components/TablePagination.js +11 -0
  47. package/Table/components/TableResizeHandle.d.ts +13 -0
  48. package/Table/components/TableResizeHandle.js +115 -0
  49. package/Table/components/TableRow.d.ts +12 -0
  50. package/Table/components/TableRow.js +126 -0
  51. package/Table/components/TableSelectionCell.d.ts +13 -0
  52. package/Table/components/TableSelectionCell.js +35 -0
  53. package/Table/components/index.d.ts +10 -0
  54. package/Table/components/index.js +10 -0
  55. package/Table/hooks/index.d.ts +9 -0
  56. package/Table/hooks/index.js +8 -0
  57. package/Table/hooks/typings.d.ts +14 -0
  58. package/Table/hooks/useTableColumns.d.ts +8 -0
  59. package/Table/hooks/useTableColumns.js +91 -0
  60. package/Table/hooks/useTableDataSource.d.ts +57 -0
  61. package/Table/hooks/useTableDataSource.js +183 -0
  62. package/Table/hooks/useTableExpansion.d.ts +7 -0
  63. package/Table/hooks/useTableExpansion.js +52 -0
  64. package/Table/hooks/useTableFixedOffsets.d.ts +29 -0
  65. package/Table/hooks/useTableFixedOffsets.js +241 -0
  66. package/Table/hooks/useTableScroll.d.ts +12 -0
  67. package/Table/hooks/useTableScroll.js +58 -0
  68. package/Table/hooks/useTableSelection.d.ts +7 -0
  69. package/Table/hooks/useTableSelection.js +94 -0
  70. package/Table/hooks/useTableSorting.d.ts +6 -0
  71. package/Table/hooks/useTableSorting.js +32 -0
  72. package/Table/hooks/useTableVirtualization.d.ts +22 -0
  73. package/Table/hooks/useTableVirtualization.js +115 -0
  74. package/Table/index.d.ts +7 -10
  75. package/Table/index.js +22 -6
  76. package/Table/utils/index.d.ts +2 -0
  77. package/Table/utils/index.js +1 -0
  78. package/Table/utils/useTableRowSelection.d.ts +18 -0
  79. package/Table/utils/useTableRowSelection.js +63 -0
  80. package/_internal/InputCheck/InputCheck.d.ts +15 -1
  81. package/_internal/InputCheck/InputCheck.js +6 -2
  82. package/_internal/InputCheck/InputCheckGroup.d.ts +11 -1
  83. package/_internal/InputCheck/InputCheckGroup.js +4 -2
  84. package/_internal/SlideFadeOverlay/SlideFadeOverlay.d.ts +1 -1
  85. package/_internal/SlideFadeOverlay/SlideFadeOverlay.js +1 -1
  86. package/index.d.ts +7 -5
  87. package/index.js +6 -9
  88. package/package.json +5 -4
  89. package/utils/flatten-children.d.ts +12 -0
  90. package/utils/flatten-children.js +37 -0
  91. package/utils/get-css-variable-value.d.ts +1 -0
  92. package/utils/get-css-variable-value.js +4 -1
  93. package/Table/TableBody.d.ts +0 -10
  94. package/Table/TableBody.js +0 -31
  95. package/Table/TableBodyRow.d.ts +0 -11
  96. package/Table/TableBodyRow.js +0 -65
  97. package/Table/TableCell.d.ts +0 -19
  98. package/Table/TableCell.js +0 -24
  99. package/Table/TableExpandedTable.d.ts +0 -11
  100. package/Table/TableExpandedTable.js +0 -29
  101. package/Table/TableHeader.d.ts +0 -3
  102. package/Table/TableHeader.js +0 -36
  103. package/Table/draggable/useTableDraggable.d.ts +0 -14
  104. package/Table/draggable/useTableDraggable.js +0 -64
  105. package/Table/editable/TableEditRenderWrapper.d.ts +0 -7
  106. package/Table/editable/TableEditRenderWrapper.js +0 -16
  107. package/Table/expandable/TableExpandable.d.ts +0 -27
  108. package/Table/expandable/TableExpandable.js +0 -24
  109. package/Table/pagination/TablePagination.d.ts +0 -10
  110. package/Table/pagination/TablePagination.js +0 -26
  111. package/Table/pagination/useTablePagination.d.ts +0 -8
  112. package/Table/pagination/useTablePagination.js +0 -30
  113. package/Table/refresh/TableRefresh.d.ts +0 -10
  114. package/Table/refresh/TableRefresh.js +0 -22
  115. package/Table/rowSelection/TableRowSelection.d.ts +0 -18
  116. package/Table/rowSelection/TableRowSelection.js +0 -93
  117. package/Table/rowSelection/useTableRowSelection.d.ts +0 -6
  118. package/Table/rowSelection/useTableRowSelection.js +0 -53
  119. package/Table/sorting/TableSortingIcon.d.ts +0 -10
  120. package/Table/sorting/TableSortingIcon.js +0 -33
  121. package/Table/sorting/useTableSorting.d.ts +0 -11
  122. package/Table/sorting/useTableSorting.js +0 -121
  123. package/Table/useTableFetchMore.d.ts +0 -10
  124. package/Table/useTableFetchMore.js +0 -50
  125. package/Table/useTableLoading.d.ts +0 -5
  126. package/Table/useTableLoading.js +0 -19
  127. package/Table/useTableScroll.d.ts +0 -592
  128. package/Table/useTableScroll.js +0 -296
  129. package/Tabs/Tab.d.ts +0 -18
  130. package/Tabs/Tab.js +0 -16
  131. package/Tabs/TabPane.d.ts +0 -14
  132. package/Tabs/TabPane.js +0 -19
  133. package/Tabs/Tabs.d.ts +0 -39
  134. package/Tabs/Tabs.js +0 -52
  135. package/Tabs/index.d.ts +0 -6
  136. package/Tabs/index.js +0 -3
  137. package/Tabs/useTabsOverflow.d.ts +0 -8
  138. package/Tabs/useTabsOverflow.js +0 -62
@@ -0,0 +1,11 @@
1
+ export interface TableExpandCellProps {
2
+ canExpand?: boolean;
3
+ className?: string;
4
+ expanded: boolean;
5
+ fixed?: boolean;
6
+ fixedOffset?: number;
7
+ isHeader?: boolean;
8
+ onClick?: VoidFunction;
9
+ showShadow?: boolean;
10
+ }
11
+ export declare const TableExpandCell: import("react").NamedExoticComponent<TableExpandCellProps & import("react").RefAttributes<HTMLTableCellElement>>;
@@ -0,0 +1,44 @@
1
+ 'use client';
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { memo, forwardRef, useCallback } from 'react';
4
+ import { tableClasses } from '@mezzanine-ui/core/table';
5
+ import { ChevronRightIcon } 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
+ const TableExpandCellInner = forwardRef(function TableExpandCell(props, ref) {
12
+ const { loading } = useTableContext();
13
+ const { canExpand = true, className, expanded, fixed = false, fixedOffset = 0, isHeader = false, onClick, showShadow = false, } = props;
14
+ const handleClick = useCallback((event) => {
15
+ event.stopPropagation();
16
+ if (canExpand && onClick) {
17
+ onClick();
18
+ }
19
+ }, [canExpand, onClick]);
20
+ const CellComponent = isHeader ? 'th' : 'td';
21
+ const cellStyle = {};
22
+ if (fixed) {
23
+ cellStyle['--fixed-start-offset'] =
24
+ `${fixedOffset}px`;
25
+ }
26
+ const renderChild = () => {
27
+ if (isHeader)
28
+ return null;
29
+ if (loading) {
30
+ return jsx(Skeleton, { width: "100%", variant: "body-highlight" });
31
+ }
32
+ return canExpand ? (jsx("button", { className: cx(tableClasses.expandIcon, {
33
+ [tableClasses.expandIconExpanded]: expanded,
34
+ }), onClick: handleClick, type: "button", children: jsx(Icon, { icon: ChevronRightIcon, color: "inherit" }) })) : null;
35
+ };
36
+ return (jsx(CellComponent, { className: cx(isHeader ? tableClasses.headerCell : tableClasses.cell, tableClasses.expandCell, {
37
+ [tableClasses.cellFixed]: fixed,
38
+ [tableClasses.cellFixedStart]: fixed,
39
+ [tableClasses.cellFixedShadow]: showShadow,
40
+ }, className), ref: ref, scope: isHeader ? 'col' : undefined, style: cellStyle, children: renderChild() }));
41
+ });
42
+ const TableExpandCell = memo(TableExpandCellInner);
43
+
44
+ export { TableExpandCell };
@@ -0,0 +1,9 @@
1
+ import { type TableDataSource } from '@mezzanine-ui/core/table';
2
+ export interface TableExpandedRowProps<T extends TableDataSource = TableDataSource> {
3
+ className?: string;
4
+ record: T;
5
+ style?: React.CSSProperties;
6
+ }
7
+ declare const TableExpandedRowInner: import("react").ForwardRefExoticComponent<TableExpandedRowProps<TableDataSource> & import("react").RefAttributes<HTMLTableRowElement>>;
8
+ export declare const TableExpandedRow: typeof TableExpandedRowInner;
9
+ export {};
@@ -0,0 +1,46 @@
1
+ 'use client';
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { memo, forwardRef, useMemo, cloneElement } from 'react';
4
+ import { getRowKey, tableClasses } from '@mezzanine-ui/core/table';
5
+ import { useTableContext } from '../TableContext.js';
6
+ import { Table } from '../Table.js';
7
+ import cx from 'clsx';
8
+
9
+ const TableExpandedRowInner = forwardRef(function TableExpandedRow(props, ref) {
10
+ const { className, record, style } = props;
11
+ const { columns, expansion, draggable, selection } = useTableContext();
12
+ // Calculate total column span
13
+ const totalColSpan = useMemo(() => {
14
+ let colSpan = columns.length;
15
+ // Add 1 for expand column itself
16
+ if (expansion)
17
+ colSpan += 1;
18
+ if (draggable === null || draggable === void 0 ? void 0 : draggable.enabled)
19
+ colSpan += 1;
20
+ if (selection)
21
+ colSpan += 1;
22
+ return colSpan;
23
+ }, [columns.length, expansion, draggable === null || draggable === void 0 ? void 0 : draggable.enabled, selection]);
24
+ const rowKey = getRowKey(record);
25
+ const isExpanded = expansion === null || expansion === void 0 ? void 0 : expansion.isRowExpanded(rowKey);
26
+ const { config } = expansion || {};
27
+ const { expandedRowRender } = config || {};
28
+ const childNeededProps = useMemo(() => ({
29
+ table: {
30
+ nested: true,
31
+ showHeader: false,
32
+ },
33
+ }), []);
34
+ if (!expandedRowRender || !isExpanded)
35
+ return null;
36
+ const children = expandedRowRender(record);
37
+ const clonedChild = cloneElement(children);
38
+ return (jsx("tr", { className: cx(tableClasses.expandedRow, 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
39
+ ? cloneElement(clonedChild, {
40
+ ...childNeededProps.table,
41
+ })
42
+ : clonedChild }) }) }));
43
+ });
44
+ const TableExpandedRow = memo(TableExpandedRowInner);
45
+
46
+ export { TableExpandedRow };
@@ -0,0 +1,4 @@
1
+ export interface TableHeaderProps {
2
+ className?: string;
3
+ }
4
+ export declare const TableHeader: import("react").NamedExoticComponent<TableHeaderProps & import("react").RefAttributes<HTMLTableSectionElement>>;
@@ -0,0 +1,125 @@
1
+ 'use client';
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
3
+ import { memo, forwardRef } from 'react';
4
+ import { tableClasses, DRAG_HANDLE_KEY, EXPANSION_KEY, SELECTION_KEY, getCellAlignClass } from '@mezzanine-ui/core/table';
5
+ import { QuestionOutlineIcon, CaretUpIcon, CaretDownIcon, DotVerticalIcon } from '@mezzanine-ui/icons';
6
+ import { useTableContext, useTableSuperContext } from '../TableContext.js';
7
+ import { TableDragHandleCell } from './TableDragHandleCell.js';
8
+ import { TableExpandCell } from './TableExpandCell.js';
9
+ import { TableResizeHandle } from './TableResizeHandle.js';
10
+ import { TableSelectionCell } from './TableSelectionCell.js';
11
+ import Tooltip from '../../Tooltip/Tooltip.js';
12
+ import Icon from '../../Icon/Icon.js';
13
+ import cx from 'clsx';
14
+
15
+ const TableHeaderInner = forwardRef(function TableHeader(props, ref) {
16
+ const { className } = props;
17
+ const { columns, draggable, expansion, fixedOffsets, resizable, selection, sorting, } = useTableContext();
18
+ const { containerWidth, scrollLeft } = useTableSuperContext();
19
+ const parseFixed = (fixed) => {
20
+ if (fixed === true || fixed === 'start')
21
+ return 'start';
22
+ if (fixed === 'end')
23
+ return 'end';
24
+ return null;
25
+ };
26
+ const renderDragHandleHeader = () => {
27
+ var _a;
28
+ if (!(draggable === null || draggable === void 0 ? void 0 : draggable.enabled))
29
+ return null;
30
+ const offsetInfo = fixedOffsets === null || fixedOffsets === void 0 ? void 0 : fixedOffsets.getDragHandleOffset();
31
+ const isFixed = !!draggable.fixed;
32
+ const showShadow = isFixed &&
33
+ (fixedOffsets === null || fixedOffsets === void 0 ? void 0 : fixedOffsets.shouldShowShadow(DRAG_HANDLE_KEY, scrollLeft !== null && scrollLeft !== void 0 ? scrollLeft : 0, containerWidth !== null && containerWidth !== void 0 ? containerWidth : 0));
34
+ return (jsx(TableDragHandleCell, { fixed: isFixed, fixedOffset: (_a = offsetInfo === null || offsetInfo === void 0 ? void 0 : offsetInfo.offset) !== null && _a !== void 0 ? _a : 0, isHeader: true, showShadow: showShadow !== null && showShadow !== void 0 ? showShadow : false }));
35
+ };
36
+ const renderSelectionHeader = () => {
37
+ var _a, _b, _c;
38
+ if (!selection)
39
+ return null;
40
+ const offsetInfo = fixedOffsets === null || fixedOffsets === void 0 ? void 0 : fixedOffsets.getSelectionOffset();
41
+ const isFixed = !!((_a = selection.config) === null || _a === void 0 ? void 0 : _a.fixed);
42
+ const showShadow = isFixed &&
43
+ (fixedOffsets === null || fixedOffsets === void 0 ? void 0 : fixedOffsets.shouldShowShadow(SELECTION_KEY, scrollLeft !== null && scrollLeft !== void 0 ? scrollLeft : 0, containerWidth !== null && containerWidth !== void 0 ? containerWidth : 0));
44
+ return (jsx(TableSelectionCell, { fixed: isFixed, fixedOffset: (_b = offsetInfo === null || offsetInfo === void 0 ? void 0 : offsetInfo.offset) !== null && _b !== void 0 ? _b : 0, indeterminate: selection.isIndeterminate, isHeader: true, hidden: (_c = selection.config) === null || _c === void 0 ? void 0 : _c.hideSelectAll, onChange: selection.toggleAll, selected: selection.isAllSelected, showShadow: showShadow !== null && showShadow !== void 0 ? showShadow : false }));
45
+ };
46
+ const renderExpandHeader = () => {
47
+ var _a, _b;
48
+ if (!expansion)
49
+ return null;
50
+ const offsetInfo = fixedOffsets === null || fixedOffsets === void 0 ? void 0 : fixedOffsets.getExpansionOffset();
51
+ const isFixed = !!((_a = expansion.config) === null || _a === void 0 ? void 0 : _a.fixed);
52
+ const showShadow = isFixed &&
53
+ (fixedOffsets === null || fixedOffsets === void 0 ? void 0 : fixedOffsets.shouldShowShadow(EXPANSION_KEY, scrollLeft !== null && scrollLeft !== void 0 ? scrollLeft : 0, containerWidth !== null && containerWidth !== void 0 ? containerWidth : 0));
54
+ return (jsx(TableExpandCell, { expanded: false, fixed: isFixed, fixedOffset: (_b = offsetInfo === null || offsetInfo === void 0 ? void 0 : offsetInfo.offset) !== null && _b !== void 0 ? _b : 0, isHeader: true, showShadow: showShadow !== null && showShadow !== void 0 ? showShadow : false }));
55
+ };
56
+ const renderHelpIcon = (column) => {
57
+ if (!column.titleHelp)
58
+ return null;
59
+ return (jsx(Tooltip, { title: column.titleHelp, disablePortal: false, children: ({ onMouseEnter, onMouseLeave, ref: tooltipRef }) => (jsx(Icon, { size: 16, icon: QuestionOutlineIcon, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, className: tableClasses.headerCellIcon, tabIndex: 0, ref: tooltipRef })) }));
60
+ };
61
+ const renderSortIcon = (column) => {
62
+ if (!column.onSort || !sorting)
63
+ return null;
64
+ const direction = column.sortOrder;
65
+ return (jsxs("button", { className: tableClasses.sortIcons, type: "button", onClick: (evt) => {
66
+ evt.stopPropagation();
67
+ sorting.onSort(column.key);
68
+ }, onKeyDown: (evt) => {
69
+ evt.stopPropagation();
70
+ if (evt.key === 'Enter' || evt.key === ' ') {
71
+ evt.preventDefault();
72
+ sorting.onSort(column.key);
73
+ }
74
+ }, children: [jsx(Icon, { className: cx(tableClasses.sortIcon, {
75
+ [tableClasses.sortIconActive]: direction === 'ascend',
76
+ }), icon: CaretUpIcon, size: 8 }), jsx(Icon, { className: cx(tableClasses.sortIcon, {
77
+ [tableClasses.sortIconActive]: direction === 'descend',
78
+ }), icon: CaretDownIcon, size: 8 })] }));
79
+ };
80
+ const renderMenuIcon = (column) => {
81
+ if (!column.titleMenu)
82
+ return null;
83
+ /** @TODO wait for dropdown component */
84
+ return (jsx(Icon, { size: 16, icon: DotVerticalIcon, className: tableClasses.headerCellIcon }));
85
+ };
86
+ const renderHeaderCells = () => {
87
+ return columns.map((column, columnIndex) => {
88
+ var _a;
89
+ const fixedPos = parseFixed(column.fixed);
90
+ const alignClass = getCellAlignClass(column.align);
91
+ const offsetInfo = fixedOffsets === null || fixedOffsets === void 0 ? void 0 : fixedOffsets.getColumnOffset(column.key);
92
+ const offset = (_a = offsetInfo === null || offsetInfo === void 0 ? void 0 : offsetInfo.offset) !== null && _a !== void 0 ? _a : 0;
93
+ const cellStyle = {};
94
+ if (fixedPos === 'start') {
95
+ cellStyle['--fixed-start-offset'] =
96
+ `${offset}px`;
97
+ }
98
+ else if (fixedPos === 'end') {
99
+ cellStyle['--fixed-end-offset'] =
100
+ `${offset}px`;
101
+ }
102
+ // Show shadow based on scroll position and sticky state
103
+ const showShadow = !!fixedPos &&
104
+ (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));
105
+ const ariaSort = (() => {
106
+ if (column.sortOrder === 'ascend')
107
+ return 'ascending';
108
+ if (column.sortOrder === 'descend')
109
+ return 'descending';
110
+ return undefined;
111
+ })();
112
+ return (jsxs("th", { "aria-sort": ariaSort, className: cx(tableClasses.headerCell, {
113
+ [tableClasses.cellFixed]: !!fixedPos,
114
+ [tableClasses.cellFixedEnd]: fixedPos === 'end',
115
+ [tableClasses.cellFixedShadow]: showShadow,
116
+ [tableClasses.cellFixedStart]: fixedPos === 'start',
117
+ [tableClasses.headerCellFixed]: !!fixedPos,
118
+ }, column.className), 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)] }), renderMenuIcon(column)] }), resizable && (jsx(TableResizeHandle, { column: column, columnIndex: columnIndex }))] }, column.key));
119
+ });
120
+ };
121
+ return (jsx("thead", { className: cx(tableClasses.header, className), ref: ref, children: jsxs("tr", { className: tableClasses.headerRow, children: [renderDragHandleHeader(), renderExpandHeader(), renderSelectionHeader(), renderHeaderCells()] }) }));
122
+ });
123
+ const TableHeader = memo(TableHeaderInner);
124
+
125
+ export { TableHeader };
@@ -0,0 +1,3 @@
1
+ import { PaginationProps } from '../../Pagination';
2
+ export type TablePaginationProps = PaginationProps;
3
+ export declare const TablePagination: import("react").NamedExoticComponent<Omit<PaginationProps, "ref"> & import("react").RefAttributes<HTMLElement>>;
@@ -0,0 +1,11 @@
1
+ 'use client';
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { memo, forwardRef } from 'react';
4
+ import Pagination from '../../Pagination/Pagination.js';
5
+
6
+ const TablePaginationInner = forwardRef(function TablePagination(props, ref) {
7
+ return jsx(Pagination, { ref: ref, ...props });
8
+ });
9
+ const TablePagination = memo(TablePaginationInner);
10
+
11
+ export { TablePagination };
@@ -0,0 +1,13 @@
1
+ import { type TableColumn } from '@mezzanine-ui/core/table';
2
+ export interface TableResizeHandleProps {
3
+ /** The column this resize handle belongs to */
4
+ column: TableColumn;
5
+ /** Index of the column in the columns array */
6
+ columnIndex: number;
7
+ }
8
+ /**
9
+ * TableResizeHandle provides column resizing functionality.
10
+ * It adjusts the width of the current column and the next column together,
11
+ * maintaining the total width of both columns.
12
+ */
13
+ export declare const TableResizeHandle: import("react").NamedExoticComponent<TableResizeHandleProps>;
@@ -0,0 +1,115 @@
1
+ 'use client';
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { memo, useRef, useCallback } from 'react';
4
+ import { tableClasses } from '@mezzanine-ui/core/table';
5
+ import { useTableContext } from '../TableContext.js';
6
+
7
+ /**
8
+ * TableResizeHandle provides column resizing functionality.
9
+ * It adjusts the width of the current column and the next column together,
10
+ * maintaining the total width of both columns.
11
+ */
12
+ const TableResizeHandle = memo(function TableResizeHandle({ column, columnIndex, }) {
13
+ const { columnState, columns, draggable, expansion, scrollContainerRef, selection, } = useTableContext();
14
+ const { setResizedColumnWidth } = columnState || {};
15
+ const startWidthRef = useRef(0);
16
+ const nextStartWidthRef = useRef(0);
17
+ const startXRef = useRef(0);
18
+ // Calculate action columns offset
19
+ const actionColumnsOffset = (() => {
20
+ let offset = 0;
21
+ if (draggable === null || draggable === void 0 ? void 0 : draggable.enabled)
22
+ offset += 1;
23
+ if (expansion)
24
+ offset += 1;
25
+ if (selection)
26
+ offset += 1;
27
+ return offset;
28
+ })();
29
+ // Get the actual rendered width of a column from the DOM
30
+ const getColumnActualWidth = useCallback((colIndex) => {
31
+ const container = scrollContainerRef === null || scrollContainerRef === void 0 ? void 0 : scrollContainerRef.current;
32
+ if (!container)
33
+ return 0;
34
+ const table = container.querySelector('table');
35
+ if (!table)
36
+ return 0;
37
+ const colGroup = table.querySelector('colgroup');
38
+ if (!colGroup)
39
+ return 0;
40
+ const colElements = colGroup.querySelectorAll('col');
41
+ const targetCol = colElements[actionColumnsOffset + colIndex];
42
+ if (!targetCol)
43
+ return 0;
44
+ return targetCol.getBoundingClientRect().width;
45
+ }, [actionColumnsOffset, scrollContainerRef]);
46
+ const handleMouseDown = useCallback((event) => {
47
+ event.preventDefault();
48
+ event.stopPropagation();
49
+ // Get next column (the one to the right)
50
+ const nextColumn = columns[columnIndex + 1];
51
+ if (!nextColumn) {
52
+ // If there's no next column, we can't do adjacent resize
53
+ return;
54
+ }
55
+ // Get the actual rendered widths from the DOM
56
+ const currentWidth = getColumnActualWidth(columnIndex);
57
+ const nextWidth = getColumnActualWidth(columnIndex + 1);
58
+ if (currentWidth === 0 || nextWidth === 0) {
59
+ return;
60
+ }
61
+ startXRef.current = event.clientX;
62
+ startWidthRef.current = currentWidth;
63
+ nextStartWidthRef.current = nextWidth;
64
+ // Get min/max constraints (undefined means no constraint)
65
+ const minWidth = column.minWidth;
66
+ const maxWidth = column.maxWidth;
67
+ const nextMinWidth = nextColumn.minWidth;
68
+ const nextMaxWidth = nextColumn.maxWidth;
69
+ const handleMouseMove = (moveEvent) => {
70
+ const diff = moveEvent.clientX - startXRef.current;
71
+ // Calculate desired new widths
72
+ const newWidth = startWidthRef.current + diff;
73
+ const newNextWidth = nextStartWidthRef.current - diff;
74
+ // Check if either column would hit its constraint
75
+ let isConstrained = false;
76
+ // Check current column constraints
77
+ if (minWidth !== undefined && newWidth < minWidth) {
78
+ isConstrained = true;
79
+ }
80
+ if (maxWidth !== undefined && newWidth > maxWidth) {
81
+ isConstrained = true;
82
+ }
83
+ // Check next column constraints
84
+ if (nextMinWidth !== undefined && newNextWidth < nextMinWidth) {
85
+ isConstrained = true;
86
+ }
87
+ if (nextMaxWidth !== undefined && newNextWidth > nextMaxWidth) {
88
+ isConstrained = true;
89
+ }
90
+ // If either column is constrained, stop both from changing
91
+ if (isConstrained) {
92
+ return;
93
+ }
94
+ // Final validation: ensure we don't go below 0
95
+ if (newWidth < 0 || newNextWidth < 0) {
96
+ return;
97
+ }
98
+ setResizedColumnWidth === null || setResizedColumnWidth === void 0 ? void 0 : setResizedColumnWidth(column.key, newWidth);
99
+ setResizedColumnWidth === null || setResizedColumnWidth === void 0 ? void 0 : setResizedColumnWidth(nextColumn.key, newNextWidth);
100
+ };
101
+ const handleMouseUp = () => {
102
+ document.removeEventListener('mousemove', handleMouseMove);
103
+ document.removeEventListener('mouseup', handleMouseUp);
104
+ };
105
+ document.addEventListener('mousemove', handleMouseMove);
106
+ document.addEventListener('mouseup', handleMouseUp);
107
+ }, [column, columnIndex, columns, getColumnActualWidth, setResizedColumnWidth]);
108
+ // Don't show resize handle for the last column (no adjacent column to resize)
109
+ if (columnIndex >= columns.length - 1) {
110
+ return null;
111
+ }
112
+ return (jsx("div", { "aria-hidden": "true", className: tableClasses.resizeHandle, onMouseDown: handleMouseDown, role: "presentation" }));
113
+ });
114
+
115
+ export { TableResizeHandle };
@@ -0,0 +1,12 @@
1
+ import { type TableDataSource } from '@mezzanine-ui/core/table';
2
+ import type { DraggableProvided } from '@hello-pangea/dnd';
3
+ export interface TableRowProps<T extends TableDataSource = TableDataSource> {
4
+ className?: string;
5
+ draggableProvided?: DraggableProvided;
6
+ record: T;
7
+ rowIndex: number;
8
+ style?: React.CSSProperties;
9
+ }
10
+ declare const TableRowInner: import("react").ForwardRefExoticComponent<TableRowProps<TableDataSource> & import("react").RefAttributes<HTMLTableRowElement>>;
11
+ export declare const TableRow: typeof TableRowInner;
12
+ export {};
@@ -0,0 +1,126 @@
1
+ 'use client';
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { memo, forwardRef, useMemo, useCallback } from 'react';
4
+ import { getRowKey, tableClasses, DRAG_HANDLE_KEY, EXPANSION_KEY, SELECTION_KEY } from '@mezzanine-ui/core/table';
5
+ import { useTableContext, useTableSuperContext } from '../TableContext.js';
6
+ import { TableCell } from './TableCell.js';
7
+ import { TableDragHandleCell } from './TableDragHandleCell.js';
8
+ import { TableExpandCell } from './TableExpandCell.js';
9
+ import { TableSelectionCell } from './TableSelectionCell.js';
10
+ import { composeRefs } from '../../utils/composeRefs.js';
11
+ import cx from 'clsx';
12
+
13
+ const parseFixed = (fixed) => {
14
+ if (fixed === true || fixed === 'start')
15
+ return 'start';
16
+ if (fixed === 'end')
17
+ return 'end';
18
+ return null;
19
+ };
20
+ const TableRowInner = forwardRef(function TableRow(props, ref) {
21
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
22
+ const { className, draggableProvided, record, rowIndex, style } = props;
23
+ const { columns, draggable, expansion, fixedOffsets, rowHeight, highlight, selection, transitionState, } = useTableContext();
24
+ const resolvedStyle = useMemo(() => ({
25
+ ...style,
26
+ ...draggableProvided === null || draggableProvided === void 0 ? void 0 : draggableProvided.draggableProps.style,
27
+ height: rowHeight,
28
+ }), [style, rowHeight, draggableProvided === null || draggableProvided === void 0 ? void 0 : draggableProvided.draggableProps.style]);
29
+ const { containerWidth, scrollLeft } = useTableSuperContext();
30
+ const rowKey = useMemo(() => getRowKey(record), [record]);
31
+ const isSelected = (_e = (_d = (_c = (_b = (_a = selection === null || selection === void 0 ? void 0 : selection.config) === null || _a === void 0 ? void 0 : _a.getCheckboxProps) === null || _b === void 0 ? void 0 : _b.call(_a, record)) === null || _c === void 0 ? void 0 : _c.selected) !== null && _d !== void 0 ? _d : selection === null || selection === void 0 ? void 0 : selection.isRowSelected(rowKey)) !== null && _e !== void 0 ? _e : false;
32
+ const isIndeterminate = (_j = (_h = (_g = (_f = selection === null || selection === void 0 ? void 0 : selection.config) === null || _f === void 0 ? void 0 : _f.getCheckboxProps) === null || _g === void 0 ? void 0 : _g.call(_f, record)) === null || _h === void 0 ? void 0 : _h.indeterminate) !== null && _j !== void 0 ? _j : false;
33
+ const isExpanded = (_k = expansion === null || expansion === void 0 ? void 0 : expansion.isRowExpanded(rowKey)) !== null && _k !== void 0 ? _k : false;
34
+ // Check transition states
35
+ const isAdding = (_l = transitionState === null || transitionState === void 0 ? void 0 : transitionState.addingKeys.has(rowKey)) !== null && _l !== void 0 ? _l : false;
36
+ const isDeleting = (_m = transitionState === null || transitionState === void 0 ? void 0 : transitionState.deletingKeys.has(rowKey)) !== null && _m !== void 0 ? _m : false;
37
+ const isFadingOut = (_o = transitionState === null || transitionState === void 0 ? void 0 : transitionState.fadingOutKeys.has(rowKey)) !== null && _o !== void 0 ? _o : false;
38
+ // Check if this row should be highlighted based on highlight mode
39
+ const isRowHighlighted = useMemo(() => {
40
+ if (!highlight)
41
+ return false;
42
+ const { mode, rowIndex: hoveredRow } = highlight;
43
+ if (hoveredRow === null)
44
+ return false;
45
+ // Row highlight: when hovering any cell in this row
46
+ if (mode === 'row' && hoveredRow === rowIndex)
47
+ return true;
48
+ // Cross highlight: this row matches the hovered row
49
+ if (mode === 'cross' && hoveredRow === rowIndex)
50
+ return true;
51
+ return false;
52
+ }, [highlight, rowIndex]);
53
+ const handleRowClick = useCallback(() => {
54
+ // Future: support row click to expand or select
55
+ }, []);
56
+ const handleKeyDown = useCallback((event) => {
57
+ if (event.key === 'Enter' || event.key === ' ') {
58
+ handleRowClick();
59
+ }
60
+ }, [handleRowClick]);
61
+ const handleMouseLeave = useCallback(() => {
62
+ highlight === null || highlight === void 0 ? void 0 : highlight.setHoveredCell(null, null);
63
+ }, [highlight]);
64
+ const renderDragHandleCell = () => {
65
+ var _a;
66
+ if (!(draggable === null || draggable === void 0 ? void 0 : draggable.enabled))
67
+ return null;
68
+ const offsetInfo = fixedOffsets === null || fixedOffsets === void 0 ? void 0 : fixedOffsets.getDragHandleOffset();
69
+ const isFixed = !!draggable.fixed;
70
+ const showShadow = isFixed &&
71
+ (fixedOffsets === null || fixedOffsets === void 0 ? void 0 : fixedOffsets.shouldShowShadow(DRAG_HANDLE_KEY, scrollLeft !== null && scrollLeft !== void 0 ? scrollLeft : 0, containerWidth !== null && containerWidth !== void 0 ? containerWidth : 0));
72
+ return (jsx(TableDragHandleCell, { dragHandleProps: draggableProvided === null || draggableProvided === void 0 ? void 0 : draggableProvided.dragHandleProps, fixed: isFixed, fixedOffset: (_a = offsetInfo === null || offsetInfo === void 0 ? void 0 : offsetInfo.offset) !== null && _a !== void 0 ? _a : 0, showShadow: showShadow !== null && showShadow !== void 0 ? showShadow : false }));
73
+ };
74
+ const renderSelectionCell = () => {
75
+ var _a, _b;
76
+ if (!selection)
77
+ return null;
78
+ const isDisabled = selection.isRowDisabled(record);
79
+ const offsetInfo = fixedOffsets === null || fixedOffsets === void 0 ? void 0 : fixedOffsets.getSelectionOffset();
80
+ const isFixed = !!((_a = selection.config) === null || _a === void 0 ? void 0 : _a.fixed);
81
+ const showShadow = isFixed &&
82
+ (fixedOffsets === null || fixedOffsets === void 0 ? void 0 : fixedOffsets.shouldShowShadow(SELECTION_KEY, scrollLeft !== null && scrollLeft !== void 0 ? scrollLeft : 0, containerWidth !== null && containerWidth !== void 0 ? containerWidth : 0));
83
+ return (jsx(TableSelectionCell, { disabled: isDisabled, fixed: isFixed, fixedOffset: (_b = offsetInfo === null || offsetInfo === void 0 ? void 0 : offsetInfo.offset) !== null && _b !== void 0 ? _b : 0, indeterminate: isIndeterminate, onChange: () => selection.toggleRow(rowKey, record), selected: isSelected, showShadow: showShadow !== null && showShadow !== void 0 ? showShadow : false }));
84
+ };
85
+ const renderExpandCell = () => {
86
+ var _a;
87
+ if (!expansion)
88
+ return null;
89
+ const { config } = expansion;
90
+ const canExpand = config.rowExpandable
91
+ ? config.rowExpandable(record)
92
+ : true;
93
+ const offsetInfo = fixedOffsets === null || fixedOffsets === void 0 ? void 0 : fixedOffsets.getExpansionOffset();
94
+ const isFixed = !!config.fixed;
95
+ const showShadow = isFixed &&
96
+ (fixedOffsets === null || fixedOffsets === void 0 ? void 0 : fixedOffsets.shouldShowShadow(EXPANSION_KEY, scrollLeft !== null && scrollLeft !== void 0 ? scrollLeft : 0, containerWidth !== null && containerWidth !== void 0 ? containerWidth : 0));
97
+ return (jsx(TableExpandCell, { canExpand: canExpand, expanded: isExpanded, fixed: isFixed, fixedOffset: (_a = offsetInfo === null || offsetInfo === void 0 ? void 0 : offsetInfo.offset) !== null && _a !== void 0 ? _a : 0, onClick: () => expansion.toggleExpand(rowKey, record), showShadow: showShadow !== null && showShadow !== void 0 ? showShadow : false }));
98
+ };
99
+ const renderCells = () => {
100
+ return columns.map((column, columnIndex) => {
101
+ var _a;
102
+ const fixedPos = parseFixed(column.fixed);
103
+ const offsetInfo = fixedOffsets === null || fixedOffsets === void 0 ? void 0 : fixedOffsets.getColumnOffset(column.key);
104
+ const offset = (_a = offsetInfo === null || offsetInfo === void 0 ? void 0 : offsetInfo.offset) !== null && _a !== void 0 ? _a : 0;
105
+ // Show shadow based on scroll position and sticky state
106
+ const showShadow = !!fixedPos &&
107
+ (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));
108
+ return (jsx(TableCell, { column: column, columnIndex: columnIndex, fixed: fixedPos !== null && fixedPos !== void 0 ? fixedPos : undefined, fixedOffset: offset, record: record, rowIndex: rowIndex, showShadow: showShadow !== null && showShadow !== void 0 ? showShadow : false }, column.key));
109
+ });
110
+ };
111
+ // Combine refs if draggable is provided
112
+ const rowRef = draggableProvided
113
+ ? composeRefs([ref, draggableProvided.innerRef])
114
+ : ref;
115
+ return (jsxs("tr", { "aria-rowindex": rowIndex + 1, "aria-selected": isSelected, className: cx(tableClasses.row, {
116
+ [tableClasses.bodyRowAdding]: isAdding,
117
+ [tableClasses.bodyRowDeleting]: isDeleting,
118
+ [tableClasses.bodyRowFadingOut]: isFadingOut,
119
+ [tableClasses.bodyRowHighlight]: isRowHighlighted,
120
+ [tableClasses.rowExpanded]: isExpanded,
121
+ [tableClasses.rowSelected]: isSelected,
122
+ }, className), "data-index": rowIndex, "data-row-key": rowKey, onClick: handleRowClick, onKeyDown: handleKeyDown, onMouseLeave: handleMouseLeave, ref: rowRef, tabIndex: 0, ...draggableProvided === null || draggableProvided === void 0 ? void 0 : draggableProvided.draggableProps, style: resolvedStyle, children: [renderDragHandleCell(), renderExpandCell(), renderSelectionCell(), renderCells()] }));
123
+ });
124
+ const TableRow = memo(TableRowInner);
125
+
126
+ export { TableRow };
@@ -0,0 +1,13 @@
1
+ export interface TableSelectionCellProps {
2
+ className?: string;
3
+ disabled?: boolean;
4
+ fixed?: boolean;
5
+ fixedOffset?: number;
6
+ hidden?: boolean;
7
+ indeterminate?: boolean;
8
+ isHeader?: boolean;
9
+ onChange: () => void;
10
+ selected: boolean;
11
+ showShadow?: boolean;
12
+ }
13
+ export declare const TableSelectionCell: import("react").NamedExoticComponent<TableSelectionCellProps & import("react").RefAttributes<HTMLTableCellElement>>;
@@ -0,0 +1,35 @@
1
+ 'use client';
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { memo, forwardRef } from 'react';
4
+ import { tableClasses } from '@mezzanine-ui/core/table';
5
+ import Checkbox from '../../Checkbox/Checkbox.js';
6
+ import { useTableContext } from '../TableContext.js';
7
+ import Skeleton from '../../Skeleton/Skeleton.js';
8
+ import cx from 'clsx';
9
+
10
+ const TableSelectionCellInner = forwardRef(function TableSelectionCell(props, ref) {
11
+ const { loading } = useTableContext();
12
+ const { className, disabled = false, fixed = false, fixedOffset = 0, hidden = false, indeterminate = false, isHeader = false, onChange, selected, showShadow = false, } = props;
13
+ const CellComponent = isHeader ? 'th' : 'td';
14
+ const cellStyle = {};
15
+ if (fixed) {
16
+ cellStyle['--fixed-start-offset'] =
17
+ `${fixedOffset}px`;
18
+ }
19
+ const renderChild = () => {
20
+ if (hidden)
21
+ return null;
22
+ if (loading) {
23
+ return jsx(Skeleton, { width: "100%", variant: "body-highlight" });
24
+ }
25
+ return (jsx(Checkbox, { checked: selected, disabled: disabled, indeterminate: indeterminate, onChange: onChange }));
26
+ };
27
+ return (jsx(CellComponent, { className: cx(isHeader ? tableClasses.headerCell : tableClasses.cell, tableClasses.selectionCell, {
28
+ [tableClasses.cellFixed]: fixed,
29
+ [tableClasses.cellFixedStart]: fixed,
30
+ [tableClasses.cellFixedShadow]: showShadow,
31
+ }, className), ref: ref, scope: isHeader ? 'col' : undefined, style: cellStyle, children: jsx("div", { className: tableClasses.selectionCheckbox, children: renderChild() }) }));
32
+ });
33
+ const TableSelectionCell = memo(TableSelectionCellInner);
34
+
35
+ export { TableSelectionCell };
@@ -0,0 +1,10 @@
1
+ export { TableBody, type TableBodyProps } from './TableBody';
2
+ export { TableCell, type TableCellProps } from './TableCell';
3
+ export { TableColGroup, type TableColGroupProps } from './TableColGroup';
4
+ export { TableExpandCell, type TableExpandCellProps } from './TableExpandCell';
5
+ export { TableExpandedRow, type TableExpandedRowProps, } from './TableExpandedRow';
6
+ export { TableHeader, type TableHeaderProps } from './TableHeader';
7
+ export { TablePagination, type TablePaginationProps } from './TablePagination';
8
+ export { TableResizeHandle, type TableResizeHandleProps, } from './TableResizeHandle';
9
+ export { TableRow, type TableRowProps } from './TableRow';
10
+ export { TableSelectionCell, type TableSelectionCellProps, } from './TableSelectionCell';
@@ -0,0 +1,10 @@
1
+ export { TableBody } from './TableBody.js';
2
+ export { TableCell } from './TableCell.js';
3
+ export { TableColGroup } from './TableColGroup.js';
4
+ export { TableExpandCell } from './TableExpandCell.js';
5
+ export { TableExpandedRow } from './TableExpandedRow.js';
6
+ export { TableHeader } from './TableHeader.js';
7
+ export { TablePagination } from './TablePagination.js';
8
+ export { TableResizeHandle } from './TableResizeHandle.js';
9
+ export { TableRow } from './TableRow.js';
10
+ export { TableSelectionCell } from './TableSelectionCell.js';
@@ -0,0 +1,9 @@
1
+ export { useTableSorting, type UseTableSortingOptions, } from './useTableSorting';
2
+ export { useTableSelection, type UseTableSelectionOptions, } from './useTableSelection';
3
+ export { useTableColumns, type UseTableColumnsOptions, } from './useTableColumns';
4
+ export { useTableExpansion, type UseTableExpansionOptions, } from './useTableExpansion';
5
+ export { useTableFixedOffsets, type FixedOffsetInfo, type UseTableFixedOffsetsOptions, type UseTableFixedOffsetsReturn, } from './useTableFixedOffsets';
6
+ export { useTableScroll, type UseTableScrollReturn } from './useTableScroll';
7
+ export { useTableVirtualization, type UseTableVirtualizationOptions, type UseTableVirtualizationReturn, } from './useTableVirtualization';
8
+ export { useTableDataSource, type TableTransitionState, type UpdateDataSourceOptions, type UseTableDataSourceOptions, type UseTableDataSourceReturn, } from './useTableDataSource';
9
+ export * from './typings';
@@ -0,0 +1,8 @@
1
+ export { useTableSorting } from './useTableSorting.js';
2
+ export { useTableSelection } from './useTableSelection.js';
3
+ export { useTableColumns } from './useTableColumns.js';
4
+ export { useTableExpansion } from './useTableExpansion.js';
5
+ export { useTableFixedOffsets } from './useTableFixedOffsets.js';
6
+ export { useTableScroll } from './useTableScroll.js';
7
+ export { useTableVirtualization } from './useTableVirtualization.js';
8
+ export { useTableDataSource } from './useTableDataSource.js';