@rjsf/utils 5.0.0-beta.1
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/LICENSE.md +201 -0
- package/README.md +106 -0
- package/dist/allowAdditionalItems.d.ts +8 -0
- package/dist/asNumber.d.ts +10 -0
- package/dist/canExpand.d.ts +11 -0
- package/dist/constants.d.ts +27 -0
- package/dist/createSchemaUtils.d.ts +9 -0
- package/dist/dataURItoBlob.d.ts +10 -0
- package/dist/deepEquals.d.ts +8 -0
- package/dist/findSchemaDefinition.d.ts +20 -0
- package/dist/getInputProps.d.ts +10 -0
- package/dist/getSchemaType.d.ts +13 -0
- package/dist/getSubmitButtonOptions.d.ts +10 -0
- package/dist/getTemplate.d.ts +10 -0
- package/dist/getUiOptions.d.ts +8 -0
- package/dist/getWidget.d.ts +13 -0
- package/dist/guessType.d.ts +7 -0
- package/dist/hasWidget.d.ts +10 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.js +8 -0
- package/dist/isConstant.d.ts +8 -0
- package/dist/isCustomWidget.d.ts +7 -0
- package/dist/isFixedItems.d.ts +8 -0
- package/dist/isObject.d.ts +7 -0
- package/dist/localToUTC.d.ts +6 -0
- package/dist/mergeDefaultsWithFormData.d.ts +15 -0
- package/dist/mergeObjects.d.ts +9 -0
- package/dist/mergeSchemas.d.ts +10 -0
- package/dist/optionsList.d.ts +10 -0
- package/dist/orderProperties.d.ts +11 -0
- package/dist/pad.d.ts +7 -0
- package/dist/parseDateString.d.ts +9 -0
- package/dist/processSelectValue.d.ts +11 -0
- package/dist/rangeSpec.d.ts +9 -0
- package/dist/schema/getDefaultFormState.d.ts +47 -0
- package/dist/schema/getDisplayLabel.d.ts +11 -0
- package/dist/schema/getMatchingOption.d.ts +10 -0
- package/dist/schema/index.d.ts +11 -0
- package/dist/schema/isFilesArray.d.ts +10 -0
- package/dist/schema/isMultiSelect.d.ts +9 -0
- package/dist/schema/isSelect.d.ts +9 -0
- package/dist/schema/mergeValidationData.d.ts +12 -0
- package/dist/schema/retrieveSchema.d.ts +98 -0
- package/dist/schema/toIdSchema.d.ts +13 -0
- package/dist/schema/toPathSchema.d.ts +11 -0
- package/dist/schemaRequiresTrueValue.d.ts +11 -0
- package/dist/shouldRender.d.ts +10 -0
- package/dist/toConstant.d.ts +9 -0
- package/dist/toDateString.d.ts +9 -0
- package/dist/types.d.ts +755 -0
- package/dist/utcToLocal.d.ts +6 -0
- package/dist/utils.cjs.development.js +2274 -0
- package/dist/utils.cjs.development.js.map +1 -0
- package/dist/utils.cjs.production.min.js +2 -0
- package/dist/utils.cjs.production.min.js.map +1 -0
- package/dist/utils.esm.js +2192 -0
- package/dist/utils.esm.js.map +1 -0
- package/dist/utils.umd.development.js +2269 -0
- package/dist/utils.umd.development.js.map +1 -0
- package/dist/utils.umd.production.min.js +2 -0
- package/dist/utils.umd.production.min.js.map +1 -0
- package/package.json +79 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,755 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { JSONSchema7, JSONSchema7Definition } from "json-schema";
|
|
3
|
+
/** The representation of any generic object type, usually used as an intersection on other types to make them more
|
|
4
|
+
* flexible in the properties they support (i.e. anything else)
|
|
5
|
+
*/
|
|
6
|
+
export declare type GenericObjectType = {
|
|
7
|
+
[name: string]: any;
|
|
8
|
+
};
|
|
9
|
+
/** Map the JSONSchema7 to our own type so that we can easily bump to JSONSchema8 at some future date and only have to
|
|
10
|
+
* update this one type.
|
|
11
|
+
*/
|
|
12
|
+
export declare type RJSFSchema = JSONSchema7;
|
|
13
|
+
/** Map the JSONSchema7Definition to our own type so that we can easily bump to JSONSchema8Definition at some future
|
|
14
|
+
* date and only have to update this one type.
|
|
15
|
+
*/
|
|
16
|
+
export declare type RJSFSchemaDefinition = JSONSchema7Definition;
|
|
17
|
+
/** The interface representing a Date object that contains an optional time */
|
|
18
|
+
export interface DateObject {
|
|
19
|
+
/** The year of the Date */
|
|
20
|
+
year: number;
|
|
21
|
+
/** The month of the Date */
|
|
22
|
+
month: number;
|
|
23
|
+
/** The day of the Date */
|
|
24
|
+
day: number;
|
|
25
|
+
/** The optional hours for the time of a Date */
|
|
26
|
+
hour?: number;
|
|
27
|
+
/** The optional minutes for the time of a Date */
|
|
28
|
+
minute?: number;
|
|
29
|
+
/** The optional seconds for the time of a Date */
|
|
30
|
+
second?: number;
|
|
31
|
+
}
|
|
32
|
+
/** Properties describing a Range specification in terms of attribute that can be added to the `HTML` `<input>` */
|
|
33
|
+
export declare type RangeSpecType = {
|
|
34
|
+
/** Specifies the interval between legal numbers in an input field */
|
|
35
|
+
step?: number;
|
|
36
|
+
/** Specifies a minimum value for an <input> element */
|
|
37
|
+
min?: number;
|
|
38
|
+
/** Specifies the maximum value for an <input> element */
|
|
39
|
+
max?: number;
|
|
40
|
+
};
|
|
41
|
+
/** Properties describing a Range specification in terms of attribute that can be added to the `HTML` `<input>` */
|
|
42
|
+
export declare type InputPropsType = Omit<RangeSpecType, "step"> & {
|
|
43
|
+
/** Specifies the type of the <input> element */
|
|
44
|
+
type: string;
|
|
45
|
+
/** Specifies the interval between legal numbers in an input field or "any" */
|
|
46
|
+
step?: number | "any";
|
|
47
|
+
/** Specifies the `autoComplete` value for an <input> element */
|
|
48
|
+
autoComplete?: HTMLInputElement["autocomplete"];
|
|
49
|
+
};
|
|
50
|
+
/** Type describing an id used for a field in the `IdSchema` */
|
|
51
|
+
export declare type FieldId = {
|
|
52
|
+
/** The id for a field */
|
|
53
|
+
$id: string;
|
|
54
|
+
};
|
|
55
|
+
/** Type describing a recursive structure of `FieldId`s for an object with a non-empty set of keys */
|
|
56
|
+
export declare type IdSchema<T = any> = FieldId & {
|
|
57
|
+
[key in keyof T]?: IdSchema<T[key]>;
|
|
58
|
+
};
|
|
59
|
+
/** Type describing a name used for a field in the `PathSchema` */
|
|
60
|
+
export declare type FieldPath = {
|
|
61
|
+
/** The name of a field */
|
|
62
|
+
$name: string;
|
|
63
|
+
};
|
|
64
|
+
/** Type describing a recursive structure of `FieldPath`s for an object with a non-empty set of keys */
|
|
65
|
+
export declare type PathSchema<T = any> = FieldPath & {
|
|
66
|
+
[key in keyof T]?: PathSchema<T[key]>;
|
|
67
|
+
};
|
|
68
|
+
/** The type for error produced by RJSF schema validation */
|
|
69
|
+
export declare type RJSFValidationError = {
|
|
70
|
+
/** Name of the error, for example, "required" or "minLength" */
|
|
71
|
+
name?: string;
|
|
72
|
+
/** Message, for example, "is a required property" or "should NOT be shorter than 3 characters" */
|
|
73
|
+
message?: string;
|
|
74
|
+
/** An object with the error params returned by ajv
|
|
75
|
+
* ([see doc](https://github.com/ajv-validator/ajv/tree/6a671057ea6aae690b5967ee26a0ddf8452c6297#error-parameters)
|
|
76
|
+
* for more info)
|
|
77
|
+
*/
|
|
78
|
+
params?: any;
|
|
79
|
+
/** A string in Javascript property accessor notation to the data path of the field with the error. For example,
|
|
80
|
+
* `.name` or `['first-name']`
|
|
81
|
+
*/
|
|
82
|
+
property?: string;
|
|
83
|
+
/** JSON pointer to the schema of the keyword that failed validation. For example, `#/fields/firstName/required`.
|
|
84
|
+
* (Note: this may sometimes be wrong due to a [bug in ajv](https://github.com/ajv-validator/ajv/issues/512))
|
|
85
|
+
*/
|
|
86
|
+
schemaPath?: string;
|
|
87
|
+
/** Full error name, for example ".name is a required property" */
|
|
88
|
+
stack: string;
|
|
89
|
+
};
|
|
90
|
+
/** The type that describes an error in a field */
|
|
91
|
+
export declare type FieldError = string;
|
|
92
|
+
/** The type that describes the list of errors for a field */
|
|
93
|
+
export declare type FieldErrors = {
|
|
94
|
+
/** The list of errors for the field */
|
|
95
|
+
__errors?: FieldError[];
|
|
96
|
+
};
|
|
97
|
+
/** Type describing a recursive structure of `FieldErrors`s for an object with a non-empty set of keys */
|
|
98
|
+
export declare type ErrorSchema<T = any> = FieldErrors & {
|
|
99
|
+
[key in keyof T]?: ErrorSchema<T[key]>;
|
|
100
|
+
};
|
|
101
|
+
/** Type that describes the list of errors for a field being actively validated by a custom validator */
|
|
102
|
+
export declare type FieldValidation = FieldErrors & {
|
|
103
|
+
/** Function that will add a new `message` to the list of errors */
|
|
104
|
+
addError: (message: string) => void;
|
|
105
|
+
};
|
|
106
|
+
/** Type describing a recursive structure of `FieldValidation`s for an object with a non-empty set of keys */
|
|
107
|
+
export declare type FormValidation<T = any> = FieldValidation & {
|
|
108
|
+
[key in keyof T]?: FormValidation<T[key]>;
|
|
109
|
+
};
|
|
110
|
+
/** The properties that are passed to an `ErrorList` implementation */
|
|
111
|
+
export declare type ErrorListProps<T = any, F = any> = {
|
|
112
|
+
/** The errorSchema constructed by `Form` */
|
|
113
|
+
errorSchema: ErrorSchema<T>;
|
|
114
|
+
/** An array of the errors */
|
|
115
|
+
errors: RJSFValidationError[];
|
|
116
|
+
/** The `formContext` object that was passed to `Form` */
|
|
117
|
+
formContext?: F;
|
|
118
|
+
/** The schema that was passed to `Form` */
|
|
119
|
+
schema: RJSFSchema;
|
|
120
|
+
/** The uiSchema that was passed to `Form` */
|
|
121
|
+
uiSchema?: UiSchema<T, F>;
|
|
122
|
+
};
|
|
123
|
+
/** The set of `Fields` stored in the `Registry` */
|
|
124
|
+
export declare type RegistryFieldsType<T = any, F = any> = {
|
|
125
|
+
/** A `Field` indexed by `name` */
|
|
126
|
+
[name: string]: Field<T, F>;
|
|
127
|
+
};
|
|
128
|
+
/** The set of `Widgets` stored in the `Registry` */
|
|
129
|
+
export declare type RegistryWidgetsType<T = any, F = any> = {
|
|
130
|
+
/** A `Widget` indexed by `name` */
|
|
131
|
+
[name: string]: Widget<T, F>;
|
|
132
|
+
};
|
|
133
|
+
/** The set of RJSF templates that can be overridden by themes or users */
|
|
134
|
+
export interface TemplatesType<T = any, F = any> {
|
|
135
|
+
/** The template to use while rendering normal or fixed array fields */
|
|
136
|
+
ArrayFieldTemplate: React.ComponentType<ArrayFieldTemplateProps<T, F>>;
|
|
137
|
+
/** The template to use while rendering the description for an array field */
|
|
138
|
+
ArrayFieldDescriptionTemplate: React.ComponentType<ArrayFieldDescriptionProps<T, F>>;
|
|
139
|
+
/** The template to use while rendering an item in an array field */
|
|
140
|
+
ArrayFieldItemTemplate: React.ComponentType<ArrayFieldTemplateItemType<T, F>>;
|
|
141
|
+
/** The template to use while rendering the title for an array field */
|
|
142
|
+
ArrayFieldTitleTemplate: React.ComponentType<ArrayFieldTitleProps<T, F>>;
|
|
143
|
+
/** The template to use while rendering the standard html input */
|
|
144
|
+
BaseInputTemplate: React.ComponentType<WidgetProps<T, F>>;
|
|
145
|
+
/** The template to use for rendering the description of a field */
|
|
146
|
+
DescriptionFieldTemplate: React.ComponentType<DescriptionFieldProps<T, F>>;
|
|
147
|
+
/** The template to use while rendering form errors */
|
|
148
|
+
ErrorListTemplate: React.ComponentType<ErrorListProps<T, F>>;
|
|
149
|
+
/** The template to use while rendering a field */
|
|
150
|
+
FieldTemplate: React.ComponentType<FieldTemplateProps<T, F>>;
|
|
151
|
+
/** The template to use while rendering an object */
|
|
152
|
+
ObjectFieldTemplate: React.ComponentType<ObjectFieldTemplateProps<T, F>>;
|
|
153
|
+
/** The template to use for rendering the title of a field */
|
|
154
|
+
TitleFieldTemplate: React.ComponentType<TitleFieldProps<T, F>>;
|
|
155
|
+
/** The template to use for rendering information about an unsupported field type in the schema */
|
|
156
|
+
UnsupportedFieldTemplate: React.ComponentType<UnsupportedFieldProps<T, F>>;
|
|
157
|
+
/** The set of templates associated with buttons in the form */
|
|
158
|
+
ButtonTemplates: {
|
|
159
|
+
/** The template to use for the main `Submit` button */
|
|
160
|
+
SubmitButton: React.ComponentType<SubmitButtonProps<T, F>>;
|
|
161
|
+
/** The template to use for the Add button used for AdditionalProperties and Array items */
|
|
162
|
+
AddButton: React.ComponentType<IconButtonProps>;
|
|
163
|
+
/** The template to use for the Move Down button used for Array items */
|
|
164
|
+
MoveDownButton: React.ComponentType<IconButtonProps>;
|
|
165
|
+
/** The template to use for the Move Up button used for Array items */
|
|
166
|
+
MoveUpButton: React.ComponentType<IconButtonProps>;
|
|
167
|
+
/** The template to use for the Remove button used for AdditionalProperties and Array items */
|
|
168
|
+
RemoveButton: React.ComponentType<IconButtonProps>;
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
/** The object containing the registered core, theme and custom fields and widgets as well as the root schema, form
|
|
172
|
+
* context, schema utils and templates.
|
|
173
|
+
*/
|
|
174
|
+
export interface Registry<T = any, F = any> {
|
|
175
|
+
/** The set of all fields used by the `Form`. Includes fields from `core`, theme-specific fields and any custom
|
|
176
|
+
* registered fields
|
|
177
|
+
*/
|
|
178
|
+
fields: RegistryFieldsType<T, F>;
|
|
179
|
+
/** The set of templates used by the `Form`. Includes templates from `core`, theme-specific fields and any custom
|
|
180
|
+
* registered templates
|
|
181
|
+
*/
|
|
182
|
+
templates: TemplatesType<T, F>;
|
|
183
|
+
/** The set of all widgets used by the `Form`. Includes widgets from `core`, theme-specific widgets and any custom
|
|
184
|
+
* registered widgets
|
|
185
|
+
*/
|
|
186
|
+
widgets: RegistryWidgetsType<T, F>;
|
|
187
|
+
/** The `formContext` object that was passed to `Form` */
|
|
188
|
+
formContext: F;
|
|
189
|
+
/** The root schema, as passed to the `Form`, which can contain referenced definitions */
|
|
190
|
+
rootSchema: RJSFSchema;
|
|
191
|
+
/** The current implementation of the `SchemaUtilsType` (from `@rjsf/utils`) in use by the `Form`. Used to call any
|
|
192
|
+
* of the validation-schema-based utility functions
|
|
193
|
+
*/
|
|
194
|
+
schemaUtils: SchemaUtilsType<T>;
|
|
195
|
+
}
|
|
196
|
+
/** The properties that are passed to a Field implementation */
|
|
197
|
+
export interface FieldProps<T = any, F = any> extends GenericObjectType, Pick<React.HTMLAttributes<HTMLElement>, Exclude<keyof React.HTMLAttributes<HTMLElement>, "onBlur" | "onFocus" | "onChange">> {
|
|
198
|
+
/** The JSON subschema object for this field */
|
|
199
|
+
schema: RJSFSchema;
|
|
200
|
+
/** The uiSchema for this field */
|
|
201
|
+
uiSchema?: UiSchema<T, F>;
|
|
202
|
+
/** The tree of unique ids for every child field */
|
|
203
|
+
idSchema: IdSchema<T>;
|
|
204
|
+
/** The data for this field */
|
|
205
|
+
formData: T;
|
|
206
|
+
/** The tree of errors for this field and its children */
|
|
207
|
+
errorSchema?: ErrorSchema<T>;
|
|
208
|
+
/** The field change event handler; called with the updated form data and an optional `ErrorSchema` */
|
|
209
|
+
onChange: (newFormData: T, es?: ErrorSchema<T>) => any;
|
|
210
|
+
/** The input blur event handler; call it with the field id and value */
|
|
211
|
+
onBlur: (id: string, value: any) => void;
|
|
212
|
+
/** The input focus event handler; call it with the field id and value */
|
|
213
|
+
onFocus: (id: string, value: any) => void;
|
|
214
|
+
/** The `formContext` object that you passed to `Form` */
|
|
215
|
+
formContext?: F;
|
|
216
|
+
/** A boolean value stating if the field should autofocus */
|
|
217
|
+
autofocus?: boolean;
|
|
218
|
+
/** A boolean value stating if the field is disabled */
|
|
219
|
+
disabled: boolean;
|
|
220
|
+
/** A boolean value stating if the field is hiding its errors */
|
|
221
|
+
hideError?: boolean;
|
|
222
|
+
/** A boolean value stating if the field is read-only */
|
|
223
|
+
readonly: boolean;
|
|
224
|
+
/** The required status of this field */
|
|
225
|
+
required?: boolean;
|
|
226
|
+
/** The unique name of the field, usually derived from the name of the property in the JSONSchema */
|
|
227
|
+
name: string;
|
|
228
|
+
/** The `registry` object */
|
|
229
|
+
registry: Registry<T, F>;
|
|
230
|
+
}
|
|
231
|
+
/** The definition of a React-based Field component */
|
|
232
|
+
export declare type Field<T = any, F = any> = React.ComponentType<FieldProps<T, F>>;
|
|
233
|
+
/** The properties that are passed to a FieldTemplate implementation */
|
|
234
|
+
export declare type FieldTemplateProps<T = any, F = any> = {
|
|
235
|
+
/** The id of the field in the hierarchy. You can use it to render a label targeting the wrapped widget */
|
|
236
|
+
id: string;
|
|
237
|
+
/** A string containing the base CSS classes, merged with any custom ones defined in your uiSchema */
|
|
238
|
+
classNames?: string;
|
|
239
|
+
/** The computed label for this field, as a string */
|
|
240
|
+
label: string;
|
|
241
|
+
/** A component instance rendering the field description, if one is defined (this will use any custom
|
|
242
|
+
* `DescriptionField` defined)
|
|
243
|
+
*/
|
|
244
|
+
description?: React.ReactElement;
|
|
245
|
+
/** A string containing any `ui:description` uiSchema directive defined */
|
|
246
|
+
rawDescription?: string;
|
|
247
|
+
/** The field or widget component instance for this field row */
|
|
248
|
+
children: React.ReactElement;
|
|
249
|
+
/** A component instance listing any encountered errors for this field */
|
|
250
|
+
errors?: React.ReactElement;
|
|
251
|
+
/** An array of strings listing all generated error messages from encountered errors for this field */
|
|
252
|
+
rawErrors?: string[];
|
|
253
|
+
/** A component instance rendering any `ui:help` uiSchema directive defined */
|
|
254
|
+
help?: React.ReactElement;
|
|
255
|
+
/** A string containing any `ui:help` uiSchema directive defined. **NOTE:** `rawHelp` will be `undefined` if passed
|
|
256
|
+
* `ui:help` is a React component instead of a string
|
|
257
|
+
*/
|
|
258
|
+
rawHelp?: string;
|
|
259
|
+
/** A boolean value stating if the field should be hidden */
|
|
260
|
+
hidden?: boolean;
|
|
261
|
+
/** A boolean value stating if the field is required */
|
|
262
|
+
required?: boolean;
|
|
263
|
+
/** A boolean value stating if the field is read-only */
|
|
264
|
+
readonly: boolean;
|
|
265
|
+
/** A boolean value stating if the field is hiding its errors */
|
|
266
|
+
hideError?: boolean;
|
|
267
|
+
/** A boolean value stating if the field is disabled */
|
|
268
|
+
disabled: boolean;
|
|
269
|
+
/** A boolean value stating if the label should be rendered or not. This is useful for nested fields in arrays where
|
|
270
|
+
* you don't want to clutter the UI
|
|
271
|
+
*/
|
|
272
|
+
displayLabel?: boolean;
|
|
273
|
+
/** The schema object for this field */
|
|
274
|
+
schema: RJSFSchema;
|
|
275
|
+
/** The uiSchema object for this field */
|
|
276
|
+
uiSchema?: UiSchema<T, F>;
|
|
277
|
+
/** The `formContext` object that was passed to `Form` */
|
|
278
|
+
formContext?: F;
|
|
279
|
+
/** The formData for this field */
|
|
280
|
+
formData: T;
|
|
281
|
+
/** The value change event handler; Can be called with a new value to change the value for this field */
|
|
282
|
+
onChange: (value: T) => void;
|
|
283
|
+
/** The key change event handler; Called when the key associated with a field is changed for an additionalProperty */
|
|
284
|
+
onKeyChange: (value: string) => () => void;
|
|
285
|
+
/** The property drop/removal event handler; Called when a field is removed in an additionalProperty context */
|
|
286
|
+
onDropPropertyClick: (value: string) => () => void;
|
|
287
|
+
/** The `registry` object */
|
|
288
|
+
registry: Registry<T, F>;
|
|
289
|
+
};
|
|
290
|
+
/** The properties that are passed to the `UnsupportedFieldTemplate` implementation */
|
|
291
|
+
export declare type UnsupportedFieldProps<T = any, F = any> = {
|
|
292
|
+
/** The schema object for this field */
|
|
293
|
+
schema: RJSFSchema;
|
|
294
|
+
/** The tree of unique ids for every child field */
|
|
295
|
+
idSchema?: IdSchema<T>;
|
|
296
|
+
/** The reason why the schema field has an unsupported type */
|
|
297
|
+
reason: string;
|
|
298
|
+
/** The `registry` object */
|
|
299
|
+
registry: Registry<T, F>;
|
|
300
|
+
};
|
|
301
|
+
/** The properties that are passed to a `TitleFieldTemplate` implementation */
|
|
302
|
+
export declare type TitleFieldProps<T = any, F = any> = {
|
|
303
|
+
/** The id of the field title in the hierarchy */
|
|
304
|
+
id: string;
|
|
305
|
+
/** The title for the field being rendered */
|
|
306
|
+
title: string;
|
|
307
|
+
/** The uiSchema object for this title field */
|
|
308
|
+
uiSchema?: UiSchema<T, F>;
|
|
309
|
+
/** A boolean value stating if the field is required */
|
|
310
|
+
required?: boolean;
|
|
311
|
+
/** The `registry` object */
|
|
312
|
+
registry: Registry<T, F>;
|
|
313
|
+
};
|
|
314
|
+
/** The properties that are passed to a `DescriptionFieldTemplate` implementation */
|
|
315
|
+
export declare type DescriptionFieldProps<T = any, F = any> = {
|
|
316
|
+
/** The id of the field description in the hierarchy */
|
|
317
|
+
id: string;
|
|
318
|
+
/** The description of the field being rendered */
|
|
319
|
+
description: string | React.ReactElement;
|
|
320
|
+
/** The `registry` object */
|
|
321
|
+
registry: Registry<T, F>;
|
|
322
|
+
};
|
|
323
|
+
/** The properties that are passed to a `ArrayFieldTitleTemplate` implementation */
|
|
324
|
+
export declare type ArrayFieldTitleProps<T = any, F = any> = Pick<TitleFieldProps<T, F>, "title" | "uiSchema" | "required" | "registry"> & {
|
|
325
|
+
/** The idSchema of the field in the hierarchy */
|
|
326
|
+
idSchema: IdSchema<T>;
|
|
327
|
+
};
|
|
328
|
+
/** The properties that are passed to a `ArrayFieldDescriptionTemplate` implementation */
|
|
329
|
+
export declare type ArrayFieldDescriptionProps<T = any, F = any> = Pick<DescriptionFieldProps<T, F>, "description" | "registry"> & {
|
|
330
|
+
/** The idSchema of the field in the hierarchy */
|
|
331
|
+
idSchema: IdSchema<T>;
|
|
332
|
+
/** The uiSchema object for this description field */
|
|
333
|
+
uiSchema?: UiSchema<T, F>;
|
|
334
|
+
};
|
|
335
|
+
/** The properties of each element in the ArrayFieldTemplateProps.items array */
|
|
336
|
+
export declare type ArrayFieldTemplateItemType<T = any, F = any> = {
|
|
337
|
+
/** The html for the item's content */
|
|
338
|
+
children: React.ReactElement;
|
|
339
|
+
/** The className string */
|
|
340
|
+
className: string;
|
|
341
|
+
/** A boolean value stating if the array item is disabled */
|
|
342
|
+
disabled: boolean;
|
|
343
|
+
/** A boolean value stating whether the array item can be moved down */
|
|
344
|
+
hasMoveDown: boolean;
|
|
345
|
+
/** A boolean value stating whether the array item can be moved up */
|
|
346
|
+
hasMoveUp: boolean;
|
|
347
|
+
/** A boolean value stating whether the array item can be removed */
|
|
348
|
+
hasRemove: boolean;
|
|
349
|
+
/** A boolean value stating whether the array item has a toolbar */
|
|
350
|
+
hasToolbar: boolean;
|
|
351
|
+
/** A number stating the index the array item occurs in `items` */
|
|
352
|
+
index: number;
|
|
353
|
+
/** Returns a function that adds a new item at `index` */
|
|
354
|
+
onAddIndexClick: (index: number) => (event?: any) => void;
|
|
355
|
+
/** Returns a function that removes the item at `index` */
|
|
356
|
+
onDropIndexClick: (index: number) => (event?: any) => void;
|
|
357
|
+
/** Returns a function that swaps the items at `index` with `newIndex` */
|
|
358
|
+
onReorderClick: (index: number, newIndex: number) => (event?: any) => void;
|
|
359
|
+
/** A boolean value stating if the array item is read-only */
|
|
360
|
+
readonly: boolean;
|
|
361
|
+
/** A stable, unique key for the array item */
|
|
362
|
+
key: string;
|
|
363
|
+
/** The `registry` object */
|
|
364
|
+
registry: Registry<T, F>;
|
|
365
|
+
};
|
|
366
|
+
/** The properties that are passed to an ArrayFieldTemplate implementation */
|
|
367
|
+
export declare type ArrayFieldTemplateProps<T = any, F = any> = {
|
|
368
|
+
/** A boolean value stating whether new elements can be added to the array */
|
|
369
|
+
canAdd?: boolean;
|
|
370
|
+
/** The className string */
|
|
371
|
+
className?: string;
|
|
372
|
+
/** A boolean value stating if the array is disabled */
|
|
373
|
+
disabled?: boolean;
|
|
374
|
+
/** An object containing the id for this object & ids for its properties */
|
|
375
|
+
idSchema: IdSchema<T>;
|
|
376
|
+
/** An array of objects representing the items in the array */
|
|
377
|
+
items: ArrayFieldTemplateItemType<T, F>[];
|
|
378
|
+
/** A function that adds a new item to the array */
|
|
379
|
+
onAddClick: (event?: any) => void;
|
|
380
|
+
/** A boolean value stating if the array is read-only */
|
|
381
|
+
readonly?: boolean;
|
|
382
|
+
/** A boolean value stating if the array is required */
|
|
383
|
+
required?: boolean;
|
|
384
|
+
/** A boolean value stating if the field is hiding its errors */
|
|
385
|
+
hideError?: boolean;
|
|
386
|
+
/** The schema object for this array */
|
|
387
|
+
schema: RJSFSchema;
|
|
388
|
+
/** The uiSchema object for this array field */
|
|
389
|
+
uiSchema?: UiSchema<T, F>;
|
|
390
|
+
/** A string value containing the title for the array */
|
|
391
|
+
title: string;
|
|
392
|
+
/** The `formContext` object that was passed to Form */
|
|
393
|
+
formContext?: F;
|
|
394
|
+
/** The formData for this array */
|
|
395
|
+
formData: T;
|
|
396
|
+
/** An array of strings listing all generated error messages from encountered errors for this widget */
|
|
397
|
+
rawErrors?: string[];
|
|
398
|
+
/** The `registry` object */
|
|
399
|
+
registry: Registry<T, F>;
|
|
400
|
+
};
|
|
401
|
+
/** The properties of each element in the ObjectFieldTemplateProps.properties array */
|
|
402
|
+
export declare type ObjectFieldTemplatePropertyType = {
|
|
403
|
+
/** The html for the property's content */
|
|
404
|
+
content: React.ReactElement;
|
|
405
|
+
/** A string representing the property name */
|
|
406
|
+
name: string;
|
|
407
|
+
/** A boolean value stating if the object property is disabled */
|
|
408
|
+
disabled: boolean;
|
|
409
|
+
/** A boolean value stating if the property is read-only */
|
|
410
|
+
readonly: boolean;
|
|
411
|
+
/** A boolean value stating if the property should be hidden */
|
|
412
|
+
hidden: boolean;
|
|
413
|
+
};
|
|
414
|
+
/** The properties that are passed to an ObjectFieldTemplate implementation */
|
|
415
|
+
export declare type ObjectFieldTemplateProps<T = any, F = any> = {
|
|
416
|
+
/** A string value containing the title for the object */
|
|
417
|
+
title: string;
|
|
418
|
+
/** A string value containing the description for the object */
|
|
419
|
+
description?: string;
|
|
420
|
+
/** A boolean value stating if the object is disabled */
|
|
421
|
+
disabled?: boolean;
|
|
422
|
+
/** An array of objects representing the properties in the object */
|
|
423
|
+
properties: ObjectFieldTemplatePropertyType[];
|
|
424
|
+
/** Returns a function that adds a new property to the object (to be used with additionalProperties) */
|
|
425
|
+
onAddClick: (schema: RJSFSchema) => () => void;
|
|
426
|
+
/** A boolean value stating if the object is read-only */
|
|
427
|
+
readonly?: boolean;
|
|
428
|
+
/** A boolean value stating if the object is required */
|
|
429
|
+
required?: boolean;
|
|
430
|
+
/** A boolean value stating if the field is hiding its errors */
|
|
431
|
+
hideError?: boolean;
|
|
432
|
+
/** The schema object for this object */
|
|
433
|
+
schema: RJSFSchema;
|
|
434
|
+
/** The uiSchema object for this object field */
|
|
435
|
+
uiSchema?: UiSchema<T, F>;
|
|
436
|
+
/** An object containing the id for this object & ids for its properties */
|
|
437
|
+
idSchema: IdSchema<T>;
|
|
438
|
+
/** The form data for the object */
|
|
439
|
+
formData: T;
|
|
440
|
+
/** The `formContext` object that was passed to Form */
|
|
441
|
+
formContext?: F;
|
|
442
|
+
/** The `registry` object */
|
|
443
|
+
registry: Registry<T, F>;
|
|
444
|
+
};
|
|
445
|
+
/** The properties that are passed to a Widget implementation */
|
|
446
|
+
export interface WidgetProps<T = any, F = any> extends GenericObjectType, Pick<React.HTMLAttributes<HTMLElement>, Exclude<keyof React.HTMLAttributes<HTMLElement>, "onBlur" | "onFocus">> {
|
|
447
|
+
/** The generated id for this widget */
|
|
448
|
+
id: string;
|
|
449
|
+
/** The JSONSchema subschema object for this widget */
|
|
450
|
+
schema: RJSFSchema;
|
|
451
|
+
/** The uiSchema for this widget */
|
|
452
|
+
uiSchema?: UiSchema<T, F>;
|
|
453
|
+
/** The current value for this widget */
|
|
454
|
+
value: any;
|
|
455
|
+
/** The required status of this widget */
|
|
456
|
+
required?: boolean;
|
|
457
|
+
/** A boolean value stating if the widget is disabled */
|
|
458
|
+
disabled?: boolean;
|
|
459
|
+
/** A boolean value stating if the widget is read-only */
|
|
460
|
+
readonly?: boolean;
|
|
461
|
+
/** A boolean value stating if the widget is hiding its errors */
|
|
462
|
+
hideError?: boolean;
|
|
463
|
+
/** A boolean value stating if the widget should autofocus */
|
|
464
|
+
autofocus?: boolean;
|
|
465
|
+
/** The placeholder for the widget, if any */
|
|
466
|
+
placeholder?: string;
|
|
467
|
+
/** A map of UI Options passed as a prop to the component, including the optional `enumOptions`
|
|
468
|
+
* which is a special case on top of `UIOptionsType` needed only by widgets
|
|
469
|
+
*/
|
|
470
|
+
options: NonNullable<UIOptionsType<T, F>> & {
|
|
471
|
+
/** The enum options list for a type that supports them */
|
|
472
|
+
enumOptions?: EnumOptionsType[];
|
|
473
|
+
};
|
|
474
|
+
/** The `formContext` object that you passed to `Form` */
|
|
475
|
+
formContext?: F;
|
|
476
|
+
/** The input blur event handler; call it with the widget id and value */
|
|
477
|
+
onBlur: (id: string, value: any) => void;
|
|
478
|
+
/** The value change event handler; call it with the new value every time it changes */
|
|
479
|
+
onChange: (value: any) => void;
|
|
480
|
+
/** The input focus event handler; call it with the widget id and value */
|
|
481
|
+
onFocus: (id: string, value: any) => void;
|
|
482
|
+
/** The computed label for this widget, as a string */
|
|
483
|
+
label: string;
|
|
484
|
+
/** A boolean value stating if the widget can accept multiple values */
|
|
485
|
+
multiple?: boolean;
|
|
486
|
+
/** An array of strings listing all generated error messages from encountered errors for this widget */
|
|
487
|
+
rawErrors?: string[];
|
|
488
|
+
/** The `registry` object */
|
|
489
|
+
registry: Registry<T, F>;
|
|
490
|
+
}
|
|
491
|
+
/** The definition of a React-based Widget component */
|
|
492
|
+
export declare type Widget<T = any, F = any> = React.ComponentType<WidgetProps<T, F>>;
|
|
493
|
+
/** The type that defines the props used by the Submit button */
|
|
494
|
+
export declare type SubmitButtonProps<T = any, F = any> = {
|
|
495
|
+
/** The uiSchema for this widget */
|
|
496
|
+
uiSchema?: UiSchema<T, F>;
|
|
497
|
+
};
|
|
498
|
+
/** The type that defines the props for an Icon button, extending from a basic HTML button attributes */
|
|
499
|
+
export declare type IconButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
500
|
+
/** An alternative specification for the type of the icon button */
|
|
501
|
+
iconType?: string;
|
|
502
|
+
/** The name representation or actual react element implementation for the icon */
|
|
503
|
+
icon?: string | React.ReactElement;
|
|
504
|
+
};
|
|
505
|
+
/** The type that defines how to change the behavior of the submit button for the form */
|
|
506
|
+
export declare type UISchemaSubmitButtonOptions = {
|
|
507
|
+
/** The text of the submit button. Set to "Submit" by default */
|
|
508
|
+
submitText?: string;
|
|
509
|
+
/** Flag, if `true`, removes the submit button completely from the form */
|
|
510
|
+
norender?: boolean;
|
|
511
|
+
/** Any other props to be passed to the submit button itself */
|
|
512
|
+
props?: GenericObjectType & {
|
|
513
|
+
/** A boolean value stating if the submit button is disabled */
|
|
514
|
+
disabled?: boolean;
|
|
515
|
+
/** The class name for the submit button */
|
|
516
|
+
className?: string;
|
|
517
|
+
};
|
|
518
|
+
};
|
|
519
|
+
/** This type represents an element used to render an enum option */
|
|
520
|
+
export declare type EnumOptionsType = {
|
|
521
|
+
/** The value for the enum option */
|
|
522
|
+
value: any;
|
|
523
|
+
/** The label for the enum options */
|
|
524
|
+
label: string;
|
|
525
|
+
/** The schema associated with the enum option when the option represents a `oneOf` or `anyOf` choice */
|
|
526
|
+
schema?: RJSFSchema;
|
|
527
|
+
};
|
|
528
|
+
/** This type remaps the keys of `Type` to prepend `ui:` onto them. As a result it does not need to be exported */
|
|
529
|
+
declare type MakeUIType<Type> = {
|
|
530
|
+
[Property in keyof Type as `ui:${string & Property}`]: Type[Property];
|
|
531
|
+
};
|
|
532
|
+
/** This type represents all the known supported options in the `ui:options` property, kept separate in order to
|
|
533
|
+
* remap the keys. It also contains all the properties, optionally, of `TemplatesType` except "ButtonTemplates"
|
|
534
|
+
*/
|
|
535
|
+
declare type UIOptionsBaseType<T = any, F = any> = Partial<Omit<TemplatesType<T, F>, "ButtonTemplates">> & {
|
|
536
|
+
/** Any classnames that the user wants to be applied to a field in the ui */
|
|
537
|
+
classNames?: string;
|
|
538
|
+
/** We know that for title, it will be a string, if it is provided */
|
|
539
|
+
title?: string;
|
|
540
|
+
/** We know that for description, it will be a string, if it is provided */
|
|
541
|
+
description?: string;
|
|
542
|
+
/** We know that for placeholder, it will be a string, if it is provided */
|
|
543
|
+
placeholder?: string;
|
|
544
|
+
/** Used to add text next to a field to guide the end user in filling it in */
|
|
545
|
+
help?: string;
|
|
546
|
+
/** Flag, if set to `true`, will mark the field as automatically focused on a text input or textarea input */
|
|
547
|
+
autofocus?: boolean;
|
|
548
|
+
/** Use to mark the field as supporting auto complete on a text input or textarea input */
|
|
549
|
+
autocomplete?: HTMLInputElement["autocomplete"];
|
|
550
|
+
/** Flag, if set to `true`, will mark all child widgets from a given field as disabled */
|
|
551
|
+
disabled?: boolean;
|
|
552
|
+
/** The default value to use when an input for a field is empty */
|
|
553
|
+
emptyValue?: any;
|
|
554
|
+
/** Will disable any of the enum options specified in the array (by value) */
|
|
555
|
+
enumDisabled?: Array<string | number | boolean>;
|
|
556
|
+
/** Flag, if set to `true`, will hide the default error display for the given field AND all of its child fields in the
|
|
557
|
+
* hierarchy
|
|
558
|
+
*/
|
|
559
|
+
hideError?: boolean;
|
|
560
|
+
/** Flag, if set to `true`, will mark all child widgets from a given field as read-only */
|
|
561
|
+
readonly?: boolean;
|
|
562
|
+
/** This property allows you to reorder the properties that are shown for a particular object */
|
|
563
|
+
order?: string[];
|
|
564
|
+
/** Flag, if set to `false`, will mark array fields as NOT being able to be added to (defaults to true) */
|
|
565
|
+
addable?: boolean;
|
|
566
|
+
/** Flag, if set to `false`, will mark array fields as NOT being able to be ordered (defaults to true) */
|
|
567
|
+
orderable?: boolean;
|
|
568
|
+
/** Flag, if set to `false`, will mark array fields as NOT being able to be removed (defaults to true) */
|
|
569
|
+
removable?: boolean;
|
|
570
|
+
/** Flag, if set to `true`, will mark a list of checkboxes as displayed all on one line instead of one per row */
|
|
571
|
+
inline?: boolean;
|
|
572
|
+
/** Used to change the input type (for example, `tel` or `email`) for an <input> */
|
|
573
|
+
inputType?: string;
|
|
574
|
+
/** Field labels are rendered by default. Labels may be omitted by setting the `label` option to `false` */
|
|
575
|
+
label?: boolean;
|
|
576
|
+
/** Provides a means to set the initial height of a textarea widget */
|
|
577
|
+
rows?: number;
|
|
578
|
+
/** If submitButtonOptions is provided it should match the `UISchemaSubmitButtonOptions` type */
|
|
579
|
+
submitButtonOptions?: UISchemaSubmitButtonOptions;
|
|
580
|
+
/** Allows RJSF to override the default widget implementation by specifying either the name of a widget that is used
|
|
581
|
+
* to look up an implementation from the `widgets` list or an actual one-off widget implementation itself
|
|
582
|
+
*/
|
|
583
|
+
widget?: Widget<T, F> | string;
|
|
584
|
+
/** When using `additionalProperties`, key collision is prevented by appending a unique integer to the duplicate key.
|
|
585
|
+
* This option allows you to change the separator between the original key name and the integer. Default is "-"
|
|
586
|
+
*/
|
|
587
|
+
duplicateKeySuffixSeparator?: string;
|
|
588
|
+
};
|
|
589
|
+
/** The type that represents the Options potentially provided by `ui:options` */
|
|
590
|
+
export declare type UIOptionsType<T = any, F = any> = UIOptionsBaseType<T, F> & {
|
|
591
|
+
/** Anything else will be one of these types */
|
|
592
|
+
[key: string]: boolean | number | string | object | any[] | null | undefined;
|
|
593
|
+
};
|
|
594
|
+
/** Type describing the well-known properties of the `UiSchema` while also supporting all user defined properties,
|
|
595
|
+
* starting with `ui:`.
|
|
596
|
+
*/
|
|
597
|
+
export declare type UiSchema<T = any, F = any> = GenericObjectType & MakeUIType<UIOptionsBaseType<T, F>> & {
|
|
598
|
+
/** Allows the form to generate a unique prefix for the `Form`'s root prefix */
|
|
599
|
+
"ui:rootFieldId"?: string;
|
|
600
|
+
/** Allows RJSF to override the default field implementation by specifying either the name of a field that is used
|
|
601
|
+
* to look up an implementation from the `fields` list or an actual one-off `Field` component implementation itself
|
|
602
|
+
*/
|
|
603
|
+
"ui:field"?: Field<T, F> | string;
|
|
604
|
+
/** An object that contains all of the potential UI options in a single object */
|
|
605
|
+
"ui:options"?: UIOptionsType<T, F>;
|
|
606
|
+
};
|
|
607
|
+
/** A `CustomValidator` function takes in a `formData` and `errors` object and returns the given `errors` object back,
|
|
608
|
+
* while potentially adding additional messages to the `errors`
|
|
609
|
+
*/
|
|
610
|
+
export declare type CustomValidator<T = any> = (formData: T, errors: FormValidation<T>) => FormValidation<T>;
|
|
611
|
+
/** An `ErrorTransformer` function will take in a list of `errors` and potentially return a transformation of those
|
|
612
|
+
* errors in what ever way it deems necessary
|
|
613
|
+
*/
|
|
614
|
+
export declare type ErrorTransformer = (errors: RJSFValidationError[]) => RJSFValidationError[];
|
|
615
|
+
/** The type that describes the data that is returned from the `ValidatorType.validateFormData()` function */
|
|
616
|
+
export declare type ValidationData<T> = {
|
|
617
|
+
/** The validation errors as a list of `RJSFValidationError` objects */
|
|
618
|
+
errors: RJSFValidationError[];
|
|
619
|
+
/** The validation errors in the form of an `ErrorSchema` */
|
|
620
|
+
errorSchema: ErrorSchema<T>;
|
|
621
|
+
};
|
|
622
|
+
/** The interface that describes the validation functions that are provided by a Validator implementation used by the
|
|
623
|
+
* schema utilities.
|
|
624
|
+
*/
|
|
625
|
+
export interface ValidatorType<T = any> {
|
|
626
|
+
/** This function processes the `formData` with an optional user contributed `customValidate` function, which receives
|
|
627
|
+
* the form data and a `errorHandler` function that will be used to add custom validation errors for each field. Also
|
|
628
|
+
* supports a `transformErrors` function that will take the raw AJV validation errors, prior to custom validation and
|
|
629
|
+
* transform them in what ever way it chooses.
|
|
630
|
+
*
|
|
631
|
+
* @param formData - The form data to validate
|
|
632
|
+
* @param schema - The schema against which to validate the form data
|
|
633
|
+
* @param [customValidate] - An optional function that is used to perform custom validation
|
|
634
|
+
* @param [transformErrors] - An optional function that is used to transform errors after AJV validation
|
|
635
|
+
*/
|
|
636
|
+
validateFormData(formData: T, schema: RJSFSchema, customValidate?: CustomValidator<T>, transformErrors?: ErrorTransformer): ValidationData<T>;
|
|
637
|
+
/** Converts an `errorSchema` into a list of `RJSFValidationErrors`
|
|
638
|
+
*
|
|
639
|
+
* @param errorSchema - The `ErrorSchema` instance to convert
|
|
640
|
+
* @param [fieldPath=[]] - The current field path, defaults to [] if not specified
|
|
641
|
+
*/
|
|
642
|
+
toErrorList(errorSchema?: ErrorSchema<T>, fieldPath?: string[]): RJSFValidationError[];
|
|
643
|
+
/** Validates data against a schema, returning true if the data is valid, or
|
|
644
|
+
* false otherwise. If the schema is invalid, then this function will return
|
|
645
|
+
* false.
|
|
646
|
+
*
|
|
647
|
+
* @param schema - The schema against which to validate the form data * @param schema
|
|
648
|
+
* @param formData- - The form data to validate
|
|
649
|
+
* @param rootSchema - The root schema used to provide $ref resolutions
|
|
650
|
+
*/
|
|
651
|
+
isValid(schema: RJSFSchema, formData: T, rootSchema: RJSFSchema): boolean;
|
|
652
|
+
}
|
|
653
|
+
/** The `SchemaUtilsType` interface provides a wrapper around the publicly exported APIs in the `@rjsf/utils/schema`
|
|
654
|
+
* directory such that one does not have to explicitly pass the `validator` or `rootSchema` to each method. Since both
|
|
655
|
+
* the `validator` and `rootSchema` generally does not change across a `Form`, this allows for providing a simplified
|
|
656
|
+
* set of APIs to the `@rjsf/core` components and the various themes as well.
|
|
657
|
+
*/
|
|
658
|
+
export interface SchemaUtilsType<T = any> {
|
|
659
|
+
/** Returns the `ValidatorType` in the `SchemaUtilsType`
|
|
660
|
+
*
|
|
661
|
+
* @returns - The `ValidatorType`
|
|
662
|
+
*/
|
|
663
|
+
getValidator(): ValidatorType<T>;
|
|
664
|
+
/** Determines whether either the `validator` and `rootSchema` differ from the ones associated with this instance of
|
|
665
|
+
* the `SchemaUtilsType`. If either `validator` or `rootSchema` are falsy, then return false to prevent the creation
|
|
666
|
+
* of a new `SchemaUtilsType` with incomplete properties.
|
|
667
|
+
*
|
|
668
|
+
* @param validator - An implementation of the `ValidatorType` interface that will be compared against the current one
|
|
669
|
+
* @param rootSchema - The root schema that will be compared against the current one
|
|
670
|
+
* @returns - True if the `SchemaUtilsType` differs from the given `validator` or `rootSchema`
|
|
671
|
+
*/
|
|
672
|
+
doesSchemaUtilsDiffer(validator: ValidatorType, rootSchema: RJSFSchema): boolean;
|
|
673
|
+
/** Returns the superset of `formData` that includes the given set updated to include any missing fields that have
|
|
674
|
+
* computed to have defaults provided in the `schema`.
|
|
675
|
+
*
|
|
676
|
+
* @param schema - The schema for which the default state is desired
|
|
677
|
+
* @param [formData] - The current formData, if any, onto which to provide any missing defaults
|
|
678
|
+
* @param [includeUndefinedValues=false] - Optional flag, if true, cause undefined values to be added as defaults
|
|
679
|
+
* @returns - The resulting `formData` with all the defaults provided
|
|
680
|
+
*/
|
|
681
|
+
getDefaultFormState(schema: RJSFSchema, formData?: T, includeUndefinedValues?: boolean): T | T[] | undefined;
|
|
682
|
+
/** Determines whether the combination of `schema` and `uiSchema` properties indicates that the label for the `schema`
|
|
683
|
+
* should be displayed in a UI.
|
|
684
|
+
*
|
|
685
|
+
* @param schema - The schema for which the display label flag is desired
|
|
686
|
+
* @param [uiSchema] - The UI schema from which to derive potentially displayable information
|
|
687
|
+
* @returns - True if the label should be displayed or false if it should not
|
|
688
|
+
*/
|
|
689
|
+
getDisplayLabel<F = any>(schema: RJSFSchema, uiSchema?: UiSchema<T, F>): boolean;
|
|
690
|
+
/** Given the `formData` and list of `options`, attempts to find the index of the option that best matches the data.
|
|
691
|
+
*
|
|
692
|
+
* @param formData - The current formData, if any, onto which to provide any missing defaults
|
|
693
|
+
* @param options - The list of options to find a matching options from
|
|
694
|
+
* @returns - The index of the matched option or 0 if none is available
|
|
695
|
+
*/
|
|
696
|
+
getMatchingOption(formData: T, options: RJSFSchema[]): number;
|
|
697
|
+
/** Checks to see if the `schema` and `uiSchema` combination represents an array of files
|
|
698
|
+
*
|
|
699
|
+
* @param schema - The schema for which check for array of files flag is desired
|
|
700
|
+
* @param [uiSchema] - The UI schema from which to check the widget
|
|
701
|
+
* @returns - True if schema/uiSchema contains an array of files, otherwise false
|
|
702
|
+
*/
|
|
703
|
+
isFilesArray<F = any>(schema: RJSFSchema, uiSchema?: UiSchema<T, F>): boolean;
|
|
704
|
+
/** Checks to see if the `schema` combination represents a multi-select
|
|
705
|
+
*
|
|
706
|
+
* @param schema - The schema for which check for a multi-select flag is desired
|
|
707
|
+
* @returns - True if schema contains a multi-select, otherwise false
|
|
708
|
+
*/
|
|
709
|
+
isMultiSelect(schema: RJSFSchema): boolean;
|
|
710
|
+
/** Checks to see if the `schema` combination represents a select
|
|
711
|
+
*
|
|
712
|
+
* @param schema - The schema for which check for a select flag is desired
|
|
713
|
+
* @returns - True if schema contains a select, otherwise false
|
|
714
|
+
*/
|
|
715
|
+
isSelect(schema: RJSFSchema): boolean;
|
|
716
|
+
/** Merges the errors in `additionalErrorSchema` into the existing `validationData` by combining the hierarchies in the
|
|
717
|
+
* two `ErrorSchema`s and then appending the error list from the `additionalErrorSchema` obtained by calling
|
|
718
|
+
* `validator.toErrorList()` onto the `errors` in the `validationData`. If no `additionalErrorSchema` is passed, then
|
|
719
|
+
* `validationData` is returned.
|
|
720
|
+
*
|
|
721
|
+
* @param validator - The validator used to convert an ErrorSchema to a list of errors
|
|
722
|
+
* @param validationData - The current `ValidationData` into which to merge the additional errors
|
|
723
|
+
* @param [additionalErrorSchema] - The additional set of errors
|
|
724
|
+
* @returns - The `validationData` with the additional errors from `additionalErrorSchema` merged into it, if provided.
|
|
725
|
+
*/
|
|
726
|
+
mergeValidationData(validationData: ValidationData<T>, additionalErrorSchema?: ErrorSchema<T>): ValidationData<T>;
|
|
727
|
+
/** Retrieves an expanded schema that has had all of its conditions, additional properties, references and
|
|
728
|
+
* dependencies resolved and merged into the `schema` given a `rawFormData` that is used to do the potentially
|
|
729
|
+
* recursive resolution.
|
|
730
|
+
*
|
|
731
|
+
* @param schema - The schema for which retrieving a schema is desired
|
|
732
|
+
* @param [rawFormData] - The current formData, if any, to assist retrieving a schema
|
|
733
|
+
* @returns - The schema having its conditions, additional properties, references and dependencies resolved
|
|
734
|
+
*/
|
|
735
|
+
retrieveSchema(schema: RJSFSchema, formData?: T): RJSFSchema;
|
|
736
|
+
/** Generates an `IdSchema` object for the `schema`, recursively
|
|
737
|
+
*
|
|
738
|
+
* @param schema - The schema for which the display label flag is desired
|
|
739
|
+
* @param [id] - The base id for the schema
|
|
740
|
+
* @param [formData] - The current formData, if any, onto which to provide any missing defaults
|
|
741
|
+
* @param [idPrefix='root'] - The prefix to use for the id
|
|
742
|
+
* @param [idSeparator='_'] - The separator to use for the path segments in the id
|
|
743
|
+
* @returns - The `IdSchema` object for the `schema`
|
|
744
|
+
*/
|
|
745
|
+
toIdSchema(schema: RJSFSchema, id?: string, formData?: T, idPrefix?: string, idSeparator?: string): IdSchema<T>;
|
|
746
|
+
/** Generates an `PathSchema` object for the `schema`, recursively
|
|
747
|
+
*
|
|
748
|
+
* @param schema - The schema for which the display label flag is desired
|
|
749
|
+
* @param [name] - The base name for the schema
|
|
750
|
+
* @param [formData] - The current formData, if any, onto which to provide any missing defaults
|
|
751
|
+
* @returns - The `PathSchema` object for the `schema`
|
|
752
|
+
*/
|
|
753
|
+
toPathSchema(schema: RJSFSchema, name?: string, formData?: T): PathSchema<T>;
|
|
754
|
+
}
|
|
755
|
+
export {};
|