@rjsf/utils 5.2.0 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import React, { StyleHTMLAttributes } from 'react';
1
+ import React, { ReactElement, ComponentType, HTMLAttributes, StyleHTMLAttributes, ReactNode, ChangeEvent, ButtonHTMLAttributes } from 'react';
2
2
  import * as json_schema from 'json-schema';
3
3
  import { JSONSchema7 } from 'json-schema';
4
4
 
@@ -27,6 +27,8 @@ declare enum TranslatableString {
27
27
  AddButton = "Add",
28
28
  /** Add button title, used by AddButton */
29
29
  AddItemButton = "Add Item",
30
+ /** Copy button title, used by IconButton */
31
+ CopyButton = "Copy",
30
32
  /** Move down button title, used by IconButton */
31
33
  MoveDownButton = "Move down",
32
34
  /** Move up button title, used by IconButton */
@@ -53,6 +55,8 @@ declare enum TranslatableString {
53
55
  TitleOptionPrefix = "%1 option %2",
54
56
  /** Key label, where %1 will be replaced by the label as provided by WrapIfAdditionalTemplate */
55
57
  KeyLabel = "%1 Key",
58
+ /** Invalid object field configuration as provided by the ObjectField */
59
+ InvalidObjectField = "Invalid \"%1\" object field configuration: <em>%2</em>.",
56
60
  /** Unsupported field schema, used by UnsupportedField */
57
61
  UnsupportedField = "Unsupported field schema.",
58
62
  /** Unsupported field schema, where %1 will be replaced by the idSchema.$id as provided by UnsupportedField */
@@ -110,13 +114,13 @@ type RangeSpecType = {
110
114
  max?: number;
111
115
  };
112
116
  /** Properties describing a Range specification in terms of attribute that can be added to the `HTML` `<input>` */
113
- type InputPropsType = Omit<RangeSpecType, "step"> & {
117
+ type InputPropsType = Omit<RangeSpecType, 'step'> & {
114
118
  /** Specifies the type of the <input> element */
115
119
  type: string;
116
120
  /** Specifies the interval between legal numbers in an input field or "any" */
117
- step?: number | "any";
121
+ step?: number | 'any';
118
122
  /** Specifies the `autoComplete` value for an <input> element */
119
- autoComplete?: HTMLInputElement["autocomplete"];
123
+ autoComplete?: HTMLInputElement['autocomplete'];
120
124
  };
121
125
  /** Type describing an id used for a field in the `IdSchema` */
122
126
  type FieldId = {
@@ -198,7 +202,7 @@ type FieldErrorProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
198
202
  /** The errorSchema constructed by `Form` */
199
203
  errorSchema?: ErrorSchema<T>;
200
204
  /** An array of the errors */
201
- errors?: Array<string | React.ReactElement>;
205
+ errors?: Array<string | ReactElement>;
202
206
  /** The tree of unique ids for every child field */
203
207
  idSchema: IdSchema<T>;
204
208
  /** The schema that was passed to field */
@@ -211,7 +215,7 @@ type FieldErrorProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
211
215
  /** The properties that are passed to an `FieldHelpTemplate` implementation */
212
216
  type FieldHelpProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
213
217
  /** The help information to be rendered */
214
- help?: string | React.ReactElement;
218
+ help?: string | ReactElement;
215
219
  /** The tree of unique ids for every child field */
216
220
  idSchema: IdSchema<T>;
217
221
  /** The schema that was passed to field */
@@ -236,47 +240,68 @@ type RegistryWidgetsType<T = any, S extends StrictRJSFSchema = RJSFSchema, F ext
236
240
  /** The set of RJSF templates that can be overridden by themes or users */
237
241
  interface TemplatesType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> {
238
242
  /** The template to use while rendering normal or fixed array fields */
239
- ArrayFieldTemplate: React.ComponentType<ArrayFieldTemplateProps<T, S, F>>;
243
+ ArrayFieldTemplate: ComponentType<ArrayFieldTemplateProps<T, S, F>>;
240
244
  /** The template to use while rendering the description for an array field */
241
- ArrayFieldDescriptionTemplate: React.ComponentType<ArrayFieldDescriptionProps<T, S, F>>;
245
+ ArrayFieldDescriptionTemplate: ComponentType<ArrayFieldDescriptionProps<T, S, F>>;
242
246
  /** The template to use while rendering an item in an array field */
243
- ArrayFieldItemTemplate: React.ComponentType<ArrayFieldTemplateItemType<T, S, F>>;
247
+ ArrayFieldItemTemplate: ComponentType<ArrayFieldTemplateItemType<T, S, F>>;
244
248
  /** The template to use while rendering the title for an array field */
245
- ArrayFieldTitleTemplate: React.ComponentType<ArrayFieldTitleProps<T, S, F>>;
249
+ ArrayFieldTitleTemplate: ComponentType<ArrayFieldTitleProps<T, S, F>>;
246
250
  /** The template to use while rendering the standard html input */
247
- BaseInputTemplate: React.ComponentType<WidgetProps<T, S, F>>;
251
+ BaseInputTemplate: ComponentType<BaseInputTemplateProps<T, S, F>>;
248
252
  /** The template to use for rendering the description of a field */
249
- DescriptionFieldTemplate: React.ComponentType<DescriptionFieldProps<T, S, F>>;
253
+ DescriptionFieldTemplate: ComponentType<DescriptionFieldProps<T, S, F>>;
250
254
  /** The template to use while rendering the errors for the whole form */
251
- ErrorListTemplate: React.ComponentType<ErrorListProps<T, S, F>>;
255
+ ErrorListTemplate: ComponentType<ErrorListProps<T, S, F>>;
252
256
  /** The template to use while rendering the errors for a single field */
253
- FieldErrorTemplate: React.ComponentType<FieldErrorProps<T, S, F>>;
257
+ FieldErrorTemplate: ComponentType<FieldErrorProps<T, S, F>>;
254
258
  /** The template to use while rendering the errors for a single field */
255
- FieldHelpTemplate: React.ComponentType<FieldHelpProps<T, S, F>>;
259
+ FieldHelpTemplate: ComponentType<FieldHelpProps<T, S, F>>;
256
260
  /** The template to use while rendering a field */
257
- FieldTemplate: React.ComponentType<FieldTemplateProps<T, S, F>>;
261
+ FieldTemplate: ComponentType<FieldTemplateProps<T, S, F>>;
258
262
  /** The template to use while rendering an object */
259
- ObjectFieldTemplate: React.ComponentType<ObjectFieldTemplateProps<T, S, F>>;
263
+ ObjectFieldTemplate: ComponentType<ObjectFieldTemplateProps<T, S, F>>;
260
264
  /** The template to use for rendering the title of a field */
261
- TitleFieldTemplate: React.ComponentType<TitleFieldProps<T, S, F>>;
265
+ TitleFieldTemplate: ComponentType<TitleFieldProps<T, S, F>>;
262
266
  /** The template to use for rendering information about an unsupported field type in the schema */
263
- UnsupportedFieldTemplate: React.ComponentType<UnsupportedFieldProps<T, S, F>>;
267
+ UnsupportedFieldTemplate: ComponentType<UnsupportedFieldProps<T, S, F>>;
264
268
  /** The template to use for rendering a field that allows a user to add additional properties */
265
- WrapIfAdditionalTemplate: React.ComponentType<WrapIfAdditionalTemplateProps<T, S, F>>;
269
+ WrapIfAdditionalTemplate: ComponentType<WrapIfAdditionalTemplateProps<T, S, F>>;
266
270
  /** The set of templates associated with buttons in the form */
267
271
  ButtonTemplates: {
268
272
  /** The template to use for the main `Submit` button */
269
- SubmitButton: React.ComponentType<SubmitButtonProps<T, S, F>>;
273
+ SubmitButton: ComponentType<SubmitButtonProps<T, S, F>>;
270
274
  /** The template to use for the Add button used for AdditionalProperties and Array items */
271
- AddButton: React.ComponentType<IconButtonProps<T, S, F>>;
275
+ AddButton: ComponentType<IconButtonProps<T, S, F>>;
276
+ /** The template to use for the Copy button used for Array items */
277
+ CopyButton: ComponentType<IconButtonProps<T, S, F>>;
272
278
  /** The template to use for the Move Down button used for Array items */
273
- MoveDownButton: React.ComponentType<IconButtonProps<T, S, F>>;
279
+ MoveDownButton: ComponentType<IconButtonProps<T, S, F>>;
274
280
  /** The template to use for the Move Up button used for Array items */
275
- MoveUpButton: React.ComponentType<IconButtonProps<T, S, F>>;
281
+ MoveUpButton: ComponentType<IconButtonProps<T, S, F>>;
276
282
  /** The template to use for the Remove button used for AdditionalProperties and Array items */
277
- RemoveButton: React.ComponentType<IconButtonProps<T, S, F>>;
283
+ RemoveButton: ComponentType<IconButtonProps<T, S, F>>;
278
284
  };
279
285
  }
286
+ /** The set of UiSchema options that can be set globally and used as fallbacks at an individual template, field or
287
+ * widget level when no field-level value of the option is provided.
288
+ */
289
+ type GlobalUISchemaOptions = {
290
+ /** Flag, if set to `false`, new items cannot be added to array fields, unless overridden (defaults to true) */
291
+ addable?: boolean;
292
+ /** Flag, if set to `true`, array items can be copied (defaults to false) */
293
+ copyable?: boolean;
294
+ /** Flag, if set to `false`, array items cannot be ordered (defaults to true) */
295
+ orderable?: boolean;
296
+ /** Flag, if set to `false`, array items will not be removable (defaults to true) */
297
+ removable?: boolean;
298
+ /** Field labels are rendered by default. Labels may be omitted by setting the `label` option to `false` */
299
+ label?: boolean;
300
+ /** When using `additionalProperties`, key collision is prevented by appending a unique integer to the duplicate key.
301
+ * This option allows you to change the separator between the original key name and the integer. Default is "-"
302
+ */
303
+ duplicateKeySuffixSeparator?: string;
304
+ };
280
305
  /** The object containing the registered core, theme and custom fields and widgets as well as the root schema, form
281
306
  * context, schema utils and templates.
282
307
  */
@@ -303,9 +328,11 @@ interface Registry<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends F
303
328
  schemaUtils: SchemaUtilsType<T, S>;
304
329
  /** The string translation function to use when displaying any of the RJSF strings in templates, fields or widgets */
305
330
  translateString: (stringKey: TranslatableString, params?: string[]) => string;
331
+ /** The optional global UI Options that are available for all templates, fields and widgets to access */
332
+ globalUiOptions?: GlobalUISchemaOptions;
306
333
  }
307
334
  /** The properties that are passed to a Field implementation */
308
- interface FieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> extends GenericObjectType, Pick<React.HTMLAttributes<HTMLElement>, Exclude<keyof React.HTMLAttributes<HTMLElement>, "onBlur" | "onFocus" | "onChange">> {
335
+ interface FieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> extends GenericObjectType, Pick<HTMLAttributes<HTMLElement>, Exclude<keyof HTMLAttributes<HTMLElement>, 'onBlur' | 'onFocus' | 'onChange'>> {
309
336
  /** The JSON subschema object for this field */
310
337
  schema: S;
311
338
  /** The uiSchema for this field */
@@ -350,7 +377,7 @@ interface FieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
350
377
  registry: Registry<T, S, F>;
351
378
  }
352
379
  /** The definition of a React-based Field component */
353
- type Field<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = React.ComponentType<FieldProps<T, S, F>>;
380
+ type Field<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = ComponentType<FieldProps<T, S, F>>;
354
381
  /** The properties that are passed to a FieldTemplate implementation */
355
382
  type FieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
356
383
  /** The id of the field in the hierarchy. You can use it to render a label targeting the wrapped widget */
@@ -364,17 +391,17 @@ type FieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F exte
364
391
  /** A component instance rendering the field description, if one is defined (this will use any custom
365
392
  * `DescriptionField` defined)
366
393
  */
367
- description?: React.ReactElement;
394
+ description?: ReactElement;
368
395
  /** A string containing any `ui:description` uiSchema directive defined */
369
396
  rawDescription?: string;
370
397
  /** The field or widget component instance for this field row */
371
- children: React.ReactElement;
398
+ children: ReactElement;
372
399
  /** A component instance listing any encountered errors for this field */
373
- errors?: React.ReactElement;
400
+ errors?: ReactElement;
374
401
  /** An array of strings listing all generated error messages from encountered errors for this field */
375
402
  rawErrors?: string[];
376
403
  /** A component instance rendering any `ui:help` uiSchema directive defined */
377
- help?: React.ReactElement;
404
+ help?: ReactElement;
378
405
  /** A string containing any `ui:help` uiSchema directive defined. **NOTE:** `rawHelp` will be `undefined` if passed
379
406
  * `ui:help` is a React component instead of a string
380
407
  */
@@ -402,7 +429,7 @@ type FieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F exte
402
429
  /** The formData for this field */
403
430
  formData?: T;
404
431
  /** The value change event handler; Can be called with a new value to change the value for this field */
405
- onChange: FieldProps["onChange"];
432
+ onChange: FieldProps['onChange'];
406
433
  /** The key change event handler; Called when the key associated with a field is changed for an additionalProperty */
407
434
  onKeyChange: (value: string) => () => void;
408
435
  /** The property drop/removal event handler; Called when a field is removed in an additionalProperty context */
@@ -445,34 +472,36 @@ type DescriptionFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F e
445
472
  /** The uiSchema object for this description field */
446
473
  uiSchema?: UiSchema<T, S, F>;
447
474
  /** The description of the field being rendered */
448
- description: string | React.ReactElement;
475
+ description: string | ReactElement;
449
476
  /** The `registry` object */
450
477
  registry: Registry<T, S, F>;
451
478
  };
452
479
  /** The properties that are passed to a `ArrayFieldTitleTemplate` implementation */
453
- type ArrayFieldTitleProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Omit<TitleFieldProps<T, S, F>, "id" | "title"> & {
480
+ type ArrayFieldTitleProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Omit<TitleFieldProps<T, S, F>, 'id' | 'title'> & {
454
481
  /** The title for the field being rendered */
455
482
  title?: string;
456
483
  /** The idSchema of the field in the hierarchy */
457
484
  idSchema: IdSchema<T>;
458
485
  };
459
486
  /** The properties that are passed to a `ArrayFieldDescriptionTemplate` implementation */
460
- type ArrayFieldDescriptionProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Omit<DescriptionFieldProps<T, S, F>, "id" | "description"> & {
487
+ type ArrayFieldDescriptionProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Omit<DescriptionFieldProps<T, S, F>, 'id' | 'description'> & {
461
488
  /** The description of the field being rendered */
462
- description?: string | React.ReactElement;
489
+ description?: string | ReactElement;
463
490
  /** The idSchema of the field in the hierarchy */
464
491
  idSchema: IdSchema<T>;
465
492
  };
466
493
  /** The properties of each element in the ArrayFieldTemplateProps.items array */
467
494
  type ArrayFieldTemplateItemType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
468
495
  /** The html for the item's content */
469
- children: React.ReactElement;
496
+ children: ReactElement;
470
497
  /** The className string */
471
498
  className: string;
472
499
  /** A boolean value stating if the array item is disabled */
473
500
  disabled: boolean;
474
501
  /** A boolean value stating whether new items can be added to the array */
475
502
  canAdd: boolean;
503
+ /** A boolean value stating whether the array item can be copied, assumed false if missing */
504
+ hasCopy: boolean;
476
505
  /** A boolean value stating whether the array item can be moved down */
477
506
  hasMoveDown: boolean;
478
507
  /** A boolean value stating whether the array item can be moved up */
@@ -487,6 +516,8 @@ type ArrayFieldTemplateItemType<T = any, S extends StrictRJSFSchema = RJSFSchema
487
516
  totalItems: number;
488
517
  /** Returns a function that adds a new item at `index` */
489
518
  onAddIndexClick: (index: number) => (event?: any) => void;
519
+ /** Returns a function that copies the item at `index` into the position at `index + 1` */
520
+ onCopyIndexClick: (index: number) => (event?: any) => void;
490
521
  /** Returns a function that removes the item at `index` */
491
522
  onDropIndexClick: (index: number) => (event?: any) => void;
492
523
  /** Returns a function that swaps the items at `index` with `newIndex` */
@@ -540,7 +571,7 @@ type ArrayFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F
540
571
  /** The properties of each element in the ObjectFieldTemplateProps.properties array */
541
572
  type ObjectFieldTemplatePropertyType = {
542
573
  /** The html for the property's content */
543
- content: React.ReactElement;
574
+ content: ReactElement;
544
575
  /** A string representing the property name */
545
576
  name: string;
546
577
  /** A boolean value stating if the object property is disabled */
@@ -584,12 +615,18 @@ type ObjectFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema,
584
615
  /** The properties that are passed to a WrapIfAdditionalTemplate implementation */
585
616
  type WrapIfAdditionalTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
586
617
  /** The field or widget component instance for this field row */
587
- children: React.ReactNode;
588
- } & Pick<FieldTemplateProps<T, S, F>, "id" | "classNames" | "style" | "label" | "required" | "readonly" | "disabled" | "schema" | "uiSchema" | "onKeyChange" | "onDropPropertyClick" | "registry">;
618
+ children: ReactNode;
619
+ } & Pick<FieldTemplateProps<T, S, F>, 'id' | 'classNames' | 'style' | 'label' | 'required' | 'readonly' | 'disabled' | 'schema' | 'uiSchema' | 'onKeyChange' | 'onDropPropertyClick' | 'registry'>;
589
620
  /** The properties that are passed to a Widget implementation */
590
- 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">> {
591
- /** The generated id for this widget */
621
+ interface WidgetProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> extends GenericObjectType, Pick<HTMLAttributes<HTMLElement>, Exclude<keyof HTMLAttributes<HTMLElement>, 'onBlur' | 'onFocus'>> {
622
+ /** The generated id for this widget, used to provide unique `name`s and `id`s for the HTML field elements rendered by
623
+ * widgets
624
+ */
592
625
  id: string;
626
+ /** The unique name of the field, usually derived from the name of the property in the JSONSchema; Provided in support
627
+ * of custom widgets.
628
+ */
629
+ name: string;
593
630
  /** The JSONSchema subschema object for this widget */
594
631
  schema: S;
595
632
  /** The uiSchema for this widget */
@@ -633,7 +670,15 @@ interface WidgetProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extend
633
670
  registry: Registry<T, S, F>;
634
671
  }
635
672
  /** The definition of a React-based Widget component */
636
- type Widget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = React.ComponentType<WidgetProps<T, S, F>>;
673
+ type Widget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = ComponentType<WidgetProps<T, S, F>>;
674
+ /** The properties that are passed to the BaseInputTemplate */
675
+ interface BaseInputTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> extends WidgetProps<T, S, F> {
676
+ /** A `BaseInputTemplate` implements a default `onChange` handler that it passes to the HTML input component to handle
677
+ * the `ChangeEvent`. Sometimes a widget may need to handle the `ChangeEvent` using custom logic. If that is the case,
678
+ * that widget should provide its own handler via this prop.
679
+ */
680
+ onChangeOverride?: (event: ChangeEvent<HTMLInputElement>) => void;
681
+ }
637
682
  /** The type that defines the props used by the Submit button */
638
683
  type SubmitButtonProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
639
684
  /** The uiSchema for this widget */
@@ -642,11 +687,11 @@ type SubmitButtonProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F exten
642
687
  registry: Registry<T, S, F>;
643
688
  };
644
689
  /** The type that defines the props for an Icon button, extending from a basic HTML button attributes */
645
- type IconButtonProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = React.ButtonHTMLAttributes<HTMLButtonElement> & {
690
+ type IconButtonProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = ButtonHTMLAttributes<HTMLButtonElement> & {
646
691
  /** An alternative specification for the type of the icon button */
647
692
  iconType?: string;
648
693
  /** The name representation or actual react element implementation for the icon */
649
- icon?: string | React.ReactElement;
694
+ icon?: string | ReactElement;
650
695
  /** The uiSchema for this widget */
651
696
  uiSchema?: UiSchema<T, S, F>;
652
697
  /** The `registry` object */
@@ -682,7 +727,7 @@ type MakeUIType<Type> = {
682
727
  /** This type represents all the known supported options in the `ui:options` property, kept separate in order to
683
728
  * remap the keys. It also contains all the properties, optionally, of `TemplatesType` except "ButtonTemplates"
684
729
  */
685
- type UIOptionsBaseType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Partial<Omit<TemplatesType<T, S, F>, "ButtonTemplates">> & {
730
+ type UIOptionsBaseType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Partial<Omit<TemplatesType<T, S, F>, 'ButtonTemplates'>> & GlobalUISchemaOptions & {
686
731
  /** Any classnames that the user wants to be applied to a field in the ui */
687
732
  classNames?: string;
688
733
  /** Any custom style that the user wants to apply to a field in the ui, applied on the same element as classNames */
@@ -698,7 +743,7 @@ type UIOptionsBaseType<T = any, S extends StrictRJSFSchema = RJSFSchema, F exten
698
743
  /** Flag, if set to `true`, will mark the field as automatically focused on a text input or textarea input */
699
744
  autofocus?: boolean;
700
745
  /** Use to mark the field as supporting auto complete on a text input or textarea input */
701
- autocomplete?: HTMLInputElement["autocomplete"];
746
+ autocomplete?: HTMLInputElement['autocomplete'];
702
747
  /** Flag, if set to `true`, will mark all child widgets from a given field as disabled */
703
748
  disabled?: boolean;
704
749
  /** The default value to use when an input for a field is empty */
@@ -713,18 +758,10 @@ type UIOptionsBaseType<T = any, S extends StrictRJSFSchema = RJSFSchema, F exten
713
758
  readonly?: boolean;
714
759
  /** This property allows you to reorder the properties that are shown for a particular object */
715
760
  order?: string[];
716
- /** Flag, if set to `false`, will mark array fields as NOT being able to be added to (defaults to true) */
717
- addable?: boolean;
718
- /** Flag, if set to `false`, will mark array fields as NOT being able to be ordered (defaults to true) */
719
- orderable?: boolean;
720
- /** Flag, if set to `false`, will mark array fields as NOT being able to be removed (defaults to true) */
721
- removable?: boolean;
722
761
  /** Flag, if set to `true`, will mark a list of checkboxes as displayed all on one line instead of one per row */
723
762
  inline?: boolean;
724
763
  /** Used to change the input type (for example, `tel` or `email`) for an <input> */
725
764
  inputType?: string;
726
- /** Field labels are rendered by default. Labels may be omitted by setting the `label` option to `false` */
727
- label?: boolean;
728
765
  /** Provides a means to set the initial height of a textarea widget */
729
766
  rows?: number;
730
767
  /** If submitButtonOptions is provided it should match the `UISchemaSubmitButtonOptions` type */
@@ -733,10 +770,6 @@ type UIOptionsBaseType<T = any, S extends StrictRJSFSchema = RJSFSchema, F exten
733
770
  * to look up an implementation from the `widgets` list or an actual one-off widget implementation itself
734
771
  */
735
772
  widget?: Widget<T, S, F> | string;
736
- /** When using `additionalProperties`, key collision is prevented by appending a unique integer to the duplicate key.
737
- * This option allows you to change the separator between the original key name and the integer. Default is "-"
738
- */
739
- duplicateKeySuffixSeparator?: string;
740
773
  };
741
774
  /** The type that represents the Options potentially provided by `ui:options` */
742
775
  type UIOptionsType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = UIOptionsBaseType<T, S, F> & {
@@ -747,12 +780,16 @@ type UIOptionsType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends F
747
780
  * starting with `ui:`.
748
781
  */
749
782
  type UiSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = GenericObjectType & MakeUIType<UIOptionsBaseType<T, S, F>> & {
750
- /** Allows the form to generate a unique prefix for the `Form`'s root prefix */
751
- "ui:rootFieldId"?: string;
783
+ /** The set of Globally relevant UI Schema options that are read from the root-level UiSchema and stored in the
784
+ * Registry for use everywhere.
785
+ */
786
+ 'ui:globalOptions'?: GlobalUISchemaOptions;
787
+ /** Allows the form to generate a unique prefix for the `Form`'s root prefix */
788
+ 'ui:rootFieldId'?: string;
752
789
  /** Allows RJSF to override the default field implementation by specifying either the name of a field that is used
753
790
  * to look up an implementation from the `fields` list or an actual one-off `Field` component implementation itself
754
791
  */
755
- "ui:field"?: Field<T, S, F> | string;
792
+ 'ui:field'?: Field<T, S, F> | string;
756
793
  /** By default, any field that is rendered for an `anyOf`/`oneOf` schema will be wrapped inside the `AnyOfField` or
757
794
  * `OneOfField` component. This default behavior may be undesirable if your custom field already handles behavior
758
795
  * related to choosing one or more subschemas contained in the `anyOf`/`oneOf` schema.
@@ -760,9 +797,9 @@ type UiSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormCo
760
797
  * omitted, so just one instance of the custom field will be rendered. If the flag is omitted or set to `false`,
761
798
  * your custom field will be wrapped by `AnyOfField`/`OneOfField`.
762
799
  */
763
- "ui:fieldReplacesAnyOrOneOf"?: boolean;
800
+ 'ui:fieldReplacesAnyOrOneOf'?: boolean;
764
801
  /** An object that contains all the potential UI options in a single object */
765
- "ui:options"?: UIOptionsType<T, S, F>;
802
+ 'ui:options'?: UIOptionsType<T, S, F>;
766
803
  };
767
804
  /** A `CustomValidator` function takes in a `formData`, `errors` and `uiSchema` objects and returns the given `errors`
768
805
  * object back, while potentially adding additional messages to the `errors`
@@ -851,15 +888,16 @@ interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchema, F ex
851
888
  * false when computing defaults for any nested object properties.
852
889
  * @returns - The resulting `formData` with all the defaults provided
853
890
  */
854
- getDefaultFormState(schema: S, formData?: T, includeUndefinedValues?: boolean | "excludeObjectChildren"): T | T[] | undefined;
891
+ getDefaultFormState(schema: S, formData?: T, includeUndefinedValues?: boolean | 'excludeObjectChildren'): T | T[] | undefined;
855
892
  /** Determines whether the combination of `schema` and `uiSchema` properties indicates that the label for the `schema`
856
893
  * should be displayed in a UI.
857
894
  *
858
895
  * @param schema - The schema for which the display label flag is desired
859
896
  * @param [uiSchema] - The UI schema from which to derive potentially displayable information
897
+ * @param [globalOptions={}] - The Global UI Schema from which to get any fallback `xxx` options
860
898
  * @returns - True if the label should be displayed or false if it should not
861
899
  */
862
- getDisplayLabel(schema: S, uiSchema?: UiSchema<T, S, F>): boolean;
900
+ getDisplayLabel(schema: S, uiSchema?: UiSchema<T, S, F>, globalOptions?: GlobalUISchemaOptions): boolean;
863
901
  /** Determines which of the given `options` provided most closely matches the `formData`.
864
902
  * Returns the index of the option that is valid and is the closest match, or 0 if there is no match.
865
903
  *
@@ -1007,6 +1045,12 @@ declare function createSchemaUtils<T = any, S extends StrictRJSFSchema = RJSFSch
1007
1045
  declare function dataURItoBlob(dataURI: string): {
1008
1046
  blob: Blob;
1009
1047
  name: string;
1048
+ } | {
1049
+ blob: {
1050
+ size: number;
1051
+ type: string;
1052
+ };
1053
+ name: string;
1010
1054
  };
1011
1055
 
1012
1056
  /** Implements a deep equals using the `lodash.isEqualWith` function, that provides a customized comparator that
@@ -1040,7 +1084,7 @@ declare function englishStringTranslator(stringToTranslate: TranslatableString,
1040
1084
  * unless `selected` is a single value. In that case, if the `valueIndex` value matches `selected`, returns
1041
1085
  * undefined, otherwise `selected`.
1042
1086
  */
1043
- declare function enumOptionsDeselectValue<S extends StrictRJSFSchema = RJSFSchema>(valueIndex: string | number, selected?: EnumOptionsType<S>["value"] | EnumOptionsType<S>["value"][], allEnumOptions?: EnumOptionsType<S>[]): EnumOptionsType<S>["value"] | EnumOptionsType<S>["value"][] | undefined;
1087
+ declare function enumOptionsDeselectValue<S extends StrictRJSFSchema = RJSFSchema>(valueIndex: string | number, selected?: EnumOptionsType<S>['value'] | EnumOptionsType<S>['value'][], allEnumOptions?: EnumOptionsType<S>[]): EnumOptionsType<S>['value'] | EnumOptionsType<S>['value'][] | undefined;
1044
1088
 
1045
1089
  /** Returns the index(es) of the options in `allEnumOptions` whose value(s) match the ones in `value`. All the
1046
1090
  * `enumOptions` are filtered based on whether they are a "selected" `value` and the index of each selected one is then
@@ -1053,7 +1097,7 @@ declare function enumOptionsDeselectValue<S extends StrictRJSFSchema = RJSFSchem
1053
1097
  * @returns - A single string index for the first `value` in `allEnumOptions`, if not `multiple`. Otherwise, the list
1054
1098
  * of indexes for (each of) the value(s) in `value`.
1055
1099
  */
1056
- declare function enumOptionsIndexForValue<S extends StrictRJSFSchema = RJSFSchema>(value: EnumOptionsType<S>["value"] | EnumOptionsType<S>["value"][], allEnumOptions?: EnumOptionsType<S>[], multiple?: boolean): string | string[] | undefined;
1100
+ declare function enumOptionsIndexForValue<S extends StrictRJSFSchema = RJSFSchema>(value: EnumOptionsType<S>['value'] | EnumOptionsType<S>['value'][], allEnumOptions?: EnumOptionsType<S>[], multiple?: boolean): string | string[] | undefined;
1057
1101
 
1058
1102
  /** Determines whether the given `value` is (one of) the `selected` value(s).
1059
1103
  *
@@ -1061,7 +1105,7 @@ declare function enumOptionsIndexForValue<S extends StrictRJSFSchema = RJSFSchem
1061
1105
  * @param selected - The current selected value or list of values
1062
1106
  * @returns - true if the `value` is one of the `selected` ones, false otherwise
1063
1107
  */
1064
- declare function enumOptionsIsSelected<S extends StrictRJSFSchema = RJSFSchema>(value: EnumOptionsType<S>["value"], selected: EnumOptionsType<S>["value"] | EnumOptionsType<S>["value"][]): boolean;
1108
+ declare function enumOptionsIsSelected<S extends StrictRJSFSchema = RJSFSchema>(value: EnumOptionsType<S>['value'], selected: EnumOptionsType<S>['value'] | EnumOptionsType<S>['value'][]): boolean;
1065
1109
 
1066
1110
  /** Add the enum option value at the `valueIndex` to the list of `selected` values in the proper order as defined by
1067
1111
  * `allEnumOptions`
@@ -1071,7 +1115,7 @@ declare function enumOptionsIsSelected<S extends StrictRJSFSchema = RJSFSchema>(
1071
1115
  * @param [allEnumOptions=[]] - The list of all the known enumOptions
1072
1116
  * @returns - The updated list of selected enum values with enum value at the `valueIndex` added to it
1073
1117
  */
1074
- declare function enumOptionsSelectValue<S extends StrictRJSFSchema = RJSFSchema>(valueIndex: string | number, selected: EnumOptionsType<S>["value"][], allEnumOptions?: EnumOptionsType<S>[]): any[];
1118
+ declare function enumOptionsSelectValue<S extends StrictRJSFSchema = RJSFSchema>(valueIndex: string | number, selected: EnumOptionsType<S>['value'][], allEnumOptions?: EnumOptionsType<S>[]): any[];
1075
1119
 
1076
1120
  /** Returns the value(s) from `allEnumOptions` at the index(es) provided by `valueIndex`. If `valueIndex` is not an
1077
1121
  * array AND the index is not valid for `allEnumOptions`, `emptyValue` is returned. If `valueIndex` is an array, AND it
@@ -1084,7 +1128,7 @@ declare function enumOptionsSelectValue<S extends StrictRJSFSchema = RJSFSchema>
1084
1128
  * @returns - The single or list of values specified by the single or list of indexes if they are valid. Otherwise,
1085
1129
  * `emptyValue` or an empty list.
1086
1130
  */
1087
- declare function enumOptionsValueForIndex<S extends StrictRJSFSchema = RJSFSchema>(valueIndex: string | number | Array<string | number>, allEnumOptions?: EnumOptionsType<S>[], emptyValue?: EnumOptionsType<S>["value"]): EnumOptionsType<S>["value"] | EnumOptionsType<S>["value"][] | undefined;
1131
+ declare function enumOptionsValueForIndex<S extends StrictRJSFSchema = RJSFSchema>(valueIndex: string | number | Array<string | number>, allEnumOptions?: EnumOptionsType<S>[], emptyValue?: EnumOptionsType<S>['value']): EnumOptionsType<S>['value'] | EnumOptionsType<S>['value'][] | undefined;
1088
1132
 
1089
1133
  /** The `ErrorSchemaBuilder<T>` is used to build an `ErrorSchema<T>` since the definition of the `ErrorSchema` type is
1090
1134
  * designed for reading information rather than writing it. Use this class to add, replace or clear errors in an error
@@ -1198,12 +1242,13 @@ declare function getSubmitButtonOptions<T = any, S extends StrictRJSFSchema = RJ
1198
1242
  declare function getTemplate<Name extends keyof TemplatesType<T, S, F>, T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(name: Name, registry: Registry<T, S, F>, uiOptions?: UIOptionsType<T, S, F>): TemplatesType<T, S, F>[Name];
1199
1243
 
1200
1244
  /** Get all passed options from ui:options, and ui:<optionName>, returning them in an object with the `ui:`
1201
- * stripped off.
1245
+ * stripped off. Any `globalOptions` will always be returned, unless they are overridden by options in the `uiSchema`.
1202
1246
  *
1203
1247
  * @param [uiSchema={}] - The UI Schema from which to get any `ui:xxx` options
1204
- * @returns - An object containing all the `ui:xxx` options with the stripped off
1248
+ * @param [globalOptions={}] - The optional Global UI Schema from which to get any fallback `xxx` options
1249
+ * @returns - An object containing all the `ui:xxx` options with the `ui:` stripped off along with all `globalOptions`
1205
1250
  */
1206
- declare function getUiOptions<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(uiSchema?: UiSchema<T, S, F>): UIOptionsType<T, S, F>;
1251
+ declare function getUiOptions<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(uiSchema?: UiSchema<T, S, F>, globalOptions?: GlobalUISchemaOptions): UIOptionsType<T, S, F>;
1207
1252
 
1208
1253
  /** Given a schema representing a field to render and either the name or actual `Widget` implementation, returns the
1209
1254
  * React component that is used to render the widget. If the `widget` is already a React component, then it is wrapped
@@ -1346,7 +1391,7 @@ declare function mergeDefaultsWithFormData<T = any>(defaults?: T, formData?: T):
1346
1391
  * NOTE: Uses shallow comparison for the duplicate checking.
1347
1392
  * @returns - A new object that is the merge of the two given objects
1348
1393
  */
1349
- declare function mergeObjects(obj1: GenericObjectType, obj2: GenericObjectType, concatArrays?: boolean | "preventDuplicates"): GenericObjectType;
1394
+ declare function mergeObjects(obj1: GenericObjectType, obj2: GenericObjectType, concatArrays?: boolean | 'preventDuplicates'): GenericObjectType;
1350
1395
 
1351
1396
  /** Recursively merge deeply nested schemas. The difference between `mergeSchemas` and `mergeObjects` is that
1352
1397
  * `mergeSchemas` only concats arrays for values under the 'required' keyword, and when it does, it doesn't include
@@ -1487,7 +1532,8 @@ declare const REF_KEY = "$ref";
1487
1532
  declare const RJSF_ADDITONAL_PROPERTIES_FLAG = "__rjsf_additionalProperties";
1488
1533
  declare const UI_FIELD_KEY = "ui:field";
1489
1534
  declare const UI_WIDGET_KEY = "ui:widget";
1490
- declare const UI_OPTIONS_KEY = "ui:options";
1535
+ declare const UI_OPTIONS_KEY = "ui:options";
1536
+ declare const UI_GLOBAL_OPTIONS_KEY = "ui:globalOptions";
1491
1537
 
1492
1538
  /** Returns the superset of `formData` that includes the given set updated to include any missing fields that have
1493
1539
  * computed to have defaults provided in the `schema`.
@@ -1501,7 +1547,7 @@ declare const UI_OPTIONS_KEY = "ui:options";
1501
1547
  * false when computing defaults for any nested object properties.
1502
1548
  * @returns - The resulting `formData` with all the defaults provided
1503
1549
  */
1504
- declare function getDefaultFormState<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, theSchema: S, formData?: T, rootSchema?: S, includeUndefinedValues?: boolean | "excludeObjectChildren"): T | T[] | undefined;
1550
+ declare function getDefaultFormState<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, theSchema: S, formData?: T, rootSchema?: S, includeUndefinedValues?: boolean | 'excludeObjectChildren'): T | T[] | undefined;
1505
1551
 
1506
1552
  /** Determines whether the combination of `schema` and `uiSchema` properties indicates that the label for the `schema`
1507
1553
  * should be displayed in a UI.
@@ -1510,9 +1556,10 @@ declare function getDefaultFormState<T = any, S extends StrictRJSFSchema = RJSFS
1510
1556
  * @param schema - The schema for which the display label flag is desired
1511
1557
  * @param [uiSchema={}] - The UI schema from which to derive potentially displayable information
1512
1558
  * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
1559
+ * @param [globalOptions={}] - The optional Global UI Schema from which to get any fallback `xxx` options
1513
1560
  * @returns - True if the label should be displayed or false if it should not
1514
1561
  */
1515
- declare function getDisplayLabel<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, schema: S, uiSchema?: UiSchema<T, S, F>, rootSchema?: S): boolean;
1562
+ declare function getDisplayLabel<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, schema: S, uiSchema?: UiSchema<T, S, F>, rootSchema?: S, globalOptions?: GlobalUISchemaOptions): boolean;
1516
1563
 
1517
1564
  /** Determines which of the given `options` provided most closely matches the `formData`. Using
1518
1565
  * `getFirstMatchingOption()` to match two schemas that differ only by the readOnly, default or const value of a field
@@ -1684,4 +1731,4 @@ declare function toIdSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F
1684
1731
  */
1685
1732
  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>;
1686
1733
 
1687
- 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, TranslatableString, 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, englishStringTranslator, enumOptionsDeselectValue, enumOptionsIndexForValue, enumOptionsIsSelected, enumOptionsSelectValue, enumOptionsValueForIndex, errorId, examplesId, findSchemaDefinition, getClosestMatchingOption, getDefaultFormState, getDisplayLabel, getFirstMatchingOption, 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, rangeSpec, replaceStringParameters, retrieveSchema, sanitizeDataForNewSchema, schemaRequiresTrueValue, shouldRender, titleId, toConstant, toDateString, toIdSchema, toPathSchema, utcToLocal };
1734
+ export { ADDITIONAL_PROPERTIES_KEY, ADDITIONAL_PROPERTY_FLAG, ALL_OF_KEY, ANY_OF_KEY, ArrayFieldDescriptionProps, ArrayFieldTemplateItemType, ArrayFieldTemplateProps, ArrayFieldTitleProps, BaseInputTemplateProps, 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, GlobalUISchemaOptions, 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, TranslatableString, UIOptionsType, UISchemaSubmitButtonOptions, UI_FIELD_KEY, UI_GLOBAL_OPTIONS_KEY, UI_OPTIONS_KEY, UI_WIDGET_KEY, UiSchema, UnsupportedFieldProps, ValidationData, ValidatorType, Widget, WidgetProps, WrapIfAdditionalTemplateProps, allowAdditionalItems, ariaDescribedByIds, asNumber, canExpand, createSchemaUtils, dataURItoBlob, deepEquals, descriptionId, englishStringTranslator, enumOptionsDeselectValue, enumOptionsIndexForValue, enumOptionsIsSelected, enumOptionsSelectValue, enumOptionsValueForIndex, errorId, examplesId, findSchemaDefinition, getClosestMatchingOption, getDefaultFormState, getDisplayLabel, getFirstMatchingOption, 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, rangeSpec, replaceStringParameters, retrieveSchema, sanitizeDataForNewSchema, schemaRequiresTrueValue, shouldRender, titleId, toConstant, toDateString, toIdSchema, toPathSchema, utcToLocal };