Upload folder using huggingface_hub
Browse files
6.14.0/gallery/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "@gradio/gallery",
|
| 3 |
-
"version": "0.17.
|
| 4 |
"description": "Gradio UI packages",
|
| 5 |
"type": "module",
|
| 6 |
"author": "",
|
|
|
|
| 1 |
{
|
| 2 |
"name": "@gradio/gallery",
|
| 3 |
+
"version": "0.17.8",
|
| 4 |
"description": "Gradio UI packages",
|
| 5 |
"type": "module",
|
| 6 |
"author": "",
|
6.14.0/gallery/shared/Gallery.svelte
CHANGED
|
@@ -160,7 +160,6 @@
|
|
| 160 |
if (selected_index == null && preview && value?.length) {
|
| 161 |
selected_index = 0;
|
| 162 |
}
|
| 163 |
-
let old_selected_index: number | null = $state(selected_index);
|
| 164 |
|
| 165 |
$effect(() => {
|
| 166 |
if (!dequal(prev_value, value)) {
|
|
@@ -195,6 +194,15 @@
|
|
| 195 |
() => ((selected_index ?? 0) + 1) % (resolved_value?.length ?? 0)
|
| 196 |
);
|
| 197 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
function handle_preview_click(event: MouseEvent): void {
|
| 199 |
const element = event.target as HTMLElement;
|
| 200 |
const x = event.offsetX;
|
|
@@ -206,6 +214,7 @@
|
|
| 206 |
} else {
|
| 207 |
selected_index = next;
|
| 208 |
}
|
|
|
|
| 209 |
}
|
| 210 |
|
| 211 |
function on_keydown(e: KeyboardEvent): void {
|
|
@@ -218,32 +227,18 @@
|
|
| 218 |
case "ArrowLeft":
|
| 219 |
e.preventDefault();
|
| 220 |
selected_index = previous;
|
|
|
|
| 221 |
break;
|
| 222 |
case "ArrowRight":
|
| 223 |
e.preventDefault();
|
| 224 |
selected_index = next;
|
|
|
|
| 225 |
break;
|
| 226 |
default:
|
| 227 |
break;
|
| 228 |
}
|
| 229 |
}
|
| 230 |
|
| 231 |
-
$effect(() => {
|
| 232 |
-
// Only trigger the effect if the selected_index has actually changed
|
| 233 |
-
if (selected_index !== old_selected_index) {
|
| 234 |
-
old_selected_index = selected_index;
|
| 235 |
-
|
| 236 |
-
// Ensure we have a valid selection and data to work with
|
| 237 |
-
if (selected_index !== null && resolved_value !== null) {
|
| 238 |
-
// Notify the parent component or listener about the updated selection
|
| 239 |
-
onselect({
|
| 240 |
-
index: selected_index,
|
| 241 |
-
value: resolved_value?.[selected_index]
|
| 242 |
-
});
|
| 243 |
-
}
|
| 244 |
-
}
|
| 245 |
-
});
|
| 246 |
-
|
| 247 |
$effect(() => {
|
| 248 |
if (allow_preview && container_element) {
|
| 249 |
scroll_to_img(selected_index);
|
|
@@ -495,7 +490,10 @@
|
|
| 495 |
{#each resolved_value as media, i}
|
| 496 |
<button
|
| 497 |
bind:this={el[i]}
|
| 498 |
-
on:click={() =>
|
|
|
|
|
|
|
|
|
|
| 499 |
class="thumbnail-item thumbnail-small"
|
| 500 |
class:selected={selected_index === i && mode !== "minimal"}
|
| 501 |
aria-label={"Thumbnail " +
|
|
@@ -616,6 +614,7 @@
|
|
| 616 |
onpreview_open();
|
| 617 |
}
|
| 618 |
selected_index = i;
|
|
|
|
| 619 |
}}
|
| 620 |
aria-label={"Thumbnail " +
|
| 621 |
(i + 1) +
|
|
|
|
| 160 |
if (selected_index == null && preview && value?.length) {
|
| 161 |
selected_index = 0;
|
| 162 |
}
|
|
|
|
| 163 |
|
| 164 |
$effect(() => {
|
| 165 |
if (!dequal(prev_value, value)) {
|
|
|
|
| 194 |
() => ((selected_index ?? 0) + 1) % (resolved_value?.length ?? 0)
|
| 195 |
);
|
| 196 |
|
| 197 |
+
function dispatch_select(index: number): void {
|
| 198 |
+
if (resolved_value !== null) {
|
| 199 |
+
onselect({
|
| 200 |
+
index,
|
| 201 |
+
value: resolved_value?.[index]
|
| 202 |
+
});
|
| 203 |
+
}
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
function handle_preview_click(event: MouseEvent): void {
|
| 207 |
const element = event.target as HTMLElement;
|
| 208 |
const x = event.offsetX;
|
|
|
|
| 214 |
} else {
|
| 215 |
selected_index = next;
|
| 216 |
}
|
| 217 |
+
dispatch_select(selected_index);
|
| 218 |
}
|
| 219 |
|
| 220 |
function on_keydown(e: KeyboardEvent): void {
|
|
|
|
| 227 |
case "ArrowLeft":
|
| 228 |
e.preventDefault();
|
| 229 |
selected_index = previous;
|
| 230 |
+
dispatch_select(selected_index);
|
| 231 |
break;
|
| 232 |
case "ArrowRight":
|
| 233 |
e.preventDefault();
|
| 234 |
selected_index = next;
|
| 235 |
+
dispatch_select(selected_index);
|
| 236 |
break;
|
| 237 |
default:
|
| 238 |
break;
|
| 239 |
}
|
| 240 |
}
|
| 241 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 242 |
$effect(() => {
|
| 243 |
if (allow_preview && container_element) {
|
| 244 |
scroll_to_img(selected_index);
|
|
|
|
| 490 |
{#each resolved_value as media, i}
|
| 491 |
<button
|
| 492 |
bind:this={el[i]}
|
| 493 |
+
on:click={() => {
|
| 494 |
+
selected_index = i;
|
| 495 |
+
dispatch_select(i);
|
| 496 |
+
}}
|
| 497 |
class="thumbnail-item thumbnail-small"
|
| 498 |
class:selected={selected_index === i && mode !== "minimal"}
|
| 499 |
aria-label={"Thumbnail " +
|
|
|
|
| 614 |
onpreview_open();
|
| 615 |
}
|
| 616 |
selected_index = i;
|
| 617 |
+
dispatch_select(i);
|
| 618 |
}}
|
| 619 |
aria-label={"Thumbnail " +
|
| 620 |
(i + 1) +
|