@centreon/ui 24.4.48 → 24.4.49

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 (137) hide show
  1. package/package.json +36 -29
  2. package/public/mockServiceWorker.js +1 -1
  3. package/src/Button/Icon/index.tsx +1 -1
  4. package/src/Button/Save/StartIcon.tsx +3 -3
  5. package/src/Button/Save/index.tsx +9 -5
  6. package/src/Checkbox/Checkbox.tsx +2 -2
  7. package/src/Checkbox/CheckboxGroup/index.tsx +2 -2
  8. package/src/Dashboard/Item.tsx +1 -1
  9. package/src/Dashboard/Layout.tsx +2 -2
  10. package/src/Dialog/Confirm/index.tsx +10 -2
  11. package/src/Dialog/index.tsx +9 -2
  12. package/src/FallbackPage/FallbackPage.tsx +3 -3
  13. package/src/FileDropZone/index.tsx +3 -1
  14. package/src/Form/Form.cypress.spec.tsx +133 -0
  15. package/src/Form/Inputs/List/Content.tsx +62 -0
  16. package/src/Form/Inputs/List/List.styles.ts +29 -0
  17. package/src/Form/Inputs/List/List.tsx +58 -0
  18. package/src/Form/Inputs/List/useList.ts +81 -0
  19. package/src/Form/Inputs/index.tsx +3 -1
  20. package/src/Form/Inputs/models.ts +9 -1
  21. package/src/Graph/BarStack/BarStack.cypress.spec.tsx +154 -0
  22. package/src/Graph/BarStack/BarStack.stories.tsx +123 -0
  23. package/src/Graph/BarStack/BarStack.styles.ts +36 -0
  24. package/src/Graph/BarStack/BarStack.tsx +14 -0
  25. package/src/Graph/BarStack/ResponsiveBarStack.tsx +208 -0
  26. package/src/Graph/BarStack/index.ts +1 -0
  27. package/src/Graph/BarStack/models.ts +19 -0
  28. package/src/Graph/BarStack/useResponsiveBarStack.ts +139 -0
  29. package/src/Graph/Gauge/Gauge.cypress.spec.tsx +102 -0
  30. package/src/Graph/Gauge/Gauge.tsx +1 -1
  31. package/src/Graph/HeatMap/HeatMap.cypress.spec.tsx +145 -0
  32. package/src/Graph/HeatMap/HeatMap.stories.tsx +0 -25
  33. package/src/Graph/HeatMap/ResponsiveHeatMap.tsx +8 -2
  34. package/src/Graph/Legend/Legend.tsx +21 -0
  35. package/src/Graph/Legend/index.ts +1 -0
  36. package/src/Graph/Legend/models.ts +11 -0
  37. package/src/Graph/LineChart/BasicComponents/Lines/Threshold/Circle.tsx +2 -2
  38. package/src/Graph/LineChart/BasicComponents/Thresholds.tsx +2 -2
  39. package/src/Graph/LineChart/BasicComponents/useFilterLines.ts +1 -1
  40. package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/GuidingLines.tsx +2 -2
  41. package/src/Graph/LineChart/InteractiveComponents/Annotations/EventAnnotations.tsx +1 -1
  42. package/src/Graph/LineChart/Legend/Legend.styles.ts +1 -1
  43. package/src/Graph/LineChart/Legend/LegendHeader.tsx +1 -1
  44. package/src/Graph/LineChart/Legend/useInteractiveValues.ts +2 -2
  45. package/src/Graph/LineChart/Legend/useLegend.ts +3 -3
  46. package/src/Graph/LineChart/helpers/doc.ts +16 -13
  47. package/src/Graph/LineChart/helpers/index.ts +1 -1
  48. package/src/Graph/LineChart/index.stories.tsx +4 -2
  49. package/src/Graph/LineChart/index.tsx +1 -1
  50. package/src/Graph/PieChart/PieChart.cypress.spec.tsx +169 -0
  51. package/src/Graph/PieChart/PieChart.stories.tsx +194 -0
  52. package/src/Graph/PieChart/PieChart.styles.ts +39 -0
  53. package/src/Graph/PieChart/PieChart.tsx +14 -0
  54. package/src/Graph/PieChart/ResponsivePie.tsx +251 -0
  55. package/src/Graph/PieChart/index.ts +1 -0
  56. package/src/Graph/PieChart/models.ts +19 -0
  57. package/src/Graph/PieChart/useResponsivePie.ts +86 -0
  58. package/src/Graph/SingleBar/SingleBar.cypress.spec.tsx +121 -0
  59. package/src/Graph/SingleBar/Thresholds.tsx +2 -2
  60. package/src/Graph/Text/Text.cypress.spec.tsx +101 -0
  61. package/src/Graph/Text/Text.stories.tsx +60 -4
  62. package/src/Graph/Text/Text.tsx +1 -1
  63. package/src/Graph/common/testUtils.ts +71 -0
  64. package/src/Graph/common/timeSeries/index.ts +22 -14
  65. package/src/Graph/common/utils.ts +19 -0
  66. package/src/Graph/index.ts +3 -0
  67. package/src/Graph/translatedLabels.ts +1 -0
  68. package/src/InputField/Select/Autocomplete/Connected/index.tsx +10 -7
  69. package/src/InputField/Select/Autocomplete/Draggable/SortableList.tsx +1 -1
  70. package/src/InputField/Select/Autocomplete/Draggable/SortableListContent.tsx +1 -1
  71. package/src/InputField/Select/Autocomplete/Draggable/index.tsx +1 -1
  72. package/src/InputField/Select/Autocomplete/index.tsx +121 -115
  73. package/src/InputField/Select/IconPopover/index.tsx +2 -2
  74. package/src/InputField/Select/index.tsx +1 -1
  75. package/src/InputField/Text/index.tsx +2 -2
  76. package/src/Listing/ActionBar/index.tsx +9 -8
  77. package/src/Listing/Cell/DataCell.styles.ts +3 -0
  78. package/src/Listing/Cell/DataCell.tsx +23 -5
  79. package/src/Listing/Header/ListingHeader.tsx +1 -1
  80. package/src/Listing/Listing.cypress.spec.tsx +80 -4
  81. package/src/Listing/Listing.styles.ts +4 -7
  82. package/src/Listing/index.stories.tsx +37 -3
  83. package/src/Listing/index.test.tsx +1 -1
  84. package/src/Listing/index.tsx +4 -3
  85. package/src/Listing/models.ts +1 -0
  86. package/src/Module/Module.cypress.spec.tsx +129 -0
  87. package/src/Module/index.tsx +2 -4
  88. package/src/RichTextEditor/RichTextEditor.tsx +12 -1
  89. package/src/SortableItems/index.tsx +2 -7
  90. package/src/ThemeProvider/index.tsx +24 -0
  91. package/src/TimePeriods/CustomTimePeriod/CompactCustomTimePeriod.styles.ts +6 -7
  92. package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/PickersStartEndDate.tsx +8 -3
  93. package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/models.ts +0 -2
  94. package/src/TimePeriods/DateTimePickerInput.tsx +56 -19
  95. package/src/TimePeriods/ResolutionTimePeriod.cypress.spec.tsx +12 -9
  96. package/src/TimePeriods/TimePeriods.cypress.spec.tsx +9 -33
  97. package/src/TimePeriods/helpers/index.ts +1 -1
  98. package/src/TimePeriods/index.stories.tsx +12 -4
  99. package/src/TimePeriods/index.tsx +2 -2
  100. package/src/api/QueryProvider.tsx +1 -1
  101. package/src/api/TestQueryProvider.tsx +1 -1
  102. package/src/api/useFetchQuery/index.ts +27 -23
  103. package/src/api/useMutationQuery/index.test.ts +4 -4
  104. package/src/api/useMutationQuery/index.ts +60 -25
  105. package/src/components/Button/Icon/IconButton.tsx +6 -2
  106. package/src/components/DataTable/DataListing.tsx +6 -0
  107. package/src/components/DataTable/DataTable.cypress.spec.tsx +193 -0
  108. package/src/components/DataTable/DataTable.stories.tsx +40 -0
  109. package/src/components/DataTable/DataTable.styles.ts +3 -0
  110. package/src/components/DataTable/DataTable.tsx +3 -3
  111. package/src/components/DataTable/Item/DataTableItem.styles.ts +7 -2
  112. package/src/components/DataTable/Item/DataTableItem.tsx +4 -4
  113. package/src/components/DataTable/index.ts +3 -1
  114. package/src/components/Form/AccessRights/ShareInput/ContactSwitch.tsx +3 -3
  115. package/src/components/Form/AccessRights/ShareInput/ShareInput.tsx +1 -0
  116. package/src/components/Form/Dashboard/DashboardForm.tsx +15 -12
  117. package/src/components/Layout/PageLayout/PageLayout.tsx +1 -1
  118. package/src/components/Layout/PageLayout/PageLayoutActions.tsx +1 -0
  119. package/src/components/Layout/PageLayout/PageLayoutBody.tsx +1 -0
  120. package/src/components/Layout/PageLayout/PageLayoutHeader.tsx +5 -1
  121. package/src/components/Layout/PageLayout/PageQuickAccess.tsx +76 -0
  122. package/src/components/Layout/PageLayout/index.ts +3 -1
  123. package/src/components/Layout/PageLayout.cypress.spec.tsx +66 -0
  124. package/src/components/Modal/Modal.styles.ts +1 -1
  125. package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.stories.tsx +3 -3
  126. package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.tsx +1 -1
  127. package/src/components/Tooltip/ConfirmationTooltip/models.ts +1 -1
  128. package/src/index.ts +2 -2
  129. package/src/queryParameters/url/index.ts +5 -1
  130. package/src/utils/index.ts +1 -1
  131. package/src/utils/useFullscreen/useFullscreenListener.ts +10 -7
  132. package/src/utils/{useLicenseExpirationWarning.cypress.spec.tsx → useLicenseExpirationWarning.test.tsx} +48 -37
  133. package/src/utils/useLicenseExpirationWarning.ts +18 -18
  134. package/src/utils/usePluralizedTranslation.ts +21 -0
  135. package/src/screens/dashboard/DashboardsDetail.stories.tsx +0 -108
  136. package/src/screens/dashboard/DashboardsOverview.stories.tsx +0 -281
  137. package/src/utils/useDateTimePickerAdapter.ts +0 -309
@@ -0,0 +1,58 @@
1
+ import { ComponentType } from 'react';
2
+
3
+ import { closestCenter } from '@dnd-kit/core';
4
+ import { verticalListSortingStrategy } from '@dnd-kit/sortable';
5
+ import { useTranslation } from 'react-i18next';
6
+
7
+ import { InputPropsWithoutGroup } from '../models';
8
+ import { SortableItems, Subtitle } from '../../..';
9
+
10
+ import { useList } from './useList';
11
+ import { useListStyles } from './List.styles';
12
+ import Content, { ContentProps } from './Content';
13
+
14
+ const List = ({
15
+ list,
16
+ fieldName
17
+ }: InputPropsWithoutGroup): JSX.Element | null => {
18
+ const { t } = useTranslation();
19
+ const { classes } = useListStyles();
20
+
21
+ const { addItem, sortList, sortedList, deleteItem } = useList({ fieldName });
22
+
23
+ const { AddItem, addItemLabel, sortLabel, SortContent, itemProps } = list as {
24
+ AddItem: ComponentType<{ addItem }>;
25
+ SortContent: ComponentType;
26
+ addItemLabel?: string;
27
+ itemProps: Array<string>;
28
+ sortLabel?: string;
29
+ };
30
+
31
+ return (
32
+ <div className={classes.list}>
33
+ {addItemLabel && <Subtitle>{t(addItemLabel)}</Subtitle>}
34
+ <AddItem addItem={addItem} />
35
+ {sortLabel && <Subtitle>{t(sortLabel)}</Subtitle>}
36
+ <div className={classes.items}>
37
+ <SortableItems
38
+ updateSortableItemsOnItemsChange
39
+ // eslint-disable-next-line react/no-unstable-nested-components
40
+ Content={(props: Omit<ContentProps, 'children' | 'deleteItem'>) => (
41
+ <Content {...props} deleteItem={deleteItem}>
42
+ <SortContent {...props} />
43
+ </Content>
44
+ )}
45
+ collisionDetection={closestCenter}
46
+ itemProps={itemProps}
47
+ items={sortedList}
48
+ sortingStrategy={verticalListSortingStrategy}
49
+ onDragEnd={({ items }): void => {
50
+ sortList(items);
51
+ }}
52
+ />
53
+ </div>
54
+ </div>
55
+ );
56
+ };
57
+
58
+ export default List;
@@ -0,0 +1,81 @@
1
+ import { useMemo, useRef } from 'react';
2
+
3
+ import { FormikValues, useFormikContext } from 'formik';
4
+ import {
5
+ append,
6
+ equals,
7
+ inc,
8
+ isEmpty,
9
+ pluck,
10
+ prop,
11
+ reject,
12
+ sortBy
13
+ } from 'ramda';
14
+
15
+ import { SelectEntry } from '../../..';
16
+
17
+ interface UseListState {
18
+ addItem: (newItem: SelectEntry) => void;
19
+ deleteItem: (id: string) => () => void;
20
+ sortList: (items: Array<string>) => void;
21
+ sortedList: Array<unknown>;
22
+ }
23
+
24
+ export const useList = ({ fieldName }): UseListState => {
25
+ const { values, setFieldValue } = useFormikContext<FormikValues>();
26
+ const maxOrder = useRef(0);
27
+
28
+ const list = values[fieldName];
29
+
30
+ const sortedList = useMemo(
31
+ () =>
32
+ sortBy(prop('order'), list).map(({ id, ...props }) => ({
33
+ id: `${id}`,
34
+ ...props
35
+ })),
36
+ [list]
37
+ );
38
+
39
+ const addItem = (newItem: SelectEntry): void => {
40
+ setFieldValue(
41
+ fieldName,
42
+ append(
43
+ {
44
+ ...newItem,
45
+ id: (newItem as SelectEntry).id as number,
46
+ order: inc(maxOrder.current)
47
+ },
48
+ list
49
+ )
50
+ );
51
+ };
52
+
53
+ const deleteItem = (id: string) => (): void => {
54
+ const newItems = reject((item) => equals(Number(id), item.id))(list);
55
+
56
+ setFieldValue(fieldName, newItems);
57
+ };
58
+
59
+ const sortList = (items: Array<string>): void => {
60
+ const newOrderedList = items.map((itemId, idx) => {
61
+ const item = sortedList.find(({ id }) => equals(id, itemId));
62
+
63
+ return {
64
+ ...item,
65
+ id: Number(item?.id),
66
+ order: inc(idx)
67
+ };
68
+ });
69
+
70
+ setFieldValue(fieldName, newOrderedList);
71
+ };
72
+
73
+ maxOrder.current = isEmpty(list) ? 0 : Math.max(...pluck('order', list));
74
+
75
+ return {
76
+ addItem,
77
+ deleteItem,
78
+ sortList,
79
+ sortedList
80
+ };
81
+ };
@@ -21,6 +21,7 @@ import CheckboxGroup from './CheckboxGroup';
21
21
  import Checkbox from './Checkbox';
22
22
  import Custom from './Custom';
23
23
  import LoadingSkeleton from './LoadingSkeleton';
24
+ import List from './List/List';
24
25
 
25
26
  export const getInput = R.cond<
26
27
  Array<InputType>,
@@ -66,6 +67,7 @@ export const getInput = R.cond<
66
67
  R.equals(InputType.CheckboxGroup) as (b: InputType) => boolean,
67
68
  R.always(CheckboxGroup)
68
69
  ],
70
+ [R.equals(InputType.List) as (b: InputType) => boolean, R.always(List)],
69
71
  [R.T, R.always(TextInput)]
70
72
  ]);
71
73
 
@@ -185,7 +187,7 @@ const Inputs = ({
185
187
  const hasGroupTitle = R.not(R.isNil(groupName));
186
188
 
187
189
  const groupProps = hasGroupTitle
188
- ? R.find(R.propEq('name', groupName), groups)
190
+ ? R.find(R.propEq(groupName, 'name'), groups)
189
191
  : ({} as Group);
190
192
 
191
193
  const isFirstElement = areGroupsOpen || R.equals(index, 0);
@@ -18,7 +18,8 @@ export enum InputType {
18
18
  Grid,
19
19
  Custom,
20
20
  Checkbox,
21
- CheckboxGroup
21
+ CheckboxGroup,
22
+ List
22
23
  }
23
24
 
24
25
  interface FieldsTableGetRequiredProps {
@@ -76,6 +77,13 @@ export interface InputProps {
76
77
  hideInput?: (values: FormikValues) => boolean;
77
78
  inputClassName?: string;
78
79
  label: string;
80
+ list?: {
81
+ AddItem: React.ComponentType<{ addItem }>;
82
+ SortContent: React.ComponentType<object>;
83
+ addItemLabel?: string;
84
+ itemProps: Array<string>;
85
+ sortLabel?: string;
86
+ };
79
87
  radio?: {
80
88
  options?: Array<{
81
89
  label: string | JSX.Element;
@@ -0,0 +1,154 @@
1
+ import numeral from 'numeral';
2
+
3
+ import BarStack from './BarStack';
4
+ import { BarType, BarStackProps } from './models';
5
+
6
+ const defaultData = [
7
+ { color: '#88B922', label: 'Ok', value: 148 },
8
+ { color: '#999999', label: 'Unknown', value: 13 },
9
+ { color: '#F7931A', label: 'Warning', value: 16 },
10
+ { color: '#FF6666', label: 'Down', value: 62 }
11
+ ];
12
+
13
+ const dataWithNullValues = [
14
+ { color: '#88B922', label: 'Ok', value: 0 },
15
+ { color: '#999999', label: 'Unknown', value: 0 },
16
+ { color: '#F7931A', label: 'Warning', value: 0 },
17
+ { color: '#FF6666', label: 'Down', value: 0 }
18
+ ];
19
+
20
+ const total = Math.floor(
21
+ defaultData.reduce((acc, { value }) => acc + value, 0)
22
+ );
23
+
24
+ const TooltipContent = ({ label, color, value }: BarType): JSX.Element => {
25
+ return (
26
+ <div data-testid={`tooltip-${label}`} style={{ color }}>
27
+ {label} : {value}
28
+ </div>
29
+ );
30
+ };
31
+
32
+ const initialize = ({
33
+ width = '400px',
34
+ height = '400px',
35
+ data = defaultData,
36
+ ...args
37
+ }: Omit<BarStackProps, 'data'> & {
38
+ data?;
39
+ height?: string;
40
+ width?: string;
41
+ }): void => {
42
+ cy.mount({
43
+ Component: (
44
+ <div style={{ height, width }}>
45
+ <BarStack {...args} data={data} />
46
+ </div>
47
+ )
48
+ });
49
+ };
50
+
51
+ describe('Bar stack', () => {
52
+ it('renders Bar stack correctly with provided data', () => {
53
+ initialize({});
54
+
55
+ defaultData.forEach(({ label }) => {
56
+ cy.findByTestId(label).should('be.visible');
57
+ });
58
+
59
+ cy.makeSnapshot();
60
+ });
61
+
62
+ it('adjusts size based on the provided width and height', () => {
63
+ initialize({ displayLegend: false, height: '300px', width: '300px' });
64
+
65
+ cy.findByTestId('barStack').should('have.css', 'height', '300px');
66
+
67
+ cy.makeSnapshot();
68
+ });
69
+
70
+ it('renders as a horizontal bar when variant is set to "horizontal"', () => {
71
+ initialize({ variant: 'horizontal' });
72
+ cy.get('[data-variant="horizontal"]').should('exist');
73
+
74
+ cy.makeSnapshot();
75
+ });
76
+
77
+ it('renders as a vertical bar when variant is set to "vertical"', () => {
78
+ initialize({ variant: 'vertical' });
79
+ cy.get('[data-variant="vertical"]').should('exist');
80
+
81
+ cy.makeSnapshot();
82
+ });
83
+
84
+ it('displays tooltip with correct information on hover', () => {
85
+ initialize({ TooltipContent });
86
+
87
+ defaultData.forEach(({ label, value }) => {
88
+ cy.findByTestId(label).trigger('mouseover', { force: true });
89
+
90
+ cy.findByTestId(`tooltip-${label}`)
91
+ .should('contain', label)
92
+ .and('contain', numeral(value).format('0a').toUpperCase());
93
+ });
94
+
95
+ cy.makeSnapshot();
96
+ });
97
+
98
+ it('conditionally displays values on rects based on displayValues prop', () => {
99
+ initialize({ displayValues: true });
100
+ defaultData.forEach(({ value }, index) => {
101
+ cy.findAllByTestId('value')
102
+ .eq(index)
103
+ .children()
104
+ .eq(0)
105
+ .should('have.text', value);
106
+ });
107
+
108
+ initialize({ displayValues: false });
109
+ cy.findAllByTestId('value').should('not.exist');
110
+
111
+ cy.makeSnapshot();
112
+ });
113
+
114
+ it('displays values on rects in percentage unit when displayValues is set to true and unit to percentage', () => {
115
+ initialize({ displayValues: true, unit: 'percentage' });
116
+ defaultData.forEach(({ value }, index) => {
117
+ cy.findAllByTestId('value')
118
+ .eq(index)
119
+ .children()
120
+ .eq(0)
121
+ .should('have.text', `${((value * 100) / total).toFixed(1)}%`);
122
+ });
123
+
124
+ cy.makeSnapshot();
125
+ });
126
+
127
+ it('displays Legend component based on displayLegend prop', () => {
128
+ initialize({ displayLegend: true });
129
+ cy.findByTestId('Legend').should('be.visible');
130
+
131
+ initialize({ displayLegend: false });
132
+ cy.findByTestId('Legend').should('not.exist');
133
+
134
+ cy.makeSnapshot();
135
+ });
136
+
137
+ it('displays the title when the title is giving', () => {
138
+ initialize({ title: 'host' });
139
+ cy.findByTestId('Title').should('be.visible');
140
+
141
+ initialize({});
142
+ cy.findByTestId('Title').should('not.exist');
143
+
144
+ cy.makeSnapshot();
145
+ });
146
+
147
+ it('displays a message "No Data Available" when all values are null', () => {
148
+ initialize({ data: dataWithNullValues, title: 'host' });
149
+
150
+ cy.contains('No Data Available');
151
+
152
+ cy.makeSnapshot();
153
+ });
154
+ });
@@ -0,0 +1,123 @@
1
+ import { Meta, StoryObj } from '@storybook/react';
2
+
3
+ import { BarType } from './models';
4
+
5
+ import { BarStack } from '.';
6
+
7
+ const data = [
8
+ { color: '#88B922', label: 'Ok', value: 148 },
9
+ { color: '#999999', label: 'Unknown', value: 63 },
10
+ { color: '#F7931A', label: 'Warning', value: 16 },
11
+ { color: '#FF6666', label: 'Down', value: 13 }
12
+ ];
13
+
14
+ const dataWithBigNumbers = [
15
+ { color: '#88B922', label: 'Ok', value: 260000 },
16
+ { color: '#999999', label: 'Unknown', value: 1010900 },
17
+ { color: '#F7931A', label: 'Warning', value: 63114 },
18
+ { color: '#FF6666', label: 'Down', value: 122222 }
19
+ ];
20
+
21
+ const dataWithSmallNumber = [
22
+ { color: '#88B922', label: 'Ok', value: 148 },
23
+ { color: '#999999', label: 'Unknown', value: 42 },
24
+ { color: '#F7931A', label: 'Warning', value: 7 },
25
+ { color: '#FF6666', label: 'Down', value: 5 }
26
+ ];
27
+
28
+ const meta: Meta<typeof BarStack> = {
29
+ component: BarStack
30
+ };
31
+
32
+ export default meta;
33
+ type Story = StoryObj<typeof BarStack>;
34
+
35
+ const TooltipContent = ({ label, color, value }: BarType): JSX.Element => {
36
+ return (
37
+ <div style={{ color }}>
38
+ {label} : {value}
39
+ </div>
40
+ );
41
+ };
42
+
43
+ const Template = (args): JSX.Element => {
44
+ return (
45
+ <div style={{ height: '300px', width: '500px' }}>
46
+ <BarStack {...args} />
47
+ </div>
48
+ );
49
+ };
50
+
51
+ export const Vertical: Story = {
52
+ args: { data, title: 'hosts' },
53
+ render: Template
54
+ };
55
+
56
+ export const WithoutTitle: Story = {
57
+ args: { data },
58
+ render: Template
59
+ };
60
+
61
+ export const WithPencentage: Story = {
62
+ args: { data, title: 'hosts', unit: 'percentage' },
63
+ render: Template
64
+ };
65
+
66
+ export const WithoutLegend: Story = {
67
+ args: { data, displayLegend: false, title: 'hosts' },
68
+
69
+ render: Template
70
+ };
71
+
72
+ export const withDisplayedValues: Story = {
73
+ args: { data, displayValues: true, title: 'hosts' },
74
+ render: Template
75
+ };
76
+
77
+ export const WithTooltip: Story = {
78
+ args: { TooltipContent, data, title: 'hosts' },
79
+ render: Template
80
+ };
81
+
82
+ export const WithBigNumbers: Story = {
83
+ args: {
84
+ TooltipContent,
85
+ data: dataWithBigNumbers,
86
+ displayValues: true,
87
+ title: 'hosts'
88
+ },
89
+ render: Template
90
+ };
91
+
92
+ export const WithSmallNumbers: Story = {
93
+ args: {
94
+ TooltipContent,
95
+ data: dataWithSmallNumber,
96
+ displayValues: true,
97
+ title: 'hosts'
98
+ },
99
+ render: Template
100
+ };
101
+
102
+ export const Horizontal: Story = {
103
+ args: {
104
+ TooltipContent,
105
+ data,
106
+ displayValues: true,
107
+ title: 'hosts',
108
+ variant: 'horizontal'
109
+ },
110
+ render: Template
111
+ };
112
+
113
+ export const HorizontalWithoutLegend: Story = {
114
+ args: {
115
+ TooltipContent,
116
+ data,
117
+ displayLegend: false,
118
+ displayValues: true,
119
+ title: 'hosts',
120
+ variant: 'horizontal'
121
+ },
122
+ render: Template
123
+ };
@@ -0,0 +1,36 @@
1
+ import { makeStyles } from 'tss-react/mui';
2
+
3
+ export const useBarStackStyles = makeStyles()((theme) => ({
4
+ barStackTooltip: {
5
+ backgroundColor: theme.palette.background.paper,
6
+ color: theme.palette.text.primary,
7
+ padding: 0,
8
+ position: 'relative'
9
+ },
10
+ container: {
11
+ alignItems: 'center',
12
+ display: 'flex',
13
+ gap: theme.spacing(1.5),
14
+ justifyContent: 'center'
15
+ },
16
+ svgContainer: {
17
+ alignItems: 'center',
18
+ backgroundColor: theme.palette.background.panelGroups,
19
+ borderRadius: theme.shape.borderRadius,
20
+ display: 'flex',
21
+ justifyContent: 'center'
22
+ },
23
+ svgWrapper: {
24
+ alignItems: 'center',
25
+ display: 'flex',
26
+ flexDirection: 'column',
27
+ gap: theme.spacing(1),
28
+ justifyContent: 'center'
29
+ },
30
+ title: {
31
+ fontSize: theme.typography.h6.fontSize,
32
+ fontWeight: theme.typography.fontWeightMedium,
33
+ margin: 0,
34
+ padding: 0
35
+ }
36
+ }));
@@ -0,0 +1,14 @@
1
+ import { ParentSize } from '../..';
2
+
3
+ import ResponsiveBarStack from './ResponsiveBarStack';
4
+ import { BarStackProps } from './models';
5
+
6
+ const Bar = (props: BarStackProps): JSX.Element => (
7
+ <ParentSize>
8
+ {({ width, height }) => (
9
+ <ResponsiveBarStack {...props} height={height} width={width} />
10
+ )}
11
+ </ParentSize>
12
+ );
13
+
14
+ export default Bar;