@redneckz/wildless-cms-uni-blocks 0.14.589 → 0.14.591
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/bundle.umd.js +84 -62
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/hooks/useElementSpace.d.ts +2 -0
- package/bundle/ui-kit/FormField/validators.d.ts +9 -9
- package/dist/hooks/useElementSpace.d.ts +2 -0
- package/dist/hooks/useElementSpace.js +21 -0
- package/dist/hooks/useElementSpace.js.map +1 -0
- package/dist/ui-kit/DatePicker/DatePicker.js +5 -1
- package/dist/ui-kit/DatePicker/DatePicker.js.map +1 -1
- package/dist/ui-kit/FormField/Fields/MiddleNameField.js +3 -1
- package/dist/ui-kit/FormField/Fields/MiddleNameField.js.map +1 -1
- package/dist/ui-kit/FormField/getObjectValidator.js +46 -45
- package/dist/ui-kit/FormField/getObjectValidator.js.map +1 -1
- package/dist/ui-kit/FormField/validators.d.ts +9 -9
- package/dist/ui-kit/FormField/validators.js +17 -9
- package/dist/ui-kit/FormField/validators.js.map +1 -1
- package/dist/ui-kit/Input/Input.js +3 -2
- package/dist/ui-kit/Input/Input.js.map +1 -1
- package/lib/hooks/useElementSpace.d.ts +2 -0
- package/lib/hooks/useElementSpace.js +18 -0
- package/lib/hooks/useElementSpace.js.map +1 -0
- package/lib/ui-kit/DatePicker/DatePicker.js +5 -1
- package/lib/ui-kit/DatePicker/DatePicker.js.map +1 -1
- package/lib/ui-kit/FormField/Fields/MiddleNameField.js +3 -1
- package/lib/ui-kit/FormField/Fields/MiddleNameField.js.map +1 -1
- package/lib/ui-kit/FormField/getObjectValidator.js +46 -45
- package/lib/ui-kit/FormField/getObjectValidator.js.map +1 -1
- package/lib/ui-kit/FormField/validators.d.ts +9 -9
- package/lib/ui-kit/FormField/validators.js +9 -9
- package/lib/ui-kit/FormField/validators.js.map +1 -1
- package/lib/ui-kit/Input/Input.js +3 -2
- package/lib/ui-kit/Input/Input.js.map +1 -1
- package/mobile/bundle/bundle.umd.js +84 -62
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/hooks/useElementSpace.d.ts +2 -0
- package/mobile/bundle/ui-kit/FormField/validators.d.ts +9 -9
- package/mobile/dist/hooks/useElementSpace.d.ts +2 -0
- package/mobile/dist/hooks/useElementSpace.js +21 -0
- package/mobile/dist/hooks/useElementSpace.js.map +1 -0
- package/mobile/dist/ui-kit/DatePicker/DatePicker.js +5 -1
- package/mobile/dist/ui-kit/DatePicker/DatePicker.js.map +1 -1
- package/mobile/dist/ui-kit/FormField/Fields/MiddleNameField.js +3 -1
- package/mobile/dist/ui-kit/FormField/Fields/MiddleNameField.js.map +1 -1
- package/mobile/dist/ui-kit/FormField/getObjectValidator.js +46 -45
- package/mobile/dist/ui-kit/FormField/getObjectValidator.js.map +1 -1
- package/mobile/dist/ui-kit/FormField/validators.d.ts +9 -9
- package/mobile/dist/ui-kit/FormField/validators.js +17 -9
- package/mobile/dist/ui-kit/FormField/validators.js.map +1 -1
- package/mobile/dist/ui-kit/Input/Input.js +3 -2
- package/mobile/dist/ui-kit/Input/Input.js.map +1 -1
- package/mobile/lib/hooks/useElementSpace.d.ts +2 -0
- package/mobile/lib/hooks/useElementSpace.js +18 -0
- package/mobile/lib/hooks/useElementSpace.js.map +1 -0
- package/mobile/lib/ui-kit/DatePicker/DatePicker.js +5 -1
- package/mobile/lib/ui-kit/DatePicker/DatePicker.js.map +1 -1
- package/mobile/lib/ui-kit/FormField/Fields/MiddleNameField.js +3 -1
- package/mobile/lib/ui-kit/FormField/Fields/MiddleNameField.js.map +1 -1
- package/mobile/lib/ui-kit/FormField/getObjectValidator.js +46 -45
- package/mobile/lib/ui-kit/FormField/getObjectValidator.js.map +1 -1
- package/mobile/lib/ui-kit/FormField/validators.d.ts +9 -9
- package/mobile/lib/ui-kit/FormField/validators.js +9 -9
- package/mobile/lib/ui-kit/FormField/validators.js.map +1 -1
- package/mobile/lib/ui-kit/Input/Input.js +3 -2
- package/mobile/lib/ui-kit/Input/Input.js.map +1 -1
- package/mobile/src/hooks/useElementSpace.ts +25 -0
- package/mobile/src/ui-kit/DatePicker/DatePicker.tsx +9 -1
- package/mobile/src/ui-kit/FormField/Fields/MiddleNameField.tsx +7 -1
- package/mobile/src/ui-kit/FormField/getObjectValidator.tsx +46 -45
- package/mobile/src/ui-kit/FormField/validators.ts +19 -18
- package/mobile/src/ui-kit/Input/Input.tsx +6 -2
- package/package.json +1 -1
- package/src/hooks/useElementSpace.ts +25 -0
- package/src/ui-kit/DatePicker/DatePicker.tsx +9 -1
- package/src/ui-kit/FormField/Fields/MiddleNameField.tsx +7 -1
- package/src/ui-kit/FormField/getObjectValidator.tsx +46 -45
- package/src/ui-kit/FormField/validators.ts +19 -18
- package/src/ui-kit/Input/Input.tsx +6 -2
|
@@ -4,30 +4,30 @@ import { validator } from '../../validation/validator';
|
|
|
4
4
|
|
|
5
5
|
const ERROR_MESSAGE = 'Некорректно заполненное поле';
|
|
6
6
|
|
|
7
|
-
export const defaultValidator =
|
|
7
|
+
export const defaultValidator = (errorMsg?: string) =>
|
|
8
|
+
required(errorMsg ? errorMsg : ERROR_MESSAGE);
|
|
8
9
|
|
|
9
10
|
export const defaultSelectValidator = validator((_) => _?.key && _?.key !== '')(ERROR_MESSAGE);
|
|
10
11
|
|
|
11
|
-
export const nameValidator =
|
|
12
|
+
export const nameValidator = (errorMsg?: string) =>
|
|
13
|
+
validator((_) => typeof _ === 'string' && _.length > 1)(errorMsg ? errorMsg : ERROR_MESSAGE);
|
|
12
14
|
|
|
13
|
-
export const lengthStringValidator = (maxLength: number) =>
|
|
14
|
-
validator((_) => typeof _ === 'string' && _.length >= 1 && _.length <= maxLength)(
|
|
15
|
+
export const lengthStringValidator = (maxLength: number, errorMsg?: string) =>
|
|
16
|
+
validator((_) => typeof _ === 'string' && _.length >= 1 && _.length <= maxLength)(
|
|
17
|
+
errorMsg ? errorMsg : ERROR_MESSAGE,
|
|
18
|
+
);
|
|
15
19
|
|
|
16
|
-
export const serieValidator =
|
|
17
|
-
|
|
18
|
-
);
|
|
20
|
+
export const serieValidator = (errorMsg: string) =>
|
|
21
|
+
validator((_) => typeof _ === 'string' && _.length === 4)(errorMsg);
|
|
19
22
|
|
|
20
|
-
export const numberValidator =
|
|
21
|
-
|
|
22
|
-
);
|
|
23
|
+
export const numberValidator = (errorMsg: string) =>
|
|
24
|
+
validator((_) => typeof _ === 'string' && _.length === 6)(errorMsg);
|
|
23
25
|
|
|
24
|
-
export const innValidator =
|
|
25
|
-
(_) => typeof _ === 'string' && (_.length === 10 || _.length === 12)
|
|
26
|
-
)(ERROR_MESSAGE);
|
|
26
|
+
export const innValidator = (errorMsg: string) =>
|
|
27
|
+
validator((_) => typeof _ === 'string' && (_.length === 10 || _.length === 12))(errorMsg);
|
|
27
28
|
|
|
28
|
-
export const phoneValidator =
|
|
29
|
-
/^(\+7)?[\s-]?\(?[0-9]{3}\)?[\s-]?[0-9]{3}[\s-]?[0-9]{2}[\s-]?[0-9]{2}
|
|
30
|
-
)(ERROR_MESSAGE);
|
|
29
|
+
export const phoneValidator = (errorMsg: string) =>
|
|
30
|
+
pattern(/^(\+7)?[\s-]?\(?[0-9]{3}\)?[\s-]?[0-9]{3}[\s-]?[0-9]{2}[\s-]?[0-9]{2}$/)(errorMsg);
|
|
31
31
|
|
|
32
32
|
export const agreementValidator = validator((_) => typeof _ === 'boolean' && _)(
|
|
33
33
|
'Согласие обязательно',
|
|
@@ -53,8 +53,9 @@ const snilsValidate = (snils: string) => {
|
|
|
53
53
|
return false;
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
-
export const snilsValidator = validator(snilsValidate)(
|
|
56
|
+
export const snilsValidator = (errorMsg: string) => validator(snilsValidate)(errorMsg);
|
|
57
57
|
|
|
58
58
|
const emailValidate = (email: string) => /^[^\s@]+@[^\s@]+\.[a-zA-Z]{2}$/.test(email);
|
|
59
59
|
|
|
60
|
-
export const emailValidator =
|
|
60
|
+
export const emailValidator = (errorMsg: string) =>
|
|
61
|
+
validator((_: string) => emailValidate(_))(errorMsg);
|
|
@@ -25,9 +25,11 @@ export const Input = JSX<InputProps>(
|
|
|
25
25
|
isTextarea = false,
|
|
26
26
|
}) => {
|
|
27
27
|
const inputRef = useRef<HTMLInputElement | null>(null);
|
|
28
|
+
|
|
28
29
|
const handleChange = useCallback(
|
|
29
30
|
(e: { target?: { value?: string } }) => {
|
|
30
|
-
|
|
31
|
+
const valueWithoutSpace = (e.target?.value || '').trimStart();
|
|
32
|
+
onChange && onChange(valueWithoutSpace);
|
|
31
33
|
},
|
|
32
34
|
[onChange],
|
|
33
35
|
);
|
|
@@ -37,7 +39,7 @@ export const Input = JSX<InputProps>(
|
|
|
37
39
|
inputRef.current?.focus();
|
|
38
40
|
}
|
|
39
41
|
}, [autoFocus, inputRef]);
|
|
40
|
-
|
|
42
|
+
|
|
41
43
|
const paddingStyle = children ? 'pr-3xl' : '';
|
|
42
44
|
const validStyle = getValidStyle(valid);
|
|
43
45
|
|
|
@@ -81,3 +83,5 @@ export const Input = JSX<InputProps>(
|
|
|
81
83
|
);
|
|
82
84
|
|
|
83
85
|
const getValidStyle = (valid: boolean) => (valid ? inputValidStyle : 'border-error');
|
|
86
|
+
|
|
87
|
+
const defaultStyle = 'w-full border rounded-md text-primary-text outline-none p-m';
|