@rjsf/core 6.0.0-beta.2 → 6.0.0-beta.21
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/core.umd.js +705 -471
- package/dist/{index.js → index.cjs} +1094 -844
- package/dist/index.cjs.map +7 -0
- package/dist/index.esm.js +1053 -774
- package/dist/index.esm.js.map +4 -4
- package/lib/components/Form.d.ts +88 -23
- package/lib/components/Form.d.ts.map +1 -1
- package/lib/components/Form.js +213 -151
- package/lib/components/fields/ArrayField.d.ts +17 -7
- package/lib/components/fields/ArrayField.d.ts.map +1 -1
- package/lib/components/fields/ArrayField.js +116 -70
- package/lib/components/fields/BooleanField.d.ts.map +1 -1
- package/lib/components/fields/BooleanField.js +7 -2
- package/lib/components/fields/LayoutGridField.d.ts +27 -25
- package/lib/components/fields/LayoutGridField.d.ts.map +1 -1
- package/lib/components/fields/LayoutGridField.js +83 -59
- package/lib/components/fields/LayoutHeaderField.d.ts +1 -1
- package/lib/components/fields/LayoutHeaderField.js +3 -3
- package/lib/components/fields/LayoutMultiSchemaField.js +6 -5
- package/lib/components/fields/MultiSchemaField.d.ts.map +1 -1
- package/lib/components/fields/MultiSchemaField.js +13 -9
- package/lib/components/fields/NullField.js +3 -3
- package/lib/components/fields/NumberField.d.ts.map +1 -1
- package/lib/components/fields/NumberField.js +3 -3
- package/lib/components/fields/ObjectField.d.ts +3 -3
- package/lib/components/fields/ObjectField.d.ts.map +1 -1
- package/lib/components/fields/ObjectField.js +34 -34
- package/lib/components/fields/OptionalDataControlsField.d.ts +8 -0
- package/lib/components/fields/OptionalDataControlsField.d.ts.map +1 -0
- package/lib/components/fields/OptionalDataControlsField.js +43 -0
- package/lib/components/fields/SchemaField.d.ts.map +1 -1
- package/lib/components/fields/SchemaField.js +17 -17
- package/lib/components/fields/StringField.d.ts.map +1 -1
- package/lib/components/fields/StringField.js +7 -2
- package/lib/components/fields/index.d.ts.map +1 -1
- package/lib/components/fields/index.js +2 -0
- package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldDescriptionTemplate.js +3 -3
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.js +2 -2
- package/lib/components/templates/ArrayFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldTemplate.js +4 -3
- package/lib/components/templates/ArrayFieldTitleTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldTitleTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldTitleTemplate.js +3 -3
- package/lib/components/templates/ButtonTemplates/AddButton.d.ts +1 -1
- package/lib/components/templates/ButtonTemplates/AddButton.d.ts.map +1 -1
- package/lib/components/templates/ButtonTemplates/AddButton.js +2 -2
- package/lib/components/templates/FieldErrorTemplate.js +2 -2
- package/lib/components/templates/FieldHelpTemplate.js +2 -2
- package/lib/components/templates/MultiSchemaFieldTemplate.d.ts +8 -0
- package/lib/components/templates/MultiSchemaFieldTemplate.d.ts.map +1 -0
- package/lib/components/templates/MultiSchemaFieldTemplate.js +10 -0
- package/lib/components/templates/ObjectFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/ObjectFieldTemplate.js +3 -2
- package/lib/components/templates/OptionalDataControlsTemplate.d.ts +11 -0
- package/lib/components/templates/OptionalDataControlsTemplate.d.ts.map +1 -0
- package/lib/components/templates/OptionalDataControlsTemplate.js +20 -0
- package/lib/components/templates/TitleField.d.ts.map +1 -1
- package/lib/components/templates/TitleField.js +2 -2
- package/lib/components/templates/UnsupportedField.js +3 -3
- package/lib/components/templates/index.d.ts.map +1 -1
- package/lib/components/templates/index.js +4 -0
- package/lib/components/widgets/AltDateWidget.d.ts.map +1 -1
- package/lib/components/widgets/AltDateWidget.js +15 -18
- package/lib/components/widgets/CheckboxesWidget.js +2 -2
- package/lib/getDefaultRegistry.d.ts.map +1 -1
- package/lib/getDefaultRegistry.js +2 -1
- package/lib/getTestRegistry.d.ts +5 -0
- package/lib/getTestRegistry.d.ts.map +1 -0
- package/lib/getTestRegistry.js +19 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +18 -19
- package/src/components/Form.tsx +306 -177
- package/src/components/fields/ArrayField.tsx +127 -80
- package/src/components/fields/BooleanField.tsx +12 -3
- package/src/components/fields/LayoutGridField.tsx +95 -88
- package/src/components/fields/LayoutHeaderField.tsx +3 -3
- package/src/components/fields/LayoutMultiSchemaField.tsx +5 -5
- package/src/components/fields/MultiSchemaField.tsx +51 -35
- package/src/components/fields/NullField.tsx +3 -3
- package/src/components/fields/NumberField.tsx +11 -3
- package/src/components/fields/ObjectField.tsx +47 -53
- package/src/components/fields/OptionalDataControlsField.tsx +84 -0
- package/src/components/fields/SchemaField.tsx +24 -30
- package/src/components/fields/StringField.tsx +12 -3
- package/src/components/fields/index.ts +2 -0
- package/src/components/templates/ArrayFieldDescriptionTemplate.tsx +3 -3
- package/src/components/templates/ArrayFieldItemButtonsTemplate.tsx +5 -5
- package/src/components/templates/ArrayFieldTemplate.tsx +9 -5
- package/src/components/templates/ArrayFieldTitleTemplate.tsx +4 -3
- package/src/components/templates/BaseInputTemplate.tsx +3 -3
- package/src/components/templates/ButtonTemplates/AddButton.tsx +2 -0
- package/src/components/templates/FieldErrorTemplate.tsx +2 -2
- package/src/components/templates/FieldHelpTemplate.tsx +2 -2
- package/src/components/templates/MultiSchemaFieldTemplate.tsx +20 -0
- package/src/components/templates/ObjectFieldTemplate.tsx +10 -5
- package/src/components/templates/OptionalDataControlsTemplate.tsx +43 -0
- package/src/components/templates/TitleField.tsx +6 -1
- package/src/components/templates/UnsupportedField.tsx +3 -3
- package/src/components/templates/WrapIfAdditionalTemplate.tsx +1 -1
- package/src/components/templates/index.ts +4 -0
- package/src/components/widgets/AltDateWidget.tsx +21 -23
- package/src/components/widgets/CheckboxWidget.tsx +2 -2
- package/src/components/widgets/CheckboxesWidget.tsx +3 -3
- package/src/components/widgets/RadioWidget.tsx +1 -1
- package/src/components/widgets/SelectWidget.tsx +1 -1
- package/src/components/widgets/TextareaWidget.tsx +1 -1
- package/src/getDefaultRegistry.ts +10 -1
- package/src/getTestRegistry.tsx +34 -0
- package/src/index.ts +2 -1
- package/dist/index.js.map +0 -7
package/lib/components/Form.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Component, createRef } from 'react';
|
|
3
|
-
import { createSchemaUtils, deepEquals, getChangedFields, getTemplate, getUiOptions, isObject, mergeObjects, NAME_KEY, RJSF_ADDITIONAL_PROPERTIES_FLAG, shouldRender, SUBMIT_BTN_OPTIONS_KEY, toErrorList, UI_GLOBAL_OPTIONS_KEY, UI_OPTIONS_KEY, validationDataMerge,
|
|
4
|
-
import
|
|
3
|
+
import { createSchemaUtils, deepEquals, ErrorSchemaBuilder, getChangedFields, getTemplate, getUiOptions, isObject, mergeObjects, NAME_KEY, RJSF_ADDITIONAL_PROPERTIES_FLAG, shouldRender, SUBMIT_BTN_OPTIONS_KEY, toErrorList, toFieldPathId, UI_GLOBAL_OPTIONS_KEY, UI_OPTIONS_KEY, validationDataMerge, DEFAULT_ID_SEPARATOR, DEFAULT_ID_PREFIX, ERRORS_KEY, } from '@rjsf/utils';
|
|
4
|
+
import _cloneDeep from 'lodash-es/cloneDeep.js';
|
|
5
5
|
import _get from 'lodash-es/get.js';
|
|
6
6
|
import _isEmpty from 'lodash-es/isEmpty.js';
|
|
7
|
-
import _isNil from 'lodash-es/isNil.js';
|
|
8
7
|
import _pick from 'lodash-es/pick.js';
|
|
8
|
+
import _set from 'lodash-es/set.js';
|
|
9
9
|
import _toPath from 'lodash-es/toPath.js';
|
|
10
10
|
import getDefaultRegistry from '../getDefaultRegistry.js';
|
|
11
11
|
/** The `Form` component renders the outer form and all the fields defined in the `schema` */
|
|
@@ -14,6 +14,9 @@ export default class Form extends Component {
|
|
|
14
14
|
* provide any possible type here
|
|
15
15
|
*/
|
|
16
16
|
formElement;
|
|
17
|
+
/** The list of pending changes
|
|
18
|
+
*/
|
|
19
|
+
pendingChanges = [];
|
|
17
20
|
/** Constructs the `Form` from the `props`. Will setup the initial state from the props. It will also call the
|
|
18
21
|
* `onChange` handler if the initially provided `formData` is modified to add missing default values as part of the
|
|
19
22
|
* state construction.
|
|
@@ -51,16 +54,23 @@ export default class Form extends Component {
|
|
|
51
54
|
*/
|
|
52
55
|
getSnapshotBeforeUpdate(prevProps, prevState) {
|
|
53
56
|
if (!deepEquals(this.props, prevProps)) {
|
|
57
|
+
// Compare the previous props formData against the current props formData
|
|
54
58
|
const formDataChangedFields = getChangedFields(this.props.formData, prevProps.formData);
|
|
59
|
+
// Compare the current props formData against the current state's formData to determine if the new props were the
|
|
60
|
+
// result of the onChange from the existing state formData
|
|
61
|
+
const stateDataChangedFields = getChangedFields(this.props.formData, this.state.formData);
|
|
55
62
|
const isSchemaChanged = !deepEquals(prevProps.schema, this.props.schema);
|
|
56
63
|
// When formData is not an object, getChangedFields returns an empty array.
|
|
57
64
|
// In this case, deepEquals is most needed to check again.
|
|
58
65
|
const isFormDataChanged = formDataChangedFields.length > 0 || !deepEquals(prevProps.formData, this.props.formData);
|
|
66
|
+
const isStateDataChanged = stateDataChangedFields.length > 0 || !deepEquals(this.state.formData, this.props.formData);
|
|
59
67
|
const nextState = this.getStateFromProps(this.props, this.props.formData,
|
|
60
68
|
// If the `schema` has changed, we need to update the retrieved schema.
|
|
61
69
|
// Or if the `formData` changes, for example in the case of a schema with dependencies that need to
|
|
62
70
|
// match one of the subSchemas, the retrieved schema must be updated.
|
|
63
|
-
isSchemaChanged || isFormDataChanged ? undefined : this.state.retrievedSchema, isSchemaChanged, formDataChangedFields
|
|
71
|
+
isSchemaChanged || isFormDataChanged ? undefined : this.state.retrievedSchema, isSchemaChanged, formDataChangedFields,
|
|
72
|
+
// Skip live validation for this request if no form data has changed from the last state
|
|
73
|
+
!isStateDataChanged);
|
|
64
74
|
const shouldUpdate = !deepEquals(nextState, prevState);
|
|
65
75
|
return { nextState, shouldUpdate };
|
|
66
76
|
}
|
|
@@ -98,16 +108,17 @@ export default class Form extends Component {
|
|
|
98
108
|
* @param retrievedSchema - An expanded schema, if not provided, it will be retrieved from the `schema` and `formData`.
|
|
99
109
|
* @param isSchemaChanged - A flag indicating whether the schema has changed.
|
|
100
110
|
* @param formDataChangedFields - The changed fields of `formData`
|
|
111
|
+
* @param skipLiveValidate - Optional flag, if true, means that we are not running live validation
|
|
101
112
|
* @returns - The new state for the `Form`
|
|
102
113
|
*/
|
|
103
|
-
getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false, formDataChangedFields = []) {
|
|
114
|
+
getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false, formDataChangedFields = [], skipLiveValidate = false) {
|
|
104
115
|
const state = this.state || {};
|
|
105
116
|
const schema = 'schema' in props ? props.schema : this.props.schema;
|
|
117
|
+
const validator = 'validator' in props ? props.validator : this.props.validator;
|
|
106
118
|
const uiSchema = ('uiSchema' in props ? props.uiSchema : this.props.uiSchema) || {};
|
|
107
119
|
const edit = typeof inputFormData !== 'undefined';
|
|
108
120
|
const liveValidate = 'liveValidate' in props ? props.liveValidate : this.props.liveValidate;
|
|
109
121
|
const mustValidate = edit && !props.noValidate && liveValidate;
|
|
110
|
-
const rootSchema = schema;
|
|
111
122
|
const experimental_defaultFormStateBehavior = 'experimental_defaultFormStateBehavior' in props
|
|
112
123
|
? props.experimental_defaultFormStateBehavior
|
|
113
124
|
: this.props.experimental_defaultFormStateBehavior;
|
|
@@ -116,11 +127,12 @@ export default class Form extends Component {
|
|
|
116
127
|
: this.props.experimental_customMergeAllOf;
|
|
117
128
|
let schemaUtils = state.schemaUtils;
|
|
118
129
|
if (!schemaUtils ||
|
|
119
|
-
schemaUtils.doesSchemaUtilsDiffer(
|
|
120
|
-
schemaUtils = createSchemaUtils(
|
|
130
|
+
schemaUtils.doesSchemaUtilsDiffer(validator, schema, experimental_defaultFormStateBehavior, experimental_customMergeAllOf)) {
|
|
131
|
+
schemaUtils = createSchemaUtils(validator, schema, experimental_defaultFormStateBehavior, experimental_customMergeAllOf);
|
|
121
132
|
}
|
|
122
|
-
const
|
|
123
|
-
const
|
|
133
|
+
const rootSchema = schemaUtils.getRootSchema();
|
|
134
|
+
const formData = schemaUtils.getDefaultFormState(rootSchema, inputFormData, false, state.initialDefaultsGenerated);
|
|
135
|
+
const _retrievedSchema = this.updateRetrievedSchema(retrievedSchema ?? schemaUtils.retrieveSchema(rootSchema, formData));
|
|
124
136
|
const getCurrentErrors = () => {
|
|
125
137
|
// If the `props.noValidate` option is set or the schema has changed, we reset the error state.
|
|
126
138
|
if (props.noValidate || isSchemaChanged) {
|
|
@@ -141,43 +153,39 @@ export default class Form extends Component {
|
|
|
141
153
|
let errorSchema;
|
|
142
154
|
let schemaValidationErrors = state.schemaValidationErrors;
|
|
143
155
|
let schemaValidationErrorSchema = state.schemaValidationErrorSchema;
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
156
|
+
// If we are skipping live validate, it means that the state has already been updated with live validation errors
|
|
157
|
+
if (mustValidate && !skipLiveValidate) {
|
|
158
|
+
const liveValidation = this.liveValidate(rootSchema, schemaUtils, state.errorSchema, formData, undefined, state.customErrors, retrievedSchema,
|
|
147
159
|
// If retrievedSchema is undefined which means the schema or formData has changed, we do not merge state.
|
|
148
|
-
// Else in the case where it hasn't changed,
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
schemaValidationErrors = errors;
|
|
156
|
-
schemaValidationErrorSchema = errorSchema;
|
|
160
|
+
// Else in the case where it hasn't changed,
|
|
161
|
+
retrievedSchema !== undefined);
|
|
162
|
+
errors = liveValidation.errors;
|
|
163
|
+
errorSchema = liveValidation.errorSchema;
|
|
164
|
+
schemaValidationErrors = liveValidation.schemaValidationErrors;
|
|
165
|
+
schemaValidationErrorSchema = liveValidation.schemaValidationErrorSchema;
|
|
157
166
|
}
|
|
158
167
|
else {
|
|
159
168
|
const currentErrors = getCurrentErrors();
|
|
160
169
|
errors = currentErrors.errors;
|
|
161
170
|
errorSchema = currentErrors.errorSchema;
|
|
162
|
-
if
|
|
171
|
+
// We only update the error schema for changed fields if mustValidate is false
|
|
172
|
+
if (formDataChangedFields.length > 0 && !mustValidate) {
|
|
163
173
|
const newErrorSchema = formDataChangedFields.reduce((acc, key) => {
|
|
164
174
|
acc[key] = undefined;
|
|
165
175
|
return acc;
|
|
166
176
|
}, {});
|
|
167
177
|
errorSchema = schemaValidationErrorSchema = mergeObjects(currentErrors.errorSchema, newErrorSchema, 'preventDuplicates');
|
|
168
178
|
}
|
|
179
|
+
const mergedErrors = this.mergeErrors({ errorSchema, errors }, props.extraErrors, state.customErrors);
|
|
180
|
+
errors = mergedErrors.errors;
|
|
181
|
+
errorSchema = mergedErrors.errorSchema;
|
|
169
182
|
}
|
|
170
|
-
|
|
171
|
-
const merged = validationDataMerge({ errorSchema, errors }, props.extraErrors);
|
|
172
|
-
errorSchema = merged.errorSchema;
|
|
173
|
-
errors = merged.errors;
|
|
174
|
-
}
|
|
175
|
-
const idSchema = schemaUtils.toIdSchema(_retrievedSchema, uiSchema['ui:rootFieldId'], formData, props.idPrefix, props.idSeparator);
|
|
183
|
+
const fieldPathId = toFieldPathId('', this.getGlobalFormOptions(this.props));
|
|
176
184
|
const nextState = {
|
|
177
185
|
schemaUtils,
|
|
178
|
-
schema,
|
|
186
|
+
schema: rootSchema,
|
|
179
187
|
uiSchema,
|
|
180
|
-
|
|
188
|
+
fieldPathId,
|
|
181
189
|
formData,
|
|
182
190
|
edit,
|
|
183
191
|
errors,
|
|
@@ -185,6 +193,7 @@ export default class Form extends Component {
|
|
|
185
193
|
schemaValidationErrors,
|
|
186
194
|
schemaValidationErrorSchema,
|
|
187
195
|
retrievedSchema: _retrievedSchema,
|
|
196
|
+
initialDefaultsGenerated: true,
|
|
188
197
|
};
|
|
189
198
|
return nextState;
|
|
190
199
|
}
|
|
@@ -195,31 +204,18 @@ export default class Form extends Component {
|
|
|
195
204
|
* @returns - True if the component should be updated, false otherwise
|
|
196
205
|
*/
|
|
197
206
|
shouldComponentUpdate(nextProps, nextState) {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
/** Gets the previously raised customValidate errors.
|
|
201
|
-
*
|
|
202
|
-
* @returns the previous customValidate errors
|
|
203
|
-
*/
|
|
204
|
-
getPreviousCustomValidateErrors() {
|
|
205
|
-
const { customValidate, uiSchema } = this.props;
|
|
206
|
-
const prevFormData = this.state.formData;
|
|
207
|
-
let customValidateErrors = {};
|
|
208
|
-
if (typeof customValidate === 'function') {
|
|
209
|
-
const errorHandler = customValidate(prevFormData, createErrorHandler(prevFormData), uiSchema);
|
|
210
|
-
const userErrorSchema = unwrapErrorHandler(errorHandler);
|
|
211
|
-
customValidateErrors = userErrorSchema;
|
|
212
|
-
}
|
|
213
|
-
return customValidateErrors;
|
|
207
|
+
const { experimental_componentUpdateStrategy = 'customDeep' } = this.props;
|
|
208
|
+
return shouldRender(this, nextProps, nextState, experimental_componentUpdateStrategy);
|
|
214
209
|
}
|
|
215
210
|
/** Validates the `formData` against the `schema` using the `altSchemaUtils` (if provided otherwise it uses the
|
|
216
211
|
* `schemaUtils` in the state), returning the results.
|
|
217
212
|
*
|
|
218
213
|
* @param formData - The new form data to validate
|
|
219
214
|
* @param schema - The schema used to validate against
|
|
220
|
-
* @param altSchemaUtils - The alternate schemaUtils to use for validation
|
|
215
|
+
* @param [altSchemaUtils] - The alternate schemaUtils to use for validation
|
|
216
|
+
* @param [retrievedSchema] - An optionally retrieved schema for per
|
|
221
217
|
*/
|
|
222
|
-
validate(formData, schema = this.
|
|
218
|
+
validate(formData, schema = this.state.schema, altSchemaUtils, retrievedSchema) {
|
|
223
219
|
const schemaUtils = altSchemaUtils ? altSchemaUtils : this.state.schemaUtils;
|
|
224
220
|
const { customValidate, transformErrors, uiSchema } = this.props;
|
|
225
221
|
const resolvedSchema = retrievedSchema ?? schemaUtils.retrieveSchema(schema, formData);
|
|
@@ -230,14 +226,63 @@ export default class Form extends Component {
|
|
|
230
226
|
/** Renders any errors contained in the `state` in using the `ErrorList`, if not disabled by `showErrorList`. */
|
|
231
227
|
renderErrors(registry) {
|
|
232
228
|
const { errors, errorSchema, schema, uiSchema } = this.state;
|
|
233
|
-
const { formContext } = this.props;
|
|
234
229
|
const options = getUiOptions(uiSchema);
|
|
235
230
|
const ErrorListTemplate = getTemplate('ErrorListTemplate', registry, options);
|
|
236
231
|
if (errors && errors.length) {
|
|
237
|
-
return (_jsx(ErrorListTemplate, { errors: errors, errorSchema: errorSchema || {}, schema: schema, uiSchema: uiSchema,
|
|
232
|
+
return (_jsx(ErrorListTemplate, { errors: errors, errorSchema: errorSchema || {}, schema: schema, uiSchema: uiSchema, registry: registry }));
|
|
238
233
|
}
|
|
239
234
|
return null;
|
|
240
235
|
}
|
|
236
|
+
/** Merges any `extraErrors` or `customErrors` into the given `schemaValidation` object, returning the result
|
|
237
|
+
*
|
|
238
|
+
* @param schemaValidation - The `ValidationData` object into which additional errors are merged
|
|
239
|
+
* @param [extraErrors] - The extra errors from the props
|
|
240
|
+
* @param [customErrors] - The customErrors from custom components
|
|
241
|
+
* @return - The `extraErrors` and `customErrors` merged into the `schemaValidation`
|
|
242
|
+
* @private
|
|
243
|
+
*/
|
|
244
|
+
mergeErrors(schemaValidation, extraErrors, customErrors) {
|
|
245
|
+
let errorSchema = schemaValidation.errorSchema;
|
|
246
|
+
let errors = schemaValidation.errors;
|
|
247
|
+
if (extraErrors) {
|
|
248
|
+
const merged = validationDataMerge(schemaValidation, extraErrors);
|
|
249
|
+
errorSchema = merged.errorSchema;
|
|
250
|
+
errors = merged.errors;
|
|
251
|
+
}
|
|
252
|
+
if (customErrors) {
|
|
253
|
+
const merged = validationDataMerge(schemaValidation, customErrors.ErrorSchema, true);
|
|
254
|
+
errorSchema = merged.errorSchema;
|
|
255
|
+
errors = merged.errors;
|
|
256
|
+
}
|
|
257
|
+
return { errors, errorSchema };
|
|
258
|
+
}
|
|
259
|
+
/** Performs live validation and then updates and returns the errors and error schemas by potentially merging in
|
|
260
|
+
* `extraErrors` and `customErrors`.
|
|
261
|
+
*
|
|
262
|
+
* @param rootSchema - The `rootSchema` from the state
|
|
263
|
+
* @param schemaUtils - The `SchemaUtilsType` from the state
|
|
264
|
+
* @param originalErrorSchema - The original `ErrorSchema` from the state
|
|
265
|
+
* @param [formData] - The new form data to validate
|
|
266
|
+
* @param [extraErrors] - The extra errors from the props
|
|
267
|
+
* @param [customErrors] - The customErrors from custom components
|
|
268
|
+
* @param [retrievedSchema] - An expanded schema, if not provided, it will be retrieved from the `schema` and `formData`
|
|
269
|
+
* @param [mergeIntoOriginalErrorSchema=false] - Optional flag indicating whether we merge into original schema
|
|
270
|
+
* @returns - An object containing `errorSchema`, `errors`, `schemaValidationErrors` and `schemaValidationErrorSchema`
|
|
271
|
+
* @private
|
|
272
|
+
*/
|
|
273
|
+
liveValidate(rootSchema, schemaUtils, originalErrorSchema, formData, extraErrors, customErrors, retrievedSchema, mergeIntoOriginalErrorSchema = false) {
|
|
274
|
+
const schemaValidation = this.validate(formData, rootSchema, schemaUtils, retrievedSchema);
|
|
275
|
+
const errors = schemaValidation.errors;
|
|
276
|
+
let errorSchema = schemaValidation.errorSchema;
|
|
277
|
+
// We merge 'originalErrorSchema' with 'schemaValidation.errorSchema.'; This done to display the raised field error.
|
|
278
|
+
if (mergeIntoOriginalErrorSchema) {
|
|
279
|
+
errorSchema = mergeObjects(originalErrorSchema, schemaValidation.errorSchema, 'preventDuplicates');
|
|
280
|
+
}
|
|
281
|
+
const schemaValidationErrors = errors;
|
|
282
|
+
const schemaValidationErrorSchema = errorSchema;
|
|
283
|
+
const mergedErrors = this.mergeErrors({ errorSchema, errors }, extraErrors, customErrors);
|
|
284
|
+
return { ...mergedErrors, schemaValidationErrors, schemaValidationErrorSchema };
|
|
285
|
+
}
|
|
241
286
|
/** Returns the `formData` with only the elements specified in the `fields` list
|
|
242
287
|
*
|
|
243
288
|
* @param formData - The data for the `Form`
|
|
@@ -261,26 +306,28 @@ export default class Form extends Component {
|
|
|
261
306
|
* @param [formData] - The form data to use while checking for empty objects/arrays
|
|
262
307
|
*/
|
|
263
308
|
getFieldNames = (pathSchema, formData) => {
|
|
309
|
+
const formValueHasData = (value, isLeaf) => typeof value !== 'object' || _isEmpty(value) || (isLeaf && !_isEmpty(value));
|
|
264
310
|
const getAllPaths = (_obj, acc = [], paths = [[]]) => {
|
|
265
|
-
Object.keys(_obj)
|
|
266
|
-
|
|
311
|
+
const objKeys = Object.keys(_obj);
|
|
312
|
+
objKeys.forEach((key) => {
|
|
313
|
+
const data = _obj[key];
|
|
314
|
+
if (typeof data === 'object') {
|
|
267
315
|
const newPaths = paths.map((path) => [...path, key]);
|
|
268
316
|
// If an object is marked with additionalProperties, all its keys are valid
|
|
269
|
-
if (
|
|
270
|
-
acc.push(
|
|
317
|
+
if (data[RJSF_ADDITIONAL_PROPERTIES_FLAG] && data[NAME_KEY] !== '') {
|
|
318
|
+
acc.push(data[NAME_KEY]);
|
|
271
319
|
}
|
|
272
320
|
else {
|
|
273
|
-
getAllPaths(
|
|
321
|
+
getAllPaths(data, acc, newPaths);
|
|
274
322
|
}
|
|
275
323
|
}
|
|
276
|
-
else if (key === NAME_KEY &&
|
|
324
|
+
else if (key === NAME_KEY && data !== '') {
|
|
277
325
|
paths.forEach((path) => {
|
|
278
326
|
const formValue = _get(formData, path);
|
|
279
|
-
|
|
280
|
-
// or an empty object/array
|
|
281
|
-
if (
|
|
282
|
-
|
|
283
|
-
(Array.isArray(formValue) && formValue.every((val) => typeof val !== 'object'))) {
|
|
327
|
+
const isLeaf = objKeys.length === 1;
|
|
328
|
+
// adds path to fieldNames if it points to a value or an empty object/array which is not a leaf
|
|
329
|
+
if (formValueHasData(formValue, isLeaf) ||
|
|
330
|
+
(Array.isArray(formValue) && formValue.every((val) => formValueHasData(val, isLeaf)))) {
|
|
284
331
|
acc.push(path);
|
|
285
332
|
}
|
|
286
333
|
});
|
|
@@ -300,68 +347,51 @@ export default class Form extends Component {
|
|
|
300
347
|
const retrievedSchema = schemaUtils.retrieveSchema(schema, formData);
|
|
301
348
|
const pathSchema = schemaUtils.toPathSchema(retrievedSchema, '', formData);
|
|
302
349
|
const fieldNames = this.getFieldNames(pathSchema, formData);
|
|
303
|
-
|
|
304
|
-
return newFormData;
|
|
350
|
+
return this.getUsedFormData(formData, fieldNames);
|
|
305
351
|
};
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
const { retrievedSchema, schemaUtils } = this.state;
|
|
309
|
-
const _retrievedSchema = resolvedSchema ?? retrievedSchema;
|
|
310
|
-
const pathSchema = schemaUtils.toPathSchema(_retrievedSchema, '', formData);
|
|
311
|
-
const fieldNames = this.getFieldNames(pathSchema, formData);
|
|
312
|
-
const filteredErrors = _pick(schemaErrors, fieldNames);
|
|
313
|
-
// If the root schema is of a primitive type, do not filter out the __errors
|
|
314
|
-
if (resolvedSchema?.type !== 'object' && resolvedSchema?.type !== 'array') {
|
|
315
|
-
filteredErrors.__errors = schemaErrors.__errors;
|
|
316
|
-
}
|
|
317
|
-
const prevCustomValidateErrors = this.getPreviousCustomValidateErrors();
|
|
318
|
-
// Filtering out the previous raised customValidate errors so that they are cleared when no longer valid.
|
|
319
|
-
const filterPreviousCustomErrors = (errors = [], prevCustomErrors) => {
|
|
320
|
-
if (errors.length === 0) {
|
|
321
|
-
return errors;
|
|
322
|
-
}
|
|
323
|
-
return errors.filter((error) => {
|
|
324
|
-
return !prevCustomErrors.includes(error);
|
|
325
|
-
});
|
|
326
|
-
};
|
|
327
|
-
// Removing undefined, null and empty errors.
|
|
328
|
-
const filterNilOrEmptyErrors = (errors, previousCustomValidateErrors = {}) => {
|
|
329
|
-
_forEach(errors, (errorAtKey, errorKey) => {
|
|
330
|
-
const prevCustomValidateErrorAtKey = previousCustomValidateErrors[errorKey];
|
|
331
|
-
if (_isNil(errorAtKey) || (Array.isArray(errorAtKey) && errorAtKey.length === 0)) {
|
|
332
|
-
delete errors[errorKey];
|
|
333
|
-
}
|
|
334
|
-
else if (isObject(errorAtKey) &&
|
|
335
|
-
isObject(prevCustomValidateErrorAtKey) &&
|
|
336
|
-
Array.isArray(prevCustomValidateErrorAtKey?.__errors)) {
|
|
337
|
-
// if previous customValidate error is an object and has __errors array, filter out the errors previous customValidate errors.
|
|
338
|
-
errors[errorKey] = filterPreviousCustomErrors(errorAtKey.__errors, prevCustomValidateErrorAtKey.__errors);
|
|
339
|
-
}
|
|
340
|
-
else if (typeof errorAtKey === 'object' && !Array.isArray(errorAtKey.__errors)) {
|
|
341
|
-
filterNilOrEmptyErrors(errorAtKey, previousCustomValidateErrors[errorKey]);
|
|
342
|
-
}
|
|
343
|
-
});
|
|
344
|
-
return errors;
|
|
345
|
-
};
|
|
346
|
-
return filterNilOrEmptyErrors(filteredErrors, prevCustomValidateErrors);
|
|
347
|
-
}
|
|
348
|
-
/** Function to handle changes made to a field in the `Form`. This handler receives an entirely new copy of the
|
|
349
|
-
* `formData` along with a new `ErrorSchema`. It will first update the `formData` with any missing default fields and
|
|
350
|
-
* then, if `omitExtraData` and `liveOmit` are turned on, the `formData` will be filtered to remove any extra data not
|
|
351
|
-
* in a form field. Then, the resulting formData will be validated if required. The state will be updated with the new
|
|
352
|
-
* updated (potentially filtered) `formData`, any errors that resulted from validation. Finally the `onChange`
|
|
353
|
-
* callback will be called if specified with the updated state.
|
|
352
|
+
/** Pushes the given change information into the `pendingChanges` array and then calls `processPendingChanges()` if
|
|
353
|
+
* the array only contains a single pending change.
|
|
354
354
|
*
|
|
355
|
-
* @param
|
|
356
|
-
* @param
|
|
357
|
-
* @param
|
|
355
|
+
* @param newValue - The new form data from a change to a field
|
|
356
|
+
* @param path - The path to the change into which to set the formData
|
|
357
|
+
* @param [newErrorSchema] - The new `ErrorSchema` based on the field change
|
|
358
|
+
* @param [id] - The id of the field that caused the change
|
|
358
359
|
*/
|
|
359
|
-
onChange = (
|
|
360
|
+
onChange = (newValue, path, newErrorSchema, id) => {
|
|
361
|
+
this.pendingChanges.push({ newValue, path, newErrorSchema, id });
|
|
362
|
+
if (this.pendingChanges.length === 1) {
|
|
363
|
+
this.processPendingChange();
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
/** Function to handle changes made to a field in the `Form`. This handler gets the first change from the
|
|
367
|
+
* `pendingChanges` list, containing the `newValue` for the `formData` and the `path` at which the `newValue` is to be
|
|
368
|
+
* updated, along with a new, optional `ErrorSchema` for that same `path` and potentially the `id` of the field being
|
|
369
|
+
* changed. It will first update the `formData` with any missing default fields and then, if `omitExtraData` and
|
|
370
|
+
* `liveOmit` are turned on, the `formData` will be filtered to remove any extra data not in a form field. Then, the
|
|
371
|
+
* resulting `formData` will be validated if required. The state will be updated with the new updated (potentially
|
|
372
|
+
* filtered) `formData`, any errors that resulted from validation. Finally the `onChange` callback will be called, if
|
|
373
|
+
* specified, with the updated state and the `processPendingChange()` function is called again.
|
|
374
|
+
*/
|
|
375
|
+
processPendingChange() {
|
|
376
|
+
if (this.pendingChanges.length === 0) {
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
const { newValue, path, id } = this.pendingChanges[0];
|
|
380
|
+
const { newErrorSchema } = this.pendingChanges[0];
|
|
360
381
|
const { extraErrors, omitExtraData, liveOmit, noValidate, liveValidate, onChange } = this.props;
|
|
361
|
-
const { schemaUtils, schema } = this.state;
|
|
382
|
+
const { formData: oldFormData, schemaUtils, schema, fieldPathId, schemaValidationErrorSchema, errors } = this.state;
|
|
383
|
+
let { customErrors, errorSchema: originalErrorSchema } = this.state;
|
|
384
|
+
const rootPathId = fieldPathId.path[0] || '';
|
|
385
|
+
const isRootPath = !path || path.length === 0 || (path.length === 1 && path[0] === rootPathId);
|
|
362
386
|
let retrievedSchema = this.state.retrievedSchema;
|
|
387
|
+
let formData = isRootPath ? newValue : _cloneDeep(oldFormData);
|
|
363
388
|
if (isObject(formData) || Array.isArray(formData)) {
|
|
364
|
-
|
|
389
|
+
if (!isRootPath) {
|
|
390
|
+
// If the newValue is not on the root path, then set it into the form data
|
|
391
|
+
_set(formData, path, newValue);
|
|
392
|
+
}
|
|
393
|
+
// Pass true to skip live validation in `getStateFromProps()` since we will do it a bit later
|
|
394
|
+
const newState = this.getStateFromProps(this.props, formData, undefined, undefined, undefined, true);
|
|
365
395
|
formData = newState.formData;
|
|
366
396
|
retrievedSchema = newState.retrievedSchema;
|
|
367
397
|
}
|
|
@@ -374,42 +404,59 @@ export default class Form extends Component {
|
|
|
374
404
|
formData: newFormData,
|
|
375
405
|
};
|
|
376
406
|
}
|
|
377
|
-
if (
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
407
|
+
if (newErrorSchema) {
|
|
408
|
+
// First check to see if there is an existing validation error on this path...
|
|
409
|
+
// @ts-expect-error TS2590, because getting from the error schema is confusing TS
|
|
410
|
+
const oldValidationError = !isRootPath ? _get(schemaValidationErrorSchema, path) : schemaValidationErrorSchema;
|
|
411
|
+
// If there is an old validation error for this path, assume we are updating it directly
|
|
412
|
+
if (!_isEmpty(oldValidationError)) {
|
|
413
|
+
// Update the originalErrorSchema "in place" or replace it if it is the root
|
|
414
|
+
if (!isRootPath) {
|
|
415
|
+
_set(originalErrorSchema, path, newErrorSchema);
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
originalErrorSchema = newErrorSchema;
|
|
419
|
+
}
|
|
387
420
|
}
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
421
|
+
else {
|
|
422
|
+
if (!customErrors) {
|
|
423
|
+
customErrors = new ErrorSchemaBuilder();
|
|
424
|
+
}
|
|
425
|
+
if (isRootPath) {
|
|
426
|
+
customErrors.setErrors(_get(newErrorSchema, ERRORS_KEY, ''));
|
|
427
|
+
}
|
|
428
|
+
else {
|
|
429
|
+
_set(customErrors.ErrorSchema, path, newErrorSchema);
|
|
430
|
+
}
|
|
392
431
|
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
432
|
+
}
|
|
433
|
+
else if (customErrors && _get(customErrors.ErrorSchema, [...path, ERRORS_KEY])) {
|
|
434
|
+
// If we have custom errors and the path has an error, then we need to clear it
|
|
435
|
+
customErrors.clearErrors(path);
|
|
436
|
+
}
|
|
437
|
+
// If there are pending changes in the queue, skip live validation since it will happen with the last change
|
|
438
|
+
if (mustValidate && this.pendingChanges.length === 1) {
|
|
439
|
+
const liveValidation = this.liveValidate(schema, schemaUtils, originalErrorSchema, newFormData, extraErrors, customErrors, retrievedSchema);
|
|
440
|
+
state = { formData: newFormData, ...liveValidation, customErrors };
|
|
400
441
|
}
|
|
401
442
|
else if (!noValidate && newErrorSchema) {
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
: newErrorSchema;
|
|
443
|
+
// Merging 'newErrorSchema' into 'errorSchema' to display the custom raised errors.
|
|
444
|
+
const mergedErrors = this.mergeErrors({ errorSchema: originalErrorSchema, errors }, extraErrors, customErrors);
|
|
405
445
|
state = {
|
|
406
446
|
formData: newFormData,
|
|
407
|
-
|
|
408
|
-
|
|
447
|
+
...mergedErrors,
|
|
448
|
+
customErrors,
|
|
409
449
|
};
|
|
410
450
|
}
|
|
411
|
-
this.setState(state, () =>
|
|
412
|
-
|
|
451
|
+
this.setState(state, () => {
|
|
452
|
+
if (onChange) {
|
|
453
|
+
onChange({ ...this.state, ...state }, id);
|
|
454
|
+
}
|
|
455
|
+
// Now remove the change we just completed and call this again
|
|
456
|
+
this.pendingChanges.shift();
|
|
457
|
+
this.processPendingChange();
|
|
458
|
+
});
|
|
459
|
+
}
|
|
413
460
|
/**
|
|
414
461
|
* If the retrievedSchema has changed the new retrievedSchema is returned.
|
|
415
462
|
* Otherwise, the old retrievedSchema is returned to persist reference.
|
|
@@ -439,6 +486,8 @@ export default class Form extends Component {
|
|
|
439
486
|
errors: [],
|
|
440
487
|
schemaValidationErrors: [],
|
|
441
488
|
schemaValidationErrorSchema: {},
|
|
489
|
+
initialDefaultsGenerated: false,
|
|
490
|
+
customErrors: undefined,
|
|
442
491
|
};
|
|
443
492
|
this.setState(state, () => onChange && onChange({ ...this.state, ...state }));
|
|
444
493
|
};
|
|
@@ -503,10 +552,22 @@ export default class Form extends Component {
|
|
|
503
552
|
});
|
|
504
553
|
}
|
|
505
554
|
};
|
|
555
|
+
/** Extracts the `GlobalFormOptions` from the given Form `props`
|
|
556
|
+
*
|
|
557
|
+
* @param props - The form props to extract the global form options from
|
|
558
|
+
* @returns - The `GlobalFormOptions` from the props
|
|
559
|
+
* @private
|
|
560
|
+
*/
|
|
561
|
+
getGlobalFormOptions(props) {
|
|
562
|
+
const { uiSchema = {}, experimental_componentUpdateStrategy, idSeparator = DEFAULT_ID_SEPARATOR, idPrefix = DEFAULT_ID_PREFIX, } = props;
|
|
563
|
+
const rootFieldId = uiSchema['ui:rootFieldId'];
|
|
564
|
+
// Omit any options that are undefined or null
|
|
565
|
+
return { idPrefix: rootFieldId || idPrefix, idSeparator, experimental_componentUpdateStrategy };
|
|
566
|
+
}
|
|
506
567
|
/** Returns the registry for the form */
|
|
507
568
|
getRegistry() {
|
|
508
569
|
const { translateString: customTranslateString, uiSchema = {} } = this.props;
|
|
509
|
-
const { schemaUtils } = this.state;
|
|
570
|
+
const { schema, schemaUtils } = this.state;
|
|
510
571
|
const { fields, templates, widgets, formContext, translateString } = getDefaultRegistry();
|
|
511
572
|
return {
|
|
512
573
|
fields: { ...fields, ...this.props.fields },
|
|
@@ -519,11 +580,12 @@ export default class Form extends Component {
|
|
|
519
580
|
},
|
|
520
581
|
},
|
|
521
582
|
widgets: { ...widgets, ...this.props.widgets },
|
|
522
|
-
rootSchema:
|
|
583
|
+
rootSchema: schema,
|
|
523
584
|
formContext: this.props.formContext || formContext,
|
|
524
585
|
schemaUtils,
|
|
525
586
|
translateString: customTranslateString || translateString,
|
|
526
587
|
globalUiOptions: uiSchema[UI_GLOBAL_OPTIONS_KEY],
|
|
588
|
+
globalFormOptions: this.getGlobalFormOptions(this.props),
|
|
527
589
|
};
|
|
528
590
|
}
|
|
529
591
|
/** Provides a function that can be used to programmatically submit the `Form` */
|
|
@@ -640,8 +702,8 @@ export default class Form extends Component {
|
|
|
640
702
|
* needed along with the submit button or any children of the form.
|
|
641
703
|
*/
|
|
642
704
|
render() {
|
|
643
|
-
const { children, id,
|
|
644
|
-
const { schema, uiSchema, formData, errorSchema,
|
|
705
|
+
const { children, id, className = '', tagName, name, method, target, action, autoComplete, enctype, acceptCharset, noHtml5Validate = false, disabled, readonly, showErrorList = 'top', _internalFormWrapper, } = this.props;
|
|
706
|
+
const { schema, uiSchema, formData, errorSchema, fieldPathId } = this.state;
|
|
645
707
|
const registry = this.getRegistry();
|
|
646
708
|
const { SchemaField: _SchemaField } = registry.fields;
|
|
647
709
|
const { SubmitButton } = registry.templates.ButtonTemplates;
|
|
@@ -655,6 +717,6 @@ export default class Form extends Component {
|
|
|
655
717
|
submitOptions = { ...submitOptions, props: { ...submitOptions.props, disabled: true } };
|
|
656
718
|
}
|
|
657
719
|
const submitUiSchema = { [UI_OPTIONS_KEY]: { [SUBMIT_BTN_OPTIONS_KEY]: submitOptions } };
|
|
658
|
-
return (_jsxs(FormTag, { className: className ? className : 'rjsf', id: id, name: name, method: method, target: target, action: action, autoComplete: autoComplete, encType: enctype, acceptCharset: acceptCharset, noValidate: noHtml5Validate, onSubmit: this.onSubmit, as: as, ref: this.formElement, children: [showErrorList === 'top' && this.renderErrors(registry), _jsx(_SchemaField, { name: '', schema: schema, uiSchema: uiSchema, errorSchema: errorSchema,
|
|
720
|
+
return (_jsxs(FormTag, { className: className ? className : 'rjsf', id: id, name: name, method: method, target: target, action: action, autoComplete: autoComplete, encType: enctype, acceptCharset: acceptCharset, noValidate: noHtml5Validate, onSubmit: this.onSubmit, as: as, ref: this.formElement, children: [showErrorList === 'top' && this.renderErrors(registry), _jsx(_SchemaField, { name: '', schema: schema, uiSchema: uiSchema, errorSchema: errorSchema, fieldPathId: fieldPathId, formData: formData, onChange: this.onChange, onBlur: this.onBlur, onFocus: this.onFocus, registry: registry, disabled: disabled, readonly: readonly }), children ? children : _jsx(SubmitButton, { uiSchema: submitUiSchema, registry: registry }), showErrorList === 'bottom' && this.renderErrors(registry)] }));
|
|
659
721
|
}
|
|
660
722
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component, MouseEvent } from 'react';
|
|
2
|
-
import { ErrorSchema, FieldProps, FormContextType,
|
|
2
|
+
import { ErrorSchema, FieldPathId, FieldPathList, FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema, UiSchema } from '@rjsf/utils';
|
|
3
3
|
/** Type used to represent the keyed form data used in the state */
|
|
4
4
|
type KeyedFormDataType<T> = {
|
|
5
5
|
key: string;
|
|
@@ -106,9 +106,19 @@ declare class ArrayField<T = any, S extends StrictRJSFSchema = RJSFSchema, F ext
|
|
|
106
106
|
*
|
|
107
107
|
* @param index - The index of the item being changed
|
|
108
108
|
*/
|
|
109
|
-
onChangeForIndex: (index: number) => (value: any, newErrorSchema?: ErrorSchema<T>, id?: string) => void;
|
|
109
|
+
onChangeForIndex: (index: number) => (value: any, path: FieldPathList, newErrorSchema?: ErrorSchema<T>, id?: string) => void;
|
|
110
110
|
/** Callback handler used to change the value for a checkbox */
|
|
111
111
|
onSelectChange: (value: any) => void;
|
|
112
|
+
/** Helper method to compute item UI schema for both normal and fixed arrays
|
|
113
|
+
* Handles both static object and dynamic function cases
|
|
114
|
+
*
|
|
115
|
+
* @param uiSchema - The parent UI schema containing items definition
|
|
116
|
+
* @param item - The item data
|
|
117
|
+
* @param index - The index of the item
|
|
118
|
+
* @param formContext - The form context
|
|
119
|
+
* @returns The computed UI schema for the item
|
|
120
|
+
*/
|
|
121
|
+
private computeItemUiSchema;
|
|
112
122
|
/** Renders the `ArrayField` depending on the specific needs of the schema and uischema elements
|
|
113
123
|
*/
|
|
114
124
|
render(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -143,8 +153,8 @@ declare class ArrayField<T = any, S extends StrictRJSFSchema = RJSFSchema, F ext
|
|
|
143
153
|
canMoveDown: boolean;
|
|
144
154
|
itemSchema: S;
|
|
145
155
|
itemData: T[];
|
|
146
|
-
itemUiSchema: UiSchema<T[], S, F
|
|
147
|
-
|
|
156
|
+
itemUiSchema: UiSchema<T[], S, F> | undefined;
|
|
157
|
+
itemFieldPathId: FieldPathId;
|
|
148
158
|
itemErrorSchema?: ErrorSchema<T[]>;
|
|
149
159
|
autofocus?: boolean;
|
|
150
160
|
onBlur: FieldProps<T[], S, F>['onBlur'];
|
|
@@ -154,7 +164,7 @@ declare class ArrayField<T = any, S extends StrictRJSFSchema = RJSFSchema, F ext
|
|
|
154
164
|
}): {
|
|
155
165
|
children: import("react/jsx-runtime").JSX.Element;
|
|
156
166
|
buttonsProps: {
|
|
157
|
-
|
|
167
|
+
fieldPathId: FieldPathId;
|
|
158
168
|
disabled: boolean | undefined;
|
|
159
169
|
readonly: boolean | undefined;
|
|
160
170
|
canAdd: boolean;
|
|
@@ -170,7 +180,7 @@ declare class ArrayField<T = any, S extends StrictRJSFSchema = RJSFSchema, F ext
|
|
|
170
180
|
onReorderClick: (index: number, newIndex: number) => (event: MouseEvent<HTMLButtonElement>) => void;
|
|
171
181
|
registry: import("@rjsf/utils").Registry<T[], S, F>;
|
|
172
182
|
schema: S;
|
|
173
|
-
uiSchema: UiSchema<T[], S, F
|
|
183
|
+
uiSchema: UiSchema<T[], S, F> | undefined;
|
|
174
184
|
};
|
|
175
185
|
className: string;
|
|
176
186
|
disabled: boolean | undefined;
|
|
@@ -181,7 +191,7 @@ declare class ArrayField<T = any, S extends StrictRJSFSchema = RJSFSchema, F ext
|
|
|
181
191
|
readonly: boolean | undefined;
|
|
182
192
|
registry: import("@rjsf/utils").Registry<T[], S, F>;
|
|
183
193
|
schema: S;
|
|
184
|
-
uiSchema: UiSchema<T[], S, F
|
|
194
|
+
uiSchema: UiSchema<T[], S, F> | undefined;
|
|
185
195
|
};
|
|
186
196
|
}
|
|
187
197
|
/** `ArrayField` is `React.ComponentType<FieldProps<T[], S, F>>` (necessarily) but the `registry` requires things to be a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArrayField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/ArrayField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,
|
|
1
|
+
{"version":3,"file":"ArrayField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/ArrayField.tsx"],"names":[],"mappings":"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"}
|