react-resizable 3.0.4 → 3.1.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/.claude/settings.local.json +12 -0
- package/.flowconfig +1 -2
- package/.packj.yaml +153 -0
- package/CHANGELOG.md +17 -3
- package/CLAUDE.md +71 -0
- package/README.md +3 -3
- package/build/Resizable.js +158 -180
- package/build/Resizable.js.flow +14 -1
- package/build/ResizableBox.js +57 -87
- package/build/propTypes.js +26 -23
- package/build/propTypes.js.flow +16 -2
- package/build/utils.js +7 -13
- package/package.json +30 -29
- package/.eslintrc +0 -38
- package/dist/bundle.js +0 -6
package/.flowconfig
CHANGED
package/.packj.yaml
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Audit policies
|
|
3
|
+
#
|
|
4
|
+
audit:
|
|
5
|
+
alerts:
|
|
6
|
+
#
|
|
7
|
+
# category: malicious packages (publicly known and unknown)
|
|
8
|
+
#
|
|
9
|
+
malicious:
|
|
10
|
+
contains known malware:
|
|
11
|
+
- reason: package is known to contain a dangerous malware
|
|
12
|
+
- enabled: true
|
|
13
|
+
typo-squatting or repo-jacking package:
|
|
14
|
+
- reason: package impersonates another popular package to propagate malware
|
|
15
|
+
- enabled: true
|
|
16
|
+
|
|
17
|
+
#
|
|
18
|
+
# alert category: suspicious packages (potentially malicious)
|
|
19
|
+
#
|
|
20
|
+
suspicious:
|
|
21
|
+
inconsistent with repo source:
|
|
22
|
+
- reason: package code inconsistent with the public repo source code
|
|
23
|
+
- enabled: false # WIP
|
|
24
|
+
overwrites system binaries:
|
|
25
|
+
- reason: package code inconsistent with the public repo source code
|
|
26
|
+
- enabled: false # WIP
|
|
27
|
+
|
|
28
|
+
#
|
|
29
|
+
# alert category: packages vulnerable to code exploits
|
|
30
|
+
#
|
|
31
|
+
vulnerable:
|
|
32
|
+
contains known vulnerabilities:
|
|
33
|
+
- reason: known vulnerabilities (CVEs) in package code could be exploited
|
|
34
|
+
- enabled: true
|
|
35
|
+
insecure network communication:
|
|
36
|
+
- reason: package code uses insecure network communication (not https)
|
|
37
|
+
- enabled: false # WIP
|
|
38
|
+
|
|
39
|
+
#
|
|
40
|
+
# packages with undesirable or "risky" attributes
|
|
41
|
+
#
|
|
42
|
+
undesirable:
|
|
43
|
+
package is old or abandoned:
|
|
44
|
+
- reason: old or abandoned packages receive no security updates and are risky
|
|
45
|
+
- enabled: true
|
|
46
|
+
|
|
47
|
+
invalid or no author email:
|
|
48
|
+
- reason: a package with lack of or invalid author email suggests 2FA not enabled
|
|
49
|
+
- enabled: true
|
|
50
|
+
|
|
51
|
+
invalid or no homepage:
|
|
52
|
+
- reason: a package with no or invalid homepage may not be preferable
|
|
53
|
+
- enabled: false
|
|
54
|
+
|
|
55
|
+
no source repo:
|
|
56
|
+
- reason: lack of public source repo may suggest malicious intention
|
|
57
|
+
- enabled: true
|
|
58
|
+
|
|
59
|
+
fewer downloads:
|
|
60
|
+
- reason: a package with few downloads may not be preferable
|
|
61
|
+
- enabled: true
|
|
62
|
+
|
|
63
|
+
no or insufficient readme:
|
|
64
|
+
- reason: a package with lack of documentation may not be preferable
|
|
65
|
+
- enabled: false
|
|
66
|
+
|
|
67
|
+
fewer versions or releases:
|
|
68
|
+
- reason: few versions suggest unstable or inactive project
|
|
69
|
+
- enabled: true
|
|
70
|
+
|
|
71
|
+
too many dependencies:
|
|
72
|
+
- reason: too many dependencies increase attack surface
|
|
73
|
+
- enabled: false
|
|
74
|
+
|
|
75
|
+
version release after a long gap:
|
|
76
|
+
- reason: a release after a long time may indicate account hijacking
|
|
77
|
+
- enabled: false
|
|
78
|
+
|
|
79
|
+
contains custom installation hooks:
|
|
80
|
+
- reason: custom installation hooks may download or execute malicious code
|
|
81
|
+
- enabled: false # WIP
|
|
82
|
+
|
|
83
|
+
#
|
|
84
|
+
# type: repo stats
|
|
85
|
+
#
|
|
86
|
+
few source repo stars:
|
|
87
|
+
- reason: a package with few repo stars may not be preferable
|
|
88
|
+
- enabled: false
|
|
89
|
+
|
|
90
|
+
few source repo forks:
|
|
91
|
+
- reason: a package with few repo forks may not be preferable
|
|
92
|
+
- enabled: false
|
|
93
|
+
|
|
94
|
+
forked source repo:
|
|
95
|
+
- reason: a forked copy of a popular package may contain malicious code
|
|
96
|
+
- enabled: true
|
|
97
|
+
|
|
98
|
+
#
|
|
99
|
+
# type: APIs and permissions
|
|
100
|
+
#
|
|
101
|
+
generates new code:
|
|
102
|
+
- reason: package generates new code at runtime, which could be malicious
|
|
103
|
+
- enabled: false
|
|
104
|
+
forks or exits OS processes:
|
|
105
|
+
- reason: package spawns new operating system processes, which could be malicious
|
|
106
|
+
- enabled: false
|
|
107
|
+
accesses obfuscated (hidden) code:
|
|
108
|
+
- enabled: true
|
|
109
|
+
accesses environment variables:
|
|
110
|
+
- enabled: false
|
|
111
|
+
changes system/environment variables:
|
|
112
|
+
- enabled: false
|
|
113
|
+
accesses files and dirs:
|
|
114
|
+
- enabled: false
|
|
115
|
+
communicates with external network:
|
|
116
|
+
- enabled: false
|
|
117
|
+
reads user input:
|
|
118
|
+
- enabled: false
|
|
119
|
+
|
|
120
|
+
#
|
|
121
|
+
# Sandboxing policies
|
|
122
|
+
#
|
|
123
|
+
sandbox:
|
|
124
|
+
rules:
|
|
125
|
+
#
|
|
126
|
+
# File system (allow or block accesses to file/dirs)
|
|
127
|
+
#
|
|
128
|
+
# ~/ represents home dir
|
|
129
|
+
# . represents cwd dir
|
|
130
|
+
#
|
|
131
|
+
# NOTE: only ONE 'allow' and 'block' lines are allowed
|
|
132
|
+
#
|
|
133
|
+
fs:
|
|
134
|
+
# TODO: customize as per your threat model
|
|
135
|
+
|
|
136
|
+
# block access to home dir and all other locations (except the ones below)
|
|
137
|
+
block: ~/, /
|
|
138
|
+
allow: ., ~/.cache, ~/.npm, ~/.local, ~/.ruby, /tmp, /proc, /etc, /var, /bin, /usr/include, /usr/local, /usr/bin, /usr/lib, /usr/share, /lib
|
|
139
|
+
|
|
140
|
+
#
|
|
141
|
+
# Network (allow or block domains/ports)
|
|
142
|
+
#
|
|
143
|
+
# NOTE: only ONE 'allow' and 'block' lines are allowed
|
|
144
|
+
#
|
|
145
|
+
network:
|
|
146
|
+
|
|
147
|
+
# TODO: customize as per your threat model
|
|
148
|
+
|
|
149
|
+
# block all external network communication (except the ones below)
|
|
150
|
+
block: 0.0.0.0
|
|
151
|
+
|
|
152
|
+
# For NPM packages
|
|
153
|
+
allow: registry.yarnpkg.com:0, npmjs.org:0, npmjs.com:0
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
### 3.1.0 (Dec 30, 2025)
|
|
4
|
+
|
|
5
|
+
- 🐛 Bugfix: Fix `onResizeStop` reporting stale size data due to React's batched state updates. The callback now uses the stored size from the last `onResize` call. [#250](https://github.com/react-grid-layout/react-resizable/pull/250)
|
|
6
|
+
- ➕ Feature: React 18 support.
|
|
7
|
+
- ✏ Chore: Migrate test suite from Enzyme to React Testing Library. [#249](https://github.com/react-grid-layout/react-resizable/pull/249)
|
|
8
|
+
- ✏ Chore: Update `react-draggable` to ^4.5.0.
|
|
9
|
+
- ✏ Chore: Update `react-test-renderer` to ^18.
|
|
10
|
+
|
|
11
|
+
### 3.0.5 (Mar 21, 2023)
|
|
12
|
+
|
|
13
|
+
- 🐛 Bugfix: Make `width` and `height` conditionally required if an `axis` is set. See [#196](https://github.com/react-grid-layout/react-resizable/issues/196)
|
|
14
|
+
- ✏ Chore: Minor dependency upgrades.
|
|
15
|
+
- ✏ Chore: Fix documentation of `onResize` callback arity.
|
|
16
|
+
|
|
3
17
|
### 3.0.4 (Jun 15, 2021)
|
|
4
18
|
|
|
5
19
|
- 🐛 Bugfix: Fix incorrect fix for `handleAxis` on DOM elements. [#175](https://github.com/react-grid-layout/react-resizable/issues/175)
|
|
@@ -8,16 +22,16 @@
|
|
|
8
22
|
### 3.0.3 (Jun 14, 2021)
|
|
9
23
|
|
|
10
24
|
- 🐛 Bugfix: Remove unknown prop `handleAxis` making it to DOM elements, causing a warning in dev.
|
|
11
|
-
- ✏ Chore:Rewrote `lockAspectRatio` logic to be more accurate and shorter.
|
|
25
|
+
- ✏ Chore: Rewrote `lockAspectRatio` logic to be more accurate and shorter.
|
|
12
26
|
|
|
13
27
|
### 3.0.2 (Jun 8, 2021)
|
|
14
28
|
|
|
15
|
-
- ✏ Chore:Add documentation for resize handles and fix a mistake where the `handleAxis` prop was not being passed to custom components.
|
|
29
|
+
- ✏ Chore: Add documentation for resize handles and fix a mistake where the `handleAxis` prop was not being passed to custom components.
|
|
16
30
|
- See [Resize Handles](README.md#resize-handle)
|
|
17
31
|
|
|
18
32
|
### 3.0.1 (May 10, 2021)
|
|
19
33
|
|
|
20
|
-
- ✏ Chore:Reduce package size through `.npmignore`.
|
|
34
|
+
- ✏ Chore: Reduce package size through `.npmignore`.
|
|
21
35
|
|
|
22
36
|
### 3.0.0 (May 10, 2021)
|
|
23
37
|
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Commands
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Install dependencies
|
|
9
|
+
yarn
|
|
10
|
+
|
|
11
|
+
# Run tests with coverage
|
|
12
|
+
yarn test
|
|
13
|
+
|
|
14
|
+
# Run tests in watch mode
|
|
15
|
+
yarn unit
|
|
16
|
+
|
|
17
|
+
# Lint (ESLint + Flow)
|
|
18
|
+
yarn lint
|
|
19
|
+
|
|
20
|
+
# Type check only
|
|
21
|
+
yarn flow
|
|
22
|
+
|
|
23
|
+
# Build (transpile lib/ to build/)
|
|
24
|
+
yarn build
|
|
25
|
+
|
|
26
|
+
# Run dev server with examples
|
|
27
|
+
yarn dev
|
|
28
|
+
|
|
29
|
+
# Build examples for production
|
|
30
|
+
yarn build-example
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Run a single test file:
|
|
34
|
+
```bash
|
|
35
|
+
npx jest __tests__/Resizable.test.js
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Run tests matching a pattern:
|
|
39
|
+
```bash
|
|
40
|
+
npx jest --testNamePattern="snapshot"
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Architecture
|
|
44
|
+
|
|
45
|
+
This is a React component library providing resizable functionality via two main components:
|
|
46
|
+
|
|
47
|
+
### Core Components (`lib/`)
|
|
48
|
+
|
|
49
|
+
- **Resizable.js** - Stateless base component. Wraps a child element with draggable resize handles using `react-draggable`'s `DraggableCore`. Computes size changes from drag deltas, applies constraints, and invokes callbacks. Does not manage state - parent must set `width`/`height` props from callback data.
|
|
50
|
+
|
|
51
|
+
- **ResizableBox.js** - Stateful wrapper around `<Resizable>`. Manages width/height state internally and renders a `<div>` with those dimensions. Simpler API for common use cases.
|
|
52
|
+
|
|
53
|
+
- **propTypes.js** - Shared Flow types and PropTypes definitions. Exports `resizableProps` object and types like `ResizeHandleAxis`, `ResizeCallbackData`, etc.
|
|
54
|
+
|
|
55
|
+
- **utils.js** - Helper `cloneElement()` that merges `style` and `className` when cloning React elements.
|
|
56
|
+
|
|
57
|
+
### Key Implementation Details
|
|
58
|
+
|
|
59
|
+
- Resize handles are rendered as `<DraggableCore>` wrappers around handle elements
|
|
60
|
+
- Handle positions: `'s'`, `'w'`, `'e'`, `'n'`, `'sw'`, `'nw'`, `'se'`, `'ne'`
|
|
61
|
+
- The `runConstraints()` method applies min/max constraints and aspect ratio locking with slack tracking
|
|
62
|
+
- Position tracking via `lastHandleRect` compensates for element repositioning during north/west drags
|
|
63
|
+
- `transformScale` prop adjusts deltas when parent has CSS transform scaling
|
|
64
|
+
|
|
65
|
+
### Build Output
|
|
66
|
+
|
|
67
|
+
`yarn build` transpiles `lib/*.js` to `build/` and copies source files as `*.js.flow` for Flow consumers.
|
|
68
|
+
|
|
69
|
+
## Testing
|
|
70
|
+
|
|
71
|
+
Tests use Jest with Enzyme for shallow/mount rendering. Test files in `__tests__/` mirror the lib structure. Snapshot tests verify render output; unit tests verify resize behavior, constraint handling, and callback data.
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ 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
|
|
|
9
|
-
See the example and associated code in [
|
|
9
|
+
See the example and associated code in [ExampleLayout](/examples/ExampleLayout.js) and
|
|
10
10
|
[ResizableBox](/lib/ResizableBox.js) for more details.
|
|
11
11
|
|
|
12
12
|
Make sure you use the associated styles in [/css/styles.css](/css/styles.css), as without them, you will have
|
|
@@ -49,7 +49,7 @@ class Example extends React.Component {
|
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
// On top layout
|
|
52
|
-
onResize = (event, {
|
|
52
|
+
onResize = (event, {node, size, handle}) => {
|
|
53
53
|
this.setState({width: size.width, height: size.height});
|
|
54
54
|
};
|
|
55
55
|
|
|
@@ -77,7 +77,7 @@ import { ResizableBox } from 'react-resizable';
|
|
|
77
77
|
class Example extends React.Component {
|
|
78
78
|
render() {
|
|
79
79
|
return (
|
|
80
|
-
<ResizableBox width={200} height={200} draggableOpts={{
|
|
80
|
+
<ResizableBox width={200} height={200} draggableOpts={{grid: [25, 25]}}
|
|
81
81
|
minConstraints={[100, 100]} maxConstraints={[300, 300]}>
|
|
82
82
|
<span>Contents</span>
|
|
83
83
|
</ResizableBox>
|