@centreon/ui 23.10.25-feature-MON-19319.0 → 23.10.25

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.
Files changed (54) hide show
  1. package/package.json +1 -8
  2. package/src/Button/Save/index.stories.tsx +10 -5
  3. package/src/Dashboard/DashboardLayout.stories.tsx +5 -3
  4. package/src/Dashboard/Layout.tsx +4 -4
  5. package/src/Dashboard/utils.ts +28 -28
  6. package/src/ThemeProvider/index.tsx +5 -6
  7. package/src/ThemeProvider/palettes.ts +208 -234
  8. package/src/components/Button/Button.styles.ts +2 -7
  9. package/src/components/Button/Button.tsx +1 -1
  10. package/src/components/Form/Dashboard/Dashboard.resource.ts +1 -1
  11. package/src/components/Form/Dashboard/DashboardForm.tsx +10 -6
  12. package/src/components/Form/Dashboard/translatedLabels.ts +1 -0
  13. package/src/components/Header/Header.stories.tsx +27 -0
  14. package/src/components/Header/Header.styles.ts +27 -0
  15. package/src/components/Header/Header.tsx +23 -0
  16. package/src/components/Header/index.ts +1 -1
  17. package/src/components/index.ts +0 -2
  18. package/src/index.ts +2 -0
  19. package/src/layout/TiledListingPage/TiledListingActions.tsx +15 -0
  20. package/src/layout/TiledListingPage/TiledListingContent.tsx +21 -0
  21. package/src/layout/TiledListingPage/TiledListingList.tsx +11 -0
  22. package/src/layout/TiledListingPage/TiledListingPage.styles.ts +16 -0
  23. package/src/layout/TiledListingPage/TiledListingPage.tsx +15 -0
  24. package/src/layout/TiledListingPage/index.ts +4 -0
  25. package/src/screens/dashboard/DashboardsOverview.stories.tsx +101 -109
  26. package/test/setupTests.js +20 -23
  27. package/src/components/Header/PageHeader/PageHeader.stories.tsx +0 -83
  28. package/src/components/Header/PageHeader/PageHeader.styles.ts +0 -105
  29. package/src/components/Header/PageHeader/PageHeader.tsx +0 -15
  30. package/src/components/Header/PageHeader/PageHeaderActions.tsx +0 -17
  31. package/src/components/Header/PageHeader/PageHeaderMain.tsx +0 -15
  32. package/src/components/Header/PageHeader/PageHeaderMenu.tsx +0 -15
  33. package/src/components/Header/PageHeader/PageHeaderTitle.tsx +0 -44
  34. package/src/components/Header/PageHeader/index.ts +0 -12
  35. package/src/components/Layout/AreaIndicator.styles.ts +0 -33
  36. package/src/components/Layout/AreaIndicator.tsx +0 -35
  37. package/src/components/Layout/PageLayout/PageLayout.stories.tsx +0 -81
  38. package/src/components/Layout/PageLayout/PageLayout.styles.ts +0 -30
  39. package/src/components/Layout/PageLayout/PageLayout.tsx +0 -21
  40. package/src/components/Layout/PageLayout/PageLayoutActions.tsx +0 -15
  41. package/src/components/Layout/PageLayout/PageLayoutBody.tsx +0 -24
  42. package/src/components/Layout/PageLayout/PageLayoutHeader.tsx +0 -15
  43. package/src/components/Layout/PageLayout/index.ts +0 -10
  44. package/src/components/Layout/index.ts +0 -1
  45. package/src/components/Menu/Menu.tsx +0 -0
  46. package/src/components/Tooltip/TextOverflowTooltip/TextOverflowTooltip.stories.tsx +0 -71
  47. package/src/components/Tooltip/TextOverflowTooltip/TextOverflowTooltip.styles.ts +0 -5
  48. package/src/components/Tooltip/TextOverflowTooltip/TextOverflowTooltip.tsx +0 -115
  49. package/src/components/Tooltip/TextOverflowTooltip/index.tsx +0 -1
  50. package/src/components/Tooltip/Tooltip.stories.tsx +0 -41
  51. package/src/components/Tooltip/Tooltip.styles.ts +0 -5
  52. package/src/components/Tooltip/Tooltip.tsx +0 -46
  53. package/src/components/Tooltip/index.ts +0 -1
  54. package/src/utils/useResizeObserver.ts +0 -6
@@ -1,12 +0,0 @@
1
- import { PageHeader as PageHeaderRoot } from './PageHeader';
2
- import { PageHeaderMain } from './PageHeaderMain';
3
- import { PageHeaderMenu } from './PageHeaderMenu';
4
- import { PageHeaderTitle } from './PageHeaderTitle';
5
- import { PageHeaderActions } from './PageHeaderActions';
6
-
7
- export const PageHeader = Object.assign(PageHeaderRoot, {
8
- Actions: PageHeaderActions,
9
- Main: PageHeaderMain,
10
- Menu: PageHeaderMenu,
11
- Title: PageHeaderTitle
12
- });
@@ -1,33 +0,0 @@
1
- import { makeStyles } from 'tss-react/mui';
2
-
3
- export const useStyles = makeStyles()((theme) => ({
4
- areaIndicator: {
5
- '& .areaIndicator': {
6
- left: theme.spacing(10)
7
- },
8
- '& label:first-of-type': {
9
- border: '1px dashed #9747FF7F',
10
- borderRadius: '4px',
11
- color: '#9747FFFF',
12
- fontSize: '0.75rem',
13
- fontWeight: 500,
14
- left: theme.spacing(1),
15
- padding: theme.spacing(0.125, 1),
16
- position: 'absolute',
17
- top: theme.spacing(0.75)
18
- },
19
- '&[data-depth="1"]': {
20
- '& label:first-of-type': {
21
- '&:before': {
22
- content: '"+ "'
23
- },
24
- left: theme.spacing(10)
25
- }
26
- },
27
-
28
- backgroundColor: '#9747FF19',
29
- minHeight: theme.spacing(4),
30
-
31
- position: 'relative'
32
- }
33
- }));
@@ -1,35 +0,0 @@
1
- import { ReactElement, ReactNode } from 'react';
2
-
3
- import { useStyles } from './AreaIndicator.styles';
4
-
5
- type AreaIndicatorProps = {
6
- children?: ReactNode | Array<ReactNode>;
7
- depth?: number;
8
- height?: number | string;
9
- name: string;
10
- width?: number | string;
11
- };
12
-
13
- const AreaIndicator = ({
14
- children,
15
- name = 'area',
16
- width = '100%',
17
- height = '100%',
18
- depth = 0
19
- }: AreaIndicatorProps): ReactElement => {
20
- const { classes } = useStyles();
21
-
22
- return (
23
- <div
24
- className={classes.areaIndicator}
25
- data-depth={depth}
26
- style={{ height, width }}
27
- >
28
- {/* eslint-disable-next-line jsx-a11y/label-has-associated-control */}
29
- <label>{name}</label>
30
- {children}
31
- </div>
32
- );
33
- };
34
-
35
- export { AreaIndicator };
@@ -1,81 +0,0 @@
1
- import { Meta, StoryObj } from '@storybook/react';
2
-
3
- import { AreaIndicator } from '../AreaIndicator';
4
- import { Default as DefaultPageHeaderStory } from '../../Header/PageHeader/PageHeader.stories';
5
-
6
- import { PageLayout } from './index';
7
-
8
- const meta: Meta<typeof PageLayout> = {
9
- argTypes: {
10
- variant: {
11
- control: {
12
- options: ['default', 'fixed-header']
13
- }
14
- }
15
- },
16
- component: PageLayout,
17
- parameters: {
18
- layout: 'fullscreen'
19
- }
20
- };
21
-
22
- export default meta;
23
- type Story = StoryObj<typeof PageLayout>;
24
-
25
- export const Default: Story = {
26
- args: {
27
- children: (
28
- <>
29
- <PageLayout.Header>
30
- <AreaIndicator name="header" />
31
- </PageLayout.Header>
32
- <PageLayout.Body>
33
- <AreaIndicator height="100vh" name="body">
34
- <PageLayout.Actions>
35
- <AreaIndicator depth={1} name="actions" />
36
- </PageLayout.Actions>
37
- </AreaIndicator>
38
- </PageLayout.Body>
39
- </>
40
- ),
41
- variant: 'default'
42
- }
43
- };
44
-
45
- export const FixedHeader: Story = {
46
- args: {
47
- children: (
48
- <>
49
- <PageLayout.Header>
50
- <AreaIndicator name="header" />
51
- </PageLayout.Header>
52
- <PageLayout.Body hasBackground>
53
- <AreaIndicator height="100vh" name="body">
54
- <PageLayout.Actions>
55
- <AreaIndicator depth={1} name="actions" />
56
- </PageLayout.Actions>
57
- </AreaIndicator>
58
- </PageLayout.Body>
59
- </>
60
- ),
61
- variant: 'fixed-header'
62
- }
63
- };
64
-
65
- export const DefaultWithPageHeader: Story = {
66
- args: {
67
- children: (
68
- <>
69
- <PageLayout.Header>
70
- {/* eslint-disable react/jsx-pascal-case */}
71
- {/* @ts-expect-error storybook story render method not being recognised */}
72
- <DefaultPageHeaderStory.render {...DefaultPageHeaderStory.args} />
73
- </PageLayout.Header>
74
- <PageLayout.Body>
75
- <AreaIndicator height="100vh" name="body" />
76
- </PageLayout.Body>
77
- </>
78
- ),
79
- variant: 'default'
80
- }
81
- };
@@ -1,30 +0,0 @@
1
- import { makeStyles } from 'tss-react/mui';
2
-
3
- export const useStyles = makeStyles()((theme) => ({
4
- pageLayout: {
5
- display: 'flex',
6
- flexDirection: 'column',
7
- height: '100%'
8
- },
9
- pageLayoutActions: {
10
- paddingBottom: theme.spacing(2.5)
11
- },
12
- pageLayoutBody: {
13
- '&[data-has-background="true"]': {
14
- backgroundColor: theme.palette.layout.body.background
15
- },
16
- padding: theme.spacing(3, 4, 5)
17
- },
18
- pageLayoutHeader: {
19
- '[data-variant="fixed-header"] &': {
20
- backgroundColor: theme.palette.layout.header.background,
21
- borderBottom: `1px solid ${theme.palette.layout.header.border}`,
22
- padding: theme.spacing(5, 4, 2),
23
- position: 'sticky',
24
- top: 0,
25
- zIndex: `calc(${theme.zIndex.mobileStepper} - 100)`
26
- },
27
-
28
- padding: theme.spacing(5, 4, 0)
29
- }
30
- }));
@@ -1,21 +0,0 @@
1
- import { ReactElement, ReactNode } from 'react';
2
-
3
- import { useStyles } from './PageLayout.styles';
4
-
5
- type PageLayoutProps = {
6
- children: Array<ReactNode> | ReactNode;
7
- variant?: 'default' | 'fixed-header';
8
- };
9
-
10
- export const PageLayout = ({
11
- children,
12
- variant = 'default'
13
- }: PageLayoutProps): ReactElement => {
14
- const { classes } = useStyles();
15
-
16
- return (
17
- <section className={classes.pageLayout} data-variant={variant}>
18
- {children}
19
- </section>
20
- );
21
- };
@@ -1,15 +0,0 @@
1
- import { ReactElement, ReactNode } from 'react';
2
-
3
- import { useStyles } from './PageLayout.styles';
4
-
5
- type PageLayoutActionsProps = {
6
- children: Array<ReactNode> | ReactNode;
7
- };
8
-
9
- export const PageLayoutActions = ({
10
- children
11
- }: PageLayoutActionsProps): ReactElement => {
12
- const { classes } = useStyles();
13
-
14
- return <section className={classes.pageLayoutActions}>{children}</section>;
15
- };
@@ -1,24 +0,0 @@
1
- import { ReactElement, ReactNode } from 'react';
2
-
3
- import { useStyles } from './PageLayout.styles';
4
-
5
- type PageLayoutBodyProps = {
6
- children: Array<ReactNode> | ReactNode;
7
- hasBackground?: boolean;
8
- };
9
-
10
- export const PageLayoutBody = ({
11
- children,
12
- hasBackground = false
13
- }: PageLayoutBodyProps): ReactElement => {
14
- const { classes } = useStyles();
15
-
16
- return (
17
- <section
18
- className={classes.pageLayoutBody}
19
- data-has-background={hasBackground}
20
- >
21
- {children}
22
- </section>
23
- );
24
- };
@@ -1,15 +0,0 @@
1
- import { ReactNode } from 'react';
2
-
3
- import { useStyles } from './PageLayout.styles';
4
-
5
- type PageLayoutHeaderProps = {
6
- children: Array<ReactNode> | ReactNode;
7
- };
8
-
9
- export const PageLayoutHeader = ({
10
- children
11
- }: PageLayoutHeaderProps): JSX.Element => {
12
- const { classes } = useStyles();
13
-
14
- return <header className={classes.pageLayoutHeader}>{children}</header>;
15
- };
@@ -1,10 +0,0 @@
1
- import { PageLayout as PageLayoutRoot } from './PageLayout';
2
- import { PageLayoutHeader } from './PageLayoutHeader';
3
- import { PageLayoutBody } from './PageLayoutBody';
4
- import { PageLayoutActions } from './PageLayoutActions';
5
-
6
- export const PageLayout = Object.assign(PageLayoutRoot, {
7
- Actions: PageLayoutActions,
8
- Body: PageLayoutBody,
9
- Header: PageLayoutHeader
10
- });
@@ -1 +0,0 @@
1
- export * from './PageLayout';
File without changes
@@ -1,71 +0,0 @@
1
- /* eslint-disable react-hooks/rules-of-hooks */
2
- import { useEffect, useState } from 'react';
3
-
4
- import { Meta, StoryObj } from '@storybook/react';
5
-
6
- // import { expect } from '@storybook/jest';
7
- import { TextOverflowTooltip } from './TextOverflowTooltip';
8
-
9
- const meta: Meta<typeof TextOverflowTooltip> = {
10
- args: {},
11
- component: TextOverflowTooltip,
12
- parameters: {
13
- layout: 'centered'
14
- }
15
- };
16
-
17
- export default meta;
18
- type Story = StoryObj<typeof TextOverflowTooltip>;
19
-
20
- export const Default: Story = {
21
- args: {
22
- label:
23
- 'Qui deserunt pariatur quis. Duis nisi velit culpa labore ipsum reprehenderit sunt laborum anim sint quis magna consequat amet. Voluptate tempor nostrud eiusmod enim qui reprehenderit.'
24
- },
25
- render: ({ label, ...args }) => {
26
- const [labelValue, setLabelValue] = useState(label);
27
- useEffect(() => setLabelValue(label), [label]);
28
-
29
- return (
30
- <TextOverflowTooltip {...args} data-testid="tooltip" label={labelValue}>
31
- <p
32
- data-testid="paragraph"
33
- style={{
34
- overflow: 'hidden',
35
- textOverflow: 'ellipsis',
36
- whiteSpace: 'nowrap',
37
- width: '40vw'
38
- }}
39
- >
40
- {labelValue}
41
- </p>
42
- </TextOverflowTooltip>
43
- );
44
- }
45
- };
46
-
47
- export const AsMultiLine: Story = {
48
- args: {
49
- ...Default.args
50
- },
51
- render: ({ label, ...args }) => {
52
- const [labelValue, setLabelValue] = useState(label);
53
- useEffect(() => setLabelValue(label), [label]);
54
-
55
- return (
56
- <TextOverflowTooltip {...args} label={labelValue}>
57
- <p
58
- style={{
59
- WebkitBoxOrient: 'vertical',
60
- WebkitLineClamp: '2',
61
- display: '-webkit-box',
62
- overflow: 'hidden',
63
- width: '40vw'
64
- }}
65
- >
66
- {labelValue}
67
- </p>
68
- </TextOverflowTooltip>
69
- );
70
- }
71
- };
@@ -1,5 +0,0 @@
1
- import { makeStyles } from 'tss-react/mui';
2
-
3
- export const useStyles = makeStyles()(() => ({
4
- textOverflowTooltip: {}
5
- }));
@@ -1,115 +0,0 @@
1
- import { ReactElement, useCallback, useEffect, useRef } from 'react';
2
-
3
- import { atom, useAtom } from 'jotai';
4
-
5
- import { Tooltip, TooltipProps } from '../Tooltip';
6
- import { useResizeObserver } from '../../../utils/useResizeObserver';
7
-
8
- import { useStyles } from './TextOverflowTooltip.styles';
9
-
10
- type TextOverflowTooltipProps = Omit<TooltipProps, 'followCursor' | 'hasCaret'>;
11
-
12
- /** @description
13
- * This component is used to display a tooltip when the text is too long, and displays the full text on hover.
14
- *
15
- * It's up to the child component to define it's `width` / `max-width`, and ellipsis.
16
- *
17
- * For single lines use :
18
- * ```
19
- * width: var(--width-of-the-text);
20
- * white-space: nowrap;
21
- * ```
22
- *
23
- * For multi-lines use :
24
- * ```
25
- * width: var(--width-of-the-text);
26
- * display: -webkit-box;
27
- * -webkit-box-orient: vertical;
28
- * -webkit-line-clamp: var(--max-lines-of-the-text);
29
- * ```
30
- */
31
-
32
- const TextOverflowTooltip = ({
33
- children,
34
- label,
35
- position = 'bottom',
36
- isOpen,
37
- ...tooltipProps
38
- }: TextOverflowTooltipProps): ReactElement => {
39
- const { classes } = useStyles();
40
-
41
- const stateAtom = useRef(
42
- atom<{
43
- hasOverflow: boolean;
44
- isOpen: boolean;
45
- }>({ hasOverflow: false, isOpen: false })
46
- ).current;
47
-
48
- const [state, setState] = useAtom(stateAtom);
49
-
50
- const onMouseEnter = useCallback(
51
- () =>
52
- state.hasOverflow &&
53
- setState({
54
- ...state,
55
- isOpen: true
56
- }),
57
- [state.hasOverflow]
58
- );
59
-
60
- const onMouseLeave = useCallback(
61
- () =>
62
- state.hasOverflow &&
63
- setState({
64
- ...state,
65
- isOpen: false
66
- }),
67
- [state.hasOverflow]
68
- );
69
-
70
- const elRef = useRef<HTMLDivElement>(null);
71
-
72
- const onResize = (): void => {
73
- const { firstElementChild: el } = elRef.current || {};
74
- if (el instanceof HTMLElement) {
75
- setState({
76
- ...state,
77
- hasOverflow:
78
- el.scrollWidth > el.offsetWidth || el.scrollHeight > el.offsetHeight
79
- });
80
- }
81
- };
82
-
83
- useResizeObserver({
84
- onResize,
85
- ref: elRef
86
- });
87
-
88
- useEffect(() => {
89
- if (isOpen) setState({ ...state, isOpen });
90
- onResize();
91
- }, [isOpen, label]);
92
-
93
- return (
94
- <Tooltip
95
- followCursor
96
- hasCaret={false}
97
- isOpen={state.isOpen}
98
- label={label}
99
- position={position}
100
- {...tooltipProps}
101
- >
102
- <div
103
- className={classes.textOverflowTooltip}
104
- data-has-overflow={state.hasOverflow}
105
- ref={elRef}
106
- onMouseEnter={onMouseEnter}
107
- onMouseLeave={onMouseLeave}
108
- >
109
- {children}
110
- </div>
111
- </Tooltip>
112
- );
113
- };
114
-
115
- export { TextOverflowTooltip };
@@ -1 +0,0 @@
1
- export * from './TextOverflowTooltip';
@@ -1,41 +0,0 @@
1
- import { Meta, StoryObj } from '@storybook/react';
2
-
3
- import { Info as InfoIcon } from '@mui/icons-material';
4
-
5
- import { Tooltip } from './Tooltip';
6
-
7
- const meta: Meta<typeof Tooltip> = {
8
- argTypes: {
9
- position: {
10
- control: {
11
- options: ['top', 'bottom', 'left', 'right']
12
- }
13
- }
14
- },
15
- component: Tooltip,
16
- parameters: {
17
- layout: 'centered'
18
- }
19
- };
20
-
21
- export default meta;
22
- type Story = StoryObj<typeof Tooltip>;
23
-
24
- export const Default: Story = {
25
- args: {
26
- children: <InfoIcon />,
27
- label: 'Tooltip content'
28
- }
29
- };
30
-
31
- export const WrappedContent: Story = {
32
- args: {
33
- children: <InfoIcon />,
34
- followCursor: false,
35
- hasCaret: true,
36
- isOpen: true,
37
- label:
38
- 'Qui deserunt pariatur quis. Duis nisi velit culpa labore ipsum reprehenderit sunt laborum anim sint quis magna consequat amet. Voluptate tempor nostrud eiusmod enim qui reprehenderit.',
39
- position: 'right'
40
- }
41
- };
@@ -1,5 +0,0 @@
1
- import { makeStyles } from 'tss-react/mui';
2
-
3
- export const useStyles = makeStyles()(() => ({
4
- tooltip: {}
5
- }));
@@ -1,46 +0,0 @@
1
- import { ReactElement, ReactNode } from 'react';
2
-
3
- import { Tooltip as MuiTooltip } from '@mui/material';
4
-
5
- import { AriaLabelingAttributes } from '../../@types/aria-attributes';
6
- import { DataTestAttributes } from '../../@types/data-attributes';
7
-
8
- import { useStyles } from './Tooltip.styles';
9
-
10
- export type TooltipProps = {
11
- children: ReactElement;
12
- followCursor?: boolean;
13
- hasCaret?: boolean;
14
- isOpen?: boolean;
15
- label: ReactNode;
16
- position?: 'top' | 'bottom' | 'left' | 'right';
17
- } & AriaLabelingAttributes &
18
- DataTestAttributes;
19
-
20
- const Tooltip = ({
21
- children,
22
- label,
23
- position = 'bottom',
24
- followCursor = true,
25
- isOpen,
26
- hasCaret = false,
27
- ...attr
28
- }: TooltipProps): ReactElement => {
29
- const { classes } = useStyles();
30
-
31
- return (
32
- <MuiTooltip
33
- arrow={hasCaret}
34
- className={classes.tooltip}
35
- followCursor={followCursor}
36
- open={isOpen}
37
- placement={position}
38
- title={label}
39
- {...attr}
40
- >
41
- {children}
42
- </MuiTooltip>
43
- );
44
- };
45
-
46
- export { Tooltip };
@@ -1 +0,0 @@
1
- export * from './Tooltip';
@@ -1,6 +0,0 @@
1
- // https://github.com/ZeeCoder/use-resize-observer
2
- import useResizeObserver from 'use-resize-observer';
3
-
4
- export * from 'use-resize-observer';
5
-
6
- export { useResizeObserver };