@bigbinary/neeto-image-uploader-frontend 1.5.22 → 1.5.24

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 CHANGED
@@ -2,15 +2,24 @@
2
2
  The `neeto-image-uploader-nano` manages assets across neeto products. The nano exports the `@bigbinary/neeto-image-uploader-frontend` NPM package and `neeto-image-uploader-engine` Rails engine for development.
3
3
 
4
4
  # Contents
5
- 1. [Development with Host Application](#development-with-host-application)
6
- - [Engine](#engine)
7
- - [Installation](#installation)
8
- - [Frontend package](#frontend-package)
9
- - [Installation](#installation-1)
10
- - [Components](#components)
11
- - [Hooks](#hooks)
12
- - [Upload Config](#upload-config)
13
- 2. [Instructions for Publishing](#instructions-for-publishing)
5
+ - [neeto-image-uploader-nano](#neeto-image-uploader-nano)
6
+ - [Contents](#contents)
7
+ - [Development with Host Application](#development-with-host-application)
8
+ - [Engine](#engine)
9
+ - [Installation](#installation)
10
+ - [Frontend package](#frontend-package)
11
+ - [Installation](#installation-1)
12
+ - [Components](#components)
13
+ - [1. `AssetLibrary` (source code)](#1-assetlibrary-source-code)
14
+ - [2. `ImageUploader` (source code)](#2-imageuploader-source-code)
15
+ - [3. `BasicImageUploader` (source code)](#3-basicimageuploader-source-code)
16
+ - [Hooks](#hooks)
17
+ - [1. `useImageUpload` (source code)](#1-useimageupload-source-code)
18
+ - [Import the hook](#import-the-hook)
19
+ - [Invoke the hook](#invoke-the-hook)
20
+ - [Call uploadImage to Upload an Image](#call-uploadimage-to-upload-an-image)
21
+ - [Upload Config](#upload-config)
22
+ - [Instructions for Publishing](#instructions-for-publishing)
14
23
 
15
24
  # Development with Host Application
16
25
  ## Engine
@@ -96,6 +105,7 @@ export default App;
96
105
  - `className`: Additional classes to be applied to the component.
97
106
  - `src`: The source URL of the image to be displayed initially.
98
107
  - `uploadConfig`: Configuration object for image uploads.
108
+ - `fixedAspectRatio`: An option to maintain a specific aspect ratio for the image. Expected input format is {height: number, width: number}.
99
109
 
100
110
  **Usage**
101
111
  ```jsx
@@ -37,7 +37,7 @@
37
37
  "upload": "Upload"
38
38
  },
39
39
  "imageEditor": {
40
- "aspetRatio": "Aspect ratio"
40
+ "aspectRatio": "Aspect ratio"
41
41
  },
42
42
  "imageUpload": {
43
43
  "change": "Change",
package/dist/index.cjs.js CHANGED
@@ -1046,7 +1046,7 @@ function isExt(v) {
1046
1046
  * @typedef {"file-invalid-type"|"file-too-large"|"file-too-small"|"too-many-files"} ErrorCode
1047
1047
  */
1048
1048
 
1049
- var _excluded$3 = ["children"],
1049
+ var _excluded$5 = ["children"],
1050
1050
  _excluded2 = ["open"],
1051
1051
  _excluded3 = ["refKey", "role", "onKeyDown", "onFocus", "onBlur", "onClick", "onDragEnter", "onDragOver", "onDragLeave", "onDrop"],
1052
1052
  _excluded4 = ["refKey", "onChange", "onClick"];
@@ -1097,7 +1097,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
1097
1097
 
1098
1098
  var Dropzone = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
1099
1099
  var children = _ref.children,
1100
- params = _objectWithoutProperties$1(_ref, _excluded$3);
1100
+ params = _objectWithoutProperties$1(_ref, _excluded$5);
1101
1101
 
1102
1102
  var _useDropzone = useDropzone(params),
1103
1103
  open = _useDropzone.open,
@@ -2069,6 +2069,7 @@ var ProgressBar = function ProgressBar(_ref) {
2069
2069
  className: "neeto-ui-bg-gray-200 neeto-ui-rounded-full w-full overflow-hidden dark:bg-gray-700"
2070
2070
  }, /*#__PURE__*/React__default["default"].createElement("div", {
2071
2071
  className: "neeto-ui-bg-primary-600 text-2xs neeto-ui-text-primary-100 neeto-ui-rounded-full flex h-3 animate-pulse items-center justify-center font-medium leading-none transition-all duration-300 ease-in-out",
2072
+ "data-cy": "neeto-image-uploader-progress-bar",
2072
2073
  style: {
2073
2074
  width: "".concat(progressPercentage, "%")
2074
2075
  }
@@ -2102,7 +2103,7 @@ var ImageDirectUpload = function ImageDirectUpload(_ref) {
2102
2103
  })
2103
2104
  }), /*#__PURE__*/React__default["default"].createElement("div", {
2104
2105
  className: "flex flex-col space-y-1"
2105
- }, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
2106
+ }, !isDisabled && /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
2106
2107
  className: "neeto-ui-text-gray-800 text-center leading-4",
2107
2108
  style: "body2"
2108
2109
  }, /*#__PURE__*/React__default["default"].createElement(reactI18next.Trans, {
@@ -2133,6 +2134,7 @@ var ImageDirectUpload = function ImageDirectUpload(_ref) {
2133
2134
  disabled: isDisabled
2134
2135
  })), /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
2135
2136
  className: "neeto-ui-text-gray-700 text-center leading-4",
2137
+ "data-cy": "neeto-image-uploader-restriction-message",
2136
2138
  lineHeight: "snug",
2137
2139
  style: "nano"
2138
2140
  }, /*#__PURE__*/React__default["default"].createElement(reactI18next.Trans, {
@@ -2144,17 +2146,17 @@ var ImageDirectUpload = function ImageDirectUpload(_ref) {
2144
2146
  }))));
2145
2147
  };
2146
2148
 
2147
- var _excluded$2 = ["className"];
2149
+ var _excluded$4 = ["className"];
2148
2150
  var ImagePlaceholder = function ImagePlaceholder(_ref) {
2149
2151
  var _ref$className = _ref.className,
2150
2152
  className = _ref$className === void 0 ? "" : _ref$className,
2151
- props = _objectWithoutProperties$2(_ref, _excluded$2);
2153
+ props = _objectWithoutProperties$2(_ref, _excluded$4);
2152
2154
  return /*#__PURE__*/React__default["default"].createElement("div", _extends$1({
2153
2155
  className: classnames__default["default"]("neeto-ui-bg-gray-200", _defineProperty$3({}, className, className))
2154
2156
  }, props));
2155
2157
  };
2156
2158
 
2157
- var _excluded$1 = ["src", "className", "fallback"];
2159
+ var _excluded$3 = ["src", "className", "fallback"];
2158
2160
  function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2159
2161
  function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), !0).forEach(function (r) { _defineProperty$3(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2160
2162
  var ImageWithFallback = function ImageWithFallback(_ref) {
@@ -2163,7 +2165,7 @@ var ImageWithFallback = function ImageWithFallback(_ref) {
2163
2165
  className = _ref$className === void 0 ? "h-full w-full" : _ref$className,
2164
2166
  _ref$fallback = _ref.fallback,
2165
2167
  Fallback = _ref$fallback === void 0 ? ImagePlaceholder : _ref$fallback,
2166
- props = _objectWithoutProperties$2(_ref, _excluded$1);
2168
+ props = _objectWithoutProperties$2(_ref, _excluded$3);
2167
2169
  var _useState = React.useState(false),
2168
2170
  _useState2 = _slicedToArray$2(_useState, 2),
2169
2171
  isLoaded = _useState2[0],
@@ -2198,10 +2200,12 @@ var UNSPLASH_DEFAULT_REQUEST_CONFIG = {
2198
2200
  };
2199
2201
  var TABS = [{
2200
2202
  label: i18next__default["default"].t("neetoImageUploader.labels.myImages"),
2201
- key: "images"
2203
+ key: "images",
2204
+ dataCy: "neeto-image-uploader-my-images-tab"
2202
2205
  }, {
2203
2206
  label: i18next__default["default"].t("neetoImageUploader.labels.searchTheWeb"),
2204
- key: "unsplash"
2207
+ key: "unsplash",
2208
+ dataCy: "neeto-image-uploader-unsplash-tab"
2205
2209
  }];
2206
2210
  var OPTIONS = [{
2207
2211
  key: "local",
@@ -2838,11 +2842,12 @@ var isNotNilOrEmpty = function isNotNilOrEmpty(value) {
2838
2842
  };
2839
2843
  var onImageLoaded = function onImageLoaded(_ref3) {
2840
2844
  var image = _ref3.image,
2841
- setCrop = _ref3.setCrop;
2845
+ setCrop = _ref3.setCrop,
2846
+ _ref3$cropAspectRatio = _ref3.cropAspectRatio,
2847
+ cropAspectRatio = _ref3$cropAspectRatio === void 0 ? 16 / 9 : _ref3$cropAspectRatio;
2842
2848
  var width = image.width,
2843
2849
  height = image.height;
2844
2850
  var imageAspectRatio = width / height;
2845
- var cropAspectRatio = 16 / 9;
2846
2851
  var maxCropWidth = 250;
2847
2852
  var maxCropHeight = maxCropWidth / cropAspectRatio;
2848
2853
  var cropWidth, cropHeight;
@@ -2884,7 +2889,7 @@ var isItemsCenter = function isItemsCenter(_ref4) {
2884
2889
  return imageHeight > imageWidth && imageHeight < wrapperHeight - 1;
2885
2890
  };
2886
2891
 
2887
- var _excluded = ["src", "className", "imageFallbackProps", "onDrop", "isDisabled", "onRemove"];
2892
+ var _excluded$2 = ["src", "className", "imageFallbackProps", "onDrop", "isDisabled", "onRemove"];
2888
2893
  function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2889
2894
  function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty$3(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2890
2895
  var BasicImageUploader = function BasicImageUploader(_ref) {
@@ -2903,7 +2908,7 @@ var BasicImageUploader = function BasicImageUploader(_ref) {
2903
2908
  isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
2904
2909
  _ref$onRemove = _ref.onRemove,
2905
2910
  onRemove = _ref$onRemove === void 0 ? neetoCist.noop : _ref$onRemove,
2906
- props = _objectWithoutProperties$2(_ref, _excluded);
2911
+ props = _objectWithoutProperties$2(_ref, _excluded$2);
2907
2912
  return /*#__PURE__*/React__default["default"].createElement("div", {
2908
2913
  className: classnames__default["default"](className, {
2909
2914
  "cursor-pointer": true,
@@ -3635,7 +3640,9 @@ var Controls = function Controls(_ref) {
3635
3640
  setCrop = _ref.setCrop,
3636
3641
  imageRef = _ref.imageRef,
3637
3642
  isFullImage = _ref.isFullImage,
3638
- setIsFullImage = _ref.setIsFullImage;
3643
+ setIsFullImage = _ref.setIsFullImage,
3644
+ _ref$hideControls = _ref.hideControls,
3645
+ hideControls = _ref$hideControls === void 0 ? false : _ref$hideControls;
3639
3646
  var _useTranslation = reactI18next.useTranslation(),
3640
3647
  t = _useTranslation.t;
3641
3648
  var _useState = React.useState(crop.height.toFixed(0)),
@@ -3676,7 +3683,7 @@ var Controls = function Controls(_ref) {
3676
3683
  }, [crop]);
3677
3684
  return /*#__PURE__*/React__default["default"].createElement("div", {
3678
3685
  className: "flex flex-col p-4 md:w-2/6 "
3679
- }, /*#__PURE__*/React__default["default"].createElement(neetoui.Switch, {
3686
+ }, !hideControls && /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(neetoui.Switch, {
3680
3687
  checked: isFullImage,
3681
3688
  className: "flex-grow-0",
3682
3689
  label: t("neetoImageUploader.labels.selectOriginalImage"),
@@ -3694,21 +3701,23 @@ var Controls = function Controls(_ref) {
3694
3701
  }), /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
3695
3702
  className: "mb-2 mt-6",
3696
3703
  style: "body2"
3697
- }, t("neetoImageUploader.imageEditor.aspetRatio")), /*#__PURE__*/React__default["default"].createElement("div", {
3704
+ }, t("neetoImageUploader.imageEditor.aspectRatio")), /*#__PURE__*/React__default["default"].createElement("div", {
3698
3705
  className: "flex gap-4 self-start"
3699
3706
  }, /*#__PURE__*/React__default["default"].createElement(neetoui.Input, {
3707
+ "data-cy": "aspect-ratio-width-input",
3700
3708
  disabled: isFullImage,
3701
3709
  size: "small",
3702
3710
  type: "number",
3703
3711
  value: aspectRatio.width,
3704
3712
  onChange: utils.withEventTargetValue(handleAspectWidthChange)
3705
3713
  }), /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, null, " : "), /*#__PURE__*/React__default["default"].createElement(neetoui.Input, {
3714
+ "data-cy": "aspect-ratio-height-input",
3706
3715
  disabled: isFullImage,
3707
3716
  size: "small",
3708
3717
  type: "number",
3709
3718
  value: aspectRatio.height,
3710
3719
  onChange: utils.withEventTargetValue(handleAspectHeightChange)
3711
- })), /*#__PURE__*/React__default["default"].createElement(neetoui.Input, {
3720
+ }))), /*#__PURE__*/React__default["default"].createElement(neetoui.Input, {
3712
3721
  className: "mt-4 flex-grow-0",
3713
3722
  disabled: isFullImage,
3714
3723
  label: t("neetoImageUploader.labels.width"),
@@ -3724,6 +3733,7 @@ var Controls = function Controls(_ref) {
3724
3733
  onChange: utils.withEventTargetValue(setHeight)
3725
3734
  }), /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
3726
3735
  className: "mt-6 self-start",
3736
+ "data-cy": "neeto-image-uploader-crop-submit-button",
3727
3737
  label: t("neetoImageUploader.labels.done"),
3728
3738
  disabled: isNilOrEmpty(imageRef.current) && (crop.width <= 0 || crop.height <= 0),
3729
3739
  onClick: handleSubmit
@@ -3736,7 +3746,9 @@ var ImageEditor = function ImageEditor(_ref) {
3736
3746
  _ref$handleImageEditC = _ref.handleImageEditComplete,
3737
3747
  handleImageEditComplete = _ref$handleImageEditC === void 0 ? neetoCist.noop : _ref$handleImageEditC,
3738
3748
  _ref$signedId = _ref.signedId,
3739
- signedId = _ref$signedId === void 0 ? "" : _ref$signedId;
3749
+ signedId = _ref$signedId === void 0 ? "" : _ref$signedId,
3750
+ _ref$fixedAspectRatio = _ref.fixedAspectRatio,
3751
+ fixedAspectRatio = _ref$fixedAspectRatio === void 0 ? {} : _ref$fixedAspectRatio;
3740
3752
  var _useState = React.useState(true),
3741
3753
  _useState2 = _slicedToArray$2(_useState, 2),
3742
3754
  isAspectRatioLocked = _useState2[0],
@@ -3746,8 +3758,8 @@ var ImageEditor = function ImageEditor(_ref) {
3746
3758
  isFullImage = _useState4[0],
3747
3759
  setIsFullImage = _useState4[1];
3748
3760
  var _useState5 = React.useState({
3749
- width: 16,
3750
- height: 9
3761
+ width: (fixedAspectRatio === null || fixedAspectRatio === void 0 ? void 0 : fixedAspectRatio.width) || 16,
3762
+ height: (fixedAspectRatio === null || fixedAspectRatio === void 0 ? void 0 : fixedAspectRatio.height) || 9
3751
3763
  }),
3752
3764
  _useState6 = _slicedToArray$2(_useState5, 2),
3753
3765
  aspectRatio = _useState6[0],
@@ -3762,6 +3774,7 @@ var ImageEditor = function ImageEditor(_ref) {
3762
3774
  cropImage = _useCropImage.mutate;
3763
3775
  var imageRef = React.useRef(null);
3764
3776
  var wrapperRef = React.useRef(null);
3777
+ var cropAspectRatio = neetoCist.isPresent(fixedAspectRatio === null || fixedAspectRatio === void 0 ? void 0 : fixedAspectRatio.width) && neetoCist.isPresent(fixedAspectRatio.height) ? (fixedAspectRatio === null || fixedAspectRatio === void 0 ? void 0 : fixedAspectRatio.width) / (fixedAspectRatio === null || fixedAspectRatio === void 0 ? void 0 : fixedAspectRatio.height) : 16 / 9;
3765
3778
  var processCrop = function processCrop() {
3766
3779
  if (isFullImage) {
3767
3780
  handleImageEditComplete(image);
@@ -3799,12 +3812,13 @@ var ImageEditor = function ImageEditor(_ref) {
3799
3812
  className: "flex h-full flex-col gap-4 px-8 py-12"
3800
3813
  }, /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
3801
3814
  className: "self-start",
3815
+ "data-cy": "image-editor-back-button",
3802
3816
  icon: neetoIcons.LeftArrow,
3803
3817
  iconPosition: "left",
3804
3818
  style: "text",
3805
3819
  onClick: handleReset
3806
3820
  }), /*#__PURE__*/React__default["default"].createElement("div", {
3807
- className: "flex h-full w-full flex-col gap-2 overflow-y-scroll md:flex-row md:overflow-y-auto"
3821
+ className: "flex h-full w-full flex-col gap-2 overflow-y-scroll md:flex-row md:overflow-y-auto"
3808
3822
  }, /*#__PURE__*/React__default["default"].createElement("div", {
3809
3823
  id: "imageEditor",
3810
3824
  ref: wrapperRef,
@@ -3822,12 +3836,14 @@ var ImageEditor = function ImageEditor(_ref) {
3822
3836
  onComplete: setCrop
3823
3837
  }, /*#__PURE__*/React__default["default"].createElement("img", {
3824
3838
  alt: t("neetoImageUploader.common.image"),
3839
+ "data-cy": "image-editor-uploaded-image",
3825
3840
  ref: imageRef,
3826
3841
  src: image === null || image === void 0 ? void 0 : image.url,
3827
3842
  onLoad: function onLoad(e) {
3828
3843
  return onImageLoaded({
3829
3844
  image: e.target,
3830
- setCrop: setCrop
3845
+ setCrop: setCrop,
3846
+ cropAspectRatio: cropAspectRatio
3831
3847
  });
3832
3848
  }
3833
3849
  }))), /*#__PURE__*/React__default["default"].createElement(Controls, {
@@ -3840,6 +3856,7 @@ var ImageEditor = function ImageEditor(_ref) {
3840
3856
  setAspectRatio: setAspectRatio,
3841
3857
  setCrop: setCrop,
3842
3858
  setIsFullImage: setIsFullImage,
3859
+ hideControls: neetoCist.isPresent(fixedAspectRatio),
3843
3860
  setAspectRatioLocked: setIsAspectRatioLocked
3844
3861
  })));
3845
3862
  };
@@ -4665,7 +4682,7 @@ var InfiniteScroller = function InfiniteScroller(_ref) {
4665
4682
  sizes: INFINITE_SCROLLER_SIZES,
4666
4683
  style: INFINITE_SCROLLER_STYLE,
4667
4684
  useWindow: false
4668
- }, images.map(function (image) {
4685
+ }, images.map(function (image, index) {
4669
4686
  var _image$urls, _image$user, _image$user2;
4670
4687
  return /*#__PURE__*/React__default["default"].createElement("div", {
4671
4688
  className: "float-left w-1/2 pb-4 pr-4 md:w-1/4",
@@ -4679,7 +4696,7 @@ var InfiniteScroller = function InfiniteScroller(_ref) {
4679
4696
  className: "neeto-ui-rounded-sm neeto-ui-bg-gray-100 group absolute h-full w-full",
4680
4697
  id: "unsplashImage".concat(image.id)
4681
4698
  }, tab === TABS[1].key && /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("img", {
4682
- "data-cy": "niu-library-image-".concat(image === null || image === void 0 ? void 0 : image.id),
4699
+ "data-cy": "niu-unsplash-image-".concat(index),
4683
4700
  src: image === null || image === void 0 || (_image$urls = image.urls) === null || _image$urls === void 0 ? void 0 : _image$urls.regular,
4684
4701
  onClick: function onClick() {
4685
4702
  return handleUnsplashImageSelect(image);
@@ -4690,7 +4707,7 @@ var InfiniteScroller = function InfiniteScroller(_ref) {
4690
4707
  rel: "noreferrer",
4691
4708
  target: "_blank"
4692
4709
  }, image === null || image === void 0 || (_image$user2 = image.user) === null || _image$user2 === void 0 ? void 0 : _image$user2.name, " | ", " ", t("neetoImageUploader.labels.unsplash"))), tab === TABS[0].key && /*#__PURE__*/React__default["default"].createElement("img", {
4693
- "data-cy": "niu-library-image-".concat(image === null || image === void 0 ? void 0 : image.fileId),
4710
+ "data-cy": "niu-library-image-".concat(index),
4694
4711
  src: image === null || image === void 0 ? void 0 : image.url,
4695
4712
  onClick: function onClick() {
4696
4713
  return setSelectedImage(image);
@@ -5019,6 +5036,7 @@ var ImageLibrary = function ImageLibrary(_ref) {
5019
5036
  }));
5020
5037
  };
5021
5038
 
5039
+ var _excluded$1 = ["key"];
5022
5040
  var Modal = function Modal(_ref) {
5023
5041
  var isOpen = _ref.isOpen,
5024
5042
  _ref$onClose = _ref.onClose,
@@ -5026,7 +5044,9 @@ var Modal = function Modal(_ref) {
5026
5044
  _ref$onUploadComplete = _ref.onUploadComplete,
5027
5045
  onUploadComplete = _ref$onUploadComplete === void 0 ? neetoCist.noop : _ref$onUploadComplete,
5028
5046
  _ref$uploadConfig = _ref.uploadConfig,
5029
- uploadConfig = _ref$uploadConfig === void 0 ? {} : _ref$uploadConfig;
5047
+ uploadConfig = _ref$uploadConfig === void 0 ? {} : _ref$uploadConfig,
5048
+ _ref$fixedAspectRatio = _ref.fixedAspectRatio,
5049
+ fixedAspectRatio = _ref$fixedAspectRatio === void 0 ? {} : _ref$fixedAspectRatio;
5030
5050
  var _useState = React.useState(TABS[0].key),
5031
5051
  _useState2 = _slicedToArray$2(_useState, 2),
5032
5052
  activeTab = _useState2[0],
@@ -5109,6 +5129,7 @@ var Modal = function Modal(_ref) {
5109
5129
  }, /*#__PURE__*/React__default["default"].createElement(neetoui.Spinner, null)), isNilOrEmpty(selectedImage) && isDragActive && /*#__PURE__*/React__default["default"].createElement("div", _extends$1({
5110
5130
  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"
5111
5131
  }, getRootProps()), /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, null, t("neetoImageUploader.common.dropHere"))), !isNilOrEmpty(selectedImage) ? /*#__PURE__*/React__default["default"].createElement(ImageEditor, {
5132
+ fixedAspectRatio: fixedAspectRatio,
5112
5133
  handleImageEditComplete: handleImageEditComplete,
5113
5134
  handleReset: function handleReset() {
5114
5135
  return setSelectedImage({});
@@ -5134,6 +5155,7 @@ var Modal = function Modal(_ref) {
5134
5155
  }, TABS.map(function (tab) {
5135
5156
  return /*#__PURE__*/React__default["default"].createElement(neetoui.Tab.Item, {
5136
5157
  active: activeTab === tab.key,
5158
+ "data-cy": tab.dataCy,
5137
5159
  key: tab.key,
5138
5160
  onClick: function onClick() {
5139
5161
  return setActiveTab(tab.key);
@@ -5143,16 +5165,11 @@ var Modal = function Modal(_ref) {
5143
5165
  className: "flex gap-2"
5144
5166
  }, options.map(function (_ref2) {
5145
5167
  var key = _ref2.key,
5146
- label = _ref2.label,
5147
- onClick = _ref2.onClick,
5148
- style = _ref2.style;
5149
- return /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
5150
- label: label,
5151
- onClick: onClick,
5152
- style: style,
5168
+ otherProps = _objectWithoutProperties$2(_ref2, _excluded$1);
5169
+ return /*#__PURE__*/React__default["default"].createElement(neetoui.Button, _extends$1({}, otherProps, {
5153
5170
  key: key,
5154
5171
  size: "small"
5155
- });
5172
+ }));
5156
5173
  })))), /*#__PURE__*/React__default["default"].createElement(ImageLibrary, {
5157
5174
  setActiveTab: setActiveTab,
5158
5175
  setIsUploading: setIsUploading,
@@ -5174,6 +5191,7 @@ var Modal = function Modal(_ref) {
5174
5191
  })))), /*#__PURE__*/React__default["default"].createElement("input", getInputProps()));
5175
5192
  };
5176
5193
 
5194
+ var _excluded = ["key", "label"];
5177
5195
  var Menu = neetoui.Dropdown.Menu,
5178
5196
  MenuItem = neetoui.Dropdown.MenuItem;
5179
5197
  var ImageUploader = function ImageUploader(_ref) {
@@ -5184,7 +5202,9 @@ var ImageUploader = function ImageUploader(_ref) {
5184
5202
  _ref$src = _ref.src,
5185
5203
  src = _ref$src === void 0 ? "" : _ref$src,
5186
5204
  _ref$uploadConfig = _ref.uploadConfig,
5187
- uploadConfig = _ref$uploadConfig === void 0 ? {} : _ref$uploadConfig;
5205
+ uploadConfig = _ref$uploadConfig === void 0 ? {} : _ref$uploadConfig,
5206
+ _ref$fixedAspectRatio = _ref.fixedAspectRatio,
5207
+ fixedAspectRatio = _ref$fixedAspectRatio === void 0 ? {} : _ref$fixedAspectRatio;
5188
5208
  var _useState = React.useState(false),
5189
5209
  _useState2 = _slicedToArray$2(_useState, 2),
5190
5210
  isAssetLibraryOpen = _useState2[0],
@@ -5275,7 +5295,8 @@ var ImageUploader = function ImageUploader(_ref) {
5275
5295
  "cursor-pointer": true
5276
5296
  })
5277
5297
  }, isNotNilOrEmpty(image.url) ? /*#__PURE__*/React__default["default"].createElement("div", {
5278
- className: IMAGE_WRAPPER_CLASSNAME
5298
+ className: IMAGE_WRAPPER_CLASSNAME,
5299
+ "data-cy": "image-uploader-wrapper"
5279
5300
  }, /*#__PURE__*/React__default["default"].createElement(ImageWithFallback, {
5280
5301
  className: "h-full w-full",
5281
5302
  "data-cy": "uploaded-image",
@@ -5290,16 +5311,17 @@ var ImageUploader = function ImageUploader(_ref) {
5290
5311
  }, /*#__PURE__*/React__default["default"].createElement(Menu, null, options.map(function (_ref2) {
5291
5312
  var key = _ref2.key,
5292
5313
  label = _ref2.label,
5293
- onClick = _ref2.onClick;
5294
- return /*#__PURE__*/React__default["default"].createElement(MenuItem.Button, {
5295
- onClick: onClick,
5314
+ otherProps = _objectWithoutProperties$2(_ref2, _excluded);
5315
+ return /*#__PURE__*/React__default["default"].createElement(MenuItem.Button, _extends$1({}, otherProps, {
5296
5316
  key: key
5297
- }, label);
5317
+ }), label);
5298
5318
  })))) : /*#__PURE__*/React__default["default"].createElement(ImageDirectUpload, {
5299
5319
  setIsAssetLibraryOpen: setIsAssetLibraryOpen,
5320
+ isDisabled: neetoCist.isPresent(fixedAspectRatio),
5300
5321
  uploadConfig: uploadConfigWithDefaults,
5301
5322
  onDrop: uploadFile
5302
5323
  }), /*#__PURE__*/React__default["default"].createElement(Modal, {
5324
+ fixedAspectRatio: fixedAspectRatio,
5303
5325
  isOpen: isAssetLibraryOpen,
5304
5326
  uploadConfig: uploadConfigWithDefaults,
5305
5327
  onClose: function onClose() {