@gradio/gallery 0.4.16 → 0.5.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 +13 -1
- package/package.json +5 -4
- package/shared/Gallery.svelte +19 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @gradio/gallery
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- [#7024](https://github.com/gradio-app/gradio/pull/7024) [`f2d69fc`](https://github.com/gradio-app/gradio/commit/f2d69fc7d0c1c3457112e702b53e38a0255fc1b7) - Fix gallery thumbnail design regression. Thanks [@hannahblair](https://github.com/hannahblair)!
|
|
8
|
+
|
|
9
|
+
## 0.4.17
|
|
10
|
+
|
|
11
|
+
### Fixes
|
|
12
|
+
|
|
13
|
+
- [#6967](https://github.com/gradio-app/gradio/pull/6967) [`5e00162`](https://github.com/gradio-app/gradio/commit/5e0016267f1d683e2daab82ee4a33d2f09513a34) - Make <Gallery /> Wasm-compatible. Thanks [@whitphx](https://github.com/whitphx)!
|
|
14
|
+
|
|
3
15
|
## 0.4.16
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -293,4 +305,4 @@ Thanks [@pngwn](https://github.com/pngwn)!
|
|
|
293
305
|
|
|
294
306
|
### Features
|
|
295
307
|
|
|
296
|
-
- [#4995](https://github.com/gradio-app/gradio/pull/4995) [`3f8c210b`](https://github.com/gradio-app/gradio/commit/3f8c210b01ef1ceaaf8ee73be4bf246b5b745bbf) - Implement left and right click in `Gallery` component and show implicit images in `Gallery` grid. Thanks [@hannahblair](https://github.com/hannahblair)!
|
|
308
|
+
- [#4995](https://github.com/gradio-app/gradio/pull/4995) [`3f8c210b`](https://github.com/gradio-app/gradio/commit/3f8c210b01ef1ceaaf8ee73be4bf246b5b745bbf) - Implement left and right click in `Gallery` component and show implicit images in `Gallery` grid. Thanks [@hannahblair](https://github.com/hannahblair)!
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradio/gallery",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Gradio UI packages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "",
|
|
@@ -9,12 +9,13 @@
|
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"dequal": "^2.0.2",
|
|
11
11
|
"@gradio/atoms": "^0.4.1",
|
|
12
|
+
"@gradio/client": "^0.10.1",
|
|
12
13
|
"@gradio/icons": "^0.3.2",
|
|
13
|
-
"@gradio/client": "^0.10.0",
|
|
14
|
-
"@gradio/image": "^0.6.0",
|
|
15
14
|
"@gradio/statustracker": "^0.4.3",
|
|
15
|
+
"@gradio/image": "^0.7.0",
|
|
16
|
+
"@gradio/upload": "^0.6.1",
|
|
16
17
|
"@gradio/utils": "^0.2.0",
|
|
17
|
-
"@gradio/
|
|
18
|
+
"@gradio/wasm": "^0.5.0"
|
|
18
19
|
},
|
|
19
20
|
"main": "./Index.svelte",
|
|
20
21
|
"main_changeset": true,
|
package/shared/Gallery.svelte
CHANGED
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
import { BlockLabel, Empty, ShareButton } from "@gradio/atoms";
|
|
3
3
|
import { ModifyUpload } from "@gradio/upload";
|
|
4
4
|
import type { SelectData } from "@gradio/utils";
|
|
5
|
+
import { Image } from "@gradio/image/shared";
|
|
5
6
|
import { dequal } from "dequal";
|
|
6
|
-
import { createEventDispatcher } from "svelte";
|
|
7
|
+
import { createEventDispatcher, getContext } from "svelte";
|
|
7
8
|
import { tick } from "svelte";
|
|
8
9
|
|
|
9
|
-
import { Download, Image } from "@gradio/icons";
|
|
10
|
+
import { Download, Image as ImageIcon } from "@gradio/icons";
|
|
10
11
|
import { normalise_file, type FileData } from "@gradio/client";
|
|
11
12
|
import { format_gallery_for_sharing } from "./utils";
|
|
12
13
|
import { IconButton } from "@gradio/atoms";
|
|
@@ -166,10 +167,11 @@
|
|
|
166
167
|
// and their remote URLs are directly passed to the client as `value[].image.url`.
|
|
167
168
|
// The `download` attribute of the <a> tag doesn't work for remote URLs (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#download),
|
|
168
169
|
// so we need to download the image via JS as below.
|
|
170
|
+
const fetch_implementation = getContext<typeof fetch>("fetch_implementation");
|
|
169
171
|
async function download(file_url: string, name: string): Promise<void> {
|
|
170
172
|
let response;
|
|
171
173
|
try {
|
|
172
|
-
response = await
|
|
174
|
+
response = await fetch_implementation(file_url);
|
|
173
175
|
} catch (error) {
|
|
174
176
|
if (error instanceof TypeError) {
|
|
175
177
|
// If CORS is not allowed (https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#checking_that_the_fetch_was_successful),
|
|
@@ -199,10 +201,10 @@
|
|
|
199
201
|
<svelte:window bind:innerHeight={window_height} />
|
|
200
202
|
|
|
201
203
|
{#if show_label}
|
|
202
|
-
<BlockLabel {show_label} Icon={
|
|
204
|
+
<BlockLabel {show_label} Icon={ImageIcon} label={label || "Gallery"} />
|
|
203
205
|
{/if}
|
|
204
206
|
{#if value == null || resolved_value == null || resolved_value.length === 0}
|
|
205
|
-
<Empty unpadded_box={true} size="large"><
|
|
207
|
+
<Empty unpadded_box={true} size="large"><ImageIcon /></Empty>
|
|
206
208
|
{:else}
|
|
207
209
|
{#if selected_image && allow_preview}
|
|
208
210
|
<button on:keydown={on_keydown} class="preview">
|
|
@@ -238,12 +240,12 @@
|
|
|
238
240
|
style="height: calc(100% - {selected_image.caption ? '80px' : '60px'})"
|
|
239
241
|
aria-label="detailed view of selected image"
|
|
240
242
|
>
|
|
241
|
-
<
|
|
243
|
+
<Image
|
|
242
244
|
data-testid="detailed-image"
|
|
243
245
|
src={selected_image.image.url}
|
|
244
246
|
alt={selected_image.caption || ""}
|
|
245
247
|
title={selected_image.caption || null}
|
|
246
|
-
class
|
|
248
|
+
class={selected_image.caption && "with-caption"}
|
|
247
249
|
loading="lazy"
|
|
248
250
|
/>
|
|
249
251
|
</button>
|
|
@@ -265,7 +267,7 @@
|
|
|
265
267
|
class:selected={selected_index === i}
|
|
266
268
|
aria-label={"Thumbnail " + (i + 1) + " of " + resolved_value.length}
|
|
267
269
|
>
|
|
268
|
-
<
|
|
270
|
+
<Image
|
|
269
271
|
src={image.image.url}
|
|
270
272
|
title={image.caption || null}
|
|
271
273
|
data-testid={"thumbnail " + (i + 1)}
|
|
@@ -306,7 +308,7 @@
|
|
|
306
308
|
on:click={() => (selected_index = i)}
|
|
307
309
|
aria-label={"Thumbnail " + (i + 1) + " of " + resolved_value.length}
|
|
308
310
|
>
|
|
309
|
-
<
|
|
311
|
+
<Image
|
|
310
312
|
alt={entry.caption || ""}
|
|
311
313
|
src={typeof entry.image === "string"
|
|
312
314
|
? entry.image
|
|
@@ -355,13 +357,17 @@
|
|
|
355
357
|
width: 100%;
|
|
356
358
|
display: flex;
|
|
357
359
|
}
|
|
358
|
-
.
|
|
360
|
+
.image-button :global(img) {
|
|
359
361
|
width: var(--size-full);
|
|
360
362
|
height: var(--size-full);
|
|
361
363
|
object-fit: contain;
|
|
362
364
|
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
+
.thumbnails :global(img) {
|
|
366
|
+
object-fit: cover;
|
|
367
|
+
width: var(--size-full);
|
|
368
|
+
height: var(--size-full);
|
|
369
|
+
}
|
|
370
|
+
.preview :global(img.with-caption) {
|
|
365
371
|
height: var(--size-full);
|
|
366
372
|
}
|
|
367
373
|
|
|
@@ -449,7 +455,7 @@
|
|
|
449
455
|
gap: var(--spacing-lg);
|
|
450
456
|
}
|
|
451
457
|
|
|
452
|
-
.thumbnail-lg > img {
|
|
458
|
+
.thumbnail-lg > :global(img) {
|
|
453
459
|
width: var(--size-full);
|
|
454
460
|
height: var(--size-full);
|
|
455
461
|
overflow: hidden;
|