@centreon/ui 24.4.54 → 24.4.56

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centreon/ui",
3
- "version": "24.4.54",
3
+ "version": "24.4.56",
4
4
  "description": "Centreon UI Components",
5
5
  "scripts": {
6
6
  "eslint": "eslint ./src --ext .js,.jsx,.ts,.tsx --max-warnings 0",
@@ -66,7 +66,7 @@
66
66
  "@storybook/preview-api": "^7.0.9",
67
67
  "@storybook/react": "^7.0.9",
68
68
  "@storybook/react-vite": "^7.0.9",
69
- "@storybook/test-runner": "^0.10.0",
69
+ "@storybook/test-runner": "^0.16.0",
70
70
  "@storybook/testing-library": "^0.1.0",
71
71
  "@storybook/theming": "^7.0.9",
72
72
  "@testing-library/cypress": "^8.0.7",
@@ -145,7 +145,7 @@
145
145
  "@mui/material": "5.x",
146
146
  "@mui/styles": "5.x",
147
147
  "@tanstack/react-query": "5.x",
148
- "axios": "0.x",
148
+ "axios": ">= 1.6.4",
149
149
  "dayjs": "1.x",
150
150
  "formik": "2.x",
151
151
  "jotai": "2.x",
@@ -27,6 +27,14 @@ const useStyles = makeStyles()((theme: Theme) => ({
27
27
  },
28
28
  noLabelInput: {
29
29
  padding: theme.spacing(1)
30
+ },
31
+ select: {
32
+ '& > fieldset > legend': {
33
+ maxWidth: 0
34
+ },
35
+ '&.Mui-focused > fieldset > legend': {
36
+ maxWidth: '100%'
37
+ }
30
38
  }
31
39
  }));
32
40
 
@@ -83,6 +91,9 @@ const SelectField = ({
83
91
  {label && <InputLabel>{label}</InputLabel>}
84
92
  <Select
85
93
  displayEmpty
94
+ classes={{
95
+ root: classes.select
96
+ }}
86
97
  fullWidth={fullWidth}
87
98
  inputProps={{
88
99
  'aria-label': ariaLabel,
@@ -0,0 +1,27 @@
1
+ import FluidTypography from '.';
2
+
3
+ const initialize = ({ width, min, max, pref }): void => {
4
+ cy.viewport(width, 590);
5
+
6
+ cy.mount({
7
+ Component: (
8
+ <FluidTypography max={max} min={min} pref={pref} text="Unreachable" />
9
+ )
10
+ });
11
+ };
12
+
13
+ describe('FluidTypography', () => {
14
+ [500, 300, 150].forEach((width) => {
15
+ Object.entries({ max: '80px', min: '30px', pref: 10 }).forEach(
16
+ ([key, value]) => {
17
+ it(`displays the text when the viewport is ${width}px and the ${key} is ${value}`, () => {
18
+ initialize({ [key]: value, width });
19
+
20
+ cy.contains('Unreachable').should('be.visible');
21
+
22
+ cy.matchImageSnapshot();
23
+ });
24
+ }
25
+ );
26
+ });
27
+ });
@@ -40,9 +40,9 @@ basic.args = {
40
40
 
41
41
  export const with200pxWidth = FluidTypographyTemplate.bind({});
42
42
  with200pxWidth.args = {
43
- height: '200px',
43
+ height: '50%',
44
44
  text: 'Hello world',
45
- width: '200px'
45
+ width: '50%'
46
46
  };
47
47
 
48
48
  export const with20pxHeight = FluidTypographyTemplate.bind({});
@@ -1,49 +1,42 @@
1
- import { useRef } from 'react';
2
-
3
1
  import { Typography, TypographyProps } from '@mui/material';
4
2
 
5
- import useFluidResizeObserver from './useFluidResizeObserver';
6
-
7
3
  type CustomTypographyProps = Pick<TypographyProps, 'variant'>;
8
4
  export interface FluidTypographyProps extends CustomTypographyProps {
9
5
  className?: string;
6
+ containerClassName?: string;
7
+ max?: string;
8
+ min?: string;
9
+ pref?: number;
10
10
  text: string;
11
11
  }
12
12
 
13
13
  const FluidTypography = ({
14
14
  text,
15
15
  variant = 'body1',
16
- className
16
+ className,
17
+ containerClassName,
18
+ min = '10px',
19
+ max = '1000px',
20
+ pref = 19
17
21
  }: 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
22
  return (
25
23
  <div
26
- ref={parentRef}
24
+ className={containerClassName}
27
25
  style={{
28
- height: `${parentSize.height}px`,
26
+ containerType: 'inline-size',
27
+ height: `100%`,
29
28
  width: `100%`
30
29
  }}
31
30
  >
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>
31
+ <Typography
32
+ className={className}
33
+ sx={{
34
+ fontSize: `clamp(${min}, ${pref}cqi, ${max})`
35
+ }}
36
+ variant={variant}
37
+ >
38
+ {text}
39
+ </Typography>
47
40
  </div>
48
41
  );
49
42
  };
package/src/api/index.ts CHANGED
@@ -30,7 +30,7 @@ const patchData =
30
30
  <TData, TResult>(cancelToken: CancelToken) =>
31
31
  ({ endpoint, data }: RequestWithData<TData>): Promise<TResult> =>
32
32
  axios
33
- .patch(endpoint, data, {
33
+ .patch(endpoint, JSON.stringify(data), {
34
34
  cancelToken,
35
35
  headers: contentTypeHeaders
36
36
  })
@@ -40,7 +40,7 @@ const postData =
40
40
  <TData, TResult>(cancelToken: CancelToken) =>
41
41
  ({ endpoint, data }: RequestWithData<TData>): Promise<TResult> =>
42
42
  axios
43
- .post(endpoint, data, {
43
+ .post(endpoint, JSON.stringify(data), {
44
44
  cancelToken,
45
45
  headers: contentTypeHeaders
46
46
  })
@@ -50,7 +50,7 @@ const putData =
50
50
  <TData, TResult>(cancelToken: CancelToken) =>
51
51
  ({ endpoint, data }: RequestWithData<TData>): Promise<TResult> =>
52
52
  axios
53
- .put(endpoint, data, {
53
+ .put(endpoint, JSON.stringify(data), {
54
54
  cancelToken,
55
55
  headers: contentTypeHeaders
56
56
  })
@@ -18,6 +18,11 @@ export const useFullscreenListener = (): boolean => {
18
18
  const toggle = (event: KeyboardEvent): void => {
19
19
  if (
20
20
  includes(document.activeElement?.tagName, ['INPUT', 'TEXTAREA']) ||
21
+ equals(
22
+ document.activeElement?.getAttribute('data-lexical-editor'),
23
+ 'true'
24
+ ) ||
25
+ equals(document.activeElement?.getAttribute('contenteditable'), 'true') ||
21
26
  !equals(event.code, 'KeyF')
22
27
  ) {
23
28
  return;
@@ -24,6 +24,7 @@ interface UseInfiniteScrollListing<T> {
24
24
  interface UseInfiniteScrollListingProps<T> {
25
25
  customQueryParameters?: Array<QueryParameter>;
26
26
  decoder?: JsonDecoder.Decoder<Listing<T>>;
27
+ enabled?: boolean;
27
28
  endpoint: string;
28
29
  limit?: number;
29
30
  pageAtom: PrimitiveAtom<number>;
@@ -40,7 +41,8 @@ export const useInfiniteScrollListing = <T>({
40
41
  suspense = true,
41
42
  parameters,
42
43
  customQueryParameters,
43
- limit = 100
44
+ limit = 100,
45
+ enabled = true
44
46
  }: UseInfiniteScrollListingProps<T>): UseInfiniteScrollListing<T> => {
45
47
  const [maxPage, setMaxPage] = useState(1);
46
48
 
@@ -61,6 +63,7 @@ export const useInfiniteScrollListing = <T>({
61
63
  getQueryKey: () => [queryKeyName, page],
62
64
  isPaginated: true,
63
65
  queryOptions: {
66
+ enabled,
64
67
  refetchOnMount: false,
65
68
  refetchOnWindowFocus: false,
66
69
  suspense: suspense && equals(page, 1)
@@ -1,56 +0,0 @@
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;