@gradio/multimodaltextbox 0.7.4 → 0.7.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 +27 -0
- package/Index.svelte +1 -1
- package/MultimodalTextbox.stories.svelte +14 -0
- package/dist/Index.svelte +1 -1
- package/dist/shared/MultimodalTextbox.svelte +54 -23
- package/package.json +8 -8
- package/shared/MultimodalTextbox.svelte +57 -23
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @gradio/multimodaltextbox
|
|
2
2
|
|
|
3
|
+
## 0.7.6
|
|
4
|
+
|
|
5
|
+
### Fixes
|
|
6
|
+
|
|
7
|
+
- [#9946](https://github.com/gradio-app/gradio/pull/9946) [`a966e9f`](https://github.com/gradio-app/gradio/commit/a966e9f753af25eb9d813dfdbce39be6f3014d82) - Hide upload button after upload when `file_count="single"`. Thanks @abidlabs!
|
|
8
|
+
- [#9904](https://github.com/gradio-app/gradio/pull/9904) [`f523c91`](https://github.com/gradio-app/gradio/commit/f523c915d3732859ff4a8019a82cb597b5208ae2) - Ensure dropped files are validated in MultimediaTextbox. Thanks @hannahblair!
|
|
9
|
+
|
|
10
|
+
### Dependency updates
|
|
11
|
+
|
|
12
|
+
- @gradio/video@0.11.8
|
|
13
|
+
- @gradio/atoms@0.11.1
|
|
14
|
+
- @gradio/client@1.8.0
|
|
15
|
+
- @gradio/utils@0.8.0
|
|
16
|
+
- @gradio/upload@0.14.1
|
|
17
|
+
- @gradio/statustracker@0.9.5
|
|
18
|
+
- @gradio/image@0.16.8
|
|
19
|
+
|
|
20
|
+
## 0.7.5
|
|
21
|
+
|
|
22
|
+
### Dependency updates
|
|
23
|
+
|
|
24
|
+
- @gradio/video@0.11.7
|
|
25
|
+
- @gradio/statustracker@0.9.4
|
|
26
|
+
- @gradio/atoms@0.11.0
|
|
27
|
+
- @gradio/upload@0.14.0
|
|
28
|
+
- @gradio/image@0.16.7
|
|
29
|
+
|
|
3
30
|
## 0.7.4
|
|
4
31
|
|
|
5
32
|
### Fixes
|
package/Index.svelte
CHANGED
|
@@ -73,3 +73,17 @@
|
|
|
73
73
|
/>
|
|
74
74
|
<Story name="Right aligned textbox" args={{ text_align: "right" }} />
|
|
75
75
|
<Story name="RTL textbox" args={{ rtl: true }} />
|
|
76
|
+
<Story
|
|
77
|
+
name="Single file upload"
|
|
78
|
+
args={{
|
|
79
|
+
file_count: "single",
|
|
80
|
+
value: {
|
|
81
|
+
text: "sample text",
|
|
82
|
+
files: [
|
|
83
|
+
{
|
|
84
|
+
path: "https://gradio-builds.s3.amazonaws.com/demo-files/ghepardo-primo-piano.jpg"
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
}}
|
|
89
|
+
/>
|
package/dist/Index.svelte
CHANGED
|
@@ -184,7 +184,29 @@ function handle_drop(event) {
|
|
|
184
184
|
event.preventDefault();
|
|
185
185
|
dragging = false;
|
|
186
186
|
if (event.dataTransfer && event.dataTransfer.files) {
|
|
187
|
-
|
|
187
|
+
const files = Array.from(event.dataTransfer.files);
|
|
188
|
+
if (file_types) {
|
|
189
|
+
const valid_files = files.filter((file) => {
|
|
190
|
+
return file_types.some((type) => {
|
|
191
|
+
if (type.startsWith(".")) {
|
|
192
|
+
return file.name.toLowerCase().endsWith(type.toLowerCase());
|
|
193
|
+
}
|
|
194
|
+
return file.type.match(new RegExp(type.replace("*", ".*")));
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
const invalid_files = files.length - valid_files.length;
|
|
198
|
+
if (invalid_files > 0) {
|
|
199
|
+
dispatch(
|
|
200
|
+
"error",
|
|
201
|
+
`${invalid_files} file(s) were rejected. Accepted formats: ${file_types.join(", ")}`
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
if (valid_files.length > 0) {
|
|
205
|
+
upload_component.load_files(valid_files);
|
|
206
|
+
}
|
|
207
|
+
} else {
|
|
208
|
+
upload_component.load_files(files);
|
|
209
|
+
}
|
|
188
210
|
}
|
|
189
211
|
}
|
|
190
212
|
</script>
|
|
@@ -245,28 +267,30 @@ function handle_drop(event) {
|
|
|
245
267
|
</div>
|
|
246
268
|
{/if}
|
|
247
269
|
<div class="input-container">
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
+
{#if !disabled && !(file_count === "single" && value.files.length > 0)}
|
|
271
|
+
<Upload
|
|
272
|
+
bind:this={upload_component}
|
|
273
|
+
on:load={handle_upload}
|
|
274
|
+
{file_count}
|
|
275
|
+
filetype={file_types}
|
|
276
|
+
{root}
|
|
277
|
+
{max_file_size}
|
|
278
|
+
bind:dragging
|
|
279
|
+
bind:uploading
|
|
280
|
+
show_progress={false}
|
|
281
|
+
disable_click={true}
|
|
282
|
+
bind:hidden_upload
|
|
283
|
+
on:error
|
|
284
|
+
hidden={true}
|
|
285
|
+
{upload}
|
|
286
|
+
{stream_handler}
|
|
287
|
+
></Upload>
|
|
288
|
+
<button
|
|
289
|
+
data-testid="upload-button"
|
|
290
|
+
class="upload-button"
|
|
291
|
+
on:click={handle_upload_click}><Paperclip /></button
|
|
292
|
+
>
|
|
293
|
+
{/if}
|
|
270
294
|
<textarea
|
|
271
295
|
data-testid="textbox"
|
|
272
296
|
use:text_area_resize={{
|
|
@@ -325,6 +349,13 @@ function handle_drop(event) {
|
|
|
325
349
|
.full-container {
|
|
326
350
|
width: 100%;
|
|
327
351
|
position: relative;
|
|
352
|
+
padding: var(--block-padding);
|
|
353
|
+
border: 1px solid transparent;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
.full-container.dragging {
|
|
357
|
+
border: 1px solid var(--color-accent);
|
|
358
|
+
border-radius: calc(var(--radius-sm) - 1px);
|
|
328
359
|
}
|
|
329
360
|
|
|
330
361
|
.full-container.dragging::after {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradio/multimodaltextbox",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.6",
|
|
4
4
|
"description": "Gradio UI packages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "",
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
"./package.json": "./package.json"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@gradio/atoms": "^0.
|
|
25
|
+
"@gradio/atoms": "^0.11.1",
|
|
26
|
+
"@gradio/statustracker": "^0.9.5",
|
|
26
27
|
"@gradio/icons": "^0.8.1",
|
|
27
|
-
"@gradio/
|
|
28
|
-
"@gradio/
|
|
29
|
-
"@gradio/
|
|
30
|
-
"@gradio/
|
|
31
|
-
"@gradio/
|
|
32
|
-
"@gradio/video": "^0.11.6"
|
|
28
|
+
"@gradio/utils": "^0.8.0",
|
|
29
|
+
"@gradio/upload": "^0.14.1",
|
|
30
|
+
"@gradio/video": "^0.11.8",
|
|
31
|
+
"@gradio/client": "^1.8.0",
|
|
32
|
+
"@gradio/image": "^0.16.8"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@gradio/preview": "^0.13.0"
|
|
@@ -229,7 +229,32 @@
|
|
|
229
229
|
event.preventDefault();
|
|
230
230
|
dragging = false;
|
|
231
231
|
if (event.dataTransfer && event.dataTransfer.files) {
|
|
232
|
-
|
|
232
|
+
const files = Array.from(event.dataTransfer.files);
|
|
233
|
+
|
|
234
|
+
if (file_types) {
|
|
235
|
+
const valid_files = files.filter((file) => {
|
|
236
|
+
return file_types.some((type) => {
|
|
237
|
+
if (type.startsWith(".")) {
|
|
238
|
+
return file.name.toLowerCase().endsWith(type.toLowerCase());
|
|
239
|
+
}
|
|
240
|
+
return file.type.match(new RegExp(type.replace("*", ".*")));
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
const invalid_files = files.length - valid_files.length;
|
|
245
|
+
if (invalid_files > 0) {
|
|
246
|
+
dispatch(
|
|
247
|
+
"error",
|
|
248
|
+
`${invalid_files} file(s) were rejected. Accepted formats: ${file_types.join(", ")}`
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (valid_files.length > 0) {
|
|
253
|
+
upload_component.load_files(valid_files);
|
|
254
|
+
}
|
|
255
|
+
} else {
|
|
256
|
+
upload_component.load_files(files);
|
|
257
|
+
}
|
|
233
258
|
}
|
|
234
259
|
}
|
|
235
260
|
</script>
|
|
@@ -290,28 +315,30 @@
|
|
|
290
315
|
</div>
|
|
291
316
|
{/if}
|
|
292
317
|
<div class="input-container">
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
318
|
+
{#if !disabled && !(file_count === "single" && value.files.length > 0)}
|
|
319
|
+
<Upload
|
|
320
|
+
bind:this={upload_component}
|
|
321
|
+
on:load={handle_upload}
|
|
322
|
+
{file_count}
|
|
323
|
+
filetype={file_types}
|
|
324
|
+
{root}
|
|
325
|
+
{max_file_size}
|
|
326
|
+
bind:dragging
|
|
327
|
+
bind:uploading
|
|
328
|
+
show_progress={false}
|
|
329
|
+
disable_click={true}
|
|
330
|
+
bind:hidden_upload
|
|
331
|
+
on:error
|
|
332
|
+
hidden={true}
|
|
333
|
+
{upload}
|
|
334
|
+
{stream_handler}
|
|
335
|
+
></Upload>
|
|
336
|
+
<button
|
|
337
|
+
data-testid="upload-button"
|
|
338
|
+
class="upload-button"
|
|
339
|
+
on:click={handle_upload_click}><Paperclip /></button
|
|
340
|
+
>
|
|
341
|
+
{/if}
|
|
315
342
|
<textarea
|
|
316
343
|
data-testid="textbox"
|
|
317
344
|
use:text_area_resize={{
|
|
@@ -370,6 +397,13 @@
|
|
|
370
397
|
.full-container {
|
|
371
398
|
width: 100%;
|
|
372
399
|
position: relative;
|
|
400
|
+
padding: var(--block-padding);
|
|
401
|
+
border: 1px solid transparent;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
.full-container.dragging {
|
|
405
|
+
border: 1px solid var(--color-accent);
|
|
406
|
+
border-radius: calc(var(--radius-sm) - 1px);
|
|
373
407
|
}
|
|
374
408
|
|
|
375
409
|
.full-container.dragging::after {
|