@evoke-platform/ui-components 1.8.1-dev.0 → 1.8.1-dev.2
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/BuilderGrid/BuilderGrid.js +5 -2
- package/dist/published/components/custom/BuilderGrid/BuilderGridToolbar.js +16 -20
- package/dist/published/components/custom/Form/FormComponents/ObjectComponent/ObjectPropertyInput.js +20 -18
- package/dist/published/stories/BuilderGrid.stories.d.ts +7 -0
- package/dist/published/stories/BuilderGrid.stories.js +39 -0
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ import ErrorComponent from '../ErrorComponent';
|
|
|
6
6
|
import BuilderGridToolbar from './BuilderGridToolbar';
|
|
7
7
|
import { EmptyContent } from './EmptyContent';
|
|
8
8
|
const BuilderGrid = (props) => {
|
|
9
|
-
const { loading, actions, item, rows, initialSort, emptyContentSelectOptions, emptyContentActionIndex, title, subtitle, disablePagination, hideEmptyContent, hideToolbar, hideSearchbar, noRowsOverlay, filterComponent, error, ...rest } = props;
|
|
9
|
+
const { loading, actions, item, rows, initialSort, emptyContentSelectOptions, emptyContentActionIndex, title, subtitle, disablePagination, hideEmptyContent, hideToolbar, hideSearchbar, noRowsOverlay, filterComponent, error, onRowClick, ...rest } = props;
|
|
10
10
|
const [anchorEl, setAnchorEl] = useState();
|
|
11
11
|
const toolbar = useMemo(() => () => (React.createElement(BuilderGridToolbar, { loading: loading, actions: actions, title: title, subtitle: subtitle, hideSearchbar: hideSearchbar, filter: filterComponent })), [loading, actions]);
|
|
12
12
|
return (React.createElement(UIThemeProvider, null, loading || rows.length || hideEmptyContent ? (React.createElement(Box, { sx: {
|
|
@@ -42,7 +42,7 @@ const BuilderGrid = (props) => {
|
|
|
42
42
|
noRowsOverlay: () => {
|
|
43
43
|
return noRowsOverlay ? noRowsOverlay : null;
|
|
44
44
|
},
|
|
45
|
-
}, rowHeight: 60, columnHeaderHeight: 62, ...rest, sx: {
|
|
45
|
+
}, rowHeight: 60, columnHeaderHeight: 62, onRowClick: onRowClick, ...rest, sx: {
|
|
46
46
|
border: 'none',
|
|
47
47
|
'& .MuiDataGrid-toolbarContainer': {
|
|
48
48
|
padding: '0',
|
|
@@ -52,6 +52,9 @@ const BuilderGrid = (props) => {
|
|
|
52
52
|
'& .MuiDataGrid-row': {
|
|
53
53
|
borderBottom: '1px solid #eee',
|
|
54
54
|
},
|
|
55
|
+
'& .MuiDataGrid-row:hover': {
|
|
56
|
+
cursor: onRowClick ? 'pointer' : 'default',
|
|
57
|
+
},
|
|
55
58
|
'& .MuiDataGrid-cell': {
|
|
56
59
|
border: 'none',
|
|
57
60
|
padding: '0 24px',
|
|
@@ -2,17 +2,11 @@ import { Typography } from '@mui/material';
|
|
|
2
2
|
import { GridToolbarContainer, GridToolbarQuickFilter, } from '@mui/x-data-grid';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import UIThemeProvider from '../../../theme';
|
|
5
|
-
import { Grid } from '../../layout';
|
|
5
|
+
import { Box, Grid } from '../../layout';
|
|
6
6
|
import { ToolbarActions } from './ToolbarActions';
|
|
7
7
|
function BuilderGridToolbar(props) {
|
|
8
8
|
const { theme, actions, title, subtitle, filter, hideSearchbar } = props;
|
|
9
9
|
const styles = {
|
|
10
|
-
container: {
|
|
11
|
-
display: 'flex',
|
|
12
|
-
margin: '0 0 15px 0',
|
|
13
|
-
justifyContent: 'space-between',
|
|
14
|
-
width: '100%',
|
|
15
|
-
},
|
|
16
10
|
iconButton: {
|
|
17
11
|
minWidth: '36px',
|
|
18
12
|
height: '36px',
|
|
@@ -43,18 +37,20 @@ function BuilderGridToolbar(props) {
|
|
|
43
37
|
};
|
|
44
38
|
return (React.createElement(UIThemeProvider, { args: { theme: theme } },
|
|
45
39
|
React.createElement(GridToolbarContainer, { sx: { padding: '0' } },
|
|
46
|
-
React.createElement(Grid, {
|
|
47
|
-
React.createElement(Grid, { display: '
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
!hideSearchbar && (React.createElement(GridToolbarQuickFilter, { variant: "outlined", size: "small", sx: styles.quickFilter })),
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
40
|
+
React.createElement(Grid, { container: true },
|
|
41
|
+
React.createElement(Grid, { item: true, xs: 12, display: 'flex', alignItems: 'center', gap: 2 },
|
|
42
|
+
React.createElement(Box, { display: 'flex', alignItems: 'center', gap: 2 },
|
|
43
|
+
title && (React.createElement(Typography, { variant: "h5", sx: {
|
|
44
|
+
fontSize: '18px',
|
|
45
|
+
fontWeight: 700,
|
|
46
|
+
marginBottom: '6px',
|
|
47
|
+
}, title: title }, title)),
|
|
48
|
+
!hideSearchbar && (React.createElement(GridToolbarQuickFilter, { variant: "outlined", size: "small", sx: styles.quickFilter }))),
|
|
49
|
+
React.createElement(ToolbarActions, { actions: actions })),
|
|
50
|
+
subtitle && (React.createElement(Grid, { item: true, xs: 12, my: 1 },
|
|
51
|
+
React.createElement(Typography, { variant: "subtitle2", sx: {
|
|
52
|
+
color: theme?.palette?.text?.secondary ?? '#637381',
|
|
53
|
+
}, title: subtitle }, subtitle))),
|
|
54
|
+
filter && (React.createElement(Grid, { item: true, xs: 12 }, filter))))));
|
|
59
55
|
}
|
|
60
56
|
export default BuilderGridToolbar;
|
package/dist/published/components/custom/Form/FormComponents/ObjectComponent/ObjectPropertyInput.js
CHANGED
|
@@ -19,6 +19,7 @@ export const ObjectPropertyInput = (props) => {
|
|
|
19
19
|
const [layout, setLayout] = useState();
|
|
20
20
|
const [layoutLoaded, setLayoutLoaded] = useState(false);
|
|
21
21
|
const DEFAULT_CREATE_ACTION = '_create';
|
|
22
|
+
const hasValue = instance?.[property.id]?.id || selectedInstance?.id;
|
|
22
23
|
useEffect(() => {
|
|
23
24
|
setLayoutLoaded(false);
|
|
24
25
|
if (relatedObject) {
|
|
@@ -198,8 +199,7 @@ export const ObjectPropertyInput = (props) => {
|
|
|
198
199
|
} }, children));
|
|
199
200
|
}, sx: {
|
|
200
201
|
'& button.MuiButtonBase-root': {
|
|
201
|
-
...(!loadingOptions &&
|
|
202
|
-
(instance?.[property.id]?.id || selectedInstance?.id)
|
|
202
|
+
...(!loadingOptions && hasValue
|
|
203
203
|
? {
|
|
204
204
|
visibility: 'visible',
|
|
205
205
|
}
|
|
@@ -213,7 +213,15 @@ export const ObjectPropertyInput = (props) => {
|
|
|
213
213
|
React.createElement(Box, null,
|
|
214
214
|
React.createElement(Typography, { sx: { marginLeft: '8px', fontSize: '14px' } }, option.label),
|
|
215
215
|
layout?.secondaryTextExpression ? (React.createElement(Typography, { sx: { marginLeft: '8px', fontSize: '14px', color: '#637381' } }, compileExpression(layout?.secondaryTextExpression, options.find((o) => o.id === option.value)))) : null)));
|
|
216
|
-
}, onOpen: () =>
|
|
216
|
+
}, onOpen: (e) => {
|
|
217
|
+
// Don't open the options if there is a value that links to another page
|
|
218
|
+
if (!(navigationSlug &&
|
|
219
|
+
navigateTo &&
|
|
220
|
+
['DIV', 'INPUT'].includes(e.target?.nodeName) &&
|
|
221
|
+
hasValue)) {
|
|
222
|
+
setOpenOptions(true);
|
|
223
|
+
}
|
|
224
|
+
}, onClose: () => setOpenOptions(false), value: hasValue
|
|
217
225
|
? {
|
|
218
226
|
value: instance?.[property.id]?.id ??
|
|
219
227
|
selectedInstance?.id ??
|
|
@@ -241,7 +249,7 @@ export const ObjectPropertyInput = (props) => {
|
|
|
241
249
|
setDropdownInput(undefined);
|
|
242
250
|
return;
|
|
243
251
|
}
|
|
244
|
-
if (
|
|
252
|
+
if (hasValue) {
|
|
245
253
|
e.preventDefault();
|
|
246
254
|
}
|
|
247
255
|
}, loading: loadingOptions, onChange: (event, value) => {
|
|
@@ -263,24 +271,18 @@ export const ObjectPropertyInput = (props) => {
|
|
|
263
271
|
if (dropdownInput) {
|
|
264
272
|
getDropdownOptions();
|
|
265
273
|
}
|
|
266
|
-
}, renderInput: (params) => (React.createElement(TextField, { ...params, placeholder: 'Select', readOnly: !loadingOptions &&
|
|
267
|
-
!!(instance?.[property.id]?.id ||
|
|
268
|
-
selectedInstance?.id), onChange: (event) => setDropdownInput(event.target.value), onClick: (e) => {
|
|
274
|
+
}, renderInput: (params) => (React.createElement(TextField, { ...params, placeholder: 'Select', readOnly: !loadingOptions && !!hasValue, onChange: (event) => setDropdownInput(event.target.value), onClick: (e) => {
|
|
269
275
|
if (navigationSlug &&
|
|
276
|
+
navigateTo &&
|
|
270
277
|
['DIV', 'INPUT'].includes(e.target?.nodeName) &&
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
selectedInstance?.id ??
|
|
277
|
-
''));
|
|
278
|
-
}
|
|
278
|
+
hasValue) {
|
|
279
|
+
setOpenOptions(false);
|
|
280
|
+
navigateTo(navigationSlug.replace(':instanceId', instance?.[property.id]?.id ??
|
|
281
|
+
selectedInstance?.id ??
|
|
282
|
+
''));
|
|
279
283
|
}
|
|
280
284
|
}, sx: {
|
|
281
|
-
...(!loadingOptions &&
|
|
282
|
-
(instance?.[property.id]?.id ||
|
|
283
|
-
selectedInstance?.id)
|
|
285
|
+
...(!loadingOptions && hasValue
|
|
284
286
|
? {
|
|
285
287
|
'.MuiOutlinedInput-root': {
|
|
286
288
|
background: 'white',
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { BuilderGridProps } from '../components/custom/BuilderGrid/BuilderGrid';
|
|
4
|
+
declare const _default: ComponentMeta<(<T extends import("@mui/x-data-grid").GridValidRowModel>(props: BuilderGridProps<T>) => React.JSX.Element)>;
|
|
5
|
+
export default _default;
|
|
6
|
+
export declare const Empty: ComponentStory<(<T extends import("@mui/x-data-grid").GridValidRowModel>(props: BuilderGridProps<T>) => React.JSX.Element)>;
|
|
7
|
+
export declare const Rows: ComponentStory<(<T extends import("@mui/x-data-grid").GridValidRowModel>(props: BuilderGridProps<T>) => React.JSX.Element)>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BuilderGrid } from '../components/custom';
|
|
3
|
+
export default {
|
|
4
|
+
title: 'Custom/BuilderGrid',
|
|
5
|
+
component: BuilderGrid,
|
|
6
|
+
};
|
|
7
|
+
const BuilderGridTemplate = (args) => {
|
|
8
|
+
return React.createElement(BuilderGrid, { ...args });
|
|
9
|
+
};
|
|
10
|
+
const columns = [
|
|
11
|
+
{ field: 'id', headerName: 'ID', type: 'string' },
|
|
12
|
+
{ field: 'name', headerName: 'Name', type: 'string' },
|
|
13
|
+
];
|
|
14
|
+
export const Empty = BuilderGridTemplate.bind({});
|
|
15
|
+
Empty.args = {
|
|
16
|
+
title: 'Tests',
|
|
17
|
+
columns,
|
|
18
|
+
rows: [],
|
|
19
|
+
item: 'test',
|
|
20
|
+
loading: false,
|
|
21
|
+
};
|
|
22
|
+
export const Rows = BuilderGridTemplate.bind({});
|
|
23
|
+
Rows.args = {
|
|
24
|
+
title: 'Tests',
|
|
25
|
+
subtitle: 'This is a long subtitle to test truncation in the toolbar component',
|
|
26
|
+
columns,
|
|
27
|
+
rows: [
|
|
28
|
+
{ id: '1', name: 'Test' },
|
|
29
|
+
{ id: '2', name: 'Test 2' },
|
|
30
|
+
],
|
|
31
|
+
item: 'test',
|
|
32
|
+
loading: false,
|
|
33
|
+
actions: [
|
|
34
|
+
{
|
|
35
|
+
label: 'Add Test',
|
|
36
|
+
onClick: () => console.log('Add Test clicked'),
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
};
|