@gradio/gallery 0.15.36 → 0.16.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.
- package/CHANGELOG.md +29 -0
- package/Gallery.test.ts +37 -0
- package/Index.svelte +13 -3
- package/dist/Index.svelte +13 -3
- package/dist/shared/Gallery.svelte +6 -0
- package/dist/shared/Gallery.svelte.d.ts +3 -0
- package/dist/types.d.ts +5 -1
- package/package.json +9 -9
- package/shared/Gallery.svelte +6 -0
- package/types.ts +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @gradio/gallery
|
|
2
2
|
|
|
3
|
+
## 0.16.1
|
|
4
|
+
|
|
5
|
+
### Dependency updates
|
|
6
|
+
|
|
7
|
+
- @gradio/utils@0.11.1
|
|
8
|
+
- @gradio/client@2.0.2
|
|
9
|
+
- @gradio/video@0.20.0
|
|
10
|
+
|
|
11
|
+
## 0.16.0
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
- [#12539](https://github.com/gradio-app/gradio/pull/12539) [`f1d83fa`](https://github.com/gradio-app/gradio/commit/f1d83fac3d6e4bad60cf896a026fa2d572f26073) - Add ability to add custom buttons to components. Thanks @abidlabs!
|
|
16
|
+
|
|
17
|
+
### Fixes
|
|
18
|
+
|
|
19
|
+
- [#12577](https://github.com/gradio-app/gradio/pull/12577) [`b4c00d2`](https://github.com/gradio-app/gradio/commit/b4c00d2f531d38e2677ea76cfeb412a7bd3bb1a3) - Fix Gallery preview_close event not firing on ESC key. Thanks @majiayu000!
|
|
20
|
+
|
|
21
|
+
### Dependency updates
|
|
22
|
+
|
|
23
|
+
- @gradio/atoms@0.20.0
|
|
24
|
+
- @gradio/utils@0.11.0
|
|
25
|
+
- @gradio/client@2.0.1
|
|
26
|
+
- @gradio/statustracker@0.12.1
|
|
27
|
+
- @gradio/upload@0.17.3
|
|
28
|
+
- @gradio/file@0.14.0
|
|
29
|
+
- @gradio/image@0.25.0
|
|
30
|
+
- @gradio/video@0.19.0
|
|
31
|
+
|
|
3
32
|
## 0.15.36
|
|
4
33
|
|
|
5
34
|
### Dependency updates
|
package/Gallery.test.ts
CHANGED
|
@@ -104,4 +104,41 @@ describe("Gallery", () => {
|
|
|
104
104
|
});
|
|
105
105
|
assert.equal(change_event.callCount, 0);
|
|
106
106
|
});
|
|
107
|
+
|
|
108
|
+
test("triggers preview_close event when pressing Escape key", async () => {
|
|
109
|
+
const { listen, getByTestId } = await render(Gallery, {
|
|
110
|
+
show_label: true,
|
|
111
|
+
label: "Gallery",
|
|
112
|
+
loading_status: loading_status,
|
|
113
|
+
preview: true,
|
|
114
|
+
buttons: ["share", "download", "fullscreen"],
|
|
115
|
+
value: [
|
|
116
|
+
{
|
|
117
|
+
image: {
|
|
118
|
+
path: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/gallery_component/files/cheetah.jpg",
|
|
119
|
+
url: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/gallery_component/files/cheetah.jpg"
|
|
120
|
+
},
|
|
121
|
+
caption: null
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
const preview_close_event = listen("preview_close");
|
|
127
|
+
|
|
128
|
+
// Find the preview container and dispatch Escape key event
|
|
129
|
+
const preview = document.querySelector(".preview");
|
|
130
|
+
if (preview) {
|
|
131
|
+
const escapeEvent = new KeyboardEvent("keydown", {
|
|
132
|
+
code: "Escape",
|
|
133
|
+
key: "Escape",
|
|
134
|
+
bubbles: true
|
|
135
|
+
});
|
|
136
|
+
preview.dispatchEvent(escapeEvent);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
assert.isTrue(
|
|
140
|
+
preview_close_event.callCount >= 1,
|
|
141
|
+
"preview_close event should be triggered when pressing Escape"
|
|
142
|
+
);
|
|
143
|
+
});
|
|
107
144
|
});
|
package/Index.svelte
CHANGED
|
@@ -152,12 +152,22 @@
|
|
|
152
152
|
allow_preview={gradio.props.allow_preview}
|
|
153
153
|
bind:selected_index={gradio.props.selected_index}
|
|
154
154
|
bind:value={gradio.props.value}
|
|
155
|
-
show_share_button={gradio.props.buttons.
|
|
156
|
-
|
|
155
|
+
show_share_button={gradio.props.buttons.some(
|
|
156
|
+
(btn) => typeof btn === "string" && btn === "share"
|
|
157
|
+
)}
|
|
158
|
+
show_download_button={gradio.props.buttons.some(
|
|
159
|
+
(btn) => typeof btn === "string" && btn === "download"
|
|
160
|
+
)}
|
|
157
161
|
fit_columns={gradio.props.fit_columns}
|
|
158
162
|
i18n={gradio.i18n}
|
|
159
163
|
_fetch={(...args) => gradio.shared.client.fetch(...args)}
|
|
160
|
-
show_fullscreen_button={gradio.props.buttons.
|
|
164
|
+
show_fullscreen_button={gradio.props.buttons.some(
|
|
165
|
+
(btn) => typeof btn === "string" && btn === "fullscreen"
|
|
166
|
+
)}
|
|
167
|
+
buttons={gradio.props.buttons}
|
|
168
|
+
on_custom_button_click={(id) => {
|
|
169
|
+
gradio.dispatch("custom_button_click", { id });
|
|
170
|
+
}}
|
|
161
171
|
{fullscreen}
|
|
162
172
|
root={gradio.shared.root}
|
|
163
173
|
file_types={gradio.props.file_types}
|
package/dist/Index.svelte
CHANGED
|
@@ -152,12 +152,22 @@
|
|
|
152
152
|
allow_preview={gradio.props.allow_preview}
|
|
153
153
|
bind:selected_index={gradio.props.selected_index}
|
|
154
154
|
bind:value={gradio.props.value}
|
|
155
|
-
show_share_button={gradio.props.buttons.
|
|
156
|
-
|
|
155
|
+
show_share_button={gradio.props.buttons.some(
|
|
156
|
+
(btn) => typeof btn === "string" && btn === "share"
|
|
157
|
+
)}
|
|
158
|
+
show_download_button={gradio.props.buttons.some(
|
|
159
|
+
(btn) => typeof btn === "string" && btn === "download"
|
|
160
|
+
)}
|
|
157
161
|
fit_columns={gradio.props.fit_columns}
|
|
158
162
|
i18n={gradio.i18n}
|
|
159
163
|
_fetch={(...args) => gradio.shared.client.fetch(...args)}
|
|
160
|
-
show_fullscreen_button={gradio.props.buttons.
|
|
164
|
+
show_fullscreen_button={gradio.props.buttons.some(
|
|
165
|
+
(btn) => typeof btn === "string" && btn === "fullscreen"
|
|
166
|
+
)}
|
|
167
|
+
buttons={gradio.props.buttons}
|
|
168
|
+
on_custom_button_click={(id) => {
|
|
169
|
+
gradio.dispatch("custom_button_click", { id });
|
|
170
|
+
}}
|
|
161
171
|
{fullscreen}
|
|
162
172
|
root={gradio.shared.root}
|
|
163
173
|
file_types={gradio.props.file_types}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
IconButtonWrapper,
|
|
8
8
|
FullscreenButton
|
|
9
9
|
} from "@gradio/atoms";
|
|
10
|
+
import type { CustomButton as CustomButtonType } from "@gradio/utils";
|
|
10
11
|
import { ModifyUpload, Upload as UploadComponent } from "@gradio/upload";
|
|
11
12
|
import type { SelectData } from "@gradio/utils";
|
|
12
13
|
import { Image } from "@gradio/image/shared";
|
|
@@ -57,6 +58,8 @@
|
|
|
57
58
|
export let stream_handler: Client["stream"] | undefined = undefined;
|
|
58
59
|
export let fit_columns = true;
|
|
59
60
|
export let upload_promise: Promise<any> | null = null;
|
|
61
|
+
export let buttons: (string | CustomButtonType)[] | null = null;
|
|
62
|
+
export let on_custom_button_click: ((id: number) => void) | null = null;
|
|
60
63
|
|
|
61
64
|
let is_full_screen = false;
|
|
62
65
|
let image_container: HTMLElement;
|
|
@@ -161,6 +164,7 @@
|
|
|
161
164
|
case "Escape":
|
|
162
165
|
e.preventDefault();
|
|
163
166
|
selected_index = null;
|
|
167
|
+
dispatch("preview_close");
|
|
164
168
|
break;
|
|
165
169
|
case "ArrowLeft":
|
|
166
170
|
e.preventDefault();
|
|
@@ -330,6 +334,8 @@
|
|
|
330
334
|
>
|
|
331
335
|
<IconButtonWrapper
|
|
332
336
|
display_top_corner={display_icon_button_wrapper_top_corner}
|
|
337
|
+
{buttons}
|
|
338
|
+
{on_custom_button_click}
|
|
333
339
|
>
|
|
334
340
|
{#if show_download_button}
|
|
335
341
|
<IconButton
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CustomButton as CustomButtonType } from "@gradio/utils";
|
|
1
2
|
import type { SelectData } from "@gradio/utils";
|
|
2
3
|
import type { GalleryImage, GalleryVideo } from "../types";
|
|
3
4
|
import { FileData } from "@gradio/client";
|
|
@@ -43,6 +44,8 @@ declare const Gallery: $$__sveltets_2_IsomorphicComponent<{
|
|
|
43
44
|
stream_handler?: Client["stream"] | undefined;
|
|
44
45
|
fit_columns?: boolean;
|
|
45
46
|
upload_promise?: Promise<any> | null;
|
|
47
|
+
buttons?: (string | CustomButtonType)[] | null;
|
|
48
|
+
on_custom_button_click?: ((id: number) => void) | null;
|
|
46
49
|
}, {
|
|
47
50
|
fullscreen: CustomEvent<any>;
|
|
48
51
|
share: CustomEvent<import("@gradio/utils").ShareData>;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { FileData, SelectData } from "@gradio/client";
|
|
2
|
+
import type { CustomButton } from "@gradio/utils";
|
|
2
3
|
export interface GalleryImage {
|
|
3
4
|
image: FileData;
|
|
4
5
|
caption: string | null;
|
|
@@ -18,7 +19,7 @@ export interface GalleryProps {
|
|
|
18
19
|
allow_preview: boolean;
|
|
19
20
|
selected_index: number | null;
|
|
20
21
|
object_fit: "contain" | "cover" | "fill" | "none" | "scale-down";
|
|
21
|
-
buttons: string[];
|
|
22
|
+
buttons: (string | CustomButton)[];
|
|
22
23
|
type: "numpy" | "pil" | "filepath";
|
|
23
24
|
fit_columns: boolean;
|
|
24
25
|
}
|
|
@@ -35,4 +36,7 @@ export interface GalleryEvents {
|
|
|
35
36
|
clear_status: any;
|
|
36
37
|
share: any;
|
|
37
38
|
error: any;
|
|
39
|
+
custom_button_click: {
|
|
40
|
+
id: number;
|
|
41
|
+
};
|
|
38
42
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradio/gallery",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.1",
|
|
4
4
|
"description": "Gradio UI packages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "",
|
|
@@ -8,15 +8,15 @@
|
|
|
8
8
|
"private": false,
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"dequal": "^2.0.3",
|
|
11
|
-
"@gradio/atoms": "^0.
|
|
12
|
-
"@gradio/
|
|
13
|
-
"@gradio/
|
|
14
|
-
"@gradio/
|
|
11
|
+
"@gradio/atoms": "^0.20.0",
|
|
12
|
+
"@gradio/file": "^0.14.0",
|
|
13
|
+
"@gradio/image": "^0.25.0",
|
|
14
|
+
"@gradio/client": "^2.0.2",
|
|
15
|
+
"@gradio/statustracker": "^0.12.1",
|
|
15
16
|
"@gradio/icons": "^0.15.0",
|
|
16
|
-
"@gradio/
|
|
17
|
-
"@gradio/
|
|
18
|
-
"@gradio/
|
|
19
|
-
"@gradio/video": "^0.18.0"
|
|
17
|
+
"@gradio/upload": "^0.17.3",
|
|
18
|
+
"@gradio/utils": "^0.11.1",
|
|
19
|
+
"@gradio/video": "^0.20.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@gradio/preview": "^0.15.1"
|
package/shared/Gallery.svelte
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
IconButtonWrapper,
|
|
8
8
|
FullscreenButton
|
|
9
9
|
} from "@gradio/atoms";
|
|
10
|
+
import type { CustomButton as CustomButtonType } from "@gradio/utils";
|
|
10
11
|
import { ModifyUpload, Upload as UploadComponent } from "@gradio/upload";
|
|
11
12
|
import type { SelectData } from "@gradio/utils";
|
|
12
13
|
import { Image } from "@gradio/image/shared";
|
|
@@ -57,6 +58,8 @@
|
|
|
57
58
|
export let stream_handler: Client["stream"] | undefined = undefined;
|
|
58
59
|
export let fit_columns = true;
|
|
59
60
|
export let upload_promise: Promise<any> | null = null;
|
|
61
|
+
export let buttons: (string | CustomButtonType)[] | null = null;
|
|
62
|
+
export let on_custom_button_click: ((id: number) => void) | null = null;
|
|
60
63
|
|
|
61
64
|
let is_full_screen = false;
|
|
62
65
|
let image_container: HTMLElement;
|
|
@@ -161,6 +164,7 @@
|
|
|
161
164
|
case "Escape":
|
|
162
165
|
e.preventDefault();
|
|
163
166
|
selected_index = null;
|
|
167
|
+
dispatch("preview_close");
|
|
164
168
|
break;
|
|
165
169
|
case "ArrowLeft":
|
|
166
170
|
e.preventDefault();
|
|
@@ -330,6 +334,8 @@
|
|
|
330
334
|
>
|
|
331
335
|
<IconButtonWrapper
|
|
332
336
|
display_top_corner={display_icon_button_wrapper_top_corner}
|
|
337
|
+
{buttons}
|
|
338
|
+
{on_custom_button_click}
|
|
333
339
|
>
|
|
334
340
|
{#if show_download_button}
|
|
335
341
|
<IconButton
|
package/types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { FileData, SelectData } from "@gradio/client";
|
|
2
|
+
import type { CustomButton } from "@gradio/utils";
|
|
2
3
|
|
|
3
4
|
export interface GalleryImage {
|
|
4
5
|
image: FileData;
|
|
@@ -22,7 +23,7 @@ export interface GalleryProps {
|
|
|
22
23
|
allow_preview: boolean;
|
|
23
24
|
selected_index: number | null;
|
|
24
25
|
object_fit: "contain" | "cover" | "fill" | "none" | "scale-down";
|
|
25
|
-
buttons: string[];
|
|
26
|
+
buttons: (string | CustomButton)[];
|
|
26
27
|
type: "numpy" | "pil" | "filepath";
|
|
27
28
|
fit_columns: boolean;
|
|
28
29
|
}
|
|
@@ -37,4 +38,5 @@ export interface GalleryEvents {
|
|
|
37
38
|
clear_status: any;
|
|
38
39
|
share: any;
|
|
39
40
|
error: any;
|
|
41
|
+
custom_button_click: { id: number };
|
|
40
42
|
}
|