@centreon/ui 26.5.14 → 26.5.15

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 (170) hide show
  1. package/package.json +6 -1
  2. package/src/ActionsList/ActionsList.styles.ts +2 -1
  3. package/src/ActionsList/index.tsx +1 -1
  4. package/src/Button/Icon/index.tsx +1 -1
  5. package/src/Button/Save/useSave.tsx +2 -1
  6. package/src/Checkbox/Checkbox.tsx +14 -9
  7. package/src/Checkbox/CheckboxGroup/index.tsx +1 -1
  8. package/src/Colors/index.tsx +12 -2
  9. package/src/Dashboard/Item.tsx +1 -1
  10. package/src/Dialog/Duplicate/index.tsx +5 -3
  11. package/src/Dialog/index.tsx +4 -1
  12. package/src/Form/Inputs/Autocomplete.tsx +30 -19
  13. package/src/Form/Inputs/ConnectedAutocomplete.tsx +27 -9
  14. package/src/Form/Inputs/FieldsTable/FieldsTable.tsx +24 -13
  15. package/src/Form/Inputs/FieldsTable/Row.tsx +7 -1
  16. package/src/Form/Inputs/List/Content.tsx +2 -2
  17. package/src/Form/Inputs/List/List.tsx +2 -1
  18. package/src/Form/Inputs/List/useList.ts +1 -1
  19. package/src/Form/Inputs/Radio.tsx +4 -1
  20. package/src/Form/Inputs/models.ts +42 -8
  21. package/src/Form/Section/PanelTabs.tsx +1 -1
  22. package/src/Form/storiesData.tsx +2 -2
  23. package/src/Graph/BarChart/Bar.tsx +39 -5
  24. package/src/Graph/BarChart/BarGroup.tsx +9 -5
  25. package/src/Graph/BarChart/BarStack.tsx +17 -4
  26. package/src/Graph/BarChart/useBarStack.ts +16 -8
  27. package/src/Graph/BarStack/Graph.tsx +21 -5
  28. package/src/Graph/BarStack/GraphAndLegend.tsx +2 -1
  29. package/src/Graph/BarStack/models.ts +23 -3
  30. package/src/Graph/BarStack/useGraphAndLegend.ts +10 -6
  31. package/src/Graph/BarStack/useResponsiveBarStack.ts +2 -1
  32. package/src/Graph/Chart/BasicComponents/Lines/Point.tsx +2 -1
  33. package/src/Graph/Chart/BasicComponents/Lines/RegularLines/index.tsx +4 -3
  34. package/src/Graph/Chart/BasicComponents/Lines/RegularLines/useRegularLines.ts +1 -1
  35. package/src/Graph/Chart/BasicComponents/Lines/StackedLines/index.tsx +4 -5
  36. package/src/Graph/Chart/BasicComponents/Lines/StackedLines/useStackedLines.ts +10 -1
  37. package/src/Graph/Chart/BasicComponents/Lines/Threshold/index.tsx +13 -4
  38. package/src/Graph/Chart/BasicComponents/Lines/Threshold/models.ts +2 -2
  39. package/src/Graph/Chart/BasicComponents/Lines/index.tsx +2 -10
  40. package/src/Graph/Chart/InteractiveComponents/AnchorPoint/StackedAnchorPoint.tsx +7 -3
  41. package/src/Graph/Chart/InteractiveComponents/AnchorPoint/models.ts +2 -2
  42. package/src/Graph/Chart/InteractiveComponents/AnchorPoint/useTickGraph.ts +4 -4
  43. package/src/Graph/Chart/InteractiveComponents/Annotations/Annotation/Area.tsx +9 -1
  44. package/src/Graph/Chart/InteractiveComponents/Annotations/Annotation/Line.tsx +9 -1
  45. package/src/Graph/Chart/InteractiveComponents/Annotations/EventAnnotations.tsx +9 -1
  46. package/src/Graph/Chart/InteractiveComponents/Annotations/useAnnotation.ts +1 -5
  47. package/src/Graph/Chart/InteractiveComponents/Tooltip/useGraphTooltip.ts +2 -2
  48. package/src/Graph/Chart/InteractiveComponents/index.tsx +8 -8
  49. package/src/Graph/Chart/Legend/LegendHeader.tsx +6 -1
  50. package/src/Graph/Chart/Legend/index.tsx +4 -1
  51. package/src/Graph/Chart/Legend/useLegend.ts +2 -2
  52. package/src/Graph/Chart/helpers/doc.ts +11 -1
  53. package/src/Graph/Chart/models.ts +2 -2
  54. package/src/Graph/Chart/useChartData.ts +4 -3
  55. package/src/Graph/Chart/useChartIntersection.ts +5 -1
  56. package/src/Graph/Gauge/AnimatedPie.tsx +7 -2
  57. package/src/Graph/Gauge/models.ts +7 -1
  58. package/src/Graph/PieChart/ResponsivePie.tsx +7 -1
  59. package/src/Graph/PieChart/models.ts +22 -3
  60. package/src/Graph/PieChart/useResponsivePie.ts +3 -2
  61. package/src/Graph/SingleBar/ThresholdLine.tsx +5 -1
  62. package/src/Graph/SingleBar/Thresholds.tsx +5 -1
  63. package/src/Graph/Timeline/ResponsiveTimeline.tsx +2 -2
  64. package/src/Graph/Timeline/useTimeline.ts +2 -1
  65. package/src/Graph/Tree/DescendantNodes.tsx +4 -3
  66. package/src/Graph/Tree/Tree.tsx +7 -1
  67. package/src/Graph/Tree/models.ts +2 -2
  68. package/src/Graph/common/Axes/UnitLabel.tsx +1 -1
  69. package/src/Graph/common/Axes/index.tsx +15 -6
  70. package/src/Graph/common/Axes/useAxisY.ts +3 -3
  71. package/src/Graph/common/BaseChart/AdditionalLine.tsx +2 -1
  72. package/src/Graph/common/BaseChart/ChartSvgWrapper.tsx +7 -3
  73. package/src/Graph/common/Grids/index.tsx +9 -3
  74. package/src/Graph/common/Thresholds/ThresholdLine.tsx +7 -1
  75. package/src/Graph/common/Thresholds/Thresholds.tsx +7 -1
  76. package/src/Graph/common/models.ts +9 -1
  77. package/src/Graph/common/timeSeries/index.test.ts +1 -1
  78. package/src/Graph/common/timeSeries/index.ts +72 -26
  79. package/src/Graph/common/timeSeries/models.ts +1 -1
  80. package/src/Graph/common/utils.ts +3 -1
  81. package/src/Image/useLoadImage.ts +6 -1
  82. package/src/InputField/Search/RegexpHelpTooltip.tsx +3 -1
  83. package/src/InputField/Select/Autocomplete/Connected/Multi/utils/index.ts +4 -1
  84. package/src/InputField/Select/Autocomplete/Connected/index.test.tsx +7 -2
  85. package/src/InputField/Select/Autocomplete/Connected/index.tsx +70 -26
  86. package/src/InputField/Select/Autocomplete/Draggable/SortableList.tsx +2 -2
  87. package/src/InputField/Select/Autocomplete/Draggable/SortableListContent.tsx +6 -4
  88. package/src/InputField/Select/Autocomplete/Draggable/index.tsx +35 -10
  89. package/src/InputField/Select/Autocomplete/Multi/Listbox.tsx +12 -2
  90. package/src/InputField/Select/Autocomplete/Multi/Multi.tsx +15 -8
  91. package/src/InputField/Select/Autocomplete/Popover/index.tsx +5 -2
  92. package/src/InputField/Select/Autocomplete/index.tsx +23 -10
  93. package/src/InputField/Select/IconPopover/index.tsx +8 -5
  94. package/src/InputField/Select/index.tsx +4 -3
  95. package/src/InputField/Text/index.tsx +1 -1
  96. package/src/InputField/Text/useAutoSize.ts +0 -2
  97. package/src/Listing/ActionBar/ColumnMultiSelect.tsx +2 -2
  98. package/src/Listing/ActionBar/Pagination.tsx +4 -2
  99. package/src/Listing/ActionBar/PaginationActions.tsx +12 -4
  100. package/src/Listing/ActionBar/index.tsx +19 -7
  101. package/src/Listing/Cell/DataCell.tsx +3 -3
  102. package/src/Listing/Cell/index.tsx +26 -13
  103. package/src/Listing/Header/Cell/ListingHeaderCell.tsx +2 -2
  104. package/src/Listing/Header/Cell/SelectActionListingHeaderCell.tsx +6 -4
  105. package/src/Listing/Header/ListingHeader.tsx +2 -2
  106. package/src/Listing/Header/_internals/PredefinedSelectionList.tsx +3 -1
  107. package/src/Listing/Row/Row.tsx +3 -3
  108. package/src/Listing/index.tsx +48 -28
  109. package/src/Listing/models.ts +11 -9
  110. package/src/MultiSelectEntries/index.tsx +3 -3
  111. package/src/Pagination/Pagination.tsx +3 -1
  112. package/src/Panel/index.tsx +2 -2
  113. package/src/PopoverMenu/index.tsx +3 -3
  114. package/src/RichTextEditor/ContentEditable.tsx +2 -1
  115. package/src/RichTextEditor/RichTextEditor.tsx +1 -1
  116. package/src/RichTextEditor/plugins/FloatingLinkEditorPlugin.tsx +16 -14
  117. package/src/RichTextEditor/plugins/ToolbarPlugin/BlockButtons.tsx +3 -3
  118. package/src/RichTextEditor/plugins/ToolbarPlugin/ListButton.tsx +1 -1
  119. package/src/RichTextEditor/plugins/ToolbarPlugin/MacrosButton.tsx +1 -1
  120. package/src/Snackbar/SnackbarProvider.tsx +1 -1
  121. package/src/Snackbar/index.tsx +4 -2
  122. package/src/Snackbar/useSnackbar.tsx +14 -4
  123. package/src/SortableItems/index.tsx +4 -4
  124. package/src/TimePeriods/CustomTimePeriod/CompactCustomTimePeriod.tsx +1 -1
  125. package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/models.ts +1 -1
  126. package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/usePickersStartEndDate.ts +9 -3
  127. package/src/TimePeriods/CustomTimePeriod/index.tsx +7 -2
  128. package/src/TimePeriods/helpers/index.ts +7 -2
  129. package/src/TimePeriods/models.ts +4 -1
  130. package/src/TimePeriods/useTimePeriod.ts +0 -2
  131. package/src/Wizard/ActionsBar.tsx +1 -1
  132. package/src/Wizard/index.test.tsx +0 -66
  133. package/src/Wizard/index.tsx +10 -5
  134. package/src/Wizard/models.ts +1 -1
  135. package/src/api/buildListingEndpoint/getSearchQueryParameterValue.ts +2 -1
  136. package/src/api/buildListingEndpoint/index.ts +7 -1
  137. package/src/api/customFetch.ts +3 -3
  138. package/src/api/useBulkResponse.ts +31 -9
  139. package/src/api/useFetchQuery/index.ts +28 -6
  140. package/src/api/useGraphQuery/index.ts +1 -1
  141. package/src/api/useRequest/index.ts +7 -7
  142. package/src/components/Button/Button.tsx +1 -1
  143. package/src/components/Button/Icon/IconButton.tsx +1 -1
  144. package/src/components/CrudPage/Listing.tsx +3 -3
  145. package/src/components/CrudPage/utils.ts +1 -1
  146. package/src/components/Form/AccessRights/AccessRights.tsx +4 -1
  147. package/src/components/Form/AccessRights/Actions/Actions.tsx +4 -1
  148. package/src/components/Form/AccessRights/ShareInput/ShareInput.tsx +1 -1
  149. package/src/components/Form/AccessRights/ShareInput/useShareInput.tsx +35 -13
  150. package/src/components/Form/AccessRights/common/RoleSelectField.tsx +1 -1
  151. package/src/components/Form/AccessRights/storiesData.ts +2 -2
  152. package/src/components/ItemComposition/ItemComposition.tsx +1 -1
  153. package/src/components/Menu/Button/MenuButton.tsx +1 -1
  154. package/src/components/Menu/useMenu.tsx +3 -1
  155. package/src/components/Tabs/Tabs.tsx +1 -1
  156. package/src/components/Tooltip/ConfirmationTooltip/models.ts +5 -1
  157. package/src/components/Zoom/useMinimap.ts +16 -10
  158. package/src/components/Zoom/useZoom.ts +12 -6
  159. package/src/components/Zoom/utils.ts +3 -1
  160. package/src/queryParameters/index.ts +8 -2
  161. package/src/utils/resourcesStatusURL.ts +20 -3
  162. package/src/utils/translatedLabel.ts +4 -2
  163. package/src/utils/useDebounce.ts +10 -9
  164. package/src/utils/useInfiniteScrollListing.ts +2 -2
  165. package/src/utils/useIntersectionObserver.ts +2 -2
  166. package/src/utils/useLicenseExpirationWarning.test.tsx +4 -2
  167. package/src/utils/useLoadImage.tsx +7 -2
  168. package/src/utils/useLocaleDateTimeFormat/index.test.tsx +2 -3
  169. package/src/utils/useLocaleDateTimeFormat/localeFallback.test.tsx +2 -3
  170. package/test/testRenderer.tsx +9 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centreon/ui",
3
- "version": "26.5.14",
3
+ "version": "26.5.15",
4
4
  "description": "Centreon UI Components",
5
5
  "scripts": {
6
6
  "update:deps": "pnpx npm-check-updates -i --format group",
@@ -85,10 +85,15 @@
85
85
  "@testing-library/jest-dom": "^6.6.3",
86
86
  "@testing-library/react": "^16.2.0",
87
87
  "@testing-library/react-hooks": "^8.0.1",
88
+ "@types/humanize-duration": "^3.27.4",
88
89
  "@types/jest": "^29.5.14",
89
90
  "@types/mocha": "^10.0.10",
91
+ "@types/numeral": "^2.0.5",
90
92
  "@types/ramda": "^0.30.2",
91
93
  "@types/react": "^19.0.10",
94
+ "@types/react-dom": "^19.2.3",
95
+ "@types/react-transition-group": "^4.4.12",
96
+ "@types/sanitize-html": "^2.16.1",
92
97
  "@types/testing-library__jest-dom": "^6.0.0",
93
98
  "@vitejs/plugin-react": "^4.3.4",
94
99
  "@vitejs/plugin-react-swc": "^3.8.0",
@@ -11,7 +11,8 @@ interface GetBackgroundAndColorProps {
11
11
  const getColor = ({ theme, status }: GetBackgroundAndColorProps): string =>
12
12
  equals(theme.palette.mode, 'dark')
13
13
  ? theme.palette.common.white
14
- : theme.palette[status].main;
14
+ : (theme.palette[status as keyof Theme['palette']] as { main: string })
15
+ .main;
15
16
 
16
17
  export const useStyles = makeStyles()((theme) => ({
17
18
  item: {
@@ -20,7 +20,7 @@ interface ActionsType {
20
20
  muiName: string;
21
21
  };
22
22
  label: string;
23
- onClick?: (e?) => void;
23
+ onClick?: (e?: React.MouseEvent) => void;
24
24
  secondaryLabel?: string;
25
25
  variant?: ActionVariants;
26
26
  }
@@ -21,7 +21,7 @@ type Props = {
21
21
  ariaLabel?: string;
22
22
  dataTestid?: string;
23
23
  className?: string;
24
- onClick: (event) => void;
24
+ onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
25
25
  title?: string | JSX.Element;
26
26
  tooltipClassName?: string;
27
27
  tooltipPlacement?:
@@ -25,7 +25,8 @@ interface StartIconConfigProps {
25
25
  enabled: boolean;
26
26
  }
27
27
 
28
- const isNilOrEmpty = (value): boolean => or(isNil(value), isEmpty(value));
28
+ const isNilOrEmpty = (value: unknown): boolean =>
29
+ or(isNil(value), isEmpty(value));
29
30
  const hasValue = any(pipe(isNilOrEmpty, not));
30
31
 
31
32
  interface UseSaveState {
@@ -1,8 +1,12 @@
1
1
  import type { SvgIconComponent } from '@mui/icons-material';
2
- import { Box, FormControlLabel, Checkbox as MuiCheckbox } from '@mui/material';
2
+ import {
3
+ Box,
4
+ FormControlLabel,
5
+ Checkbox as MuiCheckbox,
6
+ type Theme
7
+ } from '@mui/material';
3
8
  import Typography, { type TypographyProps } from '@mui/material/Typography';
4
9
 
5
- import { always, cond, equals, T } from 'ramda';
6
10
  import { makeStyles } from 'tss-react/mui';
7
11
 
8
12
  export type LabelPlacement = 'bottom' | 'top' | 'end' | 'start' | undefined;
@@ -12,12 +16,13 @@ interface StyleProps {
12
16
  labelPlacement: LabelPlacement;
13
17
  }
14
18
 
15
- const getLabelSpacing = (labelPlacement, theme): string => {
16
- return cond([
17
- [equals('top'), always(theme.spacing(0, 0, 0.5))],
18
- [equals('end'), always(theme.spacing(0, 0, 0, 0.5))],
19
- [T, always(0)]
20
- ])(labelPlacement);
19
+ const getLabelSpacing = (
20
+ labelPlacement: LabelPlacement,
21
+ theme: Theme
22
+ ): string => {
23
+ if (labelPlacement === 'top') return theme.spacing(0, 0, 0.5);
24
+ if (labelPlacement === 'end') return theme.spacing(0, 0, 0, 0.5);
25
+ return '0';
21
26
  };
22
27
 
23
28
  const useStyles = makeStyles<StyleProps>()(
@@ -58,7 +63,7 @@ interface Props {
58
63
  id: string;
59
64
  labelPlacement?: LabelPlacement;
60
65
  labelProps?: TypographyProps;
61
- onChange?: (e) => void;
66
+ onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
62
67
  }
63
68
 
64
69
  const Checkbox = ({
@@ -15,7 +15,7 @@ interface Props {
15
15
  formGroupProps?: FormGroupProps;
16
16
  labelPlacement?: LabelPlacement;
17
17
  labelProps?: TypographyProps;
18
- onChange?: (e) => void;
18
+ onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
19
19
  options: Array<string>;
20
20
  values: Array<string>;
21
21
  }
@@ -1,4 +1,12 @@
1
- import { Box, Divider, Grid, Stack, Typography, useTheme } from '@mui/material';
1
+ import {
2
+ Box,
3
+ Divider,
4
+ Grid,
5
+ Stack,
6
+ type Theme,
7
+ Typography,
8
+ useTheme
9
+ } from '@mui/material';
2
10
 
3
11
  import type { ThemeMode } from '@centreon/ui-context';
4
12
 
@@ -52,7 +60,9 @@ const ContainerDescription = ({
52
60
  <Box sx={{ width: '100%' }}>
53
61
  <Typography variant="h4">{containerTitle}</Typography>
54
62
  <Grid columnSpacing={{ md: 3, sm: 2, xs: 1 }} container rowSpacing={5}>
55
- {toPairs(palette[keyTheme]).map(
63
+ {toPairs(
64
+ palette[keyTheme as keyof Theme['palette']] as Record<string, string>
65
+ ).map(
56
66
  ([key, value]) =>
57
67
  !includes(key, keysToRemove) && (
58
68
  <Grid key={key} size={6}>
@@ -30,7 +30,7 @@ interface DashboardItemProps {
30
30
  id: string;
31
31
  onMouseDown?: (e: MouseEvent<HTMLDivElement>) => void;
32
32
  onMouseUp?: (e: MouseEvent<HTMLDivElement>) => void;
33
- onTouchEnd?: (e) => void;
33
+ onTouchEnd?: (e: React.TouchEvent<HTMLDivElement>) => void;
34
34
  style?: CSSProperties;
35
35
  ref?: RefObject<HTMLDivElement>;
36
36
  }
@@ -26,13 +26,15 @@ const Duplicate = ({
26
26
  ...rest
27
27
  }: Props): JSX.Element => {
28
28
  const { classes } = useStyles();
29
- const [value, setValue] = useState(1);
29
+ const [value, setValue] = useState<string | number>(1);
30
30
 
31
- const handleChange = ({ target }): void => {
31
+ const handleChange = ({
32
+ target
33
+ }: React.ChangeEvent<HTMLInputElement>): void => {
32
34
  setValue(target.value);
33
35
  };
34
36
 
35
- const handleConfirm = (event): void => {
37
+ const handleConfirm = (event: React.MouseEvent<HTMLButtonElement>): void => {
36
38
  onConfirm(event, value);
37
39
  };
38
40
 
@@ -48,7 +48,10 @@ export type Props = {
48
48
  labelTitle?: ReactNode;
49
49
  onCancel?: () => void;
50
50
  onClose?: () => void;
51
- onConfirm: (event, value?) => void;
51
+ onConfirm: (
52
+ event: React.MouseEvent<HTMLButtonElement>,
53
+ value?: unknown
54
+ ) => void;
52
55
  open: boolean;
53
56
  restCancelButtonProps?: ButtonProps;
54
57
  restConfirmButtonProps?: ButtonProps;
@@ -12,28 +12,37 @@ import { useMemoComponent } from '../../utils';
12
12
  import { labelPressEnterToAccept } from '../translatedLabels';
13
13
  import { type InputPropsWithoutGroup, InputType } from './models';
14
14
 
15
+ interface NormalizeNewValuesProps {
16
+ isCreatable?: boolean;
17
+ isMultiple: boolean;
18
+ newValues: SelectEntry | Array<SelectEntry | string> | null;
19
+ }
20
+
15
21
  const normalizeNewValues = ({
16
22
  newValues,
17
23
  isMultiple,
18
24
  isCreatable
19
- }): SelectEntry | Array<string | SelectEntry> => {
25
+ }: NormalizeNewValuesProps): SelectEntry | Array<string | SelectEntry> => {
20
26
  const isSingle = not(isMultiple);
21
27
  if (isSingle) {
22
- return newValues;
28
+ return newValues as SelectEntry;
23
29
  }
24
30
 
25
- return map((newValue: SelectEntry | string) => {
26
- const isManualValue = equals(type(newValue), 'String');
27
- if (isCreatable && isManualValue) {
28
- return newValue;
29
- }
31
+ return map(
32
+ (newValue: SelectEntry | string) => {
33
+ const isManualValue = equals(type(newValue), 'String');
34
+ if (isCreatable && isManualValue) {
35
+ return newValue;
36
+ }
30
37
 
31
- if (isCreatable) {
32
- return prop('name', newValue as SelectEntry);
33
- }
38
+ if (isCreatable) {
39
+ return prop('name', newValue as SelectEntry);
40
+ }
34
41
 
35
- return newValue;
36
- }, newValues);
42
+ return newValue;
43
+ },
44
+ newValues as Array<SelectEntry | string>
45
+ );
37
46
  };
38
47
 
39
48
  const Autocomplete = ({
@@ -63,7 +72,10 @@ const Autocomplete = ({
63
72
 
64
73
  const isMultiple = equals(inputType, InputType.MultiAutocomplete);
65
74
 
66
- const changeValues = (_, newValues): void => {
75
+ const changeValues = (
76
+ _: React.SyntheticEvent,
77
+ newValues: SelectEntry | Array<SelectEntry | string> | null
78
+ ): void => {
67
79
  const normalizedNewValues = normalizeNewValues({
68
80
  isCreatable,
69
81
  isMultiple,
@@ -116,7 +128,7 @@ const Autocomplete = ({
116
128
  return undefined;
117
129
  }
118
130
 
119
- return `${selectedValues?.[index]}: ${errorText}`;
131
+ return `${(selectedValues as Array<SelectEntry> | undefined)?.[index]}: ${errorText}`;
120
132
  }
121
133
  );
122
134
 
@@ -133,7 +145,8 @@ const Autocomplete = ({
133
145
  }, [errors, fieldName, isMultiple, selectedValues, touched]);
134
146
 
135
147
  const textChange = useCallback(
136
- (event): void => setInputText(event.target.value),
148
+ (event: React.ChangeEvent<HTMLInputElement>): void =>
149
+ setInputText(event.target.value),
137
150
  []
138
151
  );
139
152
 
@@ -143,9 +156,7 @@ const Autocomplete = ({
143
156
  | undefined => {
144
157
  if (isMultiple && isCreatable) {
145
158
  return equals(type(selectedValues), 'Array')
146
- ? (
147
- selectedValues as Array<SelectEntry> | Array<string> | undefined
148
- )?.map((value) => ({
159
+ ? (selectedValues as Array<string> | undefined)?.map((value) => ({
149
160
  id: value,
150
161
  name: value
151
162
  }))
@@ -179,7 +190,7 @@ const Autocomplete = ({
179
190
  equals(option, selectedValue)
180
191
  }
181
192
  label={`${t(label)}${additionalLabel}`}
182
- onChange={changeValues}
193
+ onChange={changeValues as never}
183
194
  onTextChange={textChange}
184
195
  open={isCreatable ? false : undefined}
185
196
  options={autocomplete?.options || []}
@@ -8,6 +8,8 @@ import {
8
8
  SingleConnectedAutocompleteField,
9
9
  useMemoComponent
10
10
  } from '../..';
11
+ import type { SelectEntry } from '../../InputField/Select';
12
+ import type { GetEndpointParams } from '../../InputField/Select/Autocomplete/Connected';
11
13
  import MultiConnectedAutocompleteField from '../../InputField/Select/Autocomplete/Connected/Multi';
12
14
  import { InputPropsWithoutGroup, InputType } from './models';
13
15
 
@@ -42,13 +44,15 @@ const ConnectedAutocomplete = ({
42
44
 
43
45
  const isMultiple = equals(type, InputType.MultiConnectedAutocomplete);
44
46
 
45
- const getEndpoint = (parameters): string => {
47
+ const getEndpoint = (parameters: GetEndpointParams): string => {
46
48
  const nameQueryParameters =
47
49
  connectedAutocomplete?.useNewAPIFormat && parameters?.search
48
50
  ? [
49
51
  {
50
52
  name: 'name[lk]',
51
- value: parameters.search.conditions[0].values.$lk.slice(1, -1)
53
+ value: (
54
+ parameters.search.conditions?.[0].values?.$lk as string
55
+ ).slice(1, -1)
52
56
  }
53
57
  ]
54
58
  : [];
@@ -79,7 +83,13 @@ const ConnectedAutocomplete = ({
79
83
  const fieldNamePath = split('.', fieldName);
80
84
 
81
85
  const changeAutocomplete = useCallback(
82
- (_, value): void => {
86
+ (
87
+ _: React.SyntheticEvent,
88
+ value:
89
+ | NonNullable<string | SelectEntry>
90
+ | Array<string | SelectEntry>
91
+ | null
92
+ ): void => {
83
93
  if (change) {
84
94
  change({
85
95
  setFieldTouched,
@@ -102,10 +112,13 @@ const ConnectedAutocomplete = ({
102
112
  const blur = (): void => void setFieldTouched(fieldName, true);
103
113
 
104
114
  const isOptionEqualToValue = useCallback(
105
- (option, value): boolean => {
115
+ (option: SelectEntry, value: SelectEntry): boolean => {
106
116
  return isEmpty(value)
107
117
  ? false
108
- : equals(option[filterKey], value[filterKey]);
118
+ : equals(
119
+ option[filterKey as keyof SelectEntry],
120
+ value[filterKey as keyof SelectEntry]
121
+ );
109
122
  },
110
123
  [filterKey]
111
124
  );
@@ -116,7 +129,7 @@ const ConnectedAutocomplete = ({
116
129
  | undefined;
117
130
 
118
131
  const error = path(fieldNamePath, touched)
119
- ? path(fieldNamePath, errors)
132
+ ? (path(fieldNamePath, errors) as string | undefined)
120
133
  : undefined;
121
134
 
122
135
  const disabled = getDisabled?.(values) || false;
@@ -130,10 +143,10 @@ const ConnectedAutocomplete = ({
130
143
  [isMultiple]
131
144
  );
132
145
 
133
- const deleteItem = (_, option): void => {
146
+ const deleteItem = (_: React.SyntheticEvent, option: SelectEntry): void => {
134
147
  const newValue = reject(
135
148
  propEq(option.id, 'id'),
136
- (value ?? []) as Array<Record<string, unknown>>
149
+ (value ?? []) as Array<unknown> as Array<{ id: string | number }>
137
150
  );
138
151
 
139
152
  setFieldTouched(fieldName, true, false);
@@ -145,9 +158,14 @@ const ConnectedAutocomplete = ({
145
158
  onDelete: deleteItem
146
159
  };
147
160
 
161
+ const TypedAutocompleteField =
162
+ AutocompleteField as unknown as React.ComponentType<
163
+ Record<string, unknown>
164
+ >;
165
+
148
166
  return useMemoComponent({
149
167
  Component: (
150
- <AutocompleteField
168
+ <TypedAutocompleteField
151
169
  chipProps={chipProps}
152
170
  dataTestId={dataTestId}
153
171
  decoder={connectedAutocomplete?.decoder}
@@ -93,12 +93,12 @@ interface Entity extends FieldsTableContextProps {
93
93
  }
94
94
 
95
95
  interface ContentProps extends Entity {
96
- attributes;
96
+ attributes: Record<string, unknown>;
97
97
  index: number;
98
98
  isDragging: boolean;
99
99
  itemRef: React.RefObject<HTMLDivElement>;
100
100
  listeners: DraggableSyntheticListeners;
101
- style;
101
+ style: React.CSSProperties;
102
102
  }
103
103
 
104
104
  const SortableRow = ({
@@ -269,25 +269,36 @@ const FieldsTable = ({
269
269
  }
270
270
  }, [fieldsTable, values, getSortableDefined]);
271
271
 
272
- const updatePriorities = (items): Array<unknown> =>
273
- items.reduce((acc, curr, index) => {
274
- const row = acc[curr];
275
-
276
- if (isNil(row)) {
277
- return acc;
278
- }
272
+ const updatePriorities = (items: Array<string>): Array<unknown> =>
273
+ items.reduce(
274
+ (
275
+ acc: Array<TableRowValue>,
276
+ curr: string,
277
+ index: number
278
+ ): Array<TableRowValue> => {
279
+ const row = acc[Number(curr)];
280
+
281
+ if (isNil(row)) {
282
+ return acc;
283
+ }
279
284
 
280
- (row as Record<string, unknown>).priority = index;
285
+ (row as Record<string, unknown>).priority = index;
281
286
 
282
- return acc;
283
- }, clone(tableValues));
287
+ return acc;
288
+ },
289
+ clone(tableValues)
290
+ );
284
291
 
285
292
  const dragEnd = ({ items }: DragEnd): void => {
286
293
  const updatedPriorities = updatePriorities(items);
287
294
  setFieldValue(fieldName, updatedPriorities);
288
295
  };
289
296
 
290
- const disableOverItemSortableCondition = ({ id }): boolean =>
297
+ const disableOverItemSortableCondition = ({
298
+ id
299
+ }: {
300
+ id: number | string;
301
+ }): boolean =>
291
302
  Number(id) === tableValues.length || not(isNil(fieldsTableError));
292
303
 
293
304
  return useMemoComponent({
@@ -88,7 +88,13 @@ const Row = ({
88
88
  setFieldValue(tableFieldName, remove(index, 1, tableValues));
89
89
  };
90
90
 
91
- const changeRow = ({ property, value }): void => {
91
+ const changeRow = ({
92
+ property,
93
+ value
94
+ }: {
95
+ property: string;
96
+ value: unknown;
97
+ }): void => {
92
98
  const currentRowValue = rowValues || defaultRowValue;
93
99
 
94
100
  setFieldValue(
@@ -8,7 +8,7 @@ import { IconButton } from '../../../components';
8
8
  import { useListStyles } from './List.styles';
9
9
 
10
10
  export interface ContentProps {
11
- attributes;
11
+ attributes: Record<string, unknown>;
12
12
  children: ReactNode;
13
13
  deleteItem: (id: string) => () => void;
14
14
  id: string;
@@ -17,7 +17,7 @@ export interface ContentProps {
17
17
  itemRef: React.RefObject<HTMLDivElement>;
18
18
  listeners: DraggableSyntheticListeners;
19
19
  name: string;
20
- style;
20
+ style: React.CSSProperties;
21
21
  }
22
22
 
23
23
  const Content = ({
@@ -3,6 +3,7 @@ import { verticalListSortingStrategy } from '@dnd-kit/sortable';
3
3
  import type { ComponentType } from 'react';
4
4
  import { useTranslation } from 'react-i18next';
5
5
 
6
+ import type { SelectEntry } from '../../..';
6
7
  import { SortableItems, Subtitle } from '../../..';
7
8
  import type { InputPropsWithoutGroup } from '../models';
8
9
  import Content, { type ContentProps } from './Content';
@@ -19,7 +20,7 @@ const List = ({
19
20
  const { addItem, sortList, sortedList, deleteItem } = useList({ fieldName });
20
21
 
21
22
  const { AddItem, addItemLabel, sortLabel, SortContent, itemProps } = list as {
22
- AddItem: ComponentType<{ addItem }>;
23
+ AddItem: ComponentType<{ addItem: (newItem: SelectEntry) => void }>;
23
24
  SortContent: ComponentType;
24
25
  addItemLabel?: string;
25
26
  itemProps: Array<string>;
@@ -20,7 +20,7 @@ interface UseListState {
20
20
  sortedList: Array<unknown>;
21
21
  }
22
22
 
23
- export const useList = ({ fieldName }): UseListState => {
23
+ export const useList = ({ fieldName }: { fieldName: string }): UseListState => {
24
24
  const { values, setFieldValue } = useFormikContext<FormikValues>();
25
25
  const maxOrder = useRef(0);
26
26
 
@@ -28,7 +28,10 @@ const Radio = ({
28
28
  const { values, setFieldValue, setFieldTouched, setValues, setTouched } =
29
29
  useFormikContext<FormikValues>();
30
30
 
31
- const changeRadio = (_, value): void => {
31
+ const changeRadio = (
32
+ _: React.ChangeEvent<HTMLInputElement>,
33
+ value: string
34
+ ): void => {
32
35
  if (includes(value, ['true', 'false'])) {
33
36
  if (change) {
34
37
  change({
@@ -1,11 +1,39 @@
1
1
  import type { SvgIconProps, TypographyProps } from '@mui/material';
2
2
 
3
- import type { FormikValues } from 'formik';
3
+ import type { FormikErrors, FormikTouched, FormikValues } from 'formik';
4
+ import type { JsonDecoder } from 'ts.data.json';
4
5
 
5
6
  import type { ConditionsSearchParameter } from '../../api/buildListingEndpoint/models';
6
7
  import type { SelectEntry } from '../../InputField/Select';
7
8
  import type { QueryParameter } from '../../queryParameters/models';
8
9
 
10
+ export interface ChangeArgs {
11
+ setFieldValue: (
12
+ field: string,
13
+ value: unknown,
14
+ shouldValidate?: boolean
15
+ // biome-ignore lint/suspicious/noConfusingVoidType: matches Formik's type signature
16
+ ) => Promise<void | FormikErrors<FormikValues>>;
17
+ setFieldTouched: (
18
+ field: string,
19
+ isTouched?: boolean,
20
+ shouldValidate?: boolean
21
+ // biome-ignore lint/suspicious/noConfusingVoidType: matches Formik's type signature
22
+ ) => Promise<void | FormikErrors<FormikValues>>;
23
+ setValues: (
24
+ values: React.SetStateAction<FormikValues>,
25
+ shouldValidate?: boolean
26
+ // biome-ignore lint/suspicious/noConfusingVoidType: matches Formik's type signature
27
+ ) => Promise<void | FormikErrors<FormikValues>>;
28
+ setTouched: (
29
+ touched: FormikTouched<FormikValues>,
30
+ shouldValidate?: boolean
31
+ // biome-ignore lint/suspicious/noConfusingVoidType: matches Formik's type signature
32
+ ) => Promise<void | FormikErrors<FormikValues>>;
33
+ value: unknown;
34
+ values: FormikValues;
35
+ }
36
+
9
37
  export enum InputType {
10
38
  Switch = 0,
11
39
  Radio = 1,
@@ -49,7 +77,7 @@ export interface InputProps {
49
77
  setValues,
50
78
  values,
51
79
  setTouched
52
- }) => void;
80
+ }: ChangeArgs) => void;
53
81
  checkbox?: {
54
82
  direction?: 'horizontal' | 'vertical';
55
83
  labelPlacement?: LabelPlacement;
@@ -62,19 +90,23 @@ export interface InputProps {
62
90
  chipColor?: string;
63
91
  endpoint?: string;
64
92
  filterKey?: string;
65
- getRenderedOptionText?: (option) => string | JSX.Element;
66
- getOptionLabel?: (option) => string;
93
+ getRenderedOptionText?: (option: { name: string }) => string | JSX.Element;
94
+ getOptionLabel?: (option: string | SelectEntry) => string;
67
95
  helperText?: string;
68
96
  optionProperty?: string;
69
97
  disableSelectAll?: boolean;
70
98
  limitTags?: number;
71
- decoder?;
99
+ decoder?: JsonDecoder.Decoder<unknown>;
72
100
  };
73
101
  file?: {
74
102
  multiple?: boolean;
75
103
  accept?: string;
76
104
  maxFileSize?: number;
77
- CustomDropZoneContent: ({ files }) => JSX.Element;
105
+ CustomDropZoneContent: ({
106
+ files
107
+ }: {
108
+ files: FileList | null;
109
+ }) => JSX.Element;
78
110
  };
79
111
  custom?: {
80
112
  Component: React.ComponentType<InputPropsWithoutGroup>;
@@ -105,7 +137,9 @@ export interface InputProps {
105
137
  inputClassName?: string;
106
138
  label: string;
107
139
  list?: {
108
- AddItem: React.ComponentType<{ addItem }>;
140
+ AddItem: React.ComponentType<{
141
+ addItem: (newItem: SelectEntry) => void;
142
+ }>;
109
143
  SortContent: React.ComponentType<object>;
110
144
  addItemLabel?: string;
111
145
  itemProps: Array<string>;
@@ -120,7 +154,7 @@ export interface InputProps {
120
154
  };
121
155
  required?: boolean;
122
156
  switchInput?: {
123
- getChecked?: (value) => boolean;
157
+ getChecked?: (value: unknown) => boolean;
124
158
  };
125
159
  text?: {
126
160
  endAdornment?: JSX.Element;
@@ -1,6 +1,6 @@
1
1
  import { prop, sortBy } from 'ramda';
2
- import type { TabI } from 'src/components/Tabs/Tabs';
3
2
 
3
+ import type { TabI } from '../../components/Tabs/Tabs';
4
4
  import type { Group } from '../Inputs/models';
5
5
 
6
6
  const groupToTab = (groups?: Array<Group>): Array<TabI> => {
@@ -483,7 +483,7 @@ export const CustomButton = (): JSX.Element => {
483
483
  );
484
484
  };
485
485
 
486
- const buildEntities = (from): Array<SelectEntry> => {
486
+ const buildEntities = (from: number): Array<SelectEntry> => {
487
487
  return Array(10)
488
488
  .fill(0)
489
489
  .map((_, index) => ({
@@ -492,7 +492,7 @@ const buildEntities = (from): Array<SelectEntry> => {
492
492
  }));
493
493
  };
494
494
 
495
- export const buildResult = (page): Listing<SelectEntry> => ({
495
+ export const buildResult = (page: number): Listing<SelectEntry> => ({
496
496
  meta: {
497
497
  limit: 10,
498
498
  page,