@rjsf/utils 6.0.0-alpha.0 → 6.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/dist/index.js +1281 -625
- package/dist/index.js.map +4 -4
- package/dist/utils.esm.js +1254 -598
- package/dist/utils.esm.js.map +4 -4
- package/dist/utils.umd.js +1201 -570
- 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 +1 -1
- 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 +11 -3
- package/lib/constants.js +11 -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 +1 -1
- package/lib/findSchemaDefinition.js +2 -2
- 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 +304 -166
- 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 +28 -11
- package/lib/schema/retrieveSchema.js +142 -66
- 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 +160 -131
- 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 +36 -26
- package/src/ErrorSchemaBuilder.ts +15 -8
- package/src/canExpand.ts +2 -2
- package/src/constIsAjvDataReference.ts +17 -0
- package/src/constants.ts +12 -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 +2 -2
- 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 +447 -191
- 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 +256 -75
- 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 +266 -174
- 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 description field */
|
|
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,7 +364,10 @@ 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
373
|
* widget level when no field-level value of the option is provided.
|
|
@@ -417,7 +473,11 @@ export type Field<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends Fo
|
|
|
417
473
|
>;
|
|
418
474
|
|
|
419
475
|
/** The properties that are passed to a FieldTemplate implementation */
|
|
420
|
-
export type FieldTemplateProps<
|
|
476
|
+
export type FieldTemplateProps<
|
|
477
|
+
T = any,
|
|
478
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
479
|
+
F extends FormContextType = any,
|
|
480
|
+
> = RJSFBaseProps<T, S, F> & {
|
|
421
481
|
/** The id of the field in the hierarchy. You can use it to render a label targeting the wrapped widget */
|
|
422
482
|
id: string;
|
|
423
483
|
/** A string containing the base CSS classes, merged with any custom ones defined in your uiSchema */
|
|
@@ -458,10 +518,6 @@ export type FieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema,
|
|
|
458
518
|
* you don't want to clutter the UI
|
|
459
519
|
*/
|
|
460
520
|
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
521
|
/** The `formContext` object that was passed to `Form` */
|
|
466
522
|
formContext?: F;
|
|
467
523
|
/** The formData for this field */
|
|
@@ -472,57 +528,51 @@ export type FieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema,
|
|
|
472
528
|
onKeyChange: (value: string) => () => void;
|
|
473
529
|
/** The property drop/removal event handler; Called when a field is removed in an additionalProperty context */
|
|
474
530
|
onDropPropertyClick: (value: string) => () => void;
|
|
475
|
-
/** The `registry` object */
|
|
476
|
-
registry: Registry<T, S, F>;
|
|
477
531
|
};
|
|
478
532
|
|
|
479
533
|
/** The properties that are passed to the `UnsupportedFieldTemplate` implementation */
|
|
480
|
-
export type UnsupportedFieldProps<
|
|
481
|
-
|
|
482
|
-
|
|
534
|
+
export type UnsupportedFieldProps<
|
|
535
|
+
T = any,
|
|
536
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
537
|
+
F extends FormContextType = any,
|
|
538
|
+
> = RJSFBaseProps<T, S, F> & {
|
|
483
539
|
/** The tree of unique ids for every child field */
|
|
484
540
|
idSchema?: IdSchema<T>;
|
|
485
541
|
/** The reason why the schema field has an unsupported type */
|
|
486
542
|
reason: string;
|
|
487
|
-
/** The `registry` object */
|
|
488
|
-
registry: Registry<T, S, F>;
|
|
489
543
|
};
|
|
490
544
|
|
|
491
545
|
/** The properties that are passed to a `TitleFieldTemplate` implementation */
|
|
492
|
-
export type TitleFieldProps<
|
|
546
|
+
export type TitleFieldProps<
|
|
547
|
+
T = any,
|
|
548
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
549
|
+
F extends FormContextType = any,
|
|
550
|
+
> = RJSFBaseProps<T, S, F> & {
|
|
493
551
|
/** The id of the field title in the hierarchy */
|
|
494
552
|
id: string;
|
|
495
553
|
/** The title for the field being rendered */
|
|
496
554
|
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
555
|
/** A boolean value stating if the field is required */
|
|
502
556
|
required?: boolean;
|
|
503
|
-
/** The `registry` object */
|
|
504
|
-
registry: Registry<T, S, F>;
|
|
505
557
|
};
|
|
506
558
|
|
|
507
559
|
/** The properties that are passed to a `DescriptionFieldTemplate` implementation */
|
|
508
|
-
export type DescriptionFieldProps<
|
|
560
|
+
export type DescriptionFieldProps<
|
|
561
|
+
T = any,
|
|
562
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
563
|
+
F extends FormContextType = any,
|
|
564
|
+
> = RJSFBaseProps<T, S, F> & {
|
|
509
565
|
/** The id of the field description in the hierarchy */
|
|
510
566
|
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
567
|
/** The description of the field being rendered */
|
|
516
568
|
description: string | ReactElement;
|
|
517
|
-
/** The `registry` object */
|
|
518
|
-
registry: Registry<T, S, F>;
|
|
519
569
|
};
|
|
520
570
|
|
|
521
571
|
/** The properties that are passed to a `ArrayFieldTitleTemplate` implementation */
|
|
522
572
|
export type ArrayFieldTitleProps<
|
|
523
573
|
T = any,
|
|
524
574
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
525
|
-
F extends FormContextType = any
|
|
575
|
+
F extends FormContextType = any,
|
|
526
576
|
> = Omit<TitleFieldProps<T, S, F>, 'id' | 'title'> & {
|
|
527
577
|
/** The title for the field being rendered */
|
|
528
578
|
title?: string;
|
|
@@ -534,7 +584,7 @@ export type ArrayFieldTitleProps<
|
|
|
534
584
|
export type ArrayFieldDescriptionProps<
|
|
535
585
|
T = any,
|
|
536
586
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
537
|
-
F extends FormContextType = any
|
|
587
|
+
F extends FormContextType = any,
|
|
538
588
|
> = Omit<DescriptionFieldProps<T, S, F>, 'id' | 'description'> & {
|
|
539
589
|
/** The description of the field being rendered */
|
|
540
590
|
description?: string | ReactElement;
|
|
@@ -542,16 +592,18 @@ export type ArrayFieldDescriptionProps<
|
|
|
542
592
|
idSchema: IdSchema<T>;
|
|
543
593
|
};
|
|
544
594
|
|
|
545
|
-
/** The properties of each element in the ArrayFieldTemplateProps.items array */
|
|
546
|
-
export type
|
|
595
|
+
/** The properties of the buttons to render for each element in the ArrayFieldTemplateProps.items array */
|
|
596
|
+
export type ArrayFieldItemButtonsTemplateType<
|
|
547
597
|
T = any,
|
|
548
598
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
549
|
-
F extends FormContextType = any
|
|
550
|
-
> = {
|
|
551
|
-
/** The
|
|
552
|
-
|
|
599
|
+
F extends FormContextType = any,
|
|
600
|
+
> = RJSFBaseProps<T, S, F> & {
|
|
601
|
+
/** The idSchema of the item for which buttons are being rendered */
|
|
602
|
+
idSchema: IdSchema<T>;
|
|
553
603
|
/** The className string */
|
|
554
|
-
className
|
|
604
|
+
className?: string;
|
|
605
|
+
/** Any optional style attributes */
|
|
606
|
+
style?: ButtonHTMLAttributes<HTMLButtonElement>['style'];
|
|
555
607
|
/** A boolean value stating if the array item is disabled */
|
|
556
608
|
disabled?: boolean;
|
|
557
609
|
/** A boolean value stating whether new items can be added to the array */
|
|
@@ -564,8 +616,6 @@ export type ArrayFieldTemplateItemType<
|
|
|
564
616
|
hasMoveUp: boolean;
|
|
565
617
|
/** A boolean value stating whether the array item can be removed */
|
|
566
618
|
hasRemove: boolean;
|
|
567
|
-
/** A boolean value stating whether the array item has a toolbar */
|
|
568
|
-
hasToolbar: boolean;
|
|
569
619
|
/** A number stating the index the array item occurs in `items` */
|
|
570
620
|
index: number;
|
|
571
621
|
/** A number stating the total number `items` in the array */
|
|
@@ -580,22 +630,49 @@ export type ArrayFieldTemplateItemType<
|
|
|
580
630
|
onReorderClick: (index: number, newIndex: number) => (event?: any) => void;
|
|
581
631
|
/** A boolean value stating if the array item is read-only */
|
|
582
632
|
readonly?: boolean;
|
|
633
|
+
};
|
|
634
|
+
|
|
635
|
+
/** The properties of each element in the ArrayFieldTemplateProps.items array */
|
|
636
|
+
export type ArrayFieldItemTemplateType<
|
|
637
|
+
T = any,
|
|
638
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
639
|
+
F extends FormContextType = any,
|
|
640
|
+
> = RJSFBaseProps<T, S, F> & {
|
|
641
|
+
/** The html for the item's content */
|
|
642
|
+
children: ReactNode;
|
|
643
|
+
/** The props to pass to the `ArrayFieldItemButtonTemplate` */
|
|
644
|
+
buttonsProps: ArrayFieldItemButtonsTemplateType<T, S, F>;
|
|
645
|
+
/** The className string */
|
|
646
|
+
className: string;
|
|
647
|
+
/** A boolean value stating if the array item is disabled */
|
|
648
|
+
disabled?: boolean;
|
|
649
|
+
/** A boolean value stating whether the array item has a toolbar */
|
|
650
|
+
hasToolbar: boolean;
|
|
651
|
+
/** A number stating the index the array item occurs in `items` */
|
|
652
|
+
index: number;
|
|
653
|
+
/** A number stating the total number `items` in the array */
|
|
654
|
+
totalItems: number;
|
|
655
|
+
/** A boolean value stating if the array item is read-only */
|
|
656
|
+
readonly?: boolean;
|
|
583
657
|
/** A stable, unique key for the array item */
|
|
584
658
|
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
659
|
};
|
|
592
660
|
|
|
661
|
+
/**
|
|
662
|
+
* @deprecated - Use `ArrayFieldItemTemplateType` instead
|
|
663
|
+
*/
|
|
664
|
+
export type ArrayFieldTemplateItemType<
|
|
665
|
+
T = any,
|
|
666
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
667
|
+
F extends FormContextType = any,
|
|
668
|
+
> = ArrayFieldItemTemplateType<T, S, F>;
|
|
669
|
+
|
|
593
670
|
/** The properties that are passed to an ArrayFieldTemplate implementation */
|
|
594
671
|
export type ArrayFieldTemplateProps<
|
|
595
672
|
T = any,
|
|
596
673
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
597
|
-
F extends FormContextType = any
|
|
598
|
-
> = {
|
|
674
|
+
F extends FormContextType = any,
|
|
675
|
+
> = RJSFBaseProps<T, S, F> & {
|
|
599
676
|
/** A boolean value stating whether new elements can be added to the array */
|
|
600
677
|
canAdd?: boolean;
|
|
601
678
|
/** The className string */
|
|
@@ -605,7 +682,7 @@ export type ArrayFieldTemplateProps<
|
|
|
605
682
|
/** An object containing the id for this object & ids for its properties */
|
|
606
683
|
idSchema: IdSchema<T>;
|
|
607
684
|
/** An array of objects representing the items in the array */
|
|
608
|
-
items:
|
|
685
|
+
items: ArrayFieldItemTemplateType<T, S, F>[];
|
|
609
686
|
/** A function that adds a new item to the array */
|
|
610
687
|
onAddClick: (event?: any) => void;
|
|
611
688
|
/** A boolean value stating if the array is read-only */
|
|
@@ -614,10 +691,6 @@ export type ArrayFieldTemplateProps<
|
|
|
614
691
|
required?: boolean;
|
|
615
692
|
/** A boolean value stating if the field is hiding its errors */
|
|
616
693
|
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
694
|
/** A string value containing the title for the array */
|
|
622
695
|
title: string;
|
|
623
696
|
/** The `formContext` object that was passed to Form */
|
|
@@ -628,8 +701,6 @@ export type ArrayFieldTemplateProps<
|
|
|
628
701
|
errorSchema?: ErrorSchema<T>;
|
|
629
702
|
/** An array of strings listing all generated error messages from encountered errors for this widget */
|
|
630
703
|
rawErrors?: string[];
|
|
631
|
-
/** The `registry` object */
|
|
632
|
-
registry: Registry<T, S, F>;
|
|
633
704
|
};
|
|
634
705
|
|
|
635
706
|
/** The properties of each element in the ObjectFieldTemplateProps.properties array */
|
|
@@ -650,8 +721,8 @@ export type ObjectFieldTemplatePropertyType = {
|
|
|
650
721
|
export type ObjectFieldTemplateProps<
|
|
651
722
|
T = any,
|
|
652
723
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
653
|
-
F extends FormContextType = any
|
|
654
|
-
> = {
|
|
724
|
+
F extends FormContextType = any,
|
|
725
|
+
> = RJSFBaseProps<T, S, F> & {
|
|
655
726
|
/** A string value containing the title for the object */
|
|
656
727
|
title: string;
|
|
657
728
|
/** A string value containing the description for the object */
|
|
@@ -668,10 +739,6 @@ export type ObjectFieldTemplateProps<
|
|
|
668
739
|
required?: boolean;
|
|
669
740
|
/** A boolean value stating if the field is hiding its errors */
|
|
670
741
|
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
742
|
/** An object containing the id for this object & ids for its properties */
|
|
676
743
|
idSchema: IdSchema<T>;
|
|
677
744
|
/** The optional validation errors in the form of an `ErrorSchema` */
|
|
@@ -680,37 +747,38 @@ export type ObjectFieldTemplateProps<
|
|
|
680
747
|
formData?: T;
|
|
681
748
|
/** The `formContext` object that was passed to Form */
|
|
682
749
|
formContext?: F;
|
|
683
|
-
/** The `registry` object */
|
|
684
|
-
registry: Registry<T, S, F>;
|
|
685
750
|
};
|
|
686
751
|
|
|
687
752
|
/** The properties that are passed to a WrapIfAdditionalTemplate implementation */
|
|
688
753
|
export type WrapIfAdditionalTemplateProps<
|
|
689
754
|
T = any,
|
|
690
755
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
691
|
-
F extends FormContextType = any
|
|
692
|
-
> = {
|
|
756
|
+
F extends FormContextType = any,
|
|
757
|
+
> = RJSFBaseProps<T, S, F> & {
|
|
693
758
|
/** The field or widget component instance for this field row */
|
|
694
759
|
children: ReactNode;
|
|
695
760
|
} & Pick<
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
761
|
+
FieldTemplateProps<T, S, F>,
|
|
762
|
+
| 'id'
|
|
763
|
+
| 'classNames'
|
|
764
|
+
| 'hideError'
|
|
765
|
+
| 'rawErrors'
|
|
766
|
+
| 'style'
|
|
767
|
+
| 'label'
|
|
768
|
+
| 'required'
|
|
769
|
+
| 'readonly'
|
|
770
|
+
| 'disabled'
|
|
771
|
+
| 'schema'
|
|
772
|
+
| 'uiSchema'
|
|
773
|
+
| 'onKeyChange'
|
|
774
|
+
| 'onDropPropertyClick'
|
|
775
|
+
| 'registry'
|
|
776
|
+
>;
|
|
710
777
|
|
|
711
778
|
/** The properties that are passed to a Widget implementation */
|
|
712
779
|
export interface WidgetProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>
|
|
713
780
|
extends GenericObjectType,
|
|
781
|
+
RJSFBaseProps<T, S, F>,
|
|
714
782
|
Pick<HTMLAttributes<HTMLElement>, Exclude<keyof HTMLAttributes<HTMLElement>, 'onBlur' | 'onFocus'>> {
|
|
715
783
|
/** The generated id for this widget, used to provide unique `name`s and `id`s for the HTML field elements rendered by
|
|
716
784
|
* widgets
|
|
@@ -720,10 +788,6 @@ export interface WidgetProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
720
788
|
* of custom widgets.
|
|
721
789
|
*/
|
|
722
790
|
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
791
|
/** The current value for this widget */
|
|
728
792
|
value: any;
|
|
729
793
|
/** The required status of this widget */
|
|
@@ -763,8 +827,6 @@ export interface WidgetProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
763
827
|
multiple?: boolean;
|
|
764
828
|
/** An array of strings listing all generated error messages from encountered errors for this widget */
|
|
765
829
|
rawErrors?: string[];
|
|
766
|
-
/** The `registry` object */
|
|
767
|
-
registry: Registry<T, S, F>;
|
|
768
830
|
}
|
|
769
831
|
|
|
770
832
|
/** The definition of a React-based Widget component */
|
|
@@ -776,7 +838,7 @@ export type Widget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends F
|
|
|
776
838
|
export interface BaseInputTemplateProps<
|
|
777
839
|
T = any,
|
|
778
840
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
779
|
-
F extends FormContextType = any
|
|
841
|
+
F extends FormContextType = any,
|
|
780
842
|
> extends WidgetProps<T, S, F> {
|
|
781
843
|
/** A `BaseInputTemplate` implements a default `onChange` handler that it passes to the HTML input component to handle
|
|
782
844
|
* the `ChangeEvent`. Sometimes a widget may need to handle the `ChangeEvent` using custom logic. If that is the case,
|
|
@@ -797,17 +859,14 @@ export type SubmitButtonProps<T = any, S extends StrictRJSFSchema = RJSFSchema,
|
|
|
797
859
|
export type IconButtonProps<
|
|
798
860
|
T = any,
|
|
799
861
|
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
|
-
};
|
|
862
|
+
F extends FormContextType = any,
|
|
863
|
+
> = ButtonHTMLAttributes<HTMLButtonElement> &
|
|
864
|
+
Omit<RJSFBaseProps<T, S, F>, 'schema'> & {
|
|
865
|
+
/** An alternative specification for the type of the icon button */
|
|
866
|
+
iconType?: string;
|
|
867
|
+
/** The name representation or actual react element implementation for the icon */
|
|
868
|
+
icon?: string | ReactElement;
|
|
869
|
+
};
|
|
811
870
|
|
|
812
871
|
/** The type that defines how to change the behavior of the submit button for the form */
|
|
813
872
|
export type UISchemaSubmitButtonOptions = {
|
|
@@ -843,9 +902,29 @@ type MakeUIType<Type> = {
|
|
|
843
902
|
* remap the keys. It also contains all the properties, optionally, of `TemplatesType` except "ButtonTemplates"
|
|
844
903
|
*/
|
|
845
904
|
type UIOptionsBaseType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Partial<
|
|
846
|
-
|
|
905
|
+
Pick<
|
|
906
|
+
TemplatesType<T, S, F>,
|
|
907
|
+
| 'ArrayFieldDescriptionTemplate'
|
|
908
|
+
| 'ArrayFieldItemTemplate'
|
|
909
|
+
| 'ArrayFieldTemplate'
|
|
910
|
+
| 'ArrayFieldTitleTemplate'
|
|
911
|
+
| 'BaseInputTemplate'
|
|
912
|
+
| 'DescriptionFieldTemplate'
|
|
913
|
+
| 'ErrorListTemplate'
|
|
914
|
+
| 'FieldErrorTemplate'
|
|
915
|
+
| 'FieldHelpTemplate'
|
|
916
|
+
| 'FieldTemplate'
|
|
917
|
+
| 'ObjectFieldTemplate'
|
|
918
|
+
| 'TitleFieldTemplate'
|
|
919
|
+
| 'UnsupportedFieldTemplate'
|
|
920
|
+
| 'WrapIfAdditionalTemplate'
|
|
921
|
+
>
|
|
847
922
|
> &
|
|
848
923
|
GlobalUISchemaOptions & {
|
|
924
|
+
/** Allows RJSF to override the default field implementation by specifying either the name of a field that is used
|
|
925
|
+
* to look up an implementation from the `fields` list or an actual one-off `Field` component implementation itself
|
|
926
|
+
*/
|
|
927
|
+
field?: Field<T, S, F> | string;
|
|
849
928
|
/** Any classnames that the user wants to be applied to a field in the ui */
|
|
850
929
|
classNames?: string;
|
|
851
930
|
/** Any custom style that the user wants to apply to a field in the ui, applied on the same element as classNames */
|
|
@@ -868,6 +947,12 @@ type UIOptionsBaseType<T = any, S extends StrictRJSFSchema = RJSFSchema, F exten
|
|
|
868
947
|
emptyValue?: any;
|
|
869
948
|
/** Will disable any of the enum options specified in the array (by value) */
|
|
870
949
|
enumDisabled?: Array<string | number | boolean>;
|
|
950
|
+
/** Allows a user to provide a list of labels for enum values in the schema */
|
|
951
|
+
enumNames?: string[];
|
|
952
|
+
/** Provides an optional field within a schema to be used as the oneOf/anyOf selector when there isn't a
|
|
953
|
+
* discriminator
|
|
954
|
+
*/
|
|
955
|
+
optionsSchemaSelector?: string;
|
|
871
956
|
/** Flag, if set to `true`, will hide the default error display for the given field AND all of its child fields in the
|
|
872
957
|
* hierarchy
|
|
873
958
|
*/
|
|
@@ -890,15 +975,13 @@ type UIOptionsBaseType<T = any, S extends StrictRJSFSchema = RJSFSchema, F exten
|
|
|
890
975
|
* to look up an implementation from the `widgets` list or an actual one-off widget implementation itself
|
|
891
976
|
*/
|
|
892
977
|
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
978
|
};
|
|
896
979
|
|
|
897
980
|
/** The type that represents the Options potentially provided by `ui:options` */
|
|
898
981
|
export type UIOptionsType<
|
|
899
982
|
T = any,
|
|
900
983
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
901
|
-
F extends FormContextType = any
|
|
984
|
+
F extends FormContextType = any,
|
|
902
985
|
> = UIOptionsBaseType<T, S, F> & {
|
|
903
986
|
/** Anything else will be one of these types */
|
|
904
987
|
[key: string]: boolean | number | string | object | any[] | null | undefined;
|
|
@@ -910,7 +993,7 @@ export type UIOptionsType<
|
|
|
910
993
|
export type UiSchema<
|
|
911
994
|
T = any,
|
|
912
995
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
913
|
-
F extends FormContextType = any
|
|
996
|
+
F extends FormContextType = any,
|
|
914
997
|
> = GenericObjectType &
|
|
915
998
|
MakeUIType<UIOptionsBaseType<T, S, F>> & {
|
|
916
999
|
/** The set of Globally relevant UI Schema options that are read from the root-level UiSchema and stored in the
|
|
@@ -919,10 +1002,6 @@ export type UiSchema<
|
|
|
919
1002
|
'ui:globalOptions'?: GlobalUISchemaOptions;
|
|
920
1003
|
/** Allows the form to generate a unique prefix for the `Form`'s root prefix */
|
|
921
1004
|
'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
1005
|
/** By default, any field that is rendered for an `anyOf`/`oneOf` schema will be wrapped inside the `AnyOfField` or
|
|
927
1006
|
* `OneOfField` component. This default behavior may be undesirable if your custom field already handles behavior
|
|
928
1007
|
* related to choosing one or more subschemas contained in the `anyOf`/`oneOf` schema.
|
|
@@ -941,7 +1020,7 @@ export type UiSchema<
|
|
|
941
1020
|
export type CustomValidator<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = (
|
|
942
1021
|
formData: T | undefined,
|
|
943
1022
|
errors: FormValidation<T>,
|
|
944
|
-
uiSchema?: UiSchema<T, S, F
|
|
1023
|
+
uiSchema?: UiSchema<T, S, F>,
|
|
945
1024
|
) => FormValidation<T>;
|
|
946
1025
|
|
|
947
1026
|
/** An `ErrorTransformer` function will take in a list of `errors` & a `uiSchema` and potentially return a
|
|
@@ -949,7 +1028,7 @@ export type CustomValidator<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
949
1028
|
*/
|
|
950
1029
|
export type ErrorTransformer<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = (
|
|
951
1030
|
errors: RJSFValidationError[],
|
|
952
|
-
uiSchema?: UiSchema<T, S, F
|
|
1031
|
+
uiSchema?: UiSchema<T, S, F>,
|
|
953
1032
|
) => RJSFValidationError[];
|
|
954
1033
|
|
|
955
1034
|
/** The type that describes the data that is returned from the `ValidatorType.validateFormData()` function */
|
|
@@ -980,16 +1059,8 @@ export interface ValidatorType<T = any, S extends StrictRJSFSchema = RJSFSchema,
|
|
|
980
1059
|
schema: S,
|
|
981
1060
|
customValidate?: CustomValidator<T, S, F>,
|
|
982
1061
|
transformErrors?: ErrorTransformer<T, S, F>,
|
|
983
|
-
uiSchema?: UiSchema<T, S, F
|
|
1062
|
+
uiSchema?: UiSchema<T, S, F>,
|
|
984
1063
|
): 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
1064
|
/** Validates data against a schema, returning true if the data is valid, or
|
|
994
1065
|
* false otherwise. If the schema is invalid, then this function will return
|
|
995
1066
|
* false.
|
|
@@ -1012,6 +1083,15 @@ export interface ValidatorType<T = any, S extends StrictRJSFSchema = RJSFSchema,
|
|
|
1012
1083
|
reset?: () => void;
|
|
1013
1084
|
}
|
|
1014
1085
|
|
|
1086
|
+
/** The interface for the return value of the `findFieldInSchema` function
|
|
1087
|
+
*/
|
|
1088
|
+
export interface FoundFieldType<S extends StrictRJSFSchema = RJSFSchema> {
|
|
1089
|
+
/** The field that was found, or undefined if it wasn't */
|
|
1090
|
+
field?: S;
|
|
1091
|
+
/** The requiredness of the field found or undefined if it wasn't */
|
|
1092
|
+
isRequired?: boolean;
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1015
1095
|
/** The `SchemaUtilsType` interface provides a wrapper around the publicly exported APIs in the `@rjsf/utils/schema`
|
|
1016
1096
|
* directory such that one does not have to explicitly pass the `validator` or `rootSchema` to each method. Since both
|
|
1017
1097
|
* the `validator` and `rootSchema` generally does not change across a `Form`, this allows for providing a simplified
|
|
@@ -1030,13 +1110,37 @@ export interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchem
|
|
|
1030
1110
|
* @param validator - An implementation of the `ValidatorType` interface that will be compared against the current one
|
|
1031
1111
|
* @param rootSchema - The root schema that will be compared against the current one
|
|
1032
1112
|
* @param [experimental_defaultFormStateBehavior] - Optional configuration object, if provided, allows users to override default form state behavior
|
|
1113
|
+
* @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
|
|
1033
1114
|
* @returns - True if the `SchemaUtilsType` differs from the given `validator` or `rootSchema`
|
|
1034
1115
|
*/
|
|
1035
1116
|
doesSchemaUtilsDiffer(
|
|
1036
1117
|
validator: ValidatorType<T, S, F>,
|
|
1037
1118
|
rootSchema: S,
|
|
1038
|
-
experimental_defaultFormStateBehavior?: Experimental_DefaultFormStateBehavior
|
|
1119
|
+
experimental_defaultFormStateBehavior?: Experimental_DefaultFormStateBehavior,
|
|
1120
|
+
experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,
|
|
1039
1121
|
): boolean;
|
|
1122
|
+
/** Finds the field specified by the `path` within the root or recursed `schema`. If there is no field for the specified
|
|
1123
|
+
* `path`, then the default `{ field: undefined, isRequired: undefined }` is returned. It determines whether a leaf
|
|
1124
|
+
* field is in the `required` list for its parent and if so, it is marked as required on return.
|
|
1125
|
+
*
|
|
1126
|
+
* @param schema - The current node within the JSON schema
|
|
1127
|
+
* @param path - The remaining keys in the path to the desired field
|
|
1128
|
+
* @param [formData] - The form data that is used to determine which oneOf option
|
|
1129
|
+
* @returns - An object that contains the field and its required state. If no field can be found then
|
|
1130
|
+
* `{ field: undefined, isRequired: undefined }` is returned.
|
|
1131
|
+
*/
|
|
1132
|
+
findFieldInSchema(schema: S, path: string | string[], formData?: T): FoundFieldType<S>;
|
|
1133
|
+
/** Finds the oneOf option inside the `schema['any/oneOf']` list which has the `properties[selectorField].default` that
|
|
1134
|
+
* matches the `formData[selectorField]` value. For the purposes of this function, `selectorField` is either
|
|
1135
|
+
* `schema.discriminator.propertyName` or `fallbackField`.
|
|
1136
|
+
*
|
|
1137
|
+
* @param schema - The schema element in which to search for the selected oneOf option
|
|
1138
|
+
* @param fallbackField - The field to use as a backup selector field if the schema does not have a required field
|
|
1139
|
+
* @param xxx - Either `oneOf` or `anyOf`, defines which value is being sought
|
|
1140
|
+
* @param [formData] - The form data that is used to determine which oneOf option
|
|
1141
|
+
* @returns - The anyOf/oneOf option that matches the selector field in the schema or undefined if nothing is selected
|
|
1142
|
+
*/
|
|
1143
|
+
findSelectedOptionInXxxOf(schema: S, fallbackField: string, xxx: 'anyOf' | `oneOf`, formData?: T): S | undefined;
|
|
1040
1144
|
/** Returns the superset of `formData` that includes the given set updated to include any missing fields that have
|
|
1041
1145
|
* computed to have defaults provided in the `schema`.
|
|
1042
1146
|
*
|
|
@@ -1050,7 +1154,7 @@ export interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchem
|
|
|
1050
1154
|
getDefaultFormState(
|
|
1051
1155
|
schema: S,
|
|
1052
1156
|
formData?: T,
|
|
1053
|
-
includeUndefinedValues?: boolean | 'excludeObjectChildren'
|
|
1157
|
+
includeUndefinedValues?: boolean | 'excludeObjectChildren',
|
|
1054
1158
|
): T | T[] | undefined;
|
|
1055
1159
|
/** Determines whether the combination of `schema` and `uiSchema` properties indicates that the label for the `schema`
|
|
1056
1160
|
* should be displayed in a UI.
|
|
@@ -1078,7 +1182,7 @@ export interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchem
|
|
|
1078
1182
|
formData: T | undefined,
|
|
1079
1183
|
options: S[],
|
|
1080
1184
|
selectedOption?: number,
|
|
1081
|
-
discriminatorField?: string
|
|
1185
|
+
discriminatorField?: string,
|
|
1082
1186
|
): number;
|
|
1083
1187
|
/** Given the `formData` and list of `options`, attempts to find the index of the first option that matches the data.
|
|
1084
1188
|
* Always returns the first option if there is nothing that matches.
|
|
@@ -1090,17 +1194,17 @@ export interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchem
|
|
|
1090
1194
|
* @returns - The firstindex of the matched option or 0 if none is available
|
|
1091
1195
|
*/
|
|
1092
1196
|
getFirstMatchingOption(formData: T | undefined, options: S[], discriminatorField?: string): number;
|
|
1093
|
-
/**
|
|
1094
|
-
*
|
|
1197
|
+
/** Helper that acts like lodash's `get` but additionally retrieves `$ref`s as needed to get the path for schemas
|
|
1198
|
+
* containing potentially nested `$ref`s.
|
|
1095
1199
|
*
|
|
1096
|
-
* @param
|
|
1097
|
-
* @param
|
|
1098
|
-
* @param
|
|
1099
|
-
*
|
|
1100
|
-
* @returns - The index of the matched option or 0 if none is available
|
|
1101
|
-
* @deprecated
|
|
1200
|
+
* @param schema - The current node within the JSON schema recursion
|
|
1201
|
+
* @param path - The remaining keys in the path to the desired property
|
|
1202
|
+
* @param defaultValue - The value to return if a value is not found for the `pathList` path
|
|
1203
|
+
* @returns - The internal schema from the `schema` for the given `path` or the `defaultValue` if not found
|
|
1102
1204
|
*/
|
|
1103
|
-
|
|
1205
|
+
getFromSchema(schema: S, path: string | string[], defaultValue: T): T;
|
|
1206
|
+
getFromSchema(schema: S, path: string | string[], defaultValue: S): S;
|
|
1207
|
+
getFromSchema(schema: S, path: string | string[], defaultValue: T | S): S | T;
|
|
1104
1208
|
/** Checks to see if the `schema` and `uiSchema` combination represents an array of files
|
|
1105
1209
|
*
|
|
1106
1210
|
* @param schema - The schema for which check for array of files flag is desired
|
|
@@ -1120,18 +1224,6 @@ export interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchem
|
|
|
1120
1224
|
* @returns - True if schema contains a select, otherwise false
|
|
1121
1225
|
*/
|
|
1122
1226
|
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
1227
|
/** Retrieves an expanded schema that has had all of its conditions, additional properties, references and
|
|
1136
1228
|
* dependencies resolved and merged into the `schema` given a `rawFormData` that is used to do the potentially
|
|
1137
1229
|
* recursive resolution.
|