indicator-ui 1.1.39 → 1.1.41
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.
|
@@ -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 | undefined, services: UseFormServices<T>) => Promise<FormErrorType> | FormErrorType;
|
|
73
71
|
export type BaseFieldValidators<T, F> = Partial<{
|
|
74
72
|
/** Поле обязательное */
|
|
75
73
|
required: ValidatorOption<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
|
};
|