From 4384f29b09a90894085d74fc9107745fd47e77f1 Mon Sep 17 00:00:00 2001 From: "dominic.tobias" Date: Mon, 29 Apr 2019 18:04:36 +0100 Subject: [PATCH] Fix dimension clamping in makeAspectCrop #256 --- dist/ReactCrop.js | 383 ++++-------------------------------------- dist/ReactCrop.min.js | 2 +- package-lock.json | 29 +--- package.json | 2 +- 4 files changed, 37 insertions(+), 379 deletions(-) diff --git a/dist/ReactCrop.js b/dist/ReactCrop.js index 46b0414..1ea2a76 100644 --- a/dist/ReactCrop.js +++ b/dist/ReactCrop.js @@ -7,7 +7,7 @@ exports["ReactCrop"] = factory(require("react")); else root["ReactCrop"] = factory(root["React"]); -})(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE_4__) { +})(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE_3__) { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; @@ -70,7 +70,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 3); +/******/ return __webpack_require__(__webpack_require__.s = 2); /******/ }) /************************************************************************/ /******/ ([ @@ -286,21 +286,6 @@ module.exports = ReactPropTypesSecret; /* 2 */ /***/ (function(module, exports, __webpack_require__) { -"use strict"; -/* WEBPACK VAR INJECTION */(function(process) { - -if (process.env.NODE_ENV === 'production') { - module.exports = __webpack_require__(6); -} else { - module.exports = __webpack_require__(7); -} - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) - -/***/ }), -/* 3 */ -/***/ (function(module, exports, __webpack_require__) { - "use strict"; @@ -316,11 +301,11 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); /* globals document, window */ -var _react = __webpack_require__(4); +var _react = __webpack_require__(3); var _react2 = _interopRequireDefault(_react); -var _propTypes = __webpack_require__(5); +var _propTypes = __webpack_require__(4); var _propTypes2 = _interopRequireDefault(_propTypes); @@ -1199,13 +1184,13 @@ exports.makeAspectCrop = makeAspectCrop; exports.containCrop = containCrop; /***/ }), -/* 4 */ +/* 3 */ /***/ (function(module, exports) { -module.exports = __WEBPACK_EXTERNAL_MODULE_4__; +module.exports = __WEBPACK_EXTERNAL_MODULE_3__; /***/ }), -/* 5 */ +/* 4 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {/** @@ -1216,279 +1201,31 @@ module.exports = __WEBPACK_EXTERNAL_MODULE_4__; */ if (process.env.NODE_ENV !== 'production') { - var ReactIs = __webpack_require__(2); + var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' && + Symbol.for && + Symbol.for('react.element')) || + 0xeac7; + + var isValidElement = function(object) { + return typeof object === 'object' && + object !== null && + object.$$typeof === REACT_ELEMENT_TYPE; + }; // By explicitly using `prop-types` you are opting into new development behavior. // http://fb.me/prop-types-in-prod var throwOnDirectAccess = true; - module.exports = __webpack_require__(8)(ReactIs.isElement, throwOnDirectAccess); + module.exports = __webpack_require__(5)(isValidElement, throwOnDirectAccess); } else { // By explicitly using `prop-types` you are opting into new production behavior. // http://fb.me/prop-types-in-prod - module.exports = __webpack_require__(11)(); -} - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) - -/***/ }), -/* 6 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; -/** @license React v16.8.6 - * react-is.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -Object.defineProperty(exports,"__esModule",{value:!0}); -var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b?Symbol.for("react.memo"): -60115,r=b?Symbol.for("react.lazy"):60116;function t(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case h:return a;default:return u}}case r:case q:case d:return u}}}function v(a){return t(a)===m}exports.typeOf=t;exports.AsyncMode=l;exports.ConcurrentMode=m;exports.ContextConsumer=k;exports.ContextProvider=h;exports.Element=c;exports.ForwardRef=n; -exports.Fragment=e;exports.Lazy=r;exports.Memo=q;exports.Portal=d;exports.Profiler=g;exports.StrictMode=f;exports.Suspense=p;exports.isValidElementType=function(a){return"string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||"object"===typeof a&&null!==a&&(a.$$typeof===r||a.$$typeof===q||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n)};exports.isAsyncMode=function(a){return v(a)||t(a)===l};exports.isConcurrentMode=v;exports.isContextConsumer=function(a){return t(a)===k}; -exports.isContextProvider=function(a){return t(a)===h};exports.isElement=function(a){return"object"===typeof a&&null!==a&&a.$$typeof===c};exports.isForwardRef=function(a){return t(a)===n};exports.isFragment=function(a){return t(a)===e};exports.isLazy=function(a){return t(a)===r};exports.isMemo=function(a){return t(a)===q};exports.isPortal=function(a){return t(a)===d};exports.isProfiler=function(a){return t(a)===g};exports.isStrictMode=function(a){return t(a)===f}; -exports.isSuspense=function(a){return t(a)===p}; - - -/***/ }), -/* 7 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; -/* WEBPACK VAR INJECTION */(function(process) {/** @license React v16.8.6 - * react-is.development.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - - - - - -if (process.env.NODE_ENV !== "production") { - (function() { -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -// The Symbol used to tag the ReactElement-like types. If there is no native Symbol -// nor polyfill, then a plain number is used for performance. -var hasSymbol = typeof Symbol === 'function' && Symbol.for; - -var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7; -var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca; -var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb; -var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc; -var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2; -var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd; -var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; -var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf; -var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf; -var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0; -var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1; -var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3; -var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4; - -function isValidElementType(type) { - return typeof type === 'string' || typeof type === 'function' || - // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill. - type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE); -} - -/** - * Forked from fbjs/warning: - * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js - * - * Only change is we use console.warn instead of console.error, - * and do nothing when 'console' is not supported. - * This really simplifies the code. - * --- - * Similar to invariant but only logs a warning if the condition is not met. - * This can be used to log issues in development environments in critical - * paths. Removing the logging code for production environments will keep the - * same logic and follow the same code paths. - */ - -var lowPriorityWarning = function () {}; - -{ - var printWarning = function (format) { - for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; - } - - var argIndex = 0; - var message = 'Warning: ' + format.replace(/%s/g, function () { - return args[argIndex++]; - }); - if (typeof console !== 'undefined') { - console.warn(message); - } - try { - // --- Welcome to debugging React --- - // This error was thrown as a convenience so that you can use this stack - // to find the callsite that caused this warning to fire. - throw new Error(message); - } catch (x) {} - }; - - lowPriorityWarning = function (condition, format) { - if (format === undefined) { - throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument'); - } - if (!condition) { - for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { - args[_key2 - 2] = arguments[_key2]; - } - - printWarning.apply(undefined, [format].concat(args)); - } - }; -} - -var lowPriorityWarning$1 = lowPriorityWarning; - -function typeOf(object) { - if (typeof object === 'object' && object !== null) { - var $$typeof = object.$$typeof; - switch ($$typeof) { - case REACT_ELEMENT_TYPE: - var type = object.type; - - switch (type) { - case REACT_ASYNC_MODE_TYPE: - case REACT_CONCURRENT_MODE_TYPE: - case REACT_FRAGMENT_TYPE: - case REACT_PROFILER_TYPE: - case REACT_STRICT_MODE_TYPE: - case REACT_SUSPENSE_TYPE: - return type; - default: - var $$typeofType = type && type.$$typeof; - - switch ($$typeofType) { - case REACT_CONTEXT_TYPE: - case REACT_FORWARD_REF_TYPE: - case REACT_PROVIDER_TYPE: - return $$typeofType; - default: - return $$typeof; - } - } - case REACT_LAZY_TYPE: - case REACT_MEMO_TYPE: - case REACT_PORTAL_TYPE: - return $$typeof; - } - } - - return undefined; -} - -// AsyncMode is deprecated along with isAsyncMode -var AsyncMode = REACT_ASYNC_MODE_TYPE; -var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE; -var ContextConsumer = REACT_CONTEXT_TYPE; -var ContextProvider = REACT_PROVIDER_TYPE; -var Element = REACT_ELEMENT_TYPE; -var ForwardRef = REACT_FORWARD_REF_TYPE; -var Fragment = REACT_FRAGMENT_TYPE; -var Lazy = REACT_LAZY_TYPE; -var Memo = REACT_MEMO_TYPE; -var Portal = REACT_PORTAL_TYPE; -var Profiler = REACT_PROFILER_TYPE; -var StrictMode = REACT_STRICT_MODE_TYPE; -var Suspense = REACT_SUSPENSE_TYPE; - -var hasWarnedAboutDeprecatedIsAsyncMode = false; - -// AsyncMode should be deprecated -function isAsyncMode(object) { - { - if (!hasWarnedAboutDeprecatedIsAsyncMode) { - hasWarnedAboutDeprecatedIsAsyncMode = true; - lowPriorityWarning$1(false, 'The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.'); - } - } - return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE; -} -function isConcurrentMode(object) { - return typeOf(object) === REACT_CONCURRENT_MODE_TYPE; -} -function isContextConsumer(object) { - return typeOf(object) === REACT_CONTEXT_TYPE; -} -function isContextProvider(object) { - return typeOf(object) === REACT_PROVIDER_TYPE; -} -function isElement(object) { - return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; -} -function isForwardRef(object) { - return typeOf(object) === REACT_FORWARD_REF_TYPE; -} -function isFragment(object) { - return typeOf(object) === REACT_FRAGMENT_TYPE; -} -function isLazy(object) { - return typeOf(object) === REACT_LAZY_TYPE; -} -function isMemo(object) { - return typeOf(object) === REACT_MEMO_TYPE; -} -function isPortal(object) { - return typeOf(object) === REACT_PORTAL_TYPE; -} -function isProfiler(object) { - return typeOf(object) === REACT_PROFILER_TYPE; -} -function isStrictMode(object) { - return typeOf(object) === REACT_STRICT_MODE_TYPE; -} -function isSuspense(object) { - return typeOf(object) === REACT_SUSPENSE_TYPE; -} - -exports.typeOf = typeOf; -exports.AsyncMode = AsyncMode; -exports.ConcurrentMode = ConcurrentMode; -exports.ContextConsumer = ContextConsumer; -exports.ContextProvider = ContextProvider; -exports.Element = Element; -exports.ForwardRef = ForwardRef; -exports.Fragment = Fragment; -exports.Lazy = Lazy; -exports.Memo = Memo; -exports.Portal = Portal; -exports.Profiler = Profiler; -exports.StrictMode = StrictMode; -exports.Suspense = Suspense; -exports.isValidElementType = isValidElementType; -exports.isAsyncMode = isAsyncMode; -exports.isConcurrentMode = isConcurrentMode; -exports.isContextConsumer = isContextConsumer; -exports.isContextProvider = isContextProvider; -exports.isElement = isElement; -exports.isForwardRef = isForwardRef; -exports.isFragment = isFragment; -exports.isLazy = isLazy; -exports.isMemo = isMemo; -exports.isPortal = isPortal; -exports.isProfiler = isProfiler; -exports.isStrictMode = isStrictMode; -exports.isSuspense = isSuspense; - })(); + module.exports = __webpack_require__(8)(); } /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) /***/ }), -/* 8 */ +/* 5 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -1501,13 +1238,11 @@ exports.isSuspense = isSuspense; -var ReactIs = __webpack_require__(2); -var assign = __webpack_require__(9); +var assign = __webpack_require__(6); var ReactPropTypesSecret = __webpack_require__(1); -var checkPropTypes = __webpack_require__(10); +var checkPropTypes = __webpack_require__(7); -var has = Function.call.bind(Object.prototype.hasOwnProperty); var printWarning = function() {}; if (process.env.NODE_ENV !== 'production') { @@ -1618,7 +1353,6 @@ module.exports = function(isValidElement, throwOnDirectAccess) { any: createAnyTypeChecker(), arrayOf: createArrayOfTypeChecker, element: createElementTypeChecker(), - elementType: createElementTypeTypeChecker(), instanceOf: createInstanceTypeChecker, node: createNodeChecker(), objectOf: createObjectOfTypeChecker, @@ -1772,18 +1506,6 @@ module.exports = function(isValidElement, throwOnDirectAccess) { return createChainableTypeChecker(validate); } - function createElementTypeTypeChecker() { - function validate(props, propName, componentName, location, propFullName) { - var propValue = props[propName]; - if (!ReactIs.isValidElementType(propValue)) { - var propType = getPropType(propValue); - return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.')); - } - return null; - } - return createChainableTypeChecker(validate); - } - function createInstanceTypeChecker(expectedClass) { function validate(props, propName, componentName, location, propFullName) { if (!(props[propName] instanceof expectedClass)) { @@ -1798,16 +1520,7 @@ module.exports = function(isValidElement, throwOnDirectAccess) { function createEnumTypeChecker(expectedValues) { if (!Array.isArray(expectedValues)) { - if (process.env.NODE_ENV !== 'production') { - if (arguments.length > 1) { - printWarning( - 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' + - 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).' - ); - } else { - printWarning('Invalid argument supplied to oneOf, expected an array.'); - } - } + process.env.NODE_ENV !== 'production' ? printWarning('Invalid argument supplied to oneOf, expected an instance of array.') : void 0; return emptyFunctionThatReturnsNull; } @@ -1819,14 +1532,8 @@ module.exports = function(isValidElement, throwOnDirectAccess) { } } - var valuesString = JSON.stringify(expectedValues, function replacer(key, value) { - var type = getPreciseType(value); - if (type === 'symbol') { - return String(value); - } - return value; - }); - return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.')); + var valuesString = JSON.stringify(expectedValues); + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.')); } return createChainableTypeChecker(validate); } @@ -1842,7 +1549,7 @@ module.exports = function(isValidElement, throwOnDirectAccess) { return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.')); } for (var key in propValue) { - if (has(propValue, key)) { + if (propValue.hasOwnProperty(key)) { var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); if (error instanceof Error) { return error; @@ -1999,11 +1706,6 @@ module.exports = function(isValidElement, throwOnDirectAccess) { return true; } - // falsy value can't be a Symbol - if (!propValue) { - return false; - } - // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol' if (propValue['@@toStringTag'] === 'Symbol') { return true; @@ -2078,7 +1780,6 @@ module.exports = function(isValidElement, throwOnDirectAccess) { } ReactPropTypes.checkPropTypes = checkPropTypes; - ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache; ReactPropTypes.PropTypes = ReactPropTypes; return ReactPropTypes; @@ -2087,7 +1788,7 @@ module.exports = function(isValidElement, throwOnDirectAccess) { /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) /***/ }), -/* 9 */ +/* 6 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -2184,7 +1885,7 @@ module.exports = shouldUseNative() ? Object.assign : function (target, source) { /***/ }), -/* 10 */ +/* 7 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -2202,7 +1903,6 @@ var printWarning = function() {}; if (process.env.NODE_ENV !== 'production') { var ReactPropTypesSecret = __webpack_require__(1); var loggedTypeFailures = {}; - var has = Function.call.bind(Object.prototype.hasOwnProperty); printWarning = function(text) { var message = 'Warning: ' + text; @@ -2232,7 +1932,7 @@ if (process.env.NODE_ENV !== 'production') { function checkPropTypes(typeSpecs, values, location, componentName, getStack) { if (process.env.NODE_ENV !== 'production') { for (var typeSpecName in typeSpecs) { - if (has(typeSpecs, typeSpecName)) { + if (typeSpecs.hasOwnProperty(typeSpecName)) { var error; // Prop type validation may throw. In case they do, we don't want to // fail the render phase where it didn't fail before. So we log it. @@ -2260,7 +1960,8 @@ function checkPropTypes(typeSpecs, values, location, componentName, getStack) { 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).' - ); + ) + } if (error instanceof Error && !(error.message in loggedTypeFailures)) { // Only monitor this failure once because there tends to be a lot of the @@ -2278,23 +1979,12 @@ function checkPropTypes(typeSpecs, values, location, componentName, getStack) { } } -/** - * Resets warning cache when testing. - * - * @private - */ -checkPropTypes.resetWarningCache = function() { - if (process.env.NODE_ENV !== 'production') { - loggedTypeFailures = {}; - } -} - module.exports = checkPropTypes; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) /***/ }), -/* 11 */ +/* 8 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -2310,8 +2000,6 @@ module.exports = checkPropTypes; var ReactPropTypesSecret = __webpack_require__(1); function emptyFunction() {} -function emptyFunctionWithReset() {} -emptyFunctionWithReset.resetWarningCache = emptyFunction; module.exports = function() { function shim(props, propName, componentName, location, propFullName, secret) { @@ -2345,19 +2033,16 @@ module.exports = function() { any: shim, arrayOf: getShim, element: shim, - elementType: shim, instanceOf: getShim, node: shim, objectOf: getShim, oneOf: getShim, oneOfType: getShim, shape: getShim, - exact: getShim, - - checkPropTypes: emptyFunctionWithReset, - resetWarningCache: emptyFunction + exact: getShim }; + ReactPropTypes.checkPropTypes = emptyFunction; ReactPropTypes.PropTypes = ReactPropTypes; return ReactPropTypes; diff --git a/dist/ReactCrop.min.js b/dist/ReactCrop.min.js index 16bb394..d1e18c3 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 n=r[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,t),n.l=!0,n.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 n(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);tt.height&&(r.height=t.height-r.y,r.width=r.height*e.aspect),r.x+r.width>t.width&&(r.width=t.width-r.x,r.height=r.width/e.aspect),r}function f(e,t){return!!(!e.width&&e.height||e.width&&!e.height)||(e.width/e.aspect!==e.height||e.height*e.aspect!==e.width||e.y+e.height>t.height||e.x+e.width>t.width)}function l(e,t){return e&&e.aspect&&f(e,t)?p(e,t):e}function v(e,t,r){var o=m({},t);t.aspect&&e.x>t.x&&t.height+t.y>=r.height&&(o.x=e.x);var n=!1;o.x+o.width>r.width?(o.width=t.width+(r.width-(t.x+t.width)),o.x=t.x+(r.width-(t.x+o.width)),n=!0):o.x<0&&(o.width=t.x+t.width,o.x=0,n=!0),n&&t.aspect&&(o.height=o.width/t.aspect,e.y>o.y&&(o.y=t.y+(t.height-o.height)));var a=!1;return o.y+o.height>r.height?(o.height=t.height+(r.height-(t.y+t.height)),o.y=t.y+(r.height-(t.y+o.height)),a=!0):o.y<0&&(o.height=t.y+t.height,o.y=0,a=!0),a&&t.aspect&&(o.width=o.height*t.aspect,o.x-1?(e.x=u.x,e.y=u.y,e.width=u.width,e.height=u.height):t.xOrds.indexOf(s)>-1?(e.x=u.x,e.width=u.width):t.yOrds.indexOf(s)>-1&&(e.y=u.y,e.height=u.height),r.lastYCrossover=r.yCrossOver,this.crossOverCheck(),a&&e.width=0||e.xCrossOver&&-Math.abs(e.cropStartWidth)-e.xDiff<=0)&&(e.xCrossOver=!e.xCrossOver),(!e.yCrossOver&&-Math.abs(e.cropStartHeight)-e.yDiff>=0||e.yCrossOver&&-Math.abs(e.cropStartHeight)-e.yDiff<=0)&&(e.yCrossOver=!e.yCrossOver);var t=e.xCrossOver!==e.startXCrossOver,r=e.yCrossOver!==e.startYCrossOver;e.inversedXOrd=!!t&&u(e.ord),e.inversedYOrd=!!r&&u(e.ord)}},{key:"render",value:function(){var e=this,t=this.props,r=t.children,o=t.className,a=t.crossorigin,i=t.crop,s=t.disabled,c=t.locked,d=t.imageAlt,u=t.onImageError,p=t.src,f=t.style,l=t.imageStyle,v=this.state.cropIsActive,g=void 0;h(i)&&(g=this.createCropSelection());var m=["ReactCrop"];return v&&m.push("ReactCrop--active"),i&&(i.aspect&&m.push("ReactCrop--fixed-aspect"),!v||i.width&&i.height||m.push("ReactCrop--crop-invisible")),s&&m.push("ReactCrop--disabled"),c&&m.push("ReactCrop--locked"),o&&m.push.apply(m,n(o.split(" "))),C.default.createElement("div",{ref:function(t){e.componentRef=t},className:m.join(" "),style:f,onTouchStart:this.onComponentMouseTouchDown,onMouseDown:this.onComponentMouseTouchDown,role:"presentation",tabIndex:1,onKeyDown:this.onComponentKeyDown},C.default.createElement("img",{ref:function(t){e.imageRef=t},crossOrigin:a,className:"ReactCrop__image",style:l,src:p,onLoad:function(t){return e.onImageLoad(t.target)},onError:u,alt:d}),r,g)}}]),t}(w.PureComponent);S.xOrds=["e","w"],S.yOrds=["n","s"],S.xyOrds=["nw","ne","se","sw"],S.arrowKey={left:37,up:38,right:39,down:40},S.nudgeStep=.2,S.defaultCrop={x:0,y:0,width:0,height:0},S.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,locked: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({}),renderSelectionAddon:O.default.func},S.defaultProps={className:void 0,crop:void 0,crossorigin:void 0,disabled:!1,locked:!1,imageAlt:"",maxWidth:void 0,maxHeight:void 0,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,renderSelectionAddon:void 0},t.default=S,t.Component=S,t.makeAspectCrop=p,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(){}function n(){}var a=r(4);n.resetWarningCache=o,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,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:n,resetWarningCache:o};return 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 n=r[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,t),n.l=!0,n.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 n(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);tt.height&&(r.height=t.height-r.y,r.width=r.height*e.aspect),r.x+r.width>t.width&&(r.width=t.width-r.x,r.height=r.width/e.aspect),r}function f(e,t){return!!(!e.width&&e.height||e.width&&!e.height)||(e.width/e.aspect!==e.height||e.height*e.aspect!==e.width||e.y+e.height>t.height||e.x+e.width>t.width)}function l(e,t){return e&&e.aspect&&f(e,t)?p(e,t):e}function v(e,t,r){var o=m({},t);t.aspect&&e.x>t.x&&t.height+t.y>=r.height&&(o.x=e.x);var n=!1;o.x+o.width>r.width?(o.width=t.width+(r.width-(t.x+t.width)),o.x=t.x+(r.width-(t.x+o.width)),n=!0):o.x<0&&(o.width=t.x+t.width,o.x=0,n=!0),n&&t.aspect&&(o.height=o.width/t.aspect,e.y>o.y&&(o.y=t.y+(t.height-o.height)));var a=!1;return o.y+o.height>r.height?(o.height=t.height+(r.height-(t.y+t.height)),o.y=t.y+(r.height-(t.y+o.height)),a=!0):o.y<0&&(o.height=t.y+t.height,o.y=0,a=!0),a&&t.aspect&&(o.width=o.height*t.aspect,o.x-1?(e.x=u.x,e.y=u.y,e.width=u.width,e.height=u.height):t.xOrds.indexOf(s)>-1?(e.x=u.x,e.width=u.width):t.yOrds.indexOf(s)>-1&&(e.y=u.y,e.height=u.height),r.lastYCrossover=r.yCrossOver,this.crossOverCheck(),a&&e.width=0||e.xCrossOver&&-Math.abs(e.cropStartWidth)-e.xDiff<=0)&&(e.xCrossOver=!e.xCrossOver),(!e.yCrossOver&&-Math.abs(e.cropStartHeight)-e.yDiff>=0||e.yCrossOver&&-Math.abs(e.cropStartHeight)-e.yDiff<=0)&&(e.yCrossOver=!e.yCrossOver);var t=e.xCrossOver!==e.startXCrossOver,r=e.yCrossOver!==e.startYCrossOver;e.inversedXOrd=!!t&&u(e.ord),e.inversedYOrd=!!r&&u(e.ord)}},{key:"render",value:function(){var e=this,t=this.props,r=t.children,o=t.className,a=t.crossorigin,i=t.crop,s=t.disabled,c=t.locked,d=t.imageAlt,u=t.onImageError,p=t.src,f=t.style,l=t.imageStyle,v=this.state.cropIsActive,g=void 0;h(i)&&(g=this.createCropSelection());var m=["ReactCrop"];return v&&m.push("ReactCrop--active"),i&&(i.aspect&&m.push("ReactCrop--fixed-aspect"),!v||i.width&&i.height||m.push("ReactCrop--crop-invisible")),s&&m.push("ReactCrop--disabled"),c&&m.push("ReactCrop--locked"),o&&m.push.apply(m,n(o.split(" "))),C.default.createElement("div",{ref:function(t){e.componentRef=t},className:m.join(" "),style:f,onTouchStart:this.onComponentMouseTouchDown,onMouseDown:this.onComponentMouseTouchDown,role:"presentation",tabIndex:1,onKeyDown:this.onComponentKeyDown},C.default.createElement("img",{ref:function(t){e.imageRef=t},crossOrigin:a,className:"ReactCrop__image",style:l,src:p,onLoad:function(t){return e.onImageLoad(t.target)},onError:u,alt:d}),r,g)}}]),t}(w.PureComponent);S.xOrds=["e","w"],S.yOrds=["n","s"],S.xyOrds=["nw","ne","se","sw"],S.arrowKey={left:37,up:38,right:39,down:40},S.nudgeStep=.2,S.defaultCrop={x:0,y:0,width:0,height:0},S.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,locked: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({}),renderSelectionAddon:O.default.func},S.defaultProps={className:void 0,crop:void 0,crossorigin:void 0,disabled:!1,locked:!1,imageAlt:"",maxWidth:void 0,maxHeight:void 0,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,renderSelectionAddon:void 0},t.default=S,t.Component=S,t.makeAspectCrop=p,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 n=r(4);e.exports=function(){function e(e,t,r,o,a,i){if(i!==n){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/package-lock.json b/package-lock.json index 19b5332..e30b1fc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "react-image-crop", - "version": "6.0.18", + "version": "7.0.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -199,28 +199,6 @@ } } }, - "@types/prop-types": { - "version": "15.7.0", - "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.0.tgz", - "integrity": "sha512-eItQyV43bj4rR3JPV0Skpl1SncRCdziTEK9/v8VwXmV6d/qOUO8/EuWeHBbCZcsfSHfzI5UyMJLCSXtxxznyZg==" - }, - "@types/react": { - "version": "16.8.7", - "resolved": "https://registry.npmjs.org/@types/react/-/react-16.8.7.tgz", - "integrity": "sha512-0xbkIyrDNKUn4IJVf8JaCn+ucao/cq6ZB8O6kSzhrJub1cVSqgTArtG0qCfdERWKMEIvUbrwLXeQMqWEsyr9dA==", - "requires": { - "@types/prop-types": "*", - "csstype": "^2.2.0" - } - }, - "@types/react-image-crop": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/@types/react-image-crop/-/react-image-crop-6.0.1.tgz", - "integrity": "sha512-WM23pJ8SfnqqPuVc0J804C6vP2BAw9CpISMgFHuxizkhdKL5jVJtJC1wp7vLVoSDSdNrbjjh2DAsAAqskiCIDA==", - "requires": { - "@types/react": "*" - } - }, "abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", @@ -2594,11 +2572,6 @@ "integrity": "sha1-yBSQPkViM3GgR3tAEJqq++6t27Q=", "dev": true }, - "csstype": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/csstype/-/csstype-2.6.3.tgz", - "integrity": "sha512-rINUZXOkcBmoHWEyu7JdHu5JMzkGRoMX4ov9830WNgxf5UYxcBUO0QTKAqeJ5EZfSdlrcJYkC8WwfVW7JYi4yg==" - }, "currently-unhandled": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz", diff --git a/package.json b/package.json index bb3c2b6..d4d0de4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-image-crop", - "version": "7.0.1", + "version": "7.0.2", "description": "A responsive image cropping tool for React", "repository": "https://github.com/DominicTobias/react-image-crop", "main": "dist/ReactCrop.js",