1import { S as SvelteComponent, i as init, s as safe_not_equal, f as element, h as text, c as insert, d as append, j as set_data, e as detach, q as create_component, m as space, b as attr, aa as add_render_callback, u as mount_component, ab as select_option, l as listen, v as transition_in, w as transition_out, x as destroy_component, o as destroy_each, A as createEventDispatcher, ac as select_value, L as assign, M as StatusTracker, D as binding_callbacks, J as bind, N as get_spread_update, O as get_spread_object, G as add_flush_callback, F as bubble } from './index.230aa104.js'; 2import { B as Block } from './Block.67caaa62.js'; 3import { g as get_styles } from './styles.db46e346.js'; 4import { B as BlockTitle } from './BlockTitle.8a7e0497.js'; 5 6/* home/runner/work/gradio/gradio/ui/packages/form/src/Dropdown.svelte generated by Svelte v3.49.0 */ 7 8function get_each_context(ctx, list, i) { 9 const child_ctx = ctx.slice(); 10 child_ctx[10] = list[i]; 11 return child_ctx; 12} 13 14// (16:1) <BlockTitle {show_label}> 15function create_default_slot$1(ctx) { 16 let t; 17 18 return { 19 c() { 20 t = text(/*label*/ ctx[1]); 21 }, 22 m(target, anchor) { 23 insert(target, t, anchor); 24 }, 25 p(ctx, dirty) { 26 if (dirty & /*label*/ 2) set_data(t, /*label*/ ctx[1]); 27 }, 28 d(detaching) { 29 if (detaching) detach(t); 30 } 31 }; 32} 33 34// (22:2) {#each choices as choice} 35function create_each_block(ctx) { 36 let option; 37 let t_value = /*choice*/ ctx[10] + ""; 38 let t; 39 let option_value_value; 40 41 return { 42 c() { 43 option = element("option"); 44 t = text(t_value); 45 option.__value = option_value_value = /*choice*/ ctx[10]; 46 option.value = option.__value; 47 }, 48 m(target, anchor) { 49 insert(target, option, anchor); 50 append(option, t); 51 }, 52 p(ctx, dirty) { 53 if (dirty & /*choices*/ 4 && t_value !== (t_value = /*choice*/ ctx[10] + "")) set_data(t, t_value); 54 55 if (dirty & /*choices*/ 4 && option_value_value !== (option_value_value = /*choice*/ ctx[10])) { 56 option.__value = option_value_value; 57 option.value = option.__value; 58 } 59 }, 60 d(detaching) { 61 if (detaching) detach(option); 62 } 63 }; 64} 65 66function create_fragment$1(ctx) { 67 let label_1; 68 let blocktitle; 69 let t; 70 let select; 71 let select_class_value; 72 let current; 73 let mounted; 74 let dispose; 75 76 blocktitle = new BlockTitle({ 77 props: { 78 show_label: /*show_label*/ ctx[4], 79 $$slots: { default: [create_default_slot$1] }, 80 $$scope: { ctx } 81 } 82 }); 83 84 let each_value = /*choices*/ ctx[2]; 85 let each_blocks = []; 86 87 for (let i = 0; i < each_value.length; i += 1) { 88 each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i)); 89 } 90 91 return { 92 c() { 93 label_1 = element("label"); 94 create_component(blocktitle.$$.fragment); 95 t = space(); 96 select = element("select"); 97 98 for (let i = 0; i < each_blocks.length; i += 1) { 99 each_blocks[i].c(); 100 } 101 102 attr(select, "class", select_class_value = "gr-box gr-input w-full disabled:cursor-not-allowed " + /*rounded*/ ctx[6] + " " + /*border*/ ctx[5]); 103 select.disabled = /*disabled*/ ctx[3]; 104 if (/*value*/ ctx[0] === void 0) add_render_callback(() => /*select_change_handler*/ ctx[8].call(select)); 105 }, 106 m(target, anchor) { 107 insert(target, label_1, anchor); 108 mount_component(blocktitle, label_1, null); 109 append(label_1, t); 110 append(label_1, select); 111 112 for (let i = 0; i < each_blocks.length; i += 1) { 113 each_blocks[i].m(select, null); 114 } 115 116 select_option(select, /*value*/ ctx[0]); 117 current = true; 118 119 if (!mounted) { 120 dispose = listen(select, "change", /*select_change_handler*/ ctx[8]); 121 mounted = true; 122 } 123 }, 124 p(ctx, [dirty]) { 125 const blocktitle_changes = {}; 126 if (dirty & /*show_label*/ 16) blocktitle_changes.show_label = /*show_label*/ ctx[4]; 127 128 if (dirty & /*$$scope, label*/ 8194) { 129 blocktitle_changes.$$scope = { dirty, ctx }; 130 } 131 132 blocktitle.$set(blocktitle_changes); 133 134 if (dirty & /*choices*/ 4) { 135 each_value = /*choices*/ ctx[2]; 136 let i; 137 138 for (i = 0; i < each_value.length; i += 1) { 139 const child_ctx = get_each_context(ctx, each_value, i); 140 141 if (each_blocks[i]) { 142 each_blocks[i].p(child_ctx, dirty); 143 } else { 144 each_blocks[i] = create_each_block(child_ctx); 145 each_blocks[i].c(); 146 each_blocks[i].m(select, null); 147 } 148 } 149 150 for (; i < each_blocks.length; i += 1) { 151 each_blocks[i].d(1); 152 } 153 154 each_blocks.length = each_value.length; 155 } 156 157 if (!current || dirty & /*rounded, border*/ 96 && select_class_value !== (select_class_value = "gr-box gr-input w-full disabled:cursor-not-allowed " + /*rounded*/ ctx[6] + " " + /*border*/ ctx[5])) { 158 attr(select, "class", select_class_value); 159 } 160 161 if (!current || dirty & /*disabled*/ 8) { 162 select.disabled = /*disabled*/ ctx[3]; 163 } 164
165 if (dirty & /*value, choices*/ 5) { 166 select_option(select, /*value*/ ctx[0]); 167 } 168 }, 169 i(local) { 170 if (current) return; 171 transition_in(blocktitle.$$.fragment, local); 172 current = true; 173 }, 174 o(local) { 175 transition_out(blocktitle.$$.fragment, local); 176 current = false; 177 }, 178 d(detaching) { 179 if (detaching) detach(label_1); 180 destroy_component(blocktitle); 181 destroy_each(each_blocks, detaching); 182 mounted = false; 183 dispose(); 184 } 185 }; 186} 187 188function instance$1($$self, $$props, $$invalidate) { 189 let rounded; 190 let border; 191 let { label } = $$props; 192 let { value = undefined } = $$props; 193 let { style = {} } = $$props; 194 let { choices } = $$props; 195 let { disabled = false } = $$props; 196 let { show_label } = $$props; 197 const dispatch = createEventDispatcher(); 198 199 function select_change_handler() { 200 value = select_value(this); 201 $$invalidate(0, value); 202 $$invalidate(2, choices); 203 } 204 205 $$self.$$set = $$props => { 206 if ('label' in $$props) $$invalidate(1, label = $$props.label); 207 if ('value' in $$props) $$invalidate(0, value = $$props.value);
208 if ('style' in $$props) $$invalidate(7, style = $$props.style); 209 if ('choices' in $$props) $$invalidate(2, choices = $$props.choices); 210 if ('disabled' in $$props) $$invalidate(3, disabled = $$props.disabled); 211 if ('show_label' in $$props) $$invalidate(4, show_label = $$props.show_label); 212 }; 213 214 $$self.$$.update = () => { 215 if ($$self.$$.dirty & /*value*/ 1) { 216 dispatch("change", value); 217 } 218 219 if ($$self.$$.dirty & /*style*/ 128) { 220 $$invalidate(6, { rounded, border } = get_styles(style, ["rounded", "border"]), rounded, ($$invalidate(5, border), $$invalidate(7, style))); 221 } 222 }; 223 224 return [ 225 value, 226 label, 227 choices, 228 disabled, 229 show_label, 230 border, 231 rounded, 232 style, 233 select_change_handler 234 ]; 235} 236 237class Dropdown extends SvelteComponent { 238 constructor(options) { 239 super(); 240 241 init(this, options, instance$1, create_fragment$1, safe_not_equal, { 242 label: 1, 243 value: 0, 244 style: 7, 245 choices: 2, 246 disabled: 3, 247 show_label: 4 248 }); 249 } 250} 251 252/* src/components/Dropdown/Dropdown.svelte generated by Svelte v3.49.0 */ 253 254function create_default_slot(ctx) { 255 let statustracker; 256 let t; 257 let dropdown; 258 let updating_value; 259 let current; 260 const statustracker_spread_levels = [/*loading_status*/ ctx[8]]; 261 let statustracker_props = {}; 262 263 for (let i = 0; i < statustracker_spread_levels.length; i += 1) { 264 statustracker_props = assign(statustracker_props, statustracker_spread_levels[i]); 265 } 266 267 statustracker = new StatusTracker({ props: statustracker_props }); 268 269 function dropdown_value_binding(value) { 270 /*dropdown_value_binding*/ ctx[10](value); 271 } 272 273 let dropdown_props = { 274 choices: /*choices*/ ctx[4], 275 label: /*label*/ ctx[1], 276 show_label: /*show_label*/ ctx[6], 277 style: /*style*/ ctx[7], 278 disabled: /*mode*/ ctx[9] === "static" 279 }; 280 281 if (/*value*/ ctx[0] !== void 0) { 282 dropdown_props.value = /*value*/ ctx[0]; 283 } 284 285 dropdown = new Dropdown({ props: dropdown_props }); 286 binding_callbacks.push(() => bind(dropdown, 'value', dropdown_value_binding)); 287 dropdown.$on("change", /*change_handler*/ ctx[11]); 288 289 return { 290 c() { 291 create_component(statustracker.$$.fragment); 292 t = space(); 293 create_component(dropdown.$$.fragment); 294 }, 295 m(target, anchor) { 296 mount_component(statustracker, target, anchor); 297 insert(target, t, anchor); 298 mount_component(dropdown, target, anchor); 299 current = true; 300 }, 301 p(ctx, dirty) { 302 const statustracker_changes = (dirty & /*loading_status*/ 256) 303 ? get_spread_update(statustracker_spread_levels, [get_spread_object(/*loading_status*/ ctx[8])]) 304 : {}; 305 306 statustracker.$set(statustracker_changes); 307 const dropdown_changes = {}; 308 if (dirty & /*choices*/ 16) dropdown_changes.choices = /*choices*/ ctx[4]; 309 if (dirty & /*label*/ 2) dropdown_changes.label = /*label*/ ctx[1]; 310 if (dirty & /*show_label*/ 64) dropdown_changes.show_label = /*show_label*/ ctx[6]; 311 if (dirty & /*style*/ 128) dropdown_changes.style = /*style*/ ctx[7]; 312 if (dirty & /*mode*/ 512) dropdown_changes.disabled = /*mode*/ ctx[9] === "static"; 313 314 if (!updating_value && dirty & /*value*/ 1) { 315 updating_value = true; 316 dropdown_changes.value = /*value*/ ctx[0]; 317 add_flush_callback(() => updating_value = false); 318 } 319 320 dropdown.$set(dropdown_changes); 321 }, 322 i(local) { 323 if (current) return; 324 transition_in(statustracker.$$.fragment, local); 325 transition_in(dropdown.$$.fragment, local); 326 current = true; 327 }, 328 o(local) { 329 transition_out(statustracker.$$.fragment, local); 330 transition_out(dropdown.$$.fragment, local); 331 current = false; 332 }, 333 d(detaching) { 334 destroy_component(statustracker, detaching); 335 if (detaching) detach(t); 336 destroy_component(dropdown, detaching); 337 } 338 }; 339} 340 341function create_fragment(ctx) { 342 let block; 343 let current; 344 345 block = new Block({ 346 props: { 347 visible: /*visible*/ ctx[3], 348 form_position: /*form_position*/ ctx[5], 349 elem_id: /*elem_id*/ ctx[2], 350 disable: typeof /*style*/ ctx[7].container === "boolean" && !/*style*/ ctx[7].container, 351 $$slots: { default: [create_default_slot] }, 352 $$scope: { ctx } 353 } 354 }); 355 356 return { 357 c() { 358 create_component(block.$$.fragment); 359 }, 360 m(target, anchor) { 361 mount_component(block, target, anchor); 362 current = true; 363 }, 364 p(ctx, [dirty]) { 365 const block_changes = {};
366 if (dirty & /*visible*/ 8) block_changes.visible = /*visible*/ ctx[3]; 367 if (dirty & /*form_position*/ 32) block_changes.form_position = /*form_position*/ ctx[5]; 368 if (dirty & /*elem_id*/ 4) block_changes.elem_id = /*elem_id*/ ctx[2]; 369 if (dirty & /*style*/ 128) block_changes.disable = typeof /*style*/ ctx[7].container === "boolean" && !/*style*/ ctx[7].container; 370 371 if (dirty & /*$$scope, choices, label, show_label, style, mode, value, loading_status*/ 5075) { 372 block_changes.$$scope = { dirty, ctx }; 373 } 374 375 block.$set(block_changes); 376 }, 377 i(local) { 378 if (current) return; 379 transition_in(block.$$.fragment, local); 380 current = true; 381 }, 382 o(local) { 383 transition_out(block.$$.fragment, local); 384 current = false; 385 }, 386 d(detaching) { 387 destroy_component(block, detaching); 388 } 389 }; 390} 391 392function instance($$self, $$props, $$invalidate) { 393 let { label = "Dropdown" } = $$props; 394 let { elem_id = "" } = $$props; 395 let { visible = true } = $$props; 396 let { value = "" } = $$props; 397 let { choices } = $$props; 398 let { form_position = "single" } = $$props; 399 let { show_label } = $$props; 400 let { style = {} } = $$props; 401 let { loading_status } = $$props; 402 let { mode } = $$props; 403 404 function dropdown_value_binding(value$1) { 405 value = value$1; 406 $$invalidate(0, value); 407 } 408 409 function change_handler(event) { 410 bubble.call(this, $$self, event); 411 } 412 413 $$self.$$set = $$props => {
414 if ('label' in $$props) $$invalidate(1, label = $$props.label); 415 if ('elem_id' in $$props) $$invalidate(2, elem_id = $$props.elem_id); 416 if ('visible' in $$props) $$invalidate(3, visible = $$props.visible); 417 if ('value' in $$props) $$invalidate(0, value = $$props.value); 418 if ('choices' in $$props) $$invalidate(4, choices = $$props.choices); 419 if ('form_position' in $$props) $$invalidate(5, form_position = $$props.form_position); 420 if ('show_label' in $$props) $$invalidate(6, show_label = $$props.show_label); 421 if ('style' in $$props) $$invalidate(7, style = $$props.style); 422 if ('loading_status' in $$props) $$invalidate(8, loading_status = $$props.loading_status); 423 if ('mode' in $$props) $$invalidate(9, mode = $$props.mode); 424 }; 425 426 return [ 427 value, 428 label, 429 elem_id, 430 visible, 431 choices, 432 form_position, 433 show_label, 434 style, 435 loading_status, 436 mode, 437 dropdown_value_binding, 438 change_handler 439 ]; 440} 441 442class Dropdown_1 extends SvelteComponent { 443 constructor(options) { 444 super(); 445 446 init(this, options, instance, create_fragment, safe_not_equal, { 447 label: 1, 448 elem_id: 2, 449 visible: 3, 450 value: 0, 451 choices: 4, 452 form_position: 5, 453 show_label: 6, 454 style: 7, 455 loading_status: 8, 456 mode: 9 457 }); 458 } 459} 460 461var Dropdown_1$1 = Dropdown_1; 462 463const modes = ["static", "dynamic"]; 464 465export { Dropdown_1$1 as Component, modes };
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.