gradio-pr-bot commited on
Commit
64e7dad
·
verified ·
1 Parent(s): ddfdf95

Upload folder using huggingface_hub

Browse files
6.5.0/atoms/package.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@gradio/atoms",
3
+ "version": "0.21.0",
4
+ "description": "Gradio UI packages",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "author": "",
8
+ "license": "ISC",
9
+ "dependencies": {
10
+ "@gradio/icons": "workspace:^",
11
+ "@gradio/markdown-code": "workspace:^",
12
+ "@gradio/utils": "workspace:^"
13
+ },
14
+ "peerDependencies": {
15
+ "svelte": "^5.48.0"
16
+ },
17
+ "exports": {
18
+ ".": {
19
+ "gradio": "./src/index.ts",
20
+ "svelte": "./dist/src/index.js",
21
+ "types": "./dist/src/index.d.ts"
22
+ },
23
+ "./package.json": "./package.json"
24
+ },
25
+ "main_changeset": true,
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/gradio-app/gradio.git",
29
+ "directory": "js/atoms"
30
+ },
31
+ "scripts": {
32
+ "sv-package": "svelte-package --input=. --tsconfig=../../tsconfig.json"
33
+ }
34
+ }
6.5.0/atoms/src/Block.svelte ADDED
@@ -0,0 +1,255 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ export let height: number | string | undefined = undefined;
3
+ export let min_height: number | string | undefined = undefined;
4
+ export let max_height: number | string | undefined = undefined;
5
+ export let width: number | string | undefined = undefined;
6
+ export let elem_id = "";
7
+ export let elem_classes: string[] = [];
8
+ export let variant: "solid" | "dashed" | "none" = "solid";
9
+ export let border_mode: "base" | "focus" | "contrast" = "base";
10
+ export let padding = true;
11
+ export let type: "normal" | "fieldset" = "normal";
12
+ export let test_id: string | undefined = undefined;
13
+ export let explicit_call = false;
14
+ export let container = true;
15
+ export let visible: boolean | "hidden" = true;
16
+ export let allow_overflow = true;
17
+ export let overflow_behavior: "visible" | "auto" = "auto";
18
+ export let scale: number | null = null;
19
+ export let min_width = 0;
20
+ export let flex = false;
21
+ export let resizable = false;
22
+ export let rtl = false;
23
+ export let fullscreen = false;
24
+ export let label: string | undefined = undefined;
25
+ let old_fullscreen = fullscreen;
26
+
27
+ let element: HTMLElement;
28
+
29
+ let tag = type === "fieldset" ? "fieldset" : "div";
30
+
31
+ let placeholder_height = 0;
32
+ let placeholder_width = 0;
33
+ let preexpansionBoundingRect: DOMRect | null = null;
34
+
35
+ function handleKeydown(event: KeyboardEvent): void {
36
+ if (fullscreen && event.key === "Escape") {
37
+ fullscreen = false;
38
+ }
39
+ }
40
+
41
+ $: if (fullscreen !== old_fullscreen) {
42
+ old_fullscreen = fullscreen;
43
+ if (fullscreen) {
44
+ preexpansionBoundingRect = element.getBoundingClientRect();
45
+ placeholder_height = element.offsetHeight;
46
+ placeholder_width = element.offsetWidth;
47
+ window.addEventListener("keydown", handleKeydown);
48
+ } else {
49
+ preexpansionBoundingRect = null;
50
+ window.removeEventListener("keydown", handleKeydown);
51
+ }
52
+ }
53
+
54
+ const get_dimension = (
55
+ dimension_value: string | number | undefined
56
+ ): string | undefined => {
57
+ if (dimension_value === undefined) {
58
+ return undefined;
59
+ }
60
+ if (typeof dimension_value === "number") {
61
+ return dimension_value + "px";
62
+ } else if (typeof dimension_value === "string") {
63
+ return dimension_value;
64
+ }
65
+ };
66
+
67
+ $: if (!visible) {
68
+ flex = false;
69
+ }
70
+
71
+ const resize = (e: MouseEvent): void => {
72
+ let prevY = e.clientY;
73
+ const onMouseMove = (e: MouseEvent): void => {
74
+ const dy: number = e.clientY - prevY;
75
+ prevY = e.clientY;
76
+ element.style.height = `${element.offsetHeight + dy}px`;
77
+ };
78
+ const onMouseUp = (): void => {
79
+ window.removeEventListener("mousemove", onMouseMove);
80
+ window.removeEventListener("mouseup", onMouseUp);
81
+ };
82
+ window.addEventListener("mousemove", onMouseMove);
83
+ window.addEventListener("mouseup", onMouseUp);
84
+ };
85
+ // When visible is False, we need to remove the component from the page
86
+ // We can remove it by either modifying the AppTree in Blocks or by hiding the component here
87
+ // We do it here because if visible is updated via an event, only the local state will be updated
88
+ // and we would have to flow the state back up to modify the AppTree
89
+ </script>
90
+
91
+ {#if visible === true || visible === "hidden"}
92
+ <svelte:element
93
+ this={tag}
94
+ bind:this={element}
95
+ data-testid={test_id}
96
+ id={elem_id}
97
+ class:hidden={visible === "hidden"}
98
+ class="block {elem_classes?.join(' ') || ''}"
99
+ class:padded={padding}
100
+ class:flex
101
+ class:border_focus={border_mode === "focus"}
102
+ class:border_contrast={border_mode === "contrast"}
103
+ class:hide-container={!explicit_call && !container}
104
+ style:height={fullscreen ? undefined : get_dimension(height)}
105
+ style:min-height={fullscreen ? undefined : get_dimension(min_height)}
106
+ style:max-height={fullscreen ? undefined : get_dimension(max_height)}
107
+ class:fullscreen
108
+ class:animating={fullscreen && preexpansionBoundingRect !== null}
109
+ style:--start-top={preexpansionBoundingRect
110
+ ? `${preexpansionBoundingRect.top}px`
111
+ : "0px"}
112
+ style:--start-left={preexpansionBoundingRect
113
+ ? `${preexpansionBoundingRect.left}px`
114
+ : "0px"}
115
+ style:--start-width={preexpansionBoundingRect
116
+ ? `${preexpansionBoundingRect.width}px`
117
+ : "0px"}
118
+ style:--start-height={preexpansionBoundingRect
119
+ ? `${preexpansionBoundingRect.height}px`
120
+ : "0px"}
121
+ style:width={fullscreen
122
+ ? undefined
123
+ : typeof width === "number"
124
+ ? `calc(min(${width}px, 100%))`
125
+ : get_dimension(width)}
126
+ style:border-style={variant}
127
+ style:overflow={allow_overflow ? overflow_behavior : "hidden"}
128
+ style:flex-grow={scale}
129
+ style:min-width={`calc(min(${min_width}px, 100%))`}
130
+ style:border-width="var(--block-border-width)"
131
+ class:auto-margin={scale === null}
132
+ dir={rtl ? "rtl" : "ltr"}
133
+ aria-label={label}
134
+ >
135
+ <slot />
136
+ {#if resizable}
137
+ <!-- svelte-ignore a11y-no-static-element-interactions -->
138
+ <svg
139
+ class="resize-handle"
140
+ xmlns="http://www.w3.org/2000/svg"
141
+ viewBox="0 0 10 10"
142
+ on:mousedown={resize}
143
+ >
144
+ <line x1="1" y1="9" x2="9" y2="1" stroke="gray" stroke-width="0.5" />
145
+ <line x1="5" y1="9" x2="9" y2="5" stroke="gray" stroke-width="0.5" />
146
+ </svg>
147
+ {/if}
148
+ </svelte:element>
149
+ {#if fullscreen}
150
+ <div
151
+ class="placeholder"
152
+ style:height={placeholder_height + "px"}
153
+ style:width={placeholder_width + "px"}
154
+ ></div>
155
+ {/if}
156
+ {/if}
157
+
158
+ <style>
159
+ .block {
160
+ position: relative;
161
+ margin: 0;
162
+ box-shadow: var(--block-shadow);
163
+ border-width: var(--block-border-width);
164
+ border-color: var(--block-border-color);
165
+ border-radius: var(--block-radius);
166
+ background: var(--block-background-fill);
167
+ width: 100%;
168
+ line-height: var(--line-sm);
169
+ }
170
+ .block.fullscreen {
171
+ border-radius: 0;
172
+ }
173
+
174
+ .auto-margin {
175
+ margin-left: auto;
176
+ margin-right: auto;
177
+ }
178
+
179
+ .block.border_focus {
180
+ border-color: var(--color-accent);
181
+ }
182
+
183
+ .block.border_contrast {
184
+ border-color: var(--body-text-color);
185
+ }
186
+
187
+ .padded {
188
+ padding: var(--block-padding);
189
+ }
190
+
191
+ .hidden {
192
+ display: none;
193
+ }
194
+
195
+ .flex {
196
+ display: flex;
197
+ flex-direction: column;
198
+ }
199
+ .hide-container:not(.fullscreen) {
200
+ margin: 0;
201
+ box-shadow: none;
202
+ --block-border-width: 0;
203
+ background: transparent;
204
+ padding: 0;
205
+ overflow: visible;
206
+ }
207
+ .resize-handle {
208
+ position: absolute;
209
+ bottom: 0;
210
+ right: 0;
211
+ width: 10px;
212
+ height: 10px;
213
+ fill: var(--block-border-color);
214
+ cursor: nwse-resize;
215
+ }
216
+ .fullscreen {
217
+ position: fixed;
218
+ top: 0;
219
+ left: 0;
220
+ width: 100vw;
221
+ height: 100vh;
222
+ z-index: 1000;
223
+ overflow: auto;
224
+ }
225
+
226
+ .animating {
227
+ animation: pop-out 0.1s ease-out forwards;
228
+ }
229
+
230
+ @keyframes pop-out {
231
+ 0% {
232
+ position: fixed;
233
+ top: var(--start-top);
234
+ left: var(--start-left);
235
+ width: var(--start-width);
236
+ height: var(--start-height);
237
+ z-index: 100;
238
+ }
239
+ 100% {
240
+ position: fixed;
241
+ top: 0vh;
242
+ left: 0vw;
243
+ width: 100vw;
244
+ height: 100vh;
245
+ z-index: 1000;
246
+ }
247
+ }
248
+
249
+ .placeholder {
250
+ border-radius: var(--block-radius);
251
+ border-width: var(--block-border-width);
252
+ border-color: var(--block-border-color);
253
+ border-style: dashed;
254
+ }
255
+ </style>
6.5.0/atoms/src/BlockLabel.svelte ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ export let label: string | null = null;
3
+ export let Icon: any;
4
+ export let show_label = true;
5
+ export let disable = false;
6
+ export let float = true;
7
+ export let rtl = false;
8
+ </script>
9
+
10
+ <label
11
+ for=""
12
+ class:hide={!show_label}
13
+ class:sr-only={!show_label}
14
+ class:float
15
+ class:hide-label={disable}
16
+ data-testid="block-label"
17
+ dir={rtl ? "rtl" : "ltr"}
18
+ >
19
+ <span>
20
+ <Icon />
21
+ </span>
22
+ {label}
23
+ </label>
24
+
25
+ <style>
26
+ label {
27
+ display: inline-flex;
28
+ align-items: center;
29
+ z-index: var(--layer-2);
30
+ box-shadow: var(--block-label-shadow);
31
+ border: var(--block-label-border-width) solid
32
+ var(--block-label-border-color);
33
+ border-top: none;
34
+ border-left: none;
35
+ border-radius: var(--block-label-radius);
36
+ background: var(--block-label-background-fill);
37
+ padding: var(--block-label-padding);
38
+ pointer-events: none;
39
+ color: var(--block-label-text-color);
40
+ font-weight: var(--block-label-text-weight);
41
+ font-size: var(--block-label-text-size);
42
+ line-height: var(--line-sm);
43
+ }
44
+ :global(.gr-group) label {
45
+ border-top-left-radius: 0;
46
+ }
47
+
48
+ label.float {
49
+ position: absolute;
50
+ top: var(--block-label-margin);
51
+ left: var(--block-label-margin);
52
+ }
53
+ label:not(.float) {
54
+ position: static;
55
+ margin-top: var(--block-label-margin);
56
+ margin-left: var(--block-label-margin);
57
+ }
58
+
59
+ .hide {
60
+ display: none;
61
+ }
62
+
63
+ span {
64
+ opacity: 0.8;
65
+ margin-right: var(--size-2);
66
+ width: calc(var(--block-label-text-size) - 1px);
67
+ height: calc(var(--block-label-text-size) - 1px);
68
+ }
69
+ .hide-label {
70
+ box-shadow: none;
71
+ border-width: 0;
72
+ background: transparent;
73
+ overflow: visible;
74
+ }
75
+
76
+ label[dir="rtl"] {
77
+ border: var(--block-label-border-width) solid
78
+ var(--block-label-border-color);
79
+ border-top: none;
80
+ border-right: none;
81
+ border-bottom-left-radius: var(--block-radius);
82
+ border-bottom-right-radius: var(--block-label-radius);
83
+ border-top-left-radius: var(--block-label-radius);
84
+ }
85
+
86
+ label[dir="rtl"] span {
87
+ margin-left: var(--size-2);
88
+ margin-right: 0;
89
+ }
90
+ </style>
6.5.0/atoms/src/BlockTitle.svelte ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { default as Info } from "./Info.svelte";
3
+ export let show_label = true;
4
+ export let info: string | undefined = undefined;
5
+ export let rtl = false;
6
+ </script>
7
+
8
+ <span
9
+ class:hide={!show_label}
10
+ class:has-info={info != null}
11
+ class:sr-only={!show_label}
12
+ data-testid="block-info"
13
+ dir={rtl ? "rtl" : "ltr"}
14
+ >
15
+ <slot />
16
+ </span>
17
+ {#if info}
18
+ <Info {info} />
19
+ {/if}
20
+
21
+ <style>
22
+ span.has-info {
23
+ margin-bottom: var(--spacing-xs);
24
+ }
25
+ span:not(.has-info) {
26
+ margin-bottom: var(--spacing-lg);
27
+ }
28
+ span {
29
+ display: inline-block;
30
+ position: relative;
31
+ z-index: var(--layer-4);
32
+ border: solid var(--block-title-border-width)
33
+ var(--block-title-border-color);
34
+ border-radius: var(--block-title-radius);
35
+ background: var(--block-title-background-fill);
36
+ padding: var(--block-title-padding);
37
+ color: var(--block-title-text-color);
38
+ font-weight: var(--block-title-text-weight);
39
+ font-size: var(--block-title-text-size);
40
+ line-height: var(--line-sm);
41
+ }
42
+
43
+ span[dir="rtl"] {
44
+ display: block;
45
+ }
46
+
47
+ .hide {
48
+ margin: 0;
49
+ height: 0;
50
+ }
51
+
52
+ .sr-only {
53
+ clip: rect(0, 0, 0, 0);
54
+ position: absolute;
55
+ margin: -1px;
56
+ border-width: 0;
57
+ padding: 0;
58
+ width: 1px;
59
+ height: 1px;
60
+ overflow: hidden;
61
+ white-space: nowrap;
62
+ }
63
+ </style>
6.5.0/atoms/src/CustomButton.svelte ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import type { CustomButton } from "@gradio/utils";
3
+
4
+ export let button: CustomButton;
5
+ export let on_click: (id: number) => void;
6
+ </script>
7
+
8
+ <button
9
+ class="custom-button"
10
+ on:click={() => on_click(button.id)}
11
+ title={button.value || ""}
12
+ aria-label={button.value || "Custom action"}
13
+ >
14
+ {#if button.value}
15
+ <span class="custom-button-label">{button.value}</span>
16
+ {/if}
17
+ </button>
18
+
19
+ <style>
20
+ .custom-button {
21
+ display: flex;
22
+ align-items: center;
23
+ justify-content: center;
24
+ gap: var(--size-1);
25
+ height: var(--size-6);
26
+ padding: var(--size-1) var(--size-2);
27
+ border: none;
28
+ border-radius: var(--radius-sm);
29
+ background: transparent;
30
+ color: var(--block-title-text-color);
31
+ cursor: pointer;
32
+ transition: all 0.2s;
33
+ font-size: var(--text-sm);
34
+ margin-left: var(--size-1);
35
+ }
36
+
37
+ .custom-button:hover {
38
+ background: var(--background-fill-secondary);
39
+ color: var(--body-text-color);
40
+ }
41
+
42
+ .custom-button-label {
43
+ white-space: nowrap;
44
+ }
45
+ </style>
6.5.0/atoms/src/DownloadLink.svelte ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import type { HTMLAnchorAttributes } from "svelte/elements";
3
+ import { createEventDispatcher } from "svelte";
4
+
5
+ interface DownloadLinkAttributes extends Omit<
6
+ HTMLAnchorAttributes,
7
+ "target"
8
+ > {
9
+ download: NonNullable<HTMLAnchorAttributes["download"]>;
10
+ }
11
+ type $$Props = DownloadLinkAttributes;
12
+
13
+ export let href: DownloadLinkAttributes["href"] = undefined;
14
+ export let download: DownloadLinkAttributes["download"];
15
+
16
+ const dispatch = createEventDispatcher();
17
+ </script>
18
+
19
+ <a
20
+ style:position="relative"
21
+ class="download-link"
22
+ {href}
23
+ target={typeof window !== "undefined" && window.__is_colab__
24
+ ? "_blank"
25
+ : null}
26
+ rel="noopener noreferrer"
27
+ {download}
28
+ {...$$restProps}
29
+ on:click={dispatch.bind(null, "click")}
30
+ >
31
+ <slot />
32
+ </a>
33
+
34
+ <style>
35
+ .unstyled-link {
36
+ all: unset;
37
+ cursor: pointer;
38
+ }
39
+ </style>
6.5.0/atoms/src/Empty.svelte ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ export let size: "small" | "large" = "small";
3
+ export let unpadded_box = false;
4
+
5
+ let el: HTMLDivElement;
6
+ $: parent_height = compare_el_to_parent(el);
7
+
8
+ function compare_el_to_parent(el: HTMLDivElement): boolean {
9
+ if (!el) return false;
10
+
11
+ const { height: el_height } = el.getBoundingClientRect();
12
+ const { height: parent_height } =
13
+ el.parentElement?.getBoundingClientRect() || { height: el_height };
14
+
15
+ return el_height > parent_height + 2;
16
+ }
17
+ </script>
18
+
19
+ <div
20
+ class="empty"
21
+ class:small={size === "small"}
22
+ class:large={size === "large"}
23
+ class:unpadded_box
24
+ bind:this={el}
25
+ class:small_parent={parent_height}
26
+ aria-label="Empty value"
27
+ >
28
+ <div class="icon">
29
+ <slot />
30
+ </div>
31
+ </div>
32
+
33
+ <style>
34
+ .empty {
35
+ display: flex;
36
+ justify-content: center;
37
+ align-items: center;
38
+ margin-top: calc(0px - var(--size-6));
39
+ height: var(--size-full);
40
+ }
41
+
42
+ .icon {
43
+ opacity: 0.5;
44
+ height: var(--size-5);
45
+ color: var(--body-text-color);
46
+ }
47
+
48
+ .small {
49
+ min-height: calc(var(--size-32) - 20px);
50
+ }
51
+
52
+ .large {
53
+ min-height: calc(var(--size-64) - 20px);
54
+ }
55
+
56
+ .unpadded_box {
57
+ margin-top: 0;
58
+ }
59
+
60
+ .small_parent {
61
+ min-height: 100% !important;
62
+ }
63
+ </style>
6.5.0/atoms/src/FullscreenButton.svelte ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.5.0/atoms/src/IconButton.svelte ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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}
48
+ class:pending
49
+ class:padded
50
+ class:highlight
51
+ class:transparent
52
+ style:--border-color={border}
53
+ style:color={!disabled && _color ? _color : "var(--block-label-text-color)"}
54
+ style:--bg-color={!disabled ? background : "auto"}
55
+ >
56
+ {#if show_label}<span>{label}</span>{/if}
57
+ <div
58
+ class:x-small={size === "x-small"}
59
+ class:small={size === "small"}
60
+ class:large={size === "large"}
61
+ class:medium={size === "medium"}
62
+ >
63
+ <Icon />
64
+ {#if children}{@render children()}{/if}
65
+ </div>
66
+ </button>
67
+
68
+ <style>
69
+ button {
70
+ display: flex;
71
+ justify-content: center;
72
+ align-items: center;
73
+ gap: 1px;
74
+ z-index: var(--layer-2);
75
+ border-radius: var(--radius-xs);
76
+ color: var(--block-label-text-color);
77
+ border: 1px solid var(--border-color);
78
+ padding: var(--spacing-xxs);
79
+ }
80
+
81
+ button:hover {
82
+ background-color: var(--background-fill-secondary);
83
+ }
84
+
85
+ button[disabled] {
86
+ opacity: 0.5;
87
+ box-shadow: none;
88
+ }
89
+
90
+ button[disabled]:hover {
91
+ cursor: not-allowed;
92
+ }
93
+
94
+ .padded {
95
+ background: var(--bg-color);
96
+ }
97
+
98
+ button:hover,
99
+ button.highlight {
100
+ cursor: pointer;
101
+ color: var(--color-accent);
102
+ }
103
+
104
+ .padded:hover {
105
+ color: var(--block-label-text-color);
106
+ }
107
+
108
+ span {
109
+ padding: 0px 1px;
110
+ font-size: 10px;
111
+ }
112
+
113
+ div {
114
+ display: flex;
115
+ align-items: center;
116
+ justify-content: center;
117
+ transition: filter 0.2s ease-in-out;
118
+ }
119
+
120
+ .x-small {
121
+ width: 10px;
122
+ height: 10px;
123
+ }
124
+
125
+ .small {
126
+ width: 14px;
127
+ height: 14px;
128
+ }
129
+
130
+ .medium {
131
+ width: 20px;
132
+ height: 20px;
133
+ }
134
+
135
+ .large {
136
+ width: 22px;
137
+ height: 22px;
138
+ }
139
+
140
+ .pending {
141
+ animation: flash 0.5s infinite;
142
+ }
143
+
144
+ @keyframes flash {
145
+ 0% {
146
+ opacity: 0.5;
147
+ }
148
+ 50% {
149
+ opacity: 1;
150
+ }
151
+ 100% {
152
+ opacity: 0.5;
153
+ }
154
+ }
155
+
156
+ .transparent {
157
+ background: transparent;
158
+ border: none;
159
+ box-shadow: none;
160
+ }
161
+ </style>
6.5.0/atoms/src/IconButtonWrapper.svelte ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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"}
30
+ <CustomButton
31
+ button={btn}
32
+ on_click={(id) => {
33
+ if (on_custom_button_click) {
34
+ on_custom_button_click(id);
35
+ }
36
+ }}
37
+ />
38
+ {/if}
39
+ {/each}
40
+ {/if}
41
+ </div>
42
+
43
+ <style>
44
+ .icon-button-wrapper {
45
+ display: flex;
46
+ flex-direction: row;
47
+ align-items: center;
48
+ justify-content: center;
49
+ z-index: var(--layer-2);
50
+ gap: var(--spacing-sm);
51
+ box-shadow: var(--shadow-drop);
52
+ border: 1px solid var(--border-color-primary);
53
+ background: var(--block-background-fill);
54
+ padding: var(--spacing-xxs);
55
+ }
56
+
57
+ .icon-button-wrapper.hide-top-corner {
58
+ border-top: none;
59
+ border-right: none;
60
+ border-radius: var(--block-label-right-radius);
61
+ }
62
+
63
+ .icon-button-wrapper.display-top-corner {
64
+ border-radius: var(--radius-sm) 0 0 var(--radius-sm);
65
+ top: var(--spacing-sm);
66
+ right: -1px;
67
+ }
68
+
69
+ .icon-button-wrapper:not(.top-panel) {
70
+ border: 1px solid var(--border-color-primary);
71
+ border-radius: var(--radius-sm);
72
+ }
73
+
74
+ .top-panel {
75
+ position: absolute;
76
+ top: var(--block-label-margin);
77
+ right: var(--block-label-margin);
78
+ margin: 0;
79
+ }
80
+
81
+ .icon-button-wrapper :global(button) {
82
+ margin: var(--spacing-xxs);
83
+ border-radius: var(--radius-xs);
84
+ position: relative;
85
+ }
86
+
87
+ .icon-button-wrapper :global(a.download-link:not(:last-child)),
88
+ .icon-button-wrapper :global(button:not(:last-child)) {
89
+ margin-right: var(--spacing-xxs);
90
+ }
91
+
92
+ .icon-button-wrapper
93
+ :global(a.download-link:not(:last-child):not(.no-border *)::after),
94
+ .icon-button-wrapper
95
+ :global(button:not(:last-child):not(.no-border *)::after) {
96
+ content: "";
97
+ position: absolute;
98
+ right: -4.5px;
99
+ top: 15%;
100
+ height: 70%;
101
+ width: 1px;
102
+ background-color: var(--border-color-primary);
103
+ }
104
+
105
+ .icon-button-wrapper :global(> *) {
106
+ height: 100%;
107
+ }
108
+
109
+ .icon-button-wrapper.no-background {
110
+ box-shadow: none;
111
+ border: none;
112
+ background: none;
113
+ padding: 0;
114
+ z-index: var(--layer-1);
115
+ }
116
+ </style>
6.5.0/atoms/src/Info.svelte ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { MarkdownCode as Markdown } from "@gradio/markdown-code";
3
+ export let info: string;
4
+ </script>
5
+
6
+ <div>
7
+ <Markdown message={info} sanitize_html={true} />
8
+ </div>
9
+
10
+ <style>
11
+ div > :global(.md.prose) {
12
+ font-weight: var(--block-info-text-weight);
13
+ font-size: var(--block-info-text-size);
14
+ line-height: var(--line-sm);
15
+ }
16
+ div > :global(.md.prose *) {
17
+ color: var(--block-info-text-color);
18
+ }
19
+ div {
20
+ margin-bottom: var(--spacing-md);
21
+ }
22
+ </style>
6.5.0/atoms/src/ScrollFade.svelte ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ let {
3
+ visible = false,
4
+ position = "sticky"
5
+ }: {
6
+ visible: boolean;
7
+ position?: "sticky" | "absolute";
8
+ } = $props();
9
+ </script>
10
+
11
+ {#if visible}
12
+ <div class="scroll-fade" class:absolute={position === "absolute"}></div>
13
+ {/if}
14
+
15
+ <style>
16
+ .scroll-fade {
17
+ position: sticky;
18
+ bottom: calc(0px - var(--size-2-5));
19
+ left: 0;
20
+ right: 0;
21
+ height: var(--size-6);
22
+ background: linear-gradient(
23
+ to top,
24
+ var(--block-background-fill) 30%,
25
+ transparent
26
+ );
27
+ pointer-events: none;
28
+ margin-top: calc(0px - var(--size-6));
29
+ }
30
+
31
+ .scroll-fade.absolute {
32
+ position: absolute;
33
+ bottom: 0;
34
+ margin-top: 0;
35
+ z-index: var(--layer-2);
36
+ }
37
+ </style>
6.5.0/atoms/src/SelectSource.svelte ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { Microphone, Upload, Webcam, ImagePaste, Video } from "@gradio/icons";
3
+
4
+ type source_types =
5
+ | "upload"
6
+ | "microphone"
7
+ | "webcam"
8
+ | "clipboard"
9
+ | "webcam-video"
10
+ | null;
11
+
12
+ let {
13
+ sources,
14
+ active_source = $bindable(),
15
+ handle_clear = () => {},
16
+ handle_select = () => {}
17
+ }: {
18
+ sources: Partial<source_types>[];
19
+ active_source?: Partial<source_types>;
20
+ handle_clear?: () => void;
21
+ handle_select?: (source_type: Partial<source_types>) => void;
22
+ } = $props();
23
+
24
+ let unique_sources = $derived([...new Set(sources)]);
25
+
26
+ async function handle_select_source(
27
+ source: Partial<source_types>
28
+ ): Promise<void> {
29
+ handle_clear();
30
+ active_source = source;
31
+ handle_select(source);
32
+ }
33
+ </script>
34
+
35
+ {#if unique_sources.length > 1}
36
+ <span class="source-selection" data-testid="source-select">
37
+ {#if sources.includes("upload")}
38
+ <button
39
+ class="icon"
40
+ class:selected={active_source === "upload" || !active_source}
41
+ aria-label="Upload file"
42
+ onclick={() => handle_select_source("upload")}><Upload /></button
43
+ >
44
+ {/if}
45
+
46
+ {#if sources.includes("microphone")}
47
+ <button
48
+ class="icon"
49
+ class:selected={active_source === "microphone"}
50
+ aria-label="Record audio"
51
+ onclick={() => handle_select_source("microphone")}
52
+ ><Microphone /></button
53
+ >
54
+ {/if}
55
+
56
+ {#if sources.includes("webcam")}
57
+ <button
58
+ class="icon"
59
+ class:selected={active_source === "webcam"}
60
+ aria-label="Capture from camera"
61
+ onclick={() => handle_select_source("webcam")}><Webcam /></button
62
+ >
63
+ {/if}
64
+ {#if sources.includes("webcam-video")}
65
+ <button
66
+ class="icon"
67
+ class:selected={active_source === "webcam-video"}
68
+ aria-label="Record video from camera"
69
+ onclick={() => handle_select_source("webcam-video")}><Video /></button
70
+ >
71
+ {/if}
72
+ {#if sources.includes("clipboard")}
73
+ <button
74
+ class="icon"
75
+ class:selected={active_source === "clipboard"}
76
+ aria-label="Paste from clipboard"
77
+ onclick={() => handle_select_source("clipboard")}><ImagePaste /></button
78
+ >
79
+ {/if}
80
+ </span>
81
+ {/if}
82
+
83
+ <style>
84
+ .source-selection {
85
+ display: flex;
86
+ align-items: center;
87
+ justify-content: center;
88
+ border-top: 1px solid var(--border-color-primary);
89
+ width: 100%;
90
+ margin-left: auto;
91
+ margin-right: auto;
92
+ height: var(--size-10);
93
+ }
94
+
95
+ .icon {
96
+ width: 22px;
97
+ height: 22px;
98
+ margin: var(--spacing-lg) var(--spacing-xs);
99
+ padding: var(--spacing-xs);
100
+ color: var(--neutral-400);
101
+ border-radius: var(--radius-md);
102
+ }
103
+
104
+ .selected {
105
+ color: var(--color-accent);
106
+ }
107
+
108
+ .icon:hover,
109
+ .icon:focus {
110
+ color: var(--color-accent);
111
+ }
112
+ </style>
6.5.0/atoms/src/ShareButton.svelte ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import IconButton from "./IconButton.svelte";
3
+ import { Community } from "@gradio/icons";
4
+ import { createEventDispatcher } from "svelte";
5
+ import type { ShareData } from "@gradio/utils";
6
+ import { ShareError } from "@gradio/utils";
7
+ import type { I18nFormatter } from "@gradio/utils";
8
+
9
+ const dispatch = createEventDispatcher<{
10
+ share: ShareData;
11
+ error: string;
12
+ }>();
13
+
14
+ export let formatter: (arg0: any) => Promise<string>;
15
+ export let value: any;
16
+ export let i18n: I18nFormatter;
17
+ let pending = false;
18
+ </script>
19
+
20
+ <IconButton
21
+ Icon={Community}
22
+ label={i18n("common.share")}
23
+ {pending}
24
+ onclick={async () => {
25
+ try {
26
+ pending = true;
27
+ const formatted = await formatter(value);
28
+ dispatch("share", {
29
+ description: formatted
30
+ });
31
+ } catch (e) {
32
+ console.error(e);
33
+ let message = e instanceof ShareError ? e.message : "Share failed.";
34
+ dispatch("error", message);
35
+ } finally {
36
+ pending = false;
37
+ }
38
+ }}
39
+ />
6.5.0/atoms/src/Toolbar.svelte ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ export let show_border = false;
3
+ </script>
4
+
5
+ <div class:show_border>
6
+ <slot />
7
+ </div>
8
+
9
+ <style>
10
+ div {
11
+ border-top: 1px solid transparent;
12
+ display: flex;
13
+ max-height: 100%;
14
+ justify-content: center;
15
+ align-items: center;
16
+ gap: var(--spacing-sm);
17
+ height: auto;
18
+ align-items: flex-end;
19
+ color: var(--block-label-text-color);
20
+ flex-shrink: 0;
21
+ }
22
+
23
+ .show_border {
24
+ border-top: 1px solid var(--block-border-color);
25
+ margin-top: var(--spacing-xxl);
26
+ box-shadow: var(--shadow-drop);
27
+ }
28
+ </style>
6.5.0/atoms/src/UploadText.svelte ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import type { I18nFormatter } from "@gradio/utils";
3
+ import { Upload as UploadIcon, ImagePaste } from "@gradio/icons";
4
+ import { inject } from "./utils/parse_placeholder";
5
+
6
+ export let type:
7
+ | "video"
8
+ | "image"
9
+ | "audio"
10
+ | "file"
11
+ | "csv"
12
+ | "clipboard"
13
+ | "gallery" = "file";
14
+ export let i18n: I18nFormatter;
15
+ export let message: string | undefined = undefined;
16
+ export let mode: "full" | "short" = "full";
17
+ export let hovered = false;
18
+ export let placeholder: string | undefined = undefined;
19
+
20
+ const defs = {
21
+ image: "upload_text.drop_image",
22
+ video: "upload_text.drop_video",
23
+ audio: "upload_text.drop_audio",
24
+ file: "upload_text.drop_file",
25
+ csv: "upload_text.drop_csv",
26
+ gallery: "upload_text.drop_gallery",
27
+ clipboard: "upload_text.paste_clipboard"
28
+ };
29
+
30
+ $: [heading, paragraph] = placeholder ? inject(placeholder) : [false, false];
31
+ </script>
32
+
33
+ <div class="wrap">
34
+ <span class="icon-wrap" class:hovered>
35
+ {#if type === "clipboard"}
36
+ <ImagePaste />
37
+ {:else}
38
+ <UploadIcon />
39
+ {/if}
40
+ </span>
41
+
42
+ {#if heading || paragraph}
43
+ {#if heading}
44
+ <h2>{heading}</h2>
45
+ {/if}
46
+ {#if paragraph}
47
+ <p>{paragraph}</p>
48
+ {/if}
49
+ {:else}
50
+ {i18n(defs[type] || defs.file)}
51
+
52
+ {#if mode !== "short"}
53
+ <span class="or">- {i18n("common.or")} -</span>
54
+ {message || i18n("upload_text.click_to_upload")}
55
+ {/if}
56
+ {/if}
57
+ </div>
58
+
59
+ <style>
60
+ h2 {
61
+ font-size: var(--text-xl) !important;
62
+ }
63
+
64
+ p,
65
+ h2 {
66
+ white-space: pre-line;
67
+ }
68
+
69
+ .wrap {
70
+ display: flex;
71
+ flex-direction: column;
72
+ justify-content: center;
73
+ align-items: center;
74
+ min-height: var(--size-60);
75
+ color: var(--block-label-text-color);
76
+ line-height: var(--line-md);
77
+ height: 100%;
78
+ padding-top: var(--size-3);
79
+ text-align: center;
80
+ margin: auto var(--spacing-lg);
81
+ }
82
+
83
+ .or {
84
+ color: var(--body-text-color-subdued);
85
+ display: flex;
86
+ }
87
+
88
+ .icon-wrap {
89
+ width: 30px;
90
+ margin-bottom: var(--spacing-lg);
91
+ }
92
+
93
+ @media (--screen-md) {
94
+ .wrap {
95
+ font-size: var(--text-lg);
96
+ }
97
+ }
98
+
99
+ .hovered {
100
+ color: var(--color-accent);
101
+ }
102
+ </style>
6.5.0/atoms/src/index.ts ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export { default as Block } from "./Block.svelte";
2
+ export { default as BlockTitle } from "./BlockTitle.svelte";
3
+ export { default as BlockLabel } from "./BlockLabel.svelte";
4
+ export { default as DownloadLink } from "./DownloadLink.svelte";
5
+ export { default as IconButton } from "./IconButton.svelte";
6
+ export { default as Empty } from "./Empty.svelte";
7
+ export { default as Info } from "./Info.svelte";
8
+ export { default as ShareButton } from "./ShareButton.svelte";
9
+ export { default as UploadText } from "./UploadText.svelte";
10
+ export { default as Toolbar } from "./Toolbar.svelte";
11
+ export { default as SelectSource } from "./SelectSource.svelte";
12
+ export { default as IconButtonWrapper } from "./IconButtonWrapper.svelte";
13
+ export { default as FullscreenButton } from "./FullscreenButton.svelte";
14
+ export { default as CustomButton } from "./CustomButton.svelte";
15
+ export { default as ScrollFade } from "./ScrollFade.svelte";
16
+
17
+ export const BLOCK_KEY = {};
6.5.0/atoms/src/utils/parse_placeholder.ts ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const RE_HEADING = /^(#\s*)(.+)$/m;
2
+
3
+ export function inject(text: string): [string | false, string | false] {
4
+ const trimmed_text = text.trim();
5
+
6
+ const heading_match = trimmed_text.match(RE_HEADING);
7
+ if (!heading_match) {
8
+ return [false, trimmed_text || false];
9
+ }
10
+
11
+ const [full_match, , heading_content] = heading_match;
12
+ const _heading = heading_content.trim();
13
+
14
+ if (trimmed_text === full_match) {
15
+ return [_heading, false];
16
+ }
17
+
18
+ const heading_end_index =
19
+ heading_match.index !== undefined
20
+ ? heading_match.index + full_match.length
21
+ : 0;
22
+ const remaining_text = trimmed_text.substring(heading_end_index).trim();
23
+
24
+ const _paragraph = remaining_text || false;
25
+
26
+ return [_heading, _paragraph];
27
+ }