@rjsf/core 5.14.2 → 5.15.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 +20 -11
- package/dist/index.esm.js +20 -11
- package/dist/index.esm.js.map +2 -2
- package/dist/index.js +20 -11
- package/dist/index.js.map +2 -2
- package/lib/components/Form.d.ts +3 -1
- package/lib/components/Form.js +30 -18
- package/lib/components/Form.js.map +1 -1
- package/lib/components/fields/ArrayField.js +10 -8
- package/lib/components/fields/ArrayField.js.map +1 -1
- package/lib/components/fields/BooleanField.js +7 -5
- package/lib/components/fields/BooleanField.js.map +1 -1
- package/lib/components/fields/MultiSchemaField.js +2 -3
- package/lib/components/fields/MultiSchemaField.js.map +1 -1
- package/lib/components/fields/NumberField.js +1 -1
- package/lib/components/fields/NumberField.js.map +1 -1
- package/lib/components/fields/ObjectField.js +16 -8
- package/lib/components/fields/ObjectField.js.map +1 -1
- package/lib/components/fields/SchemaField.js +4 -5
- package/lib/components/fields/SchemaField.js.map +1 -1
- package/lib/components/fields/StringField.js +2 -3
- package/lib/components/fields/StringField.js.map +1 -1
- package/lib/components/templates/ArrayFieldItemTemplate.js +2 -2
- package/lib/components/templates/ArrayFieldItemTemplate.js.map +1 -1
- package/lib/components/templates/ArrayFieldTemplate.js +2 -6
- package/lib/components/templates/ArrayFieldTemplate.js.map +1 -1
- package/lib/components/templates/BaseInputTemplate.js +8 -6
- package/lib/components/templates/BaseInputTemplate.js.map +1 -1
- package/lib/components/templates/ButtonTemplates/AddButton.js +1 -1
- package/lib/components/templates/ButtonTemplates/AddButton.js.map +1 -1
- package/lib/components/templates/ButtonTemplates/IconButton.js +6 -7
- package/lib/components/templates/ButtonTemplates/IconButton.js.map +1 -1
- package/lib/components/templates/ButtonTemplates/SubmitButton.js +1 -1
- package/lib/components/templates/ButtonTemplates/SubmitButton.js.map +1 -1
- package/lib/components/templates/DescriptionField.js +2 -2
- package/lib/components/templates/DescriptionField.js.map +1 -1
- package/lib/components/templates/ErrorList.js +3 -3
- package/lib/components/templates/ErrorList.js.map +1 -1
- package/lib/components/templates/FieldErrorTemplate.js +3 -3
- package/lib/components/templates/FieldErrorTemplate.js.map +1 -1
- package/lib/components/templates/FieldHelpTemplate.js +2 -2
- package/lib/components/templates/FieldHelpTemplate.js.map +1 -1
- package/lib/components/templates/FieldTemplate/FieldTemplate.js +2 -2
- package/lib/components/templates/FieldTemplate/FieldTemplate.js.map +1 -1
- package/lib/components/templates/FieldTemplate/Label.js +1 -1
- package/lib/components/templates/FieldTemplate/Label.js.map +1 -1
- package/lib/components/templates/ObjectFieldTemplate.js +1 -1
- package/lib/components/templates/ObjectFieldTemplate.js.map +1 -1
- package/lib/components/templates/TitleField.js +1 -1
- package/lib/components/templates/TitleField.js.map +1 -1
- package/lib/components/templates/UnsupportedField.js +1 -1
- package/lib/components/templates/UnsupportedField.js.map +1 -1
- package/lib/components/templates/WrapIfAdditionalTemplate.js +2 -2
- package/lib/components/templates/WrapIfAdditionalTemplate.js.map +1 -1
- package/lib/components/widgets/AltDateTimeWidget.js +2 -4
- package/lib/components/widgets/AltDateTimeWidget.js.map +1 -1
- package/lib/components/widgets/AltDateWidget.js +2 -2
- package/lib/components/widgets/AltDateWidget.js.map +1 -1
- package/lib/components/widgets/CheckboxWidget.js +1 -1
- package/lib/components/widgets/CheckboxWidget.js.map +1 -1
- package/lib/components/widgets/CheckboxesWidget.js +3 -3
- package/lib/components/widgets/CheckboxesWidget.js.map +1 -1
- package/lib/components/widgets/ColorWidget.js +1 -1
- package/lib/components/widgets/ColorWidget.js.map +1 -1
- package/lib/components/widgets/DateTimeWidget.js +1 -1
- package/lib/components/widgets/DateTimeWidget.js.map +1 -1
- package/lib/components/widgets/DateWidget.js +1 -1
- package/lib/components/widgets/DateWidget.js.map +1 -1
- package/lib/components/widgets/EmailWidget.js +1 -1
- package/lib/components/widgets/EmailWidget.js.map +1 -1
- package/lib/components/widgets/FileWidget.js +4 -4
- package/lib/components/widgets/FileWidget.js.map +1 -1
- package/lib/components/widgets/PasswordWidget.js +1 -1
- package/lib/components/widgets/PasswordWidget.js.map +1 -1
- package/lib/components/widgets/RadioWidget.js +3 -3
- package/lib/components/widgets/RadioWidget.js.map +1 -1
- package/lib/components/widgets/RangeWidget.js +1 -1
- package/lib/components/widgets/RangeWidget.js.map +1 -1
- package/lib/components/widgets/SelectWidget.js +3 -3
- package/lib/components/widgets/SelectWidget.js.map +1 -1
- package/lib/components/widgets/TextWidget.js +1 -1
- package/lib/components/widgets/TextWidget.js.map +1 -1
- package/lib/components/widgets/TimeWidget.js +1 -1
- package/lib/components/widgets/TimeWidget.js.map +1 -1
- package/lib/components/widgets/URLWidget.js +1 -1
- package/lib/components/widgets/URLWidget.js.map +1 -1
- package/lib/components/widgets/UpDownWidget.js +1 -1
- package/lib/components/widgets/UpDownWidget.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/withTheme.js +13 -8
- package/lib/withTheme.js.map +1 -1
- package/package.json +6 -6
- package/src/components/Form.tsx +23 -10
package/dist/core.umd.js
CHANGED
|
@@ -2991,17 +2991,18 @@
|
|
|
2991
2991
|
*/
|
|
2992
2992
|
this.onChange = (formData, newErrorSchema, id) => {
|
|
2993
2993
|
const { extraErrors, omitExtraData, liveOmit, noValidate, liveValidate, onChange } = this.props;
|
|
2994
|
-
const { schemaUtils, schema } = this.state;
|
|
2994
|
+
const { schemaUtils, schema, retrievedSchema } = this.state;
|
|
2995
2995
|
if (utils.isObject(formData) || Array.isArray(formData)) {
|
|
2996
|
-
const newState = this.getStateFromProps(this.props, formData);
|
|
2996
|
+
const newState = this.getStateFromProps(this.props, formData, retrievedSchema);
|
|
2997
2997
|
formData = newState.formData;
|
|
2998
2998
|
}
|
|
2999
2999
|
const mustValidate = !noValidate && liveValidate;
|
|
3000
3000
|
let state = { formData, schema };
|
|
3001
3001
|
let newFormData = formData;
|
|
3002
|
+
let _retrievedSchema;
|
|
3002
3003
|
if (omitExtraData === true && liveOmit === true) {
|
|
3003
|
-
|
|
3004
|
-
const pathSchema = schemaUtils.toPathSchema(
|
|
3004
|
+
_retrievedSchema = schemaUtils.retrieveSchema(schema, formData);
|
|
3005
|
+
const pathSchema = schemaUtils.toPathSchema(_retrievedSchema, "", formData);
|
|
3005
3006
|
const fieldNames = this.getFieldNames(pathSchema, formData);
|
|
3006
3007
|
newFormData = this.getUsedFormData(formData, fieldNames);
|
|
3007
3008
|
state = {
|
|
@@ -3009,7 +3010,7 @@
|
|
|
3009
3010
|
};
|
|
3010
3011
|
}
|
|
3011
3012
|
if (mustValidate) {
|
|
3012
|
-
const schemaValidation = this.validate(newFormData);
|
|
3013
|
+
const schemaValidation = this.validate(newFormData, schema, schemaUtils, retrievedSchema);
|
|
3013
3014
|
let errors = schemaValidation.errors;
|
|
3014
3015
|
let errorSchema = schemaValidation.errorSchema;
|
|
3015
3016
|
const schemaValidationErrors = errors;
|
|
@@ -3034,6 +3035,9 @@
|
|
|
3034
3035
|
errors: utils.toErrorList(errorSchema)
|
|
3035
3036
|
};
|
|
3036
3037
|
}
|
|
3038
|
+
if (_retrievedSchema) {
|
|
3039
|
+
state.retrievedSchema = _retrievedSchema;
|
|
3040
|
+
}
|
|
3037
3041
|
this.setState(state, () => onChange && onChange({ ...this.state, ...state }, id));
|
|
3038
3042
|
};
|
|
3039
3043
|
/**
|
|
@@ -3150,7 +3154,11 @@
|
|
|
3150
3154
|
*/
|
|
3151
3155
|
getSnapshotBeforeUpdate(prevProps, prevState) {
|
|
3152
3156
|
if (!utils.deepEquals(this.props, prevProps)) {
|
|
3153
|
-
const nextState = this.getStateFromProps(
|
|
3157
|
+
const nextState = this.getStateFromProps(
|
|
3158
|
+
this.props,
|
|
3159
|
+
this.props.formData,
|
|
3160
|
+
prevProps.schema !== this.props.schema ? void 0 : this.state.retrievedSchema
|
|
3161
|
+
);
|
|
3154
3162
|
const shouldUpdate = !utils.deepEquals(nextState, prevState);
|
|
3155
3163
|
return { nextState, shouldUpdate };
|
|
3156
3164
|
}
|
|
@@ -3188,7 +3196,7 @@
|
|
|
3188
3196
|
* @param inputFormData - The new or current data for the `Form`
|
|
3189
3197
|
* @returns - The new state for the `Form`
|
|
3190
3198
|
*/
|
|
3191
|
-
getStateFromProps(props, inputFormData) {
|
|
3199
|
+
getStateFromProps(props, inputFormData, retrievedSchema) {
|
|
3192
3200
|
const state = this.state || {};
|
|
3193
3201
|
const schema = "schema" in props ? props.schema : this.props.schema;
|
|
3194
3202
|
const uiSchema = ("uiSchema" in props ? props.uiSchema : this.props.uiSchema) || {};
|
|
@@ -3202,7 +3210,7 @@
|
|
|
3202
3210
|
schemaUtils = utils.createSchemaUtils(props.validator, rootSchema, experimental_defaultFormStateBehavior);
|
|
3203
3211
|
}
|
|
3204
3212
|
const formData = schemaUtils.getDefaultFormState(schema, inputFormData);
|
|
3205
|
-
const
|
|
3213
|
+
const _retrievedSchema = retrievedSchema ?? schemaUtils.retrieveSchema(schema, formData);
|
|
3206
3214
|
const getCurrentErrors = () => {
|
|
3207
3215
|
if (props.noValidate) {
|
|
3208
3216
|
return { errors: [], errorSchema: {} };
|
|
@@ -3222,7 +3230,7 @@
|
|
|
3222
3230
|
let schemaValidationErrors = state.schemaValidationErrors;
|
|
3223
3231
|
let schemaValidationErrorSchema = state.schemaValidationErrorSchema;
|
|
3224
3232
|
if (mustValidate) {
|
|
3225
|
-
const schemaValidation = this.validate(formData, schema, schemaUtils,
|
|
3233
|
+
const schemaValidation = this.validate(formData, schema, schemaUtils, _retrievedSchema);
|
|
3226
3234
|
errors = schemaValidation.errors;
|
|
3227
3235
|
errorSchema = schemaValidation.errorSchema;
|
|
3228
3236
|
schemaValidationErrors = errors;
|
|
@@ -3238,7 +3246,7 @@
|
|
|
3238
3246
|
errors = merged.errors;
|
|
3239
3247
|
}
|
|
3240
3248
|
const idSchema = schemaUtils.toIdSchema(
|
|
3241
|
-
|
|
3249
|
+
_retrievedSchema,
|
|
3242
3250
|
uiSchema["ui:rootFieldId"],
|
|
3243
3251
|
formData,
|
|
3244
3252
|
props.idPrefix,
|
|
@@ -3254,7 +3262,8 @@
|
|
|
3254
3262
|
errors,
|
|
3255
3263
|
errorSchema,
|
|
3256
3264
|
schemaValidationErrors,
|
|
3257
|
-
schemaValidationErrorSchema
|
|
3265
|
+
schemaValidationErrorSchema,
|
|
3266
|
+
retrievedSchema: _retrievedSchema
|
|
3258
3267
|
};
|
|
3259
3268
|
return nextState;
|
|
3260
3269
|
}
|
package/dist/index.esm.js
CHANGED
|
@@ -3337,17 +3337,18 @@ var Form = class extends Component5 {
|
|
|
3337
3337
|
*/
|
|
3338
3338
|
this.onChange = (formData, newErrorSchema, id) => {
|
|
3339
3339
|
const { extraErrors, omitExtraData, liveOmit, noValidate, liveValidate, onChange } = this.props;
|
|
3340
|
-
const { schemaUtils, schema } = this.state;
|
|
3340
|
+
const { schemaUtils, schema, retrievedSchema } = this.state;
|
|
3341
3341
|
if (isObject5(formData) || Array.isArray(formData)) {
|
|
3342
|
-
const newState = this.getStateFromProps(this.props, formData);
|
|
3342
|
+
const newState = this.getStateFromProps(this.props, formData, retrievedSchema);
|
|
3343
3343
|
formData = newState.formData;
|
|
3344
3344
|
}
|
|
3345
3345
|
const mustValidate = !noValidate && liveValidate;
|
|
3346
3346
|
let state = { formData, schema };
|
|
3347
3347
|
let newFormData = formData;
|
|
3348
|
+
let _retrievedSchema;
|
|
3348
3349
|
if (omitExtraData === true && liveOmit === true) {
|
|
3349
|
-
|
|
3350
|
-
const pathSchema = schemaUtils.toPathSchema(
|
|
3350
|
+
_retrievedSchema = schemaUtils.retrieveSchema(schema, formData);
|
|
3351
|
+
const pathSchema = schemaUtils.toPathSchema(_retrievedSchema, "", formData);
|
|
3351
3352
|
const fieldNames = this.getFieldNames(pathSchema, formData);
|
|
3352
3353
|
newFormData = this.getUsedFormData(formData, fieldNames);
|
|
3353
3354
|
state = {
|
|
@@ -3355,7 +3356,7 @@ var Form = class extends Component5 {
|
|
|
3355
3356
|
};
|
|
3356
3357
|
}
|
|
3357
3358
|
if (mustValidate) {
|
|
3358
|
-
const schemaValidation = this.validate(newFormData);
|
|
3359
|
+
const schemaValidation = this.validate(newFormData, schema, schemaUtils, retrievedSchema);
|
|
3359
3360
|
let errors = schemaValidation.errors;
|
|
3360
3361
|
let errorSchema = schemaValidation.errorSchema;
|
|
3361
3362
|
const schemaValidationErrors = errors;
|
|
@@ -3380,6 +3381,9 @@ var Form = class extends Component5 {
|
|
|
3380
3381
|
errors: toErrorList(errorSchema)
|
|
3381
3382
|
};
|
|
3382
3383
|
}
|
|
3384
|
+
if (_retrievedSchema) {
|
|
3385
|
+
state.retrievedSchema = _retrievedSchema;
|
|
3386
|
+
}
|
|
3383
3387
|
this.setState(state, () => onChange && onChange({ ...this.state, ...state }, id));
|
|
3384
3388
|
};
|
|
3385
3389
|
/**
|
|
@@ -3496,7 +3500,11 @@ var Form = class extends Component5 {
|
|
|
3496
3500
|
*/
|
|
3497
3501
|
getSnapshotBeforeUpdate(prevProps, prevState) {
|
|
3498
3502
|
if (!deepEquals3(this.props, prevProps)) {
|
|
3499
|
-
const nextState = this.getStateFromProps(
|
|
3503
|
+
const nextState = this.getStateFromProps(
|
|
3504
|
+
this.props,
|
|
3505
|
+
this.props.formData,
|
|
3506
|
+
prevProps.schema !== this.props.schema ? void 0 : this.state.retrievedSchema
|
|
3507
|
+
);
|
|
3500
3508
|
const shouldUpdate = !deepEquals3(nextState, prevState);
|
|
3501
3509
|
return { nextState, shouldUpdate };
|
|
3502
3510
|
}
|
|
@@ -3534,7 +3542,7 @@ var Form = class extends Component5 {
|
|
|
3534
3542
|
* @param inputFormData - The new or current data for the `Form`
|
|
3535
3543
|
* @returns - The new state for the `Form`
|
|
3536
3544
|
*/
|
|
3537
|
-
getStateFromProps(props, inputFormData) {
|
|
3545
|
+
getStateFromProps(props, inputFormData, retrievedSchema) {
|
|
3538
3546
|
const state = this.state || {};
|
|
3539
3547
|
const schema = "schema" in props ? props.schema : this.props.schema;
|
|
3540
3548
|
const uiSchema = ("uiSchema" in props ? props.uiSchema : this.props.uiSchema) || {};
|
|
@@ -3548,7 +3556,7 @@ var Form = class extends Component5 {
|
|
|
3548
3556
|
schemaUtils = createSchemaUtils(props.validator, rootSchema, experimental_defaultFormStateBehavior);
|
|
3549
3557
|
}
|
|
3550
3558
|
const formData = schemaUtils.getDefaultFormState(schema, inputFormData);
|
|
3551
|
-
const
|
|
3559
|
+
const _retrievedSchema = retrievedSchema ?? schemaUtils.retrieveSchema(schema, formData);
|
|
3552
3560
|
const getCurrentErrors = () => {
|
|
3553
3561
|
if (props.noValidate) {
|
|
3554
3562
|
return { errors: [], errorSchema: {} };
|
|
@@ -3568,7 +3576,7 @@ var Form = class extends Component5 {
|
|
|
3568
3576
|
let schemaValidationErrors = state.schemaValidationErrors;
|
|
3569
3577
|
let schemaValidationErrorSchema = state.schemaValidationErrorSchema;
|
|
3570
3578
|
if (mustValidate) {
|
|
3571
|
-
const schemaValidation = this.validate(formData, schema, schemaUtils,
|
|
3579
|
+
const schemaValidation = this.validate(formData, schema, schemaUtils, _retrievedSchema);
|
|
3572
3580
|
errors = schemaValidation.errors;
|
|
3573
3581
|
errorSchema = schemaValidation.errorSchema;
|
|
3574
3582
|
schemaValidationErrors = errors;
|
|
@@ -3584,7 +3592,7 @@ var Form = class extends Component5 {
|
|
|
3584
3592
|
errors = merged.errors;
|
|
3585
3593
|
}
|
|
3586
3594
|
const idSchema = schemaUtils.toIdSchema(
|
|
3587
|
-
|
|
3595
|
+
_retrievedSchema,
|
|
3588
3596
|
uiSchema["ui:rootFieldId"],
|
|
3589
3597
|
formData,
|
|
3590
3598
|
props.idPrefix,
|
|
@@ -3600,7 +3608,8 @@ var Form = class extends Component5 {
|
|
|
3600
3608
|
errors,
|
|
3601
3609
|
errorSchema,
|
|
3602
3610
|
schemaValidationErrors,
|
|
3603
|
-
schemaValidationErrorSchema
|
|
3611
|
+
schemaValidationErrorSchema,
|
|
3612
|
+
retrievedSchema: _retrievedSchema
|
|
3604
3613
|
};
|
|
3605
3614
|
return nextState;
|
|
3606
3615
|
}
|