@gradio/file 0.14.8 → 0.15.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,42 @@
1
1
  # @gradio/file
2
2
 
3
+ ## 0.15.1
4
+
5
+ ### Dependency updates
6
+
7
+ - @gradio/statustracker@0.15.1
8
+ - @gradio/icons@0.16.0
9
+ - @gradio/atoms@0.26.0
10
+ - @gradio/client@2.3.1
11
+ - @gradio/upload@0.18.1
12
+
13
+ ## 0.15.0
14
+
15
+ ### Features
16
+
17
+ - [#13526](https://github.com/gradio-app/gradio/pull/13526) [`53cb4ca`](https://github.com/gradio-app/gradio/commit/53cb4cae1ec3521e9170d12867253516413ba37a) - Run `pnpm lint` and `pnpm ts:check` on CI. Thanks @abidlabs!
18
+
19
+ ### Dependency updates
20
+
21
+ - @gradio/atoms@0.25.0
22
+ - @gradio/statustracker@0.15.0
23
+ - @gradio/utils@0.13.0
24
+ - @gradio/client@2.3.0
25
+ - @gradio/upload@0.18.0
26
+
27
+ ## 0.14.8
28
+
29
+ ### Dependency updates
30
+
31
+ - @gradio/client@2.2.2
32
+
33
+ ## 0.14.8
34
+
35
+ ### Dependency updates
36
+
37
+ - @gradio/client@2.2.1
38
+ - @gradio/upload@0.17.10
39
+
3
40
  ## 0.14.8
4
41
 
5
42
  ### Dependency updates
@@ -60,8 +60,3 @@
60
60
  }}
61
61
  {template}
62
62
  />
63
- <Story
64
- name="File upload with height set to 400px"
65
- args={{ interactive: true, value: null, height: 400 }}
66
- {template}
67
- />
package/File.test.ts CHANGED
@@ -1,11 +1,15 @@
1
- import { describe, test, expect, vi } from "vitest";
1
+ import { describe, test, expect, vi, afterEach } from "vitest";
2
2
  import {
3
3
  render,
4
4
  download_file,
5
5
  upload_file,
6
6
  drop_file,
7
+ cleanup,
7
8
  mock_client,
8
- TEST_TXT
9
+ TEST_TXT,
10
+ TEST_JPG,
11
+ TEST_MP4,
12
+ TEST_PDF
9
13
  } from "@self/tootils/render";
10
14
  import File from "./Index.svelte";
11
15
 
@@ -21,6 +25,8 @@ const default_props = {
21
25
  };
22
26
 
23
27
  describe("File", () => {
28
+ afterEach(() => cleanup());
29
+
24
30
  test("download link triggers a real file download with correct content", async () => {
25
31
  await render(File, {
26
32
  ...default_props,
@@ -50,4 +56,40 @@ describe("File", () => {
50
56
 
51
57
  await vi.waitFor(() => expect(upload).toHaveBeenCalled());
52
58
  });
59
+
60
+ test("file_types accepts image category uploads", async () => {
61
+ const { listen } = await render(File, {
62
+ ...default_props,
63
+ file_types: ["image", "video"]
64
+ });
65
+
66
+ const upload = listen("upload");
67
+ await upload_file(TEST_JPG);
68
+
69
+ await vi.waitFor(() => expect(upload).toHaveBeenCalledTimes(1));
70
+ });
71
+
72
+ test("file_types accepts video category uploads", async () => {
73
+ const { listen } = await render(File, {
74
+ ...default_props,
75
+ file_types: ["image", "video"]
76
+ });
77
+
78
+ const upload = listen("upload");
79
+ await upload_file(TEST_MP4);
80
+
81
+ await vi.waitFor(() => expect(upload).toHaveBeenCalledTimes(1));
82
+ });
83
+
84
+ test("file_types accepts dot-prefixed extension uploads", async () => {
85
+ const { listen } = await render(File, {
86
+ ...default_props,
87
+ file_types: [".pdf"]
88
+ });
89
+
90
+ const upload = listen("upload");
91
+ await upload_file(TEST_PDF);
92
+
93
+ await vi.waitFor(() => expect(upload).toHaveBeenCalledTimes(1));
94
+ });
53
95
  });
@@ -69,8 +69,3 @@
69
69
  }}
70
70
  {template}
71
71
  />
72
- <Story
73
- name="No value"
74
- args={{ value: null, file_count: "multiple", interactive: true }}
75
- {template}
76
- />
package/Index.svelte CHANGED
@@ -71,8 +71,8 @@
71
71
  />
72
72
  {#if !gradio.shared.interactive}
73
73
  <File
74
- on_select={({ detail }) => gradio.dispatch("select", detail)}
75
- on_download={({ detail }) => gradio.dispatch("download", detail)}
74
+ on_select={(detail) => gradio.dispatch("select", detail)}
75
+ on_download={(file) => gradio.dispatch("download", file)}
76
76
  selectable={gradio.props._selectable}
77
77
  value={gradio.props.value}
78
78
  label={gradio.shared.label}
@@ -80,7 +80,7 @@
80
80
  height={gradio.props.height}
81
81
  i18n={gradio.i18n}
82
82
  buttons={gradio.props.buttons}
83
- on_custom_button_click={(id) => {
83
+ on_custom_button_click={(id: number) => {
84
84
  gradio.dispatch("custom_button_click", { id });
85
85
  }}
86
86
  />
package/dist/Index.svelte CHANGED
@@ -71,8 +71,8 @@
71
71
  />
72
72
  {#if !gradio.shared.interactive}
73
73
  <File
74
- on_select={({ detail }) => gradio.dispatch("select", detail)}
75
- on_download={({ detail }) => gradio.dispatch("download", detail)}
74
+ on_select={(detail) => gradio.dispatch("select", detail)}
75
+ on_download={(file) => gradio.dispatch("download", file)}
76
76
  selectable={gradio.props._selectable}
77
77
  value={gradio.props.value}
78
78
  label={gradio.shared.label}
@@ -80,7 +80,7 @@
80
80
  height={gradio.props.height}
81
81
  i18n={gradio.i18n}
82
82
  buttons={gradio.props.buttons}
83
- on_custom_button_click={(id) => {
83
+ on_custom_button_click={(id: number) => {
84
84
  gradio.dispatch("custom_button_click", { id });
85
85
  }}
86
86
  />
@@ -3,6 +3,8 @@
3
3
  import { File } from "@gradio/icons";
4
4
  import FilePreview from "./FilePreview.svelte";
5
5
  import type { CustomButton as CustomButtonType } from "@gradio/utils";
6
+ import type { FileData } from "@gradio/client";
7
+ import type { I18nFormatter, SelectData } from "@gradio/utils";
6
8
 
7
9
  let {
8
10
  value,
@@ -15,6 +17,17 @@
15
17
  on_custom_button_click = null,
16
18
  on_select,
17
19
  on_download
20
+ }: {
21
+ value: FileData | FileData[] | null;
22
+ label?: string | null;
23
+ show_label?: boolean;
24
+ selectable?: boolean;
25
+ i18n: I18nFormatter;
26
+ height?: number | string | null;
27
+ buttons?: (string | CustomButtonType)[] | null;
28
+ on_custom_button_click?: ((id: number) => void) | null;
29
+ on_select?: (event_data: SelectData) => void;
30
+ on_download?: (event_data: FileData) => void;
18
31
  } = $props();
19
32
  </script>
20
33
 
@@ -32,10 +45,10 @@
32
45
  <FilePreview
33
46
  {i18n}
34
47
  {selectable}
35
- on:select={on_select}
36
- on:download={on_download}
48
+ onselect={on_select}
49
+ ondownload={on_download}
37
50
  {value}
38
- {height}
51
+ height={height ?? undefined}
39
52
  />
40
53
  {:else}
41
54
  <Empty unpadded_box={true} size="large"><File /></Empty>
@@ -1,15 +1,19 @@
1
1
  import { File } from "@gradio/icons";
2
- declare const File: import("svelte").Component<{
3
- value: any;
4
- label: any;
5
- show_label: any;
6
- selectable: any;
7
- i18n: any;
8
- height: any;
9
- buttons?: any;
10
- on_custom_button_click?: any;
11
- on_select: any;
12
- on_download: any;
13
- }, {}, "">;
2
+ import type { CustomButton as CustomButtonType } from "@gradio/utils";
3
+ import type { FileData } from "@gradio/client";
4
+ import type { I18nFormatter, SelectData } from "@gradio/utils";
5
+ type $$ComponentProps = {
6
+ value: FileData | FileData[] | null;
7
+ label?: string | null;
8
+ show_label?: boolean;
9
+ selectable?: boolean;
10
+ i18n: I18nFormatter;
11
+ height?: number | string | null;
12
+ buttons?: (string | CustomButtonType)[] | null;
13
+ on_custom_button_click?: ((id: number) => void) | null;
14
+ on_select?: (event_data: SelectData) => void;
15
+ on_download?: (event_data: FileData) => void;
16
+ };
17
+ declare const File: import("svelte").Component<$$ComponentProps, {}, "">;
14
18
  type File = ReturnType<typeof File>;
15
19
  export default File;
package/dist/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { FileData } from "@gradio/client";
2
- import type { LoadingStatus } from "js/statustracker";
2
+ import type { ILoadingStatus as LoadingStatus } from "js/statustracker";
3
3
  import type { SelectData, CustomButton } from "@gradio/utils";
4
4
  export interface FileProps {
5
5
  value: FileData | FileData[] | null;
@@ -13,7 +13,7 @@ export interface FileProps {
13
13
  }
14
14
  export interface FileEvents {
15
15
  upload: FileData | FileData[];
16
- download: void;
16
+ download: FileData;
17
17
  error: string;
18
18
  clear_status: LoadingStatus;
19
19
  clear: void;
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@gradio/file",
3
- "version": "0.14.8",
3
+ "version": "0.15.1",
4
4
  "description": "Gradio UI packages",
5
5
  "type": "module",
6
6
  "author": "",
7
7
  "license": "ISC",
8
8
  "private": false,
9
9
  "dependencies": {
10
- "@gradio/atoms": "^0.24.0",
11
- "@gradio/client": "^2.2.0",
12
- "@gradio/icons": "^0.15.1",
13
- "@gradio/upload": "^0.17.9",
14
- "@gradio/statustracker": "^0.14.1",
15
- "@gradio/utils": "^0.12.2"
10
+ "@gradio/atoms": "^0.26.0",
11
+ "@gradio/client": "^2.3.1",
12
+ "@gradio/icons": "^0.16.0",
13
+ "@gradio/utils": "^0.13.0",
14
+ "@gradio/statustracker": "^0.15.1",
15
+ "@gradio/upload": "^0.18.1"
16
16
  },
17
17
  "devDependencies": {
18
18
  "@gradio/preview": "^0.16.2"
@@ -3,6 +3,8 @@
3
3
  import { File } from "@gradio/icons";
4
4
  import FilePreview from "./FilePreview.svelte";
5
5
  import type { CustomButton as CustomButtonType } from "@gradio/utils";
6
+ import type { FileData } from "@gradio/client";
7
+ import type { I18nFormatter, SelectData } from "@gradio/utils";
6
8
 
7
9
  let {
8
10
  value,
@@ -15,6 +17,17 @@
15
17
  on_custom_button_click = null,
16
18
  on_select,
17
19
  on_download
20
+ }: {
21
+ value: FileData | FileData[] | null;
22
+ label?: string | null;
23
+ show_label?: boolean;
24
+ selectable?: boolean;
25
+ i18n: I18nFormatter;
26
+ height?: number | string | null;
27
+ buttons?: (string | CustomButtonType)[] | null;
28
+ on_custom_button_click?: ((id: number) => void) | null;
29
+ on_select?: (event_data: SelectData) => void;
30
+ on_download?: (event_data: FileData) => void;
18
31
  } = $props();
19
32
  </script>
20
33
 
@@ -32,10 +45,10 @@
32
45
  <FilePreview
33
46
  {i18n}
34
47
  {selectable}
35
- on:select={on_select}
36
- on:download={on_download}
48
+ onselect={on_select}
49
+ ondownload={on_download}
37
50
  {value}
38
- {height}
51
+ height={height ?? undefined}
39
52
  />
40
53
  {:else}
41
54
  <Empty unpadded_box={true} size="large"><File /></Empty>
package/types.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { FileData } from "@gradio/client";
2
- import type { LoadingStatus } from "js/statustracker";
2
+ import type { ILoadingStatus as LoadingStatus } from "js/statustracker";
3
3
  import type { SelectData, CustomButton } from "@gradio/utils";
4
4
 
5
5
  export interface FileProps {
@@ -15,7 +15,7 @@ export interface FileProps {
15
15
 
16
16
  export interface FileEvents {
17
17
  upload: FileData | FileData[];
18
- download: void;
18
+ download: FileData;
19
19
  error: string;
20
20
  clear_status: LoadingStatus;
21
21
  clear: void;