@centreon/ui 23.10.25-MON-19759-fe-correctly-handle-errors-return-by-register-instance-endpoint.4 → 23.10.25-MON-19506-dashboard-menu-component.2

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 (84) hide show
  1. package/package.json +12 -4
  2. package/src/Button/Save/index.stories.tsx +10 -5
  3. package/src/Dashboard/DashboardLayout.stories.tsx +3 -5
  4. package/src/Dashboard/Layout.tsx +4 -4
  5. package/src/Dashboard/utils.ts +28 -28
  6. package/src/InputField/Text/index.tsx +3 -0
  7. package/src/Snackbar/index.tsx +4 -14
  8. package/src/ThemeProvider/index.tsx +6 -5
  9. package/src/ThemeProvider/palettes.ts +385 -208
  10. package/src/base/tokens/README.md +3 -0
  11. package/src/base/tokens/source/$metadata.json +5 -0
  12. package/src/base/tokens/source/base.json +142 -0
  13. package/src/base/tokens/themes/base.tokens.d.ts +38 -0
  14. package/src/base/tokens/themes/base.tokens.json +695 -0
  15. package/src/base/tokens/themes/base.tokens.ts +38 -0
  16. package/src/base/tokens/themes/ui-dark.tokens.d.ts +38 -0
  17. package/src/base/tokens/themes/ui-dark.tokens.json +695 -0
  18. package/src/base/tokens/themes/ui-dark.tokens.ts +38 -0
  19. package/src/base/tokens/themes/ui-light.tokens.d.ts +38 -0
  20. package/src/base/tokens/themes/ui-light.tokens.json +695 -0
  21. package/src/base/tokens/themes/ui-light.tokens.ts +38 -0
  22. package/src/components/Button/Button.styles.ts +16 -3
  23. package/src/components/Button/Button.tsx +7 -4
  24. package/src/components/Form/Dashboard/Dashboard.resource.ts +1 -1
  25. package/src/components/Form/Dashboard/DashboardForm.tsx +10 -6
  26. package/src/components/Form/Dashboard/translatedLabels.ts +1 -0
  27. package/src/components/Header/Header.styles.ts +0 -27
  28. package/src/components/Header/PageHeader/PageHeader.stories.tsx +88 -0
  29. package/src/components/Header/PageHeader/PageHeader.styles.ts +99 -0
  30. package/src/components/Header/PageHeader/PageHeader.tsx +15 -0
  31. package/src/components/Header/PageHeader/PageHeaderActions.tsx +17 -0
  32. package/src/components/Header/PageHeader/PageHeaderMain.tsx +15 -0
  33. package/src/components/Header/PageHeader/PageHeaderMenu.tsx +15 -0
  34. package/src/components/Header/PageHeader/PageHeaderTitle.tsx +44 -0
  35. package/src/components/Header/PageHeader/index.ts +12 -0
  36. package/src/components/Header/index.ts +1 -1
  37. package/src/components/Layout/AreaIndicator.styles.ts +33 -0
  38. package/src/components/Layout/AreaIndicator.tsx +35 -0
  39. package/src/components/Layout/PageLayout/PageLayout.stories.tsx +81 -0
  40. package/src/components/Layout/PageLayout/PageLayout.styles.ts +30 -0
  41. package/src/components/Layout/PageLayout/PageLayout.tsx +21 -0
  42. package/src/components/Layout/PageLayout/PageLayoutActions.tsx +15 -0
  43. package/src/components/Layout/PageLayout/PageLayoutBody.tsx +24 -0
  44. package/src/components/Layout/PageLayout/PageLayoutHeader.tsx +15 -0
  45. package/src/components/Layout/PageLayout/index.ts +10 -0
  46. package/src/components/Layout/index.ts +1 -0
  47. package/src/components/Menu/Button/MenuButton.stories.tsx +16 -0
  48. package/src/components/Menu/Button/MenuButton.styles.ts +27 -0
  49. package/src/components/Menu/Button/MenuButton.tsx +59 -0
  50. package/src/components/Menu/Button/index.ts +1 -0
  51. package/src/components/Menu/Menu.stories.tsx +71 -0
  52. package/src/components/Menu/Menu.styles.ts +70 -0
  53. package/src/components/Menu/Menu.tsx +25 -0
  54. package/src/components/Menu/MenuDivider.tsx +17 -0
  55. package/src/components/Menu/MenuItem.tsx +39 -0
  56. package/src/components/Menu/MenuItems.tsx +35 -0
  57. package/src/components/Menu/index.ts +12 -0
  58. package/src/components/Menu/useMenu.tsx +79 -0
  59. package/src/components/Tooltip/TextOverflowTooltip/TextOverflowTooltip.stories.tsx +71 -0
  60. package/src/components/Tooltip/TextOverflowTooltip/TextOverflowTooltip.styles.ts +5 -0
  61. package/src/components/Tooltip/TextOverflowTooltip/TextOverflowTooltip.tsx +115 -0
  62. package/src/components/Tooltip/TextOverflowTooltip/index.tsx +1 -0
  63. package/src/components/Tooltip/Tooltip.stories.tsx +41 -0
  64. package/src/components/Tooltip/Tooltip.styles.ts +5 -0
  65. package/src/components/Tooltip/Tooltip.tsx +46 -0
  66. package/src/components/Tooltip/index.ts +1 -0
  67. package/src/components/index.ts +3 -0
  68. package/src/index.ts +0 -2
  69. package/src/screens/dashboard/DashboardsDetail.stories.tsx +93 -0
  70. package/src/screens/dashboard/DashboardsOverview.stories.tsx +110 -102
  71. package/src/styles/tokens/themes/_ui-dark.tokens.json +695 -0
  72. package/src/styles/tokens/themes/_ui-light.tokens.json +695 -0
  73. package/src/utils/index.ts +0 -1
  74. package/src/utils/useResizeObserver.ts +6 -0
  75. package/test/setupTests.js +1 -1
  76. package/src/components/Header/Header.stories.tsx +0 -27
  77. package/src/components/Header/Header.tsx +0 -23
  78. package/src/layout/TiledListingPage/TiledListingActions.tsx +0 -15
  79. package/src/layout/TiledListingPage/TiledListingContent.tsx +0 -21
  80. package/src/layout/TiledListingPage/TiledListingList.tsx +0 -11
  81. package/src/layout/TiledListingPage/TiledListingPage.styles.ts +0 -16
  82. package/src/layout/TiledListingPage/TiledListingPage.tsx +0 -15
  83. package/src/layout/TiledListingPage/index.ts +0 -4
  84. package/src/utils/useSanitizedHTML.ts +0 -18
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centreon/ui",
3
- "version": "23.10.25-MON-19759-fe-correctly-handle-errors-return-by-register-instance-endpoint.4",
3
+ "version": "23.10.25-MON-19506-dashboard-menu-component.2",
4
4
  "description": "Centreon UI Components",
5
5
  "scripts": {
6
6
  "eslint": "eslint ./src --ext .js,.jsx,.ts,.tsx --max-warnings 0",
@@ -8,10 +8,12 @@
8
8
  "storybook": "storybook dev -p 9001 -c .storybook",
9
9
  "build:storybook": "storybook build -c .storybook -o .out",
10
10
  "test": "jest",
11
+ "test:storybook:local": "test-storybook --url http://127.0.0.1:9001",
11
12
  "test:ci": "jest --silent --reporter=jest-junit",
12
13
  "cypress:ui": "cypress open --component --browser=chrome",
13
14
  "cypress:cli:updateSnapshot": "pnpm cypress:cli --env updateSnapshots=true",
14
- "cypress:cli": "cypress run --component --browser=chrome"
15
+ "cypress:cli": "cypress run --component --browser=chrome",
16
+ "tokens:transform": "TS_NODE_PROJECT=tsconfig.node.json ts-node style-dictionary.transform.ts"
15
17
  },
16
18
  "sideEffects": false,
17
19
  "repository": {
@@ -54,18 +56,23 @@
54
56
  "@storybook/addon-interactions": "^7.0.9",
55
57
  "@storybook/addon-styling": "^1.0.6",
56
58
  "@storybook/builder-vite": "^7.0.9",
59
+ "@storybook/jest": "^0.1.0",
57
60
  "@storybook/manager-api": "^7.0.9",
58
61
  "@storybook/mdx2-csf": "^1.0.0",
59
62
  "@storybook/preview-api": "^7.0.9",
60
63
  "@storybook/react": "^7.0.9",
61
64
  "@storybook/react-vite": "^7.0.9",
65
+ "@storybook/test-runner": "^0.10.0",
66
+ "@storybook/testing-library": "^0.1.0",
62
67
  "@storybook/theming": "^7.0.9",
63
68
  "@testing-library/cypress": "^8.0.7",
69
+ "@testing-library/jest-dom": "^5.16.5",
64
70
  "@testing-library/react": "^13.4.0",
65
71
  "@testing-library/react-hooks": "^8.0.1",
66
72
  "@types/jest": "^27.5.0",
67
73
  "@types/ramda": "^0.28.12",
68
74
  "@types/react": "^18.0.26",
75
+ "@types/testing-library__jest-dom": "^5.14.6",
69
76
  "@vitejs/plugin-react": "^4.0.0",
70
77
  "@vitejs/plugin-react-swc": "^3.3.0",
71
78
  "axios-mock-adapter": "^1.21.4",
@@ -83,6 +90,9 @@
83
90
  "storybook": "^7.0.9",
84
91
  "storybook-addon-mock": "^4.0.0",
85
92
  "storybook-dark-mode": "^3.0.0",
93
+ "style-dictionary": "^3.8.0",
94
+ "ts-node": "^10.9.1",
95
+ "use-resize-observer": "^9.1.0",
86
96
  "vite": "^4.3.5",
87
97
  "vite-plugin-svgr": "^3.2.0",
88
98
  "vite-plugin-turbosnap": "^1.0.2"
@@ -97,10 +107,8 @@
97
107
  "lexical": "0.8.0",
98
108
  "notistack": "^2.0.8",
99
109
  "react-grid-layout": "^1.3.4",
100
- "react-html-parser": "^2.0.2",
101
110
  "react-resizable": "^3.0.5",
102
111
  "react-transition-group": "^4.4.5",
103
- "sanitize-html": "^2.10.0",
104
112
  "ulog": "^2.0.0-beta.19"
105
113
  },
106
114
  "peerDependencies": {
@@ -1,4 +1,4 @@
1
- import { ComponentMeta, ComponentStory } from '@storybook/react';
1
+ import { ComponentStory } from '@storybook/react';
2
2
  import { makeStyles } from 'tss-react/mui';
3
3
 
4
4
  import { Theme } from '@mui/material';
@@ -13,7 +13,7 @@ const useStyles = makeStyles()((theme: Theme) => ({
13
13
  }
14
14
  }));
15
15
 
16
- export default {
16
+ const meta = {
17
17
  argTypes: {
18
18
  labelLoading: { control: 'text' },
19
19
  labelSave: { control: 'text' },
@@ -26,8 +26,13 @@ export default {
26
26
 
27
27
  component: ButtonSave,
28
28
 
29
+ parameters: {
30
+ chromatic: { delay: 300 }
31
+ },
29
32
  title: 'Button/Save'
30
- } as ComponentMeta<typeof ButtonSave>;
33
+ };
34
+
35
+ export default meta;
31
36
 
32
37
  const TemplateButtonSave: ComponentStory<typeof ButtonSave> = (args) => (
33
38
  <ButtonSave {...args} />
@@ -42,7 +47,7 @@ export const loading = (): JSX.Element => <ButtonSave loading />;
42
47
  export const succeeded = (): JSX.Element => <ButtonSave succeeded />;
43
48
 
44
49
  export const normalWithText = (): JSX.Element => (
45
- <ButtonSave labelSave="Save" />
50
+ <ButtonSave labelSave="Save" size="medium" />
46
51
  );
47
52
 
48
53
  export const largeWithText = (): JSX.Element => (
@@ -50,7 +55,7 @@ export const largeWithText = (): JSX.Element => (
50
55
  );
51
56
 
52
57
  export const loadingWithTextAndMediumSize = (): JSX.Element => (
53
- <ButtonSave loading labelLoading="Loading" />
58
+ <ButtonSave loading labelLoading="Loading" size="medium" />
54
59
  );
55
60
 
56
61
  export const succeededWithText = (): JSX.Element => (
@@ -1,5 +1,3 @@
1
- import { ReactElement } from 'react';
2
-
3
1
  import { ComponentMeta } from '@storybook/react';
4
2
  import { Layout } from 'react-grid-layout';
5
3
 
@@ -62,18 +60,18 @@ const generateLayout = (maxElements: number): Array<CustomLayout> => {
62
60
  };
63
61
 
64
62
  interface DashboardTemplateProps {
65
- header?: ReactElement;
63
+ header?: JSX.Element;
66
64
  layout?: Array<CustomLayout>;
67
65
  }
68
66
 
69
- const Header = (): ReactElement => (
67
+ const Header = (): JSX.Element => (
70
68
  <Typography variant="body2">The title</Typography>
71
69
  );
72
70
 
73
71
  const DashboardTemplate = ({
74
72
  header,
75
73
  layout = dashboardLayout
76
- }: DashboardTemplateProps): ReactElement => (
74
+ }: DashboardTemplateProps): JSX.Element => (
77
75
  <DashboardLayout.Layout<CustomLayout> layout={layout}>
78
76
  {layout.map(({ i, content, shouldUseFluidTypography }) => (
79
77
  <DashboardLayout.Item header={header} key={i}>
@@ -1,4 +1,4 @@
1
- import { ReactElement, useEffect, useState } from 'react';
1
+ import { useEffect, useState } from 'react';
2
2
 
3
3
  import { Responsive } from '@visx/visx';
4
4
  import GridLayout, { Layout, WidthProvider } from 'react-grid-layout';
@@ -14,7 +14,7 @@ const ReactGridLayout = WidthProvider(GridLayout);
14
14
 
15
15
  interface DashboardLayoutProps<T> {
16
16
  changeLayout?: (newLayout: Array<Layout>) => void;
17
- children: Array<ReactElement>;
17
+ children: Array<JSX.Element>;
18
18
  displayGrid?: boolean;
19
19
  layout: Array<T>;
20
20
  }
@@ -24,7 +24,7 @@ const Layout = <T extends Layout>({
24
24
  changeLayout,
25
25
  displayGrid,
26
26
  layout
27
- }: DashboardLayoutProps<T>): ReactElement => {
27
+ }: DashboardLayoutProps<T>): JSX.Element => {
28
28
  const { classes } = useDashboardLayoutStyles();
29
29
 
30
30
  const [columns, setColumns] = useState(getColumnsFromScreenSize());
@@ -45,7 +45,7 @@ const Layout = <T extends Layout>({
45
45
  Component: (
46
46
  <ResponsiveHeight>
47
47
  <Responsive.ParentSize>
48
- {({ width, height }): ReactElement => (
48
+ {({ width, height }): JSX.Element => (
49
49
  <div className={classes.container}>
50
50
  {displayGrid && (
51
51
  <Grid columns={columns} height={height} width={width} />
@@ -1,28 +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
- };
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
+ };
@@ -84,6 +84,7 @@ export type Props = {
84
84
  error?: string;
85
85
  externalValueForAutoSize?: string;
86
86
  open?: boolean;
87
+ required?: boolean;
87
88
  size?: SizeVariant;
88
89
  transparent?: boolean;
89
90
  value?: string;
@@ -108,6 +109,7 @@ const TextField = forwardRef(
108
109
  externalValueForAutoSize,
109
110
  autoSizeCustomPadding,
110
111
  defaultValue,
112
+ required = false,
111
113
  ...rest
112
114
  }: Props,
113
115
  ref: React.ForwardedRef<HTMLDivElement>
@@ -182,6 +184,7 @@ const TextField = forwardRef(
182
184
  ...rest.InputProps
183
185
  }}
184
186
  className={classes.textField}
187
+ required={required}
185
188
  sx={{
186
189
  width: autoSize ? width : undefined,
187
190
  ...rest?.sx
@@ -7,28 +7,22 @@ import { makeStyles } from 'tss-react/mui';
7
7
  import { IconButton, Alert } from '@mui/material';
8
8
  import IconClose from '@mui/icons-material/Close';
9
9
 
10
- import { useSanitizedHTML } from '../utils';
11
-
12
10
  import Severity from './Severity';
13
11
 
14
- const useStyles = makeStyles()((theme) => ({
12
+ const useStyles = makeStyles()({
15
13
  alertIcon: {
16
- paddingTop: theme.spacing(1.25)
14
+ paddingTop: '10px'
17
15
  },
18
16
  closeIcon: {
19
17
  fontSize: 20,
20
18
  opacity: 0.9
21
19
  },
22
20
  message: {
23
- '& a': {
24
- color: theme.palette.primary.main,
25
- textDecoration: 'none'
26
- },
27
21
  display: 'flex',
28
22
  flexDirection: 'column',
29
23
  justifyContent: 'center'
30
24
  }
31
- }));
25
+ });
32
26
 
33
27
  export interface SnackbarProps {
34
28
  id: string | number;
@@ -43,7 +37,6 @@ const Snackbar = React.forwardRef(
43
37
  ): JSX.Element => {
44
38
  const { classes } = useStyles();
45
39
  const { closeSnackbar } = useSnackbar();
46
- const sanitizedMessage = useSanitizedHTML({ initialContent: message });
47
40
  const timeoutId = React.useRef<number | undefined>();
48
41
 
49
42
  React.useEffect((): void => {
@@ -59,9 +52,6 @@ const Snackbar = React.forwardRef(
59
52
  closeSnackbar(id);
60
53
  };
61
54
 
62
- const formatedMessage =
63
- typeof message === 'string' ? <div>{sanitizedMessage}</div> : message;
64
-
65
55
  return (
66
56
  <SnackbarContent ref={ref}>
67
57
  <Alert
@@ -79,7 +69,7 @@ const Snackbar = React.forwardRef(
79
69
  severity={severity}
80
70
  variant="filled"
81
71
  >
82
- {formatedMessage}
72
+ {message}
83
73
  </Alert>
84
74
  </SnackbarContent>
85
75
  );
@@ -5,12 +5,12 @@ import { CSSInterpolation } from 'tss-react';
5
5
  import { equals } from 'ramda';
6
6
 
7
7
  import {
8
- ThemeProvider as MuiThemeProvider,
9
- Theme,
10
- StyledEngineProvider,
8
+ ButtonProps,
11
9
  createTheme,
12
10
  InputBaseProps,
13
- ButtonProps
11
+ StyledEngineProvider,
12
+ Theme,
13
+ ThemeProvider as MuiThemeProvider
14
14
  } from '@mui/material';
15
15
  import CssBaseline from '@mui/material/CssBaseline';
16
16
  import { autocompleteClasses } from '@mui/material/Autocomplete';
@@ -177,6 +177,7 @@ export const getTheme = (mode: ThemeMode): ThemeOptions => ({
177
177
  padding: 0;
178
178
  width: 100%;
179
179
  height: 100%;
180
+ text-rendering: optimizeLegibility;
180
181
  }
181
182
  body {
182
183
  background-color: ${theme.palette.background.paper};
@@ -205,7 +206,7 @@ export const getTheme = (mode: ThemeMode): ThemeOptions => ({
205
206
  @font-face {
206
207
  font-family: 'Roboto';
207
208
  font-style: normal;
208
- font-weight: 600;
209
+ font-weight: 700;
209
210
  src: local('Roboto'), local('Roboto-Bold'), url(${RobotoBoldWoff2}) format('woff2');
210
211
  }
211
212
  `