@centreon/ui 26.5.8 → 26.5.10

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 (141) hide show
  1. package/package.json +3 -1
  2. package/src/@types/globals.d.ts +21 -0
  3. package/src/Colors/index.tsx +1 -1
  4. package/src/Dashboard/Item.tsx +3 -3
  5. package/src/Dialog/Duplicate/index.tsx +1 -1
  6. package/src/FileDropZone/useDropzone.test.ts +18 -15
  7. package/src/Form/Inputs/Checkbox.tsx +6 -3
  8. package/src/Form/Inputs/CheckboxGroup.tsx +8 -8
  9. package/src/Form/Inputs/ConnectedAutocomplete.tsx +9 -3
  10. package/src/Form/Inputs/FieldsTable/FieldsTable.tsx +1 -1
  11. package/src/Form/Inputs/File.tsx +3 -1
  12. package/src/Form/Inputs/Grid.tsx +1 -1
  13. package/src/Form/Inputs/List/List.tsx +8 -7
  14. package/src/Form/Inputs/List/useList.ts +12 -6
  15. package/src/Form/Inputs/Radio.tsx +7 -1
  16. package/src/Form/Inputs/Text.tsx +1 -1
  17. package/src/Form/Inputs/index.tsx +7 -2
  18. package/src/Form/storiesData.tsx +5 -2
  19. package/src/Graph/BarChart/Bar.tsx +2 -2
  20. package/src/Graph/BarChart/BarChart.tsx +2 -0
  21. package/src/Graph/BarChart/BarGroup.tsx +3 -0
  22. package/src/Graph/BarChart/BarStack.tsx +1 -0
  23. package/src/Graph/BarChart/MemoizedGroup.tsx +3 -1
  24. package/src/Graph/BarChart/ResponsiveBarChart.tsx +5 -0
  25. package/src/Graph/BarChart/Tooltip/BarChartTooltip.tsx +4 -0
  26. package/src/Graph/BarStack/Graph.tsx +3 -0
  27. package/src/Graph/Chart/BasicComponents/Lines/RegularLines/index.tsx +4 -1
  28. package/src/Graph/Chart/BasicComponents/Lines/StackedLines/index.tsx +7 -1
  29. package/src/Graph/Chart/BasicComponents/Lines/Threshold/BasicThreshold.tsx +1 -0
  30. package/src/Graph/Chart/BasicComponents/Lines/index.tsx +11 -1
  31. package/src/Graph/Chart/Chart.tsx +9 -0
  32. package/src/Graph/Chart/InteractiveComponents/AnchorPoint/StackedAnchorPoint.tsx +2 -0
  33. package/src/Graph/Chart/InteractiveComponents/AnchorPoint/useTickGraph.ts +2 -0
  34. package/src/Graph/Chart/InteractiveComponents/Annotations/annotationsAtoms.ts +5 -0
  35. package/src/Graph/Chart/InteractiveComponents/GraphValueTooltip/GraphValueTooltip.tsx +3 -0
  36. package/src/Graph/Chart/Legend/LegendHeader.tsx +1 -0
  37. package/src/Graph/Chart/Legend/index.tsx +6 -1
  38. package/src/Graph/Chart/useChartData.ts +6 -0
  39. package/src/Graph/Gauge/AnimatedPie.tsx +3 -0
  40. package/src/Graph/Gauge/PieData.tsx +5 -0
  41. package/src/Graph/Gauge/ResponsiveGauge.tsx +2 -0
  42. package/src/Graph/Gauge/Thresholds.tsx +1 -0
  43. package/src/Graph/HeatMap/ResponsiveHeatMap.tsx +1 -0
  44. package/src/Graph/SingleBar/ResponsiveSingleBar.tsx +2 -0
  45. package/src/Graph/Timeline/ResponsiveTimeline.tsx +1 -0
  46. package/src/Graph/Tree/Links.tsx +1 -0
  47. package/src/Graph/Tree/Tree.tsx +1 -0
  48. package/src/Graph/Tree/stories/datas.ts +2 -0
  49. package/src/Graph/common/Axes/index.tsx +3 -3
  50. package/src/Graph/common/BaseChart/BaseChart.tsx +3 -0
  51. package/src/Graph/common/BaseChart/ChartSvgWrapper.tsx +1 -0
  52. package/src/Graph/common/BaseChart/Header/models.ts +1 -0
  53. package/src/Graph/common/timeSeries/index.test.ts +17 -1
  54. package/src/Graph/common/timeSeries/index.ts +12 -0
  55. package/src/Graph/common/utils.ts +6 -2
  56. package/src/InputField/Number/Number.tsx +10 -4
  57. package/src/InputField/Search/PersistentTooltip.tsx +6 -5
  58. package/src/InputField/Select/Autocomplete/Connected/Single.tsx +3 -1
  59. package/src/InputField/Select/Autocomplete/Connected/index.test.tsx +1 -1
  60. package/src/InputField/Select/Autocomplete/Connected/index.tsx +5 -1
  61. package/src/InputField/Select/Autocomplete/Draggable/SortableList.tsx +4 -5
  62. package/src/InputField/Select/Autocomplete/Draggable/index.tsx +4 -5
  63. package/src/InputField/Select/Autocomplete/Multi/Listbox.tsx +16 -1
  64. package/src/InputField/Select/Autocomplete/Multi/Multi.tsx +44 -30
  65. package/src/InputField/Select/Autocomplete/Multi/index.tsx +1 -0
  66. package/src/InputField/Select/Autocomplete/index.tsx +7 -1
  67. package/src/InputField/Select/IconPopover/index.tsx +0 -3
  68. package/src/InputField/Select/Option.tsx +6 -1
  69. package/src/InputField/Select/index.tsx +3 -3
  70. package/src/InputField/Text/index.tsx +11 -3
  71. package/src/InputField/Text/useAutoSize.ts +2 -2
  72. package/src/Listing/ActionBar/index.tsx +2 -3
  73. package/src/Listing/Cell/index.tsx +24 -22
  74. package/src/Listing/Header/Cell/ListingHeaderCell.styles.ts +7 -0
  75. package/src/Listing/Header/ListingHeader.tsx +2 -2
  76. package/src/Listing/Header/_internals/PredefinedSelectionList.tsx +3 -3
  77. package/src/Listing/index.tsx +29 -34
  78. package/src/Listing/useStyleTable.ts +1 -1
  79. package/src/Module/index.tsx +3 -3
  80. package/src/MultiSelectEntries/index.tsx +1 -1
  81. package/src/Pagination/Pagination.tsx +1 -1
  82. package/src/ParentSize/ParentSize.tsx +2 -1
  83. package/src/PopoverMenu/index.tsx +1 -7
  84. package/src/RichTextEditor/ContentEditable.tsx +2 -0
  85. package/src/RichTextEditor/RichTextEditor.tsx +1 -0
  86. package/src/RichTextEditor/plugins/FloatingLinkEditorPlugin.tsx +1 -0
  87. package/src/RichTextEditor/plugins/ToolbarPlugin/BlockButtons.tsx +1 -0
  88. package/src/RichTextEditor/plugins/ToolbarPlugin/ListButton.tsx +2 -0
  89. package/src/Snackbar/index.tsx +3 -1
  90. package/src/SortableItems/Item.tsx +8 -7
  91. package/src/SortableItems/index.tsx +1 -1
  92. package/src/ThemeProvider/index.tsx +5 -3
  93. package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/PickersStartEndDate.tsx +3 -2
  94. package/src/TimePeriods/SelectedTimePeriod.tsx +1 -1
  95. package/src/TimePeriods/timePeriodsAtoms.ts +1 -1
  96. package/src/TimePeriods/useSortTimePeriods.ts +1 -1
  97. package/src/Typography/Subtitle.tsx +3 -1
  98. package/src/Typography/story.utils.tsx +3 -2
  99. package/src/Wizard/ActionsBar.tsx +2 -2
  100. package/src/api/QueryProvider.tsx +1 -2
  101. package/src/api/buildListingEndpoint/getSearchQueryParameterValue.ts +4 -2
  102. package/src/api/useGraphQuery/index.ts +4 -2
  103. package/src/api/useMutationQuery/index.ts +11 -7
  104. package/src/api/useMutationQuery/useOptimisticMutation.ts +34 -16
  105. package/src/api/useRequest/index.test.ts +1 -1
  106. package/src/api/useRequest/index.ts +1 -1
  107. package/src/components/Button/Button.tsx +2 -2
  108. package/src/components/CrudPage/Actions/Filters.tsx +1 -1
  109. package/src/components/CrudPage/Actions/useSearch.tsx +1 -1
  110. package/src/components/CrudPage/Columns/Actions.tsx +2 -2
  111. package/src/components/CrudPage/CrudPageRoot.tsx +1 -1
  112. package/src/components/CrudPage/DeleteModal.tsx +14 -6
  113. package/src/components/CrudPage/Form/AddModal.tsx +16 -4
  114. package/src/components/CrudPage/Form/UpdateModal.tsx +2 -2
  115. package/src/components/CrudPage/Listing.tsx +2 -1
  116. package/src/components/CrudPage/hooks/useDeleteItem.ts +5 -1
  117. package/src/components/CrudPage/hooks/useGetItem.ts +3 -3
  118. package/src/components/DataTable/DataListing.tsx +1 -1
  119. package/src/components/ExpandableContainer/ExpandableContainer.tsx +1 -0
  120. package/src/components/Form/AccessRights/Actions/Actions.tsx +1 -1
  121. package/src/components/Form/AccessRights/Actions/useActions.ts +1 -4
  122. package/src/components/Form/AccessRights/List/StateChip.tsx +1 -1
  123. package/src/components/Form/AccessRights/Stats/Stats.tsx +1 -1
  124. package/src/components/Form/AccessRights/common/RoleSelectField.tsx +4 -6
  125. package/src/components/Form/Dashboard/DashboardForm.tsx +2 -2
  126. package/src/components/Header/PageHeader/PageHeader.styles.ts +26 -20
  127. package/src/components/Menu/useMenu.tsx +3 -3
  128. package/src/components/Modal/ConfirmationModal/ConfirmationModal.tsx +14 -9
  129. package/src/components/Modal/Modal.tsx +5 -3
  130. package/src/components/Modal/ModalActions.tsx +1 -1
  131. package/src/components/Modal/ModalBody.tsx +2 -2
  132. package/src/components/Modal/ModalHeader.tsx +2 -2
  133. package/src/components/Tooltip/TextOverflowTooltip/TextOverflowTooltip.tsx +8 -2
  134. package/src/index.ts +1 -1
  135. package/src/utils/sanitizedHTML.ts +1 -1
  136. package/src/utils/useDebounce.ts +3 -1
  137. package/src/utils/useLicenseExpirationWarning.ts +11 -6
  138. package/src/utils/useLocaleDateTimeFormat/index.test.tsx +3 -1
  139. package/src/utils/useLocaleDateTimeFormat/localeFallback.test.tsx +3 -1
  140. package/src/utils/useMemoComponent.ts +1 -1
  141. package/src/utils/usePluralizedTranslation.test.ts +2 -0
@@ -21,7 +21,6 @@ import {
21
21
  pick,
22
22
  prop,
23
23
  propEq,
24
- reduce,
25
24
  reject,
26
25
  slice,
27
26
  subtract,
@@ -146,7 +145,7 @@ const Listing = <
146
145
  TRow extends {
147
146
  id: RowId;
148
147
  internalListingParentId?: RowId;
149
- internalListingParentRow: TRow;
148
+ internalListingParentRow?: TRow;
150
149
  }
151
150
  >({
152
151
  customListingComponent,
@@ -217,22 +216,21 @@ const Listing = <
217
216
  const [lastSelectionIndex, setLastSelectionIndex] = useState<number | null>(
218
217
  null
219
218
  );
220
- const containerRef = useRef<HTMLDivElement>();
221
- const actionBarRef = useRef<HTMLDivElement>();
219
+ const containerRef = useRef<HTMLDivElement>(null);
220
+ const actionBarRef = useRef<HTMLDivElement>(null);
222
221
 
223
222
  const subItemsPivots = useAtomValue(subItemsPivotsAtom);
224
223
 
225
224
  const allSubItemIds = useMemo(
226
225
  () =>
227
- reduce<TRow | number, Array<string | number>>(
226
+ rows.reduce<Array<string | number>>(
228
227
  (acc, row) => [
229
228
  ...acc,
230
229
  ...(row[subItems?.getRowProperty() || ''] || []).map(
231
230
  ({ id }) => `${subItemPrefixKey}_${getId(row)}_${id}`
232
231
  )
233
232
  ],
234
- [],
235
- rows
233
+ []
236
234
  ),
237
235
  [rows, subItems, getId]
238
236
  );
@@ -240,28 +238,24 @@ const Listing = <
240
238
  const rowsToDisplay = useMemo(
241
239
  () =>
242
240
  subItems?.enable
243
- ? reduce<TRow, Array<TRow>>(
244
- (acc, row): Array<TRow> => {
245
- if (
246
- row[subItems.getRowProperty()] &&
247
- subItemsPivots.includes(row.id)
248
- ) {
249
- return [
250
- ...acc,
251
- row,
252
- ...row[subItems.getRowProperty()].map((subRow) => ({
253
- ...subRow,
254
- internalListingParentId: row.id,
255
- internalListingParentRow: row
256
- }))
257
- ];
258
- }
259
-
260
- return [...acc, row];
261
- },
262
- [],
263
- rows
264
- )
241
+ ? rows.reduce<Array<TRow>>((acc, row): Array<TRow> => {
242
+ if (
243
+ row[subItems.getRowProperty()] &&
244
+ subItemsPivots.includes(row.id)
245
+ ) {
246
+ return [
247
+ ...acc,
248
+ row,
249
+ ...row[subItems.getRowProperty()].map((subRow) => ({
250
+ ...subRow,
251
+ internalListingParentId: row.id,
252
+ internalListingParentRow: row
253
+ }))
254
+ ];
255
+ }
256
+
257
+ return [...acc, row];
258
+ }, [])
265
259
  : rows,
266
260
  [rows, subItemsPivots, subItems]
267
261
  );
@@ -434,7 +428,7 @@ const Listing = <
434
428
  );
435
429
  };
436
430
 
437
- const selectRow = (event: MouseEvent, row): void => {
431
+ const selectRow = (event: React.MouseEvent, row): void => {
438
432
  event.preventDefault();
439
433
  event.stopPropagation();
440
434
  // This prevents unwanted text selection
@@ -700,7 +694,9 @@ const Listing = <
700
694
  <EmptyResult
701
695
  label={
702
696
  labelNoResultFound
703
- ? t(labelNoResultFound)
697
+ ? typeof labelNoResultFound === 'string'
698
+ ? t(labelNoResultFound)
699
+ : labelNoResultFound
704
700
  : t(defaultLabelNoResultFound)
705
701
  }
706
702
  />
@@ -768,9 +764,8 @@ export const MemoizedListing = <TRow extends { id: string | number }>({
768
764
  ),
769
765
  memoProps: [
770
766
  ...memoProps,
771
- pick(
772
- ['id', 'label', 'disabled', 'width', 'shortLabel', 'sortField'],
773
- columns
767
+ columns.map(
768
+ pick(['id', 'label', 'disabled', 'width', 'shortLabel', 'sortField'])
774
769
  ),
775
770
  columnConfiguration,
776
771
  limit,
@@ -34,7 +34,7 @@ export const getTextStyleByViewMode = ({
34
34
  pick(
35
35
  ['color', 'fontSize', 'lineHeight'],
36
36
  theme.typography[isCompactMode(listingVariant) ? 'body2' : 'body1']
37
- );
37
+ ) as CSSObject;
38
38
 
39
39
  const useStyleTable = ({ listingVariant }: TableStyle): TableStyleState => {
40
40
  const dataStyle = useAtomValue(tableStyleAtom);
@@ -1,4 +1,4 @@
1
- import type { ThemeOptions } from '@mui/material';
1
+ import type { PaletteOptions } from '@mui/material';
2
2
  import { createGenerateClassName, StylesProvider } from '@mui/styles';
3
3
 
4
4
  import type { QueryClient } from '@tanstack/react-query';
@@ -14,8 +14,8 @@ export interface ModuleProps {
14
14
  seedName: string;
15
15
  store: ReturnType<typeof createStore>;
16
16
  overrideTheme?: {
17
- light: Partial<ThemeOptions>;
18
- dark: Partial<ThemeOptions>;
17
+ light: Partial<PaletteOptions>;
18
+ dark: Partial<PaletteOptions>;
19
19
  };
20
20
  }
21
21
 
@@ -61,7 +61,7 @@ const EntryChip = ({
61
61
  const { classes } = useStyles();
62
62
 
63
63
  return (
64
- <Grid item size={gridWidth}>
64
+ <Grid size={gridWidth}>
65
65
  <Chip
66
66
  className={classes.chip}
67
67
  label={<div className={classes.labelChip}>{label}</div>}
@@ -65,7 +65,7 @@ const Pagination = ({
65
65
  }
66
66
  });
67
67
 
68
- const pagesCount = Math.ceil(data?.meta.total / limit);
68
+ const pagesCount = Math.ceil((data?.meta?.total ?? 0) / limit);
69
69
  const arePaginationComponentsDisplayed = !equals(pagesCount, 1);
70
70
 
71
71
  const hasNoElements = useMemo(
@@ -1,5 +1,5 @@
1
1
  import { Responsive } from '@visx/visx';
2
- import type { ReactElement } from 'react';
2
+ import type { CSSProperties, ReactElement } from 'react';
3
3
 
4
4
  type ParentSizeState = {
5
5
  height: number;
@@ -10,6 +10,7 @@ type ParentSizeState = {
10
10
 
11
11
  type Props = {
12
12
  children: (args: ParentSizeState) => ReactElement;
13
+ parentSizeStyles?: CSSProperties;
13
14
  };
14
15
 
15
16
  const ParentSize = ({ children, ...props }: Props): JSX.Element => {
@@ -6,7 +6,6 @@ import {
6
6
  } from '@mui/material';
7
7
  import type { PopperProps } from '@mui/material/Popper';
8
8
 
9
- import { equals, type } from 'ramda';
10
9
  import { type Dispatch, type SetStateAction, useEffect, useState } from 'react';
11
10
  import { makeStyles } from 'tss-react/mui';
12
11
 
@@ -108,17 +107,12 @@ const PopoverMenu = ({
108
107
  <Popper
109
108
  anchorEl={anchorEl}
110
109
  className={classes.popover}
111
- nonce={undefined}
112
- onResize={(): undefined => undefined}
113
- onResizeCapture={(): undefined => undefined}
114
110
  open
115
111
  placement={popperPlacement}
116
112
  {...popperProps}
117
113
  >
118
114
  <Paper className={tooltipClassName}>
119
- {equals(type(children), 'Function')
120
- ? children({ close })
121
- : children}
115
+ {typeof children === 'function' ? children({ close }) : children}
122
116
  </Paper>
123
117
  </Popper>
124
118
  </ClickAwayListener>
@@ -145,10 +145,12 @@ const ContentEditable = ({
145
145
 
146
146
  const isTextEmpty =
147
147
  isEmpty(root) &&
148
+ // @ts-expect-error - suppressing pre-existing type mismatch
148
149
  !editor.getEditorState().toJSON().root.children?.[0]?.children?.length;
149
150
 
150
151
  const handleBlur = (event: React.FocusEvent<HTMLInputElement>): void => {
151
152
  setFocused(false);
153
+ // @ts-expect-error - suppressing pre-existing type mismatch
152
154
  onBlur?.(event);
153
155
  };
154
156
 
@@ -216,6 +216,7 @@ const RichTextEditor = ({
216
216
  resetEditorToInitialStateCondition={
217
217
  resetEditorToInitialStateCondition
218
218
  }
219
+ // @ts-expect-error - suppressing pre-existing type mismatch
219
220
  setHtmlString={setHtmlString}
220
221
  />
221
222
  }
@@ -97,6 +97,7 @@ const FloatingLinkEditor = ({
97
97
 
98
98
  if (gt(matched.length, 1)) {
99
99
  setEditedUrl(
100
+ // @ts-expect-error - suppressing pre-existing type mismatch
100
101
  replace(matched.join(''), matched[dec(matched.length)], value)
101
102
  );
102
103
 
@@ -81,6 +81,7 @@ const BlockButtons = ({ disabled }: Props): JSX.Element => {
81
81
 
82
82
  const updateToolbar = useCallback(() => {
83
83
  const selection = $getSelection();
84
+ // @ts-expect-error - suppressing pre-existing type mismatch
84
85
  const anchorNode = selection?.anchor.getNode();
85
86
  const element = equals(anchorNode?.getKey(), 'root')
86
87
  ? anchorNode
@@ -79,6 +79,7 @@ const ListButton = ({ disabled }: Props): JSX.Element => {
79
79
 
80
80
  const updateToolbar = useCallback(() => {
81
81
  const selection = $getSelection();
82
+ // @ts-expect-error - suppressing pre-existing type mismatch
82
83
  const anchorNode = selection?.anchor.getNode();
83
84
  const element = equals(anchorNode?.getKey(), 'root')
84
85
  ? anchorNode
@@ -100,6 +101,7 @@ const ListButton = ({ disabled }: Props): JSX.Element => {
100
101
  const type = parentList
101
102
  ? parentList.getListType()
102
103
  : element.getListType();
104
+ // @ts-expect-error - suppressing pre-existing type mismatch
103
105
  setElementList(type);
104
106
  }
105
107
  }, [editor]);
@@ -41,7 +41,9 @@ const Snackbar = forwardRef(
41
41
  ): JSX.Element => {
42
42
  const { classes } = useStyles();
43
43
  const { closeSnackbar } = useSnackbar();
44
- const timeoutId = useRef<NodeJS.Timeout | undefined>();
44
+ const timeoutId = useRef<ReturnType<typeof setTimeout> | undefined>(
45
+ undefined
46
+ );
45
47
 
46
48
  useEffect((): void => {
47
49
  timeoutId.current = setTimeout(() => {
@@ -1,14 +1,15 @@
1
- import { type ForwardedRef, forwardRef } from 'react';
1
+ import { forwardRef } from 'react';
2
2
 
3
3
  interface Props extends Record<string, unknown> {
4
- Content: (props) => JSX.Element;
4
+ Content: (props: Record<string, unknown>) => JSX.Element;
5
5
  isInDragOverlay?: boolean;
6
6
  }
7
7
 
8
- const Item = forwardRef(
9
- ({ Content, ...props }: Props, ref: ForwardedRef<HTMLDivElement>) => {
10
- return <Content {...props} itemRef={ref} />;
11
- }
12
- );
8
+ const Item = forwardRef<HTMLDivElement, Props>(({ Content, ...props }, ref) => {
9
+ const ContentComponent = Content as React.ComponentType<
10
+ Record<string, unknown>
11
+ >;
12
+ return <ContentComponent {...props} itemRef={ref} />;
13
+ });
13
14
 
14
15
  export default Item;
@@ -44,7 +44,7 @@ interface ContentProps {
44
44
  }
45
45
 
46
46
  export interface RootComponentProps {
47
- children: JSX.Element | null;
47
+ children: React.ReactNode;
48
48
  isInDragOverlay?: boolean;
49
49
  }
50
50
 
@@ -121,7 +121,9 @@ export const getTheme = (mode: ThemeMode): ThemeOptions => ({
121
121
  MuiChip: {
122
122
  styleOverrides: {
123
123
  root: ({ ownerState, theme }) => ({
124
- backgroundColor: !ownerState.color && theme.palette.divider,
124
+ backgroundColor: !ownerState.color
125
+ ? theme.palette.divider
126
+ : undefined,
125
127
  ...(equals(ownerState.size, 'medium') && {
126
128
  borderRadius: theme.spacing(1.25),
127
129
  fontSize: theme.typography.body2.fontSize,
@@ -179,7 +181,7 @@ export const getTheme = (mode: ThemeMode): ThemeOptions => ({
179
181
  MuiInputBase: {
180
182
  styleOverrides: {
181
183
  root: ({ ownerState, theme }) => ({
182
- ...getInputBaseInputStyle(ownerState),
184
+ ...(getInputBaseInputStyle(ownerState) as Record<string, unknown>),
183
185
  backgroundColor: theme.palette.background.paper
184
186
  })
185
187
  }
@@ -271,7 +273,7 @@ const ThemeProvider = ({ children, overrideTheme }: Props): JSX.Element => {
271
273
  return createTheme(
272
274
  mergeDeepRight(getTheme(themeMode || ThemeMode.light), {
273
275
  palette: overrideThemeByMode || {}
274
- })
276
+ }) as ThemeOptions
275
277
  );
276
278
  }, [themeMode, overrideTheme]);
277
279
 
@@ -3,6 +3,7 @@ import { Typography } from '@mui/material';
3
3
  import { LocalizationProvider } from '@mui/x-date-pickers';
4
4
  import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
5
5
 
6
+ import type { Dayjs } from 'dayjs';
6
7
  import dayjs from 'dayjs';
7
8
  import timezone from 'dayjs/plugin/timezone';
8
9
  import utc from 'dayjs/plugin/utc';
@@ -80,8 +81,8 @@ const PickerDateWithLabel = ({
80
81
  changeDate={changeDate}
81
82
  date={date}
82
83
  disabled={disabled}
83
- maxDate={maxDate}
84
- minDate={minDate}
84
+ maxDate={maxDate as (Date & Dayjs) | undefined}
85
+ minDate={minDate as (Date & Dayjs) | undefined}
85
86
  property={property}
86
87
  />
87
88
  </div>
@@ -85,7 +85,7 @@ const SelectedTimePeriod = ({
85
85
  }
86
86
  >
87
87
  {
88
- cond<number, string>([
88
+ cond<[number], string>([
89
89
  [lte(theme.breakpoints.values.md), always(largeName)],
90
90
  [T, always(name)]
91
91
  ])(width) as string
@@ -27,7 +27,7 @@ export const getNewCustomTimePeriod = ({
27
27
  .duration(dayjs(end).diff(dayjs(start)))
28
28
  .asDays();
29
29
 
30
- const timelineEventsLimit = cond<number, number>([
30
+ const timelineEventsLimit = cond<[number], number>([
31
31
  [gte(1), always(20)],
32
32
  [gte(7), always(100)],
33
33
  [T, always(500)]
@@ -12,7 +12,7 @@ const useSortTimePeriods = (
12
12
 
13
13
  const numberOfDays = dayjs.duration(dayjs(end).diff(dayjs(start))).asDays();
14
14
 
15
- const timelineEventsLimit = cond<number, number>([
15
+ const timelineEventsLimit = cond<[number], number>([
16
16
  [gte(1), always(20)],
17
17
  [gte(7), always(100)],
18
18
  [T, always(500)]
@@ -30,7 +30,9 @@ const Subtitle = ({ children, secondaryLabel }: Props): JSX.Element => {
30
30
  followCursor={false}
31
31
  label={
32
32
  containsSeveralSecondaryLabels
33
- ? secondaryLabel.map((label) => <p key={label}>{t(label)}</p>)
33
+ ? (secondaryLabel as Array<string>).map((label) => (
34
+ <p key={label}>{t(label)}</p>
35
+ ))
34
36
  : t(secondaryLabel)
35
37
  }
36
38
  placement="right"
@@ -5,6 +5,7 @@ import {
5
5
  CardHeader,
6
6
  Stack,
7
7
  Typography,
8
+ type TypographyVariant,
8
9
  useTheme
9
10
  } from '@mui/material';
10
11
 
@@ -29,7 +30,7 @@ const TypographyStory = (): JSX.Element => {
29
30
  const { classes } = useStyles();
30
31
  const { typography } = useTheme();
31
32
 
32
- const variants = [
33
+ const variants: Array<TypographyVariant> = [
33
34
  'h1',
34
35
  'h2',
35
36
  'h3',
@@ -77,7 +78,7 @@ const TypographyStory = (): JSX.Element => {
77
78
  {key}
78
79
  </Typography>
79
80
  <Typography color="text.secondary" variant="body2">
80
- {value}
81
+ {value as string}
81
82
  </Typography>
82
83
  </Box>
83
84
  ))}
@@ -45,7 +45,7 @@ const ActionsBar = ({
45
45
  direction="row"
46
46
  justifyContent="flex-end"
47
47
  >
48
- <Grid item>
48
+ <Grid>
49
49
  {!isFirstStep && (
50
50
  <Button
51
51
  aria-label={labelPrevious}
@@ -56,7 +56,7 @@ const ActionsBar = ({
56
56
  </Button>
57
57
  )}
58
58
  </Grid>
59
- <Grid item>
59
+ <Grid>
60
60
  <Button
61
61
  aria-label={labelNextFinish}
62
62
  color="primary"
@@ -8,8 +8,7 @@ export const client = new QueryClient({
8
8
  queries: {
9
9
  gcTime: defaultCacheTime,
10
10
  refetchOnWindowFocus: false,
11
- staleTime: defaultCacheTime,
12
- suspense: true
11
+ staleTime: defaultCacheTime
13
12
  }
14
13
  }
15
14
  });
@@ -110,14 +110,16 @@ const getConditionsSearchQueryParameterValue = (
110
110
  ];
111
111
  }
112
112
 
113
- return toPairs(values || {}).map(([operator, operatorValue]) => ({
113
+ return (toPairs as (obj: object) => Array<[string, unknown]>)(
114
+ values || {}
115
+ ).map(([operator, operatorValue]) => ({
114
116
  [listField]: {
115
117
  [operator]: operatorValue
116
118
  }
117
119
  }));
118
120
  })
119
121
  )
120
- };
122
+ } as { $or: Array<Record<string, unknown>> };
121
123
  };
122
124
 
123
125
  return {
@@ -183,7 +183,9 @@ const useGraphQuery = ({
183
183
  : data.current.metrics.filter(({ metric_id }) => {
184
184
  return pipe(
185
185
  pluck('excludedMetrics'),
186
- flatten,
186
+ flatten as unknown as (
187
+ list: Array<unknown>
188
+ ) => ReadonlyArray<number>,
187
189
  includes(metric_id),
188
190
  not
189
191
  )(metrics);
@@ -273,7 +275,7 @@ const useGraphQuery = ({
273
275
  base: data.current.base,
274
276
  title: ''
275
277
  },
276
- metrics: getFormattedMetrics(),
278
+ metrics: getFormattedMetrics() ?? [],
277
279
  times: data.current.times
278
280
  }
279
281
  : undefined;
@@ -129,7 +129,7 @@ const useMutationQuery = <T extends object, TMeta>({
129
129
  const listingQueryKey = getListingQueryKey();
130
130
  queryClient.setQueriesData(
131
131
  { queryKey: listingQueryKey },
132
- context.previousListing
132
+ (context as { previousListing: unknown })?.previousListing
133
133
  );
134
134
  }
135
135
 
@@ -150,7 +150,11 @@ const useMutationQuery = <T extends object, TMeta>({
150
150
  return { previousListing };
151
151
  }
152
152
  : onMutate,
153
- onSettled,
153
+ onSettled: onSettled as UseMutationOptions<
154
+ T | ResponseError,
155
+ ResponseError,
156
+ Variables<TMeta, T>
157
+ >['onSettled'],
154
158
  onSuccess: (data, variables, context) => {
155
159
  if (optimisticListing?.enabled) {
156
160
  const isQueryKeyArray = equals(
@@ -162,20 +166,20 @@ const useMutationQuery = <T extends object, TMeta>({
162
166
  : [optimisticListing?.queryKey];
163
167
 
164
168
  queryClient.invalidateQueries({
165
- queryKey: listingQueryKey
169
+ queryKey: listingQueryKey as Array<string>
166
170
  });
167
171
  }
168
172
 
169
- if (data?.isError) {
173
+ if ((data as ResponseError)?.isError) {
170
174
  if (optimisticListing?.enabled) {
171
175
  const listingQueryKey = getListingQueryKey();
172
176
  queryClient.setQueriesData(
173
177
  { queryKey: listingQueryKey },
174
- context.previousListing
178
+ (context as { previousListing: unknown })?.previousListing
175
179
  );
176
180
  }
177
181
 
178
- onError?.(data, variables, context);
182
+ onError?.(data as ResponseError, variables, context);
179
183
 
180
184
  return;
181
185
  }
@@ -209,7 +213,7 @@ const useMutationQuery = <T extends object, TMeta>({
209
213
  ...omit(['isError'], queryData),
210
214
  isError: (queryData.data as ResponseError | undefined)?.isError || false,
211
215
  isMutating: queryData.isPending
212
- };
216
+ } as unknown as UseMutationQueryState<T, TMeta>;
213
217
  };
214
218
 
215
219
  export default useMutationQuery;
@@ -5,8 +5,8 @@ import { Method } from '.';
5
5
 
6
6
  interface GetOptimisticMutationListingProps<T, TMeta> {
7
7
  method: Method;
8
- payload: T;
9
- _meta: TMeta;
8
+ payload: T | undefined;
9
+ _meta: TMeta | undefined;
10
10
  }
11
11
 
12
12
  export interface OptimisticListing {
@@ -39,7 +39,7 @@ export const useOptimisticMutation = <T, TMeta>({
39
39
  ? optimisticListing?.queryKey
40
40
  : [optimisticListing?.queryKey];
41
41
 
42
- return listingQueryKey;
42
+ return listingQueryKey as Array<string>;
43
43
  };
44
44
 
45
45
  const getPreviousListing = (): unknown => {
@@ -62,9 +62,12 @@ export const useOptimisticMutation = <T, TMeta>({
62
62
  const listingQueryKey = getListingQueryKey();
63
63
 
64
64
  const updatedPayload =
65
- payload && 'id' in payload
65
+ payload && 'id' in (payload as Record<string, unknown>)
66
66
  ? payload
67
- : { ...payload, id: (optimisticListing?.total ?? 0) + 1 };
67
+ : {
68
+ ...(payload as Record<string, unknown>),
69
+ id: (optimisticListing?.total ?? 0) + 1
70
+ };
68
71
 
69
72
  const hasOnlyOnePage =
70
73
  (optimisticListing?.total || 0) <= (optimisticListing?.limit || 0);
@@ -74,19 +77,22 @@ export const useOptimisticMutation = <T, TMeta>({
74
77
  queryClient.getQueriesData({
75
78
  queryKey: listingQueryKey
76
79
  })
77
- )?.[1];
80
+ )?.[1] as { result: Array<Record<string, unknown>> } | undefined;
78
81
 
79
82
  if (equals(Method.POST, method) && !isFormDataPayload && hasOnlyOnePage) {
80
- const newItems = append(updatedPayload, items.result);
83
+ const newItems = append(
84
+ updatedPayload as Record<string, unknown>,
85
+ items?.result ?? []
86
+ );
81
87
 
82
88
  return { ...items, result: newItems };
83
89
  }
84
90
 
85
91
  if (equals(Method.DELETE, method) && hasOnlyOnePage) {
86
- const itemIndex = items.result.findIndex(({ id }) =>
87
- equals(id, _meta.id)
92
+ const itemIndex = items?.result.findIndex(({ id }) =>
93
+ equals(id, (_meta as Record<string, unknown>)?.id)
88
94
  );
89
- const newItems = remove(itemIndex, 1, items.result);
95
+ const newItems = remove(itemIndex ?? 0, 1, items?.result ?? []);
90
96
 
91
97
  return { ...items, result: newItems };
92
98
  }
@@ -97,24 +103,36 @@ export const useOptimisticMutation = <T, TMeta>({
97
103
  (equals(Method.POST, method) && isFormDataPayload)) &&
98
104
  hasOnlyOnePage
99
105
  ) {
100
- const itemIndex = items.result.findIndex(({ id }) =>
101
- equals(id, _meta.id)
106
+ const itemIndex = items?.result.findIndex(({ id }) =>
107
+ equals(id, (_meta as Record<string, unknown>)?.id)
108
+ );
109
+ const item = items?.result.find(({ id }) =>
110
+ equals(id, (_meta as Record<string, unknown>)?.id)
102
111
  );
103
- const item = items.result.find(({ id }) => equals(id, _meta.id));
104
112
  const updatedItem = equals(Method.PUT, method)
105
113
  ? updatedPayload
106
114
  : {
107
115
  ...item,
108
116
  ...(isFormDataPayload
109
- ? Object.fromEntries(updatedPayload.entries())
117
+ ? (
118
+ Object as unknown as {
119
+ fromEntries: (
120
+ entries: IterableIterator<[string, FormDataEntryValue]>
121
+ ) => Record<string, unknown>;
122
+ }
123
+ ).fromEntries((updatedPayload as unknown as FormData).entries())
110
124
  : updatedPayload)
111
125
  };
112
- const newItems = update(itemIndex, updatedItem, items.result);
126
+ const newItems = update(
127
+ itemIndex ?? 0,
128
+ updatedItem as Record<string, unknown>,
129
+ items?.result ?? []
130
+ );
113
131
 
114
132
  return { ...items, result: newItems };
115
133
  }
116
134
 
117
- return items;
135
+ return items as object;
118
136
  };
119
137
  return { getListingQueryKey, getOptimisticMutationItems, getPreviousListing };
120
138
  };