@bigbinary/neeto-image-uploader-frontend 2.3.9 → 2.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/javascript/src/translations/en.json +1 -1
- package/dist/AssetLibrary.js +9 -8
- package/dist/AssetLibrary.js.map +1 -1
- package/dist/BasicImageUploader.js +4 -4
- package/dist/ImageUploader.js +7 -6
- package/dist/ImageUploader.js.map +1 -1
- package/dist/ImageWithFallback-Csv6Oivd.js +51 -0
- package/dist/ImageWithFallback-Csv6Oivd.js.map +1 -0
- package/dist/ImageWithFallback-DeznMgbx.js +53 -0
- package/dist/ImageWithFallback-DeznMgbx.js.map +1 -0
- package/dist/cjs/AssetLibrary.js +9 -8
- package/dist/cjs/AssetLibrary.js.map +1 -1
- package/dist/cjs/BasicImageUploader.js +10 -18
- package/dist/cjs/BasicImageUploader.js.map +1 -1
- package/dist/cjs/ImageUploader.js +19 -29
- package/dist/cjs/ImageUploader.js.map +1 -1
- package/dist/cjs/hooks.js +4 -6
- package/dist/cjs/hooks.js.map +1 -1
- package/dist/cjs/index.js +8 -9
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils.js +1 -3
- package/dist/cjs/utils.js.map +1 -1
- package/dist/hooks.js +4 -4
- package/dist/{index-9fdcdfac.js → index-BkKE5xo-.js} +179 -213
- package/dist/index-BkKE5xo-.js.map +1 -0
- package/dist/{index-cf7e4b89.js → index-BtHfh_eu.js} +2 -3
- package/dist/{index-cf7e4b89.js.map → index-BtHfh_eu.js.map} +1 -1
- package/dist/{index-8605e11c.js → index-CZjb2iXB.js} +2 -3
- package/dist/{index-8605e11c.js.map → index-CZjb2iXB.js.map} +1 -1
- package/dist/{index-a3668c72.js → index-FbPHXCzL.js} +107 -118
- package/dist/index-FbPHXCzL.js.map +1 -0
- package/dist/index.js +8 -7
- package/dist/index.js.map +1 -1
- package/dist/{query-dcc7b81b.js → query-B0eDmse7.js} +1 -1
- package/dist/{query-dcc7b81b.js.map → query-B0eDmse7.js.map} +1 -1
- package/dist/{query-3c31bf92.js → query-B7ahlELA.js} +1 -1
- package/dist/{query-3c31bf92.js.map → query-B7ahlELA.js.map} +1 -1
- package/dist/{useImageUploader-49fd1436.js → useImageUploader-Bm9TukCy.js} +16 -24
- package/dist/useImageUploader-Bm9TukCy.js.map +1 -0
- package/dist/{useImageUploader-9c1a27d0.js → useImageUploader-RX88_Cp-.js} +4 -4
- package/dist/{useImageUploader-9c1a27d0.js.map → useImageUploader-RX88_Cp-.js.map} +1 -1
- package/dist/{useProfileImageUpload-faa539d7.js → useProfileImageUpload-KpvcwEqx.js} +3 -3
- package/dist/{useProfileImageUpload-faa539d7.js.map → useProfileImageUpload-KpvcwEqx.js.map} +1 -1
- package/dist/{useProfileImageUpload-9c1d2b0f.js → useProfileImageUpload-UUrg2Lkw.js} +19 -26
- package/dist/useProfileImageUpload-UUrg2Lkw.js.map +1 -0
- package/dist/{utils-ede1695e.js → utils-BxC_k1lu.js} +105 -27
- package/dist/utils-BxC_k1lu.js.map +1 -0
- package/dist/{utils-fa0fa918.js → utils-WEbpTEyB.js} +101 -16
- package/dist/utils-WEbpTEyB.js.map +1 -0
- package/dist/utils.js +1 -1
- package/package.json +21 -20
- package/dist/ImageWithFallback-1ddf3f25.js +0 -154
- package/dist/ImageWithFallback-1ddf3f25.js.map +0 -1
- package/dist/ImageWithFallback-933ea4b1.js +0 -141
- package/dist/ImageWithFallback-933ea4b1.js.map +0 -1
- package/dist/index-9fdcdfac.js.map +0 -1
- package/dist/index-a3668c72.js.map +0 -1
- package/dist/useImageUploader-49fd1436.js.map +0 -1
- package/dist/useProfileImageUpload-9c1d2b0f.js.map +0 -1
- package/dist/utils-ede1695e.js.map +0 -1
- package/dist/utils-fa0fa918.js.map +0 -1
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var _objectWithoutProperties$1 = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
4
3
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
5
4
|
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
6
5
|
var require$$0 = require('react');
|
|
7
6
|
var neetoCist = require('@bigbinary/neeto-cist');
|
|
8
7
|
var initializers = require('@bigbinary/neeto-commons-frontend/initializers');
|
|
9
8
|
var NeetoUIModal = require('@bigbinary/neetoui/Modal');
|
|
10
|
-
var Button = require('@bigbinary/neetoui/Button');
|
|
11
9
|
var Tab = require('@bigbinary/neetoui/Tab');
|
|
12
10
|
var Spinner = require('@bigbinary/neetoui/Spinner');
|
|
13
11
|
var Toastr = require('@bigbinary/neetoui/Toastr');
|
|
14
12
|
var Typography = require('@bigbinary/neetoui/Typography');
|
|
15
13
|
var ramda = require('ramda');
|
|
16
14
|
var reactI18next = require('react-i18next');
|
|
17
|
-
var utils = require('./utils-
|
|
18
|
-
var useImageUploader = require('./useImageUploader-
|
|
19
|
-
var index = require('./index-
|
|
15
|
+
var utils$1 = require('./utils-BxC_k1lu.js');
|
|
16
|
+
var useImageUploader = require('./useImageUploader-Bm9TukCy.js');
|
|
17
|
+
var index = require('./index-BtHfh_eu.js');
|
|
20
18
|
var classnames = require('classnames');
|
|
21
19
|
var LeftArrow = require('@bigbinary/neeto-icons/LeftArrow');
|
|
20
|
+
var Button = require('@bigbinary/neetoui/Button');
|
|
22
21
|
var reactQuery = require('@tanstack/react-query');
|
|
23
22
|
var axios = require('axios');
|
|
24
23
|
var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
|
|
25
|
-
var utils
|
|
24
|
+
var utils = require('@bigbinary/neeto-commons-frontend/utils');
|
|
26
25
|
var Input = require('@bigbinary/neetoui/Input');
|
|
27
26
|
var Switch = require('@bigbinary/neetoui/Switch');
|
|
27
|
+
var Label = require('@bigbinary/neetoui/Label');
|
|
28
28
|
var jsxRuntime = require('react/jsx-runtime');
|
|
29
|
-
var query = require('./query-
|
|
29
|
+
var query = require('./query-B7ahlELA.js');
|
|
30
30
|
var MenuHorizontal = require('@bigbinary/neeto-icons/MenuHorizontal');
|
|
31
31
|
var constants = require('@bigbinary/neeto-team-members-frontend/constants');
|
|
32
32
|
var Alert = require('@bigbinary/neetoui/Alert');
|
|
@@ -34,29 +34,6 @@ var Dropdown = require('@bigbinary/neetoui/Dropdown');
|
|
|
34
34
|
var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
|
|
35
35
|
var _regeneratorRuntime = require('@babel/runtime/regenerator');
|
|
36
36
|
|
|
37
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
38
|
-
|
|
39
|
-
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties$1);
|
|
40
|
-
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
41
|
-
var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
|
|
42
|
-
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
|
|
43
|
-
var NeetoUIModal__default = /*#__PURE__*/_interopDefaultLegacy(NeetoUIModal);
|
|
44
|
-
var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);
|
|
45
|
-
var Tab__default = /*#__PURE__*/_interopDefaultLegacy(Tab);
|
|
46
|
-
var Spinner__default = /*#__PURE__*/_interopDefaultLegacy(Spinner);
|
|
47
|
-
var Toastr__default = /*#__PURE__*/_interopDefaultLegacy(Toastr);
|
|
48
|
-
var Typography__default = /*#__PURE__*/_interopDefaultLegacy(Typography);
|
|
49
|
-
var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
|
|
50
|
-
var LeftArrow__default = /*#__PURE__*/_interopDefaultLegacy(LeftArrow);
|
|
51
|
-
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
|
52
|
-
var Input__default = /*#__PURE__*/_interopDefaultLegacy(Input);
|
|
53
|
-
var Switch__default = /*#__PURE__*/_interopDefaultLegacy(Switch);
|
|
54
|
-
var MenuHorizontal__default = /*#__PURE__*/_interopDefaultLegacy(MenuHorizontal);
|
|
55
|
-
var Alert__default = /*#__PURE__*/_interopDefaultLegacy(Alert);
|
|
56
|
-
var Dropdown__default = /*#__PURE__*/_interopDefaultLegacy(Dropdown);
|
|
57
|
-
var _asyncToGenerator__default = /*#__PURE__*/_interopDefaultLegacy(_asyncToGenerator);
|
|
58
|
-
var _regeneratorRuntime__default = /*#__PURE__*/_interopDefaultLegacy(_regeneratorRuntime);
|
|
59
|
-
|
|
60
37
|
var constructCloudflareImageURL = function constructCloudflareImageURL(url) {
|
|
61
38
|
var domain = window.location.host.split(".").slice(-2).join(".");
|
|
62
39
|
return url.replace("https://imagedelivery.net", "https://images.".concat(domain, "/cdn-cgi/imagedelivery"));
|
|
@@ -67,15 +44,6 @@ var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r
|
|
|
67
44
|
var css$2 = ".niu-modal {\n width: 95vw !important;\n height: 75vh !important;\n max-width: 1152px !important;\n max-height: 576px !important;\n position: relative !important;\n}\n/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFwcC9qYXZhc2NyaXB0L3N0eWxlc2hlZXRzL2NvbXBvbmVudHMvX21vZGFsLnNjc3MiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBR0E7RUFDRSxzQkFBQTtFQUNBLHVCQUFBO0VBQ0EsNEJBQUE7RUFDQSw0QkFBQTtFQUNBLDZCQUFBO0FBRkYiLCJzb3VyY2VzQ29udGVudCI6WyIvL0Fic3RyYWN0c1xuQGltcG9ydCBcIi4uL2Fic3RyYWN0cy92YXJpYWJsZXNcIjtcblxuLm5pdS1tb2RhbCB7XG4gIHdpZHRoOiAkbml1LW1vZGFsLXdpZHRoICFpbXBvcnRhbnQ7XG4gIGhlaWdodDogJG5pdS1tb2RhbC1oZWlnaHQgIWltcG9ydGFudDtcbiAgbWF4LXdpZHRoOiAkbml1LW1vZGFsLW1heC13aWR0aCAhaW1wb3J0YW50O1xuICBtYXgtaGVpZ2h0OiAkbml1LW1vZGFsLW1heC1oZWlnaHQgIWltcG9ydGFudDtcbiAgcG9zaXRpb246IHJlbGF0aXZlICFpbXBvcnRhbnQ7XG59XG4iXX0= */";
|
|
68
45
|
n(css$2,{});
|
|
69
46
|
|
|
70
|
-
var createOptions = function createOptions() {
|
|
71
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
72
|
-
return utils.OPTIONS.map(function (option) {
|
|
73
|
-
return ramda.mergeLeft(neetoCist.findBy({
|
|
74
|
-
key: option.key
|
|
75
|
-
}, options), option);
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
|
|
79
47
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
80
48
|
|
|
81
49
|
function getDefaultExportFromCjs (x) {
|
|
@@ -109,24 +77,22 @@ function getAugmentedNamespace(n) {
|
|
|
109
77
|
|
|
110
78
|
var ReactCrop_min = {exports: {}};
|
|
111
79
|
|
|
112
|
-
ReactCrop_min.exports;
|
|
113
|
-
|
|
114
80
|
(function (module, exports) {
|
|
115
|
-
!function(e,t){module.exports=t(require$$0__default["default"]);}(commonjsGlobal,(e=>(()=>{var t={899:t=>{t.exports=e;}},n={};function o(e){var r=n[e];if(void 0!==r)return r.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,o),i.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]});},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0});};var r={};return (()=>{o.r(r),o.d(r,{Component:()=>u,areCropsEqual:()=>h,centerCrop:()=>d,clamp:()=>a,containCrop:()=>p,convertToPercentCrop:()=>c,convertToPixelCrop:()=>l,default:()=>u,defaultCrop:()=>i,makeAspectCrop:()=>s,nudgeCrop:()=>g});var e=o(899),t=o.n(e);function n(e){var t,o,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(o=n(e[t]))&&(r&&(r+=" "),r+=o);else for(t in e)e[t]&&(r&&(r+=" "),r+=t);return r}const i={x:0,y:0,width:0,height:0,unit:"px"};function a(e,t,n){return Math.min(Math.max(e,t),n)}function h(e,t){return e.width===t.width&&e.height===t.height&&e.x===t.x&&e.y===t.y&&e.unit===t.unit}function s(e,t,n,o){const r=l(e,n,o);return e.width&&(r.height=r.width/t),e.height&&(r.width=r.height*t),r.y+r.height>o&&(r.height=o-r.y,r.width=r.height*t),r.x+r.width>n&&(r.width=n-r.x,r.height=r.width/t),"%"===e.unit?c(r,n,o):r}function d(e,t,n){const o=l(e,t,n);return o.x=(t-o.width)/2,o.y=(n-o.height)/2,"%"===e.unit?c(o,t,n):o}function c(e,t,n){return "%"===e.unit?{...i,...e,unit:"%"}:{unit:"%",x:e.x?e.x/t*100:0,y:e.y?e.y/n*100:0,width:e.width?e.width/t*100:0,height:e.height?e.height/n*100:0}}function l(e,t,n){return e.unit?"px"===e.unit?{...i,...e,unit:"px"}:{unit:"px",x:e.x?e.x*t/100:0,y:e.y?e.y*n/100:0,width:e.width?e.width*t/100:0,height:e.height?e.height*n/100:0}:{...i,...e,unit:"px"}}function p(e,t,n,o,r,i=0,a=0,h=o,s=r){const d={...e};let c=Math.min(i,o),l=Math.min(a,r),p=Math.min(h,o),g=Math.min(s,r);t&&(t>1?(c=a?a*t:c,l=c/t,p=h*t):(l=i?i/t:l,c=l*t,g=s/t)),d.y<0&&(d.height=Math.max(d.height+d.y,l),d.y=0),d.x<0&&(d.width=Math.max(d.width+d.x,c),d.x=0);const w=o-(d.x+d.width);w<0&&(d.x=Math.min(d.x,o-c),d.width+=w);const u=r-(d.y+d.height);if(u<0&&(d.y=Math.min(d.y,r-l),d.height+=u),d.width<c&&("sw"!==n&&"nw"!=n||(d.x-=c-d.width),d.width=c),d.height<l&&("nw"!==n&&"ne"!=n||(d.y-=l-d.height),d.height=l),d.width>p&&("sw"!==n&&"nw"!=n||(d.x-=p-d.width),d.width=p),d.height>g&&("nw"!==n&&"ne"!=n||(d.y-=g-d.height),d.height=g),t){const e=d.width/d.height;if(e<t){const e=Math.max(d.width/t,l);"nw"!==n&&"ne"!=n||(d.y-=e-d.height),d.height=e;}else if(e>t){const e=Math.max(d.height*t,c);"sw"!==n&&"nw"!=n||(d.x-=e-d.width),d.width=e;}}return d}function g(e,t,n,o){const r={...e};return "ArrowLeft"===t?"nw"===o?(r.x-=n,r.y-=n,r.width+=n,r.height+=n):"w"===o?(r.x-=n,r.width+=n):"sw"===o?(r.x-=n,r.width+=n,r.height+=n):"ne"===o?(r.y+=n,r.width-=n,r.height-=n):"e"===o?r.width-=n:"se"===o&&(r.width-=n,r.height-=n):"ArrowRight"===t&&("nw"===o?(r.x+=n,r.y+=n,r.width-=n,r.height-=n):"w"===o?(r.x+=n,r.width-=n):"sw"===o?(r.x+=n,r.width-=n,r.height-=n):"ne"===o?(r.y-=n,r.width+=n,r.height+=n):"e"===o?r.width+=n:"se"===o&&(r.width+=n,r.height+=n)),"ArrowUp"===t?"nw"===o?(r.x-=n,r.y-=n,r.width+=n,r.height+=n):"n"===o?(r.y-=n,r.height+=n):"ne"===o?(r.y-=n,r.width+=n,r.height+=n):"sw"===o?(r.x+=n,r.width-=n,r.height-=n):"s"===o?r.height-=n:"se"===o&&(r.width-=n,r.height-=n):"ArrowDown"===t&&("nw"===o?(r.x+=n,r.y+=n,r.width-=n,r.height-=n):"n"===o?(r.y+=n,r.height-=n):"ne"===o?(r.y+=n,r.width-=n,r.height-=n):"sw"===o?(r.x-=n,r.width+=n,r.height+=n):"s"===o?r.height+=n:"se"===o&&(r.width+=n,r.height+=n)),r}const w={capture:!0,passive:!1};class u extends e.PureComponent{constructor(){super(...arguments),this.docMoveBound=!1,this.mouseDownOnCrop=!1,this.dragStarted=!1,this.evData={startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0},this.componentRef=(0, e.createRef)(),this.mediaRef=(0, e.createRef)(),this.initChangeCalled=!1,this.state={cropIsActive:!1,newCropIsBeingDrawn:!1},this.onCropPointerDown=e=>{const{crop:t,disabled:n}=this.props,o=this.getBox();if(!t)return;const r=l(t,o.width,o.height);if(n)return;e.cancelable&&e.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const i=e.target.dataset.ord,a=Boolean(i);let h=e.clientX,s=e.clientY,d=r.x,c=r.y;if(i){const t=e.clientX-o.x,n=e.clientY-o.y;let a=0,l=0;"ne"===i||"e"==i?(a=t-(r.x+r.width),l=n-r.y,d=r.x,c=r.y+r.height):"se"===i||"s"===i?(a=t-(r.x+r.width),l=n-(r.y+r.height),d=r.x,c=r.y):"sw"===i||"w"==i?(a=t-r.x,l=n-(r.y+r.height),d=r.x+r.width,c=r.y):"nw"!==i&&"n"!=i||(a=t-r.x,l=n-r.y,d=r.x+r.width,c=r.y+r.height),h=d+o.x+a,s=c+o.y+l;}this.evData={startClientX:h,startClientY:s,startCropX:d,startCropY:c,clientX:e.clientX,clientY:e.clientY,isResize:a,ord:i},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0});},this.onComponentPointerDown=e=>{const{crop:t,disabled:n,locked:o,keepSelection:r,onChange:i}=this.props,a=this.getBox();if(n||o||r&&t)return;e.cancelable&&e.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const h=e.clientX-a.x,s=e.clientY-a.y,d={unit:"px",x:h,y:s,width:0,height:0};this.evData={startClientX:e.clientX,startClientY:e.clientY,startCropX:h,startCropY:s,clientX:e.clientX,clientY:e.clientY,isResize:!0},this.mouseDownOnCrop=!0,i(l(d,a.width,a.height),c(d,a.width,a.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0});},this.onDocPointerMove=e=>{const{crop:t,disabled:n,onChange:o,onDragStart:r}=this.props,i=this.getBox();if(n||!t||!this.mouseDownOnCrop)return;e.cancelable&&e.preventDefault(),this.dragStarted||(this.dragStarted=!0,r&&r(e));const{evData:a}=this;let s;a.clientX=e.clientX,a.clientY=e.clientY,s=a.isResize?this.resizeCrop():this.dragCrop(),h(t,s)||o(l(s,i.width,i.height),c(s,i.width,i.height));},this.onComponentKeyDown=e=>{const{crop:t,disabled:n,onChange:o,onComplete:r}=this.props,i=this.getBox();if(n)return;const h=e.key;let s=!1;if(!t)return;const d=this.makePixelCrop(),p=(navigator.platform.match("Mac")?e.metaKey:e.ctrlKey)?u.nudgeStepLarge:e.shiftKey?u.nudgeStepMedium:u.nudgeStep;if("ArrowLeft"===h?(d.x-=p,s=!0):"ArrowRight"===h?(d.x+=p,s=!0):"ArrowUp"===h?(d.y-=p,s=!0):"ArrowDown"===h&&(d.y+=p,s=!0),s){e.cancelable&&e.preventDefault(),d.x=a(d.x,0,i.width-d.width),d.y=a(d.y,0,i.height-d.height);const t=l(d,i.width,i.height),n=c(d,i.width,i.height);o(t,n),r&&r(t,n);}},this.onHandlerKeyDown=(e,t)=>{const{aspect:n=0,crop:o,disabled:r,minWidth:i=0,minHeight:a=0,maxWidth:s,maxHeight:d,onChange:w,onComplete:m}=this.props,y=this.getBox();if(r||!o)return;if("ArrowUp"!==e.key&&"ArrowDown"!==e.key&&"ArrowLeft"!==e.key&&"ArrowRight"!==e.key)return;e.stopPropagation(),e.preventDefault();const x=(navigator.platform.match("Mac")?e.metaKey:e.ctrlKey)?u.nudgeStepLarge:e.shiftKey?u.nudgeStepMedium:u.nudgeStep,C=p(g(l(o,y.width,y.height),e.key,x,t),n,t,y.width,y.height,i,a,s,d);if(!h(o,C)){const e=c(C,y.width,y.height);w(C,e),m&&m(C,e);}},this.onDocPointerDone=e=>{const{crop:t,disabled:n,onComplete:o,onDragEnd:r}=this.props,i=this.getBox();this.unbindDocMove(),!n&&t&&this.mouseDownOnCrop&&(this.mouseDownOnCrop=!1,this.dragStarted=!1,r&&r(e),o&&o(l(t,i.width,i.height),c(t,i.width,i.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}));},this.onDragFocus=e=>{var t;null===(t=this.componentRef.current)||void 0===t||t.scrollTo(0,0);};}get document(){return document}getBox(){const e=this.mediaRef.current;if(!e)return {x:0,y:0,width:0,height:0};const{x:t,y:n,width:o,height:r}=e.getBoundingClientRect();return {x:t,y:n,width:o,height:r}}componentDidUpdate(e){const{crop:t,onComplete:n}=this.props;if(n&&!e.crop&&t){const{width:e,height:o}=this.getBox();e&&o&&n(l(t,e,o),c(t,e,o));}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect();}bindDocMove(){this.docMoveBound||(this.document.addEventListener("pointermove",this.onDocPointerMove,w),this.document.addEventListener("pointerup",this.onDocPointerDone,w),this.document.addEventListener("pointercancel",this.onDocPointerDone,w),this.docMoveBound=!0);}unbindDocMove(){this.docMoveBound&&(this.document.removeEventListener("pointermove",this.onDocPointerMove,w),this.document.removeEventListener("pointerup",this.onDocPointerDone,w),this.document.removeEventListener("pointercancel",this.onDocPointerDone,w),this.docMoveBound=!1);}getCropStyle(){const{crop:e}=this.props;if(e)return {top:`${e.y}${e.unit}`,left:`${e.x}${e.unit}`,width:`${e.width}${e.unit}`,height:`${e.height}${e.unit}`}}dragCrop(){const{evData:e}=this,t=this.getBox(),n=this.makePixelCrop(),o=e.clientX-e.startClientX,r=e.clientY-e.startClientY;return n.x=a(e.startCropX+o,0,t.width-n.width),n.y=a(e.startCropY+r,0,t.height-n.height),n}getPointRegion(e){const{evData:t}=this,n=t.clientX-e.x,o=t.clientY-e.y<t.startCropY;return n<t.startCropX?o?"nw":"sw":o?"ne":"se"}resizeCrop(){const{evData:e}=this,t=this.getBox(),{aspect:n=0,minWidth:o=0,minHeight:r=0,maxWidth:i,maxHeight:a}=this.props,h=this.getPointRegion(t),s=this.makePixelCrop(),d=e.ord?e.ord:h,c=e.clientX-e.startClientX,l=e.clientY-e.startClientY,g={unit:"px",x:0,y:0,width:0,height:0};"ne"===h?(g.x=e.startCropX,g.width=c,n?(g.height=g.width/n,g.y=e.startCropY-g.height):(g.height=Math.abs(l),g.y=e.startCropY-g.height)):"se"===h?(g.x=e.startCropX,g.y=e.startCropY,g.width=c,g.height=n?g.width/n:l):"sw"===h?(g.x=e.startCropX+c,g.y=e.startCropY,g.width=Math.abs(c),g.height=n?g.width/n:l):"nw"===h&&(g.x=e.startCropX+c,g.width=Math.abs(c),n?(g.height=g.width/n,g.y=e.startCropY-g.height):(g.height=Math.abs(l),g.y=e.startCropY+l));const w=p(g,n,h,t.width,t.height,o,r,i,a);return n||u.xyOrds.indexOf(d)>-1?(s.x=w.x,s.y=w.y,s.width=w.width,s.height=w.height):u.xOrds.indexOf(d)>-1?(s.x=w.x,s.width=w.width):u.yOrds.indexOf(d)>-1&&(s.y=w.y,s.height=w.height),s}createCropSelection(){const{ariaLabels:e=u.defaultProps.ariaLabels,disabled:n,locked:o,renderSelectionAddon:r,ruleOfThirds:i,crop:a}=this.props,h=this.getCropStyle();if(a)return t().createElement("div",{style:h,className:"ReactCrop__crop-selection",onPointerDown:this.onCropPointerDown,"aria-label":e.cropArea,tabIndex:0,onKeyDown:this.onComponentKeyDown,role:"group"},!n&&!o&&t().createElement("div",{className:"ReactCrop__drag-elements",onFocus:this.onDragFocus},t().createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),t().createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),t().createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),t().createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),t().createElement("div",{className:"ReactCrop__drag-handle ord-nw","data-ord":"nw",tabIndex:0,"aria-label":e.nwDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"nw"),role:"button"}),t().createElement("div",{className:"ReactCrop__drag-handle ord-n","data-ord":"n",tabIndex:0,"aria-label":e.nDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"n"),role:"button"}),t().createElement("div",{className:"ReactCrop__drag-handle ord-ne","data-ord":"ne",tabIndex:0,"aria-label":e.neDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"ne"),role:"button"}),t().createElement("div",{className:"ReactCrop__drag-handle ord-e","data-ord":"e",tabIndex:0,"aria-label":e.eDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"e"),role:"button"}),t().createElement("div",{className:"ReactCrop__drag-handle ord-se","data-ord":"se",tabIndex:0,"aria-label":e.seDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"se"),role:"button"}),t().createElement("div",{className:"ReactCrop__drag-handle ord-s","data-ord":"s",tabIndex:0,"aria-label":e.sDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"s"),role:"button"}),t().createElement("div",{className:"ReactCrop__drag-handle ord-sw","data-ord":"sw",tabIndex:0,"aria-label":e.swDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"sw"),role:"button"}),t().createElement("div",{className:"ReactCrop__drag-handle ord-w","data-ord":"w",tabIndex:0,"aria-label":e.wDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"w"),role:"button"})),r&&t().createElement("div",{className:"ReactCrop__selection-addon",onMouseDown:e=>e.stopPropagation()},r(this.state)),i&&t().createElement(t().Fragment,null,t().createElement("div",{className:"ReactCrop__rule-of-thirds-hz"}),t().createElement("div",{className:"ReactCrop__rule-of-thirds-vt"})))}makePixelCrop(){const e={...i,...this.props.crop||{}},t=this.getBox();return l(e,t.width,t.height)}render(){const{aspect:e,children:o,circularCrop:r,className:i,crop:a,disabled:h,locked:s,style:d,ruleOfThirds:c}=this.props,{cropIsActive:l,newCropIsBeingDrawn:p}=this.state,g=a?this.createCropSelection():null,w=function(){for(var e,t,o=0,r="";o<arguments.length;)(e=arguments[o++])&&(t=n(e))&&(r&&(r+=" "),r+=t);return r}("ReactCrop",i,{"ReactCrop--active":l,"ReactCrop--disabled":h,"ReactCrop--locked":s,"ReactCrop--new-crop":p,"ReactCrop--fixed-aspect":a&&e,"ReactCrop--circular-crop":a&&r,"ReactCrop--rule-of-thirds":a&&c,"ReactCrop--invisible-crop":!this.dragStarted&&a&&!a.width&&!a.height});return t().createElement("div",{ref:this.componentRef,className:w,style:d},t().createElement("div",{ref:this.mediaRef,className:"ReactCrop__child-wrapper",onPointerDown:this.onComponentPointerDown},o),g)}}u.xOrds=["e","w"],u.yOrds=["n","s"],u.xyOrds=["nw","ne","se","sw"],u.nudgeStep=1,u.nudgeStepMedium=10,u.nudgeStepLarge=100,u.defaultProps={ariaLabels:{cropArea:"Use the arrow keys to move the crop selection area",nwDragHandle:"Use the arrow keys to move the north west drag handle to change the crop selection area",nDragHandle:"Use the up and down arrow keys to move the north drag handle to change the crop selection area",neDragHandle:"Use the arrow keys to move the north east drag handle to change the crop selection area",eDragHandle:"Use the up and down arrow keys to move the east drag handle to change the crop selection area",seDragHandle:"Use the arrow keys to move the south east drag handle to change the crop selection area",sDragHandle:"Use the up and down arrow keys to move the south drag handle to change the crop selection area",swDragHandle:"Use the arrow keys to move the south west drag handle to change the crop selection area",wDragHandle:"Use the up and down arrow keys to move the west drag handle to change the crop selection area"}};})(),r})()));
|
|
116
|
-
} (ReactCrop_min
|
|
81
|
+
!function(e,t){module.exports=t(require$$0);}(commonjsGlobal,(e=>(()=>{var t={899:t=>{t.exports=e;}},n={};function o(e){var r=n[e];if(void 0!==r)return r.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,o),i.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]});},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0});};var r={};return (()=>{o.r(r),o.d(r,{Component:()=>u,areCropsEqual:()=>h,centerCrop:()=>d,clamp:()=>a,containCrop:()=>p,convertToPercentCrop:()=>c,convertToPixelCrop:()=>l,default:()=>u,defaultCrop:()=>i,makeAspectCrop:()=>s,nudgeCrop:()=>g});var e=o(899),t=o.n(e);function n(e){var t,o,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(o=n(e[t]))&&(r&&(r+=" "),r+=o);else for(t in e)e[t]&&(r&&(r+=" "),r+=t);return r}const i={x:0,y:0,width:0,height:0,unit:"px"};function a(e,t,n){return Math.min(Math.max(e,t),n)}function h(e,t){return e.width===t.width&&e.height===t.height&&e.x===t.x&&e.y===t.y&&e.unit===t.unit}function s(e,t,n,o){const r=l(e,n,o);return e.width&&(r.height=r.width/t),e.height&&(r.width=r.height*t),r.y+r.height>o&&(r.height=o-r.y,r.width=r.height*t),r.x+r.width>n&&(r.width=n-r.x,r.height=r.width/t),"%"===e.unit?c(r,n,o):r}function d(e,t,n){const o=l(e,t,n);return o.x=(t-o.width)/2,o.y=(n-o.height)/2,"%"===e.unit?c(o,t,n):o}function c(e,t,n){return "%"===e.unit?{...i,...e,unit:"%"}:{unit:"%",x:e.x?e.x/t*100:0,y:e.y?e.y/n*100:0,width:e.width?e.width/t*100:0,height:e.height?e.height/n*100:0}}function l(e,t,n){return e.unit?"px"===e.unit?{...i,...e,unit:"px"}:{unit:"px",x:e.x?e.x*t/100:0,y:e.y?e.y*n/100:0,width:e.width?e.width*t/100:0,height:e.height?e.height*n/100:0}:{...i,...e,unit:"px"}}function p(e,t,n,o,r,i=0,a=0,h=o,s=r){const d={...e};let c=Math.min(i,o),l=Math.min(a,r),p=Math.min(h,o),g=Math.min(s,r);t&&(t>1?(c=a?a*t:c,l=c/t,p=h*t):(l=i?i/t:l,c=l*t,g=s/t)),d.y<0&&(d.height=Math.max(d.height+d.y,l),d.y=0),d.x<0&&(d.width=Math.max(d.width+d.x,c),d.x=0);const w=o-(d.x+d.width);w<0&&(d.x=Math.min(d.x,o-c),d.width+=w);const u=r-(d.y+d.height);if(u<0&&(d.y=Math.min(d.y,r-l),d.height+=u),d.width<c&&("sw"!==n&&"nw"!=n||(d.x-=c-d.width),d.width=c),d.height<l&&("nw"!==n&&"ne"!=n||(d.y-=l-d.height),d.height=l),d.width>p&&("sw"!==n&&"nw"!=n||(d.x-=p-d.width),d.width=p),d.height>g&&("nw"!==n&&"ne"!=n||(d.y-=g-d.height),d.height=g),t){const e=d.width/d.height;if(e<t){const e=Math.max(d.width/t,l);"nw"!==n&&"ne"!=n||(d.y-=e-d.height),d.height=e;}else if(e>t){const e=Math.max(d.height*t,c);"sw"!==n&&"nw"!=n||(d.x-=e-d.width),d.width=e;}}return d}function g(e,t,n,o){const r={...e};return "ArrowLeft"===t?"nw"===o?(r.x-=n,r.y-=n,r.width+=n,r.height+=n):"w"===o?(r.x-=n,r.width+=n):"sw"===o?(r.x-=n,r.width+=n,r.height+=n):"ne"===o?(r.y+=n,r.width-=n,r.height-=n):"e"===o?r.width-=n:"se"===o&&(r.width-=n,r.height-=n):"ArrowRight"===t&&("nw"===o?(r.x+=n,r.y+=n,r.width-=n,r.height-=n):"w"===o?(r.x+=n,r.width-=n):"sw"===o?(r.x+=n,r.width-=n,r.height-=n):"ne"===o?(r.y-=n,r.width+=n,r.height+=n):"e"===o?r.width+=n:"se"===o&&(r.width+=n,r.height+=n)),"ArrowUp"===t?"nw"===o?(r.x-=n,r.y-=n,r.width+=n,r.height+=n):"n"===o?(r.y-=n,r.height+=n):"ne"===o?(r.y-=n,r.width+=n,r.height+=n):"sw"===o?(r.x+=n,r.width-=n,r.height-=n):"s"===o?r.height-=n:"se"===o&&(r.width-=n,r.height-=n):"ArrowDown"===t&&("nw"===o?(r.x+=n,r.y+=n,r.width-=n,r.height-=n):"n"===o?(r.y+=n,r.height-=n):"ne"===o?(r.y+=n,r.width-=n,r.height-=n):"sw"===o?(r.x-=n,r.width+=n,r.height+=n):"s"===o?r.height+=n:"se"===o&&(r.width+=n,r.height+=n)),r}const w={capture:!0,passive:!1};class u extends e.PureComponent{constructor(){super(...arguments),this.docMoveBound=!1,this.mouseDownOnCrop=!1,this.dragStarted=!1,this.evData={startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0},this.componentRef=(0, e.createRef)(),this.mediaRef=(0, e.createRef)(),this.initChangeCalled=!1,this.state={cropIsActive:!1,newCropIsBeingDrawn:!1},this.onCropPointerDown=e=>{const{crop:t,disabled:n}=this.props,o=this.getBox();if(!t)return;const r=l(t,o.width,o.height);if(n)return;e.cancelable&&e.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const i=e.target.dataset.ord,a=Boolean(i);let h=e.clientX,s=e.clientY,d=r.x,c=r.y;if(i){const t=e.clientX-o.x,n=e.clientY-o.y;let a=0,l=0;"ne"===i||"e"==i?(a=t-(r.x+r.width),l=n-r.y,d=r.x,c=r.y+r.height):"se"===i||"s"===i?(a=t-(r.x+r.width),l=n-(r.y+r.height),d=r.x,c=r.y):"sw"===i||"w"==i?(a=t-r.x,l=n-(r.y+r.height),d=r.x+r.width,c=r.y):"nw"!==i&&"n"!=i||(a=t-r.x,l=n-r.y,d=r.x+r.width,c=r.y+r.height),h=d+o.x+a,s=c+o.y+l;}this.evData={startClientX:h,startClientY:s,startCropX:d,startCropY:c,clientX:e.clientX,clientY:e.clientY,isResize:a,ord:i},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0});},this.onComponentPointerDown=e=>{const{crop:t,disabled:n,locked:o,keepSelection:r,onChange:i}=this.props,a=this.getBox();if(n||o||r&&t)return;e.cancelable&&e.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const h=e.clientX-a.x,s=e.clientY-a.y,d={unit:"px",x:h,y:s,width:0,height:0};this.evData={startClientX:e.clientX,startClientY:e.clientY,startCropX:h,startCropY:s,clientX:e.clientX,clientY:e.clientY,isResize:!0},this.mouseDownOnCrop=!0,i(l(d,a.width,a.height),c(d,a.width,a.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0});},this.onDocPointerMove=e=>{const{crop:t,disabled:n,onChange:o,onDragStart:r}=this.props,i=this.getBox();if(n||!t||!this.mouseDownOnCrop)return;e.cancelable&&e.preventDefault(),this.dragStarted||(this.dragStarted=!0,r&&r(e));const{evData:a}=this;let s;a.clientX=e.clientX,a.clientY=e.clientY,s=a.isResize?this.resizeCrop():this.dragCrop(),h(t,s)||o(l(s,i.width,i.height),c(s,i.width,i.height));},this.onComponentKeyDown=e=>{const{crop:t,disabled:n,onChange:o,onComplete:r}=this.props,i=this.getBox();if(n)return;const h=e.key;let s=!1;if(!t)return;const d=this.makePixelCrop(),p=(navigator.platform.match("Mac")?e.metaKey:e.ctrlKey)?u.nudgeStepLarge:e.shiftKey?u.nudgeStepMedium:u.nudgeStep;if("ArrowLeft"===h?(d.x-=p,s=!0):"ArrowRight"===h?(d.x+=p,s=!0):"ArrowUp"===h?(d.y-=p,s=!0):"ArrowDown"===h&&(d.y+=p,s=!0),s){e.cancelable&&e.preventDefault(),d.x=a(d.x,0,i.width-d.width),d.y=a(d.y,0,i.height-d.height);const t=l(d,i.width,i.height),n=c(d,i.width,i.height);o(t,n),r&&r(t,n);}},this.onHandlerKeyDown=(e,t)=>{const{aspect:n=0,crop:o,disabled:r,minWidth:i=0,minHeight:a=0,maxWidth:s,maxHeight:d,onChange:w,onComplete:m}=this.props,y=this.getBox();if(r||!o)return;if("ArrowUp"!==e.key&&"ArrowDown"!==e.key&&"ArrowLeft"!==e.key&&"ArrowRight"!==e.key)return;e.stopPropagation(),e.preventDefault();const x=(navigator.platform.match("Mac")?e.metaKey:e.ctrlKey)?u.nudgeStepLarge:e.shiftKey?u.nudgeStepMedium:u.nudgeStep,C=p(g(l(o,y.width,y.height),e.key,x,t),n,t,y.width,y.height,i,a,s,d);if(!h(o,C)){const e=c(C,y.width,y.height);w(C,e),m&&m(C,e);}},this.onDocPointerDone=e=>{const{crop:t,disabled:n,onComplete:o,onDragEnd:r}=this.props,i=this.getBox();this.unbindDocMove(),!n&&t&&this.mouseDownOnCrop&&(this.mouseDownOnCrop=!1,this.dragStarted=!1,r&&r(e),o&&o(l(t,i.width,i.height),c(t,i.width,i.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}));},this.onDragFocus=e=>{var t;null===(t=this.componentRef.current)||void 0===t||t.scrollTo(0,0);};}get document(){return document}getBox(){const e=this.mediaRef.current;if(!e)return {x:0,y:0,width:0,height:0};const{x:t,y:n,width:o,height:r}=e.getBoundingClientRect();return {x:t,y:n,width:o,height:r}}componentDidUpdate(e){const{crop:t,onComplete:n}=this.props;if(n&&!e.crop&&t){const{width:e,height:o}=this.getBox();e&&o&&n(l(t,e,o),c(t,e,o));}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect();}bindDocMove(){this.docMoveBound||(this.document.addEventListener("pointermove",this.onDocPointerMove,w),this.document.addEventListener("pointerup",this.onDocPointerDone,w),this.document.addEventListener("pointercancel",this.onDocPointerDone,w),this.docMoveBound=!0);}unbindDocMove(){this.docMoveBound&&(this.document.removeEventListener("pointermove",this.onDocPointerMove,w),this.document.removeEventListener("pointerup",this.onDocPointerDone,w),this.document.removeEventListener("pointercancel",this.onDocPointerDone,w),this.docMoveBound=!1);}getCropStyle(){const{crop:e}=this.props;if(e)return {top:`${e.y}${e.unit}`,left:`${e.x}${e.unit}`,width:`${e.width}${e.unit}`,height:`${e.height}${e.unit}`}}dragCrop(){const{evData:e}=this,t=this.getBox(),n=this.makePixelCrop(),o=e.clientX-e.startClientX,r=e.clientY-e.startClientY;return n.x=a(e.startCropX+o,0,t.width-n.width),n.y=a(e.startCropY+r,0,t.height-n.height),n}getPointRegion(e){const{evData:t}=this,n=t.clientX-e.x,o=t.clientY-e.y<t.startCropY;return n<t.startCropX?o?"nw":"sw":o?"ne":"se"}resizeCrop(){const{evData:e}=this,t=this.getBox(),{aspect:n=0,minWidth:o=0,minHeight:r=0,maxWidth:i,maxHeight:a}=this.props,h=this.getPointRegion(t),s=this.makePixelCrop(),d=e.ord?e.ord:h,c=e.clientX-e.startClientX,l=e.clientY-e.startClientY,g={unit:"px",x:0,y:0,width:0,height:0};"ne"===h?(g.x=e.startCropX,g.width=c,n?(g.height=g.width/n,g.y=e.startCropY-g.height):(g.height=Math.abs(l),g.y=e.startCropY-g.height)):"se"===h?(g.x=e.startCropX,g.y=e.startCropY,g.width=c,g.height=n?g.width/n:l):"sw"===h?(g.x=e.startCropX+c,g.y=e.startCropY,g.width=Math.abs(c),g.height=n?g.width/n:l):"nw"===h&&(g.x=e.startCropX+c,g.width=Math.abs(c),n?(g.height=g.width/n,g.y=e.startCropY-g.height):(g.height=Math.abs(l),g.y=e.startCropY+l));const w=p(g,n,h,t.width,t.height,o,r,i,a);return n||u.xyOrds.indexOf(d)>-1?(s.x=w.x,s.y=w.y,s.width=w.width,s.height=w.height):u.xOrds.indexOf(d)>-1?(s.x=w.x,s.width=w.width):u.yOrds.indexOf(d)>-1&&(s.y=w.y,s.height=w.height),s}createCropSelection(){const{ariaLabels:e=u.defaultProps.ariaLabels,disabled:n,locked:o,renderSelectionAddon:r,ruleOfThirds:i,crop:a}=this.props,h=this.getCropStyle();if(a)return t().createElement("div",{style:h,className:"ReactCrop__crop-selection",onPointerDown:this.onCropPointerDown,"aria-label":e.cropArea,tabIndex:0,onKeyDown:this.onComponentKeyDown,role:"group"},!n&&!o&&t().createElement("div",{className:"ReactCrop__drag-elements",onFocus:this.onDragFocus},t().createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),t().createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),t().createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),t().createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),t().createElement("div",{className:"ReactCrop__drag-handle ord-nw","data-ord":"nw",tabIndex:0,"aria-label":e.nwDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"nw"),role:"button"}),t().createElement("div",{className:"ReactCrop__drag-handle ord-n","data-ord":"n",tabIndex:0,"aria-label":e.nDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"n"),role:"button"}),t().createElement("div",{className:"ReactCrop__drag-handle ord-ne","data-ord":"ne",tabIndex:0,"aria-label":e.neDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"ne"),role:"button"}),t().createElement("div",{className:"ReactCrop__drag-handle ord-e","data-ord":"e",tabIndex:0,"aria-label":e.eDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"e"),role:"button"}),t().createElement("div",{className:"ReactCrop__drag-handle ord-se","data-ord":"se",tabIndex:0,"aria-label":e.seDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"se"),role:"button"}),t().createElement("div",{className:"ReactCrop__drag-handle ord-s","data-ord":"s",tabIndex:0,"aria-label":e.sDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"s"),role:"button"}),t().createElement("div",{className:"ReactCrop__drag-handle ord-sw","data-ord":"sw",tabIndex:0,"aria-label":e.swDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"sw"),role:"button"}),t().createElement("div",{className:"ReactCrop__drag-handle ord-w","data-ord":"w",tabIndex:0,"aria-label":e.wDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"w"),role:"button"})),r&&t().createElement("div",{className:"ReactCrop__selection-addon",onMouseDown:e=>e.stopPropagation()},r(this.state)),i&&t().createElement(t().Fragment,null,t().createElement("div",{className:"ReactCrop__rule-of-thirds-hz"}),t().createElement("div",{className:"ReactCrop__rule-of-thirds-vt"})))}makePixelCrop(){const e={...i,...this.props.crop||{}},t=this.getBox();return l(e,t.width,t.height)}render(){const{aspect:e,children:o,circularCrop:r,className:i,crop:a,disabled:h,locked:s,style:d,ruleOfThirds:c}=this.props,{cropIsActive:l,newCropIsBeingDrawn:p}=this.state,g=a?this.createCropSelection():null,w=function(){for(var e,t,o=0,r="";o<arguments.length;)(e=arguments[o++])&&(t=n(e))&&(r&&(r+=" "),r+=t);return r}("ReactCrop",i,{"ReactCrop--active":l,"ReactCrop--disabled":h,"ReactCrop--locked":s,"ReactCrop--new-crop":p,"ReactCrop--fixed-aspect":a&&e,"ReactCrop--circular-crop":a&&r,"ReactCrop--rule-of-thirds":a&&c,"ReactCrop--invisible-crop":!this.dragStarted&&a&&!a.width&&!a.height});return t().createElement("div",{ref:this.componentRef,className:w,style:d},t().createElement("div",{ref:this.mediaRef,className:"ReactCrop__child-wrapper",onPointerDown:this.onComponentPointerDown},o),g)}}u.xOrds=["e","w"],u.yOrds=["n","s"],u.xyOrds=["nw","ne","se","sw"],u.nudgeStep=1,u.nudgeStepMedium=10,u.nudgeStepLarge=100,u.defaultProps={ariaLabels:{cropArea:"Use the arrow keys to move the crop selection area",nwDragHandle:"Use the arrow keys to move the north west drag handle to change the crop selection area",nDragHandle:"Use the up and down arrow keys to move the north drag handle to change the crop selection area",neDragHandle:"Use the arrow keys to move the north east drag handle to change the crop selection area",eDragHandle:"Use the up and down arrow keys to move the east drag handle to change the crop selection area",seDragHandle:"Use the arrow keys to move the south east drag handle to change the crop selection area",sDragHandle:"Use the up and down arrow keys to move the south drag handle to change the crop selection area",swDragHandle:"Use the arrow keys to move the south west drag handle to change the crop selection area",wDragHandle:"Use the up and down arrow keys to move the west drag handle to change the crop selection area"}};})(),r})()));
|
|
82
|
+
} (ReactCrop_min));
|
|
117
83
|
|
|
118
84
|
var ReactCrop_minExports = ReactCrop_min.exports;
|
|
119
85
|
var ReactCrop = /*@__PURE__*/getDefaultExportFromCjs(ReactCrop_minExports);
|
|
120
86
|
|
|
121
87
|
var cropImage = function cropImage(payload) {
|
|
122
|
-
return
|
|
88
|
+
return axios.post("neeto_image_uploader_engine/development/crop_image", payload);
|
|
123
89
|
};
|
|
124
90
|
var developmentApi = {
|
|
125
91
|
cropImage: cropImage
|
|
126
92
|
};
|
|
127
93
|
|
|
128
94
|
function ownKeys$4(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; }
|
|
129
|
-
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), !0).forEach(function (r) {
|
|
95
|
+
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
130
96
|
var useCropImage = function useCropImage(options) {
|
|
131
97
|
return reactQuery.useMutation(_objectSpread$4({
|
|
132
98
|
mutationFn: developmentApi.cropImage
|
|
@@ -272,11 +238,11 @@ var Controls = function Controls(_ref) {
|
|
|
272
238
|
return cropHeight * (((_imageRef$current3 = imageRef.current) === null || _imageRef$current3 === void 0 ? void 0 : _imageRef$current3.naturalWidth) / ((_imageRef$current4 = imageRef.current) === null || _imageRef$current4 === void 0 ? void 0 : _imageRef$current4.width));
|
|
273
239
|
};
|
|
274
240
|
var _useState = require$$0.useState(getActualCropHeight(crop.height)),
|
|
275
|
-
_useState2 =
|
|
241
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
276
242
|
height = _useState2[0],
|
|
277
243
|
setHeight = _useState2[1];
|
|
278
244
|
var _useState3 = require$$0.useState(getActualCropWidth(crop.width)),
|
|
279
|
-
_useState4 =
|
|
245
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
280
246
|
width = _useState4[0],
|
|
281
247
|
setWidth = _useState4[1];
|
|
282
248
|
var _useImageControls = useImageControls({
|
|
@@ -308,66 +274,78 @@ var Controls = function Controls(_ref) {
|
|
|
308
274
|
setWidth(getActualCropWidth(crop.width));
|
|
309
275
|
}, [crop]);
|
|
310
276
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
311
|
-
className: "flex flex-col p-4 md:w-2/6
|
|
277
|
+
className: "flex flex-col space-y-6 p-4 md:w-2/6",
|
|
312
278
|
children: [!hideControls && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
313
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(
|
|
279
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Switch, {
|
|
314
280
|
checked: isFullImage,
|
|
315
|
-
className: "
|
|
281
|
+
className: "w-full",
|
|
316
282
|
label: t("neetoImageUploader.labels.selectOriginalImage"),
|
|
317
283
|
onChange: function onChange() {
|
|
318
284
|
return setIsFullImage(function (isFullImage) {
|
|
319
285
|
return !isFullImage;
|
|
320
286
|
});
|
|
321
287
|
}
|
|
322
|
-
}), /*#__PURE__*/jsxRuntime.jsx(
|
|
288
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Switch, {
|
|
323
289
|
checked: isAspectRatioLocked,
|
|
324
|
-
className: "
|
|
290
|
+
className: "w-full",
|
|
325
291
|
disabled: isFullImage,
|
|
326
292
|
label: t("neetoImageUploader.labels.lockAspectRatio"),
|
|
327
293
|
onChange: onToggleAspectRatioLock
|
|
328
|
-
}), /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
|
|
329
|
-
className: "mb-2 mt-6",
|
|
330
|
-
style: "body2",
|
|
331
|
-
children: t("neetoImageUploader.imageEditor.aspectRatio")
|
|
332
294
|
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
333
|
-
className: "flex
|
|
334
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
295
|
+
className: "flex w-full items-start gap-2",
|
|
296
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Label, {
|
|
297
|
+
className: "w-24 pt-2",
|
|
298
|
+
children: t("neetoImageUploader.imageEditor.aspectRatio")
|
|
299
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
300
|
+
className: "flex w-32 justify-between gap-1 self-start",
|
|
301
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Input, {
|
|
302
|
+
className: "w-12",
|
|
303
|
+
"data-cy": "aspect-ratio-width-input",
|
|
304
|
+
disabled: isFullImage,
|
|
305
|
+
type: "number",
|
|
306
|
+
value: aspectRatio.width,
|
|
307
|
+
onChange: utils.withEventTargetValue(handleAspectWidthChange)
|
|
308
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
309
|
+
children: ":"
|
|
310
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Input, {
|
|
311
|
+
className: "w-12",
|
|
312
|
+
"data-cy": "aspect-ratio-height-input",
|
|
313
|
+
disabled: isFullImage,
|
|
314
|
+
type: "number",
|
|
315
|
+
value: aspectRatio.height,
|
|
316
|
+
onChange: utils.withEventTargetValue(handleAspectHeightChange)
|
|
317
|
+
})]
|
|
350
318
|
})]
|
|
351
319
|
})]
|
|
352
|
-
}), /*#__PURE__*/jsxRuntime.
|
|
353
|
-
className: "
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
320
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
321
|
+
className: "flex w-full items-start gap-2",
|
|
322
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Label, {
|
|
323
|
+
className: "w-24 pt-2",
|
|
324
|
+
children: t("neetoImageUploader.labels.width")
|
|
325
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Input, {
|
|
326
|
+
className: "w-32 flex-grow-0",
|
|
327
|
+
disabled: isFullImage,
|
|
328
|
+
type: "number",
|
|
329
|
+
value: Math.round(width),
|
|
330
|
+
onChange: utils.withEventTargetValue(setWidth)
|
|
331
|
+
})]
|
|
332
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
333
|
+
className: "flex w-full items-start gap-2",
|
|
334
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Label, {
|
|
335
|
+
className: "w-24 pt-2",
|
|
336
|
+
children: t("neetoImageUploader.labels.height")
|
|
337
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Input, {
|
|
338
|
+
className: "w-32 flex-grow-0",
|
|
339
|
+
disabled: isFullImage,
|
|
340
|
+
type: "number",
|
|
341
|
+
value: Math.round(height),
|
|
342
|
+
onChange: utils.withEventTargetValue(setHeight)
|
|
343
|
+
})]
|
|
344
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
367
345
|
className: "mt-6 self-start",
|
|
368
346
|
"data-cy": "neeto-image-uploader-crop-submit-button",
|
|
369
347
|
label: t("neetoImageUploader.labels.done"),
|
|
370
|
-
disabled: utils.isNilOrEmpty(imageRef.current) && (crop.width <= 0 || crop.height <= 0),
|
|
348
|
+
disabled: utils$1.isNilOrEmpty(imageRef.current) && (crop.width <= 0 || crop.height <= 0),
|
|
371
349
|
onClick: handleSubmit
|
|
372
350
|
})]
|
|
373
351
|
});
|
|
@@ -383,22 +361,22 @@ var ImageEditor = function ImageEditor(_ref) {
|
|
|
383
361
|
_ref$fixedAspectRatio = _ref.fixedAspectRatio,
|
|
384
362
|
fixedAspectRatio = _ref$fixedAspectRatio === void 0 ? {} : _ref$fixedAspectRatio;
|
|
385
363
|
var _useState = require$$0.useState(true),
|
|
386
|
-
_useState2 =
|
|
364
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
387
365
|
isAspectRatioLocked = _useState2[0],
|
|
388
366
|
setIsAspectRatioLocked = _useState2[1];
|
|
389
367
|
var _useState3 = require$$0.useState(false),
|
|
390
|
-
_useState4 =
|
|
368
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
391
369
|
isFullImage = _useState4[0],
|
|
392
370
|
setIsFullImage = _useState4[1];
|
|
393
371
|
var _useState5 = require$$0.useState({
|
|
394
372
|
width: (fixedAspectRatio === null || fixedAspectRatio === void 0 ? void 0 : fixedAspectRatio.width) || 16,
|
|
395
373
|
height: (fixedAspectRatio === null || fixedAspectRatio === void 0 ? void 0 : fixedAspectRatio.height) || 9
|
|
396
374
|
}),
|
|
397
|
-
_useState6 =
|
|
375
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
398
376
|
aspectRatio = _useState6[0],
|
|
399
377
|
setAspectRatio = _useState6[1];
|
|
400
|
-
var _useState7 = require$$0.useState(utils.DEFAULT_CROP_CONFIG),
|
|
401
|
-
_useState8 =
|
|
378
|
+
var _useState7 = require$$0.useState(utils$1.DEFAULT_CROP_CONFIG),
|
|
379
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
402
380
|
crop = _useState8[0],
|
|
403
381
|
setCrop = _useState8[1];
|
|
404
382
|
var _useTranslation = reactI18next.useTranslation(),
|
|
@@ -414,7 +392,7 @@ var ImageEditor = function ImageEditor(_ref) {
|
|
|
414
392
|
return;
|
|
415
393
|
}
|
|
416
394
|
cropImage({
|
|
417
|
-
crop: utils.getCropValues({
|
|
395
|
+
crop: utils$1.getCropValues({
|
|
418
396
|
crop: crop,
|
|
419
397
|
imageRef: imageRef
|
|
420
398
|
}),
|
|
@@ -432,11 +410,11 @@ var ImageEditor = function ImageEditor(_ref) {
|
|
|
432
410
|
handleImageEditComplete(image);
|
|
433
411
|
return;
|
|
434
412
|
}
|
|
435
|
-
var newURL = initializers.globalProps.assetsUploaderService === index.CLOUD_FLARE ? utils.getCloudFlareCroppedURL({
|
|
413
|
+
var newURL = initializers.globalProps.assetsUploaderService === index.CLOUD_FLARE ? utils$1.getCloudFlareCroppedURL({
|
|
436
414
|
imageRef: imageRef,
|
|
437
415
|
image: image,
|
|
438
416
|
crop: crop
|
|
439
|
-
}) : utils.getImageKitCroppedURL({
|
|
417
|
+
}) : utils$1.getImageKitCroppedURL({
|
|
440
418
|
crop: crop,
|
|
441
419
|
imageURL: image.url,
|
|
442
420
|
imageRef: imageRef
|
|
@@ -447,10 +425,10 @@ var ImageEditor = function ImageEditor(_ref) {
|
|
|
447
425
|
};
|
|
448
426
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
449
427
|
className: "flex h-full flex-col gap-4 px-8 py-12",
|
|
450
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(
|
|
428
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
451
429
|
className: "self-start",
|
|
452
430
|
"data-cy": "image-editor-back-button",
|
|
453
|
-
icon:
|
|
431
|
+
icon: LeftArrow,
|
|
454
432
|
iconPosition: "left",
|
|
455
433
|
style: "text",
|
|
456
434
|
onClick: handleReset
|
|
@@ -459,8 +437,8 @@ var ImageEditor = function ImageEditor(_ref) {
|
|
|
459
437
|
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
460
438
|
id: "imageEditor",
|
|
461
439
|
ref: wrapperRef,
|
|
462
|
-
className:
|
|
463
|
-
"items-center": utils.isItemsCenter({
|
|
440
|
+
className: classnames("flex", "h-full w-full md:w-4/6", "justify-around", "neeto-ui-bg-gray-200", {
|
|
441
|
+
"items-center": utils$1.isItemsCenter({
|
|
464
442
|
wrapperRef: wrapperRef,
|
|
465
443
|
imageRef: imageRef
|
|
466
444
|
})
|
|
@@ -477,7 +455,7 @@ var ImageEditor = function ImageEditor(_ref) {
|
|
|
477
455
|
ref: imageRef,
|
|
478
456
|
src: image === null || image === void 0 ? void 0 : image.url,
|
|
479
457
|
onLoad: function onLoad(e) {
|
|
480
|
-
return utils.onImageLoaded({
|
|
458
|
+
return utils$1.onImageLoaded({
|
|
481
459
|
image: e.target,
|
|
482
460
|
setCrop: setCrop,
|
|
483
461
|
cropAspectRatio: cropAspectRatio
|
|
@@ -507,7 +485,7 @@ var fetch = function fetch(_ref) {
|
|
|
507
485
|
url = _ref.url,
|
|
508
486
|
page = _ref.page,
|
|
509
487
|
per = _ref.per;
|
|
510
|
-
return
|
|
488
|
+
return axios.get(url, {
|
|
511
489
|
params: {
|
|
512
490
|
searchTerm: searchTerm,
|
|
513
491
|
page: page,
|
|
@@ -516,7 +494,7 @@ var fetch = function fetch(_ref) {
|
|
|
516
494
|
});
|
|
517
495
|
};
|
|
518
496
|
var bulkDestroy = function bulkDestroy(imageIds, url) {
|
|
519
|
-
return
|
|
497
|
+
return axios["delete"](url, {
|
|
520
498
|
params: {
|
|
521
499
|
imageIds: imageIds
|
|
522
500
|
}
|
|
@@ -528,7 +506,7 @@ var imagesApi = {
|
|
|
528
506
|
};
|
|
529
507
|
|
|
530
508
|
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; }
|
|
531
|
-
function _objectSpread$3(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) {
|
|
509
|
+
function _objectSpread$3(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(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; }
|
|
532
510
|
var useFetchAssets = function useFetchAssets(_ref) {
|
|
533
511
|
var searchTerm = _ref.searchTerm,
|
|
534
512
|
url = _ref.url,
|
|
@@ -547,7 +525,7 @@ var useFetchAssets = function useFetchAssets(_ref) {
|
|
|
547
525
|
});
|
|
548
526
|
},
|
|
549
527
|
getNextPageParam: function getNextPageParam(lastPage, _, lastPageParam) {
|
|
550
|
-
return lastPage.length === utils.IMAGES_PER_PAGE ? lastPageParam + 1 : null;
|
|
528
|
+
return lastPage.length === utils$1.IMAGES_PER_PAGE ? lastPageParam + 1 : null;
|
|
551
529
|
},
|
|
552
530
|
select: function select(data) {
|
|
553
531
|
var results = data.pages.flatMap(ramda.identity);
|
|
@@ -951,15 +929,13 @@ var bricks = function bricks() {
|
|
|
951
929
|
|
|
952
930
|
var bricks_module = /*#__PURE__*/Object.freeze({
|
|
953
931
|
__proto__: null,
|
|
954
|
-
|
|
932
|
+
default: bricks
|
|
955
933
|
});
|
|
956
934
|
|
|
957
935
|
var require$$2 = /*@__PURE__*/getAugmentedNamespace(bricks_module);
|
|
958
936
|
|
|
959
937
|
var InfiniteScroll = {exports: {}};
|
|
960
938
|
|
|
961
|
-
InfiniteScroll.exports;
|
|
962
|
-
|
|
963
939
|
(function (module, exports) {
|
|
964
940
|
|
|
965
941
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -968,7 +944,7 @@ InfiniteScroll.exports;
|
|
|
968
944
|
|
|
969
945
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
970
946
|
|
|
971
|
-
var _react = require$$
|
|
947
|
+
var _react = require$$0;
|
|
972
948
|
|
|
973
949
|
var _react2 = _interopRequireDefault(_react);
|
|
974
950
|
|
|
@@ -1273,7 +1249,7 @@ var _createClass = function () { function defineProperties(target, props) { for
|
|
|
1273
1249
|
|
|
1274
1250
|
var _class, _temp2;
|
|
1275
1251
|
|
|
1276
|
-
var _react = require$$
|
|
1252
|
+
var _react = require$$0;
|
|
1277
1253
|
|
|
1278
1254
|
var _react2 = _interopRequireDefault(_react);
|
|
1279
1255
|
|
|
@@ -1433,8 +1409,8 @@ _default = lib.default = MasonryInfiniteScroller;
|
|
|
1433
1409
|
var css = ".niu-unsplash-container {\n height: calc(75vh - 220px) !important;\n max-height: 355px;\n}\n.niu-unsplash-container img {\n height: 100%;\n width: 100%;\n -o-object-fit: cover;\n object-fit: cover;\n animation: fade-in 1.2s 1s cubic-bezier(0.39, 0.575, 0.565, 1) both;\n border-radius: var(--neeto-ui-rounded);\n position: relative;\n cursor: pointer;\n}\n/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFwcC9qYXZhc2NyaXB0L3N0eWxlc2hlZXRzL2NvbXBvbmVudHMvX2ltYWdlLWxpYnJhcnkuc2NzcyIsImFwcC9qYXZhc2NyaXB0L3N0eWxlc2hlZXRzL2Fic3RyYWN0cy9fdmFyaWFibGVzLnNjc3MiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBR0E7RUFDRSxxQ0FBQTtFQUNBLGlCQ0NrQztBREhwQztBQUlFO0VBQ0UsWUFBQTtFQUNBLFdBQUE7RUFDQSxvQkFBQTtLQUFBLGlCQUFBO0VBQ0EsbUVBQUE7RUFDQSxzQ0FBQTtFQUNBLGtCQUFBO0VBQ0EsZUFBQTtBQUZKIiwic291cmNlc0NvbnRlbnQiOlsiLy9BYnN0cmFjdHNcbkBpbXBvcnQgXCIuLi9hYnN0cmFjdHMvdmFyaWFibGVzXCI7XG5cbi5uaXUtdW5zcGxhc2gtY29udGFpbmVyIHtcbiAgaGVpZ2h0OiBjYWxjKCN7JG5pdS1tb2RhbC1oZWlnaHR9IC0gI3skbml1LW1vZGFsLWhlYWRlci1oZWlnaHR9KSAhaW1wb3J0YW50O1xuICBtYXgtaGVpZ2h0OiAkbml1LXVuc3BsYXNoLWNvbnRhaW5lci1tYXgtaGVpZ2h0O1xuXG4gIGltZyB7XG4gICAgaGVpZ2h0OiAxMDAlO1xuICAgIHdpZHRoOiAxMDAlO1xuICAgIG9iamVjdC1maXQ6IGNvdmVyO1xuICAgIGFuaW1hdGlvbjogZmFkZS1pbiAxLjJzIDFzIGN1YmljLWJlemllcigwLjM5LCAwLjU3NSwgMC41NjUsIDEpIGJvdGg7XG4gICAgYm9yZGVyLXJhZGl1czogdmFyKC0tbmVldG8tdWktcm91bmRlZCk7XG4gICAgcG9zaXRpb246IHJlbGF0aXZlO1xuICAgIGN1cnNvcjogcG9pbnRlcjtcbiAgfVxufVxuIiwiJG5pdS1tb2RhbC13aWR0aDogOTV2dztcbiRuaXUtbW9kYWwtaGVpZ2h0OiA3NXZoO1xuJG5pdS1tb2RhbC1tYXgtd2lkdGg6IDExNTJweDtcbiRuaXUtbW9kYWwtbWF4LWhlaWdodDogNTc2cHg7XG4kbml1LW1vZGFsLWhlYWRlci1oZWlnaHQ6IDIyMHB4O1xuXG4kbml1LXVuc3BsYXNoLWNvbnRhaW5lci1tYXgtaGVpZ2h0OiAzNTVweDtcbiJdfQ== */";
|
|
1434
1410
|
n(css,{});
|
|
1435
1411
|
|
|
1436
|
-
var Menu =
|
|
1437
|
-
MenuItem =
|
|
1412
|
+
var Menu = Dropdown.Menu,
|
|
1413
|
+
MenuItem = Dropdown.MenuItem;
|
|
1438
1414
|
var InfiniteScroller = function InfiniteScroller(_ref) {
|
|
1439
1415
|
var _ref$hasMore = _ref.hasMore,
|
|
1440
1416
|
hasMore = _ref$hasMore === void 0 ? false : _ref$hasMore,
|
|
@@ -1452,11 +1428,11 @@ var InfiniteScroller = function InfiniteScroller(_ref) {
|
|
|
1452
1428
|
isOpen: false,
|
|
1453
1429
|
imageIds: []
|
|
1454
1430
|
}),
|
|
1455
|
-
_useState2 =
|
|
1431
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1456
1432
|
deleteConfirmation = _useState2[0],
|
|
1457
1433
|
setDeleteConfirmation = _useState2[1];
|
|
1458
1434
|
var isMenuButtonEnabled = initializers.globalProps.assetsUploaderService !== index.CLOUD_FLARE;
|
|
1459
|
-
var _useBulkDestroyAssets = useBulkDestroyAssets(utils.ASSETS_DESTROY_URL),
|
|
1435
|
+
var _useBulkDestroyAssets = useBulkDestroyAssets(utils$1.ASSETS_DESTROY_URL),
|
|
1460
1436
|
isPending = _useBulkDestroyAssets.isPending,
|
|
1461
1437
|
bulkDelete = _useBulkDestroyAssets.mutate;
|
|
1462
1438
|
var handleDelete = require$$0.useCallback(function () {
|
|
@@ -1471,7 +1447,7 @@ var InfiniteScroller = function InfiniteScroller(_ref) {
|
|
|
1471
1447
|
}, [deleteConfirmation.imageIds]);
|
|
1472
1448
|
var Loader = /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1473
1449
|
className: "flex justify-center",
|
|
1474
|
-
children: /*#__PURE__*/jsxRuntime.jsx(
|
|
1450
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Spinner, {})
|
|
1475
1451
|
});
|
|
1476
1452
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1477
1453
|
className: "niu-unsplash-container mr-2 max-w-full overflow-x-hidden overflow-y-scroll",
|
|
@@ -1482,8 +1458,8 @@ var InfiniteScroller = function InfiniteScroller(_ref) {
|
|
|
1482
1458
|
position: true,
|
|
1483
1459
|
className: "w-full",
|
|
1484
1460
|
loader: Loader,
|
|
1485
|
-
sizes: utils.INFINITE_SCROLLER_SIZES,
|
|
1486
|
-
style: utils.INFINITE_SCROLLER_STYLE,
|
|
1461
|
+
sizes: utils$1.INFINITE_SCROLLER_SIZES,
|
|
1462
|
+
style: utils$1.INFINITE_SCROLLER_STYLE,
|
|
1487
1463
|
useWindow: false,
|
|
1488
1464
|
children: images.map(function (image, index) {
|
|
1489
1465
|
var _image$urls, _image$user, _image$user2;
|
|
@@ -1498,7 +1474,7 @@ var InfiniteScroller = function InfiniteScroller(_ref) {
|
|
|
1498
1474
|
className: "neeto-ui-rounded-sm neeto-ui-bg-gray-100 group absolute h-full w-full",
|
|
1499
1475
|
"data-cy": "library-image-card",
|
|
1500
1476
|
id: "unsplashImage".concat(image.id),
|
|
1501
|
-
children: [tab === utils.TABS[
|
|
1477
|
+
children: [tab === utils$1.TABS[2].key && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1502
1478
|
children: [/*#__PURE__*/jsxRuntime.jsx("img", {
|
|
1503
1479
|
"data-cy": "niu-unsplash-image-".concat(index),
|
|
1504
1480
|
src: image === null || image === void 0 ? void 0 : (_image$urls = image.urls) === null || _image$urls === void 0 ? void 0 : _image$urls.regular,
|
|
@@ -1512,12 +1488,12 @@ var InfiniteScroller = function InfiniteScroller(_ref) {
|
|
|
1512
1488
|
target: "_blank",
|
|
1513
1489
|
children: [image === null || image === void 0 ? void 0 : (_image$user2 = image.user) === null || _image$user2 === void 0 ? void 0 : _image$user2.name, " | ", " ", t("neetoImageUploader.labels.unsplash")]
|
|
1514
1490
|
})]
|
|
1515
|
-
}), tab === utils.TABS[
|
|
1516
|
-
children: [utils
|
|
1491
|
+
}), tab === utils$1.TABS[1].key && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1492
|
+
children: [utils.hasPermission(constants.VIEW_ROLES_PERMISSION) && isMenuButtonEnabled && /*#__PURE__*/jsxRuntime.jsx(Dropdown, {
|
|
1517
1493
|
buttonSize: "small",
|
|
1518
1494
|
buttonStyle: "tertiary",
|
|
1519
1495
|
"data-cy": "image-library-image-options-".concat(index),
|
|
1520
|
-
icon:
|
|
1496
|
+
icon: MenuHorizontal,
|
|
1521
1497
|
buttonProps: {
|
|
1522
1498
|
className:
|
|
1523
1499
|
// eslint-disable-next-line @bigbinary/neeto/use-neetoui-classes
|
|
@@ -1547,7 +1523,7 @@ var InfiniteScroller = function InfiniteScroller(_ref) {
|
|
|
1547
1523
|
})
|
|
1548
1524
|
}, image.id);
|
|
1549
1525
|
})
|
|
1550
|
-
}), /*#__PURE__*/jsxRuntime.jsx(
|
|
1526
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Alert, {
|
|
1551
1527
|
isOpen: deleteConfirmation.isOpen,
|
|
1552
1528
|
isSubmitting: isPending,
|
|
1553
1529
|
message: t("neetoImageUploader.deleteConfirmation.message"),
|
|
@@ -1571,8 +1547,8 @@ var Images = function Images(_ref) {
|
|
|
1571
1547
|
t = _useTranslation.t;
|
|
1572
1548
|
var _useFetchAssets = useFetchAssets({
|
|
1573
1549
|
searchTerm: debouncedQuery,
|
|
1574
|
-
per: utils.IMAGES_PER_PAGE,
|
|
1575
|
-
url: utils.ASSETS_FETCH_URL
|
|
1550
|
+
per: utils$1.IMAGES_PER_PAGE,
|
|
1551
|
+
url: utils$1.ASSETS_FETCH_URL
|
|
1576
1552
|
}),
|
|
1577
1553
|
fetchNextPage = _useFetchAssets.fetchNextPage,
|
|
1578
1554
|
hasNextPage = _useFetchAssets.hasNextPage,
|
|
@@ -1583,7 +1559,7 @@ var Images = function Images(_ref) {
|
|
|
1583
1559
|
isLoading = _useFetchAssets.isLoading,
|
|
1584
1560
|
isError = _useFetchAssets.isError;
|
|
1585
1561
|
if (isError) {
|
|
1586
|
-
return /*#__PURE__*/jsxRuntime.jsx(
|
|
1562
|
+
return /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
1587
1563
|
className: "mt-9 flex justify-center",
|
|
1588
1564
|
style: "body2",
|
|
1589
1565
|
children: t("neetoImageUploader.unsplash.errorMessage")
|
|
@@ -1592,7 +1568,7 @@ var Images = function Images(_ref) {
|
|
|
1592
1568
|
if (isLoading) {
|
|
1593
1569
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1594
1570
|
className: "flex justify-around",
|
|
1595
|
-
children: /*#__PURE__*/jsxRuntime.jsx(
|
|
1571
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Spinner, {})
|
|
1596
1572
|
});
|
|
1597
1573
|
}
|
|
1598
1574
|
return /*#__PURE__*/require$$0.createElement(InfiniteScroller, {
|
|
@@ -1601,15 +1577,15 @@ var Images = function Images(_ref) {
|
|
|
1601
1577
|
images: results,
|
|
1602
1578
|
key: debouncedQuery,
|
|
1603
1579
|
loadMore: fetchNextPage,
|
|
1604
|
-
tab: utils.TABS[
|
|
1580
|
+
tab: utils$1.TABS[1].key
|
|
1605
1581
|
});
|
|
1606
1582
|
};
|
|
1607
1583
|
|
|
1608
|
-
var newAxiosInstance =
|
|
1584
|
+
var newAxiosInstance = axios.create();
|
|
1609
1585
|
var searchUnsplashImages = function searchUnsplashImages(_ref) {
|
|
1610
1586
|
var pageNo = _ref.pageNo,
|
|
1611
1587
|
query = _ref.query;
|
|
1612
|
-
return
|
|
1588
|
+
return axios.get("neeto_image_uploader_engine/unsplash/fetch", {
|
|
1613
1589
|
params: {
|
|
1614
1590
|
page: pageNo,
|
|
1615
1591
|
per_page: 30,
|
|
@@ -1627,7 +1603,7 @@ var unsplashApi = {
|
|
|
1627
1603
|
};
|
|
1628
1604
|
|
|
1629
1605
|
function ownKeys$2(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; }
|
|
1630
|
-
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), !0).forEach(function (r) {
|
|
1606
|
+
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1631
1607
|
var UNSPLASH_LIST = query.QUERY_KEYS.UNSPLASH_LIST;
|
|
1632
1608
|
var useFetchUnsplashImages = function useFetchUnsplashImages(_ref) {
|
|
1633
1609
|
var query$1 = _ref.query;
|
|
@@ -1660,7 +1636,7 @@ var useFetchUnsplashImages = function useFetchUnsplashImages(_ref) {
|
|
|
1660
1636
|
};
|
|
1661
1637
|
|
|
1662
1638
|
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; }
|
|
1663
|
-
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) {
|
|
1639
|
+
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(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; }
|
|
1664
1640
|
var UnsplashLibrary = function UnsplashLibrary(_ref) {
|
|
1665
1641
|
var debouncedQuery = _ref.debouncedQuery,
|
|
1666
1642
|
setSelectedImage = _ref.setSelectedImage,
|
|
@@ -1692,18 +1668,18 @@ var UnsplashLibrary = function UnsplashLibrary(_ref) {
|
|
|
1692
1668
|
}),
|
|
1693
1669
|
uploadFile = _useImageUploader.uploadFile;
|
|
1694
1670
|
var handleUnsplashImageSelect = /*#__PURE__*/function () {
|
|
1695
|
-
var _ref2 =
|
|
1671
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(image) {
|
|
1696
1672
|
var _image$urls, response, file;
|
|
1697
|
-
return
|
|
1673
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
1698
1674
|
while (1) switch (_context.prev = _context.next) {
|
|
1699
1675
|
case 0:
|
|
1700
1676
|
_context.prev = 0;
|
|
1701
1677
|
setIsUploading(true);
|
|
1702
1678
|
_context.next = 4;
|
|
1703
|
-
return unsplashApi.getUnsplashImage((_image$urls = image.urls) === null || _image$urls === void 0 ? void 0 : _image$urls.regular, utils.UNSPLASH_DEFAULT_REQUEST_CONFIG);
|
|
1679
|
+
return unsplashApi.getUnsplashImage((_image$urls = image.urls) === null || _image$urls === void 0 ? void 0 : _image$urls.regular, utils$1.UNSPLASH_DEFAULT_REQUEST_CONFIG);
|
|
1704
1680
|
case 4:
|
|
1705
1681
|
response = _context.sent;
|
|
1706
|
-
file = new File([response.data], utils.UNSPLASH_DEFAULT_NAME, {
|
|
1682
|
+
file = new File([response.data], utils$1.UNSPLASH_DEFAULT_NAME, {
|
|
1707
1683
|
type: response.data.type
|
|
1708
1684
|
});
|
|
1709
1685
|
uploadFile(file);
|
|
@@ -1712,8 +1688,8 @@ var UnsplashLibrary = function UnsplashLibrary(_ref) {
|
|
|
1712
1688
|
case 9:
|
|
1713
1689
|
_context.prev = 9;
|
|
1714
1690
|
_context.t0 = _context["catch"](0);
|
|
1715
|
-
|
|
1716
|
-
setActiveTab(utils.TABS[
|
|
1691
|
+
Toastr.error(_context.t0);
|
|
1692
|
+
setActiveTab(utils$1.TABS[1].key);
|
|
1717
1693
|
setIsUploading(false);
|
|
1718
1694
|
case 14:
|
|
1719
1695
|
case "end":
|
|
@@ -1739,7 +1715,7 @@ var UnsplashLibrary = function UnsplashLibrary(_ref) {
|
|
|
1739
1715
|
isError = _useFetchUnsplashImag.isError,
|
|
1740
1716
|
isLoading = _useFetchUnsplashImag.isLoading;
|
|
1741
1717
|
if (isError) {
|
|
1742
|
-
return /*#__PURE__*/jsxRuntime.jsx(
|
|
1718
|
+
return /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
1743
1719
|
className: "mt-9 flex justify-center",
|
|
1744
1720
|
style: "body2",
|
|
1745
1721
|
children: t("neetoImageUploader.unsplash.errorMessage")
|
|
@@ -1748,7 +1724,7 @@ var UnsplashLibrary = function UnsplashLibrary(_ref) {
|
|
|
1748
1724
|
if (isLoading) {
|
|
1749
1725
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1750
1726
|
className: "flex justify-around",
|
|
1751
|
-
children: /*#__PURE__*/jsxRuntime.jsx(
|
|
1727
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Spinner, {})
|
|
1752
1728
|
});
|
|
1753
1729
|
}
|
|
1754
1730
|
return /*#__PURE__*/require$$0.createElement(InfiniteScroller, {
|
|
@@ -1758,7 +1734,7 @@ var UnsplashLibrary = function UnsplashLibrary(_ref) {
|
|
|
1758
1734
|
images: results,
|
|
1759
1735
|
key: debouncedQuery,
|
|
1760
1736
|
loadMore: fetchNextPage,
|
|
1761
|
-
tab: utils.TABS[
|
|
1737
|
+
tab: utils$1.TABS[2].key
|
|
1762
1738
|
});
|
|
1763
1739
|
};
|
|
1764
1740
|
|
|
@@ -1768,21 +1744,21 @@ var ImageLibrary = function ImageLibrary(_ref) {
|
|
|
1768
1744
|
setIsUploading = _ref.setIsUploading,
|
|
1769
1745
|
setActiveTab = _ref.setActiveTab;
|
|
1770
1746
|
var _useState = require$$0.useState(""),
|
|
1771
|
-
_useState2 =
|
|
1747
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1772
1748
|
query = _useState2[0],
|
|
1773
1749
|
setQuery = _useState2[1];
|
|
1774
1750
|
var _useTranslation = reactI18next.useTranslation(),
|
|
1775
1751
|
t = _useTranslation.t;
|
|
1776
1752
|
var debouncedQuery = reactUtils.useDebounce(query, 400);
|
|
1777
|
-
var inputPlaceHolder = ramda.equals(tab, utils.TABS[
|
|
1753
|
+
var inputPlaceHolder = ramda.equals(tab, utils$1.TABS[2].key) ? t("neetoImageUploader.placeholders.searchImageFromWeb") : t("neetoImageUploader.placeholders.searchImage");
|
|
1778
1754
|
require$$0.useEffect(function () {
|
|
1779
1755
|
setQuery("");
|
|
1780
1756
|
}, [tab]);
|
|
1781
1757
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1782
|
-
className: "w-full pb-2
|
|
1783
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(
|
|
1758
|
+
className: "w-full px-6 pb-2 pt-1",
|
|
1759
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Input, {
|
|
1784
1760
|
autoFocus: true,
|
|
1785
|
-
className: "mb-4
|
|
1761
|
+
className: "mb-4",
|
|
1786
1762
|
"data-cy": "niu-unsplash-image-picker-search-input",
|
|
1787
1763
|
name: "text",
|
|
1788
1764
|
placeholder: inputPlaceHolder,
|
|
@@ -1791,7 +1767,7 @@ var ImageLibrary = function ImageLibrary(_ref) {
|
|
|
1791
1767
|
var value = _ref2.target.value;
|
|
1792
1768
|
return setQuery(value);
|
|
1793
1769
|
}
|
|
1794
|
-
}), tab === utils.TABS[
|
|
1770
|
+
}), tab === utils$1.TABS[1].key ? /*#__PURE__*/jsxRuntime.jsx(Images, {
|
|
1795
1771
|
debouncedQuery: debouncedQuery,
|
|
1796
1772
|
query: query,
|
|
1797
1773
|
setSelectedImage: setSelectedImage
|
|
@@ -1805,9 +1781,8 @@ var ImageLibrary = function ImageLibrary(_ref) {
|
|
|
1805
1781
|
});
|
|
1806
1782
|
};
|
|
1807
1783
|
|
|
1808
|
-
var _excluded = ["key"];
|
|
1809
1784
|
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; }
|
|
1810
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
|
|
1785
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).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; }
|
|
1811
1786
|
var Modal = function Modal(_ref) {
|
|
1812
1787
|
var isOpen = _ref.isOpen,
|
|
1813
1788
|
_ref$onClose = _ref.onClose,
|
|
@@ -1818,23 +1793,23 @@ var Modal = function Modal(_ref) {
|
|
|
1818
1793
|
uploadConfig = _ref$uploadConfig === void 0 ? {} : _ref$uploadConfig,
|
|
1819
1794
|
_ref$fixedAspectRatio = _ref.fixedAspectRatio,
|
|
1820
1795
|
fixedAspectRatio = _ref$fixedAspectRatio === void 0 ? {} : _ref$fixedAspectRatio;
|
|
1821
|
-
var _useState = require$$0.useState(utils.TABS[0].key),
|
|
1822
|
-
_useState2 =
|
|
1796
|
+
var _useState = require$$0.useState(utils$1.TABS[0].key),
|
|
1797
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1823
1798
|
activeTab = _useState2[0],
|
|
1824
1799
|
setActiveTab = _useState2[1];
|
|
1825
1800
|
var _useState3 = require$$0.useState({}),
|
|
1826
|
-
_useState4 =
|
|
1801
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
1827
1802
|
selectedImage = _useState4[0],
|
|
1828
1803
|
setSelectedImage = _useState4[1];
|
|
1829
1804
|
var _useState5 = require$$0.useState(false),
|
|
1830
|
-
_useState6 =
|
|
1805
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
1831
1806
|
isUploading = _useState6[0],
|
|
1832
1807
|
setIsUploading = _useState6[1];
|
|
1833
1808
|
var _useTranslation = reactI18next.useTranslation(),
|
|
1834
1809
|
t = _useTranslation.t;
|
|
1835
1810
|
var _useCreateBlob = useImageUploader.useCreateBlob(),
|
|
1836
1811
|
createBlob = _useCreateBlob.mutate;
|
|
1837
|
-
var uploadConfigWithDefaults = ramda.mergeRight(utils.DEFAULT_UPLOAD_CONFIG, uploadConfig);
|
|
1812
|
+
var uploadConfigWithDefaults = ramda.mergeRight(utils$1.DEFAULT_UPLOAD_CONFIG, uploadConfig);
|
|
1838
1813
|
var isCloudFlareImageUploader = initializers.globalProps.assetsUploaderService === index.CLOUD_FLARE;
|
|
1839
1814
|
var handleCloseModal = function handleCloseModal() {
|
|
1840
1815
|
onClose();
|
|
@@ -1887,7 +1862,7 @@ var Modal = function Modal(_ref) {
|
|
|
1887
1862
|
signedId: image.signedId
|
|
1888
1863
|
});
|
|
1889
1864
|
},
|
|
1890
|
-
onError:
|
|
1865
|
+
onError: Toastr.error
|
|
1891
1866
|
});
|
|
1892
1867
|
}
|
|
1893
1868
|
};
|
|
@@ -1896,40 +1871,52 @@ var Modal = function Modal(_ref) {
|
|
|
1896
1871
|
setIsUploading: setIsUploading
|
|
1897
1872
|
}),
|
|
1898
1873
|
uploadFile = _useImageUploader.uploadFile;
|
|
1899
|
-
var _useUploadDropzone = utils.useUploadDropzone({
|
|
1874
|
+
var _useUploadDropzone = utils$1.useUploadDropzone({
|
|
1900
1875
|
uploadConfig: uploadConfigWithDefaults,
|
|
1901
1876
|
onDrop: uploadFile
|
|
1902
1877
|
}),
|
|
1903
1878
|
getRootProps = _useUploadDropzone.getRootProps,
|
|
1904
1879
|
getInputProps = _useUploadDropzone.getInputProps,
|
|
1905
|
-
isDragActive = _useUploadDropzone.isDragActive
|
|
1906
|
-
inputRef = _useUploadDropzone.inputRef;
|
|
1907
|
-
var openFileUploadDialog = function openFileUploadDialog() {
|
|
1908
|
-
var _inputRef$current;
|
|
1909
|
-
return (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.click();
|
|
1910
|
-
};
|
|
1911
|
-
var options = createOptions([{
|
|
1912
|
-
key: "local",
|
|
1913
|
-
onClick: openFileUploadDialog
|
|
1914
|
-
}]);
|
|
1880
|
+
isDragActive = _useUploadDropzone.isDragActive;
|
|
1915
1881
|
require$$0.useEffect(function () {
|
|
1916
|
-
setActiveTab(utils.TABS[0].key);
|
|
1882
|
+
setActiveTab(utils$1.TABS[0].key);
|
|
1917
1883
|
}, [isOpen]);
|
|
1918
|
-
|
|
1884
|
+
var renderContent = function renderContent() {
|
|
1885
|
+
if (activeTab === "upload") {
|
|
1886
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1887
|
+
className: "flex-grow px-6 pb-6",
|
|
1888
|
+
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1889
|
+
className: "h-full w-full overflow-y-auto",
|
|
1890
|
+
children: /*#__PURE__*/jsxRuntime.jsx(utils$1.ImageDirectUpload, {
|
|
1891
|
+
isDisabled: neetoCist.isPresent(fixedAspectRatio),
|
|
1892
|
+
uploadConfig: uploadConfigWithDefaults,
|
|
1893
|
+
onDrop: uploadFile
|
|
1894
|
+
})
|
|
1895
|
+
})
|
|
1896
|
+
});
|
|
1897
|
+
}
|
|
1898
|
+
return /*#__PURE__*/jsxRuntime.jsx(ImageLibrary, {
|
|
1899
|
+
setActiveTab: setActiveTab,
|
|
1900
|
+
setIsUploading: setIsUploading,
|
|
1901
|
+
setSelectedImage: setSelectedImage,
|
|
1902
|
+
tab: activeTab
|
|
1903
|
+
});
|
|
1904
|
+
};
|
|
1905
|
+
return /*#__PURE__*/jsxRuntime.jsxs(NeetoUIModal, {
|
|
1919
1906
|
isOpen: isOpen,
|
|
1920
1907
|
className: "niu-modal",
|
|
1921
1908
|
size: "large",
|
|
1922
1909
|
onClose: handleCloseModal,
|
|
1923
1910
|
children: [isUploading && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1924
1911
|
className: "neeto-ui-bg-gray-400 absolute inset-0 z-50 flex h-full items-center justify-center opacity-50",
|
|
1925
|
-
children: /*#__PURE__*/jsxRuntime.jsx(
|
|
1926
|
-
}), utils.isNilOrEmpty(selectedImage) && isDragActive && /*#__PURE__*/jsxRuntime.jsx("div", _objectSpread(_objectSpread({
|
|
1912
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Spinner, {})
|
|
1913
|
+
}), utils$1.isNilOrEmpty(selectedImage) && isDragActive && /*#__PURE__*/jsxRuntime.jsx("div", _objectSpread(_objectSpread({
|
|
1927
1914
|
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"
|
|
1928
1915
|
}, getRootProps()), {}, {
|
|
1929
|
-
children: /*#__PURE__*/jsxRuntime.jsx(
|
|
1916
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
1930
1917
|
children: t("neetoImageUploader.common.dropHere")
|
|
1931
1918
|
})
|
|
1932
|
-
})), !utils.isNilOrEmpty(selectedImage) ? /*#__PURE__*/jsxRuntime.jsx(ImageEditor, {
|
|
1919
|
+
})), !utils$1.isNilOrEmpty(selectedImage) ? /*#__PURE__*/jsxRuntime.jsx(ImageEditor, {
|
|
1933
1920
|
fixedAspectRatio: fixedAspectRatio,
|
|
1934
1921
|
handleImageEditComplete: handleImageEditComplete,
|
|
1935
1922
|
handleReset: function handleReset() {
|
|
@@ -1938,62 +1925,41 @@ var Modal = function Modal(_ref) {
|
|
|
1938
1925
|
image: selectedImage,
|
|
1939
1926
|
signedId: selectedImage === null || selectedImage === void 0 ? void 0 : selectedImage.signedId
|
|
1940
1927
|
}) : /*#__PURE__*/jsxRuntime.jsxs("div", _objectSpread(_objectSpread({
|
|
1941
|
-
className: "h-full flex-col"
|
|
1928
|
+
className: "flex h-full flex-col"
|
|
1942
1929
|
}, getRootProps({
|
|
1943
1930
|
onClick: function onClick(event) {
|
|
1944
1931
|
return event.stopPropagation();
|
|
1945
1932
|
}
|
|
1946
1933
|
})), {}, {
|
|
1947
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(
|
|
1948
|
-
children: /*#__PURE__*/jsxRuntime.jsx(
|
|
1934
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(NeetoUIModal.Header, {
|
|
1935
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
1949
1936
|
style: "h2",
|
|
1950
1937
|
children: t("neetoImageUploader.common.imageLibrary")
|
|
1951
1938
|
})
|
|
1952
1939
|
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1953
|
-
className: "px-6 py-2",
|
|
1954
|
-
children: /*#__PURE__*/jsxRuntime.
|
|
1955
|
-
|
|
1956
|
-
children:
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
return
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
},
|
|
1967
|
-
children: tab.label
|
|
1968
|
-
}, tab.key);
|
|
1969
|
-
})
|
|
1970
|
-
})
|
|
1971
|
-
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1972
|
-
className: "flex gap-2",
|
|
1973
|
-
children: options.map(function (_ref2) {
|
|
1974
|
-
var key = _ref2.key,
|
|
1975
|
-
otherProps = _objectWithoutProperties__default["default"](_ref2, _excluded);
|
|
1976
|
-
return /*#__PURE__*/require$$0.createElement(Button__default["default"], _objectSpread(_objectSpread({}, otherProps), {}, {
|
|
1977
|
-
key: key,
|
|
1978
|
-
size: "small"
|
|
1979
|
-
}));
|
|
1980
|
-
})
|
|
1981
|
-
})]
|
|
1940
|
+
className: "flex gap-2 px-6 py-2",
|
|
1941
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Tab, {
|
|
1942
|
+
size: "small",
|
|
1943
|
+
children: utils$1.TABS.map(function (tab) {
|
|
1944
|
+
return /*#__PURE__*/jsxRuntime.jsx(Tab.Item, {
|
|
1945
|
+
active: activeTab === tab.key,
|
|
1946
|
+
"data-cy": tab.dataCy,
|
|
1947
|
+
onClick: function onClick() {
|
|
1948
|
+
return setActiveTab(tab.key);
|
|
1949
|
+
},
|
|
1950
|
+
children: tab.label
|
|
1951
|
+
}, tab.key);
|
|
1952
|
+
})
|
|
1982
1953
|
})
|
|
1983
|
-
}), /*#__PURE__*/jsxRuntime.jsx(
|
|
1984
|
-
setActiveTab: setActiveTab,
|
|
1985
|
-
setIsUploading: setIsUploading,
|
|
1986
|
-
setSelectedImage: setSelectedImage,
|
|
1987
|
-
tab: activeTab
|
|
1988
|
-
}), ramda.equals(activeTab, utils.TABS[1].key) && /*#__PURE__*/jsxRuntime.jsx(NeetoUIModal__default["default"].Footer, {
|
|
1954
|
+
}), renderContent(), ramda.equals(activeTab, utils$1.TABS[2].key) && /*#__PURE__*/jsxRuntime.jsx(NeetoUIModal.Footer, {
|
|
1989
1955
|
className: "flex items-center justify-center gap-2",
|
|
1990
|
-
children: /*#__PURE__*/jsxRuntime.jsx(
|
|
1956
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
1991
1957
|
style: "body2",
|
|
1992
1958
|
children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
|
|
1993
1959
|
i18nKey: "neetoImageUploader.unsplash.poweredByUnsplash",
|
|
1994
1960
|
components: {
|
|
1995
1961
|
a: /*#__PURE__*/jsxRuntime.jsx("a", {
|
|
1996
|
-
href: utils.UNSPLASH_URL,
|
|
1962
|
+
href: utils$1.UNSPLASH_URL,
|
|
1997
1963
|
rel: "noreferrer",
|
|
1998
1964
|
target: "_blank"
|
|
1999
1965
|
})
|
|
@@ -2007,4 +1973,4 @@ var Modal = function Modal(_ref) {
|
|
|
2007
1973
|
|
|
2008
1974
|
exports.Modal = Modal;
|
|
2009
1975
|
exports.constructCloudflareImageURL = constructCloudflareImageURL;
|
|
2010
|
-
//# sourceMappingURL=index-
|
|
1976
|
+
//# sourceMappingURL=index-BkKE5xo-.js.map
|