@celestia-island/hikari 0.55.433 → 0.55.435

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.
@@ -0,0 +1,136 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { afterEach, describe, expect, it, vi } from "vitest";
5
+ import { createApp, defineComponent, h, nextTick, ref } from "vue";
6
+
7
+ import HkSupplementInset from "./HkSupplementInset";
8
+
9
+ const here = dirname(fileURLToPath(import.meta.url));
10
+
11
+ const mounts: Array<{ app: ReturnType<typeof createApp>; container: HTMLElement }> = [];
12
+
13
+ function mountInset(props: Record<string, unknown> = {}, slots?: Record<string, () => unknown>) {
14
+ const container = document.createElement("div");
15
+ document.body.appendChild(container);
16
+ const Host = defineComponent({
17
+ name: "InsetHost",
18
+ setup() {
19
+ return () =>
20
+ h(
21
+ HkSupplementInset,
22
+ { ...props },
23
+ slots ?? {
24
+ default: () => h("span", { class: "probe-main" }, "main content"),
25
+ supplement: () => h("span", { class: "probe-supplement" }, "extra"),
26
+ },
27
+ );
28
+ },
29
+ });
30
+ const app = createApp(Host);
31
+ app.mount(container);
32
+ mounts.push({ app, container });
33
+ return { container, app };
34
+ }
35
+
36
+ afterEach(() => {
37
+ for (const { app } of mounts.splice(0)) app.unmount();
38
+ });
39
+
40
+ describe("HkSupplementInset", () => {
41
+ it("renders main and supplement regions as siblings of one surface", () => {
42
+ const { container } = mountInset();
43
+ expect(container.querySelector(".hk-supplement-inset-main .probe-main")).toBeTruthy();
44
+ expect(container.querySelector(".hk-supplement-inset-supplement-inner .probe-supplement")).toBeTruthy();
45
+ });
46
+
47
+ it("the controlled `revealed` prop drives data-revealed", async () => {
48
+ const open = ref(false);
49
+ const Host = defineComponent({
50
+ setup() {
51
+ return () => h(HkSupplementInset, { revealed: open.value });
52
+ },
53
+ });
54
+ const container = document.createElement("div");
55
+ document.body.appendChild(container);
56
+ const app = createApp(Host);
57
+ app.mount(container);
58
+ const inset = container.querySelector<HTMLElement>(".hk-supplement-inset")!;
59
+ expect(inset.hasAttribute("data-revealed")).toBe(false);
60
+ open.value = true;
61
+ await nextTick();
62
+ expect(inset.hasAttribute("data-revealed")).toBe(true);
63
+ app.unmount();
64
+ });
65
+
66
+ it("measures the supplement content into the animation width var", () => {
67
+ const { container } = mountInset();
68
+ const inset = container.querySelector<HTMLElement>(".hk-supplement-inset")!;
69
+ // happy-dom measures layout as 0, so assert the var EXISTS and is a px
70
+ // value (the ResizeObserver keeps it fresh in real browsers).
71
+ expect(inset.style.getPropertyValue("--hk-supplement-w")).toMatch(/px$/);
72
+ });
73
+
74
+ it("the `closed` prop forces the supplement shut even while hovered", () => {
75
+ // Render with BOTH data-closed and data-hover-reveal (the press-off
76
+ // state on a surface the pointer is still over): the closed attr wins
77
+ // in CSS — assert the attribute wiring carries it.
78
+ const { container } = mountInset({ closed: true, revealOnHover: true });
79
+ const inset = container.querySelector<HTMLElement>(".hk-supplement-inset")!;
80
+ expect(inset.hasAttribute("data-closed")).toBe(true);
81
+ expect(inset.hasAttribute("data-hover-reveal")).toBe(true);
82
+ });
83
+
84
+ it("omits the supplement region entirely when the slot is absent", () => {
85
+ const { container } = mountInset({}, { default: () => h("span", "main only") });
86
+ expect(container.querySelector(".hk-supplement-inset-supplement")).toBeNull();
87
+ });
88
+
89
+ it("pins the reveal grammar in the stylesheet", () => {
90
+ const scss = readFileSync(join(here, "HkSupplementInset.scss"), "utf8");
91
+ // At rest: no space, hidden (untabbable, out of the a11y tree).
92
+ expect(scss).toMatch(
93
+ /\.hk-supplement-inset-supplement\s*{[^}]*max-width:\s*0px/,
94
+ );
95
+ expect(scss).toMatch(
96
+ /\.hk-supplement-inset-supplement\s*{[^}]*visibility:\s*hidden/,
97
+ );
98
+ // Reveal: the controlled prop, hover, and focus-within all flip it —
99
+ // visibility flips immediately, width/opacity animate.
100
+ expect(scss).toMatch(
101
+ /\.hk-supplement-inset\[data-revealed\] \.hk-supplement-inset-supplement,/,
102
+ );
103
+ expect(scss).toMatch(
104
+ /\.hk-supplement-inset\[data-hover-reveal\]:not\(\[data-closed\]\):hover \.hk-supplement-inset-supplement,/,
105
+ );
106
+ expect(scss).toMatch(
107
+ /\.hk-supplement-inset\[data-hover-reveal\]:not\(\[data-closed\]\):focus-within \.hk-supplement-inset-supplement\s*{[^}]*visibility:\s*visible/,
108
+ );
109
+ // The press-off state: forced closed even under hover/focus (a touch
110
+ // tap leaves sticky hover behind — without this the toggle-off is
111
+ // unobservable).
112
+ expect(scss).toMatch(
113
+ /\.hk-supplement-inset\[data-closed\] \.hk-supplement-inset-supplement\s*{[^}]*visibility:\s*hidden/,
114
+ );
115
+ // The measured width: the inner must NOT be a shrinkable flex item (it
116
+ // would measure at min-content and clamp the reveal forever).
117
+ expect(scss).toMatch(
118
+ /\.hk-supplement-inset-supplement-inner\s*{[^}]*\n\s*flex:\s*none;/,
119
+ );
120
+ expect(scss).toMatch(
121
+ /max-width:\s*var\(--hk-supplement-w,\s*32px\)/,
122
+ );
123
+ // The push: the main region takes the remaining space (so it is pushed
124
+ // left while the supplement opens).
125
+ expect(scss).toMatch(
126
+ /\.hk-supplement-inset-main\s*{[^}]*flex:\s*1 1 auto/,
127
+ );
128
+ // Animation-context control: tokens + reduced-motion instant states.
129
+ expect(scss).toMatch(
130
+ /transition:\s*max-width\s+var\(--duration-normal\)\s+var\(--ease-standard\)/,
131
+ );
132
+ expect(scss).toMatch(
133
+ /@media \(prefers-reduced-motion: reduce\)\s*{[^}]*\.hk-supplement-inset-supplement\s*{[^}]*transition:\s*none/s,
134
+ );
135
+ });
136
+ });
@@ -0,0 +1,116 @@
1
+ import { defineComponent, onBeforeUnmount, onMounted, ref, watch, type VNodeChild } from "vue";
2
+
3
+ import "./HkSupplementInset.scss";
4
+
5
+ /**
6
+ * HkSupplementInset — the supplementary slot of a button surface
7
+ * (2026-11-19 user direction: any button surface can mount such a
8
+ * supplement — a ⋯ menu button here, anything else there). At rest the
9
+ * supplement takes NO space, so the surface's own content stays exactly
10
+ * where the host put it (a lane reservation was what pushed the theme
11
+ * panel's auto option off-centre). On reveal the supplement's column
12
+ * animates open — the main content is pushed left — and the supplement
13
+ * content fades in; the whole thing rides the animation context
14
+ * (duration/ease tokens, reduced-motion gets instant states).
15
+ *
16
+ * Reveal sources:
17
+ * - `revealOnHover` (default on): hovering the inset or moving focus
18
+ * into it reveals, CSS-only;
19
+ * - the `revealed` prop (controlled): the host toggles it — the theme
20
+ * panel reveals on a click of the ALREADY-ACTIVE option (whose press
21
+ * is otherwise a no-op), which is also the touch path where hover
22
+ * does not exist.
23
+ *
24
+ * STRUCTURE CONTRACT: the main region and the supplement region are
25
+ * SIBLING controls inside one surface — a supplement control must not be
26
+ * nested inside the main button (a button cannot nest a button). Hosts
27
+ * compose:
28
+ *
29
+ * <HkSupplementInset revealed={open}>
30
+ * {{ default: <button>…</button> }}
31
+ * {{ supplement: <HkIconButton …/> }}
32
+ * </HkSupplementInset>
33
+ *
34
+ * HkTabs' attached trigger actions are the reference consumer (main =
35
+ * the option trigger, supplement = the ⋯).
36
+ *
37
+ * At rest the supplement is `visibility: hidden` (unfocused, out of the
38
+ * a11y tree); revealing flips visibility immediately while the width and
39
+ * opacity animate. The animation target width is measured from the
40
+ * supplement content (ResizeObserver → `--hk-supplement-w`), so hosts
41
+ * never declare a pixel.
42
+ */
43
+ export default defineComponent({
44
+ name: "HkSupplementInset",
45
+ props: {
46
+ /** Controlled reveal (e.g. the host's click-toggle). Hover/focus
47
+ * reveal is independent (see `revealOnHover`). */
48
+ revealed: { type: Boolean, default: false },
49
+ /** The host's press-off state: forced closed even under hover/focus
50
+ * (a touch tap leaves sticky hover behind — without this the
51
+ * toggle-off would be unobservable). */
52
+ closed: { type: Boolean, default: false },
53
+ /** Reveal on hover / focus-within (CSS-only). Default on. */
54
+ revealOnHover: { type: Boolean, default: true },
55
+ },
56
+ setup(props, { slots }) {
57
+ const innerRef = ref<HTMLElement | null>(null);
58
+ /** The measured supplement content width — the animation's max-width
59
+ * target. Measurement (not a magic constant) keeps the mechanism
60
+ * content-agnostic; before the first measurement a safe fallback
61
+ * applies. */
62
+ const supplementWidth = ref(0);
63
+
64
+ let observer: ResizeObserver | null = null;
65
+ const measure = () => {
66
+ const el = innerRef.value;
67
+ // Layout pixels (offsetWidth ignores transforms — the strip's swap
68
+ // enter scales its cells, and a bbox read mid-transition would
69
+ // under-measure), +1 to cover the integer rounding floor.
70
+ if (el) supplementWidth.value = el.offsetWidth + 1;
71
+ };
72
+ onMounted(() => {
73
+ measure();
74
+ if (typeof ResizeObserver !== "undefined" && innerRef.value) {
75
+ observer = new ResizeObserver(() => measure());
76
+ observer.observe(innerRef.value);
77
+ }
78
+ });
79
+ watch(innerRef, () => {
80
+ measure();
81
+ if (observer) {
82
+ observer.disconnect();
83
+ observer = null;
84
+ }
85
+ if (typeof ResizeObserver !== "undefined" && innerRef.value) {
86
+ observer = new ResizeObserver(() => measure());
87
+ observer.observe(innerRef.value);
88
+ }
89
+ });
90
+ onBeforeUnmount(() => {
91
+ observer?.disconnect();
92
+ observer = null;
93
+ });
94
+
95
+ return () => (
96
+ <div
97
+ class="hk-supplement-inset"
98
+ data-revealed={props.revealed || undefined}
99
+ data-closed={props.closed || undefined}
100
+ data-hover-reveal={props.revealOnHover || undefined}
101
+ style={{ "--hk-supplement-w": `${supplementWidth.value}px` }}
102
+ >
103
+ <div class="hk-supplement-inset-main">{slots.default?.()}</div>
104
+ {slots.supplement ? (
105
+ <div class="hk-supplement-inset-supplement">
106
+ {/* The INNER is the measurement target: the outer carries the
107
+ collapsed max-width, the inner keeps its natural width. */}
108
+ <div class="hk-supplement-inset-supplement-inner" ref={innerRef}>
109
+ {(slots.supplement?.() ?? []) as VNodeChild}
110
+ </div>
111
+ </div>
112
+ ) : null}
113
+ </div>
114
+ );
115
+ },
116
+ });
@@ -132,16 +132,18 @@
132
132
  flex: none;
133
133
  }
134
134
 
135
- .hk-tabs-cell > .hk-tabs-trigger {
136
- /* Fill the cell wherever the cell's width is definite (block flex
137
- growth, slot-unit grid tracks); in a shrink-to-fit inline strip the
135
+ .hk-tabs-cell > .hk-supplement-inset {
136
+ /* The inset fills the cell and owns the reveal: at rest its supplement
137
+ takes no space, so the option's own content stays exactly centred (a
138
+ reserved lane here was what pushed the auto option off-centre). */
139
+ width: 100%;
140
+ }
141
+
142
+ .hk-supplement-inset-main > .hk-tabs-trigger {
143
+ /* Fill the main region so the option's own content shifts left when the
144
+ supplement opens (the push); in a shrink-to-fit inline strip the
138
145
  percentage resolves to the content size, so nothing changes there. */
139
146
  width: 100%;
140
- /* RESERVE the action lane. The overlay is absolutely positioned at the
141
- inline end, so without this the revealed buttons sit ON the label's
142
- last ~20px in a shrink-to-fit pill (clicks there would select the
143
- option's own text and fire the action instead). */
144
- padding-inline-end: calc(var(--space-12) + 18px);
145
147
  }
146
148
 
147
149
  /* block (row-filling) strips: the cell takes the growth its trigger
@@ -155,48 +157,8 @@
155
157
  flex: 1 0 auto;
156
158
  }
157
159
 
158
- .hk-tabs-trigger-actions {
159
- /* Overlaid at the trigger's inline-end edge — a hover reveal that
160
- never shifts layout (the pill's width is the option's track, not
161
- the content's). Hidden until hover/focus-within; on touch there is
162
- no hover, so the reachable path is the option's contextMenu
163
- long-press binding (pair the two when touch matters). */
164
- position: absolute;
165
- inset-inline-end: var(--space-4);
166
- top: 50%;
167
- transform: translateY(-50%);
168
- display: inline-flex;
169
- align-items: center;
170
- /* `visibility: hidden` (not just opacity) keeps the unrevealed action
171
- buttons OUT of the page tab order: an opacity-only hide leaves every
172
- action focusable while invisible, which both leaks Tab stops and
173
- contradicts the strip's roving-tabindex contract. `:focus-within`
174
- reveals them, so a keyboard user tabs trigger → actions. */
175
- visibility: hidden;
176
- opacity: 0;
177
- pointer-events: none;
178
- /* PAINT ORDER: the trigger above carries z-index 1, so an auto-z
179
- sibling would lose hit-testing everywhere the two overlap (which is
180
- everywhere — the trigger fills the cell and the buttons sit inside
181
- its box). One layer above the trigger puts the buttons back on top. */
182
- z-index: 2;
183
- transition: opacity var(--duration-short) ease,
184
- visibility 0s linear var(--duration-short);
185
- }
186
-
187
- .hk-tabs-cell:hover > .hk-tabs-trigger-actions,
188
- .hk-tabs-cell:focus-within > .hk-tabs-trigger-actions {
189
- visibility: visible;
190
- opacity: 1;
191
- pointer-events: auto;
192
- transition: opacity var(--duration-short) ease,
193
- visibility 0s linear 0s;
194
- }
195
-
196
- /* A whole-strip disabled render has no live actions to reveal. */
197
- .hk-tabs-cell[data-disabled] > .hk-tabs-trigger-actions {
198
- display: none;
199
- }
160
+ /* The supplement inset lives in the cell; its action buttons keep the
161
+ ghost-square grammar below (position-independent). */
200
162
 
201
163
  .hk-tabs-trigger-action {
202
164
  display: inline-flex;
@@ -415,7 +377,7 @@
415
377
  @media (prefers-reduced-motion: reduce) {
416
378
  .hk-tabs-trigger,
417
379
  .hk-tabs-indicator,
418
- .hk-tabs-trigger-actions,
380
+ .hk-supplement-inset-supplement,
419
381
  .hk-tabs-swap-enter-active,
420
382
  .hk-tabs-swap-leave-active {
421
383
  transition: none;
@@ -795,6 +795,69 @@ describe("HkTabs trigger corner badge", () => {
795
795
  });
796
796
  });
797
797
 
798
+ describe("HkTabs per-option context menu", () => {
799
+ it("opens the bound menu on right-click through the app-wide provider", async () => {
800
+ const onPick = vi.fn();
801
+ const container = document.createElement("div");
802
+ document.body.appendChild(container);
803
+ containers.push(container);
804
+ const Wrapper = defineComponent({
805
+ setup() {
806
+ return () =>
807
+ h(HkContextMenuProvider, null, {
808
+ default: () =>
809
+ h(HkTabs, {
810
+ modelValue: "a",
811
+ renderPanels: false,
812
+ tabs: [
813
+ {
814
+ key: "a",
815
+ label: "Alpha",
816
+ contextMenu: (point: { x: number; y: number }) => ({
817
+ x: point.x,
818
+ y: point.y,
819
+ title: "Alpha menu",
820
+ items: [{ key: "cfg", label: "Configure alpha" }],
821
+ onSelect: onPick,
822
+ }),
823
+ },
824
+ { key: "b", label: "Beta" },
825
+ ] as TabItem[],
826
+ }),
827
+ });
828
+ },
829
+ });
830
+ const app = createApp(Wrapper);
831
+ mounts.push(app);
832
+ app.mount(container);
833
+ await nextTick();
834
+ const trigger = container.querySelectorAll<HTMLElement>(".hk-tabs-trigger")[0]!;
835
+ trigger.dispatchEvent(new MouseEvent("contextmenu", { bubbles: true, cancelable: true, clientX: 12, clientY: 12 }));
836
+ await nextTick();
837
+ expect(document.querySelector(".hk-select-popout")).toBeTruthy();
838
+ const row = Array.from(document.querySelectorAll<HTMLButtonElement>(".hk-menu-row"))
839
+ .find((r) => r.textContent?.includes("Configure alpha"));
840
+ expect(row).toBeTruthy();
841
+ row!.click();
842
+ await nextTick();
843
+ expect(onPick).toHaveBeenCalledTimes(1);
844
+ const event = new MouseEvent("contextmenu", { bubbles: true, cancelable: true, clientX: 12, clientY: 12 });
845
+ trigger.dispatchEvent(event);
846
+ await nextTick();
847
+ expect(event.defaultPrevented).toBe(true);
848
+ });
849
+
850
+ it("defers outward when the option carries no contextMenu (event untouched)", async () => {
851
+ const { container } = mountTabs({ variant: "segmented" });
852
+ const trigger = container.querySelectorAll<HTMLElement>(".hk-tabs-trigger")[0]!;
853
+ const event = new MouseEvent("contextmenu", { bubbles: true, cancelable: true, clientX: 4, clientY: 4 });
854
+ trigger.dispatchEvent(event);
855
+ await nextTick();
856
+ expect(event.defaultPrevented).toBe(false);
857
+ expect(document.querySelector(".hk-select-popout")).toBeNull();
858
+ });
859
+ });
860
+
798
861
  describe("HkTabs caption-band drag opt-out (2026-11-12)", () => {
799
862
  // A caption-band ancestor may be a DEEP Tauri drag region, and the scroller
800
863
  // pans overflowing strips with its own pointer sweep — the two gestures
@@ -854,6 +917,64 @@ describe("HkTabs attached trigger actions (2026-11-19)", () => {
854
917
  expect(action.getAttribute("data-test")).toBe("hk-tabs-action-a-dot");
855
918
  });
856
919
 
920
+ it("reveals the supplement on a press of the ALREADY-ACTIVE option (touch path)", async () => {
921
+ // Pressing the active option is a no-op selection-wise; with actions
922
+ // attached that press toggles the supplement instead — the click/tap
923
+ // reveal path (hover is the pointer path).
924
+ const onSelect = vi.fn();
925
+ const { container, setActive } = mountWithOptions(
926
+ [{ key: "a", label: "Alpha", actions: [{ key: "dot", label: "Configure alpha", onSelect }] }],
927
+ { modelValue: "a", variant: "segmented" },
928
+ );
929
+ void setActive;
930
+ await nextTick();
931
+ const inset = container.querySelector<HTMLElement>(".hk-supplement-inset")!;
932
+ expect(inset).toBeTruthy();
933
+ expect(inset.hasAttribute("data-revealed")).toBe(false);
934
+ const trigger = container.querySelector<HTMLElement>(".hk-tabs-trigger")!;
935
+ trigger.click();
936
+ await nextTick();
937
+ expect(inset.hasAttribute("data-revealed"), "the press reveals the supplement").toBe(true);
938
+ // Press again: toggles to the CLOSED state — the attribute wiring is
939
+ // data-closed (which the CSS lets beat hover; a mere data-revealed
940
+ // removal would be masked by sticky hover). A revert to the old
941
+ // set-toggle (no closed state) fails this.
942
+ trigger.click();
943
+ await nextTick();
944
+ expect(inset.hasAttribute("data-revealed")).toBe(false);
945
+ expect(inset.hasAttribute("data-closed"), "the press-off state is explicit").toBe(true);
946
+ // Third press: re-opens.
947
+ trigger.click();
948
+ await nextTick();
949
+ expect(inset.hasAttribute("data-revealed")).toBe(true);
950
+ expect(inset.hasAttribute("data-closed")).toBe(false);
951
+ // And the selection never moved (the active option re-selected nothing).
952
+ expect(onSelect).not.toHaveBeenCalled();
953
+ });
954
+
955
+ it("closes a click-revealed supplement when the selection moves", async () => {
956
+ const onSelect = vi.fn();
957
+ const { container, setActive } = mountWithOptions(
958
+ [
959
+ { key: "a", label: "Alpha", actions: [{ key: "dot", label: "Configure alpha", onSelect }] },
960
+ { key: "b", label: "Beta" },
961
+ ],
962
+ { modelValue: "a", variant: "segmented" },
963
+ );
964
+ const inset = container.querySelector<HTMLElement>(".hk-supplement-inset")!;
965
+ const trigger = container.querySelector<HTMLElement>(".hk-tabs-trigger")!;
966
+ trigger.click();
967
+ await nextTick();
968
+ expect(inset.hasAttribute("data-revealed")).toBe(true);
969
+ setActive("b");
970
+ await nextTick();
971
+ await nextTick();
972
+ expect(
973
+ container.querySelector(".hk-supplement-inset")!.hasAttribute("data-revealed"),
974
+ "moving the selection closes the reveal",
975
+ ).toBe(false);
976
+ });
977
+
857
978
  it("renders plain options without a cell (no anatomy change)", () => {
858
979
  const onSelect = vi.fn();
859
980
  const { container } = mountWithOptions([
@@ -1230,91 +1351,19 @@ describe("HkTabs attached trigger actions (2026-11-19)", () => {
1230
1351
  expect(indicator.style.width, "the cell's width").toBe("50px");
1231
1352
  });
1232
1353
 
1233
- it("pins the reveal + overlay grammar in the stylesheet", () => {
1354
+ it("pins the supplement-inset grammar and the absent lane (off-centre fix)", () => {
1234
1355
  const scss = readFileSync(join(here, "HkTabs.scss"), "utf8");
1235
- // Hidden by default; hover/focus-within reveals (pointer-events gate).
1236
- expect(scss).toMatch(/\.hk-tabs-trigger-actions\s*{[^}]*pointer-events:\s*none/);
1237
- expect(scss).toMatch(/\.hk-tabs-cell:hover > \.hk-tabs-trigger-actions/);
1238
- expect(scss).toMatch(/\.hk-tabs-cell:focus-within > \.hk-tabs-trigger-actions/);
1239
- // Overlay: absolute at the inline end, never shifting layout.
1240
- expect(scss).toMatch(/\.hk-tabs-trigger-actions\s*{[^}]*position:\s*absolute/);
1356
+ // THE OFF-CENTRE FIX: no lane reservation on the trigger — at rest the
1357
+ // supplement takes no space and the option's own content stays centred.
1358
+ expect(scss).not.toMatch(/\.hk-tabs-cell > \.hk-tabs-trigger[^}]*padding-inline-end/);
1359
+ // The inset fills the cell; the trigger fills the main region (so the
1360
+ // push shifts its content).
1361
+ expect(scss).toMatch(/\.hk-tabs-cell > \.hk-supplement-inset\s*{[^}]*width:\s*100%/);
1362
+ expect(scss).toMatch(/\.hk-supplement-inset-main > \.hk-tabs-trigger\s*{[^}]*width:\s*100%/);
1241
1363
  // The cell is the slot-unit grid child (the trigger is not).
1242
1364
  expect(scss).toMatch(/\[data-slots\] > \.hk-tabs-cell/);
1243
- // The reserved action lane: without it the revealed buttons sit ON the
1244
- // label's tail in a shrink-to-fit pill (clicks there hit the action,
1245
- // not the option). The lane is list padding (12px) + the overlay's own
1246
- // footprint (20px button; the inset cancels against the trigger's own
1247
- // edge padding) — pin the magnitude so a shrunken calc cannot pass.
1248
- expect(scss).toMatch(
1249
- /\.hk-tabs-cell > \.hk-tabs-trigger\s*{[^}]*padding-inline-end:\s*calc\(var\(--space-12\) \+ 18px\)/,
1250
- );
1251
- // The cell anchors the overlay (positioned ancestor).
1252
- expect(scss).toMatch(/\.hk-tabs-cell\s*{[^}]*position:\s*relative/);
1253
- // Unrevealed actions stay OUT of the page tab order (visibility,
1254
- // not just opacity) or every action leaks a Tab stop per option.
1255
- expect(scss).toMatch(/\.hk-tabs-trigger-actions\s*{[^}]*visibility:\s*hidden/);
1256
- // PAINT ORDER: the trigger carries z-index 1, so the action layer must
1257
- // sit ABOVE it — an auto-z sibling loses hit-testing everywhere the two
1258
- // overlap (the buttons are inside the trigger's box), which makes every
1259
- // ⋯ unclickable while looking fine in a layout-free test.
1260
- expect(scss).toMatch(/\.hk-tabs-trigger-actions\s*{[^}]*z-index:\s*2/);
1261
- expect(scss).toMatch(/\.hk-tabs-trigger\s*{[^}]*z-index:\s*1/);
1262
- // Reduced-motion lands on the reveal too.
1263
- expect(scss).toMatch(/\.hk-tabs-trigger-actions,\s*\n\s*\.hk-tabs-swap-enter-active/);
1264
- });
1265
- });
1266
-
1267
- describe("HkTabs per-option context menu (2026-11-19)", () => {
1268
- it("opens the bound menu on right-click through the app-wide provider", async () => {
1269
- const onPick = vi.fn();
1270
- const container = document.createElement("div");
1271
- document.body.appendChild(container);
1272
- containers.push(container);
1273
- const Wrapper = defineComponent({
1274
- setup() {
1275
- return () =>
1276
- h(HkContextMenuProvider, null, {
1277
- default: () =>
1278
- h(HkTabs, {
1279
- modelValue: "a",
1280
- renderPanels: false,
1281
- tabs: [
1282
- {
1283
- key: "a",
1284
- label: "Alpha",
1285
- contextMenu: (point: { x: number; y: number }) => ({
1286
- x: point.x,
1287
- y: point.y,
1288
- title: "Alpha menu",
1289
- items: [{ key: "cfg", label: "Configure alpha" }],
1290
- onSelect: onPick,
1291
- }),
1292
- },
1293
- { key: "b", label: "Beta" },
1294
- ] as TabItem[],
1295
- }),
1296
- });
1297
- },
1298
- });
1299
- const app = createApp(Wrapper);
1300
- mounts.push(app);
1301
- app.mount(container);
1302
- await nextTick();
1303
- const trigger = container.querySelectorAll<HTMLElement>(".hk-tabs-trigger")[0]!;
1304
- trigger.dispatchEvent(new MouseEvent("contextmenu", { bubbles: true, cancelable: true, clientX: 12, clientY: 12 }));
1305
- await nextTick();
1306
- expect(document.querySelector(".hk-select-popout")).toBeTruthy();
1307
- const row = Array.from(document.querySelectorAll<HTMLButtonElement>(".hk-menu-row"))
1308
- .find((r) => r.textContent?.includes("Configure alpha"));
1309
- expect(row).toBeTruthy();
1310
- row!.click();
1311
- await nextTick();
1312
- expect(onPick).toHaveBeenCalledTimes(1);
1313
- // The binding preventDefaults — the platform menu is gone on re-click too.
1314
- const event = new MouseEvent("contextmenu", { bubbles: true, cancelable: true, clientX: 12, clientY: 12 });
1315
- trigger.dispatchEvent(event);
1316
- await nextTick();
1317
- expect(event.defaultPrevented).toBe(true);
1365
+ // The cell anchors nothing anymore — the overlay grammar is gone.
1366
+ expect(scss).not.toContain("hk-tabs-trigger-actions");
1318
1367
  });
1319
1368
 
1320
1369
  it("serves the CURRENT option closure after a rebuilt option list", async () => {