@celestia-island/hikari 0.55.360 → 0.55.362

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.
@@ -9,10 +9,12 @@ import HkTimePicker, {
9
9
  from12Hour,
10
10
  parseHhmm,
11
11
  snapMinute,
12
+ snapTimeToStep,
12
13
  to12Hour,
13
14
  } from "./HkTimePicker";
14
15
  import { setLocale } from "../i18n/context";
15
16
 
17
+ const originalWidth = window.innerWidth;
16
18
  const mounts: ReturnType<typeof createApp>[] = [];
17
19
  const containers: HTMLElement[] = [];
18
20
 
@@ -88,7 +90,7 @@ function readoutButtons(): HTMLButtonElement[] {
88
90
  }
89
91
 
90
92
  function periodButtons(): HTMLButtonElement[] {
91
- return Array.from(panel()?.querySelectorAll<HTMLButtonElement>(".hk-tp-period-btn") ?? []);
93
+ return Array.from(panel()?.querySelectorAll<HTMLButtonElement>(".hk-pill-group-pill") ?? []);
92
94
  }
93
95
 
94
96
  function face(): HTMLElement {
@@ -100,6 +102,7 @@ afterEach(async () => {
100
102
  for (const el of containers.splice(0)) el.remove();
101
103
  document.querySelectorAll(".hk-tp-panel, .hk-popover-backdrop, .hk-popover-panel").forEach((el) => el.remove());
102
104
  vi.useRealTimers();
105
+ (window as { innerWidth: number }).innerWidth = originalWidth;
103
106
  await setLocale("en");
104
107
  });
105
108
 
@@ -161,6 +164,16 @@ describe("HkTimePicker helpers", () => {
161
164
  expect(snapMinute(-8, 15)).toBe(45);
162
165
  });
163
166
 
167
+ it("snaps a whole time onto the step grid and carries the hour", () => {
168
+ expect(snapTimeToStep(14, 59, 30)).toEqual({ hour: 15, minute: 0 });
169
+ expect(snapTimeToStep(14, 46, 30)).toEqual({ hour: 15, minute: 0 });
170
+ expect(snapTimeToStep(14, 7, 15)).toEqual({ hour: 14, minute: 0 });
171
+ expect(snapTimeToStep(14, 8, 15)).toEqual({ hour: 14, minute: 15 });
172
+ expect(snapTimeToStep(23, 59, 30)).toEqual({ hour: 0, minute: 0 });
173
+ expect(snapTimeToStep(0, 0, 1)).toEqual({ hour: 0, minute: 0 });
174
+ expect(snapTimeToStep(9, 30, 1)).toEqual({ hour: 9, minute: 30 });
175
+ });
176
+
164
177
  it("places dial values on the face (0 at 12 o'clock, clockwise)", () => {
165
178
  const close = (actual: number, expected: number) => expect(actual).toBeCloseTo(expected, 6);
166
179
  const north = dialPoint(0, 12);
@@ -185,6 +198,15 @@ describe("HkTimePicker helpers", () => {
185
198
  });
186
199
 
187
200
  describe("HkTimePicker", () => {
201
+ it("uses hikari's HkPillToggleGroup for the day period", async () => {
202
+ const p = mountPicker({ modelValue: "09:30" });
203
+ await openPicker(p);
204
+ const group = panel()?.querySelector(".hk-pill-group.hk-tp-period");
205
+ expect(group, "the period is the shared pill group").not.toBeNull();
206
+ expect(group?.getAttribute("role")).toBe("group");
207
+ expect(periodButtons().map((b) => b.textContent)).toEqual(["AM", "PM"]);
208
+ });
209
+
188
210
  it("renders the trigger value and falls back to a localized placeholder", () => {
189
211
  const p = mountPicker({ modelValue: "09:30" });
190
212
  const value = p.container.querySelector<HTMLElement>(".hk-tp-value");
@@ -254,6 +276,17 @@ describe("HkTimePicker", () => {
254
276
  expect(p.emitted).toEqual(["14:00"]);
255
277
  });
256
278
 
279
+ it("carries the hour when the synthesized time crosses a coarse step boundary", async () => {
280
+ vi.useFakeTimers({ shouldAdvanceTime: true });
281
+ vi.setSystemTime(new Date(2026, 4, 6, 14, 59, 0));
282
+ const p = mountPicker({ minuteStep: 30 });
283
+ trigger(p).click();
284
+ await nextTick();
285
+ panel()!.querySelector<HTMLButtonElement>(".hk-tp-confirm")!.click();
286
+ await nextTick();
287
+ expect(p.emitted).toEqual(["15:00"]);
288
+ });
289
+
257
290
  it("snaps Now onto a coarse minuteStep", async () => {
258
291
  vi.useFakeTimers({ shouldAdvanceTime: true });
259
292
  vi.setSystemTime(new Date(2026, 4, 6, 14, 7, 0));
@@ -265,6 +298,17 @@ describe("HkTimePicker", () => {
265
298
  expect(p.emitted).toEqual(["14:00"]);
266
299
  });
267
300
 
301
+ it("carries the hour when Now crosses a coarse step boundary", async () => {
302
+ vi.useFakeTimers({ shouldAdvanceTime: true });
303
+ vi.setSystemTime(new Date(2026, 4, 6, 14, 59, 0));
304
+ const p = mountPicker({ modelValue: "09:30", minuteStep: 30 });
305
+ trigger(p).click();
306
+ await nextTick();
307
+ panel()!.querySelector<HTMLButtonElement>(".hk-tp-now")!.click();
308
+ await nextTick();
309
+ expect(p.emitted).toEqual(["15:00"]);
310
+ });
311
+
268
312
  it("keeps a stored off-grid minute verbatim until the user re-picks", async () => {
269
313
  const p = mountPicker({ modelValue: "09:07", minuteStep: 15 });
270
314
  await openPicker(p);
@@ -387,6 +431,23 @@ describe("HkTimePicker", () => {
387
431
  expect(face().getAttribute("aria-valuenow")).toBe("0");
388
432
  });
389
433
 
434
+ it("reports the last reachable minute as aria-valuemax", async () => {
435
+ const p = mountPicker({ modelValue: "09:30", minuteStep: 15 });
436
+ await openPicker(p);
437
+ readoutButtons()[1].click();
438
+ await nextTick();
439
+ expect(face().getAttribute("aria-valuemax")).toBe("45");
440
+ });
441
+
442
+ it("never renders an aria range below a stored off-grid minute", async () => {
443
+ const p = mountPicker({ modelValue: "09:59", minuteStep: 30 });
444
+ await openPicker(p);
445
+ readoutButtons()[1].click();
446
+ await nextTick();
447
+ expect(face().getAttribute("aria-valuenow")).toBe("59");
448
+ expect(face().getAttribute("aria-valuemax")).toBe("59");
449
+ });
450
+
390
451
  it("honours minuteStep for keyboard and dial snapping", async () => {
391
452
  const p = mountPicker({ modelValue: "09:30", minuteStep: 5 });
392
453
  await openPicker(p);
@@ -397,6 +458,25 @@ describe("HkTimePicker", () => {
397
458
  expect(face().getAttribute("aria-valuenow")).toBe("35");
398
459
  });
399
460
 
461
+ it("snaps a pointer drag on the dial through minuteStep", async () => {
462
+ const p = mountPicker({ modelValue: "09:30", minuteStep: 10 });
463
+ await openPicker(p);
464
+ const faceEl = face();
465
+ faceEl.getBoundingClientRect = () => ({
466
+ left: 0, top: 0, right: 200, bottom: 200, width: 200, height: 200,
467
+ x: 0, y: 0, toJSON: () => ({}),
468
+ } as DOMRect);
469
+ readoutButtons()[1].click();
470
+ await nextTick();
471
+ // 3 o'clock is minute 15; step 10 snaps it to 20 (a step-blind path
472
+ // would leave 15, so this pins the snap, not just the wiring).
473
+ faceEl.dispatchEvent(new MouseEvent("pointerdown", { clientX: 200, clientY: 100, bubbles: true }));
474
+ faceEl.dispatchEvent(new MouseEvent("pointermove", { clientX: 200, clientY: 100, bubbles: true }));
475
+ faceEl.dispatchEvent(new MouseEvent("pointerup", { clientX: 200, clientY: 100, bubbles: true }));
476
+ await nextTick();
477
+ expect(face().getAttribute("aria-valuenow")).toBe("20");
478
+ });
479
+
400
480
  it("cancelling discards the draft and keeps the model untouched", async () => {
401
481
  const p = mountPicker({ modelValue: "09:30" });
402
482
  await openPicker(p);
@@ -461,6 +541,28 @@ describe("HkTimePicker", () => {
461
541
  expect(emitted).toEqual([]);
462
542
  });
463
543
 
544
+ it("focuses the dial on open and dismisses on an outside click without emitting", async () => {
545
+ const p = mountPicker({ modelValue: "09:30" });
546
+ await openPicker(p);
547
+ expect(document.activeElement).toBe(face());
548
+ const outside = document.createElement("div");
549
+ document.body.appendChild(outside);
550
+ outside.dispatchEvent(new MouseEvent("click", { bubbles: true }));
551
+ await waitFor("the popup to close on an outside click", () => panel() === null);
552
+ expect(p.emitted).toEqual([]);
553
+ outside.remove();
554
+ });
555
+
556
+ it("docks as a bottom sheet on touch-width viewports", async () => {
557
+ (window as { innerWidth: number }).innerWidth = 375;
558
+ const p = mountPicker({ modelValue: "09:30" });
559
+ await openPicker(p);
560
+ const surface = document.querySelector<HTMLElement>(".hk-popover-panel");
561
+ expect(surface?.classList.contains("hk-is-sheet")).toBe(true);
562
+ expect(panel()?.classList.contains("is-touch")).toBe(true);
563
+ (window as { innerWidth: number }).innerWidth = originalWidth;
564
+ });
565
+
464
566
  it("never opens while disabled", async () => {
465
567
  const p = mountPicker({ modelValue: "09:30", disabled: true });
466
568
  expect(trigger(p).getAttribute("aria-disabled")).not.toBeNull();
@@ -2,6 +2,7 @@ import { Check, Clock, Moon, Sun, X } from "lucide-vue-next";
2
2
  import {
3
3
  computed,
4
4
  defineComponent,
5
+ h,
5
6
  nextTick,
6
7
  ref,
7
8
  useId,
@@ -12,6 +13,7 @@ import {
12
13
  import { useI18n } from "../i18n/context";
13
14
  import { useBreakpoint } from "../runtime/useBreakpoint";
14
15
  import HkButton from "./HkButton";
16
+ import HkPillToggleGroup from "./HkPillToggleGroup";
15
17
  import HPopover from "./HkPopover";
16
18
  import "./HkTimePicker.scss";
17
19
 
@@ -71,6 +73,20 @@ export function snapMinute(value: number, step = 1): number {
71
73
  return ((snapped % 60) + 60) % 60;
72
74
  }
73
75
 
76
+ /**
77
+ * Snap a whole clock time to the step grid, carrying the hour. The
78
+ * synthesized branches (empty model on open, Now) must not land an hour
79
+ * earlier than the real nearest slot: 14:59 with step 30 is 15:00, not
80
+ * 14:00. A STORED off-grid value is never passed through this helper.
81
+ */
82
+ export function snapTimeToStep(hour: number, minute: number, step = 1): { hour: number; minute: number } {
83
+ const safeStep = Math.min(30, Math.max(1, Math.round(step) || 1));
84
+ const dayMinutes = 24 * 60;
85
+ const total = (((Math.round(hour) % 24) + 24) % 24) * 60 + Math.round(minute);
86
+ const snapped = ((Math.round(total / safeStep) * safeStep) % dayMinutes + dayMinutes) % dayMinutes;
87
+ return { hour: Math.floor(snapped / 60) % 24, minute: snapped % 60 };
88
+ }
89
+
74
90
  /**
75
91
  * Position of a dial value on the square face, in percent of the face box:
76
92
  * `value` counts clockwise from 12 o'clock across `total` slots, and
@@ -157,10 +173,10 @@ export default defineComponent({
157
173
  function seedDraft(): void {
158
174
  const current = parsed.value ?? (() => {
159
175
  const now = new Date();
160
- // The synthesized branches are the only minutes the host never
161
- // chose, so they must land on the step grid; a STORED off-grid
162
- // model stays verbatim (the user can still re-pick it).
163
- return { hour: now.getHours(), minute: snapMinute(now.getMinutes(), props.minuteStep) };
176
+ // The synthesized branches are the only times the host never
177
+ // chose, so they carry the hour onto the step grid; a STORED
178
+ // off-grid model stays verbatim (the user can still re-pick it).
179
+ return snapTimeToStep(now.getHours(), now.getMinutes(), props.minuteStep);
164
180
  })();
165
181
  draftHour.value = current.hour;
166
182
  draftMinute.value = current.minute;
@@ -202,8 +218,9 @@ export default defineComponent({
202
218
 
203
219
  function setNow(): void {
204
220
  const now = new Date();
205
- draftHour.value = now.getHours();
206
- draftMinute.value = snapMinute(now.getMinutes(), minuteStep.value);
221
+ const snapped = snapTimeToStep(now.getHours(), now.getMinutes(), minuteStep.value);
222
+ draftHour.value = snapped.hour;
223
+ draftMinute.value = snapped.minute;
207
224
  commit(formatHhmm(draftHour.value, draftMinute.value));
208
225
  }
209
226
 
@@ -356,13 +373,34 @@ export default defineComponent({
356
373
 
357
374
  const numbers = computed(() => (mode.value === "hour" ? hourNumbers.value : minuteNumbers.value));
358
375
  const ariaValueNow = computed(() => (mode.value === "hour" ? draftHour.value : draftMinute.value));
359
- const ariaValueMax = computed(() => (mode.value === "hour" ? 23 : 59));
376
+ const ariaValueMax = computed(() => {
377
+ if (mode.value === "hour") return 23;
378
+ const gridMax = Math.floor(59 / minuteStep.value) * minuteStep.value;
379
+ // A stored off-grid minute is kept verbatim (documented contract), so
380
+ // the range must still contain it: the step grid's last value is the
381
+ // floor, not a clamp.
382
+ return Math.max(gridMax, draftMinute.value);
383
+ });
360
384
  const ariaFaceLabel = computed(() =>
361
385
  mode.value === "hour"
362
386
  ? t("hikari::dateTimePicker.hour", "Hour")
363
387
  : t("hikari::dateTimePicker.minute", "Minute"),
364
388
  );
365
389
 
390
+ const periodOptions = computed(() => [
391
+ {
392
+ value: "am",
393
+ label: t("hikari::timePicker.am", "AM"),
394
+ icon: h(Sun, { size: 13 }),
395
+ },
396
+ {
397
+ value: "pm",
398
+ label: t("hikari::timePicker.pm", "PM"),
399
+ icon: h(Moon, { size: 13 }),
400
+ },
401
+ ]);
402
+ const periodSelected = computed(() => new Set([pm.value ? "pm" : "am"]));
403
+
366
404
  const triggerAriaLabel = computed(() => {
367
405
  if (props.label && !props.hideLabel) return undefined;
368
406
  return props.label ?? t("hikari::timePicker.title", "Pick a time");
@@ -384,30 +422,14 @@ export default defineComponent({
384
422
  role="group"
385
423
  aria-label={surfaceTitle.value}
386
424
  >
387
- <div
425
+ <HkPillToggleGroup
388
426
  class="hk-tp-period"
389
- role="group"
390
- aria-label={t("hikari::timePicker.period", "Day period")}
391
- >
392
- <button
393
- type="button"
394
- class={["hk-tp-period-btn", !pm.value ? "is-active" : ""].filter(Boolean).join(" ")}
395
- aria-pressed={!pm.value}
396
- onClick={() => setPeriod(false)}
397
- >
398
- <Sun size={13} />
399
- <span>{t("hikari::timePicker.am", "AM")}</span>
400
- </button>
401
- <button
402
- type="button"
403
- class={["hk-tp-period-btn", pm.value ? "is-active" : ""].filter(Boolean).join(" ")}
404
- aria-pressed={pm.value}
405
- onClick={() => setPeriod(true)}
406
- >
407
- <Moon size={13} />
408
- <span>{t("hikari::timePicker.pm", "PM")}</span>
409
- </button>
410
- </div>
427
+ data-test="hk-time-picker-period"
428
+ label={t("hikari::timePicker.period", "Day period")}
429
+ options={periodOptions.value}
430
+ selected={periodSelected.value}
431
+ onToggle={(value: string) => setPeriod(value === "pm")}
432
+ />
411
433
 
412
434
  <div class="hk-tp-readout">
413
435
  <button
@@ -222,9 +222,15 @@ describe("HkTimeZonePicker — trigger", () => {
222
222
  const harness = mountPicker({ label: "Time zone", size: "sm" });
223
223
  expect(harness.container.querySelector(".hk-tzp-label")?.textContent).toBe("Time zone");
224
224
  expect(trigger(harness.container).classList.contains("hk-tzp-trigger-sm")).toBe(true);
225
+ const visible = mountPicker({ label: "Time zone" });
226
+ const labelEl = visible.container.querySelector(".hk-tzp-label");
227
+ expect(trigger(visible.container).getAttribute("aria-labelledby")).toBe(labelEl?.id);
228
+ expect(trigger(visible.container).getAttribute("aria-label")).toBeNull();
225
229
  const hidden = mountPicker({ label: "Time zone", hideLabel: true });
226
230
  expect(hidden.container.querySelector(".hk-tzp-label")).toBeNull();
227
231
  expect(trigger(hidden.container).getAttribute("aria-label")).toBe("Time zone");
232
+ const noLabel = mountPicker({ placeholder: "Zone" });
233
+ expect(trigger(noLabel.container).getAttribute("aria-label")).toBe("Zone");
228
234
  });
229
235
  });
230
236
 
@@ -4,6 +4,7 @@ import {
4
4
  defineAsyncComponent,
5
5
  defineComponent,
6
6
  ref,
7
+ useId,
7
8
  type PropType,
8
9
  } from "vue";
9
10
 
@@ -138,6 +139,8 @@ export default defineComponent({
138
139
  setup(props, { emit }) {
139
140
  const { t } = useI18n();
140
141
  const { isMobile } = useBreakpoint();
142
+ const generatedId = useId();
143
+ const labelId = `hk-tzp-label-${generatedId}`;
141
144
 
142
145
  const zone = computed(() => props.modelValue ?? "");
143
146
  const hasZone = computed(() => zone.value.length > 0);
@@ -147,8 +150,10 @@ export default defineComponent({
147
150
  ? zone.value
148
151
  : (props.emptyLabel ?? t("hikari::timeZonePicker.system", "System time zone")));
149
152
 
150
- const triggerLabel = computed(() =>
151
- props.label ?? t("hikari::timeZonePicker.placeholder", "Pick a time zone"));
153
+ const triggerAriaLabel = computed(() => {
154
+ if (props.label && !props.hideLabel) return undefined;
155
+ return props.label ?? props.placeholder ?? t("hikari::timeZonePicker.placeholder", "Pick a time zone");
156
+ });
152
157
 
153
158
  /** What the GLOBE is oriented to. `""` means "the system zone", and
154
159
  * the globe has no empty sector — handing it `""` would resolve to
@@ -238,7 +243,7 @@ export default defineComponent({
238
243
  return (
239
244
  <div class={["hk-tzp", props.disabled ? "is-disabled" : ""].filter(Boolean).join(" ")}>
240
245
  {props.label && !props.hideLabel && (
241
- <span class="hk-tzp-label">{props.label}</span>
246
+ <span class="hk-tzp-label" id={labelId}>{props.label}</span>
242
247
  )}
243
248
  <div
244
249
  ref={triggerRef}
@@ -251,7 +256,8 @@ export default defineComponent({
251
256
  aria-haspopup="dialog"
252
257
  aria-expanded={open.value}
253
258
  aria-disabled={props.disabled || undefined}
254
- aria-label={triggerLabel.value}
259
+ aria-labelledby={props.label && !props.hideLabel ? labelId : undefined}
260
+ aria-label={triggerAriaLabel.value}
255
261
  tabindex={props.disabled ? -1 : 0}
256
262
  onClick={toggle}
257
263
  onKeydown={onTriggerKeydown}
@@ -65,42 +65,6 @@
65
65
  min-height: 1.75rem;
66
66
  }
67
67
 
68
- .hk-wp-nav {
69
- appearance: none;
70
- background: transparent;
71
- border: 0;
72
- width: 1.75rem;
73
- height: 1.75rem;
74
- border-radius: var(--radius-md, 8px);
75
- color: var(--hi-color-muted);
76
- cursor: pointer;
77
- display: inline-flex;
78
- align-items: center;
79
- justify-content: center;
80
- transition:
81
- background var(--duration-fast, 0.15s) ease,
82
- color var(--duration-fast, 0.15s) ease;
83
-
84
- &:hover:not(:disabled) {
85
- background: var(--hi-color-surface);
86
- color: var(--hi-color-text-primary);
87
- }
88
-
89
- &:active:not(:disabled) {
90
- filter: brightness(0.95);
91
- }
92
-
93
- &:focus-visible {
94
- outline: 2px solid color-mix(in srgb, var(--hi-color-primary) 55%, transparent);
95
- outline-offset: 1px;
96
- }
97
-
98
- &:disabled {
99
- opacity: 0.25;
100
- cursor: not-allowed;
101
- }
102
- }
103
-
104
68
  .hk-wp-title {
105
69
  font-size: var(--text-sm, 0.875rem);
106
70
  font-weight: 600;
@@ -112,56 +76,6 @@
112
76
  text-overflow: ellipsis;
113
77
  }
114
78
 
115
- .hk-wp-every {
116
- appearance: none;
117
- border: 1px solid color-mix(in srgb, var(--hi-color-border) 60%, transparent);
118
- border-radius: 999px;
119
- padding: var(--space-2, 2px) var(--space-10, 10px);
120
- min-height: 1.5rem;
121
- background: transparent;
122
- color: var(--hi-color-muted);
123
- font-family: inherit;
124
- font-size: var(--text-xs, 0.75rem);
125
- font-weight: 500;
126
- line-height: 1.2;
127
- white-space: nowrap;
128
- cursor: pointer;
129
- transition:
130
- background var(--duration-fast, 0.15s) ease,
131
- border-color var(--duration-fast, 0.15s) ease,
132
- color var(--duration-fast, 0.15s) ease;
133
-
134
- &:hover:not(:disabled) {
135
- background: var(--hi-color-surface);
136
- color: var(--hi-color-text-primary);
137
- }
138
-
139
- &:active:not(:disabled) {
140
- filter: brightness(0.95);
141
- }
142
-
143
- &:focus-visible {
144
- outline: 2px solid color-mix(in srgb, var(--hi-color-primary) 55%, transparent);
145
- outline-offset: 1px;
146
- }
147
-
148
- &[aria-pressed="true"] {
149
- background: color-mix(in srgb, var(--hi-color-primary) 14%, transparent);
150
- border-color: color-mix(in srgb, var(--hi-color-primary) 45%, transparent);
151
- color: var(--hi-color-primary);
152
- font-weight: 600;
153
- }
154
-
155
- &:disabled {
156
- opacity: 0.25;
157
- cursor: not-allowed;
158
- }
159
- }
160
-
161
- /* ── Weekday header buttons ───────────────────────────────────── */
162
-
163
- /* Same seven tracks and the same gap as .hk-wp-grid, so every header
164
- * button sits exactly above its column. */
165
79
  .hk-wp-weekdays {
166
80
  display: grid;
167
81
  grid-template-columns: repeat(7, minmax(0, 1fr));
@@ -341,8 +255,11 @@
341
255
  /* Only color/background transitions here — still respect the user's
342
256
  * preference instead of animating ink changes against it. */
343
257
  @media (prefers-reduced-motion: reduce) {
344
- .hk-wp-nav,
345
- .hk-wp-every,
258
+ .hk-wp-header .hk-btn,
259
+ .hk-wp-header .hk-icon-button {
260
+ transition: none;
261
+ }
262
+
346
263
  .hk-wp-wd,
347
264
  .hk-wp-cell {
348
265
  transition: none;
@@ -0,0 +1,27 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { dirname, resolve } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+
5
+ import { describe, expect, it } from "vitest";
6
+
7
+ const here = dirname(fileURLToPath(import.meta.url));
8
+ const scss = readFileSync(resolve(here, "HkWeekdayPicker.scss"), "utf8");
9
+ const tsx = readFileSync(resolve(here, "HkWeekdayPicker.tsx"), "utf8");
10
+
11
+ describe("HkWeekdayPicker source contracts", () => {
12
+ it("rides the shared picker metrics and the family touch targets", () => {
13
+ expect(scss).toContain("var(--hk-picker-cell, 2rem)");
14
+ expect(scss).toContain("var(--hk-picker-wd, 1.25rem)");
15
+ expect(scss).toContain("var(--hk-picker-cell, 2.75rem)");
16
+ expect(scss).toContain("var(--hk-picker-wd, 1.5rem)");
17
+ });
18
+
19
+ it("composes the header actions from hikari's buttons", () => {
20
+ expect(tsx).toContain('from "./HkIconButton"');
21
+ expect(tsx).toContain('from "./HkButton"');
22
+ expect(tsx).toContain("<HkIconButton");
23
+ expect(tsx).toContain("<HkButton");
24
+ expect(scss).toContain(".hk-wp-header .hk-btn");
25
+ expect(scss).toContain(".hk-wp-header .hk-icon-button");
26
+ });
27
+ });
@@ -97,8 +97,8 @@ function summary(container: HTMLElement): string {
97
97
  }
98
98
 
99
99
  function everyChip(container: HTMLElement): HTMLButtonElement {
100
- const el = container.querySelector<HTMLButtonElement>(".hk-wp-every");
101
- expect(el, ".hk-wp-every renders").not.toBeNull();
100
+ const el = container.querySelector<HTMLButtonElement>('[data-test="hk-wp-every"]');
101
+ expect(el, "the every-day button renders").not.toBeNull();
102
102
  return el!;
103
103
  }
104
104
 
@@ -278,7 +278,7 @@ describe("HkWeekdayPicker — month navigation", () => {
278
278
  const fmt = new Intl.DateTimeFormat("en", { year: "numeric", month: "long" });
279
279
  expect(title(harness.container)).toBe(fmt.format(new Date(2026, 7, 1)));
280
280
 
281
- const navs = harness.container.querySelectorAll<HTMLButtonElement>(".hk-wp-nav");
281
+ const navs = harness.container.querySelectorAll<HTMLButtonElement>('[data-test="hk-wp-prev"], [data-test="hk-wp-next"]');
282
282
  navs[1]!.click();
283
283
  await nextTick();
284
284
  expect(title(harness.container)).toBe(fmt.format(new Date(2026, 8, 1)));
@@ -301,7 +301,7 @@ describe("HkWeekdayPicker — month navigation", () => {
301
301
 
302
302
  it("keeps the weekday bands after navigating to another month", async () => {
303
303
  const harness = mountPicker({ modelValue: [5] }); // Fridays
304
- harness.container.querySelectorAll<HTMLButtonElement>(".hk-wp-nav")[1]!.click();
304
+ harness.container.querySelectorAll<HTMLButtonElement>('[data-test="hk-wp-prev"], [data-test="hk-wp-next"]')[1]!.click();
305
305
  await nextTick();
306
306
  expect(bands(harness.container)).toHaveLength(1);
307
307
  const active = cells(harness.container).filter((c) => c.classList.contains("is-active"));
@@ -311,6 +311,56 @@ describe("HkWeekdayPicker — month navigation", () => {
311
311
  });
312
312
  });
313
313
 
314
+ describe("HkWeekdayPicker — initial month", () => {
315
+ it("follows a late initialMonth prop without moving the selection", async () => {
316
+ const container = document.createElement("div");
317
+ document.body.appendChild(container);
318
+ containers.push(container);
319
+ const month = ref<Date | null>(new Date(2026, 7, 1));
320
+ const Wrapper = defineComponent({
321
+ setup: () => () => h(HkWeekdayPicker, { modelValue: [1], initialMonth: month.value }),
322
+ });
323
+ const app = createApp(Wrapper);
324
+ mounts.push(app);
325
+ app.mount(container);
326
+ await nextTick();
327
+ const fmt = new Intl.DateTimeFormat("en", { year: "numeric", month: "long" });
328
+ expect(title(container)).toBe(fmt.format(new Date(2026, 7, 1)));
329
+ month.value = new Date(2026, 2, 1);
330
+ await nextTick();
331
+ expect(title(container)).toBe(fmt.format(new Date(2026, 2, 1)));
332
+ expect(container.querySelectorAll(".hk-wp-band")).toHaveLength(1);
333
+ });
334
+
335
+ it("does not reset month navigation when the host re-renders the same month", async () => {
336
+ const container = document.createElement("div");
337
+ document.body.appendChild(container);
338
+ containers.push(container);
339
+ const tick = ref(0);
340
+ const Wrapper = defineComponent({
341
+ setup: () => () =>
342
+ h(HkWeekdayPicker, {
343
+ // A live Date per render (same month, different timestamp) — the
344
+ // host that writes `new Date()` inline or re-renders on a clock.
345
+ initialMonth: new Date(2026, 7, 1, 0, 0, tick.value),
346
+ modelValue: [1 + tick.value * 0],
347
+ }),
348
+ });
349
+ const app = createApp(Wrapper);
350
+ mounts.push(app);
351
+ app.mount(container);
352
+ await nextTick();
353
+ const fmt = new Intl.DateTimeFormat("en", { year: "numeric", month: "long" });
354
+ const next = container.querySelector<HTMLButtonElement>('[data-test="hk-wp-next"]')!;
355
+ next.click();
356
+ await nextTick();
357
+ expect(title(container)).toBe(fmt.format(new Date(2026, 8, 1)));
358
+ tick.value += 1;
359
+ await nextTick();
360
+ expect(title(container)).toBe(fmt.format(new Date(2026, 8, 1)));
361
+ });
362
+ });
363
+
314
364
  describe("HkWeekdayPicker — disabled + accessibility", () => {
315
365
  it("blocks every interaction when disabled", async () => {
316
366
  const harness = mountPicker({ modelValue: [1], disabled: true });