@rjsf/utils 5.0.0-beta.10 → 5.0.0-beta.12

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,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import * as json_schema from 'json-schema';
3
- import { JSONSchema7, JSONSchema7Definition } from 'json-schema';
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)
@@ -8,14 +8,16 @@ import { JSONSchema7, JSONSchema7Definition } from 'json-schema';
8
8
  declare type GenericObjectType = {
9
9
  [name: string]: any;
10
10
  };
11
- /** Map the JSONSchema7 to our own type so that we can easily bump to JSONSchema8 at some future date and only have to
12
- * update this one type.
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
+ * have to update this one type.
13
13
  */
14
- declare type RJSFSchema = JSONSchema7;
15
- /** Map the JSONSchema7Definition to our own type so that we can easily bump to JSONSchema8Definition at some future
16
- * date and only have to update this one type.
14
+ declare type StrictRJSFSchema = JSONSchema7;
15
+ /** Allow for more flexible schemas (i.e. draft-2019) than the strict JSONSchema7
17
16
  */
18
- declare type RJSFSchemaDefinition = JSONSchema7Definition;
17
+ declare type RJSFSchema = StrictRJSFSchema & GenericObjectType;
18
+ /** Alias GenericObjectType as FormContextType to allow us to remap this at some future date
19
+ */
20
+ declare type FormContextType = GenericObjectType;
19
21
  /** The interface representing a Date object that contains an optional time */
20
22
  interface DateObject {
21
23
  /** The year of the Date */
@@ -110,7 +112,7 @@ declare type FormValidation<T = any> = FieldValidation & {
110
112
  [key in keyof T]?: FormValidation<T[key]>;
111
113
  };
112
114
  /** The properties that are passed to an `ErrorListTemplate` implementation */
113
- declare type ErrorListProps<T = any, F = any> = {
115
+ declare type ErrorListProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
114
116
  /** The errorSchema constructed by `Form` */
115
117
  errorSchema: ErrorSchema<T>;
116
118
  /** An array of the errors */
@@ -118,12 +120,12 @@ declare type ErrorListProps<T = any, F = any> = {
118
120
  /** The `formContext` object that was passed to `Form` */
119
121
  formContext?: F;
120
122
  /** The schema that was passed to `Form` */
121
- schema: RJSFSchema;
123
+ schema: S;
122
124
  /** The uiSchema that was passed to `Form` */
123
- uiSchema?: UiSchema<T, F>;
125
+ uiSchema?: UiSchema<T, S, F>;
124
126
  };
125
127
  /** The properties that are passed to an `FieldErrorTemplate` implementation */
126
- declare type FieldErrorProps<T = any, F = any> = {
128
+ declare type FieldErrorProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
127
129
  /** The errorSchema constructed by `Form` */
128
130
  errorSchema?: ErrorSchema<T>;
129
131
  /** An array of the errors */
@@ -131,112 +133,112 @@ declare type FieldErrorProps<T = any, F = any> = {
131
133
  /** The tree of unique ids for every child field */
132
134
  idSchema: IdSchema<T>;
133
135
  /** The schema that was passed to field */
134
- schema: RJSFSchema;
136
+ schema: S;
135
137
  /** The uiSchema that was passed to field */
136
- uiSchema?: UiSchema<T, F>;
138
+ uiSchema?: UiSchema<T, S, F>;
137
139
  /** The `registry` object */
138
- registry: Registry<T, F>;
140
+ registry: Registry<T, S, F>;
139
141
  };
140
142
  /** The properties that are passed to an `FieldHelpTemplate` implementation */
141
- declare type FieldHelpProps<T = any, F = any> = {
143
+ declare type FieldHelpProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
142
144
  /** The help information to be rendered */
143
145
  help?: string | React.ReactElement;
144
146
  /** The tree of unique ids for every child field */
145
147
  idSchema: IdSchema<T>;
146
148
  /** The schema that was passed to field */
147
- schema: RJSFSchema;
149
+ schema: S;
148
150
  /** The uiSchema that was passed to field */
149
- uiSchema?: UiSchema<T, F>;
151
+ uiSchema?: UiSchema<T, S, F>;
150
152
  /** Flag indicating whether there are errors associated with this field */
151
153
  hasErrors?: boolean;
152
154
  /** The `registry` object */
153
- registry: Registry<T, F>;
155
+ registry: Registry<T, S, F>;
154
156
  };
155
157
  /** The set of `Fields` stored in the `Registry` */
156
- declare type RegistryFieldsType<T = any, F = any> = {
158
+ declare type RegistryFieldsType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
157
159
  /** A `Field` indexed by `name` */
158
- [name: string]: Field<T, F>;
160
+ [name: string]: Field<T, S, F>;
159
161
  };
160
162
  /** The set of `Widgets` stored in the `Registry` */
161
- declare type RegistryWidgetsType<T = any, F = any> = {
163
+ declare type RegistryWidgetsType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
162
164
  /** A `Widget` indexed by `name` */
163
- [name: string]: Widget<T, F>;
165
+ [name: string]: Widget<T, S, F>;
164
166
  };
165
167
  /** The set of RJSF templates that can be overridden by themes or users */
166
- interface TemplatesType<T = any, F = any> {
168
+ interface TemplatesType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> {
167
169
  /** The template to use while rendering normal or fixed array fields */
168
- ArrayFieldTemplate: React.ComponentType<ArrayFieldTemplateProps<T, F>>;
170
+ ArrayFieldTemplate: React.ComponentType<ArrayFieldTemplateProps<T, S, F>>;
169
171
  /** The template to use while rendering the description for an array field */
170
- ArrayFieldDescriptionTemplate: React.ComponentType<ArrayFieldDescriptionProps<T, F>>;
172
+ ArrayFieldDescriptionTemplate: React.ComponentType<ArrayFieldDescriptionProps<T, S, F>>;
171
173
  /** The template to use while rendering an item in an array field */
172
- ArrayFieldItemTemplate: React.ComponentType<ArrayFieldTemplateItemType<T, F>>;
174
+ ArrayFieldItemTemplate: React.ComponentType<ArrayFieldTemplateItemType<T, S, F>>;
173
175
  /** The template to use while rendering the title for an array field */
174
- ArrayFieldTitleTemplate: React.ComponentType<ArrayFieldTitleProps<T, F>>;
176
+ ArrayFieldTitleTemplate: React.ComponentType<ArrayFieldTitleProps<T, S, F>>;
175
177
  /** The template to use while rendering the standard html input */
176
- BaseInputTemplate: React.ComponentType<WidgetProps<T, F>>;
178
+ BaseInputTemplate: React.ComponentType<WidgetProps<T, S, F>>;
177
179
  /** The template to use for rendering the description of a field */
178
- DescriptionFieldTemplate: React.ComponentType<DescriptionFieldProps<T, F>>;
180
+ DescriptionFieldTemplate: React.ComponentType<DescriptionFieldProps<T, S, F>>;
179
181
  /** The template to use while rendering the errors for the whole form */
180
- ErrorListTemplate: React.ComponentType<ErrorListProps<T, F>>;
182
+ ErrorListTemplate: React.ComponentType<ErrorListProps<T, S, F>>;
181
183
  /** The template to use while rendering the errors for a single field */
182
- FieldErrorTemplate: React.ComponentType<FieldErrorProps<T, F>>;
184
+ FieldErrorTemplate: React.ComponentType<FieldErrorProps<T, S, F>>;
183
185
  /** The template to use while rendering the errors for a single field */
184
- FieldHelpTemplate: React.ComponentType<FieldHelpProps<T, F>>;
186
+ FieldHelpTemplate: React.ComponentType<FieldHelpProps<T, S, F>>;
185
187
  /** The template to use while rendering a field */
186
- FieldTemplate: React.ComponentType<FieldTemplateProps<T, F>>;
188
+ FieldTemplate: React.ComponentType<FieldTemplateProps<T, S, F>>;
187
189
  /** The template to use while rendering an object */
188
- ObjectFieldTemplate: React.ComponentType<ObjectFieldTemplateProps<T, F>>;
190
+ ObjectFieldTemplate: React.ComponentType<ObjectFieldTemplateProps<T, S, F>>;
189
191
  /** The template to use for rendering the title of a field */
190
- TitleFieldTemplate: React.ComponentType<TitleFieldProps<T, F>>;
192
+ TitleFieldTemplate: React.ComponentType<TitleFieldProps<T, S, F>>;
191
193
  /** The template to use for rendering information about an unsupported field type in the schema */
192
- UnsupportedFieldTemplate: React.ComponentType<UnsupportedFieldProps<T, F>>;
194
+ UnsupportedFieldTemplate: React.ComponentType<UnsupportedFieldProps<T, S, F>>;
193
195
  /** The template to use for rendering a field that allows a user to add additional properties */
194
- WrapIfAdditionalTemplate: React.ComponentType<WrapIfAdditionalTemplateProps<T, F>>;
196
+ WrapIfAdditionalTemplate: React.ComponentType<WrapIfAdditionalTemplateProps<T, S, F>>;
195
197
  /** The set of templates associated with buttons in the form */
196
198
  ButtonTemplates: {
197
199
  /** The template to use for the main `Submit` button */
198
- SubmitButton: React.ComponentType<SubmitButtonProps<T, F>>;
200
+ SubmitButton: React.ComponentType<SubmitButtonProps<T, S, F>>;
199
201
  /** The template to use for the Add button used for AdditionalProperties and Array items */
200
- AddButton: React.ComponentType<IconButtonProps<T, F>>;
202
+ AddButton: React.ComponentType<IconButtonProps<T, S, F>>;
201
203
  /** The template to use for the Move Down button used for Array items */
202
- MoveDownButton: React.ComponentType<IconButtonProps<T, F>>;
204
+ MoveDownButton: React.ComponentType<IconButtonProps<T, S, F>>;
203
205
  /** The template to use for the Move Up button used for Array items */
204
- MoveUpButton: React.ComponentType<IconButtonProps<T, F>>;
206
+ MoveUpButton: React.ComponentType<IconButtonProps<T, S, F>>;
205
207
  /** The template to use for the Remove button used for AdditionalProperties and Array items */
206
- RemoveButton: React.ComponentType<IconButtonProps<T, F>>;
208
+ RemoveButton: React.ComponentType<IconButtonProps<T, S, F>>;
207
209
  };
208
210
  }
209
211
  /** The object containing the registered core, theme and custom fields and widgets as well as the root schema, form
210
212
  * context, schema utils and templates.
211
213
  */
212
- interface Registry<T = any, F = any> {
214
+ interface Registry<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> {
213
215
  /** The set of all fields used by the `Form`. Includes fields from `core`, theme-specific fields and any custom
214
216
  * registered fields
215
217
  */
216
- fields: RegistryFieldsType<T, F>;
218
+ fields: RegistryFieldsType<T, S, F>;
217
219
  /** The set of templates used by the `Form`. Includes templates from `core`, theme-specific fields and any custom
218
220
  * registered templates
219
221
  */
220
- templates: TemplatesType<T, F>;
222
+ templates: TemplatesType<T, S, F>;
221
223
  /** The set of all widgets used by the `Form`. Includes widgets from `core`, theme-specific widgets and any custom
222
224
  * registered widgets
223
225
  */
224
- widgets: RegistryWidgetsType<T, F>;
226
+ widgets: RegistryWidgetsType<T, S, F>;
225
227
  /** The `formContext` object that was passed to `Form` */
226
228
  formContext: F;
227
229
  /** The root schema, as passed to the `Form`, which can contain referenced definitions */
228
- rootSchema: RJSFSchema;
230
+ rootSchema: S;
229
231
  /** The current implementation of the `SchemaUtilsType` (from `@rjsf/utils`) in use by the `Form`. Used to call any
230
232
  * of the validation-schema-based utility functions
231
233
  */
232
- schemaUtils: SchemaUtilsType<T>;
234
+ schemaUtils: SchemaUtilsType<T, S>;
233
235
  }
234
236
  /** The properties that are passed to a Field implementation */
235
- interface FieldProps<T = any, F = any> extends GenericObjectType, Pick<React.HTMLAttributes<HTMLElement>, Exclude<keyof React.HTMLAttributes<HTMLElement>, "onBlur" | "onFocus" | "onChange">> {
237
+ 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">> {
236
238
  /** The JSON subschema object for this field */
237
- schema: RJSFSchema;
239
+ schema: S;
238
240
  /** The uiSchema for this field */
239
- uiSchema?: UiSchema<T, F>;
241
+ uiSchema?: UiSchema<T, S, F>;
240
242
  /** The tree of unique ids for every child field */
241
243
  idSchema: IdSchema<T>;
242
244
  /** The data for this field */
@@ -244,7 +246,7 @@ interface FieldProps<T = any, F = any> extends GenericObjectType, Pick<React.HTM
244
246
  /** The tree of errors for this field and its children */
245
247
  errorSchema?: ErrorSchema<T>;
246
248
  /** The field change event handler; called with the updated form data and an optional `ErrorSchema` */
247
- onChange: (newFormData: T, es?: ErrorSchema<T>) => any;
249
+ onChange: (newFormData: T, es?: ErrorSchema<T>, id?: string) => any;
248
250
  /** The input blur event handler; call it with the field id and value */
249
251
  onBlur: (id: string, value: any) => void;
250
252
  /** The input focus event handler; call it with the field id and value */
@@ -264,12 +266,12 @@ interface FieldProps<T = any, F = any> extends GenericObjectType, Pick<React.HTM
264
266
  /** The unique name of the field, usually derived from the name of the property in the JSONSchema */
265
267
  name: string;
266
268
  /** The `registry` object */
267
- registry: Registry<T, F>;
269
+ registry: Registry<T, S, F>;
268
270
  }
269
271
  /** The definition of a React-based Field component */
270
- declare type Field<T = any, F = any> = React.ComponentType<FieldProps<T, F>>;
272
+ declare type Field<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = React.ComponentType<FieldProps<T, S, F>>;
271
273
  /** The properties that are passed to a FieldTemplate implementation */
272
- declare type FieldTemplateProps<T = any, F = any> = {
274
+ declare type FieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
273
275
  /** The id of the field in the hierarchy. You can use it to render a label targeting the wrapped widget */
274
276
  id: string;
275
277
  /** A string containing the base CSS classes, merged with any custom ones defined in your uiSchema */
@@ -309,69 +311,77 @@ declare type FieldTemplateProps<T = any, F = any> = {
309
311
  */
310
312
  displayLabel?: boolean;
311
313
  /** The schema object for this field */
312
- schema: RJSFSchema;
314
+ schema: S;
313
315
  /** The uiSchema object for this field */
314
- uiSchema?: UiSchema<T, F>;
316
+ uiSchema?: UiSchema<T, S, F>;
315
317
  /** The `formContext` object that was passed to `Form` */
316
318
  formContext?: F;
317
319
  /** The formData for this field */
318
320
  formData: T;
319
321
  /** The value change event handler; Can be called with a new value to change the value for this field */
320
- onChange: (value: T) => void;
322
+ onChange: FieldProps["onChange"];
321
323
  /** The key change event handler; Called when the key associated with a field is changed for an additionalProperty */
322
324
  onKeyChange: (value: string) => () => void;
323
325
  /** The property drop/removal event handler; Called when a field is removed in an additionalProperty context */
324
326
  onDropPropertyClick: (value: string) => () => void;
325
327
  /** The `registry` object */
326
- registry: Registry<T, F>;
328
+ registry: Registry<T, S, F>;
327
329
  };
328
330
  /** The properties that are passed to the `UnsupportedFieldTemplate` implementation */
329
- declare type UnsupportedFieldProps<T = any, F = any> = {
331
+ declare type UnsupportedFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
330
332
  /** The schema object for this field */
331
- schema: RJSFSchema;
333
+ schema: S;
332
334
  /** The tree of unique ids for every child field */
333
335
  idSchema?: IdSchema<T>;
334
336
  /** The reason why the schema field has an unsupported type */
335
337
  reason: string;
336
338
  /** The `registry` object */
337
- registry: Registry<T, F>;
339
+ registry: Registry<T, S, F>;
338
340
  };
339
341
  /** The properties that are passed to a `TitleFieldTemplate` implementation */
340
- declare type TitleFieldProps<T = any, F = any> = {
342
+ declare type TitleFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
341
343
  /** The id of the field title in the hierarchy */
342
344
  id: string;
343
345
  /** The title for the field being rendered */
344
346
  title: string;
347
+ /** The schema object for the field being titled */
348
+ schema: S;
345
349
  /** The uiSchema object for this title field */
346
- uiSchema?: UiSchema<T, F>;
350
+ uiSchema?: UiSchema<T, S, F>;
347
351
  /** A boolean value stating if the field is required */
348
352
  required?: boolean;
349
353
  /** The `registry` object */
350
- registry: Registry<T, F>;
354
+ registry: Registry<T, S, F>;
351
355
  };
352
356
  /** The properties that are passed to a `DescriptionFieldTemplate` implementation */
353
- declare type DescriptionFieldProps<T = any, F = any> = {
357
+ declare type DescriptionFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
354
358
  /** The id of the field description in the hierarchy */
355
359
  id: string;
360
+ /** The schema object for the field being described */
361
+ schema: S;
362
+ /** The uiSchema object for this description field */
363
+ uiSchema?: UiSchema<T, S, F>;
356
364
  /** The description of the field being rendered */
357
365
  description: string | React.ReactElement;
358
366
  /** The `registry` object */
359
- registry: Registry<T, F>;
367
+ registry: Registry<T, S, F>;
360
368
  };
361
369
  /** The properties that are passed to a `ArrayFieldTitleTemplate` implementation */
362
- declare type ArrayFieldTitleProps<T = any, F = any> = Pick<TitleFieldProps<T, F>, "title" | "uiSchema" | "required" | "registry"> & {
370
+ declare type ArrayFieldTitleProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Omit<TitleFieldProps<T, S, F>, "id" | "title"> & {
371
+ /** The title for the field being rendered */
372
+ title?: string;
363
373
  /** The idSchema of the field in the hierarchy */
364
374
  idSchema: IdSchema<T>;
365
375
  };
366
376
  /** The properties that are passed to a `ArrayFieldDescriptionTemplate` implementation */
367
- declare type ArrayFieldDescriptionProps<T = any, F = any> = Pick<DescriptionFieldProps<T, F>, "description" | "registry"> & {
377
+ declare type ArrayFieldDescriptionProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Omit<DescriptionFieldProps<T, S, F>, "id" | "description"> & {
378
+ /** The description of the field being rendered */
379
+ description?: string | React.ReactElement;
368
380
  /** The idSchema of the field in the hierarchy */
369
381
  idSchema: IdSchema<T>;
370
- /** The uiSchema object for this description field */
371
- uiSchema?: UiSchema<T, F>;
372
382
  };
373
383
  /** The properties of each element in the ArrayFieldTemplateProps.items array */
374
- declare type ArrayFieldTemplateItemType<T = any, F = any> = {
384
+ declare type ArrayFieldTemplateItemType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
375
385
  /** The html for the item's content */
376
386
  children: React.ReactElement;
377
387
  /** The className string */
@@ -399,12 +409,12 @@ declare type ArrayFieldTemplateItemType<T = any, F = any> = {
399
409
  /** A stable, unique key for the array item */
400
410
  key: string;
401
411
  /** The uiSchema object for this field */
402
- uiSchema?: UiSchema<T, F>;
412
+ uiSchema?: UiSchema<T, S, F>;
403
413
  /** The `registry` object */
404
- registry: Registry<T, F>;
414
+ registry: Registry<T, S, F>;
405
415
  };
406
416
  /** The properties that are passed to an ArrayFieldTemplate implementation */
407
- declare type ArrayFieldTemplateProps<T = any, F = any> = {
417
+ declare type ArrayFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
408
418
  /** A boolean value stating whether new elements can be added to the array */
409
419
  canAdd?: boolean;
410
420
  /** The className string */
@@ -414,7 +424,7 @@ declare type ArrayFieldTemplateProps<T = any, F = any> = {
414
424
  /** An object containing the id for this object & ids for its properties */
415
425
  idSchema: IdSchema<T>;
416
426
  /** An array of objects representing the items in the array */
417
- items: ArrayFieldTemplateItemType<T, F>[];
427
+ items: ArrayFieldTemplateItemType<T, S, F>[];
418
428
  /** A function that adds a new item to the array */
419
429
  onAddClick: (event?: any) => void;
420
430
  /** A boolean value stating if the array is read-only */
@@ -424,9 +434,9 @@ declare type ArrayFieldTemplateProps<T = any, F = any> = {
424
434
  /** A boolean value stating if the field is hiding its errors */
425
435
  hideError?: boolean;
426
436
  /** The schema object for this array */
427
- schema: RJSFSchema;
437
+ schema: S;
428
438
  /** The uiSchema object for this array field */
429
- uiSchema?: UiSchema<T, F>;
439
+ uiSchema?: UiSchema<T, S, F>;
430
440
  /** A string value containing the title for the array */
431
441
  title: string;
432
442
  /** The `formContext` object that was passed to Form */
@@ -436,7 +446,7 @@ declare type ArrayFieldTemplateProps<T = any, F = any> = {
436
446
  /** An array of strings listing all generated error messages from encountered errors for this widget */
437
447
  rawErrors?: string[];
438
448
  /** The `registry` object */
439
- registry: Registry<T, F>;
449
+ registry: Registry<T, S, F>;
440
450
  };
441
451
  /** The properties of each element in the ObjectFieldTemplateProps.properties array */
442
452
  declare type ObjectFieldTemplatePropertyType = {
@@ -452,7 +462,7 @@ declare type ObjectFieldTemplatePropertyType = {
452
462
  hidden: boolean;
453
463
  };
454
464
  /** The properties that are passed to an ObjectFieldTemplate implementation */
455
- declare type ObjectFieldTemplateProps<T = any, F = any> = {
465
+ declare type ObjectFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
456
466
  /** A string value containing the title for the object */
457
467
  title: string;
458
468
  /** A string value containing the description for the object */
@@ -462,7 +472,7 @@ declare type ObjectFieldTemplateProps<T = any, F = any> = {
462
472
  /** An array of objects representing the properties in the object */
463
473
  properties: ObjectFieldTemplatePropertyType[];
464
474
  /** Returns a function that adds a new property to the object (to be used with additionalProperties) */
465
- onAddClick: (schema: RJSFSchema) => () => void;
475
+ onAddClick: (schema: S) => () => void;
466
476
  /** A boolean value stating if the object is read-only */
467
477
  readonly?: boolean;
468
478
  /** A boolean value stating if the object is required */
@@ -470,9 +480,9 @@ declare type ObjectFieldTemplateProps<T = any, F = any> = {
470
480
  /** A boolean value stating if the field is hiding its errors */
471
481
  hideError?: boolean;
472
482
  /** The schema object for this object */
473
- schema: RJSFSchema;
483
+ schema: S;
474
484
  /** The uiSchema object for this object field */
475
- uiSchema?: UiSchema<T, F>;
485
+ uiSchema?: UiSchema<T, S, F>;
476
486
  /** An object containing the id for this object & ids for its properties */
477
487
  idSchema: IdSchema<T>;
478
488
  /** The form data for the object */
@@ -480,21 +490,21 @@ declare type ObjectFieldTemplateProps<T = any, F = any> = {
480
490
  /** The `formContext` object that was passed to Form */
481
491
  formContext?: F;
482
492
  /** The `registry` object */
483
- registry: Registry<T, F>;
493
+ registry: Registry<T, S, F>;
484
494
  };
485
495
  /** The properties that are passed to a WrapIfAdditionalTemplate implementation */
486
- declare type WrapIfAdditionalTemplateProps<T = any, F = any> = {
496
+ declare type WrapIfAdditionalTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
487
497
  /** The field or widget component instance for this field row */
488
498
  children: React.ReactNode;
489
- } & Pick<FieldTemplateProps<T, F>, "id" | "classNames" | "label" | "required" | "readonly" | "disabled" | "schema" | "uiSchema" | "onKeyChange" | "onDropPropertyClick" | "registry">;
499
+ } & Pick<FieldTemplateProps<T, S, F>, "id" | "classNames" | "label" | "required" | "readonly" | "disabled" | "schema" | "uiSchema" | "onKeyChange" | "onDropPropertyClick" | "registry">;
490
500
  /** The properties that are passed to a Widget implementation */
491
- interface WidgetProps<T = any, F = any> extends GenericObjectType, Pick<React.HTMLAttributes<HTMLElement>, Exclude<keyof React.HTMLAttributes<HTMLElement>, "onBlur" | "onFocus">> {
501
+ 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">> {
492
502
  /** The generated id for this widget */
493
503
  id: string;
494
504
  /** The JSONSchema subschema object for this widget */
495
- schema: RJSFSchema;
505
+ schema: S;
496
506
  /** The uiSchema for this widget */
497
- uiSchema?: UiSchema<T, F>;
507
+ uiSchema?: UiSchema<T, S, F>;
498
508
  /** The current value for this widget */
499
509
  value: any;
500
510
  /** The required status of this widget */
@@ -512,7 +522,7 @@ interface WidgetProps<T = any, F = any> extends GenericObjectType, Pick<React.HT
512
522
  /** A map of UI Options passed as a prop to the component, including the optional `enumOptions`
513
523
  * which is a special case on top of `UIOptionsType` needed only by widgets
514
524
  */
515
- options: NonNullable<UIOptionsType<T, F>> & {
525
+ options: NonNullable<UIOptionsType<T, S, F>> & {
516
526
  /** The enum options list for a type that supports them */
517
527
  enumOptions?: EnumOptionsType[];
518
528
  };
@@ -531,23 +541,23 @@ interface WidgetProps<T = any, F = any> extends GenericObjectType, Pick<React.HT
531
541
  /** An array of strings listing all generated error messages from encountered errors for this widget */
532
542
  rawErrors?: string[];
533
543
  /** The `registry` object */
534
- registry: Registry<T, F>;
544
+ registry: Registry<T, S, F>;
535
545
  }
536
546
  /** The definition of a React-based Widget component */
537
- declare type Widget<T = any, F = any> = React.ComponentType<WidgetProps<T, F>>;
547
+ declare type Widget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = React.ComponentType<WidgetProps<T, S, F>>;
538
548
  /** The type that defines the props used by the Submit button */
539
- declare type SubmitButtonProps<T = any, F = any> = {
549
+ declare type SubmitButtonProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
540
550
  /** The uiSchema for this widget */
541
- uiSchema?: UiSchema<T, F>;
551
+ uiSchema?: UiSchema<T, S, F>;
542
552
  };
543
553
  /** The type that defines the props for an Icon button, extending from a basic HTML button attributes */
544
- declare type IconButtonProps<T = any, F = any> = React.ButtonHTMLAttributes<HTMLButtonElement> & {
554
+ declare type IconButtonProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = React.ButtonHTMLAttributes<HTMLButtonElement> & {
545
555
  /** An alternative specification for the type of the icon button */
546
556
  iconType?: string;
547
557
  /** The name representation or actual react element implementation for the icon */
548
558
  icon?: string | React.ReactElement;
549
559
  /** The uiSchema for this widget */
550
- uiSchema?: UiSchema<T, F>;
560
+ uiSchema?: UiSchema<T, S, F>;
551
561
  };
552
562
  /** The type that defines how to change the behavior of the submit button for the form */
553
563
  declare type UISchemaSubmitButtonOptions = {
@@ -564,13 +574,13 @@ declare type UISchemaSubmitButtonOptions = {
564
574
  };
565
575
  };
566
576
  /** This type represents an element used to render an enum option */
567
- declare type EnumOptionsType = {
577
+ declare type EnumOptionsType<S extends StrictRJSFSchema = RJSFSchema> = {
568
578
  /** The value for the enum option */
569
579
  value: any;
570
580
  /** The label for the enum options */
571
581
  label: string;
572
582
  /** The schema associated with the enum option when the option represents a `oneOf` or `anyOf` choice */
573
- schema?: RJSFSchema;
583
+ schema?: S;
574
584
  };
575
585
  /** This type remaps the keys of `Type` to prepend `ui:` onto them. As a result it does not need to be exported */
576
586
  declare type MakeUIType<Type> = {
@@ -579,7 +589,7 @@ declare type MakeUIType<Type> = {
579
589
  /** This type represents all the known supported options in the `ui:options` property, kept separate in order to
580
590
  * remap the keys. It also contains all the properties, optionally, of `TemplatesType` except "ButtonTemplates"
581
591
  */
582
- declare type UIOptionsBaseType<T = any, F = any> = Partial<Omit<TemplatesType<T, F>, "ButtonTemplates">> & {
592
+ declare type UIOptionsBaseType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Partial<Omit<TemplatesType<T, S, F>, "ButtonTemplates">> & {
583
593
  /** Any classnames that the user wants to be applied to a field in the ui */
584
594
  classNames?: string;
585
595
  /** We know that for title, it will be a string, if it is provided */
@@ -627,29 +637,29 @@ declare type UIOptionsBaseType<T = any, F = any> = Partial<Omit<TemplatesType<T,
627
637
  /** Allows RJSF to override the default widget implementation by specifying either the name of a widget that is used
628
638
  * to look up an implementation from the `widgets` list or an actual one-off widget implementation itself
629
639
  */
630
- widget?: Widget<T, F> | string;
640
+ widget?: Widget<T, S, F> | string;
631
641
  /** When using `additionalProperties`, key collision is prevented by appending a unique integer to the duplicate key.
632
642
  * This option allows you to change the separator between the original key name and the integer. Default is "-"
633
643
  */
634
644
  duplicateKeySuffixSeparator?: string;
635
645
  };
636
646
  /** The type that represents the Options potentially provided by `ui:options` */
637
- declare type UIOptionsType<T = any, F = any> = UIOptionsBaseType<T, F> & {
647
+ declare type UIOptionsType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = UIOptionsBaseType<T, S, F> & {
638
648
  /** Anything else will be one of these types */
639
649
  [key: string]: boolean | number | string | object | any[] | null | undefined;
640
650
  };
641
651
  /** Type describing the well-known properties of the `UiSchema` while also supporting all user defined properties,
642
652
  * starting with `ui:`.
643
653
  */
644
- declare type UiSchema<T = any, F = any> = GenericObjectType & MakeUIType<UIOptionsBaseType<T, F>> & {
654
+ declare type UiSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = GenericObjectType & MakeUIType<UIOptionsBaseType<T, S, F>> & {
645
655
  /** Allows the form to generate a unique prefix for the `Form`'s root prefix */
646
656
  "ui:rootFieldId"?: string;
647
657
  /** Allows RJSF to override the default field implementation by specifying either the name of a field that is used
648
658
  * to look up an implementation from the `fields` list or an actual one-off `Field` component implementation itself
649
659
  */
650
- "ui:field"?: Field<T, F> | string;
651
- /** An object that contains all of the potential UI options in a single object */
652
- "ui:options"?: UIOptionsType<T, F>;
660
+ "ui:field"?: Field<T, S, F> | string;
661
+ /** An object that contains all the potential UI options in a single object */
662
+ "ui:options"?: UIOptionsType<T, S, F>;
653
663
  };
654
664
  /** A `CustomValidator` function takes in a `formData` and `errors` object and returns the given `errors` object back,
655
665
  * while potentially adding additional messages to the `errors`
@@ -669,7 +679,7 @@ declare type ValidationData<T> = {
669
679
  /** The interface that describes the validation functions that are provided by a Validator implementation used by the
670
680
  * schema utilities.
671
681
  */
672
- interface ValidatorType<T = any> {
682
+ interface ValidatorType<T = any, S extends StrictRJSFSchema = RJSFSchema> {
673
683
  /** This function processes the `formData` with an optional user contributed `customValidate` function, which receives
674
684
  * the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also
675
685
  * supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and
@@ -680,7 +690,7 @@ interface ValidatorType<T = any> {
680
690
  * @param [customValidate] - An optional function that is used to perform custom validation
681
691
  * @param [transformErrors] - An optional function that is used to transform errors after AJV validation
682
692
  */
683
- validateFormData(formData: T, schema: RJSFSchema, customValidate?: CustomValidator<T>, transformErrors?: ErrorTransformer): ValidationData<T>;
693
+ validateFormData(formData: T | undefined, schema: S, customValidate?: CustomValidator<T>, transformErrors?: ErrorTransformer): ValidationData<T>;
684
694
  /** Converts an `errorSchema` into a list of `RJSFValidationErrors`
685
695
  *
686
696
  * @param errorSchema - The `ErrorSchema` instance to convert
@@ -692,22 +702,32 @@ interface ValidatorType<T = any> {
692
702
  * false.
693
703
  *
694
704
  * @param schema - The schema against which to validate the form data * @param schema
695
- * @param formData- - The form data to validate
705
+ * @param formData - The form data to validate
696
706
  * @param rootSchema - The root schema used to provide $ref resolutions
697
707
  */
698
- isValid(schema: RJSFSchema, formData: T, rootSchema: RJSFSchema): boolean;
708
+ isValid(schema: S, formData: T, rootSchema: S): boolean;
709
+ /** Runs the pure validation of the `schema` and `formData` without any of the RJSF functionality. Provided for use
710
+ * by the playground. Returns the `errors` from the validation
711
+ *
712
+ * @param schema - The schema against which to validate the form data * @param schema
713
+ * @param formData - The form data to validate
714
+ */
715
+ rawValidation<Result = any>(schema: S, formData?: T): {
716
+ errors?: Result[];
717
+ validationError?: Error;
718
+ };
699
719
  }
700
720
  /** The `SchemaUtilsType` interface provides a wrapper around the publicly exported APIs in the `@rjsf/utils/schema`
701
721
  * directory such that one does not have to explicitly pass the `validator` or `rootSchema` to each method. Since both
702
722
  * the `validator` and `rootSchema` generally does not change across a `Form`, this allows for providing a simplified
703
723
  * set of APIs to the `@rjsf/core` components and the various themes as well.
704
724
  */
705
- interface SchemaUtilsType<T = any> {
725
+ interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> {
706
726
  /** Returns the `ValidatorType` in the `SchemaUtilsType`
707
727
  *
708
728
  * @returns - The `ValidatorType`
709
729
  */
710
- getValidator(): ValidatorType<T>;
730
+ getValidator(): ValidatorType<T, S>;
711
731
  /** Determines whether either the `validator` and `rootSchema` differ from the ones associated with this instance of
712
732
  * the `SchemaUtilsType`. If either `validator` or `rootSchema` are falsy, then return false to prevent the creation
713
733
  * of a new `SchemaUtilsType` with incomplete properties.
@@ -716,7 +736,7 @@ interface SchemaUtilsType<T = any> {
716
736
  * @param rootSchema - The root schema that will be compared against the current one
717
737
  * @returns - True if the `SchemaUtilsType` differs from the given `validator` or `rootSchema`
718
738
  */
719
- doesSchemaUtilsDiffer(validator: ValidatorType, rootSchema: RJSFSchema): boolean;
739
+ doesSchemaUtilsDiffer(validator: ValidatorType<T, S>, rootSchema: S): boolean;
720
740
  /** Returns the superset of `formData` that includes the given set updated to include any missing fields that have
721
741
  * computed to have defaults provided in the `schema`.
722
742
  *
@@ -725,7 +745,7 @@ interface SchemaUtilsType<T = any> {
725
745
  * @param [includeUndefinedValues=false] - Optional flag, if true, cause undefined values to be added as defaults
726
746
  * @returns - The resulting `formData` with all the defaults provided
727
747
  */
728
- getDefaultFormState(schema: RJSFSchema, formData?: T, includeUndefinedValues?: boolean): T | T[] | undefined;
748
+ getDefaultFormState(schema: S, formData?: T, includeUndefinedValues?: boolean): T | T[] | undefined;
729
749
  /** Determines whether the combination of `schema` and `uiSchema` properties indicates that the label for the `schema`
730
750
  * should be displayed in a UI.
731
751
  *
@@ -733,39 +753,38 @@ interface SchemaUtilsType<T = any> {
733
753
  * @param [uiSchema] - The UI schema from which to derive potentially displayable information
734
754
  * @returns - True if the label should be displayed or false if it should not
735
755
  */
736
- getDisplayLabel<F = any>(schema: RJSFSchema, uiSchema?: UiSchema<T, F>): boolean;
756
+ getDisplayLabel(schema: S, uiSchema?: UiSchema<T, S, F>): boolean;
737
757
  /** Given the `formData` and list of `options`, attempts to find the index of the option that best matches the data.
738
758
  *
739
759
  * @param formData - The current formData, if any, onto which to provide any missing defaults
740
760
  * @param options - The list of options to find a matching options from
741
761
  * @returns - The index of the matched option or 0 if none is available
742
762
  */
743
- getMatchingOption(formData: T, options: RJSFSchema[]): number;
763
+ getMatchingOption(formData: T, options: S[]): number;
744
764
  /** Checks to see if the `schema` and `uiSchema` combination represents an array of files
745
765
  *
746
766
  * @param schema - The schema for which check for array of files flag is desired
747
767
  * @param [uiSchema] - The UI schema from which to check the widget
748
768
  * @returns - True if schema/uiSchema contains an array of files, otherwise false
749
769
  */
750
- isFilesArray<F = any>(schema: RJSFSchema, uiSchema?: UiSchema<T, F>): boolean;
770
+ isFilesArray(schema: S, uiSchema?: UiSchema<T, S, F>): boolean;
751
771
  /** Checks to see if the `schema` combination represents a multi-select
752
772
  *
753
773
  * @param schema - The schema for which check for a multi-select flag is desired
754
774
  * @returns - True if schema contains a multi-select, otherwise false
755
775
  */
756
- isMultiSelect(schema: RJSFSchema): boolean;
776
+ isMultiSelect(schema: S): boolean;
757
777
  /** Checks to see if the `schema` combination represents a select
758
778
  *
759
779
  * @param schema - The schema for which check for a select flag is desired
760
780
  * @returns - True if schema contains a select, otherwise false
761
781
  */
762
- isSelect(schema: RJSFSchema): boolean;
782
+ isSelect(schema: S): boolean;
763
783
  /** Merges the errors in `additionalErrorSchema` into the existing `validationData` by combining the hierarchies in the
764
784
  * two `ErrorSchema`s and then appending the error list from the `additionalErrorSchema` obtained by calling
765
785
  * `validator.toErrorList()` onto the `errors` in the `validationData`. If no `additionalErrorSchema` is passed, then
766
786
  * `validationData` is returned.
767
787
  *
768
- * @param validator - The validator used to convert an ErrorSchema to a list of errors
769
788
  * @param validationData - The current `ValidationData` into which to merge the additional errors
770
789
  * @param [additionalErrorSchema] - The additional set of errors
771
790
  * @returns - The `validationData` with the additional errors from `additionalErrorSchema` merged into it, if provided.
@@ -776,10 +795,10 @@ interface SchemaUtilsType<T = any> {
776
795
  * recursive resolution.
777
796
  *
778
797
  * @param schema - The schema for which retrieving a schema is desired
779
- * @param [rawFormData] - The current formData, if any, to assist retrieving a schema
798
+ * @param [formData] - The current formData, if any, to assist retrieving a schema
780
799
  * @returns - The schema having its conditions, additional properties, references and dependencies resolved
781
800
  */
782
- retrieveSchema(schema: RJSFSchema, formData?: T): RJSFSchema;
801
+ retrieveSchema(schema: S, formData?: T): S;
783
802
  /** Generates an `IdSchema` object for the `schema`, recursively
784
803
  *
785
804
  * @param schema - The schema for which the display label flag is desired
@@ -789,7 +808,7 @@ interface SchemaUtilsType<T = any> {
789
808
  * @param [idSeparator='_'] - The separator to use for the path segments in the id
790
809
  * @returns - The `IdSchema` object for the `schema`
791
810
  */
792
- toIdSchema(schema: RJSFSchema, id?: string, formData?: T, idPrefix?: string, idSeparator?: string): IdSchema<T>;
811
+ toIdSchema(schema: S, id?: string, formData?: T, idPrefix?: string, idSeparator?: string): IdSchema<T>;
793
812
  /** Generates an `PathSchema` object for the `schema`, recursively
794
813
  *
795
814
  * @param schema - The schema for which the display label flag is desired
@@ -797,7 +816,7 @@ interface SchemaUtilsType<T = any> {
797
816
  * @param [formData] - The current formData, if any, onto which to provide any missing defaults
798
817
  * @returns - The `PathSchema` object for the `schema`
799
818
  */
800
- toPathSchema(schema: RJSFSchema, name?: string, formData?: T): PathSchema<T>;
819
+ toPathSchema(schema: S, name?: string, formData?: T): PathSchema<T>;
801
820
  }
802
821
 
803
822
  /** Checks the schema to see if it is allowing additional items, by verifying that `schema.additionalItems` is an
@@ -806,7 +825,7 @@ interface SchemaUtilsType<T = any> {
806
825
  * @param schema - The schema object to check
807
826
  * @returns - True if additional items is allowed, otherwise false
808
827
  */
809
- declare function allowAdditionalItems(schema: RJSFSchema): boolean;
828
+ declare function allowAdditionalItems<S extends StrictRJSFSchema = RJSFSchema>(schema: S): boolean;
810
829
 
811
830
  /** Attempts to convert the string into a number. If an empty string is provided, then `undefined` is returned. If a
812
831
  * `null` is provided, it is returned. If the string ends in a `.` then the string is returned because the user may be
@@ -828,7 +847,7 @@ declare function asNumber(value: string | null): string | number | null | undefi
828
847
  * @param [formData] - The formData for the field
829
848
  * @returns - True if the schema element has additionalProperties, is expandable, and not at the maxProperties limit
830
849
  */
831
- declare function canExpand<T = any, F = any>(schema: RJSFSchema, uiSchema?: UiSchema<T, F>, formData?: T): boolean;
850
+ declare function canExpand<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(schema: RJSFSchema, uiSchema?: UiSchema<T, S, F>, formData?: T): boolean;
832
851
 
833
852
  /** Creates a `SchemaUtilsType` interface that is based around the given `validator` and `rootSchema` parameters. The
834
853
  * resulting interface implementation will forward the `validator` and `rootSchema` to all the wrapped APIs.
@@ -837,7 +856,7 @@ declare function canExpand<T = any, F = any>(schema: RJSFSchema, uiSchema?: UiSc
837
856
  * @param rootSchema - The root schema that will be forwarded to all the APIs
838
857
  * @returns - An implementation of a `SchemaUtilsType` interface
839
858
  */
840
- declare function createSchemaUtils<T = any>(validator: ValidatorType, rootSchema: RJSFSchema): SchemaUtilsType<T>;
859
+ declare function createSchemaUtils<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S>, rootSchema: S): SchemaUtilsType<T, S, F>;
841
860
 
842
861
  /** Given the `FileReader.readAsDataURL()` based `dataURI` extracts that data into an actual Blob along with the name
843
862
  * of that Blob if provided in the URL. If no name is provided, then the name falls back to `unknown`.
@@ -868,7 +887,7 @@ declare function deepEquals(a: any, b: any): boolean;
868
887
  * @returns - The sub-schema within the `rootSchema` which matches the `$ref` if it exists
869
888
  * @throws - Error indicating that no schema for that reference exists
870
889
  */
871
- declare function findSchemaDefinition($ref?: string, rootSchema?: RJSFSchema): RJSFSchema;
890
+ declare function findSchemaDefinition<S extends StrictRJSFSchema = RJSFSchema>($ref?: string, rootSchema?: S): S;
872
891
 
873
892
  /** Using the `schema`, `defaultType` and `options`, extract out the props for the <input> element that make sense.
874
893
  *
@@ -878,7 +897,7 @@ declare function findSchemaDefinition($ref?: string, rootSchema?: RJSFSchema): R
878
897
  * @param [autoDefaultStepAny=true] - Determines whether to auto-default step=any when the type is number and no step
879
898
  * @returns - The extracted `InputPropsType` object
880
899
  */
881
- declare function getInputProps<T = any, F = any>(schema: RJSFSchema, defaultType?: string, options?: UIOptionsType<T, F>, autoDefaultStepAny?: boolean): InputPropsType;
900
+ declare function getInputProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(schema: RJSFSchema, defaultType?: string, options?: UIOptionsType<T, S, F>, autoDefaultStepAny?: boolean): InputPropsType;
882
901
 
883
902
  /** Gets the type of a given `schema`. If the type is not explicitly defined, then an attempt is made to infer it from
884
903
  * other elements of the schema as follows:
@@ -891,14 +910,14 @@ declare function getInputProps<T = any, F = any>(schema: RJSFSchema, defaultType
891
910
  * @param schema - The schema for which to get the type
892
911
  * @returns - The type of the schema
893
912
  */
894
- declare function getSchemaType(schema: RJSFSchema): string | string[] | undefined;
913
+ declare function getSchemaType<S extends StrictRJSFSchema = RJSFSchema>(schema: S): string | string[] | undefined;
895
914
 
896
915
  /** Extracts any `ui:submitButtonOptions` from the `uiSchema` and merges them onto the `DEFAULT_OPTIONS`
897
916
  *
898
917
  * @param [uiSchema={}] - the UI Schema from which to extract submit button props
899
918
  * @returns - The merging of the `DEFAULT_OPTIONS` with any custom ones
900
919
  */
901
- declare function getSubmitButtonOptions<T = any, F = any>(uiSchema?: UiSchema<T, F>): UISchemaSubmitButtonOptions;
920
+ declare function getSubmitButtonOptions<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(uiSchema?: UiSchema<T, S, F>): UISchemaSubmitButtonOptions;
902
921
 
903
922
  /** Returns the template with the given `name` from either the `uiSchema` if it is defined or from the `registry`
904
923
  * otherwise. NOTE, since `ButtonTemplates` are not overridden in `uiSchema` only those in the `registry` are returned.
@@ -908,15 +927,15 @@ declare function getSubmitButtonOptions<T = any, F = any>(uiSchema?: UiSchema<T,
908
927
  * @param [uiOptions={}] - The `UIOptionsType` from which to read an alternate template
909
928
  * @returns - The template from either the `uiSchema` or `registry` for the `name`
910
929
  */
911
- declare function getTemplate<Name extends keyof TemplatesType<T, F>, T = any, F = any>(name: Name, registry: Registry<T, F>, uiOptions?: UIOptionsType<T, F>): TemplatesType<T, F>[Name];
930
+ 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];
912
931
 
913
932
  /** Get all passed options from ui:options, and ui:<optionName>, returning them in an object with the `ui:`
914
933
  * stripped off.
915
934
  *
916
935
  * @param [uiSchema={}] - The UI Schema from which to get any `ui:xxx` options
917
- * @returns - An object containing all of the `ui:xxx` options with the stripped off
936
+ * @returns - An object containing all the `ui:xxx` options with the stripped off
918
937
  */
919
- declare function getUiOptions<T = any, F = any>(uiSchema?: UiSchema<T, F>): UIOptionsType<T, F>;
938
+ declare function getUiOptions<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(uiSchema?: UiSchema<T, S, F>): UIOptionsType<T, S, F>;
920
939
 
921
940
  /** Given a schema representing a field to render and either the name or actual `Widget` implementation, returns the
922
941
  * React component that is used to render the widget. If the `widget` is already a React component, then it is wrapped
@@ -929,7 +948,7 @@ declare function getUiOptions<T = any, F = any>(uiSchema?: UiSchema<T, F>): UIOp
929
948
  * @returns - The `Widget` component to use
930
949
  * @throws - An error if there is no `Widget` component that can be returned
931
950
  */
932
- declare function getWidget<T = any, F = any>(schema: RJSFSchema, widget?: Widget<T, F> | string, registeredWidgets?: RegistryWidgetsType<T, F>): Widget<T, F>;
951
+ declare function getWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(schema: RJSFSchema, widget?: Widget<T, S, F> | string, registeredWidgets?: RegistryWidgetsType<T, S, F>): Widget<T, S, F>;
933
952
 
934
953
  /** Given a specific `value` attempts to guess the type of a schema element. In the case where we have to implicitly
935
954
  * create a schema, it is useful to know what type to use based on the data we are defining.
@@ -947,7 +966,7 @@ declare function guessType(value: any): "array" | "string" | "null" | "boolean"
947
966
  * @param [registeredWidgets={}] - A registry of widget name to `Widget` implementation
948
967
  * @returns - True if the widget exists, false otherwise
949
968
  */
950
- declare function hasWidget<T = any, F = any>(schema: RJSFSchema, widget: Widget<T, F> | string, registeredWidgets?: RegistryWidgetsType<T, F>): boolean;
969
+ 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;
951
970
 
952
971
  /** This function checks if the given `schema` matches a single constant value. This happens when either the schema has
953
972
  * an `enum` array with a single value or there is a `const` defined.
@@ -955,14 +974,14 @@ declare function hasWidget<T = any, F = any>(schema: RJSFSchema, widget: Widget<
955
974
  * @param schema - The schema for a field
956
975
  * @returns - True if the `schema` has a single constant value, false otherwise
957
976
  */
958
- declare function isConstant(schema: RJSFSchema): boolean;
977
+ declare function isConstant<S extends StrictRJSFSchema = RJSFSchema>(schema: S): boolean;
959
978
 
960
979
  /** Checks to see if the `uiSchema` contains the `widget` field and that the widget is not `hidden`
961
980
  *
962
981
  * @param uiSchema - The UI Schema from which to detect if it is customized
963
982
  * @returns - True if the `uiSchema` describes a custom widget, false otherwise
964
983
  */
965
- declare function isCustomWidget<T = any, F = any>(uiSchema?: UiSchema<T, F>): boolean;
984
+ declare function isCustomWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(uiSchema?: UiSchema<T, S, F>): boolean;
966
985
 
967
986
  /** Detects whether the given `schema` contains fixed items. This is the case when `schema.items` is a non-empty array
968
987
  * that only contains objects.
@@ -970,7 +989,7 @@ declare function isCustomWidget<T = any, F = any>(uiSchema?: UiSchema<T, F>): bo
970
989
  * @param schema - The schema in which to check for fixed items
971
990
  * @returns - True if there are fixed items in the schema, false otherwise
972
991
  */
973
- declare function isFixedItems(schema: RJSFSchema): boolean;
992
+ declare function isFixedItems<S extends StrictRJSFSchema = RJSFSchema>(schema: S): boolean;
974
993
 
975
994
  /** Determines whether a `thing` is an object for the purposes of RSJF. In this case, `thing` is an object if it has
976
995
  * the type `object` but is NOT null, an array or a File.
@@ -1030,7 +1049,7 @@ declare function mergeSchemas(obj1: GenericObjectType, obj2: GenericObjectType):
1030
1049
  * @param schema - The schema from which to extract the options list
1031
1050
  * @returns - The list of options from the schema
1032
1051
  */
1033
- declare function optionsList(schema: RJSFSchema): EnumOptionsType[] | undefined;
1052
+ declare function optionsList<S extends StrictRJSFSchema = RJSFSchema>(schema: S): EnumOptionsType<S>[] | undefined;
1034
1053
 
1035
1054
  /** Given a list of `properties` and an `order` list, returns a list that contains the `properties` ordered correctly.
1036
1055
  * If `order` is not an array, then the untouched `properties` list is returned. Otherwise `properties` is ordered per
@@ -1070,7 +1089,7 @@ declare function parseDateString(dateString?: string, includeTime?: boolean): Da
1070
1089
  * @param [options] - The UIOptionsType from which to potentially extract the emptyValue
1071
1090
  * @returns - The `value` converted to the proper type
1072
1091
  */
1073
- declare function processSelectValue<T = any, F = any>(schema: RJSFSchema, value?: any, options?: UIOptionsType<T, F>): any;
1092
+ declare function processSelectValue<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(schema: S, value?: any, options?: UIOptionsType<T, S, F>): any;
1074
1093
 
1075
1094
  /** Extracts the range spec information `{ step?: number, min?: number, max?: number }` that can be spread onto an HTML
1076
1095
  * input from the range analog in the schema `{ multipleOf?: number, minimum?: number, maximum?: number }`.
@@ -1078,7 +1097,7 @@ declare function processSelectValue<T = any, F = any>(schema: RJSFSchema, value?
1078
1097
  * @param schema - The schema from which to extract the range spec
1079
1098
  * @returns - A range specification from the schema
1080
1099
  */
1081
- declare function rangeSpec(schema: RJSFSchema): RangeSpecType;
1100
+ declare function rangeSpec<S extends StrictRJSFSchema = RJSFSchema>(schema: S): RangeSpecType;
1082
1101
 
1083
1102
  /** Check to see if a `schema` specifies that a value must be true. This happens when:
1084
1103
  * - `schema.const` is truthy
@@ -1089,7 +1108,7 @@ declare function rangeSpec(schema: RJSFSchema): RangeSpecType;
1089
1108
  * @param schema - The schema to check
1090
1109
  * @returns - True if the schema specifies a value that must be true, false otherwise
1091
1110
  */
1092
- declare function schemaRequiresTrueValue(schema: RJSFSchema): boolean;
1111
+ declare function schemaRequiresTrueValue<S extends StrictRJSFSchema = RJSFSchema>(schema: S): boolean;
1093
1112
 
1094
1113
  /** Determines whether the given `component` should be rerendered by comparing its current set of props and state
1095
1114
  * against the next set. If either of those two sets are not the same, then the component should be rerendered.
@@ -1108,7 +1127,7 @@ declare function shouldRender(component: React.Component, nextProps: any, nextSt
1108
1127
  * @returns - The constant value for the schema
1109
1128
  * @throws - Error when the schema does not have a constant value
1110
1129
  */
1111
- declare function toConstant(schema: RJSFSchema): json_schema.JSONSchema7Type | undefined;
1130
+ declare function toConstant<S extends StrictRJSFSchema = RJSFSchema>(schema: S): json_schema.JSONSchema7Type | undefined;
1112
1131
 
1113
1132
  /** Returns a UTC date string for the given `dateObject`. If `time` is false, then the time portion of the string is
1114
1133
  * removed.
@@ -1164,7 +1183,7 @@ declare const UI_OPTIONS_KEY = "ui:options";
1164
1183
  * @param [includeUndefinedValues=false] - Optional flag, if true, cause undefined values to be added as defaults
1165
1184
  * @returns - The resulting `formData` with all the defaults provided
1166
1185
  */
1167
- declare function getDefaultFormState<T = any>(validator: ValidatorType, theSchema: RJSFSchema, formData?: T, rootSchema?: RJSFSchema, includeUndefinedValues?: boolean): T | T[] | undefined;
1186
+ declare function getDefaultFormState<T = any, S extends StrictRJSFSchema = RJSFSchema>(validator: ValidatorType<T, S>, theSchema: S, formData?: T, rootSchema?: S, includeUndefinedValues?: boolean): T | T[] | undefined;
1168
1187
 
1169
1188
  /** Determines whether the combination of `schema` and `uiSchema` properties indicates that the label for the `schema`
1170
1189
  * should be displayed in a UI.
@@ -1175,7 +1194,7 @@ declare function getDefaultFormState<T = any>(validator: ValidatorType, theSchem
1175
1194
  * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
1176
1195
  * @returns - True if the label should be displayed or false if it should not
1177
1196
  */
1178
- declare function getDisplayLabel<T = any, F = any>(validator: ValidatorType, schema: RJSFSchema, uiSchema?: UiSchema<T, F>, rootSchema?: RJSFSchema): boolean;
1197
+ declare function getDisplayLabel<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S>, schema: S, uiSchema?: UiSchema<T, S, F>, rootSchema?: S): boolean;
1179
1198
 
1180
1199
  /** Given the `formData` and list of `options`, attempts to find the index of the option that best matches the data.
1181
1200
  *
@@ -1185,7 +1204,7 @@ declare function getDisplayLabel<T = any, F = any>(validator: ValidatorType, sch
1185
1204
  * @param rootSchema - The root schema, used to primarily to look up `$ref`s
1186
1205
  * @returns - The index of the matched option or 0 if none is available
1187
1206
  */
1188
- declare function getMatchingOption<T = any>(validator: ValidatorType, formData: T | undefined, options: RJSFSchema[], rootSchema: RJSFSchema): number;
1207
+ declare function getMatchingOption<T = any, S extends StrictRJSFSchema = RJSFSchema>(validator: ValidatorType<T, S>, formData: T | undefined, options: S[], rootSchema: S): number;
1189
1208
 
1190
1209
  /** Checks to see if the `schema` and `uiSchema` combination represents an array of files
1191
1210
  *
@@ -1195,7 +1214,7 @@ declare function getMatchingOption<T = any>(validator: ValidatorType, formData:
1195
1214
  * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
1196
1215
  * @returns - True if schema/uiSchema contains an array of files, otherwise false
1197
1216
  */
1198
- declare function isFilesArray<T = any, F = any>(validator: ValidatorType, schema: RJSFSchema, uiSchema?: UiSchema<T, F>, rootSchema?: RJSFSchema): boolean;
1217
+ declare function isFilesArray<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S>, schema: S, uiSchema?: UiSchema<T, S, F>, rootSchema?: S): boolean;
1199
1218
 
1200
1219
  /** Checks to see if the `schema` combination represents a multi-select
1201
1220
  *
@@ -1204,7 +1223,7 @@ declare function isFilesArray<T = any, F = any>(validator: ValidatorType, schema
1204
1223
  * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
1205
1224
  * @returns - True if schema contains a multi-select, otherwise false
1206
1225
  */
1207
- declare function isMultiSelect<T = any>(validator: ValidatorType, schema: RJSFSchema, rootSchema?: RJSFSchema): boolean;
1226
+ declare function isMultiSelect<T = any, S extends StrictRJSFSchema = RJSFSchema>(validator: ValidatorType<T, S>, schema: S, rootSchema?: S): boolean;
1208
1227
 
1209
1228
  /** Checks to see if the `schema` combination represents a select
1210
1229
  *
@@ -1213,7 +1232,7 @@ declare function isMultiSelect<T = any>(validator: ValidatorType, schema: RJSFSc
1213
1232
  * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
1214
1233
  * @returns - True if schema contains a select, otherwise false
1215
1234
  */
1216
- declare function isSelect<T = any>(validator: ValidatorType, theSchema: RJSFSchema, rootSchema?: RJSFSchema): boolean;
1235
+ declare function isSelect<T = any, S extends StrictRJSFSchema = RJSFSchema>(validator: ValidatorType<T, S>, theSchema: S, rootSchema?: S): boolean;
1217
1236
 
1218
1237
  /** Merges the errors in `additionalErrorSchema` into the existing `validationData` by combining the hierarchies in the
1219
1238
  * two `ErrorSchema`s and then appending the error list from the `additionalErrorSchema` obtained by calling
@@ -1225,19 +1244,19 @@ declare function isSelect<T = any>(validator: ValidatorType, theSchema: RJSFSche
1225
1244
  * @param [additionalErrorSchema] - The additional set of errors in an `ErrorSchema`
1226
1245
  * @returns - The `validationData` with the additional errors from `additionalErrorSchema` merged into it, if provided.
1227
1246
  */
1228
- declare function mergeValidationData<T = any>(validator: ValidatorType<T>, validationData: ValidationData<T>, additionalErrorSchema?: ErrorSchema<T>): ValidationData<T>;
1247
+ declare function mergeValidationData<T = any, S extends StrictRJSFSchema = RJSFSchema>(validator: ValidatorType<T, S>, validationData: ValidationData<T>, additionalErrorSchema?: ErrorSchema<T>): ValidationData<T>;
1229
1248
 
1230
1249
  /** Retrieves an expanded schema that has had all of its conditions, additional properties, references and dependencies
1231
1250
  * resolved and merged into the `schema` given a `validator`, `rootSchema` and `rawFormData` that is used to do the
1232
1251
  * potentially recursive resolution.
1233
1252
  *
1234
- * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs
1253
+ * @param validator - An implementation of the `ValidatorType<T, S>` interface that will be forwarded to all the APIs
1235
1254
  * @param schema - The schema for which retrieving a schema is desired
1236
1255
  * @param [rootSchema={}] - The root schema that will be forwarded to all the APIs
1237
1256
  * @param [rawFormData] - The current formData, if any, to assist retrieving a schema
1238
1257
  * @returns - The schema having its conditions, additional properties, references and dependencies resolved
1239
1258
  */
1240
- declare function retrieveSchema<T = any>(validator: ValidatorType, schema: RJSFSchema, rootSchema?: RJSFSchema, rawFormData?: T): RJSFSchema;
1259
+ declare function retrieveSchema<T = any, S extends StrictRJSFSchema = RJSFSchema>(validator: ValidatorType<T, S>, schema: S, rootSchema?: S, rawFormData?: T): S;
1241
1260
 
1242
1261
  /** Generates an `IdSchema` object for the `schema`, recursively
1243
1262
  *
@@ -1250,7 +1269,7 @@ declare function retrieveSchema<T = any>(validator: ValidatorType, schema: RJSFS
1250
1269
  * @param [idSeparator='_'] - The separator to use for the path segments in the id
1251
1270
  * @returns - The `IdSchema` object for the `schema`
1252
1271
  */
1253
- declare function toIdSchema<T = any>(validator: ValidatorType, schema: RJSFSchema, id?: string | null, rootSchema?: RJSFSchema, formData?: T, idPrefix?: string, idSeparator?: string): IdSchema<T>;
1272
+ declare function toIdSchema<T = any, S extends StrictRJSFSchema = RJSFSchema>(validator: ValidatorType<T, S>, schema: S, id?: string | null, rootSchema?: S, formData?: T, idPrefix?: string, idSeparator?: string): IdSchema<T>;
1254
1273
 
1255
1274
  /** Generates an `PathSchema` object for the `schema`, recursively
1256
1275
  *
@@ -1261,6 +1280,6 @@ declare function toIdSchema<T = any>(validator: ValidatorType, schema: RJSFSchem
1261
1280
  * @param [formData] - The current formData, if any, to assist retrieving a schema
1262
1281
  * @returns - The `PathSchema` object for the `schema`
1263
1282
  */
1264
- declare function toPathSchema<T = any>(validator: ValidatorType, schema: RJSFSchema, name?: string, rootSchema?: RJSFSchema, formData?: T): PathSchema<T>;
1283
+ declare function toPathSchema<T = any, S extends StrictRJSFSchema = RJSFSchema>(validator: ValidatorType<T, S>, schema: S, name?: string, rootSchema?: S, formData?: T): PathSchema<T>;
1265
1284
 
1266
- 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, ErrorTransformer, Field, FieldError, FieldErrorProps, FieldErrors, FieldHelpProps, FieldId, FieldPath, FieldProps, FieldTemplateProps, FieldValidation, FormValidation, GenericObjectType, ID_KEY, ITEMS_KEY, IconButtonProps, IdSchema, InputPropsType, NAME_KEY, ONE_OF_KEY, ObjectFieldTemplatePropertyType, ObjectFieldTemplateProps, PROPERTIES_KEY, PathSchema, REF_KEY, REQUIRED_KEY, RJSFSchema, RJSFSchemaDefinition, RJSFValidationError, RJSF_ADDITONAL_PROPERTIES_FLAG, RangeSpecType, Registry, RegistryFieldsType, RegistryWidgetsType, SUBMIT_BTN_OPTIONS_KEY, SchemaUtilsType, 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 };
1285
+ 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, 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 };