@rjsf/core 5.16.1 → 5.17.1
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 +47 -15
- package/dist/index.esm.js +52 -18
- package/dist/index.esm.js.map +3 -3
- package/dist/index.js +47 -15
- package/dist/index.js.map +2 -2
- package/lib/components/fields/ArrayField.js +1 -0
- package/lib/components/fields/ArrayField.js.map +1 -1
- package/lib/components/fields/MultiSchemaField.js +33 -6
- package/lib/components/fields/MultiSchemaField.js.map +1 -1
- package/lib/components/widgets/FileWidget.js +26 -12
- package/lib/components/widgets/FileWidget.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -11
- package/src/components/fields/ArrayField.tsx +1 -0
- package/src/components/fields/MultiSchemaField.tsx +34 -6
- package/src/components/widgets/FileWidget.tsx +25 -11
package/dist/index.js
CHANGED
|
@@ -724,6 +724,7 @@ var ArrayField = class extends import_react.Component {
|
|
|
724
724
|
uiSchema,
|
|
725
725
|
title: fieldTitle,
|
|
726
726
|
formContext,
|
|
727
|
+
errorSchema,
|
|
727
728
|
rawErrors
|
|
728
729
|
};
|
|
729
730
|
const Template = (0, import_utils.getTemplate)("ArrayFieldTemplate", registry, uiOptions);
|
|
@@ -1050,12 +1051,33 @@ var AnyOfField = class extends import_react2.Component {
|
|
|
1050
1051
|
const { required } = schema;
|
|
1051
1052
|
optionSchema = required ? (0, import_utils3.mergeSchemas)({ required }, option) : option;
|
|
1052
1053
|
}
|
|
1054
|
+
let optionsUiSchema = [];
|
|
1055
|
+
if (import_utils3.ONE_OF_KEY in schema && uiSchema && import_utils3.ONE_OF_KEY in uiSchema) {
|
|
1056
|
+
if (Array.isArray(uiSchema[import_utils3.ONE_OF_KEY])) {
|
|
1057
|
+
optionsUiSchema = uiSchema[import_utils3.ONE_OF_KEY];
|
|
1058
|
+
} else {
|
|
1059
|
+
console.warn(`uiSchema.oneOf is not an array for "${title || name}"`);
|
|
1060
|
+
}
|
|
1061
|
+
} else if (import_utils3.ANY_OF_KEY in schema && uiSchema && import_utils3.ANY_OF_KEY in uiSchema) {
|
|
1062
|
+
if (Array.isArray(uiSchema[import_utils3.ANY_OF_KEY])) {
|
|
1063
|
+
optionsUiSchema = uiSchema[import_utils3.ANY_OF_KEY];
|
|
1064
|
+
} else {
|
|
1065
|
+
console.warn(`uiSchema.anyOf is not an array for "${title || name}"`);
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
let optionUiSchema = uiSchema;
|
|
1069
|
+
if (selectedOption >= 0 && optionsUiSchema.length > selectedOption) {
|
|
1070
|
+
optionUiSchema = optionsUiSchema[selectedOption];
|
|
1071
|
+
}
|
|
1053
1072
|
const translateEnum = title ? import_utils3.TranslatableString.TitleOptionPrefix : import_utils3.TranslatableString.OptionPrefix;
|
|
1054
1073
|
const translateParams = title ? [title] : [];
|
|
1055
|
-
const enumOptions = retrievedOptions.map((opt, index) =>
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1074
|
+
const enumOptions = retrievedOptions.map((opt, index) => {
|
|
1075
|
+
const { title: uiTitle = opt.title } = (0, import_utils3.getUiOptions)(optionsUiSchema[index]);
|
|
1076
|
+
return {
|
|
1077
|
+
label: uiTitle || translateString(translateEnum, translateParams.concat(String(index + 1))),
|
|
1078
|
+
value: index
|
|
1079
|
+
};
|
|
1080
|
+
});
|
|
1059
1081
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "panel panel-default panel-body", children: [
|
|
1060
1082
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "form-group", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1061
1083
|
Widget,
|
|
@@ -1081,7 +1103,7 @@ var AnyOfField = class extends import_react2.Component {
|
|
|
1081
1103
|
hideLabel: !displayLabel
|
|
1082
1104
|
}
|
|
1083
1105
|
) }),
|
|
1084
|
-
|
|
1106
|
+
optionSchema && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(_SchemaField, { ...this.props, schema: optionSchema, uiSchema: optionUiSchema })
|
|
1085
1107
|
] });
|
|
1086
1108
|
}
|
|
1087
1109
|
};
|
|
@@ -2798,7 +2820,7 @@ function FileInfoPreview({
|
|
|
2798
2820
|
if (!dataURL) {
|
|
2799
2821
|
return null;
|
|
2800
2822
|
}
|
|
2801
|
-
if (
|
|
2823
|
+
if (["image/jpeg", "image/png"].includes(type)) {
|
|
2802
2824
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("img", { src: dataURL, style: { maxWidth: "100%" }, className: "file-preview" });
|
|
2803
2825
|
}
|
|
2804
2826
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
|
@@ -2829,15 +2851,25 @@ function FilesInfo({
|
|
|
2829
2851
|
}) });
|
|
2830
2852
|
}
|
|
2831
2853
|
function extractFileInfo(dataURLs) {
|
|
2832
|
-
return dataURLs.
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2854
|
+
return dataURLs.reduce((acc, dataURL) => {
|
|
2855
|
+
if (!dataURL) {
|
|
2856
|
+
return acc;
|
|
2857
|
+
}
|
|
2858
|
+
try {
|
|
2859
|
+
const { blob, name } = (0, import_utils29.dataURItoBlob)(dataURL);
|
|
2860
|
+
return [
|
|
2861
|
+
...acc,
|
|
2862
|
+
{
|
|
2863
|
+
dataURL,
|
|
2864
|
+
name,
|
|
2865
|
+
size: blob.size,
|
|
2866
|
+
type: blob.type
|
|
2867
|
+
}
|
|
2868
|
+
];
|
|
2869
|
+
} catch (e) {
|
|
2870
|
+
return acc;
|
|
2871
|
+
}
|
|
2872
|
+
}, []);
|
|
2841
2873
|
}
|
|
2842
2874
|
function FileWidget(props) {
|
|
2843
2875
|
const { disabled, readonly, required, multiple, onChange, value, options, registry } = props;
|