Socket
Socket
Sign inDemoInstall

re-resizable

Package Overview
Dependencies
Maintainers
1
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

re-resizable - npm Package Compare versions

Comparing version 6.9.8 to 6.9.9

149

lib/index.es5.js

@@ -5,7 +5,4 @@ 'use strict';

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var React = require('react');
var reactDom = require('react-dom');
var memoize = _interopDefault(require('fast-memoize'));

@@ -52,63 +49,30 @@ /*! *****************************************************************************

var rowSizeBase = {
width: '100%',
height: '10px',
top: '0px',
left: '0px',
cursor: 'row-resize',
};
var colSizeBase = {
width: '10px',
height: '100%',
top: '0px',
left: '0px',
cursor: 'col-resize',
};
var edgeBase = {
width: '20px',
height: '20px',
position: 'absolute',
};
var styles = {
top: {
width: '100%',
height: '10px',
top: '-5px',
left: '0px',
cursor: 'row-resize',
},
right: {
width: '10px',
height: '100%',
top: '0px',
right: '-5px',
cursor: 'col-resize',
},
bottom: {
width: '100%',
height: '10px',
bottom: '-5px',
left: '0px',
cursor: 'row-resize',
},
left: {
width: '10px',
height: '100%',
top: '0px',
left: '-5px',
cursor: 'col-resize',
},
topRight: {
width: '20px',
height: '20px',
position: 'absolute',
right: '-10px',
top: '-10px',
cursor: 'ne-resize',
},
bottomRight: {
width: '20px',
height: '20px',
position: 'absolute',
right: '-10px',
bottom: '-10px',
cursor: 'se-resize',
},
bottomLeft: {
width: '20px',
height: '20px',
position: 'absolute',
left: '-10px',
bottom: '-10px',
cursor: 'sw-resize',
},
topLeft: {
width: '20px',
height: '20px',
position: 'absolute',
left: '-10px',
top: '-10px',
cursor: 'nw-resize',
},
top: __assign(__assign({}, rowSizeBase), { top: '-5px' }),
right: __assign(__assign({}, colSizeBase), { left: undefined, right: '-5px' }),
bottom: __assign(__assign({}, rowSizeBase), { top: undefined, bottom: '-5px' }),
left: __assign(__assign({}, colSizeBase), { left: '-5px' }),
topRight: __assign(__assign({}, edgeBase), { right: '-10px', top: '-10px', cursor: 'ne-resize' }),
bottomRight: __assign(__assign({}, edgeBase), { right: '-10px', bottom: '-10px', cursor: 'se-resize' }),
bottomLeft: __assign(__assign({}, edgeBase), { left: '-10px', bottom: '-10px', cursor: 'sw-resize' }),
topLeft: __assign(__assign({}, edgeBase), { left: '-10px', top: '-10px', cursor: 'nw-resize' }),
};

@@ -137,7 +101,7 @@ var Resizer = /** @class */ (function (_super) {

};
var clamp = memoize(function (n, min, max) { return Math.max(Math.min(n, max), min); });
var snap = memoize(function (n, size) { return Math.round(n / size) * size; });
var hasDirection = memoize(function (dir, target) {
var clamp = function (n, min, max) { return Math.max(Math.min(n, max), min); };
var snap = function (n, size) { return Math.round(n / size) * size; };
var hasDirection = function (dir, target) {
return new RegExp(dir, 'i').test(target);
});
};
// INFO: In case of window is a Proxy and does not porxy Events correctly, use isTouchEvent & isMouseEvent to distinguish event type instead of `instanceof`.

@@ -151,3 +115,3 @@ var isTouchEvent = function (event) {

};
var findClosestSnap = memoize(function (n, snapArray, snapGap) {
var findClosestSnap = function (n, snapArray, snapGap) {
if (snapGap === void 0) { snapGap = 0; }

@@ -157,7 +121,4 @@ var closestGapIndex = snapArray.reduce(function (prev, curr, index) { return (Math.abs(curr - n) < Math.abs(snapArray[prev] - n) ? index : prev); }, 0);

return snapGap === 0 || gap < snapGap ? snapArray[closestGapIndex] : n;
});
var endsWith = memoize(function (str, searchStr) {
return str.substr(str.length - searchStr.length, searchStr.length) === searchStr;
});
var getStringSize = memoize(function (n) {
};
var getStringSize = function (n) {
n = n.toString();

@@ -167,36 +128,36 @@ if (n === 'auto') {

}
if (endsWith(n, 'px')) {
if (n.endsWith('px')) {
return n;
}
if (endsWith(n, '%')) {
if (n.endsWith('%')) {
return n;
}
if (endsWith(n, 'vh')) {
if (n.endsWith('vh')) {
return n;
}
if (endsWith(n, 'vw')) {
if (n.endsWith('vw')) {
return n;
}
if (endsWith(n, 'vmax')) {
if (n.endsWith('vmax')) {
return n;
}
if (endsWith(n, 'vmin')) {
if (n.endsWith('vmin')) {
return n;
}
return n + "px";
});
};
var getPixelSize = function (size, parentSize, innerWidth, innerHeight) {
if (size && typeof size === 'string') {
if (endsWith(size, 'px')) {
if (size.endsWith('px')) {
return Number(size.replace('px', ''));
}
if (endsWith(size, '%')) {
if (size.endsWith('%')) {
var ratio = Number(size.replace('%', '')) / 100;
return parentSize * ratio;
}
if (endsWith(size, 'vw')) {
if (size.endsWith('vw')) {
var ratio = Number(size.replace('vw', '')) / 100;
return innerWidth * ratio;
}
if (endsWith(size, 'vh')) {
if (size.endsWith('vh')) {
var ratio = Number(size.replace('vh', '')) / 100;

@@ -208,3 +169,3 @@ return innerHeight * ratio;

};
var calculateNewMax = memoize(function (parentSize, innerWidth, innerHeight, maxWidth, maxHeight, minWidth, minHeight) {
var calculateNewMax = function (parentSize, innerWidth, innerHeight, maxWidth, maxHeight, minWidth, minHeight) {
maxWidth = getPixelSize(maxWidth, parentSize.width, innerWidth, innerHeight);

@@ -220,3 +181,3 @@ maxHeight = getPixelSize(maxHeight, parentSize.height, innerWidth, innerHeight);

};
});
};
var definedProps = [

@@ -405,4 +366,4 @@ 'as',

}
if (_this.propsSize && _this.propsSize[key] && endsWith(_this.propsSize[key].toString(), '%')) {
if (endsWith(_this.state[key].toString(), '%')) {
if (_this.propsSize && _this.propsSize[key] && _this.propsSize[key].toString().endsWith('%')) {
if (_this.state[key].toString().endsWith('%')) {
return _this.state[key].toString();

@@ -742,11 +703,11 @@ }

if (width && typeof width === 'string') {
if (endsWith(width, '%')) {
if (width.endsWith('%')) {
var percent = (newWidth / parentSize.width) * 100;
newWidth = percent + "%";
}
else if (endsWith(width, 'vw')) {
else if (width.endsWith('vw')) {
var vw = (newWidth / this.window.innerWidth) * 100;
newWidth = vw + "vw";
}
else if (endsWith(width, 'vh')) {
else if (width.endsWith('vh')) {
var vh = (newWidth / this.window.innerHeight) * 100;

@@ -757,11 +718,11 @@ newWidth = vh + "vh";

if (height && typeof height === 'string') {
if (endsWith(height, '%')) {
if (height.endsWith('%')) {
var percent = (newHeight / parentSize.height) * 100;
newHeight = percent + "%";
}
else if (endsWith(height, 'vw')) {
else if (height.endsWith('vw')) {
var vw = (newHeight / this.window.innerWidth) * 100;
newHeight = vw + "vw";
}
else if (endsWith(height, 'vh')) {
else if (height.endsWith('vh')) {
var vh = (newHeight / this.window.innerHeight) * 100;

@@ -768,0 +729,0 @@ newHeight = vh + "vh";

@@ -28,3 +28,2 @@ var __extends = (this && this.__extends) || (function () {

import { Resizer } from './resizer';
import memoize from 'fast-memoize';
var DEFAULT_SIZE = {

@@ -34,7 +33,7 @@ width: 'auto',

};
var clamp = memoize(function (n, min, max) { return Math.max(Math.min(n, max), min); });
var snap = memoize(function (n, size) { return Math.round(n / size) * size; });
var hasDirection = memoize(function (dir, target) {
var clamp = function (n, min, max) { return Math.max(Math.min(n, max), min); };
var snap = function (n, size) { return Math.round(n / size) * size; };
var hasDirection = function (dir, target) {
return new RegExp(dir, 'i').test(target);
});
};
// INFO: In case of window is a Proxy and does not porxy Events correctly, use isTouchEvent & isMouseEvent to distinguish event type instead of `instanceof`.

@@ -48,3 +47,3 @@ var isTouchEvent = function (event) {

};
var findClosestSnap = memoize(function (n, snapArray, snapGap) {
var findClosestSnap = function (n, snapArray, snapGap) {
if (snapGap === void 0) { snapGap = 0; }

@@ -54,7 +53,4 @@ var closestGapIndex = snapArray.reduce(function (prev, curr, index) { return (Math.abs(curr - n) < Math.abs(snapArray[prev] - n) ? index : prev); }, 0);

return snapGap === 0 || gap < snapGap ? snapArray[closestGapIndex] : n;
});
var endsWith = memoize(function (str, searchStr) {
return str.substr(str.length - searchStr.length, searchStr.length) === searchStr;
});
var getStringSize = memoize(function (n) {
};
var getStringSize = function (n) {
n = n.toString();

@@ -64,36 +60,36 @@ if (n === 'auto') {

}
if (endsWith(n, 'px')) {
if (n.endsWith('px')) {
return n;
}
if (endsWith(n, '%')) {
if (n.endsWith('%')) {
return n;
}
if (endsWith(n, 'vh')) {
if (n.endsWith('vh')) {
return n;
}
if (endsWith(n, 'vw')) {
if (n.endsWith('vw')) {
return n;
}
if (endsWith(n, 'vmax')) {
if (n.endsWith('vmax')) {
return n;
}
if (endsWith(n, 'vmin')) {
if (n.endsWith('vmin')) {
return n;
}
return n + "px";
});
};
var getPixelSize = function (size, parentSize, innerWidth, innerHeight) {
if (size && typeof size === 'string') {
if (endsWith(size, 'px')) {
if (size.endsWith('px')) {
return Number(size.replace('px', ''));
}
if (endsWith(size, '%')) {
if (size.endsWith('%')) {
var ratio = Number(size.replace('%', '')) / 100;
return parentSize * ratio;
}
if (endsWith(size, 'vw')) {
if (size.endsWith('vw')) {
var ratio = Number(size.replace('vw', '')) / 100;
return innerWidth * ratio;
}
if (endsWith(size, 'vh')) {
if (size.endsWith('vh')) {
var ratio = Number(size.replace('vh', '')) / 100;

@@ -105,3 +101,3 @@ return innerHeight * ratio;

};
var calculateNewMax = memoize(function (parentSize, innerWidth, innerHeight, maxWidth, maxHeight, minWidth, minHeight) {
var calculateNewMax = function (parentSize, innerWidth, innerHeight, maxWidth, maxHeight, minWidth, minHeight) {
maxWidth = getPixelSize(maxWidth, parentSize.width, innerWidth, innerHeight);

@@ -117,3 +113,3 @@ maxHeight = getPixelSize(maxHeight, parentSize.height, innerWidth, innerHeight);

};
});
};
var definedProps = [

@@ -302,4 +298,4 @@ 'as',

}
if (_this.propsSize && _this.propsSize[key] && endsWith(_this.propsSize[key].toString(), '%')) {
if (endsWith(_this.state[key].toString(), '%')) {
if (_this.propsSize && _this.propsSize[key] && _this.propsSize[key].toString().endsWith('%')) {
if (_this.state[key].toString().endsWith('%')) {
return _this.state[key].toString();

@@ -639,11 +635,11 @@ }

if (width && typeof width === 'string') {
if (endsWith(width, '%')) {
if (width.endsWith('%')) {
var percent = (newWidth / parentSize.width) * 100;
newWidth = percent + "%";
}
else if (endsWith(width, 'vw')) {
else if (width.endsWith('vw')) {
var vw = (newWidth / this.window.innerWidth) * 100;
newWidth = vw + "vw";
}
else if (endsWith(width, 'vh')) {
else if (width.endsWith('vh')) {
var vh = (newWidth / this.window.innerHeight) * 100;

@@ -654,11 +650,11 @@ newWidth = vh + "vh";

if (height && typeof height === 'string') {
if (endsWith(height, '%')) {
if (height.endsWith('%')) {
var percent = (newHeight / parentSize.height) * 100;
newHeight = percent + "%";
}
else if (endsWith(height, 'vw')) {
else if (height.endsWith('vw')) {
var vw = (newHeight / this.window.innerWidth) * 100;
newHeight = vw + "vw";
}
else if (endsWith(height, 'vh')) {
else if (height.endsWith('vh')) {
var vh = (newHeight / this.window.innerHeight) * 100;

@@ -665,0 +661,0 @@ newHeight = vh + "vh";

@@ -26,63 +26,30 @@ var __extends = (this && this.__extends) || (function () {

import * as React from 'react';
var rowSizeBase = {
width: '100%',
height: '10px',
top: '0px',
left: '0px',
cursor: 'row-resize',
};
var colSizeBase = {
width: '10px',
height: '100%',
top: '0px',
left: '0px',
cursor: 'col-resize',
};
var edgeBase = {
width: '20px',
height: '20px',
position: 'absolute',
};
var styles = {
top: {
width: '100%',
height: '10px',
top: '-5px',
left: '0px',
cursor: 'row-resize',
},
right: {
width: '10px',
height: '100%',
top: '0px',
right: '-5px',
cursor: 'col-resize',
},
bottom: {
width: '100%',
height: '10px',
bottom: '-5px',
left: '0px',
cursor: 'row-resize',
},
left: {
width: '10px',
height: '100%',
top: '0px',
left: '-5px',
cursor: 'col-resize',
},
topRight: {
width: '20px',
height: '20px',
position: 'absolute',
right: '-10px',
top: '-10px',
cursor: 'ne-resize',
},
bottomRight: {
width: '20px',
height: '20px',
position: 'absolute',
right: '-10px',
bottom: '-10px',
cursor: 'se-resize',
},
bottomLeft: {
width: '20px',
height: '20px',
position: 'absolute',
left: '-10px',
bottom: '-10px',
cursor: 'sw-resize',
},
topLeft: {
width: '20px',
height: '20px',
position: 'absolute',
left: '-10px',
top: '-10px',
cursor: 'nw-resize',
},
top: __assign(__assign({}, rowSizeBase), { top: '-5px' }),
right: __assign(__assign({}, colSizeBase), { left: undefined, right: '-5px' }),
bottom: __assign(__assign({}, rowSizeBase), { top: undefined, bottom: '-5px' }),
left: __assign(__assign({}, colSizeBase), { left: '-5px' }),
topRight: __assign(__assign({}, edgeBase), { right: '-10px', top: '-10px', cursor: 'ne-resize' }),
bottomRight: __assign(__assign({}, edgeBase), { right: '-10px', bottom: '-10px', cursor: 'se-resize' }),
bottomLeft: __assign(__assign({}, edgeBase), { left: '-10px', bottom: '-10px', cursor: 'sw-resize' }),
topLeft: __assign(__assign({}, edgeBase), { left: '-10px', top: '-10px', cursor: 'nw-resize' }),
};

@@ -89,0 +56,0 @@ var Resizer = /** @class */ (function (_super) {

{
"name": "re-resizable",
"version": "6.9.8",
"version": "6.9.9",
"description": "Resizable component for React.",

@@ -104,5 +104,3 @@ "title": "re-resizable",

},
"dependencies": {
"fast-memoize": "^2.5.1"
},
"dependencies": {},
"peerDependencies": {

@@ -109,0 +107,0 @@ "react": "^16.13.1 || ^17.0.0 || ^18.0.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc