@gradio/uploadbutton 0.4.7 → 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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # @gradio/uploadbutton
2
2
 
3
+ ## 0.5.0
4
+
5
+ ### Features
6
+
7
+ - [#7528](https://github.com/gradio-app/gradio/pull/7528) [`eda33b3`](https://github.com/gradio-app/gradio/commit/eda33b3763897a542acf298e523fa493dc655aee) - Refactors `get_fetchable_url_or_file()` to remove it from the frontend. Thanks [@abidlabs](https://github.com/abidlabs)!
8
+ - [#7518](https://github.com/gradio-app/gradio/pull/7518) [`bd2c695`](https://github.com/gradio-app/gradio/commit/bd2c69532801f9a0626cd1192de158bde6068b9a) - Adds a `gr.DownloadButton` component. Thanks [@abidlabs](https://github.com/abidlabs)!
9
+
3
10
  ## 0.4.7
4
11
 
5
12
  ### Patch Changes
@@ -318,4 +325,4 @@ Thanks [@pngwn](https://github.com/pngwn)!
318
325
  - Updated dependencies [[`61129052`](https://github.com/gradio-app/gradio/commit/61129052ed1391a75c825c891d57fa0ad6c09fc8), [`667875b2`](https://github.com/gradio-app/gradio/commit/667875b2441753e74d25bd9d3c8adedd8ede11cd), [`67265a58`](https://github.com/gradio-app/gradio/commit/67265a58027ef1f9e4c0eb849a532f72eaebde48), [`8b4eb8ca`](https://github.com/gradio-app/gradio/commit/8b4eb8cac9ea07bde31b44e2006ca2b7b5f4de36), [`37caa2e0`](https://github.com/gradio-app/gradio/commit/37caa2e0fe95d6cab8beb174580fb557904f137f)]:
319
326
  - @gradio/client@0.2.0
320
327
  - @gradio/upload@0.0.3
321
- - @gradio/button@0.1.0
328
+ - @gradio/button@0.1.0
package/Index.svelte CHANGED
@@ -17,7 +17,7 @@
17
17
  export let root: string;
18
18
  export let size: "sm" | "lg" = "lg";
19
19
  export let scale: number | null = null;
20
- export let icon: string | null = null;
20
+ export let icon: FileData | null = null;
21
21
  export let min_width: number | undefined = undefined;
22
22
  export let variant: "primary" | "secondary" | "stop" = "secondary";
23
23
  export let gradio: Gradio<{
@@ -26,7 +26,6 @@
26
26
  click: never;
27
27
  }>;
28
28
  export let interactive: boolean;
29
- export let proxy_url: null | string = null;
30
29
 
31
30
  $: disabled = !interactive;
32
31
 
@@ -54,7 +53,6 @@
54
53
  {disabled}
55
54
  {variant}
56
55
  {label}
57
- {proxy_url}
58
56
  on:click={() => gradio.dispatch("click")}
59
57
  on:change={({ detail }) => handle_event(detail, "change")}
60
58
  on:upload={({ detail }) => handle_event(detail, "upload")}
@@ -68,7 +68,10 @@
68
68
  name="Button with external image icon"
69
69
  args={{
70
70
  label: "Upload",
71
- icon: "https://huggingface.co/front/assets/huggingface_logo-noborder.svg"
71
+ icon: {
72
+ path: "https://huggingface.co/front/assets/huggingface_logo-noborder.svg",
73
+ url: "https://huggingface.co/front/assets/huggingface_logo-noborder.svg"
74
+ }
72
75
  }}
73
76
  />
74
77
  <Story
@@ -18,7 +18,6 @@ describe("UploadButton", () => {
18
18
 
19
19
  return {
20
20
  ...actual,
21
- get_fetchable_url_or_file: () => "",
22
21
  prepare_files: () => [],
23
22
  // upload: vi.fn((f) => new Promise((res) => res([]))),
24
23
  upload_files: vi.fn((f) => new Promise((res) => res({})))
@@ -51,7 +50,6 @@ describe("UploadButton", () => {
51
50
 
52
51
  return {
53
52
  ...actual,
54
- get_fetchable_url_or_file: () => "",
55
53
  prepare_files: () => [],
56
54
  // upload: vi.fn((f) => new Promise((res) => res([]))),
57
55
  upload_files: vi.fn((f) => new Promise((res) => res({})))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradio/uploadbutton",
3
- "version": "0.4.7",
3
+ "version": "0.5.0",
4
4
  "description": "Gradio UI packages",
5
5
  "type": "module",
6
6
  "author": "",
@@ -13,9 +13,9 @@
13
13
  },
14
14
  "main": "./Index.svelte",
15
15
  "dependencies": {
16
- "@gradio/button": "^0.2.22",
17
- "@gradio/utils": "^0.3.0",
18
- "@gradio/client": "^0.12.1",
19
- "@gradio/upload": "^0.7.4"
16
+ "@gradio/button": "^0.2.23",
17
+ "@gradio/client": "^0.12.2",
18
+ "@gradio/upload": "^0.7.5",
19
+ "@gradio/utils": "^0.3.0"
20
20
  }
21
21
  }
@@ -5,7 +5,6 @@
5
5
  upload,
6
6
  prepare_files,
7
7
  type FileData,
8
- get_fetchable_url_or_file,
9
8
  type upload_files
10
9
  } from "@gradio/client";
11
10
 
@@ -18,13 +17,11 @@
18
17
  export let file_types: string[] = [];
19
18
  export let root: string;
20
19
  export let size: "sm" | "lg" = "lg";
21
- export let icon: string | null = null;
20
+ export let icon: FileData | null = null;
22
21
  export let scale: number | null = null;
23
22
  export let min_width: number | undefined = undefined;
24
23
  export let variant: "primary" | "secondary" | "stop" = "secondary";
25
24
  export let disabled = false;
26
- export let proxy_url: string | null = null;
27
- $: icon_path = get_fetchable_url_or_file(icon, root, proxy_url);
28
25
 
29
26
  const dispatch = createEventDispatcher();
30
27
 
@@ -46,12 +43,12 @@
46
43
  accept_file_types = file_types.join(", ");
47
44
  }
48
45
 
49
- function openFileUpload(): void {
46
+ function open_file_upload(): void {
50
47
  dispatch("click");
51
48
  hidden_upload.click();
52
49
  }
53
50
 
54
- async function loadFiles(files: FileList): Promise<void> {
51
+ async function load_files(files: FileList): Promise<void> {
55
52
  let _files: File[] = Array.from(files);
56
53
  if (!files.length) {
57
54
  return;
@@ -70,14 +67,14 @@
70
67
  dispatch("upload", value);
71
68
  }
72
69
 
73
- async function loadFilesFromUpload(e: Event): Promise<void> {
70
+ async function load_files_from_upload(e: Event): Promise<void> {
74
71
  const target = e.target as HTMLInputElement;
75
72
 
76
73
  if (!target.files) return;
77
- await loadFiles(target.files);
74
+ await load_files(target.files);
78
75
  }
79
76
 
80
- function clearInputValue(e: Event): void {
77
+ function clear_input_value(e: Event): void {
81
78
  const target = e.target as HTMLInputElement;
82
79
  if (target.value) target.value = "";
83
80
  }
@@ -88,8 +85,8 @@
88
85
  accept={accept_file_types}
89
86
  type="file"
90
87
  bind:this={hidden_upload}
91
- on:change={loadFilesFromUpload}
92
- on:click={clearInputValue}
88
+ on:change={load_files_from_upload}
89
+ on:click={clear_input_value}
93
90
  multiple={file_count === "multiple" || undefined}
94
91
  webkitdirectory={file_count === "directory" || undefined}
95
92
  mozdirectory={file_count === "directory" || undefined}
@@ -102,13 +99,13 @@
102
99
  {elem_id}
103
100
  {elem_classes}
104
101
  {visible}
105
- on:click={openFileUpload}
102
+ on:click={open_file_upload}
106
103
  {scale}
107
104
  {min_width}
108
105
  {disabled}
109
106
  >
110
107
  {#if icon}
111
- <img class="button-icon" src={icon_path} alt={`${value} icon`} />
108
+ <img class="button-icon" src={icon.url} alt={`${value} icon`} />
112
109
  {/if}
113
110
  <slot />
114
111
  </BaseButton>