@rjsf/core 5.16.1 → 5.17.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 +46 -15
- package/dist/index.esm.js +51 -18
- package/dist/index.esm.js.map +3 -3
- package/dist/index.js +46 -15
- package/dist/index.js.map +2 -2
- 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/MultiSchemaField.tsx +34 -6
- package/src/components/widgets/FileWidget.tsx +25 -11
package/dist/core.umd.js
CHANGED
|
@@ -986,12 +986,33 @@
|
|
|
986
986
|
const { required } = schema;
|
|
987
987
|
optionSchema = required ? utils.mergeSchemas({ required }, option) : option;
|
|
988
988
|
}
|
|
989
|
+
let optionsUiSchema = [];
|
|
990
|
+
if (utils.ONE_OF_KEY in schema && uiSchema && utils.ONE_OF_KEY in uiSchema) {
|
|
991
|
+
if (Array.isArray(uiSchema[utils.ONE_OF_KEY])) {
|
|
992
|
+
optionsUiSchema = uiSchema[utils.ONE_OF_KEY];
|
|
993
|
+
} else {
|
|
994
|
+
console.warn(`uiSchema.oneOf is not an array for "${title || name}"`);
|
|
995
|
+
}
|
|
996
|
+
} else if (utils.ANY_OF_KEY in schema && uiSchema && utils.ANY_OF_KEY in uiSchema) {
|
|
997
|
+
if (Array.isArray(uiSchema[utils.ANY_OF_KEY])) {
|
|
998
|
+
optionsUiSchema = uiSchema[utils.ANY_OF_KEY];
|
|
999
|
+
} else {
|
|
1000
|
+
console.warn(`uiSchema.anyOf is not an array for "${title || name}"`);
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
let optionUiSchema = uiSchema;
|
|
1004
|
+
if (selectedOption >= 0 && optionsUiSchema.length > selectedOption) {
|
|
1005
|
+
optionUiSchema = optionsUiSchema[selectedOption];
|
|
1006
|
+
}
|
|
989
1007
|
const translateEnum = title ? utils.TranslatableString.TitleOptionPrefix : utils.TranslatableString.OptionPrefix;
|
|
990
1008
|
const translateParams = title ? [title] : [];
|
|
991
|
-
const enumOptions = retrievedOptions.map((opt, index) =>
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
1009
|
+
const enumOptions = retrievedOptions.map((opt, index) => {
|
|
1010
|
+
const { title: uiTitle = opt.title } = utils.getUiOptions(optionsUiSchema[index]);
|
|
1011
|
+
return {
|
|
1012
|
+
label: uiTitle || translateString(translateEnum, translateParams.concat(String(index + 1))),
|
|
1013
|
+
value: index
|
|
1014
|
+
};
|
|
1015
|
+
});
|
|
995
1016
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "panel panel-default panel-body", children: [
|
|
996
1017
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "form-group", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
997
1018
|
Widget,
|
|
@@ -1017,7 +1038,7 @@
|
|
|
1017
1038
|
hideLabel: !displayLabel
|
|
1018
1039
|
}
|
|
1019
1040
|
) }),
|
|
1020
|
-
|
|
1041
|
+
optionSchema && /* @__PURE__ */ jsxRuntime.jsx(_SchemaField, { ...this.props, schema: optionSchema, uiSchema: optionUiSchema })
|
|
1021
1042
|
] });
|
|
1022
1043
|
}
|
|
1023
1044
|
};
|
|
@@ -2588,7 +2609,7 @@
|
|
|
2588
2609
|
if (!dataURL) {
|
|
2589
2610
|
return null;
|
|
2590
2611
|
}
|
|
2591
|
-
if (
|
|
2612
|
+
if (["image/jpeg", "image/png"].includes(type)) {
|
|
2592
2613
|
return /* @__PURE__ */ jsxRuntime.jsx("img", { src: dataURL, style: { maxWidth: "100%" }, className: "file-preview" });
|
|
2593
2614
|
}
|
|
2594
2615
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
@@ -2619,15 +2640,25 @@
|
|
|
2619
2640
|
}) });
|
|
2620
2641
|
}
|
|
2621
2642
|
function extractFileInfo(dataURLs) {
|
|
2622
|
-
return dataURLs.
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2643
|
+
return dataURLs.reduce((acc, dataURL) => {
|
|
2644
|
+
if (!dataURL) {
|
|
2645
|
+
return acc;
|
|
2646
|
+
}
|
|
2647
|
+
try {
|
|
2648
|
+
const { blob, name } = utils.dataURItoBlob(dataURL);
|
|
2649
|
+
return [
|
|
2650
|
+
...acc,
|
|
2651
|
+
{
|
|
2652
|
+
dataURL,
|
|
2653
|
+
name,
|
|
2654
|
+
size: blob.size,
|
|
2655
|
+
type: blob.type
|
|
2656
|
+
}
|
|
2657
|
+
];
|
|
2658
|
+
} catch (e) {
|
|
2659
|
+
return acc;
|
|
2660
|
+
}
|
|
2661
|
+
}, []);
|
|
2631
2662
|
}
|
|
2632
2663
|
function FileWidget(props) {
|
|
2633
2664
|
const { disabled, readonly, required, multiple, onChange, value, options, registry } = props;
|
package/dist/index.esm.js
CHANGED
|
@@ -918,12 +918,14 @@ import get2 from "lodash/get";
|
|
|
918
918
|
import isEmpty from "lodash/isEmpty";
|
|
919
919
|
import omit from "lodash/omit";
|
|
920
920
|
import {
|
|
921
|
+
ANY_OF_KEY,
|
|
921
922
|
deepEquals,
|
|
922
923
|
ERRORS_KEY,
|
|
923
924
|
getDiscriminatorFieldFromSchema,
|
|
924
925
|
getUiOptions as getUiOptions3,
|
|
925
926
|
getWidget as getWidget3,
|
|
926
927
|
mergeSchemas,
|
|
928
|
+
ONE_OF_KEY,
|
|
927
929
|
TranslatableString as TranslatableString3
|
|
928
930
|
} from "@rjsf/utils";
|
|
929
931
|
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
@@ -1050,12 +1052,33 @@ var AnyOfField = class extends Component2 {
|
|
|
1050
1052
|
const { required } = schema;
|
|
1051
1053
|
optionSchema = required ? mergeSchemas({ required }, option) : option;
|
|
1052
1054
|
}
|
|
1055
|
+
let optionsUiSchema = [];
|
|
1056
|
+
if (ONE_OF_KEY in schema && uiSchema && ONE_OF_KEY in uiSchema) {
|
|
1057
|
+
if (Array.isArray(uiSchema[ONE_OF_KEY])) {
|
|
1058
|
+
optionsUiSchema = uiSchema[ONE_OF_KEY];
|
|
1059
|
+
} else {
|
|
1060
|
+
console.warn(`uiSchema.oneOf is not an array for "${title || name}"`);
|
|
1061
|
+
}
|
|
1062
|
+
} else if (ANY_OF_KEY in schema && uiSchema && ANY_OF_KEY in uiSchema) {
|
|
1063
|
+
if (Array.isArray(uiSchema[ANY_OF_KEY])) {
|
|
1064
|
+
optionsUiSchema = uiSchema[ANY_OF_KEY];
|
|
1065
|
+
} else {
|
|
1066
|
+
console.warn(`uiSchema.anyOf is not an array for "${title || name}"`);
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
let optionUiSchema = uiSchema;
|
|
1070
|
+
if (selectedOption >= 0 && optionsUiSchema.length > selectedOption) {
|
|
1071
|
+
optionUiSchema = optionsUiSchema[selectedOption];
|
|
1072
|
+
}
|
|
1053
1073
|
const translateEnum = title ? TranslatableString3.TitleOptionPrefix : TranslatableString3.OptionPrefix;
|
|
1054
1074
|
const translateParams = title ? [title] : [];
|
|
1055
|
-
const enumOptions = retrievedOptions.map((opt, index) =>
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1075
|
+
const enumOptions = retrievedOptions.map((opt, index) => {
|
|
1076
|
+
const { title: uiTitle = opt.title } = getUiOptions3(optionsUiSchema[index]);
|
|
1077
|
+
return {
|
|
1078
|
+
label: uiTitle || translateString(translateEnum, translateParams.concat(String(index + 1))),
|
|
1079
|
+
value: index
|
|
1080
|
+
};
|
|
1081
|
+
});
|
|
1059
1082
|
return /* @__PURE__ */ jsxs("div", { className: "panel panel-default panel-body", children: [
|
|
1060
1083
|
/* @__PURE__ */ jsx3("div", { className: "form-group", children: /* @__PURE__ */ jsx3(
|
|
1061
1084
|
Widget,
|
|
@@ -1081,7 +1104,7 @@ var AnyOfField = class extends Component2 {
|
|
|
1081
1104
|
hideLabel: !displayLabel
|
|
1082
1105
|
}
|
|
1083
1106
|
) }),
|
|
1084
|
-
|
|
1107
|
+
optionSchema && /* @__PURE__ */ jsx3(_SchemaField, { ...this.props, schema: optionSchema, uiSchema: optionUiSchema })
|
|
1085
1108
|
] });
|
|
1086
1109
|
}
|
|
1087
1110
|
};
|
|
@@ -1129,8 +1152,8 @@ import {
|
|
|
1129
1152
|
ADDITIONAL_PROPERTY_FLAG,
|
|
1130
1153
|
PROPERTIES_KEY,
|
|
1131
1154
|
REF_KEY,
|
|
1132
|
-
ANY_OF_KEY,
|
|
1133
|
-
ONE_OF_KEY
|
|
1155
|
+
ANY_OF_KEY as ANY_OF_KEY2,
|
|
1156
|
+
ONE_OF_KEY as ONE_OF_KEY2
|
|
1134
1157
|
} from "@rjsf/utils";
|
|
1135
1158
|
import Markdown from "markdown-to-jsx";
|
|
1136
1159
|
import get3 from "lodash/get";
|
|
@@ -1256,7 +1279,7 @@ var ObjectField = class extends Component3 {
|
|
|
1256
1279
|
apSchema = schemaUtils.retrieveSchema({ $ref: apSchema[REF_KEY] }, formData);
|
|
1257
1280
|
type = apSchema.type;
|
|
1258
1281
|
}
|
|
1259
|
-
if (!type && (
|
|
1282
|
+
if (!type && (ANY_OF_KEY2 in apSchema || ONE_OF_KEY2 in apSchema)) {
|
|
1260
1283
|
type = "object";
|
|
1261
1284
|
}
|
|
1262
1285
|
}
|
|
@@ -2881,7 +2904,7 @@ function FileInfoPreview({
|
|
|
2881
2904
|
if (!dataURL) {
|
|
2882
2905
|
return null;
|
|
2883
2906
|
}
|
|
2884
|
-
if (
|
|
2907
|
+
if (["image/jpeg", "image/png"].includes(type)) {
|
|
2885
2908
|
return /* @__PURE__ */ jsx34("img", { src: dataURL, style: { maxWidth: "100%" }, className: "file-preview" });
|
|
2886
2909
|
}
|
|
2887
2910
|
return /* @__PURE__ */ jsxs17(Fragment3, { children: [
|
|
@@ -2912,15 +2935,25 @@ function FilesInfo({
|
|
|
2912
2935
|
}) });
|
|
2913
2936
|
}
|
|
2914
2937
|
function extractFileInfo(dataURLs) {
|
|
2915
|
-
return dataURLs.
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2938
|
+
return dataURLs.reduce((acc, dataURL) => {
|
|
2939
|
+
if (!dataURL) {
|
|
2940
|
+
return acc;
|
|
2941
|
+
}
|
|
2942
|
+
try {
|
|
2943
|
+
const { blob, name } = dataURItoBlob(dataURL);
|
|
2944
|
+
return [
|
|
2945
|
+
...acc,
|
|
2946
|
+
{
|
|
2947
|
+
dataURL,
|
|
2948
|
+
name,
|
|
2949
|
+
size: blob.size,
|
|
2950
|
+
type: blob.type
|
|
2951
|
+
}
|
|
2952
|
+
];
|
|
2953
|
+
} catch (e) {
|
|
2954
|
+
return acc;
|
|
2955
|
+
}
|
|
2956
|
+
}, []);
|
|
2924
2957
|
}
|
|
2925
2958
|
function FileWidget(props) {
|
|
2926
2959
|
const { disabled, readonly, required, multiple, onChange, value, options, registry } = props;
|