@gradio/gallery 0.16.1 → 0.16.2
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 +22 -0
- package/Gallery.stories.svelte +209 -115
- package/Gallery.test.ts +3 -0
- package/Index.svelte +21 -17
- package/dist/Index.svelte +21 -17
- package/dist/shared/Gallery.svelte +176 -114
- package/dist/shared/Gallery.svelte.d.ts +35 -56
- package/package.json +12 -12
- package/shared/Gallery.svelte +176 -114
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @gradio/gallery
|
|
2
2
|
|
|
3
|
+
## 0.16.2
|
|
4
|
+
|
|
5
|
+
### Fixes
|
|
6
|
+
|
|
7
|
+
- [#12800](https://github.com/gradio-app/gradio/pull/12800) [`7a1c321`](https://github.com/gradio-app/gradio/commit/7a1c321b6546ba05a353488f5133e8262c4a8a39) - Bump svelte/kit for security reasons. Thanks @freddyaboulton!
|
|
8
|
+
- [#12698](https://github.com/gradio-app/gradio/pull/12698) [`db86165`](https://github.com/gradio-app/gradio/commit/db86165535386991701ea89b2083ef5e60cd23e8) - Migrates gr.File. Thanks @aliabid94!
|
|
9
|
+
- [#12806](https://github.com/gradio-app/gradio/pull/12806) [`3b3b035`](https://github.com/gradio-app/gradio/commit/3b3b0350e90756e937fc0908446f66ae1412c89f) - Fix Gallery upload after it has been populated. Thanks @freddyaboulton!
|
|
10
|
+
- [#12779](https://github.com/gradio-app/gradio/pull/12779) [`ea2d3e9`](https://github.com/gradio-app/gradio/commit/ea2d3e985a8b42d188e551f517c5825c00790628) - Migrate Audio + Upload + Atoms to Svelte 5. Thanks @dawoodkhan82!
|
|
11
|
+
- [#12684](https://github.com/gradio-app/gradio/pull/12684) [`1373713`](https://github.com/gradio-app/gradio/commit/1373713646e34078188265eb07c4bff5a048e9a2) - Migrate Gallery to Svelte 5. Thanks @freddyaboulton!
|
|
12
|
+
|
|
13
|
+
### Dependency updates
|
|
14
|
+
|
|
15
|
+
- @gradio/statustracker@0.12.2
|
|
16
|
+
- @gradio/atoms@0.20.1
|
|
17
|
+
- @gradio/utils@0.11.2
|
|
18
|
+
- @gradio/icons@0.15.1
|
|
19
|
+
- @gradio/upload@0.17.4
|
|
20
|
+
- @gradio/client@2.0.3
|
|
21
|
+
- @gradio/image@0.25.1
|
|
22
|
+
- @gradio/file@0.14.1
|
|
23
|
+
- @gradio/video@0.20.1
|
|
24
|
+
|
|
3
25
|
## 0.16.1
|
|
4
26
|
|
|
5
27
|
### Dependency updates
|
package/Gallery.stories.svelte
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from "@storybook/addon-svelte-csf";
|
|
3
3
|
import Gallery from "./Index.svelte";
|
|
4
4
|
import { allModes } from "../storybook/modes";
|
|
5
5
|
import { within } from "@testing-library/dom";
|
|
6
|
-
import { userEvent } from "
|
|
6
|
+
import { userEvent } from "storybook/test";
|
|
7
|
+
import { wrapProps } from "../storybook/wrapProps";
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
const cheetah = "/cheetah.jpg";
|
|
10
|
+
const lion = "/lion.jpg";
|
|
11
|
+
const bus = "/bus.png";
|
|
12
|
+
const video_sample = "/video_sample.mp4";
|
|
13
|
+
|
|
14
|
+
const { Story } = defineMeta({
|
|
9
15
|
title: "Components/Gallery",
|
|
10
16
|
component: Gallery,
|
|
11
17
|
argTypes: {
|
|
@@ -79,181 +85,243 @@
|
|
|
79
85
|
}
|
|
80
86
|
}
|
|
81
87
|
}
|
|
82
|
-
};
|
|
83
|
-
</script>
|
|
88
|
+
});
|
|
84
89
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
url: "https://gradio-builds.s3.amazonaws.com/demo-files/cheetah_running.avif",
|
|
92
|
-
orig_name: "cheetah_running.avif"
|
|
93
|
-
},
|
|
94
|
-
caption: "A fast cheetah"
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
video: {
|
|
98
|
-
path: "https://gradio-builds.s3.amazonaws.com/demo-files/world.mp4",
|
|
99
|
-
url: "https://gradio-builds.s3.amazonaws.com/demo-files/world.mp4",
|
|
100
|
-
orig_name: "world.mp4"
|
|
101
|
-
},
|
|
102
|
-
caption: "The world"
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
image: {
|
|
106
|
-
path: "https://gradio-builds.s3.amazonaws.com/demo-files/cheetah-002.jpg",
|
|
107
|
-
url: "https://gradio-builds.s3.amazonaws.com/demo-files/cheetah-002.jpg",
|
|
108
|
-
orig_name: "cheetah-002.jpg"
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
image: {
|
|
113
|
-
path: "https://gradio-builds.s3.amazonaws.com/demo-files/cheetah-003.jpg",
|
|
114
|
-
url: "https://gradio-builds.s3.amazonaws.com/demo-files/cheetah-003.jpg",
|
|
115
|
-
orig_name: "cheetah-003.jpg"
|
|
116
|
-
}
|
|
90
|
+
const galleryValue = [
|
|
91
|
+
{
|
|
92
|
+
image: {
|
|
93
|
+
path: cheetah,
|
|
94
|
+
url: cheetah,
|
|
95
|
+
orig_name: "cheetah.jpg"
|
|
117
96
|
},
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
{
|
|
126
|
-
image: {
|
|
127
|
-
path: "https://gradio-builds.s3.amazonaws.com/demo-files/ghepardo-primo-piano.jpg",
|
|
128
|
-
url: "https://gradio-builds.s3.amazonaws.com/demo-files/ghepardo-primo-piano.jpg",
|
|
129
|
-
orig_name: "ghepardo-primo-piano.jpg"
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
image: {
|
|
134
|
-
path: "https://gradio-builds.s3.amazonaws.com/demo-files/main-qimg-0bbf31c18a22178cb7a8dd53640a3d05-lq.jpeg",
|
|
135
|
-
url: "https://gradio-builds.s3.amazonaws.com/demo-files/main-qimg-0bbf31c18a22178cb7a8dd53640a3d05-lq.jpeg",
|
|
136
|
-
orig_name: "main-qimg-0bbf31c18a22178cb7a8dd53640a3d05-lq.jpeg"
|
|
137
|
-
}
|
|
97
|
+
caption: "A fast cheetah"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
video: {
|
|
101
|
+
path: video_sample,
|
|
102
|
+
url: video_sample,
|
|
103
|
+
orig_name: "video_sample.mp4"
|
|
138
104
|
},
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
105
|
+
caption: "Sample video"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
image: {
|
|
109
|
+
path: lion,
|
|
110
|
+
url: lion,
|
|
111
|
+
orig_name: "lion.jpg"
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
image: {
|
|
116
|
+
path: bus,
|
|
117
|
+
url: bus,
|
|
118
|
+
orig_name: "bus.png"
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
image: {
|
|
123
|
+
path: cheetah,
|
|
124
|
+
url: cheetah,
|
|
125
|
+
orig_name: "cheetah.jpg"
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
image: {
|
|
130
|
+
path: lion,
|
|
131
|
+
url: lion,
|
|
132
|
+
orig_name: "lion.jpg"
|
|
145
133
|
}
|
|
146
|
-
|
|
147
|
-
{
|
|
148
|
-
|
|
149
|
-
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
image: {
|
|
137
|
+
path: bus,
|
|
138
|
+
url: bus,
|
|
139
|
+
orig_name: "bus.png"
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
image: {
|
|
144
|
+
path: cheetah,
|
|
145
|
+
url: cheetah,
|
|
146
|
+
orig_name: "cheetah.jpg"
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
];
|
|
150
|
+
</script>
|
|
150
151
|
|
|
151
152
|
<Story
|
|
152
153
|
name="Gallery with label"
|
|
153
|
-
args={{
|
|
154
|
+
args={{
|
|
155
|
+
label: "My Cheetah Gallery",
|
|
156
|
+
show_label: true,
|
|
157
|
+
buttons: ["fullscreen", "download", "share"]
|
|
158
|
+
}}
|
|
154
159
|
play={async ({ canvasElement }) => {
|
|
155
160
|
const canvas = within(canvasElement);
|
|
156
|
-
|
|
157
161
|
const image = canvas.getByLabelText("Thumbnail 1 of 8");
|
|
158
162
|
await userEvent.click(image);
|
|
159
|
-
const expand_btn = canvas.getByRole("button", {
|
|
160
|
-
name: "Fullscreen"
|
|
161
|
-
});
|
|
163
|
+
const expand_btn = canvas.getByRole("button", { name: "Fullscreen" });
|
|
162
164
|
await userEvent.click(expand_btn);
|
|
163
165
|
}}
|
|
164
|
-
|
|
166
|
+
>
|
|
167
|
+
{#snippet template(args)}
|
|
168
|
+
<Gallery {...wrapProps({ value: galleryValue, ...args })} />
|
|
169
|
+
{/snippet}
|
|
170
|
+
</Story>
|
|
171
|
+
|
|
165
172
|
<Story
|
|
166
173
|
name="Gallery without label"
|
|
167
|
-
args={{ label: "My Cheetah Gallery", show_label: false }}
|
|
168
|
-
|
|
174
|
+
args={{ label: "My Cheetah Gallery", show_label: false, buttons: [] }}
|
|
175
|
+
>
|
|
176
|
+
{#snippet template(args)}
|
|
177
|
+
<Gallery {...wrapProps({ value: galleryValue, ...args })} />
|
|
178
|
+
{/snippet}
|
|
179
|
+
</Story>
|
|
180
|
+
|
|
169
181
|
<Story
|
|
170
182
|
name="Gallery with rows=3 and columns=3"
|
|
171
183
|
args={{
|
|
172
184
|
label: "My Cheetah Gallery",
|
|
173
185
|
show_label: true,
|
|
174
186
|
rows: 3,
|
|
175
|
-
columns: 3
|
|
187
|
+
columns: 3,
|
|
188
|
+
buttons: []
|
|
176
189
|
}}
|
|
177
|
-
|
|
190
|
+
>
|
|
191
|
+
{#snippet template(args)}
|
|
192
|
+
<Gallery {...wrapProps({ value: galleryValue, ...args })} />
|
|
193
|
+
{/snippet}
|
|
194
|
+
</Story>
|
|
195
|
+
|
|
178
196
|
<Story
|
|
179
197
|
name="Gallery with columns=4"
|
|
180
198
|
args={{
|
|
181
199
|
label: "My Cheetah Gallery",
|
|
182
200
|
show_label: true,
|
|
183
|
-
columns: 4
|
|
201
|
+
columns: 4,
|
|
202
|
+
buttons: []
|
|
184
203
|
}}
|
|
185
|
-
|
|
204
|
+
>
|
|
205
|
+
{#snippet template(args)}
|
|
206
|
+
<Gallery {...wrapProps({ value: galleryValue, ...args })} />
|
|
207
|
+
{/snippet}
|
|
208
|
+
</Story>
|
|
209
|
+
|
|
186
210
|
<Story
|
|
187
211
|
name="Gallery with height=600"
|
|
188
|
-
args={{
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
212
|
+
args={{ label: "My Cheetah Gallery", height: 600, buttons: [] }}
|
|
213
|
+
>
|
|
214
|
+
{#snippet template(args)}
|
|
215
|
+
<Gallery {...wrapProps({ value: galleryValue, ...args })} />
|
|
216
|
+
{/snippet}
|
|
217
|
+
</Story>
|
|
218
|
+
|
|
193
219
|
<Story
|
|
194
220
|
name="Gallery with allow_preview=false"
|
|
195
221
|
args={{
|
|
196
222
|
label: "My Cheetah Gallery",
|
|
197
223
|
show_label: true,
|
|
198
|
-
allow_preview: false
|
|
224
|
+
allow_preview: false,
|
|
225
|
+
buttons: []
|
|
199
226
|
}}
|
|
200
|
-
|
|
227
|
+
>
|
|
228
|
+
{#snippet template(args)}
|
|
229
|
+
<Gallery {...wrapProps({ value: galleryValue, ...args })} />
|
|
230
|
+
{/snippet}
|
|
231
|
+
</Story>
|
|
232
|
+
|
|
201
233
|
<Story
|
|
202
234
|
name="Gallery with preview"
|
|
203
235
|
args={{
|
|
204
236
|
label: "My Cheetah Gallery",
|
|
205
237
|
show_label: true,
|
|
206
|
-
preview: true
|
|
238
|
+
preview: true,
|
|
239
|
+
buttons: []
|
|
207
240
|
}}
|
|
208
|
-
|
|
241
|
+
>
|
|
242
|
+
{#snippet template(args)}
|
|
243
|
+
<Gallery {...wrapProps({ value: galleryValue, ...args })} />
|
|
244
|
+
{/snippet}
|
|
245
|
+
</Story>
|
|
246
|
+
|
|
209
247
|
<Story
|
|
210
248
|
name="Gallery with object_fit=scale-down"
|
|
211
249
|
args={{
|
|
212
250
|
label: "My Cheetah Gallery",
|
|
213
251
|
show_label: true,
|
|
214
|
-
object_fit: "scale-down"
|
|
252
|
+
object_fit: "scale-down",
|
|
253
|
+
buttons: []
|
|
215
254
|
}}
|
|
216
|
-
|
|
255
|
+
>
|
|
256
|
+
{#snippet template(args)}
|
|
257
|
+
<Gallery {...wrapProps({ value: galleryValue, ...args })} />
|
|
258
|
+
{/snippet}
|
|
259
|
+
</Story>
|
|
260
|
+
|
|
217
261
|
<Story
|
|
218
262
|
name="Gallery with object_fit=contain"
|
|
219
263
|
args={{
|
|
220
264
|
label: "My Cheetah Gallery",
|
|
221
265
|
show_label: true,
|
|
222
|
-
object_fit: "contain"
|
|
266
|
+
object_fit: "contain",
|
|
267
|
+
buttons: []
|
|
223
268
|
}}
|
|
224
|
-
|
|
269
|
+
>
|
|
270
|
+
{#snippet template(args)}
|
|
271
|
+
<Gallery {...wrapProps({ value: galleryValue, ...args })} />
|
|
272
|
+
{/snippet}
|
|
273
|
+
</Story>
|
|
274
|
+
|
|
225
275
|
<Story
|
|
226
276
|
name="Gallery with object_fit=cover"
|
|
227
277
|
args={{
|
|
228
278
|
label: "My Cheetah Gallery",
|
|
229
279
|
show_label: true,
|
|
230
|
-
object_fit: "cover"
|
|
280
|
+
object_fit: "cover",
|
|
281
|
+
buttons: []
|
|
231
282
|
}}
|
|
232
|
-
|
|
283
|
+
>
|
|
284
|
+
{#snippet template(args)}
|
|
285
|
+
<Gallery {...wrapProps({ value: galleryValue, ...args })} />
|
|
286
|
+
{/snippet}
|
|
287
|
+
</Story>
|
|
288
|
+
|
|
233
289
|
<Story
|
|
234
290
|
name="Gallery with object_fit=none"
|
|
235
291
|
args={{
|
|
236
292
|
label: "My Cheetah Gallery",
|
|
237
293
|
show_label: true,
|
|
238
|
-
object_fit: "none"
|
|
294
|
+
object_fit: "none",
|
|
295
|
+
buttons: []
|
|
239
296
|
}}
|
|
240
|
-
|
|
297
|
+
>
|
|
298
|
+
{#snippet template(args)}
|
|
299
|
+
<Gallery {...wrapProps({ value: galleryValue, ...args })} />
|
|
300
|
+
{/snippet}
|
|
301
|
+
</Story>
|
|
302
|
+
|
|
241
303
|
<Story
|
|
242
304
|
name="Gallery with object_fit=fill"
|
|
243
305
|
args={{
|
|
244
306
|
label: "My Cheetah Gallery",
|
|
245
307
|
show_label: true,
|
|
246
|
-
object_fit: "fill"
|
|
308
|
+
object_fit: "fill",
|
|
309
|
+
buttons: []
|
|
247
310
|
}}
|
|
248
|
-
|
|
311
|
+
>
|
|
312
|
+
{#snippet template(args)}
|
|
313
|
+
<Gallery {...wrapProps({ value: galleryValue, ...args })} />
|
|
314
|
+
{/snippet}
|
|
315
|
+
</Story>
|
|
316
|
+
|
|
249
317
|
<Story
|
|
250
318
|
name="Gallery with share button"
|
|
251
|
-
args={{
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
}
|
|
256
|
-
|
|
319
|
+
args={{ label: "My Cheetah Gallery", show_label: true, buttons: ["share"] }}
|
|
320
|
+
>
|
|
321
|
+
{#snippet template(args)}
|
|
322
|
+
<Gallery {...wrapProps({ value: galleryValue, ...args })} />
|
|
323
|
+
{/snippet}
|
|
324
|
+
</Story>
|
|
257
325
|
|
|
258
326
|
<Story
|
|
259
327
|
name="Gallery with overflow of images"
|
|
@@ -262,9 +330,15 @@
|
|
|
262
330
|
show_label: true,
|
|
263
331
|
rows: 2,
|
|
264
332
|
columns: 2,
|
|
265
|
-
height: 400
|
|
333
|
+
height: 400,
|
|
334
|
+
buttons: []
|
|
266
335
|
}}
|
|
267
|
-
|
|
336
|
+
>
|
|
337
|
+
{#snippet template(args)}
|
|
338
|
+
<Gallery {...wrapProps({ value: galleryValue, ...args })} />
|
|
339
|
+
{/snippet}
|
|
340
|
+
</Story>
|
|
341
|
+
|
|
268
342
|
<Story
|
|
269
343
|
name="Gallery with overflow of images and short height"
|
|
270
344
|
args={{
|
|
@@ -272,33 +346,53 @@
|
|
|
272
346
|
show_label: true,
|
|
273
347
|
rows: 2,
|
|
274
348
|
columns: 2,
|
|
275
|
-
height: 200
|
|
349
|
+
height: 200,
|
|
350
|
+
buttons: []
|
|
276
351
|
}}
|
|
277
|
-
|
|
352
|
+
>
|
|
353
|
+
{#snippet template(args)}
|
|
354
|
+
<Gallery {...wrapProps({ value: galleryValue, ...args })} />
|
|
355
|
+
{/snippet}
|
|
356
|
+
</Story>
|
|
357
|
+
|
|
278
358
|
<Story
|
|
279
359
|
name="Gallery with download button"
|
|
280
360
|
args={{
|
|
281
361
|
label: "My Cheetah Gallery",
|
|
282
362
|
rows: 2,
|
|
283
363
|
height: 400,
|
|
284
|
-
|
|
364
|
+
buttons: ["download"]
|
|
285
365
|
}}
|
|
286
|
-
|
|
366
|
+
>
|
|
367
|
+
{#snippet template(args)}
|
|
368
|
+
<Gallery {...wrapProps({ value: galleryValue, ...args })} />
|
|
369
|
+
{/snippet}
|
|
370
|
+
</Story>
|
|
371
|
+
|
|
287
372
|
<Story
|
|
288
373
|
name="Gallery with fit_columns false"
|
|
289
374
|
args={{
|
|
290
375
|
label: "My Cheetah Gallery",
|
|
291
376
|
columns: 10,
|
|
292
|
-
|
|
377
|
+
buttons: ["download"],
|
|
293
378
|
fit_columns: false
|
|
294
379
|
}}
|
|
295
|
-
|
|
380
|
+
>
|
|
381
|
+
{#snippet template(args)}
|
|
382
|
+
<Gallery {...wrapProps({ value: galleryValue, ...args })} />
|
|
383
|
+
{/snippet}
|
|
384
|
+
</Story>
|
|
385
|
+
|
|
296
386
|
<Story
|
|
297
387
|
name="Gallery with fit_columns true"
|
|
298
388
|
args={{
|
|
299
389
|
label: "My Cheetah Gallery",
|
|
300
390
|
columns: 10,
|
|
301
|
-
|
|
391
|
+
buttons: ["download"],
|
|
302
392
|
fit_columns: true
|
|
303
393
|
}}
|
|
304
|
-
|
|
394
|
+
>
|
|
395
|
+
{#snippet template(args)}
|
|
396
|
+
<Gallery {...wrapProps({ value: galleryValue, ...args })} />
|
|
397
|
+
{/snippet}
|
|
398
|
+
</Story>
|
package/Gallery.test.ts
CHANGED
|
@@ -31,6 +31,7 @@ describe("Gallery", () => {
|
|
|
31
31
|
loading_status: loading_status,
|
|
32
32
|
preview: true,
|
|
33
33
|
buttons: ["share", "download", "fullscreen"],
|
|
34
|
+
selected_index: 0,
|
|
34
35
|
value: [
|
|
35
36
|
{
|
|
36
37
|
image: {
|
|
@@ -55,6 +56,7 @@ describe("Gallery", () => {
|
|
|
55
56
|
loading_status: loading_status,
|
|
56
57
|
preview: true,
|
|
57
58
|
buttons: ["share", "download", "fullscreen"],
|
|
59
|
+
selected_index: 0,
|
|
58
60
|
value: [
|
|
59
61
|
{
|
|
60
62
|
video: {
|
|
@@ -112,6 +114,7 @@ describe("Gallery", () => {
|
|
|
112
114
|
loading_status: loading_status,
|
|
113
115
|
preview: true,
|
|
114
116
|
buttons: ["share", "download", "fullscreen"],
|
|
117
|
+
selected_index: 0,
|
|
115
118
|
value: [
|
|
116
119
|
{
|
|
117
120
|
image: {
|
package/Index.svelte
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import { BaseFileUpload } from "@gradio/file";
|
|
14
14
|
import type { GalleryProps, GalleryEvents, GalleryData } from "./types";
|
|
15
15
|
|
|
16
|
-
let upload_promise = $state<Promise<
|
|
16
|
+
let upload_promise = $state<Promise<(FileData | null)[]>>();
|
|
17
17
|
|
|
18
18
|
class GalleryGradio extends Gradio<GalleryEvents, GalleryProps> {
|
|
19
19
|
async get_data() {
|
|
@@ -28,7 +28,9 @@
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
const props = $props();
|
|
31
|
-
const gradio = new GalleryGradio<GalleryEvents, GalleryProps>(props
|
|
31
|
+
const gradio = new GalleryGradio<GalleryEvents, GalleryProps>(props, {
|
|
32
|
+
selected_index: null
|
|
33
|
+
});
|
|
32
34
|
|
|
33
35
|
let fullscreen = $state(false);
|
|
34
36
|
|
|
@@ -105,35 +107,37 @@
|
|
|
105
107
|
i18n={gradio.i18n}
|
|
106
108
|
upload={(...args) => gradio.shared.client.upload(...args)}
|
|
107
109
|
stream_handler={(...args) => gradio.shared.client.stream(...args)}
|
|
108
|
-
|
|
109
|
-
const files = Array.isArray(
|
|
110
|
+
onupload={async (event_data) => {
|
|
111
|
+
const files = Array.isArray(event_data) ? event_data : [event_data];
|
|
110
112
|
gradio.props.value = await process_upload_files(files);
|
|
111
113
|
gradio.dispatch("upload", gradio.props.value);
|
|
112
114
|
gradio.dispatch("change", gradio.props.value);
|
|
113
115
|
}}
|
|
114
|
-
|
|
116
|
+
onerror={(event_data) => {
|
|
115
117
|
gradio.shared.loading_status = gradio.shared.loading_status || {};
|
|
116
118
|
gradio.shared.loading_status.status = "error";
|
|
117
|
-
gradio.dispatch("error",
|
|
119
|
+
gradio.dispatch("error", event_data);
|
|
118
120
|
}}
|
|
119
121
|
>
|
|
120
122
|
<UploadText i18n={gradio.i18n} type="gallery" />
|
|
121
123
|
</BaseFileUpload>
|
|
122
124
|
{:else}
|
|
123
125
|
<Gallery
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
126
|
+
onchange={() => gradio.dispatch("change")}
|
|
127
|
+
onclear={() => gradio.dispatch("change")}
|
|
128
|
+
onselect={(e) => gradio.dispatch("select", e)}
|
|
129
|
+
onshare={(e) => gradio.dispatch("share", e.detail)}
|
|
130
|
+
onerror={(e) => gradio.dispatch("error", e.detail)}
|
|
131
|
+
onpreview_open={() => {
|
|
132
|
+
gradio.dispatch("preview_open");
|
|
133
|
+
}}
|
|
134
|
+
onpreview_close={() => gradio.dispatch("preview_close")}
|
|
135
|
+
onfullscreen={({ detail }) => {
|
|
132
136
|
fullscreen = detail;
|
|
133
137
|
}}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const files = Array.isArray(e
|
|
138
|
+
ondelete={handle_delete}
|
|
139
|
+
onupload={async (e) => {
|
|
140
|
+
const files = Array.isArray(e) ? e : [e];
|
|
137
141
|
const new_value = await process_upload_files(files);
|
|
138
142
|
gradio.props.value = gradio.props.value
|
|
139
143
|
? [...gradio.props.value, ...new_value]
|
package/dist/Index.svelte
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import { BaseFileUpload } from "@gradio/file";
|
|
14
14
|
import type { GalleryProps, GalleryEvents, GalleryData } from "./types";
|
|
15
15
|
|
|
16
|
-
let upload_promise = $state<Promise<
|
|
16
|
+
let upload_promise = $state<Promise<(FileData | null)[]>>();
|
|
17
17
|
|
|
18
18
|
class GalleryGradio extends Gradio<GalleryEvents, GalleryProps> {
|
|
19
19
|
async get_data() {
|
|
@@ -28,7 +28,9 @@
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
const props = $props();
|
|
31
|
-
const gradio = new GalleryGradio<GalleryEvents, GalleryProps>(props
|
|
31
|
+
const gradio = new GalleryGradio<GalleryEvents, GalleryProps>(props, {
|
|
32
|
+
selected_index: null
|
|
33
|
+
});
|
|
32
34
|
|
|
33
35
|
let fullscreen = $state(false);
|
|
34
36
|
|
|
@@ -105,35 +107,37 @@
|
|
|
105
107
|
i18n={gradio.i18n}
|
|
106
108
|
upload={(...args) => gradio.shared.client.upload(...args)}
|
|
107
109
|
stream_handler={(...args) => gradio.shared.client.stream(...args)}
|
|
108
|
-
|
|
109
|
-
const files = Array.isArray(
|
|
110
|
+
onupload={async (event_data) => {
|
|
111
|
+
const files = Array.isArray(event_data) ? event_data : [event_data];
|
|
110
112
|
gradio.props.value = await process_upload_files(files);
|
|
111
113
|
gradio.dispatch("upload", gradio.props.value);
|
|
112
114
|
gradio.dispatch("change", gradio.props.value);
|
|
113
115
|
}}
|
|
114
|
-
|
|
116
|
+
onerror={(event_data) => {
|
|
115
117
|
gradio.shared.loading_status = gradio.shared.loading_status || {};
|
|
116
118
|
gradio.shared.loading_status.status = "error";
|
|
117
|
-
gradio.dispatch("error",
|
|
119
|
+
gradio.dispatch("error", event_data);
|
|
118
120
|
}}
|
|
119
121
|
>
|
|
120
122
|
<UploadText i18n={gradio.i18n} type="gallery" />
|
|
121
123
|
</BaseFileUpload>
|
|
122
124
|
{:else}
|
|
123
125
|
<Gallery
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
126
|
+
onchange={() => gradio.dispatch("change")}
|
|
127
|
+
onclear={() => gradio.dispatch("change")}
|
|
128
|
+
onselect={(e) => gradio.dispatch("select", e)}
|
|
129
|
+
onshare={(e) => gradio.dispatch("share", e.detail)}
|
|
130
|
+
onerror={(e) => gradio.dispatch("error", e.detail)}
|
|
131
|
+
onpreview_open={() => {
|
|
132
|
+
gradio.dispatch("preview_open");
|
|
133
|
+
}}
|
|
134
|
+
onpreview_close={() => gradio.dispatch("preview_close")}
|
|
135
|
+
onfullscreen={({ detail }) => {
|
|
132
136
|
fullscreen = detail;
|
|
133
137
|
}}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const files = Array.isArray(e
|
|
138
|
+
ondelete={handle_delete}
|
|
139
|
+
onupload={async (e) => {
|
|
140
|
+
const files = Array.isArray(e) ? e : [e];
|
|
137
141
|
const new_value = await process_upload_files(files);
|
|
138
142
|
gradio.props.value = gradio.props.value
|
|
139
143
|
? [...gradio.props.value, ...new_value]
|