Upload folder using huggingface_hub
Browse files
6.4.0/atoms/src/FullscreenButton.svelte
CHANGED
|
@@ -1,25 +1,26 @@
|
|
| 1 |
<script lang="ts">
|
| 2 |
-
import { createEventDispatcher } from "svelte";
|
| 3 |
import { IconButton } from "@gradio/atoms";
|
| 4 |
import { Maximize, Minimize } from "@gradio/icons";
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
| 7 |
fullscreen: boolean;
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
export let fullscreen;
|
| 11 |
</script>
|
| 12 |
|
| 13 |
{#if fullscreen}
|
| 14 |
<IconButton
|
| 15 |
Icon={Minimize}
|
| 16 |
label="Exit fullscreen mode"
|
| 17 |
-
|
| 18 |
/>
|
| 19 |
{:else}
|
| 20 |
<IconButton
|
| 21 |
Icon={Maximize}
|
| 22 |
label="Fullscreen"
|
| 23 |
-
|
| 24 |
/>
|
| 25 |
{/if}
|
|
|
|
| 1 |
<script lang="ts">
|
|
|
|
| 2 |
import { IconButton } from "@gradio/atoms";
|
| 3 |
import { Maximize, Minimize } from "@gradio/icons";
|
| 4 |
|
| 5 |
+
let {
|
| 6 |
+
fullscreen,
|
| 7 |
+
onclick
|
| 8 |
+
}: {
|
| 9 |
fullscreen: boolean;
|
| 10 |
+
onclick: (fullscreen: boolean) => void;
|
| 11 |
+
} = $props();
|
|
|
|
| 12 |
</script>
|
| 13 |
|
| 14 |
{#if fullscreen}
|
| 15 |
<IconButton
|
| 16 |
Icon={Minimize}
|
| 17 |
label="Exit fullscreen mode"
|
| 18 |
+
onclick={() => onclick(false)}
|
| 19 |
/>
|
| 20 |
{:else}
|
| 21 |
<IconButton
|
| 22 |
Icon={Maximize}
|
| 23 |
label="Fullscreen"
|
| 24 |
+
onclick={() => onclick(true)}
|
| 25 |
/>
|
| 26 |
{/if}
|
6.4.0/atoms/src/IconButton.svelte
CHANGED
|
@@ -1,25 +1,47 @@
|
|
| 1 |
<script lang="ts">
|
| 2 |
-
import { type Component } from "svelte";
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
</script>
|
| 18 |
|
| 19 |
<button
|
| 20 |
class="icon-button"
|
| 21 |
{disabled}
|
| 22 |
-
|
| 23 |
aria-label={label}
|
| 24 |
aria-haspopup={hasPopup}
|
| 25 |
title={label}
|
|
@@ -38,8 +60,8 @@
|
|
| 38 |
class:large={size === "large"}
|
| 39 |
class:medium={size === "medium"}
|
| 40 |
>
|
| 41 |
-
<
|
| 42 |
-
|
| 43 |
</div>
|
| 44 |
</button>
|
| 45 |
|
|
|
|
| 1 |
<script lang="ts">
|
| 2 |
+
import { type Component, type Snippet } from "svelte";
|
| 3 |
+
|
| 4 |
+
let {
|
| 5 |
+
Icon,
|
| 6 |
+
label = "",
|
| 7 |
+
show_label = false,
|
| 8 |
+
pending = false,
|
| 9 |
+
size = "small",
|
| 10 |
+
padded = true,
|
| 11 |
+
highlight = false,
|
| 12 |
+
disabled = false,
|
| 13 |
+
hasPopup = false,
|
| 14 |
+
color = "var(--block-label-text-color)",
|
| 15 |
+
transparent = false,
|
| 16 |
+
background = "var(--block-background-fill)",
|
| 17 |
+
border = "transparent",
|
| 18 |
+
onclick,
|
| 19 |
+
children
|
| 20 |
+
}: {
|
| 21 |
+
Icon: Component;
|
| 22 |
+
label?: string;
|
| 23 |
+
show_label?: boolean;
|
| 24 |
+
pending?: boolean;
|
| 25 |
+
size?: "x-small" | "small" | "large" | "medium";
|
| 26 |
+
padded?: boolean;
|
| 27 |
+
highlight?: boolean;
|
| 28 |
+
disabled?: boolean;
|
| 29 |
+
hasPopup?: boolean;
|
| 30 |
+
color?: string;
|
| 31 |
+
transparent?: boolean;
|
| 32 |
+
background?: string;
|
| 33 |
+
border?: string;
|
| 34 |
+
onclick?: (event: MouseEvent) => void;
|
| 35 |
+
children?: Snippet;
|
| 36 |
+
} = $props();
|
| 37 |
+
|
| 38 |
+
let _color = $derived(highlight ? "var(--color-accent)" : color);
|
| 39 |
</script>
|
| 40 |
|
| 41 |
<button
|
| 42 |
class="icon-button"
|
| 43 |
{disabled}
|
| 44 |
+
{onclick}
|
| 45 |
aria-label={label}
|
| 46 |
aria-haspopup={hasPopup}
|
| 47 |
title={label}
|
|
|
|
| 60 |
class:large={size === "large"}
|
| 61 |
class:medium={size === "medium"}
|
| 62 |
>
|
| 63 |
+
<Icon />
|
| 64 |
+
{#if children}{@render children()}{/if}
|
| 65 |
</div>
|
| 66 |
</button>
|
| 67 |
|
6.4.0/atoms/src/IconButtonWrapper.svelte
CHANGED
|
@@ -1,18 +1,29 @@
|
|
| 1 |
<script lang="ts">
|
| 2 |
import CustomButton from "./CustomButton.svelte";
|
| 3 |
import type { CustomButton as CustomButtonType } from "@gradio/utils";
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
</script>
|
| 11 |
|
| 12 |
<div
|
| 13 |
class={`icon-button-wrapper ${top_panel ? "top-panel" : ""} ${display_top_corner ? "display-top-corner" : "hide-top-corner"} ${!show_background ? "no-background" : ""}`}
|
| 14 |
>
|
| 15 |
-
|
| 16 |
{#if buttons}
|
| 17 |
{#each buttons as btn}
|
| 18 |
{#if typeof btn !== "string"}
|
|
|
|
| 1 |
<script lang="ts">
|
| 2 |
import CustomButton from "./CustomButton.svelte";
|
| 3 |
import type { CustomButton as CustomButtonType } from "@gradio/utils";
|
| 4 |
+
import type { Snippet } from "svelte";
|
| 5 |
|
| 6 |
+
let {
|
| 7 |
+
top_panel = true,
|
| 8 |
+
display_top_corner = false,
|
| 9 |
+
show_background = true,
|
| 10 |
+
buttons = null,
|
| 11 |
+
on_custom_button_click = null,
|
| 12 |
+
children
|
| 13 |
+
}: {
|
| 14 |
+
top_panel?: boolean;
|
| 15 |
+
display_top_corner?: boolean;
|
| 16 |
+
show_background?: boolean;
|
| 17 |
+
buttons?: (string | CustomButtonType)[] | null;
|
| 18 |
+
on_custom_button_click?: ((id: number) => void) | null;
|
| 19 |
+
children?: Snippet;
|
| 20 |
+
} = $props();
|
| 21 |
</script>
|
| 22 |
|
| 23 |
<div
|
| 24 |
class={`icon-button-wrapper ${top_panel ? "top-panel" : ""} ${display_top_corner ? "display-top-corner" : "hide-top-corner"} ${!show_background ? "no-background" : ""}`}
|
| 25 |
>
|
| 26 |
+
{#if children}{@render children()}{/if}
|
| 27 |
{#if buttons}
|
| 28 |
{#each buttons as btn}
|
| 29 |
{#if typeof btn !== "string"}
|
6.4.0/atoms/src/SelectSource.svelte
CHANGED
|
@@ -3,14 +3,19 @@
|
|
| 3 |
|
| 4 |
type source_types = "upload" | "microphone" | "webcam" | "clipboard" | null;
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
|
| 14 |
|
| 15 |
async function handle_select_source(
|
| 16 |
source: Partial<source_types>
|
|
@@ -28,7 +33,7 @@
|
|
| 28 |
class="icon"
|
| 29 |
class:selected={active_source === "upload" || !active_source}
|
| 30 |
aria-label="Upload file"
|
| 31 |
-
|
| 32 |
>
|
| 33 |
{/if}
|
| 34 |
|
|
@@ -37,7 +42,7 @@
|
|
| 37 |
class="icon"
|
| 38 |
class:selected={active_source === "microphone"}
|
| 39 |
aria-label="Record audio"
|
| 40 |
-
|
| 41 |
><Microphone /></button
|
| 42 |
>
|
| 43 |
{/if}
|
|
@@ -47,7 +52,7 @@
|
|
| 47 |
class="icon"
|
| 48 |
class:selected={active_source === "webcam"}
|
| 49 |
aria-label="Capture from camera"
|
| 50 |
-
|
| 51 |
>
|
| 52 |
{/if}
|
| 53 |
{#if sources.includes("clipboard")}
|
|
@@ -55,8 +60,7 @@
|
|
| 55 |
class="icon"
|
| 56 |
class:selected={active_source === "clipboard"}
|
| 57 |
aria-label="Paste from clipboard"
|
| 58 |
-
|
| 59 |
-
><ImagePaste /></button
|
| 60 |
>
|
| 61 |
{/if}
|
| 62 |
</span>
|
|
|
|
| 3 |
|
| 4 |
type source_types = "upload" | "microphone" | "webcam" | "clipboard" | null;
|
| 5 |
|
| 6 |
+
let {
|
| 7 |
+
sources,
|
| 8 |
+
active_source = $bindable(),
|
| 9 |
+
handle_clear = () => {},
|
| 10 |
+
handle_select = () => {}
|
| 11 |
+
}: {
|
| 12 |
+
sources: Partial<source_types>[];
|
| 13 |
+
active_source?: Partial<source_types>;
|
| 14 |
+
handle_clear?: () => void;
|
| 15 |
+
handle_select?: (source_type: Partial<source_types>) => void;
|
| 16 |
+
} = $props();
|
| 17 |
|
| 18 |
+
let unique_sources = $derived([...new Set(sources)]);
|
| 19 |
|
| 20 |
async function handle_select_source(
|
| 21 |
source: Partial<source_types>
|
|
|
|
| 33 |
class="icon"
|
| 34 |
class:selected={active_source === "upload" || !active_source}
|
| 35 |
aria-label="Upload file"
|
| 36 |
+
onclick={() => handle_select_source("upload")}><Upload /></button
|
| 37 |
>
|
| 38 |
{/if}
|
| 39 |
|
|
|
|
| 42 |
class="icon"
|
| 43 |
class:selected={active_source === "microphone"}
|
| 44 |
aria-label="Record audio"
|
| 45 |
+
onclick={() => handle_select_source("microphone")}
|
| 46 |
><Microphone /></button
|
| 47 |
>
|
| 48 |
{/if}
|
|
|
|
| 52 |
class="icon"
|
| 53 |
class:selected={active_source === "webcam"}
|
| 54 |
aria-label="Capture from camera"
|
| 55 |
+
onclick={() => handle_select_source("webcam")}><Webcam /></button
|
| 56 |
>
|
| 57 |
{/if}
|
| 58 |
{#if sources.includes("clipboard")}
|
|
|
|
| 60 |
class="icon"
|
| 61 |
class:selected={active_source === "clipboard"}
|
| 62 |
aria-label="Paste from clipboard"
|
| 63 |
+
onclick={() => handle_select_source("clipboard")}><ImagePaste /></button
|
|
|
|
| 64 |
>
|
| 65 |
{/if}
|
| 66 |
</span>
|
6.4.0/atoms/src/ShareButton.svelte
CHANGED
|
@@ -21,7 +21,7 @@
|
|
| 21 |
Icon={Community}
|
| 22 |
label={i18n("common.share")}
|
| 23 |
{pending}
|
| 24 |
-
|
| 25 |
try {
|
| 26 |
pending = true;
|
| 27 |
const formatted = await formatter(value);
|
|
|
|
| 21 |
Icon={Community}
|
| 22 |
label={i18n("common.share")}
|
| 23 |
{pending}
|
| 24 |
+
onclick={async () => {
|
| 25 |
try {
|
| 26 |
pending = true;
|
| 27 |
const formatted = await formatter(value);
|