@centreon/ui 23.10.1-revert-2271-MON-21521-notification-cloud-remove-state-macro.0 → 23.10.1-sync-dev-23-10-x-develop-oss.0
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 +38 -17
- package/src/ActionsList/models.ts +8 -0
- package/src/Checkbox/Checkbox.tsx +20 -18
- package/src/Checkbox/CheckboxGroup/index.tsx +14 -5
- package/src/Dashboard/Dashboard.styles.ts +15 -2
- package/src/Dashboard/Item.tsx +19 -12
- package/src/Dashboard/Layout.tsx +8 -5
- package/src/Form/Inputs/Radio.tsx +15 -4
- package/src/Form/Inputs/models.ts +1 -1
- package/src/Graph/Gauge/AnimatedPie.tsx +16 -12
- package/src/Graph/Gauge/Gauge.tsx +3 -4
- package/src/Graph/Gauge/ResponsiveGauge.tsx +1 -1
- package/src/Graph/LineChart/BasicComponents/Axes/index.tsx +1 -1
- package/src/Graph/LineChart/BasicComponents/Lines/RegularLines/index.tsx +13 -8
- package/src/Graph/LineChart/BasicComponents/Lines/StackedLines/index.tsx +5 -3
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/useScaleThreshold.ts +3 -3
- package/src/Graph/LineChart/BasicComponents/Lines/index.tsx +5 -5
- package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/RegularAnchorPoint.tsx +5 -5
- package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/models.ts +1 -1
- package/src/Graph/LineChart/Legend/Legend.styles.ts +3 -3
- package/src/Graph/LineChart/Legend/index.tsx +12 -10
- package/src/Graph/LineChart/Legend/useInteractiveValues.ts +10 -10
- package/src/Graph/LineChart/Legend/useLegend.ts +16 -22
- package/src/Graph/LineChart/index.tsx +4 -3
- package/src/Graph/SingleBar/ResponsiveSingleBar.tsx +47 -40
- package/src/Graph/SingleBar/SingleBar.tsx +3 -3
- package/src/Graph/common/timeSeries/index.test.ts +38 -23
- package/src/Graph/common/timeSeries/index.ts +19 -17
- package/src/Graph/common/timeSeries/models.ts +3 -1
- package/src/InputField/Search/PersistentTooltip.tsx +5 -6
- package/src/InputField/Select/Autocomplete/Connected/Multi/MultiConnectedAutocompleteField.cypress.spec.tsx +3 -35
- package/src/InputField/Select/Autocomplete/Connected/index.test.tsx +2 -6
- package/src/InputField/Select/Autocomplete/Connected/index.tsx +7 -2
- package/src/InputField/Select/Autocomplete/Multi/index.tsx +24 -14
- package/src/InputField/Select/index.tsx +1 -0
- package/src/Listing/Cell/DataCell.tsx +1 -1
- package/src/Listing/Cell/index.tsx +2 -2
- 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/ParentSize/ParentSize.tsx +24 -0
- package/src/ParentSize/index.ts +1 -0
- package/src/PopoverMenu/index.tsx +18 -4
- package/src/RichTextEditor/ContentEditable.tsx +15 -6
- package/src/RichTextEditor/RichTextEditor.cypress.spec.tsx +23 -0
- package/src/RichTextEditor/RichTextEditor.tsx +4 -1
- package/src/RichTextEditor/index.stories.tsx +9 -0
- 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 +7 -3
- package/src/ThemeProvider/palettes.ts +5 -2
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/PickersStartEndDate.tsx +9 -6
- package/src/TimePeriods/CustomTimePeriod/SimpleCustomTimePeriod.tsx +28 -0
- package/src/TimePeriods/index.stories.tsx +15 -0
- package/src/TimePeriods/index.tsx +4 -3
- package/src/TopCounterElements/ResourceSubMenu.tsx +3 -1
- package/src/TopCounterElements/TopCounterLayout.tsx +1 -1
- package/src/Wizard/index.tsx +5 -2
- package/src/Wizard/models.ts +1 -0
- package/src/api/buildListingEndpoint/getSearchQueryParameterValue.ts +35 -26
- package/src/api/buildListingEndpoint/index.test.ts +2 -2
- package/src/api/buildListingEndpoint/index.ts +1 -1
- package/src/api/buildListingEndpoint/models.ts +0 -1
- package/src/api/useFetchQuery/index.ts +2 -1
- package/src/api/useGraphQuery/index.ts +69 -32
- package/src/api/useGraphQuery/models.ts +11 -8
- package/src/api/useMutationQuery/index.ts +18 -12
- package/src/components/DataTable/DataTable.styles.ts +1 -1
- package/src/components/DataTable/Item/DataTableItem.styles.ts +3 -9
- package/src/components/DataTable/Item/DataTableItem.tsx +31 -10
- package/src/components/Form/Dashboard/Dashboard.resource.ts +5 -0
- package/src/components/Form/Dashboard/DashboardForm.styles.ts +10 -2
- package/src/components/Form/Dashboard/DashboardForm.tsx +34 -1
- package/src/components/Form/Dashboard/GlobalRefreshFieldOption.tsx +59 -0
- package/src/components/Form/Dashboard/translatedLabels.ts +3 -0
- package/src/components/Header/PageHeader/PageHeader.styles.ts +1 -1
- package/src/components/Layout/PageLayout/PageLayout.styles.ts +6 -5
- package/src/components/Layout/PageLayout/PageLayoutActions.tsx +13 -4
- package/src/components/Menu/Button/MenuButton.tsx +3 -0
- package/src/components/Menu/Menu.styles.ts +6 -8
- package/src/components/Modal/Modal.styles.ts +2 -1
- package/src/components/Modal/ModalHeader.tsx +1 -1
- package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.stories.tsx +62 -0
- package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.styles.tsx +22 -0
- package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.tsx +68 -0
- package/src/components/Tooltip/ConfirmationTooltip/TooltipContent.tsx +31 -0
- package/src/components/Tooltip/ConfirmationTooltip/index.ts +1 -0
- package/src/components/Tooltip/ConfirmationTooltip/models.ts +18 -0
- package/src/components/Tooltip/Tooltip.tsx +19 -8
- package/src/components/Tooltip/index.ts +1 -0
- package/src/index.ts +18 -3
- package/src/utils/useDebounce.ts +7 -2
- package/src/utils/useRefreshInterval.ts +23 -5
- package/src/components/Header/Header.styles.ts +0 -0
- 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-
|
|
3
|
+
"version": "23.10.1-sync-dev-23-10-x-develop-oss.0",
|
|
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,35 +1,43 @@
|
|
|
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
|
|
|
6
5
|
import {
|
|
7
|
-
SvgIconProps,
|
|
8
6
|
MenuList,
|
|
9
7
|
MenuItem,
|
|
10
8
|
ListItemText,
|
|
11
9
|
ListItemIcon,
|
|
12
|
-
Divider
|
|
10
|
+
Divider,
|
|
11
|
+
SvgIconTypeMap
|
|
13
12
|
} from '@mui/material';
|
|
13
|
+
import { OverridableComponent } from '@mui/material/OverridableComponent';
|
|
14
|
+
|
|
15
|
+
import { sanitizedHTML } from '..';
|
|
16
|
+
|
|
17
|
+
import { useStyles } from './ActionsList.styles';
|
|
18
|
+
import { ActionVariants } from './models';
|
|
14
19
|
|
|
15
20
|
interface ActionsType {
|
|
16
|
-
Icon?:
|
|
21
|
+
Icon?: OverridableComponent<SvgIconTypeMap<object, 'svg'>> & {
|
|
22
|
+
muiName: string;
|
|
23
|
+
};
|
|
17
24
|
label: string;
|
|
18
25
|
onClick?: (e?) => void;
|
|
26
|
+
secondaryLabel?: string;
|
|
27
|
+
variant?: ActionVariants;
|
|
19
28
|
}
|
|
20
29
|
|
|
30
|
+
export enum ActionsListActionDivider {
|
|
31
|
+
divider = 'divider'
|
|
32
|
+
}
|
|
33
|
+
export type ActionsListActions = Array<ActionsType | ActionsListActionDivider>;
|
|
34
|
+
|
|
21
35
|
interface Props {
|
|
22
|
-
actions:
|
|
36
|
+
actions: ActionsListActions;
|
|
23
37
|
className?: string;
|
|
24
38
|
listItemClassName?: string;
|
|
25
39
|
}
|
|
26
40
|
|
|
27
|
-
const useStyles = makeStyles()({
|
|
28
|
-
list: {
|
|
29
|
-
maxWidth: '100%'
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
|
|
33
41
|
const ActionsList = ({
|
|
34
42
|
className,
|
|
35
43
|
listItemClassName,
|
|
@@ -41,22 +49,35 @@ const ActionsList = ({
|
|
|
41
49
|
return (
|
|
42
50
|
<MenuList className={cx(classes.list, className)}>
|
|
43
51
|
{actions?.map((action, idx) => {
|
|
44
|
-
if (equals(action,
|
|
52
|
+
if (equals(action, ActionsListActionDivider.divider)) {
|
|
45
53
|
return <Divider key={`divider_${idx}`} />;
|
|
46
54
|
}
|
|
47
55
|
|
|
48
|
-
const { label, Icon, onClick } =
|
|
56
|
+
const { label, Icon, onClick, variant, secondaryLabel } =
|
|
57
|
+
action as ActionsType;
|
|
49
58
|
|
|
50
59
|
return (
|
|
51
|
-
<MenuItem
|
|
60
|
+
<MenuItem
|
|
61
|
+
aria-label={label}
|
|
62
|
+
className={classes.item}
|
|
63
|
+
data-variant={variant}
|
|
64
|
+
id={label}
|
|
65
|
+
key={label}
|
|
66
|
+
onClick={onClick}
|
|
67
|
+
>
|
|
52
68
|
{Icon && (
|
|
53
69
|
<ListItemIcon>
|
|
54
70
|
<Icon fontSize="small" />
|
|
55
71
|
</ListItemIcon>
|
|
56
72
|
)}
|
|
57
|
-
<ListItemText
|
|
58
|
-
{
|
|
59
|
-
|
|
73
|
+
<ListItemText
|
|
74
|
+
className={listItemClassName}
|
|
75
|
+
primary={t(label)}
|
|
76
|
+
secondary={
|
|
77
|
+
secondaryLabel &&
|
|
78
|
+
sanitizedHTML({ initialContent: t(secondaryLabel) })
|
|
79
|
+
}
|
|
80
|
+
/>
|
|
60
81
|
</MenuItem>
|
|
61
82
|
);
|
|
62
83
|
})}
|
|
@@ -2,17 +2,12 @@ import { makeStyles } from 'tss-react/mui';
|
|
|
2
2
|
import { T, always, cond, equals } from 'ramda';
|
|
3
3
|
|
|
4
4
|
import { SvgIconComponent } from '@mui/icons-material';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
Checkbox as MuiCheckbox,
|
|
8
|
-
Box,
|
|
9
|
-
Typography
|
|
10
|
-
} from '@mui/material';
|
|
5
|
+
import Typography, { TypographyTypeMap } from '@mui/material/Typography';
|
|
6
|
+
import { FormControlLabel, Checkbox as MuiCheckbox, Box } from '@mui/material';
|
|
11
7
|
|
|
12
8
|
export type LabelPlacement = 'bottom' | 'top' | 'end' | 'start' | undefined;
|
|
13
9
|
|
|
14
10
|
interface StyleProps {
|
|
15
|
-
disabled: boolean;
|
|
16
11
|
hasIcon: boolean;
|
|
17
12
|
labelPlacement: LabelPlacement;
|
|
18
13
|
}
|
|
@@ -26,7 +21,13 @@ const getLabelSpacing = (labelPlacement, theme): string => {
|
|
|
26
21
|
};
|
|
27
22
|
|
|
28
23
|
const useStyles = makeStyles<StyleProps>()(
|
|
29
|
-
(theme, {
|
|
24
|
+
(theme, { hasIcon, labelPlacement }) => ({
|
|
25
|
+
checkbox: {
|
|
26
|
+
'&.Mui-checked': {
|
|
27
|
+
color: theme.palette.primary.main
|
|
28
|
+
},
|
|
29
|
+
color: theme.palette.primary.main
|
|
30
|
+
},
|
|
30
31
|
container: hasIcon
|
|
31
32
|
? {
|
|
32
33
|
alignItems: 'center',
|
|
@@ -40,13 +41,8 @@ const useStyles = makeStyles<StyleProps>()(
|
|
|
40
41
|
fontSize: theme.spacing(10)
|
|
41
42
|
},
|
|
42
43
|
label: {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
: theme.palette.text.secondary,
|
|
46
|
-
fontSize: theme.typography.body1.fontSize,
|
|
47
|
-
fontWeight: equals(labelPlacement, 'top')
|
|
48
|
-
? theme.typography.fontWeightBold
|
|
49
|
-
: theme.typography.fontWeightMedium,
|
|
44
|
+
fontSize: theme.typography.body2.fontSize,
|
|
45
|
+
fontWeight: theme.typography.fontWeightMedium,
|
|
50
46
|
padding: getLabelSpacing(labelPlacement, theme)
|
|
51
47
|
}
|
|
52
48
|
})
|
|
@@ -60,6 +56,7 @@ interface Props {
|
|
|
60
56
|
disabled?: boolean;
|
|
61
57
|
label: string;
|
|
62
58
|
labelPlacement?: LabelPlacement;
|
|
59
|
+
labelProps?: TypographyTypeMap['props'];
|
|
63
60
|
onChange?: (e) => void;
|
|
64
61
|
}
|
|
65
62
|
|
|
@@ -71,10 +68,10 @@ const Checkbox = ({
|
|
|
71
68
|
className,
|
|
72
69
|
disabled = false,
|
|
73
70
|
labelPlacement = 'end',
|
|
74
|
-
dataTestId
|
|
71
|
+
dataTestId,
|
|
72
|
+
labelProps
|
|
75
73
|
}: Props): JSX.Element => {
|
|
76
74
|
const { classes, cx } = useStyles({
|
|
77
|
-
disabled,
|
|
78
75
|
hasIcon: !!Icon,
|
|
79
76
|
labelPlacement
|
|
80
77
|
});
|
|
@@ -86,6 +83,7 @@ const Checkbox = ({
|
|
|
86
83
|
control={
|
|
87
84
|
<MuiCheckbox
|
|
88
85
|
checked={checked}
|
|
86
|
+
className={classes.checkbox}
|
|
89
87
|
color="primary"
|
|
90
88
|
disabled={disabled}
|
|
91
89
|
id={label}
|
|
@@ -96,7 +94,11 @@ const Checkbox = ({
|
|
|
96
94
|
}
|
|
97
95
|
data-testid={dataTestId || ''}
|
|
98
96
|
key={label}
|
|
99
|
-
label={
|
|
97
|
+
label={
|
|
98
|
+
<Typography classes={{ root: classes.label }} {...labelProps}>
|
|
99
|
+
{label}
|
|
100
|
+
</Typography>
|
|
101
|
+
}
|
|
100
102
|
labelPlacement={labelPlacement}
|
|
101
103
|
sx={{ margin: 0, padding: 0 }}
|
|
102
104
|
/>
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { equals, includes } from 'ramda';
|
|
2
2
|
import { makeStyles } from 'tss-react/mui';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import FormGroup, { FormGroupProps } from '@mui/material/FormGroup';
|
|
5
|
+
import { TypographyTypeMap } from '@mui/material/Typography';
|
|
5
6
|
|
|
6
7
|
import Checkbox, { LabelPlacement } from '../Checkbox';
|
|
7
8
|
|
|
8
9
|
interface Props {
|
|
10
|
+
className?: string;
|
|
9
11
|
dataTestId?: string;
|
|
10
12
|
direction?: 'horizontal' | 'vertical';
|
|
11
13
|
disabled?: boolean;
|
|
14
|
+
formGroupProps?: FormGroupProps;
|
|
12
15
|
labelPlacement?: LabelPlacement;
|
|
16
|
+
labelProps?: TypographyTypeMap['props'];
|
|
13
17
|
onChange?: (e) => void;
|
|
14
18
|
options: Array<string>;
|
|
15
19
|
values: Array<string>;
|
|
@@ -34,27 +38,32 @@ const CheckboxGroup = ({
|
|
|
34
38
|
onChange,
|
|
35
39
|
labelPlacement = 'end',
|
|
36
40
|
disabled = false,
|
|
37
|
-
dataTestId
|
|
41
|
+
dataTestId,
|
|
42
|
+
className,
|
|
43
|
+
labelProps,
|
|
44
|
+
formGroupProps
|
|
38
45
|
}: Props): JSX.Element => {
|
|
39
|
-
const { classes } = useStyles();
|
|
46
|
+
const { classes, cx } = useStyles();
|
|
40
47
|
|
|
41
48
|
const row = !equals(direction, 'vertical');
|
|
42
49
|
|
|
43
50
|
return (
|
|
44
51
|
<FormGroup
|
|
45
|
-
|
|
52
|
+
classes={{ root: classes.container }}
|
|
46
53
|
data-testid={dataTestId || ''}
|
|
47
54
|
row={row}
|
|
55
|
+
{...formGroupProps}
|
|
48
56
|
>
|
|
49
57
|
{options.map((value) => {
|
|
50
58
|
return (
|
|
51
59
|
<Checkbox
|
|
52
60
|
checked={includes(value, values)}
|
|
53
|
-
className={classes.checkbox}
|
|
61
|
+
className={cx(classes.checkbox, className)}
|
|
54
62
|
disabled={disabled}
|
|
55
63
|
key={value}
|
|
56
64
|
label={value}
|
|
57
65
|
labelPlacement={labelPlacement}
|
|
66
|
+
labelProps={labelProps}
|
|
58
67
|
onChange={onChange}
|
|
59
68
|
/>
|
|
60
69
|
);
|
|
@@ -69,7 +69,14 @@ export const useDashboardLayoutStyles = makeStyles<boolean>()(
|
|
|
69
69
|
export const useDashboardItemStyles = makeStyles<{ hasHeader: boolean }>()(
|
|
70
70
|
(theme, { hasHeader }) => ({
|
|
71
71
|
widgetContainer: {
|
|
72
|
+
'&[data-padding="false"]': {
|
|
73
|
+
padding: 0
|
|
74
|
+
},
|
|
75
|
+
background: theme.palette.background.widget,
|
|
76
|
+
border: 'none',
|
|
77
|
+
borderRadius: theme.spacing(1),
|
|
72
78
|
height: '100%',
|
|
79
|
+
paddingBottom: theme.spacing(2),
|
|
73
80
|
width: '100%'
|
|
74
81
|
},
|
|
75
82
|
widgetContent: {
|
|
@@ -85,11 +92,17 @@ export const useDashboardItemStyles = makeStyles<{ hasHeader: boolean }>()(
|
|
|
85
92
|
'&[data-canMove="true"]': {
|
|
86
93
|
cursor: 'move'
|
|
87
94
|
},
|
|
88
|
-
padding: theme.spacing(0.5, 2)
|
|
95
|
+
padding: theme.spacing(0.5, 2),
|
|
96
|
+
position: 'relative'
|
|
97
|
+
},
|
|
98
|
+
widgetHeaderDraggable: {
|
|
99
|
+
height: '100%',
|
|
100
|
+
position: 'absolute',
|
|
101
|
+
width: '100%'
|
|
89
102
|
},
|
|
90
103
|
widgetPadding: {
|
|
91
104
|
overflowX: 'auto',
|
|
92
|
-
padding: hasHeader ? theme.spacing(1, 2,
|
|
105
|
+
padding: hasHeader ? theme.spacing(1, 2, 0) : theme.spacing(1, 2)
|
|
93
106
|
}
|
|
94
107
|
})
|
|
95
108
|
);
|
package/src/Dashboard/Item.tsx
CHANGED
|
@@ -6,9 +6,9 @@ import {
|
|
|
6
6
|
ReactElement
|
|
7
7
|
} from 'react';
|
|
8
8
|
|
|
9
|
-
import { isNil } from 'ramda';
|
|
9
|
+
import { isNil, prop } from 'ramda';
|
|
10
10
|
|
|
11
|
-
import { Card } from '@mui/material';
|
|
11
|
+
import { Card, useTheme } from '@mui/material';
|
|
12
12
|
|
|
13
13
|
import { useMemoComponent } from '../utils';
|
|
14
14
|
|
|
@@ -46,6 +46,7 @@ const Item = forwardRef(
|
|
|
46
46
|
const hasHeader = !isNil(header);
|
|
47
47
|
|
|
48
48
|
const { classes, cx } = useDashboardItemStyles({ hasHeader });
|
|
49
|
+
const theme = useTheme();
|
|
49
50
|
|
|
50
51
|
const listeners = {
|
|
51
52
|
onMouseDown,
|
|
@@ -58,19 +59,25 @@ const Item = forwardRef(
|
|
|
58
59
|
return useMemoComponent({
|
|
59
60
|
Component: (
|
|
60
61
|
<div
|
|
62
|
+
{...cardContainerListeners}
|
|
61
63
|
className={className}
|
|
62
64
|
ref={ref}
|
|
63
|
-
style={
|
|
64
|
-
|
|
65
|
+
style={{
|
|
66
|
+
...style,
|
|
67
|
+
width: `calc(${prop('width', style) || '0px'} - 12px)`
|
|
68
|
+
}}
|
|
65
69
|
>
|
|
66
|
-
<Card
|
|
70
|
+
<Card
|
|
71
|
+
className={classes.widgetContainer}
|
|
72
|
+
data-padding={!disablePadding}
|
|
73
|
+
>
|
|
67
74
|
{header && (
|
|
68
|
-
<div
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
<div className={classes.widgetHeader} data-canMove={canMove}>
|
|
76
|
+
<div
|
|
77
|
+
{...listeners}
|
|
78
|
+
className={classes.widgetHeaderDraggable}
|
|
79
|
+
data-testid={`${id}_move_panel`}
|
|
80
|
+
/>
|
|
74
81
|
{header}
|
|
75
82
|
</div>
|
|
76
83
|
)}
|
|
@@ -85,7 +92,7 @@ const Item = forwardRef(
|
|
|
85
92
|
</Card>
|
|
86
93
|
</div>
|
|
87
94
|
),
|
|
88
|
-
memoProps: [style, className, header]
|
|
95
|
+
memoProps: [style, className, header, theme.palette.mode, canMove]
|
|
89
96
|
});
|
|
90
97
|
}
|
|
91
98
|
);
|
package/src/Dashboard/Layout.tsx
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
2
|
|
|
3
|
-
import { Responsive } from '@visx/visx';
|
|
4
3
|
import GridLayout, { Layout, WidthProvider } from 'react-grid-layout';
|
|
5
4
|
import 'react-grid-layout/css/styles.css';
|
|
6
5
|
|
|
7
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
Responsive as ResponsiveHeight,
|
|
8
|
+
ParentSize,
|
|
9
|
+
useMemoComponent
|
|
10
|
+
} from '..';
|
|
8
11
|
|
|
9
12
|
import { useDashboardLayoutStyles } from './Dashboard.styles';
|
|
10
13
|
import { getColumnsFromScreenSize, getLayout, rowHeight } from './utils';
|
|
@@ -46,7 +49,7 @@ const Layout = <T extends Layout>({
|
|
|
46
49
|
return useMemoComponent({
|
|
47
50
|
Component: (
|
|
48
51
|
<ResponsiveHeight margin={40}>
|
|
49
|
-
<
|
|
52
|
+
<ParentSize>
|
|
50
53
|
{({ width, height }): JSX.Element => (
|
|
51
54
|
<div className={classes.container}>
|
|
52
55
|
{displayGrid && (
|
|
@@ -66,10 +69,10 @@ const Layout = <T extends Layout>({
|
|
|
66
69
|
</ReactGridLayout>
|
|
67
70
|
</div>
|
|
68
71
|
)}
|
|
69
|
-
</
|
|
72
|
+
</ParentSize>
|
|
70
73
|
</ResponsiveHeight>
|
|
71
74
|
),
|
|
72
|
-
memoProps: [columns, layout, displayGrid]
|
|
75
|
+
memoProps: [columns, layout, displayGrid, isStatic]
|
|
73
76
|
});
|
|
74
77
|
};
|
|
75
78
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FormikValues, useFormikContext } from 'formik';
|
|
2
|
-
import { equals, includes, path, split } from 'ramda';
|
|
2
|
+
import { equals, includes, path, split, type } from 'ramda';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
|
|
5
5
|
import {
|
|
@@ -73,12 +73,23 @@ const Radio = ({
|
|
|
73
73
|
disabled={disabled}
|
|
74
74
|
id={getNormalizedId(`${dataTestId}${optionLabel}`)}
|
|
75
75
|
inputProps={{
|
|
76
|
-
'aria-label':
|
|
76
|
+
'aria-label':
|
|
77
|
+
(equals(type(optionLabel), 'String') &&
|
|
78
|
+
t(optionLabel as string)) ||
|
|
79
|
+
''
|
|
77
80
|
}}
|
|
78
81
|
/>
|
|
79
82
|
}
|
|
80
|
-
key={
|
|
81
|
-
|
|
83
|
+
key={
|
|
84
|
+
equals(type(optionLabel), 'String')
|
|
85
|
+
? (optionLabel as string)
|
|
86
|
+
: `${optionValue}`
|
|
87
|
+
}
|
|
88
|
+
label={
|
|
89
|
+
equals(type(optionLabel), 'String')
|
|
90
|
+
? (t(optionLabel as string) as string)
|
|
91
|
+
: optionLabel
|
|
92
|
+
}
|
|
82
93
|
value={optionValue}
|
|
83
94
|
/>
|
|
84
95
|
))}
|