@evoke-platform/ui-components 1.0.0-dev.194 → 1.0.0-dev.195
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/core/index.d.ts +1 -0
- package/dist/published/components/custom/BuilderGrid/BuilderGrid.d.ts +2 -0
- package/dist/published/components/custom/BuilderGrid/BuilderGrid.js +3 -3
- package/dist/published/components/custom/BuilderGrid/BuilderGridToolbar.d.ts +2 -1
- package/dist/published/components/custom/BuilderGrid/BuilderGridToolbar.js +15 -7
- package/dist/published/components/custom/CriteriaBuilder/CriteriaBuilder.js +16 -11
- package/package.json +1 -1
@@ -47,3 +47,4 @@ export { SvgIcon, TableBody, TableCell, TableContainer, TableHead, TablePaginati
|
|
47
47
|
export { LoadingButton, TabContext, TabList, TabPanel, TreeItem, TreeView } from '@mui/lab';
|
48
48
|
export type { GridSize } from '@mui/material';
|
49
49
|
export type { AutocompleteOption } from './Autocomplete/Autocomplete';
|
50
|
+
export type { GridCellParams, GridColDef, GridValueFormatterParams, GridValueGetterParams, GridEventListener, } from '@mui/x-data-grid';
|
@@ -4,6 +4,7 @@ import { EmptyContentSelectOptions } from './EmptyContent';
|
|
4
4
|
export declare type GridAction = {
|
5
5
|
label: string;
|
6
6
|
onClick: () => void;
|
7
|
+
isHidden?: boolean;
|
7
8
|
};
|
8
9
|
export declare type BuilderGridProps<T extends GridValidRowModel> = MuiDataGridProps<T> & {
|
9
10
|
action?: GridAction;
|
@@ -15,6 +16,7 @@ export declare type BuilderGridProps<T extends GridValidRowModel> = MuiDataGridP
|
|
15
16
|
hideEmptyContent?: boolean;
|
16
17
|
hideToolbar?: boolean;
|
17
18
|
noRowsOverlay?: React.ReactElement;
|
19
|
+
filterComponent?: React.ReactElement;
|
18
20
|
};
|
19
21
|
declare const BuilderGrid: <T extends GridValidRowModel>(props: BuilderGridProps<T>) => JSX.Element;
|
20
22
|
export default BuilderGrid;
|
@@ -17,9 +17,9 @@ import BuilderGridToolbar from './BuilderGridToolbar';
|
|
17
17
|
import { EmptyContent } from './EmptyContent';
|
18
18
|
const BuilderGrid = (props) => {
|
19
19
|
var _a, _b;
|
20
|
-
const { loading, action, item, rows, initialSort, emptyContentSelectOptions, title, disablePagination, hideEmptyContent, hideToolbar, noRowsOverlay } = props, rest = __rest(props, ["loading", "action", "item", "rows", "initialSort", "emptyContentSelectOptions", "title", "disablePagination", "hideEmptyContent", "hideToolbar", "noRowsOverlay"]);
|
20
|
+
const { loading, action, item, rows, initialSort, emptyContentSelectOptions, title, disablePagination, hideEmptyContent, hideToolbar, noRowsOverlay, filterComponent } = props, rest = __rest(props, ["loading", "action", "item", "rows", "initialSort", "emptyContentSelectOptions", "title", "disablePagination", "hideEmptyContent", "hideToolbar", "noRowsOverlay", "filterComponent"]);
|
21
21
|
const [anchorEl, setAnchorEl] = useState();
|
22
|
-
const toolbar = useMemo(() => () => React.createElement(BuilderGridToolbar, { loading: loading, action: action, title: title }), [loading, action]);
|
22
|
+
const toolbar = useMemo(() => () => React.createElement(BuilderGridToolbar, { loading: loading, action: action, title: title, filter: filterComponent }), [loading, action]);
|
23
23
|
return (React.createElement(UIThemeProvider, null, loading || rows.length || hideEmptyContent ? (React.createElement(Box, { sx: {
|
24
24
|
backgroundColor: '#fff',
|
25
25
|
borderRadius: '6px',
|
@@ -59,7 +59,7 @@ const BuilderGrid = (props) => {
|
|
59
59
|
fontWeight: 700,
|
60
60
|
}, '& .MuiDataGrid-iconButtonContainer': {
|
61
61
|
marginLeft: '4px',
|
62
|
-
}, height:
|
62
|
+
}, height: disablePagination && !loading ? 'auto' : 'calc(100vh - 240px)' }, rest.sx), getRowId: (row) => row.id, disableColumnMenu: true, initialState: {
|
63
63
|
sorting: {
|
64
64
|
sortModel: initialSort ? [initialSort] : [],
|
65
65
|
},
|
@@ -1,9 +1,10 @@
|
|
1
|
-
/// <reference types="react" />
|
2
1
|
import { GridToolbarProps as MuiGridToolbarProps } from '@mui/x-data-grid';
|
2
|
+
import React from 'react';
|
3
3
|
import { GridAction } from './BuilderGrid';
|
4
4
|
export declare type BuilderGridToolbar = MuiGridToolbarProps & {
|
5
5
|
action?: GridAction;
|
6
6
|
title?: string;
|
7
|
+
filter?: React.ReactElement;
|
7
8
|
};
|
8
9
|
declare function BuilderGridToolbar(props: BuilderGridToolbar): JSX.Element;
|
9
10
|
export default BuilderGridToolbar;
|
@@ -6,9 +6,12 @@ import { Button } from '../../core';
|
|
6
6
|
import { Grid } from '../../layout';
|
7
7
|
function BuilderGridToolbar(props) {
|
8
8
|
var _a, _b, _c;
|
9
|
-
const { theme, action, title } = props;
|
9
|
+
const { theme, action, title, filter } = props;
|
10
10
|
const styles = {
|
11
|
-
container: {
|
11
|
+
container: {
|
12
|
+
display: 'flex',
|
13
|
+
margin: '0 0 15px 0',
|
14
|
+
},
|
12
15
|
iconButton: {
|
13
16
|
minWidth: '36px',
|
14
17
|
height: '36px',
|
@@ -25,6 +28,7 @@ function BuilderGridToolbar(props) {
|
|
25
28
|
},
|
26
29
|
quickFilter: {
|
27
30
|
'& .MuiOutlinedInput-root': {
|
31
|
+
minWidth: '300px',
|
28
32
|
'&.Mui-focused fieldset': {
|
29
33
|
borderColor: (_c = (_b = (_a = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _a === void 0 ? void 0 : _a.primary) === null || _b === void 0 ? void 0 : _b.main) !== null && _c !== void 0 ? _c : 'primary',
|
30
34
|
},
|
@@ -40,16 +44,20 @@ function BuilderGridToolbar(props) {
|
|
40
44
|
React.createElement(GridToolbarContainer, { sx: { padding: '0' } },
|
41
45
|
title && (React.createElement(Typography, { sx: { fontSize: '18px', fontWeight: 700, marginBottom: '6px', marginTop: '6px' } }, title)),
|
42
46
|
React.createElement(Grid, { container: true, sx: styles.container },
|
43
|
-
React.createElement(Grid, { item: true, xs:
|
44
|
-
|
45
|
-
|
47
|
+
React.createElement(Grid, { item: true, xs: filter ? 3 : 6, sx: {
|
48
|
+
display: 'flex',
|
49
|
+
alignItems: 'center',
|
50
|
+
} },
|
51
|
+
React.createElement(GridToolbarQuickFilter, { variant: "outlined", size: "small", sx: Object.assign(Object.assign({}, styles.quickFilter), { flex: filter ? 1 : 0 }) })),
|
52
|
+
filter && (React.createElement(Grid, { xs: 6, item: true, sx: { display: 'flex' } }, filter)),
|
53
|
+
action && !action.isHidden && (React.createElement(Grid, { item: true, xs: filter ? 3 : 6, display: 'flex', alignItems: 'center', justifyContent: 'flex-end' },
|
46
54
|
React.createElement(Button, { sx: {
|
47
55
|
fontWeight: 700,
|
48
|
-
height: '
|
56
|
+
height: '36px',
|
49
57
|
padding: '0px 14px',
|
50
58
|
'&:hover': {
|
51
59
|
boxShadow: 'none',
|
52
60
|
},
|
53
|
-
}, onClick: action
|
61
|
+
}, onClick: action.onClick, variant: 'contained' }, action.label)))))));
|
54
62
|
}
|
55
63
|
export default BuilderGridToolbar;
|
@@ -169,22 +169,27 @@ const CriteriaBuilder = (props) => {
|
|
169
169
|
if (criteria || originalCriteria) {
|
170
170
|
const criteriaToParse = criteria || originalCriteria || {};
|
171
171
|
const updatedQuery = parseMongoDB(criteriaToParse);
|
172
|
-
setQuery(Object.assign(Object.assign({}, updatedQuery), {
|
173
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
174
|
-
rules: updatedQuery.rules.map((rule) => {
|
175
|
-
var _a, _b;
|
176
|
-
const propertyType = (_a = properties.find((property) => property.id === rule.field)) === null || _a === void 0 ? void 0 : _a.type;
|
177
|
-
return Object.assign(Object.assign({}, rule), { value: propertyType === 'array' ||
|
178
|
-
(propertyType === 'string' && rule.operator === 'in') ||
|
179
|
-
rule.operator === 'notIn'
|
180
|
-
? (_b = rule.value) === null || _b === void 0 ? void 0 : _b.split(',')
|
181
|
-
: rule.value });
|
182
|
-
}) }));
|
172
|
+
setQuery(Object.assign(Object.assign({}, updatedQuery), { rules: processRules(updatedQuery.rules) }));
|
183
173
|
}
|
184
174
|
else {
|
185
175
|
setQuery({ combinator: 'and', rules: [] });
|
186
176
|
}
|
187
177
|
}, [originalCriteria]);
|
178
|
+
function processRules(rules) {
|
179
|
+
return rules.map((rule) => {
|
180
|
+
var _a, _b;
|
181
|
+
if ('rules' in rule) {
|
182
|
+
return Object.assign(Object.assign({}, rule), { rules: processRules(rule.rules) });
|
183
|
+
}
|
184
|
+
else {
|
185
|
+
const propertyType = (_a = properties.find((property) => property.id === rule.field)) === null || _a === void 0 ? void 0 : _a.type;
|
186
|
+
return Object.assign(Object.assign({}, rule), { value: propertyType === 'array' ||
|
187
|
+
(propertyType === 'string' && (rule.operator === 'in' || rule.operator === 'notIn'))
|
188
|
+
? (_b = rule.value) === null || _b === void 0 ? void 0 : _b.split(',')
|
189
|
+
: rule.value });
|
190
|
+
}
|
191
|
+
});
|
192
|
+
}
|
188
193
|
const handleQueryChange = (q) => {
|
189
194
|
setQuery(q);
|
190
195
|
const newCriteria = JSON.parse(formatQuery(q, 'mongodb'));
|