Upload folder using huggingface_hub
Browse files
6.8.1/dropdown/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "@gradio/dropdown",
|
| 3 |
-
"version": "0.11.
|
| 4 |
"description": "Gradio UI packages",
|
| 5 |
"type": "module",
|
| 6 |
"author": "",
|
|
|
|
| 1 |
{
|
| 2 |
"name": "@gradio/dropdown",
|
| 3 |
+
"version": "0.11.5",
|
| 4 |
"description": "Gradio UI packages",
|
| 5 |
"type": "module",
|
| 6 |
"author": "",
|
6.8.1/dropdown/shared/Dropdown.svelte
CHANGED
|
@@ -55,28 +55,29 @@
|
|
| 55 |
let show_options = $derived.by(() => {
|
| 56 |
return is_browser && filter_input === document.activeElement;
|
| 57 |
});
|
| 58 |
-
let choices_names
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
let
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
let [input_text, selected_index] = $derived.by(() => {
|
| 65 |
if (
|
| 66 |
value === undefined ||
|
| 67 |
value === null ||
|
| 68 |
(Array.isArray(value) && value.length === 0)
|
| 69 |
) {
|
| 70 |
-
|
|
|
|
| 71 |
} else if (choices_values.includes(value as string | number)) {
|
| 72 |
-
|
| 73 |
-
choices_names[choices_values.indexOf(value as string | number)]
|
| 74 |
-
|
| 75 |
-
];
|
| 76 |
} else if (allow_custom_value) {
|
| 77 |
-
|
|
|
|
| 78 |
} else {
|
| 79 |
-
|
|
|
|
| 80 |
}
|
| 81 |
});
|
| 82 |
// Use last_typed_value to track when the user has typed
|
|
@@ -88,6 +89,9 @@
|
|
| 88 |
// All of these are indices with respect to the choices array
|
| 89 |
let filtered_indices = $state(choices.map((_, i) => i));
|
| 90 |
let active_index: number | null = $state(null);
|
|
|
|
|
|
|
|
|
|
| 91 |
|
| 92 |
function handle_option_selected(index: any): void {
|
| 93 |
selected_index = parseInt(index);
|
|
@@ -227,7 +231,7 @@
|
|
| 227 |
{choices}
|
| 228 |
{filtered_indices}
|
| 229 |
{disabled}
|
| 230 |
-
|
| 231 |
{active_index}
|
| 232 |
onchange={handle_option_selected}
|
| 233 |
onload={() => (initialized = true)}
|
|
|
|
| 55 |
let show_options = $derived.by(() => {
|
| 56 |
return is_browser && filter_input === document.activeElement;
|
| 57 |
});
|
| 58 |
+
let choices_names = $derived(choices.map((c) => c[0]));
|
| 59 |
+
let choices_values = $derived(choices.map((c) => c[1]));
|
| 60 |
+
let input_text = $state("");
|
| 61 |
+
let selected_index: number | null = $state(null);
|
| 62 |
+
|
| 63 |
+
$effect(() => {
|
|
|
|
| 64 |
if (
|
| 65 |
value === undefined ||
|
| 66 |
value === null ||
|
| 67 |
(Array.isArray(value) && value.length === 0)
|
| 68 |
) {
|
| 69 |
+
input_text = "";
|
| 70 |
+
selected_index = null;
|
| 71 |
} else if (choices_values.includes(value as string | number)) {
|
| 72 |
+
input_text =
|
| 73 |
+
choices_names[choices_values.indexOf(value as string | number)];
|
| 74 |
+
selected_index = choices_values.indexOf(value as string | number);
|
|
|
|
| 75 |
} else if (allow_custom_value) {
|
| 76 |
+
input_text = value as string;
|
| 77 |
+
selected_index = null;
|
| 78 |
} else {
|
| 79 |
+
input_text = "";
|
| 80 |
+
selected_index = null;
|
| 81 |
}
|
| 82 |
});
|
| 83 |
// Use last_typed_value to track when the user has typed
|
|
|
|
| 89 |
// All of these are indices with respect to the choices array
|
| 90 |
let filtered_indices = $state(choices.map((_, i) => i));
|
| 91 |
let active_index: number | null = $state(null);
|
| 92 |
+
let selected_indices = $derived(
|
| 93 |
+
selected_index === null ? [] : [selected_index]
|
| 94 |
+
);
|
| 95 |
|
| 96 |
function handle_option_selected(index: any): void {
|
| 97 |
selected_index = parseInt(index);
|
|
|
|
| 231 |
{choices}
|
| 232 |
{filtered_indices}
|
| 233 |
{disabled}
|
| 234 |
+
{selected_indices}
|
| 235 |
{active_index}
|
| 236 |
onchange={handle_option_selected}
|
| 237 |
onload={() => (initialized = true)}
|