@celestia-island/hikari 0.55.477 → 0.55.479
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/dist/types/components/HkMenu.d.ts +5 -0
- package/dist/types/composables/useRailIconFlight.d.ts +14 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/HkAdminShell.test.tsx +35 -13
- package/src/components/HkFaceShell.rail.test.tsx +67 -0
- package/src/components/HkFaceShell.tsx +29 -3
- package/src/components/HkMenu.rail.test.tsx +40 -1
- package/src/components/HkMenu.tsx +21 -3
- package/src/components/HkPillToggleGroup.test.tsx +78 -1
- package/src/components/HkScrollContainer.test.ts +85 -0
- package/src/components/HkScrollContainer.tsx +63 -4
- package/src/components/HkSidebarRail.scss +23 -0
- package/src/composables/useOptionStrip.ts +20 -3
- package/src/composables/useRailIconFlight.test.ts +37 -0
- package/src/composables/useRailIconFlight.ts +52 -9
- package/src/index.ts +9 -0
- package/src/wasm/highlight/hikari_wasm_highlight.js +1 -1
- package/src/wasm/mermaid/hikari_wasm_mermaid.js +1 -1
|
@@ -32,6 +32,11 @@ export interface HkMenuItem {
|
|
|
32
32
|
key: string;
|
|
33
33
|
label: string;
|
|
34
34
|
icon?: Component;
|
|
35
|
+
/** Marks the icon as a MARK (dot, bullet, status pip) rather than an
|
|
36
|
+
* illustration: the rail flip still TRAVELS it to its new position but
|
|
37
|
+
* never tweens its size — a dot's size is its meaning, and growing it
|
|
38
|
+
* across the flip reads as a glitch (2026-11-24 user direction). */
|
|
39
|
+
iconNoScale?: boolean;
|
|
35
40
|
flag?: string;
|
|
36
41
|
checked?: boolean;
|
|
37
42
|
disabled?: boolean;
|
|
@@ -70,6 +70,16 @@
|
|
|
70
70
|
* 4. Non-participating icons (identity blocks, group carets, badge
|
|
71
71
|
* dots), the pills, and the labels crossfade exactly as before.
|
|
72
72
|
*
|
|
73
|
+
* 4a. NO-SCALE GLYPHS (2026-11-24 user direction): a MARK — a dot, a
|
|
74
|
+
* bullet, a status pip — is not an illustration that happens to be
|
|
75
|
+
* small; its size IS its meaning, and tweening it reads as a glitch
|
|
76
|
+
* ("the dot balloons, then shrinks back"). Such cells carry
|
|
77
|
+
* `data-flip-noscale`, and the flight then travels the clone at the
|
|
78
|
+
* DESTINATION's size from the first frame — position continues, size
|
|
79
|
+
* never moves. Measured per pair (either end may opt in), because the
|
|
80
|
+
* two generations are different DOM and a row can gain or lose the
|
|
81
|
+
* mark between densities.
|
|
82
|
+
*
|
|
73
83
|
* TIMING IS TOKEN-DERIVED, NOT HARDCODED (2026-11-02 user direction):
|
|
74
84
|
* the flight window reads the theme's `--duration-normal` off the swap
|
|
75
85
|
* host's computed style — the very variable HkCrossfade's dissolve
|
|
@@ -102,6 +112,10 @@
|
|
|
102
112
|
*/
|
|
103
113
|
/** Row-key attribute on an icon cell that flies across a rail flip. */
|
|
104
114
|
export declare const RAIL_FLIP_ICON_ATTR = "data-flip-icon";
|
|
115
|
+
/** Marks a flying icon cell whose GLYPH must not tween: it still travels
|
|
116
|
+
* to the destination (the motion is the point) but keeps its own size the
|
|
117
|
+
* whole way. See the "no-scale glyphs" note in the mechanism doc. */
|
|
118
|
+
export declare const RAIL_FLIP_NOSCALE_ATTR = "data-flip-noscale";
|
|
105
119
|
/** Host attribute marking a flight in progress (drives the hide rule). */
|
|
106
120
|
export declare const RAIL_FLIP_ACTIVE_ATTR = "data-flipping";
|
|
107
121
|
/** Per-cell mark stamped on exactly the LEAVING icons that were paired
|
package/dist/types/index.d.ts
CHANGED
|
@@ -203,6 +203,7 @@ export { extOf, isImageFile, isAudioFile, codeLanguage, isCodeFile, isArchiveFil
|
|
|
203
203
|
export { useReducedMotion } from "./composables/useReducedMotion";
|
|
204
204
|
export { useSidebarRail, SIDEBAR_RAIL_PEEK_DELAY, SIDEBAR_RAIL_PEEK_GRACE, SIDEBAR_RAIL_PIN_FALLBACK, SIDEBAR_RAIL_CLIP_SELECTOR, SIDEBAR_RAIL_TOGGLE_BUTTON_SELECTOR, } from "./composables/useSidebarRail";
|
|
205
205
|
export type { SidebarRailOptions, SidebarRailHandle } from "./composables/useSidebarRail";
|
|
206
|
+
export { RAIL_FLIP_ICON_ATTR, RAIL_FLIP_FLYING_ATTR, RAIL_FLIP_NOSCALE_ATTR, } from "./composables/useRailIconFlight";
|
|
206
207
|
export { provideMenuGroupState, useMenuGroupState, } from "./composables/useMenuGroupState";
|
|
207
208
|
export type { MenuGroupState } from "./composables/useMenuGroupState";
|
|
208
209
|
export { drawnScale, frameMetrics, frameScale, laidOffsetWithin, laidSize, layoutOffset, layoutRect, nearestLaidAncestor, placePoint, } from "./composables/layoutGeometry";
|
package/package.json
CHANGED
|
@@ -61,6 +61,16 @@ function mount(node: ReturnType<typeof h>) {
|
|
|
61
61
|
return container;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
/** Mount and let the post-mount viewport pass run: the shell's mobile
|
|
65
|
+
* (drawer) / desktop (inline sidebar) split is decided one tick AFTER mount
|
|
66
|
+
* so the first client pass can match the server's viewport-less one
|
|
67
|
+
* (2026-11-24 — see HkFaceShell's mounted gate). */
|
|
68
|
+
async function mountSettled(node: ReturnType<typeof h>) {
|
|
69
|
+
const el = mount(node);
|
|
70
|
+
await nextTick();
|
|
71
|
+
return el;
|
|
72
|
+
}
|
|
73
|
+
|
|
64
74
|
afterEach(() => {
|
|
65
75
|
for (const { app, container } of mounts.splice(0)) {
|
|
66
76
|
app.unmount();
|
|
@@ -230,6 +240,11 @@ describe("HkAdminShell", () => {
|
|
|
230
240
|
{ navTitle: "Navigation" },
|
|
231
241
|
{ header: () => null, sidebar: NAV, content: CONTENT },
|
|
232
242
|
));
|
|
243
|
+
// The viewport decides ONE TICK AFTER MOUNT (2026-11-24): the shell's
|
|
244
|
+
// first pass must agree with the server's (which has no viewport), so
|
|
245
|
+
// the phone/drawer split settles post-mount. See HkFaceShell's
|
|
246
|
+
// mounted gate.
|
|
247
|
+
await nextTick();
|
|
233
248
|
expect(narrow.querySelector("aside .nav-mock")).toBeNull();
|
|
234
249
|
|
|
235
250
|
// Custom 768: the same 900px reads as desktop (inline sidebar).
|
|
@@ -237,6 +252,7 @@ describe("HkAdminShell", () => {
|
|
|
237
252
|
{ navTitle: "Navigation", mobileBreakpoint: 768 },
|
|
238
253
|
{ header: () => null, sidebar: NAV, content: CONTENT },
|
|
239
254
|
));
|
|
255
|
+
await nextTick();
|
|
240
256
|
expect(wide.querySelector("aside .nav-mock")).toBeTruthy();
|
|
241
257
|
});
|
|
242
258
|
|
|
@@ -330,10 +346,13 @@ describe("HkAdminShell", () => {
|
|
|
330
346
|
// scene) loses the side gutters on phones; vertical clearance
|
|
331
347
|
// survives. Asserted via longhands — see the note above.
|
|
332
348
|
setWidth(390);
|
|
333
|
-
const mobileShell =
|
|
349
|
+
const mobileShell = await mountSettled(shellNode(
|
|
334
350
|
{ navTitle: "Navigation", contentPadding: "2rem", contentBleedOnMobile: true },
|
|
335
351
|
{ header: () => null, sidebar: NAV, content: CONTENT },
|
|
336
352
|
));
|
|
353
|
+
// Viewport-derived layout settles one tick after mount (the shell's
|
|
354
|
+
// mounted gate exists to agree with the server's viewport-less pass).
|
|
355
|
+
await nextTick();
|
|
337
356
|
const inner = paddingInner(mobileShell);
|
|
338
357
|
expect(inner?.style.paddingTop).toBe("2rem");
|
|
339
358
|
expect(inner?.style.paddingBottom).toBe("2rem");
|
|
@@ -342,10 +361,11 @@ describe("HkAdminShell", () => {
|
|
|
342
361
|
|
|
343
362
|
// Multi-value shorthand keeps per-side meaning: vertical survives,
|
|
344
363
|
// horizontal is zeroed (never the inverted "1rem 2rem 0").
|
|
345
|
-
const multi =
|
|
364
|
+
const multi = await mountSettled(shellNode(
|
|
346
365
|
{ navTitle: "Navigation", contentPadding: "1rem 2rem", contentBleedOnMobile: true },
|
|
347
366
|
{ header: () => null, sidebar: NAV, content: CONTENT },
|
|
348
367
|
));
|
|
368
|
+
await nextTick();
|
|
349
369
|
const multiInner = paddingInner(multi);
|
|
350
370
|
expect(multiInner?.style.paddingTop).toBe("1rem");
|
|
351
371
|
expect(multiInner?.style.paddingBottom).toBe("1rem");
|
|
@@ -358,10 +378,11 @@ describe("HkAdminShell", () => {
|
|
|
358
378
|
// values the bottom track defaults to the top one, which makes the
|
|
359
379
|
// correct and the transposed string identical (round-1 verification
|
|
360
380
|
// mutation (e) survived on exactly that hole).
|
|
361
|
-
const triple =
|
|
381
|
+
const triple = await mountSettled(shellNode(
|
|
362
382
|
{ navTitle: "Navigation", contentPadding: "1rem 2rem 3rem", contentBleedOnMobile: true },
|
|
363
383
|
{ header: () => null, sidebar: NAV, content: CONTENT },
|
|
364
384
|
));
|
|
385
|
+
await nextTick();
|
|
365
386
|
const tripleInner = paddingInner(triple);
|
|
366
387
|
expect(tripleInner?.style.paddingTop).toBe("1rem");
|
|
367
388
|
expect(tripleInner?.style.paddingBottom).toBe("3rem");
|
|
@@ -374,10 +395,11 @@ describe("HkAdminShell", () => {
|
|
|
374
395
|
// slot is invisible to the shorter cases (round-2 verification
|
|
375
396
|
// mutated "1rem 2rem 3rem 4rem" into "1rem 0 3rem 2rem" and the suite
|
|
376
397
|
// stayed green).
|
|
377
|
-
const quad =
|
|
398
|
+
const quad = await mountSettled(shellNode(
|
|
378
399
|
{ navTitle: "Navigation", contentPadding: "1rem 2rem 3rem 4rem", contentBleedOnMobile: true },
|
|
379
400
|
{ header: () => null, sidebar: NAV, content: CONTENT },
|
|
380
401
|
));
|
|
402
|
+
await nextTick();
|
|
381
403
|
const quadInner = paddingInner(quad);
|
|
382
404
|
expect(quadInner?.style.paddingTop).toBe("1rem");
|
|
383
405
|
expect(quadInner?.style.paddingBottom).toBe("3rem");
|
|
@@ -392,7 +414,7 @@ describe("HkAdminShell", () => {
|
|
|
392
414
|
// the shell as it shipped). happy-dom stores calc() values, so the
|
|
393
415
|
// longhands are readable here; it cannot round-trip var()/min(), which
|
|
394
416
|
// is why calc() is the probe.
|
|
395
|
-
const fn =
|
|
417
|
+
const fn = await mountSettled(shellNode(
|
|
396
418
|
{ navTitle: "Navigation", contentPadding: "calc(1rem + 2px) 1rem", contentBleedOnMobile: true },
|
|
397
419
|
{ header: () => null, sidebar: NAV, content: CONTENT },
|
|
398
420
|
));
|
|
@@ -406,7 +428,7 @@ describe("HkAdminShell", () => {
|
|
|
406
428
|
// single-level check): a bare `clamp()` cannot be the probe because
|
|
407
429
|
// happy-dom rejects it outright, so the function rides in the second
|
|
408
430
|
// track of a plain length.
|
|
409
|
-
const nested =
|
|
431
|
+
const nested = await mountSettled(shellNode(
|
|
410
432
|
{ navTitle: "Navigation", contentPadding: "5rem clamp(1rem, min(2vw, 3px), 4rem)", contentBleedOnMobile: true },
|
|
411
433
|
{ header: () => null, sidebar: NAV, content: CONTENT },
|
|
412
434
|
));
|
|
@@ -417,7 +439,7 @@ describe("HkAdminShell", () => {
|
|
|
417
439
|
expect(nestedInner?.style.paddingRight).toBe("0px");
|
|
418
440
|
|
|
419
441
|
// …and so is a space directly after the opening parenthesis.
|
|
420
|
-
const spacedFn =
|
|
442
|
+
const spacedFn = await mountSettled(shellNode(
|
|
421
443
|
{ navTitle: "Navigation", contentPadding: "calc( 1rem + 2px ) 1rem", contentBleedOnMobile: true },
|
|
422
444
|
{ header: () => null, sidebar: NAV, content: CONTENT },
|
|
423
445
|
));
|
|
@@ -433,7 +455,7 @@ describe("HkAdminShell", () => {
|
|
|
433
455
|
// behaves the same way; it is pinned in HkAdminShell.padding.test.ts
|
|
434
456
|
// because happy-dom refuses to store a comment-bearing value at all.)
|
|
435
457
|
for (const keyword of ["inherit", "unset"]) {
|
|
436
|
-
const wide =
|
|
458
|
+
const wide = await mountSettled(shellNode(
|
|
437
459
|
{ navTitle: "Navigation", contentPadding: keyword, contentBleedOnMobile: true },
|
|
438
460
|
{ header: () => null, sidebar: NAV, content: CONTENT },
|
|
439
461
|
));
|
|
@@ -444,7 +466,7 @@ describe("HkAdminShell", () => {
|
|
|
444
466
|
// around a shorthand is not a track of its own ("\t1rem 2rem" must
|
|
445
467
|
// read exactly like "1rem 2rem", never like a three-track value).
|
|
446
468
|
for (const padded of ["1rem\t2rem", "1rem\n2rem", " 1rem 2rem ", "\t1rem 2rem"]) {
|
|
447
|
-
const ws =
|
|
469
|
+
const ws = await mountSettled(shellNode(
|
|
448
470
|
{ navTitle: "Navigation", contentPadding: padded, contentBleedOnMobile: true },
|
|
449
471
|
{ header: () => null, sidebar: NAV, content: CONTENT },
|
|
450
472
|
));
|
|
@@ -457,7 +479,7 @@ describe("HkAdminShell", () => {
|
|
|
457
479
|
|
|
458
480
|
// Nothing to strip: an empty value passes through untouched, it does
|
|
459
481
|
// NOT become a zero padding of its own.
|
|
460
|
-
const blank =
|
|
482
|
+
const blank = await mountSettled(shellNode(
|
|
461
483
|
{ navTitle: "Navigation", contentPadding: "", contentBleedOnMobile: true },
|
|
462
484
|
{ header: () => null, sidebar: NAV, content: CONTENT },
|
|
463
485
|
));
|
|
@@ -478,7 +500,7 @@ describe("HkAdminShell", () => {
|
|
|
478
500
|
// The shell's own default padding (1.5rem) is what a consumer that
|
|
479
501
|
// passes nothing actually gets — pinned here because this file
|
|
480
502
|
// otherwise only ever exercises explicit values.
|
|
481
|
-
const defaulted =
|
|
503
|
+
const defaulted = await mountSettled(shellNode(
|
|
482
504
|
{ navTitle: "Navigation", contentBleedOnMobile: true },
|
|
483
505
|
{ header: () => null, sidebar: NAV, content: CONTENT },
|
|
484
506
|
));
|
|
@@ -502,7 +524,7 @@ describe("HkAdminShell", () => {
|
|
|
502
524
|
// …and a custom breakpoint moves it: the padding gate must read the
|
|
503
525
|
// same `isDesktop` the layout does, not the 1024 default (round 3
|
|
504
526
|
// mutated it to a hardcoded 1024 and the suite stayed green).
|
|
505
|
-
const narrow =
|
|
527
|
+
const narrow = await mountSettled(shellNode(
|
|
506
528
|
{ navTitle: "Navigation", contentPadding: "2rem", contentBleedOnMobile: true, mobileBreakpoint: 768 },
|
|
507
529
|
{ header: () => null, sidebar: NAV, content: CONTENT },
|
|
508
530
|
));
|
|
@@ -520,7 +542,7 @@ describe("HkAdminShell", () => {
|
|
|
520
542
|
// move the padding gate too. Round 3 mutated the gate to saturate at
|
|
521
543
|
// 1024 and only a downward custom breakpoint was covered, so the
|
|
522
544
|
// mirror image survived.
|
|
523
|
-
const tablet =
|
|
545
|
+
const tablet = await mountSettled(shellNode(
|
|
524
546
|
{ navTitle: "Navigation", contentPadding: "2rem", contentBleedOnMobile: true, mobileBreakpoint: 1440 },
|
|
525
547
|
{ header: () => null, sidebar: NAV, content: CONTENT },
|
|
526
548
|
));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
2
|
import { createApp, defineComponent, h, ref, type VNode } from "vue";
|
|
3
|
+
import { renderToString } from "@vue/server-renderer";
|
|
3
4
|
|
|
4
5
|
// Same stub shape as HkFaceShell.test.tsx: HDrawer teleports and
|
|
5
6
|
// animates; the desktop rail contract is testable without the overlay
|
|
@@ -951,6 +952,72 @@ describe("rail group fold survives the crossfade generations (#43)", () => {
|
|
|
951
952
|
expect(groupToggle(backGen).getAttribute("aria-expanded")).toBe("true");
|
|
952
953
|
});
|
|
953
954
|
|
|
955
|
+
it("renders the DESKTOP layout on the server even when the viewport is a phone", async () => {
|
|
956
|
+
// 2026-11-24 user report: a phone showed a 248px inline sidebar and a
|
|
957
|
+
// 94px content column. Root cause was this shape — the server has no
|
|
958
|
+
// viewport, so it emitted the desktop layout, the client's first pass
|
|
959
|
+
// wanted the drawer, the structures differ, Vue kept the SERVER DOM and
|
|
960
|
+
// the drawer never appeared. The mounted gate keeps both first passes
|
|
961
|
+
// on the desktop layout; SSR therefore stays viewport-agnostic (a
|
|
962
|
+
// server render at phone width must NOT produce a drawer).
|
|
963
|
+
// MUT:mut-drop-gate (removing the mounted gate turns this RED).
|
|
964
|
+
window.innerWidth = 390;
|
|
965
|
+
const app = createApp({
|
|
966
|
+
render: () =>
|
|
967
|
+
h(
|
|
968
|
+
HkFaceShell,
|
|
969
|
+
{ sidebarCollapsible: true } as Record<string, unknown>,
|
|
970
|
+
{ sidebar: () => h("div", { class: "nav-stub" }, "nav") },
|
|
971
|
+
),
|
|
972
|
+
});
|
|
973
|
+
const html = await renderToString(app);
|
|
974
|
+
expect(html, "SSR emits the desktop aside").toContain("data-shell-sidebar");
|
|
975
|
+
expect(html, "SSR never emits the drawer").not.toContain("drawer-stub");
|
|
976
|
+
// The pre-hydration CSS guard keys on this marker; if it stopped being
|
|
977
|
+
// emitted the guard would silently stop working on every phone while
|
|
978
|
+
// every assertion above stayed green (review round 2).
|
|
979
|
+
expect(html, "SSR stamps the booting marker the guard keys on").toContain(
|
|
980
|
+
"data-shell-booting",
|
|
981
|
+
);
|
|
982
|
+
});
|
|
983
|
+
|
|
984
|
+
it("never keeps a narrow-breakpoint host's sidebar hidden after mount", async () => {
|
|
985
|
+
// The pre-hydration CSS guard is scoped to `[data-shell-booting]`, which
|
|
986
|
+
// the shell REMOVES on mount. Without that bound, a host whose
|
|
987
|
+
// `mobileBreakpoint` prop is narrower than the stylesheet's 768px would
|
|
988
|
+
// have CSS hide the sidebar forever while its JS called the same
|
|
989
|
+
// viewport desktop — no sidebar and no drawer (review round 1 of #1535).
|
|
990
|
+
window.innerWidth = 700;
|
|
991
|
+
const c = mountShell({ sidebarCollapsible: true, mobileBreakpoint: 640 } as Record<string, unknown>);
|
|
992
|
+
await vi.advanceTimersByTimeAsync(0);
|
|
993
|
+
expect(
|
|
994
|
+
c.container.querySelector(".s-admin-shell")?.hasAttribute("data-shell-booting"),
|
|
995
|
+
"the booting marker must not outlive mount",
|
|
996
|
+
).toBe(false);
|
|
997
|
+
expect(c.aside(), "the prop is authoritative once mounted").toBeTruthy();
|
|
998
|
+
window.innerWidth = 1280;
|
|
999
|
+
});
|
|
1000
|
+
|
|
1001
|
+
it("switches a phone to the drawer after mount, and drops the inline sidebar", async () => {
|
|
1002
|
+
// The POST-MOUNT STATE of the same contract: once mounted, the real
|
|
1003
|
+
// viewport decides — a phone gets the drawer as its ONLY nav surface and
|
|
1004
|
+
// the squeezed inline sidebar is gone from the body. This is a state
|
|
1005
|
+
// assertion, not the regression oracle: pre-fix a client-only mount at
|
|
1006
|
+
// 390px already produced the drawer (the bug lived in the SSR/client
|
|
1007
|
+
// disagreement, which the SSR test above pins and mutations.)
|
|
1008
|
+
window.innerWidth = 390;
|
|
1009
|
+
const c = mountShell({ sidebarCollapsible: true });
|
|
1010
|
+
await vi.advanceTimersByTimeAsync(0);
|
|
1011
|
+
expect(c.aside(), "no inline sidebar on a phone after mount").toBeFalsy();
|
|
1012
|
+
c.openDrawer();
|
|
1013
|
+
await vi.advanceTimersByTimeAsync(0);
|
|
1014
|
+
expect(
|
|
1015
|
+
c.container.querySelector(".drawer-stub-body"),
|
|
1016
|
+
"the drawer is the phone's nav surface",
|
|
1017
|
+
).toBeTruthy();
|
|
1018
|
+
window.innerWidth = 1280;
|
|
1019
|
+
});
|
|
1020
|
+
|
|
954
1021
|
it("shares the fold with the mobile drawer's menu (the provide sits above BOTH slots)", async () => {
|
|
955
1022
|
// The rail is not the only slot consumer: under the breakpoint the same
|
|
956
1023
|
// sidebar slot renders inside the drawer. The store is provided from
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { computed, defineComponent, provide, ref, watch, type PropType, type SlotsType, type VNode } from "vue";
|
|
1
|
+
import { computed, defineComponent, onMounted, 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 { useActionBarCenter } from "../composables/useActionBar";
|
|
@@ -379,7 +379,31 @@ export const HkFaceShell = defineComponent({
|
|
|
379
379
|
setup(props, { slots, emit }) {
|
|
380
380
|
const { t } = useI18n();
|
|
381
381
|
const { width: viewportWidth } = useBreakpoint();
|
|
382
|
-
|
|
382
|
+
// SSR-BLIND BREAKPOINT (2026-11-24 user report, phone screenshot): the
|
|
383
|
+
// server has no viewport, so it rendered the DESKTOP layout while a
|
|
384
|
+
// phone's first client pass wanted the drawer. The structures differ
|
|
385
|
+
// (inline aside vs HDrawer), Vue reports a hydration mismatch and keeps
|
|
386
|
+
// the SERVER DOM — so the phone kept a 248px inline sidebar squeezing
|
|
387
|
+
// the content to one word per line, and the drawer never appeared. This
|
|
388
|
+
// is the same root as hikari#1531.
|
|
389
|
+
//
|
|
390
|
+
// The gate makes both first passes identical (desktop, what SSR emits)
|
|
391
|
+
// and lets the viewport answer AFTER mount — the family's established
|
|
392
|
+
// pattern for viewport-derived values (`useChromeActionSize` in
|
|
393
|
+
// HkFilterTrigger, the family's own `mounted`-guarded chrome size).
|
|
394
|
+
// Pre-mount the squeezed inline sidebar is kept off a phone's screen by
|
|
395
|
+
// CSS (see the media rule in HkSidebarRail.scss), so the flash the gate
|
|
396
|
+
// would otherwise cost never reaches the user. That CSS keys on
|
|
397
|
+
// `[data-shell-booting]` — the marker below — so it can NEVER outlive
|
|
398
|
+
// the pre-mount window and fight a host whose `mobileBreakpoint` is
|
|
399
|
+
// narrower than the stylesheet's breakpoint.
|
|
400
|
+
const mounted = ref(false);
|
|
401
|
+
onMounted(() => {
|
|
402
|
+
mounted.value = true;
|
|
403
|
+
});
|
|
404
|
+
const isDesktop = computed(
|
|
405
|
+
() => !mounted.value || viewportWidth.value >= props.mobileBreakpoint,
|
|
406
|
+
);
|
|
383
407
|
const sidebarOpen = ref(false);
|
|
384
408
|
// ── the header's CENTRE channel, read from the bar above ─────────
|
|
385
409
|
// This shell provides NO bar of its own (whoever provides, provides
|
|
@@ -545,7 +569,7 @@ export const HkFaceShell = defineComponent({
|
|
|
545
569
|
}
|
|
546
570
|
|
|
547
571
|
return () => (
|
|
548
|
-
<div class="s-admin-shell">
|
|
572
|
+
<div class="s-admin-shell" data-shell-booting={mounted.value ? undefined : true}>
|
|
549
573
|
{slots.header && (
|
|
550
574
|
<div style={{ flexShrink: 0 }}>
|
|
551
575
|
{slots.header({
|
|
@@ -578,6 +602,7 @@ export const HkFaceShell = defineComponent({
|
|
|
578
602
|
<aside
|
|
579
603
|
ref={railHostRef}
|
|
580
604
|
class="hk-sidebar-rail-host"
|
|
605
|
+
data-shell-sidebar
|
|
581
606
|
// STATE marker only (hosts/tests read "the rail layout is
|
|
582
607
|
// active"): the rail DENSITY dress itself rides the swap's
|
|
583
608
|
// generation inside the clip, so it can freeze on the
|
|
@@ -649,6 +674,7 @@ export const HkFaceShell = defineComponent({
|
|
|
649
674
|
</aside>
|
|
650
675
|
) : (
|
|
651
676
|
<aside
|
|
677
|
+
data-shell-sidebar
|
|
652
678
|
style={{
|
|
653
679
|
width: props.sidebarWidth,
|
|
654
680
|
flexShrink: 0,
|
|
@@ -7,7 +7,10 @@ import { createApp, h, nextTick, ref, type Ref } from "vue";
|
|
|
7
7
|
import { Home, Settings } from "lucide-vue-next";
|
|
8
8
|
|
|
9
9
|
import HkMenu, { type HkMenuItem } from "./HkMenu";
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
RAIL_FLIP_ICON_ATTR,
|
|
12
|
+
RAIL_FLIP_NOSCALE_ATTR,
|
|
13
|
+
} from "../composables/useRailIconFlight";
|
|
11
14
|
|
|
12
15
|
/**
|
|
13
16
|
* HkMenu sidebar-variant ICON-RAIL mode (collapsed prop, 2026-10-30):
|
|
@@ -447,6 +450,42 @@ describe("HkMenu sidebar icon rail", () => {
|
|
|
447
450
|
expect(glyph.textContent).toBe("D");
|
|
448
451
|
});
|
|
449
452
|
|
|
453
|
+
// 2026-11-24 user direction: a MARK (dot/bullet/pip) must not tween its
|
|
454
|
+
// size across the density flip — it travels, it never grows. The host
|
|
455
|
+
// opts a row in through `iconNoScale`; the cell the flight pairs must
|
|
456
|
+
// then carry the no-scale attribute in BOTH densities, or the dot quietly
|
|
457
|
+
// rejoins the size tween.
|
|
458
|
+
// MUT:mut-attr-unstamped — unstamping the cells turns this test RED (this
|
|
459
|
+
// is the very gap the attribute exists to close).
|
|
460
|
+
it("carries iconNoScale onto the rail cell as data-flip-noscale", () => {
|
|
461
|
+
// Ordinary icon: keeps the size tween (no attribute).
|
|
462
|
+
const plain = mountMenu([{ key: "home", label: "Home", icon: Home }], {
|
|
463
|
+
collapsed: true,
|
|
464
|
+
});
|
|
465
|
+
const plainCell = plain.querySelector<HTMLElement>(
|
|
466
|
+
`.hk-menu-item-icon[${RAIL_FLIP_ICON_ATTR}="home"]`,
|
|
467
|
+
);
|
|
468
|
+
expect(plainCell, "the rail row stamps its icon cell").toBeTruthy();
|
|
469
|
+
expect(
|
|
470
|
+
plainCell!.hasAttribute(RAIL_FLIP_NOSCALE_ATTR),
|
|
471
|
+
"an ordinary icon keeps the size tween",
|
|
472
|
+
).toBe(false);
|
|
473
|
+
|
|
474
|
+
// Mark: opts out of the tween.
|
|
475
|
+
const mark = mountMenu(
|
|
476
|
+
[{ key: "dot", label: "Dot", icon: Home, iconNoScale: true }],
|
|
477
|
+
{ collapsed: true },
|
|
478
|
+
);
|
|
479
|
+
const markCell = mark.querySelector<HTMLElement>(
|
|
480
|
+
`.hk-menu-item-icon[${RAIL_FLIP_ICON_ATTR}="dot"]`,
|
|
481
|
+
);
|
|
482
|
+
expect(markCell, "the mark's cell is stamped too").toBeTruthy();
|
|
483
|
+
expect(
|
|
484
|
+
markCell!.hasAttribute(RAIL_FLIP_NOSCALE_ATTR),
|
|
485
|
+
"iconNoScale must reach the cell the flight pairs",
|
|
486
|
+
).toBe(true);
|
|
487
|
+
});
|
|
488
|
+
|
|
450
489
|
it("stamps every icon cell with data-flip-icon = the row key, in BOTH densities", () => {
|
|
451
490
|
// The rail flip's icon flight (useRailIconFlight) pairs the leaving
|
|
452
491
|
// and entering copies of ONE destination by this attribute; a cell
|
|
@@ -54,6 +54,11 @@ export interface HkMenuItem {
|
|
|
54
54
|
key: string;
|
|
55
55
|
label: string;
|
|
56
56
|
icon?: Component;
|
|
57
|
+
/** Marks the icon as a MARK (dot, bullet, status pip) rather than an
|
|
58
|
+
* illustration: the rail flip still TRAVELS it to its new position but
|
|
59
|
+
* never tweens its size — a dot's size is its meaning, and growing it
|
|
60
|
+
* across the flip reads as a glitch (2026-11-24 user direction). */
|
|
61
|
+
iconNoScale?: boolean;
|
|
57
62
|
flag?: string;
|
|
58
63
|
checked?: boolean;
|
|
59
64
|
disabled?: boolean;
|
|
@@ -956,7 +961,11 @@ export default defineComponent({
|
|
|
956
961
|
// data-flip-icon: the row key opts this cell into the rail
|
|
957
962
|
// flip's icon flight (useRailIconFlight) — the flight pairs
|
|
958
963
|
// the leaving and entering copies of ONE destination by it.
|
|
959
|
-
<span
|
|
964
|
+
<span
|
|
965
|
+
class="hk-menu-item-icon"
|
|
966
|
+
data-flip-icon={item.key}
|
|
967
|
+
data-flip-noscale={item.iconNoScale ? true : undefined}
|
|
968
|
+
>
|
|
960
969
|
{h(item.icon, { size: 16 })}
|
|
961
970
|
</span>
|
|
962
971
|
)}
|
|
@@ -992,7 +1001,9 @@ export default defineComponent({
|
|
|
992
1001
|
Still conditional: an icon-less group renders no cell
|
|
993
1002
|
here, exactly as before. */}
|
|
994
1003
|
{item.icon && (
|
|
995
|
-
<span class="hk-menu-item-icon" data-flip-icon={item.key}
|
|
1004
|
+
<span class="hk-menu-item-icon" data-flip-icon={item.key}
|
|
1005
|
+
data-flip-noscale={item.iconNoScale ? true : undefined}
|
|
1006
|
+
>
|
|
996
1007
|
{h(item.icon, { size: 16 })}
|
|
997
1008
|
</span>
|
|
998
1009
|
)}
|
|
@@ -1067,6 +1078,9 @@ export default defineComponent({
|
|
|
1067
1078
|
<span
|
|
1068
1079
|
class="hk-menu-item-icon"
|
|
1069
1080
|
data-flip-icon={item.key}
|
|
1081
|
+
// A LETTER fallback is a mark, not an illustration: its size is
|
|
1082
|
+
// its identity, so the flight must not tween it (2026-11-24).
|
|
1083
|
+
data-flip-noscale={item.iconNoScale || !item.icon ? true : undefined}
|
|
1070
1084
|
data-fallback={item.icon ? undefined : true}
|
|
1071
1085
|
>
|
|
1072
1086
|
{item.icon ? h(item.icon, { size: 16 }) : item.label.trim().charAt(0).toUpperCase()}
|
|
@@ -1130,7 +1144,11 @@ export default defineComponent({
|
|
|
1130
1144
|
{railCaret(expanded, 16)}
|
|
1131
1145
|
</span>
|
|
1132
1146
|
{item.icon && (
|
|
1133
|
-
<span
|
|
1147
|
+
<span
|
|
1148
|
+
class="hk-menu-rail-glyph-corner"
|
|
1149
|
+
data-flip-icon={item.key}
|
|
1150
|
+
data-flip-noscale={item.iconNoScale ? true : undefined}
|
|
1151
|
+
>
|
|
1134
1152
|
{h(item.icon, { size: 10 })}
|
|
1135
1153
|
</span>
|
|
1136
1154
|
)}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { afterEach, describe, expect, it } from "vitest";
|
|
2
|
-
import { createApp, h } from "vue";
|
|
2
|
+
import { createApp, h, nextTick, reactive } from "vue";
|
|
3
3
|
import { readFileSync } from "node:fs";
|
|
4
4
|
import { dirname, join } from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
@@ -389,3 +389,80 @@ describe("HkPillToggleGroup track geometry contract", () => {
|
|
|
389
389
|
expect(phoneDecls.has("max-width"), "no max-width in the phone block").toBe(false);
|
|
390
390
|
});
|
|
391
391
|
});
|
|
392
|
+
|
|
393
|
+
// ── Fade re-sensing on content mutations (the 2026-11-24 report): the
|
|
394
|
+
// option set collapsing from several pills to one must retire the edge
|
|
395
|
+
// fade the wide layout earned, without a scroll and without the strip's
|
|
396
|
+
// own box resizing. The strip's MutationObserver funnels the mutations
|
|
397
|
+
// that can move scrollWidth into sense(). happy-dom performs no layout,
|
|
398
|
+
// so the stubbed strip geometry IS the new layout — the DOM mutation
|
|
399
|
+
// only has to TRIGGER the re-sense, which is the contract under test.
|
|
400
|
+
describe("HkPillToggleGroup fade re-sensing", () => {
|
|
401
|
+
// Mutation matrix (PR #1534 independent review rounds; ids match that run
|
|
402
|
+
// ledger): MUT:strip-childlist-only — reverting the strip observer to
|
|
403
|
+
// childList-only reds the characterData test below while the collapse test
|
|
404
|
+
// keeps its green (that path is childList, which the mutation isolates
|
|
405
|
+
// rather than breaks); MUT:strip-callback-neutered — a no-op observer
|
|
406
|
+
// callback reds both tests, so sensing runs through the observer and never
|
|
407
|
+
// through an accident of the stubbed geometry.
|
|
408
|
+
/** Drain the mutation microtask: the strip callback is `sense` directly
|
|
409
|
+
* (no rAF hop), so the macrotask tick alone delivers it — the trailing
|
|
410
|
+
* frames only keep the flush shape uniform with the scroller's
|
|
411
|
+
* rAF-coalesced pass. */
|
|
412
|
+
async function flushSensing(): Promise<void> {
|
|
413
|
+
await new Promise<void>((r) => setTimeout(r, 0));
|
|
414
|
+
await new Promise<void>((r) => requestAnimationFrame(() => r()));
|
|
415
|
+
await new Promise<void>((r) => requestAnimationFrame(() => r()));
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
function stubStripGeometry(strip: HTMLElement, scrollWidth: number, clientWidth: number): void {
|
|
419
|
+
Object.defineProperty(strip, "scrollWidth", { configurable: true, get: () => scrollWidth });
|
|
420
|
+
Object.defineProperty(strip, "clientWidth", { configurable: true, get: () => clientWidth });
|
|
421
|
+
Object.defineProperty(strip, "scrollLeft", { configurable: true, get: () => 0 });
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
it("retires the end fade when the option set collapses to one pill", async () => {
|
|
425
|
+
const options = reactive([
|
|
426
|
+
{ value: "chat", label: "Chat" },
|
|
427
|
+
{ value: "draw", label: "Draw" },
|
|
428
|
+
]);
|
|
429
|
+
const c = mount(h(HkPillToggleGroup, { label: "P", options, selected: new Set<string>() }));
|
|
430
|
+
// The composable wires scroll/wheel/MO sensors in a watch on the
|
|
431
|
+
// strip ref — flush the mount queue so the wiring has run before any
|
|
432
|
+
// stubbed geometry or dispatched event.
|
|
433
|
+
await nextTick();
|
|
434
|
+
const strip = c.querySelector<HTMLElement>(".hk-pill-group")!;
|
|
435
|
+
stubStripGeometry(strip, 400, 120);
|
|
436
|
+
strip.dispatchEvent(new Event("scroll"));
|
|
437
|
+
expect(strip.getAttribute("data-h-overflow")).toBe("end");
|
|
438
|
+
|
|
439
|
+
// The surviving layout fits (the stub IS that layout); the childList
|
|
440
|
+
// mutation from the patch is the only trigger the new state arrives
|
|
441
|
+
// through.
|
|
442
|
+
stubStripGeometry(strip, 80, 120);
|
|
443
|
+
options.splice(1);
|
|
444
|
+
await nextTick();
|
|
445
|
+
await flushSensing();
|
|
446
|
+
expect(strip.hasAttribute("data-h-overflow")).toBe(false);
|
|
447
|
+
});
|
|
448
|
+
|
|
449
|
+
it("lights the fade when a label is rewritten in place (characterData only)", async () => {
|
|
450
|
+
const options = reactive([{ value: "chat", label: "Chat" }]);
|
|
451
|
+
const c = mount(h(HkPillToggleGroup, { label: "P", options, selected: new Set<string>() }));
|
|
452
|
+
// Same wiring flush as above: the sensors must already be attached
|
|
453
|
+
// when the mutation lands, or the test exercises nothing.
|
|
454
|
+
await nextTick();
|
|
455
|
+
const strip = c.querySelector<HTMLElement>(".hk-pill-group")!;
|
|
456
|
+
stubStripGeometry(strip, 80, 120);
|
|
457
|
+
strip.dispatchEvent(new Event("scroll"));
|
|
458
|
+
expect(strip.hasAttribute("data-h-overflow")).toBe(false);
|
|
459
|
+
|
|
460
|
+
stubStripGeometry(strip, 400, 120);
|
|
461
|
+
// A relabeled pill adds no child and removes none — the text node
|
|
462
|
+
// mutation alone must re-sense.
|
|
463
|
+
const pill = strip.querySelectorAll<HTMLButtonElement>(".hk-pill-group-pill")[0]!;
|
|
464
|
+
(pill.firstChild as Text).data = "Conversation with a much longer title";
|
|
465
|
+
await flushSensing();
|
|
466
|
+
expect(strip.getAttribute("data-h-overflow")).toBe("end");
|
|
467
|
+
});
|
|
468
|
+
});
|