Project Init

This commit is contained in:
Muluhabt
2026-05-29 15:23:46 +03:00
commit 2fbc557aac
67387 changed files with 6063341 additions and 0 deletions

9
node_modules/@mantine/form/lib/Form/Form.d.ts generated vendored Normal file
View File

@@ -0,0 +1,9 @@
import { TransformedValues, UseFormReturnType } from '../types';
export interface FormProps<Form extends UseFormReturnType<any>> extends React.ComponentPropsWithRef<'form'> {
form: Form;
onSubmit?: (values: TransformedValues<Form>) => void;
}
export type FormComponent = (<Form extends UseFormReturnType<any>>(props: FormProps<Form>) => React.JSX.Element | React.ReactNode) & {
displayName?: string;
};
export declare const Form: FormComponent;

View File

@@ -0,0 +1,6 @@
import { _TransformValues, UseForm, UseFormReturnType } from '../types';
export interface FormProviderProps<Form> {
form: Form;
children: React.ReactNode;
}
export declare function createFormContext<Values, TransformValues extends _TransformValues<Values> = (values: Values) => Values>(): [React.FC<FormProviderProps<UseFormReturnType<Values, TransformValues>>>, () => UseFormReturnType<Values, TransformValues>, UseForm<Values, TransformValues>];

23
node_modules/@mantine/form/lib/actions/actions.d.ts generated vendored Normal file
View File

@@ -0,0 +1,23 @@
import { useLayoutEffect } from 'react';
import type { _TransformValues, ClearErrors, ClearFieldError, InsertListItem, RemoveListItem, ReorderListItem, Reset, ResetDirty, ResetStatus, SetErrors, SetFieldError, SetFieldValue, SetFormStatus, SetInitialValues, SetValues, UseFormReturnType, ValidateField } from '../types';
export declare const useIsomorphicEffect: typeof useLayoutEffect;
export declare function createFormActions<FormValues extends Record<string, any> = Record<string, any>>(name: string): {
setFieldValue: SetFieldValue<FormValues>;
setValues: SetValues<FormValues>;
setInitialValues: SetInitialValues<FormValues>;
setErrors: SetErrors;
setFieldError: SetFieldError<FormValues>;
clearFieldError: ClearFieldError;
clearErrors: ClearErrors;
reset: Reset;
validate: () => void;
validateField: ValidateField<FormValues>;
reorderListItem: ReorderListItem<FormValues>;
removeListItem: RemoveListItem<FormValues>;
insertListItem: InsertListItem<FormValues>;
setDirty: SetFormStatus;
setTouched: SetFormStatus;
resetDirty: ResetDirty<FormValues>;
resetTouched: ResetStatus;
};
export declare function useFormActions<Values = Record<string, unknown>, TransformValues extends _TransformValues<Values> = (values: Values) => Values>(name: string | undefined, form: UseFormReturnType<Values, TransformValues>): void;

1
node_modules/@mantine/form/lib/actions/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export { createFormActions, useFormActions } from './actions';

1
node_modules/@mantine/form/lib/form-index.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export declare const FORM_INDEX = "__MANTINE_FORM_INDEX__";

View File

@@ -0,0 +1 @@
export declare function getInputOnChange<Value>(setValue: (value: Value | ((current: Value) => Value)) => void): (val: Value | React.ChangeEvent<unknown> | ((current: Value) => Value)) => void;

View File

@@ -0,0 +1 @@
export { getInputOnChange } from './get-input-on-change';

View File

@@ -0,0 +1,2 @@
import { FormStatus } from '../types';
export declare function getStatus(status: FormStatus, path?: unknown): boolean;

1
node_modules/@mantine/form/lib/get-status/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export { getStatus } from './get-status';

View File

@@ -0,0 +1,2 @@
import type { FormErrors } from '../../../types';
export declare function filterErrors(errors: FormErrors): FormErrors;

View File

@@ -0,0 +1,9 @@
import { ClearErrors, ClearFieldError, FormErrors, SetErrors, SetFieldError } from '../../types';
export interface $FormErrors<Values extends Record<string, any>> {
errorsState: FormErrors;
setErrors: SetErrors;
clearErrors: ClearErrors;
setFieldError: SetFieldError<Values>;
clearFieldError: ClearFieldError;
}
export declare function useFormErrors<Values extends Record<string, any>>(initialErrors: FormErrors): $FormErrors<Values>;

View File

@@ -0,0 +1,16 @@
import { InsertListItem, RemoveListItem, ReorderListItem, ReplaceListItem } from '../../types';
import type { $FormErrors } from '../use-form-errors/use-form-errors';
import type { $FormStatus } from '../use-form-status/use-form-status';
import type { $FormValues } from '../use-form-values/use-form-values';
interface UseFormListInput<Values extends Record<string, any>> {
$values: $FormValues<Values>;
$errors: $FormErrors<Values>;
$status: $FormStatus<Values>;
}
export declare function useFormList<Values extends Record<string, any>>({ $values, $errors, $status, }: UseFormListInput<Values>): {
reorderListItem: ReorderListItem<Values>;
removeListItem: RemoveListItem<Values>;
insertListItem: InsertListItem<Values>;
replaceListItem: ReplaceListItem<Values>;
};
export {};

View File

@@ -0,0 +1,30 @@
import { ClearFieldDirty, FormMode, FormStatus, GetFieldStatus, ResetStatus, SetCalculatedFieldDirty, SetFieldDirty, SetFieldTouched } from '../../types';
import type { $FormValues } from '../use-form-values/use-form-values';
export interface $FormStatus<Values extends Record<string, any>> {
touchedState: FormStatus;
dirtyState: FormStatus;
touchedRef: React.RefObject<FormStatus>;
dirtyRef: React.RefObject<FormStatus>;
setTouched: React.Dispatch<React.SetStateAction<FormStatus>>;
setDirty: React.Dispatch<React.SetStateAction<FormStatus>>;
resetDirty: ResetStatus;
resetTouched: ResetStatus;
isTouched: GetFieldStatus<Values>;
setFieldTouched: SetFieldTouched<Values>;
setFieldDirty: SetFieldDirty<Values>;
setTouchedState: React.Dispatch<React.SetStateAction<FormStatus>>;
setDirtyState: React.Dispatch<React.SetStateAction<FormStatus>>;
clearFieldDirty: ClearFieldDirty;
isDirty: GetFieldStatus<Values>;
getDirty: () => FormStatus;
getTouched: () => FormStatus;
setCalculatedFieldDirty: SetCalculatedFieldDirty<Values>;
}
interface UseFormStatusInput<Values extends Record<string, any>> {
initialDirty: FormStatus;
initialTouched: FormStatus;
mode: FormMode;
$values: $FormValues<Values>;
}
export declare function useFormStatus<Values extends Record<string, any>>({ initialDirty, initialTouched, mode, $values, }: UseFormStatusInput<Values>): $FormStatus<Values>;
export {};

View File

@@ -0,0 +1,40 @@
import { FormMode } from '../../types';
export interface $FormValues<Values extends Record<PropertyKey, any>> {
initialized: React.RefObject<boolean>;
stateValues: Values;
refValues: React.RefObject<Values>;
valuesSnapshot: React.RefObject<Values>;
setValues: (payload: SetValuesInput<Values>) => void;
setFieldValue: (payload: SetFieldValueInput<Values>) => void;
resetValues: () => void;
setValuesSnapshot: (payload: Values) => void;
initialize: (values: Values, onInitialize: () => void) => void;
getValues: () => Values;
getValuesSnapshot: () => Values;
resetField: (path: PropertyKey, subscribers?: (SetFieldValueSubscriber<Values> | null | undefined)[]) => void;
}
export interface SetValuesSubscriberPayload<Values> {
path?: PropertyKey;
updatedValues: Values;
previousValues: Values;
}
export interface SetValuesInput<Values> {
values: Partial<Values> | ((values: Values) => Partial<Values>);
mergeWithPreviousValues?: boolean;
updateState?: boolean;
subscribers?: (SetFieldValueSubscriber<Values> | null | undefined)[];
}
export type SetFieldValueSubscriber<Values> = (payload: SetValuesSubscriberPayload<Values>) => void;
export interface SetFieldValueInput<Values> {
path: PropertyKey;
value: any;
updateState?: boolean;
subscribers?: (SetFieldValueSubscriber<Values> | null | undefined)[];
}
interface UseFormValuesInput<Values extends Record<PropertyKey, any>> {
initialValues: Values | undefined;
mode: FormMode;
onValuesChange?: ((values: Values, previousValues: Values) => void) | undefined;
}
export declare function useFormValues<Values extends Record<PropertyKey, any>>({ initialValues, onValuesChange, mode, }: UseFormValuesInput<Values>): $FormValues<Values>;
export {};

View File

@@ -0,0 +1,14 @@
import { LooseKeys } from '../../paths.types';
import { FormFieldSubscriber, Watch } from '../../types';
import { $FormStatus } from '../use-form-status/use-form-status';
import { SetValuesSubscriberPayload } from '../use-form-values/use-form-values';
interface UseFormWatchInput<Values extends Record<string, any>> {
$status: $FormStatus<Values>;
cascadeUpdates?: boolean;
}
export declare function useFormWatch<Values extends Record<string, any>>({ $status, cascadeUpdates, }: UseFormWatchInput<Values>): {
subscribers: import("react").RefObject<Record<LooseKeys<Values>, FormFieldSubscriber<Values, any>[]>>;
watch: Watch<Values>;
getFieldSubscribers: (path: LooseKeys<Values>) => ((input: SetValuesSubscriberPayload<Values>) => void)[];
};
export {};

15
node_modules/@mantine/form/lib/index.d.mts generated vendored Normal file
View File

@@ -0,0 +1,15 @@
export { useForm } from './use-form.js';
export { createFormContext } from './FormProvider/FormProvider.js';
export { createFormActions } from './actions/index.js';
export { Form } from './Form/Form.js';
export { FORM_INDEX } from './form-index.js';
export * from './validators/index.js';
export { useField } from './use-field.js';
export { formRootRule } from './validate/validate-values.js';
export { zodResolver } from './resolvers/zod-resolver/zod-resolver';
export { superstructResolver } from './resolvers/superstruct-resolver/superstruct-resolver';
export { yupResolver } from './resolvers/yup-resolver/yup-resolver';
export { joiResolver } from './resolvers/joi-resolver/joi-resolver';
export type * from './types';
export type { UseFieldInput, UseFieldReturnType } from './use-field';
export type { FormArrayElement, LooseKeys } from './paths.types.js';

15
node_modules/@mantine/form/lib/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,15 @@
export { useForm } from './use-form.js';
export { createFormContext } from './FormProvider/FormProvider.js';
export { createFormActions } from './actions/index.js';
export { Form } from './Form/Form.js';
export { FORM_INDEX } from './form-index.js';
export * from './validators/index.js';
export { useField } from './use-field.js';
export { formRootRule } from './validate/validate-values.js';
export { zodResolver } from './resolvers/zod-resolver/zod-resolver';
export { superstructResolver } from './resolvers/superstruct-resolver/superstruct-resolver';
export { yupResolver } from './resolvers/yup-resolver/yup-resolver';
export { joiResolver } from './resolvers/joi-resolver/joi-resolver';
export type * from './types';
export type { UseFieldInput, UseFieldReturnType } from './use-field';
export type { FormArrayElement, LooseKeys } from './paths.types.js';

View File

@@ -0,0 +1,5 @@
/**
* Changes the indices of every error that is after the given `index` with the given `change` at the given `path`.
* This requires that the errors are in the format of `path.index` and that the index is a number.
*/
export declare function changeErrorIndices<T extends Record<PropertyKey, any>>(path: PropertyKey, index: number | undefined, errors: T, change: 1 | -1): T;

View File

@@ -0,0 +1 @@
export declare function clearListState<T extends Record<PropertyKey, any>>(field: PropertyKey, state: T): T;

3
node_modules/@mantine/form/lib/lists/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
export { clearListState } from './clear-list-state';
export { changeErrorIndices } from './change-error-indices';
export { reorderErrors } from './reorder-errors';

View File

@@ -0,0 +1,2 @@
import { ReorderPayload } from '../types';
export declare function reorderErrors<T>(path: unknown, { from, to }: ReorderPayload, errors: T): T;

24
node_modules/@mantine/form/lib/paths.types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,24 @@
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
type ArrayKey = number;
type IsTuple<T extends readonly any[]> = number extends T['length'] ? false : true;
type TupleKeys<T extends readonly any[]> = Exclude<keyof T, keyof any[]>;
type Prev = [never, 0, 1, 2, 3, 4, 5];
type Depth = 5;
type PathConcat<TKey extends string | number, TValue, D extends number> = TValue extends Primitive ? `${TKey}` : `${TKey}` | `${TKey}.${Path<TValue, Prev[D]>}`;
export type Path<T, D extends number = Depth> = [D] extends [never] ? never : T extends readonly (infer V)[] ? IsTuple<T> extends true ? {
[K in TupleKeys<T>]-?: PathConcat<K & string, T[K], D>;
}[TupleKeys<T>] : PathConcat<ArrayKey, V, D> : {
[K in keyof T]-?: PathConcat<K & string, T[K], D>;
}[keyof T];
type ArrayPathConcat<TKey extends string | number, TValue, D extends number> = [D] extends [never] ? never : TValue extends Primitive ? never : TValue extends readonly (infer U)[] ? U extends Primitive ? never : `${TKey}` | `${TKey}.${ArrayPath<TValue, Prev[D]>}` : `${TKey}.${ArrayPath<TValue, Prev[D]>}`;
export type ArrayPath<T, D extends number = Depth> = [D] extends [never] ? never : T extends readonly (infer V)[] ? IsTuple<T> extends true ? {
[K in TupleKeys<T>]-?: ArrayPathConcat<K & string, T[K], D>;
}[TupleKeys<T>] : ArrayPathConcat<ArrayKey, V, D> : {
[K in keyof T]-?: ArrayPathConcat<K & string, T[K], D>;
}[keyof T];
export type PathValue<T, TPath extends string> = T extends any ? TPath extends `${infer K}.${infer R}` ? K extends keyof T ? R extends Path<T[K]> ? undefined extends T[K] ? PathValue<T[K], R> | undefined : PathValue<T[K], R> : never : K extends `${ArrayKey}` ? T extends readonly (infer V)[] ? PathValue<V, R & Path<V>> : never : never : TPath extends keyof T ? T[TPath] : TPath extends `${ArrayKey}` ? T extends readonly (infer V)[] ? V : never : never : never;
export type FormPathValue<T, TPath extends string> = PathValue<T, TPath> extends never ? any : PathValue<T, TPath>;
export type ArrayElement<T> = T extends readonly (infer U)[] ? U : never;
export type FormArrayElement<T, TPath extends string> = ArrayElement<FormPathValue<T, TPath>> extends never ? any : ArrayElement<FormPathValue<T, TPath>>;
export type LooseKeys<T> = Path<T> | ArrayPath<T> | (string & {});
export {};

View File

@@ -0,0 +1 @@
export declare function getDataPath(formName: string | undefined, fieldPath: PropertyKey): string;

1
node_modules/@mantine/form/lib/paths/get-path.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export declare function getPath(path: unknown, values: unknown): unknown;

View File

@@ -0,0 +1 @@
export declare function getSplittedPath(path: unknown): string[];

7
node_modules/@mantine/form/lib/paths/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,7 @@
export { getPath } from './get-path';
export { setPath } from './set-path';
export { reorderPath } from './reorder-path';
export { insertPath } from './insert-path';
export { removePath } from './remove-path';
export { getDataPath } from './get-data-path';
export { replacePath } from './replace-path';

View File

@@ -0,0 +1 @@
export declare function insertPath<T>(path: unknown, value: unknown, index: number | undefined, values: T): T;

View File

@@ -0,0 +1 @@
export declare function removePath<T>(path: unknown, index: number, values: T): T;

View File

@@ -0,0 +1,2 @@
import { ReorderPayload } from '../types';
export declare function reorderPath<T>(path: unknown, { from, to }: ReorderPayload, values: T): T;

View File

@@ -0,0 +1 @@
export declare function replacePath<T>(path: unknown, item: unknown, index: number, values: T): T;

1
node_modules/@mantine/form/lib/paths/set-path.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export declare function setPath<T>(path: unknown, value: unknown, values: T): T;

View File

@@ -0,0 +1,3 @@
import type { FormErrors } from '../../types';
/** @deprecated Use https://github.com/mantinedev/mantine-form-joi-resolver */
export declare function joiResolver(schema: any, options?: any): (values: Record<string, any>) => FormErrors;

View File

@@ -0,0 +1,3 @@
import type { FormErrors } from '../../types';
/** @deprecated Use https://github.com/mantinedev/mantine-form-superstruct-resolver */
export declare function superstructResolver(schema: any): (values: Record<string, any>) => FormErrors;

View File

@@ -0,0 +1,3 @@
import type { FormErrors } from '../../types';
/** @deprecated Use https://github.com/mantinedev/mantine-form-yup-resolver */
export declare function yupResolver(schema: any): (values: Record<string, any>) => FormErrors;

View File

@@ -0,0 +1,20 @@
import type { FormErrors } from '../../types';
interface ZodError {
path: (string | number)[];
message: string;
}
interface ZodParseSuccess {
success: true;
}
interface ZodParseError {
success: false;
error: {
errors: ZodError[];
};
}
interface ZodSchema<T extends Record<string, any>> {
safeParse: (values: T) => ZodParseSuccess | ZodParseError;
}
/** @deprecated Use https://github.com/mantinedev/mantine-form-zod-resolver */
export declare function zodResolver<T extends Record<string, any>>(schema: ZodSchema<T>): (values: T) => FormErrors;
export {};

155
node_modules/@mantine/form/lib/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,155 @@
import type { FormArrayElement, FormPathValue, LooseKeys } from './paths.types';
import type { formRootRule } from './validate/validate-values';
export type GetInputPropsType = 'input' | 'checkbox';
export type FormMode = 'controlled' | 'uncontrolled';
export type FormStatus = Record<string, boolean>;
export interface FormFieldValidationResult {
hasError: boolean;
error: React.ReactNode;
}
export interface FormValidationResult {
hasErrors: boolean;
errors: FormErrors;
}
export type FormErrors = Record<string, React.ReactNode>;
export interface ReorderPayload {
from: number;
to: number;
}
type Rule<Value, Values> = (value: Value, values: Values, path: string) => React.ReactNode;
type SetSubmitting = React.Dispatch<React.SetStateAction<boolean>>;
export type FormRule<Value, Values> = NonNullable<Value> extends ReadonlyArray<infer ListValue> ? Partial<{
[Key in keyof ListValue]: ListValue[Key] extends ReadonlyArray<infer NestedListItem> ? FormRulesRecord<NestedListItem, Values> | Rule<ListValue[Key], Values> : FormRulesRecord<ListValue[Key], Values> | Rule<ListValue[Key], Values>;
} & {
[formRootRule]?: Rule<Value, Values>;
}> | Rule<Value, Values> : NonNullable<Value> extends Record<string, any> ? FormRulesRecord<Value, Values> | Rule<Value, Values> : Rule<Value, Values>;
export type FormRulesRecord<Values, InitValues = Values> = Partial<{
[Key in keyof Values]: FormRule<Values[Key], InitValues>;
}> & {
[formRootRule]?: Rule<Values, InitValues>;
};
export type FormValidateInput<Values> = FormRulesRecord<Values> | ((values: Values) => FormErrors);
export type SetValues<Values> = React.Dispatch<React.SetStateAction<Partial<Values>>>;
export type SetInitialValues<Values> = (values: Values) => void;
export type SetErrors = React.Dispatch<React.SetStateAction<FormErrors>>;
export type SetFormStatus = React.Dispatch<React.SetStateAction<FormStatus>>;
export type OnSubmit<Values, TransformValues extends _TransformValues<Values>> = (handleSubmit: (values: ReturnType<TransformValues>, event: React.FormEvent<HTMLFormElement> | undefined) => void | Promise<any>, handleValidationFailure?: (errors: FormErrors, values: Values, event: React.FormEvent<HTMLFormElement> | undefined) => void) => (event?: React.FormEvent<HTMLFormElement>) => void;
export type GetTransformedValues<Values, TransformValues extends _TransformValues<Values>> = (values?: Values) => ReturnType<TransformValues>;
export type OnReset = (event: React.FormEvent<HTMLFormElement>) => void;
export interface GetInputPropsOptions {
type?: GetInputPropsType;
withError?: boolean;
withFocus?: boolean;
[key: string]: any;
}
export interface GetInputPropsReturnType {
onChange: any;
value?: any;
defaultValue?: any;
checked?: any;
defaultChecked?: any;
error?: any;
onFocus?: any;
onBlur?: any;
}
export type GetInputProps<Values> = <Field extends LooseKeys<Values>>(path: Field, options?: GetInputPropsOptions) => GetInputPropsReturnType;
export type SetFieldValue<Values> = <Field extends LooseKeys<Values>>(path: Field, value: FormPathValue<Values, Field> | ((prevValue: FormPathValue<Values, Field>) => FormPathValue<Values, Field>), options?: {
forceUpdate: boolean;
}) => void;
export type ClearFieldError = (path: unknown) => void;
export type ClearFieldDirty = (path: unknown) => void;
export type ClearErrors = () => void;
export type Reset = () => void;
export type Validate = () => FormValidationResult;
export type ValidateField<Values> = <Field extends LooseKeys<Values>>(path: Field) => FormFieldValidationResult;
export type SetFieldError<Values> = <Field extends LooseKeys<Values>>(path: Field, error: React.ReactNode) => void;
export type SetFieldTouched<Values> = <Field extends LooseKeys<Values>>(path: Field, touched: boolean) => void;
export type SetFieldDirty<Values> = <Field extends LooseKeys<Values>>(path: Field, dirty: boolean, forceUpdate?: boolean) => void;
export type SetCalculatedFieldDirty<Values> = <Field extends LooseKeys<Values>>(path: Field, value: FormPathValue<Values, Field>) => void;
export type ReorderListItem<Values> = <Field extends LooseKeys<Values>>(path: Field, payload: ReorderPayload) => void;
export type InsertListItem<Values> = <Field extends LooseKeys<Values>>(path: Field, item: FormArrayElement<Values, Field>, index?: number) => void;
export type ReplaceListItem<Values> = <Field extends LooseKeys<Values>>(path: Field, index: number, item: FormArrayElement<Values, Field>) => void;
export type RemoveListItem<Values> = <Field extends LooseKeys<Values>>(path: Field, index: number) => void;
export type GetFieldStatus<Values> = <Field extends LooseKeys<Values>>(path?: Field) => boolean;
export type ResetStatus = () => void;
export type GetStatus = () => FormStatus;
export type ResetDirty<Values> = (values?: Values) => void;
export type IsValid<Values> = <Field extends LooseKeys<Values>>(path?: Field) => boolean;
export type Initialize<Values> = (values: Values) => void;
export type _TransformValues<Values> = (values: Values) => unknown;
export type FormFieldSubscriber<Values, Field extends LooseKeys<Values>> = (input: {
previousValue: FormPathValue<Values, Field>;
value: FormPathValue<Values, Field>;
touched: boolean;
dirty: boolean;
}) => void;
export type Watch<Values> = <Field extends LooseKeys<Values>>(path: Field, subscriber: FormFieldSubscriber<Values, Field>) => void;
export type Key<Values> = <Field extends LooseKeys<Values>>(path: Field) => string;
export type GetInputNode<Values> = <NodeType extends HTMLElement, Field extends LooseKeys<Values>>(path: Field) => NodeType | null;
export interface UseFormInput<Values, TransformValues extends _TransformValues<Values> = (values: Values) => Values> {
name?: string;
mode?: FormMode;
initialValues?: Values;
initialErrors?: FormErrors;
initialTouched?: FormStatus;
initialDirty?: FormStatus;
transformValues?: TransformValues;
validate?: FormValidateInput<Values>;
clearInputErrorOnChange?: boolean;
validateInputOnChange?: boolean | LooseKeys<Values>[];
validateInputOnBlur?: boolean | LooseKeys<Values>[];
onValuesChange?: (values: Values, previous: Values) => void;
enhanceGetInputProps?: (payload: {
inputProps: GetInputPropsReturnType;
field: LooseKeys<Values>;
options: GetInputPropsOptions;
form: UseFormReturnType<Values, TransformValues>;
}) => Record<string, any> | undefined | void;
onSubmitPreventDefault?: 'always' | 'never' | 'validation-failed';
touchTrigger?: 'focus' | 'change';
cascadeUpdates?: boolean;
}
export interface UseFormReturnType<Values, TransformValues extends _TransformValues<Values> = (values: Values) => Values> {
values: Values;
submitting: boolean;
initialized: boolean;
errors: FormErrors;
setSubmitting: SetSubmitting;
initialize: Initialize<Values>;
setValues: SetValues<Values>;
setInitialValues: SetInitialValues<Values>;
setErrors: SetErrors;
setFieldValue: SetFieldValue<Values>;
setFieldError: SetFieldError<Values>;
clearFieldError: ClearFieldError;
clearErrors: ClearErrors;
reset: Reset;
validate: Validate;
validateField: ValidateField<Values>;
reorderListItem: ReorderListItem<Values>;
removeListItem: RemoveListItem<Values>;
replaceListItem: ReplaceListItem<Values>;
insertListItem: InsertListItem<Values>;
getInputProps: GetInputProps<Values>;
onSubmit: OnSubmit<Values, TransformValues>;
onReset: OnReset;
isDirty: GetFieldStatus<Values>;
isTouched: GetFieldStatus<Values>;
setTouched: SetFormStatus;
setDirty: SetFormStatus;
resetTouched: ResetStatus;
resetDirty: ResetDirty<Values>;
isValid: IsValid<Values>;
getTransformedValues: GetTransformedValues<Values, TransformValues>;
getValues: () => Values;
getInitialValues: () => Values;
getTouched: GetStatus;
getDirty: GetStatus;
watch: Watch<Values>;
key: Key<Values>;
getInputNode: GetInputNode<Values>;
resetField: (path: PropertyKey) => void;
}
export type UseForm<Values = Record<string, unknown>, TransformValues extends _TransformValues<Values> = (values: Values) => Values> = (input?: UseFormInput<Values, TransformValues>) => UseFormReturnType<Values, TransformValues>;
export type TransformedValues<Form extends UseFormReturnType<any>> = Parameters<Parameters<Form['onSubmit']>[0]>[0];
export {};

74
node_modules/@mantine/form/lib/use-field.d.ts generated vendored Normal file
View File

@@ -0,0 +1,74 @@
import { FormMode, GetInputPropsType } from './types';
type UseFieldErrorResolver = (error: unknown) => React.ReactNode;
export interface UseFieldInput<T, FieldType extends GetInputPropsType = 'input', Mode extends FormMode = 'controlled'> {
/** Field mode, controlled by default */
mode?: Mode;
/** Initial field value */
initialValue: T;
/** Initial touched value */
initialTouched?: boolean;
/** Initial field error message */
initialError?: React.ReactNode;
/** Called with updated value when the field value changes */
onValueChange?: (value: T) => void;
/** Determines whether the field should be validated when value changes, false by default */
validateOnChange?: boolean;
/** Determines whether the field should be validated when it loses focus, false by default */
validateOnBlur?: boolean;
/** Determines whether the field should clear error message when value changes, true by default */
clearErrorOnChange?: boolean;
/** A function to validate field value, can be sync or async */
validate?: (value: T) => React.ReactNode | Promise<React.ReactNode>;
/** Field type, input by default */
type?: FieldType;
/** A function to resolve validation error from the result returned from validate function, should return react node */
resolveValidationError?: UseFieldErrorResolver;
}
interface GetInputPropsOptions {
withError?: boolean;
withFocus?: boolean;
}
interface GetInputPropsSharedReturn {
error?: React.ReactNode;
onFocus?: () => void;
onBlur: () => void;
onChange: (value: any) => void;
}
type GetInputPropsTypeValue<T, FieldType extends GetInputPropsType, Mode extends FormMode> = FieldType extends 'checkbox' ? Mode extends 'controlled' ? {
checked: boolean;
} : {
defaultChecked: boolean;
} : Mode extends 'controlled' ? {
value: T;
} : {
defaultValue: T;
};
type GetInputPropsReturnType<T, FieldType extends GetInputPropsType, Mode extends FormMode> = GetInputPropsSharedReturn & GetInputPropsTypeValue<T, FieldType, Mode>;
export interface UseFieldReturnType<T, FieldType extends GetInputPropsType = 'input', Mode extends FormMode = 'controlled'> {
/** Returns props to pass to the input element */
getInputProps: (options?: GetInputPropsOptions) => GetInputPropsReturnType<T, FieldType, Mode>;
/** Returns current input value */
getValue: () => T;
/** Sets input value to the given value */
setValue: (value: T) => void;
/** Resets field value to initial state, sets touched state to false, sets error to null */
reset: () => void;
/** Validates current input value when called */
validate: () => Promise<React.ReactNode | void>;
/** Set to true when async validate function is called, stays true until the returned promise resolves */
isValidating: boolean;
/** Current error message */
error: React.ReactNode;
/** Sets error message to the given react node */
setError: (error: React.ReactNode) => void;
/** Returns true if the input has been focused at least once */
isTouched: () => boolean;
/** Returns true if input value is different from the initial value */
isDirty: () => boolean;
/** Resets touched state to false */
resetTouched: () => void;
/** Key that should be added to the input when mode is uncontrolled */
key: number;
}
export declare function useField<T, Mode extends FormMode = 'controlled', FieldType extends GetInputPropsType = 'input'>({ mode, clearErrorOnChange, initialValue, initialError, initialTouched, onValueChange, validateOnChange, validateOnBlur, validate, resolveValidationError, type, }: UseFieldInput<T, FieldType, Mode>): UseFieldReturnType<T, FieldType, Mode>;
export {};

2
node_modules/@mantine/form/lib/use-form.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import { _TransformValues, UseFormInput, UseFormReturnType } from './types';
export declare function useForm<Values extends Record<string, any> = Record<string, any>, TransformValues extends _TransformValues<Values> = (values: Values) => Values>({ name, mode, initialValues, initialErrors, initialDirty, initialTouched, clearInputErrorOnChange, validateInputOnChange, validateInputOnBlur, onValuesChange, transformValues, enhanceGetInputProps, validate: rules, onSubmitPreventDefault, touchTrigger, cascadeUpdates, }?: UseFormInput<Values, TransformValues>): UseFormReturnType<Values, TransformValues>;

3
node_modules/@mantine/form/lib/validate/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
export { validateValues, formRootRule } from './validate-values';
export { validateFieldValue } from './validate-field-value';
export { shouldValidateOnChange } from './should-validate-on-change';

View File

@@ -0,0 +1 @@
export declare function shouldValidateOnChange(path: unknown, validateInputOnChange: boolean | unknown[]): boolean;

View File

@@ -0,0 +1,2 @@
import { FormFieldValidationResult, FormValidateInput } from '../types';
export declare function validateFieldValue<T>(path: unknown, rules: FormValidateInput<T> | undefined, values: T): FormFieldValidationResult;

View File

@@ -0,0 +1,6 @@
import { FormErrors, FormValidateInput } from '../types';
export declare const formRootRule: unique symbol;
export declare function validateValues<T>(validate: FormValidateInput<T> | undefined, values: T): {
hasErrors: boolean;
errors: FormErrors;
};

View File

@@ -0,0 +1,7 @@
interface HasLengthOptions {
max?: number;
min?: number;
}
type HasLengthPayload = HasLengthOptions | number;
export declare function hasLength(payload: HasLengthPayload, error?: React.ReactNode): (value: unknown) => React.ReactNode;
export {};

8
node_modules/@mantine/form/lib/validators/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
export { isNotEmpty } from './is-not-empty/is-not-empty';
export { matches } from './matches/matches';
export { isEmail } from './is-email/is-email';
export { hasLength } from './has-length/has-length';
export { isInRange } from './is-in-range/is-in-range';
export { matchesField } from './matches-field/matches-field';
export { isNotEmptyHTML } from './is-not-empty-html/is-not-empty-html';
export { isJSONString } from './is-json-string/is-json-string';

View File

@@ -0,0 +1 @@
export declare function isEmail(error?: React.ReactNode): (value: unknown) => React.ReactNode;

View File

@@ -0,0 +1,6 @@
interface IsInRangePayload {
min?: number;
max?: number;
}
export declare function isInRange({ min, max }: IsInRangePayload, error?: React.ReactNode): (value: unknown) => React.ReactNode;
export {};

View File

@@ -0,0 +1 @@
export declare function isJSONString(error?: React.ReactNode): (value: unknown) => React.ReactNode;

View File

@@ -0,0 +1 @@
export declare function isNotEmptyHTML(error?: React.ReactNode): (value: unknown) => React.ReactNode;

View File

@@ -0,0 +1 @@
export declare function isNotEmpty(error?: React.ReactNode): (value: unknown) => React.ReactNode;

View File

@@ -0,0 +1 @@
export declare function matchesField<T>(field: keyof T, error?: React.ReactNode): (value: unknown, values: T) => React.ReactNode;

View File

@@ -0,0 +1 @@
export declare function matches(regexp: RegExp, error?: React.ReactNode): (value: unknown) => React.ReactNode;