@centreon/ui 23.10.54 → 23.10.56
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 -1
- package/src/Form/Inputs/index.tsx +1 -3
- package/src/Form/Inputs/models.ts +1 -1
- package/src/RichTextEditor/ContentEditable.tsx +4 -0
- package/src/components/Avatar/Avatar.stories.tsx +23 -0
- package/src/components/Avatar/Avatar.styles.ts +11 -0
- package/src/components/Avatar/Avatar.tsx +32 -0
- package/src/components/Avatar/index.ts +1 -0
- package/src/components/CollapsibleItem/CollapsibleItem.stories.tsx +25 -0
- package/src/components/CollapsibleItem/CollapsibleItem.tsx +47 -0
- package/src/components/CollapsibleItem/index.ts +1 -0
- package/src/components/CollapsibleItem/useCollapsibleItemStyles.ts +14 -0
- package/src/components/ItemComposition/Item.tsx +13 -9
- package/src/components/ItemComposition/ItemComposition.tsx +17 -13
- package/src/components/Modal/Modal.stories.tsx +32 -1
- package/src/components/Modal/Modal.styles.ts +29 -2
- package/src/components/Modal/Modal.tsx +23 -3
- package/src/components/index.ts +2 -0
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Fragment, useMemo } from 'react';
|
|
2
2
|
|
|
3
3
|
import * as R from 'ramda';
|
|
4
|
-
import { useTranslation } from 'react-i18next';
|
|
5
4
|
import { makeStyles } from 'tss-react/mui';
|
|
6
5
|
import { FormikValues, useFormikContext } from 'formik';
|
|
7
6
|
|
|
@@ -126,7 +125,6 @@ const Inputs = ({
|
|
|
126
125
|
areGroupsOpen
|
|
127
126
|
}: Props): JSX.Element => {
|
|
128
127
|
const { classes, cx } = useStyles({ groupDirection });
|
|
129
|
-
const { t } = useTranslation();
|
|
130
128
|
const formikContext = useFormikContext<FormikValues>();
|
|
131
129
|
|
|
132
130
|
const groupsName = R.pluck('name', groups);
|
|
@@ -228,7 +226,7 @@ const Inputs = ({
|
|
|
228
226
|
)}
|
|
229
227
|
variant="body1"
|
|
230
228
|
>
|
|
231
|
-
{
|
|
229
|
+
{inputProps.additionalLabel}
|
|
232
230
|
</Typography>
|
|
233
231
|
)}
|
|
234
232
|
<div className={inputProps?.inputClassName || ''}>
|
|
@@ -29,7 +29,7 @@ interface FieldsTableGetRequiredProps {
|
|
|
29
29
|
export type LabelPlacement = 'bottom' | 'top' | 'end' | 'start' | undefined;
|
|
30
30
|
|
|
31
31
|
export interface InputProps {
|
|
32
|
-
additionalLabel?: string;
|
|
32
|
+
additionalLabel?: string | JSX.Element;
|
|
33
33
|
additionalLabelClassName?: string;
|
|
34
34
|
additionalMemoProps?: Array<unknown>;
|
|
35
35
|
autocomplete?: {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
|
|
3
|
+
import Avatar from './Avatar';
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof Avatar> = {
|
|
6
|
+
component: Avatar
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default meta;
|
|
10
|
+
type Story = StoryObj<typeof Avatar>;
|
|
11
|
+
|
|
12
|
+
export const Default: Story = {
|
|
13
|
+
args: {
|
|
14
|
+
children: 'Label'
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const compact: Story = {
|
|
19
|
+
args: {
|
|
20
|
+
...Default.args,
|
|
21
|
+
compact: true
|
|
22
|
+
}
|
|
23
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { makeStyles } from 'tss-react/mui';
|
|
2
|
+
|
|
3
|
+
export const useAvatarStyles = makeStyles()((theme) => ({
|
|
4
|
+
avatar: {
|
|
5
|
+
'&[data-compact="true"]': {
|
|
6
|
+
fontSize: theme.typography.body1.fontSize,
|
|
7
|
+
height: theme.spacing(2),
|
|
8
|
+
width: theme.spacing(2)
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}));
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import { AvatarProps, Avatar as MUIAvatar } from '@mui/material';
|
|
4
|
+
|
|
5
|
+
import { useAvatarStyles } from './Avatar.styles';
|
|
6
|
+
|
|
7
|
+
interface Props extends AvatarProps {
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
className?: string;
|
|
10
|
+
compact?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const Avatar = ({
|
|
14
|
+
compact = false,
|
|
15
|
+
children,
|
|
16
|
+
className,
|
|
17
|
+
...attr
|
|
18
|
+
}: Props): JSX.Element => {
|
|
19
|
+
const { classes, cx } = useAvatarStyles();
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<MUIAvatar
|
|
23
|
+
{...attr}
|
|
24
|
+
className={cx(classes.avatar, className)}
|
|
25
|
+
data-compact={`${compact}`}
|
|
26
|
+
>
|
|
27
|
+
{children}
|
|
28
|
+
</MUIAvatar>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default Avatar;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Avatar } from './Avatar';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
|
|
3
|
+
import { CollapsibleItem } from './CollapsibleItem';
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof CollapsibleItem> = {
|
|
6
|
+
component: CollapsibleItem
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default meta;
|
|
10
|
+
type Story = StoryObj<typeof CollapsibleItem>;
|
|
11
|
+
|
|
12
|
+
export const Default: Story = {
|
|
13
|
+
args: {
|
|
14
|
+
children: 'Label',
|
|
15
|
+
title: 'Title'
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const ExpandedByDefault: Story = {
|
|
20
|
+
args: {
|
|
21
|
+
children: 'Label',
|
|
22
|
+
defaultExpanded: true,
|
|
23
|
+
title: 'Title'
|
|
24
|
+
}
|
|
25
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
AccordionDetails,
|
|
5
|
+
AccordionSummary,
|
|
6
|
+
Accordion,
|
|
7
|
+
Typography
|
|
8
|
+
} from '@mui/material';
|
|
9
|
+
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
10
|
+
|
|
11
|
+
import { useCollapsibleItemStyles } from './useCollapsibleItemStyles';
|
|
12
|
+
|
|
13
|
+
interface Props {
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
defaultExpanded?: boolean;
|
|
16
|
+
title: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const CollapsibleItem = ({
|
|
20
|
+
title,
|
|
21
|
+
children,
|
|
22
|
+
defaultExpanded
|
|
23
|
+
}: Props): JSX.Element => {
|
|
24
|
+
const { classes } = useCollapsibleItemStyles();
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<Accordion
|
|
28
|
+
disableGutters
|
|
29
|
+
className={classes.accordion}
|
|
30
|
+
defaultExpanded={defaultExpanded}
|
|
31
|
+
>
|
|
32
|
+
<AccordionSummary
|
|
33
|
+
classes={{
|
|
34
|
+
content: classes.accordionSummary
|
|
35
|
+
}}
|
|
36
|
+
expandIcon={<ExpandMoreIcon color="primary" />}
|
|
37
|
+
>
|
|
38
|
+
<Typography color="primary" variant="h6">
|
|
39
|
+
{title}
|
|
40
|
+
</Typography>
|
|
41
|
+
</AccordionSummary>
|
|
42
|
+
<AccordionDetails className={classes.accordionDetails}>
|
|
43
|
+
{children}
|
|
44
|
+
</AccordionDetails>
|
|
45
|
+
</Accordion>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CollapsibleItem } from './CollapsibleItem';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { makeStyles } from 'tss-react/mui';
|
|
2
|
+
|
|
3
|
+
export const useCollapsibleItemStyles = makeStyles()((theme) => ({
|
|
4
|
+
accordion: {
|
|
5
|
+
border: 'none',
|
|
6
|
+
borderBottom: `1px solid ${theme.palette.divider}`
|
|
7
|
+
},
|
|
8
|
+
accordionDetails: {
|
|
9
|
+
padding: theme.spacing(0, 2, 2)
|
|
10
|
+
},
|
|
11
|
+
accordionSummary: {
|
|
12
|
+
margin: theme.spacing(1.5, 0)
|
|
13
|
+
}
|
|
14
|
+
}));
|
|
@@ -9,6 +9,7 @@ import { useItemStyles } from './ItemComposition.styles';
|
|
|
9
9
|
type Props = {
|
|
10
10
|
children: Array<ReactElement>;
|
|
11
11
|
className?: string;
|
|
12
|
+
deleteButtonHidden?: boolean;
|
|
12
13
|
labelDelete: string;
|
|
13
14
|
onDeleteItem: () => void;
|
|
14
15
|
};
|
|
@@ -17,21 +18,24 @@ export const Item = ({
|
|
|
17
18
|
onDeleteItem,
|
|
18
19
|
children,
|
|
19
20
|
labelDelete,
|
|
20
|
-
className
|
|
21
|
+
className,
|
|
22
|
+
deleteButtonHidden
|
|
21
23
|
}: Props): JSX.Element => {
|
|
22
24
|
const { classes, cx } = useItemStyles();
|
|
23
25
|
|
|
24
26
|
return (
|
|
25
27
|
<div className={classes.itemContainer}>
|
|
26
28
|
<div className={cx(classes.itemContent, className)}>{children}</div>
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
{!deleteButtonHidden && (
|
|
30
|
+
<IconButton
|
|
31
|
+
aria-label={labelDelete}
|
|
32
|
+
data-testid={labelDelete}
|
|
33
|
+
icon={<CloseIcon />}
|
|
34
|
+
size="small"
|
|
35
|
+
variant="ghost"
|
|
36
|
+
onClick={onDeleteItem}
|
|
37
|
+
/>
|
|
38
|
+
)}
|
|
35
39
|
</div>
|
|
36
40
|
);
|
|
37
41
|
};
|
|
@@ -7,6 +7,7 @@ import { Button } from '..';
|
|
|
7
7
|
import { useItemCompositionStyles } from './ItemComposition.styles';
|
|
8
8
|
|
|
9
9
|
type Props = {
|
|
10
|
+
addButtonHidden?: boolean;
|
|
10
11
|
addbuttonDisabled?: boolean;
|
|
11
12
|
children: Array<ReactElement>;
|
|
12
13
|
labelAdd: string;
|
|
@@ -17,25 +18,28 @@ export const ItemComposition = ({
|
|
|
17
18
|
onAddItem,
|
|
18
19
|
children,
|
|
19
20
|
labelAdd,
|
|
20
|
-
addbuttonDisabled
|
|
21
|
+
addbuttonDisabled,
|
|
22
|
+
addButtonHidden
|
|
21
23
|
}: Props): JSX.Element => {
|
|
22
24
|
const { classes } = useItemCompositionStyles();
|
|
23
25
|
|
|
24
26
|
return (
|
|
25
27
|
<div className={classes.itemCompositionContainer}>
|
|
26
28
|
{children}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
{!addButtonHidden && (
|
|
30
|
+
<Button
|
|
31
|
+
aria-label={labelAdd}
|
|
32
|
+
data-testid={labelAdd}
|
|
33
|
+
disabled={addbuttonDisabled}
|
|
34
|
+
icon={<AddIcon />}
|
|
35
|
+
iconVariant="start"
|
|
36
|
+
size="small"
|
|
37
|
+
variant="ghost"
|
|
38
|
+
onClick={onAddItem}
|
|
39
|
+
>
|
|
40
|
+
{labelAdd}
|
|
41
|
+
</Button>
|
|
42
|
+
)}
|
|
39
43
|
</div>
|
|
40
44
|
);
|
|
41
45
|
};
|
|
@@ -10,7 +10,7 @@ const meta: Meta<typeof Modal> = {
|
|
|
10
10
|
control: {
|
|
11
11
|
type: 'select'
|
|
12
12
|
},
|
|
13
|
-
options: ['small', 'medium', 'large']
|
|
13
|
+
options: ['small', 'medium', 'large', 'xlarge', 'fullscreen']
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
component: Modal
|
|
@@ -109,3 +109,34 @@ export const AsPassive: Story = {
|
|
|
109
109
|
</Modal>
|
|
110
110
|
)
|
|
111
111
|
};
|
|
112
|
+
|
|
113
|
+
export const fullscreenWithCustomMargins: Story = {
|
|
114
|
+
args: {
|
|
115
|
+
fullscreenMargins: {
|
|
116
|
+
bottom: 20,
|
|
117
|
+
left: 40,
|
|
118
|
+
right: 10,
|
|
119
|
+
top: 90
|
|
120
|
+
},
|
|
121
|
+
hasCloseButton: true,
|
|
122
|
+
open: true,
|
|
123
|
+
size: 'fullscreen'
|
|
124
|
+
},
|
|
125
|
+
render: (args) => (
|
|
126
|
+
<Modal {...args}>
|
|
127
|
+
<Modal.Header>Modal title</Modal.Header>
|
|
128
|
+
<Modal.Body>
|
|
129
|
+
<p>
|
|
130
|
+
Occaecat consectetur amet officia magna. Eu sunt aute duis duis cillum
|
|
131
|
+
irure mollit ex aute excepteur eu id cillum.
|
|
132
|
+
</p>
|
|
133
|
+
</Modal.Body>
|
|
134
|
+
<Modal.Actions
|
|
135
|
+
labels={{
|
|
136
|
+
cancel: 'Cancel',
|
|
137
|
+
confirm: 'Confirm'
|
|
138
|
+
}}
|
|
139
|
+
/>
|
|
140
|
+
</Modal>
|
|
141
|
+
)
|
|
142
|
+
};
|
|
@@ -1,11 +1,37 @@
|
|
|
1
1
|
import { makeStyles } from 'tss-react/mui';
|
|
2
2
|
|
|
3
|
-
const useStyles = makeStyles
|
|
3
|
+
const useStyles = makeStyles<{
|
|
4
|
+
bottom?: number;
|
|
5
|
+
left?: number;
|
|
6
|
+
right?: number;
|
|
7
|
+
top?: number;
|
|
8
|
+
}>()((theme, props) => ({
|
|
4
9
|
modal: {
|
|
5
10
|
'& .MuiDialog-paper': {
|
|
6
11
|
gap: theme.spacing(2),
|
|
7
12
|
padding: theme.spacing(2)
|
|
8
13
|
},
|
|
14
|
+
'&[data-size="fullscreen"]': {
|
|
15
|
+
zIndex: 0
|
|
16
|
+
},
|
|
17
|
+
'&[data-size="fullscreen"] .MuiBackdrop-root': {
|
|
18
|
+
display: 'none'
|
|
19
|
+
},
|
|
20
|
+
'&[data-size="fullscreen"] .MuiDialog-container': {
|
|
21
|
+
alignItems: 'flex-end',
|
|
22
|
+
height: '100vh',
|
|
23
|
+
justifyContent: 'flex-end'
|
|
24
|
+
},
|
|
25
|
+
'&[data-size="fullscreen"] .MuiDialog-paper': {
|
|
26
|
+
bottom: props?.bottom ?? 0,
|
|
27
|
+
left: props?.left ?? 0,
|
|
28
|
+
margin: 0,
|
|
29
|
+
maxHeight: 'unset',
|
|
30
|
+
maxWidth: 'unset',
|
|
31
|
+
position: 'absolute',
|
|
32
|
+
right: props?.right ?? 0,
|
|
33
|
+
top: props?.top ?? 0
|
|
34
|
+
},
|
|
9
35
|
'&[data-size="large"] .MuiDialog-paper': {
|
|
10
36
|
maxWidth: '640px',
|
|
11
37
|
width: '640px'
|
|
@@ -35,7 +61,8 @@ const useStyles = makeStyles()((theme) => ({
|
|
|
35
61
|
color: theme.palette.text.secondary,
|
|
36
62
|
margin: theme.spacing(1, 0, 1, 0),
|
|
37
63
|
width: '90%'
|
|
38
|
-
}
|
|
64
|
+
},
|
|
65
|
+
height: '100%'
|
|
39
66
|
},
|
|
40
67
|
modalCloseButton: {
|
|
41
68
|
position: 'absolute',
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React, { ReactElement } from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { equals } from 'ramda';
|
|
4
|
+
|
|
5
|
+
import { Dialog as MuiDialog, Slide } from '@mui/material';
|
|
4
6
|
import { Close as CloseIcon } from '@mui/icons-material';
|
|
5
7
|
|
|
6
8
|
import { AriaLabelingAttributes } from '../../@types/aria-attributes';
|
|
@@ -10,13 +12,19 @@ import { useStyles } from './Modal.styles';
|
|
|
10
12
|
|
|
11
13
|
export type ModalProps = {
|
|
12
14
|
children: React.ReactNode;
|
|
15
|
+
fullscreenMargins?: {
|
|
16
|
+
bottom?: number;
|
|
17
|
+
left?: number;
|
|
18
|
+
right?: number;
|
|
19
|
+
top?: number;
|
|
20
|
+
};
|
|
13
21
|
hasCloseButton?: boolean;
|
|
14
22
|
onClose?: (
|
|
15
23
|
event: object,
|
|
16
24
|
reason: 'escapeKeyDown' | 'backdropClick' | 'closeButton'
|
|
17
25
|
) => void;
|
|
18
26
|
open: boolean;
|
|
19
|
-
size?: 'small' | 'medium' | 'large' | 'xlarge';
|
|
27
|
+
size?: 'small' | 'medium' | 'large' | 'xlarge' | 'fullscreen';
|
|
20
28
|
} & AriaLabelingAttributes;
|
|
21
29
|
|
|
22
30
|
/** *
|
|
@@ -28,12 +36,24 @@ const Modal = ({
|
|
|
28
36
|
onClose,
|
|
29
37
|
open,
|
|
30
38
|
size = 'small',
|
|
39
|
+
fullscreenMargins = {
|
|
40
|
+
bottom: 0,
|
|
41
|
+
left: 0,
|
|
42
|
+
right: 0,
|
|
43
|
+
top: 0
|
|
44
|
+
},
|
|
31
45
|
...attr
|
|
32
46
|
}: ModalProps): ReactElement => {
|
|
33
|
-
const { classes } = useStyles();
|
|
47
|
+
const { classes } = useStyles(fullscreenMargins);
|
|
48
|
+
|
|
49
|
+
const isFullscreen = equals(size, 'fullscreen');
|
|
34
50
|
|
|
35
51
|
return (
|
|
36
52
|
<MuiDialog
|
|
53
|
+
TransitionComponent={isFullscreen ? Slide : undefined}
|
|
54
|
+
TransitionProps={{
|
|
55
|
+
direction: 'up'
|
|
56
|
+
}}
|
|
37
57
|
className={classes.modal}
|
|
38
58
|
data-size={size}
|
|
39
59
|
open={open}
|