@gustavolmo/react-window-manager 0.4.1 → 0.4.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.
- package/README.md +76 -130
- package/dist/index.js +345 -167
- package/dist/index.js.map +1 -1
- package/dist/window-manager/internal/features/cursor/cursor-move-listener.d.ts.map +1 -1
- package/dist/window-manager/internal/features/cursor/cursor-state.d.ts +5 -2
- package/dist/window-manager/internal/features/cursor/cursor-state.d.ts.map +1 -1
- package/dist/window-manager/internal/features/grid/grid-orchestrator.d.ts +3 -2
- package/dist/window-manager/internal/features/grid/grid-orchestrator.d.ts.map +1 -1
- package/dist/window-manager/internal/features/resizing/resizing-controls.d.ts.map +1 -1
- package/dist/window-manager/internal/features/window-layout.d.ts.map +1 -1
- package/dist/window-manager/internal/features/workspace/workspace-api.d.ts +2 -2
- package/dist/window-manager/internal/features/workspace/workspace-api.d.ts.map +1 -1
- package/dist/window-manager/internal/features/workspace/workspace-resize-listener.d.ts.map +1 -1
- package/dist/window-manager/internal/runtime/dock-resolver/dock-commands.d.ts +0 -3
- package/dist/window-manager/internal/runtime/dock-resolver/dock-commands.d.ts.map +1 -1
- package/dist/window-manager/internal/runtime/drag-resolver/drag-commands.d.ts +0 -1
- package/dist/window-manager/internal/runtime/drag-resolver/drag-commands.d.ts.map +1 -1
- package/dist/window-manager/internal/runtime/resize-resolver/resize-loop-rules.d.ts +3 -0
- package/dist/window-manager/internal/runtime/resize-resolver/resize-loop-rules.d.ts.map +1 -0
- package/dist/window-manager/internal/runtime/resize-resolver/resize-loop.d.ts.map +1 -1
- package/dist/window-manager/internal/runtime/rwm-runtime.d.ts +9 -6
- package/dist/window-manager/internal/runtime/rwm-runtime.d.ts.map +1 -1
- package/dist/window-manager/internal/runtime/workspace-resolver/workspace-commands.d.ts +4 -4
- package/dist/window-manager/internal/runtime/workspace-resolver/workspace-commands.d.ts.map +1 -1
- package/dist/window-manager/model/window-types.d.ts +5 -6
- package/dist/window-manager/model/window-types.d.ts.map +1 -1
- package/dist/window-manager/model/workspace-types.d.ts +1 -1
- package/dist/window-manager/model/workspace-types.d.ts.map +1 -1
- package/dist/window-manager/rwm.d.ts +4 -7
- package/dist/window-manager/rwm.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/window-manager/internal/features/stack/stack-api.d.ts +0 -4
- package/dist/window-manager/internal/features/stack/stack-api.d.ts.map +0 -1
- package/dist/window-manager/internal/runtime/stack-resolver/stack-commands.d.ts +0 -6
- package/dist/window-manager/internal/runtime/stack-resolver/stack-commands.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,198 +1,144 @@
|
|
|
1
|
-
# React Window Manager
|
|
1
|
+
# React Window Manager (RWM)
|
|
2
|
+
|
|
3
|
+
A flexible window management system for React applications.
|
|
2
4
|
|
|
3
5
|
---
|
|
4
6
|
|
|
5
|
-
##
|
|
7
|
+
## INSTALL RWM
|
|
8
|
+
|
|
9
|
+
### 1. Install Dependencies
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
Install React Window Manager along with React and React DOM.
|
|
12
|
+
|
|
13
|
+
React and React DOM (v19+) are peer dependencies.
|
|
8
14
|
|
|
9
15
|
```bash
|
|
10
16
|
pnpm add @gustavolmo/react-window-manager
|
|
11
|
-
|
|
12
|
-
npm install @gustavolmo/react-window-manager
|
|
13
|
-
# or
|
|
14
|
-
yarn add @gustavolmo/react-window-manager
|
|
17
|
+
pnpm add react react-dom
|
|
15
18
|
```
|
|
16
19
|
|
|
17
|
-
## Requirements
|
|
18
|
-
|
|
19
|
-
### You must have:
|
|
20
|
-
|
|
21
|
-
- **React 18+ (or 19)**
|
|
22
|
-
- **React DOM**
|
|
23
|
-
- **Zustand**
|
|
24
|
-
|
|
25
|
-
Install it with
|
|
26
|
-
|
|
27
20
|
```bash
|
|
28
|
-
|
|
21
|
+
npm install @gustavolmo/react-window-manager
|
|
22
|
+
npm install react react-dom
|
|
29
23
|
```
|
|
30
24
|
|
|
31
|
-
### Styling
|
|
32
|
-
|
|
33
|
-
This library ships with its own compiled CSS.
|
|
34
|
-
|
|
35
|
-
Import the stylesheet once at your application root:
|
|
36
|
-
|
|
37
25
|
```bash
|
|
38
|
-
|
|
26
|
+
yarn add @gustavolmo/react-window-manager
|
|
27
|
+
yarn add react react-dom
|
|
39
28
|
```
|
|
40
29
|
|
|
41
|
-
The styling properties of compoents accept tailwind or regular css classes
|
|
42
|
-
|
|
43
30
|
---
|
|
44
31
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
A lightweight desktop-style window manager built with:
|
|
32
|
+
### 2. Import Default Styles
|
|
48
33
|
|
|
49
|
-
|
|
50
|
-
- **Zustand** (isolated state per window)
|
|
51
|
-
- A shared **WorkspaceLayout**
|
|
52
|
-
- Independent **WindowLayout** instances
|
|
53
|
-
- External **WindowButton** controllers
|
|
34
|
+
The library includes its own compiled CSS. Import it once at your application root:
|
|
54
35
|
|
|
55
|
-
|
|
36
|
+
```ts
|
|
37
|
+
import "@gustavolmo/react-window-manager/index.css"
|
|
38
|
+
```
|
|
56
39
|
|
|
57
40
|
---
|
|
58
41
|
|
|
59
|
-
##
|
|
42
|
+
## QUICK START
|
|
60
43
|
|
|
61
|
-
|
|
44
|
+
### 1. Create a Window
|
|
45
|
+
|
|
46
|
+
Call `createWindowStore()` to create a new window instance.
|
|
62
47
|
|
|
63
48
|
```ts
|
|
64
|
-
const
|
|
49
|
+
const myWindow1 = createWindowStore()
|
|
50
|
+
const myWindow2 = createWindowStore()
|
|
65
51
|
```
|
|
66
52
|
|
|
67
|
-
|
|
68
|
-
- The return value is a standard Zustand hook.
|
|
69
|
-
- Each window is automatically registered internally.
|
|
53
|
+
Each instance contains everything needed to render and control a window.
|
|
70
54
|
|
|
71
|
-
|
|
55
|
+
---
|
|
72
56
|
|
|
73
|
-
|
|
74
|
-
const firstWindow = createWindowStore('window-first')
|
|
75
|
-
const secondWindow = createWindowStore('window-second')
|
|
76
|
-
```
|
|
57
|
+
### 2. Render the Window
|
|
77
58
|
|
|
78
|
-
|
|
59
|
+
All windows must be rendered inside `WorkspaceLayout`.
|
|
79
60
|
|
|
80
|
-
|
|
61
|
+
This component acts as:
|
|
81
62
|
|
|
82
|
-
|
|
63
|
+
* The rendering surface
|
|
64
|
+
* The coordinate system
|
|
65
|
+
* The stacking context for all windows
|
|
83
66
|
|
|
84
67
|
```tsx
|
|
85
|
-
|
|
86
|
-
{/* WindowLayout components */}
|
|
87
|
-
</WorkspaceLayout>
|
|
88
|
-
```
|
|
68
|
+
import { WorkspaceLayout } from "@gustavolmo/react-window-manager"
|
|
89
69
|
|
|
90
|
-
|
|
70
|
+
// ...
|
|
91
71
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
- The coordinate system for all windows
|
|
72
|
+
<WorkspaceLayout>
|
|
73
|
+
{/* any valid code */}
|
|
95
74
|
|
|
96
|
-
|
|
75
|
+
<myWindow1.Window>
|
|
76
|
+
{/* any valid code */}
|
|
77
|
+
</myWindow1.Window>
|
|
97
78
|
|
|
98
|
-
|
|
79
|
+
<myWindow2.Window>
|
|
80
|
+
{/* any valid code */}
|
|
81
|
+
</myWindow2.Window>
|
|
82
|
+
</WorkspaceLayout>
|
|
83
|
+
```
|
|
99
84
|
|
|
100
|
-
|
|
85
|
+
---
|
|
101
86
|
|
|
102
|
-
|
|
103
|
-
- `windowName` → title (string or ReactNode)
|
|
104
|
-
- `defaultDock` → initial docking behavior (optional)
|
|
87
|
+
### 3. Adjusting the Workspace Layout
|
|
105
88
|
|
|
106
|
-
|
|
107
|
-
<WindowLayout
|
|
108
|
-
useWindowStore={myWindow}
|
|
109
|
-
windowName="My Window"
|
|
110
|
-
defaultDock="right"
|
|
111
|
-
>
|
|
112
|
-
<div>Any React content</div>
|
|
113
|
-
</WindowLayout>
|
|
114
|
-
```
|
|
89
|
+
By default, the workspace layout is fixed with full width and height. You can override this using `className`.
|
|
115
90
|
|
|
116
|
-
|
|
91
|
+
All windows will adjust their coordinates accordingly.
|
|
117
92
|
|
|
118
|
-
|
|
119
|
-
- `"right"`
|
|
120
|
-
- `"full"`
|
|
93
|
+
To prevent visual overflow outside the workspace layout, elements placed outside must have a higher `z-index` than the total number of windows.
|
|
121
94
|
|
|
122
|
-
|
|
95
|
+
Example:
|
|
123
96
|
|
|
124
97
|
```tsx
|
|
125
|
-
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
---
|
|
129
|
-
|
|
130
|
-
## 4. Control a Window with `WindowButton`
|
|
98
|
+
// Example with Tailwind (regular CSS also works)
|
|
131
99
|
|
|
132
|
-
|
|
100
|
+
<section className="fixed w-full h-full flex flex-col">
|
|
101
|
+
<WorkspaceLayout className="h-full w-full grow">
|
|
102
|
+
{/* any valid code */}
|
|
103
|
+
</WorkspaceLayout>
|
|
133
104
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
</
|
|
105
|
+
<nav className="w-full h-12 bg-neutral-900 flex gap-2 px-4 z-50">
|
|
106
|
+
{/* any valid code */}
|
|
107
|
+
</nav>
|
|
108
|
+
</section>
|
|
138
109
|
```
|
|
139
110
|
|
|
140
|
-
- Multiple buttons can control the same window.
|
|
141
|
-
- Buttons are fully decoupled from layout.
|
|
142
|
-
- No prop drilling is required.
|
|
143
|
-
|
|
144
111
|
---
|
|
145
112
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
Since the store is a standard Zustand hook, you can read window state directly:
|
|
113
|
+
### 4. Control the Window
|
|
149
114
|
|
|
150
|
-
|
|
151
|
-
const { isDragging, isResizing } = myWindow()
|
|
152
|
-
```
|
|
115
|
+
Use the `.Button` property from the window store to control visibility.
|
|
153
116
|
|
|
154
|
-
|
|
117
|
+
Buttons can be placed anywhere and can control the same window from multiple locations.
|
|
155
118
|
|
|
156
119
|
```tsx
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
: 'pointer-events-auto'
|
|
161
|
-
}
|
|
120
|
+
<myWindow1.Button>
|
|
121
|
+
{/* any valid code */}
|
|
122
|
+
</myWindow1.Button>
|
|
162
123
|
```
|
|
163
124
|
|
|
164
|
-
This is useful when embedding iframes or other complex interactive content.
|
|
165
|
-
|
|
166
125
|
---
|
|
167
126
|
|
|
168
|
-
|
|
127
|
+
### 5. Defaults
|
|
169
128
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
```ts
|
|
173
|
-
const { isOpen } = windowRegistry['window-my-id']()
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
This is useful when you do not have direct access to the original store reference.
|
|
177
|
-
|
|
178
|
-
---
|
|
129
|
+
The default setup includes:
|
|
179
130
|
|
|
180
|
-
|
|
131
|
+
* Built-in styling
|
|
132
|
+
* Docking panel
|
|
133
|
+
* Resize edge detection
|
|
181
134
|
|
|
182
|
-
|
|
183
|
-
- `WorkspaceLayout` → shared window surface
|
|
184
|
-
- `WindowLayout` → draggable and dockable container
|
|
185
|
-
- `WindowButton` → external controller
|
|
186
|
-
- Zustand → reactive state management
|
|
135
|
+
No additional configuration is required for basic usage.
|
|
187
136
|
|
|
188
137
|
---
|
|
189
138
|
|
|
190
|
-
##
|
|
139
|
+
## FURTHER READING
|
|
191
140
|
|
|
192
|
-
|
|
193
|
-
- No global prop chains
|
|
194
|
-
- Arbitrary React content support (apps, iframes, components)
|
|
195
|
-
- Independent lifecycle per window
|
|
196
|
-
- Scalable to many concurrent windows
|
|
141
|
+
For advanced usage patterns and API details:
|
|
197
142
|
|
|
198
|
-
|
|
143
|
+
Full documentation:
|
|
144
|
+
https://gustavolmo.github.io/react-window-manager/
|