Upload folder using huggingface_hub
Browse files- 6.4.0/textbox/Example.svelte +50 -0
- 6.4.0/textbox/Index.svelte +112 -0
- 6.4.0/textbox/package.json +41 -0
- 6.4.0/textbox/shared/Textbox.svelte +573 -0
- 6.4.0/textbox/types.ts +74 -0
6.4.0/textbox/Example.svelte
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import { onMount } from "svelte";
|
| 3 |
+
|
| 4 |
+
export let value: string | null;
|
| 5 |
+
export let type: "gallery" | "table";
|
| 6 |
+
export let selected = false;
|
| 7 |
+
|
| 8 |
+
let size: number;
|
| 9 |
+
let el: HTMLDivElement;
|
| 10 |
+
|
| 11 |
+
function set_styles(element: HTMLElement, el_width: number): void {
|
| 12 |
+
element.style.setProperty(
|
| 13 |
+
"--local-text-width",
|
| 14 |
+
`${el_width && el_width < 150 ? el_width : 200}px`
|
| 15 |
+
);
|
| 16 |
+
element.style.whiteSpace = "unset";
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
function truncate_text(text: string | null, max_length = 60): string {
|
| 20 |
+
if (!text) return "";
|
| 21 |
+
const str = String(text);
|
| 22 |
+
if (str.length <= max_length) return str;
|
| 23 |
+
return str.slice(0, max_length) + "...";
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
onMount(() => {
|
| 27 |
+
set_styles(el, size);
|
| 28 |
+
});
|
| 29 |
+
</script>
|
| 30 |
+
|
| 31 |
+
<div
|
| 32 |
+
bind:clientWidth={size}
|
| 33 |
+
bind:this={el}
|
| 34 |
+
class:table={type === "table"}
|
| 35 |
+
class:gallery={type === "gallery"}
|
| 36 |
+
class:selected
|
| 37 |
+
>
|
| 38 |
+
{truncate_text(value)}
|
| 39 |
+
</div>
|
| 40 |
+
|
| 41 |
+
<style>
|
| 42 |
+
.gallery {
|
| 43 |
+
padding: var(--size-1) var(--size-2);
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
div {
|
| 47 |
+
overflow: hidden;
|
| 48 |
+
white-space: nowrap;
|
| 49 |
+
}
|
| 50 |
+
</style>
|
6.4.0/textbox/Index.svelte
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<svelte:options accessors={true} />
|
| 2 |
+
|
| 3 |
+
<script context="module" lang="ts">
|
| 4 |
+
export { default as BaseTextbox } from "./shared/Textbox.svelte";
|
| 5 |
+
export { default as BaseExample } from "./Example.svelte";
|
| 6 |
+
</script>
|
| 7 |
+
|
| 8 |
+
<script lang="ts">
|
| 9 |
+
import { tick } from "svelte";
|
| 10 |
+
import TextBox from "./shared/Textbox.svelte";
|
| 11 |
+
import StatusTracker from "@gradio/statustracker";
|
| 12 |
+
import { Block } from "@gradio/atoms";
|
| 13 |
+
import { Gradio } from "@gradio/utils";
|
| 14 |
+
import type { TextboxProps, TextboxEvents } from "./types";
|
| 15 |
+
|
| 16 |
+
let _props = $props();
|
| 17 |
+
const gradio = new Gradio<TextboxEvents, TextboxProps>(_props);
|
| 18 |
+
|
| 19 |
+
let label = $derived(gradio.shared.label || "Textbox");
|
| 20 |
+
// Need to set the value to "" otherwise a change event gets
|
| 21 |
+
// dispatched when the child sets it to ""
|
| 22 |
+
gradio.props.value = gradio.props.value ?? "";
|
| 23 |
+
let old_value = $state(gradio.props.value);
|
| 24 |
+
|
| 25 |
+
async function dispatch_change() {
|
| 26 |
+
if (old_value !== gradio.props.value) {
|
| 27 |
+
old_value = gradio.props.value;
|
| 28 |
+
await tick();
|
| 29 |
+
gradio.dispatch("change", $state.snapshot(gradio.props.value));
|
| 30 |
+
}
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
async function handle_input(value: string): Promise<void> {
|
| 34 |
+
if (!gradio.shared || !gradio.props) return;
|
| 35 |
+
gradio.props.validation_error = null;
|
| 36 |
+
gradio.props.value = value;
|
| 37 |
+
await tick();
|
| 38 |
+
gradio.dispatch("input");
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
$effect(() => {
|
| 42 |
+
dispatch_change();
|
| 43 |
+
});
|
| 44 |
+
|
| 45 |
+
function handle_change(value: string): void {
|
| 46 |
+
if (!gradio.shared || !gradio.props) return;
|
| 47 |
+
gradio.props.validation_error = null;
|
| 48 |
+
gradio.props.value = value;
|
| 49 |
+
}
|
| 50 |
+
</script>
|
| 51 |
+
|
| 52 |
+
<Block
|
| 53 |
+
visible={gradio.shared.visible}
|
| 54 |
+
elem_id={gradio.shared.elem_id}
|
| 55 |
+
elem_classes={gradio.shared.elem_classes}
|
| 56 |
+
scale={gradio.shared.scale}
|
| 57 |
+
min_width={gradio.shared.min_width}
|
| 58 |
+
allow_overflow={false}
|
| 59 |
+
padding={gradio.shared.container}
|
| 60 |
+
rtl={gradio.props.rtl}
|
| 61 |
+
>
|
| 62 |
+
{#if gradio.shared.loading_status}
|
| 63 |
+
<StatusTracker
|
| 64 |
+
autoscroll={gradio.shared.autoscroll}
|
| 65 |
+
i18n={gradio.i18n}
|
| 66 |
+
{...gradio.shared.loading_status}
|
| 67 |
+
show_validation_error={false}
|
| 68 |
+
on_clear_status={() =>
|
| 69 |
+
gradio.dispatch("clear_status", gradio.shared.loading_status)}
|
| 70 |
+
/>
|
| 71 |
+
{/if}
|
| 72 |
+
|
| 73 |
+
<TextBox
|
| 74 |
+
bind:value={gradio.props.value}
|
| 75 |
+
{label}
|
| 76 |
+
info={gradio.props.info}
|
| 77 |
+
show_label={gradio.shared.show_label}
|
| 78 |
+
lines={gradio.props.lines}
|
| 79 |
+
type={gradio.props.type}
|
| 80 |
+
rtl={gradio.props.rtl}
|
| 81 |
+
text_align={gradio.props.text_align}
|
| 82 |
+
max_lines={gradio.props.max_lines}
|
| 83 |
+
placeholder={gradio.props.placeholder}
|
| 84 |
+
submit_btn={gradio.props.submit_btn}
|
| 85 |
+
stop_btn={gradio.props.stop_btn}
|
| 86 |
+
buttons={gradio.props.buttons}
|
| 87 |
+
autofocus={gradio.props.autofocus}
|
| 88 |
+
container={gradio.shared.container}
|
| 89 |
+
autoscroll={gradio.shared.autoscroll}
|
| 90 |
+
max_length={gradio.props.max_length}
|
| 91 |
+
html_attributes={gradio.props.html_attributes}
|
| 92 |
+
validation_error={gradio.shared?.loading_status?.validation_error ||
|
| 93 |
+
gradio.shared?.validation_error}
|
| 94 |
+
onchange={handle_change}
|
| 95 |
+
oninput={handle_input}
|
| 96 |
+
onsubmit={() => {
|
| 97 |
+
gradio.shared.validation_error = null;
|
| 98 |
+
gradio.dispatch("submit");
|
| 99 |
+
}}
|
| 100 |
+
onblur={() => gradio.dispatch("blur")}
|
| 101 |
+
onselect={(data) => gradio.dispatch("select", data)}
|
| 102 |
+
onfocus={() => gradio.dispatch("focus")}
|
| 103 |
+
onstop={() => gradio.dispatch("stop")}
|
| 104 |
+
oncopy={(data) => gradio.dispatch("copy", data)}
|
| 105 |
+
oncustombuttonclick={(id) => {
|
| 106 |
+
gradio.dispatch("custom_button_click", { id });
|
| 107 |
+
}}
|
| 108 |
+
disabled={!gradio.shared.interactive}
|
| 109 |
+
/>
|
| 110 |
+
</Block>
|
| 111 |
+
|
| 112 |
+
<!-- bind:value_is_output={gradio.props.value_is_output} -->
|
6.4.0/textbox/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@gradio/textbox",
|
| 3 |
+
"version": "0.13.2",
|
| 4 |
+
"description": "Gradio UI packages",
|
| 5 |
+
"type": "module",
|
| 6 |
+
"author": "",
|
| 7 |
+
"license": "ISC",
|
| 8 |
+
"private": false,
|
| 9 |
+
"main_changeset": true,
|
| 10 |
+
"main": "Index.svelte",
|
| 11 |
+
"exports": {
|
| 12 |
+
".": {
|
| 13 |
+
"gradio": "./Index.svelte",
|
| 14 |
+
"svelte": "./dist/Index.svelte",
|
| 15 |
+
"types": "./dist/Index.svelte.d.ts"
|
| 16 |
+
},
|
| 17 |
+
"./example": {
|
| 18 |
+
"gradio": "./Example.svelte",
|
| 19 |
+
"svelte": "./dist/Example.svelte",
|
| 20 |
+
"types": "./dist/Example.svelte.d.ts"
|
| 21 |
+
},
|
| 22 |
+
"./package.json": "./package.json"
|
| 23 |
+
},
|
| 24 |
+
"dependencies": {
|
| 25 |
+
"@gradio/atoms": "workspace:^",
|
| 26 |
+
"@gradio/icons": "workspace:^",
|
| 27 |
+
"@gradio/statustracker": "workspace:^",
|
| 28 |
+
"@gradio/utils": "workspace:^"
|
| 29 |
+
},
|
| 30 |
+
"devDependencies": {
|
| 31 |
+
"@gradio/preview": "workspace:^"
|
| 32 |
+
},
|
| 33 |
+
"peerDependencies": {
|
| 34 |
+
"svelte": "^5.43.4"
|
| 35 |
+
},
|
| 36 |
+
"repository": {
|
| 37 |
+
"type": "git",
|
| 38 |
+
"url": "git+https://github.com/gradio-app/gradio.git",
|
| 39 |
+
"directory": "js/textbox"
|
| 40 |
+
}
|
| 41 |
+
}
|
6.4.0/textbox/shared/Textbox.svelte
ADDED
|
@@ -0,0 +1,573 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import { tick } from "svelte";
|
| 3 |
+
import { BlockTitle, IconButton, IconButtonWrapper } from "@gradio/atoms";
|
| 4 |
+
import { Copy, Check, Send, Square } from "@gradio/icons";
|
| 5 |
+
import type {
|
| 6 |
+
SelectData,
|
| 7 |
+
CopyData,
|
| 8 |
+
CustomButton as CustomButtonType
|
| 9 |
+
} from "@gradio/utils";
|
| 10 |
+
import type { InputHTMLAttributes } from "../types";
|
| 11 |
+
|
| 12 |
+
let {
|
| 13 |
+
value = $bindable(""),
|
| 14 |
+
value_is_output = $bindable(false),
|
| 15 |
+
lines = 1,
|
| 16 |
+
placeholder = "",
|
| 17 |
+
label,
|
| 18 |
+
info = undefined,
|
| 19 |
+
disabled = false,
|
| 20 |
+
show_label = true,
|
| 21 |
+
container = true,
|
| 22 |
+
max_lines = undefined,
|
| 23 |
+
type = "text",
|
| 24 |
+
buttons = null,
|
| 25 |
+
oncustombuttonclick = null,
|
| 26 |
+
submit_btn = null,
|
| 27 |
+
stop_btn = null,
|
| 28 |
+
rtl = false,
|
| 29 |
+
autofocus = false,
|
| 30 |
+
text_align = undefined,
|
| 31 |
+
autoscroll = true,
|
| 32 |
+
max_length = undefined,
|
| 33 |
+
html_attributes = null,
|
| 34 |
+
validation_error = undefined,
|
| 35 |
+
onchange,
|
| 36 |
+
onsubmit,
|
| 37 |
+
onstop,
|
| 38 |
+
onblur,
|
| 39 |
+
onselect,
|
| 40 |
+
oninput,
|
| 41 |
+
onfocus,
|
| 42 |
+
oncopy
|
| 43 |
+
}: {
|
| 44 |
+
value?: string;
|
| 45 |
+
value_is_output?: boolean;
|
| 46 |
+
lines?: number;
|
| 47 |
+
placeholder?: string;
|
| 48 |
+
label: string;
|
| 49 |
+
info?: string | undefined;
|
| 50 |
+
disabled?: boolean;
|
| 51 |
+
show_label?: boolean;
|
| 52 |
+
container?: boolean;
|
| 53 |
+
max_lines?: number | undefined;
|
| 54 |
+
type?: "text" | "password" | "email";
|
| 55 |
+
buttons?: (string | CustomButtonType)[] | null;
|
| 56 |
+
oncustombuttonclick?: ((id: number) => void) | null;
|
| 57 |
+
submit_btn?: string | boolean | null;
|
| 58 |
+
stop_btn?: string | boolean | null;
|
| 59 |
+
rtl?: boolean;
|
| 60 |
+
autofocus?: boolean;
|
| 61 |
+
text_align?: "left" | "right" | undefined;
|
| 62 |
+
autoscroll?: boolean;
|
| 63 |
+
max_length?: number | undefined;
|
| 64 |
+
html_attributes?: InputHTMLAttributes | null;
|
| 65 |
+
validation_error?: string | null | undefined;
|
| 66 |
+
onchange?: (value: string) => void;
|
| 67 |
+
onsubmit?: () => void;
|
| 68 |
+
onstop?: () => void;
|
| 69 |
+
onblur?: () => void;
|
| 70 |
+
onselect?: (data: SelectData) => void;
|
| 71 |
+
oninput?: (value: string) => void;
|
| 72 |
+
onfocus?: () => void;
|
| 73 |
+
oncopy?: (data: CopyData) => void;
|
| 74 |
+
} = $props();
|
| 75 |
+
|
| 76 |
+
let el: HTMLTextAreaElement | HTMLInputElement;
|
| 77 |
+
let copied = $state(false);
|
| 78 |
+
let timer: NodeJS.Timeout;
|
| 79 |
+
let can_scroll = $state(false);
|
| 80 |
+
let previous_scroll_top = $state(0);
|
| 81 |
+
let user_has_scrolled_up = $state(false);
|
| 82 |
+
let _max_lines = $state(1);
|
| 83 |
+
|
| 84 |
+
const show_textbox_border = !submit_btn;
|
| 85 |
+
|
| 86 |
+
$effect(() => {
|
| 87 |
+
if (max_lines === undefined || max_lines === null) {
|
| 88 |
+
if (type === "text") {
|
| 89 |
+
_max_lines = Math.max(lines, 20);
|
| 90 |
+
} else {
|
| 91 |
+
_max_lines = 1;
|
| 92 |
+
}
|
| 93 |
+
} else {
|
| 94 |
+
_max_lines = Math.max(max_lines, lines);
|
| 95 |
+
}
|
| 96 |
+
});
|
| 97 |
+
|
| 98 |
+
$effect(() => {
|
| 99 |
+
value;
|
| 100 |
+
validation_error;
|
| 101 |
+
if (el && lines !== _max_lines && lines > 1) {
|
| 102 |
+
resize({ target: el });
|
| 103 |
+
}
|
| 104 |
+
});
|
| 105 |
+
|
| 106 |
+
$effect(() => {
|
| 107 |
+
if (value === null) value = "";
|
| 108 |
+
});
|
| 109 |
+
|
| 110 |
+
$effect.pre(() => {
|
| 111 |
+
if (
|
| 112 |
+
!user_has_scrolled_up &&
|
| 113 |
+
el &&
|
| 114 |
+
el.offsetHeight + el.scrollTop > el.scrollHeight - 100
|
| 115 |
+
) {
|
| 116 |
+
can_scroll = true;
|
| 117 |
+
}
|
| 118 |
+
});
|
| 119 |
+
|
| 120 |
+
const scroll = (): void => {
|
| 121 |
+
if (can_scroll && autoscroll && !user_has_scrolled_up) {
|
| 122 |
+
el.scrollTo(0, el.scrollHeight);
|
| 123 |
+
}
|
| 124 |
+
};
|
| 125 |
+
|
| 126 |
+
async function handle_change(): Promise<void> {
|
| 127 |
+
await tick();
|
| 128 |
+
onchange?.(value);
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
$effect(() => {
|
| 132 |
+
if (autofocus && el) {
|
| 133 |
+
el.focus();
|
| 134 |
+
}
|
| 135 |
+
if (can_scroll && autoscroll) {
|
| 136 |
+
scroll();
|
| 137 |
+
}
|
| 138 |
+
value_is_output = false;
|
| 139 |
+
});
|
| 140 |
+
|
| 141 |
+
$effect(() => {
|
| 142 |
+
value;
|
| 143 |
+
handle_change();
|
| 144 |
+
});
|
| 145 |
+
|
| 146 |
+
async function handle_copy(): Promise<void> {
|
| 147 |
+
if ("clipboard" in navigator) {
|
| 148 |
+
await navigator.clipboard.writeText(value);
|
| 149 |
+
oncopy?.({ value: value });
|
| 150 |
+
copy_feedback();
|
| 151 |
+
}
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
function copy_feedback(): void {
|
| 155 |
+
copied = true;
|
| 156 |
+
if (timer) clearTimeout(timer);
|
| 157 |
+
timer = setTimeout(() => {
|
| 158 |
+
copied = false;
|
| 159 |
+
}, 1000);
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
function handle_select(event: Event): void {
|
| 163 |
+
const target: HTMLTextAreaElement | HTMLInputElement = event.target as
|
| 164 |
+
| HTMLTextAreaElement
|
| 165 |
+
| HTMLInputElement;
|
| 166 |
+
const text = target.value;
|
| 167 |
+
const index: [number, number] = [
|
| 168 |
+
target.selectionStart as number,
|
| 169 |
+
target.selectionEnd as number
|
| 170 |
+
];
|
| 171 |
+
onselect?.({ value: text.substring(...index), index: index });
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
async function handle_keypress(e: KeyboardEvent): Promise<void> {
|
| 175 |
+
if (e.key === "Enter" && e.shiftKey && lines > 1) {
|
| 176 |
+
e.preventDefault();
|
| 177 |
+
await tick();
|
| 178 |
+
onsubmit?.();
|
| 179 |
+
} else if (
|
| 180 |
+
e.key === "Enter" &&
|
| 181 |
+
!e.shiftKey &&
|
| 182 |
+
lines === 1 &&
|
| 183 |
+
_max_lines >= 1
|
| 184 |
+
) {
|
| 185 |
+
e.preventDefault();
|
| 186 |
+
await tick();
|
| 187 |
+
onsubmit?.();
|
| 188 |
+
}
|
| 189 |
+
await tick();
|
| 190 |
+
oninput?.(value);
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
function handle_scroll(event: Event): void {
|
| 194 |
+
const target = event.target as HTMLElement;
|
| 195 |
+
const current_scroll_top = target.scrollTop;
|
| 196 |
+
if (current_scroll_top < previous_scroll_top) {
|
| 197 |
+
user_has_scrolled_up = true;
|
| 198 |
+
}
|
| 199 |
+
previous_scroll_top = current_scroll_top;
|
| 200 |
+
|
| 201 |
+
const max_scroll_top = target.scrollHeight - target.clientHeight;
|
| 202 |
+
const user_has_scrolled_to_bottom = current_scroll_top >= max_scroll_top;
|
| 203 |
+
if (user_has_scrolled_to_bottom) {
|
| 204 |
+
user_has_scrolled_up = false;
|
| 205 |
+
}
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
function handle_stop(): void {
|
| 209 |
+
onstop?.();
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
function handle_submit(): void {
|
| 213 |
+
onsubmit?.();
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
async function resize(
|
| 217 |
+
event: Event | { target: HTMLTextAreaElement | HTMLInputElement }
|
| 218 |
+
): Promise<void> {
|
| 219 |
+
await tick();
|
| 220 |
+
if (lines === _max_lines) return;
|
| 221 |
+
|
| 222 |
+
const target = event.target as HTMLTextAreaElement;
|
| 223 |
+
const computed_styles = window.getComputedStyle(target);
|
| 224 |
+
const padding_top = parseFloat(computed_styles.paddingTop);
|
| 225 |
+
const padding_bottom = parseFloat(computed_styles.paddingBottom);
|
| 226 |
+
const line_height = parseFloat(computed_styles.lineHeight);
|
| 227 |
+
|
| 228 |
+
let max =
|
| 229 |
+
_max_lines === undefined
|
| 230 |
+
? false
|
| 231 |
+
: padding_top + padding_bottom + line_height * _max_lines;
|
| 232 |
+
let min = padding_top + padding_bottom + lines * line_height;
|
| 233 |
+
|
| 234 |
+
target.style.height = "1px";
|
| 235 |
+
|
| 236 |
+
let scroll_height;
|
| 237 |
+
if (max && target.scrollHeight > max) {
|
| 238 |
+
scroll_height = max;
|
| 239 |
+
} else if (target.scrollHeight < min) {
|
| 240 |
+
scroll_height = min;
|
| 241 |
+
} else {
|
| 242 |
+
scroll_height = target.scrollHeight;
|
| 243 |
+
}
|
| 244 |
+
|
| 245 |
+
target.style.height = `${scroll_height}px`;
|
| 246 |
+
|
| 247 |
+
update_scrollbar_visibility(target);
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
function update_scrollbar_visibility(textarea: HTMLTextAreaElement): void {
|
| 251 |
+
// Using "auto" scroll does not work, as the scrollbar is visible even
|
| 252 |
+
// when the content is about the same height as the textarea height. So
|
| 253 |
+
// here, we add the scrollbar if the content is longer than a threshold
|
| 254 |
+
// of 1 line height beyond the textarea height.
|
| 255 |
+
const content_height = textarea.scrollHeight;
|
| 256 |
+
const visible_height = textarea.clientHeight;
|
| 257 |
+
const line_height = parseFloat(
|
| 258 |
+
window.getComputedStyle(textarea).lineHeight
|
| 259 |
+
);
|
| 260 |
+
if (content_height > visible_height + line_height) {
|
| 261 |
+
textarea.style.overflowY = "scroll";
|
| 262 |
+
} else {
|
| 263 |
+
textarea.style.overflowY = "hidden";
|
| 264 |
+
}
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
function text_area_resize(
|
| 268 |
+
_el: HTMLTextAreaElement,
|
| 269 |
+
_value: string
|
| 270 |
+
): any | undefined {
|
| 271 |
+
if (lines === _max_lines || (lines === 1 && _max_lines === 1)) return;
|
| 272 |
+
|
| 273 |
+
_el.addEventListener("input", resize);
|
| 274 |
+
|
| 275 |
+
if (_value.trim()) {
|
| 276 |
+
_el.style.overflowY = "scroll";
|
| 277 |
+
resize({ target: _el });
|
| 278 |
+
}
|
| 279 |
+
|
| 280 |
+
return {
|
| 281 |
+
destroy: () => _el.removeEventListener("input", resize)
|
| 282 |
+
};
|
| 283 |
+
}
|
| 284 |
+
</script>
|
| 285 |
+
|
| 286 |
+
<!-- svelte-ignore a11y-autofocus -->
|
| 287 |
+
<label class:container class:show_textbox_border>
|
| 288 |
+
{#if show_label && buttons && buttons.length > 0}
|
| 289 |
+
<IconButtonWrapper {buttons} {oncustombuttonclick}>
|
| 290 |
+
{#if buttons.some((btn) => typeof btn === "string" && btn === "copy")}
|
| 291 |
+
<IconButton
|
| 292 |
+
Icon={copied ? Check : Copy}
|
| 293 |
+
onclick={handle_copy}
|
| 294 |
+
label={copied ? "Copied" : "Copy"}
|
| 295 |
+
/>
|
| 296 |
+
{/if}
|
| 297 |
+
</IconButtonWrapper>
|
| 298 |
+
{/if}
|
| 299 |
+
<BlockTitle show_label={validation_error ? true : show_label} {info}
|
| 300 |
+
>{label}
|
| 301 |
+
{#if validation_error}
|
| 302 |
+
<div class="validation-error">{validation_error}</div>
|
| 303 |
+
{/if}
|
| 304 |
+
</BlockTitle>
|
| 305 |
+
|
| 306 |
+
<div class="input-container">
|
| 307 |
+
{#if lines === 1 && _max_lines === 1}
|
| 308 |
+
{#if type === "text"}
|
| 309 |
+
<input
|
| 310 |
+
data-testid="textbox"
|
| 311 |
+
type="text"
|
| 312 |
+
class="scroll-hide"
|
| 313 |
+
dir={rtl ? "rtl" : "ltr"}
|
| 314 |
+
bind:value
|
| 315 |
+
bind:this={el}
|
| 316 |
+
{placeholder}
|
| 317 |
+
{disabled}
|
| 318 |
+
{autofocus}
|
| 319 |
+
maxlength={max_length}
|
| 320 |
+
onkeypress={handle_keypress}
|
| 321 |
+
onblur={() => onblur?.()}
|
| 322 |
+
onselect={handle_select}
|
| 323 |
+
onfocus={() => onfocus?.()}
|
| 324 |
+
class:validation-error={validation_error}
|
| 325 |
+
style={text_align ? "text-align: " + text_align : ""}
|
| 326 |
+
autocapitalize={html_attributes?.autocapitalize}
|
| 327 |
+
autocorrect={html_attributes?.autocorrect}
|
| 328 |
+
spellcheck={html_attributes?.spellcheck}
|
| 329 |
+
autocomplete={html_attributes?.autocomplete}
|
| 330 |
+
tabindex={html_attributes?.tabindex}
|
| 331 |
+
enterkeyhint={html_attributes?.enterkeyhint}
|
| 332 |
+
lang={html_attributes?.lang}
|
| 333 |
+
/>
|
| 334 |
+
{:else if type === "password"}
|
| 335 |
+
<input
|
| 336 |
+
data-testid="password"
|
| 337 |
+
type="password"
|
| 338 |
+
class="scroll-hide"
|
| 339 |
+
bind:value
|
| 340 |
+
bind:this={el}
|
| 341 |
+
{placeholder}
|
| 342 |
+
{disabled}
|
| 343 |
+
{autofocus}
|
| 344 |
+
maxlength={max_length}
|
| 345 |
+
onkeypress={handle_keypress}
|
| 346 |
+
onblur={() => onblur?.()}
|
| 347 |
+
onselect={handle_select}
|
| 348 |
+
onfocus={() => onfocus?.()}
|
| 349 |
+
class:validation-error={validation_error}
|
| 350 |
+
autocomplete=""
|
| 351 |
+
autocapitalize={html_attributes?.autocapitalize}
|
| 352 |
+
autocorrect={html_attributes?.autocorrect}
|
| 353 |
+
spellcheck={html_attributes?.spellcheck}
|
| 354 |
+
tabindex={html_attributes?.tabindex}
|
| 355 |
+
enterkeyhint={html_attributes?.enterkeyhint}
|
| 356 |
+
lang={html_attributes?.lang}
|
| 357 |
+
/>
|
| 358 |
+
{:else if type === "email"}
|
| 359 |
+
<input
|
| 360 |
+
data-testid="textbox"
|
| 361 |
+
type="email"
|
| 362 |
+
class="scroll-hide"
|
| 363 |
+
bind:value
|
| 364 |
+
bind:this={el}
|
| 365 |
+
{placeholder}
|
| 366 |
+
{disabled}
|
| 367 |
+
{autofocus}
|
| 368 |
+
maxlength={max_length}
|
| 369 |
+
onkeypress={handle_keypress}
|
| 370 |
+
onblur={() => onblur?.()}
|
| 371 |
+
onselect={handle_select}
|
| 372 |
+
onfocus={() => onfocus?.()}
|
| 373 |
+
class:validation-error={validation_error}
|
| 374 |
+
autocomplete="email"
|
| 375 |
+
autocapitalize={html_attributes?.autocapitalize}
|
| 376 |
+
autocorrect={html_attributes?.autocorrect}
|
| 377 |
+
spellcheck={html_attributes?.spellcheck}
|
| 378 |
+
tabindex={html_attributes?.tabindex}
|
| 379 |
+
enterkeyhint={html_attributes?.enterkeyhint}
|
| 380 |
+
lang={html_attributes?.lang}
|
| 381 |
+
/>
|
| 382 |
+
{/if}
|
| 383 |
+
{:else}
|
| 384 |
+
<textarea
|
| 385 |
+
data-testid="textbox"
|
| 386 |
+
use:text_area_resize={value}
|
| 387 |
+
dir={rtl ? "rtl" : "ltr"}
|
| 388 |
+
class:no-label={!show_label && (submit_btn || stop_btn)}
|
| 389 |
+
bind:value
|
| 390 |
+
bind:this={el}
|
| 391 |
+
{placeholder}
|
| 392 |
+
rows={lines}
|
| 393 |
+
{disabled}
|
| 394 |
+
{autofocus}
|
| 395 |
+
maxlength={max_length}
|
| 396 |
+
onkeypress={handle_keypress}
|
| 397 |
+
onblur={() => onblur?.()}
|
| 398 |
+
onselect={handle_select}
|
| 399 |
+
onfocus={() => onfocus?.()}
|
| 400 |
+
onscroll={handle_scroll}
|
| 401 |
+
class:validation-error={validation_error}
|
| 402 |
+
style={text_align ? "text-align: " + text_align : ""}
|
| 403 |
+
autocapitalize={html_attributes?.autocapitalize}
|
| 404 |
+
autocorrect={html_attributes?.autocorrect}
|
| 405 |
+
spellcheck={html_attributes?.spellcheck}
|
| 406 |
+
autocomplete={html_attributes?.autocomplete}
|
| 407 |
+
tabindex={html_attributes?.tabindex}
|
| 408 |
+
enterkeyhint={html_attributes?.enterkeyhint}
|
| 409 |
+
lang={html_attributes?.lang}
|
| 410 |
+
/>
|
| 411 |
+
{/if}
|
| 412 |
+
{#if submit_btn}
|
| 413 |
+
<button
|
| 414 |
+
class="submit-button"
|
| 415 |
+
class:padded-button={submit_btn !== true}
|
| 416 |
+
onclick={handle_submit}
|
| 417 |
+
>
|
| 418 |
+
{#if submit_btn === true}
|
| 419 |
+
<Send />
|
| 420 |
+
{:else}
|
| 421 |
+
{submit_btn}
|
| 422 |
+
{/if}
|
| 423 |
+
</button>
|
| 424 |
+
{/if}
|
| 425 |
+
{#if stop_btn}
|
| 426 |
+
<button
|
| 427 |
+
class="stop-button"
|
| 428 |
+
class:padded-button={stop_btn !== true}
|
| 429 |
+
onclick={handle_stop}
|
| 430 |
+
>
|
| 431 |
+
{#if stop_btn === true}
|
| 432 |
+
<Square fill="none" stroke_width={2.5} />
|
| 433 |
+
{:else}
|
| 434 |
+
{stop_btn}
|
| 435 |
+
{/if}
|
| 436 |
+
</button>
|
| 437 |
+
{/if}
|
| 438 |
+
</div>
|
| 439 |
+
</label>
|
| 440 |
+
|
| 441 |
+
<style>
|
| 442 |
+
label {
|
| 443 |
+
display: block;
|
| 444 |
+
width: 100%;
|
| 445 |
+
}
|
| 446 |
+
|
| 447 |
+
input[type="text"],
|
| 448 |
+
input[type="password"],
|
| 449 |
+
input[type="email"],
|
| 450 |
+
textarea {
|
| 451 |
+
flex-grow: 1;
|
| 452 |
+
outline: none !important;
|
| 453 |
+
margin-top: 0px;
|
| 454 |
+
margin-bottom: 0px;
|
| 455 |
+
resize: none;
|
| 456 |
+
z-index: 1;
|
| 457 |
+
display: block;
|
| 458 |
+
position: relative;
|
| 459 |
+
outline: none !important;
|
| 460 |
+
background: var(--input-background-fill);
|
| 461 |
+
padding: var(--input-padding);
|
| 462 |
+
width: 100%;
|
| 463 |
+
color: var(--body-text-color);
|
| 464 |
+
font-weight: var(--input-text-weight);
|
| 465 |
+
font-size: var(--input-text-size);
|
| 466 |
+
line-height: var(--line-sm);
|
| 467 |
+
border: none;
|
| 468 |
+
}
|
| 469 |
+
|
| 470 |
+
textarea.no-label {
|
| 471 |
+
padding-top: 5px;
|
| 472 |
+
padding-bottom: 5px;
|
| 473 |
+
}
|
| 474 |
+
label.show_textbox_border input,
|
| 475 |
+
label.show_textbox_border textarea {
|
| 476 |
+
box-shadow: var(--input-shadow);
|
| 477 |
+
}
|
| 478 |
+
label:not(.container),
|
| 479 |
+
label:not(.container) input,
|
| 480 |
+
label:not(.container) textarea {
|
| 481 |
+
height: 100%;
|
| 482 |
+
}
|
| 483 |
+
label.container.show_textbox_border input,
|
| 484 |
+
label.container.show_textbox_border textarea {
|
| 485 |
+
border: var(--input-border-width) solid var(--input-border-color);
|
| 486 |
+
border-radius: var(--input-radius);
|
| 487 |
+
}
|
| 488 |
+
input:disabled,
|
| 489 |
+
textarea:disabled {
|
| 490 |
+
-webkit-opacity: 1;
|
| 491 |
+
opacity: 1;
|
| 492 |
+
}
|
| 493 |
+
|
| 494 |
+
label.container.show_textbox_border input:focus,
|
| 495 |
+
label.container.show_textbox_border textarea:focus {
|
| 496 |
+
box-shadow: var(--input-shadow-focus);
|
| 497 |
+
border-color: var(--input-border-color-focus);
|
| 498 |
+
background: var(--input-background-fill-focus);
|
| 499 |
+
}
|
| 500 |
+
|
| 501 |
+
input::placeholder,
|
| 502 |
+
textarea::placeholder {
|
| 503 |
+
color: var(--input-placeholder-color);
|
| 504 |
+
}
|
| 505 |
+
|
| 506 |
+
/* Same submit button style as MultimodalTextbox for the consistent UI */
|
| 507 |
+
.input-container {
|
| 508 |
+
display: flex;
|
| 509 |
+
position: relative;
|
| 510 |
+
align-items: flex-end;
|
| 511 |
+
}
|
| 512 |
+
.submit-button,
|
| 513 |
+
.stop-button {
|
| 514 |
+
border: none;
|
| 515 |
+
text-align: center;
|
| 516 |
+
text-decoration: none;
|
| 517 |
+
font-size: 14px;
|
| 518 |
+
cursor: pointer;
|
| 519 |
+
border-radius: 15px;
|
| 520 |
+
min-width: 30px;
|
| 521 |
+
height: 30px;
|
| 522 |
+
flex-shrink: 0;
|
| 523 |
+
display: flex;
|
| 524 |
+
justify-content: center;
|
| 525 |
+
align-items: center;
|
| 526 |
+
z-index: var(--layer-1);
|
| 527 |
+
}
|
| 528 |
+
.stop-button,
|
| 529 |
+
.submit-button {
|
| 530 |
+
background: var(--button-secondary-background-fill);
|
| 531 |
+
color: var(--button-secondary-text-color);
|
| 532 |
+
}
|
| 533 |
+
.stop-button:hover,
|
| 534 |
+
.submit-button:hover {
|
| 535 |
+
background: var(--button-secondary-background-fill-hover);
|
| 536 |
+
}
|
| 537 |
+
.stop-button:disabled,
|
| 538 |
+
.submit-button:disabled {
|
| 539 |
+
background: var(--button-secondary-background-fill);
|
| 540 |
+
cursor: pointer;
|
| 541 |
+
}
|
| 542 |
+
.stop-button:active,
|
| 543 |
+
.submit-button:active {
|
| 544 |
+
box-shadow: var(--button-shadow-active);
|
| 545 |
+
}
|
| 546 |
+
.submit-button :global(svg) {
|
| 547 |
+
height: 22px;
|
| 548 |
+
width: 22px;
|
| 549 |
+
}
|
| 550 |
+
|
| 551 |
+
.stop-button :global(svg) {
|
| 552 |
+
height: 16px;
|
| 553 |
+
width: 16px;
|
| 554 |
+
}
|
| 555 |
+
.padded-button {
|
| 556 |
+
padding: 0 10px;
|
| 557 |
+
}
|
| 558 |
+
|
| 559 |
+
div.validation-error {
|
| 560 |
+
color: var(--error-icon-color);
|
| 561 |
+
font-size: var(--font-sans);
|
| 562 |
+
margin-top: var(--spacing-sm);
|
| 563 |
+
font-weight: var(--weight-semibold);
|
| 564 |
+
}
|
| 565 |
+
|
| 566 |
+
label.container input.validation-error,
|
| 567 |
+
label.container textarea.validation-error {
|
| 568 |
+
border-color: transparent !important;
|
| 569 |
+
box-shadow:
|
| 570 |
+
0 0 3px 1px var(--error-icon-color),
|
| 571 |
+
var(--shadow-inset) !important;
|
| 572 |
+
}
|
| 573 |
+
</style>
|
6.4.0/textbox/types.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import {
|
| 2 |
+
type SelectData,
|
| 3 |
+
type CopyData,
|
| 4 |
+
type CustomButton
|
| 5 |
+
} from "@gradio/utils";
|
| 6 |
+
import type { LoadingStatus } from "@gradio/statustracker";
|
| 7 |
+
|
| 8 |
+
export interface TextboxEvents {
|
| 9 |
+
change: string;
|
| 10 |
+
submit: never;
|
| 11 |
+
blur: never;
|
| 12 |
+
select: SelectData;
|
| 13 |
+
input: never;
|
| 14 |
+
focus: never;
|
| 15 |
+
stop: never;
|
| 16 |
+
clear_status: LoadingStatus;
|
| 17 |
+
copy: CopyData;
|
| 18 |
+
custom_button_click: { id: number };
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
export interface TextboxProps {
|
| 22 |
+
value: string;
|
| 23 |
+
info: string;
|
| 24 |
+
lines: number;
|
| 25 |
+
type: "text" | "password" | "email" | undefined;
|
| 26 |
+
rtl: boolean;
|
| 27 |
+
text_align: "right" | "left";
|
| 28 |
+
max_lines: number;
|
| 29 |
+
placeholder: string;
|
| 30 |
+
submit_btn: string;
|
| 31 |
+
stop_btn: string;
|
| 32 |
+
buttons: (string | CustomButton)[] | null;
|
| 33 |
+
autofocus: boolean;
|
| 34 |
+
autoscroll: boolean;
|
| 35 |
+
max_length: number;
|
| 36 |
+
html_attributes: InputHTMLAttributes;
|
| 37 |
+
validation_error: string | null;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
type FullAutoFill =
|
| 41 |
+
| AutoFill
|
| 42 |
+
| "bday"
|
| 43 |
+
| `${OptionalPrefixToken<AutoFillAddressKind>}${"cc-additional-name"}`
|
| 44 |
+
| "nickname"
|
| 45 |
+
| "language"
|
| 46 |
+
| "organization-title"
|
| 47 |
+
| "photo"
|
| 48 |
+
| "sex"
|
| 49 |
+
| "url";
|
| 50 |
+
|
| 51 |
+
export interface InputHTMLAttributes {
|
| 52 |
+
autocapitalize?:
|
| 53 |
+
| "off"
|
| 54 |
+
| "none"
|
| 55 |
+
| "on"
|
| 56 |
+
| "sentences"
|
| 57 |
+
| "words"
|
| 58 |
+
| "characters"
|
| 59 |
+
| null;
|
| 60 |
+
autocorrect?: "on" | "off" | null;
|
| 61 |
+
spellcheck?: boolean | null;
|
| 62 |
+
autocomplete?: FullAutoFill | undefined | null;
|
| 63 |
+
tabindex?: number | null;
|
| 64 |
+
enterkeyhint?:
|
| 65 |
+
| "enter"
|
| 66 |
+
| "done"
|
| 67 |
+
| "go"
|
| 68 |
+
| "next"
|
| 69 |
+
| "previous"
|
| 70 |
+
| "search"
|
| 71 |
+
| "send"
|
| 72 |
+
| null;
|
| 73 |
+
lang?: string | null;
|
| 74 |
+
}
|