@redneckz/wildless-cms-uni-blocks 0.14.575 → 0.14.576
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/bundle/api/LeadServiceAPI.d.ts +0 -12
- package/bundle/api/dadataHints/dadataHints.d.ts +2 -0
- package/bundle/api/dadataHints/dadataHintsType.d.ts +27 -0
- package/bundle/api/dadataHints/hintsListsOptions.d.ts +33 -0
- package/bundle/blocks.schema.json +1 -1
- package/bundle/bundle.umd.js +151 -38
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/components/ApplicationForm/ApplicationFormContent.d.ts +1 -0
- package/bundle/components/ApplicationLeadForm/ApplicationLeadFormContent.d.ts +1 -0
- package/bundle/index.d.ts +0 -1
- package/bundle/ui-kit/FormField/Fields/EmailField.d.ts +2 -0
- package/bundle/ui-kit/Input/InputPopup.d.ts +7 -0
- package/bundle/ui-kit/Input/InputProps.d.ts +1 -0
- package/bundle/ui-kit/Input/useInputPopup.d.ts +10 -0
- package/dist/api/LeadServiceAPI.d.ts +0 -12
- package/dist/api/LeadServiceAPI.js.map +1 -1
- package/dist/api/dadataHints/dadataHints.d.ts +2 -0
- package/dist/api/dadataHints/dadataHints.js +30 -0
- package/dist/api/dadataHints/dadataHints.js.map +1 -0
- package/dist/api/dadataHints/dadataHintsType.d.ts +27 -0
- package/dist/api/dadataHints/dadataHintsType.js +2 -0
- package/dist/api/dadataHints/dadataHintsType.js.map +1 -0
- package/dist/api/dadataHints/hintsListsOptions.d.ts +33 -0
- package/dist/api/dadataHints/hintsListsOptions.js +33 -0
- package/dist/api/dadataHints/hintsListsOptions.js.map +1 -0
- package/dist/components/ApplicationForm/ApplicationFormContent.d.ts +1 -0
- package/dist/components/ApplicationLeadForm/ApplicationLeadFormContent.d.ts +1 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/dist/ui-kit/FormField/Fields/EmailField.d.ts +2 -0
- package/dist/ui-kit/FormField/Fields/EmailField.js +12 -0
- package/dist/ui-kit/FormField/Fields/EmailField.js.map +1 -0
- package/dist/ui-kit/FormField/Fields/MiddleNameField.js +1 -1
- package/dist/ui-kit/FormField/Fields/MiddleNameField.js.map +1 -1
- package/dist/ui-kit/FormField/Fields/SurnameField.js +1 -1
- package/dist/ui-kit/FormField/Fields/SurnameField.js.map +1 -1
- package/dist/ui-kit/FormField/getField.js +3 -2
- package/dist/ui-kit/FormField/getField.js.map +1 -1
- package/dist/ui-kit/Input/InputControl.js +17 -1
- package/dist/ui-kit/Input/InputControl.js.map +1 -1
- package/dist/ui-kit/Input/InputPopup.d.ts +7 -0
- package/dist/ui-kit/Input/InputPopup.js +6 -0
- package/dist/ui-kit/Input/InputPopup.js.map +1 -0
- package/dist/ui-kit/Input/InputProps.d.ts +1 -0
- package/dist/ui-kit/Input/useInputPopup.d.ts +10 -0
- package/dist/ui-kit/Input/useInputPopup.js +62 -0
- package/dist/ui-kit/Input/useInputPopup.js.map +1 -0
- package/lib/api/LeadServiceAPI.d.ts +0 -12
- package/lib/api/LeadServiceAPI.js.map +1 -1
- package/lib/api/dadataHints/dadataHints.d.ts +2 -0
- package/lib/api/dadataHints/dadataHints.js +27 -0
- package/lib/api/dadataHints/dadataHints.js.map +1 -0
- package/lib/api/dadataHints/dadataHintsType.d.ts +27 -0
- package/lib/api/dadataHints/dadataHintsType.js +2 -0
- package/lib/api/dadataHints/dadataHintsType.js.map +1 -0
- package/lib/api/dadataHints/hintsListsOptions.d.ts +33 -0
- package/lib/api/dadataHints/hintsListsOptions.js +31 -0
- package/lib/api/dadataHints/hintsListsOptions.js.map +1 -0
- package/lib/common.css +1 -1
- package/lib/components/ApplicationForm/ApplicationFormContent.d.ts +1 -0
- package/lib/components/ApplicationLeadForm/ApplicationLeadFormContent.d.ts +1 -0
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/index.js.map +1 -1
- package/lib/ui-kit/FormField/Fields/EmailField.d.ts +2 -0
- package/lib/ui-kit/FormField/Fields/EmailField.js +10 -0
- package/lib/ui-kit/FormField/Fields/EmailField.js.map +1 -0
- package/lib/ui-kit/FormField/Fields/MiddleNameField.js +1 -1
- package/lib/ui-kit/FormField/Fields/MiddleNameField.js.map +1 -1
- package/lib/ui-kit/FormField/Fields/SurnameField.js +1 -1
- package/lib/ui-kit/FormField/Fields/SurnameField.js.map +1 -1
- package/lib/ui-kit/FormField/getField.js +3 -2
- package/lib/ui-kit/FormField/getField.js.map +1 -1
- package/lib/ui-kit/Input/InputControl.js +17 -1
- package/lib/ui-kit/Input/InputControl.js.map +1 -1
- package/lib/ui-kit/Input/InputPopup.d.ts +7 -0
- package/lib/ui-kit/Input/InputPopup.js +4 -0
- package/lib/ui-kit/Input/InputPopup.js.map +1 -0
- package/lib/ui-kit/Input/InputProps.d.ts +1 -0
- package/lib/ui-kit/Input/useInputPopup.d.ts +10 -0
- package/lib/ui-kit/Input/useInputPopup.js +59 -0
- package/lib/ui-kit/Input/useInputPopup.js.map +1 -0
- package/mobile/bundle/api/LeadServiceAPI.d.ts +0 -12
- package/mobile/bundle/api/dadataHints/dadataHints.d.ts +2 -0
- package/mobile/bundle/api/dadataHints/dadataHintsType.d.ts +27 -0
- package/mobile/bundle/api/dadataHints/hintsListsOptions.d.ts +33 -0
- package/mobile/bundle/bundle.umd.js +151 -38
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/components/ApplicationForm/ApplicationFormContent.d.ts +1 -0
- package/mobile/bundle/components/ApplicationLeadForm/ApplicationLeadFormContent.d.ts +1 -0
- package/mobile/bundle/index.d.ts +0 -1
- package/mobile/bundle/ui-kit/FormField/Fields/EmailField.d.ts +2 -0
- package/mobile/bundle/ui-kit/Input/InputPopup.d.ts +7 -0
- package/mobile/bundle/ui-kit/Input/InputProps.d.ts +1 -0
- package/mobile/bundle/ui-kit/Input/useInputPopup.d.ts +10 -0
- package/mobile/dist/api/LeadServiceAPI.d.ts +0 -12
- package/mobile/dist/api/LeadServiceAPI.js.map +1 -1
- package/mobile/dist/api/dadataHints/dadataHints.d.ts +2 -0
- package/mobile/dist/api/dadataHints/dadataHints.js +30 -0
- package/mobile/dist/api/dadataHints/dadataHints.js.map +1 -0
- package/mobile/dist/api/dadataHints/dadataHintsType.d.ts +27 -0
- package/mobile/dist/api/dadataHints/dadataHintsType.js +2 -0
- package/mobile/dist/api/dadataHints/dadataHintsType.js.map +1 -0
- package/mobile/dist/api/dadataHints/hintsListsOptions.d.ts +33 -0
- package/mobile/dist/api/dadataHints/hintsListsOptions.js +33 -0
- package/mobile/dist/api/dadataHints/hintsListsOptions.js.map +1 -0
- package/mobile/dist/components/ApplicationForm/ApplicationFormContent.d.ts +1 -0
- package/mobile/dist/components/ApplicationLeadForm/ApplicationLeadFormContent.d.ts +1 -0
- package/mobile/dist/index.d.ts +0 -1
- package/mobile/dist/index.js +1 -3
- package/mobile/dist/index.js.map +1 -1
- package/mobile/dist/ui-kit/FormField/Fields/EmailField.d.ts +2 -0
- package/mobile/dist/ui-kit/FormField/Fields/EmailField.js +12 -0
- package/mobile/dist/ui-kit/FormField/Fields/EmailField.js.map +1 -0
- package/mobile/dist/ui-kit/FormField/Fields/MiddleNameField.js +1 -1
- package/mobile/dist/ui-kit/FormField/Fields/MiddleNameField.js.map +1 -1
- package/mobile/dist/ui-kit/FormField/Fields/SurnameField.js +1 -1
- package/mobile/dist/ui-kit/FormField/Fields/SurnameField.js.map +1 -1
- package/mobile/dist/ui-kit/FormField/getField.js +3 -2
- package/mobile/dist/ui-kit/FormField/getField.js.map +1 -1
- package/mobile/dist/ui-kit/Input/InputControl.js +17 -1
- package/mobile/dist/ui-kit/Input/InputControl.js.map +1 -1
- package/mobile/dist/ui-kit/Input/InputPopup.d.ts +7 -0
- package/mobile/dist/ui-kit/Input/InputPopup.js +6 -0
- package/mobile/dist/ui-kit/Input/InputPopup.js.map +1 -0
- package/mobile/dist/ui-kit/Input/InputProps.d.ts +1 -0
- package/mobile/dist/ui-kit/Input/useInputPopup.d.ts +10 -0
- package/mobile/dist/ui-kit/Input/useInputPopup.js +62 -0
- package/mobile/dist/ui-kit/Input/useInputPopup.js.map +1 -0
- package/mobile/lib/api/LeadServiceAPI.d.ts +0 -12
- package/mobile/lib/api/LeadServiceAPI.js.map +1 -1
- package/mobile/lib/api/dadataHints/dadataHints.d.ts +2 -0
- package/mobile/lib/api/dadataHints/dadataHints.js +27 -0
- package/mobile/lib/api/dadataHints/dadataHints.js.map +1 -0
- package/mobile/lib/api/dadataHints/dadataHintsType.d.ts +27 -0
- package/mobile/lib/api/dadataHints/dadataHintsType.js +2 -0
- package/mobile/lib/api/dadataHints/dadataHintsType.js.map +1 -0
- package/mobile/lib/api/dadataHints/hintsListsOptions.d.ts +33 -0
- package/mobile/lib/api/dadataHints/hintsListsOptions.js +31 -0
- package/mobile/lib/api/dadataHints/hintsListsOptions.js.map +1 -0
- package/mobile/lib/common.css +1 -1
- package/mobile/lib/components/ApplicationForm/ApplicationFormContent.d.ts +1 -0
- package/mobile/lib/components/ApplicationLeadForm/ApplicationLeadFormContent.d.ts +1 -0
- package/mobile/lib/index.d.ts +0 -1
- package/mobile/lib/index.js +0 -1
- package/mobile/lib/index.js.map +1 -1
- package/mobile/lib/ui-kit/FormField/Fields/EmailField.d.ts +2 -0
- package/mobile/lib/ui-kit/FormField/Fields/EmailField.js +10 -0
- package/mobile/lib/ui-kit/FormField/Fields/EmailField.js.map +1 -0
- package/mobile/lib/ui-kit/FormField/Fields/MiddleNameField.js +1 -1
- package/mobile/lib/ui-kit/FormField/Fields/MiddleNameField.js.map +1 -1
- package/mobile/lib/ui-kit/FormField/Fields/SurnameField.js +1 -1
- package/mobile/lib/ui-kit/FormField/Fields/SurnameField.js.map +1 -1
- package/mobile/lib/ui-kit/FormField/getField.js +3 -2
- package/mobile/lib/ui-kit/FormField/getField.js.map +1 -1
- package/mobile/lib/ui-kit/Input/InputControl.js +17 -1
- package/mobile/lib/ui-kit/Input/InputControl.js.map +1 -1
- package/mobile/lib/ui-kit/Input/InputPopup.d.ts +7 -0
- package/mobile/lib/ui-kit/Input/InputPopup.js +4 -0
- package/mobile/lib/ui-kit/Input/InputPopup.js.map +1 -0
- package/mobile/lib/ui-kit/Input/InputProps.d.ts +1 -0
- package/mobile/lib/ui-kit/Input/useInputPopup.d.ts +10 -0
- package/mobile/lib/ui-kit/Input/useInputPopup.js +59 -0
- package/mobile/lib/ui-kit/Input/useInputPopup.js.map +1 -0
- package/mobile/src/api/LeadServiceAPI.ts +0 -14
- package/mobile/src/api/dadataHints/dadataHints.ts +33 -0
- package/mobile/src/api/dadataHints/dadataHintsType.ts +33 -0
- package/mobile/src/api/dadataHints/hintsListsOptions.ts +44 -0
- package/mobile/src/components/ApplicationForm/ApplicationFormContent.ts +1 -0
- package/mobile/src/components/ApplicationLeadForm/ApplicationLeadFormContent.ts +1 -0
- package/mobile/src/index.ts +0 -1
- package/mobile/src/ui-kit/FormField/Fields/EmailField.tsx +18 -0
- package/mobile/src/ui-kit/FormField/Fields/MiddleNameField.tsx +2 -2
- package/mobile/src/ui-kit/FormField/Fields/SurnameField.tsx +1 -0
- package/mobile/src/ui-kit/FormField/getField.tsx +3 -8
- package/mobile/src/ui-kit/Input/InputControl.tsx +48 -18
- package/mobile/src/ui-kit/Input/InputPopup.tsx +26 -0
- package/mobile/src/ui-kit/Input/InputProps.ts +1 -0
- package/mobile/src/ui-kit/Input/useInputPopup.tsx +85 -0
- package/package.json +2 -2
- package/src/api/LeadServiceAPI.ts +0 -14
- package/src/api/dadataHints/dadataHints.ts +33 -0
- package/src/api/dadataHints/dadataHintsType.ts +33 -0
- package/src/api/dadataHints/hintsListsOptions.ts +44 -0
- package/src/components/ApplicationForm/ApplicationFormContent.ts +1 -0
- package/src/components/ApplicationLeadForm/ApplicationLeadForm.fixture.tsx +4 -4
- package/src/components/ApplicationLeadForm/ApplicationLeadFormContent.ts +1 -0
- package/src/index.ts +0 -1
- package/src/ui-kit/FormField/Fields/EmailField.tsx +18 -0
- package/src/ui-kit/FormField/Fields/MiddleNameField.tsx +2 -2
- package/src/ui-kit/FormField/Fields/SurnameField.tsx +1 -0
- package/src/ui-kit/FormField/getField.tsx +3 -8
- package/src/ui-kit/Input/InputControl.tsx +48 -18
- package/src/ui-kit/Input/InputPopup.tsx +26 -0
- package/src/ui-kit/Input/InputProps.ts +1 -0
- package/src/ui-kit/Input/useInputPopup.tsx +85 -0
- package/bundle/api/DaDataAPI.d.ts +0 -15
- package/dist/api/DaDataAPI.d.ts +0 -15
- package/dist/api/DaDataAPI.js +0 -33
- package/dist/api/DaDataAPI.js.map +0 -1
- package/lib/api/DaDataAPI.d.ts +0 -15
- package/lib/api/DaDataAPI.js +0 -30
- package/lib/api/DaDataAPI.js.map +0 -1
- package/mobile/bundle/api/DaDataAPI.d.ts +0 -15
- package/mobile/dist/api/DaDataAPI.d.ts +0 -15
- package/mobile/dist/api/DaDataAPI.js +0 -33
- package/mobile/dist/api/DaDataAPI.js.map +0 -1
- package/mobile/lib/api/DaDataAPI.d.ts +0 -15
- package/mobile/lib/api/DaDataAPI.js +0 -30
- package/mobile/lib/api/DaDataAPI.js.map +0 -1
- package/mobile/src/api/DaDataAPI.ts +0 -48
- package/src/api/DaDataAPI.ts +0 -48
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@redneckz/uni-jsx/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
3
|
+
import { getDaDataHints } from '../../api/dadataHints/dadataHints.js';
|
|
4
|
+
import { hintsListsOptions } from '../../api/dadataHints/hintsListsOptions.js';
|
|
5
|
+
import { debounce } from '../../utils/debounce.js';
|
|
6
|
+
import { usePopupManager } from '../PopupManager/usePopupManager.js';
|
|
7
|
+
import { InputPopup } from './InputPopup.js';
|
|
8
|
+
export function useInputPopup({ isOpen, value, name, onChange }) {
|
|
9
|
+
const prevInputValue = useRef(value);
|
|
10
|
+
const currentInputValue = useRef(value);
|
|
11
|
+
const [hintsList, setHintsList] = useState([]);
|
|
12
|
+
const popup = usePopupManager();
|
|
13
|
+
const defaultHintsListOptions = hintsListsOptions[name];
|
|
14
|
+
const close = useCallback(() => {
|
|
15
|
+
currentInputValue.current = value;
|
|
16
|
+
popup.close();
|
|
17
|
+
}, [value]);
|
|
18
|
+
const handleChange = useCallback((option) => {
|
|
19
|
+
close();
|
|
20
|
+
currentInputValue.current = option;
|
|
21
|
+
onChange && onChange(option);
|
|
22
|
+
}, [close, onChange]);
|
|
23
|
+
const inputRef = useRef(null);
|
|
24
|
+
const getHintsList = useMemo(() => async (searchValue) => {
|
|
25
|
+
if (!defaultHintsListOptions) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const result = await getDaDataHints({
|
|
29
|
+
url: defaultHintsListOptions.url,
|
|
30
|
+
requestData: {
|
|
31
|
+
...defaultHintsListOptions?.requestData,
|
|
32
|
+
},
|
|
33
|
+
query: searchValue,
|
|
34
|
+
});
|
|
35
|
+
if (result?.length) {
|
|
36
|
+
setHintsList(result);
|
|
37
|
+
}
|
|
38
|
+
}, []);
|
|
39
|
+
const debouncedGetHintsList = useMemo(() => debounce(getHintsList, 300), [getHintsList]);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (!isOpen || !inputRef.current || currentInputValue.current === value) {
|
|
42
|
+
close();
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const inputElement = inputRef.current;
|
|
46
|
+
const { top, left, width, height } = inputElement.getBoundingClientRect();
|
|
47
|
+
if (value && prevInputValue.current !== value) {
|
|
48
|
+
debouncedGetHintsList(value);
|
|
49
|
+
prevInputValue.current = value;
|
|
50
|
+
}
|
|
51
|
+
popup.update(_jsx(InputPopup, { options: hintsList, value: value, onChange: handleChange }), {
|
|
52
|
+
top: top + globalThis.scrollY + height,
|
|
53
|
+
left,
|
|
54
|
+
width,
|
|
55
|
+
});
|
|
56
|
+
}, [isOpen, hintsList, value, handleChange]);
|
|
57
|
+
return inputRef;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=useInputPopup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useInputPopup.js","sourceRoot":"","sources":["../../../src/ui-kit/Input/useInputPopup.tsx"],"names":[],"mappings":"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"}
|
|
@@ -2,20 +2,6 @@ import { type JSONRecord, type JSONScalar } from '@redneckz/json-op';
|
|
|
2
2
|
import { formatDate } from '../utils/formatDate';
|
|
3
3
|
import { formatPhone } from '../utils/formatPhone';
|
|
4
4
|
|
|
5
|
-
interface DaDataSuggestion<T> {
|
|
6
|
-
value?: string;
|
|
7
|
-
unrestricted_value?: string;
|
|
8
|
-
data?: T;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface DaDataAddress {
|
|
12
|
-
city?: string | null;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface DaDataResult {
|
|
16
|
-
suggestions?: DaDataSuggestion<DaDataAddress>[];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
5
|
export type LeadRequest = Record<string, JSONRecord | JSONScalar | null> & {
|
|
20
6
|
typeForm?: string;
|
|
21
7
|
addressBranch?: string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type DaDataSuggestion, type ListRequestOption } from './dadataHintsType';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_HINTS_COUNT = 10;
|
|
4
|
+
|
|
5
|
+
const getResponseHandler = (response: { suggestions: Array<DaDataSuggestion> }) => {
|
|
6
|
+
const responseData: Array<DaDataSuggestion> = response?.suggestions || [];
|
|
7
|
+
|
|
8
|
+
return responseData.map((item) => ({
|
|
9
|
+
...item,
|
|
10
|
+
processedValue: item?.value,
|
|
11
|
+
}));
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const getDaDataHints = (options: ListRequestOption): Promise<Array<DaDataSuggestion>> => {
|
|
15
|
+
const { url, query, requestData = {} } = options;
|
|
16
|
+
|
|
17
|
+
const result = fetch(`/api/v1/suggestions/${url}`, {
|
|
18
|
+
method: 'POST',
|
|
19
|
+
mode: 'cors',
|
|
20
|
+
headers: {
|
|
21
|
+
'Content-Type': 'application/json',
|
|
22
|
+
},
|
|
23
|
+
body: JSON.stringify({
|
|
24
|
+
count: DEFAULT_HINTS_COUNT,
|
|
25
|
+
...requestData,
|
|
26
|
+
query,
|
|
27
|
+
}),
|
|
28
|
+
})
|
|
29
|
+
.then((response) => response.json())
|
|
30
|
+
.then(getResponseHandler);
|
|
31
|
+
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type Nullable } from '../../utils/Nullable';
|
|
2
|
+
import { type HintOption } from './hintsListsOptions';
|
|
3
|
+
|
|
4
|
+
export interface DaDataSuggestion {
|
|
5
|
+
value: string;
|
|
6
|
+
unrestricted_value: string;
|
|
7
|
+
data: DaDataResponseItem;
|
|
8
|
+
processedValue: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type DaDataGender = 'MALE' | 'FEMALE' | 'UNKNOWN';
|
|
12
|
+
|
|
13
|
+
export interface DaDataFio {
|
|
14
|
+
surname: Nullable<string>;
|
|
15
|
+
name: Nullable<string>;
|
|
16
|
+
patronymic: Nullable<string>;
|
|
17
|
+
gender: DaDataGender;
|
|
18
|
+
qc: '0' | '1';
|
|
19
|
+
source: null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface DaDataEmail {
|
|
23
|
+
domain: Nullable<string>;
|
|
24
|
+
local: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type DaDataResponseItem = DaDataFio | DaDataEmail;
|
|
28
|
+
|
|
29
|
+
export interface ListRequestOption {
|
|
30
|
+
url: string;
|
|
31
|
+
query?: string;
|
|
32
|
+
requestData?: HintOption['requestData'];
|
|
33
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export const NAME_HINTS_LIST_OPTIONS = {
|
|
2
|
+
url: 'suggest/fio',
|
|
3
|
+
requestData: {
|
|
4
|
+
parts: ['NAME'],
|
|
5
|
+
gender: 'UNKNOWN',
|
|
6
|
+
},
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const SURNAME_HINTS_LIST_OPTIONS = {
|
|
10
|
+
url: 'suggest/fio',
|
|
11
|
+
requestData: {
|
|
12
|
+
parts: ['SURNAME'],
|
|
13
|
+
gender: 'UNKNOWN',
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const PATRONYMIC_HINTS_LIST_OPTIONS = {
|
|
18
|
+
url: 'suggest/fio',
|
|
19
|
+
requestData: {
|
|
20
|
+
parts: ['PATRONYMIC'],
|
|
21
|
+
gender: 'UNKNOWN',
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const EMAIL_HINTS_LIST_OPTIONS = {
|
|
26
|
+
url: 'suggest/email',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type HintsListOptions = Record<string, HintOption>;
|
|
30
|
+
|
|
31
|
+
export const hintsListsOptions: HintsListOptions = {
|
|
32
|
+
name: NAME_HINTS_LIST_OPTIONS,
|
|
33
|
+
surname: SURNAME_HINTS_LIST_OPTIONS,
|
|
34
|
+
middleName: PATRONYMIC_HINTS_LIST_OPTIONS,
|
|
35
|
+
email: EMAIL_HINTS_LIST_OPTIONS,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type HintOption = {
|
|
39
|
+
url: string;
|
|
40
|
+
requestData?: {
|
|
41
|
+
parts?: string[];
|
|
42
|
+
gender?: string;
|
|
43
|
+
};
|
|
44
|
+
};
|
package/mobile/src/index.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { setupHooks } from '@redneckz/uni-jsx/lib/hooks';
|
|
2
2
|
export { setup } from '@redneckz/uni-jsx/lib/setup';
|
|
3
|
-
export { DaDataAPI } from './api/DaDataAPI';
|
|
4
3
|
export { Blocks } from './components/Blocks';
|
|
5
4
|
export { ContentPage } from './components/ContentPage/ContentPage';
|
|
6
5
|
export { handlerDecorator } from './hooks/handlerDecorator';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
+
import { type FieldDef } from '../../../components/ApplicationForm/ApplicationFormContent';
|
|
3
|
+
import { InputControl } from '../../Input/InputControl';
|
|
4
|
+
import { type CustomFieldProps } from '../CustomFieldProps';
|
|
5
|
+
import { validatorObj } from '../getObjectValidator';
|
|
6
|
+
import { getValidation } from '../getValidation';
|
|
7
|
+
|
|
8
|
+
export const EmailField = JSX<CustomFieldProps>(({ field, input }) => {
|
|
9
|
+
const { required, ...rest } = input as FieldDef;
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<InputControl
|
|
13
|
+
label="Электронная почта"
|
|
14
|
+
{...getValidation(field('email'), validatorObj.email, required)}
|
|
15
|
+
{...rest}
|
|
16
|
+
/>
|
|
17
|
+
);
|
|
18
|
+
});
|
|
@@ -2,6 +2,6 @@ import { JSX } from '@redneckz/uni-jsx';
|
|
|
2
2
|
import { InputControl } from '../../Input/InputControl';
|
|
3
3
|
import { type CustomFieldProps } from '../CustomFieldProps';
|
|
4
4
|
|
|
5
|
-
export const MiddleNameField = JSX<CustomFieldProps>(({ field }) => (
|
|
6
|
-
<InputControl label="Отчество (Обязательно, при наличии)" {...field('middleName')} />
|
|
5
|
+
export const MiddleNameField = JSX<CustomFieldProps>(({ field, input }) => (
|
|
6
|
+
<InputControl label="Отчество (Обязательно, при наличии)" {...field('middleName')} {...input} />
|
|
7
7
|
));
|
|
@@ -14,6 +14,7 @@ import { ConsentInformField } from './Fields/ConsentInformField';
|
|
|
14
14
|
import { ConsentPhotoFlg } from './Fields/ConsentPhotoField';
|
|
15
15
|
import { ConsentProviderField } from './Fields/ConsentProviderField';
|
|
16
16
|
import { ConsentToReceiveMaterialsField } from './Fields/ConsentToReceiveMaterialsField';
|
|
17
|
+
import { EmailField } from './Fields/EmailField';
|
|
17
18
|
import { FeedbackMethodField } from './Fields/FeedbackMethodField';
|
|
18
19
|
import { FeedbackTypeField } from './Fields/FeedbackTypeField';
|
|
19
20
|
import { IsClientField } from './Fields/IsClientField';
|
|
@@ -51,15 +52,9 @@ export const getField =
|
|
|
51
52
|
const InputsMap = {
|
|
52
53
|
surname: <SurnameField field={field} input={input} />,
|
|
53
54
|
name: <NameField field={field} input={input} />,
|
|
54
|
-
middleName: <MiddleNameField field={field} />,
|
|
55
|
+
middleName: <MiddleNameField field={field} input={input} />,
|
|
55
56
|
phone: <PhoneField field={field} input={input} />,
|
|
56
|
-
email:
|
|
57
|
-
<InputControl
|
|
58
|
-
label="Электронная почта"
|
|
59
|
-
{...getValidation(field('email'), validatorObj.email, required)}
|
|
60
|
-
{...rest}
|
|
61
|
-
/>
|
|
62
|
-
),
|
|
57
|
+
email: <EmailField field={field} input={input} />,
|
|
63
58
|
fullName: (
|
|
64
59
|
<InputControl
|
|
65
60
|
label="ФИО"
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
+
import { useBool } from '@redneckz/uni-jsx/lib/hooks/useBool';
|
|
3
|
+
import { useOutsideClick } from '@redneckz/uni-jsx/lib/hooks/useOutsideClick';
|
|
4
|
+
import { noop } from '../../utils/noop';
|
|
2
5
|
import { style } from '../../utils/style';
|
|
3
6
|
import { Input } from './Input';
|
|
4
7
|
import { type InputProps } from './InputProps';
|
|
5
8
|
import { renderErrorText } from './renderErrorText';
|
|
9
|
+
import { useInputPopup } from './useInputPopup';
|
|
6
10
|
|
|
7
11
|
export const InputControl = JSX<InputProps>(
|
|
8
12
|
({
|
|
@@ -11,25 +15,51 @@ export const InputControl = JSX<InputProps>(
|
|
|
11
15
|
value = '',
|
|
12
16
|
placeholder,
|
|
13
17
|
error,
|
|
14
|
-
|
|
18
|
+
errors,
|
|
19
|
+
onChange = noop,
|
|
15
20
|
onBlur,
|
|
16
21
|
isTextarea,
|
|
17
22
|
type,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
name = '',
|
|
24
|
+
dadata = false,
|
|
25
|
+
}) => {
|
|
26
|
+
const [isOpen, { setFalse: close, setTrue: open }] = useBool();
|
|
27
|
+
const popupRef = useOutsideClick<HTMLDivElement>(close);
|
|
28
|
+
|
|
29
|
+
const inputRef = useInputPopup({
|
|
30
|
+
isOpen: isOpen && dadata,
|
|
31
|
+
name,
|
|
32
|
+
value,
|
|
33
|
+
onChange,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<div
|
|
38
|
+
className={style('shrink-0 w-full', className)}
|
|
39
|
+
ref={popupRef}
|
|
40
|
+
onBlur={close}
|
|
41
|
+
onFocus={open}
|
|
42
|
+
>
|
|
43
|
+
<div ref={inputRef}>
|
|
44
|
+
<Input
|
|
45
|
+
type={type || 'text'}
|
|
46
|
+
aria-label={label}
|
|
47
|
+
label={getLabel(errors, label)}
|
|
48
|
+
valid={Boolean(!error)}
|
|
49
|
+
value={value}
|
|
50
|
+
onChange={onChange}
|
|
51
|
+
onBlur={onBlur}
|
|
52
|
+
isTextarea={isTextarea}
|
|
53
|
+
placeholder={getPlaceholder(placeholder, errors, label)}
|
|
54
|
+
/>
|
|
55
|
+
</div>
|
|
56
|
+
{renderErrorText(error)}
|
|
57
|
+
</div>
|
|
58
|
+
);
|
|
59
|
+
},
|
|
35
60
|
);
|
|
61
|
+
|
|
62
|
+
const getLabel = (errors?: string[], label?: string) => (label && errors ? `${label}*` : label);
|
|
63
|
+
|
|
64
|
+
const getPlaceholder = (placeholder?: string, errors?: string[], label?: string) =>
|
|
65
|
+
errors && !label ? `${placeholder}*` : placeholder;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
+
import { type DaDataSuggestion } from '../../api/dadataHints/dadataHintsType';
|
|
3
|
+
|
|
4
|
+
export interface InputPopupProps {
|
|
5
|
+
options?: Array<DaDataSuggestion>;
|
|
6
|
+
onChange: (e: string) => void;
|
|
7
|
+
value?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const InputPopup = JSX<InputPopupProps>(({ options, onChange }) => (
|
|
11
|
+
<div
|
|
12
|
+
className="bg-white text-l max-h-64 overflow-y-auto overflow-x-hidden rounded-md shadow-2xl"
|
|
13
|
+
role="list"
|
|
14
|
+
>
|
|
15
|
+
{options?.map((item, key) => (
|
|
16
|
+
<div
|
|
17
|
+
key={key.toString()}
|
|
18
|
+
className="flex px-m py-s cursor-pointer hover:bg-main-divider pr-5xl relative"
|
|
19
|
+
role="listitem"
|
|
20
|
+
onMouseDown={() => onChange(item.processedValue)}
|
|
21
|
+
>
|
|
22
|
+
<span className="min-h-6">{item.processedValue}</span>
|
|
23
|
+
</div>
|
|
24
|
+
))}
|
|
25
|
+
</div>
|
|
26
|
+
));
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
2
|
+
import { getDaDataHints } from '../../api/dadataHints/dadataHints';
|
|
3
|
+
import { type DaDataSuggestion } from '../../api/dadataHints/dadataHintsType';
|
|
4
|
+
import { hintsListsOptions } from '../../api/dadataHints/hintsListsOptions';
|
|
5
|
+
import { debounce } from '../../utils/debounce';
|
|
6
|
+
import { usePopupManager } from '../PopupManager/usePopupManager';
|
|
7
|
+
import { InputPopup } from './InputPopup';
|
|
8
|
+
|
|
9
|
+
interface InputPopupOptions {
|
|
10
|
+
isOpen?: boolean;
|
|
11
|
+
name: string;
|
|
12
|
+
value?: string;
|
|
13
|
+
onChange: (e: string) => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function useInputPopup({ isOpen, value, name, onChange }: InputPopupOptions) {
|
|
17
|
+
const prevInputValue = useRef(value);
|
|
18
|
+
const currentInputValue = useRef(value);
|
|
19
|
+
const [hintsList, setHintsList] = useState<Array<DaDataSuggestion>>([]);
|
|
20
|
+
const popup = usePopupManager();
|
|
21
|
+
|
|
22
|
+
const defaultHintsListOptions = hintsListsOptions[name];
|
|
23
|
+
|
|
24
|
+
const close = useCallback(() => {
|
|
25
|
+
currentInputValue.current = value;
|
|
26
|
+
popup.close();
|
|
27
|
+
}, [value]);
|
|
28
|
+
|
|
29
|
+
const handleChange = useCallback(
|
|
30
|
+
(option: string) => {
|
|
31
|
+
close();
|
|
32
|
+
currentInputValue.current = option;
|
|
33
|
+
onChange && onChange(option);
|
|
34
|
+
},
|
|
35
|
+
[close, onChange],
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const inputRef = useRef<HTMLDivElement | null>(null);
|
|
39
|
+
|
|
40
|
+
const getHintsList = useMemo(
|
|
41
|
+
() => async (searchValue: string) => {
|
|
42
|
+
if (!defaultHintsListOptions) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const result = await getDaDataHints({
|
|
46
|
+
url: defaultHintsListOptions.url,
|
|
47
|
+
requestData: {
|
|
48
|
+
...defaultHintsListOptions?.requestData,
|
|
49
|
+
},
|
|
50
|
+
query: searchValue,
|
|
51
|
+
});
|
|
52
|
+
if (result?.length) {
|
|
53
|
+
setHintsList(result);
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
[],
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const debouncedGetHintsList = useMemo(() => debounce(getHintsList, 300), [getHintsList]);
|
|
60
|
+
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (!isOpen || !inputRef.current || currentInputValue.current === value) {
|
|
63
|
+
close();
|
|
64
|
+
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const inputElement = inputRef.current;
|
|
69
|
+
const { top, left, width, height } = inputElement.getBoundingClientRect();
|
|
70
|
+
|
|
71
|
+
if (value && prevInputValue.current !== value) {
|
|
72
|
+
debouncedGetHintsList(value);
|
|
73
|
+
|
|
74
|
+
prevInputValue.current = value;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
popup.update(<InputPopup options={hintsList} value={value} onChange={handleChange} />, {
|
|
78
|
+
top: top + globalThis.scrollY + height,
|
|
79
|
+
left,
|
|
80
|
+
width,
|
|
81
|
+
});
|
|
82
|
+
}, [isOpen, hintsList, value, handleChange]);
|
|
83
|
+
|
|
84
|
+
return inputRef;
|
|
85
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redneckz/wildless-cms-uni-blocks",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.576",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "ЦК",
|
|
@@ -210,7 +210,7 @@
|
|
|
210
210
|
"path": "lib/common.css"
|
|
211
211
|
},
|
|
212
212
|
{
|
|
213
|
-
"limit": "
|
|
213
|
+
"limit": "70 kB",
|
|
214
214
|
"path": "bundle/bundle.umd.min.js"
|
|
215
215
|
}
|
|
216
216
|
],
|
|
@@ -2,20 +2,6 @@ import { type JSONRecord, type JSONScalar } from '@redneckz/json-op';
|
|
|
2
2
|
import { formatDate } from '../utils/formatDate';
|
|
3
3
|
import { formatPhone } from '../utils/formatPhone';
|
|
4
4
|
|
|
5
|
-
interface DaDataSuggestion<T> {
|
|
6
|
-
value?: string;
|
|
7
|
-
unrestricted_value?: string;
|
|
8
|
-
data?: T;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface DaDataAddress {
|
|
12
|
-
city?: string | null;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface DaDataResult {
|
|
16
|
-
suggestions?: DaDataSuggestion<DaDataAddress>[];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
5
|
export type LeadRequest = Record<string, JSONRecord | JSONScalar | null> & {
|
|
20
6
|
typeForm?: string;
|
|
21
7
|
addressBranch?: string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type DaDataSuggestion, type ListRequestOption } from './dadataHintsType';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_HINTS_COUNT = 10;
|
|
4
|
+
|
|
5
|
+
const getResponseHandler = (response: { suggestions: Array<DaDataSuggestion> }) => {
|
|
6
|
+
const responseData: Array<DaDataSuggestion> = response?.suggestions || [];
|
|
7
|
+
|
|
8
|
+
return responseData.map((item) => ({
|
|
9
|
+
...item,
|
|
10
|
+
processedValue: item?.value,
|
|
11
|
+
}));
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const getDaDataHints = (options: ListRequestOption): Promise<Array<DaDataSuggestion>> => {
|
|
15
|
+
const { url, query, requestData = {} } = options;
|
|
16
|
+
|
|
17
|
+
const result = fetch(`/api/v1/suggestions/${url}`, {
|
|
18
|
+
method: 'POST',
|
|
19
|
+
mode: 'cors',
|
|
20
|
+
headers: {
|
|
21
|
+
'Content-Type': 'application/json',
|
|
22
|
+
},
|
|
23
|
+
body: JSON.stringify({
|
|
24
|
+
count: DEFAULT_HINTS_COUNT,
|
|
25
|
+
...requestData,
|
|
26
|
+
query,
|
|
27
|
+
}),
|
|
28
|
+
})
|
|
29
|
+
.then((response) => response.json())
|
|
30
|
+
.then(getResponseHandler);
|
|
31
|
+
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type Nullable } from '../../utils/Nullable';
|
|
2
|
+
import { type HintOption } from './hintsListsOptions';
|
|
3
|
+
|
|
4
|
+
export interface DaDataSuggestion {
|
|
5
|
+
value: string;
|
|
6
|
+
unrestricted_value: string;
|
|
7
|
+
data: DaDataResponseItem;
|
|
8
|
+
processedValue: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type DaDataGender = 'MALE' | 'FEMALE' | 'UNKNOWN';
|
|
12
|
+
|
|
13
|
+
export interface DaDataFio {
|
|
14
|
+
surname: Nullable<string>;
|
|
15
|
+
name: Nullable<string>;
|
|
16
|
+
patronymic: Nullable<string>;
|
|
17
|
+
gender: DaDataGender;
|
|
18
|
+
qc: '0' | '1';
|
|
19
|
+
source: null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface DaDataEmail {
|
|
23
|
+
domain: Nullable<string>;
|
|
24
|
+
local: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type DaDataResponseItem = DaDataFio | DaDataEmail;
|
|
28
|
+
|
|
29
|
+
export interface ListRequestOption {
|
|
30
|
+
url: string;
|
|
31
|
+
query?: string;
|
|
32
|
+
requestData?: HintOption['requestData'];
|
|
33
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export const NAME_HINTS_LIST_OPTIONS = {
|
|
2
|
+
url: 'suggest/fio',
|
|
3
|
+
requestData: {
|
|
4
|
+
parts: ['NAME'],
|
|
5
|
+
gender: 'UNKNOWN',
|
|
6
|
+
},
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const SURNAME_HINTS_LIST_OPTIONS = {
|
|
10
|
+
url: 'suggest/fio',
|
|
11
|
+
requestData: {
|
|
12
|
+
parts: ['SURNAME'],
|
|
13
|
+
gender: 'UNKNOWN',
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const PATRONYMIC_HINTS_LIST_OPTIONS = {
|
|
18
|
+
url: 'suggest/fio',
|
|
19
|
+
requestData: {
|
|
20
|
+
parts: ['PATRONYMIC'],
|
|
21
|
+
gender: 'UNKNOWN',
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const EMAIL_HINTS_LIST_OPTIONS = {
|
|
26
|
+
url: 'suggest/email',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type HintsListOptions = Record<string, HintOption>;
|
|
30
|
+
|
|
31
|
+
export const hintsListsOptions: HintsListOptions = {
|
|
32
|
+
name: NAME_HINTS_LIST_OPTIONS,
|
|
33
|
+
surname: SURNAME_HINTS_LIST_OPTIONS,
|
|
34
|
+
middleName: PATRONYMIC_HINTS_LIST_OPTIONS,
|
|
35
|
+
email: EMAIL_HINTS_LIST_OPTIONS,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type HintOption = {
|
|
39
|
+
url: string;
|
|
40
|
+
requestData?: {
|
|
41
|
+
parts?: string[];
|
|
42
|
+
gender?: string;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
@@ -22,12 +22,12 @@ export default {
|
|
|
22
22
|
{
|
|
23
23
|
columns: 2,
|
|
24
24
|
inputs: [
|
|
25
|
-
{ fieldType: 'common', name: 'surname', required: true },
|
|
26
|
-
{ fieldType: 'common', name: 'name', required: true },
|
|
27
|
-
{ fieldType: 'common', name: 'middleName' },
|
|
25
|
+
{ fieldType: 'common', name: 'surname', required: true, dadata: true },
|
|
26
|
+
{ fieldType: 'common', name: 'name', required: true, dadata: true },
|
|
27
|
+
{ fieldType: 'common', name: 'middleName', dadata: true },
|
|
28
28
|
{ fieldType: 'common', name: 'birthday', required: true },
|
|
29
29
|
{ fieldType: 'common', name: 'phone', required: true },
|
|
30
|
-
{ fieldType: 'common', name: 'email', required: true },
|
|
30
|
+
{ fieldType: 'common', name: 'email', required: true, dadata: true },
|
|
31
31
|
],
|
|
32
32
|
},
|
|
33
33
|
{
|