UNPKG

@sizo-group/form-builder

Version:

Welcome to **@sizo-group/form-builder**, a powerful and flexible React component library designed to help you create dynamic forms with ease. Built with Tailwind CSS, HeroUI, and react-hook-form, this library provides a reusable form builder that supports

49 lines (45 loc) 1.48 kB
import * as react_jsx_runtime from 'react/jsx-runtime'; import { Fields as Fields$1, DataForm as DataForm$1 } from '@/types/type'; import { InputProps, CheckboxProps, SwitchProps, TextAreaProps, RadioGroupProps, SelectProps } from '@heroui/react'; import { RegisterOptions } from 'react-hook-form'; declare function FB({ fields, formClassName, onSubmit, }: { fields: Fields$1[]; formClassName?: string; onSubmit: (data: DataForm$1) => void; }): react_jsx_runtime.JSX.Element; type BaseField<T> = { name: string; className?: string; rules?: RegisterOptions; initialValue?: T; }; type TextField = { type: "text" | "password"; } & BaseField<string> & InputProps; type TextareaField = { type: "textarea"; } & BaseField<string> & TextAreaProps; type RadioField = { type: "radio"; options: { label: string; value: string; }[]; } & BaseField<string> & RadioGroupProps; type CheckboxField = { type: "checkbox"; } & BaseField<boolean> & CheckboxProps; type SelectField = { type: "select"; options: { label: string; value: string; }[]; } & BaseField<string | string[]> & Omit<SelectProps, "children">; type SwitchField = { type: "switch"; } & BaseField<boolean> & SwitchProps; type Fields = TextField | CheckboxField | SwitchField | TextareaField | RadioField | SelectField; type DataForm = Record<string, Fields["initialValue"]>; export { FB as default }; export type { DataForm, Fields };