@tachui/forms 0.7.0-alpha1 → 0.8.0-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +136 -0
- package/dist/DatePicker-D5nRFTUm.js +475 -0
- package/dist/DatePicker-D5nRFTUm.js.map +1 -0
- package/dist/Select-yZyKooXk.js +945 -0
- package/dist/Select-yZyKooXk.js.map +1 -0
- package/dist/Slider-0-oal5YR.js +644 -0
- package/dist/Slider-0-oal5YR.js.map +1 -0
- package/dist/TextField-hX15dY3U.js +509 -0
- package/dist/TextField-hX15dY3U.js.map +1 -0
- package/dist/components/advanced/Slider.d.ts +190 -0
- package/dist/components/advanced/Slider.d.ts.map +1 -0
- package/dist/components/advanced/Stepper.d.ts +161 -0
- package/dist/components/advanced/Stepper.d.ts.map +1 -0
- package/dist/components/advanced/index.d.ts +15 -0
- package/dist/components/advanced/index.d.ts.map +1 -0
- package/dist/components/advanced/index.js +6 -0
- package/dist/{state → components/advanced}/index.js.map +1 -1
- package/dist/components/date-picker/DatePicker.d.ts +126 -0
- package/dist/components/date-picker/DatePicker.d.ts.map +1 -0
- package/dist/components/date-picker/index.d.ts +14 -0
- package/dist/components/date-picker/index.d.ts.map +1 -0
- package/dist/components/date-picker/index.js +5 -0
- package/dist/components/{index.js.map → date-picker/index.js.map} +1 -1
- package/dist/components/form-container/index.d.ts +58 -0
- package/dist/components/form-container/index.d.ts.map +1 -0
- package/dist/components/selection/Checkbox.d.ts.map +1 -0
- package/dist/components/selection/Radio.d.ts.map +1 -0
- package/dist/components/selection/Select.d.ts.map +1 -0
- package/dist/components/selection/index.d.ts +68 -0
- package/dist/components/selection/index.d.ts.map +1 -0
- package/dist/components/selection/index.js +12 -0
- package/dist/components/selection/index.js.map +1 -0
- package/dist/components/text-input/TextField.d.ts.map +1 -0
- package/dist/components/text-input/index.d.ts +8 -0
- package/dist/components/text-input/index.d.ts.map +1 -0
- package/dist/components/text-input/index.js +18 -0
- package/dist/components/text-input/index.js.map +1 -0
- package/dist/index-D3WfkqVv.js +249 -0
- package/dist/index-D3WfkqVv.js.map +1 -0
- package/dist/index.d.ts +10 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +196 -376
- package/dist/index.js.map +1 -1
- package/dist/state/index.d.ts.map +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/index.d.ts +19 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/validation/component-validation.d.ts +11 -2
- package/dist/validation/component-validation.d.ts.map +1 -1
- package/dist/validation/index.d.ts.map +1 -1
- package/dist/validation/index.js +687 -17
- package/dist/validation/index.js.map +1 -1
- package/package.json +54 -41
- package/src/components/advanced/Slider.ts +722 -0
- package/src/components/advanced/Stepper.ts +715 -0
- package/src/components/advanced/index.ts +20 -0
- package/src/components/date-picker/DatePicker.ts +925 -0
- package/src/components/date-picker/index.ts +20 -0
- package/src/components/form-container/index.ts +266 -0
- package/src/components/selection/Checkbox.ts +478 -0
- package/src/components/selection/Radio.ts +470 -0
- package/src/components/selection/Select.ts +620 -0
- package/src/components/selection/index.ts +81 -0
- package/src/components/text-input/TextField.ts +728 -0
- package/src/components/text-input/index.ts +35 -0
- package/src/index.ts +48 -0
- package/src/state/index.ts +544 -0
- package/src/types/index.ts +579 -0
- package/src/utils/formatters.ts +184 -0
- package/src/utils/index.ts +57 -0
- package/src/validation/component-validation.ts +429 -0
- package/src/validation/index.ts +641 -0
- package/dist/Form-ueYEcSg1.cjs +0 -2
- package/dist/Form-ueYEcSg1.cjs.map +0 -1
- package/dist/Form-ylAr3o_e.js +0 -376
- package/dist/Form-ylAr3o_e.js.map +0 -1
- package/dist/components/Form.d.ts +0 -76
- package/dist/components/Form.d.ts.map +0 -1
- package/dist/components/index.cjs +0 -2
- package/dist/components/index.cjs.map +0 -1
- package/dist/components/index.d.ts +0 -9
- package/dist/components/index.d.ts.map +0 -1
- package/dist/components/index.js +0 -31
- package/dist/components/input/Checkbox.d.ts.map +0 -1
- package/dist/components/input/Radio.d.ts.map +0 -1
- package/dist/components/input/Select.d.ts.map +0 -1
- package/dist/components/input/TextField.d.ts.map +0 -1
- package/dist/components/input/index.d.ts +0 -11
- package/dist/components/input/index.d.ts.map +0 -1
- package/dist/forms-complex-BiQsZZlT.js +0 -361
- package/dist/forms-complex-BiQsZZlT.js.map +0 -1
- package/dist/forms-complex-DLEnXXJ5.cjs +0 -2
- package/dist/forms-complex-DLEnXXJ5.cjs.map +0 -1
- package/dist/forms-core-B1bx1drO.js +0 -839
- package/dist/forms-core-B1bx1drO.js.map +0 -1
- package/dist/forms-core-W_JGVLAI.cjs +0 -9
- package/dist/forms-core-W_JGVLAI.cjs.map +0 -1
- package/dist/forms-inputs-6QdeMWFk.js +0 -1075
- package/dist/forms-inputs-6QdeMWFk.js.map +0 -1
- package/dist/forms-inputs-DQ5QI_SU.cjs +0 -2
- package/dist/forms-inputs-DQ5QI_SU.cjs.map +0 -1
- package/dist/index.cjs +0 -2
- package/dist/index.cjs.map +0 -1
- package/dist/state/index.cjs +0 -2
- package/dist/state/index.cjs.map +0 -1
- package/dist/state/index.js +0 -9
- package/dist/utils/validators.d.ts +0 -101
- package/dist/utils/validators.d.ts.map +0 -1
- package/dist/validation/index.cjs +0 -2
- package/dist/validation/index.cjs.map +0 -1
- /package/dist/components/{input → selection}/Checkbox.d.ts +0 -0
- /package/dist/components/{input → selection}/Radio.d.ts +0 -0
- /package/dist/components/{input → selection}/Select.d.ts +0 -0
- /package/dist/components/{input → text-input}/TextField.d.ts +0 -0
|
@@ -0,0 +1,579 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TachUI Forms Plugin - Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Complete type system for form components, validation, and state management.
|
|
5
|
+
* Provides SwiftUI-inspired form APIs with modern web development patterns.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type {
|
|
9
|
+
ComponentChildren,
|
|
10
|
+
ComponentInstance,
|
|
11
|
+
ComponentProps,
|
|
12
|
+
} from '@tachui/core'
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Form validation rule types
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Built-in validation rule with options
|
|
19
|
+
*/
|
|
20
|
+
export interface BuiltInValidationRule {
|
|
21
|
+
name: 'min' | 'max' | 'minLength' | 'maxLength' | 'pattern'
|
|
22
|
+
options: Record<string, any>
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type ValidationRule =
|
|
26
|
+
| 'required'
|
|
27
|
+
| 'email'
|
|
28
|
+
| 'url'
|
|
29
|
+
| 'number'
|
|
30
|
+
| 'integer'
|
|
31
|
+
| 'min'
|
|
32
|
+
| 'max'
|
|
33
|
+
| 'minLength'
|
|
34
|
+
| 'maxLength'
|
|
35
|
+
| 'pattern'
|
|
36
|
+
| 'numeric'
|
|
37
|
+
| 'phone'
|
|
38
|
+
| 'creditCard'
|
|
39
|
+
| 'ssn'
|
|
40
|
+
| 'postalCode'
|
|
41
|
+
| 'zipCode'
|
|
42
|
+
| 'date'
|
|
43
|
+
| 'time'
|
|
44
|
+
| 'strongPassword'
|
|
45
|
+
| BuiltInValidationRule
|
|
46
|
+
| CustomValidationRule
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Custom validation rule interface
|
|
50
|
+
*/
|
|
51
|
+
export interface CustomValidationRule {
|
|
52
|
+
name: string
|
|
53
|
+
validate: (value: any, options?: any) => ValidationResult
|
|
54
|
+
message?: string
|
|
55
|
+
options?: Record<string, any>
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Validation result interface
|
|
60
|
+
*/
|
|
61
|
+
export interface ValidationResult {
|
|
62
|
+
valid: boolean
|
|
63
|
+
message?: string
|
|
64
|
+
code?: string
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Field validation configuration
|
|
69
|
+
*/
|
|
70
|
+
export interface FieldValidation {
|
|
71
|
+
rules: ValidationRule[]
|
|
72
|
+
validateOn?: 'change' | 'blur' | 'submit'
|
|
73
|
+
debounceMs?: number
|
|
74
|
+
required?: boolean
|
|
75
|
+
custom?: CustomValidationRule[]
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Form field state
|
|
80
|
+
*/
|
|
81
|
+
export interface FieldState<T = any> {
|
|
82
|
+
value: T
|
|
83
|
+
error?: string
|
|
84
|
+
touched: boolean
|
|
85
|
+
dirty: boolean
|
|
86
|
+
valid: boolean
|
|
87
|
+
validating: boolean
|
|
88
|
+
focused: boolean
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Form state interface
|
|
93
|
+
*/
|
|
94
|
+
export interface FormState {
|
|
95
|
+
fields: Record<string, FieldState>
|
|
96
|
+
valid: boolean
|
|
97
|
+
dirty: boolean
|
|
98
|
+
submitting: boolean
|
|
99
|
+
submitted: boolean
|
|
100
|
+
errors: Record<string, string>
|
|
101
|
+
touched: Record<string, boolean>
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Form submission handler
|
|
106
|
+
*/
|
|
107
|
+
export type FormSubmitHandler<T = Record<string, any>> = (
|
|
108
|
+
values: T,
|
|
109
|
+
form: FormState
|
|
110
|
+
) => void | Promise<void>
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Form change handler
|
|
114
|
+
*/
|
|
115
|
+
export type FormChangeHandler<T = any> = (
|
|
116
|
+
name: string,
|
|
117
|
+
value: T,
|
|
118
|
+
field: FieldState<T>
|
|
119
|
+
) => void
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Base form field props
|
|
123
|
+
*/
|
|
124
|
+
export interface BaseFieldProps extends ComponentProps {
|
|
125
|
+
name: string
|
|
126
|
+
label?: string
|
|
127
|
+
placeholder?: string
|
|
128
|
+
disabled?: boolean
|
|
129
|
+
required?: boolean
|
|
130
|
+
validation?: FieldValidation
|
|
131
|
+
value?: any
|
|
132
|
+
defaultValue?: any
|
|
133
|
+
onChange?: FormChangeHandler
|
|
134
|
+
onBlur?: (name: string, value: any) => void
|
|
135
|
+
onFocus?: (name: string, value: any) => void
|
|
136
|
+
error?: string
|
|
137
|
+
helperText?: string
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Input field types - comprehensive SwiftUI-inspired support
|
|
142
|
+
*/
|
|
143
|
+
export type TextFieldType =
|
|
144
|
+
| 'text'
|
|
145
|
+
| 'password'
|
|
146
|
+
| 'email'
|
|
147
|
+
| 'number'
|
|
148
|
+
| 'tel'
|
|
149
|
+
| 'url'
|
|
150
|
+
| 'search'
|
|
151
|
+
| 'date'
|
|
152
|
+
| 'time'
|
|
153
|
+
| 'datetime-local'
|
|
154
|
+
| 'month'
|
|
155
|
+
| 'week'
|
|
156
|
+
| 'color'
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Auto-capitalization options
|
|
160
|
+
*/
|
|
161
|
+
export type AutoCapitalization = 'none' | 'sentences' | 'words' | 'characters'
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Keyboard type for mobile devices
|
|
165
|
+
*/
|
|
166
|
+
export type KeyboardType =
|
|
167
|
+
| 'default'
|
|
168
|
+
| 'numeric'
|
|
169
|
+
| 'email'
|
|
170
|
+
| 'phone'
|
|
171
|
+
| 'url'
|
|
172
|
+
| 'search'
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Return key type for mobile keyboards
|
|
176
|
+
*/
|
|
177
|
+
export type ReturnKeyType = 'done' | 'go' | 'next' | 'search' | 'send'
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Text field formatter function
|
|
181
|
+
*/
|
|
182
|
+
export type TextFieldFormatter = (value: string) => string
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Text field parser function
|
|
186
|
+
*/
|
|
187
|
+
export type TextFieldParser = (value: string) => string
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Text input specific props - Enhanced with core TextField features
|
|
191
|
+
*/
|
|
192
|
+
export interface TextFieldProps extends BaseFieldProps {
|
|
193
|
+
// Input configuration
|
|
194
|
+
type?: TextFieldType
|
|
195
|
+
multiline?: boolean
|
|
196
|
+
rows?: number
|
|
197
|
+
minLength?: number
|
|
198
|
+
maxLength?: number
|
|
199
|
+
pattern?: string
|
|
200
|
+
autocomplete?: string
|
|
201
|
+
spellcheck?: boolean
|
|
202
|
+
|
|
203
|
+
// Mobile/accessibility features
|
|
204
|
+
keyboardType?: KeyboardType
|
|
205
|
+
returnKeyType?: ReturnKeyType
|
|
206
|
+
autoCapitalize?: AutoCapitalization
|
|
207
|
+
autoFocus?: boolean
|
|
208
|
+
accessibilityLabel?: string
|
|
209
|
+
accessibilityHint?: string
|
|
210
|
+
accessibilityRole?: 'textbox' | 'searchbox'
|
|
211
|
+
|
|
212
|
+
// Formatting and parsing
|
|
213
|
+
formatter?: TextFieldFormatter
|
|
214
|
+
parser?: TextFieldParser
|
|
215
|
+
|
|
216
|
+
// Advanced validation
|
|
217
|
+
validateOnChange?: boolean
|
|
218
|
+
validateOnBlur?: boolean
|
|
219
|
+
|
|
220
|
+
// Typography control
|
|
221
|
+
font?: {
|
|
222
|
+
family?: string
|
|
223
|
+
size?: number | string
|
|
224
|
+
weight?:
|
|
225
|
+
| 'normal'
|
|
226
|
+
| 'bold'
|
|
227
|
+
| '100'
|
|
228
|
+
| '200'
|
|
229
|
+
| '300'
|
|
230
|
+
| '400'
|
|
231
|
+
| '500'
|
|
232
|
+
| '600'
|
|
233
|
+
| '700'
|
|
234
|
+
| '800'
|
|
235
|
+
| '900'
|
|
236
|
+
style?: 'normal' | 'italic'
|
|
237
|
+
}
|
|
238
|
+
textAlign?: 'left' | 'center' | 'right'
|
|
239
|
+
|
|
240
|
+
// Reactive props support (Signal types from @tachui/core)
|
|
241
|
+
text?: string | (() => string) // Signal support
|
|
242
|
+
placeholderSignal?: string | (() => string) // Signal support
|
|
243
|
+
disabledSignal?: boolean | (() => boolean) // Signal support
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Number input specific props
|
|
248
|
+
*/
|
|
249
|
+
export interface NumberFieldProps extends BaseFieldProps {
|
|
250
|
+
min?: number
|
|
251
|
+
max?: number
|
|
252
|
+
step?: number
|
|
253
|
+
precision?: number
|
|
254
|
+
format?: 'decimal' | 'currency' | 'percentage'
|
|
255
|
+
currency?: string
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Checkbox/Toggle props
|
|
260
|
+
*/
|
|
261
|
+
export interface CheckboxProps extends BaseFieldProps {
|
|
262
|
+
checked?: boolean
|
|
263
|
+
defaultChecked?: boolean
|
|
264
|
+
indeterminate?: boolean
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Radio button props
|
|
269
|
+
*/
|
|
270
|
+
export interface RadioProps extends BaseFieldProps {
|
|
271
|
+
value: any
|
|
272
|
+
checked?: boolean
|
|
273
|
+
groupName?: string
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Select/Picker option interface
|
|
278
|
+
*/
|
|
279
|
+
export interface SelectOption<T = any> {
|
|
280
|
+
label: string
|
|
281
|
+
value: T
|
|
282
|
+
disabled?: boolean
|
|
283
|
+
group?: string
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Select/Picker props
|
|
288
|
+
*/
|
|
289
|
+
export interface SelectProps extends BaseFieldProps {
|
|
290
|
+
options: SelectOption[]
|
|
291
|
+
multiple?: boolean
|
|
292
|
+
searchable?: boolean
|
|
293
|
+
clearable?: boolean
|
|
294
|
+
placeholder?: string
|
|
295
|
+
noOptionsMessage?: string
|
|
296
|
+
loadingMessage?: string
|
|
297
|
+
maxMenuHeight?: number
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Date picker props
|
|
302
|
+
*/
|
|
303
|
+
export interface DatePickerProps extends BaseFieldProps {
|
|
304
|
+
format?: string
|
|
305
|
+
locale?: string
|
|
306
|
+
minDate?: Date
|
|
307
|
+
maxDate?: Date
|
|
308
|
+
disabledDates?: Date[] | ((date: Date) => boolean)
|
|
309
|
+
showTime?: boolean
|
|
310
|
+
timeFormat?: string
|
|
311
|
+
startOfWeek?: 0 | 1 | 2 | 3 | 4 | 5 | 6
|
|
312
|
+
monthsToShow?: number
|
|
313
|
+
inline?: boolean
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Slider props
|
|
318
|
+
*/
|
|
319
|
+
export interface SliderProps extends BaseFieldProps {
|
|
320
|
+
min?: number
|
|
321
|
+
max?: number
|
|
322
|
+
step?: number
|
|
323
|
+
range?: boolean
|
|
324
|
+
marks?: Record<number, string>
|
|
325
|
+
vertical?: boolean
|
|
326
|
+
tooltip?: boolean | 'always' | 'hover'
|
|
327
|
+
formatTooltip?: (value: number) => string
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Stepper props
|
|
332
|
+
*/
|
|
333
|
+
export interface StepperProps extends BaseFieldProps {
|
|
334
|
+
min?: number
|
|
335
|
+
max?: number
|
|
336
|
+
step?: number
|
|
337
|
+
precision?: number
|
|
338
|
+
size?: 'small' | 'medium' | 'large'
|
|
339
|
+
showControls?: boolean
|
|
340
|
+
allowEmpty?: boolean
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Form container props
|
|
345
|
+
*/
|
|
346
|
+
export interface FormProps extends ComponentProps {
|
|
347
|
+
onSubmit?: FormSubmitHandler
|
|
348
|
+
onChange?: FormChangeHandler
|
|
349
|
+
validation?: {
|
|
350
|
+
validateOn?: 'change' | 'blur' | 'submit'
|
|
351
|
+
stopOnFirstError?: boolean
|
|
352
|
+
debounceMs?: number
|
|
353
|
+
}
|
|
354
|
+
initialValues?: Record<string, any>
|
|
355
|
+
resetOnSubmit?: boolean
|
|
356
|
+
preserveValues?: boolean
|
|
357
|
+
children: ComponentChildren
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Enhanced FormSection props (combines Core Section features with form semantics)
|
|
362
|
+
*/
|
|
363
|
+
export interface FormSectionProps extends ComponentProps {
|
|
364
|
+
// Content (enhanced from Core Section)
|
|
365
|
+
title?: string
|
|
366
|
+
description?: string
|
|
367
|
+
header?: string | (() => string) | ComponentInstance
|
|
368
|
+
footer?: string | (() => string) | ComponentInstance
|
|
369
|
+
children: ComponentChildren
|
|
370
|
+
|
|
371
|
+
// Styling (from Core Section)
|
|
372
|
+
style?: 'automatic' | 'grouped' | 'inset' | 'plain' | 'sidebar'
|
|
373
|
+
spacing?: number
|
|
374
|
+
|
|
375
|
+
// Behavior (enhanced from Core Section)
|
|
376
|
+
collapsible?: boolean
|
|
377
|
+
collapsed?: boolean
|
|
378
|
+
onToggle?: (collapsed: boolean) => void
|
|
379
|
+
|
|
380
|
+
// Accessibility
|
|
381
|
+
accessibilityLabel?: string
|
|
382
|
+
accessibilityRole?: string
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Multi-step form props
|
|
387
|
+
*/
|
|
388
|
+
export interface MultiStepFormProps extends ComponentProps {
|
|
389
|
+
steps: FormStep[]
|
|
390
|
+
currentStep?: number
|
|
391
|
+
onStepChange?: (step: number) => void
|
|
392
|
+
onComplete?: FormSubmitHandler
|
|
393
|
+
showProgress?: boolean
|
|
394
|
+
allowSkipSteps?: boolean
|
|
395
|
+
validateStepOnNext?: boolean
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Form step interface
|
|
400
|
+
*/
|
|
401
|
+
export interface FormStep {
|
|
402
|
+
id: string
|
|
403
|
+
title: string
|
|
404
|
+
description?: string
|
|
405
|
+
component: ComponentInstance
|
|
406
|
+
validation?: FieldValidation
|
|
407
|
+
optional?: boolean
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Form builder field configuration
|
|
412
|
+
*/
|
|
413
|
+
export interface FormFieldConfig {
|
|
414
|
+
type:
|
|
415
|
+
| 'text'
|
|
416
|
+
| 'number'
|
|
417
|
+
| 'email'
|
|
418
|
+
| 'select'
|
|
419
|
+
| 'checkbox'
|
|
420
|
+
| 'radio'
|
|
421
|
+
| 'date'
|
|
422
|
+
| 'slider'
|
|
423
|
+
name: string
|
|
424
|
+
label: string
|
|
425
|
+
placeholder?: string
|
|
426
|
+
required?: boolean
|
|
427
|
+
validation?: FieldValidation
|
|
428
|
+
options?: SelectOption[] // For select, radio
|
|
429
|
+
min?: number // For number, date, slider
|
|
430
|
+
max?: number // For number, date, slider
|
|
431
|
+
step?: number // For number, slider
|
|
432
|
+
format?: string // For date
|
|
433
|
+
defaultValue?: any
|
|
434
|
+
conditional?: {
|
|
435
|
+
field: string
|
|
436
|
+
operator: 'equals' | 'not-equals' | 'contains' | 'greater' | 'less'
|
|
437
|
+
value: any
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Form builder schema
|
|
443
|
+
*/
|
|
444
|
+
export interface FormSchema {
|
|
445
|
+
id: string
|
|
446
|
+
title?: string
|
|
447
|
+
description?: string
|
|
448
|
+
fields: FormFieldConfig[]
|
|
449
|
+
sections?: FormSectionConfig[]
|
|
450
|
+
validation?: {
|
|
451
|
+
rules?: Record<string, ValidationRule[]>
|
|
452
|
+
crossFieldValidation?: CrossFieldValidation[]
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Form section configuration for builder
|
|
458
|
+
*/
|
|
459
|
+
export interface FormSectionConfig {
|
|
460
|
+
id: string
|
|
461
|
+
title: string
|
|
462
|
+
description?: string
|
|
463
|
+
fields: string[] // Field names in this section
|
|
464
|
+
collapsible?: boolean
|
|
465
|
+
conditional?: {
|
|
466
|
+
field: string
|
|
467
|
+
operator: 'equals' | 'not-equals' | 'contains'
|
|
468
|
+
value: any
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Cross-field validation interface
|
|
474
|
+
*/
|
|
475
|
+
export interface CrossFieldValidation {
|
|
476
|
+
fields: string[]
|
|
477
|
+
validate: (values: Record<string, any>) => ValidationResult
|
|
478
|
+
message: string
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Form validation configuration
|
|
483
|
+
*/
|
|
484
|
+
export interface FormValidationConfig {
|
|
485
|
+
rules: Record<string, ValidationRule[]>
|
|
486
|
+
messages: Record<string, string>
|
|
487
|
+
validateOn: 'change' | 'blur' | 'submit'
|
|
488
|
+
debounceMs: number
|
|
489
|
+
stopOnFirstError: boolean
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Form theme configuration
|
|
494
|
+
*/
|
|
495
|
+
export interface FormTheme {
|
|
496
|
+
spacing: {
|
|
497
|
+
fieldGap: string
|
|
498
|
+
sectionGap: string
|
|
499
|
+
labelGap: string
|
|
500
|
+
}
|
|
501
|
+
colors: {
|
|
502
|
+
border: string
|
|
503
|
+
borderFocus: string
|
|
504
|
+
borderError: string
|
|
505
|
+
background: string
|
|
506
|
+
backgroundFocus: string
|
|
507
|
+
backgroundError: string
|
|
508
|
+
text: string
|
|
509
|
+
textError: string
|
|
510
|
+
textHelper: string
|
|
511
|
+
label: string
|
|
512
|
+
}
|
|
513
|
+
typography: {
|
|
514
|
+
labelSize: string
|
|
515
|
+
inputSize: string
|
|
516
|
+
helperSize: string
|
|
517
|
+
errorSize: string
|
|
518
|
+
}
|
|
519
|
+
borderRadius: string
|
|
520
|
+
shadows: {
|
|
521
|
+
focus: string
|
|
522
|
+
error: string
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Form analytics/tracking interface
|
|
528
|
+
*/
|
|
529
|
+
export interface FormAnalytics {
|
|
530
|
+
onFieldFocus?: (field: string) => void
|
|
531
|
+
onFieldBlur?: (field: string, value: any, timeSpent: number) => void
|
|
532
|
+
onFieldError?: (field: string, error: string) => void
|
|
533
|
+
onFormStart?: () => void
|
|
534
|
+
onFormSubmit?: (values: Record<string, any>, timeSpent: number) => void
|
|
535
|
+
onFormAbandon?: (completedFields: string[], timeSpent: number) => void
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* Form accessibility configuration
|
|
540
|
+
*/
|
|
541
|
+
export interface FormAccessibility {
|
|
542
|
+
announceErrors?: boolean
|
|
543
|
+
announceValidation?: boolean
|
|
544
|
+
errorSummary?: boolean
|
|
545
|
+
skipLinks?: boolean
|
|
546
|
+
labelStrategy?: 'label' | 'aria-label' | 'aria-labelledby'
|
|
547
|
+
fieldsetStrategy?: 'auto' | 'manual'
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* Field registration result
|
|
552
|
+
*/
|
|
553
|
+
export interface FieldRegistration {
|
|
554
|
+
register: (name: string, validation?: FieldValidation) => void
|
|
555
|
+
unregister: (name: string) => void
|
|
556
|
+
setValue: (name: string, value: any) => void
|
|
557
|
+
getValue: (name: string) => any
|
|
558
|
+
getError: (name: string) => string | undefined
|
|
559
|
+
validateField: (name: string) => Promise<boolean>
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* Form hook return interface
|
|
564
|
+
*/
|
|
565
|
+
export interface UseFormReturn {
|
|
566
|
+
fields: Record<string, FieldState>
|
|
567
|
+
state: FormState
|
|
568
|
+
register: FieldRegistration['register']
|
|
569
|
+
unregister: FieldRegistration['unregister']
|
|
570
|
+
setValue: FieldRegistration['setValue']
|
|
571
|
+
getValue: FieldRegistration['getValue']
|
|
572
|
+
getError: FieldRegistration['getError']
|
|
573
|
+
validateField: FieldRegistration['validateField']
|
|
574
|
+
validateForm: () => Promise<boolean>
|
|
575
|
+
resetForm: () => void
|
|
576
|
+
submitForm: (handler?: FormSubmitHandler) => Promise<void>
|
|
577
|
+
watch: (fields?: string[]) => Record<string, any>
|
|
578
|
+
trigger: (fields?: string[]) => Promise<boolean>
|
|
579
|
+
}
|