@rjsf/core 6.3.0 → 6.4.0
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 +45 -14
- package/dist/index.cjs +45 -14
- package/dist/index.cjs.map +2 -2
- package/dist/index.esm.js +45 -14
- package/dist/index.esm.js.map +2 -2
- package/lib/components/Form.d.ts +10 -0
- package/lib/components/Form.d.ts.map +1 -1
- package/lib/components/Form.js +44 -13
- package/lib/components/fields/ArrayField.d.ts.map +1 -1
- package/lib/components/fields/ArrayField.js +2 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/src/components/Form.tsx +53 -13
- package/src/components/fields/ArrayField.tsx +2 -1
package/dist/index.esm.js
CHANGED
|
@@ -141,7 +141,8 @@ function ArrayAsMultiSelect(props) {
|
|
|
141
141
|
} = props;
|
|
142
142
|
const { widgets: widgets2, schemaUtils, globalFormOptions, globalUiOptions } = registry;
|
|
143
143
|
const itemsSchema = schemaUtils.retrieveSchema(schema.items, items);
|
|
144
|
-
const
|
|
144
|
+
const itemsUiSchema = uiSchema?.items ?? {};
|
|
145
|
+
const enumOptions = optionsList(itemsSchema, itemsUiSchema);
|
|
145
146
|
const { widget = "select", title: uiTitle, ...options } = getUiOptions(uiSchema, globalUiOptions);
|
|
146
147
|
const Widget = getWidget(schema, widget, widgets2);
|
|
147
148
|
const label = uiTitle ?? schema.title ?? name;
|
|
@@ -4300,6 +4301,34 @@ var Form = class extends Component3 {
|
|
|
4300
4301
|
* This prevents componentDidUpdate from reverting oneOf/anyOf option switches.
|
|
4301
4302
|
*/
|
|
4302
4303
|
_isProcessingUserChange = false;
|
|
4304
|
+
/** When the `extraErrors` prop changes, re-merges `schemaValidationErrors` + `extraErrors` + `customErrors` into
|
|
4305
|
+
* state before render, ensuring the updated errors are visible immediately in a single render cycle.
|
|
4306
|
+
*
|
|
4307
|
+
* @param props - The current props
|
|
4308
|
+
* @param state - The current state
|
|
4309
|
+
* @returns Partial state with re-merged errors if `extraErrors` changed, or `null` if no update is needed
|
|
4310
|
+
*/
|
|
4311
|
+
static getDerivedStateFromProps(props, state) {
|
|
4312
|
+
if (props.extraErrors !== state._prevExtraErrors) {
|
|
4313
|
+
const baseErrors = {
|
|
4314
|
+
errors: state.schemaValidationErrors || [],
|
|
4315
|
+
errorSchema: state.schemaValidationErrorSchema || {}
|
|
4316
|
+
};
|
|
4317
|
+
let { errors, errorSchema } = baseErrors;
|
|
4318
|
+
if (props.extraErrors) {
|
|
4319
|
+
({ errors, errorSchema } = validationDataMerge(baseErrors, props.extraErrors));
|
|
4320
|
+
}
|
|
4321
|
+
if (state.customErrors) {
|
|
4322
|
+
({ errors, errorSchema } = validationDataMerge(
|
|
4323
|
+
{ errors, errorSchema },
|
|
4324
|
+
state.customErrors.ErrorSchema,
|
|
4325
|
+
true
|
|
4326
|
+
));
|
|
4327
|
+
}
|
|
4328
|
+
return { _prevExtraErrors: props.extraErrors, errors, errorSchema };
|
|
4329
|
+
}
|
|
4330
|
+
return null;
|
|
4331
|
+
}
|
|
4303
4332
|
/** Constructs the `Form` from the `props`. Will setup the initial state from the props. It will also call the
|
|
4304
4333
|
* `onChange` handler if the initially provided `formData` is modified to add missing default values as part of the
|
|
4305
4334
|
* state construction.
|
|
@@ -4313,7 +4342,10 @@ var Form = class extends Component3 {
|
|
|
4313
4342
|
}
|
|
4314
4343
|
const { formData: propsFormData, initialFormData, onChange } = props;
|
|
4315
4344
|
const formData = propsFormData ?? initialFormData;
|
|
4316
|
-
this.state =
|
|
4345
|
+
this.state = {
|
|
4346
|
+
...this.getStateFromProps(props, formData, void 0, void 0, void 0, true),
|
|
4347
|
+
_prevExtraErrors: props.extraErrors
|
|
4348
|
+
};
|
|
4317
4349
|
if (onChange && !deepEquals2(this.state.formData, formData)) {
|
|
4318
4350
|
onChange(toIChangeEvent(this.state));
|
|
4319
4351
|
}
|
|
@@ -5000,17 +5032,9 @@ var Form = class extends Component3 {
|
|
|
5000
5032
|
const { extraErrors, extraErrorsBlockSubmit, focusOnFirstError, onError } = this.props;
|
|
5001
5033
|
const { errors: prevErrors } = this.state;
|
|
5002
5034
|
const schemaValidation = this.validate(formData);
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
const schemaValidationErrors = errors;
|
|
5006
|
-
const schemaValidationErrorSchema = errorSchema;
|
|
5007
|
-
const hasError = errors.length > 0 || extraErrors && extraErrorsBlockSubmit;
|
|
5035
|
+
const { errors, errorSchema } = extraErrors ? this.mergeErrors(schemaValidation, extraErrors) : schemaValidation;
|
|
5036
|
+
const hasError = schemaValidation.errors.length > 0 || extraErrors && extraErrorsBlockSubmit;
|
|
5008
5037
|
if (hasError) {
|
|
5009
|
-
if (extraErrors) {
|
|
5010
|
-
const merged = validationDataMerge(schemaValidation, extraErrors);
|
|
5011
|
-
errorSchema = merged.errorSchema;
|
|
5012
|
-
errors = merged.errors;
|
|
5013
|
-
}
|
|
5014
5038
|
if (focusOnFirstError) {
|
|
5015
5039
|
if (typeof focusOnFirstError === "function") {
|
|
5016
5040
|
focusOnFirstError(errors[0]);
|
|
@@ -5022,8 +5046,8 @@ var Form = class extends Component3 {
|
|
|
5022
5046
|
{
|
|
5023
5047
|
errors,
|
|
5024
5048
|
errorSchema,
|
|
5025
|
-
schemaValidationErrors,
|
|
5026
|
-
schemaValidationErrorSchema
|
|
5049
|
+
schemaValidationErrors: schemaValidation.errors,
|
|
5050
|
+
schemaValidationErrorSchema: schemaValidation.errorSchema
|
|
5027
5051
|
},
|
|
5028
5052
|
() => {
|
|
5029
5053
|
if (onError) {
|
|
@@ -5033,6 +5057,13 @@ var Form = class extends Component3 {
|
|
|
5033
5057
|
}
|
|
5034
5058
|
}
|
|
5035
5059
|
);
|
|
5060
|
+
} else if (errors.length > 0) {
|
|
5061
|
+
this.setState({
|
|
5062
|
+
errors,
|
|
5063
|
+
errorSchema,
|
|
5064
|
+
schemaValidationErrors: [],
|
|
5065
|
+
schemaValidationErrorSchema: {}
|
|
5066
|
+
});
|
|
5036
5067
|
} else if (prevErrors.length > 0) {
|
|
5037
5068
|
this.setState({
|
|
5038
5069
|
errors: [],
|