gradio-pr-bot commited on
Commit
c0545e9
·
verified ·
1 Parent(s): cae151e

Upload folder using huggingface_hub

Browse files
6.0.0-dev.5/sketchbox/Index.svelte ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import type { Gradio, SelectData } from "@gradio/utils";
3
+
4
+ export let row: boolean;
5
+ export let is_container: boolean;
6
+ export let component_type: string;
7
+ export let var_name: string;
8
+ export let active = false;
9
+ export let function_mode = false;
10
+ export let event_list: string[];
11
+ export let is_input = false;
12
+ export let is_output = false;
13
+ export let triggers: string[] = [];
14
+ $: is_function = component_type === "function";
15
+
16
+ export let gradio: Gradio<{
17
+ select: SelectData;
18
+ }>;
19
+
20
+ const dispatch = (type: string) => {
21
+ return (event: MouseEvent) => {
22
+ event.stopPropagation();
23
+ gradio.dispatch("select", { index: 0, value: type });
24
+ };
25
+ };
26
+
27
+ const invisible_components = ["state", "browserstate", "function"];
28
+ </script>
29
+
30
+ <div class="sketchbox" class:function_mode class:row class:active>
31
+ <div class="cover"></div>
32
+ <!-- svelte-ignore a11y-click-events-have-key-events -->
33
+ <!-- svelte-ignore a11y-no-static-element-interactions -->
34
+ <div
35
+ class="interaction"
36
+ on:click={is_container ? undefined : dispatch("modify")}
37
+ >
38
+ {#if invisible_components.includes(component_type)}
39
+ <div class="component-name">
40
+ <span>{component_type}:</span>&nbsp;{var_name}
41
+ </div>
42
+ {/if}
43
+ {#if function_mode}
44
+ {#if !is_function && !is_container}
45
+ <div class="button-set">
46
+ <button
47
+ class="function input"
48
+ on:click={dispatch("input")}
49
+ class:selected={is_input}>input</button
50
+ >
51
+ <button
52
+ class="function output"
53
+ on:click={dispatch("output")}
54
+ class:selected={is_output}>output</button
55
+ >
56
+ | {#each event_list as event}
57
+ <button
58
+ class="function event"
59
+ on:click={dispatch("on:" + event)}
60
+ class:selected={triggers.includes(event)}>on:{event}</button
61
+ >
62
+ {/each}
63
+ </div>
64
+ {/if}
65
+ {:else}
66
+ <button class="add up" on:click={dispatch("up")}>+</button>
67
+ <button class="add left" on:click={dispatch("left")}>+</button>
68
+ <button class="add right" on:click={dispatch("right")}>+</button>
69
+ <button class="add down" on:click={dispatch("down")}>+</button>
70
+ {#if !is_container}
71
+ <button class="action modify" on:click={dispatch("modify")}>✎</button>
72
+ <button class="action delete" on:click={dispatch("delete")}>✗</button>
73
+ {/if}
74
+ {/if}
75
+ </div>
76
+ <slot />
77
+ </div>
78
+
79
+ <style>
80
+ .sketchbox {
81
+ position: inherit;
82
+ display: flex;
83
+ flex-direction: inherit;
84
+ align-items: inherit;
85
+ min-height: 32px;
86
+ }
87
+ .sketchbox:not(.function_mode) {
88
+ cursor: pointer;
89
+ }
90
+ .function_mode .cover {
91
+ background-color: color-mix(
92
+ in srgb,
93
+ var(--background-fill-primary),
94
+ transparent 80%
95
+ );
96
+ }
97
+
98
+ .row > :global(*),
99
+ .row > :global(.form),
100
+ .row > :global(.form > *) {
101
+ flex-grow: 1 !important;
102
+ }
103
+ .interaction {
104
+ position: absolute;
105
+ top: 0;
106
+ left: 0;
107
+ width: 100%;
108
+ height: 100%;
109
+ z-index: 100;
110
+ }
111
+ .cover {
112
+ position: absolute;
113
+ top: 0;
114
+ left: 0;
115
+ width: 100%;
116
+ height: 100%;
117
+ z-index: 99;
118
+ }
119
+ .interaction:hover,
120
+ .active .interaction {
121
+ border-color: var(--body-text-color);
122
+ border-width: 1px;
123
+ border-radius: var(--block-radius);
124
+ }
125
+ .active.function_mode .interaction {
126
+ border-color: var(--color-accent);
127
+ border-width: 2px;
128
+ }
129
+ .interaction:hover .add,
130
+ .interaction:hover .action {
131
+ display: flex;
132
+ }
133
+ button {
134
+ border-color: var(--body-text-color);
135
+ border-width: 1px;
136
+ background-color: var(--button-secondary-background-fill);
137
+ justify-content: center;
138
+ align-items: center;
139
+ font-weight: bold;
140
+ }
141
+ .add,
142
+ .action {
143
+ display: none;
144
+ position: absolute;
145
+ }
146
+ .action {
147
+ border-radius: 15px;
148
+ width: 30px;
149
+ height: 30px;
150
+ }
151
+ .add {
152
+ border-radius: 10px;
153
+ width: 20px;
154
+ height: 20px;
155
+ }
156
+ .function {
157
+ border-radius: 15px;
158
+ padding: 4px 8px;
159
+ font-size: 10px;
160
+ }
161
+ .function.selected {
162
+ color: white;
163
+ }
164
+ .input.selected {
165
+ background-color: oklch(0.707 0.165 254.624);
166
+ border-color: oklch(0.707 0.165 254.624);
167
+ }
168
+ .output.selected {
169
+ background-color: oklch(0.712 0.194 13.428);
170
+ border-color: oklch(0.712 0.194 13.428);
171
+ }
172
+ .event.selected {
173
+ background-color: oklch(0.702 0.183 293.541);
174
+ border-color: oklch(0.702 0.183 293.541);
175
+ }
176
+ button:hover {
177
+ background-color: var(--button-secondary-background-fill-hover);
178
+ }
179
+ .up {
180
+ top: -10px;
181
+ left: 50%;
182
+ transform: translate(-50%, 0);
183
+ width: 80%;
184
+ }
185
+ .left {
186
+ top: 50%;
187
+ left: -10px;
188
+ transform: translate(0, -50%);
189
+ height: 80%;
190
+ }
191
+ .right {
192
+ top: 50%;
193
+ right: -10px;
194
+ transform: translate(0, -50%);
195
+ height: 80%;
196
+ }
197
+ .down {
198
+ bottom: -10px;
199
+ left: 50%;
200
+ transform: translate(-50%, 0);
201
+ width: 80%;
202
+ }
203
+ .modify {
204
+ top: 50%;
205
+ left: 50%;
206
+ transform: translate(calc(-50% - 20px), -50%);
207
+ }
208
+ .delete {
209
+ top: 50%;
210
+ left: 50%;
211
+ transform: translate(calc(-50% + 20px), -50%);
212
+ }
213
+ .button-set {
214
+ display: flex;
215
+ gap: 8px;
216
+ justify-content: center;
217
+ align-items: center;
218
+ height: 100%;
219
+ flex-wrap: wrap;
220
+ padding: 0 30px;
221
+ }
222
+ .component-name {
223
+ background: var(--block-background-fill);
224
+ border: var(--block-border-color) var(--block-border-width) solid;
225
+ border-radius: var(--block-radius);
226
+ height: 100%;
227
+ display: flex;
228
+ align-items: center;
229
+ justify-content: center;
230
+ }
231
+ .component-name span {
232
+ color: var(--body-text-color-subdued);
233
+ font-style: italic;
234
+ }
235
+ </style>
6.0.0-dev.5/sketchbox/package.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@gradio/sketchbox",
3
+ "version": "0.6.18-dev.0",
4
+ "description": "Gradio UI packages",
5
+ "type": "module",
6
+ "author": "",
7
+ "license": "ISC",
8
+ "main_changeset": true,
9
+ "dependencies": {
10
+ "@gradio/atoms": "workspace:^",
11
+ "@gradio/column": "workspace:^",
12
+ "@gradio/statustracker": "workspace:^",
13
+ "@gradio/utils": "workspace:^"
14
+ },
15
+ "peerDependencies": {
16
+ "svelte": "^5.43.4"
17
+ },
18
+ "devDependencies": {
19
+ "@gradio/preview": "workspace:^"
20
+ },
21
+ "exports": {
22
+ ".": {
23
+ "gradio": "./Index.svelte",
24
+ "svelte": "./dist/Index.svelte",
25
+ "types": "./dist/Index.svelte.d.ts"
26
+ },
27
+ "./package.json": "./package.json"
28
+ },
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git+https://github.com/gradio-app/gradio.git",
32
+ "directory": "js/sketchbox"
33
+ }
34
+ }