import { ChangeEvent, MouseEventHandler, OptionHTMLAttributes, PropsWithChildren, ReactNode } from "react"; import { FieldAtom, FieldAtomConfig, FormAtom, FormFieldValues, FormFields, RESET, UseAtomOptions, UseFieldOptions, useFieldErrors } from "form-atoms"; import { Atom, ExtractAtomValue, Getter, WritableAtom } from "jotai"; import { ZodAny, ZodArray, ZodBoolean, ZodDate, ZodFile, ZodLiteral, ZodNumber, ZodObject, ZodSchema, ZodString, ZodUndefined, z } from "zod"; import { atomWithDefault } from "jotai/utils"; import { ListAtom, ListAtomConfig } from "@form-atoms/list-atom"; //#region src/atoms/types.d.ts type ExtendFieldAtom = FieldAtom extends Atom ? Atom : never; //#endregion //#region src/utils/schemaValidate.d.ts type ValidateConfig = { schema: Schema | ((get: Getter) => Schema); optionalSchema?: OptSchema | ((get: Getter) => OptSchema); }; type DefaultRequiredAtom = typeof defaultRequiredAtom; type WritableRequiredAtom = WritableAtom boolean)], void>; /** * Read-only atom for default zodFields which all are required. */ declare const defaultRequiredAtom: import("jotai").Atom; type ReadRequired = Parameters>[0]; //#endregion //#region src/utils/userValidateConfig.d.ts interface MakeSchema { (fieldSchema: Schema): Schema; (fieldSchema: Schema, get: Getter): Schema; } type UserValidateConfig = { /** * User's zod schema, or a function to enhance the initial field schema. */ schema?: Schema | MakeSchema; optionalSchema?: OptSchema | MakeSchema; }; //#endregion //#region src/fields/zod-field/zodField.d.ts type ZodFieldConfig = FieldAtomConfig | z.output> & ValidateConfig; export type ZodFieldValue = Field extends FieldAtom ? Value : never; export type ZodFieldSubmitValue = Field extends ZodField ? Required extends WritableRequiredAtom ? z.output | z.output : Required extends DefaultRequiredAtom ? z.output : never : never; export type OptionalZodField = ZodField; /** * This is an alias to ZodField, it hides the 3rd argument from type tooltip. */ export type RequiredZodField = ZodField; export type ZodField = ExtendFieldAtom | z.output, { required: RequiredAtom; }> & { optional: (readRequired?: ReadRequired) => OptionalZodField; }; export declare function zodField({ schema, optionalSchema, ...config }: ZodFieldConfig): RequiredZodField; //#endregion //#region src/fields/zod-field/zodParams.d.ts export type ZodParams = { required_error?: string; }; //#endregion //#region src/fields/field.d.ts /** * A public config for a field. */ type FieldConfig = Partial | z.output>> & UserValidateConfig & ZodParams; //#endregion //#region src/fields/array-field/arrayField.d.ts export type ZodArrayField = ZodField, ZodArray>; export type ArrayFieldParams = FieldConfig, ZodArray>; export declare const arrayField: ({ required_error, value, elementSchema, schema, optionalSchema, ...config }: { elementSchema: ElementSchema; } & ArrayFieldParams) => RequiredZodField, ZodArray>; //#endregion //#region src/fields/array-field/stringArrayField.d.ts declare const elementSchema$1: z.ZodString; export declare const stringArrayField: (params?: Partial>) => RequiredZodField, z.ZodArray>; export type StringArrayField = ReturnType; export type StringArrayFieldValue = ExtractAtomValue["value"]>; //#endregion //#region src/fields/boolean-field/booleanField.d.ts export type BooleanField = ReturnType; export type BooleanFieldValue = ExtractAtomValue["value"]>; export declare const booleanField: ({ required_error, ...config }?: Omit, "schema" | "optionalSchema">) => RequiredZodField; //#endregion //#region src/fields/checkbox-field/checkboxField.d.ts export type CheckboxField = ReturnType; export type CheckboxFieldValue = ExtractAtomValue["value"]>; export declare const checkboxField: ({ required_error, value, ...config }?: Partial, ZodBoolean>, "schema" | "optionalSchema" | "validate">>) => RequiredZodField, ZodBoolean>; //#endregion //#region src/fields/date-field/dateField.d.ts export type DateField = ReturnType; export type DateFieldValue = ExtractAtomValue["value"]>; export declare const dateField: ({ required_error, schema, optionalSchema, ...config }?: FieldConfig) => RequiredZodField; //#endregion //#region src/fields/digit-field/digitField.d.ts export type DigitField = ReturnType; export type DigitFieldValue = ExtractAtomValue["value"]>; declare const zodDigitSchema: z.ZodUnion, z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>, z.ZodLiteral<5>, z.ZodLiteral<6>, z.ZodLiteral<7>, z.ZodLiteral<8>, z.ZodLiteral<9>]>; type ZodDigitSchema = typeof zodDigitSchema; export declare const digitField: (config?: Omit, "schema" | "optionalSchema">) => RequiredZodField, z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>, z.ZodLiteral<5>, z.ZodLiteral<6>, z.ZodLiteral<7>, z.ZodLiteral<8>, z.ZodLiteral<9>]>, z.ZodUndefined>; //#endregion //#region src/fields/files-field/filesField.d.ts export type FilesField = ReturnType; export type FilesFieldValue = ExtractAtomValue["value"]>; export declare const filesField: (params?: Partial>) => RequiredZodField, ZodArray>; //#endregion //#region src/fields/list-field/listField.d.ts export type ExtendListAtom = ListAtom extends Atom ? Atom : never; export type ListField = ExtendListAtom & { optional: (readRequired?: ReadRequired) => OptionalListField; }; export type ListFieldSubmitValue = Required extends WritableRequiredAtom ? FormFieldSubmitValues[] : Required extends DefaultRequiredAtom ? [FormFieldSubmitValues, ...FormFieldSubmitValues[]] : never; /** * This is an alias to ListField, it hides the 2nd and 3rd argument from type tooltip. */ type RequiredListField = ListField>; export type OptionalListField = ListField; type ListFieldConfig = ListAtomConfig & ZodParams & UserValidateConfig, ZodArray>; export declare const listField: ({ required_error, schema, optionalSchema, ...config }: ListFieldConfig) => RequiredListField; //#endregion //#region src/fields/number-field/numberField.d.ts export type NumberField = ReturnType; export type NumberFieldValue = ExtractAtomValue["value"]>; export declare const numberField: ({ required_error, schema, optionalSchema, ...config }?: FieldConfig) => RequiredZodField; //#endregion //#region src/fields/string-field/stringField.d.ts export type StringField = ReturnType; export type StringFieldValue = ExtractAtomValue["value"]>; export declare const stringField: ({ required_error, schema, optionalSchema, ...config }?: FieldConfig) => RequiredZodField; //#endregion //#region src/fields/text-field/textField.d.ts export type TextField = ReturnType; export type TextFieldValue = ExtractAtomValue["value"]>; export declare const textField: ({ required_error, value, schema, optionalSchema, ...config }?: FieldConfig) => RequiredZodField; //#endregion //#region src/hooks/use-checkbox-field-props/useCheckboxFieldProps.d.ts export type CheckboxFieldProps = FieldProps; export declare function useCheckboxFieldProps(field: CheckboxField | BooleanField, options?: UseFieldOptions): { type: "checkbox"; checked: boolean; role: "checkbox"; "aria-checked": boolean; id: string; name: string | undefined; required: boolean; "aria-required": boolean; "aria-invalid": boolean | undefined; ref: (args_0: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement | ((value: HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | null) => HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | null) | null) => void; onBlur(): void; onChange(event: ChangeEvent): void; }; //#endregion //#region src/hooks/use-field-props/useFieldProps.d.ts export declare function useFieldProps(fieldAtom: Field, getEventValue: Element extends unknown ? (event: ChangeEvent, value: ZodFieldValue) => ZodFieldValue : never, options?: UseAtomOptions): { id: string; name: string | undefined; value: ZodFieldValue; required: boolean; "aria-required": boolean; "aria-invalid": boolean | undefined; ref: (args_0: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement | ((value: HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | null) => HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | null) | null) => void; onBlur(): void; onChange(event: ChangeEvent): void; }; //#endregion //#region src/hooks/use-field-props/FieldProps.d.ts /** * Common Props to be used on FieldComponents like CheckboxField or NumberField. */ export type FieldProps = { field: Field; label?: ReactNode; required?: boolean; } & Pick>, "initialValue">; //#endregion //#region src/hooks/use-multiselect-field-props/useMultiSelectFieldProps.d.ts export type UseMultiSelectFieldProps = { field: Field; getValue: (option: Option) => ZodArrayFieldValue; } & Pick, "options">; export type ZodArrayFieldValue = Field extends ZodField, ZodArray> ? z.infer : never; export declare const useMultiSelectFieldProps: ({ field, options, getValue }: UseMultiSelectFieldProps, { initialValue, ...atomOptions }?: UseFieldOptions>) => { id: string; name: string | undefined; required: boolean; "aria-required": boolean; "aria-invalid": boolean | undefined; ref: (args_0: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement | ((value: HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | null) => HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | null) | null) => void; onBlur(): void; onChange(event: ChangeEvent): void; value: readonly string[]; }; //#endregion //#region src/hooks/use-options/useOptions.d.ts export type UseOptionsProps