@centreon/ui 24.4.72 → 24.4.74
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 +24 -23
- package/src/Checkbox/fonts/roboto-bold-webfont.ttf +0 -0
- package/src/Checkbox/fonts/roboto-bold-webfont.woff +0 -0
- package/src/Checkbox/fonts/roboto-bold-webfont.woff2 +0 -0
- package/src/Checkbox/fonts/roboto-light-webfont.ttf +0 -0
- package/src/Checkbox/fonts/roboto-light-webfont.woff +0 -0
- package/src/Checkbox/fonts/roboto-light-webfont.woff2 +0 -0
- package/src/Checkbox/fonts/roboto-medium-webfont.ttf +0 -0
- package/src/Checkbox/fonts/roboto-medium-webfont.woff +0 -0
- package/src/Checkbox/fonts/roboto-medium-webfont.woff2 +0 -0
- package/src/Checkbox/fonts/roboto-regular-webfont.ttf +0 -0
- package/src/Checkbox/fonts/roboto-regular-webfont.woff +0 -0
- package/src/Checkbox/fonts/roboto-regular-webfont.woff2 +0 -0
- package/src/Dashboard/Item.tsx +2 -11
- package/src/Dashboard/Layout.tsx +2 -4
- package/src/Dashboard/utils.ts +1 -1
- package/src/Form/Inputs/Grid.tsx +8 -4
- package/src/Form/Inputs/models.ts +15 -14
- package/src/Graph/BarStack/BarStack.cypress.spec.tsx +87 -9
- package/src/Graph/BarStack/BarStack.stories.tsx +4 -2
- package/src/Graph/BarStack/BarStack.styles.ts +59 -30
- package/src/Graph/BarStack/Graph.tsx +176 -0
- package/src/Graph/BarStack/GraphAndLegend.tsx +119 -0
- package/src/Graph/BarStack/ResponsiveBarStack.tsx +62 -157
- package/src/Graph/BarStack/constants.ts +5 -0
- package/src/Graph/BarStack/models.ts +1 -1
- package/src/Graph/BarStack/useGraphAndLegend.ts +86 -0
- package/src/Graph/BarStack/useResponsiveBarStack.ts +74 -99
- package/src/Graph/HeatMap/ResponsiveHeatMap.tsx +19 -2
- package/src/Graph/HeatMap/model.ts +5 -1
- package/src/Graph/Legend/Legend.styles.ts +10 -0
- package/src/Graph/Legend/Legend.tsx +6 -1
- package/src/Graph/LineChart/BasicComponents/Lines/RegularLines/index.tsx +2 -1
- package/src/Graph/LineChart/BasicComponents/Lines/StackedLines/index.tsx +3 -4
- package/src/Graph/LineChart/Icons/Downtime.tsx +3 -3
- package/src/Graph/LineChart/InteractiveComponents/ZoomPreview/index.tsx +2 -1
- package/src/Graph/LineChart/Legend/Legend.styles.ts +16 -5
- package/src/Graph/LineChart/Legend/LegendHeader.tsx +4 -1
- package/src/Graph/LineChart/Legend/index.tsx +12 -5
- package/src/Graph/LineChart/LineChart.cypress.spec.tsx +53 -0
- package/src/Graph/LineChart/LineChart.tsx +10 -9
- package/src/Graph/LineChart/index.stories.tsx +13 -0
- package/src/Graph/LineChart/mockedData/curvesWithSameColor.json +252 -0
- package/src/Graph/LineChart/useLineChartData.ts +68 -18
- package/src/Graph/PieChart/ResponsivePie.tsx +3 -1
- package/src/Graph/PieChart/models.ts +1 -0
- package/src/Graph/Tree/DescendantNodes.tsx +0 -1
- package/src/Graph/Tree/Links.tsx +2 -15
- package/src/Graph/Tree/Tree.cypress.spec.tsx +0 -24
- package/src/Graph/Tree/Tree.stories.tsx +1 -17
- package/src/Graph/Tree/models.ts +0 -3
- package/src/Graph/common/utils.ts +51 -2
- package/src/Icon/BaseIcon.tsx +32 -0
- package/src/Icon/DowntimeIcon.tsx +14 -0
- package/src/InputField/Select/Autocomplete/Connected/Multi/index.test.tsx +21 -1
- package/src/InputField/Select/Autocomplete/Connected/index.test.tsx +2 -2
- package/src/InputField/Select/Autocomplete/Connected/index.tsx +10 -7
- package/src/InputField/Select/Autocomplete/Multi/index.stories.tsx +19 -0
- package/src/InputField/Select/Autocomplete/Multi/index.tsx +8 -5
- package/src/InputField/Text/index.tsx +7 -5
- package/src/Listing/ActionBar/index.tsx +1 -0
- package/src/PopoverMenu/index.tsx +4 -4
- package/src/RichTextEditor/ContentEditable.tsx +195 -195
- package/src/StoryBookThemeProvider/index.tsx +35 -36
- package/src/ThemeProvider/index.tsx +12 -12
- package/src/ThemeProvider/palettes.ts +11 -8
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/PickersStartEndDate.tsx +2 -3
- package/src/TimePeriods/DateTimePickerInput.tsx +4 -1
- package/src/TopCounterElements/TopCounterLayout.tsx +4 -3
- package/src/TopCounterElements/useCloseOnLegacyPage.tsx +9 -6
- package/src/api/buildListingEndpoint/getSearchQueryParameterValue.ts +7 -1
- package/src/api/buildListingEndpoint/models.ts +1 -0
- package/src/api/useGraphQuery/index.ts +1 -7
- package/src/components/Form/AccessRights/AccessRights.cypress.spec.tsx +13 -27
- package/src/components/Form/AccessRights/AccessRights.stories.tsx +19 -0
- package/src/components/Form/AccessRights/AccessRights.styles.ts +1 -1
- package/src/components/Form/AccessRights/AccessRights.tsx +5 -6
- package/src/components/Form/AccessRights/Actions/Actions.styles.ts +7 -3
- package/src/components/Form/AccessRights/Actions/Actions.tsx +32 -15
- package/src/components/Form/AccessRights/Actions/useActions.ts +37 -4
- package/src/components/Form/AccessRights/models.ts +3 -0
- package/src/components/Form/AccessRights/storiesData.ts +3 -0
- package/src/components/List/Item/ListItem.styles.ts +2 -2
- package/src/components/Zoom/Minimap.tsx +2 -4
- package/src/components/Zoom/Zoom.cypress.spec.tsx +13 -13
- package/src/components/Zoom/Zoom.tsx +1 -4
- package/src/components/Zoom/ZoomContent.tsx +2 -5
- package/src/components/index.ts +0 -1
- package/src/fonts/roboto-bold-webfont.ttf +0 -0
- package/src/fonts/roboto-bold-webfont.woff +0 -0
- package/src/fonts/roboto-bold-webfont.woff2 +0 -0
- package/src/fonts/roboto-light-webfont.ttf +0 -0
- package/src/fonts/roboto-light-webfont.woff +0 -0
- package/src/fonts/roboto-light-webfont.woff2 +0 -0
- package/src/fonts/roboto-medium-webfont.ttf +0 -0
- package/src/fonts/roboto-medium-webfont.woff +0 -0
- package/src/fonts/roboto-medium-webfont.woff2 +0 -0
- package/src/fonts/roboto-regular-webfont.ttf +0 -0
- package/src/fonts/roboto-regular-webfont.woff +0 -0
- package/src/fonts/roboto-regular-webfont.woff2 +0 -0
- package/src/index.ts +1 -0
- package/src/utils/index.ts +25 -25
- package/src/utils/useFullscreen/Fullscreen.cypress.spec.tsx +3 -0
- package/src/utils/useInfiniteScrollListing.ts +6 -1
- package/src/utils/useLocale/index.ts +10 -0
- package/src/utils/useLocale/useLocale.cypress.spec.tsx +40 -0
- package/src/utils/useLocaleDateTimeFormat/index.ts +5 -2
- package/src/utils/usePluralizedTranslation.ts +4 -21
- package/src/@assets/icons/downtime.icon.svg +0 -1
- package/src/components/Form/AccessRights/useAccessRightsChange.ts +0 -30
- package/src/components/Form/AccessRights/utils.ts +0 -18
- package/src/components/Tabs/Tab.styles.ts +0 -25
- package/src/components/Tabs/TabPanel.tsx +0 -22
- package/src/components/Tabs/Tabs.cypress.spec.tsx +0 -70
- package/src/components/Tabs/Tabs.stories.tsx +0 -55
- package/src/components/Tabs/Tabs.tsx +0 -55
- package/src/components/Tabs/index.ts +0 -6
- package/src/utils/resourcesStatusURL.ts +0 -166
- package/src/utils/usePluralizedTranslation.test.ts +0 -159
- /package/{public → src/Button}/fonts/roboto-bold-webfont.ttf +0 -0
- /package/{public → src/Button}/fonts/roboto-bold-webfont.woff +0 -0
- /package/{public → src/Button}/fonts/roboto-bold-webfont.woff2 +0 -0
- /package/{public → src/Button}/fonts/roboto-light-webfont.ttf +0 -0
- /package/{public → src/Button}/fonts/roboto-light-webfont.woff +0 -0
- /package/{public → src/Button}/fonts/roboto-light-webfont.woff2 +0 -0
- /package/{public → src/Button}/fonts/roboto-medium-webfont.ttf +0 -0
- /package/{public → src/Button}/fonts/roboto-medium-webfont.woff +0 -0
- /package/{public → src/Button}/fonts/roboto-medium-webfont.woff2 +0 -0
- /package/{public → src/Button}/fonts/roboto-regular-webfont.ttf +0 -0
- /package/{public → src/Button}/fonts/roboto-regular-webfont.woff +0 -0
- /package/{public → src/Button}/fonts/roboto-regular-webfont.woff2 +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@centreon/ui",
|
|
3
|
-
"version": "24.4.
|
|
3
|
+
"version": "24.4.74",
|
|
4
4
|
"description": "Centreon UI Components",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"update:deps": "pnpx npm-check-updates -i --format group",
|
|
@@ -52,13 +52,13 @@
|
|
|
52
52
|
"@cypress/react": "^8.0.0",
|
|
53
53
|
"@cypress/webpack-dev-server": "^3.7.4",
|
|
54
54
|
"@faker-js/faker": "^8.4.1",
|
|
55
|
-
"@mdx-js/react": "^3.0
|
|
56
|
-
"@simonsmith/cypress-image-snapshot": "^9.0
|
|
55
|
+
"@mdx-js/react": "^3.1.0",
|
|
56
|
+
"@simonsmith/cypress-image-snapshot": "^9.1.0",
|
|
57
57
|
"@storybook/addon-a11y": "^7.0.9",
|
|
58
58
|
"@storybook/addon-docs": "^7.0.9",
|
|
59
59
|
"@storybook/addon-essentials": "^7.0.9",
|
|
60
60
|
"@storybook/addon-interactions": "^7.0.9",
|
|
61
|
-
"@storybook/addon-styling": "^1.
|
|
61
|
+
"@storybook/addon-styling": "^1.3.7",
|
|
62
62
|
"@storybook/blocks": "^7.0.26",
|
|
63
63
|
"@storybook/builder-vite": "^7.0.9",
|
|
64
64
|
"@storybook/jest": "^0.1.0",
|
|
@@ -74,13 +74,13 @@
|
|
|
74
74
|
"@testing-library/jest-dom": "^5.16.5",
|
|
75
75
|
"@testing-library/react": "^13.4.0",
|
|
76
76
|
"@testing-library/react-hooks": "^8.0.1",
|
|
77
|
-
"@types/jest": "^29.5.
|
|
78
|
-
"@types/mocha": "^10.0.
|
|
77
|
+
"@types/jest": "^29.5.14",
|
|
78
|
+
"@types/mocha": "^10.0.10",
|
|
79
79
|
"@types/ramda": "^0.29.9",
|
|
80
80
|
"@types/react": "^18.2.65",
|
|
81
81
|
"@types/testing-library__jest-dom": "^6.0.0",
|
|
82
|
-
"@vitejs/plugin-react": "^4.
|
|
83
|
-
"@vitejs/plugin-react-swc": "^3.
|
|
82
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
83
|
+
"@vitejs/plugin-react-swc": "^3.8.0",
|
|
84
84
|
"axios-mock-adapter": "^1.22.0",
|
|
85
85
|
"cypress": "^13.7.1",
|
|
86
86
|
"identity-obj-proxy": "^3.0.0",
|
|
@@ -88,6 +88,7 @@
|
|
|
88
88
|
"mochawesome": "^7.1.3",
|
|
89
89
|
"msw": "1.3.2",
|
|
90
90
|
"msw-storybook-addon": "^1.10.0",
|
|
91
|
+
"playwright": "^1.50.1",
|
|
91
92
|
"puppeteer": "^13.7.0",
|
|
92
93
|
"react": "^18.2.0",
|
|
93
94
|
"react-dom": "^18.2.0",
|
|
@@ -113,33 +114,33 @@
|
|
|
113
114
|
"@lexical/rich-text": "^0.12.6",
|
|
114
115
|
"@lexical/selection": "^0.12.6",
|
|
115
116
|
"@lexical/utils": "^0.12.6",
|
|
116
|
-
"@react-spring/web": "^9.7.
|
|
117
|
-
"@visx/clip-path": "^3.
|
|
117
|
+
"@react-spring/web": "^9.7.5",
|
|
118
|
+
"@visx/clip-path": "^3.12.0",
|
|
118
119
|
"@visx/curve": "^2.1.0",
|
|
119
|
-
"@visx/event": "^3.
|
|
120
|
-
"@visx/group": "^3.
|
|
121
|
-
"@visx/hierarchy": "^3.
|
|
122
|
-
"@visx/legend": "^3.
|
|
123
|
-
"@visx/pattern": "^3.
|
|
124
|
-
"@visx/point": "^3.
|
|
125
|
-
"@visx/scale": "^3.
|
|
120
|
+
"@visx/event": "^3.12.0",
|
|
121
|
+
"@visx/group": "^3.12.0",
|
|
122
|
+
"@visx/hierarchy": "^3.12.0",
|
|
123
|
+
"@visx/legend": "^3.12.0",
|
|
124
|
+
"@visx/pattern": "^3.12.0",
|
|
125
|
+
"@visx/point": "^3.12.0",
|
|
126
|
+
"@visx/scale": "^3.12.0",
|
|
126
127
|
"@visx/shape": "^2.18.0",
|
|
127
|
-
"@visx/text": "^3.
|
|
128
|
+
"@visx/text": "^3.12.0",
|
|
128
129
|
"@visx/threshold": "^2.12.2",
|
|
129
130
|
"@visx/visx": "2.16.0",
|
|
130
|
-
"@visx/zoom": "^3.
|
|
131
|
+
"@visx/zoom": "^3.12.0",
|
|
131
132
|
"anylogger": "^1.0.11",
|
|
132
133
|
"d3-array": "3.2.4",
|
|
133
|
-
"humanize-duration": "^3.
|
|
134
|
+
"humanize-duration": "^3.32.1",
|
|
134
135
|
"lexical": "^0.12.6",
|
|
135
|
-
"notistack": "^3.0.
|
|
136
|
+
"notistack": "^3.0.2",
|
|
136
137
|
"numeral": "^2.0.6",
|
|
137
138
|
"ramda": "0.29.1",
|
|
138
|
-
"react-grid-layout": "^1.
|
|
139
|
+
"react-grid-layout": "^1.5.0",
|
|
139
140
|
"react-html-parser": "^2.0.2",
|
|
140
141
|
"react-resizable": "^3.0.5",
|
|
141
142
|
"react-transition-group": "^4.4.5",
|
|
142
|
-
"sanitize-html": "^2.
|
|
143
|
+
"sanitize-html": "^2.14.0",
|
|
143
144
|
"ulog": "^2.0.0-beta.19"
|
|
144
145
|
},
|
|
145
146
|
"peerDependencies": {
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/Dashboard/Item.tsx
CHANGED
|
@@ -15,7 +15,6 @@ import { useMemoComponent } from '../utils';
|
|
|
15
15
|
import { useDashboardItemStyles } from './Dashboard.styles';
|
|
16
16
|
|
|
17
17
|
interface DashboardItemProps {
|
|
18
|
-
additionalMemoProps?: Array<unknown>;
|
|
19
18
|
canMove?: boolean;
|
|
20
19
|
children: ReactElement;
|
|
21
20
|
className?: string;
|
|
@@ -40,8 +39,7 @@ const Item = forwardRef<HTMLDivElement, DashboardItemProps>(
|
|
|
40
39
|
onTouchEnd,
|
|
41
40
|
id,
|
|
42
41
|
disablePadding = false,
|
|
43
|
-
canMove = false
|
|
44
|
-
additionalMemoProps = []
|
|
42
|
+
canMove = false
|
|
45
43
|
}: DashboardItemProps,
|
|
46
44
|
ref: ForwardedRef<HTMLDivElement>
|
|
47
45
|
): ReactElement => {
|
|
@@ -94,14 +92,7 @@ const Item = forwardRef<HTMLDivElement, DashboardItemProps>(
|
|
|
94
92
|
</Card>
|
|
95
93
|
</div>
|
|
96
94
|
),
|
|
97
|
-
memoProps: [
|
|
98
|
-
style,
|
|
99
|
-
className,
|
|
100
|
-
header,
|
|
101
|
-
theme.palette.mode,
|
|
102
|
-
canMove,
|
|
103
|
-
...additionalMemoProps
|
|
104
|
-
]
|
|
95
|
+
memoProps: [style, className, header, theme.palette.mode, canMove]
|
|
105
96
|
});
|
|
106
97
|
}
|
|
107
98
|
);
|
package/src/Dashboard/Layout.tsx
CHANGED
|
@@ -16,7 +16,6 @@ import Grid from './Grid';
|
|
|
16
16
|
const ReactGridLayout = WidthProvider(GridLayout);
|
|
17
17
|
|
|
18
18
|
interface DashboardLayoutProps<T> {
|
|
19
|
-
additionalMemoProps?: Array<unknown>;
|
|
20
19
|
changeLayout?: (newLayout: Array<Layout>) => void;
|
|
21
20
|
children: Array<JSX.Element>;
|
|
22
21
|
displayGrid?: boolean;
|
|
@@ -29,8 +28,7 @@ const DashboardLayout = <T extends Layout>({
|
|
|
29
28
|
changeLayout,
|
|
30
29
|
displayGrid,
|
|
31
30
|
layout,
|
|
32
|
-
isStatic = false
|
|
33
|
-
additionalMemoProps = []
|
|
31
|
+
isStatic = false
|
|
34
32
|
}: DashboardLayoutProps<T>): JSX.Element => {
|
|
35
33
|
const { classes } = useDashboardLayoutStyles(isStatic);
|
|
36
34
|
|
|
@@ -74,7 +72,7 @@ const DashboardLayout = <T extends Layout>({
|
|
|
74
72
|
</ParentSize>
|
|
75
73
|
</ResponsiveHeight>
|
|
76
74
|
),
|
|
77
|
-
memoProps: [columns, layout, displayGrid, isStatic
|
|
75
|
+
memoProps: [columns, layout, displayGrid, isStatic]
|
|
78
76
|
});
|
|
79
77
|
};
|
|
80
78
|
|
package/src/Dashboard/utils.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { lt } from 'ramda';
|
|
2
2
|
import { Layout } from 'react-grid-layout';
|
|
3
3
|
|
|
4
|
-
export const maxColumns = 12;
|
|
5
4
|
const minColumns = 1;
|
|
6
5
|
const breakpoint = 768;
|
|
7
6
|
|
|
8
7
|
export const rowHeight = 64;
|
|
8
|
+
export const maxColumns = 12;
|
|
9
9
|
|
|
10
10
|
export const getIsSmallScreenSize = (): boolean =>
|
|
11
11
|
lt(window.innerWidth, breakpoint);
|
package/src/Form/Inputs/Grid.tsx
CHANGED
|
@@ -8,15 +8,18 @@ interface StylesProps {
|
|
|
8
8
|
alignItems?: string;
|
|
9
9
|
columns?: number;
|
|
10
10
|
gridTemplateColumns?: string;
|
|
11
|
+
isColumnDirection?: boolean;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
const useStyles = makeStyles<StylesProps>()(
|
|
14
|
-
(theme, { columns, gridTemplateColumns, alignItems }) => ({
|
|
15
|
+
(theme, { columns, gridTemplateColumns, alignItems, isColumnDirection }) => ({
|
|
15
16
|
gridFields: {
|
|
16
17
|
alignItems: alignItems || 'flex-start',
|
|
17
18
|
columnGap: theme.spacing(4),
|
|
18
|
-
display: 'grid',
|
|
19
|
-
gridTemplateColumns:
|
|
19
|
+
display: isColumnDirection ? 'flex' : 'grid',
|
|
20
|
+
gridTemplateColumns: isColumnDirection
|
|
21
|
+
? undefined
|
|
22
|
+
: gridTemplateColumns || `repeat(${columns}, 1fr)`,
|
|
20
23
|
rowGap: theme.spacing(2)
|
|
21
24
|
}
|
|
22
25
|
})
|
|
@@ -26,7 +29,8 @@ const Grid = ({ grid }: InputPropsWithoutGroup): JSX.Element => {
|
|
|
26
29
|
const { classes, cx } = useStyles({
|
|
27
30
|
alignItems: grid?.alignItems,
|
|
28
31
|
columns: grid?.columns.length,
|
|
29
|
-
gridTemplateColumns: grid?.gridTemplateColumns
|
|
32
|
+
gridTemplateColumns: grid?.gridTemplateColumns,
|
|
33
|
+
isColumnDirection: grid?.isColumnDirection
|
|
30
34
|
});
|
|
31
35
|
|
|
32
36
|
const className = grid?.className || '';
|
|
@@ -6,20 +6,20 @@ import { SelectEntry } from '../../InputField/Select';
|
|
|
6
6
|
import { ConditionsSearchParameter } from '../../api/buildListingEndpoint/models';
|
|
7
7
|
|
|
8
8
|
export enum InputType {
|
|
9
|
-
Switch,
|
|
10
|
-
Radio,
|
|
11
|
-
Text,
|
|
12
|
-
SingleAutocomplete,
|
|
13
|
-
MultiAutocomplete,
|
|
14
|
-
Password,
|
|
15
|
-
SingleConnectedAutocomplete,
|
|
16
|
-
MultiConnectedAutocomplete,
|
|
17
|
-
FieldsTable,
|
|
18
|
-
Grid,
|
|
19
|
-
Custom,
|
|
20
|
-
Checkbox,
|
|
21
|
-
CheckboxGroup,
|
|
22
|
-
List
|
|
9
|
+
Switch = 0,
|
|
10
|
+
Radio = 1,
|
|
11
|
+
Text = 2,
|
|
12
|
+
SingleAutocomplete = 3,
|
|
13
|
+
MultiAutocomplete = 4,
|
|
14
|
+
Password = 5,
|
|
15
|
+
SingleConnectedAutocomplete = 6,
|
|
16
|
+
MultiConnectedAutocomplete = 7,
|
|
17
|
+
FieldsTable = 8,
|
|
18
|
+
Grid = 9,
|
|
19
|
+
Custom = 10,
|
|
20
|
+
Checkbox = 11,
|
|
21
|
+
CheckboxGroup = 12,
|
|
22
|
+
List = 13
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
interface FieldsTableGetRequiredProps {
|
|
@@ -73,6 +73,7 @@ export interface InputProps {
|
|
|
73
73
|
className?: string;
|
|
74
74
|
columns: Array<Omit<InputProps, 'group'>>;
|
|
75
75
|
gridTemplateColumns?: string;
|
|
76
|
+
isColumnDirection?: boolean;
|
|
76
77
|
};
|
|
77
78
|
group: string;
|
|
78
79
|
hideInput?: (values: FormikValues) => boolean;
|
|
@@ -55,21 +55,43 @@ describe('Bar stack', () => {
|
|
|
55
55
|
it('adjusts size based on the provided width and height', () => {
|
|
56
56
|
initialize({ displayLegend: false, height: '300px', width: '300px' });
|
|
57
57
|
|
|
58
|
-
cy.
|
|
58
|
+
cy.get('.visx-bar-rounded')
|
|
59
|
+
.eq(0)
|
|
60
|
+
.should(
|
|
61
|
+
'have.attr',
|
|
62
|
+
'd',
|
|
63
|
+
'M8,95.18828451882847 h193 h8v8 v138.81171548117152 a8,8 0 0 1 -8,8 h-193 a8,8 0 0 1 -8,-8 v-138.81171548117152 v-8h8z'
|
|
64
|
+
);
|
|
59
65
|
|
|
60
66
|
cy.makeSnapshot();
|
|
61
67
|
});
|
|
62
68
|
|
|
63
69
|
it('renders as a horizontal bar when variant is set to "horizontal"', () => {
|
|
64
70
|
initialize({ variant: 'horizontal' });
|
|
65
|
-
|
|
71
|
+
|
|
72
|
+
cy.get('.visx-bar-rounded')
|
|
73
|
+
.eq(0)
|
|
74
|
+
.should(
|
|
75
|
+
'have.attr',
|
|
76
|
+
'd',
|
|
77
|
+
'M8,0 h231.69874476987445 h8v8 v295 v8h-8 h-231.69874476987445 a8,8 0 0 1 -8,-8 v-295 a8,8 0 0 1 8,-8z'
|
|
78
|
+
);
|
|
79
|
+
cy.get('[data-is-vertical="false"]').should('be.visible');
|
|
66
80
|
|
|
67
81
|
cy.makeSnapshot();
|
|
68
82
|
});
|
|
69
83
|
|
|
70
84
|
it('renders as a vertical bar when variant is set to "vertical"', () => {
|
|
71
85
|
initialize({ variant: 'vertical' });
|
|
72
|
-
|
|
86
|
+
|
|
87
|
+
cy.get('.visx-bar-rounded')
|
|
88
|
+
.eq(0)
|
|
89
|
+
.should(
|
|
90
|
+
'have.attr',
|
|
91
|
+
'd',
|
|
92
|
+
'M8,133.26359832635984 h293 h8v8 v200.73640167364016 a8,8 0 0 1 -8,8 h-293 a8,8 0 0 1 -8,-8 v-200.73640167364016 v-8h8z'
|
|
93
|
+
);
|
|
94
|
+
cy.get('[data-is-vertical="true"]').should('be.visible');
|
|
73
95
|
|
|
74
96
|
cy.makeSnapshot();
|
|
75
97
|
});
|
|
@@ -77,6 +99,14 @@ describe('Bar stack', () => {
|
|
|
77
99
|
it('displays tooltip with correct information on hover', () => {
|
|
78
100
|
initialize({ TooltipContent });
|
|
79
101
|
|
|
102
|
+
cy.get('.visx-bar-rounded')
|
|
103
|
+
.eq(0)
|
|
104
|
+
.should(
|
|
105
|
+
'have.attr',
|
|
106
|
+
'd',
|
|
107
|
+
'M8,133.26359832635984 h293 h8v8 v200.73640167364016 a8,8 0 0 1 -8,8 h-293 a8,8 0 0 1 -8,-8 v-200.73640167364016 v-8h8z'
|
|
108
|
+
);
|
|
109
|
+
|
|
80
110
|
defaultData.forEach(({ label, value }) => {
|
|
81
111
|
cy.findByTestId(label).trigger('mouseover', { force: true });
|
|
82
112
|
|
|
@@ -90,6 +120,14 @@ describe('Bar stack', () => {
|
|
|
90
120
|
|
|
91
121
|
it('conditionally displays values on rects based on displayValues prop', () => {
|
|
92
122
|
initialize({ displayValues: true });
|
|
123
|
+
|
|
124
|
+
cy.get('.visx-bar-rounded')
|
|
125
|
+
.eq(0)
|
|
126
|
+
.should(
|
|
127
|
+
'have.attr',
|
|
128
|
+
'd',
|
|
129
|
+
'M8,133.26359832635984 h293 h8v8 v200.73640167364016 a8,8 0 0 1 -8,8 h-293 a8,8 0 0 1 -8,-8 v-200.73640167364016 v-8h8z'
|
|
130
|
+
);
|
|
93
131
|
defaultData.forEach(({ value }, index) => {
|
|
94
132
|
cy.findAllByTestId('value')
|
|
95
133
|
.eq(index)
|
|
@@ -106,6 +144,14 @@ describe('Bar stack', () => {
|
|
|
106
144
|
|
|
107
145
|
it('displays values on rects in percentage unit when displayValues is set to true and unit to percentage', () => {
|
|
108
146
|
initialize({ displayValues: true, unit: 'percentage' });
|
|
147
|
+
|
|
148
|
+
cy.get('.visx-bar-rounded')
|
|
149
|
+
.eq(0)
|
|
150
|
+
.should(
|
|
151
|
+
'have.attr',
|
|
152
|
+
'd',
|
|
153
|
+
'M8,133.26359832635984 h293 h8v8 v200.73640167364016 a8,8 0 0 1 -8,8 h-293 a8,8 0 0 1 -8,-8 v-200.73640167364016 v-8h8z'
|
|
154
|
+
);
|
|
109
155
|
defaultData.forEach(({ value }, index) => {
|
|
110
156
|
cy.findAllByTestId('value')
|
|
111
157
|
.eq(index)
|
|
@@ -118,21 +164,53 @@ describe('Bar stack', () => {
|
|
|
118
164
|
});
|
|
119
165
|
|
|
120
166
|
it('displays Legend component based on displayLegend prop', () => {
|
|
121
|
-
initialize({ displayLegend: true });
|
|
122
|
-
cy.findByTestId('Legend').should('be.visible');
|
|
123
|
-
|
|
124
167
|
initialize({ displayLegend: false });
|
|
168
|
+
|
|
169
|
+
cy.get('.visx-bar-rounded')
|
|
170
|
+
.eq(0)
|
|
171
|
+
.should(
|
|
172
|
+
'have.attr',
|
|
173
|
+
'd',
|
|
174
|
+
'M8,133.26359832635984 h293 h8v8 v200.73640167364016 a8,8 0 0 1 -8,8 h-293 a8,8 0 0 1 -8,-8 v-200.73640167364016 v-8h8z'
|
|
175
|
+
);
|
|
176
|
+
cy.findByTestId('Ok').should('be.visible');
|
|
125
177
|
cy.findByTestId('Legend').should('not.exist');
|
|
126
178
|
|
|
127
179
|
cy.makeSnapshot();
|
|
128
180
|
});
|
|
129
181
|
|
|
130
|
-
it('displays the title when the title is
|
|
182
|
+
it('displays the title when the title is given', () => {
|
|
131
183
|
initialize({ title: 'host' });
|
|
184
|
+
|
|
185
|
+
cy.get('.visx-bar-rounded')
|
|
186
|
+
.eq(0)
|
|
187
|
+
.should(
|
|
188
|
+
'have.attr',
|
|
189
|
+
'd',
|
|
190
|
+
'M8,133.26359832635984 h293 h8v8 v200.73640167364016 a8,8 0 0 1 -8,8 h-293 a8,8 0 0 1 -8,-8 v-200.73640167364016 v-8h8z'
|
|
191
|
+
);
|
|
192
|
+
cy.findByTestId('Ok').should('be.visible');
|
|
132
193
|
cy.findByTestId('Title').should('be.visible');
|
|
133
194
|
|
|
134
|
-
|
|
135
|
-
|
|
195
|
+
cy.makeSnapshot();
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it('displays the bars within a small display', () => {
|
|
199
|
+
initialize({
|
|
200
|
+
displayLegend: true,
|
|
201
|
+
height: '89px',
|
|
202
|
+
title: 'host',
|
|
203
|
+
width: '120px'
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
cy.get('.visx-bar-rounded')
|
|
207
|
+
.eq(0)
|
|
208
|
+
.should(
|
|
209
|
+
'have.attr',
|
|
210
|
+
'd',
|
|
211
|
+
'M8,20.941422594142264 h94 h8v8 v18.058577405857733 a8,8 0 0 1 -8,8 h-94 a8,8 0 0 1 -8,-8 v-18.058577405857733 v-8h8z'
|
|
212
|
+
);
|
|
213
|
+
cy.findByTestId('Ok').should('be.visible');
|
|
136
214
|
|
|
137
215
|
cy.makeSnapshot();
|
|
138
216
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Meta, StoryObj } from '@storybook/react';
|
|
2
2
|
|
|
3
|
+
import ResponsiveBarStack from './BarStack';
|
|
3
4
|
import { BarType } from './models';
|
|
4
5
|
|
|
5
6
|
import { BarStack } from '.';
|
|
@@ -42,8 +43,8 @@ const TooltipContent = ({ label, color, value }: BarType): JSX.Element => {
|
|
|
42
43
|
|
|
43
44
|
const Template = (args): JSX.Element => {
|
|
44
45
|
return (
|
|
45
|
-
<div style={{ height: '
|
|
46
|
-
<
|
|
46
|
+
<div style={{ height: '400px', width: '400px' }}>
|
|
47
|
+
<ResponsiveBarStack {...args} />
|
|
47
48
|
</div>
|
|
48
49
|
);
|
|
49
50
|
};
|
|
@@ -104,6 +105,7 @@ export const Horizontal: Story = {
|
|
|
104
105
|
TooltipContent,
|
|
105
106
|
data,
|
|
106
107
|
displayValues: true,
|
|
108
|
+
legendDirection: 'row',
|
|
107
109
|
title: 'hosts',
|
|
108
110
|
variant: 'horizontal'
|
|
109
111
|
},
|
|
@@ -1,37 +1,66 @@
|
|
|
1
1
|
import { makeStyles } from 'tss-react/mui';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
import { legendMaxHeight, legendMaxWidth } from './constants';
|
|
4
|
+
|
|
5
|
+
export const useStyles = makeStyles()({
|
|
6
|
+
clippedTitle: {
|
|
7
|
+
overflow: 'hidden',
|
|
8
|
+
textOverflow: 'clip'
|
|
9
9
|
},
|
|
10
10
|
container: {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
display: '
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
11
|
+
'&[data-has-title="false"]': {
|
|
12
|
+
gridTemplateRows: 'auto'
|
|
13
|
+
},
|
|
14
|
+
'&[data-title-variant="md"]': {
|
|
15
|
+
gridTemplateRows: '36px auto',
|
|
16
|
+
overflow: 'hidden',
|
|
17
|
+
textOverflow: 'clip'
|
|
18
|
+
},
|
|
19
|
+
'&[data-title-variant="sm"]': {
|
|
20
|
+
gridTemplateRows: '20px auto'
|
|
21
|
+
},
|
|
22
|
+
'&[data-title-variant="xs"]': {
|
|
23
|
+
gridTemplateRows: '40px auto'
|
|
24
|
+
},
|
|
25
|
+
display: 'grid',
|
|
26
|
+
height: '100%'
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export const useGraphAndLegendStyles = makeStyles()((theme) => ({
|
|
31
|
+
graphAndLegend: {
|
|
32
|
+
'&[data-display-legend="false"][data-is-vertical="false"]': {
|
|
33
|
+
gridTemplateRows: '1fr'
|
|
34
|
+
},
|
|
35
|
+
'&[data-display-legend="true"][data-is-vertical="false"]': {
|
|
36
|
+
gap: theme.spacing(0.5),
|
|
37
|
+
gridTemplateRows: `1fr ${legendMaxHeight}px`
|
|
38
|
+
},
|
|
39
|
+
'&[data-is-vertical="true"][data-display-legend="false"]': {
|
|
40
|
+
gridTemplateColumns: '1fr'
|
|
41
|
+
},
|
|
42
|
+
'&[data-is-vertical="true"][data-display-legend="true"]': {
|
|
43
|
+
gap: theme.spacing(0.5),
|
|
44
|
+
gridTemplateColumns: `1fr ${legendMaxWidth}px`
|
|
45
|
+
},
|
|
46
|
+
display: 'grid',
|
|
47
|
+
height: '100%'
|
|
29
48
|
},
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
49
|
+
legend: {
|
|
50
|
+
'&[data-is-vertical="false"]': {
|
|
51
|
+
overflowY: 'auto'
|
|
52
|
+
},
|
|
53
|
+
'&[data-is-vertical="true"]': {
|
|
54
|
+
alignSelf: 'center'
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}));
|
|
58
|
+
|
|
59
|
+
export const useGraphStyles = makeStyles()((theme) => ({
|
|
60
|
+
tooltip: {
|
|
61
|
+
backgroundColor: theme.palette.background.paper,
|
|
62
|
+
boxShadow: theme.shadows[3],
|
|
63
|
+
color: theme.palette.text.primary,
|
|
64
|
+
padding: 0
|
|
36
65
|
}
|
|
37
66
|
}));
|