@gradio/gallery 0.15.35-dev.0 → 0.15.35-dev.3
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 +35 -0
- package/Gallery.stories.svelte +25 -0
- package/Index.svelte +78 -91
- package/dist/Example.svelte +6 -3
- package/dist/Example.svelte.d.ts +20 -18
- package/dist/Index.svelte +122 -103
- package/dist/Index.svelte.d.ts +3 -59
- package/dist/shared/Gallery.svelte +338 -240
- package/dist/shared/Gallery.svelte.d.ts +57 -52
- package/dist/types.d.ts +30 -1
- package/package.json +13 -13
- package/shared/Gallery.svelte +29 -14
- package/types.ts +30 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# @gradio/gallery
|
|
2
2
|
|
|
3
|
+
## 0.15.35-dev.3
|
|
4
|
+
|
|
5
|
+
### Dependency updates
|
|
6
|
+
|
|
7
|
+
- @gradio/atoms@0.19.0-dev.1
|
|
8
|
+
- @gradio/client@2.0.0-dev.2
|
|
9
|
+
- @gradio/statustracker@0.12.0-dev.1
|
|
10
|
+
- @gradio/upload@0.17.2-dev.2
|
|
11
|
+
- @gradio/image@0.24.0-dev.2
|
|
12
|
+
- @gradio/video@0.17.0-dev.2
|
|
13
|
+
- @gradio/file@0.13.1-dev.2
|
|
14
|
+
|
|
15
|
+
## 0.15.35-dev.2
|
|
16
|
+
|
|
17
|
+
### Dependency updates
|
|
18
|
+
|
|
19
|
+
- @gradio/atoms@0.18.2-dev.0
|
|
20
|
+
- @gradio/upload@0.17.2-dev.1
|
|
21
|
+
- @gradio/utils@0.10.3-dev.0
|
|
22
|
+
- @gradio/image@0.23.2-dev.1
|
|
23
|
+
- @gradio/statustracker@0.12.0-dev.0
|
|
24
|
+
- @gradio/icons@0.15.0-dev.0
|
|
25
|
+
- @gradio/video@0.17.0-dev.1
|
|
26
|
+
- @gradio/file@0.13.1-dev.1
|
|
27
|
+
|
|
28
|
+
## 0.15.35-dev.1
|
|
29
|
+
|
|
30
|
+
### Fixes
|
|
31
|
+
|
|
32
|
+
- [#12066](https://github.com/gradio-app/gradio/pull/12066) [`6a4757a`](https://github.com/gradio-app/gradio/commit/6a4757ab289e8e53b5503eb6887333d7ad26c9eb) - Gallery: Allow empty columns when items < columns. Thanks @missionfloyd!
|
|
33
|
+
|
|
34
|
+
### Dependency updates
|
|
35
|
+
|
|
36
|
+
- @gradio/client@2.0.0-dev.1
|
|
37
|
+
|
|
3
38
|
## 0.15.35-dev.0
|
|
4
39
|
|
|
5
40
|
### Dependency updates
|
package/Gallery.stories.svelte
CHANGED
|
@@ -62,6 +62,13 @@
|
|
|
62
62
|
description: "Whether to show the share button in the gallery",
|
|
63
63
|
control: { type: "boolean" },
|
|
64
64
|
defaultValue: false
|
|
65
|
+
},
|
|
66
|
+
fit_columns: {
|
|
67
|
+
options: [true, false],
|
|
68
|
+
description:
|
|
69
|
+
"Whether the columns should fit the width of the container",
|
|
70
|
+
control: { type: "boolean" },
|
|
71
|
+
defaultValue: true
|
|
65
72
|
}
|
|
66
73
|
},
|
|
67
74
|
parameters: {
|
|
@@ -277,3 +284,21 @@
|
|
|
277
284
|
show_download_button: true
|
|
278
285
|
}}
|
|
279
286
|
/>
|
|
287
|
+
<Story
|
|
288
|
+
name="Gallery with fit_columns false"
|
|
289
|
+
args={{
|
|
290
|
+
label: "My Cheetah Gallery",
|
|
291
|
+
columns: 10,
|
|
292
|
+
show_download_button: true,
|
|
293
|
+
fit_columns: false
|
|
294
|
+
}}
|
|
295
|
+
/>
|
|
296
|
+
<Story
|
|
297
|
+
name="Gallery with fit_columns true"
|
|
298
|
+
args={{
|
|
299
|
+
label: "My Cheetah Gallery",
|
|
300
|
+
columns: 10,
|
|
301
|
+
show_download_button: true,
|
|
302
|
+
fit_columns: true
|
|
303
|
+
}}
|
|
304
|
+
/>
|
package/Index.svelte
CHANGED
|
@@ -4,68 +4,47 @@
|
|
|
4
4
|
</script>
|
|
5
5
|
|
|
6
6
|
<script lang="ts">
|
|
7
|
-
import
|
|
7
|
+
import { tick } from "svelte";
|
|
8
8
|
import type { FileData } from "@gradio/client";
|
|
9
|
-
import type { Gradio, ShareData, SelectData } from "@gradio/utils";
|
|
10
9
|
import { Block, UploadText } from "@gradio/atoms";
|
|
11
10
|
import Gallery from "./shared/Gallery.svelte";
|
|
12
|
-
import type { LoadingStatus } from "@gradio/statustracker";
|
|
13
11
|
import { StatusTracker } from "@gradio/statustracker";
|
|
14
|
-
import {
|
|
12
|
+
import { Gradio } from "@gradio/utils";
|
|
15
13
|
import { BaseFileUpload } from "@gradio/file";
|
|
14
|
+
import type { GalleryProps, GalleryEvents, GalleryData } from "./types";
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
let upload_promise = $state<Promise<any>>();
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export let value: GalleryData[] | null = null;
|
|
27
|
-
export let file_types: string[] | null = ["image", "video"];
|
|
28
|
-
export let container = true;
|
|
29
|
-
export let scale: number | null = null;
|
|
30
|
-
export let min_width: number | undefined = undefined;
|
|
31
|
-
export let columns: number | number[] | undefined = [2];
|
|
32
|
-
export let rows: number | number[] | undefined = undefined;
|
|
33
|
-
export let height: number | "auto" = "auto";
|
|
34
|
-
export let preview: boolean;
|
|
35
|
-
export let allow_preview = true;
|
|
36
|
-
export let selected_index: number | null = null;
|
|
37
|
-
export let object_fit: "contain" | "cover" | "fill" | "none" | "scale-down" =
|
|
38
|
-
"cover";
|
|
39
|
-
export let buttons: string[] | null = null;
|
|
40
|
-
export let interactive: boolean;
|
|
41
|
-
export let gradio: Gradio<{
|
|
42
|
-
change: typeof value;
|
|
43
|
-
upload: typeof value;
|
|
44
|
-
select: SelectData;
|
|
45
|
-
share: ShareData;
|
|
46
|
-
error: string;
|
|
47
|
-
delete: { file: FileData; index: number };
|
|
48
|
-
prop_change: Record<string, any>;
|
|
49
|
-
clear_status: LoadingStatus;
|
|
50
|
-
preview_open: never;
|
|
51
|
-
preview_close: never;
|
|
52
|
-
}>;
|
|
53
|
-
export let fullscreen = false;
|
|
18
|
+
class GalleryGradio extends Gradio<GalleryEvents, GalleryProps> {
|
|
19
|
+
async get_data() {
|
|
20
|
+
if (upload_promise) {
|
|
21
|
+
await upload_promise;
|
|
22
|
+
await tick();
|
|
23
|
+
}
|
|
24
|
+
const data = await super.get_data();
|
|
54
25
|
|
|
55
|
-
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const props = $props();
|
|
31
|
+
const gradio = new GalleryGradio<GalleryEvents, GalleryProps>(props);
|
|
32
|
+
|
|
33
|
+
let fullscreen = $state(false);
|
|
56
34
|
|
|
57
|
-
|
|
35
|
+
let no_value = $derived(
|
|
36
|
+
gradio.props.value === null ? true : gradio.props.value.length === 0
|
|
37
|
+
);
|
|
58
38
|
|
|
59
39
|
function handle_delete(
|
|
60
40
|
event: CustomEvent<{ file: FileData; index: number }>
|
|
61
41
|
): void {
|
|
62
|
-
if (!value) return;
|
|
42
|
+
if (!gradio.props.value) return;
|
|
63
43
|
const { index } = event.detail;
|
|
64
44
|
gradio.dispatch("delete", event.detail);
|
|
65
|
-
value = value.filter((_, i) => i !== index);
|
|
66
|
-
gradio.dispatch("change", value);
|
|
45
|
+
gradio.props.value = gradio.props.value.filter((_, i) => i !== index);
|
|
46
|
+
gradio.dispatch("change", gradio.props.value);
|
|
67
47
|
}
|
|
68
|
-
$: selected_index, dispatch("prop_change", { selected_index });
|
|
69
48
|
|
|
70
49
|
async function process_upload_files(
|
|
71
50
|
files: FileData[]
|
|
@@ -93,44 +72,48 @@
|
|
|
93
72
|
</script>
|
|
94
73
|
|
|
95
74
|
<Block
|
|
96
|
-
{visible}
|
|
75
|
+
visible={gradio.shared.visible}
|
|
97
76
|
variant="solid"
|
|
98
77
|
padding={false}
|
|
99
|
-
{elem_id}
|
|
100
|
-
{elem_classes}
|
|
101
|
-
{container}
|
|
102
|
-
{scale}
|
|
103
|
-
{min_width}
|
|
78
|
+
elem_id={gradio.shared.elem_id}
|
|
79
|
+
elem_classes={gradio.shared.elem_classes}
|
|
80
|
+
container={gradio.shared.container}
|
|
81
|
+
scale={gradio.shared.scale}
|
|
82
|
+
min_width={gradio.shared.min_width}
|
|
104
83
|
allow_overflow={false}
|
|
105
|
-
height={typeof height === "number"
|
|
84
|
+
height={typeof gradio.props.height === "number"
|
|
85
|
+
? gradio.props.height
|
|
86
|
+
: undefined}
|
|
106
87
|
bind:fullscreen
|
|
107
88
|
>
|
|
108
89
|
<StatusTracker
|
|
109
|
-
autoscroll={gradio.autoscroll}
|
|
90
|
+
autoscroll={gradio.shared.autoscroll}
|
|
110
91
|
i18n={gradio.i18n}
|
|
111
|
-
{...loading_status}
|
|
112
|
-
on:clear_status={() =>
|
|
92
|
+
{...gradio.shared.loading_status}
|
|
93
|
+
on:clear_status={() =>
|
|
94
|
+
gradio.dispatch("clear_status", gradio.shared.loading_status)}
|
|
113
95
|
/>
|
|
114
|
-
{#if interactive && no_value}
|
|
96
|
+
{#if gradio.shared.interactive && no_value}
|
|
115
97
|
<BaseFileUpload
|
|
98
|
+
bind:upload_promise
|
|
116
99
|
value={null}
|
|
117
|
-
{root}
|
|
118
|
-
{label}
|
|
119
|
-
max_file_size={gradio.max_file_size}
|
|
100
|
+
root={gradio.shared.root}
|
|
101
|
+
label={gradio.shared.label}
|
|
102
|
+
max_file_size={gradio.shared.max_file_size}
|
|
120
103
|
file_count={"multiple"}
|
|
121
|
-
{file_types}
|
|
104
|
+
file_types={gradio.props.file_types}
|
|
122
105
|
i18n={gradio.i18n}
|
|
123
|
-
upload={(...args) => gradio.client.upload(...args)}
|
|
124
|
-
stream_handler={(...args) => gradio.client.stream(...args)}
|
|
106
|
+
upload={(...args) => gradio.shared.client.upload(...args)}
|
|
107
|
+
stream_handler={(...args) => gradio.shared.client.stream(...args)}
|
|
125
108
|
on:upload={async (e) => {
|
|
126
109
|
const files = Array.isArray(e.detail) ? e.detail : [e.detail];
|
|
127
|
-
value = await process_upload_files(files);
|
|
128
|
-
gradio.dispatch("upload", value);
|
|
129
|
-
gradio.dispatch("change", value);
|
|
110
|
+
gradio.props.value = await process_upload_files(files);
|
|
111
|
+
gradio.dispatch("upload", gradio.props.value);
|
|
112
|
+
gradio.dispatch("change", gradio.props.value);
|
|
130
113
|
}}
|
|
131
114
|
on:error={({ detail }) => {
|
|
132
|
-
loading_status = loading_status || {};
|
|
133
|
-
loading_status.status = "error";
|
|
115
|
+
gradio.shared.loading_status = gradio.shared.loading_status || {};
|
|
116
|
+
gradio.shared.loading_status.status = "error";
|
|
134
117
|
gradio.dispatch("error", detail);
|
|
135
118
|
}}
|
|
136
119
|
>
|
|
@@ -138,7 +121,8 @@
|
|
|
138
121
|
</BaseFileUpload>
|
|
139
122
|
{:else}
|
|
140
123
|
<Gallery
|
|
141
|
-
on:change={() => gradio.dispatch("change"
|
|
124
|
+
on:change={() => gradio.dispatch("change")}
|
|
125
|
+
on:clear={() => gradio.dispatch("change")}
|
|
142
126
|
on:select={(e) => gradio.dispatch("select", e.detail)}
|
|
143
127
|
on:share={(e) => gradio.dispatch("share", e.detail)}
|
|
144
128
|
on:error={(e) => gradio.dispatch("error", e.detail)}
|
|
@@ -151,32 +135,35 @@
|
|
|
151
135
|
on:upload={async (e) => {
|
|
152
136
|
const files = Array.isArray(e.detail) ? e.detail : [e.detail];
|
|
153
137
|
const new_value = await process_upload_files(files);
|
|
154
|
-
value = value
|
|
138
|
+
gradio.props.value = gradio.props.value
|
|
139
|
+
? [...gradio.props.value, ...new_value]
|
|
140
|
+
: new_value;
|
|
155
141
|
gradio.dispatch("upload", new_value);
|
|
156
|
-
gradio.dispatch("change", value);
|
|
142
|
+
gradio.dispatch("change", gradio.props.value);
|
|
157
143
|
}}
|
|
158
|
-
{label}
|
|
159
|
-
{show_label}
|
|
160
|
-
{columns}
|
|
161
|
-
{rows}
|
|
162
|
-
{height}
|
|
163
|
-
{preview}
|
|
164
|
-
{object_fit}
|
|
165
|
-
{interactive}
|
|
166
|
-
{allow_preview}
|
|
167
|
-
bind:selected_index
|
|
168
|
-
bind:value
|
|
169
|
-
show_share_button={buttons
|
|
170
|
-
show_download_button={buttons
|
|
144
|
+
label={gradio.shared.label}
|
|
145
|
+
show_label={gradio.shared.show_label}
|
|
146
|
+
columns={gradio.props.columns}
|
|
147
|
+
rows={gradio.props.rows}
|
|
148
|
+
height={gradio.props.height}
|
|
149
|
+
preview={gradio.props.preview}
|
|
150
|
+
object_fit={gradio.props.object_fit}
|
|
151
|
+
interactive={gradio.shared.interactive}
|
|
152
|
+
allow_preview={gradio.props.allow_preview}
|
|
153
|
+
bind:selected_index={gradio.props.selected_index}
|
|
154
|
+
bind:value={gradio.props.value}
|
|
155
|
+
show_share_button={gradio.props.buttons.includes("share")}
|
|
156
|
+
show_download_button={gradio.props.buttons.includes("download")}
|
|
157
|
+
fit_columns={gradio.props.fit_columns}
|
|
171
158
|
i18n={gradio.i18n}
|
|
172
|
-
_fetch={(...args) => gradio.client.fetch(...args)}
|
|
173
|
-
show_fullscreen_button={buttons
|
|
159
|
+
_fetch={(...args) => gradio.shared.client.fetch(...args)}
|
|
160
|
+
show_fullscreen_button={gradio.props.buttons.includes("fullscreen")}
|
|
174
161
|
{fullscreen}
|
|
175
|
-
{root}
|
|
176
|
-
{file_types}
|
|
177
|
-
max_file_size={gradio.max_file_size}
|
|
178
|
-
upload={(...args) => gradio.client.upload(...args)}
|
|
179
|
-
stream_handler={(...args) => gradio.client.stream(...args)}
|
|
162
|
+
root={gradio.shared.root}
|
|
163
|
+
file_types={gradio.props.file_types}
|
|
164
|
+
max_file_size={gradio.shared.max_file_size}
|
|
165
|
+
upload={(...args) => gradio.shared.client.upload(...args)}
|
|
166
|
+
stream_handler={(...args) => gradio.shared.client.stream(...args)}
|
|
180
167
|
/>
|
|
181
168
|
{/if}
|
|
182
169
|
</Block>
|
package/dist/Example.svelte
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { GalleryImage, GalleryVideo } from "./types";
|
|
3
|
+
|
|
4
|
+
export let value: (GalleryImage | GalleryVideo)[] | null;
|
|
5
|
+
export let type: "gallery" | "table";
|
|
6
|
+
export let selected = false;
|
|
4
7
|
</script>
|
|
5
8
|
|
|
6
9
|
<div
|
package/dist/Example.svelte.d.ts
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import type { GalleryImage, GalleryVideo } from "./types";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
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;
|
|
8
12
|
};
|
|
9
|
-
|
|
10
|
-
[evt: string]: CustomEvent<any>;
|
|
11
|
-
};
|
|
12
|
-
slots: {};
|
|
13
|
-
exports?: {} | undefined;
|
|
14
|
-
bindings?: string | undefined;
|
|
15
|
-
};
|
|
16
|
-
export type ExampleProps = typeof __propDef.props;
|
|
17
|
-
export type ExampleEvents = typeof __propDef.events;
|
|
18
|
-
export type ExampleSlots = typeof __propDef.slots;
|
|
19
|
-
export default class Example extends SvelteComponent<ExampleProps, ExampleEvents, ExampleSlots> {
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
20
14
|
}
|
|
21
|
-
|
|
15
|
+
declare const Example: $$__sveltets_2_IsomorphicComponent<{
|
|
16
|
+
value: (GalleryImage | GalleryVideo)[] | null;
|
|
17
|
+
type: "gallery" | "table";
|
|
18
|
+
selected?: boolean;
|
|
19
|
+
}, {
|
|
20
|
+
[evt: string]: CustomEvent<any>;
|
|
21
|
+
}, {}, {}, string>;
|
|
22
|
+
type Example = InstanceType<typeof Example>;
|
|
23
|
+
export default Example;
|
package/dist/Index.svelte
CHANGED
|
@@ -1,104 +1,119 @@
|
|
|
1
|
-
<script context="module"
|
|
2
|
-
export { default as
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
|
+
export { default as BaseGallery } from "./shared/Gallery.svelte";
|
|
3
|
+
export { default as BaseExample } from "./Example.svelte";
|
|
3
4
|
</script>
|
|
4
5
|
|
|
5
|
-
<script
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
6
|
+
<script lang="ts">
|
|
7
|
+
import { tick } from "svelte";
|
|
8
|
+
import type { FileData } from "@gradio/client";
|
|
9
|
+
import { Block, UploadText } from "@gradio/atoms";
|
|
10
|
+
import Gallery from "./shared/Gallery.svelte";
|
|
11
|
+
import { StatusTracker } from "@gradio/statustracker";
|
|
12
|
+
import { Gradio } from "@gradio/utils";
|
|
13
|
+
import { BaseFileUpload } from "@gradio/file";
|
|
14
|
+
import type { GalleryProps, GalleryEvents, GalleryData } from "./types";
|
|
15
|
+
|
|
16
|
+
let upload_promise = $state<Promise<any>>();
|
|
17
|
+
|
|
18
|
+
class GalleryGradio extends Gradio<GalleryEvents, GalleryProps> {
|
|
19
|
+
async get_data() {
|
|
20
|
+
if (upload_promise) {
|
|
21
|
+
await upload_promise;
|
|
22
|
+
await tick();
|
|
23
|
+
}
|
|
24
|
+
const data = await super.get_data();
|
|
25
|
+
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const props = $props();
|
|
31
|
+
const gradio = new GalleryGradio<GalleryEvents, GalleryProps>(props);
|
|
32
|
+
|
|
33
|
+
let fullscreen = $state(false);
|
|
34
|
+
|
|
35
|
+
let no_value = $derived(
|
|
36
|
+
gradio.props.value === null ? true : gradio.props.value.length === 0
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
function handle_delete(
|
|
40
|
+
event: CustomEvent<{ file: FileData; index: number }>
|
|
41
|
+
): void {
|
|
42
|
+
if (!gradio.props.value) return;
|
|
43
|
+
const { index } = event.detail;
|
|
44
|
+
gradio.dispatch("delete", event.detail);
|
|
45
|
+
gradio.props.value = gradio.props.value.filter((_, i) => i !== index);
|
|
46
|
+
gradio.dispatch("change", gradio.props.value);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async function process_upload_files(
|
|
50
|
+
files: FileData[]
|
|
51
|
+
): Promise<GalleryData[]> {
|
|
52
|
+
const processed_files = await Promise.all(
|
|
53
|
+
files.map(async (x) => {
|
|
54
|
+
if (x.path?.toLowerCase().endsWith(".svg") && x.url) {
|
|
55
|
+
const response = await fetch(x.url);
|
|
56
|
+
const svgContent = await response.text();
|
|
57
|
+
return {
|
|
58
|
+
...x,
|
|
59
|
+
url: `data:image/svg+xml,${encodeURIComponent(svgContent)}`
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return x;
|
|
63
|
+
})
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
return processed_files.map((x) =>
|
|
67
|
+
x.mime_type?.includes("video")
|
|
68
|
+
? { video: x, caption: null }
|
|
69
|
+
: { image: x, caption: null }
|
|
70
|
+
);
|
|
71
|
+
}
|
|
61
72
|
</script>
|
|
62
73
|
|
|
63
74
|
<Block
|
|
64
|
-
{visible}
|
|
75
|
+
visible={gradio.shared.visible}
|
|
65
76
|
variant="solid"
|
|
66
77
|
padding={false}
|
|
67
|
-
{elem_id}
|
|
68
|
-
{elem_classes}
|
|
69
|
-
{container}
|
|
70
|
-
{scale}
|
|
71
|
-
{min_width}
|
|
78
|
+
elem_id={gradio.shared.elem_id}
|
|
79
|
+
elem_classes={gradio.shared.elem_classes}
|
|
80
|
+
container={gradio.shared.container}
|
|
81
|
+
scale={gradio.shared.scale}
|
|
82
|
+
min_width={gradio.shared.min_width}
|
|
72
83
|
allow_overflow={false}
|
|
73
|
-
height={typeof height === "number"
|
|
84
|
+
height={typeof gradio.props.height === "number"
|
|
85
|
+
? gradio.props.height
|
|
86
|
+
: undefined}
|
|
74
87
|
bind:fullscreen
|
|
75
88
|
>
|
|
76
89
|
<StatusTracker
|
|
77
|
-
autoscroll={gradio.autoscroll}
|
|
90
|
+
autoscroll={gradio.shared.autoscroll}
|
|
78
91
|
i18n={gradio.i18n}
|
|
79
|
-
{...loading_status}
|
|
80
|
-
on:clear_status={() =>
|
|
92
|
+
{...gradio.shared.loading_status}
|
|
93
|
+
on:clear_status={() =>
|
|
94
|
+
gradio.dispatch("clear_status", gradio.shared.loading_status)}
|
|
81
95
|
/>
|
|
82
|
-
{#if interactive && no_value}
|
|
96
|
+
{#if gradio.shared.interactive && no_value}
|
|
83
97
|
<BaseFileUpload
|
|
98
|
+
bind:upload_promise
|
|
84
99
|
value={null}
|
|
85
|
-
{root}
|
|
86
|
-
{label}
|
|
87
|
-
max_file_size={gradio.max_file_size}
|
|
100
|
+
root={gradio.shared.root}
|
|
101
|
+
label={gradio.shared.label}
|
|
102
|
+
max_file_size={gradio.shared.max_file_size}
|
|
88
103
|
file_count={"multiple"}
|
|
89
|
-
{file_types}
|
|
104
|
+
file_types={gradio.props.file_types}
|
|
90
105
|
i18n={gradio.i18n}
|
|
91
|
-
upload={(...args) => gradio.client.upload(...args)}
|
|
92
|
-
stream_handler={(...args) => gradio.client.stream(...args)}
|
|
106
|
+
upload={(...args) => gradio.shared.client.upload(...args)}
|
|
107
|
+
stream_handler={(...args) => gradio.shared.client.stream(...args)}
|
|
93
108
|
on:upload={async (e) => {
|
|
94
109
|
const files = Array.isArray(e.detail) ? e.detail : [e.detail];
|
|
95
|
-
value = await process_upload_files(files);
|
|
96
|
-
gradio.dispatch("upload", value);
|
|
97
|
-
gradio.dispatch("change", value);
|
|
110
|
+
gradio.props.value = await process_upload_files(files);
|
|
111
|
+
gradio.dispatch("upload", gradio.props.value);
|
|
112
|
+
gradio.dispatch("change", gradio.props.value);
|
|
98
113
|
}}
|
|
99
114
|
on:error={({ detail }) => {
|
|
100
|
-
loading_status = loading_status || {};
|
|
101
|
-
loading_status.status = "error";
|
|
115
|
+
gradio.shared.loading_status = gradio.shared.loading_status || {};
|
|
116
|
+
gradio.shared.loading_status.status = "error";
|
|
102
117
|
gradio.dispatch("error", detail);
|
|
103
118
|
}}
|
|
104
119
|
>
|
|
@@ -106,7 +121,8 @@ async function process_upload_files(files) {
|
|
|
106
121
|
</BaseFileUpload>
|
|
107
122
|
{:else}
|
|
108
123
|
<Gallery
|
|
109
|
-
on:change={() => gradio.dispatch("change"
|
|
124
|
+
on:change={() => gradio.dispatch("change")}
|
|
125
|
+
on:clear={() => gradio.dispatch("change")}
|
|
110
126
|
on:select={(e) => gradio.dispatch("select", e.detail)}
|
|
111
127
|
on:share={(e) => gradio.dispatch("share", e.detail)}
|
|
112
128
|
on:error={(e) => gradio.dispatch("error", e.detail)}
|
|
@@ -119,32 +135,35 @@ async function process_upload_files(files) {
|
|
|
119
135
|
on:upload={async (e) => {
|
|
120
136
|
const files = Array.isArray(e.detail) ? e.detail : [e.detail];
|
|
121
137
|
const new_value = await process_upload_files(files);
|
|
122
|
-
value = value
|
|
138
|
+
gradio.props.value = gradio.props.value
|
|
139
|
+
? [...gradio.props.value, ...new_value]
|
|
140
|
+
: new_value;
|
|
123
141
|
gradio.dispatch("upload", new_value);
|
|
124
|
-
gradio.dispatch("change", value);
|
|
142
|
+
gradio.dispatch("change", gradio.props.value);
|
|
125
143
|
}}
|
|
126
|
-
{label}
|
|
127
|
-
{show_label}
|
|
128
|
-
{columns}
|
|
129
|
-
{rows}
|
|
130
|
-
{height}
|
|
131
|
-
{preview}
|
|
132
|
-
{object_fit}
|
|
133
|
-
{interactive}
|
|
134
|
-
{allow_preview}
|
|
135
|
-
bind:selected_index
|
|
136
|
-
bind:value
|
|
137
|
-
show_share_button={buttons
|
|
138
|
-
show_download_button={buttons
|
|
144
|
+
label={gradio.shared.label}
|
|
145
|
+
show_label={gradio.shared.show_label}
|
|
146
|
+
columns={gradio.props.columns}
|
|
147
|
+
rows={gradio.props.rows}
|
|
148
|
+
height={gradio.props.height}
|
|
149
|
+
preview={gradio.props.preview}
|
|
150
|
+
object_fit={gradio.props.object_fit}
|
|
151
|
+
interactive={gradio.shared.interactive}
|
|
152
|
+
allow_preview={gradio.props.allow_preview}
|
|
153
|
+
bind:selected_index={gradio.props.selected_index}
|
|
154
|
+
bind:value={gradio.props.value}
|
|
155
|
+
show_share_button={gradio.props.buttons.includes("share")}
|
|
156
|
+
show_download_button={gradio.props.buttons.includes("download")}
|
|
157
|
+
fit_columns={gradio.props.fit_columns}
|
|
139
158
|
i18n={gradio.i18n}
|
|
140
|
-
_fetch={(...args) => gradio.client.fetch(...args)}
|
|
141
|
-
show_fullscreen_button={buttons
|
|
159
|
+
_fetch={(...args) => gradio.shared.client.fetch(...args)}
|
|
160
|
+
show_fullscreen_button={gradio.props.buttons.includes("fullscreen")}
|
|
142
161
|
{fullscreen}
|
|
143
|
-
{root}
|
|
144
|
-
{file_types}
|
|
145
|
-
max_file_size={gradio.max_file_size}
|
|
146
|
-
upload={(...args) => gradio.client.upload(...args)}
|
|
147
|
-
stream_handler={(...args) => gradio.client.stream(...args)}
|
|
162
|
+
root={gradio.shared.root}
|
|
163
|
+
file_types={gradio.props.file_types}
|
|
164
|
+
max_file_size={gradio.shared.max_file_size}
|
|
165
|
+
upload={(...args) => gradio.shared.client.upload(...args)}
|
|
166
|
+
stream_handler={(...args) => gradio.shared.client.stream(...args)}
|
|
148
167
|
/>
|
|
149
168
|
{/if}
|
|
150
169
|
</Block>
|