@ackplus/react-tanstack-data-table 1.0.19-beta-0.15 → 1.0.20
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/README.md +868 -38
- package/package.json +1 -1
- package/src/index.d.ts +1 -4
- package/src/index.js +2 -9
- package/src/lib/components/filters/filter-value-input.d.ts +8 -1
- package/src/lib/components/filters/filter-value-input.js +14 -31
- package/src/lib/components/headers/draggable-header.d.ts +6 -2
- package/src/lib/components/headers/draggable-header.js +42 -50
- package/src/lib/components/headers/table-header.d.ts +8 -2
- package/src/lib/components/headers/table-header.js +24 -18
- package/src/lib/components/pagination/data-table-pagination.d.ts +8 -2
- package/src/lib/components/pagination/data-table-pagination.js +27 -15
- package/src/lib/components/rows/data-table-row.d.ts +9 -2
- package/src/lib/components/rows/data-table-row.js +21 -7
- package/src/lib/components/rows/empty-data-row.d.ts +11 -4
- package/src/lib/components/rows/empty-data-row.js +14 -2
- package/src/lib/components/rows/loading-rows.d.ts +9 -2
- package/src/lib/components/rows/loading-rows.js +29 -19
- package/src/lib/components/table/data-table.js +27 -32
- package/src/lib/components/table/data-table.types.d.ts +0 -18
- package/src/lib/components/toolbar/bulk-actions-toolbar.d.ts +9 -3
- package/src/lib/components/toolbar/bulk-actions-toolbar.js +15 -10
- package/src/lib/components/toolbar/column-filter-control.d.ts +14 -1
- package/src/lib/components/toolbar/column-filter-control.js +14 -12
- package/src/lib/components/toolbar/column-pinning-control.d.ts +12 -1
- package/src/lib/components/toolbar/column-pinning-control.js +24 -42
- package/src/lib/components/toolbar/column-reset-control.d.ts +8 -1
- package/src/lib/components/toolbar/column-reset-control.js +34 -6
- package/src/lib/components/toolbar/column-visibility-control.d.ts +10 -1
- package/src/lib/components/toolbar/column-visibility-control.js +7 -7
- package/src/lib/components/toolbar/data-table-toolbar.d.ts +9 -2
- package/src/lib/components/toolbar/data-table-toolbar.js +15 -2
- package/src/lib/components/toolbar/table-export-control.d.ts +7 -1
- package/src/lib/components/toolbar/table-export-control.js +24 -68
- package/src/lib/components/toolbar/table-search-control.d.ts +12 -1
- package/src/lib/components/toolbar/table-search-control.js +24 -11
- package/src/lib/components/toolbar/table-size-control.d.ts +9 -1
- package/src/lib/components/toolbar/table-size-control.js +17 -9
- package/src/lib/examples/index.d.ts +2 -0
- package/src/lib/examples/index.js +5 -1
- package/src/lib/examples/simple-slots-example.d.ts +1 -0
- package/src/lib/examples/simple-slots-example.js +115 -0
- package/src/lib/types/data-table-api.d.ts +4 -1
- package/src/lib/types/slots.types.d.ts +142 -137
- package/src/lib/utils/slot-helpers.d.ts +12 -6
- package/src/lib/utils/slot-helpers.js +86 -12
|
@@ -8,8 +8,9 @@ const react_1 = require("react");
|
|
|
8
8
|
const menu_dropdown_1 = require("../droupdown/menu-dropdown");
|
|
9
9
|
const data_table_context_1 = require("../../contexts/data-table-context");
|
|
10
10
|
const slot_helpers_1 = require("../../utils/slot-helpers");
|
|
11
|
-
function ColumnVisibilityControl() {
|
|
11
|
+
function ColumnVisibilityControl(props = {}) {
|
|
12
12
|
const { table, slots, slotProps } = (0, data_table_context_1.useDataTableContext)();
|
|
13
|
+
const iconSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'columnIcon');
|
|
13
14
|
const ColumnIconSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'columnIcon', icons_material_1.ViewColumnOutlined);
|
|
14
15
|
const columns = (0, react_1.useMemo)(() => {
|
|
15
16
|
var _a, _b;
|
|
@@ -22,10 +23,9 @@ function ColumnVisibilityControl() {
|
|
|
22
23
|
var _a;
|
|
23
24
|
(_a = table.getColumn(columnId)) === null || _a === void 0 ? void 0 : _a.toggleVisibility(visible);
|
|
24
25
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "subtitle2", sx: { mb: 1 }, children: "Show/Hide Columns" }), (0, jsx_runtime_1.jsx)(material_1.Divider, { sx: { mb: 1 } }), (0, jsx_runtime_1.jsx)(material_1.FormGroup, { children: columns.map((column) => ((0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: ((0, jsx_runtime_1.jsx)(material_1.Checkbox, { disabled: !column.getCanHide(), checked: column.getIsVisible(), onChange: (e) => handleColumnVisibilityChange(column.id, e.target.checked), size: "small" })), label: typeof column.columnDef.header === 'string' ? column.columnDef.header : column.id }, column.id))) })] })) }));
|
|
26
|
+
const mergedProps = (0, slot_helpers_1.mergeSlotProps)({
|
|
27
|
+
size: 'small',
|
|
28
|
+
sx: { flexShrink: 0 },
|
|
29
|
+
}, (slotProps === null || slotProps === void 0 ? void 0 : slotProps.columnVisibilityControl) || {}, props);
|
|
30
|
+
return ((0, jsx_runtime_1.jsx)(menu_dropdown_1.MenuDropdown, { anchor: ((0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: "Column visibility", children: (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({}, mergedProps, { children: (0, jsx_runtime_1.jsx)(ColumnIconSlot, Object.assign({}, iconSlotProps)) })) })), children: ({ handleClose }) => ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: Object.assign({ p: 2, minWidth: 200 }, mergedProps.menuSx), children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "subtitle2", sx: Object.assign({ mb: 1 }, mergedProps.titleSx), children: mergedProps.title || 'Show/Hide Columns' }), (0, jsx_runtime_1.jsx)(material_1.Divider, { sx: { mb: 1 } }), (0, jsx_runtime_1.jsx)(material_1.FormGroup, { children: columns.map((column) => ((0, jsx_runtime_1.jsx)(material_1.FormControlLabel, Object.assign({ control: ((0, jsx_runtime_1.jsx)(material_1.Checkbox, Object.assign({ disabled: !column.getCanHide(), checked: column.getIsVisible(), onChange: (e) => handleColumnVisibilityChange(column.id, e.target.checked), size: "small" }, mergedProps.checkboxProps))), label: typeof column.columnDef.header === 'string' ? column.columnDef.header : column.id }, mergedProps.labelProps), column.id))) })] })) }));
|
|
31
31
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { ToolbarProps, SxProps } from '@mui/material';
|
|
1
2
|
import { ReactNode } from 'react';
|
|
2
|
-
export interface DataTableToolbarProps {
|
|
3
|
+
export interface DataTableToolbarProps extends ToolbarProps {
|
|
3
4
|
extraFilter?: ReactNode;
|
|
4
5
|
enableGlobalFilter?: boolean;
|
|
5
6
|
title?: string;
|
|
@@ -10,5 +11,11 @@ export interface DataTableToolbarProps {
|
|
|
10
11
|
enableColumnFilter?: boolean;
|
|
11
12
|
enableTableSizeControl?: boolean;
|
|
12
13
|
enableColumnPinning?: boolean;
|
|
14
|
+
titleSx?: SxProps;
|
|
15
|
+
subtitleSx?: SxProps;
|
|
16
|
+
containerSx?: SxProps;
|
|
17
|
+
leftSectionSx?: SxProps;
|
|
18
|
+
rightSectionSx?: SxProps;
|
|
19
|
+
[key: string]: any;
|
|
13
20
|
}
|
|
14
|
-
export declare function DataTableToolbar(
|
|
21
|
+
export declare function DataTableToolbar(props?: DataTableToolbarProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DataTableToolbar = DataTableToolbar;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
6
|
const material_1 = require("@mui/material");
|
|
6
7
|
const column_filter_control_1 = require("./column-filter-control");
|
|
@@ -12,8 +13,17 @@ const table_search_control_1 = require("./table-search-control");
|
|
|
12
13
|
const table_size_control_1 = require("./table-size-control");
|
|
13
14
|
const data_table_context_1 = require("../../contexts/data-table-context");
|
|
14
15
|
const slot_helpers_1 = require("../../utils/slot-helpers");
|
|
15
|
-
function DataTableToolbar(
|
|
16
|
+
function DataTableToolbar(props = {}) {
|
|
17
|
+
const { extraFilter = null, enableGlobalFilter = true, title, subtitle, enableColumnVisibility = true, enableExport = true, enableReset = true, enableColumnFilter = true, enableTableSizeControl = true, enableColumnPinning = true, titleSx, subtitleSx, containerSx, leftSectionSx, rightSectionSx } = props, otherProps = tslib_1.__rest(props, ["extraFilter", "enableGlobalFilter", "title", "subtitle", "enableColumnVisibility", "enableExport", "enableReset", "enableColumnFilter", "enableTableSizeControl", "enableColumnPinning", "titleSx", "subtitleSx", "containerSx", "leftSectionSx", "rightSectionSx"]);
|
|
16
18
|
const { table, slots, slotProps = {} } = (0, data_table_context_1.useDataTableContext)();
|
|
19
|
+
const toolbarSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'toolbar');
|
|
20
|
+
const searchInputSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'searchInput');
|
|
21
|
+
const tableSizeControlSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'tableSizeControl');
|
|
22
|
+
const columnCustomFilterControlSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'columnCustomFilterControl');
|
|
23
|
+
const columnPinningControlSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'columnPinningControl');
|
|
24
|
+
const columnVisibilityControlSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'columnVisibilityControl');
|
|
25
|
+
const resetButtonSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'resetButton');
|
|
26
|
+
const exportButtonSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'exportButton');
|
|
17
27
|
const ToolbarSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'toolbar', material_1.Toolbar);
|
|
18
28
|
const TableSearchControlSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'searchInput', table_search_control_1.TableSearchControl);
|
|
19
29
|
const TableSizeControlSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'tableSizeControl', table_size_control_1.TableSizeControl);
|
|
@@ -22,5 +32,8 @@ function DataTableToolbar({ extraFilter = null, enableGlobalFilter = true, title
|
|
|
22
32
|
const ColumnVisibilityControlSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'columnVisibilityControl', column_visibility_control_1.ColumnVisibilityControl);
|
|
23
33
|
const ColumnResetControlSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'resetButton', column_reset_control_1.ColumnResetControl);
|
|
24
34
|
const TableExportControlSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'exportButton', table_export_control_1.TableExportControl);
|
|
25
|
-
|
|
35
|
+
const mergedToolbarProps = (0, slot_helpers_1.mergeSlotProps)({
|
|
36
|
+
table,
|
|
37
|
+
}, toolbarSlotProps, otherProps);
|
|
38
|
+
return ((0, jsx_runtime_1.jsx)(ToolbarSlot, Object.assign({}, mergedToolbarProps, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: Object.assign({ width: '100%' }, containerSx), children: [(title || subtitle) ? ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { mb: 2 }, children: [title ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", component: "div", sx: titleSx, children: title })) : null, subtitle ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", sx: subtitleSx, children: subtitle })) : null] })) : null, (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", spacing: 2, justifyContent: "space-between", alignItems: "center", children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", spacing: 0.5, alignItems: "center", sx: Object.assign({ flex: 1 }, leftSectionSx), children: [enableTableSizeControl ? ((0, jsx_runtime_1.jsx)(TableSizeControlSlot, Object.assign({}, (0, slot_helpers_1.mergeSlotProps)({}, tableSizeControlSlotProps, props.tableSizeControlProps || {})))) : null, enableColumnFilter ? ((0, jsx_runtime_1.jsx)(ColumnCustomFilterControlSlot, Object.assign({}, (0, slot_helpers_1.mergeSlotProps)({}, columnCustomFilterControlSlotProps, props.columnFilterProps || {})))) : null, enableColumnPinning ? ((0, jsx_runtime_1.jsx)(ColumnPinningControlSlot, Object.assign({}, (0, slot_helpers_1.mergeSlotProps)({}, columnPinningControlSlotProps, props.columnPinningProps || {})))) : null, enableColumnVisibility ? ((0, jsx_runtime_1.jsx)(ColumnVisibilityControlSlot, Object.assign({}, (0, slot_helpers_1.mergeSlotProps)({}, columnVisibilityControlSlotProps, props.columnVisibilityProps || {})))) : null, enableReset ? ((0, jsx_runtime_1.jsx)(ColumnResetControlSlot, Object.assign({}, (0, slot_helpers_1.mergeSlotProps)({}, resetButtonSlotProps, props.resetButtonProps || {})))) : null, enableExport ? ((0, jsx_runtime_1.jsx)(TableExportControlSlot, Object.assign({}, (0, slot_helpers_1.mergeSlotProps)({}, exportButtonSlotProps, props.exportButtonProps || {})))) : null, enableGlobalFilter ? ((0, jsx_runtime_1.jsx)(TableSearchControlSlot, Object.assign({}, (0, slot_helpers_1.mergeSlotProps)({}, searchInputSlotProps, props.searchInputProps || {})))) : null] }), (0, jsx_runtime_1.jsx)(material_1.Stack, { direction: "row", spacing: 1, alignItems: "center", sx: rightSectionSx, children: extraFilter })] })] }) })));
|
|
26
39
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IconButtonProps, SxProps } from '@mui/material';
|
|
1
2
|
import { TableFilters } from '../../types';
|
|
2
3
|
import { SelectionState } from '../../features';
|
|
3
4
|
interface TableExportControlProps {
|
|
@@ -20,6 +21,11 @@ interface TableExportControlProps {
|
|
|
20
21
|
message: string;
|
|
21
22
|
code: string;
|
|
22
23
|
}) => void;
|
|
24
|
+
iconButtonProps?: IconButtonProps;
|
|
25
|
+
tooltipProps?: any;
|
|
26
|
+
menuSx?: SxProps;
|
|
27
|
+
menuItemProps?: any;
|
|
28
|
+
[key: string]: any;
|
|
23
29
|
}
|
|
24
|
-
export declare function TableExportControl(
|
|
30
|
+
export declare function TableExportControl(props?: TableExportControlProps): import("react/jsx-runtime").JSX.Element;
|
|
25
31
|
export {};
|
|
@@ -8,97 +8,53 @@ const material_1 = require("@mui/material");
|
|
|
8
8
|
const menu_dropdown_1 = require("../droupdown/menu-dropdown");
|
|
9
9
|
const data_table_context_1 = require("../../contexts/data-table-context");
|
|
10
10
|
const icons_1 = require("../../icons");
|
|
11
|
-
const export_utils_1 = require("../../utils/export-utils");
|
|
12
11
|
const slot_helpers_1 = require("../../utils/slot-helpers");
|
|
13
|
-
function TableExportControl(
|
|
12
|
+
function TableExportControl(props = {}) {
|
|
13
|
+
const { exportFilename: propsExportFilename, onServerExport: propsOnServerExport, onExportProgress: propsOnExportProgress, onExportComplete: propsOnExportComplete, onExportError: propsOnExportError, iconButtonProps, tooltipProps, menuSx, menuItemProps } = props, otherProps = tslib_1.__rest(props, ["exportFilename", "onServerExport", "onExportProgress", "onExportComplete", "onExportError", "iconButtonProps", "tooltipProps", "menuSx", "menuItemProps"]);
|
|
14
14
|
const { table, apiRef, slots, slotProps, dataMode, isExporting, onCancelExport, exportFilename: contextExportFilename, onServerExport: contextOnServerExport, onExportProgress: contextOnExportProgress, onExportComplete: contextOnExportComplete, onExportError: contextOnExportError, } = (0, data_table_context_1.useDataTableContext)();
|
|
15
15
|
const exportFilename = propsExportFilename || contextExportFilename || 'export';
|
|
16
16
|
const onServerExport = propsOnServerExport || contextOnServerExport;
|
|
17
17
|
const onExportProgress = propsOnExportProgress || contextOnExportProgress;
|
|
18
18
|
const onExportComplete = propsOnExportComplete || contextOnExportComplete;
|
|
19
19
|
const onExportError = propsOnExportError || contextOnExportError;
|
|
20
|
+
const exportIconSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'exportIcon');
|
|
21
|
+
const csvIconSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'csvIcon');
|
|
22
|
+
const excelIconSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'excelIcon');
|
|
20
23
|
const ExportIconSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'exportIcon', icons_material_1.CloudDownloadOutlined);
|
|
21
24
|
const CsvIconSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'csvIcon', icons_1.CsvIcon);
|
|
22
25
|
const ExcelIconSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'excelIcon', icons_1.ExcelIcon);
|
|
23
26
|
const handleExport = (format) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
|
|
27
|
+
if (!(apiRef === null || apiRef === void 0 ? void 0 : apiRef.current))
|
|
28
|
+
return;
|
|
25
29
|
try {
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
const currentFilters = {
|
|
29
|
-
globalFilter: currentState.globalFilter,
|
|
30
|
-
sorting: currentState.sorting,
|
|
31
|
-
columnFilters: currentState.columnFilters,
|
|
32
|
-
};
|
|
33
|
-
const selectionData = (_b = (_a = apiRef === null || apiRef === void 0 ? void 0 : apiRef.current) === null || _a === void 0 ? void 0 : _a.selection) === null || _b === void 0 ? void 0 : _b.getSelectionState();
|
|
34
|
-
yield (0, export_utils_1.exportServerData)(table, {
|
|
35
|
-
format,
|
|
30
|
+
if (format === 'csv') {
|
|
31
|
+
yield apiRef.current.export.exportCSV({
|
|
36
32
|
filename: exportFilename,
|
|
37
|
-
fetchData: (filters, selection) => onServerExport(filters || currentFilters, selection),
|
|
38
|
-
currentFilters,
|
|
39
|
-
selection: selectionData,
|
|
40
|
-
onProgress: onExportProgress,
|
|
41
|
-
onComplete: onExportComplete,
|
|
42
|
-
onError: onExportError,
|
|
43
33
|
});
|
|
44
34
|
}
|
|
45
35
|
else {
|
|
46
|
-
yield
|
|
47
|
-
format,
|
|
36
|
+
yield apiRef.current.export.exportExcel({
|
|
48
37
|
filename: exportFilename,
|
|
49
|
-
onProgress: onExportProgress,
|
|
50
|
-
onComplete: onExportComplete,
|
|
51
|
-
onError: onExportError,
|
|
52
38
|
});
|
|
53
39
|
}
|
|
54
40
|
}
|
|
55
41
|
catch (error) {
|
|
56
42
|
console.error('Export failed:', error);
|
|
57
|
-
onExportError === null || onExportError === void 0 ? void 0 : onExportError({
|
|
58
|
-
message: error instanceof Error ? error.message : 'Export failed',
|
|
59
|
-
code: 'PROCESSING_ERROR',
|
|
60
|
-
});
|
|
61
43
|
}
|
|
62
44
|
});
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
totalColumns: exportableColumns.length,
|
|
77
|
-
hiddenColumns: hiddenFromExportColumns.length,
|
|
78
|
-
selectedRows: selectedRowCount,
|
|
79
|
-
hasSelection: hasSelection,
|
|
80
|
-
};
|
|
81
|
-
return ((0, jsx_runtime_1.jsx)(menu_dropdown_1.MenuDropdown, { anchor: ((0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: "Export data", children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "small", disabled: isExporting, sx: {
|
|
82
|
-
flexShrink: 0,
|
|
83
|
-
color: isExporting ? 'warning.main' : 'text.secondary',
|
|
84
|
-
}, children: (0, jsx_runtime_1.jsx)(ExportIconSlot, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.exportIcon)) }) })), children: ({ handleClose }) => ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
85
|
-
p: 1,
|
|
86
|
-
minWidth: 280,
|
|
87
|
-
}, children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
88
|
-
mb: 2,
|
|
89
|
-
p: 1,
|
|
90
|
-
bgcolor: 'grey.50',
|
|
91
|
-
borderRadius: 1,
|
|
92
|
-
}, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "subtitle2", gutterBottom: true, children: "Export Summary" }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body2", color: "text.secondary", children: [summary.hasSelection
|
|
93
|
-
? `${summary.selectedRows} selected • ${summary.totalColumns} exportable columns`
|
|
94
|
-
: `${summary.filteredRows} filtered • ${summary.totalColumns} exportable columns`, summary.hiddenColumns > 0 && ((0, jsx_runtime_1.jsxs)("span", { style: { color: 'orange' }, children: [' ', "\u2022 ", summary.hiddenColumns, " hidden from export"] }))] }), summary.hasSelection ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", color: "primary.main", sx: { fontWeight: 'medium' }, children: "Will export selected rows only" })) : null] }), isExporting ? ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, { onClick: () => {
|
|
95
|
-
onCancelExport === null || onCancelExport === void 0 ? void 0 : onCancelExport();
|
|
45
|
+
const mergedIconButtonProps = (0, slot_helpers_1.mergeSlotProps)({
|
|
46
|
+
size: 'small',
|
|
47
|
+
disabled: isExporting,
|
|
48
|
+
sx: { flexShrink: 0 },
|
|
49
|
+
}, exportIconSlotProps, iconButtonProps || {});
|
|
50
|
+
const mergedMenuItemProps = (0, slot_helpers_1.mergeSlotProps)({
|
|
51
|
+
sx: { minWidth: 150 },
|
|
52
|
+
}, menuItemProps || {});
|
|
53
|
+
return ((0, jsx_runtime_1.jsx)(menu_dropdown_1.MenuDropdown, { anchor: ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: isExporting ? 'Export in progress...' : 'Export data' }, tooltipProps, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({}, mergedIconButtonProps, { children: (0, jsx_runtime_1.jsx)(ExportIconSlot, Object.assign({}, exportIconSlotProps)) })) }))), children: ({ handleClose }) => ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: Object.assign({ minWidth: 200 }, menuSx), children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "subtitle2", sx: { p: 2, pb: 1 }, children: "Export Format" }), (0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ onClick: () => {
|
|
54
|
+
handleExport('csv');
|
|
55
|
+
handleClose();
|
|
56
|
+
}, disabled: isExporting }, mergedMenuItemProps, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(CsvIconSlot, Object.assign({}, csvIconSlotProps)) }), (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: "CSV", secondary: "Comma-separated values" })] })), (0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ onClick: () => {
|
|
57
|
+
handleExport('excel');
|
|
96
58
|
handleClose();
|
|
97
|
-
}, children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(
|
|
98
|
-
yield handleExport('csv');
|
|
99
|
-
handleClose();
|
|
100
|
-
}), disabled: isExporting, children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(CsvIconSlot, Object.assign({ fontSize: "small" }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.csvIcon)) }), (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: "Export as CSV", secondary: ".csv format" })] }), (0, jsx_runtime_1.jsxs)(material_1.MenuItem, { onClick: () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
101
|
-
yield handleExport('excel');
|
|
102
|
-
handleClose();
|
|
103
|
-
}), disabled: isExporting, children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(ExcelIconSlot, Object.assign({ fontSize: "small" }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.excelIcon)) }), (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: "Export as Excel", secondary: ".xlsx format" })] })] }))] })) }));
|
|
59
|
+
}, disabled: isExporting }, mergedMenuItemProps, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(ExcelIconSlot, Object.assign({}, excelIconSlotProps)) }), (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: "Excel", secondary: "Microsoft Excel format" })] })), isExporting && ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: { p: 2, pt: 1 }, children: (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", color: "text.secondary", sx: { display: 'block', textAlign: 'center' }, children: "Export in progress..." }) }))] })) }));
|
|
104
60
|
}
|
|
@@ -1 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { IconButtonProps, OutlinedInputProps, SxProps } from '@mui/material';
|
|
2
|
+
export interface TableSearchControlProps {
|
|
3
|
+
placeholder?: string;
|
|
4
|
+
autoFocus?: boolean;
|
|
5
|
+
searchIconProps?: IconButtonProps;
|
|
6
|
+
clearIconProps?: IconButtonProps;
|
|
7
|
+
inputProps?: OutlinedInputProps;
|
|
8
|
+
containerSx?: SxProps;
|
|
9
|
+
tooltipProps?: any;
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
}
|
|
12
|
+
export declare function TableSearchControl(props?: TableSearchControlProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,19 +4,17 @@ exports.TableSearchControl = TableSearchControl;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const icons_material_1 = require("@mui/icons-material");
|
|
6
6
|
const material_1 = require("@mui/material");
|
|
7
|
-
const material_2 = require("@mui/material");
|
|
8
|
-
const material_3 = require("@mui/material");
|
|
9
|
-
const material_4 = require("@mui/material");
|
|
10
|
-
const material_5 = require("@mui/material");
|
|
11
7
|
const react_1 = require("react");
|
|
12
8
|
const data_table_context_1 = require("../../contexts/data-table-context");
|
|
13
9
|
const slot_helpers_1 = require("../../utils/slot-helpers");
|
|
14
|
-
function TableSearchControl() {
|
|
10
|
+
function TableSearchControl(props = {}) {
|
|
15
11
|
const { table, slots, slotProps } = (0, data_table_context_1.useDataTableContext)();
|
|
16
12
|
const [searchVisible, setSearchVisible] = (0, react_1.useState)(false);
|
|
17
13
|
const searchInputRef = (0, react_1.useRef)(null);
|
|
18
14
|
const globalFilter = table.getState().globalFilter || '';
|
|
19
15
|
const hasSearch = globalFilter.length > 0;
|
|
16
|
+
const searchIconSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'searchIcon');
|
|
17
|
+
const clearIconSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'clearIcon');
|
|
20
18
|
const SearchIconSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'searchIcon', icons_material_1.Search);
|
|
21
19
|
const ClearIconSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'clearIcon', icons_material_1.Clear);
|
|
22
20
|
const handleChange = (0, react_1.useCallback)((e) => {
|
|
@@ -52,10 +50,25 @@ function TableSearchControl() {
|
|
|
52
50
|
}
|
|
53
51
|
return undefined;
|
|
54
52
|
}, [searchVisible]);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
const mergedSearchIconProps = (0, slot_helpers_1.mergeSlotProps)({
|
|
54
|
+
size: 'small',
|
|
55
|
+
onClick: handleSearchToggle,
|
|
56
|
+
color: hasSearch ? 'primary' : 'default',
|
|
57
|
+
sx: { flexShrink: 0 },
|
|
58
|
+
}, searchIconSlotProps, props.searchIconProps || {});
|
|
59
|
+
const mergedClearIconProps = (0, slot_helpers_1.mergeSlotProps)({
|
|
60
|
+
size: 'small',
|
|
61
|
+
onClick: handleSearchClear,
|
|
62
|
+
}, clearIconSlotProps, props.clearIconProps || {});
|
|
63
|
+
const mergedInputProps = (0, slot_helpers_1.mergeSlotProps)({
|
|
64
|
+
inputRef: searchInputRef,
|
|
65
|
+
size: 'small',
|
|
66
|
+
placeholder: props.placeholder || 'Search...',
|
|
67
|
+
value: globalFilter,
|
|
68
|
+
onChange: handleChange,
|
|
69
|
+
onBlur: handleSearchBlur,
|
|
70
|
+
autoFocus: props.autoFocus,
|
|
71
|
+
sx: { minWidth: 200 },
|
|
72
|
+
}, props.inputProps || {});
|
|
73
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: Object.assign({ display: 'flex', alignItems: 'center' }, props.containerSx), children: [!(searchVisible || hasSearch) && ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: "Search" }, props.tooltipProps, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({}, mergedSearchIconProps, { children: (0, jsx_runtime_1.jsx)(SearchIconSlot, Object.assign({}, searchIconSlotProps)) })) }))), (0, jsx_runtime_1.jsx)(material_1.Collapse, { in: searchVisible || hasSearch, orientation: "horizontal", timeout: 200, children: (0, jsx_runtime_1.jsx)(material_1.OutlinedInput, Object.assign({}, mergedInputProps, { endAdornment: hasSearch ? ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, { position: "end", children: (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({}, mergedClearIconProps, { children: (0, jsx_runtime_1.jsx)(ClearIconSlot, Object.assign({}, clearIconSlotProps)) })) })) : null })) })] }));
|
|
61
74
|
}
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { IconButtonProps, SxProps } from '@mui/material';
|
|
2
|
+
export interface TableSizeControlProps {
|
|
3
|
+
iconButtonProps?: IconButtonProps;
|
|
4
|
+
menuProps?: any;
|
|
5
|
+
tooltipProps?: any;
|
|
6
|
+
containerSx?: SxProps;
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}
|
|
9
|
+
export declare function TableSizeControl(props?: TableSizeControlProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -8,8 +8,11 @@ const menu_dropdown_1 = require("../droupdown/menu-dropdown");
|
|
|
8
8
|
const data_table_context_1 = require("../../contexts/data-table-context");
|
|
9
9
|
const icons_1 = require("../../icons");
|
|
10
10
|
const slot_helpers_1 = require("../../utils/slot-helpers");
|
|
11
|
-
function TableSizeControl() {
|
|
11
|
+
function TableSizeControl(props = {}) {
|
|
12
12
|
const { tableSize, onTableSizeChange, slotProps, slots } = (0, data_table_context_1.useDataTableContext)();
|
|
13
|
+
const tableSizeIconSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'tableSizeIcon');
|
|
14
|
+
const tableSizeSmallIconSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'tableSizeSmallIcon');
|
|
15
|
+
const tableSizeMediumIconSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'tableSizeMediumIcon');
|
|
13
16
|
const TableSizeIconSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'tableSizeIcon', icons_material_1.LineWeightOutlined);
|
|
14
17
|
const TableSizeSmallIconSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'tableSizeSmallIcon', icons_1.ViewCompactIcon);
|
|
15
18
|
const TableSizeMediumIconSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'tableSizeMediumIcon', icons_1.ViewComfortableIcon);
|
|
@@ -18,19 +21,24 @@ function TableSizeControl() {
|
|
|
18
21
|
value: 'small',
|
|
19
22
|
label: 'Compact',
|
|
20
23
|
description: 'Small padding, compact rows',
|
|
21
|
-
icon: (0, jsx_runtime_1.jsx)(TableSizeSmallIconSlot, Object.assign({},
|
|
24
|
+
icon: (0, jsx_runtime_1.jsx)(TableSizeSmallIconSlot, Object.assign({}, tableSizeSmallIconSlotProps)),
|
|
22
25
|
},
|
|
23
26
|
{
|
|
24
27
|
value: 'medium',
|
|
25
28
|
label: 'Standard',
|
|
26
29
|
description: 'Default padding and spacing',
|
|
27
|
-
icon: (0, jsx_runtime_1.jsx)(TableSizeMediumIconSlot, Object.assign({},
|
|
30
|
+
icon: (0, jsx_runtime_1.jsx)(TableSizeMediumIconSlot, Object.assign({}, tableSizeMediumIconSlotProps)),
|
|
28
31
|
},
|
|
29
32
|
];
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
const mergedIconButtonProps = (0, slot_helpers_1.mergeSlotProps)({
|
|
34
|
+
size: 'small',
|
|
35
|
+
sx: { flexShrink: 0 },
|
|
36
|
+
}, tableSizeIconSlotProps, props.iconButtonProps || {});
|
|
37
|
+
return ((0, jsx_runtime_1.jsx)(menu_dropdown_1.MenuDropdown, { anchor: ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: "Table size" }, props.tooltipProps, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({}, mergedIconButtonProps, { children: (0, jsx_runtime_1.jsx)(TableSizeIconSlot, Object.assign({}, tableSizeIconSlotProps)) })) }))), children: SIZE_OPTIONS.map((option) => ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, { selected: tableSize === option.value, onClick: () => onTableSizeChange(option.value), sx: Object.assign({ minWidth: 200 }, props.containerSx), children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { sx: { minWidth: 36 }, children: option.icon }), (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: option.label, secondary: option.description, primaryTypographyProps: {
|
|
38
|
+
variant: 'body2',
|
|
39
|
+
fontWeight: tableSize === option.value ? 600 : 400,
|
|
40
|
+
}, secondaryTypographyProps: {
|
|
41
|
+
variant: 'caption',
|
|
42
|
+
color: 'text.secondary',
|
|
43
|
+
} })] }, option.value))) }));
|
|
36
44
|
}
|
|
@@ -4,3 +4,5 @@ export { AdvancedFeaturesExample } from './advanced-features-example';
|
|
|
4
4
|
export { SimpleLocalExample } from './simple-local-example';
|
|
5
5
|
export { BulkActionsTest } from './bulk-actions-test';
|
|
6
6
|
export { ServerSideFetchingExample } from './server-side-fetching-example';
|
|
7
|
+
export { SimpleEnhancedSlotsExample } from './simple-slots-example';
|
|
8
|
+
export { ServerSideTest } from './server-side-test';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ServerSideFetchingExample = exports.BulkActionsTest = exports.SimpleLocalExample = exports.AdvancedFeaturesExample = exports.SelectionTestExample = exports.CustomColumnFilterExample = void 0;
|
|
3
|
+
exports.ServerSideTest = exports.SimpleEnhancedSlotsExample = exports.ServerSideFetchingExample = exports.BulkActionsTest = exports.SimpleLocalExample = exports.AdvancedFeaturesExample = exports.SelectionTestExample = exports.CustomColumnFilterExample = void 0;
|
|
4
4
|
var custom_column_filter_example_1 = require("./custom-column-filter-example");
|
|
5
5
|
Object.defineProperty(exports, "CustomColumnFilterExample", { enumerable: true, get: function () { return custom_column_filter_example_1.CustomColumnFilterExample; } });
|
|
6
6
|
var selection_test_example_1 = require("./selection-test-example");
|
|
@@ -13,3 +13,7 @@ var bulk_actions_test_1 = require("./bulk-actions-test");
|
|
|
13
13
|
Object.defineProperty(exports, "BulkActionsTest", { enumerable: true, get: function () { return bulk_actions_test_1.BulkActionsTest; } });
|
|
14
14
|
var server_side_fetching_example_1 = require("./server-side-fetching-example");
|
|
15
15
|
Object.defineProperty(exports, "ServerSideFetchingExample", { enumerable: true, get: function () { return server_side_fetching_example_1.ServerSideFetchingExample; } });
|
|
16
|
+
var simple_slots_example_1 = require("./simple-slots-example");
|
|
17
|
+
Object.defineProperty(exports, "SimpleEnhancedSlotsExample", { enumerable: true, get: function () { return simple_slots_example_1.SimpleEnhancedSlotsExample; } });
|
|
18
|
+
var server_side_test_1 = require("./server-side-test");
|
|
19
|
+
Object.defineProperty(exports, "ServerSideTest", { enumerable: true, get: function () { return server_side_test_1.ServerSideTest; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function SimpleEnhancedSlotsExample(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SimpleEnhancedSlotsExample = SimpleEnhancedSlotsExample;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const material_1 = require("@mui/material");
|
|
6
|
+
const icons_material_1 = require("@mui/icons-material");
|
|
7
|
+
const data_table_1 = require("../components/table/data-table");
|
|
8
|
+
const sampleData = [
|
|
9
|
+
{ id: 1, name: 'John Doe', email: 'john@example.com', status: 'active' },
|
|
10
|
+
{ id: 2, name: 'Jane Smith', email: 'jane@example.com', status: 'active' },
|
|
11
|
+
{ id: 3, name: 'Bob Johnson', email: 'bob@example.com', status: 'inactive' },
|
|
12
|
+
];
|
|
13
|
+
const columns = [
|
|
14
|
+
{ id: 'name', accessorKey: 'name', header: 'Name' },
|
|
15
|
+
{ id: 'email', accessorKey: 'email', header: 'Email' },
|
|
16
|
+
{
|
|
17
|
+
id: 'status',
|
|
18
|
+
accessorKey: 'status',
|
|
19
|
+
header: 'Status',
|
|
20
|
+
cell: ({ getValue }) => ((0, jsx_runtime_1.jsx)(material_1.Chip, { label: getValue(), color: getValue() === 'active' ? 'success' : 'default', size: "small" }))
|
|
21
|
+
},
|
|
22
|
+
];
|
|
23
|
+
const CustomSearchIcon = (props) => ((0, jsx_runtime_1.jsx)(icons_material_1.Star, Object.assign({}, props, { sx: Object.assign({ color: 'warning.main' }, props.sx) })));
|
|
24
|
+
const CustomFilterIcon = (props) => ((0, jsx_runtime_1.jsx)(icons_material_1.Favorite, Object.assign({}, props, { sx: Object.assign({ color: 'error.main' }, props.sx) })));
|
|
25
|
+
function SimpleEnhancedSlotsExample() {
|
|
26
|
+
const theme = (0, material_1.useTheme)();
|
|
27
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { p: 3 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h4", gutterBottom: true, children: "Enhanced Slots System" }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body1", paragraph: true, children: "This example demonstrates the key improvements in the enhanced slot system:" }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { mb: 3 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", gutterBottom: true, children: "Key Improvements:" }), (0, jsx_runtime_1.jsxs)("ul", { children: [(0, jsx_runtime_1.jsxs)("li", { children: [(0, jsx_runtime_1.jsx)("strong", { children: "Better Prop Merging:" }), " Special handling for sx, style, and className props"] }), (0, jsx_runtime_1.jsxs)("li", { children: [(0, jsx_runtime_1.jsx)("strong", { children: "Full Customization:" }), " Override any component without limitations"] }), (0, jsx_runtime_1.jsxs)("li", { children: [(0, jsx_runtime_1.jsx)("strong", { children: "Enhanced Type Safety:" }), " Better TypeScript support with proper typing"] }), (0, jsx_runtime_1.jsxs)("li", { children: [(0, jsx_runtime_1.jsx)("strong", { children: "Flexible Props:" }), " Pass any props to slot components"] }), (0, jsx_runtime_1.jsxs)("li", { children: [(0, jsx_runtime_1.jsx)("strong", { children: "Priority System:" }), " User props override slot props override defaults"] })] })] }), (0, jsx_runtime_1.jsx)(data_table_1.DataTable, { data: sampleData, columns: columns, enableGlobalFilter: true, enableColumnVisibility: true, enableColumnFilter: true, slots: {
|
|
28
|
+
searchIcon: CustomSearchIcon,
|
|
29
|
+
filterIcon: CustomFilterIcon,
|
|
30
|
+
}, slotProps: {
|
|
31
|
+
searchIcon: {
|
|
32
|
+
fontSize: 'large',
|
|
33
|
+
sx: {
|
|
34
|
+
animation: 'pulse 2s infinite',
|
|
35
|
+
'@keyframes pulse': {
|
|
36
|
+
'0%': { transform: 'scale(1)' },
|
|
37
|
+
'50%': { transform: 'scale(1.1)' },
|
|
38
|
+
'100%': { transform: 'scale(1)' },
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
filterIcon: {
|
|
43
|
+
fontSize: 'medium',
|
|
44
|
+
sx: {
|
|
45
|
+
transform: 'rotate(0deg)',
|
|
46
|
+
transition: 'transform 0.3s ease',
|
|
47
|
+
'&:hover': {
|
|
48
|
+
transform: 'rotate(180deg)',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
tableContainer: {
|
|
53
|
+
sx: {
|
|
54
|
+
maxHeight: '400px',
|
|
55
|
+
'&::-webkit-scrollbar': {
|
|
56
|
+
width: '8px',
|
|
57
|
+
},
|
|
58
|
+
'&::-webkit-scrollbar-track': {
|
|
59
|
+
backgroundColor: (0, material_1.alpha)(theme.palette.grey[300], 0.5),
|
|
60
|
+
borderRadius: '4px',
|
|
61
|
+
},
|
|
62
|
+
'&::-webkit-scrollbar-thumb': {
|
|
63
|
+
backgroundColor: theme.palette.primary.main,
|
|
64
|
+
borderRadius: '4px',
|
|
65
|
+
'&:hover': {
|
|
66
|
+
backgroundColor: theme.palette.primary.dark,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
toolbar: {
|
|
72
|
+
sx: {
|
|
73
|
+
background: `linear-gradient(135deg, ${(0, material_1.alpha)(theme.palette.primary.main, 0.1)} 0%, ${(0, material_1.alpha)(theme.palette.secondary.main, 0.1)} 100%)`,
|
|
74
|
+
border: `1px solid ${(0, material_1.alpha)(theme.palette.primary.main, 0.2)}`,
|
|
75
|
+
borderRadius: 2,
|
|
76
|
+
padding: 2,
|
|
77
|
+
margin: '0 0 16px 0',
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
} }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { mt: 4 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", gutterBottom: true, children: "Enhanced Slot Helper Functions:" }), (0, jsx_runtime_1.jsx)(material_1.Box, { component: "pre", sx: {
|
|
81
|
+
backgroundColor: 'grey.100',
|
|
82
|
+
p: 2,
|
|
83
|
+
borderRadius: 1,
|
|
84
|
+
fontSize: '0.875rem',
|
|
85
|
+
overflow: 'auto',
|
|
86
|
+
}, children: `// Enhanced prop merging with special handling
|
|
87
|
+
export function mergeSlotProps(
|
|
88
|
+
defaultProps = {},
|
|
89
|
+
slotProps = {},
|
|
90
|
+
userProps = {}
|
|
91
|
+
) {
|
|
92
|
+
// Handles sx, style, and className merging
|
|
93
|
+
// User props have highest priority
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Enhanced slot component retrieval
|
|
97
|
+
export function getSlotComponentWithProps(
|
|
98
|
+
slots,
|
|
99
|
+
slotProps,
|
|
100
|
+
slotName,
|
|
101
|
+
fallback,
|
|
102
|
+
defaultProps = {}
|
|
103
|
+
) {
|
|
104
|
+
return {
|
|
105
|
+
component: getSlotComponent(slots, slotName, fallback),
|
|
106
|
+
props: mergeSlotProps(defaultProps, slotProps[slotName], {})
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Usage in components:
|
|
111
|
+
const { component: IconSlot, props: iconProps } =
|
|
112
|
+
getSlotComponentWithProps(slots, slotProps, 'searchIcon', DefaultIcon);
|
|
113
|
+
|
|
114
|
+
return <IconSlot {...iconProps} />;` })] })] }));
|
|
115
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColumnPinningState, SortingState, ColumnOrderState, TableState, Row } from '@tanstack/react-table';
|
|
1
|
+
import { ColumnPinningState, SortingState, ColumnOrderState, TableState, Row, Table } from '@tanstack/react-table';
|
|
2
2
|
import { ColumnFilterState } from './table.types';
|
|
3
3
|
import { SelectionState } from '../features';
|
|
4
4
|
export interface DataTableApi<T = any> {
|
|
@@ -10,6 +10,9 @@ export interface DataTableApi<T = any> {
|
|
|
10
10
|
hideAllColumns: () => void;
|
|
11
11
|
resetColumnVisibility: () => void;
|
|
12
12
|
};
|
|
13
|
+
table: {
|
|
14
|
+
getTable: () => Table<T>;
|
|
15
|
+
};
|
|
13
16
|
columnOrdering: {
|
|
14
17
|
setColumnOrder: (columnOrder: ColumnOrderState) => void;
|
|
15
18
|
moveColumn: (columnId: string, toIndex: number) => void;
|