@celestia-island/hikari 0.55.260 → 0.55.262

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.260",
3
+ "version": "0.55.262",
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",
@@ -1,5 +1,5 @@
1
1
  import { afterEach, describe, expect, it } from "vitest";
2
- import { createApp, h } from "vue";
2
+ import { createApp, h, nextTick, ref } from "vue";
3
3
 
4
4
  import HkDonutChart from "./HkDonutChart";
5
5
  import type { HkDonutEntry } from "./donutGeometry";
@@ -80,6 +80,24 @@ describe("HkDonutChart", () => {
80
80
  expect(empty.querySelector(".hk-donut--empty")).toBeTruthy();
81
81
  });
82
82
 
83
+ it("clears a dead hover key when the entries swap under a held pointer", async () => {
84
+ // The wowsp lesson: the hovered element can unmount without firing
85
+ // mouseleave; without the reset every surviving slice would stay
86
+ // stuck at is-dim under the dead key.
87
+ const entriesRef = ref(ENTRIES);
88
+ const el = mount(h(() => <HkDonutChart entries={entriesRef.value} />));
89
+ const slices = [...el.querySelectorAll(".hk-donut__slice")];
90
+ slices[0]!.dispatchEvent(new MouseEvent("mouseenter"));
91
+ await nextTick();
92
+ expect(slices[1]!.className).toContain("is-dim");
93
+ entriesRef.value = ENTRIES.slice(0, 1);
94
+ await nextTick();
95
+ const after = [...el.querySelectorAll(".hk-donut__slice")];
96
+ expect(after).toHaveLength(1);
97
+ expect(after[0]!.className).not.toContain("is-dim");
98
+ expect(after[0]!.className).not.toContain("is-hot");
99
+ });
100
+
83
101
  it("renders the legendIcon slot's glyph in place of the text label", () => {
84
102
  const el = mount(
85
103
  <HkDonutChart
@@ -1,4 +1,4 @@
1
- import { computed, defineComponent, ref, type PropType } from "vue";
1
+ import { computed, defineComponent, ref, watch, type PropType } from "vue";
2
2
 
3
3
  import {
4
4
  chunkLegendItems,
@@ -67,6 +67,20 @@ export default defineComponent({
67
67
  },
68
68
  setup(props, { emit, slots }) {
69
69
  const hovered = ref<string | null>(null);
70
+ // A hover key lives on a DOM element; when the entries swap under a
71
+ // held pointer, the hovered element can unmount WITHOUT firing
72
+ // mouseleave (browsers skip removed nodes) — a dead key would dim
73
+ // the whole block until the pointer deliberately re-entered it.
74
+ // Resetting on every entries repaint costs nothing (a resting
75
+ // pointer only ever clears nulls) and can never stick. Lesson
76
+ // upstreamed from wowsp's ShipDistCharts, whose own test pins it.
77
+ watch(
78
+ () => props.entries,
79
+ () => {
80
+ hovered.value = null;
81
+ },
82
+ { deep: true },
83
+ );
70
84
 
71
85
  const slices = computed<HkDonutSlice[]>(() =>
72
86
  donutSlices(
@@ -200,6 +200,11 @@ describe("HkMenu sidebar icon rail", () => {
200
200
 
201
201
  const children = c.querySelector(".hk-menu-sidebar-rail-children");
202
202
  expect(children, "the open group lists its children in the rail").toBeTruthy();
203
+ // The rail wrapper wears the SHARED children class too: the expanded
204
+ // sidebar's 2px margin step reaches the rail through it — that class
205
+ // union IS the vertical-invariance carrier (2026-10-31). A rail-only
206
+ // wrapper would re-introduce the per-density step.
207
+ expect(children!.classList.contains("hk-menu-sidebar-children")).toBe(true);
203
208
  const childRows = railRows(children!);
204
209
  expect(childRows.map((row) => row.getAttribute("aria-label"))).toEqual(["Users", "Audit log"]);
205
210
  for (const row of childRows) {
@@ -238,6 +243,15 @@ describe("HkMenu sidebar icon rail", () => {
238
243
  expect(c.querySelector(".hk-menu-sidebar-group[data-open]"), "the group is still open").toBeTruthy();
239
244
  expect(groupRows(c)[0]!.getAttribute("aria-expanded")).toBe("true");
240
245
  expect(c.textContent).toContain("Users");
246
+ // TWO-SIDED class-union pin: the EXPANDED wrapper must wear the
247
+ // shared class too. Dropping it there removes the 2px step from the
248
+ // expanded sidebar — rows below an open group would move on every
249
+ // flip, the exact drift this contract kills (a rail-only pin let
250
+ // that through).
251
+ expect(
252
+ c.querySelector(".hk-menu-sidebar-group[data-open] > .hk-menu-sidebar-children"),
253
+ "the expanded children wrapper keeps the shared step class",
254
+ ).toBeTruthy();
241
255
 
242
256
  // Reverse direction: collapse it from the expanded sidebar, flip
243
257
  // back into the rail — it must stay collapsed (no resurrection).
@@ -508,10 +522,65 @@ describe("HkMenu rail styles (compiled sheet contracts)", () => {
508
522
  expect(row).toContain("justify-content: center");
509
523
  });
510
524
 
511
- it("keeps open group children in the same one-column rhythm (no indent step)", () => {
525
+ it("keeps open group children at the EXPANDED vertical step (no rail re-step)", () => {
526
+ // Vertical rhythm is density-invariant (2026-10-31 user direction:
527
+ // the collapse toggle must not move rows). The rail children wrapper
528
+ // therefore carries NO margin rule of its own — the expanded
529
+ // sidebar's 2px step from the shared .hk-menu-sidebar-children rule
530
+ // applies in the rail too, and the wrapper stays width-only (its
531
+ // selector survives only inside the comma-grouped width rule, which
532
+ // the exact-line ruleBody skips — the null here asserts no
533
+ // STANDALONE rail-children rule came back).
512
534
  const children = ruleBody(".hk-menu-sidebar[data-collapsed] .hk-menu-sidebar-rail-children");
513
- expect(children, "the rail children rule exists").not.toBeNull();
514
- expect(children).toContain("margin-top: 0");
535
+ expect(children, "a standalone rail-children rule re-stepped the margin").toBeNull();
536
+ const shared = ruleBody(".hk-menu-sidebar-children");
537
+ expect(shared, "the shared children rule exists").not.toBeNull();
538
+ expect(shared).toContain("margin-top: var(--space-2, 2px)");
539
+ // A rule whose selector is EXACTLY a rail wrapper class — top-level,
540
+ // outside any density dress — would restyle the rail children while
541
+ // evading every dress-keyed scan below (the compiled chunk then
542
+ // carries no carrier text). The wrappers' geometry must come from
543
+ // the shared rules alone.
544
+ expect(css.match(/^\s*\.hk-menu-sidebar-rail-(?:children|group)\s*\{/gm)).toBeNull();
545
+ });
546
+
547
+ it("the rail dress authors no vertical rhythm in any spelling", () => {
548
+ // The stronger form of the contract above, so a re-step cannot hide
549
+ // inside a comma-grouped selector the per-selector ruleBody skips
550
+ // AND cannot return through alternate spellings or sister metrics:
551
+ // every rule of the density dress is scanned and banned for ANY
552
+ // margin/padding spelling that reaches a block edge — the shorthand
553
+ // (it sets the block side too: the historical `margin-top: 0`
554
+ // regression spelled `margin: 0` evaded a longhand-only scan) and
555
+ // every vertical longhand, top AND bottom — plus the block-FLOW
556
+ // metrics that move rows just the same (gap/row-gap/height/
557
+ // min-height/max-height: a `gap:` inside the comma-grouped width
558
+ // rule once passed a margin/padding-only scan). Horizontal-only
559
+ // tracks (margin-inline*, padding-inline*) stay legal; absolute
560
+ // INSETS (the caret corner's inset-block-end) are flow-neutral
561
+ // decoration and stay legal. A rail band that truly needs a
562
+ // different block metric must move the BASE rule for BOTH densities.
563
+ // Keyed to BOTH carrier spellings so a future [data-rail]-keyed
564
+ // carrier in this sheet cannot slip the scan.
565
+ const dressRules = css
566
+ .split("}")
567
+ .filter(
568
+ (rule) =>
569
+ rule.includes(".hk-menu-sidebar[data-collapsed]") ||
570
+ rule.includes(".hk-menu-sidebar[data-rail]"),
571
+ );
572
+ expect(dressRules.length, "the rail dress rules exist").toBeGreaterThan(3);
573
+ for (const rule of dressRules) {
574
+ expect(rule, `vertical margin in the rail dress: ${rule}`).not.toMatch(
575
+ /\bmargin(?:-(?:top|bottom|block(?:-(?:start|end))?))?\s*:/,
576
+ );
577
+ expect(rule, `vertical padding in the rail dress: ${rule}`).not.toMatch(
578
+ /\bpadding(?:-(?:top|bottom|block(?:-(?:start|end))?))?\s*:/,
579
+ );
580
+ expect(rule, `block-flow metric in the rail dress: ${rule}`).not.toMatch(
581
+ /\b(?:gap|row-gap|height|min-height|max-height)\s*:/,
582
+ );
583
+ }
515
584
  });
516
585
 
517
586
  it("mirrors the rail caret in RTL with the scaleX convention, never a rotate", () => {
@@ -193,18 +193,18 @@
193
193
  font-weight: 600;
194
194
  }
195
195
 
196
- /* Rail groups keep the rail rhythm at every depth: the children
197
- * wrapper spends the rail's own row gap, with no margin step above
198
- * the first child and never an indent. */
196
+ /* Rail groups keep the ONE-COLUMN rhythm at every depth: width-only,
197
+ * never an indent. The children wrapper deliberately carries NO
198
+ * margin override of its own — the expanded sidebar's 2px step (the
199
+ * shared .hk-menu-sidebar-children rule above) applies in the rail
200
+ * too, because vertical rhythm is density-invariant (2026-10-31 user
201
+ * direction): a rail-specific step would move every row below an open
202
+ * group on each collapse/expand flip. */
199
203
  .hk-menu-sidebar-rail-group,
200
204
  .hk-menu-sidebar-rail-children {
201
205
  width: 100%;
202
206
  }
203
207
 
204
- .hk-menu-sidebar-rail-children {
205
- margin-top: 0;
206
- }
207
-
208
208
  /* Disclosure ink, at the same secondary weight as the expanded
209
209
  * sidebar's .hk-menu-more. The placeholder form lives in the glyph
210
210
  * cell and centers like every other row icon. */
@@ -86,23 +86,27 @@
86
86
  * kit (HkSidebarRailSwap) — the generation's [data-rail] flips with the
87
87
  * swap key, so the leaving generation keeps its dress for the dissolve
88
88
  * while the entering one takes the new one. A root-level attr cannot do
89
- * that: it would restyle the frozen leaving copy mid-dissolve. */
89
+ * that: it would restyle the frozen leaving copy mid-dissolve.
90
+ *
91
+ * VERTICAL RHYTHM IS DENSITY-INVARIANT (2026-10-31 user direction: the
92
+ * collapse toggle must not move rows). The dress authors INLINE geometry
93
+ * only — the header/footer rules below narrow the horizontal padding for
94
+ * the rail column and recentre the header, while every BLOCK metric (the
95
+ * header's 16px band, the body's 20px leading air + scroll tail, the
96
+ * footer's 16px band) stays with the base rules alone. Shrinking the
97
+ * collapsed paddings used to lift the whole nav by up to two paddings'
98
+ * worth on every flip; a band that needs a different vertical dress in
99
+ * rail mode would have to move the base values for BOTH densities, never
100
+ * add a per-density block padding. */
90
101
  .hk-sidebar[data-collapsed],
91
102
  .hk-sidebar-rail-generation[data-rail] {
92
103
  .hk-sidebar-header {
93
104
  justify-content: center;
94
- padding: var(--space-12) var(--space-8);
95
- }
96
-
97
- .hk-sidebar-body {
98
- /* Same end-cap as the expanded body — collapsed rows are icon-only
99
- * but the tail's job (announcing the end of the scroll range) is
100
- * identical, so only the leading air shrinks here. */
101
- padding-block: var(--space-12) var(--hk-sidebar-scroll-tail);
105
+ padding: var(--space-16) var(--space-8);
102
106
  }
103
107
 
104
108
  .hk-sidebar-footer {
105
- padding: var(--space-12) var(--space-8);
109
+ padding: var(--space-16) var(--space-8);
106
110
  }
107
111
  }
108
112
 
@@ -74,16 +74,61 @@ describe("HkSidebar scroll end-cap", () => {
74
74
  expect(body).not.toMatch(/padding-block:[^;]*--space-4/);
75
75
  });
76
76
 
77
- it("keeps the same tail on the collapsed body", () => {
78
- // The density dress is keyed off EITHER carrier — the legacy root's
79
- // [data-collapsed] or the rail swap generation's [data-rail] (the
80
- // generation attr freezes on the leaving copy for the dissolve, a
81
- // root attr cannot). ruleBody needs the arm its brace follows, so the
82
- // legacy arm is asserted as text and the body read from the group.
83
- expect(css).toContain(".hk-sidebar[data-collapsed] .hk-sidebar-body");
84
- const body = ruleBody(css, ".hk-sidebar-rail-generation[data-rail] .hk-sidebar-body");
85
- expect(body, "the collapsed body rule exists (grouped density carriers)").not.toBeNull();
86
- expect(body).toContain("padding-block: var(--space-12) var(--hk-sidebar-scroll-tail)");
77
+ it("the density dress keeps every vertical metric at the expanded value", () => {
78
+ // Vertical rhythm is density-invariant (2026-10-31 user direction:
79
+ // the collapse toggle must not move rows). The body therefore has no
80
+ // density rule AT ALL — the leading air AND the scroll tail ride the
81
+ // single base rule in both densities — and the header/footer dress
82
+ // rules keep the expanded BLOCK padding, narrowing only the inline
83
+ // track for the rail column.
84
+ expect(css).not.toContain(".hk-sidebar[data-collapsed] .hk-sidebar-body");
85
+ expect(css).not.toContain(".hk-sidebar-rail-generation[data-rail] .hk-sidebar-body");
86
+ // The two carrier literals above are the compiled spellings; a brand
87
+ // NEW carrier (a third density hook) is a new dress and must re-run
88
+ // this contract — not mechanically foreseeable here.
89
+ // ruleBody needs the arm its brace follows; the dress compiles to one
90
+ // comma-grouped rule per band, so the generation arm is the one the
91
+ // helper can read (the legacy arm shares its body).
92
+ const header = ruleBody(css, ".hk-sidebar-rail-generation[data-rail] .hk-sidebar-header");
93
+ expect(header, "the collapsed header rule exists (grouped density carriers)").not.toBeNull();
94
+ expect(header).toContain("padding: var(--space-16) var(--space-8)");
95
+ const footer = ruleBody(css, ".hk-sidebar-rail-generation[data-rail] .hk-sidebar-footer");
96
+ expect(footer, "the collapsed footer rule exists (grouped density carriers)").not.toBeNull();
97
+ expect(footer).toContain("padding: var(--space-16) var(--space-8)");
98
+ // The stronger, spelling-proof form (whole-dress scan): EVERY
99
+ // padding declaration in ANY dress rule must be EXACTLY the expanded
100
+ // two-track shorthand — exact, not a prefix: a three-track spelling
101
+ // (`padding: var(--space-16) var(--space-8) var(--space-12)`) drifts
102
+ // the block END past a block-start-only check, and a longhand
103
+ // (`padding-block-start:`) hides from a shorthand-only one; both
104
+ // green-holed earlier rounds. Physical `bottom` longhands are banned
105
+ // beside the logical ones. Horizontal-only tracks (padding-inline*)
106
+ // cannot match the value pin and are rejected the same way; a band
107
+ // that truly needs different block metrics must move the BASE rule
108
+ // for BOTH densities. Margins are banned outright — the bands
109
+ // separate by their paddings alone — and so are the block-FLOW
110
+ // metrics that move rows just the same (gap/row-gap/height/
111
+ // min-height/max-height).
112
+ const dressRules = css
113
+ .split("}")
114
+ .filter((rule) => rule.includes("[data-collapsed]") || rule.includes("[data-rail]"));
115
+ expect(dressRules.length, "the density dress rules exist").toBeGreaterThan(1);
116
+ for (const rule of dressRules) {
117
+ for (const decl of rule.matchAll(
118
+ /\bpadding(?:-(?:top|bottom|block(?:-(?:start|end))?))?\s*:[^;}]*/g,
119
+ )) {
120
+ expect(
121
+ decl[0].trim(),
122
+ `a dress padding is not the expanded two-track shorthand: ${decl[0]}`,
123
+ ).toBe("padding: var(--space-16) var(--space-8)");
124
+ }
125
+ expect(rule, `a margin crept into the dress: ${rule}`).not.toMatch(
126
+ /\bmargin(?:-(?:top|bottom|block(?:-(?:start|end))?))?\s*:/,
127
+ );
128
+ expect(rule, `block-flow metric in the dress: ${rule}`).not.toMatch(
129
+ /\b(?:gap|row-gap|height|min-height|max-height)\s*:/,
130
+ );
131
+ }
87
132
  });
88
133
 
89
134
  it("reads the tail fallback from the scss source, not a drifted literal", () => {
@@ -155,11 +155,12 @@ export default defineComponent({
155
155
  // dissolve), which is where the position is read from — an event-only
156
156
  // save would miss programmatic scrolls (no `scroll` event fires for
157
157
  // them), so the read happens on the ref hand-off itself and the
158
- // onScroll below merely keeps the value fresh between flips. Raw
159
- // scrollTop is an approximation across dresses (rail rows and full
160
- // rows have different heights) — an exact restore would need an
161
- // item-keyed anchor, not worth it for a nav list; the browser clamps
162
- // any overshoot.
158
+ // onScroll below merely keeps the value fresh between flips. For
159
+ // library-owned rows the raw restore is EXACT since the vertical
160
+ // rhythm became density-invariant (2026-10-31: both dresses render
161
+ // the same band paddings and row heights, so y offsets match); the
162
+ // browser clamps any overshoot a host's density-dependent content
163
+ // could still produce.
163
164
  const savedScrollTop = ref(0);
164
165
  const onBodyScroll = (e: Event): void => {
165
166
  savedScrollTop.value = (e.currentTarget as HTMLElement).scrollTop;