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, options: {
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<F, T extends Nullable<Undefinable<F>> = Nullable<Undefinable<F>>>(props?: PropsType<F, T>): {
219
- formData: T | undefined;
220
- setFormData: (formData: T) => void;
221
- setFormDataSilent: (formData: T) => void;
222
- getFormData: () => T | undefined;
223
- errors: FormErrorsType<T>;
224
- setErrors: (errors: FormErrorsType<T>) => void;
225
- getField: <P extends FormPath<T>>(path: P) => FormValue<T, P> | undefined;
226
- getFieldSync: <P extends FormPath<T>>(path: P) => FormValue<T, P> | undefined;
227
- setField: <P extends FormPath<T>>(path: P, value: FormValue<T, P> | null | undefined) => void;
228
- setFieldSilent: <P extends FormPath<T>>(path: P, value: FormValue<T, P> | null | undefined) => void;
229
- getError: <P extends FormPath<T>>(path: P) => FormErrorType | undefined;
230
- hasChildPathsErrors: <P extends FormPath<T>>(path: P) => boolean;
231
- setError: <P extends FormPath<T>>(path: P, error: FormErrorType) => void;
232
- highlightField: <P extends ExtendFormPath<T>>(path: P) => Promise<boolean>;
233
- highlightFields: (paths: ExtendFormPath<T>[]) => Promise<boolean>;
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<T>>(path: P) => Promise<boolean>;
236
- areFieldsValid: (paths: ExtendFormPath<T>[]) => Promise<boolean>;
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<T> | FormPath<T>[]) => void;
242
- clearFieldSilent: (_path: FormPath<T> | FormPath<T>[]) => void;
242
+ clearField: (_path: FormPath<TFormNullable> | FormPath<TFormNullable>[]) => void;
243
+ clearFieldSilent: (_path: FormPath<TFormNullable> | FormPath<TFormNullable>[]) => void;
243
244
  register: {
244
- (): FieldPropsType<FormValue<T, "">, "update">;
245
- <P extends FormPath<T>>(path: P, config?: FormSchemeType<T>[P]): FieldPropsType<FormValue<T, P>, "update">;
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<F | null>;
249
+ getValidForm: () => Promise<TForm | null>;
249
250
  submitForm: () => void;
250
251
  resetForm: () => void;
251
252
  };
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "react-components",
12
12
  "ui-kit"
13
13
  ],
14
- "version": "1.1.39",
14
+ "version": "1.1.41",
15
15
  "exports": {
16
16
  ".": {
17
17
  "types": "./dist/types/index.d.ts",