@classic-homes/theme-svelte 1.26.0 → 1.27.1
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.
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
import MediaEmbed from './MediaEmbed.svelte';
|
|
33
33
|
import Video from './Video.svelte';
|
|
34
34
|
import MediaTile from './internal/MediaTile.svelte';
|
|
35
|
+
import TriggerChild, { type TriggerSnippetProps } from '../internal/TriggerChild.svelte';
|
|
35
36
|
|
|
36
37
|
/** Horizontal distance that counts as a swipe rather than a tap */
|
|
37
38
|
const SWIPE_THRESHOLD = 60;
|
|
@@ -59,8 +60,14 @@
|
|
|
59
60
|
zoomable?: boolean;
|
|
60
61
|
/** Show a download link for items that expose a URL */
|
|
61
62
|
downloadable?: boolean;
|
|
62
|
-
/**
|
|
63
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Optional trigger element; omit when controlling `open` yourself. It
|
|
65
|
+
* receives `{ props }`: spread them on your own button
|
|
66
|
+
* (`{#snippet trigger({ props })}<Button {...props}>Open</Button>{/snippet}`)
|
|
67
|
+
* so that button is the trigger and gets focus back on close. A snippet
|
|
68
|
+
* that ignores them still works, wrapped in a span trigger as before.
|
|
69
|
+
*/
|
|
70
|
+
trigger?: Snippet<[TriggerSnippetProps]>;
|
|
64
71
|
/** Additional classes for the dialog surface */
|
|
65
72
|
class?: string;
|
|
66
73
|
}
|
|
@@ -81,6 +88,10 @@
|
|
|
81
88
|
class: className,
|
|
82
89
|
}: Props = $props();
|
|
83
90
|
|
|
91
|
+
const uid = $props.id();
|
|
92
|
+
// Changes once if the trigger snippet ignores its props (see TriggerChild)
|
|
93
|
+
let triggerId = $state(`${uid}-trigger`);
|
|
94
|
+
|
|
84
95
|
let swipeStartX = 0;
|
|
85
96
|
let swipeStartY = 0;
|
|
86
97
|
let swipeActive = false;
|
|
@@ -265,11 +276,9 @@
|
|
|
265
276
|
|
|
266
277
|
<DialogPrimitive.Root bind:open onOpenChange={handleOpenChange}>
|
|
267
278
|
{#if trigger}
|
|
268
|
-
<DialogPrimitive.Trigger>
|
|
279
|
+
<DialogPrimitive.Trigger id={triggerId}>
|
|
269
280
|
{#snippet child({ props })}
|
|
270
|
-
<
|
|
271
|
-
{@render trigger()}
|
|
272
|
-
</span>
|
|
281
|
+
<TriggerChild {props} {trigger} onfallback={() => (triggerId = `${uid}-trigger-wrap`)} />
|
|
273
282
|
{/snippet}
|
|
274
283
|
</DialogPrimitive.Trigger>
|
|
275
284
|
{/if}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Snippet } from 'svelte';
|
|
2
2
|
import type { MediaItem } from '../../types/components.js';
|
|
3
|
+
import { type TriggerSnippetProps } from '../internal/TriggerChild.svelte';
|
|
3
4
|
interface Props {
|
|
4
5
|
/** Items to page through */
|
|
5
6
|
items: MediaItem[];
|
|
@@ -23,8 +24,14 @@ interface Props {
|
|
|
23
24
|
zoomable?: boolean;
|
|
24
25
|
/** Show a download link for items that expose a URL */
|
|
25
26
|
downloadable?: boolean;
|
|
26
|
-
/**
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Optional trigger element; omit when controlling `open` yourself. It
|
|
29
|
+
* receives `{ props }`: spread them on your own button
|
|
30
|
+
* (`{#snippet trigger({ props })}<Button {...props}>Open</Button>{/snippet}`)
|
|
31
|
+
* so that button is the trigger and gets focus back on close. A snippet
|
|
32
|
+
* that ignores them still works, wrapped in a span trigger as before.
|
|
33
|
+
*/
|
|
34
|
+
trigger?: Snippet<[TriggerSnippetProps]>;
|
|
28
35
|
/** Additional classes for the dialog surface */
|
|
29
36
|
class?: string;
|
|
30
37
|
}
|