@celestia-island/hikari 0.55.447 → 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 +1 -1
- package/src/components/HkAdminHeader.test.tsx +159 -0
- package/src/components/HkAdminHeader.tsx +116 -18
- package/src/components/HkDeleteGateWindow.tsx +3 -2
- package/src/components/HkFaceShell.slots.test.ts +20 -0
- package/src/components/HkMenu.test.ts +10 -7
- package/src/components/HkNotificationBell.test.tsx +1 -1
- package/src/components/HkSearchInput.icons.test.tsx +47 -0
- package/src/components/HkSearchInput.tsx +3 -16
- package/src/components/HkSerpentineUnlock.tsx +2 -1
- package/src/components/adminHeaderBrand.contract.test.ts +95 -0
- package/src/styles/admin-tokens.scss +27 -0
package/package.json
CHANGED
|
@@ -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. `
|
|
53
|
-
* `center`, `emergency-stop-extra` and `theme-toggle` take
|
|
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
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
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
|
-
|
|
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
|
-
{
|
|
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
|
-
|
|
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
|
|
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:
|
|
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
|
});
|
|
@@ -1131,14 +1131,17 @@ describe("HkMenu cascade against an app-chrome band", () => {
|
|
|
1131
1131
|
const frames: Keyframe[][] = [];
|
|
1132
1132
|
const stubbed = vi.fn((keyframes: Keyframe[]) => {
|
|
1133
1133
|
frames.push(keyframes);
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
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(() => {}),
|
|
1137
1140
|
};
|
|
1138
1141
|
// Fire the finish callback on the next macrotask so the Transition
|
|
1139
1142
|
// settles exactly like a real browser completing the fold.
|
|
1140
1143
|
setTimeout(() => animation.onfinish?.(), 0);
|
|
1141
|
-
return animation as
|
|
1144
|
+
return animation as Animation;
|
|
1142
1145
|
});
|
|
1143
1146
|
Object.defineProperty(HTMLElement.prototype, "animate", {
|
|
1144
1147
|
configurable: true,
|
|
@@ -1186,8 +1189,8 @@ describe("HkMenu cascade against an app-chrome band", () => {
|
|
|
1186
1189
|
expect(frames.at(-1)?.[1]).toEqual({ height: "0px" });
|
|
1187
1190
|
|
|
1188
1191
|
// Restore the environment for the other tests in this file.
|
|
1189
|
-
delete (HTMLElement.prototype as
|
|
1190
|
-
delete (HTMLElement.prototype as
|
|
1192
|
+
delete (HTMLElement.prototype as { animate?: unknown }).animate;
|
|
1193
|
+
delete (HTMLElement.prototype as { scrollHeight?: unknown }).scrollHeight;
|
|
1191
1194
|
});
|
|
1192
1195
|
|
|
1193
1196
|
it("skips the fold animation under the global animation switch", async () => {
|
|
@@ -1220,7 +1223,7 @@ describe("HkMenu cascade against an app-chrome band", () => {
|
|
|
1220
1223
|
|
|
1221
1224
|
expect(stubbed, "the veto makes the fold instant").not.toHaveBeenCalled();
|
|
1222
1225
|
document.documentElement.removeAttribute("data-css-animations");
|
|
1223
|
-
delete (HTMLElement.prototype as
|
|
1226
|
+
delete (HTMLElement.prototype as { animate?: unknown }).animate;
|
|
1224
1227
|
});
|
|
1225
1228
|
|
|
1226
1229
|
});
|
|
@@ -628,7 +628,7 @@ describe("panel rows", () => {
|
|
|
628
628
|
addListener: () => {},
|
|
629
629
|
removeListener: () => {},
|
|
630
630
|
dispatchEvent: () => false,
|
|
631
|
-
})) as
|
|
631
|
+
})) as typeof window.matchMedia;
|
|
632
632
|
const cases: Array<[string, () => void, () => void]> = [
|
|
633
633
|
["bus parked", () => setReducedMotion(true), () => setReducedMotion(false)],
|
|
634
634
|
[
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { createApp, h, nextTick } from "vue";
|
|
3
|
+
import HkSearchInput from "./HkSearchInput";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* L176 icon pilot — visual equivalence proof (DOM structure): the lucide
|
|
7
|
+
* Search/X components must render the SAME svg shape the hand-drawn
|
|
8
|
+
* consts drew (circle+line for search, two crossing lines for clear).
|
|
9
|
+
* The clear BUTTON stays a bare button by contract — only the glyph
|
|
10
|
+
* changed (search_clear_stays_a_bare_button_by_contract).
|
|
11
|
+
*/
|
|
12
|
+
describe("HkSearchInput icon glyphs (L176 pilot)", () => {
|
|
13
|
+
it("renders lucide Search as the prefix icon (svg with circle child)", async () => {
|
|
14
|
+
const container = document.createElement("div");
|
|
15
|
+
document.body.appendChild(container);
|
|
16
|
+
const app = createApp({ render: () => h(HkSearchInput, { modelValue: "" }) });
|
|
17
|
+
app.mount(container);
|
|
18
|
+
await nextTick();
|
|
19
|
+
const icon = container.querySelector(".hk-search-input-icon svg");
|
|
20
|
+
expect(icon, "the prefix icon must be an svg inside .hk-search-input-icon").toBeTruthy();
|
|
21
|
+
expect(icon!.querySelector("circle"), "lucide Search draws a circle").toBeTruthy();
|
|
22
|
+
// lucide renders the diagonal as a <path> (same coordinates the
|
|
23
|
+
// hand-drawn <line> expressed: 21,21 → 16.65,16.65).
|
|
24
|
+
expect(icon!.querySelector("path,circle,line"), "lucide Search draws the diagonal").toBeTruthy();
|
|
25
|
+
app.unmount();
|
|
26
|
+
container.remove();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("renders lucide X as the clear icon (svg with 2 crossing lines, no circle)", async () => {
|
|
30
|
+
const container = document.createElement("div");
|
|
31
|
+
document.body.appendChild(container);
|
|
32
|
+
const app = createApp({ render: () => h(HkSearchInput, { modelValue: "hello" }) });
|
|
33
|
+
app.mount(container);
|
|
34
|
+
await nextTick();
|
|
35
|
+
const clear = container.querySelector("button[class*='clear'] svg, .hk-search-input-clear svg");
|
|
36
|
+
// fall back to any svg inside a button (the clear button's shape is contract-pinned)
|
|
37
|
+
const svgsInButtons = container.querySelectorAll("button svg");
|
|
38
|
+
const clearSvg = clear ?? (svgsInButtons.length > 0 ? svgsInButtons[0] : null);
|
|
39
|
+
expect(clearSvg, "the clear button must contain an svg").toBeTruthy();
|
|
40
|
+
// lucide renders both strokes as <path> (M18 6 6 18 / M6 6 18 18 —
|
|
41
|
+
// the same diagonals the hand-drawn <line> pair expressed).
|
|
42
|
+
expect(clearSvg!.querySelectorAll("path,line").length, "lucide X draws exactly 2 strokes").toBe(2);
|
|
43
|
+
expect(clearSvg!.querySelector("circle"), "lucide X has no circle").toBeNull();
|
|
44
|
+
app.unmount();
|
|
45
|
+
container.remove();
|
|
46
|
+
});
|
|
47
|
+
});
|
|
@@ -7,23 +7,10 @@ import {
|
|
|
7
7
|
type PropType,
|
|
8
8
|
type StyleValue,
|
|
9
9
|
} from "vue";
|
|
10
|
+
import { Search, X } from "lucide-vue-next";
|
|
10
11
|
import { useI18n } from "../i18n/context";
|
|
11
12
|
import "./HkSearchInput.scss";
|
|
12
13
|
|
|
13
|
-
const searchIcon = (
|
|
14
|
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
15
|
-
<circle cx="11" cy="11" r="8" />
|
|
16
|
-
<line x1="21" y1="21" x2="16.65" y2="16.65" />
|
|
17
|
-
</svg>
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
const clearIcon = (
|
|
21
|
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
22
|
-
<line x1="18" y1="6" x2="6" y2="18" />
|
|
23
|
-
<line x1="6" y1="6" x2="18" y2="18" />
|
|
24
|
-
</svg>
|
|
25
|
-
);
|
|
26
|
-
|
|
27
14
|
export default defineComponent({
|
|
28
15
|
name: "HkSearchInput",
|
|
29
16
|
// The styled box and the control are two nodes: the box is a chrome
|
|
@@ -130,7 +117,7 @@ export default defineComponent({
|
|
|
130
117
|
class={[...wrapperClass, (attrs as Record<string, unknown>).class]}
|
|
131
118
|
style={wrapperStyle()}
|
|
132
119
|
>
|
|
133
|
-
<span class="hk-search-input-icon"
|
|
120
|
+
<span class="hk-search-input-icon"><Search /></span>
|
|
134
121
|
<input
|
|
135
122
|
{...fieldAttrs()}
|
|
136
123
|
ref={inputRef}
|
|
@@ -151,7 +138,7 @@ export default defineComponent({
|
|
|
151
138
|
tabindex={-1}
|
|
152
139
|
aria-label={props.clearAriaLabel || t("hikari::searchInput.clear", "Clear search")}
|
|
153
140
|
>
|
|
154
|
-
|
|
141
|
+
<X />
|
|
155
142
|
</button>
|
|
156
143
|
) : null}
|
|
157
144
|
</div>
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
type PropType,
|
|
7
7
|
watch,
|
|
8
8
|
} from "vue";
|
|
9
|
+
import { asPropType } from "../utils/typing";
|
|
9
10
|
|
|
10
11
|
import {
|
|
11
12
|
DEFAULT_TURNS,
|
|
@@ -62,7 +63,7 @@ export default defineComponent({
|
|
|
62
63
|
* higher-stakes deletions can ask for more turns.
|
|
63
64
|
*/
|
|
64
65
|
turns: {
|
|
65
|
-
type:
|
|
66
|
+
type: asPropType<[number, number]>(Array),
|
|
66
67
|
default: null,
|
|
67
68
|
},
|
|
68
69
|
/** Danger tone (delete-class actions) vs neutral. */
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Static pins for the admin header's opt-in brand slot (the lagrange
|
|
8
|
+
* relocation's upstream expansion #1: a host-supplied static site logo
|
|
9
|
+
* in the left wing). happy-dom has no layout engine, so — chromeBand
|
|
10
|
+
* -contract-style — these read the declarations themselves; reverting
|
|
11
|
+
* any pinned value keeps the rest of the suite green, so each pin below
|
|
12
|
+
* is the only red-if-broken evidence for its contract. A deliberate
|
|
13
|
+
* rewrite is expected to update them.
|
|
14
|
+
*
|
|
15
|
+
* The contract (full prose on the brandSrc prop and the brand slot
|
|
16
|
+
* entry of HkAdminHeaderSlots):
|
|
17
|
+
* 1. the slot is declared in the SlotsType aggregate (zero-param —
|
|
18
|
+
* a static mark has no state to hand down);
|
|
19
|
+
* 2. the desktop face renders the mark through ONE class,
|
|
20
|
+
* .s-admin-header-brand, and only while avatarAction is "menu"
|
|
21
|
+
* (the drawer face keeps its avatar trigger — that trigger IS the
|
|
22
|
+
* drawer path, so the mobile wing is invariant under the props);
|
|
23
|
+
* 3. the mark is NON-INTERACTIVE: rendered through the div variant
|
|
24
|
+
* of HkLogo (no href ever passed), no button semantics;
|
|
25
|
+
* 4. the face pins the pointer cursor OFF on the mark (HkLogo's
|
|
26
|
+
* standalone div carries cursor: pointer for its own hosts — a
|
|
27
|
+
* header identity must not promise a click) and drops the
|
|
28
|
+
* container rounding (site marks ship their own shape);
|
|
29
|
+
* 5. the mark rides the "sm" HkLogo step — the closest visual weight
|
|
30
|
+
* to the 28px identity trigger it replaces inside the 48px band.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
34
|
+
|
|
35
|
+
const adminHeader = readFileSync(join(here, "HkAdminHeader.tsx"), "utf8");
|
|
36
|
+
const adminTokens = readFileSync(join(here, "..", "styles", "admin-tokens.scss"), "utf8");
|
|
37
|
+
|
|
38
|
+
describe("admin header brand slot contract", () => {
|
|
39
|
+
it("declares the zero-param brand slot in the SlotsType aggregate", () => {
|
|
40
|
+
expect(adminHeader, "the brand slot entry must stay in the aggregate").toMatch(
|
|
41
|
+
/brand\?: \(\) => VNode\[\];/,
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("renders the mark on the desktop face only, through the one brand class", () => {
|
|
46
|
+
expect(adminHeader, "the render site must carry the brand class").toContain(
|
|
47
|
+
'class="s-admin-header-brand"',
|
|
48
|
+
);
|
|
49
|
+
// Drawer-face invariance: the face condition lives in ONE computed
|
|
50
|
+
// (brand mounted AND avatarAction "menu") that BOTH the mark render
|
|
51
|
+
// and the trigger suppression read — dropping the computed, or
|
|
52
|
+
// widening it past the menu face, would put a static mark in front
|
|
53
|
+
// of the mobile drawer's only opener (or strand the trigger beside
|
|
54
|
+
// the mark). All three legs pinned.
|
|
55
|
+
expect(adminHeader).toMatch(
|
|
56
|
+
/brandedMenuFace = computed\(\s*\(\) => brandMounted\.value && props\.avatarAction === "menu",?\s*\)/,
|
|
57
|
+
);
|
|
58
|
+
expect(adminHeader).toMatch(
|
|
59
|
+
/brandedMenuFace\.value && \(\s*<span class="s-admin-header-brand">/,
|
|
60
|
+
);
|
|
61
|
+
expect(adminHeader).toMatch(
|
|
62
|
+
/identityMounted\.value && !brandedMenuFace\.value && \(\s*<HkAvatarButton/,
|
|
63
|
+
);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("renders the mark non-interactively (div-variant HkLogo, no href)", () => {
|
|
67
|
+
// The fallback channel passes src/alt/size ONLY: an href would turn
|
|
68
|
+
// the identity into a control (anchor semantics, keyboard focus, a
|
|
69
|
+
// navigation promise the header never asked for).
|
|
70
|
+
expect(adminHeader).toMatch(
|
|
71
|
+
/<HkLogo src=\{props\.brandSrc\} alt=\{props\.brandAlt\} size="sm" \/>/,
|
|
72
|
+
);
|
|
73
|
+
expect(adminHeader).not.toMatch(/brandSrc[^>]*href=/);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("pins the mark's non-interactive geometry in the header stylesheet", () => {
|
|
77
|
+
// The wing box: fixed flex item, like the trigger box it replaced.
|
|
78
|
+
expect(adminTokens).toMatch(/\.s-admin-header-brand\s*\{[^}]*flex-shrink: 0;/);
|
|
79
|
+
// The identity-not-control pins: HkLogo's standalone div variant
|
|
80
|
+
// ships cursor: pointer (its own hosts click it); a header mark must
|
|
81
|
+
// read static, and its rounding would clip edge-to-edge wordmarks.
|
|
82
|
+
expect(adminTokens).toMatch(
|
|
83
|
+
/\.s-admin-header-brand \.hk-logo\s*\{[^}]*cursor: default;[^}]*\}/,
|
|
84
|
+
);
|
|
85
|
+
expect(adminTokens).toMatch(
|
|
86
|
+
/\.s-admin-header-brand \.hk-logo\s*\{[^}]*border-radius: 0;/,
|
|
87
|
+
);
|
|
88
|
+
// The img carries its OWN radius from HkLogo.scss — the container
|
|
89
|
+
// pin alone leaves a rounded mark (the .hk-logo rule does not reach
|
|
90
|
+
// .hk-logo-img). Both layers pinned.
|
|
91
|
+
expect(adminTokens).toMatch(
|
|
92
|
+
/\.s-admin-header-brand \.hk-logo-img\s*\{[^}]*border-radius: 0;/,
|
|
93
|
+
);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
@@ -666,6 +666,33 @@
|
|
|
666
666
|
flex-shrink: 0;
|
|
667
667
|
}
|
|
668
668
|
|
|
669
|
+
/* The brand slot's static site mark (HkAdminHeader, opt-in brandSrc /
|
|
670
|
+
* brand slot, desktop face). It takes the avatar trigger's spot in the
|
|
671
|
+
* left wing, so it behaves like the box it replaced: a fixed flex item
|
|
672
|
+
* that never shrinks and never grows. The mark is an identity, NOT a
|
|
673
|
+
* control — HkLogo's div variant carries a click emit for standalone
|
|
674
|
+
* hosts, so the header face pins the pointer cursor off, and it drops
|
|
675
|
+
* the container rounding: site marks ship their own shape, and a
|
|
676
|
+
* radius here would clip wordmark corners that were drawn edge-to-edge. */
|
|
677
|
+
.s-admin-header-brand {
|
|
678
|
+
display: inline-flex;
|
|
679
|
+
align-items: center;
|
|
680
|
+
flex-shrink: 0;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
.s-admin-header-brand .hk-logo {
|
|
684
|
+
cursor: default;
|
|
685
|
+
border-radius: 0;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
/* The img inside carries its OWN radius from HkLogo.scss — the container
|
|
689
|
+
* pin above does not reach it, and a rounded img would still clip a
|
|
690
|
+
* mark that was drawn edge-to-edge. Same identity-not-control family:
|
|
691
|
+
* this kills the rounding on both layers. */
|
|
692
|
+
.s-admin-header-brand .hk-logo-img {
|
|
693
|
+
border-radius: 0;
|
|
694
|
+
}
|
|
695
|
+
|
|
669
696
|
/* The old hover camera veil ("change avatar" affordance) is gone: the
|
|
670
697
|
* avatar trigger opens the account MENU — the avatar edit is the Camera
|
|
671
698
|
* item inside it — so the veil promised an action the click never
|