@celestia-island/hikari 0.55.427 → 0.55.431
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/animation/registerAnimations.ts +5 -0
- package/src/components/HkBoard.nodeActions.test.tsx +3 -1
- package/src/components/HkContextMenuProvider.tsx +84 -2
- package/src/components/HkFilterChip.scss +4 -4
- package/src/components/HkFilterChip.test.tsx +119 -0
- package/src/components/HkFilterChip.tsx +87 -17
- package/src/components/HkNotificationBell.scss +24 -6
- package/src/components/HkNotificationBell.styles.test.ts +45 -3
- package/src/components/HkNotificationBell.test.tsx +55 -2
- package/src/components/HkNotificationBell.tsx +15 -6
- package/src/components/HkPillToggleGroup.tsx +13 -0
- package/src/components/HkSerpentineUnlock.scss +124 -0
- package/src/components/HkSerpentineUnlock.test.ts +312 -0
- package/src/components/HkSerpentineUnlock.tsx +366 -0
- package/src/components/HkSolarLocationEditor.tsx +440 -0
- package/src/components/HkSolarLocationSetting.tsx +35 -392
- package/src/components/HkTabs.scss +119 -0
- package/src/components/HkTabs.test.ts +585 -1
- package/src/components/HkTabs.tsx +284 -38
- package/src/components/HkThemePanelContent.solar.contract.test.ts +148 -0
- package/src/components/HkThemePanelContent.tsx +56 -2
- package/src/components/serpentineGeometry.test.ts +157 -0
- package/src/components/serpentineGeometry.ts +184 -0
- package/src/composables/defaultContextMenu.test.ts +569 -0
- package/src/composables/defaultContextMenu.ts +326 -0
- package/src/i18n/locales/ar/components.json +6 -1
- package/src/i18n/locales/ar/platform.json +1 -0
- package/src/i18n/locales/de/components.json +6 -1
- package/src/i18n/locales/de/platform.json +1 -0
- package/src/i18n/locales/en/components.json +6 -1
- package/src/i18n/locales/en/platform.json +1 -0
- package/src/i18n/locales/es/components.json +6 -1
- package/src/i18n/locales/es/platform.json +1 -0
- package/src/i18n/locales/fr/components.json +6 -1
- package/src/i18n/locales/fr/platform.json +1 -0
- package/src/i18n/locales/ja/components.json +6 -1
- package/src/i18n/locales/ja/platform.json +1 -0
- package/src/i18n/locales/ko/components.json +6 -1
- package/src/i18n/locales/ko/platform.json +1 -0
- package/src/i18n/locales/pt/components.json +6 -1
- package/src/i18n/locales/pt/platform.json +1 -0
- package/src/i18n/locales/ru/components.json +6 -1
- package/src/i18n/locales/ru/platform.json +1 -0
- package/src/i18n/locales/zh-Hans/components.json +6 -1
- package/src/i18n/locales/zh-Hans/platform.json +1 -0
- package/src/i18n/locales/zh-Hant/components.json +6 -1
- package/src/i18n/locales/zh-Hant/platform.json +1 -0
- package/src/index.ts +10 -0
package/package.json
CHANGED
|
@@ -157,3 +157,8 @@ registerCssAnimation("hk-edge-glow-breathe", { infinite: true });
|
|
|
157
157
|
// band and drops the loops (house pattern, see HkSkeleton).
|
|
158
158
|
registerCssAnimation("hk-emergency-breathe", { infinite: true });
|
|
159
159
|
registerCssAnimation("hk-emergency-signal", { infinite: true });
|
|
160
|
+
// components/HkSerpentineUnlock.scss — the deliberate-action gate's fail
|
|
161
|
+
// shake (plays once): horizontal refusal feedback when the pointer drifts
|
|
162
|
+
// off the lane. Reduced motion swaps it for a static error outline (the
|
|
163
|
+
// gate never moves anything under reduced motion).
|
|
164
|
+
registerCssAnimation("hk-serpentine-shake");
|
|
@@ -103,6 +103,8 @@ describe("HkBoard nodeActions dock styles", () => {
|
|
|
103
103
|
expect(block.slice(0, 400)).toMatch(
|
|
104
104
|
/bottom:\s*var\(--hk-board-node-action-inset, 4px\)/,
|
|
105
105
|
);
|
|
106
|
-
|
|
106
|
+
// Anchored: `/z-index:\s*6/` is a PREFIX match, so a stacking
|
|
107
|
+
// retune to 60/600 stayed green (final-residual fix).
|
|
108
|
+
expect(block.slice(0, 400)).toMatch(/z-index:\s*6\s*;/);
|
|
107
109
|
});
|
|
108
110
|
});
|
|
@@ -22,15 +22,17 @@
|
|
|
22
22
|
* `useContextMenuTrigger()` (composables/useContextMenu).
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
import { computed, defineComponent, provide, ref, shallowRef } from "vue";
|
|
25
|
+
import { computed, defineComponent, onBeforeUnmount, provide, ref, shallowRef, watch } from "vue";
|
|
26
26
|
|
|
27
27
|
import { popupViewportRect } from "../runtime/popupBounds";
|
|
28
28
|
import HkMenu from "./HkMenu";
|
|
29
29
|
import type { PanelAnchor } from "./HkSelectPanel";
|
|
30
|
+
import { contextMenuDefaultsFor } from "../composables/defaultContextMenu";
|
|
30
31
|
import {
|
|
31
32
|
CONTEXT_MENU_KEY,
|
|
32
33
|
type ContextMenuApi,
|
|
33
34
|
type ContextMenuRequest,
|
|
35
|
+
type ContextTriggerPoint,
|
|
34
36
|
} from "../composables/useContextMenu";
|
|
35
37
|
|
|
36
38
|
/** Pick the HkMenu placement that grows away from the pointer's nearest
|
|
@@ -66,7 +68,21 @@ function pointAnchor(x: number, y: number): PanelAnchor {
|
|
|
66
68
|
|
|
67
69
|
export default defineComponent({
|
|
68
70
|
name: "HkContextMenuProvider",
|
|
69
|
-
|
|
71
|
+
props: {
|
|
72
|
+
/**
|
|
73
|
+
* Install the app-wide DEFAULT context-menu regime while this
|
|
74
|
+
* provider is mounted (composables/defaultContextMenu): a
|
|
75
|
+
* window-level bubble listener that yields to any element-level
|
|
76
|
+
* binding (those preventDefault first), consults the registered
|
|
77
|
+
* default contributors (the built-in clipboard menu claims
|
|
78
|
+
* editable targets), and suppresses the platform menu everywhere
|
|
79
|
+
* else. Hosts extend the regime with
|
|
80
|
+
* `registerContextMenuDefault(...)` — region-specific defaults
|
|
81
|
+
* belong in contributors, not in new window listeners.
|
|
82
|
+
*/
|
|
83
|
+
defaults: { type: Boolean, default: false },
|
|
84
|
+
},
|
|
85
|
+
setup(props, { slots }) {
|
|
70
86
|
const open = ref(false);
|
|
71
87
|
const request = shallowRef<ContextMenuRequest | null>(null);
|
|
72
88
|
/** Remount identity: every open() swaps the HkMenu instance, so a
|
|
@@ -93,6 +109,9 @@ export default defineComponent({
|
|
|
93
109
|
|
|
94
110
|
const api: ContextMenuApi = {
|
|
95
111
|
open(next: ContextMenuRequest) {
|
|
112
|
+
// Replacing an open menu closes the previous one — its owner gets
|
|
113
|
+
// the "closed without a selection" hook it was promised.
|
|
114
|
+
if (open.value) request.value?.onClose?.();
|
|
96
115
|
request.value = next;
|
|
97
116
|
menuEpoch.value += 1;
|
|
98
117
|
open.value = true;
|
|
@@ -103,6 +122,69 @@ export default defineComponent({
|
|
|
103
122
|
};
|
|
104
123
|
provide(CONTEXT_MENU_KEY, api);
|
|
105
124
|
|
|
125
|
+
// ── The default regime (prop `defaults`) ─────────────────────────
|
|
126
|
+
// Window-level BUBBLE phase: target-level bindings run first on the
|
|
127
|
+
// element; only their leftovers reach here (defaultPrevented =
|
|
128
|
+
// yielded). The platform menu never appears: the regime owns every
|
|
129
|
+
// unclaimed right-click, with a menu when a contributor claims the
|
|
130
|
+
// point and silent suppression otherwise.
|
|
131
|
+
//
|
|
132
|
+
// preventDefault comes FIRST: the platform menu must be suppressed
|
|
133
|
+
// even when a contributor misbehaves, and a throwing contributor is
|
|
134
|
+
// isolated (DEV-loud) instead of silently handing the event back to
|
|
135
|
+
// the browser.
|
|
136
|
+
function onWindowContextMenu(event: MouseEvent) {
|
|
137
|
+
if (event.defaultPrevented) return; // a binding opened its menu
|
|
138
|
+
event.preventDefault();
|
|
139
|
+
const point: ContextTriggerPoint = {
|
|
140
|
+
x: event.clientX,
|
|
141
|
+
y: event.clientY,
|
|
142
|
+
kind: "pointer",
|
|
143
|
+
target: event.target,
|
|
144
|
+
defaultPrevented: false,
|
|
145
|
+
};
|
|
146
|
+
let request: ContextMenuRequest | null = null;
|
|
147
|
+
try {
|
|
148
|
+
request = contextMenuDefaultsFor(point);
|
|
149
|
+
} catch (err) {
|
|
150
|
+
if (import.meta.env.DEV) {
|
|
151
|
+
// eslint-disable-next-line no-console -- dev-only drift alarm
|
|
152
|
+
console.error("[HkContextMenuProvider] default contributor threw:", err);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (request) api.open(request);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// The listener follows the prop: a host may flip `defaults` at
|
|
159
|
+
// runtime (a face that gains the regime after boot), and toggling it
|
|
160
|
+
// off must actually stop claiming right-clicks.
|
|
161
|
+
let defaultsListening = false;
|
|
162
|
+
/** SSR-safe: a server render has no window, and `immediate: true` runs
|
|
163
|
+
* this during setup (the provider's documented SSR contract). */
|
|
164
|
+
const canListen = typeof window !== "undefined";
|
|
165
|
+
watch(
|
|
166
|
+
() => props.defaults,
|
|
167
|
+
(on) => {
|
|
168
|
+
if (!canListen) return;
|
|
169
|
+
if (on && !defaultsListening) {
|
|
170
|
+
window.addEventListener("contextmenu", onWindowContextMenu);
|
|
171
|
+
defaultsListening = true;
|
|
172
|
+
} else if (!on && defaultsListening) {
|
|
173
|
+
window.removeEventListener("contextmenu", onWindowContextMenu);
|
|
174
|
+
defaultsListening = false;
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
{ immediate: true },
|
|
178
|
+
);
|
|
179
|
+
onBeforeUnmount(() => {
|
|
180
|
+
// A menu still open when the provider goes away is a menu that
|
|
181
|
+
// closed without a selection — the documented hook fires.
|
|
182
|
+
request.value?.onClose?.();
|
|
183
|
+
if (!canListen) return;
|
|
184
|
+
window.removeEventListener("contextmenu", onWindowContextMenu);
|
|
185
|
+
defaultsListening = false;
|
|
186
|
+
});
|
|
187
|
+
|
|
106
188
|
/** A server render has no DOM to build the anchor from: pass `null`,
|
|
107
189
|
* the same state as a consumer that gives HkMenu no anchor at all
|
|
108
190
|
* (positioning only ever runs in the browser). */
|
|
@@ -75,10 +75,10 @@
|
|
|
75
75
|
text-overflow: ellipsis;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
/* The trigger renders NO caret (2026-11-19): a facet chip reads as the
|
|
79
|
+
* same solid-surface family as the bespoke chips beside it, and the
|
|
80
|
+
* disclosure state rides aria-expanded. Host suffixes (a direction
|
|
81
|
+
* arrow) seat through renderChipTrailing and carry their own classes. */
|
|
82
82
|
|
|
83
83
|
.hk-filter-chip-body {
|
|
84
84
|
display: flex;
|
|
@@ -133,4 +133,123 @@ describe("HkFilterChip", () => {
|
|
|
133
133
|
expect(chipButton(c).className).toContain("hk-filter-chip--on");
|
|
134
134
|
expect(chipButton(c).getAttribute("aria-label")).toContain("OpenAI");
|
|
135
135
|
});
|
|
136
|
+
|
|
137
|
+
it("renders no caret — the facet chip reads as the solid-chip family", () => {
|
|
138
|
+
const c = mount(
|
|
139
|
+
h(HkFilterChip, { label: "Providers", allLabel: "All providers", options: OPTIONS }),
|
|
140
|
+
);
|
|
141
|
+
// The 2026-11-19 default: no affordance arrow beside the label (the
|
|
142
|
+
// bespoke chips of the wowsp bar carry none either); disclosure rides
|
|
143
|
+
// aria-expanded. Host suffixes seat through renderChipTrailing.
|
|
144
|
+
expect(chipButton(c).querySelector(".hk-filter-chip-caret")).toBeNull();
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it("opens the popup at the lg pad step by default — a content panel, not a menu", async () => {
|
|
148
|
+
const open = ref(false);
|
|
149
|
+
const c = mountRendered(
|
|
150
|
+
() =>
|
|
151
|
+
h(HkFilterChip, {
|
|
152
|
+
label: "Providers",
|
|
153
|
+
allLabel: "All providers",
|
|
154
|
+
options: OPTIONS,
|
|
155
|
+
open: open.value,
|
|
156
|
+
"onUpdate:open": (v: boolean) => (open.value = v),
|
|
157
|
+
}),
|
|
158
|
+
);
|
|
159
|
+
chipButton(c).dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
|
160
|
+
await Promise.resolve();
|
|
161
|
+
await Promise.resolve();
|
|
162
|
+
// The shared container-pad token lands inline on the teleported panel
|
|
163
|
+
// at the lg step (16px) — the glass chrome's 4px menu-voice inset read
|
|
164
|
+
// cramped against the pill group.
|
|
165
|
+
const panel = document.body.querySelector<HTMLElement>(".hk-popover-panel")!;
|
|
166
|
+
expect(panel).toBeTruthy();
|
|
167
|
+
expect(panel.style.getPropertyValue("--hk-pad")).toBe("var(--space-16, 1rem)");
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it("chipText overrides the selection mirror on the trigger and in the aria name", () => {
|
|
171
|
+
// A range corridor is not a picked-label list: the host names it.
|
|
172
|
+
const c = mount(
|
|
173
|
+
h(HkFilterChip, {
|
|
174
|
+
label: "Tier",
|
|
175
|
+
allLabel: "All tiers",
|
|
176
|
+
chipText: "VI – ★",
|
|
177
|
+
}),
|
|
178
|
+
);
|
|
179
|
+
expect(chipButton(c).querySelector(".hk-filter-chip-text")!.textContent).toBe("VI – ★");
|
|
180
|
+
// The override differs from the all-label: the state stays audible.
|
|
181
|
+
expect(chipButton(c).getAttribute("aria-label")).toBe("Tier: VI – ★");
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it("seats the host's chip suffix (renderChipTrailing) after the text", () => {
|
|
185
|
+
const c = mount(
|
|
186
|
+
h(HkFilterChip, {
|
|
187
|
+
label: "Providers",
|
|
188
|
+
allLabel: "All providers",
|
|
189
|
+
options: OPTIONS,
|
|
190
|
+
renderChipTrailing: () => h("span", { class: "chip-arrow" }, "↑"),
|
|
191
|
+
}),
|
|
192
|
+
);
|
|
193
|
+
const arrow = chipButton(c).querySelector(".chip-arrow");
|
|
194
|
+
expect(arrow).toBeTruthy();
|
|
195
|
+
// After the text span: the suffix is the LAST element child.
|
|
196
|
+
expect(chipButton(c).lastElementChild).toBe(arrow);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it("forwards renderPillTrailing to the pill group; null scopes the all-pill", async () => {
|
|
200
|
+
const scopes: Array<string | null> = [];
|
|
201
|
+
const c = mountRendered(
|
|
202
|
+
() =>
|
|
203
|
+
h(HkFilterChip, {
|
|
204
|
+
label: "Providers",
|
|
205
|
+
allLabel: "All providers",
|
|
206
|
+
options: OPTIONS,
|
|
207
|
+
selected: new Set(["openai"]),
|
|
208
|
+
open: true,
|
|
209
|
+
renderPillTrailing: (value) => {
|
|
210
|
+
scopes.push(value);
|
|
211
|
+
return h("span", { class: value === null ? "arrow-all" : "arrow-opt" }, "↑");
|
|
212
|
+
},
|
|
213
|
+
}),
|
|
214
|
+
);
|
|
215
|
+
expect(document.body.querySelector(".hk-pill-group")).toBeTruthy();
|
|
216
|
+
// One call per rendered pill: the all-pill (null) plus each option.
|
|
217
|
+
expect(scopes).toEqual([null, "deepseek", "openai", "anthropic", "gemini"]);
|
|
218
|
+
// The all-pill arrow and exactly the option arrows rendered.
|
|
219
|
+
expect(document.body.querySelector(".arrow-all")).toBeTruthy();
|
|
220
|
+
const optArrows = document.body.querySelectorAll(".arrow-opt");
|
|
221
|
+
expect(optArrows.length).toBe(OPTIONS.length);
|
|
222
|
+
optArrows.forEach((arrow) => {
|
|
223
|
+
const pill = arrow.closest(".hk-pill-group-pill")!;
|
|
224
|
+
// The arrow seats after the label (the pill's last text node ends it).
|
|
225
|
+
expect(pill.textContent).toContain("↑");
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
it("the default slot replaces the pill group; the hint still appends", async () => {
|
|
230
|
+
const open = ref(true);
|
|
231
|
+
mountRendered(
|
|
232
|
+
() =>
|
|
233
|
+
h(
|
|
234
|
+
HkFilterChip,
|
|
235
|
+
{
|
|
236
|
+
label: "Tier",
|
|
237
|
+
allLabel: "All tiers",
|
|
238
|
+
hint: "Drag either end",
|
|
239
|
+
open: open.value,
|
|
240
|
+
"onUpdate:open": (v: boolean) => (open.value = v),
|
|
241
|
+
},
|
|
242
|
+
{ default: () => h("div", { class: "custom-body" }, "slider lives here") },
|
|
243
|
+
),
|
|
244
|
+
);
|
|
245
|
+
await Promise.resolve();
|
|
246
|
+
await Promise.resolve();
|
|
247
|
+
// The host's body mounts in the slot's place — a range slider is not
|
|
248
|
+
// an option set — and the hint line still appends below it.
|
|
249
|
+
expect(document.body.querySelector(".custom-body")?.textContent).toBe("slider lives here");
|
|
250
|
+
expect(document.body.querySelector(".hk-pill-group")).toBeNull();
|
|
251
|
+
expect(document.body.querySelector(".hk-filter-chip-hint")?.textContent).toBe(
|
|
252
|
+
"Drag either end",
|
|
253
|
+
);
|
|
254
|
+
});
|
|
136
255
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { computed, defineComponent, ref, type PropType } from "vue";
|
|
2
|
-
import { ChevronDown } from "lucide-vue-next";
|
|
1
|
+
import { computed, defineComponent, ref, useAttrs, type PropType, type VNode } from "vue";
|
|
3
2
|
|
|
4
3
|
import HkPopover, { type PopupPlacement } from "./HkPopover";
|
|
5
4
|
import HkPillToggleGroup, { type HkPillToggleGroupOption } from "./HkPillToggleGroup";
|
|
5
|
+
import { hkPadStyle, type HkPad } from "../runtime/containerPad";
|
|
6
6
|
import "./HkFilterChip.scss";
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -20,9 +20,40 @@ import "./HkFilterChip.scss";
|
|
|
20
20
|
* the selection: the all-label when nothing is picked, otherwise the
|
|
21
21
|
* picked labels in canonical option order (capped at three plus a +N
|
|
22
22
|
* tail, so a wide facet cannot blow up the chip strip's width).
|
|
23
|
+
*
|
|
24
|
+
* Customization (2026-11-19, the wowsp bar's full migration — every
|
|
25
|
+
* filter category of that strip now rides this one component):
|
|
26
|
+
*
|
|
27
|
+
* - The trigger drops the caret glyph. A facet chip reads as the same
|
|
28
|
+
* solid-surface family as every bespoke chip beside it (those carry
|
|
29
|
+
* no affordance arrow either — their arrows mark an ENGAGED sort);
|
|
30
|
+
* the disclosure state rides aria-expanded. Attrs fall through to
|
|
31
|
+
* the trigger (HkButton's contract), so hosts state-mark it with
|
|
32
|
+
* their own classes (wowsp's intermediate sort tint).
|
|
33
|
+
* - `padding` defaults to "lg": the popup is a CONTENT panel (pills,
|
|
34
|
+
* sliders, custom bodies), so it rides the shared container-pad
|
|
35
|
+
* token at the content step instead of the glass chrome's 4px
|
|
36
|
+
* menu-voice inset that left the pills breathing against the edge.
|
|
37
|
+
* - `chipText` overrides the selection mirror for hosts whose chip
|
|
38
|
+
* text is not a picked-label list (a range corridor reads "VI – ★").
|
|
39
|
+
* - `renderChipTrailing` / `renderPillTrailing` seat the host's
|
|
40
|
+
* direction arrows: inside the trigger, and after each popup pill
|
|
41
|
+
* (null scopes the all-pill) — re-evaluated every render, so the
|
|
42
|
+
* arrows track the host's shared direction flag.
|
|
43
|
+
* - The default slot replaces the pill group for bodies that are not
|
|
44
|
+
* an option set (a dual-thumb corridor slider); the hint line still
|
|
45
|
+
* appends below when provided. `closeOnBackdrop` passes through for
|
|
46
|
+
* hosts that run a bar-level outside close with chip re-click
|
|
47
|
+
* switching on desktop.
|
|
23
48
|
*/
|
|
24
49
|
export default defineComponent({
|
|
25
50
|
name: "HkFilterChip",
|
|
51
|
+
/** Attrs land on the TRIGGER button (HkButton's fallthrough contract):
|
|
52
|
+
* the trigger is the chrome hosts style and state-mark, while the
|
|
53
|
+
* anchor span stays a bare layout wrapper. class/style are re-merged
|
|
54
|
+
* explicitly below — a bare spread would let attrs.class win the
|
|
55
|
+
* whole class list instead of compounding onto the chrome. */
|
|
56
|
+
inheritAttrs: false,
|
|
26
57
|
props: {
|
|
27
58
|
/** Popup title + the trigger's accessible name (the category). */
|
|
28
59
|
label: { type: String, required: true },
|
|
@@ -42,19 +73,40 @@ export default defineComponent({
|
|
|
42
73
|
* the facet's semantics (multi-select? radio? clears what?) are the
|
|
43
74
|
* host's story to tell. */
|
|
44
75
|
hint: { type: String, default: undefined },
|
|
76
|
+
/** Chip-label override — for hosts whose chip text is not the picked
|
|
77
|
+
* label list (a range corridor). Undefined keeps the mirror. */
|
|
78
|
+
chipText: { type: String, default: undefined },
|
|
79
|
+
/** The popup's content inset — the shared container-pad token
|
|
80
|
+
* (runtime/containerPad). Defaults to the lg content step: this panel
|
|
81
|
+
* hosts pills and sliders, not menu voices. */
|
|
82
|
+
padding: { type: String as PropType<HkPad>, default: "lg" },
|
|
83
|
+
/** HkPopover outside-close passthrough. Hosts that own a bar-level
|
|
84
|
+
* outside close (with chip re-click switching) turn it off where
|
|
85
|
+
* the two closes would fight; mobile keeps its scrim either way. */
|
|
86
|
+
closeOnBackdrop: { type: Boolean, default: true },
|
|
87
|
+
/** Trigger-suffix renderer — the seat for a host's direction arrow.
|
|
88
|
+
* Re-evaluated every render; render nothing while disengaged. */
|
|
89
|
+
renderChipTrailing: { type: Function as PropType<() => VNode>, default: undefined },
|
|
90
|
+
/** Popup pill-suffix renderer, forwarded to the pill group — a null
|
|
91
|
+
* value scopes the all-pill, a value scopes that option. Ignored
|
|
92
|
+
* while the default slot replaces the pill group. */
|
|
93
|
+
renderPillTrailing: {
|
|
94
|
+
type: Function as PropType<(value: string | null) => VNode>,
|
|
95
|
+
default: undefined,
|
|
96
|
+
},
|
|
45
97
|
},
|
|
46
98
|
emits: {
|
|
47
99
|
"update:open": (_v: boolean) => true,
|
|
48
100
|
toggle: (_value: string) => true,
|
|
49
101
|
all: () => true,
|
|
50
102
|
},
|
|
51
|
-
setup(props, { emit }) {
|
|
103
|
+
setup(props, { emit, slots, attrs }) {
|
|
52
104
|
const anchorRef = ref<HTMLElement | null>(null);
|
|
53
105
|
|
|
54
106
|
/** Picked options in canonical order — the chip label's source. */
|
|
55
107
|
const picked = computed(() => props.options.filter((o) => props.selected.has(o.value)));
|
|
56
108
|
|
|
57
|
-
const
|
|
109
|
+
const mirrored = computed(() => {
|
|
58
110
|
if (picked.value.length === 0) return props.allLabel;
|
|
59
111
|
const names = picked.value.map((o) => o.label);
|
|
60
112
|
const head = names.slice(0, 3).join(", ");
|
|
@@ -62,21 +114,32 @@ export default defineComponent({
|
|
|
62
114
|
return rest > 0 ? `${head} +${rest}` : head;
|
|
63
115
|
});
|
|
64
116
|
|
|
117
|
+
const chipText = computed(() => props.chipText ?? mirrored.value);
|
|
118
|
+
|
|
119
|
+
/** The accessible name carries the SAME text the eye sees once a
|
|
120
|
+
* selection (or a corridor override) engages — a bare category
|
|
121
|
+
* aria-label would mask the chip's visible state. */
|
|
122
|
+
const ariaLabel = computed(() =>
|
|
123
|
+
picked.value.length > 0 || (props.chipText != null && props.chipText !== props.allLabel)
|
|
124
|
+
? `${props.label}: ${chipText.value}`
|
|
125
|
+
: props.label,
|
|
126
|
+
);
|
|
127
|
+
|
|
65
128
|
return () => (
|
|
66
129
|
<span ref={anchorRef} class="hk-filter-chip-anchor">
|
|
67
130
|
<button
|
|
131
|
+
{...attrs}
|
|
68
132
|
type="button"
|
|
69
|
-
class={["hk-filter-chip", props.selected.size > 0 && "hk-filter-chip--on"]}
|
|
133
|
+
class={["hk-filter-chip", props.selected.size > 0 && "hk-filter-chip--on", attrs.class]}
|
|
134
|
+
style={attrs.style || undefined}
|
|
70
135
|
aria-haspopup="dialog"
|
|
71
136
|
aria-expanded={props.open ? "true" : "false"}
|
|
72
|
-
aria-label={
|
|
73
|
-
picked.value.length > 0 ? `${props.label}: ${chipText.value}` : props.label
|
|
74
|
-
}
|
|
137
|
+
aria-label={ariaLabel.value}
|
|
75
138
|
title={props.label}
|
|
76
139
|
onClick={() => emit("update:open", !props.open)}
|
|
77
140
|
>
|
|
78
141
|
<span class="hk-filter-chip-text">{chipText.value}</span>
|
|
79
|
-
|
|
142
|
+
{props.renderChipTrailing?.()}
|
|
80
143
|
</button>
|
|
81
144
|
<HkPopover
|
|
82
145
|
modelValue={props.open}
|
|
@@ -85,17 +148,24 @@ export default defineComponent({
|
|
|
85
148
|
placement={props.placement}
|
|
86
149
|
offset={6}
|
|
87
150
|
sheetOnMobile
|
|
151
|
+
closeOnBackdrop={props.closeOnBackdrop}
|
|
152
|
+
padding={props.padding}
|
|
88
153
|
title={props.label}
|
|
89
154
|
>
|
|
90
155
|
<div class="hk-filter-chip-body">
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
156
|
+
{slots.default ? (
|
|
157
|
+
slots.default()
|
|
158
|
+
) : (
|
|
159
|
+
<HkPillToggleGroup
|
|
160
|
+
label={props.label}
|
|
161
|
+
options={props.options}
|
|
162
|
+
selected={props.selected}
|
|
163
|
+
allLabel={props.allLabel}
|
|
164
|
+
renderTrailing={props.renderPillTrailing}
|
|
165
|
+
onToggle={(v: string) => emit("toggle", v)}
|
|
166
|
+
onAll={() => emit("all")}
|
|
167
|
+
/>
|
|
168
|
+
)}
|
|
99
169
|
{props.hint && <div class="hk-filter-chip-hint">{props.hint}</div>}
|
|
100
170
|
</div>
|
|
101
171
|
</HkPopover>
|
|
@@ -131,18 +131,36 @@
|
|
|
131
131
|
/* Corner tally for consolidated records (2026-11-19): the unread dot's
|
|
132
132
|
primary channel — the same "attention" grammar the bell trigger speaks.
|
|
133
133
|
Sits on the glyph's bottom-end corner like a notification count. */
|
|
134
|
+
/* Screen-reader-only text (no global utility exists in hikari — this is
|
|
135
|
+
the local twin of HkTable's .hk-table-sr-only). The tally's visible
|
|
136
|
+
"99+" cap is sighted shorthand; AT reads this pair instead. */
|
|
137
|
+
.hk-notification-row__sr-only {
|
|
138
|
+
position: absolute;
|
|
139
|
+
width: 1px;
|
|
140
|
+
height: 1px;
|
|
141
|
+
padding: 0;
|
|
142
|
+
margin: -1px;
|
|
143
|
+
overflow: hidden;
|
|
144
|
+
clip-path: inset(50%);
|
|
145
|
+
white-space: nowrap;
|
|
146
|
+
border: 0;
|
|
147
|
+
}
|
|
148
|
+
|
|
134
149
|
.hk-notification-row__icon-count {
|
|
135
150
|
position: absolute;
|
|
136
151
|
inset-inline-end: -7px;
|
|
137
152
|
bottom: -6px;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
153
|
+
/* Geometry rides the scale: the badge is a hair under the 2xs step
|
|
154
|
+
(0.5625rem = 9px, the token's own 0.625rem would overflow the 14px
|
|
155
|
+
chip), and the chip box is 2 × the radius. */
|
|
156
|
+
min-width: 0.875rem;
|
|
157
|
+
height: 0.875rem;
|
|
158
|
+
padding: 0 0.1875rem;
|
|
159
|
+
border-radius: 0.4375rem;
|
|
142
160
|
background: var(--hi-color-primary, #7aa2f7);
|
|
143
161
|
color: rgb(255 255 255 / 95%);
|
|
144
|
-
font-size:
|
|
145
|
-
line-height:
|
|
162
|
+
font-size: 0.5625rem;
|
|
163
|
+
line-height: 0.875rem;
|
|
146
164
|
font-weight: 600;
|
|
147
165
|
text-align: center;
|
|
148
166
|
font-variant-numeric: tabular-nums;
|
|
@@ -13,6 +13,41 @@ const scss = readFileSync(join(__dirname, "HkNotificationBell.scss"), "utf-8")
|
|
|
13
13
|
.replace(/^[ \t]*\/\/.*$/gm, "");
|
|
14
14
|
|
|
15
15
|
describe("HkNotificationBell scss contract", () => {
|
|
16
|
+
it("the tally's sr-only twin really hides (the a11y recipe is pinned here)", () => {
|
|
17
|
+
// The badge's accessible name is real text in a visually-hidden span;
|
|
18
|
+
// happy-dom applies no stylesheets, so the CONTRACT lives here — every
|
|
19
|
+
// arm of the sr-only recipe must survive a revert that would make the
|
|
20
|
+
// twin visible (or, worse, leave it in flow and break the row).
|
|
21
|
+
const block = scss.match(/\.hk-notification-row__sr-only \{([^}]*)\}/);
|
|
22
|
+
expect(block, "the sr-only rule exists").toBeTruthy();
|
|
23
|
+
for (const arm of [
|
|
24
|
+
"position: absolute",
|
|
25
|
+
"width: 1px",
|
|
26
|
+
"height: 1px",
|
|
27
|
+
"overflow: hidden",
|
|
28
|
+
"clip-path: inset(50%)",
|
|
29
|
+
"white-space: nowrap",
|
|
30
|
+
]) {
|
|
31
|
+
expect(block![1], `sr-only carries ${arm}`).toContain(arm);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("each load-bearing rule is declared ONCE (a duplicate top-level rule could override it unseen)", () => {
|
|
36
|
+
// The row helpers extract the FIRST matching rule, so an appended
|
|
37
|
+
// duplicate with the same selector wins the cascade while the pinned
|
|
38
|
+
// body stays present (final-residual class). Counting the selector at
|
|
39
|
+
// file scope closes it for the rules these pins defend.
|
|
40
|
+
for (const selector of [
|
|
41
|
+
".hk-notification-center__list {",
|
|
42
|
+
".hk-notification-row {",
|
|
43
|
+
".hk-notification-row__icon-count {",
|
|
44
|
+
".hk-notification-center__foot {",
|
|
45
|
+
]) {
|
|
46
|
+
const hits = scss.split(selector).length - 1;
|
|
47
|
+
expect(hits, `${selector} declared exactly once`).toBe(1);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
16
51
|
it("the panel body is a definite 22rem inside the max-content popover", () => {
|
|
17
52
|
expect(scss).toContain("width: 22rem;");
|
|
18
53
|
// The old `min(22rem, 100%)` clamp is the dead-band root cause.
|
|
@@ -68,8 +103,15 @@ describe("HkNotificationBell scss contract", () => {
|
|
|
68
103
|
expect(scss).toMatch(
|
|
69
104
|
/\.hk-notification-row:hover \.hk-notification-row__actions \.hk-icon-button,\s*\n\.hk-notification-row:focus-within \.hk-notification-row__actions \.hk-icon-button\s*\{[^}]*--hi-icon-button-icon-color:\s*rgb\(var\(--color-text\) \/ 85%\)/,
|
|
70
105
|
);
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
)
|
|
106
|
+
// Exactly ONE declaration per ink value: the old third arm asserted
|
|
107
|
+
// only the property NAME on the focus-within selector, which the joint
|
|
108
|
+
// block above already covers (redundant) while an appended second
|
|
109
|
+
// declaration could override it unseen (final-residual fix).
|
|
110
|
+
expect(
|
|
111
|
+
scss.match(/--hi-icon-button-icon-color:\s*rgb\(var\(--color-text\) \/ 40%\)/g) ?? [],
|
|
112
|
+
).toHaveLength(1);
|
|
113
|
+
expect(
|
|
114
|
+
scss.match(/--hi-icon-button-icon-color:\s*rgb\(var\(--color-text\) \/ 85%\)/g) ?? [],
|
|
115
|
+
).toHaveLength(1);
|
|
74
116
|
});
|
|
75
117
|
});
|
|
@@ -364,7 +364,9 @@ describe("panel rows", () => {
|
|
|
364
364
|
const boomRow = rows().find((r) => r.textContent?.includes("boom"))!;
|
|
365
365
|
const badge = boomRow.querySelector<HTMLElement>(".hk-notification-row__icon-count");
|
|
366
366
|
expect(badge, "the tally badge renders").toBeTruthy();
|
|
367
|
-
|
|
367
|
+
// The visible glyph is the cap ("99+" above 99); the SR twin carries
|
|
368
|
+
// the pair (see the a11y case below).
|
|
369
|
+
expect(badge!.querySelector('[aria-hidden="true"]')!.textContent).toBe("3");
|
|
368
370
|
expect(badge!.getAttribute("title")).toContain("msgs");
|
|
369
371
|
// A single-occurrence record carries NO badge.
|
|
370
372
|
const otherRow = rows().find((r) => r.textContent?.includes("other"))!;
|
|
@@ -392,6 +394,28 @@ describe("panel rows", () => {
|
|
|
392
394
|
expect(rows()).toHaveLength(0);
|
|
393
395
|
});
|
|
394
396
|
|
|
397
|
+
it("the tally's accessible name is real text with its unit (not a bare number)", async () => {
|
|
398
|
+
// Final-residual fix: `aria-label` on a role-less span is not a
|
|
399
|
+
// reliable accessible name (generic role cannot be named from author),
|
|
400
|
+
// so the badge ships a visually-hidden twin with the full pair while
|
|
401
|
+
// the visible glyph stays the sighted shorthand.
|
|
402
|
+
await setLocale("en");
|
|
403
|
+
for (const id of ["t:1", "t:2", "t:3", "t:4"]) {
|
|
404
|
+
recordNotification({ id, kind: "toast", tone: "error", title: "boom" });
|
|
405
|
+
}
|
|
406
|
+
mountBell();
|
|
407
|
+
await settle();
|
|
408
|
+
bellButton().dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
|
409
|
+
await settle();
|
|
410
|
+
const badge = rows()[0]!.querySelector<HTMLElement>(".hk-notification-row__icon-count")!;
|
|
411
|
+
const sr = badge.querySelector<HTMLElement>(".hk-notification-row__sr-only");
|
|
412
|
+
expect(sr, "the visually-hidden twin renders").toBeTruthy();
|
|
413
|
+
expect(sr!.textContent).toBe("4 msgs");
|
|
414
|
+
// The hiding recipe itself is pinned in the scss contract (happy-dom
|
|
415
|
+
// applies no stylesheets, so a computed-style probe here would test
|
|
416
|
+
// the environment, not the code).
|
|
417
|
+
});
|
|
418
|
+
|
|
395
419
|
it("a toast joining a snoozed emergency's group does NOT dissolve the Restore", async () => {
|
|
396
420
|
// Round-3 S2, proven by probe: the group's FACE is its newest member
|
|
397
421
|
// (the toast), so head-only action gating hid the emergency's only
|
|
@@ -425,7 +449,9 @@ describe("panel rows", () => {
|
|
|
425
449
|
"Hidden",
|
|
426
450
|
);
|
|
427
451
|
// The tally counts both members.
|
|
428
|
-
expect(
|
|
452
|
+
expect(
|
|
453
|
+
row.querySelector('.hk-notification-row__icon-count [aria-hidden="true"]')?.textContent,
|
|
454
|
+
).toBe("2");
|
|
429
455
|
// And the restore still works through the journal's resummon path.
|
|
430
456
|
restore!.dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
|
431
457
|
await settle();
|
|
@@ -435,6 +461,33 @@ describe("panel rows", () => {
|
|
|
435
461
|
expect(row.classList.contains("is-active")).toBe(true);
|
|
436
462
|
});
|
|
437
463
|
|
|
464
|
+
it("two identical-content snoozed episodes each keep their own Restore", async () => {
|
|
465
|
+
// Final-residual fix: `restorable` used to be a single `find`, so a
|
|
466
|
+
// group holding two episodes surfaced ONE handle and stranded the
|
|
467
|
+
// other's callback (journal intact, band hidden = unreachable).
|
|
468
|
+
await setLocale("en");
|
|
469
|
+
raiseEmergencyAlert({ id: "a", severity: "warning", title: "dup" });
|
|
470
|
+
snoozeEmergencyAlert("a");
|
|
471
|
+
raiseEmergencyAlert({ id: "b", severity: "warning", title: "dup" });
|
|
472
|
+
snoozeEmergencyAlert("b");
|
|
473
|
+
mountBell();
|
|
474
|
+
await settle();
|
|
475
|
+
bellButton().dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
|
476
|
+
await settle();
|
|
477
|
+
expect(rows(), "both episodes share one content group").toHaveLength(1);
|
|
478
|
+
const restores = rows()[0]!.querySelectorAll<HTMLButtonElement>(
|
|
479
|
+
'.hk-notification-row__actions .hk-icon-button[aria-label="Show again"]',
|
|
480
|
+
);
|
|
481
|
+
expect(restores, "one Restore per restorable episode").toHaveLength(2);
|
|
482
|
+
// Each button drives its OWN episode: unsnoozing one leaves the other.
|
|
483
|
+
restores[0]!.dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
|
484
|
+
await settle();
|
|
485
|
+
const after = rows()[0]!.querySelectorAll<HTMLButtonElement>(
|
|
486
|
+
'.hk-notification-row__actions .hk-icon-button[aria-label="Show again"]',
|
|
487
|
+
);
|
|
488
|
+
expect(after, "the other episode keeps its handle").toHaveLength(1);
|
|
489
|
+
});
|
|
490
|
+
|
|
438
491
|
it("the open panel carries the overlay scrollbar tracks; closing detaches them", async () => {
|
|
439
492
|
// The list keeps native overflow MECHANICS with the suppression pair,
|
|
440
493
|
// so the overlay engine is the only chrome it can ever show (user
|