1import { B as Block } from './Button-0502e555.js'; 2import { I as Info } from './Info-2d9cfe3f.js'; 3import { S as Static } from './Index-4c82ea7b.js'; 4import './index-7f1ea29b.js'; 5import './svelte/svelte.js'; 6 7const Checkbox_svelte_svelte_type_style_lang = ''; 8 9/* home/runner/work/gradio/gradio/js/checkbox/shared/Checkbox.svelte generated by Svelte v4.2.2 */ 10const { 11 SvelteComponent: SvelteComponent$1, 12 append, 13 attr, 14 detach: detach$1, 15 element, 16 init: init$1, 17 insert: insert$1, 18 listen, 19 noop, 20 run_all, 21 safe_not_equal: safe_not_equal$1, 22 set_data: set_data$1, 23 space: space$1, 24 text: text$1, 25 toggle_class 26} = window.__gradio__svelte__internal; 27const { createEventDispatcher } = window.__gradio__svelte__internal; 28function create_fragment$1(ctx) { 29 let label_1; 30 let input; 31 let t0; 32 let span; 33 let t1; 34 let mounted; 35 let dispose; 36 37 return { 38 c() { 39 label_1 = element("label"); 40 input = element("input"); 41 t0 = space$1(); 42 span = element("span"); 43 t1 = text$1(/*label*/ ctx[1]); 44 input.disabled = /*disabled*/ ctx[2]; 45 attr(input, "type", "checkbox"); 46 attr(input, "name", "test"); 47 attr(input, "data-testid", "checkbox"); 48 attr(input, "class", "svelte-3pzdsv"); 49 attr(span, "class", "ml-2 svelte-3pzdsv"); 50 attr(label_1, "class", "svelte-3pzdsv"); 51 toggle_class(label_1, "disabled", /*disabled*/ ctx[2]); 52 }, 53 m(target, anchor) { 54 insert$1(target, label_1, anchor); 55 append(label_1, input); 56 input.checked = /*value*/ ctx[0]; 57 append(label_1, t0); 58 append(label_1, span); 59 append(span, t1); 60 61 if (!mounted) { 62 dispose = [ 63 listen(input, "change", /*input_change_handler*/ ctx[6]), 64 listen(input, "keydown", /*handle_enter*/ ctx[3]), 65 listen(input, "input", /*handle_input*/ ctx[4]) 66 ]; 67 68 mounted = true; 69 } 70 }, 71 p(ctx, [dirty]) { 72 if (dirty & /*disabled*/ 4) { 73 input.disabled = /*disabled*/ ctx[2]; 74 } 75 76 if (dirty & /*value*/ 1) { 77 input.checked = /*value*/ ctx[0]; 78 } 79 80 if (dirty & /*label*/ 2) set_data$1(t1, /*label*/ ctx[1]); 81 82 if (dirty & /*disabled*/ 4) { 83 toggle_class(label_1, "disabled", /*disabled*/ ctx[2]); 84 } 85 }, 86 i: noop, 87 o: noop, 88 d(detaching) { 89 if (detaching) { 90 detach$1(label_1); 91 } 92 93 mounted = false; 94 run_all(dispose); 95 } 96 }; 97} 98 99function instance$1($$self, $$props, $$invalidate) { 100 let disabled; 101 let { value = false } = $$props; 102 let { label = "Checkbox" } = $$props; 103 let { interactive } = $$props; 104 const dispatch = createEventDispatcher(); 105 106 async function handle_enter(event) { 107 if (event.key === "Enter") { 108 $$invalidate(0, value = !value); 109 110 dispatch("select", { 111 index: 0, 112 value: event.currentTarget.checked, 113 selected: event.currentTarget.checked 114 }); 115 } 116 } 117 118 async function handle_input(event) { 119 $$invalidate(0, value = event.currentTarget.checked); 120 121 dispatch("select", { 122 index: 0, 123 value: event.currentTarget.checked, 124 selected: event.currentTarget.checked 125 }); 126 } 127 128 function input_change_handler() { 129 value = this.checked; 130 $$invalidate(0, value); 131 } 132 133 $$self.$$set = $$props => {
134 if ('value' in $$props) $$invalidate(0, value = $$props.value); 135 if ('label' in $$props) $$invalidate(1, label = $$props.label); 136 if ('interactive' in $$props) $$invalidate(5, interactive = $$props.interactive); 137 }; 138 139 $$self.$$.update = () => { 140 if ($$self.$$.dirty & /*value*/ 1) { 141 // When the value changes, dispatch the change event via handle_change() 142 // See the docs for an explanation: https://svelte.dev/docs/svelte-components#script-3-$-marks-a-statement-as-reactive 143 (dispatch("change", value)); 144 } 145 146 if ($$self.$$.dirty & /*interactive*/ 32) { 147 $$invalidate(2, disabled = !interactive); 148 } 149 }; 150 151 return [ 152 value, 153 label, 154 disabled, 155 handle_enter, 156 handle_input, 157 interactive, 158 input_change_handler 159 ]; 160} 161 162class Checkbox extends SvelteComponent$1 { 163 constructor(options) { 164 super(); 165 init$1(this, options, instance$1, create_fragment$1, safe_not_equal$1, { value: 0, label: 1, interactive: 5 }); 166 } 167} 168 169const BaseCheckbox = Checkbox; 170 171/* home/runner/work/gradio/gradio/js/checkbox/Index.svelte generated by Svelte v4.2.2 */ 172const { 173 SvelteComponent, 174 add_flush_callback, 175 assign, 176 bind, 177 binding_callbacks, 178 check_outros, 179 create_component, 180 destroy_component, 181 detach, 182 get_spread_object, 183 get_spread_update, 184 group_outros, 185 init, 186 insert, 187 mount_component, 188 safe_not_equal, 189 set_data, 190 space, 191 text, 192 transition_in, 193 transition_out 194} = window.__gradio__svelte__internal;const { afterUpdate } = window.__gradio__svelte__internal; 195function create_if_block(ctx) { 196 let info_1; 197 let current; 198 199 info_1 = new Info({ 200 props: { 201 $$slots: { default: [create_default_slot_1] }, 202 $$scope: { ctx } 203 } 204 }); 205 206 return { 207 c() { 208 create_component(info_1.$$.fragment); 209 }, 210 m(target, anchor) { 211 mount_component(info_1, target, anchor); 212 current = true; 213 }, 214 p(ctx, dirty) { 215 const info_1_changes = {}; 216 217 if (dirty & /*$$scope, info*/ 65568) { 218 info_1_changes.$$scope = { dirty, ctx }; 219 } 220 221 info_1.$set(info_1_changes); 222 }, 223 i(local) { 224 if (current) return; 225 transition_in(info_1.$$.fragment, local); 226 current = true; 227 }, 228 o(local) { 229 transition_out(info_1.$$.fragment, local); 230 current = false; 231 }, 232 d(detaching) { 233 destroy_component(info_1, detaching); 234 } 235 }; 236} 237 238// (42:2) <Info> 239function create_default_slot_1(ctx) { 240 let t; 241 242 return { 243 c() { 244 t = text(/*info*/ ctx[5]); 245 }, 246 m(target, anchor) { 247 insert(target, t, anchor); 248 }, 249 p(ctx, dirty) { 250 if (dirty & /*info*/ 32) set_data(t, /*info*/ ctx[5]); 251 }, 252 d(detaching) { 253 if (detaching) { 254 detach(t); 255 } 256 } 257 }; 258} 259 260// (34:0) <Block {visible} {elem_id} {elem_classes} {container} {scale} {min_width}> 261function create_default_slot(ctx) { 262 let statustracker; 263 let t0; 264 let t1; 265 let basecheckbox; 266 let updating_value; 267 let current; 268 269 const statustracker_spread_levels = [ 270 { 271 autoscroll: /*gradio*/ ctx[10].autoscroll 272 }, 273 { i18n: /*gradio*/ ctx[10].i18n }, 274 /*loading_status*/ ctx[9] 275 ]; 276 277 let statustracker_props = {}; 278 279 for (let i = 0; i < statustracker_spread_levels.length; i += 1) { 280 statustracker_props = assign(statustracker_props, statustracker_spread_levels[i]); 281 } 282 283 statustracker = new Static({ props: statustracker_props }); 284 let if_block = /*info*/ ctx[5] && create_if_block(ctx); 285 286 function basecheckbox_value_binding(value) { 287 /*basecheckbox_value_binding*/ ctx[14](value); 288 } 289 290 let basecheckbox_props = { 291 label: /*label*/ ctx[4], 292 interactive: /*interactive*/ ctx[11] 293 }; 294 295 if (/*value*/ ctx[0] !== void 0) { 296 basecheckbox_props.value = /*value*/ ctx[0]; 297 } 298 299 basecheckbox = new BaseCheckbox({ props: basecheckbox_props }); 300 binding_callbacks.push(() => bind(basecheckbox, 'value', basecheckbox_value_binding)); 301 basecheckbox.$on("change", /*handle_change*/ ctx[12]); 302 basecheckbox.$on("select", /*select_handler*/ ctx[15]); 303 304 return { 305 c() { 306 create_component(statustracker.$$.fragment); 307 t0 = space(); 308 if (if_block) if_block.c(); 309 t1 = space(); 310 create_component(basecheckbox.$$.fragment); 311 }, 312 m(target, anchor) { 313 mount_component(statustracker, target, anchor); 314 insert(target, t0, anchor); 315 if (if_block) if_block.m(target, anchor); 316 insert(target, t1, anchor);
317 mount_component(basecheckbox, target, anchor); 318 current = true; 319 }, 320 p(ctx, dirty) { 321 const statustracker_changes = (dirty & /*gradio, loading_status*/ 1536) 322 ? get_spread_update(statustracker_spread_levels, [ 323 dirty & /*gradio*/ 1024 && { 324 autoscroll: /*gradio*/ ctx[10].autoscroll 325 }, 326 dirty & /*gradio*/ 1024 && { i18n: /*gradio*/ ctx[10].i18n }, 327 dirty & /*loading_status*/ 512 && get_spread_object(/*loading_status*/ ctx[9]) 328 ]) 329 : {}; 330 331 statustracker.$set(statustracker_changes); 332 333 if (/*info*/ ctx[5]) { 334 if (if_block) { 335 if_block.p(ctx, dirty); 336 337 if (dirty & /*info*/ 32) { 338 transition_in(if_block, 1); 339 } 340 } else { 341 if_block = create_if_block(ctx); 342 if_block.c(); 343 transition_in(if_block, 1); 344 if_block.m(t1.parentNode, t1); 345 } 346 } else if (if_block) { 347 group_outros(); 348 349 transition_out(if_block, 1, 1, () => { 350 if_block = null; 351 }); 352 353 check_outros(); 354 } 355 356 const basecheckbox_changes = {}; 357 if (dirty & /*label*/ 16) basecheckbox_changes.label = /*label*/ ctx[4]; 358 if (dirty & /*interactive*/ 2048) basecheckbox_changes.interactive = /*interactive*/ ctx[11]; 359 360 if (!updating_value && dirty & /*value*/ 1) { 361 updating_value = true; 362 basecheckbox_changes.value = /*value*/ ctx[0]; 363 add_flush_callback(() => updating_value = false); 364 } 365 366 basecheckbox.$set(basecheckbox_changes); 367 }, 368 i(local) { 369 if (current) return; 370 transition_in(statustracker.$$.fragment, local); 371 transition_in(if_block); 372 transition_in(basecheckbox.$$.fragment, local); 373 current = true; 374 }, 375 o(local) { 376 transition_out(statustracker.$$.fragment, local); 377 transition_out(if_block); 378 transition_out(basecheckbox.$$.fragment, local); 379 current = false; 380 }, 381 d(detaching) { 382 if (detaching) { 383 detach(t0); 384 detach(t1); 385 } 386 387 destroy_component(statustracker, detaching); 388 if (if_block) if_block.d(detaching); 389 destroy_component(basecheckbox, detaching); 390 } 391 }; 392} 393 394function create_fragment(ctx) { 395 let block; 396 let current; 397 398 block = new Block({ 399 props: { 400 visible: /*visible*/ ctx[3], 401 elem_id: /*elem_id*/ ctx[1], 402 elem_classes: /*elem_classes*/ ctx[2], 403 container: /*container*/ ctx[6], 404 scale: /*scale*/ ctx[7], 405 min_width: /*min_width*/ ctx[8], 406 $$slots: { default: [create_default_slot] }, 407 $$scope: { ctx } 408 } 409 }); 410 411 return { 412 c() { 413 create_component(block.$$.fragment); 414 }, 415 m(target, anchor) { 416 mount_component(block, target, anchor); 417 current = true; 418 }, 419 p(ctx, [dirty]) { 420 const block_changes = {}; 421 if (dirty & /*visible*/ 8) block_changes.visible = /*visible*/ ctx[3]; 422 if (dirty & /*elem_id*/ 2) block_changes.elem_id = /*elem_id*/ ctx[1]; 423 if (dirty & /*elem_classes*/ 4) block_changes.elem_classes = /*elem_classes*/ ctx[2]; 424 if (dirty & /*container*/ 64) block_changes.container = /*container*/ ctx[6]; 425 if (dirty & /*scale*/ 128) block_changes.scale = /*scale*/ ctx[7]; 426 if (dirty & /*min_width*/ 256) block_changes.min_width = /*min_width*/ ctx[8]; 427 428 if (dirty & /*$$scope, label, interactive, value, gradio, info, loading_status*/ 69169) { 429 block_changes.$$scope = { dirty, ctx }; 430 } 431 432 block.$set(block_changes); 433 }, 434 i(local) { 435 if (current) return; 436 transition_in(block.$$.fragment, local); 437 current = true; 438 }, 439 o(local) { 440 transition_out(block.$$.fragment, local); 441 current = false; 442 }, 443 d(detaching) { 444 destroy_component(block, detaching); 445 } 446 }; 447} 448 449function instance($$self, $$props, $$invalidate) { 450 let { elem_id = "" } = $$props; 451 let { elem_classes = [] } = $$props; 452 let { visible = true } = $$props; 453 let { value = false } = $$props; 454 let { value_is_output = false } = $$props; 455 let { label = "Checkbox" } = $$props; 456 let { info = undefined } = $$props; 457 let { container = true } = $$props; 458 let { scale = null } = $$props; 459 let { min_width = undefined } = $$props; 460 let { loading_status } = $$props; 461 let { gradio } = $$props; 462 let { interactive } = $$props; 463 464 function handle_change() { 465 gradio.dispatch("change"); 466 467 if (!value_is_output) { 468 gradio.dispatch("input"); 469 } 470 } 471 472 afterUpdate(() => {
473 $$invalidate(13, value_is_output = false); 474 }); 475 476 function basecheckbox_value_binding(value$1) { 477 value = value$1; 478 $$invalidate(0, value); 479 } 480 481 const select_handler = e => gradio.dispatch("select", e.detail); 482 483 $$self.$$set = $$props => { 484 if ('elem_id' in $$props) $$invalidate(1, elem_id = $$props.elem_id); 485 if ('elem_classes' in $$props) $$invalidate(2, elem_classes = $$props.elem_classes); 486 if ('visible' in $$props) $$invalidate(3, visible = $$props.visible); 487 if ('value' in $$props) $$invalidate(0, value = $$props.value); 488 if ('value_is_output' in $$props) $$invalidate(13, value_is_output = $$props.value_is_output); 489 if ('label' in $$props) $$invalidate(4, label = $$props.label); 490 if ('info' in $$props) $$invalidate(5, info = $$props.info); 491 if ('container' in $$props) $$invalidate(6, container = $$props.container); 492 if ('scale' in $$props) $$invalidate(7, scale = $$props.scale); 493 if ('min_width' in $$props) $$invalidate(8, min_width = $$props.min_width); 494 if ('loading_status' in $$props) $$invalidate(9, loading_status = $$props.loading_status);
495 if ('gradio' in $$props) $$invalidate(10, gradio = $$props.gradio); 496 if ('interactive' in $$props) $$invalidate(11, interactive = $$props.interactive); 497 }; 498 499 return [ 500 value, 501 elem_id, 502 elem_classes, 503 visible, 504 label, 505 info, 506 container, 507 scale, 508 min_width, 509 loading_status, 510 gradio, 511 interactive, 512 handle_change, 513 value_is_output, 514 basecheckbox_value_binding, 515 select_handler 516 ]; 517} 518 519class Index extends SvelteComponent { 520 constructor(options) { 521 super(); 522 523 init(this, options, instance, create_fragment, safe_not_equal, { 524 elem_id: 1, 525 elem_classes: 2, 526 visible: 3, 527 value: 0, 528 value_is_output: 13, 529 label: 4, 530 info: 5, 531 container: 6, 532 scale: 7, 533 min_width: 8, 534 loading_status: 9, 535 gradio: 10, 536 interactive: 11 537 }); 538 } 539} 540 541export { BaseCheckbox, Index as default }; 542//# sourceMappingURL=Index-8fcbb53f.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.