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