@apexcura/ui-components 0.0.16-Beta67 → 0.0.16-Beta68

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
@@ -1120,13 +1120,33 @@ var FileUpload = (props) => {
1120
1120
  const { Dragger } = import_antd18.Upload;
1121
1121
  const initialFiles = Array.isArray(props.value) ? props.value : [];
1122
1122
  const [files, setFiles] = (0, import_react27.useState)(initialFiles);
1123
- const handleChange = ({ fileList }) => {
1124
- setFiles(fileList);
1125
- console.log(fileList);
1123
+ const getDimensions = (file) => {
1124
+ return new Promise((resolve) => {
1125
+ const img = new Image();
1126
+ img.onload = () => {
1127
+ resolve({ width: img.width, height: img.height });
1128
+ };
1129
+ img.src = URL.createObjectURL(file);
1130
+ });
1131
+ };
1132
+ const handleChange = async ({ fileList }) => {
1133
+ const updatedFileList = await Promise.all(
1134
+ fileList.map(async (file) => {
1135
+ if (file.originFileObj) {
1136
+ const dimensions = await getDimensions(file.originFileObj);
1137
+ return {
1138
+ ...file,
1139
+ dimensions
1140
+ };
1141
+ }
1142
+ return file;
1143
+ })
1144
+ );
1145
+ setFiles(updatedFileList);
1126
1146
  if (props.onChange) {
1127
1147
  props.onChange({
1128
1148
  name: props.name,
1129
- value: fileList
1149
+ value: updatedFileList
1130
1150
  });
1131
1151
  }
1132
1152
  };
@@ -1138,22 +1158,6 @@ var FileUpload = (props) => {
1138
1158
  }
1139
1159
  }, 0);
1140
1160
  };
1141
- const onPreview = async (file) => {
1142
- let src = file.url;
1143
- if (!src) {
1144
- src = await new Promise((resolve) => {
1145
- const reader = new FileReader();
1146
- reader.readAsDataURL(file.originFileObj);
1147
- reader.onload = () => resolve(reader.result);
1148
- });
1149
- }
1150
- const image = new Image();
1151
- image.src = src;
1152
- const imgWindow = window.open(src);
1153
- if (imgWindow) {
1154
- imgWindow.document.write(image.outerHTML);
1155
- }
1156
- };
1157
1161
  return /* @__PURE__ */ import_react27.default.createElement("div", null, /* @__PURE__ */ import_react27.default.createElement(
1158
1162
  Dragger,
1159
1163
  {
@@ -1164,12 +1168,8 @@ var FileUpload = (props) => {
1164
1168
  multiple: props.multiple,
1165
1169
  fileList: files,
1166
1170
  onChange: handleChange,
1167
- showUploadList: {
1168
- showPreviewIcon: true,
1169
- showRemoveIcon: true
1170
- },
1171
- customRequest,
1172
- onPreview
1171
+ showUploadList: true,
1172
+ customRequest
1173
1173
  },
1174
1174
  /* @__PURE__ */ import_react27.default.createElement("p", null, /* @__PURE__ */ import_react27.default.createElement(import_icons5.InboxOutlined, null)),
1175
1175
  /* @__PURE__ */ import_react27.default.createElement("p", null, "Click or drag file to upload")
package/dist/index.mjs CHANGED
@@ -1048,13 +1048,33 @@ var FileUpload = (props) => {
1048
1048
  const { Dragger } = Upload;
1049
1049
  const initialFiles = Array.isArray(props.value) ? props.value : [];
1050
1050
  const [files, setFiles] = useState8(initialFiles);
1051
- const handleChange = ({ fileList }) => {
1052
- setFiles(fileList);
1053
- console.log(fileList);
1051
+ const getDimensions = (file) => {
1052
+ return new Promise((resolve) => {
1053
+ const img = new Image();
1054
+ img.onload = () => {
1055
+ resolve({ width: img.width, height: img.height });
1056
+ };
1057
+ img.src = URL.createObjectURL(file);
1058
+ });
1059
+ };
1060
+ const handleChange = async ({ fileList }) => {
1061
+ const updatedFileList = await Promise.all(
1062
+ fileList.map(async (file) => {
1063
+ if (file.originFileObj) {
1064
+ const dimensions = await getDimensions(file.originFileObj);
1065
+ return {
1066
+ ...file,
1067
+ dimensions
1068
+ };
1069
+ }
1070
+ return file;
1071
+ })
1072
+ );
1073
+ setFiles(updatedFileList);
1054
1074
  if (props.onChange) {
1055
1075
  props.onChange({
1056
1076
  name: props.name,
1057
- value: fileList
1077
+ value: updatedFileList
1058
1078
  });
1059
1079
  }
1060
1080
  };
@@ -1066,22 +1086,6 @@ var FileUpload = (props) => {
1066
1086
  }
1067
1087
  }, 0);
1068
1088
  };
1069
- const onPreview = async (file) => {
1070
- let src = file.url;
1071
- if (!src) {
1072
- src = await new Promise((resolve) => {
1073
- const reader = new FileReader();
1074
- reader.readAsDataURL(file.originFileObj);
1075
- reader.onload = () => resolve(reader.result);
1076
- });
1077
- }
1078
- const image = new Image();
1079
- image.src = src;
1080
- const imgWindow = window.open(src);
1081
- if (imgWindow) {
1082
- imgWindow.document.write(image.outerHTML);
1083
- }
1084
- };
1085
1089
  return /* @__PURE__ */ React26.createElement("div", null, /* @__PURE__ */ React26.createElement(
1086
1090
  Dragger,
1087
1091
  {
@@ -1092,12 +1096,8 @@ var FileUpload = (props) => {
1092
1096
  multiple: props.multiple,
1093
1097
  fileList: files,
1094
1098
  onChange: handleChange,
1095
- showUploadList: {
1096
- showPreviewIcon: true,
1097
- showRemoveIcon: true
1098
- },
1099
- customRequest,
1100
- onPreview
1099
+ showUploadList: true,
1100
+ customRequest
1101
1101
  },
1102
1102
  /* @__PURE__ */ React26.createElement("p", null, /* @__PURE__ */ React26.createElement(InboxOutlined, null)),
1103
1103
  /* @__PURE__ */ React26.createElement("p", null, "Click or drag file to upload")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apexcura/ui-components",
3
- "version": "0.0.16-Beta67",
3
+ "version": "0.0.16-Beta68",
4
4
  "description": "Apex cura React components library",
5
5
  "keywords": [
6
6
  "apex cura",