@bigbinary/neeto-image-uploader-frontend 4.0.2 → 4.0.4

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.
Files changed (101) hide show
  1. package/dist/.ready +1 -1
  2. package/dist/AssetLibrary.js +12 -9
  3. package/dist/AssetLibrary.js.map +1 -1
  4. package/dist/BasicImageUploader.js +4 -2
  5. package/dist/BasicImageUploader.js.map +1 -1
  6. package/dist/ImageForm.js +7 -4
  7. package/dist/ImageForm.js.map +1 -1
  8. package/dist/ImageUploader.js +9 -6
  9. package/dist/ImageUploader.js.map +1 -1
  10. package/dist/{ImageWithFallback-Bq5rs1yf.js → ImageWithFallback-B3DoquUi.js} +4 -4
  11. package/dist/ImageWithFallback-B3DoquUi.js.map +1 -0
  12. package/dist/ImageWithFallback-CSHOljd2.js +59 -0
  13. package/dist/ImageWithFallback-CSHOljd2.js.map +1 -0
  14. package/dist/ImageWithFallback-D1ClfJLn.js +61 -0
  15. package/dist/{ImageWithFallback-Bq5rs1yf.js.map → ImageWithFallback-D1ClfJLn.js.map} +1 -1
  16. package/dist/cjs/AssetLibrary.js +10 -7
  17. package/dist/cjs/AssetLibrary.js.map +1 -1
  18. package/dist/cjs/BasicImageUploader.js +5 -3
  19. package/dist/cjs/BasicImageUploader.js.map +1 -1
  20. package/dist/cjs/ImageForm.js +9 -6
  21. package/dist/cjs/ImageForm.js.map +1 -1
  22. package/dist/cjs/ImageUploader.js +14 -11
  23. package/dist/cjs/ImageUploader.js.map +1 -1
  24. package/dist/cjs/hooks.js +1 -1
  25. package/dist/cjs/index.js +9 -6
  26. package/dist/cjs/index.js.map +1 -1
  27. package/dist/cjs/v2/AssetLibrary.js +40 -0
  28. package/dist/cjs/v2/AssetLibrary.js.map +1 -0
  29. package/dist/cjs/v2/BasicImageUploader.js +71 -0
  30. package/dist/cjs/v2/BasicImageUploader.js.map +1 -0
  31. package/dist/cjs/v2/ImageForm.js +324 -0
  32. package/dist/cjs/v2/ImageForm.js.map +1 -0
  33. package/dist/cjs/v2/ImageUploader.js +247 -0
  34. package/dist/cjs/v2/ImageUploader.js.map +1 -0
  35. package/dist/cjs/v2/hooks.js +27 -0
  36. package/dist/cjs/v2/hooks.js.map +1 -0
  37. package/dist/cjs/v2/index.js +61 -0
  38. package/dist/cjs/v2/index.js.map +1 -0
  39. package/dist/cjs/v2/utils.js +9 -0
  40. package/dist/cjs/v2/utils.js.map +1 -0
  41. package/dist/constants-Csle2bxb.js +56 -0
  42. package/dist/constants-Csle2bxb.js.map +1 -0
  43. package/dist/constants-DI8wBtC-.js +68 -0
  44. package/dist/constants-DI8wBtC-.js.map +1 -0
  45. package/dist/hooks.js +3 -3
  46. package/dist/{imagekit.esm-CXW6c1fP.js → imagekit.esm-IYQEzBnD.js} +2 -2
  47. package/dist/{imagekit.esm-CXW6c1fP.js.map → imagekit.esm-IYQEzBnD.js.map} +1 -1
  48. package/dist/index-BuSc2dEl.js +949 -0
  49. package/dist/index-BuSc2dEl.js.map +1 -0
  50. package/dist/index-CBorETxd.js +972 -0
  51. package/dist/index-CBorETxd.js.map +1 -0
  52. package/dist/index-Cv97u10a.js +952 -0
  53. package/dist/index-Cv97u10a.js.map +1 -0
  54. package/dist/index-krkZ4CNS.js +969 -0
  55. package/dist/index-krkZ4CNS.js.map +1 -0
  56. package/dist/index.js +10 -7
  57. package/dist/index.js.map +1 -1
  58. package/dist/{useImageUploader-BLOdyAwv.js → useImageUploader-D8luC4Qw.js} +2 -2
  59. package/dist/{useImageUploader-BLOdyAwv.js.map → useImageUploader-D8luC4Qw.js.map} +1 -1
  60. package/dist/{useProfileImageUpload-CiGxDpEx.js → useProfileImageUpload-CbjVfcfI.js} +3 -3
  61. package/dist/{useProfileImageUpload-CiGxDpEx.js.map → useProfileImageUpload-CbjVfcfI.js.map} +1 -1
  62. package/dist/{useProfileImageUpload-DkmUBjtt.js → useProfileImageUpload-DbanXK57.js} +6 -6
  63. package/dist/useProfileImageUpload-DbanXK57.js.map +1 -0
  64. package/dist/useUnsplashApi-CNeNh58q.js +1065 -0
  65. package/dist/useUnsplashApi-CNeNh58q.js.map +1 -0
  66. package/dist/useUnsplashApi-D_ekWD8p.js +1057 -0
  67. package/dist/useUnsplashApi-D_ekWD8p.js.map +1 -0
  68. package/dist/useUploadDropzone-8Xa8PI-1.js +56 -0
  69. package/dist/useUploadDropzone-8Xa8PI-1.js.map +1 -0
  70. package/dist/useUploadDropzone-DMv8VMRF.js +58 -0
  71. package/dist/useUploadDropzone-DMv8VMRF.js.map +1 -0
  72. package/dist/utils-BTmA9hHb.js +364 -0
  73. package/dist/utils-BTmA9hHb.js.map +1 -0
  74. package/dist/{utils-YicuhSoR.js → utils-D5iQ8UME.js} +29 -66
  75. package/dist/utils-D5iQ8UME.js.map +1 -0
  76. package/dist/{utils-CoOpqzJA.js → utils-De7yUxgQ.js} +37 -75
  77. package/dist/utils-De7yUxgQ.js.map +1 -0
  78. package/dist/utils-DyCNC3w5.js +347 -0
  79. package/dist/utils-DyCNC3w5.js.map +1 -0
  80. package/dist/v2/AssetLibrary.js +34 -0
  81. package/dist/v2/AssetLibrary.js.map +1 -0
  82. package/dist/v2/BasicImageUploader.js +69 -0
  83. package/dist/v2/BasicImageUploader.js.map +1 -0
  84. package/dist/v2/ImageForm.js +322 -0
  85. package/dist/v2/ImageForm.js.map +1 -0
  86. package/dist/v2/ImageUploader.js +245 -0
  87. package/dist/v2/ImageUploader.js.map +1 -0
  88. package/dist/v2/hooks.js +19 -0
  89. package/dist/v2/hooks.js.map +1 -0
  90. package/dist/v2/index.js +48 -0
  91. package/dist/v2/index.js.map +1 -0
  92. package/dist/v2/utils.js +3 -0
  93. package/dist/v2/utils.js.map +1 -0
  94. package/package.json +51 -39
  95. package/dist/index-BGVHZZys.js +0 -2410
  96. package/dist/index-BGVHZZys.js.map +0 -1
  97. package/dist/index-CjVmJmv5.js +0 -2413
  98. package/dist/index-CjVmJmv5.js.map +0 -1
  99. package/dist/useProfileImageUpload-DkmUBjtt.js.map +0 -1
  100. package/dist/utils-CoOpqzJA.js.map +0 -1
  101. package/dist/utils-YicuhSoR.js.map +0 -1
@@ -0,0 +1,347 @@
1
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
+ import { forwardRef, useImperativeHandle } from 'react';
3
+ import classnames from 'classnames';
4
+ import { isPresent, noop } from '@bigbinary/neeto-cist';
5
+ import Button from '@bigbinary/neetoui/Button';
6
+ import Typography from '@bigbinary/neetoui/Typography';
7
+ import ProgressBar from '@bigbinary/neetoui/ProgressBar';
8
+ import { pipe, values, flatten, map, toUpper, join, equals, isNil, isEmpty } from 'ramda';
9
+ import { Trans } from 'react-i18next';
10
+ import { globalProps } from '@bigbinary/neeto-commons-frontend/initializers';
11
+ import { u as useUploadDropzone } from './useUploadDropzone-8Xa8PI-1.js';
12
+ import { D as DROPZONE_ROOT_DIV_CLASSNAME, b as ImageKit } from './imagekit.esm-IYQEzBnD.js';
13
+ import { jsx, jsxs } from 'react/jsx-runtime';
14
+
15
+ var DEFAULT_ALLOWED_IMAGE_TYPES = {
16
+ "image/png": [".png"],
17
+ "image/jpg": [".jpg", ".jpeg"],
18
+ "image/gif": [".gif"],
19
+ "image/svg+xml": [".svg"]
20
+ };
21
+ var DEFAULT_UPLOAD_CONFIG = {
22
+ maxImageSize: globalProps.endUserUploadedFileSizeLimitInMb,
23
+ allowedImageTypes: DEFAULT_ALLOWED_IMAGE_TYPES
24
+ };
25
+ var OPTION_KEYS = {
26
+ asset: "asset",
27
+ remove: "remove"
28
+ };
29
+
30
+ var getAllowedTypes = function getAllowedTypes(uploadConfig) {
31
+ return pipe(values, flatten, map(function (extension) {
32
+ return extension.slice(1);
33
+ }), map(toUpper), join(", "))(uploadConfig.allowedImageTypes);
34
+ };
35
+
36
+ function ownKeys(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; }
37
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
38
+ var ImageDirectUpload = /*#__PURE__*/forwardRef(function (_ref, ref) {
39
+ var _ref$uploadConfig = _ref.uploadConfig,
40
+ uploadConfig = _ref$uploadConfig === void 0 ? DEFAULT_UPLOAD_CONFIG : _ref$uploadConfig,
41
+ _ref$onDrop = _ref.onDrop,
42
+ onDrop = _ref$onDrop === void 0 ? noop : _ref$onDrop,
43
+ _ref$isDisabled = _ref.isDisabled,
44
+ isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
45
+ setIsAssetLibraryOpen = _ref.setIsAssetLibraryOpen,
46
+ _ref$defaultImageSize = _ref.defaultImageSize,
47
+ defaultImageSize = _ref$defaultImageSize === void 0 ? {} : _ref$defaultImageSize,
48
+ _ref$isUploadDisabled = _ref.isUploadDisabled,
49
+ isUploadDisabled = _ref$isUploadDisabled === void 0 ? false : _ref$isUploadDisabled,
50
+ setImage = _ref.setImage;
51
+ var _useUploadDropzone = useUploadDropzone({
52
+ uploadConfig: uploadConfig,
53
+ onDrop: onDrop,
54
+ setImage: setImage
55
+ }),
56
+ getRootProps = _useUploadDropzone.getRootProps,
57
+ getInputProps = _useUploadDropzone.getInputProps,
58
+ isDragActive = _useUploadDropzone.isDragActive,
59
+ open = _useUploadDropzone.open,
60
+ uploadProgress = _useUploadDropzone.uploadProgress,
61
+ setUploadProgress = _useUploadDropzone.setUploadProgress;
62
+ useImperativeHandle(ref, function () {
63
+ return {
64
+ upload: function upload(file) {
65
+ return onDrop(file, setUploadProgress, setImage);
66
+ }
67
+ };
68
+ });
69
+ var shouldShowProgress = !!(uploadProgress && !equals(uploadProgress, 1));
70
+ return /*#__PURE__*/jsx("div", _objectSpread(_objectSpread({}, getRootProps()), {}, {
71
+ className: classnames(DROPZONE_ROOT_DIV_CLASSNAME, {
72
+ "neeto-ui-border-gray-300": !isDragActive,
73
+ "neeto-ui-border-gray-700": isDragActive
74
+ }),
75
+ children: shouldShowProgress ? /*#__PURE__*/jsx(ProgressBar, {
76
+ progressPercentage: uploadProgress,
77
+ progressValue: "".concat(uploadProgress, "%")
78
+ }) : /*#__PURE__*/jsxs("div", {
79
+ className: "flex flex-col space-y-1",
80
+ children: [!isDisabled && /*#__PURE__*/jsx(Typography, {
81
+ className: "neeto-ui-text-gray-800 text-center leading-4",
82
+ style: "body2",
83
+ children: /*#__PURE__*/jsx(Trans, {
84
+ i18nKey: "neetoImageUploader.imageUpload.dragAndDropOrBrowseFile",
85
+ components: {
86
+ span: /*#__PURE__*/jsx(Button, {
87
+ "data-testid": "neeto-image-uploader-browse-text",
88
+ style: "link",
89
+ onClick: function onClick(event) {
90
+ event.stopPropagation();
91
+ open();
92
+ }
93
+ })
94
+ }
95
+ })
96
+ }), setIsAssetLibraryOpen && /*#__PURE__*/jsx(Typography, {
97
+ style: "body2",
98
+ className: classnames("text-center leading-4", {
99
+ "pointer-events-none": isUploadDisabled
100
+ }),
101
+ onClick: function onClick(e) {
102
+ e.stopPropagation();
103
+ setIsAssetLibraryOpen(true);
104
+ },
105
+ children: /*#__PURE__*/jsx(Trans, {
106
+ i18nKey: "neetoImageUploader.imageUpload.upload",
107
+ components: {
108
+ span: /*#__PURE__*/jsx(Button, {
109
+ "data-testid": "open-asset-library-button",
110
+ style: "link"
111
+ })
112
+ }
113
+ })
114
+ }), /*#__PURE__*/jsx("input", _objectSpread(_objectSpread({}, getInputProps()), {}, {
115
+ "data-testid": "neeto-image-uploader-file-input",
116
+ disabled: isDisabled || isUploadDisabled
117
+ })), /*#__PURE__*/jsx(Typography, {
118
+ className: "neeto-ui-text-gray-700 text-center leading-4",
119
+ "data-testid": "neeto-image-uploader-restriction-message",
120
+ lineHeight: "snug",
121
+ style: "nano",
122
+ children: /*#__PURE__*/jsx(Trans, {
123
+ i18nKey: "neetoImageUploader.imageUpload.restrictionMessage",
124
+ values: {
125
+ fileTypes: getAllowedTypes(uploadConfig),
126
+ size: uploadConfig === null || uploadConfig === void 0 ? void 0 : uploadConfig.maxImageSize
127
+ }
128
+ })
129
+ }), isPresent(defaultImageSize) && /*#__PURE__*/jsx(Typography, {
130
+ className: "neeto-ui-text-gray-700 text-center leading-4",
131
+ "data-testid": "neeto-image-uploader-ideal-image-size-info-text",
132
+ lineHeight: "snug",
133
+ style: "nano",
134
+ children: /*#__PURE__*/jsx(Trans, {
135
+ i18nKey: "neetoImageUploader.imageUpload.idealImageSizeInfo",
136
+ values: _objectSpread({}, defaultImageSize)
137
+ })
138
+ })]
139
+ })
140
+ }));
141
+ });
142
+ ImageDirectUpload.displayName = "ImageDirectUpload";
143
+
144
+ var getWholeNumberAspectRatio = function getWholeNumberAspectRatio(_ref) {
145
+ var width = _ref.width,
146
+ height = _ref.height;
147
+ if (width === height) return {
148
+ width: 1,
149
+ height: 1
150
+ };
151
+ var _gcd = function gcd(a, b) {
152
+ return b === 0 ? a : _gcd(b, a % b);
153
+ };
154
+
155
+ // Multiplying by 1000 is a temporary fix to prevent height and width with fractions (eg: 100.91).
156
+ var divisor = _gcd(width * 1000, height * 1000);
157
+ return {
158
+ width: width / divisor,
159
+ height: height / divisor
160
+ };
161
+ };
162
+ var getCropValues = function getCropValues(_ref2) {
163
+ var crop = _ref2.crop,
164
+ imageRef = _ref2.imageRef;
165
+ var naturalWidth = imageRef.current.naturalWidth;
166
+ var naturalHeight = imageRef.current.naturalHeight;
167
+ return {
168
+ x: crop.x / 100 * naturalWidth,
169
+ y: crop.y / 100 * naturalHeight,
170
+ width: crop.width / 100 * naturalWidth,
171
+ height: crop.height / 100 * naturalHeight
172
+ };
173
+ };
174
+ var getImageKitCroppedURL = function getImageKitCroppedURL(_ref3) {
175
+ var imageURL = _ref3.imageURL,
176
+ crop = _ref3.crop,
177
+ imageRef = _ref3.imageRef;
178
+ var imagekit = new ImageKit({
179
+ urlEndpoint: globalProps.imagekit.urlEndpoint
180
+ });
181
+ var _getCropValues = getCropValues({
182
+ crop: crop,
183
+ imageRef: imageRef
184
+ }),
185
+ x = _getCropValues.x,
186
+ y = _getCropValues.y,
187
+ height = _getCropValues.height,
188
+ width = _getCropValues.width;
189
+ var transformation = [{
190
+ cropMode: "extract",
191
+ x: x,
192
+ y: y,
193
+ height: height,
194
+ width: width
195
+ }];
196
+ return imagekit.url({
197
+ src: imageURL,
198
+ transformation: transformation
199
+ });
200
+ };
201
+ var isNilOrEmpty = function isNilOrEmpty(value) {
202
+ return isNil(value) || isEmpty(value);
203
+ };
204
+ var isNotNilOrEmpty = function isNotNilOrEmpty(value) {
205
+ return !isNilOrEmpty(value);
206
+ };
207
+ var isItemsCenter = function isItemsCenter(_ref4) {
208
+ var imageRef = _ref4.imageRef,
209
+ wrapperRef = _ref4.wrapperRef;
210
+ var _ref5 = imageRef.current || {},
211
+ imageHeight = _ref5.height,
212
+ imageWidth = _ref5.width;
213
+ var wrapperHeight = (wrapperRef.current || {}).clientHeight;
214
+ if (imageHeight < imageWidth && imageHeight < wrapperHeight - 1) {
215
+ // Landscape images smaller than wrapper dimensions
216
+ return true;
217
+ }
218
+ if (imageHeight === imageWidth && imageHeight < wrapperHeight - 1) {
219
+ // Square images smaller than wrapper dimensions
220
+ return true;
221
+ }
222
+ return imageHeight > imageWidth && imageHeight < wrapperHeight - 1;
223
+ };
224
+ var calculateCloudFlareImageCroppedValues = function calculateCloudFlareImageCroppedValues(_ref6) {
225
+ var image = _ref6.image,
226
+ crop = _ref6.crop;
227
+ var naturalWidth = image.metadata.width;
228
+ var naturalHeight = image.metadata.height;
229
+ var sourceX = crop.x / 100 * naturalWidth;
230
+ var sourceY = crop.y / 100 * naturalHeight;
231
+ var sourceWidth = crop.width / 100 * naturalWidth;
232
+ var sourceHeight = crop.height / 100 * naturalHeight;
233
+ var distanceFromRight = Math.abs(naturalWidth - (sourceX + sourceWidth));
234
+ var distanceFromBottom = Math.abs(naturalHeight - (sourceY + sourceHeight));
235
+ return {
236
+ top: sourceY,
237
+ right: distanceFromRight,
238
+ bottom: distanceFromBottom,
239
+ left: sourceX
240
+ };
241
+ };
242
+ var getCloudFlareCroppedURL = function getCloudFlareCroppedURL(_ref7) {
243
+ var image = _ref7.image,
244
+ crop = _ref7.crop;
245
+ var _calculateCloudFlareI = calculateCloudFlareImageCroppedValues({
246
+ image: image,
247
+ crop: crop
248
+ }),
249
+ top = _calculateCloudFlareI.top,
250
+ right = _calculateCloudFlareI.right,
251
+ bottom = _calculateCloudFlareI.bottom,
252
+ left = _calculateCloudFlareI.left;
253
+ var trimValues = "".concat(top, ";").concat(right, ";").concat(bottom, ";").concat(left);
254
+ return image.url.replace("public", "trim=".concat(trimValues));
255
+ };
256
+ var getAspectRatio = function getAspectRatio(_ref8) {
257
+ var fixedAspectRatio = _ref8.fixedAspectRatio,
258
+ imageSize = _ref8.imageSize;
259
+ if (isPresent(fixedAspectRatio === null || fixedAspectRatio === void 0 ? void 0 : fixedAspectRatio.width) && isPresent(fixedAspectRatio === null || fixedAspectRatio === void 0 ? void 0 : fixedAspectRatio.height)) {
260
+ return fixedAspectRatio;
261
+ }
262
+ if (isPresent(imageSize === null || imageSize === void 0 ? void 0 : imageSize.width) && isPresent(imageSize === null || imageSize === void 0 ? void 0 : imageSize.height)) {
263
+ return getWholeNumberAspectRatio(imageSize);
264
+ }
265
+ return {
266
+ width: 16,
267
+ height: 9
268
+ };
269
+ };
270
+ var getPixels = function getPixels(percentage, pixel) {
271
+ return Math.round(percentage / 100 * pixel);
272
+ };
273
+ var getPercentage = function getPercentage(crop, full) {
274
+ return crop / full * 100;
275
+ };
276
+ var getInitialCropSize = function getInitialCropSize(_ref9) {
277
+ var image = _ref9.image,
278
+ aspectRatioFactor = _ref9.aspectRatioFactor,
279
+ maxCropWidth = _ref9.maxCropWidth;
280
+ var imageWidth = image.naturalWidth,
281
+ imageHeight = image.naturalHeight;
282
+ var imageAspectRatio = imageWidth / imageHeight;
283
+ var maxCropHeight = maxCropWidth / aspectRatioFactor;
284
+ var cropWidth, cropHeight;
285
+ if (imageAspectRatio > aspectRatioFactor) {
286
+ cropWidth = Math.min(maxCropWidth, imageWidth);
287
+ cropHeight = cropWidth / aspectRatioFactor;
288
+ } else if (imageHeight < maxCropHeight) {
289
+ cropWidth = imageWidth;
290
+ cropHeight = imageHeight;
291
+ } else {
292
+ cropHeight = Math.min(maxCropHeight, imageHeight);
293
+ cropWidth = cropHeight * aspectRatioFactor;
294
+ }
295
+ return {
296
+ cropWidth: cropWidth,
297
+ cropHeight: cropHeight
298
+ };
299
+ };
300
+ var getHeightFromAspectRatio = function getHeightFromAspectRatio(width, aspectRatio) {
301
+ return Math.round(width * aspectRatio.height / aspectRatio.width);
302
+ };
303
+ var getWidthFromAspectRatio = function getWidthFromAspectRatio(height, aspectRatio) {
304
+ return Math.round(height * aspectRatio.width / aspectRatio.height);
305
+ };
306
+ var getWrapperRefStyles = function getWrapperRefStyles(wrapperRef, imageRef) {
307
+ var _ref10 = imageRef.current || {},
308
+ _ref10$naturalHeight = _ref10.naturalHeight,
309
+ naturalHeight = _ref10$naturalHeight === void 0 ? 100 : _ref10$naturalHeight,
310
+ _ref10$naturalWidth = _ref10.naturalWidth,
311
+ naturalWidth = _ref10$naturalWidth === void 0 ? 100 : _ref10$naturalWidth;
312
+ var _ref11 = wrapperRef.current || {},
313
+ _ref11$clientHeight = _ref11.clientHeight,
314
+ clientHeight = _ref11$clientHeight === void 0 ? 100 : _ref11$clientHeight,
315
+ _ref11$clientWidth = _ref11.clientWidth,
316
+ clientWidth = _ref11$clientWidth === void 0 ? 100 : _ref11$clientWidth;
317
+ if (naturalWidth <= clientWidth && naturalHeight <= clientHeight) {
318
+ return {
319
+ maxWidth: naturalWidth
320
+ };
321
+ } else if (naturalWidth > clientWidth && naturalHeight <= clientHeight) {
322
+ return {
323
+ maxWidth: clientWidth
324
+ };
325
+ } else if (naturalWidth <= clientWidth && naturalHeight > clientHeight) {
326
+ var _maxWidth = naturalWidth / naturalHeight * clientHeight;
327
+ return {
328
+ maxWidth: _maxWidth
329
+ };
330
+ }
331
+
332
+ // landscape
333
+ if (naturalWidth > naturalHeight) {
334
+ return {
335
+ maxWidth: clientWidth
336
+ };
337
+ }
338
+
339
+ // portrait
340
+ var maxWidth = naturalWidth / naturalHeight * clientHeight;
341
+ return {
342
+ maxWidth: maxWidth
343
+ };
344
+ };
345
+
346
+ export { DEFAULT_UPLOAD_CONFIG as D, ImageDirectUpload as I, OPTION_KEYS as O, isNilOrEmpty as a, getPixels as b, getHeightFromAspectRatio as c, getWidthFromAspectRatio as d, getInitialCropSize as e, getPercentage as f, getAspectRatio as g, getWrapperRefStyles as h, isNotNilOrEmpty as i, isItemsCenter as j, getCloudFlareCroppedURL as k, getImageKitCroppedURL as l, getCropValues as m };
347
+ //# sourceMappingURL=utils-DyCNC3w5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils-DyCNC3w5.js","sources":["../app/javascript/src/components/ImageUploader/constants.js","../app/javascript/src/components/ImageUploader/utils.js","../app/javascript/src/components/common/ImageDirectUpload.jsx","../app/javascript/src/components/ImageEditor/utils.js"],"sourcesContent":["import { globalProps } from \"neetocommons/initializers\";\n\nexport const DEFAULT_ALLOWED_IMAGE_TYPES = {\n \"image/png\": [\".png\"],\n \"image/jpg\": [\".jpg\", \".jpeg\"],\n \"image/gif\": [\".gif\"],\n \"image/svg+xml\": [\".svg\"],\n};\n\nexport const DEFAULT_UPLOAD_CONFIG = {\n maxImageSize: globalProps.endUserUploadedFileSizeLimitInMb,\n allowedImageTypes: DEFAULT_ALLOWED_IMAGE_TYPES,\n};\n\nexport const OPTION_KEYS = { asset: \"asset\", remove: \"remove\" };\n","import { flatten, pipe, join, map, toUpper, values } from \"ramda\";\n\nexport const getAllowedTypes = uploadConfig =>\n pipe(\n values,\n flatten,\n map(extension => extension.slice(1)),\n map(toUpper),\n join(\", \")\n )(uploadConfig.allowedImageTypes);\n","import { forwardRef, useImperativeHandle } from \"react\";\n\nimport classnames from \"classnames\";\nimport { noop, isPresent } from \"neetocist\";\nimport { Button, Typography, ProgressBar } from \"neetoui\";\nimport { equals } from \"ramda\";\nimport { Trans } from \"react-i18next\";\n\nimport { DEFAULT_UPLOAD_CONFIG } from \"components/ImageUploader/constants\";\nimport { getAllowedTypes } from \"components/ImageUploader/utils\";\nimport useUploadDropzone from \"hooks/useUploadDropzone\";\n\nimport { DROPZONE_ROOT_DIV_CLASSNAME } from \"./constants\";\n\nconst ImageDirectUpload = forwardRef(\n (\n {\n uploadConfig = DEFAULT_UPLOAD_CONFIG,\n onDrop = noop,\n isDisabled = false,\n setIsAssetLibraryOpen,\n defaultImageSize = {},\n isUploadDisabled = false,\n setImage,\n },\n ref\n ) => {\n const {\n getRootProps,\n getInputProps,\n isDragActive,\n open,\n uploadProgress,\n setUploadProgress,\n } = useUploadDropzone({ uploadConfig, onDrop, setImage });\n\n useImperativeHandle(ref, () => ({\n upload: file => onDrop(file, setUploadProgress, setImage),\n }));\n\n const shouldShowProgress = !!(uploadProgress && !equals(uploadProgress, 1));\n\n return (\n <div\n {...getRootProps()}\n className={classnames(DROPZONE_ROOT_DIV_CLASSNAME, {\n \"neeto-ui-border-gray-300\": !isDragActive,\n \"neeto-ui-border-gray-700\": isDragActive,\n })}\n >\n {shouldShowProgress ? (\n <ProgressBar\n progressPercentage={uploadProgress}\n progressValue={`${uploadProgress}%`}\n />\n ) : (\n <div className=\"flex flex-col space-y-1\">\n {!isDisabled && (\n <Typography\n className=\"neeto-ui-text-gray-800 text-center leading-4\"\n style=\"body2\"\n >\n <Trans\n i18nKey=\"neetoImageUploader.imageUpload.dragAndDropOrBrowseFile\"\n components={{\n span: (\n <Button\n data-testid=\"neeto-image-uploader-browse-text\"\n style=\"link\"\n onClick={event => {\n event.stopPropagation();\n open();\n }}\n />\n ),\n }}\n />\n </Typography>\n )}\n {setIsAssetLibraryOpen && (\n <Typography\n style=\"body2\"\n className={classnames(\"text-center leading-4\", {\n \"pointer-events-none\": isUploadDisabled,\n })}\n onClick={e => {\n e.stopPropagation();\n setIsAssetLibraryOpen(true);\n }}\n >\n <Trans\n i18nKey=\"neetoImageUploader.imageUpload.upload\"\n components={{\n span: (\n <Button\n data-testid=\"open-asset-library-button\"\n style=\"link\"\n />\n ),\n }}\n />\n </Typography>\n )}\n <input\n {...getInputProps()}\n data-testid=\"neeto-image-uploader-file-input\"\n disabled={isDisabled || isUploadDisabled}\n />\n <Typography\n className=\"neeto-ui-text-gray-700 text-center leading-4\"\n data-testid=\"neeto-image-uploader-restriction-message\"\n lineHeight=\"snug\"\n style=\"nano\"\n >\n <Trans\n i18nKey=\"neetoImageUploader.imageUpload.restrictionMessage\"\n values={{\n fileTypes: getAllowedTypes(uploadConfig),\n size: uploadConfig?.maxImageSize,\n }}\n />\n </Typography>\n {isPresent(defaultImageSize) && (\n <Typography\n className=\"neeto-ui-text-gray-700 text-center leading-4\"\n data-testid=\"neeto-image-uploader-ideal-image-size-info-text\"\n lineHeight=\"snug\"\n style=\"nano\"\n >\n <Trans\n i18nKey=\"neetoImageUploader.imageUpload.idealImageSizeInfo\"\n values={{ ...defaultImageSize }}\n />\n </Typography>\n )}\n </div>\n )}\n </div>\n );\n }\n);\n\nImageDirectUpload.displayName = \"ImageDirectUpload\";\n\nexport default ImageDirectUpload;\n","import ImageKit from \"imagekit-javascript\";\nimport { isPresent } from \"neetocist\";\nimport { globalProps } from \"neetocommons/initializers\";\nimport { isEmpty, isNil } from \"ramda\";\n\nconst getWholeNumberAspectRatio = ({ width, height }) => {\n if (width === height) return { width: 1, height: 1 };\n\n const gcd = (a, b) => (b === 0 ? a : gcd(b, a % b));\n\n // Multiplying by 1000 is a temporary fix to prevent height and width with fractions (eg: 100.91).\n const divisor = gcd(width * 1000, height * 1000);\n\n return { width: width / divisor, height: height / divisor };\n};\n\nexport const getCropValues = ({ crop, imageRef }) => {\n const naturalWidth = imageRef.current.naturalWidth;\n const naturalHeight = imageRef.current.naturalHeight;\n\n return {\n x: (crop.x / 100) * naturalWidth,\n y: (crop.y / 100) * naturalHeight,\n width: (crop.width / 100) * naturalWidth,\n height: (crop.height / 100) * naturalHeight,\n };\n};\n\nexport const getImageKitCroppedURL = ({ imageURL, crop, imageRef }) => {\n const imagekit = new ImageKit({\n urlEndpoint: globalProps.imagekit.urlEndpoint,\n });\n const { x, y, height, width } = getCropValues({ crop, imageRef });\n\n const transformation = [{ cropMode: \"extract\", x, y, height, width }];\n\n return imagekit.url({ src: imageURL, transformation });\n};\n\nexport const isNilOrEmpty = value => isNil(value) || isEmpty(value);\nexport const isNotNilOrEmpty = value => !isNilOrEmpty(value);\n\nexport const isItemsCenter = ({ imageRef, wrapperRef }) => {\n const { height: imageHeight, width: imageWidth } = imageRef.current || {};\n const wrapperHeight = (wrapperRef.current || {}).clientHeight;\n\n if (imageHeight < imageWidth && imageHeight < wrapperHeight - 1) {\n // Landscape images smaller than wrapper dimensions\n return true;\n }\n\n if (imageHeight === imageWidth && imageHeight < wrapperHeight - 1) {\n // Square images smaller than wrapper dimensions\n return true;\n }\n\n return imageHeight > imageWidth && imageHeight < wrapperHeight - 1;\n};\n\nexport const calculateCloudFlareImageCroppedValues = ({ image, crop }) => {\n const naturalWidth = image.metadata.width;\n const naturalHeight = image.metadata.height;\n\n const sourceX = (crop.x / 100) * naturalWidth;\n const sourceY = (crop.y / 100) * naturalHeight;\n const sourceWidth = (crop.width / 100) * naturalWidth;\n const sourceHeight = (crop.height / 100) * naturalHeight;\n\n const distanceFromRight = Math.abs(naturalWidth - (sourceX + sourceWidth));\n const distanceFromBottom = Math.abs(naturalHeight - (sourceY + sourceHeight));\n\n return {\n top: sourceY,\n right: distanceFromRight,\n bottom: distanceFromBottom,\n left: sourceX,\n };\n};\n\nexport const getCloudFlareCroppedURL = ({ image, crop }) => {\n const { top, right, bottom, left } = calculateCloudFlareImageCroppedValues({\n image,\n crop,\n });\n const trimValues = `${top};${right};${bottom};${left}`;\n\n return image.url.replace(\"public\", `trim=${trimValues}`);\n};\n\nexport const getAspectRatio = ({ fixedAspectRatio, imageSize }) => {\n if (\n isPresent(fixedAspectRatio?.width) &&\n isPresent(fixedAspectRatio?.height)\n ) {\n return fixedAspectRatio;\n }\n\n if (isPresent(imageSize?.width) && isPresent(imageSize?.height)) {\n return getWholeNumberAspectRatio(imageSize);\n }\n\n return { width: 16, height: 9 };\n};\n\nexport const getPixels = (percentage, pixel) =>\n Math.round((percentage / 100) * pixel);\n\nexport const getPercentage = (crop, full) => (crop / full) * 100;\n\nexport const getInitialCropSize = ({\n image,\n aspectRatioFactor,\n maxCropWidth,\n}) => {\n const { naturalWidth: imageWidth, naturalHeight: imageHeight } = image;\n const imageAspectRatio = imageWidth / imageHeight;\n const maxCropHeight = maxCropWidth / aspectRatioFactor;\n\n let cropWidth, cropHeight;\n\n if (imageAspectRatio > aspectRatioFactor) {\n cropWidth = Math.min(maxCropWidth, imageWidth);\n cropHeight = cropWidth / aspectRatioFactor;\n } else if (imageHeight < maxCropHeight) {\n cropWidth = imageWidth;\n cropHeight = imageHeight;\n } else {\n cropHeight = Math.min(maxCropHeight, imageHeight);\n cropWidth = cropHeight * aspectRatioFactor;\n }\n\n return { cropWidth, cropHeight };\n};\n\nexport const getHeightFromAspectRatio = (width, aspectRatio) =>\n Math.round((width * aspectRatio.height) / aspectRatio.width);\n\nexport const getWidthFromAspectRatio = (height, aspectRatio) =>\n Math.round((height * aspectRatio.width) / aspectRatio.height);\n\nexport const getWrapperRefStyles = (wrapperRef, imageRef) => {\n const { naturalHeight = 100, naturalWidth = 100 } = imageRef.current || {};\n const { clientHeight = 100, clientWidth = 100 } = wrapperRef.current || {};\n\n if (naturalWidth <= clientWidth && naturalHeight <= clientHeight) {\n return { maxWidth: naturalWidth };\n } else if (naturalWidth > clientWidth && naturalHeight <= clientHeight) {\n return { maxWidth: clientWidth };\n } else if (naturalWidth <= clientWidth && naturalHeight > clientHeight) {\n const maxWidth = (naturalWidth / naturalHeight) * clientHeight;\n\n return { maxWidth };\n }\n\n // landscape\n if (naturalWidth > naturalHeight) {\n return { maxWidth: clientWidth };\n }\n\n // portrait\n const maxWidth = (naturalWidth / naturalHeight) * clientHeight;\n\n return { maxWidth };\n};\n"],"names":["DEFAULT_ALLOWED_IMAGE_TYPES","DEFAULT_UPLOAD_CONFIG","maxImageSize","globalProps","endUserUploadedFileSizeLimitInMb","allowedImageTypes","OPTION_KEYS","asset","remove","getAllowedTypes","uploadConfig","pipe","values","flatten","map","extension","slice","toUpper","join","ImageDirectUpload","forwardRef","_ref","ref","_ref$uploadConfig","_ref$onDrop","onDrop","noop","_ref$isDisabled","isDisabled","setIsAssetLibraryOpen","_ref$defaultImageSize","defaultImageSize","_ref$isUploadDisabled","isUploadDisabled","setImage","_useUploadDropzone","useUploadDropzone","getRootProps","getInputProps","isDragActive","open","uploadProgress","setUploadProgress","useImperativeHandle","upload","file","shouldShowProgress","equals","_jsx","_objectSpread","className","classnames","DROPZONE_ROOT_DIV_CLASSNAME","children","ProgressBar","progressPercentage","progressValue","concat","_jsxs","Typography","style","Trans","i18nKey","components","span","Button","onClick","event","stopPropagation","e","disabled","lineHeight","fileTypes","size","isPresent","displayName","getWholeNumberAspectRatio","width","height","gcd","a","b","divisor","getCropValues","_ref2","crop","imageRef","naturalWidth","current","naturalHeight","x","y","getImageKitCroppedURL","_ref3","imageURL","imagekit","ImageKit","urlEndpoint","_getCropValues","transformation","cropMode","url","src","isNilOrEmpty","value","isNil","isEmpty","isNotNilOrEmpty","isItemsCenter","_ref4","wrapperRef","_ref5","imageHeight","imageWidth","wrapperHeight","clientHeight","calculateCloudFlareImageCroppedValues","_ref6","image","metadata","sourceX","sourceY","sourceWidth","sourceHeight","distanceFromRight","Math","abs","distanceFromBottom","top","right","bottom","left","getCloudFlareCroppedURL","_ref7","_calculateCloudFlareI","trimValues","replace","getAspectRatio","_ref8","fixedAspectRatio","imageSize","getPixels","percentage","pixel","round","getPercentage","full","getInitialCropSize","_ref9","aspectRatioFactor","maxCropWidth","imageAspectRatio","maxCropHeight","cropWidth","cropHeight","min","getHeightFromAspectRatio","aspectRatio","getWidthFromAspectRatio","getWrapperRefStyles","_ref10","_ref10$naturalHeight","_ref10$naturalWidth","_ref11","_ref11$clientHeight","_ref11$clientWidth","clientWidth","maxWidth"],"mappings":";;;;;;;;;;;;;;AAEO,IAAMA,2BAA2B,GAAG;EACzC,WAAW,EAAE,CAAC,MAAM,CAAC;AACrB,EAAA,WAAW,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;EAC9B,WAAW,EAAE,CAAC,MAAM,CAAC;EACrB,eAAe,EAAE,CAAC,MAAM;AAC1B,CAAC;AAEM,IAAMC,qBAAqB,GAAG;EACnCC,YAAY,EAAEC,WAAW,CAACC,gCAAgC;AAC1DC,EAAAA,iBAAiB,EAAEL;AACrB;AAEO,IAAMM,WAAW,GAAG;AAAEC,EAAAA,KAAK,EAAE,OAAO;AAAEC,EAAAA,MAAM,EAAE;AAAS;;ACZvD,IAAMC,eAAe,GAAG,SAAlBA,eAAeA,CAAGC,YAAY,EAAA;EAAA,OACzCC,IAAI,CACFC,MAAM,EACNC,OAAO,EACPC,GAAG,CAAC,UAAAC,SAAS,EAAA;AAAA,IAAA,OAAIA,SAAS,CAACC,KAAK,CAAC,CAAC,CAAC;AAAA,EAAA,CAAA,CAAC,EACpCF,GAAG,CAACG,OAAO,CAAC,EACZC,IAAI,CAAC,IAAI,CACX,CAAC,CAACR,YAAY,CAACL,iBAAiB,CAAC;AAAA,CAAA;;;;ACKnC,IAAMc,iBAAiB,gBAAGC,UAAU,CAClC,UAAAC,IAAA,EAUEC,GAAG,EACA;AAAA,EAAA,IAAAC,iBAAA,GAAAF,IAAA,CATDX,YAAY;AAAZA,IAAAA,YAAY,GAAAa,iBAAA,KAAA,MAAA,GAAGtB,qBAAqB,GAAAsB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,OAAO;AAAEoD,MAAAA,QAAQ,EAARA;KAAU;AACrB,EAAA;;AAEA;EACA,IAAIhF,YAAY,GAAGE,aAAa,EAAE;IAChC,OAAO;AAAE8E,MAAAA,QAAQ,EAAED;KAAa;AAClC,EAAA;;AAEA;AACA,EAAA,IAAMC,QAAQ,GAAIhF,YAAY,GAAGE,aAAa,GAAI0B,YAAY;EAE9D,OAAO;AAAEoD,IAAAA,QAAQ,EAARA;GAAU;AACrB;;;;"}
@@ -0,0 +1,34 @@
1
+ import '@babel/runtime/helpers/defineProperty';
2
+ import '@babel/runtime/helpers/slicedToArray';
3
+ import 'react';
4
+ import '@bigbinary/neeto-atoms';
5
+ import '@bigbinary/neeto-cist';
6
+ import '@bigbinary/neeto-commons-frontend/v2/initializers';
7
+ import 'ramda';
8
+ import 'react-i18next';
9
+ import '../useImageUploader-D8luC4Qw.js';
10
+ import '../useUploadDropzone-8Xa8PI-1.js';
11
+ import '../imagekit.esm-IYQEzBnD.js';
12
+ import '../useUnsplashApi-D_ekWD8p.js';
13
+ import '../utils-D5iQ8UME.js';
14
+ export { M as default } from '../index-BuSc2dEl.js';
15
+ import 'react/jsx-runtime';
16
+ import '@tanstack/react-query';
17
+ import '@bigbinary/neeto-commons-frontend/react-utils';
18
+ import '../query-BJnGLX4z.js';
19
+ import '@babel/runtime/helpers/asyncToGenerator';
20
+ import '@babel/runtime/regenerator';
21
+ import '@rails/activestorage';
22
+ import 'i18next';
23
+ import '@bigbinary/neeto-commons-frontend/initializers';
24
+ import '@bigbinary/neetoui/Toastr';
25
+ import 'axios';
26
+ import 'react-dropzone';
27
+ import '../constants-Csle2bxb.js';
28
+ import 'classnames';
29
+ import '@bigbinary/neeto-icons/LeftArrow';
30
+ import '@bigbinary/neeto-commons-frontend/v2/react-utils';
31
+ import '@bigbinary/neeto-commons-frontend/v2/utils';
32
+ import '@bigbinary/neeto-icons/MenuHorizontal';
33
+ import '@bigbinary/neeto-team-members-frontend/constants';
34
+ //# sourceMappingURL=AssetLibrary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AssetLibrary.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,69 @@
1
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
3
+ import { Button } from '@bigbinary/neeto-atoms';
4
+ import classnames from 'classnames';
5
+ import { noop } from '@bigbinary/neeto-cist';
6
+ import Delete from '@bigbinary/neeto-icons/Delete';
7
+ import { i as isNotNilOrEmpty, I as IMAGE_WRAPPER_CLASSNAME, a as ImageDirectUpload, b as isNilOrEmpty } from '../utils-D5iQ8UME.js';
8
+ import { I as ImageWithFallback } from '../ImageWithFallback-CSHOljd2.js';
9
+ import { jsx, jsxs } from 'react/jsx-runtime';
10
+ import 'react';
11
+ import 'ramda';
12
+ import 'react-i18next';
13
+ import '../useUploadDropzone-8Xa8PI-1.js';
14
+ import '@babel/runtime/helpers/slicedToArray';
15
+ import 'react-dropzone';
16
+ import 'i18next';
17
+ import '@bigbinary/neetoui/Toastr';
18
+ import '../imagekit.esm-IYQEzBnD.js';
19
+ import '@bigbinary/neeto-commons-frontend/v2/initializers';
20
+
21
+ var _excluded = ["src", "className", "imageFallbackProps", "onDrop", "isDisabled", "onRemove"];
22
+ function ownKeys(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; }
23
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
24
+ var BasicImageUploader = function BasicImageUploader(_ref) {
25
+ var _ref$src = _ref.src,
26
+ src = _ref$src === void 0 ? "" : _ref$src,
27
+ _ref$className = _ref.className,
28
+ className = _ref$className === void 0 ? "" : _ref$className,
29
+ _ref$imageFallbackPro = _ref.imageFallbackProps,
30
+ imageFallbackProps = _ref$imageFallbackPro === void 0 ? {
31
+ alt: "Uplaoded Image",
32
+ className: "h-full w-full"
33
+ } : _ref$imageFallbackPro,
34
+ _ref$onDrop = _ref.onDrop,
35
+ onDrop = _ref$onDrop === void 0 ? noop : _ref$onDrop,
36
+ _ref$isDisabled = _ref.isDisabled,
37
+ isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
38
+ _ref$onRemove = _ref.onRemove,
39
+ onRemove = _ref$onRemove === void 0 ? noop : _ref$onRemove,
40
+ props = _objectWithoutProperties(_ref, _excluded);
41
+ return /*#__PURE__*/jsx("div", {
42
+ className: classnames(className, {
43
+ "cursor-pointer": true,
44
+ "cursor-not-allowed": isDisabled,
45
+ "opacity-70": isDisabled && isNilOrEmpty(src)
46
+ }),
47
+ children: isNotNilOrEmpty(src) ? /*#__PURE__*/jsxs("div", {
48
+ className: IMAGE_WRAPPER_CLASSNAME,
49
+ children: [/*#__PURE__*/jsx(ImageWithFallback, _objectSpread(_objectSpread({}, _objectSpread(_objectSpread({}, imageFallbackProps), {}, {
50
+ src: src
51
+ })), {}, {
52
+ "data-testid": "uploaded-image"
53
+ })), /*#__PURE__*/jsx(Button, {
54
+ className: "absolute end-3 top-3",
55
+ "data-testid": "basic-image-uploader-remove-button",
56
+ disabled: isDisabled,
57
+ icon: Delete,
58
+ size: "sm",
59
+ onClick: onRemove
60
+ })]
61
+ }) : /*#__PURE__*/jsx(ImageDirectUpload, _objectSpread({}, _objectSpread(_objectSpread({}, props), {}, {
62
+ isDisabled: isDisabled,
63
+ onDrop: onDrop
64
+ })))
65
+ });
66
+ };
67
+
68
+ export { BasicImageUploader as default };
69
+ //# sourceMappingURL=BasicImageUploader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BasicImageUploader.js","sources":["../../app/javascript/src/v2/components/BasicImageUploader.jsx"],"sourcesContent":["import { Button } from \"@bigbinary/neeto-atoms\";\nimport classnames from \"classnames\";\nimport { noop } from \"neetocist\";\nimport { Delete } from \"neetoicons\";\n\nimport ImageDirectUpload from \"./common/ImageDirectUpload\";\nimport ImageWithFallback from \"./common/ImageWithFallback\";\nimport { IMAGE_WRAPPER_CLASSNAME } from \"./constants\";\nimport { isNilOrEmpty, isNotNilOrEmpty } from \"./ImageEditor/utils\";\n\nconst BasicImageUploader = ({\n src = \"\",\n className = \"\",\n imageFallbackProps = { alt: \"Uplaoded Image\", className: \"h-full w-full\" },\n onDrop = noop,\n isDisabled = false,\n onRemove = noop,\n ...props\n}) => (\n <div\n className={classnames(className, {\n \"cursor-pointer\": true,\n \"cursor-not-allowed\": isDisabled,\n \"opacity-70\": isDisabled && isNilOrEmpty(src),\n })}\n >\n {isNotNilOrEmpty(src) ? (\n <div className={IMAGE_WRAPPER_CLASSNAME}>\n <ImageWithFallback\n {...{ ...imageFallbackProps, src }}\n data-testid=\"uploaded-image\"\n />\n <Button\n className=\"absolute end-3 top-3\"\n data-testid=\"basic-image-uploader-remove-button\"\n disabled={isDisabled}\n icon={Delete}\n size=\"sm\"\n onClick={onRemove}\n />\n </div>\n ) : (\n <ImageDirectUpload {...{ ...props, isDisabled, onDrop }} />\n )}\n </div>\n);\n\nexport default BasicImageUploader;\n"],"names":["BasicImageUploader","_ref","_ref$src","src","_ref$className","className","_ref$imageFallbackPro","imageFallbackProps","alt","_ref$onDrop","onDrop","noop","_ref$isDisabled","isDisabled","_ref$onRemove","onRemove","props","_objectWithoutProperties","_excluded","_jsx","classnames","isNilOrEmpty","children","isNotNilOrEmpty","_jsxs","IMAGE_WRAPPER_CLASSNAME","ImageWithFallback","_objectSpread","Button","disabled","icon","Delete","size","onClick","ImageDirectUpload"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