UNPKG

goobs-frontend

Version:

A comprehensive React-based libary for building modern web applications

39 lines 1.78 kB
import { CSSProperties, ReactElement, ReactNode } from 'react'; import { z } from 'zod'; import { default as AutoFields } from './AutoFields'; export interface FormProps<TValues extends Record<string, unknown> = Record<string, unknown>> { /** * The zod object schema the form validates against. Drives validation, * per-field `required` derivation, and (for `<Form.AutoFields>`) the set of * fields to render. */ schema: z.ZodType<TValues>; /** Initial field values. */ initialValues: TValues; /** Called with validated values once the form passes validation on submit. */ onSubmit: (values: TValues) => void | Promise<void>; /** * Entity/human subject (e.g. `"contract"`). Emitted as `data-subject` and * used as the form's `aria-label` when no explicit label is provided. */ subject?: string; /** Stable form id — emitted as `data-form` and used as the diag `formId`. */ id?: string; /** Form body — hand-placed goobs fields, or `<Form.AutoFields />`. */ children: ReactNode; className?: string; style?: CSSProperties; } interface FormComponent { <TValues extends Record<string, unknown> = Record<string, unknown>>(props: FormProps<TValues>): ReactElement | null; displayName?: string; AutoFields: typeof AutoFields; } declare const Form: FormComponent; export default Form; export { useFormContext, useOptionalFormContext, type FormEngine, type FormContextValue, } from './context'; export { useFormField } from './useFormField'; export { useFieldArray, type FieldArrayBinding } from './useFieldArray'; export { useFieldValues, type FieldValuesBinding } from './useFieldValues'; export type { AutoFieldsProps } from './AutoFields'; //# sourceMappingURL=index.d.ts.map