@ackplus/react-tanstack-data-table 1.0.19-beta-0.7 → 1.0.19-beta-0.8
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 +599 -0
- package/package.json +1 -1
- package/src/index.d.ts +19 -0
- package/src/index.js +31 -0
- package/src/lib/components/droupdown/menu-dropdown.d.ts +17 -0
- package/src/lib/components/droupdown/menu-dropdown.js +52 -0
- package/src/lib/components/filters/filter-value-input.d.ts +9 -0
- package/src/lib/components/filters/filter-value-input.js +58 -0
- package/src/lib/components/filters/index.d.ts +23 -0
- package/src/lib/components/filters/index.js +129 -0
- package/src/lib/components/headers/draggable-header.d.ts +12 -0
- package/src/lib/components/headers/draggable-header.js +212 -0
- package/src/lib/components/headers/index.d.ts +2 -0
- package/src/lib/components/headers/index.js +5 -0
- package/src/lib/components/headers/table-header.d.ts +10 -0
- package/src/lib/components/headers/table-header.js +48 -0
- package/src/lib/components/index.d.ts +7 -0
- package/src/lib/components/index.js +10 -0
- package/src/lib/components/pagination/data-table-pagination.d.ts +11 -0
- package/src/lib/components/pagination/data-table-pagination.js +25 -0
- package/src/lib/components/pagination/index.d.ts +1 -0
- package/src/lib/components/pagination/index.js +4 -0
- package/src/lib/components/rows/data-table-row.d.ts +13 -0
- package/src/lib/components/rows/data-table-row.js +31 -0
- package/src/lib/components/rows/empty-data-row.d.ts +6 -0
- package/src/lib/components/rows/empty-data-row.js +11 -0
- package/src/lib/components/rows/index.d.ts +3 -0
- package/src/lib/components/rows/index.js +6 -0
- package/src/lib/components/rows/loading-rows.d.ts +5 -0
- package/src/lib/components/rows/loading-rows.js +49 -0
- package/src/lib/components/table/data-table.d.ts +3 -0
- package/src/lib/components/table/data-table.js +492 -0
- package/src/lib/components/table/data-table.types.d.ts +114 -0
- package/src/lib/components/table/data-table.types.js +2 -0
- package/src/lib/components/table/index.d.ts +2 -0
- package/src/lib/components/table/index.js +5 -0
- package/src/lib/components/toolbar/bulk-actions-toolbar.d.ts +9 -0
- package/src/lib/components/toolbar/bulk-actions-toolbar.js +25 -0
- package/src/lib/components/toolbar/column-custom-filter-control.d.ts +1 -0
- package/src/lib/components/toolbar/column-custom-filter-control.js +137 -0
- package/src/lib/components/toolbar/column-pinning-control.d.ts +1 -0
- package/src/lib/components/toolbar/column-pinning-control.js +105 -0
- package/src/lib/components/toolbar/column-reset-control.d.ts +1 -0
- package/src/lib/components/toolbar/column-reset-control.js +16 -0
- package/src/lib/components/toolbar/column-visibility-control.d.ts +1 -0
- package/src/lib/components/toolbar/column-visibility-control.js +31 -0
- package/src/lib/components/toolbar/data-table-toolbar.d.ts +14 -0
- package/src/lib/components/toolbar/data-table-toolbar.js +26 -0
- package/src/lib/components/toolbar/index.d.ts +8 -0
- package/src/lib/components/toolbar/index.js +17 -0
- package/src/lib/components/toolbar/table-export-control.d.ts +25 -0
- package/src/lib/components/toolbar/table-export-control.js +93 -0
- package/src/lib/components/toolbar/table-search-control.d.ts +1 -0
- package/src/lib/components/toolbar/table-search-control.js +61 -0
- package/src/lib/components/toolbar/table-size-control.d.ts +1 -0
- package/src/lib/components/toolbar/table-size-control.js +36 -0
- package/src/lib/contexts/data-table-context.d.ts +43 -0
- package/src/lib/contexts/data-table-context.js +54 -0
- package/src/lib/examples/advanced-features-example.d.ts +1 -0
- package/src/lib/examples/advanced-features-example.js +264 -0
- package/src/lib/examples/bulk-actions-test.d.ts +1 -0
- package/src/lib/examples/bulk-actions-test.js +44 -0
- package/src/lib/examples/custom-column-filter-example.d.ts +1 -0
- package/src/lib/examples/custom-column-filter-example.js +60 -0
- package/src/lib/examples/index.d.ts +5 -0
- package/src/lib/examples/index.js +13 -0
- package/src/lib/examples/selection-test-example.d.ts +1 -0
- package/src/lib/examples/selection-test-example.js +101 -0
- package/src/lib/examples/simple-local-example.d.ts +1 -0
- package/src/lib/examples/simple-local-example.js +97 -0
- package/src/lib/features/custom-column-filter.feature.d.ts +45 -0
- package/src/lib/features/custom-column-filter.feature.js +247 -0
- package/src/lib/features/custom-selection.feature.d.ts +46 -0
- package/src/lib/features/custom-selection.feature.js +172 -0
- package/src/lib/features/index.d.ts +2 -0
- package/src/lib/features/index.js +8 -0
- package/src/lib/hooks/index.d.ts +1 -0
- package/src/lib/hooks/index.js +4 -0
- package/src/lib/hooks/use-data-table-api.d.ts +56 -0
- package/src/lib/hooks/use-data-table-api.js +616 -0
- package/src/lib/icons/add-icon.d.ts +2 -0
- package/src/lib/icons/add-icon.js +8 -0
- package/src/lib/icons/csv-icon.d.ts +2 -0
- package/src/lib/icons/csv-icon.js +8 -0
- package/src/lib/icons/delete-icon.d.ts +2 -0
- package/src/lib/icons/delete-icon.js +8 -0
- package/src/lib/icons/excel-icon.d.ts +2 -0
- package/src/lib/icons/excel-icon.js +8 -0
- package/src/lib/icons/index.d.ts +7 -0
- package/src/lib/icons/index.js +17 -0
- package/src/lib/icons/unpin-icon.d.ts +2 -0
- package/src/lib/icons/unpin-icon.js +8 -0
- package/src/lib/icons/view-comfortable-icon.d.ts +2 -0
- package/src/lib/icons/view-comfortable-icon.js +8 -0
- package/src/lib/icons/view-compact-icon.d.ts +2 -0
- package/src/lib/icons/view-compact-icon.js +8 -0
- package/src/lib/types/column.types.d.ts +29 -0
- package/src/lib/types/column.types.js +5 -0
- package/src/lib/types/data-table-api.d.ts +134 -0
- package/src/lib/types/data-table-api.js +2 -0
- package/src/lib/types/export.types.d.ts +99 -0
- package/src/lib/types/export.types.js +2 -0
- package/src/lib/types/index.d.ts +6 -0
- package/src/lib/types/index.js +8 -0
- package/src/lib/types/slots.types.d.ts +272 -0
- package/src/lib/types/slots.types.js +2 -0
- package/src/lib/types/table.types.d.ts +63 -0
- package/src/lib/types/table.types.js +2 -0
- package/src/lib/utils/column-helpers.d.ts +7 -0
- package/src/lib/utils/column-helpers.js +43 -0
- package/src/lib/utils/debounced-fetch.utils.d.ts +11 -0
- package/src/lib/utils/debounced-fetch.utils.js +49 -0
- package/src/lib/utils/export-utils.d.ts +30 -0
- package/src/lib/utils/export-utils.js +152 -0
- package/src/lib/utils/index.d.ts +7 -0
- package/src/lib/utils/index.js +10 -0
- package/src/lib/utils/slot-helpers.d.ts +9 -0
- package/src/lib/utils/slot-helpers.js +21 -0
- package/src/lib/utils/special-columns.utils.d.ts +6 -0
- package/src/lib/utils/special-columns.utils.js +52 -0
- package/src/lib/utils/styling-helpers.d.ts +36 -0
- package/src/lib/utils/styling-helpers.js +61 -0
- package/src/lib/utils/table-helpers.d.ts +9 -0
- package/src/lib/utils/table-helpers.js +57 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { Row, SortingState, ColumnResizeMode, ColumnPinningState, RowData } from '@tanstack/react-table';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import type { CustomColumnFilterState, TableFilters, TableState } from '../../types';
|
|
4
|
+
import { DataTableColumn } from '../../types';
|
|
5
|
+
import { DataTableSlots, PartialSlotProps } from '../../types/slots.types';
|
|
6
|
+
import { DataTableSize } from '../../utils/table-helpers';
|
|
7
|
+
import { SelectionState } from '../../features/custom-selection.feature';
|
|
8
|
+
export type SelectMode = 'page' | 'all';
|
|
9
|
+
declare module '@tanstack/table-core' {
|
|
10
|
+
interface ColumnMeta<TData extends RowData, TValue> {
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export interface DataTableProps<T> {
|
|
14
|
+
columns: DataTableColumn<T>[];
|
|
15
|
+
data?: T[];
|
|
16
|
+
totalRow?: number;
|
|
17
|
+
idKey?: keyof T;
|
|
18
|
+
extraFilter?: ReactNode | null;
|
|
19
|
+
footerFilter?: ReactNode | null;
|
|
20
|
+
dataMode?: 'client' | 'server';
|
|
21
|
+
initialState?: Partial<TableState>;
|
|
22
|
+
initialLoadData?: boolean;
|
|
23
|
+
onDataStateChange?: (filters: Partial<TableState>) => void;
|
|
24
|
+
onFetchData?: (filters: Partial<TableFilters>) => Promise<{
|
|
25
|
+
data: T[];
|
|
26
|
+
total: number;
|
|
27
|
+
}>;
|
|
28
|
+
exportFilename?: string;
|
|
29
|
+
onExportProgress?: (progress: {
|
|
30
|
+
processedRows: number;
|
|
31
|
+
totalRows: number;
|
|
32
|
+
percentage: number;
|
|
33
|
+
}) => void;
|
|
34
|
+
onExportComplete?: (result: {
|
|
35
|
+
success: boolean;
|
|
36
|
+
filename: string;
|
|
37
|
+
totalRows: number;
|
|
38
|
+
}) => void;
|
|
39
|
+
onExportError?: (error: {
|
|
40
|
+
message: string;
|
|
41
|
+
code: string;
|
|
42
|
+
}) => void;
|
|
43
|
+
onServerExport?: (filters?: Partial<TableState>, selection?: SelectionState) => Promise<{
|
|
44
|
+
data: any[];
|
|
45
|
+
total: number;
|
|
46
|
+
}>;
|
|
47
|
+
onExportCancel?: () => void;
|
|
48
|
+
enableRowSelection?: boolean | ((row: Row<T>) => boolean);
|
|
49
|
+
enableMultiRowSelection?: boolean;
|
|
50
|
+
selectMode?: SelectMode;
|
|
51
|
+
isRowSelectable?: (params: {
|
|
52
|
+
row: T;
|
|
53
|
+
id: string;
|
|
54
|
+
}) => boolean;
|
|
55
|
+
onRowSelectionChange?: (selectedRows: T[], selection?: SelectionState) => void;
|
|
56
|
+
onSelectionChange?: (selection: SelectionState) => void;
|
|
57
|
+
enableBulkActions?: boolean;
|
|
58
|
+
bulkActions?: (selectionState: SelectionState) => ReactNode;
|
|
59
|
+
enableColumnResizing?: boolean;
|
|
60
|
+
columnResizeMode?: ColumnResizeMode;
|
|
61
|
+
enableColumnDragging?: boolean;
|
|
62
|
+
onColumnDragEnd?: (columnOrder: string[]) => void;
|
|
63
|
+
enableColumnPinning?: boolean;
|
|
64
|
+
onColumnPinningChange?: (pinning: ColumnPinningState) => void;
|
|
65
|
+
enableExpanding?: boolean;
|
|
66
|
+
getRowCanExpand?: (row: Row<T>) => boolean;
|
|
67
|
+
renderSubComponent?: (row: Row<T>) => ReactNode;
|
|
68
|
+
enablePagination?: boolean;
|
|
69
|
+
paginationMode?: 'client' | 'server';
|
|
70
|
+
enableGlobalFilter?: boolean;
|
|
71
|
+
enableColumnFilter?: boolean;
|
|
72
|
+
filterMode?: 'client' | 'server';
|
|
73
|
+
enableSorting?: boolean;
|
|
74
|
+
sortingMode?: 'client' | 'server';
|
|
75
|
+
onSortingChange?: (sorting: SortingState) => void;
|
|
76
|
+
enableHover?: boolean;
|
|
77
|
+
enableStripes?: boolean;
|
|
78
|
+
tableContainerProps?: any;
|
|
79
|
+
tableProps?: any;
|
|
80
|
+
fitToScreen?: boolean;
|
|
81
|
+
tableSize?: DataTableSize;
|
|
82
|
+
enableStickyHeaderOrFooter?: boolean;
|
|
83
|
+
maxHeight?: string | number;
|
|
84
|
+
enableVirtualization?: boolean;
|
|
85
|
+
estimateRowHeight?: number;
|
|
86
|
+
enableColumnVisibility?: boolean;
|
|
87
|
+
enableTableSizeControl?: boolean;
|
|
88
|
+
enableExport?: boolean;
|
|
89
|
+
enableReset?: boolean;
|
|
90
|
+
loading?: boolean;
|
|
91
|
+
emptyMessage?: string;
|
|
92
|
+
skeletonRows?: number;
|
|
93
|
+
onColumnFiltersChange?: (filterState: CustomColumnFilterState) => void;
|
|
94
|
+
onDataChange?: (data: T[]) => void;
|
|
95
|
+
selectionColumn?: {
|
|
96
|
+
width?: number;
|
|
97
|
+
pinLeft?: boolean;
|
|
98
|
+
customColumn?: DataTableColumn<any>;
|
|
99
|
+
id?: string;
|
|
100
|
+
};
|
|
101
|
+
actionColumn?: {
|
|
102
|
+
pinRight?: boolean;
|
|
103
|
+
customColumn?: DataTableColumn<any>;
|
|
104
|
+
id?: string;
|
|
105
|
+
};
|
|
106
|
+
expandingColumn?: {
|
|
107
|
+
width?: number;
|
|
108
|
+
pinLeft?: boolean;
|
|
109
|
+
customColumn?: DataTableColumn<any>;
|
|
110
|
+
id?: string;
|
|
111
|
+
};
|
|
112
|
+
slots?: Partial<DataTableSlots<T>>;
|
|
113
|
+
slotProps?: PartialSlotProps<T>;
|
|
114
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { SelectionState } from '../../features/custom-selection.feature';
|
|
3
|
+
export interface BulkActionsToolbarProps<T = any> {
|
|
4
|
+
selectionState: SelectionState;
|
|
5
|
+
selectedRowCount: number;
|
|
6
|
+
bulkActions?: (selectionState: SelectionState) => ReactNode;
|
|
7
|
+
sx?: any;
|
|
8
|
+
}
|
|
9
|
+
export declare function BulkActionsToolbar<T = any>({ selectionState, selectedRowCount, bulkActions, sx, }: BulkActionsToolbarProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BulkActionsToolbar = BulkActionsToolbar;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const material_1 = require("@mui/material");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const data_table_context_1 = require("../../contexts/data-table-context");
|
|
8
|
+
const slot_helpers_1 = require("../../utils/slot-helpers");
|
|
9
|
+
function BulkActionsToolbar({ selectionState, selectedRowCount, bulkActions, sx, }) {
|
|
10
|
+
const { slots, slotProps } = (0, data_table_context_1.useDataTableContext)();
|
|
11
|
+
const ToolbarSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'toolbar', material_1.Toolbar);
|
|
12
|
+
const renderedBulkActions = (0, react_1.useMemo)(() => {
|
|
13
|
+
if (!bulkActions)
|
|
14
|
+
return null;
|
|
15
|
+
return bulkActions(selectionState);
|
|
16
|
+
}, [bulkActions, selectionState]);
|
|
17
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Fade, { in: selectedRowCount > 0, children: (0, jsx_runtime_1.jsxs)(ToolbarSlot, Object.assign({ sx: Object.assign({ pl: { sm: 2 }, pr: {
|
|
18
|
+
xs: 1,
|
|
19
|
+
sm: 1,
|
|
20
|
+
}, bgcolor: (theme) => (0, material_1.alpha)(theme.palette.primary.main, 0.05), mb: 1, position: 'relative', zIndex: 1 }, sx) }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.bulkActionsToolbar, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, { sx: { flex: '1 1 100%' }, children: (0, jsx_runtime_1.jsx)(material_1.Typography, { color: "inherit", variant: "subtitle1", component: "div", children: (0, jsx_runtime_1.jsx)(material_1.Chip, { label: `${selectedRowCount} selected`, size: "small", color: "primary", variant: "outlined" }) }) }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
21
|
+
display: 'flex',
|
|
22
|
+
alignItems: 'center',
|
|
23
|
+
gap: 1,
|
|
24
|
+
}, children: renderedBulkActions })] })) }));
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ColumnCustomFilterControl(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ColumnCustomFilterControl = ColumnCustomFilterControl;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const icons_material_1 = require("@mui/icons-material");
|
|
6
|
+
const material_1 = require("@mui/material");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const menu_dropdown_1 = require("../droupdown/menu-dropdown");
|
|
9
|
+
const data_table_context_1 = require("../../contexts/data-table-context");
|
|
10
|
+
const icons_1 = require("../../icons");
|
|
11
|
+
const column_helpers_1 = require("../../utils/column-helpers");
|
|
12
|
+
const slot_helpers_1 = require("../../utils/slot-helpers");
|
|
13
|
+
const filters_1 = require("../filters");
|
|
14
|
+
const filter_value_input_1 = require("../filters/filter-value-input");
|
|
15
|
+
function ColumnCustomFilterControl() {
|
|
16
|
+
var _a, _b, _c;
|
|
17
|
+
const { table, slots, slotProps } = (0, data_table_context_1.useDataTableContext)();
|
|
18
|
+
const FilterIconSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'filterIcon', icons_material_1.FilterList);
|
|
19
|
+
const customFilterState = ((_a = table.getCustomColumnFilterState) === null || _a === void 0 ? void 0 : _a.call(table)) || {
|
|
20
|
+
filters: [],
|
|
21
|
+
logic: 'AND',
|
|
22
|
+
pendingFilters: [],
|
|
23
|
+
pendingLogic: 'AND'
|
|
24
|
+
};
|
|
25
|
+
const filters = customFilterState.pendingFilters;
|
|
26
|
+
const filterLogic = customFilterState.pendingLogic;
|
|
27
|
+
const activeFiltersCount = ((_c = (_b = table.getActiveColumnFilters) === null || _b === void 0 ? void 0 : _b.call(table)) === null || _c === void 0 ? void 0 : _c.length) || 0;
|
|
28
|
+
const filterableColumns = (0, react_1.useMemo)(() => {
|
|
29
|
+
return table.getAllLeafColumns()
|
|
30
|
+
.filter(column => (0, column_helpers_1.isColumnFilterable)(column));
|
|
31
|
+
}, [table]);
|
|
32
|
+
const addFilter = (0, react_1.useCallback)((columnId, operator) => {
|
|
33
|
+
var _a, _b;
|
|
34
|
+
let defaultOperator = operator || '';
|
|
35
|
+
if (columnId && !operator) {
|
|
36
|
+
const column = filterableColumns.find(col => col.id === columnId);
|
|
37
|
+
const columnType = (0, column_helpers_1.getColumnType)(column);
|
|
38
|
+
const operators = filters_1.FILTER_OPERATORS[columnType] || filters_1.FILTER_OPERATORS.text;
|
|
39
|
+
defaultOperator = ((_a = operators[0]) === null || _a === void 0 ? void 0 : _a.value) || 'contains';
|
|
40
|
+
}
|
|
41
|
+
(_b = table.addPendingColumnFilter) === null || _b === void 0 ? void 0 : _b.call(table, columnId || '', defaultOperator, '');
|
|
42
|
+
}, [table, filterableColumns]);
|
|
43
|
+
const handleAddFilter = (0, react_1.useCallback)(() => {
|
|
44
|
+
addFilter();
|
|
45
|
+
}, [addFilter]);
|
|
46
|
+
const updateFilter = (0, react_1.useCallback)((filterId, updates) => {
|
|
47
|
+
var _a;
|
|
48
|
+
(_a = table.updatePendingColumnFilter) === null || _a === void 0 ? void 0 : _a.call(table, filterId, updates);
|
|
49
|
+
}, [table]);
|
|
50
|
+
const removeFilter = (0, react_1.useCallback)((filterId) => {
|
|
51
|
+
var _a;
|
|
52
|
+
(_a = table.removePendingColumnFilter) === null || _a === void 0 ? void 0 : _a.call(table, filterId);
|
|
53
|
+
}, [table]);
|
|
54
|
+
const clearAllFilters = (0, react_1.useCallback)((closeDialog) => {
|
|
55
|
+
var _a;
|
|
56
|
+
(_a = table.clearAllPendingColumnFilters) === null || _a === void 0 ? void 0 : _a.call(table);
|
|
57
|
+
setTimeout(() => {
|
|
58
|
+
var _a;
|
|
59
|
+
(_a = table.applyPendingColumnFilters) === null || _a === void 0 ? void 0 : _a.call(table);
|
|
60
|
+
if (closeDialog) {
|
|
61
|
+
closeDialog();
|
|
62
|
+
}
|
|
63
|
+
}, 0);
|
|
64
|
+
}, [table]);
|
|
65
|
+
const handleLogicChange = (0, react_1.useCallback)((newLogic) => {
|
|
66
|
+
var _a;
|
|
67
|
+
(_a = table.setPendingFilterLogic) === null || _a === void 0 ? void 0 : _a.call(table, newLogic);
|
|
68
|
+
}, [table]);
|
|
69
|
+
const applyFilters = (0, react_1.useCallback)(() => {
|
|
70
|
+
var _a;
|
|
71
|
+
(_a = table.applyPendingColumnFilters) === null || _a === void 0 ? void 0 : _a.call(table);
|
|
72
|
+
}, [table]);
|
|
73
|
+
const handleApplyFilters = (0, react_1.useCallback)((closeDialog) => {
|
|
74
|
+
applyFilters();
|
|
75
|
+
closeDialog();
|
|
76
|
+
}, [applyFilters]);
|
|
77
|
+
const getOperatorsForColumn = (0, react_1.useCallback)((columnId) => {
|
|
78
|
+
const column = filterableColumns.find(col => col.id === columnId);
|
|
79
|
+
const type = (0, column_helpers_1.getColumnType)(column);
|
|
80
|
+
return filters_1.FILTER_OPERATORS[type] || filters_1.FILTER_OPERATORS.text;
|
|
81
|
+
}, [filterableColumns]);
|
|
82
|
+
const handleColumnChange = (0, react_1.useCallback)((filterId, newColumnId, currentFilter) => {
|
|
83
|
+
var _a;
|
|
84
|
+
const newColumn = filterableColumns.find(col => col.id === newColumnId);
|
|
85
|
+
const columnType = (0, column_helpers_1.getColumnType)(newColumn);
|
|
86
|
+
const operators = filters_1.FILTER_OPERATORS[columnType] || filters_1.FILTER_OPERATORS.text;
|
|
87
|
+
const currentOperatorValid = operators.some(op => op.value === currentFilter.operator);
|
|
88
|
+
const newOperator = currentOperatorValid ? currentFilter.operator : ((_a = operators[0]) === null || _a === void 0 ? void 0 : _a.value) || '';
|
|
89
|
+
updateFilter(filterId, {
|
|
90
|
+
columnId: newColumnId,
|
|
91
|
+
operator: newOperator,
|
|
92
|
+
value: ['isEmpty', 'isNotEmpty'].includes(newOperator) ? '' : currentFilter.value,
|
|
93
|
+
});
|
|
94
|
+
}, [filterableColumns, updateFilter]);
|
|
95
|
+
const handleOperatorChange = (0, react_1.useCallback)((filterId, newOperator, currentFilter) => {
|
|
96
|
+
updateFilter(filterId, {
|
|
97
|
+
operator: newOperator,
|
|
98
|
+
value: ['isEmpty', 'isNotEmpty'].includes(newOperator) ? '' : currentFilter.value,
|
|
99
|
+
});
|
|
100
|
+
}, [updateFilter]);
|
|
101
|
+
const handleFilterValueChange = (0, react_1.useCallback)((filterId, value) => {
|
|
102
|
+
updateFilter(filterId, { value });
|
|
103
|
+
}, [updateFilter]);
|
|
104
|
+
const handleRemoveFilter = (0, react_1.useCallback)((filterId) => {
|
|
105
|
+
removeFilter(filterId);
|
|
106
|
+
}, [removeFilter]);
|
|
107
|
+
const pendingFiltersCount = filters.filter(f => {
|
|
108
|
+
if (!f.columnId || !f.operator)
|
|
109
|
+
return false;
|
|
110
|
+
if (['isEmpty', 'isNotEmpty'].includes(f.operator))
|
|
111
|
+
return true;
|
|
112
|
+
return f.value && f.value.toString().trim() !== '';
|
|
113
|
+
}).length;
|
|
114
|
+
const hasAppliedFilters = activeFiltersCount > 0;
|
|
115
|
+
const hasPendingChanges = pendingFiltersCount > 0 || (filters.length === 0 && hasAppliedFilters);
|
|
116
|
+
(0, react_1.useEffect)(() => {
|
|
117
|
+
var _a;
|
|
118
|
+
if (filters.length === 0 && filterableColumns.length > 0 && activeFiltersCount === 0) {
|
|
119
|
+
const firstColumn = filterableColumns[0];
|
|
120
|
+
const columnType = (0, column_helpers_1.getColumnType)(firstColumn);
|
|
121
|
+
const operators = filters_1.FILTER_OPERATORS[columnType] || filters_1.FILTER_OPERATORS.text;
|
|
122
|
+
const defaultOperator = ((_a = operators[0]) === null || _a === void 0 ? void 0 : _a.value) || 'contains';
|
|
123
|
+
addFilter(firstColumn.id, defaultOperator);
|
|
124
|
+
}
|
|
125
|
+
}, [filters.length, filterableColumns, addFilter, activeFiltersCount]);
|
|
126
|
+
return ((0, jsx_runtime_1.jsx)(menu_dropdown_1.MenuDropdown, { anchor: ((0, jsx_runtime_1.jsx)(material_1.Badge, { variant: "dot", color: "primary", invisible: activeFiltersCount === 0, children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "small", color: activeFiltersCount > 0 ? 'primary' : 'default', sx: {
|
|
127
|
+
flexShrink: 0,
|
|
128
|
+
}, children: (0, jsx_runtime_1.jsx)(FilterIconSlot, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.filterIcon)) }) })), children: ({ handleClose }) => ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
129
|
+
p: 2,
|
|
130
|
+
minWidth: 500,
|
|
131
|
+
maxWidth: 650,
|
|
132
|
+
}, children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 2 }, children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", alignItems: "center", spacing: 1, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "subtitle1", sx: { fontWeight: 'bold' }, children: "Column Filters" }), activeFiltersCount > 0 && ((0, jsx_runtime_1.jsx)(material_1.Chip, { size: "small", label: `${activeFiltersCount} active`, color: "primary", variant: "outlined" }))] }), (0, jsx_runtime_1.jsx)(material_1.Stack, { direction: "row", spacing: 1, children: (0, jsx_runtime_1.jsx)(material_1.Button, { size: "small", variant: "outlined", startIcon: (0, jsx_runtime_1.jsx)(icons_1.AddIcon, {}), onClick: handleAddFilter, children: "Add Filter" }) })] }), filters.length > 1 && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { mb: 2 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", sx: { mb: 1 }, children: "Filter Logic:" }), (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", spacing: 1, children: [(0, jsx_runtime_1.jsx)(material_1.Button, { size: "small", variant: filterLogic === 'AND' ? 'contained' : 'outlined', onClick: () => handleLogicChange('AND'), children: "AND (All conditions)" }), (0, jsx_runtime_1.jsx)(material_1.Button, { size: "small", variant: filterLogic === 'OR' ? 'contained' : 'outlined', onClick: () => handleLogicChange('OR'), children: "OR (Any condition)" })] })] })), (0, jsx_runtime_1.jsx)(material_1.Divider, { sx: { mb: 2 } }), filters.length === 0 ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", sx: {
|
|
133
|
+
textAlign: 'center',
|
|
134
|
+
py: 2,
|
|
135
|
+
}, children: "No filters applied. Click \"Add Filter\" to start." })) : ((0, jsx_runtime_1.jsx)(material_1.Stack, { spacing: 2, children: filters.map((filter) => ((0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", spacing: 1, alignItems: "center", children: [(0, jsx_runtime_1.jsxs)(material_1.FormControl, { size: "small", sx: { minWidth: 140 }, children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { children: "Column" }), (0, jsx_runtime_1.jsx)(material_1.Select, { value: filter.columnId, label: "Column", onChange: (e) => handleColumnChange(filter.id, e.target.value, filter), children: filterableColumns.map(column => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: column.id, children: typeof column.columnDef.header === 'string' ? column.columnDef.header : column.id }, column.id))) })] }), (0, jsx_runtime_1.jsxs)(material_1.FormControl, { size: "small", sx: { minWidth: 160 }, disabled: !filter.columnId, children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { children: "Operator" }), (0, jsx_runtime_1.jsx)(material_1.Select, { value: filter.operator, label: "Operator", onChange: (e) => handleOperatorChange(filter.id, e.target.value, filter), children: getOperatorsForColumn(filter.columnId).map(op => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: op.value, children: op.label }, op.value))) })] }), !['isEmpty', 'isNotEmpty'].includes(filter.operator) ? ((0, jsx_runtime_1.jsx)(filter_value_input_1.FilterValueInput, { filter: filter, column: filterableColumns.find(col => col.id === filter.columnId), onValueChange: (value) => handleFilterValueChange(filter.id, value) })) : ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: { flex: 1 } })), (0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "small", onClick: () => handleRemoveFilter(filter.id), color: "error", children: (0, jsx_runtime_1.jsx)(icons_1.DeleteIcon, {}) })] }) }, filter.id))) })), (0, jsx_runtime_1.jsx)(material_1.Divider, { sx: { my: 2 } }), (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 1, children: [(hasAppliedFilters || filters.length > 0) && ((0, jsx_runtime_1.jsx)(material_1.Button, { size: "small", variant: "text", color: "warning", onClick: () => clearAllFilters(handleClose), startIcon: (0, jsx_runtime_1.jsx)(icons_1.DeleteIcon, {}), children: "Reset" })), !(hasAppliedFilters || filters.length > 0) && (0, jsx_runtime_1.jsx)(material_1.Box, {}), (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", spacing: 1, children: [(0, jsx_runtime_1.jsx)(material_1.Button, { variant: "outlined", onClick: handleClose, children: "Close" }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", onClick: () => handleApplyFilters(handleClose), disabled: !hasPendingChanges, children: pendingFiltersCount === 0 && hasAppliedFilters ? 'Clear All Filters' :
|
|
136
|
+
`Apply ${pendingFiltersCount} Filter${pendingFiltersCount !== 1 ? 's' : ''}${pendingFiltersCount > 1 ? ` (${filterLogic})` : ''}` })] })] })] })) }));
|
|
137
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ColumnPinningControl(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ColumnPinningControl = ColumnPinningControl;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const icons_material_1 = require("@mui/icons-material");
|
|
6
|
+
const material_1 = require("@mui/material");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const menu_dropdown_1 = require("../droupdown/menu-dropdown");
|
|
9
|
+
const data_table_context_1 = require("../../contexts/data-table-context");
|
|
10
|
+
const icons_1 = require("../../icons");
|
|
11
|
+
const slot_helpers_1 = require("../../utils/slot-helpers");
|
|
12
|
+
function ColumnPinningControl() {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
const { table, slots, slotProps } = (0, data_table_context_1.useDataTableContext)();
|
|
15
|
+
const PinIconSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'pinIcon', icons_material_1.PushPinOutlined);
|
|
16
|
+
const UnpinIconSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'unpinIcon', icons_1.UnpinIcon);
|
|
17
|
+
const LeftIconSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'leftIcon', icons_material_1.ArrowLeftOutlined);
|
|
18
|
+
const RightIconSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'rightIcon', icons_material_1.ArrowRightOutlined);
|
|
19
|
+
const columnPinning = table.getState().columnPinning;
|
|
20
|
+
const allColumns = (0, react_1.useMemo)(() => {
|
|
21
|
+
var _a, _b;
|
|
22
|
+
if ((_a = slotProps === null || slotProps === void 0 ? void 0 : slotProps.columnsPanel) === null || _a === void 0 ? void 0 : _a.getPinnableColumns) {
|
|
23
|
+
return (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.columnsPanel) === null || _b === void 0 ? void 0 : _b.getPinnableColumns(table.getAllLeafColumns());
|
|
24
|
+
}
|
|
25
|
+
return table.getAllLeafColumns().filter(column => column.getCanPin());
|
|
26
|
+
}, [slotProps === null || slotProps === void 0 ? void 0 : slotProps.columnsPanel, table]);
|
|
27
|
+
const handlePinColumn = (columnId, position) => {
|
|
28
|
+
const currentPinning = table.getState().columnPinning;
|
|
29
|
+
const newPinning = Object.assign({}, currentPinning);
|
|
30
|
+
newPinning.left = (newPinning.left || []).filter(id => id !== columnId);
|
|
31
|
+
newPinning.right = (newPinning.right || []).filter(id => id !== columnId);
|
|
32
|
+
if (position === 'left') {
|
|
33
|
+
newPinning.left = [...(newPinning.left || []), columnId];
|
|
34
|
+
}
|
|
35
|
+
else if (position === 'right') {
|
|
36
|
+
newPinning.right = [...(newPinning.right || []), columnId];
|
|
37
|
+
}
|
|
38
|
+
table.setColumnPinning(newPinning);
|
|
39
|
+
};
|
|
40
|
+
const getColumnPinStatus = (columnId) => {
|
|
41
|
+
var _a, _b;
|
|
42
|
+
if ((_a = columnPinning.left) === null || _a === void 0 ? void 0 : _a.includes(columnId))
|
|
43
|
+
return 'left';
|
|
44
|
+
if ((_b = columnPinning.right) === null || _b === void 0 ? void 0 : _b.includes(columnId))
|
|
45
|
+
return 'right';
|
|
46
|
+
return 'none';
|
|
47
|
+
};
|
|
48
|
+
const getColumnDisplayName = (column) => {
|
|
49
|
+
if (typeof column.columnDef.header === 'string') {
|
|
50
|
+
return column.columnDef.header;
|
|
51
|
+
}
|
|
52
|
+
return column.id;
|
|
53
|
+
};
|
|
54
|
+
const handleUnpinAll = (0, react_1.useCallback)(() => {
|
|
55
|
+
table.setColumnPinning(table.initialState.columnPinning || {});
|
|
56
|
+
}, [table]);
|
|
57
|
+
const userPinnedLeft = (((_a = columnPinning.left) === null || _a === void 0 ? void 0 : _a.filter((id) => allColumns.some((column) => column.id === id))) || []);
|
|
58
|
+
const userPinnedRight = (((_b = columnPinning.right) === null || _b === void 0 ? void 0 : _b.filter((id) => allColumns.some((column) => column.id === id))) || []);
|
|
59
|
+
const totalPinned = userPinnedLeft.length + userPinnedRight.length;
|
|
60
|
+
return ((0, jsx_runtime_1.jsx)(menu_dropdown_1.MenuDropdown, { anchor: ((0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: "Pin columns", children: (0, jsx_runtime_1.jsxs)(material_1.IconButton, { size: "small", sx: {
|
|
61
|
+
flexShrink: 0,
|
|
62
|
+
}, children: [(0, jsx_runtime_1.jsx)(PinIconSlot, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.pinIcon)), totalPinned > 0 && ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
63
|
+
position: 'absolute',
|
|
64
|
+
top: -2,
|
|
65
|
+
right: -2,
|
|
66
|
+
backgroundColor: 'primary.main',
|
|
67
|
+
color: 'white',
|
|
68
|
+
borderRadius: '50%',
|
|
69
|
+
width: 16,
|
|
70
|
+
height: 16,
|
|
71
|
+
fontSize: 10,
|
|
72
|
+
display: 'flex',
|
|
73
|
+
alignItems: 'center',
|
|
74
|
+
justifyContent: 'center',
|
|
75
|
+
}, children: totalPinned }))] }) })), children: ({ handleClose }) => ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
76
|
+
minWidth: 300,
|
|
77
|
+
maxHeight: 400,
|
|
78
|
+
overflow: 'auto',
|
|
79
|
+
}, children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
80
|
+
p: 2,
|
|
81
|
+
pb: 1,
|
|
82
|
+
}, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "subtitle2", sx: { mb: 1 }, children: "Pin Columns" }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", color: "text.secondary", children: "Pin columns to keep them visible while scrolling" })] }), (0, jsx_runtime_1.jsx)(material_1.Divider, {}), (0, jsx_runtime_1.jsx)(material_1.List, { dense: true, sx: { py: 0 }, children: allColumns.map((column) => {
|
|
83
|
+
const pinStatus = getColumnPinStatus(column.id);
|
|
84
|
+
const displayName = getColumnDisplayName(column);
|
|
85
|
+
return ((0, jsx_runtime_1.jsx)(material_1.ListItem, { sx: { py: 0.5 }, secondaryAction: ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
86
|
+
display: 'flex',
|
|
87
|
+
gap: 0.5,
|
|
88
|
+
}, children: [(0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: "Pin left", children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "small", onClick: () => handlePinColumn(column.id, pinStatus === 'left' ? 'none' : 'left'), color: pinStatus === 'left' ? 'primary' : 'default', children: (0, jsx_runtime_1.jsx)(LeftIconSlot, Object.assign({ fontSize: "small" }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.leftIcon)) }) }), (0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: "Pin right", children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "small", onClick: () => handlePinColumn(column.id, pinStatus === 'right' ? 'none' : 'right'), color: pinStatus === 'right' ? 'secondary' : 'default', children: (0, jsx_runtime_1.jsx)(RightIconSlot, Object.assign({ fontSize: "small" }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.rightIcon)) }) }), pinStatus !== 'none' && ((0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: "Unpin", children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "small", onClick: () => handlePinColumn(column.id, 'none'), children: (0, jsx_runtime_1.jsx)(UnpinIconSlot, Object.assign({ fontSize: "small" }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.unpinIcon)) }) }))] })), children: (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: displayName, secondary: pinStatus !== 'none' ? ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
89
|
+
display: 'flex',
|
|
90
|
+
alignItems: 'center',
|
|
91
|
+
gap: 0.5,
|
|
92
|
+
mt: 0.5,
|
|
93
|
+
}, children: [pinStatus === 'left' ? ((0, jsx_runtime_1.jsx)(LeftIconSlot, Object.assign({ fontSize: "small" }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.leftIcon))) : ((0, jsx_runtime_1.jsx)(RightIconSlot, Object.assign({ fontSize: "small" }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.rightIcon))), (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "caption", color: pinStatus === 'left' ? 'primary' : 'secondary', children: ["Pinned", ' ', pinStatus] })] })) : null }) }, column.id));
|
|
94
|
+
}) }), (0, jsx_runtime_1.jsx)(material_1.Divider, {}), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
95
|
+
p: 2,
|
|
96
|
+
pt: 1,
|
|
97
|
+
}, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
98
|
+
display: 'flex',
|
|
99
|
+
gap: 1,
|
|
100
|
+
justifyContent: 'space-between',
|
|
101
|
+
}, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", color: "text.secondary", children: "Quick actions:" }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
102
|
+
display: 'flex',
|
|
103
|
+
gap: 1,
|
|
104
|
+
}, children: (0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: "Unpin all user columns", children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "small", onClick: handleUnpinAll, disabled: totalPinned === 0, children: (0, jsx_runtime_1.jsx)(icons_1.UnpinIcon, { fontSize: "small" }) }) }) })] }) })] })) }));
|
|
105
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ColumnResetControl(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ColumnResetControl = ColumnResetControl;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const icons_material_1 = require("@mui/icons-material");
|
|
6
|
+
const material_1 = require("@mui/material");
|
|
7
|
+
const data_table_context_1 = require("../../contexts/data-table-context");
|
|
8
|
+
function ColumnResetControl() {
|
|
9
|
+
const { table } = (0, data_table_context_1.useDataTableContext)();
|
|
10
|
+
const handleResetLayout = () => {
|
|
11
|
+
table.resetColumnOrder();
|
|
12
|
+
table.resetColumnPinning();
|
|
13
|
+
table.resetColumnSizing();
|
|
14
|
+
};
|
|
15
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: "Reset layout", children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "small", onClick: handleResetLayout, children: (0, jsx_runtime_1.jsx)(icons_material_1.Autorenew, {}) }) }));
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ColumnVisibilityControl(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ColumnVisibilityControl = ColumnVisibilityControl;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const icons_material_1 = require("@mui/icons-material");
|
|
6
|
+
const material_1 = require("@mui/material");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const menu_dropdown_1 = require("../droupdown/menu-dropdown");
|
|
9
|
+
const data_table_context_1 = require("../../contexts/data-table-context");
|
|
10
|
+
const slot_helpers_1 = require("../../utils/slot-helpers");
|
|
11
|
+
function ColumnVisibilityControl() {
|
|
12
|
+
const { table, slots, slotProps } = (0, data_table_context_1.useDataTableContext)();
|
|
13
|
+
const ColumnIconSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'columnIcon', icons_material_1.ViewColumnOutlined);
|
|
14
|
+
const columns = (0, react_1.useMemo)(() => {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
if ((_a = slotProps === null || slotProps === void 0 ? void 0 : slotProps.columnsPanel) === null || _a === void 0 ? void 0 : _a.getTogglableColumns) {
|
|
17
|
+
return (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.columnsPanel) === null || _b === void 0 ? void 0 : _b.getTogglableColumns(table.getAllLeafColumns());
|
|
18
|
+
}
|
|
19
|
+
return table.getAllLeafColumns().filter(column => column.getCanHide());
|
|
20
|
+
}, [slotProps === null || slotProps === void 0 ? void 0 : slotProps.columnsPanel, table]);
|
|
21
|
+
const handleColumnVisibilityChange = ((columnId, visible) => {
|
|
22
|
+
var _a;
|
|
23
|
+
(_a = table.getColumn(columnId)) === null || _a === void 0 ? void 0 : _a.toggleVisibility(visible);
|
|
24
|
+
});
|
|
25
|
+
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, { size: "small", sx: {
|
|
26
|
+
flexShrink: 0,
|
|
27
|
+
}, children: (0, jsx_runtime_1.jsx)(ColumnIconSlot, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.columnIcon)) }) })), children: ({ handleClose }) => ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
28
|
+
p: 2,
|
|
29
|
+
minWidth: 200,
|
|
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))) })] })) }));
|
|
31
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface DataTableToolbarProps {
|
|
3
|
+
extraFilter?: ReactNode;
|
|
4
|
+
enableGlobalFilter?: boolean;
|
|
5
|
+
title?: string;
|
|
6
|
+
subtitle?: string;
|
|
7
|
+
enableColumnVisibility?: boolean;
|
|
8
|
+
enableExport?: boolean;
|
|
9
|
+
enableReset?: boolean;
|
|
10
|
+
enableColumnFilter?: boolean;
|
|
11
|
+
enableTableSizeControl?: boolean;
|
|
12
|
+
enableColumnPinning?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function DataTableToolbar({ extraFilter, enableGlobalFilter, title, subtitle, enableColumnVisibility, enableExport, enableReset, enableColumnFilter, enableTableSizeControl, enableColumnPinning, }: DataTableToolbarProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DataTableToolbar = DataTableToolbar;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const material_1 = require("@mui/material");
|
|
6
|
+
const column_custom_filter_control_1 = require("./column-custom-filter-control");
|
|
7
|
+
const column_pinning_control_1 = require("./column-pinning-control");
|
|
8
|
+
const column_reset_control_1 = require("./column-reset-control");
|
|
9
|
+
const column_visibility_control_1 = require("./column-visibility-control");
|
|
10
|
+
const table_export_control_1 = require("./table-export-control");
|
|
11
|
+
const table_search_control_1 = require("./table-search-control");
|
|
12
|
+
const table_size_control_1 = require("./table-size-control");
|
|
13
|
+
const data_table_context_1 = require("../../contexts/data-table-context");
|
|
14
|
+
const slot_helpers_1 = require("../../utils/slot-helpers");
|
|
15
|
+
function DataTableToolbar({ extraFilter = null, enableGlobalFilter = true, title, subtitle, enableColumnVisibility = true, enableExport = true, enableReset = true, enableColumnFilter = true, enableTableSizeControl = true, enableColumnPinning = true, }) {
|
|
16
|
+
const { table, slots, slotProps = {} } = (0, data_table_context_1.useDataTableContext)();
|
|
17
|
+
const ToolbarSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'toolbar', material_1.Toolbar);
|
|
18
|
+
const TableSearchControlSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'searchInput', table_search_control_1.TableSearchControl);
|
|
19
|
+
const TableSizeControlSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'tableSizeControl', table_size_control_1.TableSizeControl);
|
|
20
|
+
const ColumnCustomFilterControlSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'columnCustomFilterControl', column_custom_filter_control_1.ColumnCustomFilterControl);
|
|
21
|
+
const ColumnPinningControlSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'columnPinningControl', column_pinning_control_1.ColumnPinningControl);
|
|
22
|
+
const ColumnVisibilityControlSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'columnVisibilityControl', column_visibility_control_1.ColumnVisibilityControl);
|
|
23
|
+
const ColumnResetControlSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'resetButton', column_reset_control_1.ColumnResetControl);
|
|
24
|
+
const TableExportControlSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'exportButton', table_export_control_1.TableExportControl);
|
|
25
|
+
return ((0, jsx_runtime_1.jsx)(ToolbarSlot, Object.assign({ table: table }, slotProps.toolbar, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { width: '100%' }, 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", children: title })) : null, subtitle ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", 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: { flex: 1 }, children: [enableGlobalFilter ? (0, jsx_runtime_1.jsx)(TableSearchControlSlot, Object.assign({}, slotProps.searchInput)) : null, enableTableSizeControl ? (0, jsx_runtime_1.jsx)(TableSizeControlSlot, Object.assign({}, slotProps.tableSizeControl)) : null, enableColumnFilter ? (0, jsx_runtime_1.jsx)(ColumnCustomFilterControlSlot, Object.assign({}, slotProps.columnCustomFilterControl)) : null, enableColumnPinning ? (0, jsx_runtime_1.jsx)(ColumnPinningControlSlot, Object.assign({}, slotProps.columnPinningControl)) : null, enableColumnVisibility ? (0, jsx_runtime_1.jsx)(ColumnVisibilityControlSlot, Object.assign({}, slotProps.columnVisibilityControl)) : null, enableReset ? (0, jsx_runtime_1.jsx)(ColumnResetControlSlot, Object.assign({}, slotProps.resetButton)) : null, enableExport ? (0, jsx_runtime_1.jsx)(TableExportControlSlot, Object.assign({}, slotProps.exportButton)) : null] }), (0, jsx_runtime_1.jsx)(material_1.Stack, { direction: "row", spacing: 1, alignItems: "center", children: extraFilter })] })] }) })));
|
|
26
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { DataTableToolbar } from './data-table-toolbar';
|
|
2
|
+
export { ColumnVisibilityControl } from './column-visibility-control';
|
|
3
|
+
export { ColumnPinningControl } from './column-pinning-control';
|
|
4
|
+
export { ColumnResetControl } from './column-reset-control';
|
|
5
|
+
export { TableExportControl } from './table-export-control';
|
|
6
|
+
export { TableSizeControl } from './table-size-control';
|
|
7
|
+
export { BulkActionsToolbar } from './bulk-actions-toolbar';
|
|
8
|
+
export type { BulkActionsToolbarProps } from './bulk-actions-toolbar';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BulkActionsToolbar = exports.TableSizeControl = exports.TableExportControl = exports.ColumnResetControl = exports.ColumnPinningControl = exports.ColumnVisibilityControl = exports.DataTableToolbar = void 0;
|
|
4
|
+
var data_table_toolbar_1 = require("./data-table-toolbar");
|
|
5
|
+
Object.defineProperty(exports, "DataTableToolbar", { enumerable: true, get: function () { return data_table_toolbar_1.DataTableToolbar; } });
|
|
6
|
+
var column_visibility_control_1 = require("./column-visibility-control");
|
|
7
|
+
Object.defineProperty(exports, "ColumnVisibilityControl", { enumerable: true, get: function () { return column_visibility_control_1.ColumnVisibilityControl; } });
|
|
8
|
+
var column_pinning_control_1 = require("./column-pinning-control");
|
|
9
|
+
Object.defineProperty(exports, "ColumnPinningControl", { enumerable: true, get: function () { return column_pinning_control_1.ColumnPinningControl; } });
|
|
10
|
+
var column_reset_control_1 = require("./column-reset-control");
|
|
11
|
+
Object.defineProperty(exports, "ColumnResetControl", { enumerable: true, get: function () { return column_reset_control_1.ColumnResetControl; } });
|
|
12
|
+
var table_export_control_1 = require("./table-export-control");
|
|
13
|
+
Object.defineProperty(exports, "TableExportControl", { enumerable: true, get: function () { return table_export_control_1.TableExportControl; } });
|
|
14
|
+
var table_size_control_1 = require("./table-size-control");
|
|
15
|
+
Object.defineProperty(exports, "TableSizeControl", { enumerable: true, get: function () { return table_size_control_1.TableSizeControl; } });
|
|
16
|
+
var bulk_actions_toolbar_1 = require("./bulk-actions-toolbar");
|
|
17
|
+
Object.defineProperty(exports, "BulkActionsToolbar", { enumerable: true, get: function () { return bulk_actions_toolbar_1.BulkActionsToolbar; } });
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { TableFilters } from '../../types';
|
|
2
|
+
import { SelectionState } from '../../features/custom-selection.feature';
|
|
3
|
+
interface TableExportControlProps {
|
|
4
|
+
exportFilename?: string;
|
|
5
|
+
onServerExport?: (filters?: Partial<TableFilters>, selection?: SelectionState) => Promise<{
|
|
6
|
+
data: any[];
|
|
7
|
+
total: number;
|
|
8
|
+
}>;
|
|
9
|
+
onExportProgress?: (progress: {
|
|
10
|
+
processedRows: number;
|
|
11
|
+
totalRows: number;
|
|
12
|
+
percentage: number;
|
|
13
|
+
}) => void;
|
|
14
|
+
onExportComplete?: (result: {
|
|
15
|
+
success: boolean;
|
|
16
|
+
filename: string;
|
|
17
|
+
totalRows: number;
|
|
18
|
+
}) => void;
|
|
19
|
+
onExportError?: (error: {
|
|
20
|
+
message: string;
|
|
21
|
+
code: string;
|
|
22
|
+
}) => void;
|
|
23
|
+
}
|
|
24
|
+
export declare function TableExportControl({ exportFilename: propsExportFilename, onServerExport: propsOnServerExport, onExportProgress: propsOnExportProgress, onExportComplete: propsOnExportComplete, onExportError: propsOnExportError, }?: TableExportControlProps): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export {};
|