react-resizable 1.7.5 → 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/.flowconfig +1 -2
- package/.github/ISSUE_TEMPLATE.md +1 -1
- package/.github/PULL_REQUEST_TEMPLATE.md +1 -2
- package/CHANGELOG.md +5 -0
- package/LICENSE +21 -0
- package/README.md +5 -2
- package/build/Resizable.js +59 -17
- package/build/Resizable.js.flow +59 -17
- package/build/ResizableBox.js +6 -2
- package/build/ResizableBox.js.flow +5 -3
- package/css/styles.css +53 -5
- package/package.json +10 -10
package/.flowconfig
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[version]
|
|
2
|
-
0.
|
|
2
|
+
^0.98.0
|
|
3
3
|
|
|
4
4
|
[ignore]
|
|
5
5
|
.*/node_modules/babel.*
|
|
@@ -28,4 +28,3 @@ module.system.node.resolve_dirname=node_modules
|
|
|
28
28
|
module.system.node.resolve_dirname=.
|
|
29
29
|
module.use_strict=true
|
|
30
30
|
server.max_workers=6
|
|
31
|
-
unsafe.enable_getters_and_setters=true
|
|
@@ -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,10 @@
|
|
|
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
|
+
|
|
3
8
|
### 1.7.5 (Sep 26, 2017)
|
|
4
9
|
|
|
5
10
|
- Support for React 16 (no changes required, updated `peerDependencies`)
|
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
|
|
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
|
```
|
package/build/Resizable.js
CHANGED
|
@@ -121,7 +121,7 @@ var Resizable = function (_React$Component) {
|
|
|
121
121
|
*/
|
|
122
122
|
|
|
123
123
|
|
|
124
|
-
Resizable.prototype.resizeHandler = function resizeHandler(handlerName) {
|
|
124
|
+
Resizable.prototype.resizeHandler = function resizeHandler(handlerName, axis) {
|
|
125
125
|
var _this2 = this;
|
|
126
126
|
|
|
127
127
|
return function (e, _ref2) {
|
|
@@ -131,8 +131,16 @@ var Resizable = function (_React$Component) {
|
|
|
131
131
|
|
|
132
132
|
|
|
133
133
|
// Axis restrictions
|
|
134
|
-
var canDragX = _this2.props.axis === 'both' || _this2.props.axis === 'x';
|
|
135
|
-
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
|
+
}
|
|
136
144
|
|
|
137
145
|
// Update w/h
|
|
138
146
|
var width = _this2.state.width + (canDragX ? deltaX : 0);
|
|
@@ -163,9 +171,10 @@ var Resizable = function (_React$Component) {
|
|
|
163
171
|
|
|
164
172
|
var hasCb = typeof _this2.props[handlerName] === 'function';
|
|
165
173
|
if (hasCb) {
|
|
174
|
+
// $FlowIgnore isn't refining this correctly to SyntheticEvent
|
|
166
175
|
if (typeof e.persist === 'function') e.persist();
|
|
167
176
|
_this2.setState(newState, function () {
|
|
168
|
-
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 });
|
|
169
178
|
});
|
|
170
179
|
} else {
|
|
171
180
|
_this2.setState(newState);
|
|
@@ -173,7 +182,21 @@ var Resizable = function (_React$Component) {
|
|
|
173
182
|
};
|
|
174
183
|
};
|
|
175
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
|
+
|
|
176
197
|
Resizable.prototype.render = function render() {
|
|
198
|
+
var _this3 = this;
|
|
199
|
+
|
|
177
200
|
// eslint-disable-next-line no-unused-vars
|
|
178
201
|
var _props = this.props,
|
|
179
202
|
children = _props.children,
|
|
@@ -188,26 +211,29 @@ var Resizable = function (_React$Component) {
|
|
|
188
211
|
onResize = _props.onResize,
|
|
189
212
|
onResizeStop = _props.onResizeStop,
|
|
190
213
|
onResizeStart = _props.onResizeStart,
|
|
191
|
-
|
|
214
|
+
resizeHandles = _props.resizeHandles,
|
|
215
|
+
p = _objectWithoutProperties(_props, ['children', 'draggableOpts', 'width', 'height', 'handleSize', 'lockAspectRatio', 'axis', 'minConstraints', 'maxConstraints', 'onResize', 'onResizeStop', 'onResizeStart', 'resizeHandles']);
|
|
192
216
|
|
|
193
217
|
var className = p.className ? p.className + ' react-resizable' : 'react-resizable';
|
|
194
218
|
|
|
195
219
|
// What we're doing here is getting the child of this element, and cloning it with this element's props.
|
|
196
220
|
// We are then defining its children as:
|
|
197
221
|
// Its original children (resizable's child's children), and
|
|
198
|
-
//
|
|
222
|
+
// One or more draggable handles.
|
|
199
223
|
return (0, _cloneElement2.default)(children, _extends({}, p, {
|
|
200
224
|
className: className,
|
|
201
|
-
children: [children.props.children,
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
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
|
+
})]
|
|
211
237
|
}));
|
|
212
238
|
};
|
|
213
239
|
|
|
@@ -230,9 +256,24 @@ Resizable.propTypes = {
|
|
|
230
256
|
// Optional props
|
|
231
257
|
//
|
|
232
258
|
|
|
259
|
+
// Custom resize handle
|
|
260
|
+
handle: _propTypes2.default.element,
|
|
261
|
+
|
|
233
262
|
// If you change this, be sure to update your css
|
|
234
263
|
handleSize: _propTypes2.default.array,
|
|
235
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
|
+
|
|
236
277
|
// If true, will only allow width/height to move in lockstep
|
|
237
278
|
lockAspectRatio: _propTypes2.default.bool,
|
|
238
279
|
|
|
@@ -260,6 +301,7 @@ Resizable.defaultProps = {
|
|
|
260
301
|
lockAspectRatio: false,
|
|
261
302
|
axis: 'both',
|
|
262
303
|
minConstraints: [20, 20],
|
|
263
|
-
maxConstraints: [Infinity, Infinity]
|
|
304
|
+
maxConstraints: [Infinity, Infinity],
|
|
305
|
+
resizeHandles: ['se']
|
|
264
306
|
};
|
|
265
307
|
exports.default = Resizable;
|
package/build/Resizable.js.flow
CHANGED
|
@@ -6,6 +6,7 @@ import cloneElement from './cloneElement';
|
|
|
6
6
|
import type {Element as ReactElement, Node as ReactNode} from 'react';
|
|
7
7
|
|
|
8
8
|
type Axis = 'both' | 'x' | 'y' | 'none';
|
|
9
|
+
type ResizeHandle = 's' | 'w' | 'e' | 'n' | 'sw' | 'nw' | 'se' | 'ne';
|
|
9
10
|
type State = {
|
|
10
11
|
resizing: boolean,
|
|
11
12
|
width: number, height: number,
|
|
@@ -19,13 +20,15 @@ type DragCallbackData = {
|
|
|
19
20
|
};
|
|
20
21
|
export type ResizeCallbackData = {
|
|
21
22
|
node: HTMLElement,
|
|
22
|
-
size: {width: number, height: number}
|
|
23
|
+
size: {width: number, height: number},
|
|
24
|
+
handle: ResizeHandle
|
|
23
25
|
};
|
|
24
26
|
export type Props = {
|
|
25
27
|
children: ReactElement<any>,
|
|
26
28
|
className?: ?string,
|
|
27
29
|
width: number,
|
|
28
30
|
height: number,
|
|
31
|
+
handle: ReactElement<any> | (resizeHandle: ResizeHandle) => ReactElement<any>,
|
|
29
32
|
handleSize: [number, number],
|
|
30
33
|
lockAspectRatio: boolean,
|
|
31
34
|
axis: Axis,
|
|
@@ -34,7 +37,8 @@ export type Props = {
|
|
|
34
37
|
onResizeStop?: ?(e: SyntheticEvent<>, data: ResizeCallbackData) => any,
|
|
35
38
|
onResizeStart?: ?(e: SyntheticEvent<>, data: ResizeCallbackData) => any,
|
|
36
39
|
onResize?: ?(e: SyntheticEvent<>, data: ResizeCallbackData) => any,
|
|
37
|
-
draggableOpts?: ?Object
|
|
40
|
+
draggableOpts?: ?Object,
|
|
41
|
+
resizeHandles: ResizeHandle[]
|
|
38
42
|
};
|
|
39
43
|
|
|
40
44
|
export default class Resizable extends React.Component<Props, State> {
|
|
@@ -54,9 +58,24 @@ export default class Resizable extends React.Component<Props, State> {
|
|
|
54
58
|
// Optional props
|
|
55
59
|
//
|
|
56
60
|
|
|
61
|
+
// Custom resize handle
|
|
62
|
+
handle: PropTypes.element,
|
|
63
|
+
|
|
57
64
|
// If you change this, be sure to update your css
|
|
58
65
|
handleSize: PropTypes.array,
|
|
59
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
|
+
|
|
60
79
|
// If true, will only allow width/height to move in lockstep
|
|
61
80
|
lockAspectRatio: PropTypes.bool,
|
|
62
81
|
|
|
@@ -85,7 +104,8 @@ export default class Resizable extends React.Component<Props, State> {
|
|
|
85
104
|
lockAspectRatio: false,
|
|
86
105
|
axis: 'both',
|
|
87
106
|
minConstraints: [20, 20],
|
|
88
|
-
maxConstraints: [Infinity, Infinity]
|
|
107
|
+
maxConstraints: [Infinity, Infinity],
|
|
108
|
+
resizeHandles: ['se']
|
|
89
109
|
};
|
|
90
110
|
|
|
91
111
|
state: State = {
|
|
@@ -157,12 +177,20 @@ export default class Resizable extends React.Component<Props, State> {
|
|
|
157
177
|
* @param {String} handlerName Handler name to wrap.
|
|
158
178
|
* @return {Function} Handler function.
|
|
159
179
|
*/
|
|
160
|
-
resizeHandler(handlerName: string): Function {
|
|
180
|
+
resizeHandler(handlerName: string, axis: ResizeHandle): Function {
|
|
161
181
|
return (e: SyntheticEvent<> | MouseEvent, {node, deltaX, deltaY}: DragCallbackData) => {
|
|
162
182
|
|
|
163
183
|
// Axis restrictions
|
|
164
|
-
const canDragX = this.props.axis === 'both' || this.props.axis === 'x';
|
|
165
|
-
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
|
+
}
|
|
166
194
|
|
|
167
195
|
// Update w/h
|
|
168
196
|
let width = this.state.width + (canDragX ? deltaX : 0);
|
|
@@ -190,19 +218,31 @@ export default class Resizable extends React.Component<Props, State> {
|
|
|
190
218
|
|
|
191
219
|
const hasCb = typeof this.props[handlerName] === 'function';
|
|
192
220
|
if (hasCb) {
|
|
221
|
+
// $FlowIgnore isn't refining this correctly to SyntheticEvent
|
|
193
222
|
if (typeof e.persist === 'function') e.persist();
|
|
194
|
-
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}));
|
|
195
224
|
} else {
|
|
196
225
|
this.setState(newState);
|
|
197
226
|
}
|
|
198
227
|
};
|
|
199
228
|
}
|
|
200
229
|
|
|
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
|
+
|
|
201
241
|
render(): ReactNode {
|
|
202
242
|
// eslint-disable-next-line no-unused-vars
|
|
203
243
|
const {children, draggableOpts, width, height, handleSize,
|
|
204
244
|
lockAspectRatio, axis, minConstraints, maxConstraints, onResize,
|
|
205
|
-
onResizeStop, onResizeStart, ...p} = this.props;
|
|
245
|
+
onResizeStop, onResizeStart, resizeHandles, ...p} = this.props;
|
|
206
246
|
|
|
207
247
|
const className = p.className ?
|
|
208
248
|
`${p.className} react-resizable`:
|
|
@@ -211,21 +251,23 @@ export default class Resizable extends React.Component<Props, State> {
|
|
|
211
251
|
// What we're doing here is getting the child of this element, and cloning it with this element's props.
|
|
212
252
|
// We are then defining its children as:
|
|
213
253
|
// Its original children (resizable's child's children), and
|
|
214
|
-
//
|
|
254
|
+
// One or more draggable handles.
|
|
215
255
|
return cloneElement(children, {
|
|
216
256
|
...p,
|
|
217
257
|
className,
|
|
218
258
|
children: [
|
|
219
259
|
children.props.children,
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
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)}
|
|
226
267
|
>
|
|
227
|
-
|
|
228
|
-
|
|
268
|
+
{this.renderResizeHandle(h)}
|
|
269
|
+
</DraggableCore>
|
|
270
|
+
))
|
|
229
271
|
]
|
|
230
272
|
});
|
|
231
273
|
}
|
package/build/ResizableBox.js
CHANGED
|
@@ -73,6 +73,7 @@ var ResizableBox = function (_React$Component) {
|
|
|
73
73
|
// If you use Resizable directly, you are responsible for updating the child component
|
|
74
74
|
// with a new width and height.
|
|
75
75
|
var _props = this.props,
|
|
76
|
+
handle = _props.handle,
|
|
76
77
|
handleSize = _props.handleSize,
|
|
77
78
|
onResize = _props.onResize,
|
|
78
79
|
onResizeStart = _props.onResizeStart,
|
|
@@ -84,11 +85,13 @@ var ResizableBox = function (_React$Component) {
|
|
|
84
85
|
axis = _props.axis,
|
|
85
86
|
width = _props.width,
|
|
86
87
|
height = _props.height,
|
|
87
|
-
|
|
88
|
+
resizeHandles = _props.resizeHandles,
|
|
89
|
+
props = _objectWithoutProperties(_props, ['handle', 'handleSize', 'onResize', 'onResizeStart', 'onResizeStop', 'draggableOpts', 'minConstraints', 'maxConstraints', 'lockAspectRatio', 'axis', 'width', 'height', 'resizeHandles']);
|
|
88
90
|
|
|
89
91
|
return _react2.default.createElement(
|
|
90
92
|
_Resizable2.default,
|
|
91
93
|
{
|
|
94
|
+
handle: handle,
|
|
92
95
|
handleSize: handleSize,
|
|
93
96
|
width: this.state.width,
|
|
94
97
|
height: this.state.height,
|
|
@@ -99,7 +102,8 @@ var ResizableBox = function (_React$Component) {
|
|
|
99
102
|
minConstraints: minConstraints,
|
|
100
103
|
maxConstraints: maxConstraints,
|
|
101
104
|
lockAspectRatio: lockAspectRatio,
|
|
102
|
-
axis: axis
|
|
105
|
+
axis: axis,
|
|
106
|
+
resizeHandles: resizeHandles
|
|
103
107
|
},
|
|
104
108
|
_react2.default.createElement('div', _extends({ style: { width: this.state.width + 'px', height: this.state.height + 'px' } }, props))
|
|
105
109
|
);
|
|
@@ -48,10 +48,11 @@ export default class ResizableBox extends React.Component<ResizableProps, State>
|
|
|
48
48
|
// Basic wrapper around a Resizable instance.
|
|
49
49
|
// If you use Resizable directly, you are responsible for updating the child component
|
|
50
50
|
// with a new width and height.
|
|
51
|
-
const {handleSize, onResize, onResizeStart, onResizeStop, draggableOpts,
|
|
52
|
-
|
|
51
|
+
const {handle, handleSize, onResize, onResizeStart, onResizeStop, draggableOpts, minConstraints,
|
|
52
|
+
maxConstraints, lockAspectRatio, axis, width, height, resizeHandles, ...props} = this.props;
|
|
53
53
|
return (
|
|
54
54
|
<Resizable
|
|
55
|
+
handle={handle}
|
|
55
56
|
handleSize={handleSize}
|
|
56
57
|
width={this.state.width}
|
|
57
58
|
height={this.state.height}
|
|
@@ -63,7 +64,8 @@ export default class ResizableBox extends React.Component<ResizableProps, State>
|
|
|
63
64
|
maxConstraints={maxConstraints}
|
|
64
65
|
lockAspectRatio={lockAspectRatio}
|
|
65
66
|
axis={axis}
|
|
66
|
-
|
|
67
|
+
resizeHandles={resizeHandles}
|
|
68
|
+
>
|
|
67
69
|
<div style={{width: this.state.width + 'px', height: this.state.height + 'px'}} {...props} />
|
|
68
70
|
</Resizable>
|
|
69
71
|
);
|
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.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "A component that is resizable with handles.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -35,28 +35,28 @@
|
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"babel-cli": "^6.26.0",
|
|
37
37
|
"babel-core": "^6.26.0",
|
|
38
|
-
"babel-eslint": "^
|
|
39
|
-
"babel-loader": "^
|
|
38
|
+
"babel-eslint": "^10.0.1",
|
|
39
|
+
"babel-loader": "^8.0.6",
|
|
40
40
|
"babel-plugin-transform-class-properties": "^6.24.1",
|
|
41
41
|
"babel-plugin-transform-object-rest-spread": "^6.26.0",
|
|
42
42
|
"babel-preset-es2015": "^6.24.1",
|
|
43
43
|
"babel-preset-react": "^6.24.1",
|
|
44
44
|
"cross-env": "^5.0.5",
|
|
45
|
-
"css-loader": "^
|
|
46
|
-
"eslint": "^
|
|
45
|
+
"css-loader": "^2.1.1",
|
|
46
|
+
"eslint": "^5.16.0",
|
|
47
47
|
"eslint-plugin-react": "^7.4.0",
|
|
48
|
-
"flow-bin": "^0.
|
|
48
|
+
"flow-bin": "^0.98.1",
|
|
49
49
|
"lodash": "^4.3.0",
|
|
50
50
|
"pre-commit": "^1.1.2",
|
|
51
51
|
"react": "^16.0.0",
|
|
52
52
|
"react-dom": "^16.0.0",
|
|
53
|
-
"style-loader": "^0.
|
|
54
|
-
"webpack": "^
|
|
55
|
-
"webpack-dev-server": "^
|
|
53
|
+
"style-loader": "^0.23.1",
|
|
54
|
+
"webpack": "^4.31.0",
|
|
55
|
+
"webpack-dev-server": "^3.3.1"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"prop-types": "15.x",
|
|
59
|
-
"react-draggable": "^
|
|
59
|
+
"react-draggable": "^3.0.3"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"react": "0.14.x || 15.x || 16.x",
|