indicator-ui 1.1.34 → 1.1.35

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.
@@ -16,6 +16,7 @@ export declare class Form<T> {
16
16
  clearDefaultValues(): void;
17
17
  applyDefaultValue<const P extends ExtendFormPath<T>>(path: P): void;
18
18
  applyDefaultValues(): void;
19
+ checkIsEmptyValue(value: any): boolean;
19
20
  setField: <const P extends FormPath<T>>(path: P, value: FormValue<T, P> | undefined) => void;
20
21
  getField: <const P extends FormPath<T>>(path: P) => FormValue<T, P> | undefined;
21
22
  clearField(path: FormPath<T>): void;
@@ -30,6 +31,7 @@ export declare class FormError<T> {
30
31
  addErrors(errors: FormErrorsType<T>): void;
31
32
  set errors(errors: FormErrorsType<T>);
32
33
  getError<const P extends FormPath<T>>(path: P): FormErrorType | undefined;
34
+ hasChildPathsErrors<const P extends FormPath<T>>(path: P): boolean;
33
35
  setError<const P extends FormPath<T>>(path: P, error: FormErrorType): void;
34
36
  deleteError<const P extends FormPath<T>>(keyChain: P): void;
35
37
  clear(): void;
@@ -5,12 +5,15 @@ export declare function createFormServices<T, F = Nullable<Undefinable<T>>>(deps
5
5
  /** Form */
6
6
  getForm: () => Form<F>;
7
7
  setFormData: (data: F) => void;
8
+ setFormDataSilent: (data: F) => void;
8
9
  getValidForm: () => Promise<T | null>;
9
10
  /** Fields */
10
11
  getField: <P extends FormPath<F>>(path: P) => FormValue<F, P> | null | undefined;
11
12
  getFieldSync: <P extends FormPath<F>>(path: P) => FormValue<F, P> | null | undefined;
12
13
  setField: <P extends FormPath<F>>(path: P, value: FormValue<F, P> | null | undefined) => void;
14
+ setFieldSilent: <P extends FormPath<F>>(path: P, value: FormValue<F, P> | null | undefined) => void;
13
15
  clearField: (path: FormPath<F> | FormPath<F>[]) => void;
16
+ clearFieldSilent: (path: FormPath<F> | FormPath<F>[]) => void;
14
17
  /** Errors */
15
18
  getError: <P extends FormPath<F>>(path: P) => FormErrorType | undefined;
16
19
  setError: <P extends FormPath<F>>(path: P, error: FormErrorType) => void;
@@ -8,6 +8,8 @@ export type UseFormServices<T, F = Nullable<Undefinable<T>>> = {
8
8
  getData: () => Form<F>;
9
9
  /** Полностью заменить данные формы */
10
10
  setData: (data: F) => void;
11
+ /** Полностью заменить данные формы без вызова watch-коллбэков */
12
+ setDataSilent: (data: F) => void;
11
13
  getValidData: () => Promise<T | null>;
12
14
  };
13
15
  /** Работа с полями */
@@ -18,8 +20,12 @@ export type UseFormServices<T, F = Nullable<Undefinable<T>>> = {
18
20
  getSync: <P extends FormPath<F>>(path: P) => FormValue<F, P> | null | undefined;
19
21
  /** Установить значение поля */
20
22
  set: <P extends FormPath<F>>(path: P, value: FormValue<F, P> | null | undefined) => void;
23
+ /** Установить значение поля без вызова watch-коллбэков */
24
+ setSilent: <P extends FormPath<F>>(path: P, value: FormValue<F, P> | null | undefined) => void;
21
25
  /** Очистить одно или несколько полей */
22
26
  clear: (path: FormPath<F> | FormPath<F>[]) => void;
27
+ /** Очистить одно или несколько полей без вызова watch-коллбэков */
28
+ clearSilent: (path: FormPath<F> | FormPath<F>[]) => void;
23
29
  };
24
30
  /** Работа с ошибками */
25
31
  errors: {
@@ -16,6 +16,8 @@ type PropsType<Form, T> = {
16
16
  }, services: UseFormServices<Form, T>) => void;
17
17
  onSubmitAttempt?: (data: T | undefined | null, event: React.SubmitEvent<HTMLFormElement>, services: UseFormServices<Form, T>) => void;
18
18
  watch?: FormWatchType<Form>;
19
+ /** Debounce в мс для реактивной ревалидации при изменении поля с ошибкой. Полезно при async-валидаторах */
20
+ revalidateDebounce?: number;
19
21
  };
20
22
  /**
21
23
  * `useForm` — типобезопасный хук для управления состоянием и валидации форм.
@@ -214,13 +216,16 @@ type PropsType<Form, T> = {
214
216
  export declare function useForm<F, T extends Nullable<Undefinable<F>> = Nullable<Undefinable<F>>>(props?: PropsType<F, T>): {
215
217
  formData: T | undefined;
216
218
  setFormData: (formData: T) => void;
219
+ setFormDataSilent: (formData: T) => void;
217
220
  getFormData: () => T | undefined;
218
221
  errors: FormErrorsType<T>;
219
222
  setErrors: (errors: FormErrorsType<T>) => void;
220
223
  getField: <P extends FormPath<T>>(path: P) => FormValue<T, P> | undefined;
221
224
  getFieldSync: <P extends FormPath<T>>(path: P) => FormValue<T, P> | undefined;
222
225
  setField: <P extends FormPath<T>>(path: P, value: FormValue<T, P> | null | undefined) => void;
226
+ setFieldSilent: <P extends FormPath<T>>(path: P, value: FormValue<T, P> | null | undefined) => void;
223
227
  getError: <P extends FormPath<T>>(path: P) => FormErrorType | undefined;
228
+ hasChildPathsErrors: <P extends FormPath<T>>(path: P) => boolean;
224
229
  setError: <P extends FormPath<T>>(path: P, error: FormErrorType) => void;
225
230
  highlightField: <P extends ExtendFormPath<T>>(path: P) => Promise<boolean>;
226
231
  highlightFields: (paths: ExtendFormPath<T>[]) => Promise<boolean>;
@@ -229,8 +234,10 @@ export declare function useForm<F, T extends Nullable<Undefinable<F>> = Nullable
229
234
  areFieldsValid: (paths: ExtendFormPath<T>[]) => Promise<boolean>;
230
235
  isFormValid: () => Promise<boolean>;
231
236
  clearForm: () => void;
237
+ clearFormSilent: () => void;
232
238
  clearErrors: () => void;
233
239
  clearField: (_path: FormPath<T> | FormPath<T>[]) => void;
240
+ clearFieldSilent: (_path: FormPath<T> | FormPath<T>[]) => void;
234
241
  register: {
235
242
  (): FieldPropsType<FormValue<T, "">, "update">;
236
243
  <P extends FormPath<T>>(path: P, config?: FormSchemeType<T>[P]): FieldPropsType<FormValue<T, P>, "update">;
@@ -14,3 +14,4 @@ export * from './useMutationObserver';
14
14
  export * from './useResizeObserver';
15
15
  export * from './useResizeObserverRef';
16
16
  export * from './useMostVisibleElement';
17
+ export * from './useFocusBoundary';
@@ -0,0 +1,15 @@
1
+ import { FocusEvent } from 'react';
2
+ type PropsType<T extends HTMLElement> = {
3
+ onBlur?: (e: FocusEvent<T>) => void;
4
+ onFocus?: (e: FocusEvent<T>) => void;
5
+ };
6
+ /**
7
+ * Возвращает обработчики для контейнера, которые срабатывают
8
+ * только когда фокус реально покидает его границы (а не перемещается
9
+ * между внутренними фокусируемыми элементами).
10
+ */
11
+ export declare function useFocusBoundary<T extends HTMLElement = HTMLElement>(props: PropsType<T>): {
12
+ onFocus: (e: FocusEvent<T>) => void;
13
+ onBlur: (e: FocusEvent<T>) => void;
14
+ };
15
+ export {};
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "react-components",
12
12
  "ui-kit"
13
13
  ],
14
- "version": "1.1.34",
14
+ "version": "1.1.35",
15
15
  "exports": {
16
16
  ".": {
17
17
  "types": "./dist/types/index.d.ts",