@celestia-island/hikari 0.55.446 → 0.55.448

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celestia-island/hikari",
3
- "version": "0.55.446",
3
+ "version": "0.55.448",
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",
@@ -337,6 +337,165 @@ describe("HkAdminHeader", () => {
337
337
  const actions = c.querySelector(".s-admin-header-actions");
338
338
  expect(actions?.className).toContain("s-header-wing-end");
339
339
  });
340
+
341
+ it("leaves the left wing shape untouched when no brand is provided (additive gate)", () => {
342
+ // THE zero-change pin for the brand slot: hosts that never pass
343
+ // brandSrc / brand (chest today) must get the exact wing they always
344
+ // had — avatar trigger then title, no brand node anywhere. Pinned as
345
+ // a structural shape so a future left-wing refactor that disturbs
346
+ // non-branded hosts trips HERE, not in a downstream repo.
347
+ const c = mount(headerNode({ title: "Providers", userEmail: "alice@example.com" }));
348
+ const wing = c.querySelector(".s-admin-header-user");
349
+ if (wing === null) throw new Error("the wing must render");
350
+ const shape = [...wing.children].map((el) => `${el.tagName.toLowerCase()}.${el.className}`);
351
+ expect(shape).toEqual([
352
+ "button.s-admin-header-avatar",
353
+ "span.s-admin-header-title",
354
+ ]);
355
+ expect(c.querySelector(".s-admin-header-brand")).toBeNull();
356
+
357
+ // The byte-identical claim covers the DRAWER wing's children too:
358
+ // avatar trigger (the drawer opener) then the reserved ws-slot
359
+ // blank, in that order, brand node absent.
360
+ const drawer = mount(headerNode({ avatarAction: "drawer", userEmail: "alice@example.com" }));
361
+ const drawerWing = drawer.querySelector(".s-admin-header-user");
362
+ if (drawerWing === null) throw new Error("the drawer wing must render");
363
+ const drawerShape = [...drawerWing.children].map((el) => `${el.tagName.toLowerCase()}.${el.className}`);
364
+ expect(drawerShape).toEqual([
365
+ "button.s-admin-header-avatar",
366
+ "span.s-admin-header-ws-slot",
367
+ ]);
368
+ expect(drawer.querySelector(".s-admin-header-brand")).toBeNull();
369
+ });
370
+ });
371
+
372
+ describe("HkAdminHeader brand slot (opt-in site mark)", () => {
373
+ it("renders the static brand mark in place of the identity trigger on the desktop face", () => {
374
+ // Identity props are PRESENT on purpose: the mark REPLACES the
375
+ // trigger, it does not wait for an absent identity.
376
+ const c = mount(headerNode({
377
+ title: "Providers",
378
+ userEmail: "alice@example.com",
379
+ brandSrc: "https://example.invalid/logo.png",
380
+ brandAlt: "Lagrange",
381
+ }));
382
+ const brand = c.querySelector(".s-admin-header-brand");
383
+ expect(brand, "the brand mark must render").not.toBeNull();
384
+ const found = brand?.querySelector("img.hk-logo-img");
385
+ const img = found instanceof HTMLImageElement ? found : null;
386
+ expect(img?.getAttribute("src")).toBe("https://example.invalid/logo.png");
387
+ expect(img?.getAttribute("alt")).toBe("Lagrange");
388
+ expect(avatarButton(c), "the identity trigger must be replaced").toBeNull();
389
+ // The WHERE title keeps its node — the mark replaces the identity,
390
+ // not the page title beside it.
391
+ expect(c.querySelector(".s-admin-header-title")?.textContent).toBe("Providers");
392
+ });
393
+
394
+ it("keeps the mark free of button semantics (an identity, not a control)", () => {
395
+ // No hamburger on this mount: the branded wing must hold NO button
396
+ // at all — the account entry moved to the host's own surface, and
397
+ // the mark itself is a span around a div/img, not a control.
398
+ const c = mount(headerNode({ brandSrc: "https://example.invalid/logo.png" }));
399
+ expect(c.querySelector(".s-admin-header-user button")).toBeNull();
400
+ expect(c.querySelector(".s-admin-header-brand button")).toBeNull();
401
+ // SEMANTIC pins, not shape pins: a future re-render that wraps the
402
+ // mark in an anchor (href), or sprinkles tabindex/role="button" on
403
+ // it, turns the identity into a control no matter what the class
404
+ // list looks like. The scan covers the mark's WHOLE PATH: the node
405
+ // itself (a re-render may move the class onto an anchor), its
406
+ // ancestors up to the wing (an anchor WRAPPING the mark sits outside
407
+ // any descendant query — descendant-only pins are blind to it), and
408
+ // everything inside it.
409
+ const brandEl = c.querySelector(".s-admin-header-brand");
410
+ if (brandEl === null) throw new Error("the brand mark must render");
411
+ const brandPath: Element[] = [brandEl];
412
+ let cursor: Element | null = brandEl;
413
+ while (cursor && !cursor.classList.contains("s-admin-header-user")) {
414
+ cursor = cursor.parentElement;
415
+ if (cursor) brandPath.push(cursor);
416
+ }
417
+ const controlHits = [...brandPath, ...brandEl.querySelectorAll("*")].filter((el) =>
418
+ el.matches('a[href], [tabindex], [role="button"]'),
419
+ );
420
+ expect(controlHits, "the brand path must carry no control semantics").toEqual([]);
421
+ });
422
+
423
+ it("renders ZERO account surface on the branded desktop face (the replacement contract)", () => {
424
+ // The replacement clause, pinned end to end: identity props AND the
425
+ // account carrier slots are ALL supplied, yet the branded header
426
+ // 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.
430
+ const c = mount(headerNode({
431
+ title: "Providers",
432
+ username: "alice",
433
+ userEmail: "alice@example.com",
434
+ logoutLabel: "Log out",
435
+ brandSrc: "https://example.invalid/logo.png",
436
+ }, {
437
+ identity: () => h("div", { class: "host-identity" }, "host identity"),
438
+ "user-menu-extra": () => h("div", { class: "host-extra" }, "host extra"),
439
+ "avatar-modal": () => h("div", { class: "host-modal" }, "host modal"),
440
+ "locale-picker": () => h("div", { class: "host-locale" }, "host locale"),
441
+ }));
442
+ // No interactive surface anywhere in the header...
443
+ expect(c.querySelector("header button")).toBeNull();
444
+ expect(c.querySelector("header [aria-haspopup]")).toBeNull();
445
+ // ...the dropdown is not mounted (its stub renders nothing)...
446
+ expect(c.querySelector(".menu-stub")).toBeNull();
447
+ // ...and none of the account carrier slots render their bodies.
448
+ expect(c.querySelector(".host-identity")).toBeNull();
449
+ expect(c.querySelector(".host-extra")).toBeNull();
450
+ expect(c.querySelector(".host-modal")).toBeNull();
451
+ expect(c.querySelector(".host-locale")).toBeNull();
452
+ // The brand mark itself is the only thing the wing gained.
453
+ expect(c.querySelector(".s-admin-header-brand")).not.toBeNull();
454
+ });
455
+
456
+ it("prefers the brand slot over brandSrc when both are supplied", () => {
457
+ const c = mount(headerNode(
458
+ { brandSrc: "https://example.invalid/logo.png" },
459
+ { brand: () => h("span", { class: "host-brand-mark" }, "host mark") },
460
+ ));
461
+ expect(c.querySelector(".host-brand-mark")?.textContent).toBe("host mark");
462
+ expect(c.querySelector(".hk-logo")).toBeNull();
463
+ expect(avatarButton(c)).toBeNull();
464
+ });
465
+
466
+ // The slot is the FIRST of the two opt-in channels, so it must work ALONE:
467
+ // the dual-channel case above cannot see `brandMounted` losing its slot leg
468
+ // (`!!props.brandSrc` survives the whole suite with this case missing —
469
+ // review round R2'' mutation M-A).
470
+ it("mounts the brand face from the slot alone, without brandSrc", () => {
471
+ const c = mount(headerNode(
472
+ {},
473
+ { brand: () => h("span", { class: "slot-only-mark" }, "slot only") },
474
+ ));
475
+ expect(c.querySelector(".slot-only-mark")?.textContent).toBe("slot only");
476
+ // The brand face replaced the avatar identity trigger…
477
+ expect(avatarButton(c)).toBeNull();
478
+ // …and no fallback logo renders — the slot IS the brand, not a default.
479
+ expect(c.querySelector(".hk-logo")).toBeNull();
480
+ });
481
+
482
+ it("never renders the brand on the drawer face and keeps the drawer path alive", async () => {
483
+ const clicks: number[] = [];
484
+ const c = mount(headerNode({
485
+ avatarAction: "drawer",
486
+ userEmail: "alice@example.com",
487
+ brandSrc: "https://example.invalid/logo.png",
488
+ onAvatarClick: () => clicks.push(1),
489
+ }));
490
+ // The mark is absent AND the avatar trigger still opens the drawer —
491
+ // that trigger is the drawer's only opener, so the mobile path is
492
+ // invariant under the brand props.
493
+ expect(c.querySelector(".s-admin-header-brand")).toBeNull();
494
+ const btn = avatarButton(c);
495
+ expect(btn?.getAttribute("aria-haspopup")).toBe("dialog");
496
+ await click(btn);
497
+ expect(clicks).toHaveLength(1);
498
+ });
340
499
  });
341
500
 
342
501
  describe("HkAdminHeader chrome face drag region (2026-11-12)", () => {
@@ -6,6 +6,7 @@ import { CHROME_BAND_DRAG_REGION } from "../runtime/windowChrome";
6
6
  import HkMenu, { type HkMenuItem } from "./HkMenu";
7
7
  import { HkAvatarButton } from "./HkAvatarButton";
8
8
  import { useAvatarImage } from "./avatarImage";
9
+ import HkLogo from "./HkLogo";
9
10
 
10
11
  export interface LocaleOption {
11
12
  code: string;
@@ -49,8 +50,22 @@ export interface HkAdminHeaderLocalePickerSlot {
49
50
  }
50
51
 
51
52
  /**
52
- * The header's whole slot surface, in `SlotsType` form. `identity`,
53
- * `center`, `emergency-stop-extra` and `theme-toggle` take no params.
53
+ * The header's whole slot surface, in `SlotsType` form. `brand`,
54
+ * `identity`, `center`, `emergency-stop-extra` and `theme-toggle` take
55
+ * no params.
56
+ *
57
+ * `brand` (opt-in site mark): when supplied — or when the `brandSrc`
58
+ * prop is set — the DESKTOP face (avatarAction "menu") renders the
59
+ * static site logo in place of the avatar identity trigger. The mark
60
+ * is an identity, not a control: no href, no button semantics. On that
61
+ * 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.
64
+ * The drawer face never renders the mark — the avatar trigger is the
65
+ * drawer's only opener there, and the drawer path stays untouched.
66
+ * The host that swaps the identity trigger away mounts its own account
67
+ * entries in the actions wing (a ghost HkIconButton on the page-chrome
68
+ * action ladder) or skips the brand entirely.
54
69
  *
55
70
  * `user-menu-extra` (rows appended to the dropdown tail) and
56
71
  * `locale-picker` (host locale popup replacing the built-in cascade) were
@@ -58,6 +73,7 @@ export interface HkAdminHeaderLocalePickerSlot {
58
73
  * that had sat invisible since 0.55.241 now render.
59
74
  */
60
75
  export type HkAdminHeaderSlots = SlotsType<{
76
+ brand?: () => VNode[];
61
77
  identity?: () => VNode[];
62
78
  center?: () => VNode[];
63
79
  "emergency-stop-extra"?: () => VNode[];
@@ -144,6 +160,44 @@ export const HkAdminHeader = defineComponent({
144
160
  * panels without a consumer-facing face simply omit the prop and
145
161
  * keep the menu at avatar/language/logout. */
146
162
  goToFrontendLabel: { type: String, default: undefined },
163
+ /** Static site logo URL for the header's BRAND slot (opt-in). When
164
+ * set — or when the `brand` slot is supplied (the slot wins) — the
165
+ * DESKTOP face (avatarAction "menu") renders the site mark in place
166
+ * of the avatar identity trigger: one static identity at the wing
167
+ * head, where the account trigger used to sit.
168
+ *
169
+ * Contract, four clauses:
170
+ * - ZERO ACCOUNT SURFACE: the branded desktop face renders no
171
+ * 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
176
+ * (its consumers keep today's header) or mounts its own entries
177
+ * in the actions wing — the house shape is a ghost HkIconButton
178
+ * sized on the page-chrome action ladder, NOT a second
179
+ * header-internal menu.
180
+ * - DESKTOP ONLY: the drawer face (avatarAction "drawer") never
181
+ * renders the mark and keeps the avatar trigger untouched — that
182
+ * trigger is the drawer's only opener, so the mobile drawer path
183
+ * is invariant under this prop.
184
+ * - NON-INTERACTIVE: the mark is an identity, not a control. It is
185
+ * rendered through the div variant of HkLogo (no href), carries
186
+ * no button semantics (no tabindex, no role), and the face pins
187
+ * the pointer cursor off.
188
+ * - ZERO CHANGE WITHOUT IT: hosts that pass neither the slot nor
189
+ * the prop render the exact header they always did.
190
+ *
191
+ * Rendered at HkLogo's "sm" step — the closest visual weight to the
192
+ * 28px trigger it replaces, inside the header's 48px band. */
193
+ brandSrc: { type: String, default: undefined },
194
+ /** Accessible name for the static brand mark (the logo image's alt).
195
+ * Provide it: a site logo carries the site's name. The default ""
196
+ * is the DECORATIVE contract — assistive tech skips an empty-alt
197
+ * image silently, so the mark stays unannounced; that is a valid
198
+ * choice only when the mark is purely decorative (the site name
199
+ * lives elsewhere, e.g. the document title). */
200
+ brandAlt: { type: String, default: "" },
147
201
  },
148
202
  emits: {
149
203
  logout: () => true,
@@ -188,6 +242,21 @@ export const HkAdminHeader = defineComponent({
188
242
  props.onForceSignOut !== undefined,
189
243
  );
190
244
 
245
+ // The brand mark is opt-in through EITHER channel: the host `brand`
246
+ // slot (arbitrary mark nodes) or the `brandSrc` prop (a plain site
247
+ // logo URL rendered through HkLogo). See the prop contract above for
248
+ // the replacement semantics — the desktop face swaps the identity
249
+ // trigger for the mark, the drawer face ignores the brand entirely.
250
+ const brandMounted = computed(() => !!(slots.brand || props.brandSrc));
251
+ // The branded DESKTOP face carries ZERO account machinery: the mark
252
+ // 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.
256
+ const brandedMenuFace = computed(
257
+ () => brandMounted.value && props.avatarAction === "menu",
258
+ );
259
+
191
260
  function onAvatarClick(e: MouseEvent) {
192
261
  e.stopPropagation();
193
262
  if (props.avatarAction === "drawer") {
@@ -315,7 +384,7 @@ export const HkAdminHeader = defineComponent({
315
384
  <Menu size={20} class="s-admin-header-hamburger-icon" />
316
385
  </HButton>
317
386
  )}
318
- {identityMounted.value && (
387
+ {identityMounted.value && !brandedMenuFace.value && (
319
388
  <HkAvatarButton
320
389
  avatarUrl={props.avatarUrl}
321
390
  username={props.username}
@@ -325,6 +394,23 @@ export const HkAdminHeader = defineComponent({
325
394
  onClick={onAvatarClick}
326
395
  />
327
396
  )}
397
+ {/* The brand mark (opt-in brandSrc / brand slot, desktop face
398
+ * only): the static site logo takes the identity trigger's
399
+ * spot — an identity, not a control (div-variant HkLogo, no
400
+ * href, no button semantics; the pointer cursor is pinned off
401
+ * in admin-tokens). The drawer face never renders it — the
402
+ * avatar trigger above IS the drawer path there, so that wing
403
+ * stays byte-identical. The slot wins when both channels are
404
+ * supplied. On this face the account machinery below (the
405
+ * dropdown and its carrier slots) does not mount at all —
406
+ * the ZERO ACCOUNT SURFACE clause of the brand contract. */}
407
+ {brandedMenuFace.value && (
408
+ <span class="s-admin-header-brand">
409
+ {slots.brand ? slots.brand() : (
410
+ <HkLogo src={props.brandSrc} alt={props.brandAlt} size="sm" />
411
+ )}
412
+ </span>
413
+ )}
328
414
  {/* The reserved workspace-switcher slot (drawer face only).
329
415
  The chat header's left wing is avatar + ws-trigger button,
330
416
  and that wing's min-content floor is what keeps the
@@ -350,17 +436,21 @@ export const HkAdminHeader = defineComponent({
350
436
  )}
351
437
  </div>
352
438
 
353
- <HkMenu
354
- open={userMenuOpen.value}
355
- onUpdate:open={(v: boolean) => { userMenuOpen.value = v; }}
356
- anchorRef={userTriggerRef.value ?? null}
357
- placement="bottom-start"
358
- title={props.avatarTriggerLabel ?? t("hikari::adminHeader.avatarTrigger", "Account menu")}
359
- items={userMenuItems.value}
360
- onSelect={(key: string) => onUserMenuSelect(key)}
361
- >
362
- {{
363
- header: () => (
439
+ {/* The account dropdown: NOT mounted on the branded desktop face
440
+ * (zero account surface — identity / user-menu-extra have no
441
+ * carrier there); every other face mounts it exactly as before. */}
442
+ {!brandedMenuFace.value && (
443
+ <HkMenu
444
+ open={userMenuOpen.value}
445
+ onUpdate:open={(v: boolean) => { userMenuOpen.value = v; }}
446
+ anchorRef={userTriggerRef.value ?? null}
447
+ placement="bottom-start"
448
+ title={props.avatarTriggerLabel ?? t("hikari::adminHeader.avatarTrigger", "Account menu")}
449
+ items={userMenuItems.value}
450
+ onSelect={(key: string) => onUserMenuSelect(key)}
451
+ >
452
+ {{
453
+ header: () => (
364
454
  !props.username && !props.userEmail ? (
365
455
  // Pending identity: a spinner beside the label reads as
366
456
  // "actively working", not a frozen panel.
@@ -426,7 +516,8 @@ export const HkAdminHeader = defineComponent({
426
516
  close: () => { userMenuOpen.value = false; },
427
517
  }) ?? [],
428
518
  }}
429
- </HkMenu>
519
+ </HkMenu>
520
+ )}
430
521
 
431
522
  {/* Page-owned centre group (page filter tab strips, segmented
432
523
  * option pickers) — the console face of the balanced header the
@@ -471,7 +562,10 @@ export const HkAdminHeader = defineComponent({
471
562
  {slots["theme-toggle"]?.()}
472
563
  </div>
473
564
 
474
- {slots["avatar-modal"]?.({
565
+ {/* The avatar-modal host surface rides the account dropdown (its
566
+ * Camera row opens it) — no dropdown on the branded desktop face,
567
+ * no modal carrier either. Other faces mount it as before. */}
568
+ {!brandedMenuFace.value && slots["avatar-modal"]?.({
475
569
  open: avatarModalOpen.value,
476
570
  onUpdateOpen: (v: boolean) => { avatarModalOpen.value = v; },
477
571
  })}
@@ -479,8 +573,12 @@ export const HkAdminHeader = defineComponent({
479
573
  {/* Host-owned locale popup (L39 ruling a): the Language row's
480
574
  * trigger target. Anchored to the avatar trigger — the popup
481
575
  * opens where the dropdown was, so the handoff reads as the
482
- * menu sliding into a picker rather than a second surface. */}
483
- {slots["locale-picker"]?.({
576
+ * menu sliding into a picker rather than a second surface. The
577
+ * popup's ONLY trigger is that Language row, so the branded
578
+ * desktop face (no dropdown) has no carrier for it either —
579
+ * an inert popup with a dead trigger is exactly the dead-tree
580
+ * shape this contract refuses to mount. */}
581
+ {!brandedMenuFace.value && slots["locale-picker"]?.({
484
582
  open: localePickerOpen.value,
485
583
  onUpdateOpen: (v: boolean) => { localePickerOpen.value = v; },
486
584
  triggerRef: userTriggerRef.value ?? null,
@@ -1,4 +1,5 @@
1
- import { defineComponent, h, type PropType, type VNode } from "vue";
1
+ import { defineComponent, h, type VNode } from "vue";
2
+ import { asPropType } from "../utils/typing";
2
3
 
3
4
  import HkSerpentineUnlock from "./HkSerpentineUnlock";
4
5
  import HkModal from "./HkModal";
@@ -36,7 +37,7 @@ export default defineComponent({
36
37
  trackingHint: { type: String, required: true },
37
38
  /** Corner-count range `[min, max]` — higher stakes, more turns. */
38
39
  turns: {
39
- type: Array as unknown as PropType<[number, number]>,
40
+ type: asPropType<[number, number]>(Array),
40
41
  default: null,
41
42
  },
42
43
  /** Deterministic lane seed (tests / design review). */
@@ -118,4 +118,24 @@ describe("the public slot-type contract (L39)", () => {
118
118
  expect(faceSlots).toEqual({});
119
119
  expect(headerSlots).toEqual({});
120
120
  });
121
+
122
+ it("the brand slot is a zero-param render (the static-mark contract)", () => {
123
+ // Both legs of the contract bite at COMPILE time, through the
124
+ // COMPONENT's unwrapped slots type — the aggregate alias itself is
125
+ // a symbol-keyed container (SlotsType<T> = { [SlotSymbol]?: T }),
126
+ // where `{} as HkAdminHeaderSlots` compiles regardless of the inner
127
+ // optionality, so the alias-level pins are blind to it:
128
+ // - REQUIRED-SLOT leg: `undefined extends typeof slots.brand` holds
129
+ // only while `brand` keeps its undefined member (optional). Making
130
+ // the slot required flips the conditional to `never`, and the
131
+ // `const ... : never = true` line fails vue-tsc on THIS file.
132
+ // - ZERO-PARAM leg: the call must still typecheck with no arguments
133
+ // — a payload parameter would be a contract change, not an
134
+ // addition (a static site mark has no state to hand down).
135
+ // The type alias keeps the extraction purely type-level — no
136
+ // value-side cast for the escape ratchet to count (review R2''' S1).
137
+ type HeaderSlots = InstanceType<typeof barrel.HkAdminHeader>["$slots"];
138
+ const brandStaysOptional: undefined extends HeaderSlots["brand"] ? true : never = true;
139
+ expect(brandStaysOptional).toBe(true);
140
+ });
121
141
  });
@@ -376,7 +376,7 @@ describe("HkMenu sidebar icon rail", () => {
376
376
  expect(c.querySelector(".hk-menu-sidebar-rail-children")).toBeNull();
377
377
  });
378
378
 
379
- it("uses the group icon as its glyph and parks the state caret in the corner", async () => {
379
+ it("makes the state caret the primary glyph and demotes the group icon to the corner", async () => {
380
380
  const c = mountMenu(
381
381
  [
382
382
  {
@@ -389,27 +389,55 @@ describe("HkMenu sidebar icon rail", () => {
389
389
  { collapsed: true },
390
390
  );
391
391
 
392
- // A declared icon owns the glyph cell; the state caret moves out of
393
- // the column into the corner so the icon stays rail-centered.
392
+ // 2026-11-20 (ERP media rail): expandability is what the rail
393
+ // communicates, so the CARET owns the glyph cell and the declared
394
+ // group icon demotes to the bottom-end corner badge (still paired by
395
+ // data-flip-icon for the density flight).
394
396
  const group = groupRows(c)[0]!;
395
397
  const glyph = group.querySelector(".hk-menu-item-icon")!;
396
- expect(glyph.querySelector("svg"), "the declared icon is the glyph").toBeTruthy();
397
398
  expect(
398
399
  glyph.querySelector(".hk-menu-rail-caret"),
399
- "no placeholder caret in the glyph cell",
400
- ).toBeNull();
401
- const corner = group.querySelector(".hk-menu-rail-caret-corner .hk-menu-rail-caret");
402
- expect(corner, "the state caret parks in the corner").toBeTruthy();
403
- expect(corner!.classList.contains("lucide-chevron-right")).toBe(true);
400
+ "the state caret is the primary glyph",
401
+ ).toBeTruthy();
402
+ expect(glyph.classList.contains("lucide-chevron-right")).toBe(false);
403
+ const corner = group.querySelector(".hk-menu-rail-glyph-corner svg")!;
404
+ expect(corner, "the declared icon parks in the corner").toBeTruthy();
404
405
 
405
- // Opening swaps the corner glyph to ChevronDown; the icon stays put.
406
+ // Opening swaps the caret glyph to ChevronDown; the icon stays put.
406
407
  group.click();
407
408
  await nextTick();
408
409
  expect(
409
410
  groupRows(c)[0]!
410
- .querySelector(".hk-menu-rail-caret-corner .hk-menu-rail-caret")!
411
+ .querySelector(".hk-menu-item-icon .hk-menu-rail-caret")!
411
412
  .classList.contains("lucide-chevron-down"),
412
413
  ).toBe(true);
414
+ expect(
415
+ groupRows(c)[0]!.querySelector(".hk-menu-rail-glyph-corner"),
416
+ "the icon corner persists after opening",
417
+ ).toBeTruthy();
418
+ });
419
+
420
+ it("marks the rail group CORNER badge so the flight hides it (no duplicate glyph)", () => {
421
+ // 2026-11-20: the rail group renders the caret as its glyph and the
422
+ // declared icon as a demoted corner chip. The chip carries
423
+ // data-flip-icon so useRailIconFlight pairs it with the expanded
424
+ // icon — and the single-glyph hide rule must cover BOTH cell classes
425
+ // (the corner chip is not a .hk-menu-item-icon), or the old icon
426
+ // stays painted through the whole flight.
427
+ const c = mountMenu(
428
+ [
429
+ {
430
+ key: "admin",
431
+ label: "Administration",
432
+ icon: Settings,
433
+ children: [{ key: "users", label: "Users", icon: Home }],
434
+ },
435
+ ],
436
+ { collapsed: true },
437
+ );
438
+ const corner = groupRows(c)[0]!.querySelector<HTMLElement>(".hk-menu-rail-glyph-corner");
439
+ expect(corner, "the demoted icon chip renders").toBeTruthy();
440
+ expect(corner!.getAttribute("data-flip-icon"), "the chip opts into the flight").toBe("admin");
413
441
  });
414
442
 
415
443
  it("falls back to the label initial for icon-less LEAF rows", () => {
@@ -429,10 +457,15 @@ describe("HkMenu sidebar icon rail", () => {
429
457
  // welding that turns a literal drift in HkMenu's JSX (or the JS
430
458
  // pairing vocabulary) into a red test instead of a silently dead
431
459
  // flight chain (2026-11-02 review).
460
+ // 2026-11-20 rail grammar: the group's icon is the DEMOTED corner
461
+ // chip (.hk-menu-rail-glyph-corner) while the caret owns the glyph
462
+ // cell — so the rail-side query must cover BOTH cell classes.
432
463
  const iconKeys = (root: ParentNode): string[] =>
433
- [...root.querySelectorAll<HTMLElement>(`.hk-menu-item-icon[${RAIL_FLIP_ICON_ATTR}]`)].map((el) =>
434
- el.getAttribute(RAIL_FLIP_ICON_ATTR) ?? "",
435
- );
464
+ [
465
+ ...root.querySelectorAll<HTMLElement>(
466
+ `.hk-menu-item-icon[${RAIL_FLIP_ICON_ATTR}], .hk-menu-rail-glyph-corner[${RAIL_FLIP_ICON_ATTR}]`,
467
+ ),
468
+ ].map((el) => el.getAttribute(RAIL_FLIP_ICON_ATTR) ?? "");
436
469
 
437
470
  // An icon on the group exercises the group-toggle sites; the
438
471
  // icon-less leaf exercises the asymmetry the flight tolerates: the
@@ -141,6 +141,8 @@
141
141
  margin-top: var(--space-2, 2px);
142
142
  }
143
143
 
144
+
145
+
144
146
  .hk-menu-sidebar-badge {
145
147
  margin-inline-start: auto;
146
148
  display: inline-flex;
@@ -213,15 +215,19 @@
213
215
  opacity: 0.55;
214
216
  }
215
217
 
216
- /* Groups that DO carry an icon: the state caret parks in the
217
- * inline-end corner (opposite the badge dot, which sits at the block
218
- * start) so the icon glyph keeps its rail-centered column. */
219
- .hk-menu-rail-caret-corner {
218
+
219
+ /* 2026-11-20 (ERP media rail): the demoted GROUP ICON badge —
220
+ * mirrors the old caret corner slot. The caret is now the row's
221
+ * primary glyph (icon cell), and the group icon shrinks into the
222
+ * inline-end corner so the rail reads expandability first,
223
+ * affiliation second. */
224
+ .hk-menu-rail-glyph-corner {
220
225
  position: absolute;
221
226
  inset-block-end: var(--space-2, 2px);
222
- inset-inline-end: var(--space-4, 4px);
227
+ inset-inline-end: var(--space-2, 2px);
223
228
  display: inline-flex;
224
229
  pointer-events: none;
230
+ opacity: 0.75;
225
231
  }
226
232
  }
227
233
 
@@ -1124,4 +1124,106 @@ describe("HkMenu cascade against an app-chrome band", () => {
1124
1124
  await settle();
1125
1125
  expect(popoutHosts()[0]?.style.left).toBe("1016px"); // frame.x + gutter
1126
1126
  });
1127
+ it("animates the group body open and closed (WAAPI height fold)", async () => {
1128
+ // happy-dom has no WAAPI and reports scrollHeight 0; stub both so the
1129
+ // disclosure hooks take their animated path and we can inspect the
1130
+ // keyframes they build.
1131
+ const frames: Keyframe[][] = [];
1132
+ const stubbed = vi.fn((keyframes: Keyframe[]) => {
1133
+ frames.push(keyframes);
1134
+ // Type the stub as the zero-arg slice it really implements, so the
1135
+ // single cast below is a structural subset (legal without
1136
+ // double-casting) and the onfinish call site stays zero-arg.
1137
+ const animation: { onfinish: (() => void) | null; cancel: () => void } = {
1138
+ onfinish: null,
1139
+ cancel: vi.fn(() => {}),
1140
+ };
1141
+ // Fire the finish callback on the next macrotask so the Transition
1142
+ // settles exactly like a real browser completing the fold.
1143
+ setTimeout(() => animation.onfinish?.(), 0);
1144
+ return animation as Animation;
1145
+ });
1146
+ Object.defineProperty(HTMLElement.prototype, "animate", {
1147
+ configurable: true,
1148
+ value: stubbed,
1149
+ });
1150
+ Object.defineProperty(HTMLElement.prototype, "scrollHeight", {
1151
+ configurable: true,
1152
+ get: () => 120,
1153
+ });
1154
+
1155
+ const container = document.createElement("div");
1156
+ document.body.appendChild(container);
1157
+ containers.push(container);
1158
+ const app = createApp({
1159
+ render: () =>
1160
+ h(HkMenu, {
1161
+ variant: "sidebar",
1162
+ open: true,
1163
+ items: [
1164
+ {
1165
+ key: "system",
1166
+ label: "System",
1167
+ children: [{ key: "general", label: "General" }],
1168
+ },
1169
+ ],
1170
+ }),
1171
+ });
1172
+ mounts.push(app);
1173
+ app.mount(container);
1174
+ await settle();
1175
+
1176
+ const toggle = container.querySelector(
1177
+ ".hk-menu-sidebar-group-toggle",
1178
+ ) as HTMLButtonElement;
1179
+ toggle.click();
1180
+ await settle();
1181
+
1182
+ expect(stubbed, "opening folds the body with a height tween").toHaveBeenCalled();
1183
+ expect(frames[0]?.[0]).toEqual({ height: "0px" });
1184
+ expect(frames[0]?.[1]).toEqual({ height: "120px" });
1185
+
1186
+ toggle.click();
1187
+ await settle();
1188
+ expect(stubbed.mock.calls.length, "closing folds it back").toBeGreaterThan(1);
1189
+ expect(frames.at(-1)?.[1]).toEqual({ height: "0px" });
1190
+
1191
+ // Restore the environment for the other tests in this file.
1192
+ delete (HTMLElement.prototype as { animate?: unknown }).animate;
1193
+ delete (HTMLElement.prototype as { scrollHeight?: unknown }).scrollHeight;
1194
+ });
1195
+
1196
+ it("skips the fold animation under the global animation switch", async () => {
1197
+ const stubbed = vi.fn();
1198
+ Object.defineProperty(HTMLElement.prototype, "animate", {
1199
+ configurable: true,
1200
+ value: stubbed,
1201
+ });
1202
+ document.documentElement.setAttribute("data-css-animations", "0");
1203
+
1204
+ const container = document.createElement("div");
1205
+ document.body.appendChild(container);
1206
+ containers.push(container);
1207
+ const app = createApp({
1208
+ render: () =>
1209
+ h(HkMenu, {
1210
+ variant: "sidebar",
1211
+ open: true,
1212
+ items: [
1213
+ { key: "system", label: "System", children: [{ key: "general", label: "General" }] },
1214
+ ],
1215
+ }),
1216
+ });
1217
+ mounts.push(app);
1218
+ app.mount(container);
1219
+ await settle();
1220
+
1221
+ (container.querySelector(".hk-menu-sidebar-group-toggle") as HTMLButtonElement).click();
1222
+ await settle();
1223
+
1224
+ expect(stubbed, "the veto makes the fold instant").not.toHaveBeenCalled();
1225
+ document.documentElement.removeAttribute("data-css-animations");
1226
+ delete (HTMLElement.prototype as { animate?: unknown }).animate;
1227
+ });
1228
+
1127
1229
  });