v1.0 with SW PWA enabled

This commit is contained in:
Blomios
2026-01-01 17:40:53 +01:00
parent 1c0e22aac1
commit 3c8bebb2ad
29775 changed files with 2197201 additions and 119080 deletions

View File

@ -0,0 +1,22 @@
export declare const EVENTS: {
readonly BLUR: "blur";
readonly FOCUS_OUT: "focusout";
readonly CHANGE: "change";
};
export declare const VALIDATION_MODE: {
readonly onBlur: "onBlur";
readonly onChange: "onChange";
readonly onSubmit: "onSubmit";
readonly onTouched: "onTouched";
readonly all: "all";
};
export declare const INPUT_VALIDATION_RULES: {
readonly max: "max";
readonly min: "min";
readonly maxLength: "maxLength";
readonly minLength: "minLength";
readonly pattern: "pattern";
readonly required: "required";
readonly validate: "validate";
};
//# sourceMappingURL=constants.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;;CAIT,CAAC;AAEX,eAAO,MAAM,eAAe;;;;;;CAMlB,CAAC;AAEX,eAAO,MAAM,sBAAsB;;;;;;;;CAQzB,CAAC"}

View File

@ -0,0 +1,46 @@
import type { ControllerProps, FieldPath, FieldValues } from './types';
/**
* Component based on `useController` hook to work with controlled component.
*
* @remarks
* [API](https://react-hook-form.com/docs/usecontroller/controller) • [Demo](https://codesandbox.io/s/react-hook-form-v6-controller-ts-jwyzw) • [Video](https://www.youtube.com/watch?v=N2UNk_UCVyA)
*
* @param props - the path name to the form field value, and validation rules.
*
* @returns provide field handler functions, field and form state.
*
* @example
* ```tsx
* function App() {
* const { control } = useForm<FormValues>({
* defaultValues: {
* test: ""
* }
* });
*
* return (
* <form>
* <Controller
* control={control}
* name="test"
* render={({ field: { onChange, onBlur, value, ref }, formState, fieldState }) => (
* <>
* <input
* onChange={onChange} // send value to hook form
* onBlur={onBlur} // notify when input is touched
* value={value} // return updated value
* ref={ref} // set ref for focus management
* />
* <p>{formState.isSubmitted ? "submitted" : ""}</p>
* <p>{fieldState.isTouched ? "touched" : ""}</p>
* </>
* )}
* />
* </form>
* );
* }
* ```
*/
declare const Controller: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TTransformedValues = TFieldValues>(props: ControllerProps<TFieldValues, TName, TTransformedValues>) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
export { Controller };
//# sourceMappingURL=controller.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../src/controller.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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
frontend/node_modules/react-hook-form/dist/form.d.ts generated vendored Normal file
View File

@ -0,0 +1,27 @@
import React from 'react';
import type { 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 @@
{"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../src/form.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAKtD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,iBAAS,IAAI,CACX,YAAY,SAAS,WAAW,EAChC,kBAAkB,GAAG,YAAY,EACjC,KAAK,EAAE,SAAS,CAAC,YAAY,EAAE,kBAAkB,CAAC,qBAmHnD;AAED,OAAO,EAAE,IAAI,EAAE,CAAC"}

View File

@ -0,0 +1,7 @@
import type { ReactNode } from 'react';
import type { FieldValues, UseFormStateProps, UseFormStateReturn } from './types';
export type FormStateSubscribeProps<TFieldValues extends FieldValues, TTransformedValues = TFieldValues> = UseFormStateProps<TFieldValues, TTransformedValues> & {
render: (values: UseFormStateReturn<TFieldValues>) => ReactNode;
};
export declare const FormStateSubscribe: <TFieldValues extends FieldValues, TTransformedValues = TFieldValues>({ control, disabled, exact, name, render, }: FormStateSubscribeProps<TFieldValues, TTransformedValues>) => ReactNode;
//# sourceMappingURL=formStateSubscribe.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"formStateSubscribe.d.ts","sourceRoot":"","sources":["../src/formStateSubscribe.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EACV,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAGjB,MAAM,MAAM,uBAAuB,CACjC,YAAY,SAAS,WAAW,EAChC,kBAAkB,GAAG,YAAY,IAC/B,iBAAiB,CAAC,YAAY,EAAE,kBAAkB,CAAC,GAAG;IACxD,MAAM,EAAE,CAAC,MAAM,EAAE,kBAAkB,CAAC,YAAY,CAAC,KAAK,SAAS,CAAC;CACjE,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,YAAY,SAAS,WAAW,EAChC,kBAAkB,GAAG,YAAY,EACjC,6CAMC,uBAAuB,CAAC,YAAY,EAAE,kBAAkB,CAAC,cACF,CAAC"}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

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

@ -0,0 +1,14 @@
export * from './controller';
export * from './form';
export * from './formStateSubscribe';
export * from './logic';
export * from './types';
export * from './useController';
export * from './useFieldArray';
export * from './useForm';
export * from './useFormContext';
export * from './useFormState';
export * from './useWatch';
export * from './utils';
export * from './watch';
//# sourceMappingURL=index.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,sBAAsB,CAAC;AACrC,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}

2900
frontend/node_modules/react-hook-form/dist/index.esm.mjs generated vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,3 @@
export * from './logic';
export * from './utils';
//# sourceMappingURL=index.react-server.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.react-server.d.ts","sourceRoot":"","sources":["../src/index.react-server.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,4 @@
import type { 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":"appendErrors.d.ts","sourceRoot":"","sources":["../../src/logic/appendErrors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACf,MAAM,UAAU,CAAC;yBAGhB,MAAM,iBAAiB,EACvB,0BAA0B,OAAO,EACjC,QAAQ,mBAAmB,EAC3B,MAAM,MAAM,EACZ,SAAS,cAAc;AALzB,wBAeS"}

View File

@ -0,0 +1,5 @@
import type { FieldValues, UseFormProps, UseFormReturn } from '../types';
export declare function createFormControl<TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues = TFieldValues>(props?: UseFormProps<TFieldValues, TContext, TTransformedValues>): Omit<UseFormReturn<TFieldValues, TContext, TTransformedValues>, 'formState'> & {
formControl: Omit<UseFormReturn<TFieldValues, TContext, TTransformedValues>, 'formState'>;
};
//# sourceMappingURL=createFormControl.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"createFormControl.d.ts","sourceRoot":"","sources":["../../src/logic/createFormControl.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAaV,WAAW,EAiBX,YAAY,EAIZ,aAAa,EAUd,MAAM,UAAU,CAAC;AAqDlB,wBAAgB,iBAAiB,CAC/B,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,QAAQ,GAAG,GAAG,EACd,kBAAkB,GAAG,YAAY,EAEjC,KAAK,GAAE,YAAY,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,CAAM,GACnE,IAAI,CACL,aAAa,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,CAAC,EACzD,WAAW,CACZ,GAAG;IACF,WAAW,EAAE,IAAI,CACf,aAAa,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,CAAC,EACzD,WAAW,CACZ,CAAC;CACH,CAw9CA"}

View File

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

View File

@ -0,0 +1 @@
{"version":3,"file":"generateId.d.ts","sourceRoot":"","sources":["../../src/logic/generateId.ts"],"names":[],"mappings":";AAAA,wBAaE"}

View File

@ -0,0 +1,4 @@
import type { DeepPartial, FieldValues, Names } from '../types';
declare const _default: <T>(names: string | string[] | undefined, _names: Names, formValues?: FieldValues, isGlobal?: boolean, defaultValue?: DeepPartial<T> | unknown) => any;
export default _default;
//# sourceMappingURL=generateWatchOutput.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"generateWatchOutput.d.ts","sourceRoot":"","sources":["../../src/logic/generateWatchOutput.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;yBAIhD,CAAC,EACf,OAAO,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,EACpC,QAAQ,KAAK,EACb,aAAa,WAAW,EACxB,WAAW,OAAO,EAClB,eAAe,WAAW,CAAC,CAAC,CAAC,GAAG,OAAO;AALzC,wBAwBE"}

View File

@ -0,0 +1,7 @@
type CheckboxFieldResult = {
isValid: boolean;
value: string | string[] | boolean | undefined;
};
declare const _default: (options?: HTMLInputElement[]) => CheckboxFieldResult;
export default _default;
//# sourceMappingURL=getCheckboxValue.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,4 @@
declare function markFieldsDirty<T>(data: T, fields?: Record<string, any>): Record<string, any>;
export default function getDirtyFields<T>(data: T, formValues: T, dirtyFieldsFromValues?: Record<Extract<keyof T, string>, ReturnType<typeof markFieldsDirty> | boolean>): Record<Extract<keyof T, string>, boolean | Record<string, any>>;
export {};
//# sourceMappingURL=getDirtyFields.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"getDirtyFields.d.ts","sourceRoot":"","sources":["../../src/logic/getDirtyFields.ts"],"names":[],"mappings":"AAWA,iBAAS,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,uBAapE;AAED,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,CAAC,EACtC,IAAI,EAAE,CAAC,EACP,UAAU,EAAE,CAAC,EACb,qBAAqB,CAAC,EAAE,MAAM,CAC5B,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,EACxB,UAAU,CAAC,OAAO,eAAe,CAAC,GAAG,OAAO,CAC7C,mEA6BF"}

View File

@ -0,0 +1,3 @@
declare const _default: (event: unknown) => any;
export default _default;
//# sourceMappingURL=getEventValue.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"getEventValue.d.ts","sourceRoot":"","sources":["../../src/logic/getEventValue.ts"],"names":[],"mappings":"yBAKgB,OAAO,OAAO;AAA9B,wBAKY"}

View File

@ -0,0 +1,3 @@
import type { Field } from '../types';
export default function getFieldValue(_f: Field['_f']): any;
//# sourceMappingURL=getFieldValue.d.ts.map

View File

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

View File

@ -0,0 +1,4 @@
import type { Field, NativeFieldValue } from '../types';
declare const _default: <T extends NativeFieldValue>(value: T, { valueAsNumber, valueAsDate, setValueAs }: Field["_f"]) => any;
export default _default;
//# sourceMappingURL=getFieldValueAs.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"getFieldValueAs.d.ts","sourceRoot":"","sources":["../../src/logic/getFieldValueAs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;yBAIxC,CAAC,SAAS,gBAAgB,EACxC,OAAO,CAAC,EACR,4CAA4C,KAAK,CAAC,IAAI,CAAC;AAFzD,wBAgBkB"}

View File

@ -0,0 +1,4 @@
import type { FieldArrayMethodProps, InternalFieldName } from '../types';
declare const _default: (name: InternalFieldName, index: number, options?: FieldArrayMethodProps) => string;
export default _default;
//# sourceMappingURL=getFocusFieldName.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"getFocusFieldName.d.ts","sourceRoot":"","sources":["../../src/logic/getFocusFieldName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;yBAIvE,MAAM,iBAAiB,EACvB,OAAO,MAAM,EACb,UAAS,qBAA0B,KAClC,MAAM;AAJT,wBAQS"}

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":"getNodeParentName.d.ts","sourceRoot":"","sources":["../../src/logic/getNodeParentName.ts"],"names":[],"mappings":"yBAAgB,MAAM,MAAM;AAA5B,wBACwD"}

View File

@ -0,0 +1,4 @@
import type { Control, FieldValues, FormState, ReadFormState } from '../types';
declare const _default: <TFieldValues extends FieldValues, TContext = any, TTransformedValues = TFieldValues>(formState: FormState<TFieldValues>, control: Control<TFieldValues, TContext, TTransformedValues>, localProxyFormState?: ReadFormState, isRoot?: boolean) => FormState<TFieldValues>;
export default _default;
//# sourceMappingURL=getProxyFormState.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"getProxyFormState.d.ts","sourceRoot":"","sources":["../../src/logic/getProxyFormState.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;yBAG7E,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,7 @@
type RadioFieldResult = {
isValid: boolean;
value: number | string | null;
};
declare const _default: (options?: HTMLInputElement[]) => RadioFieldResult;
export default _default;
//# sourceMappingURL=getRadioValue.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"getRadioValue.d.ts","sourceRoot":"","sources":["../../src/logic/getRadioValue.ts"],"names":[],"mappings":"AAAA,KAAK,gBAAgB,GAAG;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CAC/B,CAAC;yBAOc,UAAU,gBAAgB,EAAE,KAAG,gBAAgB;AAA/D,wBAYoB"}

View File

@ -0,0 +1,14 @@
import type { CriteriaMode, FieldName, FieldRefs, FieldValues, InternalFieldName } from '../types';
declare const _default: <TFieldValues extends FieldValues>(fieldsNames: Set<InternalFieldName> | InternalFieldName[], _fields: FieldRefs, criteriaMode?: CriteriaMode, shouldUseNativeValidation?: boolean | undefined) => {
criteriaMode: CriteriaMode | undefined;
names: FieldName<TFieldValues>[];
fields: Record<string, {
ref: import("../types").Ref;
name: InternalFieldName;
refs?: HTMLInputElement[];
mount?: boolean;
} & import("../types").RegisterOptions>;
shouldUseNativeValidation: boolean | undefined;
};
export default _default;
//# sourceMappingURL=getResolverOptions.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"getResolverOptions.d.ts","sourceRoot":"","sources":["../../src/logic/getResolverOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAEZ,SAAS,EACT,SAAS,EACT,WAAW,EACX,iBAAiB,EAClB,MAAM,UAAU,CAAC;yBAIF,YAAY,SAAS,WAAW,EAC9C,aAAa,GAAG,CAAC,iBAAiB,CAAC,GAAG,iBAAiB,EAAE,EACzD,SAAS,SAAS,EAClB,eAAe,YAAY,EAC3B,4BAA4B,OAAO,GAAG,SAAS;;WAYlB,SAAS,CAAC,YAAY,CAAC,EAAE;;;;;;;;;AAhBxD,wBAoBE"}

View File

@ -0,0 +1,4 @@
import type { 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 @@
{"version":3,"file":"getRuleValue.d.ts","sourceRoot":"","sources":["../../src/logic/getRuleValue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EACf,sBAAsB,EACvB,MAAM,UAAU,CAAC;yBAKF,CAAC,SAAS,eAAe,EACvC,OAAO,cAAc,CAAC,CAAC,CAAC,GAAG,sBAAsB,CAAC,CAAC,CAAC;AADtD,wBAWe"}

View File

@ -0,0 +1,3 @@
import type { FieldError, Ref, ValidateResult } from '../types';
export default function getValidateError(result: ValidateResult, ref: Ref, type?: string): FieldError | void;
//# sourceMappingURL=getValidateError.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"getValidateError.d.ts","sourceRoot":"","sources":["../../src/logic/getValidateError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAIhE,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,MAAM,EAAE,cAAc,EACtB,GAAG,EAAE,GAAG,EACR,IAAI,SAAa,GAChB,UAAU,GAAG,IAAI,CAYnB"}

View File

@ -0,0 +1,4 @@
import type { Mode, ValidationModeFlags } from '../types';
declare const _default: (mode?: Mode) => ValidationModeFlags;
export default _default;
//# sourceMappingURL=getValidationModes.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"getValidationModes.d.ts","sourceRoot":"","sources":["../../src/logic/getValidationModes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;yBAE1C,OAAO,IAAI,KAAG,mBAAmB;AAAjD,wBAMG"}

View File

@ -0,0 +1,7 @@
import type { ValidationRule } from '../types';
declare const _default: (validationData?: ValidationRule) => {
value: string | number | boolean | RegExp | undefined;
message: string;
};
export default _default;
//# sourceMappingURL=getValueAndMessage.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"getValueAndMessage.d.ts","sourceRoot":"","sources":["../../src/logic/getValueAndMessage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;yBAI/B,iBAAiB,cAAc;;;;AAA/C,wBAMQ"}

View File

@ -0,0 +1,4 @@
import type { Field } from '../types';
declare const _default: (fieldReference: Field["_f"]) => boolean;
export default _default;
//# sourceMappingURL=hasPromiseValidation.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"hasPromiseValidation.d.ts","sourceRoot":"","sources":["../../src/logic/hasPromiseValidation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAY,MAAM,UAAU,CAAC;yBAMhC,gBAAgB,KAAK,CAAC,IAAI,CAAC;AAA3C,wBAWI"}

View File

@ -0,0 +1,4 @@
import type { Field } from '../types';
declare const _default: (options: Field["_f"]) => string | number | boolean | import("../types").ValidationValueMessage<boolean> | import("../types").ValidationValueMessage<string | number> | import("../types").ValidationRule<RegExp> | import("../types").Validate<any, import("../types").FieldValues> | Record<string, import("../types").Validate<any, import("../types").FieldValues>> | undefined;
export default _default;
//# sourceMappingURL=hasValidation.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"hasValidation.d.ts","sourceRoot":"","sources":["../../src/logic/hasValidation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;yBAEtB,SAAS,KAAK,CAAC,IAAI,CAAC;AAApC,wBAQsB"}

View File

@ -0,0 +1,4 @@
import appendErrors from './appendErrors';
import { createFormControl } from './createFormControl';
export { appendErrors, createFormControl };
//# sourceMappingURL=index.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logic/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,CAAC"}

View File

@ -0,0 +1,4 @@
import type { InternalFieldName } from '../types';
declare const _default: (names: Set<InternalFieldName>, name: InternalFieldName) => boolean;
export default _default;
//# sourceMappingURL=isNameInFieldArray.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"isNameInFieldArray.d.ts","sourceRoot":"","sources":["../../src/logic/isNameInFieldArray.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;yBAIlC,OAAO,GAAG,CAAC,iBAAiB,CAAC,EAAE,MAAM,iBAAiB;AAAtE,wBACqC"}

View File

@ -0,0 +1,4 @@
import type { InternalFieldName, Names } from '../types';
declare const _default: (name: InternalFieldName, _names: Names, isBlurEvent?: boolean) => boolean;
export default _default;
//# sourceMappingURL=isWatched.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"isWatched.d.ts","sourceRoot":"","sources":["../../src/logic/isWatched.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;yBAGvD,MAAM,iBAAiB,EACvB,QAAQ,KAAK,EACb,cAAc,OAAO;AAHvB,wBAYO"}

View File

@ -0,0 +1,4 @@
import type { FieldRefs, InternalFieldName, Ref } from '../types';
declare const iterateFieldsByAction: (fields: FieldRefs, action: (ref: Ref, name: string) => 1 | undefined | void, fieldsNames?: Set<InternalFieldName> | InternalFieldName[] | 0, abortEarly?: boolean) => true | undefined;
export default iterateFieldsByAction;
//# sourceMappingURL=iterateFieldsByAction.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"iterateFieldsByAction.d.ts","sourceRoot":"","sources":["../../src/logic/iterateFieldsByAction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAIlE,QAAA,MAAM,qBAAqB,GACzB,QAAQ,SAAS,EACjB,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC,GAAG,SAAS,GAAG,IAAI,EACxD,cAAc,GAAG,CAAC,iBAAiB,CAAC,GAAG,iBAAiB,EAAE,GAAG,CAAC,EAC9D,aAAa,OAAO,qBA0BrB,CAAC;AACF,eAAe,qBAAqB,CAAC"}

View File

@ -0,0 +1,6 @@
import type { FieldError, FieldErrors, FieldValues } from '../types';
export default function schemaErrorLookup<T extends FieldValues = FieldValues>(errors: FieldErrors<T>, _fields: FieldValues, name: string): {
error?: FieldError;
name: string;
};
//# sourceMappingURL=schemaErrorLookup.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"schemaErrorLookup.d.ts","sourceRoot":"","sources":["../../src/logic/schemaErrorLookup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAIrE,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,EAC3E,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,EACtB,OAAO,EAAE,WAAW,EACpB,IAAI,EAAE,MAAM,GACX;IACD,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd,CAyCA"}

View File

@ -0,0 +1,7 @@
import type { FieldValues, FormState, InternalFieldName, ReadFormState } from '../types';
declare const _default: <T extends FieldValues, K extends ReadFormState>(formStateData: Partial<FormState<T>> & {
name?: InternalFieldName;
values?: T;
}, _proxyFormState: K, updateFormState: (formState: Partial<FormState<T>>) => void, isRoot?: boolean) => string | true | undefined;
export default _default;
//# sourceMappingURL=shouldRenderFormState.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"shouldRenderFormState.d.ts","sourceRoot":"","sources":["../../src/logic/shouldRenderFormState.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,aAAa,EACd,MAAM,UAAU,CAAC;yBAGF,CAAC,SAAS,WAAW,EAAE,CAAC,SAAS,aAAa,EAC5D,eAAe,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG;IACrC,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB,MAAM,CAAC,EAAE,CAAC,CAAC;CACZ,EACD,iBAAiB,CAAC,EAClB,iBAAiB,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,EAC3D,SAAS,OAAO;AAPlB,wBAqBE"}

View File

@ -0,0 +1,3 @@
declare const _default: <T extends string | readonly string[] | undefined>(name?: T, signalName?: string, exact?: boolean) => boolean;
export default _default;
//# sourceMappingURL=shouldSubscribeByName.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"shouldSubscribeByName.d.ts","sourceRoot":"","sources":["../../src/logic/shouldSubscribeByName.ts"],"names":[],"mappings":"yBAEgB,CAAC,SAAS,MAAM,GAAG,SAAS,MAAM,EAAE,GAAG,SAAS,EAC9D,OAAO,CAAC,EACR,aAAa,MAAM,EACnB,QAAQ,OAAO;AAHjB,wBAeI"}

View File

@ -0,0 +1,7 @@
import type { ValidationModeFlags } from '../types';
declare const _default: (isBlurEvent: boolean, isTouched: boolean, isSubmitted: boolean, reValidateMode: {
isOnBlur: boolean;
isOnChange: boolean;
}, mode: Partial<ValidationModeFlags>) => boolean;
export default _default;
//# sourceMappingURL=skipValidation.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"skipValidation.d.ts","sourceRoot":"","sources":["../../src/logic/skipValidation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;yBAGlD,aAAa,OAAO,EACpB,WAAW,OAAO,EAClB,aAAa,OAAO,EACpB,gBAAgB;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;CACrB,EACD,MAAM,OAAO,CAAC,mBAAmB,CAAC;AARpC,wBAoBE"}

View File

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

View File

@ -0,0 +1 @@
{"version":3,"file":"unsetEmptyArray.d.ts","sourceRoot":"","sources":["../../src/logic/unsetEmptyArray.ts"],"names":[],"mappings":"yBAIgB,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,MAAM;AAAvC,wBACsD"}

View File

@ -0,0 +1,4 @@
import type { 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

View File

@ -0,0 +1 @@
{"version":3,"file":"updateFieldArrayRootError.d.ts","sourceRoot":"","sources":["../../src/logic/updateFieldArrayRootError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,WAAW,EACX,iBAAiB,EAClB,MAAM,UAAU,CAAC;yBAKF,CAAC,SAAS,WAAW,GAAG,WAAW,EACjD,QAAQ,WAAW,CAAC,CAAC,CAAC,EACtB,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,EAC1C,MAAM,iBAAiB,KACtB,WAAW,CAAC,CAAC,CAAC;AAJjB,wBASE"}

View File

@ -0,0 +1,4 @@
import type { Field, FieldValues, InternalFieldErrors, InternalNameSet } from '../types';
declare const _default: <T extends FieldValues>(field: Field, disabledFieldNames: InternalNameSet, formValues: T, validateAllFieldCriteria: boolean, shouldUseNativeValidation?: boolean, isFieldArray?: boolean) => Promise<InternalFieldErrors>;
export default _default;
//# sourceMappingURL=validateField.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"validateField.d.ts","sourceRoot":"","sources":["../../src/logic/validateField.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,KAAK,EAEL,WAAW,EACX,mBAAmB,EACnB,eAAe,EAKhB,MAAM,UAAU,CAAC;yBAqBI,CAAC,SAAS,WAAW,EACzC,OAAO,KAAK,EACZ,oBAAoB,eAAe,EACnC,YAAY,CAAC,EACb,0BAA0B,OAAO,EACjC,4BAA4B,OAAO,EACnC,eAAe,OAAO,KACrB,OAAO,CAAC,mBAAmB,CAAC;AAP/B,wBA6PE"}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,61 @@
import type React from 'react';
import type { Control, FieldError, FieldPath, FieldPathValue, FieldValues, Noop, RefCallBack, UseFormStateReturn } from './';
import type { RegisterOptions } from './validator';
export type ControllerFieldState = {
invalid: boolean;
isTouched: boolean;
isDirty: boolean;
isValidating: boolean;
error?: FieldError;
};
export type ControllerRenderProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = {
onChange: (...event: any[]) => void;
onBlur: Noop;
value: FieldPathValue<TFieldValues, TName>;
disabled?: boolean;
name: TName;
ref: RefCallBack;
};
export type UseControllerProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TTransformedValues = TFieldValues> = {
name: TName;
rules?: Omit<RegisterOptions<TFieldValues, TName>, 'valueAsNumber' | 'valueAsDate' | 'setValueAs' | 'disabled'>;
shouldUnregister?: boolean;
defaultValue?: FieldPathValue<TFieldValues, TName>;
control?: Control<TFieldValues, any, TTransformedValues>;
disabled?: boolean;
exact?: boolean;
};
export type UseControllerReturn<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = {
field: ControllerRenderProps<TFieldValues, TName>;
formState: UseFormStateReturn<TFieldValues>;
fieldState: ControllerFieldState;
};
/**
* Render function to provide the control for the field.
*
* @returns all the event handlers, and relevant field and form state.
*
* @example
* ```tsx
* const { field, fieldState, formState } = useController();
*
* <Controller
* render={({ field, formState, fieldState }) => ({
* <input
* onChange={field.onChange}
* onBlur={field.onBlur}
* name={field.name}
* ref={field.ref} // optional for focus management
* />
* })}
* />
* ```
*/
export type ControllerProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TTransformedValues = TFieldValues> = {
render: ({ field, fieldState, formState, }: {
field: ControllerRenderProps<TFieldValues, TName>;
fieldState: ControllerFieldState;
formState: UseFormStateReturn<TFieldValues>;
}) => React.ReactElement;
} & UseControllerProps<TFieldValues, TName, TTransformedValues>;
//# sourceMappingURL=controller.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/types/controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EACV,OAAO,EACP,UAAU,EACV,SAAS,EACT,cAAc,EACd,WAAW,EACX,IAAI,EACJ,WAAW,EACX,kBAAkB,EACnB,MAAM,IAAI,CAAC;AACZ,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE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AAM,mBAAmB,CAC7B,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,KAAK,SAAS,SAAS,CAAC,YAAY,CAAC,GAAG,SAAS,CAAC,YAAY,CAAC,IAC7D;IACF,KAAK,EAAE,qBAAqB,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;IAClD,SAAS,EAAE,kBAAkB,CAAC,YAAY,CAAC,CAAC;IAC5C,UAAU,EAAE,oBAAoB,CAAC;CAClC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,eAAe,CACzB,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,KAAK,SAAS,SAAS,CAAC,YAAY,CAAC,GAAG,SAAS,CAAC,YAAY,CAAC,EAC/D,kBAAkB,GAAG,YAAY,IAC/B;IACF,MAAM,EAAE,CAAC,EACP,KAAK,EACL,UAAU,EACV,SAAS,GACV,EAAE;QACD,KAAK,EAAE,qBAAqB,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;QAClD,UAAU,EAAE,oBAAoB,CAAC;QACjC,SAAS,EAAE,kBAAkB,CAAC,YAAY,CAAC,CAAC;KAC7C,KAAK,KAAK,CAAC,YAAY,CAAC;CAC1B,GAAG,kBAAkB,CAAC,YAAY,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAAC"}

View File

@ -0,0 +1,36 @@
import type { FieldValues, InternalFieldName, Ref } from './fields';
import type { BrowserNativeObject, IsAny, LiteralUnion, Merge } from './utils';
import type { RegisterOptions, ValidateResult } from './validator';
export type Message = string;
export type MultipleFieldErrors = {
[K in keyof RegisterOptions]?: ValidateResult;
} & {
[key: string]: ValidateResult;
};
export type FieldError = {
type: LiteralUnion<keyof RegisterOptions, string>;
root?: FieldError;
ref?: Ref;
types?: MultipleFieldErrors;
message?: Message;
};
export type ErrorOption = {
message?: Message;
type?: LiteralUnion<keyof RegisterOptions, string>;
types?: MultipleFieldErrors;
};
export type DeepRequired<T> = T extends BrowserNativeObject | Blob ? T : {
[K in keyof T]-?: NonNullable<DeepRequired<T[K]>>;
};
export type FieldErrorsImpl<T extends FieldValues = FieldValues> = {
[K in keyof T]?: T[K] extends BrowserNativeObject | Blob ? FieldError : K extends 'root' | `root.${string}` ? GlobalError : T[K] extends object ? Merge<FieldError, FieldErrorsImpl<T[K]>> : FieldError;
};
export type GlobalError = Partial<{
type: string | number;
message: Message;
}>;
export type FieldErrors<T extends FieldValues = FieldValues> = Partial<FieldValues extends IsAny<FieldValues> ? any : FieldErrorsImpl<DeepRequired<T>>> & {
root?: Record<string, GlobalError> & GlobalError;
};
export type InternalFieldErrors = Partial<Record<InternalFieldName, FieldError>>;
//# sourceMappingURL=errors.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAC/E,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEnE,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAE7B,MAAM,MAAM,mBAAmB,GAAG;KAC/B,CAAC,IAAI,MAAM,eAAe,CAAC,CAAC,EAAE,cAAc;CAC9C,GAAG;IACF,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,YAAY,CAAC,MAAM,eAAe,EAAE,MAAM,CAAC,CAAC;IAClD,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,WAAW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AAE,UAAU,CAAC,CACtC,CAAC"}

View File

@ -0,0 +1,2 @@
export type EventType = 'focus' | 'blur' | 'change' | 'changeText' | 'valueChange' | 'contentSizeChange' | 'endEditing' | 'keyPress' | 'submitEditing' | 'layout' | 'selectionChange' | 'longPress' | 'press' | 'pressIn' | 'pressOut' | 'momentumScrollBegin' | 'momentumScrollEnd' | 'scroll' | 'scrollBeginDrag' | 'scrollEndDrag' | 'load' | 'error' | 'progress' | 'custom';
//# sourceMappingURL=events.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GACjB,OAAO,GACP,MAAM,GACN,QAAQ,GACR,YAAY,GACZ,aAAa,GACb,mBAAmB,GACnB,YAAY,GACZ,UAAU,GACV,eAAe,GACf,QAAQ,GACR,iBAAiB,GACjB,WAAW,GACX,OAAO,GACP,SAAS,GACT,UAAU,GACV,qBAAqB,GACrB,mBAAmB,GACnB,QAAQ,GACR,iBAAiB,GACjB,eAAe,GACf,MAAM,GACN,OAAO,GACP,UAAU,GACV,QAAQ,CAAC"}

View File

@ -0,0 +1,195 @@
import type { FieldValues } from './fields';
import type { Control } from './form';
import type { FieldArrayPath, FieldArrayPathValue } from './path';
import type { RegisterOptions, Validate } from './validator';
export type UseFieldArrayProps<TFieldValues extends FieldValues = FieldValues, TFieldArrayName extends FieldArrayPath<TFieldValues> = FieldArrayPath<TFieldValues>, TKeyName extends string = 'id', TTransformedValues = TFieldValues> = {
name: TFieldArrayName;
keyName?: TKeyName;
control?: Control<TFieldValues, any, TTransformedValues>;
rules?: {
validate?: Validate<FieldArray<TFieldValues, TFieldArrayName>[], TFieldValues> | Record<string, Validate<FieldArray<TFieldValues, TFieldArrayName>[], TFieldValues>>;
} & Pick<RegisterOptions<TFieldValues>, 'maxLength' | 'minLength' | 'required'>;
shouldUnregister?: boolean;
};
/**
* `useFieldArray` returned `fields` with unique id
*/
export type FieldArrayWithId<TFieldValues extends FieldValues = FieldValues, TFieldArrayName extends FieldArrayPath<TFieldValues> = FieldArrayPath<TFieldValues>, TKeyName extends string = 'id'> = FieldArray<TFieldValues, TFieldArrayName> & Record<TKeyName, string>;
export type FieldArray<TFieldValues extends FieldValues = FieldValues, TFieldArrayName extends FieldArrayPath<TFieldValues> = FieldArrayPath<TFieldValues>> = FieldArrayPathValue<TFieldValues, TFieldArrayName> extends ReadonlyArray<infer U> | null | undefined ? U : never;
/**
* `useFieldArray` focus option, ability to toggle focus on and off with `shouldFocus` and setting focus by either field index or name.
*/
export type FieldArrayMethodProps = {
shouldFocus?: boolean;
focusIndex?: number;
focusName?: string;
};
/**
* Swap field array by supplying from and to index
*
* @remarks
* [API](https://react-hook-form.com/docs/usefieldarray) • [Demo](https://codesandbox.io/s/calc-i231d)
*
* @param indexA - from index
* @param indexB - to index
*
* @example
* ```tsx
* <button type="button" onClick={() => swap(0, 1)}>swap</button>
* ```
*/
export type UseFieldArraySwap = (indexA: number, indexB: number) => void;
/**
* Move field array by supplying from and to index
*
* @remarks
* [API](https://react-hook-form.com/docs/usefieldarray) • [Demo](https://codesandbox.io/s/calc-i231d)
*
* @param indexA - from index
* @param indexB - to index
*
* @example
* ```tsx
* <button type="button" onClick={() => move(0, 1)}>swap</button>
* ```
*/
export type UseFieldArrayMove = (indexA: number, indexB: number) => void;
/**
* Prepend field/fields to the start of the fields and optionally focus. The input value will be registered during this action.
*
* @remarks
* [API](https://react-hook-form.com/docs/usefieldarray) • [Demo](https://codesandbox.io/s/calc-i231d)
*
* @param value - prepend items or items
* @param options - focus options
*
* @example
* ```tsx
* <button type="button" onClick={() => prepend({ name: "data" })}>Prepend</button>
* <button type="button" onClick={() => prepend({ name: "data" }, { shouldFocus: false })}>Prepend</button>
* <button
* type="button"
* onClick={() => prepend([{ name: "data" }, { name: "data" }])}
* >
* Prepend
* </button>
* ```
*/
export type UseFieldArrayPrepend<TFieldValues extends FieldValues, TFieldArrayName extends FieldArrayPath<TFieldValues> = FieldArrayPath<TFieldValues>> = (value: FieldArray<TFieldValues, TFieldArrayName> | FieldArray<TFieldValues, TFieldArrayName>[], options?: FieldArrayMethodProps) => void;
/**
* Append field/fields to the end of your fields and focus. The input value will be registered during this action.
*
* @remarks
* [API](https://react-hook-form.com/docs/usefieldarray) • [Demo](https://codesandbox.io/s/calc-i231d)
*
* @param value - append items or items.
* @param options - focus options
*
* @example
* ```tsx
* <button type="button" onClick={() => append({ name: "data" })}>Append</button>
* <button type="button" onClick={() => append({ name: "data" }, { shouldFocus: false })}>Append</button>
* <button
* type="button"
* onClick={() => append([{ name: "data" }, { name: "data" }])}
* >
* Append
* </button>
* ```
*/
export type UseFieldArrayAppend<TFieldValues extends FieldValues, TFieldArrayName extends FieldArrayPath<TFieldValues> = FieldArrayPath<TFieldValues>> = (value: FieldArray<TFieldValues, TFieldArrayName> | FieldArray<TFieldValues, TFieldArrayName>[], options?: FieldArrayMethodProps) => void;
/**
* Remove field/fields at particular position.
*
* @remarks
* [API](https://react-hook-form.com/docs/usefieldarray) • [Demo](https://codesandbox.io/s/calc-i231d)
*
* @param index - index to remove at, or remove all when no index provided.
*
* @example
* ```tsx
* <button type="button" onClick={() => remove(0)}>Remove</button>
* <button
* type="button"
* onClick={() => remove()}
* >
* Remove all
* </button>
* ```
*/
export type UseFieldArrayRemove = (index?: number | number[]) => void;
/**
* Insert field/fields at particular position and focus.
*
* @remarks
* [API](https://react-hook-form.com/docs/usefieldarray) • [Demo](https://codesandbox.io/s/calc-i231d)
*
* @param index - insert position
* @param value - insert field or fields
* @param options - focus options
*
* @example
* ```tsx
* <button type="button" onClick={() => insert(1, { name: "data" })}>Insert</button>
* <button type="button" onClick={() => insert(1, { name: "data" }, { shouldFocus: false })}>Insert</button>
* <button
* type="button"
* onClick={() => insert(1, [{ name: "data" }, { name: "data" }])}
* >
* Insert
* </button>
* ```
*/
export type UseFieldArrayInsert<TFieldValues extends FieldValues, TFieldArrayName extends FieldArrayPath<TFieldValues> = FieldArrayPath<TFieldValues>> = (index: number, value: FieldArray<TFieldValues, TFieldArrayName> | FieldArray<TFieldValues, TFieldArrayName>[], options?: FieldArrayMethodProps) => void;
/**
* Update field/fields at particular position.
*
* @remarks
* [API](https://react-hook-form.com/docs/usefieldarray) • [Demo](https://codesandbox.io/s/calc-i231d)
*
* @param index - insert position
* @param value - insert field or fields
*
* @example
* ```tsx
* <button type="button" onClick={() => update(1, { name: "data" })}>Update</button>
* <button
* type="button"
* onClick={() => update(1, [{ name: "data" }, { name: "data" }])}
* >
* Update
* </button>
* ```
*/
export type UseFieldArrayUpdate<TFieldValues extends FieldValues, TFieldArrayName extends FieldArrayPath<TFieldValues> = FieldArrayPath<TFieldValues>> = (index: number, value: FieldArray<TFieldValues, TFieldArrayName>) => void;
/**
* Replace the entire field array values.
*
* @remarks
* [API](https://react-hook-form.com/docs/usefieldarray) • [Demo](https://codesandbox.io/s/calc-i231d)
*
* @param value - the entire field values.
*
* @example
* ```tsx
* <button
* type="button"
* onClick={() => replace([{ name: "data" }, { name: "data" }])}
* >
* Replace
* </button>
* ```
*/
export type UseFieldArrayReplace<TFieldValues extends FieldValues, TFieldArrayName extends FieldArrayPath<TFieldValues> = FieldArrayPath<TFieldValues>> = (value: FieldArray<TFieldValues, TFieldArrayName> | FieldArray<TFieldValues, TFieldArrayName>[]) => void;
export type UseFieldArrayReturn<TFieldValues extends FieldValues = FieldValues, TFieldArrayName extends FieldArrayPath<TFieldValues> = FieldArrayPath<TFieldValues>, TKeyName extends string = 'id'> = {
swap: UseFieldArraySwap;
move: UseFieldArrayMove;
prepend: UseFieldArrayPrepend<TFieldValues, TFieldArrayName>;
append: UseFieldArrayAppend<TFieldValues, TFieldArrayName>;
remove: UseFieldArrayRemove;
insert: UseFieldArrayInsert<TFieldValues, TFieldArrayName>;
update: UseFieldArrayUpdate<TFieldValues, TFieldArrayName>;
replace: UseFieldArrayReplace<TFieldValues, TFieldArrayName>;
fields: FieldArrayWithId<TFieldValues, TFieldArrayName, TKeyName>[];
};
//# sourceMappingURL=fieldArray.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"fieldArray.d.ts","sourceRoot":"","sources":["../../src/types/fieldArray.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE7D,MAAM,MAAM,kBAAkB,CAC5B,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,eAAe,SAAS,cAAc,CAAC,YAAY,CAAC,GAClD,cAAc,CAAC,YAAY,CAAC,EAC9B,QAAQ,SAAS,MAAM,GAAG,IAAI,EAC9B,kBAAkB,GAAG,YAAY,IAC/B;IACF,IAAI,EAAE,eAAe,CAAC;IACtB,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC,YAAY,EAAE,GAAG,EAAE,kBAAkB,CAAC,CAAC;IACzD,KAAK,CAAC,EAAE;QACN,QAAQ,CAAC,EACL,QAAQ,CAAC,UAAU,CAAC,YAAY,EAAE,eAAe,CAAC,EAAE,EAAE,YAAY,CAAC,GACnE,MAAM,CACJ,MAAM,EACN,QAAQ,CAAC,UAAU,CAAC,YAAY,EAAE,eAAe,CAAC,EAAE,EAAE,YAAY,CAAC,CACpE,CAAC;KACP,GAAG,IAAI,CACN,eAAe,CAAC,YAAY,CAAC,EAC7B,WAAW,GAAG,WAAW,GAAG,UAAU,CACvC,CAAC;IACF,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAC1B,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,eAAe,SAAS,cAAc,CAAC,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C,YAAY,EAAE,eAAe,CAAC,EAAE,KAC5C,IAAI,CAAC;AAEV,MAAM,MAAM,mBAAmB,CAC7B,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,eAAe,SAAS,cAAc,CAAC,YAAY,CAAC,GAClD,cAAc,CAAC,YAAY,CAAC,EAC9B,QAAQ,SAAS,MAAM,GAAG,IAAI,IAC5B;IACF,IAAI,EAAE,iBAAiB,CAAC;IACxB,IAAI,EAAE,iBAAiB,CAAC;IACxB,OAAO,EAAE,oBAAoB,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;IAC7D,MAAM,EAAE,mBAAmB,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;IAC3D,MAAM,EAAE,mBAAmB,CAAC;IAC5B,MAAM,EAAE,mBAAmB,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;IAC3D,MAAM,EAAE,mBAAmB,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;IAC3D,OAAO,EAAE,oBAAoB,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;IAC7D,MAAM,EAAE,gBAAgB,CAAC,YAAY,EAAE,eAAe,EAAE,QAAQ,CAAC,EAAE,CAAC;CACrE,CAAC"}

View File

@ -0,0 +1,31 @@
import type { IsFlatObject, Noop } from './utils';
import type { RegisterOptions } from './validator';
export type InternalFieldName = string;
export type FieldName<TFieldValues extends FieldValues> = IsFlatObject<TFieldValues> extends true ? Extract<keyof TFieldValues, string> : string;
export type CustomElement<TFieldValues extends FieldValues> = Partial<HTMLElement> & {
name: FieldName<TFieldValues>;
type?: string;
value?: any;
disabled?: boolean;
checked?: boolean;
options?: HTMLOptionsCollection;
files?: FileList | null;
focus?: Noop;
};
export type FieldValue<TFieldValues extends FieldValues> = TFieldValues[InternalFieldName];
export type FieldValues = Record<string, any>;
export type NativeFieldValue = string | number | boolean | null | undefined | unknown[];
export type FieldElement<TFieldValues extends FieldValues = FieldValues> = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement | CustomElement<TFieldValues>;
export type Ref = FieldElement;
export type Field = {
_f: {
ref: Ref;
name: InternalFieldName;
refs?: HTMLInputElement[];
mount?: boolean;
} & RegisterOptions;
};
export type FieldRefs = Partial<{
[key: InternalFieldName]: Field | FieldRefs;
}>;
//# sourceMappingURL=fields.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../src/types/fields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAEvC,MAAM,MAAM,SAAS,CAAC,YAAY,SAAS,WAAW,IACpD,YAAY,CAAC,YAAY,CAAC,SAAS,IAAI,GACnC,OAAO,CAAC,MAAM,YAAY,EAAE,MAAM,CAAC,GACnC,MAAM,CAAC;AAEb,MAAM,MAAM,aAAa,CAAC,YAAY,SAAS,WAAW,IACxD,OAAO,CAAC,WAAW,CAAC,GAAG;IACrB,IAAI,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,qBAAqB,CAAC;IAChC,KAAK,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IACxB,KAAK,CAAC,EAAE,IAAI,CAAC;CACd,CAAC;AAEJ,MAAM,MAAM,UAAU,CAAC,YAAY,SAAS,WAAW,IACrD,YAAY,CAAC,iBAAiB,CAAC,CAAC;AAElC,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAE9C,MAAM,MAAM,gBAAgB,GACxB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,GACT,OAAO,EAAE,CAAC;AAEd,MAAM,MAAM,YAAY,CAAC,YAAY,SAAS,WAAW,GAAG,WAAW,IACnE,gBAAgB,GAChB,iBAAiB,GACjB,mBAAmB,GACnB,aAAa,CAAC,YAAY,CAAC,CAAC;AAEhC,MAAM,MAAM,GAAG,GAAG,YAAY,CAAC;AAE/B,MAAM,MAAM,KAAK,GAAG;IAClB,EAAE,EAAE;QACF,GAAG,EAAE,GAAG,CAAC;QACT,IAAI,EAAE,iBAAiB,CAAC;QACxB,IAAI,CAAC,EAAE,gBAAgB,EAAE,CAAC;QAC1B,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB,GAAG,eAAe,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,OAAO,CAAC;IAC9B,CAAC,GAAG,EAAE,iBAAiB,GAAG,KAAK,GAAG,SAAS,CAAC;CAC7C,CAAC,CAAC"}

View File

@ -0,0 +1,731 @@
import type React from 'react';
import type { VALIDATION_MODE } from '../constants';
import type { Subject, Subscription } from '../utils/createSubject';
import type { ErrorOption, FieldError, FieldErrors } from './errors';
import type { EventType } from './events';
import type { FieldArray } from './fieldArray';
import type { FieldName, FieldRefs, FieldValue, FieldValues, InternalFieldName } from './fields';
import type { FieldArrayPath, FieldPath, FieldPathValue, FieldPathValues } from './path';
import type { Resolver } from './resolvers';
import type { DeepMap, DeepPartial, Noop } from './utils';
import type { 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 ResetFieldConfig<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = Partial<{
keepDirty: boolean;
keepTouched: boolean;
keepError: boolean;
defaultValue: FieldPathValue<TFieldValues, TFieldName>;
}>;
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>;
isReady: boolean;
};
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;
keepFieldsRef: 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;
type EitherOption<T> = {
[K in keyof T]: {
[P in K]: T[P];
} & Partial<Record<Exclude<keyof T, K>, never>>;
}[keyof T];
export type GetValuesConfig = EitherOption<{
dirtyFields: boolean;
touchedFields: boolean;
}>;
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;
* })} />
* ```
*/
(name?: undefined, config?: GetValuesConfig): 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.
* @param config - return touched or dirty fields
*
* @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, config?: GetValuesConfig): 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
* @param config - return touched or dirty fields
*
* @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], config?: GetValuesConfig): [...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 UseFormSubscribe<TFieldValues extends FieldValues> = <TFieldNames extends readonly FieldPath<TFieldValues>[]>(payload: {
name?: readonly [...TFieldNames] | TFieldNames[number];
formState?: Partial<ReadFormState>;
callback: (data: Partial<FormState<TFieldValues>> & {
values: TFieldValues;
name?: InternalFieldName;
type?: EventType;
}) => 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?: ResetFieldConfig<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> = <TFieldNames extends readonly FieldPath<TFieldValues>[]>(payload: {
name?: readonly [...TFieldNames] | TFieldNames[number];
formState?: Partial<ReadFormState>;
callback: (data: Partial<FormState<TFieldValues>> & {
values: TFieldValues;
name?: InternalFieldName;
}) => 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;
}>;
_updateIsValidating: (names?: InternalFieldName[], isValidating?: boolean) => void;
_focusError: () => boolean | undefined;
_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: UseFormSubscribe<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;
compute?: (formValues: any) => any;
};
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

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,11 @@
export * from './controller';
export * from './errors';
export * from './events';
export * from './fieldArray';
export * from './fields';
export * from './form';
export * from './path';
export * from './resolvers';
export * from './utils';
export * from './validator';
//# sourceMappingURL=index.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}

View File

@ -0,0 +1,316 @@
import type { IsAny, IsNever } from '../utils';
/**
* Type alias to `string` which describes a lodash-like path through an object.
* E.g. `'foo.bar.0.baz'`
*/
export type PathString = string;
/**
* Type which can be traversed through with a {@link PathString}.
* I.e. objects, arrays, and tuples
*/
export type Traversable = object;
/**
* Type to query whether an array type T is a tuple type.
* @typeParam T - type which may be an array or tuple
* @example
* ```
* IsTuple<[number]> = true
* IsTuple<number[]> = false
* ```
*/
export type IsTuple<T extends ReadonlyArray<any>> = number extends T['length'] ? false : true;
/**
* Type which can be used to index an array or tuple type.
*/
export type ArrayKey = number;
/**
* Type which can be used to index an object.
*/
export type Key = string;
/**
* Type to assert that a type is a {@link Key}.
* @typeParam T - type which may be a {@link Key}
*/
export type AsKey<T> = Extract<T, Key>;
/**
* Type to convert a type to a {@link Key}.
* @typeParam T - type which may be converted to a {@link Key}
*/
export type ToKey<T> = T extends ArrayKey ? `${T}` : AsKey<T>;
/**
* Type which describes a path through an object
* as a list of individual {@link Key}s.
*/
export type PathTuple = Key[];
/**
* Type to assert that a type is a {@link PathTuple}.
* @typeParam T - type which may be a {@link PathTuple}
*/
export type AsPathTuple<T> = Extract<T, PathTuple>;
/**
* Type to intersect a union type.
* See https://fettblog.eu/typescript-union-to-intersection/
* @typeParam U - union
* @example
* ```
* UnionToIntersection<{ foo: string } | { bar: number }>
* = { foo: string; bar: number }
* ```
*/
export type UnionToIntersection<U> = (U extends any ? (_: U) => any : never) extends (_: infer I) => any ? I : never;
/**
* Type which appends a {@link Key} to the {@link PathTuple} only if it is not
* blank, i.e. not the empty string.
* @typeParam PT - path
* @typeParam K - key
* @example
* ```
* AppendNonBlankKey<['foo'], 'bar'> = ['foo', 'bar']
* AppendNonBlankKey<['foo'], ''> = ['foo']
* ```
*/
type AppendNonBlankKey<PT extends PathTuple, K extends Key> = K extends '' ? PT : [...PT, K];
/**
* Type to implement {@link SplitPathString} tail recursively.
* @typeParam PS - remaining {@link PathString} which should be split into its
* individual {@link Key}s
* @typeParam PT - accumulator of the {@link Key}s which have been split from
* the original {@link PathString} already
*/
type SplitPathStringImpl<PS extends PathString, PT extends PathTuple> = PS extends `${infer K}.${infer R}` ? SplitPathStringImpl<R, AppendNonBlankKey<PT, K>> : AppendNonBlankKey<PT, PS>;
/**
* Type to split a {@link PathString} into a {@link PathTuple}.
* The individual {@link Key}s may be empty strings.
* @typeParam PS - {@link PathString} which should be split into its
* individual {@link Key}s
* @example
* ```
* SplitPathString<'foo'> = ['foo']
* SplitPathString<'foo.bar.0.baz'> = ['foo', 'bar', '0', 'baz']
* SplitPathString<'.'> = []
* ```
*/
export type SplitPathString<PS extends PathString> = SplitPathStringImpl<PS, [
]>;
/**
* Type to implement {@link JoinPathTuple} tail-recursively.
* @typeParam PT - remaining {@link Key}s which needs to be joined
* @typeParam PS - accumulator of the already joined {@link Key}s
*/
type JoinPathTupleImpl<PT extends PathTuple, PS extends PathString> = PT extends [infer K, ...infer R] ? JoinPathTupleImpl<AsPathTuple<R>, `${PS}.${AsKey<K>}`> : PS;
/**
* Type to join a {@link PathTuple} to a {@link PathString}.
* @typeParam PT - {@link PathTuple} which should be joined.
* @example
* ```
* JoinPathTuple<['foo']> = 'foo'
* JoinPathTuple<['foo', 'bar', '0', 'baz']> = 'foo.bar.0.baz'
* JoinPathTuple<[]> = never
* ```
*/
export type JoinPathTuple<PT extends PathTuple> = PT extends [
infer K,
...infer R
] ? JoinPathTupleImpl<AsPathTuple<R>, AsKey<K>> : never;
/**
* Type which converts all keys of an object to {@link Key}s.
* @typeParam T - object type
* @example
* ```
* MapKeys<{0: string}> = {'0': string}
* ```
*/
type MapKeys<T> = {
[K in keyof T as ToKey<K>]: T[K];
};
/**
* Type to access a type by a key.
* - Returns undefined if it can't be indexed by that key.
* - Returns null if the type is null.
* - Returns undefined if the type is not traversable.
* @typeParam T - type which is indexed by the key
* @typeParam K - key into the type
* ```
* TryAccess<{foo: string}, 'foo'> = string
* TryAccess<{foo: string}, 'bar'> = undefined
* TryAccess<null, 'foo'> = null
* TryAccess<string, 'foo'> = undefined
* ```
*/
type TryAccess<T, K> = K extends keyof T ? T[K] : T extends null ? null : undefined;
/**
* Type to access an array type by a key.
* Returns undefined if the key is non-numeric.
* @typeParam T - type which is indexed by the key
* @typeParam K - key into the type
* ```
* TryAccessArray<string[], '0'> = string
* TryAccessArray<string[], 'foo'> = undefined
* ```
*/
type TryAccessArray<T extends ReadonlyArray<any>, K extends Key> = K extends `${ArrayKey}` ? T[number] : TryAccess<T, K>;
/**
* Type to evaluate the type which the given key points to.
* @typeParam T - type which is indexed by the key
* @typeParam K - key into the type
* @example
* ```
* EvaluateKey<{foo: string}, 'foo'> = string
* EvaluateKey<[number, string], '1'> = string
* EvaluateKey<string[], '1'> = string
* ```
*/
export type EvaluateKey<T, K extends Key> = T extends ReadonlyArray<any> ? IsTuple<T> extends true ? TryAccess<T, K> : TryAccessArray<T, K> : TryAccess<MapKeys<T>, K>;
/**
* Type to evaluate the type which the given path points to.
* @typeParam T - deeply nested type which is indexed by the path
* @typeParam PT - path into the deeply nested type
* @example
* ```
* EvaluatePath<{foo: {bar: string}}, ['foo', 'bar']> = string
* EvaluatePath<[number, string], ['1']> = string
* EvaluatePath<number, []> = number
* EvaluatePath<number, ['foo']> = undefined
* ```
*/
export type EvaluatePath<T, PT extends PathTuple> = PT extends [
infer K,
...infer R
] ? EvaluatePath<EvaluateKey<T, AsKey<K>>, AsPathTuple<R>> : T;
/**
* Type which given a tuple type returns its own keys, i.e. only its indices.
* @typeParam T - tuple type
* @example
* ```
* TupleKeys<[number, string]> = '0' | '1'
* ```
*/
export type TupleKeys<T extends ReadonlyArray<any>> = Exclude<keyof T, keyof any[]>;
/**
* Type which extracts all numeric keys from an object.
* @typeParam T - type
* @example
* ```
* NumericObjectKeys<{0: string, '1': string, foo: string}> = '0' | '1'
* ```
*/
type NumericObjectKeys<T extends Traversable> = ToKey<Extract<keyof T, ArrayKey | `${ArrayKey}`>>;
/**
* Type which extracts all numeric keys from an object, tuple, or array.
* If a union is passed, it evaluates to the overlapping numeric keys.
* @typeParam T - type
* @example
* ```
* NumericKeys<{0: string, '1': string, foo: string}> = '0' | '1'
* NumericKeys<number[]> = `${number}`
* NumericKeys<[string, number]> = '0' | '1'
* NumericKeys<{0: string, '1': string} | [number] | number[]> = '0'
* ```
*/
export type NumericKeys<T extends Traversable> = UnionToIntersection<T extends ReadonlyArray<any> ? IsTuple<T> extends true ? [TupleKeys<T>] : [ToKey<ArrayKey>] : [NumericObjectKeys<T>]>[never];
/**
* Type which extracts all keys from an object.
* If a union is passed, it evaluates to the overlapping keys.
* @typeParam T - object type
* @example
* ```
* ObjectKeys<{foo: string, bar: string}> = 'foo' | 'bar'
* ObjectKeys<{foo: string, bar: number} | { foo: string }> = 'foo'
* ```
*/
export type ObjectKeys<T extends Traversable> = Exclude<ToKey<keyof T>, `${string}.${string}` | ''>;
/**
* Type to check whether a type's property matches the constraint type
* and return its key. Converts the key to a {@link Key}.
* @typeParam T - type whose property should be checked
* @typeParam K - key of the property
* @typeParam U - constraint type
* @example
* ```
* CheckKeyConstraint<{foo: string}, 'foo', string> = 'foo'
* CheckKeyConstraint<{foo: string}, 'foo', number> = never
* CheckKeyConstraint<string[], number, string> = `${number}`
* ```
*/
export type CheckKeyConstraint<T, K extends Key, U> = K extends any ? EvaluateKey<T, K> extends U ? K : never : never;
/**
* Type which evaluates to true when the type is an array or tuple or is a union
* which contains an array or tuple.
* @typeParam T - type
* @example
* ```
* ContainsIndexable<{foo: string}> = false
* ContainsIndexable<{foo: string} | number[]> = true
* ```
*/
export type ContainsIndexable<T> = IsNever<Extract<T, ReadonlyArray<any>>> extends true ? false : true;
/**
* Type to implement {@link Keys} for non-nullable values.
* @typeParam T - non-nullable type whose property should be checked
*/
type KeysImpl<T> = [T] extends [Traversable] ? ContainsIndexable<T> extends true ? NumericKeys<T> : ObjectKeys<T> : never;
/**
* Type to find all properties of a type that match the constraint type
* and return their keys.
* If a union is passed, it evaluates to the overlapping keys.
* @typeParam T - type whose property should be checked
* @typeParam U - constraint type
* @example
* ```
* Keys<{foo: string, bar: string}, string> = 'foo' | 'bar'
* Keys<{foo?: string, bar?: string}> = 'foo' | 'bar'
* Keys<{foo: string, bar: number}, string> = 'foo'
* Keys<[string, number], string> = '0'
* Keys<string[], string> = `${number}`
* Keys<{0: string, '1': string} | [number] | number[]> = '0'
* ```
*/
export type Keys<T, U = unknown> = IsAny<T> extends true ? Key : IsNever<T> extends true ? Key : IsNever<NonNullable<T>> extends true ? never : CheckKeyConstraint<T, KeysImpl<NonNullable<T>>, U>;
/**
* Type to check whether a {@link Key} is present in a type.
* If a union of {@link Key}s is passed, all {@link Key}s have to be present
* in the type.
* @typeParam T - type which is introspected
* @typeParam K - key
* @example
* ```
* HasKey<{foo: string}, 'foo'> = true
* HasKey<{foo: string}, 'bar'> = false
* HasKey<{foo: string}, 'foo' | 'bar'> = false
* ```
*/
export type HasKey<T, K extends Key> = IsNever<Exclude<K, Keys<T>>>;
/**
* Type to implement {@link ValidPathPrefix} tail recursively.
* @typeParam T - type which the path should be checked against
* @typeParam PT - path which should exist within the given type
* @typeParam VPT - accumulates the prefix of {@link Key}s which have been
* confirmed to exist already
*/
type ValidPathPrefixImpl<T, PT extends PathTuple, VPT extends PathTuple> = PT extends [infer K, ...infer R] ? HasKey<T, AsKey<K>> extends true ? ValidPathPrefixImpl<EvaluateKey<T, AsKey<K>>, AsPathTuple<R>, AsPathTuple<[...VPT, K]>> : VPT : VPT;
/**
* Type to find the longest path prefix which is still valid,
* i.e. exists within the given type.
* @typeParam T - type which the path should be checked against
* @typeParam PT - path which should exist within the given type
* @example
* ```
* ValidPathPrefix<{foo: {bar: string}}, ['foo', 'bar']> = ['foo', 'bar']
* ValidPathPrefix<{foo: {bar: string}}, ['foo', 'ba']> = ['foo']
* ```
*/
export type ValidPathPrefix<T, PT extends PathTuple> = ValidPathPrefixImpl<T, PT, [
]>;
/**
* Type to check whether a path through a type exists.
* @typeParam T - type which the path should be checked against
* @typeParam PT - path which should exist within the given type
* @example
* ```
* HasPath<{foo: {bar: string}}, ['foo', 'bar']> = true
* HasPath<{foo: {bar: string}}, ['foo', 'ba']> = false
* ```
*/
export type HasPath<T, PT extends PathTuple> = ValidPathPrefix<T, PT> extends PT ? true : false;
export {};
//# sourceMappingURL=common.d.ts.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,135 @@
import type { FieldValues } from '../fields';
import type { BrowserNativeObject, IsAny, IsEqual, Primitive } from '../utils';
import type { ArrayKey, IsTuple, TupleKeys } from './common';
/**
* Helper function to break apart T1 and check if any are equal to T2
*
* See {@link IsEqual}
*/
type AnyIsEqual<T1, T2> = T1 extends T2 ? IsEqual<T1, T2> extends true ? true : never : never;
/**
* Helper type for recursively constructing paths through a type.
* This actually constructs the strings and recurses into nested
* object types.
*
* See {@link Path}
*/
type PathImpl<K extends string | number, V, TraversedTypes> = V extends Primitive | BrowserNativeObject ? `${K}` : true extends AnyIsEqual<TraversedTypes, V> ? `${K}` : `${K}` | `${K}.${PathInternal<V, TraversedTypes | V>}`;
/**
* Helper type for recursively constructing paths through a type.
* This obscures the internal type param TraversedTypes from exported contract.
*
* See {@link Path}
*/
type PathInternal<T, TraversedTypes = T> = T extends ReadonlyArray<infer V> ? IsTuple<T> extends true ? {
[K in TupleKeys<T>]-?: PathImpl<K & string, T[K], TraversedTypes>;
}[TupleKeys<T>] : PathImpl<ArrayKey, V, TraversedTypes> : {
[K in keyof T]-?: PathImpl<K & string, T[K], TraversedTypes>;
}[keyof T];
/**
* Type which eagerly collects all paths through a type
* @typeParam T - type which should be introspected
* @example
* ```
* Path<{foo: {bar: string}}> = 'foo' | 'foo.bar'
* ```
*/
export type Path<T> = T extends any ? PathInternal<T> : never;
/**
* See {@link Path}
*/
export type FieldPath<TFieldValues extends FieldValues> = Path<TFieldValues>;
/**
* Helper type for recursively constructing paths through a type.
* This actually constructs the strings and recurses into nested
* object types.
*
* See {@link ArrayPath}
*/
type ArrayPathImpl<K extends string | number, V, TraversedTypes> = V extends Primitive | BrowserNativeObject ? IsAny<V> extends true ? string : never : V extends ReadonlyArray<infer U> ? U extends Primitive | BrowserNativeObject ? IsAny<V> extends true ? string : never : true extends AnyIsEqual<TraversedTypes, V> ? never : `${K}` | `${K}.${ArrayPathInternal<V, TraversedTypes | V>}` : true extends AnyIsEqual<TraversedTypes, V> ? never : `${K}.${ArrayPathInternal<V, TraversedTypes | V>}`;
/**
* Helper type for recursively constructing paths through a type.
* This obscures the internal type param TraversedTypes from exported contract.
*
* See {@link ArrayPath}
*/
type ArrayPathInternal<T, TraversedTypes = T> = T extends ReadonlyArray<infer V> ? IsTuple<T> extends true ? {
[K in TupleKeys<T>]-?: ArrayPathImpl<K & string, T[K], TraversedTypes>;
}[TupleKeys<T>] : ArrayPathImpl<ArrayKey, V, TraversedTypes> : {
[K in keyof T]-?: ArrayPathImpl<K & string, T[K], TraversedTypes>;
}[keyof T];
/**
* Type which eagerly collects all paths through a type which point to an array
* type.
* @typeParam T - type which should be introspected.
* @example
* ```
* Path<{foo: {bar: string[], baz: number[]}}> = 'foo.bar' | 'foo.baz'
* ```
*/
export type ArrayPath<T> = T extends any ? ArrayPathInternal<T> : never;
/**
* See {@link ArrayPath}
*/
export type FieldArrayPath<TFieldValues extends FieldValues> = ArrayPath<TFieldValues>;
/**
* Type to evaluate the type which the given path points to.
* @typeParam T - deeply nested type which is indexed by the path
* @typeParam P - path into the deeply nested type
* @example
* ```
* PathValue<{foo: {bar: string}}, 'foo.bar'> = string
* PathValue<[number, string], '1'> = string
* ```
*/
export type PathValue<T, P extends Path<T> | ArrayPath<T>> = PathValueImpl<T, P>;
type PathValueImpl<T, P extends string> = T extends any ? P extends `${infer K}.${infer R}` ? K extends keyof T ? undefined extends T[K] ? PathValueImpl<T[K], R> | undefined : PathValueImpl<T[K], R> : K extends `${ArrayKey}` ? T extends ReadonlyArray<infer V> ? PathValueImpl<V, R> : never : never : P extends keyof T ? T[P] : P extends `${ArrayKey}` ? T extends ReadonlyArray<infer V> ? V : T extends undefined ? undefined : never : never : never;
/**
* See {@link PathValue}
*/
export type FieldPathValue<TFieldValues extends FieldValues, TFieldPath extends FieldPath<TFieldValues>> = PathValue<TFieldValues, TFieldPath>;
/**
* See {@link PathValue}
*/
export type FieldArrayPathValue<TFieldValues extends FieldValues, TFieldArrayPath extends FieldArrayPath<TFieldValues>> = PathValue<TFieldValues, TFieldArrayPath>;
/**
* Type to evaluate the type which the given paths point to.
* @typeParam TFieldValues - field values which are indexed by the paths
* @typeParam TPath - paths into the deeply nested field values
* @example
* ```
* FieldPathValues<{foo: {bar: string}}, ['foo', 'foo.bar']>
* = [{bar: string}, string]
* ```
*/
export type FieldPathValues<TFieldValues extends FieldValues, TPath extends FieldPath<TFieldValues>[] | readonly FieldPath<TFieldValues>[]> = {} & {
[K in keyof TPath]: FieldPathValue<TFieldValues, TPath[K] & FieldPath<TFieldValues>>;
};
/**
* Type which eagerly collects all paths through a fieldType that matches a give type
* @typeParam TFieldValues - field values which are indexed by the paths
* @typeParam TValue - the value you want to match into each type
* @example
* ```typescript
* FieldPathByValue<{foo: {bar: number}, baz: number, bar: string}, number>
* = 'foo.bar' | 'baz'
* ```
*/
export type FieldPathByValue<TFieldValues extends FieldValues, TValue> = {
[Key in FieldPath<TFieldValues>]: FieldPathValue<TFieldValues, Key> extends TValue ? Key : never;
}[FieldPath<TFieldValues>];
/**
* Type which eagerly collects all array paths through a fieldType that matches a give type
* @typeParam TFieldValues - field values which are indexed by the paths
* @typeParam TValue - the value you want to match into each type
* @example
* ```typescript
* FieldArrayPathByValue<{foo: {bar: number}[], baz: number, bar: string}, {bar: number}[]>
* = 'foo'
* ```
*/
export type FieldArrayPathByValue<TFieldValues extends FieldValues, TValue> = {
[Key in FieldArrayPath<TFieldValues>]: FieldArrayPathValue<TFieldValues, Key> extends TValue ? Key : never;
}[FieldArrayPath<TFieldValues>];
export {};
//# source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