@formspec/constraints 0.1.0-alpha.21 → 0.1.0-alpha.26
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/dist/browser.cjs.map +1 -1
- package/dist/browser.js.map +1 -1
- package/dist/constraints-alpha.d.ts +925 -0
- package/dist/constraints-beta.d.ts +925 -0
- package/dist/constraints-internal.d.ts +925 -0
- package/dist/constraints.d.ts +292 -143
- package/dist/defaults.d.ts +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +9 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/validators/field-options.d.ts +6 -6
- package/dist/validators/field-types.d.ts +4 -4
- package/dist/validators/layout.d.ts +4 -4
- package/package.json +7 -7
package/dist/constraints.d.ts
CHANGED
|
@@ -35,8 +35,81 @@
|
|
|
35
35
|
* @packageDocumentation
|
|
36
36
|
*/
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Union of all field types.
|
|
40
|
+
*
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
export declare type AnyField = TextField<string> | NumberField<string> | BooleanField<string> | StaticEnumField<string, readonly EnumOptionValue[]> | DynamicEnumField<string, string> | DynamicSchemaField<string> | ArrayField<string, readonly FormElement[]> | ObjectField<string, readonly FormElement[]>;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* An array field containing repeating items.
|
|
47
|
+
*
|
|
48
|
+
* Use this for lists of values (e.g., multiple addresses, line items).
|
|
49
|
+
*
|
|
50
|
+
* @typeParam N - The field name (string literal type)
|
|
51
|
+
* @typeParam Items - The form elements that define each array item
|
|
52
|
+
*
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
55
|
+
export declare interface ArrayField<N extends string, Items extends readonly FormElement[]> {
|
|
56
|
+
/** Type discriminator for form elements */
|
|
57
|
+
readonly _type: "field";
|
|
58
|
+
/** Field type discriminator - identifies this as an array field */
|
|
59
|
+
readonly _field: "array";
|
|
60
|
+
/** Unique field identifier used as the schema key */
|
|
61
|
+
readonly name: N;
|
|
62
|
+
/** Form elements that define the schema for each array item */
|
|
63
|
+
readonly items: Items;
|
|
64
|
+
/** Display label for the field */
|
|
65
|
+
readonly label?: string;
|
|
66
|
+
/** Whether this field is required for form submission */
|
|
67
|
+
readonly required?: boolean;
|
|
68
|
+
/** Minimum number of items required */
|
|
69
|
+
readonly minItems?: number;
|
|
70
|
+
/** Maximum number of items allowed */
|
|
71
|
+
readonly maxItems?: number;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* A boolean checkbox field.
|
|
76
|
+
*
|
|
77
|
+
* @typeParam N - The field name (string literal type)
|
|
78
|
+
*
|
|
79
|
+
* @public
|
|
80
|
+
*/
|
|
81
|
+
export declare interface BooleanField<N extends string> {
|
|
82
|
+
/** Type discriminator for form elements */
|
|
83
|
+
readonly _type: "field";
|
|
84
|
+
/** Field type discriminator - identifies this as a boolean field */
|
|
85
|
+
readonly _field: "boolean";
|
|
86
|
+
/** Unique field identifier used as the schema key */
|
|
87
|
+
readonly name: N;
|
|
88
|
+
/** Display label for the field */
|
|
89
|
+
readonly label?: string;
|
|
90
|
+
/** Whether this field is required for form submission */
|
|
91
|
+
readonly required?: boolean;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* A conditional wrapper that shows/hides elements based on another field's value.
|
|
96
|
+
*
|
|
97
|
+
* @typeParam FieldName - The field to check
|
|
98
|
+
* @typeParam Value - The value that triggers the condition
|
|
99
|
+
* @typeParam Elements - Tuple of contained form elements
|
|
100
|
+
*
|
|
101
|
+
* @public
|
|
102
|
+
*/
|
|
103
|
+
export declare interface Conditional<FieldName extends string, Value, Elements extends readonly FormElement[]> {
|
|
104
|
+
/** Type discriminator - identifies this as a conditional element */
|
|
105
|
+
readonly _type: "conditional";
|
|
106
|
+
/** Name of the field whose value determines visibility */
|
|
107
|
+
readonly field: FieldName;
|
|
108
|
+
/** Value that triggers the condition (shows nested elements) */
|
|
109
|
+
readonly value: Value;
|
|
110
|
+
/** Form elements shown when condition is met */
|
|
111
|
+
readonly elements: Elements;
|
|
112
|
+
}
|
|
40
113
|
|
|
41
114
|
/**
|
|
42
115
|
* Complete constraint configuration for a FormSpec project.
|
|
@@ -77,20 +150,9 @@ export declare interface ControlOptionConstraints {
|
|
|
77
150
|
custom?: Record<string, Severity>;
|
|
78
151
|
}
|
|
79
152
|
|
|
80
|
-
|
|
81
|
-
* Default FormSpec configuration.
|
|
82
|
-
*
|
|
83
|
-
* @public
|
|
84
|
-
*/
|
|
85
|
-
export declare const DEFAULT_CONFIG: FormSpecConfig;
|
|
153
|
+
/* Excluded from this release type: DEFAULT_CONFIG */
|
|
86
154
|
|
|
87
|
-
|
|
88
|
-
* Default constraint configuration that allows all features.
|
|
89
|
-
* All constraints default to "off" (allowed).
|
|
90
|
-
*
|
|
91
|
-
* @public
|
|
92
|
-
*/
|
|
93
|
-
export declare const DEFAULT_CONSTRAINTS: ResolvedConstraintConfig;
|
|
155
|
+
/* Excluded from this release type: DEFAULT_CONSTRAINTS */
|
|
94
156
|
|
|
95
157
|
/**
|
|
96
158
|
* Creates a constraint configuration directly from an object.
|
|
@@ -117,22 +179,78 @@ export declare const DEFAULT_CONSTRAINTS: ResolvedConstraintConfig;
|
|
|
117
179
|
export declare function defineConstraints(config: ConstraintConfig): ResolvedConstraintConfig;
|
|
118
180
|
|
|
119
181
|
/**
|
|
120
|
-
*
|
|
121
|
-
* Works with FormSpec field types.
|
|
182
|
+
* A field with dynamic enum options (fetched from a data source at runtime).
|
|
122
183
|
*
|
|
123
|
-
* @
|
|
124
|
-
* @
|
|
184
|
+
* @typeParam N - The field name (string literal type)
|
|
185
|
+
* @typeParam Source - The data source key (from DataSourceRegistry)
|
|
125
186
|
*
|
|
126
187
|
* @public
|
|
127
188
|
*/
|
|
128
|
-
export declare
|
|
189
|
+
export declare interface DynamicEnumField<N extends string, Source extends string> {
|
|
190
|
+
/** Type discriminator for form elements */
|
|
191
|
+
readonly _type: "field";
|
|
192
|
+
/** Field type discriminator - identifies this as a dynamic enum field */
|
|
193
|
+
readonly _field: "dynamic_enum";
|
|
194
|
+
/** Unique field identifier used as the schema key */
|
|
195
|
+
readonly name: N;
|
|
196
|
+
/** Data source key for fetching options at runtime */
|
|
197
|
+
readonly source: Source;
|
|
198
|
+
/** Display label for the field */
|
|
199
|
+
readonly label?: string;
|
|
200
|
+
/** Whether this field is required for form submission */
|
|
201
|
+
readonly required?: boolean;
|
|
202
|
+
/** Field names whose values are needed to fetch options */
|
|
203
|
+
readonly params?: readonly string[];
|
|
204
|
+
}
|
|
129
205
|
|
|
130
206
|
/**
|
|
131
|
-
*
|
|
207
|
+
* A field that loads its schema dynamically (e.g., from an extension).
|
|
208
|
+
*
|
|
209
|
+
* @typeParam N - The field name (string literal type)
|
|
132
210
|
*
|
|
133
211
|
* @public
|
|
134
212
|
*/
|
|
135
|
-
export declare
|
|
213
|
+
export declare interface DynamicSchemaField<N extends string> {
|
|
214
|
+
/** Type discriminator for form elements */
|
|
215
|
+
readonly _type: "field";
|
|
216
|
+
/** Field type discriminator - identifies this as a dynamic schema field */
|
|
217
|
+
readonly _field: "dynamic_schema";
|
|
218
|
+
/** Unique field identifier used as the schema key */
|
|
219
|
+
readonly name: N;
|
|
220
|
+
/** Identifier for the schema source */
|
|
221
|
+
readonly schemaSource: string;
|
|
222
|
+
/** Display label for the field */
|
|
223
|
+
readonly label?: string;
|
|
224
|
+
/** Whether this field is required for form submission */
|
|
225
|
+
readonly required?: boolean;
|
|
226
|
+
/** Field names whose values are needed to configure the schema */
|
|
227
|
+
readonly params?: readonly string[];
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* An enum option with a separate ID and display label.
|
|
232
|
+
*
|
|
233
|
+
* Use this when the stored value (id) should differ from the display text (label).
|
|
234
|
+
*
|
|
235
|
+
* @public
|
|
236
|
+
*/
|
|
237
|
+
export declare interface EnumOption {
|
|
238
|
+
/** Stored enum value written into submitted data. */
|
|
239
|
+
readonly id: string;
|
|
240
|
+
/** Human-readable label shown to end users. */
|
|
241
|
+
readonly label: string;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Valid enum option types: either plain strings or objects with id/label.
|
|
246
|
+
*
|
|
247
|
+
* @public
|
|
248
|
+
*/
|
|
249
|
+
export declare type EnumOptionValue = string | EnumOption;
|
|
250
|
+
|
|
251
|
+
/* Excluded from this release type: extractFieldOptions */
|
|
252
|
+
|
|
253
|
+
/* Excluded from this release type: FieldOption */
|
|
136
254
|
|
|
137
255
|
/**
|
|
138
256
|
* Field configuration option constraints - control which field options are allowed.
|
|
@@ -156,19 +274,7 @@ export declare interface FieldOptionConstraints {
|
|
|
156
274
|
maxItems?: Severity;
|
|
157
275
|
}
|
|
158
276
|
|
|
159
|
-
|
|
160
|
-
* Context for field option validation.
|
|
161
|
-
*
|
|
162
|
-
* @public
|
|
163
|
-
*/
|
|
164
|
-
export declare interface FieldOptionsContext {
|
|
165
|
-
/** The field name */
|
|
166
|
-
fieldName: string;
|
|
167
|
-
/** Which options are present on this field */
|
|
168
|
-
presentOptions: FieldOption[];
|
|
169
|
-
/** Path to this field */
|
|
170
|
-
path?: string;
|
|
171
|
-
}
|
|
277
|
+
/* Excluded from this release type: FieldOptionsContext */
|
|
172
278
|
|
|
173
279
|
/**
|
|
174
280
|
* Field type constraints - control which field types are allowed.
|
|
@@ -195,18 +301,25 @@ export declare interface FieldTypeConstraints {
|
|
|
195
301
|
object?: Severity;
|
|
196
302
|
}
|
|
197
303
|
|
|
304
|
+
/* Excluded from this release type: FieldTypeContext */
|
|
305
|
+
|
|
198
306
|
/**
|
|
199
|
-
*
|
|
307
|
+
* Union of all form element types (fields and structural elements).
|
|
200
308
|
*
|
|
201
309
|
* @public
|
|
202
310
|
*/
|
|
203
|
-
export declare
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
311
|
+
export declare type FormElement = AnyField | Group<readonly FormElement[]> | Conditional<string, unknown, readonly FormElement[]>;
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* A complete form specification.
|
|
315
|
+
*
|
|
316
|
+
* @typeParam Elements - Tuple of top-level form elements
|
|
317
|
+
*
|
|
318
|
+
* @public
|
|
319
|
+
*/
|
|
320
|
+
export declare interface FormSpec<Elements extends readonly FormElement[]> {
|
|
321
|
+
/** Top-level form elements */
|
|
322
|
+
readonly elements: Elements;
|
|
210
323
|
}
|
|
211
324
|
|
|
212
325
|
/**
|
|
@@ -230,72 +343,35 @@ export declare interface FormSpecValidationOptions {
|
|
|
230
343
|
constraints?: ConstraintConfig;
|
|
231
344
|
}
|
|
232
345
|
|
|
233
|
-
|
|
234
|
-
* Gets the severity level for a field option.
|
|
235
|
-
*
|
|
236
|
-
* @param option - The option to check
|
|
237
|
-
* @param constraints - Field option constraints
|
|
238
|
-
* @returns Severity level, or "off" if not constrained
|
|
239
|
-
*
|
|
240
|
-
* @public
|
|
241
|
-
*/
|
|
242
|
-
export declare function getFieldOptionSeverity(option: FieldOption, constraints: FieldOptionConstraints): Severity;
|
|
346
|
+
/* Excluded from this release type: getFieldOptionSeverity */
|
|
243
347
|
|
|
244
|
-
|
|
245
|
-
* Gets the severity level for a field type.
|
|
246
|
-
*
|
|
247
|
-
* @param fieldType - The _field discriminator value
|
|
248
|
-
* @param constraints - Field type constraints
|
|
249
|
-
* @returns Severity level, or "off" if not constrained
|
|
250
|
-
*
|
|
251
|
-
* @public
|
|
252
|
-
*/
|
|
253
|
-
export declare function getFieldTypeSeverity(fieldType: string, constraints: FieldTypeConstraints): Severity;
|
|
348
|
+
/* Excluded from this release type: getFieldTypeSeverity */
|
|
254
349
|
|
|
255
350
|
/**
|
|
256
|
-
*
|
|
351
|
+
* A visual grouping of form elements.
|
|
257
352
|
*
|
|
258
|
-
*
|
|
259
|
-
* @param constraints - Field option constraints
|
|
260
|
-
* @returns true if allowed, false if disallowed
|
|
353
|
+
* Groups provide visual organization and can be rendered as fieldsets or sections.
|
|
261
354
|
*
|
|
262
|
-
* @
|
|
263
|
-
*/
|
|
264
|
-
export declare function isFieldOptionAllowed(option: FieldOption, constraints: FieldOptionConstraints): boolean;
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* Checks if a field type is allowed by the constraints.
|
|
268
|
-
* Useful for quick checks without generating issues.
|
|
269
|
-
*
|
|
270
|
-
* @param fieldType - The _field discriminator value
|
|
271
|
-
* @param constraints - Field type constraints
|
|
272
|
-
* @returns true if allowed, false if disallowed
|
|
355
|
+
* @typeParam Elements - Tuple of contained form elements
|
|
273
356
|
*
|
|
274
357
|
* @public
|
|
275
358
|
*/
|
|
276
|
-
export declare
|
|
359
|
+
export declare interface Group<Elements extends readonly FormElement[]> {
|
|
360
|
+
/** Type discriminator - identifies this as a group element */
|
|
361
|
+
readonly _type: "group";
|
|
362
|
+
/** Display label for the group */
|
|
363
|
+
readonly label: string;
|
|
364
|
+
/** Form elements contained within this group */
|
|
365
|
+
readonly elements: Elements;
|
|
366
|
+
}
|
|
277
367
|
|
|
278
|
-
|
|
279
|
-
* Checks if a layout type is allowed by the constraints.
|
|
280
|
-
*
|
|
281
|
-
* @param layoutType - The type of layout element
|
|
282
|
-
* @param constraints - Layout constraints
|
|
283
|
-
* @returns true if allowed, false if disallowed
|
|
284
|
-
*
|
|
285
|
-
* @public
|
|
286
|
-
*/
|
|
287
|
-
export declare function isLayoutTypeAllowed(layoutType: "group" | "conditional", constraints: LayoutConstraints): boolean;
|
|
368
|
+
/* Excluded from this release type: isFieldOptionAllowed */
|
|
288
369
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
* @returns true if allowed, false if exceeds limit
|
|
295
|
-
*
|
|
296
|
-
* @public
|
|
297
|
-
*/
|
|
298
|
-
export declare function isNestingDepthAllowed(depth: number, constraints: LayoutConstraints): boolean;
|
|
370
|
+
/* Excluded from this release type: isFieldTypeAllowed */
|
|
371
|
+
|
|
372
|
+
/* Excluded from this release type: isLayoutTypeAllowed */
|
|
373
|
+
|
|
374
|
+
/* Excluded from this release type: isNestingDepthAllowed */
|
|
299
375
|
|
|
300
376
|
/**
|
|
301
377
|
* Layout and structure constraints - control grouping, conditionals, nesting.
|
|
@@ -311,21 +387,7 @@ export declare interface LayoutConstraints {
|
|
|
311
387
|
maxNestingDepth?: number;
|
|
312
388
|
}
|
|
313
389
|
|
|
314
|
-
|
|
315
|
-
* Context for layout validation.
|
|
316
|
-
*
|
|
317
|
-
* @public
|
|
318
|
-
*/
|
|
319
|
-
export declare interface LayoutContext {
|
|
320
|
-
/** The type of layout element ("group" | "conditional") */
|
|
321
|
-
layoutType: "group" | "conditional";
|
|
322
|
-
/** Optional label for the element (for groups) */
|
|
323
|
-
label?: string;
|
|
324
|
-
/** Current nesting depth */
|
|
325
|
-
depth: number;
|
|
326
|
-
/** Path to this element */
|
|
327
|
-
path?: string;
|
|
328
|
-
}
|
|
390
|
+
/* Excluded from this release type: LayoutContext */
|
|
329
391
|
|
|
330
392
|
/**
|
|
331
393
|
* JSONForms layout type constraints.
|
|
@@ -415,12 +477,58 @@ export declare interface LoadConfigResult {
|
|
|
415
477
|
found: boolean;
|
|
416
478
|
}
|
|
417
479
|
|
|
480
|
+
/* Excluded from this release type: mergeWithDefaults */
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* A numeric input field.
|
|
484
|
+
*
|
|
485
|
+
* @typeParam N - The field name (string literal type)
|
|
486
|
+
*
|
|
487
|
+
* @public
|
|
488
|
+
*/
|
|
489
|
+
export declare interface NumberField<N extends string> {
|
|
490
|
+
/** Type discriminator for form elements */
|
|
491
|
+
readonly _type: "field";
|
|
492
|
+
/** Field type discriminator - identifies this as a number field */
|
|
493
|
+
readonly _field: "number";
|
|
494
|
+
/** Unique field identifier used as the schema key */
|
|
495
|
+
readonly name: N;
|
|
496
|
+
/** Display label for the field */
|
|
497
|
+
readonly label?: string;
|
|
498
|
+
/** Minimum allowed value */
|
|
499
|
+
readonly min?: number;
|
|
500
|
+
/** Maximum allowed value */
|
|
501
|
+
readonly max?: number;
|
|
502
|
+
/** Whether this field is required for form submission */
|
|
503
|
+
readonly required?: boolean;
|
|
504
|
+
/** Value must be a multiple of this number (use 1 for integer semantics) */
|
|
505
|
+
readonly multipleOf?: number;
|
|
506
|
+
}
|
|
507
|
+
|
|
418
508
|
/**
|
|
419
|
-
*
|
|
509
|
+
* An object field containing nested properties.
|
|
510
|
+
*
|
|
511
|
+
* Use this for grouping related fields under a single key in the schema.
|
|
512
|
+
*
|
|
513
|
+
* @typeParam N - The field name (string literal type)
|
|
514
|
+
* @typeParam Properties - The form elements that define the object's properties
|
|
420
515
|
*
|
|
421
516
|
* @public
|
|
422
517
|
*/
|
|
423
|
-
export declare
|
|
518
|
+
export declare interface ObjectField<N extends string, Properties extends readonly FormElement[]> {
|
|
519
|
+
/** Type discriminator for form elements */
|
|
520
|
+
readonly _type: "field";
|
|
521
|
+
/** Field type discriminator - identifies this as an object field */
|
|
522
|
+
readonly _field: "object";
|
|
523
|
+
/** Unique field identifier used as the schema key */
|
|
524
|
+
readonly name: N;
|
|
525
|
+
/** Form elements that define the properties of this object */
|
|
526
|
+
readonly properties: Properties;
|
|
527
|
+
/** Display label for the field */
|
|
528
|
+
readonly label?: string;
|
|
529
|
+
/** Whether this field is required for form submission */
|
|
530
|
+
readonly required?: boolean;
|
|
531
|
+
}
|
|
424
532
|
|
|
425
533
|
/**
|
|
426
534
|
* Fully resolved constraint configuration with all properties required.
|
|
@@ -429,10 +537,15 @@ export declare function mergeWithDefaults(config: ConstraintConfig | undefined):
|
|
|
429
537
|
* @public
|
|
430
538
|
*/
|
|
431
539
|
export declare interface ResolvedConstraintConfig {
|
|
540
|
+
/** Effective field-builder policy after defaults and overrides are merged. */
|
|
432
541
|
fieldTypes: Required<FieldTypeConstraints>;
|
|
542
|
+
/** Effective nesting and grouping policy after defaults are applied. */
|
|
433
543
|
layout: Required<LayoutConstraints>;
|
|
544
|
+
/** Effective UI-schema policy after defaults and overrides are merged. */
|
|
434
545
|
uiSchema: ResolvedUISchemaConstraints;
|
|
546
|
+
/** Effective policy for field-level builder options. */
|
|
435
547
|
fieldOptions: Required<FieldOptionConstraints>;
|
|
548
|
+
/** Effective policy for renderer-specific control options. */
|
|
436
549
|
controlOptions: Required<ControlOptionConstraints>;
|
|
437
550
|
}
|
|
438
551
|
|
|
@@ -442,7 +555,9 @@ export declare interface ResolvedConstraintConfig {
|
|
|
442
555
|
* @public
|
|
443
556
|
*/
|
|
444
557
|
export declare interface ResolvedRuleConstraints {
|
|
558
|
+
/** Effective severity controlling whether UI schema rules are allowed. */
|
|
445
559
|
enabled: Severity;
|
|
560
|
+
/** Effective severity for each supported JSON Forms rule effect. */
|
|
446
561
|
effects: Required<RuleEffectConstraints>;
|
|
447
562
|
}
|
|
448
563
|
|
|
@@ -452,7 +567,9 @@ export declare interface ResolvedRuleConstraints {
|
|
|
452
567
|
* @public
|
|
453
568
|
*/
|
|
454
569
|
export declare interface ResolvedUISchemaConstraints {
|
|
570
|
+
/** Effective severities for each supported JSON Forms layout type. */
|
|
455
571
|
layouts: Required<LayoutTypeConstraints>;
|
|
572
|
+
/** Effective rule policy after defaults have been applied. */
|
|
456
573
|
rules: ResolvedRuleConstraints;
|
|
457
574
|
}
|
|
458
575
|
|
|
@@ -495,38 +612,79 @@ export declare interface RuleEffectConstraints {
|
|
|
495
612
|
export declare type Severity = "error" | "warn" | "off";
|
|
496
613
|
|
|
497
614
|
/**
|
|
498
|
-
*
|
|
615
|
+
* A field with static enum options (known at compile time).
|
|
616
|
+
*
|
|
617
|
+
* Options can be plain strings or objects with `id` and `label` properties.
|
|
618
|
+
*
|
|
619
|
+
* @typeParam N - The field name (string literal type)
|
|
620
|
+
* @typeParam O - Tuple of option values (strings or EnumOption objects)
|
|
499
621
|
*
|
|
500
622
|
* @public
|
|
501
623
|
*/
|
|
502
|
-
export declare interface
|
|
503
|
-
/**
|
|
504
|
-
|
|
505
|
-
/**
|
|
506
|
-
|
|
624
|
+
export declare interface StaticEnumField<N extends string, O extends readonly EnumOptionValue[]> {
|
|
625
|
+
/** Type discriminator for form elements */
|
|
626
|
+
readonly _type: "field";
|
|
627
|
+
/** Field type discriminator - identifies this as an enum field */
|
|
628
|
+
readonly _field: "enum";
|
|
629
|
+
/** Unique field identifier used as the schema key */
|
|
630
|
+
readonly name: N;
|
|
631
|
+
/** Array of allowed option values */
|
|
632
|
+
readonly options: O;
|
|
633
|
+
/** Display label for the field */
|
|
634
|
+
readonly label?: string;
|
|
635
|
+
/** Whether this field is required for form submission */
|
|
636
|
+
readonly required?: boolean;
|
|
507
637
|
}
|
|
508
638
|
|
|
509
639
|
/**
|
|
510
|
-
*
|
|
640
|
+
* Form element type definitions.
|
|
641
|
+
*
|
|
642
|
+
* These types define the structure of form specifications.
|
|
643
|
+
* The structure IS the definition - nesting implies layout and conditional logic.
|
|
644
|
+
*/
|
|
645
|
+
/**
|
|
646
|
+
* A text input field.
|
|
511
647
|
*
|
|
512
|
-
* @
|
|
513
|
-
* @param constraints - Field option constraints
|
|
514
|
-
* @returns Array of validation issues (empty if valid)
|
|
648
|
+
* @typeParam N - The field name (string literal type)
|
|
515
649
|
*
|
|
516
650
|
* @public
|
|
517
651
|
*/
|
|
518
|
-
export declare
|
|
652
|
+
export declare interface TextField<N extends string> {
|
|
653
|
+
/** Type discriminator for form elements */
|
|
654
|
+
readonly _type: "field";
|
|
655
|
+
/** Field type discriminator - identifies this as a text field */
|
|
656
|
+
readonly _field: "text";
|
|
657
|
+
/** Unique field identifier used as the schema key */
|
|
658
|
+
readonly name: N;
|
|
659
|
+
/** Display label for the field */
|
|
660
|
+
readonly label?: string;
|
|
661
|
+
/** Placeholder text shown when field is empty */
|
|
662
|
+
readonly placeholder?: string;
|
|
663
|
+
/** Whether this field is required for form submission */
|
|
664
|
+
readonly required?: boolean;
|
|
665
|
+
/** Minimum string length */
|
|
666
|
+
readonly minLength?: number;
|
|
667
|
+
/** Maximum string length */
|
|
668
|
+
readonly maxLength?: number;
|
|
669
|
+
/** Regular expression pattern the value must match */
|
|
670
|
+
readonly pattern?: string;
|
|
671
|
+
}
|
|
519
672
|
|
|
520
673
|
/**
|
|
521
|
-
*
|
|
522
|
-
*
|
|
523
|
-
* @param context - Information about the field being validated
|
|
524
|
-
* @param constraints - Field type constraints
|
|
525
|
-
* @returns Array of validation issues (empty if valid)
|
|
674
|
+
* UI Schema feature constraints - control JSONForms-specific features.
|
|
526
675
|
*
|
|
527
676
|
* @public
|
|
528
677
|
*/
|
|
529
|
-
export declare
|
|
678
|
+
export declare interface UISchemaConstraints {
|
|
679
|
+
/** Layout type constraints */
|
|
680
|
+
layouts?: LayoutTypeConstraints;
|
|
681
|
+
/** Rule (conditional) constraints */
|
|
682
|
+
rules?: RuleConstraints;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
/* Excluded from this release type: validateFieldOptions */
|
|
686
|
+
|
|
687
|
+
/* Excluded from this release type: validateFieldTypes */
|
|
530
688
|
|
|
531
689
|
/**
|
|
532
690
|
* Validates a complete FormSpec against constraints.
|
|
@@ -578,16 +736,7 @@ export declare function validateFormSpec(formSpec: FormSpec<readonly FormElement
|
|
|
578
736
|
*/
|
|
579
737
|
export declare function validateFormSpecElements(elements: readonly FormElement[], options?: FormSpecValidationOptions): ValidationResult;
|
|
580
738
|
|
|
581
|
-
|
|
582
|
-
* Validates a layout element against constraints.
|
|
583
|
-
*
|
|
584
|
-
* @param context - Information about the layout element
|
|
585
|
-
* @param constraints - Layout constraints
|
|
586
|
-
* @returns Array of validation issues (empty if valid)
|
|
587
|
-
*
|
|
588
|
-
* @public
|
|
589
|
-
*/
|
|
590
|
-
export declare function validateLayout(context: LayoutContext, constraints: LayoutConstraints): ValidationIssue[];
|
|
739
|
+
/* Excluded from this release type: validateLayout */
|
|
591
740
|
|
|
592
741
|
/**
|
|
593
742
|
* A single validation issue found during constraint checking.
|
package/dist/defaults.d.ts
CHANGED
|
@@ -3,19 +3,19 @@ import type { ConstraintConfig, FormSpecConfig, ResolvedConstraintConfig } from
|
|
|
3
3
|
* Default constraint configuration that allows all features.
|
|
4
4
|
* All constraints default to "off" (allowed).
|
|
5
5
|
*
|
|
6
|
-
* @
|
|
6
|
+
* @beta
|
|
7
7
|
*/
|
|
8
8
|
export declare const DEFAULT_CONSTRAINTS: ResolvedConstraintConfig;
|
|
9
9
|
/**
|
|
10
10
|
* Default FormSpec configuration.
|
|
11
11
|
*
|
|
12
|
-
* @
|
|
12
|
+
* @beta
|
|
13
13
|
*/
|
|
14
14
|
export declare const DEFAULT_CONFIG: FormSpecConfig;
|
|
15
15
|
/**
|
|
16
16
|
* Merges user constraints with defaults, filling in any missing values.
|
|
17
17
|
*
|
|
18
|
-
* @
|
|
18
|
+
* @beta
|
|
19
19
|
*/
|
|
20
20
|
export declare function mergeWithDefaults(config: ConstraintConfig | undefined): ResolvedConstraintConfig;
|
|
21
21
|
//# sourceMappingURL=defaults.d.ts.map
|