albinasoft-ui-package 1.1.53 → 1.1.55
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.
@@ -61,6 +61,8 @@ export interface CustomFileUploaderProps {
|
|
61
61
|
* Bu, yükleme işlemi başladığında ve bittiğinde çağrılabilir.
|
62
62
|
*/
|
63
63
|
onUploadingChange?: (uploading: boolean) => void;
|
64
|
+
/** Paket içindeki tüm toast çağrıları bu containerId'ye yönlendirilecek. Opsiyoneldir. */
|
65
|
+
toastContainerId?: string;
|
64
66
|
}
|
65
67
|
export type CustomFileUploaderHandle = {
|
66
68
|
/** Pending dosya varsa toast gösterir ve false döner. */
|
@@ -85,6 +85,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
85
85
|
exports.defaultTranslations = exports.AllowedTypes = void 0;
|
86
86
|
// CustomFileUploader.tsx
|
87
87
|
var react_1 = __importStar(require("react"));
|
88
|
+
// import { toast } from "react-toastify";
|
88
89
|
var react_toastify_1 = require("react-toastify");
|
89
90
|
var fa_1 = require("react-icons/fa");
|
90
91
|
var CustomButton_1 = __importDefault(require("./CustomButton"));
|
@@ -223,7 +224,8 @@ var isAllowedFileType = function (file, allowedType) {
|
|
223
224
|
// CustomFileUploader Bileşeni
|
224
225
|
// ====================
|
225
226
|
var CustomFileUploader = (0, react_1.forwardRef)(function (props, ref) {
|
226
|
-
var url = props.url, multi = props.multi, allowedTypes = props.allowedTypes, maxFile = props.maxFile, maxSize = props.maxSize, onUploadComplete = props.onUploadComplete, onRemoveUploaded = props.onRemoveUploaded, label = props.label, onPendingChange = props.onPendingChange, translations = props.translations, clearTrigger = props.clearTrigger, onUploadingChange = props.onUploadingChange;
|
227
|
+
var url = props.url, multi = props.multi, allowedTypes = props.allowedTypes, maxFile = props.maxFile, maxSize = props.maxSize, onUploadComplete = props.onUploadComplete, onRemoveUploaded = props.onRemoveUploaded, label = props.label, onPendingChange = props.onPendingChange, translations = props.translations, clearTrigger = props.clearTrigger, onUploadingChange = props.onUploadingChange, toastContainerId = props.toastContainerId;
|
228
|
+
var toastOpts = toastContainerId ? { containerId: toastContainerId } : undefined;
|
227
229
|
// Varsayılan çeviri metinlerini, gelen prop ile birleştiriyoruz.
|
228
230
|
var finalTranslations = __assign(__assign({}, exports.defaultTranslations), translations);
|
229
231
|
var _a = (0, react_1.useState)([]), previews = _a[0], setPreviews = _a[1];
|
@@ -233,7 +235,7 @@ var CustomFileUploader = (0, react_1.forwardRef)(function (props, ref) {
|
|
233
235
|
validateReady: function () {
|
234
236
|
var hasPending = previews.some(function (p) { return !p.uploaded; });
|
235
237
|
if (hasPending) {
|
236
|
-
react_toastify_1.toast.warning(finalTranslations.pendingBeforeSubmitWarning || exports.defaultTranslations.pendingBeforeSubmitWarning);
|
238
|
+
react_toastify_1.toast.warning(finalTranslations.pendingBeforeSubmitWarning || exports.defaultTranslations.pendingBeforeSubmitWarning, toastOpts);
|
237
239
|
return false;
|
238
240
|
}
|
239
241
|
return true;
|
@@ -280,22 +282,22 @@ var CustomFileUploader = (0, react_1.forwardRef)(function (props, ref) {
|
|
280
282
|
var currentCount = multi ? previews.length : (previews.length > 0 ? 1 : 0);
|
281
283
|
var availableSlots = multi ? maxFile - currentCount : (currentCount === 0 ? 1 : 0);
|
282
284
|
if (availableSlots <= 0) {
|
283
|
-
react_toastify_1.toast.warning(finalTranslations.uploadWarningLimit);
|
285
|
+
react_toastify_1.toast.warning(finalTranslations.uploadWarningLimit, toastOpts);
|
284
286
|
return;
|
285
287
|
}
|
286
288
|
var filesToAdd = filesArray.slice(0, availableSlots);
|
287
289
|
if (filesArray.length > availableSlots) {
|
288
|
-
react_toastify_1.toast.warning(finalTranslations.uploadWarningExceed + availableSlots);
|
290
|
+
react_toastify_1.toast.warning(finalTranslations.uploadWarningExceed + availableSlots, toastOpts);
|
289
291
|
}
|
290
292
|
var newPreviews = [];
|
291
293
|
filesToAdd.forEach(function (file, index) {
|
292
294
|
if (file.size > maxSize) {
|
293
295
|
// Dosya adını eklemek için file.name'i dışarıda ekliyoruz.
|
294
|
-
react_toastify_1.toast.error(file.name + " " + finalTranslations.fileSizeError);
|
296
|
+
react_toastify_1.toast.error(file.name + " " + finalTranslations.fileSizeError, toastOpts);
|
295
297
|
return;
|
296
298
|
}
|
297
299
|
if (!isAllowedFileType(file, allowedTypes)) {
|
298
|
-
react_toastify_1.toast.error(file.name + " " + finalTranslations.fileTypeError);
|
300
|
+
react_toastify_1.toast.error(file.name + " " + finalTranslations.fileTypeError, toastOpts);
|
299
301
|
return;
|
300
302
|
}
|
301
303
|
var isImg = allowedTypes === AllowedTypes.IMAGE || (allowedTypes === AllowedTypes.VISUAL && isImageFile(file));
|
@@ -357,7 +359,7 @@ var CustomFileUploader = (0, react_1.forwardRef)(function (props, ref) {
|
|
357
359
|
onUploadingChange === null || onUploadingChange === void 0 ? void 0 : onUploadingChange(true);
|
358
360
|
filesToUpload = previews.filter(function (item) { return !item.uploaded; }).map(function (item) { return item.file; });
|
359
361
|
if (filesToUpload.length === 0) {
|
360
|
-
react_toastify_1.toast.warning(finalTranslations.noFileSelectedWarning);
|
362
|
+
react_toastify_1.toast.warning(finalTranslations.noFileSelectedWarning, toastOpts);
|
361
363
|
return [2 /*return*/];
|
362
364
|
}
|
363
365
|
// Yüklenmeye başlayan dosyaları işaretle
|
@@ -401,23 +403,23 @@ var CustomFileUploader = (0, react_1.forwardRef)(function (props, ref) {
|
|
401
403
|
updatePendingStatus(updatedPreviews);
|
402
404
|
return updatedPreviews;
|
403
405
|
});
|
404
|
-
react_toastify_1.toast.success(finalTranslations.uploadSuccessToast);
|
406
|
+
react_toastify_1.toast.success(finalTranslations.uploadSuccessToast, toastOpts);
|
405
407
|
}
|
406
408
|
else {
|
407
|
-
react_toastify_1.toast.error(finalTranslations.uploadErrorToast);
|
409
|
+
react_toastify_1.toast.error(finalTranslations.uploadErrorToast, toastOpts);
|
408
410
|
}
|
409
411
|
return [3 /*break*/, 6];
|
410
412
|
case 4: return [4 /*yield*/, response.json()];
|
411
413
|
case 5:
|
412
414
|
errorData = _a.sent();
|
413
415
|
console.error("API Hatası:", errorData);
|
414
|
-
react_toastify_1.toast.error(finalTranslations.uploadErrorToast);
|
416
|
+
react_toastify_1.toast.error(finalTranslations.uploadErrorToast, toastOpts);
|
415
417
|
_a.label = 6;
|
416
418
|
case 6: return [3 /*break*/, 9];
|
417
419
|
case 7:
|
418
420
|
error_1 = _a.sent();
|
419
421
|
console.error("API çağrısında hata:", error_1);
|
420
|
-
react_toastify_1.toast.error(finalTranslations.uploadErrorToast);
|
422
|
+
react_toastify_1.toast.error(finalTranslations.uploadErrorToast, toastOpts);
|
421
423
|
return [3 /*break*/, 9];
|
422
424
|
case 8:
|
423
425
|
onUploadingChange === null || onUploadingChange === void 0 ? void 0 : onUploadingChange(false);
|
@@ -264,7 +264,7 @@ var CustomForm = function (_a) {
|
|
264
264
|
} }))) : element.type === ElementType.DATETIMEPICKER ? (react_1.default.createElement(CustomDateTimePicker_1.default, __assign({}, element, { submitted: submitted }))) : element.type === ElementType.DIVIDER ? (react_1.default.createElement(CustomDivider_1.default, __assign({}, element))) : element.type === ElementType.RICHTEXTBOX ? (react_1.default.createElement(CustomRichTextbox_1.default, __assign({}, element))) : element.type === ElementType.TREEVIEW ? (react_1.default.createElement(CustomTreeView_1.default, __assign({}, element, { submitted: submitted }))) : element.type === ElementType.BUTTON ? (react_1.default.createElement(CustomButton_1.default, __assign({}, element, { isLoading: isLoading }))) : element.type === ElementType.AUTOCOMPLETEINPUT ? (react_1.default.createElement(CustomAutocompleteInput_1.default, __assign({}, element))) : element.type === ElementType.PHONE ? (react_1.default.createElement(CustomPhoneInput_1.default, __assign({}, element))) : element.type === ElementType.FILEUPLOADER ? (
|
265
265
|
// FILEUPLOADER elemanı için CustomFileUploader'ı render ediyoruz
|
266
266
|
react_1.default.createElement(react_1.default.Fragment, null,
|
267
|
-
react_1.default.createElement(CustomFileUploader_1.default, { ref: getUploaderRefCb(element.id), url: element.url, multi: element.multi, allowedTypes: element.allowedTypes, maxFile: element.maxFile, maxSize: element.maxSize, onUploadComplete: element.onUploadComplete, onRemoveUploaded: element.onRemoveUploaded, onPendingChange: element.onPendingChange, clearTrigger: element.clearTrigger, label: element.label, translations: element.translations, onUploadingChange: setIsUploading }))) : null)); })));
|
267
|
+
react_1.default.createElement(CustomFileUploader_1.default, { ref: getUploaderRefCb(element.id), url: element.url, multi: element.multi, allowedTypes: element.allowedTypes, maxFile: element.maxFile, maxSize: element.maxSize, onUploadComplete: element.onUploadComplete, onRemoveUploaded: element.onRemoveUploaded, onPendingChange: element.onPendingChange, clearTrigger: element.clearTrigger, label: element.label, translations: element.translations, onUploadingChange: setIsUploading, toastContainerId: "global-toaster" }))) : null)); })));
|
268
268
|
})));
|
269
269
|
})));
|
270
270
|
}),
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "albinasoft-ui-package",
|
3
|
-
"version": "1.1.
|
3
|
+
"version": "1.1.55",
|
4
4
|
"main": "dist/index.js",
|
5
5
|
"types": "dist/index.d.ts",
|
6
6
|
"scripts": {
|
@@ -15,17 +15,17 @@
|
|
15
15
|
"date-fns": "^4.1.0",
|
16
16
|
"date-fns-tz": "^3.2.0",
|
17
17
|
"quill": "^2.0.3",
|
18
|
-
"react": "^18.0.0",
|
19
18
|
"react-bootstrap": "^2.10.6",
|
20
19
|
"react-checkbox-tree": "^1.8.0",
|
21
20
|
"react-datepicker": "^7.6.0",
|
22
|
-
"react-dom": "^18.0.0",
|
23
21
|
"react-icons": "^4.12.0",
|
24
22
|
"react-input-mask": "^2.0.4",
|
25
|
-
"react-router-dom": "^7.1.1"
|
26
|
-
"react-toastify": "^10.0.6"
|
23
|
+
"react-router-dom": "^7.1.1"
|
27
24
|
},
|
28
25
|
"devDependencies": {
|
26
|
+
"react": "^18.0.0",
|
27
|
+
"react-dom": "^18.0.0",
|
28
|
+
"react-toastify": "^10.0.6",
|
29
29
|
"@types/react": "^19.0.1",
|
30
30
|
"@types/react-bootstrap": "^0.32.37",
|
31
31
|
"@types/react-input-mask": "^3.0.6",
|
@@ -34,7 +34,8 @@
|
|
34
34
|
},
|
35
35
|
"peerDependencies": {
|
36
36
|
"react": "^18.0.0",
|
37
|
-
"react-dom": "^18.0.0"
|
37
|
+
"react-dom": "^18.0.0",
|
38
|
+
"react-toastify": "^10.0.0"
|
38
39
|
},
|
39
40
|
"files": [
|
40
41
|
"dist"
|