1import { S as Static } from './Index-f4e7a341.js'; 2import { b as fly, B as Block } from './Button-f2ef1e3f.js'; 3import { B as BlockTitle } from './BlockTitle-8e3f82b6.js'; 4import { D as DropdownArrow } from './DropdownArrow-04b836e1.js'; 5export { default as BaseExample } from './Example-d8ab1392.js'; 6import './index-546f83db.js'; 7import './svelte/svelte.js'; 8import './Info-c6eafbfa.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// (185: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-vomtxz"); 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 div3; 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 div3 = element("div"); 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, "role", "listbox"); 1678 attr(input, "aria-controls", "dropdown-options"); 1679 attr(input, "aria-expanded", /*show_options*/ ctx[12]); 1680 attr(input, "aria-label", /*label*/ ctx[0]); 1681 attr(input, "class", "border-none svelte-vomtxz"); 1682 input.disabled = /*disabled*/ ctx[3]; 1683 attr(input, "autocomplete", "off"); 1684 input.readOnly = input_readonly_value = !/*filterable*/ ctx[7];
1685 toggle_class(input, "subdued", !/*choices_names*/ ctx[13].includes(/*input_text*/ ctx[8]) && !/*allow_custom_value*/ ctx[6]); 1686 attr(div0, "class", "secondary-wrap svelte-vomtxz"); 1687 attr(div1, "class", "wrap-inner svelte-vomtxz"); 1688 toggle_class(div1, "show_options", /*show_options*/ ctx[12]); 1689 attr(div2, "class", "wrap svelte-vomtxz"); 1690 attr(div3, "class", "svelte-vomtxz"); 1691 toggle_class(div3, "container", /*container*/ ctx[5]); 1692 }, 1693 m(target, anchor) { 1694 insert$1(target, div3, anchor); 1695 mount_component$1(blocktitle, div3, null); 1696 append(div3, t0); 1697 append(div3, div2); 1698 append(div2, div1); 1699 append(div1, div0); 1700 append(div0, input); 1701 set_input_value(input, /*input_text*/ ctx[8]); 1702 /*input_binding*/ ctx[28](input); 1703 append(div0, t1); 1704 if (if_block) if_block.m(div0, null); 1705 append(div2, t2); 1706 mount_component$1(dropdownoptions, div2, null); 1707 current = true; 1708 1709 if (!mounted) { 1710 dispose = [ 1711 listen(input, "input", /*input_input_handler*/ ctx[27]), 1712 listen(input, "keydown", /*handle_key_down*/ ctx[18]), 1713 listen(input, "blur", /*handle_blur*/ ctx[17]), 1714 listen(input, "focus", /*handle_focus*/ ctx[16]) 1715 ]; 1716 1717 mounted = true; 1718 } 1719 }, 1720 p(ctx, dirty) { 1721 const blocktitle_changes = {}; 1722 if (dirty[0] & /*show_label*/ 16) blocktitle_changes.show_label = /*show_label*/ ctx[4]; 1723 if (dirty[0] & /*info*/ 2) blocktitle_changes.info = /*info*/ ctx[1]; 1724 1725 if (dirty[0] & /*label*/ 1 | dirty[1] & /*$$scope*/ 1) { 1726 blocktitle_changes.$$scope = { dirty, ctx }; 1727 } 1728 1729 blocktitle.$set(blocktitle_changes); 1730 1731 if (!current || dirty[0] & /*show_options*/ 4096) { 1732 attr(input, "aria-expanded", /*show_options*/ ctx[12]); 1733 } 1734 1735 if (!current || dirty[0] & /*label*/ 1) { 1736 attr(input, "aria-label", /*label*/ ctx[0]); 1737 } 1738 1739 if (!current || dirty[0] & /*disabled*/ 8) { 1740 input.disabled = /*disabled*/ ctx[3]; 1741 } 1742 1743 if (!current || dirty[0] & /*filterable*/ 128 && input_readonly_value !== (input_readonly_value = !/*filterable*/ ctx[7])) { 1744 input.readOnly = input_readonly_value; 1745 } 1746 1747 if (dirty[0] & /*input_text*/ 256 && input.value !== /*input_text*/ ctx[8]) { 1748 set_input_value(input, /*input_text*/ ctx[8]); 1749 } 1750 1751 if (!current || dirty[0] & /*choices_names, input_text, allow_custom_value*/ 8512) {
1752 toggle_class(input, "subdued", !/*choices_names*/ ctx[13].includes(/*input_text*/ ctx[8]) && !/*allow_custom_value*/ ctx[6]); 1753 } 1754 1755 if (!/*disabled*/ ctx[3]) { 1756 if (if_block) { 1757 if (dirty[0] & /*disabled*/ 8) { 1758 transition_in$1(if_block, 1); 1759 } 1760 } else { 1761 if_block = create_if_block$1(); 1762 if_block.c(); 1763 transition_in$1(if_block, 1); 1764 if_block.m(div0, null); 1765 } 1766 } else if (if_block) { 1767 group_outros$1(); 1768 1769 transition_out$1(if_block, 1, 1, () => { 1770 if_block = null; 1771 }); 1772 1773 check_outros$1(); 1774 } 1775 1776 if (!current || dirty[0] & /*show_options*/ 4096) { 1777 toggle_class(div1, "show_options", /*show_options*/ ctx[12]); 1778 } 1779 1780 const dropdownoptions_changes = {}; 1781 if (dirty[0] & /*show_options*/ 4096) dropdownoptions_changes.show_options = /*show_options*/ ctx[12]; 1782 if (dirty[0] & /*choices*/ 4) dropdownoptions_changes.choices = /*choices*/ ctx[2]; 1783 if (dirty[0] & /*filtered_indices*/ 512) dropdownoptions_changes.filtered_indices = /*filtered_indices*/ ctx[9]; 1784 if (dirty[0] & /*disabled*/ 8) dropdownoptions_changes.disabled = /*disabled*/ ctx[3]; 1785 1786 if (dirty[0] & /*selected_index*/ 1024) dropdownoptions_changes.selected_indices = /*selected_index*/ ctx[10] === null 1787 ? [] 1788 : [/*selected_index*/ ctx[10]]; 1789 1790 if (dirty[0] & /*active_index*/ 16384) dropdownoptions_changes.active_index = /*active_index*/ ctx[14]; 1791 dropdownoptions.$set(dropdownoptions_changes); 1792 1793 if (!current || dirty[0] & /*container*/ 32) { 1794 toggle_class(div3, "container", /*container*/ ctx[5]); 1795 } 1796 }, 1797 i(local) { 1798 if (current) return; 1799 transition_in$1(blocktitle.$$.fragment, local); 1800 transition_in$1(if_block); 1801 transition_in$1(dropdownoptions.$$.fragment, local); 1802 current = true; 1803 }, 1804 o(local) { 1805 transition_out$1(blocktitle.$$.fragment, local); 1806 transition_out$1(if_block); 1807 transition_out$1(dropdownoptions.$$.fragment, local); 1808 current = false; 1809 }, 1810 d(detaching) { 1811 if (detaching) { 1812 detach$1(div3); 1813 } 1814 1815 destroy_component$1(blocktitle); 1816 /*input_binding*/ ctx[28](null); 1817 if (if_block) if_block.d(); 1818 destroy_component$1(dropdownoptions); 1819 mounted = false; 1820 run_all(dispose); 1821 } 1822 }; 1823} 1824 1825function instance$1($$self, $$props, $$invalidate) { 1826 let { label } = $$props; 1827 let { info = undefined } = $$props; 1828 let { value = [] } = $$props; 1829 let old_value = []; 1830 let { value_is_output = false } = $$props; 1831 let { choices } = $$props; 1832 let old_choices; 1833 let { disabled = false } = $$props; 1834 let { show_label } = $$props; 1835 let { container = true } = $$props; 1836 let { allow_custom_value = false } = $$props; 1837 let { filterable = true } = $$props; 1838 let filter_input; 1839 let show_options = false; 1840 let choices_names; 1841 let choices_values; 1842 let input_text = ""; 1843 let old_input_text = ""; 1844 let initialized = false; 1845 1846 // All of these are indices with respect to the choices array 1847 let filtered_indices = []; 1848 1849 let active_index = null; 1850 1851 // selected_index is null if allow_custom_value is true and the input_text is not in choices_names 1852 let selected_index = null; 1853 1854 let old_selected_index; 1855 const dispatch = createEventDispatcher(); 1856 1857 // Setting the initial value of the dropdown 1858 if (value) { 1859 old_selected_index = choices.map(c => c[1]).indexOf(value); 1860 selected_index = old_selected_index; 1861 1862 if (selected_index === -1) { 1863 old_value = value; 1864 selected_index = null; 1865 } else { 1866 [input_text, old_value] = choices[selected_index]; 1867 old_input_text = input_text; 1868 } 1869 } else if (choices.length > 0) { 1870 old_selected_index = 0; 1871 selected_index = 0; 1872 [input_text, value] = choices[selected_index]; 1873 old_value = value; 1874 old_input_text = input_text; 1875 } 1876 1877 function set_input_text() { 1878 if (value === undefined) { 1879 $$invalidate(8, input_text = ""); 1880 $$invalidate(10, selected_index = null); 1881 } else if (choices_values.includes(value)) { 1882 $$invalidate(8, input_text = choices_names[choices_values.indexOf(value)]); 1883 $$invalidate(10, selected_index = choices_values.indexOf(value)); 1884 } else if (allow_custom_value) { 1885 $$invalidate(8, input_text = value); 1886 $$invalidate(10, selected_index = null); 1887 } else {
1888 $$invalidate(8, input_text = ""); 1889 $$invalidate(10, selected_index = null); 1890 } 1891 1892 $$invalidate(26, old_selected_index = selected_index); 1893 } 1894 1895 function handle_option_selected(e) { 1896 $$invalidate(10, selected_index = parseInt(e.detail.target.dataset.index)); 1897 1898 if (isNaN(selected_index)) { 1899 // This is the case when the user clicks on the scrollbar 1900 $$invalidate(10, selected_index = null); 1901 1902 return; 1903 } 1904 1905 $$invalidate(12, show_options = false); 1906 $$invalidate(14, active_index = null); 1907 filter_input.blur(); 1908 } 1909 1910 function handle_focus(e) { 1911 $$invalidate(9, filtered_indices = choices.map((_, i) => i)); 1912 $$invalidate(12, show_options = true); 1913 dispatch("focus"); 1914 } 1915 1916 function handle_blur() { 1917 if (!allow_custom_value) { 1918 $$invalidate(8, input_text = choices_names[choices_values.indexOf(value)]); 1919 } else { 1920 $$invalidate(19, value = input_text); 1921 } 1922 1923 $$invalidate(12, show_options = false); 1924 $$invalidate(14, active_index = null); 1925 dispatch("blur"); 1926 } 1927 1928 function handle_key_down(e) { 1929 $$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))); 1930 1931 if (e.key === "Enter") { 1932 if (active_index !== null) { 1933 $$invalidate(10, selected_index = active_index); 1934 $$invalidate(12, show_options = false); 1935 filter_input.blur(); 1936 $$invalidate(14, active_index = null); 1937 } else if (choices_names.includes(input_text)) { 1938 $$invalidate(10, selected_index = choices_names.indexOf(input_text)); 1939 $$invalidate(12, show_options = false); 1940 $$invalidate(14, active_index = null); 1941 filter_input.blur(); 1942 } else if (allow_custom_value) { 1943 $$invalidate(19, value = input_text); 1944 $$invalidate(10, selected_index = null); 1945 $$invalidate(12, show_options = false); 1946 $$invalidate(14, active_index = null); 1947 filter_input.blur(); 1948 } 1949 } 1950 } 1951 1952 afterUpdate(() => { 1953 $$invalidate(20, value_is_output = false); 1954 $$invalidate(25, initialized = true); 1955 }); 1956 1957 function input_input_handler() { 1958 input_text = this.value; 1959 ((((($$invalidate(8, input_text), $$invalidate(10, selected_index)), $$invalidate(26, old_selected_index)), $$invalidate(25, initialized)), $$invalidate(2, choices)), $$invalidate(23, choices_values)); 1960 } 1961 1962 function input_binding($$value) { 1963 binding_callbacks$1[$$value ? 'unshift' : 'push'](() => { 1964 filter_input = $$value; 1965 $$invalidate(11, filter_input); 1966 }); 1967 } 1968 1969 $$self.$$set = $$props => {
1970 if ('label' in $$props) $$invalidate(0, label = $$props.label); 1971 if ('info' in $$props) $$invalidate(1, info = $$props.info); 1972 if ('value' in $$props) $$invalidate(19, value = $$props.value); 1973 if ('value_is_output' in $$props) $$invalidate(20, value_is_output = $$props.value_is_output); 1974 if ('choices' in $$props) $$invalidate(2, choices = $$props.choices); 1975 if ('disabled' in $$props) $$invalidate(3, disabled = $$props.disabled); 1976 if ('show_label' in $$props) $$invalidate(4, show_label = $$props.show_label); 1977 if ('container' in $$props) $$invalidate(5, container = $$props.container); 1978 if ('allow_custom_value' in $$props) $$invalidate(6, allow_custom_value = $$props.allow_custom_value); 1979 if ('filterable' in $$props) $$invalidate(7, filterable = $$props.filterable); 1980 }; 1981 1982 $$self.$$.update = () => { 1983 if ($$self.$$.dirty[0] & /*choices*/ 4) { 1984 { 1985 $$invalidate(13, choices_names = choices.map(c => c[0])); 1986 $$invalidate(23, choices_values = choices.map(c => c[1])); 1987 } 1988 } 1989 1990 if ($$self.$$.dirty[0] & /*selected_index, old_selected_index, initialized, choices, choices_values*/ 109052932) { 1991 { 1992 if (selected_index !== old_selected_index && selected_index !== null && initialized) { 1993 $$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))); 1994 $$invalidate(26, old_selected_index = selected_index); 1995 1996 dispatch("select", { 1997 index: selected_index, 1998 value: choices_values[selected_index], 1999 selected: true 2000 }); 2001 } 2002 } 2003 } 2004 2005 if ($$self.$$.dirty[0] & /*value, old_value, value_is_output*/ 3670016) { 2006 { 2007 if (value != old_value) { 2008 set_input_text(); 2009 handle_change(dispatch, value, value_is_output); 2010 $$invalidate(21, old_value = value); 2011 } 2012 } 2013 } 2014 2015 if ($$self.$$.dirty[0] & /*choices, old_choices, input_text, old_input_text, allow_custom_value, filtered_indices*/ 20972356) { 2016 { 2017 if (choices !== old_choices || input_text !== old_input_text) { 2018 $$invalidate(9, filtered_indices = handle_filter(choices, input_text)); 2019 $$invalidate(22, old_choices = choices); 2020 $$invalidate(24, old_input_text = input_text); 2021 2022 if (!allow_custom_value && filtered_indices.length > 0) { 2023 $$invalidate(14, active_index = filtered_indices[0]); 2024 } 2025 } 2026 } 2027 } 2028 }; 2029 2030 return [ 2031 label, 2032 info, 2033 choices, 2034 disabled, 2035 show_label, 2036 container, 2037 allow_custom_value, 2038 filterable, 2039 input_text, 2040 filtered_indices, 2041 selected_index, 2042 filter_input, 2043 show_options, 2044 choices_names, 2045 active_index, 2046 handle_option_selected, 2047 handle_focus, 2048 handle_blur, 2049 handle_key_down, 2050 value, 2051 value_is_output, 2052 old_value, 2053 old_choices, 2054 choices_values, 2055 old_input_text, 2056 initialized, 2057 old_selected_index, 2058 input_input_handler, 2059 input_binding 2060 ]; 2061} 2062 2063class Dropdown extends SvelteComponent$1 { 2064 constructor(options) { 2065 super(); 2066 2067 init$1( 2068 this, 2069 options, 2070 instance$1, 2071 create_fragment$1, 2072 safe_not_equal$1, 2073 { 2074 label: 0, 2075 info: 1, 2076 value: 19, 2077 value_is_output: 20, 2078 choices: 2, 2079 disabled: 3, 2080 show_label: 4, 2081 container: 5, 2082 allow_custom_value: 6, 2083 filterable: 7 2084 }, 2085 null, 2086 [-1, -1] 2087 ); 2088 } 2089} 2090 2091const Dropdown$1 = Dropdown; 2092 2093/* home/runner/work/gradio/gradio/js/dropdown/Index.svelte generated by Svelte v4.2.2 */ 2094const { 2095 SvelteComponent, 2096 add_flush_callback, 2097 assign, 2098 bind, 2099 binding_callbacks, 2100 check_outros, 2101 create_component, 2102 destroy_component, 2103 detach, 2104 empty, 2105 get_spread_object, 2106 get_spread_update, 2107 group_outros, 2108 init, 2109 insert, 2110 mount_component, 2111 safe_not_equal, 2112 space, 2113 transition_in, 2114 transition_out 2115} = window.__gradio__svelte__internal; 2116function create_else_block(ctx) { 2117 let dropdown; 2118 let updating_value; 2119 let updating_value_is_output; 2120 let current; 2121 2122 function dropdown_value_binding(value) { 2123 /*dropdown_value_binding*/ ctx[26](value); 2124 } 2125 2126 function dropdown_value_is_output_binding(value) { 2127 /*dropdown_value_is_output_binding*/ ctx[27](value); 2128 } 2129 2130 let dropdown_props = { 2131 choices: /*choices*/ ctx[9], 2132 label: /*label*/ ctx[2], 2133 info: /*info*/ ctx[3], 2134 show_label: /*show_label*/ ctx[10], 2135 filterable: /*filterable*/ ctx[11], 2136 allow_custom_value: /*allow_custom_value*/ ctx[16], 2137 container: /*container*/ ctx[12], 2138 disabled: !/*interactive*/ ctx[18] 2139 }; 2140 2141 if (/*value*/ ctx[0] !== void 0) { 2142 dropdown_props.value = /*value*/ ctx[0]; 2143 } 2144 2145 if (/*value_is_output*/ ctx[1] !== void 0) { 2146 dropdown_props.value_is_output = /*value_is_output*/ ctx[1]; 2147 } 2148 2149 dropdown = new Dropdown$1({ props: dropdown_props }); 2150 binding_callbacks.push(() => bind(dropdown, 'value', dropdown_value_binding)); 2151 binding_callbacks.push(() => bind(dropdown, 'value_is_output', dropdown_value_is_output_binding)); 2152 dropdown.$on("change", /*change_handler_1*/ ctx[28]); 2153 dropdown.$on("input", /*input_handler_1*/ ctx[29]); 2154 dropdown.$on("select", /*select_handler_1*/ ctx[30]); 2155 dropdown.$on("blur", /*blur_handler_1*/ ctx[31]); 2156 dropdown.$on("focus", /*focus_handler_1*/ ctx[32]); 2157 2158 return { 2159 c() { 2160 create_component(dropdown.$$.fragment); 2161 }, 2162 m(target, anchor) { 2163 mount_component(dropdown, target, anchor); 2164 current = true; 2165 }, 2166 p(ctx, dirty) { 2167 const dropdown_changes = {};
2168 if (dirty[0] & /*choices*/ 512) dropdown_changes.choices = /*choices*/ ctx[9]; 2169 if (dirty[0] & /*label*/ 4) dropdown_changes.label = /*label*/ ctx[2]; 2170 if (dirty[0] & /*info*/ 8) dropdown_changes.info = /*info*/ ctx[3]; 2171 if (dirty[0] & /*show_label*/ 1024) dropdown_changes.show_label = /*show_label*/ ctx[10]; 2172 if (dirty[0] & /*filterable*/ 2048) dropdown_changes.filterable = /*filterable*/ ctx[11]; 2173 if (dirty[0] & /*allow_custom_value*/ 65536) dropdown_changes.allow_custom_value = /*allow_custom_value*/ ctx[16]; 2174 if (dirty[0] & /*container*/ 4096) dropdown_changes.container = /*container*/ ctx[12]; 2175 if (dirty[0] & /*interactive*/ 262144) dropdown_changes.disabled = !/*interactive*/ ctx[18]; 2176 2177 if (!updating_value && dirty[0] & /*value*/ 1) { 2178 updating_value = true; 2179 dropdown_changes.value = /*value*/ ctx[0]; 2180 add_flush_callback(() => updating_value = false); 2181 } 2182 2183 if (!updating_value_is_output && dirty[0] & /*value_is_output*/ 2) { 2184 updating_value_is_output = true; 2185 dropdown_changes.value_is_output = /*value_is_output*/ ctx[1]; 2186 add_flush_callback(() => updating_value_is_output = false); 2187 } 2188 2189 dropdown.$set(dropdown_changes); 2190 }, 2191 i(local) { 2192 if (current) return; 2193 transition_in(dropdown.$$.fragment, local); 2194 current = true; 2195 }, 2196 o(local) { 2197 transition_out(dropdown.$$.fragment, local); 2198 current = false; 2199 }, 2200 d(detaching) { 2201 destroy_component(dropdown, detaching); 2202 } 2203 }; 2204} 2205 2206// (46:1) {#if multiselect} 2207function create_if_block(ctx) { 2208 let multiselect_1; 2209 let updating_value; 2210 let updating_value_is_output; 2211 let current; 2212 2213 function multiselect_1_value_binding(value) { 2214 /*multiselect_1_value_binding*/ ctx[19](value); 2215 } 2216 2217 function multiselect_1_value_is_output_binding(value) { 2218 /*multiselect_1_value_is_output_binding*/ ctx[20](value); 2219 } 2220 2221 let multiselect_1_props = { 2222 choices: /*choices*/ ctx[9], 2223 max_choices: /*max_choices*/ ctx[8], 2224 label: /*label*/ ctx[2], 2225 info: /*info*/ ctx[3], 2226 show_label: /*show_label*/ ctx[10], 2227 allow_custom_value: /*allow_custom_value*/ ctx[16], 2228 filterable: /*filterable*/ ctx[11], 2229 container: /*container*/ ctx[12], 2230 i18n: /*gradio*/ ctx[17].i18n, 2231 disabled: !/*interactive*/ ctx[18] 2232 }; 2233 2234 if (/*value*/ ctx[0] !== void 0) { 2235 multiselect_1_props.value = /*value*/ ctx[0]; 2236 } 2237 2238 if (/*value_is_output*/ ctx[1] !== void 0) { 2239 multiselect_1_props.value_is_output = /*value_is_output*/ ctx[1]; 2240 } 2241 2242 multiselect_1 = new Multiselect$1({ props: multiselect_1_props }); 2243 binding_callbacks.push(() => bind(multiselect_1, 'value', multiselect_1_value_binding)); 2244 binding_callbacks.push(() => bind(multiselect_1, 'value_is_output', multiselect_1_value_is_output_binding)); 2245 multiselect_1.$on("change", /*change_handler*/ ctx[21]); 2246 multiselect_1.$on("input", /*input_handler*/ ctx[22]); 2247 multiselect_1.$on("select", /*select_handler*/ ctx[23]); 2248 multiselect_1.$on("blur", /*blur_handler*/ ctx[24]); 2249 multiselect_1.$on("focus", /*focus_handler*/ ctx[25]); 2250 2251 return { 2252 c() { 2253 create_component(multiselect_1.$$.fragment); 2254 }, 2255 m(target, anchor) { 2256 mount_component(multiselect_1, target, anchor); 2257 current = true; 2258 }, 2259 p(ctx, dirty) { 2260 const multiselect_1_changes = {}; 2261 if (dirty[0] & /*choices*/ 512) multiselect_1_changes.choices = /*choices*/ ctx[9]; 2262 if (dirty[0] & /*max_choices*/ 256) multiselect_1_changes.max_choices = /*max_choices*/ ctx[8]; 2263 if (dirty[0] & /*label*/ 4) multiselect_1_changes.label = /*label*/ ctx[2]; 2264 if (dirty[0] & /*info*/ 8) multiselect_1_changes.info = /*info*/ ctx[3]; 2265 if (dirty[0] & /*show_label*/ 1024) multiselect_1_changes.show_label = /*show_label*/ ctx[10]; 2266 if (dirty[0] & /*allow_custom_value*/ 65536) multiselect_1_changes.allow_custom_value = /*allow_custom_value*/ ctx[16]; 2267 if (dirty[0] & /*filterable*/ 2048) multiselect_1_changes.filterable = /*filterable*/ ctx[11]; 2268 if (dirty[0] & /*container*/ 4096) multiselect_1_changes.container = /*container*/ ctx[12]; 2269 if (dirty[0] & /*gradio*/ 131072) multiselect_1_changes.i18n = /*gradio*/ ctx[17].i18n; 2270 if (dirty[0] & /*interactive*/ 262144) multiselect_1_changes.disabled = !/*interactive*/ ctx[18]; 2271 2272 if (!updating_value && dirty[0] & /*value*/ 1) { 2273 updating_value = true; 2274 multiselect_1_changes.value = /*value*/ ctx[0]; 2275 add_flush_callback(() => updating_value = false); 2276 } 2277 2278 if (!updating_value_is_output && dirty[0] & /*value_is_output*/ 2) { 2279 updating_value_is_output = true; 2280 multiselect_1_changes.value_is_output = /*value_is_output*/ ctx[1]; 2281 add_flush_callback(() => updating_value_is_output = false); 2282 } 2283 2284 multiselect_1.$set(multiselect_1_changes); 2285 }, 2286 i(local) { 2287 if (current) return; 2288 transition_in(multiselect_1.$$.fragment, local); 2289 current = true; 2290 }, 2291 o(local) { 2292 transition_out(multiselect_1.$$.fragment, local); 2293 current = false;
2294 }, 2295 d(detaching) { 2296 destroy_component(multiselect_1, detaching); 2297 } 2298 }; 2299} 2300 2301// (31:0) <Block {visible} {elem_id} {elem_classes} padding={container} allow_overflow={false} {scale} {min_width} > 2302function create_default_slot(ctx) { 2303 let statustracker; 2304 let t; 2305 let current_block_type_index; 2306 let if_block; 2307 let if_block_anchor; 2308 let current; 2309 2310 const statustracker_spread_levels = [ 2311 { 2312 autoscroll: /*gradio*/ ctx[17].autoscroll 2313 }, 2314 { i18n: /*gradio*/ ctx[17].i18n }, 2315 /*loading_status*/ ctx[15] 2316 ]; 2317 2318 let statustracker_props = {}; 2319 2320 for (let i = 0; i < statustracker_spread_levels.length; i += 1) { 2321 statustracker_props = assign(statustracker_props, statustracker_spread_levels[i]); 2322 } 2323 2324 statustracker = new Static({ props: statustracker_props }); 2325 const if_block_creators = [create_if_block, create_else_block]; 2326 const if_blocks = []; 2327 2328 function select_block_type(ctx, dirty) { 2329 if (/*multiselect*/ ctx[7]) return 0; 2330 return 1; 2331 } 2332 2333 current_block_type_index = select_block_type(ctx); 2334 if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); 2335 2336 return { 2337 c() { 2338 create_component(statustracker.$$.fragment); 2339 t = space(); 2340 if_block.c(); 2341 if_block_anchor = empty(); 2342 }, 2343 m(target, anchor) { 2344 mount_component(statustracker, target, anchor); 2345 insert(target, t, anchor); 2346 if_blocks[current_block_type_index].m(target, anchor); 2347 insert(target, if_block_anchor, anchor); 2348 current = true; 2349 }, 2350 p(ctx, dirty) { 2351 const statustracker_changes = (dirty[0] & /*gradio, loading_status*/ 163840) 2352 ? get_spread_update(statustracker_spread_levels, [ 2353 dirty[0] & /*gradio*/ 131072 && { 2354 autoscroll: /*gradio*/ ctx[17].autoscroll 2355 }, 2356 dirty[0] & /*gradio*/ 131072 && { i18n: /*gradio*/ ctx[17].i18n }, 2357 dirty[0] & /*loading_status*/ 32768 && get_spread_object(/*loading_status*/ ctx[15]) 2358 ]) 2359 : {}; 2360 2361 statustracker.$set(statustracker_changes); 2362 let previous_block_index = current_block_type_index; 2363 current_block_type_index = select_block_type(ctx); 2364 2365 if (current_block_type_index === previous_block_index) { 2366 if_blocks[current_block_type_index].p(ctx, dirty); 2367 } else { 2368 group_outros(); 2369 2370 transition_out(if_blocks[previous_block_index], 1, 1, () => { 2371 if_blocks[previous_block_index] = null; 2372 }); 2373 2374 check_outros(); 2375 if_block = if_blocks[current_block_type_index]; 2376 2377 if (!if_block) { 2378 if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); 2379 if_block.c(); 2380 } else { 2381 if_block.p(ctx, dirty); 2382 } 2383 2384 transition_in(if_block, 1); 2385 if_block.m(if_block_anchor.parentNode, if_block_anchor); 2386 } 2387 }, 2388 i(local) { 2389 if (current) return; 2390 transition_in(statustracker.$$.fragment, local); 2391 transition_in(if_block); 2392 current = true; 2393 }, 2394 o(local) { 2395 transition_out(statustracker.$$.fragment, local); 2396 transition_out(if_block); 2397 current = false; 2398 }, 2399 d(detaching) { 2400 if (detaching) { 2401 detach(t); 2402 detach(if_block_anchor); 2403 } 2404 2405 destroy_component(statustracker, detaching); 2406 if_blocks[current_block_type_index].d(detaching); 2407 } 2408 }; 2409} 2410 2411function create_fragment(ctx) { 2412 let block; 2413 let current; 2414 2415 block = new Block({ 2416 props: { 2417 visible: /*visible*/ ctx[6], 2418 elem_id: /*elem_id*/ ctx[4], 2419 elem_classes: /*elem_classes*/ ctx[5], 2420 padding: /*container*/ ctx[12], 2421 allow_overflow: false, 2422 scale: /*scale*/ ctx[13], 2423 min_width: /*min_width*/ ctx[14], 2424 $$slots: { default: [create_default_slot] }, 2425 $$scope: { ctx } 2426 } 2427 }); 2428 2429 return { 2430 c() { 2431 create_component(block.$$.fragment); 2432 }, 2433 m(target, anchor) { 2434 mount_component(block, target, anchor); 2435 current = true; 2436 }, 2437 p(ctx, dirty) { 2438 const block_changes = {}; 2439 if (dirty[0] & /*visible*/ 64) block_changes.visible = /*visible*/ ctx[6]; 2440 if (dirty[0] & /*elem_id*/ 16) block_changes.elem_id = /*elem_id*/ ctx[4]; 2441 if (dirty[0] & /*elem_classes*/ 32) block_changes.elem_classes = /*elem_classes*/ ctx[5]; 2442 if (dirty[0] & /*container*/ 4096) block_changes.padding = /*container*/ ctx[12];
2443 if (dirty[0] & /*scale*/ 8192) block_changes.scale = /*scale*/ ctx[13]; 2444 if (dirty[0] & /*min_width*/ 16384) block_changes.min_width = /*min_width*/ ctx[14]; 2445 2446 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) { 2447 block_changes.$$scope = { dirty, ctx }; 2448 } 2449 2450 block.$set(block_changes); 2451 }, 2452 i(local) { 2453 if (current) return; 2454 transition_in(block.$$.fragment, local); 2455 current = true; 2456 }, 2457 o(local) { 2458 transition_out(block.$$.fragment, local); 2459 current = false; 2460 }, 2461 d(detaching) { 2462 destroy_component(block, detaching); 2463 } 2464 }; 2465} 2466 2467function instance($$self, $$props, $$invalidate) { 2468 let { label = "Dropdown" } = $$props; 2469 let { info = undefined } = $$props; 2470 let { elem_id = "" } = $$props; 2471 let { elem_classes = [] } = $$props; 2472 let { visible = true } = $$props; 2473 let { value } = $$props; 2474 let { value_is_output = false } = $$props; 2475 let { multiselect = false } = $$props; 2476 let { max_choices = null } = $$props; 2477 let { choices } = $$props; 2478 let { show_label } = $$props; 2479 let { filterable } = $$props; 2480 let { container = true } = $$props; 2481 let { scale = null } = $$props; 2482 let { min_width = undefined } = $$props; 2483 let { loading_status } = $$props; 2484 let { allow_custom_value = false } = $$props; 2485 let { gradio } = $$props; 2486 let { interactive } = $$props; 2487 2488 function multiselect_1_value_binding(value$1) { 2489 value = value$1; 2490 $$invalidate(0, value); 2491 } 2492 2493 function multiselect_1_value_is_output_binding(value) { 2494 value_is_output = value; 2495 $$invalidate(1, value_is_output); 2496 } 2497 2498 const change_handler = () => gradio.dispatch("change"); 2499 const input_handler = () => gradio.dispatch("input"); 2500 const select_handler = e => gradio.dispatch("select", e.detail); 2501 const blur_handler = () => gradio.dispatch("blur"); 2502 const focus_handler = () => gradio.dispatch("focus"); 2503 2504 function dropdown_value_binding(value$1) { 2505 value = value$1; 2506 $$invalidate(0, value); 2507 } 2508 2509 function dropdown_value_is_output_binding(value) { 2510 value_is_output = value; 2511 $$invalidate(1, value_is_output); 2512 } 2513 2514 const change_handler_1 = () => gradio.dispatch("change"); 2515 const input_handler_1 = () => gradio.dispatch("input"); 2516 const select_handler_1 = e => gradio.dispatch("select", e.detail); 2517 const blur_handler_1 = () => gradio.dispatch("blur"); 2518 const focus_handler_1 = () => gradio.dispatch("focus"); 2519 2520 $$self.$$set = $$props => {
2521 if ('label' in $$props) $$invalidate(2, label = $$props.label); 2522 if ('info' in $$props) $$invalidate(3, info = $$props.info); 2523 if ('elem_id' in $$props) $$invalidate(4, elem_id = $$props.elem_id); 2524 if ('elem_classes' in $$props) $$invalidate(5, elem_classes = $$props.elem_classes); 2525 if ('visible' in $$props) $$invalidate(6, visible = $$props.visible); 2526 if ('value' in $$props) $$invalidate(0, value = $$props.value); 2527 if ('value_is_output' in $$props) $$invalidate(1, value_is_output = $$props.value_is_output); 2528 if ('multiselect' in $$props) $$invalidate(7, multiselect = $$props.multiselect); 2529 if ('max_choices' in $$props) $$invalidate(8, max_choices = $$props.max_choices); 2530 if ('choices' in $$props) $$invalidate(9, choices = $$props.choices); 2531 if ('show_label' in $$props) $$invalidate(10, show_label = $$props.show_label); 2532 if ('filterable' in $$props) $$invalidate(11, filterable = $$props.filterable); 2533 if ('container' in $$props) $$invalidate(12, container = $$props.container); 2534 if ('scale' in $$props) $$invali
2534date(13, scale = $$props.scale); 2535 if ('min_width' in $$props) $$invalidate(14, min_width = $$props.min_width); 2536 if ('loading_status' in $$props) $$invalidate(15, loading_status = $$props.loading_status); 2537 if ('allow_custom_value' in $$props) $$invalidate(16, allow_custom_value = $$props.allow_custom_value); 2538 if ('gradio' in $$props) $$invalidate(17, gradio = $$props.gradio); 2539 if ('interactive' in $$props) $$invalidate(18, interactive = $$props.interactive); 2540 }; 2541 2542 return [ 2543 value, 2544 value_is_output, 2545 label, 2546 info, 2547 elem_id, 2548 elem_classes, 2549 visible, 2550 multiselect, 2551 max_choices, 2552 choices, 2553 show_label, 2554 filterable, 2555 container, 2556 scale, 2557 min_width, 2558 loading_status, 2559 allow_custom_value, 2560 gradio, 2561 interactive, 2562 multiselect_1_value_binding, 2563 multiselect_1_value_is_output_binding, 2564 change_handler, 2565 input_handler, 2566 select_handler, 2567 blur_handler, 2568 focus_handler, 2569 dropdown_value_binding, 2570 dropdown_value_is_output_binding, 2571 change_handler_1, 2572 input_handler_1, 2573 select_handler_1, 2574 blur_handler_1, 2575 focus_handler_1 2576 ]; 2577} 2578 2579class Index extends SvelteComponent { 2580 constructor(options) { 2581 super(); 2582 2583 init( 2584 this, 2585 options, 2586 instance, 2587 create_fragment, 2588 safe_not_equal, 2589 { 2590 label: 2, 2591 info: 3, 2592 elem_id: 4, 2593 elem_classes: 5, 2594 visible: 6, 2595 value: 0, 2596 value_is_output: 1, 2597 multiselect: 7, 2598 max_choices: 8, 2599 choices: 9, 2600 show_label: 10, 2601 filterable: 11, 2602 container: 12, 2603 scale: 13, 2604 min_width: 14, 2605 loading_status: 15, 2606 allow_custom_value: 16, 2607 gradio: 17, 2608 interactive: 18 2609 }, 2610 null, 2611 [-1, -1] 2612 ); 2613 } 2614} 2615 2616export { Dropdown$1 as BaseDropdown, Multiselect$1 as BaseMultiselect, Index as default }; 2617//# sourceMappingURL=Index-bbc7cbab.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.