gradio-pr-bot commited on
Commit
7a6e3d3
·
verified ·
1 Parent(s): 480fa83

Upload folder using huggingface_hub

Browse files
5.49.1/checkboxgroup/Example.svelte ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ export let value: string[];
3
+ export let type: "gallery" | "table";
4
+ export let selected = false;
5
+ export let choices: [string, string | number][];
6
+
7
+ let names = value
8
+ .map(
9
+ (val) =>
10
+ (
11
+ choices.find((pair) => pair[1] === val) as
12
+ | [string, string | number]
13
+ | undefined
14
+ )?.[0]
15
+ )
16
+ .filter((name) => name !== undefined);
17
+ let names_string = names.join(", ");
18
+ </script>
19
+
20
+ <div
21
+ class:table={type === "table"}
22
+ class:gallery={type === "gallery"}
23
+ class:selected
24
+ >
25
+ {names_string}
26
+ </div>
27
+
28
+ <style>
29
+ .gallery {
30
+ padding: var(--size-1) var(--size-2);
31
+ }
32
+ </style>
5.49.1/checkboxgroup/Index.svelte ADDED
@@ -0,0 +1,290 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <svelte:options immutable={true} />
2
+
3
+ <script lang="ts">
4
+ import type { Gradio, SelectData } from "@gradio/utils";
5
+ import { Block, BlockTitle } from "@gradio/atoms";
6
+ import { StatusTracker } from "@gradio/statustracker";
7
+ import type { LoadingStatus } from "@gradio/statustracker";
8
+
9
+ export let gradio: Gradio<{
10
+ change: never;
11
+ select: SelectData;
12
+ input: never;
13
+ clear_status: LoadingStatus;
14
+ }>;
15
+ export let elem_id = "";
16
+ export let elem_classes: string[] = [];
17
+ export let visible: boolean | "hidden" = true;
18
+ export let value: (string | number)[] = [];
19
+ export let choices: [string, string | number][];
20
+ export let container = true;
21
+ export let scale: number | null = null;
22
+ export let min_width: number | undefined = undefined;
23
+ export let label = gradio.i18n("checkbox.checkbox_group");
24
+ export let info: string | undefined = undefined;
25
+ export let show_label = true;
26
+ export let show_select_all = false;
27
+
28
+ export let loading_status: LoadingStatus;
29
+ export let interactive = true;
30
+ export let old_value = value.slice();
31
+
32
+ function toggle_choice(choice: string | number): void {
33
+ if (value.includes(choice)) {
34
+ value = value.filter((v) => v !== choice);
35
+ } else {
36
+ value = [...value, choice];
37
+ }
38
+ gradio.dispatch("input");
39
+ }
40
+
41
+ function toggle_select_all(): void {
42
+ const all_values = choices.map(([, internal_value]) => internal_value);
43
+ if (value.length === all_values.length) {
44
+ value = [];
45
+ } else {
46
+ value = all_values.slice();
47
+ }
48
+ gradio.dispatch("input");
49
+ }
50
+
51
+ $: select_all_state = (() => {
52
+ const all_values = choices.map(([, internal_value]) => internal_value);
53
+ if (value.length === 0) return "unchecked";
54
+ if (value.length === all_values.length) return "checked";
55
+ return "indeterminate";
56
+ })();
57
+
58
+ $: disabled = !interactive;
59
+
60
+ $: if (JSON.stringify(old_value) !== JSON.stringify(value)) {
61
+ old_value = value;
62
+ gradio.dispatch("change");
63
+ }
64
+ </script>
65
+
66
+ <Block
67
+ {visible}
68
+ {elem_id}
69
+ {elem_classes}
70
+ type="fieldset"
71
+ {container}
72
+ {scale}
73
+ {min_width}
74
+ >
75
+ <StatusTracker
76
+ autoscroll={gradio.autoscroll}
77
+ i18n={gradio.i18n}
78
+ {...loading_status}
79
+ on:clear_status={() => gradio.dispatch("clear_status", loading_status)}
80
+ />
81
+ <BlockTitle
82
+ show_label={show_label || (show_select_all && interactive)}
83
+ {info}
84
+ >
85
+ {#if show_select_all && interactive}
86
+ <div class="select-all-container">
87
+ <label class="select-all-label">
88
+ <input
89
+ class="select-all-checkbox"
90
+ on:change={toggle_select_all}
91
+ checked={select_all_state === "checked"}
92
+ indeterminate={select_all_state === "indeterminate"}
93
+ type="checkbox"
94
+ title="Select/Deselect All"
95
+ />
96
+ </label>
97
+ <button type="button" class="label-text" on:click={toggle_select_all}>
98
+ {show_label ? label : "Select All"}
99
+ </button>
100
+ </div>
101
+ {:else if show_label}
102
+ {label}
103
+ {/if}
104
+ </BlockTitle>
105
+
106
+ <div class="wrap" data-testid="checkbox-group">
107
+ {#each choices as [display_value, internal_value], i}
108
+ <label class:disabled class:selected={value.includes(internal_value)}>
109
+ <input
110
+ {disabled}
111
+ on:change={() => toggle_choice(internal_value)}
112
+ on:input={(evt) =>
113
+ gradio.dispatch("select", {
114
+ index: i,
115
+ value: internal_value,
116
+ selected: evt.currentTarget.checked
117
+ })}
118
+ on:keydown={(event) => {
119
+ if (event.key === "Enter") {
120
+ toggle_choice(internal_value);
121
+ gradio.dispatch("select", {
122
+ index: i,
123
+ value: internal_value,
124
+ selected: !value.includes(internal_value)
125
+ });
126
+ }
127
+ }}
128
+ checked={value.includes(internal_value)}
129
+ type="checkbox"
130
+ name={internal_value?.toString()}
131
+ title={internal_value?.toString()}
132
+ />
133
+ <span class="ml-2">{display_value}</span>
134
+ </label>
135
+ {/each}
136
+ </div>
137
+ </Block>
138
+
139
+ <style>
140
+ .wrap {
141
+ display: flex;
142
+ flex-wrap: wrap;
143
+ gap: var(--checkbox-label-gap);
144
+ }
145
+ label {
146
+ display: flex;
147
+ align-items: center;
148
+ transition: var(--button-transition);
149
+ cursor: pointer;
150
+ box-shadow: var(--checkbox-label-shadow);
151
+ border: var(--checkbox-label-border-width) solid
152
+ var(--checkbox-label-border-color);
153
+ border-radius: var(--checkbox-border-radius);
154
+ background: var(--checkbox-label-background-fill);
155
+ padding: var(--checkbox-label-padding);
156
+ color: var(--checkbox-label-text-color);
157
+ font-weight: var(--checkbox-label-text-weight);
158
+ font-size: var(--checkbox-label-text-size);
159
+ line-height: var(--line-md);
160
+ }
161
+
162
+ label:hover {
163
+ background: var(--checkbox-label-background-fill-hover);
164
+ }
165
+ label:focus {
166
+ background: var(--checkbox-label-background-fill-focus);
167
+ }
168
+ label.selected {
169
+ background: var(--checkbox-label-background-fill-selected);
170
+ color: var(--checkbox-label-text-color-selected);
171
+ border-color: var(--checkbox-label-border-color-selected);
172
+ }
173
+
174
+ label > * + * {
175
+ margin-left: var(--size-2);
176
+ }
177
+
178
+ input {
179
+ --ring-color: transparent;
180
+ position: relative;
181
+ box-shadow: var(--checkbox-shadow);
182
+ border: var(--checkbox-border-width) solid var(--checkbox-border-color);
183
+ border-radius: var(--checkbox-border-radius);
184
+ background-color: var(--checkbox-background-color);
185
+ line-height: var(--line-sm);
186
+ }
187
+
188
+ input:checked,
189
+ input:checked:hover,
190
+ input:checked:focus {
191
+ border-color: var(--checkbox-border-color-selected);
192
+ background-image: var(--checkbox-check);
193
+ background-color: var(--checkbox-background-color-selected);
194
+ }
195
+
196
+ input:checked:focus {
197
+ border-color: var(--checkbox-border-color-focus);
198
+ background-image: var(--checkbox-check);
199
+ background-color: var(--checkbox-background-color-selected);
200
+ }
201
+
202
+ input:hover {
203
+ border-color: var(--checkbox-border-color-hover);
204
+ background-color: var(--checkbox-background-color-hover);
205
+ }
206
+
207
+ input:not(:checked):focus {
208
+ border-color: var(--checkbox-border-color-focus);
209
+ }
210
+
211
+ input[disabled],
212
+ .disabled {
213
+ cursor: not-allowed;
214
+ }
215
+
216
+ input:hover {
217
+ cursor: pointer;
218
+ }
219
+
220
+ .select-all-container {
221
+ display: flex;
222
+ align-items: center;
223
+ gap: var(--size-2);
224
+ }
225
+
226
+ .select-all-label {
227
+ display: flex;
228
+ align-items: center;
229
+ cursor: pointer;
230
+ margin: 0;
231
+ padding: 0;
232
+ background: none;
233
+ border: none;
234
+ box-shadow: none;
235
+ }
236
+
237
+ .select-all-checkbox {
238
+ --ring-color: transparent;
239
+ position: relative;
240
+ box-shadow: var(--checkbox-shadow);
241
+ border: var(--checkbox-border-width) solid var(--checkbox-border-color);
242
+ border-radius: var(--checkbox-border-radius);
243
+ background-color: var(--checkbox-background-color);
244
+ line-height: var(--line-sm);
245
+ margin: 0;
246
+ }
247
+
248
+ .select-all-checkbox:checked,
249
+ .select-all-checkbox:checked:hover,
250
+ .select-all-checkbox:checked:focus {
251
+ border-color: var(--checkbox-border-color-selected);
252
+ background-image: var(--checkbox-check);
253
+ background-color: var(--checkbox-background-color-selected);
254
+ }
255
+
256
+ .select-all-checkbox:indeterminate,
257
+ .select-all-checkbox:indeterminate:hover {
258
+ border-color: var(--checkbox-border-color-selected);
259
+ background-color: var(--checkbox-background-color-selected);
260
+ position: relative;
261
+ }
262
+
263
+ .select-all-checkbox:indeterminate::after {
264
+ content: "";
265
+ position: absolute;
266
+ left: 50%;
267
+ top: 50%;
268
+ transform: translate(-50%, -50%);
269
+ width: 60%;
270
+ height: 2px;
271
+ background-color: white;
272
+ }
273
+
274
+ .select-all-checkbox:not(:indeterminate):not(:checked):hover {
275
+ border-color: var(--checkbox-border-color-hover);
276
+ background-color: var(--checkbox-background-color-hover);
277
+ cursor: pointer;
278
+ }
279
+
280
+ .label-text {
281
+ margin: 0;
282
+ cursor: pointer;
283
+ background: none;
284
+ border: none;
285
+ padding: 0;
286
+ font: inherit;
287
+ color: inherit;
288
+ text-align: left;
289
+ }
290
+ </style>
5.49.1/checkboxgroup/package.json ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@gradio/checkboxgroup",
3
+ "version": "0.7.0",
4
+ "description": "Gradio UI packages",
5
+ "type": "module",
6
+ "author": "",
7
+ "license": "ISC",
8
+ "private": false,
9
+ "main_changeset": true,
10
+ "main": "./Index.svelte",
11
+ "exports": {
12
+ ".": {
13
+ "gradio": "./Index.svelte",
14
+ "svelte": "./dist/Index.svelte",
15
+ "types": "./dist/Index.svelte.d.ts"
16
+ },
17
+ "./example": {
18
+ "gradio": "./Example.svelte",
19
+ "svelte": "./dist/Example.svelte",
20
+ "types": "./dist/Example.svelte.d.ts"
21
+ },
22
+ "./package.json": "./package.json"
23
+ },
24
+ "dependencies": {
25
+ "@gradio/atoms": "workspace:^",
26
+ "@gradio/statustracker": "workspace:^",
27
+ "@gradio/utils": "workspace:^"
28
+ },
29
+ "devDependencies": {
30
+ "@gradio/preview": "workspace:^"
31
+ },
32
+ "peerDependencies": {
33
+ "svelte": "^4.0.0"
34
+ },
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git+https://github.com/gradio-app/gradio.git",
38
+ "directory": "js/checkboxgroup"
39
+ }
40
+ }