@bigbinary/neeto-image-uploader-frontend 1.5.23 → 1.5.25
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/README.md +19 -9
- package/dist/index.cjs.js +28 -13
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +29 -14
- package/dist/index.js.map +1 -1
- package/package.json +12 -12
- package/types.d.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useMemo, useRef, useReducer, useEffect, useCallback, forwardRef, useImperativeHandle, Fragment, useState } from 'react';
|
|
2
2
|
import classnames from 'classnames';
|
|
3
|
-
import { noop as noop$1, keysToCamelCase, findBy } from '@bigbinary/neeto-cist';
|
|
3
|
+
import { noop as noop$1, keysToCamelCase, findBy, isPresent } from '@bigbinary/neeto-cist';
|
|
4
4
|
import { Delete, LeftArrow, MenuHorizontal } from '@bigbinary/neeto-icons';
|
|
5
5
|
import { Toastr, Typography, Button, Switch, Input, Spinner, Modal as Modal$1, Tab, Dropdown } from '@bigbinary/neetoui';
|
|
6
6
|
import { pipe, values, flatten as flatten$1, map, toUpper, join, equals, isNil, isEmpty, mergeRight, mergeLeft, concat, __, inc, mergeDeepRight } from 'ramda';
|
|
@@ -2092,7 +2092,7 @@ var ImageDirectUpload = function ImageDirectUpload(_ref) {
|
|
|
2092
2092
|
})
|
|
2093
2093
|
}), /*#__PURE__*/React.createElement("div", {
|
|
2094
2094
|
className: "flex flex-col space-y-1"
|
|
2095
|
-
}, /*#__PURE__*/React.createElement(Typography, {
|
|
2095
|
+
}, !isDisabled && /*#__PURE__*/React.createElement(Typography, {
|
|
2096
2096
|
className: "neeto-ui-text-gray-800 text-center leading-4",
|
|
2097
2097
|
style: "body2"
|
|
2098
2098
|
}, /*#__PURE__*/React.createElement(Trans, {
|
|
@@ -2831,11 +2831,12 @@ var isNotNilOrEmpty = function isNotNilOrEmpty(value) {
|
|
|
2831
2831
|
};
|
|
2832
2832
|
var onImageLoaded = function onImageLoaded(_ref3) {
|
|
2833
2833
|
var image = _ref3.image,
|
|
2834
|
-
setCrop = _ref3.setCrop
|
|
2834
|
+
setCrop = _ref3.setCrop,
|
|
2835
|
+
_ref3$cropAspectRatio = _ref3.cropAspectRatio,
|
|
2836
|
+
cropAspectRatio = _ref3$cropAspectRatio === void 0 ? 16 / 9 : _ref3$cropAspectRatio;
|
|
2835
2837
|
var width = image.width,
|
|
2836
2838
|
height = image.height;
|
|
2837
2839
|
var imageAspectRatio = width / height;
|
|
2838
|
-
var cropAspectRatio = 16 / 9;
|
|
2839
2840
|
var maxCropWidth = 250;
|
|
2840
2841
|
var maxCropHeight = maxCropWidth / cropAspectRatio;
|
|
2841
2842
|
var cropWidth, cropHeight;
|
|
@@ -3628,7 +3629,9 @@ var Controls = function Controls(_ref) {
|
|
|
3628
3629
|
setCrop = _ref.setCrop,
|
|
3629
3630
|
imageRef = _ref.imageRef,
|
|
3630
3631
|
isFullImage = _ref.isFullImage,
|
|
3631
|
-
setIsFullImage = _ref.setIsFullImage
|
|
3632
|
+
setIsFullImage = _ref.setIsFullImage,
|
|
3633
|
+
_ref$hideControls = _ref.hideControls,
|
|
3634
|
+
hideControls = _ref$hideControls === void 0 ? false : _ref$hideControls;
|
|
3632
3635
|
var _useTranslation = useTranslation(),
|
|
3633
3636
|
t = _useTranslation.t;
|
|
3634
3637
|
var _useState = useState(crop.height.toFixed(0)),
|
|
@@ -3669,7 +3672,7 @@ var Controls = function Controls(_ref) {
|
|
|
3669
3672
|
}, [crop]);
|
|
3670
3673
|
return /*#__PURE__*/React.createElement("div", {
|
|
3671
3674
|
className: "flex flex-col p-4 md:w-2/6 "
|
|
3672
|
-
}, /*#__PURE__*/React.createElement(Switch, {
|
|
3675
|
+
}, !hideControls && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Switch, {
|
|
3673
3676
|
checked: isFullImage,
|
|
3674
3677
|
className: "flex-grow-0",
|
|
3675
3678
|
label: t("neetoImageUploader.labels.selectOriginalImage"),
|
|
@@ -3703,7 +3706,7 @@ var Controls = function Controls(_ref) {
|
|
|
3703
3706
|
type: "number",
|
|
3704
3707
|
value: aspectRatio.height,
|
|
3705
3708
|
onChange: withEventTargetValue(handleAspectHeightChange)
|
|
3706
|
-
})), /*#__PURE__*/React.createElement(Input, {
|
|
3709
|
+
}))), /*#__PURE__*/React.createElement(Input, {
|
|
3707
3710
|
className: "mt-4 flex-grow-0",
|
|
3708
3711
|
disabled: isFullImage,
|
|
3709
3712
|
label: t("neetoImageUploader.labels.width"),
|
|
@@ -3732,7 +3735,9 @@ var ImageEditor = function ImageEditor(_ref) {
|
|
|
3732
3735
|
_ref$handleImageEditC = _ref.handleImageEditComplete,
|
|
3733
3736
|
handleImageEditComplete = _ref$handleImageEditC === void 0 ? noop$1 : _ref$handleImageEditC,
|
|
3734
3737
|
_ref$signedId = _ref.signedId,
|
|
3735
|
-
signedId = _ref$signedId === void 0 ? "" : _ref$signedId
|
|
3738
|
+
signedId = _ref$signedId === void 0 ? "" : _ref$signedId,
|
|
3739
|
+
_ref$fixedAspectRatio = _ref.fixedAspectRatio,
|
|
3740
|
+
fixedAspectRatio = _ref$fixedAspectRatio === void 0 ? {} : _ref$fixedAspectRatio;
|
|
3736
3741
|
var _useState = useState(true),
|
|
3737
3742
|
_useState2 = _slicedToArray$2(_useState, 2),
|
|
3738
3743
|
isAspectRatioLocked = _useState2[0],
|
|
@@ -3742,8 +3747,8 @@ var ImageEditor = function ImageEditor(_ref) {
|
|
|
3742
3747
|
isFullImage = _useState4[0],
|
|
3743
3748
|
setIsFullImage = _useState4[1];
|
|
3744
3749
|
var _useState5 = useState({
|
|
3745
|
-
width: 16,
|
|
3746
|
-
height: 9
|
|
3750
|
+
width: (fixedAspectRatio === null || fixedAspectRatio === void 0 ? void 0 : fixedAspectRatio.width) || 16,
|
|
3751
|
+
height: (fixedAspectRatio === null || fixedAspectRatio === void 0 ? void 0 : fixedAspectRatio.height) || 9
|
|
3747
3752
|
}),
|
|
3748
3753
|
_useState6 = _slicedToArray$2(_useState5, 2),
|
|
3749
3754
|
aspectRatio = _useState6[0],
|
|
@@ -3758,6 +3763,7 @@ var ImageEditor = function ImageEditor(_ref) {
|
|
|
3758
3763
|
cropImage = _useCropImage.mutate;
|
|
3759
3764
|
var imageRef = useRef(null);
|
|
3760
3765
|
var wrapperRef = useRef(null);
|
|
3766
|
+
var cropAspectRatio = isPresent(fixedAspectRatio === null || fixedAspectRatio === void 0 ? void 0 : fixedAspectRatio.width) && isPresent(fixedAspectRatio.height) ? (fixedAspectRatio === null || fixedAspectRatio === void 0 ? void 0 : fixedAspectRatio.width) / (fixedAspectRatio === null || fixedAspectRatio === void 0 ? void 0 : fixedAspectRatio.height) : 16 / 9;
|
|
3761
3767
|
var processCrop = function processCrop() {
|
|
3762
3768
|
if (isFullImage) {
|
|
3763
3769
|
handleImageEditComplete(image);
|
|
@@ -3801,7 +3807,7 @@ var ImageEditor = function ImageEditor(_ref) {
|
|
|
3801
3807
|
style: "text",
|
|
3802
3808
|
onClick: handleReset
|
|
3803
3809
|
}), /*#__PURE__*/React.createElement("div", {
|
|
3804
|
-
className: "flex h-full w-full flex-col gap-2 overflow-y-scroll md:flex-row
|
|
3810
|
+
className: "flex h-full w-full flex-col gap-2 overflow-y-scroll md:flex-row md:overflow-y-auto"
|
|
3805
3811
|
}, /*#__PURE__*/React.createElement("div", {
|
|
3806
3812
|
id: "imageEditor",
|
|
3807
3813
|
ref: wrapperRef,
|
|
@@ -3825,7 +3831,8 @@ var ImageEditor = function ImageEditor(_ref) {
|
|
|
3825
3831
|
onLoad: function onLoad(e) {
|
|
3826
3832
|
return onImageLoaded({
|
|
3827
3833
|
image: e.target,
|
|
3828
|
-
setCrop: setCrop
|
|
3834
|
+
setCrop: setCrop,
|
|
3835
|
+
cropAspectRatio: cropAspectRatio
|
|
3829
3836
|
});
|
|
3830
3837
|
}
|
|
3831
3838
|
}))), /*#__PURE__*/React.createElement(Controls, {
|
|
@@ -3838,6 +3845,7 @@ var ImageEditor = function ImageEditor(_ref) {
|
|
|
3838
3845
|
setAspectRatio: setAspectRatio,
|
|
3839
3846
|
setCrop: setCrop,
|
|
3840
3847
|
setIsFullImage: setIsFullImage,
|
|
3848
|
+
hideControls: isPresent(fixedAspectRatio),
|
|
3841
3849
|
setAspectRatioLocked: setIsAspectRatioLocked
|
|
3842
3850
|
})));
|
|
3843
3851
|
};
|
|
@@ -5025,7 +5033,9 @@ var Modal = function Modal(_ref) {
|
|
|
5025
5033
|
_ref$onUploadComplete = _ref.onUploadComplete,
|
|
5026
5034
|
onUploadComplete = _ref$onUploadComplete === void 0 ? noop$1 : _ref$onUploadComplete,
|
|
5027
5035
|
_ref$uploadConfig = _ref.uploadConfig,
|
|
5028
|
-
uploadConfig = _ref$uploadConfig === void 0 ? {} : _ref$uploadConfig
|
|
5036
|
+
uploadConfig = _ref$uploadConfig === void 0 ? {} : _ref$uploadConfig,
|
|
5037
|
+
_ref$fixedAspectRatio = _ref.fixedAspectRatio,
|
|
5038
|
+
fixedAspectRatio = _ref$fixedAspectRatio === void 0 ? {} : _ref$fixedAspectRatio;
|
|
5029
5039
|
var _useState = useState(TABS[0].key),
|
|
5030
5040
|
_useState2 = _slicedToArray$2(_useState, 2),
|
|
5031
5041
|
activeTab = _useState2[0],
|
|
@@ -5108,6 +5118,7 @@ var Modal = function Modal(_ref) {
|
|
|
5108
5118
|
}, /*#__PURE__*/React.createElement(Spinner, null)), isNilOrEmpty(selectedImage) && isDragActive && /*#__PURE__*/React.createElement("div", _extends$1({
|
|
5109
5119
|
className: "neeto-ui-rounded-xl neeto-ui-bg-gray-400 absolute flex h-full w-full flex-col items-center justify-around border-4 border-dashed border-gray-900 opacity-40"
|
|
5110
5120
|
}, getRootProps()), /*#__PURE__*/React.createElement(Typography, null, t("neetoImageUploader.common.dropHere"))), !isNilOrEmpty(selectedImage) ? /*#__PURE__*/React.createElement(ImageEditor, {
|
|
5121
|
+
fixedAspectRatio: fixedAspectRatio,
|
|
5111
5122
|
handleImageEditComplete: handleImageEditComplete,
|
|
5112
5123
|
handleReset: function handleReset() {
|
|
5113
5124
|
return setSelectedImage({});
|
|
@@ -5180,7 +5191,9 @@ var ImageUploader = function ImageUploader(_ref) {
|
|
|
5180
5191
|
_ref$src = _ref.src,
|
|
5181
5192
|
src = _ref$src === void 0 ? "" : _ref$src,
|
|
5182
5193
|
_ref$uploadConfig = _ref.uploadConfig,
|
|
5183
|
-
uploadConfig = _ref$uploadConfig === void 0 ? {} : _ref$uploadConfig
|
|
5194
|
+
uploadConfig = _ref$uploadConfig === void 0 ? {} : _ref$uploadConfig,
|
|
5195
|
+
_ref$fixedAspectRatio = _ref.fixedAspectRatio,
|
|
5196
|
+
fixedAspectRatio = _ref$fixedAspectRatio === void 0 ? {} : _ref$fixedAspectRatio;
|
|
5184
5197
|
var _useState = useState(false),
|
|
5185
5198
|
_useState2 = _slicedToArray$2(_useState, 2),
|
|
5186
5199
|
isAssetLibraryOpen = _useState2[0],
|
|
@@ -5293,9 +5306,11 @@ var ImageUploader = function ImageUploader(_ref) {
|
|
|
5293
5306
|
}), label);
|
|
5294
5307
|
})))) : /*#__PURE__*/React.createElement(ImageDirectUpload, {
|
|
5295
5308
|
setIsAssetLibraryOpen: setIsAssetLibraryOpen,
|
|
5309
|
+
isDisabled: isPresent(fixedAspectRatio),
|
|
5296
5310
|
uploadConfig: uploadConfigWithDefaults,
|
|
5297
5311
|
onDrop: uploadFile
|
|
5298
5312
|
}), /*#__PURE__*/React.createElement(Modal, {
|
|
5313
|
+
fixedAspectRatio: fixedAspectRatio,
|
|
5299
5314
|
isOpen: isAssetLibraryOpen,
|
|
5300
5315
|
uploadConfig: uploadConfigWithDefaults,
|
|
5301
5316
|
onClose: function onClose() {
|