@celestia-island/hikari 0.55.526 → 0.55.528

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.
Files changed (41) hide show
  1. package/dist/types/components/HkAdminHeader.d.ts +31 -10
  2. package/dist/types/components/HkAlert.d.ts +35 -0
  3. package/dist/types/components/HkFaceShell.d.ts +16 -0
  4. package/dist/types/components/HkMenu.d.ts +15 -0
  5. package/dist/types/composables/usePageCreateAction.d.ts +42 -0
  6. package/dist/types/composables/usePageRefresh.d.ts +37 -0
  7. package/dist/types/composables/usePageSearch.d.ts +55 -0
  8. package/dist/types/index.d.ts +7 -1
  9. package/package.json +1 -1
  10. package/src/components/HkAdminHeader.test.tsx +142 -9
  11. package/src/components/HkAdminHeader.tsx +56 -11
  12. package/src/components/HkAdminHeader.userMenuItems.test.tsx +205 -0
  13. package/src/components/HkAdminShell.centre.test.tsx +12 -10
  14. package/src/components/HkAlert.role.test.tsx +17 -0
  15. package/src/components/HkAlert.tsx +22 -4
  16. package/src/components/HkAuthHandoff.test.tsx +10 -0
  17. package/src/components/HkAuthHandoff.tsx +6 -4
  18. package/src/components/HkFaceShell.slots.test.ts +65 -1
  19. package/src/components/HkFaceShell.tsx +16 -0
  20. package/src/components/HkMenu.test.ts +192 -2
  21. package/src/components/HkMenu.tsx +32 -0
  22. package/src/composables/usePageActions.barrel.test.ts +38 -0
  23. package/src/composables/usePageCreateAction.test.ts +309 -0
  24. package/src/composables/usePageCreateAction.ts +81 -0
  25. package/src/composables/usePageRefresh.test.ts +241 -0
  26. package/src/composables/usePageRefresh.ts +74 -0
  27. package/src/composables/usePageSearch.test.ts +345 -0
  28. package/src/composables/usePageSearch.ts +87 -0
  29. package/src/errorLandingStandalone/error-landing.html +1 -1
  30. package/src/i18n/locales/ar/components.json +2 -1
  31. package/src/i18n/locales/de/components.json +2 -1
  32. package/src/i18n/locales/en/components.json +2 -1
  33. package/src/i18n/locales/es/components.json +2 -1
  34. package/src/i18n/locales/fr/components.json +2 -1
  35. package/src/i18n/locales/ja/components.json +2 -1
  36. package/src/i18n/locales/ko/components.json +2 -1
  37. package/src/i18n/locales/pt/components.json +2 -1
  38. package/src/i18n/locales/ru/components.json +2 -1
  39. package/src/i18n/locales/zh-Hans/components.json +2 -1
  40. package/src/i18n/locales/zh-Hant/components.json +2 -1
  41. package/src/index.ts +10 -1
@@ -35,6 +35,21 @@ export interface HkAdminHeaderUserMenuExtraSlot {
35
35
  close?: () => void;
36
36
  }
37
37
 
38
+ /**
39
+ * Scoped payload of the `user-menu-items` slot — host-owned account rows
40
+ * the header seats IMMEDIATELY ABOVE the logout row, inside the dropdown's
41
+ * row run (no divider): account actions belong ahead of the destructive
42
+ * exit. `user-menu-extra` is the TAIL band BELOW logout — a change-password
43
+ * entry passed there reads as an afterthought under "Log out", which is
44
+ * where it sat while the tail was the only host carrier. Same payload shape
45
+ * as `user-menu-extra`: `close` dismisses the dropdown so a navigating entry
46
+ * leaves no orphaned menu behind. Both slots may be supplied at once and
47
+ * each keeps its own position.
48
+ */
49
+ export interface HkAdminHeaderUserMenuItemsSlot {
50
+ close?: () => void;
51
+ }
52
+
38
53
  /**
39
54
  * Scoped payload of the `locale-picker` slot — the host-owned locale
40
55
  * popup. When the slot is supplied, the menu's Language row becomes a
@@ -59,8 +74,9 @@ export interface HkAdminHeaderLocalePickerSlot {
59
74
  * static site logo in place of the avatar identity trigger. The mark
60
75
  * is an identity, not a control: no href, no button semantics. On that
61
76
  * face the account machinery does not mount at all (ZERO ACCOUNT
62
- * SURFACE): `identity`, `user-menu-extra`, `avatar-modal` and
63
- * `locale-picker` have no carrier — they all live inside the dropdown.
77
+ * SURFACE): `identity`, `user-menu-extra`, `user-menu-items`,
78
+ * `avatar-modal` and `locale-picker` have no carrier — they all live
79
+ * inside the dropdown.
64
80
  * The drawer face never renders the mark — the avatar trigger is the
65
81
  * drawer's only opener there, and the drawer path stays untouched.
66
82
  * The host that swaps the identity trigger away mounts its own account
@@ -71,6 +87,11 @@ export interface HkAdminHeaderLocalePickerSlot {
71
87
  * `locale-picker` (host locale popup replacing the built-in cascade) were
72
88
  * consumed as of the L39 ruling-a revival (2026-11-20): the erp bodies
73
89
  * that had sat invisible since 0.55.241 now render.
90
+ *
91
+ * `user-menu-items` (host account rows seated directly above the logout
92
+ * row, through HkMenu's `before-item` splice) is the position that slot
93
+ * could never offer — the tail is below logout. It coexists with
94
+ * `user-menu-extra`; each keeps its own position.
74
95
  */
75
96
  export type HkAdminHeaderSlots = SlotsType<{
76
97
  brand?: () => VNode[];
@@ -80,6 +101,7 @@ export type HkAdminHeaderSlots = SlotsType<{
80
101
  "theme-toggle"?: () => VNode[];
81
102
  "avatar-modal"?: (params: HkAdminHeaderAvatarModalSlot) => VNode[];
82
103
  "user-menu-extra"?: (params: HkAdminHeaderUserMenuExtraSlot) => VNode[];
104
+ "user-menu-items"?: (params: HkAdminHeaderUserMenuItemsSlot) => VNode[];
83
105
  "locale-picker"?: (params: HkAdminHeaderLocalePickerSlot) => VNode[];
84
106
  }>;
85
107
 
@@ -169,10 +191,10 @@ export const HkAdminHeader = defineComponent({
169
191
  * Contract, four clauses:
170
192
  * - ZERO ACCOUNT SURFACE: the branded desktop face renders no
171
193
  * account machinery at all — the avatar trigger does not render,
172
- * and the `identity` / `user-menu-extra` / `avatar-modal` /
173
- * `locale-picker` slots have NO carrier on this face (they all
174
- * live inside the dropdown, which is not mounted). A host that
175
- * needs an account face either does not opt into the brand
194
+ * and the `identity` / `user-menu-extra` / `user-menu-items` /
195
+ * `avatar-modal` / `locale-picker` slots have NO carrier on this
196
+ * face (they all live inside the dropdown, which is not mounted).
197
+ * A host that needs an account face either does not opt into the brand
176
198
  * (its consumers keep today's header) or mounts its own entries
177
199
  * in the actions wing — the house shape is a ghost HkIconButton
178
200
  * sized on the page-chrome action ladder, NOT a second
@@ -250,9 +272,10 @@ export const HkAdminHeader = defineComponent({
250
272
  const brandMounted = computed(() => !!(slots.brand || props.brandSrc));
251
273
  // The branded DESKTOP face carries ZERO account machinery: the mark
252
274
  // replaces the trigger, so the dropdown (and every slot that lives
253
- // inside it — identity, user-menu-extra, avatar-modal, locale-picker)
254
- // has no carrier and does not mount at all. On every other face this
255
- // is false and the header renders exactly as it always did.
275
+ // inside it — identity, user-menu-extra, user-menu-items,
276
+ // avatar-modal, locale-picker) has no carrier and does not mount at
277
+ // all. On every other face this is false and the header renders
278
+ // exactly as it always did.
256
279
  const brandedMenuFace = computed(
257
280
  () => brandMounted.value && props.avatarAction === "menu",
258
281
  );
@@ -465,8 +488,9 @@ export const HkAdminHeader = defineComponent({
465
488
  </div>
466
489
 
467
490
  {/* The account dropdown: NOT mounted on the branded desktop face
468
- * (zero account surface — identity / user-menu-extra have no
469
- * carrier there); every other face mounts it exactly as before.
491
+ * (zero account surface — identity / user-menu-extra /
492
+ * user-menu-items have no carrier there); every other face
493
+ * mounts it exactly as before.
470
494
  * In chrome mode it is a caption-band attachment — the header IS
471
495
  * the window titlebar there, so the panel must paint ABOVE it
472
496
  * (aboveChrome): the same exception the chat face's HeaderLeft
@@ -549,6 +573,27 @@ export const HkAdminHeader = defineComponent({
549
573
  slots["user-menu-extra"]?.({
550
574
  close: () => { userMenuOpen.value = false; },
551
575
  }) ?? [],
576
+ /* Host-owned account rows, seated IMMEDIATELY above the
577
+ * logout row. HkMenu's `before-item` hook fires right before
578
+ * each root row; the `key === "logout"` guard narrows it to
579
+ * that one splice point, so the rows join the row run bare —
580
+ * no wrapper, no divider, DOM order = Tab order = visual
581
+ * order (the host rows are native buttons). The menu's
582
+ * pending-identity shape has no logout row and so no splice
583
+ * point either: host account rows wait for an identity like
584
+ * every built-in action row. Forwarded only while the host
585
+ * supplies the slot — a header without it hands the menu the
586
+ * exact slot set it always did. */
587
+ ...(slots["user-menu-items"]
588
+ ? {
589
+ "before-item": ({ key }: { key: string }): VNode[] =>
590
+ key === "logout"
591
+ ? slots["user-menu-items"]?.({
592
+ close: () => { userMenuOpen.value = false; },
593
+ }) ?? []
594
+ : [],
595
+ }
596
+ : {}),
552
597
  }}
553
598
  </HkMenu>
554
599
  )}
@@ -0,0 +1,205 @@
1
+ // AI-generated: developed with the DeepSeek Harness agent (model GLM-5.4),
2
+ // directed and reviewed by the lead agent — SySL-1.0 §2.3 disclosure.
3
+
4
+ import { afterEach, describe, expect, it } from "vitest";
5
+ import { createApp, h, nextTick } from "vue";
6
+ import type { HkAdminHeaderUserMenuItemsSlot } from "../index";
7
+ import { HkAdminHeader } from "./HkAdminHeader";
8
+
9
+ /**
10
+ * END-TO-END pin for `user-menu-items`: the REAL HkAdminHeader over the
11
+ * REAL HkMenu. (HkAdminHeader.test.tsx stubs the menu, which proves the
12
+ * header's splice wiring but not the DOM a host's users get.) The
13
+ * contract sentence is pinned here as rendered: inside
14
+ * `.hk-menu-level[role="menu"]` the host rows are the logout row's
15
+ * immediate predecessors — no wrapper, no divider — and the
16
+ * `user-menu-extra` tail follows logout.
17
+ *
18
+ * (Repo test convention: raw createApp + container queries, no
19
+ * @vue/test-utils dependency.)
20
+ */
21
+
22
+ const LOCALES = [
23
+ { code: "en", label: "English" },
24
+ { code: "zh-Hans", label: "简体中文" },
25
+ ];
26
+
27
+ /** The order pinned on both form factors: identity band → built-in rows
28
+ * above logout → host rows → logout → the extra tail. */
29
+ const SPLICED_ORDER = [
30
+ "band:head",
31
+ "row:Avatar",
32
+ "row:Language",
33
+ "row:Account",
34
+ "host:Change password",
35
+ "host:Account center",
36
+ "row:Log out",
37
+ "band:foot[Host extra]",
38
+ ];
39
+
40
+ const mounts: Array<{ app: ReturnType<typeof createApp>; container: HTMLElement }> = [];
41
+
42
+ /** A host row written the way a host writes one for this slot: a native
43
+ * button in the menu-row grammar, so it inherits the row geometry of the
44
+ * built-in rows it sits between. */
45
+ function hostRow(
46
+ key: string,
47
+ label: string,
48
+ close: (() => void) | undefined,
49
+ ): ReturnType<typeof h> {
50
+ return h(
51
+ "button",
52
+ { type: "button", class: "hk-menu-row", "data-host": key, onClick: () => close?.() },
53
+ [h("span", { class: "hk-menu-label" }, label)],
54
+ );
55
+ }
56
+
57
+ /** Both host slots at once — the coexistence the order pin needs. */
58
+ const BOTH_SLOTS = (): Record<string, unknown> => ({
59
+ "user-menu-items": ({ close }: HkAdminHeaderUserMenuItemsSlot) => [
60
+ hostRow("change-password", "Change password", close),
61
+ hostRow("account-center", "Account center", close),
62
+ ],
63
+ "user-menu-extra": () =>
64
+ h("button", { type: "button", class: "hk-menu-row", "data-extra": "" }, [
65
+ h("span", { class: "hk-menu-label" }, "Host extra"),
66
+ ]),
67
+ });
68
+
69
+ /** Mount a signed-in header carrying the full row set (avatar, language,
70
+ * frontend link, logout) plus the given slots. */
71
+ function mountHeader(slots: Record<string, unknown> = {}) {
72
+ const container = document.createElement("div");
73
+ document.body.appendChild(container);
74
+ const app = createApp({
75
+ render: () =>
76
+ h(
77
+ HkAdminHeader,
78
+ {
79
+ username: "ada",
80
+ userEmail: "ada@example.test",
81
+ localeOptions: LOCALES,
82
+ goToFrontendLabel: "Account",
83
+ logoutLabel: "Log out",
84
+ } as never,
85
+ slots as never,
86
+ ),
87
+ });
88
+ app.mount(container);
89
+ mounts.push({ app, container });
90
+ return container;
91
+ }
92
+
93
+ const avatarButton = (c: HTMLElement) =>
94
+ c.querySelector('button[aria-haspopup]') as HTMLButtonElement | null;
95
+
96
+ const popouts = () => Array.from(document.querySelectorAll(".hk-select-popout")) as HTMLElement[];
97
+ const sheets = () => Array.from(document.querySelectorAll(".hk-select-sheet-panel")) as HTMLElement[];
98
+
99
+ /** The ROOT level of the open dropdown (desktop popout or mobile sheet). */
100
+ function rootLevel(): HTMLElement {
101
+ const surface = popouts()[0] ?? sheets()[0];
102
+ const level = surface?.querySelector('.hk-menu-level[role="menu"]');
103
+ if (!(level instanceof HTMLElement)) throw new Error("the dropdown's root level must be mounted");
104
+ return level;
105
+ }
106
+
107
+ /** One entry per child element of the level, in DOM order: `row:<label>`
108
+ * for a built-in row, `host:<text>` for a host row, `band:…` for the
109
+ * identity head and the extra's foot. */
110
+ function levelOrder(level: HTMLElement): string[] {
111
+ return Array.from(level.children).map((el) => {
112
+ if (el.classList.contains("hk-menu-slot")) {
113
+ return el.classList.contains("hk-menu-slot--foot")
114
+ ? `band:foot[${el.textContent?.trim()}]`
115
+ : "band:head";
116
+ }
117
+ return el.hasAttribute("data-host") ? `host:${el.textContent?.trim()}` : `row:${el.textContent?.trim()}`;
118
+ });
119
+ }
120
+
121
+ async function click(el: Element | null) {
122
+ el?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
123
+ await nextTick();
124
+ await new Promise((resolve) => setTimeout(resolve, 0));
125
+ await nextTick();
126
+ }
127
+
128
+ afterEach(async () => {
129
+ for (const { app, container } of mounts.splice(0)) {
130
+ app.unmount();
131
+ container.remove();
132
+ }
133
+ // Unmounting restores the panel's back-guard history asynchronously;
134
+ // de-mark the entry in place so the restore is a no-op.
135
+ window.history.replaceState(null, "");
136
+ await new Promise((resolve) => setTimeout(resolve, 0));
137
+ // happy-dom never fires transitionend, so a leaving panel lingers on
138
+ // <body> — strip it or the next test's queries see this test's panel.
139
+ document.body
140
+ .querySelectorAll(".hk-select-popout, .hk-select-sheet-panel, .hk-select-sheet-scrim")
141
+ .forEach((el) => el.remove());
142
+ window.innerWidth = 1024;
143
+ });
144
+
145
+ describe("HkAdminHeader user-menu-items (real menu, end to end)", () => {
146
+ it("seats the host rows as the logout row's immediate predecessors", async () => {
147
+ // MUT:M1 MUT:M2 MUT:M4 MUT:M11: DOM order = Tab order = visual order —
148
+ // every row is a native button, the host rows sit between the frontend
149
+ // row and logout, and the extra tail follows logout.
150
+ const c = mountHeader(BOTH_SLOTS());
151
+ await click(avatarButton(c));
152
+ const level = rootLevel();
153
+ expect(levelOrder(level)).toEqual(SPLICED_ORDER);
154
+
155
+ // BARE splice: the logout row's previous sibling IS the last host row —
156
+ // no wrapper, no divider between them.
157
+ const logout = level.querySelector(".hk-menu-row[data-danger]")!;
158
+ expect(logout.previousElementSibling).toBe(level.querySelector('[data-host="account-center"]'));
159
+ expect(level.querySelector("hr, .hk-menu-divider")).toBeNull();
160
+ // The level's only bands are the identity head and the extra's foot;
161
+ // each of the six rows between them is a native button in the shared
162
+ // menu-row grammar (DOM order = Tab order; a host row written in that
163
+ // grammar inherits the built-in rows' geometry).
164
+ const bands = Array.from(level.querySelectorAll(":scope > .hk-menu-slot")).map((el) => el.className);
165
+ expect(bands).toEqual(["hk-menu-slot hk-menu-slot--head", "hk-menu-slot hk-menu-slot--foot"]);
166
+ const between = Array.from(level.children).slice(1, -1);
167
+ expect(between.map((el) => `${el.tagName}.${el.className}`)).toEqual(
168
+ Array(6).fill("BUTTON.hk-menu-row"),
169
+ );
170
+
171
+ // MUT:M3: close() from the payload dismisses the REAL dropdown — the
172
+ // trigger collapses and the popout leaves.
173
+ (level.querySelector('[data-host="change-password"]') as HTMLButtonElement).click();
174
+ await nextTick();
175
+ expect(avatarButton(c)!.getAttribute("aria-expanded")).toBe("false");
176
+ });
177
+
178
+ it("keeps the same order in the mobile root sheet", async () => {
179
+ // MUT:M1 MUT:M4 MUT:M7 MUT:M11: the same flips as the desktop pin.
180
+ window.innerWidth = 390;
181
+ const c = mountHeader(BOTH_SLOTS());
182
+ await click(avatarButton(c));
183
+ expect(popouts()).toHaveLength(0);
184
+ expect(levelOrder(rootLevel())).toEqual(SPLICED_ORDER);
185
+ });
186
+
187
+ it("renders the exact previous level when neither host slot is supplied", async () => {
188
+ // NEGATIVE CONTROL (chest-shaped hosts): identity band, the four
189
+ // built-in rows, nothing else — no host node, no band beyond the head.
190
+ // MUT:M6 MUT:M12: a wrapper on the menu's no-slot path, or a stray node
191
+ // forwarded by a header without the slot, lands in this list.
192
+ const c = mountHeader();
193
+ await click(avatarButton(c));
194
+ const level = rootLevel();
195
+ expect(levelOrder(level)).toEqual([
196
+ "band:head",
197
+ "row:Avatar",
198
+ "row:Language",
199
+ "row:Account",
200
+ "row:Log out",
201
+ ]);
202
+ expect(level.querySelector("[data-host], [data-extra]")).toBeNull();
203
+ expect(level.querySelectorAll(":scope > .hk-menu-slot")).toHaveLength(1);
204
+ });
205
+ });
@@ -1,5 +1,5 @@
1
1
  import { afterEach, describe, expect, it } from "vitest";
2
- import { createApp, defineComponent, h, nextTick, ref, type VNode } from "vue";
2
+ import { createApp, defineComponent, h, nextTick, ref } from "vue";
3
3
 
4
4
  import { HkAdminShell } from "./HkAdminShell";
5
5
  import { HkAdminHeader } from "./HkAdminHeader";
@@ -60,9 +60,11 @@ afterEach(() => {
60
60
  setWidth(1280);
61
61
  });
62
62
 
63
- /** The payload HkAdminShell hands its header slot: the shell's own params
64
- * plus the `actions` flat list it injects. */
65
- type ShellHeaderParams = HkFaceShellHeaderSlot & { actions: VNode[] };
63
+ // The payload HkAdminShell hands its header slot is the EXPORTED
64
+ // `HkFaceShellHeaderSlot`, `actions` included. That member is optional on
65
+ // the type because a bare face shell leaves it absent (HkFaceShell.test.tsx
66
+ // pins both presences); under the admin shell each render carries it, so
67
+ // the relays below read `actions ?? []`.
66
68
 
67
69
  describe("HkAdminShell — the header centre channel", () => {
68
70
  it("delivers the page's centre group to the header slot and clears it on unmount", async () => {
@@ -83,10 +85,10 @@ describe("HkAdminShell — the header centre channel", () => {
83
85
  h(HkAdminShell, {}, {
84
86
  // The host shape this contract exists for: hand the shell-provided
85
87
  // renderer straight to HkAdminHeader's own `center` slot.
86
- header: (params: ShellHeaderParams) =>
88
+ header: (params: HkFaceShellHeaderSlot) =>
87
89
  h(
88
90
  HkAdminHeader,
89
- { title: "Page", actions: params.actions },
91
+ { title: "Page", actions: params.actions ?? [] },
90
92
  params.center ? { center: params.center } : {},
91
93
  ),
92
94
  content: () =>
@@ -117,10 +119,10 @@ describe("HkAdminShell — the header centre channel", () => {
117
119
  // (The ABSENT case belongs to HkFaceShell with no bar above it:
118
120
  // pinned in HkFaceShell.test.tsx.)
119
121
  setWidth(1024);
120
- const seen: ShellHeaderParams[] = [];
122
+ const seen: HkFaceShellHeaderSlot[] = [];
121
123
  const c = mount(
122
124
  h(HkAdminShell, {}, {
123
- header: (params: ShellHeaderParams) => {
125
+ header: (params: HkFaceShellHeaderSlot) => {
124
126
  seen.push(params);
125
127
  return null;
126
128
  },
@@ -150,10 +152,10 @@ describe("HkAdminShell — the header centre channel", () => {
150
152
  const title = ref("Page");
151
153
  const c = mount(
152
154
  h(HkAdminShell, {}, {
153
- header: (params: ShellHeaderParams) =>
155
+ header: (params: HkFaceShellHeaderSlot) =>
154
156
  h(
155
157
  HkAdminHeader,
156
- { title: title.value, actions: params.actions },
158
+ { title: title.value, actions: params.actions ?? [] },
157
159
  params.center ? { center: params.center } : {},
158
160
  ),
159
161
  content: () => h(Page),
@@ -100,4 +100,21 @@ describe("HkAlert live-region role", () => {
100
100
  expect(el.querySelector("button.hk-alert-close")).toBeTruthy();
101
101
  expect(el.querySelectorAll("[role]").length).toBe(0);
102
102
  });
103
+
104
+ it("ownsLiveRegion={false} drops the region entirely, keeping the visuals", () => {
105
+ // For an alert rendered INSIDE a container that already owns the live
106
+ // region (HkAuthHandoff's failed card declares `role="alert"` on its
107
+ // own div and flips in place on a status change): nesting a second
108
+ // assertive region makes that flip announce twice (2026-12-02 review).
109
+ // MUT:alert-ownsliveregion-ignored — hard-coding the variant split back in
110
+ // reddens this: the caller's container must be the ONE region.
111
+ for (const variant of ["error", "warning", "info", "success"] as const) {
112
+ const el = mountAlert({ variant, ownsLiveRegion: false });
113
+ expect(el.getAttribute("role")).toBeNull();
114
+ expect(el.getAttribute("aria-live")).toBeNull();
115
+ // The visual surface is untouched: icon + message still render.
116
+ expect(el.querySelector(".hk-alert-icon")).toBeTruthy();
117
+ expect(el.textContent).toContain("mind the gap");
118
+ }
119
+ });
103
120
  });
@@ -29,6 +29,20 @@ export default defineComponent({
29
29
  /** Shared container-padding override (see runtime/containerPad) —
30
30
  * unset keeps the size's own padding. */
31
31
  padding: { type: String as PropType<HkPad>, default: undefined },
32
+ /** Drop this alert's OWN live region (`role` / `aria-live` stay off
33
+ * the root) while keeping the visuals. For an alert rendered INSIDE
34
+ * a container that already owns the live region — e.g. HkAuthHandoff's
35
+ * failed card, which carries `role="alert"` itself and flips in place
36
+ * on a status change. Nesting a second assertive region there makes a
37
+ * flip announce twice (2026-12-02 review, S2). Default true: the
38
+ * standalone alert keeps its semantics, which every other consumer
39
+ * relies on.
40
+ *
41
+ * The name is `ownsLiveRegion`, NOT `ariaLive`: a camelCase prop
42
+ * lowercases to `arialive`, which CONSUMES the fallthrough
43
+ * `aria-live` attribute — a host's `aria-live="off"` would become an
44
+ * interruption instead of a silence request. */
45
+ ownsLiveRegion: { type: Boolean, default: true },
32
46
  },
33
47
  emits: {
34
48
  close: () => true,
@@ -56,11 +70,15 @@ export default defineComponent({
56
70
  // in-repo consumers mount the alert conditionally (HkSectionCard
57
71
  // error state, HkMfaVerifyCard retry hint). The role rides the
58
72
  // ROOT so the whole alert body is one announced region.
59
- const a11y = computed(() =>
60
- props.variant === "error" || props.variant === "warning"
73
+ //
74
+ // `ownsLiveRegion={false}` opts OUT of all of it — the caller's surrounding
75
+ // element is already the one region (HkAuthHandoff's failed card).
76
+ const a11y = computed(() => {
77
+ if (!props.ownsLiveRegion) return { role: undefined, "aria-live": undefined } as const;
78
+ return props.variant === "error" || props.variant === "warning"
61
79
  ? ({ role: "alert", "aria-live": "assertive" } as const)
62
- : ({ role: "status", "aria-live": "polite" } as const),
63
- );
80
+ : ({ role: "status", "aria-live": "polite" } as const);
81
+ });
64
82
 
65
83
  function onClose() {
66
84
  isDismissed.value = true;
@@ -108,6 +108,16 @@ describe("HkAuthHandoff", () => {
108
108
  expect(titled.querySelector(".hk-auth-handoff-state .hk-badge")?.textContent).toContain("Signed in");
109
109
  });
110
110
 
111
+ it("the failed description's alert does NOT own a second live region", () => {
112
+ // The card's own div declares role="alert" (#1682, mutation-pinned);
113
+ // the nested HkAlert must opt out (ownsLiveRegion={false}) or a
114
+ // status flip announces twice.
115
+ const c = mount(
116
+ h(HkAuthHandoff, { status: "failed", description: "Use another account" }),
117
+ );
118
+ expect(c.querySelectorAll("[role='alert']").length).toBe(1);
119
+ });
120
+
111
121
  it("a failed handoff's body carries the actions and NO stray text", () => {
112
122
  // MUT:handoff-leaked-jsx-comment — a bare `//` comment inside the JSX
113
123
  // children rendered VERBATIM on every non-transient handoff screen
@@ -182,10 +182,12 @@ export const HkAuthHandoff = defineComponent({
182
182
  {description ? (
183
183
  failed ? (
184
184
  // A failed/expired handoff is an ERROR surface: the
185
- // description rides the family's icon-led alert
186
- // (role="alert" below is the semantics; this is the
187
- // matching visuals).
188
- <HkAlert variant="error" message={description} />
185
+ // description rides the family's icon-led alert. The
186
+ // OUTER div already owns the live region
187
+ // (`role="alert"`), so the alert renders VISUALS only
188
+ // — a second assertive region here would announce a
189
+ // status flip twice (2026-12-02 review, S2).
190
+ <HkAlert variant="error" message={description} ownsLiveRegion={false} />
189
191
  ) : (
190
192
  <p class="s-auth-subtitle hk-auth-handoff-description">{description}</p>
191
193
  )
@@ -1,7 +1,8 @@
1
1
  import { describe, expect, it } from "vitest";
2
+ import { h } from "vue";
2
3
  import * as barrel from "../index";
3
4
  import { asIndexable } from "../utils/typing";
4
- import type { HkAdminHeaderAvatarModalSlot, HkAdminHeaderLocalePickerSlot, HkAdminHeaderSlots, HkAdminHeaderUserMenuExtraSlot, HkFaceShellHeaderSlot, HkFaceShellSidebarSlot, HkFaceShellSlots, HkFaceShellUserPanelSlot } from "../index";
5
+ import type { HkAdminHeaderAvatarModalSlot, HkAdminHeaderLocalePickerSlot, HkAdminHeaderSlots, HkAdminHeaderUserMenuExtraSlot, HkAdminHeaderUserMenuItemsSlot, HkFaceShellHeaderSlot, HkFaceShellSidebarSlot, HkFaceShellSlots, HkFaceShellUserPanelSlot } from "../index";
5
6
 
6
7
  /**
7
8
  * The L39 slot-type contract pins. The exported slot types are what chest and
@@ -62,6 +63,23 @@ function userMenuExtraBody(params: HkAdminHeaderUserMenuExtraSlot) {
62
63
  return { close };
63
64
  }
64
65
 
66
+ /** erp AdminLayout shape: relay the page's registered actions into the
67
+ * header. HkAdminShell injects the member; a bare HkFaceShell leaves it
68
+ * absent, so the relay falls back to an empty list. */
69
+ function headerActionsRelay(params: HkFaceShellHeaderSlot) {
70
+ const { actions } = params;
71
+ return actions ?? [];
72
+ }
73
+
74
+ /** erp AdminLayout shape: the user-menu-items destructure (the same
75
+ * single member as the tail slot; the change-password row calls it before
76
+ * opening its dialog). */
77
+ function userMenuItemsBody(params: HkAdminHeaderUserMenuItemsSlot) {
78
+ const { close } = params;
79
+ close?.();
80
+ return { close };
81
+ }
82
+
65
83
  describe("the public slot-type contract (L39)", () => {
66
84
  it("exports every slot type name from the barrel", () => {
67
85
  // Types are erased at runtime; the pin is the module-record presence of
@@ -107,6 +125,52 @@ describe("the public slot-type contract (L39)", () => {
107
125
  const extra = userMenuExtraBody({ close: () => { closed = true; } });
108
126
  extra.close?.();
109
127
  expect(closed).toBe(true);
128
+ // The right cluster rides the same payload: HkAdminShell hands the
129
+ // page's registered actions as a flat VNode list, and the relay below
130
+ // is the erp AdminLayout shape (destructure, then hand the list on).
131
+ // Removing the `actions` member from the payload type goes red on THIS
132
+ // file's vue-tsc (TS2339 at the destructure). MUT:actions-field-removed
133
+ const base = { isDesktop: true, showHamburger: false, compact: false, onHamburger: () => {}, onOpenDrawer: () => {} };
134
+ const pageAction = h("button", { class: "page-action" }, "refresh");
135
+ expect(headerActionsRelay({ ...base, actions: [pageAction] })).toEqual([pageAction]);
136
+ // A bare face shell's payload: the member is absent and the relay
137
+ // degrades to an empty list.
138
+ expect(headerActionsRelay(base)).toEqual([]);
139
+ // The rows-above-logout slot carries the same payload — `close` is
140
+ // its only member too, and a payload without it is still accepted.
141
+ // comment-gate-ok: a runtime smoke of the destructure only — the
142
+ // contract gate for this slot is vue-tsc (MUT:M10).
143
+ let itemsClosed = false;
144
+ const items = userMenuItemsBody({ close: () => { itemsClosed = true; } });
145
+ items.close?.();
146
+ expect(itemsClosed).toBe(true);
147
+ expect(userMenuItemsBody({})).toEqual({ close: undefined });
148
+ });
149
+
150
+ it("user-menu-items is an optional header slot with the close-only payload", () => {
151
+ // The compile-time legs bite through the COMPONENT's unwrapped slots
152
+ // type (the aggregate alias is a symbol-keyed container — see the
153
+ // brand-slot pin above); vue-tsc --noEmit on THIS file is the gate.
154
+ // MUT:M10 — all three legs go red when the barrel export, the slot
155
+ // declaration or the payload shape changes:
156
+ // - MEMBERSHIP: `HeaderSlots["user-menu-items"]` resolves only while
157
+ // the slot stays declared on HkAdminHeaderSlots.
158
+ // - OPTIONAL: `undefined extends …` holds only while the slot keeps
159
+ // its undefined member.
160
+ // - PAYLOAD: the parameter type must accept `{ close }` and `{}`, and
161
+ // stay the tail slot's shape.
162
+ type HeaderSlots = InstanceType<typeof barrel.HkAdminHeader>["$slots"];
163
+ type ItemsPayload = Parameters<NonNullable<HeaderSlots["user-menu-items"]>>[0];
164
+ const itemsStaysOptional: undefined extends HeaderSlots["user-menu-items"] ? true : never = true;
165
+ expect(itemsStaysOptional).toBe(true);
166
+ const payloadAcceptsClose: ItemsPayload = { close: () => {} };
167
+ const payloadRequiresNothing: ItemsPayload = {};
168
+ const sameShapeAsTheTail: ItemsPayload = { close: () => {} } satisfies HkAdminHeaderUserMenuExtraSlot;
169
+ expect([
170
+ typeof payloadAcceptsClose.close,
171
+ payloadRequiresNothing.close,
172
+ typeof sameShapeAsTheTail.close,
173
+ ]).toEqual(["function", undefined, "function"]);
110
174
  });
111
175
 
112
176
  it("the aggregate slot types fit a defineComponent slots declaration", () => {
@@ -198,6 +198,22 @@ export interface HkFaceShellHeaderSlot {
198
198
  * (or drops) its centre group repaints the header that renders it.
199
199
  */
200
200
  center?: () => VNode[];
201
+ /**
202
+ * The RIGHT cluster — the page action bar: the VNodes of every action the
203
+ * mounted pages registered (`useActionBar().setActions`), already in slot
204
+ * order, for the header to render as its top-right group. `HkAdminHeader`
205
+ * takes this list verbatim as its `actions` prop.
206
+ *
207
+ * Supplied by the shell that PROVIDES the bar — `HkAdminShell`, which
208
+ * owns one and re-reads it on each of its own renders, so a page's
209
+ * registration repaints the header that shows it. A bare `HkFaceShell`
210
+ * provides no bar and leaves the field ABSENT: a face whose host owns its
211
+ * chrome reads its own bar instead. A consumer therefore relays it as
212
+ * `actions ?? []`, and the optionality is the type-level mirror of the
213
+ * runtime pins in HkFaceShell.test.tsx ("actions" present under
214
+ * HkAdminShell, absent under HkFaceShell).
215
+ */
216
+ actions?: VNode[];
201
217
  }
202
218
 
203
219
  /**