@gradio/upload 0.6.0 → 0.7.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,17 @@
1
1
  # @gradio/upload
2
2
 
3
+ ## 0.7.0
4
+
5
+ ### Features
6
+
7
+ - [#7104](https://github.com/gradio-app/gradio/pull/7104) [`bc2cdc1`](https://github.com/gradio-app/gradio/commit/bc2cdc1df95b38025486cf76df4a494b66d98585) - Allow download button for interactive Audio and Video components. Thanks [@hannahblair](https://github.com/hannahblair)!
8
+
9
+ ## 0.6.1
10
+
11
+ ### Fixes
12
+
13
+ - [#6982](https://github.com/gradio-app/gradio/pull/6982) [`3f139c7`](https://github.com/gradio-app/gradio/commit/3f139c7c995f749562bb007d2a567bb167669de9) - Fix File drag and drop for specific file_types. Thanks [@dawoodkhan82](https://github.com/dawoodkhan82)!
14
+
3
15
  ## 0.6.0
4
16
 
5
17
  ### Features
package/package.json CHANGED
@@ -1,17 +1,18 @@
1
1
  {
2
2
  "name": "@gradio/upload",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Gradio UI packages",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
7
7
  "author": "",
8
8
  "license": "ISC",
9
9
  "dependencies": {
10
- "@gradio/atoms": "^0.4.1",
11
- "@gradio/upload": "^0.6.0",
12
- "@gradio/client": "^0.10.0",
13
- "@gradio/utils": "^0.2.0",
14
- "@gradio/icons": "^0.3.2"
10
+ "@gradio/atoms": "^0.5.0",
11
+ "@gradio/icons": "^0.3.2",
12
+ "@gradio/client": "^0.10.1",
13
+ "@gradio/upload": "^0.7.0",
14
+ "@gradio/utils": "^0.2.1",
15
+ "@gradio/wasm": "^0.5.1"
15
16
  },
16
17
  "main_changeset": true,
17
18
  "exports": {
@@ -1,12 +1,14 @@
1
1
  <script lang="ts">
2
2
  import { IconButton } from "@gradio/atoms";
3
3
  import type { I18nFormatter } from "@gradio/utils";
4
- import { Edit, Clear, Undo } from "@gradio/icons";
4
+ import { Edit, Clear, Undo, Download } from "@gradio/icons";
5
+ import { DownloadLink } from "@gradio/wasm/svelte";
5
6
 
6
7
  import { createEventDispatcher } from "svelte";
7
8
 
8
9
  export let editable = false;
9
10
  export let undoable = false;
11
+ export let download: string | null = null;
10
12
  export let absolute = true;
11
13
  export let i18n: I18nFormatter;
12
14
 
@@ -37,6 +39,12 @@
37
39
  />
38
40
  {/if}
39
41
 
42
+ {#if download}
43
+ <DownloadLink href={download} download>
44
+ <IconButton Icon={Download} label={i18n("common.download")} />
45
+ </DownloadLink>
46
+ {/if}
47
+
40
48
  <IconButton
41
49
  Icon={Clear}
42
50
  label={i18n("common.clear")}
package/src/Upload.svelte CHANGED
@@ -129,11 +129,16 @@
129
129
  async function loadFilesFromDrop(e: DragEvent): Promise<void> {
130
130
  dragging = false;
131
131
  if (!e.dataTransfer?.files) return;
132
-
133
- const files_to_load = Array.from(e.dataTransfer.files).filter((f) => {
134
- const file_extension =
135
- f.type !== "" ? f.type : "." + f.name.split(".").pop();
136
- if (file_extension && is_valid_mimetype(filetype, file_extension)) {
132
+ const files_to_load = Array.from(e.dataTransfer.files).filter((file) => {
133
+ const file_extension = "." + file.name.split(".").pop();
134
+ if (file.type && is_valid_mimetype(filetype, file.type)) {
135
+ return true;
136
+ }
137
+ if (
138
+ file_extension && Array.isArray(filetype)
139
+ ? filetype.includes(file_extension)
140
+ : file_extension === filetype
141
+ ) {
137
142
  return true;
138
143
  }
139
144
  dispatch("error", `Invalid file type only ${filetype} allowed.`);
@@ -182,6 +187,7 @@
182
187
  <slot />
183
188
  <input
184
189
  aria-label="file upload"
190
+ data-testid="file-upload"
185
191
  type="file"
186
192
  bind:this={hidden_upload}
187
193
  on:change={load_files_from_upload}