UNPKG

turiy-form

Version:

This package is built on shadcn, zod

94 lines (87 loc) 2.96 kB
import * as React from 'react'; import React__default, { ReactElement, ReactNode, HTMLInputTypeAttribute } from 'react'; import { UseFormReturn } from 'react-hook-form'; import * as class_variance_authority_dist_types from 'class-variance-authority/dist/types'; import { VariantProps } from 'class-variance-authority'; interface Eq { type: "string"; eq: number; } interface UnEq { type: "string" | "number"; min?: number; max?: number; } declare const regex: { email: RegExp; mobile: RegExp; url: RegExp; pan: RegExp; gstin: RegExp; aadhar: RegExp; cin: RegExp; epic: RegExp; pin: RegExp; password: RegExp; }; interface FormxSelectProps { options: Array<{ label: string; value: string; }>; onAdd?: () => any; } interface FormxFieldProps { name: string; label: string; placeholder: string; description?: ReactNode; className?: string; defaultValue: string; type: HTMLInputTypeAttribute | "select"; selectProps?: FormxSelectProps; required?: boolean; match?: RegExp | Eq | UnEq; cached?: boolean; disabled?: boolean; autoFocus?: boolean; } declare const FormxField: React__default.ForwardRefExoticComponent<FormxFieldProps & React__default.RefAttributes<unknown>>; type FormxFieldElement = ReactElement<FormxFieldProps, typeof FormxField>; interface FormxProps { children: FormxFieldElement | Array<FormxFieldElement>; className?: string; onSubmit: (data: { [name: string]: string; }) => any; onChange?: (data: { [name: string]: string; selectedFieldName: string; }) => any; onInit?: (form: UseFormReturn) => any; refine?: { on: (data: { [name: string]: string; }) => boolean; message: string; path: Array<string>; }; submitButton?: ReactNode; resetButton?: ReactNode; } declare const Formx: { ({ children, className, onSubmit, onChange, onInit, refine, submitButton, resetButton, }: Readonly<FormxProps>): React__default.JSX.Element; displayName: string; }; declare const reset: (form: UseFormReturn<any>, defaultValues: any) => void; declare function equal<T>(obj1: T, obj2: T): boolean; declare function isObject(value: any): boolean; declare const buttonVariants: (props?: ({ variant?: "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined; size?: "default" | "sm" | "lg" | "icon" | null | undefined; } & class_variance_authority_dist_types.ClassProp) | undefined) => string; interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> { asChild?: boolean; } declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>; export { Button, type ButtonProps, Formx, FormxField, type FormxFieldElement, buttonVariants, equal, isObject, regex, reset };