@gradio/upload 0.7.0 → 0.7.2

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,32 +1,50 @@
1
1
  # @gradio/upload
2
2
 
3
+ ## 0.7.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`49d9c48`](https://github.com/gradio-app/gradio/commit/49d9c48537aa706bf72628e3640389470138bdc6)]:
8
+ - @gradio/client@0.12.0
9
+ - @gradio/upload@0.7.2
10
+
11
+ ## 0.7.1
12
+
13
+ ### Features
14
+
15
+ - [#7206](https://github.com/gradio-app/gradio/pull/7206) [`572e360`](https://github.com/gradio-app/gradio/commit/572e360fff4a03c335b86e1a7517a44cb6af2bcd) - Upload tweak. Thanks [@pngwn](https://github.com/pngwn)!
16
+
17
+ ### Fixes
18
+
19
+ - [#7141](https://github.com/gradio-app/gradio/pull/7141) [`c3e61e4`](https://github.com/gradio-app/gradio/commit/c3e61e4f70696a71aede67b65d28447eb67daf16) - Few File component drag and drop. Thanks [@dawoodkhan82](https://github.com/dawoodkhan82)!
20
+
3
21
  ## 0.7.0
4
22
 
5
23
  ### Features
6
24
 
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)!
25
+ - [#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
26
 
9
27
  ## 0.6.1
10
28
 
11
29
  ### Fixes
12
30
 
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)!
31
+ - [#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
32
 
15
33
  ## 0.6.0
16
34
 
17
35
  ### Features
18
36
 
19
- - [#6965](https://github.com/gradio-app/gradio/pull/6965) [`5d00dd3`](https://github.com/gradio-app/gradio/commit/5d00dd37ca14bbfef2ceac550b29dbe05ba8cab0) - Make <UploadProgress /> Wasm-compatible. Thanks [@whitphx](https://github.com/whitphx)!
37
+ - [#6965](https://github.com/gradio-app/gradio/pull/6965) [`5d00dd3`](https://github.com/gradio-app/gradio/commit/5d00dd37ca14bbfef2ceac550b29dbe05ba8cab0) - Make <UploadProgress /> Wasm-compatible. Thanks [@whitphx](https://github.com/whitphx)!
20
38
 
21
39
  ### Fixes
22
40
 
23
- - [#6969](https://github.com/gradio-app/gradio/pull/6969) [`793bf8f`](https://github.com/gradio-app/gradio/commit/793bf8f7b1943f265c5d016c1a0c682ee549232a) - Display pending file in `<Upload />` while waiting for upload request. Thanks [@hannahblair](https://github.com/hannahblair)!
41
+ - [#6969](https://github.com/gradio-app/gradio/pull/6969) [`793bf8f`](https://github.com/gradio-app/gradio/commit/793bf8f7b1943f265c5d016c1a0c682ee549232a) - Display pending file in `<Upload />` while waiting for upload request. Thanks [@hannahblair](https://github.com/hannahblair)!
24
42
 
25
43
  ## 0.5.8
26
44
 
27
45
  ### Features
28
46
 
29
- - [#6931](https://github.com/gradio-app/gradio/pull/6931) [`6c863af`](https://github.com/gradio-app/gradio/commit/6c863af92fa9ceb5c638857eb22cc5ddb718d549) - Fix functional tests. Thanks [@aliabid94](https://github.com/aliabid94)!
47
+ - [#6931](https://github.com/gradio-app/gradio/pull/6931) [`6c863af`](https://github.com/gradio-app/gradio/commit/6c863af92fa9ceb5c638857eb22cc5ddb718d549) - Fix functional tests. Thanks [@aliabid94](https://github.com/aliabid94)!
30
48
 
31
49
  ## 0.5.7
32
50
 
@@ -317,4 +335,4 @@ From the backend, streamed outputs are served from the `/stream/` endpoint inste
317
335
  ### Patch Changes
318
336
 
319
337
  - Updated dependencies []:
320
- - @gradio/atoms@0.0.2
338
+ - @gradio/atoms@0.0.2
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@gradio/upload",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
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.5.0",
11
10
  "@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"
11
+ "@gradio/upload": "^0.7.2",
12
+ "@gradio/atoms": "^0.5.1",
13
+ "@gradio/utils": "^0.2.2",
14
+ "@gradio/client": "^0.12.0",
15
+ "@gradio/wasm": "^0.6.0"
16
16
  },
17
17
  "main_changeset": true,
18
18
  "exports": {
package/src/Upload.svelte CHANGED
@@ -27,7 +27,6 @@
27
27
  let hidden_upload: HTMLInputElement;
28
28
 
29
29
  const dispatch = createEventDispatcher();
30
-
31
30
  $: if (filetype == null || typeof filetype === "string") {
32
31
  accept_file_types = filetype;
33
32
  } else {
@@ -106,24 +105,29 @@
106
105
 
107
106
  function is_valid_mimetype(
108
107
  file_accept: string | string[] | null,
109
- mime_type: string
108
+ uploaded_file_extension: string,
109
+ uploaded_file_type: string
110
110
  ): boolean {
111
111
  if (!file_accept || file_accept === "*" || file_accept === "file/*") {
112
112
  return true;
113
113
  }
114
- if (typeof file_accept === "string" && file_accept.endsWith("/*")) {
115
- file_accept = file_accept.split(",");
116
- }
117
- if (Array.isArray(file_accept)) {
118
- return (
119
- file_accept.includes(mime_type) ||
120
- file_accept.some((type) => {
121
- const [category] = type.split("/");
122
- return type.endsWith("/*") && mime_type.startsWith(category + "/");
123
- })
124
- );
114
+ let acceptArray: string[];
115
+ if (typeof file_accept === "string") {
116
+ acceptArray = file_accept.split(",").map((s) => s.trim());
117
+ } else if (Array.isArray(file_accept)) {
118
+ acceptArray = file_accept;
119
+ } else {
120
+ return false;
125
121
  }
126
- return file_accept === mime_type;
122
+ return (
123
+ acceptArray.includes(uploaded_file_extension) ||
124
+ acceptArray.some((type) => {
125
+ const [category] = type.split("/").map((s) => s.trim());
126
+ return (
127
+ type.endsWith("/*") && uploaded_file_type.startsWith(category + "/")
128
+ );
129
+ })
130
+ );
127
131
  }
128
132
 
129
133
  async function loadFilesFromDrop(e: DragEvent): Promise<void> {
@@ -131,7 +135,10 @@
131
135
  if (!e.dataTransfer?.files) return;
132
136
  const files_to_load = Array.from(e.dataTransfer.files).filter((file) => {
133
137
  const file_extension = "." + file.name.split(".").pop();
134
- if (file.type && is_valid_mimetype(filetype, file.type)) {
138
+ if (
139
+ file_extension &&
140
+ is_valid_mimetype(filetype, file_extension, file.type)
141
+ ) {
135
142
  return true;
136
143
  }
137
144
  if (
@@ -111,6 +111,7 @@
111
111
  align-items: center;
112
112
  justify-content: center;
113
113
  min-height: var(--size-40);
114
+ width: var(--size-full);
114
115
  }
115
116
 
116
117
  .wrap::after {