@rjsf/utils 6.0.0-alpha.0 → 6.0.0-beta.10
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.js +1347 -642
- package/dist/index.js.map +4 -4
- package/dist/utils.esm.js +1324 -619
- package/dist/utils.esm.js.map +4 -4
- package/dist/utils.umd.js +1266 -590
- package/lib/ErrorSchemaBuilder.d.ts +8 -4
- package/lib/ErrorSchemaBuilder.js +10 -8
- package/lib/ErrorSchemaBuilder.js.map +1 -1
- package/lib/allowAdditionalItems.d.ts +1 -1
- package/lib/allowAdditionalItems.js +1 -1
- package/lib/allowAdditionalItems.js.map +1 -1
- package/lib/asNumber.js.map +1 -1
- package/lib/canExpand.d.ts +2 -2
- package/lib/canExpand.js +2 -2
- package/lib/canExpand.js.map +1 -1
- package/lib/constIsAjvDataReference.d.ts +9 -0
- package/lib/constIsAjvDataReference.js +15 -0
- package/lib/constIsAjvDataReference.js.map +1 -0
- package/lib/constants.d.ts +15 -3
- package/lib/constants.js +15 -3
- package/lib/constants.js.map +1 -1
- package/lib/createErrorHandler.d.ts +1 -1
- package/lib/createErrorHandler.js +2 -2
- package/lib/createErrorHandler.js.map +1 -1
- package/lib/createSchemaUtils.d.ts +3 -2
- package/lib/createSchemaUtils.js +56 -46
- package/lib/createSchemaUtils.js.map +1 -1
- package/lib/dataURItoBlob.js.map +1 -1
- package/lib/dateRangeOptions.d.ts +1 -1
- package/lib/dateRangeOptions.js +1 -1
- package/lib/dateRangeOptions.js.map +1 -1
- package/lib/deepEquals.js +1 -1
- package/lib/deepEquals.js.map +1 -1
- package/lib/englishStringTranslator.d.ts +1 -1
- package/lib/englishStringTranslator.js +1 -1
- package/lib/enumOptionsDeselectValue.d.ts +1 -1
- package/lib/enumOptionsDeselectValue.js +4 -4
- package/lib/enumOptionsDeselectValue.js.map +1 -1
- package/lib/enumOptionsIndexForValue.d.ts +1 -1
- package/lib/enumOptionsIndexForValue.js +1 -1
- package/lib/enumOptionsIndexForValue.js.map +1 -1
- package/lib/enumOptionsIsSelected.d.ts +1 -1
- package/lib/enumOptionsIsSelected.js +3 -3
- package/lib/enumOptionsIsSelected.js.map +1 -1
- package/lib/enumOptionsSelectValue.d.ts +1 -1
- package/lib/enumOptionsSelectValue.js +2 -2
- package/lib/enumOptionsSelectValue.js.map +1 -1
- package/lib/enumOptionsValueForIndex.d.ts +1 -1
- package/lib/enumOptionsValueForIndex.js.map +1 -1
- package/lib/enums.d.ts +2 -0
- package/lib/enums.js +2 -0
- package/lib/enums.js.map +1 -1
- package/lib/findSchemaDefinition.d.ts +5 -3
- package/lib/findSchemaDefinition.js +54 -11
- package/lib/findSchemaDefinition.js.map +1 -1
- package/lib/getChangedFields.d.ts +17 -0
- package/lib/getChangedFields.js +42 -0
- package/lib/getChangedFields.js.map +1 -0
- package/lib/getDateElementProps.d.ts +1 -1
- package/lib/getDateElementProps.js.map +1 -1
- package/lib/getDiscriminatorFieldFromSchema.d.ts +1 -1
- package/lib/getDiscriminatorFieldFromSchema.js +4 -3
- package/lib/getDiscriminatorFieldFromSchema.js.map +1 -1
- package/lib/getInputProps.d.ts +1 -1
- package/lib/getInputProps.js +4 -1
- package/lib/getInputProps.js.map +1 -1
- package/lib/getOptionMatchingSimpleDiscriminator.d.ts +1 -1
- package/lib/getOptionMatchingSimpleDiscriminator.js +2 -2
- package/lib/getOptionMatchingSimpleDiscriminator.js.map +1 -1
- package/lib/getSchemaType.d.ts +2 -1
- package/lib/getSchemaType.js +3 -2
- package/lib/getSchemaType.js.map +1 -1
- package/lib/getSubmitButtonOptions.d.ts +1 -1
- package/lib/getSubmitButtonOptions.js +2 -2
- package/lib/getSubmitButtonOptions.js.map +1 -1
- package/lib/getTemplate.d.ts +1 -1
- package/lib/getTemplate.js +9 -0
- package/lib/getTemplate.js.map +1 -1
- package/lib/getTestIds.d.ts +17 -0
- package/lib/getTestIds.js +34 -0
- package/lib/getTestIds.js.map +1 -0
- package/lib/getUiOptions.d.ts +1 -1
- package/lib/getUiOptions.js +2 -2
- package/lib/getUiOptions.js.map +1 -1
- package/lib/getWidget.d.ts +1 -1
- package/lib/getWidget.js +3 -3
- package/lib/getWidget.js.map +1 -1
- package/lib/guessType.d.ts +1 -1
- package/lib/guessType.js.map +1 -1
- package/lib/hasWidget.d.ts +1 -1
- package/lib/hasWidget.js +1 -1
- package/lib/hasWidget.js.map +1 -1
- package/lib/hashForSchema.d.ts +23 -1
- package/lib/hashForSchema.js +24 -6
- package/lib/hashForSchema.js.map +1 -1
- package/lib/idGenerators.d.ts +8 -1
- package/lib/idGenerators.js +11 -2
- package/lib/idGenerators.js.map +1 -1
- package/lib/index.d.ts +63 -60
- package/lib/index.js +63 -60
- package/lib/index.js.map +1 -1
- package/lib/isConstant.d.ts +1 -1
- package/lib/isConstant.js +1 -1
- package/lib/isCustomWidget.d.ts +1 -1
- package/lib/isCustomWidget.js +1 -1
- package/lib/isFixedItems.d.ts +1 -1
- package/lib/isFixedItems.js +1 -1
- package/lib/isObject.d.ts +2 -2
- package/lib/isObject.js +11 -4
- package/lib/isObject.js.map +1 -1
- package/lib/lookupFromFormContext.d.ts +11 -0
- package/lib/lookupFromFormContext.js +20 -0
- package/lib/lookupFromFormContext.js.map +1 -0
- package/lib/mergeDefaultsWithFormData.d.ts +8 -2
- package/lib/mergeDefaultsWithFormData.js +39 -10
- package/lib/mergeDefaultsWithFormData.js.map +1 -1
- package/lib/mergeObjects.d.ts +1 -1
- package/lib/mergeObjects.js +1 -1
- package/lib/mergeObjects.js.map +1 -1
- package/lib/mergeSchemas.d.ts +1 -1
- package/lib/mergeSchemas.js +4 -4
- package/lib/mergeSchemas.js.map +1 -1
- package/lib/optionsList.d.ts +9 -7
- package/lib/optionsList.js +30 -19
- package/lib/optionsList.js.map +1 -1
- package/lib/orderProperties.js.map +1 -1
- package/lib/pad.js.map +1 -1
- package/lib/parseDateString.d.ts +1 -1
- package/lib/parseDateString.js +1 -1
- package/lib/parseDateString.js.map +1 -1
- package/lib/parser/ParserValidator.d.ts +1 -1
- package/lib/parser/ParserValidator.js +6 -6
- package/lib/parser/ParserValidator.js.map +1 -1
- package/lib/parser/index.d.ts +2 -2
- package/lib/parser/index.js +1 -1
- package/lib/parser/schemaParser.d.ts +2 -2
- package/lib/parser/schemaParser.js +6 -6
- package/lib/parser/schemaParser.js.map +1 -1
- package/lib/rangeSpec.d.ts +2 -2
- package/lib/rangeSpec.js.map +1 -1
- package/lib/replaceStringParameters.js.map +1 -1
- package/lib/schema/findFieldInSchema.d.ts +19 -0
- package/lib/schema/findFieldInSchema.js +61 -0
- package/lib/schema/findFieldInSchema.js.map +1 -0
- package/lib/schema/findSelectedOptionInXxxOf.d.ts +16 -0
- package/lib/schema/findSelectedOptionInXxxOf.js +34 -0
- package/lib/schema/findSelectedOptionInXxxOf.js.map +1 -0
- package/lib/schema/getClosestMatchingOption.d.ts +5 -3
- package/lib/schema/getClosestMatchingOption.js +28 -20
- package/lib/schema/getClosestMatchingOption.js.map +1 -1
- package/lib/schema/getDefaultFormState.d.ts +60 -13
- package/lib/schema/getDefaultFormState.js +316 -167
- package/lib/schema/getDefaultFormState.js.map +1 -1
- package/lib/schema/getDisplayLabel.d.ts +3 -2
- package/lib/schema/getDisplayLabel.js +10 -9
- package/lib/schema/getDisplayLabel.js.map +1 -1
- package/lib/schema/getFirstMatchingOption.d.ts +1 -1
- package/lib/schema/getFirstMatchingOption.js +70 -2
- package/lib/schema/getFirstMatchingOption.js.map +1 -1
- package/lib/schema/getFromSchema.d.ts +14 -0
- package/lib/schema/getFromSchema.js +39 -0
- package/lib/schema/getFromSchema.js.map +1 -0
- package/lib/schema/index.d.ts +15 -14
- package/lib/schema/index.js +15 -14
- package/lib/schema/index.js.map +1 -1
- package/lib/schema/isFilesArray.d.ts +3 -2
- package/lib/schema/isFilesArray.js +5 -4
- package/lib/schema/isFilesArray.js.map +1 -1
- package/lib/schema/isMultiSelect.d.ts +3 -2
- package/lib/schema/isMultiSelect.js +4 -3
- package/lib/schema/isMultiSelect.js.map +1 -1
- package/lib/schema/isSelect.d.ts +3 -2
- package/lib/schema/isSelect.js +5 -4
- package/lib/schema/isSelect.js.map +1 -1
- package/lib/schema/retrieveSchema.d.ts +30 -12
- package/lib/schema/retrieveSchema.js +153 -70
- package/lib/schema/retrieveSchema.js.map +1 -1
- package/lib/schema/sanitizeDataForNewSchema.d.ts +3 -2
- package/lib/schema/sanitizeDataForNewSchema.js +12 -11
- package/lib/schema/sanitizeDataForNewSchema.js.map +1 -1
- package/lib/schema/toIdSchema.d.ts +3 -2
- package/lib/schema/toIdSchema.js +30 -27
- package/lib/schema/toIdSchema.js.map +1 -1
- package/lib/schema/toPathSchema.d.ts +3 -2
- package/lib/schema/toPathSchema.js +22 -20
- package/lib/schema/toPathSchema.js.map +1 -1
- package/lib/schemaRequiresTrueValue.d.ts +1 -1
- package/lib/schemaRequiresTrueValue.js.map +1 -1
- package/lib/shouldRender.js +1 -1
- package/lib/toConstant.d.ts +1 -1
- package/lib/toConstant.js +1 -1
- package/lib/toConstant.js.map +1 -1
- package/lib/toDateString.d.ts +1 -1
- package/lib/toErrorList.d.ts +1 -1
- package/lib/toErrorList.js +2 -2
- package/lib/toErrorList.js.map +1 -1
- package/lib/toErrorSchema.d.ts +1 -1
- package/lib/toErrorSchema.js +2 -2
- package/lib/toErrorSchema.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types.d.ts +172 -142
- package/lib/unwrapErrorHandler.d.ts +1 -1
- package/lib/unwrapErrorHandler.js +1 -1
- package/lib/unwrapErrorHandler.js.map +1 -1
- package/lib/utcToLocal.js +1 -1
- package/lib/utcToLocal.js.map +1 -1
- package/lib/validationDataMerge.d.ts +1 -1
- package/lib/validationDataMerge.js +3 -3
- package/lib/validationDataMerge.js.map +1 -1
- package/lib/withIdRefPrefix.d.ts +1 -1
- package/lib/withIdRefPrefix.js +2 -2
- package/lib/withIdRefPrefix.js.map +1 -1
- package/package.json +37 -26
- package/src/ErrorSchemaBuilder.ts +15 -8
- package/src/canExpand.ts +2 -2
- package/src/constIsAjvDataReference.ts +17 -0
- package/src/constants.ts +17 -3
- package/src/createSchemaUtils.ts +140 -50
- package/src/dataURItoBlob.ts +1 -1
- package/src/dateRangeOptions.ts +1 -1
- package/src/enumOptionsDeselectValue.ts +4 -5
- package/src/enumOptionsIndexForValue.ts +1 -1
- package/src/enumOptionsIsSelected.ts +4 -5
- package/src/enumOptionsSelectValue.ts +1 -1
- package/src/enumOptionsValueForIndex.ts +1 -1
- package/src/enums.ts +2 -0
- package/src/findSchemaDefinition.ts +55 -10
- package/src/getChangedFields.ts +40 -0
- package/src/getDateElementProps.ts +2 -2
- package/src/getDiscriminatorFieldFromSchema.ts +2 -1
- package/src/getInputProps.ts +6 -2
- package/src/getOptionMatchingSimpleDiscriminator.ts +2 -2
- package/src/getSchemaType.ts +3 -2
- package/src/getSubmitButtonOptions.ts +1 -1
- package/src/getTemplate.ts +12 -1
- package/src/getTestIds.ts +40 -0
- package/src/getUiOptions.ts +2 -2
- package/src/getWidget.tsx +2 -2
- package/src/hasWidget.ts +1 -1
- package/src/hashForSchema.ts +26 -6
- package/src/idGenerators.ts +10 -0
- package/src/index.ts +21 -2
- package/src/isCustomWidget.ts +1 -1
- package/src/isObject.ts +12 -5
- package/src/labelValue.ts +2 -2
- package/src/lookupFromFormContext.ts +26 -0
- package/src/mergeDefaultsWithFormData.ts +54 -9
- package/src/mergeObjects.ts +24 -21
- package/src/optionsList.ts +31 -22
- package/src/parser/ParserValidator.ts +5 -5
- package/src/parser/schemaParser.ts +6 -6
- package/src/schema/findFieldInSchema.ts +138 -0
- package/src/schema/findSelectedOptionInXxxOf.ts +53 -0
- package/src/schema/getClosestMatchingOption.ts +38 -11
- package/src/schema/getDefaultFormState.ts +461 -193
- package/src/schema/getDisplayLabel.ts +7 -4
- package/src/schema/getFirstMatchingOption.ts +79 -4
- package/src/schema/getFromSchema.ts +100 -0
- package/src/schema/index.ts +6 -4
- package/src/schema/isFilesArray.ts +18 -3
- package/src/schema/isMultiSelect.ts +10 -4
- package/src/schema/isSelect.ts +5 -3
- package/src/schema/retrieveSchema.ts +268 -78
- package/src/schema/sanitizeDataForNewSchema.ts +52 -11
- package/src/schema/toIdSchema.ts +69 -43
- package/src/schema/toPathSchema.ts +49 -16
- package/src/toErrorList.ts +2 -2
- package/src/types.ts +278 -184
- package/src/validationDataMerge.ts +1 -1
- package/src/withIdRefPrefix.ts +1 -1
- package/LICENSE.md +0 -201
- package/lib/schema/getMatchingOption.d.ts +0 -14
- package/lib/schema/getMatchingOption.js +0 -85
- package/lib/schema/getMatchingOption.js.map +0 -1
- package/lib/schema/mergeValidationData.d.ts +0 -14
- package/lib/schema/mergeValidationData.js +0 -28
- package/lib/schema/mergeValidationData.js.map +0 -1
- package/src/schema/getMatchingOption.ts +0 -103
- package/src/schema/mergeValidationData.ts +0 -38
package/src/types.ts
CHANGED
|
@@ -31,6 +31,10 @@ export type RJSFSchema = StrictRJSFSchema & GenericObjectType;
|
|
|
31
31
|
*/
|
|
32
32
|
export type FormContextType = GenericObjectType;
|
|
33
33
|
|
|
34
|
+
/** The interface for the test ID proxy objects that are returned by the `getTestId` utility function.
|
|
35
|
+
*/
|
|
36
|
+
export type TestIdShape = Record<string, string>;
|
|
37
|
+
|
|
34
38
|
/** Experimental feature that specifies the Array `minItems` default form state behavior
|
|
35
39
|
*/
|
|
36
40
|
export type Experimental_ArrayMinItems = {
|
|
@@ -53,7 +57,7 @@ export type Experimental_ArrayMinItems = {
|
|
|
53
57
|
computeSkipPopulate?: <T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
54
58
|
validator: ValidatorType<T, S, F>,
|
|
55
59
|
schema: S,
|
|
56
|
-
rootSchema?: S
|
|
60
|
+
rootSchema?: S,
|
|
57
61
|
) => boolean;
|
|
58
62
|
/** When `formData` is provided and does not contain `minItems` worth of data, this flag (`false` by default) controls
|
|
59
63
|
* whether the extra data provided by the defaults is appended onto the existing `formData` items to ensure the
|
|
@@ -66,7 +70,8 @@ export type Experimental_ArrayMinItems = {
|
|
|
66
70
|
|
|
67
71
|
/** Experimental features to specify different default form state behaviors. Currently, this affects the
|
|
68
72
|
* handling of optional array fields where `minItems` is set and handling of setting defaults based on the
|
|
69
|
-
* value of `emptyObjectFields`.
|
|
73
|
+
* value of `emptyObjectFields`. It also affects how `allOf` fields are handled and how to handle merging defaults into
|
|
74
|
+
* the formData in relation to explicit `undefined` values via `mergeDefaultsIntoFormData`.
|
|
70
75
|
*/
|
|
71
76
|
export type Experimental_DefaultFormStateBehavior = {
|
|
72
77
|
/** Optional object, that controls how the default form state for arrays with `minItems` is handled. When not provided
|
|
@@ -86,8 +91,35 @@ export type Experimental_DefaultFormStateBehavior = {
|
|
|
86
91
|
* Optional flag to compute the default form state using allOf and if/then/else schemas. Defaults to `skipDefaults'.
|
|
87
92
|
*/
|
|
88
93
|
allOf?: 'populateDefaults' | 'skipDefaults';
|
|
94
|
+
/** Optional enumerated flag controlling how the defaults are merged into the form data when dealing with undefined
|
|
95
|
+
* values, defaulting to `useFormDataIfPresent`.
|
|
96
|
+
* NOTE: If there is a default for a field and the `formData` is unspecified, the default ALWAYS merges.
|
|
97
|
+
* - `useFormDataIfPresent`: Legacy behavior - Do not merge defaults if there is a value for a field in `formData`,
|
|
98
|
+
* even if that value is explicitly set to `undefined`
|
|
99
|
+
* - `useDefaultIfFormDataUndefined`: - If the value of a field within the `formData` is `undefined`, then use the
|
|
100
|
+
* default value instead
|
|
101
|
+
*/
|
|
102
|
+
mergeDefaultsIntoFormData?: 'useFormDataIfPresent' | 'useDefaultIfFormDataUndefined';
|
|
103
|
+
/** Optional enumerated flag controlling how const values are merged into the form data as defaults when dealing with
|
|
104
|
+
* undefined values, defaulting to `always`. The defaulting behavior for this flag will always be controlled by the
|
|
105
|
+
* `emptyObjectField` flag value. For instance, if `populateRequiredDefaults` is set and the const value is not
|
|
106
|
+
* required, it will not be set.
|
|
107
|
+
* - `always`: A const value will always be merged into the form as a default. If there is are const values in a
|
|
108
|
+
* `oneOf` (for instance to create an enumeration with title different from the values), the first const value
|
|
109
|
+
* will be defaulted
|
|
110
|
+
* - `skipOneOf`: If const is in a `oneOf` it will NOT pick the first value as a default
|
|
111
|
+
* - `never`: A const value will never be used as a default
|
|
112
|
+
*
|
|
113
|
+
*/
|
|
114
|
+
constAsDefaults?: 'always' | 'skipOneOf' | 'never';
|
|
89
115
|
};
|
|
90
116
|
|
|
117
|
+
/** Optional function that allows for custom merging of `allOf` schemas
|
|
118
|
+
* @param schema - Schema with `allOf` that needs to be merged
|
|
119
|
+
* @returns The merged schema
|
|
120
|
+
*/
|
|
121
|
+
export type Experimental_CustomMergeAllOf<S extends StrictRJSFSchema = RJSFSchema> = (schema: S) => S;
|
|
122
|
+
|
|
91
123
|
/** The interface representing a Date object that contains an optional time */
|
|
92
124
|
export interface DateObject {
|
|
93
125
|
/** The year of the Date */
|
|
@@ -122,6 +154,8 @@ export type InputPropsType = Omit<RangeSpecType, 'step'> & {
|
|
|
122
154
|
step?: number | 'any';
|
|
123
155
|
/** Specifies the `autoComplete` value for an <input> element */
|
|
124
156
|
autoComplete?: HTMLInputElement['autocomplete'];
|
|
157
|
+
/** Specifies a filter for what file types the user can upload. */
|
|
158
|
+
accept?: HTMLInputElement['accept'];
|
|
125
159
|
};
|
|
126
160
|
|
|
127
161
|
/** Type describing an id used for a field in the `IdSchema` */
|
|
@@ -145,16 +179,17 @@ export type FieldPath = {
|
|
|
145
179
|
};
|
|
146
180
|
|
|
147
181
|
/** Type describing a recursive structure of `FieldPath`s for an object with a non-empty set of keys */
|
|
148
|
-
export type PathSchema<T = any> =
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
182
|
+
export type PathSchema<T = any> =
|
|
183
|
+
T extends Array<infer U>
|
|
184
|
+
? FieldPath & {
|
|
185
|
+
[i: number]: PathSchema<U>;
|
|
186
|
+
}
|
|
187
|
+
: T extends GenericObjectType
|
|
188
|
+
? FieldPath & {
|
|
189
|
+
/** The set of names for fields in the recursive object structure */
|
|
190
|
+
[key in keyof T]?: PathSchema<T[key]>;
|
|
191
|
+
}
|
|
192
|
+
: FieldPath;
|
|
158
193
|
|
|
159
194
|
/** The type for error produced by RJSF schema validation */
|
|
160
195
|
export type RJSFValidationError = {
|
|
@@ -206,54 +241,68 @@ export type FormValidation<T = any> = FieldValidation & {
|
|
|
206
241
|
[key in keyof T]?: FormValidation<T[key]>;
|
|
207
242
|
};
|
|
208
243
|
|
|
244
|
+
/** The base properties passed to various RJSF components. */
|
|
245
|
+
export type RJSFBaseProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
|
|
246
|
+
/** The schema object for the field being described */
|
|
247
|
+
schema: S;
|
|
248
|
+
/** The uiSchema object for this base component */
|
|
249
|
+
uiSchema?: UiSchema<T, S, F>;
|
|
250
|
+
/** The `registry` object */
|
|
251
|
+
registry: Registry<T, S, F>;
|
|
252
|
+
};
|
|
253
|
+
|
|
209
254
|
/** The properties that are passed to an `ErrorListTemplate` implementation */
|
|
210
|
-
export type ErrorListProps<
|
|
255
|
+
export type ErrorListProps<
|
|
256
|
+
T = any,
|
|
257
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
258
|
+
F extends FormContextType = any,
|
|
259
|
+
> = RJSFBaseProps<T, S, F> & {
|
|
211
260
|
/** The errorSchema constructed by `Form` */
|
|
212
261
|
errorSchema: ErrorSchema<T>;
|
|
213
262
|
/** An array of the errors */
|
|
214
263
|
errors: RJSFValidationError[];
|
|
215
264
|
/** The `formContext` object that was passed to `Form` */
|
|
216
265
|
formContext?: F;
|
|
217
|
-
/** The schema that was passed to `Form` */
|
|
218
|
-
schema: S;
|
|
219
|
-
/** The uiSchema that was passed to `Form` */
|
|
220
|
-
uiSchema?: UiSchema<T, S, F>;
|
|
221
|
-
/** The `registry` object */
|
|
222
|
-
registry: Registry<T, S, F>;
|
|
223
266
|
};
|
|
224
267
|
|
|
225
268
|
/** The properties that are passed to an `FieldErrorTemplate` implementation */
|
|
226
|
-
export type FieldErrorProps<
|
|
269
|
+
export type FieldErrorProps<
|
|
270
|
+
T = any,
|
|
271
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
272
|
+
F extends FormContextType = any,
|
|
273
|
+
> = RJSFBaseProps<T, S, F> & {
|
|
227
274
|
/** The errorSchema constructed by `Form` */
|
|
228
275
|
errorSchema?: ErrorSchema<T>;
|
|
229
276
|
/** An array of the errors */
|
|
230
277
|
errors?: Array<string | ReactElement>;
|
|
231
278
|
/** The tree of unique ids for every child field */
|
|
232
279
|
idSchema: IdSchema<T>;
|
|
233
|
-
/** The schema that was passed to field */
|
|
234
|
-
schema: S;
|
|
235
|
-
/** The uiSchema that was passed to field */
|
|
236
|
-
uiSchema?: UiSchema<T, S, F>;
|
|
237
|
-
/** The `registry` object */
|
|
238
|
-
registry: Registry<T, S, F>;
|
|
239
280
|
};
|
|
240
281
|
|
|
241
282
|
/** The properties that are passed to an `FieldHelpTemplate` implementation */
|
|
242
|
-
export type FieldHelpProps<
|
|
283
|
+
export type FieldHelpProps<
|
|
284
|
+
T = any,
|
|
285
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
286
|
+
F extends FormContextType = any,
|
|
287
|
+
> = RJSFBaseProps<T, S, F> & {
|
|
243
288
|
/** The help information to be rendered */
|
|
244
289
|
help?: string | ReactElement;
|
|
245
290
|
/** The tree of unique ids for every child field */
|
|
246
291
|
idSchema: IdSchema<T>;
|
|
247
|
-
/** The schema that was passed to field */
|
|
248
|
-
schema: S;
|
|
249
|
-
/** The uiSchema that was passed to field */
|
|
250
|
-
uiSchema?: UiSchema<T, S, F>;
|
|
251
292
|
/** Flag indicating whether there are errors associated with this field */
|
|
252
293
|
hasErrors?: boolean;
|
|
253
|
-
/** The `registry` object */
|
|
254
|
-
registry: Registry<T, S, F>;
|
|
255
294
|
};
|
|
256
295
|
|
|
296
|
+
/** The properties that are passed to a `GridTemplate` */
|
|
297
|
+
export interface GridTemplateProps extends GenericObjectType {
|
|
298
|
+
/** The contents of the grid template */
|
|
299
|
+
children?: ReactNode;
|
|
300
|
+
/** Optional flag indicating whether the grid element represents a column, necessary for themes which have components
|
|
301
|
+
* for Rows vs Columns. NOTE: This is falsy by default when not specified
|
|
302
|
+
*/
|
|
303
|
+
column?: boolean;
|
|
304
|
+
}
|
|
305
|
+
|
|
257
306
|
/** The set of `Fields` stored in the `Registry` */
|
|
258
307
|
export type RegistryFieldsType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
|
|
259
308
|
/** A `Field` indexed by `name` */
|
|
@@ -267,13 +316,15 @@ export type RegistryWidgetsType<T = any, S extends StrictRJSFSchema = RJSFSchema
|
|
|
267
316
|
};
|
|
268
317
|
|
|
269
318
|
/** The set of RJSF templates that can be overridden by themes or users */
|
|
270
|
-
export
|
|
319
|
+
export type TemplatesType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
|
|
271
320
|
/** The template to use while rendering normal or fixed array fields */
|
|
272
321
|
ArrayFieldTemplate: ComponentType<ArrayFieldTemplateProps<T, S, F>>;
|
|
273
322
|
/** The template to use while rendering the description for an array field */
|
|
274
323
|
ArrayFieldDescriptionTemplate: ComponentType<ArrayFieldDescriptionProps<T, S, F>>;
|
|
324
|
+
/** The template to use while rendering the buttons for an item in an array field */
|
|
325
|
+
ArrayFieldItemButtonsTemplate: ComponentType<ArrayFieldItemButtonsTemplateType<T, S, F>>;
|
|
275
326
|
/** The template to use while rendering an item in an array field */
|
|
276
|
-
ArrayFieldItemTemplate: ComponentType<
|
|
327
|
+
ArrayFieldItemTemplate: ComponentType<ArrayFieldItemTemplateType<T, S, F>>;
|
|
277
328
|
/** The template to use while rendering the title for an array field */
|
|
278
329
|
ArrayFieldTitleTemplate: ComponentType<ArrayFieldTitleProps<T, S, F>>;
|
|
279
330
|
/** The template to use while rendering the standard html input */
|
|
@@ -288,6 +339,8 @@ export interface TemplatesType<T = any, S extends StrictRJSFSchema = RJSFSchema,
|
|
|
288
339
|
FieldHelpTemplate: ComponentType<FieldHelpProps<T, S, F>>;
|
|
289
340
|
/** The template to use while rendering a field */
|
|
290
341
|
FieldTemplate: ComponentType<FieldTemplateProps<T, S, F>>;
|
|
342
|
+
/** The template to use to render a Grid element */
|
|
343
|
+
GridTemplate: ComponentType<GridTemplateProps>;
|
|
291
344
|
/** The template to use while rendering an object */
|
|
292
345
|
ObjectFieldTemplate: ComponentType<ObjectFieldTemplateProps<T, S, F>>;
|
|
293
346
|
/** The template to use for rendering the title of a field */
|
|
@@ -311,12 +364,16 @@ export interface TemplatesType<T = any, S extends StrictRJSFSchema = RJSFSchema,
|
|
|
311
364
|
/** The template to use for the Remove button used for AdditionalProperties and Array items */
|
|
312
365
|
RemoveButton: ComponentType<IconButtonProps<T, S, F>>;
|
|
313
366
|
};
|
|
314
|
-
}
|
|
367
|
+
} & {
|
|
368
|
+
/** Allow this to support any named `ComponentType` or an object of named `ComponentType`s */
|
|
369
|
+
[key: string]: ComponentType<any> | { [key: string]: ComponentType<any> } | undefined;
|
|
370
|
+
};
|
|
315
371
|
|
|
316
372
|
/** The set of UiSchema options that can be set globally and used as fallbacks at an individual template, field or
|
|
317
|
-
* widget level when no field-level value of the option is provided.
|
|
373
|
+
* widget level when no field-level value of the option is provided. Extends GenericObjectType to support allowing users
|
|
374
|
+
* to provide any value they need for their customizations.
|
|
318
375
|
*/
|
|
319
|
-
export type GlobalUISchemaOptions = {
|
|
376
|
+
export type GlobalUISchemaOptions = GenericObjectType & {
|
|
320
377
|
/** Flag, if set to `false`, new items cannot be added to array fields, unless overridden (defaults to true) */
|
|
321
378
|
addable?: boolean;
|
|
322
379
|
/** Flag, if set to `true`, array items can be copied (defaults to false) */
|
|
@@ -331,6 +388,9 @@ export type GlobalUISchemaOptions = {
|
|
|
331
388
|
* This option allows you to change the separator between the original key name and the integer. Default is "-"
|
|
332
389
|
*/
|
|
333
390
|
duplicateKeySuffixSeparator?: string;
|
|
391
|
+
/** Enables the displaying of description text that contains markdown
|
|
392
|
+
*/
|
|
393
|
+
enableMarkdownInDescription?: boolean;
|
|
334
394
|
};
|
|
335
395
|
|
|
336
396
|
/** The object containing the registered core, theme and custom fields and widgets as well as the root schema, form
|
|
@@ -366,11 +426,8 @@ export interface Registry<T = any, S extends StrictRJSFSchema = RJSFSchema, F ex
|
|
|
366
426
|
/** The properties that are passed to a Field implementation */
|
|
367
427
|
export interface FieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>
|
|
368
428
|
extends GenericObjectType,
|
|
429
|
+
RJSFBaseProps<T, S, F>,
|
|
369
430
|
Pick<HTMLAttributes<HTMLElement>, Exclude<keyof HTMLAttributes<HTMLElement>, 'onBlur' | 'onFocus' | 'onChange'>> {
|
|
370
|
-
/** The JSON subschema object for this field */
|
|
371
|
-
schema: S;
|
|
372
|
-
/** The uiSchema for this field */
|
|
373
|
-
uiSchema?: UiSchema<T, S, F>;
|
|
374
431
|
/** The tree of unique ids for every child field */
|
|
375
432
|
idSchema: IdSchema<T>;
|
|
376
433
|
/** The data for this field */
|
|
@@ -407,17 +464,22 @@ export interface FieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
407
464
|
idSeparator?: string;
|
|
408
465
|
/** An array of strings listing all generated error messages from encountered errors for this field */
|
|
409
466
|
rawErrors?: string[];
|
|
410
|
-
/** The `registry` object */
|
|
411
|
-
registry: Registry<T, S, F>;
|
|
412
467
|
}
|
|
413
468
|
|
|
414
469
|
/** The definition of a React-based Field component */
|
|
415
470
|
export type Field<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = ComponentType<
|
|
416
471
|
FieldProps<T, S, F>
|
|
417
|
-
|
|
472
|
+
> & {
|
|
473
|
+
/** The optional TEST_IDS block that some fields contain, exported for testing purposes */
|
|
474
|
+
TEST_IDS?: TestIdShape;
|
|
475
|
+
};
|
|
418
476
|
|
|
419
477
|
/** The properties that are passed to a FieldTemplate implementation */
|
|
420
|
-
export type FieldTemplateProps<
|
|
478
|
+
export type FieldTemplateProps<
|
|
479
|
+
T = any,
|
|
480
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
481
|
+
F extends FormContextType = any,
|
|
482
|
+
> = RJSFBaseProps<T, S, F> & {
|
|
421
483
|
/** The id of the field in the hierarchy. You can use it to render a label targeting the wrapped widget */
|
|
422
484
|
id: string;
|
|
423
485
|
/** A string containing the base CSS classes, merged with any custom ones defined in your uiSchema */
|
|
@@ -458,10 +520,6 @@ export type FieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema,
|
|
|
458
520
|
* you don't want to clutter the UI
|
|
459
521
|
*/
|
|
460
522
|
displayLabel?: boolean;
|
|
461
|
-
/** The schema object for this field */
|
|
462
|
-
schema: S;
|
|
463
|
-
/** The uiSchema object for this field */
|
|
464
|
-
uiSchema?: UiSchema<T, S, F>;
|
|
465
523
|
/** The `formContext` object that was passed to `Form` */
|
|
466
524
|
formContext?: F;
|
|
467
525
|
/** The formData for this field */
|
|
@@ -472,57 +530,51 @@ export type FieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema,
|
|
|
472
530
|
onKeyChange: (value: string) => () => void;
|
|
473
531
|
/** The property drop/removal event handler; Called when a field is removed in an additionalProperty context */
|
|
474
532
|
onDropPropertyClick: (value: string) => () => void;
|
|
475
|
-
/** The `registry` object */
|
|
476
|
-
registry: Registry<T, S, F>;
|
|
477
533
|
};
|
|
478
534
|
|
|
479
535
|
/** The properties that are passed to the `UnsupportedFieldTemplate` implementation */
|
|
480
|
-
export type UnsupportedFieldProps<
|
|
481
|
-
|
|
482
|
-
|
|
536
|
+
export type UnsupportedFieldProps<
|
|
537
|
+
T = any,
|
|
538
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
539
|
+
F extends FormContextType = any,
|
|
540
|
+
> = RJSFBaseProps<T, S, F> & {
|
|
483
541
|
/** The tree of unique ids for every child field */
|
|
484
542
|
idSchema?: IdSchema<T>;
|
|
485
543
|
/** The reason why the schema field has an unsupported type */
|
|
486
544
|
reason: string;
|
|
487
|
-
/** The `registry` object */
|
|
488
|
-
registry: Registry<T, S, F>;
|
|
489
545
|
};
|
|
490
546
|
|
|
491
547
|
/** The properties that are passed to a `TitleFieldTemplate` implementation */
|
|
492
|
-
export type TitleFieldProps<
|
|
548
|
+
export type TitleFieldProps<
|
|
549
|
+
T = any,
|
|
550
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
551
|
+
F extends FormContextType = any,
|
|
552
|
+
> = RJSFBaseProps<T, S, F> & {
|
|
493
553
|
/** The id of the field title in the hierarchy */
|
|
494
554
|
id: string;
|
|
495
555
|
/** The title for the field being rendered */
|
|
496
556
|
title: string;
|
|
497
|
-
/** The schema object for the field being titled */
|
|
498
|
-
schema: S;
|
|
499
|
-
/** The uiSchema object for this title field */
|
|
500
|
-
uiSchema?: UiSchema<T, S, F>;
|
|
501
557
|
/** A boolean value stating if the field is required */
|
|
502
558
|
required?: boolean;
|
|
503
|
-
/** The `registry` object */
|
|
504
|
-
registry: Registry<T, S, F>;
|
|
505
559
|
};
|
|
506
560
|
|
|
507
561
|
/** The properties that are passed to a `DescriptionFieldTemplate` implementation */
|
|
508
|
-
export type DescriptionFieldProps<
|
|
562
|
+
export type DescriptionFieldProps<
|
|
563
|
+
T = any,
|
|
564
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
565
|
+
F extends FormContextType = any,
|
|
566
|
+
> = RJSFBaseProps<T, S, F> & {
|
|
509
567
|
/** The id of the field description in the hierarchy */
|
|
510
568
|
id: string;
|
|
511
|
-
/** The schema object for the field being described */
|
|
512
|
-
schema: S;
|
|
513
|
-
/** The uiSchema object for this description field */
|
|
514
|
-
uiSchema?: UiSchema<T, S, F>;
|
|
515
569
|
/** The description of the field being rendered */
|
|
516
570
|
description: string | ReactElement;
|
|
517
|
-
/** The `registry` object */
|
|
518
|
-
registry: Registry<T, S, F>;
|
|
519
571
|
};
|
|
520
572
|
|
|
521
573
|
/** The properties that are passed to a `ArrayFieldTitleTemplate` implementation */
|
|
522
574
|
export type ArrayFieldTitleProps<
|
|
523
575
|
T = any,
|
|
524
576
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
525
|
-
F extends FormContextType = any
|
|
577
|
+
F extends FormContextType = any,
|
|
526
578
|
> = Omit<TitleFieldProps<T, S, F>, 'id' | 'title'> & {
|
|
527
579
|
/** The title for the field being rendered */
|
|
528
580
|
title?: string;
|
|
@@ -534,7 +586,7 @@ export type ArrayFieldTitleProps<
|
|
|
534
586
|
export type ArrayFieldDescriptionProps<
|
|
535
587
|
T = any,
|
|
536
588
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
537
|
-
F extends FormContextType = any
|
|
589
|
+
F extends FormContextType = any,
|
|
538
590
|
> = Omit<DescriptionFieldProps<T, S, F>, 'id' | 'description'> & {
|
|
539
591
|
/** The description of the field being rendered */
|
|
540
592
|
description?: string | ReactElement;
|
|
@@ -542,16 +594,18 @@ export type ArrayFieldDescriptionProps<
|
|
|
542
594
|
idSchema: IdSchema<T>;
|
|
543
595
|
};
|
|
544
596
|
|
|
545
|
-
/** The properties of each element in the ArrayFieldTemplateProps.items array */
|
|
546
|
-
export type
|
|
597
|
+
/** The properties of the buttons to render for each element in the ArrayFieldTemplateProps.items array */
|
|
598
|
+
export type ArrayFieldItemButtonsTemplateType<
|
|
547
599
|
T = any,
|
|
548
600
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
549
|
-
F extends FormContextType = any
|
|
550
|
-
> = {
|
|
551
|
-
/** The
|
|
552
|
-
|
|
601
|
+
F extends FormContextType = any,
|
|
602
|
+
> = RJSFBaseProps<T, S, F> & {
|
|
603
|
+
/** The idSchema of the item for which buttons are being rendered */
|
|
604
|
+
idSchema: IdSchema<T>;
|
|
553
605
|
/** The className string */
|
|
554
|
-
className
|
|
606
|
+
className?: string;
|
|
607
|
+
/** Any optional style attributes */
|
|
608
|
+
style?: ButtonHTMLAttributes<HTMLButtonElement>['style'];
|
|
555
609
|
/** A boolean value stating if the array item is disabled */
|
|
556
610
|
disabled?: boolean;
|
|
557
611
|
/** A boolean value stating whether new items can be added to the array */
|
|
@@ -564,8 +618,6 @@ export type ArrayFieldTemplateItemType<
|
|
|
564
618
|
hasMoveUp: boolean;
|
|
565
619
|
/** A boolean value stating whether the array item can be removed */
|
|
566
620
|
hasRemove: boolean;
|
|
567
|
-
/** A boolean value stating whether the array item has a toolbar */
|
|
568
|
-
hasToolbar: boolean;
|
|
569
621
|
/** A number stating the index the array item occurs in `items` */
|
|
570
622
|
index: number;
|
|
571
623
|
/** A number stating the total number `items` in the array */
|
|
@@ -580,22 +632,49 @@ export type ArrayFieldTemplateItemType<
|
|
|
580
632
|
onReorderClick: (index: number, newIndex: number) => (event?: any) => void;
|
|
581
633
|
/** A boolean value stating if the array item is read-only */
|
|
582
634
|
readonly?: boolean;
|
|
635
|
+
};
|
|
636
|
+
|
|
637
|
+
/** The properties of each element in the ArrayFieldTemplateProps.items array */
|
|
638
|
+
export type ArrayFieldItemTemplateType<
|
|
639
|
+
T = any,
|
|
640
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
641
|
+
F extends FormContextType = any,
|
|
642
|
+
> = RJSFBaseProps<T, S, F> & {
|
|
643
|
+
/** The html for the item's content */
|
|
644
|
+
children: ReactNode;
|
|
645
|
+
/** The props to pass to the `ArrayFieldItemButtonTemplate` */
|
|
646
|
+
buttonsProps: ArrayFieldItemButtonsTemplateType<T, S, F>;
|
|
647
|
+
/** The className string */
|
|
648
|
+
className: string;
|
|
649
|
+
/** A boolean value stating if the array item is disabled */
|
|
650
|
+
disabled?: boolean;
|
|
651
|
+
/** A boolean value stating whether the array item has a toolbar */
|
|
652
|
+
hasToolbar: boolean;
|
|
653
|
+
/** A number stating the index the array item occurs in `items` */
|
|
654
|
+
index: number;
|
|
655
|
+
/** A number stating the total number `items` in the array */
|
|
656
|
+
totalItems: number;
|
|
657
|
+
/** A boolean value stating if the array item is read-only */
|
|
658
|
+
readonly?: boolean;
|
|
583
659
|
/** A stable, unique key for the array item */
|
|
584
660
|
key: string;
|
|
585
|
-
/** The schema object for this array item */
|
|
586
|
-
schema: S;
|
|
587
|
-
/** The uiSchema object for this array item */
|
|
588
|
-
uiSchema?: UiSchema<T, S, F>;
|
|
589
|
-
/** The `registry` object */
|
|
590
|
-
registry: Registry<T, S, F>;
|
|
591
661
|
};
|
|
592
662
|
|
|
663
|
+
/**
|
|
664
|
+
* @deprecated - Use `ArrayFieldItemTemplateType` instead
|
|
665
|
+
*/
|
|
666
|
+
export type ArrayFieldTemplateItemType<
|
|
667
|
+
T = any,
|
|
668
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
669
|
+
F extends FormContextType = any,
|
|
670
|
+
> = ArrayFieldItemTemplateType<T, S, F>;
|
|
671
|
+
|
|
593
672
|
/** The properties that are passed to an ArrayFieldTemplate implementation */
|
|
594
673
|
export type ArrayFieldTemplateProps<
|
|
595
674
|
T = any,
|
|
596
675
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
597
|
-
F extends FormContextType = any
|
|
598
|
-
> = {
|
|
676
|
+
F extends FormContextType = any,
|
|
677
|
+
> = RJSFBaseProps<T, S, F> & {
|
|
599
678
|
/** A boolean value stating whether new elements can be added to the array */
|
|
600
679
|
canAdd?: boolean;
|
|
601
680
|
/** The className string */
|
|
@@ -605,7 +684,7 @@ export type ArrayFieldTemplateProps<
|
|
|
605
684
|
/** An object containing the id for this object & ids for its properties */
|
|
606
685
|
idSchema: IdSchema<T>;
|
|
607
686
|
/** An array of objects representing the items in the array */
|
|
608
|
-
items:
|
|
687
|
+
items: ArrayFieldItemTemplateType<T, S, F>[];
|
|
609
688
|
/** A function that adds a new item to the array */
|
|
610
689
|
onAddClick: (event?: any) => void;
|
|
611
690
|
/** A boolean value stating if the array is read-only */
|
|
@@ -614,10 +693,6 @@ export type ArrayFieldTemplateProps<
|
|
|
614
693
|
required?: boolean;
|
|
615
694
|
/** A boolean value stating if the field is hiding its errors */
|
|
616
695
|
hideError?: boolean;
|
|
617
|
-
/** The schema object for this array */
|
|
618
|
-
schema: S;
|
|
619
|
-
/** The uiSchema object for this array field */
|
|
620
|
-
uiSchema?: UiSchema<T, S, F>;
|
|
621
696
|
/** A string value containing the title for the array */
|
|
622
697
|
title: string;
|
|
623
698
|
/** The `formContext` object that was passed to Form */
|
|
@@ -628,8 +703,6 @@ export type ArrayFieldTemplateProps<
|
|
|
628
703
|
errorSchema?: ErrorSchema<T>;
|
|
629
704
|
/** An array of strings listing all generated error messages from encountered errors for this widget */
|
|
630
705
|
rawErrors?: string[];
|
|
631
|
-
/** The `registry` object */
|
|
632
|
-
registry: Registry<T, S, F>;
|
|
633
706
|
};
|
|
634
707
|
|
|
635
708
|
/** The properties of each element in the ObjectFieldTemplateProps.properties array */
|
|
@@ -650,12 +723,12 @@ export type ObjectFieldTemplatePropertyType = {
|
|
|
650
723
|
export type ObjectFieldTemplateProps<
|
|
651
724
|
T = any,
|
|
652
725
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
653
|
-
F extends FormContextType = any
|
|
654
|
-
> = {
|
|
726
|
+
F extends FormContextType = any,
|
|
727
|
+
> = RJSFBaseProps<T, S, F> & {
|
|
655
728
|
/** A string value containing the title for the object */
|
|
656
729
|
title: string;
|
|
657
730
|
/** A string value containing the description for the object */
|
|
658
|
-
description?: string;
|
|
731
|
+
description?: string | ReactElement;
|
|
659
732
|
/** A boolean value stating if the object is disabled */
|
|
660
733
|
disabled?: boolean;
|
|
661
734
|
/** An array of objects representing the properties in the object */
|
|
@@ -668,10 +741,6 @@ export type ObjectFieldTemplateProps<
|
|
|
668
741
|
required?: boolean;
|
|
669
742
|
/** A boolean value stating if the field is hiding its errors */
|
|
670
743
|
hideError?: boolean;
|
|
671
|
-
/** The schema object for this object */
|
|
672
|
-
schema: S;
|
|
673
|
-
/** The uiSchema object for this object field */
|
|
674
|
-
uiSchema?: UiSchema<T, S, F>;
|
|
675
744
|
/** An object containing the id for this object & ids for its properties */
|
|
676
745
|
idSchema: IdSchema<T>;
|
|
677
746
|
/** The optional validation errors in the form of an `ErrorSchema` */
|
|
@@ -680,37 +749,38 @@ export type ObjectFieldTemplateProps<
|
|
|
680
749
|
formData?: T;
|
|
681
750
|
/** The `formContext` object that was passed to Form */
|
|
682
751
|
formContext?: F;
|
|
683
|
-
/** The `registry` object */
|
|
684
|
-
registry: Registry<T, S, F>;
|
|
685
752
|
};
|
|
686
753
|
|
|
687
754
|
/** The properties that are passed to a WrapIfAdditionalTemplate implementation */
|
|
688
755
|
export type WrapIfAdditionalTemplateProps<
|
|
689
756
|
T = any,
|
|
690
757
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
691
|
-
F extends FormContextType = any
|
|
692
|
-
> = {
|
|
758
|
+
F extends FormContextType = any,
|
|
759
|
+
> = RJSFBaseProps<T, S, F> & {
|
|
693
760
|
/** The field or widget component instance for this field row */
|
|
694
761
|
children: ReactNode;
|
|
695
762
|
} & Pick<
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
763
|
+
FieldTemplateProps<T, S, F>,
|
|
764
|
+
| 'id'
|
|
765
|
+
| 'classNames'
|
|
766
|
+
| 'hideError'
|
|
767
|
+
| 'rawErrors'
|
|
768
|
+
| 'style'
|
|
769
|
+
| 'label'
|
|
770
|
+
| 'required'
|
|
771
|
+
| 'readonly'
|
|
772
|
+
| 'disabled'
|
|
773
|
+
| 'schema'
|
|
774
|
+
| 'uiSchema'
|
|
775
|
+
| 'onKeyChange'
|
|
776
|
+
| 'onDropPropertyClick'
|
|
777
|
+
| 'registry'
|
|
778
|
+
>;
|
|
710
779
|
|
|
711
780
|
/** The properties that are passed to a Widget implementation */
|
|
712
781
|
export interface WidgetProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>
|
|
713
782
|
extends GenericObjectType,
|
|
783
|
+
RJSFBaseProps<T, S, F>,
|
|
714
784
|
Pick<HTMLAttributes<HTMLElement>, Exclude<keyof HTMLAttributes<HTMLElement>, 'onBlur' | 'onFocus'>> {
|
|
715
785
|
/** The generated id for this widget, used to provide unique `name`s and `id`s for the HTML field elements rendered by
|
|
716
786
|
* widgets
|
|
@@ -720,10 +790,6 @@ export interface WidgetProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
720
790
|
* of custom widgets.
|
|
721
791
|
*/
|
|
722
792
|
name: string;
|
|
723
|
-
/** The JSONSchema subschema object for this widget */
|
|
724
|
-
schema: S;
|
|
725
|
-
/** The uiSchema for this widget */
|
|
726
|
-
uiSchema?: UiSchema<T, S, F>;
|
|
727
793
|
/** The current value for this widget */
|
|
728
794
|
value: any;
|
|
729
795
|
/** The required status of this widget */
|
|
@@ -763,8 +829,6 @@ export interface WidgetProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
763
829
|
multiple?: boolean;
|
|
764
830
|
/** An array of strings listing all generated error messages from encountered errors for this widget */
|
|
765
831
|
rawErrors?: string[];
|
|
766
|
-
/** The `registry` object */
|
|
767
|
-
registry: Registry<T, S, F>;
|
|
768
832
|
}
|
|
769
833
|
|
|
770
834
|
/** The definition of a React-based Widget component */
|
|
@@ -776,7 +840,7 @@ export type Widget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends F
|
|
|
776
840
|
export interface BaseInputTemplateProps<
|
|
777
841
|
T = any,
|
|
778
842
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
779
|
-
F extends FormContextType = any
|
|
843
|
+
F extends FormContextType = any,
|
|
780
844
|
> extends WidgetProps<T, S, F> {
|
|
781
845
|
/** A `BaseInputTemplate` implements a default `onChange` handler that it passes to the HTML input component to handle
|
|
782
846
|
* the `ChangeEvent`. Sometimes a widget may need to handle the `ChangeEvent` using custom logic. If that is the case,
|
|
@@ -797,17 +861,14 @@ export type SubmitButtonProps<T = any, S extends StrictRJSFSchema = RJSFSchema,
|
|
|
797
861
|
export type IconButtonProps<
|
|
798
862
|
T = any,
|
|
799
863
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
800
|
-
F extends FormContextType = any
|
|
801
|
-
> = ButtonHTMLAttributes<HTMLButtonElement> &
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
/** The `registry` object */
|
|
809
|
-
registry: Registry<T, S, F>;
|
|
810
|
-
};
|
|
864
|
+
F extends FormContextType = any,
|
|
865
|
+
> = ButtonHTMLAttributes<HTMLButtonElement> &
|
|
866
|
+
Omit<RJSFBaseProps<T, S, F>, 'schema'> & {
|
|
867
|
+
/** An alternative specification for the type of the icon button */
|
|
868
|
+
iconType?: string;
|
|
869
|
+
/** The name representation or actual react element implementation for the icon */
|
|
870
|
+
icon?: string | ReactElement;
|
|
871
|
+
};
|
|
811
872
|
|
|
812
873
|
/** The type that defines how to change the behavior of the submit button for the form */
|
|
813
874
|
export type UISchemaSubmitButtonOptions = {
|
|
@@ -843,9 +904,29 @@ type MakeUIType<Type> = {
|
|
|
843
904
|
* remap the keys. It also contains all the properties, optionally, of `TemplatesType` except "ButtonTemplates"
|
|
844
905
|
*/
|
|
845
906
|
type UIOptionsBaseType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Partial<
|
|
846
|
-
|
|
907
|
+
Pick<
|
|
908
|
+
TemplatesType<T, S, F>,
|
|
909
|
+
| 'ArrayFieldDescriptionTemplate'
|
|
910
|
+
| 'ArrayFieldItemTemplate'
|
|
911
|
+
| 'ArrayFieldTemplate'
|
|
912
|
+
| 'ArrayFieldTitleTemplate'
|
|
913
|
+
| 'BaseInputTemplate'
|
|
914
|
+
| 'DescriptionFieldTemplate'
|
|
915
|
+
| 'ErrorListTemplate'
|
|
916
|
+
| 'FieldErrorTemplate'
|
|
917
|
+
| 'FieldHelpTemplate'
|
|
918
|
+
| 'FieldTemplate'
|
|
919
|
+
| 'ObjectFieldTemplate'
|
|
920
|
+
| 'TitleFieldTemplate'
|
|
921
|
+
| 'UnsupportedFieldTemplate'
|
|
922
|
+
| 'WrapIfAdditionalTemplate'
|
|
923
|
+
>
|
|
847
924
|
> &
|
|
848
925
|
GlobalUISchemaOptions & {
|
|
926
|
+
/** Allows RJSF to override the default field implementation by specifying either the name of a field that is used
|
|
927
|
+
* to look up an implementation from the `fields` list or an actual one-off `Field` component implementation itself
|
|
928
|
+
*/
|
|
929
|
+
field?: Field<T, S, F> | string;
|
|
849
930
|
/** Any classnames that the user wants to be applied to a field in the ui */
|
|
850
931
|
classNames?: string;
|
|
851
932
|
/** Any custom style that the user wants to apply to a field in the ui, applied on the same element as classNames */
|
|
@@ -868,6 +949,12 @@ type UIOptionsBaseType<T = any, S extends StrictRJSFSchema = RJSFSchema, F exten
|
|
|
868
949
|
emptyValue?: any;
|
|
869
950
|
/** Will disable any of the enum options specified in the array (by value) */
|
|
870
951
|
enumDisabled?: Array<string | number | boolean>;
|
|
952
|
+
/** Allows a user to provide a list of labels for enum values in the schema */
|
|
953
|
+
enumNames?: string[];
|
|
954
|
+
/** Provides an optional field within a schema to be used as the oneOf/anyOf selector when there isn't a
|
|
955
|
+
* discriminator
|
|
956
|
+
*/
|
|
957
|
+
optionsSchemaSelector?: string;
|
|
871
958
|
/** Flag, if set to `true`, will hide the default error display for the given field AND all of its child fields in the
|
|
872
959
|
* hierarchy
|
|
873
960
|
*/
|
|
@@ -890,15 +977,13 @@ type UIOptionsBaseType<T = any, S extends StrictRJSFSchema = RJSFSchema, F exten
|
|
|
890
977
|
* to look up an implementation from the `widgets` list or an actual one-off widget implementation itself
|
|
891
978
|
*/
|
|
892
979
|
widget?: Widget<T, S, F> | string;
|
|
893
|
-
/** Allows a user to provide a list of labels for enum values in the schema */
|
|
894
|
-
enumNames?: string[];
|
|
895
980
|
};
|
|
896
981
|
|
|
897
982
|
/** The type that represents the Options potentially provided by `ui:options` */
|
|
898
983
|
export type UIOptionsType<
|
|
899
984
|
T = any,
|
|
900
985
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
901
|
-
F extends FormContextType = any
|
|
986
|
+
F extends FormContextType = any,
|
|
902
987
|
> = UIOptionsBaseType<T, S, F> & {
|
|
903
988
|
/** Anything else will be one of these types */
|
|
904
989
|
[key: string]: boolean | number | string | object | any[] | null | undefined;
|
|
@@ -910,7 +995,7 @@ export type UIOptionsType<
|
|
|
910
995
|
export type UiSchema<
|
|
911
996
|
T = any,
|
|
912
997
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
913
|
-
F extends FormContextType = any
|
|
998
|
+
F extends FormContextType = any,
|
|
914
999
|
> = GenericObjectType &
|
|
915
1000
|
MakeUIType<UIOptionsBaseType<T, S, F>> & {
|
|
916
1001
|
/** The set of Globally relevant UI Schema options that are read from the root-level UiSchema and stored in the
|
|
@@ -919,10 +1004,6 @@ export type UiSchema<
|
|
|
919
1004
|
'ui:globalOptions'?: GlobalUISchemaOptions;
|
|
920
1005
|
/** Allows the form to generate a unique prefix for the `Form`'s root prefix */
|
|
921
1006
|
'ui:rootFieldId'?: string;
|
|
922
|
-
/** Allows RJSF to override the default field implementation by specifying either the name of a field that is used
|
|
923
|
-
* to look up an implementation from the `fields` list or an actual one-off `Field` component implementation itself
|
|
924
|
-
*/
|
|
925
|
-
'ui:field'?: Field<T, S, F> | string;
|
|
926
1007
|
/** By default, any field that is rendered for an `anyOf`/`oneOf` schema will be wrapped inside the `AnyOfField` or
|
|
927
1008
|
* `OneOfField` component. This default behavior may be undesirable if your custom field already handles behavior
|
|
928
1009
|
* related to choosing one or more subschemas contained in the `anyOf`/`oneOf` schema.
|
|
@@ -941,7 +1022,7 @@ export type UiSchema<
|
|
|
941
1022
|
export type CustomValidator<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = (
|
|
942
1023
|
formData: T | undefined,
|
|
943
1024
|
errors: FormValidation<T>,
|
|
944
|
-
uiSchema?: UiSchema<T, S, F
|
|
1025
|
+
uiSchema?: UiSchema<T, S, F>,
|
|
945
1026
|
) => FormValidation<T>;
|
|
946
1027
|
|
|
947
1028
|
/** An `ErrorTransformer` function will take in a list of `errors` & a `uiSchema` and potentially return a
|
|
@@ -949,7 +1030,7 @@ export type CustomValidator<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
949
1030
|
*/
|
|
950
1031
|
export type ErrorTransformer<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = (
|
|
951
1032
|
errors: RJSFValidationError[],
|
|
952
|
-
uiSchema?: UiSchema<T, S, F
|
|
1033
|
+
uiSchema?: UiSchema<T, S, F>,
|
|
953
1034
|
) => RJSFValidationError[];
|
|
954
1035
|
|
|
955
1036
|
/** The type that describes the data that is returned from the `ValidatorType.validateFormData()` function */
|
|
@@ -980,16 +1061,8 @@ export interface ValidatorType<T = any, S extends StrictRJSFSchema = RJSFSchema,
|
|
|
980
1061
|
schema: S,
|
|
981
1062
|
customValidate?: CustomValidator<T, S, F>,
|
|
982
1063
|
transformErrors?: ErrorTransformer<T, S, F>,
|
|
983
|
-
uiSchema?: UiSchema<T, S, F
|
|
1064
|
+
uiSchema?: UiSchema<T, S, F>,
|
|
984
1065
|
): ValidationData<T>;
|
|
985
|
-
/** Converts an `errorSchema` into a list of `RJSFValidationErrors`
|
|
986
|
-
*
|
|
987
|
-
* @param errorSchema - The `ErrorSchema` instance to convert
|
|
988
|
-
* @param [fieldPath=[]] - The current field path, defaults to [] if not specified
|
|
989
|
-
* @deprecated - Use the `toErrorList()` function provided by `@rjsf/utils` instead. This function will be removed in
|
|
990
|
-
* the next major release.
|
|
991
|
-
*/
|
|
992
|
-
toErrorList(errorSchema?: ErrorSchema<T>, fieldPath?: string[]): RJSFValidationError[];
|
|
993
1066
|
/** Validates data against a schema, returning true if the data is valid, or
|
|
994
1067
|
* false otherwise. If the schema is invalid, then this function will return
|
|
995
1068
|
* false.
|
|
@@ -1012,6 +1085,15 @@ export interface ValidatorType<T = any, S extends StrictRJSFSchema = RJSFSchema,
|
|
|
1012
1085
|
reset?: () => void;
|
|
1013
1086
|
}
|
|
1014
1087
|
|
|
1088
|
+
/** The interface for the return value of the `findFieldInSchema` function
|
|
1089
|
+
*/
|
|
1090
|
+
export interface FoundFieldType<S extends StrictRJSFSchema = RJSFSchema> {
|
|
1091
|
+
/** The field that was found, or undefined if it wasn't */
|
|
1092
|
+
field?: S;
|
|
1093
|
+
/** The requiredness of the field found or undefined if it wasn't */
|
|
1094
|
+
isRequired?: boolean;
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1015
1097
|
/** The `SchemaUtilsType` interface provides a wrapper around the publicly exported APIs in the `@rjsf/utils/schema`
|
|
1016
1098
|
* directory such that one does not have to explicitly pass the `validator` or `rootSchema` to each method. Since both
|
|
1017
1099
|
* the `validator` and `rootSchema` generally does not change across a `Form`, this allows for providing a simplified
|
|
@@ -1030,13 +1112,37 @@ export interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchem
|
|
|
1030
1112
|
* @param validator - An implementation of the `ValidatorType` interface that will be compared against the current one
|
|
1031
1113
|
* @param rootSchema - The root schema that will be compared against the current one
|
|
1032
1114
|
* @param [experimental_defaultFormStateBehavior] - Optional configuration object, if provided, allows users to override default form state behavior
|
|
1115
|
+
* @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
|
|
1033
1116
|
* @returns - True if the `SchemaUtilsType` differs from the given `validator` or `rootSchema`
|
|
1034
1117
|
*/
|
|
1035
1118
|
doesSchemaUtilsDiffer(
|
|
1036
1119
|
validator: ValidatorType<T, S, F>,
|
|
1037
1120
|
rootSchema: S,
|
|
1038
|
-
experimental_defaultFormStateBehavior?: Experimental_DefaultFormStateBehavior
|
|
1121
|
+
experimental_defaultFormStateBehavior?: Experimental_DefaultFormStateBehavior,
|
|
1122
|
+
experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,
|
|
1039
1123
|
): boolean;
|
|
1124
|
+
/** Finds the field specified by the `path` within the root or recursed `schema`. If there is no field for the specified
|
|
1125
|
+
* `path`, then the default `{ field: undefined, isRequired: undefined }` is returned. It determines whether a leaf
|
|
1126
|
+
* field is in the `required` list for its parent and if so, it is marked as required on return.
|
|
1127
|
+
*
|
|
1128
|
+
* @param schema - The current node within the JSON schema
|
|
1129
|
+
* @param path - The remaining keys in the path to the desired field
|
|
1130
|
+
* @param [formData] - The form data that is used to determine which oneOf option
|
|
1131
|
+
* @returns - An object that contains the field and its required state. If no field can be found then
|
|
1132
|
+
* `{ field: undefined, isRequired: undefined }` is returned.
|
|
1133
|
+
*/
|
|
1134
|
+
findFieldInSchema(schema: S, path: string | string[], formData?: T): FoundFieldType<S>;
|
|
1135
|
+
/** Finds the oneOf option inside the `schema['any/oneOf']` list which has the `properties[selectorField].default` that
|
|
1136
|
+
* matches the `formData[selectorField]` value. For the purposes of this function, `selectorField` is either
|
|
1137
|
+
* `schema.discriminator.propertyName` or `fallbackField`.
|
|
1138
|
+
*
|
|
1139
|
+
* @param schema - The schema element in which to search for the selected oneOf option
|
|
1140
|
+
* @param fallbackField - The field to use as a backup selector field if the schema does not have a required field
|
|
1141
|
+
* @param xxx - Either `oneOf` or `anyOf`, defines which value is being sought
|
|
1142
|
+
* @param [formData] - The form data that is used to determine which oneOf option
|
|
1143
|
+
* @returns - The anyOf/oneOf option that matches the selector field in the schema or undefined if nothing is selected
|
|
1144
|
+
*/
|
|
1145
|
+
findSelectedOptionInXxxOf(schema: S, fallbackField: string, xxx: 'anyOf' | `oneOf`, formData?: T): S | undefined;
|
|
1040
1146
|
/** Returns the superset of `formData` that includes the given set updated to include any missing fields that have
|
|
1041
1147
|
* computed to have defaults provided in the `schema`.
|
|
1042
1148
|
*
|
|
@@ -1050,7 +1156,7 @@ export interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchem
|
|
|
1050
1156
|
getDefaultFormState(
|
|
1051
1157
|
schema: S,
|
|
1052
1158
|
formData?: T,
|
|
1053
|
-
includeUndefinedValues?: boolean | 'excludeObjectChildren'
|
|
1159
|
+
includeUndefinedValues?: boolean | 'excludeObjectChildren',
|
|
1054
1160
|
): T | T[] | undefined;
|
|
1055
1161
|
/** Determines whether the combination of `schema` and `uiSchema` properties indicates that the label for the `schema`
|
|
1056
1162
|
* should be displayed in a UI.
|
|
@@ -1078,7 +1184,7 @@ export interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchem
|
|
|
1078
1184
|
formData: T | undefined,
|
|
1079
1185
|
options: S[],
|
|
1080
1186
|
selectedOption?: number,
|
|
1081
|
-
discriminatorField?: string
|
|
1187
|
+
discriminatorField?: string,
|
|
1082
1188
|
): number;
|
|
1083
1189
|
/** Given the `formData` and list of `options`, attempts to find the index of the first option that matches the data.
|
|
1084
1190
|
* Always returns the first option if there is nothing that matches.
|
|
@@ -1090,17 +1196,17 @@ export interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchem
|
|
|
1090
1196
|
* @returns - The firstindex of the matched option or 0 if none is available
|
|
1091
1197
|
*/
|
|
1092
1198
|
getFirstMatchingOption(formData: T | undefined, options: S[], discriminatorField?: string): number;
|
|
1093
|
-
/**
|
|
1094
|
-
*
|
|
1199
|
+
/** Helper that acts like lodash's `get` but additionally retrieves `$ref`s as needed to get the path for schemas
|
|
1200
|
+
* containing potentially nested `$ref`s.
|
|
1095
1201
|
*
|
|
1096
|
-
* @param
|
|
1097
|
-
* @param
|
|
1098
|
-
* @param
|
|
1099
|
-
*
|
|
1100
|
-
* @returns - The index of the matched option or 0 if none is available
|
|
1101
|
-
* @deprecated
|
|
1202
|
+
* @param schema - The current node within the JSON schema recursion
|
|
1203
|
+
* @param path - The remaining keys in the path to the desired property
|
|
1204
|
+
* @param defaultValue - The value to return if a value is not found for the `pathList` path
|
|
1205
|
+
* @returns - The internal schema from the `schema` for the given `path` or the `defaultValue` if not found
|
|
1102
1206
|
*/
|
|
1103
|
-
|
|
1207
|
+
getFromSchema(schema: S, path: string | string[], defaultValue: T): T;
|
|
1208
|
+
getFromSchema(schema: S, path: string | string[], defaultValue: S): S;
|
|
1209
|
+
getFromSchema(schema: S, path: string | string[], defaultValue: T | S): S | T;
|
|
1104
1210
|
/** Checks to see if the `schema` and `uiSchema` combination represents an array of files
|
|
1105
1211
|
*
|
|
1106
1212
|
* @param schema - The schema for which check for array of files flag is desired
|
|
@@ -1120,18 +1226,6 @@ export interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchem
|
|
|
1120
1226
|
* @returns - True if schema contains a select, otherwise false
|
|
1121
1227
|
*/
|
|
1122
1228
|
isSelect(schema: S): boolean;
|
|
1123
|
-
/** Merges the errors in `additionalErrorSchema` into the existing `validationData` by combining the hierarchies in
|
|
1124
|
-
* the two `ErrorSchema`s and then appending the error list from the `additionalErrorSchema` obtained by calling
|
|
1125
|
-
* `validator.toErrorList()` onto the `errors` in the `validationData`. If no `additionalErrorSchema` is passed, then
|
|
1126
|
-
* `validationData` is returned.
|
|
1127
|
-
*
|
|
1128
|
-
* @param validationData - The current `ValidationData` into which to merge the additional errors
|
|
1129
|
-
* @param [additionalErrorSchema] - The additional set of errors
|
|
1130
|
-
* @returns - The `validationData` with the additional errors from `additionalErrorSchema` merged into it, if provided
|
|
1131
|
-
* @deprecated - Use the `validationDataMerge()` function exported from `@rjsf/utils` instead. This function will be
|
|
1132
|
-
* removed in the next major release.
|
|
1133
|
-
*/
|
|
1134
|
-
mergeValidationData(validationData: ValidationData<T>, additionalErrorSchema?: ErrorSchema<T>): ValidationData<T>;
|
|
1135
1229
|
/** Retrieves an expanded schema that has had all of its conditions, additional properties, references and
|
|
1136
1230
|
* dependencies resolved and merged into the `schema` given a `rawFormData` that is used to do the potentially
|
|
1137
1231
|
* recursive resolution.
|