@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.
- package/dist/.ready +1 -1
- package/dist/AssetLibrary.js +12 -9
- package/dist/AssetLibrary.js.map +1 -1
- package/dist/BasicImageUploader.js +4 -2
- package/dist/BasicImageUploader.js.map +1 -1
- package/dist/ImageForm.js +7 -4
- package/dist/ImageForm.js.map +1 -1
- package/dist/ImageUploader.js +9 -6
- package/dist/ImageUploader.js.map +1 -1
- package/dist/{ImageWithFallback-Bq5rs1yf.js → ImageWithFallback-B3DoquUi.js} +4 -4
- package/dist/ImageWithFallback-B3DoquUi.js.map +1 -0
- package/dist/ImageWithFallback-CSHOljd2.js +59 -0
- package/dist/ImageWithFallback-CSHOljd2.js.map +1 -0
- package/dist/ImageWithFallback-D1ClfJLn.js +61 -0
- package/dist/{ImageWithFallback-Bq5rs1yf.js.map → ImageWithFallback-D1ClfJLn.js.map} +1 -1
- package/dist/cjs/AssetLibrary.js +10 -7
- package/dist/cjs/AssetLibrary.js.map +1 -1
- package/dist/cjs/BasicImageUploader.js +5 -3
- package/dist/cjs/BasicImageUploader.js.map +1 -1
- package/dist/cjs/ImageForm.js +9 -6
- package/dist/cjs/ImageForm.js.map +1 -1
- package/dist/cjs/ImageUploader.js +14 -11
- package/dist/cjs/ImageUploader.js.map +1 -1
- package/dist/cjs/hooks.js +1 -1
- package/dist/cjs/index.js +9 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/v2/AssetLibrary.js +40 -0
- package/dist/cjs/v2/AssetLibrary.js.map +1 -0
- package/dist/cjs/v2/BasicImageUploader.js +71 -0
- package/dist/cjs/v2/BasicImageUploader.js.map +1 -0
- package/dist/cjs/v2/ImageForm.js +324 -0
- package/dist/cjs/v2/ImageForm.js.map +1 -0
- package/dist/cjs/v2/ImageUploader.js +247 -0
- package/dist/cjs/v2/ImageUploader.js.map +1 -0
- package/dist/cjs/v2/hooks.js +27 -0
- package/dist/cjs/v2/hooks.js.map +1 -0
- package/dist/cjs/v2/index.js +61 -0
- package/dist/cjs/v2/index.js.map +1 -0
- package/dist/cjs/v2/utils.js +9 -0
- package/dist/cjs/v2/utils.js.map +1 -0
- package/dist/constants-Csle2bxb.js +56 -0
- package/dist/constants-Csle2bxb.js.map +1 -0
- package/dist/constants-DI8wBtC-.js +68 -0
- package/dist/constants-DI8wBtC-.js.map +1 -0
- package/dist/hooks.js +3 -3
- package/dist/{imagekit.esm-CXW6c1fP.js → imagekit.esm-IYQEzBnD.js} +2 -2
- package/dist/{imagekit.esm-CXW6c1fP.js.map → imagekit.esm-IYQEzBnD.js.map} +1 -1
- package/dist/index-BuSc2dEl.js +949 -0
- package/dist/index-BuSc2dEl.js.map +1 -0
- package/dist/index-CBorETxd.js +972 -0
- package/dist/index-CBorETxd.js.map +1 -0
- package/dist/index-Cv97u10a.js +952 -0
- package/dist/index-Cv97u10a.js.map +1 -0
- package/dist/index-krkZ4CNS.js +969 -0
- package/dist/index-krkZ4CNS.js.map +1 -0
- package/dist/index.js +10 -7
- package/dist/index.js.map +1 -1
- package/dist/{useImageUploader-BLOdyAwv.js → useImageUploader-D8luC4Qw.js} +2 -2
- package/dist/{useImageUploader-BLOdyAwv.js.map → useImageUploader-D8luC4Qw.js.map} +1 -1
- package/dist/{useProfileImageUpload-CiGxDpEx.js → useProfileImageUpload-CbjVfcfI.js} +3 -3
- package/dist/{useProfileImageUpload-CiGxDpEx.js.map → useProfileImageUpload-CbjVfcfI.js.map} +1 -1
- package/dist/{useProfileImageUpload-DkmUBjtt.js → useProfileImageUpload-DbanXK57.js} +6 -6
- package/dist/useProfileImageUpload-DbanXK57.js.map +1 -0
- package/dist/useUnsplashApi-CNeNh58q.js +1065 -0
- package/dist/useUnsplashApi-CNeNh58q.js.map +1 -0
- package/dist/useUnsplashApi-D_ekWD8p.js +1057 -0
- package/dist/useUnsplashApi-D_ekWD8p.js.map +1 -0
- package/dist/useUploadDropzone-8Xa8PI-1.js +56 -0
- package/dist/useUploadDropzone-8Xa8PI-1.js.map +1 -0
- package/dist/useUploadDropzone-DMv8VMRF.js +58 -0
- package/dist/useUploadDropzone-DMv8VMRF.js.map +1 -0
- package/dist/utils-BTmA9hHb.js +364 -0
- package/dist/utils-BTmA9hHb.js.map +1 -0
- package/dist/{utils-YicuhSoR.js → utils-D5iQ8UME.js} +29 -66
- package/dist/utils-D5iQ8UME.js.map +1 -0
- package/dist/{utils-CoOpqzJA.js → utils-De7yUxgQ.js} +37 -75
- package/dist/utils-De7yUxgQ.js.map +1 -0
- package/dist/utils-DyCNC3w5.js +347 -0
- package/dist/utils-DyCNC3w5.js.map +1 -0
- package/dist/v2/AssetLibrary.js +34 -0
- package/dist/v2/AssetLibrary.js.map +1 -0
- package/dist/v2/BasicImageUploader.js +69 -0
- package/dist/v2/BasicImageUploader.js.map +1 -0
- package/dist/v2/ImageForm.js +322 -0
- package/dist/v2/ImageForm.js.map +1 -0
- package/dist/v2/ImageUploader.js +245 -0
- package/dist/v2/ImageUploader.js.map +1 -0
- package/dist/v2/hooks.js +19 -0
- package/dist/v2/hooks.js.map +1 -0
- package/dist/v2/index.js +48 -0
- package/dist/v2/index.js.map +1 -0
- package/dist/v2/utils.js +3 -0
- package/dist/v2/utils.js.map +1 -0
- package/package.json +51 -39
- package/dist/index-BGVHZZys.js +0 -2410
- package/dist/index-BGVHZZys.js.map +0 -1
- package/dist/index-CjVmJmv5.js +0 -2413
- package/dist/index-CjVmJmv5.js.map +0 -1
- package/dist/useProfileImageUpload-DkmUBjtt.js.map +0 -1
- package/dist/utils-CoOpqzJA.js.map +0 -1
- package/dist/utils-YicuhSoR.js.map +0 -1
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
|
+
var require$$0 = require('react');
|
|
5
|
+
var classnames = require('classnames');
|
|
6
|
+
var neetoCist = require('@bigbinary/neeto-cist');
|
|
7
|
+
var Button = require('@bigbinary/neetoui/Button');
|
|
8
|
+
var Typography = require('@bigbinary/neetoui/Typography');
|
|
9
|
+
var ProgressBar = require('@bigbinary/neetoui/ProgressBar');
|
|
10
|
+
var ramda = require('ramda');
|
|
11
|
+
var reactI18next = require('react-i18next');
|
|
12
|
+
var initializers = require('@bigbinary/neeto-commons-frontend/initializers');
|
|
13
|
+
var useUploadDropzone = require('./useUploadDropzone-DMv8VMRF.js');
|
|
14
|
+
var imagekit_esm = require('./imagekit.esm-CisvUNYU.js');
|
|
15
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
16
|
+
|
|
17
|
+
var DEFAULT_ALLOWED_IMAGE_TYPES = {
|
|
18
|
+
"image/png": [".png"],
|
|
19
|
+
"image/jpg": [".jpg", ".jpeg"],
|
|
20
|
+
"image/gif": [".gif"],
|
|
21
|
+
"image/svg+xml": [".svg"]
|
|
22
|
+
};
|
|
23
|
+
var DEFAULT_UPLOAD_CONFIG = {
|
|
24
|
+
maxImageSize: initializers.globalProps.endUserUploadedFileSizeLimitInMb,
|
|
25
|
+
allowedImageTypes: DEFAULT_ALLOWED_IMAGE_TYPES
|
|
26
|
+
};
|
|
27
|
+
var OPTION_KEYS = {
|
|
28
|
+
asset: "asset",
|
|
29
|
+
remove: "remove"
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
var getAllowedTypes = function getAllowedTypes(uploadConfig) {
|
|
33
|
+
return ramda.pipe(ramda.values, ramda.flatten, ramda.map(function (extension) {
|
|
34
|
+
return extension.slice(1);
|
|
35
|
+
}), ramda.map(ramda.toUpper), ramda.join(", "))(uploadConfig.allowedImageTypes);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
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; }
|
|
39
|
+
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; }
|
|
40
|
+
var ImageDirectUpload = /*#__PURE__*/require$$0.forwardRef(function (_ref, ref) {
|
|
41
|
+
var _ref$uploadConfig = _ref.uploadConfig,
|
|
42
|
+
uploadConfig = _ref$uploadConfig === void 0 ? DEFAULT_UPLOAD_CONFIG : _ref$uploadConfig,
|
|
43
|
+
_ref$onDrop = _ref.onDrop,
|
|
44
|
+
onDrop = _ref$onDrop === void 0 ? neetoCist.noop : _ref$onDrop,
|
|
45
|
+
_ref$isDisabled = _ref.isDisabled,
|
|
46
|
+
isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
|
|
47
|
+
setIsAssetLibraryOpen = _ref.setIsAssetLibraryOpen,
|
|
48
|
+
_ref$defaultImageSize = _ref.defaultImageSize,
|
|
49
|
+
defaultImageSize = _ref$defaultImageSize === void 0 ? {} : _ref$defaultImageSize,
|
|
50
|
+
_ref$isUploadDisabled = _ref.isUploadDisabled,
|
|
51
|
+
isUploadDisabled = _ref$isUploadDisabled === void 0 ? false : _ref$isUploadDisabled,
|
|
52
|
+
setImage = _ref.setImage;
|
|
53
|
+
var _useUploadDropzone = useUploadDropzone.useUploadDropzone({
|
|
54
|
+
uploadConfig: uploadConfig,
|
|
55
|
+
onDrop: onDrop,
|
|
56
|
+
setImage: setImage
|
|
57
|
+
}),
|
|
58
|
+
getRootProps = _useUploadDropzone.getRootProps,
|
|
59
|
+
getInputProps = _useUploadDropzone.getInputProps,
|
|
60
|
+
isDragActive = _useUploadDropzone.isDragActive,
|
|
61
|
+
open = _useUploadDropzone.open,
|
|
62
|
+
uploadProgress = _useUploadDropzone.uploadProgress,
|
|
63
|
+
setUploadProgress = _useUploadDropzone.setUploadProgress;
|
|
64
|
+
require$$0.useImperativeHandle(ref, function () {
|
|
65
|
+
return {
|
|
66
|
+
upload: function upload(file) {
|
|
67
|
+
return onDrop(file, setUploadProgress, setImage);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
var shouldShowProgress = !!(uploadProgress && !ramda.equals(uploadProgress, 1));
|
|
72
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", _objectSpread(_objectSpread({}, getRootProps()), {}, {
|
|
73
|
+
className: classnames(imagekit_esm.DROPZONE_ROOT_DIV_CLASSNAME, {
|
|
74
|
+
"neeto-ui-border-gray-300": !isDragActive,
|
|
75
|
+
"neeto-ui-border-gray-700": isDragActive
|
|
76
|
+
}),
|
|
77
|
+
children: shouldShowProgress ? /*#__PURE__*/jsxRuntime.jsx(ProgressBar, {
|
|
78
|
+
progressPercentage: uploadProgress,
|
|
79
|
+
progressValue: "".concat(uploadProgress, "%")
|
|
80
|
+
}) : /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
81
|
+
className: "flex flex-col space-y-1",
|
|
82
|
+
children: [!isDisabled && /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
83
|
+
className: "neeto-ui-text-gray-800 text-center leading-4",
|
|
84
|
+
style: "body2",
|
|
85
|
+
children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
|
|
86
|
+
i18nKey: "neetoImageUploader.imageUpload.dragAndDropOrBrowseFile",
|
|
87
|
+
components: {
|
|
88
|
+
span: /*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
89
|
+
"data-testid": "neeto-image-uploader-browse-text",
|
|
90
|
+
style: "link",
|
|
91
|
+
onClick: function onClick(event) {
|
|
92
|
+
event.stopPropagation();
|
|
93
|
+
open();
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
})
|
|
98
|
+
}), setIsAssetLibraryOpen && /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
99
|
+
style: "body2",
|
|
100
|
+
className: classnames("text-center leading-4", {
|
|
101
|
+
"pointer-events-none": isUploadDisabled
|
|
102
|
+
}),
|
|
103
|
+
onClick: function onClick(e) {
|
|
104
|
+
e.stopPropagation();
|
|
105
|
+
setIsAssetLibraryOpen(true);
|
|
106
|
+
},
|
|
107
|
+
children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
|
|
108
|
+
i18nKey: "neetoImageUploader.imageUpload.upload",
|
|
109
|
+
components: {
|
|
110
|
+
span: /*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
111
|
+
"data-testid": "open-asset-library-button",
|
|
112
|
+
style: "link"
|
|
113
|
+
})
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
}), /*#__PURE__*/jsxRuntime.jsx("input", _objectSpread(_objectSpread({}, getInputProps()), {}, {
|
|
117
|
+
"data-testid": "neeto-image-uploader-file-input",
|
|
118
|
+
disabled: isDisabled || isUploadDisabled
|
|
119
|
+
})), /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
120
|
+
className: "neeto-ui-text-gray-700 text-center leading-4",
|
|
121
|
+
"data-testid": "neeto-image-uploader-restriction-message",
|
|
122
|
+
lineHeight: "snug",
|
|
123
|
+
style: "nano",
|
|
124
|
+
children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
|
|
125
|
+
i18nKey: "neetoImageUploader.imageUpload.restrictionMessage",
|
|
126
|
+
values: {
|
|
127
|
+
fileTypes: getAllowedTypes(uploadConfig),
|
|
128
|
+
size: uploadConfig === null || uploadConfig === void 0 ? void 0 : uploadConfig.maxImageSize
|
|
129
|
+
}
|
|
130
|
+
})
|
|
131
|
+
}), neetoCist.isPresent(defaultImageSize) && /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
132
|
+
className: "neeto-ui-text-gray-700 text-center leading-4",
|
|
133
|
+
"data-testid": "neeto-image-uploader-ideal-image-size-info-text",
|
|
134
|
+
lineHeight: "snug",
|
|
135
|
+
style: "nano",
|
|
136
|
+
children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
|
|
137
|
+
i18nKey: "neetoImageUploader.imageUpload.idealImageSizeInfo",
|
|
138
|
+
values: _objectSpread({}, defaultImageSize)
|
|
139
|
+
})
|
|
140
|
+
})]
|
|
141
|
+
})
|
|
142
|
+
}));
|
|
143
|
+
});
|
|
144
|
+
ImageDirectUpload.displayName = "ImageDirectUpload";
|
|
145
|
+
|
|
146
|
+
var getWholeNumberAspectRatio = function getWholeNumberAspectRatio(_ref) {
|
|
147
|
+
var width = _ref.width,
|
|
148
|
+
height = _ref.height;
|
|
149
|
+
if (width === height) return {
|
|
150
|
+
width: 1,
|
|
151
|
+
height: 1
|
|
152
|
+
};
|
|
153
|
+
var _gcd = function gcd(a, b) {
|
|
154
|
+
return b === 0 ? a : _gcd(b, a % b);
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
// Multiplying by 1000 is a temporary fix to prevent height and width with fractions (eg: 100.91).
|
|
158
|
+
var divisor = _gcd(width * 1000, height * 1000);
|
|
159
|
+
return {
|
|
160
|
+
width: width / divisor,
|
|
161
|
+
height: height / divisor
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
var getCropValues = function getCropValues(_ref2) {
|
|
165
|
+
var crop = _ref2.crop,
|
|
166
|
+
imageRef = _ref2.imageRef;
|
|
167
|
+
var naturalWidth = imageRef.current.naturalWidth;
|
|
168
|
+
var naturalHeight = imageRef.current.naturalHeight;
|
|
169
|
+
return {
|
|
170
|
+
x: crop.x / 100 * naturalWidth,
|
|
171
|
+
y: crop.y / 100 * naturalHeight,
|
|
172
|
+
width: crop.width / 100 * naturalWidth,
|
|
173
|
+
height: crop.height / 100 * naturalHeight
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
var getImageKitCroppedURL = function getImageKitCroppedURL(_ref3) {
|
|
177
|
+
var imageURL = _ref3.imageURL,
|
|
178
|
+
crop = _ref3.crop,
|
|
179
|
+
imageRef = _ref3.imageRef;
|
|
180
|
+
var imagekit = new imagekit_esm.ImageKit({
|
|
181
|
+
urlEndpoint: initializers.globalProps.imagekit.urlEndpoint
|
|
182
|
+
});
|
|
183
|
+
var _getCropValues = getCropValues({
|
|
184
|
+
crop: crop,
|
|
185
|
+
imageRef: imageRef
|
|
186
|
+
}),
|
|
187
|
+
x = _getCropValues.x,
|
|
188
|
+
y = _getCropValues.y,
|
|
189
|
+
height = _getCropValues.height,
|
|
190
|
+
width = _getCropValues.width;
|
|
191
|
+
var transformation = [{
|
|
192
|
+
cropMode: "extract",
|
|
193
|
+
x: x,
|
|
194
|
+
y: y,
|
|
195
|
+
height: height,
|
|
196
|
+
width: width
|
|
197
|
+
}];
|
|
198
|
+
return imagekit.url({
|
|
199
|
+
src: imageURL,
|
|
200
|
+
transformation: transformation
|
|
201
|
+
});
|
|
202
|
+
};
|
|
203
|
+
var isNilOrEmpty = function isNilOrEmpty(value) {
|
|
204
|
+
return ramda.isNil(value) || ramda.isEmpty(value);
|
|
205
|
+
};
|
|
206
|
+
var isNotNilOrEmpty = function isNotNilOrEmpty(value) {
|
|
207
|
+
return !isNilOrEmpty(value);
|
|
208
|
+
};
|
|
209
|
+
var isItemsCenter = function isItemsCenter(_ref4) {
|
|
210
|
+
var imageRef = _ref4.imageRef,
|
|
211
|
+
wrapperRef = _ref4.wrapperRef;
|
|
212
|
+
var _ref5 = imageRef.current || {},
|
|
213
|
+
imageHeight = _ref5.height,
|
|
214
|
+
imageWidth = _ref5.width;
|
|
215
|
+
var wrapperHeight = (wrapperRef.current || {}).clientHeight;
|
|
216
|
+
if (imageHeight < imageWidth && imageHeight < wrapperHeight - 1) {
|
|
217
|
+
// Landscape images smaller than wrapper dimensions
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
220
|
+
if (imageHeight === imageWidth && imageHeight < wrapperHeight - 1) {
|
|
221
|
+
// Square images smaller than wrapper dimensions
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
return imageHeight > imageWidth && imageHeight < wrapperHeight - 1;
|
|
225
|
+
};
|
|
226
|
+
var calculateCloudFlareImageCroppedValues = function calculateCloudFlareImageCroppedValues(_ref6) {
|
|
227
|
+
var image = _ref6.image,
|
|
228
|
+
crop = _ref6.crop;
|
|
229
|
+
var naturalWidth = image.metadata.width;
|
|
230
|
+
var naturalHeight = image.metadata.height;
|
|
231
|
+
var sourceX = crop.x / 100 * naturalWidth;
|
|
232
|
+
var sourceY = crop.y / 100 * naturalHeight;
|
|
233
|
+
var sourceWidth = crop.width / 100 * naturalWidth;
|
|
234
|
+
var sourceHeight = crop.height / 100 * naturalHeight;
|
|
235
|
+
var distanceFromRight = Math.abs(naturalWidth - (sourceX + sourceWidth));
|
|
236
|
+
var distanceFromBottom = Math.abs(naturalHeight - (sourceY + sourceHeight));
|
|
237
|
+
return {
|
|
238
|
+
top: sourceY,
|
|
239
|
+
right: distanceFromRight,
|
|
240
|
+
bottom: distanceFromBottom,
|
|
241
|
+
left: sourceX
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
var getCloudFlareCroppedURL = function getCloudFlareCroppedURL(_ref7) {
|
|
245
|
+
var image = _ref7.image,
|
|
246
|
+
crop = _ref7.crop;
|
|
247
|
+
var _calculateCloudFlareI = calculateCloudFlareImageCroppedValues({
|
|
248
|
+
image: image,
|
|
249
|
+
crop: crop
|
|
250
|
+
}),
|
|
251
|
+
top = _calculateCloudFlareI.top,
|
|
252
|
+
right = _calculateCloudFlareI.right,
|
|
253
|
+
bottom = _calculateCloudFlareI.bottom,
|
|
254
|
+
left = _calculateCloudFlareI.left;
|
|
255
|
+
var trimValues = "".concat(top, ";").concat(right, ";").concat(bottom, ";").concat(left);
|
|
256
|
+
return image.url.replace("public", "trim=".concat(trimValues));
|
|
257
|
+
};
|
|
258
|
+
var getAspectRatio = function getAspectRatio(_ref8) {
|
|
259
|
+
var fixedAspectRatio = _ref8.fixedAspectRatio,
|
|
260
|
+
imageSize = _ref8.imageSize;
|
|
261
|
+
if (neetoCist.isPresent(fixedAspectRatio === null || fixedAspectRatio === void 0 ? void 0 : fixedAspectRatio.width) && neetoCist.isPresent(fixedAspectRatio === null || fixedAspectRatio === void 0 ? void 0 : fixedAspectRatio.height)) {
|
|
262
|
+
return fixedAspectRatio;
|
|
263
|
+
}
|
|
264
|
+
if (neetoCist.isPresent(imageSize === null || imageSize === void 0 ? void 0 : imageSize.width) && neetoCist.isPresent(imageSize === null || imageSize === void 0 ? void 0 : imageSize.height)) {
|
|
265
|
+
return getWholeNumberAspectRatio(imageSize);
|
|
266
|
+
}
|
|
267
|
+
return {
|
|
268
|
+
width: 16,
|
|
269
|
+
height: 9
|
|
270
|
+
};
|
|
271
|
+
};
|
|
272
|
+
var getPixels = function getPixels(percentage, pixel) {
|
|
273
|
+
return Math.round(percentage / 100 * pixel);
|
|
274
|
+
};
|
|
275
|
+
var getPercentage = function getPercentage(crop, full) {
|
|
276
|
+
return crop / full * 100;
|
|
277
|
+
};
|
|
278
|
+
var getInitialCropSize = function getInitialCropSize(_ref9) {
|
|
279
|
+
var image = _ref9.image,
|
|
280
|
+
aspectRatioFactor = _ref9.aspectRatioFactor,
|
|
281
|
+
maxCropWidth = _ref9.maxCropWidth;
|
|
282
|
+
var imageWidth = image.naturalWidth,
|
|
283
|
+
imageHeight = image.naturalHeight;
|
|
284
|
+
var imageAspectRatio = imageWidth / imageHeight;
|
|
285
|
+
var maxCropHeight = maxCropWidth / aspectRatioFactor;
|
|
286
|
+
var cropWidth, cropHeight;
|
|
287
|
+
if (imageAspectRatio > aspectRatioFactor) {
|
|
288
|
+
cropWidth = Math.min(maxCropWidth, imageWidth);
|
|
289
|
+
cropHeight = cropWidth / aspectRatioFactor;
|
|
290
|
+
} else if (imageHeight < maxCropHeight) {
|
|
291
|
+
cropWidth = imageWidth;
|
|
292
|
+
cropHeight = imageHeight;
|
|
293
|
+
} else {
|
|
294
|
+
cropHeight = Math.min(maxCropHeight, imageHeight);
|
|
295
|
+
cropWidth = cropHeight * aspectRatioFactor;
|
|
296
|
+
}
|
|
297
|
+
return {
|
|
298
|
+
cropWidth: cropWidth,
|
|
299
|
+
cropHeight: cropHeight
|
|
300
|
+
};
|
|
301
|
+
};
|
|
302
|
+
var getHeightFromAspectRatio = function getHeightFromAspectRatio(width, aspectRatio) {
|
|
303
|
+
return Math.round(width * aspectRatio.height / aspectRatio.width);
|
|
304
|
+
};
|
|
305
|
+
var getWidthFromAspectRatio = function getWidthFromAspectRatio(height, aspectRatio) {
|
|
306
|
+
return Math.round(height * aspectRatio.width / aspectRatio.height);
|
|
307
|
+
};
|
|
308
|
+
var getWrapperRefStyles = function getWrapperRefStyles(wrapperRef, imageRef) {
|
|
309
|
+
var _ref10 = imageRef.current || {},
|
|
310
|
+
_ref10$naturalHeight = _ref10.naturalHeight,
|
|
311
|
+
naturalHeight = _ref10$naturalHeight === void 0 ? 100 : _ref10$naturalHeight,
|
|
312
|
+
_ref10$naturalWidth = _ref10.naturalWidth,
|
|
313
|
+
naturalWidth = _ref10$naturalWidth === void 0 ? 100 : _ref10$naturalWidth;
|
|
314
|
+
var _ref11 = wrapperRef.current || {},
|
|
315
|
+
_ref11$clientHeight = _ref11.clientHeight,
|
|
316
|
+
clientHeight = _ref11$clientHeight === void 0 ? 100 : _ref11$clientHeight,
|
|
317
|
+
_ref11$clientWidth = _ref11.clientWidth,
|
|
318
|
+
clientWidth = _ref11$clientWidth === void 0 ? 100 : _ref11$clientWidth;
|
|
319
|
+
if (naturalWidth <= clientWidth && naturalHeight <= clientHeight) {
|
|
320
|
+
return {
|
|
321
|
+
maxWidth: naturalWidth
|
|
322
|
+
};
|
|
323
|
+
} else if (naturalWidth > clientWidth && naturalHeight <= clientHeight) {
|
|
324
|
+
return {
|
|
325
|
+
maxWidth: clientWidth
|
|
326
|
+
};
|
|
327
|
+
} else if (naturalWidth <= clientWidth && naturalHeight > clientHeight) {
|
|
328
|
+
var _maxWidth = naturalWidth / naturalHeight * clientHeight;
|
|
329
|
+
return {
|
|
330
|
+
maxWidth: _maxWidth
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// landscape
|
|
335
|
+
if (naturalWidth > naturalHeight) {
|
|
336
|
+
return {
|
|
337
|
+
maxWidth: clientWidth
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// portrait
|
|
342
|
+
var maxWidth = naturalWidth / naturalHeight * clientHeight;
|
|
343
|
+
return {
|
|
344
|
+
maxWidth: maxWidth
|
|
345
|
+
};
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
exports.DEFAULT_UPLOAD_CONFIG = DEFAULT_UPLOAD_CONFIG;
|
|
349
|
+
exports.ImageDirectUpload = ImageDirectUpload;
|
|
350
|
+
exports.OPTION_KEYS = OPTION_KEYS;
|
|
351
|
+
exports.getAspectRatio = getAspectRatio;
|
|
352
|
+
exports.getCloudFlareCroppedURL = getCloudFlareCroppedURL;
|
|
353
|
+
exports.getCropValues = getCropValues;
|
|
354
|
+
exports.getHeightFromAspectRatio = getHeightFromAspectRatio;
|
|
355
|
+
exports.getImageKitCroppedURL = getImageKitCroppedURL;
|
|
356
|
+
exports.getInitialCropSize = getInitialCropSize;
|
|
357
|
+
exports.getPercentage = getPercentage;
|
|
358
|
+
exports.getPixels = getPixels;
|
|
359
|
+
exports.getWidthFromAspectRatio = getWidthFromAspectRatio;
|
|
360
|
+
exports.getWrapperRefStyles = getWrapperRefStyles;
|
|
361
|
+
exports.isItemsCenter = isItemsCenter;
|
|
362
|
+
exports.isNilOrEmpty = isNilOrEmpty;
|
|
363
|
+
exports.isNotNilOrEmpty = isNotNilOrEmpty;
|
|
364
|
+
//# sourceMappingURL=utils-BTmA9hHb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils-BTmA9hHb.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,wBAAW,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;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;AAAXA,IAAAA,WAAW,GAAAD,kBAAA,KAAA,MAAA,GAAG,GAAG,GAAAA,kBAAA;AAE7C,EAAA,IAAI9E,YAAY,IAAI+E,WAAW,IAAI7E,aAAa,IAAI0B,YAAY,EAAE;IAChE,OAAO;AAAEoD,MAAAA,QAAQ,EAAEhF;KAAc;EACnC,CAAC,MAAM,IAAIA,YAAY,GAAG+E,WAAW,IAAI7E,aAAa,IAAI0B,YAAY,EAAE;IACtE,OAAO;AAAEoD,MAAAA,QAAQ,EAAED;KAAa;EAClC,CAAC,MAAM,IAAI/E,YAAY,IAAI+E,WAAW,IAAI7E,aAAa,GAAG0B,YAAY,EAAE;AACtE,IAAA,IAAMoD,SAAQ,GAAIhF,YAAY,GAAGE,aAAa,GAAI0B,YAAY;IAE9D,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;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
-
import {
|
|
2
|
+
import { forwardRef, useImperativeHandle } from 'react';
|
|
3
|
+
import { Progress, Typography, Button } from '@bigbinary/neeto-atoms';
|
|
3
4
|
import classnames from 'classnames';
|
|
4
|
-
import {
|
|
5
|
-
import Button from '@bigbinary/neetoui/Button';
|
|
6
|
-
import Typography from '@bigbinary/neetoui/Typography';
|
|
7
|
-
import ProgressBar from '@bigbinary/neetoui/ProgressBar';
|
|
5
|
+
import { isPresent, noop } from '@bigbinary/neeto-cist';
|
|
8
6
|
import { pipe, values, flatten, map, toUpper, join, equals, isNil, isEmpty } from 'ramda';
|
|
9
7
|
import { Trans } from 'react-i18next';
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import { useDropzone } from 'react-dropzone';
|
|
8
|
+
import { u as useUploadDropzone } from './useUploadDropzone-8Xa8PI-1.js';
|
|
9
|
+
import { globalProps } from '@bigbinary/neeto-commons-frontend/v2/initializers';
|
|
13
10
|
import i18next, { t } from 'i18next';
|
|
14
|
-
import Toastr from '@bigbinary/neetoui/Toastr';
|
|
15
|
-
import { F as FILE_ERRORS, D as DROPZONE_ROOT_DIV_CLASSNAME, C as CLOUD_FLARE, b as IMAGE_UPLOADER_BASE_URL, I as IS_DEVELOPMENT_OR_HEROKU_ENV, a as ImageKit } from './imagekit.esm-CXW6c1fP.js';
|
|
16
11
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
12
|
+
import { C as CLOUD_FLARE, a as IMAGE_UPLOADER_BASE_URL, I as IS_DEVELOPMENT_OR_HEROKU_ENV, b as ImageKit } from './imagekit.esm-IYQEzBnD.js';
|
|
17
13
|
|
|
18
14
|
var DEFAULT_ALLOWED_IMAGE_TYPES = {
|
|
19
15
|
"image/png": [".png"],
|
|
@@ -36,49 +32,13 @@ var getAllowedTypes = function getAllowedTypes(uploadConfig) {
|
|
|
36
32
|
}), map(toUpper), join(", "))(uploadConfig.allowedImageTypes);
|
|
37
33
|
};
|
|
38
34
|
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
var useUploadDropzone = function useUploadDropzone(_ref) {
|
|
50
|
-
var _ref$uploadConfig = _ref.uploadConfig,
|
|
51
|
-
uploadConfig = _ref$uploadConfig === void 0 ? {
|
|
52
|
-
allowedImageTypes: [],
|
|
53
|
-
maxImageSize: 0
|
|
54
|
-
} : _ref$uploadConfig,
|
|
55
|
-
_onDrop = _ref.onDrop,
|
|
56
|
-
_ref$setImage = _ref.setImage,
|
|
57
|
-
setImage = _ref$setImage === void 0 ? noop : _ref$setImage;
|
|
58
|
-
var _useState = useState(0),
|
|
59
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
60
|
-
uploadProgress = _useState2[0],
|
|
61
|
-
setUploadProgress = _useState2[1];
|
|
62
|
-
var _useDropzone = useDropzone({
|
|
63
|
-
onDrop: function onDrop(acceptedFiles) {
|
|
64
|
-
return _onDrop(acceptedFiles[0], setUploadProgress, setImage);
|
|
65
|
-
},
|
|
66
|
-
accept: uploadConfig === null || uploadConfig === void 0 ? void 0 : uploadConfig.allowedImageTypes,
|
|
67
|
-
multiple: false,
|
|
68
|
-
maxSize: uploadConfig.maxImageSize * 1048576,
|
|
69
|
-
onDropRejected: handleDropRejected
|
|
70
|
-
}),
|
|
71
|
-
getRootProps = _useDropzone.getRootProps,
|
|
72
|
-
getInputProps = _useDropzone.getInputProps,
|
|
73
|
-
isDragActive = _useDropzone.isDragActive;
|
|
74
|
-
return {
|
|
75
|
-
getRootProps: getRootProps,
|
|
76
|
-
getInputProps: getInputProps,
|
|
77
|
-
isDragActive: isDragActive,
|
|
78
|
-
uploadProgress: uploadProgress,
|
|
79
|
-
setUploadProgress: setUploadProgress
|
|
80
|
-
};
|
|
81
|
-
};
|
|
35
|
+
var DROPZONE_ROOT_DIV_CLASSNAME = "neeto-ui-border-primary-600 hover:neeto-ui-bg-gray-100 neeto-ui-rounded-lg flex h-full w-full flex-col items-center justify-center gap-3 border border-dashed p-4 transition-all duration-300 ease-in-out relative";
|
|
36
|
+
({
|
|
37
|
+
"file-invalid-type": t("neetoImageUploader.imageUpload.fileTypeError"),
|
|
38
|
+
"file-too-large": t("neetoImageUploader.imageUpload.fileSizeError"),
|
|
39
|
+
"file-dimension-too-large": t("neetoImageUploader.imageUpload.fileDimensionError"),
|
|
40
|
+
"file-resolution-too-large": t("neetoImageUploader.imageUpload.fileResolutionError")
|
|
41
|
+
});
|
|
82
42
|
|
|
83
43
|
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; }
|
|
84
44
|
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; }
|
|
@@ -103,6 +63,7 @@ var ImageDirectUpload = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
103
63
|
getRootProps = _useUploadDropzone.getRootProps,
|
|
104
64
|
getInputProps = _useUploadDropzone.getInputProps,
|
|
105
65
|
isDragActive = _useUploadDropzone.isDragActive,
|
|
66
|
+
open = _useUploadDropzone.open,
|
|
106
67
|
uploadProgress = _useUploadDropzone.uploadProgress,
|
|
107
68
|
setUploadProgress = _useUploadDropzone.setUploadProgress;
|
|
108
69
|
useImperativeHandle(ref, function () {
|
|
@@ -118,25 +79,29 @@ var ImageDirectUpload = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
118
79
|
"neeto-ui-border-gray-300": !isDragActive,
|
|
119
80
|
"neeto-ui-border-gray-700": isDragActive
|
|
120
81
|
}),
|
|
121
|
-
children: shouldShowProgress ? /*#__PURE__*/jsx(
|
|
122
|
-
|
|
123
|
-
|
|
82
|
+
children: shouldShowProgress ? /*#__PURE__*/jsx(Progress, {
|
|
83
|
+
progressValue: "".concat(uploadProgress, "%"),
|
|
84
|
+
value: uploadProgress
|
|
124
85
|
}) : /*#__PURE__*/jsxs("div", {
|
|
125
86
|
className: "flex flex-col space-y-1",
|
|
126
87
|
children: [!isDisabled && /*#__PURE__*/jsx(Typography, {
|
|
127
88
|
className: "neeto-ui-text-gray-800 text-center leading-4",
|
|
128
|
-
|
|
89
|
+
variant: "body2",
|
|
129
90
|
children: /*#__PURE__*/jsx(Trans, {
|
|
130
91
|
i18nKey: "neetoImageUploader.imageUpload.dragAndDropOrBrowseFile",
|
|
131
92
|
components: {
|
|
132
93
|
span: /*#__PURE__*/jsx(Button, {
|
|
133
94
|
"data-testid": "neeto-image-uploader-browse-text",
|
|
134
|
-
|
|
95
|
+
variant: "link",
|
|
96
|
+
onClick: function onClick(event) {
|
|
97
|
+
event.stopPropagation();
|
|
98
|
+
open();
|
|
99
|
+
}
|
|
135
100
|
})
|
|
136
101
|
}
|
|
137
102
|
})
|
|
138
103
|
}), setIsAssetLibraryOpen && /*#__PURE__*/jsx(Typography, {
|
|
139
|
-
|
|
104
|
+
variant: "body2",
|
|
140
105
|
className: classnames("text-center leading-4", {
|
|
141
106
|
"pointer-events-none": isUploadDisabled
|
|
142
107
|
}),
|
|
@@ -149,7 +114,7 @@ var ImageDirectUpload = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
149
114
|
components: {
|
|
150
115
|
span: /*#__PURE__*/jsx(Button, {
|
|
151
116
|
"data-testid": "open-asset-library-button",
|
|
152
|
-
|
|
117
|
+
variant: "link"
|
|
153
118
|
})
|
|
154
119
|
}
|
|
155
120
|
})
|
|
@@ -159,8 +124,7 @@ var ImageDirectUpload = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
159
124
|
})), /*#__PURE__*/jsx(Typography, {
|
|
160
125
|
className: "neeto-ui-text-gray-700 text-center leading-4",
|
|
161
126
|
"data-testid": "neeto-image-uploader-restriction-message",
|
|
162
|
-
|
|
163
|
-
style: "nano",
|
|
127
|
+
variant: "nano",
|
|
164
128
|
children: /*#__PURE__*/jsx(Trans, {
|
|
165
129
|
i18nKey: "neetoImageUploader.imageUpload.restrictionMessage",
|
|
166
130
|
values: {
|
|
@@ -171,8 +135,7 @@ var ImageDirectUpload = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
171
135
|
}), isPresent(defaultImageSize) && /*#__PURE__*/jsx(Typography, {
|
|
172
136
|
className: "neeto-ui-text-gray-700 text-center leading-4",
|
|
173
137
|
"data-testid": "neeto-image-uploader-ideal-image-size-info-text",
|
|
174
|
-
|
|
175
|
-
style: "nano",
|
|
138
|
+
variant: "nano",
|
|
176
139
|
children: /*#__PURE__*/jsx(Trans, {
|
|
177
140
|
i18nKey: "neetoImageUploader.imageUpload.idealImageSizeInfo",
|
|
178
141
|
values: _objectSpread({}, defaultImageSize)
|
|
@@ -435,5 +398,5 @@ var getWrapperRefStyles = function getWrapperRefStyles(wrapperRef, imageRef) {
|
|
|
435
398
|
};
|
|
436
399
|
};
|
|
437
400
|
|
|
438
|
-
export { ASSETS_DESTROY_URL as A, DEFAULT_UPLOAD_CONFIG as D, IMAGE_WRAPPER_CLASSNAME as I, OPTION_KEYS as O, TABS as T, UNSPLASH_DEFAULT_NAME as U, ImageDirectUpload as a, isNilOrEmpty as b, DEFAULT_CROP_CONFIG as c, getPixels as d, getHeightFromAspectRatio as e, getWidthFromAspectRatio as f, getAspectRatio as g, getInitialCropSize as h, isNotNilOrEmpty as i, getPercentage as j, getWrapperRefStyles as k, isItemsCenter as l, getCloudFlareCroppedURL as m, getImageKitCroppedURL as n, getCropValues as o,
|
|
439
|
-
//# sourceMappingURL=utils-
|
|
401
|
+
export { ASSETS_DESTROY_URL as A, DEFAULT_UPLOAD_CONFIG as D, IMAGE_WRAPPER_CLASSNAME as I, OPTION_KEYS as O, TABS as T, UNSPLASH_DEFAULT_NAME as U, ImageDirectUpload as a, isNilOrEmpty as b, DEFAULT_CROP_CONFIG as c, getPixels as d, getHeightFromAspectRatio as e, getWidthFromAspectRatio as f, getAspectRatio as g, getInitialCropSize as h, isNotNilOrEmpty as i, getPercentage as j, getWrapperRefStyles as k, isItemsCenter as l, getCloudFlareCroppedURL as m, getImageKitCroppedURL as n, getCropValues as o, INFINITE_SCROLLER_STYLE as p, INFINITE_SCROLLER_SIZES as q, IMAGES_PER_PAGE as r, ASSETS_FETCH_URL as s, UNSPLASH_DEFAULT_REQUEST_CONFIG as t, UNSPLASH_URL as u };
|
|
402
|
+
//# sourceMappingURL=utils-D5iQ8UME.js.map
|