gradio-pr-bot commited on
Commit
29255b4
·
verified ·
1 Parent(s): e52f7dd

Upload folder using huggingface_hub

Browse files
5.49.1/atoms/package.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@gradio/atoms",
3
+ "version": "0.18.1",
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": "^4.0.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-pkg": "svelte-package --input=. --cwd=../../.config/"
33
+ }
34
+ }
5.49.1/atoms/src/Block.svelte ADDED
@@ -0,0 +1,247 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ </script>
85
+
86
+ <svelte:element
87
+ this={tag}
88
+ bind:this={element}
89
+ data-testid={test_id}
90
+ id={elem_id}
91
+ class:hidden={visible === false || visible === "hidden"}
92
+ class="block {elem_classes?.join(' ') || ''}"
93
+ class:padded={padding}
94
+ class:flex
95
+ class:border_focus={border_mode === "focus"}
96
+ class:border_contrast={border_mode === "contrast"}
97
+ class:hide-container={!explicit_call && !container}
98
+ style:height={fullscreen ? undefined : get_dimension(height)}
99
+ style:min-height={fullscreen ? undefined : get_dimension(min_height)}
100
+ style:max-height={fullscreen ? undefined : get_dimension(max_height)}
101
+ class:fullscreen
102
+ class:animating={fullscreen && preexpansionBoundingRect !== null}
103
+ style:--start-top={preexpansionBoundingRect
104
+ ? `${preexpansionBoundingRect.top}px`
105
+ : "0px"}
106
+ style:--start-left={preexpansionBoundingRect
107
+ ? `${preexpansionBoundingRect.left}px`
108
+ : "0px"}
109
+ style:--start-width={preexpansionBoundingRect
110
+ ? `${preexpansionBoundingRect.width}px`
111
+ : "0px"}
112
+ style:--start-height={preexpansionBoundingRect
113
+ ? `${preexpansionBoundingRect.height}px`
114
+ : "0px"}
115
+ style:width={fullscreen
116
+ ? undefined
117
+ : typeof width === "number"
118
+ ? `calc(min(${width}px, 100%))`
119
+ : get_dimension(width)}
120
+ style:border-style={variant}
121
+ style:overflow={allow_overflow ? overflow_behavior : "hidden"}
122
+ style:flex-grow={scale}
123
+ style:min-width={`calc(min(${min_width}px, 100%))`}
124
+ style:border-width="var(--block-border-width)"
125
+ class:auto-margin={scale === null}
126
+ dir={rtl ? "rtl" : "ltr"}
127
+ >
128
+ <slot />
129
+ {#if resizable}
130
+ <!-- svelte-ignore a11y-no-static-element-interactions -->
131
+ <svg
132
+ class="resize-handle"
133
+ xmlns="http://www.w3.org/2000/svg"
134
+ viewBox="0 0 10 10"
135
+ on:mousedown={resize}
136
+ >
137
+ <line x1="1" y1="9" x2="9" y2="1" stroke="gray" stroke-width="0.5" />
138
+ <line x1="5" y1="9" x2="9" y2="5" stroke="gray" stroke-width="0.5" />
139
+ </svg>
140
+ {/if}
141
+ </svelte:element>
142
+ {#if fullscreen}
143
+ <div
144
+ class="placeholder"
145
+ style:height={placeholder_height + "px"}
146
+ style:width={placeholder_width + "px"}
147
+ ></div>
148
+ {/if}
149
+
150
+ <style>
151
+ .block {
152
+ position: relative;
153
+ margin: 0;
154
+ box-shadow: var(--block-shadow);
155
+ border-width: var(--block-border-width);
156
+ border-color: var(--block-border-color);
157
+ border-radius: var(--block-radius);
158
+ background: var(--block-background-fill);
159
+ width: 100%;
160
+ line-height: var(--line-sm);
161
+ }
162
+ .block.fullscreen {
163
+ border-radius: 0;
164
+ }
165
+
166
+ .auto-margin {
167
+ margin-left: auto;
168
+ margin-right: auto;
169
+ }
170
+
171
+ .block.border_focus {
172
+ border-color: var(--color-accent);
173
+ }
174
+
175
+ .block.border_contrast {
176
+ border-color: var(--body-text-color);
177
+ }
178
+
179
+ .padded {
180
+ padding: var(--block-padding);
181
+ }
182
+
183
+ .hidden {
184
+ display: none;
185
+ }
186
+
187
+ .flex {
188
+ display: flex;
189
+ flex-direction: column;
190
+ }
191
+ .hide-container:not(.fullscreen) {
192
+ margin: 0;
193
+ box-shadow: none;
194
+ --block-border-width: 0;
195
+ background: transparent;
196
+ padding: 0;
197
+ overflow: visible;
198
+ }
199
+ .resize-handle {
200
+ position: absolute;
201
+ bottom: 0;
202
+ right: 0;
203
+ width: 10px;
204
+ height: 10px;
205
+ fill: var(--block-border-color);
206
+ cursor: nwse-resize;
207
+ }
208
+ .fullscreen {
209
+ position: fixed;
210
+ top: 0;
211
+ left: 0;
212
+ width: 100vw;
213
+ height: 100vh;
214
+ z-index: 1000;
215
+ overflow: auto;
216
+ }
217
+
218
+ .animating {
219
+ animation: pop-out 0.1s ease-out forwards;
220
+ }
221
+
222
+ @keyframes pop-out {
223
+ 0% {
224
+ position: fixed;
225
+ top: var(--start-top);
226
+ left: var(--start-left);
227
+ width: var(--start-width);
228
+ height: var(--start-height);
229
+ z-index: 100;
230
+ }
231
+ 100% {
232
+ position: fixed;
233
+ top: 0vh;
234
+ left: 0vw;
235
+ width: 100vw;
236
+ height: 100vh;
237
+ z-index: 1000;
238
+ }
239
+ }
240
+
241
+ .placeholder {
242
+ border-radius: var(--block-radius);
243
+ border-width: var(--block-border-width);
244
+ border-color: var(--block-border-color);
245
+ border-style: dashed;
246
+ }
247
+ </style>
5.49.1/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>
5.49.1/atoms/src/BlockTitle.svelte ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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:sr-only={!show_label}
10
+ class:hide={!show_label}
11
+ class:has-info={info != null}
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
+ </style>
5.49.1/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>
5.49.1/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>
5.49.1/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}
5.49.1/atoms/src/IconButton.svelte ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { type ComponentType } from "svelte";
3
+ export let Icon: ComponentType;
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>
5.49.1/atoms/src/IconButtonWrapper.svelte ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script>
2
+ export let top_panel = true;
3
+ export let display_top_corner = false;
4
+ </script>
5
+
6
+ <div
7
+ class={`icon-button-wrapper ${top_panel ? "top-panel" : ""} ${display_top_corner ? "display-top-corner" : "hide-top-corner"}`}
8
+ >
9
+ <slot></slot>
10
+ </div>
11
+
12
+ <style>
13
+ .icon-button-wrapper {
14
+ display: flex;
15
+ flex-direction: row;
16
+ align-items: center;
17
+ justify-content: center;
18
+ z-index: var(--layer-2);
19
+ gap: var(--spacing-sm);
20
+ box-shadow: var(--shadow-drop);
21
+ border: 1px solid var(--border-color-primary);
22
+ background: var(--block-background-fill);
23
+ padding: var(--spacing-xxs);
24
+ }
25
+
26
+ .icon-button-wrapper.hide-top-corner {
27
+ border-top: none;
28
+ border-right: none;
29
+ border-radius: var(--block-label-right-radius);
30
+ }
31
+
32
+ .icon-button-wrapper.display-top-corner {
33
+ border-radius: var(--radius-sm) 0 0 var(--radius-sm);
34
+ top: var(--spacing-sm);
35
+ right: -1px;
36
+ }
37
+
38
+ .icon-button-wrapper:not(.top-panel) {
39
+ border: 1px solid var(--border-color-primary);
40
+ border-radius: var(--radius-sm);
41
+ }
42
+
43
+ .top-panel {
44
+ position: absolute;
45
+ top: var(--block-label-margin);
46
+ right: var(--block-label-margin);
47
+ margin: 0;
48
+ }
49
+
50
+ .icon-button-wrapper :global(button) {
51
+ margin: var(--spacing-xxs);
52
+ border-radius: var(--radius-xs);
53
+ position: relative;
54
+ }
55
+
56
+ .icon-button-wrapper :global(a.download-link:not(:last-child)),
57
+ .icon-button-wrapper :global(button:not(:last-child)) {
58
+ margin-right: var(--spacing-xxs);
59
+ }
60
+
61
+ .icon-button-wrapper
62
+ :global(a.download-link:not(:last-child):not(.no-border *)::after),
63
+ .icon-button-wrapper
64
+ :global(button:not(:last-child):not(.no-border *)::after) {
65
+ content: "";
66
+ position: absolute;
67
+ right: -4.5px;
68
+ top: 15%;
69
+ height: 70%;
70
+ width: 1px;
71
+ background-color: var(--border-color-primary);
72
+ }
73
+
74
+ .icon-button-wrapper :global(> *) {
75
+ height: 100%;
76
+ }
77
+ </style>
5.49.1/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>
5.49.1/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>
5.49.1/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
+ />
5.49.1/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>
5.49.1/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>
5.49.1/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 = {};
5.49.1/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
+ }