indicator-ui 1.1.40 → 1.1.42
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/dist/index.cjs +8 -8
- package/dist/index.js +300 -296
- package/dist/types/src/hooks/forms/lib/createFormServices.d.ts +1 -1
- package/dist/types/src/hooks/forms/lib/scheme.d.ts +2 -1
- package/dist/types/src/hooks/forms/types/scheme.d.ts +2 -4
- package/dist/types/src/hooks/forms/types/services.d.ts +2 -2
- package/dist/types/src/hooks/forms/useForm.d.ts +27 -26
- package/package.json +1 -1
|
@@ -27,4 +27,4 @@ export declare function createFormServices<T, F = Nullable<Undefinable<T>>>(deps
|
|
|
27
27
|
highlightField: <P extends ExtendFormPath<F>>(path: P) => Promise<boolean>;
|
|
28
28
|
highlightFields: (paths: ExtendFormPath<F>[]) => Promise<boolean>;
|
|
29
29
|
highlightFormErrors: () => Promise<boolean>;
|
|
30
|
-
}): UseFormServices<T
|
|
30
|
+
}): UseFormServices<T>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { ExtendFormPath, ExtendFormValue, FieldConfigType, FormDefaultValues, FormPath, FormSchemeType, GetProcessArrayFieldValue } from '../types';
|
|
1
|
+
import { ExtendFormPath, ExtendFormValue, FieldConfigType, FormDefaultValues, FormPath, FormSchemeType, GetProcessArrayFieldValue, UseFormServices } from '../types';
|
|
2
2
|
import { Form, FormValidateFun } from '../classes';
|
|
3
3
|
type PropsOptionsType<T> = {
|
|
4
4
|
form: Form<T>;
|
|
5
5
|
formValidateFun: FormValidateFun<T>;
|
|
6
|
+
services: UseFormServices<T>;
|
|
6
7
|
};
|
|
7
8
|
/** Полностью заменяет валидаторы поля */
|
|
8
9
|
export declare function processValidators<T, F>(path: FormPath<T>, _config: FieldConfigType<T, F>, options: PropsOptionsType<T>): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FocusEvent, SetStateAction } from 'react';
|
|
2
2
|
import { Nullable, Undefinable } from '../../../types';
|
|
3
3
|
import { ExtendFormPath, ExtendFormValue, FormErrorType, FormPath, FormValue } from './formTypes';
|
|
4
|
-
import { UseFormServices } from '
|
|
4
|
+
import { UseFormServices } from './services';
|
|
5
5
|
export type StringFieldValidators = Partial<{
|
|
6
6
|
/** Минимальная длина строки */
|
|
7
7
|
minStr: number;
|
|
@@ -67,9 +67,7 @@ export type ArrayFieldValidators = Partial<{
|
|
|
67
67
|
/** Максимальное количество элементов в массиве */
|
|
68
68
|
maxItemCount: number;
|
|
69
69
|
}>;
|
|
70
|
-
export type FormValidateCustomFunType<T, F> = (value: F | undefined,
|
|
71
|
-
getField: <P extends FormPath<T>>(path: P) => FormValue<T, P> | undefined;
|
|
72
|
-
}) => Promise<FormErrorType> | FormErrorType;
|
|
70
|
+
export type FormValidateCustomFunType<T, F> = (value: F | null | undefined, services: UseFormServices<T>) => Promise<FormErrorType> | FormErrorType;
|
|
73
71
|
export type BaseFieldValidators<T, F> = Partial<{
|
|
74
72
|
/** Поле обязательное */
|
|
75
73
|
required: ValidatorOption<boolean>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ExtendFormPath, FormErrorsType, FormErrorType, FormPath, FormValue } from './formTypes';
|
|
2
2
|
import { Form } from '../classes';
|
|
3
3
|
import { Nullable, Undefinable } from '../../../types';
|
|
4
|
-
export type UseFormServices<T
|
|
4
|
+
export type UseFormServices<T> = Nullable<Undefinable<T>> extends infer F ? {
|
|
5
5
|
/** Работа с данными формы */
|
|
6
6
|
form: {
|
|
7
7
|
/** Получить актуальные данные формы */
|
|
@@ -56,4 +56,4 @@ export type UseFormServices<T, F = Nullable<Undefinable<T>>> = {
|
|
|
56
56
|
/** Подсветить все ошибки формы */
|
|
57
57
|
form: () => Promise<boolean>;
|
|
58
58
|
};
|
|
59
|
-
};
|
|
59
|
+
} : never;
|
|
@@ -9,12 +9,12 @@ type PropsType<Form, T> = {
|
|
|
9
9
|
useInstanceRefApi?: boolean;
|
|
10
10
|
initFormData?: T;
|
|
11
11
|
scheme?: FormSchemeType<T>;
|
|
12
|
-
onSubmit?: (data: Form, event: React.SubmitEvent<HTMLFormElement>, services: UseFormServices<Form
|
|
12
|
+
onSubmit?: (data: Form, event: React.SubmitEvent<HTMLFormElement>, services: UseFormServices<Form>) => void | Promise<void>;
|
|
13
13
|
/** Callback при ошибки валидации полей */
|
|
14
14
|
onSubmitError?: (event: {
|
|
15
15
|
errors: FormErrorsType<T>;
|
|
16
|
-
}, services: UseFormServices<Form
|
|
17
|
-
onSubmitAttempt?: (data: T | undefined | null, event: React.SubmitEvent<HTMLFormElement>, services: UseFormServices<Form
|
|
16
|
+
}, services: UseFormServices<Form>) => void;
|
|
17
|
+
onSubmitAttempt?: (data: T | undefined | null, event: React.SubmitEvent<HTMLFormElement>, services: UseFormServices<Form>) => void;
|
|
18
18
|
watch?: FormWatchType<Form>;
|
|
19
19
|
/** Отключить вызов watch-коллбэков для родительских путей при изменении вложенного поля */
|
|
20
20
|
offWatchDeep?: boolean;
|
|
@@ -215,37 +215,38 @@ type PropsType<Form, T> = {
|
|
|
215
215
|
* @template Form Полный тип формы
|
|
216
216
|
* @template T Тип начальных данных
|
|
217
217
|
*/
|
|
218
|
-
export declare function useForm<
|
|
219
|
-
formData:
|
|
220
|
-
setFormData: (formData:
|
|
221
|
-
setFormDataSilent: (formData:
|
|
222
|
-
getFormData: () =>
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
218
|
+
export declare function useForm<TForm, TFormNullable extends Nullable<Undefinable<TForm>> = Nullable<Undefinable<TForm>>>(props?: PropsType<TForm, TFormNullable>): {
|
|
219
|
+
formData: TFormNullable | undefined;
|
|
220
|
+
setFormData: (formData: TFormNullable) => void;
|
|
221
|
+
setFormDataSilent: (formData: TFormNullable) => void;
|
|
222
|
+
getFormData: () => TFormNullable | undefined;
|
|
223
|
+
getFormDataSync: () => TFormNullable | undefined;
|
|
224
|
+
errors: FormErrorsType<TFormNullable>;
|
|
225
|
+
setErrors: (errors: FormErrorsType<TFormNullable>) => void;
|
|
226
|
+
getField: <P extends FormPath<TFormNullable>>(path: P) => FormValue<TFormNullable, P> | undefined;
|
|
227
|
+
getFieldSync: <P extends FormPath<TFormNullable>>(path: P) => FormValue<TFormNullable, P> | undefined;
|
|
228
|
+
setField: <P extends FormPath<TFormNullable>>(path: P, value: FormValue<TFormNullable, P> | null | undefined) => void;
|
|
229
|
+
setFieldSilent: <P extends FormPath<TFormNullable>>(path: P, value: FormValue<TFormNullable, P> | null | undefined) => void;
|
|
230
|
+
getError: <P extends FormPath<TFormNullable>>(path: P) => FormErrorType | undefined;
|
|
231
|
+
hasChildPathsErrors: <P extends FormPath<TFormNullable>>(path: P) => boolean;
|
|
232
|
+
setError: <P extends FormPath<TFormNullable>>(path: P, error: FormErrorType) => void;
|
|
233
|
+
highlightField: <P extends ExtendFormPath<TFormNullable>>(path: P) => Promise<boolean>;
|
|
234
|
+
highlightFields: (paths: ExtendFormPath<TFormNullable>[]) => Promise<boolean>;
|
|
234
235
|
highlightFormErrors: () => Promise<boolean>;
|
|
235
|
-
isFieldValid: <P extends ExtendFormPath<
|
|
236
|
-
areFieldsValid: (paths: ExtendFormPath<
|
|
236
|
+
isFieldValid: <P extends ExtendFormPath<TFormNullable>>(path: P) => Promise<boolean>;
|
|
237
|
+
areFieldsValid: (paths: ExtendFormPath<TFormNullable>[]) => Promise<boolean>;
|
|
237
238
|
isFormValid: () => Promise<boolean>;
|
|
238
239
|
clearForm: () => void;
|
|
239
240
|
clearFormSilent: () => void;
|
|
240
241
|
clearErrors: () => void;
|
|
241
|
-
clearField: (_path: FormPath<
|
|
242
|
-
clearFieldSilent: (_path: FormPath<
|
|
242
|
+
clearField: (_path: FormPath<TFormNullable> | FormPath<TFormNullable>[]) => void;
|
|
243
|
+
clearFieldSilent: (_path: FormPath<TFormNullable> | FormPath<TFormNullable>[]) => void;
|
|
243
244
|
register: {
|
|
244
|
-
(): FieldPropsType<FormValue<
|
|
245
|
-
<P extends FormPath<
|
|
245
|
+
(): FieldPropsType<FormValue<TFormNullable, "">, "update">;
|
|
246
|
+
<P extends FormPath<TFormNullable>>(path: P, config?: FormSchemeType<TFormNullable>[P]): FieldPropsType<FormValue<TFormNullable, P>, "update">;
|
|
246
247
|
};
|
|
247
248
|
registerForm: (refsInstance?: FormInstance) => Pick<React.DetailedHTMLProps<React.FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>, "ref" | "onReset" | "onSubmit" | "noValidate"> & Pick<InstanceRefAttributes<HTMLFormElement>, "instanceRef">;
|
|
248
|
-
getValidForm: () => Promise<
|
|
249
|
+
getValidForm: () => Promise<TForm | null>;
|
|
249
250
|
submitForm: () => void;
|
|
250
251
|
resetForm: () => void;
|
|
251
252
|
};
|