1import { S as Static } from './Index-39333b6d.js'; 2import { b as fly, B as Block } from './Button-9166aeba.js'; 3import { B as BlockTitle } from './BlockTitle-f55769d0.js'; 4import { D as DropdownArrow } from './DropdownArrow-5d4e9f28.js'; 5export { default as BaseExample } from './Example-7b848c75.js'; 6import './index-85f5f7ca.js'; 7import './svelte/svelte.js'; 8import './Info-1c249d3c.js'; 9 10/* home/runner/work/gradio/gradio/js/icons/src/Remove.svelte generated by Svelte v4.2.2 */ 11const { 12 SvelteComponent: SvelteComponent$4, 13 append: append$3, 14 attr: attr$3, 15 detach: detach$4, 16 init: init$4, 17 insert: insert$4, 18 noop, 19 safe_not_equal: safe_not_equal$4, 20 svg_element 21} = window.__gradio__svelte__internal; 22function create_fragment$4(ctx) { 23 let svg; 24 let path; 25 26 return { 27 c() { 28 svg = svg_element("svg"); 29 path = svg_element("path"); 30 attr$3(path, "d", "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"); 31 attr$3(svg, "xmlns", "http://www.w3.org/2000/svg"); 32 attr$3(svg, "viewBox", "0 0 24 24"); 33 }, 34 m(target, anchor) { 35 insert$4(target, svg, anchor); 36 append$3(svg, path); 37 }, 38 p: noop, 39 i: noop, 40 o: noop, 41 d(detaching) { 42 if (detaching) { 43 detach$4(svg); 44 } 45 } 46 }; 47} 48 49class Remove extends SvelteComponent$4 { 50 constructor(options) { 51 super(); 52 init$4(this, options, null, create_fragment$4, safe_not_equal$4, {}); 53 } 54} 55 56const DropdownOptions_svelte_svelte_type_style_lang = ''; 57 58/* home/runner/work/gradio/gradio/js/dropdown/shared/DropdownOptions.svelte generated by Svelte v4.2.2 */ 59const { 60 SvelteComponent: SvelteComponent$3, 61 add_render_callback, 62 append: append$2, 63 attr: attr$2, 64 binding_callbacks: binding_callbacks$3, 65 check_outros: check_outros$3, 66 create_bidirectional_transition, 67 destroy_each: destroy_each$1, 68 detach: detach$3, 69 element: element$2, 70 empty: empty$1, 71 ensure_array_like: ensure_array_like$1, 72 group_outros: group_outros$3, 73 init: init$3, 74 insert: insert$3, 75 listen: listen$2, 76 prevent_default: prevent_default$1, 77 run_all: run_all$2, 78 safe_not_equal: safe_not_equal$3, 79 set_data: set_data$2, 80 set_style, 81 space: space$3, 82 text: text$2, 83 toggle_class: toggle_class$2, 84 transition_in: transition_in$3, 85 transition_out: transition_out$3 86} = window.__gradio__svelte__internal;const { createEventDispatcher: createEventDispatcher$2 } = window.__gradio__svelte__internal; 87function get_each_context$1(ctx, list, i) { 88 const child_ctx = ctx.slice(); 89 child_ctx[24] = list[i]; 90 return child_ctx; 91} 92 93// (68:0) {#if show_options && !disabled} 94function create_if_block$3(ctx) { 95 let ul; 96 let ul_transition; 97 let current; 98 let mounted; 99 let dispose; 100 let each_value = ensure_array_like$1(/*filtered_indices*/ ctx[1]); 101 let each_blocks = []; 102 103 for (let i = 0; i < each_value.length; i += 1) { 104 each_blocks[i] = create_each_block$1(get_each_context$1(ctx, each_value, i)); 105 } 106 107 return { 108 c() { 109 ul = element$2("ul"); 110 111 for (let i = 0; i < each_blocks.length; i += 1) { 112 each_blocks[i].c(); 113 } 114 115 attr$2(ul, "class", "options svelte-1aonegi"); 116 attr$2(ul, "role", "listbox"); 117 set_style(ul, "top", /*top*/ ctx[9]); 118 set_style(ul, "bottom", /*bottom*/ ctx[10]); 119 set_style(ul, "max-height", `calc(${/*max_height*/ ctx[11]}px - var(--window-padding))`); 120 set_style(ul, "width", /*input_width*/ ctx[8] + "px"); 121 }, 122 m(target, anchor) { 123 insert$3(target, ul, anchor); 124 125 for (let i = 0; i < each_blocks.length; i += 1) { 126 if (each_blocks[i]) { 127 each_blocks[i].m(ul, null); 128 } 129 } 130 131 /*ul_binding*/ ctx[21](ul); 132 current = true; 133 134 if (!mounted) { 135 dispose = listen$2(ul, "mousedown", prevent_default$1(/*mousedown_handler*/ ctx[20])); 136 mounted = true; 137 } 138 }, 139 p(ctx, dirty) { 140 if (dirty & /*filtered_indices, choices, selected_indices, active_index*/ 51) { 141 each_value = ensure_array_like$1(/*filtered_indices*/ ctx[1]); 142 let i; 143 144 for (i = 0; i < each_value.length; i += 1) { 145 const child_ctx = get_each_context$1(ctx, each_value, i); 146 147 if (each_blocks[i]) { 148 each_blocks[i].p(child_ctx, dirty); 149 } else { 150 each_blocks[i] = create_each_block$1(child_ctx); 151 each_blocks[i].c(); 152 each_blocks[i].m(ul, null); 153 } 154 } 155 156 for (; i < each_blocks.length; i += 1) { 157 each_blocks[i].d(1); 158 } 159 160 each_blocks.length = each_value.length; 161 } 162
163 if (dirty & /*top*/ 512) { 164 set_style(ul, "top", /*top*/ ctx[9]); 165 } 166 167 if (dirty & /*bottom*/ 1024) { 168 set_style(ul, "bottom", /*bottom*/ ctx[10]); 169 } 170 171 if (dirty & /*max_height*/ 2048) { 172 set_style(ul, "max-height", `calc(${/*max_height*/ ctx[11]}px - var(--window-padding))`); 173 } 174 175 if (dirty & /*input_width*/ 256) { 176 set_style(ul, "width", /*input_width*/ ctx[8] + "px"); 177 } 178 }, 179 i(local) { 180 if (current) return; 181 182 if (local) { 183 add_render_callback(() => { 184 if (!current) return; 185 if (!ul_transition) ul_transition = create_bidirectional_transition(ul, fly, { duration: 200, y: 5 }, true); 186 ul_transition.run(1); 187 }); 188 } 189 190 current = true; 191 }, 192 o(local) { 193 if (local) { 194 if (!ul_transition) ul_transition = create_bidirectional_transition(ul, fly, { duration: 200, y: 5 }, false); 195 ul_transition.run(0); 196 } 197 198 current = false; 199 }, 200 d(detaching) { 201 if (detaching) { 202 detach$3(ul); 203 } 204 205 destroy_each$1(each_blocks, detaching); 206 /*ul_binding*/ ctx[21](null); 207 if (detaching && ul_transition) ul_transition.end(); 208 mounted = false; 209 dispose(); 210 } 211 }; 212} 213 214// (80:2) {#each filtered_indices as index} 215function create_each_block$1(ctx) { 216 let li; 217 let span; 218 let t1; 219 let t2_value = /*choices*/ ctx[0][/*index*/ ctx[24]][0] + ""; 220 let t2; 221 let t3; 222 let li_data_index_value; 223 let li_aria_label_value; 224 let li_aria_selected_value; 225 226 return { 227 c() { 228 li = element$2("li"); 229 span = element$2("span"); 230 span.textContent = "â"; 231 t1 = space$3(); 232 t2 = text$2(t2_value); 233 t3 = space$3(); 234 attr$2(span, "class", "inner-item svelte-1aonegi"); 235 toggle_class$2(span, "hide", !/*selected_indices*/ ctx[4].includes(/*index*/ ctx[24])); 236 attr$2(li, "class", "item svelte-1aonegi"); 237 attr$2(li, "data-index", li_data_index_value = /*index*/ ctx[24]); 238 attr$2(li, "aria-label", li_aria_label_value = /*choices*/ ctx[0][/*index*/ ctx[24]][0]); 239 attr$2(li, "data-testid", "dropdown-option"); 240 attr$2(li, "role", "option"); 241 attr$2(li, "aria-selected", li_aria_selected_value = /*selected_indices*/ ctx[4].includes(/*index*/ ctx[24])); 242 toggle_class$2(li, "selected", /*selected_indices*/ ctx[4].includes(/*index*/ ctx[24])); 243 toggle_class$2(li, "active", /*index*/ ctx[24] === /*active_index*/ ctx[5]); 244 toggle_class$2(li, "bg-gray-100", /*index*/ ctx[24] === /*active_index*/ ctx[5]); 245 toggle_class$2(li, "dark:bg-gray-600", /*index*/ ctx[24] === /*active_index*/ ctx[5]); 246 }, 247 m(target, anchor) { 248 insert$3(target, li, anchor); 249 append$2(li, span); 250 append$2(li, t1); 251 append$2(li, t2); 252 append$2(li, t3); 253 }, 254 p(ctx, dirty) { 255 if (dirty & /*selected_indices, filtered_indices*/ 18) { 256 toggle_class$2(span, "hide", !/*selected_indices*/ ctx[4].includes(/*index*/ ctx[24])); 257 } 258 259 if (dirty & /*choices, filtered_indices*/ 3 && t2_value !== (t2_value = /*choices*/ ctx[0][/*index*/ ctx[24]][0] + "")) set_data$2(t2, t2_value); 260 261 if (dirty & /*filtered_indices*/ 2 && li_data_index_value !== (li_data_index_value = /*index*/ ctx[24])) { 262 attr$2(li, "data-index", li_data_index_value); 263 } 264 265 if (dirty & /*choices, filtered_indices*/ 3 && li_aria_label_value !== (li_aria_label_value = /*choices*/ ctx[0][/*index*/ ctx[24]][0])) { 266 attr$2(li, "aria-label", li_aria_label_value); 267 } 268 269 if (dirty & /*selected_indices, filtered_indices*/ 18 && li_aria_selected_value !== (li_aria_selected_value = /*selected_indices*/ ctx[4].includes(/*index*/ ctx[24]))) { 270 attr$2(li, "aria-selected", li_aria_selected_value); 271 } 272 273 if (dirty & /*selected_indices, filtered_indices*/ 18) { 274 toggle_class$2(li, "selected", /*selected_indices*/ ctx[4].includes(/*index*/ ctx[24])); 275 } 276 277 if (dirty & /*filtered_indices, active_index*/ 34) { 278 toggle_class$2(li, "active", /*index*/ ctx[24] === /*active_index*/ ctx[5]); 279 } 280 281 if (dirty & /*filtered_indices, active_index*/ 34) { 282 toggle_class$2(li, "bg-gray-100", /*index*/ ctx[24] === /*active_index*/ ctx[5]); 283 } 284 285 if (dirty & /*filtered_indices, active_index*/ 34) { 286 toggle_class$2(li, "dark:bg-gray-600", /*index*/ ctx[24] === /*active_index*/ ctx[5]); 287 } 288 }, 289 d(detaching) { 290 if (detaching) { 291 detach$3(li); 292 } 293 } 294 }; 295} 296 297function create_fragment$3(ctx) { 298 let div; 299 let t; 300 let if_block_anchor; 301 let mounted; 302 let dispose; 303 add_render_callback(/*onwindowresize*/ ctx[18]); 304 let if_block = /*show_options*/ ctx[2] && !/*disabled*/ ctx[3] && create_if_block$3(ctx); 305 306 return { 307 c() { 308 div = element$2("div"); 309 t = space$3(); 310 if (if_block) if_block.c(); 311 if_block_anchor = empty$1(); 312 attr$2(div, "class", "reference"); 313 }, 314 m(target, anchor) { 315 insert$3(target, div, anchor); 316 /*div_binding*/ ctx[19](div); 317 insert$3(target, t, anchor); 318 if (if_block) if_block.m(target, anchor); 319 insert$3(target, if_block_anchor, anchor); 320 321 if (!mounted) { 322 dispose = [ 323 listen$2(window, "scroll", /*scroll_listener*/ ctx[13]), 324 listen$2(window, "resize", /*onwindowresize*/ ctx[18]) 325 ]; 326 327 mounted = true; 328 } 329 }, 330 p(ctx, [dirty]) { 331 if (/*show_options*/ ctx[2] && !/*disabled*/ ctx[3]) { 332 if (if_block) { 333 if_block.p(ctx, dirty); 334
335 if (dirty & /*show_options, disabled*/ 12) { 336 transition_in$3(if_block, 1); 337 } 338 } else { 339 if_block = create_if_block$3(ctx); 340 if_block.c(); 341 transition_in$3(if_block, 1); 342 if_block.m(if_block_anchor.parentNode, if_block_anchor); 343 } 344 } else if (if_block) { 345 group_outros$3(); 346 347 transition_out$3(if_block, 1, 1, () => { 348 if_block = null; 349 }); 350 351 check_outros$3(); 352 } 353 }, 354 i(local) { 355 transition_in$3(if_block); 356 }, 357 o(local) { 358 transition_out$3(if_block); 359 }, 360 d(detaching) { 361 if (detaching) { 362 detach$3(div); 363 detach$3(t); 364 detach$3(if_block_anchor); 365 } 366 367 /*div_binding*/ ctx[19](null); 368 if (if_block) if_block.d(detaching); 369 mounted = false; 370 run_all$2(dispose); 371 } 372 }; 373} 374 375function instance$3($$self, $$props, $$invalidate) { 376 let { choices } = $$props; 377 let { filtered_indices } = $$props; 378 let { show_options = false } = $$props; 379 let { disabled = false } = $$props; 380 let { selected_indices = [] } = $$props; 381 let { active_index = null } = $$props; 382 let distance_from_top; 383 let distance_from_bottom; 384 let input_height; 385 let input_width; 386 let refElement; 387 let listElement; 388 let top, bottom, max_height; 389 let innerHeight; 390 391 function calculate_window_distance() { 392 const { top: ref_top, bottom: ref_bottom } = refElement.getBoundingClientRect(); 393 $$invalidate(15, distance_from_top = ref_top); 394 $$invalidate(16, distance_from_bottom = innerHeight - ref_bottom); 395 } 396 397 let scroll_timeout = null; 398 399 function scroll_listener() { 400 if (!show_options) return; 401 402 if (scroll_timeout !== null) { 403 clearTimeout(scroll_timeout); 404 } 405 406 scroll_timeout = setTimeout( 407 () => { 408 calculate_window_distance(); 409 scroll_timeout = null; 410 }, 411 10 412 ); 413 } 414 415 const dispatch = createEventDispatcher$2(); 416 417 function onwindowresize() { 418 $$invalidate(12, innerHeight = window.innerHeight); 419 } 420 421 function div_binding($$value) { 422 binding_callbacks$3[$$value ? 'unshift' : 'push'](() => { 423 refElement = $$value; 424 $$invalidate(6, refElement); 425 }); 426 } 427 428 const mousedown_handler = e => dispatch("change", e); 429 430 function ul_binding($$value) { 431 binding_callbacks$3[$$value ? 'unshift' : 'push'](() => { 432 listElement = $$value; 433 $$invalidate(7, listElement); 434 }); 435 } 436 437 $$self.$$set = $$props => {
438 if ('choices' in $$props) $$invalidate(0, choices = $$props.choices); 439 if ('filtered_indices' in $$props) $$invalidate(1, filtered_indices = $$props.filtered_indices); 440 if ('show_options' in $$props) $$invalidate(2, show_options = $$props.show_options); 441 if ('disabled' in $$props) $$invalidate(3, disabled = $$props.disabled); 442 if ('selected_indices' in $$props) $$invalidate(4, selected_indices = $$props.selected_indices); 443 if ('active_index' in $$props) $$invalidate(5, active_index = $$props.active_index); 444 }; 445 446 $$self.$$.update = () => { 447 if ($$self.$$.dirty & /*show_options, refElement, listElement, selected_indices, distance_from_bottom, distance_from_top, input_height*/ 229588) { 448 { 449 if (show_options && refElement) { 450 if (listElement && selected_indices.length > 0) { 451 let elements = listElement.querySelectorAll("li"); 452 453 for (const element of Array.from(elements)) { 454 if (element.getAttribute("data-index") === selected_indices[0].toString()) { 455 listElement?.scrollTo?.(0, element.offsetTop); 456 break; 457 } 458 } 459 } 460 461 calculate_window_distance(); 462 const rect = refElement.parentElement?.getBoundingClientRect(); 463 $$invalidate(17, input_height = rect?.height || 0); 464 $$invalidate(8, input_width = rect?.width || 0); 465 } 466 467 if (distance_from_bottom > distance_from_top) { 468 $$invalidate(9, top = `${distance_from_top}px`); 469 $$invalidate(11, max_height = distance_from_bottom); 470 $$invalidate(10, bottom = null); 471 } else { 472 $$invalidate(10, bottom = `${distance_from_bottom + input_height}px`); 473 $$invalidate(11, max_height = distance_from_top - input_height); 474 $$invalidate(9, top = null); 475 } 476 } 477 } 478 }; 479 480 return [ 481 choices, 482 filtered_indices, 483 show_options, 484 disabled, 485 selected_indices, 486 active_index, 487 refElement, 488 listElement, 489 input_width, 490 top, 491 bottom, 492 max_height, 493 innerHeight, 494 scroll_listener, 495 dispatch, 496 distance_from_top, 497 distance_from_bottom, 498 input_height, 499 onwindowresize, 500 div_binding, 501 mousedown_handler, 502 ul_binding 503 ]; 504} 505 506class DropdownOptions extends SvelteComponent$3 { 507 constructor(options) { 508 super(); 509 510 init$3(this, options, instance$3, create_fragment$3, safe_not_equal$3, { 511 choices: 0, 512 filtered_indices: 1, 513 show_options: 2, 514 disabled: 3, 515 selected_indices: 4, 516 active_index: 5 517 }); 518 } 519} 520 521function positive_mod(n, m) { 522 return (n % m + m) % m; 523} 524function handle_filter(choices, input_text) { 525 return choices.reduce((filtered_indices, o, index) => { 526 if (input_text ? o[0].toLowerCase().includes(input_text.toLowerCase()) : true) { 527 filtered_indices.push(index); 528 } 529 return filtered_indices; 530 }, []); 531} 532function handle_change(dispatch, value, value_is_output) { 533 dispatch("change", value); 534 if (!value_is_output) { 535 dispatch("input"); 536 } 537} 538function handle_shared_keys(e, active_index, filtered_indices) { 539 if (e.key === "Escape") { 540 return [false, active_index]; 541 } 542 if (e.key === "ArrowDown" || e.key === "ArrowUp") { 543 if (filtered_indices.length >= 0) { 544 if (active_index === null) { 545 active_index = e.key === "ArrowDown" ? filtered_indices[0] : filtered_indices[filtered_indices.length - 1]; 546 } else { 547 const index_in_filtered = filtered_indices.indexOf(active_index); 548 const increment = e.key === "ArrowUp" ? -1 : 1; 549 active_index = filtered_indices[positive_mod(index_in_filtered + increment, filtered_indices.length)]; 550 } 551 } 552 } 553 return [true, active_index]; 554} 555 556const Multiselect_svelte_svelte_type_style_lang = ''; 557 558/* home/runner/work/gradio/gradio/js/dropdown/shared/Multiselect.svelte generated by Svelte v4.2.2 */ 559const { 560 SvelteComponent: SvelteComponent$2, 561 append: append$1, 562 attr: attr$1, 563 binding_callbacks: binding_callbacks$2, 564 check_outros: check_outros$2, 565 create_component: create_component$2, 566 destroy_component: destroy_component$2, 567 destroy_each, 568 detach: detach$2, 569 element: element$1, 570 ensure_array_like, 571 group_outros: group_outros$2, 572 init: init$2, 573 insert: insert$2, 574 listen: listen$1, 575 mount_component: mount_component$2, 576 prevent_default, 577 run_all: run_all$1, 578 safe_not_equal: safe_not_equal$2, 579 set_data: set_data$1, 580 set_input_value: set_input_value$1, 581 space: space$2, 582 text: text$1, 583 toggle_class: toggle_class$1, 584 transition_in: transition_in$2, 585 transition_out: transition_out$2 586} = window.__gradio__svelte__internal; 587const { afterUpdate: afterUpdate$1, createEventDispatcher: createEventDispatcher$1 } = window.__gradio__svelte__internal; 588function get_each_context(ctx, list, i) { 589 const child_ctx = ctx.slice(); 590 child_ctx[39] = list[i]; 591 return child_ctx; 592} 593 594// (184:1) <BlockTitle {show_label} {info}> 595function create_default_slot$2(ctx) { 596 let t; 597 598 return { 599 c() { 600 t = text$1(/*label*/ ctx[0]); 601 }, 602 m(target, anchor) { 603 insert$2(target, t, anchor); 604 }, 605 p(ctx, dirty) {
606 if (dirty[0] & /*label*/ 1) set_data$1(t, /*label*/ ctx[0]); 607 }, 608 d(detaching) { 609 if (detaching) { 610 detach$2(t); 611 } 612 } 613 }; 614} 615 616// (193:6) {:else} 617function create_else_block$1(ctx) { 618 let t_value = /*s*/ ctx[39] + ""; 619 let t; 620 621 return { 622 c() { 623 t = text$1(t_value); 624 }, 625 m(target, anchor) { 626 insert$2(target, t, anchor); 627 }, 628 p(ctx, dirty) { 629 if (dirty[0] & /*selected_indices*/ 4096 && t_value !== (t_value = /*s*/ ctx[39] + "")) set_data$1(t, t_value); 630 }, 631 d(detaching) { 632 if (detaching) { 633 detach$2(t); 634 } 635 } 636 }; 637} 638 639// (191:6) {#if typeof s === "number"} 640function create_if_block_3(ctx) { 641 let t_value = /*choices_names*/ ctx[15][/*s*/ ctx[39]] + ""; 642 let t; 643 644 return { 645 c() { 646 t = text$1(t_value); 647 }, 648 m(target, anchor) { 649 insert$2(target, t, anchor); 650 }, 651 p(ctx, dirty) { 652 if (dirty[0] & /*choices_names, selected_indices*/ 36864 && t_value !== (t_value = /*choices_names*/ ctx[15][/*s*/ ctx[39]] + "")) set_data$1(t, t_value); 653 }, 654 d(detaching) { 655 if (detaching) { 656 detach$2(t); 657 } 658 } 659 }; 660} 661 662// (197:5) {#if !disabled} 663function create_if_block_2(ctx) { 664 let div; 665 let remove; 666 let div_title_value; 667 let current; 668 let mounted; 669 let dispose; 670 remove = new Remove({}); 671 672 function click_handler() { 673 return /*click_handler*/ ctx[30](/*s*/ ctx[39]); 674 } 675 676 function keydown_handler(...args) { 677 return /*keydown_handler*/ ctx[31](/*s*/ ctx[39], ...args); 678 } 679 680 return { 681 c() { 682 div = element$1("div"); 683 create_component$2(remove.$$.fragment); 684 attr$1(div, "class", "token-remove svelte-j8ht98"); 685 attr$1(div, "role", "button"); 686 attr$1(div, "tabindex", "0"); 687 attr$1(div, "title", div_title_value = /*i18n*/ ctx[9]("common.remove") + " " + /*s*/ ctx[39]); 688 }, 689 m(target, anchor) { 690 insert$2(target, div, anchor); 691 mount_component$2(remove, div, null); 692 current = true; 693 694 if (!mounted) { 695 dispose = [ 696 listen$1(div, "click", prevent_default(click_handler)), 697 listen$1(div, "keydown", prevent_default(keydown_handler)) 698 ]; 699 700 mounted = true; 701 } 702 }, 703 p(new_ctx, dirty) { 704 ctx = new_ctx; 705 706 if (!current || dirty[0] & /*i18n, selected_indices*/ 4608 && div_title_value !== (div_title_value = /*i18n*/ ctx[9]("common.remove") + " " + /*s*/ ctx[39])) { 707 attr$1(div, "title", div_title_value); 708 } 709 }, 710 i(local) { 711 if (current) return; 712 transition_in$2(remove.$$.fragment, local); 713 current = true; 714 }, 715 o(local) { 716 transition_out$2(remove.$$.fragment, local); 717 current = false; 718 }, 719 d(detaching) { 720 if (detaching) { 721 detach$2(div); 722 } 723 724 destroy_component$2(remove); 725 mounted = false; 726 run_all$1(dispose); 727 } 728 }; 729} 730 731// (188:3) {#each selected_indices as s} 732function create_each_block(ctx) { 733 let div; 734 let span; 735 let t; 736 let current; 737 738 function select_block_type(ctx, dirty) { 739 if (typeof /*s*/ ctx[39] === "number") return create_if_block_3; 740 return create_else_block$1; 741 } 742 743 let current_block_type = select_block_type(ctx); 744 let if_block0 = current_block_type(ctx); 745 let if_block1 = !/*disabled*/ ctx[4] && create_if_block_2(ctx); 746 747 return { 748 c() { 749 div = element$1("div"); 750 span = element$1("span"); 751 if_block0.c(); 752 t = space$2(); 753 if (if_block1) if_block1.c(); 754 attr$1(span, "class", "svelte-j8ht98"); 755 attr$1(div, "class", "token svelte-j8ht98"); 756 }, 757 m(target, anchor) { 758 insert$2(target, div, anchor); 759 append$1(div, span); 760 if_block0.m(span, null); 761 append$1(div, t); 762 if (if_block1) if_block1.m(div, null); 763 current = true; 764 }, 765 p(ctx, dirty) { 766 if (current_block_type === (current_block_type = select_block_type(ctx)) && if_block0) { 767 if_block0.p(ctx, dirty); 768 } else { 769 if_block0.d(1); 770 if_block0 = current_block_type(ctx); 771 772 if (if_block0) { 773 if_block0.c(); 774 if_block0.m(span, null); 775 } 776 } 777 778 if (!/*disabled*/ ctx[4]) { 779 if (if_block1) { 780 if_block1.p(ctx, dirty); 781 782 if (dirty[0] & /*disabled*/ 16) { 783 transition_in$2(if_block1, 1); 784 } 785 } else { 786 if_block1 = create_if_block_2(ctx); 787 if_block1.c(); 788 transition_in$2(if_block1, 1); 789 if_block1.m(div, null); 790 } 791 } else if (if_block1) { 792 group_outros$2(); 793 794 transition_out$2(if_block1, 1, 1, () => { 795 if_block1 = null; 796 }); 797 798 check_outros$2(); 799 } 800 }, 801 i(local) { 802 if (current) return; 803 transition_in$2(if_block1); 804 current = true; 805 }, 806 o(local) { 807 transition_out$2(if_block1); 808 current = false;
809 }, 810 d(detaching) { 811 if (detaching) { 812 detach$2(div); 813 } 814 815 if_block0.d(); 816 if (if_block1) if_block1.d(); 817 } 818 }; 819} 820 821// (231:4) {#if !disabled} 822function create_if_block$2(ctx) { 823 let t; 824 let span; 825 let dropdownarrow; 826 let current; 827 let if_block = /*selected_indices*/ ctx[12].length > 0 && create_if_block_1(ctx); 828 dropdownarrow = new DropdownArrow({}); 829 830 return { 831 c() { 832 if (if_block) if_block.c(); 833 t = space$2(); 834 span = element$1("span"); 835 create_component$2(dropdownarrow.$$.fragment); 836 attr$1(span, "class", "icon-wrap svelte-j8ht98"); 837 }, 838 m(target, anchor) { 839 if (if_block) if_block.m(target, anchor); 840 insert$2(target, t, anchor); 841 insert$2(target, span, anchor); 842 mount_component$2(dropdownarrow, span, null); 843 current = true; 844 }, 845 p(ctx, dirty) { 846 if (/*selected_indices*/ ctx[12].length > 0) { 847 if (if_block) { 848 if_block.p(ctx, dirty); 849 850 if (dirty[0] & /*selected_indices*/ 4096) { 851 transition_in$2(if_block, 1); 852 } 853 } else { 854 if_block = create_if_block_1(ctx); 855 if_block.c(); 856 transition_in$2(if_block, 1); 857 if_block.m(t.parentNode, t); 858 } 859 } else if (if_block) { 860 group_outros$2(); 861 862 transition_out$2(if_block, 1, 1, () => { 863 if_block = null; 864 }); 865 866 check_outros$2(); 867 } 868 }, 869 i(local) { 870 if (current) return; 871 transition_in$2(if_block); 872 transition_in$2(dropdownarrow.$$.fragment, local); 873 current = true; 874 }, 875 o(local) { 876 transition_out$2(if_block); 877 transition_out$2(dropdownarrow.$$.fragment, local); 878 current = false; 879 }, 880 d(detaching) { 881 if (detaching) { 882 detach$2(t); 883 detach$2(span); 884 } 885 886 if (if_block) if_block.d(detaching); 887 destroy_component$2(dropdownarrow); 888 } 889 }; 890} 891 892// (232:5) {#if selected_indices.length > 0} 893function create_if_block_1(ctx) { 894 let div; 895 let remove; 896 let div_title_value; 897 let current; 898 let mounted; 899 let dispose; 900 remove = new Remove({}); 901 902 return { 903 c() { 904 div = element$1("div"); 905 create_component$2(remove.$$.fragment); 906 attr$1(div, "role", "button"); 907 attr$1(div, "tabindex", "0"); 908 attr$1(div, "class", "token-remove remove-all svelte-j8ht98"); 909 attr$1(div, "title", div_title_value = /*i18n*/ ctx[9]("common.clear")); 910 }, 911 m(target, anchor) { 912 insert$2(target, div, anchor); 913 mount_component$2(remove, div, null); 914 current = true; 915 916 if (!mounted) { 917 dispose = [ 918 listen$1(div, "click", /*remove_all*/ ctx[20]), 919 listen$1(div, "keydown", /*keydown_handler_1*/ ctx[34]) 920 ]; 921 922 mounted = true; 923 } 924 }, 925 p(ctx, dirty) { 926 if (!current || dirty[0] & /*i18n*/ 512 && div_title_value !== (div_title_value = /*i18n*/ ctx[9]("common.clear"))) { 927 attr$1(div, "title", div_title_value); 928 } 929 }, 930 i(local) { 931 if (current) return; 932 transition_in$2(remove.$$.fragment, local); 933 current = true; 934 }, 935 o(local) { 936 transition_out$2(remove.$$.fragment, local); 937 current = false; 938 }, 939 d(detaching) { 940 if (detaching) { 941 detach$2(div); 942 } 943 944 destroy_component$2(remove); 945 mounted = false; 946 run_all$1(dispose); 947 } 948 }; 949} 950 951function create_fragment$2(ctx) { 952 let label_1; 953 let blocktitle; 954 let t0; 955 let div2; 956 let div1; 957 let t1; 958 let div0; 959 let input; 960 let input_readonly_value; 961 let t2; 962 let t3; 963 let dropdownoptions; 964 let current; 965 let mounted; 966 let dispose; 967 968 blocktitle = new BlockTitle({ 969 props: { 970 show_label: /*show_label*/ ctx[5], 971 info: /*info*/ ctx[1], 972 $$slots: { default: [create_default_slot$2] }, 973 $$scope: { ctx } 974 } 975 }); 976 977 let each_value = ensure_array_like(/*selected_indices*/ ctx[12]); 978 let each_blocks = []; 979 980 for (let i = 0; i < each_value.length; i += 1) { 981 each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i)); 982 } 983 984 const out = i => transition_out$2(each_blocks[i], 1, 1, () => { 985 each_blocks[i] = null; 986 }); 987 988 let if_block = !/*disabled*/ ctx[4] && create_if_block$2(ctx); 989 990 dropdownoptions = new DropdownOptions({ 991 props: { 992 show_options: /*show_options*/ ctx[14], 993 choices: /*choices*/ ctx[3], 994 filtered_indices: /*filtered_indices*/ ctx[11], 995 disabled: /*disabled*/ ctx[4], 996 selected_indices: /*selected_indices*/ ctx[12], 997 active_index: /*active_index*/ ctx[16] 998 } 999 }); 1000 1001 dropdownoptions.$on("change", /*handle_option_selected*/ ctx[19]); 1002 1003 return { 1004 c() { 1005 label_1 = element$1("label"); 1006 create_component$2(blocktitle.$$.fragment); 1007 t0 = space$2(); 1008 div2 = element$1("div"); 1009 div1 = element$1("div"); 1010 1011 for (let i = 0; i < each_blocks.length; i += 1) { 1012 each_blocks[i].c(); 1013 } 1014 1015 t1 = space$2(); 1016 div0 = element$1("div"); 1017 input = element$1("input"); 1018 t2 = space$2(); 1019 if (if_block) if_block.c(); 1020 t3 = space$2(); 1021 create_component$2(dropdownoptions.$$.fragment);
1022 attr$1(input, "class", "border-none svelte-j8ht98"); 1023 input.disabled = /*disabled*/ ctx[4]; 1024 attr$1(input, "autocomplete", "off"); 1025 input.readOnly = input_readonly_value = !/*filterable*/ ctx[8]; 1026 toggle_class$1(input, "subdued", !/*choices_names*/ ctx[15].includes(/*input_text*/ ctx[10]) && !/*allow_custom_value*/ ctx[7] || /*selected_indices*/ ctx[12].length === /*max_choices*/ ctx[2]); 1027 attr$1(div0, "class", "secondary-wrap svelte-j8ht98"); 1028 attr$1(div1, "class", "wrap-inner svelte-j8ht98"); 1029 toggle_class$1(div1, "show_options", /*show_options*/ ctx[14]); 1030 attr$1(div2, "class", "wrap svelte-j8ht98"); 1031 attr$1(label_1, "class", "svelte-j8ht98"); 1032 toggle_class$1(label_1, "container", /*container*/ ctx[6]); 1033 }, 1034 m(target, anchor) { 1035 insert$2(target, label_1, anchor); 1036 mount_component$2(blocktitle, label_1, null); 1037 append$1(label_1, t0); 1038 append$1(label_1, div2); 1039 append$1(div2, div1); 1040 1041 for (let i = 0; i < each_blocks.length; i += 1) { 1042 if (each_blocks[i]) { 1043 each_blocks[i].m(div1, null); 1044 } 1045 } 1046 1047 append$1(div1, t1); 1048 append$1(div1, div0); 1049 append$1(div0, input); 1050 set_input_value$1(input, /*input_text*/ ctx[10]); 1051 /*input_binding*/ ctx[33](input); 1052 append$1(div0, t2); 1053 if (if_block) if_block.m(div0, null); 1054 append$1(div2, t3); 1055 mount_component$2(dropdownoptions, div2, null); 1056 current = true; 1057 1058 if (!mounted) { 1059 dispose = [ 1060 listen$1(input, "input", /*input_input_handler*/ ctx[32]), 1061 listen$1(input, "keydown", /*handle_key_down*/ ctx[22]), 1062 listen$1(input, "blur", /*handle_blur*/ ctx[17]), 1063 listen$1(input, "focus", /*handle_focus*/ ctx[21]) 1064 ]; 1065 1066 mounted = true; 1067 } 1068 }, 1069 p(ctx, dirty) { 1070 const blocktitle_changes = {}; 1071 if (dirty[0] & /*show_label*/ 32) blocktitle_changes.show_label = /*show_label*/ ctx[5]; 1072 if (dirty[0] & /*info*/ 2) blocktitle_changes.info = /*info*/ ctx[1]; 1073 1074 if (dirty[0] & /*label*/ 1 | dirty[1] & /*$$scope*/ 2048) { 1075 blocktitle_changes.$$scope = { dirty, ctx }; 1076 } 1077 1078 blocktitle.$set(blocktitle_changes); 1079 1080 if (dirty[0] & /*i18n, selected_indices, remove_selected_choice, disabled, choices_names*/ 299536) { 1081 each_value = ensure_array_like(/*selected_indices*/ ctx[12]); 1082 let i; 1083 1084 for (i = 0; i < each_value.length; i += 1) { 1085 const child_ctx = get_each_context(ctx, each_value, i); 1086 1087 if (each_blocks[i]) { 1088 each_blocks[i].p(child_ctx, dirty); 1089 transition_in$2(each_blocks[i], 1); 1090 } else { 1091 each_blocks[i] = create_each_block(child_ctx); 1092 each_blocks[i].c(); 1093 transition_in$2(each_blocks[i], 1); 1094 each_blocks[i].m(div1, t1); 1095 } 1096 } 1097 1098 group_outros$2(); 1099 1100 for (i = each_value.length; i < each_blocks.length; i += 1) { 1101 out(i); 1102 } 1103 1104 check_outros$2(); 1105 } 1106 1107 if (!current || dirty[0] & /*disabled*/ 16) { 1108 input.disabled = /*disabled*/ ctx[4]; 1109 } 1110 1111 if (!current || dirty[0] & /*filterable*/ 256 && input_readonly_value !== (input_readonly_value = !/*filterable*/ ctx[8])) { 1112 input.readOnly = input_readonly_value; 1113 } 1114 1115 if (dirty[0] & /*input_text*/ 1024 && input.value !== /*input_text*/ ctx[10]) { 1116 set_input_value$1(input, /*input_text*/ ctx[10]); 1117 } 1118 1119 if (!current || dirty[0] & /*choices_names, input_text, allow_custom_value, selected_indices, max_choices*/ 38020) {
1120 toggle_class$1(input, "subdued", !/*choices_names*/ ctx[15].includes(/*input_text*/ ctx[10]) && !/*allow_custom_value*/ ctx[7] || /*selected_indices*/ ctx[12].length === /*max_choices*/ ctx[2]); 1121 } 1122 1123 if (!/*disabled*/ ctx[4]) { 1124 if (if_block) { 1125 if_block.p(ctx, dirty); 1126 1127 if (dirty[0] & /*disabled*/ 16) { 1128 transition_in$2(if_block, 1); 1129 } 1130 } else { 1131 if_block = create_if_block$2(ctx); 1132 if_block.c(); 1133 transition_in$2(if_block, 1); 1134 if_block.m(div0, null); 1135 } 1136 } else if (if_block) { 1137 group_outros$2(); 1138 1139 transition_out$2(if_block, 1, 1, () => { 1140 if_block = null; 1141 }); 1142 1143 check_outros$2(); 1144 } 1145 1146 if (!current || dirty[0] & /*show_options*/ 16384) { 1147 toggle_class$1(div1, "show_options", /*show_options*/ ctx[14]); 1148 } 1149 1150 const dropdownoptions_changes = {}; 1151 if (dirty[0] & /*show_options*/ 16384) dropdownoptions_changes.show_options = /*show_options*/ ctx[14]; 1152 if (dirty[0] & /*choices*/ 8) dropdownoptions_changes.choices = /*choices*/ ctx[3]; 1153 if (dirty[0] & /*filtered_indices*/ 2048) dropdownoptions_changes.filtered_indices = /*filtered_indices*/ ctx[11]; 1154 if (dirty[0] & /*disabled*/ 16) dropdownoptions_changes.disabled = /*disabled*/ ctx[4]; 1155 if (dirty[0] & /*selected_indices*/ 4096) dropdownoptions_changes.selected_indices = /*selected_indices*/ ctx[12]; 1156 if (dirty[0] & /*active_index*/ 65536) dropdownoptions_changes.active_index = /*active_index*/ ctx[16]; 1157 dropdownoptions.$set(dropdownoptions_changes); 1158 1159 if (!current || dirty[0] & /*container*/ 64) { 1160 toggle_class$1(label_1, "container", /*container*/ ctx[6]); 1161 } 1162 }, 1163 i(local) { 1164 if (current) return; 1165 transition_in$2(blocktitle.$$.fragment, local); 1166 1167 for (let i = 0; i < each_value.length; i += 1) { 1168 transition_in$2(each_blocks[i]); 1169 } 1170 1171 transition_in$2(if_block); 1172 transition_in$2(dropdownoptions.$$.fragment, local); 1173 current = true; 1174 }, 1175 o(local) { 1176 transition_out$2(blocktitle.$$.fragment, local);
1177 each_blocks = each_blocks.filter(Boolean); 1178 1179 for (let i = 0; i < each_blocks.length; i += 1) { 1180 transition_out$2(each_blocks[i]); 1181 } 1182 1183 transition_out$2(if_block); 1184 transition_out$2(dropdownoptions.$$.fragment, local); 1185 current = false; 1186 }, 1187 d(detaching) { 1188 if (detaching) { 1189 detach$2(label_1); 1190 } 1191 1192 destroy_component$2(blocktitle); 1193 destroy_each(each_blocks, detaching); 1194 /*input_binding*/ ctx[33](null); 1195 if (if_block) if_block.d(); 1196 destroy_component$2(dropdownoptions); 1197 mounted = false; 1198 run_all$1(dispose); 1199 } 1200 }; 1201} 1202 1203function instance$2($$self, $$props, $$invalidate) { 1204 let { label } = $$props; 1205 let { info = undefined } = $$props; 1206 let { value = [] } = $$props; 1207 let old_value = []; 1208 let { value_is_output = false } = $$props; 1209 let { max_choices = null } = $$props; 1210 let { choices } = $$props; 1211 let old_choices; 1212 let { disabled = false } = $$props; 1213 let { show_label } = $$props; 1214 let { container = true } = $$props; 1215 let { allow_custom_value = false } = $$props; 1216 let { filterable = true } = $$props; 1217 let { i18n } = $$props; 1218 let filter_input; 1219 let input_text = ""; 1220 let old_input_text = ""; 1221 let show_options = false; 1222 let choices_names; 1223 let choices_values; 1224 1225 // All of these are indices with respect to the choices array 1226 let filtered_indices = []; 1227 1228 let active_index = null; 1229 1230 // selected_index consists of indices from choices or strings if allow_custom_value is true and user types in a custom value 1231 let selected_indices = []; 1232 1233 let old_selected_index = []; 1234 const dispatch = createEventDispatcher$1(); 1235 1236 // Setting the initial value of the multiselect dropdown 1237 if (Array.isArray(value)) { 1238 value.forEach(element => { 1239 const index = choices.map(c => c[1]).indexOf(element); 1240 1241 if (index !== -1) { 1242 selected_indices.push(index); 1243 } else { 1244 selected_indices.push(element); 1245 } 1246 }); 1247 } 1248 1249 function handle_blur() { 1250 if (!allow_custom_value) { 1251 $$invalidate(10, input_text = ""); 1252 } 1253 1254 if (allow_custom_value && input_text !== "") { 1255 add_selected_choice(input_text); 1256 $$invalidate(10, input_text = ""); 1257 } 1258 1259 $$invalidate(14, show_options = false); 1260 $$invalidate(16, active_index = null); 1261 dispatch("blur"); 1262 } 1263 1264 function remove_selected_choice(option_index) { 1265 $$invalidate(12, selected_indices = selected_indices.filter(v => v !== option_index)); 1266 1267 dispatch("select", { 1268 index: typeof option_index === "number" ? option_index : -1, 1269 value: typeof option_index === "number" 1270 ? choices_values[option_index] 1271 : option_index, 1272 selected: false 1273 }); 1274 } 1275 1276 function add_selected_choice(option_index) { 1277 if (max_choices === null || selected_indices.length < max_choices) { 1278 $$invalidate(12, selected_indices = [...selected_indices, option_index]); 1279 1280 dispatch("select", { 1281 index: typeof option_index === "number" ? option_index : -1, 1282 value: typeof option_index === "number" 1283 ? choices_values[option_index] 1284 : option_index, 1285 selected: true 1286 }); 1287 } 1288 1289 if (selected_indices.length === max_choices) { 1290 $$invalidate(14, show_options = false); 1291 $$invalidate(16, active_index = null); 1292 filter_input.blur(); 1293 } 1294 } 1295 1296 function handle_option_selected(e) { 1297 const option_index = parseInt(e.detail.target.dataset.index); 1298 add_or_remove_index(option_index); 1299 } 1300 1301 function add_or_remove_index(option_index) { 1302 if (selected_indices.includes(option_index)) { 1303 remove_selected_choice(option_index); 1304 } else { 1305 add_selected_choice(option_index); 1306 } 1307 1308 $$invalidate(10, input_text = ""); 1309 } 1310 1311 function remove_all(e) { 1312 $$invalidate(12, selected_indices = []); 1313 $$invalidate(10, input_text = ""); 1314 e.preventDefault(); 1315 } 1316 1317 function handle_focus(e) { 1318 $$invalidate(11, filtered_indices = choices.map((_, i) => i)); 1319 1320 if (max_choices === null || selected_indices.length < max_choices) { 1321 $$invalidate(14, show_options = true); 1322 } 1323 1324 dispatch("focus"); 1325 } 1326 1327 function handle_key_down(e) { 1328 $$invalidate(14, [show_options, active_index] = handle_shared_keys(e, active_index, filtered_indices), show_options, (((((($$invalidate(16, active_index), $$invalidate(3, choices)), $$invalidate(26, old_choices)), $$invali
1328date(10, input_text)), $$invalidate(27, old_input_text)), $$invalidate(7, allow_custom_value)), $$invalidate(11, filtered_indices))); 1329 1330 if (e.key === "Enter") { 1331 if (active_index !== null) { 1332 add_or_remove_index(active_index); 1333 } else { 1334 if (allow_custom_value) { 1335 add_selected_choice(input_text); 1336 $$invalidate(10, input_text = ""); 1337 } 1338 } 1339 } 1340 1341 if (e.key === "Backspace" && input_text === "") { 1342 $$invalidate(12, selected_indices = [...selected_indices.slice(0, -1)]); 1343 } 1344 1345 if (selected_indices.length === max_choices) { 1346 $$invalidate(14, show_options = false); 1347 $$invalidate(16, active_index = null); 1348 } 1349 } 1350 1351 function set_selected_indices() { 1352 if (value === undefined) { 1353 $$invalidate(12, selected_indices = []); 1354 } else if (Array.isArray(value)) { 1355 $$invalidate(12, selected_indices = value.map(v => { 1356 const index = choices_values.indexOf(v); 1357 1358 if (index !== -1) { 1359 return index; 1360 } 1361 1362 if (allow_custom_value) { 1363 return v; 1364 } 1365 1366 // Instead of returning null, skip this iteration 1367 return undefined; 1368 }).filter(val => val !== undefined)); 1369 } 1370 } 1371 1372 afterUpdate$1(() => { 1373 $$invalidate(24, value_is_output = false); 1374 }); 1375 1376 const click_handler = s => remove_selected_choice(s); 1377 1378 const keydown_handler = (s, event) => { 1379 if (event.key === "Enter") { 1380 remove_selected_choice(s); 1381 } 1382 }; 1383 1384 function input_input_handler() { 1385 input_text = this.value; 1386 $$invalidate(10, input_text); 1387 } 1388 1389 function input_binding($$value) { 1390 binding_callbacks$2[$$value ? 'unshift' : 'push'](() => { 1391 filter_input = $$value; 1392 $$invalidate(13, filter_input); 1393 }); 1394 } 1395 1396 const keydown_handler_1 = event => { 1397 if (event.key === "Enter") { 1398 remove_all(event); 1399 } 1400 }; 1401 1402 $$self.$$set = $$props => {
1403 if ('label' in $$props) $$invalidate(0, label = $$props.label); 1404 if ('info' in $$props) $$invalidate(1, info = $$props.info); 1405 if ('value' in $$props) $$invalidate(23, value = $$props.value); 1406 if ('value_is_output' in $$props) $$invalidate(24, value_is_output = $$props.value_is_output); 1407 if ('max_choices' in $$props) $$invalidate(2, max_choices = $$props.max_choices); 1408 if ('choices' in $$props) $$invalidate(3, choices = $$props.choices); 1409 if ('disabled' in $$props) $$invalidate(4, disabled = $$props.disabled); 1410 if ('show_label' in $$props) $$invalidate(5, show_label = $$props.show_label); 1411 if ('container' in $$props) $$invalidate(6, container = $$props.container); 1412 if ('allow_custom_value' in $$props) $$invalidate(7, allow_custom_value = $$props.allow_custom_value); 1413 if ('filterable' in $$props) $$invalidate(8, filterable = $$props.filterable); 1414 if ('i18n' in $$props) $$invalidate(9, i18n = $$props.i18n); 1415 }; 1416 1417 $$self.$$.update = () => { 1418 if ($$self.$$.dirty[0] & /*choices*/ 8) { 1419 { 1420 $$invalidate(15, choices_names = choices.map(c => c[0])); 1421 $$invalidate(28, choices_values = choices.map(c => c[1])); 1422 } 1423 } 1424 1425 if ($$self.$$.dirty[0] & /*choices, old_choices, input_text, old_input_text, allow_custom_value, filtered_indices*/ 201329800) { 1426 { 1427 if (choices !== old_choices || input_text !== old_input_text) { 1428 $$invalidate(11, filtered_indices = handle_filter(choices, input_text)); 1429 $$invalidate(26, old_choices = choices); 1430 $$invalidate(27, old_input_text = input_text); 1431 1432 if (!allow_custom_value) { 1433 $$invalidate(16, active_index = filtered_indices[0]); 1434 } 1435 } 1436 } 1437 } 1438 1439 if ($$self.$$.dirty[0] & /*selected_indices, old_selected_index, choices_values*/ 805310464) { 1440 { 1441 if (JSON.stringify(selected_indices) != JSON.stringify(old_selected_index)) { 1442 $$invalidate(23, value = selected_indices.map(index => typeof index === "number" 1443 ? choices_values[index] 1444 : index)); 1445 1446 $$invalidate(29, old_selected_index = selected_indices.slice()); 1447 } 1448 } 1449 } 1450 1451 if ($$self.$$.dirty[0] & /*value, old_value, value_is_output*/ 58720256) { 1452 { 1453 if (JSON.stringify(value) != JSON.stringify(old_value)) { 1454 handle_change(dispatch, value, value_is_output); 1455 $$invalidate(25, old_value = Array.isArray(value) ? value.slice() : value); 1456 } 1457 } 1458 } 1459 1460 if ($$self.$$.dirty[0] & /*value*/ 8388608) { 1461 (set_selected_indices()); 1462 } 1463 }; 1464 1465 return [ 1466 label, 1467 info, 1468 max_choices, 1469 choices, 1470 disabled, 1471 show_label, 1472 container, 1473 allow_custom_value, 1474 filterable, 1475 i18n, 1476 input_text, 1477 filtered_indices, 1478 selected_indices, 1479 filter_input, 1480 show_options, 1481 choices_names, 1482 active_index, 1483 handle_blur, 1484 remove_selected_choice, 1485 handle_option_selected, 1486 remove_all, 1487 handle_focus, 1488 handle_key_down, 1489 value, 1490 value_is_output, 1491 old_value, 1492 old_choices, 1493 old_input_text, 1494 choices_values, 1495 old_selected_index, 1496 click_handler, 1497 keydown_handler, 1498 input_input_handler, 1499 input_binding, 1500 keydown_handler_1 1501 ]; 1502} 1503 1504class Multiselect extends SvelteComponent$2 { 1505 constructor(options) { 1506 super(); 1507 1508 init$2( 1509 this, 1510 options, 1511 instance$2, 1512 create_fragment$2, 1513 safe_not_equal$2, 1514 { 1515 label: 0, 1516 info: 1, 1517 value: 23, 1518 value_is_output: 24, 1519 max_choices: 2, 1520 choices: 3, 1521 disabled: 4, 1522 show_label: 5, 1523 container: 6, 1524 allow_custom_value: 7, 1525 filterable: 8, 1526 i18n: 9 1527 }, 1528 null, 1529 [-1, -1] 1530 ); 1531 } 1532} 1533 1534const Multiselect$1 = Multiselect; 1535 1536const Dropdown_svelte_svelte_type_style_lang = ''; 1537 1538/* home/runner/work/gradio/gradio/js/dropdown/shared/Dropdown.svelte generated by Svelte v4.2.2 */ 1539const { 1540 SvelteComponent: SvelteComponent$1, 1541 append, 1542 attr, 1543 binding_callbacks: binding_callbacks$1, 1544 check_outros: check_outros$1, 1545 create_component: create_component$1, 1546 destroy_component: destroy_component$1, 1547 detach: detach$1, 1548 element, 1549 group_outros: group_outros$1, 1550 init: init$1, 1551 insert: insert$1, 1552 listen, 1553 mount_component: mount_component$1, 1554 run_all, 1555 safe_not_equal: safe_not_equal$1, 1556 set_data, 1557 set_input_value, 1558 space: space$1, 1559 text, 1560 toggle_class, 1561 transition_in: transition_in$1, 1562 transition_out: transition_out$1 1563} = window.__gradio__svelte__internal;const { createEventDispatcher, afterUpdate } = window.__gradio__svelte__internal; 1564function create_default_slot$1(ctx) { 1565 let t; 1566 1567 return { 1568 c() { 1569 t = text(/*label*/ ctx[0]); 1570 }, 1571 m(target, anchor) { 1572 insert$1(target, t, anchor); 1573 }, 1574 p(ctx, dirty) {
1575 if (dirty[0] & /*label*/ 1) set_data(t, /*label*/ ctx[0]); 1576 }, 1577 d(detaching) { 1578 if (detaching) { 1579 detach$1(t); 1580 } 1581 } 1582 }; 1583} 1584 1585// (181:4) {#if !disabled} 1586function create_if_block$1(ctx) { 1587 let div; 1588 let dropdownarrow; 1589 let current; 1590 dropdownarrow = new DropdownArrow({}); 1591 1592 return { 1593 c() { 1594 div = element("div"); 1595 create_component$1(dropdownarrow.$$.fragment); 1596 attr(div, "class", "icon-wrap svelte-1evtqhp"); 1597 }, 1598 m(target, anchor) { 1599 insert$1(target, div, anchor); 1600 mount_component$1(dropdownarrow, div, null); 1601 current = true; 1602 }, 1603 i(local) { 1604 if (current) return; 1605 transition_in$1(dropdownarrow.$$.fragment, local); 1606 current = true; 1607 }, 1608 o(local) { 1609 transition_out$1(dropdownarrow.$$.fragment, local); 1610 current = false; 1611 }, 1612 d(detaching) { 1613 if (detaching) { 1614 detach$1(div); 1615 } 1616 1617 destroy_component$1(dropdownarrow); 1618 } 1619 }; 1620} 1621 1622function create_fragment$1(ctx) { 1623 let label_1; 1624 let blocktitle; 1625 let t0; 1626 let div2; 1627 let div1; 1628 let div0; 1629 let input; 1630 let input_readonly_value; 1631 let t1; 1632 let t2; 1633 let dropdownoptions; 1634 let current; 1635 let mounted; 1636 let dispose; 1637 1638 blocktitle = new BlockTitle({ 1639 props: { 1640 show_label: /*show_label*/ ctx[4], 1641 info: /*info*/ ctx[1], 1642 $$slots: { default: [create_default_slot$1] }, 1643 $$scope: { ctx } 1644 } 1645 }); 1646 1647 let if_block = !/*disabled*/ ctx[3] && create_if_block$1(); 1648 1649 dropdownoptions = new DropdownOptions({ 1650 props: { 1651 show_options: /*show_options*/ ctx[12], 1652 choices: /*choices*/ ctx[2], 1653 filtered_indices: /*filtered_indices*/ ctx[9], 1654 disabled: /*disabled*/ ctx[3], 1655 selected_indices: /*selected_index*/ ctx[10] === null 1656 ? [] 1657 : [/*selected_index*/ ctx[10]], 1658 active_index: /*active_index*/ ctx[14] 1659 } 1660 }); 1661 1662 dropdownoptions.$on("change", /*handle_option_selected*/ ctx[15]); 1663 1664 return { 1665 c() { 1666 label_1 = element("label"); 1667 create_component$1(blocktitle.$$.fragment); 1668 t0 = space$1(); 1669 div2 = element("div"); 1670 div1 = element("div"); 1671 div0 = element("div"); 1672 input = element("input"); 1673 t1 = space$1(); 1674 if (if_block) if_block.c(); 1675 t2 = space$1(); 1676 create_component$1(dropdownoptions.$$.fragment); 1677 attr(input, "class", "border-none svelte-1evtqhp"); 1678 input.disabled = /*disabled*/ ctx[3]; 1679 attr(input, "autocomplete", "off"); 1680 input.readOnly = input_readonly_value = !/*filterable*/ ctx[7];
1681 toggle_class(input, "subdued", !/*choices_names*/ ctx[13].includes(/*input_text*/ ctx[8]) && !/*allow_custom_value*/ ctx[6]); 1682 attr(div0, "class", "secondary-wrap svelte-1evtqhp"); 1683 attr(div1, "class", "wrap-inner svelte-1evtqhp"); 1684 toggle_class(div1, "show_options", /*show_options*/ ctx[12]); 1685 attr(div2, "class", "wrap svelte-1evtqhp"); 1686 attr(label_1, "class", "svelte-1evtqhp"); 1687 toggle_class(label_1, "container", /*container*/ ctx[5]); 1688 }, 1689 m(target, anchor) { 1690 insert$1(target, label_1, anchor); 1691 mount_component$1(blocktitle, label_1, null); 1692 append(label_1, t0); 1693 append(label_1, div2); 1694 append(div2, div1); 1695 append(div1, div0); 1696 append(div0, input); 1697 set_input_value(input, /*input_text*/ ctx[8]); 1698 /*input_binding*/ ctx[28](input); 1699 append(div0, t1); 1700 if (if_block) if_block.m(div0, null); 1701 append(div2, t2); 1702 mount_component$1(dropdownoptions, div2, null); 1703 current = true; 1704 1705 if (!mounted) { 1706 dispose = [ 1707 listen(input, "input", /*input_input_handler*/ ctx[27]), 1708 listen(input, "keydown", /*handle_key_down*/ ctx[18]), 1709 listen(input, "blur", /*handle_blur*/ ctx[17]), 1710 listen(input, "focus", /*handle_focus*/ ctx[16]) 1711 ]; 1712 1713 mounted = true; 1714 } 1715 }, 1716 p(ctx, dirty) { 1717 const blocktitle_changes = {}; 1718 if (dirty[0] & /*show_label*/ 16) blocktitle_changes.show_label = /*show_label*/ ctx[4]; 1719 if (dirty[0] & /*info*/ 2) blocktitle_changes.info = /*info*/ ctx[1]; 1720 1721 if (dirty[0] & /*label*/ 1 | dirty[1] & /*$$scope*/ 1) { 1722 blocktitle_changes.$$scope = { dirty, ctx }; 1723 } 1724 1725 blocktitle.$set(blocktitle_changes); 1726 1727 if (!current || dirty[0] & /*disabled*/ 8) { 1728 input.disabled = /*disabled*/ ctx[3]; 1729 } 1730 1731 if (!current || dirty[0] & /*filterable*/ 128 && input_readonly_value !== (input_readonly_value = !/*filterable*/ ctx[7])) { 1732 input.readOnly = input_readonly_value; 1733 } 1734 1735 if (dirty[0] & /*input_text*/ 256 && input.value !== /*input_text*/ ctx[8]) { 1736 set_input_value(input, /*input_text*/ ctx[8]); 1737 } 1738 1739 if (!current || dirty[0] & /*choices_names, input_text, allow_custom_value*/ 8512) {
1740 toggle_class(input, "subdued", !/*choices_names*/ ctx[13].includes(/*input_text*/ ctx[8]) && !/*allow_custom_value*/ ctx[6]); 1741 } 1742 1743 if (!/*disabled*/ ctx[3]) { 1744 if (if_block) { 1745 if (dirty[0] & /*disabled*/ 8) { 1746 transition_in$1(if_block, 1); 1747 } 1748 } else { 1749 if_block = create_if_block$1(); 1750 if_block.c(); 1751 transition_in$1(if_block, 1); 1752 if_block.m(div0, null); 1753 } 1754 } else if (if_block) { 1755 group_outros$1(); 1756 1757 transition_out$1(if_block, 1, 1, () => { 1758 if_block = null; 1759 }); 1760 1761 check_outros$1(); 1762 } 1763 1764 if (!current || dirty[0] & /*show_options*/ 4096) { 1765 toggle_class(div1, "show_options", /*show_options*/ ctx[12]); 1766 } 1767 1768 const dropdownoptions_changes = {}; 1769 if (dirty[0] & /*show_options*/ 4096) dropdownoptions_changes.show_options = /*show_options*/ ctx[12]; 1770 if (dirty[0] & /*choices*/ 4) dropdownoptions_changes.choices = /*choices*/ ctx[2]; 1771 if (dirty[0] & /*filtered_indices*/ 512) dropdownoptions_changes.filtered_indices = /*filtered_indices*/ ctx[9]; 1772 if (dirty[0] & /*disabled*/ 8) dropdownoptions_changes.disabled = /*disabled*/ ctx[3]; 1773 1774 if (dirty[0] & /*selected_index*/ 1024) dropdownoptions_changes.selected_indices = /*selected_index*/ ctx[10] === null 1775 ? [] 1776 : [/*selected_index*/ ctx[10]]; 1777 1778 if (dirty[0] & /*active_index*/ 16384) dropdownoptions_changes.active_index = /*active_index*/ ctx[14]; 1779 dropdownoptions.$set(dropdownoptions_changes); 1780 1781 if (!current || dirty[0] & /*container*/ 32) { 1782 toggle_class(label_1, "container", /*container*/ ctx[5]); 1783 } 1784 }, 1785 i(local) { 1786 if (current) return; 1787 transition_in$1(blocktitle.$$.fragment, local); 1788 transition_in$1(if_block); 1789 transition_in$1(dropdownoptions.$$.fragment, local); 1790 current = true; 1791 }, 1792 o(local) { 1793 transition_out$1(blocktitle.$$.fragment, local); 1794 transition_out$1(if_block); 1795 transition_out$1(dropdownoptions.$$.fragment, local); 1796 current = false; 1797 }, 1798 d(detaching) { 1799 if (detaching) { 1800 detach$1(label_1); 1801 } 1802 1803 destroy_component$1(blocktitle); 1804 /*input_binding*/ ctx[28](null); 1805 if (if_block) if_block.d(); 1806 destroy_component$1(dropdownoptions); 1807 mounted = false; 1808 run_all(dispose); 1809 } 1810 }; 1811} 1812 1813function instance$1($$self, $$props, $$invalidate) { 1814 let { label } = $$props; 1815 let { info = undefined } = $$props; 1816 let { value = [] } = $$props; 1817 let old_value = []; 1818 let { value_is_output = false } = $$props; 1819 let { choices } = $$props; 1820 let old_choices; 1821 let { disabled = false } = $$props; 1822 let { show_label } = $$props; 1823 let { container = true } = $$props; 1824 let { allow_custom_value = false } = $$props; 1825 let { filterable = true } = $$props; 1826 let filter_input; 1827 let show_options = false; 1828 let choices_names; 1829 let choices_values; 1830 let input_text = ""; 1831 let old_input_text = ""; 1832 let initialized = false; 1833 1834 // All of these are indices with respect to the choices array 1835 let filtered_indices = []; 1836 1837 let active_index = null; 1838 1839 // selected_index is null if allow_custom_value is true and the input_text is not in choices_names 1840 let selected_index = null; 1841 1842 let old_selected_index; 1843 const dispatch = createEventDispatcher(); 1844 1845 // Setting the initial value of the dropdown 1846 if (value) { 1847 old_selected_index = choices.map(c => c[1]).indexOf(value); 1848 selected_index = old_selected_index; 1849 1850 if (selected_index === -1) { 1851 old_value = value; 1852 selected_index = null; 1853 } else { 1854 [input_text, old_value] = choices[selected_index]; 1855 old_input_text = input_text; 1856 } 1857 } else if (choices.length > 0) { 1858 old_selected_index = 0; 1859 selected_index = 0; 1860 [input_text, value] = choices[selected_index]; 1861 old_value = value; 1862 old_input_text = input_text; 1863 } 1864 1865 function set_input_text() { 1866 if (value === undefined) { 1867 $$invalidate(8, input_text = ""); 1868 $$invalidate(10, selected_index = null); 1869 } else if (choices_values.includes(value)) { 1870 $$invalidate(8, input_text = choices_names[choices_values.indexOf(value)]); 1871 $$invalidate(10, selected_index = choices_values.indexOf(value)); 1872 } else if (allow_custom_value) { 1873 $$invalidate(8, input_text = value); 1874 $$invalidate(10, selected_index = null); 1875 } else {
1876 $$invalidate(8, input_text = ""); 1877 $$invalidate(10, selected_index = null); 1878 } 1879 1880 $$invalidate(26, old_selected_index = selected_index); 1881 } 1882 1883 function handle_option_selected(e) { 1884 $$invalidate(10, selected_index = parseInt(e.detail.target.dataset.index)); 1885 1886 if (isNaN(selected_index)) { 1887 // This is the case when the user clicks on the scrollbar 1888 $$invalidate(10, selected_index = null); 1889 1890 return; 1891 } 1892 1893 $$invalidate(12, show_options = false); 1894 $$invalidate(14, active_index = null); 1895 filter_input.blur(); 1896 } 1897 1898 function handle_focus(e) { 1899 $$invalidate(9, filtered_indices = choices.map((_, i) => i)); 1900 $$invalidate(12, show_options = true); 1901 dispatch("focus"); 1902 } 1903 1904 function handle_blur() { 1905 if (!allow_custom_value) { 1906 $$invalidate(8, input_text = choices_names[choices_values.indexOf(value)]); 1907 } else { 1908 $$invalidate(19, value = input_text); 1909 } 1910 1911 $$invalidate(12, show_options = false); 1912 $$invalidate(14, active_index = null); 1913 dispatch("blur"); 1914 } 1915 1916 function handle_key_down(e) { 1917 $$invalidate(12, [show_options, active_index] = handle_shared_keys(e, active_index, filtered_indices), show_options, (((((((((($$invalidate(14, active_index), $$invalidate(2, choices)), $$invalidate(22, old_choices)), $$invalidate(8, input_text)), $$invalidate(24, old_input_text)), $$invalidate(6, allow_custom_value)), $$invalidate(9, filtered_indices)), $$invalidate(10, selected_index)), $$invalidate(26, old_selected_index)), $$invalidate(25, initialized)), $$invalidate(23, choices_values))); 1918 1919 if (e.key === "Enter") { 1920 if (active_index !== null) { 1921 $$invalidate(10, selected_index = active_index); 1922 $$invalidate(12, show_options = false); 1923 filter_input.blur(); 1924 $$invalidate(14, active_index = null); 1925 } else if (choices_names.includes(input_text)) { 1926 $$invalidate(10, selected_index = choices_names.indexOf(input_text)); 1927 $$invalidate(12, show_options = false); 1928 $$invalidate(14, active_index = null); 1929 filter_input.blur(); 1930 } else if (allow_custom_value) { 1931 $$invalidate(19, value = input_text); 1932 $$invalidate(10, selected_index = null); 1933 $$invalidate(12, show_options = false); 1934 $$invalidate(14, active_index = null); 1935 filter_input.blur(); 1936 } 1937 } 1938 } 1939 1940 afterUpdate(() => { 1941 $$invalidate(20, value_is_output = false); 1942 $$invalidate(25, initialized = true); 1943 }); 1944 1945 function input_input_handler() { 1946 input_text = this.value; 1947 ((((($$invalidate(8, input_text), $$invalidate(10, selected_index)), $$invalidate(26, old_selected_index)), $$invalidate(25, initialized)), $$invalidate(2, choices)), $$invalidate(23, choices_values)); 1948 } 1949 1950 function input_binding($$value) { 1951 binding_callbacks$1[$$value ? 'unshift' : 'push'](() => { 1952 filter_input = $$value; 1953 $$invalidate(11, filter_input); 1954 }); 1955 } 1956 1957 $$self.$$set = $$props => {
1958 if ('label' in $$props) $$invalidate(0, label = $$props.label); 1959 if ('info' in $$props) $$invalidate(1, info = $$props.info); 1960 if ('value' in $$props) $$invalidate(19, value = $$props.value); 1961 if ('value_is_output' in $$props) $$invalidate(20, value_is_output = $$props.value_is_output); 1962 if ('choices' in $$props) $$invalidate(2, choices = $$props.choices); 1963 if ('disabled' in $$props) $$invalidate(3, disabled = $$props.disabled); 1964 if ('show_label' in $$props) $$invalidate(4, show_label = $$props.show_label); 1965 if ('container' in $$props) $$invalidate(5, container = $$props.container); 1966 if ('allow_custom_value' in $$props) $$invalidate(6, allow_custom_value = $$props.allow_custom_value); 1967 if ('filterable' in $$props) $$invalidate(7, filterable = $$props.filterable); 1968 }; 1969 1970 $$self.$$.update = () => { 1971 if ($$self.$$.dirty[0] & /*choices*/ 4) { 1972 { 1973 $$invalidate(13, choices_names = choices.map(c => c[0])); 1974 $$invalidate(23, choices_values = choices.map(c => c[1])); 1975 } 1976 } 1977 1978 if ($$self.$$.dirty[0] & /*selected_index, old_selected_index, initialized, choices, choices_values*/ 109052932) { 1979 { 1980 if (selected_index !== old_selected_index && selected_index !== null && initialized) { 1981 $$invalidate(8, [input_text, value] = choices[selected_index], input_text, ((((($$invalidate(19, value), $$invalidate(10, selected_index)), $$invalidate(26, old_selected_index)), $$invalidate(25, initialized)), $$invalidate(2, choices)), $$invalidate(23, choices_values))); 1982 $$invalidate(26, old_selected_index = selected_index); 1983 1984 dispatch("select", { 1985 index: selected_index, 1986 value: choices_values[selected_index], 1987 selected: true 1988 }); 1989 } 1990 } 1991 } 1992 1993 if ($$self.$$.dirty[0] & /*value, old_value, value_is_output*/ 3670016) { 1994 { 1995 if (value != old_value) { 1996 set_input_text(); 1997 handle_change(dispatch, value, value_is_output); 1998 $$invalidate(21, old_value = value); 1999 } 2000 } 2001 } 2002 2003 if ($$self.$$.dirty[0] & /*choices, old_choices, input_text, old_input_text, allow_custom_value, filtered_indices*/ 20972356) { 2004 { 2005 if (choices !== old_choices || input_text !== old_input_text) { 2006 $$invalidate(9, filtered_indices = handle_filter(choices, input_text)); 2007 $$invalidate(22, old_choices = choices); 2008 $$invalidate(24, old_input_text = input_text); 2009 2010 if (!allow_custom_value && filtered_indices.length > 0) { 2011 $$invalidate(14, active_index = filtered_indices[0]); 2012 } 2013 } 2014 } 2015 } 2016 }; 2017 2018 return [ 2019 label, 2020 info, 2021 choices, 2022 disabled, 2023 show_label, 2024 container, 2025 allow_custom_value, 2026 filterable, 2027 input_text, 2028 filtered_indices, 2029 selected_index, 2030 filter_input, 2031 show_options, 2032 choices_names, 2033 active_index, 2034 handle_option_selected, 2035 handle_focus, 2036 handle_blur, 2037 handle_key_down, 2038 value, 2039 value_is_output, 2040 old_value, 2041 old_choices, 2042 choices_values, 2043 old_input_text, 2044 initialized, 2045 old_selected_index, 2046 input_input_handler, 2047 input_binding 2048 ]; 2049} 2050 2051class Dropdown extends SvelteComponent$1 { 2052 constructor(options) { 2053 super(); 2054 2055 init$1( 2056 this, 2057 options, 2058 instance$1, 2059 create_fragment$1, 2060 safe_not_equal$1, 2061 { 2062 label: 0, 2063 info: 1, 2064 value: 19, 2065 value_is_output: 20, 2066 choices: 2, 2067 disabled: 3, 2068 show_label: 4, 2069 container: 5, 2070 allow_custom_value: 6, 2071 filterable: 7 2072 }, 2073 null, 2074 [-1, -1] 2075 ); 2076 } 2077} 2078 2079const Dropdown$1 = Dropdown; 2080 2081/* home/runner/work/gradio/gradio/js/dropdown/Index.svelte generated by Svelte v4.2.2 */ 2082const { 2083 SvelteComponent, 2084 add_flush_callback, 2085 assign, 2086 bind, 2087 binding_callbacks, 2088 check_outros, 2089 create_component, 2090 destroy_component, 2091 detach, 2092 empty, 2093 get_spread_object, 2094 get_spread_update, 2095 group_outros, 2096 init, 2097 insert, 2098 mount_component, 2099 safe_not_equal, 2100 space, 2101 transition_in, 2102 transition_out 2103} = window.__gradio__svelte__internal; 2104function create_else_block(ctx) { 2105 let dropdown; 2106 let updating_value; 2107 let updating_value_is_output; 2108 let current; 2109 2110 function dropdown_value_binding(value) { 2111 /*dropdown_value_binding*/ ctx[26](value); 2112 } 2113 2114 function dropdown_value_is_output_binding(value) { 2115 /*dropdown_value_is_output_binding*/ ctx[27](value); 2116 } 2117 2118 let dropdown_props = { 2119 choices: /*choices*/ ctx[9], 2120 label: /*label*/ ctx[2], 2121 info: /*info*/ ctx[3], 2122 show_label: /*show_label*/ ctx[10], 2123 filterable: /*filterable*/ ctx[11], 2124 allow_custom_value: /*allow_custom_value*/ ctx[16], 2125 container: /*container*/ ctx[12], 2126 disabled: !/*interactive*/ ctx[18] 2127 }; 2128 2129 if (/*value*/ ctx[0] !== void 0) { 2130 dropdown_props.value = /*value*/ ctx[0]; 2131 } 2132 2133 if (/*value_is_output*/ ctx[1] !== void 0) { 2134 dropdown_props.value_is_output = /*value_is_output*/ ctx[1]; 2135 } 2136 2137 dropdown = new Dropdown$1({ props: dropdown_props }); 2138 binding_callbacks.push(() => bind(dropdown, 'value', dropdown_value_binding)); 2139 binding_callbacks.push(() => bind(dropdown, 'value_is_output', dropdown_value_is_output_binding)); 2140 dropdown.$on("change", /*change_handler_1*/ ctx[28]); 2141 dropdown.$on("input", /*input_handler_1*/ ctx[29]); 2142 dropdown.$on("select", /*select_handler_1*/ ctx[30]); 2143 dropdown.$on("blur", /*blur_handler_1*/ ctx[31]); 2144 dropdown.$on("focus", /*focus_handler_1*/ ctx[32]); 2145 2146 return { 2147 c() { 2148 create_component(dropdown.$$.fragment); 2149 }, 2150 m(target, anchor) { 2151 mount_component(dropdown, target, anchor); 2152 current = true; 2153 }, 2154 p(ctx, dirty) { 2155 const dropdown_changes = {};
2156 if (dirty[0] & /*choices*/ 512) dropdown_changes.choices = /*choices*/ ctx[9]; 2157 if (dirty[0] & /*label*/ 4) dropdown_changes.label = /*label*/ ctx[2]; 2158 if (dirty[0] & /*info*/ 8) dropdown_changes.info = /*info*/ ctx[3]; 2159 if (dirty[0] & /*show_label*/ 1024) dropdown_changes.show_label = /*show_label*/ ctx[10]; 2160 if (dirty[0] & /*filterable*/ 2048) dropdown_changes.filterable = /*filterable*/ ctx[11]; 2161 if (dirty[0] & /*allow_custom_value*/ 65536) dropdown_changes.allow_custom_value = /*allow_custom_value*/ ctx[16]; 2162 if (dirty[0] & /*container*/ 4096) dropdown_changes.container = /*container*/ ctx[12]; 2163 if (dirty[0] & /*interactive*/ 262144) dropdown_changes.disabled = !/*interactive*/ ctx[18]; 2164 2165 if (!updating_value && dirty[0] & /*value*/ 1) { 2166 updating_value = true; 2167 dropdown_changes.value = /*value*/ ctx[0]; 2168 add_flush_callback(() => updating_value = false); 2169 } 2170 2171 if (!updating_value_is_output && dirty[0] & /*value_is_output*/ 2) { 2172 updating_value_is_output = true; 2173 dropdown_changes.value_is_output = /*value_is_output*/ ctx[1]; 2174 add_flush_callback(() => updating_value_is_output = false); 2175 } 2176 2177 dropdown.$set(dropdown_changes); 2178 }, 2179 i(local) { 2180 if (current) return; 2181 transition_in(dropdown.$$.fragment, local); 2182 current = true; 2183 }, 2184 o(local) { 2185 transition_out(dropdown.$$.fragment, local); 2186 current = false; 2187 }, 2188 d(detaching) { 2189 destroy_component(dropdown, detaching); 2190 } 2191 }; 2192} 2193 2194// (46:1) {#if multiselect} 2195function create_if_block(ctx) { 2196 let multiselect_1; 2197 let updating_value; 2198 let updating_value_is_output; 2199 let current; 2200 2201 function multiselect_1_value_binding(value) { 2202 /*multiselect_1_value_binding*/ ctx[19](value); 2203 } 2204 2205 function multiselect_1_value_is_output_binding(value) { 2206 /*multiselect_1_value_is_output_binding*/ ctx[20](value); 2207 } 2208 2209 let multiselect_1_props = { 2210 choices: /*choices*/ ctx[9], 2211 max_choices: /*max_choices*/ ctx[8], 2212 label: /*label*/ ctx[2], 2213 info: /*info*/ ctx[3], 2214 show_label: /*show_label*/ ctx[10], 2215 allow_custom_value: /*allow_custom_value*/ ctx[16], 2216 filterable: /*filterable*/ ctx[11], 2217 container: /*container*/ ctx[12], 2218 i18n: /*gradio*/ ctx[17].i18n, 2219 disabled: !/*interactive*/ ctx[18] 2220 }; 2221 2222 if (/*value*/ ctx[0] !== void 0) { 2223 multiselect_1_props.value = /*value*/ ctx[0]; 2224 } 2225 2226 if (/*value_is_output*/ ctx[1] !== void 0) { 2227 multiselect_1_props.value_is_output = /*value_is_output*/ ctx[1]; 2228 } 2229 2230 multiselect_1 = new Multiselect$1({ props: multiselect_1_props }); 2231 binding_callbacks.push(() => bind(multiselect_1, 'value', multiselect_1_value_binding)); 2232 binding_callbacks.push(() => bind(multiselect_1, 'value_is_output', multiselect_1_value_is_output_binding)); 2233 multiselect_1.$on("change", /*change_handler*/ ctx[21]); 2234 multiselect_1.$on("input", /*input_handler*/ ctx[22]); 2235 multiselect_1.$on("select", /*select_handler*/ ctx[23]); 2236 multiselect_1.$on("blur", /*blur_handler*/ ctx[24]); 2237 multiselect_1.$on("focus", /*focus_handler*/ ctx[25]); 2238 2239 return { 2240 c() { 2241 create_component(multiselect_1.$$.fragment); 2242 }, 2243 m(target, anchor) { 2244 mount_component(multiselect_1, target, anchor); 2245 current = true; 2246 }, 2247 p(ctx, dirty) { 2248 const multiselect_1_changes = {}; 2249 if (dirty[0] & /*choices*/ 512) multiselect_1_changes.choices = /*choices*/ ctx[9]; 2250 if (dirty[0] & /*max_choices*/ 256) multiselect_1_changes.max_choices = /*max_choices*/ ctx[8]; 2251 if (dirty[0] & /*label*/ 4) multiselect_1_changes.label = /*label*/ ctx[2]; 2252 if (dirty[0] & /*info*/ 8) multiselect_1_changes.info = /*info*/ ctx[3]; 2253 if (dirty[0] & /*show_label*/ 1024) multiselect_1_changes.show_label = /*show_label*/ ctx[10]; 2254 if (dirty[0] & /*allow_custom_value*/ 65536) multiselect_1_changes.allow_custom_value = /*allow_custom_value*/ ctx[16]; 2255 if (dirty[0] & /*filterable*/ 2048) multiselect_1_changes.filterable = /*filterable*/ ctx[11]; 2256 if (dirty[0] & /*container*/ 4096) multiselect_1_changes.container = /*container*/ ctx[12]; 2257 if (dirty[0] & /*gradio*/ 131072) multiselect_1_changes.i18n = /*gradio*/ ctx[17].i18n; 2258 if (dirty[0] & /*interactive*/ 262144) multiselect_1_changes.disabled = !/*interactive*/ ctx[18]; 2259 2260 if (!updating_value && dirty[0] & /*value*/ 1) { 2261 updating_value = true; 2262 multiselect_1_changes.value = /*value*/ ctx[0]; 2263 add_flush_callback(() => updating_value = false); 2264 } 2265 2266 if (!updating_value_is_output && dirty[0] & /*value_is_output*/ 2) { 2267 updating_value_is_output = true; 2268 multiselect_1_changes.value_is_output = /*value_is_output*/ ctx[1]; 2269 add_flush_callback(() => updating_value_is_output = false); 2270 } 2271 2272 multiselect_1.$set(multiselect_1_changes); 2273 }, 2274 i(local) { 2275 if (current) return; 2276 transition_in(multiselect_1.$$.fragment, local); 2277 current = true; 2278 }, 2279 o(local) { 2280 transition_out(multiselect_1.$$.fragment, local); 2281 current = false;
2282 }, 2283 d(detaching) { 2284 destroy_component(multiselect_1, detaching); 2285 } 2286 }; 2287} 2288 2289// (31:0) <Block {visible} {elem_id} {elem_classes} padding={container} allow_overflow={false} {scale} {min_width} > 2290function create_default_slot(ctx) { 2291 let statustracker; 2292 let t; 2293 let current_block_type_index; 2294 let if_block; 2295 let if_block_anchor; 2296 let current; 2297 2298 const statustracker_spread_levels = [ 2299 { 2300 autoscroll: /*gradio*/ ctx[17].autoscroll 2301 }, 2302 { i18n: /*gradio*/ ctx[17].i18n }, 2303 /*loading_status*/ ctx[15] 2304 ]; 2305 2306 let statustracker_props = {}; 2307 2308 for (let i = 0; i < statustracker_spread_levels.length; i += 1) { 2309 statustracker_props = assign(statustracker_props, statustracker_spread_levels[i]); 2310 } 2311 2312 statustracker = new Static({ props: statustracker_props }); 2313 const if_block_creators = [create_if_block, create_else_block]; 2314 const if_blocks = []; 2315 2316 function select_block_type(ctx, dirty) { 2317 if (/*multiselect*/ ctx[7]) return 0; 2318 return 1; 2319 } 2320 2321 current_block_type_index = select_block_type(ctx); 2322 if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); 2323 2324 return { 2325 c() { 2326 create_component(statustracker.$$.fragment); 2327 t = space(); 2328 if_block.c(); 2329 if_block_anchor = empty(); 2330 }, 2331 m(target, anchor) { 2332 mount_component(statustracker, target, anchor); 2333 insert(target, t, anchor); 2334 if_blocks[current_block_type_index].m(target, anchor); 2335 insert(target, if_block_anchor, anchor); 2336 current = true; 2337 }, 2338 p(ctx, dirty) { 2339 const statustracker_changes = (dirty[0] & /*gradio, loading_status*/ 163840) 2340 ? get_spread_update(statustracker_spread_levels, [ 2341 dirty[0] & /*gradio*/ 131072 && { 2342 autoscroll: /*gradio*/ ctx[17].autoscroll 2343 }, 2344 dirty[0] & /*gradio*/ 131072 && { i18n: /*gradio*/ ctx[17].i18n }, 2345 dirty[0] & /*loading_status*/ 32768 && get_spread_object(/*loading_status*/ ctx[15]) 2346 ]) 2347 : {}; 2348 2349 statustracker.$set(statustracker_changes); 2350 let previous_block_index = current_block_type_index; 2351 current_block_type_index = select_block_type(ctx); 2352 2353 if (current_block_type_index === previous_block_index) { 2354 if_blocks[current_block_type_index].p(ctx, dirty); 2355 } else { 2356 group_outros(); 2357 2358 transition_out(if_blocks[previous_block_index], 1, 1, () => { 2359 if_blocks[previous_block_index] = null; 2360 }); 2361 2362 check_outros(); 2363 if_block = if_blocks[current_block_type_index]; 2364 2365 if (!if_block) { 2366 if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); 2367 if_block.c(); 2368 } else { 2369 if_block.p(ctx, dirty); 2370 } 2371 2372 transition_in(if_block, 1); 2373 if_block.m(if_block_anchor.parentNode, if_block_anchor); 2374 } 2375 }, 2376 i(local) { 2377 if (current) return; 2378 transition_in(statustracker.$$.fragment, local); 2379 transition_in(if_block); 2380 current = true; 2381 }, 2382 o(local) { 2383 transition_out(statustracker.$$.fragment, local); 2384 transition_out(if_block); 2385 current = false; 2386 }, 2387 d(detaching) { 2388 if (detaching) { 2389 detach(t); 2390 detach(if_block_anchor); 2391 } 2392 2393 destroy_component(statustracker, detaching); 2394 if_blocks[current_block_type_index].d(detaching); 2395 } 2396 }; 2397} 2398 2399function create_fragment(ctx) { 2400 let block; 2401 let current; 2402 2403 block = new Block({ 2404 props: { 2405 visible: /*visible*/ ctx[6], 2406 elem_id: /*elem_id*/ ctx[4], 2407 elem_classes: /*elem_classes*/ ctx[5], 2408 padding: /*container*/ ctx[12], 2409 allow_overflow: false, 2410 scale: /*scale*/ ctx[13], 2411 min_width: /*min_width*/ ctx[14], 2412 $$slots: { default: [create_default_slot] }, 2413 $$scope: { ctx } 2414 } 2415 }); 2416 2417 return { 2418 c() { 2419 create_component(block.$$.fragment); 2420 }, 2421 m(target, anchor) { 2422 mount_component(block, target, anchor); 2423 current = true; 2424 }, 2425 p(ctx, dirty) { 2426 const block_changes = {}; 2427 if (dirty[0] & /*visible*/ 64) block_changes.visible = /*visible*/ ctx[6]; 2428 if (dirty[0] & /*elem_id*/ 16) block_changes.elem_id = /*elem_id*/ ctx[4]; 2429 if (dirty[0] & /*elem_classes*/ 32) block_changes.elem_classes = /*elem_classes*/ ctx[5]; 2430 if (dirty[0] & /*container*/ 4096) block_changes.padding = /*container*/ ctx[12];
2431 if (dirty[0] & /*scale*/ 8192) block_changes.scale = /*scale*/ ctx[13]; 2432 if (dirty[0] & /*min_width*/ 16384) block_changes.min_width = /*min_width*/ ctx[14]; 2433 2434 if (dirty[0] & /*choices, max_choices, label, info, show_label, allow_custom_value, filterable, container, gradio, interactive, value, value_is_output, multiselect, loading_status*/ 499599 | dirty[1] & /*$$scope*/ 4) { 2435 block_changes.$$scope = { dirty, ctx }; 2436 } 2437 2438 block.$set(block_changes); 2439 }, 2440 i(local) { 2441 if (current) return; 2442 transition_in(block.$$.fragment, local); 2443 current = true; 2444 }, 2445 o(local) { 2446 transition_out(block.$$.fragment, local); 2447 current = false; 2448 }, 2449 d(detaching) { 2450 destroy_component(block, detaching); 2451 } 2452 }; 2453} 2454 2455function instance($$self, $$props, $$invalidate) { 2456 let { label = "Dropdown" } = $$props; 2457 let { info = undefined } = $$props; 2458 let { elem_id = "" } = $$props; 2459 let { elem_classes = [] } = $$props; 2460 let { visible = true } = $$props; 2461 let { value } = $$props; 2462 let { value_is_output = false } = $$props; 2463 let { multiselect = false } = $$props; 2464 let { max_choices = null } = $$props; 2465 let { choices } = $$props; 2466 let { show_label } = $$props; 2467 let { filterable } = $$props; 2468 let { container = true } = $$props; 2469 let { scale = null } = $$props; 2470 let { min_width = undefined } = $$props; 2471 let { loading_status } = $$props; 2472 let { allow_custom_value = false } = $$props; 2473 let { gradio } = $$props; 2474 let { interactive } = $$props; 2475 2476 function multiselect_1_value_binding(value$1) { 2477 value = value$1; 2478 $$invalidate(0, value); 2479 } 2480 2481 function multiselect_1_value_is_output_binding(value) { 2482 value_is_output = value; 2483 $$invalidate(1, value_is_output); 2484 } 2485 2486 const change_handler = () => gradio.dispatch("change"); 2487 const input_handler = () => gradio.dispatch("input"); 2488 const select_handler = e => gradio.dispatch("select", e.detail); 2489 const blur_handler = () => gradio.dispatch("blur"); 2490 const focus_handler = () => gradio.dispatch("focus"); 2491 2492 function dropdown_value_binding(value$1) { 2493 value = value$1; 2494 $$invalidate(0, value); 2495 } 2496 2497 function dropdown_value_is_output_binding(value) { 2498 value_is_output = value; 2499 $$invalidate(1, value_is_output); 2500 } 2501 2502 const change_handler_1 = () => gradio.dispatch("change"); 2503 const input_handler_1 = () => gradio.dispatch("input"); 2504 const select_handler_1 = e => gradio.dispatch("select", e.detail); 2505 const blur_handler_1 = () => gradio.dispatch("blur"); 2506 const focus_handler_1 = () => gradio.dispatch("focus"); 2507 2508 $$self.$$set = $$props => {
2509 if ('label' in $$props) $$invalidate(2, label = $$props.label); 2510 if ('info' in $$props) $$invalidate(3, info = $$props.info); 2511 if ('elem_id' in $$props) $$invalidate(4, elem_id = $$props.elem_id); 2512 if ('elem_classes' in $$props) $$invalidate(5, elem_classes = $$props.elem_classes); 2513 if ('visible' in $$props) $$invalidate(6, visible = $$props.visible); 2514 if ('value' in $$props) $$invalidate(0, value = $$props.value); 2515 if ('value_is_output' in $$props) $$invalidate(1, value_is_output = $$props.value_is_output); 2516 if ('multiselect' in $$props) $$invalidate(7, multiselect = $$props.multiselect); 2517 if ('max_choices' in $$props) $$invalidate(8, max_choices = $$props.max_choices); 2518 if ('choices' in $$props) $$invalidate(9, choices = $$props.choices); 2519 if ('show_label' in $$props) $$invalidate(10, show_label = $$props.show_label); 2520 if ('filterable' in $$props) $$invalidate(11, filterable = $$props.filterable); 2521 if ('container' in $$props) $$invalidate(12, container = $$props.container); 2522 if ('scale' in $$props) $$invali
2522date(13, scale = $$props.scale); 2523 if ('min_width' in $$props) $$invalidate(14, min_width = $$props.min_width); 2524 if ('loading_status' in $$props) $$invalidate(15, loading_status = $$props.loading_status); 2525 if ('allow_custom_value' in $$props) $$invalidate(16, allow_custom_value = $$props.allow_custom_value); 2526 if ('gradio' in $$props) $$invalidate(17, gradio = $$props.gradio); 2527 if ('interactive' in $$props) $$invalidate(18, interactive = $$props.interactive); 2528 }; 2529 2530 return [ 2531 value, 2532 value_is_output, 2533 label, 2534 info, 2535 elem_id, 2536 elem_classes, 2537 visible, 2538 multiselect, 2539 max_choices, 2540 choices, 2541 show_label, 2542 filterable, 2543 container, 2544 scale, 2545 min_width, 2546 loading_status, 2547 allow_custom_value, 2548 gradio, 2549 interactive, 2550 multiselect_1_value_binding, 2551 multiselect_1_value_is_output_binding, 2552 change_handler, 2553 input_handler, 2554 select_handler, 2555 blur_handler, 2556 focus_handler, 2557 dropdown_value_binding, 2558 dropdown_value_is_output_binding, 2559 change_handler_1, 2560 input_handler_1, 2561 select_handler_1, 2562 blur_handler_1, 2563 focus_handler_1 2564 ]; 2565} 2566 2567class Index extends SvelteComponent { 2568 constructor(options) { 2569 super(); 2570 2571 init( 2572 this, 2573 options, 2574 instance, 2575 create_fragment, 2576 safe_not_equal, 2577 { 2578 label: 2, 2579 info: 3, 2580 elem_id: 4, 2581 elem_classes: 5, 2582 visible: 6, 2583 value: 0, 2584 value_is_output: 1, 2585 multiselect: 7, 2586 max_choices: 8, 2587 choices: 9, 2588 show_label: 10, 2589 filterable: 11, 2590 container: 12, 2591 scale: 13, 2592 min_width: 14, 2593 loading_status: 15, 2594 allow_custom_value: 16, 2595 gradio: 17, 2596 interactive: 18 2597 }, 2598 null, 2599 [-1, -1] 2600 ); 2601 } 2602} 2603 2604export { Dropdown$1 as BaseDropdown, Multiselect$1 as BaseMultiselect, Index as default }; 2605//# sourceMappingURL=Index-2d776cb8.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.