@opengov/form-utils
Advanced tools
+16
-10
@@ -1,2 +0,2 @@ | ||
| import { FieldValues, Control } from 'react-hook-form'; | ||
| import { FieldValues, Control, RegisterOptions, Validate } from 'react-hook-form'; | ||
| import { DateUnit, DayOfWeek } from './enums'; | ||
@@ -137,3 +137,6 @@ /** TEMPLATE TYPES */ | ||
| /** FIELD CONFIGURATION TYPES */ | ||
| export type FieldConfiguration<T extends FieldValues = FieldValues> = { | ||
| export type FieldRules<TFieldValues extends FieldValues = FieldValues> = Omit<RegisterOptions, 'validate'> & { | ||
| validate?: Record<string, Validate<any, TFieldValues>>; | ||
| }; | ||
| export type FieldConfiguration<TFieldValues extends FieldValues = FieldValues> = { | ||
| type: string; | ||
@@ -143,14 +146,17 @@ name: string; | ||
| icon?: string; | ||
| groups: ConfigurationGroup<T>[]; | ||
| groups: ConfigurationGroup<TFieldValues>[]; | ||
| label?: LabelConfiguration; | ||
| fullWidth?: boolean; | ||
| }; | ||
| export type TypeConfig<T extends FieldConfiguration = FieldConfiguration> = T & { | ||
| renderField: (template: FieldTemplate, config: T, { disabled, readonly, name, icons, }: { | ||
| disabled?: boolean; | ||
| readonly?: boolean; | ||
| name?: string; | ||
| icons?: React.ReactNode; | ||
| }) => JSX.Element; | ||
| export type FieldInstanceState<TFieldValues extends FieldValues = FieldValues> = { | ||
| disabled?: boolean; | ||
| readonly?: boolean; | ||
| name?: string; | ||
| icons?: React.ReactNode; | ||
| rules?: FieldRules<TFieldValues>; | ||
| }; | ||
| export type RenderField<TConfig extends FieldConfiguration = FieldConfiguration> = (template: FieldTemplate, config: TConfig, state: FieldInstanceState) => JSX.Element; | ||
| export type TypeConfig<TConfig extends FieldConfiguration = FieldConfiguration> = TConfig & { | ||
| renderField: RenderField<TConfig>; | ||
| }; | ||
| export type TextConfiguration = FieldConfiguration & { | ||
@@ -157,0 +163,0 @@ maxLength: number; |
+1
-1
| { | ||
| "name": "@opengov/form-utils", | ||
| "version": "0.7.0", | ||
| "version": "0.7.1", | ||
| "description": "OpenGov Smart Forms form utils", | ||
@@ -5,0 +5,0 @@ "type": "module", |
9266
4.91%232
2.65%