@evoke-platform/ui-components 1.0.0-dev.214 → 1.0.0-dev.215
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/dist/published/components/custom/DataGrid/DataGrid.d.ts +7 -0
- package/dist/published/components/custom/DataGrid/DataGrid.js +51 -8
- package/dist/published/components/custom/DataGrid/DateTimeCustomOperator.d.ts +2 -0
- package/dist/published/components/custom/DataGrid/DateTimeCustomOperator.js +65 -0
- package/dist/published/components/custom/DataGrid/Toolbar.js +7 -1
- package/package.json +1 -1
@@ -6,6 +6,10 @@ export declare type BulkAction = {
|
|
6
6
|
onClick: () => void;
|
7
7
|
selectionCount?: number;
|
8
8
|
};
|
9
|
+
declare type LoadingOptions = {
|
10
|
+
color: string;
|
11
|
+
messages?: string[];
|
12
|
+
};
|
9
13
|
export declare type DataGridProps<T extends GridValidRowModel> = MuiDataGridProps<T> & {
|
10
14
|
onRefresh?: () => void;
|
11
15
|
theme?: Theme;
|
@@ -14,7 +18,10 @@ export declare type DataGridProps<T extends GridValidRowModel> = MuiDataGridProp
|
|
14
18
|
filterSettings?: {
|
15
19
|
mode: 'client' | 'server';
|
16
20
|
maxRows?: number;
|
21
|
+
filterColumns?: boolean;
|
17
22
|
};
|
18
23
|
hideSearchbar?: boolean;
|
24
|
+
loadingOptions?: LoadingOptions;
|
19
25
|
};
|
20
26
|
export default function <T extends GridValidRowModel>(props: DataGridProps<T>): JSX.Element;
|
27
|
+
export {};
|
@@ -10,27 +10,43 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
10
10
|
return t;
|
11
11
|
};
|
12
12
|
import { DataGrid as MuiDataGrid, getGridStringOperators, getGridDateOperators, getGridSingleSelectOperators, getGridBooleanOperators, GridPagination, getGridNumericOperators, } from '@mui/x-data-grid';
|
13
|
-
import
|
13
|
+
import { lighten } from '@mui/material';
|
14
|
+
import React, { useEffect, useState } from 'react';
|
14
15
|
import Toolbar from './Toolbar';
|
15
16
|
import UIThemeProvider from '../../../theme';
|
16
17
|
import { Box, Typography } from '@mui/material';
|
18
|
+
import { dateTimeBetweenOperator } from './DateTimeCustomOperator';
|
19
|
+
import LinearProgress from '../../core/LinearProgress';
|
17
20
|
export default function (props) {
|
18
21
|
var _a;
|
19
|
-
const { onRefresh, loading, theme, title, bulkAction, filterSettings, columns, rows, hideSearchbar } = props, rest = __rest(props, ["onRefresh", "loading", "theme", "title", "bulkAction", "filterSettings", "columns", "rows", "hideSearchbar"]);
|
22
|
+
const { onRefresh, loading, theme, title, bulkAction, filterSettings, columns, rows, hideSearchbar, loadingOptions } = props, rest = __rest(props, ["onRefresh", "loading", "theme", "title", "bulkAction", "filterSettings", "columns", "rows", "hideSearchbar", "loadingOptions"]);
|
20
23
|
const [anchorEl, setAnchorEl] = useState();
|
24
|
+
const [loadingMessageIndex, setLoadingMessageIndex] = useState(0);
|
21
25
|
const addColumnFilterOperators = (columns) => {
|
22
|
-
return (filterSettings === null || filterSettings === void 0 ? void 0 : filterSettings.mode) === 'server'
|
26
|
+
return (filterSettings === null || filterSettings === void 0 ? void 0 : filterSettings.mode) === 'server' || !!(filterSettings === null || filterSettings === void 0 ? void 0 : filterSettings.filterColumns)
|
23
27
|
? columns.map((column) => (Object.assign(Object.assign({}, column), { filterOperators: column.type === 'string'
|
24
|
-
? getGridStringOperators().filter((o) => !['isEmpty', 'isNotEmpty', '
|
28
|
+
? getGridStringOperators().filter((o) => !['isEmpty', 'isNotEmpty', 'isAnyOf'].includes(o.value))
|
25
29
|
: column.type === 'date' || column.type === 'dateTime'
|
26
|
-
? getGridDateOperators(column.type === 'dateTime')
|
30
|
+
? getGridDateOperators(column.type === 'dateTime')
|
31
|
+
.filter((o) => !['isEmpty', 'isNotEmpty', 'isAnyOf'].includes(o.value))
|
32
|
+
.concat(dateTimeBetweenOperator)
|
27
33
|
: column.type === 'number'
|
28
|
-
? getGridNumericOperators().filter((o) => !['isEmpty', 'isNotEmpty'].includes(o.value))
|
34
|
+
? getGridNumericOperators().filter((o) => !['isEmpty', 'isNotEmpty', 'isAnyOf'].includes(o.value))
|
29
35
|
: column.type === 'singleSelect'
|
30
36
|
? getGridSingleSelectOperators().filter((o) => !['isEmpty', 'isNotEmpty', 'isAnyOf'].includes(o.value))
|
31
|
-
: getGridBooleanOperators().filter((o) => !['isEmpty', 'isNotEmpty'].includes(o.value)) })))
|
37
|
+
: getGridBooleanOperators().filter((o) => !['isEmpty', 'isNotEmpty', 'isAnyOf'].includes(o.value)) })))
|
32
38
|
: columns;
|
33
39
|
};
|
40
|
+
useEffect(() => {
|
41
|
+
var _a;
|
42
|
+
if (!loading || !((_a = loadingOptions === null || loadingOptions === void 0 ? void 0 : loadingOptions.messages) === null || _a === void 0 ? void 0 : _a.length))
|
43
|
+
return;
|
44
|
+
const intervalId = setInterval(() => {
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
46
|
+
setLoadingMessageIndex((prevIndex) => (prevIndex + 1) % loadingOptions.messages.length);
|
47
|
+
}, 1500);
|
48
|
+
return () => clearInterval(intervalId);
|
49
|
+
}, [loading, loadingMessageIndex, loadingOptions]);
|
34
50
|
return (React.createElement(UIThemeProvider, { args: { theme: theme } },
|
35
51
|
React.createElement(MuiDataGrid, Object.assign({ onMenuOpen: (env) => setAnchorEl(env.target), loading: loading, filterMode: (_a = filterSettings === null || filterSettings === void 0 ? void 0 : filterSettings.mode) !== null && _a !== void 0 ? _a : 'client', rows: rows }, rest, { columns: addColumnFilterOperators(columns), sx: Object.assign({ borderRadius: '8px', border: 'none', '& .MuiDataGrid-columnHeaders': {
|
36
52
|
backgroundColor: '#F4F6F8',
|
@@ -39,7 +55,7 @@ export default function (props) {
|
|
39
55
|
}, '& .MuiDataGrid-virtualScrollerContent': {
|
40
56
|
borderRight: '1px solid #eee',
|
41
57
|
borderLeft: '1px solid #eee',
|
42
|
-
}, '& .MuiDataGrid-toolbarContainer': {
|
58
|
+
}, '& .MuiDataGrid-virtualScroller': Object.assign({}, (loading ? { overflow: 'hidden' } : {})), '& .MuiDataGrid-toolbarContainer': {
|
43
59
|
padding: '0',
|
44
60
|
fontColor: '#212B36',
|
45
61
|
}, '& .MuiDataGrid-row': {
|
@@ -81,6 +97,10 @@ export default function (props) {
|
|
81
97
|
boxShadow: '0px 24px 48px rgba(145, 158, 171, 0.4)',
|
82
98
|
padding: '8px',
|
83
99
|
stop: -120,
|
100
|
+
'& .MuiDataGrid-filterFormValueInput': {
|
101
|
+
minWidth: '190px',
|
102
|
+
width: 'auto',
|
103
|
+
},
|
84
104
|
},
|
85
105
|
},
|
86
106
|
},
|
@@ -92,5 +112,28 @@ export default function (props) {
|
|
92
112
|
search.`))),
|
93
113
|
React.createElement(GridPagination, null)));
|
94
114
|
},
|
115
|
+
LoadingOverlay: () => {
|
116
|
+
var _a, _b;
|
117
|
+
return (React.createElement(Box, { sx: {
|
118
|
+
minHeight: '100%',
|
119
|
+
display: 'flex',
|
120
|
+
justifyContent: 'center',
|
121
|
+
alignItems: 'center',
|
122
|
+
backgroundColor: '#fff',
|
123
|
+
overflow: 'hidden',
|
124
|
+
} },
|
125
|
+
React.createElement(Box, { width: '225px' },
|
126
|
+
React.createElement(Typography, { sx: { marginBottom: '8px', color: '#aaa', width: '100%', textAlign: 'center' } }, (loadingOptions === null || loadingOptions === void 0 ? void 0 : loadingOptions.messages)
|
127
|
+
? loadingOptions.messages[loadingMessageIndex]
|
128
|
+
: 'Loading'),
|
129
|
+
React.createElement(LinearProgress, { sx: {
|
130
|
+
backgroundColor: (_a = loadingOptions === null || loadingOptions === void 0 ? void 0 : loadingOptions.color) !== null && _a !== void 0 ? _a : '#0075A7',
|
131
|
+
'& .MuiLinearProgress-bar': {
|
132
|
+
backgroundColor: lighten((_b = loadingOptions === null || loadingOptions === void 0 ? void 0 : loadingOptions.color) !== null && _b !== void 0 ? _b : '#0075A7', 0.5),
|
133
|
+
},
|
134
|
+
borderRadius: '6px',
|
135
|
+
width: '100%',
|
136
|
+
} }))));
|
137
|
+
},
|
95
138
|
} }))));
|
96
139
|
}
|
@@ -0,0 +1,65 @@
|
|
1
|
+
import { Box, debounce, TextField } from '@mui/material';
|
2
|
+
import { useGridRootProps } from '@mui/x-data-grid';
|
3
|
+
import React, { useEffect, useState } from 'react';
|
4
|
+
import { isNil } from 'lodash';
|
5
|
+
function DateTimeRangeFilter(props) {
|
6
|
+
var _a;
|
7
|
+
const rootProps = useGridRootProps();
|
8
|
+
const { item, applyValue, focusElementRef = null } = props;
|
9
|
+
const [filterValueState, setFilterValueState] = useState((_a = item.value) !== null && _a !== void 0 ? _a : '');
|
10
|
+
useEffect(() => {
|
11
|
+
var _a;
|
12
|
+
const itemValue = (_a = item.value) !== null && _a !== void 0 ? _a : [undefined, undefined];
|
13
|
+
setFilterValueState(itemValue);
|
14
|
+
}, [item.value]);
|
15
|
+
const updateFilterValue = (from, to) => {
|
16
|
+
setFilterValueState([from, to]);
|
17
|
+
debounce(() => {
|
18
|
+
applyValue(Object.assign(Object.assign({}, item), { value: [from, to] }));
|
19
|
+
}, rootProps.filterDebounceMs)();
|
20
|
+
};
|
21
|
+
const handleChange = (event) => {
|
22
|
+
const updatedValue = event.target.value;
|
23
|
+
if (event.target.name === 'from') {
|
24
|
+
updateFilterValue(updatedValue, filterValueState[1]);
|
25
|
+
}
|
26
|
+
else if (event.target.name === 'to') {
|
27
|
+
updateFilterValue(filterValueState[0], updatedValue);
|
28
|
+
}
|
29
|
+
};
|
30
|
+
return (React.createElement(Box, { sx: {
|
31
|
+
display: 'inline-flex',
|
32
|
+
flexDirection: 'row',
|
33
|
+
alignItems: 'end',
|
34
|
+
height: 48,
|
35
|
+
pl: '20px',
|
36
|
+
} },
|
37
|
+
React.createElement(TextField, { name: "from", label: "From", variant: "standard", value: filterValueState[0], onChange: handleChange, type: "datetime-local", inputRef: focusElementRef, InputLabelProps: { shrink: true }, sx: { mr: 2, width: '175px' } }),
|
38
|
+
React.createElement(TextField, { name: "to", label: "To", variant: "standard", value: filterValueState[1], onChange: handleChange, InputLabelProps: { shrink: true }, type: "datetime-local", sx: { width: '175px' } })));
|
39
|
+
}
|
40
|
+
export const dateTimeBetweenOperator = [
|
41
|
+
{
|
42
|
+
label: 'between',
|
43
|
+
value: 'between',
|
44
|
+
getApplyFilterFn: () => null,
|
45
|
+
getApplyFilterFnV7: (filterItem) => {
|
46
|
+
const to = filterItem.value[0];
|
47
|
+
const from = filterItem.value[1];
|
48
|
+
return (value) => {
|
49
|
+
if (isNil(value))
|
50
|
+
return false;
|
51
|
+
if (to && from) {
|
52
|
+
return to <= value && value <= from;
|
53
|
+
}
|
54
|
+
else if (to) {
|
55
|
+
return value <= to;
|
56
|
+
}
|
57
|
+
else if (from) {
|
58
|
+
return value >= from;
|
59
|
+
}
|
60
|
+
return false;
|
61
|
+
};
|
62
|
+
},
|
63
|
+
InputComponent: DateTimeRangeFilter,
|
64
|
+
},
|
65
|
+
];
|
@@ -52,7 +52,13 @@ function Toolbar(props) {
|
|
52
52
|
!bulkAction ? (React.createElement(Grid, { item: true },
|
53
53
|
React.createElement(Grid, { container: true, spacing: 1, sx: styles.icon },
|
54
54
|
React.createElement(Grid, { item: true, sx: { paddingRight: '15px' } },
|
55
|
-
React.createElement(GridToolbarExport, { sx: {
|
55
|
+
React.createElement(GridToolbarExport, { sx: {
|
56
|
+
color: '#212B36',
|
57
|
+
height: '95%',
|
58
|
+
'&:hover': { backgroundColor: '#f2f3f5' },
|
59
|
+
paddingLeft: '10px',
|
60
|
+
paddingRight: '10px',
|
61
|
+
}, printOptions: { disableToolbarButton: true }, startIcon: React.createElement(FileDownloadRounded, null) })),
|
56
62
|
React.createElement(Grid, { item: true },
|
57
63
|
React.createElement(GridToolbarFilterButton, { componentsProps: {
|
58
64
|
button: {
|