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

Upload folder using huggingface_hub

Browse files
6.0.2/atoms/package.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@gradio/atoms",
3
+ "version": "0.19.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.43.4"
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.0.2/atoms/src/Block.svelte ADDED
@@ -0,0 +1,253 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ let old_fullscreen = fullscreen;
25
+
26
+ let element: HTMLElement;
27
+
28
+ let tag = type === "fieldset" ? "fieldset" : "div";
29
+
30
+ let placeholder_height = 0;
31
+ let placeholder_width = 0;
32
+ let preexpansionBoundingRect: DOMRect | null = null;
33
+
34
+ function handleKeydown(event: KeyboardEvent): void {
35
+ if (fullscreen && event.key === "Escape") {
36
+ fullscreen = false;
37
+ }
38
+ }
39
+
40
+ $: if (fullscreen !== old_fullscreen) {
41
+ old_fullscreen = fullscreen;
42
+ if (fullscreen) {
43
+ preexpansionBoundingRect = element.getBoundingClientRect();
44
+ placeholder_height = element.offsetHeight;
45
+ placeholder_width = element.offsetWidth;
46
+ window.addEventListener("keydown", handleKeydown);
47
+ } else {
48
+ preexpansionBoundingRect = null;
49
+ window.removeEventListener("keydown", handleKeydown);
50
+ }
51
+ }
52
+
53
+ const get_dimension = (
54
+ dimension_value: string | number | undefined
55
+ ): string | undefined => {
56
+ if (dimension_value === undefined) {
57
+ return undefined;
58
+ }
59
+ if (typeof dimension_value === "number") {
60
+ return dimension_value + "px";
61
+ } else if (typeof dimension_value === "string") {
62
+ return dimension_value;
63
+ }
64
+ };
65
+
66
+ $: if (!visible) {
67
+ flex = false;
68
+ }
69
+
70
+ const resize = (e: MouseEvent): void => {
71
+ let prevY = e.clientY;
72
+ const onMouseMove = (e: MouseEvent): void => {
73
+ const dy: number = e.clientY - prevY;
74
+ prevY = e.clientY;
75
+ element.style.height = `${element.offsetHeight + dy}px`;
76
+ };
77
+ const onMouseUp = (): void => {
78
+ window.removeEventListener("mousemove", onMouseMove);
79
+ window.removeEventListener("mouseup", onMouseUp);
80
+ };
81
+ window.addEventListener("mousemove", onMouseMove);
82
+ window.addEventListener("mouseup", onMouseUp);
83
+ };
84
+ // When visible is False, we need to remove the component from the page
85
+ // We can remove it by either modifying the AppTree in Blocks or by hiding the component here
86
+ // We do it here because if visible is updated via an event, only the local state will be updated
87
+ // and we would have to flow the state back up to modify the AppTree
88
+ </script>
89
+
90
+ {#if visible === true || visible === "hidden"}
91
+ <svelte:element
92
+ this={tag}
93
+ bind:this={element}
94
+ data-testid={test_id}
95
+ id={elem_id}
96
+ class:hidden={visible === "hidden"}
97
+ class="block {elem_classes?.join(' ') || ''}"
98
+ class:padded={padding}
99
+ class:flex
100
+ class:border_focus={border_mode === "focus"}
101
+ class:border_contrast={border_mode === "contrast"}
102
+ class:hide-container={!explicit_call && !container}
103
+ style:height={fullscreen ? undefined : get_dimension(height)}
104
+ style:min-height={fullscreen ? undefined : get_dimension(min_height)}
105
+ style:max-height={fullscreen ? undefined : get_dimension(max_height)}
106
+ class:fullscreen
107
+ class:animating={fullscreen && preexpansionBoundingRect !== null}
108
+ style:--start-top={preexpansionBoundingRect
109
+ ? `${preexpansionBoundingRect.top}px`
110
+ : "0px"}
111
+ style:--start-left={preexpansionBoundingRect
112
+ ? `${preexpansionBoundingRect.left}px`
113
+ : "0px"}
114
+ style:--start-width={preexpansionBoundingRect
115
+ ? `${preexpansionBoundingRect.width}px`
116
+ : "0px"}
117
+ style:--start-height={preexpansionBoundingRect
118
+ ? `${preexpansionBoundingRect.height}px`
119
+ : "0px"}
120
+ style:width={fullscreen
121
+ ? undefined
122
+ : typeof width === "number"
123
+ ? `calc(min(${width}px, 100%))`
124
+ : get_dimension(width)}
125
+ style:border-style={variant}
126
+ style:overflow={allow_overflow ? overflow_behavior : "hidden"}
127
+ style:flex-grow={scale}
128
+ style:min-width={`calc(min(${min_width}px, 100%))`}
129
+ style:border-width="var(--block-border-width)"
130
+ class:auto-margin={scale === null}
131
+ dir={rtl ? "rtl" : "ltr"}
132
+ >
133
+ <slot />
134
+ {#if resizable}
135
+ <!-- svelte-ignore a11y-no-static-element-interactions -->
136
+ <svg
137
+ class="resize-handle"
138
+ xmlns="http://www.w3.org/2000/svg"
139
+ viewBox="0 0 10 10"
140
+ on:mousedown={resize}
141
+ >
142
+ <line x1="1" y1="9" x2="9" y2="1" stroke="gray" stroke-width="0.5" />
143
+ <line x1="5" y1="9" x2="9" y2="5" stroke="gray" stroke-width="0.5" />
144
+ </svg>
145
+ {/if}
146
+ </svelte:element>
147
+ {#if fullscreen}
148
+ <div
149
+ class="placeholder"
150
+ style:height={placeholder_height + "px"}
151
+ style:width={placeholder_width + "px"}
152
+ ></div>
153
+ {/if}
154
+ {/if}
155
+
156
+ <style>
157
+ .block {
158
+ position: relative;
159
+ margin: 0;
160
+ box-shadow: var(--block-shadow);
161
+ border-width: var(--block-border-width);
162
+ border-color: var(--block-border-color);
163
+ border-radius: var(--block-radius);
164
+ background: var(--block-background-fill);
165
+ width: 100%;
166
+ line-height: var(--line-sm);
167
+ }
168
+ .block.fullscreen {
169
+ border-radius: 0;
170
+ }
171
+
172
+ .auto-margin {
173
+ margin-left: auto;
174
+ margin-right: auto;
175
+ }
176
+
177
+ .block.border_focus {
178
+ border-color: var(--color-accent);
179
+ }
180
+
181
+ .block.border_contrast {
182
+ border-color: var(--body-text-color);
183
+ }
184
+
185
+ .padded {
186
+ padding: var(--block-padding);
187
+ }
188
+
189
+ .hidden {
190
+ display: none;
191
+ }
192
+
193
+ .flex {
194
+ display: flex;
195
+ flex-direction: column;
196
+ }
197
+ .hide-container:not(.fullscreen) {
198
+ margin: 0;
199
+ box-shadow: none;
200
+ --block-border-width: 0;
201
+ background: transparent;
202
+ padding: 0;
203
+ overflow: visible;
204
+ }
205
+ .resize-handle {
206
+ position: absolute;
207
+ bottom: 0;
208
+ right: 0;
209
+ width: 10px;
210
+ height: 10px;
211
+ fill: var(--block-border-color);
212
+ cursor: nwse-resize;
213
+ }
214
+ .fullscreen {
215
+ position: fixed;
216
+ top: 0;
217
+ left: 0;
218
+ width: 100vw;
219
+ height: 100vh;
220
+ z-index: 1000;
221
+ overflow: auto;
222
+ }
223
+
224
+ .animating {
225
+ animation: pop-out 0.1s ease-out forwards;
226
+ }
227
+
228
+ @keyframes pop-out {
229
+ 0% {
230
+ position: fixed;
231
+ top: var(--start-top);
232
+ left: var(--start-left);
233
+ width: var(--start-width);
234
+ height: var(--start-height);
235
+ z-index: 100;
236
+ }
237
+ 100% {
238
+ position: fixed;
239
+ top: 0vh;
240
+ left: 0vw;
241
+ width: 100vw;
242
+ height: 100vh;
243
+ z-index: 1000;
244
+ }
245
+ }
246
+
247
+ .placeholder {
248
+ border-radius: var(--block-radius);
249
+ border-width: var(--block-border-width);
250
+ border-color: var(--block-border-color);
251
+ border-style: dashed;
252
+ }
253
+ </style>
6.0.2/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.0.2/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.0.2/atoms/src/DownloadLink.svelte ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import type { HTMLAnchorAttributes } from "svelte/elements";
3
+ import { createEventDispatcher } from "svelte";
4
+
5
+ interface DownloadLinkAttributes
6
+ extends Omit<HTMLAnchorAttributes, "target"> {
7
+ download: NonNullable<HTMLAnchorAttributes["download"]>;
8
+ }
9
+ type $$Props = DownloadLinkAttributes;
10
+
11
+ export let href: DownloadLinkAttributes["href"] = undefined;
12
+ export let download: DownloadLinkAttributes["download"];
13
+
14
+ const dispatch = createEventDispatcher();
15
+ </script>
16
+
17
+ <a
18
+ style:position="relative"
19
+ class="download-link"
20
+ {href}
21
+ target={typeof window !== "undefined" && window.__is_colab__
22
+ ? "_blank"
23
+ : null}
24
+ rel="noopener noreferrer"
25
+ {download}
26
+ {...$$restProps}
27
+ on:click={dispatch.bind(null, "click")}
28
+ >
29
+ <slot />
30
+ </a>
31
+
32
+ <style>
33
+ .unstyled-link {
34
+ all: unset;
35
+ cursor: pointer;
36
+ }
37
+ </style>
6.0.2/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.0.2/atoms/src/FullscreenButton.svelte ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { createEventDispatcher } from "svelte";
3
+ import { IconButton } from "@gradio/atoms";
4
+ import { Maximize, Minimize } from "@gradio/icons";
5
+
6
+ const dispatch = createEventDispatcher<{
7
+ fullscreen: boolean;
8
+ }>();
9
+
10
+ export let fullscreen;
11
+ </script>
12
+
13
+ {#if fullscreen}
14
+ <IconButton
15
+ Icon={Minimize}
16
+ label="Exit fullscreen mode"
17
+ on:click={() => dispatch("fullscreen", false)}
18
+ />
19
+ {:else}
20
+ <IconButton
21
+ Icon={Maximize}
22
+ label="Fullscreen"
23
+ on:click={() => dispatch("fullscreen", true)}
24
+ />
25
+ {/if}
6.0.2/atoms/src/IconButton.svelte ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { type Component } from "svelte";
3
+ export let Icon: Component;
4
+ export let label = "";
5
+ export let show_label = false;
6
+ export let pending = false;
7
+ export let size: "x-small" | "small" | "large" | "medium" = "small";
8
+ export let padded = true;
9
+ export let highlight = false;
10
+ export let disabled = false;
11
+ export let hasPopup = false;
12
+ export let color = "var(--block-label-text-color)";
13
+ export let transparent = false;
14
+ export let background = "var(--block-background-fill)";
15
+ export let border = "transparent";
16
+ $: _color = highlight ? "var(--color-accent)" : color;
17
+ </script>
18
+
19
+ <button
20
+ class="icon-button"
21
+ {disabled}
22
+ on:click
23
+ aria-label={label}
24
+ aria-haspopup={hasPopup}
25
+ title={label}
26
+ class:pending
27
+ class:padded
28
+ class:highlight
29
+ class:transparent
30
+ style:--border-color={border}
31
+ style:color={!disabled && _color ? _color : "var(--block-label-text-color)"}
32
+ style:--bg-color={!disabled ? background : "auto"}
33
+ >
34
+ {#if show_label}<span>{label}</span>{/if}
35
+ <div
36
+ class:x-small={size === "x-small"}
37
+ class:small={size === "small"}
38
+ class:large={size === "large"}
39
+ class:medium={size === "medium"}
40
+ >
41
+ <svelte:component this={Icon} />
42
+ <slot />
43
+ </div>
44
+ </button>
45
+
46
+ <style>
47
+ button {
48
+ display: flex;
49
+ justify-content: center;
50
+ align-items: center;
51
+ gap: 1px;
52
+ z-index: var(--layer-2);
53
+ border-radius: var(--radius-xs);
54
+ color: var(--block-label-text-color);
55
+ border: 1px solid var(--border-color);
56
+ padding: var(--spacing-xxs);
57
+ }
58
+
59
+ button:hover {
60
+ background-color: var(--background-fill-secondary);
61
+ }
62
+
63
+ button[disabled] {
64
+ opacity: 0.5;
65
+ box-shadow: none;
66
+ }
67
+
68
+ button[disabled]:hover {
69
+ cursor: not-allowed;
70
+ }
71
+
72
+ .padded {
73
+ background: var(--bg-color);
74
+ }
75
+
76
+ button:hover,
77
+ button.highlight {
78
+ cursor: pointer;
79
+ color: var(--color-accent);
80
+ }
81
+
82
+ .padded:hover {
83
+ color: var(--block-label-text-color);
84
+ }
85
+
86
+ span {
87
+ padding: 0px 1px;
88
+ font-size: 10px;
89
+ }
90
+
91
+ div {
92
+ display: flex;
93
+ align-items: center;
94
+ justify-content: center;
95
+ transition: filter 0.2s ease-in-out;
96
+ }
97
+
98
+ .x-small {
99
+ width: 10px;
100
+ height: 10px;
101
+ }
102
+
103
+ .small {
104
+ width: 14px;
105
+ height: 14px;
106
+ }
107
+
108
+ .medium {
109
+ width: 20px;
110
+ height: 20px;
111
+ }
112
+
113
+ .large {
114
+ width: 22px;
115
+ height: 22px;
116
+ }
117
+
118
+ .pending {
119
+ animation: flash 0.5s infinite;
120
+ }
121
+
122
+ @keyframes flash {
123
+ 0% {
124
+ opacity: 0.5;
125
+ }
126
+ 50% {
127
+ opacity: 1;
128
+ }
129
+ 100% {
130
+ opacity: 0.5;
131
+ }
132
+ }
133
+
134
+ .transparent {
135
+ background: transparent;
136
+ border: none;
137
+ box-shadow: none;
138
+ }
139
+ </style>
6.0.2/atoms/src/IconButtonWrapper.svelte ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script>
2
+ export let top_panel = true;
3
+ export let display_top_corner = false;
4
+ export let show_background = true;
5
+ </script>
6
+
7
+ <div
8
+ class={`icon-button-wrapper ${top_panel ? "top-panel" : ""} ${display_top_corner ? "display-top-corner" : "hide-top-corner"} ${!show_background ? "no-background" : ""}`}
9
+ >
10
+ <slot></slot>
11
+ </div>
12
+
13
+ <style>
14
+ .icon-button-wrapper {
15
+ display: flex;
16
+ flex-direction: row;
17
+ align-items: center;
18
+ justify-content: center;
19
+ z-index: var(--layer-2);
20
+ gap: var(--spacing-sm);
21
+ box-shadow: var(--shadow-drop);
22
+ border: 1px solid var(--border-color-primary);
23
+ background: var(--block-background-fill);
24
+ padding: var(--spacing-xxs);
25
+ }
26
+
27
+ .icon-button-wrapper.hide-top-corner {
28
+ border-top: none;
29
+ border-right: none;
30
+ border-radius: var(--block-label-right-radius);
31
+ }
32
+
33
+ .icon-button-wrapper.display-top-corner {
34
+ border-radius: var(--radius-sm) 0 0 var(--radius-sm);
35
+ top: var(--spacing-sm);
36
+ right: -1px;
37
+ }
38
+
39
+ .icon-button-wrapper:not(.top-panel) {
40
+ border: 1px solid var(--border-color-primary);
41
+ border-radius: var(--radius-sm);
42
+ }
43
+
44
+ .top-panel {
45
+ position: absolute;
46
+ top: var(--block-label-margin);
47
+ right: var(--block-label-margin);
48
+ margin: 0;
49
+ }
50
+
51
+ .icon-button-wrapper :global(button) {
52
+ margin: var(--spacing-xxs);
53
+ border-radius: var(--radius-xs);
54
+ position: relative;
55
+ }
56
+
57
+ .icon-button-wrapper :global(a.download-link:not(:last-child)),
58
+ .icon-button-wrapper :global(button:not(:last-child)) {
59
+ margin-right: var(--spacing-xxs);
60
+ }
61
+
62
+ .icon-button-wrapper
63
+ :global(a.download-link:not(:last-child):not(.no-border *)::after),
64
+ .icon-button-wrapper
65
+ :global(button:not(:last-child):not(.no-border *)::after) {
66
+ content: "";
67
+ position: absolute;
68
+ right: -4.5px;
69
+ top: 15%;
70
+ height: 70%;
71
+ width: 1px;
72
+ background-color: var(--border-color-primary);
73
+ }
74
+
75
+ .icon-button-wrapper :global(> *) {
76
+ height: 100%;
77
+ }
78
+
79
+ .icon-button-wrapper.no-background {
80
+ box-shadow: none;
81
+ border: none;
82
+ background: none;
83
+ padding: 0;
84
+ z-index: var(--layer-1);
85
+ }
86
+ </style>
6.0.2/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.0.2/atoms/src/SelectSource.svelte ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { Microphone, Upload, Webcam, ImagePaste } from "@gradio/icons";
3
+
4
+ type source_types = "upload" | "microphone" | "webcam" | "clipboard" | null;
5
+
6
+ export let sources: Partial<source_types>[];
7
+ export let active_source: Partial<source_types>;
8
+ export let handle_clear: () => void = () => {};
9
+ export let handle_select: (
10
+ source_type: Partial<source_types>
11
+ ) => void = () => {};
12
+
13
+ $: unique_sources = [...new Set(sources)];
14
+
15
+ async function handle_select_source(
16
+ source: Partial<source_types>
17
+ ): Promise<void> {
18
+ handle_clear();
19
+ active_source = source;
20
+ handle_select(source);
21
+ }
22
+ </script>
23
+
24
+ {#if unique_sources.length > 1}
25
+ <span class="source-selection" data-testid="source-select">
26
+ {#if sources.includes("upload")}
27
+ <button
28
+ class="icon"
29
+ class:selected={active_source === "upload" || !active_source}
30
+ aria-label="Upload file"
31
+ on:click={() => handle_select_source("upload")}><Upload /></button
32
+ >
33
+ {/if}
34
+
35
+ {#if sources.includes("microphone")}
36
+ <button
37
+ class="icon"
38
+ class:selected={active_source === "microphone"}
39
+ aria-label="Record audio"
40
+ on:click={() => handle_select_source("microphone")}
41
+ ><Microphone /></button
42
+ >
43
+ {/if}
44
+
45
+ {#if sources.includes("webcam")}
46
+ <button
47
+ class="icon"
48
+ class:selected={active_source === "webcam"}
49
+ aria-label="Capture from camera"
50
+ on:click={() => handle_select_source("webcam")}><Webcam /></button
51
+ >
52
+ {/if}
53
+ {#if sources.includes("clipboard")}
54
+ <button
55
+ class="icon"
56
+ class:selected={active_source === "clipboard"}
57
+ aria-label="Paste from clipboard"
58
+ on:click={() => handle_select_source("clipboard")}
59
+ ><ImagePaste /></button
60
+ >
61
+ {/if}
62
+ </span>
63
+ {/if}
64
+
65
+ <style>
66
+ .source-selection {
67
+ display: flex;
68
+ align-items: center;
69
+ justify-content: center;
70
+ border-top: 1px solid var(--border-color-primary);
71
+ width: 100%;
72
+ margin-left: auto;
73
+ margin-right: auto;
74
+ height: var(--size-10);
75
+ }
76
+
77
+ .icon {
78
+ width: 22px;
79
+ height: 22px;
80
+ margin: var(--spacing-lg) var(--spacing-xs);
81
+ padding: var(--spacing-xs);
82
+ color: var(--neutral-400);
83
+ border-radius: var(--radius-md);
84
+ }
85
+
86
+ .selected {
87
+ color: var(--color-accent);
88
+ }
89
+
90
+ .icon:hover,
91
+ .icon:focus {
92
+ color: var(--color-accent);
93
+ }
94
+ </style>
6.0.2/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
+ on:click={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.0.2/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.0.2/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.0.2/atoms/src/index.ts ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
15
+ export const BLOCK_KEY = {};
6.0.2/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
+ }