@gradio/upload 0.5.5 → 0.5.7

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,19 @@
1
1
  # @gradio/upload
2
2
 
3
+ ## 0.5.7
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`d406855`](https://github.com/gradio-app/gradio/commit/d4068557953746662235d595ec435c42ceb24414)]:
8
+ - @gradio/client@0.9.4
9
+ - @gradio/upload@0.5.7
10
+
11
+ ## 0.5.6
12
+
13
+ ### Fixes
14
+
15
+ - [#6766](https://github.com/gradio-app/gradio/pull/6766) [`73268ee`](https://github.com/gradio-app/gradio/commit/73268ee2e39f23ebdd1e927cb49b8d79c4b9a144) - Improve source selection UX. Thanks [@hannahblair](https://github.com/hannahblair)!
16
+
3
17
  ## 0.5.5
4
18
 
5
19
  ### Patch Changes
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@gradio/upload",
3
- "version": "0.5.5",
3
+ "version": "0.5.7",
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.0",
11
- "@gradio/icons": "^0.3.2",
12
- "@gradio/client": "^0.9.2",
13
- "@gradio/upload": "^0.5.5",
14
- "@gradio/utils": "^0.2.0"
10
+ "@gradio/atoms": "^0.4.1",
11
+ "@gradio/client": "^0.9.4",
12
+ "@gradio/upload": "^0.5.7",
13
+ "@gradio/utils": "^0.2.0",
14
+ "@gradio/icons": "^0.3.2"
15
15
  },
16
16
  "main_changeset": true,
17
17
  "exports": {
package/src/Upload.svelte CHANGED
@@ -15,7 +15,6 @@
15
15
  export let root: string;
16
16
  export let hidden = false;
17
17
  export let format: "blob" | "file" = "file";
18
- export let include_sources = false;
19
18
  export let uploading = false;
20
19
 
21
20
  let upload_id: string;
@@ -44,6 +43,26 @@
44
43
  dragging = !dragging;
45
44
  }
46
45
 
46
+ export function paste_clipboard(): void {
47
+ navigator.clipboard.read().then(async (items) => {
48
+ for (let i = 0; i < items.length; i++) {
49
+ const type = items[i].types.find((t) => t.startsWith("image/"));
50
+ if (type) {
51
+ dispatch("load", null);
52
+ items[i].getType(type).then(async (blob) => {
53
+ const file = new File(
54
+ [blob],
55
+ `clipboard.${type.replace("image/", "")}`
56
+ );
57
+ const f = await load_files([file]);
58
+ dispatch("load", f?.[0]);
59
+ });
60
+ break;
61
+ }
62
+ }
63
+ });
64
+ }
65
+
47
66
  export function open_file_upload(): void {
48
67
  if (disable_click) return;
49
68
  hidden_upload.value = "";
@@ -126,7 +145,19 @@
126
145
  }
127
146
  </script>
128
147
 
129
- {#if uploading}
148
+ {#if filetype === "clipboard"}
149
+ <button
150
+ class:hidden
151
+ class:center
152
+ class:boundedheight
153
+ class:flex
154
+ style:height="100%"
155
+ tabindex={hidden ? -1 : 0}
156
+ on:click={paste_clipboard}
157
+ >
158
+ <slot />
159
+ </button>
160
+ {:else if uploading}
130
161
  {#if !hidden}
131
162
  <UploadProgress {root} {upload_id} files={file_data} />
132
163
  {/if}
@@ -136,7 +167,7 @@
136
167
  class:center
137
168
  class:boundedheight
138
169
  class:flex
139
- style:height={include_sources ? "calc(100% - 40px" : "100%"}
170
+ style:height="100%"
140
171
  tabindex={hidden ? -1 : 0}
141
172
  on:drag|preventDefault|stopPropagation
142
173
  on:dragstart|preventDefault|stopPropagation