@object-ui/types 0.3.0
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/LICENSE +21 -0
- package/README.md +304 -0
- package/dist/api-types.d.ts +451 -0
- package/dist/api-types.d.ts.map +1 -0
- package/dist/api-types.js +10 -0
- package/dist/app.d.ts +120 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +7 -0
- package/dist/base.d.ts +360 -0
- package/dist/base.d.ts.map +1 -0
- package/dist/base.js +10 -0
- package/dist/complex.d.ts +433 -0
- package/dist/complex.d.ts.map +1 -0
- package/dist/complex.js +9 -0
- package/dist/crud.d.ts +457 -0
- package/dist/crud.d.ts.map +1 -0
- package/dist/crud.js +10 -0
- package/dist/data-display.d.ts +599 -0
- package/dist/data-display.d.ts.map +1 -0
- package/dist/data-display.js +9 -0
- package/dist/data.d.ts +295 -0
- package/dist/data.d.ts.map +1 -0
- package/dist/data.js +10 -0
- package/dist/disclosure.d.ts +107 -0
- package/dist/disclosure.d.ts.map +1 -0
- package/dist/disclosure.js +9 -0
- package/dist/feedback.d.ts +159 -0
- package/dist/feedback.d.ts.map +1 -0
- package/dist/feedback.js +9 -0
- package/dist/form.d.ts +932 -0
- package/dist/form.d.ts.map +1 -0
- package/dist/form.js +9 -0
- package/dist/index.d.ts +108 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +48 -0
- package/dist/layout.d.ts +418 -0
- package/dist/layout.d.ts.map +1 -0
- package/dist/layout.js +10 -0
- package/dist/navigation.d.ts +224 -0
- package/dist/navigation.d.ts.map +1 -0
- package/dist/navigation.js +9 -0
- package/dist/objectql.d.ts +254 -0
- package/dist/objectql.d.ts.map +1 -0
- package/dist/objectql.js +10 -0
- package/dist/overlay.d.ts +396 -0
- package/dist/overlay.d.ts.map +1 -0
- package/dist/overlay.js +9 -0
- package/dist/registry.d.ts +85 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +1 -0
- package/package.json +82 -0
- package/src/api-types.ts +464 -0
- package/src/app.ts +138 -0
- package/src/base.ts +416 -0
- package/src/complex.ts +465 -0
- package/src/crud.ts +467 -0
- package/src/data-display.ts +630 -0
- package/src/data.ts +341 -0
- package/src/disclosure.ts +113 -0
- package/src/feedback.ts +170 -0
- package/src/form.ts +954 -0
- package/src/index.ts +350 -0
- package/src/layout.ts +451 -0
- package/src/navigation.ts +235 -0
- package/src/objectql.ts +301 -0
- package/src/overlay.ts +418 -0
- package/src/registry.ts +182 -0
package/src/form.ts
ADDED
|
@@ -0,0 +1,954 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @object-ui/types - Form Component Schemas
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for form input and interactive components.
|
|
5
|
+
*
|
|
6
|
+
* @module form
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { BaseSchema, SchemaNode } from './base';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Button component
|
|
14
|
+
*/
|
|
15
|
+
export interface ButtonSchema extends BaseSchema {
|
|
16
|
+
type: 'button';
|
|
17
|
+
/**
|
|
18
|
+
* Button text label
|
|
19
|
+
*/
|
|
20
|
+
label?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Button variant/style
|
|
23
|
+
* @default 'default'
|
|
24
|
+
*/
|
|
25
|
+
variant?: 'default' | 'secondary' | 'destructive' | 'outline' | 'ghost' | 'link';
|
|
26
|
+
/**
|
|
27
|
+
* Button size
|
|
28
|
+
* @default 'default'
|
|
29
|
+
*/
|
|
30
|
+
size?: 'default' | 'sm' | 'lg' | 'icon';
|
|
31
|
+
/**
|
|
32
|
+
* Whether button is disabled
|
|
33
|
+
*/
|
|
34
|
+
disabled?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Whether button is in loading state
|
|
37
|
+
*/
|
|
38
|
+
loading?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Icon to display (lucide-react icon name)
|
|
41
|
+
*/
|
|
42
|
+
icon?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Icon position
|
|
45
|
+
* @default 'left'
|
|
46
|
+
*/
|
|
47
|
+
iconPosition?: 'left' | 'right';
|
|
48
|
+
/**
|
|
49
|
+
* Click handler
|
|
50
|
+
*/
|
|
51
|
+
onClick?: () => void | Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Button type
|
|
54
|
+
* @default 'button'
|
|
55
|
+
*/
|
|
56
|
+
buttonType?: 'button' | 'submit' | 'reset';
|
|
57
|
+
/**
|
|
58
|
+
* Child components (for custom content)
|
|
59
|
+
*/
|
|
60
|
+
children?: SchemaNode | SchemaNode[];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Text input component
|
|
65
|
+
*/
|
|
66
|
+
export interface InputSchema extends BaseSchema {
|
|
67
|
+
type: 'input';
|
|
68
|
+
/**
|
|
69
|
+
* Field name for form submission
|
|
70
|
+
*/
|
|
71
|
+
name?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Input label
|
|
74
|
+
*/
|
|
75
|
+
label?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Placeholder text
|
|
78
|
+
*/
|
|
79
|
+
placeholder?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Input type
|
|
82
|
+
* @default 'text'
|
|
83
|
+
*/
|
|
84
|
+
inputType?: 'text' | 'email' | 'password' | 'number' | 'tel' | 'url' | 'search' | 'date' | 'time' | 'datetime-local';
|
|
85
|
+
/**
|
|
86
|
+
* Default value
|
|
87
|
+
*/
|
|
88
|
+
defaultValue?: string | number;
|
|
89
|
+
/**
|
|
90
|
+
* Controlled value
|
|
91
|
+
*/
|
|
92
|
+
value?: string | number;
|
|
93
|
+
/**
|
|
94
|
+
* Whether field is required
|
|
95
|
+
*/
|
|
96
|
+
required?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Whether field is disabled
|
|
99
|
+
*/
|
|
100
|
+
disabled?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Whether field is readonly
|
|
103
|
+
*/
|
|
104
|
+
readOnly?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Help text or description
|
|
107
|
+
*/
|
|
108
|
+
description?: string;
|
|
109
|
+
/**
|
|
110
|
+
* Error message
|
|
111
|
+
*/
|
|
112
|
+
error?: string;
|
|
113
|
+
/**
|
|
114
|
+
* Change handler
|
|
115
|
+
*/
|
|
116
|
+
onChange?: (value: string | number) => void;
|
|
117
|
+
/**
|
|
118
|
+
* Input wrapper CSS class
|
|
119
|
+
*/
|
|
120
|
+
wrapperClass?: string;
|
|
121
|
+
/**
|
|
122
|
+
* Minimum value (for number type)
|
|
123
|
+
*/
|
|
124
|
+
min?: number;
|
|
125
|
+
/**
|
|
126
|
+
* Maximum value (for number type)
|
|
127
|
+
*/
|
|
128
|
+
max?: number;
|
|
129
|
+
/**
|
|
130
|
+
* Step value (for number type)
|
|
131
|
+
*/
|
|
132
|
+
step?: number;
|
|
133
|
+
/**
|
|
134
|
+
* Maximum length
|
|
135
|
+
*/
|
|
136
|
+
maxLength?: number;
|
|
137
|
+
/**
|
|
138
|
+
* Pattern for validation
|
|
139
|
+
*/
|
|
140
|
+
pattern?: string;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Textarea component
|
|
145
|
+
*/
|
|
146
|
+
export interface TextareaSchema extends BaseSchema {
|
|
147
|
+
type: 'textarea';
|
|
148
|
+
/**
|
|
149
|
+
* Field name for form submission
|
|
150
|
+
*/
|
|
151
|
+
name?: string;
|
|
152
|
+
/**
|
|
153
|
+
* Textarea label
|
|
154
|
+
*/
|
|
155
|
+
label?: string;
|
|
156
|
+
/**
|
|
157
|
+
* Placeholder text
|
|
158
|
+
*/
|
|
159
|
+
placeholder?: string;
|
|
160
|
+
/**
|
|
161
|
+
* Default value
|
|
162
|
+
*/
|
|
163
|
+
defaultValue?: string;
|
|
164
|
+
/**
|
|
165
|
+
* Controlled value
|
|
166
|
+
*/
|
|
167
|
+
value?: string;
|
|
168
|
+
/**
|
|
169
|
+
* Number of visible rows
|
|
170
|
+
*/
|
|
171
|
+
rows?: number;
|
|
172
|
+
/**
|
|
173
|
+
* Whether field is required
|
|
174
|
+
*/
|
|
175
|
+
required?: boolean;
|
|
176
|
+
/**
|
|
177
|
+
* Whether field is disabled
|
|
178
|
+
*/
|
|
179
|
+
disabled?: boolean;
|
|
180
|
+
/**
|
|
181
|
+
* Whether field is readonly
|
|
182
|
+
*/
|
|
183
|
+
readOnly?: boolean;
|
|
184
|
+
/**
|
|
185
|
+
* Help text or description
|
|
186
|
+
*/
|
|
187
|
+
description?: string;
|
|
188
|
+
/**
|
|
189
|
+
* Error message
|
|
190
|
+
*/
|
|
191
|
+
error?: string;
|
|
192
|
+
/**
|
|
193
|
+
* Change handler
|
|
194
|
+
*/
|
|
195
|
+
onChange?: (value: string) => void;
|
|
196
|
+
/**
|
|
197
|
+
* Maximum length
|
|
198
|
+
*/
|
|
199
|
+
maxLength?: number;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Select dropdown component
|
|
204
|
+
*/
|
|
205
|
+
export interface SelectSchema extends BaseSchema {
|
|
206
|
+
type: 'select';
|
|
207
|
+
/**
|
|
208
|
+
* Field name for form submission
|
|
209
|
+
*/
|
|
210
|
+
name?: string;
|
|
211
|
+
/**
|
|
212
|
+
* Select label
|
|
213
|
+
*/
|
|
214
|
+
label?: string;
|
|
215
|
+
/**
|
|
216
|
+
* Placeholder text
|
|
217
|
+
*/
|
|
218
|
+
placeholder?: string;
|
|
219
|
+
/**
|
|
220
|
+
* Default selected value
|
|
221
|
+
*/
|
|
222
|
+
defaultValue?: string;
|
|
223
|
+
/**
|
|
224
|
+
* Controlled value
|
|
225
|
+
*/
|
|
226
|
+
value?: string;
|
|
227
|
+
/**
|
|
228
|
+
* Select options
|
|
229
|
+
*/
|
|
230
|
+
options: SelectOption[];
|
|
231
|
+
/**
|
|
232
|
+
* Whether field is required
|
|
233
|
+
*/
|
|
234
|
+
required?: boolean;
|
|
235
|
+
/**
|
|
236
|
+
* Whether field is disabled
|
|
237
|
+
*/
|
|
238
|
+
disabled?: boolean;
|
|
239
|
+
/**
|
|
240
|
+
* Help text or description
|
|
241
|
+
*/
|
|
242
|
+
description?: string;
|
|
243
|
+
/**
|
|
244
|
+
* Error message
|
|
245
|
+
*/
|
|
246
|
+
error?: string;
|
|
247
|
+
/**
|
|
248
|
+
* Change handler
|
|
249
|
+
*/
|
|
250
|
+
onChange?: (value: string) => void;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Select option
|
|
255
|
+
*/
|
|
256
|
+
export interface SelectOption {
|
|
257
|
+
/**
|
|
258
|
+
* Option label (displayed to user)
|
|
259
|
+
*/
|
|
260
|
+
label: string;
|
|
261
|
+
/**
|
|
262
|
+
* Option value (submitted in form)
|
|
263
|
+
*/
|
|
264
|
+
value: string;
|
|
265
|
+
/**
|
|
266
|
+
* Whether option is disabled
|
|
267
|
+
*/
|
|
268
|
+
disabled?: boolean;
|
|
269
|
+
/**
|
|
270
|
+
* Option icon
|
|
271
|
+
*/
|
|
272
|
+
icon?: string;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Checkbox component
|
|
277
|
+
*/
|
|
278
|
+
export interface CheckboxSchema extends BaseSchema {
|
|
279
|
+
type: 'checkbox';
|
|
280
|
+
/**
|
|
281
|
+
* Field name for form submission
|
|
282
|
+
*/
|
|
283
|
+
name?: string;
|
|
284
|
+
/**
|
|
285
|
+
* Checkbox label
|
|
286
|
+
*/
|
|
287
|
+
label?: string;
|
|
288
|
+
/**
|
|
289
|
+
* Default checked state
|
|
290
|
+
*/
|
|
291
|
+
defaultChecked?: boolean;
|
|
292
|
+
/**
|
|
293
|
+
* Controlled checked state
|
|
294
|
+
*/
|
|
295
|
+
checked?: boolean;
|
|
296
|
+
/**
|
|
297
|
+
* Whether checkbox is disabled
|
|
298
|
+
*/
|
|
299
|
+
disabled?: boolean;
|
|
300
|
+
/**
|
|
301
|
+
* Help text or description
|
|
302
|
+
*/
|
|
303
|
+
description?: string;
|
|
304
|
+
/**
|
|
305
|
+
* Error message
|
|
306
|
+
*/
|
|
307
|
+
error?: string;
|
|
308
|
+
/**
|
|
309
|
+
* Change handler
|
|
310
|
+
*/
|
|
311
|
+
onChange?: (checked: boolean) => void;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Radio group component
|
|
316
|
+
*/
|
|
317
|
+
export interface RadioGroupSchema extends BaseSchema {
|
|
318
|
+
type: 'radio-group';
|
|
319
|
+
/**
|
|
320
|
+
* Field name for form submission
|
|
321
|
+
*/
|
|
322
|
+
name?: string;
|
|
323
|
+
/**
|
|
324
|
+
* Radio group label
|
|
325
|
+
*/
|
|
326
|
+
label?: string;
|
|
327
|
+
/**
|
|
328
|
+
* Default selected value
|
|
329
|
+
*/
|
|
330
|
+
defaultValue?: string;
|
|
331
|
+
/**
|
|
332
|
+
* Controlled value
|
|
333
|
+
*/
|
|
334
|
+
value?: string;
|
|
335
|
+
/**
|
|
336
|
+
* Radio options
|
|
337
|
+
*/
|
|
338
|
+
options: RadioOption[];
|
|
339
|
+
/**
|
|
340
|
+
* Radio group orientation
|
|
341
|
+
* @default 'vertical'
|
|
342
|
+
*/
|
|
343
|
+
orientation?: 'horizontal' | 'vertical';
|
|
344
|
+
/**
|
|
345
|
+
* Whether field is disabled
|
|
346
|
+
*/
|
|
347
|
+
disabled?: boolean;
|
|
348
|
+
/**
|
|
349
|
+
* Help text or description
|
|
350
|
+
*/
|
|
351
|
+
description?: string;
|
|
352
|
+
/**
|
|
353
|
+
* Error message
|
|
354
|
+
*/
|
|
355
|
+
error?: string;
|
|
356
|
+
/**
|
|
357
|
+
* Change handler
|
|
358
|
+
*/
|
|
359
|
+
onChange?: (value: string) => void;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Radio option
|
|
364
|
+
*/
|
|
365
|
+
export interface RadioOption {
|
|
366
|
+
/**
|
|
367
|
+
* Option label
|
|
368
|
+
*/
|
|
369
|
+
label: string;
|
|
370
|
+
/**
|
|
371
|
+
* Option value
|
|
372
|
+
*/
|
|
373
|
+
value: string;
|
|
374
|
+
/**
|
|
375
|
+
* Whether option is disabled
|
|
376
|
+
*/
|
|
377
|
+
disabled?: boolean;
|
|
378
|
+
/**
|
|
379
|
+
* Option description
|
|
380
|
+
*/
|
|
381
|
+
description?: string;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Switch/Toggle component
|
|
386
|
+
*/
|
|
387
|
+
export interface SwitchSchema extends BaseSchema {
|
|
388
|
+
type: 'switch';
|
|
389
|
+
/**
|
|
390
|
+
* Field name for form submission
|
|
391
|
+
*/
|
|
392
|
+
name?: string;
|
|
393
|
+
/**
|
|
394
|
+
* Switch label
|
|
395
|
+
*/
|
|
396
|
+
label?: string;
|
|
397
|
+
/**
|
|
398
|
+
* Default checked state
|
|
399
|
+
*/
|
|
400
|
+
defaultChecked?: boolean;
|
|
401
|
+
/**
|
|
402
|
+
* Controlled checked state
|
|
403
|
+
*/
|
|
404
|
+
checked?: boolean;
|
|
405
|
+
/**
|
|
406
|
+
* Whether switch is disabled
|
|
407
|
+
*/
|
|
408
|
+
disabled?: boolean;
|
|
409
|
+
/**
|
|
410
|
+
* Help text or description
|
|
411
|
+
*/
|
|
412
|
+
description?: string;
|
|
413
|
+
/**
|
|
414
|
+
* Change handler
|
|
415
|
+
*/
|
|
416
|
+
onChange?: (checked: boolean) => void;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Toggle button component
|
|
421
|
+
*/
|
|
422
|
+
export interface ToggleSchema extends BaseSchema {
|
|
423
|
+
type: 'toggle';
|
|
424
|
+
/**
|
|
425
|
+
* Toggle label
|
|
426
|
+
*/
|
|
427
|
+
label?: string;
|
|
428
|
+
/**
|
|
429
|
+
* Default pressed state
|
|
430
|
+
*/
|
|
431
|
+
defaultPressed?: boolean;
|
|
432
|
+
/**
|
|
433
|
+
* Controlled pressed state
|
|
434
|
+
*/
|
|
435
|
+
pressed?: boolean;
|
|
436
|
+
/**
|
|
437
|
+
* Whether toggle is disabled
|
|
438
|
+
*/
|
|
439
|
+
disabled?: boolean;
|
|
440
|
+
/**
|
|
441
|
+
* Toggle variant
|
|
442
|
+
* @default 'default'
|
|
443
|
+
*/
|
|
444
|
+
variant?: 'default' | 'outline';
|
|
445
|
+
/**
|
|
446
|
+
* Toggle size
|
|
447
|
+
* @default 'default'
|
|
448
|
+
*/
|
|
449
|
+
size?: 'default' | 'sm' | 'lg';
|
|
450
|
+
/**
|
|
451
|
+
* Change handler
|
|
452
|
+
*/
|
|
453
|
+
onChange?: (pressed: boolean) => void;
|
|
454
|
+
/**
|
|
455
|
+
* Child content
|
|
456
|
+
*/
|
|
457
|
+
children?: SchemaNode | SchemaNode[];
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* Slider component
|
|
462
|
+
*/
|
|
463
|
+
export interface SliderSchema extends BaseSchema {
|
|
464
|
+
type: 'slider';
|
|
465
|
+
/**
|
|
466
|
+
* Field name for form submission
|
|
467
|
+
*/
|
|
468
|
+
name?: string;
|
|
469
|
+
/**
|
|
470
|
+
* Slider label
|
|
471
|
+
*/
|
|
472
|
+
label?: string;
|
|
473
|
+
/**
|
|
474
|
+
* Default value
|
|
475
|
+
*/
|
|
476
|
+
defaultValue?: number[];
|
|
477
|
+
/**
|
|
478
|
+
* Controlled value
|
|
479
|
+
*/
|
|
480
|
+
value?: number[];
|
|
481
|
+
/**
|
|
482
|
+
* Minimum value
|
|
483
|
+
* @default 0
|
|
484
|
+
*/
|
|
485
|
+
min?: number;
|
|
486
|
+
/**
|
|
487
|
+
* Maximum value
|
|
488
|
+
* @default 100
|
|
489
|
+
*/
|
|
490
|
+
max?: number;
|
|
491
|
+
/**
|
|
492
|
+
* Step increment
|
|
493
|
+
* @default 1
|
|
494
|
+
*/
|
|
495
|
+
step?: number;
|
|
496
|
+
/**
|
|
497
|
+
* Whether slider is disabled
|
|
498
|
+
*/
|
|
499
|
+
disabled?: boolean;
|
|
500
|
+
/**
|
|
501
|
+
* Help text or description
|
|
502
|
+
*/
|
|
503
|
+
description?: string;
|
|
504
|
+
/**
|
|
505
|
+
* Change handler
|
|
506
|
+
*/
|
|
507
|
+
onChange?: (value: number[]) => void;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* File upload component
|
|
512
|
+
*/
|
|
513
|
+
export interface FileUploadSchema extends BaseSchema {
|
|
514
|
+
type: 'file-upload';
|
|
515
|
+
/**
|
|
516
|
+
* Field name for form submission
|
|
517
|
+
*/
|
|
518
|
+
name?: string;
|
|
519
|
+
/**
|
|
520
|
+
* Upload label
|
|
521
|
+
*/
|
|
522
|
+
label?: string;
|
|
523
|
+
/**
|
|
524
|
+
* Accepted file types
|
|
525
|
+
* @example 'image/*', '.pdf,.doc'
|
|
526
|
+
*/
|
|
527
|
+
accept?: string;
|
|
528
|
+
/**
|
|
529
|
+
* Allow multiple files
|
|
530
|
+
* @default false
|
|
531
|
+
*/
|
|
532
|
+
multiple?: boolean;
|
|
533
|
+
/**
|
|
534
|
+
* Maximum file size in bytes
|
|
535
|
+
*/
|
|
536
|
+
maxSize?: number;
|
|
537
|
+
/**
|
|
538
|
+
* Maximum number of files (for multiple)
|
|
539
|
+
*/
|
|
540
|
+
maxFiles?: number;
|
|
541
|
+
/**
|
|
542
|
+
* Whether field is disabled
|
|
543
|
+
*/
|
|
544
|
+
disabled?: boolean;
|
|
545
|
+
/**
|
|
546
|
+
* Help text or description
|
|
547
|
+
*/
|
|
548
|
+
description?: string;
|
|
549
|
+
/**
|
|
550
|
+
* Error message
|
|
551
|
+
*/
|
|
552
|
+
error?: string;
|
|
553
|
+
/**
|
|
554
|
+
* Change handler (receives FileList or File[])
|
|
555
|
+
*/
|
|
556
|
+
onChange?: (files: FileList | File[]) => void;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* Date picker component
|
|
561
|
+
*/
|
|
562
|
+
export interface DatePickerSchema extends BaseSchema {
|
|
563
|
+
type: 'date-picker';
|
|
564
|
+
/**
|
|
565
|
+
* Field name for form submission
|
|
566
|
+
*/
|
|
567
|
+
name?: string;
|
|
568
|
+
/**
|
|
569
|
+
* Date picker label
|
|
570
|
+
*/
|
|
571
|
+
label?: string;
|
|
572
|
+
/**
|
|
573
|
+
* Placeholder text
|
|
574
|
+
*/
|
|
575
|
+
placeholder?: string;
|
|
576
|
+
/**
|
|
577
|
+
* Default value (Date object or ISO string)
|
|
578
|
+
*/
|
|
579
|
+
defaultValue?: Date | string;
|
|
580
|
+
/**
|
|
581
|
+
* Controlled value
|
|
582
|
+
*/
|
|
583
|
+
value?: Date | string;
|
|
584
|
+
/**
|
|
585
|
+
* Minimum selectable date
|
|
586
|
+
*/
|
|
587
|
+
minDate?: Date | string;
|
|
588
|
+
/**
|
|
589
|
+
* Maximum selectable date
|
|
590
|
+
*/
|
|
591
|
+
maxDate?: Date | string;
|
|
592
|
+
/**
|
|
593
|
+
* Date format
|
|
594
|
+
* @default 'PPP'
|
|
595
|
+
*/
|
|
596
|
+
format?: string;
|
|
597
|
+
/**
|
|
598
|
+
* Whether field is disabled
|
|
599
|
+
*/
|
|
600
|
+
disabled?: boolean;
|
|
601
|
+
/**
|
|
602
|
+
* Help text or description
|
|
603
|
+
*/
|
|
604
|
+
description?: string;
|
|
605
|
+
/**
|
|
606
|
+
* Error message
|
|
607
|
+
*/
|
|
608
|
+
error?: string;
|
|
609
|
+
/**
|
|
610
|
+
* Change handler
|
|
611
|
+
*/
|
|
612
|
+
onChange?: (date: Date | undefined) => void;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* Calendar component
|
|
617
|
+
*/
|
|
618
|
+
export interface CalendarSchema extends BaseSchema {
|
|
619
|
+
type: 'calendar';
|
|
620
|
+
/**
|
|
621
|
+
* Default selected date(s)
|
|
622
|
+
*/
|
|
623
|
+
defaultValue?: Date | Date[];
|
|
624
|
+
/**
|
|
625
|
+
* Controlled selected date(s)
|
|
626
|
+
*/
|
|
627
|
+
value?: Date | Date[];
|
|
628
|
+
/**
|
|
629
|
+
* Selection mode
|
|
630
|
+
* @default 'single'
|
|
631
|
+
*/
|
|
632
|
+
mode?: 'single' | 'multiple' | 'range';
|
|
633
|
+
/**
|
|
634
|
+
* Minimum selectable date
|
|
635
|
+
*/
|
|
636
|
+
minDate?: Date | string;
|
|
637
|
+
/**
|
|
638
|
+
* Maximum selectable date
|
|
639
|
+
*/
|
|
640
|
+
maxDate?: Date | string;
|
|
641
|
+
/**
|
|
642
|
+
* Whether calendar is disabled
|
|
643
|
+
*/
|
|
644
|
+
disabled?: boolean;
|
|
645
|
+
/**
|
|
646
|
+
* Change handler
|
|
647
|
+
*/
|
|
648
|
+
onChange?: (date: Date | Date[] | undefined) => void;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
* Input OTP component
|
|
653
|
+
*/
|
|
654
|
+
export interface InputOTPSchema extends BaseSchema {
|
|
655
|
+
type: 'input-otp';
|
|
656
|
+
/**
|
|
657
|
+
* Field name for form submission
|
|
658
|
+
*/
|
|
659
|
+
name?: string;
|
|
660
|
+
/**
|
|
661
|
+
* OTP input label
|
|
662
|
+
*/
|
|
663
|
+
label?: string;
|
|
664
|
+
/**
|
|
665
|
+
* Number of OTP digits
|
|
666
|
+
* @default 6
|
|
667
|
+
*/
|
|
668
|
+
length?: number;
|
|
669
|
+
/**
|
|
670
|
+
* Default value
|
|
671
|
+
*/
|
|
672
|
+
defaultValue?: string;
|
|
673
|
+
/**
|
|
674
|
+
* Controlled value
|
|
675
|
+
*/
|
|
676
|
+
value?: string;
|
|
677
|
+
/**
|
|
678
|
+
* Whether field is disabled
|
|
679
|
+
*/
|
|
680
|
+
disabled?: boolean;
|
|
681
|
+
/**
|
|
682
|
+
* Help text or description
|
|
683
|
+
*/
|
|
684
|
+
description?: string;
|
|
685
|
+
/**
|
|
686
|
+
* Error message
|
|
687
|
+
*/
|
|
688
|
+
error?: string;
|
|
689
|
+
/**
|
|
690
|
+
* Change handler
|
|
691
|
+
*/
|
|
692
|
+
onChange?: (value: string) => void;
|
|
693
|
+
/**
|
|
694
|
+
* Complete handler (called when all digits filled)
|
|
695
|
+
*/
|
|
696
|
+
onComplete?: (value: string) => void;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* Form validation rule
|
|
701
|
+
*/
|
|
702
|
+
export interface ValidationRule {
|
|
703
|
+
/**
|
|
704
|
+
* Required field validation
|
|
705
|
+
*/
|
|
706
|
+
required?: string | boolean;
|
|
707
|
+
/**
|
|
708
|
+
* Minimum length validation
|
|
709
|
+
*/
|
|
710
|
+
minLength?: { value: number; message: string };
|
|
711
|
+
/**
|
|
712
|
+
* Maximum length validation
|
|
713
|
+
*/
|
|
714
|
+
maxLength?: { value: number; message: string };
|
|
715
|
+
/**
|
|
716
|
+
* Minimum value validation (for numbers)
|
|
717
|
+
*/
|
|
718
|
+
min?: { value: number; message: string };
|
|
719
|
+
/**
|
|
720
|
+
* Maximum value validation (for numbers)
|
|
721
|
+
*/
|
|
722
|
+
max?: { value: number; message: string };
|
|
723
|
+
/**
|
|
724
|
+
* Pattern validation (regex)
|
|
725
|
+
*/
|
|
726
|
+
pattern?: { value: string | RegExp; message: string };
|
|
727
|
+
/**
|
|
728
|
+
* Custom validation function
|
|
729
|
+
* @param value - The field value to validate
|
|
730
|
+
* @returns true if valid, false or error message if invalid
|
|
731
|
+
*/
|
|
732
|
+
validate?: (value: string | number | boolean | null | undefined) => boolean | string | Promise<boolean | string>;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
/**
|
|
736
|
+
* Form field condition for conditional rendering
|
|
737
|
+
*/
|
|
738
|
+
export interface FieldCondition {
|
|
739
|
+
/**
|
|
740
|
+
* Field to watch
|
|
741
|
+
*/
|
|
742
|
+
field: string;
|
|
743
|
+
/**
|
|
744
|
+
* Show when field equals this value
|
|
745
|
+
*/
|
|
746
|
+
equals?: any;
|
|
747
|
+
/**
|
|
748
|
+
* Show when field does not equal this value
|
|
749
|
+
*/
|
|
750
|
+
notEquals?: any;
|
|
751
|
+
/**
|
|
752
|
+
* Show when field value is in this array
|
|
753
|
+
*/
|
|
754
|
+
in?: any[];
|
|
755
|
+
/**
|
|
756
|
+
* Custom condition function
|
|
757
|
+
*/
|
|
758
|
+
custom?: (formData: any) => boolean;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
/**
|
|
762
|
+
* Form field configuration
|
|
763
|
+
*/
|
|
764
|
+
export interface FormField {
|
|
765
|
+
/**
|
|
766
|
+
* Unique field identifier
|
|
767
|
+
*/
|
|
768
|
+
id?: string;
|
|
769
|
+
/**
|
|
770
|
+
* Field name for form submission
|
|
771
|
+
*/
|
|
772
|
+
name: string;
|
|
773
|
+
/**
|
|
774
|
+
* Field label
|
|
775
|
+
*/
|
|
776
|
+
label?: string;
|
|
777
|
+
/**
|
|
778
|
+
* Field description
|
|
779
|
+
*/
|
|
780
|
+
description?: string;
|
|
781
|
+
/**
|
|
782
|
+
* Field type/component
|
|
783
|
+
*/
|
|
784
|
+
type?: string;
|
|
785
|
+
/**
|
|
786
|
+
* Input type (for input fields)
|
|
787
|
+
*/
|
|
788
|
+
inputType?: string;
|
|
789
|
+
/**
|
|
790
|
+
* Whether field is required
|
|
791
|
+
*/
|
|
792
|
+
required?: boolean;
|
|
793
|
+
/**
|
|
794
|
+
* Whether field is disabled
|
|
795
|
+
*/
|
|
796
|
+
disabled?: boolean;
|
|
797
|
+
/**
|
|
798
|
+
* Placeholder text
|
|
799
|
+
*/
|
|
800
|
+
placeholder?: string;
|
|
801
|
+
/**
|
|
802
|
+
* Select options (for select/radio)
|
|
803
|
+
*/
|
|
804
|
+
options?: SelectOption[] | RadioOption[];
|
|
805
|
+
/**
|
|
806
|
+
* Validation rules
|
|
807
|
+
*/
|
|
808
|
+
validation?: ValidationRule;
|
|
809
|
+
/**
|
|
810
|
+
* Conditional rendering
|
|
811
|
+
*/
|
|
812
|
+
condition?: FieldCondition;
|
|
813
|
+
/**
|
|
814
|
+
* Additional field-specific props
|
|
815
|
+
*/
|
|
816
|
+
[key: string]: any;
|
|
817
|
+
/**
|
|
818
|
+
* Column span for grid layouts
|
|
819
|
+
* @default 1
|
|
820
|
+
*/
|
|
821
|
+
colSpan?: number;
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
/**
|
|
825
|
+
* Complete form component
|
|
826
|
+
*/
|
|
827
|
+
export interface FormSchema extends BaseSchema {
|
|
828
|
+
type: 'form';
|
|
829
|
+
/**
|
|
830
|
+
* Form fields configuration
|
|
831
|
+
*/
|
|
832
|
+
fields?: FormField[];
|
|
833
|
+
/**
|
|
834
|
+
* Default form values
|
|
835
|
+
*/
|
|
836
|
+
defaultValues?: Record<string, any>;
|
|
837
|
+
/**
|
|
838
|
+
* Submit button label
|
|
839
|
+
* @default 'Submit'
|
|
840
|
+
*/
|
|
841
|
+
submitLabel?: string;
|
|
842
|
+
/**
|
|
843
|
+
* Cancel button label
|
|
844
|
+
* @default 'Cancel'
|
|
845
|
+
*/
|
|
846
|
+
cancelLabel?: string;
|
|
847
|
+
/**
|
|
848
|
+
* Show cancel button
|
|
849
|
+
* @default false
|
|
850
|
+
*/
|
|
851
|
+
showCancel?: boolean;
|
|
852
|
+
/**
|
|
853
|
+
* Form layout
|
|
854
|
+
* @default 'vertical'
|
|
855
|
+
*/
|
|
856
|
+
layout?: 'vertical' | 'horizontal';
|
|
857
|
+
/**
|
|
858
|
+
* Number of columns for multi-column layout
|
|
859
|
+
* @default 1
|
|
860
|
+
*/
|
|
861
|
+
columns?: number;
|
|
862
|
+
/**
|
|
863
|
+
* Validation mode
|
|
864
|
+
* @default 'onSubmit'
|
|
865
|
+
*/
|
|
866
|
+
validationMode?: 'onSubmit' | 'onBlur' | 'onChange' | 'onTouched' | 'all';
|
|
867
|
+
/**
|
|
868
|
+
* Reset form after successful submission
|
|
869
|
+
* @default false
|
|
870
|
+
*/
|
|
871
|
+
resetOnSubmit?: boolean;
|
|
872
|
+
/**
|
|
873
|
+
* Whether form is disabled
|
|
874
|
+
*/
|
|
875
|
+
disabled?: boolean;
|
|
876
|
+
/**
|
|
877
|
+
* Form mode
|
|
878
|
+
* @default 'edit'
|
|
879
|
+
*/
|
|
880
|
+
mode?: 'edit' | 'read' | 'disabled';
|
|
881
|
+
/**
|
|
882
|
+
* Custom action buttons (replaces default submit/cancel)
|
|
883
|
+
*/
|
|
884
|
+
actions?: SchemaNode[];
|
|
885
|
+
/**
|
|
886
|
+
* Submit handler
|
|
887
|
+
*/
|
|
888
|
+
onSubmit?: (data: Record<string, any>) => void | Promise<void>;
|
|
889
|
+
/**
|
|
890
|
+
* Change handler (called on any field change)
|
|
891
|
+
*/
|
|
892
|
+
onChange?: (data: Record<string, any>) => void;
|
|
893
|
+
/**
|
|
894
|
+
* Cancel handler
|
|
895
|
+
*/
|
|
896
|
+
onCancel?: () => void;
|
|
897
|
+
/**
|
|
898
|
+
* Show form action buttons
|
|
899
|
+
* @default true
|
|
900
|
+
*/
|
|
901
|
+
showActions?: boolean;
|
|
902
|
+
/**
|
|
903
|
+
* Field container CSS class
|
|
904
|
+
*/
|
|
905
|
+
fieldContainerClass?: string;
|
|
906
|
+
/**
|
|
907
|
+
* Child components (alternative to fields array)
|
|
908
|
+
*/
|
|
909
|
+
children?: SchemaNode | SchemaNode[];
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
/**
|
|
913
|
+
* Label component
|
|
914
|
+
*/
|
|
915
|
+
export interface LabelSchema extends BaseSchema {
|
|
916
|
+
type: 'label';
|
|
917
|
+
/**
|
|
918
|
+
* Label text content
|
|
919
|
+
*/
|
|
920
|
+
text?: string;
|
|
921
|
+
/**
|
|
922
|
+
* Legacy label property
|
|
923
|
+
*/
|
|
924
|
+
label?: string;
|
|
925
|
+
/**
|
|
926
|
+
* Legacy content property
|
|
927
|
+
*/
|
|
928
|
+
content?: string;
|
|
929
|
+
/**
|
|
930
|
+
* HTML for attribute
|
|
931
|
+
*/
|
|
932
|
+
htmlFor?: string;
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
/**
|
|
936
|
+
* Union type of all form schemas
|
|
937
|
+
*/
|
|
938
|
+
export type FormComponentSchema =
|
|
939
|
+
| ButtonSchema
|
|
940
|
+
| InputSchema
|
|
941
|
+
| TextareaSchema
|
|
942
|
+
| SelectSchema
|
|
943
|
+
| CheckboxSchema
|
|
944
|
+
| RadioGroupSchema
|
|
945
|
+
| SwitchSchema
|
|
946
|
+
| ToggleSchema
|
|
947
|
+
| SliderSchema
|
|
948
|
+
| FileUploadSchema
|
|
949
|
+
| DatePickerSchema
|
|
950
|
+
| CalendarSchema
|
|
951
|
+
| InputOTPSchema
|
|
952
|
+
| FormSchema
|
|
953
|
+
| LabelSchema;
|
|
954
|
+
|