@ackplus/react-tanstack-data-table 1.0.19-beta-0.15 → 1.0.19-beta-0.16
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/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 +18 -23
- 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/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
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -14,7 +14,4 @@ export * from './lib/hooks';
|
|
|
14
14
|
export * from './lib/types';
|
|
15
15
|
export type { Column, ColumnDef, Row, Table, Header, Cell, SortingState, ColumnFiltersState, VisibilityState, ColumnOrderState, ColumnPinningState, PaginationState, } from '@tanstack/react-table';
|
|
16
16
|
export * from './lib/features';
|
|
17
|
-
export
|
|
18
|
-
export { CustomColumnFilterExample } from './lib/examples/custom-column-filter-example';
|
|
19
|
-
export { SimpleLocalExample } from './lib/examples/simple-local-example';
|
|
20
|
-
export { AdvancedFeaturesExample } from './lib/examples/advanced-features-example';
|
|
17
|
+
export * from './lib/examples';
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.DataTableToolbar = exports.BulkActionsToolbar = exports.TableSizeControl = exports.TableExportControl = exports.ColumnResetControl = exports.ColumnPinningControl = exports.ColumnVisibilityControl = exports.DataTable = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
var table_1 = require("./lib/components/table");
|
|
6
6
|
Object.defineProperty(exports, "DataTable", { enumerable: true, get: function () { return table_1.DataTable; } });
|
|
@@ -23,11 +23,4 @@ tslib_1.__exportStar(require("./lib/utils/table-helpers"), exports);
|
|
|
23
23
|
tslib_1.__exportStar(require("./lib/hooks"), exports);
|
|
24
24
|
tslib_1.__exportStar(require("./lib/types"), exports);
|
|
25
25
|
tslib_1.__exportStar(require("./lib/features"), exports);
|
|
26
|
-
|
|
27
|
-
Object.defineProperty(exports, "ServerSideTest", { enumerable: true, get: function () { return server_side_test_1.ServerSideTest; } });
|
|
28
|
-
var custom_column_filter_example_1 = require("./lib/examples/custom-column-filter-example");
|
|
29
|
-
Object.defineProperty(exports, "CustomColumnFilterExample", { enumerable: true, get: function () { return custom_column_filter_example_1.CustomColumnFilterExample; } });
|
|
30
|
-
var simple_local_example_1 = require("./lib/examples/simple-local-example");
|
|
31
|
-
Object.defineProperty(exports, "SimpleLocalExample", { enumerable: true, get: function () { return simple_local_example_1.SimpleLocalExample; } });
|
|
32
|
-
var advanced_features_example_1 = require("./lib/examples/advanced-features-example");
|
|
33
|
-
Object.defineProperty(exports, "AdvancedFeaturesExample", { enumerable: true, get: function () { return advanced_features_example_1.AdvancedFeaturesExample; } });
|
|
26
|
+
tslib_1.__exportStar(require("./lib/examples"), exports);
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
import { FormControlProps, TextFieldProps, SelectProps, SxProps } from '@mui/material';
|
|
1
2
|
import { Column } from '@tanstack/react-table';
|
|
2
3
|
import { ColumnFilterRule } from '../../features';
|
|
3
4
|
interface FilterValueInputProps<T> {
|
|
4
5
|
filter: ColumnFilterRule;
|
|
5
6
|
column: Column<T, any>;
|
|
6
7
|
onValueChange: (value: any) => void;
|
|
8
|
+
formControlProps?: FormControlProps;
|
|
9
|
+
textFieldProps?: TextFieldProps;
|
|
10
|
+
selectProps?: SelectProps;
|
|
11
|
+
datePickerProps?: any;
|
|
12
|
+
containerSx?: SxProps;
|
|
13
|
+
[key: string]: any;
|
|
7
14
|
}
|
|
8
|
-
export declare function FilterValueInput<T>(
|
|
15
|
+
export declare function FilterValueInput<T>(props: FilterValueInputProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
9
16
|
export {};
|
|
@@ -9,50 +9,33 @@ const moment_1 = tslib_1.__importDefault(require("moment"));
|
|
|
9
9
|
const column_helpers_1 = require("../../utils/column-helpers");
|
|
10
10
|
const AdapterMoment_1 = require("@mui/x-date-pickers/AdapterMoment");
|
|
11
11
|
const x_date_pickers_1 = require("@mui/x-date-pickers");
|
|
12
|
-
function FilterValueInput(
|
|
12
|
+
function FilterValueInput(props) {
|
|
13
|
+
const { filter, column, onValueChange, formControlProps, textFieldProps, selectProps, datePickerProps, containerSx } = props, otherProps = tslib_1.__rest(props, ["filter", "column", "onValueChange", "formControlProps", "textFieldProps", "selectProps", "datePickerProps", "containerSx"]);
|
|
13
14
|
const columnType = (0, column_helpers_1.getColumnType)(column);
|
|
14
15
|
const customComponent = (0, column_helpers_1.getCustomFilterComponent)(column);
|
|
15
16
|
const options = (0, column_helpers_1.getColumnOptions)(column);
|
|
16
17
|
const operator = filter.operator;
|
|
17
18
|
if (customComponent) {
|
|
18
19
|
const CustomComponent = customComponent;
|
|
19
|
-
return ((0, jsx_runtime_1.jsx)(CustomComponent, { value: filter.value, onChange: onValueChange, filter: filter, column: column }));
|
|
20
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: containerSx, children: (0, jsx_runtime_1.jsx)(CustomComponent, Object.assign({ value: filter.value, onChange: onValueChange, filter: filter, column: column }, otherProps)) }));
|
|
20
21
|
}
|
|
21
22
|
if (columnType === 'boolean') {
|
|
22
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.FormControl, { size: "small", sx: {
|
|
23
|
-
flex: 1,
|
|
24
|
-
minWidth: 120,
|
|
25
|
-
}, children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { children: "Value" }), (0, jsx_runtime_1.jsxs)(material_1.Select, { value: filter.value || 'any', label: "Value", onChange: (e) => onValueChange(e.target.value), children: [(0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: 'any', children: "Any" }, 'any'), (0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: 'true', children: "True" }, 'true'), (0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: 'false', children: "False" }, 'false')] })] }));
|
|
23
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.FormControl, Object.assign({ size: "small", sx: Object.assign({ flex: 1, minWidth: 120 }, containerSx) }, formControlProps, { children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { children: "Value" }), (0, jsx_runtime_1.jsxs)(material_1.Select, Object.assign({ value: filter.value || 'any', label: "Value", onChange: (e) => onValueChange(e.target.value) }, selectProps, { children: [(0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: 'any', children: "Any" }, 'any'), (0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: 'true', children: "True" }, 'true'), (0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: 'false', children: "False" }, 'false')] }))] })));
|
|
26
24
|
}
|
|
27
|
-
if (
|
|
28
|
-
if (operator === 'in'
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return opt ? opt.label : val;
|
|
32
|
-
}).join(', '), children: options.map(option => ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, { value: option.value, children: [(0, jsx_runtime_1.jsx)(material_1.Checkbox, { checked: Array.isArray(filter.value) && filter.value.indexOf(option.value) > -1 }), (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: option.label })] }, String(option.value)))) })] }));
|
|
25
|
+
if (options && options.length > 0) {
|
|
26
|
+
if (operator === 'in') {
|
|
27
|
+
const currentValue = Array.isArray(filter.value) ? filter.value : [];
|
|
28
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.FormControl, Object.assign({ size: "small", sx: Object.assign({ flex: 1, minWidth: 120 }, containerSx) }, formControlProps, { children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { children: "Values" }), (0, jsx_runtime_1.jsx)(material_1.Select, Object.assign({ multiple: true, value: currentValue, label: "Values", onChange: (e) => onValueChange(e.target.value), renderValue: (selected) => selected.join(', ') }, selectProps, { children: options.map(option => ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, { value: option.value, children: [(0, jsx_runtime_1.jsx)(material_1.Checkbox, { checked: currentValue.includes(option.value) }), (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: option.label })] }, String(option.value)))) }))] })));
|
|
33
29
|
}
|
|
34
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.FormControl, { size: "small", sx: { flex: 1, minWidth: 120 }, children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { children: "Value" }), (0, jsx_runtime_1.jsx)(material_1.Select, { value: filter.value, label: "Value", onChange: (e) => onValueChange(e.target.value), children: options.map(option => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: option.value, children: option.label }, String(option.value)))) })] }));
|
|
30
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.FormControl, Object.assign({ size: "small", sx: Object.assign({ flex: 1, minWidth: 120 }, containerSx) }, formControlProps, { children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { children: "Value" }), (0, jsx_runtime_1.jsx)(material_1.Select, Object.assign({ value: filter.value, label: "Value", onChange: (e) => onValueChange(e.target.value) }, selectProps, { children: options.map(option => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: option.value, children: option.label }, String(option.value)))) }))] })));
|
|
35
31
|
}
|
|
36
32
|
if (columnType === 'date') {
|
|
37
|
-
return ((0, jsx_runtime_1.jsx)(x_date_pickers_1.LocalizationProvider, { dateAdapter: AdapterMoment_1.AdapterMoment, children: (0, jsx_runtime_1.jsx)(DatePicker_1.DatePicker, { value: filter.value ? (0, moment_1.default)(filter.value) : null, onChange: (e) => onValueChange(e === null || e === void 0 ? void 0 : e.toDate()), slotProps: {
|
|
38
|
-
textField: {
|
|
39
|
-
|
|
40
|
-
label: 'Value',
|
|
41
|
-
sx: {
|
|
42
|
-
flex: 1,
|
|
43
|
-
minWidth: 120,
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
} }) }));
|
|
33
|
+
return ((0, jsx_runtime_1.jsx)(x_date_pickers_1.LocalizationProvider, { dateAdapter: AdapterMoment_1.AdapterMoment, children: (0, jsx_runtime_1.jsx)(DatePicker_1.DatePicker, Object.assign({ value: filter.value ? (0, moment_1.default)(filter.value) : null, onChange: (e) => onValueChange(e === null || e === void 0 ? void 0 : e.toDate()), slotProps: {
|
|
34
|
+
textField: Object.assign({ size: 'small', label: 'Value', sx: Object.assign({ flex: 1, minWidth: 120 }, containerSx) }, textFieldProps),
|
|
35
|
+
} }, datePickerProps)) }));
|
|
47
36
|
}
|
|
48
37
|
if (columnType === 'number') {
|
|
49
|
-
return ((0, jsx_runtime_1.jsx)(material_1.TextField, { size: "small", label: "Value", value: filter.value, onChange: (e) => onValueChange(e.target.value), type: "number", sx: {
|
|
50
|
-
flex: 1,
|
|
51
|
-
minWidth: 120,
|
|
52
|
-
} }));
|
|
38
|
+
return ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({ size: "small", label: "Value", value: filter.value, onChange: (e) => onValueChange(e.target.value), type: "number", sx: Object.assign({ flex: 1, minWidth: 120 }, containerSx) }, textFieldProps)));
|
|
53
39
|
}
|
|
54
|
-
return ((0, jsx_runtime_1.jsx)(material_1.TextField, { size: "small", label: "Value", value: filter.value, onChange: (e) => onValueChange(e.target.value), sx: {
|
|
55
|
-
flex: 1,
|
|
56
|
-
minWidth: 120,
|
|
57
|
-
} }));
|
|
40
|
+
return ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({ size: "small", label: "Value", value: filter.value, onChange: (e) => onValueChange(e.target.value), sx: Object.assign({ flex: 1, minWidth: 120 }, containerSx) }, textFieldProps)));
|
|
58
41
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SxProps } from '@mui/material';
|
|
1
2
|
import { Header } from '@tanstack/react-table';
|
|
2
3
|
import React from 'react';
|
|
3
4
|
interface DraggableHeaderProps<T> {
|
|
@@ -5,9 +6,12 @@ interface DraggableHeaderProps<T> {
|
|
|
5
6
|
enableSorting?: boolean;
|
|
6
7
|
draggable?: boolean;
|
|
7
8
|
onColumnReorder?: (draggedColumnId: string, targetColumnId: string) => void;
|
|
9
|
+
containerSx?: SxProps;
|
|
10
|
+
sortIconProps?: any;
|
|
11
|
+
alignment?: 'left' | 'center' | 'right';
|
|
8
12
|
slots?: Record<string, any>;
|
|
9
13
|
slotProps?: Record<string, any>;
|
|
10
|
-
|
|
14
|
+
[key: string]: any;
|
|
11
15
|
}
|
|
12
|
-
export declare function DraggableHeader<T>(
|
|
16
|
+
export declare function DraggableHeader<T>(props: DraggableHeaderProps<T>): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode>> | import("react/jsx-runtime").JSX.Element;
|
|
13
17
|
export {};
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DraggableHeader = DraggableHeader;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
6
|
const icons_material_1 = require("@mui/icons-material");
|
|
6
7
|
const material_1 = require("@mui/material");
|
|
7
8
|
const react_table_1 = require("@tanstack/react-table");
|
|
8
9
|
const react_1 = require("react");
|
|
9
10
|
const slot_helpers_1 = require("../../utils/slot-helpers");
|
|
10
|
-
function DraggableHeader(
|
|
11
|
+
function DraggableHeader(props) {
|
|
12
|
+
const { header, enableSorting = true, draggable = false, onColumnReorder, containerSx, sortIconProps, alignment, slots, slotProps } = props, otherProps = tslib_1.__rest(props, ["header", "enableSorting", "draggable", "onColumnReorder", "containerSx", "sortIconProps", "alignment", "slots", "slotProps"]);
|
|
11
13
|
const [isDragging, setIsDragging] = (0, react_1.useState)(false);
|
|
12
14
|
const [dragOver, setDragOver] = (0, react_1.useState)(false);
|
|
13
15
|
const autoScrollIntervalRef = (0, react_1.useRef)(null);
|
|
14
16
|
const dragStartPositionRef = (0, react_1.useRef)(null);
|
|
15
17
|
const headerElementRef = (0, react_1.useRef)(null);
|
|
18
|
+
const sortIconAscSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'sortIconAsc');
|
|
19
|
+
const sortIconDescSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'sortIconDesc');
|
|
16
20
|
const SortIconAscSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'sortIconAsc', icons_material_1.ArrowUpwardOutlined);
|
|
17
21
|
const SortIconDescSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'sortIconDesc', icons_material_1.ArrowDownwardOutlined);
|
|
18
22
|
const AUTO_SCROLL_THRESHOLD = 50;
|
|
@@ -86,56 +90,46 @@ function DraggableHeader({ header, enableSorting = true, draggable = false, onCo
|
|
|
86
90
|
}, []);
|
|
87
91
|
const checkAutoScroll = (0, react_1.useCallback)((clientX) => {
|
|
88
92
|
const container = findScrollableContainer();
|
|
89
|
-
if (!container)
|
|
93
|
+
if (!container)
|
|
90
94
|
return;
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
stopAutoScroll();
|
|
96
|
-
if (distanceFromLeft < AUTO_SCROLL_THRESHOLD && container.scrollLeft > 0) {
|
|
95
|
+
const containerRect = container.getBoundingClientRect();
|
|
96
|
+
const leftEdge = containerRect.left + AUTO_SCROLL_THRESHOLD;
|
|
97
|
+
const rightEdge = containerRect.right - AUTO_SCROLL_THRESHOLD;
|
|
98
|
+
if (clientX < leftEdge) {
|
|
97
99
|
startAutoScroll('left');
|
|
98
100
|
}
|
|
99
|
-
else if (
|
|
100
|
-
container.scrollLeft < container.scrollWidth - container.clientWidth) {
|
|
101
|
+
else if (clientX > rightEdge) {
|
|
101
102
|
startAutoScroll('right');
|
|
102
103
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
]);
|
|
104
|
+
else {
|
|
105
|
+
stopAutoScroll();
|
|
106
|
+
}
|
|
107
|
+
}, [findScrollableContainer, startAutoScroll, stopAutoScroll]);
|
|
108
108
|
const handleDragStart = (e) => {
|
|
109
109
|
if (!draggable)
|
|
110
110
|
return;
|
|
111
|
-
setIsDragging(true);
|
|
112
|
-
dragStartPositionRef.current = {
|
|
113
|
-
x: e.clientX,
|
|
114
|
-
y: e.clientY,
|
|
115
|
-
};
|
|
116
111
|
e.dataTransfer.setData('text/plain', header.id);
|
|
117
112
|
e.dataTransfer.effectAllowed = 'move';
|
|
113
|
+
setIsDragging(true);
|
|
114
|
+
dragStartPositionRef.current = { x: e.clientX, y: e.clientY };
|
|
118
115
|
};
|
|
119
|
-
const handleDrag = (
|
|
120
|
-
if (!
|
|
116
|
+
const handleDrag = (e) => {
|
|
117
|
+
if (!draggable || !dragStartPositionRef.current)
|
|
121
118
|
return;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
}, [
|
|
126
|
-
isDragging,
|
|
127
|
-
draggable,
|
|
128
|
-
checkAutoScroll,
|
|
129
|
-
]);
|
|
119
|
+
checkAutoScroll(e.clientX);
|
|
120
|
+
};
|
|
130
121
|
const getSortIcon = () => {
|
|
131
122
|
if (!enableSorting)
|
|
132
123
|
return null;
|
|
133
124
|
const sortDirection = header.column.getIsSorted();
|
|
125
|
+
const mergedSortIconProps = (0, slot_helpers_1.mergeSlotProps)({
|
|
126
|
+
fontSize: 'small',
|
|
127
|
+
}, sortIconProps || {});
|
|
134
128
|
if (sortDirection === 'asc') {
|
|
135
|
-
return ((0, jsx_runtime_1.jsx)(SortIconAscSlot, Object.assign({
|
|
129
|
+
return ((0, jsx_runtime_1.jsx)(SortIconAscSlot, Object.assign({}, (0, slot_helpers_1.mergeSlotProps)(mergedSortIconProps, sortIconAscSlotProps))));
|
|
136
130
|
}
|
|
137
131
|
if (sortDirection === 'desc') {
|
|
138
|
-
return ((0, jsx_runtime_1.jsx)(SortIconDescSlot, Object.assign({
|
|
132
|
+
return ((0, jsx_runtime_1.jsx)(SortIconDescSlot, Object.assign({}, (0, slot_helpers_1.mergeSlotProps)(mergedSortIconProps, sortIconDescSlotProps))));
|
|
139
133
|
}
|
|
140
134
|
return null;
|
|
141
135
|
};
|
|
@@ -188,27 +182,25 @@ function DraggableHeader({ header, enableSorting = true, draggable = false, onCo
|
|
|
188
182
|
return 'pointer';
|
|
189
183
|
return 'default';
|
|
190
184
|
};
|
|
185
|
+
const mergedContainerProps = (0, slot_helpers_1.mergeSlotProps)({
|
|
186
|
+
ref: headerElementRef,
|
|
187
|
+
sx: Object.assign({ display: 'flex', alignItems: 'center', justifyContent: justifyContent, gap: 1, cursor: getCursor(), userSelect: 'none', opacity: isDragging ? 0.5 : 1, backgroundColor: dragOver ? 'rgba(25, 118, 210, 0.08)' : 'transparent', borderLeft: dragOver ? '2px solid #1976d2' : 'none', padding: dragOver ? '0 0 0 -2px' : '0', width: '100%', height: '100%', '&:active': {
|
|
188
|
+
cursor: draggable ? 'grabbing' : 'pointer',
|
|
189
|
+
} }, containerSx),
|
|
190
|
+
draggable: draggable,
|
|
191
|
+
onDragStart: handleDragStart,
|
|
192
|
+
onDrag: handleDrag,
|
|
193
|
+
onDragEnd: handleDragEnd,
|
|
194
|
+
onDragOver: handleDragOver,
|
|
195
|
+
onDragLeave: handleDragLeave,
|
|
196
|
+
onDrop: handleDrop,
|
|
197
|
+
onClick: enableSorting ? handleSort : undefined,
|
|
198
|
+
}, otherProps);
|
|
191
199
|
if (!draggable && !enableSorting) {
|
|
192
200
|
return (0, react_table_1.flexRender)(header.column.columnDef.header, header.getContext());
|
|
193
201
|
}
|
|
194
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Box, {
|
|
195
|
-
display: 'flex',
|
|
196
|
-
alignItems: 'center',
|
|
197
|
-
justifyContent: justifyContent,
|
|
198
|
-
gap: 1,
|
|
199
|
-
cursor: getCursor(),
|
|
200
|
-
userSelect: 'none',
|
|
201
|
-
opacity: isDragging ? 0.5 : 1,
|
|
202
|
-
backgroundColor: dragOver ? 'rgba(25, 118, 210, 0.08)' : 'transparent',
|
|
203
|
-
borderLeft: dragOver ? '2px solid #1976d2' : 'none',
|
|
204
|
-
padding: dragOver ? '0 0 0 -2px' : '0',
|
|
205
|
-
width: '100%',
|
|
206
|
-
height: '100%',
|
|
207
|
-
'&:active': {
|
|
208
|
-
cursor: draggable ? 'grabbing' : 'pointer',
|
|
209
|
-
},
|
|
210
|
-
}, draggable: draggable, onDragStart: handleDragStart, onDrag: handleDrag, onDragEnd: handleDragEnd, onDragOver: handleDragOver, onDragLeave: handleDragLeave, onDrop: handleDrop, onClick: enableSorting ? handleSort : undefined, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { component: "span", sx: {
|
|
202
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({}, mergedContainerProps, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, { component: "span", sx: {
|
|
211
203
|
display: 'inline-flex',
|
|
212
204
|
gap: 1,
|
|
213
|
-
}, children: [(0, react_table_1.flexRender)(header.column.columnDef.header, header.getContext()), getSortIcon()] }) }));
|
|
205
|
+
}, children: [(0, react_table_1.flexRender)(header.column.columnDef.header, header.getContext()), getSortIcon()] }) })));
|
|
214
206
|
}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
import { TableHeadProps, TableRowProps, TableCellProps, SxProps } from '@mui/material';
|
|
2
|
+
export interface TableHeaderProps extends TableHeadProps {
|
|
2
3
|
draggable?: boolean;
|
|
3
4
|
enableColumnResizing?: boolean;
|
|
4
5
|
enableStickyHeader?: boolean;
|
|
5
6
|
fitToScreen?: boolean;
|
|
6
7
|
onColumnReorder?: (draggedColumnId: string, targetColumnId: string) => void;
|
|
8
|
+
headerRowProps?: TableRowProps;
|
|
9
|
+
headerCellProps?: TableCellProps;
|
|
10
|
+
containerSx?: SxProps;
|
|
11
|
+
resizeHandleSx?: SxProps;
|
|
7
12
|
slots?: Record<string, any>;
|
|
8
13
|
slotProps?: Record<string, any>;
|
|
14
|
+
[key: string]: any;
|
|
9
15
|
}
|
|
10
|
-
export declare function TableHeader<T>(
|
|
16
|
+
export declare function TableHeader<T>(props: TableHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,25 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TableHeader = TableHeader;
|
|
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 draggable_header_1 = require("./draggable-header");
|
|
7
8
|
const data_table_context_1 = require("../../contexts/data-table-context");
|
|
8
9
|
const utils_1 = require("../../utils");
|
|
9
10
|
const slot_helpers_1 = require("../../utils/slot-helpers");
|
|
10
|
-
function TableHeader(
|
|
11
|
+
function TableHeader(props) {
|
|
12
|
+
const { draggable = false, enableColumnResizing = false, enableStickyHeader = false, fitToScreen = true, onColumnReorder, headerRowProps, headerCellProps, containerSx, resizeHandleSx, slots, slotProps } = props, otherProps = tslib_1.__rest(props, ["draggable", "enableColumnResizing", "enableStickyHeader", "fitToScreen", "onColumnReorder", "headerRowProps", "headerCellProps", "containerSx", "resizeHandleSx", "slots", "slotProps"]);
|
|
11
13
|
const theme = (0, material_1.useTheme)();
|
|
12
14
|
const { table } = (0, data_table_context_1.useDataTableContext)();
|
|
15
|
+
const headerCellSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'headerCell');
|
|
16
|
+
const headerRowSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'headerRow');
|
|
17
|
+
const headerSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'header');
|
|
13
18
|
const HeaderCellSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'headerCell', material_1.TableCell);
|
|
14
19
|
const HeaderRowSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'headerRow', material_1.TableRow);
|
|
15
20
|
const HeaderSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'header', material_1.TableHead);
|
|
21
|
+
const mergedHeaderProps = (0, slot_helpers_1.mergeSlotProps)({
|
|
22
|
+
sx: containerSx,
|
|
23
|
+
}, headerSlotProps, otherProps);
|
|
24
|
+
const mergedHeaderRowProps = (0, slot_helpers_1.mergeSlotProps)({}, headerRowSlotProps, headerRowProps || {});
|
|
16
25
|
const renderHeaderCell = (header) => {
|
|
17
26
|
const isPinned = header.column.getIsPinned();
|
|
18
27
|
const pinnedPosition = isPinned ? header.column.getStart('left') : undefined;
|
|
19
28
|
const pinnedRightPosition = isPinned === 'right' ? header.column.getAfter('right') : undefined;
|
|
20
29
|
const alignment = (0, utils_1.getColumnAlignment)(header.column.columnDef);
|
|
21
30
|
const enableSorting = header.column.getCanSort();
|
|
22
|
-
|
|
31
|
+
const mergedHeaderCellProps = (0, slot_helpers_1.mergeSlotProps)({
|
|
32
|
+
align: alignment,
|
|
33
|
+
sx: Object.assign({}, (0, utils_1.getPinnedColumnStyle)({
|
|
23
34
|
width: (fitToScreen && !enableColumnResizing) ? 'auto' : header.getSize(),
|
|
24
35
|
isPinned,
|
|
25
36
|
pinnedPosition,
|
|
@@ -28,21 +39,16 @@ function TableHeader({ draggable = false, enableColumnResizing = false, enableSt
|
|
|
28
39
|
pinnedRightPosition,
|
|
29
40
|
zIndex: isPinned ? 10 : 1,
|
|
30
41
|
disableStickyHeader: enableStickyHeader,
|
|
31
|
-
}))
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
backgroundColor: header.column.getIsResizing() ? 'primary.main' : theme.palette.grey[300],
|
|
42
|
-
'&:hover': {
|
|
43
|
-
backgroundColor: theme.palette.primary.main,
|
|
44
|
-
},
|
|
45
|
-
} })) : null] }), header.id));
|
|
42
|
+
})),
|
|
43
|
+
}, headerCellSlotProps, headerCellProps || {});
|
|
44
|
+
const mergedResizeHandleProps = (0, slot_helpers_1.mergeSlotProps)({
|
|
45
|
+
onMouseDown: header.getResizeHandler(),
|
|
46
|
+
onTouchStart: header.getResizeHandler(),
|
|
47
|
+
sx: Object.assign({ position: 'absolute', right: 0, top: '25%', height: '50%', width: '3px', cursor: 'col-resize', userSelect: 'none', touchAction: 'none', borderRadius: '4px', backgroundColor: header.column.getIsResizing() ? 'primary.main' : theme.palette.grey[300], '&:hover': {
|
|
48
|
+
backgroundColor: theme.palette.primary.main,
|
|
49
|
+
} }, resizeHandleSx),
|
|
50
|
+
});
|
|
51
|
+
return ((0, jsx_runtime_1.jsxs)(HeaderCellSlot, Object.assign({}, mergedHeaderCellProps, { children: [(0, jsx_runtime_1.jsx)(draggable_header_1.DraggableHeader, { header: header, enableSorting: enableSorting, draggable: !!(draggable && !isPinned), onColumnReorder: onColumnReorder, slots: slots, slotProps: slotProps, alignment: alignment }), enableColumnResizing && header.column.getCanResize() ? ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({}, mergedResizeHandleProps))) : null] }), header.id));
|
|
46
52
|
};
|
|
47
|
-
return ((0, jsx_runtime_1.jsx)(HeaderSlot, Object.assign({},
|
|
53
|
+
return ((0, jsx_runtime_1.jsx)(HeaderSlot, Object.assign({}, mergedHeaderProps, { children: table.getHeaderGroups().map(headerGroup => ((0, jsx_runtime_1.jsx)(HeaderRowSlot, Object.assign({}, mergedHeaderRowProps, { children: headerGroup.headers.map(renderHeaderCell) }), headerGroup.id))) })));
|
|
48
54
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TablePaginationProps } from '@mui/material';
|
|
1
|
+
import { TablePaginationProps, SxProps } from '@mui/material';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
export interface DataTablePaginationProps extends Omit<TablePaginationProps, 'count' | 'rowsPerPage' | 'page' | 'onPageChange' | 'onRowsPerPageChange'> {
|
|
4
4
|
totalRow: number;
|
|
@@ -7,5 +7,11 @@ export interface DataTablePaginationProps extends Omit<TablePaginationProps, 'co
|
|
|
7
7
|
pageIndex: number;
|
|
8
8
|
pageSize: number;
|
|
9
9
|
};
|
|
10
|
+
containerSx?: SxProps;
|
|
11
|
+
paginationProps?: TablePaginationProps;
|
|
12
|
+
footerSx?: SxProps;
|
|
13
|
+
slots?: Record<string, any>;
|
|
14
|
+
slotProps?: Record<string, any>;
|
|
15
|
+
[key: string]: any;
|
|
10
16
|
}
|
|
11
|
-
export declare const DataTablePagination: import("react").MemoExoticComponent<(
|
|
17
|
+
export declare const DataTablePagination: import("react").MemoExoticComponent<(props: DataTablePaginationProps) => import("react/jsx-runtime").JSX.Element>;
|
|
@@ -6,20 +6,32 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
6
6
|
const material_1 = require("@mui/material");
|
|
7
7
|
const react_1 = require("react");
|
|
8
8
|
const data_table_context_1 = require("../../contexts/data-table-context");
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const slot_helpers_1 = require("../../utils/slot-helpers");
|
|
10
|
+
exports.DataTablePagination = (0, react_1.memo)((props) => {
|
|
11
|
+
const { footerFilter = null, pagination, totalRow, containerSx, paginationProps, footerSx, slots, slotProps } = props, otherProps = tslib_1.__rest(props, ["footerFilter", "pagination", "totalRow", "containerSx", "paginationProps", "footerSx", "slots", "slotProps"]);
|
|
11
12
|
const { table } = (0, data_table_context_1.useDataTableContext)();
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
13
|
+
const paginationSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'pagination');
|
|
14
|
+
const PaginationSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'pagination', material_1.TablePagination);
|
|
15
|
+
const mergedContainerProps = (0, slot_helpers_1.mergeSlotProps)({
|
|
16
|
+
sx: Object.assign({ display: 'flex', alignItems: 'center', gap: 1, justifyContent: 'space-between', px: 2 }, containerSx),
|
|
17
|
+
});
|
|
18
|
+
const mergedPaginationProps = (0, slot_helpers_1.mergeSlotProps)({
|
|
19
|
+
component: 'div',
|
|
20
|
+
count: totalRow,
|
|
21
|
+
rowsPerPage: pagination === null || pagination === void 0 ? void 0 : pagination.pageSize,
|
|
22
|
+
page: pagination === null || pagination === void 0 ? void 0 : pagination.pageIndex,
|
|
23
|
+
onPageChange: (_, page) => {
|
|
24
|
+
table.setPageIndex(page);
|
|
25
|
+
},
|
|
26
|
+
onRowsPerPageChange: (e) => {
|
|
27
|
+
const newPageSize = Number(e.target.value);
|
|
28
|
+
table.setPageIndex(0);
|
|
29
|
+
table.setPageSize(newPageSize);
|
|
30
|
+
},
|
|
31
|
+
showFirstButton: true,
|
|
32
|
+
showLastButton: true,
|
|
33
|
+
labelRowsPerPage: 'Rows per page:',
|
|
34
|
+
labelDisplayedRows: ({ from, to, count }) => `${from}–${to} of ${count !== -1 ? count : `more than ${to}`}`,
|
|
35
|
+
}, paginationSlotProps, Object.assign(Object.assign({}, paginationProps), otherProps));
|
|
36
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({}, mergedContainerProps, { children: [footerFilter && ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: footerSx, children: footerFilter })), (0, jsx_runtime_1.jsx)(PaginationSlot, Object.assign({}, mergedPaginationProps))] })));
|
|
25
37
|
});
|
|
@@ -1,13 +1,20 @@
|
|
|
1
|
+
import { TableRowProps, TableCellProps, SxProps } from '@mui/material';
|
|
1
2
|
import { Row } from '@tanstack/react-table';
|
|
2
3
|
import { ReactNode } from 'react';
|
|
3
|
-
export interface DataTableRowProps<T> {
|
|
4
|
+
export interface DataTableRowProps<T> extends TableRowProps {
|
|
4
5
|
row: Row<T>;
|
|
5
6
|
enableHover?: boolean;
|
|
6
7
|
enableStripes?: boolean;
|
|
7
8
|
isOdd?: boolean;
|
|
8
9
|
renderSubComponent?: (row: Row<T>) => ReactNode;
|
|
9
10
|
disableStickyHeader?: boolean;
|
|
11
|
+
cellProps?: TableCellProps;
|
|
12
|
+
expandedRowProps?: TableRowProps;
|
|
13
|
+
expandedCellProps?: TableCellProps;
|
|
14
|
+
containerSx?: SxProps;
|
|
15
|
+
expandedContainerSx?: SxProps;
|
|
10
16
|
slots?: Record<string, any>;
|
|
11
17
|
slotProps?: Record<string, any>;
|
|
18
|
+
[key: string]: any;
|
|
12
19
|
}
|
|
13
|
-
export declare function DataTableRow<T>(
|
|
20
|
+
export declare function DataTableRow<T>(props: DataTableRowProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,23 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DataTableRow = DataTableRow;
|
|
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 react_table_1 = require("@tanstack/react-table");
|
|
7
8
|
const utils_1 = require("../../utils");
|
|
8
9
|
const slot_helpers_1 = require("../../utils/slot-helpers");
|
|
9
|
-
function DataTableRow(
|
|
10
|
+
function DataTableRow(props) {
|
|
11
|
+
const { row, enableHover = true, enableStripes = false, isOdd = false, renderSubComponent, disableStickyHeader = false, cellProps, expandedRowProps, expandedCellProps, containerSx, expandedContainerSx, slots, slotProps } = props, otherProps = tslib_1.__rest(props, ["row", "enableHover", "enableStripes", "isOdd", "renderSubComponent", "disableStickyHeader", "cellProps", "expandedRowProps", "expandedCellProps", "containerSx", "expandedContainerSx", "slots", "slotProps"]);
|
|
12
|
+
const cellSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'cell');
|
|
13
|
+
const expandedRowSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'expandedRow');
|
|
14
|
+
const rowSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'row');
|
|
10
15
|
const CellSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'cell', material_1.TableCell);
|
|
11
16
|
const ExpandedRowSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'expandedRow', material_1.TableRow);
|
|
12
17
|
const TableRowSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'row', material_1.TableRow);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
const mergedRowProps = (0, slot_helpers_1.mergeSlotProps)({
|
|
19
|
+
hover: enableHover,
|
|
20
|
+
sx: Object.assign({ backgroundColor: enableStripes && isOdd ? 'action.hover' : 'transparent' }, containerSx),
|
|
21
|
+
}, rowSlotProps, otherProps);
|
|
22
|
+
const mergedExpandedRowProps = (0, slot_helpers_1.mergeSlotProps)({
|
|
23
|
+
sx: expandedContainerSx,
|
|
24
|
+
}, expandedRowSlotProps, expandedRowProps || {});
|
|
25
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(TableRowSlot, Object.assign({}, mergedRowProps, { children: row.getVisibleCells().map(cell => {
|
|
16
26
|
const isPinned = cell.column.getIsPinned();
|
|
17
27
|
const pinnedPosition = isPinned ? cell.column.getStart('left') : undefined;
|
|
18
28
|
const pinnedRightPosition = isPinned === 'right' ? cell.column.getAfter('right') : undefined;
|
|
19
29
|
const alignment = (0, utils_1.getColumnAlignment)(cell.column.columnDef);
|
|
20
|
-
|
|
30
|
+
const mergedCellProps = (0, slot_helpers_1.mergeSlotProps)({
|
|
31
|
+
align: alignment,
|
|
32
|
+
sx: Object.assign({}, (0, utils_1.getPinnedColumnStyle)({
|
|
21
33
|
width: cell.column.getSize() || 'auto',
|
|
22
34
|
isPinned,
|
|
23
35
|
pinnedPosition,
|
|
@@ -26,6 +38,8 @@ function DataTableRow({ row, enableHover = true, enableStripes = false, isOdd =
|
|
|
26
38
|
disableStickyHeader,
|
|
27
39
|
isLastLeftPinnedColumn: isPinned === 'left' && cell.column.getIsLastColumn('left'),
|
|
28
40
|
isFirstRightPinnedColumn: isPinned === 'right' && cell.column.getIsFirstColumn('right'),
|
|
29
|
-
}))
|
|
30
|
-
|
|
41
|
+
})),
|
|
42
|
+
}, cellSlotProps, cellProps || {});
|
|
43
|
+
return ((0, jsx_runtime_1.jsx)(CellSlot, Object.assign({}, mergedCellProps, { children: (0, react_table_1.flexRender)(cell.column.columnDef.cell, cell.getContext()) }), cell.id));
|
|
44
|
+
}) })), row.getIsExpanded() && renderSubComponent ? ((0, jsx_runtime_1.jsx)(ExpandedRowSlot, Object.assign({}, mergedExpandedRowProps, { children: (0, jsx_runtime_1.jsx)(CellSlot, Object.assign({ colSpan: row.getVisibleCells().length + 1, sx: Object.assign({ py: 0 }, expandedCellProps === null || expandedCellProps === void 0 ? void 0 : expandedCellProps.sx) }, (0, slot_helpers_1.mergeSlotProps)({}, cellSlotProps, expandedCellProps || {}), { children: (0, jsx_runtime_1.jsx)(material_1.Collapse, { in: row.getIsExpanded(), timeout: "auto", unmountOnExit: true, children: renderSubComponent(row) }) })) }))) : null] }));
|
|
31
45
|
}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { TableRowProps, TableCellProps, SxProps } from '@mui/material';
|
|
2
|
+
export interface EmptyDataRowProps {
|
|
2
3
|
colSpan: number;
|
|
3
4
|
message: string;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
rowProps?: TableRowProps;
|
|
6
|
+
cellProps?: TableCellProps;
|
|
7
|
+
containerSx?: SxProps;
|
|
8
|
+
messageSx?: SxProps;
|
|
9
|
+
slots?: Record<string, any>;
|
|
10
|
+
slotProps?: Record<string, any>;
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}
|
|
13
|
+
export declare function EmptyDataRow(props: EmptyDataRowProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EmptyDataRow = EmptyDataRow;
|
|
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 slot_helpers_1 = require("../../utils/slot-helpers");
|
|
7
|
-
function EmptyDataRow(
|
|
8
|
+
function EmptyDataRow(props) {
|
|
9
|
+
const { colSpan, message, rowProps, cellProps, containerSx, messageSx, slots, slotProps } = props, otherProps = tslib_1.__rest(props, ["colSpan", "message", "rowProps", "cellProps", "containerSx", "messageSx", "slots", "slotProps"]);
|
|
10
|
+
const emptyRowSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'emptyRow');
|
|
11
|
+
const cellSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'cell');
|
|
8
12
|
const EmptyRowSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'emptyRow', material_1.TableRow);
|
|
9
13
|
const EmptyCellSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'cell', material_1.TableCell);
|
|
10
|
-
|
|
14
|
+
const mergedRowProps = (0, slot_helpers_1.mergeSlotProps)({
|
|
15
|
+
sx: containerSx,
|
|
16
|
+
}, emptyRowSlotProps, rowProps || {});
|
|
17
|
+
const mergedCellProps = (0, slot_helpers_1.mergeSlotProps)({
|
|
18
|
+
colSpan,
|
|
19
|
+
align: 'center',
|
|
20
|
+
sx: Object.assign({ py: 4 }, messageSx),
|
|
21
|
+
}, cellSlotProps, cellProps || {});
|
|
22
|
+
return ((0, jsx_runtime_1.jsx)(EmptyRowSlot, Object.assign({}, mergedRowProps, { children: (0, jsx_runtime_1.jsx)(EmptyCellSlot, Object.assign({}, mergedCellProps, { children: message })) })));
|
|
11
23
|
}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { TableRowProps, TableCellProps, SxProps } from '@mui/material';
|
|
2
|
+
export interface LoadingRowsProps {
|
|
2
3
|
rowCount?: number;
|
|
4
|
+
rowProps?: TableRowProps;
|
|
5
|
+
cellProps?: TableCellProps;
|
|
6
|
+
skeletonProps?: any;
|
|
7
|
+
containerSx?: SxProps;
|
|
3
8
|
slots?: Record<string, any>;
|
|
4
9
|
slotProps?: Record<string, any>;
|
|
5
|
-
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
}
|
|
12
|
+
export declare function LoadingRows(props: LoadingRowsProps): import("react/jsx-runtime").JSX.Element;
|