@celestia-island/hikari 0.55.404 → 0.55.406

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celestia-island/hikari",
3
- "version": "0.55.404",
3
+ "version": "0.55.406",
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",
@@ -0,0 +1,103 @@
1
+ import { afterEach, describe, expect, it } from "vitest";
2
+ import { createApp, defineComponent, h, nextTick, reactive } from "vue";
3
+
4
+ import HkAlert from "./HkAlert";
5
+
6
+ /**
7
+ * A11y guard for HkAlert's root live-region semantics: error/warning
8
+ * announce assertively (`role="alert"` + aria-live="assertive"), info/
9
+ * success politely (`role="status"` + aria-live="polite") — the same
10
+ * split and explicit pairing as the HkToast family. The role rides the
11
+ * ROOT element so the whole alert body is one announced region, and
12
+ * the pairing must survive a runtime variant change (both real
13
+ * consumers mount the alert conditionally; HkSectionCard swaps the
14
+ * variant as state changes).
15
+ *
16
+ * (Repo test convention: raw createApp + document queries, no
17
+ * @vue/test-utils dependency.)
18
+ */
19
+
20
+ const mounts: Array<{ app: ReturnType<typeof createApp>; container: HTMLElement }> = [];
21
+
22
+ function mountAlert(props: Record<string, unknown> = {}): HTMLElement {
23
+ const container = document.createElement("div");
24
+ document.body.appendChild(container);
25
+ const Wrapper = defineComponent({
26
+ setup() {
27
+ return () => h(HkAlert, { message: "mind the gap", ...props });
28
+ },
29
+ });
30
+ const app = createApp(Wrapper);
31
+ app.mount(container);
32
+ mounts.push({ app, container });
33
+ const el = container.querySelector<HTMLElement>(".hk-alert");
34
+ expect(el, ".hk-alert renders").toBeTruthy();
35
+ return el!;
36
+ }
37
+
38
+ afterEach(() => {
39
+ for (const { app, container } of mounts) {
40
+ app.unmount();
41
+ container.remove();
42
+ }
43
+ mounts.length = 0;
44
+ });
45
+
46
+ describe("HkAlert live-region role", () => {
47
+ it.each([
48
+ ["error", "alert", "assertive"],
49
+ ["warning", "alert", "assertive"],
50
+ ["info", "status", "polite"],
51
+ ["success", "status", "polite"],
52
+ ] as const)(
53
+ "the %s variant renders role=%s + aria-live=%s on the root",
54
+ (variant, role, live) => {
55
+ const el = mountAlert({ variant });
56
+ expect(el.getAttribute("role")).toBe(role);
57
+ expect(el.getAttribute("aria-live")).toBe(live);
58
+ },
59
+ );
60
+
61
+ it("the default variant (error) announces assertively", () => {
62
+ const el = mountAlert();
63
+ expect(el.getAttribute("role")).toBe("alert");
64
+ expect(el.getAttribute("aria-live")).toBe("assertive");
65
+ });
66
+
67
+ it("the pairing survives a runtime variant change", async () => {
68
+ // The computed role must react to the prop: HkSectionCard swaps the
69
+ // variant while mounted (idle → error), so a stale role would
70
+ // mis-announce the whole class of state-driven alerts.
71
+ const state = reactive<{ variant: "info" | "error" }>({ variant: "info" });
72
+ const container = document.createElement("div");
73
+ document.body.appendChild(container);
74
+ const Wrapper = defineComponent({
75
+ setup() {
76
+ return () => h(HkAlert, { message: "mind the gap", ...state });
77
+ },
78
+ });
79
+ const app = createApp(Wrapper);
80
+ app.mount(container);
81
+ mounts.push({ app, container });
82
+
83
+ const el = container.querySelector<HTMLElement>(".hk-alert")!;
84
+ expect(el.getAttribute("role")).toBe("status");
85
+ expect(el.getAttribute("aria-live")).toBe("polite");
86
+
87
+ state.variant = "error";
88
+ await nextTick();
89
+ expect(el.getAttribute("role")).toBe("alert");
90
+ expect(el.getAttribute("aria-live")).toBe("assertive");
91
+ });
92
+
93
+ it("the root is the only role carrier — even with title + close button", () => {
94
+ // The closable configuration adds the most plausible nested
95
+ // candidate (a <button>); it must stay role-less so the root
96
+ // remains the ONE announced region (no double announcement).
97
+ const el = mountAlert({ variant: "info", closable: true, title: "Heads up" });
98
+ expect(el.classList.contains("hk-alert")).toBe(true);
99
+ expect(el.getAttribute("role")).toBe("status");
100
+ expect(el.querySelector("button.hk-alert-close")).toBeTruthy();
101
+ expect(el.querySelectorAll("[role]").length).toBe(0);
102
+ });
103
+ });
@@ -45,6 +45,23 @@ export default defineComponent({
45
45
  !props.title ? "hk-alert-no-title" : "",
46
46
  ]);
47
47
 
48
+ // Live-region semantics by variant — the HkToast family split
49
+ // (HkToast.tsx): errors/warnings interrupt (`role="alert"` +
50
+ // assertive), everything else announces politely (`role="status"` +
51
+ // polite). The aria-live attribute rides along explicitly, same as
52
+ // HkToast / HkLoadingVeil / HkPersistentToast, though ARIA already
53
+ // implies it from the role. A live region only announces content
54
+ // inserted or changed AFTER it registers — an alert present at
55
+ // mount is read in document order like static content; both real
56
+ // in-repo consumers mount the alert conditionally (HkSectionCard
57
+ // error state, HkMfaVerifyCard retry hint). The role rides the
58
+ // ROOT so the whole alert body is one announced region.
59
+ const a11y = computed(() =>
60
+ props.variant === "error" || props.variant === "warning"
61
+ ? ({ role: "alert", "aria-live": "assertive" } as const)
62
+ : ({ role: "status", "aria-live": "polite" } as const),
63
+ );
64
+
48
65
  function onClose() {
49
66
  isDismissed.value = true;
50
67
  emit("close");
@@ -56,7 +73,12 @@ export default defineComponent({
56
73
  const IconComp = VARIANT_ICONS[props.variant];
57
74
 
58
75
  return (
59
- <div class={rootCls.value} style={hkPadStyle(props.padding)}>
76
+ <div
77
+ class={rootCls.value}
78
+ style={hkPadStyle(props.padding)}
79
+ role={a11y.value.role}
80
+ aria-live={a11y.value["aria-live"]}
81
+ >
60
82
  <span class="hk-alert-icon">
61
83
  {slots.icon ? (
62
84
  slots.icon()
@@ -82,6 +82,16 @@
82
82
 
83
83
  .hk-notification-row {
84
84
  display: flex;
85
+ /* All three columns (glyph / body / actions) center against the ROW
86
+ height, never against their own content. The default stretch
87
+ stretched a ONE-LINE body to the 24px dismiss button's height while
88
+ the block body hugged the top — the title floated ~4px above the
89
+ shared center line, clearly visible exactly when the row has a
90
+ single line (user report 2026-11-17; both the desktop flyout and
91
+ the mobile sheet share this renderer). Whole-row centering is the
92
+ same grammar the actions column already speaks (2026-11-15 ruling
93
+ below). */
94
+ align-items: center;
85
95
  gap: var(--space-12, 0.75rem);
86
96
  padding: var(--space-8, 0.5rem) var(--space-8, 0.5rem);
87
97
  border-bottom: 1px solid rgb(var(--color-border) / 6%);
@@ -95,7 +105,6 @@
95
105
  flex: none;
96
106
  display: inline-flex;
97
107
  align-items: center;
98
- padding-top: 2px;
99
108
  /* Tone ink follows the row's tone class (rules below). */
100
109
  color: rgb(var(--color-text) / 65%);
101
110
  }
@@ -25,6 +25,23 @@ describe("HkNotificationBell scss contract", () => {
25
25
  );
26
26
  });
27
27
 
28
+ it("the row centers its columns against the ROW height (one-line rows included)", () => {
29
+ // Default stretch stretched a one-line body to the 24px dismiss
30
+ // button and hugged the title to the body's top — visibly off the
31
+ // shared center line exactly when the row has a single line
32
+ // (user report 2026-11-17).
33
+ expect(scss).toMatch(/^\.hk-notification-row \{[^}]*align-items:\s*center;/m);
34
+ });
35
+
36
+ it("the tone glyph carries no stretch-era first-line padding hack", () => {
37
+ // `padding-top: 2px` was an optical nudge for the first line under
38
+ // stretch; under row centering it parks the glyph below the shared
39
+ // center line, so the icon rule must not carry any padding-top.
40
+ const iconBlock = scss.match(/^\.hk-notification-row__icon \{([^}]*)\}/m);
41
+ expect(iconBlock).toBeTruthy();
42
+ expect(iconBlock![1]).not.toContain("padding-top");
43
+ });
44
+
28
45
  it("the dismiss glyph ink rides --hi-icon-button-icon-color (ancestor color is inert)", () => {
29
46
  // Rest ink on the button, plus the row-hover/focus-within brighten —
30
47
  // both through the var channel the ghost button itself consumes.