@gradio/image 0.3.5 → 0.3.6

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,11 @@
1
1
  # @gradio/image
2
2
 
3
+ ## 0.3.6
4
+
5
+ ### Fixes
6
+
7
+ - [#6441](https://github.com/gradio-app/gradio/pull/6441) [`2f805a7dd`](https://github.com/gradio-app/gradio/commit/2f805a7dd3d2b64b098f659dadd5d01258290521) - Small but important bugfixes for gr.Image: The upload event was not triggering at all. The paste-from-clipboard was not triggering an upload event. The clear button was not triggering a change event. The change event was triggering infinitely. Uploaded images were not preserving their original names. Uploading a new image should clear out the previous image. Thanks [@freddyaboulton](https://github.com/freddyaboulton)!
8
+
3
9
  ## 0.3.5
4
10
 
5
11
  ### Patch Changes
@@ -196,4 +202,4 @@ Thanks [@pngwn](https://github.com/pngwn)!
196
202
 
197
203
  ### Features
198
204
 
199
- - [#4979](https://github.com/gradio-app/gradio/pull/4979) [`44ac8ad0`](https://github.com/gradio-app/gradio/commit/44ac8ad08d82ea12c503dde5c78f999eb0452de2) - Allow setting sketch color default. Thanks [@aliabid94](https://github.com/aliabid94)!
205
+ - [#4979](https://github.com/gradio-app/gradio/pull/4979) [`44ac8ad0`](https://github.com/gradio-app/gradio/commit/44ac8ad08d82ea12c503dde5c78f999eb0452de2) - Allow setting sketch color default. Thanks [@aliabid94](https://github.com/aliabid94)!
package/Index.svelte CHANGED
@@ -61,7 +61,9 @@
61
61
  share: ShareData;
62
62
  }>;
63
63
 
64
- $: value?.url && gradio.dispatch("change");
64
+ $: url = _value?.url;
65
+ $: url && gradio.dispatch("change");
66
+
65
67
  let dragging: boolean;
66
68
  let active_tool: null | "webcam" = null;
67
69
  </script>
@@ -127,7 +129,10 @@
127
129
  {root}
128
130
  {sources}
129
131
  on:edit={() => gradio.dispatch("edit")}
130
- on:clear={() => gradio.dispatch("clear")}
132
+ on:clear={() => {
133
+ gradio.dispatch("clear");
134
+ gradio.dispatch("change");
135
+ }}
131
136
  on:stream={() => gradio.dispatch("stream")}
132
137
  on:drag={({ detail }) => (dragging = detail)}
133
138
  on:upload={() => gradio.dispatch("upload")}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradio/image",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "description": "Gradio UI packages",
5
5
  "type": "module",
6
6
  "author": "",
@@ -10,13 +10,13 @@
10
10
  "cropperjs": "^1.5.12",
11
11
  "lazy-brush": "^1.0.1",
12
12
  "resize-observer-polyfill": "^1.5.1",
13
- "@gradio/atoms": "^0.2.1",
13
+ "@gradio/atoms": "^0.2.2",
14
14
  "@gradio/client": "^0.8.1",
15
- "@gradio/statustracker": "^0.3.1",
16
- "@gradio/icons": "^0.2.0",
17
- "@gradio/utils": "^0.2.0",
18
- "@gradio/upload": "^0.4.1",
19
- "@gradio/wasm": "^0.3.0"
15
+ "@gradio/statustracker": "^0.3.2",
16
+ "@gradio/upload": "^0.4.2",
17
+ "@gradio/icons": "^0.2.1",
18
+ "@gradio/wasm": "^0.3.0",
19
+ "@gradio/utils": "^0.2.0"
20
20
  },
21
21
  "main_changeset": true,
22
22
  "main": "./Index.svelte",
@@ -40,7 +40,7 @@
40
40
  <a
41
41
  href={value.url}
42
42
  target={window.__is_colab__ ? "_blank" : null}
43
- download={"image"}
43
+ download={value.orig_name || "image"}
44
44
  >
45
45
  <IconButton Icon={Download} label={i18n("common.download")} />
46
46
  </a>
@@ -33,10 +33,12 @@
33
33
  export let i18n: I18nFormatter;
34
34
 
35
35
  let upload: Upload;
36
+ let uploading = false;
36
37
  export let active_tool: "webcam" | null = null;
37
38
 
38
39
  function handle_upload({ detail }: CustomEvent<FileData>): void {
39
40
  value = normalise_file(detail, root, null);
41
+ dispatch("upload");
40
42
  }
41
43
 
42
44
  async function handle_save(img_blob: Blob | any): Promise<void> {
@@ -52,6 +54,8 @@
52
54
  pending = false;
53
55
  }
54
56
 
57
+ $: if (uploading) value = null;
58
+
55
59
  $: value && !value.url && (value = normalise_file(value, root, null));
56
60
 
57
61
  const dispatch = createEventDispatcher<{
@@ -111,6 +115,7 @@
111
115
  for (let i = 0; i < items.length; i++) {
112
116
  const type = items[i].types.find((t) => t.startsWith("image/"));
113
117
  if (type) {
118
+ value = null;
114
119
  items[i].getType(type).then(async (blob) => {
115
120
  const f = await upload.load_files([
116
121
  new File([blob], `clipboard.${type.replace("image/", "")}`)
@@ -139,12 +144,18 @@
139
144
 
140
145
  <div data-testid="image" class="image-container">
141
146
  {#if value?.url}
142
- <ClearImage on:remove_image={() => (value = null)} />
147
+ <ClearImage
148
+ on:remove_image={() => {
149
+ value = null;
150
+ dispatch("clear");
151
+ }}
152
+ />
143
153
  {/if}
144
154
  <div class="upload-container">
145
155
  <Upload
146
156
  hidden={value !== null || active_tool === "webcam"}
147
157
  bind:this={upload}
158
+ bind:uploading
148
159
  bind:dragging
149
160
  filetype="image/*"
150
161
  on:load={handle_upload}
@@ -187,6 +198,7 @@
187
198
  on:click={() => handle_toolbar(source)}
188
199
  Icon={sources_meta[source].icon}
189
200
  size="large"
201
+ label="{source}-image-toolbar-btn"
190
202
  padded={false}
191
203
  />
192
204
  {/each}