@centreon/ui 23.10.32-MON-19938-cloud-notifications-fix-search-select-boxes.3 → 23.10.33
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
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCallback, useMemo
|
|
1
|
+
import { useCallback, useMemo } from 'react';
|
|
2
2
|
|
|
3
3
|
import { FormikValues, useFormikContext } from 'formik';
|
|
4
4
|
import { equals, isEmpty, path, split } from 'ramda';
|
|
@@ -11,12 +11,7 @@ import {
|
|
|
11
11
|
} from '../..';
|
|
12
12
|
import MultiConnectedAutocompleteField from '../../InputField/Select/Autocomplete/Connected/Multi';
|
|
13
13
|
|
|
14
|
-
import {
|
|
15
|
-
AutoCompleteChangeData,
|
|
16
|
-
InputPropsWithoutGroup,
|
|
17
|
-
InputType,
|
|
18
|
-
Reason
|
|
19
|
-
} from './models';
|
|
14
|
+
import { InputPropsWithoutGroup, InputType } from './models';
|
|
20
15
|
|
|
21
16
|
const defaultFilterKey = 'name';
|
|
22
17
|
|
|
@@ -34,8 +29,6 @@ const ConnectedAutocomplete = ({
|
|
|
34
29
|
}: InputPropsWithoutGroup): JSX.Element => {
|
|
35
30
|
const { t } = useTranslation();
|
|
36
31
|
|
|
37
|
-
const [autocompleteChangeData, setAutocompleteChangeData] =
|
|
38
|
-
useState<AutoCompleteChangeData>();
|
|
39
32
|
const { values, touched, errors, setFieldValue, setFieldTouched } =
|
|
40
33
|
useFormikContext<FormikValues>();
|
|
41
34
|
|
|
@@ -62,9 +55,7 @@ const ConnectedAutocomplete = ({
|
|
|
62
55
|
const fieldNamePath = split('.', fieldName);
|
|
63
56
|
|
|
64
57
|
const changeAutocomplete = useCallback(
|
|
65
|
-
(_, value
|
|
66
|
-
setAutocompleteChangeData({ reason, value });
|
|
67
|
-
|
|
58
|
+
(_, value): void => {
|
|
68
59
|
if (change) {
|
|
69
60
|
change({ setFieldValue, value });
|
|
70
61
|
|
|
@@ -113,7 +104,6 @@ const ConnectedAutocomplete = ({
|
|
|
113
104
|
return useMemoComponent({
|
|
114
105
|
Component: (
|
|
115
106
|
<AutocompleteField
|
|
116
|
-
autocompleteChangeData={autocompleteChangeData}
|
|
117
107
|
dataTestId={dataTestId}
|
|
118
108
|
disableClearable={false}
|
|
119
109
|
disabled={disabled}
|
|
@@ -103,16 +103,3 @@ export interface Group {
|
|
|
103
103
|
name: string;
|
|
104
104
|
order: number;
|
|
105
105
|
}
|
|
106
|
-
|
|
107
|
-
export enum Reason {
|
|
108
|
-
blur = 'blur',
|
|
109
|
-
clear = 'clear',
|
|
110
|
-
createOption = 'createOption',
|
|
111
|
-
removeOption = 'removeOption',
|
|
112
|
-
selectOption = 'selectOption'
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export interface AutoCompleteChangeData {
|
|
116
|
-
reason: Reason;
|
|
117
|
-
value: string;
|
|
118
|
-
}
|
|
@@ -28,10 +28,8 @@ import {
|
|
|
28
28
|
SearchParameter
|
|
29
29
|
} from '../../../../api/buildListingEndpoint/models';
|
|
30
30
|
import useFetchQuery from '../../../../api/useFetchQuery';
|
|
31
|
-
import { AutoCompleteChangeData } from '../../../../Form/Inputs/models';
|
|
32
31
|
|
|
33
32
|
export interface ConnectedAutoCompleteFieldProps<TData> {
|
|
34
|
-
autocompleteChangeData?: AutoCompleteChangeData;
|
|
35
33
|
conditionField?: keyof SelectEntry;
|
|
36
34
|
field: string;
|
|
37
35
|
getEndpoint: ({ search, page }) => string;
|
|
@@ -57,7 +55,6 @@ const ConnectedAutocompleteField = (
|
|
|
57
55
|
getRenderedOptionText = (option): string => option.name?.toString(),
|
|
58
56
|
getRequestHeaders,
|
|
59
57
|
displayOptionThumbnail,
|
|
60
|
-
autocompleteChangeData,
|
|
61
58
|
...props
|
|
62
59
|
}: ConnectedAutoCompleteFieldProps<TData> &
|
|
63
60
|
Omit<AutocompleteFieldProps, 'options'>): JSX.Element => {
|
|
@@ -277,13 +274,6 @@ const ConnectedAutocompleteField = (
|
|
|
277
274
|
);
|
|
278
275
|
}, useDeepCompare([searchConditions]));
|
|
279
276
|
|
|
280
|
-
useEffect(() => {
|
|
281
|
-
if (!autocompleteChangeData) {
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
setSearchParameter(undefined);
|
|
285
|
-
}, [autocompleteChangeData?.reason, autocompleteChangeData?.value]);
|
|
286
|
-
|
|
287
277
|
useEffect(() => {
|
|
288
278
|
if (!optionsOpen) {
|
|
289
279
|
return;
|