@centreon/ui 25.1.5 → 25.1.7
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/Dashboard/Dashboard.styles.ts +76 -21
- package/src/Dashboard/Grid.tsx +2 -2
- package/src/Dashboard/Item.tsx +11 -9
- package/src/Dashboard/Layout.tsx +15 -32
- package/src/Dashboard/utils.ts +1 -1
- package/src/Dialog/Confirm/index.tsx +4 -2
- package/src/Dialog/Duplicate/index.tsx +6 -4
- package/src/Dialog/index.tsx +4 -1
- package/src/Form/FormButtons.tsx +1 -1
- package/src/Form/Inputs/Text.tsx +8 -4
- package/src/Graph/Chart/Chart.tsx +1 -1
- package/src/Graph/SingleBar/SingleBar.tsx +15 -8
- package/src/InputField/Number/Number.cypress.spec.tsx +6 -2
- package/src/InputField/Number/Number.tsx +10 -5
- package/src/InputField/Select/Autocomplete/Draggable/index.tsx +13 -3
- package/src/InputField/Select/Autocomplete/autoComplete.styles.ts +92 -0
- package/src/InputField/Select/Autocomplete/index.tsx +61 -129
- package/src/InputField/Text/index.tsx +46 -40
- package/src/Listing/Header/Cell/ListingHeaderCell.tsx +3 -1
- package/src/Listing/Listing.cypress.spec.tsx +2 -2
- package/src/Listing/Row/Row.tsx +1 -1
- package/src/ThemeProvider/palettes.ts +2 -2
- package/src/TopCounterElements/ResourceCounters.tsx +1 -3
- package/src/api/useMutationQuery/useOptimisticMutation.ts +8 -5
- package/src/components/Button/Icon/IconButton.tsx +32 -27
- package/src/components/CrudPage/Actions/Search.tsx +6 -2
- package/src/components/CrudPage/CrudPageRoot.tsx +3 -1
- package/src/components/DataTable/Item/DataTableItem.tsx +1 -1
- package/src/components/Form/Dashboard/GlobalRefreshFieldOption.tsx +7 -3
- package/src/components/Header/PageHeader/PageHeader.styles.ts +18 -20
- package/src/components/Layout/PageLayout/PageLayout.styles.ts +3 -3
package/package.json
CHANGED
|
@@ -17,51 +17,106 @@ export const useDashboardLayoutStyles = makeStyles<boolean>()(
|
|
|
17
17
|
boxShadow: theme.shadows[3]
|
|
18
18
|
},
|
|
19
19
|
'& .react-grid-item.react-grid-placeholder': {
|
|
20
|
-
backgroundColor: alpha(theme.palette.primary.main, 0.
|
|
20
|
+
backgroundColor: alpha(theme.palette.primary.main, 0.4)
|
|
21
21
|
},
|
|
22
22
|
'& .react-grid-item.resizing': {
|
|
23
23
|
boxShadow: theme.shadows[3]
|
|
24
24
|
},
|
|
25
25
|
'& .react-resizable-handle': {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
borderRadius: theme.shape.borderRadius,
|
|
29
|
-
display: isStatic ? 'none' : 'block',
|
|
26
|
+
display: isStatic ? 'none' : 'flex',
|
|
27
|
+
position: 'absolute',
|
|
30
28
|
opacity: 0,
|
|
31
|
-
|
|
29
|
+
transition: theme.transitions.create('opacity')
|
|
32
30
|
},
|
|
33
|
-
'& .react-resizable-handle
|
|
31
|
+
'& .react-resizable-handle-e': {
|
|
32
|
+
'& .handle-content-e': {
|
|
33
|
+
backgroundColor: theme.palette.action.focus,
|
|
34
|
+
backgroundImage: 'none',
|
|
35
|
+
borderRadius: theme.shape.borderRadius,
|
|
36
|
+
display: isStatic ? 'none' : 'block',
|
|
37
|
+
height: 'calc(100% / 3)',
|
|
38
|
+
width: '100%'
|
|
39
|
+
},
|
|
34
40
|
cursor: 'ew-resize',
|
|
35
41
|
height: `calc(100% - ${theme.spacing(3)})`,
|
|
36
42
|
marginTop: 0,
|
|
37
43
|
right: 0,
|
|
38
44
|
top: 0,
|
|
39
|
-
|
|
40
|
-
|
|
45
|
+
width: theme.spacing(0.75),
|
|
46
|
+
alignItems: 'center'
|
|
47
|
+
},
|
|
48
|
+
'& .react-resizable-handle-w': {
|
|
49
|
+
'& .handle-content-w': {
|
|
50
|
+
backgroundColor: theme.palette.action.focus,
|
|
51
|
+
backgroundImage: 'none',
|
|
52
|
+
borderRadius: theme.shape.borderRadius,
|
|
53
|
+
display: isStatic ? 'none' : 'block',
|
|
54
|
+
height: 'calc(100% / 3)',
|
|
55
|
+
width: '100%'
|
|
56
|
+
},
|
|
57
|
+
cursor: 'ew-resize',
|
|
58
|
+
height: `calc(100% - ${theme.spacing(3)})`,
|
|
59
|
+
marginTop: 0,
|
|
60
|
+
left: 0,
|
|
61
|
+
top: 0,
|
|
62
|
+
width: theme.spacing(0.75),
|
|
63
|
+
alignItems: 'center'
|
|
41
64
|
},
|
|
42
|
-
|
|
65
|
+
|
|
66
|
+
'& .react-resizable-handle-s': {
|
|
67
|
+
justifyContent: 'center',
|
|
68
|
+
'& .handle-content-s': {
|
|
69
|
+
backgroundColor: theme.palette.action.focus,
|
|
70
|
+
backgroundImage: 'none',
|
|
71
|
+
borderRadius: theme.shape.borderRadius,
|
|
72
|
+
display: isStatic ? 'none' : 'block',
|
|
73
|
+
width: 'calc(100% / 4)'
|
|
74
|
+
},
|
|
43
75
|
bottom: 4,
|
|
44
76
|
cursor: 'ns-resize',
|
|
45
|
-
height: theme.spacing(
|
|
77
|
+
height: theme.spacing(0.75),
|
|
46
78
|
left: 0,
|
|
47
79
|
marginLeft: 0,
|
|
48
|
-
|
|
49
|
-
width: `calc(100% - ${theme.spacing(3)})`
|
|
80
|
+
width: `calc(100% - ${theme.spacing(1)})`
|
|
50
81
|
},
|
|
51
|
-
'& .react-resizable-handle
|
|
82
|
+
'& .react-resizable-handle-se': {
|
|
83
|
+
'& .handle-content-se': {
|
|
84
|
+
backgroundColor: theme.palette.action.focus,
|
|
85
|
+
backgroundImage: 'none',
|
|
86
|
+
borderRadius: theme.shape.borderRadius,
|
|
87
|
+
display: isStatic ? 'none' : 'block',
|
|
88
|
+
width: '100%',
|
|
89
|
+
height: '100%'
|
|
90
|
+
},
|
|
52
91
|
bottom: 4,
|
|
53
92
|
cursor: 'nwse-resize',
|
|
54
|
-
height: theme.spacing(
|
|
93
|
+
height: theme.spacing(1.5),
|
|
55
94
|
right: 0,
|
|
56
|
-
|
|
57
|
-
|
|
95
|
+
width: theme.spacing(1.5),
|
|
96
|
+
opacity: 0.7
|
|
58
97
|
},
|
|
59
|
-
'& .react-resizable-handle
|
|
60
|
-
content:
|
|
98
|
+
'& .react-resizable-handle-sw': {
|
|
99
|
+
'& .handle-content-sw': {
|
|
100
|
+
backgroundColor: theme.palette.action.focus,
|
|
101
|
+
backgroundImage: 'none',
|
|
102
|
+
borderRadius: theme.shape.borderRadius,
|
|
103
|
+
display: isStatic ? 'none' : 'block',
|
|
104
|
+
width: '100%',
|
|
105
|
+
height: '100%'
|
|
106
|
+
},
|
|
107
|
+
bottom: 4,
|
|
108
|
+
cursor: 'nesw-resize',
|
|
109
|
+
height: theme.spacing(1.5),
|
|
110
|
+
left: 0,
|
|
111
|
+
width: theme.spacing(1.5),
|
|
112
|
+
opacity: 0.7
|
|
61
113
|
},
|
|
62
114
|
'& .react-resizable-handle:hover': {
|
|
63
115
|
opacity: 1
|
|
64
116
|
},
|
|
117
|
+
'& .react-resizable-handle::after': {
|
|
118
|
+
content: 'none'
|
|
119
|
+
},
|
|
65
120
|
position: 'relative',
|
|
66
121
|
height: '100%'
|
|
67
122
|
}
|
|
@@ -93,10 +148,10 @@ export const useDashboardItemStyles = makeStyles<{ hasHeader: boolean }>()(
|
|
|
93
148
|
'&:hover': {
|
|
94
149
|
backgroundColor: theme.palette.action.hover
|
|
95
150
|
},
|
|
96
|
-
'&[data-
|
|
151
|
+
'&[data-can-move="false"]': {
|
|
97
152
|
cursor: 'default'
|
|
98
153
|
},
|
|
99
|
-
'&[data-
|
|
154
|
+
'&[data-can-move="true"]': {
|
|
100
155
|
cursor: 'move'
|
|
101
156
|
},
|
|
102
157
|
padding: theme.spacing(0, 1.5),
|
package/src/Dashboard/Grid.tsx
CHANGED
|
@@ -27,7 +27,7 @@ const Grid = ({ width, height, columns }: Props): ReactElement => {
|
|
|
27
27
|
[width]
|
|
28
28
|
);
|
|
29
29
|
|
|
30
|
-
const numberOfRows = Math.floor(height / (rowHeight +
|
|
30
|
+
const numberOfRows = Math.floor(height / (rowHeight + 8));
|
|
31
31
|
|
|
32
32
|
const yScale = useMemo(
|
|
33
33
|
() =>
|
|
@@ -58,8 +58,8 @@ const Grid = ({ width, height, columns }: Props): ReactElement => {
|
|
|
58
58
|
yScale={yScale}
|
|
59
59
|
xScale={xScale}
|
|
60
60
|
stroke={theme.palette.divider}
|
|
61
|
-
top={-10}
|
|
62
61
|
width={width}
|
|
62
|
+
left={-8}
|
|
63
63
|
/>
|
|
64
64
|
</svg>
|
|
65
65
|
),
|
package/src/Dashboard/Item.tsx
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from 'react';
|
|
10
10
|
|
|
11
11
|
import { useAtomValue } from 'jotai';
|
|
12
|
-
import { equals, isNil,
|
|
12
|
+
import { equals, isNil, omit, type } from 'ramda';
|
|
13
13
|
|
|
14
14
|
import { Card, useTheme } from '@mui/material';
|
|
15
15
|
import LoadingSkeleton from '../LoadingSkeleton';
|
|
@@ -79,25 +79,27 @@ const Item = forwardRef<HTMLDivElement, DashboardItemProps>(
|
|
|
79
79
|
const cardContainerListeners = !hasHeader ? listeners : {};
|
|
80
80
|
|
|
81
81
|
useEffect(() => {
|
|
82
|
-
if (isNil(ref)) {
|
|
82
|
+
if (isNil(ref?.current)) {
|
|
83
83
|
return;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
setElement(ref.current);
|
|
87
87
|
}, [ref]);
|
|
88
88
|
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
};
|
|
89
|
+
const newTransform =
|
|
90
|
+
style?.transform &&
|
|
91
|
+
`translate3d(${style.transform.match(/translate\(([a-z0-9\ \,\-]+)\)/)[1]}, 0px)`;
|
|
93
92
|
|
|
94
93
|
return useMemoComponent({
|
|
95
94
|
Component: (
|
|
96
95
|
<div
|
|
97
|
-
ref={ref}
|
|
98
96
|
{...cardContainerListeners}
|
|
99
97
|
className={sanitizedReactGridLayoutClassName}
|
|
100
|
-
|
|
98
|
+
ref={ref}
|
|
99
|
+
style={{
|
|
100
|
+
...omit(['transform'], style || {}),
|
|
101
|
+
transform: newTransform
|
|
102
|
+
}}
|
|
101
103
|
>
|
|
102
104
|
<ExpandableContainer>
|
|
103
105
|
{({ isExpanded, label, key, ...rest }) => {
|
|
@@ -122,7 +124,7 @@ const Item = forwardRef<HTMLDivElement, DashboardItemProps>(
|
|
|
122
124
|
{childrenHeader && (
|
|
123
125
|
<div
|
|
124
126
|
className={classes.widgetHeader}
|
|
125
|
-
data-
|
|
127
|
+
data-can-move={canControl}
|
|
126
128
|
>
|
|
127
129
|
{canControl && (
|
|
128
130
|
<div
|
package/src/Dashboard/Layout.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCallback, useEffect,
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import { useSetAtom } from 'jotai';
|
|
4
4
|
import GridLayout, { Layout, WidthProvider } from 'react-grid-layout';
|
|
@@ -8,7 +8,6 @@ import { ParentSize, useMemoComponent } from '..';
|
|
|
8
8
|
|
|
9
9
|
import { Box } from '@mui/material';
|
|
10
10
|
import { useDashboardLayoutStyles } from './Dashboard.styles';
|
|
11
|
-
import Grid from './Grid';
|
|
12
11
|
import { isResizingItemAtom } from './atoms';
|
|
13
12
|
import { getColumnsFromScreenSize, getLayout, rowHeight } from './utils';
|
|
14
13
|
|
|
@@ -23,22 +22,20 @@ interface DashboardLayoutProps<T> {
|
|
|
23
22
|
layout: Array<T>;
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return max;
|
|
25
|
+
const Handle = (axis, ref) => {
|
|
26
|
+
return (
|
|
27
|
+
<span
|
|
28
|
+
className={`react-resizable-handle react-resizable-handle-${axis}`}
|
|
29
|
+
ref={ref}
|
|
30
|
+
>
|
|
31
|
+
<span className={`handle-content-${axis}`} />
|
|
32
|
+
</span>
|
|
33
|
+
);
|
|
36
34
|
};
|
|
37
35
|
|
|
38
36
|
const DashboardLayout = <T extends Layout>({
|
|
39
37
|
children,
|
|
40
38
|
changeLayout,
|
|
41
|
-
displayGrid,
|
|
42
39
|
layout,
|
|
43
40
|
isStatic = false,
|
|
44
41
|
additionalMemoProps = []
|
|
@@ -63,13 +60,6 @@ const DashboardLayout = <T extends Layout>({
|
|
|
63
60
|
setIsResizingItem(null);
|
|
64
61
|
}, []);
|
|
65
62
|
|
|
66
|
-
const containerHeight =
|
|
67
|
-
useMemo((): number | undefined => {
|
|
68
|
-
const nbRow = bottom(getLayout(layout));
|
|
69
|
-
const containerPaddingY = 4;
|
|
70
|
-
return nbRow * rowHeight + (nbRow - 1) * 20 + containerPaddingY * 2;
|
|
71
|
-
}, [layout, rowHeight]) ?? 0;
|
|
72
|
-
|
|
73
63
|
useEffect(() => {
|
|
74
64
|
window.addEventListener('resize', resize);
|
|
75
65
|
|
|
@@ -85,26 +75,19 @@ const DashboardLayout = <T extends Layout>({
|
|
|
85
75
|
sx={{ overflowY: 'auto', overflowX: 'hidden' }}
|
|
86
76
|
>
|
|
87
77
|
<ParentSize>
|
|
88
|
-
{({ width
|
|
78
|
+
{({ width }): JSX.Element => (
|
|
89
79
|
<Box className={classes.container}>
|
|
90
|
-
{displayGrid && (
|
|
91
|
-
<Grid
|
|
92
|
-
columns={columns}
|
|
93
|
-
height={containerHeight > height ? containerHeight : height}
|
|
94
|
-
width={width}
|
|
95
|
-
/>
|
|
96
|
-
)}
|
|
97
80
|
<ReactGridLayout
|
|
98
81
|
cols={columns}
|
|
99
|
-
containerPadding={[4, 0]}
|
|
100
82
|
layout={getLayout(layout)}
|
|
101
|
-
margin={[
|
|
102
|
-
resizeHandles={['s', 'e', 'se']}
|
|
83
|
+
margin={[12, 12]}
|
|
84
|
+
resizeHandles={['s', 'e', 'se', 'sw', 'w']}
|
|
103
85
|
rowHeight={rowHeight}
|
|
104
86
|
width={width}
|
|
105
87
|
onLayoutChange={changeLayout}
|
|
106
88
|
onResizeStart={startResize}
|
|
107
89
|
onResizeStop={stopResize}
|
|
90
|
+
resizeHandle={Handle}
|
|
108
91
|
>
|
|
109
92
|
{children}
|
|
110
93
|
</ReactGridLayout>
|
|
@@ -113,7 +96,7 @@ const DashboardLayout = <T extends Layout>({
|
|
|
113
96
|
</ParentSize>
|
|
114
97
|
</Box>
|
|
115
98
|
),
|
|
116
|
-
memoProps: [columns, layout,
|
|
99
|
+
memoProps: [columns, layout, isStatic, ...additionalMemoProps]
|
|
117
100
|
});
|
|
118
101
|
};
|
|
119
102
|
|
package/src/Dashboard/utils.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ButtonProps, DialogContentText, Typography } from '@mui/material';
|
|
1
|
+
import { ButtonProps, DialogContentText, DialogContentTextProps, Typography } from '@mui/material';
|
|
2
2
|
|
|
3
3
|
import Dialog, { Props as DialogProps } from '..';
|
|
4
4
|
|
|
@@ -8,6 +8,7 @@ type Props = DialogProps & {
|
|
|
8
8
|
labelSecondMessage?: string | null;
|
|
9
9
|
restCancelButtonProps?: ButtonProps;
|
|
10
10
|
restConfirmButtonProps?: ButtonProps;
|
|
11
|
+
dialogContentTextProps?:DialogContentTextProps
|
|
11
12
|
};
|
|
12
13
|
|
|
13
14
|
const Confirm = ({
|
|
@@ -16,6 +17,7 @@ const Confirm = ({
|
|
|
16
17
|
children,
|
|
17
18
|
restCancelButtonProps,
|
|
18
19
|
restConfirmButtonProps,
|
|
20
|
+
dialogContentTextProps,
|
|
19
21
|
...rest
|
|
20
22
|
}: Props): JSX.Element => (
|
|
21
23
|
<Dialog
|
|
@@ -23,7 +25,7 @@ const Confirm = ({
|
|
|
23
25
|
restConfirmButtonProps={restConfirmButtonProps}
|
|
24
26
|
{...rest}
|
|
25
27
|
>
|
|
26
|
-
<DialogContentText>
|
|
28
|
+
<DialogContentText {...dialogContentTextProps}>
|
|
27
29
|
{labelMessage && <Typography>{labelMessage}</Typography>}
|
|
28
30
|
{labelSecondMessage && <Typography>{labelSecondMessage}</Typography>}
|
|
29
31
|
{children}
|
|
@@ -56,10 +56,12 @@ const Duplicate = ({
|
|
|
56
56
|
fullWidth
|
|
57
57
|
className={classes.container}
|
|
58
58
|
color="primary"
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
slotProps={{
|
|
60
|
+
htmlInput: {
|
|
61
|
+
'aria-label': 'Duplications',
|
|
62
|
+
max: limit,
|
|
63
|
+
min: 1
|
|
64
|
+
}
|
|
63
65
|
}}
|
|
64
66
|
label={labelInput}
|
|
65
67
|
margin="dense"
|
package/src/Dialog/index.tsx
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
DialogContent,
|
|
11
11
|
DialogProps,
|
|
12
12
|
DialogTitle,
|
|
13
|
+
DialogTitleProps,
|
|
13
14
|
Dialog as MuiDialog
|
|
14
15
|
} from '@mui/material';
|
|
15
16
|
|
|
@@ -37,6 +38,7 @@ export type Props = {
|
|
|
37
38
|
className?: string;
|
|
38
39
|
confirmDisabled?: boolean;
|
|
39
40
|
contentWidth?: number;
|
|
41
|
+
dialogTitleProps?:DialogTitleProps
|
|
40
42
|
dialogActionsClassName?: string;
|
|
41
43
|
dialogConfirmButtonClassName?: string;
|
|
42
44
|
dialogContentClassName?: string;
|
|
@@ -68,6 +70,7 @@ const Dialog = ({
|
|
|
68
70
|
confirmDisabled = false,
|
|
69
71
|
cancelDisabled = false,
|
|
70
72
|
submitting = false,
|
|
73
|
+
dialogTitleProps,
|
|
71
74
|
dialogPaperClassName,
|
|
72
75
|
dialogTitleClassName,
|
|
73
76
|
dialogContentClassName,
|
|
@@ -90,7 +93,7 @@ const Dialog = ({
|
|
|
90
93
|
{...rest}
|
|
91
94
|
>
|
|
92
95
|
{labelTitle && (
|
|
93
|
-
<DialogTitle className={dialogTitleClassName}>{labelTitle}</DialogTitle>
|
|
96
|
+
<DialogTitle className={dialogTitleClassName} {...dialogTitleProps}>{labelTitle}</DialogTitle>
|
|
94
97
|
)}
|
|
95
98
|
{children && (
|
|
96
99
|
<DialogContent
|
package/src/Form/FormButtons.tsx
CHANGED
package/src/Form/Inputs/Text.tsx
CHANGED
|
@@ -138,10 +138,14 @@ const Text = ({
|
|
|
138
138
|
value={value || ''}
|
|
139
139
|
onBlur={handleBlur(fieldName)}
|
|
140
140
|
onChange={changeText}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
141
|
+
textFieldSlotsAndSlotProps={{
|
|
142
|
+
slotProps: {
|
|
143
|
+
htmlInput: {
|
|
144
|
+
'data-testid': dataTestId || label,
|
|
145
|
+
'aria-label': label,
|
|
146
|
+
min: text?.min
|
|
147
|
+
}
|
|
148
|
+
}
|
|
145
149
|
}}
|
|
146
150
|
/>
|
|
147
151
|
),
|
|
@@ -232,7 +232,7 @@ const Chart = ({
|
|
|
232
232
|
[axis?.showGridLines]
|
|
233
233
|
);
|
|
234
234
|
|
|
235
|
-
if (!isInViewport && !skipIntersectionObserver) {
|
|
235
|
+
if ((!isInViewport && !skipIntersectionObserver) || !height) {
|
|
236
236
|
return (
|
|
237
237
|
<Skeleton
|
|
238
238
|
height={graphSvgRef?.current?.clientHeight ?? graphHeight}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Skeleton } from '@mui/material';
|
|
1
2
|
import { ParentSize } from '../..';
|
|
2
3
|
|
|
3
4
|
import ResponsiveSingleBar from './ResponsiveSingleBar';
|
|
@@ -10,14 +11,20 @@ const SingleBar = ({ data, ...props }: SingleBarProps): JSX.Element | null => {
|
|
|
10
11
|
|
|
11
12
|
return (
|
|
12
13
|
<ParentSize>
|
|
13
|
-
{({ width, height }) =>
|
|
14
|
-
|
|
15
|
-
{
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
{({ width, height }) => {
|
|
15
|
+
if (!height || !width) {
|
|
16
|
+
return <Skeleton height={20} variant="rectangular" width="100%" />;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<ResponsiveSingleBar
|
|
21
|
+
{...props}
|
|
22
|
+
data={data}
|
|
23
|
+
height={height}
|
|
24
|
+
width={width}
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
27
|
+
}}
|
|
21
28
|
</ParentSize>
|
|
22
29
|
);
|
|
23
30
|
};
|
|
@@ -31,7 +31,7 @@ const NumberField = ({
|
|
|
31
31
|
defaultValue ? `${defaultValue}` : ''
|
|
32
32
|
);
|
|
33
33
|
|
|
34
|
-
const {
|
|
34
|
+
const { textFieldSlotsAndSlotProps } = props;
|
|
35
35
|
|
|
36
36
|
const changeValue = (event: ChangeEvent<HTMLInputElement>): void => {
|
|
37
37
|
const inputValue = event.target.value;
|
|
@@ -44,8 +44,10 @@ const NumberField = ({
|
|
|
44
44
|
T,
|
|
45
45
|
always(
|
|
46
46
|
clamp(
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
textFieldSlotsAndSlotProps?.slotProps?.htmlInput?.min ||
|
|
48
|
+
Number.NEGATIVE_INFINITY,
|
|
49
|
+
textFieldSlotsAndSlotProps?.slotProps?.htmlInput?.max ||
|
|
50
|
+
Number.POSITIVE_INFINITY,
|
|
49
51
|
number
|
|
50
52
|
)
|
|
51
53
|
)
|
|
@@ -59,12 +61,15 @@ const NumberField = ({
|
|
|
59
61
|
|
|
60
62
|
return (
|
|
61
63
|
<TextField
|
|
62
|
-
defaultValue={defaultValue}
|
|
63
64
|
type="number"
|
|
64
65
|
value={actualValue}
|
|
65
66
|
onChange={changeValue}
|
|
66
67
|
{...props}
|
|
67
|
-
|
|
68
|
+
textFieldSlotsAndSlotProps={{
|
|
69
|
+
slotProps: {
|
|
70
|
+
htmlInput: { ...textFieldSlotsAndSlotProps?.slotProps?.htmlInput }
|
|
71
|
+
}
|
|
72
|
+
}}
|
|
68
73
|
placeholder={
|
|
69
74
|
placeholder || (!defaultValue ? `${fallbackValue}` : undefined)
|
|
70
75
|
}
|
|
@@ -181,9 +181,19 @@ const DraggableAutocomplete = (
|
|
|
181
181
|
{...renderProps}
|
|
182
182
|
error={error}
|
|
183
183
|
helperText={error}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
184
|
+
textFieldSlotsAndSlotProps={{
|
|
185
|
+
slotProps: {
|
|
186
|
+
input:{
|
|
187
|
+
...renderProps?.InputProps
|
|
188
|
+
},
|
|
189
|
+
inputLabel:{
|
|
190
|
+
...renderProps?.inputLabel
|
|
191
|
+
},
|
|
192
|
+
htmlInput: {
|
|
193
|
+
...renderProps.inputProps,
|
|
194
|
+
value: inputText || ''
|
|
195
|
+
}
|
|
196
|
+
}
|
|
187
197
|
}}
|
|
188
198
|
label={label}
|
|
189
199
|
required={required}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { equals } from 'ramda';
|
|
2
|
+
import { makeStyles } from 'tss-react/mui';
|
|
3
|
+
|
|
4
|
+
import { autocompleteClasses } from '@mui/material/Autocomplete';
|
|
5
|
+
|
|
6
|
+
import { ThemeMode } from '@centreon/ui-context';
|
|
7
|
+
|
|
8
|
+
interface StyledProps {
|
|
9
|
+
hideInput?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const textfieldHeight = (hideInput?: boolean): number | undefined =>
|
|
13
|
+
hideInput ? 0 : undefined;
|
|
14
|
+
|
|
15
|
+
export const useAutoCompleteStyles = makeStyles<StyledProps>()(
|
|
16
|
+
(theme, { hideInput }) => ({
|
|
17
|
+
hiddenText: {
|
|
18
|
+
transform: 'scale(0)'
|
|
19
|
+
},
|
|
20
|
+
input: {
|
|
21
|
+
'&:after': {
|
|
22
|
+
borderBottom: 0
|
|
23
|
+
},
|
|
24
|
+
'&:before': {
|
|
25
|
+
borderBottom: 0,
|
|
26
|
+
content: 'unset'
|
|
27
|
+
},
|
|
28
|
+
'&:hover:before': {
|
|
29
|
+
borderBottom: 0
|
|
30
|
+
},
|
|
31
|
+
height: textfieldHeight(hideInput)
|
|
32
|
+
},
|
|
33
|
+
inputLabel: {
|
|
34
|
+
'&&': {
|
|
35
|
+
fontSize: theme.typography.body1.fontSize,
|
|
36
|
+
maxWidth: '72%',
|
|
37
|
+
overflow: 'hidden',
|
|
38
|
+
textOverflow: 'ellipsis',
|
|
39
|
+
transform: 'translate(12px, 14px) scale(1)',
|
|
40
|
+
whiteSpace: 'nowrap'
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
inputLabelShrink: {
|
|
44
|
+
'&&': {
|
|
45
|
+
maxWidth: '90%'
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
inputWithLabel: {
|
|
49
|
+
'&[class*="MuiFilledInput-root"]': {
|
|
50
|
+
paddingTop: theme.spacing(2)
|
|
51
|
+
},
|
|
52
|
+
paddingTop: theme.spacing(1)
|
|
53
|
+
},
|
|
54
|
+
inputWithoutLabel: {
|
|
55
|
+
'&[class*="MuiFilledInput-root"][class*="MuiFilledInput-marginDense"]': {
|
|
56
|
+
paddingBottom: hideInput ? 0 : theme.spacing(0.75),
|
|
57
|
+
paddingRight: hideInput ? 0 : theme.spacing(1),
|
|
58
|
+
paddingTop: hideInput ? 0 : theme.spacing(0.75)
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
loadingIndicator: {
|
|
62
|
+
textAlign: 'center'
|
|
63
|
+
},
|
|
64
|
+
options: {
|
|
65
|
+
alignItems: 'center',
|
|
66
|
+
display: 'grid',
|
|
67
|
+
gridAutoFlow: 'column',
|
|
68
|
+
gridGap: theme.spacing(1)
|
|
69
|
+
},
|
|
70
|
+
popper: {
|
|
71
|
+
[`& .${autocompleteClasses.listbox}`]: {
|
|
72
|
+
[`& .${autocompleteClasses.option}`]: {
|
|
73
|
+
[`&:hover, &[aria-selected="true"], &.${autocompleteClasses.focused},
|
|
74
|
+
&.${autocompleteClasses.focused}[aria-selected="true"]`]: {
|
|
75
|
+
background: equals(theme.palette.mode, ThemeMode.dark)
|
|
76
|
+
? theme.palette.primary.dark
|
|
77
|
+
: theme.palette.primary.light,
|
|
78
|
+
color: equals(theme.palette.mode, ThemeMode.dark)
|
|
79
|
+
? theme.palette.common.white
|
|
80
|
+
: theme.palette.primary.main
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
padding: 0
|
|
84
|
+
},
|
|
85
|
+
zIndex: theme.zIndex.tooltip + 1
|
|
86
|
+
},
|
|
87
|
+
textfield: {
|
|
88
|
+
height: textfieldHeight(hideInput),
|
|
89
|
+
visibility: hideInput ? 'hidden' : 'visible'
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
);
|