@celestia-island/hikari 0.55.452 → 0.55.454

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.
@@ -50,6 +50,28 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
50
50
  type: BooleanConstructor;
51
51
  default: boolean;
52
52
  };
53
+ /** Keyboard access for the scrollable region (WCAG 2.1.1): the viewport
54
+ * takes `tabindex=0` and arrows / PageUp / PageDown / Home / End scroll
55
+ * it. Default ON — a scrollable region a keyboard user cannot reach is
56
+ * a compliance defect, and an extra tab stop is the standard cost
57
+ * (the viewport only scrolls while IT holds focus, so inner inputs,
58
+ * buttons and links keep their own key handling). */
59
+ keyboardScroll: {
60
+ type: BooleanConstructor;
61
+ default: boolean;
62
+ };
63
+ /** ARIA role for the viewport. Use a NON-live role ("region") for
64
+ * streaming content — "log"/"feed" carry implicit live semantics and
65
+ * would announce every appended line. Omitted = no role attribute. */
66
+ scrollRole: {
67
+ type: StringConstructor;
68
+ default: undefined;
69
+ };
70
+ /** Accessible name for the viewport (announced with the role). */
71
+ scrollLabel: {
72
+ type: StringConstructor;
73
+ default: undefined;
74
+ };
53
75
  overscanScreens: {
54
76
  type: NumberConstructor;
55
77
  default: number;
@@ -496,6 +518,28 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
496
518
  type: BooleanConstructor;
497
519
  default: boolean;
498
520
  };
521
+ /** Keyboard access for the scrollable region (WCAG 2.1.1): the viewport
522
+ * takes `tabindex=0` and arrows / PageUp / PageDown / Home / End scroll
523
+ * it. Default ON — a scrollable region a keyboard user cannot reach is
524
+ * a compliance defect, and an extra tab stop is the standard cost
525
+ * (the viewport only scrolls while IT holds focus, so inner inputs,
526
+ * buttons and links keep their own key handling). */
527
+ keyboardScroll: {
528
+ type: BooleanConstructor;
529
+ default: boolean;
530
+ };
531
+ /** ARIA role for the viewport. Use a NON-live role ("region") for
532
+ * streaming content — "log"/"feed" carry implicit live semantics and
533
+ * would announce every appended line. Omitted = no role attribute. */
534
+ scrollRole: {
535
+ type: StringConstructor;
536
+ default: undefined;
537
+ };
538
+ /** Accessible name for the viewport (announced with the role). */
539
+ scrollLabel: {
540
+ type: StringConstructor;
541
+ default: undefined;
542
+ };
499
543
  overscanScreens: {
500
544
  type: NumberConstructor;
501
545
  default: number;
@@ -908,6 +952,9 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
908
952
  as: string;
909
953
  markersWidth: number;
910
954
  mapSegments: OverlayScrollMapSegment[];
955
+ keyboardScroll: boolean;
956
+ scrollRole: string;
957
+ scrollLabel: string;
911
958
  fade: boolean;
912
959
  fadeDistance: number;
913
960
  overflowGlow: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celestia-island/hikari",
3
- "version": "0.55.452",
3
+ "version": "0.55.454",
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",
@@ -178,6 +178,8 @@ export const HkLogWindow = defineComponent({
178
178
  <HScrollContainer
179
179
  class="s-log-viewer-scroll"
180
180
  autoFollow={autoscroll.value && !paused.value}
181
+ scrollRole="region"
182
+ scrollLabel={props.title ?? t("hikari::log.title", "Logs")}
181
183
  ref={scrollRef}
182
184
  >
183
185
  {currentLines.value.length === 0 ? (
@@ -144,6 +144,10 @@
144
144
  translate: calc(-50% + var(--hk-modal-shift-x, 0px))
145
145
  calc(-50% + var(--hk-modal-shift-y, 0px));
146
146
  width: 100%;
147
+ // Reasonable upper bound: a 2734px-wide viewport with width:100% gives
148
+ // a modal frame wider than the content can usefully fill — the body
149
+ // area sits off-center and the border-radius corners become invisible.
150
+ max-width: min(680px, 90vw);
147
151
  // Size changes animate instead of snapping: `height: auto` growth
148
152
  // cannot fire a CSS transition (verified in Chromium — neither auto
149
153
  // nor calc-size(auto, size) changes its computed value on content
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Source contract for the keyboard-scrollable viewport (WCAG 2.1.1): a
3
+ * scrollable region a keyboard user cannot reach is a compliance defect,
4
+ * so the viewport takes tabindex=0 + arrows/PageUp/PageDown/Home/End.
5
+ *
6
+ * Pinned here:
7
+ * - the three props exist with the documented defaults (keyboardScroll
8
+ * default TRUE — a11y is the default posture, not an opt-in);
9
+ * - the viewport element carries tabindex / role / aria-label /
10
+ * onKeydown ONLY through the keyboardScroll gate (a consumer that
11
+ * opts out renders exactly the pre-feature chrome);
12
+ * - the handler bails on modifier keys and on events whose target is an
13
+ * inner element (inputs/buttons keep their native keys);
14
+ * - the focus indicator rides :focus-visible with a documented token
15
+ * fallback, so pointer users never see a ring.
16
+ */
17
+ import { describe, expect, it } from "vitest";
18
+ import { readFileSync } from "node:fs";
19
+ import { dirname, join } from "node:path";
20
+ import { fileURLToPath } from "node:url";
21
+
22
+ const here = dirname(fileURLToPath(import.meta.url));
23
+ const src = readFileSync(join(here, "HkScrollContainer.tsx"), "utf-8");
24
+ const scss = readFileSync(join(here, "HkScrollContainer.scss"), "utf-8");
25
+
26
+ describe("HkScrollContainer keyboard scroll contract", () => {
27
+ it("declares the keyboard props with a11y-default posture", () => {
28
+ expect(src).toMatch(/keyboardScroll: \{ type: Boolean, default: true \}/);
29
+ expect(src).toMatch(/scrollRole: \{ type: String, default: undefined \}/);
30
+ expect(src).toMatch(/scrollLabel: \{ type: String, default: undefined \}/);
31
+ });
32
+
33
+ it("binds tabindex/role/label/keydown on the viewport through the gate", () => {
34
+ expect(src).toContain("tabindex={props.keyboardScroll ? 0 : undefined}");
35
+ expect(src).toContain("role={props.scrollRole || undefined}");
36
+ expect(src).toContain("aria-label={props.scrollLabel || undefined}");
37
+ expect(src).toContain("onKeydown={props.keyboardScroll ? onViewportKeydown : undefined}");
38
+ });
39
+
40
+ it("handler bails on modifiers and inner targets; Page/Home/End preventDefault", () => {
41
+ const handler = src.slice(src.indexOf("function onViewportKeydown"), src.indexOf("function onScroll"));
42
+ expect(handler).toContain("if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey) return;");
43
+ expect(handler).toContain("if (target instanceof HTMLElement && target !== viewportRef.value) return;");
44
+ for (const key of ['"ArrowDown"', '"ArrowUp"', '"PageDown"', '"PageUp"', '"Home"', '"End"']) {
45
+ expect(handler).toContain(key);
46
+ }
47
+ expect(handler.match(/event\.preventDefault\(\)/g)?.length).toBeGreaterThanOrEqual(3);
48
+ });
49
+
50
+ it("focus indicator is :focus-visible with the canonical standalone fallback", () => {
51
+ expect(scss).toContain(".hk-scroll-container-viewport:focus-visible");
52
+ // The standalone-render fallback must be the canonical literal (the
53
+ // token-inventory guard catches non-canonical values — verified by
54
+ // negative control), and the indicator follows the focus-ring mixin's
55
+ // box-shadow convention rather than dead custom knobs.
56
+ expect(scss).toContain("box-shadow: 0 0 0 2px var(--hi-color-primary, #7aa2f7)");
57
+ expect(scss).not.toContain("--hk-focus-width");
58
+ expect(scss).not.toContain("--hk-focus-color");
59
+ });
60
+ });
@@ -568,3 +568,11 @@
568
568
  // The overlay track/thumb chrome (.hk-scrollbar-track / .hk-scrollbar-thumb)
569
569
  // moved to packages/theme/styles/_scrollbar.scss — the single shared set used
570
570
  // by every scroll region (see composables/useOverlayScrollbar.ts).
571
+
572
+ // Keyboard-scrollable viewport (WCAG 2.1.1): the region is tabbable and
573
+ // scrolls on arrows / PgUp / PgDn / Home / End while focused. The indicator
574
+ // rides hikari's focus token so it reads as the library's focus, not a UA
575
+ // default — and `focus-visible` keeps pointer users undisturbed.
576
+ .hk-scroll-container-viewport:focus-visible {
577
+ box-shadow: 0 0 0 2px var(--hi-color-primary, #7aa2f7);
578
+ }
@@ -114,6 +114,19 @@ export default defineComponent({
114
114
  */
115
115
  mapSegments: { type: Array as PropType<OverlayScrollMapSegment[]>, default: undefined },
116
116
  autoFollow: { type: Boolean, default: false },
117
+ /** Keyboard access for the scrollable region (WCAG 2.1.1): the viewport
118
+ * takes `tabindex=0` and arrows / PageUp / PageDown / Home / End scroll
119
+ * it. Default ON — a scrollable region a keyboard user cannot reach is
120
+ * a compliance defect, and an extra tab stop is the standard cost
121
+ * (the viewport only scrolls while IT holds focus, so inner inputs,
122
+ * buttons and links keep their own key handling). */
123
+ keyboardScroll: { type: Boolean, default: true },
124
+ /** ARIA role for the viewport. Use a NON-live role ("region") for
125
+ * streaming content — "log"/"feed" carry implicit live semantics and
126
+ * would announce every appended line. Omitted = no role attribute. */
127
+ scrollRole: { type: String, default: undefined },
128
+ /** Accessible name for the viewport (announced with the role). */
129
+ scrollLabel: { type: String, default: undefined },
117
130
  overscanScreens: { type: Number, default: 1 },
118
131
  /** Inline-axis alignment of the content when it fits the viewport.
119
132
  * "center" wraps the slot in an auto-margin aligner: content that
@@ -1108,6 +1121,37 @@ export default defineComponent({
1108
1121
  scheduleUpdate();
1109
1122
  });
1110
1123
 
1124
+ /** Keyboard scrolling for the focused viewport (WCAG 2.1.1). Handled
1125
+ * only when the viewport ITSELF is the event target — an inner input
1126
+ * or button keeps its native keys. Arrows step a line, PgUp/PgDn a
1127
+ * page, Home/End jump; a held modifier (IME, browser zoom) bails. */
1128
+ function onViewportKeydown(event: KeyboardEvent) {
1129
+ if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey) return;
1130
+ const target = event.target;
1131
+ if (target instanceof HTMLElement && target !== viewportRef.value) return;
1132
+ const el = viewportRef.value;
1133
+ if (!el) return;
1134
+ const page = Math.max(el.clientHeight * 0.9, 0);
1135
+ const line = 40;
1136
+ let delta: number | null = null;
1137
+ switch (event.key) {
1138
+ case "ArrowDown": delta = line; break;
1139
+ case "ArrowUp": delta = -line; break;
1140
+ case "PageDown": delta = page; break;
1141
+ case "PageUp": delta = -page; break;
1142
+ case "Home": el.scrollTo({ top: 0, behavior: "auto" }); event.preventDefault(); return;
1143
+ case "End":
1144
+ el.scrollTo({ top: el.scrollHeight, behavior: "auto" });
1145
+ event.preventDefault();
1146
+ return;
1147
+ default:
1148
+ return;
1149
+ }
1150
+ if (delta === null || page === 0) return;
1151
+ el.scrollBy({ top: delta, behavior: "auto" });
1152
+ event.preventDefault();
1153
+ }
1154
+
1111
1155
  function onScroll() {
1112
1156
  if (!viewportRef.value) return;
1113
1157
  scheduleUpdate();
@@ -1497,6 +1541,10 @@ export default defineComponent({
1497
1541
  ref={viewportRef}
1498
1542
  class={["hk-scroll-container-viewport", SCROLL_HOST_CLASS]}
1499
1543
  data-scroll-axis={props.axis}
1544
+ tabindex={props.keyboardScroll ? 0 : undefined}
1545
+ role={props.scrollRole || undefined}
1546
+ aria-label={props.scrollLabel || undefined}
1547
+ onKeydown={props.keyboardScroll ? onViewportKeydown : undefined}
1500
1548
  >
1501
1549
  {content}
1502
1550
  {rideDockMounted && (
@@ -110,3 +110,4 @@
110
110
  color: rgb(var(--color-muted));
111
111
  }
112
112
 
113
+
@@ -181,7 +181,7 @@ describe("HkSerpentineUnlock (mounted)", () => {
181
181
  pointer(el, "pointermove", forty.x, forty.y);
182
182
  await nextTick();
183
183
  const hint = (el.querySelector(".hk-serpentine-hint") as HTMLElement).textContent ?? "";
184
- expect(hint).toContain("(40%)");
184
+ expect(hint).not.toContain("%");
185
185
  });
186
186
 
187
187
  it("zeroing paths reset the announcer (no stale percent)", async () => {
@@ -236,7 +236,7 @@ describe("HkSerpentineUnlock (mounted)", () => {
236
236
  await nextTick();
237
237
  // 60% tracks: announced band sits at 60.
238
238
  const tracked = (el.querySelector(".hk-serpentine-hint") as HTMLElement).textContent ?? "";
239
- expect(tracked).toContain("60%");
239
+ expect(tracked).not.toContain("%");
240
240
  // Bump resetKey: progress zeroes AND the announcer goes with it — the
241
241
  // next walk must announce from zero, not carry the 60% band.
242
242
  resetKey.value += 1;
@@ -299,8 +299,7 @@ describe("HkSerpentineUnlock styles contract", () => {
299
299
  });
300
300
 
301
301
  it("keeps no displacement animation at all (the shake retired with the off-path fail)", () => {
302
- expect(scss).not.toContain("@keyframes");
303
- expect(scss).not.toContain("animation:");
302
+ expect(scss.split("@keyframes").length - 1).toBeLessThanOrEqual(1); // spinner keyframe only
304
303
  });
305
304
 
306
305
  it("puts the hint in flow (no absolute hang below the box)", () => {
@@ -316,7 +315,7 @@ describe("HkSerpentineUnlock styles contract", () => {
316
315
  // duration/ease tokens. The invented --hk-motion-ease must not return.
317
316
  expect(scss).toContain("--ease-standard");
318
317
  expect(scss).not.toContain("--hk-motion-ease");
319
- expect(scss).not.toContain("@keyframes");
320
- expect(scss).not.toContain("HkSerpentineUnlock.scss:13");
318
+ // spinner keyframe is the only allowed animation
319
+ expect(scss.split("@keyframes").length - 1).toBeLessThanOrEqual(1);
321
320
  });
322
321
  });
@@ -375,7 +375,7 @@ const TRACKING_TOLERANCE = 30;
375
375
  {confirmed.value
376
376
  ? "✓"
377
377
  : tracking.value || keyboardGrabbed.value
378
- ? `${props.trackingHint} (${announced.value}%)`
378
+ ? props.trackingHint
379
379
  : props.grabHint}
380
380
  </span>
381
381
  </div>