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.2 to 6.9.3

61

lib/index.js

@@ -0,1 +1,2 @@

"use strict";
var __extends = (this && this.__extends) || (function () {

@@ -25,5 +26,29 @@ var extendStatics = function (d, b) {

};
import * as React from 'react';
import { Resizer } from './resizer';
import memoize from 'fast-memoize';
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Resizable = void 0;
var React = __importStar(require("react"));
var resizer_1 = require("./resizer");
var fast_memoize_1 = __importDefault(require("fast-memoize"));
var DEFAULT_SIZE = {

@@ -33,5 +58,5 @@ 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 = fast_memoize_1.default(function (n, min, max) { return Math.max(Math.min(n, max), min); });
var snap = fast_memoize_1.default(function (n, size) { return Math.round(n / size) * size; });
var hasDirection = fast_memoize_1.default(function (dir, target) {
return new RegExp(dir, 'i').test(target);

@@ -47,3 +72,3 @@ });

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

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

});
var endsWith = memoize(function (str, searchStr) {
var endsWith = fast_memoize_1.default(function (str, searchStr) {
return str.substr(str.length - searchStr.length, searchStr.length) === searchStr;
});
var getStringSize = memoize(function (n) {
var getStringSize = fast_memoize_1.default(function (n) {
n = n.toString();

@@ -103,3 +128,3 @@ if (n === 'auto') {

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

@@ -611,2 +636,8 @@ maxHeight = getPixelSize(maxHeight, parentSize.height, innerWidth, innerHeight);

var boundaryMax = this.calculateNewMaxFromBoundary(maxWidth, maxHeight);
if (this.props.snap && this.props.snap.x) {
newWidth = findClosestSnap(newWidth, this.props.snap.x, this.props.snapGap);
}
if (this.props.snap && this.props.snap.y) {
newHeight = findClosestSnap(newHeight, this.props.snap.y, this.props.snapGap);
}
// Calculate new size from aspect ratio

@@ -623,8 +654,2 @@ var newSize = this.calculateNewSizeFromAspectRatio(newWidth, newHeight, { width: boundaryMax.maxWidth, height: boundaryMax.maxHeight }, { width: minWidth, height: minHeight });

}
if (this.props.snap && this.props.snap.x) {
newWidth = findClosestSnap(newWidth, this.props.snap.x, this.props.snapGap);
}
if (this.props.snap && this.props.snap.y) {
newHeight = findClosestSnap(newHeight, this.props.snap.y, this.props.snapGap);
}
var delta = {

@@ -709,3 +734,3 @@ width: newWidth - original.width,

if (enable[dir] !== false) {
return (React.createElement(Resizer, { key: dir, direction: dir, onResizeStart: _this.onResizeStart, replaceStyles: handleStyles && handleStyles[dir], className: handleClasses && handleClasses[dir] }, handleComponent && handleComponent[dir] ? handleComponent[dir] : null));
return (React.createElement(resizer_1.Resizer, { key: dir, direction: dir, onResizeStart: _this.onResizeStart, replaceStyles: handleStyles && handleStyles[dir], className: handleClasses && handleClasses[dir] }, handleComponent && handleComponent[dir] ? handleComponent[dir] : null));
}

@@ -762,2 +787,2 @@ return null;

}(React.PureComponent));
export { Resizable };
exports.Resizable = Resizable;

@@ -0,1 +1,2 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -37,8 +38,12 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
import test from 'ava';
import React from 'react';
import ReactDOM from 'react-dom';
import sinon from 'sinon';
import TestUtils from 'react-dom/test-utils';
import { Resizable } from './';
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var ava_1 = __importDefault(require("ava"));
var react_1 = __importDefault(require("react"));
var react_dom_1 = __importDefault(require("react-dom"));
var sinon_1 = __importDefault(require("sinon"));
var test_utils_1 = __importDefault(require("react-dom/test-utils"));
var _1 = require("./");
var screenshot = require('avaron').screenshot;

@@ -57,21 +62,21 @@ var mouseMove = function (x, y) {

};
test.afterEach(function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.afterEach(function (t) { return __awaiter(void 0, void 0, void 0, function () {
var content;
return __generator(this, function (_a) {
ReactDOM.unmountComponentAtNode(document.body);
react_dom_1.default.unmountComponentAtNode(document.body);
content = document.querySelector('#content');
if (!content)
return [2 /*return*/];
ReactDOM.unmountComponentAtNode(content);
react_dom_1.default.unmountComponentAtNode(content);
return [2 /*return*/];
});
}); });
test.serial('should box width and height equal 100px', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('should box width and height equal 100px', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var resizable, divs;
return __generator(this, function (_a) {
resizable = TestUtils.renderIntoDocument(React.createElement(Resizable, { defaultSize: { width: 100, height: 100 } }));
resizable = test_utils_1.default.renderIntoDocument(react_1.default.createElement(_1.Resizable, { defaultSize: { width: 100, height: 100 } }));
if (!resizable || resizable instanceof Element) {
return [2 /*return*/, t.fail()];
}
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
t.is(divs.length, 10);

@@ -84,9 +89,9 @@ t.is(divs[0].style.width, '100px');

}); });
test.serial('should allow vh, vw relative units', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('should allow vh, vw relative units', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var resizable, divs;
return __generator(this, function (_a) {
resizable = TestUtils.renderIntoDocument(React.createElement(Resizable, { defaultSize: { width: '100vw', height: '100vh' } }));
resizable = test_utils_1.default.renderIntoDocument(react_1.default.createElement(_1.Resizable, { defaultSize: { width: '100vw', height: '100vh' } }));
if (!resizable || resizable instanceof Element)
return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
t.is(divs.length, 10);

@@ -99,9 +104,9 @@ t.is(divs[0].style.width, '100vw');

}); });
test.serial('should allow vmax, vmin relative units', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('should allow vmax, vmin relative units', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var resizable, divs;
return __generator(this, function (_a) {
resizable = TestUtils.renderIntoDocument(React.createElement(Resizable, { defaultSize: { width: '100vmax', height: '100vmin' } }));
resizable = test_utils_1.default.renderIntoDocument(react_1.default.createElement(_1.Resizable, { defaultSize: { width: '100vmax', height: '100vmin' } }));
if (!resizable || resizable instanceof Element)
return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
t.is(divs.length, 10);

@@ -114,10 +119,10 @@ t.is(divs[0].style.width, '100vmax');

}); });
test.serial('should box width and height equal auto when size omitted', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('should box width and height equal auto when size omitted', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var resizable, divs;
return __generator(this, function (_a) {
resizable = TestUtils.renderIntoDocument(React.createElement(Resizable, null));
resizable = test_utils_1.default.renderIntoDocument(react_1.default.createElement(_1.Resizable, null));
if (!resizable || resizable instanceof Element) {
return [2 /*return*/, t.fail()];
}
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
t.is(divs.length, 10);

@@ -130,10 +135,10 @@ t.is(divs[0].style.width, 'auto');

}); });
test.serial('should box width and height equal auto when set auto', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('should box width and height equal auto when set auto', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var resizable, divs;
return __generator(this, function (_a) {
resizable = TestUtils.renderIntoDocument(React.createElement(Resizable, { defaultSize: { width: 'auto', height: 'auto' } }));
resizable = test_utils_1.default.renderIntoDocument(react_1.default.createElement(_1.Resizable, { defaultSize: { width: 'auto', height: 'auto' } }));
if (!resizable || resizable instanceof Element) {
return [2 /*return*/, t.fail()];
}
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
t.is(divs.length, 10);

@@ -146,10 +151,10 @@ t.is(divs[0].style.width, 'auto');

}); });
test.serial('Should style is applied to box', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('Should style is applied to box', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var resizable, divs;
return __generator(this, function (_a) {
resizable = TestUtils.renderIntoDocument(React.createElement(Resizable, { style: { position: 'absolute' } }));
resizable = test_utils_1.default.renderIntoDocument(react_1.default.createElement(_1.Resizable, { style: { position: 'absolute' } }));
if (!resizable || resizable instanceof Element) {
return [2 /*return*/, t.fail()];
}
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
t.is(divs.length, 10);

@@ -160,10 +165,10 @@ t.is(divs[0].style.position, 'absolute');

}); });
test.serial('Should custom class name be applied to box', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('Should custom class name be applied to box', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var resizable, divs;
return __generator(this, function (_a) {
resizable = TestUtils.renderIntoDocument(React.createElement(Resizable, { className: 'custom-class-name' }));
resizable = test_utils_1.default.renderIntoDocument(react_1.default.createElement(_1.Resizable, { className: 'custom-class-name' }));
if (!resizable || resizable instanceof Element) {
return [2 /*return*/, t.fail()];
}
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
t.is(divs.length, 10);

@@ -174,10 +179,10 @@ t.is(divs[0].className, 'custom-class-name');

}); });
test.serial('Should use a custom wrapper element', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('Should use a custom wrapper element', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var resizable, headers;
return __generator(this, function (_a) {
resizable = TestUtils.renderIntoDocument(React.createElement(Resizable, { as: "header" }));
resizable = test_utils_1.default.renderIntoDocument(react_1.default.createElement(_1.Resizable, { as: "header" }));
if (!resizable || resizable instanceof Element) {
return [2 /*return*/, t.fail()];
}
headers = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'header');
headers = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'header');
t.is(headers.length, 1);

@@ -187,11 +192,11 @@ return [2 /*return*/];

}); });
test.serial('Should custom class name be applied to resizer', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('Should custom class name be applied to resizer', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var resizable, divs, node;
return __generator(this, function (_a) {
resizable = TestUtils.renderIntoDocument(React.createElement(Resizable, { handleClasses: { right: 'right-handle-class' } }));
resizable = test_utils_1.default.renderIntoDocument(react_1.default.createElement(_1.Resizable, { handleClasses: { right: 'right-handle-class' } }));
if (!resizable || resizable instanceof Element) {
return [2 /*return*/, t.fail()];
}
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = ReactDOM.findDOMNode(divs[3]);
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = react_dom_1.default.findDOMNode(divs[3]);
if (!node || !(node instanceof HTMLDivElement))

@@ -203,11 +208,11 @@ return [2 /*return*/, t.fail()];

}); });
test.serial('Should create custom span that wraps resizable divs ', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('Should create custom span that wraps resizable divs ', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var resizable, divs, node;
return __generator(this, function (_a) {
resizable = TestUtils.renderIntoDocument(React.createElement(Resizable, { handleWrapperClass: "wrapper-class" }));
resizable = test_utils_1.default.renderIntoDocument(react_1.default.createElement(_1.Resizable, { handleWrapperClass: "wrapper-class" }));
if (!resizable || resizable instanceof Element) {
return [2 /*return*/, t.fail()];
}
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = ReactDOM.findDOMNode(divs[1]);
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = react_dom_1.default.findDOMNode(divs[1]);
t.is(node.getAttribute('class'), 'wrapper-class');

@@ -217,6 +222,6 @@ return [2 /*return*/];

}); });
test.serial('Should not render resizer when enable props all false', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('Should not render resizer when enable props all false', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var resizable, divs;
return __generator(this, function (_a) {
resizable = TestUtils.renderIntoDocument(React.createElement(Resizable, { enable: {
resizable = test_utils_1.default.renderIntoDocument(react_1.default.createElement(_1.Resizable, { enable: {
top: false,

@@ -234,3 +239,3 @@ right: false,

}
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
t.is(divs.length, 2);

@@ -240,6 +245,6 @@ return [2 /*return*/];

}); });
test.serial('Should render one resizer when one enable props set true', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('Should render one resizer when one enable props set true', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var resizable, divs;
return __generator(this, function (_a) {
resizable = TestUtils.renderIntoDocument(React.createElement(Resizable, { enable: {
resizable = test_utils_1.default.renderIntoDocument(react_1.default.createElement(_1.Resizable, { enable: {
top: false,

@@ -256,3 +261,3 @@ right: true,

return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
t.is(divs.length, 3);

@@ -262,6 +267,6 @@ return [2 /*return*/];

}); });
test.serial('Should render two resizer when two enable props set true', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('Should render two resizer when two enable props set true', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var resizable, divs;
return __generator(this, function (_a) {
resizable = TestUtils.renderIntoDocument(React.createElement(Resizable, { enable: {
resizable = test_utils_1.default.renderIntoDocument(react_1.default.createElement(_1.Resizable, { enable: {
top: true,

@@ -278,3 +283,3 @@ right: true,

return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
t.is(divs.length, 4);

@@ -284,6 +289,6 @@ return [2 /*return*/];

}); });
test.serial('Should render three resizer when three enable props set true', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('Should render three resizer when three enable props set true', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var resizable, divs;
return __generator(this, function (_a) {
resizable = TestUtils.renderIntoDocument(React.createElement(Resizable, { enable: {
resizable = test_utils_1.default.renderIntoDocument(react_1.default.createElement(_1.Resizable, { enable: {
top: true,

@@ -300,3 +305,3 @@ right: true,

return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
t.is(divs.length, 5);

@@ -306,7 +311,7 @@ return [2 /*return*/];

}); });
test.serial('Should only right is resizable and call onResizeStart when mousedown', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('Should only right is resizable and call onResizeStart when mousedown', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var onResizeStart, resizable, divs;
return __generator(this, function (_a) {
onResizeStart = sinon.spy();
resizable = TestUtils.renderIntoDocument(React.createElement(Resizable, { onResizeStart: onResizeStart, enable: {
onResizeStart = sinon_1.default.spy();
resizable = test_utils_1.default.renderIntoDocument(react_1.default.createElement(_1.Resizable, { onResizeStart: onResizeStart, enable: {
top: false,

@@ -323,5 +328,5 @@ right: true,

return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
t.is(divs.length, 3);
TestUtils.Simulate.mouseDown(ReactDOM.findDOMNode(divs[2]));
test_utils_1.default.Simulate.mouseDown(react_dom_1.default.findDOMNode(divs[2]));
t.is(onResizeStart.callCount, 1);

@@ -332,7 +337,7 @@ t.is(onResizeStart.getCall(0).args[1], 'right');

}); });
test.serial('Should only bottom is resizable and call onResizeStart when mousedown', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('Should only bottom is resizable and call onResizeStart when mousedown', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var onResizeStart, resizable, divs;
return __generator(this, function (_a) {
onResizeStart = sinon.spy();
resizable = TestUtils.renderIntoDocument(React.createElement(Resizable, { onResizeStart: onResizeStart, enable: {
onResizeStart = sinon_1.default.spy();
resizable = test_utils_1.default.renderIntoDocument(react_1.default.createElement(_1.Resizable, { onResizeStart: onResizeStart, enable: {
top: false,

@@ -349,5 +354,5 @@ right: false,

return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
t.is(divs.length, 3);
TestUtils.Simulate.mouseDown(ReactDOM.findDOMNode(divs[2]));
test_utils_1.default.Simulate.mouseDown(react_dom_1.default.findDOMNode(divs[2]));
t.is(onResizeStart.callCount, 1);

@@ -358,7 +363,7 @@ t.is(onResizeStart.getCall(0).args[1], 'bottom');

}); });
test.serial('Should only bottomRight is resizable and call onResizeStart when mousedown', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('Should only bottomRight is resizable and call onResizeStart when mousedown', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var onResizeStart, resizable, divs;
return __generator(this, function (_a) {
onResizeStart = sinon.spy();
resizable = TestUtils.renderIntoDocument(React.createElement(Resizable, { onResizeStart: onResizeStart, enable: {
onResizeStart = sinon_1.default.spy();
resizable = test_utils_1.default.renderIntoDocument(react_1.default.createElement(_1.Resizable, { onResizeStart: onResizeStart, enable: {
top: false,

@@ -375,5 +380,5 @@ right: false,

return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
t.is(divs.length, 3);
TestUtils.Simulate.mouseDown(ReactDOM.findDOMNode(divs[2]));
test_utils_1.default.Simulate.mouseDown(react_dom_1.default.findDOMNode(divs[2]));
t.is(onResizeStart.callCount, 1);

@@ -384,3 +389,3 @@ t.is(onResizeStart.getCall(0).args[1], 'bottomRight');

}); });
test.serial('Should not begin resize when onResizeStart returns false', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('Should not begin resize when onResizeStart returns false', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var onResizeStart, onResize, resizable, divs, previousState;

@@ -391,9 +396,9 @@ return __generator(this, function (_a) {

};
onResize = sinon.spy();
resizable = TestUtils.renderIntoDocument(React.createElement(Resizable, { onResizeStart: onResizeStart, onResize: onResize }));
onResize = sinon_1.default.spy();
resizable = test_utils_1.default.renderIntoDocument(react_1.default.createElement(_1.Resizable, { onResizeStart: onResizeStart, onResize: onResize }));
if (!resizable || resizable instanceof Element)
return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
previousState = resizable.state.isResizing;
TestUtils.Simulate.mouseDown(ReactDOM.findDOMNode(divs[2]));
test_utils_1.default.Simulate.mouseDown(react_dom_1.default.findDOMNode(divs[2]));
mouseMove(200, 220);

@@ -405,17 +410,17 @@ t.is(onResize.callCount, 0);

}); });
test.serial('should call onResize with expected args when resize direction right', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('should call onResize with expected args when resize direction right', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var onResize, onResizeStart, resizable, divs, node;
return __generator(this, function (_a) {
onResize = sinon.spy();
onResizeStart = sinon.spy();
resizable = ReactDOM.render(React.createElement(Resizable, { defaultSize: { width: 100, height: 100 }, onResize: onResize, onResizeStart: onResizeStart, style: { padding: '40px' } }), document.getElementById('content'));
onResize = sinon_1.default.spy();
onResizeStart = sinon_1.default.spy();
resizable = react_dom_1.default.render(react_1.default.createElement(_1.Resizable, { defaultSize: { width: 100, height: 100 }, onResize: onResize, onResizeStart: onResizeStart, style: { padding: '40px' } }), document.getElementById('content'));
if (!resizable || resizable instanceof Element)
return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = ReactDOM.findDOMNode(divs[3]);
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = react_dom_1.default.findDOMNode(divs[3]);
if (!node || !(node instanceof HTMLDivElement))
return [2 /*return*/, t.fail()];
TestUtils.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
test_utils_1.default.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
mouseMove(200, 220);
TestUtils.Simulate.mouseUp(node);
test_utils_1.default.Simulate.mouseUp(node);
t.is(onResize.callCount, 1);

@@ -430,17 +435,17 @@ t.true(onResize.getCall(0).args[0] instanceof Event);

}); });
test.serial('should call onResize with expected args when resize direction bottom', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('should call onResize with expected args when resize direction bottom', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var onResize, onResizeStart, resizable, divs, node;
return __generator(this, function (_a) {
onResize = sinon.spy();
onResizeStart = sinon.spy();
resizable = ReactDOM.render(React.createElement(Resizable, { defaultSize: { width: 100, height: 100 }, onResize: onResize, onResizeStart: onResizeStart, style: { padding: '40px' } }), document.getElementById('content'));
onResize = sinon_1.default.spy();
onResizeStart = sinon_1.default.spy();
resizable = react_dom_1.default.render(react_1.default.createElement(_1.Resizable, { defaultSize: { width: 100, height: 100 }, onResize: onResize, onResizeStart: onResizeStart, style: { padding: '40px' } }), document.getElementById('content'));
if (!resizable || resizable instanceof Element)
return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = ReactDOM.findDOMNode(divs[4]);
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = react_dom_1.default.findDOMNode(divs[4]);
if (!node || !(node instanceof HTMLDivElement))
return [2 /*return*/, t.fail()];
TestUtils.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
test_utils_1.default.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
mouseMove(200, 220);
TestUtils.Simulate.mouseUp(node);
test_utils_1.default.Simulate.mouseUp(node);
t.is(onResize.callCount, 1);

@@ -455,17 +460,17 @@ t.true(onResize.getCall(0).args[0] instanceof MouseEvent);

}); });
test.serial('should call onResize with expected args when resize direction bottomRight', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('should call onResize with expected args when resize direction bottomRight', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var onResize, onResizeStart, resizable, divs, node;
return __generator(this, function (_a) {
onResize = sinon.spy();
onResizeStart = sinon.spy();
resizable = ReactDOM.render(React.createElement(Resizable, { defaultSize: { width: 100, height: 100 }, onResize: onResize, onResizeStart: onResizeStart, style: { padding: '40px' } }), document.getElementById('content'));
onResize = sinon_1.default.spy();
onResizeStart = sinon_1.default.spy();
resizable = react_dom_1.default.render(react_1.default.createElement(_1.Resizable, { defaultSize: { width: 100, height: 100 }, onResize: onResize, onResizeStart: onResizeStart, style: { padding: '40px' } }), document.getElementById('content'));
if (!resizable || resizable instanceof Element)
return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = ReactDOM.findDOMNode(divs[7]);
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = react_dom_1.default.findDOMNode(divs[7]);
if (!node || !(node instanceof HTMLDivElement))
return [2 /*return*/, t.fail()];
TestUtils.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
test_utils_1.default.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
mouseMove(200, 220);
TestUtils.Simulate.mouseUp(node);
test_utils_1.default.Simulate.mouseUp(node);
t.is(onResize.callCount, 1);

@@ -480,16 +485,16 @@ t.true(onResize.getCall(0).args[0] instanceof MouseEvent);

}); });
test.serial('should call onResizeStop when resize stop direction right', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('should call onResizeStop when resize stop direction right', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var onResize, onResizeStart, onResizeStop, resizable, divs, node;
return __generator(this, function (_a) {
onResize = sinon.spy();
onResizeStart = sinon.spy();
onResizeStop = sinon.spy();
resizable = ReactDOM.render(React.createElement(Resizable, { defaultSize: { width: 100, height: 100 }, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop, style: { padding: '40px' } }), document.getElementById('content'));
onResize = sinon_1.default.spy();
onResizeStart = sinon_1.default.spy();
onResizeStop = sinon_1.default.spy();
resizable = react_dom_1.default.render(react_1.default.createElement(_1.Resizable, { defaultSize: { width: 100, height: 100 }, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop, style: { padding: '40px' } }), document.getElementById('content'));
if (!resizable || resizable instanceof Element)
return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = ReactDOM.findDOMNode(divs[3]);
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = react_dom_1.default.findDOMNode(divs[3]);
if (!node || !(node instanceof HTMLDivElement))
return [2 /*return*/, t.fail()];
TestUtils.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
test_utils_1.default.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
mouseMove(200, 220);

@@ -506,16 +511,16 @@ mouseUp(200, 220);

}); });
test.serial('should call onResizeStop when resize stop direction bottom', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('should call onResizeStop when resize stop direction bottom', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var onResize, onResizeStart, onResizeStop, resizable, divs, node;
return __generator(this, function (_a) {
onResize = sinon.spy();
onResizeStart = sinon.spy();
onResizeStop = sinon.spy();
resizable = ReactDOM.render(React.createElement(Resizable, { defaultSize: { width: 100, height: 100 }, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop, style: { padding: '40px' } }), document.getElementById('content'));
onResize = sinon_1.default.spy();
onResizeStart = sinon_1.default.spy();
onResizeStop = sinon_1.default.spy();
resizable = react_dom_1.default.render(react_1.default.createElement(_1.Resizable, { defaultSize: { width: 100, height: 100 }, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop, style: { padding: '40px' } }), document.getElementById('content'));
if (!resizable || resizable instanceof Element)
return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = ReactDOM.findDOMNode(divs[4]);
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = react_dom_1.default.findDOMNode(divs[4]);
if (!node || !(node instanceof HTMLDivElement))
return [2 /*return*/, t.fail()];
TestUtils.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
test_utils_1.default.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
mouseMove(200, 220);

@@ -532,16 +537,16 @@ mouseUp(200, 220);

}); });
test.serial('should call onResizeStop when resize stop direction bottomRight', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('should call onResizeStop when resize stop direction bottomRight', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var onResize, onResizeStart, onResizeStop, resizable, divs, node;
return __generator(this, function (_a) {
onResize = sinon.spy();
onResizeStart = sinon.spy();
onResizeStop = sinon.spy();
resizable = ReactDOM.render(React.createElement(Resizable, { defaultSize: { width: 100, height: 100 }, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop, style: { padding: '40px' } }), document.getElementById('content'));
onResize = sinon_1.default.spy();
onResizeStart = sinon_1.default.spy();
onResizeStop = sinon_1.default.spy();
resizable = react_dom_1.default.render(react_1.default.createElement(_1.Resizable, { defaultSize: { width: 100, height: 100 }, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop, style: { padding: '40px' } }), document.getElementById('content'));
if (!resizable || resizable instanceof Element)
return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = ReactDOM.findDOMNode(divs[7]);
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = react_dom_1.default.findDOMNode(divs[7]);
if (!node || !(node instanceof HTMLDivElement))
return [2 /*return*/, t.fail()];
TestUtils.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
test_utils_1.default.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
mouseMove(200, 220);

@@ -557,6 +562,6 @@ mouseUp(200, 220);

}); });
test.serial('should component size updated when updateSize method called', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('should component size updated when updateSize method called', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var resizable;
return __generator(this, function (_a) {
resizable = ReactDOM.render(React.createElement(Resizable, { defaultSize: { width: 100, height: 100 } }), document.getElementById('content'));
resizable = react_dom_1.default.render(react_1.default.createElement(_1.Resizable, { defaultSize: { width: 100, height: 100 } }), document.getElementById('content'));
resizable.updateSize({ width: 200, height: 300 });

@@ -568,16 +573,16 @@ t.is(resizable.state.width, 200);

}); });
test.serial('should snapped by grid value', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('should snapped by grid value', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var onResize, onResizeStart, onResizeStop, resizable, divs, node;
return __generator(this, function (_a) {
onResize = sinon.spy();
onResizeStart = sinon.spy();
onResizeStop = sinon.spy();
resizable = ReactDOM.render(React.createElement(Resizable, { defaultSize: { width: 100, height: 100 }, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop, grid: [10, 10] }), document.getElementById('content'));
onResize = sinon_1.default.spy();
onResizeStart = sinon_1.default.spy();
onResizeStop = sinon_1.default.spy();
resizable = react_dom_1.default.render(react_1.default.createElement(_1.Resizable, { defaultSize: { width: 100, height: 100 }, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop, grid: [10, 10] }), document.getElementById('content'));
if (!resizable || resizable instanceof Element)
return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = ReactDOM.findDOMNode(divs[7]);
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = react_dom_1.default.findDOMNode(divs[7]);
if (!node || !(node instanceof HTMLDivElement))
return [2 /*return*/, t.fail()];
TestUtils.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
test_utils_1.default.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
mouseMove(12, 12);

@@ -591,16 +596,16 @@ t.true(onResize.getCall(0).args[0] instanceof MouseEvent);

}); });
test.serial('should snapped by absolute snap value', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('should snapped by absolute snap value', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var onResize, onResizeStart, onResizeStop, resizable, divs, node;
return __generator(this, function (_a) {
onResize = sinon.spy();
onResizeStart = sinon.spy();
onResizeStop = sinon.spy();
resizable = ReactDOM.render(React.createElement(Resizable, { defaultSize: { width: 100, height: 100 }, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop, snap: { x: [20, 30], y: [100] } }), document.getElementById('content'));
onResize = sinon_1.default.spy();
onResizeStart = sinon_1.default.spy();
onResizeStop = sinon_1.default.spy();
resizable = react_dom_1.default.render(react_1.default.createElement(_1.Resizable, { defaultSize: { width: 100, height: 100 }, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop, snap: { x: [20, 30], y: [100] } }), document.getElementById('content'));
if (!resizable || resizable instanceof Element)
return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = ReactDOM.findDOMNode(divs[7]);
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = react_dom_1.default.findDOMNode(divs[7]);
if (!node || !(node instanceof HTMLDivElement))
return [2 /*return*/, t.fail()];
TestUtils.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
test_utils_1.default.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
mouseMove(12, 12);

@@ -614,16 +619,16 @@ t.true(onResize.getCall(0).args[0] instanceof MouseEvent);

}); });
test.serial('should only snap if the gap is small enough', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('should only snap if the gap is small enough', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var onResize, onResizeStart, onResizeStop, resizable, divs, node;
return __generator(this, function (_a) {
onResize = sinon.spy();
onResizeStart = sinon.spy();
onResizeStop = sinon.spy();
resizable = ReactDOM.render(React.createElement(Resizable, { defaultSize: { width: 40, height: 40 }, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop, grid: [40, 40], snapGap: 10 }), document.getElementById('content'));
onResize = sinon_1.default.spy();
onResizeStart = sinon_1.default.spy();
onResizeStop = sinon_1.default.spy();
resizable = react_dom_1.default.render(react_1.default.createElement(_1.Resizable, { defaultSize: { width: 40, height: 40 }, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop, grid: [40, 40], snapGap: 10 }), document.getElementById('content'));
if (!resizable || resizable instanceof Element)
return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = ReactDOM.findDOMNode(divs[7]);
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = react_dom_1.default.findDOMNode(divs[7]);
if (!node || !(node instanceof HTMLDivElement))
return [2 /*return*/, t.fail()];
TestUtils.Simulate.mouseDown(node, { clientX: 40, clientY: 40 });
test_utils_1.default.Simulate.mouseDown(node, { clientX: 40, clientY: 40 });
mouseMove(15, 15);

@@ -641,16 +646,16 @@ t.true(onResize.getCall(0).args[0] instanceof MouseEvent);

}); });
test.serial('should clamped by max width', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('should clamped by max width', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var onResize, onResizeStart, onResizeStop, resizable, divs, node;
return __generator(this, function (_a) {
onResize = sinon.spy();
onResizeStart = sinon.spy();
onResizeStop = sinon.spy();
resizable = ReactDOM.render(React.createElement(Resizable, { defaultSize: { width: 100, height: 100 }, maxWidth: 200, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop }), document.getElementById('content'));
onResize = sinon_1.default.spy();
onResizeStart = sinon_1.default.spy();
onResizeStop = sinon_1.default.spy();
resizable = react_dom_1.default.render(react_1.default.createElement(_1.Resizable, { defaultSize: { width: 100, height: 100 }, maxWidth: 200, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop }), document.getElementById('content'));
if (!resizable || resizable instanceof Element)
return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = ReactDOM.findDOMNode(divs[7]);
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = react_dom_1.default.findDOMNode(divs[7]);
if (!node || !(node instanceof HTMLDivElement))
return [2 /*return*/, t.fail()];
TestUtils.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
test_utils_1.default.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
mouseMove(200, 0);

@@ -663,16 +668,16 @@ t.true(onResize.getCall(0).args[0] instanceof MouseEvent);

}); });
test.serial('should clamped by min width', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('should clamped by min width', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var onResize, onResizeStart, onResizeStop, resizable, divs, node;
return __generator(this, function (_a) {
onResize = sinon.spy();
onResizeStart = sinon.spy();
onResizeStop = sinon.spy();
resizable = ReactDOM.render(React.createElement(Resizable, { defaultSize: { width: 100, height: 100 }, minWidth: 50, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop }), document.getElementById('content'));
onResize = sinon_1.default.spy();
onResizeStart = sinon_1.default.spy();
onResizeStop = sinon_1.default.spy();
resizable = react_dom_1.default.render(react_1.default.createElement(_1.Resizable, { defaultSize: { width: 100, height: 100 }, minWidth: 50, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop }), document.getElementById('content'));
if (!resizable || resizable instanceof Element)
return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = ReactDOM.findDOMNode(divs[7]);
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = react_dom_1.default.findDOMNode(divs[7]);
if (!node || !(node instanceof HTMLDivElement))
return [2 /*return*/, t.fail()];
TestUtils.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
test_utils_1.default.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
mouseMove(-100, 0);

@@ -685,16 +690,16 @@ t.true(onResize.getCall(0).args[0] instanceof MouseEvent);

}); });
test.serial('should allow 0 as minWidth', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('should allow 0 as minWidth', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var onResize, onResizeStart, onResizeStop, resizable, divs, node;
return __generator(this, function (_a) {
onResize = sinon.spy();
onResizeStart = sinon.spy();
onResizeStop = sinon.spy();
resizable = ReactDOM.render(React.createElement(Resizable, { defaultSize: { width: 100, height: 100 }, minWidth: 0, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop }), document.getElementById('content'));
onResize = sinon_1.default.spy();
onResizeStart = sinon_1.default.spy();
onResizeStop = sinon_1.default.spy();
resizable = react_dom_1.default.render(react_1.default.createElement(_1.Resizable, { defaultSize: { width: 100, height: 100 }, minWidth: 0, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop }), document.getElementById('content'));
if (!resizable || resizable instanceof Element)
return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = ReactDOM.findDOMNode(divs[7]);
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = react_dom_1.default.findDOMNode(divs[7]);
if (!node || !(node instanceof HTMLDivElement))
return [2 /*return*/, t.fail()];
TestUtils.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
test_utils_1.default.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
mouseMove(-100, 0);

@@ -707,16 +712,16 @@ t.true(onResize.getCall(0).args[0] instanceof MouseEvent);

}); });
test.serial('should clamped by max height', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('should clamped by max height', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var onResize, onResizeStart, onResizeStop, resizable, divs, node;
return __generator(this, function (_a) {
onResize = sinon.spy();
onResizeStart = sinon.spy();
onResizeStop = sinon.spy();
resizable = ReactDOM.render(React.createElement(Resizable, { defaultSize: { width: 100, height: 100 }, maxHeight: 200, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop }), document.getElementById('content'));
onResize = sinon_1.default.spy();
onResizeStart = sinon_1.default.spy();
onResizeStop = sinon_1.default.spy();
resizable = react_dom_1.default.render(react_1.default.createElement(_1.Resizable, { defaultSize: { width: 100, height: 100 }, maxHeight: 200, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop }), document.getElementById('content'));
if (!resizable || resizable instanceof Element)
return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = ReactDOM.findDOMNode(divs[7]);
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = react_dom_1.default.findDOMNode(divs[7]);
if (!node || !(node instanceof HTMLDivElement))
return [2 /*return*/, t.fail()];
TestUtils.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
test_utils_1.default.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
mouseMove(0, 200);

@@ -729,16 +734,16 @@ t.true(onResize.getCall(0).args[0] instanceof MouseEvent);

}); });
test.serial('should clamped by min height', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('should clamped by min height', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var onResize, onResizeStart, onResizeStop, resizable, divs, node;
return __generator(this, function (_a) {
onResize = sinon.spy();
onResizeStart = sinon.spy();
onResizeStop = sinon.spy();
resizable = ReactDOM.render(React.createElement(Resizable, { defaultSize: { width: 100, height: 100 }, minHeight: 50, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop }), document.getElementById('content'));
onResize = sinon_1.default.spy();
onResizeStart = sinon_1.default.spy();
onResizeStop = sinon_1.default.spy();
resizable = react_dom_1.default.render(react_1.default.createElement(_1.Resizable, { defaultSize: { width: 100, height: 100 }, minHeight: 50, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop }), document.getElementById('content'));
if (!resizable || resizable instanceof Element)
return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = ReactDOM.findDOMNode(divs[7]);
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = react_dom_1.default.findDOMNode(divs[7]);
if (!node || !(node instanceof HTMLDivElement))
return [2 /*return*/, t.fail()];
TestUtils.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
test_utils_1.default.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
mouseMove(0, -100);

@@ -751,16 +756,16 @@ t.true(onResize.getCall(0).args[0] instanceof MouseEvent);

}); });
test.serial('should allow 0 as minHeight', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('should allow 0 as minHeight', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var onResize, onResizeStart, onResizeStop, resizable, divs, node;
return __generator(this, function (_a) {
onResize = sinon.spy();
onResizeStart = sinon.spy();
onResizeStop = sinon.spy();
resizable = ReactDOM.render(React.createElement(Resizable, { defaultSize: { width: 100, height: 100 }, minHeight: 0, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop }), document.getElementById('content'));
onResize = sinon_1.default.spy();
onResizeStart = sinon_1.default.spy();
onResizeStop = sinon_1.default.spy();
resizable = react_dom_1.default.render(react_1.default.createElement(_1.Resizable, { defaultSize: { width: 100, height: 100 }, minHeight: 0, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop }), document.getElementById('content'));
if (!resizable || resizable instanceof Element)
return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = ReactDOM.findDOMNode(divs[7]);
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = react_dom_1.default.findDOMNode(divs[7]);
if (!node || !(node instanceof HTMLDivElement))
return [2 /*return*/, t.fail()];
TestUtils.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
test_utils_1.default.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
mouseMove(0, -100);

@@ -773,16 +778,16 @@ t.true(onResize.getCall(0).args[0] instanceof MouseEvent);

}); });
test.serial('should aspect ratio locked when resize to right', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('should aspect ratio locked when resize to right', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var onResize, onResizeStart, onResizeStop, resizable, divs, node;
return __generator(this, function (_a) {
onResize = sinon.spy();
onResizeStart = sinon.spy();
onResizeStop = sinon.spy();
resizable = ReactDOM.render(React.createElement(Resizable, { defaultSize: { width: 100, height: 100 }, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop, lockAspectRatio: true }), document.getElementById('content'));
onResize = sinon_1.default.spy();
onResizeStart = sinon_1.default.spy();
onResizeStop = sinon_1.default.spy();
resizable = react_dom_1.default.render(react_1.default.createElement(_1.Resizable, { defaultSize: { width: 100, height: 100 }, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop, lockAspectRatio: true }), document.getElementById('content'));
if (!resizable || resizable instanceof Element)
return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = ReactDOM.findDOMNode(divs[3]);
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = react_dom_1.default.findDOMNode(divs[3]);
if (!node || !(node instanceof HTMLDivElement))
return [2 /*return*/, t.fail()];
TestUtils.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
test_utils_1.default.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
mouseMove(200, 0);

@@ -798,16 +803,16 @@ mouseUp(200, 0);

}); });
test.serial('should aspect ratio locked with 1:1 ratio when resize to right', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('should aspect ratio locked with 1:1 ratio when resize to right', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var onResize, onResizeStart, onResizeStop, resizable, divs, node;
return __generator(this, function (_a) {
onResize = sinon.spy();
onResizeStart = sinon.spy();
onResizeStop = sinon.spy();
resizable = ReactDOM.render(React.createElement(Resizable, { defaultSize: { width: 100, height: 100 }, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop, lockAspectRatio: 1 / 1 }), document.getElementById('content'));
onResize = sinon_1.default.spy();
onResizeStart = sinon_1.default.spy();
onResizeStop = sinon_1.default.spy();
resizable = react_dom_1.default.render(react_1.default.createElement(_1.Resizable, { defaultSize: { width: 100, height: 100 }, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop, lockAspectRatio: 1 / 1 }), document.getElementById('content'));
if (!resizable || resizable instanceof Element)
return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = ReactDOM.findDOMNode(divs[3]);
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = react_dom_1.default.findDOMNode(divs[3]);
if (!node || !(node instanceof HTMLDivElement))
return [2 /*return*/, t.fail()];
TestUtils.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
test_utils_1.default.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
mouseMove(200, 0);

@@ -823,16 +828,16 @@ mouseUp(200, 0);

}); });
test.serial('should aspect ratio locked with 2:1 ratio when resize to right', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('should aspect ratio locked with 2:1 ratio when resize to right', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var onResize, onResizeStart, onResizeStop, resizable, divs, node;
return __generator(this, function (_a) {
onResize = sinon.spy();
onResizeStart = sinon.spy();
onResizeStop = sinon.spy();
resizable = ReactDOM.render(React.createElement(Resizable, { defaultSize: { width: 200, height: 100 }, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop, lockAspectRatio: 2 / 1 }), document.getElementById('content'));
onResize = sinon_1.default.spy();
onResizeStart = sinon_1.default.spy();
onResizeStop = sinon_1.default.spy();
resizable = react_dom_1.default.render(react_1.default.createElement(_1.Resizable, { defaultSize: { width: 200, height: 100 }, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop, lockAspectRatio: 2 / 1 }), document.getElementById('content'));
if (!resizable || resizable instanceof Element)
return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = ReactDOM.findDOMNode(divs[3]);
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = react_dom_1.default.findDOMNode(divs[3]);
if (!node || !(node instanceof HTMLDivElement))
return [2 /*return*/, t.fail()];
TestUtils.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
test_utils_1.default.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
mouseMove(200, 0);

@@ -848,16 +853,16 @@ mouseUp(200, 0);

}); });
test.serial('should aspect ratio locked with 2:1 ratio with extra width/height when resize to right', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('should aspect ratio locked with 2:1 ratio with extra width/height when resize to right', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var onResize, onResizeStart, onResizeStop, resizable, divs, node;
return __generator(this, function (_a) {
onResize = sinon.spy();
onResizeStart = sinon.spy();
onResizeStop = sinon.spy();
resizable = ReactDOM.render(React.createElement(Resizable, { defaultSize: { width: 250, height: 150 }, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop, lockAspectRatio: 2 / 1, lockAspectRatioExtraHeight: 50, lockAspectRatioExtraWidth: 50 }), document.getElementById('content'));
onResize = sinon_1.default.spy();
onResizeStart = sinon_1.default.spy();
onResizeStop = sinon_1.default.spy();
resizable = react_dom_1.default.render(react_1.default.createElement(_1.Resizable, { defaultSize: { width: 250, height: 150 }, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop, lockAspectRatio: 2 / 1, lockAspectRatioExtraHeight: 50, lockAspectRatioExtraWidth: 50 }), document.getElementById('content'));
if (!resizable || resizable instanceof Element)
return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = ReactDOM.findDOMNode(divs[3]);
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = react_dom_1.default.findDOMNode(divs[3]);
if (!node || !(node instanceof HTMLDivElement))
return [2 /*return*/, t.fail()];
TestUtils.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
test_utils_1.default.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
mouseMove(200, 0);

@@ -873,16 +878,16 @@ mouseUp(200, 0);

}); });
test.serial('should aspect ratio locked when resize to bottom', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('should aspect ratio locked when resize to bottom', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var onResize, onResizeStart, onResizeStop, resizable, divs, node;
return __generator(this, function (_a) {
onResize = sinon.spy();
onResizeStart = sinon.spy();
onResizeStop = sinon.spy();
resizable = ReactDOM.render(React.createElement(Resizable, { defaultSize: { width: 100, height: 100 }, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop, lockAspectRatio: true }), document.getElementById('content'));
onResize = sinon_1.default.spy();
onResizeStart = sinon_1.default.spy();
onResizeStop = sinon_1.default.spy();
resizable = react_dom_1.default.render(react_1.default.createElement(_1.Resizable, { defaultSize: { width: 100, height: 100 }, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop, lockAspectRatio: true }), document.getElementById('content'));
if (!resizable || resizable instanceof Element)
return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = ReactDOM.findDOMNode(divs[4]);
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = react_dom_1.default.findDOMNode(divs[4]);
if (!node || !(node instanceof HTMLDivElement))
return [2 /*return*/, t.fail()];
TestUtils.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
test_utils_1.default.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
mouseMove(0, 200);

@@ -898,16 +903,16 @@ mouseUp(0, 200);

}); });
test.serial('should aspect ratio locked with 1:1 ratio when resize to bottom', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('should aspect ratio locked with 1:1 ratio when resize to bottom', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var onResize, onResizeStart, onResizeStop, resizable, divs, node;
return __generator(this, function (_a) {
onResize = sinon.spy();
onResizeStart = sinon.spy();
onResizeStop = sinon.spy();
resizable = ReactDOM.render(React.createElement(Resizable, { defaultSize: { width: 100, height: 100 }, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop, lockAspectRatio: 1 / 1 }), document.getElementById('content'));
onResize = sinon_1.default.spy();
onResizeStart = sinon_1.default.spy();
onResizeStop = sinon_1.default.spy();
resizable = react_dom_1.default.render(react_1.default.createElement(_1.Resizable, { defaultSize: { width: 100, height: 100 }, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop, lockAspectRatio: 1 / 1 }), document.getElementById('content'));
if (!resizable || resizable instanceof Element)
return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = ReactDOM.findDOMNode(divs[4]);
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = react_dom_1.default.findDOMNode(divs[4]);
if (!node || !(node instanceof HTMLDivElement))
return [2 /*return*/, t.fail()];
TestUtils.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
test_utils_1.default.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
mouseMove(0, 200);

@@ -923,16 +928,16 @@ mouseUp(0, 200);

}); });
test.serial('should aspect ratio locked with 2:1 ratio when resize to bottom', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('should aspect ratio locked with 2:1 ratio when resize to bottom', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var onResize, onResizeStart, onResizeStop, resizable, divs, node;
return __generator(this, function (_a) {
onResize = sinon.spy();
onResizeStart = sinon.spy();
onResizeStop = sinon.spy();
resizable = ReactDOM.render(React.createElement(Resizable, { defaultSize: { width: 200, height: 100 }, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop, lockAspectRatio: 2 / 1 }), document.getElementById('content'));
onResize = sinon_1.default.spy();
onResizeStart = sinon_1.default.spy();
onResizeStop = sinon_1.default.spy();
resizable = react_dom_1.default.render(react_1.default.createElement(_1.Resizable, { defaultSize: { width: 200, height: 100 }, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop, lockAspectRatio: 2 / 1 }), document.getElementById('content'));
if (!resizable || resizable instanceof Element)
return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = ReactDOM.findDOMNode(divs[4]);
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = react_dom_1.default.findDOMNode(divs[4]);
if (!node || !(node instanceof HTMLDivElement))
return [2 /*return*/, t.fail()];
TestUtils.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
test_utils_1.default.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
mouseMove(0, 200);

@@ -948,16 +953,16 @@ mouseUp(0, 200);

}); });
test.serial('should aspect ratio locked with 2:1 ratio with extra width/height when resize to bottom', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('should aspect ratio locked with 2:1 ratio with extra width/height when resize to bottom', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var onResize, onResizeStart, onResizeStop, resizable, divs, node;
return __generator(this, function (_a) {
onResize = sinon.spy();
onResizeStart = sinon.spy();
onResizeStop = sinon.spy();
resizable = ReactDOM.render(React.createElement(Resizable, { defaultSize: { width: 250, height: 150 }, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop, lockAspectRatio: 2 / 1, lockAspectRatioExtraHeight: 50, lockAspectRatioExtraWidth: 50 }), document.getElementById('content'));
onResize = sinon_1.default.spy();
onResizeStart = sinon_1.default.spy();
onResizeStop = sinon_1.default.spy();
resizable = react_dom_1.default.render(react_1.default.createElement(_1.Resizable, { defaultSize: { width: 250, height: 150 }, onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop, lockAspectRatio: 2 / 1, lockAspectRatioExtraHeight: 50, lockAspectRatioExtraWidth: 50 }), document.getElementById('content'));
if (!resizable || resizable instanceof Element)
return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = ReactDOM.findDOMNode(divs[4]);
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = react_dom_1.default.findDOMNode(divs[4]);
if (!node || !(node instanceof HTMLDivElement))
return [2 /*return*/, t.fail()];
TestUtils.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
test_utils_1.default.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
mouseMove(0, 200);

@@ -973,16 +978,16 @@ mouseUp(0, 200);

}); });
test.serial('should clamped by parent width', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('should clamped by parent width', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var onResize, onResizeStart, onResizeStop, resizable, divs, node;
return __generator(this, function (_a) {
onResize = sinon.spy();
onResizeStart = sinon.spy();
onResizeStop = sinon.spy();
resizable = ReactDOM.render(React.createElement(Resizable, { defaultSize: { width: 100, height: 100 }, bounds: "parent", onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop }), document.getElementById('content'));
onResize = sinon_1.default.spy();
onResizeStart = sinon_1.default.spy();
onResizeStop = sinon_1.default.spy();
resizable = react_dom_1.default.render(react_1.default.createElement(_1.Resizable, { defaultSize: { width: 100, height: 100 }, bounds: "parent", onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop }), document.getElementById('content'));
if (!resizable || resizable instanceof Element)
return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = ReactDOM.findDOMNode(divs[7]);
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = react_dom_1.default.findDOMNode(divs[7]);
if (!node || !(node instanceof HTMLDivElement))
return [2 /*return*/, t.fail()];
TestUtils.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
test_utils_1.default.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
mouseMove(200, 0);

@@ -995,16 +1000,16 @@ t.true(onResize.getCall(0).args[0] instanceof MouseEvent);

}); });
test.serial('should clamped by parent height', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('should clamped by parent height', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var onResize, onResizeStart, onResizeStop, resizable, divs, node;
return __generator(this, function (_a) {
onResize = sinon.spy();
onResizeStart = sinon.spy();
onResizeStop = sinon.spy();
resizable = ReactDOM.render(React.createElement(Resizable, { defaultSize: { width: 100, height: 100 }, bounds: "parent", onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop }), document.getElementById('content'));
onResize = sinon_1.default.spy();
onResizeStart = sinon_1.default.spy();
onResizeStop = sinon_1.default.spy();
resizable = react_dom_1.default.render(react_1.default.createElement(_1.Resizable, { defaultSize: { width: 100, height: 100 }, bounds: "parent", onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop }), document.getElementById('content'));
if (!resizable || resizable instanceof Element)
return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = ReactDOM.findDOMNode(divs[7]);
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = react_dom_1.default.findDOMNode(divs[7]);
if (!node || !(node instanceof HTMLDivElement))
return [2 /*return*/, t.fail()];
TestUtils.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
test_utils_1.default.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
mouseMove(0, 200);

@@ -1017,9 +1022,9 @@ t.true(onResize.getCall(0).args[0] instanceof MouseEvent);

}); });
test.serial('should defaultSize ignored when size set', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('should defaultSize ignored when size set', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var resizable, divs;
return __generator(this, function (_a) {
resizable = TestUtils.renderIntoDocument(React.createElement(Resizable, { defaultSize: { width: 100, height: 100 }, size: { width: 200, height: 300 } }));
resizable = test_utils_1.default.renderIntoDocument(react_1.default.createElement(_1.Resizable, { defaultSize: { width: 100, height: 100 }, size: { width: 200, height: 300 } }));
if (!resizable || resizable instanceof Element)
return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
t.is(divs.length, 10);

@@ -1032,11 +1037,11 @@ t.is(divs[0].style.width, '200px');

}); });
test.serial('should render a handleComponent for right', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('should render a handleComponent for right', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var CustomComponent, resizable, divs, node, handleNode;
return __generator(this, function (_a) {
CustomComponent = React.createElement("div", { className: 'customHandle-right' });
resizable = TestUtils.renderIntoDocument(React.createElement(Resizable, { handleComponent: { right: CustomComponent } }));
CustomComponent = react_1.default.createElement("div", { className: 'customHandle-right' });
resizable = test_utils_1.default.renderIntoDocument(react_1.default.createElement(_1.Resizable, { handleComponent: { right: CustomComponent } }));
if (!resizable || resizable instanceof Element)
return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = ReactDOM.findDOMNode(divs[3]);
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = react_dom_1.default.findDOMNode(divs[3]);
if (!node || !(node instanceof HTMLDivElement))

@@ -1050,16 +1055,16 @@ return [2 /*return*/, t.fail()];

}); });
test.serial('should adjust resizing for specified scale', function (t) { return __awaiter(void 0, void 0, void 0, function () {
ava_1.default.serial('should adjust resizing for specified scale', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var onResize, resizable, divs, node;
return __generator(this, function (_a) {
onResize = sinon.spy();
resizable = ReactDOM.render(React.createElement(Resizable, { defaultSize: { width: 100, height: 100 }, onResize: onResize, style: { padding: '40px' }, scale: 0.5 }), document.getElementById('content'));
onResize = sinon_1.default.spy();
resizable = react_dom_1.default.render(react_1.default.createElement(_1.Resizable, { defaultSize: { width: 100, height: 100 }, onResize: onResize, style: { padding: '40px' }, scale: 0.5 }), document.getElementById('content'));
if (!resizable || resizable instanceof Element)
return [2 /*return*/, t.fail()];
divs = TestUtils.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = ReactDOM.findDOMNode(divs[7]);
divs = test_utils_1.default.scryRenderedDOMComponentsWithTag(resizable, 'div');
node = react_dom_1.default.findDOMNode(divs[7]);
if (!node || !(node instanceof HTMLDivElement))
return [2 /*return*/, t.fail()];
TestUtils.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
test_utils_1.default.Simulate.mouseDown(node, { clientX: 0, clientY: 0 });
mouseMove(200, 220);
TestUtils.Simulate.mouseUp(node);
test_utils_1.default.Simulate.mouseUp(node);
t.is(onResize.callCount, 1);

@@ -1066,0 +1071,0 @@ t.true(onResize.getCall(0).args[0] instanceof MouseEvent);

@@ -0,1 +1,2 @@

"use strict";
var __extends = (this && this.__extends) || (function () {

@@ -25,3 +26,24 @@ var extendStatics = function (d, b) {

};
import * as React from 'react';
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Resizer = void 0;
var React = __importStar(require("react"));
var styles = {

@@ -106,2 +128,2 @@ top: {

}(React.PureComponent));
export { Resizer };
exports.Resizer = Resizer;
{
"name": "re-resizable",
"version": "6.9.2",
"version": "6.9.3",
"description": "Resizable component for React.",

@@ -5,0 +5,0 @@ "title": "re-resizable",

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