@evoke-platform/ui-components 1.0.0-dev.147 → 1.0.0-dev.149-test-1056
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 +23 -32
- package/dist/published/components/custom/DataGrid/Toolbar.d.ts +3 -0
- package/dist/published/components/custom/DataGrid/Toolbar.js +26 -6
- package/dist/published/components/custom/FormField/FormField.d.ts +1 -0
- package/dist/published/components/custom/FormField/FormField.js +1 -1
- package/dist/published/components/custom/FormField/InputFieldComponent/InputFieldComponent.js +4 -2
- package/dist/published/stories/DataGrid.stories.d.ts +5 -0
- package/dist/published/stories/DataGrid.stories.js +44 -0
- package/package.json +1 -1
@@ -1,8 +1,15 @@
|
|
1
1
|
/// <reference types="react" />
|
2
2
|
import { DataGridProps as MuiDataGridProps, GridValidRowModel } from '@mui/x-data-grid';
|
3
3
|
import { Theme } from '@mui/material';
|
4
|
+
export declare type BulkAction = {
|
5
|
+
label: string;
|
6
|
+
onClick: () => void;
|
7
|
+
selectionCount?: number;
|
8
|
+
};
|
4
9
|
export declare type DataGridProps<T extends GridValidRowModel> = MuiDataGridProps<T> & {
|
5
10
|
onRefresh?: () => void;
|
6
11
|
theme?: Theme;
|
12
|
+
title?: string;
|
13
|
+
bulkAction?: BulkAction;
|
7
14
|
};
|
8
15
|
export default function <T extends GridValidRowModel>(props: DataGridProps<T>): JSX.Element;
|
@@ -14,49 +14,40 @@ import React, { useMemo, useState } from 'react';
|
|
14
14
|
import Toolbar from './Toolbar';
|
15
15
|
import UIThemeProvider from '../../../theme';
|
16
16
|
export default function (props) {
|
17
|
-
const { onRefresh, loading, theme } = props, rest = __rest(props, ["onRefresh", "loading", "theme"]);
|
17
|
+
const { onRefresh, loading, theme, title, bulkAction } = props, rest = __rest(props, ["onRefresh", "loading", "theme", "title", "bulkAction"]);
|
18
18
|
const [anchorEl, setAnchorEl] = useState();
|
19
|
-
const toolbar = useMemo(() => () => React.createElement(Toolbar, { onRefresh: onRefresh, setAnchorEl: setAnchorEl, loading: loading, theme: theme }), [onRefresh, loading]);
|
19
|
+
const toolbar = useMemo(() => () => (React.createElement(Toolbar, { onRefresh: onRefresh, setAnchorEl: setAnchorEl, loading: loading, theme: theme, title: title, bulkAction: bulkAction })), [onRefresh, loading]);
|
20
20
|
return (React.createElement(UIThemeProvider, { args: { theme: theme } },
|
21
|
-
React.createElement(MuiDataGrid, Object.assign({ onMenuOpen: (env) => setAnchorEl(env.target), loading: loading }, rest, { sx: {
|
22
|
-
borderRadius: '8px',
|
23
|
-
border: 'none',
|
24
|
-
'& .MuiDataGrid-columnHeaders': {
|
21
|
+
React.createElement(MuiDataGrid, Object.assign({ onMenuOpen: (env) => setAnchorEl(env.target), loading: loading }, rest, { sx: Object.assign({ borderRadius: '8px', border: 'none', '& .MuiDataGrid-columnHeaders': {
|
25
22
|
backgroundColor: '#F4F6F8',
|
26
23
|
color: '#637381',
|
27
|
-
borderRadius: '8px 8px 0 0'
|
28
|
-
},
|
29
|
-
'& .MuiDataGrid-virtualScrollerContent': {
|
24
|
+
borderRadius: '8px 8px 0 0',
|
25
|
+
}, '& .MuiDataGrid-virtualScrollerContent': {
|
30
26
|
borderRight: '1px solid #eee',
|
31
27
|
borderLeft: '1px solid #eee',
|
32
|
-
},
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
},
|
37
|
-
'& .MuiDataGrid-row': {
|
28
|
+
}, '& .MuiDataGrid-toolbarContainer': {
|
29
|
+
padding: '0',
|
30
|
+
fontColor: '#212B36',
|
31
|
+
}, '& .MuiDataGrid-row': {
|
38
32
|
borderBottom: '1px solid #eee',
|
39
|
-
},
|
40
|
-
|
41
|
-
|
42
|
-
},
|
43
|
-
'& .MuiDataGrid-footerContainer': {
|
33
|
+
}, '& .MuiDataGrid-cell': {
|
34
|
+
border: 'none',
|
35
|
+
}, '& .MuiDataGrid-footerContainer': {
|
44
36
|
border: '1px solid #eee',
|
45
|
-
borderRadius: '0 0 8px 8px'
|
46
|
-
},
|
47
|
-
|
37
|
+
borderRadius: '0 0 8px 8px',
|
38
|
+
}, '& .MuiTablePagination-displayedRows': {
|
39
|
+
marginBottom: 0,
|
40
|
+
}, '.css-17hki28-MuiButtonBase-root-MuiButton-root': {
|
48
41
|
padding: '7px',
|
49
42
|
color: '#757575',
|
50
43
|
'&:hover': {
|
51
44
|
backgroundColor: '#f2f3f5',
|
52
|
-
}
|
53
|
-
},
|
54
|
-
height: 'calc(100vh - 240px)'
|
55
|
-
}, localeText: {
|
45
|
+
},
|
46
|
+
}, height: 'calc(100vh - 240px)' }, rest.sx), localeText: {
|
56
47
|
toolbarColumns: '',
|
57
48
|
toolbarDensity: '',
|
58
49
|
toolbarFilters: '',
|
59
|
-
toolbarExport: 'Download'
|
50
|
+
toolbarExport: 'Download',
|
60
51
|
}, componentsProps: {
|
61
52
|
panel: {
|
62
53
|
anchorEl: anchorEl,
|
@@ -66,10 +57,10 @@ export default function (props) {
|
|
66
57
|
borderRadius: '8px',
|
67
58
|
boxShadow: '0px 24px 48px rgba(145, 158, 171, 0.4)',
|
68
59
|
padding: '8px',
|
69
|
-
stop: -120
|
70
|
-
}
|
71
|
-
}
|
72
|
-
}
|
60
|
+
stop: -120,
|
61
|
+
},
|
62
|
+
},
|
63
|
+
},
|
73
64
|
}, components: {
|
74
65
|
Toolbar: toolbar,
|
75
66
|
} }))));
|
@@ -1,10 +1,13 @@
|
|
1
1
|
/// <reference types="react" />
|
2
2
|
import { GridToolbarProps as MuiGridToolbarProps } from '@mui/x-data-grid';
|
3
|
+
import { BulkAction } from './DataGrid';
|
3
4
|
export declare type GridToolbarProps = MuiGridToolbarProps & {
|
4
5
|
onRefresh?: () => void;
|
5
6
|
setAnchorEl?: (anchorEl: HTMLAnchorElement | null) => void;
|
6
7
|
loading?: boolean;
|
7
8
|
theme?: any;
|
9
|
+
title?: string;
|
10
|
+
bulkAction?: BulkAction;
|
8
11
|
};
|
9
12
|
declare function Toolbar(props: GridToolbarProps): JSX.Element;
|
10
13
|
export default Toolbar;
|
@@ -1,12 +1,13 @@
|
|
1
|
-
import { FileDownloadRounded, FilterAlt, Refresh, TableChartRounded, TableRowsRounded
|
1
|
+
import { FileDownloadRounded, FilterAlt, Refresh, TableChartRounded, TableRowsRounded } from '@mui/icons-material';
|
2
2
|
import { GridToolbarColumnsButton, GridToolbarContainer, GridToolbarDensitySelector, GridToolbarExport, GridToolbarFilterButton, GridToolbarQuickFilter, } from '@mui/x-data-grid';
|
3
3
|
import React from 'react';
|
4
4
|
import { Grid } from '../../layout';
|
5
|
-
import { IconButton } from '../../core';
|
5
|
+
import { IconButton, Button } from '../../core';
|
6
6
|
import UIThemeProvider from '../../../theme';
|
7
|
+
import { Typography } from '@mui/material';
|
7
8
|
function Toolbar(props) {
|
8
9
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
9
|
-
const { onRefresh, setAnchorEl, loading, theme } = props;
|
10
|
+
const { onRefresh, setAnchorEl, loading, theme, title, bulkAction } = props;
|
10
11
|
const styles = {
|
11
12
|
container: { display: 'flex', justifyContent: 'space-between', margin: '0 0 15px 0' },
|
12
13
|
iconButton: {
|
@@ -33,7 +34,7 @@ function Toolbar(props) {
|
|
33
34
|
borderRadius: '8px',
|
34
35
|
color: '#919EAB',
|
35
36
|
borderColor: 'rgba(145, 158, 171, 0.32)',
|
36
|
-
}
|
37
|
+
},
|
37
38
|
},
|
38
39
|
};
|
39
40
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
@@ -45,9 +46,11 @@ function Toolbar(props) {
|
|
45
46
|
return (React.createElement(UIThemeProvider, { args: { theme: theme } },
|
46
47
|
React.createElement(GridToolbarContainer, { sx: { padding: '0' } },
|
47
48
|
React.createElement(Grid, { container: true, sx: styles.container },
|
49
|
+
title && (React.createElement(Grid, { xs: 12, sx: { marginBottom: '15px' } },
|
50
|
+
React.createElement(Typography, { sx: { fontSize: '20px', fontWeight: 700 } }, title))),
|
48
51
|
React.createElement(Grid, { item: true, xs: 6 },
|
49
52
|
React.createElement(GridToolbarQuickFilter, { variant: "outlined", size: "small", sx: styles.quickFilter })),
|
50
|
-
React.createElement(Grid, { item: true },
|
53
|
+
!bulkAction ? (React.createElement(Grid, { item: true },
|
51
54
|
React.createElement(Grid, { container: true, spacing: 1, sx: styles.icon },
|
52
55
|
React.createElement(Grid, { item: true, sx: { paddingRight: '15px' } },
|
53
56
|
React.createElement(GridToolbarExport, { sx: { color: '#212B36' }, printOptions: { disableToolbarButton: true }, startIcon: React.createElement(FileDownloadRounded, null) })),
|
@@ -64,6 +67,23 @@ function Toolbar(props) {
|
|
64
67
|
React.createElement(GridToolbarDensitySelector, { startIcon: React.createElement(TableRowsRounded, { sx: { marginLeft: '8px' } }), sx: styles.iconButton, onClickCapture: setAnchor })),
|
65
68
|
onRefresh && (React.createElement(Grid, { item: true },
|
66
69
|
React.createElement(IconButton, { onClick: onRefresh, disabled: loading, sx: { borderRadius: '4px' } },
|
67
|
-
React.createElement(Refresh, null)))))))
|
70
|
+
React.createElement(Refresh, null))))))) : (React.createElement(Grid, { item: true, xs: 6, display: 'flex', alignItems: 'center', justifyContent: 'flex-end' },
|
71
|
+
!!bulkAction.selectionCount && bulkAction.selectionCount !== 0 && (React.createElement(Typography, { sx: { marginRight: '12px' } }, `${bulkAction.selectionCount} selected`)),
|
72
|
+
React.createElement(Button, { sx: {
|
73
|
+
fontWeight: 700,
|
74
|
+
height: '40px',
|
75
|
+
padding: '0px 14px',
|
76
|
+
backgroundColor: '#DFE3E8',
|
77
|
+
'&:hover': { backgroundColor: '#c8ccd0' },
|
78
|
+
}, color: 'inherit', onClick: bulkAction.onClick }, bulkAction.label),
|
79
|
+
onRefresh && (React.createElement(Grid, { item: true, marginLeft: '6px' },
|
80
|
+
React.createElement(Button, { onClick: onRefresh, disabled: loading, sx: {
|
81
|
+
height: '40px',
|
82
|
+
minWidth: '45px',
|
83
|
+
borderRadius: '8px',
|
84
|
+
backgroundColor: '#dfe3e8',
|
85
|
+
'&:hover': { backgroundColor: '#c8ccd0' },
|
86
|
+
} },
|
87
|
+
React.createElement(Refresh, { sx: { color: 'black' } }))))))))));
|
68
88
|
}
|
69
89
|
export default Toolbar;
|
@@ -50,7 +50,7 @@ const FormField = (props) => {
|
|
50
50
|
control = React.createElement(Select, Object.assign({}, commonProps));
|
51
51
|
break;
|
52
52
|
default:
|
53
|
-
control = (React.createElement(InputFieldComponent, Object.assign({}, commonProps, { mask: mask, inputMaskPlaceholderChar: inputMaskPlaceholderChar, isMultiLineText: isMultiLineText, rows: rows })));
|
53
|
+
control = (React.createElement(InputFieldComponent, Object.assign({}, commonProps, { instance: props.instance, mask: mask, inputMaskPlaceholderChar: inputMaskPlaceholderChar, isMultiLineText: isMultiLineText, rows: rows })));
|
54
54
|
break;
|
55
55
|
}
|
56
56
|
return control;
|
package/dist/published/components/custom/FormField/InputFieldComponent/InputFieldComponent.js
CHANGED
@@ -27,13 +27,15 @@ export const NumericFormat = (props) => {
|
|
27
27
|
};
|
28
28
|
const InputFieldComponent = (props) => {
|
29
29
|
var _a;
|
30
|
-
const { property, defaultValue, error, errorMessage, onBlur, readOnly, required, size, placeholder, mask, min, max, isMultiLineText, rows, inputMaskPlaceholderChar, } = props;
|
30
|
+
const { property, defaultValue, error, errorMessage, onBlur, readOnly, required, size, placeholder, mask, min, max, isMultiLineText, rows, inputMaskPlaceholderChar, instance } = props;
|
31
31
|
const [value, setValue] = useState(defaultValue !== null && defaultValue !== void 0 ? defaultValue : '');
|
32
32
|
const [inputValue, setInputValue] = useState('');
|
33
33
|
const id = property.id;
|
34
34
|
useEffect(() => {
|
35
|
+
console.log("DefaultValue (ui-lib)", defaultValue);
|
36
|
+
console.log("instance (ui-lib)", instance);
|
35
37
|
setValue(defaultValue !== null && defaultValue !== void 0 ? defaultValue : '');
|
36
|
-
}, [defaultValue]);
|
38
|
+
}, [defaultValue, instance]);
|
37
39
|
const handleChange = (e) => {
|
38
40
|
const inputValue = property.type === 'integer' && /^-?\d+$/.test(e.target.value)
|
39
41
|
? parseInt(e.target.value, 10)
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
2
|
+
import { DataGrid as CustomDataGrid } from '../index';
|
3
|
+
declare const _default: ComponentMeta<typeof CustomDataGrid>;
|
4
|
+
export default _default;
|
5
|
+
export declare const DataGrid: ComponentStory<typeof CustomDataGrid>;
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { Grid, DataGrid as CustomDataGrid, Typography } from '../index';
|
3
|
+
const fetchData = () => {
|
4
|
+
return data;
|
5
|
+
};
|
6
|
+
const data = [
|
7
|
+
{
|
8
|
+
id: '123',
|
9
|
+
name: 'John Smith',
|
10
|
+
},
|
11
|
+
{
|
12
|
+
id: '456',
|
13
|
+
name: 'Jane Doe',
|
14
|
+
},
|
15
|
+
];
|
16
|
+
export default {
|
17
|
+
title: 'Data Display/Data Grid',
|
18
|
+
component: CustomDataGrid,
|
19
|
+
args: {
|
20
|
+
columns: [
|
21
|
+
{ field: 'id', headerName: 'ID', type: 'string', width: 400 },
|
22
|
+
{ field: 'name', headerName: 'Name', type: 'string', width: 400 },
|
23
|
+
],
|
24
|
+
rows: data,
|
25
|
+
getRowId: (row) => row.id,
|
26
|
+
onRefresh: fetchData,
|
27
|
+
sx: {
|
28
|
+
height: 'auto',
|
29
|
+
},
|
30
|
+
},
|
31
|
+
};
|
32
|
+
const DataGridTemplate = (args) => (React.createElement(Grid, { container: true, width: '100%', display: 'block' },
|
33
|
+
React.createElement(Grid, { item: true, xs: 12 },
|
34
|
+
React.createElement(Typography, { variant: "h6" }, "With filtering options:"),
|
35
|
+
React.createElement(CustomDataGrid, Object.assign({ key: 'data-grid' }, args))),
|
36
|
+
React.createElement(Grid, { item: true, xs: 12, sx: { marginTop: '14px' } },
|
37
|
+
React.createElement(Typography, { variant: "h6" }, "With title and bulk action:"),
|
38
|
+
React.createElement(CustomDataGrid, Object.assign({}, args, { key: 'data-grid-with-bulk-action', title: 'Data Grid', bulkAction: {
|
39
|
+
label: 'Bulk Action',
|
40
|
+
action: () => {
|
41
|
+
console.log('Bulk acion clicked');
|
42
|
+
},
|
43
|
+
} })))));
|
44
|
+
export const DataGrid = DataGridTemplate.bind({});
|