@celestia-island/hikari 0.55.413 → 0.55.415
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/HkSelectionGrid.scss +20 -8
- package/src/components/HkSelectionGrid.test.tsx +357 -0
- package/src/components/HkSelectionGrid.tsx +5 -3
- package/src/components/HkUsageFlow.barrel.test.ts +39 -0
- package/src/components/HkUsageFlow.scss +133 -0
- package/src/components/HkUsageFlow.test.tsx +236 -0
- package/src/components/HkUsageFlow.tsx +253 -0
- package/src/components/usageFlowLayout.test.ts +699 -0
- package/src/components/usageFlowLayout.ts +716 -0
- package/src/index.ts +20 -0
package/package.json
CHANGED
|
@@ -271,17 +271,29 @@
|
|
|
271
271
|
}
|
|
272
272
|
|
|
273
273
|
/* ── Optional selected edge ──────────────────────────────────────────────
|
|
274
|
-
A
|
|
275
|
-
|
|
276
|
-
|
|
274
|
+
A primary accent TAB on the item's LEADING side, DETACHED from the
|
|
275
|
+
selected frame. The frame's emphasis is one even inset ring (1px border
|
|
276
|
+
+ 1px ring = 2px on every side, unchanged by this rule); the tab is a
|
|
277
|
+
separate 3px pill.
|
|
278
|
+
|
|
279
|
+
Measured geometry (Chrome, 2026-11-17): an absolutely-positioned child
|
|
280
|
+
resolves against the PADDING box, so `inset-inline-start: 4px` puts the
|
|
281
|
+
tab 5px in from the border box — 3px of visible gap to the ring — and
|
|
282
|
+
leaves 5px of clearance to the label (3px in `dense`, whose leading
|
|
283
|
+
padding is 10px). `top`/`bottom` inset the pill the same 4px, so it
|
|
284
|
+
stops short of the frame instead of running into it.
|
|
285
|
+
|
|
286
|
+
The flush bar this replaced sat at the padding edge and merged with the
|
|
287
|
+
border + ring into one unbroken 4px primary slab on the leading edge
|
|
288
|
+
only — the frame read as lopsided/fattened there (fleet admission card,
|
|
289
|
+
user report 2026-11-17). A pseudo element, so nothing shifts. */
|
|
277
290
|
.hk-selection-grid[data-edge] .hk-selection-grid-item[data-selected]::before {
|
|
278
291
|
content: "";
|
|
279
292
|
position: absolute;
|
|
280
|
-
inset-inline-start: 0;
|
|
281
|
-
top: 0;
|
|
282
|
-
bottom: 0;
|
|
293
|
+
inset-inline-start: var(--space-4, 0.25rem);
|
|
294
|
+
top: var(--space-4, 0.25rem);
|
|
295
|
+
bottom: var(--space-4, 0.25rem);
|
|
283
296
|
width: 3px;
|
|
284
|
-
border-
|
|
285
|
-
border-end-start-radius: var(--radius-sm, 4px);
|
|
297
|
+
border-radius: var(--radius-full, 9999px);
|
|
286
298
|
background: var(--hi-color-primary, #7aa2f7);
|
|
287
299
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { afterEach, describe, expect, it } from "vitest";
|
|
2
2
|
import { createApp, h } from "vue";
|
|
3
|
+
import { compile } from "sass";
|
|
4
|
+
import { dirname, resolve } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
3
6
|
|
|
4
7
|
import HkSelectionGrid, { type SelectionGridItem } from "./HkSelectionGrid";
|
|
5
8
|
|
|
@@ -16,6 +19,10 @@ import HkSelectionGrid, { type SelectionGridItem } from "./HkSelectionGrid";
|
|
|
16
19
|
* the floor as a CSS var, and NO `data-cols` hook (the narrow-viewport
|
|
17
20
|
* overrides key off data-cols and must not fight the fluid template)
|
|
18
21
|
* - without `minItemWidth` the fixed `columns` contract is unchanged
|
|
22
|
+
* - `selectedEdge`'s accent tab stays DETACHED from the selected frame
|
|
23
|
+
* (stylesheet contract below): flush against border + inset ring it
|
|
24
|
+
* merged into one fattened leading edge (fleet admission card, user
|
|
25
|
+
* report 2026-11-17)
|
|
19
26
|
*
|
|
20
27
|
* House style: raw createApp mounts on a shared container list torn down
|
|
21
28
|
* after each case; DOM assertions via document queries.
|
|
@@ -234,3 +241,353 @@ describe("HkSelectionGrid list layout, actions and edge", () => {
|
|
|
234
241
|
});
|
|
235
242
|
});
|
|
236
243
|
});
|
|
244
|
+
|
|
245
|
+
describe("HkSelectionGrid selected-edge stylesheet contract", () => {
|
|
246
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
247
|
+
const css = compile(resolve(here, "HkSelectionGrid.scss"), { style: "expanded" }).css;
|
|
248
|
+
|
|
249
|
+
// ── A dependency-free CSS reader ──────────────────────────────────────
|
|
250
|
+
// Text scraping cannot answer the questions these contracts ask (which
|
|
251
|
+
// RULE wins the cascade, whether a SHORTHAND set a width, whether a
|
|
252
|
+
// later rule overrides the base one), so the compiled sheet is walked
|
|
253
|
+
// into rules + declarations in DOCUMENT order. Quotes, comments and
|
|
254
|
+
// parentheses are tracked while scanning, so a comma inside `var(...)`
|
|
255
|
+
// or `color-mix(...)` never splits a value.
|
|
256
|
+
|
|
257
|
+
interface CssRule {
|
|
258
|
+
selector: string;
|
|
259
|
+
declarations: Array<[string, string]>;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/** Split a declaration list on `;` outside quotes/parentheses. */
|
|
263
|
+
function splitDeclarations(body: string): Array<[string, string]> {
|
|
264
|
+
const out: Array<[string, string]> = [];
|
|
265
|
+
let current = "";
|
|
266
|
+
let quote = "";
|
|
267
|
+
let depth = 0;
|
|
268
|
+
for (let i = 0; i < body.length; i += 1) {
|
|
269
|
+
const ch = body[i];
|
|
270
|
+
if (ch === "/" && body[i + 1] === "*") {
|
|
271
|
+
const end = body.indexOf("*/", i + 2);
|
|
272
|
+
i = end < 0 ? body.length : end + 2;
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
if (quote) {
|
|
276
|
+
current += ch;
|
|
277
|
+
if (ch === "\\") {
|
|
278
|
+
current += body[i + 1] ?? "";
|
|
279
|
+
i += 1;
|
|
280
|
+
} else if (ch === quote) {
|
|
281
|
+
quote = "";
|
|
282
|
+
}
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
if (ch === '"' || ch === "'") {
|
|
286
|
+
quote = ch;
|
|
287
|
+
current += ch;
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
290
|
+
if (ch === "(") depth += 1;
|
|
291
|
+
if (ch === ")") depth -= 1;
|
|
292
|
+
if (ch === ";" && depth === 0) {
|
|
293
|
+
const at = current.indexOf(":");
|
|
294
|
+
if (at > 0) {
|
|
295
|
+
out.push([
|
|
296
|
+
current.slice(0, at).trim().toLowerCase(),
|
|
297
|
+
current.slice(at + 1).trim(),
|
|
298
|
+
]);
|
|
299
|
+
}
|
|
300
|
+
current = "";
|
|
301
|
+
continue;
|
|
302
|
+
}
|
|
303
|
+
current += ch;
|
|
304
|
+
}
|
|
305
|
+
const at = current.indexOf(":");
|
|
306
|
+
if (at > 0) {
|
|
307
|
+
out.push([current.slice(0, at).trim().toLowerCase(), current.slice(at + 1).trim()]);
|
|
308
|
+
}
|
|
309
|
+
return out;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/** Every style rule in the sheet, in document order (at-rule bodies are
|
|
313
|
+
* walked too, so a media override is graded like any other rule). */
|
|
314
|
+
function parseRules(source: string): CssRule[] {
|
|
315
|
+
const rules: CssRule[] = [];
|
|
316
|
+
let i = 0;
|
|
317
|
+
while (i < source.length) {
|
|
318
|
+
if (/\s/.test(source[i])) {
|
|
319
|
+
i += 1;
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
if (source[i] === "/" && source[i + 1] === "*") {
|
|
323
|
+
const end = source.indexOf("*/", i + 2);
|
|
324
|
+
i = end < 0 ? source.length : end + 2;
|
|
325
|
+
continue;
|
|
326
|
+
}
|
|
327
|
+
// Prelude: up to the `{` that opens this block — or up to a `;`, which
|
|
328
|
+
// means this is a statement at-rule (`@charset "UTF-8";` opens the
|
|
329
|
+
// sheet) and has no body to read.
|
|
330
|
+
let j = i;
|
|
331
|
+
let quote = "";
|
|
332
|
+
let paren = 0;
|
|
333
|
+
let statement = false;
|
|
334
|
+
while (j < source.length) {
|
|
335
|
+
const ch = source[j];
|
|
336
|
+
if (quote) {
|
|
337
|
+
if (ch === "\\") j += 1;
|
|
338
|
+
else if (ch === quote) quote = "";
|
|
339
|
+
j += 1;
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
// Comments are skipped HERE too: prose like "the item's leading
|
|
343
|
+
// side" is an apostrophe to a naive scanner, which then swallows the
|
|
344
|
+
// rest of the sheet as a string.
|
|
345
|
+
if (ch === "/" && source[j + 1] === "*") {
|
|
346
|
+
const end = source.indexOf("*/", j + 2);
|
|
347
|
+
j = end < 0 ? source.length : end + 2;
|
|
348
|
+
continue;
|
|
349
|
+
}
|
|
350
|
+
if (ch === '"' || ch === "'") {
|
|
351
|
+
quote = ch;
|
|
352
|
+
j += 1;
|
|
353
|
+
continue;
|
|
354
|
+
}
|
|
355
|
+
if (ch === "(") paren += 1;
|
|
356
|
+
else if (ch === ")") paren -= 1;
|
|
357
|
+
else if (ch === "{" && paren === 0) break;
|
|
358
|
+
else if (ch === ";" && paren === 0) {
|
|
359
|
+
statement = true;
|
|
360
|
+
break;
|
|
361
|
+
} else if (ch === "}" && paren === 0) {
|
|
362
|
+
j += 1;
|
|
363
|
+
statement = true;
|
|
364
|
+
break;
|
|
365
|
+
}
|
|
366
|
+
j += 1;
|
|
367
|
+
}
|
|
368
|
+
if (j >= source.length) break;
|
|
369
|
+
if (statement) {
|
|
370
|
+
i = j + 1;
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
const prelude = source.slice(i, j).trim();
|
|
374
|
+
// Body: balanced braces.
|
|
375
|
+
let k = j + 1;
|
|
376
|
+
let depth = 1;
|
|
377
|
+
let bodyQuote = "";
|
|
378
|
+
let bodyParen = 0;
|
|
379
|
+
while (k < source.length && depth > 0) {
|
|
380
|
+
const ch = source[k];
|
|
381
|
+
if (ch === "/" && source[k + 1] === "*") {
|
|
382
|
+
const end = source.indexOf("*/", k + 2);
|
|
383
|
+
k = end < 0 ? source.length : end + 2;
|
|
384
|
+
continue;
|
|
385
|
+
}
|
|
386
|
+
if (bodyQuote) {
|
|
387
|
+
if (ch === "\\") k += 1;
|
|
388
|
+
else if (ch === bodyQuote) bodyQuote = "";
|
|
389
|
+
k += 1;
|
|
390
|
+
continue;
|
|
391
|
+
}
|
|
392
|
+
if (ch === '"' || ch === "'") {
|
|
393
|
+
bodyQuote = ch;
|
|
394
|
+
k += 1;
|
|
395
|
+
continue;
|
|
396
|
+
}
|
|
397
|
+
if (ch === "(") bodyParen += 1;
|
|
398
|
+
else if (ch === ")") bodyParen -= 1;
|
|
399
|
+
else if (ch === "{" && bodyParen === 0) depth += 1;
|
|
400
|
+
else if (ch === "}" && bodyParen === 0) depth -= 1;
|
|
401
|
+
if (depth === 0) break;
|
|
402
|
+
k += 1;
|
|
403
|
+
}
|
|
404
|
+
const body = source.slice(j + 1, k);
|
|
405
|
+
if (prelude.startsWith("@")) {
|
|
406
|
+
rules.push(...parseRules(body));
|
|
407
|
+
} else if (prelude) {
|
|
408
|
+
rules.push({ selector: prelude, declarations: splitDeclarations(body) });
|
|
409
|
+
}
|
|
410
|
+
i = k + 1;
|
|
411
|
+
}
|
|
412
|
+
return rules;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
const rules = parseRules(css);
|
|
416
|
+
|
|
417
|
+
/** The declarations that apply to an exact selector, in cascade order. */
|
|
418
|
+
function declarationsFor(selector: string): Array<[string, string]> {
|
|
419
|
+
return rules
|
|
420
|
+
.filter((r) => r.selector.split(",").some((one) => one.trim() === selector))
|
|
421
|
+
.flatMap((r) => r.declarations);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/** Property → the LAST value declared for it (what the cascade uses). */
|
|
425
|
+
function computedFor(selector: string): Map<string, string> {
|
|
426
|
+
const map = new Map<string, string>();
|
|
427
|
+
for (const [prop, value] of declarationsFor(selector)) map.set(prop, value);
|
|
428
|
+
return map;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/** Split a comma-separated CSS value into layers, ignoring commas nested
|
|
432
|
+
* inside a function (`color-mix(in srgb, …)`, `var(--x, …)`). */
|
|
433
|
+
function splitLayers(value: string): string[] {
|
|
434
|
+
const layers: string[] = [];
|
|
435
|
+
let current = "";
|
|
436
|
+
let depth = 0;
|
|
437
|
+
for (const ch of value) {
|
|
438
|
+
if (ch === "(") depth += 1;
|
|
439
|
+
if (ch === ")") depth -= 1;
|
|
440
|
+
if (ch === "," && depth === 0) {
|
|
441
|
+
layers.push(current.trim());
|
|
442
|
+
current = "";
|
|
443
|
+
continue;
|
|
444
|
+
}
|
|
445
|
+
current += ch;
|
|
446
|
+
}
|
|
447
|
+
if (current.trim()) layers.push(current.trim());
|
|
448
|
+
return layers;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
const TAB = ".hk-selection-grid[data-edge] .hk-selection-grid-item[data-selected]::before";
|
|
452
|
+
const ITEM = ".hk-selection-grid-item";
|
|
453
|
+
const SELECTED = ".hk-selection-grid-item[data-selected]";
|
|
454
|
+
|
|
455
|
+
/** Rules whose selector list names this class, in document order. A
|
|
456
|
+
* source-level pin has to look at EVERY rule that can match the element,
|
|
457
|
+
* not just the one canonical spelling — otherwise a higher-specificity
|
|
458
|
+
* descendant selector or a `::after` clone overrides the canonical rule
|
|
459
|
+
* in the browser while this file stays green. */
|
|
460
|
+
function rulesNaming(needle: string): CssRule[] {
|
|
461
|
+
return rules.filter((r) =>
|
|
462
|
+
r.selector.split(",").some((one) => one.includes(needle)),
|
|
463
|
+
);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/** Normalized form of one compound selector: `:before` and `::before` are
|
|
467
|
+
* the same pseudo-element in CSS, so they are compared as one. */
|
|
468
|
+
function normalized(selector: string): string {
|
|
469
|
+
return selector.replace(/\s+/g, " ").trim().replace(/(^|[^:]):(before|after)\b/g, "$1::$2");
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
it("detaches the accent tab from the selected frame", () => {
|
|
473
|
+
// Flush (`0`), the bar merged with the 1px border and the 1px inset ring
|
|
474
|
+
// into one unbroken primary slab on the leading edge — the reported
|
|
475
|
+
// defect. Exact values, so a zeroed FALLBACK cannot pass either.
|
|
476
|
+
const tab = computedFor(TAB);
|
|
477
|
+
expect(tab.get("position")).toBe("absolute");
|
|
478
|
+
expect(tab.get("inset-inline-start")).toBe("var(--space-4, 0.25rem)");
|
|
479
|
+
expect(tab.get("top")).toBe("var(--space-4, 0.25rem)");
|
|
480
|
+
expect(tab.get("bottom")).toBe("var(--space-4, 0.25rem)");
|
|
481
|
+
});
|
|
482
|
+
|
|
483
|
+
it("draws exactly one 3px pill, and it is the only tab on the item", () => {
|
|
484
|
+
// The width IS the clearance budget: the leading padding is 12px (10px
|
|
485
|
+
// dense), so a wider bar eats into the label and a zero width renders
|
|
486
|
+
// the feature away. `width` is read as a PROPERTY, so `max-width: 3px`
|
|
487
|
+
// (which computes to nothing) cannot satisfy it.
|
|
488
|
+
const tab = computedFor(TAB);
|
|
489
|
+
expect(tab.get("width")).toBe("3px");
|
|
490
|
+
expect(tab.get("border-radius")).toBe("var(--radius-full, 9999px)");
|
|
491
|
+
// …and it has to be DRAWN: a transparent or display-less tab renders
|
|
492
|
+
// nothing while every geometry value above still reads correctly.
|
|
493
|
+
expect(tab.get("content")).toBe('""');
|
|
494
|
+
expect(tab.get("display")).toBeUndefined();
|
|
495
|
+
expect(tab.get("background")).toBe("var(--hi-color-primary, #7aa2f7)");
|
|
496
|
+
// Exactly ONE pseudo-element draws on a selected item. A second tab
|
|
497
|
+
// (a `::after` clone, or the single-colon spelling, or a `:hover`
|
|
498
|
+
// variant) would paint a competing bar the geometry pins never see.
|
|
499
|
+
const tabs = rulesNaming(".hk-selection-grid-item[data-selected]")
|
|
500
|
+
.filter((r) => /::?(before|after)\b/.test(r.selector))
|
|
501
|
+
.map((r) => normalized(r.selector));
|
|
502
|
+
expect(tabs).toEqual([normalized(TAB)]);
|
|
503
|
+
// The tab's declaration set is closed: no extra `inset`/`margin`/
|
|
504
|
+
// `translate`/`rotate` may move or resize it behind the pins' back.
|
|
505
|
+
expect(new Set(Object.keys(Object.fromEntries(declarationsFor(TAB))))).toEqual(
|
|
506
|
+
new Set([
|
|
507
|
+
"content",
|
|
508
|
+
"position",
|
|
509
|
+
"inset-inline-start",
|
|
510
|
+
"top",
|
|
511
|
+
"bottom",
|
|
512
|
+
"width",
|
|
513
|
+
"border-radius",
|
|
514
|
+
"background",
|
|
515
|
+
]),
|
|
516
|
+
);
|
|
517
|
+
});
|
|
518
|
+
|
|
519
|
+
it("declares no per-side border geometry anywhere in the sheet", () => {
|
|
520
|
+
// THIS IS A SOURCE-LEVEL PIN, not a rendering proof, and its scope is
|
|
521
|
+
// "no single SIDE may get thicker". It keeps the frame's thickness coming
|
|
522
|
+
// from ONE uniform `border` shorthand plus the selected ring and rejects
|
|
523
|
+
// every per-side border property by NAME — a whitelist, because
|
|
524
|
+
// enumerating the shapes a side could be thickened through (`-width`, the
|
|
525
|
+
// axis shorthands, `border-left`, …) misses one every round.
|
|
526
|
+
//
|
|
527
|
+
// Out of scope on purpose: a UNIFORM thickening of the whole frame
|
|
528
|
+
// (`outline: 2px solid` with a negative offset, or a 3px `border` on the
|
|
529
|
+
// selected state) is a design change, not this defect — the other pins
|
|
530
|
+
// still hold the ring and the tab. Which four sides the browser really
|
|
531
|
+
// paints was verified by pixel measurement during review (see the PR).
|
|
532
|
+
const borderProps = new Set(
|
|
533
|
+
rules
|
|
534
|
+
.flatMap((r) => r.declarations)
|
|
535
|
+
.map(([prop]) => prop)
|
|
536
|
+
.filter((prop) => /^border(-|$)/.test(prop)),
|
|
537
|
+
);
|
|
538
|
+
expect([...borderProps].sort()).toEqual([
|
|
539
|
+
"border",
|
|
540
|
+
"border-color",
|
|
541
|
+
"border-radius",
|
|
542
|
+
"border-start-start-radius",
|
|
543
|
+
"border-end-start-radius",
|
|
544
|
+
].filter((prop) => borderProps.has(prop)).sort());
|
|
545
|
+
// The one width-bearing declaration is the item's shorthand, and the
|
|
546
|
+
// selected state colours the border instead of resizing it.
|
|
547
|
+
expect(computedFor(ITEM).get("border")).toMatch(/^1px solid /);
|
|
548
|
+
expect(computedFor(SELECTED).get("border")).toBeUndefined();
|
|
549
|
+
expect(computedFor(SELECTED).get("border-color")).toBe(
|
|
550
|
+
"var(--hi-color-primary, #7aa2f7)",
|
|
551
|
+
);
|
|
552
|
+
});
|
|
553
|
+
|
|
554
|
+
it("keeps the selected emphasis a single inset ring, and only there", () => {
|
|
555
|
+
// One inset ring, split with a depth-aware scanner so a legitimate single
|
|
556
|
+
// layer carrying `color-mix(...)` is not mistaken for two.
|
|
557
|
+
const layers = splitLayers(computedFor(SELECTED).get("box-shadow") ?? "");
|
|
558
|
+
expect(layers).toHaveLength(1);
|
|
559
|
+
expect(layers[0]).toMatch(/^inset 0 0 0 1px/);
|
|
560
|
+
// EVERY shadow layer of EVERY rule that names the item is inspected, not
|
|
561
|
+
// just the base selected rule: the reported state is a HOVERED selected
|
|
562
|
+
// row, so a one-sided `inset 3px 0 0 3px` in `[data-selected]:hover`
|
|
563
|
+
// reproduces the lopsidedness with the base rule untouched. Allowed
|
|
564
|
+
// layers are exactly the two shapes the sheet really uses: the even 1px
|
|
565
|
+
// inset ring, and non-inset elevation shadows.
|
|
566
|
+
const offenders: string[] = [];
|
|
567
|
+
for (const rule of rulesNaming(".hk-selection-grid-item")) {
|
|
568
|
+
for (const [prop, value] of rule.declarations) {
|
|
569
|
+
if (prop !== "box-shadow") continue;
|
|
570
|
+
for (const layer of splitLayers(value)) {
|
|
571
|
+
const inset = /^inset\b/.test(layer);
|
|
572
|
+
if (inset && !/^inset 0 0 0 1px /.test(layer)) {
|
|
573
|
+
offenders.push(`${rule.selector} → ${layer}`);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
expect(offenders).toEqual([]);
|
|
579
|
+
// The selected state and its `:hover` sibling are the only two rules that
|
|
580
|
+
// may carry an inset ring at all.
|
|
581
|
+
const ringed = rulesNaming(".hk-selection-grid-item")
|
|
582
|
+
.filter((r) =>
|
|
583
|
+
r.declarations.some(
|
|
584
|
+
([prop, value]) => prop === "box-shadow" && /inset\b/.test(value),
|
|
585
|
+
),
|
|
586
|
+
)
|
|
587
|
+
.map((r) => normalized(r.selector))
|
|
588
|
+
.sort();
|
|
589
|
+
expect(ringed).toEqual(
|
|
590
|
+
[normalized(SELECTED), normalized(`${SELECTED}:hover`)].sort(),
|
|
591
|
+
);
|
|
592
|
+
});
|
|
593
|
+
});
|
|
@@ -60,9 +60,11 @@ export default defineComponent({
|
|
|
60
60
|
* picker list rather than a card grid): the check cell centers on the
|
|
61
61
|
* row's trailing edge instead of parking at the top corner. */
|
|
62
62
|
layout: { type: String as PropType<"grid" | "list">, default: "grid" },
|
|
63
|
-
/** Optional emphasis for the selected item: a
|
|
64
|
-
*
|
|
65
|
-
* geometry never shifts
|
|
63
|
+
/** Optional emphasis for the selected item: a primary accent tab on
|
|
64
|
+
* the item's leading side, DETACHED from the selected frame (a pseudo
|
|
65
|
+
* element inside the border box, so the geometry never shifts — and
|
|
66
|
+
* the 2px ring stays uniform on all four sides instead of merging
|
|
67
|
+
* with the tab into a fattened leading edge). */
|
|
66
68
|
selectedEdge: { type: Boolean, default: false },
|
|
67
69
|
},
|
|
68
70
|
emits: {
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import * as barrel from "../index";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The public barrel guard for the usage-flow family (the
|
|
7
|
+
* HkCalendarHeatmap.barrel.test.ts precedent): every other test reaches
|
|
8
|
+
* the modules through their direct paths, so deleting the re-export lines
|
|
9
|
+
* from index.ts would leave the whole suite green — only an external
|
|
10
|
+
* consumer (arona / shittim-chest) would notice.
|
|
11
|
+
*
|
|
12
|
+
* This file deliberately does NOT mock "@celestia-island/hikari": the
|
|
13
|
+
* package's self-reference resolves to this very module.
|
|
14
|
+
*/
|
|
15
|
+
describe("the public barrel", () => {
|
|
16
|
+
it("exports the component under both family names", () => {
|
|
17
|
+
expect(barrel.HkUsageFlow, "HkUsageFlow must be re-exported").toBeTruthy();
|
|
18
|
+
expect(barrel.HUsageFlow).toBe(barrel.HkUsageFlow);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("exports the pure layout helpers", () => {
|
|
22
|
+
expect(typeof barrel.usageFlowLayout).toBe("function");
|
|
23
|
+
expect(typeof barrel.truncateFlowLabel).toBe("function");
|
|
24
|
+
expect(typeof barrel.formatFlowPercent).toBe("function");
|
|
25
|
+
expect(typeof barrel.flowLabelVisible).toBe("function");
|
|
26
|
+
expect(Array.isArray(barrel.USAGE_FLOW_PALETTE)).toBe(true);
|
|
27
|
+
expect(barrel.USAGE_FLOW_PALETTE.length).toBeGreaterThanOrEqual(8);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("lays out a minimal flow through the barrel surface", () => {
|
|
31
|
+
const layout = barrel.usageFlowLayout([
|
|
32
|
+
{ source: "a", middle: "b", target: "c", value: 1 },
|
|
33
|
+
]);
|
|
34
|
+
expect(layout.empty).toBe(false);
|
|
35
|
+
expect(layout.nodes).toHaveLength(3);
|
|
36
|
+
expect(layout.links).toHaveLength(2);
|
|
37
|
+
expect(layout.legend.map((row) => row.label)).toEqual(["c"]);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// HkUsageFlow anatomy — self-sufficient styling (the component
|
|
2
|
+
// self-sufficiency guard): every class lives here, no host atomic or
|
|
3
|
+
// utility layer. Ribbon/node fills are inline theme-token expressions the
|
|
4
|
+
// layout computes; ink here comes from theme tokens, so light/dark/brand
|
|
5
|
+
// flips repaint without a re-render.
|
|
6
|
+
//
|
|
7
|
+
// AI-generated (DeepSeek V4.1 via DeepSeek Harness), 2026-11-17 — SySL-1.0 §2.3.
|
|
8
|
+
|
|
9
|
+
@use "../styles/polyfill" as *;
|
|
10
|
+
|
|
11
|
+
.hk-usage-flow {
|
|
12
|
+
width: 100%;
|
|
13
|
+
|
|
14
|
+
&__body {
|
|
15
|
+
width: 100%;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&__chart {
|
|
19
|
+
display: block;
|
|
20
|
+
width: 100%;
|
|
21
|
+
height: auto;
|
|
22
|
+
overflow: visible;
|
|
23
|
+
/* The chart's coordinate system is LTR: label anchors are
|
|
24
|
+
direction-relative in SVG, so an RTL host would otherwise flip
|
|
25
|
+
start/end and paint the first column's label across its own bar
|
|
26
|
+
(and the last column's past the frame). The axis is LTR by
|
|
27
|
+
construction; label TEXT still renders with its own bidi. */
|
|
28
|
+
direction: ltr;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Ribbons read as "flow into the target": translucent so stacked paths
|
|
32
|
+
// never turn opaque where two lanes overlap, and the node/label ink stays
|
|
33
|
+
// legible on top.
|
|
34
|
+
&__ribbon {
|
|
35
|
+
fill-opacity: 0.42;
|
|
36
|
+
transition: fill-opacity 0.16s ease;
|
|
37
|
+
stroke: none;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&__bar {
|
|
41
|
+
shape-rendering: geometricPrecision;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Labels sit over ribbons: a background-coloured halo keeps them legible
|
|
45
|
+
// without a second layout pass (SVG2 paint-order; the halo is the same
|
|
46
|
+
// frame colour the chart sits on).
|
|
47
|
+
&__label {
|
|
48
|
+
font-size: var(--text-xs, 12px);
|
|
49
|
+
fill: rgb(var(--color-text) / 0.9);
|
|
50
|
+
paint-order: stroke;
|
|
51
|
+
stroke: rgb(var(--color-background) / 0.92);
|
|
52
|
+
stroke-width: 3px;
|
|
53
|
+
stroke-linejoin: round;
|
|
54
|
+
pointer-events: none;
|
|
55
|
+
@include user-select(none);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
&__label--others {
|
|
59
|
+
font-style: italic;
|
|
60
|
+
fill: rgb(var(--color-text-secondary) / 0.9);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
&__legend {
|
|
64
|
+
display: flex;
|
|
65
|
+
flex-wrap: wrap;
|
|
66
|
+
gap: 4px 18px;
|
|
67
|
+
margin: 10px 0 0;
|
|
68
|
+
padding: 0;
|
|
69
|
+
list-style: none;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
&__legend-row {
|
|
73
|
+
display: flex;
|
|
74
|
+
align-items: baseline;
|
|
75
|
+
gap: 6px;
|
|
76
|
+
font-size: var(--text-sm, 13px);
|
|
77
|
+
min-width: 0;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// A registered model with no measured usage keeps its slot but recedes.
|
|
81
|
+
&__legend-row--idle {
|
|
82
|
+
opacity: 0.45;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
&__legend-swatch {
|
|
86
|
+
width: 9px;
|
|
87
|
+
height: 9px;
|
|
88
|
+
border-radius: 2px;
|
|
89
|
+
flex: none;
|
|
90
|
+
align-self: center;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
&__legend-label {
|
|
94
|
+
color: rgb(var(--color-text) / 0.88);
|
|
95
|
+
max-width: 22em;
|
|
96
|
+
overflow: hidden;
|
|
97
|
+
text-overflow: ellipsis;
|
|
98
|
+
white-space: nowrap;
|
|
99
|
+
/* The --others row italicizes this box; the inline-end cushion keeps a
|
|
100
|
+
synthetic-oblique trailing stroke from being shaved (textClip
|
|
101
|
+
contract, HkAffixPicker precedent). */
|
|
102
|
+
padding-inline-end: 0.2em;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
&__legend-value {
|
|
106
|
+
color: var(--hi-color-muted);
|
|
107
|
+
font-variant-numeric: tabular-nums;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
&__legend-pct {
|
|
111
|
+
color: var(--hi-color-muted);
|
|
112
|
+
font-variant-numeric: tabular-nums;
|
|
113
|
+
min-width: 3.2em;
|
|
114
|
+
text-align: end;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
&--empty {
|
|
118
|
+
/* Auto height: the empty face may also carry the registered roster,
|
|
119
|
+
and a fixed 120px box would clip a long one. */
|
|
120
|
+
min-height: 120px;
|
|
121
|
+
display: flex;
|
|
122
|
+
flex-direction: column;
|
|
123
|
+
align-items: center;
|
|
124
|
+
justify-content: center;
|
|
125
|
+
gap: 8px;
|
|
126
|
+
padding: 12px 0;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
&__empty {
|
|
130
|
+
font-size: var(--text-sm, 13px);
|
|
131
|
+
color: var(--hi-color-muted);
|
|
132
|
+
}
|
|
133
|
+
}
|