Upload folder using huggingface_hub
Browse files- 5.49.1/html/Example.svelte +20 -0
- 5.49.1/html/Index.svelte +73 -0
- 5.49.1/html/package.json +45 -0
- 5.49.1/html/shared/HTML.svelte +95 -0
5.49.1/html/Example.svelte
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
export let value: string;
|
| 3 |
+
export let type: "gallery" | "table";
|
| 4 |
+
export let selected = false;
|
| 5 |
+
</script>
|
| 6 |
+
|
| 7 |
+
<div
|
| 8 |
+
class:table={type === "table"}
|
| 9 |
+
class:gallery={type === "gallery"}
|
| 10 |
+
class:selected
|
| 11 |
+
class="prose"
|
| 12 |
+
>
|
| 13 |
+
{@html value}
|
| 14 |
+
</div>
|
| 15 |
+
|
| 16 |
+
<style>
|
| 17 |
+
.gallery {
|
| 18 |
+
padding: var(--size-2);
|
| 19 |
+
}
|
| 20 |
+
</style>
|
5.49.1/html/Index.svelte
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import type { Gradio } from "@gradio/utils";
|
| 3 |
+
import HTML from "./shared/HTML.svelte";
|
| 4 |
+
import { StatusTracker } from "@gradio/statustracker";
|
| 5 |
+
import type { LoadingStatus } from "@gradio/statustracker";
|
| 6 |
+
import { Block, BlockLabel } from "@gradio/atoms";
|
| 7 |
+
import { Code as CodeIcon } from "@gradio/icons";
|
| 8 |
+
import { css_units } from "@gradio/utils";
|
| 9 |
+
|
| 10 |
+
export let label = "HTML";
|
| 11 |
+
export let elem_id = "";
|
| 12 |
+
export let elem_classes: string[] = [];
|
| 13 |
+
export let visible: boolean | "hidden" = true;
|
| 14 |
+
export let value = "";
|
| 15 |
+
export let loading_status: LoadingStatus;
|
| 16 |
+
export let gradio: Gradio<{
|
| 17 |
+
change: never;
|
| 18 |
+
click: never;
|
| 19 |
+
clear_status: LoadingStatus;
|
| 20 |
+
}>;
|
| 21 |
+
export let show_label = false;
|
| 22 |
+
export let min_height: number | undefined = undefined;
|
| 23 |
+
export let max_height: number | undefined = undefined;
|
| 24 |
+
export let container = false;
|
| 25 |
+
export let padding = true;
|
| 26 |
+
export let autoscroll = false;
|
| 27 |
+
</script>
|
| 28 |
+
|
| 29 |
+
<Block {visible} {elem_id} {elem_classes} {container} padding={false}>
|
| 30 |
+
{#if show_label}
|
| 31 |
+
<BlockLabel Icon={CodeIcon} {show_label} {label} float={false} />
|
| 32 |
+
{/if}
|
| 33 |
+
|
| 34 |
+
<StatusTracker
|
| 35 |
+
autoscroll={gradio.autoscroll}
|
| 36 |
+
i18n={gradio.i18n}
|
| 37 |
+
{...loading_status}
|
| 38 |
+
variant="center"
|
| 39 |
+
on:clear_status={() => gradio.dispatch("clear_status", loading_status)}
|
| 40 |
+
/>
|
| 41 |
+
<div
|
| 42 |
+
class="html-container"
|
| 43 |
+
class:padding
|
| 44 |
+
class:pending={loading_status?.status === "pending"}
|
| 45 |
+
style:min-height={min_height && loading_status?.status !== "pending"
|
| 46 |
+
? css_units(min_height)
|
| 47 |
+
: undefined}
|
| 48 |
+
style:max-height={max_height ? css_units(max_height) : undefined}
|
| 49 |
+
>
|
| 50 |
+
<HTML
|
| 51 |
+
{value}
|
| 52 |
+
{elem_classes}
|
| 53 |
+
{visible}
|
| 54 |
+
{autoscroll}
|
| 55 |
+
on:change={() => gradio.dispatch("change")}
|
| 56 |
+
on:click={() => gradio.dispatch("click")}
|
| 57 |
+
/>
|
| 58 |
+
</div>
|
| 59 |
+
</Block>
|
| 60 |
+
|
| 61 |
+
<style>
|
| 62 |
+
.padding {
|
| 63 |
+
padding: var(--block-padding);
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
div {
|
| 67 |
+
transition: 150ms;
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
.pending {
|
| 71 |
+
opacity: 0.2;
|
| 72 |
+
}
|
| 73 |
+
</style>
|
5.49.1/html/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@gradio/html",
|
| 3 |
+
"version": "0.7.2",
|
| 4 |
+
"description": "Gradio UI packages",
|
| 5 |
+
"type": "module",
|
| 6 |
+
"author": "",
|
| 7 |
+
"license": "ISC",
|
| 8 |
+
"private": false,
|
| 9 |
+
"main_changeset": true,
|
| 10 |
+
"dependencies": {
|
| 11 |
+
"@gradio/atoms": "workspace:^",
|
| 12 |
+
"@gradio/statustracker": "workspace:^",
|
| 13 |
+
"@gradio/utils": "workspace:^",
|
| 14 |
+
"@gradio/icons": "workspace:^"
|
| 15 |
+
},
|
| 16 |
+
"devDependencies": {
|
| 17 |
+
"@gradio/preview": "workspace:^"
|
| 18 |
+
},
|
| 19 |
+
"exports": {
|
| 20 |
+
"./package.json": "./package.json",
|
| 21 |
+
".": {
|
| 22 |
+
"gradio": "./Index.svelte",
|
| 23 |
+
"svelte": "./dist/Index.svelte",
|
| 24 |
+
"types": "./dist/Index.svelte.d.ts"
|
| 25 |
+
},
|
| 26 |
+
"./example": {
|
| 27 |
+
"gradio": "./Example.svelte",
|
| 28 |
+
"svelte": "./dist/Example.svelte",
|
| 29 |
+
"types": "./dist/Example.svelte.d.ts"
|
| 30 |
+
},
|
| 31 |
+
"./base": {
|
| 32 |
+
"gradio": "./Index.svelte",
|
| 33 |
+
"svelte": "./dist/Index.svelte",
|
| 34 |
+
"types": "./dist/Index.svelte.d.ts"
|
| 35 |
+
}
|
| 36 |
+
},
|
| 37 |
+
"peerDependencies": {
|
| 38 |
+
"svelte": "^4.0.0"
|
| 39 |
+
},
|
| 40 |
+
"repository": {
|
| 41 |
+
"type": "git",
|
| 42 |
+
"url": "git+https://github.com/gradio-app/gradio.git",
|
| 43 |
+
"directory": "js/html"
|
| 44 |
+
}
|
| 45 |
+
}
|
5.49.1/html/shared/HTML.svelte
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import { createEventDispatcher, onMount, tick } from "svelte";
|
| 3 |
+
|
| 4 |
+
export let elem_classes: string[] = [];
|
| 5 |
+
export let value: string;
|
| 6 |
+
export let visible: boolean | "hidden" = true;
|
| 7 |
+
export let autoscroll = false;
|
| 8 |
+
|
| 9 |
+
const dispatch = createEventDispatcher<{
|
| 10 |
+
change: undefined;
|
| 11 |
+
click: undefined;
|
| 12 |
+
}>();
|
| 13 |
+
|
| 14 |
+
let div: HTMLDivElement;
|
| 15 |
+
let scrollable_parent: HTMLElement | null = null;
|
| 16 |
+
|
| 17 |
+
function get_scrollable_parent(element: HTMLElement): HTMLElement | null {
|
| 18 |
+
let parent = element.parentElement;
|
| 19 |
+
while (parent) {
|
| 20 |
+
const style = window.getComputedStyle(parent);
|
| 21 |
+
if (
|
| 22 |
+
style.overflow === "auto" ||
|
| 23 |
+
style.overflow === "scroll" ||
|
| 24 |
+
style.overflowY === "auto" ||
|
| 25 |
+
style.overflowY === "scroll"
|
| 26 |
+
) {
|
| 27 |
+
return parent;
|
| 28 |
+
}
|
| 29 |
+
parent = parent.parentElement;
|
| 30 |
+
}
|
| 31 |
+
return null;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
function is_at_bottom(): boolean {
|
| 35 |
+
if (!div) return true;
|
| 36 |
+
if (!scrollable_parent) {
|
| 37 |
+
return (
|
| 38 |
+
window.innerHeight + window.scrollY >=
|
| 39 |
+
document.documentElement.scrollHeight - 100
|
| 40 |
+
);
|
| 41 |
+
}
|
| 42 |
+
return (
|
| 43 |
+
scrollable_parent.offsetHeight + scrollable_parent.scrollTop >=
|
| 44 |
+
scrollable_parent.scrollHeight - 100
|
| 45 |
+
);
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
function scroll_to_bottom(): void {
|
| 49 |
+
if (!div) return;
|
| 50 |
+
if (scrollable_parent) {
|
| 51 |
+
scrollable_parent.scrollTo(0, scrollable_parent.scrollHeight);
|
| 52 |
+
} else {
|
| 53 |
+
window.scrollTo(0, document.documentElement.scrollHeight);
|
| 54 |
+
}
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
async function scroll_on_value_update(): Promise<void> {
|
| 58 |
+
if (!autoscroll || !div) return;
|
| 59 |
+
if (!scrollable_parent) {
|
| 60 |
+
scrollable_parent = get_scrollable_parent(div);
|
| 61 |
+
}
|
| 62 |
+
if (is_at_bottom()) {
|
| 63 |
+
await new Promise((resolve) => setTimeout(resolve, 300));
|
| 64 |
+
scroll_to_bottom();
|
| 65 |
+
}
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
onMount(() => {
|
| 69 |
+
if (autoscroll) {
|
| 70 |
+
scroll_to_bottom();
|
| 71 |
+
}
|
| 72 |
+
scroll_on_value_update();
|
| 73 |
+
});
|
| 74 |
+
|
| 75 |
+
$: value, dispatch("change");
|
| 76 |
+
$: if (value && autoscroll) {
|
| 77 |
+
scroll_on_value_update();
|
| 78 |
+
}
|
| 79 |
+
</script>
|
| 80 |
+
|
| 81 |
+
<!-- svelte-ignore a11y-click-events-have-key-events a11y-no-static-element-interactions -->
|
| 82 |
+
<div
|
| 83 |
+
bind:this={div}
|
| 84 |
+
class="prose {elem_classes.join(' ')}"
|
| 85 |
+
class:hide={!visible}
|
| 86 |
+
on:click={() => dispatch("click")}
|
| 87 |
+
>
|
| 88 |
+
{@html value}
|
| 89 |
+
</div>
|
| 90 |
+
|
| 91 |
+
<style>
|
| 92 |
+
.hide {
|
| 93 |
+
display: none;
|
| 94 |
+
}
|
| 95 |
+
</style>
|