react-resizable 1.7.2 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintrc CHANGED
@@ -24,9 +24,6 @@
24
24
  "browser": true,
25
25
  "node": true
26
26
  },
27
- "ecmaFeatures": {
28
- "jsx": true
29
- },
30
27
  "globals": {
31
28
  // For Flow
32
29
  "ReactElement",
package/.flowconfig CHANGED
@@ -1,8 +1,12 @@
1
+ [version]
2
+ ^0.98.0
3
+
1
4
  [ignore]
2
5
  .*/node_modules/babel.*
3
6
  .*/node_modules/fbjs/.*
4
7
  .*/node_modules/express/.*
5
8
  .*/node_modules/serve-index/.*
9
+ <PROJECT_ROOT>/build/.*
6
10
 
7
11
  [include]
8
12
 
@@ -24,4 +28,3 @@ module.system.node.resolve_dirname=node_modules
24
28
  module.system.node.resolve_dirname=.
25
29
  module.use_strict=true
26
30
  server.max_workers=6
27
- unsafe.enable_getters_and_setters=true
@@ -19,5 +19,5 @@ OS:
19
19
  #### Reproduction
20
20
 
21
21
  If this is a bug report, please provide a reproduction of the issue by going to
22
- http://www.webpackbin.com/41YFBvekG.
22
+ https://codesandbox.io/s/9229wz40yo?fontsize=14.
23
23
  Paste a link here to your working reproduction.
@@ -1,6 +1,5 @@
1
1
  Thanks for submitting a pull request to React-Resizable!
2
2
 
3
- Please reference an open issue. If one has not been created, please create one along with a failing
4
- example or test case.
3
+ Please reference an open issue. If one has not been created, please create one along with a failing example or test case.
5
4
 
6
5
  Please do not commit built files (`/dist`) to pull requests. They are built only at release.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ### 1.8.0 (May 15 2019)
4
+
5
+ - Added support for custom resize handles (https://github.com/STRML/react-resizable/pull/79)
6
+ - Added support for resize handles on all corners (https://github.com/STRML/react-resizable/pull/191)
7
+
8
+ ### 1.7.5 (Sep 26, 2017)
9
+
10
+ - Support for React 16 (no changes required, updated `peerDependencies`)
11
+ - Minor dep updates.
12
+
13
+ ### 1.7.4 (Sep 5, 2017)
14
+
15
+ - Minor Flow & dependency updates.
16
+
17
+ ### 1.7.3 (Aug 31, 2017)
18
+
19
+ - Fix React deprecation warnings from `import *`
20
+ - https://github.com/facebook/react/issues/10583
21
+
3
22
  ### 1.7.2 (Aug 21, 2017)
4
23
 
5
24
  - Pkg: Add `react-draggable@3.0.0` to version range.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016-2018 Samuel Reed
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [View the Demo](https://strml.github.io/react-resizable/examples/1.html)
4
4
 
5
- A simple widget that can be resized via a handle.
5
+ A simple widget that can be resized via one or more handles.
6
6
 
7
7
  You can either use the `<Resizable>` element directly, or use the much simpler `<ResizableBox>` element.
8
8
 
@@ -50,6 +50,8 @@ These props apply to both `<Resizable>` and `<ResizableBox>`.
50
50
  children: React.Element<any>,
51
51
  width: number,
52
52
  height: number,
53
+ // Either a ReactElement to be used as handle, or a function returning an element that is fed the handle's location as its first argument.
54
+ handle: ReactElement<any> | (resizeHandle: 's' | 'w' | 'e' | 'n' | 'sw' | 'nw' | 'se' | 'ne') => ReactElement<any>,
53
55
  // If you change this, be sure to update your css
54
56
  handleSize: [number, number] = [10, 10],
55
57
  lockAspectRatio: boolean = false,
@@ -59,6 +61,7 @@ These props apply to both `<Resizable>` and `<ResizableBox>`.
59
61
  onResizeStop?: ?(e: SyntheticEvent, data: ResizeCallbackData) => any,
60
62
  onResizeStart?: ?(e: SyntheticEvent, data: ResizeCallbackData) => any,
61
63
  onResize?: ?(e: SyntheticEvent, data: ResizeCallbackData) => any,
62
- draggableOpts?: ?Object
64
+ draggableOpts?: ?Object,
65
+ resizeHandles?: ?Array<'s' | 'w' | 'e' | 'n' | 'sw' | 'nw' | 'se' | 'ne'> = ['se']
63
66
  };
64
67
  ```
@@ -6,7 +6,7 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument
6
6
 
7
7
  var _react = require('react');
8
8
 
9
- var React = _interopRequireWildcard(_react);
9
+ var _react2 = _interopRequireDefault(_react);
10
10
 
11
11
  var _propTypes = require('prop-types');
12
12
 
@@ -20,8 +20,6 @@ var _cloneElement2 = _interopRequireDefault(_cloneElement);
20
20
 
21
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
22
 
23
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
24
-
25
23
  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; }
26
24
 
27
25
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -123,7 +121,7 @@ var Resizable = function (_React$Component) {
123
121
  */
124
122
 
125
123
 
126
- Resizable.prototype.resizeHandler = function resizeHandler(handlerName) {
124
+ Resizable.prototype.resizeHandler = function resizeHandler(handlerName, axis) {
127
125
  var _this2 = this;
128
126
 
129
127
  return function (e, _ref2) {
@@ -133,8 +131,16 @@ var Resizable = function (_React$Component) {
133
131
 
134
132
 
135
133
  // Axis restrictions
136
- var canDragX = _this2.props.axis === 'both' || _this2.props.axis === 'x';
137
- var canDragY = _this2.props.axis === 'both' || _this2.props.axis === 'y';
134
+ var canDragX = (_this2.props.axis === 'both' || _this2.props.axis === 'x') && ['n', 's'].indexOf(axis) === -1;
135
+ var canDragY = (_this2.props.axis === 'both' || _this2.props.axis === 'y') && ['e', 'w'].indexOf(axis) === -1;
136
+
137
+ // reverse delta if using top or left drag handles
138
+ if (canDragX && axis[axis.length - 1] === 'w') {
139
+ deltaX = -deltaX;
140
+ }
141
+ if (canDragY && axis[0] === 'n') {
142
+ deltaY = -deltaY;
143
+ }
138
144
 
139
145
  // Update w/h
140
146
  var width = _this2.state.width + (canDragX ? deltaX : 0);
@@ -165,9 +171,10 @@ var Resizable = function (_React$Component) {
165
171
 
166
172
  var hasCb = typeof _this2.props[handlerName] === 'function';
167
173
  if (hasCb) {
174
+ // $FlowIgnore isn't refining this correctly to SyntheticEvent
168
175
  if (typeof e.persist === 'function') e.persist();
169
176
  _this2.setState(newState, function () {
170
- return _this2.props[handlerName](e, { node: node, size: { width: width, height: height } });
177
+ return _this2.props[handlerName](e, { node: node, size: { width: width, height: height }, handle: axis });
171
178
  });
172
179
  } else {
173
180
  _this2.setState(newState);
@@ -175,7 +182,21 @@ var Resizable = function (_React$Component) {
175
182
  };
176
183
  };
177
184
 
185
+ Resizable.prototype.renderResizeHandle = function renderResizeHandle(resizeHandle) {
186
+ var handle = this.props.handle;
187
+
188
+ if (handle) {
189
+ if (typeof handle === 'function') {
190
+ return handle(resizeHandle);
191
+ }
192
+ return handle;
193
+ }
194
+ return _react2.default.createElement('span', { className: 'react-resizable-handle react-resizable-handle-' + resizeHandle });
195
+ };
196
+
178
197
  Resizable.prototype.render = function render() {
198
+ var _this3 = this;
199
+
179
200
  // eslint-disable-next-line no-unused-vars
180
201
  var _props = this.props,
181
202
  children = _props.children,
@@ -190,31 +211,34 @@ var Resizable = function (_React$Component) {
190
211
  onResize = _props.onResize,
191
212
  onResizeStop = _props.onResizeStop,
192
213
  onResizeStart = _props.onResizeStart,
193
- p = _objectWithoutProperties(_props, ['children', 'draggableOpts', 'width', 'height', 'handleSize', 'lockAspectRatio', 'axis', 'minConstraints', 'maxConstraints', 'onResize', 'onResizeStop', 'onResizeStart']);
214
+ resizeHandles = _props.resizeHandles,
215
+ p = _objectWithoutProperties(_props, ['children', 'draggableOpts', 'width', 'height', 'handleSize', 'lockAspectRatio', 'axis', 'minConstraints', 'maxConstraints', 'onResize', 'onResizeStop', 'onResizeStart', 'resizeHandles']);
194
216
 
195
217
  var className = p.className ? p.className + ' react-resizable' : 'react-resizable';
196
218
 
197
219
  // What we're doing here is getting the child of this element, and cloning it with this element's props.
198
220
  // We are then defining its children as:
199
221
  // Its original children (resizable's child's children), and
200
- // A draggable handle.
222
+ // One or more draggable handles.
201
223
  return (0, _cloneElement2.default)(children, _extends({}, p, {
202
224
  className: className,
203
- children: [children.props.children, React.createElement(
204
- _reactDraggable.DraggableCore,
205
- _extends({}, draggableOpts, {
206
- key: 'resizableHandle',
207
- onStop: this.resizeHandler('onResizeStop'),
208
- onStart: this.resizeHandler('onResizeStart'),
209
- onDrag: this.resizeHandler('onResize')
210
- }),
211
- React.createElement('span', { className: 'react-resizable-handle' })
212
- )]
225
+ children: [children.props.children, resizeHandles.map(function (h) {
226
+ return _react2.default.createElement(
227
+ _reactDraggable.DraggableCore,
228
+ _extends({}, draggableOpts, {
229
+ key: 'resizableHandle-' + h,
230
+ onStop: _this3.resizeHandler('onResizeStop', h),
231
+ onStart: _this3.resizeHandler('onResizeStart', h),
232
+ onDrag: _this3.resizeHandler('onResize', h)
233
+ }),
234
+ _this3.renderResizeHandle(h)
235
+ );
236
+ })]
213
237
  }));
214
238
  };
215
239
 
216
240
  return Resizable;
217
- }(React.Component);
241
+ }(_react2.default.Component);
218
242
 
219
243
  Resizable.propTypes = {
220
244
  //
@@ -232,9 +256,24 @@ Resizable.propTypes = {
232
256
  // Optional props
233
257
  //
234
258
 
259
+ // Custom resize handle
260
+ handle: _propTypes2.default.element,
261
+
235
262
  // If you change this, be sure to update your css
236
263
  handleSize: _propTypes2.default.array,
237
264
 
265
+ // Defines which resize handles should be rendered (default: 'se')
266
+ // Allows for any combination of:
267
+ // 's' - South handle (bottom-center)
268
+ // 'w' - West handle (left-center)
269
+ // 'e' - East handle (right-center)
270
+ // 'n' - North handle (top-center)
271
+ // 'sw' - Southwest handle (bottom-left)
272
+ // 'nw' - Northwest handle (top-left)
273
+ // 'se' - Southeast handle (bottom-right)
274
+ // 'ne' - Northeast handle (top-center)
275
+ resizeHandles: _propTypes2.default.arrayOf(_propTypes2.default.oneOf(['s', 'w', 'e', 'n', 'sw', 'nw', 'se', 'ne'])),
276
+
238
277
  // If true, will only allow width/height to move in lockstep
239
278
  lockAspectRatio: _propTypes2.default.bool,
240
279
 
@@ -262,6 +301,7 @@ Resizable.defaultProps = {
262
301
  lockAspectRatio: false,
263
302
  axis: 'both',
264
303
  minConstraints: [20, 20],
265
- maxConstraints: [Infinity, Infinity]
304
+ maxConstraints: [Infinity, Infinity],
305
+ resizeHandles: ['se']
266
306
  };
267
307
  exports.default = Resizable;
@@ -1,10 +1,12 @@
1
1
  // @flow
2
- import * as React from 'react';
2
+ import React from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import {DraggableCore} from 'react-draggable';
5
5
  import cloneElement from './cloneElement';
6
+ import type {Element as ReactElement, Node as ReactNode} from 'react';
6
7
 
7
8
  type Axis = 'both' | 'x' | 'y' | 'none';
9
+ type ResizeHandle = 's' | 'w' | 'e' | 'n' | 'sw' | 'nw' | 'se' | 'ne';
8
10
  type State = {
9
11
  resizing: boolean,
10
12
  width: number, height: number,
@@ -18,12 +20,15 @@ type DragCallbackData = {
18
20
  };
19
21
  export type ResizeCallbackData = {
20
22
  node: HTMLElement,
21
- size: {width: number, height: number}
23
+ size: {width: number, height: number},
24
+ handle: ResizeHandle
22
25
  };
23
26
  export type Props = {
24
- children: React.Element<any>,
27
+ children: ReactElement<any>,
28
+ className?: ?string,
25
29
  width: number,
26
30
  height: number,
31
+ handle: ReactElement<any> | (resizeHandle: ResizeHandle) => ReactElement<any>,
27
32
  handleSize: [number, number],
28
33
  lockAspectRatio: boolean,
29
34
  axis: Axis,
@@ -32,7 +37,8 @@ export type Props = {
32
37
  onResizeStop?: ?(e: SyntheticEvent<>, data: ResizeCallbackData) => any,
33
38
  onResizeStart?: ?(e: SyntheticEvent<>, data: ResizeCallbackData) => any,
34
39
  onResize?: ?(e: SyntheticEvent<>, data: ResizeCallbackData) => any,
35
- draggableOpts?: ?Object
40
+ draggableOpts?: ?Object,
41
+ resizeHandles: ResizeHandle[]
36
42
  };
37
43
 
38
44
  export default class Resizable extends React.Component<Props, State> {
@@ -52,9 +58,24 @@ export default class Resizable extends React.Component<Props, State> {
52
58
  // Optional props
53
59
  //
54
60
 
61
+ // Custom resize handle
62
+ handle: PropTypes.element,
63
+
55
64
  // If you change this, be sure to update your css
56
65
  handleSize: PropTypes.array,
57
66
 
67
+ // Defines which resize handles should be rendered (default: 'se')
68
+ // Allows for any combination of:
69
+ // 's' - South handle (bottom-center)
70
+ // 'w' - West handle (left-center)
71
+ // 'e' - East handle (right-center)
72
+ // 'n' - North handle (top-center)
73
+ // 'sw' - Southwest handle (bottom-left)
74
+ // 'nw' - Northwest handle (top-left)
75
+ // 'se' - Southeast handle (bottom-right)
76
+ // 'ne' - Northeast handle (top-center)
77
+ resizeHandles: PropTypes.arrayOf(PropTypes.oneOf(['s', 'w', 'e', 'n', 'sw', 'nw', 'se', 'ne'])),
78
+
58
79
  // If true, will only allow width/height to move in lockstep
59
80
  lockAspectRatio: PropTypes.bool,
60
81
 
@@ -83,7 +104,8 @@ export default class Resizable extends React.Component<Props, State> {
83
104
  lockAspectRatio: false,
84
105
  axis: 'both',
85
106
  minConstraints: [20, 20],
86
- maxConstraints: [Infinity, Infinity]
107
+ maxConstraints: [Infinity, Infinity],
108
+ resizeHandles: ['se']
87
109
  };
88
110
 
89
111
  state: State = {
@@ -155,12 +177,20 @@ export default class Resizable extends React.Component<Props, State> {
155
177
  * @param {String} handlerName Handler name to wrap.
156
178
  * @return {Function} Handler function.
157
179
  */
158
- resizeHandler(handlerName: string): Function {
180
+ resizeHandler(handlerName: string, axis: ResizeHandle): Function {
159
181
  return (e: SyntheticEvent<> | MouseEvent, {node, deltaX, deltaY}: DragCallbackData) => {
160
182
 
161
183
  // Axis restrictions
162
- const canDragX = this.props.axis === 'both' || this.props.axis === 'x';
163
- const canDragY = this.props.axis === 'both' || this.props.axis === 'y';
184
+ const canDragX = (this.props.axis === 'both' || this.props.axis === 'x') && ['n', 's'].indexOf(axis) === -1;
185
+ const canDragY = (this.props.axis === 'both' || this.props.axis === 'y') && ['e', 'w'].indexOf(axis) === -1;
186
+
187
+ // reverse delta if using top or left drag handles
188
+ if (canDragX && axis[axis.length - 1] === 'w') {
189
+ deltaX = -deltaX;
190
+ }
191
+ if (canDragY && axis[0] === 'n') {
192
+ deltaY = -deltaY;
193
+ }
164
194
 
165
195
  // Update w/h
166
196
  let width = this.state.width + (canDragX ? deltaX : 0);
@@ -188,19 +218,31 @@ export default class Resizable extends React.Component<Props, State> {
188
218
 
189
219
  const hasCb = typeof this.props[handlerName] === 'function';
190
220
  if (hasCb) {
221
+ // $FlowIgnore isn't refining this correctly to SyntheticEvent
191
222
  if (typeof e.persist === 'function') e.persist();
192
- this.setState(newState, () => this.props[handlerName](e, {node, size: {width, height}}));
223
+ this.setState(newState, () => this.props[handlerName](e, {node, size: {width, height}, handle: axis}));
193
224
  } else {
194
225
  this.setState(newState);
195
226
  }
196
227
  };
197
228
  }
198
229
 
199
- render(): React.Node {
230
+ renderResizeHandle(resizeHandle: ResizeHandle): ReactNode {
231
+ const {handle} = this.props;
232
+ if (handle) {
233
+ if (typeof handle === 'function') {
234
+ return handle(resizeHandle);
235
+ }
236
+ return handle;
237
+ }
238
+ return <span className={`react-resizable-handle react-resizable-handle-${resizeHandle}`} />;
239
+ }
240
+
241
+ render(): ReactNode {
200
242
  // eslint-disable-next-line no-unused-vars
201
243
  const {children, draggableOpts, width, height, handleSize,
202
244
  lockAspectRatio, axis, minConstraints, maxConstraints, onResize,
203
- onResizeStop, onResizeStart, ...p} = this.props;
245
+ onResizeStop, onResizeStart, resizeHandles, ...p} = this.props;
204
246
 
205
247
  const className = p.className ?
206
248
  `${p.className} react-resizable`:
@@ -209,21 +251,23 @@ export default class Resizable extends React.Component<Props, State> {
209
251
  // What we're doing here is getting the child of this element, and cloning it with this element's props.
210
252
  // We are then defining its children as:
211
253
  // Its original children (resizable's child's children), and
212
- // A draggable handle.
254
+ // One or more draggable handles.
213
255
  return cloneElement(children, {
214
256
  ...p,
215
257
  className,
216
258
  children: [
217
259
  children.props.children,
218
- <DraggableCore
219
- {...draggableOpts}
220
- key="resizableHandle"
221
- onStop={this.resizeHandler('onResizeStop')}
222
- onStart={this.resizeHandler('onResizeStart')}
223
- onDrag={this.resizeHandler('onResize')}
260
+ resizeHandles.map(h => (
261
+ <DraggableCore
262
+ {...draggableOpts}
263
+ key={`resizableHandle-${h}`}
264
+ onStop={this.resizeHandler('onResizeStop', h)}
265
+ onStart={this.resizeHandler('onResizeStart', h)}
266
+ onDrag={this.resizeHandler('onResize', h)}
224
267
  >
225
- <span className="react-resizable-handle" />
226
- </DraggableCore>
268
+ {this.renderResizeHandle(h)}
269
+ </DraggableCore>
270
+ ))
227
271
  ]
228
272
  });
229
273
  }
@@ -6,7 +6,7 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument
6
6
 
7
7
  var _react = require('react');
8
8
 
9
- var React = _interopRequireWildcard(_react);
9
+ var _react2 = _interopRequireDefault(_react);
10
10
 
11
11
  var _propTypes = require('prop-types');
12
12
 
@@ -18,8 +18,6 @@ var _Resizable2 = _interopRequireDefault(_Resizable);
18
18
 
19
19
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
20
 
21
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
22
-
23
21
  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; }
24
22
 
25
23
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -75,6 +73,7 @@ var ResizableBox = function (_React$Component) {
75
73
  // If you use Resizable directly, you are responsible for updating the child component
76
74
  // with a new width and height.
77
75
  var _props = this.props,
76
+ handle = _props.handle,
78
77
  handleSize = _props.handleSize,
79
78
  onResize = _props.onResize,
80
79
  onResizeStart = _props.onResizeStart,
@@ -86,11 +85,13 @@ var ResizableBox = function (_React$Component) {
86
85
  axis = _props.axis,
87
86
  width = _props.width,
88
87
  height = _props.height,
89
- props = _objectWithoutProperties(_props, ['handleSize', 'onResize', 'onResizeStart', 'onResizeStop', 'draggableOpts', 'minConstraints', 'maxConstraints', 'lockAspectRatio', 'axis', 'width', 'height']);
88
+ resizeHandles = _props.resizeHandles,
89
+ props = _objectWithoutProperties(_props, ['handle', 'handleSize', 'onResize', 'onResizeStart', 'onResizeStop', 'draggableOpts', 'minConstraints', 'maxConstraints', 'lockAspectRatio', 'axis', 'width', 'height', 'resizeHandles']);
90
90
 
91
- return React.createElement(
91
+ return _react2.default.createElement(
92
92
  _Resizable2.default,
93
93
  {
94
+ handle: handle,
94
95
  handleSize: handleSize,
95
96
  width: this.state.width,
96
97
  height: this.state.height,
@@ -101,14 +102,15 @@ var ResizableBox = function (_React$Component) {
101
102
  minConstraints: minConstraints,
102
103
  maxConstraints: maxConstraints,
103
104
  lockAspectRatio: lockAspectRatio,
104
- axis: axis
105
+ axis: axis,
106
+ resizeHandles: resizeHandles
105
107
  },
106
- React.createElement('div', _extends({ style: { width: this.state.width + 'px', height: this.state.height + 'px' } }, props))
108
+ _react2.default.createElement('div', _extends({ style: { width: this.state.width + 'px', height: this.state.height + 'px' } }, props))
107
109
  );
108
110
  };
109
111
 
110
112
  return ResizableBox;
111
- }(React.Component);
113
+ }(_react2.default.Component);
112
114
 
113
115
  ResizableBox.propTypes = {
114
116
  height: _propTypes2.default.number,
@@ -1,8 +1,9 @@
1
1
  // @flow
2
- import * as React from 'react';
2
+ import React from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import Resizable from './Resizable';
5
5
  import type {Props as ResizableProps, ResizeCallbackData} from './Resizable';
6
+ import type {Node as ReactNode} from 'react';
6
7
 
7
8
  type State = {width: number, height: number};
8
9
 
@@ -43,14 +44,15 @@ export default class ResizableBox extends React.Component<ResizableProps, State>
43
44
  }
44
45
  }
45
46
 
46
- render(): React.Node {
47
+ render(): ReactNode {
47
48
  // Basic wrapper around a Resizable instance.
48
49
  // If you use Resizable directly, you are responsible for updating the child component
49
50
  // with a new width and height.
50
- const {handleSize, onResize, onResizeStart, onResizeStop, draggableOpts,
51
- minConstraints, maxConstraints, lockAspectRatio, axis, width, height, ...props} = this.props;
51
+ const {handle, handleSize, onResize, onResizeStart, onResizeStop, draggableOpts, minConstraints,
52
+ maxConstraints, lockAspectRatio, axis, width, height, resizeHandles, ...props} = this.props;
52
53
  return (
53
54
  <Resizable
55
+ handle={handle}
54
56
  handleSize={handleSize}
55
57
  width={this.state.width}
56
58
  height={this.state.height}
@@ -62,7 +64,8 @@ export default class ResizableBox extends React.Component<ResizableProps, State>
62
64
  maxConstraints={maxConstraints}
63
65
  lockAspectRatio={lockAspectRatio}
64
66
  axis={axis}
65
- >
67
+ resizeHandles={resizeHandles}
68
+ >
66
69
  <div style={{width: this.state.width + 'px', height: this.state.height + 'px'}} {...props} />
67
70
  </Resizable>
68
71
  );
@@ -4,9 +4,9 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument
4
4
 
5
5
  var _react = require('react');
6
6
 
7
- var React = _interopRequireWildcard(_react);
7
+ var _react2 = _interopRequireDefault(_react);
8
8
 
9
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
10
 
11
11
  // React.addons.cloneWithProps look-alike that merges style & className.
12
12
  module.exports = function cloneElement(element, props) {
@@ -16,5 +16,5 @@ module.exports = function cloneElement(element, props) {
16
16
  if (props.className && element.props.className) {
17
17
  props.className = element.props.className + ' ' + props.className;
18
18
  }
19
- return React.cloneElement(element, props);
19
+ return _react2.default.cloneElement(element, props);
20
20
  };
@@ -1,8 +1,9 @@
1
1
  // @flow
2
- import * as React from 'react';
2
+ import React from 'react';
3
+ import type {Element as ReactElement} from 'react';
3
4
 
4
5
  // React.addons.cloneWithProps look-alike that merges style & className.
5
- module.exports = function cloneElement(element: React.Element<any>, props: Object): React.Element<any> {
6
+ module.exports = function cloneElement(element: ReactElement<any>, props: Object): ReactElement<any> {
6
7
  if (props.style && element.props.style) {
7
8
  props.style = {...element.props.style, ...props.style};
8
9
  }
package/css/styles.css CHANGED
@@ -5,13 +5,61 @@
5
5
  position: absolute;
6
6
  width: 20px;
7
7
  height: 20px;
8
- bottom: 0;
9
- right: 0;
10
- background: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2IDYiIHN0eWxlPSJiYWNrZ3JvdW5kLWNvbG9yOiNmZmZmZmYwMCIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSI2cHgiIGhlaWdodD0iNnB4Ij48ZyBvcGFjaXR5PSIwLjMwMiI+PHBhdGggZD0iTSA2IDYgTCAwIDYgTCAwIDQuMiBMIDQgNC4yIEwgNC4yIDQuMiBMIDQuMiAwIEwgNiAwIEwgNiA2IEwgNiA2IFoiIGZpbGw9IiMwMDAwMDAiLz48L2c+PC9zdmc+');
11
- background-position: bottom right;
12
- padding: 0 3px 3px 0;
13
8
  background-repeat: no-repeat;
14
9
  background-origin: content-box;
15
10
  box-sizing: border-box;
11
+ background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2IDYiIHN0eWxlPSJiYWNrZ3JvdW5kLWNvbG9yOiNmZmZmZmYwMCIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSI2cHgiIGhlaWdodD0iNnB4Ij48ZyBvcGFjaXR5PSIwLjMwMiI+PHBhdGggZD0iTSA2IDYgTCAwIDYgTCAwIDQuMiBMIDQgNC4yIEwgNC4yIDQuMiBMIDQuMiAwIEwgNiAwIEwgNiA2IEwgNiA2IFoiIGZpbGw9IiMwMDAwMDAiLz48L2c+PC9zdmc+');
12
+ background-position: bottom right;
13
+ padding: 0 3px 3px 0;
14
+ }
15
+ .react-resizable-handle-sw {
16
+ bottom: 0;
17
+ left: 0;
18
+ cursor: sw-resize;
19
+ transform: rotate(90deg);
20
+ }
21
+ .react-resizable-handle-se {
22
+ bottom: 0;
23
+ right: 0;
16
24
  cursor: se-resize;
17
25
  }
26
+ .react-resizable-handle-nw {
27
+ top: 0;
28
+ left: 0;
29
+ cursor: nw-resize;
30
+ transform: rotate(180deg);
31
+ }
32
+ .react-resizable-handle-ne {
33
+ top: 0;
34
+ right: 0;
35
+ cursor: ne-resize;
36
+ transform: rotate(270deg);
37
+ }
38
+ .react-resizable-handle-w,
39
+ .react-resizable-handle-e {
40
+ top: 50%;
41
+ margin-top: -10px;
42
+ cursor: ew-resize;
43
+ }
44
+ .react-resizable-handle-w {
45
+ left: 0;
46
+ transform: rotate(135deg);
47
+ }
48
+ .react-resizable-handle-e {
49
+ right: 0;
50
+ transform: rotate(315deg);
51
+ }
52
+ .react-resizable-handle-n,
53
+ .react-resizable-handle-s {
54
+ left: 50%;
55
+ margin-left: -10px;
56
+ cursor: ns-resize;
57
+ }
58
+ .react-resizable-handle-n {
59
+ top: 0;
60
+ transform: rotate(225deg);
61
+ }
62
+ .react-resizable-handle-s {
63
+ bottom: 0;
64
+ transform: rotate(45deg);
65
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-resizable",
3
- "version": "1.7.2",
3
+ "version": "1.8.0",
4
4
  "description": "A component that is resizable with handles.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -10,11 +10,12 @@
10
10
  "build-example": "webpack",
11
11
  "dev": "webpack-dev-server --open --open-page=examples/1.html",
12
12
  "watch": "webpack --progress --watch",
13
- "prepublish": "npm run build",
14
- "validate": "yarn list",
13
+ "prepare": "npm run build",
14
+ "validate": "yarn check",
15
15
  "preversion": "npm run lint",
16
16
  "version": "git add CHANGELOG.md",
17
- "postversion": "git push && git push --tags"
17
+ "postversion": "git push && git push --tags",
18
+ "flow": "flow"
18
19
  },
19
20
  "repository": {
20
21
  "type": "git",
@@ -34,32 +35,32 @@
34
35
  "devDependencies": {
35
36
  "babel-cli": "^6.26.0",
36
37
  "babel-core": "^6.26.0",
37
- "babel-eslint": "^7.2.3",
38
- "babel-loader": "^7.1.2",
38
+ "babel-eslint": "^10.0.1",
39
+ "babel-loader": "^8.0.6",
39
40
  "babel-plugin-transform-class-properties": "^6.24.1",
40
41
  "babel-plugin-transform-object-rest-spread": "^6.26.0",
41
42
  "babel-preset-es2015": "^6.24.1",
42
43
  "babel-preset-react": "^6.24.1",
43
44
  "cross-env": "^5.0.5",
44
- "css-loader": "^0.28.5",
45
- "eslint": "^4.5.0",
46
- "eslint-plugin-react": "^7.2.1",
47
- "flow-bin": "^0.53.1",
45
+ "css-loader": "^2.1.1",
46
+ "eslint": "^5.16.0",
47
+ "eslint-plugin-react": "^7.4.0",
48
+ "flow-bin": "^0.98.1",
48
49
  "lodash": "^4.3.0",
49
50
  "pre-commit": "^1.1.2",
50
- "react": "^15.6.1",
51
- "react-dom": "^15.6.1",
52
- "style-loader": "^0.18.2",
53
- "webpack": "^3.5.5",
54
- "webpack-dev-server": "^2.7.1"
51
+ "react": "^16.0.0",
52
+ "react-dom": "^16.0.0",
53
+ "style-loader": "^0.23.1",
54
+ "webpack": "^4.31.0",
55
+ "webpack-dev-server": "^3.3.1"
55
56
  },
56
57
  "dependencies": {
57
- "prop-types": "^15.5.8",
58
- "react-draggable": "^2.2.6 || ^3.0.0"
58
+ "prop-types": "15.x",
59
+ "react-draggable": "^3.0.3"
59
60
  },
60
61
  "peerDependencies": {
61
- "react": "^0.14.0 || ^15.0.0",
62
- "react-dom": "^0.14.0 || ^15.0.0"
62
+ "react": "0.14.x || 15.x || 16.x",
63
+ "react-dom": "0.14.x || 15.x || 16.x"
63
64
  },
64
65
  "publishConfig": {
65
66
  "registry": "https://registry.npmjs.org"
package/.npmignore DELETED
@@ -1,6 +0,0 @@
1
- examples/
2
- test/
3
- lib/
4
- build.sh
5
- *.config.js
6
- yarn.lock