@celestia-island/hikari 0.55.345 → 0.55.347

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.345",
3
+ "version": "0.55.347",
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",
@@ -0,0 +1,27 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import * as barrel from "../index";
3
+ import { asIndexable } from "../utils/typing";
4
+
5
+ /**
6
+ * The public barrel guard for the dashed add/empty affordance tile
7
+ * (HkEdgeGlow.barrel.test.ts shape): deleting the export lines from
8
+ * index.ts kept the ENTIRE suite green while the component's own tests
9
+ * reach the module through "./HkAddTile" — only an external consumer
10
+ * would have noticed. Recorded as a residual in #1222's R4/R5; this
11
+ * file closes it.
12
+ *
13
+ * This file deliberately does NOT mock "@celestia-island/hikari": the
14
+ * package's self-reference resolves to the very same src/index.ts module
15
+ * as "../index", so a vi.mock here would replace the barrel under test
16
+ * with the mock's own namespace.
17
+ */
18
+ describe("the public barrel", () => {
19
+ it("exports the add tile under both family names", () => {
20
+ const hk = asIndexable(barrel.HkAddTile);
21
+ expect(hk, "HkAddTile must be re-exported").toBeTruthy();
22
+ expect(hk.name).toBe("HkAddTile");
23
+ // The H- alias rides the HCard/HkCard family convention: consumers
24
+ // import either name, one component underneath.
25
+ expect(barrel.HAddTile).toBe(barrel.HkAddTile);
26
+ });
27
+ });
@@ -60,8 +60,13 @@ describe("HkAddTile neutrality contract", () => {
60
60
  const drag = fullRule(css, ".hk-add-tile--drag-over");
61
61
  expect(drag).toContain("rgb(var(--color-primary) / 8%)");
62
62
  // Whole-file sweep: exactly one top-level rule chunk paints the
63
- // wash, and it is the drag-over rule.
64
- const chunks = css.split(/(?=\.hk-add-tile)/g).filter((r) => r.includes("/ 8%)"));
63
+ // wash, and it is the drag-over rule. Comments are stripped first —
64
+ // a mere mention of the wash alpha in prose must not red this (the
65
+ // R3 comment-sensitivity residual).
66
+ const cssSansComments = css.replace(/\/\*[\s\S]*?\*\//g, "").replace(/^\s*\/\/.*$/gm, "");
67
+ const chunks = cssSansComments
68
+ .split(/(?=\.hk-add-tile)/g)
69
+ .filter((r) => r.includes("/ 8%)"));
65
70
  expect(chunks.length).toBe(1);
66
71
  expect(chunks[0].startsWith(".hk-add-tile--drag-over")).toBe(true);
67
72
  });
@@ -41,7 +41,7 @@
41
41
  }
42
42
  }
43
43
 
44
- /* List-end form: a slim left-aligned row ("+ add one more") that rides
44
+ /* List-end form: a slim start-aligned row ("+ add one more") that rides
45
45
  * the end of a row list instead of floating under it as a button. */
46
46
  .hk-add-tile--compact {
47
47
  flex-direction: row;
@@ -39,6 +39,14 @@ function dropEvent(files: File[]): Event {
39
39
  return ev;
40
40
  }
41
41
 
42
+ /** A dragleave carrying a relatedTarget — the containment contract the
43
+ handler keys on (undefined leaves it null = "left to nothing"). */
44
+ function leaveEvent(relatedTarget: Node | null): Event {
45
+ const ev = new Event("dragleave", { bubbles: true, cancelable: true });
46
+ Object.defineProperty(ev, "relatedTarget", { value: relatedTarget });
47
+ return ev;
48
+ }
49
+
42
50
  function file(name: string): File {
43
51
  return new File(["x"], name, { type: "text/plain" });
44
52
  }
@@ -131,22 +139,47 @@ describe("HkAddTile", () => {
131
139
  expect(onDropFiles).not.toHaveBeenCalled();
132
140
  });
133
141
 
134
- it("flips the drag-over class across child boundaries without flicker", async () => {
142
+ it("keeps drag-over across child boundaries, clears on real exit", async () => {
135
143
  const c = mount(h(HkAddTile, { droppable: true }, { default: () => "Drop" }));
136
144
  const el = tileEl(c);
137
145
  // The default slot text is a direct child; enter the tile, then its
138
- // label span boundary, then back out of the span only.
146
+ // glyph boundary, then back into the label area only.
139
147
  el.dispatchEvent(new Event("dragenter", { bubbles: true }));
140
148
  await nextTick();
141
149
  expect(el.classList.contains("hk-add-tile--drag-over")).toBe(true);
142
- const inner = el.querySelector("span") ?? el.firstElementChild ?? el;
150
+ const inner = el.firstElementChild as Element;
143
151
  inner.dispatchEvent(new Event("dragenter", { bubbles: true })); // depth 2
144
- inner.dispatchEvent(new Event("dragleave", { bubbles: true })); // depth 1 — still over
152
+ // Internal move (leaving the glyph toward the label): contained, so
153
+ // the depth must not RESET — an always-reset leave with no
154
+ // containment check would clear the wash here. (The blind-decrement
155
+ // direction is the self-heal test's below.)
156
+ inner.dispatchEvent(leaveEvent(el));
145
157
  await nextTick();
146
158
  expect(el.classList.contains("hk-add-tile--drag-over")).toBe(true);
147
- el.dispatchEvent(new Event("dragleave", { bubbles: true })); // depth 0
159
+ el.dispatchEvent(leaveEvent(null)); // left to nothing — full reset
160
+ await nextTick();
161
+ expect(el.classList.contains("hk-add-tile--drag-over")).toBe(false);
162
+ });
163
+
164
+ it("self-heals when a hovered child leaves the DOM mid-drag", async () => {
165
+ // The stuck-depth leak (residual sweep): a slot child removed
166
+ // mid-hover never fires its own leave, so the old decrement could
167
+ // strand the count above zero and keep the wash lit after the
168
+ // pointer had fully exited. The containment reset clears the wash on
169
+ // the first real exit regardless of how deep the count was stranded.
170
+ const c = mount(h(HkAddTile, { droppable: true }, { default: () => "Drop" }));
171
+ const el = tileEl(c);
172
+ el.dispatchEvent(new Event("dragenter", { bubbles: true }));
173
+ const inner = el.firstElementChild as Element;
174
+ inner.dispatchEvent(new Event("dragenter", { bubbles: true })); // depth 2
175
+ inner.remove(); // slot swap: the child's leave never fires
176
+ el.dispatchEvent(leaveEvent(null)); // pointer exits the tile for real
148
177
  await nextTick();
149
178
  expect(el.classList.contains("hk-add-tile--drag-over")).toBe(false);
179
+ // The next drag session starts from a clean slate.
180
+ el.dispatchEvent(new Event("dragenter", { bubbles: true }));
181
+ await nextTick();
182
+ expect(el.classList.contains("hk-add-tile--drag-over")).toBe(true);
150
183
  });
151
184
 
152
185
  it("cancels dragenter/dragover exactly when it accepts the drag", () => {
@@ -16,7 +16,7 @@ import "./HkAddTile.scss";
16
16
  * the empty state of a list or panel ("no sources yet — add one to
17
17
  * begin"). The whole tile is the click target; hosts no longer pair
18
18
  * a passive dashed box with a separate button below it.
19
- * - **compact** — a slim left-aligned row ("+ Add node / repo"): the
19
+ * - **compact** — a slim start-aligned row ("+ Add node / repo"): the
20
20
  * tile that rides the END of a list of rows and grows the list. It
21
21
  * replaces the loose secondary button, so the add affordance reads
22
22
  * as part of the list instead of floating under it.
@@ -60,6 +60,7 @@ export default defineComponent({
60
60
  const dragOver = computed(
61
61
  () => props.droppable && !props.disabled && dragDepth.value > 0,
62
62
  );
63
+ const rootEl = ref<HTMLButtonElement | null>(null);
63
64
 
64
65
  /** Whether this tile accepts the drag at all. Refusing means NEVER
65
66
  * calling preventDefault: the browser only permits a drop onto a
@@ -83,8 +84,18 @@ export default defineComponent({
83
84
  e.preventDefault();
84
85
  }
85
86
 
86
- function onDragleave() {
87
- if (dragDepth.value > 0) dragDepth.value -= 1;
87
+ function onDragleave(e: DragEvent) {
88
+ // Containment check instead of a blind decrement: a child that
89
+ // leaves the DOM mid-hover (slot swap) never fires its own leave,
90
+ // so a plain `depth -= 1` could strand the count above zero and
91
+ // keep the drag-over wash lit after the pointer has fully exited
92
+ // (the R3 residual sweep). When the leave's relatedTarget is
93
+ // outside the tile — or null, i.e. left to nothing — the pointer
94
+ // has truly gone: reset fully.
95
+ const root = rootEl.value;
96
+ const rt = e.relatedTarget as Node | null;
97
+ if (root && rt && root.contains(rt)) return;
98
+ dragDepth.value = 0;
88
99
  }
89
100
 
90
101
  function onDrop(e: DragEvent) {
@@ -115,6 +126,7 @@ export default defineComponent({
115
126
  return (
116
127
  <button
117
128
  type="button"
129
+ ref={rootEl}
118
130
  class={[
119
131
  "hk-add-tile",
120
132
  props.compact && "hk-add-tile--compact",
@@ -128,6 +128,16 @@ describe("HkThemeToggle row lead-cell contract", () => {
128
128
  // rules anymore (the alignment contract retired with the row).
129
129
  const css = read("HkThemeToggle.scss");
130
130
  expect(css).not.toMatch(/\.s-theme-item-customize \.hk-menu-item-icon/);
131
+ // The entry's vertical rhythm is owned component-side (residual
132
+ // sweep: the margin rule previously had no vue-side pin at all).
133
+ expect(css).toMatch(/\.s-theme-item-customize\s*\{[^}]*margin-top/);
134
+ // And the mobile sheet rides the family's 44px touch contract. The
135
+ // `}\s*\}` fence pins media-block CONTAINMENT — a rule un-nested
136
+ // from the block but placed after it would fail the double close
137
+ // (residual sweep: `[\s\S]*?` alone bridges braces).
138
+ expect(css).toMatch(
139
+ /\(max-width: 767px\)[\s\S]*?\.s-theme-item-customize\s*\{[^}]*min-height[^}]*\}\s*\}/,
140
+ );
131
141
  });
132
142
 
133
143
  it("aligns mode-extra host rows to the lead column without rescaling their glyph", () => {
@@ -365,6 +365,14 @@
365
365
  .s-theme-item-row[data-custom] .s-theme-item-name {
366
366
  margin-inline-end: 2.75rem;
367
367
  }
368
+
369
+ /* The customize tile rides the menu family's sheet touch geometry:
370
+ * its compact padding alone reads ~32px, under the 44px sheet-row
371
+ * contract every sibling row gets from the item-sheet tokens
372
+ * (2026-11-11 residual sweep). Desktop keeps the compact metrics. */
373
+ .s-theme-item-customize {
374
+ min-height: var(--hk-menu-item-min-h, 2.75rem);
375
+ }
368
376
  }
369
377
 
370
378
  /* ── Host-provided row anatomy (item-leading / item-trailing) ───────────
@@ -74,10 +74,11 @@ function triggerButton(container: HTMLElement): HTMLButtonElement {
74
74
  return trigger!;
75
75
  }
76
76
 
77
- function paletteButton(): HTMLButtonElement {
77
+ function customizeEntry(): HTMLButtonElement {
78
78
  // The entry rides the standard HkAddTile (2026-11-11 family migration)
79
79
  // and no longer carries s-theme-item-btn — the stable host hook class
80
- // is the query surface.
80
+ // is the query surface. (The helper's old paletteButton name retired
81
+ // with the palette glyph: the tile's default is a Plus.)
81
82
  const btn = document.body.querySelector<HTMLButtonElement>(
82
83
  ".s-theme-menu .s-theme-item-customize",
83
84
  );
@@ -168,7 +169,7 @@ describe("HkThemeToggle external customization", () => {
168
169
  openMenu(container);
169
170
  await settle();
170
171
 
171
- paletteButton().click();
172
+ customizeEntry().click();
172
173
  await settle();
173
174
 
174
175
  expect(openCustomize()).toBe(1);
@@ -183,7 +184,7 @@ describe("HkThemeToggle external customization", () => {
183
184
  openMenu(container);
184
185
  await settle();
185
186
 
186
- paletteButton().click();
187
+ customizeEntry().click();
187
188
  await settle();
188
189
 
189
190
  expect(openCustomize()).toBe(0);