@centreon/ui 23.10.24-MON-19323-dashboard-page-header-component.1 → 23.10.24
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/package.json +1 -8
- package/src/Checkbox/Checkbox.tsx +107 -0
- package/src/Checkbox/CheckboxGroup/index.stories.tsx +41 -0
- package/src/Checkbox/CheckboxGroup/index.tsx +66 -0
- package/src/Checkbox/index.stories.tsx +39 -0
- package/src/Checkbox/index.tsx +2 -0
- package/src/Dashboard/Dashboard.styles.ts +62 -60
- package/src/Dashboard/DashboardLayout.stories.tsx +5 -3
- package/src/Dashboard/Grid.tsx +1 -1
- package/src/Dashboard/Item.tsx +9 -6
- package/src/Dashboard/Layout.tsx +4 -4
- package/src/Dashboard/utils.ts +28 -28
- package/src/Dialog/Confirm/index.tsx +14 -4
- package/src/Dialog/index.tsx +3 -0
- package/src/Form/CollapsibleGroup.tsx +11 -5
- package/src/Form/Form.stories.tsx +1 -1
- package/src/Form/Form.tsx +24 -9
- package/src/Form/Inputs/Checkbox.tsx +57 -0
- package/src/Form/Inputs/CheckboxGroup.tsx +76 -0
- package/src/Form/Inputs/Grid.tsx +4 -2
- package/src/Form/Inputs/index.tsx +29 -7
- package/src/Form/Inputs/models.ts +13 -1
- package/src/Form/storiesData.tsx +45 -0
- package/src/Panel/index.tsx +6 -4
- package/src/RichTextEditor/ContentEditable.tsx +27 -7
- package/src/RichTextEditor/RichTextEditor.tsx +86 -45
- package/src/ThemeProvider/index.tsx +9 -7
- package/src/ThemeProvider/palettes.ts +208 -283
- package/src/Wizard/index.stories.tsx +5 -18
- package/src/components/Button/Button.styles.ts +2 -7
- package/src/components/Button/Button.tsx +1 -1
- package/src/components/DataTable/Item/DataTableItem.tsx +2 -0
- package/src/components/Header/Header.stories.tsx +27 -0
- package/src/components/Header/Header.styles.ts +27 -0
- package/src/components/Header/Header.tsx +23 -0
- package/src/components/Header/index.ts +1 -1
- package/src/components/Modal/ModalActions.tsx +4 -2
- package/src/components/index.ts +0 -2
- package/src/index.ts +4 -0
- package/src/layout/TiledListingPage/TiledListingActions.tsx +15 -0
- package/src/layout/TiledListingPage/TiledListingContent.tsx +21 -0
- package/src/layout/TiledListingPage/TiledListingList.tsx +11 -0
- package/src/layout/TiledListingPage/TiledListingPage.styles.ts +16 -0
- package/src/layout/TiledListingPage/TiledListingPage.tsx +15 -0
- package/src/layout/TiledListingPage/index.ts +4 -0
- package/src/screens/dashboard/DashboardsOverview.stories.tsx +101 -109
- package/src/utils/index.ts +1 -0
- package/src/utils/panelSize.ts +15 -0
- package/test/setupTests.js +20 -23
- package/src/components/Header/PageHeader/PageHeader.stories.tsx +0 -83
- package/src/components/Header/PageHeader/PageHeader.styles.ts +0 -105
- package/src/components/Header/PageHeader/PageHeader.tsx +0 -15
- package/src/components/Header/PageHeader/PageHeaderActions.tsx +0 -17
- package/src/components/Header/PageHeader/PageHeaderMain.tsx +0 -15
- package/src/components/Header/PageHeader/PageHeaderMenu.tsx +0 -15
- package/src/components/Header/PageHeader/PageHeaderTitle.tsx +0 -44
- package/src/components/Header/PageHeader/index.ts +0 -12
- package/src/components/Layout/AreaIndicator.styles.ts +0 -33
- package/src/components/Layout/AreaIndicator.tsx +0 -35
- package/src/components/Layout/PageLayout/PageLayout.stories.tsx +0 -81
- package/src/components/Layout/PageLayout/PageLayout.styles.ts +0 -30
- package/src/components/Layout/PageLayout/PageLayout.tsx +0 -21
- package/src/components/Layout/PageLayout/PageLayoutActions.tsx +0 -15
- package/src/components/Layout/PageLayout/PageLayoutBody.tsx +0 -24
- package/src/components/Layout/PageLayout/PageLayoutHeader.tsx +0 -15
- package/src/components/Layout/PageLayout/index.ts +0 -10
- package/src/components/Layout/index.ts +0 -1
- package/src/components/Menu/Menu.tsx +0 -0
- package/src/components/Tooltip/TextOverflowTooltip/TextOverflowTooltip.stories.tsx +0 -83
- package/src/components/Tooltip/TextOverflowTooltip/TextOverflowTooltip.styles.ts +0 -5
- package/src/components/Tooltip/TextOverflowTooltip/TextOverflowTooltip.tsx +0 -115
- package/src/components/Tooltip/TextOverflowTooltip/index.tsx +0 -1
- package/src/components/Tooltip/Tooltip.stories.tsx +0 -41
- package/src/components/Tooltip/Tooltip.styles.ts +0 -5
- package/src/components/Tooltip/Tooltip.tsx +0 -46
- package/src/components/Tooltip/index.ts +0 -1
- package/src/utils/useResizeObserver.ts +0 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@centreon/ui",
|
|
3
|
-
"version": "23.10.24
|
|
3
|
+
"version": "23.10.24",
|
|
4
4
|
"description": "Centreon UI Components",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"eslint": "eslint ./src --ext .js,.jsx,.ts,.tsx --max-warnings 0",
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
"storybook": "storybook dev -p 9001 -c .storybook",
|
|
9
9
|
"build:storybook": "storybook build -c .storybook -o .out",
|
|
10
10
|
"test": "jest",
|
|
11
|
-
"test:storybook:local": "test-storybook --url http://127.0.0.1:9001",
|
|
12
11
|
"test:ci": "jest --silent --reporter=jest-junit",
|
|
13
12
|
"cypress:ui": "cypress open --component --browser=chrome",
|
|
14
13
|
"cypress:cli:updateSnapshot": "pnpm cypress:cli --env updateSnapshots=true",
|
|
@@ -55,23 +54,18 @@
|
|
|
55
54
|
"@storybook/addon-interactions": "^7.0.9",
|
|
56
55
|
"@storybook/addon-styling": "^1.0.6",
|
|
57
56
|
"@storybook/builder-vite": "^7.0.9",
|
|
58
|
-
"@storybook/jest": "^0.1.0",
|
|
59
57
|
"@storybook/manager-api": "^7.0.9",
|
|
60
58
|
"@storybook/mdx2-csf": "^1.0.0",
|
|
61
59
|
"@storybook/preview-api": "^7.0.9",
|
|
62
60
|
"@storybook/react": "^7.0.9",
|
|
63
61
|
"@storybook/react-vite": "^7.0.9",
|
|
64
|
-
"@storybook/test-runner": "^0.10.0",
|
|
65
|
-
"@storybook/testing-library": "^0.1.0",
|
|
66
62
|
"@storybook/theming": "^7.0.9",
|
|
67
63
|
"@testing-library/cypress": "^8.0.7",
|
|
68
|
-
"@testing-library/jest-dom": "^5.16.5",
|
|
69
64
|
"@testing-library/react": "^13.4.0",
|
|
70
65
|
"@testing-library/react-hooks": "^8.0.1",
|
|
71
66
|
"@types/jest": "^27.5.0",
|
|
72
67
|
"@types/ramda": "^0.28.12",
|
|
73
68
|
"@types/react": "^18.0.26",
|
|
74
|
-
"@types/testing-library__jest-dom": "^5.14.6",
|
|
75
69
|
"@vitejs/plugin-react": "^4.0.0",
|
|
76
70
|
"@vitejs/plugin-react-swc": "^3.3.0",
|
|
77
71
|
"axios-mock-adapter": "^1.21.4",
|
|
@@ -89,7 +83,6 @@
|
|
|
89
83
|
"storybook": "^7.0.9",
|
|
90
84
|
"storybook-addon-mock": "^4.0.0",
|
|
91
85
|
"storybook-dark-mode": "^3.0.0",
|
|
92
|
-
"use-resize-observer": "^9.1.0",
|
|
93
86
|
"vite": "^4.3.5",
|
|
94
87
|
"vite-plugin-svgr": "^3.2.0",
|
|
95
88
|
"vite-plugin-turbosnap": "^1.0.2"
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { makeStyles } from 'tss-react/mui';
|
|
2
|
+
import { T, always, cond, equals } from 'ramda';
|
|
3
|
+
|
|
4
|
+
import { SvgIconComponent } from '@mui/icons-material';
|
|
5
|
+
import {
|
|
6
|
+
FormControlLabel,
|
|
7
|
+
Checkbox as MuiCheckbox,
|
|
8
|
+
Box,
|
|
9
|
+
Typography
|
|
10
|
+
} from '@mui/material';
|
|
11
|
+
|
|
12
|
+
export type LabelPlacement = 'bottom' | 'top' | 'end' | 'start' | undefined;
|
|
13
|
+
|
|
14
|
+
interface StyleProps {
|
|
15
|
+
disabled: boolean;
|
|
16
|
+
hasIcon: boolean;
|
|
17
|
+
labelPlacement: LabelPlacement;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const getLabelSpacing = (labelPlacement, theme): string => {
|
|
21
|
+
return cond([
|
|
22
|
+
[equals('top'), always(theme.spacing(0, 0, 0.5))],
|
|
23
|
+
[equals('end'), always(theme.spacing(0, 0, 0, 0.5))],
|
|
24
|
+
[T, always(0)]
|
|
25
|
+
])(labelPlacement);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const useStyles = makeStyles<StyleProps>()(
|
|
29
|
+
(theme, { disabled, hasIcon, labelPlacement }) => ({
|
|
30
|
+
container: hasIcon
|
|
31
|
+
? {
|
|
32
|
+
alignItems: 'center',
|
|
33
|
+
display: 'flex',
|
|
34
|
+
flexDirection: 'column',
|
|
35
|
+
justifyContent: 'space-between',
|
|
36
|
+
minHeight: theme.spacing(11)
|
|
37
|
+
}
|
|
38
|
+
: {},
|
|
39
|
+
icon: {
|
|
40
|
+
fontSize: theme.spacing(10)
|
|
41
|
+
},
|
|
42
|
+
label: {
|
|
43
|
+
color: disabled
|
|
44
|
+
? theme.palette.action.disabled
|
|
45
|
+
: theme.palette.text.secondary,
|
|
46
|
+
fontSize: theme.typography.body1.fontSize,
|
|
47
|
+
fontWeight: equals(labelPlacement, 'top')
|
|
48
|
+
? theme.typography.fontWeightBold
|
|
49
|
+
: theme.typography.fontWeightMedium,
|
|
50
|
+
padding: getLabelSpacing(labelPlacement, theme)
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
interface Props {
|
|
56
|
+
Icon?: SvgIconComponent;
|
|
57
|
+
checked: boolean;
|
|
58
|
+
className?: string;
|
|
59
|
+
dataTestId?: string;
|
|
60
|
+
disabled?: boolean;
|
|
61
|
+
label: string;
|
|
62
|
+
labelPlacement?: LabelPlacement;
|
|
63
|
+
onChange?: (e) => void;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const Checkbox = ({
|
|
67
|
+
Icon,
|
|
68
|
+
checked,
|
|
69
|
+
label,
|
|
70
|
+
onChange,
|
|
71
|
+
className,
|
|
72
|
+
disabled = false,
|
|
73
|
+
labelPlacement = 'end',
|
|
74
|
+
dataTestId
|
|
75
|
+
}: Props): JSX.Element => {
|
|
76
|
+
const { classes, cx } = useStyles({
|
|
77
|
+
disabled,
|
|
78
|
+
hasIcon: !!Icon,
|
|
79
|
+
labelPlacement
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<Box className={cx(classes.container, className)}>
|
|
84
|
+
{Icon && <Icon className={classes.icon} />}
|
|
85
|
+
<FormControlLabel
|
|
86
|
+
control={
|
|
87
|
+
<MuiCheckbox
|
|
88
|
+
checked={checked}
|
|
89
|
+
color="primary"
|
|
90
|
+
disabled={disabled}
|
|
91
|
+
id={label}
|
|
92
|
+
size="small"
|
|
93
|
+
sx={{ padding: 0 }}
|
|
94
|
+
onChange={onChange}
|
|
95
|
+
/>
|
|
96
|
+
}
|
|
97
|
+
data-testid={dataTestId || ''}
|
|
98
|
+
key={label}
|
|
99
|
+
label={<Typography className={classes.label}>{label}</Typography>}
|
|
100
|
+
labelPlacement={labelPlacement}
|
|
101
|
+
sx={{ margin: 0, padding: 0 }}
|
|
102
|
+
/>
|
|
103
|
+
</Box>
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export default Checkbox;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
2
|
+
|
|
3
|
+
import CheckboxGroup from '.';
|
|
4
|
+
|
|
5
|
+
const options = ['ok', 'warning', 'critical', 'unknown'];
|
|
6
|
+
|
|
7
|
+
const values = ['ok', 'critical'];
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
argTypes: {},
|
|
11
|
+
component: CheckboxGroup,
|
|
12
|
+
title: 'Checkbox/Multi'
|
|
13
|
+
} as ComponentMeta<typeof CheckboxGroup>;
|
|
14
|
+
|
|
15
|
+
const Template: ComponentStory<typeof CheckboxGroup> = (args) => (
|
|
16
|
+
<CheckboxGroup {...args} />
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
export const Playground = Template.bind({});
|
|
20
|
+
|
|
21
|
+
Playground.args = {
|
|
22
|
+
options,
|
|
23
|
+
values
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const Horizontal = Template.bind({});
|
|
27
|
+
|
|
28
|
+
Horizontal.args = {
|
|
29
|
+
direction: 'horizontal',
|
|
30
|
+
options,
|
|
31
|
+
values
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const LabelOnTop = Template.bind({});
|
|
35
|
+
|
|
36
|
+
LabelOnTop.args = {
|
|
37
|
+
direction: 'horizontal',
|
|
38
|
+
labelPlacement: 'top',
|
|
39
|
+
options,
|
|
40
|
+
values
|
|
41
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { equals, includes } from 'ramda';
|
|
2
|
+
import { makeStyles } from 'tss-react/mui';
|
|
3
|
+
|
|
4
|
+
import { FormGroup } from '@mui/material';
|
|
5
|
+
|
|
6
|
+
import Checkbox, { LabelPlacement } from '../Checkbox';
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
dataTestId?: string;
|
|
10
|
+
direction?: 'horizontal' | 'vertical';
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
labelPlacement?: LabelPlacement;
|
|
13
|
+
onChange?: (e) => void;
|
|
14
|
+
options: Array<string>;
|
|
15
|
+
values: Array<string>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const useStyles = makeStyles()((theme) => ({
|
|
19
|
+
checkbox: {
|
|
20
|
+
display: 'flex',
|
|
21
|
+
justifyContent: 'center',
|
|
22
|
+
minWidth: theme.spacing(10)
|
|
23
|
+
},
|
|
24
|
+
container: {
|
|
25
|
+
display: 'flex',
|
|
26
|
+
gap: 1
|
|
27
|
+
}
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
const CheckboxGroup = ({
|
|
31
|
+
options,
|
|
32
|
+
values,
|
|
33
|
+
direction = 'vertical',
|
|
34
|
+
onChange,
|
|
35
|
+
labelPlacement = 'end',
|
|
36
|
+
disabled = false,
|
|
37
|
+
dataTestId
|
|
38
|
+
}: Props): JSX.Element => {
|
|
39
|
+
const { classes } = useStyles();
|
|
40
|
+
|
|
41
|
+
const row = !equals(direction, 'vertical');
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<FormGroup
|
|
45
|
+
className={classes.container}
|
|
46
|
+
data-testid={dataTestId || ''}
|
|
47
|
+
row={row}
|
|
48
|
+
>
|
|
49
|
+
{options.map((value) => {
|
|
50
|
+
return (
|
|
51
|
+
<Checkbox
|
|
52
|
+
checked={includes(value, values)}
|
|
53
|
+
className={classes.checkbox}
|
|
54
|
+
disabled={disabled}
|
|
55
|
+
key={value}
|
|
56
|
+
label={value}
|
|
57
|
+
labelPlacement={labelPlacement}
|
|
58
|
+
onChange={onChange}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
})}
|
|
62
|
+
</FormGroup>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export default CheckboxGroup;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
2
|
+
|
|
3
|
+
import MailIcon from '@mui/icons-material/MailOutline';
|
|
4
|
+
|
|
5
|
+
import Checkbox from './Checkbox';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
argTypes: {},
|
|
9
|
+
component: Checkbox,
|
|
10
|
+
title: 'Checkbox/Single'
|
|
11
|
+
} as ComponentMeta<typeof Checkbox>;
|
|
12
|
+
|
|
13
|
+
const Template: ComponentStory<typeof Checkbox> = (args) => (
|
|
14
|
+
<Checkbox {...args} />
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
export const Playground = Template.bind({});
|
|
18
|
+
|
|
19
|
+
Playground.args = {
|
|
20
|
+
checked: true,
|
|
21
|
+
label: 'Up'
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const WithIcon = Template.bind({});
|
|
25
|
+
|
|
26
|
+
WithIcon.args = {
|
|
27
|
+
Icon: MailIcon,
|
|
28
|
+
checked: true,
|
|
29
|
+
label: 'Mail',
|
|
30
|
+
labelPlacement: 'end'
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const LabelOnTop = Template.bind({});
|
|
34
|
+
|
|
35
|
+
LabelOnTop.args = {
|
|
36
|
+
checked: true,
|
|
37
|
+
label: 'Down',
|
|
38
|
+
labelPlacement: 'top'
|
|
39
|
+
};
|
|
@@ -2,67 +2,69 @@ import { makeStyles } from 'tss-react/mui';
|
|
|
2
2
|
|
|
3
3
|
import { alpha } from '@mui/material';
|
|
4
4
|
|
|
5
|
-
export const useDashboardLayoutStyles = makeStyles()(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
5
|
+
export const useDashboardLayoutStyles = makeStyles<boolean>()(
|
|
6
|
+
(theme, isStatic: boolean) => ({
|
|
7
|
+
container: {
|
|
8
|
+
'& .react-grid-item': {
|
|
9
|
+
borderRadius: theme.shape.borderRadius,
|
|
10
|
+
transition: theme.transitions.create('all', {
|
|
11
|
+
delay: 0,
|
|
12
|
+
duration: 100,
|
|
13
|
+
easing: theme.transitions.easing.easeOut
|
|
14
|
+
})
|
|
15
|
+
},
|
|
16
|
+
'& .react-grid-item.react-draggable-dragging': {
|
|
17
|
+
boxShadow: theme.shadows[3]
|
|
18
|
+
},
|
|
19
|
+
'& .react-grid-item.react-grid-placeholder': {
|
|
20
|
+
backgroundColor: alpha(theme.palette.primary.main, 0.7)
|
|
21
|
+
},
|
|
22
|
+
'& .react-grid-item.resizing': {
|
|
23
|
+
boxShadow: theme.shadows[3]
|
|
24
|
+
},
|
|
25
|
+
'& .react-resizable-handle': {
|
|
26
|
+
backgroundColor: theme.palette.action.focus,
|
|
27
|
+
backgroundImage: 'none',
|
|
28
|
+
borderRadius: theme.shape.borderRadius,
|
|
29
|
+
display: isStatic ? 'none' : 'block',
|
|
30
|
+
opacity: 0,
|
|
31
|
+
position: 'absolute'
|
|
32
|
+
},
|
|
33
|
+
'& .react-resizable-handle.react-resizable-handle-e': {
|
|
34
|
+
cursor: 'ew-resize',
|
|
35
|
+
height: `calc(100% - ${theme.spacing(3)})`,
|
|
36
|
+
marginTop: 0,
|
|
37
|
+
right: 0,
|
|
38
|
+
top: 0,
|
|
39
|
+
transform: 'rotate(0deg)',
|
|
40
|
+
width: theme.spacing(1)
|
|
41
|
+
},
|
|
42
|
+
'& .react-resizable-handle.react-resizable-handle-s': {
|
|
43
|
+
bottom: 0,
|
|
44
|
+
cursor: 'ns-resize',
|
|
45
|
+
height: theme.spacing(1),
|
|
46
|
+
left: 0,
|
|
47
|
+
marginLeft: 0,
|
|
48
|
+
transform: 'rotate(0deg)',
|
|
49
|
+
width: `calc(100% - ${theme.spacing(3)})`
|
|
50
|
+
},
|
|
51
|
+
'& .react-resizable-handle.react-resizable-handle-se': {
|
|
52
|
+
bottom: 0,
|
|
53
|
+
cursor: 'nwse-resize',
|
|
54
|
+
height: theme.spacing(2),
|
|
55
|
+
right: 0,
|
|
56
|
+
transform: 'rotate(0deg)',
|
|
57
|
+
width: theme.spacing(2)
|
|
58
|
+
},
|
|
59
|
+
'& .react-resizable-handle::after': {
|
|
60
|
+
content: 'none'
|
|
61
|
+
},
|
|
62
|
+
'& .react-resizable-handle:hover': {
|
|
63
|
+
opacity: 1
|
|
64
|
+
}
|
|
63
65
|
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
+
})
|
|
67
|
+
);
|
|
66
68
|
|
|
67
69
|
export const useDashboardItemStyles = makeStyles()((theme) => ({
|
|
68
70
|
widgetContainer: {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
|
|
1
3
|
import { ComponentMeta } from '@storybook/react';
|
|
2
4
|
import { Layout } from 'react-grid-layout';
|
|
3
5
|
|
|
@@ -60,18 +62,18 @@ const generateLayout = (maxElements: number): Array<CustomLayout> => {
|
|
|
60
62
|
};
|
|
61
63
|
|
|
62
64
|
interface DashboardTemplateProps {
|
|
63
|
-
header?:
|
|
65
|
+
header?: ReactElement;
|
|
64
66
|
layout?: Array<CustomLayout>;
|
|
65
67
|
}
|
|
66
68
|
|
|
67
|
-
const Header = ():
|
|
69
|
+
const Header = (): ReactElement => (
|
|
68
70
|
<Typography variant="body2">The title</Typography>
|
|
69
71
|
);
|
|
70
72
|
|
|
71
73
|
const DashboardTemplate = ({
|
|
72
74
|
header,
|
|
73
75
|
layout = dashboardLayout
|
|
74
|
-
}: DashboardTemplateProps):
|
|
76
|
+
}: DashboardTemplateProps): ReactElement => (
|
|
75
77
|
<DashboardLayout.Layout<CustomLayout> layout={layout}>
|
|
76
78
|
{layout.map(({ i, content, shouldUseFluidTypography }) => (
|
|
77
79
|
<DashboardLayout.Item header={header} key={i}>
|
package/src/Dashboard/Grid.tsx
CHANGED
package/src/Dashboard/Item.tsx
CHANGED
|
@@ -18,7 +18,7 @@ interface DashboardItemProps {
|
|
|
18
18
|
children: ReactElement;
|
|
19
19
|
className?: string;
|
|
20
20
|
header?: ReactElement;
|
|
21
|
-
|
|
21
|
+
id: string;
|
|
22
22
|
onMouseDown?: (e: MouseEvent<HTMLDivElement>) => void;
|
|
23
23
|
onMouseUp?: (e: MouseEvent<HTMLDivElement>) => void;
|
|
24
24
|
onTouchEnd?: (e) => void;
|
|
@@ -29,13 +29,13 @@ const Item = forwardRef(
|
|
|
29
29
|
(
|
|
30
30
|
{
|
|
31
31
|
children,
|
|
32
|
-
key,
|
|
33
32
|
style,
|
|
34
33
|
className,
|
|
35
34
|
header,
|
|
36
35
|
onMouseDown,
|
|
37
36
|
onMouseUp,
|
|
38
|
-
onTouchEnd
|
|
37
|
+
onTouchEnd,
|
|
38
|
+
id
|
|
39
39
|
}: DashboardItemProps,
|
|
40
40
|
ref: ForwardedRef<HTMLDivElement>
|
|
41
41
|
): ReactElement => {
|
|
@@ -55,14 +55,17 @@ const Item = forwardRef(
|
|
|
55
55
|
Component: (
|
|
56
56
|
<div
|
|
57
57
|
className={className}
|
|
58
|
-
key={key}
|
|
59
58
|
ref={ref}
|
|
60
59
|
style={style}
|
|
61
60
|
{...cardContainerListeners}
|
|
62
61
|
>
|
|
63
62
|
<Card className={classes.widgetContainer}>
|
|
64
63
|
{header && (
|
|
65
|
-
<div
|
|
64
|
+
<div
|
|
65
|
+
{...listeners}
|
|
66
|
+
className={classes.widgetHeader}
|
|
67
|
+
data-testid={`${id}_move_panel`}
|
|
68
|
+
>
|
|
66
69
|
{header}
|
|
67
70
|
</div>
|
|
68
71
|
)}
|
|
@@ -70,7 +73,7 @@ const Item = forwardRef(
|
|
|
70
73
|
</Card>
|
|
71
74
|
</div>
|
|
72
75
|
),
|
|
73
|
-
memoProps: [
|
|
76
|
+
memoProps: [style, className, header]
|
|
74
77
|
});
|
|
75
78
|
}
|
|
76
79
|
);
|
package/src/Dashboard/Layout.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
1
|
+
import { ReactElement, useEffect, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import { Responsive } from '@visx/visx';
|
|
4
4
|
import GridLayout, { Layout, WidthProvider } from 'react-grid-layout';
|
|
@@ -14,7 +14,7 @@ const ReactGridLayout = WidthProvider(GridLayout);
|
|
|
14
14
|
|
|
15
15
|
interface DashboardLayoutProps<T> {
|
|
16
16
|
changeLayout?: (newLayout: Array<Layout>) => void;
|
|
17
|
-
children: Array<
|
|
17
|
+
children: Array<ReactElement>;
|
|
18
18
|
displayGrid?: boolean;
|
|
19
19
|
layout: Array<T>;
|
|
20
20
|
}
|
|
@@ -24,7 +24,7 @@ const Layout = <T extends Layout>({
|
|
|
24
24
|
changeLayout,
|
|
25
25
|
displayGrid,
|
|
26
26
|
layout
|
|
27
|
-
}: DashboardLayoutProps<T>):
|
|
27
|
+
}: DashboardLayoutProps<T>): ReactElement => {
|
|
28
28
|
const { classes } = useDashboardLayoutStyles();
|
|
29
29
|
|
|
30
30
|
const [columns, setColumns] = useState(getColumnsFromScreenSize());
|
|
@@ -45,7 +45,7 @@ const Layout = <T extends Layout>({
|
|
|
45
45
|
Component: (
|
|
46
46
|
<ResponsiveHeight>
|
|
47
47
|
<Responsive.ParentSize>
|
|
48
|
-
{({ width, height }):
|
|
48
|
+
{({ width, height }): ReactElement => (
|
|
49
49
|
<div className={classes.container}>
|
|
50
50
|
{displayGrid && (
|
|
51
51
|
<Grid columns={columns} height={height} width={width} />
|
package/src/Dashboard/utils.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { lt } from 'ramda';
|
|
2
|
-
import { Layout } from 'react-grid-layout';
|
|
3
|
-
|
|
4
|
-
export const maxColumns = 12;
|
|
5
|
-
const minColumns = 1;
|
|
6
|
-
const breakpoint = 768;
|
|
7
|
-
|
|
8
|
-
export const rowHeight = 64;
|
|
9
|
-
|
|
10
|
-
export const getIsSmallScreenSize = (): boolean =>
|
|
11
|
-
lt(window.innerWidth, breakpoint);
|
|
12
|
-
|
|
13
|
-
export const getColumnsFromScreenSize = (): number =>
|
|
14
|
-
getIsSmallScreenSize() ? minColumns : maxColumns;
|
|
15
|
-
|
|
16
|
-
export const getLayout = <T extends Layout>(layout: Array<T>): Array<T> => {
|
|
17
|
-
const isSmallScreenSize = getIsSmallScreenSize();
|
|
18
|
-
if (!isSmallScreenSize) {
|
|
19
|
-
return layout;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return layout
|
|
23
|
-
.sort((a, b) => a.x + a.y - (b.x + b.y))
|
|
24
|
-
.map((widget) => ({
|
|
25
|
-
...widget,
|
|
26
|
-
w: 1
|
|
27
|
-
}));
|
|
28
|
-
};
|
|
1
|
+
import { lt } from 'ramda';
|
|
2
|
+
import { Layout } from 'react-grid-layout';
|
|
3
|
+
|
|
4
|
+
export const maxColumns = 12;
|
|
5
|
+
const minColumns = 1;
|
|
6
|
+
const breakpoint = 768;
|
|
7
|
+
|
|
8
|
+
export const rowHeight = 64;
|
|
9
|
+
|
|
10
|
+
export const getIsSmallScreenSize = (): boolean =>
|
|
11
|
+
lt(window.innerWidth, breakpoint);
|
|
12
|
+
|
|
13
|
+
export const getColumnsFromScreenSize = (): number =>
|
|
14
|
+
getIsSmallScreenSize() ? minColumns : maxColumns;
|
|
15
|
+
|
|
16
|
+
export const getLayout = <T extends Layout>(layout: Array<T>): Array<T> => {
|
|
17
|
+
const isSmallScreenSize = getIsSmallScreenSize();
|
|
18
|
+
if (!isSmallScreenSize) {
|
|
19
|
+
return layout;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return layout
|
|
23
|
+
.sort((a, b) => a.x + a.y - (b.x + b.y))
|
|
24
|
+
.map((widget) => ({
|
|
25
|
+
...widget,
|
|
26
|
+
w: 1
|
|
27
|
+
}));
|
|
28
|
+
};
|
|
@@ -1,12 +1,22 @@
|
|
|
1
|
-
import DialogContentText from '@mui/material
|
|
1
|
+
import { DialogContentText, Typography } from '@mui/material';
|
|
2
2
|
|
|
3
3
|
import Dialog, { Props as DialogProps } from '..';
|
|
4
4
|
|
|
5
|
-
type Props = DialogProps & {
|
|
5
|
+
type Props = DialogProps & {
|
|
6
|
+
labelMessage?: string | null;
|
|
7
|
+
labelSecondMessage?: string | null;
|
|
8
|
+
};
|
|
6
9
|
|
|
7
|
-
const Confirm = ({
|
|
10
|
+
const Confirm = ({
|
|
11
|
+
labelMessage,
|
|
12
|
+
labelSecondMessage,
|
|
13
|
+
...rest
|
|
14
|
+
}: Props): JSX.Element => (
|
|
8
15
|
<Dialog {...rest}>
|
|
9
|
-
|
|
16
|
+
<DialogContentText>
|
|
17
|
+
{labelMessage && <Typography>{labelMessage}</Typography>}
|
|
18
|
+
{labelSecondMessage && <Typography>{labelSecondMessage}</Typography>}
|
|
19
|
+
</DialogContentText>
|
|
10
20
|
</Dialog>
|
|
11
21
|
);
|
|
12
22
|
|
package/src/Dialog/index.tsx
CHANGED
|
@@ -35,6 +35,7 @@ export type Props = {
|
|
|
35
35
|
confirmDisabled?: boolean;
|
|
36
36
|
contentWidth?: number;
|
|
37
37
|
dialogActionsClassName?: string;
|
|
38
|
+
dialogConfirmButtonClassName?: string;
|
|
38
39
|
dialogContentClassName?: string;
|
|
39
40
|
dialogPaperClassName?: string;
|
|
40
41
|
dialogTitleClassName?: string;
|
|
@@ -65,6 +66,7 @@ const Dialog = ({
|
|
|
65
66
|
dialogTitleClassName,
|
|
66
67
|
dialogContentClassName,
|
|
67
68
|
dialogActionsClassName,
|
|
69
|
+
dialogConfirmButtonClassName,
|
|
68
70
|
...rest
|
|
69
71
|
}: Props): JSX.Element => {
|
|
70
72
|
const { classes, cx } = useStyles({ contentWidth });
|
|
@@ -97,6 +99,7 @@ const Dialog = ({
|
|
|
97
99
|
)}
|
|
98
100
|
<Button
|
|
99
101
|
aria-label={labelConfirm || ''}
|
|
102
|
+
className={dialogConfirmButtonClassName}
|
|
100
103
|
color="primary"
|
|
101
104
|
disabled={confirmDisabled}
|
|
102
105
|
endIcon={submitting && <CircularProgress size={15} />}
|