@rjsf/utils 5.0.0-beta.2 → 5.0.0-beta.4
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 +1221 -38
- package/package.json +3 -3
- package/dist/allowAdditionalItems.d.ts +0 -8
- package/dist/asNumber.d.ts +0 -10
- package/dist/canExpand.d.ts +0 -11
- package/dist/constants.d.ts +0 -27
- package/dist/createSchemaUtils.d.ts +0 -9
- package/dist/dataURItoBlob.d.ts +0 -10
- package/dist/deepEquals.d.ts +0 -8
- package/dist/findSchemaDefinition.d.ts +0 -20
- package/dist/getInputProps.d.ts +0 -10
- package/dist/getSchemaType.d.ts +0 -13
- package/dist/getSubmitButtonOptions.d.ts +0 -10
- package/dist/getTemplate.d.ts +0 -10
- package/dist/getUiOptions.d.ts +0 -8
- package/dist/getWidget.d.ts +0 -13
- package/dist/guessType.d.ts +0 -7
- package/dist/hasWidget.d.ts +0 -10
- package/dist/isConstant.d.ts +0 -8
- package/dist/isCustomWidget.d.ts +0 -7
- package/dist/isFixedItems.d.ts +0 -8
- package/dist/isObject.d.ts +0 -7
- package/dist/localToUTC.d.ts +0 -6
- package/dist/mergeDefaultsWithFormData.d.ts +0 -15
- package/dist/mergeObjects.d.ts +0 -9
- package/dist/mergeSchemas.d.ts +0 -10
- package/dist/optionsList.d.ts +0 -10
- package/dist/orderProperties.d.ts +0 -11
- package/dist/pad.d.ts +0 -7
- package/dist/parseDateString.d.ts +0 -9
- package/dist/processSelectValue.d.ts +0 -11
- package/dist/rangeSpec.d.ts +0 -9
- package/dist/schema/getDefaultFormState.d.ts +0 -47
- package/dist/schema/getDisplayLabel.d.ts +0 -11
- package/dist/schema/getMatchingOption.d.ts +0 -10
- package/dist/schema/index.d.ts +0 -11
- package/dist/schema/isFilesArray.d.ts +0 -10
- package/dist/schema/isMultiSelect.d.ts +0 -9
- package/dist/schema/isSelect.d.ts +0 -9
- package/dist/schema/mergeValidationData.d.ts +0 -12
- package/dist/schema/retrieveSchema.d.ts +0 -98
- package/dist/schema/toIdSchema.d.ts +0 -13
- package/dist/schema/toPathSchema.d.ts +0 -11
- package/dist/schemaRequiresTrueValue.d.ts +0 -11
- package/dist/shouldRender.d.ts +0 -10
- package/dist/toConstant.d.ts +0 -9
- package/dist/toDateString.d.ts +0 -9
- package/dist/types.d.ts +0 -755
- package/dist/utcToLocal.d.ts +0 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,38 +1,1221 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import * as json_schema from 'json-schema';
|
|
3
|
+
import { JSONSchema7, JSONSchema7Definition } from 'json-schema';
|
|
4
|
+
|
|
5
|
+
/** The representation of any generic object type, usually used as an intersection on other types to make them more
|
|
6
|
+
* flexible in the properties they support (i.e. anything else)
|
|
7
|
+
*/
|
|
8
|
+
declare type GenericObjectType = {
|
|
9
|
+
[name: string]: any;
|
|
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.
|
|
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.
|
|
17
|
+
*/
|
|
18
|
+
declare type RJSFSchemaDefinition = JSONSchema7Definition;
|
|
19
|
+
/** The interface representing a Date object that contains an optional time */
|
|
20
|
+
interface DateObject {
|
|
21
|
+
/** The year of the Date */
|
|
22
|
+
year: number;
|
|
23
|
+
/** The month of the Date */
|
|
24
|
+
month: number;
|
|
25
|
+
/** The day of the Date */
|
|
26
|
+
day: number;
|
|
27
|
+
/** The optional hours for the time of a Date */
|
|
28
|
+
hour?: number;
|
|
29
|
+
/** The optional minutes for the time of a Date */
|
|
30
|
+
minute?: number;
|
|
31
|
+
/** The optional seconds for the time of a Date */
|
|
32
|
+
second?: number;
|
|
33
|
+
}
|
|
34
|
+
/** Properties describing a Range specification in terms of attribute that can be added to the `HTML` `<input>` */
|
|
35
|
+
declare type RangeSpecType = {
|
|
36
|
+
/** Specifies the interval between legal numbers in an input field */
|
|
37
|
+
step?: number;
|
|
38
|
+
/** Specifies a minimum value for an <input> element */
|
|
39
|
+
min?: number;
|
|
40
|
+
/** Specifies the maximum value for an <input> element */
|
|
41
|
+
max?: number;
|
|
42
|
+
};
|
|
43
|
+
/** Properties describing a Range specification in terms of attribute that can be added to the `HTML` `<input>` */
|
|
44
|
+
declare type InputPropsType = Omit<RangeSpecType, "step"> & {
|
|
45
|
+
/** Specifies the type of the <input> element */
|
|
46
|
+
type: string;
|
|
47
|
+
/** Specifies the interval between legal numbers in an input field or "any" */
|
|
48
|
+
step?: number | "any";
|
|
49
|
+
/** Specifies the `autoComplete` value for an <input> element */
|
|
50
|
+
autoComplete?: HTMLInputElement["autocomplete"];
|
|
51
|
+
};
|
|
52
|
+
/** Type describing an id used for a field in the `IdSchema` */
|
|
53
|
+
declare type FieldId = {
|
|
54
|
+
/** The id for a field */
|
|
55
|
+
$id: string;
|
|
56
|
+
};
|
|
57
|
+
/** Type describing a recursive structure of `FieldId`s for an object with a non-empty set of keys */
|
|
58
|
+
declare type IdSchema<T = any> = FieldId & {
|
|
59
|
+
[key in keyof T]?: IdSchema<T[key]>;
|
|
60
|
+
};
|
|
61
|
+
/** Type describing a name used for a field in the `PathSchema` */
|
|
62
|
+
declare type FieldPath = {
|
|
63
|
+
/** The name of a field */
|
|
64
|
+
$name: string;
|
|
65
|
+
};
|
|
66
|
+
/** Type describing a recursive structure of `FieldPath`s for an object with a non-empty set of keys */
|
|
67
|
+
declare type PathSchema<T = any> = FieldPath & {
|
|
68
|
+
[key in keyof T]?: PathSchema<T[key]>;
|
|
69
|
+
};
|
|
70
|
+
/** The type for error produced by RJSF schema validation */
|
|
71
|
+
declare type RJSFValidationError = {
|
|
72
|
+
/** Name of the error, for example, "required" or "minLength" */
|
|
73
|
+
name?: string;
|
|
74
|
+
/** Message, for example, "is a required property" or "should NOT be shorter than 3 characters" */
|
|
75
|
+
message?: string;
|
|
76
|
+
/** An object with the error params returned by ajv
|
|
77
|
+
* ([see doc](https://github.com/ajv-validator/ajv/tree/6a671057ea6aae690b5967ee26a0ddf8452c6297#error-parameters)
|
|
78
|
+
* for more info)
|
|
79
|
+
*/
|
|
80
|
+
params?: any;
|
|
81
|
+
/** A string in Javascript property accessor notation to the data path of the field with the error. For example,
|
|
82
|
+
* `.name` or `['first-name']`
|
|
83
|
+
*/
|
|
84
|
+
property?: string;
|
|
85
|
+
/** JSON pointer to the schema of the keyword that failed validation. For example, `#/fields/firstName/required`.
|
|
86
|
+
* (Note: this may sometimes be wrong due to a [bug in ajv](https://github.com/ajv-validator/ajv/issues/512))
|
|
87
|
+
*/
|
|
88
|
+
schemaPath?: string;
|
|
89
|
+
/** Full error name, for example ".name is a required property" */
|
|
90
|
+
stack: string;
|
|
91
|
+
};
|
|
92
|
+
/** The type that describes an error in a field */
|
|
93
|
+
declare type FieldError = string;
|
|
94
|
+
/** The type that describes the list of errors for a field */
|
|
95
|
+
declare type FieldErrors = {
|
|
96
|
+
/** The list of errors for the field */
|
|
97
|
+
__errors?: FieldError[];
|
|
98
|
+
};
|
|
99
|
+
/** Type describing a recursive structure of `FieldErrors`s for an object with a non-empty set of keys */
|
|
100
|
+
declare type ErrorSchema<T = any> = FieldErrors & {
|
|
101
|
+
[key in keyof T]?: ErrorSchema<T[key]>;
|
|
102
|
+
};
|
|
103
|
+
/** Type that describes the list of errors for a field being actively validated by a custom validator */
|
|
104
|
+
declare type FieldValidation = FieldErrors & {
|
|
105
|
+
/** Function that will add a new `message` to the list of errors */
|
|
106
|
+
addError: (message: string) => void;
|
|
107
|
+
};
|
|
108
|
+
/** Type describing a recursive structure of `FieldValidation`s for an object with a non-empty set of keys */
|
|
109
|
+
declare type FormValidation<T = any> = FieldValidation & {
|
|
110
|
+
[key in keyof T]?: FormValidation<T[key]>;
|
|
111
|
+
};
|
|
112
|
+
/** The properties that are passed to an `ErrorList` implementation */
|
|
113
|
+
declare type ErrorListProps<T = any, F = any> = {
|
|
114
|
+
/** The errorSchema constructed by `Form` */
|
|
115
|
+
errorSchema: ErrorSchema<T>;
|
|
116
|
+
/** An array of the errors */
|
|
117
|
+
errors: RJSFValidationError[];
|
|
118
|
+
/** The `formContext` object that was passed to `Form` */
|
|
119
|
+
formContext?: F;
|
|
120
|
+
/** The schema that was passed to `Form` */
|
|
121
|
+
schema: RJSFSchema;
|
|
122
|
+
/** The uiSchema that was passed to `Form` */
|
|
123
|
+
uiSchema?: UiSchema<T, F>;
|
|
124
|
+
};
|
|
125
|
+
/** The set of `Fields` stored in the `Registry` */
|
|
126
|
+
declare type RegistryFieldsType<T = any, F = any> = {
|
|
127
|
+
/** A `Field` indexed by `name` */
|
|
128
|
+
[name: string]: Field<T, F>;
|
|
129
|
+
};
|
|
130
|
+
/** The set of `Widgets` stored in the `Registry` */
|
|
131
|
+
declare type RegistryWidgetsType<T = any, F = any> = {
|
|
132
|
+
/** A `Widget` indexed by `name` */
|
|
133
|
+
[name: string]: Widget<T, F>;
|
|
134
|
+
};
|
|
135
|
+
/** The set of RJSF templates that can be overridden by themes or users */
|
|
136
|
+
interface TemplatesType<T = any, F = any> {
|
|
137
|
+
/** The template to use while rendering normal or fixed array fields */
|
|
138
|
+
ArrayFieldTemplate: React.ComponentType<ArrayFieldTemplateProps<T, F>>;
|
|
139
|
+
/** The template to use while rendering the description for an array field */
|
|
140
|
+
ArrayFieldDescriptionTemplate: React.ComponentType<ArrayFieldDescriptionProps<T, F>>;
|
|
141
|
+
/** The template to use while rendering an item in an array field */
|
|
142
|
+
ArrayFieldItemTemplate: React.ComponentType<ArrayFieldTemplateItemType<T, F>>;
|
|
143
|
+
/** The template to use while rendering the title for an array field */
|
|
144
|
+
ArrayFieldTitleTemplate: React.ComponentType<ArrayFieldTitleProps<T, F>>;
|
|
145
|
+
/** The template to use while rendering the standard html input */
|
|
146
|
+
BaseInputTemplate: React.ComponentType<WidgetProps<T, F>>;
|
|
147
|
+
/** The template to use for rendering the description of a field */
|
|
148
|
+
DescriptionFieldTemplate: React.ComponentType<DescriptionFieldProps<T, F>>;
|
|
149
|
+
/** The template to use while rendering form errors */
|
|
150
|
+
ErrorListTemplate: React.ComponentType<ErrorListProps<T, F>>;
|
|
151
|
+
/** The template to use while rendering a field */
|
|
152
|
+
FieldTemplate: React.ComponentType<FieldTemplateProps<T, F>>;
|
|
153
|
+
/** The template to use while rendering an object */
|
|
154
|
+
ObjectFieldTemplate: React.ComponentType<ObjectFieldTemplateProps<T, F>>;
|
|
155
|
+
/** The template to use for rendering the title of a field */
|
|
156
|
+
TitleFieldTemplate: React.ComponentType<TitleFieldProps<T, F>>;
|
|
157
|
+
/** The template to use for rendering information about an unsupported field type in the schema */
|
|
158
|
+
UnsupportedFieldTemplate: React.ComponentType<UnsupportedFieldProps<T, F>>;
|
|
159
|
+
/** The set of templates associated with buttons in the form */
|
|
160
|
+
ButtonTemplates: {
|
|
161
|
+
/** The template to use for the main `Submit` button */
|
|
162
|
+
SubmitButton: React.ComponentType<SubmitButtonProps<T, F>>;
|
|
163
|
+
/** The template to use for the Add button used for AdditionalProperties and Array items */
|
|
164
|
+
AddButton: React.ComponentType<IconButtonProps>;
|
|
165
|
+
/** The template to use for the Move Down button used for Array items */
|
|
166
|
+
MoveDownButton: React.ComponentType<IconButtonProps>;
|
|
167
|
+
/** The template to use for the Move Up button used for Array items */
|
|
168
|
+
MoveUpButton: React.ComponentType<IconButtonProps>;
|
|
169
|
+
/** The template to use for the Remove button used for AdditionalProperties and Array items */
|
|
170
|
+
RemoveButton: React.ComponentType<IconButtonProps>;
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
/** The object containing the registered core, theme and custom fields and widgets as well as the root schema, form
|
|
174
|
+
* context, schema utils and templates.
|
|
175
|
+
*/
|
|
176
|
+
interface Registry<T = any, F = any> {
|
|
177
|
+
/** The set of all fields used by the `Form`. Includes fields from `core`, theme-specific fields and any custom
|
|
178
|
+
* registered fields
|
|
179
|
+
*/
|
|
180
|
+
fields: RegistryFieldsType<T, F>;
|
|
181
|
+
/** The set of templates used by the `Form`. Includes templates from `core`, theme-specific fields and any custom
|
|
182
|
+
* registered templates
|
|
183
|
+
*/
|
|
184
|
+
templates: TemplatesType<T, F>;
|
|
185
|
+
/** The set of all widgets used by the `Form`. Includes widgets from `core`, theme-specific widgets and any custom
|
|
186
|
+
* registered widgets
|
|
187
|
+
*/
|
|
188
|
+
widgets: RegistryWidgetsType<T, F>;
|
|
189
|
+
/** The `formContext` object that was passed to `Form` */
|
|
190
|
+
formContext: F;
|
|
191
|
+
/** The root schema, as passed to the `Form`, which can contain referenced definitions */
|
|
192
|
+
rootSchema: RJSFSchema;
|
|
193
|
+
/** The current implementation of the `SchemaUtilsType` (from `@rjsf/utils`) in use by the `Form`. Used to call any
|
|
194
|
+
* of the validation-schema-based utility functions
|
|
195
|
+
*/
|
|
196
|
+
schemaUtils: SchemaUtilsType<T>;
|
|
197
|
+
}
|
|
198
|
+
/** The properties that are passed to a Field implementation */
|
|
199
|
+
interface FieldProps<T = any, F = any> extends GenericObjectType, Pick<React.HTMLAttributes<HTMLElement>, Exclude<keyof React.HTMLAttributes<HTMLElement>, "onBlur" | "onFocus" | "onChange">> {
|
|
200
|
+
/** The JSON subschema object for this field */
|
|
201
|
+
schema: RJSFSchema;
|
|
202
|
+
/** The uiSchema for this field */
|
|
203
|
+
uiSchema?: UiSchema<T, F>;
|
|
204
|
+
/** The tree of unique ids for every child field */
|
|
205
|
+
idSchema: IdSchema<T>;
|
|
206
|
+
/** The data for this field */
|
|
207
|
+
formData: T;
|
|
208
|
+
/** The tree of errors for this field and its children */
|
|
209
|
+
errorSchema?: ErrorSchema<T>;
|
|
210
|
+
/** The field change event handler; called with the updated form data and an optional `ErrorSchema` */
|
|
211
|
+
onChange: (newFormData: T, es?: ErrorSchema<T>) => any;
|
|
212
|
+
/** The input blur event handler; call it with the field id and value */
|
|
213
|
+
onBlur: (id: string, value: any) => void;
|
|
214
|
+
/** The input focus event handler; call it with the field id and value */
|
|
215
|
+
onFocus: (id: string, value: any) => void;
|
|
216
|
+
/** The `formContext` object that you passed to `Form` */
|
|
217
|
+
formContext?: F;
|
|
218
|
+
/** A boolean value stating if the field should autofocus */
|
|
219
|
+
autofocus?: boolean;
|
|
220
|
+
/** A boolean value stating if the field is disabled */
|
|
221
|
+
disabled: boolean;
|
|
222
|
+
/** A boolean value stating if the field is hiding its errors */
|
|
223
|
+
hideError?: boolean;
|
|
224
|
+
/** A boolean value stating if the field is read-only */
|
|
225
|
+
readonly: boolean;
|
|
226
|
+
/** The required status of this field */
|
|
227
|
+
required?: boolean;
|
|
228
|
+
/** The unique name of the field, usually derived from the name of the property in the JSONSchema */
|
|
229
|
+
name: string;
|
|
230
|
+
/** The `registry` object */
|
|
231
|
+
registry: Registry<T, F>;
|
|
232
|
+
}
|
|
233
|
+
/** The definition of a React-based Field component */
|
|
234
|
+
declare type Field<T = any, F = any> = React.ComponentType<FieldProps<T, F>>;
|
|
235
|
+
/** The properties that are passed to a FieldTemplate implementation */
|
|
236
|
+
declare type FieldTemplateProps<T = any, F = any> = {
|
|
237
|
+
/** The id of the field in the hierarchy. You can use it to render a label targeting the wrapped widget */
|
|
238
|
+
id: string;
|
|
239
|
+
/** A string containing the base CSS classes, merged with any custom ones defined in your uiSchema */
|
|
240
|
+
classNames?: string;
|
|
241
|
+
/** The computed label for this field, as a string */
|
|
242
|
+
label: string;
|
|
243
|
+
/** A component instance rendering the field description, if one is defined (this will use any custom
|
|
244
|
+
* `DescriptionField` defined)
|
|
245
|
+
*/
|
|
246
|
+
description?: React.ReactElement;
|
|
247
|
+
/** A string containing any `ui:description` uiSchema directive defined */
|
|
248
|
+
rawDescription?: string;
|
|
249
|
+
/** The field or widget component instance for this field row */
|
|
250
|
+
children: React.ReactElement;
|
|
251
|
+
/** A component instance listing any encountered errors for this field */
|
|
252
|
+
errors?: React.ReactElement;
|
|
253
|
+
/** An array of strings listing all generated error messages from encountered errors for this field */
|
|
254
|
+
rawErrors?: string[];
|
|
255
|
+
/** A component instance rendering any `ui:help` uiSchema directive defined */
|
|
256
|
+
help?: React.ReactElement;
|
|
257
|
+
/** A string containing any `ui:help` uiSchema directive defined. **NOTE:** `rawHelp` will be `undefined` if passed
|
|
258
|
+
* `ui:help` is a React component instead of a string
|
|
259
|
+
*/
|
|
260
|
+
rawHelp?: string;
|
|
261
|
+
/** A boolean value stating if the field should be hidden */
|
|
262
|
+
hidden?: boolean;
|
|
263
|
+
/** A boolean value stating if the field is required */
|
|
264
|
+
required?: boolean;
|
|
265
|
+
/** A boolean value stating if the field is read-only */
|
|
266
|
+
readonly: boolean;
|
|
267
|
+
/** A boolean value stating if the field is hiding its errors */
|
|
268
|
+
hideError?: boolean;
|
|
269
|
+
/** A boolean value stating if the field is disabled */
|
|
270
|
+
disabled: boolean;
|
|
271
|
+
/** A boolean value stating if the label should be rendered or not. This is useful for nested fields in arrays where
|
|
272
|
+
* you don't want to clutter the UI
|
|
273
|
+
*/
|
|
274
|
+
displayLabel?: boolean;
|
|
275
|
+
/** The schema object for this field */
|
|
276
|
+
schema: RJSFSchema;
|
|
277
|
+
/** The uiSchema object for this field */
|
|
278
|
+
uiSchema?: UiSchema<T, F>;
|
|
279
|
+
/** The `formContext` object that was passed to `Form` */
|
|
280
|
+
formContext?: F;
|
|
281
|
+
/** The formData for this field */
|
|
282
|
+
formData: T;
|
|
283
|
+
/** The value change event handler; Can be called with a new value to change the value for this field */
|
|
284
|
+
onChange: (value: T) => void;
|
|
285
|
+
/** The key change event handler; Called when the key associated with a field is changed for an additionalProperty */
|
|
286
|
+
onKeyChange: (value: string) => () => void;
|
|
287
|
+
/** The property drop/removal event handler; Called when a field is removed in an additionalProperty context */
|
|
288
|
+
onDropPropertyClick: (value: string) => () => void;
|
|
289
|
+
/** The `registry` object */
|
|
290
|
+
registry: Registry<T, F>;
|
|
291
|
+
};
|
|
292
|
+
/** The properties that are passed to the `UnsupportedFieldTemplate` implementation */
|
|
293
|
+
declare type UnsupportedFieldProps<T = any, F = any> = {
|
|
294
|
+
/** The schema object for this field */
|
|
295
|
+
schema: RJSFSchema;
|
|
296
|
+
/** The tree of unique ids for every child field */
|
|
297
|
+
idSchema?: IdSchema<T>;
|
|
298
|
+
/** The reason why the schema field has an unsupported type */
|
|
299
|
+
reason: string;
|
|
300
|
+
/** The `registry` object */
|
|
301
|
+
registry: Registry<T, F>;
|
|
302
|
+
};
|
|
303
|
+
/** The properties that are passed to a `TitleFieldTemplate` implementation */
|
|
304
|
+
declare type TitleFieldProps<T = any, F = any> = {
|
|
305
|
+
/** The id of the field title in the hierarchy */
|
|
306
|
+
id: string;
|
|
307
|
+
/** The title for the field being rendered */
|
|
308
|
+
title: string;
|
|
309
|
+
/** The uiSchema object for this title field */
|
|
310
|
+
uiSchema?: UiSchema<T, F>;
|
|
311
|
+
/** A boolean value stating if the field is required */
|
|
312
|
+
required?: boolean;
|
|
313
|
+
/** The `registry` object */
|
|
314
|
+
registry: Registry<T, F>;
|
|
315
|
+
};
|
|
316
|
+
/** The properties that are passed to a `DescriptionFieldTemplate` implementation */
|
|
317
|
+
declare type DescriptionFieldProps<T = any, F = any> = {
|
|
318
|
+
/** The id of the field description in the hierarchy */
|
|
319
|
+
id: string;
|
|
320
|
+
/** The description of the field being rendered */
|
|
321
|
+
description: string | React.ReactElement;
|
|
322
|
+
/** The `registry` object */
|
|
323
|
+
registry: Registry<T, F>;
|
|
324
|
+
};
|
|
325
|
+
/** The properties that are passed to a `ArrayFieldTitleTemplate` implementation */
|
|
326
|
+
declare type ArrayFieldTitleProps<T = any, F = any> = Pick<TitleFieldProps<T, F>, "title" | "uiSchema" | "required" | "registry"> & {
|
|
327
|
+
/** The idSchema of the field in the hierarchy */
|
|
328
|
+
idSchema: IdSchema<T>;
|
|
329
|
+
};
|
|
330
|
+
/** The properties that are passed to a `ArrayFieldDescriptionTemplate` implementation */
|
|
331
|
+
declare type ArrayFieldDescriptionProps<T = any, F = any> = Pick<DescriptionFieldProps<T, F>, "description" | "registry"> & {
|
|
332
|
+
/** The idSchema of the field in the hierarchy */
|
|
333
|
+
idSchema: IdSchema<T>;
|
|
334
|
+
/** The uiSchema object for this description field */
|
|
335
|
+
uiSchema?: UiSchema<T, F>;
|
|
336
|
+
};
|
|
337
|
+
/** The properties of each element in the ArrayFieldTemplateProps.items array */
|
|
338
|
+
declare type ArrayFieldTemplateItemType<T = any, F = any> = {
|
|
339
|
+
/** The html for the item's content */
|
|
340
|
+
children: React.ReactElement;
|
|
341
|
+
/** The className string */
|
|
342
|
+
className: string;
|
|
343
|
+
/** A boolean value stating if the array item is disabled */
|
|
344
|
+
disabled: boolean;
|
|
345
|
+
/** A boolean value stating whether the array item can be moved down */
|
|
346
|
+
hasMoveDown: boolean;
|
|
347
|
+
/** A boolean value stating whether the array item can be moved up */
|
|
348
|
+
hasMoveUp: boolean;
|
|
349
|
+
/** A boolean value stating whether the array item can be removed */
|
|
350
|
+
hasRemove: boolean;
|
|
351
|
+
/** A boolean value stating whether the array item has a toolbar */
|
|
352
|
+
hasToolbar: boolean;
|
|
353
|
+
/** A number stating the index the array item occurs in `items` */
|
|
354
|
+
index: number;
|
|
355
|
+
/** Returns a function that adds a new item at `index` */
|
|
356
|
+
onAddIndexClick: (index: number) => (event?: any) => void;
|
|
357
|
+
/** Returns a function that removes the item at `index` */
|
|
358
|
+
onDropIndexClick: (index: number) => (event?: any) => void;
|
|
359
|
+
/** Returns a function that swaps the items at `index` with `newIndex` */
|
|
360
|
+
onReorderClick: (index: number, newIndex: number) => (event?: any) => void;
|
|
361
|
+
/** A boolean value stating if the array item is read-only */
|
|
362
|
+
readonly: boolean;
|
|
363
|
+
/** A stable, unique key for the array item */
|
|
364
|
+
key: string;
|
|
365
|
+
/** The `registry` object */
|
|
366
|
+
registry: Registry<T, F>;
|
|
367
|
+
};
|
|
368
|
+
/** The properties that are passed to an ArrayFieldTemplate implementation */
|
|
369
|
+
declare type ArrayFieldTemplateProps<T = any, F = any> = {
|
|
370
|
+
/** A boolean value stating whether new elements can be added to the array */
|
|
371
|
+
canAdd?: boolean;
|
|
372
|
+
/** The className string */
|
|
373
|
+
className?: string;
|
|
374
|
+
/** A boolean value stating if the array is disabled */
|
|
375
|
+
disabled?: boolean;
|
|
376
|
+
/** An object containing the id for this object & ids for its properties */
|
|
377
|
+
idSchema: IdSchema<T>;
|
|
378
|
+
/** An array of objects representing the items in the array */
|
|
379
|
+
items: ArrayFieldTemplateItemType<T, F>[];
|
|
380
|
+
/** A function that adds a new item to the array */
|
|
381
|
+
onAddClick: (event?: any) => void;
|
|
382
|
+
/** A boolean value stating if the array is read-only */
|
|
383
|
+
readonly?: boolean;
|
|
384
|
+
/** A boolean value stating if the array is required */
|
|
385
|
+
required?: boolean;
|
|
386
|
+
/** A boolean value stating if the field is hiding its errors */
|
|
387
|
+
hideError?: boolean;
|
|
388
|
+
/** The schema object for this array */
|
|
389
|
+
schema: RJSFSchema;
|
|
390
|
+
/** The uiSchema object for this array field */
|
|
391
|
+
uiSchema?: UiSchema<T, F>;
|
|
392
|
+
/** A string value containing the title for the array */
|
|
393
|
+
title: string;
|
|
394
|
+
/** The `formContext` object that was passed to Form */
|
|
395
|
+
formContext?: F;
|
|
396
|
+
/** The formData for this array */
|
|
397
|
+
formData: T;
|
|
398
|
+
/** An array of strings listing all generated error messages from encountered errors for this widget */
|
|
399
|
+
rawErrors?: string[];
|
|
400
|
+
/** The `registry` object */
|
|
401
|
+
registry: Registry<T, F>;
|
|
402
|
+
};
|
|
403
|
+
/** The properties of each element in the ObjectFieldTemplateProps.properties array */
|
|
404
|
+
declare type ObjectFieldTemplatePropertyType = {
|
|
405
|
+
/** The html for the property's content */
|
|
406
|
+
content: React.ReactElement;
|
|
407
|
+
/** A string representing the property name */
|
|
408
|
+
name: string;
|
|
409
|
+
/** A boolean value stating if the object property is disabled */
|
|
410
|
+
disabled: boolean;
|
|
411
|
+
/** A boolean value stating if the property is read-only */
|
|
412
|
+
readonly: boolean;
|
|
413
|
+
/** A boolean value stating if the property should be hidden */
|
|
414
|
+
hidden: boolean;
|
|
415
|
+
};
|
|
416
|
+
/** The properties that are passed to an ObjectFieldTemplate implementation */
|
|
417
|
+
declare type ObjectFieldTemplateProps<T = any, F = any> = {
|
|
418
|
+
/** A string value containing the title for the object */
|
|
419
|
+
title: string;
|
|
420
|
+
/** A string value containing the description for the object */
|
|
421
|
+
description?: string;
|
|
422
|
+
/** A boolean value stating if the object is disabled */
|
|
423
|
+
disabled?: boolean;
|
|
424
|
+
/** An array of objects representing the properties in the object */
|
|
425
|
+
properties: ObjectFieldTemplatePropertyType[];
|
|
426
|
+
/** Returns a function that adds a new property to the object (to be used with additionalProperties) */
|
|
427
|
+
onAddClick: (schema: RJSFSchema) => () => void;
|
|
428
|
+
/** A boolean value stating if the object is read-only */
|
|
429
|
+
readonly?: boolean;
|
|
430
|
+
/** A boolean value stating if the object is required */
|
|
431
|
+
required?: boolean;
|
|
432
|
+
/** A boolean value stating if the field is hiding its errors */
|
|
433
|
+
hideError?: boolean;
|
|
434
|
+
/** The schema object for this object */
|
|
435
|
+
schema: RJSFSchema;
|
|
436
|
+
/** The uiSchema object for this object field */
|
|
437
|
+
uiSchema?: UiSchema<T, F>;
|
|
438
|
+
/** An object containing the id for this object & ids for its properties */
|
|
439
|
+
idSchema: IdSchema<T>;
|
|
440
|
+
/** The form data for the object */
|
|
441
|
+
formData: T;
|
|
442
|
+
/** The `formContext` object that was passed to Form */
|
|
443
|
+
formContext?: F;
|
|
444
|
+
/** The `registry` object */
|
|
445
|
+
registry: Registry<T, F>;
|
|
446
|
+
};
|
|
447
|
+
/** The properties that are passed to a Widget implementation */
|
|
448
|
+
interface WidgetProps<T = any, F = any> extends GenericObjectType, Pick<React.HTMLAttributes<HTMLElement>, Exclude<keyof React.HTMLAttributes<HTMLElement>, "onBlur" | "onFocus">> {
|
|
449
|
+
/** The generated id for this widget */
|
|
450
|
+
id: string;
|
|
451
|
+
/** The JSONSchema subschema object for this widget */
|
|
452
|
+
schema: RJSFSchema;
|
|
453
|
+
/** The uiSchema for this widget */
|
|
454
|
+
uiSchema?: UiSchema<T, F>;
|
|
455
|
+
/** The current value for this widget */
|
|
456
|
+
value: any;
|
|
457
|
+
/** The required status of this widget */
|
|
458
|
+
required?: boolean;
|
|
459
|
+
/** A boolean value stating if the widget is disabled */
|
|
460
|
+
disabled?: boolean;
|
|
461
|
+
/** A boolean value stating if the widget is read-only */
|
|
462
|
+
readonly?: boolean;
|
|
463
|
+
/** A boolean value stating if the widget is hiding its errors */
|
|
464
|
+
hideError?: boolean;
|
|
465
|
+
/** A boolean value stating if the widget should autofocus */
|
|
466
|
+
autofocus?: boolean;
|
|
467
|
+
/** The placeholder for the widget, if any */
|
|
468
|
+
placeholder?: string;
|
|
469
|
+
/** A map of UI Options passed as a prop to the component, including the optional `enumOptions`
|
|
470
|
+
* which is a special case on top of `UIOptionsType` needed only by widgets
|
|
471
|
+
*/
|
|
472
|
+
options: NonNullable<UIOptionsType<T, F>> & {
|
|
473
|
+
/** The enum options list for a type that supports them */
|
|
474
|
+
enumOptions?: EnumOptionsType[];
|
|
475
|
+
};
|
|
476
|
+
/** The `formContext` object that you passed to `Form` */
|
|
477
|
+
formContext?: F;
|
|
478
|
+
/** The input blur event handler; call it with the widget id and value */
|
|
479
|
+
onBlur: (id: string, value: any) => void;
|
|
480
|
+
/** The value change event handler; call it with the new value every time it changes */
|
|
481
|
+
onChange: (value: any) => void;
|
|
482
|
+
/** The input focus event handler; call it with the widget id and value */
|
|
483
|
+
onFocus: (id: string, value: any) => void;
|
|
484
|
+
/** The computed label for this widget, as a string */
|
|
485
|
+
label: string;
|
|
486
|
+
/** A boolean value stating if the widget can accept multiple values */
|
|
487
|
+
multiple?: boolean;
|
|
488
|
+
/** An array of strings listing all generated error messages from encountered errors for this widget */
|
|
489
|
+
rawErrors?: string[];
|
|
490
|
+
/** The `registry` object */
|
|
491
|
+
registry: Registry<T, F>;
|
|
492
|
+
}
|
|
493
|
+
/** The definition of a React-based Widget component */
|
|
494
|
+
declare type Widget<T = any, F = any> = React.ComponentType<WidgetProps<T, F>>;
|
|
495
|
+
/** The type that defines the props used by the Submit button */
|
|
496
|
+
declare type SubmitButtonProps<T = any, F = any> = {
|
|
497
|
+
/** The uiSchema for this widget */
|
|
498
|
+
uiSchema?: UiSchema<T, F>;
|
|
499
|
+
};
|
|
500
|
+
/** The type that defines the props for an Icon button, extending from a basic HTML button attributes */
|
|
501
|
+
declare type IconButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
502
|
+
/** An alternative specification for the type of the icon button */
|
|
503
|
+
iconType?: string;
|
|
504
|
+
/** The name representation or actual react element implementation for the icon */
|
|
505
|
+
icon?: string | React.ReactElement;
|
|
506
|
+
};
|
|
507
|
+
/** The type that defines how to change the behavior of the submit button for the form */
|
|
508
|
+
declare type UISchemaSubmitButtonOptions = {
|
|
509
|
+
/** The text of the submit button. Set to "Submit" by default */
|
|
510
|
+
submitText?: string;
|
|
511
|
+
/** Flag, if `true`, removes the submit button completely from the form */
|
|
512
|
+
norender?: boolean;
|
|
513
|
+
/** Any other props to be passed to the submit button itself */
|
|
514
|
+
props?: GenericObjectType & {
|
|
515
|
+
/** A boolean value stating if the submit button is disabled */
|
|
516
|
+
disabled?: boolean;
|
|
517
|
+
/** The class name for the submit button */
|
|
518
|
+
className?: string;
|
|
519
|
+
};
|
|
520
|
+
};
|
|
521
|
+
/** This type represents an element used to render an enum option */
|
|
522
|
+
declare type EnumOptionsType = {
|
|
523
|
+
/** The value for the enum option */
|
|
524
|
+
value: any;
|
|
525
|
+
/** The label for the enum options */
|
|
526
|
+
label: string;
|
|
527
|
+
/** The schema associated with the enum option when the option represents a `oneOf` or `anyOf` choice */
|
|
528
|
+
schema?: RJSFSchema;
|
|
529
|
+
};
|
|
530
|
+
/** This type remaps the keys of `Type` to prepend `ui:` onto them. As a result it does not need to be exported */
|
|
531
|
+
declare type MakeUIType<Type> = {
|
|
532
|
+
[Property in keyof Type as `ui:${string & Property}`]: Type[Property];
|
|
533
|
+
};
|
|
534
|
+
/** This type represents all the known supported options in the `ui:options` property, kept separate in order to
|
|
535
|
+
* remap the keys. It also contains all the properties, optionally, of `TemplatesType` except "ButtonTemplates"
|
|
536
|
+
*/
|
|
537
|
+
declare type UIOptionsBaseType<T = any, F = any> = Partial<Omit<TemplatesType<T, F>, "ButtonTemplates">> & {
|
|
538
|
+
/** Any classnames that the user wants to be applied to a field in the ui */
|
|
539
|
+
classNames?: string;
|
|
540
|
+
/** We know that for title, it will be a string, if it is provided */
|
|
541
|
+
title?: string;
|
|
542
|
+
/** We know that for description, it will be a string, if it is provided */
|
|
543
|
+
description?: string;
|
|
544
|
+
/** We know that for placeholder, it will be a string, if it is provided */
|
|
545
|
+
placeholder?: string;
|
|
546
|
+
/** Used to add text next to a field to guide the end user in filling it in */
|
|
547
|
+
help?: string;
|
|
548
|
+
/** Flag, if set to `true`, will mark the field as automatically focused on a text input or textarea input */
|
|
549
|
+
autofocus?: boolean;
|
|
550
|
+
/** Use to mark the field as supporting auto complete on a text input or textarea input */
|
|
551
|
+
autocomplete?: HTMLInputElement["autocomplete"];
|
|
552
|
+
/** Flag, if set to `true`, will mark all child widgets from a given field as disabled */
|
|
553
|
+
disabled?: boolean;
|
|
554
|
+
/** The default value to use when an input for a field is empty */
|
|
555
|
+
emptyValue?: any;
|
|
556
|
+
/** Will disable any of the enum options specified in the array (by value) */
|
|
557
|
+
enumDisabled?: Array<string | number | boolean>;
|
|
558
|
+
/** Flag, if set to `true`, will hide the default error display for the given field AND all of its child fields in the
|
|
559
|
+
* hierarchy
|
|
560
|
+
*/
|
|
561
|
+
hideError?: boolean;
|
|
562
|
+
/** Flag, if set to `true`, will mark all child widgets from a given field as read-only */
|
|
563
|
+
readonly?: boolean;
|
|
564
|
+
/** This property allows you to reorder the properties that are shown for a particular object */
|
|
565
|
+
order?: string[];
|
|
566
|
+
/** Flag, if set to `false`, will mark array fields as NOT being able to be added to (defaults to true) */
|
|
567
|
+
addable?: boolean;
|
|
568
|
+
/** Flag, if set to `false`, will mark array fields as NOT being able to be ordered (defaults to true) */
|
|
569
|
+
orderable?: boolean;
|
|
570
|
+
/** Flag, if set to `false`, will mark array fields as NOT being able to be removed (defaults to true) */
|
|
571
|
+
removable?: boolean;
|
|
572
|
+
/** Flag, if set to `true`, will mark a list of checkboxes as displayed all on one line instead of one per row */
|
|
573
|
+
inline?: boolean;
|
|
574
|
+
/** Used to change the input type (for example, `tel` or `email`) for an <input> */
|
|
575
|
+
inputType?: string;
|
|
576
|
+
/** Field labels are rendered by default. Labels may be omitted by setting the `label` option to `false` */
|
|
577
|
+
label?: boolean;
|
|
578
|
+
/** Provides a means to set the initial height of a textarea widget */
|
|
579
|
+
rows?: number;
|
|
580
|
+
/** If submitButtonOptions is provided it should match the `UISchemaSubmitButtonOptions` type */
|
|
581
|
+
submitButtonOptions?: UISchemaSubmitButtonOptions;
|
|
582
|
+
/** Allows RJSF to override the default widget implementation by specifying either the name of a widget that is used
|
|
583
|
+
* to look up an implementation from the `widgets` list or an actual one-off widget implementation itself
|
|
584
|
+
*/
|
|
585
|
+
widget?: Widget<T, F> | string;
|
|
586
|
+
/** When using `additionalProperties`, key collision is prevented by appending a unique integer to the duplicate key.
|
|
587
|
+
* This option allows you to change the separator between the original key name and the integer. Default is "-"
|
|
588
|
+
*/
|
|
589
|
+
duplicateKeySuffixSeparator?: string;
|
|
590
|
+
};
|
|
591
|
+
/** The type that represents the Options potentially provided by `ui:options` */
|
|
592
|
+
declare type UIOptionsType<T = any, F = any> = UIOptionsBaseType<T, F> & {
|
|
593
|
+
/** Anything else will be one of these types */
|
|
594
|
+
[key: string]: boolean | number | string | object | any[] | null | undefined;
|
|
595
|
+
};
|
|
596
|
+
/** Type describing the well-known properties of the `UiSchema` while also supporting all user defined properties,
|
|
597
|
+
* starting with `ui:`.
|
|
598
|
+
*/
|
|
599
|
+
declare type UiSchema<T = any, F = any> = GenericObjectType & MakeUIType<UIOptionsBaseType<T, F>> & {
|
|
600
|
+
/** Allows the form to generate a unique prefix for the `Form`'s root prefix */
|
|
601
|
+
"ui:rootFieldId"?: string;
|
|
602
|
+
/** Allows RJSF to override the default field implementation by specifying either the name of a field that is used
|
|
603
|
+
* to look up an implementation from the `fields` list or an actual one-off `Field` component implementation itself
|
|
604
|
+
*/
|
|
605
|
+
"ui:field"?: Field<T, F> | string;
|
|
606
|
+
/** An object that contains all of the potential UI options in a single object */
|
|
607
|
+
"ui:options"?: UIOptionsType<T, F>;
|
|
608
|
+
};
|
|
609
|
+
/** A `CustomValidator` function takes in a `formData` and `errors` object and returns the given `errors` object back,
|
|
610
|
+
* while potentially adding additional messages to the `errors`
|
|
611
|
+
*/
|
|
612
|
+
declare type CustomValidator<T = any> = (formData: T, errors: FormValidation<T>) => FormValidation<T>;
|
|
613
|
+
/** An `ErrorTransformer` function will take in a list of `errors` and potentially return a transformation of those
|
|
614
|
+
* errors in what ever way it deems necessary
|
|
615
|
+
*/
|
|
616
|
+
declare type ErrorTransformer = (errors: RJSFValidationError[]) => RJSFValidationError[];
|
|
617
|
+
/** The type that describes the data that is returned from the `ValidatorType.validateFormData()` function */
|
|
618
|
+
declare type ValidationData<T> = {
|
|
619
|
+
/** The validation errors as a list of `RJSFValidationError` objects */
|
|
620
|
+
errors: RJSFValidationError[];
|
|
621
|
+
/** The validation errors in the form of an `ErrorSchema` */
|
|
622
|
+
errorSchema: ErrorSchema<T>;
|
|
623
|
+
};
|
|
624
|
+
/** The interface that describes the validation functions that are provided by a Validator implementation used by the
|
|
625
|
+
* schema utilities.
|
|
626
|
+
*/
|
|
627
|
+
interface ValidatorType<T = any> {
|
|
628
|
+
/** This function processes the `formData` with an optional user contributed `customValidate` function, which receives
|
|
629
|
+
* the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also
|
|
630
|
+
* supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and
|
|
631
|
+
* transform them in what ever way it chooses.
|
|
632
|
+
*
|
|
633
|
+
* @param formData - The form data to validate
|
|
634
|
+
* @param schema - The schema against which to validate the form data
|
|
635
|
+
* @param [customValidate] - An optional function that is used to perform custom validation
|
|
636
|
+
* @param [transformErrors] - An optional function that is used to transform errors after AJV validation
|
|
637
|
+
*/
|
|
638
|
+
validateFormData(formData: T, schema: RJSFSchema, customValidate?: CustomValidator<T>, transformErrors?: ErrorTransformer): ValidationData<T>;
|
|
639
|
+
/** Converts an `errorSchema` into a list of `RJSFValidationErrors`
|
|
640
|
+
*
|
|
641
|
+
* @param errorSchema - The `ErrorSchema` instance to convert
|
|
642
|
+
* @param [fieldPath=[]] - The current field path, defaults to [] if not specified
|
|
643
|
+
*/
|
|
644
|
+
toErrorList(errorSchema?: ErrorSchema<T>, fieldPath?: string[]): RJSFValidationError[];
|
|
645
|
+
/** Validates data against a schema, returning true if the data is valid, or
|
|
646
|
+
* false otherwise. If the schema is invalid, then this function will return
|
|
647
|
+
* false.
|
|
648
|
+
*
|
|
649
|
+
* @param schema - The schema against which to validate the form data * @param schema
|
|
650
|
+
* @param formData- - The form data to validate
|
|
651
|
+
* @param rootSchema - The root schema used to provide $ref resolutions
|
|
652
|
+
*/
|
|
653
|
+
isValid(schema: RJSFSchema, formData: T, rootSchema: RJSFSchema): boolean;
|
|
654
|
+
}
|
|
655
|
+
/** The `SchemaUtilsType` interface provides a wrapper around the publicly exported APIs in the `@rjsf/utils/schema`
|
|
656
|
+
* directory such that one does not have to explicitly pass the `validator` or `rootSchema` to each method. Since both
|
|
657
|
+
* the `validator` and `rootSchema` generally does not change across a `Form`, this allows for providing a simplified
|
|
658
|
+
* set of APIs to the `@rjsf/core` components and the various themes as well.
|
|
659
|
+
*/
|
|
660
|
+
interface SchemaUtilsType<T = any> {
|
|
661
|
+
/** Returns the `ValidatorType` in the `SchemaUtilsType`
|
|
662
|
+
*
|
|
663
|
+
* @returns - The `ValidatorType`
|
|
664
|
+
*/
|
|
665
|
+
getValidator(): ValidatorType<T>;
|
|
666
|
+
/** Determines whether either the `validator` and `rootSchema` differ from the ones associated with this instance of
|
|
667
|
+
* the `SchemaUtilsType`. If either `validator` or `rootSchema` are falsy, then return false to prevent the creation
|
|
668
|
+
* of a new `SchemaUtilsType` with incomplete properties.
|
|
669
|
+
*
|
|
670
|
+
* @param validator - An implementation of the `ValidatorType` interface that will be compared against the current one
|
|
671
|
+
* @param rootSchema - The root schema that will be compared against the current one
|
|
672
|
+
* @returns - True if the `SchemaUtilsType` differs from the given `validator` or `rootSchema`
|
|
673
|
+
*/
|
|
674
|
+
doesSchemaUtilsDiffer(validator: ValidatorType, rootSchema: RJSFSchema): boolean;
|
|
675
|
+
/** Returns the superset of `formData` that includes the given set updated to include any missing fields that have
|
|
676
|
+
* computed to have defaults provided in the `schema`.
|
|
677
|
+
*
|
|
678
|
+
* @param schema - The schema for which the default state is desired
|
|
679
|
+
* @param [formData] - The current formData, if any, onto which to provide any missing defaults
|
|
680
|
+
* @param [includeUndefinedValues=false] - Optional flag, if true, cause undefined values to be added as defaults
|
|
681
|
+
* @returns - The resulting `formData` with all the defaults provided
|
|
682
|
+
*/
|
|
683
|
+
getDefaultFormState(schema: RJSFSchema, formData?: T, includeUndefinedValues?: boolean): T | T[] | undefined;
|
|
684
|
+
/** Determines whether the combination of `schema` and `uiSchema` properties indicates that the label for the `schema`
|
|
685
|
+
* should be displayed in a UI.
|
|
686
|
+
*
|
|
687
|
+
* @param schema - The schema for which the display label flag is desired
|
|
688
|
+
* @param [uiSchema] - The UI schema from which to derive potentially displayable information
|
|
689
|
+
* @returns - True if the label should be displayed or false if it should not
|
|
690
|
+
*/
|
|
691
|
+
getDisplayLabel<F = any>(schema: RJSFSchema, uiSchema?: UiSchema<T, F>): boolean;
|
|
692
|
+
/** Given the `formData` and list of `options`, attempts to find the index of the option that best matches the data.
|
|
693
|
+
*
|
|
694
|
+
* @param formData - The current formData, if any, onto which to provide any missing defaults
|
|
695
|
+
* @param options - The list of options to find a matching options from
|
|
696
|
+
* @returns - The index of the matched option or 0 if none is available
|
|
697
|
+
*/
|
|
698
|
+
getMatchingOption(formData: T, options: RJSFSchema[]): number;
|
|
699
|
+
/** Checks to see if the `schema` and `uiSchema` combination represents an array of files
|
|
700
|
+
*
|
|
701
|
+
* @param schema - The schema for which check for array of files flag is desired
|
|
702
|
+
* @param [uiSchema] - The UI schema from which to check the widget
|
|
703
|
+
* @returns - True if schema/uiSchema contains an array of files, otherwise false
|
|
704
|
+
*/
|
|
705
|
+
isFilesArray<F = any>(schema: RJSFSchema, uiSchema?: UiSchema<T, F>): boolean;
|
|
706
|
+
/** Checks to see if the `schema` combination represents a multi-select
|
|
707
|
+
*
|
|
708
|
+
* @param schema - The schema for which check for a multi-select flag is desired
|
|
709
|
+
* @returns - True if schema contains a multi-select, otherwise false
|
|
710
|
+
*/
|
|
711
|
+
isMultiSelect(schema: RJSFSchema): boolean;
|
|
712
|
+
/** Checks to see if the `schema` combination represents a select
|
|
713
|
+
*
|
|
714
|
+
* @param schema - The schema for which check for a select flag is desired
|
|
715
|
+
* @returns - True if schema contains a select, otherwise false
|
|
716
|
+
*/
|
|
717
|
+
isSelect(schema: RJSFSchema): boolean;
|
|
718
|
+
/** Merges the errors in `additionalErrorSchema` into the existing `validationData` by combining the hierarchies in the
|
|
719
|
+
* two `ErrorSchema`s and then appending the error list from the `additionalErrorSchema` obtained by calling
|
|
720
|
+
* `validator.toErrorList()` onto the `errors` in the `validationData`. If no `additionalErrorSchema` is passed, then
|
|
721
|
+
* `validationData` is returned.
|
|
722
|
+
*
|
|
723
|
+
* @param validator - The validator used to convert an ErrorSchema to a list of errors
|
|
724
|
+
* @param validationData - The current `ValidationData` into which to merge the additional errors
|
|
725
|
+
* @param [additionalErrorSchema] - The additional set of errors
|
|
726
|
+
* @returns - The `validationData` with the additional errors from `additionalErrorSchema` merged into it, if provided.
|
|
727
|
+
*/
|
|
728
|
+
mergeValidationData(validationData: ValidationData<T>, additionalErrorSchema?: ErrorSchema<T>): ValidationData<T>;
|
|
729
|
+
/** Retrieves an expanded schema that has had all of its conditions, additional properties, references and
|
|
730
|
+
* dependencies resolved and merged into the `schema` given a `rawFormData` that is used to do the potentially
|
|
731
|
+
* recursive resolution.
|
|
732
|
+
*
|
|
733
|
+
* @param schema - The schema for which retrieving a schema is desired
|
|
734
|
+
* @param [rawFormData] - The current formData, if any, to assist retrieving a schema
|
|
735
|
+
* @returns - The schema having its conditions, additional properties, references and dependencies resolved
|
|
736
|
+
*/
|
|
737
|
+
retrieveSchema(schema: RJSFSchema, formData?: T): RJSFSchema;
|
|
738
|
+
/** Generates an `IdSchema` object for the `schema`, recursively
|
|
739
|
+
*
|
|
740
|
+
* @param schema - The schema for which the display label flag is desired
|
|
741
|
+
* @param [id] - The base id for the schema
|
|
742
|
+
* @param [formData] - The current formData, if any, onto which to provide any missing defaults
|
|
743
|
+
* @param [idPrefix='root'] - The prefix to use for the id
|
|
744
|
+
* @param [idSeparator='_'] - The separator to use for the path segments in the id
|
|
745
|
+
* @returns - The `IdSchema` object for the `schema`
|
|
746
|
+
*/
|
|
747
|
+
toIdSchema(schema: RJSFSchema, id?: string, formData?: T, idPrefix?: string, idSeparator?: string): IdSchema<T>;
|
|
748
|
+
/** Generates an `PathSchema` object for the `schema`, recursively
|
|
749
|
+
*
|
|
750
|
+
* @param schema - The schema for which the display label flag is desired
|
|
751
|
+
* @param [name] - The base name for the schema
|
|
752
|
+
* @param [formData] - The current formData, if any, onto which to provide any missing defaults
|
|
753
|
+
* @returns - The `PathSchema` object for the `schema`
|
|
754
|
+
*/
|
|
755
|
+
toPathSchema(schema: RJSFSchema, name?: string, formData?: T): PathSchema<T>;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
/** Checks the schema to see if it is allowing additional items, by verifying that `schema.additionalItems` is an
|
|
759
|
+
* object. The user is warned in the console if `schema.additionalItems` has the value `true`.
|
|
760
|
+
*
|
|
761
|
+
* @param schema - The schema object to check
|
|
762
|
+
* @returns - True if additional items is allowed, otherwise false
|
|
763
|
+
*/
|
|
764
|
+
declare function allowAdditionalItems(schema: RJSFSchema): boolean;
|
|
765
|
+
|
|
766
|
+
/** Attempts to convert the string into a number. If an empty string is provided, then `undefined` is returned. If a
|
|
767
|
+
* `null` is provided, it is returned. If the string ends in a `.` then the string is returned because the user may be
|
|
768
|
+
* in the middle of typing a float number. If a number ends in a pattern like `.0`, `.20`, `.030`, string is returned
|
|
769
|
+
* because the user may be typing number that will end in a non-zero digit. Otherwise, the string is wrapped by
|
|
770
|
+
* `Number()` and if that result is not `NaN`, that number will be returned, otherwise the string `value` will be.
|
|
771
|
+
*
|
|
772
|
+
* @param value - The string or null value to convert to a number
|
|
773
|
+
* @returns - The `value` converted to a number when appropriate, otherwise the `value`
|
|
774
|
+
*/
|
|
775
|
+
declare function asNumber(value: string | null): string | number | null | undefined;
|
|
776
|
+
|
|
777
|
+
/** Checks whether the field described by `schema`, having the `uiSchema` and `formData` supports expanding. The UI for
|
|
778
|
+
* the field can expand if it has additional properties, is not forced as non-expandable by the `uiSchema` and the
|
|
779
|
+
* `formData` object doesn't already have `schema.maxProperties` elements.
|
|
780
|
+
*
|
|
781
|
+
* @param schema - The schema for the field that is being checked
|
|
782
|
+
* @param [uiSchema={}] - The uiSchema for the field
|
|
783
|
+
* @param [formData] - The formData for the field
|
|
784
|
+
* @returns - True if the schema element has additionalProperties, is expandable, and not at the maxProperties limit
|
|
785
|
+
*/
|
|
786
|
+
declare function canExpand<T = any, F = any>(schema: RJSFSchema, uiSchema?: UiSchema<T, F>, formData?: T): boolean;
|
|
787
|
+
|
|
788
|
+
/** Creates a `SchemaUtilsType` interface that is based around the given `validator` and `rootSchema` parameters. The
|
|
789
|
+
* resulting interface implementation will forward the `validator` and `rootSchema` to all the wrapped APIs.
|
|
790
|
+
*
|
|
791
|
+
* @param validator - an implementation of the `ValidatorType` interface that will be forwarded to all the APIs
|
|
792
|
+
* @param rootSchema - The root schema that will be forwarded to all the APIs
|
|
793
|
+
* @returns - An implementation of a `SchemaUtilsType` interface
|
|
794
|
+
*/
|
|
795
|
+
declare function createSchemaUtils<T = any>(validator: ValidatorType, rootSchema: RJSFSchema): SchemaUtilsType<T>;
|
|
796
|
+
|
|
797
|
+
/** Given the `FileReader.readAsDataURL()` based `dataURI` extracts that data into an actual Blob along with the name
|
|
798
|
+
* of that Blob if provided in the URL. If no name is provided, then the name falls back to `unknown`.
|
|
799
|
+
*
|
|
800
|
+
* @param dataURI - The `DataUrl` potentially containing name and raw data to be converted to a Blob
|
|
801
|
+
* @returns - an object containing a Blob and its name, extracted from the URI
|
|
802
|
+
*/
|
|
803
|
+
declare function dataURItoBlob(dataURI: string): {
|
|
804
|
+
blob: Blob;
|
|
805
|
+
name: string;
|
|
806
|
+
};
|
|
807
|
+
|
|
808
|
+
/** Implements a deep equals using the `lodash.isEqualWith` function, that provides a customized comparator that
|
|
809
|
+
* assumes all functions are equivalent.
|
|
810
|
+
*
|
|
811
|
+
* @param a - The first element to compare
|
|
812
|
+
* @param b - The second element to compare
|
|
813
|
+
* @returns - True if the `a` and `b` are deeply equal, false otherwise
|
|
814
|
+
*/
|
|
815
|
+
declare function deepEquals(a: any, b: any): boolean;
|
|
816
|
+
|
|
817
|
+
/** Given the name of a `$ref` from within a schema, using the `rootSchema`, look up and return the sub-schema using the
|
|
818
|
+
* path provided by that reference. If `#` is not the first character of the reference, or the path does not exist in
|
|
819
|
+
* the schema, then throw an Error. Otherwise return the sub-schema. Also deals with nested `$ref`s in the sub-schema.
|
|
820
|
+
*
|
|
821
|
+
* @param $ref - The ref string for which the schema definition is desired
|
|
822
|
+
* @param [rootSchema={}] - The root schema in which to search for the definition
|
|
823
|
+
* @returns - The sub-schema within the `rootSchema` which matches the `$ref` if it exists
|
|
824
|
+
* @throws - Error indicating that no schema for that reference exists
|
|
825
|
+
*/
|
|
826
|
+
declare function findSchemaDefinition($ref?: string, rootSchema?: RJSFSchema): RJSFSchema;
|
|
827
|
+
|
|
828
|
+
/** Using the `schema`, `defaultType` and `options`, extract out the props for the <input> element that make sense.
|
|
829
|
+
*
|
|
830
|
+
* @param schema - The schema for the field provided by the widget
|
|
831
|
+
* @param [defaultType] - The default type, if any, for the field provided by the widget
|
|
832
|
+
* @param [options={}] - The UI Options for the field provided by the widget
|
|
833
|
+
* @param [autoDefaultStepAny=true] - Determines whether to auto-default step=any when the type is number and no step
|
|
834
|
+
* @returns - The extracted `InputPropsType` object
|
|
835
|
+
*/
|
|
836
|
+
declare function getInputProps<T = any, F = any>(schema: RJSFSchema, defaultType?: string, options?: UIOptionsType<T, F>, autoDefaultStepAny?: boolean): InputPropsType;
|
|
837
|
+
|
|
838
|
+
/** Gets the type of a given `schema`. If the type is not explicitly defined, then an attempt is made to infer it from
|
|
839
|
+
* other elements of the schema as follows:
|
|
840
|
+
* - schema.const: Returns the `guessType()` of that value
|
|
841
|
+
* - schema.enum: Returns `string`
|
|
842
|
+
* - schema.properties: Returns `object`
|
|
843
|
+
* - schema.additionalProperties: Returns `object`
|
|
844
|
+
* - type is an array with a length of 2 and one type is 'null': Returns the other type
|
|
845
|
+
*
|
|
846
|
+
* @param schema - The schema for which to get the type
|
|
847
|
+
* @returns - The type of the schema
|
|
848
|
+
*/
|
|
849
|
+
declare function getSchemaType(schema: RJSFSchema): string | string[] | undefined;
|
|
850
|
+
|
|
851
|
+
/** Extracts any `ui:submitButtonOptions` from the `uiSchema` and merges them onto the `DEFAULT_OPTIONS`
|
|
852
|
+
*
|
|
853
|
+
* @param [uiSchema={}] - the UI Schema from which to extract submit button props
|
|
854
|
+
* @returns - The merging of the `DEFAULT_OPTIONS` with any custom ones
|
|
855
|
+
*/
|
|
856
|
+
declare function getSubmitButtonOptions<T = any, F = any>(uiSchema?: UiSchema<T, F>): UISchemaSubmitButtonOptions;
|
|
857
|
+
|
|
858
|
+
/** Returns the template with the given `name` from either the `uiSchema` if it is defined or from the `registry`
|
|
859
|
+
* otherwise. NOTE, since `ButtonTemplates` are not overridden in `uiSchema` only those in the `registry` are returned.
|
|
860
|
+
*
|
|
861
|
+
* @param name - The name of the template to fetch, restricted to the keys of `TemplatesType`
|
|
862
|
+
* @param registry - The `Registry` from which to read the template
|
|
863
|
+
* @param [uiOptions={}] - The `UIOptionsType` from which to read an alternate template
|
|
864
|
+
* @returns - The template from either the `uiSchema` or `registry` for the `name`
|
|
865
|
+
*/
|
|
866
|
+
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];
|
|
867
|
+
|
|
868
|
+
/** Get all passed options from ui:options, and ui:<optionName>, returning them in an object with the `ui:`
|
|
869
|
+
* stripped off.
|
|
870
|
+
*
|
|
871
|
+
* @param [uiSchema={}] - The UI Schema from which to get any `ui:xxx` options
|
|
872
|
+
* @returns - An object containing all of the `ui:xxx` options with the stripped off
|
|
873
|
+
*/
|
|
874
|
+
declare function getUiOptions<T = any, F = any>(uiSchema?: UiSchema<T, F>): UIOptionsType<T, F>;
|
|
875
|
+
|
|
876
|
+
/** Given a schema representing a field to render and either the name or actual `Widget` implementation, returns the
|
|
877
|
+
* React component that is used to render the widget. If the `widget` is already a React component, then it is wrapped
|
|
878
|
+
* with a `MergedWidget`. Otherwise an attempt is made to look up the widget inside of the `registeredWidgets` map based
|
|
879
|
+
* on the schema type and `widget` name. If no widget component can be found an `Error` is thrown.
|
|
880
|
+
*
|
|
881
|
+
* @param schema - The schema for the field
|
|
882
|
+
* @param [widget] - Either the name of the widget OR a `Widget` implementation to use
|
|
883
|
+
* @param [registeredWidgets={}] - A registry of widget name to `Widget` implementation
|
|
884
|
+
* @returns - The `Widget` component to use
|
|
885
|
+
* @throws - An error if there is no `Widget` component that can be returned
|
|
886
|
+
*/
|
|
887
|
+
declare function getWidget<T = any, F = any>(schema: RJSFSchema, widget?: Widget<T, F> | string, registeredWidgets?: RegistryWidgetsType<T, F>): Widget<T, F>;
|
|
888
|
+
|
|
889
|
+
/** Given a specific `value` attempts to guess the type of a schema element. In the case where we have to implicitly
|
|
890
|
+
* create a schema, it is useful to know what type to use based on the data we are defining.
|
|
891
|
+
*
|
|
892
|
+
* @param value - The value from which to guess the type
|
|
893
|
+
* @returns - The best guess for the object type
|
|
894
|
+
*/
|
|
895
|
+
declare function guessType(value: any): "array" | "string" | "null" | "boolean" | "number" | "object";
|
|
896
|
+
|
|
897
|
+
/** Detects whether the `widget` exists for the `schema` with the associated `registryWidgets` and returns true if it
|
|
898
|
+
* does, or false if it doesn't.
|
|
899
|
+
*
|
|
900
|
+
* @param schema - The schema for the field
|
|
901
|
+
* @param widget - Either the name of the widget OR a `Widget` implementation to use
|
|
902
|
+
* @param [registeredWidgets={}] - A registry of widget name to `Widget` implementation
|
|
903
|
+
* @returns - True if the widget exists, false otherwise
|
|
904
|
+
*/
|
|
905
|
+
declare function hasWidget<T = any, F = any>(schema: RJSFSchema, widget: Widget<T, F> | string, registeredWidgets?: RegistryWidgetsType<T, F>): boolean;
|
|
906
|
+
|
|
907
|
+
/** This function checks if the given `schema` matches a single constant value. This happens when either the schema has
|
|
908
|
+
* an `enum` array with a single value or there is a `const` defined.
|
|
909
|
+
*
|
|
910
|
+
* @param schema - The schema for a field
|
|
911
|
+
* @returns - True if the `schema` has a single constant value, false otherwise
|
|
912
|
+
*/
|
|
913
|
+
declare function isConstant(schema: RJSFSchema): boolean;
|
|
914
|
+
|
|
915
|
+
/** Checks to see if the `uiSchema` contains the `widget` field and that the widget is not `hidden`
|
|
916
|
+
*
|
|
917
|
+
* @param uiSchema - The UI Schema from which to detect if it is customized
|
|
918
|
+
* @returns - True if the `uiSchema` describes a custom widget, false otherwise
|
|
919
|
+
*/
|
|
920
|
+
declare function isCustomWidget<T = any, F = any>(uiSchema?: UiSchema<T, F>): boolean;
|
|
921
|
+
|
|
922
|
+
/** Detects whether the given `schema` contains fixed items. This is the case when `schema.items` is a non-empty array
|
|
923
|
+
* that only contains objects.
|
|
924
|
+
*
|
|
925
|
+
* @param schema - The schema in which to check for fixed items
|
|
926
|
+
* @returns - True if there are fixed items in the schema, false otherwise
|
|
927
|
+
*/
|
|
928
|
+
declare function isFixedItems(schema: RJSFSchema): boolean;
|
|
929
|
+
|
|
930
|
+
/** Determines whether a `thing` is an object for the purposes of RSJF. In this case, `thing` is an object if it has
|
|
931
|
+
* the type `object` but is NOT null, an array or a File.
|
|
932
|
+
*
|
|
933
|
+
* @param thing - The thing to check to see whether it is an object
|
|
934
|
+
* @returns - True if it is a non-null, non-array, non-File object
|
|
935
|
+
*/
|
|
936
|
+
declare function isObject(thing: any): boolean;
|
|
937
|
+
|
|
938
|
+
/** Converts a local Date string into a UTC date string
|
|
939
|
+
*
|
|
940
|
+
* @param dateString - The string representation of a date as accepted by the `Date()` constructor
|
|
941
|
+
* @returns - A UTC date string if `dateString` is truthy, otherwise undefined
|
|
942
|
+
*/
|
|
943
|
+
declare function localToUTC(dateString: string): string | undefined;
|
|
944
|
+
|
|
945
|
+
/** Merges the `defaults` object of type `T` into the `formData` of type `T`
|
|
946
|
+
*
|
|
947
|
+
* When merging defaults and form data, we want to merge in this specific way:
|
|
948
|
+
* - objects are deeply merged
|
|
949
|
+
* - arrays are merged in such a way that:
|
|
950
|
+
* - when the array is set in form data, only array entries set in form data
|
|
951
|
+
* are deeply merged; additional entries from the defaults are ignored
|
|
952
|
+
* - when the array is not set in form data, the default is copied over
|
|
953
|
+
* - scalars are overwritten/set by form data
|
|
954
|
+
*
|
|
955
|
+
* @param defaults - The defaults to merge
|
|
956
|
+
* @param formData - The form data into which the defaults will be merged
|
|
957
|
+
* @returns - The resulting merged form data with defaults
|
|
958
|
+
*/
|
|
959
|
+
declare function mergeDefaultsWithFormData<T = any>(defaults: T, formData: T): T;
|
|
960
|
+
|
|
961
|
+
/** Recursively merge deeply nested objects.
|
|
962
|
+
*
|
|
963
|
+
* @param obj1 - The first object to merge
|
|
964
|
+
* @param obj2 - The second object to merge
|
|
965
|
+
* @param [concatArrays=false] - Optional flag that, when true, will cause arrays to be concatenated
|
|
966
|
+
* @returns - A new object that is the merge of the two given objects
|
|
967
|
+
*/
|
|
968
|
+
declare function mergeObjects(obj1: GenericObjectType, obj2: GenericObjectType, concatArrays?: boolean): GenericObjectType;
|
|
969
|
+
|
|
970
|
+
/** Recursively merge deeply nested schemas. The difference between `mergeSchemas` and `mergeObjects` is that
|
|
971
|
+
* `mergeSchemas` only concats arrays for values under the 'required' keyword, and when it does, it doesn't include
|
|
972
|
+
* duplicate values.
|
|
973
|
+
*
|
|
974
|
+
* @param obj1 - The first schema object to merge
|
|
975
|
+
* @param obj2 - The second schema object to merge
|
|
976
|
+
* @returns - The merged schema object
|
|
977
|
+
*/
|
|
978
|
+
declare function mergeSchemas(obj1: GenericObjectType, obj2: GenericObjectType): GenericObjectType;
|
|
979
|
+
|
|
980
|
+
/** Gets the list of options from the schema. If the schema has an enum list, then those enum values are returned. The
|
|
981
|
+
* labels for the options will be extracted from the non-standard, RJSF-deprecated `enumNames` if it exists, otherwise
|
|
982
|
+
* the label will be the same as the `value`. If the schema has a `oneOf` or `anyOf`, then the value is the list of
|
|
983
|
+
* `const` values from the schema and the label is either the `schema.title` or the value.
|
|
984
|
+
*
|
|
985
|
+
* @param schema - The schema from which to extract the options list
|
|
986
|
+
* @returns - The list of options from the schema
|
|
987
|
+
*/
|
|
988
|
+
declare function optionsList(schema: RJSFSchema): EnumOptionsType[] | undefined;
|
|
989
|
+
|
|
990
|
+
/** Given a list of `properties` and an `order` list, returns a list that contains the `properties` ordered correctly.
|
|
991
|
+
* If `order` is not an array, then the untouched `properties` list is returned. Otherwise `properties` is ordered per
|
|
992
|
+
* the `order` list. If `order` contains a '*' then any `properties` that are not mentioned explicity in `order` will be
|
|
993
|
+
* places in the location of the `*`.
|
|
994
|
+
*
|
|
995
|
+
* @param properties - The list of property keys to be ordered
|
|
996
|
+
* @param order - An array of property keys to be ordered first, with an optional '*' property
|
|
997
|
+
* @returns - A list with the `properties` ordered
|
|
998
|
+
* @throws - Error when the properties cannot be ordered correctly
|
|
999
|
+
*/
|
|
1000
|
+
declare function orderProperties(properties: string[], order?: string[]): string[];
|
|
1001
|
+
|
|
1002
|
+
/** Returns a string representation of the `num` that is padded with leading "0"s if necessary
|
|
1003
|
+
*
|
|
1004
|
+
* @param num - The number to pad
|
|
1005
|
+
* @param width - The width of the string at which no lead padding is necessary
|
|
1006
|
+
* @returns - The number converted to a string with leading zero padding if the number of digits is less than `width`
|
|
1007
|
+
*/
|
|
1008
|
+
declare function pad(num: number, width: number): string;
|
|
1009
|
+
|
|
1010
|
+
/** Parses the `dateString` into a `DateObject`, including the time information when `includeTime` is true
|
|
1011
|
+
*
|
|
1012
|
+
* @param dateString - The date string to parse into a DateObject
|
|
1013
|
+
* @param [includeTime=true] - Optional flag, if false, will not include the time data into the object
|
|
1014
|
+
* @returns - The date string converted to a `DateObject`
|
|
1015
|
+
* @throws - Error when the date cannot be parsed from the string
|
|
1016
|
+
*/
|
|
1017
|
+
declare function parseDateString(dateString?: string, includeTime?: boolean): DateObject;
|
|
1018
|
+
|
|
1019
|
+
/** Returns the real value for a select widget due to a silly limitation in the DOM which causes option change event
|
|
1020
|
+
* values to always be retrieved as strings. Uses the `schema` to help determine the value's true type. If the value is
|
|
1021
|
+
* an empty string, then the `emptyValue` from the `options` is returned, falling back to undefined.
|
|
1022
|
+
*
|
|
1023
|
+
* @param schema - The schema to used to determine the value's true type
|
|
1024
|
+
* @param [value] - The value to convert
|
|
1025
|
+
* @param [options] - The UIOptionsType from which to potentially extract the emptyValue
|
|
1026
|
+
* @returns - The `value` converted to the proper type
|
|
1027
|
+
*/
|
|
1028
|
+
declare function processSelectValue<T = any, F = any>(schema: RJSFSchema, value?: any, options?: UIOptionsType<T, F>): any;
|
|
1029
|
+
|
|
1030
|
+
/** Extracts the range spec information `{ step?: number, min?: number, max?: number }` that can be spread onto an HTML
|
|
1031
|
+
* input from the range analog in the schema `{ multipleOf?: number, minimum?: number, maximum?: number }`.
|
|
1032
|
+
*
|
|
1033
|
+
* @param schema - The schema from which to extract the range spec
|
|
1034
|
+
* @returns - A range specification from the schema
|
|
1035
|
+
*/
|
|
1036
|
+
declare function rangeSpec(schema: RJSFSchema): RangeSpecType;
|
|
1037
|
+
|
|
1038
|
+
/** Check to see if a `schema` specifies that a value must be true. This happens when:
|
|
1039
|
+
* - `schema.const` is truthy
|
|
1040
|
+
* - `schema.enum` == `[true]`
|
|
1041
|
+
* - `schema.anyOf` or `schema.oneOf` has a single value which recursively returns true
|
|
1042
|
+
* - `schema.allOf` has at least one value which recursively returns true
|
|
1043
|
+
*
|
|
1044
|
+
* @param schema - The schema to check
|
|
1045
|
+
* @returns - True if the schema specifies a value that must be true, false otherwise
|
|
1046
|
+
*/
|
|
1047
|
+
declare function schemaRequiresTrueValue(schema: RJSFSchema): boolean;
|
|
1048
|
+
|
|
1049
|
+
/** Determines whether the given `component` should be rerendered by comparing its current set of props and state
|
|
1050
|
+
* against the next set. If either of those two sets are not the same, then the component should be rerendered.
|
|
1051
|
+
*
|
|
1052
|
+
* @param component - A React component being checked
|
|
1053
|
+
* @param nextProps - The next set of props against which to check
|
|
1054
|
+
* @param nextState - The next set of state against which to check
|
|
1055
|
+
* @returns - True if the component should be re-rendered, false otherwise
|
|
1056
|
+
*/
|
|
1057
|
+
declare function shouldRender(component: React.Component, nextProps: any, nextState: any): boolean;
|
|
1058
|
+
|
|
1059
|
+
/** Returns the constant value from the schema when it is either a single value enum or has a const key. Otherwise
|
|
1060
|
+
* throws an error.
|
|
1061
|
+
*
|
|
1062
|
+
* @param schema - The schema from which to obtain the constant value
|
|
1063
|
+
* @returns - The constant value for the schema
|
|
1064
|
+
* @throws - Error when the schema does not have a constant value
|
|
1065
|
+
*/
|
|
1066
|
+
declare function toConstant(schema: RJSFSchema): json_schema.JSONSchema7Type | undefined;
|
|
1067
|
+
|
|
1068
|
+
/** Returns a UTC date string for the given `dateObject`. If `time` is false, then the time portion of the string is
|
|
1069
|
+
* removed.
|
|
1070
|
+
*
|
|
1071
|
+
* @param dateObject - The `DateObject` to convert to a date string
|
|
1072
|
+
* @param [time=true] - Optional flag used to remove the time portion of the date string if false
|
|
1073
|
+
* @returns - The UTC date string
|
|
1074
|
+
*/
|
|
1075
|
+
declare function toDateString(dateObject: DateObject, time?: boolean): string;
|
|
1076
|
+
|
|
1077
|
+
/** Converts a UTC date string into a local Date format
|
|
1078
|
+
*
|
|
1079
|
+
* @param jsonDate - A UTC date string
|
|
1080
|
+
* @returns - An empty string when `jsonDate` is falsey, otherwise a date string in local format
|
|
1081
|
+
*/
|
|
1082
|
+
declare function utcToLocal(jsonDate: string): string;
|
|
1083
|
+
|
|
1084
|
+
/** Below are the list of all the keys into various elements of a RJSFSchema or UiSchema that are used by the various
|
|
1085
|
+
* utility functions. In addition to those keys, there are the special `ADDITIONAL_PROPERTY_FLAG` and
|
|
1086
|
+
* `RJSF_ADDITONAL_PROPERTIES_FLAG` flags that is added to a schema under certain conditions by the `retrieveSchema()`
|
|
1087
|
+
* utility.
|
|
1088
|
+
*/
|
|
1089
|
+
declare const ADDITIONAL_PROPERTY_FLAG = "__additional_property";
|
|
1090
|
+
declare const ADDITIONAL_PROPERTIES_KEY = "additionalProperties";
|
|
1091
|
+
declare const ALL_OF_KEY = "allOf";
|
|
1092
|
+
declare const ANY_OF_KEY = "anyOf";
|
|
1093
|
+
declare const CONST_KEY = "const";
|
|
1094
|
+
declare const DEFAULT_KEY = "default";
|
|
1095
|
+
declare const DEFINITIONS_KEY = "definitions";
|
|
1096
|
+
declare const DEPENDENCIES_KEY = "dependencies";
|
|
1097
|
+
declare const ENUM_KEY = "enum";
|
|
1098
|
+
declare const ERRORS_KEY = "__errors";
|
|
1099
|
+
declare const ID_KEY = "$id";
|
|
1100
|
+
declare const ITEMS_KEY = "items";
|
|
1101
|
+
declare const NAME_KEY = "$name";
|
|
1102
|
+
declare const ONE_OF_KEY = "oneOf";
|
|
1103
|
+
declare const PROPERTIES_KEY = "properties";
|
|
1104
|
+
declare const REQUIRED_KEY = "required";
|
|
1105
|
+
declare const SUBMIT_BTN_OPTIONS_KEY = "submitButtonOptions";
|
|
1106
|
+
declare const REF_KEY = "$ref";
|
|
1107
|
+
declare const RJSF_ADDITONAL_PROPERTIES_FLAG = "__rjsf_additionalProperties";
|
|
1108
|
+
declare const UI_FIELD_KEY = "ui:field";
|
|
1109
|
+
declare const UI_WIDGET_KEY = "ui:widget";
|
|
1110
|
+
declare const UI_OPTIONS_KEY = "ui:options";
|
|
1111
|
+
|
|
1112
|
+
/** Returns the superset of `formData` that includes the given set updated to include any missing fields that have
|
|
1113
|
+
* computed to have defaults provided in the `schema`.
|
|
1114
|
+
*
|
|
1115
|
+
* @param validator - An implementation of the `ValidatorType` interface that will be used when necessary
|
|
1116
|
+
* @param theSchema - The schema for which the default state is desired
|
|
1117
|
+
* @param [formData] - The current formData, if any, onto which to provide any missing defaults
|
|
1118
|
+
* @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
|
|
1119
|
+
* @param [includeUndefinedValues=false] - Optional flag, if true, cause undefined values to be added as defaults
|
|
1120
|
+
* @returns - The resulting `formData` with all the defaults provided
|
|
1121
|
+
*/
|
|
1122
|
+
declare function getDefaultFormState<T = any>(validator: ValidatorType, theSchema: RJSFSchema, formData?: T, rootSchema?: RJSFSchema, includeUndefinedValues?: boolean): T | T[] | undefined;
|
|
1123
|
+
|
|
1124
|
+
/** Determines whether the combination of `schema` and `uiSchema` properties indicates that the label for the `schema`
|
|
1125
|
+
* should be displayed in a UI.
|
|
1126
|
+
*
|
|
1127
|
+
* @param validator - An implementation of the `ValidatorType` interface that will be used when necessary
|
|
1128
|
+
* @param schema - The schema for which the display label flag is desired
|
|
1129
|
+
* @param [uiSchema={}] - The UI schema from which to derive potentially displayable information
|
|
1130
|
+
* @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
|
|
1131
|
+
* @returns - True if the label should be displayed or false if it should not
|
|
1132
|
+
*/
|
|
1133
|
+
declare function getDisplayLabel<T = any, F = any>(validator: ValidatorType, schema: RJSFSchema, uiSchema?: UiSchema<T, F>, rootSchema?: RJSFSchema): boolean;
|
|
1134
|
+
|
|
1135
|
+
/** Given the `formData` and list of `options`, attempts to find the index of the option that best matches the data.
|
|
1136
|
+
*
|
|
1137
|
+
* @param validator - An implementation of the `ValidatorType` interface that will be used when necessary
|
|
1138
|
+
* @param formData - The current formData, if any, used to figure out a match
|
|
1139
|
+
* @param options - The list of options to find a matching options from
|
|
1140
|
+
* @param rootSchema - The root schema, used to primarily to look up `$ref`s
|
|
1141
|
+
* @returns - The index of the matched option or 0 if none is available
|
|
1142
|
+
*/
|
|
1143
|
+
declare function getMatchingOption<T = any>(validator: ValidatorType, formData: T | undefined, options: RJSFSchema[], rootSchema: RJSFSchema): number;
|
|
1144
|
+
|
|
1145
|
+
/** Checks to see if the `schema` and `uiSchema` combination represents an array of files
|
|
1146
|
+
*
|
|
1147
|
+
* @param validator - An implementation of the `ValidatorType` interface that will be used when necessary
|
|
1148
|
+
* @param schema - The schema for which check for array of files flag is desired
|
|
1149
|
+
* @param [uiSchema={}] - The UI schema from which to check the widget
|
|
1150
|
+
* @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
|
|
1151
|
+
* @returns - True if schema/uiSchema contains an array of files, otherwise false
|
|
1152
|
+
*/
|
|
1153
|
+
declare function isFilesArray<T = any, F = any>(validator: ValidatorType, schema: RJSFSchema, uiSchema?: UiSchema<T, F>, rootSchema?: RJSFSchema): boolean;
|
|
1154
|
+
|
|
1155
|
+
/** Checks to see if the `schema` combination represents a multi-select
|
|
1156
|
+
*
|
|
1157
|
+
* @param validator - An implementation of the `ValidatorType` interface that will be used when necessary
|
|
1158
|
+
* @param schema - The schema for which check for a multi-select flag is desired
|
|
1159
|
+
* @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
|
|
1160
|
+
* @returns - True if schema contains a multi-select, otherwise false
|
|
1161
|
+
*/
|
|
1162
|
+
declare function isMultiSelect<T = any>(validator: ValidatorType, schema: RJSFSchema, rootSchema?: RJSFSchema): boolean;
|
|
1163
|
+
|
|
1164
|
+
/** Checks to see if the `schema` combination represents a select
|
|
1165
|
+
*
|
|
1166
|
+
* @param validator - An implementation of the `ValidatorType` interface that will be used when necessary
|
|
1167
|
+
* @param theSchema - The schema for which check for a select flag is desired
|
|
1168
|
+
* @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
|
|
1169
|
+
* @returns - True if schema contains a select, otherwise false
|
|
1170
|
+
*/
|
|
1171
|
+
declare function isSelect<T = any>(validator: ValidatorType, theSchema: RJSFSchema, rootSchema?: RJSFSchema): boolean;
|
|
1172
|
+
|
|
1173
|
+
/** Merges the errors in `additionalErrorSchema` into the existing `validationData` by combining the hierarchies in the
|
|
1174
|
+
* two `ErrorSchema`s and then appending the error list from the `additionalErrorSchema` obtained by calling
|
|
1175
|
+
* `validator.toErrorList()` onto the `errors` in the `validationData`. If no `additionalErrorSchema` is passed, then
|
|
1176
|
+
* `validationData` is returned.
|
|
1177
|
+
*
|
|
1178
|
+
* @param validator - The validator used to convert an ErrorSchema to a list of errors
|
|
1179
|
+
* @param validationData - The current `ValidationData` into which to merge the additional errors
|
|
1180
|
+
* @param [additionalErrorSchema] - The additional set of errors in an `ErrorSchema`
|
|
1181
|
+
* @returns - The `validationData` with the additional errors from `additionalErrorSchema` merged into it, if provided.
|
|
1182
|
+
*/
|
|
1183
|
+
declare function mergeValidationData<T = any>(validator: ValidatorType<T>, validationData: ValidationData<T>, additionalErrorSchema?: ErrorSchema<T>): ValidationData<T>;
|
|
1184
|
+
|
|
1185
|
+
/** Retrieves an expanded schema that has had all of its conditions, additional properties, references and dependencies
|
|
1186
|
+
* resolved and merged into the `schema` given a `validator`, `rootSchema` and `rawFormData` that is used to do the
|
|
1187
|
+
* potentially recursive resolution.
|
|
1188
|
+
*
|
|
1189
|
+
* @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs
|
|
1190
|
+
* @param schema - The schema for which retrieving a schema is desired
|
|
1191
|
+
* @param [rootSchema={}] - The root schema that will be forwarded to all the APIs
|
|
1192
|
+
* @param [rawFormData] - The current formData, if any, to assist retrieving a schema
|
|
1193
|
+
* @returns - The schema having its conditions, additional properties, references and dependencies resolved
|
|
1194
|
+
*/
|
|
1195
|
+
declare function retrieveSchema<T = any>(validator: ValidatorType, schema: RJSFSchema, rootSchema?: RJSFSchema, rawFormData?: T): RJSFSchema;
|
|
1196
|
+
|
|
1197
|
+
/** Generates an `IdSchema` object for the `schema`, recursively
|
|
1198
|
+
*
|
|
1199
|
+
* @param validator - An implementation of the `ValidatorType` interface that will be used when necessary
|
|
1200
|
+
* @param schema - The schema for which the `IdSchema` is desired
|
|
1201
|
+
* @param [id] - The base id for the schema
|
|
1202
|
+
* @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
|
|
1203
|
+
* @param [formData] - The current formData, if any, to assist retrieving a schema
|
|
1204
|
+
* @param [idPrefix='root'] - The prefix to use for the id
|
|
1205
|
+
* @param [idSeparator='_'] - The separator to use for the path segments in the id
|
|
1206
|
+
* @returns - The `IdSchema` object for the `schema`
|
|
1207
|
+
*/
|
|
1208
|
+
declare function toIdSchema<T = any>(validator: ValidatorType, schema: RJSFSchema, id?: string | null, rootSchema?: RJSFSchema, formData?: T, idPrefix?: string, idSeparator?: string): IdSchema<T>;
|
|
1209
|
+
|
|
1210
|
+
/** Generates an `PathSchema` object for the `schema`, recursively
|
|
1211
|
+
*
|
|
1212
|
+
* @param validator - An implementation of the `ValidatorType` interface that will be used when necessary
|
|
1213
|
+
* @param schema - The schema for which the `PathSchema` is desired
|
|
1214
|
+
* @param [name=''] - The base name for the schema
|
|
1215
|
+
* @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
|
|
1216
|
+
* @param [formData] - The current formData, if any, to assist retrieving a schema
|
|
1217
|
+
* @returns - The `PathSchema` object for the `schema`
|
|
1218
|
+
*/
|
|
1219
|
+
declare function toPathSchema<T = any>(validator: ValidatorType, schema: RJSFSchema, name?: string, rootSchema?: RJSFSchema, formData?: T): PathSchema<T>;
|
|
1220
|
+
|
|
1221
|
+
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, FieldErrors, 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, 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 };
|