1import { B as Block } from './Button-f2ef1e3f.js'; 2import { B as BlockTitle } from './BlockTitle-8e3f82b6.js'; 3import { S as Static } from './Index-f4e7a341.js'; 4import './index-546f83db.js'; 5import './svelte/svelte.js'; 6import './Info-c6eafbfa.js'; 7 8const Index_svelte_svelte_type_style_lang = ''; 9 10/* home/runner/work/gradio/gradio/js/checkboxgroup/Index.svelte generated by Svelte v4.2.2 */ 11const { 12 SvelteComponent, 13 append, 14 assign, 15 attr, 16 create_component, 17 destroy_component, 18 destroy_each, 19 detach, 20 element, 21 ensure_array_like, 22 get_spread_object, 23 get_spread_update, 24 init, 25 insert, 26 listen, 27 mount_component, 28 not_equal, 29 run_all, 30 set_data, 31 space, 32 text, 33 toggle_class, 34 transition_in, 35 transition_out 36} = window.__gradio__svelte__internal; 37function get_each_context(ctx, list, i) { 38 const child_ctx = ctx.slice(); 39 child_ctx[19] = list[i][0]; 40 child_ctx[20] = list[i][1]; 41 child_ctx[22] = i; 42 return child_ctx; 43} 44 45// (46:1) <BlockTitle {show_label} {info}> 46function create_default_slot_1(ctx) { 47 let t; 48 49 return { 50 c() { 51 t = text(/*label*/ ctx[9]); 52 }, 53 m(target, anchor) { 54 insert(target, t, anchor); 55 }, 56 p(ctx, dirty) { 57 if (dirty & /*label*/ 512) set_data(t, /*label*/ ctx[9]); 58 }, 59 d(detaching) { 60 if (detaching) { 61 detach(t); 62 } 63 } 64 }; 65} 66 67// (49:2) {#each choices as [display_value, internal_value], i} 68function create_each_block(ctx) { 69 let label_1; 70 let input; 71 let input_checked_value; 72 let input_name_value; 73 let input_title_value; 74 let t0; 75 let span; 76 let t1_value = /*display_value*/ ctx[19] + ""; 77 let t1; 78 let t2; 79 let mounted; 80 let dispose; 81 82 function change_handler() { 83 return /*change_handler*/ ctx[16](/*internal_value*/ ctx[20]); 84 } 85 86 function input_handler(...args) { 87 return /*input_handler*/ ctx[17](/*i*/ ctx[22], /*internal_value*/ ctx[20], ...args); 88 } 89 90 function keydown_handler(...args) { 91 return /*keydown_handler*/ ctx[18](/*internal_value*/ ctx[20], /*i*/ ctx[22], ...args); 92 } 93 94 return { 95 c() { 96 label_1 = element("label"); 97 input = element("input"); 98 t0 = space(); 99 span = element("span"); 100 t1 = text(t1_value); 101 t2 = space(); 102 input.disabled = /*disabled*/ ctx[13]; 103 input.checked = input_checked_value = /*value*/ ctx[0].includes(/*internal_value*/ ctx[20]); 104 attr(input, "type", "checkbox"); 105 attr(input, "name", input_name_value = /*internal_value*/ ctx[20]?.toString()); 106 attr(input, "title", input_title_value = /*internal_value*/ ctx[20]?.toString()); 107 attr(input, "class", "svelte-1k4wjf2"); 108 attr(span, "class", "ml-2 svelte-1k4wjf2"); 109 attr(label_1, "class", "svelte-1k4wjf2"); 110 toggle_class(label_1, "disabled", /*disabled*/ ctx[13]); 111 toggle_class(label_1, "selected", /*value*/ ctx[0].includes(/*internal_value*/ ctx[20])); 112 }, 113 m(target, anchor) { 114 insert(target, label_1, anchor); 115 append(label_1, input); 116 append(label_1, t0); 117 append(label_1, span); 118 append(span, t1); 119 append(label_1, t2); 120 121 if (!mounted) { 122 dispose = [ 123 listen(input, "change", change_handler), 124 listen(input, "input", input_handler), 125 listen(input, "keydown", keydown_handler) 126 ]; 127 128 mounted = true; 129 } 130 }, 131 p(new_ctx, dirty) { 132 ctx = new_ctx; 133 134 if (dirty & /*disabled*/ 8192) { 135 input.disabled = /*disabled*/ ctx[13]; 136 } 137 138 if (dirty & /*value, choices*/ 33 && input_checked_value !== (input_checked_value = /*value*/ ctx[0].includes(/*internal_value*/ ctx[20]))) { 139 input.checked = input_checked_value; 140 } 141 142 if (dirty & /*choices*/ 32 && input_name_value !== (input_name_value = /*internal_value*/ ctx[20]?.toString())) { 143 attr(input, "name", input_name_value); 144 } 145 146 if (dirty & /*choices*/ 32 && input_title_value !== (input_title_value = /*internal_value*/ ctx[20]?.toString())) { 147 attr(input, "title", input_title_value); 148 } 149 150 if (dirty & /*choices*/ 32 && t1_value !== (t1_value = /*display_value*/ ctx[19] + "")) set_data(t1, t1_value); 151 152 if (dirty & /*disabled*/ 8192) { 153 toggle_class(label_1, "disabled", /*disabled*/ ctx[13]); 154 } 155 156 if (dirty & /*value, choices*/ 33) { 157 toggle_class(label_1, "selected", /*value*/ ctx[0].includes(/*internal_value*/ ctx[20])); 158 } 159 }, 160 d(detaching) { 161 if (detaching) { 162 detach(label_1); 163 } 164 165 mounted = false;
166 run_all(dispose); 167 } 168 }; 169} 170 171// (32:0) <Block {visible} {elem_id} {elem_classes} type="fieldset" {container} {scale} {min_width} > 172function create_default_slot(ctx) { 173 let statustracker; 174 let t0; 175 let blocktitle; 176 let t1; 177 let div; 178 let current; 179 180 const statustracker_spread_levels = [ 181 { autoscroll: /*gradio*/ ctx[1].autoscroll }, 182 { i18n: /*gradio*/ ctx[1].i18n }, 183 /*loading_status*/ ctx[12] 184 ]; 185 186 let statustracker_props = {}; 187 188 for (let i = 0; i < statustracker_spread_levels.length; i += 1) { 189 statustracker_props = assign(statustracker_props, statustracker_spread_levels[i]); 190 } 191 192 statustracker = new Static({ props: statustracker_props }); 193 194 blocktitle = new BlockTitle({ 195 props: { 196 show_label: /*show_label*/ ctx[11], 197 info: /*info*/ ctx[10], 198 $$slots: { default: [create_default_slot_1] }, 199 $$scope: { ctx } 200 } 201 }); 202 203 let each_value = ensure_array_like(/*choices*/ ctx[5]); 204 let each_blocks = []; 205 206 for (let i = 0; i < each_value.length; i += 1) { 207 each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i)); 208 } 209 210 return { 211 c() { 212 create_component(statustracker.$$.fragment); 213 t0 = space(); 214 create_component(blocktitle.$$.fragment); 215 t1 = space(); 216 div = element("div"); 217 218 for (let i = 0; i < each_blocks.length; i += 1) { 219 each_blocks[i].c(); 220 } 221 222 attr(div, "class", "wrap svelte-1k4wjf2"); 223 attr(div, "data-testid", "checkbox-group"); 224 }, 225 m(target, anchor) { 226 mount_component(statustracker, target, anchor); 227 insert(target, t0, anchor); 228 mount_component(blocktitle, target, anchor); 229 insert(target, t1, anchor); 230 insert(target, div, anchor); 231 232 for (let i = 0; i < each_blocks.length; i += 1) { 233 if (each_blocks[i]) { 234 each_blocks[i].m(div, null); 235 } 236 } 237 238 current = true; 239 }, 240 p(ctx, dirty) { 241 const statustracker_changes = (dirty & /*gradio, loading_status*/ 4098) 242 ? get_spread_update(statustracker_spread_levels, [ 243 dirty & /*gradio*/ 2 && { autoscroll: /*gradio*/ ctx[1].autoscroll }, 244 dirty & /*gradio*/ 2 && { i18n: /*gradio*/ ctx[1].i18n }, 245 dirty & /*loading_status*/ 4096 && get_spread_object(/*loading_status*/ ctx[12]) 246 ]) 247 : {}; 248 249 statustracker.$set(statustracker_changes); 250 const blocktitle_changes = {}; 251 if (dirty & /*show_label*/ 2048) blocktitle_changes.show_label = /*show_label*/ ctx[11]; 252 if (dirty & /*info*/ 1024) blocktitle_changes.info = /*info*/ ctx[10]; 253 254 if (dirty & /*$$scope, label*/ 8389120) { 255 blocktitle_changes.$$scope = { dirty, ctx }; 256 } 257 258 blocktitle.$set(blocktitle_changes); 259 260 if (dirty & /*disabled, value, choices, toggle_choice, gradio*/ 24611) { 261 each_value = ensure_array_like(/*choices*/ ctx[5]); 262 let i; 263 264 for (i = 0; i < each_value.length; i += 1) { 265 const child_ctx = get_each_context(ctx, each_value, i); 266 267 if (each_blocks[i]) { 268 each_blocks[i].p(child_ctx, dirty); 269 } else { 270 each_blocks[i] = create_each_block(child_ctx); 271 each_blocks[i].c(); 272 each_blocks[i].m(div, null); 273 } 274 } 275 276 for (; i < each_blocks.length; i += 1) { 277 each_blocks[i].d(1); 278 } 279 280 each_blocks.length = each_value.length; 281 } 282 }, 283 i(local) { 284 if (current) return; 285 transition_in(statustracker.$$.fragment, local); 286 transition_in(blocktitle.$$.fragment, local); 287 current = true; 288 }, 289 o(local) { 290 transition_out(statustracker.$$.fragment, local); 291 transition_out(blocktitle.$$.fragment, local); 292 current = false; 293 }, 294 d(detaching) { 295 if (detaching) { 296 detach(t0); 297 detach(t1); 298 detach(div); 299 } 300 301 destroy_component(statustracker, detaching); 302 destroy_component(blocktitle, detaching); 303 destroy_each(each_blocks, detaching); 304 } 305 }; 306} 307 308function create_fragment(ctx) { 309 let block; 310 let current; 311 312 block = new Block({ 313 props: { 314 visible: /*visible*/ ctx[4], 315 elem_id: /*elem_id*/ ctx[2], 316 elem_classes: /*elem_classes*/ ctx[3], 317 type: "fieldset", 318 container: /*container*/ ctx[6], 319 scale: /*scale*/ ctx[7], 320 min_width: /*min_width*/ ctx[8], 321 $$slots: { default: [create_default_slot] }, 322 $$scope: { ctx } 323 } 324 }); 325 326 return { 327 c() { 328 create_component(block.$$.fragment); 329 }, 330 m(target, anchor) { 331 mount_component(block, target, anchor); 332 current = true; 333 }, 334 p(ctx, [dirty]) { 335 const block_changes = {};
336 if (dirty & /*visible*/ 16) block_changes.visible = /*visible*/ ctx[4]; 337 if (dirty & /*elem_id*/ 4) block_changes.elem_id = /*elem_id*/ ctx[2]; 338 if (dirty & /*elem_classes*/ 8) block_changes.elem_classes = /*elem_classes*/ ctx[3]; 339 if (dirty & /*container*/ 64) block_changes.container = /*container*/ ctx[6]; 340 if (dirty & /*scale*/ 128) block_changes.scale = /*scale*/ ctx[7]; 341 if (dirty & /*min_width*/ 256) block_changes.min_width = /*min_width*/ ctx[8]; 342 343 if (dirty & /*$$scope, choices, disabled, value, gradio, show_label, info, label, loading_status*/ 8404515) { 344 block_changes.$$scope = { dirty, ctx }; 345 } 346 347 block.$set(block_changes); 348 }, 349 i(local) { 350 if (current) return; 351 transition_in(block.$$.fragment, local); 352 current = true; 353 }, 354 o(local) { 355 transition_out(block.$$.fragment, local); 356 current = false; 357 }, 358 d(detaching) { 359 destroy_component(block, detaching); 360 } 361 }; 362} 363 364function instance($$self, $$props, $$invalidate) { 365 let disabled; 366 let { gradio } = $$props; 367 let { elem_id = "" } = $$props; 368 let { elem_classes = [] } = $$props; 369 let { visible = true } = $$props; 370 let { value = [] } = $$props; 371 let { choices } = $$props; 372 let { container = true } = $$props; 373 let { scale = null } = $$props; 374 let { min_width = undefined } = $$props; 375 let { label = gradio.i18n("checkbox.checkbox_group") } = $$props; 376 let { info = undefined } = $$props; 377 let { show_label = true } = $$props; 378 let { loading_status } = $$props; 379 let { interactive = true } = $$props; 380 381 function toggle_choice(choice) { 382 if (value.includes(choice)) { 383 $$invalidate(0, value = value.filter(v => v !== choice)); 384 } else { 385 $$invalidate(0, value = [...value, choice]); 386 } 387 388 gradio.dispatch("input"); 389 } 390 391 const change_handler = internal_value => toggle_choice(internal_value); 392 393 const input_handler = (i, internal_value, evt) => gradio.dispatch("select", { 394 index: i, 395 value: internal_value, 396 selected: evt.currentTarget.checked 397 }); 398 399 const keydown_handler = (internal_value, i, event) => { 400 if (event.key === "Enter") { 401 toggle_choice(internal_value); 402 403 gradio.dispatch("select", { 404 index: i, 405 value: internal_value, 406 selected: !value.includes(internal_value) 407 }); 408 } 409 }; 410 411 $$self.$$set = $$props => {
412 if ('gradio' in $$props) $$invalidate(1, gradio = $$props.gradio); 413 if ('elem_id' in $$props) $$invalidate(2, elem_id = $$props.elem_id); 414 if ('elem_classes' in $$props) $$invalidate(3, elem_classes = $$props.elem_classes); 415 if ('visible' in $$props) $$invalidate(4, visible = $$props.visible); 416 if ('value' in $$props) $$invalidate(0, value = $$props.value); 417 if ('choices' in $$props) $$invalidate(5, choices = $$props.choices); 418 if ('container' in $$props) $$invalidate(6, container = $$props.container); 419 if ('scale' in $$props) $$invalidate(7, scale = $$props.scale); 420 if ('min_width' in $$props) $$invalidate(8, min_width = $$props.min_width); 421 if ('label' in $$props) $$invalidate(9, label = $$props.label); 422 if ('info' in $$props) $$invalidate(10, info = $$props.info); 423 if ('show_label' in $$props) $$invalidate(11, show_label = $$props.show_label); 424 if ('loading_status' in $$props) $$invalidate(12, loading_status = $$props.loading_status); 425 if ('interactive' in $$props) $$invalidate(15, interactive = $$props.interactive); 426 }; 427 428 $$self.$$.update = () => { 429 if ($$self.$$.dirty & /*interactive*/ 32768) { 430 $$invalidate(13, disabled = !interactive); 431 } 432 433 if ($$self.$$.dirty & /*value, gradio*/ 3) { 434 value && gradio.dispatch("change"); 435 } 436 }; 437 438 return [ 439 value, 440 gradio, 441 elem_id, 442 elem_classes, 443 visible, 444 choices, 445 container, 446 scale, 447 min_width, 448 label, 449 info, 450 show_label, 451 loading_status, 452 disabled, 453 toggle_choice, 454 interactive, 455 change_handler, 456 input_handler, 457 keydown_handler 458 ]; 459} 460 461class Index extends SvelteComponent { 462 constructor(options) { 463 super(); 464 465 init(this, options, instance, create_fragment, not_equal, { 466 gradio: 1, 467 elem_id: 2, 468 elem_classes: 3, 469 visible: 4, 470 value: 0, 471 choices: 5, 472 container: 6, 473 scale: 7, 474 min_width: 8, 475 label: 9, 476 info: 10, 477 show_label: 11, 478 loading_status: 12, 479 interactive: 15 480 }); 481 } 482} 483 484export { Index as default }; 485//# sourceMappingURL=Index-4042439d.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.