@gustavolmo/react-window-manager 0.2.1 → 0.3.1
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/dist/index.css +1 -644
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +7 -101
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +788 -678
- package/dist/index.js.map +1 -1
- package/dist/window-manager/internal/assets/svg-win-icons.d.ts +8 -0
- package/dist/window-manager/internal/assets/svg-win-icons.d.ts.map +1 -0
- package/dist/window-manager/internal/features/cursor/cursor-move-listener.d.ts +2 -0
- package/dist/window-manager/internal/features/cursor/cursor-move-listener.d.ts.map +1 -0
- package/dist/window-manager/internal/features/cursor/cursor-state.d.ts +9 -0
- package/dist/window-manager/internal/features/cursor/cursor-state.d.ts.map +1 -0
- package/dist/window-manager/internal/features/docking/docking-api.d.ts +15 -0
- package/dist/window-manager/internal/features/docking/docking-api.d.ts.map +1 -0
- package/dist/window-manager/internal/features/docking/docking-controls.d.ts +2 -0
- package/dist/window-manager/internal/features/docking/docking-controls.d.ts.map +1 -0
- package/dist/window-manager/internal/features/drag/drag-handle.d.ts +6 -0
- package/dist/window-manager/internal/features/drag/drag-handle.d.ts.map +1 -0
- package/dist/window-manager/internal/features/grid/grid-api.d.ts +4 -0
- package/dist/window-manager/internal/features/grid/grid-api.d.ts.map +1 -0
- package/dist/window-manager/internal/features/resizing/resizing-api.d.ts +7 -0
- package/dist/window-manager/internal/features/resizing/resizing-api.d.ts.map +1 -0
- package/dist/window-manager/internal/features/resizing/resizing-controls.d.ts +6 -0
- package/dist/window-manager/internal/features/resizing/resizing-controls.d.ts.map +1 -0
- package/dist/window-manager/internal/features/stack/stack-api.d.ts +6 -0
- package/dist/window-manager/internal/features/stack/stack-api.d.ts.map +1 -0
- package/dist/window-manager/internal/features/view-port/view-port-resize-listener.d.ts +2 -0
- package/dist/window-manager/internal/features/view-port/view-port-resize-listener.d.ts.map +1 -0
- package/dist/window-manager/internal/features/window-button.d.ts +11 -0
- package/dist/window-manager/internal/features/window-button.d.ts.map +1 -0
- package/dist/window-manager/internal/features/window-layout.d.ts +17 -0
- package/dist/window-manager/internal/features/window-layout.d.ts.map +1 -0
- package/dist/window-manager/internal/features/workspace/workspace-api.d.ts +6 -0
- package/dist/window-manager/internal/features/workspace/workspace-api.d.ts.map +1 -0
- package/dist/window-manager/internal/features/workspace/workspace-state.d.ts +3 -0
- package/dist/window-manager/internal/features/workspace/workspace-state.d.ts.map +1 -0
- package/dist/window-manager/model/window-types.d.ts +46 -0
- package/dist/window-manager/model/window-types.d.ts.map +1 -0
- package/dist/window-manager/model/workspace-types.d.ts +20 -0
- package/dist/window-manager/model/workspace-types.d.ts.map +1 -0
- package/dist/window-manager/registration/window-store-factory.d.ts +14 -0
- package/dist/window-manager/registration/window-store-factory.d.ts.map +1 -0
- package/dist/window-manager/rwm.d.ts +33 -0
- package/dist/window-manager/rwm.d.ts.map +1 -0
- package/dist/window-manager/workspace-layout.d.ts +19 -0
- package/dist/window-manager/workspace-layout.d.ts.map +1 -0
- package/package.json +6 -3
package/dist/index.js
CHANGED
|
@@ -1,264 +1,13 @@
|
|
|
1
|
-
// src/window-manager/window-store-factory.tsx
|
|
2
|
-
import { create } from "zustand";
|
|
3
|
-
var windowRegistry = {};
|
|
4
|
-
var createWindowStore = (windowId, bottomOffsetPx) => {
|
|
5
|
-
if (windowRegistry[windowId])
|
|
6
|
-
console.error("This store ID is already in use: " + windowId);
|
|
7
|
-
const zIndexAtLaunch = Object.keys(windowRegistry).length + 1;
|
|
8
|
-
const storeInstance = create((set, get) => ({
|
|
9
|
-
windowId,
|
|
10
|
-
isActive: false,
|
|
11
|
-
setIsActive: (isActive) => set({ isActive }),
|
|
12
|
-
resetFlag: false,
|
|
13
|
-
reset: () => set({ resetFlag: !get().resetFlag, isWinMinimized: true }),
|
|
14
|
-
zIndex: zIndexAtLaunch,
|
|
15
|
-
setZIndex: (newIndex) => set({ zIndex: newIndex }),
|
|
16
|
-
self: void 0,
|
|
17
|
-
setSelf: (ref) => set({ self: ref }),
|
|
18
|
-
winVisualState: "demaximized",
|
|
19
|
-
setWinVisualState: (newState) => set({ winVisualState: newState }),
|
|
20
|
-
isWinMinimized: true,
|
|
21
|
-
setIsWinMinimized: (isMini) => set({ isWinMinimized: isMini }),
|
|
22
|
-
dragClickOffset: { pointX: 0, pointY: 0 },
|
|
23
|
-
setDragClickOffset: (newCoord) => set({ dragClickOffset: { pointX: newCoord.pointX, pointY: newCoord.pointY } }),
|
|
24
|
-
isDragging: false,
|
|
25
|
-
setIsDragging: (updatedIsDragging) => set({ isDragging: updatedIsDragging }),
|
|
26
|
-
winCoord: { pointX: 40, pointY: 40 },
|
|
27
|
-
setWinCoord: (newWinCoord) => set({ winCoord: { pointX: newWinCoord.pointX, pointY: newWinCoord.pointY } }),
|
|
28
|
-
isResizing: false,
|
|
29
|
-
setIsResizing: (updatedIsResizing) => set({ isResizing: updatedIsResizing }),
|
|
30
|
-
winWidth: window.innerWidth * 0.95,
|
|
31
|
-
setWinWidth: (newWinWidth) => set({ winWidth: newWinWidth }),
|
|
32
|
-
winHeight: window.innerHeight * 0.75,
|
|
33
|
-
setWinHeight: (newWinHeight) => set({ winHeight: newWinHeight }),
|
|
34
|
-
stopDragAndResize: () => set({ isDragging: false, isResizing: false }),
|
|
35
|
-
maximizeWindow: () => {
|
|
36
|
-
set({
|
|
37
|
-
winCoord: { pointX: 0, pointY: 0 },
|
|
38
|
-
winHeight: window.innerHeight - bottomOffsetPx,
|
|
39
|
-
winWidth: window.innerWidth,
|
|
40
|
-
winVisualState: "maximized"
|
|
41
|
-
});
|
|
42
|
-
},
|
|
43
|
-
demaximizeWindow: () => {
|
|
44
|
-
set({
|
|
45
|
-
winCoord: { pointX: 40, pointY: 40 },
|
|
46
|
-
winWidth: window.innerWidth * 0.95,
|
|
47
|
-
winHeight: window.innerHeight * 0.75,
|
|
48
|
-
winVisualState: "demaximized"
|
|
49
|
-
});
|
|
50
|
-
},
|
|
51
|
-
minimizeWindow: () => set({ isWinMinimized: true }),
|
|
52
|
-
openWindow: () => {
|
|
53
|
-
const winRef = get().self;
|
|
54
|
-
if (get().isWinMinimized && winRef?.current) {
|
|
55
|
-
set({ isWinMinimized: false });
|
|
56
|
-
winRef.current.style.transform = "translate(0, 0) scale(1)";
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
dockWindowRight: () => {
|
|
60
|
-
set({
|
|
61
|
-
winCoord: { pointX: window.innerWidth / 2, pointY: 0 },
|
|
62
|
-
winWidth: window.innerWidth / 2,
|
|
63
|
-
winHeight: window.innerHeight - bottomOffsetPx,
|
|
64
|
-
winVisualState: "demaximized"
|
|
65
|
-
});
|
|
66
|
-
},
|
|
67
|
-
dockWindowLeft: () => {
|
|
68
|
-
set({
|
|
69
|
-
winCoord: { pointX: 0, pointY: 0 },
|
|
70
|
-
winWidth: window.innerWidth / 2,
|
|
71
|
-
winHeight: window.innerHeight - bottomOffsetPx,
|
|
72
|
-
winVisualState: "demaximized"
|
|
73
|
-
});
|
|
74
|
-
},
|
|
75
|
-
dockWindowTop: () => {
|
|
76
|
-
set({
|
|
77
|
-
winCoord: { pointX: 0, pointY: 0 },
|
|
78
|
-
winWidth: window.innerWidth,
|
|
79
|
-
winHeight: window.innerHeight / 2 - bottomOffsetPx / 2,
|
|
80
|
-
winVisualState: "demaximized"
|
|
81
|
-
});
|
|
82
|
-
},
|
|
83
|
-
dockWindowBottom: () => {
|
|
84
|
-
set({
|
|
85
|
-
winCoord: { pointX: 0, pointY: window.innerHeight / 2 - bottomOffsetPx / 2 },
|
|
86
|
-
winWidth: window.innerWidth,
|
|
87
|
-
winHeight: window.innerHeight / 2 - bottomOffsetPx / 2,
|
|
88
|
-
winVisualState: "demaximized"
|
|
89
|
-
});
|
|
90
|
-
},
|
|
91
|
-
dockWindowBottomRight: () => set({
|
|
92
|
-
winCoord: {
|
|
93
|
-
pointX: window.innerWidth / 2,
|
|
94
|
-
pointY: window.innerHeight / 2 - bottomOffsetPx / 2
|
|
95
|
-
},
|
|
96
|
-
winWidth: window.innerWidth / 2,
|
|
97
|
-
winHeight: window.innerHeight / 2 - bottomOffsetPx / 2,
|
|
98
|
-
winVisualState: "demaximized"
|
|
99
|
-
}),
|
|
100
|
-
dockWindowTopRight: () => set({
|
|
101
|
-
winCoord: { pointX: window.innerWidth / 2, pointY: 0 },
|
|
102
|
-
winWidth: window.innerWidth / 2,
|
|
103
|
-
winHeight: window.innerHeight / 2 - bottomOffsetPx / 2,
|
|
104
|
-
winVisualState: "demaximized"
|
|
105
|
-
}),
|
|
106
|
-
dockWindowBottomLeft: () => set({
|
|
107
|
-
winCoord: { pointX: 0, pointY: window.innerHeight / 2 - bottomOffsetPx / 2 },
|
|
108
|
-
winWidth: window.innerWidth / 2,
|
|
109
|
-
winHeight: window.innerHeight / 2 - bottomOffsetPx / 2,
|
|
110
|
-
winVisualState: "demaximized"
|
|
111
|
-
}),
|
|
112
|
-
dockWindowTopLeft: () => set({
|
|
113
|
-
winCoord: { pointX: 0, pointY: 0 },
|
|
114
|
-
winWidth: window.innerWidth / 2,
|
|
115
|
-
winHeight: window.innerHeight / 2 - bottomOffsetPx / 2,
|
|
116
|
-
winVisualState: "demaximized"
|
|
117
|
-
}),
|
|
118
|
-
WIN_MIN_WIDTH: 232,
|
|
119
|
-
WIN_MIN_HEIGHT: 128,
|
|
120
|
-
setWIN_MIN_WIDTH: (w) => set({ WIN_MIN_WIDTH: w }),
|
|
121
|
-
setWIN_MIN_HEIGHT: (h) => set({ WIN_MIN_HEIGHT: h })
|
|
122
|
-
}));
|
|
123
|
-
windowRegistry[windowId] = storeInstance;
|
|
124
|
-
return storeInstance;
|
|
125
|
-
};
|
|
1
|
+
// src/window-manager/registration/window-store-factory.tsx
|
|
2
|
+
import { create as create3 } from "zustand";
|
|
126
3
|
|
|
127
|
-
// src/window-manager/
|
|
128
|
-
|
|
129
|
-
for (const key of Object.keys(windowRegistry)) {
|
|
130
|
-
windowRegistry[key].getState().stopDragAndResize();
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
var resetAllWindows = () => {
|
|
134
|
-
for (const key of Object.keys(windowRegistry)) {
|
|
135
|
-
windowRegistry[key].getState().reset();
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
var bringTargetWindowToFront = (targetId) => {
|
|
139
|
-
const targetWindow = windowRegistry[targetId].getState();
|
|
140
|
-
for (const key of Object.keys(windowRegistry)) {
|
|
141
|
-
const window2 = windowRegistry[key].getState();
|
|
142
|
-
if (window2.windowId === targetWindow.windowId) {
|
|
143
|
-
continue;
|
|
144
|
-
}
|
|
145
|
-
window2.setIsActive(false);
|
|
146
|
-
if (window2.zIndex >= targetWindow.zIndex) {
|
|
147
|
-
window2.setZIndex(window2.zIndex - 1);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
targetWindow.setZIndex(Object.keys(windowRegistry).length);
|
|
151
|
-
targetWindow.setIsActive(true);
|
|
152
|
-
};
|
|
153
|
-
var getOpenedWindowCount = () => {
|
|
154
|
-
let openWnidowCount = 0;
|
|
155
|
-
for (const key of Object.keys(windowRegistry)) {
|
|
156
|
-
if (!windowRegistry[key].getState().isWinMinimized)
|
|
157
|
-
openWnidowCount++;
|
|
158
|
-
}
|
|
159
|
-
return openWnidowCount;
|
|
160
|
-
};
|
|
4
|
+
// src/window-manager/internal/features/window-layout.tsx
|
|
5
|
+
import { useEffect as useEffect3, useRef } from "react";
|
|
161
6
|
|
|
162
|
-
// src/window-manager/
|
|
7
|
+
// src/window-manager/internal/assets/svg-win-icons.tsx
|
|
163
8
|
import { jsx } from "react/jsx-runtime";
|
|
164
|
-
function
|
|
165
|
-
children,
|
|
166
|
-
useWindowStore,
|
|
167
|
-
className,
|
|
168
|
-
isClosedClassName = "brightness-[85%]",
|
|
169
|
-
isOpenClassName = "brightness-150"
|
|
170
|
-
}) {
|
|
171
|
-
const { openWindow, minimizeWindow, isWinMinimized, windowId, isActive } = useWindowStore();
|
|
172
|
-
const handleOpenCloseWin = () => {
|
|
173
|
-
if (isWinMinimized) {
|
|
174
|
-
bringTargetWindowToFront(windowId);
|
|
175
|
-
openWindow();
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
if (isActive) {
|
|
179
|
-
minimizeWindow();
|
|
180
|
-
}
|
|
181
|
-
bringTargetWindowToFront(windowId);
|
|
182
|
-
};
|
|
9
|
+
function IconWinMaximize({ color }) {
|
|
183
10
|
return /* @__PURE__ */ jsx(
|
|
184
|
-
"button",
|
|
185
|
-
{
|
|
186
|
-
id: `${windowId}_button`,
|
|
187
|
-
onClick: handleOpenCloseWin,
|
|
188
|
-
className: `
|
|
189
|
-
${className}
|
|
190
|
-
${isWinMinimized ? isClosedClassName : isOpenClassName}`,
|
|
191
|
-
children
|
|
192
|
-
}
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// src/screen-manager/cursor-state.ts
|
|
197
|
-
import { create as create2 } from "zustand";
|
|
198
|
-
var useCursorState = create2((set) => ({
|
|
199
|
-
x: 10,
|
|
200
|
-
y: 10,
|
|
201
|
-
setX: (newX) => set({ x: newX }),
|
|
202
|
-
setY: (newY) => set({ y: newY })
|
|
203
|
-
}));
|
|
204
|
-
|
|
205
|
-
// src/screen-manager/screen-listeners.tsx
|
|
206
|
-
import { useEffect } from "react";
|
|
207
|
-
import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
208
|
-
function ScreenListeners() {
|
|
209
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
210
|
-
/* @__PURE__ */ jsx2(CursorCoordinates, {}),
|
|
211
|
-
/* @__PURE__ */ jsx2(WindowResizeReset, {})
|
|
212
|
-
] });
|
|
213
|
-
}
|
|
214
|
-
function WindowResizeReset() {
|
|
215
|
-
useEffect(() => {
|
|
216
|
-
const handleWindowResize = () => {
|
|
217
|
-
resetAllWindows();
|
|
218
|
-
};
|
|
219
|
-
window.addEventListener("resize", handleWindowResize);
|
|
220
|
-
return () => document.removeEventListener("pointermove", handleWindowResize);
|
|
221
|
-
}, []);
|
|
222
|
-
return /* @__PURE__ */ jsx2(Fragment, {});
|
|
223
|
-
}
|
|
224
|
-
function CursorCoordinates() {
|
|
225
|
-
const { setX, setY } = useCursorState();
|
|
226
|
-
useEffect(() => {
|
|
227
|
-
const handleWindowPosition = (e) => {
|
|
228
|
-
e.preventDefault();
|
|
229
|
-
setX(e.clientX);
|
|
230
|
-
setY(e.clientY);
|
|
231
|
-
};
|
|
232
|
-
document.addEventListener("pointermove", handleWindowPosition);
|
|
233
|
-
return () => document.removeEventListener("pointermove", handleWindowPosition);
|
|
234
|
-
}, [setX, setY]);
|
|
235
|
-
return /* @__PURE__ */ jsx2(Fragment, {});
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
// src/window-manager/workspace-layout.tsx
|
|
239
|
-
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
240
|
-
function WorkspaceLayout({ children }) {
|
|
241
|
-
return /* @__PURE__ */ jsxs2(
|
|
242
|
-
"main",
|
|
243
|
-
{
|
|
244
|
-
onMouseLeave: stopAllDragAndResize,
|
|
245
|
-
onMouseUp: stopAllDragAndResize,
|
|
246
|
-
className: "absolute overflow-hidden h-full w-full touch-none",
|
|
247
|
-
children: [
|
|
248
|
-
/* @__PURE__ */ jsx3(ScreenListeners, {}),
|
|
249
|
-
children
|
|
250
|
-
]
|
|
251
|
-
}
|
|
252
|
-
);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
// src/window-manager/window-layout.tsx
|
|
256
|
-
import { useEffect as useEffect4, useRef } from "react";
|
|
257
|
-
|
|
258
|
-
// src/window-assets/svg-win-icons.tsx
|
|
259
|
-
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
260
|
-
function iconWinMaximize(color) {
|
|
261
|
-
return /* @__PURE__ */ jsx4(
|
|
262
11
|
"svg",
|
|
263
12
|
{
|
|
264
13
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -270,7 +19,7 @@ function iconWinMaximize(color) {
|
|
|
270
19
|
stroke: color ? color : "#cccccc",
|
|
271
20
|
color: color ? color : "#cccccc",
|
|
272
21
|
className: "size-6",
|
|
273
|
-
children: /* @__PURE__ */
|
|
22
|
+
children: /* @__PURE__ */ jsx(
|
|
274
23
|
"path",
|
|
275
24
|
{
|
|
276
25
|
strokeLinecap: "round",
|
|
@@ -281,8 +30,8 @@ function iconWinMaximize(color) {
|
|
|
281
30
|
}
|
|
282
31
|
);
|
|
283
32
|
}
|
|
284
|
-
function
|
|
285
|
-
return /* @__PURE__ */
|
|
33
|
+
function IconWinDemaximize({ color }) {
|
|
34
|
+
return /* @__PURE__ */ jsx(
|
|
286
35
|
"svg",
|
|
287
36
|
{
|
|
288
37
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -294,7 +43,7 @@ function iconWinDemaximize(color) {
|
|
|
294
43
|
stroke: color ? color : "#cccccc",
|
|
295
44
|
color: color ? color : "#cccccc",
|
|
296
45
|
className: "size-6",
|
|
297
|
-
children: /* @__PURE__ */
|
|
46
|
+
children: /* @__PURE__ */ jsx(
|
|
298
47
|
"path",
|
|
299
48
|
{
|
|
300
49
|
strokeLinecap: "round",
|
|
@@ -305,8 +54,8 @@ function iconWinDemaximize(color) {
|
|
|
305
54
|
}
|
|
306
55
|
);
|
|
307
56
|
}
|
|
308
|
-
function
|
|
309
|
-
return /* @__PURE__ */
|
|
57
|
+
function IconWinMinimize({ color }) {
|
|
58
|
+
return /* @__PURE__ */ jsx(
|
|
310
59
|
"svg",
|
|
311
60
|
{
|
|
312
61
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -318,354 +67,362 @@ function iconWinMinimize(color) {
|
|
|
318
67
|
stroke: color ? color : "#cccccc",
|
|
319
68
|
color: color ? color : "#cccccc",
|
|
320
69
|
className: "size-6",
|
|
321
|
-
children: /* @__PURE__ */
|
|
70
|
+
children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18 18 6M6 6l12 12" })
|
|
322
71
|
}
|
|
323
72
|
);
|
|
324
73
|
}
|
|
325
74
|
|
|
326
|
-
// src/window-manager/
|
|
327
|
-
import {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
dockWindowBottom,
|
|
335
|
-
dockWindowTop,
|
|
336
|
-
dockWindowTopLeft,
|
|
337
|
-
dockWindowBottomLeft,
|
|
338
|
-
dockWindowTopRight,
|
|
339
|
-
dockWindowBottomRight
|
|
340
|
-
} = useWindowStore();
|
|
341
|
-
const [isVisible, setIsVisible] = useState(false);
|
|
342
|
-
const [isHovering, setIsHovering] = useState(false);
|
|
343
|
-
useEffect2(() => {
|
|
344
|
-
let dealy;
|
|
345
|
-
if (isDragging) {
|
|
346
|
-
dealy = setTimeout(() => {
|
|
347
|
-
setIsVisible(true);
|
|
348
|
-
}, 100);
|
|
349
|
-
} else {
|
|
350
|
-
setIsVisible(false);
|
|
351
|
-
}
|
|
352
|
-
return () => clearTimeout(dealy);
|
|
353
|
-
}, [isDragging]);
|
|
354
|
-
const cornerDockControl = /* @__PURE__ */ jsxs3("div", { className: `flex xl:p-0 shrink-0 gap-0.5`, children: [
|
|
355
|
-
/* @__PURE__ */ jsxs3("div", { className: "flex flex-col justify-center gap-0.5", children: [
|
|
356
|
-
/* @__PURE__ */ jsx5(
|
|
357
|
-
"button",
|
|
358
|
-
{
|
|
359
|
-
className: "hover:bg-zinc-300 border border-zinc-500 bg-zinc-600 w-10 h-6 rounded-sm",
|
|
360
|
-
onMouseUp: dockWindowTopLeft
|
|
361
|
-
}
|
|
362
|
-
),
|
|
363
|
-
/* @__PURE__ */ jsx5(
|
|
364
|
-
"button",
|
|
365
|
-
{
|
|
366
|
-
className: "hover:bg-zinc-300 border border-zinc-500 bg-zinc-600 w-10 h-6 rounded-sm",
|
|
367
|
-
onMouseUp: dockWindowBottomLeft
|
|
368
|
-
}
|
|
369
|
-
)
|
|
370
|
-
] }),
|
|
371
|
-
/* @__PURE__ */ jsxs3("div", { className: "flex flex-col justify-center gap-0.5", children: [
|
|
372
|
-
/* @__PURE__ */ jsx5(
|
|
373
|
-
"button",
|
|
374
|
-
{
|
|
375
|
-
className: "hover:bg-zinc-300 border border-zinc-500 bg-zinc-600 w-10 h-6 rounded-sm",
|
|
376
|
-
onMouseUp: dockWindowTopRight
|
|
377
|
-
}
|
|
378
|
-
),
|
|
379
|
-
/* @__PURE__ */ jsx5(
|
|
380
|
-
"button",
|
|
381
|
-
{
|
|
382
|
-
className: "hover:bg-zinc-300 border border-zinc-500 bg-zinc-600 w-10 h-6 rounded-sm",
|
|
383
|
-
onMouseUp: dockWindowBottomRight
|
|
384
|
-
}
|
|
385
|
-
)
|
|
386
|
-
] })
|
|
387
|
-
] });
|
|
388
|
-
const sideDideControl = /* @__PURE__ */ jsxs3("div", { className: `flex shrink-0 items-center gap-0.5`, children: [
|
|
389
|
-
/* @__PURE__ */ jsx5(
|
|
390
|
-
"button",
|
|
391
|
-
{
|
|
392
|
-
className: "hover:bg-zinc-300 border border-zinc-500 bg-zinc-600 w-8 h-12 rounded-sm",
|
|
393
|
-
onMouseUp: dockWindowLeft
|
|
394
|
-
}
|
|
395
|
-
),
|
|
396
|
-
/* @__PURE__ */ jsx5(
|
|
397
|
-
"button",
|
|
398
|
-
{
|
|
399
|
-
className: "hover:bg-zinc-300 border border-zinc-500 bg-zinc-600 w-8 h-12 rounded-sm",
|
|
400
|
-
onMouseUp: dockWindowRight
|
|
401
|
-
}
|
|
402
|
-
)
|
|
403
|
-
] });
|
|
404
|
-
const horizontalDockControl = /* @__PURE__ */ jsxs3("div", { className: `flex flex-col shrink-0 items-center gap-0.5`, children: [
|
|
405
|
-
/* @__PURE__ */ jsx5(
|
|
406
|
-
"button",
|
|
407
|
-
{
|
|
408
|
-
className: "hover:bg-zinc-300 border border-zinc-500 bg-zinc-600 w-14 h-6 rounded-sm",
|
|
409
|
-
onMouseUp: dockWindowTop
|
|
410
|
-
}
|
|
411
|
-
),
|
|
412
|
-
/* @__PURE__ */ jsx5(
|
|
413
|
-
"button",
|
|
414
|
-
{
|
|
415
|
-
className: "hover:bg-zinc-300 border border-zinc-500 bg-zinc-600 w-14 h-6 rounded-sm",
|
|
416
|
-
onMouseUp: dockWindowBottom
|
|
417
|
-
}
|
|
418
|
-
)
|
|
419
|
-
] });
|
|
420
|
-
const windowDockPannel = /* @__PURE__ */ jsx5(
|
|
421
|
-
"span",
|
|
422
|
-
{
|
|
423
|
-
className: "pointer-events-auto px-4 pb-4",
|
|
424
|
-
onMouseOver: () => setIsHovering(true),
|
|
425
|
-
onMouseLeave: () => setIsHovering(false),
|
|
426
|
-
children: /* @__PURE__ */ jsxs3(
|
|
427
|
-
"section",
|
|
428
|
-
{
|
|
429
|
-
className: `
|
|
430
|
-
flex w-fit border border-zinc-600 border-t-0 rounded-b-md bg-zinc-800
|
|
431
|
-
overflow-hidden px-8 gap-4 h-full py-4
|
|
432
|
-
`,
|
|
433
|
-
children: [
|
|
434
|
-
cornerDockControl,
|
|
435
|
-
horizontalDockControl,
|
|
436
|
-
sideDideControl
|
|
437
|
-
]
|
|
438
|
-
}
|
|
439
|
-
)
|
|
440
|
-
}
|
|
441
|
-
);
|
|
442
|
-
return /* @__PURE__ */ jsx5(
|
|
443
|
-
"div",
|
|
444
|
-
{
|
|
445
|
-
className: `
|
|
446
|
-
${isVisible ? isHovering ? "top-0 opacity-50" : "top-[-68px] opacity-80" : "top-[-104px] opacity-0"}
|
|
447
|
-
transition-all duration-500
|
|
448
|
-
absolute z-50 flex items-center justify-center
|
|
449
|
-
w-full mx-auto pointer-events-none`,
|
|
450
|
-
children: windowDockPannel
|
|
451
|
-
}
|
|
452
|
-
);
|
|
453
|
-
}
|
|
75
|
+
// src/window-manager/internal/features/cursor/cursor-state.ts
|
|
76
|
+
import { create } from "zustand";
|
|
77
|
+
var useCursorState = create((set) => ({
|
|
78
|
+
x: 10,
|
|
79
|
+
y: 10,
|
|
80
|
+
setX: (newX) => set({ x: newX }),
|
|
81
|
+
setY: (newY) => set({ y: newY })
|
|
82
|
+
}));
|
|
454
83
|
|
|
455
|
-
// src/window-manager/
|
|
456
|
-
import { useEffect
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
84
|
+
// src/window-manager/internal/features/resizing/resizing-controls.tsx
|
|
85
|
+
import { useEffect } from "react";
|
|
86
|
+
|
|
87
|
+
// src/window-manager/internal/features/workspace/workspace-state.ts
|
|
88
|
+
import { create as create2 } from "zustand";
|
|
89
|
+
var useWorkspaceState = create2((set) => ({
|
|
90
|
+
ref: null,
|
|
91
|
+
setRef: (newRef) => set({ ref: newRef }),
|
|
92
|
+
activeWindowId: "react-dynamic-window-instance0",
|
|
93
|
+
setActiveWindowId: (newId) => set({ activeWindowId: newId }),
|
|
94
|
+
responsiveBreak: "sm",
|
|
95
|
+
setResponsiveBreak: (breakPoint) => set({ responsiveBreak: breakPoint })
|
|
96
|
+
}));
|
|
97
|
+
|
|
98
|
+
// src/window-manager/internal/features/workspace/workspace-api.ts
|
|
99
|
+
var wsApi = {
|
|
100
|
+
getRect: () => {
|
|
101
|
+
const rect = useWorkspaceState.getState().ref?.getBoundingClientRect();
|
|
102
|
+
const top = rect?.top ?? 0;
|
|
103
|
+
const left = rect?.left ?? 0;
|
|
104
|
+
const innerHeight = rect?.height ?? 0;
|
|
105
|
+
const innerWidth = rect?.width ?? 0;
|
|
106
|
+
const bottom = top + innerHeight;
|
|
107
|
+
const right = left + innerWidth;
|
|
108
|
+
const centerX = left + innerWidth / 2;
|
|
109
|
+
const centerY = top + innerHeight / 2;
|
|
110
|
+
const wsWindow = {
|
|
111
|
+
top,
|
|
112
|
+
left,
|
|
113
|
+
innerHeight,
|
|
114
|
+
innerWidth,
|
|
115
|
+
bottom,
|
|
116
|
+
right,
|
|
117
|
+
centerX,
|
|
118
|
+
centerY
|
|
119
|
+
};
|
|
120
|
+
return wsWindow;
|
|
121
|
+
},
|
|
122
|
+
isBelowBreakPoint: () => {
|
|
123
|
+
const wsRect = wsApi.getRect();
|
|
124
|
+
const breakPoint = useWorkspaceState.getState().responsiveBreak;
|
|
125
|
+
return wsRect.innerWidth < responsiveBreakInPx(breakPoint);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
var responsiveBreakInPx = (breakPoint) => {
|
|
129
|
+
switch (breakPoint) {
|
|
130
|
+
case "sm":
|
|
131
|
+
return 640;
|
|
132
|
+
case "md":
|
|
133
|
+
return 768;
|
|
134
|
+
case "lg":
|
|
135
|
+
return 1024;
|
|
136
|
+
case "xl":
|
|
137
|
+
return 1280;
|
|
138
|
+
case "never":
|
|
139
|
+
return 0;
|
|
140
|
+
case "always":
|
|
141
|
+
return Infinity;
|
|
142
|
+
default:
|
|
143
|
+
return breakPoint;
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
// src/window-manager/internal/features/resizing/resizing-api.ts
|
|
148
|
+
var resizeApi = {
|
|
149
|
+
stopAllDragAndResize: () => {
|
|
150
|
+
for (const key of Object.keys(windowRegistry)) {
|
|
151
|
+
windowRegistry[key].getState().isDragging = false;
|
|
152
|
+
windowRegistry[key].getState().resizeAction = false;
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
setResizeAction: (winId, action) => {
|
|
156
|
+
windowRegistry[winId].setState({ resizeAction: action });
|
|
157
|
+
},
|
|
158
|
+
dispatchResizeAction: (winId) => {
|
|
159
|
+
const ctx = getDependencies(winId);
|
|
160
|
+
if (!ctx.win.resizeAction)
|
|
476
161
|
return;
|
|
477
|
-
setWinVisualState("demaximized");
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
162
|
+
ctx.win.setWinVisualState("demaximized");
|
|
163
|
+
switch (ctx.win.resizeAction) {
|
|
164
|
+
case "s":
|
|
165
|
+
privateApi.resizeBottomWinHeight(ctx);
|
|
166
|
+
break;
|
|
167
|
+
case "n":
|
|
168
|
+
privateApi.resizeTopWinHeight(ctx);
|
|
169
|
+
break;
|
|
170
|
+
case "e":
|
|
171
|
+
privateApi.resizeRightWinWidth(ctx);
|
|
172
|
+
break;
|
|
173
|
+
case "w":
|
|
174
|
+
privateApi.resizeLeftWinWidth(ctx);
|
|
175
|
+
break;
|
|
176
|
+
case "se":
|
|
177
|
+
privateApi.resizeRightBottomWidthAndHeight(ctx);
|
|
178
|
+
break;
|
|
179
|
+
case "sw":
|
|
180
|
+
privateApi.resizeLeftBottomWidthAndHeight(ctx);
|
|
181
|
+
break;
|
|
182
|
+
case "ne":
|
|
183
|
+
privateApi.resizeRightTopWidthAndHeight(ctx);
|
|
184
|
+
break;
|
|
185
|
+
case "nw":
|
|
186
|
+
privateApi.resizeLeftTopWidthAndHeight(ctx);
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
var privateApi = {
|
|
192
|
+
resizeRightWinWidth: (resizeCtx) => {
|
|
193
|
+
const { wsRect, win, winBox, x, y } = resizeCtx;
|
|
497
194
|
if (!winBox)
|
|
498
195
|
return;
|
|
499
|
-
const minWinWidth = x - winBox.left < WIN_MIN_WIDTH;
|
|
196
|
+
const minWinWidth = x - winBox.left < win.WIN_MIN_WIDTH;
|
|
500
197
|
if (minWinWidth)
|
|
501
198
|
return;
|
|
502
|
-
const cursorOutOfBounds = x >
|
|
199
|
+
const cursorOutOfBounds = x > wsRect.right || x < wsRect.left;
|
|
503
200
|
if (cursorOutOfBounds)
|
|
504
201
|
return;
|
|
505
202
|
const sizeDiff = x - winBox.right;
|
|
506
|
-
setWinWidth(winWidth + sizeDiff);
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
const winBox =
|
|
203
|
+
win.setWinWidth(win.winWidth + sizeDiff);
|
|
204
|
+
},
|
|
205
|
+
resizeLeftWinWidth: (resizeCtx) => {
|
|
206
|
+
const { wsRect, win, winBox, x, y } = resizeCtx;
|
|
510
207
|
if (!winBox)
|
|
511
208
|
return;
|
|
512
|
-
const minWinWidth = winBox.right - x <= WIN_MIN_WIDTH;
|
|
209
|
+
const minWinWidth = winBox.right - x <= win.WIN_MIN_WIDTH;
|
|
513
210
|
if (minWinWidth)
|
|
514
211
|
return;
|
|
515
|
-
const cursorOutOfBounds = x >
|
|
212
|
+
const cursorOutOfBounds = x > wsRect.right || x < wsRect.left;
|
|
516
213
|
if (cursorOutOfBounds)
|
|
517
214
|
return;
|
|
518
215
|
const sizeDiff = winBox.left - x;
|
|
519
|
-
setWinWidth(winWidth + sizeDiff);
|
|
520
|
-
setWinCoord({ pointX: x, pointY: winCoord.pointY });
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
const winBox =
|
|
216
|
+
win.setWinWidth(win.winWidth + sizeDiff);
|
|
217
|
+
win.setWinCoord({ pointX: x, pointY: win.winCoord.pointY });
|
|
218
|
+
},
|
|
219
|
+
resizeTopWinHeight: (resizeCtx) => {
|
|
220
|
+
const { wsRect, win, winBox, x, y } = resizeCtx;
|
|
524
221
|
if (!winBox)
|
|
525
222
|
return;
|
|
526
|
-
const minWinHeight = winBox.bottom - y <= WIN_MIN_HEIGHT;
|
|
223
|
+
const minWinHeight = winBox.bottom - y <= win.WIN_MIN_HEIGHT;
|
|
527
224
|
if (minWinHeight)
|
|
528
225
|
return;
|
|
529
|
-
const cursorOutOfBounds = y >
|
|
226
|
+
const cursorOutOfBounds = y > wsRect.bottom || y < wsRect.top;
|
|
530
227
|
if (cursorOutOfBounds)
|
|
531
228
|
return;
|
|
532
229
|
const sizeDiff = winBox.top - y;
|
|
533
|
-
setWinHeight(winHeight + sizeDiff);
|
|
534
|
-
setWinCoord({ pointX: winCoord.pointX, pointY: y });
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
const winBox =
|
|
230
|
+
win.setWinHeight(win.winHeight + sizeDiff);
|
|
231
|
+
win.setWinCoord({ pointX: win.winCoord.pointX, pointY: y });
|
|
232
|
+
},
|
|
233
|
+
resizeBottomWinHeight: (resizeCtx) => {
|
|
234
|
+
const { wsRect, win, winBox, x, y } = resizeCtx;
|
|
538
235
|
if (!winBox)
|
|
539
236
|
return;
|
|
540
|
-
const minWinHeight = y - winBox.top < WIN_MIN_HEIGHT;
|
|
237
|
+
const minWinHeight = y - winBox.top < win.WIN_MIN_HEIGHT;
|
|
541
238
|
if (minWinHeight)
|
|
542
239
|
return;
|
|
543
|
-
const cursorOutOfBounds = y >
|
|
240
|
+
const cursorOutOfBounds = y > wsRect.bottom || y < wsRect.top;
|
|
544
241
|
if (cursorOutOfBounds)
|
|
545
242
|
return;
|
|
546
243
|
const sizeDiff = y - winBox.bottom;
|
|
547
|
-
setWinHeight(winHeight + sizeDiff);
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
resizeRightWinWidth();
|
|
551
|
-
resizeBottomWinHeight();
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
resizeLeftWinWidth();
|
|
555
|
-
resizeBottomWinHeight();
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
resizeRightWinWidth();
|
|
559
|
-
resizeTopWinHeight();
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
|
|
244
|
+
win.setWinHeight(win.winHeight + sizeDiff);
|
|
245
|
+
},
|
|
246
|
+
resizeRightBottomWidthAndHeight: (resizeCtx) => {
|
|
247
|
+
privateApi.resizeRightWinWidth(resizeCtx);
|
|
248
|
+
privateApi.resizeBottomWinHeight(resizeCtx);
|
|
249
|
+
},
|
|
250
|
+
resizeLeftBottomWidthAndHeight: (resizeCtx) => {
|
|
251
|
+
privateApi.resizeLeftWinWidth(resizeCtx);
|
|
252
|
+
privateApi.resizeBottomWinHeight(resizeCtx);
|
|
253
|
+
},
|
|
254
|
+
resizeRightTopWidthAndHeight: (resizeCtx) => {
|
|
255
|
+
privateApi.resizeRightWinWidth(resizeCtx);
|
|
256
|
+
privateApi.resizeTopWinHeight(resizeCtx);
|
|
257
|
+
},
|
|
258
|
+
/**
|
|
259
|
+
* @note this specific case needs it's own logic instead of simply calling
|
|
260
|
+
* resizeLeftWinWidth & resizeTopWinHeight. Since both manipulate
|
|
261
|
+
* winWidth, winHeight and winCoord, one's logic will override the other
|
|
262
|
+
*/
|
|
263
|
+
resizeLeftTopWidthAndHeight: (resizeCtx) => {
|
|
264
|
+
const { wsRect, win, winBox, x, y } = resizeCtx;
|
|
563
265
|
if (!winBox)
|
|
564
266
|
return;
|
|
565
|
-
const cursorOutOfBoundsY = y >
|
|
566
|
-
const cursorOutOfBoundsX = x >
|
|
267
|
+
const cursorOutOfBoundsY = y > wsRect.bottom || y < wsRect.top;
|
|
268
|
+
const cursorOutOfBoundsX = x > wsRect.right || x < wsRect.left;
|
|
567
269
|
if (cursorOutOfBoundsY || cursorOutOfBoundsX)
|
|
568
270
|
return;
|
|
569
|
-
const minWinHeight = winBox.bottom - y <= WIN_MIN_HEIGHT;
|
|
570
|
-
const minWinWidth = winBox.right - x <= WIN_MIN_WIDTH;
|
|
571
|
-
setWinCoord({
|
|
572
|
-
pointX: minWinWidth ? winCoord.pointX : x,
|
|
573
|
-
pointY: minWinHeight ? winCoord.pointY : y
|
|
271
|
+
const minWinHeight = winBox.bottom - y <= win.WIN_MIN_HEIGHT;
|
|
272
|
+
const minWinWidth = winBox.right - x <= win.WIN_MIN_WIDTH;
|
|
273
|
+
win.setWinCoord({
|
|
274
|
+
pointX: minWinWidth ? win.winCoord.pointX : x,
|
|
275
|
+
pointY: minWinHeight ? win.winCoord.pointY : y
|
|
574
276
|
});
|
|
575
277
|
if (!minWinHeight) {
|
|
576
278
|
const sizeDiffY = winBox.top - y;
|
|
577
|
-
setWinHeight(winHeight + sizeDiffY);
|
|
279
|
+
win.setWinHeight(win.winHeight + sizeDiffY);
|
|
578
280
|
}
|
|
579
281
|
if (!minWinWidth) {
|
|
580
282
|
const sizeDiffX = winBox.left - x;
|
|
581
|
-
setWinWidth(winWidth + sizeDiffX);
|
|
283
|
+
win.setWinWidth(win.winWidth + sizeDiffX);
|
|
582
284
|
}
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
const
|
|
589
|
-
|
|
590
|
-
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
var getDependencies = (winId) => {
|
|
288
|
+
const wsRect = wsApi.getRect();
|
|
289
|
+
const win = windowRegistry[winId].getState();
|
|
290
|
+
const winBox = win.self?.current?.getBoundingClientRect();
|
|
291
|
+
const { x, y } = useCursorState.getState();
|
|
292
|
+
return { wsRect, win, winBox, x, y };
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
// src/window-manager/internal/features/stack/stack-api.ts
|
|
296
|
+
var stackApi = {
|
|
297
|
+
bringTargetWindowToFront: (targetId) => {
|
|
298
|
+
const targetWindow = windowRegistry[targetId].getState();
|
|
591
299
|
for (const key of Object.keys(windowRegistry)) {
|
|
592
|
-
const
|
|
593
|
-
|
|
594
|
-
if (remoteWin.windowId === thisWin.windowId) {
|
|
300
|
+
const window2 = windowRegistry[key].getState();
|
|
301
|
+
if (window2.windowId === targetWindow.windowId) {
|
|
595
302
|
continue;
|
|
596
303
|
}
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
const remoteWinEndY = remoteWin.winCoord.pointY + remoteWin.winHeight;
|
|
601
|
-
const thisWinStartX = thisWin.winCoord.pointX;
|
|
602
|
-
const thisWinEndX = thisWin.winCoord.pointX + thisWin.winWidth;
|
|
603
|
-
const remoteWinStartX = remoteWin.winCoord.pointX;
|
|
604
|
-
const remoteWinEndX = remoteWin.winCoord.pointX + remoteWin.winWidth;
|
|
605
|
-
const isRemoteOutside = remoteWinEndY !== thisWinEndY || remoteWinEndX !== thisWinEndX || remoteWinStartY !== thisWinStartY || remoteWinStartX !== thisWinStartX;
|
|
606
|
-
if (currentResize === "right-width") {
|
|
607
|
-
const isEdgeAlignedOnXAxis = Math.abs(thisWinEndX - remoteWinStartX) <= tolerance;
|
|
608
|
-
const isOverlapOnYAxis = thisWinStartY <= remoteWinEndY && thisWinEndY >= remoteWinStartY;
|
|
609
|
-
const isEdgeResize = allowDistantResize ? isEdgeAlignedOnXAxis : isEdgeAlignedOnXAxis && isOverlapOnYAxis;
|
|
610
|
-
if (isEdgeResize) {
|
|
611
|
-
remoteWin.setIsResizing("left-width");
|
|
612
|
-
}
|
|
613
|
-
const isRemoteOnSameLane = Math.abs(thisWinEndX - remoteWinEndX) < tolerance && Math.abs(thisWinStartX - remoteWinStartX) < tolerance;
|
|
614
|
-
const isRemoteEdgeConnected = Math.abs(thisWinEndY - remoteWinStartY) < tolerance || Math.abs(thisWinStartY - remoteWinEndY) < tolerance;
|
|
615
|
-
const isStackResize = allowDistantResize ? isRemoteOnSameLane && isRemoteOutside : isRemoteOnSameLane && isRemoteEdgeConnected;
|
|
616
|
-
if (isStackResize) {
|
|
617
|
-
remoteWin.setIsResizing("right-width");
|
|
618
|
-
}
|
|
304
|
+
window2.setIsActive(false);
|
|
305
|
+
if (window2.zIndex >= targetWindow.zIndex) {
|
|
306
|
+
window2.setZIndex(window2.zIndex - 1);
|
|
619
307
|
}
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
308
|
+
}
|
|
309
|
+
targetWindow.setZIndex(Object.keys(windowRegistry).length);
|
|
310
|
+
targetWindow.setIsActive(true);
|
|
311
|
+
},
|
|
312
|
+
getOpenedWindowCount: () => {
|
|
313
|
+
let openWnidowCount = 0;
|
|
314
|
+
for (const key of Object.keys(windowRegistry))
|
|
315
|
+
if (!windowRegistry[key].getState().isWindowClosed)
|
|
316
|
+
openWnidowCount++;
|
|
317
|
+
return openWnidowCount;
|
|
318
|
+
},
|
|
319
|
+
resetStack: () => {
|
|
320
|
+
for (const key of Object.keys(windowRegistry)) {
|
|
321
|
+
windowRegistry[key].getState().reset();
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
// src/window-manager/internal/features/grid/grid-api.ts
|
|
327
|
+
var gridApi = {
|
|
328
|
+
orchestrateGridResize: (winId) => orchestrationGridResize(winId)
|
|
329
|
+
};
|
|
330
|
+
var orchestrationGridResize = (winId) => {
|
|
331
|
+
const tolerance = 4;
|
|
332
|
+
const allowDistantResize = stackApi.getOpenedWindowCount() >= 3;
|
|
333
|
+
const thisWin = windowRegistry[winId].getState();
|
|
334
|
+
const currentResize = thisWin.resizeAction;
|
|
335
|
+
for (const key of Object.keys(windowRegistry)) {
|
|
336
|
+
const remoteWin = windowRegistry[key].getState();
|
|
337
|
+
if (remoteWin.windowId === thisWin.windowId) {
|
|
338
|
+
continue;
|
|
339
|
+
}
|
|
340
|
+
const thisWinStartY = thisWin.winCoord.pointY;
|
|
341
|
+
const thisWinEndY = thisWin.winCoord.pointY + thisWin.winHeight;
|
|
342
|
+
const remoteWinStartY = remoteWin.winCoord.pointY;
|
|
343
|
+
const remoteWinEndY = remoteWin.winCoord.pointY + remoteWin.winHeight;
|
|
344
|
+
const thisWinStartX = thisWin.winCoord.pointX;
|
|
345
|
+
const thisWinEndX = thisWin.winCoord.pointX + thisWin.winWidth;
|
|
346
|
+
const remoteWinStartX = remoteWin.winCoord.pointX;
|
|
347
|
+
const remoteWinEndX = remoteWin.winCoord.pointX + remoteWin.winWidth;
|
|
348
|
+
const isRemoteOutside = remoteWinEndY !== thisWinEndY || remoteWinEndX !== thisWinEndX || remoteWinStartY !== thisWinStartY || remoteWinStartX !== thisWinStartX;
|
|
349
|
+
if (currentResize === "e") {
|
|
350
|
+
const isEdgeAlignedOnXAxis = Math.abs(thisWinEndX - remoteWinStartX) <= tolerance;
|
|
351
|
+
const isOverlapOnYAxis = thisWinStartY <= remoteWinEndY && thisWinEndY >= remoteWinStartY;
|
|
352
|
+
const isEdgeResize = allowDistantResize ? isEdgeAlignedOnXAxis : isEdgeAlignedOnXAxis && isOverlapOnYAxis;
|
|
353
|
+
if (isEdgeResize) {
|
|
354
|
+
remoteWin.setResizeAction("w");
|
|
633
355
|
}
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
remoteWin.setIsResizing("bottom-height");
|
|
640
|
-
}
|
|
641
|
-
const isRemoteOnSameLane = Math.abs(thisWinEndY - remoteWinEndY) < tolerance && Math.abs(thisWinStartY - remoteWinStartY) < tolerance;
|
|
642
|
-
const isRemoteEdgeConnected = Math.abs(thisWinEndX - remoteWinStartX) < tolerance || Math.abs(thisWinStartX - remoteWinEndX) < tolerance;
|
|
643
|
-
const isStackResize = allowDistantResize ? isRemoteOnSameLane && isRemoteOutside : isRemoteOnSameLane && isRemoteEdgeConnected;
|
|
644
|
-
if (isStackResize) {
|
|
645
|
-
remoteWin.setIsResizing("top-height");
|
|
646
|
-
}
|
|
356
|
+
const isRemoteOnSameLane = Math.abs(thisWinEndX - remoteWinEndX) < tolerance && Math.abs(thisWinStartX - remoteWinStartX) < tolerance;
|
|
357
|
+
const isRemoteEdgeConnected = Math.abs(thisWinEndY - remoteWinStartY) < tolerance || Math.abs(thisWinStartY - remoteWinEndY) < tolerance;
|
|
358
|
+
const isStackResize = allowDistantResize ? isRemoteOnSameLane && isRemoteOutside : isRemoteOnSameLane && isRemoteEdgeConnected;
|
|
359
|
+
if (isStackResize) {
|
|
360
|
+
remoteWin.setResizeAction("e");
|
|
647
361
|
}
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
362
|
+
}
|
|
363
|
+
if (currentResize === "w") {
|
|
364
|
+
const isEdgeAlignedOnXAxis = Math.abs(thisWinStartX - remoteWinEndX) <= tolerance;
|
|
365
|
+
const isOverlapOnYAxis = thisWinStartY <= remoteWinEndY && thisWinEndY >= remoteWinStartY;
|
|
366
|
+
const isEdgeResize = allowDistantResize ? isEdgeAlignedOnXAxis : isEdgeAlignedOnXAxis && isOverlapOnYAxis;
|
|
367
|
+
if (isEdgeResize) {
|
|
368
|
+
remoteWin.setResizeAction("e");
|
|
369
|
+
}
|
|
370
|
+
const isRemoteOnSameLane = Math.abs(thisWinEndX - remoteWinEndX) < tolerance && Math.abs(thisWinStartX - remoteWinStartX) < tolerance;
|
|
371
|
+
const isRemoteEdgeConnected = Math.abs(thisWinEndY - remoteWinStartY) < tolerance || Math.abs(thisWinStartY - remoteWinEndY) < tolerance;
|
|
372
|
+
const isStackResize = allowDistantResize ? isRemoteOnSameLane && isRemoteOutside : isRemoteOnSameLane && isRemoteEdgeConnected;
|
|
373
|
+
if (isStackResize) {
|
|
374
|
+
remoteWin.setResizeAction("w");
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
if (currentResize === "n") {
|
|
378
|
+
const isEdgeAlignedOnYAxis = Math.abs(thisWinStartY - remoteWinEndY) <= tolerance;
|
|
379
|
+
const isOverlapOnXAxis = thisWinStartX <= remoteWinEndX && thisWinEndX >= remoteWinStartX;
|
|
380
|
+
const isEdgeResize = allowDistantResize ? isEdgeAlignedOnYAxis : isEdgeAlignedOnYAxis && isOverlapOnXAxis;
|
|
381
|
+
if (isEdgeResize) {
|
|
382
|
+
remoteWin.setResizeAction("s");
|
|
383
|
+
}
|
|
384
|
+
const isRemoteOnSameLane = Math.abs(thisWinEndY - remoteWinEndY) < tolerance && Math.abs(thisWinStartY - remoteWinStartY) < tolerance;
|
|
385
|
+
const isRemoteEdgeConnected = Math.abs(thisWinEndX - remoteWinStartX) < tolerance || Math.abs(thisWinStartX - remoteWinEndX) < tolerance;
|
|
386
|
+
const isStackResize = allowDistantResize ? isRemoteOnSameLane && isRemoteOutside : isRemoteOnSameLane && isRemoteEdgeConnected;
|
|
387
|
+
if (isStackResize) {
|
|
388
|
+
remoteWin.setResizeAction("n");
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
if (currentResize === "s") {
|
|
392
|
+
const isEdgeAlignedOnYAxis = Math.abs(thisWinEndY - remoteWinStartY) <= tolerance;
|
|
393
|
+
const isOverlapOnXAxis = thisWinStartX <= remoteWinEndX && thisWinEndX >= remoteWinStartX;
|
|
394
|
+
const isEdgeResize = allowDistantResize ? isEdgeAlignedOnYAxis : isEdgeAlignedOnYAxis && isOverlapOnXAxis;
|
|
395
|
+
if (isEdgeResize) {
|
|
396
|
+
remoteWin.setResizeAction("n");
|
|
397
|
+
}
|
|
398
|
+
const isRemoteOnSameLane = Math.abs(thisWinEndY - remoteWinEndY) < tolerance && Math.abs(thisWinStartY - remoteWinStartY) < tolerance;
|
|
399
|
+
const isRemoteEdgeConnected = Math.abs(thisWinEndX - remoteWinStartX) < tolerance || Math.abs(thisWinStartX - remoteWinEndX) < tolerance;
|
|
400
|
+
const isStackResize = allowDistantResize ? isRemoteOnSameLane && isRemoteOutside : isRemoteOnSameLane && isRemoteEdgeConnected;
|
|
401
|
+
if (isStackResize) {
|
|
402
|
+
remoteWin.setResizeAction("s");
|
|
661
403
|
}
|
|
662
404
|
}
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
// src/window-manager/internal/features/resizing/resizing-controls.tsx
|
|
409
|
+
import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
410
|
+
function ResizingControls({ winId }) {
|
|
411
|
+
const { x, y } = useCursorState();
|
|
412
|
+
const { winCoord, winWidth, winHeight, resizeAction } = windowRegistry[winId]();
|
|
413
|
+
useEffect(() => {
|
|
414
|
+
resizeApi.dispatchResizeAction(winId);
|
|
415
|
+
}, [resizeAction, x, y]);
|
|
416
|
+
const handleResizeClick = (resizeAction2) => {
|
|
417
|
+
resizeApi.setResizeAction(winId, resizeAction2);
|
|
418
|
+
gridApi.orchestrateGridResize(winId);
|
|
663
419
|
};
|
|
664
|
-
return /* @__PURE__ */
|
|
665
|
-
/* @__PURE__ */
|
|
420
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
421
|
+
/* @__PURE__ */ jsx2(
|
|
666
422
|
"span",
|
|
667
423
|
{
|
|
668
|
-
|
|
424
|
+
onMouseUp: () => handleResizeClick(false),
|
|
425
|
+
onMouseDown: () => handleResizeClick("e"),
|
|
669
426
|
id: "win-resize-right-width",
|
|
670
427
|
className: "fixed w-2 opacity-60 cursor-w-resize z-10",
|
|
671
428
|
style: {
|
|
@@ -675,10 +432,11 @@ function ResizingControls({ useWindowStore, windowRef }) {
|
|
|
675
432
|
}
|
|
676
433
|
}
|
|
677
434
|
),
|
|
678
|
-
/* @__PURE__ */
|
|
435
|
+
/* @__PURE__ */ jsx2(
|
|
679
436
|
"span",
|
|
680
437
|
{
|
|
681
|
-
|
|
438
|
+
onMouseUp: () => handleResizeClick(false),
|
|
439
|
+
onMouseDown: () => handleResizeClick("w"),
|
|
682
440
|
id: "win-resize-left-width",
|
|
683
441
|
className: "fixed w-2 opacity-60 cursor-w-resize z-10",
|
|
684
442
|
style: {
|
|
@@ -688,10 +446,11 @@ function ResizingControls({ useWindowStore, windowRef }) {
|
|
|
688
446
|
}
|
|
689
447
|
}
|
|
690
448
|
),
|
|
691
|
-
/* @__PURE__ */
|
|
449
|
+
/* @__PURE__ */ jsx2(
|
|
692
450
|
"span",
|
|
693
451
|
{
|
|
694
|
-
|
|
452
|
+
onMouseUp: () => handleResizeClick(false),
|
|
453
|
+
onMouseDown: () => handleResizeClick("s"),
|
|
695
454
|
id: "win-resize-bottom-height",
|
|
696
455
|
className: "fixed h-2 opacity-60 cursor-s-resize z-10",
|
|
697
456
|
style: {
|
|
@@ -701,10 +460,11 @@ function ResizingControls({ useWindowStore, windowRef }) {
|
|
|
701
460
|
}
|
|
702
461
|
}
|
|
703
462
|
),
|
|
704
|
-
/* @__PURE__ */
|
|
463
|
+
/* @__PURE__ */ jsx2(
|
|
705
464
|
"span",
|
|
706
465
|
{
|
|
707
|
-
|
|
466
|
+
onMouseUp: () => handleResizeClick(false),
|
|
467
|
+
onMouseDown: () => handleResizeClick("n"),
|
|
708
468
|
id: "win-resize-top-height",
|
|
709
469
|
className: "fixed h-2 opacity-60 cursor-s-resize z-10",
|
|
710
470
|
style: {
|
|
@@ -714,10 +474,11 @@ function ResizingControls({ useWindowStore, windowRef }) {
|
|
|
714
474
|
}
|
|
715
475
|
}
|
|
716
476
|
),
|
|
717
|
-
/* @__PURE__ */
|
|
477
|
+
/* @__PURE__ */ jsx2(
|
|
718
478
|
"span",
|
|
719
479
|
{
|
|
720
|
-
|
|
480
|
+
onMouseUp: () => handleResizeClick(false),
|
|
481
|
+
onMouseDown: () => handleResizeClick("se"),
|
|
721
482
|
id: "win-resize-bottom-right-all",
|
|
722
483
|
className: "fixed h-3 w-3 opacity-60 cursor-se-resize z-20",
|
|
723
484
|
style: {
|
|
@@ -726,10 +487,11 @@ function ResizingControls({ useWindowStore, windowRef }) {
|
|
|
726
487
|
}
|
|
727
488
|
}
|
|
728
489
|
),
|
|
729
|
-
/* @__PURE__ */
|
|
490
|
+
/* @__PURE__ */ jsx2(
|
|
730
491
|
"span",
|
|
731
492
|
{
|
|
732
|
-
|
|
493
|
+
onMouseUp: () => handleResizeClick(false),
|
|
494
|
+
onMouseDown: () => handleResizeClick("sw"),
|
|
733
495
|
id: "win-resize-bottom-left-all",
|
|
734
496
|
className: "fixed h-3 w-3 opacity-60 cursor-sw-resize z-20",
|
|
735
497
|
style: {
|
|
@@ -738,10 +500,11 @@ function ResizingControls({ useWindowStore, windowRef }) {
|
|
|
738
500
|
}
|
|
739
501
|
}
|
|
740
502
|
),
|
|
741
|
-
/* @__PURE__ */
|
|
503
|
+
/* @__PURE__ */ jsx2(
|
|
742
504
|
"span",
|
|
743
505
|
{
|
|
744
|
-
|
|
506
|
+
onMouseUp: () => handleResizeClick(false),
|
|
507
|
+
onMouseDown: () => handleResizeClick("ne"),
|
|
745
508
|
id: "win-resize-top-right-all",
|
|
746
509
|
className: "fixed h-3 w-3 opacity-60 cursor-ne-resize z-20",
|
|
747
510
|
style: {
|
|
@@ -750,10 +513,11 @@ function ResizingControls({ useWindowStore, windowRef }) {
|
|
|
750
513
|
}
|
|
751
514
|
}
|
|
752
515
|
),
|
|
753
|
-
/* @__PURE__ */
|
|
516
|
+
/* @__PURE__ */ jsx2(
|
|
754
517
|
"span",
|
|
755
518
|
{
|
|
756
|
-
|
|
519
|
+
onMouseUp: () => handleResizeClick(false),
|
|
520
|
+
onMouseDown: () => handleResizeClick("nw"),
|
|
757
521
|
id: "win-resize-top-left-all",
|
|
758
522
|
className: "fixed h-3 w-3 opacity-60 cursor-nw-resize z-20",
|
|
759
523
|
style: {
|
|
@@ -765,18 +529,58 @@ function ResizingControls({ useWindowStore, windowRef }) {
|
|
|
765
529
|
] });
|
|
766
530
|
}
|
|
767
531
|
|
|
768
|
-
// src/window-manager/
|
|
769
|
-
import {
|
|
532
|
+
// src/window-manager/internal/features/drag/drag-handle.tsx
|
|
533
|
+
import { useEffect as useEffect2, useState } from "react";
|
|
534
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
535
|
+
function DragHandle({ winId }) {
|
|
536
|
+
const { x, y } = useCursorState();
|
|
537
|
+
const { winVisualState, isDragging, winCoord, setWinCoord, setIsDragging } = windowRegistry[winId]();
|
|
538
|
+
const [dragClickOffset, setDragClickOffset] = useState({
|
|
539
|
+
pointX: wsApi.getRect().left,
|
|
540
|
+
pointY: wsApi.getRect().top
|
|
541
|
+
});
|
|
542
|
+
useEffect2(() => {
|
|
543
|
+
if (wsApi.isBelowBreakPoint())
|
|
544
|
+
return;
|
|
545
|
+
if (!isDragging)
|
|
546
|
+
return;
|
|
547
|
+
if (winVisualState === "maximized")
|
|
548
|
+
dockApi.demaximizeWindow(winId);
|
|
549
|
+
const wsRect = wsApi.getRect();
|
|
550
|
+
let adjustedX = x - dragClickOffset.pointX;
|
|
551
|
+
if (x > wsRect.right || x < wsRect.left)
|
|
552
|
+
adjustedX = winCoord.pointX;
|
|
553
|
+
let adjustedY = y - dragClickOffset.pointY;
|
|
554
|
+
if (y > wsRect.bottom || y < wsRect.top)
|
|
555
|
+
adjustedY = winCoord.pointY;
|
|
556
|
+
setWinCoord({ pointX: adjustedX, pointY: adjustedY });
|
|
557
|
+
}, [isDragging, x, y]);
|
|
558
|
+
const startDrag = (isDragging2) => {
|
|
559
|
+
setDragClickOffset({ pointX: x - winCoord.pointX, pointY: y - winCoord.pointY });
|
|
560
|
+
setIsDragging(isDragging2);
|
|
561
|
+
};
|
|
562
|
+
return /* @__PURE__ */ jsx3(
|
|
563
|
+
"div",
|
|
564
|
+
{
|
|
565
|
+
onMouseDown: () => startDrag(true),
|
|
566
|
+
onMouseUp: () => startDrag(false),
|
|
567
|
+
onDoubleClick: () => dockApi.maximizeWindow(winId),
|
|
568
|
+
className: "grow min-w-8 h-8 px-2 text-white flex items-center text-sm bg-white bg-opacity-0 hover:bg-opacity-5 mix-blend-difference"
|
|
569
|
+
}
|
|
570
|
+
);
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
// src/window-manager/internal/features/window-layout.tsx
|
|
574
|
+
import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
770
575
|
function WindowLayout({
|
|
771
|
-
responsiveBreak = "lg",
|
|
772
576
|
children,
|
|
773
577
|
windowName,
|
|
774
578
|
navbarChildren,
|
|
775
|
-
|
|
776
|
-
defaultDock,
|
|
579
|
+
winId,
|
|
580
|
+
defaultDock = "default",
|
|
777
581
|
style
|
|
778
582
|
}) {
|
|
779
|
-
const {
|
|
583
|
+
const { ref: wsRef } = useWorkspaceState();
|
|
780
584
|
const windowRef = useRef(null);
|
|
781
585
|
const {
|
|
782
586
|
windowId,
|
|
@@ -785,107 +589,62 @@ function WindowLayout({
|
|
|
785
589
|
setSelf,
|
|
786
590
|
resetFlag,
|
|
787
591
|
winVisualState,
|
|
788
|
-
|
|
789
|
-
dragClickOffset,
|
|
790
|
-
setDragClickOffset,
|
|
791
|
-
isDragging,
|
|
792
|
-
setIsDragging,
|
|
592
|
+
isWindowClosed,
|
|
793
593
|
winCoord,
|
|
794
|
-
setWinCoord,
|
|
795
|
-
setIsResizing,
|
|
796
594
|
winWidth,
|
|
797
|
-
winHeight
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
demaximizeWindow,
|
|
801
|
-
dockWindowRight,
|
|
802
|
-
dockWindowLeft
|
|
803
|
-
} = useWindowStore();
|
|
804
|
-
useEffect4(() => {
|
|
595
|
+
winHeight
|
|
596
|
+
} = windowRegistry[winId]();
|
|
597
|
+
useEffect3(() => {
|
|
805
598
|
setSelf(windowRef);
|
|
806
|
-
if (
|
|
807
|
-
maximizeWindow();
|
|
808
|
-
else if (defaultDock === "left")
|
|
809
|
-
dockWindowLeft();
|
|
810
|
-
else if (defaultDock === "right")
|
|
811
|
-
dockWindowRight();
|
|
812
|
-
else if (defaultDock === "full")
|
|
813
|
-
maximizeWindow();
|
|
814
|
-
else
|
|
815
|
-
demaximizeWindow();
|
|
816
|
-
}, [setSelf, windowRef, resetFlag]);
|
|
817
|
-
useEffect4(() => {
|
|
818
|
-
if (isMobile())
|
|
819
|
-
return;
|
|
820
|
-
if (!isDragging)
|
|
599
|
+
if (wsApi.isBelowBreakPoint()) {
|
|
600
|
+
dockApi.maximizeWindow(winId);
|
|
821
601
|
return;
|
|
822
|
-
if (winVisualState === "maximized")
|
|
823
|
-
demaximizeWindow();
|
|
824
|
-
let adjustedX = x - dragClickOffset.pointX;
|
|
825
|
-
if (x > window.innerWidth || x < 0)
|
|
826
|
-
adjustedX = winCoord.pointX;
|
|
827
|
-
let adjustedY = y - dragClickOffset.pointY;
|
|
828
|
-
if (y > window.innerHeight || y < 0)
|
|
829
|
-
adjustedY = winCoord.pointY;
|
|
830
|
-
setWinCoord({ pointX: adjustedX, pointY: adjustedY });
|
|
831
|
-
}, [isDragging, x, y]);
|
|
832
|
-
const responsiveBreakInPx = (breakPoint) => {
|
|
833
|
-
switch (breakPoint) {
|
|
834
|
-
case "sm":
|
|
835
|
-
return 640;
|
|
836
|
-
case "md":
|
|
837
|
-
return 768;
|
|
838
|
-
case "lg":
|
|
839
|
-
return 1024;
|
|
840
|
-
case "xl":
|
|
841
|
-
return 1280;
|
|
842
|
-
case "never":
|
|
843
|
-
return 0;
|
|
844
|
-
case "always":
|
|
845
|
-
return Infinity;
|
|
846
|
-
default:
|
|
847
|
-
return breakPoint;
|
|
848
602
|
}
|
|
603
|
+
dockingRoutes[defaultDock](winId);
|
|
604
|
+
}, [setSelf, windowRef, resetFlag, wsRef]);
|
|
605
|
+
const dockingRoutes = {
|
|
606
|
+
right: dockApi.dockWindowRight,
|
|
607
|
+
left: dockApi.dockWindowLeft,
|
|
608
|
+
full: dockApi.maximizeWindow,
|
|
609
|
+
top: dockApi.dockWindowTop,
|
|
610
|
+
bottom: dockApi.dockWindowBottom,
|
|
611
|
+
"top-right": dockApi.dockWindowTopRight,
|
|
612
|
+
"top-left": dockApi.dockWindowTopLeft,
|
|
613
|
+
"bottom-right": dockApi.dockWindowBottomRight,
|
|
614
|
+
"bottom-left": dockApi.dockWindowBottomLeft,
|
|
615
|
+
default: dockApi.demaximizeWindow
|
|
849
616
|
};
|
|
850
|
-
const
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
setIsResizing(isResizing);
|
|
859
|
-
};
|
|
860
|
-
const maximizeControl = winVisualState === "maximized" ? /* @__PURE__ */ jsx7(
|
|
617
|
+
const maximizeControl = winVisualState === "maximized" ? /* @__PURE__ */ jsx4(
|
|
618
|
+
"button",
|
|
619
|
+
{
|
|
620
|
+
className: `block hover:bg-gray-500 hover:bg-opacity-10 px-5 h-full`,
|
|
621
|
+
onClick: () => dockApi.demaximizeWindow(winId),
|
|
622
|
+
children: /* @__PURE__ */ jsx4(IconWinDemaximize, { color: style?.navControlsColor })
|
|
623
|
+
}
|
|
624
|
+
) : /* @__PURE__ */ jsx4(
|
|
861
625
|
"button",
|
|
862
626
|
{
|
|
863
|
-
className: `block hover:bg-gray-
|
|
864
|
-
onClick:
|
|
865
|
-
children:
|
|
627
|
+
className: `block hover:bg-gray-500 hover:bg-opacity-10 px-5 h-full`,
|
|
628
|
+
onClick: () => dockApi.maximizeWindow(winId),
|
|
629
|
+
children: /* @__PURE__ */ jsx4(IconWinMaximize, { color: style?.navControlsColor })
|
|
866
630
|
}
|
|
867
|
-
)
|
|
631
|
+
);
|
|
632
|
+
const closeControl = /* @__PURE__ */ jsx4(
|
|
868
633
|
"button",
|
|
869
634
|
{
|
|
870
|
-
className:
|
|
871
|
-
onClick:
|
|
872
|
-
children:
|
|
635
|
+
className: "hover:bg-red-500 hover:bg-opacity-20 px-5 h-full",
|
|
636
|
+
onClick: () => dockApi.closeWindow(winId),
|
|
637
|
+
children: /* @__PURE__ */ jsx4(IconWinMinimize, { color: style?.navControlsColor })
|
|
873
638
|
}
|
|
874
639
|
);
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
!isMobile() && /* @__PURE__ */ jsx7(DockingControls, { useWindowStore }),
|
|
878
|
-
/* @__PURE__ */ jsxs5(
|
|
640
|
+
return /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
641
|
+
/* @__PURE__ */ jsxs2(
|
|
879
642
|
"div",
|
|
880
643
|
{
|
|
881
644
|
id: windowId,
|
|
882
645
|
ref: windowRef,
|
|
883
646
|
className: `fixed bg-white shadow-lg border border-zinc-600 rounded-sm overflow-hidden`,
|
|
884
|
-
onMouseDown: () => bringTargetWindowToFront(windowId),
|
|
885
|
-
onMouseUp: () => {
|
|
886
|
-
handleNavbarClick(false);
|
|
887
|
-
handleResizeClick(false);
|
|
888
|
-
},
|
|
647
|
+
onMouseDown: () => stackApi.bringTargetWindowToFront(windowId),
|
|
889
648
|
style: {
|
|
890
649
|
backgroundColor: style?.windowBackgroundColor,
|
|
891
650
|
top: `${winCoord.pointY}px`,
|
|
@@ -895,12 +654,12 @@ function WindowLayout({
|
|
|
895
654
|
zIndex: `${zIndex}`,
|
|
896
655
|
/* MINIMIZE LOGIC */
|
|
897
656
|
transition: "transform 0.2s ease-in-out, opacity 0.3s ease-in-out",
|
|
898
|
-
opacity:
|
|
899
|
-
transform:
|
|
900
|
-
${
|
|
657
|
+
opacity: isWindowClosed ? 0 : 1,
|
|
658
|
+
transform: isWindowClosed ? `translate(${wsApi.getRect().innerWidth / 2 - winCoord.pointX - winWidth / 2}px,
|
|
659
|
+
${wsApi.getRect().innerHeight - winCoord.pointY - winHeight / 2}px) scale(0.02)` : ""
|
|
901
660
|
},
|
|
902
661
|
children: [
|
|
903
|
-
/* @__PURE__ */
|
|
662
|
+
/* @__PURE__ */ jsxs2(
|
|
904
663
|
"nav",
|
|
905
664
|
{
|
|
906
665
|
style: {
|
|
@@ -910,34 +669,385 @@ function WindowLayout({
|
|
|
910
669
|
h-[32px] w-full flex items-center bg-neutral-800
|
|
911
670
|
${isActive ? "brightness-100 opacity-100" : "brightness-75 opacity-80"}`,
|
|
912
671
|
children: [
|
|
913
|
-
/* @__PURE__ */
|
|
914
|
-
/* @__PURE__ */
|
|
915
|
-
/* @__PURE__ */
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
onMouseDown: () => handleNavbarClick(true),
|
|
919
|
-
onDoubleClick: maximizeWindow,
|
|
920
|
-
className: "grow min-w-8 h-8 px-2 text-white flex items-center text-sm"
|
|
921
|
-
}
|
|
922
|
-
),
|
|
923
|
-
!isMobile() && maximizeControl,
|
|
924
|
-
minimizeControl
|
|
672
|
+
/* @__PURE__ */ jsx4("div", { className: "w-fit shrink-0 h-8 px-2 text-white flex items-center text-sm truncate", children: windowName }),
|
|
673
|
+
/* @__PURE__ */ jsx4("div", { className: "h-8 px-2 text-white flex items-center text-sm truncate", children: navbarChildren }),
|
|
674
|
+
/* @__PURE__ */ jsx4(DragHandle, { winId }),
|
|
675
|
+
!wsApi.isBelowBreakPoint() && maximizeControl,
|
|
676
|
+
closeControl
|
|
925
677
|
]
|
|
926
678
|
}
|
|
927
679
|
),
|
|
928
|
-
!
|
|
929
|
-
/* @__PURE__ */
|
|
680
|
+
!wsApi.isBelowBreakPoint() && /* @__PURE__ */ jsx4(ResizingControls, { winId }),
|
|
681
|
+
/* @__PURE__ */ jsx4("div", { className: `relative w-full h-[calc(100%-32px)] overflow-auto`, children })
|
|
930
682
|
]
|
|
931
683
|
}
|
|
932
684
|
),
|
|
933
685
|
" "
|
|
934
686
|
] });
|
|
935
687
|
}
|
|
688
|
+
|
|
689
|
+
// src/window-manager/internal/features/window-button.tsx
|
|
690
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
691
|
+
function WindowButton({
|
|
692
|
+
children,
|
|
693
|
+
winId,
|
|
694
|
+
className,
|
|
695
|
+
isClosedClassName = "brightness-[85%]",
|
|
696
|
+
isOpenClassName = "brightness-150"
|
|
697
|
+
}) {
|
|
698
|
+
const { isWindowClosed, windowId, isActive } = windowRegistry[winId]();
|
|
699
|
+
const handleOpenCloseWin = () => {
|
|
700
|
+
if (isWindowClosed) {
|
|
701
|
+
stackApi.bringTargetWindowToFront(windowId);
|
|
702
|
+
dockApi.openWindow(winId);
|
|
703
|
+
return;
|
|
704
|
+
}
|
|
705
|
+
if (isActive)
|
|
706
|
+
dockApi.closeWindow(winId);
|
|
707
|
+
stackApi.bringTargetWindowToFront(windowId);
|
|
708
|
+
};
|
|
709
|
+
return /* @__PURE__ */ jsx5(
|
|
710
|
+
"button",
|
|
711
|
+
{
|
|
712
|
+
id: `${windowId}_button`,
|
|
713
|
+
onClick: handleOpenCloseWin,
|
|
714
|
+
className: `
|
|
715
|
+
${className}
|
|
716
|
+
${isWindowClosed ? isClosedClassName : isOpenClassName}`,
|
|
717
|
+
children
|
|
718
|
+
}
|
|
719
|
+
);
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
// src/window-manager/registration/window-store-factory.tsx
|
|
723
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
724
|
+
var windownMinWidth = 232;
|
|
725
|
+
var windownMinHeight = 128;
|
|
726
|
+
var windowRegistry = {};
|
|
727
|
+
var createWindowStore = () => {
|
|
728
|
+
const zIndexAtLaunch = Object.keys(windowRegistry).length + 1;
|
|
729
|
+
const windowInstanceId = `react-dynamic-window-instance${Object.keys(windowRegistry).length}`;
|
|
730
|
+
const storeInstance = create3((set, get) => ({
|
|
731
|
+
windowId: windowInstanceId,
|
|
732
|
+
self: void 0,
|
|
733
|
+
setSelf: (ref) => set({ self: ref }),
|
|
734
|
+
WIN_MIN_WIDTH: windownMinWidth,
|
|
735
|
+
setWIN_MIN_WIDTH: (w) => set({ WIN_MIN_WIDTH: w }),
|
|
736
|
+
WIN_MIN_HEIGHT: windownMinHeight,
|
|
737
|
+
setWIN_MIN_HEIGHT: (h) => set({ WIN_MIN_HEIGHT: h }),
|
|
738
|
+
isActive: false,
|
|
739
|
+
setIsActive: (isActive) => {
|
|
740
|
+
useWorkspaceState.getState().setActiveWindowId(get().windowId);
|
|
741
|
+
set({ isActive });
|
|
742
|
+
},
|
|
743
|
+
resetFlag: false,
|
|
744
|
+
reset: () => set({ resetFlag: !get().resetFlag, isWindowClosed: true }),
|
|
745
|
+
zIndex: zIndexAtLaunch,
|
|
746
|
+
setZIndex: (newIndex) => set({ zIndex: newIndex }),
|
|
747
|
+
winVisualState: "demaximized",
|
|
748
|
+
setWinVisualState: (newState) => set({ winVisualState: newState }),
|
|
749
|
+
isWindowClosed: true,
|
|
750
|
+
setisWindowClosed: (isClosed) => set({ isWindowClosed: isClosed }),
|
|
751
|
+
winCoord: { pointX: 40, pointY: 40 },
|
|
752
|
+
setWinCoord: (newWinCoord) => set({ winCoord: { pointX: newWinCoord.pointX, pointY: newWinCoord.pointY } }),
|
|
753
|
+
winWidth: windownMinWidth,
|
|
754
|
+
setWinWidth: (newWinWidth) => set({ winWidth: newWinWidth }),
|
|
755
|
+
winHeight: windownMinHeight,
|
|
756
|
+
setWinHeight: (newWinHeight) => set({ winHeight: newWinHeight }),
|
|
757
|
+
resizeAction: false,
|
|
758
|
+
setResizeAction: (updatedIsResizing) => set({ resizeAction: updatedIsResizing }),
|
|
759
|
+
isDragging: false,
|
|
760
|
+
setIsDragging: (updatedIsDragging) => set({ isDragging: updatedIsDragging })
|
|
761
|
+
}));
|
|
762
|
+
windowRegistry[windowInstanceId] = storeInstance;
|
|
763
|
+
return {
|
|
764
|
+
id: storeInstance.getState().windowId,
|
|
765
|
+
store: storeInstance,
|
|
766
|
+
Window: (props) => /* @__PURE__ */ jsx6(WindowLayout, { ...props, winId: windowInstanceId }),
|
|
767
|
+
Button: (props) => /* @__PURE__ */ jsx6(WindowButton, { ...props, winId: windowInstanceId })
|
|
768
|
+
};
|
|
769
|
+
};
|
|
770
|
+
|
|
771
|
+
// src/window-manager/internal/features/docking/docking-api.ts
|
|
772
|
+
var dockApi = {
|
|
773
|
+
dockWindowRight: (winId) => {
|
|
774
|
+
windowRegistry[winId].setState({
|
|
775
|
+
winCoord: { pointX: wsApi.getRect().centerX, pointY: wsApi.getRect().top },
|
|
776
|
+
winWidth: wsApi.getRect().innerWidth / 2,
|
|
777
|
+
winHeight: wsApi.getRect().innerHeight,
|
|
778
|
+
winVisualState: "demaximized"
|
|
779
|
+
});
|
|
780
|
+
},
|
|
781
|
+
dockWindowLeft: (winId) => {
|
|
782
|
+
windowRegistry[winId].setState({
|
|
783
|
+
winCoord: { pointX: wsApi.getRect().left, pointY: wsApi.getRect().top },
|
|
784
|
+
winWidth: wsApi.getRect().innerWidth / 2,
|
|
785
|
+
winHeight: wsApi.getRect().innerHeight,
|
|
786
|
+
winVisualState: "demaximized"
|
|
787
|
+
});
|
|
788
|
+
},
|
|
789
|
+
dockWindowTop: (winId) => {
|
|
790
|
+
windowRegistry[winId].setState({
|
|
791
|
+
winCoord: { pointX: wsApi.getRect().left, pointY: wsApi.getRect().top },
|
|
792
|
+
winWidth: wsApi.getRect().innerWidth,
|
|
793
|
+
winHeight: wsApi.getRect().innerHeight / 2,
|
|
794
|
+
winVisualState: "demaximized"
|
|
795
|
+
});
|
|
796
|
+
},
|
|
797
|
+
dockWindowBottom: (winId) => {
|
|
798
|
+
windowRegistry[winId].setState({
|
|
799
|
+
winCoord: { pointX: wsApi.getRect().left, pointY: wsApi.getRect().centerY },
|
|
800
|
+
winWidth: wsApi.getRect().innerWidth,
|
|
801
|
+
winHeight: wsApi.getRect().innerHeight / 2,
|
|
802
|
+
winVisualState: "demaximized"
|
|
803
|
+
});
|
|
804
|
+
},
|
|
805
|
+
dockWindowBottomRight: (winId) => {
|
|
806
|
+
windowRegistry[winId].setState({
|
|
807
|
+
winCoord: {
|
|
808
|
+
pointX: wsApi.getRect().centerX,
|
|
809
|
+
pointY: wsApi.getRect().centerY
|
|
810
|
+
},
|
|
811
|
+
winWidth: wsApi.getRect().innerWidth / 2,
|
|
812
|
+
winHeight: wsApi.getRect().innerHeight / 2,
|
|
813
|
+
winVisualState: "demaximized"
|
|
814
|
+
});
|
|
815
|
+
},
|
|
816
|
+
dockWindowTopRight: (winId) => {
|
|
817
|
+
windowRegistry[winId].setState({
|
|
818
|
+
winCoord: { pointX: wsApi.getRect().centerX, pointY: wsApi.getRect().top },
|
|
819
|
+
winWidth: wsApi.getRect().innerWidth / 2,
|
|
820
|
+
winHeight: wsApi.getRect().innerHeight / 2,
|
|
821
|
+
winVisualState: "demaximized"
|
|
822
|
+
});
|
|
823
|
+
},
|
|
824
|
+
dockWindowBottomLeft: (winId) => {
|
|
825
|
+
windowRegistry[winId].setState({
|
|
826
|
+
winCoord: { pointX: wsApi.getRect().left, pointY: wsApi.getRect().centerY },
|
|
827
|
+
winWidth: wsApi.getRect().innerWidth / 2,
|
|
828
|
+
winHeight: wsApi.getRect().innerHeight / 2,
|
|
829
|
+
winVisualState: "demaximized"
|
|
830
|
+
});
|
|
831
|
+
},
|
|
832
|
+
dockWindowTopLeft: (winId) => {
|
|
833
|
+
windowRegistry[winId].setState({
|
|
834
|
+
winCoord: { pointX: wsApi.getRect().left, pointY: wsApi.getRect().top },
|
|
835
|
+
winWidth: wsApi.getRect().innerWidth / 2,
|
|
836
|
+
winHeight: wsApi.getRect().innerHeight / 2,
|
|
837
|
+
winVisualState: "demaximized"
|
|
838
|
+
});
|
|
839
|
+
},
|
|
840
|
+
maximizeWindow: (winId) => {
|
|
841
|
+
windowRegistry[winId].setState({
|
|
842
|
+
winCoord: { pointX: wsApi.getRect().left, pointY: wsApi.getRect().top },
|
|
843
|
+
winHeight: wsApi.getRect().innerHeight,
|
|
844
|
+
winWidth: wsApi.getRect().innerWidth,
|
|
845
|
+
winVisualState: "maximized"
|
|
846
|
+
});
|
|
847
|
+
},
|
|
848
|
+
demaximizeWindow: (winId) => {
|
|
849
|
+
windowRegistry[winId].setState({
|
|
850
|
+
winCoord: { pointX: wsApi.getRect().left + 16, pointY: wsApi.getRect().top + 16 },
|
|
851
|
+
winWidth: wsApi.getRect().innerWidth * 0.95,
|
|
852
|
+
winHeight: wsApi.getRect().innerHeight * 0.75,
|
|
853
|
+
winVisualState: "demaximized"
|
|
854
|
+
});
|
|
855
|
+
},
|
|
856
|
+
closeWindow: (winId) => {
|
|
857
|
+
windowRegistry[winId].setState({ isWindowClosed: true });
|
|
858
|
+
},
|
|
859
|
+
openWindow: (winId) => {
|
|
860
|
+
const winState = windowRegistry[winId].getState();
|
|
861
|
+
const winRef = winState.self;
|
|
862
|
+
if (winState.isWindowClosed && winRef?.current) {
|
|
863
|
+
windowRegistry[winId].setState({ isWindowClosed: false });
|
|
864
|
+
winRef.current.style.transform = "translate(0, 0) scale(1)";
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
};
|
|
868
|
+
|
|
869
|
+
// src/window-manager/rwm.ts
|
|
870
|
+
var rwm = {
|
|
871
|
+
dockApi,
|
|
872
|
+
resizeApi,
|
|
873
|
+
stackApi,
|
|
874
|
+
workspaceApi: wsApi,
|
|
875
|
+
worskpaceState: useWorkspaceState
|
|
876
|
+
};
|
|
877
|
+
var rwm_default = rwm;
|
|
878
|
+
|
|
879
|
+
// src/window-manager/workspace-layout.tsx
|
|
880
|
+
import { useEffect as useEffect6, useRef as useRef2 } from "react";
|
|
881
|
+
|
|
882
|
+
// src/window-manager/internal/features/docking/docking-controls.tsx
|
|
883
|
+
import { useState as useState2 } from "react";
|
|
884
|
+
import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
885
|
+
function DockingControls() {
|
|
886
|
+
const [isHovering, setIsHovering] = useState2(false);
|
|
887
|
+
const { activeWindowId } = useWorkspaceState();
|
|
888
|
+
const { isDragging } = windowRegistry[activeWindowId]();
|
|
889
|
+
const cornerDockControl = /* @__PURE__ */ jsxs3("div", { className: `flex xl:p-0 shrink-0 gap-0.5`, children: [
|
|
890
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex flex-col justify-center gap-0.5", children: [
|
|
891
|
+
/* @__PURE__ */ jsx7(
|
|
892
|
+
"button",
|
|
893
|
+
{
|
|
894
|
+
className: "hover:bg-zinc-300 border border-zinc-500 bg-zinc-600 w-10 h-6 rounded-sm",
|
|
895
|
+
onMouseUp: () => dockApi.dockWindowTopLeft(activeWindowId)
|
|
896
|
+
}
|
|
897
|
+
),
|
|
898
|
+
/* @__PURE__ */ jsx7(
|
|
899
|
+
"button",
|
|
900
|
+
{
|
|
901
|
+
className: "hover:bg-zinc-300 border border-zinc-500 bg-zinc-600 w-10 h-6 rounded-sm",
|
|
902
|
+
onMouseUp: () => dockApi.dockWindowBottomLeft(activeWindowId)
|
|
903
|
+
}
|
|
904
|
+
)
|
|
905
|
+
] }),
|
|
906
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex flex-col justify-center gap-0.5", children: [
|
|
907
|
+
/* @__PURE__ */ jsx7(
|
|
908
|
+
"button",
|
|
909
|
+
{
|
|
910
|
+
className: "hover:bg-zinc-300 border border-zinc-500 bg-zinc-600 w-10 h-6 rounded-sm",
|
|
911
|
+
onMouseUp: () => dockApi.dockWindowTopRight(activeWindowId)
|
|
912
|
+
}
|
|
913
|
+
),
|
|
914
|
+
/* @__PURE__ */ jsx7(
|
|
915
|
+
"button",
|
|
916
|
+
{
|
|
917
|
+
className: "hover:bg-zinc-300 border border-zinc-500 bg-zinc-600 w-10 h-6 rounded-sm",
|
|
918
|
+
onMouseUp: () => dockApi.dockWindowBottomRight(activeWindowId)
|
|
919
|
+
}
|
|
920
|
+
)
|
|
921
|
+
] })
|
|
922
|
+
] });
|
|
923
|
+
const sideDideControl = /* @__PURE__ */ jsxs3("div", { className: `flex shrink-0 items-center gap-0.5`, children: [
|
|
924
|
+
/* @__PURE__ */ jsx7(
|
|
925
|
+
"button",
|
|
926
|
+
{
|
|
927
|
+
className: "hover:bg-zinc-300 border border-zinc-500 bg-zinc-600 w-8 h-12 rounded-sm",
|
|
928
|
+
onMouseUp: () => dockApi.dockWindowLeft(activeWindowId)
|
|
929
|
+
}
|
|
930
|
+
),
|
|
931
|
+
/* @__PURE__ */ jsx7(
|
|
932
|
+
"button",
|
|
933
|
+
{
|
|
934
|
+
className: "hover:bg-zinc-300 border border-zinc-500 bg-zinc-600 w-8 h-12 rounded-sm",
|
|
935
|
+
onMouseUp: () => dockApi.dockWindowRight(activeWindowId)
|
|
936
|
+
}
|
|
937
|
+
)
|
|
938
|
+
] });
|
|
939
|
+
const horizontalDockControl = /* @__PURE__ */ jsxs3("div", { className: `flex flex-col shrink-0 items-center gap-0.5`, children: [
|
|
940
|
+
/* @__PURE__ */ jsx7(
|
|
941
|
+
"button",
|
|
942
|
+
{
|
|
943
|
+
className: "hover:bg-zinc-300 border border-zinc-500 bg-zinc-600 w-14 h-6 rounded-sm",
|
|
944
|
+
onMouseUp: () => dockApi.dockWindowTop(activeWindowId)
|
|
945
|
+
}
|
|
946
|
+
),
|
|
947
|
+
/* @__PURE__ */ jsx7(
|
|
948
|
+
"button",
|
|
949
|
+
{
|
|
950
|
+
className: "hover:bg-zinc-300 border border-zinc-500 bg-zinc-600 w-14 h-6 rounded-sm",
|
|
951
|
+
onMouseUp: () => dockApi.dockWindowBottom(activeWindowId)
|
|
952
|
+
}
|
|
953
|
+
)
|
|
954
|
+
] });
|
|
955
|
+
const windowDockPannel = /* @__PURE__ */ jsx7(
|
|
956
|
+
"span",
|
|
957
|
+
{
|
|
958
|
+
className: "pointer-events-auto px-4 pb-2",
|
|
959
|
+
onMouseOver: () => setIsHovering(true),
|
|
960
|
+
onMouseLeave: () => setIsHovering(false),
|
|
961
|
+
children: /* @__PURE__ */ jsxs3(
|
|
962
|
+
"section",
|
|
963
|
+
{
|
|
964
|
+
className: `
|
|
965
|
+
flex w-fit border border-zinc-600 border-t-0 rounded-b-md bg-zinc-800
|
|
966
|
+
overflow-hidden px-8 gap-4 h-full py-4
|
|
967
|
+
`,
|
|
968
|
+
children: [
|
|
969
|
+
cornerDockControl,
|
|
970
|
+
horizontalDockControl,
|
|
971
|
+
sideDideControl
|
|
972
|
+
]
|
|
973
|
+
}
|
|
974
|
+
)
|
|
975
|
+
}
|
|
976
|
+
);
|
|
977
|
+
return /* @__PURE__ */ jsx7(
|
|
978
|
+
"div",
|
|
979
|
+
{
|
|
980
|
+
className: `
|
|
981
|
+
${isDragging ? isHovering ? "top-0 opacity-50" : "top-[-68px] opacity-80" : "top-[-104px] opacity-0"}
|
|
982
|
+
transition-all duration-500
|
|
983
|
+
absolute z-50 flex items-center justify-center
|
|
984
|
+
w-full mx-auto pointer-events-none`,
|
|
985
|
+
children: windowDockPannel
|
|
986
|
+
}
|
|
987
|
+
);
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
// src/window-manager/internal/features/cursor/cursor-move-listener.tsx
|
|
991
|
+
import { useEffect as useEffect4 } from "react";
|
|
992
|
+
import { Fragment as Fragment3, jsx as jsx8 } from "react/jsx-runtime";
|
|
993
|
+
function CursorMoveListener() {
|
|
994
|
+
const { setX, setY } = useCursorState();
|
|
995
|
+
useEffect4(() => {
|
|
996
|
+
const handleWindowPosition = (e) => {
|
|
997
|
+
e.preventDefault();
|
|
998
|
+
setX(e.clientX);
|
|
999
|
+
setY(e.clientY);
|
|
1000
|
+
};
|
|
1001
|
+
window.addEventListener("pointermove", handleWindowPosition);
|
|
1002
|
+
return () => window.removeEventListener("pointermove", handleWindowPosition);
|
|
1003
|
+
}, [setX, setY]);
|
|
1004
|
+
return /* @__PURE__ */ jsx8(Fragment3, {});
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
// src/window-manager/internal/features/view-port/view-port-resize-listener.tsx
|
|
1008
|
+
import { useEffect as useEffect5 } from "react";
|
|
1009
|
+
import { Fragment as Fragment4, jsx as jsx9 } from "react/jsx-runtime";
|
|
1010
|
+
function ViewPortResizeListener() {
|
|
1011
|
+
useEffect5(() => {
|
|
1012
|
+
window.addEventListener("resize", stackApi.resetStack);
|
|
1013
|
+
return () => window.removeEventListener("resize", stackApi.resetStack);
|
|
1014
|
+
}, []);
|
|
1015
|
+
return /* @__PURE__ */ jsx9(Fragment4, {});
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
// src/window-manager/workspace-layout.tsx
|
|
1019
|
+
import { jsx as jsx10, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1020
|
+
function WorkspaceLayout({ children, className, responsiveBreak = "sm" }) {
|
|
1021
|
+
const workspaceRef = useRef2(null);
|
|
1022
|
+
const { setRef, setResponsiveBreak } = useWorkspaceState();
|
|
1023
|
+
useEffect6(() => {
|
|
1024
|
+
setRef(workspaceRef.current);
|
|
1025
|
+
}, []);
|
|
1026
|
+
useEffect6(() => {
|
|
1027
|
+
setResponsiveBreak(responsiveBreak);
|
|
1028
|
+
}, [responsiveBreak]);
|
|
1029
|
+
return /* @__PURE__ */ jsxs4(
|
|
1030
|
+
"section",
|
|
1031
|
+
{
|
|
1032
|
+
ref: workspaceRef,
|
|
1033
|
+
onMouseLeave: resizeApi.stopAllDragAndResize,
|
|
1034
|
+
onMouseUp: resizeApi.stopAllDragAndResize,
|
|
1035
|
+
className: className ? className : "fixed overflow-hidden h-full w-full touch-none",
|
|
1036
|
+
children: [
|
|
1037
|
+
/* @__PURE__ */ jsx10(ViewPortResizeListener, {}),
|
|
1038
|
+
/* @__PURE__ */ jsx10(CursorMoveListener, {}),
|
|
1039
|
+
/* @__PURE__ */ jsxs4("div", { className: " w-full h-full relative overflow-hidden", children: [
|
|
1040
|
+
!wsApi.isBelowBreakPoint() && /* @__PURE__ */ jsx10(DockingControls, {}),
|
|
1041
|
+
children
|
|
1042
|
+
] })
|
|
1043
|
+
]
|
|
1044
|
+
}
|
|
1045
|
+
);
|
|
1046
|
+
}
|
|
936
1047
|
export {
|
|
937
|
-
WindowButton,
|
|
938
|
-
WindowLayout,
|
|
939
1048
|
WorkspaceLayout,
|
|
940
1049
|
createWindowStore,
|
|
1050
|
+
rwm_default as rwm,
|
|
941
1051
|
windowRegistry
|
|
942
1052
|
};
|
|
943
1053
|
//# sourceMappingURL=index.js.map
|