@gradio/downloadbutton 0.1.27 → 0.1.28-beta.2
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 +28 -0
- package/dist/Index.svelte +34 -0
- package/dist/Index.svelte.d.ts +31 -0
- package/dist/shared/DownloadButton.svelte +60 -0
- package/dist/shared/DownloadButton.svelte.d.ts +30 -0
- package/package.json +13 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @gradio/downloadbutton
|
|
2
2
|
|
|
3
|
+
## 0.1.28-beta.2
|
|
4
|
+
|
|
5
|
+
### Dependency updates
|
|
6
|
+
|
|
7
|
+
- @gradio/client@1.6.0-beta.2
|
|
8
|
+
- @gradio/utils@0.7.0-beta.2
|
|
9
|
+
- @gradio/button@0.3.0-beta.2
|
|
10
|
+
|
|
11
|
+
## 0.1.28-beta.1
|
|
12
|
+
|
|
13
|
+
### Dependency updates
|
|
14
|
+
|
|
15
|
+
- @gradio/utils@0.7.0-beta.1
|
|
16
|
+
- @gradio/client@1.6.0-beta.1
|
|
17
|
+
- @gradio/button@0.3.0-beta.1
|
|
18
|
+
|
|
19
|
+
## 0.1.28
|
|
20
|
+
|
|
21
|
+
### Fixes
|
|
22
|
+
|
|
23
|
+
- [#9163](https://github.com/gradio-app/gradio/pull/9163) [`2b6cbf2`](https://github.com/gradio-app/gradio/commit/2b6cbf25908e42cf027324e54ef2cc0baad11a91) - fix exports and generate types. Thanks @pngwn!
|
|
24
|
+
|
|
25
|
+
### Dependency updates
|
|
26
|
+
|
|
27
|
+
- @gradio/utils@0.6.1
|
|
28
|
+
- @gradio/client@1.5.2
|
|
29
|
+
- @gradio/button@0.2.51
|
|
30
|
+
|
|
3
31
|
## 0.1.27
|
|
4
32
|
|
|
5
33
|
### Features
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<script context="module">export { default as BaseButton } from "./shared/DownloadButton.svelte";
|
|
2
|
+
</script>
|
|
3
|
+
|
|
4
|
+
<script>import {} from "@gradio/client";
|
|
5
|
+
import DownloadButton from "./shared/DownloadButton.svelte";
|
|
6
|
+
export let elem_id = "";
|
|
7
|
+
export let elem_classes = [];
|
|
8
|
+
export let visible = true;
|
|
9
|
+
export let value;
|
|
10
|
+
export let variant = "secondary";
|
|
11
|
+
export let interactive;
|
|
12
|
+
export let size = "lg";
|
|
13
|
+
export let scale = null;
|
|
14
|
+
export let icon = null;
|
|
15
|
+
export let min_width = void 0;
|
|
16
|
+
export let label = null;
|
|
17
|
+
export let gradio;
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<DownloadButton
|
|
21
|
+
{value}
|
|
22
|
+
{variant}
|
|
23
|
+
{elem_id}
|
|
24
|
+
{elem_classes}
|
|
25
|
+
{size}
|
|
26
|
+
{scale}
|
|
27
|
+
{icon}
|
|
28
|
+
{min_width}
|
|
29
|
+
{visible}
|
|
30
|
+
disabled={!interactive}
|
|
31
|
+
on:click={() => gradio.dispatch("click")}
|
|
32
|
+
>
|
|
33
|
+
{label ? gradio.i18n(label) : ""}
|
|
34
|
+
</DownloadButton>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
export { default as BaseButton } from "./shared/DownloadButton.svelte";
|
|
3
|
+
import type { Gradio } from "@gradio/utils";
|
|
4
|
+
import { type FileData } from "@gradio/client";
|
|
5
|
+
declare const __propDef: {
|
|
6
|
+
props: {
|
|
7
|
+
elem_id?: string | undefined;
|
|
8
|
+
elem_classes?: string[] | undefined;
|
|
9
|
+
visible?: boolean | undefined;
|
|
10
|
+
value: null | FileData;
|
|
11
|
+
variant?: ("primary" | "secondary" | "stop") | undefined;
|
|
12
|
+
interactive: boolean;
|
|
13
|
+
size?: ("sm" | "lg") | undefined;
|
|
14
|
+
scale?: (number | null) | undefined;
|
|
15
|
+
icon?: (null | FileData) | undefined;
|
|
16
|
+
min_width?: number | undefined;
|
|
17
|
+
label?: (string | null) | undefined;
|
|
18
|
+
gradio: Gradio<{
|
|
19
|
+
click: never;
|
|
20
|
+
}>;
|
|
21
|
+
};
|
|
22
|
+
events: {
|
|
23
|
+
[evt: string]: CustomEvent<any>;
|
|
24
|
+
};
|
|
25
|
+
slots: {};
|
|
26
|
+
};
|
|
27
|
+
export type IndexProps = typeof __propDef.props;
|
|
28
|
+
export type IndexEvents = typeof __propDef.events;
|
|
29
|
+
export type IndexSlots = typeof __propDef.slots;
|
|
30
|
+
export default class Index extends SvelteComponent<IndexProps, IndexEvents, IndexSlots> {
|
|
31
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<script>import { createEventDispatcher } from "svelte";
|
|
2
|
+
import {} from "@gradio/client";
|
|
3
|
+
import { BaseButton } from "@gradio/button";
|
|
4
|
+
export let elem_id = "";
|
|
5
|
+
export let elem_classes = [];
|
|
6
|
+
export let visible = true;
|
|
7
|
+
export let variant = "secondary";
|
|
8
|
+
export let size = "lg";
|
|
9
|
+
export let value;
|
|
10
|
+
export let icon;
|
|
11
|
+
export let disabled = false;
|
|
12
|
+
export let scale = null;
|
|
13
|
+
export let min_width = void 0;
|
|
14
|
+
const dispatch = createEventDispatcher();
|
|
15
|
+
function download_file() {
|
|
16
|
+
dispatch("click");
|
|
17
|
+
if (!value?.url) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
let file_name;
|
|
21
|
+
if (!value.orig_name && value.url) {
|
|
22
|
+
const parts = value.url.split("/");
|
|
23
|
+
file_name = parts[parts.length - 1];
|
|
24
|
+
file_name = file_name.split("?")[0].split("#")[0];
|
|
25
|
+
} else {
|
|
26
|
+
file_name = value.orig_name;
|
|
27
|
+
}
|
|
28
|
+
const a = document.createElement("a");
|
|
29
|
+
a.href = value.url;
|
|
30
|
+
a.download = file_name || "file";
|
|
31
|
+
document.body.appendChild(a);
|
|
32
|
+
a.click();
|
|
33
|
+
document.body.removeChild(a);
|
|
34
|
+
}
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<BaseButton
|
|
38
|
+
{size}
|
|
39
|
+
{variant}
|
|
40
|
+
{elem_id}
|
|
41
|
+
{elem_classes}
|
|
42
|
+
{visible}
|
|
43
|
+
on:click={download_file}
|
|
44
|
+
{scale}
|
|
45
|
+
{min_width}
|
|
46
|
+
{disabled}
|
|
47
|
+
>
|
|
48
|
+
{#if icon}
|
|
49
|
+
<img class="button-icon" src={icon.url} alt={`${value} icon`} />
|
|
50
|
+
{/if}
|
|
51
|
+
<slot />
|
|
52
|
+
</BaseButton>
|
|
53
|
+
|
|
54
|
+
<style>
|
|
55
|
+
.button-icon {
|
|
56
|
+
width: var(--text-xl);
|
|
57
|
+
height: var(--text-xl);
|
|
58
|
+
margin-right: var(--spacing-xl);
|
|
59
|
+
}
|
|
60
|
+
</style>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import { type FileData } from "@gradio/client";
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
elem_id?: string | undefined;
|
|
6
|
+
elem_classes?: string[] | undefined;
|
|
7
|
+
visible?: boolean | undefined;
|
|
8
|
+
variant?: ("primary" | "secondary" | "stop") | undefined;
|
|
9
|
+
size?: ("sm" | "lg") | undefined;
|
|
10
|
+
value: null | FileData;
|
|
11
|
+
icon: null | FileData;
|
|
12
|
+
disabled?: boolean | undefined;
|
|
13
|
+
scale?: (number | null) | undefined;
|
|
14
|
+
min_width?: number | undefined;
|
|
15
|
+
};
|
|
16
|
+
events: {
|
|
17
|
+
click: CustomEvent<any>;
|
|
18
|
+
} & {
|
|
19
|
+
[evt: string]: CustomEvent<any>;
|
|
20
|
+
};
|
|
21
|
+
slots: {
|
|
22
|
+
default: {};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export type DownloadButtonProps = typeof __propDef.props;
|
|
26
|
+
export type DownloadButtonEvents = typeof __propDef.events;
|
|
27
|
+
export type DownloadButtonSlots = typeof __propDef.slots;
|
|
28
|
+
export default class DownloadButton extends SvelteComponent<DownloadButtonProps, DownloadButtonEvents, DownloadButtonSlots> {
|
|
29
|
+
}
|
|
30
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,25 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradio/downloadbutton",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.28-beta.2",
|
|
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/button": "^0.2
|
|
11
|
-
"@gradio/client": "^1.
|
|
12
|
-
"@gradio/utils": "^0.
|
|
10
|
+
"@gradio/button": "^0.3.0-beta.2",
|
|
11
|
+
"@gradio/client": "^1.6.0-beta.2",
|
|
12
|
+
"@gradio/utils": "^0.7.0-beta.2"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@gradio/preview": "^0.11.
|
|
15
|
+
"@gradio/preview": "^0.11.1"
|
|
16
16
|
},
|
|
17
17
|
"main": "./Index.svelte",
|
|
18
18
|
"main_changeset": true,
|
|
19
19
|
"exports": {
|
|
20
|
-
".":
|
|
20
|
+
".": {
|
|
21
|
+
"gradio": "./Index.svelte",
|
|
22
|
+
"svelte": "./dist/Index.svelte",
|
|
23
|
+
"types": "./dist/Index.svelte.d.ts"
|
|
24
|
+
},
|
|
21
25
|
"./package.json": "./package.json"
|
|
22
26
|
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"svelte": "^4.0.0"
|
|
29
|
+
},
|
|
23
30
|
"repository": {
|
|
24
31
|
"type": "git",
|
|
25
32
|
"url": "git+https://github.com/gradio-app/gradio.git",
|