@surdeddd/wmkit 0.7.0 → 0.7.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/dist/angular.cjs +3 -3
- package/dist/angular.js +1 -1
- package/dist/{chunk-VQ3TLK3N.js → chunk-FOWW4LXS.js} +51 -30
- package/dist/chunk-FOWW4LXS.js.map +1 -0
- package/dist/{chunk-E47Q36LM.cjs → chunk-NJAI5R4J.cjs} +51 -30
- package/dist/chunk-NJAI5R4J.cjs.map +1 -0
- package/dist/index.cjs +18 -18
- package/dist/index.js +1 -1
- package/dist/react.cjs +3 -3
- package/dist/react.js +1 -1
- package/dist/solid.cjs +3 -3
- package/dist/solid.js +1 -1
- package/dist/svelte.cjs +3 -3
- package/dist/svelte.js +1 -1
- package/dist/vue.cjs +3 -3
- package/dist/vue.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-E47Q36LM.cjs.map +0 -1
- package/dist/chunk-VQ3TLK3N.js.map +0 -1
|
@@ -1027,6 +1027,7 @@ function createWindowManager(options = {}) {
|
|
|
1027
1027
|
}
|
|
1028
1028
|
}
|
|
1029
1029
|
function applyEntry(entry) {
|
|
1030
|
+
const previousWindows = windows;
|
|
1030
1031
|
windows = entry.windows;
|
|
1031
1032
|
order = [...entry.order];
|
|
1032
1033
|
modalCount = countModals();
|
|
@@ -1038,6 +1039,16 @@ function createWindowManager(options = {}) {
|
|
|
1038
1039
|
if (workspace !== previousWorkspace) {
|
|
1039
1040
|
queueEvent(() => emitter.emit("workspace", { workspace, previous: previousWorkspace }));
|
|
1040
1041
|
}
|
|
1042
|
+
for (const id of Object.keys(previousWindows)) {
|
|
1043
|
+
if (windows[id]) continue;
|
|
1044
|
+
const closed = previousWindows[id];
|
|
1045
|
+
queueEvent(() => emitter.emit("close", { window: closed }));
|
|
1046
|
+
}
|
|
1047
|
+
for (const id of order) {
|
|
1048
|
+
if (previousWindows[id]) continue;
|
|
1049
|
+
const opened = windows[id];
|
|
1050
|
+
queueEvent(() => emitter.emit("open", { window: opened }));
|
|
1051
|
+
}
|
|
1041
1052
|
reflowViewport();
|
|
1042
1053
|
commit();
|
|
1043
1054
|
}
|
|
@@ -1988,7 +1999,7 @@ function attachDesktop(wm, element, options = {}) {
|
|
|
1988
1999
|
const registry = /* @__PURE__ */ new Map();
|
|
1989
2000
|
const cleanup = [];
|
|
1990
2001
|
let lastOrder = null;
|
|
1991
|
-
let
|
|
2002
|
+
let focusedEl = null;
|
|
1992
2003
|
let drag = null;
|
|
1993
2004
|
let groupTargetId = null;
|
|
1994
2005
|
let groupTargetEl = null;
|
|
@@ -2175,16 +2186,11 @@ function attachDesktop(wm, element, options = {}) {
|
|
|
2175
2186
|
}
|
|
2176
2187
|
}
|
|
2177
2188
|
if (orderChanged) applyStacking(state.order);
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
if (state.focusedId) {
|
|
2184
|
-
const next = registry.get(state.focusedId);
|
|
2185
|
-
if (next) next.element.dataset.wmFocused = "";
|
|
2186
|
-
}
|
|
2187
|
-
lastFocused = state.focusedId;
|
|
2189
|
+
const wanted = state.focusedId ? registry.get(state.focusedId)?.element ?? null : null;
|
|
2190
|
+
if (wanted !== focusedEl) {
|
|
2191
|
+
if (focusedEl) delete focusedEl.dataset.wmFocused;
|
|
2192
|
+
focusedEl = wanted;
|
|
2193
|
+
if (focusedEl) focusedEl.dataset.wmFocused = "";
|
|
2188
2194
|
}
|
|
2189
2195
|
lastOrder = state.order;
|
|
2190
2196
|
}
|
|
@@ -2414,23 +2420,31 @@ function attachDesktop(wm, element, options = {}) {
|
|
|
2414
2420
|
};
|
|
2415
2421
|
windowElement.addEventListener("keydown", onModalTrap);
|
|
2416
2422
|
attached.cleanup.push(() => windowElement.removeEventListener("keydown", onModalTrap));
|
|
2423
|
+
let detached = false;
|
|
2417
2424
|
const detach = () => {
|
|
2425
|
+
if (detached) return;
|
|
2426
|
+
detached = true;
|
|
2418
2427
|
if (drag?.id === id) endDrag(true);
|
|
2419
2428
|
for (const dispose of attached.cleanup) dispose();
|
|
2420
2429
|
for (const resizeHandle of attached.handles) resizeHandle.remove();
|
|
2421
2430
|
registry.delete(id);
|
|
2431
|
+
if (registry.get(id)?.element !== windowElement) delete windowElement.dataset.wmWindow;
|
|
2432
|
+
delete windowElement.dataset.wmFocused;
|
|
2433
|
+
delete windowElement.dataset.wmTabTarget;
|
|
2434
|
+
if (focusedEl === windowElement) focusedEl = null;
|
|
2435
|
+
if (groupTargetEl === windowElement) {
|
|
2436
|
+
groupTargetId = null;
|
|
2437
|
+
groupTargetEl = null;
|
|
2438
|
+
}
|
|
2422
2439
|
};
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
attached.cleanup.push(stopOnClose);
|
|
2430
|
-
}
|
|
2440
|
+
const stopOnClose = wm.on("close", ({ window: closed }) => {
|
|
2441
|
+
if (closed.id !== id) return;
|
|
2442
|
+
detach();
|
|
2443
|
+
if (windowOptions.removeOnClose) windowElement.remove();
|
|
2444
|
+
});
|
|
2445
|
+
attached.cleanup.push(stopOnClose);
|
|
2431
2446
|
registry.set(id, attached);
|
|
2432
2447
|
lastOrder = null;
|
|
2433
|
-
lastFocused = null;
|
|
2434
2448
|
syncAll();
|
|
2435
2449
|
if (wm.getState().focusedId === id && !windowElement.contains(doc.activeElement)) {
|
|
2436
2450
|
windowElement.focus({ preventScroll: true });
|
|
@@ -2458,7 +2472,7 @@ function attachDesktop(wm, element, options = {}) {
|
|
|
2458
2472
|
// src/dom/binder.ts
|
|
2459
2473
|
function createDesktopBinder(wm, options = {}) {
|
|
2460
2474
|
let controller = null;
|
|
2461
|
-
let
|
|
2475
|
+
let stops = [];
|
|
2462
2476
|
const entries = /* @__PURE__ */ new Set();
|
|
2463
2477
|
function attachEntry(entry) {
|
|
2464
2478
|
if (controller && !entry.detach && wm.get(entry.id)) {
|
|
@@ -2466,8 +2480,8 @@ function createDesktopBinder(wm, options = {}) {
|
|
|
2466
2480
|
}
|
|
2467
2481
|
}
|
|
2468
2482
|
function unbindDesktop() {
|
|
2469
|
-
|
|
2470
|
-
|
|
2483
|
+
for (const stop of stops) stop();
|
|
2484
|
+
stops = [];
|
|
2471
2485
|
for (const entry of entries) entry.detach = null;
|
|
2472
2486
|
controller?.destroy();
|
|
2473
2487
|
controller = null;
|
|
@@ -2478,11 +2492,18 @@ function createDesktopBinder(wm, options = {}) {
|
|
|
2478
2492
|
bindDesktop(element) {
|
|
2479
2493
|
if (controller) throw new Error("wmkit: desktop is already bound");
|
|
2480
2494
|
controller = attachDesktop(wm, element, options);
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2495
|
+
stops.push(
|
|
2496
|
+
wm.on("open", ({ window: win }) => {
|
|
2497
|
+
for (const entry of entries) {
|
|
2498
|
+
if (entry.id === win.id) attachEntry(entry);
|
|
2499
|
+
}
|
|
2500
|
+
}),
|
|
2501
|
+
wm.on("close", ({ window: win }) => {
|
|
2502
|
+
for (const entry of entries) {
|
|
2503
|
+
if (entry.id === win.id) entry.detach = null;
|
|
2504
|
+
}
|
|
2505
|
+
})
|
|
2506
|
+
);
|
|
2486
2507
|
for (const entry of entries) attachEntry(entry);
|
|
2487
2508
|
return unbindDesktop;
|
|
2488
2509
|
},
|
|
@@ -2520,5 +2541,5 @@ exports.flipToTarget = flipToTarget;
|
|
|
2520
2541
|
exports.magnetize = magnetize;
|
|
2521
2542
|
exports.prefersReducedMotion = prefersReducedMotion;
|
|
2522
2543
|
exports.zoneBounds = zoneBounds;
|
|
2523
|
-
//# sourceMappingURL=chunk-
|
|
2524
|
-
//# sourceMappingURL=chunk-
|
|
2544
|
+
//# sourceMappingURL=chunk-NJAI5R4J.cjs.map
|
|
2545
|
+
//# sourceMappingURL=chunk-NJAI5R4J.cjs.map
|