1import { a as Button, B as Block } from './Button-f2ef1e3f.js'; 2import { S as Static } from './Index-f4e7a341.js'; 3import { d as dequal } from './index-21d69e4c.js'; 4import { c as copy } from './utils-8f25e669.js'; 5import { U as Upload } from './ModifyUpload.svelte_svelte_type_style_lang-6f675b46.js'; 6import './Index.svelte_svelte_type_style_lang-e30cedec.js'; 7import { M as MarkdownCode } from './Example.svelte_svelte_type_style_lang-f9f57d93.js'; 8import { d as dsvFormat } from './dsv-a37bb3db.js'; 9export { default as BaseExample } from './Example-7d6bb9b6.js'; 10import './index-546f83db.js'; 11import './svelte/svelte.js'; 12import './prism-python-fe60d73a.js'; 13 14const EditableCell_svelte_svelte_type_style_lang = ''; 15 16/* home/runner/work/gradio/gradio/js/dataframe/shared/EditableCell.svelte generated by Svelte v4.2.2 */ 17const { 18 HtmlTag, 19 SvelteComponent: SvelteComponent$3, 20 action_destroyer: action_destroyer$1, 21 attr: attr$2, 22 binding_callbacks: binding_callbacks$2, 23 bubble, 24 check_outros: check_outros$2, 25 create_component: create_component$2, 26 destroy_component: destroy_component$2, 27 detach: detach$3, 28 element: element$2, 29 empty: empty$2, 30 group_outros: group_outros$2, 31 init: init$3, 32 insert: insert$3, 33 listen: listen$2, 34 mount_component: mount_component$2, 35 noop, 36 prevent_default, 37 run_all: run_all$1, 38 safe_not_equal: safe_not_equal$3, 39 set_data: set_data$1, 40 set_input_value, 41 space: space$3, 42 text: text$2, 43 toggle_class: toggle_class$1, 44 transition_in: transition_in$3, 45 transition_out: transition_out$3 46} = window.__gradio__svelte__internal; 47const { createEventDispatcher: createEventDispatcher$1 } = window.__gradio__svelte__internal; 48function create_if_block_2$1(ctx) { 49 let input; 50 let mounted; 51 let dispose; 52 53 return { 54 c() { 55 input = element$2("input"); 56 attr$2(input, "role", "textbox"); 57 attr$2(input, "tabindex", "-1"); 58 attr$2(input, "class", "svelte-q8uklq"); 59 toggle_class$1(input, "header", /*header*/ ctx[5]); 60 }, 61 m(target, anchor) { 62 insert$3(target, input, anchor); 63 /*input_binding*/ ctx[18](input); 64 set_input_value(input, /*_value*/ ctx[10]); 65 66 if (!mounted) { 67 dispose = [ 68 listen$2(input, "input", /*input_input_handler*/ ctx[19]), 69 listen$2(input, "blur", /*handle_blur*/ ctx[12]), 70 action_destroyer$1(/*use_focus*/ ctx[11].call(null, input)), 71 listen$2(input, "keydown", /*keydown_handler*/ ctx[17]) 72 ]; 73 74 mounted = true; 75 } 76 }, 77 p(ctx, dirty) { 78 if (dirty & /*_value*/ 1024 && input.value !== /*_value*/ ctx[10]) { 79 set_input_value(input, /*_value*/ ctx[10]); 80 } 81 82 if (dirty & /*header*/ 32) { 83 toggle_class$1(input, "header", /*header*/ ctx[5]); 84 } 85 }, 86 d(detaching) { 87 if (detaching) { 88 detach$3(input); 89 } 90 91 /*input_binding*/ ctx[18](null); 92 mounted = false; 93 run_all$1(dispose); 94 } 95 }; 96} 97 98// (63:1) {:else} 99function create_else_block(ctx) { 100 let t_value = (/*editable*/ ctx[9] 101 ? /*value*/ ctx[0] 102 : /*display_value*/ ctx[3] || /*value*/ ctx[0]) + ""; 103 104 let t; 105 106 return { 107 c() { 108 t = text$2(t_value); 109 }, 110 m(target, anchor) { 111 insert$3(target, t, anchor); 112 }, 113 p(ctx, dirty) { 114 if (dirty & /*editable, value, display_value*/ 521 && t_value !== (t_value = (/*editable*/ ctx[9] 115 ? /*value*/ ctx[0] 116 : /*display_value*/ ctx[3] || /*value*/ ctx[0]) + "")) set_data$1(t, t_value); 117 }, 118 i: noop, 119 o: noop, 120 d(detaching) { 121 if (detaching) { 122 detach$3(t); 123 } 124 } 125 }; 126} 127 128// (56:35) 129function create_if_block_1$1(ctx) { 130 let markdowncode; 131 let current; 132 133 markdowncode = new MarkdownCode({ 134 props: { 135 message: /*value*/ ctx[0].toLocaleString(), 136 latex_delimiters: /*latex_delimiters*/ ctx[7], 137 line_breaks: /*line_breaks*/ ctx[8], 138 chatbot: false 139 } 140 }); 141 142 return { 143 c() { 144 create_component$2(markdowncode.$$.fragment); 145 }, 146 m(target, anchor) { 147 mount_component$2(markdowncode, target, anchor); 148 current = true; 149 }, 150 p(ctx, dirty) { 151 const markdowncode_changes = {}; 152 if (dirty & /*value*/ 1) markdowncode_changes.message = /*value*/ ctx[0].toLocaleString(); 153 if (dirty & /*latex_delimiters*/ 128) markdowncode_changes.latex_delimiters = /*latex_delimiters*/ ctx[7];
154 if (dirty & /*line_breaks*/ 256) markdowncode_changes.line_breaks = /*line_breaks*/ ctx[8]; 155 markdowncode.$set(markdowncode_changes); 156 }, 157 i(local) { 158 if (current) return; 159 transition_in$3(markdowncode.$$.fragment, local); 160 current = true; 161 }, 162 o(local) { 163 transition_out$3(markdowncode.$$.fragment, local); 164 current = false; 165 }, 166 d(detaching) { 167 destroy_component$2(markdowncode, detaching); 168 } 169 }; 170} 171 172// (54:1) {#if datatype === "html"} 173function create_if_block$2(ctx) { 174 let html_tag; 175 let html_anchor; 176 177 return { 178 c() { 179 html_tag = new HtmlTag(false); 180 html_anchor = empty$2(); 181 html_tag.a = html_anchor; 182 }, 183 m(target, anchor) { 184 html_tag.m(/*value*/ ctx[0], target, anchor); 185 insert$3(target, html_anchor, anchor); 186 }, 187 p(ctx, dirty) { 188 if (dirty & /*value*/ 1) html_tag.p(/*value*/ ctx[0]); 189 }, 190 i: noop, 191 o: noop, 192 d(detaching) { 193 if (detaching) { 194 detach$3(html_anchor); 195 html_tag.d(); 196 } 197 } 198 }; 199} 200 201function create_fragment$3(ctx) { 202 let t; 203 let span; 204 let current_block_type_index; 205 let if_block1; 206 let current; 207 let mounted; 208 let dispose; 209 let if_block0 = /*edit*/ ctx[2] && create_if_block_2$1(ctx); 210 const if_block_creators = [create_if_block$2, create_if_block_1$1, create_else_block]; 211 const if_blocks = []; 212 213 function select_block_type(ctx, dirty) { 214 if (/*datatype*/ ctx[6] === "html") return 0; 215 if (/*datatype*/ ctx[6] === "markdown") return 1; 216 return 2; 217 } 218 219 current_block_type_index = select_block_type(ctx); 220 if_block1 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); 221 222 return { 223 c() { 224 if (if_block0) if_block0.c(); 225 t = space$3(); 226 span = element$2("span"); 227 if_block1.c(); 228 attr$2(span, "tabindex", "-1"); 229 attr$2(span, "role", "button"); 230 attr$2(span, "style", /*styling*/ ctx[4]); 231 attr$2(span, "class", "svelte-q8uklq"); 232 toggle_class$1(span, "edit", /*edit*/ ctx[2]); 233 }, 234 m(target, anchor) { 235 if (if_block0) if_block0.m(target, anchor); 236 insert$3(target, t, anchor); 237 insert$3(target, span, anchor); 238 if_blocks[current_block_type_index].m(span, null); 239 current = true; 240 241 if (!mounted) { 242 dispose = [ 243 listen$2(span, "dblclick", /*dblclick_handler*/ ctx[15]), 244 listen$2(span, "focus", prevent_default(/*focus_handler*/ ctx[16])) 245 ]; 246 247 mounted = true; 248 } 249 }, 250 p(ctx, [dirty]) { 251 if (/*edit*/ ctx[2]) { 252 if (if_block0) { 253 if_block0.p(ctx, dirty); 254 } else { 255 if_block0 = create_if_block_2$1(ctx); 256 if_block0.c(); 257 if_block0.m(t.parentNode, t); 258 } 259 } else if (if_block0) { 260 if_block0.d(1); 261 if_block0 = null; 262 } 263 264 let previous_block_index = current_block_type_index; 265 current_block_type_index = select_block_type(ctx); 266 267 if (current_block_type_index === previous_block_index) { 268 if_blocks[current_block_type_index].p(ctx, dirty); 269 } else { 270 group_outros$2(); 271 272 transition_out$3(if_blocks[previous_block_index], 1, 1, () => { 273 if_blocks[previous_block_index] = null; 274 }); 275 276 check_outros$2(); 277 if_block1 = if_blocks[current_block_type_index]; 278 279 if (!if_block1) { 280 if_block1 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); 281 if_block1.c(); 282 } else { 283 if_block1.p(ctx, dirty); 284 } 285 286 transition_in$3(if_block1, 1); 287 if_block1.m(span, null); 288 } 289 290 if (!current || dirty & /*styling*/ 16) { 291 attr$2(span, "style", /*styling*/ ctx[4]); 292 } 293 294 if (!current || dirty & /*edit*/ 4) { 295 toggle_class$1(span, "edit", /*edit*/ ctx[2]); 296 } 297 }, 298 i(local) { 299 if (current) return; 300 transition_in$3(if_block1); 301 current = true; 302 }, 303 o(local) { 304 transition_out$3(if_block1); 305 current = false; 306 }, 307 d(detaching) { 308 if (detaching) { 309 detach$3(t); 310 detach$3(span); 311 } 312 313 if (if_block0) if_block0.d(detaching); 314 if_blocks[current_block_type_index].d(); 315 mounted = false; 316 run_all$1(dispose); 317 } 318 }; 319} 320 321function instance$3($$self, $$props, $$invalidate) { 322 let _value; 323 let { edit } = $$props; 324 let { value = "" } = $$props; 325 let { display_value = null } = $$props; 326 let { styling = "" } = $$props; 327 let { header = false } = $$props; 328 let { datatype = "str" } = $$props; 329 let { latex_delimiters } = $$props; 330 let { clear_on_focus = false } = $$props; 331 let { select_on_focus = false } = $$props; 332 let { line_breaks = true } = $$props; 333 let { editable = true } = $$props; 334 const dispatch = createEventDispatcher$1(); 335 let { el } = $$props; 336 337 function use_focus(node) { 338 if (clear_on_focus) {
339 $$invalidate(10, _value = ""); 340 } 341 342 if (select_on_focus) { 343 node.select(); 344 } 345 346 node.focus(); 347 return {}; 348 } 349 350 function handle_blur({ currentTarget }) { 351 $$invalidate(0, value = currentTarget.value); 352 dispatch("blur"); 353 } 354 355 function dblclick_handler(event) { 356 bubble.call(this, $$self, event); 357 } 358 359 function focus_handler(event) { 360 bubble.call(this, $$self, event); 361 } 362 363 function keydown_handler(event) { 364 bubble.call(this, $$self, event); 365 } 366 367 function input_binding($$value) { 368 binding_callbacks$2[$$value ? 'unshift' : 'push'](() => { 369 el = $$value; 370 $$invalidate(1, el); 371 }); 372 } 373 374 function input_input_handler() { 375 _value = this.value; 376 ($$invalidate(10, _value), $$invalidate(0, value)); 377 } 378 379 $$self.$$set = $$props => { 380 if ('edit' in $$props) $$invalidate(2, edit = $$props.edit); 381 if ('value' in $$props) $$invalidate(0, value = $$props.value); 382 if ('display_value' in $$props) $$invalidate(3, display_value = $$props.display_value); 383 if ('styling' in $$props) $$invalidate(4, styling = $$props.styling);
384 if ('header' in $$props) $$invalidate(5, header = $$props.header); 385 if ('datatype' in $$props) $$invalidate(6, datatype = $$props.datatype); 386 if ('latex_delimiters' in $$props) $$invalidate(7, latex_delimiters = $$props.latex_delimiters); 387 if ('clear_on_focus' in $$props) $$invalidate(13, clear_on_focus = $$props.clear_on_focus); 388 if ('select_on_focus' in $$props) $$invalidate(14, select_on_focus = $$props.select_on_focus); 389 if ('line_breaks' in $$props) $$invalidate(8, line_breaks = $$props.line_breaks); 390 if ('editable' in $$props) $$invalidate(9, editable = $$props.editable); 391 if ('el' in $$props) $$invalidate(1, el = $$props.el); 392 }; 393 394 $$self.$$.update = () => { 395 if ($$self.$$.dirty & /*value*/ 1) { 396 $$invalidate(10, _value = value); 397 } 398 }; 399 400 return [ 401 value, 402 el, 403 edit, 404 display_value, 405 styling, 406 header, 407 datatype, 408 latex_delimiters, 409 line_breaks, 410 editable, 411 _value, 412 use_focus, 413 handle_blur, 414 clear_on_focus, 415 select_on_focus, 416 dblclick_handler, 417 focus_handler, 418 keydown_handler, 419 input_binding, 420 input_input_handler 421 ]; 422} 423 424class EditableCell extends SvelteComponent$3 { 425 constructor(options) { 426 super(); 427 428 init$3(this, options, instance$3, create_fragment$3, safe_not_equal$3, { 429 edit: 2, 430 value: 0, 431 display_value: 3, 432 styling: 4, 433 header: 5, 434 datatype: 6, 435 latex_delimiters: 7, 436 clear_on_focus: 13, 437 select_on_focus: 14, 438 line_breaks: 8, 439 editable: 9, 440 el: 1 441 }); 442 } 443} 444 445const VirtualTable_svelte_svelte_type_style_lang = ''; 446 447/* home/runner/work/gradio/gradio/js/dataframe/shared/VirtualTable.svelte generated by Svelte v4.2.2 */ 448const { 449 SvelteComponent: SvelteComponent$2, 450 add_iframe_resize_listener: add_iframe_resize_listener$1, 451 add_render_callback: add_render_callback$1, 452 append: append$1, 453 attr: attr$1, 454 binding_callbacks: binding_callbacks$1, 455 check_outros: check_outros$1, 456 create_slot, 457 detach: detach$2, 458 element: element$1, 459 empty: empty$1, 460 ensure_array_like: ensure_array_like$1, 461 get_all_dirty_from_scope, 462 get_slot_changes, 463 group_outros: group_outros$1, 464 init: init$2, 465 insert: insert$2, 466 listen: listen$1, 467 outro_and_destroy_block: outro_and_destroy_block$1, 468 safe_not_equal: safe_not_equal$2, 469 set_style: set_style$1, 470 space: space$2, 471 text: text$1, 472 transition_in: transition_in$2, 473 transition_out: transition_out$2, 474 update_keyed_each: update_keyed_each$1, 475 update_slot_base 476} = window.__gradio__svelte__internal; 477const { onMount: onMount$1, tick: tick$1 } = window.__gradio__svelte__internal;const get_tfoot_slot_changes = dirty => ({}); 478const get_tfoot_slot_context = ctx => ({}); 479 480function get_each_context$1(ctx, list, i) { 481 const child_ctx = ctx.slice(); 482 child_ctx[34] = list[i]; 483 return child_ctx; 484} 485 486const get_tbody_slot_changes = dirty => ({ 487 item: dirty[0] & /*visible*/ 256, 488 index: dirty[0] & /*visible*/ 256 489}); 490 491const get_tbody_slot_context = ctx => ({ 492 item: /*item*/ ctx[34].data, 493 index: /*item*/ ctx[34].index 494}); 495 496const get_thead_slot_changes = dirty => ({}); 497const get_thead_slot_context = ctx => ({}); 498 499// (217:3) {#if visible.length && visible[0].data.length} 500function create_if_block$1(ctx) { 501 let each_blocks = []; 502 let each_1_lookup = new Map(); 503 let each_1_anchor; 504 let current; 505 let each_value = ensure_array_like$1(/*visible*/ ctx[8]); 506 const get_key = ctx => /*item*/ ctx[34].data[0].id; 507 508 for (let i = 0; i < each_value.length; i += 1) { 509 let child_ctx = get_each_context$1(ctx, each_value, i); 510 let key = get_key(child_ctx); 511 each_1_lookup.set(key, each_blocks[i] = create_each_block$1(key, child_ctx)); 512 } 513 514 return { 515 c() { 516 for (let i = 0; i < each_blocks.length; i += 1) { 517 each_blocks[i].c(); 518 } 519 520 each_1_anchor = empty$1(); 521 }, 522 m(target, anchor) { 523 for (let i = 0; i < each_blocks.length; i += 1) { 524 if (each_blocks[i]) { 525 each_blocks[i].m(target, anchor); 526 } 527 } 528 529 insert$2(target, each_1_anchor, anchor); 530 current = true; 531 }, 532 p(ctx, dirty) { 533 if (dirty[0] & /*$$scope, visible*/ 2097408) { 534 each_value = ensure_array_like$1(/*visible*/ ctx[8]); 535 group_outros$1(); 536 each_blocks = update_keyed_each$1(each_blocks, dirty, get_key, 1, ctx, each_value, each_1_lookup, each_1_anchor.parentNode, outro_and_destroy_block$1, create_each_block$1, each_1_anchor, get_each_context$1); 537 check_outros$1(); 538 } 539 }, 540 i(local) { 541 if (current) return; 542 543 for (let i = 0; i < each_value.length; i += 1) { 544 transition_in$2(each_blocks[i]); 545 } 546 547 current = true; 548 }, 549 o(local) { 550 for (let i = 0; i < each_blocks.length; i += 1) { 551 transition_out$2(each_blocks[i]); 552 } 553 554 current = false;
555 }, 556 d(detaching) { 557 if (detaching) { 558 detach$2(each_1_anchor); 559 } 560 561 for (let i = 0; i < each_blocks.length; i += 1) { 562 each_blocks[i].d(detaching); 563 } 564 } 565 }; 566} 567 568// (219:60) Missing Table Row 569function fallback_block(ctx) { 570 let t; 571 572 return { 573 c() { 574 t = text$1("Missing Table Row\n\t\t\t\t\t"); 575 }, 576 m(target, anchor) { 577 insert$2(target, t, anchor); 578 }, 579 d(detaching) { 580 if (detaching) { 581 detach$2(t); 582 } 583 } 584 }; 585} 586 587// (218:4) {#each visible as item (item.data[0].id)} 588function create_each_block$1(key_1, ctx) { 589 let first; 590 let current; 591 const tbody_slot_template = /*#slots*/ ctx[22].tbody; 592 const tbody_slot = create_slot(tbody_slot_template, ctx, /*$$scope*/ ctx[21], get_tbody_slot_context); 593 const tbody_slot_or_fallback = tbody_slot || fallback_block(); 594 595 return { 596 key: key_1, 597 first: null, 598 c() { 599 first = empty$1(); 600 if (tbody_slot_or_fallback) tbody_slot_or_fallback.c(); 601 this.first = first; 602 }, 603 m(target, anchor) { 604 insert$2(target, first, anchor); 605 606 if (tbody_slot_or_fallback) { 607 tbody_slot_or_fallback.m(target, anchor); 608 } 609 610 current = true; 611 }, 612 p(new_ctx, dirty) { 613 ctx = new_ctx; 614 615 if (tbody_slot) { 616 if (tbody_slot.p && (!current || dirty[0] & /*$$scope, visible*/ 2097408)) { 617 update_slot_base( 618 tbody_slot, 619 tbody_slot_template, 620 ctx, 621 /*$$scope*/ ctx[21], 622 !current 623 ? get_all_dirty_from_scope(/*$$scope*/ ctx[21]) 624 : get_slot_changes(tbody_slot_template, /*$$scope*/ ctx[21], dirty, get_tbody_slot_changes), 625 get_tbody_slot_context 626 ); 627 } 628 } 629 }, 630 i(local) { 631 if (current) return; 632 transition_in$2(tbody_slot_or_fallback, local); 633 current = true; 634 }, 635 o(local) { 636 transition_out$2(tbody_slot_or_fallback, local); 637 current = false; 638 }, 639 d(detaching) { 640 if (detaching) { 641 detach$2(first); 642 } 643 644 if (tbody_slot_or_fallback) tbody_slot_or_fallback.d(detaching); 645 } 646 }; 647} 648 649function create_fragment$2(ctx) { 650 let svelte_virtual_table_viewport; 651 let table; 652 let thead; 653 let thead_resize_listener; 654 let t0; 655 let tbody; 656 let t1; 657 let tfoot; 658 let tfoot_resize_listener; 659 let table_resize_listener; 660 let current; 661 let mounted; 662 let dispose; 663 const thead_slot_template = /*#slots*/ ctx[22].thead; 664 const thead_slot = create_slot(thead_slot_template, ctx, /*$$scope*/ ctx[21], get_thead_slot_context); 665 let if_block = /*visible*/ ctx[8].length && /*visible*/ ctx[8][0].data.length && create_if_block$1(ctx); 666 const tfoot_slot_template = /*#slots*/ ctx[22].tfoot; 667 const tfoot_slot = create_slot(tfoot_slot_template, ctx, /*$$scope*/ ctx[21], get_tfoot_slot_context); 668 669 return { 670 c() { 671 svelte_virtual_table_viewport = element$1("svelte-virtual-table-viewport"); 672 table = element$1("table"); 673 thead = element$1("thead"); 674 if (thead_slot) thead_slot.c(); 675 t0 = space$2(); 676 tbody = element$1("tbody"); 677 if (if_block) if_block.c(); 678 t1 = space$2(); 679 tfoot = element$1("tfoot"); 680 if (tfoot_slot) tfoot_slot.c(); 681 attr$1(thead, "class", "thead svelte-1jok1de"); 682 add_render_callback$1(() => /*thead_elementresize_handler*/ ctx[23].call(thead)); 683 attr$1(tbody, "class", "tbody svelte-1jok1de"); 684 attr$1(tfoot, "class", "tfoot svelte-1jok1de"); 685 add_render_callback$1(() => /*tfoot_elementresize_handler*/ ctx[25].call(tfoot)); 686 attr$1(table, "class", "table svelte-1jok1de"); 687 set_style$1(table, "height", height); 688 set_style$1(table, "--bw-svt-p-top", /*top*/ ctx[5] + "px"); 689 set_style$1(table, "--bw-svt-p-bottom", /*bottom*/ ctx[1] + "px"); 690 set_style$1(table, "--bw-svt-head-height", /*head_height*/ ctx[3] + "px"); 691 set_style$1(table, "--bw-svt-foot-height", /*foot_height*/ ctx[4] + "px"); 692 set_style$1(table, "--bw-svt-avg-row-height", /*average_height*/ ctx[0] + "px"); 693 add_render_callback$1(() => /*table_elementresize_handler*/ ctx[27].call(table)); 694 }, 695 m(target, anchor) { 696 insert$2(target, svelte_virtual_table_viewport, anchor); 697 append$1(svelte_virtual_table_viewport, table); 698 append$1(table, thead); 699 700 if (thead_slot) { 701 thead_slot.m(thead, null); 702 } 703 704 thead_resize_listener = add_iframe_resize_listener$1(thead, /*thead_elementresize_handler*/ ctx[23].bind(thead)); 705 append$1(table, t0); 706 append$1(table, tbody); 707 if (if_block) if_block.m(tbody, null); 708 /*tbody_binding*/ ctx[24](tbody); 709 append$1(table, t1); 710 append$1(table, tfoot); 711 712 if (tfoot_slot) { 713 tfoot_slot.m(tfoot, null); 714 } 715 716 tfoot_resize_listener = add_iframe_resize_listener$1(tfoot, /*tfoot_elementresize_handler*/ ctx[25].bind(tfoot)); 717 /*table_binding*/ ctx[26](table); 718 table_resize_listener = add_iframe_resize_listener$1(table, /*table_elementresize_handler*/ ctx[27].bind(table)); 719 current = true; 720 721 if (!mounted) { 722 dispose = listen$1(table, "scroll", /*handle_scroll*/ ctx[9]); 723 mounted = true; 724 } 725 }, 726 p(ctx, dirty) { 727 if (thead_slot) { 728 if (thead_slot.p && (!current || dirty[0] & /*$$scope*/ 2097152)) { 729 update_slot_base( 730 thead_slot, 731 thead_slot_template, 732 ctx, 733 /*$$scope*/ ctx[21], 734 !current 735 ? get_all_dirty_from_scope(/*$$scope*/ ctx[21]) 736 : get_slot_changes(thead_slot_template, /*$$scope*/ ctx[21], dirty, get_thead_slot_changes), 737 get_thead_slot_context 738 ); 739 } 740 } 741 742 if (/*visible*/ ctx[8].length && /*visible*/ ctx[8][0].data.length) { 743 if (if_block) { 744 if_block.p(ctx, dirty); 745
746 if (dirty[0] & /*visible*/ 256) { 747 transition_in$2(if_block, 1); 748 } 749 } else { 750 if_block = create_if_block$1(ctx); 751 if_block.c(); 752 transition_in$2(if_block, 1); 753 if_block.m(tbody, null); 754 } 755 } else if (if_block) { 756 group_outros$1(); 757 758 transition_out$2(if_block, 1, 1, () => { 759 if_block = null; 760 }); 761 762 check_outros$1(); 763 } 764 765 if (tfoot_slot) { 766 if (tfoot_slot.p && (!current || dirty[0] & /*$$scope*/ 2097152)) { 767 update_slot_base( 768 tfoot_slot, 769 tfoot_slot_template, 770 ctx, 771 /*$$scope*/ ctx[21], 772 !current 773 ? get_all_dirty_from_scope(/*$$scope*/ ctx[21]) 774 : get_slot_changes(tfoot_slot_template, /*$$scope*/ ctx[21], dirty, get_tfoot_slot_changes), 775 get_tfoot_slot_context 776 ); 777 } 778 } 779 780 if (!current || dirty[0] & /*top*/ 32) { 781 set_style$1(table, "--bw-svt-p-top", /*top*/ ctx[5] + "px"); 782 } 783 784 if (!current || dirty[0] & /*bottom*/ 2) { 785 set_style$1(table, "--bw-svt-p-bottom", /*bottom*/ ctx[1] + "px"); 786 } 787 788 if (!current || dirty[0] & /*head_height*/ 8) { 789 set_style$1(table, "--bw-svt-head-height", /*head_height*/ ctx[3] + "px"); 790 } 791 792 if (!current || dirty[0] & /*foot_height*/ 16) { 793 set_style$1(table, "--bw-svt-foot-height", /*foot_height*/ ctx[4] + "px"); 794 } 795 796 if (!current || dirty[0] & /*average_height*/ 1) { 797 set_style$1(table, "--bw-svt-avg-row-height", /*average_height*/ ctx[0] + "px"); 798 } 799 }, 800 i(local) { 801 if (current) return; 802 transition_in$2(thead_slot, local); 803 transition_in$2(if_block); 804 transition_in$2(tfoot_slot, local); 805 current = true; 806 }, 807 o(local) { 808 transition_out$2(thead_slot, local); 809 transition_out$2(if_block); 810 transition_out$2(tfoot_slot, local); 811 current = false; 812 }, 813 d(detaching) { 814 if (detaching) { 815 detach$2(svelte_virtual_table_viewport); 816 } 817 818 if (thead_slot) thead_slot.d(detaching); 819 thead_resize_listener(); 820 if (if_block) if_block.d(); 821 /*tbody_binding*/ ctx[24](null); 822 if (tfoot_slot) tfoot_slot.d(detaching); 823 tfoot_resize_listener(); 824 /*table_binding*/ ctx[26](null); 825 table_resize_listener();
826 mounted = false; 827 dispose(); 828 } 829 }; 830} 831 832let height = "100%"; 833 834function get_computed_px_amount(elem, property) { 835 if (!elem) { 836 return 0; 837 } 838 839 const compStyle = getComputedStyle(elem); 840 let x = parseInt(compStyle.getPropertyValue(property)); 841 return x; 842} 843 844function instance$2($$self, $$props, $$invalidate) { 845 let sortedItems; 846 let { $$slots: slots = {}, $$scope } = $$props; 847 let { items = [] } = $$props; 848 let { table_width } = $$props; 849 let { max_height } = $$props; 850 let { actual_height } = $$props; 851 let { table_scrollbar_width } = $$props; 852 let { start = 0 } = $$props; 853 let { end = 0 } = $$props; 854 let { selected } = $$props; 855 let average_height; 856 let bottom = 0; 857 let contents; 858 let head_height = 0; 859 let foot_height = 0; 860 let height_map = []; 861 let mounted; 862 let rows; 863 let top = 0; 864 let viewport; 865 let viewport_height = 0; 866 let visible = []; 867 let content_height = 0; 868 869 async function refresh_height_map(_items) { 870 if (viewport_height === 0 || table_width === 0) { 871 return; 872 } 873 874 const { scrollTop } = viewport; 875 $$invalidate(13, table_scrollbar_width = viewport.offsetWidth - viewport.clientWidth); 876 content_height = top - (scrollTop - head_height); 877 let i = start; 878 879 while (content_height < max_height && i < _items.length) { 880 let row = rows[i - start]; 881 882 if (!row) { 883 $$invalidate(11, end = i + 1); 884 await tick$1(); // render the newly visible row 885 row = rows[i - start]; 886 } 887 888 let _h = row?.getBoundingClientRect().height; 889 890 if (!_h) { 891 _h = average_height; 892 } 893 894 const row_height = height_map[i] = _h; 895 content_height += row_height; 896 i += 1; 897 } 898 899 $$invalidate(11, end = i); 900 const remaining = _items.length - end; 901 const scrollbar_height = viewport.offsetHeight - viewport.clientHeight; 902 903 if (scrollbar_height > 0) { 904 content_height += scrollbar_height; 905 } 906 907 let filtered_height_map = height_map.filter(v => typeof v === "number"); 908 $$invalidate(0, average_height = filtered_height_map.reduce((a, b) => a + b, 0) / filtered_height_map.length); 909 $$invalidate(1, bottom = remaining * average_height); 910 height_map.length = _items.length; 911 await tick$1(); 912 913 if (!max_height) { 914 $$invalidate(12, actual_height = content_height + 1); 915 } else if (content_height < max_height) { 916 $$invalidate(12, actual_height = content_height + 2); 917 } else { 918 $$invalidate(12, actual_height = max_height); 919 } 920 921 await tick$1(); 922 } 923 924 async function scroll_and_render(n) { 925 requestAnimationFrame(async () => { 926 if (typeof n !== "number") return; 927 const direction = typeof n !== "number" ? false : is_in_view(n); 928 929 if (direction === true) { 930 return; 931 } 932 933 if (direction === "back") { 934 await scroll_to_index(n, { behavior: "instant" }); 935 } 936 937 if (direction === "forwards") { 938 await scroll_to_index(n, { behavior: "instant" }, true); 939 } 940 }); 941 } 942 943 function is_in_view(n) { 944 const current = rows && rows[n - start]; 945 946 if (!current && n < start) { 947 return "back"; 948 } 949 950 if (!current && n >= end - 1) { 951 return "forwards"; 952 } 953 954 const { top: viewport_top } = viewport.getBoundingClientRect(); 955 const { top, bottom } = current.getBoundingClientRect(); 956 957 if (top - viewport_top < 37) { 958 return "back"; 959 } 960 961 if (bottom - viewport_top > viewport_height) { 962 return "forwards"; 963 } 964 965 return true; 966 } 967 968 async function handle_scroll(e) { 969 const scroll_top = viewport.scrollTop; 970 rows = contents.children; 971 const is_start_overflow = sortedItems.length < start; 972 const row_top_border = get_computed_px_amount(rows[1], "border-top-width"); 973 const actual_border_collapsed_width = 0; 974 975 if (is_start_overflow) { 976 await scroll_to_index(sortedItems.length - 1, { behavior: "auto" }); 977 } 978 979 let new_start = 0; 980 981 // acquire height map for currently visible rows 982 for (let v = 0; v < rows.length; v += 1) { 983 height_map[start + v] = rows[v].getBoundingClientRect().height; 984 } 985 986 let i = 0; 987 988 // start from top: thead, with its borders, plus the first border to afterwards neglect 989 let y = head_height + row_top_border / 2; 990 991 let row_heights = []; 992 993 // loop items to find new start 994 while (i < sortedItems.length) { 995 const row_height = height_map[i] || average_height; 996 row_heights[i] = row_height; 997 998 // we only want to jump if the full (incl. border) row is away 999 if (y + row_height + actual_border_collapsed_width > scroll_top) { 1000 // this is the last index still inside the viewport 1001 new_start = i; 1002
1003 $$invalidate(5, top = y - (head_height + row_top_border / 2)); 1004 break; 1005 } 1006 1007 y += row_height; 1008 i += 1; 1009 } 1010 1011 new_start = Math.max(0, new_start); 1012 1013 while (i < sortedItems.length) { 1014 const row_height = height_map[i] || average_height; 1015 y += row_height; 1016 i += 1; 1017 1018 if (y > scroll_top + viewport_height) { 1019 break; 1020 } 1021 } 1022 1023 $$invalidate(10, start = new_start); 1024 $$invalidate(11, end = i); 1025 const remaining = sortedItems.length - end; 1026 1027 if (end === 0) { 1028 $$invalidate(11, end = 10); 1029 } 1030 1031 $$invalidate(0, average_height = (y - head_height) / end); 1032 let remaining_height = remaining * average_height; // 0 1033 1034 // compute height map for remaining items 1035 while (i < sortedItems.length) { 1036 i += 1; 1037 height_map[i] = average_height; 1038 } 1039 1040 $$invalidate(1, bottom = remaining_height); 1041 1042 if (!isFinite(bottom)) { 1043 $$invalidate(1, bottom = 200000); 1044 } 1045 } 1046 1047 async function scroll_to_index(index, opts, align_end = false) { 1048 await tick$1(); 1049 const _itemHeight = average_height; 1050 let distance = index * _itemHeight; 1051 1052 if (align_end) { 1053 distance = distance - viewport_height + _itemHeight + head_height; 1054 } 1055 1056 const scrollbar_height = viewport.offsetHeight - viewport.clientHeight; 1057 1058 if (scrollbar_height > 0) { 1059 distance += scrollbar_height; 1060 } 1061 1062 const _opts = { 1063 top: distance, 1064 behavior: "smooth", 1065 ...opts 1066 }; 1067 1068 viewport.scrollTo(_opts); 1069 } 1070 1071 onMount$1(() => { 1072 rows = contents.children; 1073 $$invalidate(19, mounted = true); 1074 refresh_height_map(items); 1075 }); 1076 1077 function thead_elementresize_handler() { 1078 head_height = this.offsetHeight; 1079 $$invalidate(3, head_height); 1080 } 1081 1082 function tbody_binding($$value) { 1083 binding_callbacks$1[$$value ? 'unshift' : 'push'](() => { 1084 contents = $$value; 1085 $$invalidate(2, contents); 1086 }); 1087 } 1088 1089 function tfoot_elementresize_handler() { 1090 foot_height = this.offsetHeight; 1091 $$invalidate(4, foot_height); 1092 } 1093 1094 function table_binding($$value) { 1095 binding_callbacks$1[$$value ? 'unshift' : 'push'](() => { 1096 viewport = $$value; 1097 $$invalidate(6, viewport); 1098 }); 1099 } 1100 1101 function table_elementresize_handler() { 1102 viewport_height = this.offsetHeight; 1103 $$invalidate(7, viewport_height); 1104 } 1105 1106 $$self.$$set = $$props => {
1107 if ('items' in $$props) $$invalidate(14, items = $$props.items); 1108 if ('table_width' in $$props) $$invalidate(15, table_width = $$props.table_width); 1109 if ('max_height' in $$props) $$invalidate(16, max_height = $$props.max_height); 1110 if ('actual_height' in $$props) $$invalidate(12, actual_height = $$props.actual_height); 1111 if ('table_scrollbar_width' in $$props) $$invalidate(13, table_scrollbar_width = $$props.table_scrollbar_width); 1112 if ('start' in $$props) $$invalidate(10, start = $$props.start); 1113 if ('end' in $$props) $$invalidate(11, end = $$props.end); 1114 if ('selected' in $$props) $$invalidate(17, selected = $$props.selected); 1115 if ('$$scope' in $$props) $$invalidate(21, $$scope = $$props.$$scope); 1116 }; 1117 1118 $$self.$$.update = () => { 1119 if ($$self.$$.dirty[0] & /*items*/ 16384) { 1120 $$invalidate(20, sortedItems = items); 1121 } 1122 1123 if ($$self.$$.dirty[0] & /*mounted, sortedItems*/ 1572864) { 1124 if (mounted) requestAnimationFrame(() => refresh_height_map(sortedItems)); 1125 } 1126 1127 if ($$self.$$.dirty[0] & /*selected*/ 131072) { 1128 scroll_and_render(selected); 1129 } 1130 1131 if ($$self.$$.dirty[0] & /*sortedItems, start, end*/ 1051648) { 1132 $$invalidate(8, visible = sortedItems.slice(start, end).map((data, i) => { 1133 return { index: i + start, data }; 1134 })); 1135 } 1136 }; 1137 1138 return [ 1139 average_height, 1140 bottom, 1141 contents, 1142 head_height, 1143 foot_height, 1144 top, 1145 viewport, 1146 viewport_height, 1147 visible, 1148 handle_scroll, 1149 start, 1150 end, 1151 actual_height, 1152 table_scrollbar_width, 1153 items, 1154 table_width, 1155 max_height, 1156 selected, 1157 scroll_to_index, 1158 mounted, 1159 sortedItems, 1160 $$scope, 1161 slots, 1162 thead_elementresize_handler, 1163 tbody_binding, 1164 tfoot_elementresize_handler, 1165 table_binding, 1166 table_elementresize_handler 1167 ]; 1168} 1169 1170class VirtualTable extends SvelteComponent$2 { 1171 constructor(options) { 1172 super(); 1173 1174 init$2( 1175 this, 1176 options, 1177 instance$2, 1178 create_fragment$2, 1179 safe_not_equal$2, 1180 { 1181 items: 14, 1182 table_width: 15, 1183 max_height: 16, 1184 actual_height: 12, 1185 table_scrollbar_width: 13, 1186 start: 10, 1187 end: 11, 1188 selected: 17, 1189 scroll_to_index: 18 1190 }, 1191 null, 1192 [-1, -1] 1193 ); 1194 } 1195 1196 get scroll_to_index() { 1197 return this.$$.ctx[18]; 1198 } 1199} 1200 1201const Table_svelte_svelte_type_style_lang = ''; 1202 1203/* home/runner/work/gradio/gradio/js/dataframe/shared/Table.svelte generated by Svelte v4.2.2 */ 1204const { 1205 SvelteComponent: SvelteComponent$1, 1206 action_destroyer, 1207 add_flush_callback, 1208 add_iframe_resize_listener, 1209 add_render_callback, 1210 append, 1211 attr, 1212 bind, 1213 binding_callbacks, 1214 check_outros, 1215 create_component: create_component$1, 1216 destroy_component: destroy_component$1, 1217 detach: detach$1, 1218 element, 1219 empty, 1220 ensure_array_like, 1221 group_outros, 1222 init: init$1, 1223 insert: insert$1, 1224 listen, 1225 mount_component: mount_component$1, 1226 outro_and_destroy_block, 1227 run_all, 1228 safe_not_equal: safe_not_equal$1, 1229 set_data, 1230 set_style, 1231 space: space$1, 1232 svg_element, 1233 text, 1234 toggle_class, 1235 transition_in: transition_in$1, 1236 transition_out: transition_out$1, 1237 update_keyed_each 1238} = window.__gradio__svelte__internal; 1239const { createEventDispatcher, tick, onMount } = window.__gradio__svelte__internal; 1240function get_each_context_1(ctx, list, i) { 1241 const child_ctx = ctx.slice(); 1242 child_ctx[12] = list[i].value; 1243 child_ctx[87] = list[i].id; 1244 child_ctx[90] = list; 1245 child_ctx[91] = i; 1246 return child_ctx; 1247} 1248 1249function get_each_context(ctx, list, i) { 1250 const child_ctx = ctx.slice(); 1251 child_ctx[12] = list[i].value; 1252 child_ctx[87] = list[i].id; 1253 child_ctx[88] = list; 1254 child_ctx[89] = i; 1255 return child_ctx; 1256} 1257 1258function get_each_context_2(ctx, list, i) { 1259 const child_ctx = ctx.slice(); 1260 child_ctx[12] = list[i].value; 1261 child_ctx[87] = list[i].id; 1262 child_ctx[92] = list; 1263 child_ctx[89] = i; 1264 return child_ctx; 1265} 1266 1267function get_each_context_3(ctx, list, i) { 1268 const child_ctx = ctx.slice(); 1269 child_ctx[12] = list[i].value; 1270 child_ctx[87] = list[i].id; 1271 child_ctx[91] = i; 1272 return child_ctx; 1273} 1274 1275// (504:1) {#if label && label.length !== 0} 1276function create_if_block_5(ctx) { 1277 let p; 1278 let t; 1279 1280 return { 1281 c() { 1282 p = element("p"); 1283 t = text(/*label*/ ctx[1]); 1284 attr(p, "class", "svelte-1bvc1p0"); 1285 }, 1286 m(target, anchor) { 1287 insert$1(target, p, anchor); 1288 append(p, t); 1289 }, 1290 p(ctx, dirty) {
1291 if (dirty[0] & /*label*/ 2) set_data(t, /*label*/ ctx[1]); 1292 }, 1293 d(detaching) { 1294 if (detaching) { 1295 detach$1(p); 1296 } 1297 } 1298 }; 1299} 1300 1301// (524:3) {#if label && label.length !== 0} 1302function create_if_block_4(ctx) { 1303 let caption; 1304 let t; 1305 1306 return { 1307 c() { 1308 caption = element("caption"); 1309 t = text(/*label*/ ctx[1]); 1310 attr(caption, "class", "sr-only"); 1311 }, 1312 m(target, anchor) { 1313 insert$1(target, caption, anchor); 1314 append(caption, t); 1315 }, 1316 p(ctx, dirty) { 1317 if (dirty[0] & /*label*/ 2) set_data(t, /*label*/ ctx[1]); 1318 }, 1319 d(detaching) { 1320 if (detaching) { 1321 detach$1(caption); 1322 } 1323 } 1324 }; 1325} 1326 1327// (529:5) {#each _headers as { value, id } 1328function create_each_block_3(key_1, ctx) { 1329 let th; 1330 let div1; 1331 let editablecell; 1332 let t0; 1333 let div0; 1334 let svg; 1335 let path; 1336 let div0_class_value; 1337 let t1; 1338 let th_aria_sort_value; 1339 let current; 1340 1341 editablecell = new EditableCell({ 1342 props: { 1343 value: /*value*/ ctx[12], 1344 latex_delimiters: /*latex_delimiters*/ ctx[4], 1345 line_breaks: /*line_breaks*/ ctx[10], 1346 header: true, 1347 edit: false, 1348 el: null 1349 } 1350 }); 1351 1352 return { 1353 key: key_1, 1354 first: null, 1355 c() { 1356 th = element("th"); 1357 div1 = element("div"); 1358 create_component$1(editablecell.$$.fragment); 1359 t0 = space$1(); 1360 div0 = element("div"); 1361 svg = svg_element("svg"); 1362 path = svg_element("path"); 1363 t1 = space$1(); 1364 attr(path, "d", "M4.49999 0L8.3971 6.75H0.602875L4.49999 0Z"); 1365 attr(svg, "width", "1em"); 1366 attr(svg, "height", "1em"); 1367 attr(svg, "viewBox", "0 0 9 7"); 1368 attr(svg, "fill", "none"); 1369 attr(svg, "xmlns", "http://www.w3.org/2000/svg"); 1370 attr(svg, "class", "svelte-1bvc1p0"); 1371 attr(div0, "class", div0_class_value = "sort-button " + /*sort_direction*/ ctx[18] + "" + " svelte-1bvc1p0"); 1372 toggle_class(div0, "sorted", /*sort_by*/ ctx[19] === /*i*/ ctx[91]); 1373 toggle_class(div0, "des", /*sort_by*/ ctx[19] === /*i*/ ctx[91] && /*sort_direction*/ ctx[18] === "des"); 1374 attr(div1, "class", "cell-wrap svelte-1bvc1p0"); 1375 attr(th, "aria-sort", th_aria_sort_value = /*get_sort_status*/ ctx[35](/*value*/ ctx[12], /*sort_by*/ ctx[19], /*sort_direction*/ ctx[18])); 1376 attr(th, "class", "svelte-1bvc1p0"); 1377 toggle_class(th, "editing", /*header_edit*/ ctx[24] === /*i*/ ctx[91]); 1378 1379 set_style(th, "width", /*column_widths*/ ctx[11].length 1380 ? /*column_widths*/ ctx[11][/*i*/ ctx[91]] 1381 : undefined); 1382 1383 this.first = th; 1384 }, 1385 m(target, anchor) { 1386 insert$1(target, th, anchor); 1387 append(th, div1); 1388 mount_component$1(editablecell, div1, null); 1389 append(div1, t0); 1390 append(div1, div0); 1391 append(div0, svg); 1392 append(svg, path); 1393 append(th, t1); 1394 current = true; 1395 }, 1396 p(new_ctx, dirty) { 1397 ctx = new_ctx; 1398 const editablecell_changes = {}; 1399 if (dirty[0] & /*_headers*/ 65536) editablecell_changes.value = /*value*/ ctx[12]; 1400 if (dirty[0] & /*latex_delimiters*/ 16) editablecell_changes.latex_delimiters = /*latex_delimiters*/ ctx[4]; 1401 if (dirty[0] & /*line_breaks*/ 1024) editablecell_changes.line_breaks = /*line_breaks*/ ctx[10]; 1402 editablecell.$set(editablecell_changes); 1403 1404 if (!current || dirty[0] & /*sort_direction*/ 262144 && div0_class_value !== (div0_class_value = "sort-button " + /*sort_direction*/ ctx[18] + "" + " svelte-1bvc1p0")) { 1405 attr(div0, "class", div0_class_value); 1406 } 1407 1408 if (!current || dirty[0] & /*sort_direction, sort_by, _headers*/ 851968) { 1409 toggle_class(div0, "sorted", /*sort_by*/ ctx[19] === /*i*/ ctx[91]); 1410 } 1411 1412 if (!current || dirty[0] & /*sort_direction, sort_by, _headers, sort_direction*/ 851968) { 1413 toggle_class(div0, "des", /*sort_by*/ ctx[19] === /*i*/ ctx[91] && /*sort_direction*/ ctx[18] === "des"); 1414 } 1415 1416 if (!current || dirty[0] & /*_headers, sort_by, sort_direction*/ 851968 && th_aria_sort_value !== (th_aria_sort_value = /*get_sort_status*/ ctx[35](/*value*/ ctx[12], /*sort_by*/ ctx[19], /*sort_direction*/ ctx[18]))) { 1417 attr(th, "aria-sort", th_aria_sort_value); 1418 } 1419 1420 if (!current || dirty[0] & /*header_edit, _headers*/ 16842752) { 1421 toggle_class(th, "editing", /*header_edit*/ ctx[24] === /*i*/ ctx[91]); 1422 } 1423 1424 if (dirty[0] & /*column_widths, _headers*/ 67584) { 1425 set_style(th, "width", /*column_widths*/ ctx[11].length 1426 ? /*column_widths*/ ctx[11][/*i*/ ctx[91]] 1427 : undefined); 1428 } 1429 }, 1430 i(local) { 1431 if (current) return; 1432 transition_in$1(editablecell.$$.fragment, local); 1433 current = true; 1434 }, 1435 o(local) { 1436 transition_out$1(editablecell.$$.fragment, local); 1437 current = false;
1438 }, 1439 d(detaching) { 1440 if (detaching) { 1441 detach$1(th); 1442 } 1443 1444 destroy_component$1(editablecell); 1445 } 1446 }; 1447} 1448 1449// (567:5) {#each max as { value, id } 1450function create_each_block_2(key_1, ctx) { 1451 let td; 1452 let div; 1453 let editablecell; 1454 let t; 1455 let j = /*j*/ ctx[89]; 1456 let current; 1457 1458 editablecell = new EditableCell({ 1459 props: { 1460 value: /*value*/ ctx[12], 1461 latex_delimiters: /*latex_delimiters*/ ctx[4], 1462 line_breaks: /*line_breaks*/ ctx[10], 1463 datatype: Array.isArray(/*datatype*/ ctx[0]) 1464 ? /*datatype*/ ctx[0][/*j*/ ctx[89]] 1465 : /*datatype*/ ctx[0], 1466 edit: false, 1467 el: null 1468 } 1469 }); 1470 1471 const assign_td = () => /*td_binding*/ ctx[52](td, j); 1472 const unassign_td = () => /*td_binding*/ ctx[52](null, j); 1473 1474 return { 1475 key: key_1, 1476 first: null, 1477 c() { 1478 td = element("td"); 1479 div = element("div"); 1480 create_component$1(editablecell.$$.fragment); 1481 t = space$1(); 1482 attr(div, "class", "cell-wrap svelte-1bvc1p0"); 1483 attr(td, "tabindex", "-1"); 1484 attr(td, "class", "svelte-1bvc1p0"); 1485 this.first = td; 1486 }, 1487 m(target, anchor) { 1488 insert$1(target, td, anchor); 1489 append(td, div); 1490 mount_component$1(editablecell, div, null); 1491 append(td, t); 1492 assign_td(); 1493 current = true; 1494 }, 1495 p(new_ctx, dirty) { 1496 ctx = new_ctx; 1497 const editablecell_changes = {}; 1498 if (dirty[1] & /*max*/ 8) editablecell_changes.value = /*value*/ ctx[12]; 1499 if (dirty[0] & /*latex_delimiters*/ 16) editablecell_changes.latex_delimiters = /*latex_delimiters*/ ctx[4]; 1500 if (dirty[0] & /*line_breaks*/ 1024) editablecell_changes.line_breaks = /*line_breaks*/ ctx[10]; 1501 1502 if (dirty[0] & /*datatype*/ 1 | dirty[1] & /*max*/ 8) editablecell_changes.datatype = Array.isArray(/*datatype*/ ctx[0]) 1503 ? /*datatype*/ ctx[0][/*j*/ ctx[89]] 1504 : /*datatype*/ ctx[0]; 1505 1506 editablecell.$set(editablecell_changes); 1507 1508 if (j !== /*j*/ ctx[89]) { 1509 unassign_td(); 1510 j = /*j*/ ctx[89]; 1511 assign_td(); 1512 } 1513 }, 1514 i(local) { 1515 if (current) return; 1516 transition_in$1(editablecell.$$.fragment, local); 1517 current = true; 1518 }, 1519 o(local) { 1520 transition_out$1(editablecell.$$.fragment, local); 1521 current = false; 1522 }, 1523 d(detaching) { 1524 if (detaching) { 1525 detach$1(td); 1526 } 1527 1528 destroy_component$1(editablecell); 1529 unassign_td(); 1530 } 1531 }; 1532} 1533 1534// (601:4) {#if label && label.length !== 0} 1535function create_if_block_3(ctx) { 1536 let caption; 1537 let t; 1538 1539 return { 1540 c() { 1541 caption = element("caption"); 1542 t = text(/*label*/ ctx[1]); 1543 attr(caption, "class", "sr-only"); 1544 }, 1545 m(target, anchor) { 1546 insert$1(target, caption, anchor); 1547 append(caption, t); 1548 }, 1549 p(ctx, dirty) { 1550 if (dirty[0] & /*label*/ 2) set_data(t, /*label*/ ctx[1]); 1551 }, 1552 d(detaching) { 1553 if (detaching) { 1554 detach$1(caption); 1555 } 1556 } 1557 }; 1558} 1559 1560// (593:3) <VirtualTable bind:items={data} table_width={t_width} max_height={height} bind:actual_height={table_height} bind:table_scrollbar_width={scrollbar_width} selected={selected_index} > 1561function create_default_slot_3(ctx) { 1562 let if_block_anchor; 1563 let if_block = /*label*/ ctx[1] && /*label*/ ctx[1].length !== 0 && create_if_block_3(ctx); 1564 1565 return { 1566 c() { 1567 if (if_block) if_block.c(); 1568 if_block_anchor = empty(); 1569 }, 1570 m(target, anchor) { 1571 if (if_block) if_block.m(target, anchor); 1572 insert$1(target, if_block_anchor, anchor); 1573 }, 1574 p(ctx, dirty) { 1575 if (/*label*/ ctx[1] && /*label*/ ctx[1].length !== 0) { 1576 if (if_block) { 1577 if_block.p(ctx, dirty); 1578 } else { 1579 if_block = create_if_block_3(ctx); 1580 if_block.c(); 1581 if_block.m(if_block_anchor.parentNode, if_block_anchor); 1582 } 1583 } else if (if_block) { 1584 if_block.d(1); 1585 if_block = null; 1586 } 1587 }, 1588 d(detaching) { 1589 if (detaching) { 1590 detach$1(if_block_anchor); 1591 } 1592 1593 if (if_block) if_block.d(detaching); 1594 } 1595 }; 1596} 1597 1598// (605:5) {#each _headers as { value, id } 1599function create_each_block_1(key_1, ctx) { 1600 let th; 1601 let div1; 1602 let editablecell; 1603 let updating_value; 1604 let updating_el; 1605 let t0; 1606 let div0; 1607 let svg; 1608 let path; 1609 let div0_class_value; 1610 let t1; 1611 let th_aria_sort_value; 1612 let current; 1613 let mounted; 1614 let dispose; 1615 1616 function editablecell_value_binding_1(value) { 1617 /*editablecell_value_binding_1*/ ctx[61](value, /*i*/ ctx[91]); 1618 } 1619 1620 function editablecell_el_binding_1(value) {
1621 /*editablecell_el_binding_1*/ ctx[62](value, /*id*/ ctx[87]); 1622 } 1623 1624 function dblclick_handler_1() { 1625 return /*dblclick_handler_1*/ ctx[63](/*i*/ ctx[91]); 1626 } 1627 1628 let editablecell_props = { 1629 latex_delimiters: /*latex_delimiters*/ ctx[4], 1630 line_breaks: /*line_breaks*/ ctx[10], 1631 edit: /*header_edit*/ ctx[24] === /*i*/ ctx[91], 1632 select_on_focus: /*select_on_focus*/ ctx[25], 1633 header: true 1634 }; 1635 1636 if (/*_headers*/ ctx[16][/*i*/ ctx[91]].value !== void 0) { 1637 editablecell_props.value = /*_headers*/ ctx[16][/*i*/ ctx[91]].value; 1638 } 1639 1640 if (/*els*/ ctx[22][/*id*/ ctx[87]].input !== void 0) { 1641 editablecell_props.el = /*els*/ ctx[22][/*id*/ ctx[87]].input; 1642 } 1643 1644 editablecell = new EditableCell({ props: editablecell_props }); 1645 binding_callbacks.push(() => bind(editablecell, 'value', editablecell_value_binding_1)); 1646 binding_callbacks.push(() => bind(editablecell, 'el', editablecell_el_binding_1)); 1647 editablecell.$on("keydown", /*end_header_edit*/ ctx[41]); 1648 editablecell.$on("dblclick", dblclick_handler_1); 1649 1650 function click_handler_1() { 1651 return /*click_handler_1*/ ctx[64](/*i*/ ctx[91]); 1652 } 1653 1654 return { 1655 key: key_1, 1656 first: null, 1657 c() { 1658 th = element("th"); 1659 div1 = element("div"); 1660 create_component$1(editablecell.$$.fragment); 1661 t0 = space$1(); 1662 div0 = element("div"); 1663 svg = svg_element("svg"); 1664 path = svg_element("path"); 1665 t1 = space$1(); 1666 attr(path, "d", "M4.49999 0L8.3971 6.75H0.602875L4.49999 0Z"); 1667 attr(svg, "width", "1em"); 1668 attr(svg, "height", "1em"); 1669 attr(svg, "viewBox", "0 0 9 7"); 1670 attr(svg, "fill", "none"); 1671 attr(svg, "xmlns", "http://www.w3.org/2000/svg"); 1672 attr(svg, "class", "svelte-1bvc1p0"); 1673 attr(div0, "class", div0_class_value = "sort-button " + /*sort_direction*/ ctx[18] + "" + " svelte-1bvc1p0"); 1674 toggle_class(div0, "sorted", /*sort_by*/ ctx[19] === /*i*/ ctx[91]); 1675 toggle_class(div0, "des", /*sort_by*/ ctx[19] === /*i*/ ctx[91] && /*sort_direction*/ ctx[18] === "des"); 1676 attr(div1, "class", "cell-wrap svelte-1bvc1p0"); 1677 attr(th, "aria-sort", th_aria_sort_value = /*get_sort_status*/ ctx[35](/*value*/ ctx[12], /*sort_by*/ ctx[19], /*sort_direction*/ ctx[18])); 1678 set_style(th, "width", "var(--cell-width-" + /*i*/ ctx[91] + ")"); 1679 attr(th, "class", "svelte-1bvc1p0"); 1680 toggle_class(th, "focus", /*header_edit*/ ctx[24] === /*i*/ ctx[91] || /*selected_header*/ ctx[26] === /*i*/ ctx[91]); 1681 this.first = th; 1682 }, 1683 m(target, anchor) { 1684 insert$1(target, th, anchor); 1685 append(th, div1); 1686 mount_component$1(editablecell, div1, null); 1687 append(div1, t0); 1688 append(div1, div0); 1689 append(div0, svg); 1690 append(svg, path); 1691 append(th, t1); 1692 current = true; 1693 1694 if (!mounted) { 1695 dispose = listen(div0, "click", click_handler_1); 1696 mounted = true; 1697 } 1698 }, 1699 p(new_ctx, dirty) { 1700 ctx = new_ctx; 1701 const editablecell_changes = {}; 1702 if (dirty[0] & /*latex_delimiters*/ 16) editablecell_changes.latex_delimiters = /*latex_delimiters*/ ctx[4]; 1703 if (dirty[0] & /*line_breaks*/ 1024) editablecell_changes.line_breaks = /*line_breaks*/ ctx[10]; 1704 if (dirty[0] & /*header_edit, _headers*/ 16842752) editablecell_changes.edit = /*header_edit*/ ctx[24] === /*i*/ ctx[91]; 1705 if (dirty[0] & /*select_on_focus*/ 33554432) editablecell_changes.select_on_focus = /*select_on_focus*/ ctx[25]; 1706 1707 if (!updating_value && dirty[0] & /*_headers*/ 65536) { 1708 updating_value = true; 1709 editablecell_changes.value = /*_headers*/ ctx[16][/*i*/ ctx[91]].value; 1710 add_flush_callback(() => updating_value = false); 1711 } 1712 1713 if (!updating_el && dirty[0] & /*els, _headers*/ 4259840) { 1714 updating_el = true; 1715 editablecell_changes.el = /*els*/ ctx[22][/*id*/ ctx[87]].input; 1716 add_flush_callback(() => updating_el = false); 1717 } 1718 1719 editablecell.$set(editablecell_changes); 1720 1721 if (!current || dirty[0] & /*sort_direction*/ 262144 && div0_class_value !== (div0_class_value = "sort-button " + /*sort_direction*/ ctx[18] + "" + " svelte-1bvc1p0")) { 1722 attr(div0, "class", div0_class_value); 1723 } 1724 1725 if (!current || dirty[0] & /*sort_direction, sort_by, _headers*/ 851968) { 1726 toggle_class(div0, "sorted", /*sort_by*/ ctx[19] === /*i*/ ctx[91]); 1727 } 1728 1729 if (!current || dirty[0] & /*sort_direction, sort_by, _headers, sort_direction*/ 851968) { 1730 toggle_class(div0, "des", /*sort_by*/ ctx[19] === /*i*/ ctx[91] && /*sort_direction*/ ctx[18] === "des"); 1731 } 1732 1733 if (!current || dirty[0] & /*_headers, sort_by, sort_direction*/ 851968 && th_aria_sort_value !== (th_aria_sort_value = /*get_sort_status*/ ctx[35](/*value*/ ctx[12], /*sort_by*/ ctx[19], /*sort_direction*/ ctx[18]))) { 1734 attr(th, "aria-sort", th_aria_sort_value); 1735 } 1736 1737 if (!current || dirty[0] & /*_headers*/ 65536) { 1738 set_style(th, "width", "var(--cell-width-" + /*i*/ ctx[91] + ")"); 1739 } 1740 1741 if (!current || dirty[0] & /*header_edit, _headers, selected_header*/ 83951616) { 1742 toggle_class(th, "focus", /*header_edit*/ ctx[24] === /*i*/ ctx[91] || /*selected_header*/ ctx[26] === /*i*/ ctx[91]); 1743 } 1744 }, 1745 i(local) { 1746 if (current) return; 1747 transition_in$1(editablecell.$$.fragment, local); 1748 current = true; 1749 }, 1750 o(local) { 1751 transition_out$1(editablecell.$$.fragment, local); 1752 current = false;
1753 }, 1754 d(detaching) { 1755 if (detaching) { 1756 detach$1(th); 1757 } 1758 1759 destroy_component$1(editablecell); 1760 mounted = false; 1761 dispose(); 1762 } 1763 }; 1764} 1765 1766// (604:4) 1767function create_thead_slot(ctx) { 1768 let tr; 1769 let each_blocks = []; 1770 let each_1_lookup = new Map(); 1771 let current; 1772 let each_value_1 = ensure_array_like(/*_headers*/ ctx[16]); 1773 const get_key = ctx => /*id*/ ctx[87]; 1774 1775 for (let i = 0; i < each_value_1.length; i += 1) { 1776 let child_ctx = get_each_context_1(ctx, each_value_1, i); 1777 let key = get_key(child_ctx); 1778 each_1_lookup.set(key, each_blocks[i] = create_each_block_1(key, child_ctx)); 1779 } 1780 1781 return { 1782 c() { 1783 tr = element("tr"); 1784 1785 for (let i = 0; i < each_blocks.length; i += 1) { 1786 each_blocks[i].c(); 1787 } 1788 1789 attr(tr, "slot", "thead"); 1790 attr(tr, "class", "svelte-1bvc1p0"); 1791 }, 1792 m(target, anchor) { 1793 insert$1(target, tr, anchor); 1794 1795 for (let i = 0; i < each_blocks.length; i += 1) { 1796 if (each_blocks[i]) { 1797 each_blocks[i].m(tr, null); 1798 } 1799 } 1800 1801 current = true; 1802 }, 1803 p(ctx, dirty) { 1804 if (dirty[0] & /*_headers, sort_by, sort_direction, header_edit, selected_header, latex_delimiters, line_breaks, select_on_focus, els*/ 122487824 | dirty[1] & /*get_sort_status, handle_sort, end_header_edit, edit_header*/ 1808) { 1805 each_value_1 = ensure_array_like(/*_headers*/ ctx[16]); 1806 group_outros(); 1807 each_blocks = update_keyed_each(each_blocks, dirty, get_key, 1, ctx, each_value_1, each_1_lookup, tr, outro_and_destroy_block, create_each_block_1, null, get_each_context_1); 1808 check_outros(); 1809 } 1810 }, 1811 i(local) { 1812 if (current) return; 1813 1814 for (let i = 0; i < each_value_1.length; i += 1) { 1815 transition_in$1(each_blocks[i]); 1816 } 1817 1818 current = true; 1819 }, 1820 o(local) { 1821 for (let i = 0; i < each_blocks.length; i += 1) { 1822 transition_out$1(each_blocks[i]); 1823 } 1824 1825 current = false; 1826 }, 1827 d(detaching) { 1828 if (detaching) { 1829 detach$1(tr); 1830 } 1831 1832 for (let i = 0; i < each_blocks.length; i += 1) { 1833 each_blocks[i].d(); 1834 } 1835 } 1836 }; 1837} 1838 1839// (649:5) {#each item as { value, id } 1840function create_each_block(key_1, ctx) { 1841 let td; 1842 let div; 1843 let editablecell; 1844 let updating_value; 1845 let updating_el; 1846 let t; 1847 let td_style_value; 1848 let style_width = `var(--cell-width-${/*j*/ ctx[89]})`; 1849 let current; 1850 let mounted; 1851 let dispose; 1852 1853 function editablecell_value_binding(value) { 1854 /*editablecell_value_binding*/ ctx[55](value, /*index*/ ctx[85], /*j*/ ctx[89]); 1855 } 1856 1857 function editablecell_el_binding(value) { 1858 /*editablecell_el_binding*/ ctx[56](value, /*id*/ ctx[87]); 1859 } 1860 1861 let editablecell_props = { 1862 display_value: /*display_value*/ ctx[14]?.[/*index*/ ctx[85]]?.[/*j*/ ctx[89]], 1863 latex_delimiters: /*latex_delimiters*/ ctx[4], 1864 line_breaks: /*line_breaks*/ ctx[10], 1865 editable: /*editable*/ ctx[5], 1866 edit: dequal(/*editing*/ ctx[21], [/*index*/ ctx[85], /*j*/ ctx[89]]), 1867 datatype: Array.isArray(/*datatype*/ ctx[0]) 1868 ? /*datatype*/ ctx[0][/*j*/ ctx[89]] 1869 : /*datatype*/ ctx[0], 1870 clear_on_focus: /*clear_on_focus*/ ctx[23] 1871 }; 1872 1873 if (/*data*/ ctx[17][/*index*/ ctx[85]][/*j*/ ctx[89]].value !== void 0) { 1874 editablecell_props.value = /*data*/ ctx[17][/*index*/ ctx[85]][/*j*/ ctx[89]].value; 1875 } 1876 1877 if (/*els*/ ctx[22][/*id*/ ctx[87]].input !== void 0) { 1878 editablecell_props.el = /*els*/ ctx[22][/*id*/ ctx[87]].input; 1879 } 1880 1881 editablecell = new EditableCell({ props: editablecell_props }); 1882 binding_callbacks.push(() => bind(editablecell, 'value', editablecell_value_binding)); 1883 binding_callbacks.push(() => bind(editablecell, 'el', editablecell_el_binding)); 1884 editablecell.$on("blur", /*blur_handler*/ ctx[57]); 1885 1886 function touchstart_handler() { 1887 return /*touchstart_handler*/ ctx[58](/*index*/ ctx[85], /*j*/ ctx[89]); 1888 } 1889 1890 function click_handler() { 1891 return /*click_handler*/ ctx[59](/*index*/ ctx[85], /*j*/ ctx[89]); 1892 } 1893 1894 function dblclick_handler() { 1895 return /*dblclick_handler*/ ctx[60](/*index*/ ctx[85], /*j*/ ctx[89]); 1896 } 1897 1898 return { 1899 key: key_1, 1900 first: null, 1901 c() { 1902 td = element("td"); 1903 div = element("div"); 1904 create_component$1(editablecell.$$.fragment); 1905 t = space$1(); 1906 attr(div, "class", "cell-wrap svelte-1bvc1p0"); 1907 attr(td, "tabindex", "0"); 1908 attr(td, "style", td_style_value = /*styling*/ ctx[15]?.[/*index*/ ctx[85]]?.[/*j*/ ctx[89]] || ""); 1909 attr(td, "class", "svelte-1bvc1p0"); 1910 toggle_class(td, "focus", dequal(/*selected*/ ctx[13], [/*index*/ ctx[85], /*j*/ ctx[89]])); 1911 set_style(td, "width", style_width); 1912 this.first = td; 1913 }, 1914 m(target, anchor) { 1915 insert$1(target, td, anchor); 1916 append(td, div);
1917 mount_component$1(editablecell, div, null); 1918 append(td, t); 1919 current = true; 1920 1921 if (!mounted) { 1922 dispose = [ 1923 listen(td, "touchstart", touchstart_handler, { passive: true }), 1924 listen(td, "click", click_handler), 1925 listen(td, "dblclick", dblclick_handler) 1926 ]; 1927 1928 mounted = true; 1929 } 1930 }, 1931 p(new_ctx, dirty) { 1932 ctx = new_ctx; 1933 const editablecell_changes = {}; 1934 if (dirty[0] & /*display_value*/ 16384 | dirty[2] & /*index, item*/ 25165824) editablecell_changes.display_value = /*display_value*/ ctx[14]?.[/*index*/ ctx[85]]?.[/*j*/ ctx[89]]; 1935 if (dirty[0] & /*latex_delimiters*/ 16) editablecell_changes.latex_delimiters = /*latex_delimiters*/ ctx[4]; 1936 if (dirty[0] & /*line_breaks*/ 1024) editablecell_changes.line_breaks = /*line_breaks*/ ctx[10]; 1937 if (dirty[0] & /*editable*/ 32) editablecell_changes.editable = /*editable*/ ctx[5]; 1938 if (dirty[0] & /*editing*/ 2097152 | dirty[2] & /*index, item*/ 25165824) editablecell_changes.edit = dequal(/*editing*/ ctx[21], [/*index*/ ctx[85], /*j*/ ctx[89]]); 1939 1940 if (dirty[0] & /*datatype*/ 1 | dirty[2] & /*item*/ 16777216) editablecell_changes.datatype = Array.isArray(/*datatype*/ ctx[0]) 1941 ? /*datatype*/ ctx[0][/*j*/ ctx[89]] 1942 : /*datatype*/ ctx[0]; 1943 1944 if (dirty[0] & /*clear_on_focus*/ 8388608) editablecell_changes.clear_on_focus = /*clear_on_focus*/ ctx[23]; 1945 1946 if (!updating_value && dirty[0] & /*data*/ 131072 | dirty[2] & /*index, item*/ 25165824) { 1947 updating_value = true; 1948 editablecell_changes.value = /*data*/ ctx[17][/*index*/ ctx[85]][/*j*/ ctx[89]].value; 1949 add_flush_callback(() => updating_value = false); 1950 } 1951 1952 if (!updating_el && dirty[0] & /*els*/ 4194304 | dirty[2] & /*item*/ 16777216) { 1953 updating_el = true; 1954 editablecell_changes.el = /*els*/ ctx[22][/*id*/ ctx[87]].input; 1955 add_flush_callback(() => updating_el = false); 1956 } 1957 1958 editablecell.$set(editablecell_changes); 1959 1960 if (!current || dirty[0] & /*styling*/ 32768 | dirty[2] & /*index, item*/ 25165824 && td_style_value !== (td_style_value = /*styling*/ ctx[15]?.[/*index*/ ctx[85]]?.[/*j*/ ctx[89]] || "")) { 1961 attr(td, "style", td_style_value); 1962 } 1963 1964 if (!current || dirty[0] & /*selected*/ 8192 | dirty[2] & /*index, item*/ 25165824) { 1965 toggle_class(td, "focus", dequal(/*selected*/ ctx[13], [/*index*/ ctx[85], /*j*/ ctx[89]])); 1966 } 1967 1968 const style_changed = dirty[0] & /*styling*/ 32768 | dirty[2] & /*index, item*/ 25165824; 1969 1970 if (dirty[0] & /*styling*/ 32768 | dirty[2] & /*item, index*/ 25165824 && style_width !== (style_width = `var(--cell-width-${/*j*/ ctx[89]})`) || style_changed) { 1971 set_style(td, "width", style_width); 1972 } 1973 }, 1974 i(local) { 1975 if (current) return; 1976 transition_in$1(editablecell.$$.fragment, local); 1977 current = true; 1978 }, 1979 o(local) { 1980 transition_out$1(editablecell.$$.fragment, local); 1981 current = false; 1982 }, 1983 d(detaching) { 1984 if (detaching) { 1985 detach$1(td); 1986 } 1987 1988 destroy_component$1(editablecell); 1989 mounted = false; 1990 run_all(dispose); 1991 } 1992 }; 1993} 1994 1995// (648:4) 1996function create_tbody_slot(ctx) { 1997 let tr; 1998 let each_blocks = []; 1999 let each_1_lookup = new Map(); 2000 let current; 2001 let each_value = ensure_array_like(/*item*/ ctx[86]); 2002 const get_key = ctx => /*id*/ ctx[87]; 2003 2004 for (let i = 0; i < each_value.length; i += 1) { 2005 let child_ctx = get_each_context(ctx, each_value, i); 2006 let key = get_key(child_ctx); 2007 each_1_lookup.set(key, each_blocks[i] = create_each_block(key, child_ctx)); 2008 } 2009 2010 return { 2011 c() { 2012 tr = element("tr"); 2013 2014 for (let i = 0; i < each_blocks.length; i += 1) { 2015 each_blocks[i].c(); 2016 } 2017 2018 attr(tr, "slot", "tbody"); 2019 attr(tr, "class", "svelte-1bvc1p0"); 2020 toggle_class(tr, "row_odd", /*index*/ ctx[85] % 2 === 0); 2021 }, 2022 m(target, anchor) { 2023 insert$1(target, tr, anchor); 2024 2025 for (let i = 0; i < each_blocks.length; i += 1) { 2026 if (each_blocks[i]) { 2027 each_blocks[i].m(tr, null); 2028 } 2029 } 2030 2031 current = true; 2032 }, 2033 p(ctx, dirty) { 2034 if (dirty[0] & /*styling, selected, display_value, latex_delimiters, line_breaks, editable, editing, datatype, clear_on_focus, data, els, parent*/ 551740465 | dirty[1] & /*start_edit, handle_cell_click*/ 160 | dirty[2] & /*index, item*/ 25165824) { 2035 each_value = ensure_array_like(/*item*/ ctx[86]); 2036 group_outros(); 2037 each_blocks = update_keyed_each(each_blocks, dirty, get_key, 1, ctx, each_value, each_1_lookup, tr, outro_and_destroy_block, create_each_block, null, get_each_context); 2038 check_outros(); 2039 } 2040 2041 if (!current || dirty[2] & /*index*/ 8388608) { 2042 toggle_class(tr, "row_odd", /*index*/ ctx[85] % 2 === 0); 2043 } 2044 }, 2045 i(local) { 2046 if (current) return; 2047 2048 for (let i = 0; i < each_value.length; i += 1) { 2049 transition_in$1(each_blocks[i]); 2050 } 2051 2052 current = true; 2053 }, 2054 o(local) { 2055 for (let i = 0; i < each_blocks.length; i += 1) { 2056 transition_out$1(each_blocks[i]); 2057 } 2058 2059 current = false;
2060 }, 2061 d(detaching) { 2062 if (detaching) { 2063 detach$1(tr); 2064 } 2065 2066 for (let i = 0; i < each_blocks.length; i += 1) { 2067 each_blocks[i].d(); 2068 } 2069 } 2070 }; 2071} 2072 2073// (584:2) <Upload flex={false} center={false} boundedheight={false} disable_click={true} {root} on:load={(e) => blob_to_string(data_uri_to_blob(e.detail.data))} bind:dragging > 2074function create_default_slot_2(ctx) { 2075 let virtualtable; 2076 let updating_items; 2077 let updating_actual_height; 2078 let updating_table_scrollbar_width; 2079 let current; 2080 2081 function virtualtable_items_binding(value) { 2082 /*virtualtable_items_binding*/ ctx[65](value); 2083 } 2084 2085 function virtualtable_actual_height_binding(value) { 2086 /*virtualtable_actual_height_binding*/ ctx[66](value); 2087 } 2088 2089 function virtualtable_table_scrollbar_width_binding(value) { 2090 /*virtualtable_table_scrollbar_width_binding*/ ctx[67](value); 2091 } 2092 2093 let virtualtable_props = { 2094 table_width: /*t_width*/ ctx[28], 2095 max_height: /*height*/ ctx[9], 2096 selected: /*selected_index*/ ctx[33], 2097 $$slots: { 2098 tbody: [ 2099 create_tbody_slot, 2100 ({ index, item }) => ({ 85: index, 86: item }), 2101 ({ index, item }) => [0, 0, (index ? 8388608 : 0) | (item ? 16777216 : 0)] 2102 ], 2103 thead: [create_thead_slot], 2104 default: [create_default_slot_3] 2105 }, 2106 $$scope: { ctx } 2107 }; 2108 2109 if (/*data*/ ctx[17] !== void 0) { 2110 virtualtable_props.items = /*data*/ ctx[17]; 2111 } 2112 2113 if (/*table_height*/ ctx[31] !== void 0) { 2114 virtualtable_props.actual_height = /*table_height*/ ctx[31]; 2115 } 2116 2117 if (/*scrollbar_width*/ ctx[32] !== void 0) { 2118 virtualtable_props.table_scrollbar_width = /*scrollbar_width*/ ctx[32]; 2119 } 2120 2121 virtualtable = new VirtualTable({ props: virtualtable_props }); 2122 binding_callbacks.push(() => bind(virtualtable, 'items', virtualtable_items_binding)); 2123 binding_callbacks.push(() => bind(virtualtable, 'actual_height', virtualtable_actual_height_binding)); 2124 binding_callbacks.push(() => bind(virtualtable, 'table_scrollbar_width', virtualtable_table_scrollbar_width_binding)); 2125 2126 return { 2127 c() { 2128 create_component$1(virtualtable.$$.fragment); 2129 }, 2130 m(target, anchor) { 2131 mount_component$1(virtualtable, target, anchor); 2132 current = true; 2133 }, 2134 p(ctx, dirty) { 2135 const virtualtable_changes = {}; 2136 if (dirty[0] & /*t_width*/ 268435456) virtualtable_changes.table_width = /*t_width*/ ctx[28]; 2137 if (dirty[0] & /*height*/ 512) virtualtable_changes.max_height = /*height*/ ctx[9]; 2138 if (dirty[1] & /*selected_index*/ 4) virtualtable_changes.selected = /*selected_index*/ ctx[33]; 2139 2140 if (dirty[0] & /*styling, selected, display_value, latex_delimiters, line_breaks, editable, editing, datatype, clear_on_focus, data, els, parent, _headers, sort_by, sort_direction, header_edit, selected_header, select_on_focus, label*/ 670032947 | dirty[2] & /*index, item*/ 25165824 | dirty[3] & /*$$scope*/ 2) { 2141 virtualtable_changes.$$scope = { dirty, ctx }; 2142 } 2143 2144 if (!updating_items && dirty[0] & /*data*/ 131072) { 2145 updating_items = true; 2146 virtualtable_changes.items = /*data*/ ctx[17]; 2147 add_flush_callback(() => updating_items = false); 2148 } 2149 2150 if (!updating_actual_height && dirty[1] & /*table_height*/ 1) { 2151 updating_actual_height = true; 2152 virtualtable_changes.actual_height = /*table_height*/ ctx[31]; 2153 add_flush_callback(() => updating_actual_height = false); 2154 } 2155 2156 if (!updating_table_scrollbar_width && dirty[1] & /*scrollbar_width*/ 2) { 2157 updating_table_scrollbar_width = true; 2158 virtualtable_changes.table_scrollbar_width = /*scrollbar_width*/ ctx[32]; 2159 add_flush_callback(() => updating_table_scrollbar_width = false); 2160 } 2161 2162 virtualtable.$set(virtualtable_changes); 2163 }, 2164 i(local) { 2165 if (current) return; 2166 transition_in$1(virtualtable.$$.fragment, local); 2167 current = true; 2168 }, 2169 o(local) { 2170 transition_out$1(virtualtable.$$.fragment, local); 2171 current = false; 2172 }, 2173 d(detaching) { 2174 destroy_component$1(virtualtable, detaching); 2175 } 2176 }; 2177} 2178 2179// (679:1) {#if editable} 2180function create_if_block(ctx) { 2181 let div; 2182 let t; 2183 let current; 2184 let if_block0 = /*row_count*/ ctx[3][1] === "dynamic" && create_if_block_2(ctx); 2185 let if_block1 = /*col_count*/ ctx[2][1] === "dynamic" && create_if_block_1(ctx); 2186 2187 return { 2188 c() { 2189 div = element("div"); 2190 if (if_block0) if_block0.c(); 2191 t = space$1(); 2192 if (if_block1) if_block1.c(); 2193 attr(div, "class", "controls-wrap svelte-1bvc1p0"); 2194 }, 2195 m(target, anchor) { 2196 insert$1(target, div, anchor); 2197 if (if_block0) if_block0.m(div, null); 2198 append(div, t); 2199 if (if_block1) if_block1.m(div, null); 2200 current = true; 2201 }, 2202 p(ctx, dirty) { 2203 if (/*row_count*/ ctx[3][1] === "dynamic") { 2204 if (if_block0) { 2205 if_block0.p(ctx, dirty); 2206
2207 if (dirty[0] & /*row_count*/ 8) { 2208 transition_in$1(if_block0, 1); 2209 } 2210 } else { 2211 if_block0 = create_if_block_2(ctx); 2212 if_block0.c(); 2213 transition_in$1(if_block0, 1); 2214 if_block0.m(div, t); 2215 } 2216 } else if (if_block0) { 2217 group_outros(); 2218 2219 transition_out$1(if_block0, 1, 1, () => { 2220 if_block0 = null; 2221 }); 2222 2223 check_outros(); 2224 } 2225 2226 if (/*col_count*/ ctx[2][1] === "dynamic") { 2227 if (if_block1) { 2228 if_block1.p(ctx, dirty); 2229 2230 if (dirty[0] & /*col_count*/ 4) { 2231 transition_in$1(if_block1, 1); 2232 } 2233 } else { 2234 if_block1 = create_if_block_1(ctx); 2235 if_block1.c(); 2236 transition_in$1(if_block1, 1); 2237 if_block1.m(div, null); 2238 } 2239 } else if (if_block1) { 2240 group_outros(); 2241 2242 transition_out$1(if_block1, 1, 1, () => { 2243 if_block1 = null; 2244 }); 2245 2246 check_outros(); 2247 } 2248 }, 2249 i(local) { 2250 if (current) return; 2251 transition_in$1(if_block0); 2252 transition_in$1(if_block1); 2253 current = true; 2254 }, 2255 o(local) { 2256 transition_out$1(if_block0); 2257 transition_out$1(if_block1); 2258 current = false; 2259 }, 2260 d(detaching) { 2261 if (detaching) { 2262 detach$1(div); 2263 } 2264 2265 if (if_block0) if_block0.d(); 2266 if (if_block1) if_block1.d(); 2267 } 2268 }; 2269} 2270 2271// (681:3) {#if row_count[1] === "dynamic"} 2272function create_if_block_2(ctx) { 2273 let span; 2274 let basebutton; 2275 let current; 2276 2277 basebutton = new Button({ 2278 props: { 2279 variant: "secondary", 2280 size: "sm", 2281 $$slots: { default: [create_default_slot_1] }, 2282 $$scope: { ctx } 2283 } 2284 }); 2285 2286 basebutton.$on("click", /*click_handler_2*/ ctx[72]); 2287 2288 return { 2289 c() { 2290 span = element("span"); 2291 create_component$1(basebutton.$$.fragment); 2292 attr(span, "class", "button-wrap svelte-1bvc1p0"); 2293 }, 2294 m(target, anchor) { 2295 insert$1(target, span, anchor); 2296 mount_component$1(basebutton, span, null); 2297 current = true; 2298 }, 2299 p(ctx, dirty) { 2300 const basebutton_changes = {}; 2301 2302 if (dirty[0] & /*i18n*/ 256 | dirty[3] & /*$$scope*/ 2) { 2303 basebutton_changes.$$scope = { dirty, ctx }; 2304 } 2305 2306 basebutton.$set(basebutton_changes); 2307 }, 2308 i(local) { 2309 if (current) return; 2310 transition_in$1(basebutton.$$.fragment, local); 2311 current = true; 2312 }, 2313 o(local) { 2314 transition_out$1(basebutton.$$.fragment, local); 2315 current = false; 2316 }, 2317 d(detaching) { 2318 if (detaching) { 2319 detach$1(span); 2320 } 2321 2322 destroy_component$1(basebutton); 2323 } 2324 }; 2325} 2326 2327// (683:5) <BaseButton variant="secondary" size="sm" on:click={(e) => (e.stopPropagation(), add_row())} > 2328function create_default_slot_1(ctx) { 2329 let svg; 2330 let path; 2331 let t0; 2332 let t1_value = /*i18n*/ ctx[8]("dataframe.new_row") + ""; 2333 let t1; 2334 2335 return { 2336 c() { 2337 svg = svg_element("svg"); 2338 path = svg_element("path"); 2339 t0 = space$1(); 2340 t1 = text(t1_value); 2341 attr(path, "fill", "currentColor"); 2342 attr(path, "d", "M24.59 16.59L17 24.17V4h-2v20.17l-7.59-7.58L6 18l10 10l10-10l-1.41-1.41z"); 2343 attr(svg, "xmlns", "http://www.w3.org/2000/svg"); 2344 attr(svg, "xmlns:xlink", "http://www.w3.org/1999/xlink"); 2345 attr(svg, "aria-hidden", "true"); 2346 attr(svg, "role", "img"); 2347 attr(svg, "width", "1em"); 2348 attr(svg, "height", "1em"); 2349 attr(svg, "preserveAspectRatio", "xMidYMid meet"); 2350 attr(svg, "viewBox", "0 0 32 32"); 2351 attr(svg, "class", "svelte-1bvc1p0"); 2352 }, 2353 m(target, anchor) { 2354 insert$1(target, svg, anchor); 2355 append(svg, path); 2356 insert$1(target, t0, anchor); 2357 insert$1(target, t1, anchor); 2358 }, 2359 p(ctx, dirty) { 2360 if (dirty[0] & /*i18n*/ 256 && t1_value !== (t1_value = /*i18n*/ ctx[8]("dataframe.new_row") + "")) set_data(t1, t1_value); 2361 }, 2362 d(detaching) { 2363 if (detaching) { 2364 detach$1(svg); 2365 detach$1(t0); 2366 detach$1(t1); 2367 } 2368 } 2369 }; 2370} 2371 2372// (707:3) {#if col_count[1] === "dynamic"} 2373function create_if_block_1(ctx) { 2374 let span; 2375 let basebutton; 2376 let current; 2377 2378 basebutton = new Button({ 2379 props: { 2380 variant: "secondary", 2381 size: "sm", 2382 $$slots: { default: [create_default_slot$1] }, 2383 $$scope: { ctx } 2384 } 2385 }); 2386 2387 basebutton.$on("click", /*click_handler_3*/ ctx[73]); 2388 2389 return { 2390 c() { 2391 span = element("span"); 2392 create_component$1(basebutton.$$.fragment); 2393 attr(span, "class", "button-wrap svelte-1bvc1p0"); 2394 }, 2395 m(target, anchor) { 2396 insert$1(target, span, anchor);
2397 mount_component$1(basebutton, span, null); 2398 current = true; 2399 }, 2400 p(ctx, dirty) { 2401 const basebutton_changes = {}; 2402 2403 if (dirty[0] & /*i18n*/ 256 | dirty[3] & /*$$scope*/ 2) { 2404 basebutton_changes.$$scope = { dirty, ctx }; 2405 } 2406 2407 basebutton.$set(basebutton_changes); 2408 }, 2409 i(local) { 2410 if (current) return; 2411 transition_in$1(basebutton.$$.fragment, local); 2412 current = true; 2413 }, 2414 o(local) { 2415 transition_out$1(basebutton.$$.fragment, local); 2416 current = false; 2417 }, 2418 d(detaching) { 2419 if (detaching) { 2420 detach$1(span); 2421 } 2422 2423 destroy_component$1(basebutton); 2424 } 2425 }; 2426} 2427 2428// (709:5) <BaseButton variant="secondary" size="sm" on:click={(e) => (e.stopPropagation(), add_col())} > 2429function create_default_slot$1(ctx) { 2430 let svg; 2431 let path; 2432 let t0; 2433 let t1_value = /*i18n*/ ctx[8]("dataframe.new_column") + ""; 2434 let t1; 2435 2436 return { 2437 c() { 2438 svg = svg_element("svg"); 2439 path = svg_element("path"); 2440 t0 = space$1(); 2441 t1 = text(t1_value); 2442 attr(path, "fill", "currentColor"); 2443 attr(path, "d", "m18 6l-1.43 1.393L24.15 15H4v2h20.15l-7.58 7.573L18 26l10-10L18 6z"); 2444 attr(svg, "xmlns", "http://www.w3.org/2000/svg"); 2445 attr(svg, "xmlns:xlink", "http://www.w3.org/1999/xlink"); 2446 attr(svg, "aria-hidden", "true"); 2447 attr(svg, "role", "img"); 2448 attr(svg, "width", "1em"); 2449 attr(svg, "height", "1em"); 2450 attr(svg, "preserveAspectRatio", "xMidYMid meet"); 2451 attr(svg, "viewBox", "0 0 32 32"); 2452 attr(svg, "class", "svelte-1bvc1p0"); 2453 }, 2454 m(target, anchor) { 2455 insert$1(target, svg, anchor); 2456 append(svg, path); 2457 insert$1(target, t0, anchor); 2458 insert$1(target, t1, anchor); 2459 }, 2460 p(ctx, dirty) { 2461 if (dirty[0] & /*i18n*/ 256 && t1_value !== (t1_value = /*i18n*/ ctx[8]("dataframe.new_column") + "")) set_data(t1, t1_value); 2462 }, 2463 d(detaching) { 2464 if (detaching) { 2465 detach$1(svg); 2466 detach$1(t0); 2467 detach$1(t1); 2468 } 2469 } 2470 }; 2471} 2472 2473function create_fragment$1(ctx) { 2474 let div1; 2475 let t0; 2476 let div0; 2477 let table_1; 2478 let t1; 2479 let thead; 2480 let tr0; 2481 let each_blocks_1 = []; 2482 let each0_lookup = new Map(); 2483 let t2; 2484 let tbody; 2485 let tr1; 2486 let each_blocks = []; 2487 let each1_lookup = new Map(); 2488 let table_1_resize_listener; 2489 let t3; 2490 let upload; 2491 let updating_dragging; 2492 let t4; 2493 let current; 2494 let mounted; 2495 let dispose; 2496 let if_block0 = /*label*/ ctx[1] && /*label*/ ctx[1].length !== 0 && create_if_block_5(ctx); 2497 let if_block1 = /*label*/ ctx[1] && /*label*/ ctx[1].length !== 0 && create_if_block_4(ctx); 2498 let each_value_3 = ensure_array_like(/*_headers*/ ctx[16]); 2499 const get_key = ctx => /*id*/ ctx[87]; 2500 2501 for (let i = 0; i < each_value_3.length; i += 1) { 2502 let child_ctx = get_each_context_3(ctx, each_value_3, i); 2503 let key = get_key(child_ctx); 2504 each0_lookup.set(key, each_blocks_1[i] = create_each_block_3(key, child_ctx)); 2505 } 2506 2507 let each_value_2 = ensure_array_like(/*max*/ ctx[34]); 2508 const get_key_1 = ctx => /*id*/ ctx[87]; 2509 2510 for (let i = 0; i < each_value_2.length; i += 1) { 2511 let child_ctx = get_each_context_2(ctx, each_value_2, i); 2512 let key = get_key_1(child_ctx); 2513 each1_lookup.set(key, each_blocks[i] = create_each_block_2(key, child_ctx)); 2514 } 2515 2516 function upload_dragging_binding(value) { 2517 /*upload_dragging_binding*/ ctx[68](value); 2518 } 2519 2520 let upload_props = { 2521 flex: false, 2522 center: false, 2523 boundedheight: false, 2524 disable_click: true, 2525 root: /*root*/ ctx[7], 2526 $$slots: { default: [create_default_slot_2] }, 2527 $$scope: { ctx } 2528 }; 2529 2530 if (/*dragging*/ ctx[27] !== void 0) { 2531 upload_props.dragging = /*dragging*/ ctx[27]; 2532 } 2533 2534 upload = new Upload({ props: upload_props }); 2535 binding_callbacks.push(() => bind(upload, 'dragging', upload_dragging_binding)); 2536 upload.$on("load", /*load_handler*/ ctx[69]); 2537 let if_block2 = /*editable*/ ctx[5] && create_if_block(ctx); 2538 2539 return { 2540 c() { 2541 div1 = element("div"); 2542 if (if_block0) if_block0.c(); 2543 t0 = space$1(); 2544 div0 = element("div"); 2545 table_1 = element("table"); 2546 if (if_block1) if_block1.c(); 2547 t1 = space$1(); 2548 thead = element("thead"); 2549 tr0 = element("tr"); 2550 2551 for (let i = 0; i < each_blocks_1.length; i += 1) { 2552 each_blocks_1[i].c(); 2553 } 2554 2555 t2 = space$1(); 2556 tbody = element("tbody"); 2557 tr1 = element("tr"); 2558 2559 for (let i = 0; i < each_blocks.length; i += 1) { 2560 each_blocks[i].c(); 2561 } 2562 2563 t3 = space$1(); 2564 create_component$1(upload.$$.fragment); 2565 t4 = space$1(); 2566 if (if_block2) if_block2.c(); 2567 attr(tr0, "class", "svelte-1bvc1p0"); 2568 attr(thead, "class", "svelte-1bvc1p0"); 2569 attr(tr1, "class", "svelte-1bvc1p0"); 2570 attr(table_1, "class", "svelte-1bvc1p0"); 2571 add_render_callback(() =>
2571 /*table_1_elementresize_handler*/ ctx[53].call(table_1)); 2572 toggle_class(table_1, "fixed-layout", /*column_widths*/ ctx[11].length != 0); 2573 attr(div0, "class", "table-wrap svelte-1bvc1p0"); 2574 set_style(div0, "height", /*table_height*/ ctx[31] + "px"); 2575 attr(div0, "role", "grid"); 2576 attr(div0, "tabindex", "0"); 2577 toggle_class(div0, "dragging", /*dragging*/ ctx[27]); 2578 toggle_class(div0, "no-wrap", !/*wrap*/ ctx[6]); 2579 attr(div1, "class", "svelte-1bvc1p0"); 2580 toggle_class(div1, "label", /*label*/ ctx[1] && /*label*/ ctx[1].length !== 0); 2581 }, 2582 m(target, anchor) { 2583 insert$1(target, div1, anchor); 2584 if (if_block0) if_block0.m(div1, null); 2585 append(div1, t0); 2586 append(div1, div0); 2587 append(div0, table_1); 2588 if (if_block1) if_block1.m(table_1, null); 2589 append(table_1, t1); 2590 append(table_1, thead); 2591 append(thead, tr0); 2592 2593 for (let i = 0; i < each_blocks_1.length; i += 1) { 2594 if (each_blocks_1[i]) { 2595 each_blocks_1[i].m(tr0, null); 2596 } 2597 } 2598 2599 append(table_1, t2); 2600 append(table_1, tbody); 2601 append(tbody, tr1); 2602 2603 for (let i = 0; i < each_blocks.length; i += 1) { 2604 if (each_blocks[i]) { 2605 each_blocks[i].m(tr1, null); 2606 } 2607 } 2608 2609 table_1_resize_listener = add_iframe_resize_listener(table_1, /*table_1_elementresize_handler*/ ctx[53].bind(table_1)); 2610 /*table_1_binding*/ ctx[54](table_1); 2611 append(div0, t3); 2612 mount_component$1(upload, div0, null); 2613 /*div0_binding*/ ctx[70](div0); 2614 append(div1, t4); 2615 if (if_block2) if_block2.m(div1, null); 2616 current = true; 2617 2618 if (!mounted) { 2619 dispose = [ 2620 listen(window, "click", /*handle_click_outside*/ ctx[44]), 2621 listen(window, "touchstart", /*handle_click_outside*/ ctx[44]), 2622 listen(window, "resize", /*resize_handler*/ ctx[51]), 2623 listen(div0, "keydown", /*keydown_handler*/ ctx[71]), 2624 action_destroyer(copy.call(null, div1)) 2625 ]; 2626 2627 mounted = true; 2628 } 2629 }, 2630 p(ctx, dirty) { 2631 if (/*label*/ ctx[1] && /*label*/ ctx[1].length !== 0) { 2632 if (if_block0) { 2633 if_block0.p(ctx, dirty); 2634 } else { 2635 if_block0 = create_if_block_5(ctx); 2636 if_block0.c(); 2637 if_block0.m(div1, t0); 2638 } 2639 } else if (if_block0) { 2640 if_block0.d(1); 2641 if_block0 = null; 2642 } 2643 2644 if (/*label*/ ctx[1] && /*label*/ ctx[1].length !== 0) { 2645 if (if_block1) { 2646 if_block1.p(ctx, dirty); 2647 } else { 2648 if_block1 = create_if_block_4(ctx); 2649 if_block1.c(); 2650 if_block1.m(table_1, t1); 2651 } 2652 } else if (if_block1) { 2653 if_block1.d(1); 2654 if_block1 = null; 2655 } 2656 2657 if (dirty[0] & /*_headers, sort_by, sort_direction, header_edit, column_widths, latex_delimiters, line_breaks*/ 17632272 | dirty[1] & /*get_sort_status*/ 16) { 2658 each_value_3 = ensure_array_like(/*_headers*/ ctx[16]); 2659 group_outros(); 2660 each_blocks_1 = update_keyed_each(each_blocks_1, dirty, get_key, 1, ctx, each_value_3, each0_lookup, tr0, outro_and_destroy_block, create_each_block_3, null, get_each_context_3); 2661 check_outros(); 2662 } 2663 2664 if (dirty[0] & /*cells, latex_delimiters, line_breaks, datatype*/ 1049617 | dirty[1] & /*max*/ 8) { 2665 each_value_2 = ensure_array_like(/*max*/ ctx[34]); 2666 group_outros(); 2667 each_blocks = update_keyed_each(each_blocks, dirty, get_key_1, 1, ctx, each_value_2, each1_lookup, tr1, outro_and_destroy_block, create_each_block_2, null, get_each_context_2); 2668 check_outros(); 2669 } 2670 2671 if (!current || dirty[0] & /*column_widths*/ 2048) { 2672 toggle_class(table_1, "fixed-layout", /*column_widths*/ ctx[11].length != 0); 2673 } 2674 2675 const upload_changes = {}; 2676 if (dirty[0] & /*root*/ 128) upload_changes.root = /*root*/ ctx[7]; 2677 2678 if (dirty[0] & /*t_width, height, data, styling, selected, display_value, latex_delimiters, line_breaks, editable, editing, datatype, clear_on_focus, els, parent, _headers, sort_by, sort_direction, header_edit, selected_header, select_on_focus, label*/ 938468915 | dirty[1] & /*selected_index, table_height, scrollbar_width*/ 7 | dirty[3] & /*$$scope*/ 2) { 2679 upload_changes.$$scope = { dirty, ctx }; 2680 } 2681 2682 if (!updating_dragging && dirty[0] & /*dragging*/ 134217728) { 2683 updating_dragging = true; 2684 upload_changes.dragging = /*dragging*/ ctx[27]; 2685 add_flush_callback(() => updating_dragging = false); 2686 } 2687 2688 upload.$set(upload_changes); 2689 2690 if (!current || dirty[1] & /*table_height*/ 1) { 2691 set_style(div0, "height", /*table_height*/ ctx[31] + "px"); 2692 } 2693 2694 if (!current || dirty[0] & /*dragging*/ 134217728) { 2695 toggle_class(div0, "dragging", /*dragging*/ ctx[27]); 2696 } 2697 2698 if (!current || dirty[0] & /*wrap*/ 64) { 2699 toggle_class(div0, "no-wrap", !/*wrap*/ ctx[6]); 2700 } 2701 2702 if (/*editable*/ ctx[5]) { 2703 if (if_block2) { 2704 if_block2.p(ctx, dirty); 2705
2706 if (dirty[0] & /*editable*/ 32) { 2707 transition_in$1(if_block2, 1); 2708 } 2709 } else { 2710 if_block2 = create_if_block(ctx); 2711 if_block2.c(); 2712 transition_in$1(if_block2, 1); 2713 if_block2.m(div1, null); 2714 } 2715 } else if (if_block2) { 2716 group_outros(); 2717 2718 transition_out$1(if_block2, 1, 1, () => { 2719 if_block2 = null; 2720 }); 2721 2722 check_outros(); 2723 } 2724 2725 if (!current || dirty[0] & /*label*/ 2) { 2726 toggle_class(div1, "label", /*label*/ ctx[1] && /*label*/ ctx[1].length !== 0); 2727 } 2728 }, 2729 i(local) { 2730 if (current) return; 2731 2732 for (let i = 0; i < each_value_3.length; i += 1) { 2733 transition_in$1(each_blocks_1[i]); 2734 } 2735 2736 for (let i = 0; i < each_value_2.length; i += 1) { 2737 transition_in$1(each_blocks[i]); 2738 } 2739 2740 transition_in$1(upload.$$.fragment, local); 2741 transition_in$1(if_block2); 2742 current = true; 2743 }, 2744 o(local) { 2745 for (let i = 0; i < each_blocks_1.length; i += 1) { 2746 transition_out$1(each_blocks_1[i]); 2747 } 2748 2749 for (let i = 0; i < each_blocks.length; i += 1) { 2750 transition_out$1(each_blocks[i]); 2751 } 2752 2753 transition_out$1(upload.$$.fragment, local); 2754 transition_out$1(if_block2); 2755 current = false; 2756 }, 2757 d(detaching) { 2758 if (detaching) { 2759 detach$1(div1); 2760 } 2761 2762 if (if_block0) if_block0.d(); 2763 if (if_block1) if_block1.d(); 2764 2765 for (let i = 0; i < each_blocks_1.length; i += 1) { 2766 each_blocks_1[i].d(); 2767 } 2768 2769 for (let i = 0; i < each_blocks.length; i += 1) { 2770 each_blocks[i].d(); 2771 } 2772 2773 table_1_resize_listener(); 2774 /*table_1_binding*/ ctx[54](null); 2775 destroy_component$1(upload); 2776 /*div0_binding*/ ctx[70](null); 2777 if (if_block2) if_block2.d(); 2778 mounted = false; 2779 run_all(dispose); 2780 } 2781 }; 2782} 2783 2784function make_id() { 2785 return Math.random().toString(36).substring(2, 15); 2786} 2787 2788function guess_delimitaor(text, possibleDelimiters) { 2789 return possibleDelimiters.filter(weedOut); 2790 2791 function weedOut(delimiter) { 2792 var cache = -1; 2793 return text.split("\n").every(checkLength); 2794 2795 function checkLength(line) { 2796 if (!line) { 2797 return true; 2798 } 2799 2800 var length = line.split(delimiter).length; 2801 2802 if (cache < 0) { 2803 cache = length; 2804 } 2805 2806 return cache === length && length > 1; 2807 } 2808 } 2809} 2810 2811function data_uri_to_blob(data_uri) { 2812 const byte_str = atob(data_uri.split(",")[1]); 2813 const mime_str = data_uri.split(",")[0].split(":")[1].split(";")[0]; 2814 const ab = new ArrayBuffer(byte_str.length); 2815 const ia = new Uint8Array(ab); 2816 2817 for (let i = 0; i < byte_str.length; i++) { 2818 ia[i] = byte_str.charCodeAt(i); 2819 } 2820 2821 return new Blob([ab], { type: mime_str }); 2822} 2823 2824function instance$1($$self, $$props, $$invalidate) { 2825 let max; 2826 let selected_index; 2827 let { datatype } = $$props; 2828 let { label = null } = $$props; 2829 let { headers = [] } = $$props; 2830 let values; 2831 let { value } = $$props; 2832 let { col_count } = $$props; 2833 let { row_count } = $$props; 2834 let { latex_delimiters } = $$props; 2835 let { editable = true } = $$props; 2836 let { wrap = false } = $$props; 2837 let { root } = $$props; 2838 let { i18n } = $$props; 2839 let { height = 500 } = $$props; 2840 let { line_breaks = true } = $$props; 2841 let { column_widths = [] } = $$props; 2842 let selected = false; 2843 let display_value = value?.metadata?.display_value ?? null; 2844 let styling = value?.metadata?.styling ?? null; 2845 const dispatch = createEventDispatcher(); 2846 let editing = false; 2847 const get_data_at = (row, col) => data?.[row]?.[col]?.value; 2848 let els = {}; 2849 2850 function make_headers(_head) { 2851 let _h = _head || []; 2852 2853 if (col_count[1] === "fixed" && _h.length < col_count[0]) { 2854 const fill = Array(col_count[0] - _h.length).fill("").map((_, i) => `${i + _h.length}`); 2855 _h = _h.concat(fill); 2856 } 2857 2858 if (!_h || _h.length === 0) { 2859 return Array(col_count[0]).fill(0).map((_, i) => { 2860 const _id = make_id(); 2861 $$invalidate(22, els[_id] = { cell: null, input: null }, els); 2862 return { id: _id, value: JSON.stringify(i + 1) }; 2863 }); 2864 } 2865 2866 return _h.map((h, i) => { 2867 const _id = make_id(); 2868 $$invalidate(22, els[_id] = { cell: null, input: null }, els); 2869 return { id: _id, value: h ?? "" }; 2870 }); 2871 } 2872 2873 function process_data(_values) { 2874 const data_row_length = _values.length; 2875 2876 return Array(row_count[1] === "fixed" 2877 ? row_count[0] 2878 : data_row_length < row_count[0] 2879 ? row_count[0] 2880 : data_row_length).fill(0).map((_, i) => Array(col_count[1] === "fixed" 2881 ? col_count[0] 2882 : data_row_length > 0 ? _values[0].length : headers.length).fill(0).map((_, j) => { 2883 const id = make_id();
2884 $$invalidate(22, els[id] = els[id] || { input: null, cell: null }, els); 2885 const obj = { value: _values?.[i]?.[j] ?? "", id }; 2886 return obj; 2887 })); 2888 } 2889 2890 let _headers = make_headers(headers); 2891 let old_headers; 2892 2893 function trigger_headers() { 2894 $$invalidate(16, _headers = make_headers(headers)); 2895 $$invalidate(49, old_headers = headers.slice()); 2896 } 2897 2898 let data = [[]]; 2899 let old_val = undefined; 2900 2901 function get_sort_status(name, _sort, direction) { 2902 if (!_sort) return "none"; 2903 2904 if (headers[_sort] === name) { 2905 if (direction === "asc") return "ascending"; 2906 if (direction === "des") return "descending"; 2907 } 2908 2909 return "none"; 2910 } 2911 2912 function get_current_indices(id) { 2913 return data.reduce( 2914 (acc, arr, i) => { 2915 const j = arr.reduce((_acc, _data, k) => id === _data.id ? k : _acc, -1); 2916 return j === -1 ? acc : [i, j]; 2917 }, 2918 [-1, -1] 2919 ); 2920 } 2921 2922 async function start_edit(i, j) { 2923 if (!editable || dequal(editing, [i, j])) return; 2924 $$invalidate(21, editing = [i, j]); 2925 } 2926 2927 function move_cursor(key, current_coords) { 2928 const dir = ({ 2929 ArrowRight: [0, 1], 2930 ArrowLeft: [0, -1], 2931 ArrowDown: [1, 0], 2932 ArrowUp: [-1, 0] 2933 })[key]; 2934 2935 const i = current_coords[0] + dir[0]; 2936 const j = current_coords[1] + dir[1]; 2937 2938 if (i < 0 && j <= 0) { 2939 $$invalidate(26, selected_header = j); 2940 $$invalidate(13, selected = false); 2941 } else { 2942 const is_data = data[i]?.[j]; 2943 $$invalidate(13, selected = is_data ? [i, j] : selected); 2944 } 2945 } 2946 2947 let clear_on_focus = false; 2948 2949 // eslint-disable-next-line complexity 2950 async function handle_keydown(event) { 2951 if (selected_header !== false && header_edit === false) { 2952 switch (event.key) { 2953 case "ArrowDown": 2954 $$invalidate(13, selected = [0, selected_header]); 2955 $$invalidate(26, selected_header = false); 2956 return; 2957 case "ArrowLeft": 2958 $$invalidate(26, selected_header = selected_header > 0 2959 ? selected_header - 1 2960 : selected_header); 2961 return; 2962 case "ArrowRight": 2963 $$invalidate(26, selected_header = selected_header < _headers.length - 1 2964 ? selected_header + 1 2965 : selected_header); 2966 return; 2967 case "Escape": 2968 event.preventDefault(); 2969 $$invalidate(26, selected_header = false); 2970 break; 2971 case "Enter": 2972 event.preventDefault(); 2973 break; 2974 } 2975 } 2976 2977 if (!selected) { 2978 return; 2979 } 2980 2981 const [i, j] = selected; 2982 2983 switch (event.key) { 2984 case "ArrowRight": 2985 case "ArrowLeft": 2986 case "ArrowDown": 2987 case "ArrowUp": 2988 if (editing) break; 2989 event.preventDefault(); 2990 move_cursor(event.key, [i, j]); 2991 break; 2992 case "Escape": 2993 if (!editable) break; 2994 event.preventDefault(); 2995 $$invalidate(21, editing = false); 2996 break; 2997 case "Enter": 2998 if (!editable) break; 2999 event.preventDefault(); 3000 if (event.shiftKey) { 3001 add_row(i); 3002 await tick(); 3003 $$invalidate(13, selected = [i + 1, j]); 3004 } else { 3005 if (dequal(editing, [i, j])) { 3006 $$invalidate(21, editing = false); 3007 await tick(); 3008 $$invalidate(13, selected = [i, j]); 3009 } else { 3010 $$invalidate(21, editing = [i, j]); 3011 } 3012 } 3013 break; 3014 case "Backspace": 3015 if (!editable) break; 3016 if (!editing) { 3017 event.preventDefault(); 3018 $$invalidate(17, data[i][j].value = "", data); 3019 } 3020 break; 3021 case "Delete": 3022 if (!editable) break; 3023 if (!editing) { 3024 event.preventDefault(); 3025 $$invalidate(17, data[i][j].value = "", data); 3026 } 3027 break; 3028 case "Tab": 3029 let direction = event.shiftKey ? -1 : 1; 3030 let is_data_x = data[i][j + direction]; 3031 let is_data_y = data?.[i + direction]?.[direction > 0 ? 0 : _headers.length - 1]; 3032 if (is_data_x || is_data_y) { 3033 event.preventDefault(); 3034 3035 $$invalidate(13, selected = is_data_x 3036 ? [i, j + direction] 3037 : [i + direction, direction > 0 ? 0 : _headers.length - 1]); 3038 } 3039 $$invalidate(21, editing = false); 3040 break; 3041 default: 3042 if (!editable) break; 3043 if ((!editing || editing && dequal(editing, [i, j])) && event.key.length === 1) { 3044 $$invalidate(23, clear_on_focus = true); 3045 $$invalidate(21, editing = [i, j]); 3046 } 3047 } 3048 } 3049 3050 async function handle_cell_click(i, j) { 3051 if (dequal(editing, [i, j])) return;
3052 $$invalidate(24, header_edit = false); 3053 $$invalidate(26, selected_header = false); 3054 $$invalidate(21, editing = false); 3055 $$invalidate(13, selected = [i, j]); 3056 await tick(); 3057 parent.focus(); 3058 } 3059 3060 let sort_direction; 3061 let sort_by; 3062 3063 function handle_sort(col) { 3064 if (typeof sort_by !== "number" || sort_by !== col) { 3065 $$invalidate(18, sort_direction = "asc"); 3066 $$invalidate(19, sort_by = col); 3067 } else { 3068 if (sort_direction === "asc") { 3069 $$invalidate(18, sort_direction = "des"); 3070 } else if (sort_direction === "des") { 3071 $$invalidate(18, sort_direction = "asc"); 3072 } 3073 } 3074 } 3075 3076 let header_edit; 3077 let select_on_focus = false; 3078 let selected_header = false; 3079 3080 async function edit_header(i, _select = false) { 3081 if (!editable || col_count[1] !== "dynamic" || header_edit === i) return; 3082 $$invalidate(13, selected = false); 3083 $$invalidate(26, selected_header = i); 3084 $$invalidate(24, header_edit = i); 3085 $$invalidate(25, select_on_focus = _select); 3086 } 3087 3088 function end_header_edit(event) { 3089 if (!editable) return; 3090 3091 switch (event.key) { 3092 case "Escape": 3093 case "Enter": 3094 case "Tab": 3095 event.preventDefault(); 3096 $$invalidate(13, selected = false); 3097 $$invalidate(26, selected_header = header_edit); 3098 $$invalidate(24, header_edit = false); 3099 parent.focus(); 3100 break; 3101 } 3102 } 3103 3104 async function add_row(index) { 3105 parent.focus(); 3106 if (row_count[1] !== "dynamic") return; 3107 3108 if (data.length === 0) { 3109 $$invalidate(48, values = [Array(headers.length).fill("")]); 3110 return; 3111 } 3112 3113 data.splice(index ? index + 1 : data.length, 0, Array(data[0].length).fill(0).map((_, i) => { 3114 const _id = make_id(); 3115 $$invalidate(22, els[_id] = { cell: null, input: null }, els); 3116 return { id: _id, value: "" }; 3117 })); 3118 3119 ((($$invalidate(17, data), $$invalidate(48, values)), $$invalidate(50, old_val)), $$invalidate(12, value)); 3120 $$invalidate(13, selected = [index ? index + 1 : data.length - 1, 0]); 3121 } 3122 3123 async function add_col() { 3124 parent.focus(); 3125 if (col_count[1] !== "dynamic") return; 3126 3127 for (let i = 0; i < data.length; i++) { 3128 const _id = make_id(); 3129 $$invalidate(22, els[_id] = { cell: null, input: null }, els); 3130 data[i].push({ id: _id, value: "" }); 3131 } 3132 3133 headers.push(`Header ${headers.length + 1}`); 3134 ((($$invalidate(17, data), $$invalidate(48, values)), $$invalidate(50, old_val)), $$invalidate(12, value)); 3135 (($$invalidate(47, headers), $$invalidate(12, value)), $$invalidate(48, values)); 3136 await tick(); 3137 3138 requestAnimationFrame(() => { 3139 edit_header(headers.length - 1, true); 3140 const new_w = parent.querySelectorAll("tbody")[1].offsetWidth; 3141 parent.querySelectorAll("table")[1].scrollTo({ left: new_w }); 3142 }); 3143 } 3144 3145 function handle_click_outside(event) { 3146 event.stopImmediatePropagation(); 3147 const [trigger] = event.composedPath(); 3148 3149 if (parent.contains(trigger)) { 3150 return; 3151 } 3152 3153 $$invalidate(21, editing = false); 3154 $$invalidate(24, header_edit = false); 3155 $$invalidate(26, selected_header = false); 3156 $$invalidate(13, selected = false); 3157 } 3158 3159 function blob_to_string(blob) { 3160 const reader = new FileReader(); 3161 3162 function handle_read(e) { 3163 if (!e?.target?.result || typeof e.target.result !== "string") return; 3164 const [delimiter] = guess_delimitaor(e.target.result, [",", "\t"]); 3165 const [head, ...rest] = dsvFormat(delimiter).parseRows(e.target.result); 3166 3167 $$invalidate(16, _headers = make_headers(col_count[1] === "fixed" 3168 ? head.slice(0, col_count[0]) 3169 : head)); 3170 3171 $$invalidate(48, values = rest); 3172 reader.removeEventListener("loadend", handle_read); 3173 } 3174 3175 reader.addEventListener("loadend", handle_read); 3176 reader.readAsText(blob); 3177 } 3178 3179 let dragging = false; 3180 let t_width = 0; 3181 3182 function get_max(_d) { 3183 let max = _d[0].slice(); 3184 3185 for (let i = 0; i < _d.length; i++) { 3186 for (let j = 0; j < _d[i].length; j++) { 3187 if (`${max[j].value}`.length < `${_d[i][j].value}`.length) { 3188 max[j] = _d[i][j]; 3189 } 3190 } 3191 } 3192 3193 return max; 3194 } 3195 3196 let cells = []; 3197 let parent; 3198 let table; 3199 3200 function set_cell_widths() { 3201 const widths = cells.map((el, i) => { 3202 return el?.clientWidth || 0; 3203 }); 3204 3205 if (widths.length === 0) return; 3206 3207 for (let i = 0; i < widths.length; i++) { 3208 parent.style.setProperty(`--cell-width-${i}`, `${widths[i] - scrollbar_width / widths.length}px`); 3209 } 3210 } 3211 3212 let table_height = height; 3213 let scrollbar_width = 0; 3214 3215 function sort_data(_data, _display_value, _styling, col, dir) { 3216 let id = null; 3217 3218 //Checks if the selected cell is still in the data 3219 if (selected && selected[0] in data && selected[1] in data[selected[0]]) { 3220 id = data[selected[0]][selected[1]].id; 3221 } 3222 3223 if (typeof col !== "number" || !dir) { 3224 return; 3225 } 3226 3227 const indices = [...Array(_data.length).keys()]; 3228 3229 if (dir === "asc") { 3230 indices.sort((i, j) => _data[i][col].value < _data[j][col].value ? -1 : 1); 3231 } else if (dir === "des") { 3232 indices.sort((i, j) => _data[i][col].value > _data[j][col].value ? -1 : 1); 3233 } else { 3234 return; 3235 } 3236 3237 // sort all the data and metadata based on the values in the data 3238 const temp_data = [..._data]; 3239 3240 const temp_display_value = _display_value ? [..._display_value] : null; 3241 const temp_styling = _styling ? [..._styling] : null; 3242
3243 indices.forEach((originalIndex, sortedIndex) => { 3244 _data[sortedIndex] = temp_data[originalIndex]; 3245 if (_display_value && temp_display_value) _display_value[sortedIndex] = temp_display_value[originalIndex]; 3246 if (_styling && temp_styling) _styling[sortedIndex] = temp_styling[originalIndex]; 3247 }); 3248 3249 ((($$invalidate(17, data), $$invalidate(48, values)), $$invalidate(50, old_val)), $$invalidate(12, value)); 3250 3251 if (id) { 3252 const [i, j] = get_current_indices(id); 3253 $$invalidate(13, selected = [i, j]); 3254 } 3255 } 3256 3257 let is_visible = false; 3258 3259 onMount(() => { 3260 const observer = new IntersectionObserver((entries, observer) => { 3261 entries.forEach(entry => { 3262 if (entry.isIntersecting && !is_visible) { 3263 set_cell_widths(); 3264 ((($$invalidate(17, data), $$invalidate(48, values)), $$invalidate(50, old_val)), $$invalidate(12, value)); 3265 } 3266 3267 is_visible = entry.isIntersecting; 3268 }); 3269 }); 3270 3271 observer.observe(parent); 3272 3273 return () => { 3274 observer.disconnect(); 3275 }; 3276 }); 3277 3278 const resize_handler = () => set_cell_widths(); 3279 3280 function td_binding($$value, j) { 3281 binding_callbacks[$$value ? 'unshift' : 'push'](() => { 3282 cells[j] = $$value; 3283 $$invalidate(20, cells); 3284 }); 3285 } 3286 3287 function table_1_elementresize_handler() { 3288 t_width = this.clientWidth; 3289 $$invalidate(28, t_width); 3290 } 3291 3292 function table_1_binding($$value) { 3293 binding_callbacks[$$value ? 'unshift' : 'push'](() => { 3294 table = $$value; 3295 $$invalidate(30, table); 3296 }); 3297 } 3298 3299 function editablecell_value_binding(value$1, index, j) { 3300 if ($$self.$$.not_equal(data[index][j].value, value$1)) { 3301 data[index][j].value = value$1; 3302 ((($$invalidate(17, data), $$invalidate(48, values)), $$invalidate(50, old_val)), $$invalidate(12, value)); 3303 } 3304 } 3305 3306 function editablecell_el_binding(value, id) { 3307 if ($$self.$$.not_equal(els[id].input, value)) { 3308 els[id].input = value; 3309 $$invalidate(22, els); 3310 } 3311 } 3312 3313 const blur_handler = () => ($$invalidate(23, clear_on_focus = false), parent.focus()); 3314 const touchstart_handler = (index, j) => start_edit(index, j); 3315 const click_handler = (index, j) => handle_cell_click(index, j); 3316 const dblclick_handler = (index, j) => start_edit(index, j); 3317 3318 function editablecell_value_binding_1(value, i) { 3319 if ($$self.$$.not_equal(_headers[i].value, value)) { 3320 _headers[i].value = value; 3321 $$invalidate(16, _headers); 3322 } 3323 } 3324 3325 function editablecell_el_binding_1(value, id) { 3326 if ($$self.$$.not_equal(els[id].input, value)) { 3327 els[id].input = value; 3328 $$invalidate(22, els); 3329 } 3330 } 3331 3332 const dblclick_handler_1 = i => edit_header(i); 3333 const click_handler_1 = i => handle_sort(i); 3334 3335 function virtualtable_items_binding(value$1) { 3336 data = value$1; 3337 ((($$invalidate(17, data), $$invalidate(48, values)), $$invalidate(50, old_val)), $$invalidate(12, value)); 3338 } 3339 3340 function virtualtable_actual_height_binding(value) { 3341 table_height = value; 3342 $$invalidate(31, table_height); 3343 } 3344 3345 function virtualtable_table_scrollbar_width_binding(value) { 3346 scrollbar_width = value; 3347 $$invalidate(32, scrollbar_width); 3348 } 3349 3350 function upload_dragging_binding(value) { 3351 dragging = value; 3352 $$invalidate(27, dragging); 3353 } 3354 3355 const load_handler = e => blob_to_string(data_uri_to_blob(e.detail.data)); 3356 3357 function div0_binding($$value) { 3358 binding_callbacks[$$value ? 'unshift' : 'push'](() => { 3359 parent = $$value; 3360 $$invalidate(29, parent); 3361 }); 3362 } 3363 3364 const keydown_handler = e => handle_keydown(e); 3365 const click_handler_2 = e => (e.stopPropagation(), add_row()); 3366 const click_handler_3 = e => (e.stopPropagation(), add_col()); 3367 3368 $$self.$$set = $$props => {
3369 if ('datatype' in $$props) $$invalidate(0, datatype = $$props.datatype); 3370 if ('label' in $$props) $$invalidate(1, label = $$props.label); 3371 if ('headers' in $$props) $$invalidate(47, headers = $$props.headers); 3372 if ('value' in $$props) $$invalidate(12, value = $$props.value); 3373 if ('col_count' in $$props) $$invalidate(2, col_count = $$props.col_count); 3374 if ('row_count' in $$props) $$invalidate(3, row_count = $$props.row_count); 3375 if ('latex_delimiters' in $$props) $$invalidate(4, latex_delimiters = $$props.latex_delimiters); 3376 if ('editable' in $$props) $$invalidate(5, editable = $$props.editable); 3377 if ('wrap' in $$props) $$invalidate(6, wrap = $$props.wrap); 3378 if ('root' in $$props) $$invalidate(7, root = $$props.root); 3379 if ('i18n' in $$props) $$invalidate(8, i18n = $$props.i18n); 3380 if ('height' in $$props) $$invalidate(9, height = $$props.height); 3381 if ('line_breaks' in $$props) $$invalidate(10, line_breaks = $$props.line_breaks); 3382 if ('column_widths' in $$props) $$invalidate(11, column_widths = $$props.column_widths); 3383 }; 3384 3385 $$self.$$.update = () => { 3386 if ($$self.$$.dirty[0] & /*value*/ 4096 | $$self.$$.dirty[1] & /*values*/ 131072) { 3387 { 3388 if (value) { 3389 $$invalidate(47, headers = value.headers); 3390 $$invalidate(48, values = value.data); 3391 $$invalidate(14, display_value = value?.metadata?.display_value ?? null); 3392 $$invalidate(15, styling = value?.metadata?.styling ?? null); 3393 } else if (values === null) { 3394 $$invalidate(48, values = []); 3395 } 3396 } 3397 } 3398 3399 if ($$self.$$.dirty[0] & /*selected*/ 8192) { 3400 { 3401 if (selected !== false) { 3402 const [row, col] = selected; 3403 3404 if (!isNaN(row) && !isNaN(col)) { 3405 dispatch("select", { 3406 index: [row, col], 3407 value: get_data_at(row, col) 3408 }); 3409 } 3410 } 3411 } 3412 } 3413 3414 if ($$self.$$.dirty[1] & /*headers, old_headers*/ 327680) { 3415 { 3416 if (!dequal(headers, old_headers)) { 3417 trigger_headers(); 3418 } 3419 } 3420 } 3421 3422 if ($$self.$$.dirty[1] & /*values, old_val*/ 655360) { 3423 if (!dequal(values, old_val)) { 3424 $$invalidate(17, data = process_data(values)); 3425 $$invalidate(50, old_val = values); 3426 } 3427 } 3428 3429 if ($$self.$$.dirty[0] & /*_headers, data, editable, display_value, styling*/ 245792) { 3430 _headers && dispatch("change", { 3431 data: data.map(r => r.map(({ value }) => value)), 3432 headers: _headers.map(h => h.value), 3433 metadata: editable ? null : { display_value, styling } 3434 }); 3435 } 3436 3437 if ($$self.$$.dirty[0] & /*data*/ 131072) { 3438 $$invalidate(34, max = get_max(data)); 3439 } 3440 3441 if ($$self.$$.dirty[0] & /*cells*/ 1048576) { 3442 cells[0] && set_cell_widths(); 3443 } 3444 3445 if ($$self.$$.dirty[0] & /*data, display_value, styling, sort_by, sort_direction*/ 966656) { 3446 sort_data(data, display_value, styling, sort_by, sort_direction); 3447 } 3448 3449 if ($$self.$$.dirty[0] & /*selected*/ 8192) { 3450 $$invalidate(33, selected_index = !!selected && selected[0]); 3451 } 3452 }; 3453 3454 return [ 3455 datatype, 3456 label, 3457 col_count, 3458 row_count, 3459 latex_delimiters, 3460 editable, 3461 wrap, 3462 root, 3463 i18n, 3464 height, 3465 line_breaks, 3466 column_widths, 3467 value, 3468 selected, 3469 display_value, 3470 styling, 3471 _headers, 3472 data, 3473 sort_direction, 3474 sort_by, 3475 cells, 3476 editing, 3477 els, 3478 clear_on_focus, 3479 header_edit, 3480 select_on_focus, 3481 selected_header, 3482 dragging, 3483 t_width, 3484 parent, 3485 table, 3486 table_height, 3487 scrollbar_width, 3488 selected_index, 3489 max, 3490 get_sort_status, 3491 start_edit, 3492 handle_keydown, 3493 handle_cell_click, 3494 handle_sort, 3495 edit_header, 3496 end_header_edit, 3497 add_row, 3498 add_col, 3499 handle_click_outside, 3500 blob_to_string, 3501 set_cell_widths, 3502 headers, 3503 values, 3504 old_headers, 3505 old_val, 3506 resize_handler, 3507 td_binding, 3508 table_1_elementresize_handler, 3509 table_1_binding, 3510 editablecell_value_binding, 3511 editablecell_el_binding, 3512 blur_handler, 3513 touchstart_handler, 3514 click_handler, 3515 dblclick_handler, 3516 editablecell_value_binding_1, 3517 editablecell_el_binding_1, 3518 dblclick_handler_1, 3519 click_handler_1, 3520 virtualtable_items_binding, 3521 virtualtable_actual_height_binding, 3522 virtualtable_table_scrollbar_width_binding, 3523 upload_dragging_binding, 3524 load_handler, 3525 div0_binding, 3526 keydown_handler, 3527 click_handler_2, 3528 click_handler_3 3529 ]; 3530} 3531 3532class Table extends SvelteComponent$1 { 3533 constructor(options) { 3534 super(); 3535 3536 init$1( 3537 this, 3538 options, 3539 instance$1, 3540 create_fragment$1, 3541 safe_not_equal$1, 3542 { 3543 datatype: 0, 3544 label: 1, 3545 headers: 47, 3546 value: 12, 3547 col_count: 2, 3548 row_count: 3, 3549 latex_delimiters: 4, 3550 editable: 5, 3551 wrap: 6, 3552 root: 7,
3553 i18n: 8, 3554 height: 9, 3555 line_breaks: 10, 3556 column_widths: 11 3557 }, 3558 null, 3559 [-1, -1, -1, -1] 3560 ); 3561 } 3562} 3563 3564const Table$1 = Table; 3565 3566/* home/runner/work/gradio/gradio/js/dataframe/Index.svelte generated by Svelte v4.2.2 */ 3567const { 3568 SvelteComponent, 3569 assign, 3570 create_component, 3571 destroy_component, 3572 detach, 3573 get_spread_object, 3574 get_spread_update, 3575 init, 3576 insert, 3577 is_function, 3578 mount_component, 3579 safe_not_equal, 3580 space, 3581 transition_in, 3582 transition_out 3583} = window.__gradio__svelte__internal; 3584const { afterUpdate } = window.__gradio__svelte__internal; 3585function create_default_slot(ctx) { 3586 let statustracker; 3587 let t; 3588 let table; 3589 let current; 3590 3591 const statustracker_spread_levels = [ 3592 { 3593 autoscroll: /*gradio*/ ctx[15].autoscroll 3594 }, 3595 { i18n: /*gradio*/ ctx[15].i18n }, 3596 /*loading_status*/ ctx[18] 3597 ]; 3598 3599 let statustracker_props = {}; 3600 3601 for (let i = 0; i < statustracker_spread_levels.length; i += 1) { 3602 statustracker_props = assign(statustracker_props, statustracker_spread_levels[i]); 3603 } 3604 3605 statustracker = new Static({ props: statustracker_props }); 3606 3607 table = new Table$1({ 3608 props: { 3609 root: /*root*/ ctx[12], 3610 label: /*label*/ ctx[7], 3611 row_count: /*row_count*/ ctx[6], 3612 col_count: /*col_count*/ ctx[5], 3613 value: /*value*/ ctx[0], 3614 headers: /*headers*/ ctx[1], 3615 wrap: /*wrap*/ ctx[8], 3616 datatype: /*datatype*/ ctx[9], 3617 latex_delimiters: /*latex_delimiters*/ ctx[16], 3618 editable: /*interactive*/ ctx[19], 3619 height: /*height*/ ctx[17], 3620 i18n: /*gradio*/ ctx[15].i18n, 3621 line_breaks: /*line_breaks*/ ctx[13], 3622 column_widths: /*column_widths*/ ctx[14] 3623 } 3624 }); 3625 3626 table.$on("change", function () { 3627 if (is_function(/*interactive*/ ctx[19] 3628 ? /*change_handler*/ ctx[22] 3629 : change_handler_1)) (/*interactive*/ ctx[19] 3630 ? /*change_handler*/ ctx[22] 3631 : change_handler_1).apply(this, arguments); 3632 }); 3633 3634 table.$on("select", /*select_handler*/ ctx[23]); 3635 3636 return { 3637 c() { 3638 create_component(statustracker.$$.fragment); 3639 t = space(); 3640 create_component(table.$$.fragment); 3641 }, 3642 m(target, anchor) { 3643 mount_component(statustracker, target, anchor); 3644 insert(target, t, anchor); 3645 mount_component(table, target, anchor); 3646 current = true; 3647 }, 3648 p(new_ctx, dirty) { 3649 ctx = new_ctx; 3650 3651 const statustracker_changes = (dirty & /*gradio, loading_status*/ 294912) 3652 ? get_spread_update(statustracker_spread_levels, [ 3653 dirty & /*gradio*/ 32768 && { 3654 autoscroll: /*gradio*/ ctx[15].autoscroll 3655 }, 3656 dirty & /*gradio*/ 32768 && { i18n: /*gradio*/ ctx[15].i18n }, 3657 dirty & /*loading_status*/ 262144 && get_spread_object(/*loading_status*/ ctx[18]) 3658 ]) 3659 : {}; 3660 3661 statustracker.$set(statustracker_changes); 3662 const table_changes = {}; 3663 if (dirty & /*root*/ 4096) table_changes.root = /*root*/ ctx[12]; 3664 if (dirty & /*label*/ 128) table_changes.label = /*label*/ ctx[7]; 3665 if (dirty & /*row_count*/ 64) table_changes.row_count = /*row_count*/ ctx[6]; 3666 if (dirty & /*col_count*/ 32) table_changes.col_count = /*col_count*/ ctx[5]; 3667 if (dirty & /*value*/ 1) table_changes.value = /*value*/ ctx[0]; 3668 if (dirty & /*headers*/ 2) table_changes.headers = /*headers*/ ctx[1]; 3669 if (dirty & /*wrap*/ 256) table_changes.wrap = /*wrap*/ ctx[8]; 3670 if (dirty & /*datatype*/ 512) table_changes.datatype = /*datatype*/ ctx[9]; 3671 if (dirty & /*latex_delimiters*/ 65536) table_changes.latex_delimiters = /*latex_delimiters*/ ctx[16]; 3672 if (dirty & /*interactive*/ 524288) table_changes.editable = /*interactive*/ ctx[19]; 3673 if (dirty & /*height*/ 131072) table_changes.height = /*height*/ ctx[17]; 3674 if (dirty & /*gradio*/ 32768) table_changes.i18n = /*gradio*/ ctx[15].i18n; 3675 if (dirty & /*line_breaks*/ 8192) table_changes.line_breaks = /*line_breaks*/ ctx[13]; 3676 if (dirty & /*column_widths*/ 16384) table_changes.column_widths = /*column_widths*/ ctx[14]; 3677 table.$set(table_changes); 3678 }, 3679 i(local) { 3680 if (current) return; 3681 transition_in(statustracker.$$.fragment, local); 3682 transition_in(table.$$.fragment, local); 3683 current = true; 3684 }, 3685 o(local) { 3686 transition_out(statustracker.$$.fragment, local); 3687 transition_out(table.$$.fragment, local); 3688 current = false;
3689 }, 3690 d(detaching) { 3691 if (detaching) { 3692 detach(t); 3693 } 3694 3695 destroy_component(statustracker, detaching); 3696 destroy_component(table, detaching); 3697 } 3698 }; 3699} 3700 3701function create_fragment(ctx) { 3702 let block; 3703 let current; 3704 3705 block = new Block({ 3706 props: { 3707 visible: /*visible*/ ctx[4], 3708 padding: false, 3709 elem_id: /*elem_id*/ ctx[2], 3710 elem_classes: /*elem_classes*/ ctx[3], 3711 container: false, 3712 scale: /*scale*/ ctx[10], 3713 min_width: /*min_width*/ ctx[11], 3714 allow_overflow: false, 3715 $$slots: { default: [create_default_slot] }, 3716 $$scope: { ctx } 3717 } 3718 }); 3719 3720 return { 3721 c() { 3722 create_component(block.$$.fragment); 3723 }, 3724 m(target, anchor) { 3725 mount_component(block, target, anchor); 3726 current = true; 3727 }, 3728 p(ctx, [dirty]) { 3729 const block_changes = {}; 3730 if (dirty & /*visible*/ 16) block_changes.visible = /*visible*/ ctx[4]; 3731 if (dirty & /*elem_id*/ 4) block_changes.elem_id = /*elem_id*/ ctx[2]; 3732 if (dirty & /*elem_classes*/ 8) block_changes.elem_classes = /*elem_classes*/ ctx[3]; 3733 if (dirty & /*scale*/ 1024) block_changes.scale = /*scale*/ ctx[10]; 3734 if (dirty & /*min_width*/ 2048) block_changes.min_width = /*min_width*/ ctx[11]; 3735 3736 if (dirty & /*$$scope, root, label, row_count, col_count, value, headers, wrap, datatype, latex_delimiters, interactive, height, gradio, line_breaks, column_widths, loading_status*/ 34599907) { 3737 block_changes.$$scope = { dirty, ctx }; 3738 } 3739 3740 block.$set(block_changes); 3741 }, 3742 i(local) { 3743 if (current) return; 3744 transition_in(block.$$.fragment, local); 3745 current = true; 3746 }, 3747 o(local) { 3748 transition_out(block.$$.fragment, local); 3749 current = false; 3750 }, 3751 d(detaching) { 3752 destroy_component(block, detaching); 3753 } 3754 }; 3755} 3756 3757const change_handler_1 = () => { 3758 3759}; 3760 3761function instance($$self, $$props, $$invalidate) { 3762 let { headers = [] } = $$props; 3763 let { elem_id = "" } = $$props; 3764 let { elem_classes = [] } = $$props; 3765 let { visible = true } = $$props; 3766 3767 let { value = { 3768 data: [["", "", ""]], 3769 headers: ["1", "2", "3"], 3770 metadata: null 3771 } } = $$props; 3772 3773 let old_value = JSON.stringify(value); 3774 let { value_is_output = false } = $$props; 3775 let { col_count } = $$props; 3776 let { row_count } = $$props; 3777 let { label = null } = $$props; 3778 let { wrap } = $$props; 3779 let { datatype } = $$props; 3780 let { scale = null } = $$props; 3781 let { min_width = undefined } = $$props; 3782 let { root } = $$props; 3783 let { line_breaks = true } = $$props; 3784 let { column_widths = [] } = $$props; 3785 let { gradio } = $$props; 3786 let { latex_delimiters } = $$props; 3787 let { height = undefined } = $$props; 3788 let { loading_status } = $$props; 3789 let { interactive } = $$props; 3790 3791 function handle_change() { 3792 gradio.dispatch("change"); 3793 3794 if (!value_is_output) { 3795 gradio.dispatch("input"); 3796 } 3797 } 3798 3799 afterUpdate(() => { 3800 $$invalidate(20, value_is_output = false); 3801 }); 3802 3803 if (Array.isArray(value) && value?.[0]?.length === 0 || value.data?.[0]?.length === 0) { 3804 value = { 3805 data: [Array(col_count?.[0] || 3).fill("")], 3806 headers: Array(col_count?.[0] || 3).fill("").map((_, i) => `${i + 1}`), 3807 metadata: null 3808 }; 3809 } 3810 3811 const change_handler = e => $$invalidate(0, value = e.detail); 3812 const select_handler = e => gradio.dispatch("select", e.detail); 3813 3814 $$self.$$set = $$props => {
3815 if ('headers' in $$props) $$invalidate(1, headers = $$props.headers); 3816 if ('elem_id' in $$props) $$invalidate(2, elem_id = $$props.elem_id); 3817 if ('elem_classes' in $$props) $$invalidate(3, elem_classes = $$props.elem_classes); 3818 if ('visible' in $$props) $$invalidate(4, visible = $$props.visible); 3819 if ('value' in $$props) $$invalidate(0, value = $$props.value); 3820 if ('value_is_output' in $$props) $$invalidate(20, value_is_output = $$props.value_is_output); 3821 if ('col_count' in $$props) $$invalidate(5, col_count = $$props.col_count); 3822 if ('row_count' in $$props) $$invalidate(6, row_count = $$props.row_count); 3823 if ('label' in $$props) $$invalidate(7, label = $$props.label); 3824 if ('wrap' in $$props) $$invalidate(8, wrap = $$props.wrap); 3825 if ('datatype' in $$props) $$invalidate(9, datatype = $$props.datatype); 3826 if ('scale' in $$props) $$invalidate(10, scale = $$props.scale); 3827 if ('min_width' in $$props) $$invalidate(11, min_width = $$props.min_width); 3828 if ('root' in $$props) $$invalidate(12, root = $$props.root);
3829 if ('line_breaks' in $$props) $$invalidate(13, line_breaks = $$props.line_breaks); 3830 if ('column_widths' in $$props) $$invalidate(14, column_widths = $$props.column_widths); 3831 if ('gradio' in $$props) $$invalidate(15, gradio = $$props.gradio); 3832 if ('latex_delimiters' in $$props) $$invalidate(16, latex_delimiters = $$props.latex_delimiters); 3833 if ('height' in $$props) $$invalidate(17, height = $$props.height); 3834 if ('loading_status' in $$props) $$invalidate(18, loading_status = $$props.loading_status); 3835 if ('interactive' in $$props) $$invalidate(19, interactive = $$props.interactive); 3836 }; 3837 3838 $$self.$$.update = () => { 3839 if ($$self.$$.dirty & /*value, old_value*/ 2097153) { 3840 { 3841 if (JSON.stringify(value) !== old_value) { 3842 $$invalidate(21, old_value = JSON.stringify(value)); 3843 handle_change(); 3844 } 3845 } 3846 } 3847 }; 3848 3849 return [ 3850 value, 3851 headers, 3852 elem_id, 3853 elem_classes, 3854 visible, 3855 col_count, 3856 row_count, 3857 label, 3858 wrap, 3859 datatype, 3860 scale, 3861 min_width, 3862 root, 3863 line_breaks, 3864 column_widths, 3865 gradio, 3866 latex_delimiters, 3867 height, 3868 loading_status, 3869 interactive, 3870 value_is_output, 3871 old_value, 3872 change_handler, 3873 select_handler 3874 ]; 3875} 3876 3877class Index extends SvelteComponent { 3878 constructor(options) { 3879 super(); 3880 3881 init(this, options, instance, create_fragment, safe_not_equal, { 3882 headers: 1, 3883 elem_id: 2, 3884 elem_classes: 3, 3885 visible: 4, 3886 value: 0, 3887 value_is_output: 20, 3888 col_count: 5, 3889 row_count: 6, 3890 label: 7, 3891 wrap: 8, 3892 datatype: 9, 3893 scale: 10, 3894 min_width: 11, 3895 root: 12, 3896 line_breaks: 13, 3897 column_widths: 14, 3898 gradio: 15, 3899 latex_delimiters: 16, 3900 height: 17, 3901 loading_status: 18, 3902 interactive: 19 3903 }); 3904 } 3905} 3906 3907export { Table$1 as BaseDataFrame, Index as default }; 3908//# sourceMappingURL=Index-385cad93.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.