@celestia-island/hikari 0.55.421 → 0.55.424

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.
@@ -74,6 +74,10 @@
74
74
  display: flex;
75
75
  justify-content: flex-end;
76
76
  padding-top: var(--space-8, 0.5rem);
77
+ /* Breathing room BELOW the clear-all (user direction 2026-11-19):
78
+ the popover panel's own pad is a bare 4px, which glued the button
79
+ to the glass edge — the foot owns the extra bottom inset. */
80
+ padding-bottom: var(--space-8, 0.5rem);
77
81
  border-top: 1px solid rgb(var(--color-border) / 10%);
78
82
  margin-top: var(--space-8, 0.5rem);
79
83
  }
@@ -25,6 +25,17 @@ describe("HkNotificationBell scss contract", () => {
25
25
  );
26
26
  });
27
27
 
28
+ it("the clear-all foot carries bottom padding (the glass edge gap)", () => {
29
+ // User direction 2026-11-19: the popover panel's own 4px pad glued
30
+ // the clear-all button to the panel's bottom edge — the foot owns
31
+ // the extra bottom inset. The VALUE is pinned (round-3 review,
32
+ // mutant M4): a presence-only match let `padding-bottom: 0` — a
33
+ // no-op revert — stay green.
34
+ const footBlock = scss.match(/^\.hk-notification-center__foot \{([^}]*)\}/m);
35
+ expect(footBlock).toBeTruthy();
36
+ expect(footBlock![1]).toContain("padding-bottom: var(--space-8, 0.5rem)");
37
+ });
38
+
28
39
  it("the row centers its columns against the ROW height (one-line rows included)", () => {
29
40
  // Default stretch stretched a one-line body to the 24px dismiss
30
41
  // button and hugged the title to the body's top — visibly off the
@@ -1,4 +1,4 @@
1
- import { afterEach, describe, expect, it } from "vitest";
1
+ import { afterEach, describe, expect, it, vi } from "vitest";
2
2
  import { createApp, h, nextTick } from "vue";
3
3
 
4
4
  import HkNotificationBell from "./HkNotificationBell";
@@ -13,9 +13,12 @@ import { setLocale } from "../i18n/context";
13
13
  * - clicking the bell opens the panel (HkPopover panel mounts) and
14
14
  * opening IS the read receipt (dot goes dark)
15
15
  * - rows render title / time / detail / code chip
16
+ * - error/warning rows carry the toast-family copy button (user
17
+ * direction 2026-11-19) and copy the FULL record to the clipboard;
18
+ * the other tones stay non-copyable like their surfaces
16
19
  * - a snoozed emergency entry shows the Hidden state chip and its
17
20
  * restore button unsnoozes through the journal's resummon path
18
- * - Clear all empties the journal
21
+ * - Clear all (icon + label) empties the journal
19
22
  *
20
23
  * (Repo test convention: raw createApp + document queries, no
21
24
  * @vue/test-utils dependency.)
@@ -50,6 +53,16 @@ function rows(): HTMLElement[] {
50
53
  return Array.from(document.querySelectorAll<HTMLElement>(".hk-notification-row"));
51
54
  }
52
55
 
56
+ /** The toast family's clipboard write, stubbed at navigator level
57
+ * (same shape HkTable/HkErrorLanding tests use) — jsdom has no
58
+ * clipboard, and the fallback execCommand path would not tell us
59
+ * WHAT text was copied. */
60
+ function stubClipboard() {
61
+ const writeText = vi.fn().mockResolvedValue(undefined);
62
+ Object.defineProperty(navigator, "clipboard", { value: { writeText }, configurable: true });
63
+ return writeText;
64
+ }
65
+
53
66
  afterEach(() => {
54
67
  for (const { app, container } of mounts) {
55
68
  app.unmount();
@@ -122,6 +135,77 @@ describe("panel rows", () => {
122
135
  expect(row.querySelector(".hk-notification-row__time")).toBeTruthy();
123
136
  });
124
137
 
138
+ it("error AND warning rows carry the toast's copy button; the payload is the FULL record", async () => {
139
+ // User direction 2026-11-19: beside dismiss, error/warning rows get
140
+ // the toast family's own copy affordance (same button shape, same
141
+ // `hikari::toast.copy` label, same clipboard write). The row clips
142
+ // its text, so the copied payload must be the complete record —
143
+ // title / code / detail, whatever fields exist, one per line.
144
+ // BOTH tones are pinned positively (round-2 review): dropping the
145
+ // warning arm of rowCopyable must go red here, not just the error
146
+ // arm.
147
+ await setLocale("en");
148
+ const writeText = stubClipboard();
149
+ recordNotification({
150
+ id: "toast:e:1:1",
151
+ kind: "toast",
152
+ tone: "error",
153
+ title: "billing.quota.snapshot: billing.quota.bad_gate",
154
+ detail: "The gate returned an unrecoverable verdict",
155
+ code: "billing.quota.bad_gate",
156
+ });
157
+ recordNotification({ id: "toast:w:1:2", kind: "toast", tone: "warning", title: "disk almost full" });
158
+ mountBell();
159
+ await settle();
160
+ bellButton().dispatchEvent(new MouseEvent("click", { bubbles: true }));
161
+ await settle();
162
+ const byLabel = (row: HTMLElement, label: string) =>
163
+ row.querySelector<HTMLButtonElement>(
164
+ `.hk-notification-row__actions .hk-icon-button[aria-label="${label}"]`,
165
+ );
166
+ const errorRow = rows().find((r) => r.textContent?.includes("billing.quota"))!;
167
+ const copy = byLabel(errorRow, "Copy");
168
+ expect(copy, "copy button renders on an error row").toBeTruthy();
169
+ // LEFT of dismiss: the copy button is the actions lane's first child.
170
+ expect(copy!.parentElement!.firstElementChild).toBe(copy);
171
+ copy!.dispatchEvent(new MouseEvent("click", { bubbles: true }));
172
+ await settle();
173
+ expect(writeText).toHaveBeenCalledTimes(1);
174
+ expect(writeText).toHaveBeenCalledWith(
175
+ "billing.quota.snapshot: billing.quota.bad_gate\nbilling.quota.bad_gate\nThe gate returned an unrecoverable verdict",
176
+ );
177
+
178
+ // The warning arm: same button, and the title-only payload proves
179
+ // the optional code/detail guards skip MISSING fields instead of
180
+ // joining empty lines.
181
+ const warningRow = rows().find((r) => r.textContent?.includes("disk almost full"))!;
182
+ const warningCopy = byLabel(warningRow, "Copy");
183
+ expect(warningCopy, "copy button renders on a warning row").toBeTruthy();
184
+ warningCopy!.dispatchEvent(new MouseEvent("click", { bubbles: true }));
185
+ await settle();
186
+ expect(writeText).toHaveBeenCalledTimes(2);
187
+ expect(writeText).toHaveBeenLastCalledWith("disk almost full");
188
+ // The toast seat's hover hint rides along (claim pin — round-3
189
+ // mutant M3 deleted it green): aria-label AND title, same key.
190
+ expect(copy!.getAttribute("title")).toBe("Copy");
191
+ });
192
+
193
+ it("tones the toast family treats as non-copyable get NO copy button", async () => {
194
+ await setLocale("en");
195
+ stubClipboard();
196
+ recordNotification({ id: "s1", kind: "toast", tone: "success", title: "saved" });
197
+ recordNotification({ id: "i1", kind: "toast", tone: "info", title: "heads up" });
198
+ mountBell();
199
+ await settle();
200
+ bellButton().dispatchEvent(new MouseEvent("click", { bubbles: true }));
201
+ await settle();
202
+ expect(rows()).toHaveLength(2);
203
+ expect(
204
+ document.querySelector('.hk-notification-row__actions .hk-icon-button[aria-label="Copy"]'),
205
+ "success/info records stay non-copyable, like their surfaces",
206
+ ).toBeNull();
207
+ });
208
+
125
209
  it("a snoozed emergency shows Hidden + a working restore button", async () => {
126
210
  await setLocale("en");
127
211
  raiseEmergencyAlert({ id: "quota", severity: "warning", title: "quota out" });
@@ -159,6 +243,13 @@ describe("panel rows", () => {
159
243
  expect(row.classList.contains("is-active")).toBe(true);
160
244
  expect(row.querySelector('.hk-notification-row__actions .hk-icon-button[aria-label="Show again"]')).toBeFalsy();
161
245
  expect(row.querySelector(".hk-notification-row__state")).toBeFalsy();
246
+ // Emergency records inherit the copy affordance through their tone
247
+ // (round-3 intent-drift pin): a warning-severity emergency IS a
248
+ // copyable diagnostic record — its whole action lane is exactly
249
+ // [Copy] (live episodes carry no dismiss, and an active band has
250
+ // no restore).
251
+ expect(row.querySelector('.hk-notification-row__actions .hk-icon-button[aria-label="Copy"]')).toBeTruthy();
252
+ expect(row.querySelectorAll(".hk-notification-row__actions .hk-icon-button")).toHaveLength(1);
162
253
  });
163
254
 
164
255
  it("an emergency row carries NO dismiss button (live episode is not user-dismissable)", async () => {
@@ -217,9 +308,12 @@ describe("panel rows", () => {
217
308
  expect(row.querySelector('.hk-notification-row__actions .hk-icon-button[aria-label="Show again"]')).toBeFalsy();
218
309
  // R10 (PR #1333): the state-scoped gate means a CLEARED emergency
219
310
  // row IS dismissable — this is the pin that was lost in eb492e44's
220
- // wrong-sibling deletion.
311
+ // wrong-sibling deletion. Pinned by LABEL (round-2 review): the row
312
+ // now also carries a copy button, and a bare `.hk-icon-button`
313
+ // first-match resolves to THAT, so dropping the dismiss gate would
314
+ // have stayed green.
221
315
  expect(
222
- row.querySelector(".hk-notification-row__actions .hk-icon-button"),
316
+ row.querySelector('.hk-notification-row__actions .hk-icon-button[aria-label="Dismiss"]'),
223
317
  "a resolved record is dismissable",
224
318
  ).not.toBeNull();
225
319
  });
@@ -237,7 +331,9 @@ describe("panel rows", () => {
237
331
  await settle();
238
332
  expect(rows()).toHaveLength(2);
239
333
  const dropRow = rows().find((r) => r.textContent?.includes("drop me"))!;
240
- const dismiss = dropRow.querySelector<HTMLButtonElement>(".hk-notification-row__actions .hk-icon-button")!;
334
+ const dismiss = dropRow.querySelector<HTMLButtonElement>(
335
+ '.hk-notification-row__actions .hk-icon-button[aria-label="Dismiss"]',
336
+ )!;
241
337
  expect(dismiss.getAttribute("aria-label")).toBe("Dismiss");
242
338
  dismiss.dispatchEvent(new MouseEvent("click", { bubbles: true }));
243
339
  await settle();
@@ -260,9 +356,11 @@ describe("panel rows", () => {
260
356
  const titles = rows().map((r) => r.querySelector(".hk-notification-row__title")?.textContent);
261
357
  expect(titles).toEqual(["newer", "older"]);
262
358
 
263
- (document.querySelector<HTMLButtonElement>(".hk-notification-center__foot .hk-btn")!).dispatchEvent(
264
- new MouseEvent("click", { bubbles: true }),
265
- );
359
+ // The clear-all affordance announces itself by its glyph (user
360
+ // direction 2026-11-19): a leading icon inside the label button.
361
+ const clearBtn = document.querySelector<HTMLButtonElement>(".hk-notification-center__foot .hk-btn")!;
362
+ expect(clearBtn.querySelector(".hk-btn-icon")).toBeTruthy();
363
+ clearBtn.dispatchEvent(new MouseEvent("click", { bubbles: true }));
266
364
  await settle();
267
365
  expect(document.querySelector(".hk-notification-center__empty")).toBeTruthy();
268
366
  expect(rows()).toHaveLength(0);
@@ -23,11 +23,29 @@
23
23
  * (`onResummon`, wired by useEmergencyAlert); the button reuses the
24
24
  * emergency family's own "Show again" copy.
25
25
  *
26
+ * Per-row copy (user direction 2026-11-19): rows whose tone the toast
27
+ * family already deems copyable by default (error/warning —
28
+ * useToast's `defaultCopyable`) carry the toast's own copy icon
29
+ * button (same HkIconButton shape, same `hikari::toast.copy` label,
30
+ * same useClipboard write) to the LEFT of dismiss, copying the full
31
+ * untruncated record (title / code / detail, one per line) — the row
32
+ * clips its text, so the clipboard is the only place the whole thing
33
+ * still exists.
34
+ *
26
35
  * Renders nothing extra while the journal is empty beyond the bell
27
36
  * itself — an empty notification center still shows its (disabled-
28
37
  * looking) trigger so the host chrome never reflows on first use.
29
38
  */
30
- import { CircleCheck as CheckCircle, Info, LoaderCircle, RotateCcw, TriangleAlert as AlertTriangle, X } from "lucide-vue-next";
39
+ import {
40
+ CircleCheck as CheckCircle,
41
+ Copy,
42
+ Info,
43
+ LoaderCircle,
44
+ RotateCcw,
45
+ Trash2,
46
+ TriangleAlert as AlertTriangle,
47
+ X,
48
+ } from "lucide-vue-next";
31
49
  import { computed, defineComponent, h, ref, watch, type Component } from "vue";
32
50
 
33
51
  import { useChromeActionSize } from "../composables/useChromeActionSize";
@@ -37,6 +55,7 @@ import {
37
55
  type HkNotificationEntry,
38
56
  type HkNotificationTone,
39
57
  } from "../runtime/notificationCenter";
58
+ import { useClipboard } from "../runtime/useClipboard";
40
59
  import HkIconButton from "./HkIconButton";
41
60
  import HkButton from "./HkButton";
42
61
  import HkPopover from "./HkPopover";
@@ -51,6 +70,13 @@ const TONE_ICONS: Record<HkNotificationTone, Component> = {
51
70
  loading: LoaderCircle,
52
71
  };
53
72
 
73
+ /** The toast family's own copyable-by-default set (useToast
74
+ * `defaultCopyable`): error and warning records get the per-row copy
75
+ * button, the other tones mirror their non-copyable surfaces. */
76
+ function rowCopyable(entry: HkNotificationEntry): boolean {
77
+ return entry.tone === "error" || entry.tone === "warning";
78
+ }
79
+
54
80
  /** `HH:mm` today, `MM-dd HH:mm` otherwise — Intl does the locale work
55
81
  * (the journal stores epoch ms; formatting is a view concern). */
56
82
  function formatRowTime(ts: number, locale: string): string {
@@ -70,6 +96,7 @@ export default defineComponent({
70
96
  const { t } = useI18n();
71
97
  const { entries, forget, markAllRead, reset } = useNotificationCenter();
72
98
  const chromeSize = useChromeActionSize();
99
+ const clipboard = useClipboard();
73
100
  const open = ref(false);
74
101
  const anchorRef = ref<HTMLElement | null>(null);
75
102
 
@@ -90,6 +117,18 @@ export default defineComponent({
90
117
  if (v) markAllRead();
91
118
  });
92
119
 
120
+ /** The toast's copy affordance, carried over: same clipboard write
121
+ * path (useClipboard), but the payload is the journal's own shape —
122
+ * the FULL untruncated record, one field per line (title / code /
123
+ * detail — whatever the entry carries). The row itself ellipsizes,
124
+ * so the clipboard is the only complete copy of what was shown. */
125
+ function copyEntry(entry: HkNotificationEntry) {
126
+ const parts = [entry.title];
127
+ if (entry.code) parts.push(entry.code);
128
+ if (entry.detail) parts.push(entry.detail);
129
+ void clipboard.copy(parts.join("\n"));
130
+ }
131
+
93
132
  function renderRow(entry: HkNotificationEntry) {
94
133
  const Icon = TONE_ICONS[entry.tone] ?? Info;
95
134
  const isLive = entry.kind === "emergency" && entry.state !== "cleared";
@@ -137,9 +176,22 @@ export default defineComponent({
137
176
  )}
138
177
  </div>
139
178
  <div class="hk-notification-row__actions">
140
- {/* Dismiss is gated OFF for live emergency episodes (round-6
141
- S1: a snoozed alert's entry carries the ONLY restore
142
- handle). Restore is gated ON only for snoozed entries. */}
179
+ {/* Copy (toast-family tones, left of dismiss per user
180
+ direction 2026-11-19) → dismiss → restore. Dismiss is
181
+ gated OFF for live emergency episodes (round-6 S1: a
182
+ snoozed alert's entry carries the ONLY restore handle).
183
+ Restore is gated ON only for snoozed entries. */}
184
+ {rowCopyable(entry) && (
185
+ <HkIconButton
186
+ size={24}
187
+ variant="ghost"
188
+ aria-label={t("hikari::toast.copy", "Copy")}
189
+ {...{ title: t("hikari::toast.copy", "Copy") }}
190
+ onClick={() => copyEntry(entry)}
191
+ >
192
+ {{ icon: () => <Copy size={14} /> }}
193
+ </HkIconButton>
194
+ )}
143
195
  {!isLive && (
144
196
  <HkIconButton
145
197
  size={24}
@@ -207,11 +259,11 @@ export default defineComponent({
207
259
  {sorted.value.map(renderRow)}
208
260
  </ul>
209
261
  <div class="hk-notification-center__foot">
210
- <HkButton
211
- variant="ghost"
212
- size="sm"
213
- onClick={() => reset()}
214
- >
262
+ {/* The wipe glyph reads before the label is parsed —
263
+ a destructive affordance announced by its icon
264
+ (user direction 2026-11-19), from the same lucide
265
+ family the row glyphs already speak. */}
266
+ <HkButton variant="ghost" size="sm" icon="Trash2" onClick={() => reset()}>
215
267
  {t("hikari::notificationCenter.clearAll", "Clear all")}
216
268
  </HkButton>
217
269
  </div>
@@ -105,6 +105,34 @@
105
105
  }
106
106
  }
107
107
 
108
+ /* Trigger presentation: the host's icon button IS the visible trigger;
109
+ * this wrapper is only the anchor (click/keydown wiring lives on it in
110
+ * the tsx) — no field box, no padding of its own. */
111
+ .hk-user-picker-trigger {
112
+ display: inline-flex;
113
+ align-items: center;
114
+ justify-content: center;
115
+ cursor: pointer;
116
+ }
117
+
118
+ /* Off a one-glyph anchor the popout cannot inherit a useful width
119
+ * (matchAnchorWidth is off in trigger mode) — the panel carries a catalog
120
+ * width and lets the surface's own viewport clamp absorb overflow. */
121
+ .hk-user-picker-panel.is-trigger-anchor {
122
+ width: min(24rem, 80vw);
123
+ }
124
+
125
+ /* Mobile sheet context (#424 pattern, the HkTagInput / HkAffixPicker
126
+ * spelling): inside the full-width select sheet the popup's designed
127
+ * measure becomes a centered cap instead of a left-glued clamp — the
128
+ * trigger panel reads as one designed block inside the viewport-wide
129
+ * sheet rather than hugging its left edge. */
130
+ .hk-select-sheet-panel .hk-user-picker-panel.is-trigger-anchor {
131
+ width: 100%;
132
+ max-width: min(24rem, 100%);
133
+ margin-inline: auto;
134
+ }
135
+
108
136
  /* ── Panel content ──────────────────────────────────────────────────── */
109
137
 
110
138
  /* The content column inside HkSelectPanel. `.hk-user-picker-dialog` is the
@@ -204,6 +232,14 @@
204
232
  }
205
233
 
206
234
  .hk-user-picker-row-main {
235
+ /* Fills the middle lane between a (optional) leading icon cell and the
236
+ * (multi-mode) trailing check — under the row's
237
+ * `justify-content: space-between` a content-sized main would let a
238
+ * leading glyph push the name to the far END of the row instead of
239
+ * sitting beside it. `flex: 1` keeps the icon leading, the text
240
+ * mid-row, the check trailing, in BOTH the plain and the group-kind
241
+ * row shapes. */
242
+ flex: 1;
207
243
  display: flex;
208
244
  flex-direction: column;
209
245
  min-width: 0;
@@ -237,6 +273,16 @@
237
273
  font-weight: 700;
238
274
  }
239
275
 
276
+ /* The group-kind glyph (data-kind="group"): the grammar's leading icon
277
+ * cell (_menu-item.scss `mi.icon` — fixed square, svg normalized), so a
278
+ * group row reads exactly like any other menu row's icon column instead
279
+ * of a bare glyph floating under the row's space-between layout. */
280
+ .hk-user-picker-row-kind {
281
+ @include mi.icon;
282
+
283
+ color: rgb(var(--color-text) / 55%);
284
+ }
285
+
240
286
  /* ── Multi-mode footer (draft count + Cancel / Confirm) ─────────────── */
241
287
 
242
288
  .hk-user-picker-footer {
@@ -345,4 +345,112 @@ describe("HkUserPicker", () => {
345
345
  expect(searchField()!.value).toBe("");
346
346
  expect(rowsBand()!.textContent).toContain("Type a nickname, username or email to search.");
347
347
  });
348
+
349
+ // ── Trigger presentation (2026-11-18 third pass) ────────────────────
350
+ // The host collapses the field into its own icon button via the
351
+ // `trigger` slot; the SAME panel anchors to that button.
352
+ it("trigger mode renders the slot instead of the tag field", () => {
353
+ let slotKeys: string[] | null = null;
354
+ mount(() => h(HkUserPicker, { modelValue: [alice], search: async () => [] }, {
355
+ trigger: (slotProps: { open: boolean }) => {
356
+ slotKeys = Object.keys(slotProps);
357
+ return h("button", { class: "test-trigger", "data-open": String(slotProps.open) }, "Add member");
358
+ },
359
+ }));
360
+ // No tag field: the slot content IS the visible chrome.
361
+ expect(document.body.querySelector(".hk-user-picker-field")).toBeNull();
362
+ const anchor = document.body.querySelector<HTMLElement>(".hk-user-picker-trigger")!;
363
+ expect(anchor).not.toBeNull();
364
+ const button = anchor.querySelector<HTMLButtonElement>("button.test-trigger")!;
365
+ expect(button.textContent).toBe("Add member");
366
+ expect(button.getAttribute("data-open")).toBe("false");
367
+ // The slot payload is `{ open }` ONLY (the HkDateTimePicker /
368
+ // HkAffixPicker precedent): `toggle` is deliberately not handed out —
369
+ // a host that wired it onto the button inside the wrapper would
370
+ // double-toggle the panel shut in one event.
371
+ expect(slotKeys).toEqual(["open"]);
372
+ });
373
+
374
+ it("clicking the trigger opens the same search-first panel and mirrors the open state", async () => {
375
+ const search = vi.fn(async () => [bob]);
376
+ mount(() => h(HkUserPicker, { modelValue: [], search }, {
377
+ trigger: ({ open }: { open: boolean }) =>
378
+ h("button", { class: "test-trigger", "data-open": String(open) }, "Add member"),
379
+ }));
380
+ const button = () =>
381
+ document.body.querySelector<HTMLButtonElement>("button.test-trigger")!;
382
+ expect(button().getAttribute("data-open")).toBe("false");
383
+ button().click();
384
+ await settle();
385
+ await nextTick();
386
+ // The panel content mounted (anchored to the trigger wrapper) and the
387
+ // slot saw the open flip.
388
+ expect(button().getAttribute("data-open")).toBe("true");
389
+ expect(document.body.querySelector(".hk-user-picker-rows")).not.toBeNull();
390
+ const input = document.body.querySelector<HTMLInputElement>(".hk-user-picker-search input");
391
+ expect(input).not.toBeNull();
392
+ // The trigger form keeps the search-first contract on BOTH halves:
393
+ // focus lands in the panel's search field, exactly like the field form.
394
+ expect(document.activeElement).toBe(input);
395
+ await wait(DEBOUNCE_WAIT);
396
+ await settle();
397
+ // The empty-query contract survives the trigger form.
398
+ expect(search).not.toHaveBeenCalled();
399
+ expect(rows()).toHaveLength(0);
400
+ });
401
+
402
+ it("single-mode pick from the trigger panel emits and closes", async () => {
403
+ const onUpdate = vi.fn();
404
+ mount(() => h(HkUserPicker, {
405
+ modelValue: [],
406
+ search: async () => [bob],
407
+ "onUpdate:modelValue": (users: HkUserOption[]) => onUpdate(users),
408
+ }, {
409
+ trigger: () => h("button", { class: "test-trigger" }, "Add member"),
410
+ }));
411
+ document.body.querySelector<HTMLButtonElement>("button.test-trigger")!.click();
412
+ await settle();
413
+ await searchFor("bo");
414
+ rows()[0].click();
415
+ await nextTick();
416
+ expect(onUpdate).toHaveBeenCalledWith([bob]);
417
+ await wait(CLOSE_WAIT);
418
+ expect(document.body.querySelector(".hk-user-picker-panel"), "panel closed").toBeNull();
419
+ });
420
+
421
+ // ── Group-kind rows (2026-11-18 third pass) ─────────────────────────
422
+ it("group-kind rows render the group glyph and data-kind, user rows stay plain", async () => {
423
+ const team: HkUserOption = { uid: "g-1", username: "", displayName: "Design team", kind: "group" };
424
+ mount(() => h(HkUserPicker, { modelValue: [], search: async () => [team, alice] }));
425
+ await openPanel();
426
+ await searchFor("a");
427
+ expect(rows()).toHaveLength(2);
428
+ const groupRow = rows()[0];
429
+ expect(groupRow.getAttribute("data-kind")).toBe("group");
430
+ expect(groupRow.querySelector(".hk-user-picker-row-kind")).not.toBeNull();
431
+ expect(groupRow.textContent).toContain("Design team");
432
+ const userRow = rows()[1];
433
+ expect(userRow.getAttribute("data-kind")).toBeNull();
434
+ expect(userRow.querySelector(".hk-user-picker-row-kind")).toBeNull();
435
+ });
436
+
437
+ it("a group-kind row picks like any other row", async () => {
438
+ const onUpdate = vi.fn();
439
+ const team: HkUserOption = { uid: "g-1", username: "", displayName: "Design team", kind: "group" };
440
+ mount(() => h(HkUserPicker, {
441
+ modelValue: [],
442
+ mode: "multi",
443
+ search: async () => [team, alice],
444
+ "onUpdate:modelValue": (users: HkUserOption[]) => onUpdate(users),
445
+ }));
446
+ await openPanel();
447
+ await searchFor("a");
448
+ rows()[0].click();
449
+ rows()[1].click();
450
+ await nextTick();
451
+ const confirm = document.body.querySelector<HTMLButtonElement>(".hk-user-picker-confirm")!;
452
+ confirm.click();
453
+ await nextTick();
454
+ expect(onUpdate).toHaveBeenCalledWith([team, alice]);
455
+ });
348
456
  });
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Source contract: the trigger presentation's panel geometry (2026-11-18
3
+ * third pass).
4
+ *
5
+ * The trigger form anchors the panel to a one-glyph icon button, so it
6
+ * cannot inherit the anchor's width (matchAnchorWidth off) and carries a
7
+ * catalog measure instead. That measure must NOT leak into the phone
8
+ * sheet: inside the viewport-wide sheet band it becomes a centered cap,
9
+ * not a left-glued clamp — the #424 pattern the HkTagInput / HkAffixPicker
10
+ * sheets spell out. jsdom cannot see layout, so this contract pins the
11
+ * stylesheet source: both branches of the geometry exist, with the sheet
12
+ * override keyed on the SAME `.is-trigger-anchor` marker the popout rule
13
+ * uses (a rename of one branch orphans the other — this pin fails).
14
+ */
15
+ import { describe, expect, it } from "vitest";
16
+ import { readFileSync } from "node:fs";
17
+ import { dirname, join } from "node:path";
18
+ import { fileURLToPath } from "node:url";
19
+
20
+ const here = dirname(fileURLToPath(import.meta.url));
21
+ const scss = readFileSync(join(here, "HkUserPicker.scss"), "utf-8");
22
+
23
+ /** The balanced `{...}` block that FOLLOWS `at` (the singleScroll
24
+ * contract's reader — a naive `[^}]*` would stop at the first nested
25
+ * `}` and let properties appended after a future nested block evade the
26
+ * pin). */
27
+ function blockAt(src: string, at: number): string {
28
+ const open = src.indexOf("{", at);
29
+ expect(open, "selector block exists").toBeGreaterThanOrEqual(0);
30
+ let depth = 0;
31
+ for (let i = open; i < src.length; i++) {
32
+ if (src[i] === "{") depth++;
33
+ else if (src[i] === "}") {
34
+ depth--;
35
+ if (depth === 0) return src.slice(open, i + 1);
36
+ }
37
+ }
38
+ return "";
39
+ }
40
+
41
+ describe("HkUserPicker trigger panel geometry (source contract)", () => {
42
+ it("carries the popout measure and the sheet override on the same marker", () => {
43
+ const popoutAt = scss.indexOf(".hk-user-picker-panel.is-trigger-anchor");
44
+ expect(popoutAt, "the popout width rule exists").toBeGreaterThanOrEqual(0);
45
+ const popout = blockAt(scss, popoutAt);
46
+ expect(popout).toContain("width: min(24rem, 80vw);");
47
+
48
+ // The sheet override is keyed on the SAME marker, scoped under the
49
+ // sheet panel: width hands over to the band, the measure becomes a
50
+ // centered cap (#424 — never a left-glued clamp).
51
+ const sheetAt = scss.indexOf(
52
+ ".hk-select-sheet-panel .hk-user-picker-panel.is-trigger-anchor",
53
+ );
54
+ expect(sheetAt, "the sheet override exists").toBeGreaterThanOrEqual(0);
55
+ expect(sheetAt, "the override follows the popout rule").toBeGreaterThan(popoutAt);
56
+ const sheet = blockAt(scss, sheetAt);
57
+ expect(sheet).toContain("width: 100%;");
58
+ expect(sheet).toContain("max-width: min(24rem, 100%);");
59
+ expect(sheet).toContain("margin-inline: auto;");
60
+ });
61
+ });