@celestia-island/hikari 0.55.401 → 0.55.403

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.
Files changed (31) hide show
  1. package/package.json +1 -1
  2. package/src/components/HkDateTag.test.tsx +46 -3
  3. package/src/components/HkDateTag.tsx +18 -4
  4. package/src/components/HkRemoteInputDock.barrel.test.ts +29 -0
  5. package/src/components/HkRemoteInputDock.scss +125 -0
  6. package/src/components/HkRemoteInputDock.test.tsx +271 -0
  7. package/src/components/HkRemoteInputDock.tsx +252 -0
  8. package/src/components/HkVirtualCursor.scss +93 -0
  9. package/src/components/HkVirtualCursor.test.tsx +146 -0
  10. package/src/components/HkVirtualCursor.tsx +133 -0
  11. package/src/components/remoteInputTypes.test.ts +47 -0
  12. package/src/components/remoteInputTypes.ts +95 -0
  13. package/src/composables/useOrientationLock.test.ts +39 -0
  14. package/src/composables/useOrientationLock.ts +39 -0
  15. package/src/composables/useRemoteTouchGestures.test.ts +180 -0
  16. package/src/composables/useRemoteTouchGestures.ts +251 -0
  17. package/src/composables/useVirtualPointer.test.ts +128 -0
  18. package/src/composables/useVirtualPointer.ts +151 -0
  19. package/src/i18n/locales/ar/components.json +58 -47
  20. package/src/i18n/locales/de/components.json +58 -47
  21. package/src/i18n/locales/en/components.json +58 -47
  22. package/src/i18n/locales/es/components.json +58 -47
  23. package/src/i18n/locales/fr/components.json +58 -47
  24. package/src/i18n/locales/ja/components.json +58 -47
  25. package/src/i18n/locales/ko/components.json +58 -47
  26. package/src/i18n/locales/pt/components.json +58 -47
  27. package/src/i18n/locales/ru/components.json +58 -47
  28. package/src/i18n/locales/zh-Hans/components.json +62 -51
  29. package/src/i18n/locales/zh-Hant/components.json +62 -51
  30. package/src/i18n/usageSurface.test.ts +4 -0
  31. package/src/index.ts +25 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celestia-island/hikari",
3
- "version": "0.55.401",
3
+ "version": "0.55.403",
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",
@@ -10,8 +10,9 @@ import { setLocale } from "../i18n/context";
10
10
  * COMPONENT contract: the segment order follows the ACTIVE hikari
11
11
  * locale (year first for zh-Hans, year LAST for en) with that locale's
12
12
  * own separators, the order re-derives live when the host flips the
13
- * locale, `time` appends the muted trailing segment, and unparseable
14
- * input renders the empty pill shell.
13
+ * locale, `time` appends the muted trailing segment, `seconds` widens
14
+ * that segment to hour:minute:second (only under `time`), and
15
+ * unparseable input renders the empty pill shell.
15
16
  */
16
17
 
17
18
  const mounts: Array<{ app: ReturnType<typeof createApp>; container: HTMLElement }> = [];
@@ -20,7 +21,11 @@ const mounts: Array<{ app: ReturnType<typeof createApp>; container: HTMLElement
20
21
  // every CI time zone; the pill renders local calendar segments.
21
22
  const SHIP_DATE = new Date(2024, 9, 6, 14, 30);
22
23
 
23
- function mountTag(props: { value: string | number | Date; time?: boolean }): HTMLElement {
24
+ function mountTag(props: {
25
+ value: string | number | Date;
26
+ time?: boolean;
27
+ seconds?: boolean;
28
+ }): HTMLElement {
24
29
  const container = document.createElement("div");
25
30
  document.body.appendChild(container);
26
31
  const app = createApp({ render: () => h(HkDateTag, props) });
@@ -123,6 +128,44 @@ describe("HkDateTag time segment", () => {
123
128
  });
124
129
  });
125
130
 
131
+ describe("HkDateTag seconds segment", () => {
132
+ // A nonzero second is the point: the widened segment must show the
133
+ // record's exact tick, not a padded zero.
134
+ const TICK = new Date(2024, 9, 6, 14, 30, 5);
135
+
136
+ it("widens the time segment to hour:minute:second when asked", async () => {
137
+ await setLocale("zh-Hans");
138
+ const container = mountTag({ value: TICK, time: true, seconds: true });
139
+ const segs = segsOf(container);
140
+ // Same segment count and element role as the plain time pill — the
141
+ // widening refines the segment in place.
142
+ expect(segs).toHaveLength(4);
143
+ expect(segs[3].classList.contains("hk-date-tag__seg--time")).toBe(true);
144
+ expect(segs[3].textContent).toBe("14:30:05");
145
+ expect(textOf(container)).toBe("2024/10/06 14:30:05");
146
+ });
147
+
148
+ it("formats the seconds form for the active locale", async () => {
149
+ await setLocale("en");
150
+ const container = mountTag({ value: TICK, time: true, seconds: true });
151
+ const segs = segsOf(container);
152
+ expect(segs).toHaveLength(4);
153
+ expect(segs[3]!.textContent).toBe("02:30:05 PM");
154
+ expect(textOf(container)).toBe("10/06/2024 02:30:05 PM");
155
+ });
156
+
157
+ it("does nothing without the time flag", async () => {
158
+ await setLocale("zh-Hans");
159
+ const container = mountTag({ value: TICK, seconds: true });
160
+ const segs = segsOf(container);
161
+ expect(segs).toHaveLength(3);
162
+ expect(segs.some((s) => s.classList.contains("hk-date-tag__seg--time"))).toBe(false);
163
+ // No time segment also means NO separator — the pill's text is the
164
+ // bare date, byte-identical to the no-flags render.
165
+ expect(textOf(container)).toBe("2024/10/06");
166
+ });
167
+ });
168
+
126
169
  describe("HkDateTag value normalization", () => {
127
170
  it("accepts epoch milliseconds and date strings like the Date form", async () => {
128
171
  await setLocale("en");
@@ -10,7 +10,8 @@ import "./HkDateTag.scss";
10
10
  * dates (zh: 2024/10/06 — year first; en: 10/06/2024 — the year LAST;
11
11
  * de: 06.10.2024 — day first), joined by that locale's own literal
12
12
  * separators. With the `time` flag a fourth, muted segment carries the
13
- * locale time (hour + minute, 2-digit) after a blank separator.
13
+ * locale time (hour + minute, 2-digit — widened to hour:minute:second
14
+ * under `seconds`) after a blank separator.
14
15
  *
15
16
  * Generic business part (peer of HkTemplateText / HkMarkdownRenderer,
16
17
  * NOT of the HkInput family): hosts render compact per-row dates in
@@ -32,6 +33,11 @@ import "./HkDateTag.scss";
32
33
  * `setLocale` re-orders the line live.
33
34
  * - `time` (default false) appends the muted time segment
34
35
  * (`hk-date-tag__seg--time`) after a blank separator.
36
+ * - `seconds` (default false) widens the time segment to
37
+ * hour:minute:second — it refines the `time` segment in place (same
38
+ * element, same muted role) and does nothing when `time` is false.
39
+ * Trace/log surfaces that need second precision (a 176ms tool call
40
+ * landing between two :30 ticks) opt in; tables stay at HH:mm.
35
41
  */
36
42
  export const HkDateTag = defineComponent({
37
43
  name: "HkDateTag",
@@ -44,6 +50,8 @@ export const HkDateTag = defineComponent({
44
50
  },
45
51
  /** Append the muted locale time segment (hour + minute, 2-digit). */
46
52
  time: { type: Boolean, default: false },
53
+ /** Widen the time segment to hour:minute:second (needs `time`). */
54
+ seconds: { type: Boolean, default: false },
47
55
  },
48
56
  setup(props) {
49
57
  const date = computed<Date | null>(() => {
@@ -70,12 +78,18 @@ export const HkDateTag = defineComponent({
70
78
  }).formatToParts(d);
71
79
  });
72
80
 
73
- /** The locale time (hour + minute, 2-digit) when the pill opts
74
- * in — null without `time` or for an invalid date. */
81
+ /** The locale time (hour + minute, or hour:minute:second under
82
+ * `seconds`) when the pill opts in — null without `time` or for an
83
+ * invalid date. */
75
84
  const timeText = computed<string | null>(() => {
76
85
  const d = date.value;
77
86
  if (!props.time || d === null) return null;
78
- return new Intl.DateTimeFormat(locale.value, { hour: "2-digit", minute: "2-digit" }).format(d);
87
+ return new Intl.DateTimeFormat(
88
+ locale.value,
89
+ props.seconds
90
+ ? { hour: "2-digit", minute: "2-digit", second: "2-digit" }
91
+ : { hour: "2-digit", minute: "2-digit" },
92
+ ).format(d);
79
93
  });
80
94
 
81
95
  return () => (
@@ -0,0 +1,29 @@
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 (HkAdaptiveTabs.barrel.test.ts shape): the
7
+ * component's own tests reach it through "./HkRemoteInputDock" — only
8
+ * an external consumer would notice a dropped export line.
9
+ */
10
+ describe("the public barrel", () => {
11
+ it("exports the remote-input components under both family names", () => {
12
+ const dock = asIndexable(barrel.HkRemoteInputDock);
13
+ expect(dock, "HkRemoteInputDock must be re-exported").toBeTruthy();
14
+ expect(dock.name).toBe("HkRemoteInputDock");
15
+ expect(barrel.HRemoteInputDock).toBe(barrel.HkRemoteInputDock);
16
+
17
+ const cursor = asIndexable(barrel.HkVirtualCursor);
18
+ expect(cursor, "HkVirtualCursor must be re-exported").toBeTruthy();
19
+ expect(cursor.name).toBe("HkVirtualCursor");
20
+ expect(barrel.HVirtualCursor).toBe(barrel.HkVirtualCursor);
21
+ });
22
+
23
+ it("exports the composables and the mask vocabulary", () => {
24
+ expect(typeof barrel.useVirtualPointer).toBe("function");
25
+ expect(typeof barrel.useRemoteTouchGestures).toBe("function");
26
+ expect(typeof barrel.useOrientationLock).toBe("function");
27
+ expect([barrel.MASK_LEFT, barrel.MASK_MIDDLE, barrel.MASK_RIGHT]).toEqual([1, 2, 4]);
28
+ });
29
+ });
@@ -0,0 +1,125 @@
1
+ /* HkRemoteInputDock — the remote-control dial.
2
+ *
3
+ * A fixed-corner dial button that expands into the control card. The
4
+ * card speaks the panel grammar (sheet surface, fine radius) so it
5
+ * reads as a floating panel, not a popup menu. */
6
+
7
+ @use "../styles/polyfill" as *;
8
+
9
+ .hk-remote-input-dock {
10
+ position: absolute;
11
+ /* The dock-gap law (#1340): every dock's edge gap reads the shared
12
+ * override chain, never a private constant. */
13
+ right: var(--hk-dock-gap-right, var(--hk-dock-inset, var(--hk-dock-gap, var(--space-16, 1rem))));
14
+ bottom: var(--hk-dock-gap-bottom, var(--hk-dock-inset, var(--hk-dock-gap, var(--space-16, 1rem))));
15
+ z-index: 3; /* above the session surface + virtual cursor */
16
+ display: flex;
17
+ flex-direction: column;
18
+ align-items: flex-end;
19
+ gap: 0.5rem;
20
+ }
21
+
22
+ .hk-remote-input-dock__dial {
23
+ width: 44px;
24
+ height: 44px;
25
+ border-radius: 999px;
26
+ border: 1px solid rgb(var(--color-border));
27
+ background: rgb(var(--color-background) / 92%);
28
+ color: rgb(var(--color-text));
29
+ display: grid;
30
+ place-items: center;
31
+ cursor: pointer;
32
+ box-shadow: 0 4px 14px rgb(0 0 0 / 30%);
33
+ @include backdrop-filter(blur(6px));
34
+
35
+ &[data-open] {
36
+ background: rgb(var(--color-primary) / 90%);
37
+ color: rgb(var(--color-on-primary, 255 255 255));
38
+ border-color: rgb(var(--color-primary));
39
+ }
40
+
41
+ &:focus-visible {
42
+ outline: 2px solid rgb(var(--color-primary) / 70%);
43
+ outline-offset: 2px;
44
+ }
45
+ }
46
+
47
+ .hk-remote-input-dock__card {
48
+ width: 13rem;
49
+ padding: 0.6rem;
50
+ border-radius: var(--radius-md, 10px);
51
+ border: 1px solid rgb(var(--color-border));
52
+ background: rgb(var(--color-background) / 96%);
53
+ box-shadow: 0 8px 24px rgb(0 0 0 / 35%);
54
+ @include backdrop-filter(blur(8px));
55
+ display: flex;
56
+ flex-direction: column;
57
+ gap: 0.5rem;
58
+ }
59
+
60
+ .hk-remote-input-dock__modes {
61
+ display: grid;
62
+ grid-template-columns: 1fr 1fr;
63
+ gap: 0.35rem;
64
+ }
65
+
66
+ .hk-remote-input-dock__mode {
67
+ padding: 0.35rem 0.4rem;
68
+ border-radius: var(--radius-sm, 6px);
69
+ border: 1px solid rgb(var(--color-border));
70
+ background: transparent;
71
+ color: rgb(var(--color-text));
72
+ font-size: 0.78rem;
73
+ cursor: pointer;
74
+
75
+ &[data-active] {
76
+ background: rgb(var(--color-primary) / 14%);
77
+ border-color: rgb(var(--color-primary) / 60%);
78
+ color: rgb(var(--color-primary));
79
+ }
80
+
81
+ &:focus-visible {
82
+ outline: 2px solid rgb(var(--color-primary) / 70%);
83
+ outline-offset: 1px;
84
+ }
85
+ }
86
+
87
+ .hk-remote-input-dock__pad {
88
+ display: grid;
89
+ grid-template-columns: repeat(5, 1fr);
90
+ gap: 0.3rem;
91
+ }
92
+
93
+ .hk-remote-input-dock__btn {
94
+ height: 2rem;
95
+ border-radius: var(--radius-sm, 6px);
96
+ border: 1px solid rgb(var(--color-border));
97
+ background: rgb(var(--color-surface, var(--color-background)));
98
+ color: rgb(var(--color-text));
99
+ font-size: 0.8rem;
100
+ cursor: pointer;
101
+ touch-action: none;
102
+ @include user-select(none);
103
+
104
+ &:active:not(:disabled) {
105
+ background: rgb(var(--color-primary) / 22%);
106
+ }
107
+
108
+ &:disabled {
109
+ opacity: 0.45;
110
+ cursor: default;
111
+ }
112
+
113
+ &:focus-visible {
114
+ outline: 2px solid rgb(var(--color-primary) / 70%);
115
+ outline-offset: 1px;
116
+ }
117
+ }
118
+
119
+ .hk-remote-input-dock__host {
120
+ display: flex;
121
+ flex-wrap: wrap;
122
+ gap: 0.35rem;
123
+ padding-top: 0.35rem;
124
+ border-top: 1px solid rgb(var(--color-border) / 60%);
125
+ }
@@ -0,0 +1,271 @@
1
+ import { afterEach, describe, expect, it, vitest } from "vitest";
2
+ import { createApp, defineComponent, h, nextTick, ref } from "vue";
3
+
4
+ import HkRemoteInputDock from "./HkRemoteInputDock";
5
+
6
+ const mounts: ReturnType<typeof createApp>[] = [];
7
+ const containers: HTMLElement[] = [];
8
+
9
+ interface Mounted {
10
+ container: HTMLElement;
11
+ dial: HTMLButtonElement;
12
+ modes: () => HTMLButtonElement[];
13
+ btns: () => HTMLButtonElement[];
14
+ }
15
+
16
+ /** Mount a dock through a wrapper app (the HkFab.test.tsx pattern). */
17
+ function mountDock(props: Record<string, unknown> = {}, slot?: () => ReturnType<typeof h>): Mounted {
18
+ const container = document.createElement("div");
19
+ document.body.appendChild(container);
20
+ containers.push(container);
21
+
22
+ const Wrapper = defineComponent({
23
+ setup() {
24
+ return () =>
25
+ h(HkRemoteInputDock, props, slot ? { default: slot } : undefined);
26
+ },
27
+ });
28
+ const app = createApp(Wrapper);
29
+ mounts.push(app);
30
+ app.mount(container);
31
+
32
+ const dial = container.querySelector<HTMLButtonElement>(".hk-remote-input-dock__dial");
33
+ if (!dial) throw new Error("dock did not render its dial");
34
+ return {
35
+ container,
36
+ dial,
37
+ modes: () => [...container.querySelectorAll<HTMLButtonElement>(".hk-remote-input-dock__mode")],
38
+ btns: () => [...container.querySelectorAll<HTMLButtonElement>(".hk-remote-input-dock__btn")],
39
+ };
40
+ }
41
+
42
+ afterEach(() => {
43
+ while (mounts.length) mounts.pop()?.unmount();
44
+ while (containers.length) containers.pop()?.remove();
45
+ });
46
+
47
+ describe("HkRemoteInputDock", () => {
48
+ it("hidden prop renders nothing", () => {
49
+ const container = document.createElement("div");
50
+ document.body.appendChild(container);
51
+ containers.push(container);
52
+ const app = createApp({ render: () => h(HkRemoteInputDock, { hidden: true }) });
53
+ mounts.push(app);
54
+ app.mount(container);
55
+ expect(container.querySelector(".hk-remote-input-dock")).toBeNull();
56
+ });
57
+
58
+ it("the dial expands the card; the mode radios drive update:mode", async () => {
59
+ const seen: string[] = [];
60
+ const m = mountDock({ mode: "direct", "onUpdate:mode": (v: string) => seen.push(v) });
61
+ expect(m.container.querySelector(".hk-remote-input-dock__card")).toBeNull();
62
+ m.dial.click();
63
+ await nextTick();
64
+ expect(m.container.querySelector(".hk-remote-input-dock__card")).not.toBeNull();
65
+ const radios = m.modes();
66
+ expect(radios[0]!.getAttribute("aria-checked")).toBe("true");
67
+ expect(radios[1]!.getAttribute("aria-checked")).toBe("false");
68
+ radios[1]!.click();
69
+ await nextTick();
70
+ expect(seen).toEqual(["virtual"]);
71
+ });
72
+
73
+ it("pad hold-buttons drive the actions with an absolute held mask", async () => {
74
+ const actions = { setButtons: vitest.fn(), wheel: vitest.fn() };
75
+ const m = mountDock({ mode: "virtual", actions });
76
+ m.dial.click();
77
+ await nextTick();
78
+ const btns = m.btns();
79
+ // [left, middle, right, wheelUp, wheelDown]
80
+ btns[0]!.dispatchEvent(new Event("pointerdown", { bubbles: true }));
81
+ expect(actions.setButtons).toHaveBeenLastCalledWith(0b001);
82
+ btns[2]!.dispatchEvent(new Event("pointerdown", { bubbles: true }));
83
+ expect(actions.setButtons).toHaveBeenLastCalledWith(0b101);
84
+ btns[0]!.dispatchEvent(new Event("pointerup", { bubbles: true }));
85
+ expect(actions.setButtons).toHaveBeenLastCalledWith(0b100);
86
+ // An unheld pad's pointerleave must not fire a phantom release.
87
+ actions.setButtons.mockClear();
88
+ btns[1]!.dispatchEvent(new Event("pointerleave", { bubbles: true }));
89
+ expect(actions.setButtons).not.toHaveBeenCalled();
90
+ });
91
+
92
+ it("wheel taps ride the actions; without actions the pad disables", async () => {
93
+ const actions = { setButtons: vitest.fn(), wheel: vitest.fn() };
94
+ const m = mountDock({ actions });
95
+ m.dial.click();
96
+ await nextTick();
97
+ const btns = m.btns();
98
+ btns[3]!.click();
99
+ btns[4]!.click();
100
+ expect(actions.wheel.mock.calls).toEqual([[1], [-1]]);
101
+
102
+ while (mounts.length) mounts.pop()?.unmount();
103
+ while (containers.length) containers.pop()?.remove();
104
+ const bare = mountDock();
105
+ bare.dial.click();
106
+ await nextTick();
107
+ expect(bare.btns()[0]!.disabled).toBe(true);
108
+ });
109
+
110
+ it("outside pointerdown and Escape close the card", async () => {
111
+ const m = mountDock();
112
+ m.dial.click();
113
+ await nextTick();
114
+ expect(m.container.querySelector(".hk-remote-input-dock__card")).not.toBeNull();
115
+ document.dispatchEvent(
116
+ new KeyboardEvent("keydown", { key: "Escape", bubbles: true, cancelable: true }),
117
+ );
118
+ await nextTick();
119
+ expect(m.container.querySelector(".hk-remote-input-dock__card")).toBeNull();
120
+ });
121
+
122
+ it("a HELD pad keeps the card open across outside touches", async () => {
123
+ const actions = { setButtons: vitest.fn(), wheel: vitest.fn() };
124
+ const m = mountDock({ actions });
125
+ m.dial.click();
126
+ await nextTick();
127
+ const btns = m.btns();
128
+ btns[0]!.dispatchEvent(new Event("pointerdown", { bubbles: true }));
129
+ // A touch on the canvas (outside the dock) while the pad is held:
130
+ // the card must stay open — the held button is still in use.
131
+ document.dispatchEvent(new Event("pointerdown", { bubbles: true }));
132
+ await nextTick();
133
+ expect(m.container.querySelector(".hk-remote-input-dock__card")).not.toBeNull();
134
+ // Releasing the pad: an outside touch now closes.
135
+ btns[0]!.dispatchEvent(new Event("pointerup", { bubbles: true }));
136
+ document.dispatchEvent(new Event("pointerdown", { bubbles: true }));
137
+ await nextTick();
138
+ expect(m.container.querySelector(".hk-remote-input-dock__card")).toBeNull();
139
+ });
140
+
141
+ it("every card-unmount path force-releases held bits", async () => {
142
+ // (a) Escape closes → release
143
+ const a = { setButtons: vitest.fn(), wheel: vitest.fn() };
144
+ const ma = mountDock({ actions: a });
145
+ ma.dial.click();
146
+ await nextTick();
147
+ ma.btns()[2]!.dispatchEvent(new Event("pointerdown", { bubbles: true }));
148
+ document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true, cancelable: true }));
149
+ await nextTick();
150
+ expect(a.setButtons).toHaveBeenLastCalledWith(0);
151
+
152
+ // (b) hidden while open → release
153
+ const b = { setButtons: vitest.fn(), wheel: vitest.fn() };
154
+ const container = document.createElement("div");
155
+ document.body.appendChild(container);
156
+ containers.push(container);
157
+ const app = createApp({
158
+ setup() {
159
+ const hidden = ref(false);
160
+ return () => [
161
+ h(HkRemoteInputDock, { actions: b, hidden: hidden.value }),
162
+ h("button", { class: "flip", onClick: () => { hidden.value = true; } }, "flip"),
163
+ ];
164
+ },
165
+ });
166
+ mounts.push(app);
167
+ app.mount(container);
168
+ (container.querySelector<HTMLButtonElement>(".hk-remote-input-dock__dial"))!.click();
169
+ await nextTick();
170
+ const padBtns = [...container.querySelectorAll<HTMLButtonElement>(".hk-remote-input-dock__btn")];
171
+ padBtns[0]!.dispatchEvent(new Event("pointerdown", { bubbles: true }));
172
+ expect(b.setButtons).toHaveBeenLastCalledWith(0b001);
173
+ (container.querySelector<HTMLButtonElement>(".flip"))!.click();
174
+ await nextTick();
175
+ expect(container.querySelector(".hk-remote-input-dock")).toBeNull();
176
+ expect(b.setButtons).toHaveBeenLastCalledWith(0); // hidden force-releases
177
+ // A hidden dock swallows no Escape: the listener stood down.
178
+ const esc = new KeyboardEvent("keydown", { key: "Escape", bubbles: true, cancelable: true });
179
+ document.dispatchEvent(esc);
180
+ expect(esc.defaultPrevented).toBe(false);
181
+ });
182
+
183
+ it("component UNMOUNT releases a held pad (the third teardown path)", async () => {
184
+ const actions = { setButtons: vitest.fn(), wheel: vitest.fn() };
185
+ const m = mountDock({ actions });
186
+ m.dial.click();
187
+ await nextTick();
188
+ m.btns()[1]!.dispatchEvent(new Event("pointerdown", { bubbles: true }));
189
+ expect(actions.setButtons).toHaveBeenLastCalledWith(0b010);
190
+ while (mounts.length) mounts.pop()?.unmount();
191
+ expect(actions.setButtons).toHaveBeenLastCalledWith(0);
192
+ });
193
+
194
+ it("actions vanishing mid-hold clears the strand locally", async () => {
195
+ const actions = { setButtons: vitest.fn(), wheel: vitest.fn() };
196
+ const container = document.createElement("div");
197
+ document.body.appendChild(container);
198
+ containers.push(container);
199
+ const app = createApp({
200
+ setup() {
201
+ const live = ref<typeof actions | null>(actions);
202
+ return () => [
203
+ h(HkRemoteInputDock, { actions: live.value }),
204
+ h("button", { class: "drop", onClick: () => { live.value = null; } }, "drop"),
205
+ h("button", { class: "revive", onClick: () => { live.value = actions; } }, "revive"),
206
+ ];
207
+ },
208
+ });
209
+ mounts.push(app);
210
+ app.mount(container);
211
+ (container.querySelector<HTMLButtonElement>(".hk-remote-input-dock__dial"))!.click();
212
+ await nextTick();
213
+ const pad = () => [...container.querySelectorAll<HTMLButtonElement>(".hk-remote-input-dock__btn")];
214
+ pad()[0]!.dispatchEvent(new Event("pointerdown", { bubbles: true }));
215
+ expect(actions.setButtons).toHaveBeenLastCalledWith(0b001);
216
+ // The wire vanishes mid-hold: no release frame can ride it (it is
217
+ // GONE), but the local bit must not linger into the next session.
218
+ (container.querySelector<HTMLButtonElement>(".drop"))!.click();
219
+ await nextTick();
220
+ (container.querySelector<HTMLButtonElement>(".revive"))!.click();
221
+ await nextTick();
222
+ actions.setButtons.mockClear();
223
+ // Press a DIFFERENT mask: a stranded 0b001 would ride along as
224
+ // 0b011 — the collinear same-mask form cannot distinguish.
225
+ pad()[1]!.dispatchEvent(new Event("pointerdown", { bubbles: true }));
226
+ expect(actions.setButtons).toHaveBeenLastCalledWith(0b010); // the strand died with the old wire
227
+ });
228
+
229
+ it("the radiogroup roves tabindex and switches on arrows", async () => {
230
+ const container = document.createElement("div");
231
+ document.body.appendChild(container);
232
+ containers.push(container);
233
+ const mode = ref<"direct" | "virtual">("direct");
234
+ const app = createApp({
235
+ setup: () => () =>
236
+ h(HkRemoteInputDock, {
237
+ mode: mode.value,
238
+ "onUpdate:mode": (v: "direct" | "virtual") => { mode.value = v; },
239
+ }),
240
+ });
241
+ mounts.push(app);
242
+ app.mount(container);
243
+ (container.querySelector<HTMLButtonElement>(".hk-remote-input-dock__dial"))!.click();
244
+ await nextTick();
245
+ const radios = () => [...container.querySelectorAll<HTMLButtonElement>(".hk-remote-input-dock__mode")];
246
+ expect(radios()[0]!.tabIndex).toBe(0);
247
+ expect(radios()[1]!.tabIndex).toBe(-1);
248
+ radios()[0]!.dispatchEvent(new KeyboardEvent("keydown", { key: "ArrowRight", bubbles: true }));
249
+ await nextTick();
250
+ expect(mode.value, "the arrow flipped the mode").toBe("virtual");
251
+ expect(radios()[1]!.tabIndex, "focus roved to the now-checked radio").toBe(0);
252
+ });
253
+
254
+ it("the pad carries its accessible group role and labels", async () => {
255
+ const m = mountDock({ actions: { setButtons: () => {}, wheel: () => {} } });
256
+ m.dial.click();
257
+ await nextTick();
258
+ const pad = m.container.querySelector('[class="hk-remote-input-dock__pad"]');
259
+ expect(pad!.getAttribute("role")).toBe("group");
260
+ expect(pad!.getAttribute("aria-label")).toBeTruthy();
261
+ const labelled = [...m.btns()].every((b) => b.getAttribute("aria-label"));
262
+ expect(labelled, "every pad button is labelled").toBe(true);
263
+ });
264
+
265
+ it("renders host view controls through the default slot", async () => {
266
+ const m = mountDock({}, () => h("button", { class: "host-ctl" }, "FIT"));
267
+ m.dial.click();
268
+ await nextTick();
269
+ expect(m.container.querySelector(".hk-remote-input-dock__host .host-ctl")).not.toBeNull();
270
+ });
271
+ });