@gradio/upload 0.4.2 → 0.5.1

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,10 +1,68 @@
1
1
  # @gradio/upload
2
2
 
3
+ ## 0.5.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`71f1a1f99`](https://github.com/gradio-app/gradio/commit/71f1a1f9931489d465c2c1302a5c8d768a3cd23a)]:
8
+ - @gradio/client@0.8.2
9
+ - @gradio/upload@0.5.1
10
+
11
+ ## 0.5.0
12
+
13
+ ### Highlights
14
+
15
+ #### New `ImageEditor` component ([#6169](https://github.com/gradio-app/gradio/pull/6169) [`9caddc17b`](https://github.com/gradio-app/gradio/commit/9caddc17b1dea8da1af8ba724c6a5eab04ce0ed8))
16
+
17
+ A brand new component, completely separate from `Image` that provides simple editing capabilities.
18
+
19
+ - Set background images from file uploads, webcam, or just paste!
20
+ - Crop images with an improved cropping UI. App authors can event set specific crop size, or crop ratios (`1:1`, etc)
21
+ - Paint on top of any image (or no image) and erase any mistakes!
22
+ - The ImageEditor supports layers, confining draw and erase actions to that layer.
23
+ - More flexible access to data. The image component returns a composite image representing the final state of the canvas as well as providing the background and all layers as individual images.
24
+ - Fully customisable. All features can be enabled and disabled. Even the brush color swatches can be customised.
25
+
26
+ <video src="https://user-images.githubusercontent.com/12937446/284027169-31188926-fd16-4a1c-8718-998e7aae4695.mp4" autoplay muted></video>
27
+
28
+ ```py
29
+
30
+ def fn(im):
31
+ im["composite"] # the full canvas
32
+ im["background"] # the background image
33
+ im["layers"] # a list of individual layers
34
+
35
+
36
+ im = gr.ImageEditor(
37
+ # decide which sources you'd like to accept
38
+ sources=["upload", "webcam", "clipboard"],
39
+ # set a cropsize constraint, can either be a ratio or a concrete [width, height]
40
+ crop_size="1:1",
41
+ # enable crop (or disable it)
42
+ transforms=["crop"],
43
+ # customise the brush
44
+ brush=Brush(
45
+ default_size="25", # or leave it as 'auto'
46
+ color_mode="fixed", # 'fixed' hides the user swatches and colorpicker, 'defaults' shows it
47
+ default_color="hotpink", # html names are supported
48
+ colors=[
49
+ "rgba(0, 150, 150, 1)", # rgb(a)
50
+ "#fff", # hex rgb
51
+ "hsl(360, 120, 120)" # in fact any valid colorstring
52
+ ]
53
+ ),
54
+ brush=Eraser(default_size="25")
55
+ )
56
+
57
+ ```
58
+
59
+ Thanks [@pngwn](https://github.com/pngwn)!
60
+
3
61
  ## 0.4.2
4
62
 
5
63
  ### Fixes
6
64
 
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)!
65
+ - [#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
66
 
9
67
  ## 0.4.1
10
68
 
@@ -188,4 +246,4 @@ From the backend, streamed outputs are served from the `/stream/` endpoint inste
188
246
  ### Patch Changes
189
247
 
190
248
  - Updated dependencies []:
191
- - @gradio/atoms@0.0.2
249
+ - @gradio/atoms@0.0.2
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@gradio/upload",
3
- "version": "0.4.2",
3
+ "version": "0.5.1",
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.2.2",
11
- "@gradio/icons": "^0.2.1",
12
- "@gradio/client": "^0.8.1",
13
- "@gradio/upload": "^0.4.2",
14
- "@gradio/utils": "^0.2.0"
10
+ "@gradio/atoms": "^0.3.0",
11
+ "@gradio/client": "^0.8.2",
12
+ "@gradio/icons": "^0.3.0",
13
+ "@gradio/utils": "^0.2.0",
14
+ "@gradio/upload": "^0.5.1"
15
15
  },
16
16
  "main_changeset": true,
17
17
  "exports": {
package/src/Upload.svelte CHANGED
@@ -14,6 +14,7 @@
14
14
  export let disable_click = false;
15
15
  export let root: string;
16
16
  export let hidden = false;
17
+ export let format: "blob" | "file" = "file";
17
18
  export let include_sources = false;
18
19
  export let uploading = false;
19
20
 
@@ -63,7 +64,15 @@
63
64
  async function load_files_from_upload(e: Event): Promise<void> {
64
65
  const target = e.target as HTMLInputElement;
65
66
  if (!target.files) return;
66
- await load_files(Array.from(target.files));
67
+ if (format != "blob") {
68
+ await load_files(Array.from(target.files));
69
+ } else {
70
+ if (file_count === "single") {
71
+ dispatch("load", target.files[0]);
72
+ return;
73
+ }
74
+ dispatch("load", target.files);
75
+ }
67
76
  }
68
77
 
69
78
  function is_valid_mimetype(
@@ -107,6 +116,7 @@
107
116
  class:boundedheight
108
117
  class:flex
109
118
  style:height={include_sources ? "calc(100% - 40px" : "100%"}
119
+ tabindex={hidden ? -1 : 0}
110
120
  on:drag|preventDefault|stopPropagation
111
121
  on:dragstart|preventDefault|stopPropagation
112
122
  on:dragend|preventDefault|stopPropagation
@@ -121,6 +131,7 @@
121
131
  >
122
132
  <slot />
123
133
  <input
134
+ aria-label="file upload"
124
135
  type="file"
125
136
  bind:this={hidden_upload}
126
137
  on:change={load_files_from_upload}
@@ -140,8 +151,10 @@
140
151
 
141
152
  .hidden {
142
153
  display: none;
143
- height: 0;
154
+ height: 0 !important;
144
155
  position: absolute;
156
+ width: 0;
157
+ flex-grow: 0;
145
158
  }
146
159
 
147
160
  .center {