@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.
Files changed (35) hide show
  1. package/README.md +76 -130
  2. package/dist/index.js +345 -167
  3. package/dist/index.js.map +1 -1
  4. package/dist/window-manager/internal/features/cursor/cursor-move-listener.d.ts.map +1 -1
  5. package/dist/window-manager/internal/features/cursor/cursor-state.d.ts +5 -2
  6. package/dist/window-manager/internal/features/cursor/cursor-state.d.ts.map +1 -1
  7. package/dist/window-manager/internal/features/grid/grid-orchestrator.d.ts +3 -2
  8. package/dist/window-manager/internal/features/grid/grid-orchestrator.d.ts.map +1 -1
  9. package/dist/window-manager/internal/features/resizing/resizing-controls.d.ts.map +1 -1
  10. package/dist/window-manager/internal/features/window-layout.d.ts.map +1 -1
  11. package/dist/window-manager/internal/features/workspace/workspace-api.d.ts +2 -2
  12. package/dist/window-manager/internal/features/workspace/workspace-api.d.ts.map +1 -1
  13. package/dist/window-manager/internal/features/workspace/workspace-resize-listener.d.ts.map +1 -1
  14. package/dist/window-manager/internal/runtime/dock-resolver/dock-commands.d.ts +0 -3
  15. package/dist/window-manager/internal/runtime/dock-resolver/dock-commands.d.ts.map +1 -1
  16. package/dist/window-manager/internal/runtime/drag-resolver/drag-commands.d.ts +0 -1
  17. package/dist/window-manager/internal/runtime/drag-resolver/drag-commands.d.ts.map +1 -1
  18. package/dist/window-manager/internal/runtime/resize-resolver/resize-loop-rules.d.ts +3 -0
  19. package/dist/window-manager/internal/runtime/resize-resolver/resize-loop-rules.d.ts.map +1 -0
  20. package/dist/window-manager/internal/runtime/resize-resolver/resize-loop.d.ts.map +1 -1
  21. package/dist/window-manager/internal/runtime/rwm-runtime.d.ts +9 -6
  22. package/dist/window-manager/internal/runtime/rwm-runtime.d.ts.map +1 -1
  23. package/dist/window-manager/internal/runtime/workspace-resolver/workspace-commands.d.ts +4 -4
  24. package/dist/window-manager/internal/runtime/workspace-resolver/workspace-commands.d.ts.map +1 -1
  25. package/dist/window-manager/model/window-types.d.ts +5 -6
  26. package/dist/window-manager/model/window-types.d.ts.map +1 -1
  27. package/dist/window-manager/model/workspace-types.d.ts +1 -1
  28. package/dist/window-manager/model/workspace-types.d.ts.map +1 -1
  29. package/dist/window-manager/rwm.d.ts +4 -7
  30. package/dist/window-manager/rwm.d.ts.map +1 -1
  31. package/package.json +1 -1
  32. package/dist/window-manager/internal/features/stack/stack-api.d.ts +0 -4
  33. package/dist/window-manager/internal/features/stack/stack-api.d.ts.map +0 -1
  34. package/dist/window-manager/internal/runtime/stack-resolver/stack-commands.d.ts +0 -6
  35. 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
- ## Installation
7
+ ## INSTALL RWM
8
+
9
+ ### 1. Install Dependencies
6
10
 
7
- ### Install the package
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
- # or
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
- pnpm add react react-dom zustand
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
- import "@gustavolmo/react-window-manager/index.css"
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
- ## Overview
46
-
47
- A lightweight desktop-style window manager built with:
32
+ ### 2. Import Default Styles
48
33
 
49
- - **React**
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
- Each window instance is fully isolated, draggable, dockable, and externally controllable via its own store.
36
+ ```ts
37
+ import "@gustavolmo/react-window-manager/index.css"
38
+ ```
56
39
 
57
40
  ---
58
41
 
59
- ## 1. Create a Window Store
42
+ ## QUICK START
60
43
 
61
- Initialize a window instance early (module scope recommended):
44
+ ### 1. Create a Window
45
+
46
+ Call `createWindowStore()` to create a new window instance.
62
47
 
63
48
  ```ts
64
- const myWindow = createWindowStore('window-my-id')
49
+ const myWindow1 = createWindowStore()
50
+ const myWindow2 = createWindowStore()
65
51
  ```
66
52
 
67
- - The ID must be unique.
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
- You can create multiple windows:
55
+ ---
72
56
 
73
- ```ts
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
- ## 2. Wrap Everything in `WorkspaceLayout`
61
+ This component acts as:
81
62
 
82
- All windows must be rendered inside a shared workspace:
63
+ * The rendering surface
64
+ * The coordinate system
65
+ * The stacking context for all windows
83
66
 
84
67
  ```tsx
85
- <WorkspaceLayout>
86
- {/* WindowLayout components */}
87
- </WorkspaceLayout>
88
- ```
68
+ import { WorkspaceLayout } from "@gustavolmo/react-window-manager"
89
69
 
90
- The workspace acts as:
70
+ // ...
91
71
 
92
- - The rendering surface
93
- - The stacking context
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
- ## 3. Render a Window
79
+ <myWindow2.Window>
80
+ {/* any valid code */}
81
+ </myWindow2.Window>
82
+ </WorkspaceLayout>
83
+ ```
99
84
 
100
- Use `WindowLayout` and pass:
85
+ ---
101
86
 
102
- - `useWindowStore` the store instance
103
- - `windowName` → title (string or ReactNode)
104
- - `defaultDock` → initial docking behavior (optional)
87
+ ### 3. Adjusting the Workspace Layout
105
88
 
106
- ```tsx
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
- Supported docking modes:
91
+ All windows will adjust their coordinates accordingly.
117
92
 
118
- - `"left"`
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
- Responsive docking can be computed:
95
+ Example:
123
96
 
124
97
  ```tsx
125
- defaultDock={window.innerWidth < 800 ? 'full' : 'left'}
126
- ```
127
-
128
- ---
129
-
130
- ## 4. Control a Window with `WindowButton`
98
+ // Example with Tailwind (regular CSS also works)
131
99
 
132
- Place a control button anywhere in your UI:
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
- ```tsx
135
- <WindowButton useWindowStore={myWindow}>
136
- <p>Open Window</p>
137
- </WindowButton>
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
- ## 5. Access Window State
147
-
148
- Since the store is a standard Zustand hook, you can read window state directly:
113
+ ### 4. Control the Window
149
114
 
150
- ```ts
151
- const { isDragging, isResizing } = myWindow()
152
- ```
115
+ Use the `.Button` property from the window store to control visibility.
153
116
 
154
- Example use case:
117
+ Buttons can be placed anywhere and can control the same window from multiple locations.
155
118
 
156
119
  ```tsx
157
- className={
158
- isDragging || isResizing
159
- ? 'pointer-events-none'
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
- ## 6. Access via Registry (Optional)
127
+ ### 5. Defaults
169
128
 
170
- Windows are also registered globally by ID:
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
- ## Architecture Summary
131
+ * Built-in styling
132
+ * Docking panel
133
+ * Resize edge detection
181
134
 
182
- - `createWindowStore(id)` creates isolated window state
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
- ## Design Principles
139
+ ## FURTHER READING
191
140
 
192
- - Fully decoupled window instances
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
- This enables building browser-based desktop-style interfaces with minimal setup and clean separation of concerns.
143
+ Full documentation:
144
+ https://gustavolmo.github.io/react-window-manager/