@gradio/downloadbutton 0.4.15 → 0.4.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 +25 -0
- package/DownloadButton.stories.svelte +64 -60
- package/Index.svelte +1 -1
- package/dist/Index.svelte +1 -1
- package/dist/shared/DownloadButton.svelte +33 -15
- package/dist/shared/DownloadButton.svelte.d.ts +9 -31
- package/package.json +6 -6
- package/shared/DownloadButton.svelte +33 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @gradio/downloadbutton
|
|
2
2
|
|
|
3
|
+
## 0.4.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
|
+
|
|
9
|
+
### Dependency updates
|
|
10
|
+
|
|
11
|
+
- @gradio/button@0.6.3
|
|
12
|
+
- @gradio/utils@0.11.2
|
|
13
|
+
- @gradio/client@2.0.3
|
|
14
|
+
|
|
15
|
+
## 0.4.16
|
|
16
|
+
|
|
17
|
+
### Fixes
|
|
18
|
+
|
|
19
|
+
- [#12689](https://github.com/gradio-app/gradio/pull/12689) [`be89f8c`](https://github.com/gradio-app/gradio/commit/be89f8c4272a2d2c3da9345c3e26df5505307428) - Migrate DownloadButton to Svelte 5. Thanks @dawoodkhan82!
|
|
20
|
+
- [#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!
|
|
21
|
+
|
|
22
|
+
### Dependency updates
|
|
23
|
+
|
|
24
|
+
- @gradio/utils@0.11.1
|
|
25
|
+
- @gradio/button@0.6.2
|
|
26
|
+
- @gradio/client@2.0.2
|
|
27
|
+
|
|
3
28
|
## 0.4.15
|
|
4
29
|
|
|
5
30
|
### Dependency updates
|
|
@@ -1,69 +1,75 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import {
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from "@storybook/addon-svelte-csf";
|
|
3
3
|
import DownloadButton 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/DownloadButton",
|
|
8
|
+
component: DownloadButton,
|
|
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
|
-
<DownloadButton value
|
|
56
|
-
|
|
54
|
+
{#snippet template(args)}
|
|
55
|
+
<DownloadButton {...wrapProps({ value: "", interactive: true, ...args })} />
|
|
56
|
+
{/snippet}
|
|
57
57
|
|
|
58
58
|
<Story
|
|
59
59
|
name="Primary"
|
|
60
60
|
args={{ label: "Download", variant: "primary", size: "lg", scale: 1 }}
|
|
61
|
+
{template}
|
|
61
62
|
/>
|
|
62
63
|
<Story
|
|
63
64
|
name="Secondary"
|
|
64
65
|
args={{ label: "Download", variant: "secondary", size: "lg" }}
|
|
66
|
+
{template}
|
|
67
|
+
/>
|
|
68
|
+
<Story
|
|
69
|
+
name="Stop"
|
|
70
|
+
args={{ label: "Download", variant: "stop", size: "lg" }}
|
|
71
|
+
{template}
|
|
65
72
|
/>
|
|
66
|
-
<Story name="Stop" args={{ label: "Download", 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: "Download", 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/Index.svelte
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
min_width={gradio.shared.min_width}
|
|
23
23
|
visible={gradio.shared.visible}
|
|
24
24
|
disabled={!gradio.shared.interactive}
|
|
25
|
-
|
|
25
|
+
on_click={() => gradio.dispatch("click")}
|
|
26
26
|
>
|
|
27
27
|
{gradio.shared.label ?? ""}
|
|
28
28
|
</DownloadButton>
|
package/dist/Index.svelte
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
min_width={gradio.shared.min_width}
|
|
23
23
|
visible={gradio.shared.visible}
|
|
24
24
|
disabled={!gradio.shared.interactive}
|
|
25
|
-
|
|
25
|
+
on_click={() => gradio.dispatch("click")}
|
|
26
26
|
>
|
|
27
27
|
{gradio.shared.label ?? ""}
|
|
28
28
|
</DownloadButton>
|
|
@@ -1,22 +1,38 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { createEventDispatcher } from "svelte";
|
|
3
2
|
import { type FileData } from "@gradio/client";
|
|
4
3
|
import { BaseButton } from "@gradio/button";
|
|
4
|
+
import { type Snippet } from "svelte";
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
let {
|
|
7
|
+
elem_id = "",
|
|
8
|
+
elem_classes = [],
|
|
9
|
+
visible = true,
|
|
10
|
+
variant = "secondary",
|
|
11
|
+
size = "lg",
|
|
12
|
+
value,
|
|
13
|
+
icon,
|
|
14
|
+
disabled = false,
|
|
15
|
+
scale = null,
|
|
16
|
+
min_width = undefined,
|
|
17
|
+
on_click,
|
|
18
|
+
children
|
|
19
|
+
}: {
|
|
20
|
+
elem_id?: string;
|
|
21
|
+
elem_classes?: string[];
|
|
22
|
+
visible?: boolean | "hidden";
|
|
23
|
+
variant?: "primary" | "secondary" | "stop";
|
|
24
|
+
size?: "sm" | "md" | "lg";
|
|
25
|
+
value: FileData | null;
|
|
26
|
+
icon: FileData | null;
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
scale?: number | null;
|
|
29
|
+
min_width?: number | undefined;
|
|
30
|
+
on_click?: () => void;
|
|
31
|
+
children?: Snippet;
|
|
32
|
+
} = $props();
|
|
17
33
|
|
|
18
34
|
function download_file(): void {
|
|
19
|
-
|
|
35
|
+
on_click?.();
|
|
20
36
|
if (!value?.url) {
|
|
21
37
|
return;
|
|
22
38
|
}
|
|
@@ -43,7 +59,7 @@
|
|
|
43
59
|
{elem_id}
|
|
44
60
|
{elem_classes}
|
|
45
61
|
{visible}
|
|
46
|
-
|
|
62
|
+
onclick={download_file}
|
|
47
63
|
{scale}
|
|
48
64
|
{min_width}
|
|
49
65
|
{disabled}
|
|
@@ -51,7 +67,9 @@
|
|
|
51
67
|
{#if icon}
|
|
52
68
|
<img class="button-icon" src={icon.url} alt={`${value} icon`} />
|
|
53
69
|
{/if}
|
|
54
|
-
|
|
70
|
+
{#if children}
|
|
71
|
+
{@render children()}
|
|
72
|
+
{/if}
|
|
55
73
|
</BaseButton>
|
|
56
74
|
|
|
57
75
|
<style>
|
|
@@ -1,41 +1,19 @@
|
|
|
1
1
|
import { type FileData } from "@gradio/client";
|
|
2
|
-
|
|
3
|
-
|
|
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 DownloadButton: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{
|
|
2
|
+
import { type Snippet } from "svelte";
|
|
3
|
+
type $$ComponentProps = {
|
|
21
4
|
elem_id?: string;
|
|
22
5
|
elem_classes?: string[];
|
|
23
6
|
visible?: boolean | "hidden";
|
|
24
7
|
variant?: "primary" | "secondary" | "stop";
|
|
25
8
|
size?: "sm" | "md" | "lg";
|
|
26
|
-
value:
|
|
27
|
-
icon:
|
|
9
|
+
value: FileData | null;
|
|
10
|
+
icon: FileData | null;
|
|
28
11
|
disabled?: boolean;
|
|
29
12
|
scale?: number | null;
|
|
30
13
|
min_width?: number | undefined;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
[evt: string]: CustomEvent<any>;
|
|
37
|
-
}, {
|
|
38
|
-
default: {};
|
|
39
|
-
}, {}, string>;
|
|
40
|
-
type DownloadButton = InstanceType<typeof DownloadButton>;
|
|
14
|
+
on_click?: () => void;
|
|
15
|
+
children?: Snippet;
|
|
16
|
+
};
|
|
17
|
+
declare const DownloadButton: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
18
|
+
type DownloadButton = ReturnType<typeof DownloadButton>;
|
|
41
19
|
export default DownloadButton;
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradio/downloadbutton",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.17",
|
|
4
4
|
"description": "Gradio UI packages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "",
|
|
7
7
|
"license": "ISC",
|
|
8
8
|
"private": false,
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@gradio/
|
|
11
|
-
"@gradio/
|
|
12
|
-
"@gradio/
|
|
10
|
+
"@gradio/button": "^0.6.3",
|
|
11
|
+
"@gradio/client": "^2.0.3",
|
|
12
|
+
"@gradio/utils": "^0.11.2"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@gradio/preview": "^0.15.
|
|
15
|
+
"@gradio/preview": "^0.15.2"
|
|
16
16
|
},
|
|
17
17
|
"main": "./Index.svelte",
|
|
18
18
|
"main_changeset": true,
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"svelte": "^5.
|
|
28
|
+
"svelte": "^5.48.0"
|
|
29
29
|
},
|
|
30
30
|
"repository": {
|
|
31
31
|
"type": "git",
|
|
@@ -1,22 +1,38 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { createEventDispatcher } from "svelte";
|
|
3
2
|
import { type FileData } from "@gradio/client";
|
|
4
3
|
import { BaseButton } from "@gradio/button";
|
|
4
|
+
import { type Snippet } from "svelte";
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
let {
|
|
7
|
+
elem_id = "",
|
|
8
|
+
elem_classes = [],
|
|
9
|
+
visible = true,
|
|
10
|
+
variant = "secondary",
|
|
11
|
+
size = "lg",
|
|
12
|
+
value,
|
|
13
|
+
icon,
|
|
14
|
+
disabled = false,
|
|
15
|
+
scale = null,
|
|
16
|
+
min_width = undefined,
|
|
17
|
+
on_click,
|
|
18
|
+
children
|
|
19
|
+
}: {
|
|
20
|
+
elem_id?: string;
|
|
21
|
+
elem_classes?: string[];
|
|
22
|
+
visible?: boolean | "hidden";
|
|
23
|
+
variant?: "primary" | "secondary" | "stop";
|
|
24
|
+
size?: "sm" | "md" | "lg";
|
|
25
|
+
value: FileData | null;
|
|
26
|
+
icon: FileData | null;
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
scale?: number | null;
|
|
29
|
+
min_width?: number | undefined;
|
|
30
|
+
on_click?: () => void;
|
|
31
|
+
children?: Snippet;
|
|
32
|
+
} = $props();
|
|
17
33
|
|
|
18
34
|
function download_file(): void {
|
|
19
|
-
|
|
35
|
+
on_click?.();
|
|
20
36
|
if (!value?.url) {
|
|
21
37
|
return;
|
|
22
38
|
}
|
|
@@ -43,7 +59,7 @@
|
|
|
43
59
|
{elem_id}
|
|
44
60
|
{elem_classes}
|
|
45
61
|
{visible}
|
|
46
|
-
|
|
62
|
+
onclick={download_file}
|
|
47
63
|
{scale}
|
|
48
64
|
{min_width}
|
|
49
65
|
{disabled}
|
|
@@ -51,7 +67,9 @@
|
|
|
51
67
|
{#if icon}
|
|
52
68
|
<img class="button-icon" src={icon.url} alt={`${value} icon`} />
|
|
53
69
|
{/if}
|
|
54
|
-
|
|
70
|
+
{#if children}
|
|
71
|
+
{@render children()}
|
|
72
|
+
{/if}
|
|
55
73
|
</BaseButton>
|
|
56
74
|
|
|
57
75
|
<style>
|