@rjsf/utils 6.0.0-alpha.0 → 6.0.0-beta.2
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 +1340 -639
- package/dist/index.js.map +4 -4
- package/dist/utils.esm.js +1316 -615
- package/dist/utils.esm.js.map +4 -4
- package/dist/utils.umd.js +1262 -589
- 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 +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 +53 -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 +309 -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 +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 +165 -139
- 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 +54 -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 +453 -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 +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 +271 -181
- 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/lib/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ButtonHTMLAttributes, ChangeEvent, ComponentType, HTMLAttributes, ReactElement, ReactNode, StyleHTMLAttributes } from 'react';
|
|
2
2
|
import { JSONSchema7 } from 'json-schema';
|
|
3
|
-
import { TranslatableString } from './enums';
|
|
3
|
+
import { TranslatableString } from './enums.js';
|
|
4
4
|
/** The representation of any generic object type, usually used as an intersection on other types to make them more
|
|
5
5
|
* flexible in the properties they support (i.e. anything else)
|
|
6
6
|
*/
|
|
@@ -17,6 +17,9 @@ export type RJSFSchema = StrictRJSFSchema & GenericObjectType;
|
|
|
17
17
|
/** Alias GenericObjectType as FormContextType to allow us to remap this at some future date
|
|
18
18
|
*/
|
|
19
19
|
export type FormContextType = GenericObjectType;
|
|
20
|
+
/** The interface for the test ID proxy objects that are returned by the `getTestId` utility function.
|
|
21
|
+
*/
|
|
22
|
+
export type TestIdShape = Record<string, string>;
|
|
20
23
|
/** Experimental feature that specifies the Array `minItems` default form state behavior
|
|
21
24
|
*/
|
|
22
25
|
export type Experimental_ArrayMinItems = {
|
|
@@ -47,7 +50,8 @@ export type Experimental_ArrayMinItems = {
|
|
|
47
50
|
};
|
|
48
51
|
/** Experimental features to specify different default form state behaviors. Currently, this affects the
|
|
49
52
|
* handling of optional array fields where `minItems` is set and handling of setting defaults based on the
|
|
50
|
-
* value of `emptyObjectFields`.
|
|
53
|
+
* value of `emptyObjectFields`. It also affects how `allOf` fields are handled and how to handle merging defaults into
|
|
54
|
+
* the formData in relation to explicit `undefined` values via `mergeDefaultsIntoFormData`.
|
|
51
55
|
*/
|
|
52
56
|
export type Experimental_DefaultFormStateBehavior = {
|
|
53
57
|
/** Optional object, that controls how the default form state for arrays with `minItems` is handled. When not provided
|
|
@@ -67,7 +71,33 @@ export type Experimental_DefaultFormStateBehavior = {
|
|
|
67
71
|
* Optional flag to compute the default form state using allOf and if/then/else schemas. Defaults to `skipDefaults'.
|
|
68
72
|
*/
|
|
69
73
|
allOf?: 'populateDefaults' | 'skipDefaults';
|
|
74
|
+
/** Optional enumerated flag controlling how the defaults are merged into the form data when dealing with undefined
|
|
75
|
+
* values, defaulting to `useFormDataIfPresent`.
|
|
76
|
+
* NOTE: If there is a default for a field and the `formData` is unspecified, the default ALWAYS merges.
|
|
77
|
+
* - `useFormDataIfPresent`: Legacy behavior - Do not merge defaults if there is a value for a field in `formData`,
|
|
78
|
+
* even if that value is explicitly set to `undefined`
|
|
79
|
+
* - `useDefaultIfFormDataUndefined`: - If the value of a field within the `formData` is `undefined`, then use the
|
|
80
|
+
* default value instead
|
|
81
|
+
*/
|
|
82
|
+
mergeDefaultsIntoFormData?: 'useFormDataIfPresent' | 'useDefaultIfFormDataUndefined';
|
|
83
|
+
/** Optional enumerated flag controlling how const values are merged into the form data as defaults when dealing with
|
|
84
|
+
* undefined values, defaulting to `always`. The defaulting behavior for this flag will always be controlled by the
|
|
85
|
+
* `emptyObjectField` flag value. For instance, if `populateRequiredDefaults` is set and the const value is not
|
|
86
|
+
* required, it will not be set.
|
|
87
|
+
* - `always`: A const value will always be merged into the form as a default. If there is are const values in a
|
|
88
|
+
* `oneOf` (for instance to create an enumeration with title different from the values), the first const value
|
|
89
|
+
* will be defaulted
|
|
90
|
+
* - `skipOneOf`: If const is in a `oneOf` it will NOT pick the first value as a default
|
|
91
|
+
* - `never`: A const value will never be used as a default
|
|
92
|
+
*
|
|
93
|
+
*/
|
|
94
|
+
constAsDefaults?: 'always' | 'skipOneOf' | 'never';
|
|
70
95
|
};
|
|
96
|
+
/** Optional function that allows for custom merging of `allOf` schemas
|
|
97
|
+
* @param schema - Schema with `allOf` that needs to be merged
|
|
98
|
+
* @returns The merged schema
|
|
99
|
+
*/
|
|
100
|
+
export type Experimental_CustomMergeAllOf<S extends StrictRJSFSchema = RJSFSchema> = (schema: S) => S;
|
|
71
101
|
/** The interface representing a Date object that contains an optional time */
|
|
72
102
|
export interface DateObject {
|
|
73
103
|
/** The year of the Date */
|
|
@@ -100,6 +130,8 @@ export type InputPropsType = Omit<RangeSpecType, 'step'> & {
|
|
|
100
130
|
step?: number | 'any';
|
|
101
131
|
/** Specifies the `autoComplete` value for an <input> element */
|
|
102
132
|
autoComplete?: HTMLInputElement['autocomplete'];
|
|
133
|
+
/** Specifies a filter for what file types the user can upload. */
|
|
134
|
+
accept?: HTMLInputElement['accept'];
|
|
103
135
|
};
|
|
104
136
|
/** Type describing an id used for a field in the `IdSchema` */
|
|
105
137
|
export type FieldId = {
|
|
@@ -163,51 +195,51 @@ export type FieldValidation = FieldErrors & {
|
|
|
163
195
|
export type FormValidation<T = any> = FieldValidation & {
|
|
164
196
|
[key in keyof T]?: FormValidation<T[key]>;
|
|
165
197
|
};
|
|
198
|
+
/** The base properties passed to various RJSF components. */
|
|
199
|
+
export type RJSFBaseProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
|
|
200
|
+
/** The schema object for the field being described */
|
|
201
|
+
schema: S;
|
|
202
|
+
/** The uiSchema object for this base component */
|
|
203
|
+
uiSchema?: UiSchema<T, S, F>;
|
|
204
|
+
/** The `registry` object */
|
|
205
|
+
registry: Registry<T, S, F>;
|
|
206
|
+
};
|
|
166
207
|
/** The properties that are passed to an `ErrorListTemplate` implementation */
|
|
167
|
-
export type ErrorListProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
|
|
208
|
+
export type ErrorListProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
|
|
168
209
|
/** The errorSchema constructed by `Form` */
|
|
169
210
|
errorSchema: ErrorSchema<T>;
|
|
170
211
|
/** An array of the errors */
|
|
171
212
|
errors: RJSFValidationError[];
|
|
172
213
|
/** The `formContext` object that was passed to `Form` */
|
|
173
214
|
formContext?: F;
|
|
174
|
-
/** The schema that was passed to `Form` */
|
|
175
|
-
schema: S;
|
|
176
|
-
/** The uiSchema that was passed to `Form` */
|
|
177
|
-
uiSchema?: UiSchema<T, S, F>;
|
|
178
|
-
/** The `registry` object */
|
|
179
|
-
registry: Registry<T, S, F>;
|
|
180
215
|
};
|
|
181
216
|
/** The properties that are passed to an `FieldErrorTemplate` implementation */
|
|
182
|
-
export type FieldErrorProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
|
|
217
|
+
export type FieldErrorProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
|
|
183
218
|
/** The errorSchema constructed by `Form` */
|
|
184
219
|
errorSchema?: ErrorSchema<T>;
|
|
185
220
|
/** An array of the errors */
|
|
186
221
|
errors?: Array<string | ReactElement>;
|
|
187
222
|
/** The tree of unique ids for every child field */
|
|
188
223
|
idSchema: IdSchema<T>;
|
|
189
|
-
/** The schema that was passed to field */
|
|
190
|
-
schema: S;
|
|
191
|
-
/** The uiSchema that was passed to field */
|
|
192
|
-
uiSchema?: UiSchema<T, S, F>;
|
|
193
|
-
/** The `registry` object */
|
|
194
|
-
registry: Registry<T, S, F>;
|
|
195
224
|
};
|
|
196
225
|
/** The properties that are passed to an `FieldHelpTemplate` implementation */
|
|
197
|
-
export type FieldHelpProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
|
|
226
|
+
export type FieldHelpProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
|
|
198
227
|
/** The help information to be rendered */
|
|
199
228
|
help?: string | ReactElement;
|
|
200
229
|
/** The tree of unique ids for every child field */
|
|
201
230
|
idSchema: IdSchema<T>;
|
|
202
|
-
/** The schema that was passed to field */
|
|
203
|
-
schema: S;
|
|
204
|
-
/** The uiSchema that was passed to field */
|
|
205
|
-
uiSchema?: UiSchema<T, S, F>;
|
|
206
231
|
/** Flag indicating whether there are errors associated with this field */
|
|
207
232
|
hasErrors?: boolean;
|
|
208
|
-
/** The `registry` object */
|
|
209
|
-
registry: Registry<T, S, F>;
|
|
210
233
|
};
|
|
234
|
+
/** The properties that are passed to a `GridTemplate` */
|
|
235
|
+
export interface GridTemplateProps extends GenericObjectType {
|
|
236
|
+
/** The contents of the grid template */
|
|
237
|
+
children?: ReactNode;
|
|
238
|
+
/** Optional flag indicating whether the grid element represents a column, necessary for themes which have components
|
|
239
|
+
* for Rows vs Columns. NOTE: This is falsy by default when not specified
|
|
240
|
+
*/
|
|
241
|
+
column?: boolean;
|
|
242
|
+
}
|
|
211
243
|
/** The set of `Fields` stored in the `Registry` */
|
|
212
244
|
export type RegistryFieldsType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
|
|
213
245
|
/** A `Field` indexed by `name` */
|
|
@@ -219,13 +251,15 @@ export type RegistryWidgetsType<T = any, S extends StrictRJSFSchema = RJSFSchema
|
|
|
219
251
|
[name: string]: Widget<T, S, F>;
|
|
220
252
|
};
|
|
221
253
|
/** The set of RJSF templates that can be overridden by themes or users */
|
|
222
|
-
export
|
|
254
|
+
export type TemplatesType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
|
|
223
255
|
/** The template to use while rendering normal or fixed array fields */
|
|
224
256
|
ArrayFieldTemplate: ComponentType<ArrayFieldTemplateProps<T, S, F>>;
|
|
225
257
|
/** The template to use while rendering the description for an array field */
|
|
226
258
|
ArrayFieldDescriptionTemplate: ComponentType<ArrayFieldDescriptionProps<T, S, F>>;
|
|
259
|
+
/** The template to use while rendering the buttons for an item in an array field */
|
|
260
|
+
ArrayFieldItemButtonsTemplate: ComponentType<ArrayFieldItemButtonsTemplateType<T, S, F>>;
|
|
227
261
|
/** The template to use while rendering an item in an array field */
|
|
228
|
-
ArrayFieldItemTemplate: ComponentType<
|
|
262
|
+
ArrayFieldItemTemplate: ComponentType<ArrayFieldItemTemplateType<T, S, F>>;
|
|
229
263
|
/** The template to use while rendering the title for an array field */
|
|
230
264
|
ArrayFieldTitleTemplate: ComponentType<ArrayFieldTitleProps<T, S, F>>;
|
|
231
265
|
/** The template to use while rendering the standard html input */
|
|
@@ -240,6 +274,8 @@ export interface TemplatesType<T = any, S extends StrictRJSFSchema = RJSFSchema,
|
|
|
240
274
|
FieldHelpTemplate: ComponentType<FieldHelpProps<T, S, F>>;
|
|
241
275
|
/** The template to use while rendering a field */
|
|
242
276
|
FieldTemplate: ComponentType<FieldTemplateProps<T, S, F>>;
|
|
277
|
+
/** The template to use to render a Grid element */
|
|
278
|
+
GridTemplate: ComponentType<GridTemplateProps>;
|
|
243
279
|
/** The template to use while rendering an object */
|
|
244
280
|
ObjectFieldTemplate: ComponentType<ObjectFieldTemplateProps<T, S, F>>;
|
|
245
281
|
/** The template to use for rendering the title of a field */
|
|
@@ -263,7 +299,12 @@ export interface TemplatesType<T = any, S extends StrictRJSFSchema = RJSFSchema,
|
|
|
263
299
|
/** The template to use for the Remove button used for AdditionalProperties and Array items */
|
|
264
300
|
RemoveButton: ComponentType<IconButtonProps<T, S, F>>;
|
|
265
301
|
};
|
|
266
|
-
}
|
|
302
|
+
} & {
|
|
303
|
+
/** Allow this to support any named `ComponentType` or an object of named `ComponentType`s */
|
|
304
|
+
[key: string]: ComponentType<any> | {
|
|
305
|
+
[key: string]: ComponentType<any>;
|
|
306
|
+
} | undefined;
|
|
307
|
+
};
|
|
267
308
|
/** The set of UiSchema options that can be set globally and used as fallbacks at an individual template, field or
|
|
268
309
|
* widget level when no field-level value of the option is provided.
|
|
269
310
|
*/
|
|
@@ -282,6 +323,9 @@ export type GlobalUISchemaOptions = {
|
|
|
282
323
|
* This option allows you to change the separator between the original key name and the integer. Default is "-"
|
|
283
324
|
*/
|
|
284
325
|
duplicateKeySuffixSeparator?: string;
|
|
326
|
+
/** Enables the displaying of description text that contains markdown
|
|
327
|
+
*/
|
|
328
|
+
enableMarkdownInDescription?: boolean;
|
|
285
329
|
};
|
|
286
330
|
/** The object containing the registered core, theme and custom fields and widgets as well as the root schema, form
|
|
287
331
|
* context, schema utils and templates.
|
|
@@ -313,11 +357,7 @@ export interface Registry<T = any, S extends StrictRJSFSchema = RJSFSchema, F ex
|
|
|
313
357
|
globalUiOptions?: GlobalUISchemaOptions;
|
|
314
358
|
}
|
|
315
359
|
/** The properties that are passed to a Field implementation */
|
|
316
|
-
export interface FieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> extends GenericObjectType, Pick<HTMLAttributes<HTMLElement>, Exclude<keyof HTMLAttributes<HTMLElement>, 'onBlur' | 'onFocus' | 'onChange'>> {
|
|
317
|
-
/** The JSON subschema object for this field */
|
|
318
|
-
schema: S;
|
|
319
|
-
/** The uiSchema for this field */
|
|
320
|
-
uiSchema?: UiSchema<T, S, F>;
|
|
360
|
+
export interface FieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> extends GenericObjectType, RJSFBaseProps<T, S, F>, Pick<HTMLAttributes<HTMLElement>, Exclude<keyof HTMLAttributes<HTMLElement>, 'onBlur' | 'onFocus' | 'onChange'>> {
|
|
321
361
|
/** The tree of unique ids for every child field */
|
|
322
362
|
idSchema: IdSchema<T>;
|
|
323
363
|
/** The data for this field */
|
|
@@ -354,13 +394,11 @@ export interface FieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
354
394
|
idSeparator?: string;
|
|
355
395
|
/** An array of strings listing all generated error messages from encountered errors for this field */
|
|
356
396
|
rawErrors?: string[];
|
|
357
|
-
/** The `registry` object */
|
|
358
|
-
registry: Registry<T, S, F>;
|
|
359
397
|
}
|
|
360
398
|
/** The definition of a React-based Field component */
|
|
361
399
|
export type Field<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = ComponentType<FieldProps<T, S, F>>;
|
|
362
400
|
/** The properties that are passed to a FieldTemplate implementation */
|
|
363
|
-
export type FieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
|
|
401
|
+
export type FieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
|
|
364
402
|
/** The id of the field in the hierarchy. You can use it to render a label targeting the wrapped widget */
|
|
365
403
|
id: string;
|
|
366
404
|
/** A string containing the base CSS classes, merged with any custom ones defined in your uiSchema */
|
|
@@ -401,10 +439,6 @@ export type FieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema,
|
|
|
401
439
|
* you don't want to clutter the UI
|
|
402
440
|
*/
|
|
403
441
|
displayLabel?: boolean;
|
|
404
|
-
/** The schema object for this field */
|
|
405
|
-
schema: S;
|
|
406
|
-
/** The uiSchema object for this field */
|
|
407
|
-
uiSchema?: UiSchema<T, S, F>;
|
|
408
442
|
/** The `formContext` object that was passed to `Form` */
|
|
409
443
|
formContext?: F;
|
|
410
444
|
/** The formData for this field */
|
|
@@ -415,47 +449,29 @@ export type FieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema,
|
|
|
415
449
|
onKeyChange: (value: string) => () => void;
|
|
416
450
|
/** The property drop/removal event handler; Called when a field is removed in an additionalProperty context */
|
|
417
451
|
onDropPropertyClick: (value: string) => () => void;
|
|
418
|
-
/** The `registry` object */
|
|
419
|
-
registry: Registry<T, S, F>;
|
|
420
452
|
};
|
|
421
453
|
/** The properties that are passed to the `UnsupportedFieldTemplate` implementation */
|
|
422
|
-
export type UnsupportedFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
|
|
423
|
-
/** The schema object for this field */
|
|
424
|
-
schema: S;
|
|
454
|
+
export type UnsupportedFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
|
|
425
455
|
/** The tree of unique ids for every child field */
|
|
426
456
|
idSchema?: IdSchema<T>;
|
|
427
457
|
/** The reason why the schema field has an unsupported type */
|
|
428
458
|
reason: string;
|
|
429
|
-
/** The `registry` object */
|
|
430
|
-
registry: Registry<T, S, F>;
|
|
431
459
|
};
|
|
432
460
|
/** The properties that are passed to a `TitleFieldTemplate` implementation */
|
|
433
|
-
export type TitleFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
|
|
461
|
+
export type TitleFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
|
|
434
462
|
/** The id of the field title in the hierarchy */
|
|
435
463
|
id: string;
|
|
436
464
|
/** The title for the field being rendered */
|
|
437
465
|
title: string;
|
|
438
|
-
/** The schema object for the field being titled */
|
|
439
|
-
schema: S;
|
|
440
|
-
/** The uiSchema object for this title field */
|
|
441
|
-
uiSchema?: UiSchema<T, S, F>;
|
|
442
466
|
/** A boolean value stating if the field is required */
|
|
443
467
|
required?: boolean;
|
|
444
|
-
/** The `registry` object */
|
|
445
|
-
registry: Registry<T, S, F>;
|
|
446
468
|
};
|
|
447
469
|
/** The properties that are passed to a `DescriptionFieldTemplate` implementation */
|
|
448
|
-
export type DescriptionFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
|
|
470
|
+
export type DescriptionFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
|
|
449
471
|
/** The id of the field description in the hierarchy */
|
|
450
472
|
id: string;
|
|
451
|
-
/** The schema object for the field being described */
|
|
452
|
-
schema: S;
|
|
453
|
-
/** The uiSchema object for this description field */
|
|
454
|
-
uiSchema?: UiSchema<T, S, F>;
|
|
455
473
|
/** The description of the field being rendered */
|
|
456
474
|
description: string | ReactElement;
|
|
457
|
-
/** The `registry` object */
|
|
458
|
-
registry: Registry<T, S, F>;
|
|
459
475
|
};
|
|
460
476
|
/** The properties that are passed to a `ArrayFieldTitleTemplate` implementation */
|
|
461
477
|
export type ArrayFieldTitleProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Omit<TitleFieldProps<T, S, F>, 'id' | 'title'> & {
|
|
@@ -471,12 +487,14 @@ export type ArrayFieldDescriptionProps<T = any, S extends StrictRJSFSchema = RJS
|
|
|
471
487
|
/** The idSchema of the field in the hierarchy */
|
|
472
488
|
idSchema: IdSchema<T>;
|
|
473
489
|
};
|
|
474
|
-
/** The properties of each element in the ArrayFieldTemplateProps.items array */
|
|
475
|
-
export type
|
|
476
|
-
/** The
|
|
477
|
-
|
|
490
|
+
/** The properties of the buttons to render for each element in the ArrayFieldTemplateProps.items array */
|
|
491
|
+
export type ArrayFieldItemButtonsTemplateType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
|
|
492
|
+
/** The idSchema of the item for which buttons are being rendered */
|
|
493
|
+
idSchema: IdSchema<T>;
|
|
478
494
|
/** The className string */
|
|
479
|
-
className
|
|
495
|
+
className?: string;
|
|
496
|
+
/** Any optional style attributes */
|
|
497
|
+
style?: ButtonHTMLAttributes<HTMLButtonElement>['style'];
|
|
480
498
|
/** A boolean value stating if the array item is disabled */
|
|
481
499
|
disabled?: boolean;
|
|
482
500
|
/** A boolean value stating whether new items can be added to the array */
|
|
@@ -489,8 +507,6 @@ export type ArrayFieldTemplateItemType<T = any, S extends StrictRJSFSchema = RJS
|
|
|
489
507
|
hasMoveUp: boolean;
|
|
490
508
|
/** A boolean value stating whether the array item can be removed */
|
|
491
509
|
hasRemove: boolean;
|
|
492
|
-
/** A boolean value stating whether the array item has a toolbar */
|
|
493
|
-
hasToolbar: boolean;
|
|
494
510
|
/** A number stating the index the array item occurs in `items` */
|
|
495
511
|
index: number;
|
|
496
512
|
/** A number stating the total number `items` in the array */
|
|
@@ -505,17 +521,34 @@ export type ArrayFieldTemplateItemType<T = any, S extends StrictRJSFSchema = RJS
|
|
|
505
521
|
onReorderClick: (index: number, newIndex: number) => (event?: any) => void;
|
|
506
522
|
/** A boolean value stating if the array item is read-only */
|
|
507
523
|
readonly?: boolean;
|
|
524
|
+
};
|
|
525
|
+
/** The properties of each element in the ArrayFieldTemplateProps.items array */
|
|
526
|
+
export type ArrayFieldItemTemplateType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
|
|
527
|
+
/** The html for the item's content */
|
|
528
|
+
children: ReactNode;
|
|
529
|
+
/** The props to pass to the `ArrayFieldItemButtonTemplate` */
|
|
530
|
+
buttonsProps: ArrayFieldItemButtonsTemplateType<T, S, F>;
|
|
531
|
+
/** The className string */
|
|
532
|
+
className: string;
|
|
533
|
+
/** A boolean value stating if the array item is disabled */
|
|
534
|
+
disabled?: boolean;
|
|
535
|
+
/** A boolean value stating whether the array item has a toolbar */
|
|
536
|
+
hasToolbar: boolean;
|
|
537
|
+
/** A number stating the index the array item occurs in `items` */
|
|
538
|
+
index: number;
|
|
539
|
+
/** A number stating the total number `items` in the array */
|
|
540
|
+
totalItems: number;
|
|
541
|
+
/** A boolean value stating if the array item is read-only */
|
|
542
|
+
readonly?: boolean;
|
|
508
543
|
/** A stable, unique key for the array item */
|
|
509
544
|
key: string;
|
|
510
|
-
/** The schema object for this array item */
|
|
511
|
-
schema: S;
|
|
512
|
-
/** The uiSchema object for this array item */
|
|
513
|
-
uiSchema?: UiSchema<T, S, F>;
|
|
514
|
-
/** The `registry` object */
|
|
515
|
-
registry: Registry<T, S, F>;
|
|
516
545
|
};
|
|
546
|
+
/**
|
|
547
|
+
* @deprecated - Use `ArrayFieldItemTemplateType` instead
|
|
548
|
+
*/
|
|
549
|
+
export type ArrayFieldTemplateItemType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = ArrayFieldItemTemplateType<T, S, F>;
|
|
517
550
|
/** The properties that are passed to an ArrayFieldTemplate implementation */
|
|
518
|
-
export type ArrayFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
|
|
551
|
+
export type ArrayFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
|
|
519
552
|
/** A boolean value stating whether new elements can be added to the array */
|
|
520
553
|
canAdd?: boolean;
|
|
521
554
|
/** The className string */
|
|
@@ -525,7 +558,7 @@ export type ArrayFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSc
|
|
|
525
558
|
/** An object containing the id for this object & ids for its properties */
|
|
526
559
|
idSchema: IdSchema<T>;
|
|
527
560
|
/** An array of objects representing the items in the array */
|
|
528
|
-
items:
|
|
561
|
+
items: ArrayFieldItemTemplateType<T, S, F>[];
|
|
529
562
|
/** A function that adds a new item to the array */
|
|
530
563
|
onAddClick: (event?: any) => void;
|
|
531
564
|
/** A boolean value stating if the array is read-only */
|
|
@@ -534,10 +567,6 @@ export type ArrayFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSc
|
|
|
534
567
|
required?: boolean;
|
|
535
568
|
/** A boolean value stating if the field is hiding its errors */
|
|
536
569
|
hideError?: boolean;
|
|
537
|
-
/** The schema object for this array */
|
|
538
|
-
schema: S;
|
|
539
|
-
/** The uiSchema object for this array field */
|
|
540
|
-
uiSchema?: UiSchema<T, S, F>;
|
|
541
570
|
/** A string value containing the title for the array */
|
|
542
571
|
title: string;
|
|
543
572
|
/** The `formContext` object that was passed to Form */
|
|
@@ -548,8 +577,6 @@ export type ArrayFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSc
|
|
|
548
577
|
errorSchema?: ErrorSchema<T>;
|
|
549
578
|
/** An array of strings listing all generated error messages from encountered errors for this widget */
|
|
550
579
|
rawErrors?: string[];
|
|
551
|
-
/** The `registry` object */
|
|
552
|
-
registry: Registry<T, S, F>;
|
|
553
580
|
};
|
|
554
581
|
/** The properties of each element in the ObjectFieldTemplateProps.properties array */
|
|
555
582
|
export type ObjectFieldTemplatePropertyType = {
|
|
@@ -565,11 +592,11 @@ export type ObjectFieldTemplatePropertyType = {
|
|
|
565
592
|
hidden: boolean;
|
|
566
593
|
};
|
|
567
594
|
/** The properties that are passed to an ObjectFieldTemplate implementation */
|
|
568
|
-
export type ObjectFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
|
|
595
|
+
export type ObjectFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
|
|
569
596
|
/** A string value containing the title for the object */
|
|
570
597
|
title: string;
|
|
571
598
|
/** A string value containing the description for the object */
|
|
572
|
-
description?: string;
|
|
599
|
+
description?: string | ReactElement;
|
|
573
600
|
/** A boolean value stating if the object is disabled */
|
|
574
601
|
disabled?: boolean;
|
|
575
602
|
/** An array of objects representing the properties in the object */
|
|
@@ -582,10 +609,6 @@ export type ObjectFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFS
|
|
|
582
609
|
required?: boolean;
|
|
583
610
|
/** A boolean value stating if the field is hiding its errors */
|
|
584
611
|
hideError?: boolean;
|
|
585
|
-
/** The schema object for this object */
|
|
586
|
-
schema: S;
|
|
587
|
-
/** The uiSchema object for this object field */
|
|
588
|
-
uiSchema?: UiSchema<T, S, F>;
|
|
589
612
|
/** An object containing the id for this object & ids for its properties */
|
|
590
613
|
idSchema: IdSchema<T>;
|
|
591
614
|
/** The optional validation errors in the form of an `ErrorSchema` */
|
|
@@ -594,16 +617,14 @@ export type ObjectFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFS
|
|
|
594
617
|
formData?: T;
|
|
595
618
|
/** The `formContext` object that was passed to Form */
|
|
596
619
|
formContext?: F;
|
|
597
|
-
/** The `registry` object */
|
|
598
|
-
registry: Registry<T, S, F>;
|
|
599
620
|
};
|
|
600
621
|
/** The properties that are passed to a WrapIfAdditionalTemplate implementation */
|
|
601
|
-
export type WrapIfAdditionalTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = {
|
|
622
|
+
export type WrapIfAdditionalTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = RJSFBaseProps<T, S, F> & {
|
|
602
623
|
/** The field or widget component instance for this field row */
|
|
603
624
|
children: ReactNode;
|
|
604
|
-
} & Pick<FieldTemplateProps<T, S, F>, 'id' | 'classNames' | 'style' | 'label' | 'required' | 'readonly' | 'disabled' | 'schema' | 'uiSchema' | 'onKeyChange' | 'onDropPropertyClick' | 'registry'>;
|
|
625
|
+
} & Pick<FieldTemplateProps<T, S, F>, 'id' | 'classNames' | 'hideError' | 'rawErrors' | 'style' | 'label' | 'required' | 'readonly' | 'disabled' | 'schema' | 'uiSchema' | 'onKeyChange' | 'onDropPropertyClick' | 'registry'>;
|
|
605
626
|
/** The properties that are passed to a Widget implementation */
|
|
606
|
-
export interface WidgetProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> extends GenericObjectType, Pick<HTMLAttributes<HTMLElement>, Exclude<keyof HTMLAttributes<HTMLElement>, 'onBlur' | 'onFocus'>> {
|
|
627
|
+
export interface WidgetProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> extends GenericObjectType, RJSFBaseProps<T, S, F>, Pick<HTMLAttributes<HTMLElement>, Exclude<keyof HTMLAttributes<HTMLElement>, 'onBlur' | 'onFocus'>> {
|
|
607
628
|
/** The generated id for this widget, used to provide unique `name`s and `id`s for the HTML field elements rendered by
|
|
608
629
|
* widgets
|
|
609
630
|
*/
|
|
@@ -612,10 +633,6 @@ export interface WidgetProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
612
633
|
* of custom widgets.
|
|
613
634
|
*/
|
|
614
635
|
name: string;
|
|
615
|
-
/** The JSONSchema subschema object for this widget */
|
|
616
|
-
schema: S;
|
|
617
|
-
/** The uiSchema for this widget */
|
|
618
|
-
uiSchema?: UiSchema<T, S, F>;
|
|
619
636
|
/** The current value for this widget */
|
|
620
637
|
value: any;
|
|
621
638
|
/** The required status of this widget */
|
|
@@ -655,8 +672,6 @@ export interface WidgetProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
655
672
|
multiple?: boolean;
|
|
656
673
|
/** An array of strings listing all generated error messages from encountered errors for this widget */
|
|
657
674
|
rawErrors?: string[];
|
|
658
|
-
/** The `registry` object */
|
|
659
|
-
registry: Registry<T, S, F>;
|
|
660
675
|
}
|
|
661
676
|
/** The definition of a React-based Widget component */
|
|
662
677
|
export type Widget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = ComponentType<WidgetProps<T, S, F>>;
|
|
@@ -676,15 +691,11 @@ export type SubmitButtonProps<T = any, S extends StrictRJSFSchema = RJSFSchema,
|
|
|
676
691
|
registry: Registry<T, S, F>;
|
|
677
692
|
};
|
|
678
693
|
/** The type that defines the props for an Icon button, extending from a basic HTML button attributes */
|
|
679
|
-
export type IconButtonProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
694
|
+
export type IconButtonProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = ButtonHTMLAttributes<HTMLButtonElement> & Omit<RJSFBaseProps<T, S, F>, 'schema'> & {
|
|
680
695
|
/** An alternative specification for the type of the icon button */
|
|
681
696
|
iconType?: string;
|
|
682
697
|
/** The name representation or actual react element implementation for the icon */
|
|
683
698
|
icon?: string | ReactElement;
|
|
684
|
-
/** The uiSchema for this widget */
|
|
685
|
-
uiSchema?: UiSchema<T, S, F>;
|
|
686
|
-
/** The `registry` object */
|
|
687
|
-
registry: Registry<T, S, F>;
|
|
688
699
|
};
|
|
689
700
|
/** The type that defines how to change the behavior of the submit button for the form */
|
|
690
701
|
export type UISchemaSubmitButtonOptions = {
|
|
@@ -716,7 +727,11 @@ type MakeUIType<Type> = {
|
|
|
716
727
|
/** This type represents all the known supported options in the `ui:options` property, kept separate in order to
|
|
717
728
|
* remap the keys. It also contains all the properties, optionally, of `TemplatesType` except "ButtonTemplates"
|
|
718
729
|
*/
|
|
719
|
-
type UIOptionsBaseType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Partial<
|
|
730
|
+
type UIOptionsBaseType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Partial<Pick<TemplatesType<T, S, F>, 'ArrayFieldDescriptionTemplate' | 'ArrayFieldItemTemplate' | 'ArrayFieldTemplate' | 'ArrayFieldTitleTemplate' | 'BaseInputTemplate' | 'DescriptionFieldTemplate' | 'ErrorListTemplate' | 'FieldErrorTemplate' | 'FieldHelpTemplate' | 'FieldTemplate' | 'ObjectFieldTemplate' | 'TitleFieldTemplate' | 'UnsupportedFieldTemplate' | 'WrapIfAdditionalTemplate'>> & GlobalUISchemaOptions & {
|
|
731
|
+
/** Allows RJSF to override the default field implementation by specifying either the name of a field that is used
|
|
732
|
+
* to look up an implementation from the `fields` list or an actual one-off `Field` component implementation itself
|
|
733
|
+
*/
|
|
734
|
+
field?: Field<T, S, F> | string;
|
|
720
735
|
/** Any classnames that the user wants to be applied to a field in the ui */
|
|
721
736
|
classNames?: string;
|
|
722
737
|
/** Any custom style that the user wants to apply to a field in the ui, applied on the same element as classNames */
|
|
@@ -739,6 +754,12 @@ type UIOptionsBaseType<T = any, S extends StrictRJSFSchema = RJSFSchema, F exten
|
|
|
739
754
|
emptyValue?: any;
|
|
740
755
|
/** Will disable any of the enum options specified in the array (by value) */
|
|
741
756
|
enumDisabled?: Array<string | number | boolean>;
|
|
757
|
+
/** Allows a user to provide a list of labels for enum values in the schema */
|
|
758
|
+
enumNames?: string[];
|
|
759
|
+
/** Provides an optional field within a schema to be used as the oneOf/anyOf selector when there isn't a
|
|
760
|
+
* discriminator
|
|
761
|
+
*/
|
|
762
|
+
optionsSchemaSelector?: string;
|
|
742
763
|
/** Flag, if set to `true`, will hide the default error display for the given field AND all of its child fields in the
|
|
743
764
|
* hierarchy
|
|
744
765
|
*/
|
|
@@ -761,8 +782,6 @@ type UIOptionsBaseType<T = any, S extends StrictRJSFSchema = RJSFSchema, F exten
|
|
|
761
782
|
* to look up an implementation from the `widgets` list or an actual one-off widget implementation itself
|
|
762
783
|
*/
|
|
763
784
|
widget?: Widget<T, S, F> | string;
|
|
764
|
-
/** Allows a user to provide a list of labels for enum values in the schema */
|
|
765
|
-
enumNames?: string[];
|
|
766
785
|
};
|
|
767
786
|
/** The type that represents the Options potentially provided by `ui:options` */
|
|
768
787
|
export type UIOptionsType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = UIOptionsBaseType<T, S, F> & {
|
|
@@ -779,10 +798,6 @@ export type UiSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
|
|
|
779
798
|
'ui:globalOptions'?: GlobalUISchemaOptions;
|
|
780
799
|
/** Allows the form to generate a unique prefix for the `Form`'s root prefix */
|
|
781
800
|
'ui:rootFieldId'?: string;
|
|
782
|
-
/** Allows RJSF to override the default field implementation by specifying either the name of a field that is used
|
|
783
|
-
* to look up an implementation from the `fields` list or an actual one-off `Field` component implementation itself
|
|
784
|
-
*/
|
|
785
|
-
'ui:field'?: Field<T, S, F> | string;
|
|
786
801
|
/** By default, any field that is rendered for an `anyOf`/`oneOf` schema will be wrapped inside the `AnyOfField` or
|
|
787
802
|
* `OneOfField` component. This default behavior may be undesirable if your custom field already handles behavior
|
|
788
803
|
* related to choosing one or more subschemas contained in the `anyOf`/`oneOf` schema.
|
|
@@ -825,14 +840,6 @@ export interface ValidatorType<T = any, S extends StrictRJSFSchema = RJSFSchema,
|
|
|
825
840
|
* @param [uiSchema] - An optional uiSchema that is passed to `transformErrors` and `customValidate`
|
|
826
841
|
*/
|
|
827
842
|
validateFormData(formData: T | undefined, schema: S, customValidate?: CustomValidator<T, S, F>, transformErrors?: ErrorTransformer<T, S, F>, uiSchema?: UiSchema<T, S, F>): ValidationData<T>;
|
|
828
|
-
/** Converts an `errorSchema` into a list of `RJSFValidationErrors`
|
|
829
|
-
*
|
|
830
|
-
* @param errorSchema - The `ErrorSchema` instance to convert
|
|
831
|
-
* @param [fieldPath=[]] - The current field path, defaults to [] if not specified
|
|
832
|
-
* @deprecated - Use the `toErrorList()` function provided by `@rjsf/utils` instead. This function will be removed in
|
|
833
|
-
* the next major release.
|
|
834
|
-
*/
|
|
835
|
-
toErrorList(errorSchema?: ErrorSchema<T>, fieldPath?: string[]): RJSFValidationError[];
|
|
836
843
|
/** Validates data against a schema, returning true if the data is valid, or
|
|
837
844
|
* false otherwise. If the schema is invalid, then this function will return
|
|
838
845
|
* false.
|
|
@@ -857,6 +864,14 @@ export interface ValidatorType<T = any, S extends StrictRJSFSchema = RJSFSchema,
|
|
|
857
864
|
*/
|
|
858
865
|
reset?: () => void;
|
|
859
866
|
}
|
|
867
|
+
/** The interface for the return value of the `findFieldInSchema` function
|
|
868
|
+
*/
|
|
869
|
+
export interface FoundFieldType<S extends StrictRJSFSchema = RJSFSchema> {
|
|
870
|
+
/** The field that was found, or undefined if it wasn't */
|
|
871
|
+
field?: S;
|
|
872
|
+
/** The requiredness of the field found or undefined if it wasn't */
|
|
873
|
+
isRequired?: boolean;
|
|
874
|
+
}
|
|
860
875
|
/** The `SchemaUtilsType` interface provides a wrapper around the publicly exported APIs in the `@rjsf/utils/schema`
|
|
861
876
|
* directory such that one does not have to explicitly pass the `validator` or `rootSchema` to each method. Since both
|
|
862
877
|
* the `validator` and `rootSchema` generally does not change across a `Form`, this allows for providing a simplified
|
|
@@ -875,9 +890,32 @@ export interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchem
|
|
|
875
890
|
* @param validator - An implementation of the `ValidatorType` interface that will be compared against the current one
|
|
876
891
|
* @param rootSchema - The root schema that will be compared against the current one
|
|
877
892
|
* @param [experimental_defaultFormStateBehavior] - Optional configuration object, if provided, allows users to override default form state behavior
|
|
893
|
+
* @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
|
|
878
894
|
* @returns - True if the `SchemaUtilsType` differs from the given `validator` or `rootSchema`
|
|
879
895
|
*/
|
|
880
|
-
doesSchemaUtilsDiffer(validator: ValidatorType<T, S, F>, rootSchema: S, experimental_defaultFormStateBehavior?: Experimental_DefaultFormStateBehavior): boolean;
|
|
896
|
+
doesSchemaUtilsDiffer(validator: ValidatorType<T, S, F>, rootSchema: S, experimental_defaultFormStateBehavior?: Experimental_DefaultFormStateBehavior, experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>): boolean;
|
|
897
|
+
/** Finds the field specified by the `path` within the root or recursed `schema`. If there is no field for the specified
|
|
898
|
+
* `path`, then the default `{ field: undefined, isRequired: undefined }` is returned. It determines whether a leaf
|
|
899
|
+
* field is in the `required` list for its parent and if so, it is marked as required on return.
|
|
900
|
+
*
|
|
901
|
+
* @param schema - The current node within the JSON schema
|
|
902
|
+
* @param path - The remaining keys in the path to the desired field
|
|
903
|
+
* @param [formData] - The form data that is used to determine which oneOf option
|
|
904
|
+
* @returns - An object that contains the field and its required state. If no field can be found then
|
|
905
|
+
* `{ field: undefined, isRequired: undefined }` is returned.
|
|
906
|
+
*/
|
|
907
|
+
findFieldInSchema(schema: S, path: string | string[], formData?: T): FoundFieldType<S>;
|
|
908
|
+
/** Finds the oneOf option inside the `schema['any/oneOf']` list which has the `properties[selectorField].default` that
|
|
909
|
+
* matches the `formData[selectorField]` value. For the purposes of this function, `selectorField` is either
|
|
910
|
+
* `schema.discriminator.propertyName` or `fallbackField`.
|
|
911
|
+
*
|
|
912
|
+
* @param schema - The schema element in which to search for the selected oneOf option
|
|
913
|
+
* @param fallbackField - The field to use as a backup selector field if the schema does not have a required field
|
|
914
|
+
* @param xxx - Either `oneOf` or `anyOf`, defines which value is being sought
|
|
915
|
+
* @param [formData] - The form data that is used to determine which oneOf option
|
|
916
|
+
* @returns - The anyOf/oneOf option that matches the selector field in the schema or undefined if nothing is selected
|
|
917
|
+
*/
|
|
918
|
+
findSelectedOptionInXxxOf(schema: S, fallbackField: string, xxx: 'anyOf' | `oneOf`, formData?: T): S | undefined;
|
|
881
919
|
/** Returns the superset of `formData` that includes the given set updated to include any missing fields that have
|
|
882
920
|
* computed to have defaults provided in the `schema`.
|
|
883
921
|
*
|
|
@@ -922,17 +960,17 @@ export interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchem
|
|
|
922
960
|
* @returns - The firstindex of the matched option or 0 if none is available
|
|
923
961
|
*/
|
|
924
962
|
getFirstMatchingOption(formData: T | undefined, options: S[], discriminatorField?: string): number;
|
|
925
|
-
/**
|
|
926
|
-
*
|
|
963
|
+
/** Helper that acts like lodash's `get` but additionally retrieves `$ref`s as needed to get the path for schemas
|
|
964
|
+
* containing potentially nested `$ref`s.
|
|
927
965
|
*
|
|
928
|
-
* @param
|
|
929
|
-
* @param
|
|
930
|
-
* @param
|
|
931
|
-
*
|
|
932
|
-
* @returns - The index of the matched option or 0 if none is available
|
|
933
|
-
* @deprecated
|
|
966
|
+
* @param schema - The current node within the JSON schema recursion
|
|
967
|
+
* @param path - The remaining keys in the path to the desired property
|
|
968
|
+
* @param defaultValue - The value to return if a value is not found for the `pathList` path
|
|
969
|
+
* @returns - The internal schema from the `schema` for the given `path` or the `defaultValue` if not found
|
|
934
970
|
*/
|
|
935
|
-
|
|
971
|
+
getFromSchema(schema: S, path: string | string[], defaultValue: T): T;
|
|
972
|
+
getFromSchema(schema: S, path: string | string[], defaultValue: S): S;
|
|
973
|
+
getFromSchema(schema: S, path: string | string[], defaultValue: T | S): S | T;
|
|
936
974
|
/** Checks to see if the `schema` and `uiSchema` combination represents an array of files
|
|
937
975
|
*
|
|
938
976
|
* @param schema - The schema for which check for array of files flag is desired
|
|
@@ -952,18 +990,6 @@ export interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchem
|
|
|
952
990
|
* @returns - True if schema contains a select, otherwise false
|
|
953
991
|
*/
|
|
954
992
|
isSelect(schema: S): boolean;
|
|
955
|
-
/** Merges the errors in `additionalErrorSchema` into the existing `validationData` by combining the hierarchies in
|
|
956
|
-
* the two `ErrorSchema`s and then appending the error list from the `additionalErrorSchema` obtained by calling
|
|
957
|
-
* `validator.toErrorList()` onto the `errors` in the `validationData`. If no `additionalErrorSchema` is passed, then
|
|
958
|
-
* `validationData` is returned.
|
|
959
|
-
*
|
|
960
|
-
* @param validationData - The current `ValidationData` into which to merge the additional errors
|
|
961
|
-
* @param [additionalErrorSchema] - The additional set of errors
|
|
962
|
-
* @returns - The `validationData` with the additional errors from `additionalErrorSchema` merged into it, if provided
|
|
963
|
-
* @deprecated - Use the `validationDataMerge()` function exported from `@rjsf/utils` instead. This function will be
|
|
964
|
-
* removed in the next major release.
|
|
965
|
-
*/
|
|
966
|
-
mergeValidationData(validationData: ValidationData<T>, additionalErrorSchema?: ErrorSchema<T>): ValidationData<T>;
|
|
967
993
|
/** Retrieves an expanded schema that has had all of its conditions, additional properties, references and
|
|
968
994
|
* dependencies resolved and merged into the `schema` given a `rawFormData` that is used to do the potentially
|
|
969
995
|
* recursive resolution.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ErrorSchema, FormValidation } from './types';
|
|
1
|
+
import { ErrorSchema, FormValidation } from './types.js';
|
|
2
2
|
/** Unwraps the `errorHandler` structure into the associated `ErrorSchema`, stripping the `addError()` functions from it
|
|
3
3
|
*
|
|
4
4
|
* @param errorHandler - The `FormValidation` error handling structure
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import isPlainObject from 'lodash/isPlainObject';
|
|
1
|
+
import isPlainObject from 'lodash-es/isPlainObject.js';
|
|
2
2
|
/** Unwraps the `errorHandler` structure into the associated `ErrorSchema`, stripping the `addError()` functions from it
|
|
3
3
|
*
|
|
4
4
|
* @param errorHandler - The `FormValidation` error handling structure
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unwrapErrorHandler.js","sourceRoot":"","sources":["../src/unwrapErrorHandler.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,sBAAsB,CAAC;AAIjD;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAU,YAA+B;IACjF,OAAO,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACnD,IAAI,GAAG,KAAK,UAAU,EAAE;
|
|
1
|
+
{"version":3,"file":"unwrapErrorHandler.js","sourceRoot":"","sources":["../src/unwrapErrorHandler.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,sBAAsB,CAAC;AAIjD;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAU,YAA+B;IACjF,OAAO,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACnD,IAAI,GAAG,KAAK,UAAU,EAAE,CAAC;YACvB,OAAO,GAAG,CAAC;QACb,CAAC;aAAM,CAAC;YACN,MAAM,WAAW,GAAI,YAAkC,CAAC,GAAG,CAAC,CAAC;YAC7D,IAAI,aAAa,CAAC,WAAW,CAAC,EAAE,CAAC;gBAC/B,OAAO;oBACL,GAAG,GAAG;oBACN,CAAC,GAAG,CAAC,EAAE,kBAAkB,CAAC,WAAW,CAAC;iBACvC,CAAC;YACJ,CAAC;YACD,OAAO,EAAE,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,CAAC;QACxC,CAAC;IACH,CAAC,EAAE,EAAoB,CAAC,CAAC;AAC3B,CAAC"}
|
package/lib/utcToLocal.js
CHANGED