@marianmeres/stuic 2.40.0 → 2.41.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.
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
import { tooltip } from "../../actions/index.js";
|
|
31
31
|
import { X } from "../X/index.js";
|
|
32
32
|
import { preloadImgs } from "../../utils/preload-img.js";
|
|
33
|
+
import { fade } from "svelte/transition";
|
|
33
34
|
|
|
34
35
|
export type AssetPreviewUrlObj = {
|
|
35
36
|
// o
|
|
@@ -59,7 +60,13 @@
|
|
|
59
60
|
/** Optional translate function */
|
|
60
61
|
t?: TranslateFn;
|
|
61
62
|
/** Optional delete handler - receives the current asset and its index */
|
|
62
|
-
onDelete?: (
|
|
63
|
+
onDelete?: (
|
|
64
|
+
asset: AssetPreview,
|
|
65
|
+
index: number,
|
|
66
|
+
controls: {
|
|
67
|
+
close: () => void;
|
|
68
|
+
}
|
|
69
|
+
) => void;
|
|
63
70
|
}
|
|
64
71
|
|
|
65
72
|
export function getAssetIcon(ext?: string) {
|
|
@@ -163,6 +170,7 @@
|
|
|
163
170
|
);
|
|
164
171
|
let previewIdx = $state<number>(0);
|
|
165
172
|
let modal: Modal | undefined = $state();
|
|
173
|
+
let dotTooltip: string | undefined = $state();
|
|
166
174
|
|
|
167
175
|
// Zoom state
|
|
168
176
|
const ZOOM_LEVELS = [1, 1.5, 2, 3, 4] as const;
|
|
@@ -187,6 +195,9 @@
|
|
|
187
195
|
$effect(() => {
|
|
188
196
|
const visible = modal?.visibility().visible;
|
|
189
197
|
if (visible) {
|
|
198
|
+
// Reset preview index on modal open
|
|
199
|
+
previewIdx = 0;
|
|
200
|
+
|
|
190
201
|
// perhaps we should have some upper limit here...
|
|
191
202
|
const toPreload = (assets ?? [])
|
|
192
203
|
.map((asset) => (asset.isImage ? String(asset.url.full) : ""))
|
|
@@ -341,6 +352,10 @@
|
|
|
341
352
|
resetZoom();
|
|
342
353
|
}
|
|
343
354
|
|
|
355
|
+
function preview(idx: number) {
|
|
356
|
+
previewIdx = idx % assets.length;
|
|
357
|
+
}
|
|
358
|
+
|
|
344
359
|
// $inspect(assets).with(clog);
|
|
345
360
|
</script>
|
|
346
361
|
|
|
@@ -454,7 +469,7 @@
|
|
|
454
469
|
<button
|
|
455
470
|
class={twMerge(TOP_BUTTON_CLS, classControls)}
|
|
456
471
|
type="button"
|
|
457
|
-
onclick={() => onDelete(previewAsset, previewIdx)}
|
|
472
|
+
onclick={() => onDelete(previewAsset, previewIdx, { close })}
|
|
458
473
|
aria-label={t("delete")}
|
|
459
474
|
use:tooltip
|
|
460
475
|
>
|
|
@@ -493,8 +508,19 @@
|
|
|
493
508
|
{/if}
|
|
494
509
|
|
|
495
510
|
{#if assets.length > 1}
|
|
511
|
+
{#if dotTooltip}
|
|
512
|
+
<div
|
|
513
|
+
class="absolute bottom-10 left-0 right-0 text-center"
|
|
514
|
+
transition:fade={{ duration: 100 }}
|
|
515
|
+
>
|
|
516
|
+
<span class="bg-white p-1 rounded opacity/75">
|
|
517
|
+
{dotTooltip}
|
|
518
|
+
</span>
|
|
519
|
+
</div>
|
|
520
|
+
{/if}
|
|
496
521
|
<div class="absolute bottom-4 left-1/2 -translate-x-1/2 flex items-center gap-3">
|
|
497
522
|
{#each assets as _, i}
|
|
523
|
+
<!-- svelte-ignore a11y_mouse_events_have_key_events -->
|
|
498
524
|
<button
|
|
499
525
|
type="button"
|
|
500
526
|
class={twMerge(
|
|
@@ -505,7 +531,13 @@
|
|
|
505
531
|
previewIdx = i;
|
|
506
532
|
resetZoom();
|
|
507
533
|
}}
|
|
508
|
-
aria-label={
|
|
534
|
+
aria-label={assets[i]?.name}
|
|
535
|
+
onmouseover={() => {
|
|
536
|
+
dotTooltip = assets[i]?.name;
|
|
537
|
+
}}
|
|
538
|
+
onmouseout={() => {
|
|
539
|
+
dotTooltip = undefined;
|
|
540
|
+
}}
|
|
509
541
|
></button>
|
|
510
542
|
{/each}
|
|
511
543
|
</div>
|
|
@@ -15,7 +15,9 @@ export interface Props {
|
|
|
15
15
|
/** Optional translate function */
|
|
16
16
|
t?: TranslateFn;
|
|
17
17
|
/** Optional delete handler - receives the current asset and its index */
|
|
18
|
-
onDelete?: (asset: AssetPreview, index: number
|
|
18
|
+
onDelete?: (asset: AssetPreview, index: number, controls: {
|
|
19
|
+
close: () => void;
|
|
20
|
+
}) => void;
|
|
19
21
|
}
|
|
20
22
|
export declare function getAssetIcon(ext?: string): CallableFunction;
|
|
21
23
|
declare const AssetsPreview: import("svelte").Component<Props, {
|