@gradio/downloadbutton 0.4.13-dev.0 → 0.4.13
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 +31 -0
- package/Index.svelte +15 -28
- package/dist/Index.svelte +20 -26
- package/dist/Index.svelte.d.ts +3 -32
- package/dist/shared/DownloadButton.svelte +37 -34
- package/dist/shared/DownloadButton.svelte.d.ts +38 -29
- package/dist/types.d.ts +10 -0
- package/dist/types.js +1 -0
- package/package.json +6 -6
- package/types.ts +12 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,35 @@
|
|
|
1
1
|
# @gradio/downloadbutton
|
|
2
|
+
## 0.4.13
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
- [#12438](https://github.com/gradio-app/gradio/pull/12438) [`25ffc03`](https://github.com/gradio-app/gradio/commit/25ffc0398f8feb43d817c02b2ab970c16de6d797) - Svelte5 migration and bugfix
|
|
7
|
+
|
|
8
|
+
### Dependencies
|
|
9
|
+
|
|
10
|
+
- @gradio/button@0.5.14
|
|
11
|
+
- @gradio/client@2.0.0
|
|
12
|
+
- @gradio/utils@0.10.3
|
|
13
|
+
|
|
14
|
+
## 0.4.13-dev.1
|
|
15
|
+
|
|
16
|
+
### Dependency updates
|
|
17
|
+
|
|
18
|
+
- @gradio/client@2.0.0-dev.2
|
|
19
|
+
- @gradio/button@0.5.14-dev.2
|
|
20
|
+
|
|
21
|
+
## 0.4.13-dev.1
|
|
22
|
+
|
|
23
|
+
### Dependency updates
|
|
24
|
+
|
|
25
|
+
- @gradio/utils@0.10.3-dev.0
|
|
26
|
+
- @gradio/button@0.5.14-dev.1
|
|
27
|
+
|
|
28
|
+
## 0.4.13-dev.0
|
|
29
|
+
|
|
30
|
+
### Dependency updates
|
|
31
|
+
|
|
32
|
+
- @gradio/client@2.0.0-dev.1
|
|
2
33
|
|
|
3
34
|
## 0.4.13-dev.0
|
|
4
35
|
|
package/Index.svelte
CHANGED
|
@@ -3,39 +3,26 @@
|
|
|
3
3
|
</script>
|
|
4
4
|
|
|
5
5
|
<script lang="ts">
|
|
6
|
-
import
|
|
7
|
-
import { type FileData } from "@gradio/client";
|
|
8
|
-
|
|
6
|
+
import { Gradio } from "@gradio/utils";
|
|
9
7
|
import DownloadButton from "./shared/DownloadButton.svelte";
|
|
8
|
+
import type { DownloadButtonProps, DownloadButtonEvents } from "./types";
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export let visible: boolean | "hidden" = true;
|
|
14
|
-
export let value: null | FileData;
|
|
15
|
-
export let variant: "primary" | "secondary" | "stop" = "secondary";
|
|
16
|
-
export let interactive: boolean;
|
|
17
|
-
export let size: "sm" | "lg" = "lg";
|
|
18
|
-
export let scale: number | null = null;
|
|
19
|
-
export let icon: null | FileData = null;
|
|
20
|
-
export let min_width: number | undefined = undefined;
|
|
21
|
-
export let label: string | null = null;
|
|
22
|
-
export let gradio: Gradio<{
|
|
23
|
-
click: never;
|
|
24
|
-
}>;
|
|
10
|
+
const props = $props();
|
|
11
|
+
const gradio = new Gradio<DownloadButtonEvents, DownloadButtonProps>(props);
|
|
25
12
|
</script>
|
|
26
13
|
|
|
27
14
|
<DownloadButton
|
|
28
|
-
{value}
|
|
29
|
-
{variant}
|
|
30
|
-
{elem_id}
|
|
31
|
-
{elem_classes}
|
|
32
|
-
{size}
|
|
33
|
-
{scale}
|
|
34
|
-
{icon}
|
|
35
|
-
{min_width}
|
|
36
|
-
{visible}
|
|
37
|
-
disabled={!interactive}
|
|
15
|
+
value={gradio.props.value}
|
|
16
|
+
variant={gradio.props.variant}
|
|
17
|
+
elem_id={gradio.shared.elem_id}
|
|
18
|
+
elem_classes={gradio.shared.elem_classes}
|
|
19
|
+
size={gradio.props.size}
|
|
20
|
+
scale={gradio.shared.scale}
|
|
21
|
+
icon={gradio.props.icon}
|
|
22
|
+
min_width={gradio.shared.min_width}
|
|
23
|
+
visible={gradio.shared.visible}
|
|
24
|
+
disabled={!gradio.shared.interactive}
|
|
38
25
|
on:click={() => gradio.dispatch("click")}
|
|
39
26
|
>
|
|
40
|
-
{label ?? ""}
|
|
27
|
+
{gradio.shared.label ?? ""}
|
|
41
28
|
</DownloadButton>
|
package/dist/Index.svelte
CHANGED
|
@@ -1,34 +1,28 @@
|
|
|
1
|
-
<script context="module"
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
|
+
export { default as BaseButton } from "./shared/DownloadButton.svelte";
|
|
2
3
|
</script>
|
|
3
4
|
|
|
4
|
-
<script
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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;
|
|
5
|
+
<script lang="ts">
|
|
6
|
+
import { Gradio } from "@gradio/utils";
|
|
7
|
+
import DownloadButton from "./shared/DownloadButton.svelte";
|
|
8
|
+
import type { DownloadButtonProps, DownloadButtonEvents } from "./types";
|
|
9
|
+
|
|
10
|
+
const props = $props();
|
|
11
|
+
const gradio = new Gradio<DownloadButtonEvents, DownloadButtonProps>(props);
|
|
18
12
|
</script>
|
|
19
13
|
|
|
20
14
|
<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}
|
|
15
|
+
value={gradio.props.value}
|
|
16
|
+
variant={gradio.props.variant}
|
|
17
|
+
elem_id={gradio.shared.elem_id}
|
|
18
|
+
elem_classes={gradio.shared.elem_classes}
|
|
19
|
+
size={gradio.props.size}
|
|
20
|
+
scale={gradio.shared.scale}
|
|
21
|
+
icon={gradio.props.icon}
|
|
22
|
+
min_width={gradio.shared.min_width}
|
|
23
|
+
visible={gradio.shared.visible}
|
|
24
|
+
disabled={!gradio.shared.interactive}
|
|
31
25
|
on:click={() => gradio.dispatch("click")}
|
|
32
26
|
>
|
|
33
|
-
{label ?? ""}
|
|
27
|
+
{gradio.shared.label ?? ""}
|
|
34
28
|
</DownloadButton>
|
package/dist/Index.svelte.d.ts
CHANGED
|
@@ -1,33 +1,4 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
export { default as BaseButton } from "./shared/DownloadButton.svelte";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
props: {
|
|
7
|
-
elem_id?: string;
|
|
8
|
-
elem_classes?: string[];
|
|
9
|
-
visible?: boolean | "hidden";
|
|
10
|
-
value: null | FileData;
|
|
11
|
-
variant?: "primary" | "secondary" | "stop";
|
|
12
|
-
interactive: boolean;
|
|
13
|
-
size?: "sm" | "lg";
|
|
14
|
-
scale?: number | null;
|
|
15
|
-
icon?: null | FileData;
|
|
16
|
-
min_width?: number | undefined;
|
|
17
|
-
label?: string | null;
|
|
18
|
-
gradio: Gradio<{
|
|
19
|
-
click: never;
|
|
20
|
-
}>;
|
|
21
|
-
};
|
|
22
|
-
events: {
|
|
23
|
-
[evt: string]: CustomEvent<any>;
|
|
24
|
-
};
|
|
25
|
-
slots: {};
|
|
26
|
-
exports?: {} | undefined;
|
|
27
|
-
bindings?: string | undefined;
|
|
28
|
-
};
|
|
29
|
-
export type IndexProps = typeof __propDef.props;
|
|
30
|
-
export type IndexEvents = typeof __propDef.events;
|
|
31
|
-
export type IndexSlots = typeof __propDef.slots;
|
|
32
|
-
export default class Index extends SvelteComponent<IndexProps, IndexEvents, IndexSlots> {
|
|
33
|
-
}
|
|
2
|
+
declare const Index: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
3
|
+
type Index = ReturnType<typeof Index>;
|
|
4
|
+
export default Index;
|
|
@@ -1,37 +1,40 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {} from "
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export let
|
|
7
|
-
export let
|
|
8
|
-
export let
|
|
9
|
-
export let
|
|
10
|
-
export let
|
|
11
|
-
export let
|
|
12
|
-
export let
|
|
13
|
-
export let
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { createEventDispatcher } from "svelte";
|
|
3
|
+
import { type FileData } from "@gradio/client";
|
|
4
|
+
import { BaseButton } from "@gradio/button";
|
|
5
|
+
|
|
6
|
+
export let elem_id = "";
|
|
7
|
+
export let elem_classes: string[] = [];
|
|
8
|
+
export let visible: boolean | "hidden" = true;
|
|
9
|
+
export let variant: "primary" | "secondary" | "stop" = "secondary";
|
|
10
|
+
export let size: "sm" | "md" | "lg" = "lg";
|
|
11
|
+
export let value: null | FileData;
|
|
12
|
+
export let icon: null | FileData;
|
|
13
|
+
export let disabled = false;
|
|
14
|
+
export let scale: number | null = null;
|
|
15
|
+
export let min_width: number | undefined = undefined;
|
|
16
|
+
const dispatch = createEventDispatcher();
|
|
17
|
+
|
|
18
|
+
function download_file(): void {
|
|
19
|
+
dispatch("click");
|
|
20
|
+
if (!value?.url) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
let file_name;
|
|
24
|
+
if (!value.orig_name && value.url) {
|
|
25
|
+
const parts = value.url.split("/");
|
|
26
|
+
file_name = parts[parts.length - 1];
|
|
27
|
+
file_name = file_name.split("?")[0].split("#")[0];
|
|
28
|
+
} else {
|
|
29
|
+
file_name = value.orig_name;
|
|
30
|
+
}
|
|
31
|
+
const a = document.createElement("a");
|
|
32
|
+
a.href = value.url;
|
|
33
|
+
a.download = file_name || "file";
|
|
34
|
+
document.body.appendChild(a);
|
|
35
|
+
a.click();
|
|
36
|
+
document.body.removeChild(a);
|
|
37
|
+
}
|
|
35
38
|
</script>
|
|
36
39
|
|
|
37
40
|
<BaseButton
|
|
@@ -1,32 +1,41 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import { type FileData } from "@gradio/client";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
scale?: number | null;
|
|
14
|
-
min_width?: number | undefined;
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
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;
|
|
15
12
|
};
|
|
16
|
-
|
|
17
|
-
click: CustomEvent<any>;
|
|
18
|
-
} & {
|
|
19
|
-
[evt: string]: CustomEvent<any>;
|
|
20
|
-
};
|
|
21
|
-
slots: {
|
|
22
|
-
default: {};
|
|
23
|
-
};
|
|
24
|
-
exports?: {} | undefined;
|
|
25
|
-
bindings?: string | undefined;
|
|
26
|
-
};
|
|
27
|
-
export type DownloadButtonProps = typeof __propDef.props;
|
|
28
|
-
export type DownloadButtonEvents = typeof __propDef.events;
|
|
29
|
-
export type DownloadButtonSlots = typeof __propDef.slots;
|
|
30
|
-
export default class DownloadButton extends SvelteComponent<DownloadButtonProps, DownloadButtonEvents, DownloadButtonSlots> {
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
31
14
|
}
|
|
32
|
-
|
|
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<{
|
|
21
|
+
elem_id?: string;
|
|
22
|
+
elem_classes?: string[];
|
|
23
|
+
visible?: boolean | "hidden";
|
|
24
|
+
variant?: "primary" | "secondary" | "stop";
|
|
25
|
+
size?: "sm" | "md" | "lg";
|
|
26
|
+
value: null | FileData;
|
|
27
|
+
icon: null | FileData;
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
scale?: number | null;
|
|
30
|
+
min_width?: number | undefined;
|
|
31
|
+
}, {
|
|
32
|
+
default: {};
|
|
33
|
+
}>, {
|
|
34
|
+
click: CustomEvent<any>;
|
|
35
|
+
} & {
|
|
36
|
+
[evt: string]: CustomEvent<any>;
|
|
37
|
+
}, {
|
|
38
|
+
default: {};
|
|
39
|
+
}, {}, string>;
|
|
40
|
+
type DownloadButton = InstanceType<typeof DownloadButton>;
|
|
41
|
+
export default DownloadButton;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FileData } from "@gradio/client";
|
|
2
|
+
export interface DownloadButtonProps {
|
|
3
|
+
value: FileData | null;
|
|
4
|
+
variant: "primary" | "secondary" | "stop";
|
|
5
|
+
size: "sm" | "lg";
|
|
6
|
+
icon: FileData | null;
|
|
7
|
+
}
|
|
8
|
+
export interface DownloadButtonEvents {
|
|
9
|
+
click: never;
|
|
10
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradio/downloadbutton",
|
|
3
|
-
"version": "0.4.13
|
|
3
|
+
"version": "0.4.13",
|
|
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.5.14
|
|
11
|
-
"@gradio/
|
|
12
|
-
"@gradio/
|
|
10
|
+
"@gradio/button": "^0.5.14",
|
|
11
|
+
"@gradio/utils": "^0.10.3",
|
|
12
|
+
"@gradio/client": "^2.0.0"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@gradio/preview": "^0.
|
|
15
|
+
"@gradio/preview": "^0.15.0"
|
|
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": "^
|
|
28
|
+
"svelte": "^5.43.4"
|
|
29
29
|
},
|
|
30
30
|
"repository": {
|
|
31
31
|
"type": "git",
|
package/types.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FileData } from "@gradio/client";
|
|
2
|
+
|
|
3
|
+
export interface DownloadButtonProps {
|
|
4
|
+
value: FileData | null;
|
|
5
|
+
variant: "primary" | "secondary" | "stop";
|
|
6
|
+
size: "sm" | "lg";
|
|
7
|
+
icon: FileData | null;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface DownloadButtonEvents {
|
|
11
|
+
click: never;
|
|
12
|
+
}
|