@gradio/uploadbutton 0.9.15 → 0.9.17
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 +26 -0
- package/Index.svelte +4 -4
- package/UploadButton.stories.svelte +64 -60
- package/dist/Index.svelte +4 -4
- package/dist/shared/UploadButton.svelte +63 -35
- package/dist/shared/UploadButton.svelte.d.ts +10 -33
- package/package.json +7 -7
- package/shared/UploadButton.svelte +63 -35
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @gradio/uploadbutton
|
|
2
2
|
|
|
3
|
+
## 0.9.17
|
|
4
|
+
|
|
5
|
+
### Fixes
|
|
6
|
+
|
|
7
|
+
- [#12800](https://github.com/gradio-app/gradio/pull/12800) [`7a1c321`](https://github.com/gradio-app/gradio/commit/7a1c321b6546ba05a353488f5133e8262c4a8a39) - Bump svelte/kit for security reasons. Thanks @freddyaboulton!
|
|
8
|
+
- [#12782](https://github.com/gradio-app/gradio/pull/12782) [`8a262d6`](https://github.com/gradio-app/gradio/commit/8a262d652ad8f33a2c09f3f98f501978ae416cf0) - Migrate UploadButton. Thanks @freddyaboulton!
|
|
9
|
+
|
|
10
|
+
### Dependency updates
|
|
11
|
+
|
|
12
|
+
- @gradio/button@0.6.3
|
|
13
|
+
- @gradio/utils@0.11.2
|
|
14
|
+
- @gradio/upload@0.17.4
|
|
15
|
+
- @gradio/client@2.0.3
|
|
16
|
+
|
|
17
|
+
## 0.9.16
|
|
18
|
+
|
|
19
|
+
### Fixes
|
|
20
|
+
|
|
21
|
+
- [#12681](https://github.com/gradio-app/gradio/pull/12681) [`ba46c2d`](https://github.com/gradio-app/gradio/commit/ba46c2df1405c11e495304af8f91acfdf69d0b18) - Migrate Button to Svelte 5. Thanks @freddyaboulton!
|
|
22
|
+
|
|
23
|
+
### Dependency updates
|
|
24
|
+
|
|
25
|
+
- @gradio/utils@0.11.1
|
|
26
|
+
- @gradio/button@0.6.2
|
|
27
|
+
- @gradio/client@2.0.2
|
|
28
|
+
|
|
3
29
|
## 0.9.15
|
|
4
30
|
|
|
5
31
|
### Dependency updates
|
package/Index.svelte
CHANGED
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
variant={gradio.props.variant}
|
|
47
47
|
label={gradio.shared.label}
|
|
48
48
|
max_file_size={gradio.shared.max_file_size}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
onclick={() => gradio.dispatch("click")}
|
|
50
|
+
onchange={(detail) => handle_event(detail, "change")}
|
|
51
|
+
onupload={(detail) => handle_event(detail, "upload")}
|
|
52
|
+
onerror={(detail) => {
|
|
53
53
|
gradio.dispatch("error", detail);
|
|
54
54
|
}}
|
|
55
55
|
upload={(...args) => gradio.shared.client.upload(...args)}
|
|
@@ -1,69 +1,75 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import {
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from "@storybook/addon-svelte-csf";
|
|
3
3
|
import UploadButton from "./Index.svelte";
|
|
4
|
-
|
|
4
|
+
import { wrapProps } from "../storybook/wrapProps";
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
6
|
+
const { Story } = defineMeta({
|
|
7
|
+
title: "Components/UploadButton",
|
|
8
|
+
component: UploadButton,
|
|
9
|
+
argTypes: {
|
|
10
|
+
label: {
|
|
11
|
+
control: "text",
|
|
12
|
+
description: "The text to display on the button",
|
|
13
|
+
name: "label",
|
|
14
|
+
value: "Gradio Button"
|
|
15
|
+
},
|
|
16
|
+
variant: {
|
|
17
|
+
options: ["primary", "secondary", "stop"],
|
|
18
|
+
description: "The variant of the button",
|
|
19
|
+
control: { type: "select" },
|
|
20
|
+
defaultValue: "primary"
|
|
21
|
+
},
|
|
22
|
+
size: {
|
|
23
|
+
options: ["sm", "lg"],
|
|
24
|
+
description: "The size of the button",
|
|
25
|
+
control: { type: "select" },
|
|
26
|
+
defaultValue: "lg"
|
|
27
|
+
},
|
|
28
|
+
visible: {
|
|
29
|
+
options: [true, false],
|
|
30
|
+
description: "Sets the visibility of the button",
|
|
31
|
+
control: { type: "boolean" },
|
|
32
|
+
defaultValue: true
|
|
33
|
+
},
|
|
34
|
+
interactive: {
|
|
35
|
+
options: [true, false],
|
|
36
|
+
description: "If false, the button will be in a disabled state",
|
|
37
|
+
control: { type: "boolean" },
|
|
38
|
+
defaultValue: true
|
|
39
|
+
},
|
|
40
|
+
disabled: {
|
|
41
|
+
options: [true, false],
|
|
42
|
+
control: { type: "boolean" },
|
|
43
|
+
defaultValue: false
|
|
44
|
+
},
|
|
45
|
+
scale: {
|
|
46
|
+
options: [null, 0.5, 1, 2],
|
|
47
|
+
description: "relative size compared to adjacent Components.",
|
|
48
|
+
control: { type: "select" }
|
|
49
|
+
}
|
|
50
50
|
}
|
|
51
|
-
}
|
|
52
|
-
|
|
51
|
+
});
|
|
52
|
+
</script>
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
<UploadButton value
|
|
56
|
-
|
|
54
|
+
{#snippet template(args)}
|
|
55
|
+
<UploadButton {...wrapProps({ value: "Gradio Button", ...args })} />
|
|
56
|
+
{/snippet}
|
|
57
57
|
|
|
58
58
|
<Story
|
|
59
59
|
name="Primary"
|
|
60
60
|
args={{ label: "Upload", variant: "primary", size: "lg", scale: 1 }}
|
|
61
|
+
{template}
|
|
61
62
|
/>
|
|
62
63
|
<Story
|
|
63
64
|
name="Secondary"
|
|
64
65
|
args={{ label: "Upload", variant: "secondary", size: "lg" }}
|
|
66
|
+
{template}
|
|
67
|
+
/>
|
|
68
|
+
<Story
|
|
69
|
+
name="Stop"
|
|
70
|
+
args={{ label: "Upload", variant: "stop", size: "lg" }}
|
|
71
|
+
{template}
|
|
65
72
|
/>
|
|
66
|
-
<Story name="Stop" args={{ label: "Upload", variant: "stop", size: "lg" }} />
|
|
67
73
|
<Story
|
|
68
74
|
name="Button with external image icon"
|
|
69
75
|
args={{
|
|
@@ -73,17 +79,15 @@
|
|
|
73
79
|
url: "https://huggingface.co/front/assets/huggingface_logo-noborder.svg"
|
|
74
80
|
}
|
|
75
81
|
}}
|
|
82
|
+
{template}
|
|
76
83
|
/>
|
|
77
84
|
<Story
|
|
78
85
|
name="Button with visible equal to false"
|
|
79
|
-
args={{
|
|
80
|
-
|
|
81
|
-
visible: false
|
|
82
|
-
}}
|
|
86
|
+
args={{ label: "Upload", visible: false }}
|
|
87
|
+
{template}
|
|
83
88
|
/>
|
|
84
89
|
<Story
|
|
85
90
|
name="Button with null label (should be collapsed)"
|
|
86
|
-
args={{
|
|
87
|
-
|
|
88
|
-
}}
|
|
91
|
+
args={{ label: null }}
|
|
92
|
+
{template}
|
|
89
93
|
/>
|
package/dist/Index.svelte
CHANGED
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
variant={gradio.props.variant}
|
|
47
47
|
label={gradio.shared.label}
|
|
48
48
|
max_file_size={gradio.shared.max_file_size}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
onclick={() => gradio.dispatch("click")}
|
|
50
|
+
onchange={(detail) => handle_event(detail, "change")}
|
|
51
|
+
onupload={(detail) => handle_event(detail, "upload")}
|
|
52
|
+
onerror={(detail) => {
|
|
53
53
|
gradio.dispatch("error", detail);
|
|
54
54
|
}}
|
|
55
55
|
upload={(...args) => gradio.shared.client.upload(...args)}
|
|
@@ -1,44 +1,71 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { tick
|
|
2
|
+
import { tick } from "svelte";
|
|
3
3
|
import { BaseButton } from "@gradio/button";
|
|
4
4
|
import { prepare_files, type FileData, type Client } from "@gradio/client";
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
6
|
+
let {
|
|
7
|
+
elem_id = "",
|
|
8
|
+
elem_classes = [],
|
|
9
|
+
visible = true,
|
|
10
|
+
label,
|
|
11
|
+
value,
|
|
12
|
+
file_count,
|
|
13
|
+
file_types = [],
|
|
14
|
+
root,
|
|
15
|
+
size = "lg",
|
|
16
|
+
icon = null,
|
|
17
|
+
scale = null,
|
|
18
|
+
min_width = undefined,
|
|
19
|
+
variant = "secondary",
|
|
20
|
+
disabled = false,
|
|
21
|
+
max_file_size = null,
|
|
22
|
+
upload,
|
|
23
|
+
onclick,
|
|
24
|
+
onchange,
|
|
25
|
+
onupload,
|
|
26
|
+
onerror,
|
|
27
|
+
children
|
|
28
|
+
}: {
|
|
29
|
+
elem_id?: string;
|
|
30
|
+
elem_classes?: string[];
|
|
31
|
+
visible?: boolean | "hidden";
|
|
32
|
+
label: string | null;
|
|
33
|
+
value?: null | FileData | FileData[];
|
|
34
|
+
file_count: string;
|
|
35
|
+
file_types?: string[];
|
|
36
|
+
root: string;
|
|
37
|
+
size?: "sm" | "md" | "lg";
|
|
38
|
+
icon?: FileData | null;
|
|
39
|
+
scale?: number | null;
|
|
40
|
+
min_width?: number | undefined;
|
|
41
|
+
variant?: "primary" | "secondary" | "stop";
|
|
42
|
+
disabled?: boolean;
|
|
43
|
+
max_file_size?: number | null;
|
|
44
|
+
upload: Client["upload"];
|
|
45
|
+
onclick?: () => void;
|
|
46
|
+
onchange?: (value: null | FileData | FileData[]) => void;
|
|
47
|
+
onupload?: (value: null | FileData | FileData[]) => void;
|
|
48
|
+
onerror?: (message: string) => void;
|
|
49
|
+
children?: import("svelte").Snippet;
|
|
50
|
+
} = $props();
|
|
24
51
|
|
|
25
52
|
let hidden_upload: HTMLInputElement;
|
|
26
|
-
let accept_file_types: string | null;
|
|
27
53
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
54
|
+
let accept_file_types = $derived.by(() => {
|
|
55
|
+
if (file_types == null) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
const mapped = file_types.map((x) => {
|
|
32
59
|
if (x.startsWith(".")) {
|
|
33
60
|
return x;
|
|
34
61
|
}
|
|
35
62
|
return x + "/*";
|
|
36
63
|
});
|
|
37
|
-
|
|
38
|
-
}
|
|
64
|
+
return mapped.join(", ");
|
|
65
|
+
});
|
|
39
66
|
|
|
40
67
|
function open_file_upload(): void {
|
|
41
|
-
|
|
68
|
+
onclick?.();
|
|
42
69
|
hidden_upload.click();
|
|
43
70
|
}
|
|
44
71
|
|
|
@@ -59,12 +86,13 @@
|
|
|
59
86
|
await upload(all_file_data, root, undefined, max_file_size ?? Infinity)
|
|
60
87
|
)?.filter((x) => x !== null) as FileData[];
|
|
61
88
|
} catch (e) {
|
|
62
|
-
|
|
89
|
+
onerror?.((e as Error).message);
|
|
63
90
|
return;
|
|
64
91
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
92
|
+
const new_value =
|
|
93
|
+
file_count === "single" ? all_file_data?.[0] : all_file_data;
|
|
94
|
+
onchange?.(new_value);
|
|
95
|
+
onupload?.(new_value);
|
|
68
96
|
}
|
|
69
97
|
|
|
70
98
|
async function load_files_from_upload(e: Event): Promise<void> {
|
|
@@ -85,8 +113,8 @@
|
|
|
85
113
|
accept={accept_file_types}
|
|
86
114
|
type="file"
|
|
87
115
|
bind:this={hidden_upload}
|
|
88
|
-
|
|
89
|
-
|
|
116
|
+
onchange={load_files_from_upload}
|
|
117
|
+
onclick={clear_input_value}
|
|
90
118
|
multiple={file_count === "multiple" || undefined}
|
|
91
119
|
webkitdirectory={file_count === "directory" || undefined}
|
|
92
120
|
mozdirectory={file_count === "directory" || undefined}
|
|
@@ -99,7 +127,7 @@
|
|
|
99
127
|
{elem_id}
|
|
100
128
|
{elem_classes}
|
|
101
129
|
{visible}
|
|
102
|
-
|
|
130
|
+
onclick={open_file_upload}
|
|
103
131
|
{scale}
|
|
104
132
|
{min_width}
|
|
105
133
|
{disabled}
|
|
@@ -107,7 +135,7 @@
|
|
|
107
135
|
{#if icon}
|
|
108
136
|
<img class="button-icon" src={icon.url} alt={`${value} icon`} />
|
|
109
137
|
{/if}
|
|
110
|
-
|
|
138
|
+
{#if children}{@render children()}{/if}
|
|
111
139
|
</BaseButton>
|
|
112
140
|
|
|
113
141
|
<style>
|
|
@@ -1,28 +1,10 @@
|
|
|
1
1
|
import { type FileData, type Client } from "@gradio/client";
|
|
2
|
-
|
|
3
|
-
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
-
$$bindings?: Bindings;
|
|
5
|
-
} & Exports;
|
|
6
|
-
(internal: unknown, props: Props & {
|
|
7
|
-
$$events?: Events;
|
|
8
|
-
$$slots?: Slots;
|
|
9
|
-
}): Exports & {
|
|
10
|
-
$set?: any;
|
|
11
|
-
$on?: any;
|
|
12
|
-
};
|
|
13
|
-
z_$$bindings?: Bindings;
|
|
14
|
-
}
|
|
15
|
-
type $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {
|
|
16
|
-
default: any;
|
|
17
|
-
} ? Props extends Record<string, never> ? any : {
|
|
18
|
-
children?: any;
|
|
19
|
-
} : {});
|
|
20
|
-
declare const UploadButton: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{
|
|
2
|
+
type $$ComponentProps = {
|
|
21
3
|
elem_id?: string;
|
|
22
4
|
elem_classes?: string[];
|
|
23
5
|
visible?: boolean | "hidden";
|
|
24
6
|
label: string | null;
|
|
25
|
-
value
|
|
7
|
+
value?: null | FileData | FileData[];
|
|
26
8
|
file_count: string;
|
|
27
9
|
file_types?: string[];
|
|
28
10
|
root: string;
|
|
@@ -34,17 +16,12 @@ declare const UploadButton: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_Pr
|
|
|
34
16
|
disabled?: boolean;
|
|
35
17
|
max_file_size?: number | null;
|
|
36
18
|
upload: Client["upload"];
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
[evt: string]: CustomEvent<any>;
|
|
46
|
-
}, {
|
|
47
|
-
default: {};
|
|
48
|
-
}, {}, string>;
|
|
49
|
-
type UploadButton = InstanceType<typeof UploadButton>;
|
|
19
|
+
onclick?: () => void;
|
|
20
|
+
onchange?: (value: null | FileData | FileData[]) => void;
|
|
21
|
+
onupload?: (value: null | FileData | FileData[]) => void;
|
|
22
|
+
onerror?: (message: string) => void;
|
|
23
|
+
children?: import("svelte").Snippet;
|
|
24
|
+
};
|
|
25
|
+
declare const UploadButton: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
26
|
+
type UploadButton = ReturnType<typeof UploadButton>;
|
|
50
27
|
export default UploadButton;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradio/uploadbutton",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.17",
|
|
4
4
|
"description": "Gradio UI packages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "",
|
|
@@ -17,16 +17,16 @@
|
|
|
17
17
|
},
|
|
18
18
|
"main": "./Index.svelte",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@gradio/button": "^0.6.
|
|
21
|
-
"@gradio/
|
|
22
|
-
"@gradio/
|
|
23
|
-
"@gradio/utils": "^0.11.
|
|
20
|
+
"@gradio/button": "^0.6.3",
|
|
21
|
+
"@gradio/upload": "^0.17.4",
|
|
22
|
+
"@gradio/client": "^2.0.3",
|
|
23
|
+
"@gradio/utils": "^0.11.2"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@gradio/preview": "^0.15.
|
|
26
|
+
"@gradio/preview": "^0.15.2"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"svelte": "^5.
|
|
29
|
+
"svelte": "^5.48.0"
|
|
30
30
|
},
|
|
31
31
|
"repository": {
|
|
32
32
|
"type": "git",
|
|
@@ -1,44 +1,71 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { tick
|
|
2
|
+
import { tick } from "svelte";
|
|
3
3
|
import { BaseButton } from "@gradio/button";
|
|
4
4
|
import { prepare_files, type FileData, type Client } from "@gradio/client";
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
6
|
+
let {
|
|
7
|
+
elem_id = "",
|
|
8
|
+
elem_classes = [],
|
|
9
|
+
visible = true,
|
|
10
|
+
label,
|
|
11
|
+
value,
|
|
12
|
+
file_count,
|
|
13
|
+
file_types = [],
|
|
14
|
+
root,
|
|
15
|
+
size = "lg",
|
|
16
|
+
icon = null,
|
|
17
|
+
scale = null,
|
|
18
|
+
min_width = undefined,
|
|
19
|
+
variant = "secondary",
|
|
20
|
+
disabled = false,
|
|
21
|
+
max_file_size = null,
|
|
22
|
+
upload,
|
|
23
|
+
onclick,
|
|
24
|
+
onchange,
|
|
25
|
+
onupload,
|
|
26
|
+
onerror,
|
|
27
|
+
children
|
|
28
|
+
}: {
|
|
29
|
+
elem_id?: string;
|
|
30
|
+
elem_classes?: string[];
|
|
31
|
+
visible?: boolean | "hidden";
|
|
32
|
+
label: string | null;
|
|
33
|
+
value?: null | FileData | FileData[];
|
|
34
|
+
file_count: string;
|
|
35
|
+
file_types?: string[];
|
|
36
|
+
root: string;
|
|
37
|
+
size?: "sm" | "md" | "lg";
|
|
38
|
+
icon?: FileData | null;
|
|
39
|
+
scale?: number | null;
|
|
40
|
+
min_width?: number | undefined;
|
|
41
|
+
variant?: "primary" | "secondary" | "stop";
|
|
42
|
+
disabled?: boolean;
|
|
43
|
+
max_file_size?: number | null;
|
|
44
|
+
upload: Client["upload"];
|
|
45
|
+
onclick?: () => void;
|
|
46
|
+
onchange?: (value: null | FileData | FileData[]) => void;
|
|
47
|
+
onupload?: (value: null | FileData | FileData[]) => void;
|
|
48
|
+
onerror?: (message: string) => void;
|
|
49
|
+
children?: import("svelte").Snippet;
|
|
50
|
+
} = $props();
|
|
24
51
|
|
|
25
52
|
let hidden_upload: HTMLInputElement;
|
|
26
|
-
let accept_file_types: string | null;
|
|
27
53
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
54
|
+
let accept_file_types = $derived.by(() => {
|
|
55
|
+
if (file_types == null) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
const mapped = file_types.map((x) => {
|
|
32
59
|
if (x.startsWith(".")) {
|
|
33
60
|
return x;
|
|
34
61
|
}
|
|
35
62
|
return x + "/*";
|
|
36
63
|
});
|
|
37
|
-
|
|
38
|
-
}
|
|
64
|
+
return mapped.join(", ");
|
|
65
|
+
});
|
|
39
66
|
|
|
40
67
|
function open_file_upload(): void {
|
|
41
|
-
|
|
68
|
+
onclick?.();
|
|
42
69
|
hidden_upload.click();
|
|
43
70
|
}
|
|
44
71
|
|
|
@@ -59,12 +86,13 @@
|
|
|
59
86
|
await upload(all_file_data, root, undefined, max_file_size ?? Infinity)
|
|
60
87
|
)?.filter((x) => x !== null) as FileData[];
|
|
61
88
|
} catch (e) {
|
|
62
|
-
|
|
89
|
+
onerror?.((e as Error).message);
|
|
63
90
|
return;
|
|
64
91
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
92
|
+
const new_value =
|
|
93
|
+
file_count === "single" ? all_file_data?.[0] : all_file_data;
|
|
94
|
+
onchange?.(new_value);
|
|
95
|
+
onupload?.(new_value);
|
|
68
96
|
}
|
|
69
97
|
|
|
70
98
|
async function load_files_from_upload(e: Event): Promise<void> {
|
|
@@ -85,8 +113,8 @@
|
|
|
85
113
|
accept={accept_file_types}
|
|
86
114
|
type="file"
|
|
87
115
|
bind:this={hidden_upload}
|
|
88
|
-
|
|
89
|
-
|
|
116
|
+
onchange={load_files_from_upload}
|
|
117
|
+
onclick={clear_input_value}
|
|
90
118
|
multiple={file_count === "multiple" || undefined}
|
|
91
119
|
webkitdirectory={file_count === "directory" || undefined}
|
|
92
120
|
mozdirectory={file_count === "directory" || undefined}
|
|
@@ -99,7 +127,7 @@
|
|
|
99
127
|
{elem_id}
|
|
100
128
|
{elem_classes}
|
|
101
129
|
{visible}
|
|
102
|
-
|
|
130
|
+
onclick={open_file_upload}
|
|
103
131
|
{scale}
|
|
104
132
|
{min_width}
|
|
105
133
|
{disabled}
|
|
@@ -107,7 +135,7 @@
|
|
|
107
135
|
{#if icon}
|
|
108
136
|
<img class="button-icon" src={icon.url} alt={`${value} icon`} />
|
|
109
137
|
{/if}
|
|
110
|
-
|
|
138
|
+
{#if children}{@render children()}{/if}
|
|
111
139
|
</BaseButton>
|
|
112
140
|
|
|
113
141
|
<style>
|