This commit is contained in:
morgan
2026-03-13 19:23:37 +03:00
parent 8917f1631f
commit cc7403191a
5113 changed files with 168404 additions and 0 deletions

167
node_modules/react-hook-form/README.md generated vendored Normal file
View File

@@ -0,0 +1,167 @@
<div align="center">
<a href="https://react-hook-form.com" title="React Hook Form - Simple React forms validation">
<img src="https://raw.githubusercontent.com/react-hook-form/react-hook-form/master/docs/logo.png" alt="React Hook Form Logo - React hook custom hook for form validation" />
</a>
</div>
<div align="center">
[![npm downloads](https://img.shields.io/npm/dm/react-hook-form.svg?style=for-the-badge)](https://www.npmjs.com/package/react-hook-form)
[![npm](https://img.shields.io/npm/dt/react-hook-form.svg?style=for-the-badge)](https://www.npmjs.com/package/react-hook-form)
[![npm](https://img.shields.io/npm/l/react-hook-form?style=for-the-badge)](https://github.com/react-hook-form/react-hook-form/blob/master/LICENSE)
[![Discord](https://img.shields.io/discord/754891658327359538.svg?style=for-the-badge&label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/yYv7GZ8)
</div>
<p align="center">
<a href="https://react-hook-form.com/get-started">Get started</a> |
<a href="https://react-hook-form.com/docs">API</a> |
<a href="https://react-hook-form.com/form-builder">Form Builder</a> |
<a href="https://react-hook-form.com/faqs">FAQs</a> |
<a href="https://github.com/react-hook-form/react-hook-form/tree/master/examples">Examples</a>
</p>
### Features
- Built with performance, UX and DX in mind
- Embraces native HTML form [validation](https://react-hook-form.com/get-started#Applyvalidation)
- Out of the box integration with [UI libraries](https://codesandbox.io/s/react-hook-form-v7-controller-5h1q5)
- [Small size](https://bundlephobia.com/result?p=react-hook-form@latest) and no [dependencies](./package.json)
- Support [Yup](https://github.com/jquense/yup), [Zod](https://github.com/colinhacks/zod), [AJV](https://github.com/ajv-validator/ajv), [Superstruct](https://github.com/ianstormtaylor/superstruct), [Joi](https://github.com/hapijs/joi) and [others](https://github.com/react-hook-form/resolvers)
### Install
npm install react-hook-form
### Quickstart
```jsx
import { useForm } from 'react-hook-form';
function App() {
const {
register,
handleSubmit,
formState: { errors },
} = useForm();
return (
<form onSubmit={handleSubmit((data) => console.log(data))}>
<input {...register('firstName')} />
<input {...register('lastName', { required: true })} />
{errors.lastName && <p>Last name is required.</p>}
<input {...register('age', { pattern: /\d+/ })} />
{errors.age && <p>Please enter number for age.</p>}
<input type="submit" />
</form>
);
}
```
### Sponsors
Thanks go to these kind and lovely sponsors!
<a target="_blank" href='https://workleap.com/'>
<img width="94" src="https://images.opencollective.com/workleap/db82f38/logo/256.png?height=256" />
</a>
<a target="_blank" href='https://www.sgkb.ch/'>
<img width="94" src="https://images.opencollective.com/st-galler-kantonalbank-ag/bfdd17f/logo/256.png?height=256" />
</a>
<a target="_blank" href='https://www.sanity.io/'>
<img width="94" src="https://images.opencollective.com/sanity_io/558f87f/logo/256.png?height=256" />
</a>
<a target="_blank" href='https://route4me.com/'>
<img width="94" src="https://images.opencollective.com/route4me/71fb6fa/avatar/256.png?height=256" />
</a>
<a target="_blank" href='https://twicsy.com/'>
<img width="94" src="https://images.opencollective.com/buy-instagram-followers-twicsy/b4c5d7f/logo/256.png?height=256" />
</a>
<a target="_blank" href='https://toss.im'>
<img width="94" src="https://images.opencollective.com/toss/3ed69b3/logo/256.png" />
</a>
<a target="_blank" href='https://principal.com/about-us'>
<img width="94" src="https://images.opencollective.com/principal/431e690/logo/256.png?height=256" />
</a>
<a target="_blank" href="https://graphcms.com">
<img width="94" src="https://avatars.githubusercontent.com/u/31031438" />
</a>
<a target="_blank" href="https://www.beekai.com/">
<img width="94" src="https://www.beekai.com/marketing/logo/logo.svg" />
</a>
<a target="_blank" href="https://kanamekey.com">
<img width="94" src="https://images.opencollective.com/kaname/d15fd98/logo/256.png" />
</a>
<a target="_blank" href="https://www.casinoreviews.net/">
<img width="94" src="https://images.opencollective.com/casinoreviews/f0877d1/logo/256.png" />
</a>
### Past sponsors
<a href="https://www.leniolabs.com/" target="_blank">
<img src="https://images.opencollective.com/leniolabs_/63e9b6e/logo/256.png" width="48" height="48" />
</a>
<a target="_blank" href="https://underbelly.is">
<img width="48" src="https://images.opencollective.com/underbelly/989a4a6/logo/256.png" />
</a>
<a target="_blank" href="https://feathery.io">
<img width="48" src="https://images.opencollective.com/feathery1/c29b0a1/logo/256.png" />
</a>
<a target="_blank" href="https://getform.io">
<img width="48" src="https://images.opencollective.com/getformio2/3c978c8/avatar/256.png" />
</a>
<a href="https://marmelab.com/" target="_blank">
<img src="https://images.opencollective.com/marmelab/d7fd82f/logo/256.png" width="48" height="48" />
</a>
<a target="_blank" href="https://formcarry.com/">
<img width="48" src="https://images.opencollective.com/formcarry/a40a4ea/logo/256.png" />
</a>
<a target="_blank" href="https://fabform.io">
<img width="48" src="https://images.opencollective.com/fabform/2834037/logo/256.png" />
</a>
<a target="_blank" href="https://www.thinkmill.com.au/">
<img width="48" src="https://images.opencollective.com/thinkmill/28910ec/logo/256.png" />
</a>
<a target="_blank" href="https://kwork.studio/">
<img width="48" src="https://images.opencollective.com/knowledge-work/f91b72d/logo/256.png" />
</a>
<a target="_blank" href="https://fiberplane.com/">
<img width="48" src="https://avatars.githubusercontent.com/u/61152955?s=200&v=4" />
</a>
<a target="_blank" href="https://www.jetbrains.com/">
<img width="48" src="https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.png" />
</a>
<a target="_blank" href="https://www.mirakl.com/">
<img width="48" src="https://images.opencollective.com/mirakl/0b191f0/logo/256.png" />
</a>
<a target="_blank" href='https://wantedlyinc.com'>
<img width="48" src="https://images.opencollective.com/wantedly/d94e44e/logo/256.png" />
</a>
### Backers
Thanks go to all our backers! [[Become a backer](https://opencollective.com/react-hook-form#backer)].
<a href="https://opencollective.com/react-hook-form#backers">
<img src="https://opencollective.com/react-hook-form/backers.svg?width=950" />
</a>
### Contributors
Thanks go to these wonderful people! [[Become a contributor](CONTRIBUTING.md)].
<a href="https://github.com/react-hook-form/react-hook-form/graphs/contributors">
<img src="https://opencollective.com/react-hook-form/contributors.svg?width=890&button=false" />
</a>
<br />
<br />
<a href="https://ui.dev/bytes/?r=bill">
<img src="https://raw.githubusercontent.com/react-hook-form/react-hook-form/master/docs/ads-1.jpeg" />
</a>
<br />
<br />
<p align="center">Documentation website supported and backed by <a href="https://vercel.com"><b>Vercel</b></a></p>

View File

@@ -0,0 +1 @@
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../src/controller.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGlE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,QAAA,MAAM,UAAU,GACd,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,KAAK,SAAS,SAAS,CAAC,YAAY,CAAC,GAAG,SAAS,CAAC,YAAY,CAAC,EAC/D,kBAAkB,GAAG,YAAY,EAEjC,OAAO,eAAe,CAAC,YAAY,EAAE,KAAK,EAAE,kBAAkB,CAAC,+FAEY,CAAC;AAE9E,OAAO,EAAE,UAAU,EAAE,CAAC"}

27
node_modules/react-hook-form/dist/form.d.ts generated vendored Normal file
View File

@@ -0,0 +1,27 @@
import React from 'react';
import { FieldValues, FormProps } from './types';
/**
* Form component to manage submission.
*
* @param props - to setup submission detail. {@link FormProps}
*
* @returns form component or headless render prop.
*
* @example
* ```tsx
* function App() {
* const { control, formState: { errors } } = useForm();
*
* return (
* <Form action="/api" control={control}>
* <input {...register("name")} />
* <p>{errors?.root?.server && 'Server error'}</p>
* <button>Submit</button>
* </Form>
* );
* }
* ```
*/
declare function Form<TFieldValues extends FieldValues, TTransformedValues = TFieldValues>(props: FormProps<TFieldValues, TTransformedValues>): React.JSX.Element;
export { Form };
//# sourceMappingURL=form.d.ts.map

View File

@@ -0,0 +1,4 @@
import { InternalFieldErrors, InternalFieldName, ValidateResult } from '../types';
declare const _default: (name: InternalFieldName, validateAllFieldCriteria: boolean, errors: InternalFieldErrors, type: string, message: ValidateResult) => {};
export default _default;
//# sourceMappingURL=appendErrors.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getCheckboxValue.d.ts","sourceRoot":"","sources":["../../src/logic/getCheckboxValue.ts"],"names":[],"mappings":"AAEA,KAAK,mBAAmB,GAAG;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,GAAG,SAAS,CAAC;CAChD,CAAC;yBASc,UAAU,gBAAgB,EAAE,KAAG,mBAAmB;AAAlE,wBAoBE"}

View File

@@ -0,0 +1 @@
{"version":3,"file":"getFieldValue.d.ts","sourceRoot":"","sources":["../../src/logic/getFieldValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAWjC,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EAAE,EAAE,KAAK,CAAC,IAAI,CAAC,OAoBpD"}

View File

@@ -0,0 +1,3 @@
declare const _default: (name: string) => string;
export default _default;
//# sourceMappingURL=getNodeParentName.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getProxyFormState.d.ts","sourceRoot":"","sources":["../../src/logic/getProxyFormState.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;yBAGxE,YAAY,SAAS,WAAW,EAChC,QAAQ,GAAG,GAAG,EACd,kBAAkB,GAAG,YAAY,EAEjC,WAAW,SAAS,CAAC,YAAY,CAAC,EAClC,SAAS,OAAO,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,CAAC,EAC5D,sBAAsB,aAAa,EACnC,gBAAa;AARf,wBA8BE"}

View File

@@ -0,0 +1,4 @@
import { ValidationRule, ValidationValue, ValidationValueMessage } from '../types';
declare const _default: <T extends ValidationValue>(rule?: ValidationRule<T> | ValidationValueMessage<T>) => string | T | undefined;
export default _default;
//# sourceMappingURL=getRuleValue.d.ts.map

View File

@@ -0,0 +1,4 @@
import { FieldError, FieldErrors, FieldValues, InternalFieldName } from '../types';
declare const _default: <T extends FieldValues = FieldValues>(errors: FieldErrors<T>, error: Partial<Record<string, FieldError>>, name: InternalFieldName) => FieldErrors<T>;
export default _default;
//# sourceMappingURL=updateFieldArrayRootError.d.ts.map

711
node_modules/react-hook-form/dist/types/form.d.ts generated vendored Normal file
View File

@@ -0,0 +1,711 @@
import React from 'react';
import { VALIDATION_MODE } from '../constants';
import { Subject, Subscription } from '../utils/createSubject';
import { ErrorOption, FieldError, FieldErrors } from './errors';
import { EventType } from './events';
import { FieldArray } from './fieldArray';
import { FieldName, FieldRefs, FieldValue, FieldValues, InternalFieldName } from './fields';
import { FieldArrayPath, FieldPath, FieldPathValue, FieldPathValues } from './path';
import { Resolver } from './resolvers';
import { DeepMap, DeepPartial, Noop } from './utils';
import { RegisterOptions } from './validator';
declare const $NestedValue: unique symbol;
/**
* @deprecated to be removed in the next major version
*/
export type NestedValue<TValue extends object = object> = {
[$NestedValue]: never;
} & TValue;
export type DefaultValues<TFieldValues> = TFieldValues extends AsyncDefaultValues<TFieldValues> ? DeepPartial<Awaited<TFieldValues>> : DeepPartial<TFieldValues>;
export type InternalNameSet = Set<InternalFieldName>;
export type ValidationMode = typeof VALIDATION_MODE;
export type Mode = keyof ValidationMode;
export type ValidationModeFlags = {
isOnSubmit: boolean;
isOnBlur: boolean;
isOnChange: boolean;
isOnAll: boolean;
isOnTouch: boolean;
};
export type CriteriaMode = 'firstError' | 'all';
export type SubmitHandler<T> = (data: T, event?: React.BaseSyntheticEvent) => unknown | Promise<unknown>;
export type FormSubmitHandler<TTransformedValues> = (payload: {
data: TTransformedValues;
event?: React.BaseSyntheticEvent;
formData: FormData;
formDataJson: string;
method?: 'post' | 'put' | 'delete';
}) => unknown | Promise<unknown>;
export type SubmitErrorHandler<TFieldValues extends FieldValues> = (errors: FieldErrors<TFieldValues>, event?: React.BaseSyntheticEvent) => unknown | Promise<unknown>;
export type SetValueConfig = Partial<{
shouldValidate: boolean;
shouldDirty: boolean;
shouldTouch: boolean;
}>;
export type TriggerConfig = Partial<{
shouldFocus: boolean;
}>;
export type ChangeHandler = (event: {
target: any;
type?: any;
}) => Promise<void | boolean>;
export type DelayCallback = (wait: number) => void;
type AsyncDefaultValues<TFieldValues> = (payload?: unknown) => Promise<TFieldValues>;
export type UseFormProps<TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues = TFieldValues> = Partial<{
mode: Mode;
disabled: boolean;
reValidateMode: Exclude<Mode, 'onTouched' | 'all'>;
defaultValues: DefaultValues<TFieldValues> | AsyncDefaultValues<TFieldValues>;
values: TFieldValues;
errors: FieldErrors<TFieldValues>;
resetOptions: Parameters<UseFormReset<TFieldValues>>[1];
resolver: Resolver<TFieldValues, TContext, TTransformedValues>;
context: TContext;
shouldFocusError: boolean;
shouldUnregister: boolean;
shouldUseNativeValidation: boolean;
progressive: boolean;
criteriaMode: CriteriaMode;
delayError: number;
formControl?: Omit<UseFormReturn<TFieldValues, TContext, TTransformedValues>, 'formState'>;
}>;
export type FieldNamesMarkedBoolean<TFieldValues extends FieldValues> = DeepMap<DeepPartial<TFieldValues>, boolean>;
export type FormStateProxy<TFieldValues extends FieldValues = FieldValues> = {
isDirty: boolean;
isValidating: boolean;
dirtyFields: FieldNamesMarkedBoolean<TFieldValues>;
touchedFields: FieldNamesMarkedBoolean<TFieldValues>;
validatingFields: FieldNamesMarkedBoolean<TFieldValues>;
errors: boolean;
isValid: boolean;
};
export type ReadFormState = {
[K in keyof FormStateProxy]: boolean | 'all';
} & {
values?: boolean;
};
export type FormState<TFieldValues extends FieldValues> = {
isDirty: boolean;
isLoading: boolean;
isSubmitted: boolean;
isSubmitSuccessful: boolean;
isSubmitting: boolean;
isValidating: boolean;
isValid: boolean;
disabled: boolean;
submitCount: number;
defaultValues?: undefined | Readonly<DeepPartial<TFieldValues>>;
dirtyFields: Partial<Readonly<FieldNamesMarkedBoolean<TFieldValues>>>;
touchedFields: Partial<Readonly<FieldNamesMarkedBoolean<TFieldValues>>>;
validatingFields: Partial<Readonly<FieldNamesMarkedBoolean<TFieldValues>>>;
errors: FieldErrors<TFieldValues>;
};
export type KeepStateOptions = Partial<{
keepDirtyValues: boolean;
keepErrors: boolean;
keepDirty: boolean;
keepValues: boolean;
keepDefaultValues: boolean;
keepIsSubmitted: boolean;
keepIsSubmitSuccessful: boolean;
keepTouched: boolean;
keepIsValidating: boolean;
keepIsValid: boolean;
keepSubmitCount: boolean;
}>;
export type SetFieldValue<TFieldValues extends FieldValues> = FieldValue<TFieldValues>;
export type RefCallBack = (instance: any) => void;
export type UseFormRegisterReturn<TFieldName extends InternalFieldName = InternalFieldName> = {
onChange: ChangeHandler;
onBlur: ChangeHandler;
ref: RefCallBack;
name: TFieldName;
min?: string | number;
max?: string | number;
maxLength?: number;
minLength?: number;
pattern?: string;
required?: boolean;
disabled?: boolean;
};
/**
* Register field into hook form with or without the actual DOM ref. You can invoke register anywhere in the component including at `useEffect`.
*
* @remarks
* [API](https://react-hook-form.com/docs/useform/register) • [Demo](https://codesandbox.io/s/react-hook-form-register-ts-ip2j3) • [Video](https://www.youtube.com/watch?v=JFIpCoajYkA)
*
* @param name - the path name to the form field value, name is required and unique
* @param options - register options include validation, disabled, unregister, value as and dependent validation
*
* @returns onChange, onBlur, name, ref, and native contribute attribute if browser validation is enabled.
*
* @example
* ```tsx
* // Register HTML native input
* <input {...register("input")} />
* <select {...register("select")} />
*
* // Register options
* <textarea {...register("textarea", { required: "This is required.", maxLength: 20 })} />
* <input type="number" {...register("name2", { valueAsNumber: true })} />
* <input {...register("name3", { deps: ["name2"] })} />
*
* // Register custom field at useEffect
* useEffect(() => {
* register("name4");
* register("name5", { value: "hiddenValue" });
* }, [register])
*
* // Register without ref
* const { onChange, onBlur, name } = register("name6")
* <input onChange={onChange} onBlur={onBlur} name={name} />
* ```
*/
export type UseFormRegister<TFieldValues extends FieldValues> = <TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>(name: TFieldName, options?: RegisterOptions<TFieldValues, TFieldName>) => UseFormRegisterReturn<TFieldName>;
export type SetFocusOptions = Partial<{
shouldSelect: boolean;
}>;
/**
* Set focus on a registered field. You can start to invoke this method after all fields are mounted to the DOM.
*
* @remarks
* [API](https://react-hook-form.com/docs/useform/setfocus) • [Demo](https://codesandbox.io/s/setfocus-rolus)
*
* @param name - the path name to the form field value.
* @param options - input focus behavior options
*
* @example
* ```tsx
* useEffect(() => {
* setFocus("name");
* }, [setFocus])
* // shouldSelect allows to select input's content on focus
* <button onClick={() => setFocus("name", { shouldSelect: true })}>Focus</button>
* ```
*/
export type UseFormSetFocus<TFieldValues extends FieldValues> = <TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>(name: TFieldName, options?: SetFocusOptions) => void;
export type UseFormGetValues<TFieldValues extends FieldValues> = {
/**
* Get the entire form values when no argument is supplied to this function.
*
* @remarks
* [API](https://react-hook-form.com/docs/useform/getvalues) • [Demo](https://codesandbox.io/s/react-hook-form-v7-ts-getvalues-txsfg)
*
* @returns form values
*
* @example
* ```tsx
* <button onClick={() => getValues()}>getValues</button>
*
* <input {...register("name", {
* validate: (value, formValues) => formValues.otherField === value;
* })} />
* ```
*/
(): TFieldValues;
/**
* Get a single field value.
*
* @remarks
* [API](https://react-hook-form.com/docs/useform/getvalues) • [Demo](https://codesandbox.io/s/react-hook-form-v7-ts-getvalues-txsfg)
*
* @param name - the path name to the form field value.
*
* @returns the single field value
*
* @example
* ```tsx
* <button onClick={() => getValues("name")}>getValues</button>
*
* <input {...register("name", {
* validate: () => getValues('otherField') === "test";
* })} />
* ```
*/
<TFieldName extends FieldPath<TFieldValues>>(name: TFieldName): FieldPathValue<TFieldValues, TFieldName>;
/**
* Get an array of field values.
*
* @remarks
* [API](https://react-hook-form.com/docs/useform/getvalues) • [Demo](https://codesandbox.io/s/react-hook-form-v7-ts-getvalues-txsfg)
*
* @param names - an array of field names
*
* @returns An array of field values
*
* @example
* ```tsx
* <button onClick={() => getValues(["name", "name1"])}>getValues</button>
*
* <input {...register("name", {
* validate: () => getValues(["fieldA", "fieldB"]).includes("test");
* })} />
* ```
*/
<TFieldNames extends FieldPath<TFieldValues>[]>(names: readonly [...TFieldNames]): [...FieldPathValues<TFieldValues, TFieldNames>];
};
/**
* This method will return individual field states. It will be useful when you are trying to retrieve the nested value field state in a typesafe approach.
*
* @remarks
* [API](https://react-hook-form.com/docs/useform/getfieldstate) • [Demo](https://codesandbox.io/s/getfieldstate-jvekk)
*
* @param name - the path name to the form field value.
*
* @returns invalid, isDirty, isTouched and error object
*
* @example
* ```tsx
* // those formState has to be subscribed
* const { formState: { dirtyFields, errors, touchedFields } } = formState();
* getFieldState('name')
* // Get field state when form state is not subscribed yet
* getFieldState('name', formState)
*
* // It's ok to combine with useFormState
* const formState = useFormState();
* getFieldState('name')
* getFieldState('name', formState)
* ```
*/
export type UseFormGetFieldState<TFieldValues extends FieldValues> = <TFieldName extends FieldPath<TFieldValues>>(name: TFieldName, formState?: FormState<TFieldValues>) => {
invalid: boolean;
isDirty: boolean;
isTouched: boolean;
isValidating: boolean;
error?: FieldError;
};
/**
* This method will allow you to subscribe to formState without component render
*
* @remarks
* [API](https://react-hook-form.com/docs/useform/subscribe) • [Demo](https://codesandbox.io/s/subscribe)
*
* @param options - subscription options on which formState subscribe to
*
* @example
* ```tsx
const { subscribe } = useForm()
useEffect(() => {
subscribe({
formState: { isDirty: true },
callback: () => {}
})
})
* ```
*/
export type UseFromSubscribe<TFieldValues extends FieldValues> = (payload: {
name?: string;
formState?: Partial<ReadFormState>;
callback: (data: Partial<FormState<TFieldValues>> & {
values: TFieldValues;
}) => void;
exact?: boolean;
}) => () => void;
export type UseFormWatch<TFieldValues extends FieldValues> = {
/**
* Watch and subscribe to the entire form update/change based on onChange and re-render at the useForm.
*
* @remarks
* [API](https://react-hook-form.com/docs/useform/watch) • [Demo](https://codesandbox.io/s/react-hook-form-watch-v7-ts-8et1d) • [Video](https://www.youtube.com/watch?v=3qLd69WMqKk)
*
* @returns return the entire form values
*
* @example
* ```tsx
* const formValues = watch();
* ```
*/
(): TFieldValues;
/**
* Watch and subscribe to an array of fields used outside of render.
*
* @remarks
* [API](https://react-hook-form.com/docs/useform/watch) • [Demo](https://codesandbox.io/s/react-hook-form-watch-v7-ts-8et1d) • [Video](https://www.youtube.com/watch?v=3qLd69WMqKk)
*
* @param names - an array of field names
* @param defaultValue - defaultValues for the entire form
*
* @returns return an array of field values
*
* @example
* ```tsx
* const [name, name1] = watch(["name", "name1"]);
* ```
*/
<TFieldNames extends readonly FieldPath<TFieldValues>[]>(names: readonly [...TFieldNames], defaultValue?: DeepPartial<TFieldValues>): FieldPathValues<TFieldValues, TFieldNames>;
/**
* Watch and subscribe to a single field used outside of render.
*
* @remarks
* [API](https://react-hook-form.com/docs/useform/watch) • [Demo](https://codesandbox.io/s/react-hook-form-watch-v7-ts-8et1d) • [Video](https://www.youtube.com/watch?v=3qLd69WMqKk)
*
* @param name - the path name to the form field value.
* @param defaultValue - defaultValues for the entire form
*
* @returns return the single field value
*
* @example
* ```tsx
* const name = watch("name");
* ```
*/
<TFieldName extends FieldPath<TFieldValues>>(name: TFieldName, defaultValue?: FieldPathValue<TFieldValues, TFieldName>): FieldPathValue<TFieldValues, TFieldName>;
/**
* Subscribe to field update/change without trigger re-render
*
* @remarks
* [API](https://react-hook-form.com/docs/useform/watch) • [Demo](https://codesandbox.io/s/react-hook-form-watch-v7-ts-8et1d) • [Video](https://www.youtube.com/watch?v=3qLd69WMqKk)
*
* @param callback - call back function to subscribe all fields change and return unsubscribe function
* @param defaultValues - defaultValues for the entire form
*
* @returns unsubscribe function
*
* @example
* ```tsx
* useEffect(() => {
* const { unsubscribe } = watch((value) => {
* console.log(value);
* });
* return () => unsubscribe();
* }, [watch])
* ```
*/
(callback: WatchObserver<TFieldValues>, defaultValues?: DeepPartial<TFieldValues>): Subscription;
};
/**
* Trigger field or form validation
*
* @remarks
* [API](https://react-hook-form.com/docs/useform/trigger) • [Demo](https://codesandbox.io/s/react-hook-form-v7-ts-triggervalidation-forked-xs7hl) • [Video](https://www.youtube.com/watch?v=-bcyJCDjksE)
*
* @param name - provide empty argument will trigger the entire form validation, an array of field names will validate an array of fields, and a single field name will only trigger that field's validation.
* @param options - should focus on the error field
*
* @returns validation result
*
* @example
* ```tsx
* useEffect(() => {
* trigger();
* }, [trigger])
*
* <button onClick={async () => {
* const result = await trigger(); // result will be a boolean value
* }}>
* trigger
* </button>
* ```
*/
export type UseFormTrigger<TFieldValues extends FieldValues> = (name?: FieldPath<TFieldValues> | FieldPath<TFieldValues>[] | readonly FieldPath<TFieldValues>[], options?: TriggerConfig) => Promise<boolean>;
/**
* Clear the entire form errors.
*
* @remarks
* [API](https://react-hook-form.com/docs/useform/clearerrors) • [Demo](https://codesandbox.io/s/react-hook-form-v7-ts-clearerrors-w3ymx)
*
* @param name - the path name to the form field value.
*
* @example
* Clear all errors
* ```tsx
* clearErrors(); // clear the entire form error
* clearErrors(["name", "name1"]) // clear an array of fields' error
* clearErrors("name2"); // clear a single field error
* ```
*/
export type UseFormClearErrors<TFieldValues extends FieldValues> = (name?: FieldPath<TFieldValues> | FieldPath<TFieldValues>[] | readonly FieldPath<TFieldValues>[] | `root.${string}` | 'root') => void;
/**
* Set a single field value, or a group of fields value.
*
* @remarks
* [API](https://react-hook-form.com/docs/useform/setvalue) • [Demo](https://codesandbox.io/s/react-hook-form-v7-ts-setvalue-8z9hx) • [Video](https://www.youtube.com/watch?v=qpv51sCH3fI)
*
* @param name - the path name to the form field value.
* @param value - field value
* @param options - should validate or update form state
*
* @example
* ```tsx
* // Update a single field
* setValue('name', 'value', {
* shouldValidate: true, // trigger validation
* shouldTouch: true, // update touched fields form state
* shouldDirty: true, // update dirty and dirty fields form state
* });
*
* // Update a group fields
* setValue('root', {
* a: 'test', // setValue('root.a', 'data')
* b: 'test1', // setValue('root.b', 'data')
* });
*
* // Update a nested object field
* setValue('select', { label: 'test', value: 'Test' });
* ```
*/
export type UseFormSetValue<TFieldValues extends FieldValues> = <TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>(name: TFieldName, value: FieldPathValue<TFieldValues, TFieldName>, options?: SetValueConfig) => void;
/**
* Set an error for the field. When set an error which is not associated to a field then manual `clearErrors` invoke is required.
*
* @remarks
* [API](https://react-hook-form.com/docs/useform/seterror) • [Demo](https://codesandbox.io/s/react-hook-form-v7-ts-seterror-nfxxu) • [Video](https://www.youtube.com/watch?v=raMqvE0YyIY)
*
* @param name - the path name to the form field value.
* @param error - an error object which contains type and optional message
* @param options - whether or not to focus on the field
*
* @example
* ```tsx
* // when the error is not associated with any fields, `clearError` will need to invoke to clear the error
* const onSubmit = () => setError("serverError", { type: "server", message: "Error occurred"})
*
* <button onClick={() => setError("name", { type: "min" })} />
*
* // focus on the input after setting the error
* <button onClick={() => setError("name", { type: "max" }, { shouldFocus: true })} />
* ```
*/
export type UseFormSetError<TFieldValues extends FieldValues> = (name: FieldPath<TFieldValues> | `root.${string}` | 'root', error: ErrorOption, options?: {
shouldFocus: boolean;
}) => void;
/**
* Unregister a field reference and remove its value.
*
* @remarks
* [API](https://react-hook-form.com/docs/useform/unregister) • [Demo](https://codesandbox.io/s/react-hook-form-unregister-4k2ey) • [Video](https://www.youtube.com/watch?v=TM99g_NW5Gk&feature=emb_imp_woyt)
*
* @param name - the path name to the form field value.
* @param options - keep form state options
*
* @example
* ```tsx
* register("name", { required: true })
*
* <button onClick={() => unregister("name")} />
* // there are various keep options to retain formState
* <button onClick={() => unregister("name", { keepErrors: true })} />
* ```
*/
export type UseFormUnregister<TFieldValues extends FieldValues> = (name?: FieldPath<TFieldValues> | FieldPath<TFieldValues>[] | readonly FieldPath<TFieldValues>[], options?: Omit<KeepStateOptions, 'keepIsSubmitted' | 'keepSubmitCount' | 'keepValues' | 'keepDefaultValues' | 'keepErrors'> & {
keepValue?: boolean;
keepDefaultValue?: boolean;
keepError?: boolean;
}) => void;
/**
* Validate the entire form. Handle submit and error callback.
*
* @remarks
* [API](https://react-hook-form.com/docs/useform/handlesubmit) • [Demo](https://codesandbox.io/s/react-hook-form-handlesubmit-ts-v7-lcrtu) • [Video](https://www.youtube.com/watch?v=KzcPKB9SOEk)
*
* @param onValid - callback function invoked after form pass validation
* @param onInvalid - callback function invoked when form failed validation
*
* @returns callback - return callback function
*
* @example
* ```tsx
* const onSubmit = (data) => console.log(data);
* const onError = (error) => console.log(error);
*
* <form onSubmit={handleSubmit(onSubmit, onError)} />
* ```
*/
export type UseFormHandleSubmit<TFieldValues extends FieldValues, TTransformedValues = TFieldValues> = (onValid: SubmitHandler<TTransformedValues>, onInvalid?: SubmitErrorHandler<TFieldValues>) => (e?: React.BaseSyntheticEvent) => Promise<void>;
/**
* Reset a field state and reference.
*
* @remarks
* [API](https://react-hook-form.com/docs/useform/resetfield) • [Demo](https://codesandbox.io/s/priceless-firefly-d0kuv) • [Video](https://www.youtube.com/watch?v=IdLFcNaEFEo)
*
* @param name - the path name to the form field value.
* @param options - keep form state options
*
* @example
* ```tsx
* <input {...register("firstName", { required: true })} />
* <button type="button" onClick={() => resetField("firstName"))}>Reset</button>
* ```
*/
export type UseFormResetField<TFieldValues extends FieldValues> = <TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>(name: TFieldName, options?: Partial<{
keepDirty: boolean;
keepTouched: boolean;
keepError: boolean;
defaultValue: FieldPathValue<TFieldValues, TFieldName>;
}>) => void;
type ResetAction<TFieldValues> = (formValues: TFieldValues) => TFieldValues;
/**
* Reset at the entire form state.
*
* @remarks
* [API](https://react-hook-form.com/docs/useform/reset) • [Demo](https://codesandbox.io/s/react-hook-form-reset-v7-ts-pu901) • [Video](https://www.youtube.com/watch?v=qmCLBjyPwVk)
*
* @param values - the entire form values to be reset
* @param keepStateOptions - keep form state options
*
* @example
* ```tsx
* useEffect(() => {
* // reset the entire form after component mount or form defaultValues is ready
* reset({
* fieldA: "test"
* fieldB: "test"
* });
* }, [reset])
*
* // reset by combine with existing form values
* reset({
* ...getValues(),
* fieldB: "test"
*});
*
* // reset and keep form state
* reset({
* ...getValues(),
*}, {
* keepErrors: true,
* keepDirty: true
*});
* ```
*/
export type UseFormReset<TFieldValues extends FieldValues> = (values?: DefaultValues<TFieldValues> | TFieldValues | ResetAction<TFieldValues>, keepStateOptions?: KeepStateOptions) => void;
export type WatchInternal<TFieldValues> = (fieldNames?: InternalFieldName | InternalFieldName[], defaultValue?: DeepPartial<TFieldValues>, isMounted?: boolean, isGlobal?: boolean) => FieldPathValue<FieldValues, InternalFieldName> | FieldPathValues<FieldValues, InternalFieldName[]>;
export type GetIsDirty = <TName extends InternalFieldName, TData>(name?: TName, data?: TData) => boolean;
export type FormStateSubjectRef<TFieldValues extends FieldValues> = Subject<Partial<FormState<TFieldValues>> & {
name?: InternalFieldName;
values?: TFieldValues;
type?: EventType;
}>;
export type Subjects<TFieldValues extends FieldValues = FieldValues> = {
array: Subject<{
name?: InternalFieldName;
values?: FieldValues;
}>;
state: FormStateSubjectRef<TFieldValues>;
};
export type Names = {
mount: InternalNameSet;
unMount: InternalNameSet;
disabled: InternalNameSet;
array: InternalNameSet;
watch: InternalNameSet;
focus?: InternalFieldName;
watchAll?: boolean;
};
export type BatchFieldArrayUpdate = <T extends Function, TFieldValues extends FieldValues, TFieldArrayName extends FieldArrayPath<TFieldValues> = FieldArrayPath<TFieldValues>>(name: InternalFieldName, updatedFieldArrayValues?: Partial<FieldArray<TFieldValues, TFieldArrayName>>[], method?: T, args?: Partial<{
argA: unknown;
argB: unknown;
}>, shouldSetValue?: boolean, shouldUpdateFieldsAndErrors?: boolean) => void;
export type FromSubscribe<TFieldValues extends FieldValues> = (payload: {
name?: string;
formState?: Partial<ReadFormState>;
callback: (data: Partial<FormState<TFieldValues>> & {
values: TFieldValues;
}) => void;
exact?: boolean;
reRenderRoot?: boolean;
}) => () => void;
export type Control<TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues = TFieldValues> = {
_subjects: Subjects<TFieldValues>;
_removeUnmounted: Noop;
_names: Names;
_state: {
mount: boolean;
action: boolean;
watch: boolean;
};
_reset: UseFormReset<TFieldValues>;
_options: UseFormProps<TFieldValues, TContext, TTransformedValues>;
_getDirty: GetIsDirty;
_resetDefaultValues: Noop;
_formState: FormState<TFieldValues>;
_setValid: (shouldUpdateValid?: boolean) => void;
_fields: FieldRefs;
_formValues: FieldValues;
_proxyFormState: ReadFormState;
_defaultValues: Partial<DefaultValues<TFieldValues>>;
_getWatch: WatchInternal<TFieldValues>;
_setFieldArray: BatchFieldArrayUpdate;
_getFieldArray: <TFieldArrayValues>(name: InternalFieldName) => Partial<TFieldArrayValues>[];
_setErrors: (errors: FieldErrors<TFieldValues>) => void;
_setDisabledField: (props: {
disabled?: boolean;
name: FieldName<any>;
}) => void;
_runSchema: (names: InternalFieldName[]) => Promise<{
errors: FieldErrors;
}>;
_disableForm: (disabled?: boolean) => void;
_subscribe: FromSubscribe<TFieldValues>;
register: UseFormRegister<TFieldValues>;
handleSubmit: UseFormHandleSubmit<TFieldValues, TTransformedValues>;
unregister: UseFormUnregister<TFieldValues>;
getFieldState: UseFormGetFieldState<TFieldValues>;
setError: UseFormSetError<TFieldValues>;
};
export type WatchObserver<TFieldValues extends FieldValues> = (value: DeepPartial<TFieldValues>, info: {
name?: FieldPath<TFieldValues>;
type?: EventType;
values?: unknown;
}) => void;
export type UseFormReturn<TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues = TFieldValues> = {
watch: UseFormWatch<TFieldValues>;
getValues: UseFormGetValues<TFieldValues>;
getFieldState: UseFormGetFieldState<TFieldValues>;
setError: UseFormSetError<TFieldValues>;
clearErrors: UseFormClearErrors<TFieldValues>;
setValue: UseFormSetValue<TFieldValues>;
trigger: UseFormTrigger<TFieldValues>;
formState: FormState<TFieldValues>;
resetField: UseFormResetField<TFieldValues>;
reset: UseFormReset<TFieldValues>;
handleSubmit: UseFormHandleSubmit<TFieldValues, TTransformedValues>;
unregister: UseFormUnregister<TFieldValues>;
control: Control<TFieldValues, TContext, TTransformedValues>;
register: UseFormRegister<TFieldValues>;
setFocus: UseFormSetFocus<TFieldValues>;
subscribe: UseFromSubscribe<TFieldValues>;
};
export type UseFormStateProps<TFieldValues extends FieldValues, TTransformedValues = TFieldValues> = Partial<{
control?: Control<TFieldValues, any, TTransformedValues>;
disabled?: boolean;
name?: FieldPath<TFieldValues> | FieldPath<TFieldValues>[] | readonly FieldPath<TFieldValues>[];
exact?: boolean;
}>;
export type UseFormStateReturn<TFieldValues extends FieldValues> = FormState<TFieldValues>;
export type UseWatchProps<TFieldValues extends FieldValues = FieldValues> = {
defaultValue?: unknown;
disabled?: boolean;
name?: FieldPath<TFieldValues> | FieldPath<TFieldValues>[] | readonly FieldPath<TFieldValues>[];
control?: Control<TFieldValues>;
exact?: boolean;
};
export type FormProviderProps<TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues = TFieldValues> = {
children: React.ReactNode | React.ReactNode[];
} & UseFormReturn<TFieldValues, TContext, TTransformedValues>;
export type FormProps<TFieldValues extends FieldValues, TTransformedValues = TFieldValues> = Omit<React.FormHTMLAttributes<HTMLFormElement>, 'onError' | 'onSubmit'> & Partial<{
control: Control<TFieldValues, any, TTransformedValues>;
headers: Record<string, string>;
validateStatus: (status: number) => boolean;
onError: ({ response, error, }: {
response: Response;
error?: undefined;
} | {
response?: undefined;
error: unknown;
}) => void;
onSuccess: ({ response }: {
response: Response;
}) => void;
onSubmit: FormSubmitHandler<TTransformedValues>;
method: 'post' | 'put' | 'delete';
children: React.ReactNode | React.ReactNode[];
render: (props: {
submit: (e?: React.FormEvent) => void;
}) => React.ReactNode | React.ReactNode[];
encType: 'application/x-www-form-urlencoded' | 'multipart/form-data' | 'text/plain' | 'application/json';
}>;
export {};
//# sourceMappingURL=form.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"useFieldArray.d.ts","sourceRoot":"","sources":["../src/useFieldArray.ts"],"names":[],"mappings":"AAwBA,OAAO,EAKL,cAAc,EAId,WAAW,EAIX,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAGjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,aAAa,CAC3B,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,eAAe,SACb,cAAc,CAAC,YAAY,CAAC,GAAG,cAAc,CAAC,YAAY,CAAC,EAC7D,QAAQ,SAAS,MAAM,GAAG,IAAI,EAC9B,kBAAkB,GAAG,YAAY,EAEjC,KAAK,EAAE,kBAAkB,CACvB,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,kBAAkB,CACnB,GACA,mBAAmB,CAAC,YAAY,EAAE,eAAe,EAAE,QAAQ,CAAC,CAmW9D"}

View File

@@ -0,0 +1 @@
{"version":3,"file":"useFormContext.d.ts","sourceRoot":"","sources":["../src/useFormContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAIxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,cAAc,GACzB,YAAY,SAAS,WAAW,EAChC,QAAQ,GAAG,GAAG,EACd,kBAAkB,GAAG,YAAY,OAC9B,aAAa,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,CAK1D,CAAC;AAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,YAAY,GACvB,YAAY,SAAS,WAAW,EAChC,QAAQ,GAAG,GAAG,EACd,kBAAkB,GAAG,YAAY,EAEjC,OAAO,iBAAiB,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,CAAC,sBAQrE,CAAC"}

View File

@@ -0,0 +1 @@
{"version":3,"file":"compact.d.ts","sourceRoot":"","sources":["../../src/utils/compact.ts"],"names":[],"mappings":"yBAAgB,MAAM,EAAE,OAAO,MAAM,EAAE;AAAvC,wBACoD"}

View File

@@ -0,0 +1,3 @@
declare const _default: (value: unknown) => value is boolean;
export default _default;
//# sourceMappingURL=isBoolean.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"isBoolean.d.ts","sourceRoot":"","sources":["../../src/utils/isBoolean.ts"],"names":[],"mappings":"yBAAgB,OAAO,OAAO,KAAG,KAAK,IAAI,OAAO;AAAjD,wBAAgF"}

View File

@@ -0,0 +1,3 @@
declare const _default: (value: unknown) => value is Date;
export default _default;
//# sourceMappingURL=isDateObject.d.ts.map

View File

@@ -0,0 +1,4 @@
import { FieldElement } from '../types';
declare const _default: (element: FieldElement) => element is HTMLInputElement;
export default _default;
//# sourceMappingURL=isFileInput.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"isMessage.d.ts","sourceRoot":"","sources":["../../src/utils/isMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;yBAGnB,OAAO,OAAO,KAAG,KAAK,IAAI,OAAO;AAAjD,wBAAqE"}

View File

@@ -0,0 +1 @@
{"version":3,"file":"isNullOrUndefined.d.ts","sourceRoot":"","sources":["../../src/utils/isNullOrUndefined.ts"],"names":[],"mappings":"yBAAgB,OAAO,OAAO,KAAG,KAAK,IAAI,IAAI,GAAG,SAAS;AAA1D,wBAA4E"}

3
node_modules/react-hook-form/dist/utils/prepend.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
declare const _default: <T>(data: T[], value: T | T[]) => T[];
export default _default;
//# sourceMappingURL=prepend.d.ts.map

4
node_modules/react-hook-form/dist/utils/set.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
import { FieldPath, FieldValues } from '../types';
declare const _default: (object: FieldValues, path: FieldPath<FieldValues>, value?: unknown) => void;
export default _default;
//# sourceMappingURL=set.d.ts.map