@centreon/ui 23.10.1-MON-20803-RS-add-basic-filter.25 → 23.10.1-MON-20803-RS-add-basic-filter.27
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/ActionsList/ActionsList.styles.ts +116 -0
- package/src/ActionsList/index.stories.tsx +74 -0
- package/src/ActionsList/index.tsx +20 -12
- package/src/ActionsList/models.ts +8 -0
- package/src/Checkbox/Checkbox.tsx +10 -10
- package/src/Listing/Listing.cypress.spec.tsx +17 -15
- package/src/Listing/Listing.styles.ts +5 -0
- package/src/Listing/index.stories.tsx +2 -1
- package/src/Listing/index.tsx +140 -151
- package/src/ListingPage/index.stories.tsx +21 -8
- package/src/ListingPage/index.tsx +19 -37
- package/src/RichTextEditor/RichTextEditor.cypress.spec.tsx +23 -0
- package/src/RichTextEditor/index.stories.tsx +4 -2
- package/src/RichTextEditor/plugins/ToolbarPlugin/AlignPicker.tsx +115 -0
- package/src/RichTextEditor/plugins/ToolbarPlugin/ToolbarPlugin.styles.ts +15 -0
- package/src/RichTextEditor/plugins/ToolbarPlugin/index.tsx +2 -0
- package/src/components/Menu/Button/MenuButton.tsx +3 -0
- package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.stories.tsx +62 -0
- package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.styles.tsx +19 -0
- package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.tsx +67 -0
- package/src/components/Tooltip/ConfirmationTooltip/TooltipContent.tsx +31 -0
- package/src/components/Tooltip/ConfirmationTooltip/index.ts +0 -0
- package/src/components/Tooltip/ConfirmationTooltip/models.ts +18 -0
- package/src/components/Tooltip/Tooltip.tsx +19 -8
- package/src/components/Tooltip/Tooltip.styles.ts +0 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@centreon/ui",
|
|
3
|
-
"version": "23.10.1-MON-20803-RS-add-basic-filter.
|
|
3
|
+
"version": "23.10.1-MON-20803-RS-add-basic-filter.27",
|
|
4
4
|
"description": "Centreon UI Components",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"eslint": "eslint ./src --ext .js,.jsx,.ts,.tsx --max-warnings 0",
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { makeStyles } from 'tss-react/mui';
|
|
2
|
+
import { equals } from 'ramda';
|
|
3
|
+
|
|
4
|
+
import { Theme, alpha } from '@mui/material';
|
|
5
|
+
|
|
6
|
+
interface GetBackgroundAndColorProps {
|
|
7
|
+
status: string;
|
|
8
|
+
theme: Theme;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const getColor = ({ theme, status }: GetBackgroundAndColorProps): string =>
|
|
12
|
+
equals(theme.palette.mode, 'dark')
|
|
13
|
+
? theme.palette.common.white
|
|
14
|
+
: theme.palette[status].main;
|
|
15
|
+
|
|
16
|
+
export const useStyles = makeStyles()((theme) => ({
|
|
17
|
+
item: {
|
|
18
|
+
'& .MuiListItemText-secondary': {
|
|
19
|
+
textWrap: 'pretty'
|
|
20
|
+
},
|
|
21
|
+
'&[data-variant="error"]': {
|
|
22
|
+
'& .MuiListItemIcon-root': {
|
|
23
|
+
color: getColor({ status: 'error', theme })
|
|
24
|
+
},
|
|
25
|
+
'&:hover': {
|
|
26
|
+
background: alpha(
|
|
27
|
+
theme.palette.error.main,
|
|
28
|
+
theme.palette.action.focusOpacity
|
|
29
|
+
),
|
|
30
|
+
color: getColor({ status: 'error', theme })
|
|
31
|
+
},
|
|
32
|
+
color: theme.palette.error.main
|
|
33
|
+
},
|
|
34
|
+
'&[data-variant="info"]': {
|
|
35
|
+
'& .MuiListItemIcon-root': {
|
|
36
|
+
color: getColor({ status: 'info', theme })
|
|
37
|
+
},
|
|
38
|
+
'&:hover': {
|
|
39
|
+
background: alpha(
|
|
40
|
+
theme.palette.info.main,
|
|
41
|
+
theme.palette.action.focusOpacity
|
|
42
|
+
),
|
|
43
|
+
color: getColor({ status: 'info', theme })
|
|
44
|
+
},
|
|
45
|
+
color: theme.palette.info.main
|
|
46
|
+
},
|
|
47
|
+
'&[data-variant="pending"]': {
|
|
48
|
+
'& .MuiListItemIcon-root': {
|
|
49
|
+
color: getColor({ status: 'pending', theme })
|
|
50
|
+
},
|
|
51
|
+
'&:hover': {
|
|
52
|
+
background: alpha(
|
|
53
|
+
theme.palette.pending.main,
|
|
54
|
+
theme.palette.action.focusOpacity
|
|
55
|
+
),
|
|
56
|
+
color: getColor({ status: 'pending', theme })
|
|
57
|
+
},
|
|
58
|
+
color: theme.palette.pending.main
|
|
59
|
+
},
|
|
60
|
+
'&[data-variant="primary"]': {
|
|
61
|
+
'& .MuiListItemIcon-root': {
|
|
62
|
+
color: getColor({ status: 'primary', theme })
|
|
63
|
+
},
|
|
64
|
+
'&:hover': {
|
|
65
|
+
background: alpha(
|
|
66
|
+
theme.palette.primary.main,
|
|
67
|
+
theme.palette.action.focusOpacity
|
|
68
|
+
),
|
|
69
|
+
color: getColor({ status: 'primary', theme })
|
|
70
|
+
},
|
|
71
|
+
color: theme.palette.primary.main
|
|
72
|
+
},
|
|
73
|
+
'&[data-variant="secondary"]': {
|
|
74
|
+
'& .MuiListItemIcon-root': {
|
|
75
|
+
color: getColor({ status: 'secondary', theme })
|
|
76
|
+
},
|
|
77
|
+
'&:hover': {
|
|
78
|
+
background: alpha(
|
|
79
|
+
theme.palette.secondary.main,
|
|
80
|
+
theme.palette.action.focusOpacity
|
|
81
|
+
),
|
|
82
|
+
color: getColor({ status: 'secondary', theme })
|
|
83
|
+
},
|
|
84
|
+
color: theme.palette.secondary.main
|
|
85
|
+
},
|
|
86
|
+
'&[data-variant="success"]': {
|
|
87
|
+
'& .MuiListItemIcon-root': {
|
|
88
|
+
color: getColor({ status: 'success', theme })
|
|
89
|
+
},
|
|
90
|
+
'&:hover': {
|
|
91
|
+
background: alpha(
|
|
92
|
+
theme.palette.success.main,
|
|
93
|
+
theme.palette.action.focusOpacity
|
|
94
|
+
),
|
|
95
|
+
color: getColor({ status: 'success', theme })
|
|
96
|
+
},
|
|
97
|
+
color: theme.palette.success.main
|
|
98
|
+
},
|
|
99
|
+
'&[data-variant="warning"]': {
|
|
100
|
+
'& .MuiListItemIcon-root': {
|
|
101
|
+
color: getColor({ status: 'warning', theme })
|
|
102
|
+
},
|
|
103
|
+
'&:hover': {
|
|
104
|
+
background: alpha(
|
|
105
|
+
theme.palette.warning.main,
|
|
106
|
+
theme.palette.action.focusOpacity
|
|
107
|
+
),
|
|
108
|
+
color: getColor({ status: 'warning', theme })
|
|
109
|
+
},
|
|
110
|
+
color: theme.palette.warning.main
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
list: {
|
|
114
|
+
width: '100%'
|
|
115
|
+
}
|
|
116
|
+
}));
|
|
@@ -24,6 +24,68 @@ const actions = [
|
|
|
24
24
|
}
|
|
25
25
|
];
|
|
26
26
|
|
|
27
|
+
const actionsWithVariants = [
|
|
28
|
+
{
|
|
29
|
+
label: 'No variant',
|
|
30
|
+
onClick: (): void => undefined
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
label: 'Primary',
|
|
34
|
+
onClick: (): void => undefined,
|
|
35
|
+
variant: 'primary'
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
label: 'Secondary',
|
|
39
|
+
onClick: (): void => undefined,
|
|
40
|
+
variant: 'secondary'
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
label: 'Success',
|
|
44
|
+
onClick: (): void => undefined,
|
|
45
|
+
variant: 'success'
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
label: 'Warning',
|
|
49
|
+
onClick: (): void => undefined,
|
|
50
|
+
variant: 'warning'
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
label: 'Error',
|
|
54
|
+
onClick: (): void => undefined,
|
|
55
|
+
variant: 'error'
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
label: 'Info',
|
|
59
|
+
onClick: (): void => undefined,
|
|
60
|
+
variant: 'info'
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
label: 'Pending',
|
|
64
|
+
onClick: (): void => undefined,
|
|
65
|
+
variant: 'pending'
|
|
66
|
+
}
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
const actionsWithSecondaryLabel = [
|
|
70
|
+
{
|
|
71
|
+
Icon: EditIcon,
|
|
72
|
+
label: 'Edit',
|
|
73
|
+
onClick: (): void => undefined
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
Icon: CopyIcon,
|
|
77
|
+
label: 'Duplicate',
|
|
78
|
+
onClick: (): void => undefined,
|
|
79
|
+
secondaryLabel:
|
|
80
|
+
'This is a secondary label that the purpose is to give a small description about an action'
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
Icon: DeleteIcon,
|
|
84
|
+
label: 'Delete',
|
|
85
|
+
onClick: (): void => undefined
|
|
86
|
+
}
|
|
87
|
+
];
|
|
88
|
+
|
|
27
89
|
export default {
|
|
28
90
|
argTypes: {},
|
|
29
91
|
component: ActionsList,
|
|
@@ -39,3 +101,15 @@ export const Playground = Template.bind({});
|
|
|
39
101
|
Playground.args = {
|
|
40
102
|
actions
|
|
41
103
|
};
|
|
104
|
+
|
|
105
|
+
export const Variants = Template.bind({});
|
|
106
|
+
|
|
107
|
+
Variants.args = {
|
|
108
|
+
actions: actionsWithVariants
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export const SecondaryLabel = Template.bind({});
|
|
112
|
+
|
|
113
|
+
SecondaryLabel.args = {
|
|
114
|
+
actions: actionsWithSecondaryLabel
|
|
115
|
+
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* eslint-disable react/no-array-index-key */
|
|
2
|
-
import { makeStyles } from 'tss-react/mui';
|
|
3
2
|
import { useTranslation } from 'react-i18next';
|
|
4
3
|
import { equals } from 'ramda';
|
|
5
4
|
|
|
@@ -12,10 +11,15 @@ import {
|
|
|
12
11
|
Divider
|
|
13
12
|
} from '@mui/material';
|
|
14
13
|
|
|
14
|
+
import { useStyles } from './ActionsList.styles';
|
|
15
|
+
import { ActionVariants } from './models';
|
|
16
|
+
|
|
15
17
|
interface ActionsType {
|
|
16
18
|
Icon?: (props: SvgIconProps) => JSX.Element;
|
|
17
19
|
label: string;
|
|
18
20
|
onClick?: (e?) => void;
|
|
21
|
+
secondaryLabel?: string;
|
|
22
|
+
variant?: ActionVariants;
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
interface Props {
|
|
@@ -24,12 +28,6 @@ interface Props {
|
|
|
24
28
|
listItemClassName?: string;
|
|
25
29
|
}
|
|
26
30
|
|
|
27
|
-
const useStyles = makeStyles()({
|
|
28
|
-
list: {
|
|
29
|
-
maxWidth: '100%'
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
|
|
33
31
|
const ActionsList = ({
|
|
34
32
|
className,
|
|
35
33
|
listItemClassName,
|
|
@@ -45,18 +43,28 @@ const ActionsList = ({
|
|
|
45
43
|
return <Divider key={`divider_${idx}`} />;
|
|
46
44
|
}
|
|
47
45
|
|
|
48
|
-
const { label, Icon, onClick } =
|
|
46
|
+
const { label, Icon, onClick, variant, secondaryLabel } =
|
|
47
|
+
action as ActionsType;
|
|
49
48
|
|
|
50
49
|
return (
|
|
51
|
-
<MenuItem
|
|
50
|
+
<MenuItem
|
|
51
|
+
aria-label={label}
|
|
52
|
+
className={classes.item}
|
|
53
|
+
data-variant={variant}
|
|
54
|
+
id={label}
|
|
55
|
+
key={label}
|
|
56
|
+
onClick={onClick}
|
|
57
|
+
>
|
|
52
58
|
{Icon && (
|
|
53
59
|
<ListItemIcon>
|
|
54
60
|
<Icon fontSize="small" />
|
|
55
61
|
</ListItemIcon>
|
|
56
62
|
)}
|
|
57
|
-
<ListItemText
|
|
58
|
-
{
|
|
59
|
-
|
|
63
|
+
<ListItemText
|
|
64
|
+
className={listItemClassName}
|
|
65
|
+
primary={t(label)}
|
|
66
|
+
secondary={secondaryLabel && t(secondaryLabel)}
|
|
67
|
+
/>
|
|
60
68
|
</MenuItem>
|
|
61
69
|
);
|
|
62
70
|
})}
|
|
@@ -8,7 +8,6 @@ import { FormControlLabel, Checkbox as MuiCheckbox, Box } from '@mui/material';
|
|
|
8
8
|
export type LabelPlacement = 'bottom' | 'top' | 'end' | 'start' | undefined;
|
|
9
9
|
|
|
10
10
|
interface StyleProps {
|
|
11
|
-
disabled: boolean;
|
|
12
11
|
hasIcon: boolean;
|
|
13
12
|
labelPlacement: LabelPlacement;
|
|
14
13
|
}
|
|
@@ -22,7 +21,13 @@ const getLabelSpacing = (labelPlacement, theme): string => {
|
|
|
22
21
|
};
|
|
23
22
|
|
|
24
23
|
const useStyles = makeStyles<StyleProps>()(
|
|
25
|
-
(theme, {
|
|
24
|
+
(theme, { hasIcon, labelPlacement }) => ({
|
|
25
|
+
checkbox: {
|
|
26
|
+
'&.Mui-checked': {
|
|
27
|
+
color: theme.palette.primary.main
|
|
28
|
+
},
|
|
29
|
+
color: theme.palette.primary.main
|
|
30
|
+
},
|
|
26
31
|
container: hasIcon
|
|
27
32
|
? {
|
|
28
33
|
alignItems: 'center',
|
|
@@ -36,13 +41,8 @@ const useStyles = makeStyles<StyleProps>()(
|
|
|
36
41
|
fontSize: theme.spacing(10)
|
|
37
42
|
},
|
|
38
43
|
label: {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
: theme.palette.text.secondary,
|
|
42
|
-
fontSize: theme.typography.body1.fontSize,
|
|
43
|
-
fontWeight: equals(labelPlacement, 'top')
|
|
44
|
-
? theme.typography.fontWeightBold
|
|
45
|
-
: theme.typography.fontWeightMedium,
|
|
44
|
+
fontSize: theme.typography.body2.fontSize,
|
|
45
|
+
fontWeight: theme.typography.fontWeightMedium,
|
|
46
46
|
padding: getLabelSpacing(labelPlacement, theme)
|
|
47
47
|
}
|
|
48
48
|
})
|
|
@@ -72,7 +72,6 @@ const Checkbox = ({
|
|
|
72
72
|
labelProps
|
|
73
73
|
}: Props): JSX.Element => {
|
|
74
74
|
const { classes, cx } = useStyles({
|
|
75
|
-
disabled,
|
|
76
75
|
hasIcon: !!Icon,
|
|
77
76
|
labelPlacement
|
|
78
77
|
});
|
|
@@ -84,6 +83,7 @@ const Checkbox = ({
|
|
|
84
83
|
control={
|
|
85
84
|
<MuiCheckbox
|
|
86
85
|
checked={checked}
|
|
86
|
+
className={classes.checkbox}
|
|
87
87
|
color="primary"
|
|
88
88
|
disabled={disabled}
|
|
89
89
|
id={label}
|
|
@@ -67,21 +67,23 @@ const mountListing = (): void => {
|
|
|
67
67
|
|
|
68
68
|
cy.mount({
|
|
69
69
|
Component: (
|
|
70
|
-
<
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
70
|
+
<div style={{ height: '100vh' }}>
|
|
71
|
+
<Listing
|
|
72
|
+
checkable
|
|
73
|
+
columns={columnsWithSubItems}
|
|
74
|
+
currentPage={1}
|
|
75
|
+
limit={10}
|
|
76
|
+
rows={listingWithSubItems}
|
|
77
|
+
subItems={{
|
|
78
|
+
canCheckSubItems: false,
|
|
79
|
+
enable: true,
|
|
80
|
+
labelCollapse: 'Collapse',
|
|
81
|
+
labelExpand: 'Expand',
|
|
82
|
+
rowProperty: 'subItems'
|
|
83
|
+
}}
|
|
84
|
+
totalRows={10}
|
|
85
|
+
/>
|
|
86
|
+
</div>
|
|
85
87
|
)
|
|
86
88
|
});
|
|
87
89
|
};
|
|
@@ -30,6 +30,11 @@ const useListingStyles = makeStyles<StylesProps>()(
|
|
|
30
30
|
height: '100%',
|
|
31
31
|
width: '100%'
|
|
32
32
|
},
|
|
33
|
+
listingContainer: {
|
|
34
|
+
height: '100%',
|
|
35
|
+
overflow: 'hidden',
|
|
36
|
+
width: '100%'
|
|
37
|
+
},
|
|
33
38
|
loadingIndicator: {
|
|
34
39
|
height: loadingIndicatorHeight,
|
|
35
40
|
width: '100%'
|