@centreon/ui 23.10.19 → 23.10.20-MON-18490-widgets.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 +5 -2
- package/src/Button/Icon/index.tsx +1 -1
- package/src/Button/Save/index.tsx +1 -1
- package/src/Dashboard/Dashboard.styles.ts +83 -0
- package/src/Dashboard/DashboardLayout.stories.tsx +104 -0
- package/src/Dashboard/Grid.tsx +70 -0
- package/src/Dashboard/Item.tsx +72 -0
- package/src/Dashboard/Layout.tsx +74 -0
- package/src/Dashboard/index.tsx +9 -0
- package/src/Dashboard/utils.ts +28 -0
- package/src/FileDropZone/index.tsx +1 -1
- package/src/Form/FormButtons.tsx +2 -1
- package/src/Form/Inputs/Autocomplete.tsx +1 -1
- package/src/Form/Inputs/Radio.tsx +1 -1
- package/src/Form/Inputs/Switch.tsx +1 -1
- package/src/InputField/Select/Autocomplete/Connected/index.tsx +3 -5
- package/src/InputField/Select/Autocomplete/index.stories.tsx +1 -10
- package/src/InputField/Select/Autocomplete/index.tsx +1 -1
- package/src/InputField/Select/index.tsx +1 -1
- package/src/InputField/Text/index.tsx +1 -1
- package/src/Listing/ActionBar/index.tsx +1 -1
- package/src/Listing/index.tsx +2 -1
- package/src/ListingPage/index.tsx +1 -1
- package/src/Panel/Memoized.tsx +1 -1
- package/src/Panel/Section/index.tsx +1 -1
- package/src/SortableItems/SortableItem.tsx +1 -1
- package/src/Typography/FluidTypography/index.stories.tsx +63 -0
- package/src/Typography/FluidTypography/index.tsx +51 -0
- package/src/Typography/FluidTypography/useFluidResizeObserver.ts +56 -0
- package/src/Typography/{index.stories.tsx → Typography.stories.tsx} +5 -5
- package/src/__image_snapshots__/storyshots-test-js-image-story-shots-dashboard-normal-1-snap.png +0 -0
- package/src/__image_snapshots__/storyshots-test-js-image-story-shots-dashboard-with-item-header-1-snap.png +0 -0
- package/src/__image_snapshots__/storyshots-test-js-image-story-shots-dashboard-with-many-panels-1-snap.png +0 -0
- package/src/__image_snapshots__/storyshots-test-js-image-story-shots-fluid-typography-basic-1-snap.png +0 -0
- package/src/__image_snapshots__/storyshots-test-js-image-story-shots-fluid-typography-with-20-px-height-1-snap.png +0 -0
- package/src/__image_snapshots__/storyshots-test-js-image-story-shots-fluid-typography-with-200-px-width-1-snap.png +0 -0
- package/src/__image_snapshots__/storyshots-test-js-image-story-shots-fluid-typography-with-heading-5-variant-1-snap.png +0 -0
- package/src/__image_snapshots__/storyshots-test-js-image-story-shots-fluid-typography-with-long-text-1-snap.png +0 -0
- package/src/index.ts +20 -1
- package/src/utils/getNormalizedId.ts +3 -1
- package/src/utils/useCopyToClipboard.ts +3 -2
- package/src/utils/useDebounce.ts +3 -1
- package/src/utils/useDeepCallback.ts +3 -1
- package/src/utils/useDeepMemo.ts +3 -1
- package/src/utils/useIntersectionObserver.ts +3 -1
- package/src/utils/useKeyObserver.tsx +3 -1
- package/src/utils/useLocaleDateTimeFormat/index.test.tsx +1 -1
- package/src/utils/useLocaleDateTimeFormat/index.ts +2 -1
- package/src/utils/useLocaleDateTimeFormat/localeFallback.test.tsx +1 -1
- package/src/utils/useMemoComponent.ts +3 -1
- package/src/utils/index.ts +0 -15
- package/src/utils/useDateTimePickerAdapter.ts +0 -309
- /package/src/Typography/{index.tsx → story.utils.tsx} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@centreon/ui",
|
|
3
|
-
"version": "23.10.
|
|
3
|
+
"version": "23.10.20-MON-18490-widgets.0",
|
|
4
4
|
"description": "Centreon UI Components",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"eslint": "eslint ./src --ext .js,.jsx,.ts,.tsx --max-warnings 0",
|
|
@@ -89,7 +89,9 @@
|
|
|
89
89
|
"lexical": "0.8.0",
|
|
90
90
|
"notistack": "^2.0.8",
|
|
91
91
|
"react-transition-group": "^4.4.5",
|
|
92
|
-
"ulog": "^2.0.0-beta.19"
|
|
92
|
+
"ulog": "^2.0.0-beta.19",
|
|
93
|
+
"react-grid-layout": "^1.3.4",
|
|
94
|
+
"react-resizable": "^3.0.5"
|
|
93
95
|
},
|
|
94
96
|
"peerDependencies": {
|
|
95
97
|
"@centreon/ui-context": "file:../ui-context",
|
|
@@ -108,6 +110,7 @@
|
|
|
108
110
|
"ramda": "0.x",
|
|
109
111
|
"react-i18next": "12.x",
|
|
110
112
|
"react-router-dom": "6.x",
|
|
113
|
+
"react-scale-text": "1.x",
|
|
111
114
|
"resize-observer-polyfill": "1.x",
|
|
112
115
|
"ts.data.json": "2.x",
|
|
113
116
|
"tss-react": "4.x"
|
|
@@ -4,7 +4,7 @@ import { makeStyles } from 'tss-react/mui';
|
|
|
4
4
|
import { Theme, Tooltip } from '@mui/material';
|
|
5
5
|
import { LoadingButton } from '@mui/lab';
|
|
6
6
|
|
|
7
|
-
import
|
|
7
|
+
import getNormalizedId from '../../utils/getNormalizedId';
|
|
8
8
|
|
|
9
9
|
import StartIcon from './StartIcon';
|
|
10
10
|
import Content from './Content';
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { makeStyles } from 'tss-react/mui';
|
|
2
|
+
|
|
3
|
+
import { alpha } from '@mui/material';
|
|
4
|
+
|
|
5
|
+
export const useDashboardLayoutStyles = makeStyles()((theme) => ({
|
|
6
|
+
container: {
|
|
7
|
+
'& .react-grid-item': {
|
|
8
|
+
borderRadius: theme.shape.borderRadius,
|
|
9
|
+
transition: theme.transitions.create('all', {
|
|
10
|
+
delay: 0,
|
|
11
|
+
duration: 100,
|
|
12
|
+
easing: theme.transitions.easing.easeOut
|
|
13
|
+
})
|
|
14
|
+
},
|
|
15
|
+
'& .react-grid-item.react-draggable-dragging': {
|
|
16
|
+
boxShadow: theme.shadows[3]
|
|
17
|
+
},
|
|
18
|
+
'& .react-grid-item.react-grid-placeholder': {
|
|
19
|
+
backgroundColor: alpha(theme.palette.primary.main, 0.7)
|
|
20
|
+
},
|
|
21
|
+
'& .react-grid-item.resizing': {
|
|
22
|
+
boxShadow: theme.shadows[3]
|
|
23
|
+
},
|
|
24
|
+
'& .react-resizable-handle': {
|
|
25
|
+
backgroundColor: theme.palette.action.focus,
|
|
26
|
+
backgroundImage: 'none',
|
|
27
|
+
borderRadius: theme.shape.borderRadius,
|
|
28
|
+
display: 'block',
|
|
29
|
+
opacity: 0,
|
|
30
|
+
position: 'absolute'
|
|
31
|
+
},
|
|
32
|
+
'& .react-resizable-handle.react-resizable-handle-e': {
|
|
33
|
+
cursor: 'ew-resize',
|
|
34
|
+
height: `calc(100% - ${theme.spacing(3)})`,
|
|
35
|
+
marginTop: 0,
|
|
36
|
+
right: 0,
|
|
37
|
+
top: 0,
|
|
38
|
+
transform: 'rotate(0deg)',
|
|
39
|
+
width: theme.spacing(1)
|
|
40
|
+
},
|
|
41
|
+
'& .react-resizable-handle.react-resizable-handle-s': {
|
|
42
|
+
bottom: 0,
|
|
43
|
+
cursor: 'ns-resize',
|
|
44
|
+
height: theme.spacing(1),
|
|
45
|
+
left: 0,
|
|
46
|
+
marginLeft: 0,
|
|
47
|
+
transform: 'rotate(0deg)',
|
|
48
|
+
width: `calc(100% - ${theme.spacing(3)})`
|
|
49
|
+
},
|
|
50
|
+
'& .react-resizable-handle.react-resizable-handle-se': {
|
|
51
|
+
bottom: 0,
|
|
52
|
+
cursor: 'nwse-resize',
|
|
53
|
+
height: theme.spacing(2),
|
|
54
|
+
right: 0,
|
|
55
|
+
transform: 'rotate(0deg)',
|
|
56
|
+
width: theme.spacing(2)
|
|
57
|
+
},
|
|
58
|
+
'& .react-resizable-handle::after': {
|
|
59
|
+
content: 'none'
|
|
60
|
+
},
|
|
61
|
+
'& .react-resizable-handle:hover': {
|
|
62
|
+
opacity: 1
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}));
|
|
66
|
+
|
|
67
|
+
export const useDashboardItemStyles = makeStyles()((theme) => ({
|
|
68
|
+
widgetContainer: {
|
|
69
|
+
height: '100%',
|
|
70
|
+
width: '100%'
|
|
71
|
+
},
|
|
72
|
+
widgetContent: {
|
|
73
|
+
height: '100%',
|
|
74
|
+
padding: theme.spacing(1, 2)
|
|
75
|
+
},
|
|
76
|
+
widgetHeader: {
|
|
77
|
+
'&:hover': {
|
|
78
|
+
backgroundColor: theme.palette.action.hover
|
|
79
|
+
},
|
|
80
|
+
cursor: 'move',
|
|
81
|
+
padding: theme.spacing(0.5, 2)
|
|
82
|
+
}
|
|
83
|
+
}));
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { ComponentMeta } from '@storybook/react';
|
|
2
|
+
import { Layout } from 'react-grid-layout';
|
|
3
|
+
|
|
4
|
+
import { Typography } from '@mui/material';
|
|
5
|
+
|
|
6
|
+
import FluidTypography from '../Typography/FluidTypography';
|
|
7
|
+
|
|
8
|
+
import { DashboardLayout } from '.';
|
|
9
|
+
|
|
10
|
+
interface CustomLayout extends Layout {
|
|
11
|
+
content: string;
|
|
12
|
+
shouldUseFluidTypography: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const dashboardLayout: Array<CustomLayout> = [
|
|
16
|
+
{
|
|
17
|
+
content: 'Hello world',
|
|
18
|
+
h: 4,
|
|
19
|
+
i: 'a',
|
|
20
|
+
shouldUseFluidTypography: false,
|
|
21
|
+
w: 6,
|
|
22
|
+
x: 0,
|
|
23
|
+
y: 0
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
content: 'This is a panel',
|
|
27
|
+
h: 3,
|
|
28
|
+
i: 'b',
|
|
29
|
+
minW: 2,
|
|
30
|
+
shouldUseFluidTypography: false,
|
|
31
|
+
w: 7,
|
|
32
|
+
x: 1,
|
|
33
|
+
y: 7
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
content: 'And the last panel with fluid typography',
|
|
37
|
+
h: 7,
|
|
38
|
+
i: 'c',
|
|
39
|
+
shouldUseFluidTypography: true,
|
|
40
|
+
w: 6,
|
|
41
|
+
x: 6,
|
|
42
|
+
y: 6
|
|
43
|
+
}
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
const generateLayout = (maxElements: number): Array<CustomLayout> => {
|
|
47
|
+
return Array(maxElements)
|
|
48
|
+
.fill(0)
|
|
49
|
+
.map((_, i): CustomLayout => {
|
|
50
|
+
return {
|
|
51
|
+
content: `${i}`,
|
|
52
|
+
h: 3,
|
|
53
|
+
i: i.toString(),
|
|
54
|
+
shouldUseFluidTypography: false,
|
|
55
|
+
w: 3,
|
|
56
|
+
x: (i * 3) % 12,
|
|
57
|
+
y: Math.floor(i / 12)
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
interface DashboardTemplateProps {
|
|
63
|
+
header?: JSX.Element;
|
|
64
|
+
layout?: Array<CustomLayout>;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const Header = (): JSX.Element => (
|
|
68
|
+
<Typography variant="body2">The title</Typography>
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const DashboardTemplate = ({
|
|
72
|
+
header,
|
|
73
|
+
layout = dashboardLayout
|
|
74
|
+
}: DashboardTemplateProps): JSX.Element => (
|
|
75
|
+
<DashboardLayout.Layout<CustomLayout> layout={layout}>
|
|
76
|
+
{layout.map(({ i, content, shouldUseFluidTypography }) => (
|
|
77
|
+
<DashboardLayout.Item header={header} key={i}>
|
|
78
|
+
{shouldUseFluidTypography ? (
|
|
79
|
+
<FluidTypography text={content} />
|
|
80
|
+
) : (
|
|
81
|
+
<Typography>{content}</Typography>
|
|
82
|
+
)}
|
|
83
|
+
</DashboardLayout.Item>
|
|
84
|
+
))}
|
|
85
|
+
</DashboardLayout.Layout>
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
export default {
|
|
89
|
+
argTypes: {},
|
|
90
|
+
component: DashboardTemplate,
|
|
91
|
+
title: 'Dashboard'
|
|
92
|
+
} as ComponentMeta<typeof DashboardTemplate>;
|
|
93
|
+
|
|
94
|
+
export const normal = DashboardTemplate.bind({});
|
|
95
|
+
|
|
96
|
+
export const withManyPanels = DashboardTemplate.bind({});
|
|
97
|
+
withManyPanels.args = {
|
|
98
|
+
layout: generateLayout(1000)
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export const withItemHeader = DashboardTemplate.bind({});
|
|
102
|
+
withItemHeader.args = {
|
|
103
|
+
header: <Header />
|
|
104
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { FC, useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Grid as VisxGrid } from '@visx/visx';
|
|
4
|
+
import { scaleLinear } from '@visx/scale';
|
|
5
|
+
|
|
6
|
+
import { useTheme } from '@mui/material';
|
|
7
|
+
|
|
8
|
+
import useMemoComponent from '../utils/useMemoComponent';
|
|
9
|
+
|
|
10
|
+
import { maxColumns, rowHeight } from './utils';
|
|
11
|
+
|
|
12
|
+
interface Props {
|
|
13
|
+
columns: number;
|
|
14
|
+
height: number;
|
|
15
|
+
width: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const Grid: FC<Props> = ({ width, height, columns }) => {
|
|
19
|
+
const theme = useTheme();
|
|
20
|
+
|
|
21
|
+
const xScale = useMemo(
|
|
22
|
+
() =>
|
|
23
|
+
scaleLinear({
|
|
24
|
+
domain: [0, maxColumns],
|
|
25
|
+
range: [0, width]
|
|
26
|
+
}),
|
|
27
|
+
[width]
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
const numberOfRows = Math.floor(height / (rowHeight + 16));
|
|
31
|
+
|
|
32
|
+
const yScale = useMemo(
|
|
33
|
+
() =>
|
|
34
|
+
scaleLinear({
|
|
35
|
+
domain: [0, numberOfRows],
|
|
36
|
+
range: [0, height]
|
|
37
|
+
}),
|
|
38
|
+
[height]
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const tick = maxColumns / columns;
|
|
42
|
+
|
|
43
|
+
const xTickValues = Array(columns)
|
|
44
|
+
.fill(0)
|
|
45
|
+
.map((_, index) => index * tick);
|
|
46
|
+
|
|
47
|
+
return useMemoComponent({
|
|
48
|
+
Component: (
|
|
49
|
+
<svg style={{ height, position: 'absolute', width }}>
|
|
50
|
+
<VisxGrid.GridColumns
|
|
51
|
+
height={height}
|
|
52
|
+
scale={xScale}
|
|
53
|
+
stroke={theme.palette.divider}
|
|
54
|
+
tickValues={xTickValues}
|
|
55
|
+
width={width}
|
|
56
|
+
/>
|
|
57
|
+
<VisxGrid.GridRows
|
|
58
|
+
height={height}
|
|
59
|
+
scale={yScale}
|
|
60
|
+
stroke={theme.palette.divider}
|
|
61
|
+
top={-10}
|
|
62
|
+
width={width}
|
|
63
|
+
/>
|
|
64
|
+
</svg>
|
|
65
|
+
),
|
|
66
|
+
memoProps: [height, width, columns]
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export default Grid;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { CSSProperties, ForwardedRef, MouseEvent, forwardRef } from 'react';
|
|
2
|
+
|
|
3
|
+
import { isNil } from 'ramda';
|
|
4
|
+
|
|
5
|
+
import { Card } from '@mui/material';
|
|
6
|
+
|
|
7
|
+
import useMemoComponent from '../utils/useMemoComponent';
|
|
8
|
+
|
|
9
|
+
import { useDashboardItemStyles } from './Dashboard.styles';
|
|
10
|
+
|
|
11
|
+
interface DashboardItemProps {
|
|
12
|
+
children: JSX.Element;
|
|
13
|
+
className?: string;
|
|
14
|
+
header?: JSX.Element;
|
|
15
|
+
key: string;
|
|
16
|
+
onMouseDown?: (e: MouseEvent<HTMLDivElement>) => void;
|
|
17
|
+
onMouseUp?: (e: MouseEvent<HTMLDivElement>) => void;
|
|
18
|
+
onTouchEnd?: (e) => void;
|
|
19
|
+
style?: CSSProperties;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const Item = forwardRef(
|
|
23
|
+
(
|
|
24
|
+
{
|
|
25
|
+
children,
|
|
26
|
+
key,
|
|
27
|
+
style,
|
|
28
|
+
className,
|
|
29
|
+
header,
|
|
30
|
+
onMouseDown,
|
|
31
|
+
onMouseUp,
|
|
32
|
+
onTouchEnd
|
|
33
|
+
}: DashboardItemProps,
|
|
34
|
+
ref: ForwardedRef<HTMLDivElement>
|
|
35
|
+
): JSX.Element => {
|
|
36
|
+
const { classes } = useDashboardItemStyles();
|
|
37
|
+
|
|
38
|
+
const hasHeader = !isNil(header);
|
|
39
|
+
|
|
40
|
+
const listeners = {
|
|
41
|
+
onMouseDown,
|
|
42
|
+
onMouseUp,
|
|
43
|
+
onTouchEnd
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const cardContainerListeners = !hasHeader ? listeners : {};
|
|
47
|
+
|
|
48
|
+
return useMemoComponent({
|
|
49
|
+
Component: (
|
|
50
|
+
<div
|
|
51
|
+
className={className}
|
|
52
|
+
key={key}
|
|
53
|
+
ref={ref}
|
|
54
|
+
style={style}
|
|
55
|
+
{...cardContainerListeners}
|
|
56
|
+
>
|
|
57
|
+
<Card className={classes.widgetContainer}>
|
|
58
|
+
{header && (
|
|
59
|
+
<div {...listeners} className={classes.widgetHeader}>
|
|
60
|
+
{header}
|
|
61
|
+
</div>
|
|
62
|
+
)}
|
|
63
|
+
<div className={classes.widgetContent}>{children}</div>
|
|
64
|
+
</Card>
|
|
65
|
+
</div>
|
|
66
|
+
),
|
|
67
|
+
memoProps: [key, style, className, header]
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
export default Item;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Responsive } from '@visx/visx';
|
|
4
|
+
import GridLayout, { WidthProvider, Layout } from 'react-grid-layout';
|
|
5
|
+
import 'react-grid-layout/css/styles.css';
|
|
6
|
+
|
|
7
|
+
import { Responsive as ResponsiveHeight, useMemoComponent } from '..';
|
|
8
|
+
|
|
9
|
+
import { useDashboardLayoutStyles } from './Dashboard.styles';
|
|
10
|
+
import { getColumnsFromScreenSize, getLayout, rowHeight } from './utils';
|
|
11
|
+
import Grid from './Grid';
|
|
12
|
+
|
|
13
|
+
const ReactGridLayout = WidthProvider(GridLayout);
|
|
14
|
+
|
|
15
|
+
interface DashboardLayoutProps<T> {
|
|
16
|
+
changeLayout?: (newLayout: Array<Layout>) => void;
|
|
17
|
+
children: Array<JSX.Element>;
|
|
18
|
+
displayGrid?: boolean;
|
|
19
|
+
layout: Array<T>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const Layout = <T extends Layout>({
|
|
23
|
+
children,
|
|
24
|
+
changeLayout,
|
|
25
|
+
displayGrid,
|
|
26
|
+
layout
|
|
27
|
+
}: DashboardLayoutProps<T>): JSX.Element => {
|
|
28
|
+
const { classes } = useDashboardLayoutStyles();
|
|
29
|
+
|
|
30
|
+
const [columns, setColumns] = useState(getColumnsFromScreenSize());
|
|
31
|
+
|
|
32
|
+
const resize = (): void => {
|
|
33
|
+
setColumns(getColumnsFromScreenSize());
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
window.addEventListener('resize', resize);
|
|
38
|
+
|
|
39
|
+
return (): void => {
|
|
40
|
+
window.removeEventListener('resize', resize);
|
|
41
|
+
};
|
|
42
|
+
}, []);
|
|
43
|
+
|
|
44
|
+
return useMemoComponent({
|
|
45
|
+
Component: (
|
|
46
|
+
<ResponsiveHeight>
|
|
47
|
+
<Responsive.ParentSize>
|
|
48
|
+
{({ width, height }): JSX.Element => (
|
|
49
|
+
<div className={classes.container}>
|
|
50
|
+
{displayGrid && (
|
|
51
|
+
<Grid columns={columns} height={height} width={width} />
|
|
52
|
+
)}
|
|
53
|
+
<ReactGridLayout
|
|
54
|
+
cols={columns}
|
|
55
|
+
containerPadding={[4, 0]}
|
|
56
|
+
layout={getLayout(layout)}
|
|
57
|
+
margin={[20, 20]}
|
|
58
|
+
resizeHandles={['s', 'e', 'se']}
|
|
59
|
+
rowHeight={rowHeight}
|
|
60
|
+
width={width}
|
|
61
|
+
onLayoutChange={changeLayout}
|
|
62
|
+
>
|
|
63
|
+
{children}
|
|
64
|
+
</ReactGridLayout>
|
|
65
|
+
</div>
|
|
66
|
+
)}
|
|
67
|
+
</Responsive.ParentSize>
|
|
68
|
+
</ResponsiveHeight>
|
|
69
|
+
),
|
|
70
|
+
memoProps: [columns, layout, displayGrid]
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export default Layout;
|
|
@@ -0,0 +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
|
+
};
|
|
@@ -17,7 +17,7 @@ import { alpha, Box, FormHelperText, Typography } from '@mui/material';
|
|
|
17
17
|
|
|
18
18
|
import { userAtom } from '@centreon/ui-context';
|
|
19
19
|
|
|
20
|
-
import
|
|
20
|
+
import useMemoComponent from '../utils/useMemoComponent';
|
|
21
21
|
|
|
22
22
|
import { labelDropOr, labelSelectAFile } from './translatedLabels';
|
|
23
23
|
import useDropzone, { UseDropzoneState } from './useDropzone';
|
package/src/Form/FormButtons.tsx
CHANGED
|
@@ -8,7 +8,8 @@ import { makeStyles } from 'tss-react/mui';
|
|
|
8
8
|
import { Button } from '@mui/material';
|
|
9
9
|
|
|
10
10
|
import SaveButton from '../Button/Save';
|
|
11
|
-
import
|
|
11
|
+
import useMemoComponent from '../utils/useMemoComponent';
|
|
12
|
+
import getNormalizedId from '../utils/getNormalizedId';
|
|
12
13
|
|
|
13
14
|
import {
|
|
14
15
|
labelReset,
|
|
@@ -9,7 +9,7 @@ import { FormHelperText, Stack } from '@mui/material';
|
|
|
9
9
|
import SingleAutocompleteField from '../../InputField/Select/Autocomplete';
|
|
10
10
|
import { labelPressEnterToAccept } from '../translatedLabels';
|
|
11
11
|
import MultiAutocompleteField from '../../InputField/Select/Autocomplete/Multi';
|
|
12
|
-
import
|
|
12
|
+
import useMemoComponent from '../../utils/useMemoComponent';
|
|
13
13
|
import { SelectEntry } from '../../InputField/Select';
|
|
14
14
|
|
|
15
15
|
import { InputPropsWithoutGroup, InputType } from './models';
|
|
@@ -6,7 +6,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
6
6
|
|
|
7
7
|
import { FormControlLabel, Switch as MUISwitch } from '@mui/material';
|
|
8
8
|
|
|
9
|
-
import
|
|
9
|
+
import getNormalizedId from '../../utils/getNormalizedId';
|
|
10
10
|
import { useMemoComponent } from '../..';
|
|
11
11
|
|
|
12
12
|
import { InputPropsWithoutGroup } from './models';
|
|
@@ -16,18 +16,16 @@ import {
|
|
|
16
16
|
import { CircularProgress, useTheme } from '@mui/material';
|
|
17
17
|
|
|
18
18
|
import { Props as AutocompleteFieldProps } from '..';
|
|
19
|
-
import
|
|
20
|
-
useDebounce,
|
|
21
|
-
useIntersectionObserver,
|
|
22
|
-
useDeepCompare
|
|
23
|
-
} from '../../../../utils';
|
|
19
|
+
import useIntersectionObserver from '../../../../utils/useIntersectionObserver';
|
|
24
20
|
import { ListingModel, SelectEntry } from '../../../..';
|
|
25
21
|
import Option from '../../Option';
|
|
26
22
|
import {
|
|
27
23
|
ConditionsSearchParameter,
|
|
28
24
|
SearchParameter
|
|
29
25
|
} from '../../../../api/buildListingEndpoint/models';
|
|
26
|
+
import useDebounce from '../../../../utils/useDebounce';
|
|
30
27
|
import useFetchQuery from '../../../../api/useFetchQuery';
|
|
28
|
+
import { useDeepCompare } from '../../../../utils/useMemoComponent';
|
|
31
29
|
|
|
32
30
|
export interface ConnectedAutoCompleteFieldProps<TData> {
|
|
33
31
|
conditionField?: keyof SelectEntry;
|
|
@@ -85,7 +85,7 @@ const AutoSizeAutocompleteField = ({
|
|
|
85
85
|
endAdornment,
|
|
86
86
|
customPadding
|
|
87
87
|
}: AutoSizeAutocompleteFieldProps): JSX.Element => {
|
|
88
|
-
const [value, setValue] = React.useState(
|
|
88
|
+
const [value, setValue] = React.useState(null);
|
|
89
89
|
|
|
90
90
|
const change = (_, newValue): void => {
|
|
91
91
|
setValue(newValue);
|
|
@@ -108,12 +108,3 @@ const AutoSizeAutocompleteField = ({
|
|
|
108
108
|
export const autoSize = (): JSX.Element => {
|
|
109
109
|
return <AutoSizeAutocompleteField />;
|
|
110
110
|
};
|
|
111
|
-
|
|
112
|
-
export const autoSizeWithCustomPadding = (): JSX.Element => {
|
|
113
|
-
return (
|
|
114
|
-
<AutoSizeAutocompleteField
|
|
115
|
-
customPadding={5}
|
|
116
|
-
endAdornment={<EndAdornment />}
|
|
117
|
-
/>
|
|
118
|
-
);
|
|
119
|
-
};
|
|
@@ -20,7 +20,7 @@ import Option from '../Option';
|
|
|
20
20
|
import TextField from '../../Text';
|
|
21
21
|
import { SelectEntry } from '..';
|
|
22
22
|
import { searchLabel } from '../../translatedLabels';
|
|
23
|
-
import
|
|
23
|
+
import getNormalizedId from '../../../utils/getNormalizedId';
|
|
24
24
|
|
|
25
25
|
export type Props = {
|
|
26
26
|
autoFocus?: boolean;
|
|
@@ -11,7 +11,7 @@ import { userAtom, ListingVariant } from '@centreon/ui-context';
|
|
|
11
11
|
|
|
12
12
|
import { ListingProps } from '../..';
|
|
13
13
|
import { labelOf, labelRowsPerPage } from '../translatedLabels';
|
|
14
|
-
import
|
|
14
|
+
import useMemoComponent from '../../utils/useMemoComponent';
|
|
15
15
|
import IconButton from '../../Button/Icon/index';
|
|
16
16
|
|
|
17
17
|
import StyledPagination from './Pagination';
|
package/src/Listing/index.tsx
CHANGED
|
@@ -31,7 +31,8 @@ import { Box, LinearProgress, Table, TableBody } from '@mui/material';
|
|
|
31
31
|
|
|
32
32
|
import { ListingVariant } from '@centreon/ui-context';
|
|
33
33
|
|
|
34
|
-
import
|
|
34
|
+
import useKeyObserver from '../utils/useKeyObserver';
|
|
35
|
+
import useMemoComponent from '../utils/useMemoComponent';
|
|
35
36
|
|
|
36
37
|
import ListingActionBar from './ActionBar';
|
|
37
38
|
import Cell from './Cell';
|
|
@@ -4,7 +4,7 @@ import { makeStyles } from 'tss-react/mui';
|
|
|
4
4
|
|
|
5
5
|
import { Box } from '@mui/material';
|
|
6
6
|
|
|
7
|
-
import
|
|
7
|
+
import useMemoComponent from '../utils/useMemoComponent';
|
|
8
8
|
import WithPanel from '../Panel/WithPanel';
|
|
9
9
|
|
|
10
10
|
import FilterSkeleton from './FilterSkeleton';
|
package/src/Panel/Memoized.tsx
CHANGED
|
@@ -6,7 +6,7 @@ import ForwardIcon from '@mui/icons-material/ArrowForwardIos';
|
|
|
6
6
|
|
|
7
7
|
import Panel from '..';
|
|
8
8
|
import ContentWithCircularLoading from '../../ContentWithCircularProgress';
|
|
9
|
-
import
|
|
9
|
+
import useMemoComponent from '../../utils/useMemoComponent';
|
|
10
10
|
|
|
11
11
|
import ExpandableSection from './ExpandableSection';
|
|
12
12
|
|