@celestia-island/hikari 0.55.454 → 0.55.456
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/types/composables/useHostPromotion.d.ts +24 -0
- package/dist/types/composables/useOverviewRuler.d.ts +77 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/HkExpansionPanel.scss +14 -5
- package/src/components/HkExpansionPanel.test.tsx +34 -3
- package/src/components/HkExpansionPanel.tsx +9 -1
- package/src/components/HkSerpentineUnlock.scss +17 -0
- package/src/components/HkSerpentineUnlock.test.ts +49 -2
- package/src/components/HkSerpentineUnlock.tsx +9 -1
- package/src/components/HkTabs.scss +11 -0
- package/src/components/HkTabs.test.ts +75 -0
- package/src/composables/useHostPromotion.ts +58 -0
- package/src/composables/useOverlayScrollbar.ts +14 -21
- package/src/composables/useOverviewRuler.behavior.test.ts +324 -0
- package/src/composables/useOverviewRuler.contract.test.ts +76 -0
- package/src/composables/useOverviewRuler.ts +395 -0
- package/src/index.ts +9 -0
- package/src/styles/index.scss +1 -0
- package/src/styles/overview-ruler.scss +87 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reference-counted host-position promotion, shared by every composable
|
|
3
|
+
* that needs a positioned positioning context (the overlay scrollbar and
|
|
4
|
+
* the overview ruler). A module-private WeakMap per composable is the
|
|
5
|
+
* exact accident this exists to prevent: ruler A's detach stripping the
|
|
6
|
+
* positioning out from under a still-live scrollbar B on the same host.
|
|
7
|
+
*
|
|
8
|
+
* Contract:
|
|
9
|
+
* - `promoteHost(host)` counts the caller and returns its release;
|
|
10
|
+
* - the FIRST caller on a static/empty-position host sets
|
|
11
|
+
* `position: relative`; every later caller (whatever the computed
|
|
12
|
+
* position now is) is still counted;
|
|
13
|
+
* - the LAST release restores the PRE-ATTACH inline position — unless a
|
|
14
|
+
* consumer re-styled the host after attach (their style wins; the
|
|
15
|
+
* saved value stays dead).
|
|
16
|
+
*/
|
|
17
|
+
export interface PromoteHostHandle {
|
|
18
|
+
release(): void;
|
|
19
|
+
/** Whether THIS call applied the promotion (count reached 1 on a
|
|
20
|
+
* static/empty host). Consumers use it to gate companion markers that
|
|
21
|
+
* only make sense when the promotion actually happened. */
|
|
22
|
+
promoted: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare function promoteHost(host: HTMLElement): PromoteHostHandle;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useOverviewRuler — a standalone minimap strip ("竖向瀑布流") that any
|
|
3
|
+
* scrollable element can attach, the same way attachOverlayScrollbars
|
|
4
|
+
* attaches the scrollbar. It renders a proportional density map of the
|
|
5
|
+
* viewport's content (one band per top-level block, sized by its share of
|
|
6
|
+
* the content extent) plus a cursor marking the visible window; dragging
|
|
7
|
+
* scrolls the viewport, clicking jumps.
|
|
8
|
+
*
|
|
9
|
+
* Design direction (2026-11-21 user ruling): the minimap is a STANDALONE
|
|
10
|
+
* attachment — not a mode of the scrollbar — and it is the same primitive
|
|
11
|
+
* a waterfall layout needs: a vertical (or horizontal) strip of
|
|
12
|
+
* proportional bands with a draggable cursor. Direction and cursor
|
|
13
|
+
* behaviour are options, not separate components.
|
|
14
|
+
*
|
|
15
|
+
* Two cursor modes:
|
|
16
|
+
* - "jump" (default): pointer down anywhere on the strip scrolls so the
|
|
17
|
+
* content window under the pointer becomes the visible window, then
|
|
18
|
+
* keeps dragging (双向可拖动 — both the cursor and a strip click steer
|
|
19
|
+
* the scroll);
|
|
20
|
+
* - "thumb": only the cursor box is draggable; strip clicks are inert.
|
|
21
|
+
*
|
|
22
|
+
* Sampling: bands are harvested from `bandSelector` matches inside the
|
|
23
|
+
* viewport (default: the viewport's DIRECT element children). Nested
|
|
24
|
+
* matches are dropped when a match contains another (a parent band's
|
|
25
|
+
* extent already contains its children's — counting both would paint the
|
|
26
|
+
* same content twice). Caller-driven content (virtualized rows, a canvas
|
|
27
|
+
* terminal) should pass a `bandSelector` for whatever stands in for lines,
|
|
28
|
+
* or drive `setBands` directly with fractions.
|
|
29
|
+
*
|
|
30
|
+
* The strip sits at z-index 9 — UNDER the overlay scrollbar's interactive
|
|
31
|
+
* track (z-index 10, see theme/scrollbar.scss) so a host that attaches
|
|
32
|
+
* both keeps fine scrolling on the track while the ruler carries the map.
|
|
33
|
+
*/
|
|
34
|
+
export type OverviewRulerAxis = "vertical" | "horizontal";
|
|
35
|
+
export type OverviewRulerCursorMode = "jump" | "thumb";
|
|
36
|
+
export interface OverviewRulerBand {
|
|
37
|
+
/** Band start as a fraction of the content extent, 0..1. */
|
|
38
|
+
start: number;
|
|
39
|
+
/** Band length as a fraction of the content extent, 0..1. */
|
|
40
|
+
length: number;
|
|
41
|
+
/** Extra class for the band (e.g. severity coloring for log lines). */
|
|
42
|
+
modifier?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface OverviewRulerOptions {
|
|
45
|
+
/** Strip direction. Default "vertical" (the waterfall). */
|
|
46
|
+
axis?: OverviewRulerAxis;
|
|
47
|
+
/** Strip thickness in CSS px. Default 48 (vertical) / 36 (horizontal). */
|
|
48
|
+
thickness?: number;
|
|
49
|
+
/** Which edge of the host the strip docks to. Default "end"
|
|
50
|
+
* (right for vertical, bottom for horizontal). */
|
|
51
|
+
side?: "start" | "end";
|
|
52
|
+
/** Selector harvested INSIDE the viewport for band sources. Matches
|
|
53
|
+
* contained within another match are dropped (the parent band already
|
|
54
|
+
* covers them). Default: the viewport's DIRECT element children. */
|
|
55
|
+
bandSelector?: string;
|
|
56
|
+
/** Cursor behaviour: "jump" (default) = strip pointer down jumps then
|
|
57
|
+
* drags; "thumb" = only the cursor box is draggable. */
|
|
58
|
+
cursorDrag?: OverviewRulerCursorMode;
|
|
59
|
+
/** Element the strip is appended to — its positioning context. Same
|
|
60
|
+
* contract as OverlayScrollbarOptions.host: a box wrapping exactly the
|
|
61
|
+
* viewport. Defaults to the viewport's DOM parent. */
|
|
62
|
+
host?: HTMLElement;
|
|
63
|
+
/** Content-resample cadence in ms (bands, not the cursor — the cursor
|
|
64
|
+
* tracks scroll and resize live). Default 250. */
|
|
65
|
+
resampleMs?: number;
|
|
66
|
+
}
|
|
67
|
+
export interface OverviewRulerHandle {
|
|
68
|
+
/** Resample the bands and reposition the cursor. */
|
|
69
|
+
update(): void;
|
|
70
|
+
/** Replace the sampled bands with caller fractions (virtualized or
|
|
71
|
+
* canvas content). An empty list clears the waterfall. */
|
|
72
|
+
setBands(bands: OverviewRulerBand[]): void;
|
|
73
|
+
/** Remove the strip and every listener/observer; restore any inline
|
|
74
|
+
* positioning the promotion applied. Safe to call twice. */
|
|
75
|
+
detach(): void;
|
|
76
|
+
}
|
|
77
|
+
export declare function attachOverviewRuler(viewport: HTMLElement, opts?: OverviewRulerOptions): OverviewRulerHandle;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -550,3 +550,4 @@ export type { VirtualPointerSinks, UseVirtualPointer, } from "./composables/useV
|
|
|
550
550
|
export { useRemoteTouchGestures } from "./composables/useRemoteTouchGestures";
|
|
551
551
|
export type { TouchGestureHandlers } from "./composables/useRemoteTouchGestures";
|
|
552
552
|
export { useOrientationLock } from "./composables/useOrientationLock";
|
|
553
|
+
export { attachOverviewRuler, type OverviewRulerAxis, type OverviewRulerBand, type OverviewRulerCursorMode, type OverviewRulerHandle, type OverviewRulerOptions, } from "./composables/useOverviewRuler";
|
package/package.json
CHANGED
|
@@ -125,17 +125,26 @@
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
.hk-expansion-panel-content {
|
|
128
|
+
/* The clipped grid item must stay PADDING-FREE: vertical padding on it
|
|
129
|
+
cannot collapse with the 0fr track — the track goes to zero but the
|
|
130
|
+
padding block survives as a residual band under the header of every
|
|
131
|
+
closed panel (the "weird padding below the collapsed DPI card"
|
|
132
|
+
report). The body inset therefore lives on the inner wrapper, which
|
|
133
|
+
the clip takes away wholesale when the track collapses. */
|
|
134
|
+
min-height: 0;
|
|
135
|
+
overflow: hidden;
|
|
136
|
+
visibility: hidden;
|
|
137
|
+
// Stays visible while the closing animation runs, then hides.
|
|
138
|
+
transition: visibility 0s linear var(--duration-normal);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.hk-expansion-panel-content-inner {
|
|
128
142
|
/* The BODY padding belongs to the panel, not to each host: inline
|
|
129
143
|
padding matches the header's own (var(--space-12)), so body content
|
|
130
144
|
aligns with the title, and the bottom pad gives the content breathing
|
|
131
145
|
room before the panel edge. Without this every consumer hand-pads
|
|
132
146
|
(and forgets — the flush body was exactly that report). */
|
|
133
147
|
padding: var(--space-8) var(--space-12) var(--space-12);
|
|
134
|
-
min-height: 0;
|
|
135
|
-
overflow: hidden;
|
|
136
|
-
visibility: hidden;
|
|
137
|
-
// Stays visible while the closing animation runs, then hides.
|
|
138
|
-
transition: visibility 0s linear var(--duration-normal);
|
|
139
148
|
}
|
|
140
149
|
|
|
141
150
|
.hk-expansion-panel[data-open] .hk-expansion-panel-content {
|
|
@@ -111,15 +111,46 @@ describe("HkExpansionPanel", () => {
|
|
|
111
111
|
});
|
|
112
112
|
});
|
|
113
113
|
|
|
114
|
-
describe("HkExpansionPanel body padding contract (2026-11-19)", () => {
|
|
114
|
+
describe("HkExpansionPanel body padding contract (2026-11-19, relocated 2026-11-21)", () => {
|
|
115
115
|
// The BODY padding belongs to the panel (user direction 2026-11-19: a
|
|
116
116
|
// flush expanded body read as a host bug, and hosts that hand-padded
|
|
117
117
|
// doubled once the panel grew its own). The stylesheet contract keeps
|
|
118
118
|
// the inset from being dropped again.
|
|
119
|
-
|
|
119
|
+
//
|
|
120
|
+
// 2026-11-21 (user report: a residual band below the collapsed DPI
|
|
121
|
+
// card): the padding MOVED from the clipped grid item to an inner
|
|
122
|
+
// wrapper. Vertical padding on the clipped item cannot collapse with
|
|
123
|
+
// the 0fr track — the track goes to zero but the padding block
|
|
124
|
+
// survives as a ~20px dead band under the header of every closed
|
|
125
|
+
// panel. Both halves are pinned: the inset still exists (inner), and
|
|
126
|
+
// the clip itself carries none.
|
|
127
|
+
it("owns the body inset on the inner wrapper (header-aligned inline + bottom)", () => {
|
|
120
128
|
const scss = readFileSync(join(dirname(fileURLToPath(import.meta.url)), "HkExpansionPanel.scss"), "utf8");
|
|
121
129
|
expect(scss).toMatch(
|
|
122
|
-
/\.hk-expansion-panel-content\s*{[^}]*padding:\s*var\(--space-8\)\s+var\(--space-12\)\s+var\(--space-12\)/,
|
|
130
|
+
/\.hk-expansion-panel-content-inner\s*{[^}]*padding:\s*var\(--space-8\)\s+var\(--space-12\)\s+var\(--space-12\)/,
|
|
123
131
|
);
|
|
124
132
|
});
|
|
133
|
+
|
|
134
|
+
it("keeps the clipped grid item padding-free so a closed panel collapses to zero", () => {
|
|
135
|
+
const scss = readFileSync(join(dirname(fileURLToPath(import.meta.url)), "HkExpansionPanel.scss"), "utf8");
|
|
136
|
+
const content = scss.match(/\.hk-expansion-panel-content\s*{([^}]*)}/)?.[1] ?? "";
|
|
137
|
+
// Strip comments first — the prose explains the rule and mentions the
|
|
138
|
+
// word; only the declarations count.
|
|
139
|
+
const declarations = content.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/[^\n]*/g, "");
|
|
140
|
+
expect(declarations).not.toMatch(/padding/);
|
|
141
|
+
// The collapse machinery stays on the clip: the 0fr track + the
|
|
142
|
+
// min-height/overflow pair are what make the closed body actually
|
|
143
|
+
// disappear rather than shrink to its padding.
|
|
144
|
+
expect(declarations).toContain("min-height: 0");
|
|
145
|
+
expect(declarations).toContain("overflow: hidden");
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it("renders the inner wrapper between the clip and the slot content", () => {
|
|
149
|
+
const container = mountPanel({ title: "T" }, { default: () => h("p", "body") });
|
|
150
|
+
const content = panelOf(container).querySelector<HTMLElement>(".hk-expansion-panel-content")!;
|
|
151
|
+
expect(content).toBeTruthy();
|
|
152
|
+
const inner = content.querySelector<HTMLElement>(":scope > .hk-expansion-panel-content-inner");
|
|
153
|
+
expect(inner).toBeTruthy();
|
|
154
|
+
expect(inner!.textContent).toBe("body");
|
|
155
|
+
});
|
|
125
156
|
});
|
|
@@ -93,7 +93,15 @@ export default defineComponent({
|
|
|
93
93
|
</span>
|
|
94
94
|
</button>
|
|
95
95
|
<div class="hk-expansion-panel-body">
|
|
96
|
-
<div class="hk-expansion-panel-content">
|
|
96
|
+
<div class="hk-expansion-panel-content">
|
|
97
|
+
{/* The PADDING lives on this inner wrapper, not on the clipped
|
|
98
|
+
grid item: a padded grid item cannot collapse to zero (the
|
|
99
|
+
padding block survives the 0fr track as a residual band under
|
|
100
|
+
the header — the "weird padding below the collapsed DPI card"
|
|
101
|
+
report). The clip stays padding-free; the wrapper is what
|
|
102
|
+
gets clipped away. */}
|
|
103
|
+
<div class="hk-expansion-panel-content-inner">{slots.default?.()}</div>
|
|
104
|
+
</div>
|
|
97
105
|
</div>
|
|
98
106
|
</div>
|
|
99
107
|
);
|
|
@@ -104,10 +104,27 @@
|
|
|
104
104
|
// The generous top padding keeps the copy clear of the lane stroke —
|
|
105
105
|
// a second device pass showed 8px reading as part of the graphic.
|
|
106
106
|
display: block;
|
|
107
|
+
// One text line's box, kept across states: the confirmed spinner (12px)
|
|
108
|
+
// is shorter than the text line box it replaces, and without this floor
|
|
109
|
+
// the hint (and everything below it) jumps up ~6px at the moment of
|
|
110
|
+
// confirm.
|
|
111
|
+
min-height: calc(var(--text-xs, 0.75rem) * 1.5);
|
|
107
112
|
padding: var(--space-8, 8px) var(--space-12, 12px) var(--space-4, 4px);
|
|
108
113
|
text-align: center;
|
|
109
114
|
font-size: var(--text-xs, 0.75rem);
|
|
110
115
|
color: rgb(var(--color-muted));
|
|
111
116
|
}
|
|
112
117
|
|
|
118
|
+
// The retired ✓ glyph is a busy spinner now (2026-11-21 user ruling):
|
|
119
|
+
// a walk completion hands off to the parent, so the hint line shows the
|
|
120
|
+
// standard spinner. The wrapper is a BLOCK-level flex box, so
|
|
121
|
+
// text-align cannot centre it — this confirmed override must stay AFTER
|
|
122
|
+
// the base rule above (same specificity (0,2,0); source order decides)
|
|
123
|
+
// or the centring silently dies (R5-caught S2).
|
|
124
|
+
.hk-serpentine--confirmed .hk-serpentine-hint {
|
|
125
|
+
display: flex;
|
|
126
|
+
align-items: center;
|
|
127
|
+
justify-content: center;
|
|
128
|
+
}
|
|
129
|
+
|
|
113
130
|
|
|
@@ -126,6 +126,33 @@ describe("HkSerpentineUnlock (mounted)", () => {
|
|
|
126
126
|
expect(cancelSpy).not.toHaveBeenCalled();
|
|
127
127
|
});
|
|
128
128
|
|
|
129
|
+
it("shows the busy spinner after a confirm — never a ✓ success stamp", async () => {
|
|
130
|
+
// 2026-11-21 user ruling: a walk completion hands off to the parent,
|
|
131
|
+
// so the hint line renders the standard spinner (the retired "✓"
|
|
132
|
+
// read as a success stamp on a deletion still in flight — and the
|
|
133
|
+
// #1468 revert had brought it back). DOM assertions ride nextTick:
|
|
134
|
+
// the confirm emit is synchronous, the render is not.
|
|
135
|
+
const el = mountGate();
|
|
136
|
+
expect(el.querySelector(".hk-serpentine-hint .hk-spinner")).toBeNull();
|
|
137
|
+
const path = generateSerpentinePath(600, 96, 42);
|
|
138
|
+
const start = path.points[0]!;
|
|
139
|
+
pointer(el, "pointerdown", start.x, start.y);
|
|
140
|
+
for (let d = 6; d <= path.totalLength + 4; d += 6) {
|
|
141
|
+
const at = projectOntoPath(path.points, d);
|
|
142
|
+
pointer(el, "pointermove", at.x, at.y);
|
|
143
|
+
}
|
|
144
|
+
pointer(el, "pointerup", 600, 48);
|
|
145
|
+
await nextTick();
|
|
146
|
+
// Mutation-ordering contract (R3 S1): the two semantic pins come FIRST,
|
|
147
|
+
// so each dies on its own line — a mutation back to the text "✓" trips
|
|
148
|
+
// the glyph-absence pin (and drops aria-busy), not just the spinner
|
|
149
|
+
// existence query.
|
|
150
|
+
const hint = el.querySelector(".hk-serpentine-hint")!;
|
|
151
|
+
expect(hint.textContent).not.toContain("✓");
|
|
152
|
+
expect(el.getAttribute("aria-busy")).toBe("true");
|
|
153
|
+
expect(hint.querySelector(".hk-spinner")).toBeTruthy();
|
|
154
|
+
});
|
|
155
|
+
|
|
129
156
|
it("holds position when the pointer drifts off-lane (no reset)", () => {
|
|
130
157
|
// Device feedback: an 18px corridor reset the walk on every wobble.
|
|
131
158
|
// Now a drifting pointer HOLDS the knob (no fail, no spring); the walk
|
|
@@ -299,7 +326,26 @@ describe("HkSerpentineUnlock styles contract", () => {
|
|
|
299
326
|
});
|
|
300
327
|
|
|
301
328
|
it("keeps no displacement animation at all (the shake retired with the off-path fail)", () => {
|
|
302
|
-
|
|
329
|
+
// The busy spinner is the standard HkSpinner component — its rotation
|
|
330
|
+
// keyframe lives in HkSpinner.scss, not here (0 here is the healthy
|
|
331
|
+
// state; the ≤1 slack exists only so a future local keyframe does not
|
|
332
|
+
// read as a regression of the retired shake).
|
|
333
|
+
expect(scss.split("@keyframes").length - 1).toBeLessThanOrEqual(1);
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
it("authors the confirmed flex override AFTER the base hint rule (cascade pin)", () => {
|
|
337
|
+
// R5-caught S2: both selectors are (0,2,0), so source order decides.
|
|
338
|
+
// The confirmed rule (flex centring for the block-level spinner
|
|
339
|
+
// wrapper) sat ABOVE the base `display: block` and never applied —
|
|
340
|
+
// the spinner hugged the hint line's left edge. Pin the order.
|
|
341
|
+
const base = scss.indexOf(".hk-serpentine-hint {");
|
|
342
|
+
const confirmed = scss.indexOf(".hk-serpentine--confirmed .hk-serpentine-hint {");
|
|
343
|
+
expect(base).toBeGreaterThan(-1);
|
|
344
|
+
expect(confirmed).toBeGreaterThan(base);
|
|
345
|
+
// And the override really carries the centring declarations.
|
|
346
|
+
const confirmedBlock = scss.slice(confirmed);
|
|
347
|
+
expect(confirmedBlock).toContain("display: flex");
|
|
348
|
+
expect(confirmedBlock).toContain("justify-content: center");
|
|
303
349
|
});
|
|
304
350
|
|
|
305
351
|
it("puts the hint in flow (no absolute hang below the box)", () => {
|
|
@@ -315,7 +361,8 @@ describe("HkSerpentineUnlock styles contract", () => {
|
|
|
315
361
|
// duration/ease tokens. The invented --hk-motion-ease must not return.
|
|
316
362
|
expect(scss).toContain("--ease-standard");
|
|
317
363
|
expect(scss).not.toContain("--hk-motion-ease");
|
|
318
|
-
// spinner
|
|
364
|
+
// The spinner rides the standard HkSpinner component; no local
|
|
365
|
+
// rotation keyframe belongs in this sheet.
|
|
319
366
|
expect(scss.split("@keyframes").length - 1).toBeLessThanOrEqual(1);
|
|
320
367
|
});
|
|
321
368
|
});
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
} from "./serpentineGeometry";
|
|
20
20
|
import "./HkSerpentineUnlock.scss";
|
|
21
21
|
import { onFrame, reportTransition, type AnimationHandle } from "../runtime/animationBus";
|
|
22
|
+
import HkSpinner from "./HkSpinner";
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* Deliberate-action gate: drag the handle along a randomly generated
|
|
@@ -335,6 +336,7 @@ const TRACKING_TOLERANCE = 30;
|
|
|
335
336
|
ref={viewport}
|
|
336
337
|
role="group"
|
|
337
338
|
aria-label={props.label}
|
|
339
|
+
aria-busy={confirmed.value || undefined}
|
|
338
340
|
tabindex={props.disabled ? -1 : 0}
|
|
339
341
|
onKeydown={onKeydown}
|
|
340
342
|
onPointerdown={onPointerDown}
|
|
@@ -373,7 +375,13 @@ const TRACKING_TOLERANCE = 30;
|
|
|
373
375
|
</div>
|
|
374
376
|
<span class="hk-serpentine-hint" aria-live="polite">
|
|
375
377
|
{confirmed.value
|
|
376
|
-
|
|
378
|
+
// The walk is done and the parent is acting on it: a busy
|
|
379
|
+
// spinner (2026-11-21 user ruling — the retired "✓" claimed a
|
|
380
|
+
// completion the gate does not know about; it also came back
|
|
381
|
+
// from the #1461 revert looking like a *success* stamp on a
|
|
382
|
+
// deletion still in flight). The standard spinner renders in
|
|
383
|
+
// the hint line and the gate announces busy (aria-busy).
|
|
384
|
+
? <HkSpinner size="xs" />
|
|
377
385
|
: tracking.value || keyboardGrabbed.value
|
|
378
386
|
? props.trackingHint
|
|
379
387
|
: props.grabHint}
|
|
@@ -137,6 +137,17 @@
|
|
|
137
137
|
takes no space, so the option's own content stays exactly centred (a
|
|
138
138
|
reserved lane here was what pushed the auto option off-centre). */
|
|
139
139
|
width: 100%;
|
|
140
|
+
|
|
141
|
+
.hk-supplement-inset-supplement-inner {
|
|
142
|
+
/* Trailing inset inside the collapsing column (so it, too, occupies
|
|
143
|
+
nothing at rest): the cell has no padding of its own and the
|
|
144
|
+
sliding indicator frames the CELL — without a trailing inset the
|
|
145
|
+
revealed action's 20px hit area lands flush on the segment edge
|
|
146
|
+
and the dots glyph hugs the boundary (user report). Matches the
|
|
147
|
+
trigger's own inline padding (var(--space-12)) so the revealed
|
|
148
|
+
action reads as sitting inside the option, same as the label. */
|
|
149
|
+
padding-inline-end: var(--space-12);
|
|
150
|
+
}
|
|
140
151
|
}
|
|
141
152
|
|
|
142
153
|
.hk-supplement-inset-main > .hk-tabs-trigger {
|
|
@@ -1439,3 +1439,78 @@ describe("HkTabs attached trigger actions (2026-11-19)", () => {
|
|
|
1439
1439
|
expect(document.querySelector(".hk-select-popout")).toBeNull();
|
|
1440
1440
|
});
|
|
1441
1441
|
});
|
|
1442
|
+
|
|
1443
|
+
describe("HkTabs supplement trailing inset (2026-11-21)", () => {
|
|
1444
|
+
// User report: the hover/press-revealed ⋯ inside a segmented option sat
|
|
1445
|
+
// flush on the segment's right edge — the cell has no padding of its own
|
|
1446
|
+
// and the sliding indicator frames the CELL, so the action's hit area
|
|
1447
|
+
// landed on the boundary. The fix gives the supplement column a trailing
|
|
1448
|
+
// inset matching the trigger's own inline padding, INSIDE the collapsing
|
|
1449
|
+
// column (at rest it still occupies nothing, so the label stays centred).
|
|
1450
|
+
const scss = readFileSync(join(here, "HkTabs.scss"), "utf8");
|
|
1451
|
+
|
|
1452
|
+
it("pads the supplement column's end inside the option cell", () => {
|
|
1453
|
+
// Brace-walk the `.hk-tabs-cell > .hk-supplement-inset` block itself:
|
|
1454
|
+
// a plain whole-file regex would also match a hoisted top-level rule,
|
|
1455
|
+
// which would leak the inset to every HkSupplementInset consumer.
|
|
1456
|
+
const cellStart = scss.indexOf(".hk-tabs-cell > .hk-supplement-inset");
|
|
1457
|
+
expect(cellStart).toBeGreaterThan(-1);
|
|
1458
|
+
const open = scss.indexOf("{", cellStart);
|
|
1459
|
+
let depth = 0;
|
|
1460
|
+
let end = -1;
|
|
1461
|
+
for (let i = open; i < scss.length; i++) {
|
|
1462
|
+
if (scss[i] === "{") depth++;
|
|
1463
|
+
else if (scss[i] === "}") {
|
|
1464
|
+
depth--;
|
|
1465
|
+
if (depth === 0) {
|
|
1466
|
+
end = i;
|
|
1467
|
+
break;
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
expect(end).toBeGreaterThan(open);
|
|
1472
|
+
const cellBlock = scss.slice(open, end + 1);
|
|
1473
|
+
expect(cellBlock).toContain(".hk-supplement-inset-supplement-inner");
|
|
1474
|
+
expect(cellBlock).toContain("padding-inline-end: var(--space-12)");
|
|
1475
|
+
// And the nested selector really is the inner (not some other child).
|
|
1476
|
+
expect(cellBlock).toMatch(
|
|
1477
|
+
/\.hk-supplement-inset-supplement-inner\s*{[^}]*padding-inline-end:\s*var\(--space-12\)/,
|
|
1478
|
+
);
|
|
1479
|
+
});
|
|
1480
|
+
|
|
1481
|
+
it("mounts the inset cell anatomy an action rides in (structure anchor)", () => {
|
|
1482
|
+
const onSelect = vi.fn();
|
|
1483
|
+
const container = document.createElement("div");
|
|
1484
|
+
document.body.appendChild(container);
|
|
1485
|
+
containers.push(container);
|
|
1486
|
+
const active = ref("a");
|
|
1487
|
+
const Wrapper = defineComponent({
|
|
1488
|
+
setup() {
|
|
1489
|
+
return () =>
|
|
1490
|
+
h(HkTabs, {
|
|
1491
|
+
modelValue: active.value,
|
|
1492
|
+
"onUpdate:modelValue": (v: string) => { active.value = v; },
|
|
1493
|
+
renderPanels: false,
|
|
1494
|
+
variant: "segmented",
|
|
1495
|
+
tabs: [
|
|
1496
|
+
{ key: "a", label: "Auto", actions: [{ key: "dot", label: "Configure", onSelect }] },
|
|
1497
|
+
{ key: "b", label: "Dark" },
|
|
1498
|
+
] as TabItem[],
|
|
1499
|
+
});
|
|
1500
|
+
},
|
|
1501
|
+
});
|
|
1502
|
+
const app = createApp(Wrapper);
|
|
1503
|
+
mounts.push(app);
|
|
1504
|
+
app.mount(container);
|
|
1505
|
+
// cell > inset > (main > trigger, supplement > inner > action): the
|
|
1506
|
+
// stylesheet's descendant inset rule must reach the real supplement.
|
|
1507
|
+
const inner = container.querySelector<HTMLElement>(
|
|
1508
|
+
".hk-tabs-cell > .hk-supplement-inset .hk-supplement-inset-supplement-inner",
|
|
1509
|
+
);
|
|
1510
|
+
expect(inner).toBeTruthy();
|
|
1511
|
+
expect(
|
|
1512
|
+
inner!.querySelector(".hk-tabs-trigger-action"),
|
|
1513
|
+
"the action renders inside the padded inner",
|
|
1514
|
+
).toBeTruthy();
|
|
1515
|
+
});
|
|
1516
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reference-counted host-position promotion, shared by every composable
|
|
3
|
+
* that needs a positioned positioning context (the overlay scrollbar and
|
|
4
|
+
* the overview ruler). A module-private WeakMap per composable is the
|
|
5
|
+
* exact accident this exists to prevent: ruler A's detach stripping the
|
|
6
|
+
* positioning out from under a still-live scrollbar B on the same host.
|
|
7
|
+
*
|
|
8
|
+
* Contract:
|
|
9
|
+
* - `promoteHost(host)` counts the caller and returns its release;
|
|
10
|
+
* - the FIRST caller on a static/empty-position host sets
|
|
11
|
+
* `position: relative`; every later caller (whatever the computed
|
|
12
|
+
* position now is) is still counted;
|
|
13
|
+
* - the LAST release restores the PRE-ATTACH inline position — unless a
|
|
14
|
+
* consumer re-styled the host after attach (their style wins; the
|
|
15
|
+
* saved value stays dead).
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const promotedParents = new WeakMap<HTMLElement, { count: number; saved: string }>();
|
|
19
|
+
|
|
20
|
+
export interface PromoteHostHandle {
|
|
21
|
+
release(): void;
|
|
22
|
+
/** Whether THIS call applied the promotion (count reached 1 on a
|
|
23
|
+
* static/empty host). Consumers use it to gate companion markers that
|
|
24
|
+
* only make sense when the promotion actually happened. */
|
|
25
|
+
promoted: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function promoteHost(host: HTMLElement): PromoteHostHandle {
|
|
29
|
+
let entry = promotedParents.get(host);
|
|
30
|
+
if (!entry) {
|
|
31
|
+
entry = { count: 0, saved: host.style.position };
|
|
32
|
+
promotedParents.set(host, entry);
|
|
33
|
+
}
|
|
34
|
+
entry.count += 1;
|
|
35
|
+
const computedPosition = getComputedStyle(host).position;
|
|
36
|
+
const promoted = entry.count === 1 && (computedPosition === "static" || computedPosition === "");
|
|
37
|
+
if (promoted) {
|
|
38
|
+
host.style.position = "relative";
|
|
39
|
+
}
|
|
40
|
+
let released = false;
|
|
41
|
+
return {
|
|
42
|
+
promoted,
|
|
43
|
+
release(): void {
|
|
44
|
+
if (released) return;
|
|
45
|
+
released = true;
|
|
46
|
+
const current = promotedParents.get(host);
|
|
47
|
+
if (!current || current !== entry) return;
|
|
48
|
+
entry.count -= 1;
|
|
49
|
+
if (entry.count <= 0) {
|
|
50
|
+
// Only undo OUR promotion: if a consumer re-positioned the host
|
|
51
|
+
// after attach, their inline style wins and the saved value stays
|
|
52
|
+
// dead (presence-gated, per R4b).
|
|
53
|
+
if (host.style.position === "relative") host.style.position = entry.saved;
|
|
54
|
+
promotedParents.delete(host);
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
// `detach()` on close/unmount so no DOM or listener leaks.
|
|
25
25
|
|
|
26
26
|
import { drawnScale } from "./layoutGeometry";
|
|
27
|
+
import { promoteHost } from "./useHostPromotion";
|
|
27
28
|
import { scheduleCronAfter, type CronHandle } from "../runtime/cronBus";
|
|
28
29
|
import { scheduleFrame, type AnimationHandle } from "../runtime/animationBus";
|
|
29
30
|
|
|
@@ -240,7 +241,7 @@ const POSITION_GUARD_ATTR = "data-hk-overlay-scrollbar-positioned";
|
|
|
240
241
|
* (e.g. sibling code panes reconciled independently); the inline
|
|
241
242
|
* `position: relative` must survive until the LAST handle detaches, so
|
|
242
243
|
* promotion is reference-counted. */
|
|
243
|
-
|
|
244
|
+
|
|
244
245
|
|
|
245
246
|
/** Read the scroll geometry of `viewport` for one axis. */
|
|
246
247
|
function axisMetrics(viewport: HTMLElement, horizontal: boolean) {
|
|
@@ -296,25 +297,21 @@ export function attachOverlayScrollbars(
|
|
|
296
297
|
// viewport's parent. A static parent would anchor them to the
|
|
297
298
|
// nearest positioned ancestor instead — promote it to `relative`
|
|
298
299
|
// and remember the previous inline value for restore on detach —
|
|
299
|
-
// reference-counted per parent (see
|
|
300
|
+
// reference-counted per parent (see useHostPromotion) so a sibling
|
|
300
301
|
// handle's detach cannot strip the positioning out from under the
|
|
301
302
|
// tracks that remain.
|
|
302
303
|
// (Real browsers always report "static" for unpositioned elements;
|
|
303
304
|
// happy-dom reports "" — both mean "no positioning context".)
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
305
|
+
// Positioning guard: the tracks are position:absolute inside the
|
|
306
|
+
// viewport's parent. A static parent would anchor them to the nearest
|
|
307
|
+
// positioned ancestor — promote it to `relative` through the shared
|
|
308
|
+
// reference-counted helper so a sibling composable's detach (the
|
|
309
|
+
// overview ruler attaches to the same hosts) cannot strip the
|
|
310
|
+
// positioning out from under the tracks that remain.
|
|
311
|
+
const promotion = promoteHost(parent);
|
|
312
|
+
if (promotion.promoted) {
|
|
313
|
+
parent.setAttribute(POSITION_GUARD_ATTR, "true");
|
|
311
314
|
}
|
|
312
|
-
// Count EVERY handle on a promoted parent — including handles whose
|
|
313
|
-
// attach sees the parent already `relative` (computed styles reflect
|
|
314
|
-
// the first handle's inline promotion). Skipping those would let the
|
|
315
|
-
// first detach strip the positioning out from under surviving tracks.
|
|
316
|
-
const entry = promotedParents.get(parent);
|
|
317
|
-
if (entry) entry.count++;
|
|
318
315
|
|
|
319
316
|
const states: AxisState[] = [];
|
|
320
317
|
if (wantV) states.push(makeAxisState(false));
|
|
@@ -688,13 +685,9 @@ export function attachOverlayScrollbars(
|
|
|
688
685
|
state.hideTimer?.disconnect();
|
|
689
686
|
state.track.remove();
|
|
690
687
|
}
|
|
691
|
-
|
|
692
|
-
if (
|
|
693
|
-
// Last handle on this parent is gone — restore its inline
|
|
694
|
-
// positioning exactly as the guard found it.
|
|
695
|
-
parent.style.position = entry.saved;
|
|
688
|
+
promotion.release();
|
|
689
|
+
if (parent.style.position !== "relative") {
|
|
696
690
|
parent.removeAttribute(POSITION_GUARD_ATTR);
|
|
697
|
-
promotedParents.delete(parent);
|
|
698
691
|
}
|
|
699
692
|
},
|
|
700
693
|
};
|