@celestia-island/hikari 0.55.437 → 0.55.440
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/HkAdaptiveTabs.test.tsx +1 -1
- package/src/components/HkAdminHeader.test.tsx +76 -1
- package/src/components/HkAdminHeader.tsx +73 -13
- package/src/components/HkAffixPicker.scss +13 -0
- package/src/components/HkAffixPicker.test.tsx +79 -1
- package/src/components/HkAffixPicker.tsx +37 -0
- package/src/components/HkBoard3D.tsx +3 -3
- package/src/components/HkDeleteFact.scss +25 -0
- package/src/components/HkDeleteFact.tsx +28 -0
- package/src/components/HkDeleteGateWindow.scss +9 -0
- package/src/components/HkDeleteGateWindow.test.ts +133 -0
- package/src/components/HkDeleteGateWindow.tsx +89 -0
- package/src/components/HkEditableTable.test.tsx +15 -9
- package/src/components/HkEmergencyAlert.layering.contract.test.ts +1 -1
- package/src/components/HkFaceShell.slots.test.ts +28 -1
- package/src/components/HkJsonTree.tsx +1 -1
- package/src/components/HkKanban.tsx +1 -1
- package/src/components/HkLoadMore.tsx +1 -1
- package/src/components/HkLocalePicker.tsx +1 -1
- package/src/components/HkLocalePickerPopup.tsx +1 -1
- package/src/components/HkMarkdownRenderer.mermaid.test.tsx +6 -6
- package/src/components/HkMenu.tsx +1 -1
- package/src/components/HkMermaidDiagram.test.tsx +4 -6
- package/src/components/HkNavSidebar.tsx +1 -1
- package/src/components/HkNodeCanvas.tsx +6 -6
- package/src/components/HkRangeRibbon.test.tsx +2 -2
- package/src/components/HkScrollContainer.dock.test.tsx +6 -6
- package/src/components/HkScrollContainer.dockRide.test.tsx +7 -7
- package/src/components/HkSerpentineUnlock.scss +11 -2
- package/src/components/HkSerpentineUnlock.tsx +56 -28
- package/src/components/HkTagDotRow.tsx +1 -1
- package/src/components/HkTerminal.test.tsx +1 -1
- package/src/components/HkTimeZonePicker.tsx +1 -1
- package/src/components/HkWaterfall.tsx +1 -1
- package/src/components/HkWindowControls.test.tsx +2 -2
- package/src/components/__tests__/hkMarkdownLinks.test.ts +2 -2
- package/src/components/serpentineGeometry.test.ts +21 -0
- package/src/components/serpentineGeometry.ts +41 -7
- package/src/composables/useHighlight.ts +3 -3
- package/src/index.ts +3 -1
- package/src/plugins/boot-recovery.details.test.ts +4 -2
- package/src/plugins/boot-recovery.error-context.test.ts +14 -16
- package/src/plugins/boot-recovery.external.test.ts +8 -7
- package/src/runtime/hyperlink.ts +1 -1
- package/src/runtime/popupBounds.test.ts +2 -2
- package/src/runtime/tooltipBridge.test.ts +1 -1
- package/src/scene3d/modelLayer.ts +2 -2
- package/src/utils/currency.test.ts +1 -1
- package/src/utils/currency.ts +1 -1
package/package.json
CHANGED
|
@@ -53,7 +53,11 @@ vi.mock("./HkMenu", async () => {
|
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
flatten(props.items);
|
|
56
|
-
return h("div", { class: "menu-stub" }, [
|
|
56
|
+
return h("div", { class: "menu-stub" }, [
|
|
57
|
+
...(slots.header?.() ?? []),
|
|
58
|
+
...rows,
|
|
59
|
+
...(slots.footer?.() ?? []),
|
|
60
|
+
]);
|
|
57
61
|
};
|
|
58
62
|
},
|
|
59
63
|
});
|
|
@@ -356,3 +360,74 @@ describe("HkAdminHeader chrome face drag region (2026-11-12)", () => {
|
|
|
356
360
|
expect(c.querySelector("header")!.hasAttribute("data-tauri-drag-region")).toBe(false);
|
|
357
361
|
});
|
|
358
362
|
});
|
|
363
|
+
|
|
364
|
+
describe("HkAdminHeader host slots (L39 ruling-a revival)", () => {
|
|
365
|
+
const LOCALES = [
|
|
366
|
+
{ code: "en", label: "English" },
|
|
367
|
+
{ code: "zh-Hans", label: "简体中文" },
|
|
368
|
+
];
|
|
369
|
+
|
|
370
|
+
async function openMenu(c: HTMLElement) {
|
|
371
|
+
await click(avatarButton(c));
|
|
372
|
+
return c.querySelector(".menu-stub") as HTMLElement | null;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
it("renders user-menu-extra rows in the dropdown tail and close() dismisses the menu", async () => {
|
|
376
|
+
const c = mount(
|
|
377
|
+
headerNode({ logoutLabel: "Log out" }, {
|
|
378
|
+
"user-menu-extra": ({ close }: { close?: () => void }) =>
|
|
379
|
+
h("button", { class: "menu-stub-row extra-row", onClick: () => close?.() }, "Account center"),
|
|
380
|
+
}),
|
|
381
|
+
);
|
|
382
|
+
const menu = await openMenu(c);
|
|
383
|
+
// The host row rides AFTER the built-in rows (tail), inside the menu.
|
|
384
|
+
const rows = menuRows(c);
|
|
385
|
+
expect(rows[rows.length - 1].textContent).toBe("Account center");
|
|
386
|
+
// close() dismisses the dropdown — a navigating entry leaves no
|
|
387
|
+
// orphaned menu behind.
|
|
388
|
+
await click(rows[rows.length - 1]);
|
|
389
|
+
expect(c.querySelector(".menu-stub")).toBeNull();
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
it("renders the locale-picker popup when the Language row is selected", async () => {
|
|
393
|
+
const c = mount(
|
|
394
|
+
headerNode(
|
|
395
|
+
{ localeOptions: LOCALES, localeMenuLabel: "Language" },
|
|
396
|
+
{
|
|
397
|
+
"locale-picker": ({ open }: { open: boolean }) =>
|
|
398
|
+
h("div", { class: "locale-popup", "data-open": String(open) }, "picker"),
|
|
399
|
+
},
|
|
400
|
+
),
|
|
401
|
+
);
|
|
402
|
+
// Popup starts closed.
|
|
403
|
+
expect(c.querySelector(".locale-popup")?.getAttribute("data-open")).toBe("false");
|
|
404
|
+
const menu = await openMenu(c);
|
|
405
|
+
// Slot mode: the Language row is a leaf (no built-in cascade rows).
|
|
406
|
+
expect(menu!.querySelector('[data-key="locale:en"]')).toBeNull();
|
|
407
|
+
expect(menu!.querySelector('[data-key="locale:zh-Hans"]')).toBeNull();
|
|
408
|
+
await click(menu!.querySelector('[data-key="locale"]'));
|
|
409
|
+
// Selecting the Language row opens the host popup (the payload's
|
|
410
|
+
// open flips true; the real assertion is the rendered data-open).
|
|
411
|
+
expect(c.querySelector(".locale-popup")?.getAttribute("data-open")).toBe("true");
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
it("keeps the built-in cascade when no locale-picker slot is supplied", async () => {
|
|
415
|
+
// NEGATIVE CONTROL (hosts like chest pass localeOptions and nothing
|
|
416
|
+
// else): the Language row keeps its built-in children exactly as
|
|
417
|
+
// before the revival.
|
|
418
|
+
const c = mount(headerNode({ localeOptions: LOCALES, localeMenuLabel: "Language" }));
|
|
419
|
+
const menu = await openMenu(c);
|
|
420
|
+
expect(menu!.querySelector('[data-key="locale:en"]')).not.toBeNull();
|
|
421
|
+
expect(menu!.querySelector('[data-key="locale:zh-Hans"]')).not.toBeNull();
|
|
422
|
+
expect(menu!.querySelector('[data-key="locale"]')).not.toBeNull();
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
it("renders neither host surface when neither slot is supplied", () => {
|
|
426
|
+
// NEGATIVE CONTROL: existing hosts (chest-shaped) see zero change —
|
|
427
|
+
// no tail rows, no popup mount, the exact DOM they always had.
|
|
428
|
+
const c = mount(headerNode({ localeOptions: LOCALES }));
|
|
429
|
+
expect(c.querySelector(".menu-stub")).toBeNull();
|
|
430
|
+
expect(c.querySelector(".locale-popup")).toBeNull();
|
|
431
|
+
expect(c.textContent).not.toContain("Account center");
|
|
432
|
+
});
|
|
433
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { computed, defineComponent, ref, watch, type PropType, type SlotsType, type VNode } from "vue";
|
|
1
|
+
import { computed, defineComponent, ref, watch, type PropType, type Ref, type SlotsType, type VNode } from "vue";
|
|
2
2
|
import { Camera, ExternalLink, Languages, LogOut, Menu } from "lucide-vue-next";
|
|
3
3
|
import { HBadge, HButton, HSpinner } from "@celestia-island/hikari";
|
|
4
4
|
import { useI18n } from "../i18n/context";
|
|
@@ -21,17 +21,40 @@ export interface HkAdminHeaderAvatarModalSlot {
|
|
|
21
21
|
onUpdateOpen: (value: boolean) => void;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Scoped payload of the `user-menu-extra` slot — host-owned rows the
|
|
26
|
+
* header appends to the user dropdown's TAIL (above nothing, below every
|
|
27
|
+
* built-in row). `close` dismisses the dropdown so a navigating entry
|
|
28
|
+
* (account center, …) leaves no orphaned menu behind. Mirrors the erp-side
|
|
29
|
+
* `AdminHeaderUserMenuExtraSlot` contract verbatim (L39 ruling a: the slot
|
|
30
|
+
* is consumed since this header grew the wiring).
|
|
31
|
+
*/
|
|
32
|
+
export interface HkAdminHeaderUserMenuExtraSlot {
|
|
33
|
+
close?: () => void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Scoped payload of the `locale-picker` slot — the host-owned locale
|
|
38
|
+
* popup. When the slot is supplied, the menu's Language row becomes a
|
|
39
|
+
* plain trigger for this popup (the built-in children cascade stands
|
|
40
|
+
* down); `triggerRef` anchors the popup to the avatar trigger so it
|
|
41
|
+
* opens where the menu was. Mirrors the erp-side
|
|
42
|
+
* `AdminHeaderLocalePickerSlot` contract verbatim.
|
|
43
|
+
*/
|
|
44
|
+
export interface HkAdminHeaderLocalePickerSlot {
|
|
45
|
+
open: boolean;
|
|
46
|
+
onUpdateOpen: (value: boolean) => void;
|
|
47
|
+
triggerRef: Ref<HTMLElement | null> | HTMLElement | null;
|
|
48
|
+
}
|
|
49
|
+
|
|
24
50
|
/**
|
|
25
51
|
* The header's whole slot surface, in `SlotsType` form. `identity`,
|
|
26
52
|
* `center`, `emergency-stop-extra` and `theme-toggle` take no params.
|
|
27
53
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* (reviving erp's invisible account-center menu entries) or erp should delete
|
|
33
|
-
* the dead bodies is ⏳ pending a user decision; until then neither name may
|
|
34
|
-
* appear in this aggregate.
|
|
54
|
+
* `user-menu-extra` (rows appended to the dropdown tail) and
|
|
55
|
+
* `locale-picker` (host locale popup replacing the built-in cascade) were
|
|
56
|
+
* consumed as of the L39 ruling-a revival (2026-11-20): the erp bodies
|
|
57
|
+
* that had sat invisible since 0.55.241 now render.
|
|
35
58
|
*/
|
|
36
59
|
export type HkAdminHeaderSlots = SlotsType<{
|
|
37
60
|
identity?: () => VNode[];
|
|
@@ -39,6 +62,8 @@ export type HkAdminHeaderSlots = SlotsType<{
|
|
|
39
62
|
"emergency-stop-extra"?: () => VNode[];
|
|
40
63
|
"theme-toggle"?: () => VNode[];
|
|
41
64
|
"avatar-modal"?: (params: HkAdminHeaderAvatarModalSlot) => VNode[];
|
|
65
|
+
"user-menu-extra"?: (params: HkAdminHeaderUserMenuExtraSlot) => VNode[];
|
|
66
|
+
"locale-picker"?: (params: HkAdminHeaderLocalePickerSlot) => VNode[];
|
|
42
67
|
}>;
|
|
43
68
|
|
|
44
69
|
export const HkAdminHeader = defineComponent({
|
|
@@ -132,6 +157,11 @@ export const HkAdminHeader = defineComponent({
|
|
|
132
157
|
const userMenuOpen = ref(false);
|
|
133
158
|
const userTriggerRef = ref<HTMLElement>();
|
|
134
159
|
const avatarModalOpen = ref(false);
|
|
160
|
+
// The host-owned locale popup's open state (L39 ruling a): when the
|
|
161
|
+
// `locale-picker` slot is supplied, the menu's Language row triggers
|
|
162
|
+
// THIS popup instead of the built-in children cascade — anchored to
|
|
163
|
+
// the avatar trigger, so the popup opens exactly where the menu was.
|
|
164
|
+
const localePickerOpen = ref(false);
|
|
135
165
|
// The DROPDOWN identity image's own failed-load latch, with the same
|
|
136
166
|
// URL-change reset the trigger's latch has inside HkAvatarButton —
|
|
137
167
|
// an avatar re-upload or account switch must heal BOTH faces (R2's
|
|
@@ -197,11 +227,19 @@ export const HkAdminHeader = defineComponent({
|
|
|
197
227
|
key: "locale",
|
|
198
228
|
label: props.localeMenuLabel ?? t("hikari::adminHeader.language", "Language"),
|
|
199
229
|
icon: Languages,
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
230
|
+
// A host-supplied `locale-picker` slot turns this row into a
|
|
231
|
+
// plain trigger for the host popup — the built-in cascade
|
|
232
|
+
// stands down (two locale surfaces in one menu would read as
|
|
233
|
+
// duplicated controls). Select routing is in onUserMenuSelect.
|
|
234
|
+
...(slots["locale-picker"]
|
|
235
|
+
? {}
|
|
236
|
+
: {
|
|
237
|
+
children: props.localeOptions.map((o) => ({
|
|
238
|
+
key: `locale:${o.code}`,
|
|
239
|
+
label: o.label,
|
|
240
|
+
checked: o.code === props.currentLocale,
|
|
241
|
+
})),
|
|
242
|
+
}),
|
|
205
243
|
});
|
|
206
244
|
}
|
|
207
245
|
// Frontend link — mirrors the drawer user panel's "go to frontend"
|
|
@@ -224,6 +262,10 @@ export const HkAdminHeader = defineComponent({
|
|
|
224
262
|
function onUserMenuSelect(key: string) {
|
|
225
263
|
if (key === "avatar") {
|
|
226
264
|
avatarModalOpen.value = true;
|
|
265
|
+
} else if (key === "locale" && slots["locale-picker"]) {
|
|
266
|
+
// Host-popup mode: the menu closes around the select (HkMenu's
|
|
267
|
+
// own behaviour) and the popup takes over the anchor's spot.
|
|
268
|
+
localePickerOpen.value = true;
|
|
227
269
|
} else if (key.startsWith("locale:")) {
|
|
228
270
|
emit("localeSelect", key.slice("locale:".length));
|
|
229
271
|
} else if (key === "go-to-frontend") {
|
|
@@ -377,6 +419,14 @@ export const HkAdminHeader = defineComponent({
|
|
|
377
419
|
</div>
|
|
378
420
|
)
|
|
379
421
|
),
|
|
422
|
+
/* Host-owned tail rows (L39 ruling a): appended AFTER every
|
|
423
|
+
* built-in row — the account-center / change-password entries
|
|
424
|
+
* erp has been passing since 0.55.241. `close` dismisses the
|
|
425
|
+
* dropdown so a navigating entry leaves no orphaned menu. */
|
|
426
|
+
footer: () =>
|
|
427
|
+
slots["user-menu-extra"]?.({
|
|
428
|
+
close: () => { userMenuOpen.value = false; },
|
|
429
|
+
}) ?? [],
|
|
380
430
|
}}
|
|
381
431
|
</HkMenu>
|
|
382
432
|
|
|
@@ -427,6 +477,16 @@ export const HkAdminHeader = defineComponent({
|
|
|
427
477
|
open: avatarModalOpen.value,
|
|
428
478
|
onUpdateOpen: (v: boolean) => { avatarModalOpen.value = v; },
|
|
429
479
|
})}
|
|
480
|
+
|
|
481
|
+
{/* Host-owned locale popup (L39 ruling a): the Language row's
|
|
482
|
+
* trigger target. Anchored to the avatar trigger — the popup
|
|
483
|
+
* opens where the dropdown was, so the handoff reads as the
|
|
484
|
+
* menu sliding into a picker rather than a second surface. */}
|
|
485
|
+
{slots["locale-picker"]?.({
|
|
486
|
+
open: localePickerOpen.value,
|
|
487
|
+
onUpdateOpen: (v: boolean) => { localePickerOpen.value = v; },
|
|
488
|
+
triggerRef: userTriggerRef.value ?? null,
|
|
489
|
+
})}
|
|
430
490
|
</header>
|
|
431
491
|
);
|
|
432
492
|
},
|
|
@@ -288,6 +288,19 @@
|
|
|
288
288
|
sans-serif;
|
|
289
289
|
}
|
|
290
290
|
|
|
291
|
+
/* The standard leading capsule (HkAffixOption.badge): the HBadge base
|
|
292
|
+
* owns every visual channel (primary wash, mono face, squared pill,
|
|
293
|
+
* tabular-friendly padding) — here it only opts out of the flex
|
|
294
|
+
* shrink/grow axes: `none` keeps the capsule from growing into the
|
|
295
|
+
* label's room (and from shrinking under it), so the emoji `flag` and
|
|
296
|
+
* the label keep their natural widths around it.
|
|
297
|
+
* The gap to the label is the row grammar's own --hk-menu-item-gap
|
|
298
|
+
* (8px desktop / sheet inherits), so hosts never hand-tune spacing. */
|
|
299
|
+
.hk-affix-row-badge,
|
|
300
|
+
.hk-affix-tag-badge {
|
|
301
|
+
flex: none;
|
|
302
|
+
}
|
|
303
|
+
|
|
291
304
|
.hk-affix-row-label {
|
|
292
305
|
flex: 1;
|
|
293
306
|
min-width: 0;
|
|
@@ -33,6 +33,7 @@ interface MountOptions {
|
|
|
33
33
|
confirmRemove?: boolean;
|
|
34
34
|
disabled?: boolean;
|
|
35
35
|
tagValues?: Record<string, string>;
|
|
36
|
+
options?: HkAffixOption[];
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
function mountPicker(opts: MountOptions = {}) {
|
|
@@ -47,7 +48,7 @@ function mountPicker(opts: MountOptions = {}) {
|
|
|
47
48
|
const app = createApp({
|
|
48
49
|
render: () =>
|
|
49
50
|
h(HkAffixPicker, {
|
|
50
|
-
options: OPTIONS,
|
|
51
|
+
options: opts.options ?? OPTIONS,
|
|
51
52
|
mode: opts.mode ?? "single",
|
|
52
53
|
selected: opts.selected ?? "",
|
|
53
54
|
activeKey: opts.activeKey,
|
|
@@ -494,3 +495,80 @@ describe("affix side → popup placement contract", () => {
|
|
|
494
495
|
);
|
|
495
496
|
});
|
|
496
497
|
});
|
|
498
|
+
|
|
499
|
+
describe("HkAffixPicker badge capsule", () => {
|
|
500
|
+
/** Provider-roster fixture (the shape GroupEditModal ships): a
|
|
501
|
+
* textual ordinal rides `badge` — the standard capsule slot — and
|
|
502
|
+
* never the emoji-font `flag` glyph slot (2026-11-20 user report:
|
|
503
|
+
* `flag: "#1"` rendered bare unstyled text). */
|
|
504
|
+
const BADGED: HkAffixOption[] = [
|
|
505
|
+
{ key: "llama-local", label: "llama-local", badge: "#1", keywords: "llama-local" },
|
|
506
|
+
{ key: "deepseek", label: "deepseek", badge: "#2", keywords: "deepseek" },
|
|
507
|
+
{ key: "bare", label: "bare provider" },
|
|
508
|
+
];
|
|
509
|
+
|
|
510
|
+
it("renders the badge as a standard capsule before the label; flag slot stays empty", async () => {
|
|
511
|
+
const { container } = mountPicker({ options: BADGED, selected: "llama-local" });
|
|
512
|
+
await openPopup(container);
|
|
513
|
+
const badges = [...document.querySelectorAll<HTMLElement>(".hk-affix-row-badge")];
|
|
514
|
+
expect(badges.map((b) => b.textContent)).toEqual(["#1", "#2"]);
|
|
515
|
+
// The capsule IS the standard badge chrome — primary wash, mono face,
|
|
516
|
+
// small size, squared pill — not just any span wearing the class
|
|
517
|
+
// (R2: a props-degraded mutant must turn red here).
|
|
518
|
+
for (const b of badges) {
|
|
519
|
+
expect(b.classList.contains("hk-badge-primary")).toBe(true);
|
|
520
|
+
expect(b.dataset.size).toBe("sm");
|
|
521
|
+
expect(b.dataset.mono).toBe("");
|
|
522
|
+
expect(b.dataset.pill).toBe("false");
|
|
523
|
+
}
|
|
524
|
+
// Textual ordinals must not leak into the emoji-flag glyph span.
|
|
525
|
+
expect(document.querySelector(".hk-affix-row-flag")).toBeNull();
|
|
526
|
+
// Capsule precedes the label inside its row (the row grammar's own
|
|
527
|
+
// 8px menu-item gap provides the spacing — no hand-tuned margins).
|
|
528
|
+
const row = rows()[0];
|
|
529
|
+
const badgeEl = row.querySelector(".hk-affix-row-badge");
|
|
530
|
+
const labelEl = row.querySelector(".hk-affix-row-label");
|
|
531
|
+
expect(
|
|
532
|
+
badgeEl &&
|
|
533
|
+
labelEl &&
|
|
534
|
+
!!(badgeEl.compareDocumentPosition(labelEl) & Node.DOCUMENT_POSITION_FOLLOWING),
|
|
535
|
+
).toBe(true);
|
|
536
|
+
});
|
|
537
|
+
|
|
538
|
+
it("multi mode keeps the badge on selected tags and remaining rows alike", async () => {
|
|
539
|
+
const { container } = mountPicker({
|
|
540
|
+
options: BADGED,
|
|
541
|
+
mode: "multi",
|
|
542
|
+
selected: ["deepseek"],
|
|
543
|
+
});
|
|
544
|
+
await openPopup(container);
|
|
545
|
+
const t = tag("deepseek");
|
|
546
|
+
expect(t, "selected tag renders").toBeTruthy();
|
|
547
|
+
expect(t!.querySelector(".hk-affix-tag-badge")?.textContent).toBe("#2");
|
|
548
|
+
// The not-yet-selected rows keep their capsules; a badge-less row
|
|
549
|
+
// (bare) renders no badge node at all.
|
|
550
|
+
expect(
|
|
551
|
+
rows().map((r) => r.querySelector(".hk-affix-row-badge")?.textContent),
|
|
552
|
+
).toEqual(["#1", undefined]);
|
|
553
|
+
});
|
|
554
|
+
|
|
555
|
+
it("options without a badge render no badge nodes", async () => {
|
|
556
|
+
// MULTI mode on purpose (R2: single mode never renders tags, so a
|
|
557
|
+
// `.hk-affix-tag-badge` assertion there is vacuous): both surfaces
|
|
558
|
+
// — remaining rows AND selected tags — must stay badge-free for a
|
|
559
|
+
// badge-less option.
|
|
560
|
+
const { container } = mountPicker({
|
|
561
|
+
options: BADGED,
|
|
562
|
+
mode: "multi",
|
|
563
|
+
selected: ["bare"],
|
|
564
|
+
});
|
|
565
|
+
await openPopup(container);
|
|
566
|
+
const t = tag("bare provider");
|
|
567
|
+
expect(t, "selected tag renders").toBeTruthy();
|
|
568
|
+
expect(t!.querySelector(".hk-affix-tag-badge")).toBeNull();
|
|
569
|
+
// The remaining rows are the two BADGED options — theirs render.
|
|
570
|
+
expect(
|
|
571
|
+
rows().map((r) => r.querySelector(".hk-affix-row-badge")?.textContent),
|
|
572
|
+
).toEqual(["#1", "#2"]);
|
|
573
|
+
});
|
|
574
|
+
});
|
|
@@ -11,6 +11,7 @@ import { ChevronDown, Plus, Search, X } from "lucide-vue-next";
|
|
|
11
11
|
|
|
12
12
|
import { useI18n } from "../i18n/context";
|
|
13
13
|
|
|
14
|
+
import HBadge from "./HkBadge";
|
|
14
15
|
import HkInput from "./HkInput";
|
|
15
16
|
import HkListTransition from "./HkListTransition";
|
|
16
17
|
import HkMenu from "./HkMenu";
|
|
@@ -27,6 +28,16 @@ export interface HkAffixOption {
|
|
|
27
28
|
meta?: string;
|
|
28
29
|
/** Optional leading glyph (flag emoji or any short symbol). */
|
|
29
30
|
flag?: string;
|
|
31
|
+
/** Standard leading CAPSULE: a small primary mono badge (`HBadge`,
|
|
32
|
+
* primary / sm / mono / square) — the visual language of the model
|
|
33
|
+
* tag's `#N` number segment downstream (shittim-chest kit
|
|
34
|
+
* `HkModelTag`, which renders its ordinal as exactly this badge
|
|
35
|
+
* shape) — rendered after the flag, before the label, separated by
|
|
36
|
+
* the row's own gap. Roster ordinals, short codes. A TEXTUAL
|
|
37
|
+
* ordinal never belongs in `flag`: that span is an emoji-font glyph
|
|
38
|
+
* slot, and an `#N` inside it renders as bare unstyled text
|
|
39
|
+
* (2026-11-20 user report). */
|
|
40
|
+
badge?: string;
|
|
30
41
|
/** Extra haystack for the search filter (aliases, codes, digits). */
|
|
31
42
|
keywords?: string;
|
|
32
43
|
disabled?: boolean;
|
|
@@ -60,6 +71,10 @@ function isSubsequence(query: string, text: string): boolean {
|
|
|
60
71
|
* - the option rows themselves: single mode shows every option and
|
|
61
72
|
* closes on pick; multi mode lists the NOT-yet-selected options and
|
|
62
73
|
* stays open for batch adds;
|
|
74
|
+
* - a row (or tag) can carry a `badge` — the standard leading capsule
|
|
75
|
+
* (primary mono, the model-tag num-segment language) for roster
|
|
76
|
+
* ordinals and short codes; `flag` stays the emoji glyph slot and
|
|
77
|
+
* the two never swap jobs;
|
|
63
78
|
* - with `allowCustom`, a trailing "Use <query>" row appears whenever
|
|
64
79
|
* the typed query is not an exact label match — free-text entries
|
|
65
80
|
* without leaving the keyboard flow (Enter picks the first row, or
|
|
@@ -420,6 +435,17 @@ export const HkAffixPicker = defineComponent({
|
|
|
420
435
|
{tag.flag}
|
|
421
436
|
</span>
|
|
422
437
|
)}
|
|
438
|
+
{tag.badge && (
|
|
439
|
+
<HBadge
|
|
440
|
+
variant="primary"
|
|
441
|
+
size="sm"
|
|
442
|
+
mono
|
|
443
|
+
pill={false}
|
|
444
|
+
class="hk-affix-tag-badge"
|
|
445
|
+
>
|
|
446
|
+
{tag.badge}
|
|
447
|
+
</HBadge>
|
|
448
|
+
)}
|
|
423
449
|
<span
|
|
424
450
|
class="hk-affix-tag-text"
|
|
425
451
|
data-unset={valueDriven && !value ? "" : undefined}
|
|
@@ -511,6 +537,17 @@ export const HkAffixPicker = defineComponent({
|
|
|
511
537
|
{option.flag}
|
|
512
538
|
</span>
|
|
513
539
|
)}
|
|
540
|
+
{option.badge && (
|
|
541
|
+
<HBadge
|
|
542
|
+
variant="primary"
|
|
543
|
+
size="sm"
|
|
544
|
+
mono
|
|
545
|
+
pill={false}
|
|
546
|
+
class="hk-affix-row-badge"
|
|
547
|
+
>
|
|
548
|
+
{option.badge}
|
|
549
|
+
</HBadge>
|
|
550
|
+
)}
|
|
514
551
|
<span class="hk-affix-row-label">{option.label}</span>
|
|
515
552
|
{option.meta && (
|
|
516
553
|
<span class="hk-affix-row-meta">{option.meta}</span>
|
|
@@ -953,19 +953,19 @@ export default defineComponent({
|
|
|
953
953
|
frameAll(padding = 1.3, durationMs = 0) {
|
|
954
954
|
if (!camera || !controls) return;
|
|
955
955
|
const box = new THREE.Box3();
|
|
956
|
-
let
|
|
956
|
+
let frameable = false;
|
|
957
957
|
for (const def of registry.values()) {
|
|
958
958
|
if (def.content === false) continue;
|
|
959
959
|
// Skip what the MAIN camera cannot see (the minimap's helpers
|
|
960
960
|
// live on their own layer): framing must never chase them.
|
|
961
961
|
if (!def.object.layers.test(camera.layers)) continue;
|
|
962
962
|
box.expandByObject(def.object);
|
|
963
|
-
|
|
963
|
+
frameable = true;
|
|
964
964
|
}
|
|
965
965
|
// Nothing frameable registered yet (an async page calling
|
|
966
966
|
// frameAll before its content arrives): stay put rather than
|
|
967
967
|
// framing whatever happens to be in the scene.
|
|
968
|
-
if (!
|
|
968
|
+
if (!frameable || box.isEmpty()) return;
|
|
969
969
|
groundHandle?.fit(box);
|
|
970
970
|
const sphere = box.getBoundingSphere(new THREE.Sphere());
|
|
971
971
|
const dist = fitDistance(sphere.radius, camera.fov, camera.aspect) * padding;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// One emphasised key fact: a bordered chip pairing a muted label with a
|
|
2
|
+
// strong value. Channels are emitted-theme triplets wrapped in rgb().
|
|
3
|
+
|
|
4
|
+
.hk-delete-fact {
|
|
5
|
+
display: inline-flex;
|
|
6
|
+
align-items: baseline;
|
|
7
|
+
gap: var(--space-4, 4px);
|
|
8
|
+
padding: var(--space-2, 2px) var(--space-6, 6px);
|
|
9
|
+
border-radius: var(--radius-sm, 4px);
|
|
10
|
+
border: 1px solid rgb(var(--color-error, 166 41 55) / 35%);
|
|
11
|
+
background: rgb(var(--color-error, 166 41 55) / 6%);
|
|
12
|
+
font-size: var(--text-xs, 0.75rem);
|
|
13
|
+
max-width: 100%;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.hk-delete-fact-label {
|
|
17
|
+
color: rgb(var(--color-muted, 120 120 130));
|
|
18
|
+
flex-shrink: 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.hk-delete-fact-value {
|
|
22
|
+
color: rgb(var(--color-text, 20 20 24));
|
|
23
|
+
font-weight: 600;
|
|
24
|
+
overflow-wrap: anywhere;
|
|
25
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defineComponent } from "vue";
|
|
2
|
+
|
|
3
|
+
import "./HkDeleteFact.scss";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* One emphasised key fact inside a {@link HkDeleteGateWindow} message
|
|
7
|
+
* slot. The house rule: EVERY key fact of the thing being deleted — name,
|
|
8
|
+
* per-locale alias, owner, counters, the names of attached resources — is
|
|
9
|
+
* rendered through this tag, so the irreversible act visibly names its
|
|
10
|
+
* target instead of waving at an anonymous blob.
|
|
11
|
+
*/
|
|
12
|
+
export default defineComponent({
|
|
13
|
+
name: "HkDeleteFact",
|
|
14
|
+
props: {
|
|
15
|
+
/** The fact's label ("名称" / "所有者" / "来源"). */
|
|
16
|
+
label: { type: String, required: true },
|
|
17
|
+
/** The fact's value ("ml-lab" / "demiurge" / "7 个仓库"). */
|
|
18
|
+
value: { type: String, required: true },
|
|
19
|
+
},
|
|
20
|
+
setup(props) {
|
|
21
|
+
return () => (
|
|
22
|
+
<span class="hk-delete-fact">
|
|
23
|
+
<span class="hk-delete-fact-label">{props.label}</span>
|
|
24
|
+
<span class="hk-delete-fact-value">{props.value}</span>
|
|
25
|
+
</span>
|
|
26
|
+
);
|
|
27
|
+
},
|
|
28
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// The delete confirmation window's message area: facts block on top, gate
|
|
2
|
+
// below, hint inside the gate (in flow per the stage split).
|
|
3
|
+
|
|
4
|
+
.hk-delete-gate-message {
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
gap: var(--space-8, 8px);
|
|
8
|
+
margin-block-end: var(--space-12, 12px);
|
|
9
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { createApp, defineComponent, h, nextTick, ref } from "vue";
|
|
3
|
+
|
|
4
|
+
const confirmSpy = vi.fn();
|
|
5
|
+
const cancelSpy = vi.fn();
|
|
6
|
+
|
|
7
|
+
vi.mock("../runtime/animationBus", () => ({
|
|
8
|
+
onFrame: vi.fn(() => ({ disconnect: vi.fn() })),
|
|
9
|
+
reportTransition: vi.fn(() => ({ disconnect: vi.fn() })),
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
// HkModal is stubbed: this suite pins the WINDOW's wiring (open state,
|
|
13
|
+
// slot message, gate presence), not the modal chrome (covered upstream).
|
|
14
|
+
vi.mock("./HkModal", () => ({
|
|
15
|
+
default: defineComponent({
|
|
16
|
+
name: "HkModal",
|
|
17
|
+
props: { modelValue: { type: Boolean, default: false }, title: { type: String, default: "" } },
|
|
18
|
+
setup(props, { slots }) {
|
|
19
|
+
return () =>
|
|
20
|
+
props.modelValue
|
|
21
|
+
? h("div", { class: "delwin-stub" }, [
|
|
22
|
+
h("div", { class: "delwin-stub-title" }, props.title),
|
|
23
|
+
slots.default?.(),
|
|
24
|
+
])
|
|
25
|
+
: null;
|
|
26
|
+
},
|
|
27
|
+
}),
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
import HkDeleteGateWindow from "./HkDeleteGateWindow";
|
|
31
|
+
|
|
32
|
+
const mounts: Array<{ app: ReturnType<typeof createApp>; container: HTMLElement }> = [];
|
|
33
|
+
|
|
34
|
+
function mountWindow(slotHtml: string, props: Record<string, unknown> = {}) {
|
|
35
|
+
const container = document.createElement("div");
|
|
36
|
+
document.body.appendChild(container);
|
|
37
|
+
const Harness = defineComponent({
|
|
38
|
+
setup() {
|
|
39
|
+
return () =>
|
|
40
|
+
h(HkDeleteGateWindow, {
|
|
41
|
+
open: true,
|
|
42
|
+
title: "删除工作区",
|
|
43
|
+
label: "此工作区",
|
|
44
|
+
grabHint: "grab",
|
|
45
|
+
trackingHint: "keep going",
|
|
46
|
+
onConfirm: () => confirmSpy(),
|
|
47
|
+
onCancel: (p: number) => cancelSpy(p),
|
|
48
|
+
...props,
|
|
49
|
+
}, {
|
|
50
|
+
default: () => h("div", {
|
|
51
|
+
class: "hk-delete-gate-message",
|
|
52
|
+
innerHTML: slotHtml,
|
|
53
|
+
}),
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
const app = createApp(Harness);
|
|
58
|
+
app.mount(container);
|
|
59
|
+
mounts.push({ app, container });
|
|
60
|
+
return container;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
afterEach(() => {
|
|
64
|
+
for (const { app, container } of mounts.splice(0)) {
|
|
65
|
+
app.unmount();
|
|
66
|
+
container.remove();
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
describe("HkDeleteGateWindow", () => {
|
|
71
|
+
it("renders the slot message, the title and the gate inside the window", () => {
|
|
72
|
+
const c = mountWindow(
|
|
73
|
+
'<span class="hk-delete-fact"><span class="hk-delete-fact-label">名称</span><span class="hk-delete-fact-value">ml-lab</span></span>',
|
|
74
|
+
);
|
|
75
|
+
expect(c.querySelector(".delwin-stub-title")!.textContent).toBe("删除工作区");
|
|
76
|
+
expect(c.querySelector(".hk-delete-gate-message .hk-delete-fact")!.textContent).toContain("ml-lab");
|
|
77
|
+
expect(c.querySelector(".hk-serpentine")).toBeTruthy();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("renders closed when open=false", () => {
|
|
81
|
+
const c = mountWindow("<p>msg</p>", { open: false });
|
|
82
|
+
expect(c.querySelector(".hk-serpentine")).toBeNull();
|
|
83
|
+
expect(c.querySelector(".delwin-stub")).toBeNull();
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("passes a higher turn range through to the lane (sensitive deletes walk more)", () => {
|
|
87
|
+
const c = mountWindow("<p>msg</p>", { turns: [7, 9], seed: 42 });
|
|
88
|
+
const lane = c.querySelector(".hk-serpentine-lane") as SVGElement;
|
|
89
|
+
const corners = lane.getAttribute("points")!.split(" ").length - 2;
|
|
90
|
+
expect(corners).toBeGreaterThanOrEqual(7);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("closes itself after the gate confirms and forwards the walk events", async () => {
|
|
94
|
+
// The gate inside the window is the REAL component; walk it to the goal
|
|
95
|
+
// and release: the window must emit confirm (the parent performs the
|
|
96
|
+
// delete) AND close itself (update:open=false). A short release must
|
|
97
|
+
// NOT close — it only emits cancel with the progress.
|
|
98
|
+
const onUpdate = vi.fn();
|
|
99
|
+
const c = mountWindow("<p>msg</p>", {
|
|
100
|
+
"onUpdate:open": onUpdate,
|
|
101
|
+
seed: 42,
|
|
102
|
+
onConfirm: () => confirmSpy(),
|
|
103
|
+
onCancel: (p: number) => cancelSpy(p),
|
|
104
|
+
});
|
|
105
|
+
const el = c.querySelector(".hk-serpentine")!;
|
|
106
|
+
const down = new PointerEvent("pointerdown", { bubbles: true, clientX: 24, clientY: 48, pointerId: 1 });
|
|
107
|
+
el.dispatchEvent(down);
|
|
108
|
+
// Mid-lane release: cancel only.
|
|
109
|
+
const mid = new PointerEvent("pointermove", { bubbles: true, clientX: 300, clientY: 48, pointerId: 1 });
|
|
110
|
+
el.dispatchEvent(mid);
|
|
111
|
+
const up = new PointerEvent("pointerup", { bubbles: true, clientX: 300, clientY: 48, pointerId: 1 });
|
|
112
|
+
el.dispatchEvent(up);
|
|
113
|
+
expect(confirmSpy).not.toHaveBeenCalled();
|
|
114
|
+
expect(cancelSpy).toHaveBeenCalled();
|
|
115
|
+
expect(onUpdate).not.toHaveBeenCalled(); // stays open
|
|
116
|
+
// Re-open state is already open; a full walk then confirms and closes.
|
|
117
|
+
el.dispatchEvent(down);
|
|
118
|
+
for (let x = 30; x <= 600; x += 10) {
|
|
119
|
+
el.dispatchEvent(new PointerEvent("pointermove", { bubbles: true, clientX: x, clientY: 48, pointerId: 1 }));
|
|
120
|
+
}
|
|
121
|
+
el.dispatchEvent(new PointerEvent("pointerup", { bubbles: true, clientX: 600, clientY: 48, pointerId: 1 }));
|
|
122
|
+
expect(confirmSpy).toHaveBeenCalledTimes(1);
|
|
123
|
+
expect(onUpdate).toHaveBeenCalledWith(false);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it("key facts carry the emphasis classes", () => {
|
|
127
|
+
const c = mountWindow(
|
|
128
|
+
'<span class="hk-delete-fact"><span class="hk-delete-fact-label">所有者</span><span class="hk-delete-fact-value">demiurge</span></span>',
|
|
129
|
+
);
|
|
130
|
+
expect(c.querySelector(".hk-delete-fact-label")!.textContent).toBe("所有者");
|
|
131
|
+
expect(c.querySelector(".hk-delete-fact-value")!.textContent).toBe("demiurge");
|
|
132
|
+
});
|
|
133
|
+
});
|