@celestia-island/hikari 0.55.476 → 0.55.477

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.
@@ -165,6 +165,22 @@ export interface HkFaceShellUserPanelSlot {
165
165
  */
166
166
  export type HkFaceShellSlots = SlotsType<{
167
167
  header?: (params: HkFaceShellHeaderSlot) => VNode[];
168
+ /**
169
+ * The header sub-row: a host-owned band rendered directly under the
170
+ * header and ABOVE the document scroll viewport. It is the "which scope
171
+ * am I in" line — the console's active-platform strip is its first
172
+ * consumer — and it is deliberately NOT inside the header slot: the
173
+ * header's three-zone grid (avatar | centre group | actions) has no free
174
+ * row, and a host-owned title there would compete with the page-owned
175
+ * centre group for the same track.
176
+ *
177
+ * Geometry: no wrapper box of the shell's own — the slot's VNodes are
178
+ * the band's boxes, so a slot that renders nothing reserves nothing.
179
+ * The band does not scroll (it sits above the viewport), so it stays put
180
+ * while the page scrolls, and it never takes part in the content padding
181
+ * contract: the page body below keeps its gutters exactly as before.
182
+ */
183
+ headerExtra?: () => VNode[];
168
184
  sidebar?: (params: HkFaceShellSidebarSlot) => VNode[];
169
185
  userPanel?: (params: HkFaceShellUserPanelSlot) => VNode[];
170
186
  content?: () => VNode[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celestia-island/hikari",
3
- "version": "0.55.476",
3
+ "version": "0.55.477",
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",
@@ -179,6 +179,11 @@ export const HkAdminShell = defineComponent({
179
179
  // shell that stops relaying the field goes red there.
180
180
  })
181
181
  : undefined,
182
+ // The header sub-row rides through verbatim: this face has no
183
+ // opinion on the band (it is the host's scope label, not chrome
184
+ // the wrapper can synthesize), and dropping it here would make
185
+ // the admin face silently narrower than the shell it composes.
186
+ headerExtra: slots.headerExtra,
182
187
  sidebar: slots.sidebar,
183
188
  userPanel: slots.userPanel,
184
189
  content: slots.content,
@@ -0,0 +1,208 @@
1
+ import { afterEach, describe, expect, it, vi } from "vitest";
2
+ import { createApp, defineComponent, h, nextTick, ref, type VNode } from "vue";
3
+
4
+ // HDrawer teleports and animates. This file never opens the drawer (the
5
+ // band sits outside the body that hosts it), so a deliberately MINIMAL
6
+ // closed-drawer stub is enough: it renders the slot only when open, with
7
+ // none of the `drawer-stub` body/footer classes HkFaceShell.test.tsx needs.
8
+ vi.mock("@celestia-island/hikari", async (importOriginal) => {
9
+ const actual = await importOriginal<typeof import("@celestia-island/hikari")>();
10
+ const { defineComponent, h } = await import("vue");
11
+ const HDrawerStub = defineComponent({
12
+ name: "HDrawer",
13
+ props: {
14
+ modelValue: { type: Boolean, default: false },
15
+ side: { type: String, default: "left" },
16
+ size: { type: String, default: "280px" },
17
+ title: { type: String, default: undefined },
18
+ panelClass: { type: String, default: undefined },
19
+ },
20
+ setup(props, { slots }) {
21
+ return () => (props.modelValue ? h("div", slots.default?.()) : null);
22
+ },
23
+ });
24
+ return { ...actual, HDrawer: HDrawerStub };
25
+ });
26
+
27
+ import { HkFaceShell } from "./HkFaceShell";
28
+ import { HkAdminShell } from "./HkAdminShell";
29
+
30
+ /**
31
+ * `headerExtra` — the header sub-row (2026-11-24). What this file pins:
32
+ *
33
+ * 1. GEOMETRY: the band renders directly under the header and ABOVE the
34
+ * body, so it inherits the header's full width and sits clear of the
35
+ * document scroll viewport — a scope line must not scroll away with
36
+ * the page it scopes.
37
+ * 2. NO WRAPPER: the slot's VNodes are the band's boxes. The shell adds
38
+ * no box of its own, so a host that styles its band keeps its own
39
+ * geometry, and an empty slot reserves nothing.
40
+ * 3. HkAdminShell RELAYS the slot verbatim: the admin wrapper has no
41
+ * opinion on the band, and dropping it there would make the admin face
42
+ * silently narrower than the shell it composes.
43
+ *
44
+ * (Repo test convention: raw createApp + container queries.)
45
+ */
46
+
47
+ const mounts: Array<{ app: ReturnType<typeof createApp>; container: HTMLElement }> = [];
48
+
49
+ function mount(node: VNode) {
50
+ const container = document.createElement("div");
51
+ document.body.appendChild(container);
52
+ const app = createApp({ render: () => node });
53
+ app.mount(container);
54
+ mounts.push({ app, container });
55
+ return container;
56
+ }
57
+
58
+ afterEach(() => {
59
+ for (const { app, container } of mounts.splice(0)) {
60
+ app.unmount();
61
+ container.remove();
62
+ }
63
+ });
64
+
65
+ const CONTENT = () => h("main", { class: "content-mock" }, "CONTENT");
66
+ const HEADER = () => h("div", { class: "header-mock" }, "HEADER");
67
+ const BAND = () => h("div", { class: "band-mock" }, "ACTIVE PANEL");
68
+
69
+ /** The shell's own boxes in DOM order, named by their first class. */
70
+ function ordered(c: HTMLElement, selector: string): string[] {
71
+ return [...c.querySelectorAll(selector)].map((el) => el.className.split(" ")[0]);
72
+ }
73
+
74
+ describe("HkFaceShell headerExtra", () => {
75
+ it("renders the band under the header and above the body, outside the scroll viewport", () => {
76
+ const c = mount(h(HkFaceShell, { navTitle: "Navigation" }, {
77
+ header: HEADER,
78
+ headerExtra: BAND,
79
+ content: CONTENT,
80
+ }));
81
+ const band = c.querySelector(".band-mock");
82
+ expect(band, "the band renders").toBeTruthy();
83
+ expect(band!.textContent).toBe("ACTIVE PANEL");
84
+ // Order: header → band → body (document mode's viewport lives inside body).
85
+ expect(ordered(c, ".header-mock,.band-mock,.s-admin-shell-body")).toEqual([
86
+ "header-mock",
87
+ "band-mock",
88
+ "s-admin-shell-body",
89
+ ]);
90
+ // The whole point: the band is NOT inside the scroll viewport.
91
+ expect(band!.closest(".hk-scroll-container-viewport")).toBeNull();
92
+ expect(band!.closest(".hk-scroll-container")).toBeNull();
93
+ expect(band!.closest(".s-admin-shell-body")).toBeNull();
94
+ // It is also not inside the header: the header's three-zone grid has
95
+ // no free row, and a host scope line must not compete with the page's
96
+ // centre group. The guard is the PARENT (the root), not `closest` — a
97
+ // band moved into the header wrapper becomes a SIBLING of the header
98
+ // mock, so `closest(".header-mock")` would stay null there (review R2).
99
+ expect(band!.parentElement).toBe(c.querySelector(".s-admin-shell"));
100
+ });
101
+
102
+ it("adds no wrapper box of its own — the slot's VNode IS the band", () => {
103
+ const c = mount(h(HkFaceShell, { navTitle: "Navigation" }, {
104
+ header: HEADER,
105
+ headerExtra: BAND,
106
+ content: CONTENT,
107
+ }));
108
+ const band = c.querySelector(".band-mock")!;
109
+ // The band's parent is the shell root itself, not an intermediate
110
+ // container the shell synthesized around the slot.
111
+ expect(band.parentElement!.classList.contains("s-admin-shell")).toBe(true);
112
+ // The header lives in the shell's own flex-shrink wrapper; the band
113
+ // sits beside that wrapper as a sibling, which is what keeps it out
114
+ // of the header's three-zone grid.
115
+ const headerBox = c.querySelector(".header-mock")!.parentElement!;
116
+ expect(headerBox.classList.contains("s-admin-shell")).toBe(false);
117
+ expect(band.previousElementSibling).toBe(headerBox);
118
+ });
119
+
120
+ it("reserves nothing when the slot is absent or empty, and renders exactly one band when filled", () => {
121
+ // Name each root child by its first class, or by its tag when it carries
122
+ // none (the header wrapper is a bare `<div style="flex-shrink: 0">`).
123
+ const rootChildren = (c: HTMLElement) =>
124
+ [...c.querySelector(".s-admin-shell")!.children]
125
+ .map((el) => el.className.split(" ")[0] || el.tagName.toLowerCase());
126
+ const absent = mount(h(HkFaceShell, { navTitle: "Navigation" }, {
127
+ header: HEADER, content: CONTENT,
128
+ }));
129
+ const empty = mount(h(HkFaceShell, { navTitle: "Navigation" }, {
130
+ header: HEADER, headerExtra: () => [], content: CONTENT,
131
+ }));
132
+ const filled = mount(h(HkFaceShell, { navTitle: "Navigation" }, {
133
+ header: HEADER, headerExtra: BAND, content: CONTENT,
134
+ }));
135
+ // Absent: the root holds the header wrapper and the body, nothing else.
136
+ expect(rootChildren(absent)).toEqual(["div", "s-admin-shell-body"]);
137
+ expect(absent.querySelector(".band-mock")).toBeNull();
138
+ // EMPTY slot ≡ absent: the literal "an empty slot reserves nothing".
139
+ // (The header wrapper is conditional on `slots.header`, so both mounts
140
+ // carry it; the list is identical.)
141
+ expect(rootChildren(empty)).toEqual(rootChildren(absent));
142
+ expect(empty.querySelector(".band-mock")).toBeNull();
143
+ // Filled: exactly ONE band, as the body's immediately preceding sibling.
144
+ // Asserting the full list (not a count delta) is what catches a shell-
145
+ // synthesized wrapper AND a duplicate render (review R2, M2 / M6).
146
+ expect(rootChildren(filled)).toEqual(["div", "band-mock", "s-admin-shell-body"]);
147
+ expect(filled.querySelectorAll(".band-mock").length).toBe(1);
148
+ const band = filled.querySelector(".band-mock")!;
149
+ expect(band.nextElementSibling).toBe(filled.querySelector(".s-admin-shell-body"));
150
+ // The main region is untouched by the band in every case.
151
+ expect(filled.querySelector(".s-admin-shell-main")!.children.length)
152
+ .toBe(absent.querySelector(".s-admin-shell-main")!.children.length);
153
+ });
154
+
155
+ it("keeps the band outside the contentKey crossfade so a page swap leaves it in place", async () => {
156
+ // A tiny host whose key is a ref, so the swap is driven for real: the
157
+ // ruling's promise is "a page swap leaves the band in place", and that
158
+ // is only testable by swapping (review R2).
159
+ const page = ref("page-a");
160
+ const Host = defineComponent({
161
+ setup() {
162
+ return () => h(HkFaceShell, { navTitle: "Navigation", contentKey: page.value }, {
163
+ header: HEADER,
164
+ headerExtra: BAND,
165
+ content: () => h("main", { class: "content-mock" }, page.value),
166
+ });
167
+ },
168
+ });
169
+ const c = mount(h(Host));
170
+ const bandBefore = c.querySelector(".band-mock");
171
+ expect(bandBefore, "the band renders").toBeTruthy();
172
+ expect(bandBefore!.closest(".hk-crossfade")).toBeNull();
173
+ expect(bandBefore!.closest(".s-admin-shell-swap")).toBeNull();
174
+ expect(c.querySelector('[data-crossfade-key="page-a"] .content-mock')!.textContent).toBe("page-a");
175
+ page.value = "page-b";
176
+ await nextTick();
177
+ // The page changed: the ENTERING crossfade item carries the new key
178
+ // (the leaving item stays in the DOM for its exit transition, which is
179
+ // why the lookup is by key rather than first-match)…
180
+ expect(c.querySelector('[data-crossfade-key="page-b"] .content-mock')!.textContent).toBe("page-b");
181
+ // …and the band is the SAME DOM node, not a re-mount. (This identity
182
+ // line catches a re-MOUNT; "band inside the crossfade" is caught by
183
+ // the structural `closest(".hk-crossfade")` guard above — Vue re-
184
+ // PARENTS a slot vnode into the entering item without re-mounting it,
185
+ // so identity alone would not notice. Review R3.)
186
+ expect(c.querySelector(".band-mock")).toBe(bandBefore);
187
+ });
188
+ });
189
+
190
+ describe("HkAdminShell relays headerExtra", () => {
191
+ it("passes the band through to the inner shell unchanged", () => {
192
+ // HkAdminShell provides its own action bar; mount it bare.
193
+ const c = mount(h(HkAdminShell, { navTitle: "Navigation" }, {
194
+ header: () => h("div", { class: "header-mock" }, "HEADER"),
195
+ headerExtra: BAND,
196
+ content: CONTENT,
197
+ }));
198
+ const band = c.querySelector(".band-mock");
199
+ expect(band, "the admin face renders the host's band").toBeTruthy();
200
+ expect(band!.textContent).toBe("ACTIVE PANEL");
201
+ expect(ordered(c, ".header-mock,.band-mock,.s-admin-shell-body")).toEqual([
202
+ "header-mock",
203
+ "band-mock",
204
+ "s-admin-shell-body",
205
+ ]);
206
+ expect(band!.closest(".hk-scroll-container-viewport")).toBeNull();
207
+ });
208
+ });
@@ -230,6 +230,22 @@ export interface HkFaceShellUserPanelSlot {
230
230
  */
231
231
  export type HkFaceShellSlots = SlotsType<{
232
232
  header?: (params: HkFaceShellHeaderSlot) => VNode[];
233
+ /**
234
+ * The header sub-row: a host-owned band rendered directly under the
235
+ * header and ABOVE the document scroll viewport. It is the "which scope
236
+ * am I in" line — the console's active-platform strip is its first
237
+ * consumer — and it is deliberately NOT inside the header slot: the
238
+ * header's three-zone grid (avatar | centre group | actions) has no free
239
+ * row, and a host-owned title there would compete with the page-owned
240
+ * centre group for the same track.
241
+ *
242
+ * Geometry: no wrapper box of the shell's own — the slot's VNodes are
243
+ * the band's boxes, so a slot that renders nothing reserves nothing.
244
+ * The band does not scroll (it sits above the viewport), so it stays put
245
+ * while the page scrolls, and it never takes part in the content padding
246
+ * contract: the page body below keeps its gutters exactly as before.
247
+ */
248
+ headerExtra?: () => VNode[];
233
249
  sidebar?: (params: HkFaceShellSidebarSlot) => VNode[];
234
250
  userPanel?: (params: HkFaceShellUserPanelSlot) => VNode[];
235
251
  content?: () => VNode[];
@@ -549,6 +565,13 @@ export const HkFaceShell = defineComponent({
549
565
  </div>
550
566
  )}
551
567
 
568
+ {/* The header sub-row: directly under the header, above the
569
+ body — so it inherits the header's full width and sits clear
570
+ of the content viewport's scrolling. Slot VNodes are NOT
571
+ wrapped: the consumer's element IS the band (see the slot
572
+ doc), and an empty slot renders no box at all. */}
573
+ {slots.headerExtra?.()}
574
+
552
575
  <div class="s-admin-shell-body" style={{ paddingBottom: footerPad() }}>
553
576
  {isDesktop.value && !props.sidebarCollapsed && slots.sidebar && (
554
577
  props.sidebarCollapsible ? (