@celestia-island/hikari 0.55.414 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celestia-island/hikari",
3
- "version": "0.55.414",
3
+ "version": "0.55.415",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Hikari UI library, Vue 3 runtime — one design system for Vue 3 and Rust/WASM applications",
@@ -271,17 +271,29 @@
271
271
  }
272
272
 
273
273
  /* ── Optional selected edge ──────────────────────────────────────────────
274
- A thickened primary bar on the item's LEADING side, drawn inside the
275
- border box (a pseudo element, so nothing shifts) — the "this is the
276
- chosen one" cue some hosts want on top of the ring + check. */
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-start-start-radius: var(--radius-sm, 4px);
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 thickened primary edge
64
- * bar on the item's leading side (drawn inside the border box, so the
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: {