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