diff --git a/dist/ReactCrop.js b/dist/ReactCrop.js index d92ed7a..4085ac3 100644 --- a/dist/ReactCrop.js +++ b/dist/ReactCrop.js @@ -292,7 +292,7 @@ module.exports = ReactPropTypesSecret; Object.defineProperty(exports, "__esModule", { value: true }); -exports.containCrop = exports.makeAspectCrop = exports.getPixelCrop = exports.Component = exports.default = exports.ReactCrop = undefined; +exports.containCrop = exports.makeAspectCrop = exports.getPixelCrop = exports.Component = exports.default = undefined; 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; }; }(); @@ -1148,7 +1148,6 @@ ReactCrop.defaultProps = { imageStyle: undefined }; -exports.ReactCrop = ReactCrop; exports.default = ReactCrop; exports.Component = ReactCrop; exports.getPixelCrop = getPixelCrop; diff --git a/dist/ReactCrop.min.js b/dist/ReactCrop.min.js index 29b8ac3..0c206e9 100644 --- a/dist/ReactCrop.min.js +++ b/dist/ReactCrop.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.ReactCrop=t(require("react")):e.ReactCrop=t(e.React)}("undefined"!=typeof self?self:this,function(e){return function(e){function t(o){if(r[o])return r[o].exports;var a=r[o]={i:o,l:!1,exports:{}};return e[o].call(a.exports,a,a.exports,t),a.l=!0,a.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,o){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,r){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function a(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t100&&(r.height=100-e.y,r.width=r.height*e.aspect/t),e.x+(r.width||e.width)>100&&(r.width=100-e.x,r.height=r.width/e.aspect*t),r}function l(e,t){return e&&e.aspect&&(!e.width&&e.height||e.width&&!e.height)?f(e,t.naturalWidth/t.naturalHeight):e}function g(e,t){if(!e||!t)return null;var r=Math.round(e.naturalWidth*(t.x/100)),o=Math.round(e.naturalHeight*(t.y/100)),a=Math.round(e.naturalWidth*(t.width/100)),n=Math.round(e.naturalHeight*(t.height/100));return{x:r,y:o,width:h(a,0,e.naturalWidth-r),height:h(n,0,e.naturalHeight-o)}}function v(e,t,r){var o=y({},t),a=!1;o.x+o.width>100?(o.width=t.width+(100-(t.x+t.width)),o.x=t.x+(100-(t.x+o.width)),a=!0):o.x<0&&(o.width=t.x+t.width,o.x=0,a=!0),a&&t.aspect&&(o.height=o.width/t.aspect*r,e.y>o.y&&(o.y=t.y+(t.height-o.height)));var n=!1;return o.y+o.height>100?(o.height=t.height+(100-(t.y+t.height)),o.y=t.y+(100-(t.y+o.height)),n=!0):o.y<0&&(o.height=t.y+t.height,o.y=0,n=!0),n&&t.aspect&&(o.width=o.height*t.aspect/r,o.x-1?(e.x=c.x,e.y=c.y,e.width=c.width,e.height=c.height):t.xOrds.indexOf(o)>-1?(e.x=c.x,e.width=c.width):t.yOrds.indexOf(o)>-1&&(e.y=c.y,e.height=c.height),r.lastYCrossover=r.yCrossOver,this.crossOverCheck(),e}},{key:"straightenYPath",value:function(e){var t=this.evData,r=t.ord,o=t.cropOffset,a=t.cropStartWidth/100*this.imageRef.width,n=t.cropStartHeight/100*this.imageRef.height,i=void 0,s=void 0;return"nw"===r||"se"===r?(i=n/a,s=o.top-o.left*i):(i=-n/a,s=o.top+(n-o.left*i)),i*e+s}},{key:"createCropSelection",value:function(){var e=this,t=this.props.disabled,r=this.getCropStyle();return C.default.createElement("div",{ref:function(t){e.cropSelectRef=t},style:r,className:"ReactCrop__crop-selection",onMouseDown:this.onCropMouseTouchDown,onTouchStart:this.onCropMouseTouchDown,role:"presentation"},!t&&C.default.createElement("div",{className:"ReactCrop__drag-elements"},C.default.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),C.default.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),C.default.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),C.default.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),C.default.createElement("div",{className:"ReactCrop__drag-handle ord-nw","data-ord":"nw"}),C.default.createElement("div",{className:"ReactCrop__drag-handle ord-n","data-ord":"n"}),C.default.createElement("div",{className:"ReactCrop__drag-handle ord-ne","data-ord":"ne"}),C.default.createElement("div",{className:"ReactCrop__drag-handle ord-e","data-ord":"e"}),C.default.createElement("div",{className:"ReactCrop__drag-handle ord-se","data-ord":"se"}),C.default.createElement("div",{className:"ReactCrop__drag-handle ord-s","data-ord":"s"}),C.default.createElement("div",{className:"ReactCrop__drag-handle ord-sw","data-ord":"sw"}),C.default.createElement("div",{className:"ReactCrop__drag-handle ord-w","data-ord":"w"})))}},{key:"makeNewCrop",value:function(){return y({},t.defaultCrop,this.props.crop)}},{key:"crossOverCheck",value:function(){var e=this.evData;(!e.xCrossOver&&-Math.abs(e.cropStartWidth)-e.xDiffPc>=0||e.xCrossOver&&-Math.abs(e.cropStartWidth)-e.xDiffPc<=0)&&(e.xCrossOver=!e.xCrossOver),(!e.yCrossOver&&-Math.abs(e.cropStartHeight)-e.yDiffPc>=0||e.yCrossOver&&-Math.abs(e.cropStartHeight)-e.yDiffPc<=0)&&(e.yCrossOver=!e.yCrossOver);var t=e.xCrossOver!==e.startXCrossOver,r=e.yCrossOver!==e.startYCrossOver;e.inversedXOrd=!!t&&p(e.ord),e.inversedYOrd=!!r&&p(e.ord)}},{key:"render",value:function(){var e=this,t=this.props,r=t.children,o=t.className,n=t.crossorigin,i=t.crop,s=t.disabled,c=t.imageAlt,d=t.onImageError,h=t.src,p=t.style,f=t.imageStyle,l=this.state.cropIsActive,g=void 0;u(i)&&(g=this.createCropSelection());var v=["ReactCrop"];return l&&v.push("ReactCrop--active"),i&&(i.aspect&&v.push("ReactCrop--fixed-aspect"),!l||i.width&&i.height||v.push("ReactCrop--crop-invisible")),s&&v.push("ReactCrop--disabled"),o&&v.push.apply(v,a(o.split(" "))),C.default.createElement("div",{ref:function(t){e.componentRef=t},className:v.join(" "),style:p,onTouchStart:this.onComponentMouseTouchDown,onMouseDown:this.onComponentMouseTouchDown,role:"presentation",tabIndex:"1",onKeyDown:this.onComponentKeyDown},C.default.createElement("img",{ref:function(t){e.imageRef=t},crossOrigin:n,className:"ReactCrop__image",style:f,src:h,onLoad:function(t){return e.onImageLoad(t.target)},onError:d,alt:c}),g,r)}}]),t}(w.PureComponent);b.xOrds=["e","w"],b.yOrds=["n","s"],b.xyOrds=["nw","ne","se","sw"],b.arrowKey={left:37,up:38,right:39,down:40},b.nudgeStep=.2,b.defaultCrop={x:0,y:0,width:0,height:0},b.propTypes={className:O.default.string,crossorigin:O.default.string,children:O.default.oneOfType([O.default.arrayOf(O.default.node),O.default.node]),crop:O.default.shape({aspect:O.default.number,x:O.default.number,y:O.default.number,width:O.default.number,height:O.default.number}),disabled:O.default.bool,imageAlt:O.default.string,imageStyle:O.default.shape({}),keepSelection:O.default.bool,minWidth:O.default.number,minHeight:O.default.number,maxWidth:O.default.number,maxHeight:O.default.number,onChange:O.default.func.isRequired,onImageError:O.default.func,onComplete:O.default.func,onImageLoaded:O.default.func,onDragStart:O.default.func,onDragEnd:O.default.func,src:O.default.string.isRequired,style:O.default.shape({})},b.defaultProps={className:void 0,crop:void 0,crossorigin:void 0,disabled:!1,imageAlt:"",maxWidth:100,maxHeight:100,minWidth:0,minHeight:0,keepSelection:!1,onComplete:function(){},onImageError:function(){},onImageLoaded:function(){},onDragStart:function(){},onDragEnd:function(){},children:void 0,style:void 0,imageStyle:void 0},t.ReactCrop=b,t.default=b,t.Component=b,t.getPixelCrop=g,t.makeAspectCrop=f,t.containCrop=v},function(t,r){t.exports=e},function(e,t,r){e.exports=r(3)()},function(e,t,r){"use strict";function o(){}var a=r(4);e.exports=function(){function e(e,t,r,o,n,i){if(i!==a){var s=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}}function t(){return e}e.isRequired=e;var r={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return r.checkPropTypes=o,r.PropTypes=r,r}},function(e,t,r){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}])}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.ReactCrop=t(require("react")):e.ReactCrop=t(e.React)}("undefined"!=typeof self?self:this,function(e){return function(e){function t(o){if(r[o])return r[o].exports;var a=r[o]={i:o,l:!1,exports:{}};return e[o].call(a.exports,a,a.exports,t),a.l=!0,a.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,o){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,r){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function a(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t100&&(r.height=100-e.y,r.width=r.height*e.aspect/t),e.x+(r.width||e.width)>100&&(r.width=100-e.x,r.height=r.width/e.aspect*t),r}function l(e,t){return e&&e.aspect&&(!e.width&&e.height||e.width&&!e.height)?f(e,t.naturalWidth/t.naturalHeight):e}function g(e,t){if(!e||!t)return null;var r=Math.round(e.naturalWidth*(t.x/100)),o=Math.round(e.naturalHeight*(t.y/100)),a=Math.round(e.naturalWidth*(t.width/100)),n=Math.round(e.naturalHeight*(t.height/100));return{x:r,y:o,width:h(a,0,e.naturalWidth-r),height:h(n,0,e.naturalHeight-o)}}function v(e,t,r){var o=y({},t),a=!1;o.x+o.width>100?(o.width=t.width+(100-(t.x+t.width)),o.x=t.x+(100-(t.x+o.width)),a=!0):o.x<0&&(o.width=t.x+t.width,o.x=0,a=!0),a&&t.aspect&&(o.height=o.width/t.aspect*r,e.y>o.y&&(o.y=t.y+(t.height-o.height)));var n=!1;return o.y+o.height>100?(o.height=t.height+(100-(t.y+t.height)),o.y=t.y+(100-(t.y+o.height)),n=!0):o.y<0&&(o.height=t.y+t.height,o.y=0,n=!0),n&&t.aspect&&(o.width=o.height*t.aspect/r,o.x-1?(e.x=c.x,e.y=c.y,e.width=c.width,e.height=c.height):t.xOrds.indexOf(o)>-1?(e.x=c.x,e.width=c.width):t.yOrds.indexOf(o)>-1&&(e.y=c.y,e.height=c.height),r.lastYCrossover=r.yCrossOver,this.crossOverCheck(),e}},{key:"straightenYPath",value:function(e){var t=this.evData,r=t.ord,o=t.cropOffset,a=t.cropStartWidth/100*this.imageRef.width,n=t.cropStartHeight/100*this.imageRef.height,i=void 0,s=void 0;return"nw"===r||"se"===r?(i=n/a,s=o.top-o.left*i):(i=-n/a,s=o.top+(n-o.left*i)),i*e+s}},{key:"createCropSelection",value:function(){var e=this,t=this.props.disabled,r=this.getCropStyle();return C.default.createElement("div",{ref:function(t){e.cropSelectRef=t},style:r,className:"ReactCrop__crop-selection",onMouseDown:this.onCropMouseTouchDown,onTouchStart:this.onCropMouseTouchDown,role:"presentation"},!t&&C.default.createElement("div",{className:"ReactCrop__drag-elements"},C.default.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),C.default.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),C.default.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),C.default.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),C.default.createElement("div",{className:"ReactCrop__drag-handle ord-nw","data-ord":"nw"}),C.default.createElement("div",{className:"ReactCrop__drag-handle ord-n","data-ord":"n"}),C.default.createElement("div",{className:"ReactCrop__drag-handle ord-ne","data-ord":"ne"}),C.default.createElement("div",{className:"ReactCrop__drag-handle ord-e","data-ord":"e"}),C.default.createElement("div",{className:"ReactCrop__drag-handle ord-se","data-ord":"se"}),C.default.createElement("div",{className:"ReactCrop__drag-handle ord-s","data-ord":"s"}),C.default.createElement("div",{className:"ReactCrop__drag-handle ord-sw","data-ord":"sw"}),C.default.createElement("div",{className:"ReactCrop__drag-handle ord-w","data-ord":"w"})))}},{key:"makeNewCrop",value:function(){return y({},t.defaultCrop,this.props.crop)}},{key:"crossOverCheck",value:function(){var e=this.evData;(!e.xCrossOver&&-Math.abs(e.cropStartWidth)-e.xDiffPc>=0||e.xCrossOver&&-Math.abs(e.cropStartWidth)-e.xDiffPc<=0)&&(e.xCrossOver=!e.xCrossOver),(!e.yCrossOver&&-Math.abs(e.cropStartHeight)-e.yDiffPc>=0||e.yCrossOver&&-Math.abs(e.cropStartHeight)-e.yDiffPc<=0)&&(e.yCrossOver=!e.yCrossOver);var t=e.xCrossOver!==e.startXCrossOver,r=e.yCrossOver!==e.startYCrossOver;e.inversedXOrd=!!t&&p(e.ord),e.inversedYOrd=!!r&&p(e.ord)}},{key:"render",value:function(){var e=this,t=this.props,r=t.children,o=t.className,n=t.crossorigin,i=t.crop,s=t.disabled,c=t.imageAlt,d=t.onImageError,h=t.src,p=t.style,f=t.imageStyle,l=this.state.cropIsActive,g=void 0;u(i)&&(g=this.createCropSelection());var v=["ReactCrop"];return l&&v.push("ReactCrop--active"),i&&(i.aspect&&v.push("ReactCrop--fixed-aspect"),!l||i.width&&i.height||v.push("ReactCrop--crop-invisible")),s&&v.push("ReactCrop--disabled"),o&&v.push.apply(v,a(o.split(" "))),C.default.createElement("div",{ref:function(t){e.componentRef=t},className:v.join(" "),style:p,onTouchStart:this.onComponentMouseTouchDown,onMouseDown:this.onComponentMouseTouchDown,role:"presentation",tabIndex:"1",onKeyDown:this.onComponentKeyDown},C.default.createElement("img",{ref:function(t){e.imageRef=t},crossOrigin:n,className:"ReactCrop__image",style:f,src:h,onLoad:function(t){return e.onImageLoad(t.target)},onError:d,alt:c}),g,r)}}]),t}(w.PureComponent);R.xOrds=["e","w"],R.yOrds=["n","s"],R.xyOrds=["nw","ne","se","sw"],R.arrowKey={left:37,up:38,right:39,down:40},R.nudgeStep=.2,R.defaultCrop={x:0,y:0,width:0,height:0},R.propTypes={className:O.default.string,crossorigin:O.default.string,children:O.default.oneOfType([O.default.arrayOf(O.default.node),O.default.node]),crop:O.default.shape({aspect:O.default.number,x:O.default.number,y:O.default.number,width:O.default.number,height:O.default.number}),disabled:O.default.bool,imageAlt:O.default.string,imageStyle:O.default.shape({}),keepSelection:O.default.bool,minWidth:O.default.number,minHeight:O.default.number,maxWidth:O.default.number,maxHeight:O.default.number,onChange:O.default.func.isRequired,onImageError:O.default.func,onComplete:O.default.func,onImageLoaded:O.default.func,onDragStart:O.default.func,onDragEnd:O.default.func,src:O.default.string.isRequired,style:O.default.shape({})},R.defaultProps={className:void 0,crop:void 0,crossorigin:void 0,disabled:!1,imageAlt:"",maxWidth:100,maxHeight:100,minWidth:0,minHeight:0,keepSelection:!1,onComplete:function(){},onImageError:function(){},onImageLoaded:function(){},onDragStart:function(){},onDragEnd:function(){},children:void 0,style:void 0,imageStyle:void 0},t.default=R,t.Component=R,t.getPixelCrop=g,t.makeAspectCrop=f,t.containCrop=v},function(t,r){t.exports=e},function(e,t,r){e.exports=r(3)()},function(e,t,r){"use strict";function o(){}var a=r(4);e.exports=function(){function e(e,t,r,o,n,i){if(i!==a){var s=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}}function t(){return e}e.isRequired=e;var r={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return r.checkPropTypes=o,r.PropTypes=r,r}},function(e,t,r){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}])}); \ No newline at end of file diff --git a/lib/ReactCrop.js b/lib/ReactCrop.js index 47ec98e..dc5f5eb 100644 --- a/lib/ReactCrop.js +++ b/lib/ReactCrop.js @@ -803,7 +803,6 @@ ReactCrop.defaultProps = { }; export { - ReactCrop, ReactCrop as default, ReactCrop as Component, getPixelCrop,