@celestia-island/hikari 0.55.343 → 0.55.345

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.343",
3
+ "version": "0.55.345",
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",
@@ -3,11 +3,26 @@
3
3
  .hk-media-slider {
4
4
  position: relative;
5
5
  height: 6px;
6
- border-radius: var(--radius-sm);
7
- background: rgb(var(--color-muted) / 22%);
8
6
  cursor: pointer;
9
7
  touch-action: none;
10
8
  @include user-select(none);
9
+ // The drawable rail is inset by the thumb radius at each end (6px — the
10
+ // thumb is 12px at every size); the value comes inline from the component,
11
+ // this is only the no-inline fallback. A thumb parked on 0/1 then rests
12
+ // ON the rail instead of hanging off its cap (2026-11-11, the same shape
13
+ // HkSlider ships).
14
+ --hk-media-slider-rail-inset: 6px;
15
+ }
16
+
17
+ // The track paint moved off the element box onto ::before so it can start
18
+ // and end at the rail edges (the element itself stays the full-width hit
19
+ // area).
20
+ .hk-media-slider::before {
21
+ content: "";
22
+ position: absolute;
23
+ inset: 0 var(--hk-media-slider-rail-inset, 6px);
24
+ border-radius: var(--radius-full, 9999px);
25
+ background: rgb(var(--color-muted) / 22%);
11
26
  }
12
27
 
13
28
  .hk-media-slider[data-size="sm"] {
@@ -21,15 +36,20 @@
21
36
 
22
37
  .hk-media-slider-buffered {
23
38
  position: absolute;
24
- inset: 0 auto 0 0;
25
- border-radius: var(--radius-sm);
39
+ inset: 0 auto 0 var(--hk-media-slider-rail-inset, 6px);
40
+ // Flat start (hidden under the fill), rounded end cap: the buffered edge
41
+ // is visible past the fill at partial playback.
42
+ border-radius: 0 var(--radius-full, 9999px) var(--radius-full, 9999px) 0;
26
43
  background: rgb(var(--color-muted) / 40%);
27
44
  }
28
45
 
29
46
  .hk-media-slider-fill {
30
47
  position: absolute;
31
- inset: 0 auto 0 0;
32
- border-radius: var(--radius-sm);
48
+ inset: 0 auto 0 var(--hk-media-slider-rail-inset, 6px);
49
+ // The LEFT cap stays FLAT — a pill cap on a thin saturated bar reads as a
50
+ // pointed nib at the rail start (2026-11-11 user report) — while the end
51
+ // cap stays round and closes the rail off at 100%.
52
+ border-radius: 0 var(--radius-full, 9999px) var(--radius-full, 9999px) 0;
33
53
  background: rgb(var(--color-primary));
34
54
  }
35
55
 
@@ -0,0 +1,139 @@
1
+ import { afterEach, describe, expect, it } from "vitest";
2
+ import { createApp, h, ref } from "vue";
3
+ import { readFileSync } from "node:fs";
4
+ import { dirname, join } from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+
7
+ import HkMediaSlider from "./HkMediaSlider";
8
+
9
+ /**
10
+ * HkMediaSlider contract (the seek/volume primitive): the 2026-11-11
11
+ * rail-inset geometry — thumb parked on 0/1 rests ON the rail, buffered and
12
+ * fill widths anchor at the rail start (flat cap), presses map into the
13
+ * inset rail. The nested precision editor this shares visual language with
14
+ * is pinned in hikari's HkSlider suite.
15
+ *
16
+ * Repo test convention: raw createApp + document queries.
17
+ */
18
+
19
+ const mounts: Array<{ app: ReturnType<typeof createApp>; container: HTMLElement }> = [];
20
+
21
+ function mountSlider(ratio: number, buffered = 0) {
22
+ const container = document.createElement("div");
23
+ document.body.appendChild(container);
24
+ const seen: Array<number> = [];
25
+ const app = createApp({
26
+ setup: () => () =>
27
+ h(HkMediaSlider, {
28
+ ratio,
29
+ buffered,
30
+ ariaLabel: "Seek",
31
+ "onUpdate:ratio": (v: number) => seen.push(v),
32
+ }),
33
+ });
34
+ app.mount(container);
35
+ mounts.push({ app, container });
36
+ const slider = container.querySelector(".hk-media-slider") as HTMLElement;
37
+ return { slider, seen };
38
+ }
39
+
40
+ function pinRect(slider: HTMLElement) {
41
+ Object.defineProperty(slider, "getBoundingClientRect", {
42
+ configurable: true,
43
+ value: () =>
44
+ ({ left: 0, width: 200, height: 6, top: 0, right: 200, bottom: 6, x: 0, y: 0 }) as DOMRect,
45
+ });
46
+ }
47
+
48
+ function pointer(type: string, clientX: number) {
49
+ return new PointerEvent(type, { bubbles: true, clientX, pointerId: 1, pointerType: "mouse" });
50
+ }
51
+
52
+ afterEach(() => {
53
+ for (const { app, container } of mounts.splice(0)) {
54
+ app.unmount();
55
+ container.remove();
56
+ }
57
+ });
58
+
59
+ describe("HkMediaSlider — the inset rail", () => {
60
+ it("keeps endpoint thumbs ON the rail with a flat-start fill", () => {
61
+ // Source contract: the pill cap on a thin saturated bar read as a
62
+ // pointed nib at the rail start (2026-11-11 user report).
63
+ const here = dirname(fileURLToPath(import.meta.url));
64
+ const scss = readFileSync(join(here, "HkMediaSlider.scss"), "utf-8");
65
+ const fill = scss.match(/\.hk-media-slider-fill\s*{[^}]*}/)?.[0] ?? "";
66
+ expect(fill).toContain("border-radius: 0 var(--radius-full, 9999px)");
67
+ expect(fill).toContain("inset: 0 auto 0 var(--hk-media-slider-rail-inset, 6px)");
68
+
69
+ const atEnd = mountSlider(1);
70
+ expect(
71
+ (atEnd.slider.querySelector(".hk-media-slider-thumb") as HTMLElement).style.left,
72
+ ).toBe("calc(100% - 6px)");
73
+ expect(
74
+ (atEnd.slider.querySelector(".hk-media-slider-fill") as HTMLElement).style.width,
75
+ ).toBe("calc(100% - 12px)");
76
+ expect(atEnd.slider.style.getPropertyValue("--hk-media-slider-rail-inset")).toBe("6px");
77
+
78
+ const atStart = mountSlider(0);
79
+ expect(
80
+ (atStart.slider.querySelector(".hk-media-slider-thumb") as HTMLElement).style.left,
81
+ ).toBe("calc(0% + 6px)");
82
+ expect(
83
+ (atStart.slider.querySelector(".hk-media-slider-fill") as HTMLElement).style.width,
84
+ ).toBe("calc(0% - 0px)");
85
+ });
86
+
87
+ it("anchors the buffered bar at the rail start ahead of the fill", () => {
88
+ const { slider } = mountSlider(0.25, 0.5);
89
+ expect(
90
+ (slider.querySelector(".hk-media-slider-buffered") as HTMLElement).style.width,
91
+ ).toBe("calc(50% - 6px)");
92
+ expect(
93
+ (slider.querySelector(".hk-media-slider-fill") as HTMLElement).style.width,
94
+ ).toBe("calc(25% - 3px)");
95
+ expect(
96
+ (slider.querySelector(".hk-media-slider-thumb") as HTMLElement).style.left,
97
+ ).toBe("calc(25% + 3px)");
98
+ });
99
+
100
+ it("omits the buffered bar when nothing is buffered", () => {
101
+ const { slider } = mountSlider(0.5);
102
+ expect(slider.querySelector(".hk-media-slider-buffered")).toBeNull();
103
+ expect(
104
+ (slider.querySelector(".hk-media-slider-fill") as HTMLElement).style.width,
105
+ ).toBe("calc(50% - 6px)");
106
+ });
107
+
108
+ it("maps presses into the inset rail and saturates outside", () => {
109
+ const { slider, seen } = mountSlider(0);
110
+ pinRect(slider);
111
+ // 200px rect, 6px insets → a 188px rail: the rail start/mid/end land on
112
+ // clientX 6/100/194; presses outside saturate.
113
+ slider.dispatchEvent(pointer("pointerdown", 6));
114
+ expect(seen).toEqual([0]);
115
+ slider.dispatchEvent(pointer("pointerdown", 100));
116
+ expect(seen).toEqual([0, 0.5]);
117
+ slider.dispatchEvent(pointer("pointerdown", 194));
118
+ expect(seen).toEqual([0, 0.5, 1]);
119
+ // Presses before the rail start clamp (the old full-width mapping would
120
+ // emit 3/200 instead of 0).
121
+ slider.dispatchEvent(pointer("pointerdown", 3));
122
+ expect(seen).toEqual([0, 0.5, 1, 0]);
123
+ });
124
+
125
+ it("degenerate rails re-assert the current value instead of dividing", () => {
126
+ const { slider, seen } = mountSlider(0.5);
127
+ // 10px rect is thinner than both insets (12px): the press re-emits the
128
+ // current ratio (the Rust mirror's None → no-emit parity), never a
129
+ // division blow-up.
130
+ pinRect(slider);
131
+ Object.defineProperty(slider, "getBoundingClientRect", {
132
+ configurable: true,
133
+ value: () =>
134
+ ({ left: 0, width: 10, height: 6, top: 0, right: 10, bottom: 6, x: 0, y: 0 }) as DOMRect,
135
+ });
136
+ slider.dispatchEvent(pointer("pointerdown", 5));
137
+ expect(seen).toEqual([0.5]);
138
+ });
139
+ });
@@ -7,6 +7,16 @@ import "./HkMediaSlider.scss";
7
7
  * volume slider are built on. Pointer-drag (with capture) emits the ratio
8
8
  * continuously so consumers can scrub live. An optional secondary `buffered`
9
9
  * fill renders behind the played fill.
10
+ *
11
+ * Rail geometry (2026-11-11, the same shape HkSlider ships): the drawable
12
+ * rail is inset by the thumb radius (6px — the thumb is 12px at every size)
13
+ * at each end via the inline `--hk-media-slider-rail-inset` var, so a thumb
14
+ * parked on 0/1 rests ON the rail instead of hanging off its cap, and the
15
+ * fill starts FLAT at the rail edge (a rounded cap on a thin saturated bar
16
+ * reads as a pointed nib). The emitted positions use the linear calc
17
+ * expansion `calc(F% ± Npx)` — identical geometry to
18
+ * `inset + (100% - 2·inset)·f`, and the form jsdom/cssstyle parses for the
19
+ * contract tests.
10
20
  */
11
21
  export default defineComponent({
12
22
  name: "HkMediaSlider",
@@ -24,11 +34,36 @@ export default defineComponent({
24
34
  const trackRef = ref<HTMLElement | null>(null);
25
35
  let dragging = false;
26
36
 
37
+ /** Thumb radius: the thumb is 12px at every size (scss). */
38
+ const railInset = 6;
39
+
40
+ function round4(n: number): number {
41
+ return Math.round(n * 1e4) / 1e4;
42
+ }
43
+
44
+ /** The fill/buffered width along the rail: `railLength·f` as
45
+ * `calc(F% - Npx)`. */
46
+ function railWidth(f: number): string {
47
+ return `calc(${round4(f * 100)}% - ${round4(railInset * 2 * f)}px)`;
48
+ }
49
+
50
+ /** A position ON the rail (thumb center): `inset + railLength·f`. */
51
+ function railPos(f: number): string {
52
+ const px = round4(railInset * (1 - 2 * f));
53
+ const op = px < 0 ? " - " : " + ";
54
+ return `calc(${round4(f * 100)}%${op}${Math.abs(px)}px)`;
55
+ }
56
+
27
57
  function ratioFrom(clientX: number): number {
28
58
  const el = trackRef.value;
29
59
  if (!el) return 0;
30
60
  const rect = el.getBoundingClientRect();
31
- return Math.max(0, Math.min(1, (clientX - rect.left) / rect.width));
61
+ const rail = rect.width - railInset * 2;
62
+ // Degenerate rail (hidden or thinner than both insets): re-assert the
63
+ // current value instead of inventing a position (the Rust mirror's
64
+ // None → no-emit parity).
65
+ if (rect.width <= 0 || rail <= 0) return props.ratio;
66
+ return Math.max(0, Math.min(1, (clientX - rect.left - railInset) / rail));
32
67
  }
33
68
  function onDown(e: PointerEvent) {
34
69
  if (props.disabled) return;
@@ -62,6 +97,7 @@ export default defineComponent({
62
97
  props.disabled && "is-disabled",
63
98
  ].filter(Boolean).join(" ")}
64
99
  data-size={props.size}
100
+ style={{ "--hk-media-slider-rail-inset": `${railInset}px` }}
65
101
  role="slider"
66
102
  tabindex={-1}
67
103
  aria-label={props.ariaLabel}
@@ -71,10 +107,13 @@ export default defineComponent({
71
107
  onPointerdown={onDown}
72
108
  >
73
109
  {props.buffered > 0 && (
74
- <div class="hk-media-slider-buffered" style={{ width: `${props.buffered * 100}%` }} />
110
+ <div
111
+ class="hk-media-slider-buffered"
112
+ style={{ width: railWidth(props.buffered) }}
113
+ />
75
114
  )}
76
- <div class="hk-media-slider-fill" style={{ width: `${props.ratio * 100}%` }} />
77
- <div class="hk-media-slider-thumb" style={{ left: `${props.ratio * 100}%` }} />
115
+ <div class="hk-media-slider-fill" style={{ width: railWidth(props.ratio) }} />
116
+ <div class="hk-media-slider-thumb" style={{ left: railPos(props.ratio) }} />
78
117
  </div>
79
118
  );
80
119
  },
@@ -1,7 +1,8 @@
1
1
  import HkIconButton from "./HkIconButton";
2
+ import HkAddTile from "./HkAddTile";
2
3
 
3
4
  import { computed, defineComponent, onUnmounted, ref, watch, type PropType } from "vue";
4
- import { Monitor, MoonStar, Palette, Sun, Trash as Trash2 } from "lucide-vue-next";
5
+ import { Monitor, MoonStar, Sun, Trash as Trash2 } from "lucide-vue-next";
5
6
  import {
6
7
  HDivider,
7
8
  solarAltitude,
@@ -309,9 +310,18 @@ export const HkThemePanelContent = defineComponent({
309
310
  );
310
311
  })}
311
312
 
312
- <button
313
- type="button"
314
- class="s-theme-item-btn s-theme-item-customize"
313
+ {/* The customize entry is the standard add tile (2026-11-11
314
+ family migration): the compact dashed form riding the END of
315
+ the theme list — the same "add one more" gesture semantics
316
+ as every other list-end affordance, so hosts stop
317
+ hand-painting it (chest's centered dashed hand-roll retires
318
+ with this). The s-theme-item-customize class stays as the
319
+ host hook (host scopes and tests target it); the default
320
+ Plus glyph replaces the palette mark — creating a scheme is
321
+ an add gesture. */}
322
+ <HkAddTile
323
+ compact
324
+ class="s-theme-item-customize"
315
325
  onClick={() => {
316
326
  if (props.externalCustomize) {
317
327
  emit("request-close");
@@ -321,9 +331,8 @@ export const HkThemePanelContent = defineComponent({
321
331
  }
322
332
  }}
323
333
  >
324
- <span class="hk-menu-item-icon"><Palette size={14} /></span>
325
- <span class="s-theme-item-name">{t("hikari::theme.customize")}</span>
326
- </button>
334
+ {t("hikari::theme.customize")}
335
+ </HkAddTile>
327
336
  </div>
328
337
  {(() => {
329
338
  const extra = slots["menu-extra"]?.() ?? [];
@@ -9,13 +9,15 @@
9
9
  *
10
10
  * The widened cell must stay scoped (2026-09-12 field report): shipped
11
11
  * first as a bare `.s-theme-item-btn .hk-menu-item-icon` rule, it also
12
- * matched the 自定义 row and every host row reusing s-theme-item-btn —
13
- * and mi.icon normalizes those cells' svg to the cell, so their 14px
14
- * glyphs rendered 28px wide. The widening therefore targets named scopes
15
- * (lead slot, customize row) plus the toggle-owned mode-extra strip, the
16
- * last one widening the CELL while pinning the glyph back to the
17
- * standard box so host strip rows (chest's DPI entry) align their labels
18
- * with the theme rows' names without rescaling their icons.
12
+ * matched every host row reusing s-theme-item-btn — and mi.icon
13
+ * normalizes those cells' svg to the cell, so their 14px glyphs rendered
14
+ * 28px wide. The widening therefore targets named scopes (lead slot)
15
+ * plus the toggle-owned mode-extra strip, the last one widening the CELL
16
+ * while pinning the glyph back to the standard box so host strip rows
17
+ * (chest's DPI entry) align their labels with the theme rows' names
18
+ * without rescaling their icons. (The customize row left this contract
19
+ * 2026-11-11: the entry is the standard HkAddTile compact form now — a
20
+ * self-contained dashed tile, not a lead-column row.)
19
21
  */
20
22
  import { describe, expect, it } from "vitest";
21
23
  import { readFileSync } from "node:fs";
@@ -105,30 +107,27 @@ describe("HkThemeToggle row lead-cell contract", () => {
105
107
 
106
108
  it("does not widen icon cells with a bare unscoped theme-row rule", () => {
107
109
  const css = read("HkThemeToggle.scss");
108
- // A bare `.s-theme-item-btn .hk-menu-item-icon {` rule also hits the
109
- // customize row and host mode-extra rows; the widened cell may only
110
- // target named scopes (lead slot, customize row, mode-extra strip).
110
+ // A bare `.s-theme-item-btn .hk-menu-item-icon {` rule also hits
111
+ // host mode-extra rows; the widened cell may only target named
112
+ // scopes (lead slot, mode-extra strip).
111
113
  expect(css).not.toMatch(/^\.s-theme-item-btn \.hk-menu-item-icon\s*\{/m);
112
114
  });
113
115
 
114
- it("aligns the customize row to the lead column without rescaling its glyph", () => {
116
+ it("renders the customize entry as the standard HkAddTile compact form", () => {
117
+ // 2026-11-11 family migration: the entry rides the standard dashed
118
+ // add tile below the theme list (same "add one more" semantics as
119
+ // every other list-end affordance) instead of a lead-aligned menu
120
+ // row — the old .hk-menu-item-icon lead-column alignment rules are
121
+ // retired with the markup that needed them.
122
+ const panel = read("HkThemePanelContent.tsx");
123
+ const entry = panel.match(/<HkAddTile[\s\S]*?s-theme-item-customize[\s\S]*?>[\s\S]*?<\/HkAddTile>/);
124
+ expect(entry).not.toBeNull();
125
+ expect(entry![0]).toContain("compact");
126
+ expect(entry![0]).not.toContain("hk-menu-item-icon");
127
+ // The toggle's own sheet carries no customize-specific icon cell
128
+ // rules anymore (the alignment contract retired with the row).
115
129
  const css = read("HkThemeToggle.scss");
116
- // The customize affordance joins the 28px lead column (2026-09-11
117
- // field report: its palette sat a full cell left of the rows' bitmap
118
- // marks), but the glyph must keep the standard menu icon size —
119
- // mi.icon normalizes svg to the cell, so the box is pinned back.
120
- const block = css.match(
121
- /\.s-theme-item-customize \.hk-menu-item-icon\s*\{[^}]*\}/,
122
- );
123
- expect(block).not.toBeNull();
124
- expect(block![0]).toContain("width: 28px");
125
- expect(block![0]).toContain("height: 28px");
126
-
127
- const svgBlock = css.match(
128
- /\.s-theme-item-customize \.hk-menu-item-icon > svg\s*\{[^}]*\}/,
129
- );
130
- expect(svgBlock).not.toBeNull();
131
- expect(svgBlock![0]).toContain("var(--hk-menu-item-icon-box)");
130
+ expect(css).not.toMatch(/\.s-theme-item-customize \.hk-menu-item-icon/);
132
131
  });
133
132
 
134
133
  it("aligns mode-extra host rows to the lead column without rescaling their glyph", () => {
@@ -288,24 +288,13 @@
288
288
  height: 28px;
289
289
  }
290
290
 
291
- /* The customize affordance joins the theme rows' 28px lead column so the
292
- * palette glyph and the row marks sit on one line and every name starts
293
- * at the same x (2026-09-11 field report: with the lead cell at 28px and
294
- * this row at the generic box, the selected theme's bitmap mark read a
295
- * full cell to the right of the customize palette). The cell widens but
296
- * the GLYPH keeps the standard menu icon size — mi.icon normalizes svg
297
- * to the cell, so the box is pinned back explicitly; widening a cell
298
- * must never re-scale its glyph (the 0.42.2 regression class). */
299
- .s-theme-item-customize .hk-menu-item-icon {
300
- @include mi.icon;
301
-
302
- width: 28px;
303
- height: 28px;
304
- }
291
+ /* (The customize row's lead-column alignment rules retired 2026-11-11:
292
+ * the entry itself is the standard HkAddTile compact form now — a
293
+ * self-contained dashed tile below the list, not a row in the lead
294
+ * column — so it carries no .hk-menu-item-icon cell to widen.) */
305
295
 
306
- .s-theme-item-customize .hk-menu-item-icon > svg {
307
- width: var(--hk-menu-item-icon-box);
308
- height: var(--hk-menu-item-icon-box);
296
+ .s-theme-item-customize {
297
+ margin-top: var(--space-8, 0.5rem);
309
298
  }
310
299
 
311
300
  /* Host rows in the mode-extra strip (chest's DPI entry row reuses
@@ -314,9 +303,9 @@
314
303
  * (2026-09-12 field report: with the strip row at the generic 16px cell
315
304
  * its label sat a full cell-width left of the theme rows' names). The
316
305
  * strip container is the toggle's own, so the scope needs no host
317
- * class-name contract. As with the customize row, the cell widens but
318
- * the GLYPH keeps the standard menu icon size — widening a cell must
319
- * never re-scale its glyph (the 0.42.2 regression class). */
306
+ * class-name contract. The cell widens but the GLYPH keeps the standard
307
+ * menu icon size — widening a cell must never re-scale its glyph (the
308
+ * 0.42.2 regression class). */
320
309
  .s-theme-mode-extra .s-theme-item-btn .hk-menu-item-icon {
321
310
  @include mi.icon;
322
311
 
@@ -75,8 +75,11 @@ function triggerButton(container: HTMLElement): HTMLButtonElement {
75
75
  }
76
76
 
77
77
  function paletteButton(): HTMLButtonElement {
78
- const btn = [...document.body.querySelectorAll<HTMLButtonElement>(".s-theme-menu .s-theme-item-btn")].find(
79
- (b) => b.textContent?.includes("Customize"),
78
+ // The entry rides the standard HkAddTile (2026-11-11 family migration)
79
+ // and no longer carries s-theme-item-btn — the stable host hook class
80
+ // is the query surface.
81
+ const btn = document.body.querySelector<HTMLButtonElement>(
82
+ ".s-theme-menu .s-theme-item-customize",
80
83
  );
81
84
  return btn!;
82
85
  }