Added logging, changed some directory structure

This commit is contained in:
2018-01-13 21:33:40 -05:00
parent f079a5f067
commit 8e72ffb917
73656 changed files with 35284 additions and 53718 deletions

View File

@@ -0,0 +1,10 @@
{
"presets": [
["es2015", {"loose": true}],
"react"
],
"plugins": [
"transform-class-properties",
"transform-object-rest-spread",
]
}

View File

@@ -0,0 +1,33 @@
{
"root": true,
"parser": "babel-eslint",
"plugins": [
"react"
],
"extends": "eslint:recommended",
"rules": {
"strict": 0,
"quotes": [0, "single"],
"curly": [1, "multi-line"],
"camelcase": 0,
"comma-dangle": 0,
"dot-notation": 0,
"no-console": 0,
"no-use-before-define": [1, "nofunc"],
"no-underscore-dangle": 0,
"no-unused-vars": 0,
"new-cap": 0,
"react/jsx-uses-vars": 1,
"semi": [1, "always"]
},
env: {
"browser": true,
"node": true
},
"globals": {
// For Flow
"ReactElement",
"ReactClass",
"SyntheticEvent"
}
}

View File

@@ -0,0 +1,31 @@
[version]
0.55.0
[ignore]
.*/node_modules/babel.*
.*/node_modules/fbjs/.*
.*/node_modules/express/.*
.*/node_modules/serve-index/.*
<PROJECT_ROOT>/build/.*
[include]
[libs]
[options]
suppress_comment=\\(.\\|\n\\)*\\s*\\$FlowFixMe.*
suppress_comment=\\(.\\|\n\\)*\\s*\\$FlowBug.*
suppress_comment=\\(.\\|\n\\)*\\s*\\$FlowIgnore.*
suppress_comment=\\(.\\|\n\\)*\\s*\\$FlowNewLine.*
suppress_comment=\\(.\\|\n\\)*\\s*\\$FlowIssue
suppress_type=$FlowFixMe
esproposal.class_static_fields=enable
esproposal.class_instance_fields=enable
esproposal.decorators=ignore
esproposal.export_star_as=enable
experimental.strict_call_arity=true
module.system.node.resolve_dirname=node_modules
module.system.node.resolve_dirname=.
module.use_strict=true
server.max_workers=6
unsafe.enable_getters_and_setters=true

View File

@@ -0,0 +1,23 @@
### Thanks for opening an issue!
Please select the type of issue you're reporting. For questions.
- [ ] Bug
- [ ] Feature Request
- [ ] Question
### Problem Report
> Please describe the problem here.
#### System Info
Node Version:
Browser:
OS:
#### Reproduction
If this is a bug report, please provide a reproduction of the issue by going to
http://www.webpackbin.com/41YFBvekG.
Paste a link here to your working reproduction.

View File

@@ -0,0 +1,6 @@
Thanks for submitting a pull request to React-Resizable!
Please reference an open issue. If one has not been created, please create one along with a failing
example or test case.
Please do not commit built files (`/dist`) to pull requests. They are built only at release.

View File

@@ -0,0 +1,94 @@
# Changelog
### 1.7.5 (Sep 26, 2017)
- Support for React 16 (no changes required, updated `peerDependencies`)
- Minor dep updates.
### 1.7.4 (Sep 5, 2017)
- Minor Flow & dependency updates.
### 1.7.3 (Aug 31, 2017)
- Fix React deprecation warnings from `import *`
- https://github.com/facebook/react/issues/10583
### 1.7.2 (Aug 21, 2017)
- Pkg: Add `react-draggable@3.0.0` to version range.
- This package is compatible with both `@2` and `@3` versions.
### 1.7.1 (May 23, 2017)
- Bugfix: Some flow types were improperly specified.
### 1.7.0 (May 1, 2017)
- Deprecation: `React.PropTypes` now deprecated in React 15.5, moved to `prop-types` package
- Internal: Update devDeps, upgrade to webpack 2
- Internal: Remove babel `stage-1` and `transform-flow-comments`, bring in only selected plugins, makes for leaner dev/build.
### 1.6.0 (Jan 23, 2017)
- Feature: Allow restricting by axis. (#40, thanks @dnissley-al)
### 1.5.0 (Jan 23, 2017)
- Bugfix: Persist SyntheticEvents when needed (#45, #46)
- Feature: Add componentWillReceiveProps to `<ResizableBox>` (#44, thanks @JoaoMosmann)
### 1.4.6 (Dec 30, 2016)
- Removed unused ref from `<Resizable>`.
- Added development lockfile.
### 1.4.5 (Sep 30, 2016)
- Fix bad publish
### 1.4.4 (Sep 30, 2016)
- Bugfix: Minor flow errors
### 1.4.3 (Sep 27, 2016)
- Bugfix: Don't pass `onResize` in `<ResizableBox>`.
- Bugfix: Fix new Flow errors (type parameters no longer optional).
### 1.4.2 (July 1, 2016)
- Bugfix: Don't pass unknown props to underlying DOM element. Fixes React 15.2.0 warnings.
### 1.4.1 (May 23, 2016)
- Bugfix: Resizable handle should have a `key` when injected. Fixes React warnings on custom components.
### 1.4.0 (May 20, 2016)
- Update to React-Draggable v2, which changed callback data structure.
### 1.3.4 (May 17, 2016)
- Bugfix: Slack was not being reset on resizeStop. Fixes #34, #36.
- Added `flow-bin` to devDeps.
### 1.3.3 (Apr 19, 2016)
- Enhancement: Add Flow comments.
### 1.3.2 (Apr 8, 2016)
- Bugfix: Prevent `width` and `height` from leaking to the underlying DOM element and being written.
### 1.3.1 (Apr 8, 2016)
- Allow React v15 in peerdeps.
### 1.3.0 (Mar 11, 2016)
- Switch to ES2015 Loose Mode to fix IE9/10 issues.
- Flow typing fixes.
- Styling fixes to the demo page.
> Changes before 1.3.0 were not logged. Please see the git commit history.

View File

@@ -0,0 +1,64 @@
### React-Resizable
[View the Demo](https://strml.github.io/react-resizable/examples/1.html)
A simple widget that can be resized via a handle.
You can either use the `<Resizable>` element directly, or use the much simpler `<ResizableBox>` element.
See the example and associated code in [TestLayout](/test/TestLayout.js) and
[ResizableBox](/lib/ResizableBox.js) for more details.
Make sure you use the associated styles in [/css/styles.css](/css/styles.css), as without them, you will have
problems with handle placement and visibility.
You can pass options directly to the underlying `DraggableCore` instance by using the prop `draggableOpts`.
See the [demo](/test/TestLayout.js) for more on this.
### Installation
Using [npm](https://www.npmjs.com/):
$ npm install --save react-resizable
### Usage
```js
const Resizable = require('react-resizable').Resizable; // or,
const ResizableBox = require('react-resizable').ResizableBox;
// ES6
import { Resizable, ResizableBox } from 'react-resizable';
// ...
render() {
return (
<ResizableBox width={200} height={200} draggableOpts={{...}}
minConstraints={[100, 100]} maxConstraints={[300, 300]}>
<span>Contents</span>
</ResizableBox>
);
}
```
### Props
These props apply to both `<Resizable>` and `<ResizableBox>`.
```js
{
children: React.Element<any>,
width: number,
height: number,
// If you change this, be sure to update your css
handleSize: [number, number] = [10, 10],
lockAspectRatio: boolean = false,
axis: 'both' | 'x' | 'y' | 'none' = 'both',
minConstraints: [number, number] = [10, 10],
maxConstraints: [number, number] = [Infinity, Infinity],
onResizeStop?: ?(e: SyntheticEvent, data: ResizeCallbackData) => any,
onResizeStart?: ?(e: SyntheticEvent, data: ResizeCallbackData) => any,
onResize?: ?(e: SyntheticEvent, data: ResizeCallbackData) => any,
draggableOpts?: ?Object
};
```

View File

@@ -0,0 +1,265 @@
'use strict';
exports.__esModule = true;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _reactDraggable = require('react-draggable');
var _cloneElement = require('./cloneElement');
var _cloneElement2 = _interopRequireDefault(_cloneElement);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Resizable = function (_React$Component) {
_inherits(Resizable, _React$Component);
function Resizable() {
var _temp, _this, _ret;
_classCallCheck(this, Resizable);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.state = {
resizing: false,
width: _this.props.width, height: _this.props.height,
slackW: 0, slackH: 0
}, _temp), _possibleConstructorReturn(_this, _ret);
}
Resizable.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
// If parent changes height/width, set that in our state.
if (!this.state.resizing && (nextProps.width !== this.props.width || nextProps.height !== this.props.height)) {
this.setState({
width: nextProps.width,
height: nextProps.height
});
}
};
Resizable.prototype.lockAspectRatio = function lockAspectRatio(width, height, aspectRatio) {
height = width / aspectRatio;
width = height * aspectRatio;
return [width, height];
};
// If you do this, be careful of constraints
Resizable.prototype.runConstraints = function runConstraints(width, height) {
var _ref = [this.props.minConstraints, this.props.maxConstraints],
min = _ref[0],
max = _ref[1];
if (this.props.lockAspectRatio) {
var ratio = this.state.width / this.state.height;
height = width / ratio;
width = height * ratio;
}
if (!min && !max) return [width, height];
var oldW = width,
oldH = height;
// Add slack to the values used to calculate bound position. This will ensure that if
// we start removing slack, the element won't react to it right away until it's been
// completely removed.
var _state = this.state,
slackW = _state.slackW,
slackH = _state.slackH;
width += slackW;
height += slackH;
if (min) {
width = Math.max(min[0], width);
height = Math.max(min[1], height);
}
if (max) {
width = Math.min(max[0], width);
height = Math.min(max[1], height);
}
// If the numbers changed, we must have introduced some slack. Record it for the next iteration.
slackW += oldW - width;
slackH += oldH - height;
if (slackW !== this.state.slackW || slackH !== this.state.slackH) {
this.setState({ slackW: slackW, slackH: slackH });
}
return [width, height];
};
/**
* Wrapper around drag events to provide more useful data.
*
* @param {String} handlerName Handler name to wrap.
* @return {Function} Handler function.
*/
Resizable.prototype.resizeHandler = function resizeHandler(handlerName) {
var _this2 = this;
return function (e, _ref2) {
var node = _ref2.node,
deltaX = _ref2.deltaX,
deltaY = _ref2.deltaY;
// Axis restrictions
var canDragX = _this2.props.axis === 'both' || _this2.props.axis === 'x';
var canDragY = _this2.props.axis === 'both' || _this2.props.axis === 'y';
// Update w/h
var width = _this2.state.width + (canDragX ? deltaX : 0);
var height = _this2.state.height + (canDragY ? deltaY : 0);
// Early return if no change
var widthChanged = width !== _this2.state.width,
heightChanged = height !== _this2.state.height;
if (handlerName === 'onResize' && !widthChanged && !heightChanged) return;
// Set the appropriate state for this handler.
var _runConstraints = _this2.runConstraints(width, height);
width = _runConstraints[0];
height = _runConstraints[1];
var newState = {};
if (handlerName === 'onResizeStart') {
newState.resizing = true;
} else if (handlerName === 'onResizeStop') {
newState.resizing = false;
newState.slackW = newState.slackH = 0;
} else {
// Early return if no change after constraints
if (width === _this2.state.width && height === _this2.state.height) return;
newState.width = width;
newState.height = height;
}
var hasCb = typeof _this2.props[handlerName] === 'function';
if (hasCb) {
if (typeof e.persist === 'function') e.persist();
_this2.setState(newState, function () {
return _this2.props[handlerName](e, { node: node, size: { width: width, height: height } });
});
} else {
_this2.setState(newState);
}
};
};
Resizable.prototype.render = function render() {
// eslint-disable-next-line no-unused-vars
var _props = this.props,
children = _props.children,
draggableOpts = _props.draggableOpts,
width = _props.width,
height = _props.height,
handleSize = _props.handleSize,
lockAspectRatio = _props.lockAspectRatio,
axis = _props.axis,
minConstraints = _props.minConstraints,
maxConstraints = _props.maxConstraints,
onResize = _props.onResize,
onResizeStop = _props.onResizeStop,
onResizeStart = _props.onResizeStart,
p = _objectWithoutProperties(_props, ['children', 'draggableOpts', 'width', 'height', 'handleSize', 'lockAspectRatio', 'axis', 'minConstraints', 'maxConstraints', 'onResize', 'onResizeStop', 'onResizeStart']);
var className = p.className ? p.className + ' react-resizable' : 'react-resizable';
// What we're doing here is getting the child of this element, and cloning it with this element's props.
// We are then defining its children as:
// Its original children (resizable's child's children), and
// A draggable handle.
return (0, _cloneElement2.default)(children, _extends({}, p, {
className: className,
children: [children.props.children, _react2.default.createElement(
_reactDraggable.DraggableCore,
_extends({}, draggableOpts, {
key: 'resizableHandle',
onStop: this.resizeHandler('onResizeStop'),
onStart: this.resizeHandler('onResizeStart'),
onDrag: this.resizeHandler('onResize')
}),
_react2.default.createElement('span', { className: 'react-resizable-handle' })
)]
}));
};
return Resizable;
}(_react2.default.Component);
Resizable.propTypes = {
//
// Required Props
//
// Require that one and only one child be present.
children: _propTypes2.default.element.isRequired,
// Initial w/h
width: _propTypes2.default.number.isRequired,
height: _propTypes2.default.number.isRequired,
//
// Optional props
//
// If you change this, be sure to update your css
handleSize: _propTypes2.default.array,
// If true, will only allow width/height to move in lockstep
lockAspectRatio: _propTypes2.default.bool,
// Restricts resizing to a particular axis (default: 'both')
// 'both' - allows resizing by width or height
// 'x' - only allows the width to be changed
// 'y' - only allows the height to be changed
// 'none' - disables resizing altogether
axis: _propTypes2.default.oneOf(['both', 'x', 'y', 'none']),
// Min/max size
minConstraints: _propTypes2.default.arrayOf(_propTypes2.default.number),
maxConstraints: _propTypes2.default.arrayOf(_propTypes2.default.number),
// Callbacks
onResizeStop: _propTypes2.default.func,
onResizeStart: _propTypes2.default.func,
onResize: _propTypes2.default.func,
// These will be passed wholesale to react-draggable's DraggableCore
draggableOpts: _propTypes2.default.object
};
Resizable.defaultProps = {
handleSize: [20, 20],
lockAspectRatio: false,
axis: 'both',
minConstraints: [20, 20],
maxConstraints: [Infinity, Infinity]
};
exports.default = Resizable;

View File

@@ -0,0 +1,232 @@
// @flow
import React from 'react';
import PropTypes from 'prop-types';
import {DraggableCore} from 'react-draggable';
import cloneElement from './cloneElement';
import type {Element as ReactElement, Node as ReactNode} from 'react';
type Axis = 'both' | 'x' | 'y' | 'none';
type State = {
resizing: boolean,
width: number, height: number,
slackW: number, slackH: number
};
type DragCallbackData = {
node: HTMLElement,
x: number, y: number,
deltaX: number, deltaY: number,
lastX: number, lastY: number
};
export type ResizeCallbackData = {
node: HTMLElement,
size: {width: number, height: number}
};
export type Props = {
children: ReactElement<any>,
className?: ?string,
width: number,
height: number,
handleSize: [number, number],
lockAspectRatio: boolean,
axis: Axis,
minConstraints: [number, number],
maxConstraints: [number, number],
onResizeStop?: ?(e: SyntheticEvent<>, data: ResizeCallbackData) => any,
onResizeStart?: ?(e: SyntheticEvent<>, data: ResizeCallbackData) => any,
onResize?: ?(e: SyntheticEvent<>, data: ResizeCallbackData) => any,
draggableOpts?: ?Object
};
export default class Resizable extends React.Component<Props, State> {
static propTypes = {
//
// Required Props
//
// Require that one and only one child be present.
children: PropTypes.element.isRequired,
// Initial w/h
width: PropTypes.number.isRequired,
height: PropTypes.number.isRequired,
//
// Optional props
//
// If you change this, be sure to update your css
handleSize: PropTypes.array,
// If true, will only allow width/height to move in lockstep
lockAspectRatio: PropTypes.bool,
// Restricts resizing to a particular axis (default: 'both')
// 'both' - allows resizing by width or height
// 'x' - only allows the width to be changed
// 'y' - only allows the height to be changed
// 'none' - disables resizing altogether
axis: PropTypes.oneOf(['both', 'x', 'y', 'none']),
// Min/max size
minConstraints: PropTypes.arrayOf(PropTypes.number),
maxConstraints: PropTypes.arrayOf(PropTypes.number),
// Callbacks
onResizeStop: PropTypes.func,
onResizeStart: PropTypes.func,
onResize: PropTypes.func,
// These will be passed wholesale to react-draggable's DraggableCore
draggableOpts: PropTypes.object
};
static defaultProps = {
handleSize: [20, 20],
lockAspectRatio: false,
axis: 'both',
minConstraints: [20, 20],
maxConstraints: [Infinity, Infinity]
};
state: State = {
resizing: false,
width: this.props.width, height: this.props.height,
slackW: 0, slackH: 0
};
componentWillReceiveProps(nextProps: Object) {
// If parent changes height/width, set that in our state.
if (!this.state.resizing &&
(nextProps.width !== this.props.width || nextProps.height !== this.props.height)) {
this.setState({
width: nextProps.width,
height: nextProps.height
});
}
}
lockAspectRatio(width: number, height: number, aspectRatio: number): [number, number] {
height = width / aspectRatio;
width = height * aspectRatio;
return [width, height];
}
// If you do this, be careful of constraints
runConstraints(width: number, height: number): [number, number] {
const [min, max] = [this.props.minConstraints, this.props.maxConstraints];
if (this.props.lockAspectRatio) {
const ratio = this.state.width / this.state.height;
height = width / ratio;
width = height * ratio;
}
if (!min && !max) return [width, height];
const [oldW, oldH] = [width, height];
// Add slack to the values used to calculate bound position. This will ensure that if
// we start removing slack, the element won't react to it right away until it's been
// completely removed.
let {slackW, slackH} = this.state;
width += slackW;
height += slackH;
if (min) {
width = Math.max(min[0], width);
height = Math.max(min[1], height);
}
if (max) {
width = Math.min(max[0], width);
height = Math.min(max[1], height);
}
// If the numbers changed, we must have introduced some slack. Record it for the next iteration.
slackW += (oldW - width);
slackH += (oldH - height);
if (slackW !== this.state.slackW || slackH !== this.state.slackH) {
this.setState({slackW, slackH});
}
return [width, height];
}
/**
* Wrapper around drag events to provide more useful data.
*
* @param {String} handlerName Handler name to wrap.
* @return {Function} Handler function.
*/
resizeHandler(handlerName: string): Function {
return (e: SyntheticEvent<> | MouseEvent, {node, deltaX, deltaY}: DragCallbackData) => {
// Axis restrictions
const canDragX = this.props.axis === 'both' || this.props.axis === 'x';
const canDragY = this.props.axis === 'both' || this.props.axis === 'y';
// Update w/h
let width = this.state.width + (canDragX ? deltaX : 0);
let height = this.state.height + (canDragY ? deltaY : 0);
// Early return if no change
const widthChanged = width !== this.state.width, heightChanged = height !== this.state.height;
if (handlerName === 'onResize' && !widthChanged && !heightChanged) return;
[width, height] = this.runConstraints(width, height);
// Set the appropriate state for this handler.
const newState = {};
if (handlerName === 'onResizeStart') {
newState.resizing = true;
} else if (handlerName === 'onResizeStop') {
newState.resizing = false;
newState.slackW = newState.slackH = 0;
} else {
// Early return if no change after constraints
if (width === this.state.width && height === this.state.height) return;
newState.width = width;
newState.height = height;
}
const hasCb = typeof this.props[handlerName] === 'function';
if (hasCb) {
if (typeof e.persist === 'function') e.persist();
this.setState(newState, () => this.props[handlerName](e, {node, size: {width, height}}));
} else {
this.setState(newState);
}
};
}
render(): ReactNode {
// eslint-disable-next-line no-unused-vars
const {children, draggableOpts, width, height, handleSize,
lockAspectRatio, axis, minConstraints, maxConstraints, onResize,
onResizeStop, onResizeStart, ...p} = this.props;
const className = p.className ?
`${p.className} react-resizable`:
'react-resizable';
// What we're doing here is getting the child of this element, and cloning it with this element's props.
// We are then defining its children as:
// Its original children (resizable's child's children), and
// A draggable handle.
return cloneElement(children, {
...p,
className,
children: [
children.props.children,
<DraggableCore
{...draggableOpts}
key="resizableHandle"
onStop={this.resizeHandler('onResizeStop')}
onStart={this.resizeHandler('onResizeStart')}
onDrag={this.resizeHandler('onResize')}
>
<span className="react-resizable-handle" />
</DraggableCore>
]
});
}
}

View File

@@ -0,0 +1,118 @@
'use strict';
exports.__esModule = true;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _Resizable = require('./Resizable');
var _Resizable2 = _interopRequireDefault(_Resizable);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
// An example use of Resizable.
var ResizableBox = function (_React$Component) {
_inherits(ResizableBox, _React$Component);
function ResizableBox() {
var _temp, _this, _ret;
_classCallCheck(this, ResizableBox);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.state = {
width: _this.props.width,
height: _this.props.height
}, _this.onResize = function (e, data) {
var size = data.size;
var width = size.width,
height = size.height;
if (_this.props.onResize) {
e.persist && e.persist();
_this.setState(size, function () {
return _this.props.onResize && _this.props.onResize(e, data);
});
} else {
_this.setState(size);
}
}, _temp), _possibleConstructorReturn(_this, _ret);
}
ResizableBox.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
if (nextProps.width !== this.props.width || nextProps.height !== this.props.height) {
this.setState({
width: nextProps.width,
height: nextProps.height
});
}
};
ResizableBox.prototype.render = function render() {
// Basic wrapper around a Resizable instance.
// If you use Resizable directly, you are responsible for updating the child component
// with a new width and height.
var _props = this.props,
handleSize = _props.handleSize,
onResize = _props.onResize,
onResizeStart = _props.onResizeStart,
onResizeStop = _props.onResizeStop,
draggableOpts = _props.draggableOpts,
minConstraints = _props.minConstraints,
maxConstraints = _props.maxConstraints,
lockAspectRatio = _props.lockAspectRatio,
axis = _props.axis,
width = _props.width,
height = _props.height,
props = _objectWithoutProperties(_props, ['handleSize', 'onResize', 'onResizeStart', 'onResizeStop', 'draggableOpts', 'minConstraints', 'maxConstraints', 'lockAspectRatio', 'axis', 'width', 'height']);
return _react2.default.createElement(
_Resizable2.default,
{
handleSize: handleSize,
width: this.state.width,
height: this.state.height,
onResizeStart: onResizeStart,
onResize: this.onResize,
onResizeStop: onResizeStop,
draggableOpts: draggableOpts,
minConstraints: minConstraints,
maxConstraints: maxConstraints,
lockAspectRatio: lockAspectRatio,
axis: axis
},
_react2.default.createElement('div', _extends({ style: { width: this.state.width + 'px', height: this.state.height + 'px' } }, props))
);
};
return ResizableBox;
}(_react2.default.Component);
ResizableBox.propTypes = {
height: _propTypes2.default.number,
width: _propTypes2.default.number
};
ResizableBox.defaultProps = {
handleSize: [20, 20]
};
exports.default = ResizableBox;

View File

@@ -0,0 +1,71 @@
// @flow
import React from 'react';
import PropTypes from 'prop-types';
import Resizable from './Resizable';
import type {Props as ResizableProps, ResizeCallbackData} from './Resizable';
import type {Node as ReactNode} from 'react';
type State = {width: number, height: number};
// An example use of Resizable.
export default class ResizableBox extends React.Component<ResizableProps, State> {
static propTypes = {
height: PropTypes.number,
width: PropTypes.number
};
static defaultProps = {
handleSize: [20,20]
};
state: State = {
width: this.props.width,
height: this.props.height,
};
onResize = (e: SyntheticEvent<>, data: ResizeCallbackData) => {
const {size} = data;
const {width, height} = size;
if (this.props.onResize) {
e.persist && e.persist();
this.setState(size, () => this.props.onResize && this.props.onResize(e, data));
} else {
this.setState(size);
}
};
componentWillReceiveProps(nextProps: ResizableProps) {
if (nextProps.width !== this.props.width || nextProps.height !== this.props.height) {
this.setState({
width: nextProps.width,
height: nextProps.height
});
}
}
render(): ReactNode {
// Basic wrapper around a Resizable instance.
// If you use Resizable directly, you are responsible for updating the child component
// with a new width and height.
const {handleSize, onResize, onResizeStart, onResizeStop, draggableOpts,
minConstraints, maxConstraints, lockAspectRatio, axis, width, height, ...props} = this.props;
return (
<Resizable
handleSize={handleSize}
width={this.state.width}
height={this.state.height}
onResizeStart={onResizeStart}
onResize={this.onResize}
onResizeStop={onResizeStop}
draggableOpts={draggableOpts}
minConstraints={minConstraints}
maxConstraints={maxConstraints}
lockAspectRatio={lockAspectRatio}
axis={axis}
>
<div style={{width: this.state.width + 'px', height: this.state.height + 'px'}} {...props} />
</Resizable>
);
}
}

View File

@@ -0,0 +1,20 @@
'use strict';
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// React.addons.cloneWithProps look-alike that merges style & className.
module.exports = function cloneElement(element, props) {
if (props.style && element.props.style) {
props.style = _extends({}, element.props.style, props.style);
}
if (props.className && element.props.className) {
props.className = element.props.className + ' ' + props.className;
}
return _react2.default.cloneElement(element, props);
};

View File

@@ -0,0 +1,14 @@
// @flow
import React from 'react';
import type {Element as ReactElement} from 'react';
// React.addons.cloneWithProps look-alike that merges style & className.
module.exports = function cloneElement(element: ReactElement<any>, props: Object): ReactElement<any> {
if (props.style && element.props.style) {
props.style = {...element.props.style, ...props.style};
}
if (props.className && element.props.className) {
props.className = `${element.props.className} ${props.className}`;
}
return React.cloneElement(element, props);
};

View File

@@ -0,0 +1,17 @@
.react-resizable {
position: relative;
}
.react-resizable-handle {
position: absolute;
width: 20px;
height: 20px;
bottom: 0;
right: 0;
background: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2IDYiIHN0eWxlPSJiYWNrZ3JvdW5kLWNvbG9yOiNmZmZmZmYwMCIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSI2cHgiIGhlaWdodD0iNnB4Ij48ZyBvcGFjaXR5PSIwLjMwMiI+PHBhdGggZD0iTSA2IDYgTCAwIDYgTCAwIDQuMiBMIDQgNC4yIEwgNC4yIDQuMiBMIDQuMiAwIEwgNiAwIEwgNiA2IEwgNiA2IFoiIGZpbGw9IiMwMDAwMDAiLz48L2c+PC9zdmc+');
background-position: bottom right;
padding: 0 3px 3px 0;
background-repeat: no-repeat;
background-origin: content-box;
box-sizing: border-box;
cursor: se-resize;
}

View File

@@ -0,0 +1,7 @@
'use strict';
module.exports = function() {
throw new Error("Don't instantiate Resizable directly! Use require('react-resizable').Resizable");
};
module.exports.Resizable = require('./build/Resizable').default;
module.exports.ResizableBox = require('./build/ResizableBox').default;

View File

@@ -0,0 +1,104 @@
{
"_args": [
[
"react-resizable@1.7.5",
"C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\torrent-project"
]
],
"_from": "react-resizable@1.7.5",
"_id": "react-resizable@1.7.5",
"_inBundle": false,
"_integrity": "sha512-lauPcBsLqmxMHXHpTeOBpYenGalbSikYr8hK+lwtNYMQX1pGd2iYE+pDvZEV97nCnzuCtWM9htp7OpsBIY2Sjw==",
"_location": "/react-grid-layout/react-resizable",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "react-resizable@1.7.5",
"name": "react-resizable",
"escapedName": "react-resizable",
"rawSpec": "1.7.5",
"saveSpec": null,
"fetchSpec": "1.7.5"
},
"_requiredBy": [
"/react-grid-layout"
],
"_resolved": "https://registry.npmjs.org/react-resizable/-/react-resizable-1.7.5.tgz",
"_spec": "1.7.5",
"_where": "C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\torrent-project",
"author": {
"name": "Samuel Reed",
"email": "samuel.trace.reed@gmail.com",
"url": "http://strml.net/"
},
"bugs": {
"url": "https://github.com/STRML/react-resizable/issues"
},
"dependencies": {
"prop-types": "15.x",
"react-draggable": "^2.2.6 || ^3.0.3"
},
"description": "A component that is resizable with handles.",
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-eslint": "^8.0.1",
"babel-loader": "^7.1.2",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"cross-env": "^5.0.5",
"css-loader": "^0.28.7",
"eslint": "^4.7.2",
"eslint-plugin-react": "^7.4.0",
"flow-bin": "^0.55.0",
"lodash": "^4.3.0",
"pre-commit": "^1.1.2",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"style-loader": "^0.18.2",
"webpack": "^3.6.0",
"webpack-dev-server": "^2.8.2"
},
"homepage": "https://github.com/STRML/react-resizable",
"keywords": [
"react",
"resize",
"resizable"
],
"license": "MIT",
"main": "index.js",
"name": "react-resizable",
"peerDependencies": {
"react": "0.14.x || 15.x || 16.x",
"react-dom": "0.14.x || 15.x || 16.x"
},
"pre-commit": [
"lint",
"validate"
],
"publishConfig": {
"registry": "https://registry.npmjs.org"
},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/STRML/react-resizable.git"
},
"scripts": {
"build": "bash build.sh",
"build-example": "webpack",
"dev": "webpack-dev-server --open --open-page=examples/1.html",
"flow": "flow",
"lint": "eslint --ext .js,.jsx lib/ test/; flow",
"postversion": "git push && git push --tags",
"prepare": "npm run build",
"preversion": "npm run lint",
"test": "echo \"Error: no test specified\" && exit 1",
"validate": "yarn check",
"version": "git add CHANGELOG.md",
"watch": "webpack --progress --watch"
},
"version": "1.7.5"
}