indicator-ui 1.0.1 → 1.0.2
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.js
CHANGED
|
@@ -15740,7 +15740,7 @@ function fU(...n) {
|
|
|
15740
15740
|
v();
|
|
15741
15741
|
}, se = () => {
|
|
15742
15742
|
p().clear(), b();
|
|
15743
|
-
}, ae = (q, W) => {
|
|
15743
|
+
}, ae = (q = "", W) => {
|
|
15744
15744
|
const K = { ...W || {}, ...r?.[q] || {} };
|
|
15745
15745
|
return Fx(q, K, { form: l(), formValidateFun: m() }), M8({
|
|
15746
15746
|
form: u,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FocusEvent } from 'react';
|
|
2
|
-
import { Nullable } from '../../../types';
|
|
2
|
+
import { Nullable, Undefinable } from '../../../types';
|
|
3
3
|
import { ExtendFormPath, ExtendFormValue, FormErrorType, FormPath, FormValue } from './formTypes';
|
|
4
4
|
export type StringFieldValidators = Partial<{
|
|
5
5
|
/** Минимальная длина строки */
|
|
@@ -149,7 +149,7 @@ export type FieldConfigType<T, F> = DefaultValueConfig<T, F> & BaseFieldValidato
|
|
|
149
149
|
*
|
|
150
150
|
* @template T — тип данных формы (например, интерфейс или тип объекта формы).
|
|
151
151
|
*/
|
|
152
|
-
export type FormSchemeType<T> = Nullable<
|
|
152
|
+
export type FormSchemeType<T> = Nullable<Undefinable<T>> extends infer Form ? {
|
|
153
153
|
[K in ExtendFormPath<Form>]?: FieldConfigType<Form, ExtendFormValue<Form, K>>;
|
|
154
154
|
} : never;
|
|
155
155
|
export type FieldPropsType<V> = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { default as React, FormEvent } from 'react';
|
|
2
2
|
import { ExtendFormPath, FieldPropsType, FormErrorsType, FormErrorType } from '..';
|
|
3
|
-
import { Nullable } from '../../types';
|
|
3
|
+
import { Nullable, Undefinable } from '../../types';
|
|
4
4
|
import { FormPath, FormSchemeType, FormValue } from './types';
|
|
5
5
|
type PropsType<T, Form> = [
|
|
6
6
|
props?: {
|
|
@@ -179,7 +179,7 @@ type PropsType<T, Form> = [
|
|
|
179
179
|
*
|
|
180
180
|
* ---
|
|
181
181
|
* @template Form — объект, описывающий форму.
|
|
182
|
-
* @template T — частичный тип формы (используется для инициализации, по умолчанию `
|
|
182
|
+
* @template T — частичный тип формы (используется для инициализации, по умолчанию `Undefinable<Form>`).
|
|
183
183
|
*
|
|
184
184
|
* @param {Object} [params]
|
|
185
185
|
* @param {T} [params.initFormData] — начальные данные формы.
|
|
@@ -188,7 +188,7 @@ type PropsType<T, Form> = [
|
|
|
188
188
|
*
|
|
189
189
|
* @returns {object} Объект с методами и состоянием формы (см. таблицу выше).
|
|
190
190
|
*/
|
|
191
|
-
export declare function useForm<Form, T extends Nullable<
|
|
191
|
+
export declare function useForm<Form, T extends Nullable<Undefinable<Form>> = Nullable<Undefinable<Form>>>(...args: PropsType<T, Form>): {
|
|
192
192
|
formData: T | undefined;
|
|
193
193
|
setFormData: (formData: T) => void;
|
|
194
194
|
getFormData: () => T | undefined;
|
|
@@ -208,7 +208,7 @@ export declare function useForm<Form, T extends Nullable<Partial<Form>> = Nullab
|
|
|
208
208
|
clearForm: () => void;
|
|
209
209
|
clearErrors: () => void;
|
|
210
210
|
clearField: (_path: FormPath<T> | FormPath<T>[]) => void;
|
|
211
|
-
register: <P extends FormPath<T>>(path
|
|
211
|
+
register: <P extends FormPath<T>>(path?: P, config?: FormSchemeType<T>[P]) => FieldPropsType<FormValue<T, P>>;
|
|
212
212
|
registerForm: () => Pick<React.ComponentProps<"form">, "onSubmit" | "onReset" | "noValidate">;
|
|
213
213
|
getValidForm: () => Promise<Form | null>;
|
|
214
214
|
};
|
|
@@ -10,13 +10,17 @@ export type IsString<T> = T extends string ? true : false;
|
|
|
10
10
|
export type IsDate<T> = T extends (string | Date | number) ? true : false;
|
|
11
11
|
export type IsNumber<T> = T extends number ? true : false;
|
|
12
12
|
export type IsArray<T> = T extends any[] ? true : false;
|
|
13
|
+
export type IsObject<T> = T extends object ? true : false;
|
|
13
14
|
export type IsTuple<T> = T extends readonly any[] ? number extends T['length'] ? false : true : false;
|
|
14
15
|
export type NegativeBoolean<T> = T extends true ? false : true;
|
|
15
16
|
export type NotTuple<T> = NegativeBoolean<IsTuple<T>>;
|
|
16
17
|
export type BuildTuple<N extends number, T extends any[] = []> = T['length'] extends N ? T : BuildTuple<N, [...T, N]>;
|
|
17
|
-
export type Nullable<T> = {
|
|
18
|
+
export type Nullable<T> = null | (IsObject<T> extends true ? IsArray<T> extends true ? T : {
|
|
18
19
|
[K in keyof T]: T[K] | null;
|
|
19
|
-
}
|
|
20
|
+
} : T);
|
|
21
|
+
export type Undefinable<T> = undefined | (IsObject<T> extends true ? IsArray<T> extends true ? T : {
|
|
22
|
+
[K in keyof T]: T[K] | undefined;
|
|
23
|
+
} : T);
|
|
20
24
|
export type Merge<A extends Record<any, any>, B extends Record<any, any>> = Omit<A, keyof B> & B;
|
|
21
25
|
export type AsProps<T extends ElementType, P extends Record<string, any> = {}> = Merge<React.ComponentProps<T>, {
|
|
22
26
|
as?: T;
|