gradio-pr-bot commited on
Commit
d12bc96
·
verified ·
1 Parent(s): 9b461b7

Upload folder using huggingface_hub

Browse files
5.49.1/simpletextbox/Example.svelte ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ min-width: var(--local-text-width);
49
+
50
+ white-space: nowrap;
51
+ }
52
+ </style>
5.49.1/simpletextbox/Index.svelte ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <svelte:options accessors={true} />
2
+
3
+ <script lang="ts">
4
+ import type { Gradio } from "@gradio/utils";
5
+ import { BlockTitle } from "@gradio/atoms";
6
+ import { Block } from "@gradio/atoms";
7
+ import { StatusTracker } from "@gradio/statustracker";
8
+ import type { LoadingStatus } from "@gradio/statustracker";
9
+ import { tick } from "svelte";
10
+
11
+ export let gradio: Gradio<{
12
+ change: never;
13
+ submit: never;
14
+ input: never;
15
+ clear_status: LoadingStatus;
16
+ }>;
17
+ export let label = "Textbox";
18
+ export let elem_id = "";
19
+ export let elem_classes: string[] = [];
20
+ export let visible: boolean | "hidden" = true;
21
+ export let value = "";
22
+ export let placeholder = "";
23
+ export let show_label: boolean;
24
+ export let scale: number | null = null;
25
+ export let min_width: number | undefined = undefined;
26
+ export let loading_status: LoadingStatus | undefined = undefined;
27
+ export let value_is_output = false;
28
+ export let interactive: boolean;
29
+ export let rtl = false;
30
+
31
+ let el: HTMLTextAreaElement | HTMLInputElement;
32
+ const container = true;
33
+
34
+ function handle_change(): void {
35
+ gradio.dispatch("change");
36
+ if (!value_is_output) {
37
+ gradio.dispatch("input");
38
+ }
39
+ }
40
+
41
+ async function handle_keypress(e: KeyboardEvent): Promise<void> {
42
+ await tick();
43
+ if (e.key === "Enter") {
44
+ e.preventDefault();
45
+ gradio.dispatch("submit");
46
+ }
47
+ }
48
+
49
+ $: if (value === null) value = "";
50
+
51
+ // When the value changes, dispatch the change event via handle_change()
52
+ // See the docs for an explanation: https://svelte.dev/docs/svelte-components#script-3-$-marks-a-statement-as-reactive
53
+ $: value, handle_change();
54
+ </script>
55
+
56
+ <Block
57
+ {visible}
58
+ {elem_id}
59
+ {elem_classes}
60
+ {scale}
61
+ {min_width}
62
+ allow_overflow={false}
63
+ padding={true}
64
+ >
65
+ {#if loading_status}
66
+ <StatusTracker
67
+ autoscroll={gradio.autoscroll}
68
+ i18n={gradio.i18n}
69
+ {...loading_status}
70
+ on:clear_status={() => gradio.dispatch("clear_status", loading_status)}
71
+ />
72
+ {/if}
73
+
74
+ <label class:container>
75
+ <BlockTitle {show_label} info={undefined}>{label}</BlockTitle>
76
+
77
+ <input
78
+ data-testid="textbox"
79
+ type="text"
80
+ class="scroll-hide"
81
+ bind:value
82
+ bind:this={el}
83
+ {placeholder}
84
+ disabled={!interactive}
85
+ dir={rtl ? "rtl" : "ltr"}
86
+ on:keypress={handle_keypress}
87
+ />
88
+ </label>
89
+ </Block>
90
+
91
+ <style>
92
+ label {
93
+ display: block;
94
+ width: 100%;
95
+ }
96
+
97
+ input {
98
+ display: block;
99
+ position: relative;
100
+ outline: none !important;
101
+ box-shadow: var(--input-shadow);
102
+ background: var(--input-background-fill);
103
+ padding: var(--input-padding);
104
+ width: 100%;
105
+ color: var(--body-text-color);
106
+ font-weight: var(--input-text-weight);
107
+ font-size: var(--input-text-size);
108
+ line-height: var(--line-sm);
109
+ border: none;
110
+ }
111
+ .container > input {
112
+ border: var(--input-border-width) solid var(--input-border-color);
113
+ border-radius: var(--input-radius);
114
+ }
115
+ input:disabled {
116
+ -webkit-text-fill-color: var(--body-text-color);
117
+ -webkit-opacity: 1;
118
+ opacity: 1;
119
+ }
120
+
121
+ input:focus {
122
+ box-shadow: var(--input-shadow-focus);
123
+ border-color: var(--input-border-color-focus);
124
+ }
125
+
126
+ input::placeholder {
127
+ color: var(--input-placeholder-color);
128
+ }
129
+ </style>
5.49.1/simpletextbox/package.json ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@gradio/simpletextbox",
3
+ "version": "0.3.30",
4
+ "description": "Gradio UI packages",
5
+ "type": "module",
6
+ "author": "",
7
+ "license": "ISC",
8
+ "private": false,
9
+ "main_changeset": true,
10
+ "exports": {
11
+ ".": {
12
+ "gradio": "./Index.svelte",
13
+ "svelte": "./dist/Index.svelte",
14
+ "types": "./dist/Index.svelte.d.ts"
15
+ },
16
+ "./example": {
17
+ "gradio": "./Example.svelte",
18
+ "svelte": "./dist/Example.svelte",
19
+ "types": "./dist/Example.svelte.d.ts"
20
+ },
21
+ "./package.json": "./package.json"
22
+ },
23
+ "dependencies": {
24
+ "@gradio/atoms": "workspace:^",
25
+ "@gradio/icons": "workspace:^",
26
+ "@gradio/statustracker": "workspace:^",
27
+ "@gradio/utils": "workspace:^"
28
+ },
29
+ "devDependencies": {
30
+ "@gradio/preview": "workspace:^"
31
+ },
32
+ "peerDependencies": {
33
+ "svelte": "^4.0.0"
34
+ },
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git+https://github.com/gradio-app/gradio.git",
38
+ "directory": "js/simpletextbox"
39
+ }
40
+ }