@gradio/code 0.16.0 → 0.17.0
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 +20 -0
- package/Index.svelte +8 -1
- package/dist/Index.svelte +8 -1
- package/dist/shared/Widgets.svelte +10 -3
- package/dist/shared/Widgets.svelte.d.ts +3 -0
- package/dist/types.d.ts +5 -0
- package/package.json +7 -7
- package/shared/Widgets.svelte +10 -3
- package/types.ts +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
1
|
# @gradio/code
|
|
2
|
+
|
|
3
|
+
## 0.17.0
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- [#12539](https://github.com/gradio-app/gradio/pull/12539) [`f1d83fa`](https://github.com/gradio-app/gradio/commit/f1d83fac3d6e4bad60cf896a026fa2d572f26073) - Add ability to add custom buttons to components. Thanks @abidlabs!
|
|
8
|
+
|
|
9
|
+
### Dependency updates
|
|
10
|
+
|
|
11
|
+
- @gradio/atoms@0.20.0
|
|
12
|
+
- @gradio/utils@0.11.0
|
|
13
|
+
- @gradio/statustracker@0.12.1
|
|
14
|
+
- @gradio/upload@0.17.3
|
|
15
|
+
|
|
16
|
+
## 0.16.0
|
|
17
|
+
|
|
18
|
+
### Dependency updates
|
|
19
|
+
|
|
20
|
+
- @gradio/utils@0.10.4
|
|
21
|
+
|
|
2
22
|
## 0.16.0
|
|
3
23
|
|
|
4
24
|
### Features
|
package/Index.svelte
CHANGED
|
@@ -69,7 +69,14 @@
|
|
|
69
69
|
<CodeIcon />
|
|
70
70
|
</Empty>
|
|
71
71
|
{:else}
|
|
72
|
-
<Widget
|
|
72
|
+
<Widget
|
|
73
|
+
language={gradio.props.language}
|
|
74
|
+
value={gradio.props.value}
|
|
75
|
+
buttons={gradio.props.buttons ?? ["copy", "download"]}
|
|
76
|
+
on_custom_button_click={(id) => {
|
|
77
|
+
gradio.dispatch("custom_button_click", { id });
|
|
78
|
+
}}
|
|
79
|
+
/>
|
|
73
80
|
|
|
74
81
|
<Code
|
|
75
82
|
bind:value={gradio.props.value}
|
package/dist/Index.svelte
CHANGED
|
@@ -69,7 +69,14 @@
|
|
|
69
69
|
<CodeIcon />
|
|
70
70
|
</Empty>
|
|
71
71
|
{:else}
|
|
72
|
-
<Widget
|
|
72
|
+
<Widget
|
|
73
|
+
language={gradio.props.language}
|
|
74
|
+
value={gradio.props.value}
|
|
75
|
+
buttons={gradio.props.buttons ?? ["copy", "download"]}
|
|
76
|
+
on_custom_button_click={(id) => {
|
|
77
|
+
gradio.dispatch("custom_button_click", { id });
|
|
78
|
+
}}
|
|
79
|
+
/>
|
|
73
80
|
|
|
74
81
|
<Code
|
|
75
82
|
bind:value={gradio.props.value}
|
|
@@ -2,12 +2,19 @@
|
|
|
2
2
|
import Copy from "./Copy.svelte";
|
|
3
3
|
import Download from "./Download.svelte";
|
|
4
4
|
import { IconButtonWrapper } from "@gradio/atoms";
|
|
5
|
+
import type { CustomButton as CustomButtonType } from "@gradio/utils";
|
|
5
6
|
|
|
6
7
|
export let value: string;
|
|
7
8
|
export let language: string;
|
|
9
|
+
export let buttons: (string | CustomButtonType)[] | null = null;
|
|
10
|
+
export let on_custom_button_click: ((id: number) => void) | null = null;
|
|
8
11
|
</script>
|
|
9
12
|
|
|
10
|
-
<IconButtonWrapper>
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
<IconButtonWrapper {buttons} {on_custom_button_click}>
|
|
14
|
+
{#if buttons?.some((btn) => typeof btn === "string" && btn === "download")}
|
|
15
|
+
<Download {value} {language} />
|
|
16
|
+
{/if}
|
|
17
|
+
{#if buttons?.some((btn) => typeof btn === "string" && btn === "copy")}
|
|
18
|
+
<Copy {value} />
|
|
19
|
+
{/if}
|
|
13
20
|
</IconButtonWrapper>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CustomButton as CustomButtonType } from "@gradio/utils";
|
|
1
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> {
|
|
2
3
|
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
4
|
$$bindings?: Bindings;
|
|
@@ -14,6 +15,8 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
|
|
|
14
15
|
declare const Widgets: $$__sveltets_2_IsomorphicComponent<{
|
|
15
16
|
value: string;
|
|
16
17
|
language: string;
|
|
18
|
+
buttons?: (string | CustomButtonType)[] | null;
|
|
19
|
+
on_custom_button_click?: ((id: number) => void) | null;
|
|
17
20
|
}, {
|
|
18
21
|
[evt: string]: CustomEvent<any>;
|
|
19
22
|
}, {}, {}, string>;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CustomButton } from "@gradio/utils";
|
|
1
2
|
export interface CodeProps {
|
|
2
3
|
value: string;
|
|
3
4
|
language: string;
|
|
@@ -6,6 +7,7 @@ export interface CodeProps {
|
|
|
6
7
|
show_line_numbers: boolean;
|
|
7
8
|
autocomplete: boolean;
|
|
8
9
|
lines: number;
|
|
10
|
+
buttons: (string | CustomButton)[] | null;
|
|
9
11
|
}
|
|
10
12
|
export interface CodeEvents {
|
|
11
13
|
change: any;
|
|
@@ -13,4 +15,7 @@ export interface CodeEvents {
|
|
|
13
15
|
focus: any;
|
|
14
16
|
blur: any;
|
|
15
17
|
clear_status: any;
|
|
18
|
+
custom_button_click: {
|
|
19
|
+
id: number;
|
|
20
|
+
};
|
|
16
21
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradio/code",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "Gradio UI packages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
"cm6-theme-basic-dark": "^0.2.0",
|
|
28
28
|
"cm6-theme-basic-light": "^0.2.0",
|
|
29
29
|
"codemirror": "^6.0.2",
|
|
30
|
-
"@gradio/
|
|
31
|
-
"@gradio/
|
|
32
|
-
"@gradio/upload": "^0.17.
|
|
33
|
-
"@gradio/
|
|
34
|
-
"@gradio/
|
|
30
|
+
"@gradio/atoms": "^0.20.0",
|
|
31
|
+
"@gradio/icons": "^0.15.0",
|
|
32
|
+
"@gradio/upload": "^0.17.3",
|
|
33
|
+
"@gradio/statustracker": "^0.12.1",
|
|
34
|
+
"@gradio/utils": "^0.11.0"
|
|
35
35
|
},
|
|
36
36
|
"main_changeset": true,
|
|
37
37
|
"main": "./Index.svelte",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"./package.json": "./package.json"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@gradio/preview": "^0.15.
|
|
54
|
+
"@gradio/preview": "^0.15.1"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"svelte": "^5.43.4"
|
package/shared/Widgets.svelte
CHANGED
|
@@ -2,12 +2,19 @@
|
|
|
2
2
|
import Copy from "./Copy.svelte";
|
|
3
3
|
import Download from "./Download.svelte";
|
|
4
4
|
import { IconButtonWrapper } from "@gradio/atoms";
|
|
5
|
+
import type { CustomButton as CustomButtonType } from "@gradio/utils";
|
|
5
6
|
|
|
6
7
|
export let value: string;
|
|
7
8
|
export let language: string;
|
|
9
|
+
export let buttons: (string | CustomButtonType)[] | null = null;
|
|
10
|
+
export let on_custom_button_click: ((id: number) => void) | null = null;
|
|
8
11
|
</script>
|
|
9
12
|
|
|
10
|
-
<IconButtonWrapper>
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
<IconButtonWrapper {buttons} {on_custom_button_click}>
|
|
14
|
+
{#if buttons?.some((btn) => typeof btn === "string" && btn === "download")}
|
|
15
|
+
<Download {value} {language} />
|
|
16
|
+
{/if}
|
|
17
|
+
{#if buttons?.some((btn) => typeof btn === "string" && btn === "copy")}
|
|
18
|
+
<Copy {value} />
|
|
19
|
+
{/if}
|
|
13
20
|
</IconButtonWrapper>
|
package/types.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { CustomButton } from "@gradio/utils";
|
|
2
|
+
|
|
1
3
|
export interface CodeProps {
|
|
2
4
|
value: string;
|
|
3
5
|
language: string;
|
|
@@ -6,6 +8,7 @@ export interface CodeProps {
|
|
|
6
8
|
show_line_numbers: boolean;
|
|
7
9
|
autocomplete: boolean;
|
|
8
10
|
lines: number;
|
|
11
|
+
buttons: (string | CustomButton)[] | null;
|
|
9
12
|
}
|
|
10
13
|
|
|
11
14
|
export interface CodeEvents {
|
|
@@ -14,4 +17,5 @@ export interface CodeEvents {
|
|
|
14
17
|
focus: any;
|
|
15
18
|
blur: any;
|
|
16
19
|
clear_status: any;
|
|
20
|
+
custom_button_click: { id: number };
|
|
17
21
|
}
|