@celestia-island/hikari 0.55.495 → 0.55.496

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.
@@ -1,5 +1,31 @@
1
1
  import { type PropType } from "vue";
2
2
  import "./HkCornerText.scss";
3
+ /**
4
+ * Does a slot's returned tree paint NOTHING at all? The lane's dead-space
5
+ * rule must read the RENDERED nodes, not the slot's existence: Vue hands
6
+ * back a truthy value for every slot shape a host can write, so the
7
+ * original `!slotContent` test kept an invisible `.hk-corner-text` box
8
+ * (with the corner's flex margins) for a slot that renders `[]`, `[null]`,
9
+ * `false`, `""` or a whitespace-only string.
10
+ *
11
+ * The walk mirrors what Vue's own normalizer accepts:
12
+ * - `null` / `undefined` / booleans paint nothing (they normalize to a
13
+ * comment placeholder);
14
+ * - strings only paint when they carry a non-whitespace character — a
15
+ * blank string still mounts a text node, which occupies a flex row in
16
+ * the lane;
17
+ * - numbers always paint (`0` is real content);
18
+ * - a `Text` vnode paints when its children carry such a string;
19
+ * - `Fragment` vnodes (what a slot returning an array is wrapped in) and
20
+ * plain arrays recurse — they paint only what their children paint;
21
+ * - `Comment` vnodes never paint;
22
+ * - every other vnode (element, component, Teleport, Suspense) paints by
23
+ * definition.
24
+ *
25
+ * A function is NOT invoked here: Vue resolves slot functions, and calling
26
+ * a host's by hand could run it twice per render.
27
+ */
28
+ export declare function slotPaintsNothing(value: unknown): boolean;
3
29
  /** One entry of a corner text lane: plain text, or a link when `href`
4
30
  * is set (registry links open in a new tab with `noopener`, the same
5
31
  * contract as the beian filings). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celestia-island/hikari",
3
- "version": "0.55.495",
3
+ "version": "0.55.496",
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",
@@ -287,12 +287,30 @@ describe("HkAuthCard SCSS spacing contract", () => {
287
287
  expect(scss).not.toMatch(/\.s-auth-form:has\(\+ \.s-auth-methods\)/);
288
288
  });
289
289
 
290
- it("keeps the form's collapsed bottom padding feeding the footer band", () => {
290
+ it("keeps the form's collapsed bottom padding feeding the footer band (sibling pin)", () => {
291
291
  // The form→footer distance is composed (8px form padding-bottom via
292
292
  // :has + the footer's own margin); losing the collapse would swap in
293
- // the form's default 24px bottom padding instead.
294
- const rule = scss.match(/\.s-auth-form:has\(\.s-auth-footer\)\s*{[^}]*}/)?.[0] ?? "";
295
- expect(rule, ":has collapse rule must exist").toBeTruthy();
293
+ // the form's default 32px bottom padding instead.
294
+ const rule = scss.match(/\.s-auth-form:has\(\+ \.s-auth-footer\)\s*{[^}]*}/)?.[0] ?? "";
295
+ expect(rule, ":has(+ …) sibling collapse rule must exist").toBeTruthy();
296
296
  expect(rule).toContain("padding-bottom: var(--space-8, 0.5rem)");
297
+
298
+ // The DOM half — the card's footer IS a direct sibling of the form, so
299
+ // this is the arm that fires for every card-shaped surface (HkLoginFlow's
300
+ // swapped body needs the DESCENDANT arm; see HkLoginFlow.test.tsx).
301
+ // MUT:authcard-footer-shape-drift (nesting the footer inside the form,
302
+ // or emitting it before it, flips both assertions below).
303
+ const c = mount(
304
+ h(HkAuthCard, { title: "T" }, {
305
+ default: () => h("input", { class: "probe-field" }),
306
+ footer: () => h("div", { class: "probe-footer" }, "row"),
307
+ }),
308
+ );
309
+ const form = c.querySelector(".s-auth-form");
310
+ const footer = c.querySelector(".s-auth-footer");
311
+ expect(form).not.toBeNull();
312
+ expect(footer).not.toBeNull();
313
+ expect(footer!.previousElementSibling).toBe(form);
314
+ expect(form!.contains(footer)).toBe(false);
297
315
  });
298
316
  });
@@ -93,6 +93,39 @@ describe("HkCornerText", () => {
93
93
  expect(c.querySelector(".hk-corner-text")).toBeNull();
94
94
  });
95
95
 
96
+ it("treats a slot that PAINTS nothing as empty (the dead-space rule reads children, not the slot)", () => {
97
+ // A declared slot is always truthy, so `!slotContent` kept an
98
+ // invisible `.hk-corner-text` box (and the corner's flex margins with
99
+ // it) for every one of these shapes. The rule now walks the rendered
100
+ // nodes; each arm below is a shape a host writes by accident.
101
+ // MUT:corner-dead-space-slot-truthiness (restoring `!slotContent`
102
+ // renders the box for all of these and this goes red).
103
+ const emptyShapes: Array<[string, () => unknown]> = [
104
+ ["empty array", () => []],
105
+ ["nulls only", () => [null, null]],
106
+ ["false", () => false],
107
+ ["empty string", () => ""],
108
+ ["whitespace only", () => " "],
109
+ ["nested null array", () => [null]],
110
+ ];
111
+ for (const [label, slot] of emptyShapes) {
112
+ const c = mount(h(HkCornerText, { items: [] }, { default: slot as never }));
113
+ expect(c.querySelector(".hk-corner-text"), `slot shape "${label}" must not paint a lane`).toBeNull();
114
+ }
115
+ });
116
+
117
+ it("keeps the lane for slot children that DO paint (zero and text are content)", () => {
118
+ // The counterpart arm: the new check must not swallow real content.
119
+ // MUT:corner-dead-space-overreach (treating numbers as empty or
120
+ // dropping text nodes hides these lanes).
121
+ const zero = mount(h(HkCornerText, { items: [] }, { default: () => 0 }));
122
+ expect(zero.querySelector(".hk-corner-text")?.textContent).toBe("0");
123
+ const text = mount(h(HkCornerText, { items: [] }, { default: () => "苏ICP备" }));
124
+ expect(text.querySelector(".hk-corner-text")?.textContent).toBe("苏ICP备");
125
+ const nested = mount(h(HkCornerText, { items: [] }, { default: () => [[h("i", { class: "deep" }, "x")]] }));
126
+ expect(nested.querySelector(".hk-corner-text .deep")).not.toBeNull();
127
+ });
128
+
96
129
  it("as=nav marks a link lane as a labeled landmark; div stays unlabeled", () => {
97
130
  const c = mount(h(HkCornerText, { items, as: "nav", ariaLabel: "备案" }));
98
131
  const nav = c.querySelector("nav.hk-corner-text")!;
@@ -1,7 +1,50 @@
1
- import { defineComponent, type PropType } from "vue";
1
+ import { Comment, Fragment, Text, defineComponent, type PropType } from "vue";
2
2
 
3
3
  import "./HkCornerText.scss";
4
4
 
5
+ /**
6
+ * Does a slot's returned tree paint NOTHING at all? The lane's dead-space
7
+ * rule must read the RENDERED nodes, not the slot's existence: Vue hands
8
+ * back a truthy value for every slot shape a host can write, so the
9
+ * original `!slotContent` test kept an invisible `.hk-corner-text` box
10
+ * (with the corner's flex margins) for a slot that renders `[]`, `[null]`,
11
+ * `false`, `""` or a whitespace-only string.
12
+ *
13
+ * The walk mirrors what Vue's own normalizer accepts:
14
+ * - `null` / `undefined` / booleans paint nothing (they normalize to a
15
+ * comment placeholder);
16
+ * - strings only paint when they carry a non-whitespace character — a
17
+ * blank string still mounts a text node, which occupies a flex row in
18
+ * the lane;
19
+ * - numbers always paint (`0` is real content);
20
+ * - a `Text` vnode paints when its children carry such a string;
21
+ * - `Fragment` vnodes (what a slot returning an array is wrapped in) and
22
+ * plain arrays recurse — they paint only what their children paint;
23
+ * - `Comment` vnodes never paint;
24
+ * - every other vnode (element, component, Teleport, Suspense) paints by
25
+ * definition.
26
+ *
27
+ * A function is NOT invoked here: Vue resolves slot functions, and calling
28
+ * a host's by hand could run it twice per render.
29
+ */
30
+ export function slotPaintsNothing(value: unknown): boolean {
31
+ if (value === null || value === undefined || typeof value === "boolean") return true;
32
+ if (typeof value === "string") return value.trim().length === 0;
33
+ if (typeof value === "number") return false;
34
+ if (Array.isArray(value)) return value.every(slotPaintsNothing);
35
+ if (typeof value === "object") {
36
+ const vnode = value as { type?: unknown; children?: unknown };
37
+ if (vnode.type === Comment) return true;
38
+ if (vnode.type === Text) return slotPaintsNothing(vnode.children);
39
+ if (vnode.type === Fragment || Array.isArray(vnode.children)) {
40
+ return slotPaintsNothing(vnode.children);
41
+ }
42
+ return false;
43
+ }
44
+ // Symbol / bigint / function — nothing renders as a structural node.
45
+ return true;
46
+ }
47
+
5
48
  /** One entry of a corner text lane: plain text, or a link when `href`
6
49
  * is set (registry links open in a new tab with `noopener`, the same
7
50
  * contract as the beian filings). */
@@ -102,7 +145,7 @@ export const HkCornerText = defineComponent({
102
145
  ),
103
146
  );
104
147
  const slotContent = slots.default?.();
105
- const empty = entries.length === 0 && !slotContent;
148
+ const empty = entries.length === 0 && slotPaintsNothing(slotContent);
106
149
  if (empty) return null;
107
150
  const Tag = props.as;
108
151
  return (
@@ -611,14 +611,15 @@ describe("HkLoginFlow — stable shell channel swap (2026-11-24 user direction)"
611
611
  expect(document.activeElement).toBe(trigger);
612
612
  });
613
613
 
614
- it("extends the :has rhythm collapse to the bare fragment's descendant footer block (styles pin)", () => {
615
- // The stable shell's bare fragment renders the footer block as a
616
- // DESCENDANT of the shell's .s-auth-form — the sibling `:has(+ …)`
617
- // rule cannot see it, so the descendant variant carries the same
618
- // collapsed bottom padding (without it the form's full 24px bottom
619
- // padding stacks onto the footer's top margin).
620
- // MUT:r1487-rhythm-descendant (reverting to sibling-only rules
621
- // makes this match empty).
614
+ it("keeps the descendant :has arm that the flow's footer shape needs (structure pin)", () => {
615
+ // The shell's bare credential fragment renders the footer block inside
616
+ // the SWAPPED BODY, several levels below the shell's `.s-auth-form`
617
+ // (`.s-auth-form > .hk-login-flow-body > .hk-crossfade >
618
+ // .hk-crossfade-item > .s-auth-footer`). The sibling `:has(+ …)` rule
619
+ // above it therefore does NOT match this shape — this descendant arm
620
+ // is the only rule that does, so it is load-bearing, not a fallback.
621
+ // MUT:r1487-rhythm-descendant (reverting to sibling-only rules makes
622
+ // this match empty; the pin below then has nothing to assert).
622
623
  const here = dirname(fileURLToPath(import.meta.url));
623
624
  const scss = readFileSync(join(here, "../styles/admin-tokens.scss"), "utf-8");
624
625
  const collapse = scss.match(/\.s-auth-form:has\(\.s-auth-footer\)\s*{[^}]*}/g)?.join("\n") ?? "";
@@ -626,6 +627,29 @@ describe("HkLoginFlow — stable shell channel swap (2026-11-24 user direction)"
626
627
  expect(collapse).toContain("padding-bottom: var(--space-8, 0.5rem)");
627
628
  // The retired methods block's rules stay gone (2026-11-26 grammar).
628
629
  expect(scss).not.toContain(".s-auth-methods");
630
+
631
+ // The DOM half — the reason the rule above exists, asserted against the
632
+ // REAL tree instead of a prose claim. jsdom has no CSS engine, so the
633
+ // pin is structural: it proves the footer is a descendant (and NOT a
634
+ // sibling) of the form, which is exactly what makes the sibling arm
635
+ // miss and the descendant arm the only working one. Behavioral
636
+ // confirmation in a real engine: Chrome 155 computed
637
+ // `padding-bottom: 8px` on this form via the descendant arm, and
638
+ // deleting that single rule from the sheet flipped it to 32px.
639
+ // MUT:r1487-footer-shape-drift (moving the footer out to sit beside
640
+ // the form — or wrapping the fragment so no `.s-auth-form` covers it —
641
+ // makes `matches` below flip and this goes red).
642
+ const c = mount(h(HkLoginFlow, {
643
+ modelValue: "cloud",
644
+ channels: [cloudChannel],
645
+ }, { footer: () => h("div", { class: "probe-footer" }, "row") }));
646
+ const form = c.querySelector(".s-auth-form");
647
+ const footer = c.querySelector(".s-auth-footer");
648
+ expect(form, "the flow's credentials body must carry the shell's form block").not.toBeNull();
649
+ expect(footer, "a passed footer must render its block").not.toBeNull();
650
+ expect(form!.contains(footer), "the footer must be a DESCENDANT of the form").toBe(true);
651
+ expect(footer!.previousElementSibling, "the footer must NOT be the form's sibling").not.toBe(form);
652
+ expect(form!.querySelector(".s-auth-footer")).toBe(footer);
629
653
  });
630
654
 
631
655
  it("renders no footer band when the host passed no footer slot (flow-level dead-space guard)", () => {
@@ -1371,16 +1371,20 @@
1371
1371
  padding-bottom: var(--space-8, 0.5rem);
1372
1372
  }
1373
1373
 
1374
- /* The stable-shell shape (HkLoginFlow's bare sign-in fragment, 2026-11):
1375
- the footer block rides INSIDE the swapped channel body as a
1376
- DESCENDANT of the shell's form block, so the sibling rule above
1377
- cannot see that shape — collapse it with the same padding here (a
1378
- bare-fragment footer otherwise stacks the form's full bottom padding
1379
- onto the footer's top margin). A card whose block IS a direct child
1380
- already fires the sibling rule above with the same value, so this arm
1381
- changes nothing for it (HkLoginFlow is the only descendant-shaped
1382
- consumer today). Non-:has engines keep the full bottom padding in BOTH
1383
- shapes — the sibling rule degrades the same way (spacing-only). */
1374
+ /* The stable-shell shape (HkLoginFlow's bare sign-in fragment): the footer
1375
+ block rides INSIDE the swapped channel body, several levels below the
1376
+ shell's form block — `.s-auth-form > .hk-login-flow-body >
1377
+ .hk-crossfade > .hk-crossfade-item > .s-auth-footer` (measured in Chrome
1378
+ 155 on the shipped components, 2026-11-26) — so the sibling rule above
1379
+ cannot see that shape and this descendant arm collapses the same
1380
+ padding. Both arms are load-bearing and neither is redundant: on the
1381
+ flow's credentials body the sibling arm does NOT match (the footer is
1382
+ not a sibling of the form) and this arm is the only one that does;
1383
+ deleting it puts the form's 32px bottom padding back under the footer.
1384
+ A card whose block IS a direct child already fires the sibling arm with
1385
+ the same value, so this arm changes nothing for it. Non-:has engines
1386
+ keep the full bottom padding in BOTH shapes — the sibling rule degrades
1387
+ the same way (spacing-only). */
1384
1388
  .s-auth-form:has(.s-auth-footer) {
1385
1389
  padding-bottom: var(--space-8, 0.5rem);
1386
1390
  }