@open-slide/core 1.13.6 → 1.15.0
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/{build-OAZ8maw5.js → build-BsaslS8C.js} +1 -1
- package/dist/cli/bin.js +3 -3
- package/dist/{config-CU_NISD6.js → config-BOc3-oDV.js} +38 -3
- package/dist/{config-CvzwK0tq.d.ts → config-CE2sKgqH.d.ts} +1 -1
- package/dist/dev-BU7OY0ai.js +94 -0
- package/dist/{format-CXtO6ORA.js → format-afijk371.js} +140 -8
- package/dist/index.d.ts +7 -7
- package/dist/index.js +4 -2
- package/dist/locale/index.d.ts +1 -1
- package/dist/locale/index.js +1 -1
- package/dist/{preview-DZLZ3L9v.js → preview-DbL7Wt77.js} +1 -1
- package/dist/{types-DucrShh9.d.ts → types-GA4ekcYB.d.ts} +37 -0
- package/dist/vite/index.d.ts +2 -2
- package/dist/vite/index.js +1 -1
- package/package.json +2 -2
- package/src/app/components/asset-view.tsx +762 -63
- package/src/app/components/inspector/image-crop-dialog.tsx +3 -3
- package/src/app/components/inspector/inspect-overlay.tsx +44 -32
- package/src/app/components/inspector/inspector-panel.tsx +31 -26
- package/src/app/components/language-toggle.tsx +1 -1
- package/src/app/components/overview-grid.tsx +14 -12
- package/src/app/components/present/control-bar.tsx +24 -21
- package/src/app/components/present/progress-bar.tsx +1 -1
- package/src/app/components/sidebar/folder-item.tsx +26 -22
- package/src/app/components/sidebar/icon-picker.tsx +8 -8
- package/src/app/components/sidebar/sidebar-footer.tsx +100 -31
- package/src/app/components/sidebar/sidebar.tsx +22 -18
- package/src/app/components/style-panel/style-panel.tsx +8 -4
- package/src/app/components/theme-toggle.tsx +3 -3
- package/src/app/components/themes/theme-detail.tsx +2 -2
- package/src/app/components/themes/themes-gallery.tsx +1 -1
- package/src/app/components/thumbnail-rail-scroll.test.ts +60 -0
- package/src/app/components/thumbnail-rail-scroll.ts +33 -0
- package/src/app/components/thumbnail-rail.tsx +235 -66
- package/src/app/components/ui/badge.tsx +16 -13
- package/src/app/components/ui/button.tsx +4 -10
- package/src/app/components/ui/context-menu.tsx +46 -36
- package/src/app/components/ui/dialog.tsx +11 -13
- package/src/app/components/ui/dropdown-menu.tsx +59 -37
- package/src/app/components/ui/label.tsx +2 -5
- package/src/app/components/ui/popover.tsx +25 -18
- package/src/app/components/ui/progress.tsx +8 -6
- package/src/app/components/ui/scroll-area.tsx +5 -5
- package/src/app/components/ui/select.tsx +40 -41
- package/src/app/components/ui/separator.tsx +3 -5
- package/src/app/components/ui/slider.tsx +25 -18
- package/src/app/components/ui/tabs.tsx +8 -8
- package/src/app/components/ui/toggle-group.tsx +8 -7
- package/src/app/components/ui/toggle.tsx +5 -5
- package/src/app/components/ui/tooltip.tsx +39 -22
- package/src/app/lib/asset-filter.test.ts +176 -0
- package/src/app/lib/asset-filter.ts +80 -0
- package/src/app/lib/assets.ts +19 -4
- package/src/app/routes/home-shell.tsx +24 -20
- package/src/app/routes/home.tsx +48 -42
- package/src/app/routes/presenter.tsx +1 -1
- package/src/app/routes/slide.tsx +54 -47
- package/src/app/styles.css +86 -110
- package/src/locale/en.ts +34 -1
- package/src/locale/ja.ts +34 -2
- package/src/locale/types.ts +37 -0
- package/src/locale/zh-cn.ts +34 -1
- package/src/locale/zh-tw.ts +34 -1
- package/dist/dev-C78J1TLR.js +0 -20
|
@@ -15,8 +15,18 @@ import {
|
|
|
15
15
|
verticalListSortingStrategy,
|
|
16
16
|
} from '@dnd-kit/sortable';
|
|
17
17
|
import { CSS } from '@dnd-kit/utilities';
|
|
18
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
ChevronDown,
|
|
20
|
+
ChevronUp,
|
|
21
|
+
Copy,
|
|
22
|
+
Grid2x2,
|
|
23
|
+
ListOrdered,
|
|
24
|
+
type LucideIcon,
|
|
25
|
+
Sparkles,
|
|
26
|
+
Trash2,
|
|
27
|
+
} from 'lucide-react';
|
|
19
28
|
import { Fragment, useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
29
|
+
import { Button } from '@/components/ui/button';
|
|
20
30
|
import {
|
|
21
31
|
ContextMenu,
|
|
22
32
|
ContextMenuContent,
|
|
@@ -34,6 +44,11 @@ import type { Page } from '../lib/sdk';
|
|
|
34
44
|
import { CANVAS_HEIGHT, CANVAS_WIDTH } from '../lib/sdk';
|
|
35
45
|
import type { SlideTransition } from '../lib/transition';
|
|
36
46
|
import { SlideCanvas } from './slide-canvas';
|
|
47
|
+
import {
|
|
48
|
+
getCenteredThumbnailScrollTop,
|
|
49
|
+
getThumbnailOffscreenDirection,
|
|
50
|
+
type ThumbnailOffscreenDirection,
|
|
51
|
+
} from './thumbnail-rail-scroll';
|
|
37
52
|
|
|
38
53
|
type Orientation = 'vertical' | 'horizontal';
|
|
39
54
|
|
|
@@ -84,18 +99,23 @@ export function ThumbnailRail({
|
|
|
84
99
|
onOverview,
|
|
85
100
|
}: Props) {
|
|
86
101
|
const activeRef = useRef<HTMLButtonElement | null>(null);
|
|
102
|
+
const virtualListRef = useRef<HTMLDivElement | null>(null);
|
|
103
|
+
const verticalViewportRef = useRef<HTMLElement | null>(null);
|
|
104
|
+
const focusCurrentAfterScrollRef = useRef(false);
|
|
105
|
+
const [currentPosition, setCurrentPosition] = useState<ThumbnailOffscreenDirection>(null);
|
|
87
106
|
const t = useLocale();
|
|
88
107
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
108
|
+
const setVerticalScrollElements = useCallback(
|
|
109
|
+
(viewport: HTMLElement | null, root: HTMLDivElement | null) => {
|
|
110
|
+
verticalViewportRef.current = viewport;
|
|
111
|
+
virtualListRef.current = root;
|
|
112
|
+
},
|
|
113
|
+
[],
|
|
114
|
+
);
|
|
92
115
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
behavior: reduceMotion ? 'auto' : 'smooth',
|
|
97
|
-
});
|
|
98
|
-
}, [current]);
|
|
116
|
+
const cancelPendingFocus = useCallback(() => {
|
|
117
|
+
focusCurrentAfterScrollRef.current = false;
|
|
118
|
+
}, []);
|
|
99
119
|
|
|
100
120
|
const thumbWidth =
|
|
101
121
|
width != null
|
|
@@ -105,6 +125,52 @@ export function ThumbnailRail({
|
|
|
105
125
|
const height = CANVAS_HEIGHT * scale;
|
|
106
126
|
const rowHeight = height + VERTICAL_THUMB_PADDING_Y + VERTICAL_THUMB_GAP;
|
|
107
127
|
|
|
128
|
+
const scrollToCurrent = useCallback(
|
|
129
|
+
(focusCurrent: boolean) => {
|
|
130
|
+
const viewport = verticalViewportRef.current;
|
|
131
|
+
const root = virtualListRef.current;
|
|
132
|
+
if (!viewport || !root || pages.length <= 0) return;
|
|
133
|
+
|
|
134
|
+
focusCurrentAfterScrollRef.current = focusCurrent;
|
|
135
|
+
const clampedCurrent = Math.min(Math.max(current, 0), pages.length - 1);
|
|
136
|
+
const topInset = root.offsetTop;
|
|
137
|
+
const itemTop = topInset + clampedCurrent * rowHeight;
|
|
138
|
+
viewport.scrollTo({
|
|
139
|
+
top: getCenteredThumbnailScrollTop({
|
|
140
|
+
itemTop,
|
|
141
|
+
itemHeight: rowHeight,
|
|
142
|
+
viewportHeight: viewport.clientHeight,
|
|
143
|
+
topInset,
|
|
144
|
+
}),
|
|
145
|
+
behavior: scrollBehavior(),
|
|
146
|
+
});
|
|
147
|
+
},
|
|
148
|
+
[current, pages.length, rowHeight],
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
useEffect(() => {
|
|
152
|
+
if (currentPosition !== null || !focusCurrentAfterScrollRef.current) return;
|
|
153
|
+
let frame = 0;
|
|
154
|
+
let attempts = 0;
|
|
155
|
+
const focusCurrent = () => {
|
|
156
|
+
if (!focusCurrentAfterScrollRef.current) return;
|
|
157
|
+
const active = activeRef.current;
|
|
158
|
+
if (active) {
|
|
159
|
+
active.focus({ preventScroll: true });
|
|
160
|
+
focusCurrentAfterScrollRef.current = false;
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
attempts += 1;
|
|
164
|
+
if (attempts < 4) {
|
|
165
|
+
frame = requestAnimationFrame(focusCurrent);
|
|
166
|
+
} else {
|
|
167
|
+
focusCurrentAfterScrollRef.current = false;
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
frame = requestAnimationFrame(focusCurrent);
|
|
171
|
+
return () => cancelAnimationFrame(frame);
|
|
172
|
+
}, [currentPosition]);
|
|
173
|
+
|
|
108
174
|
const renderThumb = useCallback(
|
|
109
175
|
(PageComp: Page, i: number) => {
|
|
110
176
|
const active = i === current;
|
|
@@ -138,7 +204,7 @@ export function ThumbnailRail({
|
|
|
138
204
|
ref={active ? activeRef : undefined}
|
|
139
205
|
onClick={() => onSelect(i)}
|
|
140
206
|
aria-label={format(t.thumbnailRail.goToPageAria, { n: i + 1 })}
|
|
141
|
-
aria-current={active ? '
|
|
207
|
+
aria-current={active ? 'page' : undefined}
|
|
142
208
|
className={thumbButtonClass(active)}
|
|
143
209
|
>
|
|
144
210
|
{inner}
|
|
@@ -206,20 +272,22 @@ export function ThumbnailRail({
|
|
|
206
272
|
<span className="folio">{pages.length.toString().padStart(2, '0')}</span>
|
|
207
273
|
{onOverview && (
|
|
208
274
|
<Tooltip>
|
|
209
|
-
<TooltipTrigger
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
275
|
+
<TooltipTrigger
|
|
276
|
+
render={
|
|
277
|
+
<button
|
|
278
|
+
type="button"
|
|
279
|
+
onClick={onOverview}
|
|
280
|
+
aria-label={t.thumbnailRail.overviewAria}
|
|
281
|
+
className={cn(
|
|
282
|
+
'flex size-5 items-center justify-center rounded-[3px] text-muted-foreground/70 outline-none',
|
|
283
|
+
'motion-safe:transition-colors hover:bg-muted hover:text-foreground',
|
|
284
|
+
'focus-visible:ring-1 focus-visible:ring-brand',
|
|
285
|
+
)}
|
|
286
|
+
>
|
|
287
|
+
<Grid2x2 className="size-3.5" strokeWidth={1.75} />
|
|
288
|
+
</button>
|
|
289
|
+
}
|
|
290
|
+
/>
|
|
223
291
|
<TooltipContent side="bottom" sideOffset={6}>
|
|
224
292
|
{t.thumbnailRail.overviewAria}
|
|
225
293
|
</TooltipContent>
|
|
@@ -233,36 +301,104 @@ export function ThumbnailRail({
|
|
|
233
301
|
current={current}
|
|
234
302
|
rowHeight={rowHeight}
|
|
235
303
|
activeRef={activeRef}
|
|
304
|
+
onScrollElementsChange={setVerticalScrollElements}
|
|
305
|
+
onScrollInteraction={cancelPendingFocus}
|
|
306
|
+
onCurrentPositionChange={setCurrentPosition}
|
|
236
307
|
renderThumb={renderThumb}
|
|
237
308
|
/>
|
|
238
309
|
</aside>
|
|
239
310
|
);
|
|
240
311
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
312
|
+
const scrollAreaContents = onReorder ? (
|
|
313
|
+
<SortableRail pages={pages} onReorder={onReorder} onSelect={onSelect}>
|
|
314
|
+
{list}
|
|
315
|
+
</SortableRail>
|
|
316
|
+
) : (
|
|
317
|
+
list
|
|
318
|
+
);
|
|
319
|
+
|
|
320
|
+
return (
|
|
321
|
+
<TooltipProvider delay={200}>
|
|
322
|
+
<div className="relative h-full">
|
|
244
323
|
<ScrollArea className="h-full border-r border-hairline bg-sidebar [&_[data-slot=scroll-area-scrollbar]]:z-20">
|
|
245
|
-
{
|
|
324
|
+
{scrollAreaContents}
|
|
246
325
|
</ScrollArea>
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
326
|
+
{currentPosition && (
|
|
327
|
+
<CurrentThumbnailButton
|
|
328
|
+
direction={currentPosition}
|
|
329
|
+
label={format(
|
|
330
|
+
currentPosition === 'above'
|
|
331
|
+
? t.thumbnailRail.scrollUpToCurrentPage
|
|
332
|
+
: t.thumbnailRail.scrollDownToCurrentPage,
|
|
333
|
+
{ n: current + 1 },
|
|
334
|
+
)}
|
|
335
|
+
onActivate={scrollToCurrent}
|
|
336
|
+
/>
|
|
337
|
+
)}
|
|
338
|
+
</div>
|
|
339
|
+
</TooltipProvider>
|
|
340
|
+
);
|
|
341
|
+
}
|
|
250
342
|
|
|
343
|
+
function CurrentThumbnailButton({
|
|
344
|
+
direction,
|
|
345
|
+
label,
|
|
346
|
+
onActivate,
|
|
347
|
+
}: {
|
|
348
|
+
direction: Exclude<ThumbnailOffscreenDirection, null>;
|
|
349
|
+
label: string;
|
|
350
|
+
onActivate: (focusCurrent: boolean) => void;
|
|
351
|
+
}) {
|
|
352
|
+
const Icon = direction === 'above' ? ChevronUp : ChevronDown;
|
|
251
353
|
return (
|
|
252
|
-
<
|
|
253
|
-
<
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
354
|
+
<Tooltip>
|
|
355
|
+
<TooltipTrigger
|
|
356
|
+
render={
|
|
357
|
+
<Button
|
|
358
|
+
type="button"
|
|
359
|
+
variant="outline"
|
|
360
|
+
size="icon-sm"
|
|
361
|
+
aria-label={label}
|
|
362
|
+
onClick={(event) => onActivate(event.detail === 0)}
|
|
363
|
+
onKeyDown={(event) => {
|
|
364
|
+
if (event.key === ' ') {
|
|
365
|
+
event.preventDefault();
|
|
366
|
+
event.stopPropagation();
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
if (event.key !== 'Enter') return;
|
|
370
|
+
event.preventDefault();
|
|
371
|
+
event.stopPropagation();
|
|
372
|
+
onActivate(true);
|
|
373
|
+
}}
|
|
374
|
+
onKeyUp={(event) => {
|
|
375
|
+
if (event.key !== ' ') return;
|
|
376
|
+
event.preventDefault();
|
|
377
|
+
event.stopPropagation();
|
|
378
|
+
onActivate(true);
|
|
379
|
+
}}
|
|
380
|
+
className={cn(
|
|
381
|
+
'pointer-events-auto absolute left-1/2 z-30 -translate-x-1/2 bg-card/95 shadow-floating backdrop-blur-sm',
|
|
382
|
+
'motion-safe:animate-in motion-safe:fade-in-0 motion-safe:zoom-in-95 motion-safe:duration-150',
|
|
383
|
+
direction === 'above' ? 'top-10' : 'bottom-3',
|
|
384
|
+
)}
|
|
385
|
+
>
|
|
386
|
+
<Icon className="size-3.5" strokeWidth={1.75} aria-hidden />
|
|
387
|
+
</Button>
|
|
388
|
+
}
|
|
389
|
+
/>
|
|
390
|
+
<TooltipContent side={direction === 'above' ? 'bottom' : 'top'} sideOffset={6}>
|
|
391
|
+
{label}
|
|
392
|
+
</TooltipContent>
|
|
393
|
+
</Tooltip>
|
|
259
394
|
);
|
|
260
395
|
}
|
|
261
396
|
|
|
262
397
|
function thumbButtonClass(active: boolean): string {
|
|
263
398
|
return cn(
|
|
264
|
-
'group/thumb flex w-full items-start gap-2.5 rounded-[6px] p-1.5 text-left motion-safe:transition-colors',
|
|
399
|
+
'group/thumb flex w-full items-start gap-2.5 rounded-[6px] p-1.5 text-left outline-none motion-safe:transition-colors',
|
|
265
400
|
'hover:bg-muted/60',
|
|
401
|
+
'focus-visible:ring-1 focus-visible:ring-brand focus-visible:ring-offset-1 focus-visible:ring-offset-sidebar',
|
|
266
402
|
active && 'bg-muted',
|
|
267
403
|
);
|
|
268
404
|
}
|
|
@@ -362,7 +498,7 @@ function HorizontalVirtualThumbList({
|
|
|
362
498
|
ref={active ? activeRef : undefined}
|
|
363
499
|
onClick={() => onSelect(i)}
|
|
364
500
|
aria-label={format(t.thumbnailRail.goToPageAria, { n: i + 1 })}
|
|
365
|
-
aria-current={active ? '
|
|
501
|
+
aria-current={active ? 'page' : undefined}
|
|
366
502
|
className={cn('group/thumb relative flex shrink-0 flex-col items-center gap-1.5')}
|
|
367
503
|
>
|
|
368
504
|
<span
|
|
@@ -432,12 +568,18 @@ function VirtualThumbList({
|
|
|
432
568
|
current,
|
|
433
569
|
rowHeight,
|
|
434
570
|
activeRef,
|
|
571
|
+
onScrollElementsChange,
|
|
572
|
+
onScrollInteraction,
|
|
573
|
+
onCurrentPositionChange,
|
|
435
574
|
renderThumb,
|
|
436
575
|
}: {
|
|
437
576
|
pages: Page[];
|
|
438
577
|
current: number;
|
|
439
578
|
rowHeight: number;
|
|
440
579
|
activeRef: React.MutableRefObject<HTMLButtonElement | null>;
|
|
580
|
+
onScrollElementsChange: (viewport: HTMLElement | null, root: HTMLDivElement | null) => void;
|
|
581
|
+
onScrollInteraction: () => void;
|
|
582
|
+
onCurrentPositionChange: (position: ThumbnailOffscreenDirection) => void;
|
|
441
583
|
renderThumb: (page: Page, index: number) => React.ReactNode;
|
|
442
584
|
}) {
|
|
443
585
|
const rootRef = useRef<HTMLDivElement | null>(null);
|
|
@@ -450,14 +592,32 @@ function VirtualThumbList({
|
|
|
450
592
|
if (!viewport || !root) return;
|
|
451
593
|
const scrollTop = Math.max(0, viewport.scrollTop - root.offsetTop);
|
|
452
594
|
setRange(getVisibleRange(scrollTop, pages.length, viewport.clientHeight, rowHeight));
|
|
453
|
-
|
|
595
|
+
|
|
596
|
+
if (pages.length <= 0) {
|
|
597
|
+
onCurrentPositionChange(null);
|
|
598
|
+
return;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
const clampedCurrent = Math.min(Math.max(current, 0), pages.length - 1);
|
|
602
|
+
const itemTop = root.offsetTop + clampedCurrent * rowHeight;
|
|
603
|
+
onCurrentPositionChange(
|
|
604
|
+
getThumbnailOffscreenDirection({
|
|
605
|
+
itemTop,
|
|
606
|
+
itemBottom: itemTop + rowHeight,
|
|
607
|
+
visibleTop: viewport.scrollTop + root.offsetTop,
|
|
608
|
+
visibleBottom: viewport.scrollTop + viewport.clientHeight,
|
|
609
|
+
}),
|
|
610
|
+
);
|
|
611
|
+
}, [current, onCurrentPositionChange, pages.length, rowHeight]);
|
|
454
612
|
|
|
455
613
|
useEffect(() => {
|
|
456
614
|
const root = rootRef.current;
|
|
457
615
|
if (!root) return;
|
|
458
616
|
const viewport = root.closest('[data-slot="scroll-area-viewport"]') as HTMLElement | null;
|
|
459
617
|
if (!viewport) return;
|
|
618
|
+
const scrollArea = viewport.parentElement;
|
|
460
619
|
viewportRef.current = viewport;
|
|
620
|
+
onScrollElementsChange(viewport, root);
|
|
461
621
|
|
|
462
622
|
let frame = 0;
|
|
463
623
|
const scheduleUpdate = () => {
|
|
@@ -467,29 +627,38 @@ function VirtualThumbList({
|
|
|
467
627
|
const resizeObserver = new ResizeObserver(scheduleUpdate);
|
|
468
628
|
|
|
469
629
|
viewport.addEventListener('scroll', scheduleUpdate, { passive: true });
|
|
630
|
+
scrollArea?.addEventListener('wheel', onScrollInteraction, { passive: true });
|
|
631
|
+
scrollArea?.addEventListener('touchstart', onScrollInteraction, { passive: true });
|
|
632
|
+
scrollArea?.addEventListener('pointerdown', onScrollInteraction, { passive: true });
|
|
470
633
|
resizeObserver.observe(viewport);
|
|
471
634
|
scheduleUpdate();
|
|
472
635
|
|
|
473
636
|
return () => {
|
|
474
637
|
cancelAnimationFrame(frame);
|
|
475
638
|
viewport.removeEventListener('scroll', scheduleUpdate);
|
|
639
|
+
scrollArea?.removeEventListener('wheel', onScrollInteraction);
|
|
640
|
+
scrollArea?.removeEventListener('touchstart', onScrollInteraction);
|
|
641
|
+
scrollArea?.removeEventListener('pointerdown', onScrollInteraction);
|
|
476
642
|
resizeObserver.disconnect();
|
|
477
643
|
if (viewportRef.current === viewport) viewportRef.current = null;
|
|
644
|
+
onScrollElementsChange(null, null);
|
|
478
645
|
};
|
|
479
|
-
}, [updateRange]);
|
|
646
|
+
}, [onScrollElementsChange, onScrollInteraction, updateRange]);
|
|
480
647
|
|
|
481
648
|
useEffect(() => {
|
|
482
649
|
const viewport = viewportRef.current;
|
|
483
650
|
const root = rootRef.current;
|
|
484
651
|
if (!viewport || !root) return;
|
|
485
652
|
|
|
486
|
-
|
|
653
|
+
if (pages.length <= 0) return;
|
|
654
|
+
const clampedCurrent = Math.min(Math.max(current, 0), pages.length - 1);
|
|
655
|
+
const top = root.offsetTop + clampedCurrent * rowHeight;
|
|
487
656
|
const bottom = top + rowHeight;
|
|
488
|
-
const viewportTop = viewport.scrollTop;
|
|
489
|
-
const viewportBottom =
|
|
657
|
+
const viewportTop = viewport.scrollTop + root.offsetTop;
|
|
658
|
+
const viewportBottom = viewport.scrollTop + viewport.clientHeight;
|
|
490
659
|
|
|
491
660
|
if (top < viewportTop) {
|
|
492
|
-
viewport.scrollTo({ top, behavior: scrollBehavior() });
|
|
661
|
+
viewport.scrollTo({ top: top - root.offsetTop, behavior: scrollBehavior() });
|
|
493
662
|
} else if (bottom > viewportBottom) {
|
|
494
663
|
viewport.scrollTo({ top: bottom - viewport.clientHeight, behavior: scrollBehavior() });
|
|
495
664
|
} else {
|
|
@@ -499,7 +668,7 @@ function VirtualThumbList({
|
|
|
499
668
|
behavior: scrollBehavior(),
|
|
500
669
|
});
|
|
501
670
|
}
|
|
502
|
-
}, [activeRef, current, rowHeight]);
|
|
671
|
+
}, [activeRef, current, pages.length, rowHeight]);
|
|
503
672
|
|
|
504
673
|
const visibleRange = clampVisibleRange(range, current, pages.length);
|
|
505
674
|
const visible = [];
|
|
@@ -643,18 +812,20 @@ function ThumbContents({
|
|
|
643
812
|
function ThumbIndicator({ icon: Icon, label }: { icon: LucideIcon; label: string }) {
|
|
644
813
|
return (
|
|
645
814
|
<Tooltip>
|
|
646
|
-
<TooltipTrigger
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
815
|
+
<TooltipTrigger
|
|
816
|
+
render={
|
|
817
|
+
<span
|
|
818
|
+
role="img"
|
|
819
|
+
aria-label={label}
|
|
820
|
+
className={cn(
|
|
821
|
+
'flex size-3.5 items-center justify-center text-muted-foreground/55',
|
|
822
|
+
'motion-safe:transition-colors group-hover/thumb:text-muted-foreground/80',
|
|
823
|
+
)}
|
|
824
|
+
>
|
|
825
|
+
<Icon className="size-3" strokeWidth={2} />
|
|
826
|
+
</span>
|
|
827
|
+
}
|
|
828
|
+
/>
|
|
658
829
|
<TooltipContent side="right" sideOffset={6}>
|
|
659
830
|
{label}
|
|
660
831
|
</TooltipContent>
|
|
@@ -679,11 +850,9 @@ function ThumbContextMenu({
|
|
|
679
850
|
const canDelete = pageCount > 1;
|
|
680
851
|
return (
|
|
681
852
|
<ContextMenu>
|
|
682
|
-
<ContextMenuTrigger
|
|
683
|
-
{children}
|
|
684
|
-
</ContextMenuTrigger>
|
|
853
|
+
<ContextMenuTrigger aria-label={ariaLabel} render={children as React.ReactElement} />
|
|
685
854
|
<ContextMenuContent className="min-w-[180px]">
|
|
686
|
-
<ContextMenuItem
|
|
855
|
+
<ContextMenuItem onClick={() => actions.onDuplicate(index)}>
|
|
687
856
|
<Copy />
|
|
688
857
|
{t.thumbnailRail.duplicatePage}
|
|
689
858
|
</ContextMenuItem>
|
|
@@ -691,7 +860,7 @@ function ThumbContextMenu({
|
|
|
691
860
|
<ContextMenuItem
|
|
692
861
|
variant="destructive"
|
|
693
862
|
disabled={!canDelete}
|
|
694
|
-
|
|
863
|
+
onClick={() => {
|
|
695
864
|
if (canDelete) actions.onDelete(index);
|
|
696
865
|
}}
|
|
697
866
|
>
|
|
@@ -786,7 +955,7 @@ function SortableThumb({
|
|
|
786
955
|
type="button"
|
|
787
956
|
onClick={onSelect}
|
|
788
957
|
aria-label={ariaLabel}
|
|
789
|
-
aria-current={active ? '
|
|
958
|
+
aria-current={active ? 'page' : undefined}
|
|
790
959
|
style={{
|
|
791
960
|
transform: CSS.Transform.toString(yOnlyTransform),
|
|
792
961
|
transition,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { cva, type VariantProps } from 'class-variance-authority';
|
|
3
|
-
import {
|
|
3
|
+
import { mergeProps } from '@base-ui/react/merge-props';
|
|
4
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
4
5
|
|
|
5
6
|
import { cn } from '@/lib/utils';
|
|
6
7
|
|
|
@@ -27,19 +28,21 @@ const badgeVariants = cva(
|
|
|
27
28
|
function Badge({
|
|
28
29
|
className,
|
|
29
30
|
variant = 'default',
|
|
30
|
-
|
|
31
|
+
render,
|
|
31
32
|
...props
|
|
32
|
-
}:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
<
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
}: useRender.ComponentProps<'span'> & VariantProps<typeof badgeVariants>) {
|
|
34
|
+
return useRender({
|
|
35
|
+
defaultTagName: 'span',
|
|
36
|
+
render,
|
|
37
|
+
props: mergeProps<'span'>(
|
|
38
|
+
{
|
|
39
|
+
'data-slot': 'badge',
|
|
40
|
+
'data-variant': variant,
|
|
41
|
+
className: cn(badgeVariants({ variant }), className),
|
|
42
|
+
} as React.ComponentPropsWithRef<'span'>,
|
|
43
|
+
props,
|
|
44
|
+
),
|
|
45
|
+
});
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
export { Badge, badgeVariants };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { cva, type VariantProps } from 'class-variance-authority';
|
|
3
|
-
import {
|
|
3
|
+
import { Button as ButtonPrimitive } from '@base-ui/react/button';
|
|
4
4
|
|
|
5
5
|
import { cn } from '@/lib/utils';
|
|
6
6
|
|
|
@@ -39,7 +39,7 @@ const buttonVariants = cva(
|
|
|
39
39
|
'border border-border bg-card text-foreground',
|
|
40
40
|
'hover:bg-muted/60 hover:border-foreground/20',
|
|
41
41
|
'aria-expanded:bg-muted aria-expanded:border-foreground/25',
|
|
42
|
-
'data-
|
|
42
|
+
'data-pressed:bg-foreground data-pressed:text-background data-pressed:border-foreground',
|
|
43
43
|
].join(' '),
|
|
44
44
|
secondary:
|
|
45
45
|
'bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary/90',
|
|
@@ -77,16 +77,10 @@ function Button({
|
|
|
77
77
|
className,
|
|
78
78
|
variant = 'default',
|
|
79
79
|
size = 'default',
|
|
80
|
-
asChild = false,
|
|
81
80
|
...props
|
|
82
|
-
}: React.ComponentProps<
|
|
83
|
-
VariantProps<typeof buttonVariants> & {
|
|
84
|
-
asChild?: boolean;
|
|
85
|
-
}) {
|
|
86
|
-
const Comp = asChild ? Slot.Root : 'button';
|
|
87
|
-
|
|
81
|
+
}: React.ComponentProps<typeof ButtonPrimitive> & VariantProps<typeof buttonVariants>) {
|
|
88
82
|
return (
|
|
89
|
-
<
|
|
83
|
+
<ButtonPrimitive
|
|
90
84
|
data-slot="button"
|
|
91
85
|
data-variant={variant}
|
|
92
86
|
data-size={size}
|