@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.
- package/dist/types/components/HkDirectionalSwap.d.ts +53 -6
- package/dist/types/components/HkInput.d.ts +1 -1
- package/dist/types/components/HkMenu.d.ts +1 -1
- package/dist/types/components/HkRowActions.d.ts +1 -1
- package/dist/types/components/HkTable.d.ts +1 -1
- package/dist/types/components/HkTimePicker.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/HkDirectionalSwap.test.tsx +614 -23
- package/src/components/HkDirectionalSwap.tsx +219 -26
- package/src/components/HkScrollProgressDock.scss +71 -2
- package/src/components/HkScrollProgressDock.test.tsx +508 -1
- package/src/components/HkScrollProgressDock.tsx +424 -40
- package/src/errorLandingStandalone/error-landing.html +1 -1
- package/src/i18n/locales/ar/components.json +5 -1
- package/src/i18n/locales/de/components.json +5 -1
- package/src/i18n/locales/en/components.json +5 -1
- package/src/i18n/locales/es/components.json +5 -1
- package/src/i18n/locales/fr/components.json +5 -1
- package/src/i18n/locales/ja/components.json +5 -1
- package/src/i18n/locales/ko/components.json +5 -1
- package/src/i18n/locales/pt/components.json +5 -1
- package/src/i18n/locales/ru/components.json +5 -1
- package/src/i18n/locales/zh-Hans/components.json +5 -1
- package/src/i18n/locales/zh-Hant/components.json +5 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// 2026-11-09: "做成默认开启但可以禁用注入的 dock 组件,它本身应该首先
|
|
4
4
|
// 独立,然后被列表大组件使用").
|
|
5
5
|
//
|
|
6
|
-
// This module owns
|
|
6
|
+
// This module owns five things:
|
|
7
7
|
// 1. the provide/inject vocabulary — the registration key
|
|
8
8
|
// (`HK_SCROLL_PROGRESS_REGISTRAR`) a list uses to find the registrar
|
|
9
9
|
// of the NEAREST enclosing enabled dock (provide/inject scoping is
|
|
@@ -27,7 +27,23 @@
|
|
|
27
27
|
// 4. the pill itself: head + arrow + tail (the lucide `ArrowRight`
|
|
28
28
|
// glyph replaces the old tilde/hyphen between the two halves — the
|
|
29
29
|
// breadcrumb separator precedent — with an RTL scaleX flip) and the
|
|
30
|
-
// single-row sentence rendered whole with NO icon
|
|
30
|
+
// single-row sentence rendered whole with NO icon;
|
|
31
|
+
// 5. the JUMP SURFACE (user direction 2026-11-30): the pill is now a
|
|
32
|
+
// real control, not pure chrome. Hover (hover-capable pointers) or
|
|
33
|
+
// click/tap opens — IMMEDIATELY, no delay — a HkPopover anchored
|
|
34
|
+
// above the pill that shows the current band, a scrub slider (each
|
|
35
|
+
// tick jumps live) and a row field + 跳转 button; on mobile viewports
|
|
36
|
+
// the same surface rises from the bottom edge as a sheet
|
|
37
|
+
// (`sheetOnMobile`). Hover-opened panels stay while the pointer is
|
|
38
|
+
// over pill or panel; click/tap PINS the panel so it survives the
|
|
39
|
+
// pointer leaving; Esc, outside click, a second pill click or a
|
|
40
|
+
// committed jump dismiss it. Jumping puts row N at the TOP of the
|
|
41
|
+
// viewport band, clamped to the LOADED rows (a declared total larger
|
|
42
|
+
// than the delivered rows cannot be scrolled to until its rows
|
|
43
|
+
// exist). The pill capturing its own pointer events also ENDS the
|
|
44
|
+
// old pass-through: clicks on the pill used to land on whatever row
|
|
45
|
+
// sat underneath it (app copy-toasts fired from a click on the
|
|
46
|
+
// pill), because the decorative pill was `pointer-events: none`.
|
|
31
47
|
//
|
|
32
48
|
// Laziness contract: when the dock cannot or may not run (the `disabled`
|
|
33
49
|
// prop, a shell that closed `HK_SCROLL_PROGRESS_ALLOWED`, a nested dock
|
|
@@ -52,7 +68,13 @@ import {
|
|
|
52
68
|
} from "vue";
|
|
53
69
|
|
|
54
70
|
import { scheduleFrame, type AnimationHandle } from "../runtime/animationBus";
|
|
71
|
+
import { releaseMediaQuery, useMediaQuery } from "../runtime/useMediaQuery";
|
|
72
|
+
import { laidOffsetWithin } from "../composables/layoutGeometry";
|
|
55
73
|
import { useI18n } from "../i18n/context";
|
|
74
|
+
import HkPopover from "./HkPopover";
|
|
75
|
+
import HkButton from "./HkButton";
|
|
76
|
+
import HkNumberInput from "./HkNumberInput";
|
|
77
|
+
import HkSlider from "./HkSlider";
|
|
56
78
|
import "./HkScrollProgressDock.scss";
|
|
57
79
|
|
|
58
80
|
/** What a list hands to the registrar so the pill can describe it:
|
|
@@ -116,16 +138,145 @@ export const HK_SCROLL_PROGRESS_ALLOWED: InjectionKey<boolean> =
|
|
|
116
138
|
export const HK_SCROLL_PROGRESS_DOCK_ACTIVE: InjectionKey<boolean> =
|
|
117
139
|
Symbol("hk-scroll-progress-dock-active");
|
|
118
140
|
|
|
119
|
-
/**
|
|
120
|
-
*
|
|
141
|
+
/** Interpolate one locale's range sentence. Each half carries whatever
|
|
142
|
+
* placeholders its locale uses (ja's head carries {total}; ko's tail is
|
|
143
|
+
* bare) — the missing ones are no-ops. Shared by the pill and the jump
|
|
144
|
+
* panel so the two can never disagree about the wording. */
|
|
145
|
+
function fillRange(s: string, from: number, to: number, total: number): string {
|
|
146
|
+
return s
|
|
147
|
+
.replace("{from}", String(from))
|
|
148
|
+
.replace("{to}", String(to))
|
|
149
|
+
.replace("{total}", String(total));
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** How long (ms) the pointer may be over NEITHER surface before a
|
|
153
|
+
* hover-opened panel closes. Short on purpose: the panel is not a
|
|
154
|
+
* modal, and the pill↔panel gap is 4px — anything stuck longer reads
|
|
155
|
+
* as a stuck tooltip. A pinned (clicked) panel ignores it. */
|
|
156
|
+
const HOVER_GRACE_MS = 120;
|
|
157
|
+
|
|
158
|
+
/** The jump panel body (the HkPopover slot): the current band sentence,
|
|
159
|
+
* a scrub slider (each tick jumps live) and a row field + 跳转 button.
|
|
160
|
+
* The component is FRESH per open — the popover unmounts closed
|
|
161
|
+
* content, so a reopen re-syncs the field to the live band and clears
|
|
162
|
+
* the typed state. */
|
|
163
|
+
const HkScrollProgressDockJumpPanel = defineComponent({
|
|
164
|
+
name: "HkScrollProgressDockJumpPanel",
|
|
165
|
+
props: {
|
|
166
|
+
/** First visible row (1-based) — mirrors into the slider and the
|
|
167
|
+
* field until the user types. */
|
|
168
|
+
from: { type: Number, default: 0 },
|
|
169
|
+
/** Last visible row (1-based, inclusive). */
|
|
170
|
+
to: { type: Number, default: 0 },
|
|
171
|
+
/** Authoritative total — the slider's and field's ceiling. */
|
|
172
|
+
total: { type: Number, default: 0 },
|
|
173
|
+
},
|
|
174
|
+
emits: {
|
|
175
|
+
/** Slider scrub: jump live, KEEP the surface open (the drag is the
|
|
176
|
+
* fast travel; dismissing it under the pointer would fight the
|
|
177
|
+
* gesture). */
|
|
178
|
+
scrub: (_row: number) => true,
|
|
179
|
+
/** 跳转 confirm: jump, then the host CLOSES the surface so the
|
|
180
|
+
* destination is visible (the mobile sheet covers the very list it
|
|
181
|
+
* jumped; the anchored panel hides the same rows it names). */
|
|
182
|
+
commit: (_row: number) => true,
|
|
183
|
+
},
|
|
184
|
+
setup(props, { emit }) {
|
|
185
|
+
const { t } = useI18n();
|
|
186
|
+
// The field mirrors the live first-visible row until the user types
|
|
187
|
+
// (dirty). One-way on purpose — once typed, the field is the user's
|
|
188
|
+
// for the rest of this open (a fresh open re-syncs it); the SLIDER
|
|
189
|
+
// keeps mirroring the live band either way, so scrub and field can
|
|
190
|
+
// deliberately disagree after a manual edit.
|
|
191
|
+
const dirty = ref(false);
|
|
192
|
+
const jumpValue = ref(props.from);
|
|
193
|
+
watch(() => props.from, (v) => {
|
|
194
|
+
if (!dirty.value) jumpValue.value = v;
|
|
195
|
+
});
|
|
196
|
+
const ceiling = Math.max(props.total, 1);
|
|
197
|
+
const clampTarget = (v: number): number => {
|
|
198
|
+
if (!Number.isFinite(v)) return 1;
|
|
199
|
+
return Math.min(ceiling, Math.max(1, Math.round(v)));
|
|
200
|
+
};
|
|
201
|
+
function commit() {
|
|
202
|
+
emit("commit", clampTarget(jumpValue.value));
|
|
203
|
+
}
|
|
204
|
+
return () => {
|
|
205
|
+
const degenerate = props.total < 1 || props.from < 1 || props.to < props.from;
|
|
206
|
+
const single = !degenerate && props.from === props.to;
|
|
207
|
+
const fill = (s: string) => fillRange(s, props.from, props.to, props.total);
|
|
208
|
+
return (
|
|
209
|
+
<div
|
|
210
|
+
class="hk-scroll-progress-dock-jump"
|
|
211
|
+
onKeydown={(e: KeyboardEvent) => {
|
|
212
|
+
// Enter inside the panel (the field included — it has no
|
|
213
|
+
// Enter semantics of its own) commits; Esc is the popover's
|
|
214
|
+
// own channel and stays untouched.
|
|
215
|
+
if (e.key === "Enter") {
|
|
216
|
+
e.preventDefault();
|
|
217
|
+
commit();
|
|
218
|
+
}
|
|
219
|
+
}}
|
|
220
|
+
>
|
|
221
|
+
<div class="hk-scroll-progress-dock-jump-position" aria-live="polite">
|
|
222
|
+
{single ? (
|
|
223
|
+
<span>{fill(t("hikari::scrollProgress.single", "Row {from} of {total}"))}</span>
|
|
224
|
+
) : !degenerate ? (
|
|
225
|
+
<>
|
|
226
|
+
<span>{fill(t("hikari::scrollProgress.rangeHead", "Rows {from}"))}</span>
|
|
227
|
+
<ArrowRight class="hk-scroll-progress-dock-arrow" aria-hidden="true" />
|
|
228
|
+
<span>{fill(t("hikari::scrollProgress.rangeTail", "{to} of {total}"))}</span>
|
|
229
|
+
</>
|
|
230
|
+
) : null}
|
|
231
|
+
</div>
|
|
232
|
+
<HkSlider
|
|
233
|
+
modelValue={Math.min(Math.max(props.from, 1), ceiling)}
|
|
234
|
+
min={1}
|
|
235
|
+
max={ceiling}
|
|
236
|
+
step={1}
|
|
237
|
+
size="sm"
|
|
238
|
+
ariaLabel={t("hikari::scrollProgress.jumpSliderLabel", "Scroll position")}
|
|
239
|
+
onUpdate:modelValue={(n: number) => emit("scrub", n)}
|
|
240
|
+
/>
|
|
241
|
+
<div class="hk-scroll-progress-dock-jump-row">
|
|
242
|
+
<HkNumberInput
|
|
243
|
+
modelValue={jumpValue.value}
|
|
244
|
+
min={1}
|
|
245
|
+
max={ceiling}
|
|
246
|
+
step={1}
|
|
247
|
+
size="sm"
|
|
248
|
+
label={t("hikari::scrollProgress.jumpRowLabel", "Row")}
|
|
249
|
+
onUpdate:modelValue={(n: number) => {
|
|
250
|
+
dirty.value = true;
|
|
251
|
+
jumpValue.value = n;
|
|
252
|
+
}}
|
|
253
|
+
/>
|
|
254
|
+
<HkButton size="sm" variant="secondary" onClick={commit}>
|
|
255
|
+
{t("hikari::scrollProgress.jumpGo", "Go")}
|
|
256
|
+
</HkButton>
|
|
257
|
+
</div>
|
|
258
|
+
</div>
|
|
259
|
+
);
|
|
260
|
+
};
|
|
261
|
+
},
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
/** The pill renderer — now also the jump surface's TRIGGER (user
|
|
265
|
+
* direction 2026-11-30; see the module header). States mirrored on
|
|
266
|
+
* `data-state` so the SCSS owns the paint:
|
|
121
267
|
* - "hidden" — a precondition fails (no registration, no overflow, no
|
|
122
268
|
* rows): `display: none`, never just transparent;
|
|
123
269
|
* - "active" — the scroll offset is changing: opaque;
|
|
124
|
-
* - "idle" — scrolling stopped: opacity 0 over the ~200ms fade
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
270
|
+
* - "idle" — scrolling stopped: opacity 0 over the ~200ms fade —
|
|
271
|
+
* but still HOVERABLE, so the pointer affordance (reveal + open the
|
|
272
|
+
* jump panel) works without a prior scroll; hover/focus/`is-open`
|
|
273
|
+
* paint it opaque again.
|
|
274
|
+
* A11y honesty, updated: the pill was `aria-hidden` decorative chrome
|
|
275
|
+
* while it could not be interacted with; as a trigger it now carries
|
|
276
|
+
* `role="button"`, a localized `aria-label` (the jump title) and the
|
|
277
|
+
* popover wiring (`aria-haspopup` / `aria-expanded`). The band digits
|
|
278
|
+
* stay unnamed chrome INSIDE the button (aria-hidden spans) — the
|
|
279
|
+
* accessible name is the jump label, not the numbers. */
|
|
129
280
|
const HkScrollProgressDockPill = defineComponent({
|
|
130
281
|
name: "HkScrollProgressDockPill",
|
|
131
282
|
props: {
|
|
@@ -138,23 +289,170 @@ const HkScrollProgressDockPill = defineComponent({
|
|
|
138
289
|
to: { type: Number, default: 0 },
|
|
139
290
|
/** Authoritative total (the pill's "共 N 条" / "of N"). */
|
|
140
291
|
total: { type: Number, default: 0 },
|
|
292
|
+
/** The dock's jump executor (put row N at the top of the band).
|
|
293
|
+
* The pill owns the SURFACE (open/pin/close); the dock owns the
|
|
294
|
+
* MOVEMENT — the split keeps the executor next to the registration
|
|
295
|
+
* and row grammar it needs. */
|
|
296
|
+
onJump: { type: Function as PropType<(row: number) => void>, default: undefined },
|
|
141
297
|
},
|
|
142
298
|
setup(props) {
|
|
143
299
|
const { t } = useI18n();
|
|
300
|
+
const pillRef = ref<HTMLElement | null>(null);
|
|
301
|
+
/** The jump panel's wrapper inside the popover slot — the element
|
|
302
|
+
* whose live `:hover` state proves the pointer owns the panel. */
|
|
303
|
+
const panelRootRef = ref<HTMLElement | null>(null);
|
|
304
|
+
const open = ref(false);
|
|
305
|
+
/** A click/tap PINS the panel: it survives the pointer leaving pill
|
|
306
|
+
* and panel, until Esc / outside click / a second pill click / a
|
|
307
|
+
* committed jump. Hover-opened panels are unpinned. */
|
|
308
|
+
const pinned = ref(false);
|
|
309
|
+
// Hover-to-open is a hover-capable pointer affordance only — touch
|
|
310
|
+
// pointers synthesize an enter on the tap that would open a sheet
|
|
311
|
+
// and then fight its own leave; touch opens through click, which
|
|
312
|
+
// pins.
|
|
313
|
+
const hoverCapable = useMediaQuery("(hover: hover) and (pointer: fine)");
|
|
314
|
+
// The pill↔panel travel is not a hover gap (the panel anchors with
|
|
315
|
+
// a 4px offset), but a sensing re-render can land mid-travel; the
|
|
316
|
+
// grace closes only when NO surface owns the pointer after it
|
|
317
|
+
// elapses. A pinned panel ignores it entirely.
|
|
318
|
+
let hoverGrace: ReturnType<typeof setTimeout> | null = null;
|
|
319
|
+
let pointerInPill = false;
|
|
320
|
+
let pointerInPanel = false;
|
|
321
|
+
// Freshness gate on the flags: they only update on enter/leave
|
|
322
|
+
// events, which a STATIONARY pointer never fires — content moving
|
|
323
|
+
// out from under the pointer (a scroll, a list reload) leaves them
|
|
324
|
+
// stale with no event to correct them. Live `:hover` is the ground
|
|
325
|
+
// truth in hover-capable engines; the flags are trusted only while
|
|
326
|
+
// some pointer event is recent (R2 2026-11-30: the previous
|
|
327
|
+
// flag-only check admitted an "open, no owner" state that armed
|
|
328
|
+
// nothing and lingered until the next click).
|
|
329
|
+
let lastPointerActivity = 0;
|
|
330
|
+
const POINTER_FRESH_MS = HOVER_GRACE_MS / 2;
|
|
331
|
+
|
|
332
|
+
function stampPointer() {
|
|
333
|
+
lastPointerActivity = Date.now();
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
function cancelHoverGrace() {
|
|
337
|
+
if (hoverGrace !== null) {
|
|
338
|
+
clearTimeout(hoverGrace);
|
|
339
|
+
hoverGrace = null;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
/** Does the pointer currently own either surface? Live `:hover`
|
|
343
|
+
* wins whenever it reads true (and resyncs the flags with the
|
|
344
|
+
* truth); otherwise recently-stamped flags decide. */
|
|
345
|
+
function matchesHover(el: HTMLElement | null): boolean {
|
|
346
|
+
try {
|
|
347
|
+
return el?.matches(":hover") ?? false;
|
|
348
|
+
} catch {
|
|
349
|
+
// An engine without :hover matching keeps the flag path.
|
|
350
|
+
return false;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
function hoverOwned(): boolean {
|
|
354
|
+
const pillHover = matchesHover(pillRef.value);
|
|
355
|
+
const panelHover = matchesHover(panelRootRef.value);
|
|
356
|
+
if (pillHover || panelHover) {
|
|
357
|
+
pointerInPill = pillHover;
|
|
358
|
+
pointerInPanel = panelHover;
|
|
359
|
+
return true;
|
|
360
|
+
}
|
|
361
|
+
const flagsFresh = Date.now() - lastPointerActivity <= POINTER_FRESH_MS;
|
|
362
|
+
return flagsFresh && (pointerInPill || pointerInPanel);
|
|
363
|
+
}
|
|
364
|
+
function scheduleHoverClose() {
|
|
365
|
+
if (pinned.value) return;
|
|
366
|
+
cancelHoverGrace();
|
|
367
|
+
hoverGrace = setTimeout(() => {
|
|
368
|
+
hoverGrace = null;
|
|
369
|
+
if (!pinned.value && !hoverOwned()) open.value = false;
|
|
370
|
+
}, HOVER_GRACE_MS);
|
|
371
|
+
}
|
|
372
|
+
onBeforeUnmount(cancelHoverGrace);
|
|
373
|
+
onBeforeUnmount(() => releaseMediaQuery("(hover: hover) and (pointer: fine)"));
|
|
374
|
+
// The band updating under an open unpinned panel (a scroll, a list
|
|
375
|
+
// reload) is exactly the event that can strand the pointer off both
|
|
376
|
+
// surfaces without any enter/leave — re-check ownership on it.
|
|
377
|
+
watch([() => props.from, () => props.to], () => {
|
|
378
|
+
if (open.value && !pinned.value) scheduleHoverClose();
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
function onPillPointerEnter() {
|
|
382
|
+
pointerInPill = true;
|
|
383
|
+
stampPointer();
|
|
384
|
+
cancelHoverGrace();
|
|
385
|
+
if (!open.value) {
|
|
386
|
+
pinned.value = false;
|
|
387
|
+
if (hoverCapable.value) {
|
|
388
|
+
open.value = true;
|
|
389
|
+
// Arm the ownership check immediately: the open edge itself
|
|
390
|
+
// must not outlive the pointer that caused it.
|
|
391
|
+
scheduleHoverClose();
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
function onPillPointerLeave() {
|
|
396
|
+
pointerInPill = false;
|
|
397
|
+
stampPointer();
|
|
398
|
+
scheduleHoverClose();
|
|
399
|
+
}
|
|
400
|
+
function onPanelEnter() {
|
|
401
|
+
pointerInPanel = true;
|
|
402
|
+
stampPointer();
|
|
403
|
+
cancelHoverGrace();
|
|
404
|
+
}
|
|
405
|
+
function onPanelLeave() {
|
|
406
|
+
pointerInPanel = false;
|
|
407
|
+
stampPointer();
|
|
408
|
+
scheduleHoverClose();
|
|
409
|
+
}
|
|
410
|
+
/** Click / tap / Enter / Space: toggle. Opening from a click pins. */
|
|
411
|
+
function toggle() {
|
|
412
|
+
stampPointer();
|
|
413
|
+
cancelHoverGrace();
|
|
414
|
+
if (open.value && pinned.value) {
|
|
415
|
+
open.value = false;
|
|
416
|
+
pinned.value = false;
|
|
417
|
+
} else {
|
|
418
|
+
open.value = true;
|
|
419
|
+
pinned.value = true;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
function onPillClick(e: MouseEvent) {
|
|
423
|
+
// The pill owns its clicks: they must not fall through to the
|
|
424
|
+
// rows underneath (the old decorative pass-through — the app
|
|
425
|
+
// copy-toasts the user reported) nor bubble into the host's
|
|
426
|
+
// handlers.
|
|
427
|
+
e.stopPropagation();
|
|
428
|
+
toggle();
|
|
429
|
+
}
|
|
430
|
+
function onPillKeydown(e: KeyboardEvent) {
|
|
431
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
432
|
+
e.preventDefault();
|
|
433
|
+
toggle();
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
function onJumpUpdate(openValue: boolean) {
|
|
437
|
+
open.value = openValue;
|
|
438
|
+
if (!openValue) pinned.value = false;
|
|
439
|
+
}
|
|
440
|
+
function onScrub(row: number) {
|
|
441
|
+
props.onJump?.(row);
|
|
442
|
+
}
|
|
443
|
+
function onCommit(row: number) {
|
|
444
|
+
props.onJump?.(row);
|
|
445
|
+
open.value = false;
|
|
446
|
+
pinned.value = false;
|
|
447
|
+
}
|
|
448
|
+
|
|
144
449
|
return () => {
|
|
145
450
|
// One visible row collapses the range to the single-row sentence
|
|
146
451
|
// (rendered whole, NO icon); a degenerate band (0 rows) renders no
|
|
147
452
|
// text with the pill itself (its precondition path hides it).
|
|
148
453
|
const degenerate = props.total < 1 || props.from < 1 || props.to < props.from;
|
|
149
454
|
const single = !degenerate && props.from === props.to;
|
|
150
|
-
|
|
151
|
-
// (ja's head carries {total}; ko's tail is bare) — the missing
|
|
152
|
-
// ones are no-ops.
|
|
153
|
-
const fill = (s: string) =>
|
|
154
|
-
s
|
|
155
|
-
.replace("{from}", String(props.from))
|
|
156
|
-
.replace("{to}", String(props.to))
|
|
157
|
-
.replace("{total}", String(props.total));
|
|
455
|
+
const fill = (s: string) => fillRange(s, props.from, props.to, props.total);
|
|
158
456
|
const head = single || degenerate
|
|
159
457
|
? ""
|
|
160
458
|
: fill(t("hikari::scrollProgress.rangeHead", "Rows {from}"));
|
|
@@ -164,22 +462,57 @@ const HkScrollProgressDockPill = defineComponent({
|
|
|
164
462
|
const sentence = single
|
|
165
463
|
? fill(t("hikari::scrollProgress.single", "Row {from} of {total}"))
|
|
166
464
|
: "";
|
|
465
|
+
const jumpTitle = t("hikari::scrollProgress.jumpTitle", "Jump to row");
|
|
167
466
|
return (
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
467
|
+
<>
|
|
468
|
+
<span
|
|
469
|
+
ref={pillRef}
|
|
470
|
+
class={open.value ? "hk-scroll-progress-dock is-open" : "hk-scroll-progress-dock"}
|
|
471
|
+
data-state={!props.shown ? "hidden" : props.active ? "active" : "idle"}
|
|
472
|
+
role="button"
|
|
473
|
+
tabindex={props.shown ? 0 : -1}
|
|
474
|
+
aria-haspopup="dialog"
|
|
475
|
+
aria-expanded={props.shown && open.value ? "true" : "false"}
|
|
476
|
+
aria-label={jumpTitle}
|
|
477
|
+
onPointerenter={onPillPointerEnter}
|
|
478
|
+
onPointerleave={onPillPointerLeave}
|
|
479
|
+
onClick={onPillClick}
|
|
480
|
+
onKeydown={onPillKeydown}
|
|
481
|
+
>
|
|
482
|
+
{single ? (
|
|
483
|
+
<span class="hk-scroll-progress-dock-text" aria-hidden="true">{sentence}</span>
|
|
484
|
+
) : !degenerate ? (
|
|
485
|
+
<>
|
|
486
|
+
<span class="hk-scroll-progress-dock-text" aria-hidden="true">{head}</span>
|
|
487
|
+
<ArrowRight class="hk-scroll-progress-dock-arrow" aria-hidden="true" />
|
|
488
|
+
<span class="hk-scroll-progress-dock-text" aria-hidden="true">{tail}</span>
|
|
489
|
+
</>
|
|
490
|
+
) : null}
|
|
491
|
+
</span>
|
|
492
|
+
<HkPopover
|
|
493
|
+
modelValue={open.value}
|
|
494
|
+
onUpdate:modelValue={onJumpUpdate}
|
|
495
|
+
placement="top"
|
|
496
|
+
anchorRef={pillRef.value ?? null}
|
|
497
|
+
sheetOnMobile
|
|
498
|
+
title={jumpTitle}
|
|
499
|
+
onMouseenter={onPanelEnter}
|
|
500
|
+
onMouseleave={onPanelLeave}
|
|
501
|
+
>
|
|
502
|
+
{/* The wrapper carries the panel-root ref the ownership
|
|
503
|
+
check reads `:hover` off (the jump panel itself is the
|
|
504
|
+
slot body; the wrapper adds no chrome). */}
|
|
505
|
+
<div ref={panelRootRef}>
|
|
506
|
+
<HkScrollProgressDockJumpPanel
|
|
507
|
+
from={props.from}
|
|
508
|
+
to={props.to}
|
|
509
|
+
total={props.total}
|
|
510
|
+
onScrub={onScrub}
|
|
511
|
+
onCommit={onCommit}
|
|
512
|
+
/>
|
|
513
|
+
</div>
|
|
514
|
+
</HkPopover>
|
|
515
|
+
</>
|
|
183
516
|
);
|
|
184
517
|
};
|
|
185
518
|
},
|
|
@@ -340,6 +673,62 @@ export const HkScrollProgressDock = defineComponent({
|
|
|
340
673
|
return firstIntersecting ?? (nearestAbove ? { handle: nearestAbove.handle, root: nearestAbove.root } : null);
|
|
341
674
|
}
|
|
342
675
|
|
|
676
|
+
/** The active registration's rows under the CURRENT row grammar —
|
|
677
|
+
* the handle's `getRows` wins over the dock selector (HkTable's
|
|
678
|
+
* section bands are body `<tr>`s that are not data rows; no
|
|
679
|
+
* `getRows` or an undefined return keeps the selector path).
|
|
680
|
+
* Shared by the sensing pass AND the jump executor so the two can
|
|
681
|
+
* never disagree about what a "row" is. */
|
|
682
|
+
function activeRows(band: DOMRect): { handle: HkScrollProgressHandle; root: HTMLElement; rows: readonly Element[] } | null {
|
|
683
|
+
const active = pickActiveProgressRoot(band);
|
|
684
|
+
if (!active) return null;
|
|
685
|
+
const rows = active.handle.getRows?.() ?? Array.from(active.root.querySelectorAll(props.selector));
|
|
686
|
+
return { handle: active.handle, root: active.root, rows };
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
/** Jump the active list so row `target` (1-based) sits at the top
|
|
690
|
+
* of the viewport band — the pill's jump surface executor. Clamped
|
|
691
|
+
* to the LOADED rows: a declared total larger than the delivered
|
|
692
|
+
* rows (a lazy-loading list) cannot be scrolled to until its rows
|
|
693
|
+
* exist, so a jump past the end parks at the last loaded row (the
|
|
694
|
+
* browser's own clamp at the list end does the rest). Instant, not
|
|
695
|
+
* smooth — the slider scrub emits every tick and smooth scrolling
|
|
696
|
+
* would lag behind the gesture. */
|
|
697
|
+
function jumpToRow(target: number): boolean {
|
|
698
|
+
const vp = currentViewport;
|
|
699
|
+
if (!vp) return false;
|
|
700
|
+
// Same overflow precondition as the sensing pass (the pill can be
|
|
701
|
+
// shown from a stale pass and the page shrink under it): nothing
|
|
702
|
+
// to travel when there is no overflow.
|
|
703
|
+
if (vp.scrollHeight <= vp.clientHeight + 1) return false;
|
|
704
|
+
const band = vp.getBoundingClientRect();
|
|
705
|
+
const active = activeRows(band);
|
|
706
|
+
if (!active || active.rows.length === 0) return false;
|
|
707
|
+
const index = Math.min(Math.max(Math.round(target), 1), active.rows.length) - 1;
|
|
708
|
+
const row = active.rows[index] as HTMLElement | undefined;
|
|
709
|
+
if (!row) return false;
|
|
710
|
+
const rect = row.getBoundingClientRect();
|
|
711
|
+
if (!Number.isFinite(rect.top) || !Number.isFinite(band.top)) return false;
|
|
712
|
+
// Zoom/transform-correct placement — the HkScrollContainer.scrollToElement
|
|
713
|
+
// shape (user direction 2026-11-30, wheel audit): a scroll offset lives
|
|
714
|
+
// in LAYOUT space, while the drawn-box delta (`rect.top - band.top`) is
|
|
715
|
+
// `k` times too large at root zoom `k` — the layoutGeometry file doc
|
|
716
|
+
// says exactly this. Target the row's layout offset inside the viewport
|
|
717
|
+
// and keep the drawn-box math only as the fallback for a chain that
|
|
718
|
+
// cannot be summed (an `<svg>` boundary, no layout).
|
|
719
|
+
const inside = laidOffsetWithin(row, vp);
|
|
720
|
+
const landing = Number.isFinite(inside.y)
|
|
721
|
+
? inside.y
|
|
722
|
+
: vp.scrollTop + rect.top - band.top;
|
|
723
|
+
// "instant", not "auto": a dict without an explicit behavior falls
|
|
724
|
+
// back to the used `scroll-behavior`, so a consumer stylesheet could
|
|
725
|
+
// turn the scrub's every tick into a compositor animation. The old
|
|
726
|
+
// `scrollTop =` write was immune; this keeps the doc comment's
|
|
727
|
+
// promise (R2 2026-11-30).
|
|
728
|
+
vp.scrollTo({ top: landing, behavior: "instant" as ScrollBehavior });
|
|
729
|
+
return true;
|
|
730
|
+
}
|
|
731
|
+
|
|
343
732
|
/** Pill sensing. Preconditions: a registration, vertical overflow,
|
|
344
733
|
* and an active list with at least one row; failing any hides the
|
|
345
734
|
* pill outright. While they hold, the band is the VISIBLE ROW
|
|
@@ -359,14 +748,8 @@ export const HkScrollProgressDock = defineComponent({
|
|
|
359
748
|
}
|
|
360
749
|
syncRootObservers();
|
|
361
750
|
const band = vp.getBoundingClientRect();
|
|
362
|
-
const active =
|
|
363
|
-
|
|
364
|
-
// `<tr>`s that are not data rows); its `getRows` wins over the
|
|
365
|
-
// dock selector. No `getRows` (or an undefined return) keeps the
|
|
366
|
-
// selector path byte-for-byte.
|
|
367
|
-
const rows = active
|
|
368
|
-
? active.handle.getRows?.() ?? active.root.querySelectorAll(props.selector)
|
|
369
|
-
: [];
|
|
751
|
+
const active = activeRows(band);
|
|
752
|
+
const rows = active ? active.rows : [];
|
|
370
753
|
if (!active || rows.length === 0 || vp.scrollHeight <= vp.clientHeight + 1) {
|
|
371
754
|
setProgressHidden();
|
|
372
755
|
return;
|
|
@@ -509,6 +892,7 @@ export const HkScrollProgressDock = defineComponent({
|
|
|
509
892
|
from={progressFrom.value}
|
|
510
893
|
to={progressTo.value}
|
|
511
894
|
total={progressDenominator.value}
|
|
895
|
+
onJump={jumpToRow}
|
|
512
896
|
/>
|
|
513
897
|
);
|
|
514
898
|
// The pill TELEPORTS to the container host (the element that is
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!doctype html>
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
|
-
<meta name="hk-error-landing" content="v1 0.55.
|
|
4
|
+
<meta name="hk-error-landing" content="v1 0.55.521 <dev>">
|
|
5
5
|
<meta charset="utf-8" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
7
|
<meta name="robots" content="noindex" />
|
|
@@ -421,5 +421,9 @@
|
|
|
421
421
|
"hikari::mdEditor.viewPreview": "المعاينة فقط",
|
|
422
422
|
"hikari::mdEditor.viewText": "النص فقط",
|
|
423
423
|
"hikari::masterDetail.close": "إغلاق",
|
|
424
|
-
"hikari::masterDetail.emptyTitle": "لم يتم تحديد أي شيء"
|
|
424
|
+
"hikari::masterDetail.emptyTitle": "لم يتم تحديد أي شيء",
|
|
425
|
+
"hikari::scrollProgress.jumpTitle": "الانتقال إلى صف",
|
|
426
|
+
"hikari::scrollProgress.jumpGo": "انتقل",
|
|
427
|
+
"hikari::scrollProgress.jumpRowLabel": "صف",
|
|
428
|
+
"hikari::scrollProgress.jumpSliderLabel": "موضع التمرير"
|
|
425
429
|
}
|
|
@@ -421,5 +421,9 @@
|
|
|
421
421
|
"hikari::mdEditor.viewPreview": "Nur Vorschau",
|
|
422
422
|
"hikari::mdEditor.viewText": "Nur Text",
|
|
423
423
|
"hikari::masterDetail.close": "Schließen",
|
|
424
|
-
"hikari::masterDetail.emptyTitle": "Nichts ausgewählt"
|
|
424
|
+
"hikari::masterDetail.emptyTitle": "Nichts ausgewählt",
|
|
425
|
+
"hikari::scrollProgress.jumpTitle": "Zu Zeile springen",
|
|
426
|
+
"hikari::scrollProgress.jumpGo": "Springen",
|
|
427
|
+
"hikari::scrollProgress.jumpRowLabel": "Zeile",
|
|
428
|
+
"hikari::scrollProgress.jumpSliderLabel": "Scrollposition"
|
|
425
429
|
}
|
|
@@ -421,5 +421,9 @@
|
|
|
421
421
|
"hikari::mdEditor.viewPreview": "Preview only",
|
|
422
422
|
"hikari::mdEditor.viewText": "Text only",
|
|
423
423
|
"hikari::masterDetail.close": "Close",
|
|
424
|
-
"hikari::masterDetail.emptyTitle": "Nothing selected"
|
|
424
|
+
"hikari::masterDetail.emptyTitle": "Nothing selected",
|
|
425
|
+
"hikari::scrollProgress.jumpTitle": "Jump to row",
|
|
426
|
+
"hikari::scrollProgress.jumpGo": "Go",
|
|
427
|
+
"hikari::scrollProgress.jumpRowLabel": "Row",
|
|
428
|
+
"hikari::scrollProgress.jumpSliderLabel": "Scroll position"
|
|
425
429
|
}
|
|
@@ -421,5 +421,9 @@
|
|
|
421
421
|
"hikari::mdEditor.viewPreview": "Solo vista previa",
|
|
422
422
|
"hikari::mdEditor.viewText": "Solo texto",
|
|
423
423
|
"hikari::masterDetail.close": "Cerrar",
|
|
424
|
-
"hikari::masterDetail.emptyTitle": "Nada seleccionado"
|
|
424
|
+
"hikari::masterDetail.emptyTitle": "Nada seleccionado",
|
|
425
|
+
"hikari::scrollProgress.jumpTitle": "Ir a la fila",
|
|
426
|
+
"hikari::scrollProgress.jumpGo": "Ir",
|
|
427
|
+
"hikari::scrollProgress.jumpRowLabel": "Fila",
|
|
428
|
+
"hikari::scrollProgress.jumpSliderLabel": "Posición"
|
|
425
429
|
}
|
|
@@ -421,5 +421,9 @@
|
|
|
421
421
|
"hikari::mdEditor.viewPreview": "Aperçu seul",
|
|
422
422
|
"hikari::mdEditor.viewText": "Texte seul",
|
|
423
423
|
"hikari::masterDetail.close": "Fermer",
|
|
424
|
-
"hikari::masterDetail.emptyTitle": "Aucune sélection"
|
|
424
|
+
"hikari::masterDetail.emptyTitle": "Aucune sélection",
|
|
425
|
+
"hikari::scrollProgress.jumpTitle": "Aller à la ligne",
|
|
426
|
+
"hikari::scrollProgress.jumpGo": "Aller",
|
|
427
|
+
"hikari::scrollProgress.jumpRowLabel": "Ligne",
|
|
428
|
+
"hikari::scrollProgress.jumpSliderLabel": "Position"
|
|
425
429
|
}
|
|
@@ -421,5 +421,9 @@
|
|
|
421
421
|
"hikari::mdEditor.viewPreview": "プレビューのみ",
|
|
422
422
|
"hikari::mdEditor.viewText": "テキストのみ",
|
|
423
423
|
"hikari::masterDetail.close": "閉じる",
|
|
424
|
-
"hikari::masterDetail.emptyTitle": "何も選択されていません"
|
|
424
|
+
"hikari::masterDetail.emptyTitle": "何も選択されていません",
|
|
425
|
+
"hikari::scrollProgress.jumpTitle": "行へ移動",
|
|
426
|
+
"hikari::scrollProgress.jumpGo": "移動",
|
|
427
|
+
"hikari::scrollProgress.jumpRowLabel": "行",
|
|
428
|
+
"hikari::scrollProgress.jumpSliderLabel": "スクロール位置"
|
|
425
429
|
}
|
|
@@ -421,5 +421,9 @@
|
|
|
421
421
|
"hikari::mdEditor.viewPreview": "미리보기만",
|
|
422
422
|
"hikari::mdEditor.viewText": "텍스트만",
|
|
423
423
|
"hikari::masterDetail.close": "닫기",
|
|
424
|
-
"hikari::masterDetail.emptyTitle": "선택된 항목 없음"
|
|
424
|
+
"hikari::masterDetail.emptyTitle": "선택된 항목 없음",
|
|
425
|
+
"hikari::scrollProgress.jumpTitle": "행으로 이동",
|
|
426
|
+
"hikari::scrollProgress.jumpGo": "이동",
|
|
427
|
+
"hikari::scrollProgress.jumpRowLabel": "행",
|
|
428
|
+
"hikari::scrollProgress.jumpSliderLabel": "스크롤 위치"
|
|
425
429
|
}
|
|
@@ -421,5 +421,9 @@
|
|
|
421
421
|
"hikari::mdEditor.viewPreview": "Só pré-visualização",
|
|
422
422
|
"hikari::mdEditor.viewText": "Só texto",
|
|
423
423
|
"hikari::masterDetail.close": "Fechar",
|
|
424
|
-
"hikari::masterDetail.emptyTitle": "Nada selecionado"
|
|
424
|
+
"hikari::masterDetail.emptyTitle": "Nada selecionado",
|
|
425
|
+
"hikari::scrollProgress.jumpTitle": "Ir para a linha",
|
|
426
|
+
"hikari::scrollProgress.jumpGo": "Ir",
|
|
427
|
+
"hikari::scrollProgress.jumpRowLabel": "Linha",
|
|
428
|
+
"hikari::scrollProgress.jumpSliderLabel": "Posição"
|
|
425
429
|
}
|
|
@@ -421,5 +421,9 @@
|
|
|
421
421
|
"hikari::mdEditor.viewPreview": "Только предпросмотр",
|
|
422
422
|
"hikari::mdEditor.viewText": "Только текст",
|
|
423
423
|
"hikari::masterDetail.close": "Закрыть",
|
|
424
|
-
"hikari::masterDetail.emptyTitle": "Ничего не выбрано"
|
|
424
|
+
"hikari::masterDetail.emptyTitle": "Ничего не выбрано",
|
|
425
|
+
"hikari::scrollProgress.jumpTitle": "Перейти к строке",
|
|
426
|
+
"hikari::scrollProgress.jumpGo": "Перейти",
|
|
427
|
+
"hikari::scrollProgress.jumpRowLabel": "Строка",
|
|
428
|
+
"hikari::scrollProgress.jumpSliderLabel": "Позиция"
|
|
425
429
|
}
|