@rjsf/utils 5.0.0-beta.16 → 5.0.0-beta.17

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.d.ts CHANGED
@@ -1,23 +1,23 @@
1
- import React from 'react';
1
+ import React, { StyleHTMLAttributes } from 'react';
2
2
  import * as json_schema from 'json-schema';
3
3
  import { JSONSchema7 } from 'json-schema';
4
4
 
5
5
  /** The representation of any generic object type, usually used as an intersection on other types to make them more
6
6
  * flexible in the properties they support (i.e. anything else)
7
7
  */
8
- declare type GenericObjectType = {
8
+ type GenericObjectType = {
9
9
  [name: string]: any;
10
10
  };
11
11
  /** Map the JSONSchema7 to our own type so that we can easily bump to a more recent version at some future date and only
12
12
  * have to update this one type.
13
13
  */
14
- declare type StrictRJSFSchema = JSONSchema7;
14
+ type StrictRJSFSchema = JSONSchema7;
15
15
  /** Allow for more flexible schemas (i.e. draft-2019) than the strict JSONSchema7
16
16
  */
17
- declare type RJSFSchema = StrictRJSFSchema & GenericObjectType;
17
+ type RJSFSchema = StrictRJSFSchema & GenericObjectType;
18
18
  /** Alias GenericObjectType as FormContextType to allow us to remap this at some future date
19
19
  */
20
- declare type FormContextType = GenericObjectType;
20
+ type FormContextType = GenericObjectType;
21
21
  /** The interface representing a Date object that contains an optional time */
22
22
  interface DateObject {
23
23
  /** The year of the Date */
@@ -34,7 +34,7 @@ interface DateObject {
34
34
  second?: number;
35
35
  }
36
36
  /** Properties describing a Range specification in terms of attribute that can be added to the `HTML` `<input>` */
37
- declare type RangeSpecType = {
37
+ type RangeSpecType = {
38
38
  /** Specifies the interval between legal numbers in an input field */
39
39
  step?: number;
40
40
  /** Specifies a minimum value for an <input> element */
@@ -43,7 +43,7 @@ declare type RangeSpecType = {
43
43
  max?: number;
44
44
  };
45
45
  /** Properties describing a Range specification in terms of attribute that can be added to the `HTML` `<input>` */
46
- declare type InputPropsType = Omit<RangeSpecType, "step"> & {
46
+ type InputPropsType = Omit<RangeSpecType, "step"> & {
47
47
  /** Specifies the type of the <input> element */
48
48
  type: string;
49
49
  /** Specifies the interval between legal numbers in an input field or "any" */
@@ -52,25 +52,25 @@ declare type InputPropsType = Omit<RangeSpecType, "step"> & {
52
52
  autoComplete?: HTMLInputElement["autocomplete"];
53
53
  };
54
54
  /** Type describing an id used for a field in the `IdSchema` */
55
- declare type FieldId = {
55
+ type FieldId = {
56
56
  /** The id for a field */
57
57
  $id: string;
58
58
  };
59
59
  /** Type describing a recursive structure of `FieldId`s for an object with a non-empty set of keys */
60
- declare type IdSchema<T = any> = FieldId & {
60
+ type IdSchema<T = any> = FieldId & {
61
61
  [key in keyof T]?: IdSchema<T[key]>;
62
62
  };
63
63
  /** Type describing a name used for a field in the `PathSchema` */
64
- declare type FieldPath = {
64
+ type FieldPath = {
65
65
  /** The name of a field */
66
66
  $name: string;
67
67
  };
68
68
  /** Type describing a recursive structure of `FieldPath`s for an object with a non-empty set of keys */
69
- declare type PathSchema<T = any> = FieldPath & {
69
+ type PathSchema<T = any> = FieldPath & {
70
70
  [key in keyof T]?: PathSchema<T[key]>;
71
71
  };
72
72
  /** The type for error produced by RJSF schema validation */
73
- declare type RJSFValidationError = {
73
+ type RJSFValidationError = {
74
74
  /** Name of the error, for example, "required" or "minLength" */
75
75
  name?: string;
76
76
  /** Message, for example, "is a required property" or "should NOT be shorter than 3 characters" */
@@ -92,27 +92,27 @@ declare type RJSFValidationError = {
92
92
  stack: string;
93
93
  };
94
94
  /** The type that describes an error in a field */
95
- declare type FieldError = string;
95
+ type FieldError = string;
96
96
  /** The type that describes the list of errors for a field */
97
- declare type FieldErrors = {
97
+ type FieldErrors = {
98
98
  /** The list of errors for the field */
99
99
  __errors?: FieldError[];
100
100
  };
101
101
  /** Type describing a recursive structure of `FieldErrors`s for an object with a non-empty set of keys */
102
- declare type ErrorSchema<T = any> = FieldErrors & {
102
+ type ErrorSchema<T = any> = FieldErrors & {
103
103
  [key in keyof T]?: ErrorSchema<T[key]>;
104
104
  };
105
105
  /** Type that describes the list of errors for a field being actively validated by a custom validator */
106
- declare type FieldValidation = FieldErrors & {
106
+ type FieldValidation = FieldErrors & {
107
107
  /** Function that will add a new `message` to the list of errors */
108
108
  addError: (message: string) => void;
109
109
  };
110
110
  /** Type describing a recursive structure of `FieldValidation`s for an object with a non-empty set of keys */
111
- declare type FormValidation<T = any> = FieldValidation & {
111
+ type FormValidation<T = any> = FieldValidation & {
112
112
  [key in keyof T]?: FormValidation<T[key]>;
113
113
  };
114
114
  /** The properties that are passed to an `ErrorListTemplate` implementation */
115
- declare type ErrorListProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
115
+ type ErrorListProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
116
116
  /** The errorSchema constructed by `Form` */
117
117
  errorSchema: ErrorSchema<T>;
118
118
  /** An array of the errors */
@@ -125,7 +125,7 @@ declare type ErrorListProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F
125
125
  uiSchema?: UiSchema<T, S, F>;
126
126
  };
127
127
  /** The properties that are passed to an `FieldErrorTemplate` implementation */
128
- declare type FieldErrorProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
128
+ type FieldErrorProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
129
129
  /** The errorSchema constructed by `Form` */
130
130
  errorSchema?: ErrorSchema<T>;
131
131
  /** An array of the errors */
@@ -140,7 +140,7 @@ declare type FieldErrorProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F
140
140
  registry: Registry<T, S, F>;
141
141
  };
142
142
  /** The properties that are passed to an `FieldHelpTemplate` implementation */
143
- declare type FieldHelpProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
143
+ type FieldHelpProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
144
144
  /** The help information to be rendered */
145
145
  help?: string | React.ReactElement;
146
146
  /** The tree of unique ids for every child field */
@@ -155,12 +155,12 @@ declare type FieldHelpProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F
155
155
  registry: Registry<T, S, F>;
156
156
  };
157
157
  /** The set of `Fields` stored in the `Registry` */
158
- declare type RegistryFieldsType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
158
+ type RegistryFieldsType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
159
159
  /** A `Field` indexed by `name` */
160
160
  [name: string]: Field<T, S, F>;
161
161
  };
162
162
  /** The set of `Widgets` stored in the `Registry` */
163
- declare type RegistryWidgetsType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
163
+ type RegistryWidgetsType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
164
164
  /** A `Widget` indexed by `name` */
165
165
  [name: string]: Widget<T, S, F>;
166
166
  };
@@ -269,13 +269,15 @@ interface FieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
269
269
  registry: Registry<T, S, F>;
270
270
  }
271
271
  /** The definition of a React-based Field component */
272
- declare type Field<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = React.ComponentType<FieldProps<T, S, F>>;
272
+ type Field<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = React.ComponentType<FieldProps<T, S, F>>;
273
273
  /** The properties that are passed to a FieldTemplate implementation */
274
- declare type FieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
274
+ type FieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
275
275
  /** The id of the field in the hierarchy. You can use it to render a label targeting the wrapped widget */
276
276
  id: string;
277
277
  /** A string containing the base CSS classes, merged with any custom ones defined in your uiSchema */
278
278
  classNames?: string;
279
+ /** An object containing the style as defined in the `uiSchema` */
280
+ style?: StyleHTMLAttributes<any>;
279
281
  /** The computed label for this field, as a string */
280
282
  label: string;
281
283
  /** A component instance rendering the field description, if one is defined (this will use any custom
@@ -328,7 +330,7 @@ declare type FieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema
328
330
  registry: Registry<T, S, F>;
329
331
  };
330
332
  /** The properties that are passed to the `UnsupportedFieldTemplate` implementation */
331
- declare type UnsupportedFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
333
+ type UnsupportedFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
332
334
  /** The schema object for this field */
333
335
  schema: S;
334
336
  /** The tree of unique ids for every child field */
@@ -339,7 +341,7 @@ declare type UnsupportedFieldProps<T = any, S extends StrictRJSFSchema = RJSFSch
339
341
  registry: Registry<T, S, F>;
340
342
  };
341
343
  /** The properties that are passed to a `TitleFieldTemplate` implementation */
342
- declare type TitleFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
344
+ type TitleFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
343
345
  /** The id of the field title in the hierarchy */
344
346
  id: string;
345
347
  /** The title for the field being rendered */
@@ -354,7 +356,7 @@ declare type TitleFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F
354
356
  registry: Registry<T, S, F>;
355
357
  };
356
358
  /** The properties that are passed to a `DescriptionFieldTemplate` implementation */
357
- declare type DescriptionFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
359
+ type DescriptionFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
358
360
  /** The id of the field description in the hierarchy */
359
361
  id: string;
360
362
  /** The schema object for the field being described */
@@ -367,21 +369,21 @@ declare type DescriptionFieldProps<T = any, S extends StrictRJSFSchema = RJSFSch
367
369
  registry: Registry<T, S, F>;
368
370
  };
369
371
  /** The properties that are passed to a `ArrayFieldTitleTemplate` implementation */
370
- declare type ArrayFieldTitleProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Omit<TitleFieldProps<T, S, F>, "id" | "title"> & {
372
+ type ArrayFieldTitleProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Omit<TitleFieldProps<T, S, F>, "id" | "title"> & {
371
373
  /** The title for the field being rendered */
372
374
  title?: string;
373
375
  /** The idSchema of the field in the hierarchy */
374
376
  idSchema: IdSchema<T>;
375
377
  };
376
378
  /** The properties that are passed to a `ArrayFieldDescriptionTemplate` implementation */
377
- declare type ArrayFieldDescriptionProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Omit<DescriptionFieldProps<T, S, F>, "id" | "description"> & {
379
+ type ArrayFieldDescriptionProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Omit<DescriptionFieldProps<T, S, F>, "id" | "description"> & {
378
380
  /** The description of the field being rendered */
379
381
  description?: string | React.ReactElement;
380
382
  /** The idSchema of the field in the hierarchy */
381
383
  idSchema: IdSchema<T>;
382
384
  };
383
385
  /** The properties of each element in the ArrayFieldTemplateProps.items array */
384
- declare type ArrayFieldTemplateItemType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
386
+ type ArrayFieldTemplateItemType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
385
387
  /** The html for the item's content */
386
388
  children: React.ReactElement;
387
389
  /** The className string */
@@ -420,7 +422,7 @@ declare type ArrayFieldTemplateItemType<T = any, S extends StrictRJSFSchema = RJ
420
422
  registry: Registry<T, S, F>;
421
423
  };
422
424
  /** The properties that are passed to an ArrayFieldTemplate implementation */
423
- declare type ArrayFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
425
+ type ArrayFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
424
426
  /** A boolean value stating whether new elements can be added to the array */
425
427
  canAdd?: boolean;
426
428
  /** The className string */
@@ -455,7 +457,7 @@ declare type ArrayFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFS
455
457
  registry: Registry<T, S, F>;
456
458
  };
457
459
  /** The properties of each element in the ObjectFieldTemplateProps.properties array */
458
- declare type ObjectFieldTemplatePropertyType = {
460
+ type ObjectFieldTemplatePropertyType = {
459
461
  /** The html for the property's content */
460
462
  content: React.ReactElement;
461
463
  /** A string representing the property name */
@@ -468,7 +470,7 @@ declare type ObjectFieldTemplatePropertyType = {
468
470
  hidden: boolean;
469
471
  };
470
472
  /** The properties that are passed to an ObjectFieldTemplate implementation */
471
- declare type ObjectFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
473
+ type ObjectFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
472
474
  /** A string value containing the title for the object */
473
475
  title: string;
474
476
  /** A string value containing the description for the object */
@@ -499,10 +501,10 @@ declare type ObjectFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSF
499
501
  registry: Registry<T, S, F>;
500
502
  };
501
503
  /** The properties that are passed to a WrapIfAdditionalTemplate implementation */
502
- declare type WrapIfAdditionalTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
504
+ type WrapIfAdditionalTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
503
505
  /** The field or widget component instance for this field row */
504
506
  children: React.ReactNode;
505
- } & Pick<FieldTemplateProps<T, S, F>, "id" | "classNames" | "label" | "required" | "readonly" | "disabled" | "schema" | "uiSchema" | "onKeyChange" | "onDropPropertyClick" | "registry">;
507
+ } & Pick<FieldTemplateProps<T, S, F>, "id" | "classNames" | "style" | "label" | "required" | "readonly" | "disabled" | "schema" | "uiSchema" | "onKeyChange" | "onDropPropertyClick" | "registry">;
506
508
  /** The properties that are passed to a Widget implementation */
507
509
  interface WidgetProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> extends GenericObjectType, Pick<React.HTMLAttributes<HTMLElement>, Exclude<keyof React.HTMLAttributes<HTMLElement>, "onBlur" | "onFocus">> {
508
510
  /** The generated id for this widget */
@@ -550,16 +552,16 @@ interface WidgetProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extend
550
552
  registry: Registry<T, S, F>;
551
553
  }
552
554
  /** The definition of a React-based Widget component */
553
- declare type Widget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = React.ComponentType<WidgetProps<T, S, F>>;
555
+ type Widget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = React.ComponentType<WidgetProps<T, S, F>>;
554
556
  /** The type that defines the props used by the Submit button */
555
- declare type SubmitButtonProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
557
+ type SubmitButtonProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
556
558
  /** The uiSchema for this widget */
557
559
  uiSchema?: UiSchema<T, S, F>;
558
560
  /** The `registry` object */
559
561
  registry: Registry<T, S, F>;
560
562
  };
561
563
  /** The type that defines the props for an Icon button, extending from a basic HTML button attributes */
562
- declare type IconButtonProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = React.ButtonHTMLAttributes<HTMLButtonElement> & {
564
+ type IconButtonProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = React.ButtonHTMLAttributes<HTMLButtonElement> & {
563
565
  /** An alternative specification for the type of the icon button */
564
566
  iconType?: string;
565
567
  /** The name representation or actual react element implementation for the icon */
@@ -570,7 +572,7 @@ declare type IconButtonProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F
570
572
  registry: Registry<T, S, F>;
571
573
  };
572
574
  /** The type that defines how to change the behavior of the submit button for the form */
573
- declare type UISchemaSubmitButtonOptions = {
575
+ type UISchemaSubmitButtonOptions = {
574
576
  /** The text of the submit button. Set to "Submit" by default */
575
577
  submitText?: string;
576
578
  /** Flag, if `true`, removes the submit button completely from the form */
@@ -584,7 +586,7 @@ declare type UISchemaSubmitButtonOptions = {
584
586
  };
585
587
  };
586
588
  /** This type represents an element used to render an enum option */
587
- declare type EnumOptionsType<S extends StrictRJSFSchema = RJSFSchema> = {
589
+ type EnumOptionsType<S extends StrictRJSFSchema = RJSFSchema> = {
588
590
  /** The value for the enum option */
589
591
  value: any;
590
592
  /** The label for the enum options */
@@ -593,15 +595,17 @@ declare type EnumOptionsType<S extends StrictRJSFSchema = RJSFSchema> = {
593
595
  schema?: S;
594
596
  };
595
597
  /** This type remaps the keys of `Type` to prepend `ui:` onto them. As a result it does not need to be exported */
596
- declare type MakeUIType<Type> = {
598
+ type MakeUIType<Type> = {
597
599
  [Property in keyof Type as `ui:${string & Property}`]: Type[Property];
598
600
  };
599
601
  /** This type represents all the known supported options in the `ui:options` property, kept separate in order to
600
602
  * remap the keys. It also contains all the properties, optionally, of `TemplatesType` except "ButtonTemplates"
601
603
  */
602
- declare type UIOptionsBaseType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Partial<Omit<TemplatesType<T, S, F>, "ButtonTemplates">> & {
604
+ type UIOptionsBaseType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Partial<Omit<TemplatesType<T, S, F>, "ButtonTemplates">> & {
603
605
  /** Any classnames that the user wants to be applied to a field in the ui */
604
606
  classNames?: string;
607
+ /** Any custom style that the user wants to apply to a field in the ui, applied on the same element as classNames */
608
+ style?: StyleHTMLAttributes<any>;
605
609
  /** We know that for title, it will be a string, if it is provided */
606
610
  title?: string;
607
611
  /** We know that for description, it will be a string, if it is provided */
@@ -654,14 +658,14 @@ declare type UIOptionsBaseType<T = any, S extends StrictRJSFSchema = RJSFSchema,
654
658
  duplicateKeySuffixSeparator?: string;
655
659
  };
656
660
  /** The type that represents the Options potentially provided by `ui:options` */
657
- declare type UIOptionsType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = UIOptionsBaseType<T, S, F> & {
661
+ type UIOptionsType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = UIOptionsBaseType<T, S, F> & {
658
662
  /** Anything else will be one of these types */
659
663
  [key: string]: boolean | number | string | object | any[] | null | undefined;
660
664
  };
661
665
  /** Type describing the well-known properties of the `UiSchema` while also supporting all user defined properties,
662
666
  * starting with `ui:`.
663
667
  */
664
- declare type UiSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = GenericObjectType & MakeUIType<UIOptionsBaseType<T, S, F>> & {
668
+ type UiSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = GenericObjectType & MakeUIType<UIOptionsBaseType<T, S, F>> & {
665
669
  /** Allows the form to generate a unique prefix for the `Form`'s root prefix */
666
670
  "ui:rootFieldId"?: string;
667
671
  /** Allows RJSF to override the default field implementation by specifying either the name of a field that is used
@@ -674,13 +678,13 @@ declare type UiSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extend
674
678
  /** A `CustomValidator` function takes in a `formData`, `errors` and `uiSchema` objects and returns the given `errors`
675
679
  * object back, while potentially adding additional messages to the `errors`
676
680
  */
677
- declare type CustomValidator<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = (formData: T, errors: FormValidation<T>, uiSchema?: UiSchema<T, S, F>) => FormValidation<T>;
681
+ type CustomValidator<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = (formData: T, errors: FormValidation<T>, uiSchema?: UiSchema<T, S, F>) => FormValidation<T>;
678
682
  /** An `ErrorTransformer` function will take in a list of `errors` & a `uiSchema` and potentially return a
679
683
  * transformation of those errors in what ever way it deems necessary
680
684
  */
681
- declare type ErrorTransformer<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = (errors: RJSFValidationError[], uiSchema?: UiSchema<T, S, F>) => RJSFValidationError[];
685
+ type ErrorTransformer<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = (errors: RJSFValidationError[], uiSchema?: UiSchema<T, S, F>) => RJSFValidationError[];
682
686
  /** The type that describes the data that is returned from the `ValidatorType.validateFormData()` function */
683
- declare type ValidationData<T> = {
687
+ type ValidationData<T> = {
684
688
  /** The validation errors as a list of `RJSFValidationError` objects */
685
689
  errors: RJSFValidationError[];
686
690
  /** The validation errors in the form of an `ErrorSchema` */
@@ -891,6 +895,23 @@ declare function dataURItoBlob(dataURI: string): {
891
895
  */
892
896
  declare function deepEquals(a: any, b: any): boolean;
893
897
 
898
+ /** Removes the `value` from the currently `selected` list of values
899
+ *
900
+ * @param value - The value to be removed from the selected list
901
+ * @param selected - The current list of selected values
902
+ * @returns - The updated `selected` list with the `value` removed from it
903
+ */
904
+ declare function enumOptionsDeselectValue<S extends StrictRJSFSchema = RJSFSchema>(value: EnumOptionsType<S>["value"], selected: EnumOptionsType<S>["value"][]): any[];
905
+
906
+ /** Add the `value` to the list of `selected` values in the proper order as defined by `allEnumOptions`
907
+ *
908
+ * @param value - The value that should be selected
909
+ * @param selected - The current list of selected values
910
+ * @param allEnumOptions - The list of all the known enumOptions
911
+ * @returns - The updated list of selected enum values with `value` added to it in the proper location
912
+ */
913
+ declare function enumOptionsSelectValue<S extends StrictRJSFSchema = RJSFSchema>(value: EnumOptionsType<S>["value"], selected: EnumOptionsType<S>["value"][], allEnumOptions?: EnumOptionsType<S>[]): any[];
914
+
894
915
  /** The `ErrorSchemaBuilder<T>` is used to build an `ErrorSchema<T>` since the definition of the `ErrorSchema` type is
895
916
  * designed for reading information rather than writing it. Use this class to add, replace or clear errors in an error
896
917
  * schema by using either dotted path or an array of path names. Once you are done building the `ErrorSchema`, you can
@@ -1041,6 +1062,53 @@ declare function guessType(value: any): "array" | "string" | "null" | "boolean"
1041
1062
  */
1042
1063
  declare function hasWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(schema: RJSFSchema, widget: Widget<T, S, F> | string, registeredWidgets?: RegistryWidgetsType<T, S, F>): boolean;
1043
1064
 
1065
+ /** Return a consistent `id` for the field description element
1066
+ *
1067
+ * @param id - Either simple string id or an IdSchema from which to extract it
1068
+ * @returns - The consistent id for the field description element from the given `id`
1069
+ */
1070
+ declare function descriptionId<T = any>(id: IdSchema<T> | string): string;
1071
+ /** Return a consistent `id` for the field error element
1072
+ *
1073
+ * @param id - Either simple string id or an IdSchema from which to extract it
1074
+ * @returns - The consistent id for the field error element from the given `id`
1075
+ */
1076
+ declare function errorId<T = any>(id: IdSchema<T> | string): string;
1077
+ /** Return a consistent `id` for the field examples element
1078
+ *
1079
+ * @param id - Either simple string id or an IdSchema from which to extract it
1080
+ * @returns - The consistent id for the field examples element from the given `id`
1081
+ */
1082
+ declare function examplesId<T = any>(id: IdSchema<T> | string): string;
1083
+ /** Return a consistent `id` for the field help element
1084
+ *
1085
+ * @param id - Either simple string id or an IdSchema from which to extract it
1086
+ * @returns - The consistent id for the field help element from the given `id`
1087
+ */
1088
+ declare function helpId<T = any>(id: IdSchema<T> | string): string;
1089
+ /** Return a consistent `id` for the field title element
1090
+ *
1091
+ * @param id - Either simple string id or an IdSchema from which to extract it
1092
+ * @returns - The consistent id for the field title element from the given `id`
1093
+ */
1094
+ declare function titleId<T = any>(id: IdSchema<T> | string): string;
1095
+ /** Return a list of element ids that contain additional information about the field that can be used to as the aria
1096
+ * description of the field. This is correctly omitting `titleId` which would be "labeling" rather than "describing" the
1097
+ * element.
1098
+ *
1099
+ * @param id - Either simple string id or an IdSchema from which to extract it
1100
+ * @param [includeExamples=false] - Optional flag, if true, will add the `examplesId` into the list
1101
+ * @returns - The string containing the list of ids for use in an `aria-describedBy` attribute
1102
+ */
1103
+ declare function ariaDescribedByIds<T = any>(id: IdSchema<T> | string, includeExamples?: boolean): string;
1104
+ /** Return a consistent `id` for the `option`s of a `Radio` or `Checkboxes` widget
1105
+ *
1106
+ * @param id - The id of the parent component for the option
1107
+ * @param option - The option for which the id is desired
1108
+ * @returns - An id for the option based on the parent `id`
1109
+ */
1110
+ declare function optionId<S extends StrictRJSFSchema = RJSFSchema>(id: string, option: EnumOptionsType<S>): string;
1111
+
1044
1112
  /** This function checks if the given `schema` matches a single constant value. This happens when either the schema has
1045
1113
  * an `enum` array with a single value or there is a `const` defined.
1046
1114
  *
@@ -1359,4 +1427,4 @@ declare function toIdSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F
1359
1427
  */
1360
1428
  declare function toPathSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, schema: S, name?: string, rootSchema?: S, formData?: T): PathSchema<T>;
1361
1429
 
1362
- export { ADDITIONAL_PROPERTIES_KEY, ADDITIONAL_PROPERTY_FLAG, ALL_OF_KEY, ANY_OF_KEY, ArrayFieldDescriptionProps, ArrayFieldTemplateItemType, ArrayFieldTemplateProps, ArrayFieldTitleProps, CONST_KEY, CustomValidator, DEFAULT_KEY, DEFINITIONS_KEY, DEPENDENCIES_KEY, DateObject, DescriptionFieldProps, ENUM_KEY, ERRORS_KEY, EnumOptionsType, ErrorListProps, ErrorSchema, ErrorSchemaBuilder, ErrorTransformer, Field, FieldError, FieldErrorProps, FieldErrors, FieldHelpProps, FieldId, FieldPath, FieldProps, FieldTemplateProps, FieldValidation, FormContextType, FormValidation, GenericObjectType, ID_KEY, ITEMS_KEY, IconButtonProps, IdSchema, InputPropsType, NAME_KEY, ONE_OF_KEY, ObjectFieldTemplatePropertyType, ObjectFieldTemplateProps, PROPERTIES_KEY, PathSchema, REF_KEY, REQUIRED_KEY, RJSFSchema, RJSFValidationError, RJSF_ADDITONAL_PROPERTIES_FLAG, RangeSpecType, Registry, RegistryFieldsType, RegistryWidgetsType, SUBMIT_BTN_OPTIONS_KEY, SchemaUtilsType, StrictRJSFSchema, SubmitButtonProps, TemplatesType, TitleFieldProps, UIOptionsType, UISchemaSubmitButtonOptions, UI_FIELD_KEY, UI_OPTIONS_KEY, UI_WIDGET_KEY, UiSchema, UnsupportedFieldProps, ValidationData, ValidatorType, Widget, WidgetProps, WrapIfAdditionalTemplateProps, allowAdditionalItems, asNumber, canExpand, createSchemaUtils, dataURItoBlob, deepEquals, findSchemaDefinition, getDefaultFormState, getDisplayLabel, getInputProps, getMatchingOption, getSchemaType, getSubmitButtonOptions, getTemplate, getUiOptions, getWidget, guessType, hasWidget, isConstant, isCustomWidget, isFilesArray, isFixedItems, isMultiSelect, isObject, isSelect, localToUTC, mergeDefaultsWithFormData, mergeObjects, mergeSchemas, mergeValidationData, optionsList, orderProperties, pad, parseDateString, processSelectValue, rangeSpec, retrieveSchema, schemaRequiresTrueValue, shouldRender, toConstant, toDateString, toIdSchema, toPathSchema, utcToLocal };
1430
+ export { ADDITIONAL_PROPERTIES_KEY, ADDITIONAL_PROPERTY_FLAG, ALL_OF_KEY, ANY_OF_KEY, ArrayFieldDescriptionProps, ArrayFieldTemplateItemType, ArrayFieldTemplateProps, ArrayFieldTitleProps, CONST_KEY, CustomValidator, DEFAULT_KEY, DEFINITIONS_KEY, DEPENDENCIES_KEY, DateObject, DescriptionFieldProps, ENUM_KEY, ERRORS_KEY, EnumOptionsType, ErrorListProps, ErrorSchema, ErrorSchemaBuilder, ErrorTransformer, Field, FieldError, FieldErrorProps, FieldErrors, FieldHelpProps, FieldId, FieldPath, FieldProps, FieldTemplateProps, FieldValidation, FormContextType, FormValidation, GenericObjectType, ID_KEY, ITEMS_KEY, IconButtonProps, IdSchema, InputPropsType, NAME_KEY, ONE_OF_KEY, ObjectFieldTemplatePropertyType, ObjectFieldTemplateProps, PROPERTIES_KEY, PathSchema, REF_KEY, REQUIRED_KEY, RJSFSchema, RJSFValidationError, RJSF_ADDITONAL_PROPERTIES_FLAG, RangeSpecType, Registry, RegistryFieldsType, RegistryWidgetsType, SUBMIT_BTN_OPTIONS_KEY, SchemaUtilsType, StrictRJSFSchema, SubmitButtonProps, TemplatesType, TitleFieldProps, UIOptionsType, UISchemaSubmitButtonOptions, UI_FIELD_KEY, UI_OPTIONS_KEY, UI_WIDGET_KEY, UiSchema, UnsupportedFieldProps, ValidationData, ValidatorType, Widget, WidgetProps, WrapIfAdditionalTemplateProps, allowAdditionalItems, ariaDescribedByIds, asNumber, canExpand, createSchemaUtils, dataURItoBlob, deepEquals, descriptionId, enumOptionsDeselectValue, enumOptionsSelectValue, errorId, examplesId, findSchemaDefinition, getDefaultFormState, getDisplayLabel, getInputProps, getMatchingOption, getSchemaType, getSubmitButtonOptions, getTemplate, getUiOptions, getWidget, guessType, hasWidget, helpId, isConstant, isCustomWidget, isFilesArray, isFixedItems, isMultiSelect, isObject, isSelect, localToUTC, mergeDefaultsWithFormData, mergeObjects, mergeSchemas, mergeValidationData, optionId, optionsList, orderProperties, pad, parseDateString, processSelectValue, rangeSpec, retrieveSchema, schemaRequiresTrueValue, shouldRender, titleId, toConstant, toDateString, toIdSchema, toPathSchema, utcToLocal };
@@ -13,6 +13,7 @@ var union = require('lodash/union');
13
13
  var cloneDeep = require('lodash/cloneDeep');
14
14
  var React = require('react');
15
15
  var ReactIs = require('react-is');
16
+ var isString = require('lodash/isString');
16
17
 
17
18
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
18
19
 
@@ -27,6 +28,7 @@ var union__default = /*#__PURE__*/_interopDefaultLegacy(union);
27
28
  var cloneDeep__default = /*#__PURE__*/_interopDefaultLegacy(cloneDeep);
28
29
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
29
30
  var ReactIs__default = /*#__PURE__*/_interopDefaultLegacy(ReactIs);
31
+ var isString__default = /*#__PURE__*/_interopDefaultLegacy(isString);
30
32
 
31
33
  /** Determines whether a `thing` is an object for the purposes of RSJF. In this case, `thing` is an object if it has
32
34
  * the type `object` but is NOT null, an array or a File.
@@ -99,7 +101,7 @@ function _defineProperties(target, props) {
99
101
  descriptor.enumerable = descriptor.enumerable || false;
100
102
  descriptor.configurable = true;
101
103
  if ("value" in descriptor) descriptor.writable = true;
102
- Object.defineProperty(target, descriptor.key, descriptor);
104
+ Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
103
105
  }
104
106
  }
105
107
  function _createClass(Constructor, protoProps, staticProps) {
@@ -139,6 +141,20 @@ function _objectWithoutPropertiesLoose(source, excluded) {
139
141
  }
140
142
  return target;
141
143
  }
144
+ function _toPrimitive(input, hint) {
145
+ if (typeof input !== "object" || input === null) return input;
146
+ var prim = input[Symbol.toPrimitive];
147
+ if (prim !== undefined) {
148
+ var res = prim.call(input, hint || "default");
149
+ if (typeof res !== "object") return res;
150
+ throw new TypeError("@@toPrimitive must return a primitive value.");
151
+ }
152
+ return (hint === "string" ? String : Number)(input);
153
+ }
154
+ function _toPropertyKey(arg) {
155
+ var key = _toPrimitive(arg, "string");
156
+ return typeof key === "symbol" ? key : String(key);
157
+ }
142
158
 
143
159
  /** Below are the list of all the keys into various elements of a RJSFSchema or UiSchema that are used by the various
144
160
  * utility functions. In addition to those keys, there are the special `ADDITIONAL_PROPERTY_FLAG` and
@@ -1428,6 +1444,43 @@ function dataURItoBlob(dataURI) {
1428
1444
  };
1429
1445
  }
1430
1446
 
1447
+ /** Removes the `value` from the currently `selected` list of values
1448
+ *
1449
+ * @param value - The value to be removed from the selected list
1450
+ * @param selected - The current list of selected values
1451
+ * @returns - The updated `selected` list with the `value` removed from it
1452
+ */
1453
+ function enumOptionsDeselectValue(value, selected) {
1454
+ return selected.filter(function (v) {
1455
+ return v !== value;
1456
+ });
1457
+ }
1458
+
1459
+ /** Add the `value` to the list of `selected` values in the proper order as defined by `allEnumOptions`
1460
+ *
1461
+ * @param value - The value that should be selected
1462
+ * @param selected - The current list of selected values
1463
+ * @param allEnumOptions - The list of all the known enumOptions
1464
+ * @returns - The updated list of selected enum values with `value` added to it in the proper location
1465
+ */
1466
+ function enumOptionsSelectValue(value, selected, allEnumOptions) {
1467
+ if (allEnumOptions === void 0) {
1468
+ allEnumOptions = [];
1469
+ }
1470
+ var all = allEnumOptions.map(function (_ref) {
1471
+ var value = _ref.value;
1472
+ return value;
1473
+ });
1474
+ var at = all.indexOf(value);
1475
+ // If location of the value is not in the list of all enum values, just put it at the end
1476
+ var updated = at === -1 ? selected.concat(value) : selected.slice(0, at).concat(value, selected.slice(at));
1477
+ // As inserting values at predefined index positions doesn't work with empty
1478
+ // arrays, we need to reorder the updated selection to match the initial order
1479
+ return updated.sort(function (a, b) {
1480
+ return Number(all.indexOf(a) > all.indexOf(b));
1481
+ });
1482
+ }
1483
+
1431
1484
  /** The `ErrorSchemaBuilder<T>` is used to build an `ErrorSchema<T>` since the definition of the `ErrorSchema` type is
1432
1485
  * designed for reading information rather than writing it. Use this class to add, replace or clear errors in an error
1433
1486
  * schema by using either dotted path or an array of path names. Once you are done building the `ErrorSchema`, you can
@@ -1787,6 +1840,80 @@ function hasWidget(schema, widget, registeredWidgets) {
1787
1840
  }
1788
1841
  }
1789
1842
 
1843
+ /** Generates a consistent `id` pattern for a given `id` and a `suffix`
1844
+ *
1845
+ * @param id - Either simple string id or an IdSchema from which to extract it
1846
+ * @param suffix - The suffix to append to the id
1847
+ */
1848
+ function idGenerator(id, suffix) {
1849
+ var theId = isString__default["default"](id) ? id : id[ID_KEY];
1850
+ return theId + "__" + suffix;
1851
+ }
1852
+ /** Return a consistent `id` for the field description element
1853
+ *
1854
+ * @param id - Either simple string id or an IdSchema from which to extract it
1855
+ * @returns - The consistent id for the field description element from the given `id`
1856
+ */
1857
+ function descriptionId(id) {
1858
+ return idGenerator(id, "description");
1859
+ }
1860
+ /** Return a consistent `id` for the field error element
1861
+ *
1862
+ * @param id - Either simple string id or an IdSchema from which to extract it
1863
+ * @returns - The consistent id for the field error element from the given `id`
1864
+ */
1865
+ function errorId(id) {
1866
+ return idGenerator(id, "error");
1867
+ }
1868
+ /** Return a consistent `id` for the field examples element
1869
+ *
1870
+ * @param id - Either simple string id or an IdSchema from which to extract it
1871
+ * @returns - The consistent id for the field examples element from the given `id`
1872
+ */
1873
+ function examplesId(id) {
1874
+ return idGenerator(id, "examples");
1875
+ }
1876
+ /** Return a consistent `id` for the field help element
1877
+ *
1878
+ * @param id - Either simple string id or an IdSchema from which to extract it
1879
+ * @returns - The consistent id for the field help element from the given `id`
1880
+ */
1881
+ function helpId(id) {
1882
+ return idGenerator(id, "help");
1883
+ }
1884
+ /** Return a consistent `id` for the field title element
1885
+ *
1886
+ * @param id - Either simple string id or an IdSchema from which to extract it
1887
+ * @returns - The consistent id for the field title element from the given `id`
1888
+ */
1889
+ function titleId(id) {
1890
+ return idGenerator(id, "title");
1891
+ }
1892
+ /** Return a list of element ids that contain additional information about the field that can be used to as the aria
1893
+ * description of the field. This is correctly omitting `titleId` which would be "labeling" rather than "describing" the
1894
+ * element.
1895
+ *
1896
+ * @param id - Either simple string id or an IdSchema from which to extract it
1897
+ * @param [includeExamples=false] - Optional flag, if true, will add the `examplesId` into the list
1898
+ * @returns - The string containing the list of ids for use in an `aria-describedBy` attribute
1899
+ */
1900
+ function ariaDescribedByIds(id, includeExamples) {
1901
+ if (includeExamples === void 0) {
1902
+ includeExamples = false;
1903
+ }
1904
+ var examples = includeExamples ? " " + examplesId(id) : "";
1905
+ return errorId(id) + " " + descriptionId(id) + " " + helpId(id) + examples;
1906
+ }
1907
+ /** Return a consistent `id` for the `option`s of a `Radio` or `Checkboxes` widget
1908
+ *
1909
+ * @param id - The id of the parent component for the option
1910
+ * @param option - The option for which the id is desired
1911
+ * @returns - An id for the option based on the parent `id`
1912
+ */
1913
+ function optionId(id, option) {
1914
+ return id + "-" + option.value;
1915
+ }
1916
+
1790
1917
  /** Converts a local Date string into a UTC date string
1791
1918
  *
1792
1919
  * @param dateString - The string representation of a date as accepted by the `Date()` constructor
@@ -2112,11 +2239,17 @@ exports.UI_FIELD_KEY = UI_FIELD_KEY;
2112
2239
  exports.UI_OPTIONS_KEY = UI_OPTIONS_KEY;
2113
2240
  exports.UI_WIDGET_KEY = UI_WIDGET_KEY;
2114
2241
  exports.allowAdditionalItems = allowAdditionalItems;
2242
+ exports.ariaDescribedByIds = ariaDescribedByIds;
2115
2243
  exports.asNumber = asNumber;
2116
2244
  exports.canExpand = canExpand;
2117
2245
  exports.createSchemaUtils = createSchemaUtils;
2118
2246
  exports.dataURItoBlob = dataURItoBlob;
2119
2247
  exports.deepEquals = deepEquals;
2248
+ exports.descriptionId = descriptionId;
2249
+ exports.enumOptionsDeselectValue = enumOptionsDeselectValue;
2250
+ exports.enumOptionsSelectValue = enumOptionsSelectValue;
2251
+ exports.errorId = errorId;
2252
+ exports.examplesId = examplesId;
2120
2253
  exports.findSchemaDefinition = findSchemaDefinition;
2121
2254
  exports.getDefaultFormState = getDefaultFormState;
2122
2255
  exports.getDisplayLabel = getDisplayLabel;
@@ -2129,6 +2262,7 @@ exports.getUiOptions = getUiOptions;
2129
2262
  exports.getWidget = getWidget;
2130
2263
  exports.guessType = guessType;
2131
2264
  exports.hasWidget = hasWidget;
2265
+ exports.helpId = helpId;
2132
2266
  exports.isConstant = isConstant;
2133
2267
  exports.isCustomWidget = isCustomWidget;
2134
2268
  exports.isFilesArray = isFilesArray;
@@ -2141,6 +2275,7 @@ exports.mergeDefaultsWithFormData = mergeDefaultsWithFormData;
2141
2275
  exports.mergeObjects = mergeObjects;
2142
2276
  exports.mergeSchemas = mergeSchemas;
2143
2277
  exports.mergeValidationData = mergeValidationData;
2278
+ exports.optionId = optionId;
2144
2279
  exports.optionsList = optionsList;
2145
2280
  exports.orderProperties = orderProperties;
2146
2281
  exports.pad = pad;
@@ -2150,6 +2285,7 @@ exports.rangeSpec = rangeSpec;
2150
2285
  exports.retrieveSchema = retrieveSchema;
2151
2286
  exports.schemaRequiresTrueValue = schemaRequiresTrueValue;
2152
2287
  exports.shouldRender = shouldRender;
2288
+ exports.titleId = titleId;
2153
2289
  exports.toConstant = toConstant;
2154
2290
  exports.toDateString = toDateString;
2155
2291
  exports.toIdSchema = toIdSchema;