@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
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { ComponentMeta } from '@storybook/react';
|
|
2
|
+
|
|
3
|
+
import { Box } from '@mui/material';
|
|
4
|
+
|
|
5
|
+
import FluidTypography, { FluidTypographyProps } from '.';
|
|
6
|
+
|
|
7
|
+
interface Props extends FluidTypographyProps {
|
|
8
|
+
height?: string | number;
|
|
9
|
+
width?: string | number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const FluidTypographyTemplate = ({
|
|
13
|
+
width = '900px',
|
|
14
|
+
height = '700px',
|
|
15
|
+
text,
|
|
16
|
+
variant
|
|
17
|
+
}: Props): JSX.Element => {
|
|
18
|
+
return (
|
|
19
|
+
<Box sx={{ height, width }}>
|
|
20
|
+
<FluidTypography text={text} variant={variant} />
|
|
21
|
+
</Box>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default {
|
|
26
|
+
argTypes: {
|
|
27
|
+
height: { control: 'text' },
|
|
28
|
+
text: { control: 'text' },
|
|
29
|
+
variant: { control: 'text' },
|
|
30
|
+
width: { control: 'text' }
|
|
31
|
+
},
|
|
32
|
+
component: FluidTypographyTemplate,
|
|
33
|
+
title: 'Fluid Typography'
|
|
34
|
+
} as ComponentMeta<typeof FluidTypographyTemplate>;
|
|
35
|
+
|
|
36
|
+
export const basic = FluidTypographyTemplate.bind({});
|
|
37
|
+
basic.args = {
|
|
38
|
+
text: 'Hello world'
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const with200pxWidth = FluidTypographyTemplate.bind({});
|
|
42
|
+
with200pxWidth.args = {
|
|
43
|
+
height: '200px',
|
|
44
|
+
text: 'Hello world',
|
|
45
|
+
width: '200px'
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const with20pxHeight = FluidTypographyTemplate.bind({});
|
|
49
|
+
with20pxHeight.args = {
|
|
50
|
+
height: '20px',
|
|
51
|
+
text: 'Hello world'
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const withLongText = FluidTypographyTemplate.bind({});
|
|
55
|
+
withLongText.args = {
|
|
56
|
+
text: 'This is a very long text becaaaaaaause it has a lot to sayyyyy !!!!!!!!'
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export const withHeading5Variant = FluidTypographyTemplate.bind({});
|
|
60
|
+
withHeading5Variant.args = {
|
|
61
|
+
text: 'Hello world',
|
|
62
|
+
variant: 'h5'
|
|
63
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Typography, TypographyProps } from '@mui/material';
|
|
4
|
+
|
|
5
|
+
import useFluidResizeObserver from './useFluidResizeObserver';
|
|
6
|
+
|
|
7
|
+
type CustomTypographyProps = Pick<TypographyProps, 'variant'>;
|
|
8
|
+
export interface FluidTypographyProps extends CustomTypographyProps {
|
|
9
|
+
className?: string;
|
|
10
|
+
text: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const FluidTypography = ({
|
|
14
|
+
text,
|
|
15
|
+
variant = 'body1',
|
|
16
|
+
className
|
|
17
|
+
}: FluidTypographyProps): JSX.Element => {
|
|
18
|
+
const containerRef = useRef<HTMLElement>();
|
|
19
|
+
const parentRef = useRef<HTMLElement>();
|
|
20
|
+
|
|
21
|
+
const size = useFluidResizeObserver({ ref: containerRef });
|
|
22
|
+
const parentSize = useFluidResizeObserver({ isParent: true, ref: parentRef });
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<div
|
|
26
|
+
ref={parentRef}
|
|
27
|
+
style={{
|
|
28
|
+
height: `${parentSize.height}px`,
|
|
29
|
+
width: `100%`
|
|
30
|
+
}}
|
|
31
|
+
>
|
|
32
|
+
<div ref={containerRef} style={{ height: '100%', width: '100%' }}>
|
|
33
|
+
<Typography
|
|
34
|
+
className={className}
|
|
35
|
+
sx={{
|
|
36
|
+
fontSize: `clamp(10px, min(${Math.floor(
|
|
37
|
+
size.width / 6
|
|
38
|
+
)}px, ${Math.floor(size.height / 6)}px), min(${size.width}px, ${
|
|
39
|
+
size.height
|
|
40
|
+
}px))`
|
|
41
|
+
}}
|
|
42
|
+
variant={variant}
|
|
43
|
+
>
|
|
44
|
+
{text}
|
|
45
|
+
</Typography>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export default FluidTypography;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MutableRefObject,
|
|
3
|
+
useCallback,
|
|
4
|
+
useEffect,
|
|
5
|
+
useRef,
|
|
6
|
+
useState
|
|
7
|
+
} from 'react';
|
|
8
|
+
|
|
9
|
+
interface Size {
|
|
10
|
+
height: number;
|
|
11
|
+
width: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface UseFluidResizeObserver {
|
|
15
|
+
isParent?: boolean;
|
|
16
|
+
ref: MutableRefObject<HTMLElement | undefined>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const useFluidResizeObserver = ({
|
|
20
|
+
ref,
|
|
21
|
+
isParent
|
|
22
|
+
}: UseFluidResizeObserver): Size => {
|
|
23
|
+
const [size, setSize] = useState<Size>({ height: 0, width: 0 });
|
|
24
|
+
|
|
25
|
+
const observer = useRef<ResizeObserver | null>(null);
|
|
26
|
+
|
|
27
|
+
const resizeObserver = useCallback(
|
|
28
|
+
(element) => {
|
|
29
|
+
if (observer.current) {
|
|
30
|
+
observer.current.disconnect();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
observer.current = new ResizeObserver(
|
|
34
|
+
([entry]: Array<ResizeObserverEntry>) => {
|
|
35
|
+
setSize({
|
|
36
|
+
height: entry.target?.getBoundingClientRect().height || 0,
|
|
37
|
+
width: entry.target?.getBoundingClientRect().width || 0
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
if (element && observer.current) {
|
|
43
|
+
observer.current.observe(element);
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
[ref.current]
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
resizeObserver(isParent ? ref.current?.parentElement : ref.current);
|
|
51
|
+
}, [ref.current]);
|
|
52
|
+
|
|
53
|
+
return size;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export default useFluidResizeObserver;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import TypographyStory from './story.utils';
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
6
|
argTypes: {},
|
|
7
|
-
component:
|
|
7
|
+
component: TypographyStory,
|
|
8
8
|
title: 'Typography'
|
|
9
|
-
} as ComponentMeta<typeof
|
|
9
|
+
} as ComponentMeta<typeof TypographyStory>;
|
|
10
10
|
|
|
11
|
-
const TemplateTypographtStory: ComponentStory<typeof
|
|
11
|
+
const TemplateTypographtStory: ComponentStory<typeof TypographyStory> = (
|
|
12
12
|
args
|
|
13
|
-
) => <
|
|
13
|
+
) => <TypographyStory {...args} />;
|
|
14
14
|
|
|
15
15
|
export const typography = (): JSX.Element => (
|
|
16
16
|
<TemplateTypographtStory text="Hello world" />
|
package/src/__image_snapshots__/storyshots-test-js-image-story-shots-dashboard-normal-1-snap.png
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/index.ts
CHANGED
|
@@ -82,6 +82,15 @@ export type {
|
|
|
82
82
|
} from './api/buildListingEndpoint/models';
|
|
83
83
|
export { default as buildListingDecoder } from './api/buildListingDecoder';
|
|
84
84
|
|
|
85
|
+
export {
|
|
86
|
+
default as useLocaleDateTimeFormat,
|
|
87
|
+
dateTimeFormat,
|
|
88
|
+
dateFormat,
|
|
89
|
+
timeFormat
|
|
90
|
+
} from './utils/useLocaleDateTimeFormat';
|
|
91
|
+
|
|
92
|
+
export { default as useDebounce } from './utils/useDebounce';
|
|
93
|
+
export { default as useIntersectionObserver } from './utils/useIntersectionObserver';
|
|
85
94
|
export { default as ContentWithCircularLoading } from './ContentWithCircularProgress';
|
|
86
95
|
export {
|
|
87
96
|
setUrlQueryParameters,
|
|
@@ -93,6 +102,12 @@ export type {
|
|
|
93
102
|
ListsSearchParameter
|
|
94
103
|
} from './api/buildListingEndpoint/models';
|
|
95
104
|
|
|
105
|
+
export {
|
|
106
|
+
default as useMemoComponent,
|
|
107
|
+
useDeepCompare
|
|
108
|
+
} from './utils/useMemoComponent';
|
|
109
|
+
export { default as useCopyToClipboard } from './utils/useCopyToClipboard';
|
|
110
|
+
|
|
96
111
|
export { default as MenuSkeleton } from './MenuSkeleton';
|
|
97
112
|
export { default as PopoverMenu } from './PopoverMenu';
|
|
98
113
|
|
|
@@ -128,6 +143,8 @@ export {
|
|
|
128
143
|
} from './FileDropZone';
|
|
129
144
|
export type { CustomDropZoneContentProps } from './FileDropZone';
|
|
130
145
|
export { default as TestQueryProvider } from './api/TestQueryProvider';
|
|
146
|
+
export * from './utils/useThemeMode';
|
|
147
|
+
export * from './utils/typedMemo';
|
|
131
148
|
export * from './FallbackPage/FallbackPage';
|
|
132
149
|
export * from './Logo/CentreonLogo';
|
|
133
150
|
export * from './TopCounterElements';
|
|
@@ -135,7 +152,9 @@ export { default as Image, ImageVariant } from './Image/Image';
|
|
|
135
152
|
export { default as WallpaperPage } from './WallpaperPage';
|
|
136
153
|
export { RichTextEditor } from './RichTextEditor';
|
|
137
154
|
export { default as ActionsList } from './ActionsList';
|
|
155
|
+
export { getStatusColors, SeverityCode } from './utils/statuses';
|
|
138
156
|
|
|
139
157
|
export type { ResponseError, CatchErrorProps } from './api/customFetch';
|
|
140
158
|
|
|
141
|
-
export
|
|
159
|
+
export { default as FluidTypography } from './Typography/FluidTypography';
|
|
160
|
+
export * from './Dashboard';
|
|
@@ -10,8 +10,7 @@ interface Props {
|
|
|
10
10
|
errorMessage: string;
|
|
11
11
|
successMessage: string;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
export const useCopyToClipboard = ({
|
|
13
|
+
const useCopyToClipboard = ({
|
|
15
14
|
successMessage,
|
|
16
15
|
errorMessage
|
|
17
16
|
}: Props): Result => {
|
|
@@ -54,3 +53,5 @@ export const useCopyToClipboard = ({
|
|
|
54
53
|
|
|
55
54
|
return { copy };
|
|
56
55
|
};
|
|
56
|
+
|
|
57
|
+
export default useCopyToClipboard;
|
package/src/utils/useDebounce.ts
CHANGED
|
@@ -6,7 +6,7 @@ interface Props {
|
|
|
6
6
|
wait: number;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
const useDebounce = ({
|
|
10
10
|
functionToDebounce,
|
|
11
11
|
wait,
|
|
12
12
|
memoProps = []
|
|
@@ -23,3 +23,5 @@ export const useDebounce = ({
|
|
|
23
23
|
}, wait);
|
|
24
24
|
}, memoProps);
|
|
25
25
|
};
|
|
26
|
+
|
|
27
|
+
export default useDebounce;
|
|
@@ -7,9 +7,11 @@ interface UseDeepCallback<TParameters, TReturn, TMemoProps> {
|
|
|
7
7
|
deps: Array<TMemoProps>;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
const useDeepCallback = <TParameters, TReturn, TMemoProps>({
|
|
11
11
|
deps,
|
|
12
12
|
callback
|
|
13
13
|
}: UseDeepCallback<TParameters, TReturn, TMemoProps>): ((
|
|
14
14
|
props: TParameters
|
|
15
15
|
) => TReturn) => useCallback((props) => callback(props), useDeepCompare(deps));
|
|
16
|
+
|
|
17
|
+
export default useDeepCallback;
|
package/src/utils/useDeepMemo.ts
CHANGED
|
@@ -7,8 +7,10 @@ interface UseDeepMemo<TVariable, TMemoProps> {
|
|
|
7
7
|
variable: TVariable;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
const useDeepMemo = <TVariable, TMemoProps>({
|
|
11
11
|
deps,
|
|
12
12
|
variable
|
|
13
13
|
}: UseDeepMemo<TVariable, TMemoProps>): TVariable =>
|
|
14
14
|
useMemo(() => variable, useDeepCompare(deps));
|
|
15
|
+
|
|
16
|
+
export default useDeepMemo;
|
|
@@ -7,7 +7,7 @@ interface HookParam {
|
|
|
7
7
|
page: number;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
const useIntersectionObserver = ({
|
|
11
11
|
maxPage,
|
|
12
12
|
page,
|
|
13
13
|
loading,
|
|
@@ -41,3 +41,5 @@ export const useIntersectionObserver = ({
|
|
|
41
41
|
|
|
42
42
|
return lastElementRef;
|
|
43
43
|
};
|
|
44
|
+
|
|
45
|
+
export default useIntersectionObserver;
|
|
@@ -4,7 +4,7 @@ interface UseKeyObserverProps {
|
|
|
4
4
|
isShiftKeyDown: boolean;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
const useKeyObserver = (): UseKeyObserverProps => {
|
|
8
8
|
const [isShiftKeyDown, setIsShiftKeyDown] = useState<boolean>(false);
|
|
9
9
|
|
|
10
10
|
const pressShift = (): void => setIsShiftKeyDown(true);
|
|
@@ -34,3 +34,5 @@ export const useKeyObserver = (): UseKeyObserverProps => {
|
|
|
34
34
|
isShiftKeyDown
|
|
35
35
|
};
|
|
36
36
|
};
|
|
37
|
+
|
|
38
|
+
export default useKeyObserver;
|
|
@@ -10,7 +10,7 @@ import { Provider, useSetAtom } from 'jotai';
|
|
|
10
10
|
|
|
11
11
|
import { userAtom, ThemeMode } from '@centreon/ui-context';
|
|
12
12
|
|
|
13
|
-
import
|
|
13
|
+
import useLocaleDateTimeFormat from '.';
|
|
14
14
|
|
|
15
15
|
dayjs.extend(timezonePlugin);
|
|
16
16
|
dayjs.extend(utcPlugin);
|
|
@@ -10,7 +10,7 @@ import { render, RenderResult } from '@testing-library/react';
|
|
|
10
10
|
|
|
11
11
|
import { userAtom, ThemeMode } from '@centreon/ui-context';
|
|
12
12
|
|
|
13
|
-
import
|
|
13
|
+
import useLocaleDateTimeFormat from '.';
|
|
14
14
|
|
|
15
15
|
dayjs.extend(timezonePlugin);
|
|
16
16
|
dayjs.extend(utcPlugin);
|
|
@@ -19,8 +19,10 @@ interface MemoComponent {
|
|
|
19
19
|
memoProps: Array<unknown>;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
const useMemoComponent = ({
|
|
23
23
|
Component,
|
|
24
24
|
memoProps
|
|
25
25
|
}: MemoComponent): JSX.Element =>
|
|
26
26
|
useMemo(() => Component, useDeepCompare(memoProps));
|
|
27
|
+
|
|
28
|
+
export default useMemoComponent;
|
package/src/utils/index.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export * from './useLocaleDateTimeFormat';
|
|
2
|
-
export * from './getNormalizedId';
|
|
3
|
-
export * from './statuses';
|
|
4
|
-
export * from './typedMemo';
|
|
5
|
-
export * from './useCopyToClipboard';
|
|
6
|
-
export * from './useDateTimePickerAdapter';
|
|
7
|
-
export * from './useDebounce';
|
|
8
|
-
export * from './useDeepCallback';
|
|
9
|
-
export * from './useDeepMemo';
|
|
10
|
-
export * from './useIntersectionObserver';
|
|
11
|
-
export * from './useKeyObserver';
|
|
12
|
-
export * from './useLoadImage';
|
|
13
|
-
export * from './useMemoComponent';
|
|
14
|
-
export * from './useThemeMode';
|
|
15
|
-
export * from './useViewportIntersection';
|