@celestia-island/hikari 0.55.347 → 0.55.348
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/HkAboutModal.test.tsx +15 -3
- package/src/components/HkAboutModal.tsx +30 -20
- package/src/components/HkErrorLanding.test.tsx +11 -2
- package/src/components/HkErrorLanding.tsx +12 -8
- package/src/components/HkLogWindow.contract.test.ts +44 -0
- package/src/components/HkLogWindow.tsx +7 -5
- package/src/components/HkModal.scss +37 -0
- package/src/components/HkModal.styles.test.ts +82 -0
- package/src/components/HkModal.test.tsx +75 -0
- package/src/components/HkModal.tsx +19 -0
- package/src/components/HkScrollPin.tsx +4 -1
- package/src/components/HkSelectionControls.styles.test.ts +2 -0
- package/src/components/HkToast.test.tsx +39 -0
- package/src/components/HkToast.tsx +20 -5
- package/src/errorReporting/HkErrorReportingOverlay.tsx +12 -0
- package/src/errorReporting/index.test.tsx +20 -0
- package/src/i18n/locales/ar/components.json +0 -1
- package/src/i18n/locales/ar/components.toml +0 -1
- package/src/i18n/locales/ar/errors.json +1 -2
- package/src/i18n/locales/ar/platform.json +0 -3
- package/src/i18n/locales/de/components.json +0 -1
- package/src/i18n/locales/de/components.toml +0 -1
- package/src/i18n/locales/de/errors.json +1 -2
- package/src/i18n/locales/de/platform.json +0 -3
- package/src/i18n/locales/en/components.json +0 -1
- package/src/i18n/locales/en/components.toml +0 -1
- package/src/i18n/locales/en/errors.json +1 -2
- package/src/i18n/locales/en/platform.json +0 -3
- package/src/i18n/locales/es/components.json +0 -1
- package/src/i18n/locales/es/components.toml +0 -1
- package/src/i18n/locales/es/errors.json +1 -2
- package/src/i18n/locales/es/platform.json +0 -3
- package/src/i18n/locales/fr/components.json +0 -1
- package/src/i18n/locales/fr/components.toml +0 -1
- package/src/i18n/locales/fr/errors.json +1 -2
- package/src/i18n/locales/fr/platform.json +0 -3
- package/src/i18n/locales/ja/components.json +0 -1
- package/src/i18n/locales/ja/components.toml +0 -1
- package/src/i18n/locales/ja/errors.json +1 -2
- package/src/i18n/locales/ja/platform.json +0 -3
- package/src/i18n/locales/ko/components.json +0 -1
- package/src/i18n/locales/ko/components.toml +0 -1
- package/src/i18n/locales/ko/errors.json +1 -2
- package/src/i18n/locales/ko/platform.json +0 -3
- package/src/i18n/locales/pt/components.json +0 -1
- package/src/i18n/locales/pt/components.toml +0 -1
- package/src/i18n/locales/pt/errors.json +1 -2
- package/src/i18n/locales/pt/platform.json +0 -3
- package/src/i18n/locales/ru/components.json +0 -1
- package/src/i18n/locales/ru/components.toml +0 -1
- package/src/i18n/locales/ru/errors.json +1 -2
- package/src/i18n/locales/ru/platform.json +0 -3
- package/src/i18n/locales/zh-Hans/components.json +0 -1
- package/src/i18n/locales/zh-Hans/components.toml +0 -1
- package/src/i18n/locales/zh-Hans/errors.json +1 -2
- package/src/i18n/locales/zh-Hans/platform.json +0 -3
- package/src/i18n/locales/zh-Hant/components.json +0 -1
- package/src/i18n/locales/zh-Hant/components.toml +0 -1
- package/src/i18n/locales/zh-Hant/errors.json +1 -2
- package/src/i18n/locales/zh-Hant/platform.json +0 -3
package/package.json
CHANGED
|
@@ -13,7 +13,10 @@ import { setLocale } from "../i18n/context";
|
|
|
13
13
|
* name without an href stays plain text
|
|
14
14
|
* - description / license / copyright render the given strings
|
|
15
15
|
* - component rows split the machine value from an optional meta pill
|
|
16
|
-
* - the backdrop factory
|
|
16
|
+
* - the backdrop factory rides the WINDOW-level material layer (2026-11-12):
|
|
17
|
+
* the body-level bed clipped the artwork to the content box and the
|
|
18
|
+
* frame's padding read as a second surface — the artwork now spans the
|
|
19
|
+
* whole frame, and the body mounts no bed of its own
|
|
17
20
|
* - licenses and links render as chips under one centered block
|
|
18
21
|
* - footer (filing) links render as external links
|
|
19
22
|
* - `face: "plain"` / `face: "accent"` turn any of them into a bare text
|
|
@@ -401,12 +404,21 @@ describe("HkAboutModal branding", () => {
|
|
|
401
404
|
expect(links[0]!.getAttribute("href")).toBe("https://beian.miit.gov.cn/");
|
|
402
405
|
});
|
|
403
406
|
|
|
404
|
-
it("
|
|
407
|
+
it("wears the backdrop at window level: the artwork spans the frame, the body mounts no bed", async () => {
|
|
405
408
|
mountAbout({ backdrop: () => h("div", { class: "test-backdrop-marker" }) });
|
|
406
409
|
await flushModal();
|
|
407
|
-
|
|
410
|
+
// The artwork rides HkModal's material slot — inside the frame, above
|
|
411
|
+
// the frame's own fill, below the header/body/footer chrome.
|
|
412
|
+
const layer = query<HTMLElement>(".hk-modal-backdrop");
|
|
408
413
|
expect(layer.getAttribute("aria-hidden")).toBe("true");
|
|
409
414
|
expect(layer.querySelector(".test-backdrop-marker")).toBeTruthy();
|
|
415
|
+
const content = layer.closest(".hk-modal-content");
|
|
416
|
+
expect(content).toBeTruthy();
|
|
417
|
+
expect(content!.getAttribute("data-backdrop")).not.toBeNull();
|
|
418
|
+
// The body-level bed is exactly the seam this replaces: clipped to the
|
|
419
|
+
// content box, it left the window padding a different material. The
|
|
420
|
+
// modal must not mount one any more.
|
|
421
|
+
expect(document.body.querySelector(".s-about-modal-backdrop")).toBeNull();
|
|
410
422
|
});
|
|
411
423
|
|
|
412
424
|
it("renders links as external chips", async () => {
|
|
@@ -403,9 +403,14 @@ export const HkAboutModal = defineComponent({
|
|
|
403
403
|
/** Render the legal filings as a chip group (see {@link HkAboutBody}). */
|
|
404
404
|
filingsAsChips: { type: Boolean, default: false },
|
|
405
405
|
/**
|
|
406
|
-
* Optional decorative backdrop factory
|
|
407
|
-
*
|
|
408
|
-
*
|
|
406
|
+
* Optional decorative backdrop factory. In the MODAL this rides the
|
|
407
|
+
* window-level material slot: one clipped, pointer-inert layer the
|
|
408
|
+
* whole frame wears — header, body padding and footer included — so
|
|
409
|
+
* the padding is part of the artwork instead of a second surface
|
|
410
|
+
* (2026-11-12; the body-level bed this used to mount showed the
|
|
411
|
+
* artwork clipped to the content box with a different material band
|
|
412
|
+
* around it). Non-modal hosts mounting {@link HkAboutBody} directly
|
|
413
|
+
* still get the body-level layer from that component.
|
|
409
414
|
*/
|
|
410
415
|
backdrop: { type: Function as PropType<() => unknown>, default: undefined },
|
|
411
416
|
title: { type: String, default: undefined },
|
|
@@ -422,23 +427,28 @@ export const HkAboutModal = defineComponent({
|
|
|
422
427
|
onUpdate:modelValue={(v: boolean) => emit("update:modelValue", v)}
|
|
423
428
|
title={props.title ?? t("hikari::about.title", "About")}
|
|
424
429
|
width="30rem"
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
430
|
+
v-slots={{
|
|
431
|
+
// Window-level material: the artwork spans the frame's padding
|
|
432
|
+
// and header, so no content-area bed is handed to the body.
|
|
433
|
+
backdrop: props.backdrop ? () => props.backdrop!() : undefined,
|
|
434
|
+
default: () => (
|
|
435
|
+
<HkAboutBody
|
|
436
|
+
appName={props.appName}
|
|
437
|
+
version={props.version}
|
|
438
|
+
logoSrc={props.logoSrc}
|
|
439
|
+
tagline={props.tagline}
|
|
440
|
+
description={props.description}
|
|
441
|
+
credits={props.credits}
|
|
442
|
+
licenses={props.licenses}
|
|
443
|
+
componentVersions={props.componentVersions}
|
|
444
|
+
copyright={props.copyright}
|
|
445
|
+
links={props.links}
|
|
446
|
+
footerLinks={props.footerLinks}
|
|
447
|
+
filingsAsChips={props.filingsAsChips}
|
|
448
|
+
/>
|
|
449
|
+
),
|
|
450
|
+
}}
|
|
451
|
+
/>
|
|
442
452
|
);
|
|
443
453
|
},
|
|
444
454
|
});
|
|
@@ -2,6 +2,7 @@ import { afterEach, describe, expect, it, vi } from "vitest";
|
|
|
2
2
|
import { createApp, h, nextTick } from "vue";
|
|
3
3
|
|
|
4
4
|
import { HkErrorLanding } from "./HkErrorLanding";
|
|
5
|
+
import { useToast } from "../runtime/useToast";
|
|
5
6
|
const mounts: Array<{ app: ReturnType<typeof createApp>; container: HTMLElement }> = [];
|
|
6
7
|
|
|
7
8
|
interface MountOptions {
|
|
@@ -203,16 +204,24 @@ describe("HkErrorLanding", () => {
|
|
|
203
204
|
expect(buttons[1]!.classList.contains("fake-action")).toBe(true);
|
|
204
205
|
});
|
|
205
206
|
|
|
206
|
-
it("writes the copy payload and
|
|
207
|
+
it("writes the copy payload, toasts success, and keeps the label constant", async () => {
|
|
207
208
|
const writeText = stubClipboard();
|
|
209
|
+
useToast().toasts.splice(0);
|
|
208
210
|
const el = mountLanding({ copyText: "full error info" });
|
|
209
211
|
const copy = actionButtons(el)[0]!;
|
|
210
212
|
copy.click();
|
|
211
213
|
await vi.waitFor(() => expect(writeText).toHaveBeenCalledTimes(1));
|
|
212
214
|
expect(writeText).toHaveBeenCalledWith("full error info");
|
|
215
|
+
// The toast is the ONLY copy feedback (user direction 2026-11-11):
|
|
216
|
+
// the button's text never flips to "Copied" — it stays put while the
|
|
217
|
+
// shared toast speaks.
|
|
218
|
+
await vi.waitFor(() => {
|
|
219
|
+
expect(useToast().toasts.some((t) => t.type === "success")).toBe(true);
|
|
220
|
+
});
|
|
213
221
|
await nextTick();
|
|
214
222
|
await nextTick();
|
|
215
|
-
expect(actionButtons(el)[0]!.textContent).toBe("
|
|
223
|
+
expect(actionButtons(el)[0]!.textContent).toBe("Copy error details");
|
|
224
|
+
useToast().toasts.splice(0);
|
|
216
225
|
});
|
|
217
226
|
|
|
218
227
|
it("renders the copy action alone when the host passes no actions", () => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Braces,
|
|
1
|
+
import { Braces, Copy, Info, TriangleAlert } from "lucide-vue-next";
|
|
2
2
|
import {
|
|
3
3
|
computed,
|
|
4
4
|
defineComponent,
|
|
@@ -12,7 +12,8 @@ import {
|
|
|
12
12
|
|
|
13
13
|
import { attachOverlayScrollbars, type OverlayScrollbarHandle } from "../composables/useOverlayScrollbar";
|
|
14
14
|
import { useI18n } from "../i18n/context";
|
|
15
|
-
import {
|
|
15
|
+
import { useClipboardWithToast } from "../runtime/useClipboard";
|
|
16
|
+
import { useToast } from "../runtime/useToast";
|
|
16
17
|
import HkBadge from "./HkBadge";
|
|
17
18
|
import HkButton from "./HkButton";
|
|
18
19
|
|
|
@@ -74,7 +75,12 @@ function normalizeSlotNodes(nodes: VNode | VNode[] | undefined): VNode[] {
|
|
|
74
75
|
* whole error-landing family instead of every consumer hand-rolling its
|
|
75
76
|
* own copy row (the boundary used to ship a private one; it now feeds this
|
|
76
77
|
* hook). `copyLabel` overrides the button wording when a host already
|
|
77
|
-
* ships its own.
|
|
78
|
+
* ships its own. Feedback rides the shared clipboard-with-toast path and
|
|
79
|
+
* NOTHING else (user direction 2026-11-11): a copy control's text never
|
|
80
|
+
* flips to "Copied" — the toast speaks once, and the button stays put.
|
|
81
|
+
* The toast renders in the HOST's viewport (the family toast surface);
|
|
82
|
+
* a host without one hears nothing, same contract as every other
|
|
83
|
+
* useClipboardWithToast consumer.
|
|
78
84
|
*/
|
|
79
85
|
export const HkErrorLanding = defineComponent({
|
|
80
86
|
name: "HkErrorLanding",
|
|
@@ -106,7 +112,7 @@ export const HkErrorLanding = defineComponent({
|
|
|
106
112
|
},
|
|
107
113
|
setup(props, { slots }) {
|
|
108
114
|
const { t } = useI18n();
|
|
109
|
-
const clipboard =
|
|
115
|
+
const clipboard = useClipboardWithToast(useToast());
|
|
110
116
|
|
|
111
117
|
const titleText = computed(() => props.title || t("hikari::errors.defaultTitle", "Something went wrong"));
|
|
112
118
|
const hasDetails = computed(() => slots.default != null);
|
|
@@ -243,10 +249,8 @@ export const HkErrorLanding = defineComponent({
|
|
|
243
249
|
variant="ghost"
|
|
244
250
|
onClick={() => { void clipboard.copy(props.copyText); }}
|
|
245
251
|
>
|
|
246
|
-
|
|
247
|
-
{
|
|
248
|
-
? t("hikari::errors.copied", "Copied")
|
|
249
|
-
: props.copyLabel || t("hikari::errors.copyDetails", "Copy error details")}
|
|
252
|
+
<Copy size={12} />
|
|
253
|
+
{props.copyLabel || t("hikari::errors.copyDetails", "Copy error details")}
|
|
250
254
|
</HkButton>
|
|
251
255
|
)]
|
|
252
256
|
: []),
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { describe, expect, it } from "vitest";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Copy-feedback contract for HkLogWindow's toolbar (user direction
|
|
8
|
+
* 2026-11-11: EVERY click-to-copy control keeps CONSTANT text — the
|
|
9
|
+
* shared toast is the only feedback; a control whose wording mutates
|
|
10
|
+
* under the cursor reads as a second, competing signal beside it).
|
|
11
|
+
*
|
|
12
|
+
* The copy button lives inside the HModal sheet, whose open
|
|
13
|
+
* choreography never settles under happy-dom — the DOM is unreachable
|
|
14
|
+
* from vitest, so the contract is pinned on the source (the same
|
|
15
|
+
* source-contract pattern TopicMindMap.styles.test.ts uses for
|
|
16
|
+
* stylesheet rules vitest cannot resolve).
|
|
17
|
+
*/
|
|
18
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
19
|
+
const tsx = readFileSync(join(here, "HkLogWindow.tsx"), "utf-8");
|
|
20
|
+
|
|
21
|
+
describe("HkLogWindow copy feedback", () => {
|
|
22
|
+
it("rides the shared clipboard-with-toast path, not the bare hook", () => {
|
|
23
|
+
expect(tsx).toMatch(/useClipboardWithToast,\s*useToast/);
|
|
24
|
+
// The bare hook has no toast — its only feedback channel was the
|
|
25
|
+
// copied-state tooltip flip this contract retires.
|
|
26
|
+
expect(tsx).not.toMatch(/useClipboard[,}]/);
|
|
27
|
+
expect(tsx).toMatch(/useClipboardWithToast\(useToast\(\)\)/);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("keeps the copy control's tooltip constant — no copied-state flip", () => {
|
|
31
|
+
// Comments stripped first: the guard is about CODE reading the
|
|
32
|
+
// copied state, not prose explaining the contract.
|
|
33
|
+
const code = tsx
|
|
34
|
+
.split("\n")
|
|
35
|
+
.filter((line) => !line.trim().startsWith("//"))
|
|
36
|
+
.join("\n");
|
|
37
|
+
// No copied-state read anywhere in the component: the flip cannot
|
|
38
|
+
// come back through a side door (a computed, a local ref, …).
|
|
39
|
+
expect(code).not.toMatch(/\bcopied\b/);
|
|
40
|
+
const title = /title=\{t\("hikari::log\.copy", "Copy"\)\}/;
|
|
41
|
+
expect(tsx).toMatch(title);
|
|
42
|
+
expect(tsx).not.toMatch(/hikari::log\.copied/);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { computed, defineComponent, nextTick, ref, watch, type PropType } from "vue";
|
|
2
2
|
import { Copy, Eraser, Pause, Play, ScrollText } from "lucide-vue-next";
|
|
3
|
-
import { HModal, HScrollContainer,
|
|
3
|
+
import { HModal, HScrollContainer, useClipboardWithToast, useToast, type ModalWidth } from "@celestia-island/hikari";
|
|
4
4
|
|
|
5
5
|
import { useI18n } from "../i18n/context";
|
|
6
6
|
|
|
@@ -56,7 +56,11 @@ export const HkLogWindow = defineComponent({
|
|
|
56
56
|
},
|
|
57
57
|
setup(props, { emit }) {
|
|
58
58
|
const { t } = useI18n();
|
|
59
|
-
|
|
59
|
+
// Copy feedback speaks through the shared toast ONLY (user direction
|
|
60
|
+
// 2026-11-11): the copy control's tooltip never flips to "Copied" —
|
|
61
|
+
// a control whose wording mutates under the cursor reads as a
|
|
62
|
+
// second, competing signal beside the toast.
|
|
63
|
+
const clipboard = useClipboardWithToast(useToast());
|
|
60
64
|
|
|
61
65
|
const activeTab = ref<string>("");
|
|
62
66
|
const autoscroll = ref(true);
|
|
@@ -110,8 +114,6 @@ export const HkLogWindow = defineComponent({
|
|
|
110
114
|
void clipboard.copy(currentLines.value.join("\n"));
|
|
111
115
|
}
|
|
112
116
|
|
|
113
|
-
const copied = computed(() => clipboard.copied.value);
|
|
114
|
-
|
|
115
117
|
return () => (
|
|
116
118
|
<HModal
|
|
117
119
|
modelValue={props.modelValue}
|
|
@@ -158,7 +160,7 @@ export const HkLogWindow = defineComponent({
|
|
|
158
160
|
class="s-log-btn"
|
|
159
161
|
disabled={currentLines.value.length === 0}
|
|
160
162
|
onClick={handleCopy}
|
|
161
|
-
title={
|
|
163
|
+
title={t("hikari::log.copy", "Copy")}
|
|
162
164
|
>
|
|
163
165
|
<Copy size={12} />
|
|
164
166
|
</button>
|
|
@@ -331,6 +331,7 @@
|
|
|
331
331
|
--hk-scroll-pad-bottom: var(--hk-pad, var(--hk-modal-padding-body, 1.5rem));
|
|
332
332
|
--hk-scroll-pad-left: var(--hk-pad, var(--hk-modal-padding-body, 1.5rem));
|
|
333
333
|
|
|
334
|
+
|
|
334
335
|
// Gutter covers (scroll-pin contract, 2026-09-14): the body's top and
|
|
335
336
|
// bottom whitespace stays paintable OUTSIDE the scroll flow, so a
|
|
336
337
|
// pinned child (HkScrollPin strategy="offset") stops below the gutter
|
|
@@ -365,6 +366,42 @@
|
|
|
365
366
|
}
|
|
366
367
|
}
|
|
367
368
|
|
|
369
|
+
// Window-level material slot (2026-11-12): the decorative layer the whole
|
|
370
|
+
// frame wears when a `backdrop` slot is handed to HkModal. z-index: -1
|
|
371
|
+
// paints it above the frame's own fill (the user's glass/acrylic finish
|
|
372
|
+
// shows through any transparent regions of the artwork) and below every
|
|
373
|
+
// in-flow sibling — header, body and footer need no z-index of their own.
|
|
374
|
+
// border-radius: inherit + overflow: hidden keep the artwork inside the
|
|
375
|
+
// frame's own corners on desktop AND inside the sheet's clip-path reveal
|
|
376
|
+
// on phones, so a host never re-clips its artwork per surface.
|
|
377
|
+
.hk-modal-backdrop {
|
|
378
|
+
position: absolute;
|
|
379
|
+
inset: 0;
|
|
380
|
+
z-index: -1;
|
|
381
|
+
overflow: hidden;
|
|
382
|
+
border-radius: inherit;
|
|
383
|
+
pointer-events: none;
|
|
384
|
+
|
|
385
|
+
> * {
|
|
386
|
+
width: 100%;
|
|
387
|
+
height: 100%;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// A frame wearing a material has no gutter covers: the covers exist to
|
|
392
|
+
// repaint the body's top/bottom whitespace in the window's surface colour
|
|
393
|
+
// so scrolled content vanishes under the padding — over an artwork that
|
|
394
|
+
// solid repaint IS the seam (the exact "padding looks like another
|
|
395
|
+
// material" bug this slot replaces). With the artwork spanning the
|
|
396
|
+
// padding, the whitespace is already the material; the trade (rows
|
|
397
|
+
// scrolling through the gutter stay visible over the artwork) is the
|
|
398
|
+
// documented cost of opting into a window material, and the header/footer
|
|
399
|
+
// bands still bound the body.
|
|
400
|
+
.hk-modal-content[data-backdrop] .hk-modal-body::before,
|
|
401
|
+
.hk-modal-content[data-backdrop] .hk-modal-body::after {
|
|
402
|
+
content: none;
|
|
403
|
+
}
|
|
404
|
+
|
|
368
405
|
.hk-modal-body-scroll {
|
|
369
406
|
flex: 1;
|
|
370
407
|
min-height: 0;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { dirname, resolve } from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
|
|
4
|
+
import { compile } from "sass";
|
|
5
|
+
import { describe, expect, it } from "vitest";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Compiled-stylesheet guard for the window-level material slot (PR #1229).
|
|
9
|
+
*
|
|
10
|
+
* The runtime suite pins the SLOT (the layer element, its frame-level
|
|
11
|
+
* position, the `data-backdrop` mark) but Vitest stubs CSS, so nothing at
|
|
12
|
+
* runtime can see the two rules the mark is supposed to key — deleting
|
|
13
|
+
* either one leaves every DOM test green while the artwork breaks (the
|
|
14
|
+
* M3 mutation in review survived exactly this way):
|
|
15
|
+
*
|
|
16
|
+
* 1. the backdrop layer rule (position/inertness/inheritance), and
|
|
17
|
+
* 2. the gutter-cover suppression — without it the body's top/bottom
|
|
18
|
+
* covers repaint solid bands over the artwork, which is the
|
|
19
|
+
* "padding reads as a second material" seam this slot exists to fix.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
const componentDir = resolve(dirname(fileURLToPath(import.meta.url)));
|
|
23
|
+
|
|
24
|
+
function ruleBody(sheet: string, selector: string): string {
|
|
25
|
+
const escaped = selector.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
26
|
+
const matches = [
|
|
27
|
+
...sheet.matchAll(new RegExp(`(?:(?<=^)|(?<=[}{]))\\s*${escaped}\\s*\\{([^}]*)\\}`, "g")),
|
|
28
|
+
];
|
|
29
|
+
expect(matches, `${selector} compiles exactly once`).toHaveLength(1);
|
|
30
|
+
return matches[0]?.[1] ?? "";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const sheet = compile(resolve(componentDir, "HkModal.scss"), {
|
|
34
|
+
style: "expanded",
|
|
35
|
+
}).css.replace(/\s+/g, " ");
|
|
36
|
+
|
|
37
|
+
describe("HkModal window material (compiled contract)", () => {
|
|
38
|
+
it("positions the backdrop layer under the chrome and inside the frame's corners", () => {
|
|
39
|
+
const body = ruleBody(sheet, ".hk-modal-backdrop");
|
|
40
|
+
// Every property is load-bearing: the layer must be inert, clipped,
|
|
41
|
+
// corner-conforming (desktop corners AND the phone sheet reveal) and
|
|
42
|
+
// painted below every in-flow sibling while staying above the frame's
|
|
43
|
+
// own glass fill.
|
|
44
|
+
expect(body).toContain("position: absolute");
|
|
45
|
+
expect(body).toContain("inset: 0");
|
|
46
|
+
expect(body).toContain("z-index: -1");
|
|
47
|
+
expect(body).toContain("overflow: hidden");
|
|
48
|
+
expect(body).toContain("border-radius: inherit");
|
|
49
|
+
expect(body).toContain("pointer-events: none");
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("sizes the handed-in artwork to the frame", () => {
|
|
53
|
+
// Expanded output nests the child selector: `.hk-modal-backdrop > *`.
|
|
54
|
+
const body = ruleBody(sheet, ".hk-modal-backdrop > *");
|
|
55
|
+
expect(body).toContain("width: 100%");
|
|
56
|
+
expect(body).toContain("height: 100%");
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("suppresses the body's gutter covers while a material is worn", () => {
|
|
60
|
+
// The covers must STOP EXISTING (content:none), not merely paint
|
|
61
|
+
// transparent: they also carry the scroll-pin mask semantics, and a
|
|
62
|
+
// transparent cover would still sit over the artwork. The rule
|
|
63
|
+
// compiles as ONE combined selector (before + after share a body) —
|
|
64
|
+
// assert on that combined form. The selector is keyed on the FRAME's
|
|
65
|
+
// own mark so an unrelated `data-backdrop` attribute on some outer
|
|
66
|
+
// host element can never suppress a nested modal's covers.
|
|
67
|
+
const body = ruleBody(
|
|
68
|
+
sheet,
|
|
69
|
+
".hk-modal-content[data-backdrop] .hk-modal-body::before, .hk-modal-content[data-backdrop] .hk-modal-body::after",
|
|
70
|
+
);
|
|
71
|
+
expect(body).toContain("content: none");
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("keeps the plain gutter covers for frames without a material", () => {
|
|
75
|
+
// The default contract is unchanged: the shared cover rule still
|
|
76
|
+
// paints when no backdrop slot is handed in (the later per-side rules
|
|
77
|
+
// only position the two strips).
|
|
78
|
+
const shared = ruleBody(sheet, ".hk-modal-body::before, .hk-modal-body::after");
|
|
79
|
+
expect(shared).toContain('content: ""');
|
|
80
|
+
expect(shared).not.toContain("content: none");
|
|
81
|
+
});
|
|
82
|
+
});
|
|
@@ -477,6 +477,81 @@ describe("HkModal dial slot (stack priority)", () => {
|
|
|
477
477
|
});
|
|
478
478
|
});
|
|
479
479
|
|
|
480
|
+
describe("HkModal window-level material slot", () => {
|
|
481
|
+
it("wears the backdrop over the whole frame: layer first, chrome above, no body-level bed", async () => {
|
|
482
|
+
const container = document.createElement("div");
|
|
483
|
+
document.body.appendChild(container);
|
|
484
|
+
containers.push(container);
|
|
485
|
+
|
|
486
|
+
const Wrapper = defineComponent({
|
|
487
|
+
setup() {
|
|
488
|
+
return () =>
|
|
489
|
+
h(HkModal, {
|
|
490
|
+
modelValue: true,
|
|
491
|
+
title: "Window",
|
|
492
|
+
}, {
|
|
493
|
+
default: () => h("p", { class: "body-probe" }, "content"),
|
|
494
|
+
backdrop: () => h("div", { class: "material-probe" }, "art"),
|
|
495
|
+
});
|
|
496
|
+
},
|
|
497
|
+
});
|
|
498
|
+
const app = createApp(Wrapper);
|
|
499
|
+
mounts.push(app);
|
|
500
|
+
app.mount(container);
|
|
501
|
+
|
|
502
|
+
await vi.waitFor(() => {
|
|
503
|
+
const content = document.body.querySelector(".hk-modal-content");
|
|
504
|
+
expect(content).not.toBeNull();
|
|
505
|
+
// The frame is MARKED as wearing a material: the stylesheet keys the
|
|
506
|
+
// gutter-cover suppression off this attribute, so a layer without
|
|
507
|
+
// the mark would leave solid bands across the padding.
|
|
508
|
+
expect(content!.getAttribute("data-backdrop")).not.toBeNull();
|
|
509
|
+
const layer = content!.querySelector(".hk-modal-backdrop");
|
|
510
|
+
expect(layer).not.toBeNull();
|
|
511
|
+
// Decorative by contract: inert to pointer and hidden from a11y.
|
|
512
|
+
expect(layer!.getAttribute("aria-hidden")).toBe("true");
|
|
513
|
+
// The artwork sits at FRAME level — above the frame's own fill,
|
|
514
|
+
// below every in-flow chrome band. It must not live in the body:
|
|
515
|
+
// the body-level bed is exactly the "padding looks like a second
|
|
516
|
+
// surface" bug this slot replaces.
|
|
517
|
+
expect(layer!.parentElement).toBe(content);
|
|
518
|
+
expect(content!.querySelector(".hk-modal-body")!.contains(layer!)).toBe(false);
|
|
519
|
+
expect(layer!.querySelector(".material-probe")).not.toBeNull();
|
|
520
|
+
// First child: the header, body and footer all paint above it in
|
|
521
|
+
// source order, so the material never covers the chrome.
|
|
522
|
+
expect(content!.firstElementChild).toBe(layer);
|
|
523
|
+
const header = content!.querySelector(".hk-modal-header");
|
|
524
|
+
expect(header).not.toBeNull();
|
|
525
|
+
expect(layer!.contains(header!)).toBe(false);
|
|
526
|
+
});
|
|
527
|
+
});
|
|
528
|
+
|
|
529
|
+
it("renders no layer and no mark when no backdrop is handed in", async () => {
|
|
530
|
+
const container = document.createElement("div");
|
|
531
|
+
document.body.appendChild(container);
|
|
532
|
+
containers.push(container);
|
|
533
|
+
|
|
534
|
+
const Wrapper = defineComponent({
|
|
535
|
+
setup() {
|
|
536
|
+
return () =>
|
|
537
|
+
h(HkModal, { modelValue: true, title: "Window" }, {
|
|
538
|
+
default: () => h("p", null, "content"),
|
|
539
|
+
});
|
|
540
|
+
},
|
|
541
|
+
});
|
|
542
|
+
const app = createApp(Wrapper);
|
|
543
|
+
mounts.push(app);
|
|
544
|
+
app.mount(container);
|
|
545
|
+
|
|
546
|
+
await vi.waitFor(() => {
|
|
547
|
+
const content = document.body.querySelector(".hk-modal-content");
|
|
548
|
+
expect(content).not.toBeNull();
|
|
549
|
+
expect(content!.getAttribute("data-backdrop")).toBeNull();
|
|
550
|
+
expect(content!.querySelector(".hk-modal-backdrop")).toBeNull();
|
|
551
|
+
});
|
|
552
|
+
});
|
|
553
|
+
});
|
|
554
|
+
|
|
480
555
|
describe("HkModal chrome / content split", () => {
|
|
481
556
|
it("keeps the title bar and the footer action row outside the scaled content region", async () => {
|
|
482
557
|
const container = document.createElement("div");
|
|
@@ -1101,6 +1101,12 @@ export default defineComponent({
|
|
|
1101
1101
|
aria-modal="true"
|
|
1102
1102
|
aria-label={resolvedSurfaceName.value}
|
|
1103
1103
|
data-draggable={props.draggable || undefined}
|
|
1104
|
+
// Marks the frame as wearing a window-level material
|
|
1105
|
+
// (see the backdrop slot below): the CSS uses it to stop
|
|
1106
|
+
// the body's gutter covers painting solid bands over the
|
|
1107
|
+
// artwork — with a material on the frame, the padding is
|
|
1108
|
+
// part of the material, not a different surface.
|
|
1109
|
+
data-backdrop={slots.backdrop ? "" : undefined}
|
|
1104
1110
|
style={{
|
|
1105
1111
|
maxWidth: resolvedWidth.value,
|
|
1106
1112
|
zIndex: contentZ.value,
|
|
@@ -1114,6 +1120,19 @@ export default defineComponent({
|
|
|
1114
1120
|
so a consumer tearing down its state on close
|
|
1115
1121
|
cannot blank the window mid-fold. */}
|
|
1116
1122
|
{contentHold.hold(() => [
|
|
1123
|
+
slots.backdrop ? (
|
|
1124
|
+
// Window-level material: one clipped, pointer-inert
|
|
1125
|
+
// layer the whole frame wears — header, body padding
|
|
1126
|
+
// and footer included, so a host hands the artwork to
|
|
1127
|
+
// the WINDOW and no content area needs its own custom
|
|
1128
|
+
// bed. z-index -1 keeps it above the frame's own fill
|
|
1129
|
+
// (glass/acrylic finish) and below every in-flow
|
|
1130
|
+
// sibling; sizing and the render loop belong to the
|
|
1131
|
+
// handed-in subtree exactly as on the body-level slot.
|
|
1132
|
+
<div class="hk-modal-backdrop" aria-hidden="true">
|
|
1133
|
+
{slots.backdrop()}
|
|
1134
|
+
</div>
|
|
1135
|
+
) : null,
|
|
1117
1136
|
headerShown ? (
|
|
1118
1137
|
<>
|
|
1119
1138
|
<div
|
|
@@ -18,7 +18,10 @@ export type ScrollPinSide = "top" | "bottom" | "left" | "right";
|
|
|
18
18
|
* (`--hk-scroll-pad-*`); the host paints the zone above/below the pin,
|
|
19
19
|
* so scrolled content vanishes under the whitespace instead of showing
|
|
20
20
|
* through a gap. Works for pins anywhere in the flow (toolbars may
|
|
21
|
-
* precede them).
|
|
21
|
+
* precede them). EXCEPTION: a modal wearing a window-level material
|
|
22
|
+
* (`data-backdrop`, HkModal's backdrop slot) suppresses those covers —
|
|
23
|
+
* over a window-spanning artwork the solid repaint IS the seam, so
|
|
24
|
+
* content scrolling through the gutter stays visible there by design.
|
|
22
25
|
* - `"bleed"` — absorb the host's in-flow padding into the pin itself
|
|
23
26
|
* (`padding: var(--hk-scroll-pad-…) + negative margin`): the pin's own
|
|
24
27
|
* background paints over the padding zone so the whitespace travels
|
|
@@ -2923,6 +2923,7 @@ describe("label first-line anchoring", () => {
|
|
|
2923
2923
|
"bundle :: - | .hk-layout > * | position: relative",
|
|
2924
2924
|
"bundle :: - | .hk-markdown code | font-family: var(--font-mono, ui-monospace, \"SF Mono\", Menlo, Consolas, \"DejaVu Sans Mono\", \"Liberation Mono\", \"PingFang SC\", \"Microsoft YaHei\", \"Noto Sans CJK SC\", monospace); font-size: 0.85em; padding: 0.15em 0.35em",
|
|
2925
2925
|
"bundle :: - | .hk-menu-item a | align-items: center; display: flex; gap: 1rem; height: 100%; width: 100%",
|
|
2926
|
+
"bundle :: - | .hk-modal-backdrop > * | height: 100%; width: 100%",
|
|
2926
2927
|
"bundle :: - | .hk-modal-body-inner > * + * | margin-top: var(--hk-modal-body-gap, 0.75rem)",
|
|
2927
2928
|
"bundle :: - | .hk-row > * | margin: 0 0.5rem",
|
|
2928
2929
|
"bundle :: - | .hk-sidebar-item-content a | align-items: center; bottom: -0.75rem; display: flex; gap: 0.875rem; left: -1.5rem; padding-left: 1.5rem; position: absolute; right: -1rem; top: -0.75rem",
|
|
@@ -2961,6 +2962,7 @@ describe("label first-line anchoring", () => {
|
|
|
2961
2962
|
"components/HkDiffViewer.scss :: - | .hk-diff-viewer__hunk-stats em | font-style: normal; font-weight: 600",
|
|
2962
2963
|
"components/HkDraggableList.scss :: - | .hk-draggable-list-content > :only-child | flex: 1; min-width: 0",
|
|
2963
2964
|
"components/HkMarkdownRenderer.scss :: - | .hk-markdown code | font-family: var(--font-mono, ui-monospace, \"SF Mono\", Menlo, Consolas, \"DejaVu Sans Mono\", \"Liberation Mono\", \"PingFang SC\", \"Microsoft YaHei\", \"Noto Sans CJK SC\", monospace); font-size: 0.85em; padding: 0.15em 0.35em",
|
|
2965
|
+
"components/HkModal.scss :: - | .hk-modal-backdrop > * | height: 100%; width: 100%",
|
|
2964
2966
|
"components/HkModal.scss :: - | .hk-modal-body-inner > * + * | margin-top: var(--hk-modal-body-gap, 0.75rem)",
|
|
2965
2967
|
"components/HkScrollContainer.scss :: - | .hk-scroll-container[data-dock-tail=true] > .hk-scroll-container-viewport > * | flex-shrink: 0",
|
|
2966
2968
|
"demo.scss :: - | .icon-grid small | font-size: 0.625rem",
|
|
@@ -236,6 +236,45 @@ describe("HkToast", () => {
|
|
|
236
236
|
});
|
|
237
237
|
});
|
|
238
238
|
|
|
239
|
+
describe("HkToast teleport placement", () => {
|
|
240
|
+
it("renders the band IN PLACE when teleport is false (takeover hosts)", async () => {
|
|
241
|
+
const container = document.createElement("div");
|
|
242
|
+
document.body.appendChild(container);
|
|
243
|
+
const app = createApp({ render: () => h(HkToast, { teleport: false }) });
|
|
244
|
+
mounts.push({ app, container });
|
|
245
|
+
app.mount(container);
|
|
246
|
+
const toast = useToast();
|
|
247
|
+
toast.success("in place");
|
|
248
|
+
await settle();
|
|
249
|
+
|
|
250
|
+
// The band lives INSIDE the host container — the takeover-host
|
|
251
|
+
// contract (the error-reporting overlay's z band sits above the
|
|
252
|
+
// family overlay root, so a teleported stack would paint under an
|
|
253
|
+
// opaque backdrop and be invisible).
|
|
254
|
+
expect(container.querySelector(".hk-toast-container")).not.toBeNull();
|
|
255
|
+
expect(container.querySelector(".hk-toast-item")).not.toBeNull();
|
|
256
|
+
// And NOT in the family overlay root.
|
|
257
|
+
const overlayRoot = document.getElementById("hk-overlay-root");
|
|
258
|
+
if (overlayRoot) {
|
|
259
|
+
expect(overlayRoot.querySelector(".hk-toast-container")).toBeNull();
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
it("teleports the band into the family overlay root by default", async () => {
|
|
264
|
+
const container = document.createElement("div");
|
|
265
|
+
document.body.appendChild(container);
|
|
266
|
+
const app = createApp({ render: () => h(HkToast) });
|
|
267
|
+
mounts.push({ app, container });
|
|
268
|
+
app.mount(container);
|
|
269
|
+
const toast = useToast();
|
|
270
|
+
toast.success("teleported");
|
|
271
|
+
await settle();
|
|
272
|
+
|
|
273
|
+
expect(container.querySelector(".hk-toast-container")).toBeNull();
|
|
274
|
+
expect(document.getElementById("hk-overlay-root")?.querySelector(".hk-toast-container")).not.toBeNull();
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
|
|
239
278
|
describe("HkToast live-region semantics", () => {
|
|
240
279
|
it("announces errors as alert/assertive and everything else as status/polite", async () => {
|
|
241
280
|
mountHost();
|
|
@@ -204,7 +204,15 @@ const HkToastItem = defineComponent({
|
|
|
204
204
|
|
|
205
205
|
export default defineComponent({
|
|
206
206
|
name: "HkToast",
|
|
207
|
-
|
|
207
|
+
props: {
|
|
208
|
+
/** Render the stack IN PLACE instead of teleporting into the family
|
|
209
|
+
* overlay root — for hosts that own their stacking context (a
|
|
210
|
+
* full-screen takeover shell, e.g. the error-reporting overlay,
|
|
211
|
+
* whose own z band sits above the overlay root and would paint an
|
|
212
|
+
* opaque backdrop over the teleported stack). */
|
|
213
|
+
teleport: { type: Boolean, default: true },
|
|
214
|
+
},
|
|
215
|
+
setup(props) {
|
|
208
216
|
const { toasts, remove } = useToast();
|
|
209
217
|
// The toast stack registers with the popup manager (kind "toast") so
|
|
210
218
|
// it holds the topmost z band (POPUP_Z_BANDS.toast): toasts stay
|
|
@@ -282,8 +290,14 @@ export default defineComponent({
|
|
|
282
290
|
: undefined,
|
|
283
291
|
);
|
|
284
292
|
|
|
285
|
-
return () =>
|
|
286
|
-
|
|
293
|
+
return () => {
|
|
294
|
+
// The band teleports into the family overlay root by default. The
|
|
295
|
+
// `teleport: false` face renders it IN PLACE instead — for hosts
|
|
296
|
+
// that own their stacking context (a full-screen takeover shell,
|
|
297
|
+
// e.g. the error-reporting overlay, whose own z band sits ABOVE
|
|
298
|
+
// the overlay root and would paint an opaque backdrop over the
|
|
299
|
+
// teleported stack, silencing it visually).
|
|
300
|
+
const band = (
|
|
287
301
|
<div class="hk-toast-container" style={containerStyle.value}>
|
|
288
302
|
<TransitionGroup
|
|
289
303
|
ref={hostRef}
|
|
@@ -310,7 +324,8 @@ export default defineComponent({
|
|
|
310
324
|
))}
|
|
311
325
|
</TransitionGroup>
|
|
312
326
|
</div>
|
|
313
|
-
|
|
314
|
-
|
|
327
|
+
);
|
|
328
|
+
return props.teleport === false ? band : <Teleport to={ensureOverlayRoot()}>{band}</Teleport>;
|
|
329
|
+
};
|
|
315
330
|
},
|
|
316
331
|
});
|