indicator-ui 1.0.34 → 1.0.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.
@@ -1,9 +1,11 @@
1
1
  import { ExtendFormPath, FormErrorsType, FormErrorType, FormPath, FormValue, UseFormServices } from '../types';
2
2
  import { Form } from '../classes';
3
- export declare function createFormServices<T>(deps: {
3
+ import { Nullable, Undefinable } from '../../../types';
4
+ export declare function createFormServices<F, T = Nullable<Undefinable<F>>>(deps: {
4
5
  /** Form */
5
6
  getForm: () => Form<T>;
6
7
  setFormData: (data: T) => void;
8
+ getValidForm: () => Promise<F | null>;
7
9
  /** Fields */
8
10
  getField: <P extends FormPath<T>>(path: P) => FormValue<T, P> | null | undefined;
9
11
  getFieldSync: <P extends FormPath<T>>(path: P) => FormValue<T, P> | undefined;
@@ -22,4 +24,4 @@ export declare function createFormServices<T>(deps: {
22
24
  highlightField: <P extends ExtendFormPath<T>>(path: P) => Promise<boolean>;
23
25
  highlightFields: (paths: ExtendFormPath<T>[]) => Promise<boolean>;
24
26
  highlightFormErrors: () => Promise<boolean>;
25
- }): UseFormServices<T>;
27
+ }): UseFormServices<F, T>;
@@ -1,12 +1,14 @@
1
1
  import { ExtendFormPath, FormErrorsType, FormErrorType, FormPath, FormValue } from './formTypes';
2
2
  import { Form } from '../classes';
3
- export type UseFormServices<T> = {
3
+ import { Nullable, Undefinable } from '../../../types';
4
+ export type UseFormServices<F, T = Nullable<Undefinable<F>>> = {
4
5
  /** Работа с данными формы */
5
6
  form: {
6
7
  /** Получить актуальные данные формы */
7
8
  getData: () => Form<T>;
8
9
  /** Полностью заменить данные формы */
9
10
  setData: (data: T) => void;
11
+ getValidData: () => Promise<F | null>;
10
12
  };
11
13
  /** Работа с полями */
12
14
  fields: {
@@ -6,12 +6,12 @@ type PropsType<T, Form> = [
6
6
  props?: {
7
7
  initFormData?: T;
8
8
  scheme?: FormSchemeType<T>;
9
- onSubmit?: (data: Form, event: FormEvent<HTMLFormElement>, services: UseFormServices<T>) => void | Promise<void>;
9
+ onSubmit?: (data: Form, event: FormEvent<HTMLFormElement>, services: UseFormServices<Form, T>) => void | Promise<void>;
10
10
  /** Callback при ошибки валидации полей */
11
11
  onSubmitError?: (event: {
12
12
  errors: FormErrorsType<T>;
13
- }, services: UseFormServices<T>) => void;
14
- onSubmitAttempt?: (data: T | undefined | null, event: FormEvent<HTMLFormElement>, services: UseFormServices<T>) => void;
13
+ }, services: UseFormServices<Form, T>) => void;
14
+ onSubmitAttempt?: (data: T | undefined | null, event: FormEvent<HTMLFormElement>, services: UseFormServices<Form, T>) => void;
15
15
  }
16
16
  ];
17
17
  /**
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "react-components",
12
12
  "ui-kit"
13
13
  ],
14
- "version": "1.0.34",
14
+ "version": "1.0.35",
15
15
  "exports": {
16
16
  ".": {
17
17
  "types": "./dist/types/index.d.ts",