@celestia-island/hikari 0.55.527 → 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 (36) hide show
  1. package/dist/types/components/HkAdminHeader.d.ts +31 -10
  2. package/dist/types/components/HkFaceShell.d.ts +16 -0
  3. package/dist/types/components/HkMenu.d.ts +15 -0
  4. package/dist/types/composables/usePageCreateAction.d.ts +42 -0
  5. package/dist/types/composables/usePageRefresh.d.ts +37 -0
  6. package/dist/types/composables/usePageSearch.d.ts +55 -0
  7. package/dist/types/index.d.ts +7 -1
  8. package/package.json +1 -1
  9. package/src/components/HkAdminHeader.test.tsx +142 -9
  10. package/src/components/HkAdminHeader.tsx +56 -11
  11. package/src/components/HkAdminHeader.userMenuItems.test.tsx +205 -0
  12. package/src/components/HkAdminShell.centre.test.tsx +12 -10
  13. package/src/components/HkFaceShell.slots.test.ts +65 -1
  14. package/src/components/HkFaceShell.tsx +16 -0
  15. package/src/components/HkMenu.test.ts +192 -2
  16. package/src/components/HkMenu.tsx +32 -0
  17. package/src/composables/usePageActions.barrel.test.ts +38 -0
  18. package/src/composables/usePageCreateAction.test.ts +309 -0
  19. package/src/composables/usePageCreateAction.ts +81 -0
  20. package/src/composables/usePageRefresh.test.ts +241 -0
  21. package/src/composables/usePageRefresh.ts +74 -0
  22. package/src/composables/usePageSearch.test.ts +345 -0
  23. package/src/composables/usePageSearch.ts +87 -0
  24. package/src/errorLandingStandalone/error-landing.html +1 -1
  25. package/src/i18n/locales/ar/components.json +2 -1
  26. package/src/i18n/locales/de/components.json +2 -1
  27. package/src/i18n/locales/en/components.json +2 -1
  28. package/src/i18n/locales/es/components.json +2 -1
  29. package/src/i18n/locales/fr/components.json +2 -1
  30. package/src/i18n/locales/ja/components.json +2 -1
  31. package/src/i18n/locales/ko/components.json +2 -1
  32. package/src/i18n/locales/pt/components.json +2 -1
  33. package/src/i18n/locales/ru/components.json +2 -1
  34. package/src/i18n/locales/zh-Hans/components.json +2 -1
  35. package/src/i18n/locales/zh-Hant/components.json +2 -1
  36. package/src/index.ts +10 -1
@@ -23,6 +23,20 @@ export interface HkAdminHeaderAvatarModalSlot {
23
23
  export interface HkAdminHeaderUserMenuExtraSlot {
24
24
  close?: () => void;
25
25
  }
26
+ /**
27
+ * Scoped payload of the `user-menu-items` slot — host-owned account rows
28
+ * the header seats IMMEDIATELY ABOVE the logout row, inside the dropdown's
29
+ * row run (no divider): account actions belong ahead of the destructive
30
+ * exit. `user-menu-extra` is the TAIL band BELOW logout — a change-password
31
+ * entry passed there reads as an afterthought under "Log out", which is
32
+ * where it sat while the tail was the only host carrier. Same payload shape
33
+ * as `user-menu-extra`: `close` dismisses the dropdown so a navigating entry
34
+ * leaves no orphaned menu behind. Both slots may be supplied at once and
35
+ * each keeps its own position.
36
+ */
37
+ export interface HkAdminHeaderUserMenuItemsSlot {
38
+ close?: () => void;
39
+ }
26
40
  /**
27
41
  * Scoped payload of the `locale-picker` slot — the host-owned locale
28
42
  * popup. When the slot is supplied, the menu's Language row becomes a
@@ -46,8 +60,9 @@ export interface HkAdminHeaderLocalePickerSlot {
46
60
  * static site logo in place of the avatar identity trigger. The mark
47
61
  * is an identity, not a control: no href, no button semantics. On that
48
62
  * face the account machinery does not mount at all (ZERO ACCOUNT
49
- * SURFACE): `identity`, `user-menu-extra`, `avatar-modal` and
50
- * `locale-picker` have no carrier — they all live inside the dropdown.
63
+ * SURFACE): `identity`, `user-menu-extra`, `user-menu-items`,
64
+ * `avatar-modal` and `locale-picker` have no carrier — they all live
65
+ * inside the dropdown.
51
66
  * The drawer face never renders the mark — the avatar trigger is the
52
67
  * drawer's only opener there, and the drawer path stays untouched.
53
68
  * The host that swaps the identity trigger away mounts its own account
@@ -58,6 +73,11 @@ export interface HkAdminHeaderLocalePickerSlot {
58
73
  * `locale-picker` (host locale popup replacing the built-in cascade) were
59
74
  * consumed as of the L39 ruling-a revival (2026-11-20): the erp bodies
60
75
  * that had sat invisible since 0.55.241 now render.
76
+ *
77
+ * `user-menu-items` (host account rows seated directly above the logout
78
+ * row, through HkMenu's `before-item` splice) is the position that slot
79
+ * could never offer — the tail is below logout. It coexists with
80
+ * `user-menu-extra`; each keeps its own position.
61
81
  */
62
82
  export type HkAdminHeaderSlots = SlotsType<{
63
83
  brand?: () => VNode[];
@@ -67,6 +87,7 @@ export type HkAdminHeaderSlots = SlotsType<{
67
87
  "theme-toggle"?: () => VNode[];
68
88
  "avatar-modal"?: (params: HkAdminHeaderAvatarModalSlot) => VNode[];
69
89
  "user-menu-extra"?: (params: HkAdminHeaderUserMenuExtraSlot) => VNode[];
90
+ "user-menu-items"?: (params: HkAdminHeaderUserMenuItemsSlot) => VNode[];
70
91
  "locale-picker"?: (params: HkAdminHeaderLocalePickerSlot) => VNode[];
71
92
  }>;
72
93
  export declare const HkAdminHeader: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
@@ -239,10 +260,10 @@ export declare const HkAdminHeader: import("vue").DefineComponent<import("vue").
239
260
  * Contract, four clauses:
240
261
  * - ZERO ACCOUNT SURFACE: the branded desktop face renders no
241
262
  * account machinery at all — the avatar trigger does not render,
242
- * and the `identity` / `user-menu-extra` / `avatar-modal` /
243
- * `locale-picker` slots have NO carrier on this face (they all
244
- * live inside the dropdown, which is not mounted). A host that
245
- * needs an account face either does not opt into the brand
263
+ * and the `identity` / `user-menu-extra` / `user-menu-items` /
264
+ * `avatar-modal` / `locale-picker` slots have NO carrier on this
265
+ * face (they all live inside the dropdown, which is not mounted).
266
+ * A host that needs an account face either does not opt into the brand
246
267
  * (its consumers keep today's header) or mounts its own entries
247
268
  * in the actions wing — the house shape is a ghost HkIconButton
248
269
  * sized on the page-chrome action ladder, NOT a second
@@ -451,10 +472,10 @@ export declare const HkAdminHeader: import("vue").DefineComponent<import("vue").
451
472
  * Contract, four clauses:
452
473
  * - ZERO ACCOUNT SURFACE: the branded desktop face renders no
453
474
  * account machinery at all — the avatar trigger does not render,
454
- * and the `identity` / `user-menu-extra` / `avatar-modal` /
455
- * `locale-picker` slots have NO carrier on this face (they all
456
- * live inside the dropdown, which is not mounted). A host that
457
- * needs an account face either does not opt into the brand
475
+ * and the `identity` / `user-menu-extra` / `user-menu-items` /
476
+ * `avatar-modal` / `locale-picker` slots have NO carrier on this
477
+ * face (they all live inside the dropdown, which is not mounted).
478
+ * A host that needs an account face either does not opt into the brand
458
479
  * (its consumers keep today's header) or mounts its own entries
459
480
  * in the actions wing — the house shape is a ghost HkIconButton
460
481
  * sized on the page-chrome action ladder, NOT a second
@@ -136,6 +136,22 @@ export interface HkFaceShellHeaderSlot {
136
136
  * (or drops) its centre group repaints the header that renders it.
137
137
  */
138
138
  center?: () => VNode[];
139
+ /**
140
+ * The RIGHT cluster — the page action bar: the VNodes of every action the
141
+ * mounted pages registered (`useActionBar().setActions`), already in slot
142
+ * order, for the header to render as its top-right group. `HkAdminHeader`
143
+ * takes this list verbatim as its `actions` prop.
144
+ *
145
+ * Supplied by the shell that PROVIDES the bar — `HkAdminShell`, which
146
+ * owns one and re-reads it on each of its own renders, so a page's
147
+ * registration repaints the header that shows it. A bare `HkFaceShell`
148
+ * provides no bar and leaves the field ABSENT: a face whose host owns its
149
+ * chrome reads its own bar instead. A consumer therefore relays it as
150
+ * `actions ?? []`, and the optionality is the type-level mirror of the
151
+ * runtime pins in HkFaceShell.test.tsx ("actions" present under
152
+ * HkAdminShell, absent under HkFaceShell).
153
+ */
154
+ actions?: VNode[];
139
155
  }
140
156
  /**
141
157
  * Scoped payload of the `sidebar` slot. Desktop renders it twice — expanded
@@ -39,6 +39,21 @@ import "./HkMenu.scss";
39
39
  * (HkAffixPicker) put their search here so a long catalog scrolls
40
40
  * under the field instead of taking it along (2026-11-27 user report).
41
41
  * Cascade levels and mobile sub-sheets carry neither.
42
+ *
43
+ * One more slot seats host rows BETWEEN the built-in ones — popup
44
+ * variant, ROOT level, DATA-DRIVEN mode only:
45
+ * - `before-item` — scoped, `({ key }) => VNode[]`, invoked right
46
+ * before EACH root row renders with that row's `HkMenuItem.key`; its
47
+ * nodes splice into the level as the row's IMMEDIATE predecessors —
48
+ * bare (no wrapper, no divider), so the host supplies menu-row markup
49
+ * itself and keys the splice on the row key it wants to precede.
50
+ * HkAdminHeader's `user-menu-items` lands directly above the logout
51
+ * row this way (the `footer` band sits BELOW logout — too late for an
52
+ * account action). With no slot the level DOM is byte-identical.
53
+ * Inert everywhere else: cascade levels and mobile sub-sheets are not
54
+ * the root, the sidebar variant draws its rows through its own
55
+ * renderers and never consults the hook, and in composition mode the
56
+ * default slot draws its own rows (no item row to precede).
42
57
  */
43
58
  export interface HkMenuItem {
44
59
  key: string;
@@ -0,0 +1,42 @@
1
+ import { type Component, type Ref } from "vue";
2
+ /** What a page passes to `usePageCreateAction`. */
3
+ export interface UsePageCreateActionOptions {
4
+ /** Accessible name + tooltip — the label the in-page button printed.
5
+ * A FUNCTION is resolved on every header render, which is how a page
6
+ * whose create action changes with its sub-tab (or its locale) keeps the
7
+ * button labelled correctly without re-registering. */
8
+ label: string | (() => string);
9
+ /** Opens the page's own create dialog / starts the create flow. */
10
+ onCreate: () => unknown;
11
+ /** True while the action cannot run (e.g. a save is in flight). */
12
+ disabled?: Ref<boolean> | (() => boolean);
13
+ /** False hides the button entirely (evaluated on every header render). */
14
+ visible?: () => boolean;
15
+ /** Glyph override; defaults to the plus. The glyph stays 16px — the
16
+ * glyph size is part of the cluster's geometry, not a page's choice. */
17
+ icon?: Component;
18
+ }
19
+ /**
20
+ * The standard CREATE affordance of the page-chrome grammar
21
+ * (`design/page-chrome.md`, the create rule): a page's primary create
22
+ * action is a plus icon button in the shell header's top-right cluster —
23
+ * never a standalone button inside the page body.
24
+ *
25
+ * The visible label the in-page button used to carry becomes the button's
26
+ * accessible name (`aria-label`) and tooltip (`title`). The page keeps
27
+ * owning its own dialog: this composable registers the button only, and
28
+ * `onCreate` is what opens that dialog.
29
+ *
30
+ * Geometry is deliberately identical to `usePageRefresh`'s — an
31
+ * `HkIconButton` on the `useChromeActionSize` ladder with a 16px glyph — so
32
+ * the cluster reads as one row of chrome. The registration declares the
33
+ * Create slot, whose canonical rank (the rank table in `useActionBar.ts`)
34
+ * places the plus leftmost no matter which composable the view calls first:
35
+ * [create][filter?][search][refresh][window].
36
+ *
37
+ * Call once from a view's (or card's) setup; the registration dies with
38
+ * that scope, so leaving the page — or switching the tab that mounted the
39
+ * card — clears the button. Outside any action-bar provider the call is a
40
+ * silent no-op (`useActionBar`'s contract).
41
+ */
42
+ export declare function usePageCreateAction(options: UsePageCreateActionOptions): void;
@@ -0,0 +1,37 @@
1
+ import { type Ref } from "vue";
2
+ /** What a page passes to `usePageRefresh` beside its refresh callback. */
3
+ export interface UsePageRefreshOptions {
4
+ /** True while the page's fetch is in flight — the button DISABLES, so a
5
+ * second click cannot stack a second fetch, and re-enables when the ref
6
+ * clears. */
7
+ loading?: Ref<boolean>;
8
+ /** Accessible label override; defaults to the localized "Refresh"
9
+ * (`hikari::pageActions.refresh`). */
10
+ label?: string;
11
+ /** False hides the button entirely (the renderer emits nothing) — for
12
+ * views whose refresh belongs to ONE stage/mode of a longer-lived
13
+ * component. Evaluated on every header render, so flipping the stage
14
+ * shows/hides the button reactively; the per-scope registration
15
+ * contract is unchanged. */
16
+ visible?: () => boolean;
17
+ }
18
+ /**
19
+ * The standard REFRESH affordance of the page-chrome grammar
20
+ * (`design/page-chrome.md`): THE refresh button of a page, registered in
21
+ * the Refresh slot of the shell header's top-right cluster — the same slot
22
+ * the theme toggle lives in, and the same button geometry (an `HkIconButton`
23
+ * on the `useChromeActionSize` ladder with a 16px glyph). A page either
24
+ * has a refresh, and it is HERE, or it has none: an in-body refresh button
25
+ * beside it is a second source for one verb.
26
+ *
27
+ * The slot's canonical rank (the rank table in `useActionBar.ts`) seats the
28
+ * button right of the search and left of the window opener regardless of
29
+ * the order the page registered its affordances in:
30
+ * [create][filter?][search][refresh][window].
31
+ *
32
+ * Call once from a view's setup; the registration dies with the view's
33
+ * scope (`useActionBar`'s per-scope contract), so switching pages clears
34
+ * the button automatically. Outside any action-bar provider the call is a
35
+ * silent no-op.
36
+ */
37
+ export declare function usePageRefresh(refresh: () => unknown, options?: UsePageRefreshOptions): void;
@@ -0,0 +1,55 @@
1
+ import { type ComputedRef, type Ref } from "vue";
2
+ /** What a page passes to `usePageSearch`. */
3
+ export interface UsePageSearchOptions {
4
+ /** Accessible label / sheet title; defaults to `HkSearchTrigger`'s own
5
+ * localized "Search". */
6
+ label?: string;
7
+ /** Input placeholder; defaults to the localized "Search…". */
8
+ placeholder?: string;
9
+ /** Commit debounce while typing, ms (`HkSearchTrigger`'s own default is
10
+ * 300; Enter commits immediately). */
11
+ debounce?: number;
12
+ /** Drafts shorter than this never commit (`HkSearchTrigger`'s own
13
+ * default is 1; 0 disables the floor). */
14
+ minLength?: number;
15
+ /** Initial keyword (deep-link restore); default "". */
16
+ initial?: string;
17
+ /** False hides the trigger entirely (evaluated on every header render) —
18
+ * for keep-mounted panes that must not show their search chrome while
19
+ * another pane is active. */
20
+ visible?: () => boolean;
21
+ }
22
+ /** What `usePageSearch` hands back: the page's keyword model. */
23
+ export interface UsePageSearchReturn {
24
+ /** The trimmed active keyword ("" = none). Reactive. */
25
+ search: ComputedRef<string>;
26
+ /** The raw keyword ref, for hosts that need to write it directly. */
27
+ keyword: Ref<string>;
28
+ }
29
+ /**
30
+ * The standard SEARCH affordance of the page-chrome grammar
31
+ * (`design/page-chrome.md`) — the search-behaviour half of a list page.
32
+ * One trigger (hikari's `HkSearchTrigger`, the chrome twin of the filter
33
+ * trigger) registered in the Search slot of the shell header's top-right
34
+ * cluster, one keyword namespace: the page decides WHAT the keyword
35
+ * matches (its fetcher maps it onto its own query params), the trigger
36
+ * decides HOW search behaves (draft panel, debounce, clear,
37
+ * commit-on-close).
38
+ *
39
+ * The cluster orders itself by slot rank, so the order this composable is
40
+ * called in relative to `usePageCreateAction` / `usePageRefresh` does not
41
+ * matter — the header reads [create][filter?][search][refresh][window].
42
+ *
43
+ * const { search } = usePageSearch();
44
+ * const rows = useTableFetch(fetcher, { params: () => ({ search: search.value }) });
45
+ *
46
+ * The returned `search` is the TRIMMED keyword ("" = none) — feed it into
47
+ * the page's query params. The model is two-way: a commit from the trigger
48
+ * (typed, pasted or cleared) writes `keyword`, and a host that writes
49
+ * `keyword` itself re-renders the trigger with the new active keyword.
50
+ *
51
+ * Call once from a view's setup; the registration dies with that scope
52
+ * (`useActionBar`'s per-scope contract). Outside any action-bar provider
53
+ * the registration is a silent no-op and the keyword model still works.
54
+ */
55
+ export declare function usePageSearch(options?: UsePageSearchOptions): UsePageSearchReturn;
@@ -249,6 +249,12 @@ export { provideActionBar, useActionBar, PageActionSlot, orderActionRegistration
249
249
  export { useActionBarCenter } from "./composables/useActionBar";
250
250
  export type { ActionBarRenderer, PageActionSlotValue, ActionBarRegistration } from "./composables/useActionBar";
251
251
  export { useChromeActionSize } from "./composables/useChromeActionSize";
252
+ export { usePageCreateAction } from "./composables/usePageCreateAction";
253
+ export type { UsePageCreateActionOptions } from "./composables/usePageCreateAction";
254
+ export { usePageRefresh } from "./composables/usePageRefresh";
255
+ export type { UsePageRefreshOptions } from "./composables/usePageRefresh";
256
+ export { usePageSearch } from "./composables/usePageSearch";
257
+ export type { UsePageSearchOptions, UsePageSearchReturn } from "./composables/usePageSearch";
252
258
  export { leadingZeroBits, sha256, solvePow, solvePowSync, verifyPow } from "./utils/pow";
253
259
  export type { PowChallenge, PowSolution } from "./utils/pow";
254
260
  export { HkLocalePicker as HLocalePicker } from "./components/HkLocalePicker";
@@ -478,7 +484,7 @@ export { HkAdminShell as HkAdminShell } from "./components/HkAdminShell";
478
484
  export { HkFaceShell as HkFaceShell } from "./components/HkFaceShell";
479
485
  export type { HkFaceShellHeaderSlot, HkFaceShellSidebarSlot, HkFaceShellUserPanelSlot, HkFaceShellSlots } from "./components/HkFaceShell";
480
486
  export { HkAdminHeader as HkAdminHeader } from "./components/HkAdminHeader";
481
- export type { HkAdminHeaderAvatarModalSlot, HkAdminHeaderLocalePickerSlot, HkAdminHeaderSlots, HkAdminHeaderUserMenuExtraSlot } from "./components/HkAdminHeader";
487
+ export type { HkAdminHeaderAvatarModalSlot, HkAdminHeaderLocalePickerSlot, HkAdminHeaderSlots, HkAdminHeaderUserMenuExtraSlot, HkAdminHeaderUserMenuItemsSlot } from "./components/HkAdminHeader";
482
488
  export { HkAvatarButton as HkAvatarButton } from "./components/HkAvatarButton";
483
489
  export { HkNavSidebar as HkNavSidebar } from "./components/HkNavSidebar";
484
490
  export { HkThemeToggle as HkThemeToggle } from "./components/HkThemeToggle";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celestia-island/hikari",
3
- "version": "0.55.527",
3
+ "version": "0.55.528",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Hikari UI library, Vue 3 runtime — one design system for Vue 3 and Rust/WASM applications",
@@ -17,6 +17,17 @@ interface MenuItemStub {
17
17
  // wiring row clicks to the select handler; the rest of hikari stays
18
18
  // real. The select handler reaches the stub through attrs (it is not
19
19
  // re-declared as an emit, which would strip it from props).
20
+ //
21
+ // The stub honours HkMenu's root-level `before-item` hook the same way
22
+ // the real menu does (its nodes land right before each ROOT row; child
23
+ // rows live in their own level upstream and never see it), so the
24
+ // header's splice WIRING is observable here (comment-gate-ok: wiring
25
+ // only — the real splice geometry is pinned by MUT:M1/M2/M6 in
26
+ // HkMenu.test.ts and by the real-menu pins in
27
+ // HkAdminHeader.userMenuItems.test.tsx). It mirrors the call
28
+ // convention only — the real splice geometry is pinned in HkMenu.test.ts
29
+ // and, with the real menu under this real header, in
30
+ // HkAdminHeader.userMenuItems.test.tsx.
20
31
  vi.mock("./HkMenu", async () => {
21
32
  const { defineComponent, h } = await import("vue");
22
33
  const { asPropType } = await import("../utils/typing");
@@ -31,8 +42,12 @@ vi.mock("./HkMenu", async () => {
31
42
  return () => {
32
43
  if (!props.open) return null;
33
44
  const rows: ReturnType<typeof h>[] = [];
34
- const flatten = (items: MenuItemStub[]) => {
35
- for (const item of items ?? []) {
45
+ const beforeItem = slots["before-item"] as
46
+ | ((payload: { key: string }) => ReturnType<typeof h>[])
47
+ | undefined;
48
+ const flatten = (list: MenuItemStub[], root: boolean) => {
49
+ for (const item of list ?? []) {
50
+ if (root && beforeItem) rows.push(...beforeItem({ key: item.key }));
36
51
  rows.push(
37
52
  h(
38
53
  "button",
@@ -49,11 +64,18 @@ vi.mock("./HkMenu", async () => {
49
64
  item.label,
50
65
  ),
51
66
  );
52
- if (item.children?.length) flatten(item.children);
67
+ if (item.children?.length) flatten(item.children, false);
53
68
  }
54
69
  };
55
- flatten(props.items);
56
- return h("div", { class: "menu-stub" }, [
70
+ flatten(props.items, true);
71
+ // The slot KEYS the header handed the menu, sorted — published as an
72
+ // attribute so a test can pin the slot SET itself (a carrier the
73
+ // header must not pass unasked), not only what the slots render.
74
+ const slotKeys = Object.keys(slots)
75
+ .filter((key) => !key.startsWith("_"))
76
+ .sort()
77
+ .join(" ");
78
+ return h("div", { class: "menu-stub", "data-slots": slotKeys }, [
57
79
  ...(slots.header?.() ?? []),
58
80
  ...rows,
59
81
  ...(slots.footer?.() ?? []),
@@ -78,7 +100,9 @@ import { HkAdminHeader } from "./HkAdminHeader";
78
100
  * - an empty identity renders the signing-in placeholder + the
79
101
  * force-sign-out escape row;
80
102
  * - Language children carry checked state and emit localeSelect;
81
- * - the goToFrontend row sits directly above logout.
103
+ * - the goToFrontend row sits directly above logout;
104
+ * - host rows from `user-menu-items` sit between the built-in rows and
105
+ * logout (the splice wiring), `user-menu-extra` rows stay in the tail.
82
106
  *
83
107
  * (Repo test convention: raw createApp + container queries, no
84
108
  * @vue/test-utils dependency.)
@@ -424,9 +448,14 @@ describe("HkAdminHeader brand slot (opt-in site mark)", () => {
424
448
  // The replacement clause, pinned end to end: identity props AND the
425
449
  // account carrier slots are ALL supplied, yet the branded header
426
450
  // exposes no account trigger, no popup, and none of the slot bodies
427
- // — the dropdown (and identity / user-menu-extra / avatar-modal /
428
- // locale-picker inside it) does not mount at all. This is the pin
429
- // that keeps a future edit from "helpfully" wiring the menu back.
451
+ // — the dropdown (and identity / user-menu-extra / user-menu-items /
452
+ // avatar-modal / locale-picker inside it) does not mount at all
453
+ // (MUT:M4 — a host-supplied user-menu-items row renders, so the
454
+ // wiring exists; the branded face mounts no menu to carry it).
455
+ // This is the pin that keeps a future edit from "helpfully" wiring
456
+ // the menu back. comment-gate-ok: user-menu-items rides that existing
457
+ // pin — with no dropdown mounted there is no splice carrier, and
458
+ // wiring the menu back is already red on the `header button` line.
430
459
  const c = mount(headerNode({
431
460
  title: "Providers",
432
461
  username: "alice",
@@ -436,6 +465,7 @@ describe("HkAdminHeader brand slot (opt-in site mark)", () => {
436
465
  }, {
437
466
  identity: () => h("div", { class: "host-identity" }, "host identity"),
438
467
  "user-menu-extra": () => h("div", { class: "host-extra" }, "host extra"),
468
+ "user-menu-items": () => h("div", { class: "host-items" }, "host items"),
439
469
  "avatar-modal": () => h("div", { class: "host-modal" }, "host modal"),
440
470
  "locale-picker": () => h("div", { class: "host-locale" }, "host locale"),
441
471
  }));
@@ -447,6 +477,7 @@ describe("HkAdminHeader brand slot (opt-in site mark)", () => {
447
477
  // ...and none of the account carrier slots render their bodies.
448
478
  expect(c.querySelector(".host-identity")).toBeNull();
449
479
  expect(c.querySelector(".host-extra")).toBeNull();
480
+ expect(c.querySelector(".host-items")).toBeNull();
450
481
  expect(c.querySelector(".host-modal")).toBeNull();
451
482
  expect(c.querySelector(".host-locale")).toBeNull();
452
483
  // The brand mark itself is the only thing the wing gained.
@@ -548,6 +579,108 @@ describe("HkAdminHeader host slots (L39 ruling-a revival)", () => {
548
579
  expect(c.querySelector(".menu-stub")).toBeNull();
549
580
  });
550
581
 
582
+ /** DOM order of the stub menu's rows = Tab order (every row is a native
583
+ * button): a built-in row's key, or `#label` for a host row. */
584
+ const rowOrder = (c: HTMLElement) =>
585
+ [...c.querySelectorAll<HTMLButtonElement>(".menu-stub button")].map(
586
+ (b) => b.dataset.key ?? `#${b.textContent}`,
587
+ );
588
+
589
+ const hostRow = (label: string, onClick?: () => void) =>
590
+ h("button", { class: "menu-stub-row host-item", type: "button", onClick }, label);
591
+
592
+ it("seats user-menu-items rows directly above logout, ahead of the user-menu-extra tail", async () => {
593
+ // MUT:M1 MUT:M2 MUT:M4: DOM order = Tab order = visual order — Avatar,
594
+ // Language, Account, <host rows>, Logout, <extra>. Host rows moved
595
+ // below logout (M1), repeated before every row (M2) or a dropped tail
596
+ // (M4) each change this list.
597
+ const c = mount(
598
+ headerNode({ localeOptions: LOCALES, goToFrontendLabel: "Account", logoutLabel: "Log out" }, {
599
+ "user-menu-items": ({ close }: { close?: () => void }) => [
600
+ hostRow("Change password", () => close?.()),
601
+ hostRow("Account center", () => close?.()),
602
+ ],
603
+ "user-menu-extra": () => h("button", { class: "menu-stub-row extra-row", type: "button" }, "Host extra"),
604
+ }),
605
+ );
606
+ const menu = (await openMenu(c))!;
607
+ // The carrier: the menu receives `before-item` beside the two bands.
608
+ expect(menu.dataset.slots).toBe("before-item footer header");
609
+ expect(rowOrder(c)).toEqual([
610
+ "avatar",
611
+ "locale",
612
+ "locale:en",
613
+ "locale:zh-Hans",
614
+ "go-to-frontend",
615
+ "#Change password",
616
+ "#Account center",
617
+ "logout",
618
+ "#Host extra",
619
+ ]);
620
+ // The payload's close() dismisses the dropdown on either host row — a
621
+ // navigating entry leaves no orphaned menu behind. MUT:M3
622
+ await click(c.querySelector(".host-item"));
623
+ expect(c.querySelector(".menu-stub")).toBeNull();
624
+ await openMenu(c);
625
+ await click(c.querySelectorAll(".host-item")[1]);
626
+ expect(c.querySelector(".menu-stub")).toBeNull();
627
+ });
628
+
629
+ it("keeps logout the last row when only user-menu-items is supplied", async () => {
630
+ // MUT:M1 MUT:M2: host rows dropped below logout, or repeated before
631
+ // every row, both break this list.
632
+ const c = mount(headerNode({ logoutLabel: "Log out" }, {
633
+ "user-menu-items": () => hostRow("Change password"),
634
+ }));
635
+ await openMenu(c);
636
+ expect(rowOrder(c)).toEqual(["avatar", "#Change password", "logout"]);
637
+ });
638
+
639
+ it("renders the exact previous rows when user-menu-items is not supplied", async () => {
640
+ // NEGATIVE CONTROL: a header without the slot hands the menu what it
641
+ // always did — the same row list with no node in between.
642
+ // MUT:M12: a stray node on the no-slot path shows up in this shape.
643
+ const c = mount(headerNode({ localeOptions: LOCALES, goToFrontendLabel: "Account", logoutLabel: "Log out" }));
644
+ const menu = (await openMenu(c))!;
645
+ expect(menuRows(c).map((r) => r.dataset.key)).toEqual([
646
+ "avatar",
647
+ "locale",
648
+ "locale:en",
649
+ "locale:zh-Hans",
650
+ "go-to-frontend",
651
+ "logout",
652
+ ]);
653
+ expect([...menu.children].map((el) => el.className)).toEqual([
654
+ "s-user-header s-user-header--profile",
655
+ "menu-stub-row",
656
+ "menu-stub-row",
657
+ "menu-stub-row",
658
+ "menu-stub-row",
659
+ "menu-stub-row",
660
+ "menu-stub-row",
661
+ ]);
662
+ // The slot SET is the exact previous one too: `before-item` travels
663
+ // only with the host slot, so a header without it adds no carrier —
664
+ // an always-forwarded hook renders nothing, which is why the DOM
665
+ // controls above cannot see it. MUT:before-item-unconditional
666
+ expect(menu.dataset.slots).toBe("footer header");
667
+ });
668
+
669
+ it("renders no user-menu-items rows in the pending-identity menu", async () => {
670
+ // The splice is keyed on the logout ROW, not on "the last row": the
671
+ // pending menu holds only the force-sign-out escape, and a host
672
+ // account row must not appear above it — account rows wait for an
673
+ // identity like every built-in action row. MUT:M13
674
+ const c = mount(
675
+ headerNode(
676
+ { username: "", userEmail: "", signingInLabel: "Signing in…", onForceSignOut: () => {} },
677
+ { "user-menu-items": () => hostRow("Change password") },
678
+ ),
679
+ );
680
+ const menu = (await openMenu(c))!;
681
+ expect([...menu.querySelectorAll("button")].map((b) => b.dataset.key)).toEqual(["force-signout"]);
682
+ });
683
+
551
684
  it("renders the locale-picker popup when the Language row is selected", async () => {
552
685
  const c = mount(
553
686
  headerNode(
@@ -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
  )}