@gradio/downloadbutton 0.4.13-dev.0 → 0.4.13-dev.1

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 CHANGED
@@ -1,5 +1,25 @@
1
1
  # @gradio/downloadbutton
2
2
 
3
+ ## 0.4.13-dev.1
4
+
5
+ ### Dependency updates
6
+
7
+ - @gradio/client@2.0.0-dev.2
8
+ - @gradio/button@0.5.14-dev.2
9
+
10
+ ## 0.4.13-dev.1
11
+
12
+ ### Dependency updates
13
+
14
+ - @gradio/utils@0.10.3-dev.0
15
+ - @gradio/button@0.5.14-dev.1
16
+
17
+ ## 0.4.13-dev.0
18
+
19
+ ### Dependency updates
20
+
21
+ - @gradio/client@2.0.0-dev.1
22
+
3
23
  ## 0.4.13-dev.0
4
24
 
5
25
  ### Dependency updates
package/Index.svelte CHANGED
@@ -3,39 +3,26 @@
3
3
  </script>
4
4
 
5
5
  <script lang="ts">
6
- import type { Gradio } from "@gradio/utils";
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
- export let elem_id = "";
12
- export let elem_classes: string[] = [];
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">export { default as BaseButton } from "./shared/DownloadButton.svelte";
1
+ <script context="module" lang="ts">
2
+ export { default as BaseButton } from "./shared/DownloadButton.svelte";
2
3
  </script>
3
4
 
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;
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>
@@ -1,33 +1,4 @@
1
- import { SvelteComponent } from "svelte";
2
1
  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;
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>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
- }
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
- declare const __propDef: {
4
- props: {
5
- elem_id?: string;
6
- elem_classes?: string[];
7
- visible?: boolean | "hidden";
8
- variant?: "primary" | "secondary" | "stop";
9
- size?: "sm" | "md" | "lg";
10
- value: null | FileData;
11
- icon: null | FileData;
12
- disabled?: boolean;
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
- events: {
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
- export {};
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;
@@ -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-dev.0",
3
+ "version": "0.4.13-dev.1",
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-dev.0",
11
- "@gradio/client": "^2.0.0-dev.0",
12
- "@gradio/utils": "^0.10.2"
10
+ "@gradio/client": "^2.0.0-dev.2",
11
+ "@gradio/utils": "^0.10.3-dev.0",
12
+ "@gradio/button": "^0.5.14-dev.2"
13
13
  },
14
14
  "devDependencies": {
15
- "@gradio/preview": "^0.14.0"
15
+ "@gradio/preview": "^0.15.0-dev.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": "^4.0.0"
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
+ }