indicator-ui 0.1.64 → 0.1.65

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.
@@ -3,7 +3,7 @@ import { Form, FormError } from "../classes";
3
3
  type PropsType<T, P extends FormPath<T>> = {
4
4
  path: P;
5
5
  form: Form<T>;
6
- setField: (path: P, value: FormValue<T, P> | undefined) => void;
6
+ setField: (path: P, value: FormValue<T, P> | null | undefined) => void;
7
7
  formErrors: FormError<T>;
8
8
  highlightField: (path: P) => void;
9
9
  };
@@ -1,3 +1,4 @@
1
+ import { DeepNullable } from "../../../types";
1
2
  import { ExtendFormPath, ExtendFormValue, FormErrorType, FormPath, FormValue } from './formTypes';
2
3
  export type StringFieldValidators = Partial<{
3
4
  /** Минимальная длина строки */
@@ -147,12 +148,12 @@ export type FieldConfigType<T, F> = DefaultValueConfig<T, F> & BaseFieldValidato
147
148
  *
148
149
  * @template T — тип данных формы (например, интерфейс или тип объекта формы).
149
150
  */
150
- export type FormSchemeType<T> = Partial<T> extends infer Form ? {
151
+ export type FormSchemeType<T> = DeepNullable<Partial<T>> extends infer Form ? {
151
152
  [K in ExtendFormPath<Form>]?: FieldConfigType<Form, ExtendFormValue<Form, K>>;
152
153
  } : never;
153
154
  export type FieldPropsType<V> = {
154
- value?: V;
155
- onChange?: (value?: V) => void;
155
+ value?: V | null;
156
+ onChange?: (value?: V | null) => void;
156
157
  error?: FormErrorType;
157
158
  onBlur?: () => void;
158
159
  };
@@ -1,5 +1,6 @@
1
1
  import React, { FormEvent } from "react";
2
2
  import { ExtendFormPath, FieldPropsType, FormErrorsType, FormErrorType } from "../../hooks";
3
+ import { DeepNullable } from "../../types";
3
4
  import { FormPath, FormSchemeType, FormValue } from "./types";
4
5
  type PropsType<T, Form> = [
5
6
  props?: {
@@ -185,7 +186,7 @@ type PropsType<T, Form> = [
185
186
  *
186
187
  * @returns {object} Объект с методами и состоянием формы (см. таблицу выше).
187
188
  */
188
- export declare function useForm<Form, T extends Partial<Form> = Partial<Form>>(...args: PropsType<T, Form>): {
189
+ export declare function useForm<Form, T extends DeepNullable<Partial<Form>> = DeepNullable<Partial<Form>>>(...args: PropsType<T, Form>): {
189
190
  formData: T | undefined;
190
191
  setFormData: (formData: T) => void;
191
192
  getFormData: () => T | undefined;
@@ -193,7 +194,7 @@ export declare function useForm<Form, T extends Partial<Form> = Partial<Form>>(.
193
194
  setErrors: (errors: FormErrorsType<T>) => void;
194
195
  getField: <P extends FormPath<T>>(path: P) => FormValue<T, P> | undefined;
195
196
  getFieldSync: <P extends FormPath<T>>(path: P) => FormValue<T, P> | undefined;
196
- setField: <P extends FormPath<T>>(path: P, value: FormValue<T, P> | undefined) => void;
197
+ setField: <P extends FormPath<T>>(path: P, value: FormValue<T, P> | null | undefined) => void;
197
198
  getError: <P extends FormPath<T>>(path: P) => FormErrorType | undefined;
198
199
  setError: <P extends FormPath<T>>(path: P, error: FormErrorType) => void;
199
200
  highlightField: <P extends ExtendFormPath<T>>(path: P) => Promise<void>;
@@ -14,4 +14,7 @@ export type IsTuple<T> = T extends readonly any[] ? number extends T['length'] ?
14
14
  export type NegativeBoolean<T> = T extends true ? false : true;
15
15
  export type NotTuple<T> = NegativeBoolean<IsTuple<T>>;
16
16
  export type BuildTuple<N extends number, T extends any[] = []> = T['length'] extends N ? T : BuildTuple<N, [...T, N]>;
17
+ export type DeepNullable<T> = {
18
+ [K in keyof T]: DeepNullable<T[K]> | null;
19
+ };
17
20
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "indicator-ui",
3
- "version": "0.1.64",
3
+ "version": "0.1.65",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/types/src/index.d.ts",
6
6
  "style": "dist/index.css",