@celestia-island/hikari 0.55.499 → 0.55.500

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.
@@ -97,9 +97,11 @@ export declare const HkAdminShell: import("vue").DefineComponent<import("vue").E
97
97
  type: StringConstructor;
98
98
  default: undefined;
99
99
  };
100
- /** Extra class for the mobile nav drawer's panel — lets consumers zero
101
- * nested paddings so drawer nav rows and a `userPanel` footer share
102
- * one left edge. */
100
+ /** Extra class for the mobile nav drawer's panel — a scoping hook for
101
+ * consumer chrome (theme/surface overrides). It is NOT a padding
102
+ * lever any more: the shell zeroes the drawer body's padding itself
103
+ * so the nav panel fills the drawer (see the HDrawer call below), so
104
+ * nav rows and the `userPanel` footer already share one left edge. */
103
105
  drawerPanelClass: {
104
106
  type: StringConstructor;
105
107
  default: undefined;
@@ -226,9 +228,11 @@ export declare const HkAdminShell: import("vue").DefineComponent<import("vue").E
226
228
  type: StringConstructor;
227
229
  default: undefined;
228
230
  };
229
- /** Extra class for the mobile nav drawer's panel — lets consumers zero
230
- * nested paddings so drawer nav rows and a `userPanel` footer share
231
- * one left edge. */
231
+ /** Extra class for the mobile nav drawer's panel — a scoping hook for
232
+ * consumer chrome (theme/surface overrides). It is NOT a padding
233
+ * lever any more: the shell zeroes the drawer body's padding itself
234
+ * so the nav panel fills the drawer (see the HDrawer call below), so
235
+ * nav rows and the `userPanel` footer already share one left edge. */
232
236
  drawerPanelClass: {
233
237
  type: StringConstructor;
234
238
  default: undefined;
@@ -272,9 +272,11 @@ export declare const HkFaceShell: import("vue").DefineComponent<import("vue").Ex
272
272
  type: StringConstructor;
273
273
  default: undefined;
274
274
  };
275
- /** Extra class for the mobile nav drawer's panel — lets consumers zero
276
- * nested paddings so drawer nav rows and a `userPanel` footer share
277
- * one left edge. */
275
+ /** Extra class for the mobile nav drawer's panel — a scoping hook for
276
+ * consumer chrome (theme/surface overrides). It is NOT a padding
277
+ * lever any more: the shell zeroes the drawer body's padding itself
278
+ * so the nav panel fills the drawer (see the HDrawer call below), so
279
+ * nav rows and the `userPanel` footer already share one left edge. */
278
280
  drawerPanelClass: {
279
281
  type: StringConstructor;
280
282
  default: undefined;
@@ -435,9 +437,11 @@ export declare const HkFaceShell: import("vue").DefineComponent<import("vue").Ex
435
437
  type: StringConstructor;
436
438
  default: undefined;
437
439
  };
438
- /** Extra class for the mobile nav drawer's panel — lets consumers zero
439
- * nested paddings so drawer nav rows and a `userPanel` footer share
440
- * one left edge. */
440
+ /** Extra class for the mobile nav drawer's panel — a scoping hook for
441
+ * consumer chrome (theme/surface overrides). It is NOT a padding
442
+ * lever any more: the shell zeroes the drawer body's padding itself
443
+ * so the nav panel fills the drawer (see the HDrawer call below), so
444
+ * nav rows and the `userPanel` footer already share one left edge. */
441
445
  drawerPanelClass: {
442
446
  type: StringConstructor;
443
447
  default: undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celestia-island/hikari",
3
- "version": "0.55.499",
3
+ "version": "0.55.500",
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",
@@ -85,9 +85,11 @@ export const HkAdminShell = defineComponent({
85
85
  * (e.g. `"var(--s-footer-height)"`). */
86
86
  footerHeight: { type: String, default: undefined },
87
87
  navTitle: { type: String, default: undefined },
88
- /** Extra class for the mobile nav drawer's panel — lets consumers zero
89
- * nested paddings so drawer nav rows and a `userPanel` footer share
90
- * one left edge. */
88
+ /** Extra class for the mobile nav drawer's panel — a scoping hook for
89
+ * consumer chrome (theme/surface overrides). It is NOT a padding
90
+ * lever any more: the shell zeroes the drawer body's padding itself
91
+ * so the nav panel fills the drawer (see the HDrawer call below), so
92
+ * nav rows and the `userPanel` footer already share one left edge. */
91
93
  drawerPanelClass: { type: String, default: undefined },
92
94
  /** Content-area padding (inside the scroll viewport). Padding is
93
95
  * applied to an inner wrapper rather than the scroll container so
@@ -1,9 +1,14 @@
1
1
  import { afterEach, describe, expect, it } from "vitest";
2
2
  import { createApp, defineComponent, h, nextTick, ref } from "vue";
3
+ import { readFileSync } from "node:fs";
4
+ import { dirname, resolve } from "node:path";
5
+ import { fileURLToPath } from "node:url";
3
6
 
4
7
  import HkDrawer from "./HkDrawer";
5
8
  import { usePopupManager } from "../runtime/usePopupManager";
6
9
 
10
+ const here = dirname(fileURLToPath(import.meta.url));
11
+
7
12
  const mounts: ReturnType<typeof createApp>[] = [];
8
13
  const containers: HTMLElement[] = [];
9
14
 
@@ -203,3 +208,65 @@ describe("HkDrawer Escape precedence", () => {
203
208
  expect(open.value).toBe(false);
204
209
  });
205
210
  });
211
+
212
+ /**
213
+ * The CONTAINER-PADDING contract on the drawer body (2026-11-27).
214
+ *
215
+ * `HkFaceShell`'s mobile nav drawer relies on `padding="none"` so the nav
216
+ * panel fills the drawer — and the panel's overlay scroll rail, which rides
217
+ * the panel's own edge, hugs the drawer edge instead of floating inside it.
218
+ * The shell-level test can only assert the PROP it passes; this pin holds
219
+ * the other half of the chain, so a regression in HkDrawer's plumbing (the
220
+ * prop no longer reaching `--hk-pad`, or the body rule no longer reading
221
+ * it) fails here rather than silently re-insetting every shell's nav.
222
+ *
223
+ * MUT: dropping `hkPadStyle(props.padding)` from the panel style, or
224
+ * changing `--hk-pad` in HkDrawer.scss's body padding rule, turns this RED.
225
+ */
226
+ describe("HkDrawer container padding contract", () => {
227
+ const scss = readFileSync(resolve(here, "./HkDrawer.scss"), "utf8");
228
+
229
+ function bodyRule(): string {
230
+ const css = scss.replace(/\/\*[\s\S]*?\*\//g, "").replace(/^\s*\/\/.*$/gm, "");
231
+ const at = css.indexOf(".hk-drawer-body {");
232
+ expect(at, "the .hk-drawer-body rule must exist").toBeGreaterThan(-1);
233
+ let depth = 0;
234
+ for (let i = css.indexOf("{", at); i < css.length; i += 1) {
235
+ if (css[i] === "{") depth += 1;
236
+ else if (css[i] === "}") {
237
+ depth -= 1;
238
+ if (depth === 0) return css.slice(at, i + 1);
239
+ }
240
+ }
241
+ return "";
242
+ }
243
+
244
+ it("the body's padding reads --hk-pad FIRST (the padding prop's arm)", () => {
245
+ // Order is the contract: an unset --hk-pad must fall back to the theme
246
+ // token and then the historical 1rem, but when a host passes
247
+ // padding="none" the token must win outright.
248
+ expect(bodyRule()).toMatch(/padding:\s*var\(\s*--hk-pad\b/);
249
+ });
250
+
251
+ it('maps padding="none" onto the token as 0', async () => {
252
+ const open = ref(true);
253
+ const container = document.createElement("div");
254
+ document.body.appendChild(container);
255
+ containers.push(container);
256
+ const app = createApp({
257
+ render: () =>
258
+ h(HkDrawer, { modelValue: open.value, padding: "none" }, { default: () => h("div", "content") }),
259
+ });
260
+ mounts.push(app);
261
+ app.mount(container);
262
+ await nextTick();
263
+ await new Promise((resolve) => setTimeout(resolve, 0));
264
+ await nextTick();
265
+ const panel = document.querySelector<HTMLElement>(".hk-drawer-panel");
266
+ expect(panel, "the drawer panel renders").not.toBeNull();
267
+ // The custom property is what the body rule consumes; asserting it on
268
+ // the PANEL (its declaring element) proves the prop→token hop without
269
+ // depending on a CSS engine happy-dom does not run.
270
+ expect(panel!.style.getPropertyValue("--hk-pad").trim()).toBe("0");
271
+ });
272
+ });
@@ -7,6 +7,12 @@ import { createApp, defineComponent, h, inject, nextTick, type VNode } from "vue
7
7
  // HDrawer teleports and animates; replace it with an inline passthrough
8
8
  // (same stub shape as HkAdminShell.test.tsx) so the shell contract is
9
9
  // testable without the overlay runtime.
10
+ /** Records what the shell hands its mobile drawer. `padding` is the
11
+ * contract this file pins: a nav PANEL brings its own paddings, so the
12
+ * drawer body must add none (a 1rem body padding insets the panel and the
13
+ * overlay scroll rail that rides its edge — the 2026-11-27 field report). */
14
+ const drawerState = vi.hoisted(() => ({ padding: "unset" as string | undefined }));
15
+
10
16
  vi.mock("@celestia-island/hikari", async (importOriginal) => {
11
17
  const actual = await importOriginal<typeof import("@celestia-island/hikari")>();
12
18
  const { defineComponent, h } = await import("vue");
@@ -18,16 +24,30 @@ vi.mock("@celestia-island/hikari", async (importOriginal) => {
18
24
  size: { type: String, default: "280px" },
19
25
  title: { type: String, default: undefined },
20
26
  panelClass: { type: String, default: undefined },
27
+ padding: { type: String, default: undefined },
21
28
  },
22
29
  setup(props, { slots }) {
23
30
  return () =>
24
31
  props.modelValue
25
- ? h("div", { class: ["drawer-stub", props.panelClass] }, [
26
- h("div", { class: "drawer-stub-body" }, slots.default?.()),
32
+ ? ((drawerState.padding = props.padding),
33
+ h("div", { class: ["drawer-stub", props.panelClass] }, [
34
+ h(
35
+ "div",
36
+ {
37
+ class: "drawer-stub-body",
38
+ // The real HDrawer maps `padding` onto `--hk-pad` on the
39
+ // panel (runtime/containerPad) and the body consumes it.
40
+ // The stub renders that token on the body so the shell's
41
+ // obligation ("this drawer ends up unpadded") is observable
42
+ // without a CSS engine.
43
+ style: drawerState.padding === "none" ? { "--hk-pad": "0" } : undefined,
44
+ },
45
+ slots.default?.(),
46
+ ),
27
47
  slots.footer
28
48
  ? h("div", { class: "drawer-stub-footer" }, slots.footer())
29
49
  : null,
30
- ])
50
+ ]))
31
51
  : null;
32
52
  },
33
53
  });
@@ -338,3 +358,79 @@ describe("the contentMode attrs leak (R2 S2)", () => {
338
358
  expect(src, "and forwarded honestly").toContain("contentMode: props.contentMode,");
339
359
  });
340
360
  });
361
+
362
+ /**
363
+ * The MOBILE DRAWER host contract (2026-11-27 field report, phone
364
+ * screenshot: "侧边栏的滚动条没贴边" — the nav panel's scroll rail floated
365
+ * ~20px inside the drawer instead of hugging its edge).
366
+ *
367
+ * Root cause, measured on the docs hub: HkFaceShell handed HDrawer no
368
+ * `padding`, so the drawer body carried its 1rem default; the nav panel
369
+ * (which every consumer fills with `inDrawer ? "100%" : …`) was inset to
370
+ * the content box, and the shared overlay rail — attached to the panel's
371
+ * body band — rode the PANEL's edge, not the drawer's. Zeroing the drawer
372
+ * body's padding makes the panel fill it: rail right edge moved 260 → 276
373
+ * against a 280px panel (the engine's own 4px inset).
374
+ *
375
+ * MUT: dropping `padding="none"` from the shell's HDrawer turns this RED.
376
+ */
377
+ describe("mobile drawer: the nav panel fills it", () => {
378
+ it("passes padding=none so the panel (and its scroll rail) reaches the drawer edge", async () => {
379
+ const originalWidth = window.innerWidth;
380
+ Object.defineProperty(window, "innerWidth", { configurable: true, writable: true, value: 400 });
381
+ try {
382
+ let openDrawer: (() => void) | null = null;
383
+ let drawerSidebarParams: Record<string, unknown> | null = null;
384
+ drawerState.padding = "unset";
385
+ const c = mount(
386
+ h(
387
+ HkFaceShell,
388
+ { navTitle: "Navigation" },
389
+ {
390
+ header: (params: Record<string, unknown>) => {
391
+ openDrawer = params.onOpenDrawer as () => void;
392
+ return null;
393
+ },
394
+ content: CONTENT,
395
+ sidebar: (params: Record<string, unknown>) => {
396
+ drawerSidebarParams = params;
397
+ return h("div", { class: "nav-panel" }, "NAV");
398
+ },
399
+ },
400
+ ),
401
+ );
402
+ // Below the desktop breakpoint the shell renders the drawer host; it
403
+ // mounts closed, so open it the way the hamburger does.
404
+ expect(typeof openDrawer, "the shell must hand the header a drawer opener").toBe("function");
405
+ (openDrawer as unknown as () => void)();
406
+ await nextTick();
407
+ await nextTick();
408
+
409
+ const stub = c.ownerDocument.querySelector(".drawer-stub");
410
+ expect(stub, "the drawer opens below the breakpoint").not.toBeNull();
411
+ // THE contract: no body padding, so the panel fills the drawer.
412
+ expect(drawerState.padding).toBe("none");
413
+ // …and the panel is told it is in the drawer, which is what makes the
414
+ // consumers render `width: 100%`. Both halves must hold: padding alone
415
+ // would shrink a panel that still sizes itself to a fixed width.
416
+ expect(drawerSidebarParams).not.toBeNull();
417
+ expect(drawerSidebarParams!.inDrawer).toBe(true);
418
+ expect(drawerSidebarParams!.collapsed).toBe(false);
419
+ expect(stub!.querySelector(".nav-panel")).not.toBeNull();
420
+ // SECOND, INDEPENDENT guard: the DRAWER BODY must end up with no
421
+ // padding, asserted through the container-padding TOKEN the stub
422
+ // renders — not through the source text. Two earlier forms were
423
+ // rejected by review for the right reasons: a fixed window was passed
424
+ // by an unrelated `padding="none"` 1000+ chars away, and an anchored
425
+ // source slice could be satisfied by a COMMENT (`/* padding="none"
426
+ // retired above */`) while the prop was gone. Reading the rendered
427
+ // token has neither hole, and it is refactor-proof: a props-constant
428
+ // spread that still passes the prop keeps the token at 0.
429
+ const stubBody = stub!.querySelector<HTMLElement>(".drawer-stub-body");
430
+ expect(stubBody, "the drawer body renders").not.toBeNull();
431
+ expect(stubBody!.style.getPropertyValue("--hk-pad").trim()).toBe("0");
432
+ } finally {
433
+ Object.defineProperty(window, "innerWidth", { configurable: true, writable: true, value: originalWidth });
434
+ }
435
+ });
436
+ });
@@ -314,9 +314,11 @@ export const HkFaceShell = defineComponent({
314
314
  * value (e.g. `"var(--s-footer-height)"`). */
315
315
  footerHeight: { type: String, default: undefined },
316
316
  navTitle: { type: String, default: undefined },
317
- /** Extra class for the mobile nav drawer's panel — lets consumers zero
318
- * nested paddings so drawer nav rows and a `userPanel` footer share
319
- * one left edge. */
317
+ /** Extra class for the mobile nav drawer's panel — a scoping hook for
318
+ * consumer chrome (theme/surface overrides). It is NOT a padding
319
+ * lever any more: the shell zeroes the drawer body's padding itself
320
+ * so the nav panel fills the drawer (see the HDrawer call below), so
321
+ * nav rows and the `userPanel` footer already share one left edge. */
320
322
  drawerPanelClass: { type: String, default: undefined },
321
323
  /** Content host mode (see the component doc): `document` wraps the
322
324
  * content in the shell's scroll viewport + padding wrapper;
@@ -719,6 +721,16 @@ export const HkFaceShell = defineComponent({
719
721
  size="280px"
720
722
  title={props.navTitle ?? t("hikari::adminShell.navTitle", "Navigation")}
721
723
  panelClass={props.drawerPanelClass}
724
+ // NO BODY PADDING. The slot below is a nav PANEL, not prose:
725
+ // every consumer fills it (`width={inDrawer ? "100%" : …}`) and
726
+ // the panel brings its own paddings. HDrawer's 1rem body
727
+ // padding would inset that panel — and its overlay scroll rail,
728
+ // which rides the panel's own edge — leaving the rail floating
729
+ // ~20px inside the drawer instead of hugging it (2026-11-27
730
+ // field report, phone screenshot: "侧边栏的滚动条没贴边").
731
+ // Measured on the docs hub before/after: rail right edge 260 vs
732
+ // panel 280 (20px gap) → 276 (4px, the engine's standard inset).
733
+ padding="none"
722
734
  >
723
735
  {/* The drawer body carries the nav; a `userPanel` slot rides
724
736
  the drawer footer (identity + account actions) so mobile
@@ -93,7 +93,10 @@
93
93
 
94
94
  // Diamond: a true rhombus SVG polygon (see the node slot painter) —
95
95
  // the layout reserved a wide-short box (horizontal diagonal = width)
96
- // so the inscribed label band fits inside the rhombus waist.
96
+ // so the inscribed label band fits inside the rhombus waist. Its label
97
+ // carries a percentage cap as a GUARD, not a live constraint — the
98
+ // arithmetic in the label block below shows the cap never bites at the
99
+ // current sizing slope.
97
100
  &--diamond {
98
101
  position: relative;
99
102
  border: none;
@@ -117,7 +120,15 @@
117
120
  &__label {
118
121
  position: relative;
119
122
  z-index: 1;
120
- max-width: 72%;
123
+ // The layout sizes a node FROM its label (`labelWidth + 2 * NODE_PAD_X`
124
+ // in mermaid/layout.ts), so for rect/rounded/circle the box is exactly
125
+ // big enough for the text and a percentage cap can only ever CLIP it.
126
+ // The old 72% hit every shape: measured on docs.celestia.world
127
+ // 2026-11-27, 10 of 11 labels on a real diagram ellipsized ("markdown"
128
+ // → "markd…", "HTML" → "HT…"), and lifting the cap at runtime cleaned
129
+ // all 11. 100% keeps the ellipsis as a last resort while letting the
130
+ // sized box do its job.
131
+ max-width: 100%;
121
132
  overflow: hidden;
122
133
  text-overflow: ellipsis;
123
134
  white-space: nowrap;
@@ -125,6 +136,19 @@
125
136
  // (textClip.contract.test.ts) — 1.25 cuts g/j/p/q/y ink.
126
137
  line-height: 1.3;
127
138
  }
139
+
140
+ // The diamond keeps a cap because its label band is inscribed in the
141
+ // rhombus waist — but do the arithmetic before claiming it clips
142
+ // anything: the diamond zeroes its padding/border, so `100%` here IS the
143
+ // reserved box `labelWidth * 1.55 + 24`, and 0.72 * 1.55 = 1.116 > 1
144
+ // means the cap band is ALWAYS wider than the label (slack never drops
145
+ // below ~+21px across the whole range). So this changes nothing today:
146
+ // it is a guard for a future slope change, not a live constraint, and it
147
+ // is kept only so a smaller `1.55` cannot let the band spill past the
148
+ // waist.
149
+ &--diamond &__label {
150
+ max-width: 72%;
151
+ }
128
152
  }
129
153
 
130
154
  // ── Sequence ─────────────────────────────────────────────────────────
@@ -50,3 +50,35 @@ describe("mermaid cluster frame stylesheet contract", () => {
50
50
  expect(ruleFor(css, ".hk-mmd-group__label")).toMatch(/position:\s*absolute/);
51
51
  });
52
52
  });
53
+
54
+ /**
55
+ * Graph node labels must be allowed the width the LAYOUT already gave them.
56
+ *
57
+ * `mermaid/layout.ts` sizes a node from its own text
58
+ * (`labelWidth + 2 * NODE_PAD_X`), so the box is exactly big enough for the
59
+ * label. A percentage cap on the label can therefore only ever CLIP it —
60
+ * and one did: `max-width: 72%` ellipsized every graph label, which is what
61
+ * a real docs page showed on 2026-11-27 (`markdown` → `markd…`, `HTML` →
62
+ * `HT…`; measured on docs.celestia.world, 10 of 11 labels clipped, and all
63
+ * 11 clean once the cap was lifted at runtime).
64
+ *
65
+ * The diamond keeps its cap: its label band is inscribed in the rhombus
66
+ * waist, which is ALREADY narrower than the cap band (waist ≈ 0.675·box vs
67
+ * band 0.72·box), so the cap is latent — it neither binds the label nor
68
+ * protects the waist today, and is kept only as a guard for a future change
69
+ * of the diamond's sizing slope.
70
+ *
71
+ * MUT: restoring `max-width: 72%` on the base label rule turns this RED.
72
+ */
73
+ describe("mermaid graph label width contract", () => {
74
+ it("lets rect/rounded/circle labels use the box the layout sized for them", () => {
75
+ const css = compiled("HkMermaidDiagram.scss");
76
+ expect(ruleFor(css, ".hk-mmd-node__label")).toMatch(/max-width:\s*100%/);
77
+ });
78
+
79
+ it("keeps the narrow band for the diamond waist", () => {
80
+ const css = compiled("HkMermaidDiagram.scss");
81
+ const diamond = ruleFor(css, ".hk-mmd-node--diamond .hk-mmd-node__label");
82
+ expect(diamond).toMatch(/max-width:\s*72%/);
83
+ });
84
+ });
@@ -1,7 +1,7 @@
1
1
  <!doctype html>
2
2
  <html lang="en">
3
3
  <head>
4
- <meta name="hk-error-landing" content="v1 0.55.499 <dev>">
4
+ <meta name="hk-error-landing" content="v1 0.55.500 <dev>">
5
5
  <meta charset="utf-8" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1" />
7
7
  <meta name="robots" content="noindex" />