@sunggang/ui-lib 0.0.1 → 0.0.3
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/index.esm.js
CHANGED
|
@@ -3389,7 +3389,7 @@ function _unsupported_iterable_to_array$2(o, minLen) {
|
|
|
3389
3389
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
|
|
3390
3390
|
}
|
|
3391
3391
|
var DropImage = function(param) {
|
|
3392
|
-
var _param_preview = param.preview, preview = _param_preview === void 0 ? true : _param_preview, setFiles = param.setFiles;
|
|
3392
|
+
var _param_preview = param.preview, preview = _param_preview === void 0 ? true : _param_preview, setFiles = param.setFiles, imageUrls = param.imageUrls;
|
|
3393
3393
|
var _useState = _sliced_to_array$2(useState([]), 2), previewFiles = _useState[0], setPreviewFiles = _useState[1];
|
|
3394
3394
|
var _useDropzone = useDropzone({
|
|
3395
3395
|
accept: {
|
|
@@ -3401,7 +3401,7 @@ var DropImage = function(param) {
|
|
|
3401
3401
|
".jpeg"
|
|
3402
3402
|
]
|
|
3403
3403
|
},
|
|
3404
|
-
maxFiles:
|
|
3404
|
+
maxFiles: 10,
|
|
3405
3405
|
maxSize: 5000000,
|
|
3406
3406
|
onDrop: function(dropFiles) {
|
|
3407
3407
|
var newFiles = [];
|
|
@@ -3415,7 +3415,7 @@ var DropImage = function(param) {
|
|
|
3415
3415
|
setPreviewFiles(newFiles);
|
|
3416
3416
|
});
|
|
3417
3417
|
}
|
|
3418
|
-
}), getRootProps = _useDropzone.getRootProps, getInputProps = _useDropzone.getInputProps
|
|
3418
|
+
}), getRootProps = _useDropzone.getRootProps, getInputProps = _useDropzone.getInputProps; _useDropzone.isDragActive; _useDropzone.isDragAccept; _useDropzone.isDragReject;
|
|
3419
3419
|
return /*#__PURE__*/ jsxs("section", {
|
|
3420
3420
|
className: "w-full",
|
|
3421
3421
|
children: [
|
|
@@ -3429,28 +3429,17 @@ var DropImage = function(param) {
|
|
|
3429
3429
|
children: /*#__PURE__*/ jsx("div", {
|
|
3430
3430
|
className: "w-full bg-gray-light rounded-lg",
|
|
3431
3431
|
children: /*#__PURE__*/ jsx("div", {
|
|
3432
|
-
className: "
|
|
3432
|
+
className: "border-2 border-dashed border-gray-400 rounded-lg bg-gray-100",
|
|
3433
3433
|
children: /*#__PURE__*/ jsxs("div", {
|
|
3434
|
-
className: "flex items-center flex-col p-
|
|
3434
|
+
className: "flex items-center flex-col p-16",
|
|
3435
3435
|
children: [
|
|
3436
|
-
"
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
children: [
|
|
3440
|
-
isDragAccept && /*#__PURE__*/ jsx("p", {
|
|
3441
|
-
children: "All files will be accepted"
|
|
3442
|
-
}),
|
|
3443
|
-
isDragReject && /*#__PURE__*/ jsx("p", {
|
|
3444
|
-
children: "Some files will be rejected"
|
|
3445
|
-
}),
|
|
3446
|
-
!isDragActive && /*#__PURE__*/ jsx("p", {
|
|
3447
|
-
children: "Drop files here to upload"
|
|
3448
|
-
})
|
|
3449
|
-
]
|
|
3436
|
+
/*#__PURE__*/ jsx("p", {
|
|
3437
|
+
className: "font-normal text-sm text-gray-400 py-4",
|
|
3438
|
+
children: "圖片僅支援 png、jpg、jpeg"
|
|
3450
3439
|
}),
|
|
3451
|
-
/*#__PURE__*/ jsx("
|
|
3452
|
-
|
|
3453
|
-
children: "
|
|
3440
|
+
/*#__PURE__*/ jsx("h5", {
|
|
3441
|
+
className: "mb-2 text-xl font-bold tracking-tight text-gray-700",
|
|
3442
|
+
children: "拖曳圖片至此"
|
|
3454
3443
|
})
|
|
3455
3444
|
]
|
|
3456
3445
|
})
|
|
@@ -3460,15 +3449,23 @@ var DropImage = function(param) {
|
|
|
3460
3449
|
]
|
|
3461
3450
|
})),
|
|
3462
3451
|
preview && /*#__PURE__*/ jsx("div", {
|
|
3463
|
-
className: "flex gap-2",
|
|
3464
|
-
children: previewFiles
|
|
3452
|
+
className: "flex pt-2 gap-2",
|
|
3453
|
+
children: (previewFiles === null || previewFiles === void 0 ? void 0 : previewFiles.length) ? previewFiles.length > 0 && previewFiles.map(function(item) {
|
|
3465
3454
|
return /*#__PURE__*/ jsx("div", {
|
|
3466
|
-
className: "w-24 h-24 object-cover",
|
|
3467
3455
|
children: /*#__PURE__*/ jsx("img", {
|
|
3456
|
+
className: "w-24 h-24 object-cover",
|
|
3468
3457
|
src: item === null || item === void 0 ? void 0 : item.preview,
|
|
3469
3458
|
alt: ""
|
|
3470
3459
|
})
|
|
3471
3460
|
}, item === null || item === void 0 ? void 0 : item.uuid);
|
|
3461
|
+
}) : imageUrls && imageUrls.length && imageUrls.map(function(item) {
|
|
3462
|
+
return /*#__PURE__*/ jsx("div", {
|
|
3463
|
+
children: /*#__PURE__*/ jsx("img", {
|
|
3464
|
+
className: "w-24 h-24 object-cover",
|
|
3465
|
+
src: item,
|
|
3466
|
+
alt: ""
|
|
3467
|
+
})
|
|
3468
|
+
}, item);
|
|
3472
3469
|
})
|
|
3473
3470
|
})
|
|
3474
3471
|
]
|
|
@@ -5573,7 +5570,7 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
5573
5570
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
|
|
5574
5571
|
}
|
|
5575
5572
|
var BaseTemplate = function(param) {
|
|
5576
|
-
var file = param.file;
|
|
5573
|
+
var file = param.file, imageUrl = param.imageUrl;
|
|
5577
5574
|
var _useState = _sliced_to_array$1(useState(null), 2), tempImage = _useState[0], setTempImage = _useState[1];
|
|
5578
5575
|
useEffect(function() {
|
|
5579
5576
|
var fileReader;
|
|
@@ -5602,9 +5599,9 @@ var BaseTemplate = function(param) {
|
|
|
5602
5599
|
className: "max-w-sm mx-auto bg-white rounded-lg shadow-md overflow-hidden items-center",
|
|
5603
5600
|
children: /*#__PURE__*/ jsx("div", {
|
|
5604
5601
|
className: "px-4 py-6 w-72 h-56",
|
|
5605
|
-
children: tempImage ? /*#__PURE__*/ jsx("img", {
|
|
5606
|
-
className: "w-full h-full object-
|
|
5607
|
-
src: tempImage,
|
|
5602
|
+
children: tempImage || imageUrl ? /*#__PURE__*/ jsx("img", {
|
|
5603
|
+
className: "w-full h-full object-contain border-dashed border-2 border-gray-400 p-6 rounded-lg",
|
|
5604
|
+
src: tempImage || imageUrl,
|
|
5608
5605
|
alt: ""
|
|
5609
5606
|
}) : /*#__PURE__*/ jsx("div", {
|
|
5610
5607
|
id: "image-preview",
|
|
@@ -5682,20 +5679,18 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
5682
5679
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
5683
5680
|
}
|
|
5684
5681
|
var CustomUpload = function(param) {
|
|
5685
|
-
var className = param.className, children = param.children, file = param.file, setFile = param.setFile;
|
|
5682
|
+
var className = param.className, children = param.children, file = param.file, setFile = param.setFile, imageUrl = param.imageUrl;
|
|
5686
5683
|
var imageMimeType = /image\/(png|jpg|jpeg)/i;
|
|
5687
5684
|
var DEFAULT_IMAGE_SIZE_LIMIT_IN_BYTES = 5120000; // 5000 KB
|
|
5688
5685
|
var _useState = _sliced_to_array(useState(null), 2), modal = _useState[0], setModal = _useState[1];
|
|
5689
5686
|
var hiddenFileInput = useRef(null);
|
|
5690
5687
|
var handleImageClick = function() {
|
|
5691
5688
|
var _hiddenFileInput_current;
|
|
5692
|
-
console.log(hiddenFileInput);
|
|
5693
5689
|
(_hiddenFileInput_current = hiddenFileInput.current) === null || _hiddenFileInput_current === void 0 ? void 0 : _hiddenFileInput_current.click();
|
|
5694
5690
|
};
|
|
5695
5691
|
var handleImageChange = function(event) {
|
|
5696
5692
|
var _event_target_files, _currentFile_type;
|
|
5697
5693
|
var currentFile = (_event_target_files = event.target.files) === null || _event_target_files === void 0 ? void 0 : _event_target_files[0];
|
|
5698
|
-
console.log(currentFile);
|
|
5699
5694
|
if (!currentFile) {
|
|
5700
5695
|
setFile(null);
|
|
5701
5696
|
return;
|
|
@@ -5737,7 +5732,8 @@ var CustomUpload = function(param) {
|
|
|
5737
5732
|
onClick: handleImageClick,
|
|
5738
5733
|
children: [
|
|
5739
5734
|
children || /*#__PURE__*/ jsx(BaseTemplate, {
|
|
5740
|
-
file: file
|
|
5735
|
+
file: file,
|
|
5736
|
+
imageUrl: imageUrl
|
|
5741
5737
|
}),
|
|
5742
5738
|
/*#__PURE__*/ jsx("input", {
|
|
5743
5739
|
type: "file",
|
package/package.json
CHANGED