@centreon/ui 24.4.57 → 24.4.59
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 +31 -38
- package/public/mockServiceWorker.js +1 -1
- package/src/Button/Icon/index.tsx +1 -1
- package/src/Button/Save/StartIcon.tsx +3 -3
- package/src/Button/Save/index.tsx +5 -9
- package/src/Checkbox/Checkbox.tsx +2 -2
- package/src/Checkbox/CheckboxGroup/index.tsx +2 -2
- package/src/Dashboard/Item.tsx +1 -1
- package/src/Dashboard/Layout.tsx +2 -2
- package/src/Dialog/Confirm/index.tsx +2 -10
- package/src/Dialog/index.tsx +2 -9
- package/src/FallbackPage/FallbackPage.tsx +3 -3
- package/src/FileDropZone/index.tsx +1 -3
- package/src/Form/Inputs/index.tsx +1 -3
- package/src/Form/Inputs/models.ts +1 -9
- package/src/Graph/Gauge/Gauge.tsx +1 -1
- package/src/Graph/HeatMap/HeatMap.stories.tsx +25 -0
- package/src/Graph/HeatMap/ResponsiveHeatMap.tsx +2 -8
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/Circle.tsx +2 -2
- package/src/Graph/LineChart/BasicComponents/Thresholds.tsx +2 -2
- package/src/Graph/LineChart/BasicComponents/useFilterLines.ts +1 -1
- package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/GuidingLines.tsx +2 -2
- package/src/Graph/LineChart/InteractiveComponents/Annotations/EventAnnotations.tsx +1 -1
- package/src/Graph/LineChart/Legend/Legend.styles.ts +1 -1
- package/src/Graph/LineChart/Legend/LegendHeader.tsx +1 -1
- package/src/Graph/LineChart/Legend/useInteractiveValues.ts +2 -2
- package/src/Graph/LineChart/Legend/useLegend.ts +3 -3
- package/src/Graph/LineChart/helpers/doc.ts +13 -16
- package/src/Graph/LineChart/helpers/index.ts +1 -1
- package/src/Graph/LineChart/index.stories.tsx +2 -4
- package/src/Graph/LineChart/index.tsx +1 -1
- package/src/Graph/SingleBar/Thresholds.tsx +2 -2
- package/src/Graph/Text/Text.stories.tsx +4 -60
- package/src/Graph/Text/Text.tsx +1 -1
- package/src/Graph/common/timeSeries/index.ts +14 -22
- package/src/Graph/common/utils.ts +0 -19
- package/src/Graph/index.ts +0 -3
- package/src/InputField/Select/Autocomplete/Connected/index.tsx +7 -10
- package/src/InputField/Select/Autocomplete/Draggable/SortableList.tsx +1 -1
- package/src/InputField/Select/Autocomplete/Draggable/SortableListContent.tsx +1 -1
- package/src/InputField/Select/Autocomplete/Draggable/index.tsx +1 -1
- package/src/InputField/Select/Autocomplete/Multi/index.tsx +2 -4
- package/src/InputField/Select/Autocomplete/index.tsx +116 -129
- package/src/InputField/Select/IconPopover/index.tsx +2 -2
- package/src/InputField/Select/index.tsx +1 -12
- package/src/InputField/Text/index.tsx +2 -2
- package/src/Listing/ActionBar/index.tsx +8 -9
- package/src/Listing/Cell/DataCell.styles.ts +0 -3
- package/src/Listing/Cell/DataCell.tsx +5 -23
- package/src/Listing/Header/ListingHeader.tsx +1 -1
- package/src/Listing/Listing.cypress.spec.tsx +4 -80
- package/src/Listing/Listing.styles.ts +7 -4
- package/src/Listing/index.stories.tsx +3 -37
- package/src/Listing/index.test.tsx +1 -1
- package/src/Listing/index.tsx +3 -4
- package/src/Listing/models.ts +0 -1
- package/src/Module/index.tsx +4 -2
- package/src/PopoverMenu/index.tsx +5 -6
- package/src/RichTextEditor/RichTextEditor.tsx +1 -12
- package/src/SortableItems/index.tsx +7 -2
- package/src/ThemeProvider/index.tsx +0 -24
- package/src/TimePeriods/CustomTimePeriod/CompactCustomTimePeriod.styles.ts +7 -6
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/PickersStartEndDate.tsx +3 -8
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/models.ts +2 -0
- package/src/TimePeriods/DateTimePickerInput.tsx +19 -56
- package/src/TimePeriods/ResolutionTimePeriod.cypress.spec.tsx +9 -12
- package/src/TimePeriods/TimePeriods.cypress.spec.tsx +33 -9
- package/src/TimePeriods/helpers/index.ts +1 -1
- package/src/TimePeriods/index.stories.tsx +4 -12
- package/src/TimePeriods/index.tsx +2 -2
- package/src/Typography/FluidTypography/index.stories.tsx +2 -2
- package/src/Typography/FluidTypography/index.tsx +28 -21
- package/src/Typography/FluidTypography/useFluidResizeObserver.ts +56 -0
- package/src/api/QueryProvider.tsx +1 -1
- package/src/api/TestQueryProvider.tsx +1 -1
- package/src/api/index.ts +3 -3
- package/src/api/useFetchQuery/index.ts +23 -27
- package/src/api/useMutationQuery/index.test.ts +4 -4
- package/src/api/useMutationQuery/index.ts +25 -60
- package/src/components/Button/Icon/IconButton.tsx +2 -6
- package/src/components/DataTable/DataTable.stories.tsx +0 -40
- package/src/components/DataTable/DataTable.styles.ts +0 -3
- package/src/components/DataTable/DataTable.tsx +3 -3
- package/src/components/DataTable/Item/DataTableItem.styles.ts +2 -7
- package/src/components/DataTable/Item/DataTableItem.tsx +28 -9
- package/src/components/DataTable/index.ts +1 -3
- package/src/components/Form/AccessRights/ShareInput/ContactSwitch.tsx +3 -3
- package/src/components/Form/AccessRights/ShareInput/ShareInput.tsx +0 -1
- package/src/components/Form/Dashboard/DashboardForm.tsx +12 -15
- package/src/components/Layout/PageLayout/PageLayout.tsx +1 -1
- package/src/components/Layout/PageLayout/PageLayoutActions.tsx +0 -1
- package/src/components/Layout/PageLayout/PageLayoutBody.tsx +0 -1
- package/src/components/Layout/PageLayout/PageLayoutHeader.tsx +1 -5
- package/src/components/Layout/PageLayout/index.ts +1 -3
- package/src/components/List/Item/ListItem.tsx +3 -3
- package/src/components/Modal/Modal.styles.ts +3 -8
- package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.stories.tsx +3 -3
- package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.tsx +1 -1
- package/src/components/Tooltip/ConfirmationTooltip/models.ts +1 -1
- package/src/index.ts +2 -2
- package/src/queryParameters/url/index.ts +1 -5
- package/src/screens/dashboard/DashboardsDetail.stories.tsx +108 -0
- package/src/screens/dashboard/DashboardsOverview.stories.tsx +281 -0
- package/src/utils/index.ts +1 -1
- package/src/utils/useDateTimePickerAdapter.ts +309 -0
- package/src/utils/useFullscreen/Fullscreen.cypress.spec.tsx +3 -1
- package/src/utils/useFullscreen/useFullscreenListener.ts +7 -10
- package/src/utils/useInfiniteScrollListing.ts +1 -4
- package/src/utils/{useLicenseExpirationWarning.test.tsx → useLicenseExpirationWarning.cypress.spec.tsx} +37 -48
- package/src/utils/useLicenseExpirationWarning.ts +18 -18
- package/src/Form/Form.cypress.spec.tsx +0 -133
- package/src/Form/Inputs/List/Content.tsx +0 -62
- package/src/Form/Inputs/List/List.styles.ts +0 -29
- package/src/Form/Inputs/List/List.tsx +0 -58
- package/src/Form/Inputs/List/useList.ts +0 -81
- package/src/Graph/BarStack/BarStack.cypress.spec.tsx +0 -154
- package/src/Graph/BarStack/BarStack.stories.tsx +0 -123
- package/src/Graph/BarStack/BarStack.styles.ts +0 -37
- package/src/Graph/BarStack/BarStack.tsx +0 -14
- package/src/Graph/BarStack/ResponsiveBarStack.tsx +0 -222
- package/src/Graph/BarStack/index.ts +0 -1
- package/src/Graph/BarStack/models.ts +0 -20
- package/src/Graph/BarStack/useResponsiveBarStack.ts +0 -137
- package/src/Graph/Gauge/Gauge.cypress.spec.tsx +0 -102
- package/src/Graph/HeatMap/HeatMap.cypress.spec.tsx +0 -145
- package/src/Graph/Legend/Legend.tsx +0 -21
- package/src/Graph/Legend/index.ts +0 -1
- package/src/Graph/Legend/models.ts +0 -11
- package/src/Graph/PieChart/PieChart.cypress.spec.tsx +0 -169
- package/src/Graph/PieChart/PieChart.stories.tsx +0 -194
- package/src/Graph/PieChart/PieChart.styles.ts +0 -39
- package/src/Graph/PieChart/PieChart.tsx +0 -14
- package/src/Graph/PieChart/ResponsivePie.tsx +0 -254
- package/src/Graph/PieChart/index.ts +0 -1
- package/src/Graph/PieChart/models.ts +0 -20
- package/src/Graph/PieChart/useResponsivePie.ts +0 -85
- package/src/Graph/SingleBar/SingleBar.cypress.spec.tsx +0 -121
- package/src/Graph/Text/Text.cypress.spec.tsx +0 -101
- package/src/Graph/common/testUtils.ts +0 -71
- package/src/Graph/translatedLabels.ts +0 -1
- package/src/Module/Module.cypress.spec.tsx +0 -129
- package/src/Typography/FluidTypography/FluidTypography.cypress.spec.tsx +0 -27
- package/src/components/DataTable/DataListing.tsx +0 -6
- package/src/components/DataTable/DataTable.cypress.spec.tsx +0 -193
- package/src/components/Layout/PageLayout/PageQuickAccess.tsx +0 -76
- package/src/components/Layout/PageLayout.cypress.spec.tsx +0 -66
- package/src/utils/usePluralizedTranslation.ts +0 -21
|
@@ -2,15 +2,12 @@ import { useAtomValue } from 'jotai';
|
|
|
2
2
|
import { makeStyles } from 'tss-react/mui';
|
|
3
3
|
import { equals } from 'ramda';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
|
-
import dayjs from 'dayjs';
|
|
6
|
-
import utc from 'dayjs/plugin/utc';
|
|
7
|
-
import timezone from 'dayjs/plugin/timezone';
|
|
8
5
|
|
|
9
|
-
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
|
|
10
6
|
import { Typography } from '@mui/material';
|
|
11
7
|
import { LocalizationProvider } from '@mui/x-date-pickers';
|
|
12
8
|
|
|
13
9
|
import { userAtom } from '@centreon/ui-context';
|
|
10
|
+
import { useDateTimePickerAdapter } from '@centreon/ui';
|
|
14
11
|
|
|
15
12
|
import DateTimePickerInput from '../../DateTimePickerInput';
|
|
16
13
|
import {
|
|
@@ -23,9 +20,6 @@ import ErrorText from './ErrorText';
|
|
|
23
20
|
import { PickersData, PickersStartEndDateDirection } from './models';
|
|
24
21
|
import { PickersStartEndDateModel } from './usePickersStartEndDate';
|
|
25
22
|
|
|
26
|
-
dayjs.extend(utc);
|
|
27
|
-
dayjs.extend(timezone);
|
|
28
|
-
|
|
29
23
|
const useStyles = makeStyles()((theme) => ({
|
|
30
24
|
error: {
|
|
31
25
|
textAlign: 'center'
|
|
@@ -110,6 +104,7 @@ const PickersStartEndDate = ({
|
|
|
110
104
|
direction = PickersStartEndDateDirection.column
|
|
111
105
|
}: Props): JSX.Element => {
|
|
112
106
|
const { classes, cx } = useStyles();
|
|
107
|
+
const { Adapter } = useDateTimePickerAdapter();
|
|
113
108
|
|
|
114
109
|
const { locale } = useAtomValue(userAtom);
|
|
115
110
|
const error = useAtomValue(errorTimePeriodAtom);
|
|
@@ -131,7 +126,7 @@ const PickersStartEndDate = ({
|
|
|
131
126
|
return (
|
|
132
127
|
<LocalizationProvider
|
|
133
128
|
adapterLocale={locale.substring(0, 2)}
|
|
134
|
-
dateAdapter={
|
|
129
|
+
dateAdapter={Adapter}
|
|
135
130
|
>
|
|
136
131
|
<div className={styleContainer}>
|
|
137
132
|
<PickerDateWithLabel
|
|
@@ -18,6 +18,8 @@ export interface PickersData {
|
|
|
18
18
|
getError?: (value: boolean) => void;
|
|
19
19
|
isDisabledEndPicker?: boolean;
|
|
20
20
|
isDisabledStartPicker?: boolean;
|
|
21
|
+
onCloseEndPicker?: (isClosed: boolean) => void;
|
|
22
|
+
onCloseStartPicker?: (isClosed: boolean) => void;
|
|
21
23
|
rangeEndDate?: RangeDate;
|
|
22
24
|
rangeStartDate?: RangeDate;
|
|
23
25
|
}
|
|
@@ -1,85 +1,48 @@
|
|
|
1
|
-
import
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import { useAtomValue } from 'jotai';
|
|
5
|
-
import { equals } from 'ramda';
|
|
3
|
+
import { DateTimePicker } from '@mui/x-date-pickers';
|
|
6
4
|
|
|
7
|
-
import {
|
|
8
|
-
DateTimePicker,
|
|
9
|
-
DateTimePickerProps,
|
|
10
|
-
LocalizationProvider
|
|
11
|
-
} from '@mui/x-date-pickers';
|
|
12
|
-
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
|
|
13
|
-
|
|
14
|
-
import { userAtom } from '@centreon/ui-context';
|
|
5
|
+
import { useDateTimePickerAdapter } from '@centreon/ui';
|
|
15
6
|
|
|
16
7
|
import { CustomTimePeriodProperty } from './models';
|
|
17
8
|
|
|
18
|
-
interface ChangeDateProps {
|
|
19
|
-
date: Date;
|
|
20
|
-
property: CustomTimePeriodProperty | string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
9
|
interface Props {
|
|
24
|
-
changeDate: (props
|
|
10
|
+
changeDate: (props) => void;
|
|
25
11
|
date: Date | null;
|
|
26
12
|
desktopMediaQuery?: string;
|
|
27
13
|
disabled?: boolean;
|
|
28
14
|
maxDate?: Date;
|
|
29
15
|
minDate?: Date;
|
|
30
|
-
|
|
31
|
-
property: CustomTimePeriodProperty | string;
|
|
16
|
+
property: CustomTimePeriodProperty;
|
|
32
17
|
}
|
|
33
18
|
|
|
34
19
|
const DateTimePickerInput = ({
|
|
35
20
|
date,
|
|
36
21
|
maxDate,
|
|
37
22
|
minDate,
|
|
38
|
-
minDateTime,
|
|
39
23
|
property,
|
|
40
24
|
changeDate,
|
|
41
25
|
disabled = false,
|
|
42
|
-
desktopMediaQuery
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const desktopPickerMediaQuery =
|
|
46
|
-
'@media (min-width: 1024px) or (pointer: fine)';
|
|
47
|
-
|
|
48
|
-
const { timezone, locale } = useAtomValue(userAtom);
|
|
49
|
-
|
|
50
|
-
const isUTC = equals(timezone, 'UTC');
|
|
26
|
+
desktopMediaQuery
|
|
27
|
+
}: Props): JSX.Element => {
|
|
28
|
+
const { desktopPickerMediaQuery } = useDateTimePickerAdapter();
|
|
51
29
|
|
|
52
30
|
const changeTime = (newValue: dayjs.Dayjs | null): void => {
|
|
53
31
|
changeDate({ date: dayjs(newValue).toDate(), property });
|
|
54
32
|
};
|
|
55
33
|
|
|
56
|
-
const formatDate = useCallback(
|
|
57
|
-
(currentDate: Date | null): Dayjs => {
|
|
58
|
-
return isUTC ? dayjs.utc(currentDate) : dayjs.tz(currentDate, timezone);
|
|
59
|
-
},
|
|
60
|
-
[isUTC, timezone]
|
|
61
|
-
);
|
|
62
|
-
|
|
63
34
|
return (
|
|
64
|
-
<
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
maxDate={maxDate && formatDate(maxDate)}
|
|
76
|
-
minDate={minDate && formatDate(minDate)}
|
|
77
|
-
minDateTime={minDateTime && formatDate(minDateTime)}
|
|
78
|
-
value={formatDate(date)}
|
|
79
|
-
onChange={changeTime}
|
|
80
|
-
{...rest}
|
|
81
|
-
/>
|
|
82
|
-
</LocalizationProvider>
|
|
35
|
+
<DateTimePicker<dayjs.Dayjs>
|
|
36
|
+
dayOfWeekFormatter={(day: string): string =>
|
|
37
|
+
day.substring(0, 2).toUpperCase()
|
|
38
|
+
}
|
|
39
|
+
desktopModeMediaQuery={desktopMediaQuery ?? desktopPickerMediaQuery}
|
|
40
|
+
disabled={disabled}
|
|
41
|
+
maxDate={maxDate && dayjs(maxDate)}
|
|
42
|
+
minDate={minDate && dayjs(minDate)}
|
|
43
|
+
value={dayjs(date)}
|
|
44
|
+
onChange={changeTime}
|
|
45
|
+
/>
|
|
83
46
|
);
|
|
84
47
|
};
|
|
85
48
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import dayjs from 'dayjs';
|
|
2
|
-
import 'dayjs/locale/
|
|
2
|
+
import 'dayjs/locale/fr';
|
|
3
3
|
import localizedFormatPlugin from 'dayjs/plugin/localizedFormat';
|
|
4
4
|
import timezonePlugin from 'dayjs/plugin/timezone';
|
|
5
5
|
import utcPlugin from 'dayjs/plugin/utc';
|
|
@@ -19,18 +19,18 @@ dayjs.extend(localizedFormatPlugin);
|
|
|
19
19
|
|
|
20
20
|
const data = [
|
|
21
21
|
{
|
|
22
|
-
locale: '
|
|
23
|
-
resolution: { height:
|
|
22
|
+
locale: 'fr_FR',
|
|
23
|
+
resolution: { height: 720, width: 500 },
|
|
24
24
|
timezone: 'Europe/Paris'
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
|
-
locale: '
|
|
28
|
-
resolution: { height:
|
|
27
|
+
locale: 'fr_FR',
|
|
28
|
+
resolution: { height: 720, width: 200 },
|
|
29
29
|
timezone: 'Europe/Paris'
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
|
-
locale: '
|
|
33
|
-
resolution: { height:
|
|
32
|
+
locale: 'fr_FR',
|
|
33
|
+
resolution: { height: 720, width: 1024 },
|
|
34
34
|
timezone: 'Europe/Paris'
|
|
35
35
|
}
|
|
36
36
|
];
|
|
@@ -45,7 +45,7 @@ data.forEach((item) =>
|
|
|
45
45
|
|
|
46
46
|
store.set(userAtom, {
|
|
47
47
|
...retrievedUser,
|
|
48
|
-
locale: '
|
|
48
|
+
locale: 'fr_FR',
|
|
49
49
|
timezone: 'Europe/Paris'
|
|
50
50
|
});
|
|
51
51
|
|
|
@@ -59,10 +59,7 @@ data.forEach((item) =>
|
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
it(`displays correctly the dates design when screen resolution is ${width}px`, () => {
|
|
62
|
-
cy.
|
|
63
|
-
resolution: { height, width },
|
|
64
|
-
title: `${width}px`
|
|
65
|
-
});
|
|
62
|
+
cy.makeSnapshot(`${width}px`);
|
|
66
63
|
});
|
|
67
64
|
})
|
|
68
65
|
);
|
|
@@ -3,10 +3,15 @@ import localizedFormatPlugin from 'dayjs/plugin/localizedFormat';
|
|
|
3
3
|
import timezonePlugin from 'dayjs/plugin/timezone';
|
|
4
4
|
import utcPlugin from 'dayjs/plugin/utc';
|
|
5
5
|
import { Provider, createStore } from 'jotai';
|
|
6
|
-
import { equals } from 'ramda';
|
|
6
|
+
import { equals, inc } from 'ramda';
|
|
7
7
|
import { renderHook } from '@testing-library/react';
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { LocalizationProvider } from '@mui/x-date-pickers';
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
useLocaleDateTimeFormat,
|
|
13
|
+
useDateTimePickerAdapter
|
|
14
|
+
} from '@centreon/ui';
|
|
10
15
|
import { ListingVariant, userAtom } from '@centreon/ui-context';
|
|
11
16
|
|
|
12
17
|
import { CustomTimePeriodProperty } from './models';
|
|
@@ -292,6 +297,10 @@ testData.forEach((item) =>
|
|
|
292
297
|
beforeEach(() => {
|
|
293
298
|
cy.viewport('macbook-13');
|
|
294
299
|
|
|
300
|
+
const { result } = renderHook(() => useDateTimePickerAdapter());
|
|
301
|
+
|
|
302
|
+
const { Adapter } = result.current;
|
|
303
|
+
|
|
295
304
|
const store = createStore();
|
|
296
305
|
store.set(userAtom, {
|
|
297
306
|
...retrievedUser,
|
|
@@ -302,16 +311,31 @@ testData.forEach((item) =>
|
|
|
302
311
|
cy.mount({
|
|
303
312
|
Component: (
|
|
304
313
|
<Provider store={store}>
|
|
305
|
-
<
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
314
|
+
<LocalizationProvider adapterLocale="en" dateAdapter={Adapter}>
|
|
315
|
+
<DateTimePickerInput
|
|
316
|
+
changeDate={cy.stub()}
|
|
317
|
+
date={new Date(item.initialDate)}
|
|
318
|
+
desktopMediaQuery="@media (min-width: 1024px)"
|
|
319
|
+
property={CustomTimePeriodProperty.start}
|
|
320
|
+
/>
|
|
321
|
+
</LocalizationProvider>
|
|
310
322
|
</Provider>
|
|
311
323
|
)
|
|
312
324
|
});
|
|
313
325
|
});
|
|
314
326
|
|
|
327
|
+
it('checks input calendar value contains correct date', () => {
|
|
328
|
+
const { result } = renderHook(() => useLocaleDateTimeFormat());
|
|
329
|
+
const { format } = result.current;
|
|
330
|
+
|
|
331
|
+
const dateInput = format({
|
|
332
|
+
date: dayjs(item.initialDate).tz(item.timezone),
|
|
333
|
+
formatString: 'L hh:mm A'
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
cy.get('input').should('have.value', dateInput);
|
|
337
|
+
});
|
|
338
|
+
|
|
315
339
|
it(`displays the correct number of days for the current month when the ${item.button} button is clicked`, () => {
|
|
316
340
|
cy.get('button').click();
|
|
317
341
|
item.data.forEach((element) => {
|
|
@@ -365,7 +389,7 @@ testData.forEach((item) =>
|
|
|
365
389
|
|
|
366
390
|
cy.get('[role="rowgroup"]').children().as('listWeeks');
|
|
367
391
|
|
|
368
|
-
cy.get('@listWeeks').should('have.length', numberWeeks);
|
|
392
|
+
cy.get('@listWeeks').should('have.length', inc(numberWeeks));
|
|
369
393
|
cy.get('@listWeeks').eq(0).as('firstWeek');
|
|
370
394
|
cy.get('@firstWeek').children().as('listDaysInFirstWeek');
|
|
371
395
|
|
|
@@ -392,7 +416,7 @@ testData.forEach((item) =>
|
|
|
392
416
|
|
|
393
417
|
cy.get('[role="rowgroup"]').children().as('listWeeks');
|
|
394
418
|
|
|
395
|
-
cy.get('@listWeeks').should('have.length', numberWeeks);
|
|
419
|
+
cy.get('@listWeeks').should('have.length', inc(numberWeeks));
|
|
396
420
|
|
|
397
421
|
cy.get('@listWeeks')
|
|
398
422
|
.eq(numberWeeks - 1)
|
|
@@ -88,27 +88,20 @@ const args = {
|
|
|
88
88
|
]
|
|
89
89
|
};
|
|
90
90
|
|
|
91
|
-
const parameters = {
|
|
92
|
-
chromatic: { diffThreshold: 0.1 }
|
|
93
|
-
};
|
|
94
|
-
|
|
95
91
|
export const BasicTimePeriod: Story = {
|
|
96
92
|
...Template,
|
|
97
|
-
argTypes
|
|
98
|
-
parameters
|
|
93
|
+
argTypes
|
|
99
94
|
};
|
|
100
95
|
|
|
101
96
|
export const WithExtraTimePeriods: Story = {
|
|
102
97
|
...Template,
|
|
103
98
|
argTypes,
|
|
104
|
-
args
|
|
105
|
-
parameters
|
|
99
|
+
args
|
|
106
100
|
};
|
|
107
101
|
|
|
108
102
|
export const WithExternalComponent: Story = {
|
|
109
103
|
...TemplateWithExternalComponent,
|
|
110
|
-
argTypes
|
|
111
|
-
parameters
|
|
104
|
+
argTypes
|
|
112
105
|
};
|
|
113
106
|
|
|
114
107
|
export const SimpleTimePeriod: StorySimpleTimePeriod = {
|
|
@@ -116,6 +109,5 @@ export const SimpleTimePeriod: StorySimpleTimePeriod = {
|
|
|
116
109
|
args: {
|
|
117
110
|
endDate: dayjs(Date.now()).toDate(),
|
|
118
111
|
startDate: dayjs(Date.now()).subtract(29, 'day').toDate()
|
|
119
|
-
}
|
|
120
|
-
parameters
|
|
112
|
+
}
|
|
121
113
|
};
|
|
@@ -20,7 +20,7 @@ import { useStyles } from './TimePeriods.styles';
|
|
|
20
20
|
import {
|
|
21
21
|
CustomTimePeriod as CustomTimePeriodModel,
|
|
22
22
|
EndStartInterval,
|
|
23
|
-
TimePeriod
|
|
23
|
+
TimePeriod
|
|
24
24
|
} from './models';
|
|
25
25
|
import useTimePeriod from './useTimePeriod';
|
|
26
26
|
|
|
@@ -34,7 +34,7 @@ interface Parameters extends EndStartInterval {
|
|
|
34
34
|
export interface Props {
|
|
35
35
|
adjustTimePeriodData?: Omit<CustomTimePeriodModel, 'timelineEventsLimit'>;
|
|
36
36
|
disabled?: boolean;
|
|
37
|
-
extraTimePeriods?: Array<Omit<
|
|
37
|
+
extraTimePeriods?: Array<Omit<TimePeriod, 'timelineEventsLimit'>>;
|
|
38
38
|
getIsError?: (value: boolean) => void;
|
|
39
39
|
getParameters?: ({ start, end, timelineEventsLimit }: Parameters) => void;
|
|
40
40
|
renderExternalComponent?: ReactNode;
|
|
@@ -40,9 +40,9 @@ basic.args = {
|
|
|
40
40
|
|
|
41
41
|
export const with200pxWidth = FluidTypographyTemplate.bind({});
|
|
42
42
|
with200pxWidth.args = {
|
|
43
|
-
height: '
|
|
43
|
+
height: '200px',
|
|
44
44
|
text: 'Hello world',
|
|
45
|
-
width: '
|
|
45
|
+
width: '200px'
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
export const with20pxHeight = FluidTypographyTemplate.bind({});
|
|
@@ -1,42 +1,49 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
|
|
1
3
|
import { Typography, TypographyProps } from '@mui/material';
|
|
2
4
|
|
|
5
|
+
import useFluidResizeObserver from './useFluidResizeObserver';
|
|
6
|
+
|
|
3
7
|
type CustomTypographyProps = Pick<TypographyProps, 'variant'>;
|
|
4
8
|
export interface FluidTypographyProps extends CustomTypographyProps {
|
|
5
9
|
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
|
|
17
|
-
containerClassName,
|
|
18
|
-
min = '10px',
|
|
19
|
-
max = '1000px',
|
|
20
|
-
pref = 19
|
|
16
|
+
className
|
|
21
17
|
}: 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
|
+
|
|
22
24
|
return (
|
|
23
25
|
<div
|
|
24
|
-
|
|
26
|
+
ref={parentRef}
|
|
25
27
|
style={{
|
|
26
|
-
|
|
27
|
-
height: `100%`,
|
|
28
|
+
height: `${parentSize.height}px`,
|
|
28
29
|
width: `100%`
|
|
29
30
|
}}
|
|
30
31
|
>
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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>
|
|
40
47
|
</div>
|
|
41
48
|
);
|
|
42
49
|
};
|
|
@@ -0,0 +1,56 @@
|
|
|
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;
|
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,
|
|
33
|
+
.patch(endpoint, 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,
|
|
43
|
+
.post(endpoint, 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,
|
|
53
|
+
.put(endpoint, data, {
|
|
54
54
|
cancelToken,
|
|
55
55
|
headers: contentTypeHeaders
|
|
56
56
|
})
|
|
@@ -27,9 +27,7 @@ export interface UseFetchQueryProps<T> {
|
|
|
27
27
|
getQueryKey: () => QueryKey;
|
|
28
28
|
httpCodesBypassErrorSnackbar?: Array<number>;
|
|
29
29
|
isPaginated?: boolean;
|
|
30
|
-
queryOptions?:
|
|
31
|
-
suspense?: boolean;
|
|
32
|
-
} & Omit<
|
|
30
|
+
queryOptions?: Omit<
|
|
33
31
|
UseQueryOptions<T | ResponseError, Error, T | ResponseError, QueryKey>,
|
|
34
32
|
'queryKey' | 'queryFn'
|
|
35
33
|
>;
|
|
@@ -37,12 +35,11 @@ export interface UseFetchQueryProps<T> {
|
|
|
37
35
|
|
|
38
36
|
export type UseFetchQueryState<T> = {
|
|
39
37
|
data?: T;
|
|
40
|
-
error: Omit<ResponseError, 'isError'> | null;
|
|
41
38
|
fetchQuery: () => Promise<T | ResponseError>;
|
|
42
39
|
prefetchNextPage: ({ page, getPrefetchQueryKey }) => void;
|
|
43
40
|
prefetchPreviousPage: ({ page, getPrefetchQueryKey }) => void;
|
|
44
41
|
prefetchQuery: ({ endpointParams, queryKey }) => void;
|
|
45
|
-
} & Omit<QueryObserverBaseResult, 'data'
|
|
42
|
+
} & Omit<QueryObserverBaseResult, 'data'>;
|
|
46
43
|
|
|
47
44
|
export interface PrefetchEndpointParams {
|
|
48
45
|
page: number;
|
|
@@ -67,8 +64,9 @@ const useFetchQuery = <T extends object>({
|
|
|
67
64
|
|
|
68
65
|
const { showErrorMessage } = useSnackbar();
|
|
69
66
|
|
|
70
|
-
const queryData = useQuery<T | ResponseError, Error>(
|
|
71
|
-
|
|
67
|
+
const queryData = useQuery<T | ResponseError, Error>(
|
|
68
|
+
getQueryKey(),
|
|
69
|
+
({ signal }): Promise<T | ResponseError> =>
|
|
72
70
|
customFetch<T>({
|
|
73
71
|
baseEndpoint,
|
|
74
72
|
catchError,
|
|
@@ -78,9 +76,10 @@ const useFetchQuery = <T extends object>({
|
|
|
78
76
|
headers: new Headers(fetchHeaders),
|
|
79
77
|
signal
|
|
80
78
|
}),
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
{
|
|
80
|
+
...queryOptions
|
|
81
|
+
}
|
|
82
|
+
);
|
|
84
83
|
|
|
85
84
|
const queryClient = useQueryClient();
|
|
86
85
|
|
|
@@ -100,8 +99,9 @@ const useFetchQuery = <T extends object>({
|
|
|
100
99
|
};
|
|
101
100
|
|
|
102
101
|
const prefetchQuery = ({ endpointParams, queryKey }): void => {
|
|
103
|
-
queryClient.prefetchQuery(
|
|
104
|
-
|
|
102
|
+
queryClient.prefetchQuery(
|
|
103
|
+
queryKey,
|
|
104
|
+
({ signal }): Promise<T | ResponseError> =>
|
|
105
105
|
customFetch<T>({
|
|
106
106
|
baseEndpoint,
|
|
107
107
|
catchError,
|
|
@@ -110,9 +110,8 @@ const useFetchQuery = <T extends object>({
|
|
|
110
110
|
endpoint: getEndpoint(endpointParams),
|
|
111
111
|
headers: new Headers(fetchHeaders),
|
|
112
112
|
signal
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
});
|
|
113
|
+
})
|
|
114
|
+
);
|
|
116
115
|
};
|
|
117
116
|
|
|
118
117
|
const prefetchNextPage = ({ page, getPrefetchQueryKey }): void => {
|
|
@@ -142,8 +141,9 @@ const useFetchQuery = <T extends object>({
|
|
|
142
141
|
};
|
|
143
142
|
|
|
144
143
|
const fetchQuery = (): Promise<T | ResponseError> => {
|
|
145
|
-
return queryClient.fetchQuery(
|
|
146
|
-
|
|
144
|
+
return queryClient.fetchQuery(
|
|
145
|
+
getQueryKey(),
|
|
146
|
+
({ signal }): Promise<T | ResponseError> =>
|
|
147
147
|
customFetch<T>({
|
|
148
148
|
baseEndpoint,
|
|
149
149
|
catchError,
|
|
@@ -152,9 +152,8 @@ const useFetchQuery = <T extends object>({
|
|
|
152
152
|
endpoint: getEndpoint(),
|
|
153
153
|
headers: new Headers(fetchHeaders),
|
|
154
154
|
signal
|
|
155
|
-
})
|
|
156
|
-
|
|
157
|
-
});
|
|
155
|
+
})
|
|
156
|
+
);
|
|
158
157
|
};
|
|
159
158
|
|
|
160
159
|
const data = useMemo(
|
|
@@ -175,16 +174,13 @@ const useFetchQuery = <T extends object>({
|
|
|
175
174
|
return;
|
|
176
175
|
}
|
|
177
176
|
|
|
178
|
-
queryClient.cancelQueries(
|
|
177
|
+
queryClient.cancelQueries(getQueryKey());
|
|
179
178
|
};
|
|
180
179
|
}, []);
|
|
181
180
|
|
|
182
|
-
useEffect(
|
|
183
|
-
()
|
|
184
|
-
|
|
185
|
-
},
|
|
186
|
-
useDeepCompare([queryData.data])
|
|
187
|
-
);
|
|
181
|
+
useEffect(() => {
|
|
182
|
+
manageError();
|
|
183
|
+
}, useDeepCompare([queryData.data]));
|
|
188
184
|
|
|
189
185
|
return {
|
|
190
186
|
...omit(['data', 'error'], queryData),
|