@celestia-island/hikari 0.55.359 → 0.55.361
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 +1 -1
- package/src/components/HkAdminHeader.test.tsx +23 -0
- package/src/components/HkAdminHeader.tsx +9 -1
- package/src/components/HkScrollContainer.dock.test.tsx +100 -2
- package/src/components/HkScrollContainer.scss +15 -10
- package/src/components/HkScrollContainer.tsx +9 -2
- package/src/components/HkTimePicker.scss +11 -49
- package/src/components/HkTimePicker.styles.test.ts +31 -0
- package/src/components/HkTimePicker.test.ts +103 -1
- package/src/components/HkTimePicker.tsx +52 -30
- package/src/components/HkTimeZonePicker.test.tsx +6 -0
- package/src/components/HkTimeZonePicker.tsx +10 -4
- package/src/components/HkTitleBar.test.tsx +32 -0
- package/src/components/HkTitleBar.tsx +13 -1
- package/src/components/HkWeekdayPicker.scss +5 -88
- package/src/components/HkWeekdayPicker.styles.test.ts +27 -0
- package/src/components/HkWeekdayPicker.test.tsx +54 -4
- package/src/components/HkWeekdayPicker.tsx +38 -14
- package/src/index.ts +8 -0
- package/src/plugins/boot-chrome.d.mts +10 -1
- package/src/plugins/boot-chrome.mjs +8 -0
- package/src/res/boot-chrome.js +97 -3
- package/src/res/bootChrome.test.ts +108 -1
- package/src/runtime/index.ts +6 -0
- package/src/runtime/windowChrome.ts +59 -0
package/package.json
CHANGED
|
@@ -60,6 +60,7 @@ vi.mock("./HkMenu", async () => {
|
|
|
60
60
|
return { default: HMenuStub };
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
+
import { CHROME_BAND_DRAG_REGION } from "../runtime/windowChrome";
|
|
63
64
|
import { HkAdminHeader } from "./HkAdminHeader";
|
|
64
65
|
|
|
65
66
|
/**
|
|
@@ -333,3 +334,25 @@ describe("HkAdminHeader", () => {
|
|
|
333
334
|
expect(actions?.className).toContain("s-header-wing-end");
|
|
334
335
|
});
|
|
335
336
|
});
|
|
337
|
+
|
|
338
|
+
describe("HkAdminHeader chrome face drag region (2026-11-12)", () => {
|
|
339
|
+
// WHY: with chrome on, this header IS the desktop window's caption band (Tauri
|
|
340
|
+
// decorations:false). A bare drag attribute only matches the exact event
|
|
341
|
+
// target, so the wings that tile the header shadowed it — dragging and the
|
|
342
|
+
// double-click maximize never fired. The chrome face must carry hikari's deep
|
|
343
|
+
// contract on the header root; the content face (chrome off) must not.
|
|
344
|
+
it("carries the shared deep drag region when it is the caption band", () => {
|
|
345
|
+
const c = mount(headerNode({ chrome: true }));
|
|
346
|
+
const header = c.querySelector("header")!;
|
|
347
|
+
expect(header.getAttribute("data-tauri-drag-region")).toBe(CHROME_BAND_DRAG_REGION);
|
|
348
|
+
// The LITERAL as well — the constant comparison alone follows a wrong value
|
|
349
|
+
// (mutation evidence: "true" kept this suite green before this pin).
|
|
350
|
+
expect(header.getAttribute("data-tauri-drag-region")).toBe("deep");
|
|
351
|
+
expect(header.classList.contains("hk-chrome-band")).toBe(true);
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
it("leaves the content-face header out of the drag contract", () => {
|
|
355
|
+
const c = mount(headerNode({}));
|
|
356
|
+
expect(c.querySelector("header")!.hasAttribute("data-tauri-drag-region")).toBe(false);
|
|
357
|
+
});
|
|
358
|
+
});
|
|
@@ -2,6 +2,7 @@ import { computed, defineComponent, ref, watch, type PropType, type VNode } from
|
|
|
2
2
|
import { Camera, ExternalLink, Languages, LogOut, Menu } from "lucide-vue-next";
|
|
3
3
|
import { HBadge, HButton, HSpinner } from "@celestia-island/hikari";
|
|
4
4
|
import { useI18n } from "../i18n/context";
|
|
5
|
+
import { CHROME_BAND_DRAG_REGION } from "../runtime/windowChrome";
|
|
5
6
|
import HkMenu, { type HkMenuItem } from "./HkMenu";
|
|
6
7
|
import { HkAvatarButton } from "./HkAvatarButton";
|
|
7
8
|
|
|
@@ -27,7 +28,13 @@ export const HkAdminHeader = defineComponent({
|
|
|
27
28
|
* window-controls chrome contract (.s-glass-header--chrome /
|
|
28
29
|
* --hk-window-controls-edge-inset) instead of the content inset —
|
|
29
30
|
* a standard-mode cluster glued to the frame corner is the flush
|
|
30
|
-
* variant's look worn by the wrong mode (field report 2026-10-25).
|
|
31
|
+
* variant's look worn by the wrong mode (field report 2026-10-25).
|
|
32
|
+
* The face also claims the titlebar layer (.hk-chrome-band) and
|
|
33
|
+
* carries hikari's deep drag region (CHROME_BAND_DRAG_REGION): the
|
|
34
|
+
* whole header surface drags and double-click-maximizes under
|
|
35
|
+
* Tauri's injected handler — the header IS the caption band, and its
|
|
36
|
+
* wings/wrappers would otherwise shadow a bare attribute off the
|
|
37
|
+
* event target (2026-11-12 user report). */
|
|
31
38
|
chrome: { type: Boolean, default: false },
|
|
32
39
|
actions: { type: Array as PropType<VNode[]>, default: () => [] },
|
|
33
40
|
/** Signed-in identity. Drives the avatar fallback letter, the
|
|
@@ -220,6 +227,7 @@ export const HkAdminHeader = defineComponent({
|
|
|
220
227
|
props.chrome ? "s-glass-header--chrome" : "",
|
|
221
228
|
props.chrome ? "hk-chrome-band" : "",
|
|
222
229
|
]}
|
|
230
|
+
data-tauri-drag-region={props.chrome ? CHROME_BAND_DRAG_REGION : undefined}
|
|
223
231
|
>
|
|
224
232
|
<div ref={userTriggerRef} class="s-admin-header-user s-header-wing-start">
|
|
225
233
|
{/* The hamburger rides INSIDE the left wing: the balanced grid
|
|
@@ -18,8 +18,8 @@ import { readFileSync } from "node:fs";
|
|
|
18
18
|
import { dirname, join } from "node:path";
|
|
19
19
|
import { fileURLToPath } from "node:url";
|
|
20
20
|
|
|
21
|
-
import { afterEach, describe, expect, it } from "vitest";
|
|
22
|
-
import { createApp, h, defineComponent, ref, type VNodeChild } from "vue";
|
|
21
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
22
|
+
import { createApp, h, defineComponent, reactive, ref, type VNodeChild } from "vue";
|
|
23
23
|
|
|
24
24
|
import HkKanban from "./HkKanban";
|
|
25
25
|
import HkScrollContainer from "./HkScrollContainer";
|
|
@@ -70,6 +70,104 @@ describe("HkScrollContainer dock slots", () => {
|
|
|
70
70
|
expect(host.style.getPropertyValue("--hk-scroll-dock-top")).toBe("0px");
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
+
it("drops a fade-era data-dir mirror once the gate owns the edges", async () => {
|
|
74
|
+
// The dir mirror belongs to the `fade` band-slot swap (the sheet's RTL
|
|
75
|
+
// rules read it under [data-fade]). When a dock container ALSO had
|
|
76
|
+
// `fade` on for a while and then turns it off, the dock branch takes
|
|
77
|
+
// over - and it must not leave the mirror behind (the cleanup promise
|
|
78
|
+
// is "fade off removes it", which the no-dock tests pin but a dock
|
|
79
|
+
// container exercises through a different branch).
|
|
80
|
+
const instance = ref<{ refresh: () => void } | null>(null);
|
|
81
|
+
const container = document.createElement("div");
|
|
82
|
+
document.body.appendChild(container);
|
|
83
|
+
containers.push(container);
|
|
84
|
+
const props = reactive({ fade: true, dockFade: true });
|
|
85
|
+
const app = createApp(defineComponent({
|
|
86
|
+
setup() {
|
|
87
|
+
return () =>
|
|
88
|
+
h(
|
|
89
|
+
HkScrollContainer,
|
|
90
|
+
{ ref: instance as never, ...props },
|
|
91
|
+
{
|
|
92
|
+
default: () => h("div", { class: "content" }, "rows"),
|
|
93
|
+
dockBottom: () => h("div", { class: "the-dock" }, "dock"),
|
|
94
|
+
},
|
|
95
|
+
);
|
|
96
|
+
},
|
|
97
|
+
}));
|
|
98
|
+
mounts.push(app);
|
|
99
|
+
const host = (app.mount(container) as unknown as { $el: HTMLElement }).$el;
|
|
100
|
+
const viewport = host.querySelector(".hk-scroll-container-viewport") as HTMLElement;
|
|
101
|
+
Object.defineProperty(viewport, "scrollHeight", { value: 400, configurable: true });
|
|
102
|
+
Object.defineProperty(viewport, "clientHeight", { value: 100, configurable: true });
|
|
103
|
+
Object.defineProperty(viewport, "scrollTop", { value: 120, configurable: true });
|
|
104
|
+
instance.value?.refresh();
|
|
105
|
+
await Promise.resolve();
|
|
106
|
+
// The fade pass has run, so a mirrored dir exists...
|
|
107
|
+
expect(host.getAttribute("data-dir")).not.toBeNull();
|
|
108
|
+
|
|
109
|
+
// ...and turning `fade` off must drop it (the dock branch cleans up)
|
|
110
|
+
// and re-derive the strengths through the binary gate.
|
|
111
|
+
props.fade = false;
|
|
112
|
+
// Let the wrapper re-render first (the spread only re-reads on the
|
|
113
|
+
// wrapper's own render pass); refresh AFTER the child has the new
|
|
114
|
+
// props, or the fade branch runs one last time and re-stamps the dir.
|
|
115
|
+
await Promise.resolve();
|
|
116
|
+
instance.value?.refresh();
|
|
117
|
+
await Promise.resolve();
|
|
118
|
+
expect(host.getAttribute("data-dir")).toBeNull();
|
|
119
|
+
// 280 still hidden below the fold: the dock gate is lit.
|
|
120
|
+
expect(host.style.getPropertyValue("--hk-scroll-fade-strength-bottom")).toBe("1");
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it("re-senses when dockFade flips at rest, without a manual refresh", async () => {
|
|
124
|
+
// The re-sense watcher keys on [fade, fadeDistance, dockFade]. This is
|
|
125
|
+
// its only coverage: flipping dockFade at rest with NO manual refresh —
|
|
126
|
+
// the watcher's scheduled frame must re-run the dock branch and clear
|
|
127
|
+
// the stale strength (a manual refresh here would exercise the sense
|
|
128
|
+
// pass and hide a missing key, which the review's mutation proved).
|
|
129
|
+
vi.useFakeTimers();
|
|
130
|
+
try {
|
|
131
|
+
const instance = ref<{ refresh: () => void } | null>(null);
|
|
132
|
+
const container = document.createElement("div");
|
|
133
|
+
document.body.appendChild(container);
|
|
134
|
+
containers.push(container);
|
|
135
|
+
const props = reactive({ dockFade: true });
|
|
136
|
+
const app = createApp(defineComponent({
|
|
137
|
+
setup() {
|
|
138
|
+
return () =>
|
|
139
|
+
h(
|
|
140
|
+
HkScrollContainer,
|
|
141
|
+
{ ref: instance as never, ...props },
|
|
142
|
+
{
|
|
143
|
+
default: () => h("div", { class: "content" }, "rows"),
|
|
144
|
+
dockBottom: () => h("div", { class: "the-dock" }, "dock"),
|
|
145
|
+
},
|
|
146
|
+
);
|
|
147
|
+
},
|
|
148
|
+
}));
|
|
149
|
+
mounts.push(app);
|
|
150
|
+
const host = (app.mount(container) as unknown as { $el: HTMLElement }).$el;
|
|
151
|
+
const viewport = host.querySelector(".hk-scroll-container-viewport") as HTMLElement;
|
|
152
|
+
Object.defineProperty(viewport, "scrollHeight", { value: 400, configurable: true });
|
|
153
|
+
Object.defineProperty(viewport, "clientHeight", { value: 100, configurable: true });
|
|
154
|
+
Object.defineProperty(viewport, "scrollTop", { value: 0, configurable: true });
|
|
155
|
+
instance.value?.refresh();
|
|
156
|
+
await vi.advanceTimersByTimeAsync(60);
|
|
157
|
+
// 300 hidden below the fold: the gate is lit at full depth.
|
|
158
|
+
expect(host.style.getPropertyValue("--hk-scroll-fade-strength-bottom")).toBe("1");
|
|
159
|
+
|
|
160
|
+
props.dockFade = false;
|
|
161
|
+
// NO refresh: the watcher's own scheduled update must do the pass.
|
|
162
|
+
await vi.advanceTimersByTimeAsync(60);
|
|
163
|
+
// The dock branch no longer runs, the stale value was cleared and
|
|
164
|
+
// nothing republished it.
|
|
165
|
+
expect(host.style.getPropertyValue("--hk-scroll-fade-strength-bottom")).toBe("");
|
|
166
|
+
} finally {
|
|
167
|
+
vi.useRealTimers();
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
|
|
73
171
|
it("retires the dock band at the scroll end instead of covering the last row", async () => {
|
|
74
172
|
// 2026-11-12 user report: the cruise board's band kept painting over
|
|
75
173
|
// its own flush-parked last row at full scroll. Dock bands share the
|
|
@@ -86,8 +86,10 @@
|
|
|
86
86
|
into a 0..1 number mirrored as --hk-scroll-fade-strength-<side>.
|
|
87
87
|
Pull the strip and the trailing edge's fade grows from a hard cut
|
|
88
88
|
through a hint to the full band; scroll back and it recedes. Edges
|
|
89
|
-
with nothing hidden read strength 1 (the pre-JS
|
|
90
|
-
|
|
89
|
+
with nothing hidden read strength 1 (the pre-JS fallback), which
|
|
90
|
+
with a 0px band contributes nothing. Dock-fed edges are gated
|
|
91
|
+
separately by the dock branch (binary, see the dock-edge-fade
|
|
92
|
+
block). Physical-side
|
|
91
93
|
names AND a mirrored data-dir: the component resolves the computed
|
|
92
94
|
direction once and publishes both the depths and the direction
|
|
93
95
|
attribute from the same pass, so the LTR and RTL state rules
|
|
@@ -381,16 +383,19 @@
|
|
|
381
383
|
documented shape, not a bug.
|
|
382
384
|
|
|
383
385
|
The dock band MULTIPLIES its own size by the published strength
|
|
384
|
-
(2026-11-12 user report).
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
386
|
+
(2026-11-12 user report). Before the dock gate the component published
|
|
387
|
+
no strengths for a dock-only container (the `fade` prop owns that
|
|
388
|
+
ramp), so the band sat at full depth forever and a scroller parked at
|
|
389
|
+
its END kept painting over its own last row —
|
|
388
390
|
「拉到最底部仍然有渐变阴影覆盖最后一行」. The dock path now publishes a
|
|
389
391
|
binary gate (lit while the edge hides content, retired at the end), and
|
|
390
|
-
this `calc()` is what turns it into px:
|
|
391
|
-
the flush-parked row reads in full
|
|
392
|
-
|
|
393
|
-
|
|
392
|
+
this `calc()` is what turns it into px: with `fade` off, the dock
|
|
393
|
+
branch publishes 0 at the end, so the flush-parked row reads in full
|
|
394
|
+
(with `fade` on, the ramp branch owns the edge and the 2026-11-06
|
|
395
|
+
ownership note above still describes that combination). The `1`
|
|
396
|
+
fallback keeps the pre-fix full band wherever nothing is published
|
|
397
|
+
(SSR, no JS pass yet). A ride dock does run the gate but stamps no
|
|
398
|
+
marker, so its published values have no reader. */
|
|
394
399
|
.hk-scroll-container[data-dock-fade="bottom"] {
|
|
395
400
|
--hk-scroll-fade-bottom: calc(
|
|
396
401
|
var(--hk-scroll-dock-fade, 2rem) * var(--hk-scroll-fade-strength-bottom, 1)
|
|
@@ -235,7 +235,14 @@ export default defineComponent({
|
|
|
235
235
|
* ride-mode dock: that dock lives INSIDE the masked viewport, so the
|
|
236
236
|
* same band would fade the dock's own bottom edge; and it needs no
|
|
237
237
|
* dissolve at all, because the air between content and dock is the
|
|
238
|
-
* dock's measured height (see `dockMode`).
|
|
238
|
+
* dock's measured height (see `dockMode`). The band RETIRES at the
|
|
239
|
+
* scroll end (2026-11-12 user report): it is the dock size
|
|
240
|
+
* multiplied by a binary strength this component publishes for
|
|
241
|
+
* dock-fed edges — lit while content still hides past the edge,
|
|
242
|
+
* retired at the sense's own 1px deadband — so a flush-parked last
|
|
243
|
+
* row reads in full instead of sitting under a permanent gradient.
|
|
244
|
+
* With `fade` ALSO on, the ramp branch owns the edges and the
|
|
245
|
+
* sheet's ownership note describes that combination. */
|
|
239
246
|
dockFade: { type: Boolean, default: true },
|
|
240
247
|
/** Opt-in tail clearance for FLOATING docks (2026-10-12): a dock that
|
|
241
248
|
* lives OUTSIDE this container (a shell-level fixed plane — a page's
|
|
@@ -1086,7 +1093,7 @@ export default defineComponent({
|
|
|
1086
1093
|
// Runtime fade changes re-sense immediately: flipping `fade` on with
|
|
1087
1094
|
// content already hidden must not wait for a scroll, and a different
|
|
1088
1095
|
// fadeDistance re-derives every strength without any DOM motion.
|
|
1089
|
-
watch(() => [props.fade, props.fadeDistance] as const, () => {
|
|
1096
|
+
watch(() => [props.fade, props.fadeDistance, props.dockFade] as const, () => {
|
|
1090
1097
|
scheduleUpdate();
|
|
1091
1098
|
});
|
|
1092
1099
|
|
|
@@ -153,55 +153,17 @@
|
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
/* ── Day period (AM / PM) ─────────────────────────────────────── */
|
|
156
|
-
|
|
156
|
+
/* The segmented control is hikari's HkPillToggleGroup; only the clock
|
|
157
|
+
* panel's own alignment/icon scale lives here. */
|
|
157
158
|
.hk-tp-period {
|
|
158
|
-
display: grid;
|
|
159
|
-
grid-template-columns: 1fr 1fr;
|
|
160
|
-
gap: 2px;
|
|
161
|
-
padding: 2px;
|
|
162
|
-
background: color-mix(in srgb, rgb(var(--color-surface)) 70%, transparent);
|
|
163
|
-
border: 1px solid color-mix(in srgb, rgb(var(--color-text)) 12%, transparent);
|
|
164
|
-
border-radius: var(--radius-md, 8px);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
.hk-tp-period-btn {
|
|
168
|
-
appearance: none;
|
|
169
|
-
border: 0;
|
|
170
|
-
background: transparent;
|
|
171
|
-
height: 2rem;
|
|
172
|
-
display: inline-flex;
|
|
173
|
-
align-items: center;
|
|
174
159
|
justify-content: center;
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
font-weight: 600;
|
|
179
|
-
letter-spacing: 0.02em;
|
|
180
|
-
color: var(--hi-color-muted);
|
|
181
|
-
border-radius: var(--radius-sm, 4px);
|
|
182
|
-
cursor: pointer;
|
|
183
|
-
transition:
|
|
184
|
-
background-color var(--duration-fast, 0.15s) ease,
|
|
185
|
-
color var(--duration-fast, 0.15s) ease;
|
|
186
|
-
|
|
187
|
-
&:hover:not(.is-active) {
|
|
188
|
-
background: color-mix(in srgb, rgb(var(--color-text)) 6%, transparent);
|
|
189
|
-
color: var(--hi-color-text-primary);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
&.is-active {
|
|
193
|
-
background: rgb(var(--color-primary));
|
|
194
|
-
color: rgb(var(--color-on-solid));
|
|
195
|
-
|
|
196
|
-
svg {
|
|
197
|
-
color: rgb(var(--color-on-solid-icon, 255 255 255));
|
|
198
|
-
}
|
|
199
|
-
}
|
|
160
|
+
cursor: default;
|
|
161
|
+
touch-action: manipulation;
|
|
162
|
+
}
|
|
200
163
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
}
|
|
164
|
+
.hk-tp-period .hk-pill-group-icon svg {
|
|
165
|
+
width: 13px;
|
|
166
|
+
height: 13px;
|
|
205
167
|
}
|
|
206
168
|
|
|
207
169
|
/* ── Readout ──────────────────────────────────────────────────── */
|
|
@@ -423,15 +385,15 @@
|
|
|
423
385
|
font-size: var(--text-sm, 0.875rem);
|
|
424
386
|
}
|
|
425
387
|
|
|
426
|
-
.hk-tp-panel.is-touch .hk-tp-period-
|
|
427
|
-
height: 2.35rem;
|
|
388
|
+
.hk-tp-panel.is-touch .hk-tp-period .hk-pill-group-pill {
|
|
389
|
+
min-height: 2.35rem;
|
|
428
390
|
font-size: var(--text-sm, 0.875rem);
|
|
429
391
|
}
|
|
430
392
|
|
|
431
393
|
@media (prefers-reduced-motion: reduce) {
|
|
432
394
|
.hk-tp-trigger,
|
|
433
395
|
.hk-tp-clear,
|
|
434
|
-
.hk-tp-period-
|
|
396
|
+
.hk-tp-period .hk-pill-group-pill,
|
|
435
397
|
.hk-tp-readout-btn,
|
|
436
398
|
.hk-tp-number {
|
|
437
399
|
transition: none;
|
|
@@ -0,0 +1,31 @@
|
|
|
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, "HkTimePicker.scss"), "utf8");
|
|
9
|
+
const tsx = readFileSync(resolve(here, "HkTimePicker.tsx"), "utf8");
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Source-contract pins: the minute-mode metrics key (the number layer is
|
|
13
|
+
* a sibling of the slider, so `.hk-tp-face.is-minute` can never match —
|
|
14
|
+
* a regression pin even though the selector predates this PR) and the
|
|
15
|
+
* shared segmented period control introduced here. A SCSS-only edit
|
|
16
|
+
* reintroducing the old selector used to leave every behavioral test
|
|
17
|
+
* green; this file is the missing guard.
|
|
18
|
+
*/
|
|
19
|
+
describe("HkTimePicker source contracts", () => {
|
|
20
|
+
it("keys the minute-mode rules on the number layer, never the face", () => {
|
|
21
|
+
expect(scss).toContain(".hk-tp-numbers.is-minute .hk-tp-number");
|
|
22
|
+
expect(scss).toContain(".hk-tp-panel.is-touch .hk-tp-numbers.is-minute .hk-tp-number");
|
|
23
|
+
expect(scss).not.toContain(".hk-tp-face.is-minute");
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("builds the day period on hikari's shared pill group", () => {
|
|
27
|
+
expect(tsx).toContain('from "./HkPillToggleGroup"');
|
|
28
|
+
expect(tsx).toContain("<HkPillToggleGroup");
|
|
29
|
+
expect(scss).not.toContain(".hk-tp-period-btn");
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -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-
|
|
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();
|