@evoke-platform/ui-components 1.8.1-dev.1 → 1.8.1-dev.3
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 +17 -20
- 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,21 @@ 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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
React.createElement(Grid,
|
|
58
|
-
React.createElement(
|
|
40
|
+
React.createElement(Grid, { container: true },
|
|
41
|
+
React.createElement(Grid, { item: true, xs: 12, display: 'flex', alignItems: 'center', gap: 2, my: 1 },
|
|
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
|
+
width: 'max-content',
|
|
48
|
+
}, title: title }, title)),
|
|
49
|
+
!hideSearchbar && (React.createElement(GridToolbarQuickFilter, { variant: "outlined", size: "small", sx: styles.quickFilter }))),
|
|
50
|
+
React.createElement(ToolbarActions, { actions: actions })),
|
|
51
|
+
subtitle && (React.createElement(Grid, { item: true, xs: 12, mb: 1 },
|
|
52
|
+
React.createElement(Typography, { variant: "subtitle2", sx: {
|
|
53
|
+
color: theme?.palette?.text?.secondary ?? '#637381',
|
|
54
|
+
}, title: subtitle }, subtitle))),
|
|
55
|
+
filter && (React.createElement(Grid, { item: true, xs: 12 }, filter))))));
|
|
59
56
|
}
|
|
60
57
|
export default BuilderGridToolbar;
|
|
@@ -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
|
+
};
|