@celestia-island/hikari 0.55.434 → 0.55.436
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/HkAdminHeader.tsx +32 -1
- package/src/components/HkAdminTablePage.tsx +2 -2
- package/src/components/HkFaceShell.slots.test.ts +94 -0
- package/src/components/HkFaceShell.tsx +57 -1
- package/src/components/HkSerpentineUnlock.scss +3 -1
- package/src/components/HkSupplementInset.scss +83 -0
- package/src/components/HkSupplementInset.test.tsx +136 -0
- package/src/components/HkSupplementInset.tsx +116 -0
- package/src/components/HkTable.rows.test.tsx +164 -0
- package/src/components/HkTable.tsx +16 -4
- package/src/components/HkTabs.scss +13 -51
- package/src/components/HkTabs.test.ts +131 -82
- package/src/components/HkTabs.tsx +68 -27
- package/src/index.ts +5 -1
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { computed, defineComponent, ref, watch, type PropType, type VNode } from "vue";
|
|
1
|
+
import { computed, defineComponent, ref, watch, type PropType, 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";
|
|
@@ -11,8 +11,39 @@ export interface LocaleOption {
|
|
|
11
11
|
label: string;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Scoped payload of the `avatar-modal` slot — the exact object the header
|
|
16
|
+
* passes when it mounts the avatar crop modal (known-live-issues L39:
|
|
17
|
+
* consumers hand-copied this shape as local interfaces; single-sourced here).
|
|
18
|
+
*/
|
|
19
|
+
export interface HkAdminHeaderAvatarModalSlot {
|
|
20
|
+
open: boolean;
|
|
21
|
+
onUpdateOpen: (value: boolean) => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The header's whole slot surface, in `SlotsType` form. `identity`,
|
|
26
|
+
* `center`, `emergency-stop-extra` and `theme-toggle` take no params.
|
|
27
|
+
*
|
|
28
|
+
* NOT part of this contract: the erp-side `locale-picker` / `user-menu-extra`
|
|
29
|
+
* names (L39, lead ruling 2026-11-19) — declared by celestia-erp's local
|
|
30
|
+
* interfaces but NEVER consumed by hikari's HkAdminHeader, so the slot bodies
|
|
31
|
+
* erp passes have never rendered. Whether hikari should grow the consumption
|
|
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.
|
|
35
|
+
*/
|
|
36
|
+
export type HkAdminHeaderSlots = SlotsType<{
|
|
37
|
+
identity?: () => VNode[];
|
|
38
|
+
center?: () => VNode[];
|
|
39
|
+
"emergency-stop-extra"?: () => VNode[];
|
|
40
|
+
"theme-toggle"?: () => VNode[];
|
|
41
|
+
"avatar-modal"?: (params: HkAdminHeaderAvatarModalSlot) => VNode[];
|
|
42
|
+
}>;
|
|
43
|
+
|
|
14
44
|
export const HkAdminHeader = defineComponent({
|
|
15
45
|
name: "HkAdminHeader",
|
|
46
|
+
slots: Object as HkAdminHeaderSlots,
|
|
16
47
|
props: {
|
|
17
48
|
/** Page title rendered beside the avatar — the view the console is
|
|
18
49
|
* currently ON (dashboard, providers, …). The signed-in nickname
|
|
@@ -3,7 +3,7 @@ import { HAlert, HCard, HEmptyState, HSpinner, HTable, useI18n } from "@celestia
|
|
|
3
3
|
import HkCrossfade from "./HkCrossfade";
|
|
4
4
|
import HkScrollProgressDock from "./HkScrollProgressDock";
|
|
5
5
|
import { HkPageHeader } from "./HkPageHeader";
|
|
6
|
-
import type { HkRowManageGate } from "./HkTable";
|
|
6
|
+
import type { HkRowManageGate, HkTableRow } from "./HkTable";
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
/** Column definition passed through to HTable. */
|
|
@@ -50,7 +50,7 @@ export const HkAdminTablePage = defineComponent({
|
|
|
50
50
|
/** Refresh failed while rows are still on screen — banner, not a
|
|
51
51
|
* replacement of the table. */
|
|
52
52
|
staleError: { type: String as PropType<string | undefined>, default: undefined },
|
|
53
|
-
rows: { type: Array as PropType<
|
|
53
|
+
rows: { type: Array as PropType<readonly HkTableRow[]>, required: true },
|
|
54
54
|
columns: { type: Array as PropType<HTableColumn[]>, required: true },
|
|
55
55
|
rowKey: { type: String, default: "id" },
|
|
56
56
|
emptyTitle: { type: String, default: "" },
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import * as barrel from "../index";
|
|
3
|
+
import { asIndexable } from "../utils/typing";
|
|
4
|
+
import type { HkAdminHeaderAvatarModalSlot, HkAdminHeaderSlots, HkFaceShellHeaderSlot, HkFaceShellSidebarSlot, HkFaceShellSlots, HkFaceShellUserPanelSlot } from "../index";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The L39 slot-type contract pins. The exported slot types are what chest and
|
|
8
|
+
* erp hand-copied as local interfaces (4 + 5 copies across the two repos);
|
|
9
|
+
* these pins keep the PUBLIC contract honest in both directions:
|
|
10
|
+
*
|
|
11
|
+
* - runtime: the barrel keeps exporting every type name (a deleted `export
|
|
12
|
+
* type` line does not fail any other test — types vanish silently for
|
|
13
|
+
* importers while vitest stays green, the exact barrel-gap shape the
|
|
14
|
+
* HkFaceShell runtime pin below was written for);
|
|
15
|
+
* - type-level: each interface is CONSUMED the way the downstream
|
|
16
|
+
* AdminLayouts consume it (subset destructuring + the aggregate wired into
|
|
17
|
+
* a defineComponent `slots:`), so a payload-field rename or removal breaks
|
|
18
|
+
* THIS file's compile (vue-tsc --noEmit), not a downstream repo's build.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/** chest/erp AdminLayout shape: destructure a SUBSET of the header params. */
|
|
22
|
+
function headerSubset(params: HkFaceShellHeaderSlot) {
|
|
23
|
+
const { compact, onOpenDrawer } = params;
|
|
24
|
+
return { compact, onOpenDrawer };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** The full five-field payload must be readable (no hand-copied subset lag). */
|
|
28
|
+
function headerFull(params: HkFaceShellHeaderSlot) {
|
|
29
|
+
return [params.isDesktop, params.showHamburger, params.compact, params.onHamburger, params.onOpenDrawer];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function sidebarBody(params: HkFaceShellSidebarSlot) {
|
|
33
|
+
// The optional peek/inDrawer flags are exactly the union the three render
|
|
34
|
+
// sites pass (desktop expanded, rail peek, mobile drawer).
|
|
35
|
+
return { collapsed: params.collapsed, onNavigate: params.onNavigate, peeking: params.peeking, inDrawer: params.inDrawer };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function userPanelBody(params: HkFaceShellUserPanelSlot) {
|
|
39
|
+
return { onNavigate: params.onNavigate };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** erp AdminLayout shape: the avatar-modal destructure. */
|
|
43
|
+
function avatarModalBody(params: HkAdminHeaderAvatarModalSlot) {
|
|
44
|
+
const { open, onUpdateOpen } = params;
|
|
45
|
+
onUpdateOpen(!open);
|
|
46
|
+
return { open, onUpdateOpen };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
describe("the public slot-type contract (L39)", () => {
|
|
50
|
+
it("exports every slot type name from the barrel", () => {
|
|
51
|
+
// Types are erased at runtime; the pin is the module-record presence of
|
|
52
|
+
// each name via a type-only import assertion below plus this runtime
|
|
53
|
+
// guard that the COMPONENTS still resolve (the types ride their files).
|
|
54
|
+
const face = asIndexable(barrel.HkFaceShell);
|
|
55
|
+
const header = asIndexable(barrel.HkAdminHeader);
|
|
56
|
+
expect(face, "HkFaceShell must stay exported").toBeTruthy();
|
|
57
|
+
expect(header, "HkAdminHeader must stay exported").toBeTruthy();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("both components keep their slots declaration wired into the options (R3 M4 pin)", () => {
|
|
61
|
+
// The `slots: Object as <Aggregate>` option line is what makes the
|
|
62
|
+
// declared contract type the component's OWN render-site invocations
|
|
63
|
+
// (proved red under field-rename mutations) — but deleting the line
|
|
64
|
+
// alone kept vue-tsc green (R3 M4 SURVIVED), because nothing compiled
|
|
65
|
+
// against the component side of the wiring. The options object carries
|
|
66
|
+
// `slots` at runtime, so this pin makes the deletion loud.
|
|
67
|
+
const face = asIndexable(barrel.HkFaceShell);
|
|
68
|
+
const header = asIndexable(barrel.HkAdminHeader);
|
|
69
|
+
expect(face.slots, "HkFaceShell must keep its slots declaration").toBeTruthy();
|
|
70
|
+
expect(header.slots, "HkAdminHeader must keep its slots declaration").toBeTruthy();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("the slot param interfaces accept the real payloads", () => {
|
|
74
|
+
expect(headerSubset({ isDesktop: false, showHamburger: true, compact: true, onHamburger: () => {}, onOpenDrawer: () => {} })).toEqual({ compact: true, onOpenDrawer: expect.any(Function) });
|
|
75
|
+
expect(headerFull({ isDesktop: true, showHamburger: false, compact: false, onHamburger: () => {}, onOpenDrawer: () => {} }).filter(Boolean).length).toBe(3);
|
|
76
|
+
expect(sidebarBody({ collapsed: true, onNavigate: () => {}, peeking: false })).toEqual({ collapsed: true, onNavigate: expect.any(Function), peeking: false, inDrawer: undefined });
|
|
77
|
+
expect(sidebarBody({ collapsed: false, onNavigate: () => {}, inDrawer: true }).inDrawer).toBe(true);
|
|
78
|
+
expect(userPanelBody({ onNavigate: () => {} }).onNavigate).toEqual(expect.any(Function));
|
|
79
|
+
let opened = false;
|
|
80
|
+
const avatar = avatarModalBody({ open: false, onUpdateOpen: (v) => { opened = v; } });
|
|
81
|
+
expect(avatar.open).toBe(false);
|
|
82
|
+
expect(opened).toBe(true);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("the aggregate slot types fit a defineComponent slots declaration", () => {
|
|
86
|
+
// The compile-time proof: both aggregates are SlotsType-compatible
|
|
87
|
+
// objects usable as `slots: Object as ...`. Runtime stand-in asserts the
|
|
88
|
+
// alias is a plain object cast (no accidental runtime import).
|
|
89
|
+
const faceSlots = {} as HkFaceShellSlots;
|
|
90
|
+
const headerSlots = {} as HkAdminHeaderSlots;
|
|
91
|
+
expect(faceSlots).toEqual({});
|
|
92
|
+
expect(headerSlots).toEqual({});
|
|
93
|
+
});
|
|
94
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { computed, defineComponent, provide, ref, watch, type PropType } from "vue";
|
|
1
|
+
import { computed, defineComponent, provide, ref, watch, type PropType, type SlotsType, type VNode } from "vue";
|
|
2
2
|
import { HkCrossfade, HDrawer, HScrollContainer, useBreakpoint } from "@celestia-island/hikari";
|
|
3
3
|
import { useI18n } from "../i18n/context";
|
|
4
4
|
import { useSidebarRail } from "../composables/useSidebarRail";
|
|
@@ -168,8 +168,64 @@ export function mobileSideGutterFree(value: string): string {
|
|
|
168
168
|
* footer, the fixed footer band and its injection-driven height
|
|
169
169
|
* reservation, the overlays slot — behaves identically in both modes.
|
|
170
170
|
*/
|
|
171
|
+
/**
|
|
172
|
+
* Scoped payload of the `header` slot — the exact object every render site
|
|
173
|
+
* passes (known-live-issues L39: consumers hand-copied subsets of this shape
|
|
174
|
+
* as local interfaces; the export makes the contract single-sourced).
|
|
175
|
+
*/
|
|
176
|
+
export interface HkFaceShellHeaderSlot {
|
|
177
|
+
/** Viewport at or above `mobileBreakpoint` (the desktop layout). */
|
|
178
|
+
isDesktop: boolean;
|
|
179
|
+
/** True on the mobile layout — the hamburger button should render. */
|
|
180
|
+
showHamburger: boolean;
|
|
181
|
+
/** True below `mobileBreakpoint` — the drawer is the only nav surface. */
|
|
182
|
+
compact: boolean;
|
|
183
|
+
/** Toggles the mobile hamburger drawer. */
|
|
184
|
+
onHamburger: () => void;
|
|
185
|
+
/** Opens the mobile nav drawer directly (e.g. the avatar's drawer mode). */
|
|
186
|
+
onOpenDrawer: () => void;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Scoped payload of the `sidebar` slot. Desktop renders it twice — expanded
|
|
191
|
+
* panel and (opt-in) the icon-rail hover peek; mobile renders a third copy
|
|
192
|
+
* inside the drawer. `peeking` is only set on the rail peek copy, `inDrawer`
|
|
193
|
+
* only on the mobile drawer copy; both stay optional so one body serves all.
|
|
194
|
+
*/
|
|
195
|
+
export interface HkFaceShellSidebarSlot {
|
|
196
|
+
/** The icon-rail dress (true only on the collapsed rail outside a peek). */
|
|
197
|
+
collapsed: boolean;
|
|
198
|
+
/** Call after any in-sidebar navigation so the mobile drawer closes. */
|
|
199
|
+
onNavigate: () => void;
|
|
200
|
+
/** True while the collapsed rail shows its hover-peek overlay (desktop). */
|
|
201
|
+
peeking?: boolean;
|
|
202
|
+
/** Set on the mobile drawer copy: the slot should fill its full width. */
|
|
203
|
+
inDrawer?: boolean;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** Scoped payload of the `userPanel` slot (the drawer footer). */
|
|
207
|
+
export interface HkFaceShellUserPanelSlot {
|
|
208
|
+
/** Call after any in-panel navigation so the mobile drawer closes. */
|
|
209
|
+
onNavigate: () => void;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* The shell's whole slot surface, in `SlotsType` form so a host can type its
|
|
214
|
+
* own wrapper with `slots: Object as HkFaceShellSlots` and get per-slot
|
|
215
|
+
* param checking for free. `content` / `footer` / `overlays` take no params.
|
|
216
|
+
*/
|
|
217
|
+
export type HkFaceShellSlots = SlotsType<{
|
|
218
|
+
header?: (params: HkFaceShellHeaderSlot) => VNode[];
|
|
219
|
+
sidebar?: (params: HkFaceShellSidebarSlot) => VNode[];
|
|
220
|
+
userPanel?: (params: HkFaceShellUserPanelSlot) => VNode[];
|
|
221
|
+
content?: () => VNode[];
|
|
222
|
+
footer?: () => VNode[];
|
|
223
|
+
overlays?: () => VNode[];
|
|
224
|
+
}>;
|
|
225
|
+
|
|
171
226
|
export const HkFaceShell = defineComponent({
|
|
172
227
|
name: "HkFaceShell",
|
|
228
|
+
slots: Object as HkFaceShellSlots,
|
|
173
229
|
props: {
|
|
174
230
|
sidebarCollapsed: { type: Boolean, default: false },
|
|
175
231
|
sidebarWidth: { type: String, default: "224px" },
|
|
@@ -92,8 +92,10 @@
|
|
|
92
92
|
.hk-serpentine-hint {
|
|
93
93
|
// In-flow under the lane: an absolutely-positioned hint hung below the
|
|
94
94
|
// box got clipped by the confirmation window's padding (device feedback).
|
|
95
|
+
// The generous top padding keeps the copy clear of the lane stroke —
|
|
96
|
+
// a second device pass showed 8px reading as part of the graphic.
|
|
95
97
|
display: block;
|
|
96
|
-
padding: var(--space-
|
|
98
|
+
padding: var(--space-16, 16px) var(--space-12, 12px) var(--space-4, 4px);
|
|
97
99
|
text-align: center;
|
|
98
100
|
font-size: var(--text-xs, 0.75rem);
|
|
99
101
|
color: rgb(var(--color-muted));
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/* HkSupplementInset — the supplementary slot of a button surface.
|
|
2
|
+
*
|
|
3
|
+
* At rest the supplement takes NO space (the surface's own content stays
|
|
4
|
+
* exactly centred where the host put it). On reveal the supplement's
|
|
5
|
+
* column animates open — pushing the main content left — and the
|
|
6
|
+
* supplement content fades in. Everything rides the animation context
|
|
7
|
+
* (duration/ease tokens; reduced-motion users get the instant states).
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
.hk-supplement-inset {
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
min-width: 0;
|
|
14
|
+
max-width: 100%;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.hk-supplement-inset-main {
|
|
18
|
+
/* The main region takes the remaining space; as the supplement column
|
|
19
|
+
opens, it (and its centred content) is pushed left. */
|
|
20
|
+
flex: 1 1 auto;
|
|
21
|
+
min-width: 0;
|
|
22
|
+
display: inline-flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
justify-content: center;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.hk-supplement-inset-supplement {
|
|
28
|
+
/* The column collapses to 0 and animates to the measured content width
|
|
29
|
+
(--hk-supplement-w, set from a ResizeObserver on the inner) — the
|
|
30
|
+
horizontal twin of HkExpansionPanel's 0fr→1fr body trick, minus the
|
|
31
|
+
magic constant. visibility joins the collapse: an unrevealed
|
|
32
|
+
supplement is untabbable and out of the a11y tree (an opacity-only
|
|
33
|
+
hide leaks Tab stops). */
|
|
34
|
+
max-width: 0px;
|
|
35
|
+
opacity: 0;
|
|
36
|
+
overflow: hidden;
|
|
37
|
+
visibility: hidden;
|
|
38
|
+
display: inline-flex;
|
|
39
|
+
align-items: center;
|
|
40
|
+
transition: max-width var(--duration-normal) var(--ease-standard),
|
|
41
|
+
opacity var(--duration-short) ease,
|
|
42
|
+
visibility 0s linear var(--duration-normal);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.hk-supplement-inset-supplement-inner {
|
|
46
|
+
/* The inner keeps its max-content width (the measurement target) and
|
|
47
|
+
overflows the collapsed outer — a shrinkable flex item would measure
|
|
48
|
+
at min-content and clamp the reveal forever. Hence flex: none. */
|
|
49
|
+
flex: none;
|
|
50
|
+
display: inline-flex;
|
|
51
|
+
align-items: center;
|
|
52
|
+
gap: var(--space-4);
|
|
53
|
+
padding-inline-start: var(--space-4);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/* Reveal: the controlled prop, hovering, or holding focus inside the
|
|
57
|
+
inset. visibility flips immediately so the controls become focusable
|
|
58
|
+
the moment the reveal starts. */
|
|
59
|
+
.hk-supplement-inset[data-revealed] .hk-supplement-inset-supplement,
|
|
60
|
+
.hk-supplement-inset[data-hover-reveal]:not([data-closed]):hover .hk-supplement-inset-supplement,
|
|
61
|
+
.hk-supplement-inset[data-hover-reveal]:not([data-closed]):focus-within .hk-supplement-inset-supplement {
|
|
62
|
+
max-width: var(--hk-supplement-w, 32px);
|
|
63
|
+
opacity: 1;
|
|
64
|
+
visibility: visible;
|
|
65
|
+
transition: max-width var(--duration-normal) var(--ease-standard),
|
|
66
|
+
opacity var(--duration-short) ease,
|
|
67
|
+
visibility 0s linear 0s;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* The host's press-off state: forced closed even under hover/focus-within
|
|
71
|
+
(touch keeps sticky hover after a tap — without this the press-off would
|
|
72
|
+
be unobservable there). Hovering again after leaving re-reveals. */
|
|
73
|
+
.hk-supplement-inset[data-closed] .hk-supplement-inset-supplement {
|
|
74
|
+
max-width: 0px;
|
|
75
|
+
opacity: 0;
|
|
76
|
+
visibility: hidden;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@media (prefers-reduced-motion: reduce) {
|
|
80
|
+
.hk-supplement-inset-supplement {
|
|
81
|
+
transition: none;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
5
|
+
import { createApp, defineComponent, h, nextTick, ref } from "vue";
|
|
6
|
+
|
|
7
|
+
import HkSupplementInset from "./HkSupplementInset";
|
|
8
|
+
|
|
9
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
|
|
11
|
+
const mounts: Array<{ app: ReturnType<typeof createApp>; container: HTMLElement }> = [];
|
|
12
|
+
|
|
13
|
+
function mountInset(props: Record<string, unknown> = {}, slots?: Record<string, () => unknown>) {
|
|
14
|
+
const container = document.createElement("div");
|
|
15
|
+
document.body.appendChild(container);
|
|
16
|
+
const Host = defineComponent({
|
|
17
|
+
name: "InsetHost",
|
|
18
|
+
setup() {
|
|
19
|
+
return () =>
|
|
20
|
+
h(
|
|
21
|
+
HkSupplementInset,
|
|
22
|
+
{ ...props },
|
|
23
|
+
slots ?? {
|
|
24
|
+
default: () => h("span", { class: "probe-main" }, "main content"),
|
|
25
|
+
supplement: () => h("span", { class: "probe-supplement" }, "extra"),
|
|
26
|
+
},
|
|
27
|
+
);
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
const app = createApp(Host);
|
|
31
|
+
app.mount(container);
|
|
32
|
+
mounts.push({ app, container });
|
|
33
|
+
return { container, app };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
afterEach(() => {
|
|
37
|
+
for (const { app } of mounts.splice(0)) app.unmount();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe("HkSupplementInset", () => {
|
|
41
|
+
it("renders main and supplement regions as siblings of one surface", () => {
|
|
42
|
+
const { container } = mountInset();
|
|
43
|
+
expect(container.querySelector(".hk-supplement-inset-main .probe-main")).toBeTruthy();
|
|
44
|
+
expect(container.querySelector(".hk-supplement-inset-supplement-inner .probe-supplement")).toBeTruthy();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("the controlled `revealed` prop drives data-revealed", async () => {
|
|
48
|
+
const open = ref(false);
|
|
49
|
+
const Host = defineComponent({
|
|
50
|
+
setup() {
|
|
51
|
+
return () => h(HkSupplementInset, { revealed: open.value });
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
const container = document.createElement("div");
|
|
55
|
+
document.body.appendChild(container);
|
|
56
|
+
const app = createApp(Host);
|
|
57
|
+
app.mount(container);
|
|
58
|
+
const inset = container.querySelector<HTMLElement>(".hk-supplement-inset")!;
|
|
59
|
+
expect(inset.hasAttribute("data-revealed")).toBe(false);
|
|
60
|
+
open.value = true;
|
|
61
|
+
await nextTick();
|
|
62
|
+
expect(inset.hasAttribute("data-revealed")).toBe(true);
|
|
63
|
+
app.unmount();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("measures the supplement content into the animation width var", () => {
|
|
67
|
+
const { container } = mountInset();
|
|
68
|
+
const inset = container.querySelector<HTMLElement>(".hk-supplement-inset")!;
|
|
69
|
+
// happy-dom measures layout as 0, so assert the var EXISTS and is a px
|
|
70
|
+
// value (the ResizeObserver keeps it fresh in real browsers).
|
|
71
|
+
expect(inset.style.getPropertyValue("--hk-supplement-w")).toMatch(/px$/);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("the `closed` prop forces the supplement shut even while hovered", () => {
|
|
75
|
+
// Render with BOTH data-closed and data-hover-reveal (the press-off
|
|
76
|
+
// state on a surface the pointer is still over): the closed attr wins
|
|
77
|
+
// in CSS — assert the attribute wiring carries it.
|
|
78
|
+
const { container } = mountInset({ closed: true, revealOnHover: true });
|
|
79
|
+
const inset = container.querySelector<HTMLElement>(".hk-supplement-inset")!;
|
|
80
|
+
expect(inset.hasAttribute("data-closed")).toBe(true);
|
|
81
|
+
expect(inset.hasAttribute("data-hover-reveal")).toBe(true);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("omits the supplement region entirely when the slot is absent", () => {
|
|
85
|
+
const { container } = mountInset({}, { default: () => h("span", "main only") });
|
|
86
|
+
expect(container.querySelector(".hk-supplement-inset-supplement")).toBeNull();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("pins the reveal grammar in the stylesheet", () => {
|
|
90
|
+
const scss = readFileSync(join(here, "HkSupplementInset.scss"), "utf8");
|
|
91
|
+
// At rest: no space, hidden (untabbable, out of the a11y tree).
|
|
92
|
+
expect(scss).toMatch(
|
|
93
|
+
/\.hk-supplement-inset-supplement\s*{[^}]*max-width:\s*0px/,
|
|
94
|
+
);
|
|
95
|
+
expect(scss).toMatch(
|
|
96
|
+
/\.hk-supplement-inset-supplement\s*{[^}]*visibility:\s*hidden/,
|
|
97
|
+
);
|
|
98
|
+
// Reveal: the controlled prop, hover, and focus-within all flip it —
|
|
99
|
+
// visibility flips immediately, width/opacity animate.
|
|
100
|
+
expect(scss).toMatch(
|
|
101
|
+
/\.hk-supplement-inset\[data-revealed\] \.hk-supplement-inset-supplement,/,
|
|
102
|
+
);
|
|
103
|
+
expect(scss).toMatch(
|
|
104
|
+
/\.hk-supplement-inset\[data-hover-reveal\]:not\(\[data-closed\]\):hover \.hk-supplement-inset-supplement,/,
|
|
105
|
+
);
|
|
106
|
+
expect(scss).toMatch(
|
|
107
|
+
/\.hk-supplement-inset\[data-hover-reveal\]:not\(\[data-closed\]\):focus-within \.hk-supplement-inset-supplement\s*{[^}]*visibility:\s*visible/,
|
|
108
|
+
);
|
|
109
|
+
// The press-off state: forced closed even under hover/focus (a touch
|
|
110
|
+
// tap leaves sticky hover behind — without this the toggle-off is
|
|
111
|
+
// unobservable).
|
|
112
|
+
expect(scss).toMatch(
|
|
113
|
+
/\.hk-supplement-inset\[data-closed\] \.hk-supplement-inset-supplement\s*{[^}]*visibility:\s*hidden/,
|
|
114
|
+
);
|
|
115
|
+
// The measured width: the inner must NOT be a shrinkable flex item (it
|
|
116
|
+
// would measure at min-content and clamp the reveal forever).
|
|
117
|
+
expect(scss).toMatch(
|
|
118
|
+
/\.hk-supplement-inset-supplement-inner\s*{[^}]*\n\s*flex:\s*none;/,
|
|
119
|
+
);
|
|
120
|
+
expect(scss).toMatch(
|
|
121
|
+
/max-width:\s*var\(--hk-supplement-w,\s*32px\)/,
|
|
122
|
+
);
|
|
123
|
+
// The push: the main region takes the remaining space (so it is pushed
|
|
124
|
+
// left while the supplement opens).
|
|
125
|
+
expect(scss).toMatch(
|
|
126
|
+
/\.hk-supplement-inset-main\s*{[^}]*flex:\s*1 1 auto/,
|
|
127
|
+
);
|
|
128
|
+
// Animation-context control: tokens + reduced-motion instant states.
|
|
129
|
+
expect(scss).toMatch(
|
|
130
|
+
/transition:\s*max-width\s+var\(--duration-normal\)\s+var\(--ease-standard\)/,
|
|
131
|
+
);
|
|
132
|
+
expect(scss).toMatch(
|
|
133
|
+
/@media \(prefers-reduced-motion: reduce\)\s*{[^}]*\.hk-supplement-inset-supplement\s*{[^}]*transition:\s*none/s,
|
|
134
|
+
);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { defineComponent, onBeforeUnmount, onMounted, ref, watch, type VNodeChild } from "vue";
|
|
2
|
+
|
|
3
|
+
import "./HkSupplementInset.scss";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* HkSupplementInset — the supplementary slot of a button surface
|
|
7
|
+
* (2026-11-19 user direction: any button surface can mount such a
|
|
8
|
+
* supplement — a ⋯ menu button here, anything else there). At rest the
|
|
9
|
+
* supplement takes NO space, so the surface's own content stays exactly
|
|
10
|
+
* where the host put it (a lane reservation was what pushed the theme
|
|
11
|
+
* panel's auto option off-centre). On reveal the supplement's column
|
|
12
|
+
* animates open — the main content is pushed left — and the supplement
|
|
13
|
+
* content fades in; the whole thing rides the animation context
|
|
14
|
+
* (duration/ease tokens, reduced-motion gets instant states).
|
|
15
|
+
*
|
|
16
|
+
* Reveal sources:
|
|
17
|
+
* - `revealOnHover` (default on): hovering the inset or moving focus
|
|
18
|
+
* into it reveals, CSS-only;
|
|
19
|
+
* - the `revealed` prop (controlled): the host toggles it — the theme
|
|
20
|
+
* panel reveals on a click of the ALREADY-ACTIVE option (whose press
|
|
21
|
+
* is otherwise a no-op), which is also the touch path where hover
|
|
22
|
+
* does not exist.
|
|
23
|
+
*
|
|
24
|
+
* STRUCTURE CONTRACT: the main region and the supplement region are
|
|
25
|
+
* SIBLING controls inside one surface — a supplement control must not be
|
|
26
|
+
* nested inside the main button (a button cannot nest a button). Hosts
|
|
27
|
+
* compose:
|
|
28
|
+
*
|
|
29
|
+
* <HkSupplementInset revealed={open}>
|
|
30
|
+
* {{ default: <button>…</button> }}
|
|
31
|
+
* {{ supplement: <HkIconButton …/> }}
|
|
32
|
+
* </HkSupplementInset>
|
|
33
|
+
*
|
|
34
|
+
* HkTabs' attached trigger actions are the reference consumer (main =
|
|
35
|
+
* the option trigger, supplement = the ⋯).
|
|
36
|
+
*
|
|
37
|
+
* At rest the supplement is `visibility: hidden` (unfocused, out of the
|
|
38
|
+
* a11y tree); revealing flips visibility immediately while the width and
|
|
39
|
+
* opacity animate. The animation target width is measured from the
|
|
40
|
+
* supplement content (ResizeObserver → `--hk-supplement-w`), so hosts
|
|
41
|
+
* never declare a pixel.
|
|
42
|
+
*/
|
|
43
|
+
export default defineComponent({
|
|
44
|
+
name: "HkSupplementInset",
|
|
45
|
+
props: {
|
|
46
|
+
/** Controlled reveal (e.g. the host's click-toggle). Hover/focus
|
|
47
|
+
* reveal is independent (see `revealOnHover`). */
|
|
48
|
+
revealed: { type: Boolean, default: false },
|
|
49
|
+
/** The host's press-off state: forced closed even under hover/focus
|
|
50
|
+
* (a touch tap leaves sticky hover behind — without this the
|
|
51
|
+
* toggle-off would be unobservable). */
|
|
52
|
+
closed: { type: Boolean, default: false },
|
|
53
|
+
/** Reveal on hover / focus-within (CSS-only). Default on. */
|
|
54
|
+
revealOnHover: { type: Boolean, default: true },
|
|
55
|
+
},
|
|
56
|
+
setup(props, { slots }) {
|
|
57
|
+
const innerRef = ref<HTMLElement | null>(null);
|
|
58
|
+
/** The measured supplement content width — the animation's max-width
|
|
59
|
+
* target. Measurement (not a magic constant) keeps the mechanism
|
|
60
|
+
* content-agnostic; before the first measurement a safe fallback
|
|
61
|
+
* applies. */
|
|
62
|
+
const supplementWidth = ref(0);
|
|
63
|
+
|
|
64
|
+
let observer: ResizeObserver | null = null;
|
|
65
|
+
const measure = () => {
|
|
66
|
+
const el = innerRef.value;
|
|
67
|
+
// Layout pixels (offsetWidth ignores transforms — the strip's swap
|
|
68
|
+
// enter scales its cells, and a bbox read mid-transition would
|
|
69
|
+
// under-measure), +1 to cover the integer rounding floor.
|
|
70
|
+
if (el) supplementWidth.value = el.offsetWidth + 1;
|
|
71
|
+
};
|
|
72
|
+
onMounted(() => {
|
|
73
|
+
measure();
|
|
74
|
+
if (typeof ResizeObserver !== "undefined" && innerRef.value) {
|
|
75
|
+
observer = new ResizeObserver(() => measure());
|
|
76
|
+
observer.observe(innerRef.value);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
watch(innerRef, () => {
|
|
80
|
+
measure();
|
|
81
|
+
if (observer) {
|
|
82
|
+
observer.disconnect();
|
|
83
|
+
observer = null;
|
|
84
|
+
}
|
|
85
|
+
if (typeof ResizeObserver !== "undefined" && innerRef.value) {
|
|
86
|
+
observer = new ResizeObserver(() => measure());
|
|
87
|
+
observer.observe(innerRef.value);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
onBeforeUnmount(() => {
|
|
91
|
+
observer?.disconnect();
|
|
92
|
+
observer = null;
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
return () => (
|
|
96
|
+
<div
|
|
97
|
+
class="hk-supplement-inset"
|
|
98
|
+
data-revealed={props.revealed || undefined}
|
|
99
|
+
data-closed={props.closed || undefined}
|
|
100
|
+
data-hover-reveal={props.revealOnHover || undefined}
|
|
101
|
+
style={{ "--hk-supplement-w": `${supplementWidth.value}px` }}
|
|
102
|
+
>
|
|
103
|
+
<div class="hk-supplement-inset-main">{slots.default?.()}</div>
|
|
104
|
+
{slots.supplement ? (
|
|
105
|
+
<div class="hk-supplement-inset-supplement">
|
|
106
|
+
{/* The INNER is the measurement target: the outer carries the
|
|
107
|
+
collapsed max-width, the inner keeps its natural width. */}
|
|
108
|
+
<div class="hk-supplement-inset-supplement-inner" ref={innerRef}>
|
|
109
|
+
{(slots.supplement?.() ?? []) as VNodeChild}
|
|
110
|
+
</div>
|
|
111
|
+
</div>
|
|
112
|
+
) : null}
|
|
113
|
+
</div>
|
|
114
|
+
);
|
|
115
|
+
},
|
|
116
|
+
});
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
2
|
+
import { createApp, h } from "vue";
|
|
3
|
+
|
|
4
|
+
import { HkAdminTablePage, HkTable, type HkTableSection, type HkTableRow } from "../index";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The L38 row-typing contract. The old `rows: Record<string, unknown>[]`
|
|
8
|
+
* forced every interface-typed row array through a downstream assertion
|
|
9
|
+
* bridge (chest: 43 `tableRows(...)` sites); `rows: readonly HkTableRow[]`
|
|
10
|
+
* (object) accepts interfaces structurally. These pins hold both halves:
|
|
11
|
+
*
|
|
12
|
+
* - TYPE level (enforced by `pnpm build`, which typechecks this file): an
|
|
13
|
+
* interface row array — the exact shape that needed a bridge before —
|
|
14
|
+
* assigns to `rows` and to `HkTableSection.rows` with NO cast anywhere in
|
|
15
|
+
* this file; a `Record<string, unknown>[]` (the legacy bridge output)
|
|
16
|
+
* still assigns (existing call sites keep compiling).
|
|
17
|
+
* - RUNTIME level: interface rows render their column values through the
|
|
18
|
+
* internal `as Record` confinement casts (two, one per pipeline entry),
|
|
19
|
+
* and the row objects reaching cell slots are the consumer's own
|
|
20
|
+
* instances (reference identity — what chest's downstream
|
|
21
|
+
* `tableRows(arr) === arr` pin protects) is preserved by a copy-per-sort
|
|
22
|
+
* pipeline that never clones on input.
|
|
23
|
+
*
|
|
24
|
+
* (Repo test convention: raw createApp + document queries, no
|
|
25
|
+
* @vue/test-utils.)
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/** The bridge-needing shape: an interface (NO implicit index signature). */
|
|
29
|
+
interface PanelRow {
|
|
30
|
+
id: string;
|
|
31
|
+
label: string;
|
|
32
|
+
count: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const PANEL_COLUMNS = [
|
|
36
|
+
{ key: "label", title: "Label" },
|
|
37
|
+
{ key: "count", title: "Count" },
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
const mounts: Array<{ app: ReturnType<typeof createApp>; container: HTMLElement }> = [];
|
|
41
|
+
|
|
42
|
+
afterEach(() => {
|
|
43
|
+
while (mounts.length) {
|
|
44
|
+
const { app, container } = mounts.pop()!;
|
|
45
|
+
app.unmount();
|
|
46
|
+
container.remove();
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
function mountRows(rows: readonly HkTableRow[], sections?: HkTableSection[]): HTMLElement {
|
|
51
|
+
const container = document.createElement("div");
|
|
52
|
+
document.body.appendChild(container);
|
|
53
|
+
const app = createApp({
|
|
54
|
+
render: () => h(HkTable, { columns: PANEL_COLUMNS, rows, sections }),
|
|
55
|
+
});
|
|
56
|
+
app.mount(container);
|
|
57
|
+
mounts.push({ app, container });
|
|
58
|
+
return container;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
describe("HkTable row typing (L38)", () => {
|
|
62
|
+
it("accepts interface-typed rows without any bridge (type level pinned by vue-tsc on this file)", () => {
|
|
63
|
+
// No cast: this exact array needed `tableRows(rows)` before L38.
|
|
64
|
+
const rows: PanelRow[] = [
|
|
65
|
+
{ id: "a", label: "Alpha", count: 2 },
|
|
66
|
+
{ id: "b", label: "Beta", count: 5 },
|
|
67
|
+
];
|
|
68
|
+
const container = mountRows(rows);
|
|
69
|
+
expect(container.textContent).toContain("Alpha");
|
|
70
|
+
expect(container.textContent).toContain("Beta");
|
|
71
|
+
expect(container.textContent).toContain("5");
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("accepts interface-typed sections the same way (R3 M2 pin: the rows must be interface-typed ARRAYS, not inline literals)", () => {
|
|
75
|
+
// Inline section-row literals carry implicit index signatures and stay
|
|
76
|
+
// assignable to the OLD Record type too — this pin routes declared
|
|
77
|
+
// `PanelRow[]` consts through `sections` so reverting the widening in
|
|
78
|
+
// HkTableSection fails THIS file's compile (R3 mutation M2 survived
|
|
79
|
+
// the first version of this test for exactly that reason).
|
|
80
|
+
const oneRows: PanelRow[] = [{ id: "a", label: "Alpha", count: 1 }];
|
|
81
|
+
const twoRows: PanelRow[] = [{ id: "b", label: "Beta", count: 7 }];
|
|
82
|
+
const sections: HkTableSection[] = [
|
|
83
|
+
{ key: "one", label: "One", rows: oneRows },
|
|
84
|
+
{ key: "two", label: "Two", rows: twoRows },
|
|
85
|
+
];
|
|
86
|
+
const container = mountRows([], sections);
|
|
87
|
+
expect(container.textContent).toContain("One");
|
|
88
|
+
expect(container.textContent).toContain("Two");
|
|
89
|
+
expect(container.textContent).toContain("Alpha");
|
|
90
|
+
expect(container.textContent).toContain("7");
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("keeps accepting legacy Record-typed rows (existing bridge outputs stay assignable)", () => {
|
|
94
|
+
const legacy: Record<string, unknown>[] = [{ id: "x", label: "Legacy", count: 9 }];
|
|
95
|
+
const container = mountRows(legacy);
|
|
96
|
+
expect(container.textContent).toContain("Legacy");
|
|
97
|
+
expect(container.textContent).toContain("9");
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("HkTableRow is the object family root (interfaces and Records both count)", () => {
|
|
101
|
+
const rows: HkTableRow[] = [
|
|
102
|
+
{ id: "i", label: "Interface", count: 0 } satisfies PanelRow,
|
|
103
|
+
{ id: "r", label: "Record", count: 0 } as Record<string, unknown>,
|
|
104
|
+
];
|
|
105
|
+
expect(rows.length).toBe(2);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it("cell slots receive the consumer's own row instances (reference identity through the confinement casts)", () => {
|
|
109
|
+
// The slot fn's param is CONSUMER-annotated (chest's AvatarSourcesCard
|
|
110
|
+
// pattern); HkTable deliberately declares no slots type, so the
|
|
111
|
+
// annotation faces no contravariance constraint. The row objects ride
|
|
112
|
+
// the pipeline's copy-per-sort arrays BY REFERENCE — sorting copies the
|
|
113
|
+
// array, never the rows.
|
|
114
|
+
const seen: PanelRow[] = [];
|
|
115
|
+
const rows: PanelRow[] = [{ id: "a", label: "Alpha", count: 3 }];
|
|
116
|
+
const container = document.createElement("div");
|
|
117
|
+
document.body.appendChild(container);
|
|
118
|
+
const app = createApp({
|
|
119
|
+
render: () =>
|
|
120
|
+
h(
|
|
121
|
+
HkTable,
|
|
122
|
+
{ columns: PANEL_COLUMNS, rows },
|
|
123
|
+
{
|
|
124
|
+
"cell-count": ({ row, index }: { row: PanelRow; value: unknown; index: number }) => {
|
|
125
|
+
seen.push(row);
|
|
126
|
+
return h("span", {}, `${row.count}x@${index}`);
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
),
|
|
130
|
+
});
|
|
131
|
+
app.mount(container);
|
|
132
|
+
mounts.push({ app, container });
|
|
133
|
+
expect(container.textContent).toContain("Alpha");
|
|
134
|
+
expect(container.textContent).toContain("3x@0");
|
|
135
|
+
expect(seen[0]).toBe(rows[0]);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it("HkAdminTablePage accepts interface rows too (R5 S2 pin — it forwards rows verbatim to HkTable)", () => {
|
|
139
|
+
// HkAdminTablePage only reads `.length` and forwards `rows={props.rows}`
|
|
140
|
+
// to the widened HkTable, so its own prop must be the SAME family or
|
|
141
|
+
// every chest site routed through it keeps needing the bridge
|
|
142
|
+
// (MyTasksView-style: `interface UserTask` rows). Declared const, not
|
|
143
|
+
// an inline literal, so reverting THIS prop to Record fails the compile.
|
|
144
|
+
const pageRows: PanelRow[] = [
|
|
145
|
+
{ id: "a", label: "PageAlpha", count: 4 },
|
|
146
|
+
{ id: "b", label: "PageBeta", count: 6 },
|
|
147
|
+
];
|
|
148
|
+
const container = document.createElement("div");
|
|
149
|
+
document.body.appendChild(container);
|
|
150
|
+
const app = createApp({
|
|
151
|
+
render: () =>
|
|
152
|
+
h(HkAdminTablePage, {
|
|
153
|
+
title: "Panels",
|
|
154
|
+
columns: PANEL_COLUMNS,
|
|
155
|
+
rows: pageRows,
|
|
156
|
+
rowKey: "id",
|
|
157
|
+
}),
|
|
158
|
+
});
|
|
159
|
+
app.mount(container);
|
|
160
|
+
mounts.push({ app, container });
|
|
161
|
+
expect(container.textContent).toContain("PageAlpha");
|
|
162
|
+
expect(container.textContent).toContain("6");
|
|
163
|
+
});
|
|
164
|
+
});
|
|
@@ -48,9 +48,21 @@ export interface HkTableSection {
|
|
|
48
48
|
key: string;
|
|
49
49
|
/** Default band text; the `section` slot overrides the whole band content. */
|
|
50
50
|
label?: string;
|
|
51
|
-
rows:
|
|
51
|
+
rows: readonly HkTableRow[];
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
/**
|
|
55
|
+
* The row shape `HkTable` accepts (L38): any object, interfaces included.
|
|
56
|
+
* The old `Record<string, unknown>` forced every consumer whose rows are an
|
|
57
|
+
* `interface` (no implicit index signature) through a downstream assertion
|
|
58
|
+
* bridge — chest carried 43. Indexing is the library's business, not the
|
|
59
|
+
* consumer's, so the prop side is `object` and the ONE `as Record` cast per
|
|
60
|
+
* pipeline entry lives inside this file (search `L38 confinement`); the
|
|
61
|
+
* out-direction payloads (emits, `HkRowManageGate`) stay
|
|
62
|
+
* `Record<string, unknown>` so existing bridges keep compiling.
|
|
63
|
+
*/
|
|
64
|
+
export type HkTableRow = object;
|
|
65
|
+
|
|
54
66
|
/** A section's live display state: the sorted rows plus the flat offset
|
|
55
67
|
* its first row occupies in the concatenation of every section's rows
|
|
56
68
|
* (the index space `reorder` emits and selection walks). */
|
|
@@ -108,7 +120,7 @@ export default defineComponent({
|
|
|
108
120
|
name: "HkTable",
|
|
109
121
|
props: {
|
|
110
122
|
columns: { type: Array as PropType<Column[]>, required: true },
|
|
111
|
-
rows: { type: Array as PropType<
|
|
123
|
+
rows: { type: Array as PropType<readonly HkTableRow[]>, default: () => [] },
|
|
112
124
|
/** Grouped mode: when provided, `rows` is unused and the body renders
|
|
113
125
|
* ONE `<tbody class="hk-table-section-body">` per section, each led by
|
|
114
126
|
* a band row (`<th scope="rowgroup">`, `colspan` = total columns).
|
|
@@ -349,7 +361,7 @@ export default defineComponent({
|
|
|
349
361
|
});
|
|
350
362
|
}
|
|
351
363
|
|
|
352
|
-
const sortedRows = computed(() => sortRows(props.rows));
|
|
364
|
+
const sortedRows = computed(() => sortRows(props.rows as Record<string, unknown>[])); // ts-escape-ok: L38 confinement — the ONE cast on the unsectioned rows entry (interface rows carry no index signature; indexing is ours, not the consumer's)
|
|
353
365
|
|
|
354
366
|
/** The sectioned display plan: each section's rows sorted WITHIN the
|
|
355
367
|
* section, section order untouched, plus the flat offset its first row
|
|
@@ -359,7 +371,7 @@ export default defineComponent({
|
|
|
359
371
|
if (!props.sections) return [];
|
|
360
372
|
let offset = 0;
|
|
361
373
|
return props.sections.map((section, index) => {
|
|
362
|
-
const rows = sortRows(section.rows);
|
|
374
|
+
const rows = sortRows(section.rows as Record<string, unknown>[]); // ts-escape-ok: L38 confinement — the ONE cast on the sectioned rows entry
|
|
363
375
|
const view: SectionView = { section, index, rows, offset };
|
|
364
376
|
offset += rows.length;
|
|
365
377
|
return view;
|
|
@@ -132,16 +132,18 @@
|
|
|
132
132
|
flex: none;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
.hk-tabs-cell > .hk-
|
|
136
|
-
/*
|
|
137
|
-
|
|
135
|
+
.hk-tabs-cell > .hk-supplement-inset {
|
|
136
|
+
/* The inset fills the cell and owns the reveal: at rest its supplement
|
|
137
|
+
takes no space, so the option's own content stays exactly centred (a
|
|
138
|
+
reserved lane here was what pushed the auto option off-centre). */
|
|
139
|
+
width: 100%;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.hk-supplement-inset-main > .hk-tabs-trigger {
|
|
143
|
+
/* Fill the main region so the option's own content shifts left when the
|
|
144
|
+
supplement opens (the push); in a shrink-to-fit inline strip the
|
|
138
145
|
percentage resolves to the content size, so nothing changes there. */
|
|
139
146
|
width: 100%;
|
|
140
|
-
/* RESERVE the action lane. The overlay is absolutely positioned at the
|
|
141
|
-
inline end, so without this the revealed buttons sit ON the label's
|
|
142
|
-
last ~20px in a shrink-to-fit pill (clicks there would select the
|
|
143
|
-
option's own text and fire the action instead). */
|
|
144
|
-
padding-inline-end: calc(var(--space-12) + 18px);
|
|
145
147
|
}
|
|
146
148
|
|
|
147
149
|
/* block (row-filling) strips: the cell takes the growth its trigger
|
|
@@ -155,48 +157,8 @@
|
|
|
155
157
|
flex: 1 0 auto;
|
|
156
158
|
}
|
|
157
159
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
never shifts layout (the pill's width is the option's track, not
|
|
161
|
-
the content's). Hidden until hover/focus-within; on touch there is
|
|
162
|
-
no hover, so the reachable path is the option's contextMenu
|
|
163
|
-
long-press binding (pair the two when touch matters). */
|
|
164
|
-
position: absolute;
|
|
165
|
-
inset-inline-end: var(--space-4);
|
|
166
|
-
top: 50%;
|
|
167
|
-
transform: translateY(-50%);
|
|
168
|
-
display: inline-flex;
|
|
169
|
-
align-items: center;
|
|
170
|
-
/* `visibility: hidden` (not just opacity) keeps the unrevealed action
|
|
171
|
-
buttons OUT of the page tab order: an opacity-only hide leaves every
|
|
172
|
-
action focusable while invisible, which both leaks Tab stops and
|
|
173
|
-
contradicts the strip's roving-tabindex contract. `:focus-within`
|
|
174
|
-
reveals them, so a keyboard user tabs trigger → actions. */
|
|
175
|
-
visibility: hidden;
|
|
176
|
-
opacity: 0;
|
|
177
|
-
pointer-events: none;
|
|
178
|
-
/* PAINT ORDER: the trigger above carries z-index 1, so an auto-z
|
|
179
|
-
sibling would lose hit-testing everywhere the two overlap (which is
|
|
180
|
-
everywhere — the trigger fills the cell and the buttons sit inside
|
|
181
|
-
its box). One layer above the trigger puts the buttons back on top. */
|
|
182
|
-
z-index: 2;
|
|
183
|
-
transition: opacity var(--duration-short) ease,
|
|
184
|
-
visibility 0s linear var(--duration-short);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
.hk-tabs-cell:hover > .hk-tabs-trigger-actions,
|
|
188
|
-
.hk-tabs-cell:focus-within > .hk-tabs-trigger-actions {
|
|
189
|
-
visibility: visible;
|
|
190
|
-
opacity: 1;
|
|
191
|
-
pointer-events: auto;
|
|
192
|
-
transition: opacity var(--duration-short) ease,
|
|
193
|
-
visibility 0s linear 0s;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
/* A whole-strip disabled render has no live actions to reveal. */
|
|
197
|
-
.hk-tabs-cell[data-disabled] > .hk-tabs-trigger-actions {
|
|
198
|
-
display: none;
|
|
199
|
-
}
|
|
160
|
+
/* The supplement inset lives in the cell; its action buttons keep the
|
|
161
|
+
ghost-square grammar below (position-independent). */
|
|
200
162
|
|
|
201
163
|
.hk-tabs-trigger-action {
|
|
202
164
|
display: inline-flex;
|
|
@@ -415,7 +377,7 @@
|
|
|
415
377
|
@media (prefers-reduced-motion: reduce) {
|
|
416
378
|
.hk-tabs-trigger,
|
|
417
379
|
.hk-tabs-indicator,
|
|
418
|
-
.hk-
|
|
380
|
+
.hk-supplement-inset-supplement,
|
|
419
381
|
.hk-tabs-swap-enter-active,
|
|
420
382
|
.hk-tabs-swap-leave-active {
|
|
421
383
|
transition: none;
|
|
@@ -795,6 +795,69 @@ describe("HkTabs trigger corner badge", () => {
|
|
|
795
795
|
});
|
|
796
796
|
});
|
|
797
797
|
|
|
798
|
+
describe("HkTabs per-option context menu", () => {
|
|
799
|
+
it("opens the bound menu on right-click through the app-wide provider", async () => {
|
|
800
|
+
const onPick = vi.fn();
|
|
801
|
+
const container = document.createElement("div");
|
|
802
|
+
document.body.appendChild(container);
|
|
803
|
+
containers.push(container);
|
|
804
|
+
const Wrapper = defineComponent({
|
|
805
|
+
setup() {
|
|
806
|
+
return () =>
|
|
807
|
+
h(HkContextMenuProvider, null, {
|
|
808
|
+
default: () =>
|
|
809
|
+
h(HkTabs, {
|
|
810
|
+
modelValue: "a",
|
|
811
|
+
renderPanels: false,
|
|
812
|
+
tabs: [
|
|
813
|
+
{
|
|
814
|
+
key: "a",
|
|
815
|
+
label: "Alpha",
|
|
816
|
+
contextMenu: (point: { x: number; y: number }) => ({
|
|
817
|
+
x: point.x,
|
|
818
|
+
y: point.y,
|
|
819
|
+
title: "Alpha menu",
|
|
820
|
+
items: [{ key: "cfg", label: "Configure alpha" }],
|
|
821
|
+
onSelect: onPick,
|
|
822
|
+
}),
|
|
823
|
+
},
|
|
824
|
+
{ key: "b", label: "Beta" },
|
|
825
|
+
] as TabItem[],
|
|
826
|
+
}),
|
|
827
|
+
});
|
|
828
|
+
},
|
|
829
|
+
});
|
|
830
|
+
const app = createApp(Wrapper);
|
|
831
|
+
mounts.push(app);
|
|
832
|
+
app.mount(container);
|
|
833
|
+
await nextTick();
|
|
834
|
+
const trigger = container.querySelectorAll<HTMLElement>(".hk-tabs-trigger")[0]!;
|
|
835
|
+
trigger.dispatchEvent(new MouseEvent("contextmenu", { bubbles: true, cancelable: true, clientX: 12, clientY: 12 }));
|
|
836
|
+
await nextTick();
|
|
837
|
+
expect(document.querySelector(".hk-select-popout")).toBeTruthy();
|
|
838
|
+
const row = Array.from(document.querySelectorAll<HTMLButtonElement>(".hk-menu-row"))
|
|
839
|
+
.find((r) => r.textContent?.includes("Configure alpha"));
|
|
840
|
+
expect(row).toBeTruthy();
|
|
841
|
+
row!.click();
|
|
842
|
+
await nextTick();
|
|
843
|
+
expect(onPick).toHaveBeenCalledTimes(1);
|
|
844
|
+
const event = new MouseEvent("contextmenu", { bubbles: true, cancelable: true, clientX: 12, clientY: 12 });
|
|
845
|
+
trigger.dispatchEvent(event);
|
|
846
|
+
await nextTick();
|
|
847
|
+
expect(event.defaultPrevented).toBe(true);
|
|
848
|
+
});
|
|
849
|
+
|
|
850
|
+
it("defers outward when the option carries no contextMenu (event untouched)", async () => {
|
|
851
|
+
const { container } = mountTabs({ variant: "segmented" });
|
|
852
|
+
const trigger = container.querySelectorAll<HTMLElement>(".hk-tabs-trigger")[0]!;
|
|
853
|
+
const event = new MouseEvent("contextmenu", { bubbles: true, cancelable: true, clientX: 4, clientY: 4 });
|
|
854
|
+
trigger.dispatchEvent(event);
|
|
855
|
+
await nextTick();
|
|
856
|
+
expect(event.defaultPrevented).toBe(false);
|
|
857
|
+
expect(document.querySelector(".hk-select-popout")).toBeNull();
|
|
858
|
+
});
|
|
859
|
+
});
|
|
860
|
+
|
|
798
861
|
describe("HkTabs caption-band drag opt-out (2026-11-12)", () => {
|
|
799
862
|
// A caption-band ancestor may be a DEEP Tauri drag region, and the scroller
|
|
800
863
|
// pans overflowing strips with its own pointer sweep — the two gestures
|
|
@@ -854,6 +917,64 @@ describe("HkTabs attached trigger actions (2026-11-19)", () => {
|
|
|
854
917
|
expect(action.getAttribute("data-test")).toBe("hk-tabs-action-a-dot");
|
|
855
918
|
});
|
|
856
919
|
|
|
920
|
+
it("reveals the supplement on a press of the ALREADY-ACTIVE option (touch path)", async () => {
|
|
921
|
+
// Pressing the active option is a no-op selection-wise; with actions
|
|
922
|
+
// attached that press toggles the supplement instead — the click/tap
|
|
923
|
+
// reveal path (hover is the pointer path).
|
|
924
|
+
const onSelect = vi.fn();
|
|
925
|
+
const { container, setActive } = mountWithOptions(
|
|
926
|
+
[{ key: "a", label: "Alpha", actions: [{ key: "dot", label: "Configure alpha", onSelect }] }],
|
|
927
|
+
{ modelValue: "a", variant: "segmented" },
|
|
928
|
+
);
|
|
929
|
+
void setActive;
|
|
930
|
+
await nextTick();
|
|
931
|
+
const inset = container.querySelector<HTMLElement>(".hk-supplement-inset")!;
|
|
932
|
+
expect(inset).toBeTruthy();
|
|
933
|
+
expect(inset.hasAttribute("data-revealed")).toBe(false);
|
|
934
|
+
const trigger = container.querySelector<HTMLElement>(".hk-tabs-trigger")!;
|
|
935
|
+
trigger.click();
|
|
936
|
+
await nextTick();
|
|
937
|
+
expect(inset.hasAttribute("data-revealed"), "the press reveals the supplement").toBe(true);
|
|
938
|
+
// Press again: toggles to the CLOSED state — the attribute wiring is
|
|
939
|
+
// data-closed (which the CSS lets beat hover; a mere data-revealed
|
|
940
|
+
// removal would be masked by sticky hover). A revert to the old
|
|
941
|
+
// set-toggle (no closed state) fails this.
|
|
942
|
+
trigger.click();
|
|
943
|
+
await nextTick();
|
|
944
|
+
expect(inset.hasAttribute("data-revealed")).toBe(false);
|
|
945
|
+
expect(inset.hasAttribute("data-closed"), "the press-off state is explicit").toBe(true);
|
|
946
|
+
// Third press: re-opens.
|
|
947
|
+
trigger.click();
|
|
948
|
+
await nextTick();
|
|
949
|
+
expect(inset.hasAttribute("data-revealed")).toBe(true);
|
|
950
|
+
expect(inset.hasAttribute("data-closed")).toBe(false);
|
|
951
|
+
// And the selection never moved (the active option re-selected nothing).
|
|
952
|
+
expect(onSelect).not.toHaveBeenCalled();
|
|
953
|
+
});
|
|
954
|
+
|
|
955
|
+
it("closes a click-revealed supplement when the selection moves", async () => {
|
|
956
|
+
const onSelect = vi.fn();
|
|
957
|
+
const { container, setActive } = mountWithOptions(
|
|
958
|
+
[
|
|
959
|
+
{ key: "a", label: "Alpha", actions: [{ key: "dot", label: "Configure alpha", onSelect }] },
|
|
960
|
+
{ key: "b", label: "Beta" },
|
|
961
|
+
],
|
|
962
|
+
{ modelValue: "a", variant: "segmented" },
|
|
963
|
+
);
|
|
964
|
+
const inset = container.querySelector<HTMLElement>(".hk-supplement-inset")!;
|
|
965
|
+
const trigger = container.querySelector<HTMLElement>(".hk-tabs-trigger")!;
|
|
966
|
+
trigger.click();
|
|
967
|
+
await nextTick();
|
|
968
|
+
expect(inset.hasAttribute("data-revealed")).toBe(true);
|
|
969
|
+
setActive("b");
|
|
970
|
+
await nextTick();
|
|
971
|
+
await nextTick();
|
|
972
|
+
expect(
|
|
973
|
+
container.querySelector(".hk-supplement-inset")!.hasAttribute("data-revealed"),
|
|
974
|
+
"moving the selection closes the reveal",
|
|
975
|
+
).toBe(false);
|
|
976
|
+
});
|
|
977
|
+
|
|
857
978
|
it("renders plain options without a cell (no anatomy change)", () => {
|
|
858
979
|
const onSelect = vi.fn();
|
|
859
980
|
const { container } = mountWithOptions([
|
|
@@ -1230,91 +1351,19 @@ describe("HkTabs attached trigger actions (2026-11-19)", () => {
|
|
|
1230
1351
|
expect(indicator.style.width, "the cell's width").toBe("50px");
|
|
1231
1352
|
});
|
|
1232
1353
|
|
|
1233
|
-
it("pins the
|
|
1354
|
+
it("pins the supplement-inset grammar and the absent lane (off-centre fix)", () => {
|
|
1234
1355
|
const scss = readFileSync(join(here, "HkTabs.scss"), "utf8");
|
|
1235
|
-
//
|
|
1236
|
-
|
|
1237
|
-
expect(scss).toMatch(/\.hk-tabs-cell
|
|
1238
|
-
|
|
1239
|
-
//
|
|
1240
|
-
expect(scss).toMatch(/\.hk-tabs-
|
|
1356
|
+
// THE OFF-CENTRE FIX: no lane reservation on the trigger — at rest the
|
|
1357
|
+
// supplement takes no space and the option's own content stays centred.
|
|
1358
|
+
expect(scss).not.toMatch(/\.hk-tabs-cell > \.hk-tabs-trigger[^}]*padding-inline-end/);
|
|
1359
|
+
// The inset fills the cell; the trigger fills the main region (so the
|
|
1360
|
+
// push shifts its content).
|
|
1361
|
+
expect(scss).toMatch(/\.hk-tabs-cell > \.hk-supplement-inset\s*{[^}]*width:\s*100%/);
|
|
1362
|
+
expect(scss).toMatch(/\.hk-supplement-inset-main > \.hk-tabs-trigger\s*{[^}]*width:\s*100%/);
|
|
1241
1363
|
// The cell is the slot-unit grid child (the trigger is not).
|
|
1242
1364
|
expect(scss).toMatch(/\[data-slots\] > \.hk-tabs-cell/);
|
|
1243
|
-
// The
|
|
1244
|
-
|
|
1245
|
-
// not the option). The lane is list padding (12px) + the overlay's own
|
|
1246
|
-
// footprint (20px button; the inset cancels against the trigger's own
|
|
1247
|
-
// edge padding) — pin the magnitude so a shrunken calc cannot pass.
|
|
1248
|
-
expect(scss).toMatch(
|
|
1249
|
-
/\.hk-tabs-cell > \.hk-tabs-trigger\s*{[^}]*padding-inline-end:\s*calc\(var\(--space-12\) \+ 18px\)/,
|
|
1250
|
-
);
|
|
1251
|
-
// The cell anchors the overlay (positioned ancestor).
|
|
1252
|
-
expect(scss).toMatch(/\.hk-tabs-cell\s*{[^}]*position:\s*relative/);
|
|
1253
|
-
// Unrevealed actions stay OUT of the page tab order (visibility,
|
|
1254
|
-
// not just opacity) or every action leaks a Tab stop per option.
|
|
1255
|
-
expect(scss).toMatch(/\.hk-tabs-trigger-actions\s*{[^}]*visibility:\s*hidden/);
|
|
1256
|
-
// PAINT ORDER: the trigger carries z-index 1, so the action layer must
|
|
1257
|
-
// sit ABOVE it — an auto-z sibling loses hit-testing everywhere the two
|
|
1258
|
-
// overlap (the buttons are inside the trigger's box), which makes every
|
|
1259
|
-
// ⋯ unclickable while looking fine in a layout-free test.
|
|
1260
|
-
expect(scss).toMatch(/\.hk-tabs-trigger-actions\s*{[^}]*z-index:\s*2/);
|
|
1261
|
-
expect(scss).toMatch(/\.hk-tabs-trigger\s*{[^}]*z-index:\s*1/);
|
|
1262
|
-
// Reduced-motion lands on the reveal too.
|
|
1263
|
-
expect(scss).toMatch(/\.hk-tabs-trigger-actions,\s*\n\s*\.hk-tabs-swap-enter-active/);
|
|
1264
|
-
});
|
|
1265
|
-
});
|
|
1266
|
-
|
|
1267
|
-
describe("HkTabs per-option context menu (2026-11-19)", () => {
|
|
1268
|
-
it("opens the bound menu on right-click through the app-wide provider", async () => {
|
|
1269
|
-
const onPick = vi.fn();
|
|
1270
|
-
const container = document.createElement("div");
|
|
1271
|
-
document.body.appendChild(container);
|
|
1272
|
-
containers.push(container);
|
|
1273
|
-
const Wrapper = defineComponent({
|
|
1274
|
-
setup() {
|
|
1275
|
-
return () =>
|
|
1276
|
-
h(HkContextMenuProvider, null, {
|
|
1277
|
-
default: () =>
|
|
1278
|
-
h(HkTabs, {
|
|
1279
|
-
modelValue: "a",
|
|
1280
|
-
renderPanels: false,
|
|
1281
|
-
tabs: [
|
|
1282
|
-
{
|
|
1283
|
-
key: "a",
|
|
1284
|
-
label: "Alpha",
|
|
1285
|
-
contextMenu: (point: { x: number; y: number }) => ({
|
|
1286
|
-
x: point.x,
|
|
1287
|
-
y: point.y,
|
|
1288
|
-
title: "Alpha menu",
|
|
1289
|
-
items: [{ key: "cfg", label: "Configure alpha" }],
|
|
1290
|
-
onSelect: onPick,
|
|
1291
|
-
}),
|
|
1292
|
-
},
|
|
1293
|
-
{ key: "b", label: "Beta" },
|
|
1294
|
-
] as TabItem[],
|
|
1295
|
-
}),
|
|
1296
|
-
});
|
|
1297
|
-
},
|
|
1298
|
-
});
|
|
1299
|
-
const app = createApp(Wrapper);
|
|
1300
|
-
mounts.push(app);
|
|
1301
|
-
app.mount(container);
|
|
1302
|
-
await nextTick();
|
|
1303
|
-
const trigger = container.querySelectorAll<HTMLElement>(".hk-tabs-trigger")[0]!;
|
|
1304
|
-
trigger.dispatchEvent(new MouseEvent("contextmenu", { bubbles: true, cancelable: true, clientX: 12, clientY: 12 }));
|
|
1305
|
-
await nextTick();
|
|
1306
|
-
expect(document.querySelector(".hk-select-popout")).toBeTruthy();
|
|
1307
|
-
const row = Array.from(document.querySelectorAll<HTMLButtonElement>(".hk-menu-row"))
|
|
1308
|
-
.find((r) => r.textContent?.includes("Configure alpha"));
|
|
1309
|
-
expect(row).toBeTruthy();
|
|
1310
|
-
row!.click();
|
|
1311
|
-
await nextTick();
|
|
1312
|
-
expect(onPick).toHaveBeenCalledTimes(1);
|
|
1313
|
-
// The binding preventDefaults — the platform menu is gone on re-click too.
|
|
1314
|
-
const event = new MouseEvent("contextmenu", { bubbles: true, cancelable: true, clientX: 12, clientY: 12 });
|
|
1315
|
-
trigger.dispatchEvent(event);
|
|
1316
|
-
await nextTick();
|
|
1317
|
-
expect(event.defaultPrevented).toBe(true);
|
|
1365
|
+
// The cell anchors nothing anymore — the overlay grammar is gone.
|
|
1366
|
+
expect(scss).not.toContain("hk-tabs-trigger-actions");
|
|
1318
1367
|
});
|
|
1319
1368
|
|
|
1320
1369
|
it("serves the CURRENT option closure after a rebuilt option list", async () => {
|
|
@@ -7,6 +7,7 @@ import HkHoverRevealAction from "./HkHoverRevealAction";
|
|
|
7
7
|
import HkIconButton from "./HkIconButton";
|
|
8
8
|
import HkTransitionContainer from "./HkTransitionContainer";
|
|
9
9
|
import HkCornerBadge from "./HkCornerBadge";
|
|
10
|
+
import HkSupplementInset from "./HkSupplementInset";
|
|
10
11
|
import type { CornerBadgePlacement, CornerBadgeVariant } from "./HkCornerBadge";
|
|
11
12
|
import { iconByName } from "../composables/iconRegistry";
|
|
12
13
|
import { useI18n } from "../i18n/context";
|
|
@@ -290,6 +291,13 @@ export default defineComponent({
|
|
|
290
291
|
* positioned ancestor, so the button's own offsets would be
|
|
291
292
|
* cell-relative and break the indicator math). */
|
|
292
293
|
const cellRefs = ref<Map<number, HTMLElement>>(new Map());
|
|
294
|
+
/** The press state of attached supplements per option key: pressing an
|
|
295
|
+
* ALREADY-ACTIVE option is a no-op selection-wise, so with actions
|
|
296
|
+
* attached that press toggles the supplement — 'open' forces it open,
|
|
297
|
+
* 'closed' forces it shut (even under the sticky hover a touch tap
|
|
298
|
+
* leaves behind), no entry = hover-follow. Cleared when the selection
|
|
299
|
+
* moves; pruned when options leave the strip. */
|
|
300
|
+
const supplementStates = ref<Map<string, "open" | "closed">>(new Map());
|
|
293
301
|
const indicatorStyle = ref<Record<string, string>>({});
|
|
294
302
|
/** The indicator fades in once real geometry first lands (no pop-in
|
|
295
303
|
* on mount), then slides via its left/width transition. */
|
|
@@ -584,11 +592,29 @@ export default defineComponent({
|
|
|
584
592
|
unbindAllContextMenus();
|
|
585
593
|
});
|
|
586
594
|
|
|
587
|
-
watch(() => props.modelValue, () =>
|
|
595
|
+
watch(() => props.modelValue, () => {
|
|
596
|
+
// A pressed-open supplement belongs to the option the user was
|
|
597
|
+
// interacting with; once the selection moves, it closes.
|
|
598
|
+
if (supplementStates.value.size) {
|
|
599
|
+
supplementStates.value = new Map();
|
|
600
|
+
}
|
|
601
|
+
nextTick(refreshGeometry);
|
|
602
|
+
});
|
|
588
603
|
|
|
589
604
|
watch(() => props.tabs, () => {
|
|
590
605
|
triggerRefs.value.clear();
|
|
591
606
|
cellRefs.value.clear();
|
|
607
|
+
// Supplements of options that left the strip — or collapsed into a
|
|
608
|
+
// merged run (props.tabs keeps those keys; they just stop rendering)
|
|
609
|
+
// — are dead state: a later un-merge must not re-open a stale reveal.
|
|
610
|
+
const live = new Set(
|
|
611
|
+
props.tabs.filter((tb) => !mergeSet.value.has(tb.key)).map((tb) => tb.key),
|
|
612
|
+
);
|
|
613
|
+
if (supplementStates.value.size) {
|
|
614
|
+
for (const key of [...supplementStates.value.keys()]) {
|
|
615
|
+
if (!live.has(key)) supplementStates.value.delete(key);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
592
618
|
nextTick(refreshGeometry);
|
|
593
619
|
}, { deep: true });
|
|
594
620
|
|
|
@@ -785,7 +811,18 @@ export default defineComponent({
|
|
|
785
811
|
tabindex={active || idx === fallbackTabbableIdx.value ? undefined : -1}
|
|
786
812
|
disabled={props.disabled || disabled}
|
|
787
813
|
onClick={() => {
|
|
788
|
-
if (
|
|
814
|
+
if (props.disabled || disabled) return;
|
|
815
|
+
if (tab.key !== props.modelValue) {
|
|
816
|
+
emit("update:modelValue", tab.key);
|
|
817
|
+
} else if (actions?.length) {
|
|
818
|
+
// Re-pressing the active option toggles its supplement —
|
|
819
|
+
// the click/tap reveal path (hover is the pointer path).
|
|
820
|
+
const cycle = (state: "open" | "closed" | undefined): "open" | "closed" =>
|
|
821
|
+
state === "open" ? "closed" : "open";
|
|
822
|
+
const next = new Map(supplementStates.value);
|
|
823
|
+
next.set(tab.key, cycle(supplementStates.value.get(tab.key)));
|
|
824
|
+
supplementStates.value = next;
|
|
825
|
+
}
|
|
789
826
|
}}
|
|
790
827
|
>
|
|
791
828
|
{(() => {
|
|
@@ -833,6 +870,14 @@ export default defineComponent({
|
|
|
833
870
|
</button>
|
|
834
871
|
);
|
|
835
872
|
if (actions) {
|
|
873
|
+
// The attached actions ride the supplement inset: at rest it takes
|
|
874
|
+
// NO space (the option's own content stays exactly centred — the
|
|
875
|
+
// old lane reservation pushed it off-centre); on reveal it
|
|
876
|
+
// animates open, pushing the content left, and the controls fade
|
|
877
|
+
// in. The action buttons are SIBLINGS of the trigger (a button
|
|
878
|
+
// cannot nest a button) inside the inset's supplement region.
|
|
879
|
+
const state = supplementStates.value.get(tab.key);
|
|
880
|
+
const isRevealed = state === "open";
|
|
836
881
|
listChildren.push(
|
|
837
882
|
<div
|
|
838
883
|
key={tab.key}
|
|
@@ -846,31 +891,27 @@ export default defineComponent({
|
|
|
846
891
|
data-disabled={props.disabled || disabled || undefined}
|
|
847
892
|
style={{ "--hk-tabs-span": String(slotSpan(tab)) }}
|
|
848
893
|
>
|
|
849
|
-
{
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
{(action.icon != null ? action.icon : <Ellipsis size={14} />) as VNodeChild}
|
|
871
|
-
</button>
|
|
872
|
-
))}
|
|
873
|
-
</span>
|
|
894
|
+
<HkSupplementInset closed={state === "closed"} revealed={isRevealed}>
|
|
895
|
+
{{
|
|
896
|
+
default: () => trigger,
|
|
897
|
+
supplement: () => actions.map((action) => (
|
|
898
|
+
<button
|
|
899
|
+
key={action.key}
|
|
900
|
+
type="button"
|
|
901
|
+
class="hk-tabs-trigger-action"
|
|
902
|
+
title={action.label}
|
|
903
|
+
aria-label={action.label}
|
|
904
|
+
data-test={`hk-tabs-action-${tab.key}-${action.key}`}
|
|
905
|
+
disabled={props.disabled || disabled || action.disabled || undefined}
|
|
906
|
+
onClick={() => {
|
|
907
|
+
if (!props.disabled && !disabled && !action.disabled) action.onSelect();
|
|
908
|
+
}}
|
|
909
|
+
>
|
|
910
|
+
{(action.icon != null ? action.icon : <Ellipsis size={14} />) as VNodeChild}
|
|
911
|
+
</button>
|
|
912
|
+
)),
|
|
913
|
+
}}
|
|
914
|
+
</HkSupplementInset>
|
|
874
915
|
</div>,
|
|
875
916
|
);
|
|
876
917
|
} else {
|
package/src/index.ts
CHANGED
|
@@ -39,6 +39,7 @@ export { default as HEmptyState } from "./components/HkEmptyState";
|
|
|
39
39
|
export { default as HStepGuide } from "./components/HkStepGuide";
|
|
40
40
|
export type { StepGuideItem } from "./components/HkStepGuide";
|
|
41
41
|
export { default as HExpansionPanel } from "./components/HkExpansionPanel";
|
|
42
|
+
export { default as HSupplementInset } from "./components/HkSupplementInset";
|
|
42
43
|
export { default as HFab, type HFabAction } from "./components/HkFab";
|
|
43
44
|
export { default as HIcon } from "./components/HkIcon";
|
|
44
45
|
export { default as HIconButton } from "./components/HkIconButton";
|
|
@@ -967,8 +968,9 @@ export { default as HkSlider } from "./components/HkSlider";
|
|
|
967
968
|
export { default as HkTokenInput, compactTokenCount, type TokenUnit } from "./components/HkTokenInput";
|
|
968
969
|
export { default as HkSliderField } from "./components/HkSliderField";
|
|
969
970
|
export { default as HkSpinner } from "./components/HkSpinner";
|
|
971
|
+
export { default as HkSupplementInset } from "./components/HkSupplementInset";
|
|
970
972
|
export { default as HkSwitch } from "./components/HkSwitch";
|
|
971
|
-
export { default as HkTable, type HkRowManageGate, type HkTableSection } from "./components/HkTable";
|
|
973
|
+
export { default as HkTable, type HkRowManageGate, type HkTableRow, type HkTableSection } from "./components/HkTable";
|
|
972
974
|
export { default as HkTabs } from "./components/HkTabs";
|
|
973
975
|
export { default as HkTag } from "./components/HkTag";
|
|
974
976
|
export { default as HkTextarea } from "./components/HkTextarea";
|
|
@@ -1066,7 +1068,9 @@ export { HkErrorLanding as HkErrorLanding } from "./components/HkErrorLanding";
|
|
|
1066
1068
|
export { HkErrorReportingOverlay as HkErrorReportingOverlay } from "./errorReporting";
|
|
1067
1069
|
export { HkAdminShell as HkAdminShell } from "./components/HkAdminShell";
|
|
1068
1070
|
export { HkFaceShell as HkFaceShell } from "./components/HkFaceShell";
|
|
1071
|
+
export type { HkFaceShellHeaderSlot, HkFaceShellSidebarSlot, HkFaceShellUserPanelSlot, HkFaceShellSlots } from "./components/HkFaceShell";
|
|
1069
1072
|
export { HkAdminHeader as HkAdminHeader } from "./components/HkAdminHeader";
|
|
1073
|
+
export type { HkAdminHeaderAvatarModalSlot, HkAdminHeaderSlots } from "./components/HkAdminHeader";
|
|
1070
1074
|
export { HkAvatarButton as HkAvatarButton } from "./components/HkAvatarButton";
|
|
1071
1075
|
export { HkNavSidebar as HkNavSidebar } from "./components/HkNavSidebar";
|
|
1072
1076
|
export { HkThemeToggle as HkThemeToggle } from "./components/HkThemeToggle";
|