@celestia-island/hikari 0.55.520 → 0.55.521

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.
@@ -44,14 +44,39 @@
44
44
  * still snaps — taller the moment the exchange starts, shorter the
45
45
  * frame it ends (measured on the docs shell's preview/source card,
46
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)
47
+ * wrapper tweens from the height it had BEFORE the incoming copy
48
+ * inserted (read in the leaving copy's before-hook — by the enter
49
+ * hook the row has already grown to the taller generation) to the
50
+ * incoming generation's OWN height (read with the item un-stretched:
51
+ * a grid item renders at the row's height, i.e. the outgoing copy's),
52
+ * over the same duration/easing as the travel, and releases back to
53
+ * auto once BOTH the enter has settled AND no leaving copy remains in
54
+ * the cell — either alone would jump. Reduced motion (duration 0)
50
55
  * keeps the snap — the instant change IS that preference. A faster
51
56
  * 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.
57
+ * enter, the tween STAYS ARMED at its animated mid-state, the next
58
+ * before-leave reads that as its start, and the next enter re-freezes
59
+ * from it without a jump. The Transition's own teardown (the host
60
+ * flipping to `disabled`, a watchdog sweep, unmount) is what releases
61
+ * a stranded tween.
62
+ * - The first cut of this tween (2026-11-29) never ran in a browser:
63
+ * it read BOTH ends after the insertion, so `from` and `target` were
64
+ * the same stretched row height and the whole change happened at the
65
+ * release (measured live 2026-11-30: writes 200px → 200px, the host
66
+ * flat for the exchange, a 200 → 189 snap the frame it ended). The
67
+ * tests were green because happy-dom has no layout and the stubbed
68
+ * heights ignored the stretch; they now model the grid (see the
69
+ * `stubGrid` pins).
70
+ * - Two contracts the tween assumes of its host. (a) Hosts do not pin
71
+ * `height`/`min-height` on `.hk-dswap-item`: an explicit box defeats
72
+ * the un-stretched read — the read returns the pin, and a pin at the
73
+ * row is the no-op again (see `readUnstretchedHeight`); hosts size
74
+ * the pane, the item's child. (b) The host is BORDER-BOX with no
75
+ * padding or border of its own: `offsetHeight` is a border-box figure
76
+ * and is written into `height`, which under `box-sizing: content-box`
77
+ * is the content box — a padded or bordered `.hk-dswap` would offset
78
+ * the tween by its box extra (the docs shell's host is border-box with
79
+ * neither, so the target path is exact).
55
80
  */
56
81
 
57
82
  import { defineComponent, onBeforeUnmount, ref, Transition, watch, type PropType, type VNode } from "vue";
@@ -97,6 +122,37 @@ export function resolveSwapDirection(
97
122
  return b < a ? "back" : "forward";
98
123
  }
99
124
 
125
+ /**
126
+ * Read a grid item's OWN content height. Under the cell's geometry a
127
+ * grid item stretches to the row (the taller generation), so its
128
+ * rendered height is the outgoing copy's; `align-self: start` sizes it
129
+ * to its content for the read. The item's inline `align-self` is put
130
+ * back exactly as it was — value AND priority — so a style the item
131
+ * arrived with survives. Exported for its own pin: the swap creates the
132
+ * item in the same tick its enter hook reads it, so no test can hand it
133
+ * a prior inline style through the component.
134
+ *
135
+ * CONTRACT: the item's box belongs to the component — hosts must not pin
136
+ * `height` or `min-height` on `.hk-dswap-item`. Un-stretching defeats the
137
+ * ROW, not an explicit box: a pinned item reads its PIN — the explicit
138
+ * box wins over both the row stretch and the content height — and a pin
139
+ * at the row turns the tween back into the no-op this component just
140
+ * fixed (measured, Chrome 155, R5: with the item pinned to the row's
141
+ * 240px, stretched and un-stretched both read 240 while the content is
142
+ * 100). Hosts size the PANE (the item's child); that is where the docs
143
+ * shell's band-fill lives, and this read runs before its attribute
144
+ * exists.
145
+ */
146
+ export function readUnstretchedHeight(item: HTMLElement): number {
147
+ const prior = item.style.getPropertyValue("align-self");
148
+ const priority = item.style.getPropertyPriority("align-self");
149
+ item.style.alignSelf = "start";
150
+ const height = item.offsetHeight;
151
+ if (prior) item.style.setProperty("align-self", prior, priority);
152
+ else item.style.removeProperty("align-self");
153
+ return height;
154
+ }
155
+
100
156
  export default defineComponent({
101
157
  name: "HkDirectionalSwap",
102
158
  props: {
@@ -182,44 +238,139 @@ export default defineComponent({
182
238
  // `hostProps.style` object above — Vue patches style keys it rendered
183
239
  // and would silently reset our inline tween height on the next render;
184
240
  // these writes live outside the vnode on purpose.
185
- /** Freeze the wrapper at its rendered height, arm the height
186
- * transition, and step to the incoming generation's height — the
241
+ /** The exchange's START height: the host as it stood before the
242
+ * incoming copy inserted, read in the leaving copy's before-hook —
243
+ * the last moment the cell holds the outgoing generation alone. By
244
+ * the enter hook it is too late: the insertion has already grown
245
+ * the row to the taller generation (measured live: the host reads
246
+ * 189 at rest and 200 the instant the taller copy lands). With a
247
+ * leaving copy still in the cell the host's `offsetHeight` is the
248
+ * ROW (the taller copy), not the rendered height — so this read is
249
+ * only true while the tween is still ARMED (an interrupted exchange
250
+ * reads its animated mid-state here) or while the cell holds one
251
+ * generation (a swap from rest). Null until a leave arms it; a
252
+ * leave-less enter (none today — the component renders no `appear`)
253
+ * falls back to the host's own height. Consumed by the next begin,
254
+ * whatever it then decides; cleared again by the Transition's
255
+ * teardown and the watchdog sweep. */
256
+ let restHeight: number | null = null;
257
+ /** The running exchange's settled state. The explicit height
258
+ * releases only when the enter has settled (the tween is at its
259
+ * target) AND no leaving copy remains (the cell's `auto` resolves
260
+ * to that target); see `settleHeightAnimation`. */
261
+ let enterSettled = false;
262
+ let leaving = 0;
263
+ /** The element the armed tween lives on and the inline height it
264
+ * wrote there (see `endHeightAnimation`). */
265
+ let armedHost: HTMLElement | null = null;
266
+ let armedHeight = "";
267
+
268
+ /** Arm the tween: freeze the wrapper at the pre-insertion height,
269
+ * flush, then step to the incoming generation's own height — the
187
270
  * forced layout between the two writes is what makes them a
188
271
  * before/after pair. No-ops when the prop is off, the effective
189
272
  * duration is zero (reduced motion keeps the snap by design), or
190
273
  * either height is unreadable (a hidden or not-yet-laid-out surface
191
274
  * reports 0 — animating to/from 0 would collapse the card; the snap
192
- * is the safe face there, same as reduced motion). A faster
193
- * follow-up swap arrives after Vue cancelled the interrupted enter
194
- * (the release runs), so its freeze reads the cell's CURRENT layout
195
- * height — the interrupted tween's mid-state — never the old start. */
275
+ * is the safe face there, same as reduced motion). */
196
276
  function beginHeightAnimation(incoming: Element): void {
277
+ // Consumed first, unconditionally: a value read for THIS exchange
278
+ // must never survive into the next one, whatever returns below.
279
+ const start = restHeight;
280
+ restHeight = null;
197
281
  if (!props.animateHeight) return;
198
282
  if (motionDuration() === 0) return;
199
283
  const host = hostRef.value;
200
284
  if (!host) return;
201
- const from = host.offsetHeight;
202
- const target = (incoming as HTMLElement).offsetHeight;
285
+ const item = incoming as HTMLElement;
286
+ // The cell's grid items STRETCH to the row, and the row is the
287
+ // taller generation — so the incoming item's rendered height is
288
+ // the OUTGOING copy's (measured live on the docs shell's card:
289
+ // both copies read 200 while the incoming pane is 189; the tween
290
+ // wrote 200px → 200px and never ran). Read it un-stretched; item
291
+ // alignment does not move the row (content-sized), so the host
292
+ // read below is unaffected.
293
+ const target = readUnstretchedHeight(item);
294
+ const from = start ?? host.offsetHeight;
203
295
  if (from === 0 || target === 0) return;
204
296
  host.style.height = `${from}px`;
205
297
  // Flush so the frozen height is the transition's computed start
206
298
  // (a same-frame change from auto would jump instead of tween).
207
299
  void host.offsetHeight;
300
+ armedHost = host;
301
+ armedHeight = `${target}px`;
208
302
  host.setAttribute("data-height-anim", "");
209
- host.style.height = `${target}px`;
303
+ host.style.height = armedHeight;
210
304
  }
211
305
 
212
306
  /** Release the explicit height back to auto and disarm the
213
307
  * transition. Guarded on the armed attribute so it only ever
214
308
  * unwinds THIS component's own writes: an unarmed call (default-off
215
309
  * host, or a second after-hook) must leave a host's own inline
216
- * height alone. */
310
+ * height alone — and so must a release that finds the host's
311
+ * inline height no longer the value this component wrote (a host
312
+ * that sized itself mid-exchange keeps its own number; only the
313
+ * arm is undone). Falls back to the element the tween was armed
314
+ * on: the component's own unmount nulls `hostRef` on the host vnode
315
+ * BEFORE the Transition child's teardown hook runs (Vue's `unmount`
316
+ * sets the ref, then unmounts the children), so a release keyed on
317
+ * the ref alone is a no-op exactly on that path (R6 measured the
318
+ * detached host keeping `data-height-anim` and its inline height).
319
+ * A node a host re-inserts (keep-alive, a manual move) must not
320
+ * come back frozen. */
217
321
  function endHeightAnimation(): void {
218
- const host = hostRef.value;
322
+ const host = hostRef.value ?? armedHost;
219
323
  if (!host) return;
220
324
  if (!host.hasAttribute("data-height-anim")) return;
221
325
  host.removeAttribute("data-height-anim");
222
- host.style.height = "";
326
+ // Compared by value: this component writes integer px (offsetHeight
327
+ // is an integer), and a numeric compare is immune to how a browser
328
+ // re-serialises either side on read-back.
329
+ if (parseFloat(host.style.height) === parseFloat(armedHeight)) host.style.height = "";
330
+ armedHost = null;
331
+ armedHeight = "";
332
+ }
333
+
334
+ /** Release once the exchange has fully settled — the incoming
335
+ * copy's own transition at its end, and every leaving copy out of
336
+ * the cell. Releasing on either settle alone jumps: before the
337
+ * enter ends, from the mid-tween height to `auto`; with a leaving
338
+ * copy still present, to the taller row it still holds. Whichever
339
+ * hook fires LAST does the release. The order is the engine's, not
340
+ * this component's to pick — it is deterministic per engine (Vue's
341
+ * leave `done` removes the copy BEFORE `onAfterLeave`, and a
342
+ * same-length leave resolves first in this Chromium), but nothing
343
+ * here may lean on it. One path leans on the ENTER's release: a
344
+ * keep-alive deactivation skips the teardown, and the leaving copy's
345
+ * after-leave arrives with its element already detached — in the
346
+ * measured path it was the entering copy's timer that carried the
347
+ * release of a deactivated host (R7); a refactor that drops the
348
+ * enter side of this guard could freeze one. */
349
+ function settleHeightAnimation(): void {
350
+ if (!enterSettled || leaving > 0) return;
351
+ endHeightAnimation();
352
+ }
353
+
354
+ /** The Transition itself is going away — the host flipped to the
355
+ * `disabled`/suppressed branch, or the whole component unmounts.
356
+ * No hook of the exchange will ever run again, so an armed tween
357
+ * releases HERE. (R2 of the first cut: keeping the tween armed
358
+ * through a cancelled enter is what lets a follow-up freeze read
359
+ * the mid-state, and THIS is the other half of that bargain —
360
+ * without it a mid-exchange flip to `disabled` would freeze the
361
+ * height for good.) The settle-state and `restHeight` resets are
362
+ * defensive: Vue's own leave flow still fires an interrupted copy's
363
+ * after-leave once its frame callback resolves, so the counter
364
+ * balances with or without them (measured: deleting them leaves
365
+ * every pin green). They keep the state right if a copy is ever
366
+ * swept without that callback, and nothing pins them on their own. */
367
+ function teardownHeightAnimation(): void {
368
+ endHeightAnimation();
369
+ armedHost = null;
370
+ armedHeight = "";
371
+ leaving = 0;
372
+ enterSettled = false;
373
+ restHeight = null;
223
374
  }
224
375
 
225
376
  function armWatchdog(): void {
@@ -252,7 +403,12 @@ export default defineComponent({
252
403
  suppress.value = true;
253
404
  // A wedged engine also wedges the height tween: release the
254
405
  // explicit height or the surface stays frozen at a stale size.
255
- endHeightAnimation();
406
+ // The settle state resets with it — the swept copies never get
407
+ // their after-leave. Belt to a brace: `suppress` re-renders
408
+ // without the Transition, whose teardown (below) does the same
409
+ // on its own; this call is what keeps the state right if that
410
+ // flow ever changes, and no test pins it on its own.
411
+ teardownHeightAnimation();
256
412
  }
257
413
  }
258
414
 
@@ -327,36 +483,73 @@ export default defineComponent({
327
483
  host's data attributes; the stylesheet owns the geometry. */}
328
484
  <Transition
329
485
  name="hk-dswap"
486
+ // Vue invokes this from `unmount` for ANY vnode, component
487
+ // included, BEFORE the subtree comes apart — the one signal
488
+ // that no exchange hook will run again (see
489
+ // `teardownHeightAnimation`). A cancelled enter is NOT that
490
+ // signal: the next enter follows in the same tick. (A vnode
491
+ // hook, typed on `VNodeProps` — not on the JSX props of a
492
+ // component — hence the spread.)
493
+ {...({ onVnodeBeforeUnmount: teardownHeightAnimation } as Record<string, unknown>)}
330
494
  onBeforeEnter={() => {
331
495
  armReport();
332
496
  armWatchdog();
333
497
  }}
334
498
  onEnter={(el: Element) => {
335
- // Runs right after the incoming item inserts — the one moment
336
- // both heights are readable: the wrapper still renders the
337
- // leaving generation, the item carries the incoming one.
499
+ // Runs right after the incoming item inserts; the start
500
+ // height was captured in the before-leave hook below.
501
+ enterSettled = false;
338
502
  beginHeightAnimation(el);
339
503
  }}
340
504
  onAfterEnter={() => {
341
- endHeightAnimation();
505
+ enterSettled = true;
506
+ settleHeightAnimation();
342
507
  settleReport();
343
508
  }}
344
509
  onEnterCancelled={() => {
345
- endHeightAnimation();
510
+ // An interrupted exchange. Deliberately NOT released: the
511
+ // tween stays armed at its animated mid-state so the
512
+ // before-leave hook that follows in this same tick reads
513
+ // THAT as the next start, and the next enter re-freezes
514
+ // from it without a jump. Releasing here would drop the
515
+ // host to `auto` — the row, i.e. the taller copy still in
516
+ // the cell — and the follow-up would freeze at the row
517
+ // (R2 of the first cut measured exactly that). The
518
+ // Transition's own teardown is what releases a stranded
519
+ // tween.
346
520
  settleReport();
347
521
  }}
348
522
  onBeforeLeave={(el: Element) => {
349
523
  setLeavingInert(el, true);
350
524
  armReport();
351
525
  armWatchdog();
526
+ leaving += 1;
527
+ // The last read before the row changes (see `restHeight`):
528
+ // the rendered height — at rest, or the animated mid-state
529
+ // of an interrupted tween that is still armed.
530
+ if (props.animateHeight && hostRef.value) restHeight = hostRef.value.offsetHeight;
352
531
  }}
353
532
  onAfterLeave={() => {
354
- endHeightAnimation();
533
+ // Vue removes the leaving copy BEFORE this hook runs, so
534
+ // the cell now holds the incoming generation alone.
535
+ leaving = Math.max(0, leaving - 1);
536
+ settleHeightAnimation();
355
537
  settleReport();
356
538
  }}
357
539
  onLeaveCancelled={(el: Element) => {
358
540
  setLeavingInert(el, false);
359
- endHeightAnimation();
541
+ leaving = Math.max(0, leaving - 1);
542
+ // Not reachable with this component's keyed single child
543
+ // today: Vue only cancels a leave when the SAME element is
544
+ // re-entered (`beforeEnter`'s `el[leaveCbKey](true)`), and
545
+ // a keyed swap always mounts a fresh element — a copy whose
546
+ // key comes back has its leave FINISHED instead (measured:
547
+ // A→B→A→B fires `enter-cancelled` twice, `leave-cancelled`
548
+ // zero times). Kept consistent with the cancelled-enter rule
549
+ // above: no release here, so a following enter would re-freeze
550
+ // from the armed host's current rendered height. What that
551
+ // would look like in a browser is unmeasured — the path has
552
+ // never fired.
360
553
  settleReport();
361
554
  }}
362
555
  >
@@ -3,7 +3,11 @@
3
3
  /* ── Scroll-progress dock (HkScrollProgressDock) ──────────────────
4
4
  The localized range sentence floating near the bottom-center of a
5
5
  scrolling list ("Rows 11 → 20 of 340" with the arrow glyph between
6
- the two halves): the visible row band over the total. The pill
6
+ the two halves): the visible row band over the total. Since the jump
7
+ surface (2026-11-30) the pill is a real trigger: hover/click opens a
8
+ HkPopover (mobile: bottom sheet) with the band, a scrub slider and a
9
+ row field — see the jump panel rules at the bottom of this file. The
10
+ pill
7
11
  TELEPORTS to the container HOST (position: relative), never the
8
12
  viewport — viewport-absolute chrome scrolls away with the content,
9
13
  the same reason the autotag band and the selection-hint gradients
@@ -33,7 +37,13 @@
33
37
  bottom: max(var(--space-10), env(safe-area-inset-bottom, 0px));
34
38
  transform: translateX(-50%);
35
39
  z-index: 6;
36
- pointer-events: none;
40
+ /* The pill is the jump surface's TRIGGER now (user direction
41
+ * 2026-11-30): it captures its own pointer events so clicks no longer
42
+ * fall through to the row underneath (the decorative pass-through
43
+ * that fired app copy-toasts from a pill click) — and so hover can
44
+ * surface it and the jump panel at all. */
45
+ pointer-events: auto;
46
+ cursor: pointer;
37
47
  @include user-select(none);
38
48
  display: inline-flex;
39
49
  align-items: center;
@@ -62,6 +72,20 @@
62
72
  opacity: 0.85;
63
73
  }
64
74
 
75
+ /* Idle stays transparent to the EYE but not to the pointer: hover,
76
+ * keyboard focus and an open jump panel all reveal the pill — the
77
+ * trigger must be findable without a prior scroll. */
78
+ &:hover,
79
+ &:focus-visible,
80
+ &.is-open {
81
+ opacity: 1;
82
+ }
83
+
84
+ &:focus-visible {
85
+ outline: 2px solid var(--hi-border-color-focus, rgb(var(--color-primary, 122 162 247)));
86
+ outline-offset: 2px;
87
+ }
88
+
65
89
  /* A failed precondition (no registered list, no vertical overflow,
66
90
  * a list whose rows are empty) removes the box outright — the pill
67
91
  * must never linger as dead chrome. */
@@ -70,6 +94,51 @@
70
94
  }
71
95
  }
72
96
 
97
+ /* ── Jump panel (the HkPopover slot; desktop anchored above the pill,
98
+ mobile the sheet body) ──────────────────────────────────────────
99
+ Width is a readable scrub-strip width, not full-bleed; the sheet form
100
+ (`.hk-is-sheet` ancestor) spans the viewport instead. */
101
+ .hk-scroll-progress-dock-jump {
102
+ width: 264px;
103
+ max-width: calc(100vw - 2 * var(--viewport-gutter, 16px));
104
+ display: grid;
105
+ gap: var(--space-12, 12px);
106
+ padding: var(--space-8, 8px);
107
+
108
+ /* The sheet form spans the viewport: the pill-side strip width AND
109
+ * its viewport clamp must both go, or the sheet body shrinks back to
110
+ * a centred ≤(100vw−2·gutter) block with dead bands on both sides
111
+ * (the HkNotificationBell sheet precedent, #1333 round 2). */
112
+ .hk-is-sheet & {
113
+ width: 100%;
114
+ max-width: none;
115
+ }
116
+ }
117
+
118
+ .hk-scroll-progress-dock-jump-position {
119
+ display: inline-flex;
120
+ align-items: center;
121
+ gap: var(--space-4, 4px);
122
+ font-family: var(--font-mono);
123
+ font-size: var(--text-sm, 0.8125rem);
124
+ font-variant-numeric: tabular-nums;
125
+ color: var(--hi-color-text-primary, currentColor);
126
+ white-space: nowrap;
127
+ }
128
+
129
+ .hk-scroll-progress-dock-jump-row {
130
+ display: flex;
131
+ align-items: flex-end;
132
+ gap: var(--space-8, 8px);
133
+
134
+ /* The field grows, the 跳转 button holds its ink; flex-end lines the
135
+ * button up with the FIELD row (the label stacks above it). */
136
+ > .hk-number-input {
137
+ flex: 1;
138
+ min-width: 0;
139
+ }
140
+ }
141
+
73
142
  /* Letter-spacing is INK tracking: it belongs on the text halves only,
74
143
  * never on the arrow glyph between them. */
75
144
  .hk-scroll-progress-dock-text {