@celestia-island/hikari 0.55.112 → 0.55.114
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/package.json +1 -1
- package/src/components/HkFloatingLayer.test.tsx +21 -0
- package/src/components/HkFloatingLayer.tsx +11 -3
- package/src/components/HkModal.test.tsx +61 -0
- package/src/components/HkModal.tsx +28 -2
- package/src/components/HkModalBreadcrumb.test.tsx +76 -4
- package/src/components/HkModalBreadcrumb.tsx +52 -3
- package/src/index.ts +3 -0
- package/src/runtime/index.ts +10 -1
- package/src/runtime/usePopupManager.test.ts +47 -1
- package/src/runtime/usePopupManager.ts +30 -1
package/package.json
CHANGED
|
@@ -143,3 +143,24 @@ describe("HkFloatingLayer", () => {
|
|
|
143
143
|
expect(m.root()!.querySelector(".probe")).not.toBeNull();
|
|
144
144
|
});
|
|
145
145
|
});
|
|
146
|
+
|
|
147
|
+
describe("HkFloatingLayer yieldToWindows", () => {
|
|
148
|
+
it("hides while any window is open and returns when the last window closes", async () => {
|
|
149
|
+
const manager = usePopupManager();
|
|
150
|
+
const win = manager.register("modal", true, "Blocking");
|
|
151
|
+
const m = mountLayer({ yieldToWindows: true });
|
|
152
|
+
expect(m.root()).toBeNull();
|
|
153
|
+
manager.unregister(win.id);
|
|
154
|
+
await nextTick();
|
|
155
|
+
expect(m.root()).not.toBeNull();
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it("default layers keep floating over windows (opt-in only)", async () => {
|
|
159
|
+
const manager = usePopupManager();
|
|
160
|
+
const win = manager.register("modal", true, "Blocking");
|
|
161
|
+
const m = mountLayer({});
|
|
162
|
+
expect(m.root()).not.toBeNull();
|
|
163
|
+
manager.unregister(win.id);
|
|
164
|
+
await nextTick();
|
|
165
|
+
});
|
|
166
|
+
});
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
type PropType,
|
|
8
8
|
} from "vue";
|
|
9
9
|
|
|
10
|
-
import { usePopupManager } from "../runtime/usePopupManager";
|
|
10
|
+
import { hasLiveWindow, usePopupManager } from "../runtime/usePopupManager";
|
|
11
11
|
import "./HkFloatingLayer.scss";
|
|
12
12
|
|
|
13
13
|
type FloatCorner = "bottom-right" | "bottom-left" | "top-right" | "top-left";
|
|
@@ -63,6 +63,11 @@ export default defineComponent({
|
|
|
63
63
|
offsetY: { type: String, default: undefined },
|
|
64
64
|
/** Accessible group name for the chrome (e.g. "Date dial"). */
|
|
65
65
|
ariaLabel: { type: String, default: "" },
|
|
66
|
+
/** Stack priority (user direction 2026-10-04): when true the layer
|
|
67
|
+
* yields the screen while ANY window is open - page-level dial
|
|
68
|
+
* chrome disappears under the top window instead of floating over
|
|
69
|
+
* it, and returns when the last window closes. */
|
|
70
|
+
yieldToWindows: { type: Boolean, default: false },
|
|
66
71
|
},
|
|
67
72
|
setup(props, { slots }) {
|
|
68
73
|
const { register, unregister } = usePopupManager();
|
|
@@ -71,7 +76,10 @@ export default defineComponent({
|
|
|
71
76
|
// Annotation-band chrome, not a breadcrumb level: non-blocking,
|
|
72
77
|
// untitled, no scroll lock, no outside-dismiss channel. Registered
|
|
73
78
|
// exactly while shown (immediate, so the first paint already
|
|
74
|
-
// carries the band z); a hidden layer holds no slot.
|
|
79
|
+
// carries the band z); a hidden layer holds no slot. (A
|
|
80
|
+
// yielded layer keeps its slot held while hidden — constant chrome
|
|
81
|
+
// flipping a registered slot on every window open/close would churn
|
|
82
|
+
// the band for no visual effect.)
|
|
75
83
|
watch(
|
|
76
84
|
() => props.open,
|
|
77
85
|
(show) => {
|
|
@@ -89,7 +97,7 @@ export default defineComponent({
|
|
|
89
97
|
});
|
|
90
98
|
|
|
91
99
|
return () => {
|
|
92
|
-
if (!props.open) return null;
|
|
100
|
+
if (!props.open || (props.yieldToWindows && hasLiveWindow.value)) return null;
|
|
93
101
|
return (
|
|
94
102
|
<Teleport to="body">
|
|
95
103
|
<div
|
|
@@ -415,3 +415,64 @@ describe("HkModal autoFollow", () => {
|
|
|
415
415
|
expect(s.jump()).toBeNull();
|
|
416
416
|
});
|
|
417
417
|
});
|
|
418
|
+
|
|
419
|
+
// Stack-priority dial slot (user direction 2026-10-04): the window owns
|
|
420
|
+
// its dial while it is the topmost window, yields while another window
|
|
421
|
+
// stacks above, and the page dial returns on close. The surface machine
|
|
422
|
+
// runs on macrotask timers, so every stack transition below is staged
|
|
423
|
+
// through vi.waitFor, never bare ticks.
|
|
424
|
+
describe("HkModal dial slot (stack priority)", () => {
|
|
425
|
+
async function mountDialModal(withDial: boolean) {
|
|
426
|
+
const container = document.createElement("div");
|
|
427
|
+
document.body.appendChild(container);
|
|
428
|
+
containers.push(container);
|
|
429
|
+
const open = ref(true);
|
|
430
|
+
const Wrapper = defineComponent({
|
|
431
|
+
setup() {
|
|
432
|
+
return () =>
|
|
433
|
+
h(HkModal, {
|
|
434
|
+
modelValue: open.value,
|
|
435
|
+
title: "Window",
|
|
436
|
+
"onUpdate:modelValue": (v: boolean) => { open.value = v; },
|
|
437
|
+
}, withDial
|
|
438
|
+
? {
|
|
439
|
+
default: () => h("div", "body content"),
|
|
440
|
+
dial: () => h("button", { class: "dial-probe" }, "dial"),
|
|
441
|
+
}
|
|
442
|
+
: { default: () => h("div", "body content") });
|
|
443
|
+
},
|
|
444
|
+
});
|
|
445
|
+
const app = createApp(Wrapper);
|
|
446
|
+
mounts.push(app);
|
|
447
|
+
app.mount(container);
|
|
448
|
+
return { open };
|
|
449
|
+
}
|
|
450
|
+
const dialLayer = () => document.body.querySelector(".hk-floating-layer");
|
|
451
|
+
|
|
452
|
+
it("mounts its dial slot on the top layer while the window is topmost", async () => {
|
|
453
|
+
await mountDialModal(true);
|
|
454
|
+
await vi.waitFor(() => {
|
|
455
|
+
const layer = dialLayer();
|
|
456
|
+
expect(layer).not.toBeNull();
|
|
457
|
+
expect(layer!.querySelector(".dial-probe")).not.toBeNull();
|
|
458
|
+
});
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
it("yields while another window stacks above and returns when it closes", async () => {
|
|
462
|
+
const m = await mountDialModal(true);
|
|
463
|
+
await vi.waitFor(() => expect(dialLayer()).not.toBeNull());
|
|
464
|
+
const { register, unregister } = usePopupManager();
|
|
465
|
+
const above = register("modal", true, "Above");
|
|
466
|
+
await vi.waitFor(() => expect(dialLayer()).toBeNull());
|
|
467
|
+
unregister(above.id);
|
|
468
|
+
await vi.waitFor(() => expect(dialLayer()).not.toBeNull());
|
|
469
|
+
m.open.value = false;
|
|
470
|
+
await vi.waitFor(() => expect(dialLayer()).toBeNull());
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
it("renders no dial layer when the window declares none", async () => {
|
|
474
|
+
await mountDialModal(false);
|
|
475
|
+
await vi.waitFor(() => expect(document.body.querySelector(".hk-modal-root")).not.toBeNull());
|
|
476
|
+
expect(dialLayer()).toBeNull();
|
|
477
|
+
});
|
|
478
|
+
});
|
|
@@ -2,9 +2,10 @@ import { computed, defineComponent, nextTick, onBeforeUnmount, onMounted, ref, s
|
|
|
2
2
|
|
|
3
3
|
import { useI18n } from "../i18n/context";
|
|
4
4
|
import "./HkModal.scss";
|
|
5
|
+
import HkFloatingLayer from "./HkFloatingLayer";
|
|
5
6
|
import { focusFirst, trapFocus } from "../utils/dom";
|
|
6
7
|
import { useOverlay } from "../runtime/useOverlay";
|
|
7
|
-
import { usePopupManager } from "../runtime/usePopupManager";
|
|
8
|
+
import { topWindowZ, usePopupManager } from "../runtime/usePopupManager";
|
|
8
9
|
import { createBackGuard } from "../runtime/backStack";
|
|
9
10
|
import { scheduleFrame, type AnimationHandle } from "../runtime/animationBus";
|
|
10
11
|
import { attachOverlayScrollbars, type OverlayScrollbarHandle } from "../composables/useOverlayScrollbar";
|
|
@@ -936,12 +937,24 @@ export default defineComponent({
|
|
|
936
937
|
|
|
937
938
|
const contentHold = useSurfaceContentHold(machine.phase);
|
|
938
939
|
|
|
940
|
+
// Stack-priority dial chrome (user direction 2026-10-04): the
|
|
941
|
+
// window's own dial replaces the page's while this window is the
|
|
942
|
+
// topmost one, yields while another window stacks above it (dial
|
|
943
|
+
// or not), and the page dial returns when the last window closes.
|
|
944
|
+
const dialVisible = computed(() =>
|
|
945
|
+
Boolean(
|
|
946
|
+
machine.mounted.value &&
|
|
947
|
+
handle.value &&
|
|
948
|
+
(topWindowZ.value === null || topWindowZ.value <= handle.value.zIndex),
|
|
949
|
+
),
|
|
950
|
+
);
|
|
951
|
+
|
|
939
952
|
return () => {
|
|
940
953
|
if (!machine.mounted.value) return null;
|
|
941
954
|
|
|
942
955
|
const headerShown = props.title || props.closable || slots.header || slots.headerLead;
|
|
943
956
|
|
|
944
|
-
|
|
957
|
+
const windowSurface = (
|
|
945
958
|
<Teleport to="body">
|
|
946
959
|
<div
|
|
947
960
|
class="hk-modal-root"
|
|
@@ -1066,6 +1079,19 @@ export default defineComponent({
|
|
|
1066
1079
|
</div>
|
|
1067
1080
|
</Teleport>
|
|
1068
1081
|
);
|
|
1082
|
+
|
|
1083
|
+
// The dial rides the top layer beside its window (stack
|
|
1084
|
+
// priority): mounted with the window, yielded above, retired
|
|
1085
|
+
// when the window closes so the page dial can return.
|
|
1086
|
+
if (!slots.dial) return windowSurface;
|
|
1087
|
+
return (
|
|
1088
|
+
<>
|
|
1089
|
+
{windowSurface}
|
|
1090
|
+
<HkFloatingLayer open={dialVisible.value} corner="bottom-right">
|
|
1091
|
+
{slots.dial()}
|
|
1092
|
+
</HkFloatingLayer>
|
|
1093
|
+
</>
|
|
1094
|
+
);
|
|
1069
1095
|
};
|
|
1070
1096
|
|
|
1071
1097
|
function renderWindowedBody() {
|
|
@@ -640,7 +640,9 @@ describe("HkModalBreadcrumb overflow fold", () => {
|
|
|
640
640
|
// The strip is teleported into the host's zoomed root: the header's
|
|
641
641
|
// rect is VISUAL px while the inline top it writes is LOCAL px, so the
|
|
642
642
|
// height is divided by the zoom. Forgetting the division drifts the
|
|
643
|
-
// strip (zoom − 1) · height / 2 down its window.
|
|
643
|
+
// strip (zoom − 1) · height / 2 down its window. The strip's OWN height
|
|
644
|
+
// rides the same conversion (clearance branch), so it is mocked here
|
|
645
|
+
// too: 88 visual px = 44 local at zoom 2.
|
|
644
646
|
const app = document.createElement("div");
|
|
645
647
|
app.id = "app";
|
|
646
648
|
app.style.top = "10px";
|
|
@@ -665,21 +667,91 @@ describe("HkModalBreadcrumb overflow fold", () => {
|
|
|
665
667
|
const rect = (height: number): DOMRect =>
|
|
666
668
|
({ x: 0, y: 0, width: 200, height, top: 0, left: 0, right: 200, bottom: height, toJSON: () => ({}) }) as DOMRect;
|
|
667
669
|
vi.spyOn(HTMLElement.prototype, "getBoundingClientRect").mockImplementation(function (this: HTMLElement) {
|
|
668
|
-
|
|
670
|
+
if (this === header) return rect(96);
|
|
671
|
+
if (this.classList.contains("hk-modal-breadcrumb")) return rect(88);
|
|
672
|
+
return rect(0);
|
|
669
673
|
});
|
|
670
674
|
try {
|
|
671
675
|
setViewport(1200);
|
|
672
676
|
manager.register("modal", true, "第一层");
|
|
673
677
|
manager.register("modal", true, "第二层");
|
|
674
678
|
await mountStrip();
|
|
675
|
-
// 10 (app top, local) + (96 visual / 2
|
|
676
|
-
|
|
679
|
+
// 10 (app top, local) + the lower of: header centre (96 visual / 2
|
|
680
|
+
// zoom) / 2 = 24, and the clearance 12 + (88 visual / 2 zoom) / 2 =
|
|
681
|
+
// 34 — the clearance sits lower and wins.
|
|
682
|
+
expect(strip()!.style.top).toBe("44px");
|
|
677
683
|
} finally {
|
|
678
684
|
vi.restoreAllMocks();
|
|
679
685
|
app.remove();
|
|
680
686
|
}
|
|
681
687
|
});
|
|
682
688
|
|
|
689
|
+
it("keeps daylight between the app's top edge and the strip", async () => {
|
|
690
|
+
// Centred on a standard short header, the strip's own upper half used
|
|
691
|
+
// to kiss the very top edge (2026-10-05 user report): a ~24px centre
|
|
692
|
+
// line is less than the strip's half height. The top is now the LOWER
|
|
693
|
+
// of "header centre" and the topGap clearance; the boxless test DOM
|
|
694
|
+
// exercises the rule on the two layout fallbacks (48px header, 43px
|
|
695
|
+
// strip). The app top is deliberately non-zero (5px) so NO expectation
|
|
696
|
+
// coincides with the pre-resync initial ref — each leg proves resyncTop
|
|
697
|
+
// actually wrote: 5 + max(48/2, gap + 43/2).
|
|
698
|
+
const app = document.createElement("div");
|
|
699
|
+
app.id = "app";
|
|
700
|
+
app.style.top = "5px";
|
|
701
|
+
document.body.appendChild(app);
|
|
702
|
+
const unmountAll = () => {
|
|
703
|
+
for (const a of mounts.splice(0)) a.unmount();
|
|
704
|
+
};
|
|
705
|
+
try {
|
|
706
|
+
setViewport(1200);
|
|
707
|
+
manager.register("modal", true, "第一层");
|
|
708
|
+
manager.register("modal", true, "第二层");
|
|
709
|
+
await mountStrip();
|
|
710
|
+
expect(strip()!.style.top).toBe("38.5px");
|
|
711
|
+
unmountAll();
|
|
712
|
+
|
|
713
|
+
// A host pinning the legacy, header-centred position passes 0:
|
|
714
|
+
// 5 + max(24, 0 + 21.5) — the centre branch wins again.
|
|
715
|
+
await mountStrip({ topGap: 0 });
|
|
716
|
+
expect(strip()!.style.top).toBe("29px");
|
|
717
|
+
unmountAll();
|
|
718
|
+
|
|
719
|
+
// And a host wanting more air simply raises the gap.
|
|
720
|
+
await mountStrip({ topGap: 40 });
|
|
721
|
+
expect(strip()!.style.top).toBe("66.5px");
|
|
722
|
+
unmountAll();
|
|
723
|
+
|
|
724
|
+
// A NaN gap is host junk: it falls back to the default instead of
|
|
725
|
+
// poisoning Math.max into `top: NaNpx` (which the browser drops).
|
|
726
|
+
await mountStrip({ topGap: Number.NaN });
|
|
727
|
+
expect(strip()!.style.top).toBe("38.5px");
|
|
728
|
+
} finally {
|
|
729
|
+
unmountAll();
|
|
730
|
+
app.remove();
|
|
731
|
+
}
|
|
732
|
+
});
|
|
733
|
+
|
|
734
|
+
it("paints the fallback position before any resync can run", async () => {
|
|
735
|
+
// A host whose app root id never resolves leaves resyncTop at its
|
|
736
|
+
// early-return, so the strip paints the INITIAL ref: that line must
|
|
737
|
+
// already encode the clearance rule on the two layout fallbacks
|
|
738
|
+
// (48px header, 43px strip), not a legacy literal. Every other
|
|
739
|
+
// style.top assertion lives in tests that create #app, where the
|
|
740
|
+
// pre-mount resync overwrites the init before the first render
|
|
741
|
+
// (mutation round M5: reverting the init to a bare 24 passed
|
|
742
|
+
// everything else green).
|
|
743
|
+
setViewport(1200);
|
|
744
|
+
manager.register("modal", true, "第一层");
|
|
745
|
+
manager.register("modal", true, "第二层");
|
|
746
|
+
await mountStrip({ appRootId: "no-such-root" });
|
|
747
|
+
expect(strip()!.style.top).toBe("33.5px");
|
|
748
|
+
for (const a of mounts.splice(0)) a.unmount();
|
|
749
|
+
|
|
750
|
+
// The init follows the prop the same way the resync does.
|
|
751
|
+
await mountStrip({ appRootId: "no-such-root", topGap: 0 });
|
|
752
|
+
expect(strip()!.style.top).toBe("21.5px");
|
|
753
|
+
});
|
|
754
|
+
|
|
683
755
|
it("writes the viewport fence in the strip's own px", async () => {
|
|
684
756
|
// A vw-authored cap would be scaled by a host root zoom at paint, so the
|
|
685
757
|
// fence is re-derived from the live viewport (minus the shared gutter)
|
|
@@ -36,6 +36,13 @@ const GAP_PX = 8;
|
|
|
36
36
|
const SIDE_PADDING_PX = 32;
|
|
37
37
|
const BORDER_PX = 1;
|
|
38
38
|
const MORE_PX = 24;
|
|
39
|
+
/** The strip's own height for the moments no box can be measured (first
|
|
40
|
+
* resync, unit DOM): the stylesheet declares 12px vertical padding, a
|
|
41
|
+
* ~17px label line and a 1px border — 12·2 + 17 + 1·2 ≈ 43. Models the
|
|
42
|
+
* UNFOLDED strip; a folded one is ~50px (the 24px trigger line) — the
|
|
43
|
+
* fallback only serves boxless DOMs, a real browser measures the live
|
|
44
|
+
* nav and the slow tick re-derives from it. */
|
|
45
|
+
const STRIP_HEIGHT_PX = 43;
|
|
39
46
|
|
|
40
47
|
interface Crumb {
|
|
41
48
|
/** Popup-registry id this crumb can navigate back to. */
|
|
@@ -66,12 +73,33 @@ export default defineComponent({
|
|
|
66
73
|
* hidden-layers menu.
|
|
67
74
|
*/
|
|
68
75
|
maxLabelUnits: { type: Number, default: 10 },
|
|
76
|
+
/**
|
|
77
|
+
* Least daylight, in px, between the app's top edge and the strip's own
|
|
78
|
+
* top edge. The strip is centred on the app header, and on the standard
|
|
79
|
+
* short header that centre line sits ~24px from the top — less than the
|
|
80
|
+
* strip's half height, so its upper half used to kiss the very top edge
|
|
81
|
+
* (2026-10-05 user report). The top is now the lower of "centred on the
|
|
82
|
+
* header" and "this clearance"; a header whose centre already sits at
|
|
83
|
+
* least this far down keeps the strip centred on it. Authored in the
|
|
84
|
+
* strip's LOCAL px like every length here — a host root zoom scales it
|
|
85
|
+
* at paint, so it can only over-deliver daylight. Below 8 the entrance
|
|
86
|
+
* keyframe's own 8px slide transiently pokes back above the app top.
|
|
87
|
+
*/
|
|
88
|
+
topGap: { type: Number, default: 12 },
|
|
69
89
|
},
|
|
70
90
|
setup(props) {
|
|
71
91
|
const manager = usePopupManager();
|
|
72
92
|
const { t } = useI18n();
|
|
73
93
|
const { isMobile } = useBreakpoint();
|
|
74
94
|
|
|
95
|
+
/** Sanitized once: a host passing NaN would otherwise poison both the
|
|
96
|
+
* pre-resync ref and every resync (Math.max(x, NaN) is NaN, and the
|
|
97
|
+
* browser drops `top: NaNpx`, parking the strip at its static
|
|
98
|
+
* position). A NEGATIVE gap stays the host's choice: it lowers the
|
|
99
|
+
* clearance candidate below the centre line, which then wins — i.e.
|
|
100
|
+
* "I don't care about daylight". */
|
|
101
|
+
const topGapPx = computed(() => (Number.isFinite(props.topGap) ? props.topGap : 12));
|
|
102
|
+
|
|
75
103
|
/** Which entries the strip navigates. Windows (modal/drawer) always;
|
|
76
104
|
* dropdown-kind surfaces only while they BLOCK like a window — the
|
|
77
105
|
* mobile bottom sheet a menu/popover becomes when viewport space
|
|
@@ -375,7 +403,10 @@ export default defineComponent({
|
|
|
375
403
|
});
|
|
376
404
|
onBeforeUnmount(() => document.removeEventListener("keydown", onSurfaceKeydown));
|
|
377
405
|
|
|
378
|
-
|
|
406
|
+
/** Pre-resync paint position: the clearance rule evaluated on the two
|
|
407
|
+
* layout fallbacks (48px header, 43px strip). The first nextTick
|
|
408
|
+
* resync replaces it with measured numbers. */
|
|
409
|
+
const topPx = ref(topGapPx.value + STRIP_HEIGHT_PX / 2);
|
|
379
410
|
function resyncTop() {
|
|
380
411
|
const app = document.getElementById(props.appRootId);
|
|
381
412
|
if (!app) return;
|
|
@@ -397,7 +428,20 @@ export default defineComponent({
|
|
|
397
428
|
const headerH = header
|
|
398
429
|
? header.getBoundingClientRect().height / z
|
|
399
430
|
: props.headerFallbackHeight;
|
|
400
|
-
|
|
431
|
+
// The strip's own height comes back in the same VISUAL px the
|
|
432
|
+
// header's rect does (it teleports into the same zoomed subtree), so
|
|
433
|
+
// it divides by the zoom read at the strip itself. No box (first
|
|
434
|
+
// resync, unit DOM) falls back to the stylesheet-declared height.
|
|
435
|
+
let stripH = STRIP_HEIGHT_PX;
|
|
436
|
+
if (navRef.value) {
|
|
437
|
+
const navH = navRef.value.getBoundingClientRect().height;
|
|
438
|
+
if (navH > 0) stripH = navH / ancestorZoom(navRef.value);
|
|
439
|
+
}
|
|
440
|
+
// Centre on the header, but keep the promised daylight: whichever
|
|
441
|
+
// candidate parks the strip LOWER wins, so a centre line near the
|
|
442
|
+
// viewport top can no longer push the strip's upper half against
|
|
443
|
+
// (or past) the top edge.
|
|
444
|
+
topPx.value = appTop + Math.max(headerH / 2, topGapPx.value + stripH / 2);
|
|
401
445
|
}
|
|
402
446
|
|
|
403
447
|
/** Viewport fence, in the strip's OWN px. The stylesheet cap is
|
|
@@ -463,6 +507,9 @@ export default defineComponent({
|
|
|
463
507
|
if (!handle) handle = scheduleEvery(onSlowTick, 1000);
|
|
464
508
|
window.addEventListener("resize", onViewportChange);
|
|
465
509
|
void nextTick(() => {
|
|
510
|
+
// The strip's own box exists only now: re-derive the top with
|
|
511
|
+
// a measured height (the pre-mount resync ran on fallbacks).
|
|
512
|
+
resyncBox();
|
|
466
513
|
measureStrip();
|
|
467
514
|
observeClone();
|
|
468
515
|
});
|
|
@@ -495,7 +542,9 @@ export default defineComponent({
|
|
|
495
542
|
if (!visible.value) return;
|
|
496
543
|
// Synchronous first measure: the collapsed shape is committed in the
|
|
497
544
|
// same task as the mount, so the strip never paints one frame wide
|
|
498
|
-
// enough to spill before folding.
|
|
545
|
+
// enough to spill before folding. The top is re-derived with the
|
|
546
|
+
// strip's now-measurable height for the same reason.
|
|
547
|
+
resyncBox();
|
|
499
548
|
measureStrip();
|
|
500
549
|
observeClone();
|
|
501
550
|
});
|
package/src/index.ts
CHANGED
package/src/runtime/index.ts
CHANGED
|
@@ -56,7 +56,16 @@ export {
|
|
|
56
56
|
} from "./backStack";
|
|
57
57
|
export { useMediaQuery, releaseMediaQuery } from "./useMediaQuery";
|
|
58
58
|
export { useOverlay, closeAll, isOverlayOpen, type OverlayHandle, type UseOverlayOptions } from "./useOverlay";
|
|
59
|
-
export {
|
|
59
|
+
export {
|
|
60
|
+
hasLiveWindow,
|
|
61
|
+
isWindowEntry,
|
|
62
|
+
topWindowZ,
|
|
63
|
+
usePopupManager,
|
|
64
|
+
POPUP_Z_BANDS,
|
|
65
|
+
POPUP_Z_STEP,
|
|
66
|
+
type PopupHandle,
|
|
67
|
+
type PopupKind,
|
|
68
|
+
} from "./usePopupManager";
|
|
60
69
|
export { useToast, TOAST_DURATION, type ToastItem, type ToastMessage, type ToastType } from "./useToast";
|
|
61
70
|
export { useConfirm } from "./useConfirm";
|
|
62
71
|
export { useBlockingToast, showBlockingToast, resolveBlockingToast, clearBlockingToasts, type BlockingToastItem, type BlockingToastOptions, type BlockingToastVariant } from "./useBlockingToast";
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
2
|
import { watch } from "vue";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
hasLiveWindow,
|
|
6
|
+
POPUP_Z_BANDS,
|
|
7
|
+
POPUP_Z_STEP,
|
|
8
|
+
topWindowZ,
|
|
9
|
+
usePopupManager,
|
|
10
|
+
} from "./usePopupManager";
|
|
5
11
|
|
|
6
12
|
const managers: ReturnType<typeof usePopupManager>[] = [];
|
|
7
13
|
|
|
@@ -338,3 +344,43 @@ describe("usePopupManager closeAbove", () => {
|
|
|
338
344
|
}
|
|
339
345
|
});
|
|
340
346
|
});
|
|
347
|
+
|
|
348
|
+
describe("usePopupManager window-stack signals", () => {
|
|
349
|
+
it("derived signals track the live window band (page chrome's yield rule)", () => {
|
|
350
|
+
const m = usePopupManager();
|
|
351
|
+
const win = m.register("modal", true, "Window");
|
|
352
|
+
expect(hasLiveWindow.value).toBe(true);
|
|
353
|
+
expect(topWindowZ.value).toBe(win.zIndex);
|
|
354
|
+
// Tooltip-band entries are not windows: they must not flip the signals.
|
|
355
|
+
const tip = m.register("tooltip", false);
|
|
356
|
+
expect(hasLiveWindow.value).toBe(true);
|
|
357
|
+
expect(topWindowZ.value).toBe(win.zIndex);
|
|
358
|
+
m.unregister(tip.id);
|
|
359
|
+
m.unregister(win.id);
|
|
360
|
+
expect(hasLiveWindow.value).toBe(false);
|
|
361
|
+
expect(topWindowZ.value).toBeNull();
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
it("only window-band entries count: anchored dropdowns no, docked sheets yes", () => {
|
|
365
|
+
const m = usePopupManager();
|
|
366
|
+
const dd = m.register("dropdown", false);
|
|
367
|
+
expect(hasLiveWindow.value).toBe(false);
|
|
368
|
+
m.unregister(dd.id);
|
|
369
|
+
const sheet = m.register("dropdown", true, "Sheet", true);
|
|
370
|
+
expect(hasLiveWindow.value).toBe(true);
|
|
371
|
+
expect(topWindowZ.value).toBe(sheet.zIndex);
|
|
372
|
+
m.unregister(sheet.id);
|
|
373
|
+
expect(hasLiveWindow.value).toBe(false);
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
it("topWindowZ follows the topmost of stacked windows", () => {
|
|
377
|
+
const m = usePopupManager();
|
|
378
|
+
const low = m.register("modal", true, "Low");
|
|
379
|
+
const high = m.register("modal", true, "High");
|
|
380
|
+
expect(topWindowZ.value).toBe(high.zIndex);
|
|
381
|
+
expect(topWindowZ.value).toBeGreaterThan(low.zIndex);
|
|
382
|
+
m.unregister(high.id);
|
|
383
|
+
expect(topWindowZ.value).toBe(low.zIndex);
|
|
384
|
+
m.unregister(low.id);
|
|
385
|
+
});
|
|
386
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { readonly, ref } from "vue";
|
|
1
|
+
import { computed, readonly, ref } from "vue";
|
|
2
2
|
|
|
3
3
|
import { reportHkRuntime, type HkRuntimeHandle } from "./registry";
|
|
4
4
|
|
|
@@ -70,6 +70,14 @@ function effectiveBand(kind: PopupKind, blocking: boolean): number {
|
|
|
70
70
|
return POPUP_Z_BANDS[kind];
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
/** True when a live entry is a WINDOW (blocks the page like one):
|
|
74
|
+
* modal/drawer by kind, or a dropdown-kind surface docked as a
|
|
75
|
+
* blocking mobile sheet. Page chrome (dials, floating pads) uses
|
|
76
|
+
* this to yield the screen to whatever window is on top. */
|
|
77
|
+
export function isWindowEntry(kind: PopupKind, blocking: boolean): boolean {
|
|
78
|
+
return effectiveBand(kind, blocking) === POPUP_Z_BANDS.modal;
|
|
79
|
+
}
|
|
80
|
+
|
|
73
81
|
/** In-band stacking step. Even numbers leave the odd slot free for the
|
|
74
82
|
* +1 content/panel layer each overlay puts above its own root. */
|
|
75
83
|
export const POPUP_Z_STEP = 2;
|
|
@@ -132,6 +140,27 @@ function uid(): string {
|
|
|
132
140
|
}
|
|
133
141
|
|
|
134
142
|
const registry = ref<Map<string, PopupEntry>>(new Map());
|
|
143
|
+
|
|
144
|
+
// Derived window-stack signals (reactive over the live registry):
|
|
145
|
+
// whether ANY window is open, and the topmost window's z slot. Stack
|
|
146
|
+
// priority for dial chrome rides these — a window's own dial replaces
|
|
147
|
+
// the page's while it is topmost; close the window and the page's
|
|
148
|
+
// dial returns.
|
|
149
|
+
export const hasLiveWindow = computed<boolean>(() => {
|
|
150
|
+
for (const entry of registry.value.values()) {
|
|
151
|
+
if (isWindowEntry(entry.kind, entry.blocking)) return true;
|
|
152
|
+
}
|
|
153
|
+
return false;
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
export const topWindowZ = computed<number | null>(() => {
|
|
157
|
+
let top: number | null = null;
|
|
158
|
+
for (const entry of registry.value.values()) {
|
|
159
|
+
if (!isWindowEntry(entry.kind, entry.blocking)) continue;
|
|
160
|
+
if (top === null || entry.zIndex > top) top = entry.zIndex;
|
|
161
|
+
}
|
|
162
|
+
return top;
|
|
163
|
+
});
|
|
135
164
|
let scrollLockCount = 0;
|
|
136
165
|
|
|
137
166
|
// Runtime-registry reporting (the "context of contexts"). Lazy: the
|