@rjsf/utils 6.0.0-beta.2 → 6.0.0-beta.21
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/{index.js → index.cjs} +396 -264
- package/dist/index.cjs.map +7 -0
- package/dist/utils.esm.js +395 -263
- package/dist/utils.esm.js.map +4 -4
- package/dist/utils.umd.js +368 -249
- package/lib/ErrorSchemaBuilder.d.ts +2 -2
- package/lib/canExpand.d.ts +1 -1
- package/lib/constants.d.ts +3 -0
- package/lib/constants.js +3 -0
- package/lib/constants.js.map +1 -1
- package/lib/createSchemaUtils.js +25 -18
- package/lib/createSchemaUtils.js.map +1 -1
- package/lib/enums.d.ts +9 -3
- package/lib/enums.js +9 -3
- package/lib/enums.js.map +1 -1
- package/lib/findSchemaDefinition.d.ts +7 -1
- package/lib/findSchemaDefinition.js +48 -6
- package/lib/findSchemaDefinition.js.map +1 -1
- package/lib/getTestIds.js +2 -2
- package/lib/getTestIds.js.map +1 -1
- package/lib/getUiOptions.js +4 -0
- package/lib/getUiOptions.js.map +1 -1
- package/lib/getWidget.js +3 -3
- package/lib/getWidget.js.map +1 -1
- package/lib/guessType.d.ts +1 -1
- package/lib/idGenerators.d.ts +22 -15
- package/lib/idGenerators.js +17 -8
- package/lib/idGenerators.js.map +1 -1
- package/lib/index.d.ts +10 -4
- package/lib/index.js +9 -4
- package/lib/index.js.map +1 -1
- package/lib/isFormDataAvailable.d.ts +7 -0
- package/lib/isFormDataAvailable.js +13 -0
- package/lib/isFormDataAvailable.js.map +1 -0
- package/lib/isRootSchema.d.ts +13 -0
- package/lib/isRootSchema.js +25 -0
- package/lib/isRootSchema.js.map +1 -0
- package/lib/mergeDefaultsWithFormData.js +14 -2
- package/lib/mergeDefaultsWithFormData.js.map +1 -1
- package/lib/schema/findFieldInSchema.d.ts +1 -1
- package/lib/schema/findFieldInSchema.js +1 -1
- package/lib/schema/getDefaultFormState.d.ts +17 -3
- package/lib/schema/getDefaultFormState.js +73 -27
- package/lib/schema/getDefaultFormState.js.map +1 -1
- package/lib/schema/getDisplayLabel.js +2 -2
- package/lib/schema/getDisplayLabel.js.map +1 -1
- package/lib/schema/index.d.ts +1 -2
- package/lib/schema/index.js +1 -2
- package/lib/schema/index.js.map +1 -1
- package/lib/schema/retrieveSchema.d.ts +11 -6
- package/lib/schema/retrieveSchema.js +42 -19
- package/lib/schema/retrieveSchema.js.map +1 -1
- package/lib/shallowEquals.d.ts +8 -0
- package/lib/shallowEquals.js +36 -0
- package/lib/shallowEquals.js.map +1 -0
- package/lib/shouldRender.d.ts +8 -2
- package/lib/shouldRender.js +17 -2
- package/lib/shouldRender.js.map +1 -1
- package/lib/shouldRenderOptionalField.d.ts +18 -0
- package/lib/shouldRenderOptionalField.js +47 -0
- package/lib/shouldRenderOptionalField.js.map +1 -0
- package/lib/toFieldPathId.d.ts +12 -0
- package/lib/toFieldPathId.js +19 -0
- package/lib/toFieldPathId.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types.d.ts +136 -81
- package/lib/validationDataMerge.d.ts +2 -1
- package/lib/validationDataMerge.js +3 -2
- package/lib/validationDataMerge.js.map +1 -1
- package/package.json +13 -14
- package/src/ErrorSchemaBuilder.ts +2 -2
- package/src/constants.ts +3 -0
- package/src/createSchemaUtils.ts +25 -26
- package/src/enums.ts +9 -3
- package/src/findSchemaDefinition.ts +55 -6
- package/src/getTestIds.ts +2 -2
- package/src/getUiOptions.ts +4 -0
- package/src/getWidget.tsx +3 -3
- package/src/idGenerators.ts +35 -25
- package/src/index.ts +16 -2
- package/src/isFormDataAvailable.ts +13 -0
- package/src/isRootSchema.ts +30 -0
- package/src/mergeDefaultsWithFormData.ts +16 -2
- package/src/schema/findFieldInSchema.ts +1 -1
- package/src/schema/getDefaultFormState.ts +95 -33
- package/src/schema/getDisplayLabel.ts +2 -2
- package/src/schema/index.ts +0 -2
- package/src/schema/retrieveSchema.ts +46 -10
- package/src/shallowEquals.ts +41 -0
- package/src/shouldRender.ts +27 -2
- package/src/shouldRenderOptionalField.ts +56 -0
- package/src/toFieldPathId.ts +24 -0
- package/src/types.ts +156 -84
- package/src/validationDataMerge.ts +7 -1
- package/dist/index.js.map +0 -7
- package/lib/schema/toIdSchema.d.ts +0 -14
- package/lib/schema/toIdSchema.js +0 -62
- package/lib/schema/toIdSchema.js.map +0 -1
- package/src/schema/toIdSchema.ts +0 -131
package/lib/types.d.ts
CHANGED
|
@@ -133,15 +133,23 @@ export type InputPropsType = Omit<RangeSpecType, 'step'> & {
|
|
|
133
133
|
/** Specifies a filter for what file types the user can upload. */
|
|
134
134
|
accept?: HTMLInputElement['accept'];
|
|
135
135
|
};
|
|
136
|
-
/**
|
|
137
|
-
|
|
136
|
+
/** The list of path elements that represents where in the schema a field is located. When the item in the field list is
|
|
137
|
+
* a string, then it represents the name of the property within an object. When it is a number, then it represents the
|
|
138
|
+
* index within an array.
|
|
139
|
+
*
|
|
140
|
+
* For example:
|
|
141
|
+
* `[]` represents the root object of the schema
|
|
142
|
+
* `['foo', 'bar']` represents the `bar` element contained within the `foo` element of the schema
|
|
143
|
+
* `['baz', 1]` represents the second element in the list `baz` of the schema
|
|
144
|
+
*/
|
|
145
|
+
export type FieldPathList = (string | number)[];
|
|
146
|
+
/** Type describing an id and path used for a field */
|
|
147
|
+
export type FieldPathId = {
|
|
138
148
|
/** The id for a field */
|
|
139
149
|
$id: string;
|
|
150
|
+
/** The path for a field */
|
|
151
|
+
path: FieldPathList;
|
|
140
152
|
};
|
|
141
|
-
/** Type describing a recursive structure of `FieldId`s for an object with a non-empty set of keys */
|
|
142
|
-
export type IdSchema<T = any> = T extends GenericObjectType ? FieldId & {
|
|
143
|
-
[key in keyof T]?: IdSchema<T[key]>;
|
|
144
|
-
} : FieldId;
|
|
145
153
|
/** Type describing a name used for a field in the `PathSchema` */
|
|
146
154
|
export type FieldPath = {
|
|
147
155
|
/** The name of a field */
|
|
@@ -174,6 +182,8 @@ export type RJSFValidationError = {
|
|
|
174
182
|
schemaPath?: string;
|
|
175
183
|
/** Full error name, for example ".name is a required property" */
|
|
176
184
|
stack: string;
|
|
185
|
+
/** The title property for the failing field*/
|
|
186
|
+
title?: string;
|
|
177
187
|
};
|
|
178
188
|
/** The type that describes an error in a field */
|
|
179
189
|
export type FieldError = string;
|
|
@@ -210,8 +220,6 @@ export type ErrorListProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F e
|
|
|
210
220
|
errorSchema: ErrorSchema<T>;
|
|
211
221
|
/** An array of the errors */
|
|
212
222
|
errors: RJSFValidationError[];
|
|
213
|
-
/** The `formContext` object that was passed to `Form` */
|
|
214
|
-
formContext?: F;
|
|
215
223
|
};
|
|
216
224
|
/** The properties that are passed to an `FieldErrorTemplate` implementation */
|
|
217
225
|
export type FieldErrorProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
|
|
@@ -219,15 +227,15 @@ export type FieldErrorProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
219
227
|
errorSchema?: ErrorSchema<T>;
|
|
220
228
|
/** An array of the errors */
|
|
221
229
|
errors?: Array<string | ReactElement>;
|
|
222
|
-
/** The
|
|
223
|
-
|
|
230
|
+
/** The FieldPathId of the field in the hierarchy */
|
|
231
|
+
fieldPathId: FieldPathId;
|
|
224
232
|
};
|
|
225
233
|
/** The properties that are passed to an `FieldHelpTemplate` implementation */
|
|
226
234
|
export type FieldHelpProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
|
|
227
235
|
/** The help information to be rendered */
|
|
228
236
|
help?: string | ReactElement;
|
|
229
|
-
/** The
|
|
230
|
-
|
|
237
|
+
/** The FieldPathId of the field in the hierarchy */
|
|
238
|
+
fieldPathId: FieldPathId;
|
|
231
239
|
/** Flag indicating whether there are errors associated with this field */
|
|
232
240
|
hasErrors?: boolean;
|
|
233
241
|
};
|
|
@@ -276,8 +284,12 @@ export type TemplatesType<T = any, S extends StrictRJSFSchema = RJSFSchema, F ex
|
|
|
276
284
|
FieldTemplate: ComponentType<FieldTemplateProps<T, S, F>>;
|
|
277
285
|
/** The template to use to render a Grid element */
|
|
278
286
|
GridTemplate: ComponentType<GridTemplateProps>;
|
|
287
|
+
/** The template to use while rendering a multi-schema field (i.e. anyOf, oneOf) */
|
|
288
|
+
MultiSchemaFieldTemplate: ComponentType<MultiSchemaFieldTemplateProps<T, S, F>>;
|
|
279
289
|
/** The template to use while rendering an object */
|
|
280
290
|
ObjectFieldTemplate: ComponentType<ObjectFieldTemplateProps<T, S, F>>;
|
|
291
|
+
/** The template to use while rendering the Optional Data field controls */
|
|
292
|
+
OptionalDataControlsTemplate: ComponentType<OptionalDataControlsTemplateProps<T, S, F>>;
|
|
281
293
|
/** The template to use for rendering the title of a field */
|
|
282
294
|
TitleFieldTemplate: ComponentType<TitleFieldProps<T, S, F>>;
|
|
283
295
|
/** The template to use for rendering information about an unsupported field type in the schema */
|
|
@@ -306,9 +318,10 @@ export type TemplatesType<T = any, S extends StrictRJSFSchema = RJSFSchema, F ex
|
|
|
306
318
|
} | undefined;
|
|
307
319
|
};
|
|
308
320
|
/** The set of UiSchema options that can be set globally and used as fallbacks at an individual template, field or
|
|
309
|
-
* widget level when no field-level value of the option is provided.
|
|
321
|
+
* widget level when no field-level value of the option is provided. Extends GenericObjectType to support allowing users
|
|
322
|
+
* to provide any value they need for their customizations.
|
|
310
323
|
*/
|
|
311
|
-
export type GlobalUISchemaOptions = {
|
|
324
|
+
export type GlobalUISchemaOptions = GenericObjectType & {
|
|
312
325
|
/** Flag, if set to `false`, new items cannot be added to array fields, unless overridden (defaults to true) */
|
|
313
326
|
addable?: boolean;
|
|
314
327
|
/** Flag, if set to `true`, array items can be copied (defaults to false) */
|
|
@@ -326,6 +339,25 @@ export type GlobalUISchemaOptions = {
|
|
|
326
339
|
/** Enables the displaying of description text that contains markdown
|
|
327
340
|
*/
|
|
328
341
|
enableMarkdownInDescription?: boolean;
|
|
342
|
+
/** Enables the rendering of the Optional Data Field UI for specific types of schemas, either `object`, `array` or
|
|
343
|
+
* both. To disable the Optional Data Field UI for a specific field, provide an empty array within the UI schema.
|
|
344
|
+
*/
|
|
345
|
+
enableOptionalDataFieldForType?: ('object' | 'array')[];
|
|
346
|
+
};
|
|
347
|
+
/** The set of options from the `Form` that will be available on the `Registry` for use in everywhere the `registry` is
|
|
348
|
+
* available.
|
|
349
|
+
*/
|
|
350
|
+
export type GlobalFormOptions = {
|
|
351
|
+
/** To avoid collisions with existing ids in the DOM, it is possible to change the prefix used for ids;
|
|
352
|
+
* Default is `root`. This prop is passed to the `toFilePathId()` function within the RJSF field implementations.
|
|
353
|
+
*/
|
|
354
|
+
readonly idPrefix: string;
|
|
355
|
+
/** To avoid using a path separator that is present in field names, it is possible to change the separator used for
|
|
356
|
+
* ids; Default is `_`. This prop is passed to the `toFilePathId()` function within the RJSF field implementations.
|
|
357
|
+
*/
|
|
358
|
+
readonly idSeparator: string;
|
|
359
|
+
/** The component update strategy used by the Form and its fields for performance optimization */
|
|
360
|
+
readonly experimental_componentUpdateStrategy?: 'customDeep' | 'shallow' | 'always';
|
|
329
361
|
};
|
|
330
362
|
/** The object containing the registered core, theme and custom fields and widgets as well as the root schema, form
|
|
331
363
|
* context, schema utils and templates.
|
|
@@ -335,7 +367,7 @@ export interface Registry<T = any, S extends StrictRJSFSchema = RJSFSchema, F ex
|
|
|
335
367
|
* registered fields
|
|
336
368
|
*/
|
|
337
369
|
fields: RegistryFieldsType<T, S, F>;
|
|
338
|
-
/** The set of templates used by the `Form`. Includes templates from `core`, theme-specific
|
|
370
|
+
/** The set of templates used by the `Form`. Includes templates from `core`, theme-specific templates and any custom
|
|
339
371
|
* registered templates
|
|
340
372
|
*/
|
|
341
373
|
templates: TemplatesType<T, S, F>;
|
|
@@ -353,25 +385,27 @@ export interface Registry<T = any, S extends StrictRJSFSchema = RJSFSchema, F ex
|
|
|
353
385
|
schemaUtils: SchemaUtilsType<T, S>;
|
|
354
386
|
/** The string translation function to use when displaying any of the RJSF strings in templates, fields or widgets */
|
|
355
387
|
translateString: (stringKey: TranslatableString, params?: string[]) => string;
|
|
388
|
+
/** The global Form Options that are available for all templates, fields and widgets to access */
|
|
389
|
+
readonly globalFormOptions: GlobalFormOptions;
|
|
356
390
|
/** The optional global UI Options that are available for all templates, fields and widgets to access */
|
|
357
391
|
globalUiOptions?: GlobalUISchemaOptions;
|
|
358
392
|
}
|
|
359
|
-
/** The properties that are passed to a Field implementation */
|
|
393
|
+
/** The properties that are passed to a `Field` implementation */
|
|
360
394
|
export interface FieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> extends GenericObjectType, RJSFBaseProps<T, S, F>, Pick<HTMLAttributes<HTMLElement>, Exclude<keyof HTMLAttributes<HTMLElement>, 'onBlur' | 'onFocus' | 'onChange'>> {
|
|
361
|
-
/** The
|
|
362
|
-
|
|
395
|
+
/** The FieldPathId of the field in the hierarchy */
|
|
396
|
+
fieldPathId: FieldPathId;
|
|
363
397
|
/** The data for this field */
|
|
364
398
|
formData?: T;
|
|
365
399
|
/** The tree of errors for this field and its children */
|
|
366
400
|
errorSchema?: ErrorSchema<T>;
|
|
367
|
-
/** The field change event handler; called with the updated
|
|
368
|
-
|
|
401
|
+
/** The field change event handler; called with the updated field value, the change path for the value
|
|
402
|
+
* (defaults to an empty array), an optional ErrorSchema and the optional id of the field being changed
|
|
403
|
+
*/
|
|
404
|
+
onChange: (newValue: T | undefined, path: FieldPathList, es?: ErrorSchema<T>, id?: string) => void;
|
|
369
405
|
/** The input blur event handler; call it with the field id and value */
|
|
370
406
|
onBlur: (id: string, value: any) => void;
|
|
371
407
|
/** The input focus event handler; call it with the field id and value */
|
|
372
408
|
onFocus: (id: string, value: any) => void;
|
|
373
|
-
/** The `formContext` object that you passed to `Form` */
|
|
374
|
-
formContext?: F;
|
|
375
409
|
/** A boolean value stating if the field should autofocus */
|
|
376
410
|
autofocus?: boolean;
|
|
377
411
|
/** A boolean value stating if the field is disabled */
|
|
@@ -384,20 +418,15 @@ export interface FieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
384
418
|
required?: boolean;
|
|
385
419
|
/** The unique name of the field, usually derived from the name of the property in the JSONSchema */
|
|
386
420
|
name: string;
|
|
387
|
-
/** To avoid collisions with existing ids in the DOM, it is possible to change the prefix used for ids;
|
|
388
|
-
* Default is `root`
|
|
389
|
-
*/
|
|
390
|
-
idPrefix?: string;
|
|
391
|
-
/** To avoid using a path separator that is present in field names, it is possible to change the separator used for
|
|
392
|
-
* ids (Default is `_`)
|
|
393
|
-
*/
|
|
394
|
-
idSeparator?: string;
|
|
395
421
|
/** An array of strings listing all generated error messages from encountered errors for this field */
|
|
396
422
|
rawErrors?: string[];
|
|
397
423
|
}
|
|
398
424
|
/** The definition of a React-based Field component */
|
|
399
|
-
export type Field<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = ComponentType<FieldProps<T, S, F
|
|
400
|
-
/** The
|
|
425
|
+
export type Field<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = ComponentType<FieldProps<T, S, F>> & {
|
|
426
|
+
/** The optional TEST_IDS block that some fields contain, exported for testing purposes */
|
|
427
|
+
TEST_IDS?: TestIdShape;
|
|
428
|
+
};
|
|
429
|
+
/** The properties that are passed to a `FieldTemplate` implementation */
|
|
401
430
|
export type FieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
|
|
402
431
|
/** The id of the field in the hierarchy. You can use it to render a label targeting the wrapped widget */
|
|
403
432
|
id: string;
|
|
@@ -439,8 +468,6 @@ export type FieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema,
|
|
|
439
468
|
* you don't want to clutter the UI
|
|
440
469
|
*/
|
|
441
470
|
displayLabel?: boolean;
|
|
442
|
-
/** The `formContext` object that was passed to `Form` */
|
|
443
|
-
formContext?: F;
|
|
444
471
|
/** The formData for this field */
|
|
445
472
|
formData?: T;
|
|
446
473
|
/** The value change event handler; Can be called with a new value to change the value for this field */
|
|
@@ -452,8 +479,8 @@ export type FieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema,
|
|
|
452
479
|
};
|
|
453
480
|
/** The properties that are passed to the `UnsupportedFieldTemplate` implementation */
|
|
454
481
|
export type UnsupportedFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
|
|
455
|
-
/** The
|
|
456
|
-
|
|
482
|
+
/** The FieldPathId of the field in the hierarchy */
|
|
483
|
+
fieldPathId: FieldPathId;
|
|
457
484
|
/** The reason why the schema field has an unsupported type */
|
|
458
485
|
reason: string;
|
|
459
486
|
};
|
|
@@ -465,6 +492,8 @@ export type TitleFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
465
492
|
title: string;
|
|
466
493
|
/** A boolean value stating if the field is required */
|
|
467
494
|
required?: boolean;
|
|
495
|
+
/** Add optional data control */
|
|
496
|
+
optionalDataControl?: ReactNode;
|
|
468
497
|
};
|
|
469
498
|
/** The properties that are passed to a `DescriptionFieldTemplate` implementation */
|
|
470
499
|
export type DescriptionFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
|
|
@@ -477,20 +506,22 @@ export type DescriptionFieldProps<T = any, S extends StrictRJSFSchema = RJSFSche
|
|
|
477
506
|
export type ArrayFieldTitleProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Omit<TitleFieldProps<T, S, F>, 'id' | 'title'> & {
|
|
478
507
|
/** The title for the field being rendered */
|
|
479
508
|
title?: string;
|
|
480
|
-
/** The
|
|
481
|
-
|
|
509
|
+
/** The FieldPathId of the field in the hierarchy */
|
|
510
|
+
fieldPathId: FieldPathId;
|
|
511
|
+
/** Add optional data control */
|
|
512
|
+
optionalDataControl?: ReactNode;
|
|
482
513
|
};
|
|
483
514
|
/** The properties that are passed to a `ArrayFieldDescriptionTemplate` implementation */
|
|
484
515
|
export type ArrayFieldDescriptionProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Omit<DescriptionFieldProps<T, S, F>, 'id' | 'description'> & {
|
|
485
516
|
/** The description of the field being rendered */
|
|
486
517
|
description?: string | ReactElement;
|
|
487
|
-
/**
|
|
488
|
-
|
|
518
|
+
/** An object containing the id and path for this field */
|
|
519
|
+
fieldPathId: FieldPathId;
|
|
489
520
|
};
|
|
490
521
|
/** The properties of the buttons to render for each element in the ArrayFieldTemplateProps.items array */
|
|
491
522
|
export type ArrayFieldItemButtonsTemplateType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
|
|
492
|
-
/** The
|
|
493
|
-
|
|
523
|
+
/** The FieldPathId of the item for which buttons are being rendered */
|
|
524
|
+
fieldPathId: FieldPathId;
|
|
494
525
|
/** The className string */
|
|
495
526
|
className?: string;
|
|
496
527
|
/** Any optional style attributes */
|
|
@@ -547,20 +578,14 @@ export type ArrayFieldItemTemplateType<T = any, S extends StrictRJSFSchema = RJS
|
|
|
547
578
|
* @deprecated - Use `ArrayFieldItemTemplateType` instead
|
|
548
579
|
*/
|
|
549
580
|
export type ArrayFieldTemplateItemType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = ArrayFieldItemTemplateType<T, S, F>;
|
|
550
|
-
/** The properties
|
|
551
|
-
export type
|
|
552
|
-
/** A boolean value stating whether new elements can be added to the array */
|
|
553
|
-
canAdd?: boolean;
|
|
581
|
+
/** The common properties of the two container templates: `ArrayFieldTemplateProps` and `ObjectFieldTemplateProps` */
|
|
582
|
+
export type ContainerFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
|
|
554
583
|
/** The className string */
|
|
555
584
|
className?: string;
|
|
556
585
|
/** A boolean value stating if the array is disabled */
|
|
557
586
|
disabled?: boolean;
|
|
558
|
-
/**
|
|
559
|
-
|
|
560
|
-
/** An array of objects representing the items in the array */
|
|
561
|
-
items: ArrayFieldItemTemplateType<T, S, F>[];
|
|
562
|
-
/** A function that adds a new item to the array */
|
|
563
|
-
onAddClick: (event?: any) => void;
|
|
587
|
+
/** The FieldPathId of the field in the hierarchy */
|
|
588
|
+
fieldPathId: FieldPathId;
|
|
564
589
|
/** A boolean value stating if the array is read-only */
|
|
565
590
|
readonly?: boolean;
|
|
566
591
|
/** A boolean value stating if the array is required */
|
|
@@ -569,12 +594,21 @@ export type ArrayFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSc
|
|
|
569
594
|
hideError?: boolean;
|
|
570
595
|
/** A string value containing the title for the array */
|
|
571
596
|
title: string;
|
|
572
|
-
/** The `formContext` object that was passed to Form */
|
|
573
|
-
formContext?: F;
|
|
574
597
|
/** The formData for this array */
|
|
575
598
|
formData?: T;
|
|
576
|
-
/** The
|
|
599
|
+
/** The optional validation errors in the form of an `ErrorSchema` */
|
|
577
600
|
errorSchema?: ErrorSchema<T>;
|
|
601
|
+
/** The optional data control node to render within the ObjectFieldTemplate that controls */
|
|
602
|
+
optionalDataControl?: ReactNode;
|
|
603
|
+
};
|
|
604
|
+
/** The properties that are passed to an `ArrayFieldTemplate` implementation */
|
|
605
|
+
export type ArrayFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = ContainerFieldTemplateProps<T, S, F> & {
|
|
606
|
+
/** A boolean value stating whether new elements can be added to the array */
|
|
607
|
+
canAdd?: boolean;
|
|
608
|
+
/** An array of objects representing the items in the array */
|
|
609
|
+
items: ArrayFieldItemTemplateType<T, S, F>[];
|
|
610
|
+
/** A function that adds a new item to the array */
|
|
611
|
+
onAddClick: (event?: any) => void;
|
|
578
612
|
/** An array of strings listing all generated error messages from encountered errors for this widget */
|
|
579
613
|
rawErrors?: string[];
|
|
580
614
|
};
|
|
@@ -592,13 +626,9 @@ export type ObjectFieldTemplatePropertyType = {
|
|
|
592
626
|
hidden: boolean;
|
|
593
627
|
};
|
|
594
628
|
/** The properties that are passed to an ObjectFieldTemplate implementation */
|
|
595
|
-
export type ObjectFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> =
|
|
596
|
-
/** A string value containing the title for the object */
|
|
597
|
-
title: string;
|
|
629
|
+
export type ObjectFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = ContainerFieldTemplateProps<T, S, F> & {
|
|
598
630
|
/** A string value containing the description for the object */
|
|
599
631
|
description?: string | ReactElement;
|
|
600
|
-
/** A boolean value stating if the object is disabled */
|
|
601
|
-
disabled?: boolean;
|
|
602
632
|
/** An array of objects representing the properties in the object */
|
|
603
633
|
properties: ObjectFieldTemplatePropertyType[];
|
|
604
634
|
/** Returns a function that adds a new property to the object (to be used with additionalProperties) */
|
|
@@ -609,22 +639,38 @@ export type ObjectFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFS
|
|
|
609
639
|
required?: boolean;
|
|
610
640
|
/** A boolean value stating if the field is hiding its errors */
|
|
611
641
|
hideError?: boolean;
|
|
612
|
-
/**
|
|
613
|
-
|
|
642
|
+
/** The FieldPathId of the field in the hierarchy */
|
|
643
|
+
fieldPathId: FieldPathId;
|
|
614
644
|
/** The optional validation errors in the form of an `ErrorSchema` */
|
|
615
645
|
errorSchema?: ErrorSchema<T>;
|
|
616
646
|
/** The form data for the object */
|
|
617
647
|
formData?: T;
|
|
618
|
-
|
|
619
|
-
|
|
648
|
+
};
|
|
649
|
+
/** The properties that are passed to a OptionalDataControlsTemplate implementation */
|
|
650
|
+
export type OptionalDataControlsTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
|
|
651
|
+
/** The generated id for this Optional Data Control instance */
|
|
652
|
+
id: string;
|
|
653
|
+
/** The label to use for the Optional Data Control */
|
|
654
|
+
label: string;
|
|
655
|
+
/** Optional callback to call when clicking on the Optional Data Control to add data */
|
|
656
|
+
onRemoveClick?: () => void;
|
|
657
|
+
/** Optional callback to call when clicking on the Optional Data Control to remove data */
|
|
658
|
+
onAddClick?: () => void;
|
|
620
659
|
};
|
|
621
660
|
/** The properties that are passed to a WrapIfAdditionalTemplate implementation */
|
|
622
661
|
export type WrapIfAdditionalTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
|
|
623
662
|
/** The field or widget component instance for this field row */
|
|
624
663
|
children: ReactNode;
|
|
625
664
|
} & Pick<FieldTemplateProps<T, S, F>, 'id' | 'classNames' | 'hideError' | 'rawErrors' | 'style' | 'label' | 'required' | 'readonly' | 'disabled' | 'schema' | 'uiSchema' | 'onKeyChange' | 'onDropPropertyClick' | 'registry'>;
|
|
626
|
-
/** The properties that are passed to a
|
|
627
|
-
export interface
|
|
665
|
+
/** The properties that are passed to a MultiSchemaFieldTemplate implementation */
|
|
666
|
+
export interface MultiSchemaFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> extends RJSFBaseProps<T, S, F> {
|
|
667
|
+
/** The rendered widget used to select a schema option */
|
|
668
|
+
selector: ReactNode;
|
|
669
|
+
/** The rendered SchemaField for the selected schema option */
|
|
670
|
+
optionSchemaField: ReactNode;
|
|
671
|
+
}
|
|
672
|
+
/** The properties that are passed to a `Widget` implementation */
|
|
673
|
+
export interface WidgetProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> extends GenericObjectType, RJSFBaseProps<T, S, F>, Pick<HTMLAttributes<HTMLElement>, Exclude<keyof HTMLAttributes<HTMLElement>, 'onBlur' | 'onFocus' | 'onChange'>> {
|
|
628
674
|
/** The generated id for this widget, used to provide unique `name`s and `id`s for the HTML field elements rendered by
|
|
629
675
|
* widgets
|
|
630
676
|
*/
|
|
@@ -654,8 +700,6 @@ export interface WidgetProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
654
700
|
/** The enum options list for a type that supports them */
|
|
655
701
|
enumOptions?: EnumOptionsType<S>[];
|
|
656
702
|
};
|
|
657
|
-
/** The `formContext` object that you passed to `Form` */
|
|
658
|
-
formContext?: F;
|
|
659
703
|
/** The input blur event handler; call it with the widget id and value */
|
|
660
704
|
onBlur: (id: string, value: any) => void;
|
|
661
705
|
/** The value change event handler; call it with the new value every time it changes */
|
|
@@ -788,6 +832,12 @@ export type UIOptionsType<T = any, S extends StrictRJSFSchema = RJSFSchema, F ex
|
|
|
788
832
|
/** Anything else will be one of these types */
|
|
789
833
|
[key: string]: boolean | number | string | object | any[] | null | undefined;
|
|
790
834
|
};
|
|
835
|
+
/**
|
|
836
|
+
* A utility type that extracts the element type from an array type.
|
|
837
|
+
* If the type is not an array, it returns the type itself as a safe fallback.
|
|
838
|
+
* Handles both standard arrays and readonly arrays.
|
|
839
|
+
*/
|
|
840
|
+
export type ArrayElement<A> = A extends readonly (infer E)[] ? E : A;
|
|
791
841
|
/** Type describing the well-known properties of the `UiSchema` while also supporting all user defined properties,
|
|
792
842
|
* starting with `ui:`.
|
|
793
843
|
*/
|
|
@@ -796,7 +846,10 @@ export type UiSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
|
|
|
796
846
|
* Registry for use everywhere.
|
|
797
847
|
*/
|
|
798
848
|
'ui:globalOptions'?: GlobalUISchemaOptions;
|
|
799
|
-
/** Allows the form to generate a unique prefix for the `Form`'s root prefix
|
|
849
|
+
/** Allows the form to generate a unique prefix for the `Form`'s root prefix
|
|
850
|
+
*
|
|
851
|
+
* @deprecated - use `Form.idPrefix` instead, will be removed in a future major version
|
|
852
|
+
*/
|
|
800
853
|
'ui:rootFieldId'?: string;
|
|
801
854
|
/** By default, any field that is rendered for an `anyOf`/`oneOf` schema will be wrapped inside the `AnyOfField` or
|
|
802
855
|
* `OneOfField` component. This default behavior may be undesirable if your custom field already handles behavior
|
|
@@ -808,6 +861,11 @@ export type UiSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
|
|
|
808
861
|
'ui:fieldReplacesAnyOrOneOf'?: boolean;
|
|
809
862
|
/** An object that contains all the potential UI options in a single object */
|
|
810
863
|
'ui:options'?: UIOptionsType<T, S, F>;
|
|
864
|
+
/** The uiSchema for items in an array. Can be an object for a uniform uiSchema across all items (current behavior),
|
|
865
|
+
* or a function that returns a dynamic uiSchema based on the item's data and index.
|
|
866
|
+
* When using a function, it receives the item data, index, and optionally the form context as parameters.
|
|
867
|
+
*/
|
|
868
|
+
items?: UiSchema<ArrayElement<T>, S, F> | ((itemData: ArrayElement<T>, index: number, formContext?: F) => UiSchema<ArrayElement<T>, S, F>);
|
|
811
869
|
};
|
|
812
870
|
/** A `CustomValidator` function takes in a `formData`, `errors` and `uiSchema` objects and returns the given `errors`
|
|
813
871
|
* object back, while potentially adding additional messages to the `errors`
|
|
@@ -878,6 +936,11 @@ export interface FoundFieldType<S extends StrictRJSFSchema = RJSFSchema> {
|
|
|
878
936
|
* set of APIs to the `@rjsf/core` components and the various themes as well.
|
|
879
937
|
*/
|
|
880
938
|
export interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> {
|
|
939
|
+
/** Returns the `rootSchema` in the `SchemaUtilsType`
|
|
940
|
+
*
|
|
941
|
+
* @returns - The rootSchema
|
|
942
|
+
*/
|
|
943
|
+
getRootSchema(): S;
|
|
881
944
|
/** Returns the `ValidatorType` in the `SchemaUtilsType`
|
|
882
945
|
*
|
|
883
946
|
* @returns - The `ValidatorType`
|
|
@@ -924,9 +987,10 @@ export interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchem
|
|
|
924
987
|
* @param [includeUndefinedValues=false] - Optional flag, if true, cause undefined values to be added as defaults.
|
|
925
988
|
* If "excludeObjectChildren", cause undefined values for this object and pass `includeUndefinedValues` as
|
|
926
989
|
* false when computing defaults for any nested object properties.
|
|
990
|
+
* @param initialDefaultsGenerated - Indicates whether or not initial defaults have been generated
|
|
927
991
|
* @returns - The resulting `formData` with all the defaults provided
|
|
928
992
|
*/
|
|
929
|
-
getDefaultFormState(schema: S, formData?: T, includeUndefinedValues?: boolean | 'excludeObjectChildren'): T | T[] | undefined;
|
|
993
|
+
getDefaultFormState(schema: S, formData?: T, includeUndefinedValues?: boolean | 'excludeObjectChildren', initialDefaultsGenerated?: boolean): T | T[] | undefined;
|
|
930
994
|
/** Determines whether the combination of `schema` and `uiSchema` properties indicates that the label for the `schema`
|
|
931
995
|
* should be displayed in a UI.
|
|
932
996
|
*
|
|
@@ -996,9 +1060,10 @@ export interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchem
|
|
|
996
1060
|
*
|
|
997
1061
|
* @param schema - The schema for which retrieving a schema is desired
|
|
998
1062
|
* @param [formData] - The current formData, if any, to assist retrieving a schema
|
|
1063
|
+
* @param [resolveAnyOfOrOneOfRefs] - Optional flag indicating whether to resolved refs in anyOf/oneOf lists
|
|
999
1064
|
* @returns - The schema having its conditions, additional properties, references and dependencies resolved
|
|
1000
1065
|
*/
|
|
1001
|
-
retrieveSchema(schema: S, formData?: T): S;
|
|
1066
|
+
retrieveSchema(schema: S, formData?: T, resolveAnyOfOrOneOfRefs?: boolean): S;
|
|
1002
1067
|
/** Sanitize the `data` associated with the `oldSchema` so it is considered appropriate for the `newSchema`. If the
|
|
1003
1068
|
* new schema does not contain any properties, then `undefined` is returned to clear all the form data. Due to the
|
|
1004
1069
|
* nature of schemas, this sanitization happens recursively for nested objects of data. Also, any properties in the
|
|
@@ -1011,16 +1076,6 @@ export interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchem
|
|
|
1011
1076
|
* to `undefined`. Will return `undefined` if the new schema is not an object containing properties.
|
|
1012
1077
|
*/
|
|
1013
1078
|
sanitizeDataForNewSchema(newSchema?: S, oldSchema?: S, data?: any): T;
|
|
1014
|
-
/** Generates an `IdSchema` object for the `schema`, recursively
|
|
1015
|
-
*
|
|
1016
|
-
* @param schema - The schema for which the display label flag is desired
|
|
1017
|
-
* @param [id] - The base id for the schema
|
|
1018
|
-
* @param [formData] - The current formData, if any, onto which to provide any missing defaults
|
|
1019
|
-
* @param [idPrefix='root'] - The prefix to use for the id
|
|
1020
|
-
* @param [idSeparator='_'] - The separator to use for the path segments in the id
|
|
1021
|
-
* @returns - The `IdSchema` object for the `schema`
|
|
1022
|
-
*/
|
|
1023
|
-
toIdSchema(schema: S, id?: string, formData?: T, idPrefix?: string, idSeparator?: string): IdSchema<T>;
|
|
1024
1079
|
/** Generates an `PathSchema` object for the `schema`, recursively
|
|
1025
1080
|
*
|
|
1026
1081
|
* @param schema - The schema for which the display label flag is desired
|
|
@@ -6,6 +6,7 @@ import { ErrorSchema, ValidationData } from './types.js';
|
|
|
6
6
|
*
|
|
7
7
|
* @param validationData - The current `ValidationData` into which to merge the additional errors
|
|
8
8
|
* @param [additionalErrorSchema] - The optional additional set of errors in an `ErrorSchema`
|
|
9
|
+
* @param [preventDuplicates=false] - Optional flag, if true, will call `mergeObjects()` with `preventDuplicates`
|
|
9
10
|
* @returns - The `validationData` with the additional errors from `additionalErrorSchema` merged into it, if provided.
|
|
10
11
|
*/
|
|
11
|
-
export default function validationDataMerge<T = any>(validationData: ValidationData<T>, additionalErrorSchema?: ErrorSchema<T
|
|
12
|
+
export default function validationDataMerge<T = any>(validationData: ValidationData<T>, additionalErrorSchema?: ErrorSchema<T>, preventDuplicates?: boolean): ValidationData<T>;
|
|
@@ -8,9 +8,10 @@ import toErrorList from './toErrorList.js';
|
|
|
8
8
|
*
|
|
9
9
|
* @param validationData - The current `ValidationData` into which to merge the additional errors
|
|
10
10
|
* @param [additionalErrorSchema] - The optional additional set of errors in an `ErrorSchema`
|
|
11
|
+
* @param [preventDuplicates=false] - Optional flag, if true, will call `mergeObjects()` with `preventDuplicates`
|
|
11
12
|
* @returns - The `validationData` with the additional errors from `additionalErrorSchema` merged into it, if provided.
|
|
12
13
|
*/
|
|
13
|
-
export default function validationDataMerge(validationData, additionalErrorSchema) {
|
|
14
|
+
export default function validationDataMerge(validationData, additionalErrorSchema, preventDuplicates = false) {
|
|
14
15
|
if (!additionalErrorSchema) {
|
|
15
16
|
return validationData;
|
|
16
17
|
}
|
|
@@ -18,7 +19,7 @@ export default function validationDataMerge(validationData, additionalErrorSchem
|
|
|
18
19
|
let errors = toErrorList(additionalErrorSchema);
|
|
19
20
|
let errorSchema = additionalErrorSchema;
|
|
20
21
|
if (!isEmpty(oldErrorSchema)) {
|
|
21
|
-
errorSchema = mergeObjects(oldErrorSchema, additionalErrorSchema, true);
|
|
22
|
+
errorSchema = mergeObjects(oldErrorSchema, additionalErrorSchema, preventDuplicates ? 'preventDuplicates' : true);
|
|
22
23
|
errors = [...oldErrors].concat(errors);
|
|
23
24
|
}
|
|
24
25
|
return { errorSchema, errors };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validationDataMerge.js","sourceRoot":"","sources":["../src/validationDataMerge.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,gBAAgB,CAAC;AAErC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,WAAW,MAAM,eAAe,CAAC;AAGxC
|
|
1
|
+
{"version":3,"file":"validationDataMerge.js","sourceRoot":"","sources":["../src/validationDataMerge.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,gBAAgB,CAAC;AAErC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,WAAW,MAAM,eAAe,CAAC;AAGxC;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CACzC,cAAiC,EACjC,qBAAsC,EACtC,iBAAiB,GAAG,KAAK;IAEzB,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC3B,OAAO,cAAc,CAAC;IACxB,CAAC;IACD,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,cAAc,CAAC;IAC1E,IAAI,MAAM,GAAG,WAAW,CAAC,qBAAqB,CAAC,CAAC;IAChD,IAAI,WAAW,GAAG,qBAAqB,CAAC;IACxC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC;QAC7B,WAAW,GAAG,YAAY,CACxB,cAAc,EACd,qBAAqB,EACrB,iBAAiB,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,IAAI,CAC7B,CAAC;QACpB,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;AACjC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rjsf/utils",
|
|
3
|
-
"version": "6.0.0-beta.
|
|
3
|
+
"version": "6.0.0-beta.21",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -9,27 +9,27 @@
|
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
11
|
"types": "./lib/index.d.ts",
|
|
12
|
-
"require": "./dist/index.
|
|
12
|
+
"require": "./dist/index.cjs",
|
|
13
13
|
"import": "./lib/index.js"
|
|
14
14
|
},
|
|
15
15
|
"./lib": {
|
|
16
16
|
"types": "./lib/index.d.ts",
|
|
17
|
-
"require": "./dist/index.
|
|
17
|
+
"require": "./dist/index.cjs",
|
|
18
18
|
"import": "./lib/index.js"
|
|
19
19
|
},
|
|
20
20
|
"./lib/*.js": {
|
|
21
21
|
"types": "./lib/*.d.ts",
|
|
22
|
-
"require": "./dist/*.
|
|
22
|
+
"require": "./dist/*.cjs",
|
|
23
23
|
"import": "./lib/*.js"
|
|
24
24
|
},
|
|
25
25
|
"./dist": {
|
|
26
26
|
"types": "./lib/index.d.ts",
|
|
27
|
-
"require": "./dist/index.
|
|
27
|
+
"require": "./dist/index.cjs",
|
|
28
28
|
"import": "./lib/index.js"
|
|
29
29
|
},
|
|
30
|
-
"./dist/*.
|
|
30
|
+
"./dist/*.cjs": {
|
|
31
31
|
"types": "./lib/*.d.ts",
|
|
32
|
-
"require": "./dist/*.
|
|
32
|
+
"require": "./dist/*.cjs",
|
|
33
33
|
"import": "./lib/*.js"
|
|
34
34
|
}
|
|
35
35
|
},
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"scripts": {
|
|
46
46
|
"compileReplacer": "tsc -p tsconfig.replacer.json && move-file lodashReplacer.js lodashReplacer.cjs",
|
|
47
47
|
"build:ts": "npm run compileReplacer && rimraf ./lib && tsc -b tsconfig.build.json && tsc-alias -p tsconfig.build.json",
|
|
48
|
-
"build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.
|
|
48
|
+
"build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.cjs --sourcemap --packages=external --format=cjs",
|
|
49
49
|
"build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/utils.esm.js --sourcemap --packages=external --format=esm",
|
|
50
50
|
"build:umd": "rollup dist/utils.esm.js --format=umd --file=dist/utils.umd.js --name=@rjsf/utils",
|
|
51
51
|
"build": "npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd",
|
|
@@ -65,20 +65,19 @@
|
|
|
65
65
|
"react": ">=18"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"fast-uri": "^3.0
|
|
68
|
+
"fast-uri": "^3.1.0",
|
|
69
69
|
"json-schema-merge-allof": "^0.8.1",
|
|
70
70
|
"jsonpointer": "^5.0.1",
|
|
71
71
|
"lodash": "^4.17.21",
|
|
72
72
|
"lodash-es": "^4.17.21",
|
|
73
|
-
"
|
|
74
|
-
"react-is": "^18.2.0"
|
|
73
|
+
"react-is": "^18.3.1"
|
|
75
74
|
},
|
|
76
75
|
"devDependencies": {
|
|
77
76
|
"@types/json-schema": "^7.0.15",
|
|
78
77
|
"@types/json-schema-merge-allof": "^0.6.5",
|
|
79
|
-
"@types/react-is": "^18.
|
|
80
|
-
"deep-freeze-es6": "^
|
|
81
|
-
"eslint": "^8.
|
|
78
|
+
"@types/react-is": "^18.3.1",
|
|
79
|
+
"deep-freeze-es6": "^4.0.1",
|
|
80
|
+
"eslint": "^8.57.1"
|
|
82
81
|
},
|
|
83
82
|
"publishConfig": {
|
|
84
83
|
"access": "public"
|
|
@@ -3,13 +3,13 @@ import get from 'lodash/get';
|
|
|
3
3
|
import set from 'lodash/set';
|
|
4
4
|
import setWith from 'lodash/setWith';
|
|
5
5
|
|
|
6
|
-
import { ErrorSchema } from './types';
|
|
6
|
+
import { ErrorSchema, FieldPathList } from './types';
|
|
7
7
|
import { ERRORS_KEY } from './constants';
|
|
8
8
|
|
|
9
9
|
/** Represents the type of the path which can be a string of dotted path values or a list of string or numbers where
|
|
10
10
|
* numbers represent array indexes/
|
|
11
11
|
*/
|
|
12
|
-
export type PathType = string |
|
|
12
|
+
export type PathType = string | FieldPathList;
|
|
13
13
|
|
|
14
14
|
/** The `ErrorSchemaBuilder<T>` is used to build an `ErrorSchema<T>` since the definition of the `ErrorSchema` type is
|
|
15
15
|
* designed for reading information rather than writing it. Use this class to add, replace or clear errors in an error
|
package/src/constants.ts
CHANGED
|
@@ -26,6 +26,8 @@ export const REQUIRED_KEY = 'required';
|
|
|
26
26
|
export const SUBMIT_BTN_OPTIONS_KEY = 'submitButtonOptions';
|
|
27
27
|
export const REF_KEY = '$ref';
|
|
28
28
|
export const SCHEMA_KEY = '$schema';
|
|
29
|
+
export const DEFAULT_ID_PREFIX = 'root';
|
|
30
|
+
export const DEFAULT_ID_SEPARATOR = '_';
|
|
29
31
|
/** The path of the discriminator value returned by the schema endpoint.
|
|
30
32
|
* The discriminator is the value in a `oneOf` that determines which option is selected.
|
|
31
33
|
*/
|
|
@@ -46,4 +48,5 @@ export const UI_GLOBAL_OPTIONS_KEY = 'ui:globalOptions';
|
|
|
46
48
|
|
|
47
49
|
/** The JSON Schema version strings
|
|
48
50
|
*/
|
|
51
|
+
export const JSON_SCHEMA_DRAFT_2019_09 = 'https://json-schema.org/draft/2019-09/schema';
|
|
49
52
|
export const JSON_SCHEMA_DRAFT_2020_12 = 'https://json-schema.org/draft/2020-12/schema';
|