@rjsf/core 6.5.1 → 6.5.3
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 +41 -13
- package/dist/index.cjs +37 -9
- package/dist/index.cjs.map +2 -2
- package/dist/index.esm.js +63 -32
- package/dist/index.esm.js.map +3 -3
- package/lib/components/Form.d.ts.map +1 -1
- package/lib/components/Form.js +40 -8
- package/lib/components/fields/ArrayField.d.ts.map +1 -1
- package/lib/components/fields/ArrayField.js +3 -1
- package/lib/components/fields/SchemaField.d.ts.map +1 -1
- package/lib/components/fields/SchemaField.js +8 -3
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/components/Form.tsx +41 -7
- package/src/components/fields/ArrayField.tsx +3 -1
- package/src/components/fields/SchemaField.tsx +11 -2
package/dist/index.esm.js
CHANGED
|
@@ -23,7 +23,9 @@ import {
|
|
|
23
23
|
ERRORS_KEY as ERRORS_KEY3,
|
|
24
24
|
ID_KEY as ID_KEY5,
|
|
25
25
|
getUsedFormData,
|
|
26
|
-
getFieldNames
|
|
26
|
+
getFieldNames,
|
|
27
|
+
ANY_OF_KEY as ANY_OF_KEY6,
|
|
28
|
+
ONE_OF_KEY as ONE_OF_KEY6
|
|
27
29
|
} from "@rjsf/utils";
|
|
28
30
|
import _cloneDeep from "lodash/cloneDeep";
|
|
29
31
|
import _get from "lodash/get";
|
|
@@ -781,10 +783,12 @@ function ArrayField(props) {
|
|
|
781
783
|
);
|
|
782
784
|
const handleChange = useCallback(
|
|
783
785
|
(value, path, newErrorSchema, id) => {
|
|
786
|
+
const lastPathIsItemIndex = typeof path.at(-1) === "number";
|
|
784
787
|
onChange(
|
|
785
788
|
// We need to treat undefined items as nulls to have validation.
|
|
786
789
|
// See https://github.com/tdegrunt/jsonschema/issues/206
|
|
787
|
-
|
|
790
|
+
// Only set to null for array items, and not for object properties within array items
|
|
791
|
+
lastPathIsItemIndex && value === void 0 ? null : value,
|
|
788
792
|
path,
|
|
789
793
|
newErrorSchema,
|
|
790
794
|
id
|
|
@@ -2316,6 +2320,7 @@ import {
|
|
|
2316
2320
|
shouldRender,
|
|
2317
2321
|
shouldRenderOptionalField as shouldRenderOptionalField4,
|
|
2318
2322
|
toFieldPathId as toFieldPathId5,
|
|
2323
|
+
TranslatableString as TranslatableString7,
|
|
2319
2324
|
UI_OPTIONS_KEY as UI_OPTIONS_KEY2
|
|
2320
2325
|
} from "@rjsf/utils";
|
|
2321
2326
|
import isObject5 from "lodash/isObject";
|
|
@@ -2389,7 +2394,9 @@ function SchemaFieldRender(props) {
|
|
|
2389
2394
|
[fieldId, onChange]
|
|
2390
2395
|
);
|
|
2391
2396
|
const FieldComponent = getFieldComponent(schema, uiOptions, registry);
|
|
2392
|
-
const
|
|
2397
|
+
const isDeprecated = Boolean(schema.deprecated);
|
|
2398
|
+
const deprecatedHandling = isDeprecated ? uiOptions.deprecatedHandling ?? "label" : void 0;
|
|
2399
|
+
const disabled = Boolean(uiOptions.disabled ?? props.disabled) || deprecatedHandling === "disable";
|
|
2393
2400
|
const readonly = Boolean(uiOptions.readonly ?? (props.readonly || props.schema.readOnly || schema.readOnly));
|
|
2394
2401
|
const uiSchemaHideError = uiOptions.hideError;
|
|
2395
2402
|
const hideError = uiSchemaHideError === void 0 ? props.hideError : Boolean(uiSchemaHideError);
|
|
@@ -2452,9 +2459,12 @@ function SchemaFieldRender(props) {
|
|
|
2452
2459
|
} else {
|
|
2453
2460
|
label = ADDITIONAL_PROPERTY_FLAG2 in schema ? name : uiOptions.title || props.schema.title || schema.title || props.title || name;
|
|
2454
2461
|
}
|
|
2462
|
+
if (deprecatedHandling === "label") {
|
|
2463
|
+
label = registry.translateString(TranslatableString7.DeprecatedLabel, [label]);
|
|
2464
|
+
}
|
|
2455
2465
|
const description = uiOptions.description || props.schema.description || schema.description || "";
|
|
2456
2466
|
const help = uiOptions.help;
|
|
2457
|
-
const hidden = uiOptions.widget === "hidden";
|
|
2467
|
+
const hidden = uiOptions.widget === "hidden" || deprecatedHandling === "hide";
|
|
2458
2468
|
const classNames = ["rjsf-field", `rjsf-field-${getSchemaType2(schema)}`];
|
|
2459
2469
|
if (!hideError && __errors && __errors.length > 0) {
|
|
2460
2470
|
classNames.push("rjsf-field-error");
|
|
@@ -3029,10 +3039,10 @@ function SubmitButton({ uiSchema }) {
|
|
|
3029
3039
|
}
|
|
3030
3040
|
|
|
3031
3041
|
// src/components/templates/ButtonTemplates/AddButton.tsx
|
|
3032
|
-
import { TranslatableString as
|
|
3042
|
+
import { TranslatableString as TranslatableString9 } from "@rjsf/utils";
|
|
3033
3043
|
|
|
3034
3044
|
// src/components/templates/ButtonTemplates/IconButton.tsx
|
|
3035
|
-
import { TranslatableString as
|
|
3045
|
+
import { TranslatableString as TranslatableString8 } from "@rjsf/utils";
|
|
3036
3046
|
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
3037
3047
|
function IconButton(props) {
|
|
3038
3048
|
const { iconType = "default", icon, className, uiSchema, registry, ...otherProps } = props;
|
|
@@ -3042,25 +3052,25 @@ function CopyButton(props) {
|
|
|
3042
3052
|
const {
|
|
3043
3053
|
registry: { translateString }
|
|
3044
3054
|
} = props;
|
|
3045
|
-
return /* @__PURE__ */ jsx21(IconButton, { title: translateString(
|
|
3055
|
+
return /* @__PURE__ */ jsx21(IconButton, { title: translateString(TranslatableString8.CopyButton), ...props, icon: "copy" });
|
|
3046
3056
|
}
|
|
3047
3057
|
function MoveDownButton(props) {
|
|
3048
3058
|
const {
|
|
3049
3059
|
registry: { translateString }
|
|
3050
3060
|
} = props;
|
|
3051
|
-
return /* @__PURE__ */ jsx21(IconButton, { title: translateString(
|
|
3061
|
+
return /* @__PURE__ */ jsx21(IconButton, { title: translateString(TranslatableString8.MoveDownButton), ...props, icon: "arrow-down" });
|
|
3052
3062
|
}
|
|
3053
3063
|
function MoveUpButton(props) {
|
|
3054
3064
|
const {
|
|
3055
3065
|
registry: { translateString }
|
|
3056
3066
|
} = props;
|
|
3057
|
-
return /* @__PURE__ */ jsx21(IconButton, { title: translateString(
|
|
3067
|
+
return /* @__PURE__ */ jsx21(IconButton, { title: translateString(TranslatableString8.MoveUpButton), ...props, icon: "arrow-up" });
|
|
3058
3068
|
}
|
|
3059
3069
|
function RemoveButton(props) {
|
|
3060
3070
|
const {
|
|
3061
3071
|
registry: { translateString }
|
|
3062
3072
|
} = props;
|
|
3063
|
-
return /* @__PURE__ */ jsx21(IconButton, { title: translateString(
|
|
3073
|
+
return /* @__PURE__ */ jsx21(IconButton, { title: translateString(TranslatableString8.RemoveButton), ...props, iconType: "danger", icon: "remove" });
|
|
3064
3074
|
}
|
|
3065
3075
|
function ClearButton({
|
|
3066
3076
|
id,
|
|
@@ -3078,7 +3088,7 @@ function ClearButton({
|
|
|
3078
3088
|
iconType: "default",
|
|
3079
3089
|
icon: "remove",
|
|
3080
3090
|
className: "btn-clear col-xs-12",
|
|
3081
|
-
title: translateString(
|
|
3091
|
+
title: translateString(TranslatableString8.ClearButton),
|
|
3082
3092
|
onClick,
|
|
3083
3093
|
disabled,
|
|
3084
3094
|
registry,
|
|
@@ -3108,7 +3118,7 @@ function AddButton({
|
|
|
3108
3118
|
iconType: "info",
|
|
3109
3119
|
icon: "plus",
|
|
3110
3120
|
className: "btn-add col-xs-12",
|
|
3111
|
-
title: translateString(
|
|
3121
|
+
title: translateString(TranslatableString9.AddButton),
|
|
3112
3122
|
onClick,
|
|
3113
3123
|
disabled,
|
|
3114
3124
|
registry
|
|
@@ -3162,7 +3172,7 @@ function DescriptionField(props) {
|
|
|
3162
3172
|
|
|
3163
3173
|
// src/components/templates/ErrorList.tsx
|
|
3164
3174
|
import {
|
|
3165
|
-
TranslatableString as
|
|
3175
|
+
TranslatableString as TranslatableString10
|
|
3166
3176
|
} from "@rjsf/utils";
|
|
3167
3177
|
import { jsx as jsx25, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
3168
3178
|
function ErrorList({
|
|
@@ -3171,7 +3181,7 @@ function ErrorList({
|
|
|
3171
3181
|
}) {
|
|
3172
3182
|
const { translateString } = registry;
|
|
3173
3183
|
return /* @__PURE__ */ jsxs7("div", { className: "panel panel-danger errors", children: [
|
|
3174
|
-
/* @__PURE__ */ jsx25("div", { className: "panel-heading", children: /* @__PURE__ */ jsx25("h3", { className: "panel-title", children: translateString(
|
|
3184
|
+
/* @__PURE__ */ jsx25("div", { className: "panel-heading", children: /* @__PURE__ */ jsx25("h3", { className: "panel-title", children: translateString(TranslatableString10.ErrorsLabel) }) }),
|
|
3175
3185
|
/* @__PURE__ */ jsx25("ul", { className: "list-group", children: errors.map((error, i) => {
|
|
3176
3186
|
return /* @__PURE__ */ jsx25("li", { className: "list-group-item text-danger", children: error.stack }, i);
|
|
3177
3187
|
}) })
|
|
@@ -3436,20 +3446,20 @@ function TitleField(props) {
|
|
|
3436
3446
|
}
|
|
3437
3447
|
|
|
3438
3448
|
// src/components/templates/UnsupportedField.tsx
|
|
3439
|
-
import { TranslatableString as
|
|
3449
|
+
import { TranslatableString as TranslatableString11 } from "@rjsf/utils";
|
|
3440
3450
|
import Markdown4 from "markdown-to-jsx";
|
|
3441
3451
|
import { jsx as jsx37, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
3442
3452
|
function UnsupportedField(props) {
|
|
3443
3453
|
const { schema, fieldPathId, reason, registry } = props;
|
|
3444
3454
|
const { translateString } = registry;
|
|
3445
|
-
let translateEnum =
|
|
3455
|
+
let translateEnum = TranslatableString11.UnsupportedField;
|
|
3446
3456
|
const translateParams = [];
|
|
3447
3457
|
if (fieldPathId && fieldPathId.$id) {
|
|
3448
|
-
translateEnum =
|
|
3458
|
+
translateEnum = TranslatableString11.UnsupportedFieldWithId;
|
|
3449
3459
|
translateParams.push(fieldPathId.$id);
|
|
3450
3460
|
}
|
|
3451
3461
|
if (reason) {
|
|
3452
|
-
translateEnum = translateEnum ===
|
|
3462
|
+
translateEnum = translateEnum === TranslatableString11.UnsupportedField ? TranslatableString11.UnsupportedFieldWithReason : TranslatableString11.UnsupportedFieldWithIdAndReason;
|
|
3453
3463
|
translateParams.push(reason);
|
|
3454
3464
|
}
|
|
3455
3465
|
return /* @__PURE__ */ jsxs13("div", { className: "unsupported-field", children: [
|
|
@@ -3463,7 +3473,7 @@ var UnsupportedField_default = UnsupportedField;
|
|
|
3463
3473
|
import {
|
|
3464
3474
|
ADDITIONAL_PROPERTY_FLAG as ADDITIONAL_PROPERTY_FLAG3,
|
|
3465
3475
|
buttonId as buttonId4,
|
|
3466
|
-
TranslatableString as
|
|
3476
|
+
TranslatableString as TranslatableString12
|
|
3467
3477
|
} from "@rjsf/utils";
|
|
3468
3478
|
import { jsx as jsx38, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
3469
3479
|
function WrapIfAdditionalTemplate(props) {
|
|
@@ -3488,7 +3498,7 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
3488
3498
|
} = props;
|
|
3489
3499
|
const { templates: templates2, translateString } = registry;
|
|
3490
3500
|
const { RemoveButton: RemoveButton2 } = templates2.ButtonTemplates;
|
|
3491
|
-
const keyLabel = translateString(
|
|
3501
|
+
const keyLabel = translateString(TranslatableString12.KeyLabel, [label]);
|
|
3492
3502
|
const additional = ADDITIONAL_PROPERTY_FLAG3 in schema;
|
|
3493
3503
|
const hasDescription = !!rawDescription;
|
|
3494
3504
|
const classNamesList = ["form-group", classNames];
|
|
@@ -3562,7 +3572,7 @@ var templates_default = templates;
|
|
|
3562
3572
|
// src/components/widgets/AltDateWidget.tsx
|
|
3563
3573
|
import {
|
|
3564
3574
|
DateElement,
|
|
3565
|
-
TranslatableString as
|
|
3575
|
+
TranslatableString as TranslatableString13,
|
|
3566
3576
|
useAltDateWidgetProps
|
|
3567
3577
|
} from "@rjsf/utils";
|
|
3568
3578
|
import { jsx as jsx39, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
@@ -3586,8 +3596,8 @@ function AltDateWidget(props) {
|
|
|
3586
3596
|
autofocus: autofocus && i === 0
|
|
3587
3597
|
}
|
|
3588
3598
|
) }, i)),
|
|
3589
|
-
(options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /* @__PURE__ */ jsx39("li", { className: "list-inline-item", children: /* @__PURE__ */ jsx39("a", { href: "#", className: "btn btn-info btn-now", onClick: handleSetNow, children: translateString(
|
|
3590
|
-
(options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /* @__PURE__ */ jsx39("li", { className: "list-inline-item", children: /* @__PURE__ */ jsx39("a", { href: "#", className: "btn btn-warning btn-clear", onClick: handleClear, children: translateString(
|
|
3599
|
+
(options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /* @__PURE__ */ jsx39("li", { className: "list-inline-item", children: /* @__PURE__ */ jsx39("a", { href: "#", className: "btn btn-info btn-now", onClick: handleSetNow, children: translateString(TranslatableString13.NowLabel) }) }),
|
|
3600
|
+
(options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /* @__PURE__ */ jsx39("li", { className: "list-inline-item", children: /* @__PURE__ */ jsx39("a", { href: "#", className: "btn btn-warning btn-clear", onClick: handleClear, children: translateString(TranslatableString13.ClearLabel) }) })
|
|
3591
3601
|
] });
|
|
3592
3602
|
}
|
|
3593
3603
|
var AltDateWidget_default = AltDateWidget;
|
|
@@ -3810,7 +3820,7 @@ function EmailWidget(props) {
|
|
|
3810
3820
|
// src/components/widgets/FileWidget.tsx
|
|
3811
3821
|
import {
|
|
3812
3822
|
getTemplate as getTemplate22,
|
|
3813
|
-
TranslatableString as
|
|
3823
|
+
TranslatableString as TranslatableString14,
|
|
3814
3824
|
useFileWidgetProps
|
|
3815
3825
|
} from "@rjsf/utils";
|
|
3816
3826
|
import Markdown5 from "markdown-to-jsx";
|
|
@@ -3829,7 +3839,7 @@ function FileInfoPreview({
|
|
|
3829
3839
|
}
|
|
3830
3840
|
return /* @__PURE__ */ jsxs18(Fragment4, { children: [
|
|
3831
3841
|
" ",
|
|
3832
|
-
/* @__PURE__ */ jsx47("a", { download: `preview-${name}`, href: dataURL, className: "file-download", children: translateString(
|
|
3842
|
+
/* @__PURE__ */ jsx47("a", { download: `preview-${name}`, href: dataURL, className: "file-download", children: translateString(TranslatableString14.PreviewLabel) })
|
|
3833
3843
|
] });
|
|
3834
3844
|
}
|
|
3835
3845
|
function FilesInfo({
|
|
@@ -3848,7 +3858,7 @@ function FilesInfo({
|
|
|
3848
3858
|
const { name, size, type } = fileInfo;
|
|
3849
3859
|
const handleRemove = () => onRemove(key);
|
|
3850
3860
|
return /* @__PURE__ */ jsxs18("li", { children: [
|
|
3851
|
-
/* @__PURE__ */ jsx47(Markdown5, { children: translateString(
|
|
3861
|
+
/* @__PURE__ */ jsx47(Markdown5, { children: translateString(TranslatableString14.FilesInfo, [name, type, String(size)]) }),
|
|
3852
3862
|
preview && /* @__PURE__ */ jsx47(FileInfoPreview, { fileInfo, registry }),
|
|
3853
3863
|
/* @__PURE__ */ jsx47(RemoveButton2, { onClick: handleRemove, registry })
|
|
3854
3864
|
] }, key);
|
|
@@ -4752,7 +4762,8 @@ var Form = class extends Component3 {
|
|
|
4752
4762
|
const { newErrorSchema } = this.pendingChanges[0];
|
|
4753
4763
|
const { extraErrors, omitExtraData, liveOmit, noValidate, liveValidate, onChange, removeEmptyOptionalObjects } = this.props;
|
|
4754
4764
|
const { formData: oldFormData, schemaUtils, schema, fieldPathId, schemaValidationErrorSchema, errors } = this.state;
|
|
4755
|
-
let { customErrors
|
|
4765
|
+
let { customErrors } = this.state;
|
|
4766
|
+
let mergeBaseErrorSchema = schemaValidationErrorSchema;
|
|
4756
4767
|
const rootPathId = fieldPathId.path[0] || "";
|
|
4757
4768
|
const isRootPath = !path || path.length === 0 || path.length === 1 && path[0] === rootPathId;
|
|
4758
4769
|
let retrievedSchema = this.state.retrievedSchema;
|
|
@@ -4764,7 +4775,26 @@ var Form = class extends Component3 {
|
|
|
4764
4775
|
if (newValue === ADDITIONAL_PROPERTY_KEY_REMOVE) {
|
|
4765
4776
|
_unset(formData, path);
|
|
4766
4777
|
} else if (!isRootPath) {
|
|
4767
|
-
|
|
4778
|
+
let unsetPath = false;
|
|
4779
|
+
let valueForPath = newValue;
|
|
4780
|
+
if (newValue === void 0) {
|
|
4781
|
+
const lastSegment = path[path.length - 1];
|
|
4782
|
+
if (typeof lastSegment === "number") {
|
|
4783
|
+
valueForPath = null;
|
|
4784
|
+
} else {
|
|
4785
|
+
const { field } = schemaUtils.findFieldInSchema(schema, path, oldFormData);
|
|
4786
|
+
const leaf = field;
|
|
4787
|
+
const isOneOfOrAnyOfLeaf = leaf && (ONE_OF_KEY6 in leaf || ANY_OF_KEY6 in leaf);
|
|
4788
|
+
if (!isOneOfOrAnyOfLeaf && leaf !== void 0) {
|
|
4789
|
+
unsetPath = true;
|
|
4790
|
+
}
|
|
4791
|
+
}
|
|
4792
|
+
}
|
|
4793
|
+
if (unsetPath) {
|
|
4794
|
+
_unset(formData, path);
|
|
4795
|
+
} else {
|
|
4796
|
+
_set(formData, path, valueForPath);
|
|
4797
|
+
}
|
|
4768
4798
|
}
|
|
4769
4799
|
const newState = this.getStateFromProps(this.props, inputForDefaults, void 0, void 0, void 0, true);
|
|
4770
4800
|
formData = newState.formData;
|
|
@@ -4795,9 +4825,10 @@ var Form = class extends Component3 {
|
|
|
4795
4825
|
const oldValidationError = !isRootPath ? _get(schemaValidationErrorSchema, path) : schemaValidationErrorSchema;
|
|
4796
4826
|
if (!_isEmpty(oldValidationError)) {
|
|
4797
4827
|
if (!isRootPath) {
|
|
4798
|
-
|
|
4828
|
+
mergeBaseErrorSchema = _cloneDeep(schemaValidationErrorSchema);
|
|
4829
|
+
_set(mergeBaseErrorSchema, path, newErrorSchema);
|
|
4799
4830
|
} else {
|
|
4800
|
-
|
|
4831
|
+
mergeBaseErrorSchema = newErrorSchema;
|
|
4801
4832
|
}
|
|
4802
4833
|
} else {
|
|
4803
4834
|
if (!customErrors) {
|
|
@@ -4819,7 +4850,7 @@ var Form = class extends Component3 {
|
|
|
4819
4850
|
const liveValidation = this.liveValidate(
|
|
4820
4851
|
schema,
|
|
4821
4852
|
schemaUtils,
|
|
4822
|
-
|
|
4853
|
+
mergeBaseErrorSchema,
|
|
4823
4854
|
newFormData,
|
|
4824
4855
|
extraErrors,
|
|
4825
4856
|
customErrors,
|
|
@@ -4827,7 +4858,7 @@ var Form = class extends Component3 {
|
|
|
4827
4858
|
);
|
|
4828
4859
|
state = { formData: newFormData, ...liveValidation, customErrors };
|
|
4829
4860
|
} else if (!noValidate && newErrorSchema) {
|
|
4830
|
-
const mergedErrors = this.mergeErrors({ errorSchema:
|
|
4861
|
+
const mergedErrors = this.mergeErrors({ errorSchema: mergeBaseErrorSchema, errors }, extraErrors, customErrors);
|
|
4831
4862
|
state = {
|
|
4832
4863
|
formData: newFormData,
|
|
4833
4864
|
...mergedErrors,
|