@celestia-island/hikari 0.55.375 → 0.55.380
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 -2
- package/src/components/HkEmergencyAlert.layering.contract.test.ts +1 -1
- package/src/components/HkEmergencyAlert.scss +12 -9
- package/src/components/HkEmergencySnoozeTray.contract.test.ts +32 -0
- package/src/components/HkEmergencySnoozeTray.scss +37 -0
- package/src/components/HkEmergencySnoozeTray.test.tsx +125 -0
- package/src/components/HkEmergencySnoozeTray.tsx +105 -0
- package/src/components/HkMermaidDiagram.test.tsx +2 -2
- package/src/components/HkPersistentToast.scss +13 -0
- package/src/components/HkPersistentToast.tsx +14 -2
- package/src/components/__tests__/hkMermaidLayout.test.ts +11 -11
- package/src/components/__tests__/hkMermaidParse.test.ts +72 -338
- package/src/composables/useHighlight.ts +49 -200
- package/src/composables/wasmHighlight.ts +2 -2
- package/src/i18n/locales/ar/components.json +2 -1
- package/src/i18n/locales/de/components.json +2 -1
- package/src/i18n/locales/en/components.json +2 -1
- package/src/i18n/locales/es/components.json +2 -1
- package/src/i18n/locales/fr/components.json +2 -1
- package/src/i18n/locales/ja/components.json +2 -1
- package/src/i18n/locales/ko/components.json +2 -1
- package/src/i18n/locales/pt/components.json +2 -1
- package/src/i18n/locales/ru/components.json +2 -1
- package/src/i18n/locales/zh-Hans/components.json +2 -1
- package/src/i18n/locales/zh-Hant/components.json +2 -1
- package/src/index.ts +3 -1
- package/src/mermaid/__golden.test.ts +31 -0
- package/src/mermaid/__snapshots__/__golden.test.ts.snap +232 -0
- package/src/mermaid/index.ts +4 -3
- package/src/mermaid/wasmEngine.ts +15 -10
- package/src/runtime/index.ts +1 -1
- package/src/runtime/useEmergencyAlert.test.ts +21 -0
- package/src/runtime/useEmergencyAlert.ts +14 -0
- package/src/scene3d/__golden.test.ts +34 -0
- package/src/scene3d/__snapshots__/__golden.test.ts.snap +12 -0
- package/src/scene3d/holographicFleetScene.test.ts +1 -1
- package/src/scene3d/holographicFleetSpec.ts +2 -121
- package/src/wasm/highlight/hikari_wasm_highlight.js +1 -1
- package/src/wasm/mermaid/hikari_wasm_mermaid.js +1 -1
- package/src/composables/highlightLanguages.ts +0 -109
- package/src/composables/languageForPath.test.ts +0 -86
- package/src/mermaid/__wasm_ts_equivalence.test.ts +0 -87
- package/src/mermaid/parse.ts +0 -51
- package/src/mermaid/parseClass.ts +0 -179
- package/src/mermaid/parseGantt.ts +0 -94
- package/src/mermaid/parseGraph.ts +0 -312
- package/src/mermaid/parsePie.ts +0 -67
- package/src/mermaid/parseQuadrant.ts +0 -110
- package/src/mermaid/parseSequence.ts +0 -77
- package/src/scene3d/holographicFleetSpec.test.ts +0 -474
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celestia-island/hikari",
|
|
3
|
-
"version": "0.55.
|
|
3
|
+
"version": "0.55.380",
|
|
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",
|
|
@@ -82,7 +82,6 @@
|
|
|
82
82
|
"@xterm/addon-image": "^0.10.0-beta.301",
|
|
83
83
|
"@xterm/xterm": "^6.1.0-beta.304",
|
|
84
84
|
"dompurify": "^3",
|
|
85
|
-
"highlight.js": "^11",
|
|
86
85
|
"lucide-vue-next": "^1",
|
|
87
86
|
"marked": "^18"
|
|
88
87
|
},
|
|
@@ -123,7 +123,7 @@ describe("emergency alert layering contract", () => {
|
|
|
123
123
|
expect(root).not.toContain("var(--color-background");
|
|
124
124
|
// Dark-ink DIRECTION, not a literal: every RGB channel must be
|
|
125
125
|
// dark (<60) and the veil substantial (alpha >= 40%). A future
|
|
126
|
-
// retune (55%→52%,
|
|
126
|
+
// retune (55%→52%, 12 14 20 etc.) passes; a light recolor
|
|
127
127
|
// (200 210 220) fails on semantics, not on mismatched text.
|
|
128
128
|
// EXACTLY ONE declaration per property, counted by NAME in any
|
|
129
129
|
// value form: a later duplicate wins the cascade silently, so a
|
|
@@ -23,13 +23,16 @@
|
|
|
23
23
|
--hk-emergency-line-soft: color-mix(in srgb, var(--hk-emergency-line) 55%, transparent);
|
|
24
24
|
--hk-emergency-edge-glow: color-mix(in srgb, var(--hk-emergency-line) 22%, transparent);
|
|
25
25
|
--hk-emergency-wash: color-mix(in srgb, var(--hk-emergency-line) 14%, transparent);
|
|
26
|
-
--hk-emergency-band-bg: rgb(var(--color-surface,
|
|
26
|
+
--hk-emergency-band-bg: rgb(var(--color-surface, 255 255 255) / 96%);
|
|
27
27
|
// The scrim is DARK INK ON PURPOSE — theme-independent. Pointing it
|
|
28
28
|
// at --color-background (the 0.55.370 default) makes it a WHITE veil
|
|
29
29
|
// in light themes: the page never darkens, and the takeover reads as
|
|
30
30
|
// a pastel banner on plain paper (2026-11-14 field report). A scrim
|
|
31
|
-
// darkens what is behind it; that is mode-independent.
|
|
32
|
-
|
|
31
|
+
// darkens what is behind it; that is mode-independent. The ink is
|
|
32
|
+
// the house pure black (HkModal / HkDrawer scrims = rgba(0,0,0,α)
|
|
33
|
+
// behind their own --hk-*-overlay-bg vars); this takeover dims at
|
|
34
|
+
// 55% versus their 45% — a takeover sits above work, not beside it.
|
|
35
|
+
--hk-emergency-scrim: rgb(0 0 0 / 55%);
|
|
33
36
|
|
|
34
37
|
position: fixed;
|
|
35
38
|
// Chrome-band leg: in native hosts the window titlebar owns the top
|
|
@@ -95,9 +98,9 @@
|
|
|
95
98
|
// a deep soft shadow lifts it off the scrim so the takeover reads
|
|
96
99
|
// as layered, not pasted (0.55.370 field note: without this the
|
|
97
100
|
// light band floated flat on the light page).
|
|
98
|
-
box-shadow: 0 24px 72px rgb(
|
|
101
|
+
box-shadow: 0 24px 72px rgb(0 0 0 / 45%);
|
|
99
102
|
text-align: center;
|
|
100
|
-
color: rgb(var(--color-text,
|
|
103
|
+
color: rgb(var(--color-text, 30 32 36));
|
|
101
104
|
font-family: var(--font-sans, system-ui, sans-serif);
|
|
102
105
|
|
|
103
106
|
// FUI double line: a second, fainter signal line hugging each edge
|
|
@@ -183,7 +186,7 @@
|
|
|
183
186
|
font-weight: 700;
|
|
184
187
|
line-height: 1.2;
|
|
185
188
|
letter-spacing: 0.01em;
|
|
186
|
-
color: rgb(var(--color-text,
|
|
189
|
+
color: rgb(var(--color-text, 30 32 36));
|
|
187
190
|
}
|
|
188
191
|
|
|
189
192
|
.hk-emergency-desc {
|
|
@@ -191,7 +194,7 @@
|
|
|
191
194
|
max-width: 56ch;
|
|
192
195
|
font-size: clamp(1rem, 2vw, 1.125rem);
|
|
193
196
|
line-height: 1.6;
|
|
194
|
-
color: rgb(var(--color-muted,
|
|
197
|
+
color: rgb(var(--color-muted, 118 122 128));
|
|
195
198
|
white-space: pre-line;
|
|
196
199
|
}
|
|
197
200
|
|
|
@@ -200,7 +203,7 @@
|
|
|
200
203
|
font-family: var(--font-mono, ui-monospace, monospace);
|
|
201
204
|
font-size: 0.8125rem;
|
|
202
205
|
letter-spacing: 0.08em;
|
|
203
|
-
color: rgb(var(--color-muted,
|
|
206
|
+
color: rgb(var(--color-muted, 118 122 128));
|
|
204
207
|
}
|
|
205
208
|
|
|
206
209
|
.hk-emergency-actions {
|
|
@@ -224,7 +227,7 @@
|
|
|
224
227
|
.is-warning .hk-emergency-actions .hk-btn-primary {
|
|
225
228
|
background: var(--hk-emergency-wash);
|
|
226
229
|
border-color: var(--hk-emergency-line);
|
|
227
|
-
color: rgb(var(--color-text,
|
|
230
|
+
color: rgb(var(--color-text, 30 32 36));
|
|
228
231
|
}
|
|
229
232
|
|
|
230
233
|
.is-warning .hk-emergency-actions .hk-btn-primary:hover:not(:disabled):not(:focus-visible) {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Source contract: the snooze tray is COMPOSITION, not a bespoke chip.
|
|
3
|
+
* Its chips are HkPersistentToast (severity tone, label, detail card)
|
|
4
|
+
* inside HkPersistentToastGroup (the "+N" counter) — the same members
|
|
5
|
+
* every chrome bar uses. A hand-rolled chip markup here would fork the
|
|
6
|
+
* chrome-bar chip language (2026-11-14 user direction: upstream
|
|
7
|
+
* components only, glue is the tray's whole job).
|
|
8
|
+
*/
|
|
9
|
+
import { readFileSync } from "node:fs";
|
|
10
|
+
import { dirname, join } from "node:path";
|
|
11
|
+
import { fileURLToPath } from "node:url";
|
|
12
|
+
|
|
13
|
+
import { describe, expect, it } from "vitest";
|
|
14
|
+
|
|
15
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
16
|
+
const tsx = readFileSync(join(here, "HkEmergencySnoozeTray.tsx"), "utf-8")
|
|
17
|
+
.replace(/^[ \t]*\/\/.*$/gm, "");
|
|
18
|
+
|
|
19
|
+
describe("emergency snooze tray composition contract", () => {
|
|
20
|
+
it("composes upstream chip members instead of hand-rolling", () => {
|
|
21
|
+
expect(tsx).toMatch(/import HkPersistentToast from ".\/HkPersistentToast";/);
|
|
22
|
+
expect(tsx).toMatch(/import HkPersistentToastGroup from ".\/HkPersistentToastGroup";/);
|
|
23
|
+
expect(tsx).toMatch(/<HkPersistentToastGroup maxVisible={/);
|
|
24
|
+
expect(tsx).toMatch(/<HkPersistentToast\n/);
|
|
25
|
+
// No bespoke chip surface: no element carrying the chip's own class.
|
|
26
|
+
expect(tsx).not.toMatch(/class=["'][^"']*hk-persistent-toast(?!-group)/);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("restore goes through the context, not ad-hoc state", () => {
|
|
30
|
+
expect(tsx).toMatch(/unsnoozeEmergencyAlert\(item\.id\)/);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// HEmergencySnoozeTray — in-flow chrome-bar composition over
|
|
2
|
+
// HkPersistentToast(Group); the only bespoke ink here is the detail
|
|
3
|
+
// card's content block (the chips themselves are upstream members).
|
|
4
|
+
// Severity coloring rides the chips' own tone classes.
|
|
5
|
+
|
|
6
|
+
.hk-emergency-snooze-tray {
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
min-width: 0;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.hk-emergency-snooze-card {
|
|
13
|
+
display: grid;
|
|
14
|
+
gap: var(--space-8, 0.5rem);
|
|
15
|
+
justify-items: start;
|
|
16
|
+
max-width: 320px;
|
|
17
|
+
padding: var(--space-12, 0.75rem);
|
|
18
|
+
|
|
19
|
+
&__icon {
|
|
20
|
+
color: var(--hi-color-warning, rgb(var(--color-warning, 222 168 62)));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&.is-danger &__icon {
|
|
24
|
+
color: var(--hi-color-error, rgb(var(--color-error, 226 84 84)));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&__title {
|
|
28
|
+
margin: 0;
|
|
29
|
+
font-weight: 600;
|
|
30
|
+
color: rgb(var(--color-text, 30 32 36));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&__desc {
|
|
34
|
+
margin: 0;
|
|
35
|
+
color: rgb(var(--color-muted, 118 122 128));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
2
|
+
import { createPinia, setActivePinia } from "pinia";
|
|
3
|
+
import { createApp, h, nextTick } from "vue";
|
|
4
|
+
|
|
5
|
+
import HkEmergencySnoozeTray from "./HkEmergencySnoozeTray";
|
|
6
|
+
import {
|
|
7
|
+
raiseEmergencyAlert,
|
|
8
|
+
resetEmergencyAlerts,
|
|
9
|
+
snoozeEmergencyAlert,
|
|
10
|
+
useEmergencyAlert,
|
|
11
|
+
} from "../runtime/useEmergencyAlert";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* HEmergencySnoozeTray contract:
|
|
15
|
+
* - no snoozed alerts → renders nothing
|
|
16
|
+
* - snoozed alerts render HkPersistentToast chips (severity tone,
|
|
17
|
+
* label = title), iconOnly collapses to the icon (label span gone,
|
|
18
|
+
* aria-label kept)
|
|
19
|
+
* - the restore button in the detail card unsnoozes (the alert
|
|
20
|
+
* returns to the band; the chip leaves the tray)
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
const mounts: Array<{ app: ReturnType<typeof createApp>; container: HTMLElement }> = [];
|
|
24
|
+
|
|
25
|
+
function mountHost(props: { iconOnly?: boolean; maxVisible?: number } = {}) {
|
|
26
|
+
const container = document.createElement("div");
|
|
27
|
+
document.body.appendChild(container);
|
|
28
|
+
const app = createApp({
|
|
29
|
+
render: () =>
|
|
30
|
+
h(HkEmergencySnoozeTray, {
|
|
31
|
+
iconOnly: props.iconOnly ?? false,
|
|
32
|
+
maxVisible: props.maxVisible ?? 0,
|
|
33
|
+
}),
|
|
34
|
+
});
|
|
35
|
+
mounts.push({ app, container });
|
|
36
|
+
app.mount(container);
|
|
37
|
+
return container;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function settle() {
|
|
41
|
+
await nextTick();
|
|
42
|
+
await new Promise((r) => setTimeout(r, 30));
|
|
43
|
+
await nextTick();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function tray(): HTMLElement | null {
|
|
47
|
+
return document.querySelector<HTMLElement>(".hk-emergency-snooze-tray");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function chips(): HTMLElement[] {
|
|
51
|
+
return Array.from(document.querySelectorAll<HTMLElement>(".hk-persistent-toast"));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
beforeEach(() => {
|
|
55
|
+
setActivePinia(createPinia());
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
afterEach(() => {
|
|
59
|
+
for (const { app, container } of mounts) {
|
|
60
|
+
app.unmount();
|
|
61
|
+
container.remove();
|
|
62
|
+
}
|
|
63
|
+
mounts.length = 0;
|
|
64
|
+
resetEmergencyAlerts();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
describe("HEmergencySnoozeTray", () => {
|
|
68
|
+
it("renders nothing while nothing is snoozed", async () => {
|
|
69
|
+
raiseEmergencyAlert({ id: "a", severity: "warning", title: "a", dismissible: true });
|
|
70
|
+
mountHost();
|
|
71
|
+
await settle();
|
|
72
|
+
expect(tray()).toBeNull();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("snoozed alerts render as severity-toned chips with the title label", async () => {
|
|
76
|
+
mountHost();
|
|
77
|
+
raiseEmergencyAlert({ id: "q", severity: "warning", title: "可用额度已用完", dismissible: true });
|
|
78
|
+
snoozeEmergencyAlert("q");
|
|
79
|
+
await settle();
|
|
80
|
+
const { alerts } = useEmergencyAlert();
|
|
81
|
+
expect(tray()).not.toBeNull();
|
|
82
|
+
expect(chips()).toHaveLength(1);
|
|
83
|
+
expect(chips()[0].classList.contains("hk-persistent-toast--warning")).toBe(true);
|
|
84
|
+
expect(chips()[0].textContent).toContain("可用额度已用完");
|
|
85
|
+
expect(alerts).toHaveLength(1); // snoozed, not cleared
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("danger alerts map to the error tone chip (R3 M3b)", async () => {
|
|
89
|
+
mountHost();
|
|
90
|
+
raiseEmergencyAlert({ id: "d", severity: "danger", title: "t", dismissible: true });
|
|
91
|
+
snoozeEmergencyAlert("d");
|
|
92
|
+
await settle();
|
|
93
|
+
expect(chips()[0].classList.contains("hk-persistent-toast--error")).toBe(true);
|
|
94
|
+
resetEmergencyAlerts();
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("iconOnly collapses chips to the icon (label span dropped, aria-label kept)", async () => {
|
|
98
|
+
mountHost({ iconOnly: true });
|
|
99
|
+
raiseEmergencyAlert({ id: "q", severity: "warning", title: "可用额度已用完", dismissible: true });
|
|
100
|
+
snoozeEmergencyAlert("q");
|
|
101
|
+
await settle();
|
|
102
|
+
const chip = chips()[0];
|
|
103
|
+
expect(chip.classList.contains("hk-persistent-toast--icon-only")).toBe(true);
|
|
104
|
+
expect(chip.querySelector(".hk-persistent-toast__label")).toBeNull();
|
|
105
|
+
expect(chip.getAttribute("aria-label")).toBe("可用额度已用完");
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it("the restore button unsnoozes: the chip leaves the tray", async () => {
|
|
109
|
+
mountHost();
|
|
110
|
+
raiseEmergencyAlert({ id: "q", severity: "warning", title: "t", dismissible: true });
|
|
111
|
+
snoozeEmergencyAlert("q");
|
|
112
|
+
await settle();
|
|
113
|
+
// The detail card is lazy: clicking the chip pins it open, which
|
|
114
|
+
// is how a keyboard/touch user reaches the restore button.
|
|
115
|
+
chips()[0].click();
|
|
116
|
+
await settle();
|
|
117
|
+
const restore = document.querySelector<HTMLButtonElement>(".hk-emergency-snooze-card button");
|
|
118
|
+
expect(restore).not.toBeNull();
|
|
119
|
+
restore!.click();
|
|
120
|
+
await settle();
|
|
121
|
+
const { alerts } = useEmergencyAlert();
|
|
122
|
+
expect(alerts[0]?.snoozed).toBe(false);
|
|
123
|
+
expect(chips()).toHaveLength(0);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HEmergencySnoozeTray — the persistent home for SNOOZED emergency
|
|
3
|
+
* alerts ("hide for now" must not make an alert vanish: it minimizes
|
|
4
|
+
* to a persistent chip in the chrome bar's trailing corner — the same
|
|
5
|
+
* strip the desktop titlebar and the browser header share; the HOST
|
|
6
|
+
* mounts this component there, next to the window controls).
|
|
7
|
+
*
|
|
8
|
+
* Pure composition over upstream members — the chips ARE
|
|
9
|
+
* HkPersistentToast (severity tone icon + label + hover/pin detail
|
|
10
|
+
* card), the row is HkPersistentToastGroup (first N visible, the rest
|
|
11
|
+
* collapse into the "+N" counter — the mobile single-icon + count
|
|
12
|
+
* shape falls out of maxVisible=1 + the chips' iconOnly mode). No
|
|
13
|
+
* bespoke chip markup here.
|
|
14
|
+
*
|
|
15
|
+
* Chip contract:
|
|
16
|
+
* - tone = the alert's severity (warning amber / danger red);
|
|
17
|
+
* - label = the alert title; the detail card carries the description
|
|
18
|
+
* and a "show again" button — clicking it UNSNOOZES the alert (the
|
|
19
|
+
* band returns; the episode stays live until the condition clears).
|
|
20
|
+
* - Narrow chrome bars (host passes `iconOnly`, e.g. via
|
|
21
|
+
* useBreakpoint().isMobile) collapse each chip to its tone icon;
|
|
22
|
+
* the group counter takes over from there.
|
|
23
|
+
*
|
|
24
|
+
* Mount once in the chrome bar; renders NOTHING while no alert is
|
|
25
|
+
* snoozed.
|
|
26
|
+
*/
|
|
27
|
+
import { TriangleAlert } from "lucide-vue-next";
|
|
28
|
+
import { computed, defineComponent } from "vue";
|
|
29
|
+
|
|
30
|
+
import { useI18n } from "../i18n/context";
|
|
31
|
+
import {
|
|
32
|
+
unsnoozeEmergencyAlert,
|
|
33
|
+
useEmergencyAlert,
|
|
34
|
+
type EmergencyAlertItem,
|
|
35
|
+
} from "../runtime/useEmergencyAlert";
|
|
36
|
+
import HkButton from "./HkButton";
|
|
37
|
+
import HkPersistentToast from "./HkPersistentToast";
|
|
38
|
+
import HkPersistentToastGroup from "./HkPersistentToastGroup";
|
|
39
|
+
|
|
40
|
+
export default defineComponent({
|
|
41
|
+
name: "HEmergencySnoozeTray",
|
|
42
|
+
props: {
|
|
43
|
+
/** Icon-only chips (narrow chrome bars). The host decides via its
|
|
44
|
+
* own breakpoint read (useBreakpoint().isMobile is the expected
|
|
45
|
+
* driver). */
|
|
46
|
+
iconOnly: { type: Boolean, default: false },
|
|
47
|
+
/** Visible chips before the "+N" counter takes over (1 on mobile,
|
|
48
|
+
* 3 otherwise, when the host leaves it to the tray). */
|
|
49
|
+
maxVisible: { type: Number, default: 0 },
|
|
50
|
+
},
|
|
51
|
+
setup(props) {
|
|
52
|
+
const { alerts } = useEmergencyAlert();
|
|
53
|
+
const { t } = useI18n();
|
|
54
|
+
|
|
55
|
+
const snoozed = computed(() => alerts.filter((a) => a.snoozed));
|
|
56
|
+
const resolvedMaxVisible = computed(() =>
|
|
57
|
+
props.maxVisible > 0 ? props.maxVisible : props.iconOnly ? 1 : 3,
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
function renderChip(item: EmergencyAlertItem, iconOnly: boolean) {
|
|
61
|
+
return (
|
|
62
|
+
<HkPersistentToast
|
|
63
|
+
key={item.id}
|
|
64
|
+
tone={item.severity === "danger" ? "error" : "warning"}
|
|
65
|
+
label={item.title}
|
|
66
|
+
iconOnly={iconOnly}
|
|
67
|
+
>
|
|
68
|
+
{{
|
|
69
|
+
detail: () => (
|
|
70
|
+
<div class={["hk-emergency-snooze-card", `is-${item.severity}`]}>
|
|
71
|
+
<TriangleAlert
|
|
72
|
+
size={14}
|
|
73
|
+
class="hk-emergency-snooze-card__icon"
|
|
74
|
+
aria-hidden="true"
|
|
75
|
+
/>
|
|
76
|
+
<p class="hk-emergency-snooze-card__title">{item.title}</p>
|
|
77
|
+
{item.description && (
|
|
78
|
+
<p class="hk-emergency-snooze-card__desc">{item.description}</p>
|
|
79
|
+
)}
|
|
80
|
+
<HkButton
|
|
81
|
+
size="sm"
|
|
82
|
+
variant="primary"
|
|
83
|
+
onClick={() => unsnoozeEmergencyAlert(item.id)}
|
|
84
|
+
>
|
|
85
|
+
{t("hikari::emergencyAlert.restore", "Show again")}
|
|
86
|
+
</HkButton>
|
|
87
|
+
</div>
|
|
88
|
+
),
|
|
89
|
+
}}
|
|
90
|
+
</HkPersistentToast>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return () => {
|
|
95
|
+
if (snoozed.value.length === 0) return null;
|
|
96
|
+
return (
|
|
97
|
+
<span class="hk-emergency-snooze-tray">
|
|
98
|
+
<HkPersistentToastGroup maxVisible={resolvedMaxVisible.value}>
|
|
99
|
+
{snoozed.value.map((item) => renderChip(item, props.iconOnly))}
|
|
100
|
+
</HkPersistentToastGroup>
|
|
101
|
+
</span>
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
},
|
|
105
|
+
});
|
|
@@ -3,7 +3,7 @@ import { createApp, h, nextTick } from "vue";
|
|
|
3
3
|
|
|
4
4
|
import HkMermaidDiagram from "./HkMermaidDiagram";
|
|
5
5
|
import { buildBoardModel, heuristicTextWidth } from "../mermaid/layout";
|
|
6
|
-
import {
|
|
6
|
+
import { wasmMermaidEngine } from "../mermaid/wasmEngine";
|
|
7
7
|
import { setMermaidEngineForTests } from "../mermaid/engine";
|
|
8
8
|
import { mermaidParser } from "../mermaid";
|
|
9
9
|
|
|
@@ -258,7 +258,7 @@ describe("round-2 fix pins", () => {
|
|
|
258
258
|
// `after t1 t0 t1` ⇒ deps [t1, t0] (space-split + dedupe), and t2's
|
|
259
259
|
// bar starts past BOTH dependencies' ends.
|
|
260
260
|
const model = buildBoardModel(
|
|
261
|
-
|
|
261
|
+
wasmMermaidEngine.parse("gantt\nsection S\none : t1, 2d\nother : t0, 1d\ntwo : t2, after t1 t0 t1, 1d") as never,
|
|
262
262
|
heuristicTextWidth,
|
|
263
263
|
);
|
|
264
264
|
const bar = (name: string) => {
|
|
@@ -132,3 +132,16 @@ button.hk-persistent-toast {
|
|
|
132
132
|
animation: none;
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
|
+
|
|
136
|
+
// Icon-only mode (HkPersistentToast iconOnly prop): the chip collapses
|
|
137
|
+
// to its tone icon — narrow chrome bars (mobile headers) keep a
|
|
138
|
+
// clickable, severity-colored surface without the label text. The
|
|
139
|
+
// label rides along as aria-label on the button, so the accessible
|
|
140
|
+
// name survives the collapse.
|
|
141
|
+
.hk-persistent-toast--icon-only {
|
|
142
|
+
padding: 2px var(--space-6, 0.375rem);
|
|
143
|
+
|
|
144
|
+
.hk-persistent-toast__label {
|
|
145
|
+
display: none;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -73,6 +73,13 @@ export default defineComponent({
|
|
|
73
73
|
dismissible: { type: Boolean, default: false },
|
|
74
74
|
openDelay: { type: Number, default: 150 },
|
|
75
75
|
closeGrace: { type: Number, default: 250 },
|
|
76
|
+
/** Icon-only mode (narrow chrome bars, e.g. mobile headers): the
|
|
77
|
+
* label span is dropped and the chip collapses to the tone icon —
|
|
78
|
+
* still a button with the full detail-slot interactivity, announced
|
|
79
|
+
* via aria-label from the label text. The HOST decides when to
|
|
80
|
+
* collapse (breakpoint/viewport is chrome-bar context, not the
|
|
81
|
+
* chip's own concern). */
|
|
82
|
+
iconOnly: { type: Boolean, default: false },
|
|
76
83
|
},
|
|
77
84
|
emits: {
|
|
78
85
|
dismiss: () => true,
|
|
@@ -232,7 +239,12 @@ export default defineComponent({
|
|
|
232
239
|
<span ref={wrapRef} class="hk-persistent-toast-wrap" role="status" aria-live="polite">
|
|
233
240
|
<Tag
|
|
234
241
|
type={interactive.value ? "button" : undefined}
|
|
235
|
-
class={[
|
|
242
|
+
class={[
|
|
243
|
+
"hk-persistent-toast",
|
|
244
|
+
`hk-persistent-toast--${props.tone}`,
|
|
245
|
+
props.iconOnly && "hk-persistent-toast--icon-only",
|
|
246
|
+
]}
|
|
247
|
+
aria-label={props.iconOnly ? props.label : undefined}
|
|
236
248
|
aria-expanded={interactive.value ? open.value : undefined}
|
|
237
249
|
aria-haspopup={interactive.value ? "true" : undefined}
|
|
238
250
|
aria-controls={open.value ? popupId : undefined}
|
|
@@ -258,7 +270,7 @@ export default defineComponent({
|
|
|
258
270
|
) : (
|
|
259
271
|
<Info size={12} class="hk-persistent-toast__icon" aria-hidden="true" />
|
|
260
272
|
)}
|
|
261
|
-
<span class="hk-persistent-toast__label">{props.label}</span>
|
|
273
|
+
{!props.iconOnly && <span class="hk-persistent-toast__label">{props.label}</span>}
|
|
262
274
|
</Tag>
|
|
263
275
|
{props.dismissible && (
|
|
264
276
|
<HIconButton
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
2
|
|
|
3
3
|
import { buildBoardModel, heuristicTextWidth, layoutGraph } from "../../mermaid/layout";
|
|
4
|
-
import {
|
|
4
|
+
import { wasmMermaidEngine } from "../../mermaid/wasmEngine";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Layout invariants — the geometry module is pure and deterministic, so
|
|
@@ -59,7 +59,7 @@ describe("layoutGraph", () => {
|
|
|
59
59
|
|
|
60
60
|
describe("buildBoardModel", () => {
|
|
61
61
|
it("flowchart: nodes and labeled edges carry through, arrows set", () => {
|
|
62
|
-
const model = buildBoardModel(
|
|
62
|
+
const model = buildBoardModel(wasmMermaidEngine.parse("graph TD\nA[Start] -->|go| B{Q}") as never, measure);
|
|
63
63
|
expect(model.nodes.map((n) => n.id)).toEqual(["n:A", "n:B"]);
|
|
64
64
|
expect(model.edges).toEqual([
|
|
65
65
|
{ id: "e:0", from: "n:A", to: "n:B", style: "bezier", dashed: false, arrow: "solid", label: "go" },
|
|
@@ -69,7 +69,7 @@ describe("buildBoardModel", () => {
|
|
|
69
69
|
|
|
70
70
|
it("sequence: participant headers, lifelines, message junctions and self-loop vias", () => {
|
|
71
71
|
const model = buildBoardModel(
|
|
72
|
-
|
|
72
|
+
wasmMermaidEngine.parse("sequenceDiagram\nparticipant A\nA ->> B: hi\nB -->> A: yo\nA ->> A: note") as never,
|
|
73
73
|
measure,
|
|
74
74
|
);
|
|
75
75
|
const ids = new Set(model.nodes.map((n) => n.id));
|
|
@@ -89,7 +89,7 @@ describe("buildBoardModel", () => {
|
|
|
89
89
|
|
|
90
90
|
it("class: cards keep member-driven heights and inheritance edges arrow", () => {
|
|
91
91
|
const model = buildBoardModel(
|
|
92
|
-
|
|
92
|
+
wasmMermaidEngine.parse("classDiagram\nclass A {\n+x: i32\n}\nclass B {\n}\nA <|-- B") as never,
|
|
93
93
|
measure,
|
|
94
94
|
);
|
|
95
95
|
const a = model.nodes.find((n) => n.id === "n:A")!;
|
|
@@ -103,7 +103,7 @@ describe("buildBoardModel", () => {
|
|
|
103
103
|
|
|
104
104
|
it("gantt: sequential tasks advance, deps push starts, axis exists", () => {
|
|
105
105
|
const model = buildBoardModel(
|
|
106
|
-
|
|
106
|
+
wasmMermaidEngine.parse("gantt\nsection S\none : t1, 2d\ntwo : t2, 3d\nthree : t3, after t1, 1d") as never,
|
|
107
107
|
measure,
|
|
108
108
|
);
|
|
109
109
|
const bar = (name: string): { x: number; w: number } => {
|
|
@@ -120,10 +120,10 @@ describe("buildBoardModel", () => {
|
|
|
120
120
|
});
|
|
121
121
|
|
|
122
122
|
it("pie and quadrant render as a single painter card", () => {
|
|
123
|
-
const pie = buildBoardModel(
|
|
123
|
+
const pie = buildBoardModel(wasmMermaidEngine.parse('pie\n"a": 1\n"b": 2') as never, measure);
|
|
124
124
|
expect(pie.nodes).toHaveLength(1);
|
|
125
125
|
expect(pie.nodes[0].kind).toBe("pie");
|
|
126
|
-
const quad = buildBoardModel(
|
|
126
|
+
const quad = buildBoardModel(wasmMermaidEngine.parse("quadrantChart\np: [0.5, 0.5]") as never, measure);
|
|
127
127
|
expect(quad.nodes).toHaveLength(1);
|
|
128
128
|
expect(quad.nodes[0].kind).toBe("quadrant");
|
|
129
129
|
});
|
|
@@ -148,7 +148,7 @@ describe("layout pin tests (mutation survivors)", () => {
|
|
|
148
148
|
|
|
149
149
|
it("sequence messages stack one row step apart", () => {
|
|
150
150
|
const model = buildBoardModel(
|
|
151
|
-
|
|
151
|
+
wasmMermaidEngine.parse("sequenceDiagram\nA ->> B: one\nA ->> B: two\nA ->> B: three") as never,
|
|
152
152
|
measure,
|
|
153
153
|
);
|
|
154
154
|
const rows = model.nodes
|
|
@@ -162,7 +162,7 @@ describe("layout pin tests (mutation survivors)", () => {
|
|
|
162
162
|
|
|
163
163
|
it("a gantt dep ACROSS sections pushes the start past the section cursor", () => {
|
|
164
164
|
const model = buildBoardModel(
|
|
165
|
-
|
|
165
|
+
wasmMermaidEngine.parse([
|
|
166
166
|
"gantt",
|
|
167
167
|
"section One",
|
|
168
168
|
"long : t1, 5d",
|
|
@@ -185,9 +185,9 @@ describe("layout pin tests (mutation survivors)", () => {
|
|
|
185
185
|
});
|
|
186
186
|
|
|
187
187
|
it("suggestHeight floors at 200px for tiny content", () => {
|
|
188
|
-
const model = buildBoardModel(
|
|
188
|
+
const model = buildBoardModel(wasmMermaidEngine.parse("sequenceDiagram\nA ->> B: x") as never, measure);
|
|
189
189
|
expect(model.suggestedHeight).toBeGreaterThanOrEqual(200);
|
|
190
|
-
const bare = buildBoardModel(
|
|
190
|
+
const bare = buildBoardModel(wasmMermaidEngine.parse("sequenceDiagram\nparticipant Only") as never, measure);
|
|
191
191
|
expect(bare.suggestedHeight).toBe(200);
|
|
192
192
|
});
|
|
193
193
|
});
|