Upload folder using huggingface_hub
Browse files- 6.2.0/code/Index.svelte +8 -1
- 6.2.0/code/package.json +1 -1
- 6.2.0/code/shared/Widgets.svelte +10 -3
- 6.2.0/code/types.ts +4 -0
6.2.0/code/Index.svelte
CHANGED
|
@@ -69,7 +69,14 @@
|
|
| 69 |
<CodeIcon />
|
| 70 |
</Empty>
|
| 71 |
{:else}
|
| 72 |
-
<Widget
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
<Code
|
| 75 |
bind:value={gradio.props.value}
|
|
|
|
| 69 |
<CodeIcon />
|
| 70 |
</Empty>
|
| 71 |
{:else}
|
| 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 |
+
/>
|
| 80 |
|
| 81 |
<Code
|
| 82 |
bind:value={gradio.props.value}
|
6.2.0/code/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "@gradio/code",
|
| 3 |
-
"version": "0.
|
| 4 |
"description": "Gradio UI packages",
|
| 5 |
"type": "module",
|
| 6 |
"author": "",
|
|
|
|
| 1 |
{
|
| 2 |
"name": "@gradio/code",
|
| 3 |
+
"version": "0.17.0",
|
| 4 |
"description": "Gradio UI packages",
|
| 5 |
"type": "module",
|
| 6 |
"author": "",
|
6.2.0/code/shared/Widgets.svelte
CHANGED
|
@@ -2,12 +2,19 @@
|
|
| 2 |
import Copy from "./Copy.svelte";
|
| 3 |
import Download from "./Download.svelte";
|
| 4 |
import { IconButtonWrapper } from "@gradio/atoms";
|
|
|
|
| 5 |
|
| 6 |
export let value: string;
|
| 7 |
export let language: string;
|
|
|
|
|
|
|
| 8 |
</script>
|
| 9 |
|
| 10 |
-
<IconButtonWrapper>
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
</IconButtonWrapper>
|
|
|
|
| 2 |
import Copy from "./Copy.svelte";
|
| 3 |
import Download from "./Download.svelte";
|
| 4 |
import { IconButtonWrapper } from "@gradio/atoms";
|
| 5 |
+
import type { CustomButton as CustomButtonType } from "@gradio/utils";
|
| 6 |
|
| 7 |
export let value: string;
|
| 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;
|
| 11 |
</script>
|
| 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}
|
| 20 |
</IconButtonWrapper>
|
6.2.0/code/types.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
|
|
|
|
|
| 1 |
export interface CodeProps {
|
| 2 |
value: string;
|
| 3 |
language: string;
|
|
@@ -6,6 +8,7 @@ export interface CodeProps {
|
|
| 6 |
show_line_numbers: boolean;
|
| 7 |
autocomplete: boolean;
|
| 8 |
lines: number;
|
|
|
|
| 9 |
}
|
| 10 |
|
| 11 |
export interface CodeEvents {
|
|
@@ -14,4 +17,5 @@ export interface CodeEvents {
|
|
| 14 |
focus: any;
|
| 15 |
blur: any;
|
| 16 |
clear_status: any;
|
|
|
|
| 17 |
}
|
|
|
|
| 1 |
+
import type { CustomButton } from "@gradio/utils";
|
| 2 |
+
|
| 3 |
export interface CodeProps {
|
| 4 |
value: string;
|
| 5 |
language: string;
|
|
|
|
| 8 |
show_line_numbers: boolean;
|
| 9 |
autocomplete: boolean;
|
| 10 |
lines: number;
|
| 11 |
+
buttons: (string | CustomButton)[] | null;
|
| 12 |
}
|
| 13 |
|
| 14 |
export interface CodeEvents {
|
|
|
|
| 17 |
focus: any;
|
| 18 |
blur: any;
|
| 19 |
clear_status: any;
|
| 20 |
+
custom_button_click: { id: number };
|
| 21 |
}
|