Zod schema generate form
types used for generating array of obejct to render html form fieldsunknown
typescript
a year ago
1.0 kB
44
Indexable
Never
type InputFields = Partial<InputHTMLAttributes<HTMLInputElement>>; type SelectFields = Partial<SelectHTMLAttributes<HTMLSelectElement>>; type OptionFields = Partial<OptionHTMLAttributes<HTMLOptionElement>>; type BaseCustomFields<TDef extends ActionHandlerDef> = { label: string; name: keyof TDef['input']; }; type InputCustomFields<TDef extends ActionHandlerDef> = BaseCustomFields<TDef> & { tag?: 'input'; options?: never; }; type SelectCustomFields<TDef extends ActionHandlerDef> = BaseCustomFields<TDef> & { tag: 'select'; options: Array<OptionFields>; }; type CustomFields<TDef extends ActionHandlerDef> = InputCustomFields<TDef> | SelectCustomFields<TDef>; export type FieldElement<TDef extends ActionHandlerDef> = (InputFields | SelectFields) & CustomFields<TDef>; export type FieldOptions<TDef extends ActionHandlerDef> = Partial<{ [K in keyof TDef['input']]: Partial<FieldElement<TDef>>; }>; export type CreateTRPCFormWithSchemaFieldsType<TDef extends ActionHandlerDef> = Array<FieldElement<TDef>>;