@bigbinary/neeto-image-uploader-frontend 1.4.14 → 1.4.15
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/app/javascript/src/translations/en.json +1 -0
- package/dist/index.cjs.js +44 -16
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +45 -17
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -2368,11 +2368,11 @@ var Controls = function Controls(_ref) {
|
|
|
2368
2368
|
setAspectRatio = _ref.setAspectRatio,
|
|
2369
2369
|
setAspectRatioLocked = _ref.setAspectRatioLocked,
|
|
2370
2370
|
setCrop = _ref.setCrop,
|
|
2371
|
-
imageRef = _ref.imageRef
|
|
2371
|
+
imageRef = _ref.imageRef,
|
|
2372
|
+
isFullImage = _ref.isFullImage,
|
|
2373
|
+
setIsFullImage = _ref.setIsFullImage;
|
|
2372
2374
|
var _useTranslation = reactI18next.useTranslation(),
|
|
2373
2375
|
t = _useTranslation.t;
|
|
2374
|
-
// const [imageQuality, setImageQuality] = useState("50"); //TODO: Implement image quality
|
|
2375
|
-
|
|
2376
2376
|
var _useImageControls = useImageControls({
|
|
2377
2377
|
isAspectRatioLocked: isAspectRatioLocked,
|
|
2378
2378
|
setAspectRatioLocked: setAspectRatioLocked,
|
|
@@ -2389,9 +2389,19 @@ var Controls = function Controls(_ref) {
|
|
|
2389
2389
|
handleAspectHeightChange = _useImageControls.handleAspectHeightChange;
|
|
2390
2390
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
2391
2391
|
className: "flex w-1/4 flex-col overflow-scroll pl-6 pt-8"
|
|
2392
|
-
}, /*#__PURE__*/React__default["default"].createElement(neetoui.
|
|
2393
|
-
checked:
|
|
2392
|
+
}, /*#__PURE__*/React__default["default"].createElement(neetoui.Switch, {
|
|
2393
|
+
checked: isFullImage,
|
|
2394
2394
|
className: "flex-grow-0",
|
|
2395
|
+
label: t("neetoImageUploader.labels.selectOriginalImage"),
|
|
2396
|
+
onChange: function onChange() {
|
|
2397
|
+
return setIsFullImage(function (isFullImage) {
|
|
2398
|
+
return !isFullImage;
|
|
2399
|
+
});
|
|
2400
|
+
}
|
|
2401
|
+
}), /*#__PURE__*/React__default["default"].createElement(neetoui.Switch, {
|
|
2402
|
+
checked: isAspectRatioLocked,
|
|
2403
|
+
className: "mt-4 flex-grow-0",
|
|
2404
|
+
disabled: isFullImage,
|
|
2395
2405
|
label: t("neetoImageUploader.labels.lockAspectRatio"),
|
|
2396
2406
|
onChange: onToggleAspectRatioLock
|
|
2397
2407
|
}), /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
|
|
@@ -2400,23 +2410,27 @@ var Controls = function Controls(_ref) {
|
|
|
2400
2410
|
}, t("neetoImageUploader.imageEditor.aspetRatio")), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
2401
2411
|
className: "flex gap-4 self-start"
|
|
2402
2412
|
}, /*#__PURE__*/React__default["default"].createElement(neetoui.Input, {
|
|
2413
|
+
disabled: isFullImage,
|
|
2403
2414
|
size: "small",
|
|
2404
2415
|
type: "number",
|
|
2405
2416
|
value: aspectRatio.width,
|
|
2406
2417
|
onChange: utils.withEventTargetValue(handleAspectWidthChange)
|
|
2407
2418
|
}), /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, null, " : "), /*#__PURE__*/React__default["default"].createElement(neetoui.Input, {
|
|
2419
|
+
disabled: isFullImage,
|
|
2408
2420
|
size: "small",
|
|
2409
2421
|
type: "number",
|
|
2410
2422
|
value: aspectRatio.height,
|
|
2411
2423
|
onChange: utils.withEventTargetValue(handleAspectHeightChange)
|
|
2412
2424
|
})), /*#__PURE__*/React__default["default"].createElement(neetoui.Input, {
|
|
2413
2425
|
className: "mt-4 flex-grow-0",
|
|
2426
|
+
disabled: isFullImage,
|
|
2414
2427
|
label: t("neetoImageUploader.labels.width"),
|
|
2415
2428
|
type: "number",
|
|
2416
2429
|
value: crop.width.toFixed(2),
|
|
2417
2430
|
onChange: utils.withEventTargetValue(handleWidthChange)
|
|
2418
2431
|
}), /*#__PURE__*/React__default["default"].createElement(neetoui.Input, {
|
|
2419
2432
|
className: "mt-4 flex-grow-0",
|
|
2433
|
+
disabled: isFullImage,
|
|
2420
2434
|
label: t("neetoImageUploader.labels.height"),
|
|
2421
2435
|
type: "number",
|
|
2422
2436
|
value: crop.height.toFixed(2),
|
|
@@ -2486,17 +2500,21 @@ var ImageEditor = function ImageEditor(_ref) {
|
|
|
2486
2500
|
_useState2 = _slicedToArray$2(_useState, 2),
|
|
2487
2501
|
isAspectRatioLocked = _useState2[0],
|
|
2488
2502
|
setIsAspectRatioLocked = _useState2[1];
|
|
2489
|
-
var _useState3 = React.useState(
|
|
2503
|
+
var _useState3 = React.useState(false),
|
|
2504
|
+
_useState4 = _slicedToArray$2(_useState3, 2),
|
|
2505
|
+
isFullImage = _useState4[0],
|
|
2506
|
+
setIsFullImage = _useState4[1];
|
|
2507
|
+
var _useState5 = React.useState({
|
|
2490
2508
|
width: 16,
|
|
2491
2509
|
height: 9
|
|
2492
2510
|
}),
|
|
2493
|
-
_useState4 = _slicedToArray$2(_useState3, 2),
|
|
2494
|
-
aspectRatio = _useState4[0],
|
|
2495
|
-
setAspectRatio = _useState4[1];
|
|
2496
|
-
var _useState5 = React.useState(DEFAULT_CROP_CONFIG),
|
|
2497
2511
|
_useState6 = _slicedToArray$2(_useState5, 2),
|
|
2498
|
-
|
|
2499
|
-
|
|
2512
|
+
aspectRatio = _useState6[0],
|
|
2513
|
+
setAspectRatio = _useState6[1];
|
|
2514
|
+
var _useState7 = React.useState(DEFAULT_CROP_CONFIG),
|
|
2515
|
+
_useState8 = _slicedToArray$2(_useState7, 2),
|
|
2516
|
+
crop = _useState8[0],
|
|
2517
|
+
setCrop = _useState8[1];
|
|
2500
2518
|
var _useTranslation = reactI18next.useTranslation(),
|
|
2501
2519
|
t = _useTranslation.t;
|
|
2502
2520
|
var _useCropImage = useCropImage(),
|
|
@@ -2504,6 +2522,10 @@ var ImageEditor = function ImageEditor(_ref) {
|
|
|
2504
2522
|
var imageRef = React.useRef(null);
|
|
2505
2523
|
var wrapperRef = React.useRef(null);
|
|
2506
2524
|
var processCrop = function processCrop() {
|
|
2525
|
+
if (isFullImage) {
|
|
2526
|
+
handleImageEditComplete(image);
|
|
2527
|
+
return;
|
|
2528
|
+
}
|
|
2507
2529
|
cropImage({
|
|
2508
2530
|
crop: getCropValues({
|
|
2509
2531
|
crop: crop,
|
|
@@ -2519,6 +2541,10 @@ var ImageEditor = function ImageEditor(_ref) {
|
|
|
2519
2541
|
processCrop();
|
|
2520
2542
|
return;
|
|
2521
2543
|
}
|
|
2544
|
+
if (isFullImage) {
|
|
2545
|
+
handleImageEditComplete(image);
|
|
2546
|
+
return;
|
|
2547
|
+
}
|
|
2522
2548
|
var newURL = getCroppedImageURL({
|
|
2523
2549
|
crop: crop,
|
|
2524
2550
|
imageURL: image.url,
|
|
@@ -2548,7 +2574,7 @@ var ImageEditor = function ImageEditor(_ref) {
|
|
|
2548
2574
|
})
|
|
2549
2575
|
})
|
|
2550
2576
|
}, /*#__PURE__*/React__default["default"].createElement(ReactCrop, {
|
|
2551
|
-
crop: crop,
|
|
2577
|
+
crop: isFullImage ? null : crop,
|
|
2552
2578
|
src: image === null || image === void 0 ? void 0 : image.url,
|
|
2553
2579
|
aspect: isAspectRatioLocked ? aspectRatio.width / aspectRatio.height : 0,
|
|
2554
2580
|
onChange: setCrop,
|
|
@@ -2569,8 +2595,10 @@ var ImageEditor = function ImageEditor(_ref) {
|
|
|
2569
2595
|
handleSubmit: handleSubmit,
|
|
2570
2596
|
imageRef: imageRef,
|
|
2571
2597
|
isAspectRatioLocked: isAspectRatioLocked,
|
|
2598
|
+
isFullImage: isFullImage,
|
|
2572
2599
|
setAspectRatio: setAspectRatio,
|
|
2573
2600
|
setCrop: setCrop,
|
|
2601
|
+
setIsFullImage: setIsFullImage,
|
|
2574
2602
|
setAspectRatioLocked: setIsAspectRatioLocked
|
|
2575
2603
|
})));
|
|
2576
2604
|
};
|
|
@@ -6087,7 +6115,7 @@ var Modal = function Modal(_ref) {
|
|
|
6087
6115
|
var handleImageEditComplete = function handleImageEditComplete(editedImage) {
|
|
6088
6116
|
if (IS_DEVELOPMENT_OR_HEROKU_ENV) {
|
|
6089
6117
|
onUploadComplete({
|
|
6090
|
-
url: editedImage.
|
|
6118
|
+
url: editedImage.url,
|
|
6091
6119
|
signedId: editedImage.signedId
|
|
6092
6120
|
});
|
|
6093
6121
|
} else {
|
|
@@ -6333,7 +6361,7 @@ var ImageUploader = function ImageUploader(_ref) {
|
|
|
6333
6361
|
setSignedId("");
|
|
6334
6362
|
setIsEditorOpen(false);
|
|
6335
6363
|
};
|
|
6336
|
-
var
|
|
6364
|
+
var handleUploadComplete = function handleUploadComplete(image) {
|
|
6337
6365
|
if (IS_DEVELOPMENT_OR_HEROKU_ENV) {
|
|
6338
6366
|
handleSuccess(ramda.mergeRight(image, {
|
|
6339
6367
|
metadata: {
|
|
@@ -6377,7 +6405,7 @@ var ImageUploader = function ImageUploader(_ref) {
|
|
|
6377
6405
|
var _useDropzoneWithValid = useDropzoneWithValidation({
|
|
6378
6406
|
maxSize: uploadConfigWithDefaults === null || uploadConfigWithDefaults === void 0 ? void 0 : uploadConfigWithDefaults.maxImageSize,
|
|
6379
6407
|
acceptedTypes: uploadConfigWithDefaults === null || uploadConfigWithDefaults === void 0 ? void 0 : uploadConfigWithDefaults.allowedImageTypes,
|
|
6380
|
-
onUploadComplete:
|
|
6408
|
+
onUploadComplete: handleUploadComplete,
|
|
6381
6409
|
setIsUploading: setIsUploading
|
|
6382
6410
|
}),
|
|
6383
6411
|
getRootProps = _useDropzoneWithValid.getRootProps,
|