px-react-ui-components 1.1.24 → 1.1.26
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.
|
@@ -20,8 +20,13 @@ let Resizer, Camera, FACING_MODES, IMAGE_TYPES;
|
|
|
20
20
|
let hasImageResizer = false;
|
|
21
21
|
let hasCamera = false;
|
|
22
22
|
try {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
const raw = require("react-image-file-resizer");
|
|
24
|
+
// Vite/ESM: default export is { default: { imageFileResizer } }; CJS often { imageFileResizer }
|
|
25
|
+
const resolved = raw && (raw.default ?? raw);
|
|
26
|
+
if (resolved && typeof resolved.imageFileResizer === "function") {
|
|
27
|
+
Resizer = resolved;
|
|
28
|
+
hasImageResizer = true;
|
|
29
|
+
}
|
|
25
30
|
} catch (error) {
|
|
26
31
|
console.warn("MyFileUpload: react-image-file-resizer bağımlılığı bulunamadı.");
|
|
27
32
|
}
|
|
@@ -46,11 +51,15 @@ const MyFileUploadAcceptType = exports.MyFileUploadAcceptType = {
|
|
|
46
51
|
Object.freeze(MyFileUploadAcceptType);
|
|
47
52
|
function MyFileUpload({
|
|
48
53
|
t = null,
|
|
54
|
+
name = null,
|
|
55
|
+
required = false,
|
|
49
56
|
multiple = false,
|
|
50
57
|
accept = MyFileUploadAcceptType.ALL,
|
|
51
58
|
camera = true,
|
|
52
59
|
maxSizeMB = 50,
|
|
53
60
|
onData,
|
|
61
|
+
label = null,
|
|
62
|
+
labelClassName = null,
|
|
54
63
|
className = null,
|
|
55
64
|
classNameContainer = null,
|
|
56
65
|
classNameItem = null,
|
|
@@ -113,7 +122,20 @@ function MyFileUpload({
|
|
|
113
122
|
});
|
|
114
123
|
(0, _MyAlert.MyAlert)("<br/><br/><div style='display: block;font-size:13px;width: 100%;text-align: left;'>" + message + "</div>", _MyAlert.MyAlertType.WARNING);
|
|
115
124
|
}
|
|
116
|
-
if (onData && (Array.isArray(resdata) && resdata.length > 0 || !Array.isArray(resdata) && resdata))
|
|
125
|
+
if (onData && (Array.isArray(resdata) && resdata.length > 0 || !Array.isArray(resdata) && resdata)) {
|
|
126
|
+
if (name) {
|
|
127
|
+
onData({
|
|
128
|
+
target: {
|
|
129
|
+
name: name,
|
|
130
|
+
files: Array.isArray(resdata) ? resdata : [resdata],
|
|
131
|
+
value: Array.isArray(resdata) ? resdata : [resdata]
|
|
132
|
+
},
|
|
133
|
+
value: Array.isArray(resdata) ? resdata : [resdata]
|
|
134
|
+
});
|
|
135
|
+
} else {
|
|
136
|
+
onData(resdata);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
117
139
|
setLoading(false);
|
|
118
140
|
};
|
|
119
141
|
const getBase64 = (files, callback = null) => {
|
|
@@ -150,7 +172,7 @@ function MyFileUpload({
|
|
|
150
172
|
continue;
|
|
151
173
|
}
|
|
152
174
|
let extension_type = type_image.indexOf(file_ext) > -1 ? "image" : "file";
|
|
153
|
-
if (extension_type == "file") {
|
|
175
|
+
if (extension_type == "file" || !hasImageResizer) {
|
|
154
176
|
const reader = new FileReader();
|
|
155
177
|
reader.onload = function () {
|
|
156
178
|
let fileitem = {
|
|
@@ -246,9 +268,31 @@ function MyFileUpload({
|
|
|
246
268
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_MyWaiting.default, {
|
|
247
269
|
show: loading,
|
|
248
270
|
message: ""
|
|
249
|
-
}), /*#__PURE__*/(0, _jsxRuntime.
|
|
250
|
-
|
|
251
|
-
|
|
271
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
272
|
+
style: {
|
|
273
|
+
display: 'flex',
|
|
274
|
+
flexDirection: 'row',
|
|
275
|
+
gap: '1px'
|
|
276
|
+
},
|
|
277
|
+
children: [label && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
278
|
+
style: {
|
|
279
|
+
display: "block",
|
|
280
|
+
fontSize: 11,
|
|
281
|
+
fontWeight: "bold",
|
|
282
|
+
color: "black",
|
|
283
|
+
marginBottom: "0.25rem",
|
|
284
|
+
paddingLeft: "0.5rem",
|
|
285
|
+
textTransform: "uppercase",
|
|
286
|
+
letterSpacing: "0.05em"
|
|
287
|
+
},
|
|
288
|
+
className: labelClassName ? labelClassName : '',
|
|
289
|
+
children: [label, " ", required && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
290
|
+
style: {
|
|
291
|
+
color: 'red'
|
|
292
|
+
},
|
|
293
|
+
children: "*"
|
|
294
|
+
})]
|
|
295
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
252
296
|
className: _MyFileUploadModule.default.myFileUploadContainer + (className != null ? " " + className : ''),
|
|
253
297
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
254
298
|
className: _MyFileUploadModule.default.myFileUploadContainerItem + (classNameItem != null ? " " + classNameItem : ''),
|
|
@@ -301,7 +345,7 @@ function MyFileUpload({
|
|
|
301
345
|
})
|
|
302
346
|
})]
|
|
303
347
|
})]
|
|
304
|
-
})
|
|
348
|
+
})]
|
|
305
349
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_MyModal.default, {
|
|
306
350
|
show: cameraopen,
|
|
307
351
|
onClose: () => setCameraopen(false),
|
|
@@ -317,7 +361,7 @@ function MyFileUpload({
|
|
|
317
361
|
} : undefined
|
|
318
362
|
},
|
|
319
363
|
onTakePhoto: dataUri => {
|
|
320
|
-
console.log(dataUri);
|
|
364
|
+
// console.log(dataUri);
|
|
321
365
|
handleTakePhoto(dataUri);
|
|
322
366
|
},
|
|
323
367
|
onCameraError: handleCameraError,
|