@celestia-island/hikari 0.55.513 → 0.55.515
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/HkDirectionalSwap.d.ts +27 -0
- package/dist/types/mermaid/layout.d.ts +32 -0
- package/package.json +1 -1
- package/src/components/HkBoard.arrows.test.tsx +116 -4
- package/src/components/HkBoard.scss +49 -13
- package/src/components/HkBoard.tsx +58 -33
- package/src/components/HkDirectionalSwap.scss +19 -1
- package/src/components/HkDirectionalSwap.test.tsx +363 -0
- package/src/components/HkDirectionalSwap.tsx +95 -4
- package/src/components/HkSelectionControls.styles.test.ts +13 -1
- package/src/components/__tests__/hkMermaidLayout.test.ts +230 -1
- package/src/errorLandingStandalone/error-landing.html +1 -1
- package/src/mermaid/layout.ts +77 -4
|
@@ -38,6 +38,20 @@
|
|
|
38
38
|
* - A STALL WATCHDOG, same shape as HkCrossfade's: if the browser wedges
|
|
39
39
|
* the Transition engine (rAF frozen), the frozen leaving item is swept
|
|
40
40
|
* and the wrapper is dropped so keys apply synchronously from then on.
|
|
41
|
+
* - `animateHeight` (OPT-IN, default off) softens the one geometry this
|
|
42
|
+
* grid cannot express: the cell keeps the TALLER generation's height
|
|
43
|
+
* for the whole exchange, so a swap between different-height panes
|
|
44
|
+
* still snaps — taller the moment the exchange starts, shorter the
|
|
45
|
+
* frame it ends (measured on the docs shell's preview/source card,
|
|
46
|
+
* 2026-11-29: 360px → 278px in ONE frame). With the prop on, the
|
|
47
|
+
* wrapper freezes at its rendered height, transitions to the incoming
|
|
48
|
+
* generation's height over the same duration/easing as the travel,
|
|
49
|
+
* and releases back to auto on settle. Reduced motion (duration 0)
|
|
50
|
+
* keeps the snap — the instant change IS that preference. A faster
|
|
51
|
+
* follow-up swap interrupts the running exchange: Vue cancels the
|
|
52
|
+
* enter (which releases), and the next freeze reads the cell's
|
|
53
|
+
* CURRENT rendered height — the interrupted tween's mid-state —
|
|
54
|
+
* never the old start.
|
|
41
55
|
*/
|
|
42
56
|
import { type PropType } from "vue";
|
|
43
57
|
import "./HkDirectionalSwap.scss";
|
|
@@ -88,6 +102,12 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
88
102
|
type: BooleanConstructor;
|
|
89
103
|
default: boolean;
|
|
90
104
|
};
|
|
105
|
+
/** Animate the wrapper's height across the exchange (see the module
|
|
106
|
+
* note). Default off: every existing host keeps the grid's snap. */
|
|
107
|
+
animateHeight: {
|
|
108
|
+
type: BooleanConstructor;
|
|
109
|
+
default: boolean;
|
|
110
|
+
};
|
|
91
111
|
tag: {
|
|
92
112
|
type: StringConstructor;
|
|
93
113
|
default: string;
|
|
@@ -136,6 +156,12 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
136
156
|
type: BooleanConstructor;
|
|
137
157
|
default: boolean;
|
|
138
158
|
};
|
|
159
|
+
/** Animate the wrapper's height across the exchange (see the module
|
|
160
|
+
* note). Default off: every existing host keeps the grid's snap. */
|
|
161
|
+
animateHeight: {
|
|
162
|
+
type: BooleanConstructor;
|
|
163
|
+
default: boolean;
|
|
164
|
+
};
|
|
139
165
|
tag: {
|
|
140
166
|
type: StringConstructor;
|
|
141
167
|
default: string;
|
|
@@ -153,5 +179,6 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
153
179
|
tag: string;
|
|
154
180
|
duration: number;
|
|
155
181
|
travel: number;
|
|
182
|
+
animateHeight: boolean;
|
|
156
183
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
157
184
|
export default _default;
|
|
@@ -79,6 +79,34 @@ export declare function heuristicTextWidth(text: string, fontSize: number, opts?
|
|
|
79
79
|
/** Canvas-backed measure with heuristic fallback (happy-dom has no 2D
|
|
80
80
|
* canvas → the fallback keeps tests deterministic). */
|
|
81
81
|
export declare function createCanvasMeasureText(): MeasureText;
|
|
82
|
+
/** ── Edge-caption width budget (2026-11-29) ──────────────────────────
|
|
83
|
+
* A caption wider than the rank band spilled over the neighbouring
|
|
84
|
+
* rank's node boxes and was painted UNDER them (the caption is board
|
|
85
|
+
* chrome, the boxes are HTML nodes above it) — the chest docs defect:
|
|
86
|
+
* "models and keys" readable only up to the 模型网关 box's edge. Two
|
|
87
|
+
* halves, both keyed off this constant:
|
|
88
|
+
*
|
|
89
|
+
* 1. THE CAP. The board renders captions as HTML chips clamped to
|
|
90
|
+
* `EDGE_LABEL_MAX_W` (world px) with an ellipsis; the full text
|
|
91
|
+
* rides the `title` attribute (the family tooltip bridge upgrades
|
|
92
|
+
* hover, the touch bridge upgrades long-press).
|
|
93
|
+
* 2. THE RESERVATION. Every rank band a captioned edge crosses widens
|
|
94
|
+
* its main-axis gap to `labelW + 2 × EDGE_LABEL_GAP_PAD`, so the
|
|
95
|
+
* chip paints in empty band, not under boxes. Vertical stacks
|
|
96
|
+
* (TD/BT) already clear a caption's HEIGHT inside `GAP_RANK`; only
|
|
97
|
+
* the horizontal directions need real widening. */
|
|
98
|
+
export declare const EDGE_LABEL_MAX_W = 180;
|
|
99
|
+
/** Clearance around a caption chip inside a widened band, per side. The
|
|
100
|
+
* chip itself is wider than its text: 8px padding each side + a 1px
|
|
101
|
+
* border = 18px of chrome, and `translate(-50%,-50%)` centers THAT box
|
|
102
|
+
* on the band midpoint — so the band must clear the chrome too (the R1
|
|
103
|
+
* finding: a caption at the 180 cap poked 9px into the neighbour rank).
|
|
104
|
+
* 24 = 9 (half chrome) + 15 of air. */
|
|
105
|
+
export declare const EDGE_LABEL_GAP_PAD = 24;
|
|
106
|
+
/** The caption's font size — the board's `.hk-board-edge-label` paints
|
|
107
|
+
* 12px; the measurement must use the same size or the reservation and
|
|
108
|
+
* the visible chip disagree. */
|
|
109
|
+
export declare const EDGE_LABEL_FONT = 12;
|
|
82
110
|
interface GraphItem {
|
|
83
111
|
id: string;
|
|
84
112
|
w: number;
|
|
@@ -113,9 +141,13 @@ export declare function feedbackArcSet(items: GraphItem[], edges: RankedEdge[]):
|
|
|
113
141
|
export interface GraphLayoutInput {
|
|
114
142
|
/** World-rect size per node id (already includes card chrome). */
|
|
115
143
|
items: GraphItem[];
|
|
144
|
+
/** `labelW` = the edge caption's CAPPED width (the caller measures and
|
|
145
|
+
* clamps to `EDGE_LABEL_MAX_W`). Bands the edge crosses reserve room
|
|
146
|
+
* for it — see `EDGE_LABEL_GAP_PAD` below. */
|
|
116
147
|
edges: Array<{
|
|
117
148
|
from: string;
|
|
118
149
|
to: string;
|
|
150
|
+
labelW?: number;
|
|
119
151
|
}>;
|
|
120
152
|
direction: MermaidDirection;
|
|
121
153
|
/** Cross-axis gap between same-rank siblings, world px. Cluster frames pad
|
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@ import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
|
2
2
|
import { createApp, defineComponent, h, nextTick } from "vue";
|
|
3
3
|
|
|
4
4
|
import HkBoard, { type BoardEdgeInput, type BoardNodeInput } from "./HkBoard";
|
|
5
|
+
import { EDGE_LABEL_GAP_PAD } from "../mermaid/layout";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* HkBoard — what a diagram needs from the board beyond "it draws".
|
|
@@ -235,9 +236,16 @@ describe("HkBoard — arrows arrive head-on", () => {
|
|
|
235
236
|
expect(c2y).toBeLessThan(ey);
|
|
236
237
|
expect(path.getAttribute("marker-end")).toMatch(/^url\(#hk-board-ah-/);
|
|
237
238
|
// The caption rides the curve's own midpoint.
|
|
238
|
-
const label = board.container.querySelector(".hk-board-edge-label")!;
|
|
239
|
+
const label = board.container.querySelector<HTMLElement>(".hk-board-edge-label")!;
|
|
239
240
|
expect(label.textContent).toBe("go");
|
|
240
|
-
|
|
241
|
+
// The caption is an HTML chip now (SVG text cannot be width-clamped):
|
|
242
|
+
// its position reads off the world-coord left/top, centered by the
|
|
243
|
+
// stylesheet's translate(-50%, -50%).
|
|
244
|
+
const chipAt = (el: HTMLElement): [number, number] => [
|
|
245
|
+
Number.parseFloat(el.style.left),
|
|
246
|
+
Number.parseFloat(el.style.top),
|
|
247
|
+
];
|
|
248
|
+
expect(chipAt(label)).toEqual([50, 80]);
|
|
241
249
|
board.unmount();
|
|
242
250
|
});
|
|
243
251
|
|
|
@@ -278,8 +286,11 @@ describe("HkBoard — arrows arrive head-on", () => {
|
|
|
278
286
|
expect(c2x).toBe(ex);
|
|
279
287
|
expect(c2y).toBeLessThan(ey);
|
|
280
288
|
// the middle via is the caption anchor
|
|
281
|
-
const label = board.container.querySelector(".hk-board-edge-label")!;
|
|
282
|
-
expect([
|
|
289
|
+
const label = board.container.querySelector<HTMLElement>(".hk-board-edge-label")!;
|
|
290
|
+
expect([
|
|
291
|
+
Number.parseFloat(label.style.left),
|
|
292
|
+
Number.parseFloat(label.style.top),
|
|
293
|
+
]).toEqual([40, 113]);
|
|
283
294
|
board.unmount();
|
|
284
295
|
});
|
|
285
296
|
|
|
@@ -357,3 +368,104 @@ describe("HkBoard — arrows arrive head-on", () => {
|
|
|
357
368
|
c.remove();
|
|
358
369
|
});
|
|
359
370
|
});
|
|
371
|
+
|
|
372
|
+
// MUT:board-edge-caption-chips — captions are HTML chips, not SVG text:
|
|
373
|
+
// an SVG caption cannot be width-clamped, so a long one sprawled across
|
|
374
|
+
// the neighbouring rank and painted UNDER the node boxes (the chest docs
|
|
375
|
+
// defect). The chip carries the full text in `title` (family hover
|
|
376
|
+
// bridge → house bubble, touch bridge → long-press bar, bare host →
|
|
377
|
+
// native tooltip) and clamps via the CSS-var max-width whose fallback is
|
|
378
|
+
// the layout's own cap constant — reservation and ellipsis must agree.
|
|
379
|
+
describe("HkBoard — edge caption chips", () => {
|
|
380
|
+
it("renders the caption as a clamped, titled chip above the node layer", async () => {
|
|
381
|
+
const nodes: BoardNodeInput[] = [
|
|
382
|
+
{ id: "a", x: 0, y: 0, w: 100, h: 40, label: "A" },
|
|
383
|
+
{ id: "b", x: 400, y: 0, w: 100, h: 40, label: "B" },
|
|
384
|
+
];
|
|
385
|
+
const edges: BoardEdgeInput[] = [{ id: "e", from: "a", to: "b", label: "models and keys" }];
|
|
386
|
+
const board = mountBoard({ nodes, edges });
|
|
387
|
+
const c = board.container;
|
|
388
|
+
const chip = c.querySelector<HTMLElement>(".hk-board-edge-label")!;
|
|
389
|
+
expect(chip, "the caption chip").toBeTruthy();
|
|
390
|
+
expect(chip.tagName).toBe("DIV");
|
|
391
|
+
expect(chip.textContent).toBe("models and keys");
|
|
392
|
+
// The full text rides `title` for the tooltip bridges — EVERY caption
|
|
393
|
+
// gets one, truncated or not (the user direction: 全部都带 tooltip).
|
|
394
|
+
expect(chip.getAttribute("title")).toBe("models and keys");
|
|
395
|
+
// The clamp is the CSS var whose fallback IS the layout's reservation
|
|
396
|
+
// constant: retuning the var retunes the chip without code changes.
|
|
397
|
+
expect(chip.style.maxWidth).toBe("var(--hk-board-edge-label-max-w, 180px)");
|
|
398
|
+
// The chip layer paints AFTER the nodes (DOM order = paint order):
|
|
399
|
+
// a caption must never again lose a hiding contest with a box.
|
|
400
|
+
const world = c.querySelector(".hk-board-world")!;
|
|
401
|
+
const firstNode = world.querySelector(".hk-board-node")!;
|
|
402
|
+
const layer = chip.parentElement!;
|
|
403
|
+
expect(layer.className).toBe("hk-board-labels");
|
|
404
|
+
expect(
|
|
405
|
+
firstNode.compareDocumentPosition(layer) & Node.DOCUMENT_POSITION_FOLLOWING,
|
|
406
|
+
"the label layer follows the nodes in DOM order",
|
|
407
|
+
).toBeTruthy();
|
|
408
|
+
board.unmount();
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
it("renders end captions (class multiplicities) as titled chips too", async () => {
|
|
412
|
+
const nodes: BoardNodeInput[] = [
|
|
413
|
+
{ id: "a", x: 0, y: 0, w: 100, h: 40, label: "A" },
|
|
414
|
+
{ id: "b", x: 400, y: 0, w: 100, h: 40, label: "B" },
|
|
415
|
+
];
|
|
416
|
+
const edges: BoardEdgeInput[] = [
|
|
417
|
+
{ id: "e", from: "a", to: "b", labelFrom: "1..*", labelTo: "0..1" },
|
|
418
|
+
];
|
|
419
|
+
const board = mountBoard({ nodes, edges });
|
|
420
|
+
const c = board.container;
|
|
421
|
+
const from = c.querySelector<HTMLElement>(".hk-board-edge-endlabel")!;
|
|
422
|
+
expect(from).toBeTruthy();
|
|
423
|
+
expect(from.getAttribute("title")).toBe("1..*");
|
|
424
|
+
const all = [...c.querySelectorAll<HTMLElement>(".hk-board-edge-endlabel")];
|
|
425
|
+
expect(all.map((el) => el.getAttribute("title")).sort()).toEqual(["0..1", "1..*"]);
|
|
426
|
+
// Each end chip clamps on ITS OWN var (default 120), not the caption's
|
|
427
|
+
// (180): a host retuning the caption width must not resize the
|
|
428
|
+
// multiplicities, and a code-only regression that reuses the caption
|
|
429
|
+
// var here turns this red (R1 S3-1).
|
|
430
|
+
for (const chip of all) {
|
|
431
|
+
expect(chip.style.maxWidth).toBe("var(--hk-board-edge-endlabel-max-w, 120px)");
|
|
432
|
+
}
|
|
433
|
+
board.unmount();
|
|
434
|
+
});
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
// MUT:board-caption-sheet — the chip's chrome arithmetic backs the
|
|
438
|
+
// layout's band reservation (EDGE_LABEL_GAP_PAD 24 per side clears the
|
|
439
|
+
// 9px half-chrome with air): the sheet must keep the chip's horizontal
|
|
440
|
+
// padding/border at that size, and the two max-width vars stay separate
|
|
441
|
+
// so tuning one caption kind cannot resize the other (R1 S3-1).
|
|
442
|
+
const captionSheet = (await import("node:fs")).readFileSync(
|
|
443
|
+
(await import("node:path")).resolve(__dirname, "./HkBoard.scss"),
|
|
444
|
+
"utf8",
|
|
445
|
+
);
|
|
446
|
+
|
|
447
|
+
describe("HkBoard — caption chip sheet contract", () => {
|
|
448
|
+
const sheet = captionSheet;
|
|
449
|
+
const stripped = sheet.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/[^\n]*/g, "$1");
|
|
450
|
+
const ruleBody = (selector: string): string | null => {
|
|
451
|
+
const at = stripped.indexOf(selector);
|
|
452
|
+
if (at < 0) return null;
|
|
453
|
+
const open = stripped.indexOf("{", at);
|
|
454
|
+
const close = stripped.indexOf("}", open);
|
|
455
|
+
return close > open ? stripped.slice(open + 1, close) : null;
|
|
456
|
+
};
|
|
457
|
+
it("keeps the chip chrome inside the reservation budget", () => {
|
|
458
|
+
const body = ruleBody(".hk-board-edge-label {")!;
|
|
459
|
+
expect(body).toMatch(/padding:\s*2px 8px/);
|
|
460
|
+
expect(body).toMatch(/border:\s*1px solid/);
|
|
461
|
+
expect(body).toMatch(/max-width:\s*var\(--hk-board-edge-label-max-w/);
|
|
462
|
+
// 9 (half chrome: 8px padding + 1px border, per side) must stay under
|
|
463
|
+
// the layout's per-side clearance, or a capped chip pokes into the
|
|
464
|
+
// neighbouring rank again (R1 measured the 9px poke at the cap).
|
|
465
|
+
expect(EDGE_LABEL_GAP_PAD).toBeGreaterThan(9);
|
|
466
|
+
});
|
|
467
|
+
it("endlabels carry their own width var, not the caption's", () => {
|
|
468
|
+
const body = ruleBody(".hk-board-edge-endlabel {")!;
|
|
469
|
+
expect(body).toMatch(/max-width:\s*var\(--hk-board-edge-endlabel-max-w,\s*120px\)/);
|
|
470
|
+
});
|
|
471
|
+
});
|
|
@@ -39,27 +39,63 @@
|
|
|
39
39
|
pointer-events: none;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
// Edge caption chips (opt-in `label` / `labelFrom` / `labelTo` on
|
|
43
|
+
// BoardEdgeInput). HTML, not SVG text — an SVG caption cannot be
|
|
44
|
+
// width-clamped, so a long one sprawled over the neighbouring rank and
|
|
45
|
+
// painted UNDER the node boxes (the chest docs defect, 2026-11-29). The
|
|
46
|
+
// chip clamps to `--hk-board-edge-label-max-w` (world px, matching the
|
|
47
|
+
// layout's band reservation) with an ellipsis, and carries its full text
|
|
48
|
+
// in `title` — the family hover bridge upgrades that to the house
|
|
49
|
+
// tooltip bubble, the touch bridge to the long-press hint bar, and an
|
|
50
|
+
// un-instrumented host still gets the native tooltip. The surface chip
|
|
51
|
+
// replaces the old paint-order halo: it must read over its own path,
|
|
52
|
+
// the grid, and neighbouring edges without a measuring pass.
|
|
53
|
+
.hk-board-labels {
|
|
54
|
+
position: absolute;
|
|
55
|
+
inset: 0;
|
|
56
|
+
// The layer never blocks the board's own gestures; a chip opts back in
|
|
57
|
+
// so the tooltip bridges can engage on it.
|
|
58
|
+
pointer-events: none;
|
|
59
|
+
}
|
|
60
|
+
|
|
45
61
|
.hk-board-edge-label {
|
|
62
|
+
position: absolute;
|
|
63
|
+
transform: translate(-50%, -50%);
|
|
64
|
+
max-width: var(--hk-board-edge-label-max-w, 180px);
|
|
65
|
+
overflow: hidden;
|
|
66
|
+
text-overflow: ellipsis;
|
|
67
|
+
white-space: nowrap;
|
|
68
|
+
pointer-events: auto;
|
|
69
|
+
box-sizing: border-box;
|
|
70
|
+
padding: 2px 8px;
|
|
71
|
+
border-radius: var(--radius-sm, 6px);
|
|
72
|
+
background: rgb(var(--color-surface));
|
|
73
|
+
border: 1px solid rgb(var(--color-border) / 35%);
|
|
46
74
|
font-size: 12px;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
75
|
+
color: rgb(var(--color-text) / 85%);
|
|
76
|
+
// One step above the nodes (DOM order after them): with the layout's
|
|
77
|
+
// band reservation a chip has nothing to cover, but it must never lose
|
|
78
|
+
// a hiding contest with a box again.
|
|
79
|
+
cursor: default;
|
|
52
80
|
}
|
|
53
81
|
|
|
54
82
|
.hk-board-edge-endlabel {
|
|
55
83
|
// One step smaller than the midpoint caption: the multiplicities are
|
|
56
84
|
// metadata, the caption is the message.
|
|
85
|
+
position: absolute;
|
|
86
|
+
transform: translate(-50%, -50%);
|
|
87
|
+
max-width: var(--hk-board-edge-endlabel-max-w, 120px);
|
|
88
|
+
overflow: hidden;
|
|
89
|
+
text-overflow: ellipsis;
|
|
90
|
+
white-space: nowrap;
|
|
91
|
+
pointer-events: auto;
|
|
92
|
+
box-sizing: border-box;
|
|
93
|
+
padding: 1px 6px;
|
|
94
|
+
border-radius: var(--radius-sm, 6px);
|
|
95
|
+
background: rgb(var(--color-surface));
|
|
57
96
|
font-size: 10px;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
stroke: rgb(var(--color-surface));
|
|
61
|
-
stroke-width: 4px;
|
|
62
|
-
stroke-linejoin: round;
|
|
97
|
+
color: rgb(var(--color-text) / 85%);
|
|
98
|
+
cursor: default;
|
|
63
99
|
}
|
|
64
100
|
|
|
65
101
|
// Edge ink (fill/stroke/linecap) is set as presentation attributes on every
|
|
@@ -66,6 +66,7 @@ import {
|
|
|
66
66
|
} from "../utils/boardEdges";
|
|
67
67
|
import "./HkBoard.scss";
|
|
68
68
|
import { drawnScale } from "../composables/layoutGeometry";
|
|
69
|
+
import { EDGE_LABEL_MAX_W } from "../mermaid/layout";
|
|
69
70
|
|
|
70
71
|
/**
|
|
71
72
|
* A node on the board. `hidden` nodes are junction-only (invisible).
|
|
@@ -342,6 +343,47 @@ export default defineComponent({
|
|
|
342
343
|
return out;
|
|
343
344
|
});
|
|
344
345
|
|
|
346
|
+
/** ── Edge captions as HTML chips (2026-11-29) ────────────────────
|
|
347
|
+
* They used to be SVG `<text>` at the route midpoint, which cannot
|
|
348
|
+
* be width-clamped: a long caption sprawled across the neighbouring
|
|
349
|
+
* rank and painted UNDER the node layer (the chest docs defect —
|
|
350
|
+
* "models and keys" readable only up to the box edge). As HTML
|
|
351
|
+
* chips they clamp to `EDGE_LABEL_MAX_W` world px (ellipsis, a CSS
|
|
352
|
+
* var lets a host retune), and each carries its full text in the
|
|
353
|
+
* `title` attribute: the family hover bridge upgrades that to the
|
|
354
|
+
* house tooltip bubble, the touch bridge to the long-press hint
|
|
355
|
+
* bar, and a host with neither bridge installed still gets the
|
|
356
|
+
* native tooltip. Chips live ABOVE the node layer by DOM order —
|
|
357
|
+
* with the layout's band reservation there is nothing to cover,
|
|
358
|
+
* and a chip must never again lose a hiding contest with a box. */
|
|
359
|
+
const labelChips = computed(() => {
|
|
360
|
+
const out: Array<{ key: string; cls: string; x: number; y: number; text: string; max: string }> = [];
|
|
361
|
+
for (const e of edgePaths.value) {
|
|
362
|
+
if (e.label !== null) {
|
|
363
|
+
out.push({
|
|
364
|
+
key: `${e.id}:mid`, cls: "hk-board-edge-label", x: e.labelAt.x, y: e.labelAt.y, text: e.label,
|
|
365
|
+
max: `var(--hk-board-edge-label-max-w, ${EDGE_LABEL_MAX_W}px)`,
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
if (e.labelFrom !== null && e.labelFromAt !== null) {
|
|
369
|
+
out.push({
|
|
370
|
+
key: `${e.id}:from`, cls: "hk-board-edge-endlabel", x: e.labelFromAt.x, y: e.labelFromAt.y, text: e.labelFrom,
|
|
371
|
+
// The end captions are metadata (smaller sheet default): their
|
|
372
|
+
// var must NOT fall back to the caption cap, or a host tuning
|
|
373
|
+
// the caption var would resize multiplicities too (R1 S3-1).
|
|
374
|
+
max: "var(--hk-board-edge-endlabel-max-w, 120px)",
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
if (e.labelTo !== null && e.labelToAt !== null) {
|
|
378
|
+
out.push({
|
|
379
|
+
key: `${e.id}:to`, cls: "hk-board-edge-endlabel", x: e.labelToAt.x, y: e.labelToAt.y, text: e.labelTo,
|
|
380
|
+
max: "var(--hk-board-edge-endlabel-max-w, 120px)",
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
return out;
|
|
385
|
+
});
|
|
386
|
+
|
|
345
387
|
/** One marker per (kind, ink) pair actually used — marker fill cannot
|
|
346
388
|
* follow the referencing stroke on every engine hikari supports, so
|
|
347
389
|
* the defs are minted from the edge list (deterministic, in edge
|
|
@@ -766,39 +808,6 @@ export default defineComponent({
|
|
|
766
808
|
marker-end={e.headEnd ? markerRef(e.headEnd, e.ink) : markerOf(e.arrow, e.ink)}
|
|
767
809
|
marker-start={e.headStart ? markerRef("solid", e.ink) : undefined}
|
|
768
810
|
/>
|
|
769
|
-
{e.label !== null && (
|
|
770
|
-
<text
|
|
771
|
-
class="hk-board-edge-label"
|
|
772
|
-
x={e.labelAt.x}
|
|
773
|
-
y={e.labelAt.y}
|
|
774
|
-
text-anchor="middle"
|
|
775
|
-
dominant-baseline="middle"
|
|
776
|
-
>
|
|
777
|
-
{e.label}
|
|
778
|
-
</text>
|
|
779
|
-
)}
|
|
780
|
-
{e.labelFrom !== null && e.labelFromAt !== null && (
|
|
781
|
-
<text
|
|
782
|
-
class="hk-board-edge-endlabel"
|
|
783
|
-
x={e.labelFromAt.x}
|
|
784
|
-
y={e.labelFromAt.y}
|
|
785
|
-
text-anchor="middle"
|
|
786
|
-
dominant-baseline="middle"
|
|
787
|
-
>
|
|
788
|
-
{e.labelFrom}
|
|
789
|
-
</text>
|
|
790
|
-
)}
|
|
791
|
-
{e.labelTo !== null && e.labelToAt !== null && (
|
|
792
|
-
<text
|
|
793
|
-
class="hk-board-edge-endlabel"
|
|
794
|
-
x={e.labelToAt.x}
|
|
795
|
-
y={e.labelToAt.y}
|
|
796
|
-
text-anchor="middle"
|
|
797
|
-
dominant-baseline="middle"
|
|
798
|
-
>
|
|
799
|
-
{e.labelTo}
|
|
800
|
-
</text>
|
|
801
|
-
)}
|
|
802
811
|
</g>
|
|
803
812
|
))}
|
|
804
813
|
</svg>
|
|
@@ -841,6 +850,22 @@ export default defineComponent({
|
|
|
841
850
|
: null}
|
|
842
851
|
</div>
|
|
843
852
|
))}
|
|
853
|
+
<div class="hk-board-labels">
|
|
854
|
+
{labelChips.value.map((c) => (
|
|
855
|
+
<div
|
|
856
|
+
key={c.key}
|
|
857
|
+
class={c.cls}
|
|
858
|
+
style={{
|
|
859
|
+
left: `${c.x}px`,
|
|
860
|
+
top: `${c.y}px`,
|
|
861
|
+
maxWidth: c.max,
|
|
862
|
+
}}
|
|
863
|
+
title={c.text}
|
|
864
|
+
>
|
|
865
|
+
{c.text}
|
|
866
|
+
</div>
|
|
867
|
+
))}
|
|
868
|
+
</div>
|
|
844
869
|
</div>
|
|
845
870
|
{props.minimap && (
|
|
846
871
|
// Slider drags arrive as ABSOLUTE rung targets — land the camera
|
|
@@ -28,6 +28,18 @@
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
// ── height animation (`animateHeight`, opt-in) ────────────────────────
|
|
32
|
+
// The grid cell keeps the taller generation for the whole exchange, so
|
|
33
|
+
// between different-height panes the surface snaps at the exchange's
|
|
34
|
+
// edges. The component freezes an explicit height, tweens it to the
|
|
35
|
+
// incoming generation's size on this transition, and releases to auto on
|
|
36
|
+
// settle. `overflow: clip` above is what makes the shrink direction
|
|
37
|
+
// readable: the taller outgoing copy slides out through the shrinking
|
|
38
|
+
// box instead of overflowing it.
|
|
39
|
+
.hk-dswap[data-height-anim] {
|
|
40
|
+
transition: height var(--hk-swap-duration, 300ms) var(--ease-out-expo, cubic-bezier(0.19, 1, 0.22, 1));
|
|
41
|
+
}
|
|
42
|
+
|
|
31
43
|
// ── travel ───────────────────────────────────────────────────────────
|
|
32
44
|
// The entering copy starts offset toward the edge it comes FROM and
|
|
33
45
|
// settles to 0; the leaving copy goes on to the opposite edge. Offsets are
|
|
@@ -102,7 +114,9 @@
|
|
|
102
114
|
|
|
103
115
|
// Reduced motion: keep the fade (shortened), drop the travel entirely — the
|
|
104
116
|
// component also zeroes `--hk-swap-travel`, this is the belt to that brace
|
|
105
|
-
// for a host that sets the property itself.
|
|
117
|
+
// for a host that sets the property itself. The height tween goes with the
|
|
118
|
+
// travel: the snap IS the reduced-motion contract (the component skips the
|
|
119
|
+
// freeze when the duration is zero; this covers a host-set duration too).
|
|
106
120
|
@media (prefers-reduced-motion: reduce) {
|
|
107
121
|
.hk-dswap-enter-active,
|
|
108
122
|
.hk-dswap-leave-active {
|
|
@@ -113,4 +127,8 @@
|
|
|
113
127
|
.hk-dswap-leave-to {
|
|
114
128
|
transform: none;
|
|
115
129
|
}
|
|
130
|
+
|
|
131
|
+
.hk-dswap[data-height-anim] {
|
|
132
|
+
transition: none;
|
|
133
|
+
}
|
|
116
134
|
}
|