freddyaboulton HF Staff commited on
Commit
083c6e3
·
verified ·
1 Parent(s): ac2bd61

Upload folder using huggingface_hub

Browse files
6.0.0/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>
6.0.0/simpletextbox/Index.svelte ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <svelte:options accessors={true} />
2
+
3
+ <script lang="ts">
4
+ import type { SimpleTextboxProps, SimpleTextboxEvents } from "./types";
5
+ import { Gradio } from "@gradio/utils";
6
+ import { BlockTitle } from "@gradio/atoms";
7
+ import { Block } from "@gradio/atoms";
8
+ import { StatusTracker } from "@gradio/statustracker";
9
+ import { tick } from "svelte";
10
+
11
+ const props = $props();
12
+ const gradio = new Gradio<SimpleTextboxEvents, SimpleTextboxProps>(props);
13
+
14
+ let el: HTMLTextAreaElement | HTMLInputElement;
15
+ const container = true;
16
+ let old_value = $state(gradio.props.value);
17
+
18
+ async function handle_keypress(e: KeyboardEvent): Promise<void> {
19
+ await tick();
20
+ if (e.key === "Enter") {
21
+ e.preventDefault();
22
+ gradio.dispatch("submit");
23
+ }
24
+ }
25
+
26
+ $effect(() => {
27
+ if (old_value != gradio.props.value) {
28
+ old_value = gradio.props.value;
29
+ gradio.dispatch("change");
30
+ }
31
+ });
32
+ </script>
33
+
34
+ <Block
35
+ visible={gradio.shared.visible}
36
+ elem_id={gradio.shared.elem_id}
37
+ elem_classes={gradio.shared.elem_classes}
38
+ scale={gradio.shared.scale}
39
+ min_width={gradio.shared.min_width}
40
+ allow_overflow={false}
41
+ padding={true}
42
+ >
43
+ {#if gradio.shared.loading_status}
44
+ <StatusTracker
45
+ autoscroll={gradio.shared.autoscroll}
46
+ i18n={gradio.i18n}
47
+ {...gradio.shared.loading_status}
48
+ on_clear_status={() =>
49
+ gradio.dispatch("clear_status", gradio.shared.loading_status)}
50
+ />
51
+ {/if}
52
+
53
+ <label class:container>
54
+ <BlockTitle show_label={gradio.shared.show_label} info={undefined}
55
+ >{gradio.shared.label}</BlockTitle
56
+ >
57
+
58
+ <input
59
+ data-testid="textbox"
60
+ type="text"
61
+ class="scroll-hide"
62
+ bind:value={gradio.props.value}
63
+ bind:this={el}
64
+ placeholder={gradio.props.placeholder}
65
+ disabled={!gradio.shared.interactive}
66
+ dir={gradio.props.rtl ? "rtl" : "ltr"}
67
+ on:input={() => gradio.dispatch("input")}
68
+ on:keypress={handle_keypress}
69
+ />
70
+ </label>
71
+ </Block>
72
+
73
+ <style>
74
+ label {
75
+ display: block;
76
+ width: 100%;
77
+ }
78
+
79
+ input {
80
+ display: block;
81
+ position: relative;
82
+ outline: none !important;
83
+ box-shadow: var(--input-shadow);
84
+ background: var(--input-background-fill);
85
+ padding: var(--input-padding);
86
+ width: 100%;
87
+ color: var(--body-text-color);
88
+ font-weight: var(--input-text-weight);
89
+ font-size: var(--input-text-size);
90
+ line-height: var(--line-sm);
91
+ border: none;
92
+ }
93
+ .container > input {
94
+ border: var(--input-border-width) solid var(--input-border-color);
95
+ border-radius: var(--input-radius);
96
+ }
97
+ input:disabled {
98
+ -webkit-text-fill-color: var(--body-text-color);
99
+ -webkit-opacity: 1;
100
+ opacity: 1;
101
+ }
102
+
103
+ input:focus {
104
+ box-shadow: var(--input-shadow-focus);
105
+ border-color: var(--input-border-color-focus);
106
+ }
107
+
108
+ input::placeholder {
109
+ color: var(--input-placeholder-color);
110
+ }
111
+ </style>
6.0.0/simpletextbox/package.json ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@gradio/simpletextbox",
3
+ "version": "0.3.31",
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": "^5.43.4"
34
+ },
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git+https://github.com/gradio-app/gradio.git",
38
+ "directory": "js/simpletextbox"
39
+ }
40
+ }
6.0.0/simpletextbox/types.ts ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { LoadingStatus } from "@gradio/statustracker";
2
+
3
+ export interface SimpleTextboxProps {
4
+ value: string;
5
+ placeholder: string;
6
+ rtl: boolean;
7
+ }
8
+
9
+ export interface SimpleTextboxEvents {
10
+ change: never;
11
+ submit: never;
12
+ input: never;
13
+ clear_status: LoadingStatus;
14
+ }