@gradio/imageslider 0.6.0 → 0.7.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/CHANGELOG.md +14 -0
- package/Example.svelte +11 -4
- package/ImageSlider.test.ts +15 -0
- package/Index.svelte +16 -49
- package/dist/Example.svelte +11 -4
- package/dist/Example.svelte.d.ts +4 -18
- package/dist/Index.svelte +16 -49
- package/dist/shared/ClearImage.svelte +2 -3
- package/dist/shared/ClearImage.svelte.d.ts +5 -19
- package/dist/shared/Image.svelte +67 -45
- package/dist/shared/Image.svelte.d.ts +14 -40
- package/dist/shared/ImageEl.svelte +22 -23
- package/dist/shared/ImageEl.svelte.d.ts +7 -22
- package/dist/shared/Slider.svelte +34 -19
- package/dist/shared/Slider.svelte.d.ts +8 -29
- package/dist/shared/SliderPreview.svelte +79 -50
- package/dist/shared/SliderPreview.svelte.d.ts +8 -23
- package/dist/shared/SliderUpload.svelte +43 -20
- package/dist/shared/SliderUpload.svelte.d.ts +11 -49
- package/package.json +6 -6
- package/shared/ClearImage.svelte +2 -3
- package/shared/Image.svelte +67 -45
- package/shared/ImageEl.svelte +22 -23
- package/shared/Slider.svelte +34 -19
- package/shared/SliderPreview.svelte +79 -50
- package/shared/SliderUpload.svelte +43 -20
|
@@ -1,36 +1,35 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { HTMLImgAttributes } from "svelte/elements";
|
|
3
|
-
import {
|
|
4
|
-
interface Props extends HTMLImgAttributes {
|
|
3
|
+
import { onMount, tick } from "svelte";
|
|
4
|
+
interface Props extends Omit<HTMLImgAttributes, "onload"> {
|
|
5
5
|
"data-testid"?: string;
|
|
6
6
|
fixed?: boolean;
|
|
7
7
|
transform?: string;
|
|
8
|
-
img_el?: HTMLImageElement;
|
|
8
|
+
img_el?: HTMLImageElement | null;
|
|
9
9
|
hidden?: boolean;
|
|
10
10
|
variant?: "preview" | "upload";
|
|
11
11
|
max_height?: number;
|
|
12
12
|
fullscreen?: boolean;
|
|
13
|
-
|
|
14
|
-
type $$Props = Props;
|
|
15
|
-
|
|
16
|
-
export let src: HTMLImgAttributes["src"] = undefined;
|
|
17
|
-
export let fullscreen = false;
|
|
18
|
-
|
|
19
|
-
export let fixed = false;
|
|
20
|
-
export let transform = "translate(0px, 0px) scale(1)";
|
|
21
|
-
export let img_el: HTMLImageElement | null = null;
|
|
22
|
-
export let hidden = false;
|
|
23
|
-
export let variant = "upload";
|
|
24
|
-
export let max_height = 500;
|
|
25
|
-
|
|
26
|
-
const dispatch = createEventDispatcher<{
|
|
27
|
-
load: {
|
|
13
|
+
onload?: (size: {
|
|
28
14
|
top: number;
|
|
29
15
|
left: number;
|
|
30
16
|
width: number;
|
|
31
17
|
height: number;
|
|
32
|
-
};
|
|
33
|
-
}
|
|
18
|
+
}) => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let {
|
|
22
|
+
src = undefined,
|
|
23
|
+
fullscreen = false,
|
|
24
|
+
fixed = false,
|
|
25
|
+
transform = "translate(0px, 0px) scale(1)",
|
|
26
|
+
img_el = $bindable<HTMLImageElement | null>(),
|
|
27
|
+
hidden = false,
|
|
28
|
+
variant = "upload",
|
|
29
|
+
max_height = 500,
|
|
30
|
+
onload,
|
|
31
|
+
...restProps
|
|
32
|
+
}: Props = $props();
|
|
34
33
|
|
|
35
34
|
function get_image_size(img: HTMLImageElement | null): {
|
|
36
35
|
top: number;
|
|
@@ -70,7 +69,7 @@
|
|
|
70
69
|
const resizer = new ResizeObserver(async (entries) => {
|
|
71
70
|
for (const entry of entries) {
|
|
72
71
|
await tick();
|
|
73
|
-
|
|
72
|
+
onload?.(get_image_size(img_el));
|
|
74
73
|
}
|
|
75
74
|
});
|
|
76
75
|
|
|
@@ -86,7 +85,7 @@
|
|
|
86
85
|
<img
|
|
87
86
|
{src}
|
|
88
87
|
data-testid="imageslider-image"
|
|
89
|
-
{
|
|
88
|
+
{...restProps}
|
|
90
89
|
class:fixed
|
|
91
90
|
style:transform
|
|
92
91
|
bind:this={img_el}
|
|
@@ -96,7 +95,7 @@
|
|
|
96
95
|
style:max-height={max_height && !fullscreen ? `${max_height}px` : null}
|
|
97
96
|
class:fullscreen
|
|
98
97
|
class:small={!fullscreen}
|
|
99
|
-
|
|
98
|
+
onload={() => onload?.(get_image_size(img_el))}
|
|
100
99
|
/>
|
|
101
100
|
|
|
102
101
|
<style>
|
|
@@ -1,35 +1,20 @@
|
|
|
1
1
|
import type { HTMLImgAttributes } from "svelte/elements";
|
|
2
|
-
interface
|
|
3
|
-
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
-
$$bindings?: Bindings;
|
|
5
|
-
} & Exports;
|
|
6
|
-
(internal: unknown, props: Props & {
|
|
7
|
-
$$events?: Events;
|
|
8
|
-
$$slots?: Slots;
|
|
9
|
-
}): Exports & {
|
|
10
|
-
$set?: any;
|
|
11
|
-
$on?: any;
|
|
12
|
-
};
|
|
13
|
-
z_$$bindings?: Bindings;
|
|
14
|
-
}
|
|
15
|
-
declare const ImageEl: $$__sveltets_2_IsomorphicComponent<HTMLImgAttributes & {
|
|
2
|
+
interface Props extends Omit<HTMLImgAttributes, "onload"> {
|
|
16
3
|
"data-testid"?: string;
|
|
17
4
|
fixed?: boolean;
|
|
18
5
|
transform?: string;
|
|
19
|
-
img_el?: HTMLImageElement;
|
|
6
|
+
img_el?: HTMLImageElement | null;
|
|
20
7
|
hidden?: boolean;
|
|
21
8
|
variant?: "preview" | "upload";
|
|
22
9
|
max_height?: number;
|
|
23
10
|
fullscreen?: boolean;
|
|
24
|
-
|
|
25
|
-
load: CustomEvent<{
|
|
11
|
+
onload?: (size: {
|
|
26
12
|
top: number;
|
|
27
13
|
left: number;
|
|
28
14
|
width: number;
|
|
29
15
|
height: number;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
type ImageEl = InstanceType<typeof ImageEl>;
|
|
16
|
+
}) => void;
|
|
17
|
+
}
|
|
18
|
+
declare const ImageEl: import("svelte").Component<Props, {}, "img_el">;
|
|
19
|
+
type ImageEl = ReturnType<typeof ImageEl>;
|
|
35
20
|
export default ImageEl;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { onMount } from "svelte";
|
|
2
|
+
import { onMount, type Snippet } from "svelte";
|
|
3
3
|
import { drag } from "d3-drag";
|
|
4
4
|
import { select } from "d3-selection";
|
|
5
5
|
|
|
@@ -7,22 +7,33 @@
|
|
|
7
7
|
return Math.min(Math.max(value, min), max);
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
let {
|
|
11
|
+
position = $bindable(0.5),
|
|
12
|
+
disabled = false,
|
|
13
|
+
slider_color = "var(--border-color-primary)",
|
|
14
|
+
image_size = { top: 0, left: 0, width: 0, height: 0 },
|
|
15
|
+
el = $bindable<HTMLDivElement | undefined>(undefined),
|
|
16
|
+
parent_el = $bindable<HTMLDivElement | undefined>(undefined),
|
|
17
|
+
children
|
|
18
|
+
}: {
|
|
19
|
+
position?: number;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
slider_color?: string;
|
|
22
|
+
image_size?: {
|
|
23
|
+
top: number;
|
|
24
|
+
left: number;
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
};
|
|
28
|
+
el?: HTMLDivElement;
|
|
29
|
+
parent_el?: HTMLDivElement;
|
|
30
|
+
children?: Snippet;
|
|
31
|
+
} = $props();
|
|
12
32
|
|
|
13
|
-
export let slider_color = "var(--border-color-primary)";
|
|
14
|
-
export let image_size: {
|
|
15
|
-
top: number;
|
|
16
|
-
left: number;
|
|
17
|
-
width: number;
|
|
18
|
-
height: number;
|
|
19
|
-
} = { top: 0, left: 0, width: 0, height: 0 };
|
|
20
|
-
export let el: HTMLDivElement | undefined = undefined;
|
|
21
|
-
export let parent_el: HTMLDivElement | undefined = undefined;
|
|
22
33
|
let inner: Element;
|
|
23
|
-
let px = 0;
|
|
24
|
-
let active = false;
|
|
25
|
-
let container_width = 0;
|
|
34
|
+
let px = $state(0);
|
|
35
|
+
let active = $state(false);
|
|
36
|
+
let container_width = $state(0);
|
|
26
37
|
|
|
27
38
|
function set_position(width: number): void {
|
|
28
39
|
container_width = parent_el?.getBoundingClientRect().width || 0;
|
|
@@ -67,8 +78,12 @@
|
|
|
67
78
|
px = clamp(image_size.width * pc + image_size.left, 0, container_width);
|
|
68
79
|
}
|
|
69
80
|
|
|
70
|
-
|
|
71
|
-
|
|
81
|
+
$effect(() => {
|
|
82
|
+
set_position(image_size.width);
|
|
83
|
+
});
|
|
84
|
+
$effect(() => {
|
|
85
|
+
update_position_from_pc(position);
|
|
86
|
+
});
|
|
72
87
|
|
|
73
88
|
onMount(() => {
|
|
74
89
|
set_position(image_size.width);
|
|
@@ -80,11 +95,11 @@
|
|
|
80
95
|
});
|
|
81
96
|
</script>
|
|
82
97
|
|
|
83
|
-
<svelte:window
|
|
98
|
+
<svelte:window onresize={() => set_position(image_size.width)} />
|
|
84
99
|
|
|
85
100
|
<div class="wrap" role="none" bind:this={parent_el}>
|
|
86
101
|
<div class="content" bind:this={el}>
|
|
87
|
-
|
|
102
|
+
{#if children}{@render children()}{/if}
|
|
88
103
|
</div>
|
|
89
104
|
<div
|
|
90
105
|
class="outer"
|
|
@@ -1,22 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
$$bindings?: Bindings;
|
|
4
|
-
} & Exports;
|
|
5
|
-
(internal: unknown, props: Props & {
|
|
6
|
-
$$events?: Events;
|
|
7
|
-
$$slots?: Slots;
|
|
8
|
-
}): Exports & {
|
|
9
|
-
$set?: any;
|
|
10
|
-
$on?: any;
|
|
11
|
-
};
|
|
12
|
-
z_$$bindings?: Bindings;
|
|
13
|
-
}
|
|
14
|
-
type $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {
|
|
15
|
-
default: any;
|
|
16
|
-
} ? Props extends Record<string, never> ? any : {
|
|
17
|
-
children?: any;
|
|
18
|
-
} : {});
|
|
19
|
-
declare const Slider: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{
|
|
1
|
+
import { type Snippet } from "svelte";
|
|
2
|
+
type $$ComponentProps = {
|
|
20
3
|
position?: number;
|
|
21
4
|
disabled?: boolean;
|
|
22
5
|
slider_color?: string;
|
|
@@ -26,14 +9,10 @@ declare const Slider: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWit
|
|
|
26
9
|
width: number;
|
|
27
10
|
height: number;
|
|
28
11
|
};
|
|
29
|
-
el?: HTMLDivElement
|
|
30
|
-
parent_el?: HTMLDivElement
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
}, {
|
|
36
|
-
default: {};
|
|
37
|
-
}, {}, string>;
|
|
38
|
-
type Slider = InstanceType<typeof Slider>;
|
|
12
|
+
el?: HTMLDivElement;
|
|
13
|
+
parent_el?: HTMLDivElement;
|
|
14
|
+
children?: Snippet;
|
|
15
|
+
};
|
|
16
|
+
declare const Slider: import("svelte").Component<$$ComponentProps, {}, "position" | "el" | "parent_el">;
|
|
17
|
+
type Slider = ReturnType<typeof Slider>;
|
|
39
18
|
export default Slider;
|
|
@@ -16,31 +16,49 @@
|
|
|
16
16
|
import { ZoomableImage } from "./zoom";
|
|
17
17
|
import { onMount } from "svelte";
|
|
18
18
|
import { tweened, type Tweened } from "svelte/motion";
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
19
|
+
|
|
20
|
+
let {
|
|
21
|
+
value = $bindable<[null | FileData, null | FileData]>([null, null]),
|
|
22
|
+
label = undefined,
|
|
23
|
+
show_download_button = true,
|
|
24
|
+
show_label,
|
|
25
|
+
i18n,
|
|
26
|
+
position = $bindable(0.5),
|
|
27
|
+
layer_images = true,
|
|
28
|
+
show_single = false,
|
|
29
|
+
slider_color,
|
|
30
|
+
show_fullscreen_button = true,
|
|
31
|
+
fullscreen = $bindable(false),
|
|
32
|
+
buttons = null,
|
|
33
|
+
on_custom_button_click = null,
|
|
34
|
+
el_width = $bindable(0),
|
|
35
|
+
max_height,
|
|
36
|
+
interactive = true,
|
|
37
|
+
onclear,
|
|
38
|
+
onfullscreen
|
|
39
|
+
}: {
|
|
40
|
+
value?: [null | FileData, null | FileData];
|
|
41
|
+
label?: string;
|
|
42
|
+
show_download_button?: boolean;
|
|
43
|
+
show_label: boolean;
|
|
44
|
+
i18n: I18nFormatter;
|
|
45
|
+
position?: number;
|
|
46
|
+
layer_images?: boolean;
|
|
47
|
+
show_single?: boolean;
|
|
48
|
+
slider_color: string;
|
|
49
|
+
show_fullscreen_button?: boolean;
|
|
50
|
+
fullscreen?: boolean;
|
|
51
|
+
buttons?: (string | CustomButtonType)[] | null;
|
|
52
|
+
on_custom_button_click?: ((id: number) => void) | null;
|
|
53
|
+
el_width?: number;
|
|
54
|
+
max_height: number;
|
|
55
|
+
interactive?: boolean;
|
|
56
|
+
onclear?: () => void;
|
|
57
|
+
onfullscreen?: (fullscreen: boolean) => void;
|
|
58
|
+
} = $props();
|
|
59
|
+
|
|
60
|
+
let img = $state<HTMLImageElement>();
|
|
61
|
+
let slider_wrap = $state<HTMLDivElement>();
|
|
44
62
|
let image_container: HTMLDivElement;
|
|
45
63
|
|
|
46
64
|
let transform: Tweened<{ x: number; y: number; z: number }> = tweened(
|
|
@@ -50,18 +68,28 @@
|
|
|
50
68
|
}
|
|
51
69
|
);
|
|
52
70
|
let parent_el: HTMLDivElement;
|
|
71
|
+
let img_width = $state(0);
|
|
72
|
+
let viewport_width = $state(0);
|
|
73
|
+
let image_size = $state<{
|
|
74
|
+
top: number;
|
|
75
|
+
left: number;
|
|
76
|
+
width: number;
|
|
77
|
+
height: number;
|
|
78
|
+
}>({ top: 0, left: 0, width: 0, height: 0 });
|
|
53
79
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
80
|
+
let coords_at_viewport = $derived(
|
|
81
|
+
get_coords_at_viewport(
|
|
82
|
+
position,
|
|
83
|
+
viewport_width,
|
|
84
|
+
image_size.width,
|
|
85
|
+
image_size.left,
|
|
86
|
+
$transform.x,
|
|
87
|
+
$transform.z
|
|
88
|
+
)
|
|
89
|
+
);
|
|
90
|
+
let style = $derived(
|
|
91
|
+
layer_images ? `clip-path: inset(0 0 0 ${coords_at_viewport * 100}%)` : ""
|
|
61
92
|
);
|
|
62
|
-
$: style = layer_images
|
|
63
|
-
? `clip-path: inset(0 0 0 ${coords_at_viewport * 100}%)`
|
|
64
|
-
: "";
|
|
65
93
|
|
|
66
94
|
function get_coords_at_viewport(
|
|
67
95
|
viewport_percent_x: number, // 0-1
|
|
@@ -80,15 +108,12 @@
|
|
|
80
108
|
return percent_position;
|
|
81
109
|
}
|
|
82
110
|
|
|
83
|
-
let img_width = 0;
|
|
84
|
-
let viewport_width = 0;
|
|
85
|
-
|
|
86
111
|
let zoomable_image: ZoomableImage | null = null;
|
|
87
112
|
let observer: ResizeObserver | null = null;
|
|
88
113
|
|
|
89
114
|
function init_image(
|
|
90
|
-
img: HTMLImageElement,
|
|
91
|
-
slider_wrap: HTMLDivElement
|
|
115
|
+
img: HTMLImageElement | undefined,
|
|
116
|
+
slider_wrap: HTMLDivElement | undefined
|
|
92
117
|
): void {
|
|
93
118
|
if (!img || !slider_wrap) return;
|
|
94
119
|
zoomable_image?.destroy();
|
|
@@ -115,7 +140,9 @@
|
|
|
115
140
|
observer.observe(img);
|
|
116
141
|
}
|
|
117
142
|
|
|
118
|
-
|
|
143
|
+
$effect(() => {
|
|
144
|
+
init_image(img, slider_wrap);
|
|
145
|
+
});
|
|
119
146
|
|
|
120
147
|
onMount(() => {
|
|
121
148
|
return () => {
|
|
@@ -126,11 +153,13 @@
|
|
|
126
153
|
|
|
127
154
|
let slider_wrap_parent: HTMLDivElement;
|
|
128
155
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
156
|
+
function handle_image_load(size: {
|
|
157
|
+
top: number;
|
|
158
|
+
left: number;
|
|
159
|
+
width: number;
|
|
160
|
+
height: number;
|
|
161
|
+
}): void {
|
|
162
|
+
image_size = size;
|
|
134
163
|
}
|
|
135
164
|
</script>
|
|
136
165
|
|
|
@@ -151,7 +180,7 @@
|
|
|
151
180
|
{fullscreen}
|
|
152
181
|
onclick={(is_fullscreen) => {
|
|
153
182
|
fullscreen = is_fullscreen;
|
|
154
|
-
|
|
183
|
+
onfullscreen?.(is_fullscreen);
|
|
155
184
|
}}
|
|
156
185
|
/>
|
|
157
186
|
{/if}
|
|
@@ -170,7 +199,7 @@
|
|
|
170
199
|
label="Remove Image"
|
|
171
200
|
onclick={(event) => {
|
|
172
201
|
value = [null, null];
|
|
173
|
-
|
|
202
|
+
onclear?.();
|
|
174
203
|
event.stopPropagation();
|
|
175
204
|
}}
|
|
176
205
|
/>
|
|
@@ -198,7 +227,7 @@
|
|
|
198
227
|
transform="translate({$transform.x}px, {$transform.y}px) scale({$transform.z})"
|
|
199
228
|
{fullscreen}
|
|
200
229
|
{max_height}
|
|
201
|
-
|
|
230
|
+
onload={handle_image_load}
|
|
202
231
|
/>
|
|
203
232
|
<ImageEl
|
|
204
233
|
variant="preview"
|
|
@@ -211,7 +240,7 @@
|
|
|
211
240
|
transform="translate({$transform.x}px, {$transform.y}px) scale({$transform.z})"
|
|
212
241
|
{fullscreen}
|
|
213
242
|
{max_height}
|
|
214
|
-
|
|
243
|
+
onload={handle_image_load}
|
|
215
244
|
/>
|
|
216
245
|
</Slider>
|
|
217
246
|
</div>
|
|
@@ -1,26 +1,13 @@
|
|
|
1
1
|
import type { CustomButton as CustomButtonType } from "@gradio/utils";
|
|
2
2
|
import { type FileData } from "@gradio/client";
|
|
3
3
|
import type { I18nFormatter } from "@gradio/utils";
|
|
4
|
-
|
|
5
|
-
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
6
|
-
$$bindings?: Bindings;
|
|
7
|
-
} & Exports;
|
|
8
|
-
(internal: unknown, props: Props & {
|
|
9
|
-
$$events?: Events;
|
|
10
|
-
$$slots?: Slots;
|
|
11
|
-
}): Exports & {
|
|
12
|
-
$set?: any;
|
|
13
|
-
$on?: any;
|
|
14
|
-
};
|
|
15
|
-
z_$$bindings?: Bindings;
|
|
16
|
-
}
|
|
17
|
-
declare const SliderPreview: $$__sveltets_2_IsomorphicComponent<{
|
|
4
|
+
type $$ComponentProps = {
|
|
18
5
|
value?: [null | FileData, null | FileData];
|
|
19
|
-
label?: string
|
|
6
|
+
label?: string;
|
|
20
7
|
show_download_button?: boolean;
|
|
21
8
|
show_label: boolean;
|
|
22
9
|
i18n: I18nFormatter;
|
|
23
|
-
position
|
|
10
|
+
position?: number;
|
|
24
11
|
layer_images?: boolean;
|
|
25
12
|
show_single?: boolean;
|
|
26
13
|
slider_color: string;
|
|
@@ -31,11 +18,9 @@ declare const SliderPreview: $$__sveltets_2_IsomorphicComponent<{
|
|
|
31
18
|
el_width?: number;
|
|
32
19
|
max_height: number;
|
|
33
20
|
interactive?: boolean;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
}, {}, {}, string>;
|
|
40
|
-
type SliderPreview = InstanceType<typeof SliderPreview>;
|
|
21
|
+
onclear?: () => void;
|
|
22
|
+
onfullscreen?: (fullscreen: boolean) => void;
|
|
23
|
+
};
|
|
24
|
+
declare const SliderPreview: import("svelte").Component<$$ComponentProps, {}, "value" | "position" | "fullscreen" | "el_width">;
|
|
25
|
+
type SliderPreview = ReturnType<typeof SliderPreview>;
|
|
41
26
|
export default SliderPreview;
|
|
@@ -1,24 +1,48 @@
|
|
|
1
1
|
<svelte:options accessors={true} />
|
|
2
2
|
|
|
3
3
|
<script lang="ts">
|
|
4
|
+
import type { Snippet } from "svelte";
|
|
4
5
|
import type { I18nFormatter } from "@gradio/utils";
|
|
5
6
|
import Image from "./Image.svelte";
|
|
6
7
|
import { type Client } from "@gradio/client";
|
|
7
8
|
|
|
8
9
|
import type { FileData } from "@gradio/client";
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
let {
|
|
12
|
+
value = $bindable<[FileData | null, FileData | null]>([null, null]),
|
|
13
|
+
upload,
|
|
14
|
+
stream_handler,
|
|
15
|
+
label,
|
|
16
|
+
show_label,
|
|
17
|
+
i18n,
|
|
18
|
+
root,
|
|
19
|
+
upload_count = 1,
|
|
20
|
+
dragging = $bindable(false),
|
|
21
|
+
max_height,
|
|
22
|
+
max_file_size = null,
|
|
23
|
+
upload_promise = $bindable(),
|
|
24
|
+
onclear,
|
|
25
|
+
ondrag,
|
|
26
|
+
onupload,
|
|
27
|
+
children
|
|
28
|
+
}: {
|
|
29
|
+
value?: [FileData | null, FileData | null];
|
|
30
|
+
upload: Client["upload"];
|
|
31
|
+
stream_handler: Client["stream"];
|
|
32
|
+
label: string;
|
|
33
|
+
show_label: boolean;
|
|
34
|
+
i18n: I18nFormatter;
|
|
35
|
+
root: string;
|
|
36
|
+
upload_count?: number;
|
|
37
|
+
dragging?: boolean;
|
|
38
|
+
max_height: number;
|
|
39
|
+
max_file_size?: number | null;
|
|
40
|
+
upload_promise?: Promise<any>;
|
|
41
|
+
onclear?: () => void;
|
|
42
|
+
ondrag?: (dragging: boolean) => void;
|
|
43
|
+
onupload?: (value: [FileData | null, FileData | null]) => void;
|
|
44
|
+
children?: Snippet;
|
|
45
|
+
} = $props();
|
|
22
46
|
</script>
|
|
23
47
|
|
|
24
48
|
<Image
|
|
@@ -28,13 +52,12 @@
|
|
|
28
52
|
bind:value
|
|
29
53
|
bind:dragging
|
|
30
54
|
{root}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
on:share
|
|
55
|
+
{onclear}
|
|
56
|
+
ondrag={(detail) => {
|
|
57
|
+
dragging = detail;
|
|
58
|
+
ondrag?.(detail);
|
|
59
|
+
}}
|
|
60
|
+
{onupload}
|
|
38
61
|
{label}
|
|
39
62
|
{show_label}
|
|
40
63
|
{upload_count}
|
|
@@ -44,5 +67,5 @@
|
|
|
44
67
|
{max_height}
|
|
45
68
|
{i18n}
|
|
46
69
|
>
|
|
47
|
-
|
|
70
|
+
{#if children}{@render children()}{/if}
|
|
48
71
|
</Image>
|
|
@@ -1,25 +1,8 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
1
2
|
import type { I18nFormatter } from "@gradio/utils";
|
|
2
3
|
import { type Client } from "@gradio/client";
|
|
3
4
|
import type { FileData } from "@gradio/client";
|
|
4
|
-
|
|
5
|
-
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
6
|
-
$$bindings?: Bindings;
|
|
7
|
-
} & Exports;
|
|
8
|
-
(internal: unknown, props: Props & {
|
|
9
|
-
$$events?: Events;
|
|
10
|
-
$$slots?: Slots;
|
|
11
|
-
}): Exports & {
|
|
12
|
-
$set?: any;
|
|
13
|
-
$on?: any;
|
|
14
|
-
};
|
|
15
|
-
z_$$bindings?: Bindings;
|
|
16
|
-
}
|
|
17
|
-
type $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {
|
|
18
|
-
default: any;
|
|
19
|
-
} ? Props extends Record<string, never> ? any : {
|
|
20
|
-
children?: any;
|
|
21
|
-
} : {});
|
|
22
|
-
declare const SliderUpload: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{
|
|
5
|
+
type $$ComponentProps = {
|
|
23
6
|
value?: [FileData | null, FileData | null];
|
|
24
7
|
upload: Client["upload"];
|
|
25
8
|
stream_handler: Client["stream"];
|
|
@@ -28,36 +11,15 @@ declare const SliderUpload: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_Pr
|
|
|
28
11
|
i18n: I18nFormatter;
|
|
29
12
|
root: string;
|
|
30
13
|
upload_count?: number;
|
|
31
|
-
dragging
|
|
14
|
+
dragging?: boolean;
|
|
32
15
|
max_height: number;
|
|
33
16
|
max_file_size?: number | null;
|
|
34
|
-
upload_promise?: Promise<any
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
select: CustomEvent<import("@gradio/utils").SelectData>;
|
|
43
|
-
share: CustomEvent<any>;
|
|
44
|
-
} & {
|
|
45
|
-
[evt: string]: CustomEvent<any>;
|
|
46
|
-
}, {
|
|
47
|
-
default: {};
|
|
48
|
-
}, {
|
|
49
|
-
value: [FileData | null, FileData | null];
|
|
50
|
-
upload: Client["upload"];
|
|
51
|
-
stream_handler: Client["stream"];
|
|
52
|
-
label: string;
|
|
53
|
-
show_label: boolean;
|
|
54
|
-
i18n: I18nFormatter;
|
|
55
|
-
root: string;
|
|
56
|
-
upload_count: number;
|
|
57
|
-
dragging: boolean;
|
|
58
|
-
max_height: number;
|
|
59
|
-
max_file_size: number | null;
|
|
60
|
-
upload_promise: Promise<any> | null;
|
|
61
|
-
}, string>;
|
|
62
|
-
type SliderUpload = InstanceType<typeof SliderUpload>;
|
|
17
|
+
upload_promise?: Promise<any>;
|
|
18
|
+
onclear?: () => void;
|
|
19
|
+
ondrag?: (dragging: boolean) => void;
|
|
20
|
+
onupload?: (value: [FileData | null, FileData | null]) => void;
|
|
21
|
+
children?: Snippet;
|
|
22
|
+
};
|
|
23
|
+
declare const SliderUpload: import("svelte").Component<$$ComponentProps, {}, "value" | "dragging" | "upload_promise">;
|
|
24
|
+
type SliderUpload = ReturnType<typeof SliderUpload>;
|
|
63
25
|
export default SliderUpload;
|