@gradio/gallery 0.12.0 → 0.13.0-beta.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 CHANGED
@@ -1,5 +1,58 @@
1
1
  # @gradio/gallery
2
2
 
3
+ ## 0.13.0-beta.1
4
+
5
+ ### Dependency updates
6
+
7
+ - @gradio/video@0.11.0-beta.1
8
+ - @gradio/atoms@0.8.1-beta.1
9
+ - @gradio/icons@0.8.0-beta.1
10
+ - @gradio/statustracker@0.8.0-beta.1
11
+ - @gradio/utils@0.7.0-beta.1
12
+ - @gradio/client@1.6.0-beta.1
13
+ - @gradio/image@0.16.0-beta.1
14
+ - @gradio/upload@0.12.4-beta.1
15
+ - @gradio/file@0.9.4-beta.1
16
+
17
+ ## 0.13.0-beta.0
18
+
19
+ ### Features
20
+
21
+ - [#9052](https://github.com/gradio-app/gradio/pull/9052) [`f3652eb`](https://github.com/gradio-app/gradio/commit/f3652ebe08211e12739df73c15fd97e5ff81276a) - Video gallery. Thanks @dawoodkhan82!
22
+
23
+ ### Fixes
24
+
25
+ - [#9163](https://github.com/gradio-app/gradio/pull/9163) [`2b6cbf2`](https://github.com/gradio-app/gradio/commit/2b6cbf25908e42cf027324e54ef2cc0baad11a91) - fix exports and generate types. Thanks @pngwn!
26
+
27
+ ### Dependency updates
28
+
29
+ - @gradio/utils@0.7.0-beta.0
30
+ - @gradio/statustracker@0.8.0-beta.0
31
+ - @gradio/atoms@0.8.1-beta.0
32
+ - @gradio/client@1.6.0-beta.0
33
+ - @gradio/icons@0.8.0-beta.0
34
+ - @gradio/upload@0.12.4-beta.0
35
+ - @gradio/image@0.16.0-beta.0
36
+ - @gradio/video@0.11.0-beta.0
37
+ - @gradio/file@0.9.4-beta.0
38
+
39
+ ## 0.12.1
40
+
41
+ ### Features
42
+
43
+ - [#9118](https://github.com/gradio-app/gradio/pull/9118) [`e1c404d`](https://github.com/gradio-app/gradio/commit/e1c404da1143fb52b659d03e028bdba1badf443d) - setup npm-previews of all packages. Thanks @pngwn!
44
+
45
+ ### Dependency updates
46
+
47
+ - @gradio/utils@0.6.0
48
+ - @gradio/upload@0.12.3
49
+ - @gradio/atoms@0.8.0
50
+ - @gradio/client@1.5.1
51
+ - @gradio/statustracker@0.7.5
52
+ - @gradio/icons@0.7.1
53
+ - @gradio/image@0.15.0
54
+ - @gradio/file@0.9.3
55
+
3
56
  ## 0.12.0
4
57
 
5
58
  ### Features
@@ -86,6 +86,14 @@
86
86
  },
87
87
  caption: "A fast cheetah"
88
88
  },
89
+ {
90
+ video: {
91
+ path: "https://gradio-builds.s3.amazonaws.com/demo-files/world.mp4",
92
+ url: "https://gradio-builds.s3.amazonaws.com/demo-files/world.mp4",
93
+ orig_name: "world.mp4"
94
+ },
95
+ caption: "The world"
96
+ },
89
97
  {
90
98
  image: {
91
99
  path: "https://gradio-builds.s3.amazonaws.com/demo-files/cheetah-002.jpg",
@@ -139,7 +147,7 @@
139
147
  play={async ({ canvasElement }) => {
140
148
  const canvas = within(canvasElement);
141
149
 
142
- const image = canvas.getByLabelText("Thumbnail 1 of 7");
150
+ const image = canvas.getByLabelText("Thumbnail 1 of 8");
143
151
  await userEvent.click(image);
144
152
  const expand_btn = canvas.getByRole("button", {
145
153
  name: "View in full screen"
package/Gallery.test.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { test, describe, assert, afterEach, vi } from "vitest";
2
- import { cleanup, render } from "@gradio/tootils";
3
- import { setupi18n } from "../app/src/i18n";
2
+ import { cleanup, render } from "@self/tootils";
3
+ import { setupi18n } from "../core/src/i18n";
4
4
 
5
5
  import Gallery from "./Index.svelte";
6
6
  import type { LoadingStatus } from "@gradio/statustracker";
@@ -33,8 +33,8 @@ describe("Gallery", () => {
33
33
  value: [
34
34
  {
35
35
  image: {
36
- path: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/a.mp4",
37
- url: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/a.mp4"
36
+ path: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/gallery_component/files/cheetah.jpg",
37
+ url: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/gallery_component/files/cheetah.jpg"
38
38
  },
39
39
  caption: null
40
40
  }
@@ -43,7 +43,30 @@ describe("Gallery", () => {
43
43
  let item = getByTestId("detailed-image") as HTMLImageElement;
44
44
  assert.equal(
45
45
  item.src,
46
- "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/a.mp4"
46
+ "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/gallery_component/files/cheetah.jpg"
47
+ );
48
+ });
49
+
50
+ test("renders the video provided", async () => {
51
+ const { getByTestId } = await render(Gallery, {
52
+ show_label: true,
53
+ label: "Gallery",
54
+ loading_status: loading_status,
55
+ preview: true,
56
+ value: [
57
+ {
58
+ video: {
59
+ path: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/gallery_component/files/world.mp4",
60
+ url: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/gallery_component/files/world.mp4"
61
+ },
62
+ caption: null
63
+ }
64
+ ]
65
+ });
66
+ let item = getByTestId("detailed-video") as HTMLVideoElement;
67
+ assert.equal(
68
+ item.src,
69
+ "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/gallery_component/files/world.mp4"
47
70
  );
48
71
  });
49
72
 
@@ -56,8 +79,8 @@ describe("Gallery", () => {
56
79
  value: [
57
80
  {
58
81
  image: {
59
- path: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/a.mp4",
60
- url: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/a.mp4"
82
+ path: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/gallery_component/files/cheetah.jpg",
83
+ url: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/gallery_component/files/cheetah.jpg"
61
84
  },
62
85
  caption: null
63
86
  }
@@ -69,8 +92,8 @@ describe("Gallery", () => {
69
92
  value: [
70
93
  {
71
94
  image: {
72
- path: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/a.mp4",
73
- url: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/a.mp4"
95
+ path: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/gallery_component/files/cheetah.jpg",
96
+ url: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/gallery_component/files/cheetah.jpg"
74
97
  },
75
98
  caption: null
76
99
  }
package/Index.svelte CHANGED
@@ -3,15 +3,17 @@
3
3
  </script>
4
4
 
5
5
  <script lang="ts">
6
+ import type { GalleryImage, GalleryVideo } from "./types";
6
7
  import type { Gradio, ShareData, SelectData } from "@gradio/utils";
7
8
  import { Block, UploadText } from "@gradio/atoms";
8
9
  import Gallery from "./shared/Gallery.svelte";
9
10
  import type { LoadingStatus } from "@gradio/statustracker";
10
11
  import { StatusTracker } from "@gradio/statustracker";
11
- import type { FileData } from "@gradio/client";
12
12
  import { createEventDispatcher } from "svelte";
13
13
  import { BaseFileUpload } from "@gradio/file";
14
14
 
15
+ type GalleryData = GalleryImage | GalleryVideo;
16
+
15
17
  export let loading_status: LoadingStatus;
16
18
  export let show_label: boolean;
17
19
  export let label: string;
@@ -19,7 +21,8 @@
19
21
  export let elem_id = "";
20
22
  export let elem_classes: string[] = [];
21
23
  export let visible = true;
22
- export let value: { image: FileData; caption: string | null }[] | null = null;
24
+ export let value: GalleryData[] | null = null;
25
+ export let file_types: string[] | null = ["image", "video"];
23
26
  export let container = true;
24
27
  export let scale: number | null = null;
25
28
  export let min_width: number | undefined = undefined;
@@ -47,7 +50,7 @@
47
50
 
48
51
  const dispatch = createEventDispatcher();
49
52
 
50
- $: no_value = Array.isArray(value) ? value.length === 0 : !value;
53
+ $: no_value = value === null ? true : value.length === 0;
51
54
  $: selected_index, dispatch("prop_change", { selected_index });
52
55
  </script>
53
56
 
@@ -76,13 +79,17 @@
76
79
  {label}
77
80
  max_file_size={gradio.max_file_size}
78
81
  file_count={"multiple"}
79
- file_types={["image"]}
82
+ {file_types}
80
83
  i18n={gradio.i18n}
81
84
  upload={gradio.client.upload}
82
85
  stream_handler={gradio.client.stream}
83
86
  on:upload={(e) => {
84
87
  const files = Array.isArray(e.detail) ? e.detail : [e.detail];
85
- value = files.map((x) => ({ image: x, caption: null }));
88
+ value = files.map((x) =>
89
+ x.mime_type?.includes("video")
90
+ ? { video: x, caption: null }
91
+ : { image: x, caption: null }
92
+ );
86
93
  gradio.dispatch("upload", value);
87
94
  }}
88
95
  on:error={({ detail }) => {
@@ -0,0 +1,110 @@
1
+ <script context="module">export { default as BaseGallery } from "./shared/Gallery.svelte";
2
+ </script>
3
+
4
+ <script>import { Block, UploadText } from "@gradio/atoms";
5
+ import Gallery from "./shared/Gallery.svelte";
6
+ import { StatusTracker } from "@gradio/statustracker";
7
+ import { createEventDispatcher } from "svelte";
8
+ import { BaseFileUpload } from "@gradio/file";
9
+ export let loading_status;
10
+ export let show_label;
11
+ export let label;
12
+ export let root;
13
+ export let elem_id = "";
14
+ export let elem_classes = [];
15
+ export let visible = true;
16
+ export let value = null;
17
+ export let file_types = ["image", "video"];
18
+ export let container = true;
19
+ export let scale = null;
20
+ export let min_width = void 0;
21
+ export let columns = [2];
22
+ export let rows = void 0;
23
+ export let height = "auto";
24
+ export let preview;
25
+ export let allow_preview = true;
26
+ export let selected_index = null;
27
+ export let object_fit = "cover";
28
+ export let show_share_button = false;
29
+ export let interactive;
30
+ export let show_download_button = false;
31
+ export let gradio;
32
+ export let show_fullscreen_button = true;
33
+ const dispatch = createEventDispatcher();
34
+ $:
35
+ no_value = value === null ? true : value.length === 0;
36
+ $:
37
+ selected_index, dispatch("prop_change", { selected_index });
38
+ </script>
39
+
40
+ <Block
41
+ {visible}
42
+ variant="solid"
43
+ padding={false}
44
+ {elem_id}
45
+ {elem_classes}
46
+ {container}
47
+ {scale}
48
+ {min_width}
49
+ allow_overflow={false}
50
+ height={typeof height === "number" ? height : undefined}
51
+ >
52
+ <StatusTracker
53
+ autoscroll={gradio.autoscroll}
54
+ i18n={gradio.i18n}
55
+ {...loading_status}
56
+ on:clear_status={() => gradio.dispatch("clear_status", loading_status)}
57
+ />
58
+ {#if interactive && no_value}
59
+ <BaseFileUpload
60
+ value={null}
61
+ {root}
62
+ {label}
63
+ max_file_size={gradio.max_file_size}
64
+ file_count={"multiple"}
65
+ {file_types}
66
+ i18n={gradio.i18n}
67
+ upload={gradio.client.upload}
68
+ stream_handler={gradio.client.stream}
69
+ on:upload={(e) => {
70
+ const files = Array.isArray(e.detail) ? e.detail : [e.detail];
71
+ value = files.map((x) =>
72
+ x.mime_type?.includes("video")
73
+ ? { video: x, caption: null }
74
+ : { image: x, caption: null }
75
+ );
76
+ gradio.dispatch("upload", value);
77
+ }}
78
+ on:error={({ detail }) => {
79
+ loading_status = loading_status || {};
80
+ loading_status.status = "error";
81
+ gradio.dispatch("error", detail);
82
+ }}
83
+ >
84
+ <UploadText i18n={gradio.i18n} type="gallery" />
85
+ </BaseFileUpload>
86
+ {:else}
87
+ <Gallery
88
+ on:change={() => gradio.dispatch("change", value)}
89
+ on:select={(e) => gradio.dispatch("select", e.detail)}
90
+ on:share={(e) => gradio.dispatch("share", e.detail)}
91
+ on:error={(e) => gradio.dispatch("error", e.detail)}
92
+ {label}
93
+ {show_label}
94
+ {columns}
95
+ {rows}
96
+ {height}
97
+ {preview}
98
+ {object_fit}
99
+ {interactive}
100
+ {allow_preview}
101
+ bind:selected_index
102
+ bind:value
103
+ {show_share_button}
104
+ {show_download_button}
105
+ i18n={gradio.i18n}
106
+ _fetch={gradio.client.fetch}
107
+ {show_fullscreen_button}
108
+ />
109
+ {/if}
110
+ </Block>
@@ -0,0 +1,52 @@
1
+ import { SvelteComponent } from "svelte";
2
+ export { default as BaseGallery } from "./shared/Gallery.svelte";
3
+ import type { GalleryImage, GalleryVideo } from "./types";
4
+ import type { Gradio, ShareData, SelectData } from "@gradio/utils";
5
+ import type { LoadingStatus } from "@gradio/statustracker";
6
+ declare const __propDef: {
7
+ props: {
8
+ loading_status: LoadingStatus;
9
+ show_label: boolean;
10
+ label: string;
11
+ root: string;
12
+ elem_id?: string | undefined;
13
+ elem_classes?: string[] | undefined;
14
+ visible?: boolean | undefined;
15
+ value?: ((GalleryImage | GalleryVideo)[] | null) | undefined;
16
+ file_types?: (string[] | null) | undefined;
17
+ container?: boolean | undefined;
18
+ scale?: (number | null) | undefined;
19
+ min_width?: number | undefined;
20
+ columns?: number | number[] | undefined;
21
+ rows?: number | number[] | undefined;
22
+ height?: (number | "auto") | undefined;
23
+ preview: boolean;
24
+ allow_preview?: boolean | undefined;
25
+ selected_index?: (number | null) | undefined;
26
+ object_fit?: ("contain" | "cover" | "fill" | "none" | "scale-down") | undefined;
27
+ show_share_button?: boolean | undefined;
28
+ interactive: boolean;
29
+ show_download_button?: boolean | undefined;
30
+ gradio: Gradio<{
31
+ change: (GalleryImage | GalleryVideo)[] | null;
32
+ upload: (GalleryImage | GalleryVideo)[] | null;
33
+ select: SelectData;
34
+ share: ShareData;
35
+ error: string;
36
+ prop_change: Record<string, any>;
37
+ clear_status: LoadingStatus;
38
+ }>;
39
+ show_fullscreen_button?: boolean | undefined;
40
+ };
41
+ events: {
42
+ prop_change: CustomEvent<any>;
43
+ } & {
44
+ [evt: string]: CustomEvent<any>;
45
+ };
46
+ slots: {};
47
+ };
48
+ export type IndexProps = typeof __propDef.props;
49
+ export type IndexEvents = typeof __propDef.events;
50
+ export type IndexSlots = typeof __propDef.slots;
51
+ export default class Index extends SvelteComponent<IndexProps, IndexEvents, IndexSlots> {
52
+ }