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