1import { B as Block } from './Button-0502e555.js'; 2import { B as BlockTitle } from './BlockTitle-a8a324e7.js'; 3import { S as Static } from './Index-4c82ea7b.js'; 4export { default as BaseExample } from './Example-b79eee1b.js'; 5import './index-7f1ea29b.js'; 6import './svelte/svelte.js'; 7import './Info-2d9cfe3f.js'; 8 9const Radio_svelte_svelte_type_style_lang = ''; 10 11/* home/runner/work/gradio/gradio/js/radio/shared/Radio.svelte generated by Svelte v4.2.2 */ 12const { 13 SvelteComponent: SvelteComponent$1, 14 append, 15 attr: attr$1, 16 detach: detach$1, 17 element: element$1, 18 init: init$1, 19 init_binding_group, 20 insert: insert$1, 21 listen, 22 noop, 23 safe_not_equal: safe_not_equal$1, 24 set_data: set_data$1, 25 set_input_value, 26 space: space$1, 27 text: text$1, 28 toggle_class 29} = window.__gradio__svelte__internal; 30const { createEventDispatcher } = window.__gradio__svelte__internal; 31function create_fragment$1(ctx) { 32 let label; 33 let input; 34 let value_has_changed = false; 35 let t0; 36 let span; 37 let t1; 38 let label_data_testid_value; 39 let binding_group; 40 let mounted; 41 let dispose; 42 binding_group = init_binding_group(/*$$binding_groups*/ ctx[6][0]); 43 44 return { 45 c() { 46 label = element$1("label"); 47 input = element$1("input"); 48 t0 = space$1(); 49 span = element$1("span"); 50 t1 = text$1(/*display_value*/ ctx[1]); 51 input.disabled = /*disabled*/ ctx[3]; 52 attr$1(input, "type", "radio"); 53 attr$1(input, "name", "radio-" + ++id); 54 input.__value = /*internal_value*/ ctx[2]; 55 set_input_value(input, input.__value); 56 attr$1(input, "class", "svelte-1mhtq7j"); 57 attr$1(span, "class", "ml-2 svelte-1mhtq7j"); 58 attr$1(label, "data-testid", label_data_testid_value = "" + (/*display_value*/ ctx[1] + "-radio-label")); 59 attr$1(label, "class", "svelte-1mhtq7j"); 60 toggle_class(label, "disabled", /*disabled*/ ctx[3]); 61 toggle_class(label, "selected", /*is_selected*/ ctx[4]); 62 binding_group.p(input); 63 }, 64 m(target, anchor) { 65 insert$1(target, label, anchor); 66 append(label, input); 67 input.checked = input.__value === /*selected*/ ctx[0]; 68 append(label, t0); 69 append(label, span); 70 append(span, t1); 71 72 if (!mounted) { 73 dispose = listen(input, "change", /*input_change_handler*/ ctx[5]); 74 mounted = true; 75 } 76 }, 77 p(ctx, [dirty]) { 78 if (dirty & /*disabled*/ 8) { 79 input.disabled = /*disabled*/ ctx[3]; 80 } 81 82 if (dirty & /*internal_value*/ 4) { 83 input.__value = /*internal_value*/ ctx[2]; 84 set_input_value(input, input.__value); 85 value_has_changed = true; 86 } 87 88 if (value_has_changed || dirty & /*selected*/ 1) { 89 input.checked = input.__value === /*selected*/ ctx[0]; 90 } 91 92 if (dirty & /*display_value*/ 2) set_data$1(t1, /*display_value*/ ctx[1]); 93 94 if (dirty & /*display_value*/ 2 && label_data_testid_value !== (label_data_testid_value = "" + (/*display_value*/ ctx[1] + "-radio-label"))) { 95 attr$1(label, "data-testid", label_data_testid_value); 96 } 97 98 if (dirty & /*disabled*/ 8) { 99 toggle_class(label, "disabled", /*disabled*/ ctx[3]); 100 } 101 102 if (dirty & /*is_selected*/ 16) { 103 toggle_class(label, "selected", /*is_selected*/ ctx[4]); 104 } 105 }, 106 i: noop, 107 o: noop, 108 d(detaching) { 109 if (detaching) { 110 detach$1(label); 111 } 112 113 binding_group.r(); 114 mounted = false; 115 dispose(); 116 } 117 }; 118} 119 120let id = 0; 121 122function instance$1($$self, $$props, $$invalidate) { 123 let { display_value } = $$props; 124 let { internal_value } = $$props; 125 let { disabled = false } = $$props; 126 let { selected = null } = $$props; 127 const dispatch = createEventDispatcher(); 128 let is_selected = false; 129 130 async function handle_input(selected, internal_value) { 131 $$invalidate(4, is_selected = selected === internal_value); 132 133 if (is_selected) { 134 dispatch("input", internal_value); 135 } 136 } 137 138 const $$binding_groups = [[]]; 139 140 function input_change_handler() { 141 selected = this.__value; 142 $$invalidate(0, selected); 143 } 144 145 $$self.$$set = $$props => {
146 if ('display_value' in $$props) $$invalidate(1, display_value = $$props.display_value); 147 if ('internal_value' in $$props) $$invalidate(2, internal_value = $$props.internal_value); 148 if ('disabled' in $$props) $$invalidate(3, disabled = $$props.disabled); 149 if ('selected' in $$props) $$invalidate(0, selected = $$props.selected); 150 }; 151 152 $$self.$$.update = () => { 153 if ($$self.$$.dirty & /*selected, internal_value*/ 5) { 154 handle_input(selected, internal_value); 155 } 156 }; 157 158 return [ 159 selected, 160 display_value, 161 internal_value, 162 disabled, 163 is_selected, 164 input_change_handler, 165 $$binding_groups 166 ]; 167} 168 169class Radio extends SvelteComponent$1 { 170 constructor(options) { 171 super(); 172 173 init$1(this, options, instance$1, create_fragment$1, safe_not_equal$1, { 174 display_value: 1, 175 internal_value: 2, 176 disabled: 3, 177 selected: 0 178 }); 179 } 180} 181 182const BaseRadio = Radio; 183 184const Index_svelte_svelte_type_style_lang = ''; 185 186/* home/runner/work/gradio/gradio/js/radio/Index.svelte generated by Svelte v4.2.2 */ 187const { 188 SvelteComponent, 189 add_flush_callback, 190 assign, 191 attr, 192 bind, 193 binding_callbacks, 194 check_outros, 195 create_component, 196 destroy_component, 197 detach, 198 element, 199 empty, 200 ensure_array_like, 201 get_spread_object, 202 get_spread_update, 203 group_outros, 204 init, 205 insert, 206 mount_component, 207 outro_and_destroy_block, 208 safe_not_equal, 209 set_data, 210 space, 211 text, 212 transition_in, 213 transition_out, 214 update_keyed_each 215} = window.__gradio__svelte__internal; 216const { afterUpdate } = window.__gradio__svelte__internal; 217function get_each_context(ctx, list, i) { 218 const child_ctx = ctx.slice(); 219 child_ctx[19] = list[i][0]; 220 child_ctx[20] = list[i][1]; 221 child_ctx[22] = i; 222 return child_ctx; 223} 224 225// (52:1) <BlockTitle {show_label} {info}> 226function create_default_slot_1(ctx) { 227 let t; 228 229 return { 230 c() { 231 t = text(/*label*/ ctx[2]); 232 }, 233 m(target, anchor) { 234 insert(target, t, anchor); 235 }, 236 p(ctx, dirty) { 237 if (dirty & /*label*/ 4) set_data(t, /*label*/ ctx[2]); 238 }, 239 d(detaching) { 240 if (detaching) { 241 detach(t); 242 } 243 } 244 }; 245} 246 247// (55:2) {#each choices as [display_value, internal_value], i (i)} 248function create_each_block(key_1, ctx) { 249 let first; 250 let baseradio; 251 let updating_selected; 252 let current; 253 254 function baseradio_selected_binding(value) { 255 /*baseradio_selected_binding*/ ctx[16](value); 256 } 257 258 function input_handler() { 259 return /*input_handler*/ ctx[17](/*internal_value*/ ctx[20], /*i*/ ctx[22]); 260 } 261 262 let baseradio_props = { 263 display_value: /*display_value*/ ctx[19], 264 internal_value: /*internal_value*/ ctx[20], 265 disabled: /*disabled*/ ctx[13] 266 }; 267 268 if (/*value*/ ctx[0] !== void 0) { 269 baseradio_props.selected = /*value*/ ctx[0]; 270 } 271 272 baseradio = new BaseRadio({ props: baseradio_props }); 273 binding_callbacks.push(() => bind(baseradio, 'selected', baseradio_selected_binding)); 274 baseradio.$on("input", input_handler); 275 276 return { 277 key: key_1, 278 first: null, 279 c() { 280 first = empty(); 281 create_component(baseradio.$$.fragment); 282 this.first = first; 283 }, 284 m(target, anchor) { 285 insert(target, first, anchor); 286 mount_component(baseradio, target, anchor); 287 current = true; 288 }, 289 p(new_ctx, dirty) { 290 ctx = new_ctx; 291 const baseradio_changes = {}; 292 if (dirty & /*choices*/ 128) baseradio_changes.display_value = /*display_value*/ ctx[19]; 293 if (dirty & /*choices*/ 128) baseradio_changes.internal_value = /*internal_value*/ ctx[20]; 294 if (dirty & /*disabled*/ 8192) baseradio_changes.disabled = /*disabled*/ ctx[13]; 295 296 if (!updating_selected && dirty & /*value*/ 1) { 297 updating_selected = true; 298 baseradio_changes.selected = /*value*/ ctx[0]; 299 add_flush_callback(() => updating_selected = false); 300 } 301 302 baseradio.$set(baseradio_changes); 303 }, 304 i(local) { 305 if (current) return; 306 transition_in(baseradio.$$.fragment, local); 307 current = true; 308 }, 309 o(local) { 310 transition_out(baseradio.$$.fragment, local); 311 current = false; 312 }, 313 d(detaching) { 314 if (detaching) { 315 detach(first); 316 } 317 318 destroy_component(baseradio, detaching); 319 } 320 }; 321} 322 323// (37:0) <Block {visible} type="fieldset" {elem_id} {elem_classes} {container} {scale} {min_width} > 324function create_default_slot(ctx) { 325 let statustracker; 326 let t0; 327 let blocktitle; 328 let t1; 329 let div; 330 let each_blocks = []; 331 let each_1_lookup = new Map(); 332 let current; 333 334 const statustracker_spread_levels = [ 335 { autoscroll: /*gradio*/ ctx[1].autoscroll }, 336 { i18n: /*gradio*/ ctx[1].i18n }, 337 /*loading_status*/ ctx[12] 338 ]; 339 340 let statustracker_props = {}; 341 342 for (let i = 0; i < statustracker_spread_levels.length; i += 1) { 343 statustracker_props = assign(statustracker_props, statustracker_spread_levels[i]); 344 } 345 346 statustracker = new Static({ props: statustracker_props }); 347 348 blocktitle = new BlockTitle({ 349 props: { 350 show_label: /*show_label*/ ctx[8], 351 info: /*info*/ ctx[3], 352 $$slots: { default: [create_default_slot_1] }, 353 $$scope: { ctx } 354 } 355 }); 356 357 let each_value = ensure_array_like(/*choices*/ ctx[7]); 358 const get_key = ctx => /*i*/ ctx[22]; 359 360 for (let i = 0; i < each_value.length; i += 1) { 361 let child_ctx = get_each_context(ctx, each_value, i); 362 let key = get_key(child_ctx); 363 each_1_lookup.set(key, each_blocks[i] = create_each_block(key, child_ctx)); 364 } 365 366 return { 367 c() { 368 create_component(statustracker.$$.fragment); 369 t0 = space(); 370 create_component(blocktitle.$$.fragment); 371 t1 = space(); 372 div = element("div"); 373 374 for (let i = 0; i < each_blocks.length; i += 1) { 375 each_blocks[i].c(); 376 } 377 378 attr(div, "class", "wrap svelte-1kzox3m"); 379 }, 380 m(target, anchor) { 381 mount_component(statustracker, target, anchor); 382 insert(target, t0, anchor);
383 mount_component(blocktitle, target, anchor); 384 insert(target, t1, anchor); 385 insert(target, div, anchor); 386 387 for (let i = 0; i < each_blocks.length; i += 1) { 388 if (each_blocks[i]) { 389 each_blocks[i].m(div, null); 390 } 391 } 392 393 current = true; 394 }, 395 p(ctx, dirty) { 396 const statustracker_changes = (dirty & /*gradio, loading_status*/ 4098) 397 ? get_spread_update(statustracker_spread_levels, [ 398 dirty & /*gradio*/ 2 && { autoscroll: /*gradio*/ ctx[1].autoscroll }, 399 dirty & /*gradio*/ 2 && { i18n: /*gradio*/ ctx[1].i18n }, 400 dirty & /*loading_status*/ 4096 && get_spread_object(/*loading_status*/ ctx[12]) 401 ]) 402 : {}; 403 404 statustracker.$set(statustracker_changes); 405 const blocktitle_changes = {}; 406 if (dirty & /*show_label*/ 256) blocktitle_changes.show_label = /*show_label*/ ctx[8]; 407 if (dirty & /*info*/ 8) blocktitle_changes.info = /*info*/ ctx[3]; 408 409 if (dirty & /*$$scope, label*/ 8388612) { 410 blocktitle_changes.$$scope = { dirty, ctx }; 411 } 412 413 blocktitle.$set(blocktitle_changes); 414 415 if (dirty & /*choices, disabled, value, gradio*/ 8323) { 416 each_value = ensure_array_like(/*choices*/ ctx[7]); 417 group_outros(); 418 each_blocks = update_keyed_each(each_blocks, dirty, get_key, 1, ctx, each_value, each_1_lookup, div, outro_and_destroy_block, create_each_block, null, get_each_context); 419 check_outros(); 420 } 421 }, 422 i(local) { 423 if (current) return; 424 transition_in(statustracker.$$.fragment, local); 425 transition_in(blocktitle.$$.fragment, local); 426 427 for (let i = 0; i < each_value.length; i += 1) { 428 transition_in(each_blocks[i]); 429 } 430 431 current = true; 432 }, 433 o(local) { 434 transition_out(statustracker.$$.fragment, local); 435 transition_out(blocktitle.$$.fragment, local); 436 437 for (let i = 0; i < each_blocks.length; i += 1) { 438 transition_out(each_blocks[i]); 439 } 440 441 current = false; 442 }, 443 d(detaching) { 444 if (detaching) { 445 detach(t0); 446 detach(t1); 447 detach(div); 448 } 449 450 destroy_component(statustracker, detaching); 451 destroy_component(blocktitle, detaching); 452 453 for (let i = 0; i < each_blocks.length; i += 1) { 454 each_blocks[i].d(); 455 } 456 } 457 }; 458} 459 460function create_fragment(ctx) { 461 let block; 462 let current; 463 464 block = new Block({ 465 props: { 466 visible: /*visible*/ ctx[6], 467 type: "fieldset", 468 elem_id: /*elem_id*/ ctx[4], 469 elem_classes: /*elem_classes*/ ctx[5], 470 container: /*container*/ ctx[9], 471 scale: /*scale*/ ctx[10], 472 min_width: /*min_width*/ ctx[11], 473 $$slots: { default: [create_default_slot] }, 474 $$scope: { ctx } 475 } 476 }); 477 478 return { 479 c() { 480 create_component(block.$$.fragment); 481 }, 482 m(target, anchor) { 483 mount_component(block, target, anchor); 484 current = true; 485 }, 486 p(ctx, [dirty]) { 487 const block_changes = {}; 488 if (dirty & /*visible*/ 64) block_changes.visible = /*visible*/ ctx[6]; 489 if (dirty & /*elem_id*/ 16) block_changes.elem_id = /*elem_id*/ ctx[4]; 490 if (dirty & /*elem_classes*/ 32) block_changes.elem_classes = /*elem_classes*/ ctx[5]; 491 if (dirty & /*container*/ 512) block_changes.container = /*container*/ ctx[9]; 492 if (dirty & /*scale*/ 1024) block_changes.scale = /*scale*/ ctx[10]; 493 if (dirty & /*min_width*/ 2048) block_changes.min_width = /*min_width*/ ctx[11]; 494 495 if (dirty & /*$$scope, choices, disabled, value, gradio, show_label, info, label, loading_status*/ 8401295) { 496 block_changes.$$scope = { dirty, ctx }; 497 } 498 499 block.$set(block_changes); 500 }, 501 i(local) { 502 if (current) return; 503 transition_in(block.$$.fragment, local); 504 current = true; 505 }, 506 o(local) { 507 transition_out(block.$$.fragment, local); 508 current = false; 509 }, 510 d(detaching) { 511 destroy_component(block, detaching); 512 } 513 }; 514} 515 516function instance($$self, $$props, $$invalidate) { 517 let disabled; 518 let { gradio } = $$props; 519 let { label = gradio.i18n("radio.radio") } = $$props; 520 let { info = undefined } = $$props; 521 let { elem_id = "" } = $$props; 522 let { elem_classes = [] } = $$props; 523 let { visible = true } = $$props; 524 let { value = null } = $$props; 525 let { value_is_output = false } = $$props; 526 let { choices = [] } = $$props; 527 let { show_label = true } = $$props; 528 let { container = false } = $$props; 529 let { scale = null } = $$props; 530 let { min_width = undefined } = $$props; 531 let { loading_status } = $$props; 532 let { interactive = true } = $$props; 533 534 function handle_change() { 535 gradio.dispatch("change"); 536 537 if (!value_is_output) { 538 gradio.dispatch("input"); 539 } 540 } 541 542 afterUpdate(() => {
543 $$invalidate(14, value_is_output = false); 544 }); 545 546 function baseradio_selected_binding(value$1) { 547 value = value$1; 548 $$invalidate(0, value); 549 } 550 551 const input_handler = (internal_value, i) => gradio.dispatch("select", { value: internal_value, index: i }); 552 553 $$self.$$set = $$props => { 554 if ('gradio' in $$props) $$invalidate(1, gradio = $$props.gradio); 555 if ('label' in $$props) $$invalidate(2, label = $$props.label); 556 if ('info' in $$props) $$invalidate(3, info = $$props.info); 557 if ('elem_id' in $$props) $$invalidate(4, elem_id = $$props.elem_id); 558 if ('elem_classes' in $$props) $$invalidate(5, elem_classes = $$props.elem_classes); 559 if ('visible' in $$props) $$invalidate(6, visible = $$props.visible); 560 if ('value' in $$props) $$invalidate(0, value = $$props.value); 561 if ('value_is_output' in $$props) $$invalidate(14, value_is_output = $$props.value_is_output); 562 if ('choices' in $$props) $$invalidate(7, choices = $$props.choices); 563 if ('show_label' in $$props) $$invalidate(8, show_label = $$props.show_label);
564 if ('container' in $$props) $$invalidate(9, container = $$props.container); 565 if ('scale' in $$props) $$invalidate(10, scale = $$props.scale); 566 if ('min_width' in $$props) $$invalidate(11, min_width = $$props.min_width); 567 if ('loading_status' in $$props) $$invalidate(12, loading_status = $$props.loading_status); 568 if ('interactive' in $$props) $$invalidate(15, interactive = $$props.interactive); 569 }; 570 571 $$self.$$.update = () => { 572 if ($$self.$$.dirty & /*value*/ 1) { 573 (handle_change()); 574 } 575 576 if ($$self.$$.dirty & /*interactive*/ 32768) { 577 $$invalidate(13, disabled = !interactive); 578 } 579 }; 580 581 return [ 582 value, 583 gradio, 584 label, 585 info, 586 elem_id, 587 elem_classes, 588 visible, 589 choices, 590 show_label, 591 container, 592 scale, 593 min_width, 594 loading_status, 595 disabled, 596 value_is_output, 597 interactive, 598 baseradio_selected_binding, 599 input_handler 600 ]; 601} 602 603class Index extends SvelteComponent { 604 constructor(options) { 605 super(); 606 607 init(this, options, instance, create_fragment, safe_not_equal, { 608 gradio: 1, 609 label: 2, 610 info: 3, 611 elem_id: 4, 612 elem_classes: 5, 613 visible: 6, 614 value: 0, 615 value_is_output: 14, 616 choices: 7, 617 show_label: 8, 618 container: 9, 619 scale: 10, 620 min_width: 11, 621 loading_status: 12, 622 interactive: 15 623 }); 624 } 625} 626 627export { BaseRadio, Index as default }; 628//# sourceMappingURL=Index-99a2fdc9.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.