react-resizable 3.1.1 → 3.1.2

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.
@@ -0,0 +1,110 @@
1
+ # Fix GitHub Issue
2
+
3
+ Analyze and fix GitHub issue #$ARGUMENTS for react-grid-layout.
4
+
5
+ ## Workflow
6
+
7
+ Follow these steps precisely:
8
+
9
+ ### 1. Understand the Issue
10
+
11
+ Fetch and analyze the issue:
12
+
13
+ ```bash
14
+ gh issue view $ARGUMENTS
15
+ ```
16
+
17
+ Determine:
18
+
19
+ - What is the bug? (not feature requests or questions)
20
+ - Is there a CodeSandbox reproduction?
21
+ - Which component/hook is affected?
22
+ - Is this fixable? (has clear reproduction, is actually a bug)
23
+
24
+ If not actionable, explain why and stop.
25
+
26
+ ### 2. Investigate
27
+
28
+ - Search for relevant code using Grep/Glob
29
+ - Read the affected files
30
+ - Identify the root cause
31
+ - Check existing tests in `test/spec/`
32
+
33
+ ### 3. Write a Failing Test FIRST
34
+
35
+ **CRITICAL: The test must fail before implementing the fix.**
36
+
37
+ Add a test to the appropriate file in `test/spec/` that:
38
+
39
+ - Reproduces the exact bug behavior
40
+ - Includes comment `// #$ARGUMENTS`
41
+ - Actually FAILS when run
42
+
43
+ Verify it fails:
44
+
45
+ ```bash
46
+ NODE_ENV=test npx jest --testPathPatterns="<test-file>"
47
+ ```
48
+
49
+ If test passes, it's invalid - revise until it fails.
50
+
51
+ ### 4. Implement the Fix
52
+
53
+ - Make minimal changes to fix the bug
54
+ - Add comments explaining non-obvious fixes
55
+ - Reference the issue number
56
+
57
+ Verify test now passes:
58
+
59
+ ```bash
60
+ NODE_ENV=test npx jest --testPathPatterns="<test-file>"
61
+ ```
62
+
63
+ ### 5. Validate
64
+
65
+ Run in order:
66
+
67
+ ```bash
68
+ yarn test
69
+ yarn lint
70
+ yarn fmt
71
+ ```
72
+
73
+ Fix any failures before proceeding.
74
+
75
+ ### 6. Commit and PR
76
+
77
+ ```bash
78
+ git checkout -b fix/issue-$ARGUMENTS-<short-desc>
79
+ git add <files>
80
+ git commit -m "fix: <description> (#$ARGUMENTS)"
81
+ git push -u origin fix/issue-$ARGUMENTS-<short-desc>
82
+ gh pr create --title "fix: <description> (#$ARGUMENTS)" --body "Fixes #$ARGUMENTS
83
+
84
+ ## Summary
85
+ <root cause>
86
+
87
+ ## Fix
88
+ <what changed>
89
+
90
+ ## Test plan
91
+ - [x] Test fails without fix
92
+ - [x] Test passes with fix
93
+ - [x] All tests pass"
94
+ ```
95
+
96
+ ### 7. Wait and Merge
97
+
98
+ ```bash
99
+ gh pr checks <pr-number> --watch
100
+ gh pr merge <pr-number> --squash --delete-branch
101
+ git checkout master && git pull
102
+ ```
103
+
104
+ ## Key Files
105
+
106
+ - `src/core/` - Pure algorithms
107
+ - `src/react/components/` - React components
108
+ - `src/react/hooks/` - React hooks
109
+ - `src/legacy/` - v1 compatibility
110
+ - `test/spec/` - Tests
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ### 3.1.2 (Jan 1, 2026)
4
+
5
+ - 🐛 Bugfix: Fix SSR crash where `Element` is not defined in Node.js environments. [#251](https://github.com/react-grid-layout/react-resizable/issues/251)
6
+
3
7
  ### 3.1.1 (Dec 30, 2025)
4
8
 
5
9
  - 🐛 Bugfix: Fix crash when `Resizable` child has a single child element (was not iterable). [#219](https://github.com/react-grid-layout/react-resizable/issues/219)
package/README.md CHANGED
@@ -1,84 +1,118 @@
1
- ### React-Resizable
1
+ # React-Resizable
2
2
 
3
- [View the Demo](https://react-grid-layout.github.io/react-resizable/index.html)
3
+ [![npm version](https://img.shields.io/npm/v/react-resizable.svg)](https://www.npmjs.com/package/react-resizable)
4
+ [![npm downloads](https://img.shields.io/npm/dm/react-resizable.svg)](https://www.npmjs.com/package/react-resizable)
5
+ [![Build Status](https://github.com/react-grid-layout/react-resizable/actions/workflows/test.yml/badge.svg)](https://github.com/react-grid-layout/react-resizable/actions/workflows/test.yml)
6
+
7
+ [**View the Demo**](https://react-grid-layout.github.io/react-resizable/examples/)
4
8
 
5
9
  A simple widget that can be resized via one or more handles.
6
10
 
7
11
  You can either use the `<Resizable>` element directly, or use the much simpler `<ResizableBox>` element.
8
12
 
9
- See the example and associated code in [ExampleLayout](/examples/ExampleLayout.js) and
10
- [ResizableBox](/lib/ResizableBox.js) for more details.
13
+ See the example and associated code in [ExampleLayout](https://github.com/react-grid-layout/react-resizable/blob/master/examples/ExampleLayout.js) and
14
+ [ResizableBox](https://github.com/react-grid-layout/react-resizable/blob/master/lib/ResizableBox.js) for more details.
15
+
16
+ ## Table of Contents
17
+
18
+ - [Installation](#installation)
19
+ - [Compatibility](#compatibility)
20
+ - [Usage](#usage)
21
+ - [Resizable](#resizable)
22
+ - [ResizableBox](#resizablebox)
23
+ - [Props](#props)
24
+ - [Extracting Styles](#extracting-styles)
25
+ - [Custom Resize Handles](#resize-handle)
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ $ npm install --save react-resizable
31
+ ```
32
+
33
+ ## Extracting Styles
34
+
35
+ You **must** include the associated styles in your application, otherwise the resize handles will not be visible and will not work properly.
11
36
 
12
- Make sure you use the associated styles in [/css/styles.css](/css/styles.css), as without them, you will have
13
- problems with handle placement and visibility.
37
+ ```js
38
+ // In your JS/TS entry point:
39
+ import 'react-resizable/css/styles.css';
40
+ ```
14
41
 
15
- You can pass options directly to the underlying `DraggableCore` instance by using the prop `draggableOpts`.
16
- See the [demo](/examples/TestLayout.js) for more on this.
42
+ Or import it in your CSS:
17
43
 
18
- ### Installation
44
+ ```css
45
+ @import 'react-resizable/css/styles.css';
46
+ ```
19
47
 
20
- $ npm install --save react-resizable
48
+ If you're using a bundler that doesn't support CSS imports, you can find the styles at `node_modules/react-resizable/css/styles.css` and include them manually.
21
49
 
22
- ### Compatibility
50
+ ## Compatibility
23
51
 
24
- [React-Resizable 3.x](/CHANGELOG.md#3.0.0) is compatible with React `>= 16.3`.
25
- React-Resizable 2.x has been skipped.
26
- [React-Resizable 1.x](/CHANGELOG.md#1.11.1) is compatible with React `14-17`.
52
+ | Version | React Version |
53
+ |---------|---------------|
54
+ | [3.x](https://github.com/react-grid-layout/react-resizable/blob/master/CHANGELOG.md#300-may-10-2021) | `>= 16.3` |
55
+ | 2.x | Skipped |
56
+ | [1.x](https://github.com/react-grid-layout/react-resizable/blob/master/CHANGELOG.md#1111-mar-5-2021) | `14 - 17` |
27
57
 
28
- ### Usage
58
+ ## Usage
29
59
 
30
60
  This package has two major exports:
31
61
 
32
- * [`<Resizable>`](/lib/Resizable.js): A raw component that does not have state. Use as a building block for larger components, by listening to its
33
- callbacks and setting its props.
34
- * [`<ResizableBox>`](/lib/ResizableBox.js): A simple `<div {...props} />` element that manages basic state. Convenient for simple use-cases.
62
+ * [`<Resizable>`](https://github.com/react-grid-layout/react-resizable/blob/master/lib/Resizable.js): A raw component that does not have state. Use as a building block for larger components, by listening to its callbacks and setting its props.
63
+ * [`<ResizableBox>`](https://github.com/react-grid-layout/react-resizable/blob/master/lib/ResizableBox.js): A simple `<div {...props} />` element that manages basic state. Convenient for simple use-cases.
35
64
 
65
+ ### `<Resizable>`
36
66
 
37
- #### `<Resizable>`
38
67
  ```js
39
- const {Resizable} = require('react-resizable');
40
-
41
- // ES6
42
68
  import { Resizable } from 'react-resizable';
69
+ import 'react-resizable/css/styles.css';
43
70
 
44
- // ...
45
71
  class Example extends React.Component {
46
72
  state = {
47
73
  width: 200,
48
74
  height: 200,
49
75
  };
50
76
 
51
- // On top layout
52
77
  onResize = (event, {node, size, handle}) => {
53
78
  this.setState({width: size.width, height: size.height});
54
79
  };
55
80
 
56
81
  render() {
57
82
  return (
58
- <Resizable height={this.state.height} width={this.state.width} onResize={this.onResize}>
59
- <div className="box" style={{width: this.state.width + 'px', height: this.state.height + 'px'}}>
83
+ <Resizable
84
+ height={this.state.height}
85
+ width={this.state.width}
86
+ onResize={this.onResize}
87
+ >
88
+ <div
89
+ className="box"
90
+ style={{width: this.state.width + 'px', height: this.state.height + 'px'}}
91
+ >
60
92
  <span>Contents</span>
61
93
  </div>
62
94
  </Resizable>
63
95
  );
64
96
  }
65
97
  }
66
-
67
98
  ```
68
99
 
100
+ ### `<ResizableBox>`
69
101
 
70
- #### `<ResizableBox>`
71
102
  ```js
72
- const {ResizableBox} = require('react-resizable');
73
-
74
- // ES6
75
103
  import { ResizableBox } from 'react-resizable';
104
+ import 'react-resizable/css/styles.css';
76
105
 
77
106
  class Example extends React.Component {
78
107
  render() {
79
108
  return (
80
- <ResizableBox width={200} height={200} draggableOpts={{grid: [25, 25]}}
81
- minConstraints={[100, 100]} maxConstraints={[300, 300]}>
109
+ <ResizableBox
110
+ width={200}
111
+ height={200}
112
+ draggableOpts={{grid: [25, 25]}}
113
+ minConstraints={[100, 100]}
114
+ maxConstraints={[300, 300]}
115
+ >
82
116
  <span>Contents</span>
83
117
  </ResizableBox>
84
118
  );
@@ -86,7 +120,7 @@ class Example extends React.Component {
86
120
  }
87
121
  ```
88
122
 
89
- ### Props
123
+ ## Props
90
124
 
91
125
  These props apply to both `<Resizable>` and `<ResizableBox>`. Unknown props that are not in the list below will be passed to the child component.
92
126
 
@@ -96,14 +130,15 @@ type ResizeCallbackData = {
96
130
  size: {width: number, height: number},
97
131
  handle: ResizeHandleAxis
98
132
  };
133
+
99
134
  type ResizeHandleAxis = 's' | 'w' | 'e' | 'n' | 'sw' | 'nw' | 'se' | 'ne';
100
135
 
101
- type ResizableProps =
102
- {
136
+ type ResizableProps = {
103
137
  children: React.Element<any>,
104
138
  width: number,
105
139
  height: number,
106
- // 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.
140
+ // Either a ReactElement to be used as handle, or a function
141
+ // returning an element that is fed the handle's location as its first argument.
107
142
  handle: ReactElement<any> | (resizeHandle: ResizeHandleAxis, ref: ReactRef<HTMLElement>) => ReactElement<any>,
108
143
  // If you change this, be sure to update your css
109
144
  handleSize: [number, number] = [10, 10],
@@ -115,7 +150,9 @@ type ResizableProps =
115
150
  onResizeStart?: ?(e: SyntheticEvent, data: ResizeCallbackData) => any,
116
151
  onResize?: ?(e: SyntheticEvent, data: ResizeCallbackData) => any,
117
152
  draggableOpts?: ?Object,
118
- resizeHandles?: ?Array<ResizeHandleAxis> = ['se']
153
+ resizeHandles?: ?Array<ResizeHandleAxis> = ['se'],
154
+ // If `transform: scale(n)` is set on the parent, this should be set to `n`.
155
+ transformScale?: number = 1
119
156
  };
120
157
  ```
121
158
 
@@ -129,15 +166,17 @@ The following props can also be used on `<ResizableBox>`:
129
166
 
130
167
  If a `width` or `height` is passed to `<ResizableBox>`'s `style` prop, it will be ignored as it is required for internal function.
131
168
 
132
- #### Resize Handle
169
+ You can pass options directly to the underlying `DraggableCore` instance by using the prop `draggableOpts`. See the [demo](https://react-grid-layout.github.io/react-resizable/examples/) for more on this.
170
+
171
+ ## Resize Handle
133
172
 
134
- If you override the resize handle, we expect that any `ref` passed to your new handle with represent the underlying DOM element.
173
+ If you override the resize handle, we expect that any `ref` passed to your new handle will represent the underlying DOM element.
135
174
 
136
175
  This is required, as `react-resizable` must be able to access the underlying DOM node to attach handlers and measure position deltas.
137
176
 
138
177
  There are a few ways to do this:
139
178
 
140
- ##### Native DOM Element
179
+ ### Native DOM Element
141
180
 
142
181
  This requires no special treatment.
143
182
 
@@ -145,11 +184,11 @@ This requires no special treatment.
145
184
  <Resizable handle={<div className="foo" />} />
146
185
  ```
147
186
 
148
- ##### Custom React Component
187
+ ### Custom React Component
149
188
 
150
189
  You must [forward the ref](https://reactjs.org/docs/forwarding-refs.html) and props to the underlying DOM element.
151
190
 
152
- ###### Class Components
191
+ #### Class Components
153
192
 
154
193
  ```js
155
194
  class MyHandleComponent extends React.Component {
@@ -163,7 +202,7 @@ const MyHandle = React.forwardRef((props, ref) => <MyHandleComponent innerRef={r
163
202
  <Resizable handle={<MyHandle />} />
164
203
  ```
165
204
 
166
- ###### Functional Components
205
+ #### Functional Components
167
206
 
168
207
  ```js
169
208
  const MyHandle = React.forwardRef((props, ref) => {
@@ -174,7 +213,7 @@ const MyHandle = React.forwardRef((props, ref) => {
174
213
  <Resizable handle={<MyHandle />} />
175
214
  ```
176
215
 
177
- ##### Custom Function
216
+ ### Custom Function
178
217
 
179
218
  You can define a function as a handle, which will simply receive an axis (see above `ResizeHandleAxis` type) and ref. This may be more clear to read, depending on your coding style.
180
219
 
@@ -183,5 +222,9 @@ const MyHandle = (props) => {
183
222
  return <div ref={props.innerRef} className="foo" {...props} />;
184
223
  };
185
224
 
186
- <Resizable handle={(handleAxis, ref) => <MyHandle innerRef={ref} className={`foo handle-${handleAxis}`} {...props} />} />
187
- ```
225
+ <Resizable handle={(handleAxis, ref) => <MyHandle innerRef={ref} className={`foo handle-${handleAxis}`} />} />
226
+ ```
227
+
228
+ ## License
229
+
230
+ MIT
@@ -30,7 +30,8 @@ const resizableProps = exports.resizableProps = {
30
30
  children: _propTypes.default.node,
31
31
  disabled: _propTypes.default.bool,
32
32
  enableUserSelectHack: _propTypes.default.bool,
33
- offsetParent: _propTypes.default.instanceOf(Element),
33
+ // #251: Check for Element to support SSR environments where DOM globals don't exist
34
+ offsetParent: typeof Element !== 'undefined' ? _propTypes.default.instanceOf(Element) : _propTypes.default.any,
34
35
  grid: _propTypes.default.arrayOf(_propTypes.default.number),
35
36
  handle: _propTypes.default.string,
36
37
  nodeRef: _propTypes.default.object,
@@ -76,7 +76,8 @@ export const resizableProps: Object = {
76
76
  children: PropTypes.node,
77
77
  disabled: PropTypes.bool,
78
78
  enableUserSelectHack: PropTypes.bool,
79
- offsetParent: PropTypes.instanceOf(Element),
79
+ // #251: Check for Element to support SSR environments where DOM globals don't exist
80
+ offsetParent: typeof Element !== 'undefined' ? PropTypes.instanceOf(Element) : PropTypes.any,
80
81
  grid: PropTypes.arrayOf(PropTypes.number),
81
82
  handle: PropTypes.string,
82
83
  nodeRef: PropTypes.object,
package/index.html ADDED
@@ -0,0 +1,11 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta http-equiv="refresh" content="0; url=https://react-grid-layout.github.io/react-resizable/examples/">
6
+ <title>React-Resizable</title>
7
+ </head>
8
+ <body>
9
+ <p>Redirecting to <a href="https://react-grid-layout.github.io/react-resizable/examples/">examples</a>...</p>
10
+ </body>
11
+ </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-resizable",
3
- "version": "3.1.1",
3
+ "version": "3.1.2",
4
4
  "description": "A component that is resizable with handles.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "repository": {
20
20
  "type": "git",
21
- "url": "git@github.com:react-grid-layout/react-resizable.git"
21
+ "url": "git+ssh://git@github.com/react-grid-layout/react-resizable.git"
22
22
  },
23
23
  "keywords": [
24
24
  "react",