1import { a as Button, B as Block } from './Button-c2bc75a7.js'; 2import { S as Static } from './Index-9d23d982.js'; 3import { d as dequal } from './index-21d69e4c.js'; 4import { c as copy } from './utils-013c0d40.js'; 5import { U as Upload } from './ModifyUpload.svelte_svelte_type_style_lang-b9d20eaa.js'; 6import './index-12d4b00b.js'; 7import './Index.svelte_svelte_type_style_lang-7fd1e462.js'; 8import { M as MarkdownCode } from './Example.svelte_svelte_type_style_lang-183af30f.js'; 9import { d as dsvFormat } from './dsv-a37bb3db.js'; 10export { default as BaseExample } from './Example-bac8e01d.js'; 11import './svelte/svelte.js'; 12import './prism-python-9de6db01.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-z9gpua"); 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-z9gpua"); 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 ResizeObserverSingleton: ResizeObserverSingleton$1, 450 SvelteComponent: SvelteComponent$2, 451 add_iframe_resize_listener, 452 add_render_callback, 453 append: append$1, 454 attr: attr$1, 455 binding_callbacks: binding_callbacks$1, 456 check_outros: check_outros$1, 457 create_slot, 458 detach: detach$2, 459 element: element$1, 460 empty: empty$1, 461 ensure_array_like: ensure_array_like$1, 462 get_all_dirty_from_scope, 463 get_slot_changes, 464 group_outros: group_outros$1, 465 init: init$2, 466 insert: insert$2, 467 listen: listen$1, 468 outro_and_destroy_block: outro_and_destroy_block$1, 469 resize_observer_content_box: resize_observer_content_box$1, 470 safe_not_equal: safe_not_equal$2, 471 set_style: set_style$1, 472 space: space$2, 473 text: text$1, 474 transition_in: transition_in$2, 475 transition_out: transition_out$2, 476 update_keyed_each: update_keyed_each$1, 477 update_slot_base 478} = window.__gradio__svelte__internal; 479const { onMount: onMount$1, tick: tick$1 } = window.__gradio__svelte__internal;const get_tfoot_slot_changes = dirty => ({}); 480const get_tfoot_slot_context = ctx => ({}); 481 482function get_each_context$1(ctx, list, i) { 483 const child_ctx = ctx.slice(); 484 child_ctx[34] = list[i]; 485 return child_ctx; 486} 487 488const get_tbody_slot_changes = dirty => ({ 489 item: dirty[0] & /*visible*/ 256, 490 index: dirty[0] & /*visible*/ 256 491}); 492 493const get_tbody_slot_context = ctx => ({ 494 item: /*item*/ ctx[34].data, 495 index: /*item*/ ctx[34].index 496}); 497 498const get_thead_slot_changes = dirty => ({}); 499const get_thead_slot_context = ctx => ({}); 500 501// (218:3) {#if visible.length && visible[0].data.length} 502function create_if_block$1(ctx) { 503 let each_blocks = []; 504 let each_1_lookup = new Map(); 505 let each_1_anchor; 506 let current; 507 let each_value = ensure_array_like$1(/*visible*/ ctx[8]); 508 const get_key = ctx => /*item*/ ctx[34].data[0].id; 509 510 for (let i = 0; i < each_value.length; i += 1) { 511 let child_ctx = get_each_context$1(ctx, each_value, i); 512 let key = get_key(child_ctx); 513 each_1_lookup.set(key, each_blocks[i] = create_each_block$1(key, child_ctx)); 514 } 515 516 return { 517 c() { 518 for (let i = 0; i < each_blocks.length; i += 1) { 519 each_blocks[i].c(); 520 } 521 522 each_1_anchor = empty$1(); 523 }, 524 m(target, anchor) { 525 for (let i = 0; i < each_blocks.length; i += 1) { 526 if (each_blocks[i]) { 527 each_blocks[i].m(target, anchor); 528 } 529 } 530 531 insert$2(target, each_1_anchor, anchor); 532 current = true; 533 }, 534 p(ctx, dirty) { 535 if (dirty[0] & /*$$scope, visible*/ 1048832) { 536 each_value = ensure_array_like$1(/*visible*/ ctx[8]); 537 group_outros$1(); 538 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); 539 check_outros$1(); 540 } 541 }, 542 i(local) { 543 if (current) return; 544 545 for (let i = 0; i < each_value.length; i += 1) { 546 transition_in$2(each_blocks[i]); 547 } 548 549 current = true; 550 }, 551 o(local) { 552 for (let i = 0; i < each_blocks.length; i += 1) { 553 transition_out$2(each_blocks[i]); 554 } 555 556 current = false;
557 }, 558 d(detaching) { 559 if (detaching) { 560 detach$2(each_1_anchor); 561 } 562 563 for (let i = 0; i < each_blocks.length; i += 1) { 564 each_blocks[i].d(detaching); 565 } 566 } 567 }; 568} 569 570// (220:60) Missing Table Row 571function fallback_block(ctx) { 572 let t; 573 574 return { 575 c() { 576 t = text$1("Missing Table Row\n\t\t\t\t\t"); 577 }, 578 m(target, anchor) { 579 insert$2(target, t, anchor); 580 }, 581 d(detaching) { 582 if (detaching) { 583 detach$2(t); 584 } 585 } 586 }; 587} 588 589// (219:4) {#each visible as item (item.data[0].id)} 590function create_each_block$1(key_1, ctx) { 591 let first; 592 let current; 593 const tbody_slot_template = /*#slots*/ ctx[21].tbody; 594 const tbody_slot = create_slot(tbody_slot_template, ctx, /*$$scope*/ ctx[20], get_tbody_slot_context); 595 const tbody_slot_or_fallback = tbody_slot || fallback_block(); 596 597 return { 598 key: key_1, 599 first: null, 600 c() { 601 first = empty$1(); 602 if (tbody_slot_or_fallback) tbody_slot_or_fallback.c(); 603 this.first = first; 604 }, 605 m(target, anchor) { 606 insert$2(target, first, anchor); 607 608 if (tbody_slot_or_fallback) { 609 tbody_slot_or_fallback.m(target, anchor); 610 } 611 612 current = true; 613 }, 614 p(new_ctx, dirty) { 615 ctx = new_ctx; 616 617 if (tbody_slot) { 618 if (tbody_slot.p && (!current || dirty[0] & /*$$scope, visible*/ 1048832)) { 619 update_slot_base( 620 tbody_slot, 621 tbody_slot_template, 622 ctx, 623 /*$$scope*/ ctx[20], 624 !current 625 ? get_all_dirty_from_scope(/*$$scope*/ ctx[20]) 626 : get_slot_changes(tbody_slot_template, /*$$scope*/ ctx[20], dirty, get_tbody_slot_changes), 627 get_tbody_slot_context 628 ); 629 } 630 } 631 }, 632 i(local) { 633 if (current) return; 634 transition_in$2(tbody_slot_or_fallback, local); 635 current = true; 636 }, 637 o(local) { 638 transition_out$2(tbody_slot_or_fallback, local); 639 current = false; 640 }, 641 d(detaching) { 642 if (detaching) { 643 detach$2(first); 644 } 645 646 if (tbody_slot_or_fallback) tbody_slot_or_fallback.d(detaching); 647 } 648 }; 649} 650 651function create_fragment$2(ctx) { 652 let svelte_virtual_table_viewport; 653 let table; 654 let thead; 655 let thead_resize_listener; 656 let t0; 657 let tbody; 658 let t1; 659 let tfoot; 660 let tfoot_resize_listener; 661 let table_resize_listener; 662 let current; 663 let mounted; 664 let dispose; 665 const thead_slot_template = /*#slots*/ ctx[21].thead; 666 const thead_slot = create_slot(thead_slot_template, ctx, /*$$scope*/ ctx[20], get_thead_slot_context); 667 let if_block = /*visible*/ ctx[8].length && /*visible*/ ctx[8][0].data.length && create_if_block$1(ctx); 668 const tfoot_slot_template = /*#slots*/ ctx[21].tfoot; 669 const tfoot_slot = create_slot(tfoot_slot_template, ctx, /*$$scope*/ ctx[20], get_tfoot_slot_context); 670 671 return { 672 c() { 673 svelte_virtual_table_viewport = element$1("svelte-virtual-table-viewport"); 674 table = element$1("table"); 675 thead = element$1("thead"); 676 if (thead_slot) thead_slot.c(); 677 t0 = space$2(); 678 tbody = element$1("tbody"); 679 if (if_block) if_block.c(); 680 t1 = space$2(); 681 tfoot = element$1("tfoot"); 682 if (tfoot_slot) tfoot_slot.c(); 683 attr$1(thead, "class", "thead svelte-1txh5yn"); 684 add_render_callback(() => /*thead_elementresize_handler*/ ctx[22].call(thead)); 685 attr$1(tbody, "class", "tbody svelte-1txh5yn"); 686 attr$1(tfoot, "class", "tfoot svelte-1txh5yn"); 687 add_render_callback(() => /*tfoot_elementresize_handler*/ ctx[24].call(tfoot)); 688 attr$1(table, "class", "table svelte-1txh5yn"); 689 set_style$1(table, "height", height); 690 set_style$1(table, "--bw-svt-p-top", /*top*/ ctx[6] + "px"); 691 set_style$1(table, "--bw-svt-p-bottom", /*bottom*/ ctx[2] + "px"); 692 set_style$1(table, "--bw-svt-head-height", /*head_height*/ ctx[4] + "px"); 693 set_style$1(table, "--bw-svt-foot-height", /*foot_height*/ ctx[5] + "px"); 694 set_style$1(table, "--bw-svt-avg-row-height", /*average_height*/ ctx[1] + "px"); 695 }, 696 m(target, anchor) { 697 insert$2(target, svelte_virtual_table_viewport, anchor); 698 append$1(svelte_virtual_table_viewport, table); 699 append$1(table, thead); 700 701 if (thead_slot) { 702 thead_slot.m(thead, null); 703 } 704 705 thead_resize_listener = add_iframe_resize_listener(thead, /*thead_elementresize_handler*/ ctx[22].bind(thead)); 706 append$1(table, t0); 707 append$1(table, tbody); 708 if (if_block) if_block.m(tbody, null); 709 /*tbody_binding*/ ctx[23](tbody); 710 append$1(table, t1); 711 append$1(table, tfoot); 712 713 if (tfoot_slot) { 714 tfoot_slot.m(tfoot, null); 715 } 716 717 tfoot_resize_listener = add_iframe_resize_listener(tfoot, /*tfoot_elementresize_handler*/ ctx[24].bind(tfoot)); 718 /*table_binding*/ ctx[25](table); 719 table_resize_listener = resize_observer_content_box$1.observe(table, /*table_elementresizecontentbox_handler*/ ctx[26].bind(table)); 720 current = true; 721 722 if (!mounted) { 723 dispose = listen$1(table, "scroll", /*handle_scroll*/ ctx[9]); 724 mounted = true; 725 } 726 }, 727 p(ctx, dirty) { 728 if (thead_slot) { 729 if (thead_slot.p && (!current || dirty[0] & /*$$scope*/ 1048576)) { 730 update_slot_base( 731 thead_slot, 732 thead_slot_template, 733 ctx, 734 /*$$scope*/ ctx[20], 735 !current 736 ? get_all_dirty_from_scope(/*$$scope*/ ctx[20]) 737 : get_slot_changes(thead_slot_template, /*$$scope*/ ctx[20], dirty, get_thead_slot_changes), 738 get_thead_slot_context 739 ); 740 } 741 } 742 743 if (/*visible*/ ctx[8].length && /*visible*/ ctx[8][0].data.length) { 744 if (if_block) { 745 if_block.p(ctx, dirty); 746
747 if (dirty[0] & /*visible*/ 256) { 748 transition_in$2(if_block, 1); 749 } 750 } else { 751 if_block = create_if_block$1(ctx); 752 if_block.c(); 753 transition_in$2(if_block, 1); 754 if_block.m(tbody, null); 755 } 756 } else if (if_block) { 757 group_outros$1(); 758 759 transition_out$2(if_block, 1, 1, () => { 760 if_block = null; 761 }); 762 763 check_outros$1(); 764 } 765 766 if (tfoot_slot) { 767 if (tfoot_slot.p && (!current || dirty[0] & /*$$scope*/ 1048576)) { 768 update_slot_base( 769 tfoot_slot, 770 tfoot_slot_template, 771 ctx, 772 /*$$scope*/ ctx[20], 773 !current 774 ? get_all_dirty_from_scope(/*$$scope*/ ctx[20]) 775 : get_slot_changes(tfoot_slot_template, /*$$scope*/ ctx[20], dirty, get_tfoot_slot_changes), 776 get_tfoot_slot_context 777 ); 778 } 779 } 780 781 if (!current || dirty[0] & /*top*/ 64) { 782 set_style$1(table, "--bw-svt-p-top", /*top*/ ctx[6] + "px"); 783 } 784 785 if (!current || dirty[0] & /*bottom*/ 4) { 786 set_style$1(table, "--bw-svt-p-bottom", /*bottom*/ ctx[2] + "px"); 787 } 788 789 if (!current || dirty[0] & /*head_height*/ 16) { 790 set_style$1(table, "--bw-svt-head-height", /*head_height*/ ctx[4] + "px"); 791 } 792 793 if (!current || dirty[0] & /*foot_height*/ 32) { 794 set_style$1(table, "--bw-svt-foot-height", /*foot_height*/ ctx[5] + "px"); 795 } 796 797 if (!current || dirty[0] & /*average_height*/ 2) { 798 set_style$1(table, "--bw-svt-avg-row-height", /*average_height*/ ctx[1] + "px"); 799 } 800 }, 801 i(local) { 802 if (current) return; 803 transition_in$2(thead_slot, local); 804 transition_in$2(if_block); 805 transition_in$2(tfoot_slot, local); 806 current = true; 807 }, 808 o(local) { 809 transition_out$2(thead_slot, local); 810 transition_out$2(if_block); 811 transition_out$2(tfoot_slot, local); 812 current = false; 813 }, 814 d(detaching) { 815 if (detaching) { 816 detach$2(svelte_virtual_table_viewport); 817 } 818 819 if (thead_slot) thead_slot.d(detaching); 820 thead_resize_listener(); 821 if (if_block) if_block.d(); 822 /*tbody_binding*/ ctx[23](null); 823 if (tfoot_slot) tfoot_slot.d(detaching); 824 tfoot_resize_listener(); 825 /*table_binding*/ ctx[25](null); 826 table_resize_listener();
827 mounted = false; 828 dispose(); 829 } 830 }; 831} 832 833let height = "100%"; 834 835function get_computed_px_amount(elem, property) { 836 if (!elem) { 837 return 0; 838 } 839 840 const compStyle = getComputedStyle(elem); 841 let x = parseInt(compStyle.getPropertyValue(property)); 842 return x; 843} 844 845function instance$2($$self, $$props, $$invalidate) { 846 let sortedItems; 847 let { $$slots: slots = {}, $$scope } = $$props; 848 let { items = [] } = $$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 viewport_box; 868 let content_height = 0; 869 870 async function refresh_height_map(_items) { 871 if (viewport_height === 0) { 872 return; 873 } 874 875 const { scrollTop } = viewport; 876 $$invalidate(13, table_scrollbar_width = viewport.offsetWidth - viewport.clientWidth); 877 content_height = top - (scrollTop - head_height); 878 let i = start; 879 880 while (content_height < max_height && i < _items.length) { 881 let row = rows[i - start]; 882 883 if (!row) { 884 $$invalidate(11, end = i + 1); 885 await tick$1(); // render the newly visible row 886 row = rows[i - start]; 887 } 888 889 let _h = row?.getBoundingClientRect().height; 890 891 if (!_h) { 892 _h = average_height; 893 } 894 895 const row_height = height_map[i] = _h; 896 content_height += row_height; 897 i += 1; 898 } 899 900 $$invalidate(11, end = i); 901 const remaining = _items.length - end; 902 const scrollbar_height = viewport.offsetHeight - viewport.clientHeight; 903 904 if (scrollbar_height > 0) { 905 content_height += scrollbar_height; 906 } 907 908 let filtered_height_map = height_map.filter(v => typeof v === "number"); 909 $$invalidate(1, average_height = filtered_height_map.reduce((a, b) => a + b, 0) / filtered_height_map.length); 910 $$invalidate(2, bottom = remaining * average_height); 911 height_map.length = _items.length; 912 await tick$1(); 913 914 if (!max_height) { 915 $$invalidate(12, actual_height = content_height + 1); 916 } else if (content_height < max_height) { 917 $$invalidate(12, actual_height = content_height + 2); 918 } else { 919 $$invalidate(12, actual_height = max_height); 920 } 921 922 await tick$1(); 923 } 924 925 async function scroll_and_render(n) { 926 requestAnimationFrame(async () => { 927 if (typeof n !== "number") return; 928 const direction = typeof n !== "number" ? false : is_in_view(n); 929 930 if (direction === true) { 931 return; 932 } 933 934 if (direction === "back") { 935 await scroll_to_index(n, { behavior: "instant" }); 936 } 937 938 if (direction === "forwards") { 939 await scroll_to_index(n, { behavior: "instant" }, true); 940 } 941 }); 942 } 943 944 function is_in_view(n) { 945 const current = rows && rows[n - start]; 946 947 if (!current && n < start) { 948 return "back"; 949 } 950 951 if (!current && n >= end - 1) { 952 return "forwards"; 953 } 954 955 const { top: viewport_top } = viewport.getBoundingClientRect(); 956 const { top, bottom } = current.getBoundingClientRect(); 957 958 if (top - viewport_top < 37) { 959 return "back"; 960 } 961 962 if (bottom - viewport_top > viewport_height) { 963 return "forwards"; 964 } 965 966 return true; 967 } 968 969 async function handle_scroll(e) { 970 const scroll_top = viewport.scrollTop; 971 rows = contents.children; 972 const is_start_overflow = sortedItems.length < start; 973 const row_top_border = get_computed_px_amount(rows[1], "border-top-width"); 974 const actual_border_collapsed_width = 0; 975 976 if (is_start_overflow) { 977 await scroll_to_index(sortedItems.length - 1, { behavior: "auto" }); 978 } 979 980 let new_start = 0; 981 982 // acquire height map for currently visible rows 983 for (let v = 0; v < rows.length; v += 1) { 984 height_map[start + v] = rows[v].getBoundingClientRect().height; 985 } 986 987 let i = 0; 988 989 // start from top: thead, with its borders, plus the first border to afterwards neglect 990 let y = head_height + row_top_border / 2; 991 992 let row_heights = []; 993 994 // loop items to find new start 995 while (i < sortedItems.length) { 996 const row_height = height_map[i] || average_height; 997 row_heights[i] = row_height; 998 999 // we only want to jump if the full (incl. border) row is away 1000 if (y + row_height + actual_border_collapsed_width > scroll_top) { 1001 // this is the last index still inside the viewport 1002 new_start = i; 1003
1004 $$invalidate(6, top = y - (head_height + row_top_border / 2)); 1005 break; 1006 } 1007 1008 y += row_height; 1009 i += 1; 1010 } 1011 1012 new_start = Math.max(0, new_start); 1013 1014 while (i < sortedItems.length) { 1015 const row_height = height_map[i] || average_height; 1016 y += row_height; 1017 i += 1; 1018 1019 if (y > scroll_top + viewport_height) { 1020 break; 1021 } 1022 } 1023 1024 $$invalidate(10, start = new_start); 1025 $$invalidate(11, end = i); 1026 const remaining = sortedItems.length - end; 1027 1028 if (end === 0) { 1029 $$invalidate(11, end = 10); 1030 } 1031 1032 $$invalidate(1, average_height = (y - head_height) / end); 1033 let remaining_height = remaining * average_height; // 0 1034 1035 // compute height map for remaining items 1036 while (i < sortedItems.length) { 1037 i += 1; 1038 height_map[i] = average_height; 1039 } 1040 1041 $$invalidate(2, bottom = remaining_height); 1042 1043 if (!isFinite(bottom)) { 1044 $$invalidate(2, bottom = 200000); 1045 } 1046 } 1047 1048 async function scroll_to_index(index, opts, align_end = false) { 1049 await tick$1(); 1050 const _itemHeight = average_height; 1051 let distance = index * _itemHeight; 1052 1053 if (align_end) { 1054 distance = distance - viewport_height + _itemHeight + head_height; 1055 } 1056 1057 const scrollbar_height = viewport.offsetHeight - viewport.clientHeight; 1058 1059 if (scrollbar_height > 0) { 1060 distance += scrollbar_height; 1061 } 1062 1063 const _opts = { 1064 top: distance, 1065 behavior: "smooth", 1066 ...opts 1067 }; 1068 1069 viewport.scrollTo(_opts); 1070 } 1071 1072 onMount$1(() => { 1073 rows = contents.children; 1074 $$invalidate(18, mounted = true); 1075 refresh_height_map(items); 1076 }); 1077 1078 function thead_elementresize_handler() { 1079 head_height = this.offsetHeight; 1080 $$invalidate(4, head_height); 1081 } 1082 1083 function tbody_binding($$value) { 1084 binding_callbacks$1[$$value ? 'unshift' : 'push'](() => { 1085 contents = $$value; 1086 $$invalidate(3, contents); 1087 }); 1088 } 1089 1090 function tfoot_elementresize_handler() { 1091 foot_height = this.offsetHeight; 1092 $$invalidate(5, foot_height); 1093 } 1094 1095 function table_binding($$value) { 1096 binding_callbacks$1[$$value ? 'unshift' : 'push'](() => { 1097 viewport = $$value; 1098 $$invalidate(7, viewport); 1099 }); 1100 } 1101 1102 function table_elementresizecontentbox_handler() { 1103 viewport_box = ResizeObserverSingleton$1.entries.get(this)?.contentRect; 1104 $$invalidate(0, viewport_box); 1105 } 1106 1107 $$self.$$set = $$props => {
1108 if ('items' in $$props) $$invalidate(14, items = $$props.items); 1109 if ('max_height' in $$props) $$invalidate(15, 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(16, selected = $$props.selected); 1115 if ('$$scope' in $$props) $$invalidate(20, $$scope = $$props.$$scope); 1116 }; 1117 1118 $$self.$$.update = () => { 1119 if ($$self.$$.dirty[0] & /*viewport_box*/ 1) { 1120 viewport_height = viewport_box?.height || 0; 1121 } 1122 1123 if ($$self.$$.dirty[0] & /*items*/ 16384) { 1124 $$invalidate(19, sortedItems = items); 1125 } 1126 1127 if ($$self.$$.dirty[0] & /*mounted, sortedItems*/ 786432) { 1128 if (mounted) requestAnimationFrame(() => refresh_height_map(sortedItems)); 1129 } 1130 1131 if ($$self.$$.dirty[0] & /*selected*/ 65536) { 1132 scroll_and_render(selected); 1133 } 1134 1135 if ($$self.$$.dirty[0] & /*sortedItems, start, end*/ 527360) { 1136 $$invalidate(8, visible = sortedItems.slice(start, end).map((data, i) => { 1137 return { index: i + start, data }; 1138 })); 1139 } 1140 }; 1141 1142 return [ 1143 viewport_box, 1144 average_height, 1145 bottom, 1146 contents, 1147 head_height, 1148 foot_height, 1149 top, 1150 viewport, 1151 visible, 1152 handle_scroll, 1153 start, 1154 end, 1155 actual_height, 1156 table_scrollbar_width, 1157 items, 1158 max_height, 1159 selected, 1160 scroll_to_index, 1161 mounted, 1162 sortedItems, 1163 $$scope, 1164 slots, 1165 thead_elementresize_handler, 1166 tbody_binding, 1167 tfoot_elementresize_handler, 1168 table_binding, 1169 table_elementresizecontentbox_handler 1170 ]; 1171} 1172 1173class VirtualTable extends SvelteComponent$2 { 1174 constructor(options) { 1175 super(); 1176 1177 init$2( 1178 this, 1179 options, 1180 instance$2, 1181 create_fragment$2, 1182 safe_not_equal$2, 1183 { 1184 items: 14, 1185 max_height: 15, 1186 actual_height: 12, 1187 table_scrollbar_width: 13, 1188 start: 10, 1189 end: 11, 1190 selected: 16, 1191 scroll_to_index: 17 1192 }, 1193 null, 1194 [-1, -1] 1195 ); 1196 } 1197 1198 get scroll_to_index() { 1199 return this.$$.ctx[17]; 1200 } 1201} 1202 1203const Table_svelte_svelte_type_style_lang = ''; 1204 1205/* home/runner/work/gradio/gradio/js/dataframe/shared/Table.svelte generated by Svelte v4.2.2 */ 1206const { 1207 ResizeObserverSingleton, 1208 SvelteComponent: SvelteComponent$1, 1209 action_destroyer, 1210 add_flush_callback, 1211 append, 1212 attr, 1213 bind, 1214 binding_callbacks, 1215 check_outros, 1216 create_component: create_component$1, 1217 destroy_component: destroy_component$1, 1218 detach: detach$1, 1219 element, 1220 empty, 1221 ensure_array_like, 1222 group_outros, 1223 init: init$1, 1224 insert: insert$1, 1225 listen, 1226 mount_component: mount_component$1, 1227 outro_and_destroy_block, 1228 resize_observer_content_box, 1229 run_all, 1230 safe_not_equal: safe_not_equal$1, 1231 set_data, 1232 set_style, 1233 space: space$1, 1234 svg_element, 1235 text, 1236 toggle_class, 1237 transition_in: transition_in$1, 1238 transition_out: transition_out$1, 1239 update_keyed_each 1240} = window.__gradio__svelte__internal; 1241const { createEventDispatcher, tick, onMount } = window.__gradio__svelte__internal; 1242function get_each_context_1(ctx, list, i) { 1243 const child_ctx = ctx.slice(); 1244 child_ctx[13] = list[i].value; 1245 child_ctx[88] = list[i].id; 1246 child_ctx[91] = list; 1247 child_ctx[92] = i; 1248 return child_ctx; 1249} 1250 1251function get_each_context(ctx, list, i) { 1252 const child_ctx = ctx.slice(); 1253 child_ctx[13] = list[i].value; 1254 child_ctx[88] = list[i].id; 1255 child_ctx[89] = list; 1256 child_ctx[90] = i; 1257 return child_ctx; 1258} 1259 1260function get_each_context_2(ctx, list, i) { 1261 const child_ctx = ctx.slice(); 1262 child_ctx[13] = list[i].value; 1263 child_ctx[88] = list[i].id; 1264 child_ctx[93] = list; 1265 child_ctx[90] = i; 1266 return child_ctx; 1267} 1268 1269function get_each_context_3(ctx, list, i) { 1270 const child_ctx = ctx.slice(); 1271 child_ctx[13] = list[i].value; 1272 child_ctx[88] = list[i].id; 1273 child_ctx[92] = i; 1274 return child_ctx; 1275} 1276 1277// (505:1) {#if label && label.length !== 0 && show_label} 1278function create_if_block_5(ctx) { 1279 let p; 1280 let t; 1281 1282 return { 1283 c() { 1284 p = element("p"); 1285 t = text(/*label*/ ctx[1]); 1286 attr(p, "class", "svelte-1bvc1p0"); 1287 }, 1288 m(target, anchor) { 1289 insert$1(target, p, anchor); 1290 append(p, t); 1291 }, 1292 p(ctx, dirty) {
1293 if (dirty[0] & /*label*/ 2) set_data(t, /*label*/ ctx[1]); 1294 }, 1295 d(detaching) { 1296 if (detaching) { 1297 detach$1(p); 1298 } 1299 } 1300 }; 1301} 1302 1303// (525:3) {#if label && label.length !== 0} 1304function create_if_block_4(ctx) { 1305 let caption; 1306 let t; 1307 1308 return { 1309 c() { 1310 caption = element("caption"); 1311 t = text(/*label*/ ctx[1]); 1312 attr(caption, "class", "sr-only"); 1313 }, 1314 m(target, anchor) { 1315 insert$1(target, caption, anchor); 1316 append(caption, t); 1317 }, 1318 p(ctx, dirty) { 1319 if (dirty[0] & /*label*/ 2) set_data(t, /*label*/ ctx[1]); 1320 }, 1321 d(detaching) { 1322 if (detaching) { 1323 detach$1(caption); 1324 } 1325 } 1326 }; 1327} 1328 1329// (530:5) {#each _headers as { value, id } 1330function create_each_block_3(key_1, ctx) { 1331 let th; 1332 let div1; 1333 let editablecell; 1334 let t0; 1335 let div0; 1336 let svg; 1337 let path; 1338 let div0_class_value; 1339 let t1; 1340 let th_aria_sort_value; 1341 let current; 1342 1343 editablecell = new EditableCell({ 1344 props: { 1345 value: /*value*/ ctx[13], 1346 latex_delimiters: /*latex_delimiters*/ ctx[5], 1347 line_breaks: /*line_breaks*/ ctx[11], 1348 header: true, 1349 edit: false, 1350 el: null 1351 } 1352 }); 1353 1354 return { 1355 key: key_1, 1356 first: null, 1357 c() { 1358 th = element("th"); 1359 div1 = element("div"); 1360 create_component$1(editablecell.$$.fragment); 1361 t0 = space$1(); 1362 div0 = element("div"); 1363 svg = svg_element("svg"); 1364 path = svg_element("path"); 1365 t1 = space$1(); 1366 attr(path, "d", "M4.49999 0L8.3971 6.75H0.602875L4.49999 0Z"); 1367 attr(svg, "width", "1em"); 1368 attr(svg, "height", "1em"); 1369 attr(svg, "viewBox", "0 0 9 7"); 1370 attr(svg, "fill", "none"); 1371 attr(svg, "xmlns", "http://www.w3.org/2000/svg"); 1372 attr(svg, "class", "svelte-1bvc1p0"); 1373 attr(div0, "class", div0_class_value = "sort-button " + /*sort_direction*/ ctx[19] + "" + " svelte-1bvc1p0"); 1374 toggle_class(div0, "sorted", /*sort_by*/ ctx[20] === /*i*/ ctx[92]); 1375 toggle_class(div0, "des", /*sort_by*/ ctx[20] === /*i*/ ctx[92] && /*sort_direction*/ ctx[19] === "des"); 1376 attr(div1, "class", "cell-wrap svelte-1bvc1p0"); 1377 attr(th, "aria-sort", th_aria_sort_value = /*get_sort_status*/ ctx[36](/*value*/ ctx[13], /*sort_by*/ ctx[20], /*sort_direction*/ ctx[19])); 1378 attr(th, "class", "svelte-1bvc1p0"); 1379 toggle_class(th, "editing", /*header_edit*/ ctx[26] === /*i*/ ctx[92]); 1380 1381 set_style(th, "width", /*column_widths*/ ctx[12].length 1382 ? /*column_widths*/ ctx[12][/*i*/ ctx[92]] 1383 : undefined); 1384 1385 this.first = th; 1386 }, 1387 m(target, anchor) { 1388 insert$1(target, th, anchor); 1389 append(th, div1); 1390 mount_component$1(editablecell, div1, null); 1391 append(div1, t0); 1392 append(div1, div0); 1393 append(div0, svg); 1394 append(svg, path); 1395 append(th, t1); 1396 current = true; 1397 }, 1398 p(new_ctx, dirty) { 1399 ctx = new_ctx; 1400 const editablecell_changes = {}; 1401 if (dirty[0] & /*_headers*/ 131072) editablecell_changes.value = /*value*/ ctx[13]; 1402 if (dirty[0] & /*latex_delimiters*/ 32) editablecell_changes.latex_delimiters = /*latex_delimiters*/ ctx[5]; 1403 if (dirty[0] & /*line_breaks*/ 2048) editablecell_changes.line_breaks = /*line_breaks*/ ctx[11]; 1404 editablecell.$set(editablecell_changes); 1405 1406 if (!current || dirty[0] & /*sort_direction*/ 524288 && div0_class_value !== (div0_class_value = "sort-button " + /*sort_direction*/ ctx[19] + "" + " svelte-1bvc1p0")) { 1407 attr(div0, "class", div0_class_value); 1408 } 1409 1410 if (!current || dirty[0] & /*sort_direction, sort_by, _headers*/ 1703936) { 1411 toggle_class(div0, "sorted", /*sort_by*/ ctx[20] === /*i*/ ctx[92]); 1412 } 1413 1414 if (!current || dirty[0] & /*sort_direction, sort_by, _headers, sort_direction*/ 1703936) { 1415 toggle_class(div0, "des", /*sort_by*/ ctx[20] === /*i*/ ctx[92] && /*sort_direction*/ ctx[19] === "des"); 1416 } 1417 1418 if (!current || dirty[0] & /*_headers, sort_by, sort_direction*/ 1703936 && th_aria_sort_value !== (th_aria_sort_value = /*get_sort_status*/ ctx[36](/*value*/ ctx[13], /*sort_by*/ ctx[20], /*sort_direction*/ ctx[19]))) { 1419 attr(th, "aria-sort", th_aria_sort_value); 1420 } 1421 1422 if (!current || dirty[0] & /*header_edit, _headers*/ 67239936) { 1423 toggle_class(th, "editing", /*header_edit*/ ctx[26] === /*i*/ ctx[92]); 1424 } 1425
1426 if (dirty[0] & /*column_widths, _headers*/ 135168) { 1427 set_style(th, "width", /*column_widths*/ ctx[12].length 1428 ? /*column_widths*/ ctx[12][/*i*/ ctx[92]] 1429 : undefined); 1430 } 1431 }, 1432 i(local) { 1433 if (current) return; 1434 transition_in$1(editablecell.$$.fragment, local); 1435 current = true; 1436 }, 1437 o(local) { 1438 transition_out$1(editablecell.$$.fragment, local); 1439 current = false; 1440 }, 1441 d(detaching) { 1442 if (detaching) { 1443 detach$1(th); 1444 } 1445 1446 destroy_component$1(editablecell); 1447 } 1448 }; 1449} 1450 1451// (568:5) {#each max as { value, id } 1452function create_each_block_2(key_1, ctx) { 1453 let td; 1454 let div; 1455 let editablecell; 1456 let t; 1457 let j = /*j*/ ctx[90]; 1458 let current; 1459 1460 editablecell = new EditableCell({ 1461 props: { 1462 value: /*value*/ ctx[13], 1463 latex_delimiters: /*latex_delimiters*/ ctx[5], 1464 line_breaks: /*line_breaks*/ ctx[11], 1465 datatype: Array.isArray(/*datatype*/ ctx[0]) 1466 ? /*datatype*/ ctx[0][/*j*/ ctx[90]] 1467 : /*datatype*/ ctx[0], 1468 edit: false, 1469 el: null 1470 } 1471 }); 1472 1473 const assign_td = () => /*td_binding*/ ctx[53](td, j); 1474 const unassign_td = () => /*td_binding*/ ctx[53](null, j); 1475 1476 return { 1477 key: key_1, 1478 first: null, 1479 c() { 1480 td = element("td"); 1481 div = element("div"); 1482 create_component$1(editablecell.$$.fragment); 1483 t = space$1(); 1484 attr(div, "class", "cell-wrap svelte-1bvc1p0"); 1485 attr(td, "tabindex", "-1"); 1486 attr(td, "class", "svelte-1bvc1p0"); 1487 this.first = td; 1488 }, 1489 m(target, anchor) { 1490 insert$1(target, td, anchor); 1491 append(td, div); 1492 mount_component$1(editablecell, div, null); 1493 append(td, t); 1494 assign_td(); 1495 current = true; 1496 }, 1497 p(new_ctx, dirty) { 1498 ctx = new_ctx; 1499 const editablecell_changes = {}; 1500 if (dirty[1] & /*max*/ 16) editablecell_changes.value = /*value*/ ctx[13]; 1501 if (dirty[0] & /*latex_delimiters*/ 32) editablecell_changes.latex_delimiters = /*latex_delimiters*/ ctx[5]; 1502 if (dirty[0] & /*line_breaks*/ 2048) editablecell_changes.line_breaks = /*line_breaks*/ ctx[11]; 1503 1504 if (dirty[0] & /*datatype*/ 1 | dirty[1] & /*max*/ 16) editablecell_changes.datatype = Array.isArray(/*datatype*/ ctx[0]) 1505 ? /*datatype*/ ctx[0][/*j*/ ctx[90]] 1506 : /*datatype*/ ctx[0]; 1507 1508 editablecell.$set(editablecell_changes); 1509 1510 if (j !== /*j*/ ctx[90]) { 1511 unassign_td(); 1512 j = /*j*/ ctx[90]; 1513 assign_td(); 1514 } 1515 }, 1516 i(local) { 1517 if (current) return; 1518 transition_in$1(editablecell.$$.fragment, local); 1519 current = true; 1520 }, 1521 o(local) { 1522 transition_out$1(editablecell.$$.fragment, local); 1523 current = false; 1524 }, 1525 d(detaching) { 1526 if (detaching) { 1527 detach$1(td); 1528 } 1529 1530 destroy_component$1(editablecell); 1531 unassign_td(); 1532 } 1533 }; 1534} 1535 1536// (601:4) {#if label && label.length !== 0} 1537function create_if_block_3(ctx) { 1538 let caption; 1539 let t; 1540 1541 return { 1542 c() { 1543 caption = element("caption"); 1544 t = text(/*label*/ ctx[1]); 1545 attr(caption, "class", "sr-only"); 1546 }, 1547 m(target, anchor) { 1548 insert$1(target, caption, anchor); 1549 append(caption, t); 1550 }, 1551 p(ctx, dirty) { 1552 if (dirty[0] & /*label*/ 2) set_data(t, /*label*/ ctx[1]); 1553 }, 1554 d(detaching) { 1555 if (detaching) { 1556 detach$1(caption); 1557 } 1558 } 1559 }; 1560} 1561 1562// (594:3) <VirtualTable bind:items={data} max_height={height} bind:actual_height={table_height} bind:table_scrollbar_width={scrollbar_width} selected={selected_index} > 1563function create_default_slot_3(ctx) { 1564 let if_block_anchor; 1565 let if_block = /*label*/ ctx[1] && /*label*/ ctx[1].length !== 0 && create_if_block_3(ctx); 1566 1567 return { 1568 c() { 1569 if (if_block) if_block.c(); 1570 if_block_anchor = empty(); 1571 }, 1572 m(target, anchor) { 1573 if (if_block) if_block.m(target, anchor); 1574 insert$1(target, if_block_anchor, anchor); 1575 }, 1576 p(ctx, dirty) { 1577 if (/*label*/ ctx[1] && /*label*/ ctx[1].length !== 0) { 1578 if (if_block) { 1579 if_block.p(ctx, dirty); 1580 } else { 1581 if_block = create_if_block_3(ctx); 1582 if_block.c(); 1583 if_block.m(if_block_anchor.parentNode, if_block_anchor); 1584 } 1585 } else if (if_block) { 1586 if_block.d(1); 1587 if_block = null; 1588 } 1589 }, 1590 d(detaching) { 1591 if (detaching) { 1592 detach$1(if_block_anchor); 1593 } 1594 1595 if (if_block) if_block.d(detaching); 1596 } 1597 }; 1598} 1599 1600// (605:5) {#each _headers as { value, id } 1601function create_each_block_1(key_1, ctx) { 1602 let th; 1603 let div1; 1604 let editablecell; 1605 let updating_value; 1606 let updating_el; 1607 let t0; 1608 let div0; 1609 let svg; 1610 let path; 1611 let div0_class_value; 1612 let t1; 1613 let th_aria_sort_value; 1614 let current; 1615 let mounted; 1616 let dispose; 1617 1618 function editablecell_value_binding_1(value) { 1619 /*editablecell_value_binding_1*/ ctx[62](value, /*i*/ ctx[92]); 1620 } 1621 1622 function editablecell_el_binding_1(value) {
1623 /*editablecell_el_binding_1*/ ctx[63](value, /*id*/ ctx[88]); 1624 } 1625 1626 function dblclick_handler_1() { 1627 return /*dblclick_handler_1*/ ctx[64](/*i*/ ctx[92]); 1628 } 1629 1630 let editablecell_props = { 1631 latex_delimiters: /*latex_delimiters*/ ctx[5], 1632 line_breaks: /*line_breaks*/ ctx[11], 1633 edit: /*header_edit*/ ctx[26] === /*i*/ ctx[92], 1634 select_on_focus: /*select_on_focus*/ ctx[27], 1635 header: true 1636 }; 1637 1638 if (/*_headers*/ ctx[17][/*i*/ ctx[92]].value !== void 0) { 1639 editablecell_props.value = /*_headers*/ ctx[17][/*i*/ ctx[92]].value; 1640 } 1641 1642 if (/*els*/ ctx[24][/*id*/ ctx[88]].input !== void 0) { 1643 editablecell_props.el = /*els*/ ctx[24][/*id*/ ctx[88]].input; 1644 } 1645 1646 editablecell = new EditableCell({ props: editablecell_props }); 1647 binding_callbacks.push(() => bind(editablecell, 'value', editablecell_value_binding_1)); 1648 binding_callbacks.push(() => bind(editablecell, 'el', editablecell_el_binding_1)); 1649 editablecell.$on("keydown", /*end_header_edit*/ ctx[42]); 1650 editablecell.$on("dblclick", dblclick_handler_1); 1651 1652 function click_handler_1() { 1653 return /*click_handler_1*/ ctx[65](/*i*/ ctx[92]); 1654 } 1655 1656 return { 1657 key: key_1, 1658 first: null, 1659 c() { 1660 th = element("th"); 1661 div1 = element("div"); 1662 create_component$1(editablecell.$$.fragment); 1663 t0 = space$1(); 1664 div0 = element("div"); 1665 svg = svg_element("svg"); 1666 path = svg_element("path"); 1667 t1 = space$1(); 1668 attr(path, "d", "M4.49999 0L8.3971 6.75H0.602875L4.49999 0Z"); 1669 attr(svg, "width", "1em"); 1670 attr(svg, "height", "1em"); 1671 attr(svg, "viewBox", "0 0 9 7"); 1672 attr(svg, "fill", "none"); 1673 attr(svg, "xmlns", "http://www.w3.org/2000/svg"); 1674 attr(svg, "class", "svelte-1bvc1p0"); 1675 attr(div0, "class", div0_class_value = "sort-button " + /*sort_direction*/ ctx[19] + "" + " svelte-1bvc1p0"); 1676 toggle_class(div0, "sorted", /*sort_by*/ ctx[20] === /*i*/ ctx[92]); 1677 toggle_class(div0, "des", /*sort_by*/ ctx[20] === /*i*/ ctx[92] && /*sort_direction*/ ctx[19] === "des"); 1678 attr(div1, "class", "cell-wrap svelte-1bvc1p0"); 1679 attr(th, "aria-sort", th_aria_sort_value = /*get_sort_status*/ ctx[36](/*value*/ ctx[13], /*sort_by*/ ctx[20], /*sort_direction*/ ctx[19])); 1680 set_style(th, "width", "var(--cell-width-" + /*i*/ ctx[92] + ")"); 1681 attr(th, "class", "svelte-1bvc1p0"); 1682 toggle_class(th, "focus", /*header_edit*/ ctx[26] === /*i*/ ctx[92] || /*selected_header*/ ctx[28] === /*i*/ ctx[92]); 1683 this.first = th; 1684 }, 1685 m(target, anchor) { 1686 insert$1(target, th, anchor); 1687 append(th, div1); 1688 mount_component$1(editablecell, div1, null); 1689 append(div1, t0); 1690 append(div1, div0); 1691 append(div0, svg); 1692 append(svg, path); 1693 append(th, t1); 1694 current = true; 1695 1696 if (!mounted) { 1697 dispose = listen(div0, "click", click_handler_1); 1698 mounted = true; 1699 } 1700 }, 1701 p(new_ctx, dirty) { 1702 ctx = new_ctx; 1703 const editablecell_changes = {}; 1704 if (dirty[0] & /*latex_delimiters*/ 32) editablecell_changes.latex_delimiters = /*latex_delimiters*/ ctx[5]; 1705 if (dirty[0] & /*line_breaks*/ 2048) editablecell_changes.line_breaks = /*line_breaks*/ ctx[11]; 1706 if (dirty[0] & /*header_edit, _headers*/ 67239936) editablecell_changes.edit = /*header_edit*/ ctx[26] === /*i*/ ctx[92]; 1707 if (dirty[0] & /*select_on_focus*/ 134217728) editablecell_changes.select_on_focus = /*select_on_focus*/ ctx[27]; 1708 1709 if (!updating_value && dirty[0] & /*_headers*/ 131072) { 1710 updating_value = true; 1711 editablecell_changes.value = /*_headers*/ ctx[17][/*i*/ ctx[92]].value; 1712 add_flush_callback(() => updating_value = false); 1713 } 1714 1715 if (!updating_el && dirty[0] & /*els, _headers*/ 16908288) { 1716 updating_el = true; 1717 editablecell_changes.el = /*els*/ ctx[24][/*id*/ ctx[88]].input; 1718 add_flush_callback(() => updating_el = false); 1719 } 1720 1721 editablecell.$set(editablecell_changes); 1722 1723 if (!current || dirty[0] & /*sort_direction*/ 524288 && div0_class_value !== (div0_class_value = "sort-button " + /*sort_direction*/ ctx[19] + "" + " svelte-1bvc1p0")) { 1724 attr(div0, "class", div0_class_value); 1725 } 1726 1727 if (!current || dirty[0] & /*sort_direction, sort_by, _headers*/ 1703936) { 1728 toggle_class(div0, "sorted", /*sort_by*/ ctx[20] === /*i*/ ctx[92]); 1729 } 1730 1731 if (!current || dirty[0] & /*sort_direction, sort_by, _headers, sort_direction*/ 1703936) { 1732 toggle_class(div0, "des", /*sort_by*/ ctx[20] === /*i*/ ctx[92] && /*sort_direction*/ ctx[19] === "des"); 1733 } 1734 1735 if (!current || dirty[0] & /*_headers, sort_by, sort_direction*/ 1703936 && th_aria_sort_value !== (th_aria_sort_value = /*get_sort_status*/ ctx[36](/*value*/ ctx[13], /*sort_by*/ ctx[20], /*sort_direction*/ ctx[19]))) { 1736 attr(th, "aria-sort", th_aria_sort_value); 1737 } 1738 1739 if (!current || dirty[0] & /*_headers*/ 131072) { 1740 set_style(th, "width", "var(--cell-width-" + /*i*/ ctx[92] + ")"); 1741 } 1742 1743 if (!current || dirty[0] & /*header_edit, _headers, selected_header*/ 335675392) { 1744 toggle_class(th, "focus", /*header_edit*/ ctx[26] === /*i*/ ctx[92] || /*selected_header*/ ctx[28] === /*i*/ ctx[92]); 1745 } 1746 }, 1747 i(local) { 1748 if (current) return; 1749 transition_in$1(editablecell.$$.fragment, local); 1750 current = true; 1751 }, 1752 o(local) { 1753 transition_out$1(editablecell.$$.fragment, local); 1754 current = false;
1755 }, 1756 d(detaching) { 1757 if (detaching) { 1758 detach$1(th); 1759 } 1760 1761 destroy_component$1(editablecell); 1762 mounted = false; 1763 dispose(); 1764 } 1765 }; 1766} 1767 1768// (604:4) 1769function create_thead_slot(ctx) { 1770 let tr; 1771 let each_blocks = []; 1772 let each_1_lookup = new Map(); 1773 let current; 1774 let each_value_1 = ensure_array_like(/*_headers*/ ctx[17]); 1775 const get_key = ctx => /*id*/ ctx[88]; 1776 1777 for (let i = 0; i < each_value_1.length; i += 1) { 1778 let child_ctx = get_each_context_1(ctx, each_value_1, i); 1779 let key = get_key(child_ctx); 1780 each_1_lookup.set(key, each_blocks[i] = create_each_block_1(key, child_ctx)); 1781 } 1782 1783 return { 1784 c() { 1785 tr = element("tr"); 1786 1787 for (let i = 0; i < each_blocks.length; i += 1) { 1788 each_blocks[i].c(); 1789 } 1790 1791 attr(tr, "slot", "thead"); 1792 attr(tr, "class", "svelte-1bvc1p0"); 1793 }, 1794 m(target, anchor) { 1795 insert$1(target, tr, anchor); 1796 1797 for (let i = 0; i < each_blocks.length; i += 1) { 1798 if (each_blocks[i]) { 1799 each_blocks[i].m(tr, null); 1800 } 1801 } 1802 1803 current = true; 1804 }, 1805 p(ctx, dirty) { 1806 if (dirty[0] & /*_headers, sort_by, sort_direction, header_edit, selected_header, latex_delimiters, line_breaks, select_on_focus, els*/ 488245280 | dirty[1] & /*get_sort_status, handle_sort, end_header_edit, edit_header*/ 3616) { 1807 each_value_1 = ensure_array_like(/*_headers*/ ctx[17]); 1808 group_outros(); 1809 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); 1810 check_outros(); 1811 } 1812 }, 1813 i(local) { 1814 if (current) return; 1815 1816 for (let i = 0; i < each_value_1.length; i += 1) { 1817 transition_in$1(each_blocks[i]); 1818 } 1819 1820 current = true; 1821 }, 1822 o(local) { 1823 for (let i = 0; i < each_blocks.length; i += 1) { 1824 transition_out$1(each_blocks[i]); 1825 } 1826 1827 current = false; 1828 }, 1829 d(detaching) { 1830 if (detaching) { 1831 detach$1(tr); 1832 } 1833 1834 for (let i = 0; i < each_blocks.length; i += 1) { 1835 each_blocks[i].d(); 1836 } 1837 } 1838 }; 1839} 1840 1841// (649:5) {#each item as { value, id } 1842function create_each_block(key_1, ctx) { 1843 let td; 1844 let div; 1845 let editablecell; 1846 let updating_value; 1847 let updating_el; 1848 let t; 1849 let td_style_value; 1850 let style_width = `var(--cell-width-${/*j*/ ctx[90]})`; 1851 let current; 1852 let mounted; 1853 let dispose; 1854 1855 function editablecell_value_binding(value) { 1856 /*editablecell_value_binding*/ ctx[56](value, /*index*/ ctx[86], /*j*/ ctx[90]); 1857 } 1858 1859 function editablecell_el_binding(value) { 1860 /*editablecell_el_binding*/ ctx[57](value, /*id*/ ctx[88]); 1861 } 1862 1863 let editablecell_props = { 1864 display_value: /*display_value*/ ctx[15]?.[/*index*/ ctx[86]]?.[/*j*/ ctx[90]], 1865 latex_delimiters: /*latex_delimiters*/ ctx[5], 1866 line_breaks: /*line_breaks*/ ctx[11], 1867 editable: /*editable*/ ctx[6], 1868 edit: dequal(/*editing*/ ctx[23], [/*index*/ ctx[86], /*j*/ ctx[90]]), 1869 datatype: Array.isArray(/*datatype*/ ctx[0]) 1870 ? /*datatype*/ ctx[0][/*j*/ ctx[90]] 1871 : /*datatype*/ ctx[0], 1872 clear_on_focus: /*clear_on_focus*/ ctx[25] 1873 }; 1874 1875 if (/*data*/ ctx[18][/*index*/ ctx[86]][/*j*/ ctx[90]].value !== void 0) { 1876 editablecell_props.value = /*data*/ ctx[18][/*index*/ ctx[86]][/*j*/ ctx[90]].value; 1877 } 1878 1879 if (/*els*/ ctx[24][/*id*/ ctx[88]].input !== void 0) { 1880 editablecell_props.el = /*els*/ ctx[24][/*id*/ ctx[88]].input; 1881 } 1882 1883 editablecell = new EditableCell({ props: editablecell_props }); 1884 binding_callbacks.push(() => bind(editablecell, 'value', editablecell_value_binding)); 1885 binding_callbacks.push(() => bind(editablecell, 'el', editablecell_el_binding)); 1886 editablecell.$on("blur", /*blur_handler*/ ctx[58]); 1887 1888 function touchstart_handler() { 1889 return /*touchstart_handler*/ ctx[59](/*index*/ ctx[86], /*j*/ ctx[90]); 1890 } 1891 1892 function click_handler() { 1893 return /*click_handler*/ ctx[60](/*index*/ ctx[86], /*j*/ ctx[90]); 1894 } 1895 1896 function dblclick_handler() { 1897 return /*dblclick_handler*/ ctx[61](/*index*/ ctx[86], /*j*/ ctx[90]); 1898 } 1899 1900 return { 1901 key: key_1, 1902 first: null, 1903 c() { 1904 td = element("td"); 1905 div = element("div"); 1906 create_component$1(editablecell.$$.fragment); 1907 t = space$1(); 1908 attr(div, "class", "cell-wrap svelte-1bvc1p0"); 1909 attr(td, "tabindex", "0"); 1910 attr(td, "style", td_style_value = /*styling*/ ctx[16]?.[/*index*/ ctx[86]]?.[/*j*/ ctx[90]] || ""); 1911 attr(td, "class", "svelte-1bvc1p0"); 1912 toggle_class(td, "focus", dequal(/*selected*/ ctx[14], [/*index*/ ctx[86], /*j*/ ctx[90]])); 1913 set_style(td, "width", style_width); 1914 this.first = td; 1915 }, 1916 m(target, anchor) { 1917 insert$1(target, td, anchor); 1918 append(td, div);
1919 mount_component$1(editablecell, div, null); 1920 append(td, t); 1921 current = true; 1922 1923 if (!mounted) { 1924 dispose = [ 1925 listen(td, "touchstart", touchstart_handler, { passive: true }), 1926 listen(td, "click", click_handler), 1927 listen(td, "dblclick", dblclick_handler) 1928 ]; 1929 1930 mounted = true; 1931 } 1932 }, 1933 p(new_ctx, dirty) { 1934 ctx = new_ctx; 1935 const editablecell_changes = {}; 1936 if (dirty[0] & /*display_value*/ 32768 | dirty[2] & /*index, item*/ 50331648) editablecell_changes.display_value = /*display_value*/ ctx[15]?.[/*index*/ ctx[86]]?.[/*j*/ ctx[90]]; 1937 if (dirty[0] & /*latex_delimiters*/ 32) editablecell_changes.latex_delimiters = /*latex_delimiters*/ ctx[5]; 1938 if (dirty[0] & /*line_breaks*/ 2048) editablecell_changes.line_breaks = /*line_breaks*/ ctx[11]; 1939 if (dirty[0] & /*editable*/ 64) editablecell_changes.editable = /*editable*/ ctx[6]; 1940 if (dirty[0] & /*editing*/ 8388608 | dirty[2] & /*index, item*/ 50331648) editablecell_changes.edit = dequal(/*editing*/ ctx[23], [/*index*/ ctx[86], /*j*/ ctx[90]]); 1941 1942 if (dirty[0] & /*datatype*/ 1 | dirty[2] & /*item*/ 33554432) editablecell_changes.datatype = Array.isArray(/*datatype*/ ctx[0]) 1943 ? /*datatype*/ ctx[0][/*j*/ ctx[90]] 1944 : /*datatype*/ ctx[0]; 1945 1946 if (dirty[0] & /*clear_on_focus*/ 33554432) editablecell_changes.clear_on_focus = /*clear_on_focus*/ ctx[25]; 1947 1948 if (!updating_value && dirty[0] & /*data*/ 262144 | dirty[2] & /*index, item*/ 50331648) { 1949 updating_value = true; 1950 editablecell_changes.value = /*data*/ ctx[18][/*index*/ ctx[86]][/*j*/ ctx[90]].value; 1951 add_flush_callback(() => updating_value = false); 1952 } 1953 1954 if (!updating_el && dirty[0] & /*els*/ 16777216 | dirty[2] & /*item*/ 33554432) { 1955 updating_el = true; 1956 editablecell_changes.el = /*els*/ ctx[24][/*id*/ ctx[88]].input; 1957 add_flush_callback(() => updating_el = false); 1958 } 1959 1960 editablecell.$set(editablecell_changes); 1961 1962 if (!current || dirty[0] & /*styling*/ 65536 | dirty[2] & /*index, item*/ 50331648 && td_style_value !== (td_style_value = /*styling*/ ctx[16]?.[/*index*/ ctx[86]]?.[/*j*/ ctx[90]] || "")) { 1963 attr(td, "style", td_style_value); 1964 } 1965 1966 if (!current || dirty[0] & /*selected*/ 16384 | dirty[2] & /*index, item*/ 50331648) { 1967 toggle_class(td, "focus", dequal(/*selected*/ ctx[14], [/*index*/ ctx[86], /*j*/ ctx[90]])); 1968 } 1969 1970 const style_changed = dirty[0] & /*styling*/ 65536 | dirty[2] & /*index, item*/ 50331648; 1971 1972 if (dirty[0] & /*styling*/ 65536 | dirty[2] & /*item, index*/ 50331648 && style_width !== (style_width = `var(--cell-width-${/*j*/ ctx[90]})`) || style_changed) { 1973 set_style(td, "width", style_width); 1974 } 1975 }, 1976 i(local) { 1977 if (current) return; 1978 transition_in$1(editablecell.$$.fragment, local); 1979 current = true; 1980 }, 1981 o(local) { 1982 transition_out$1(editablecell.$$.fragment, local); 1983 current = false; 1984 }, 1985 d(detaching) { 1986 if (detaching) { 1987 detach$1(td); 1988 } 1989 1990 destroy_component$1(editablecell); 1991 mounted = false; 1992 run_all(dispose); 1993 } 1994 }; 1995} 1996 1997// (648:4) 1998function create_tbody_slot(ctx) { 1999 let tr; 2000 let each_blocks = []; 2001 let each_1_lookup = new Map(); 2002 let current; 2003 let each_value = ensure_array_like(/*item*/ ctx[87]); 2004 const get_key = ctx => /*id*/ ctx[88]; 2005 2006 for (let i = 0; i < each_value.length; i += 1) { 2007 let child_ctx = get_each_context(ctx, each_value, i); 2008 let key = get_key(child_ctx); 2009 each_1_lookup.set(key, each_blocks[i] = create_each_block(key, child_ctx)); 2010 } 2011 2012 return { 2013 c() { 2014 tr = element("tr"); 2015 2016 for (let i = 0; i < each_blocks.length; i += 1) { 2017 each_blocks[i].c(); 2018 } 2019 2020 attr(tr, "slot", "tbody"); 2021 attr(tr, "class", "svelte-1bvc1p0"); 2022 toggle_class(tr, "row_odd", /*index*/ ctx[86] % 2 === 0); 2023 }, 2024 m(target, anchor) { 2025 insert$1(target, tr, anchor); 2026 2027 for (let i = 0; i < each_blocks.length; i += 1) { 2028 if (each_blocks[i]) { 2029 each_blocks[i].m(tr, null); 2030 } 2031 } 2032 2033 current = true; 2034 }, 2035 p(ctx, dirty) { 2036 if (dirty[0] & /*styling, selected, display_value, latex_delimiters, line_breaks, editable, editing, datatype, clear_on_focus, data, els, parent*/ 1132841057 | dirty[1] & /*start_edit, handle_cell_click*/ 320 | dirty[2] & /*index, item*/ 50331648) { 2037 each_value = ensure_array_like(/*item*/ ctx[87]); 2038 group_outros(); 2039 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); 2040 check_outros(); 2041 } 2042 2043 if (!current || dirty[2] & /*index*/ 16777216) { 2044 toggle_class(tr, "row_odd", /*index*/ ctx[86] % 2 === 0); 2045 } 2046 }, 2047 i(local) { 2048 if (current) return; 2049 2050 for (let i = 0; i < each_value.length; i += 1) { 2051 transition_in$1(each_blocks[i]); 2052 } 2053 2054 current = true; 2055 }, 2056 o(local) { 2057 for (let i = 0; i < each_blocks.length; i += 1) { 2058 transition_out$1(each_blocks[i]); 2059 } 2060 2061 current = false;
2062 }, 2063 d(detaching) { 2064 if (detaching) { 2065 detach$1(tr); 2066 } 2067 2068 for (let i = 0; i < each_blocks.length; i += 1) { 2069 each_blocks[i].d(); 2070 } 2071 } 2072 }; 2073} 2074 2075// (585: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 > 2076function create_default_slot_2(ctx) { 2077 let virtualtable; 2078 let updating_items; 2079 let updating_actual_height; 2080 let updating_table_scrollbar_width; 2081 let current; 2082 2083 function virtualtable_items_binding(value) { 2084 /*virtualtable_items_binding*/ ctx[66](value); 2085 } 2086 2087 function virtualtable_actual_height_binding(value) { 2088 /*virtualtable_actual_height_binding*/ ctx[67](value); 2089 } 2090 2091 function virtualtable_table_scrollbar_width_binding(value) { 2092 /*virtualtable_table_scrollbar_width_binding*/ ctx[68](value); 2093 } 2094 2095 let virtualtable_props = { 2096 max_height: /*height*/ ctx[10], 2097 selected: /*selected_index*/ ctx[34], 2098 $$slots: { 2099 tbody: [ 2100 create_tbody_slot, 2101 ({ index, item }) => ({ 86: index, 87: item }), 2102 ({ index, item }) => [0, 0, (index ? 16777216 : 0) | (item ? 33554432 : 0)] 2103 ], 2104 thead: [create_thead_slot], 2105 default: [create_default_slot_3] 2106 }, 2107 $$scope: { ctx } 2108 }; 2109 2110 if (/*data*/ ctx[18] !== void 0) { 2111 virtualtable_props.items = /*data*/ ctx[18]; 2112 } 2113 2114 if (/*table_height*/ ctx[32] !== void 0) { 2115 virtualtable_props.actual_height = /*table_height*/ ctx[32]; 2116 } 2117 2118 if (/*scrollbar_width*/ ctx[33] !== void 0) { 2119 virtualtable_props.table_scrollbar_width = /*scrollbar_width*/ ctx[33]; 2120 } 2121 2122 virtualtable = new VirtualTable({ props: virtualtable_props }); 2123 binding_callbacks.push(() => bind(virtualtable, 'items', virtualtable_items_binding)); 2124 binding_callbacks.push(() => bind(virtualtable, 'actual_height', virtualtable_actual_height_binding)); 2125 binding_callbacks.push(() => bind(virtualtable, 'table_scrollbar_width', virtualtable_table_scrollbar_width_binding)); 2126 2127 return { 2128 c() { 2129 create_component$1(virtualtable.$$.fragment); 2130 }, 2131 m(target, anchor) { 2132 mount_component$1(virtualtable, target, anchor); 2133 current = true; 2134 }, 2135 p(ctx, dirty) { 2136 const virtualtable_changes = {}; 2137 if (dirty[0] & /*height*/ 1024) virtualtable_changes.max_height = /*height*/ ctx[10]; 2138 if (dirty[1] & /*selected_index*/ 8) virtualtable_changes.selected = /*selected_index*/ ctx[34]; 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*/ 1604307043 | dirty[2] & /*index, item*/ 50331648 | dirty[3] & /*$$scope*/ 4) { 2141 virtualtable_changes.$$scope = { dirty, ctx }; 2142 } 2143 2144 if (!updating_items && dirty[0] & /*data*/ 262144) { 2145 updating_items = true; 2146 virtualtable_changes.items = /*data*/ ctx[18]; 2147 add_flush_callback(() => updating_items = false); 2148 } 2149 2150 if (!updating_actual_height && dirty[1] & /*table_height*/ 2) { 2151 updating_actual_height = true; 2152 virtualtable_changes.actual_height = /*table_height*/ ctx[32]; 2153 add_flush_callback(() => updating_actual_height = false); 2154 } 2155 2156 if (!updating_table_scrollbar_width && dirty[1] & /*scrollbar_width*/ 4) { 2157 updating_table_scrollbar_width = true; 2158 virtualtable_changes.table_scrollbar_width = /*scrollbar_width*/ ctx[33]; 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[4][1] === "dynamic" && create_if_block_2(ctx); 2185 let if_block1 = /*col_count*/ ctx[3][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[4][1] === "dynamic") { 2204 if (if_block0) { 2205 if_block0.p(ctx, dirty); 2206
2207 if (dirty[0] & /*row_count*/ 16) { 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[3][1] === "dynamic") { 2227 if (if_block1) { 2228 if_block1.p(ctx, dirty); 2229 2230 if (dirty[0] & /*col_count*/ 8) { 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[73]); 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*/ 512 | dirty[3] & /*$$scope*/ 4) { 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[9]("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*/ 512 && t1_value !== (t1_value = /*i18n*/ ctx[9]("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[74]); 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*/ 512 | dirty[3] & /*$$scope*/ 4) { 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[9]("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*/ 512 && t1_value !== (t1_value = /*i18n*/ ctx[9]("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 && /*show_label*/ ctx[2] && 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[17]); 2499 const get_key = ctx => /*id*/ ctx[88]; 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[35]); 2508 const get_key_1 = ctx => /*id*/ ctx[88]; 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[69](value); 2518 } 2519 2520 let upload_props = { 2521 flex: false, 2522 center: false, 2523 boundedheight: false, 2524 disable_click: true, 2525 root: /*root*/ ctx[8], 2526 $$slots: { default: [create_default_slot_2] }, 2527 $$scope: { ctx } 2528 }; 2529 2530 if (/*dragging*/ ctx[29] !== void 0) { 2531 upload_props.dragging = /*dragging*/ ctx[29]; 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[70]); 2537 let if_block2 = /*editable*/ ctx[6] && 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 toggle_class(table_1, "fixed-layout", /*column_widths*/ ctx[12].length != 0); 2572 attr(div0, "class", "table-wrap svelte-1bvc1p0"); 2573 set_style(div0, "height", /*table_height*/ ctx[32] + "px"); 2574 attr(div0, "role", "grid"); 2575 attr(div0, "tabindex", "0"); 2576 toggle_class(div0, "dragging", /*dragging*/ ctx[29]); 2577 toggle_class(div0, "no-wrap", !/*wrap*/ ctx[7]); 2578 attr(div1, "class", "svelte-1bvc1p0"); 2579 toggle_class(div1, "label", /*label*/ ctx[1] && /*label*/ ctx[1].length !== 0); 2580 }, 2581 m(target, anchor) { 2582 insert$1(target, div1, anchor); 2583 if (if_block0) if_block0.m(div1, null); 2584 append(div1, t0); 2585 append(div1, div0); 2586 append(div0, table_1); 2587 if (if_block1) if_block1.m(table_1, null); 2588 append(table_1, t1); 2589 append(table_1, thead); 2590 append(thead, tr0); 2591 2592 for (let i = 0; i < each_blocks_1.length; i += 1) { 2593 if (each_blocks_1[i]) { 2594 each_blocks_1[i].m(tr0, null); 2595 } 2596 } 2597 2598 append(table_1, t2); 2599 append(table_1, tbody); 2600 append(tbody, tr1); 2601 2602 for (let i = 0; i < each_blocks.length; i += 1) { 2603 if (each_blocks[i]) { 2604 each_blocks[i].m(tr1, null); 2605 } 2606 } 2607 2608 table_1_resize_listener = resize_observer_content_box.observe(table_1, /*table_1_elementresizecontentbox_handler*/ ctx[54].bind(table_1)); 2609 /*table_1_binding*/ ctx[55](table_1); 2610 append(div0, t3);
2611 mount_component$1(upload, div0, null); 2612 /*div0_binding*/ ctx[71](div0); 2613 append(div1, t4); 2614 if (if_block2) if_block2.m(div1, null); 2615 current = true; 2616 2617 if (!mounted) { 2618 dispose = [ 2619 listen(window, "click", /*handle_click_outside*/ ctx[45]), 2620 listen(window, "touchstart", /*handle_click_outside*/ ctx[45]), 2621 listen(window, "resize", /*resize_handler*/ ctx[52]), 2622 listen(div0, "keydown", /*keydown_handler*/ ctx[72]), 2623 action_destroyer(copy.call(null, div1)) 2624 ]; 2625 2626 mounted = true; 2627 } 2628 }, 2629 p(ctx, dirty) { 2630 if (/*label*/ ctx[1] && /*label*/ ctx[1].length !== 0 && /*show_label*/ ctx[2]) { 2631 if (if_block0) { 2632 if_block0.p(ctx, dirty); 2633 } else { 2634 if_block0 = create_if_block_5(ctx); 2635 if_block0.c(); 2636 if_block0.m(div1, t0); 2637 } 2638 } else if (if_block0) { 2639 if_block0.d(1); 2640 if_block0 = null; 2641 } 2642 2643 if (/*label*/ ctx[1] && /*label*/ ctx[1].length !== 0) { 2644 if (if_block1) { 2645 if_block1.p(ctx, dirty); 2646 } else { 2647 if_block1 = create_if_block_4(ctx); 2648 if_block1.c(); 2649 if_block1.m(table_1, t1); 2650 } 2651 } else if (if_block1) { 2652 if_block1.d(1); 2653 if_block1 = null; 2654 } 2655 2656 if (dirty[0] & /*_headers, sort_by, sort_direction, header_edit, column_widths, latex_delimiters, line_breaks*/ 68818976 | dirty[1] & /*get_sort_status*/ 32) { 2657 each_value_3 = ensure_array_like(/*_headers*/ ctx[17]); 2658 group_outros(); 2659 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); 2660 check_outros(); 2661 } 2662 2663 if (dirty[0] & /*cells, latex_delimiters, line_breaks, datatype*/ 2099233 | dirty[1] & /*max*/ 16) { 2664 each_value_2 = ensure_array_like(/*max*/ ctx[35]); 2665 group_outros(); 2666 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); 2667 check_outros(); 2668 } 2669 2670 if (!current || dirty[0] & /*column_widths*/ 4096) { 2671 toggle_class(table_1, "fixed-layout", /*column_widths*/ ctx[12].length != 0); 2672 } 2673 2674 const upload_changes = {}; 2675 if (dirty[0] & /*root*/ 256) upload_changes.root = /*root*/ ctx[8]; 2676 2677 if (dirty[0] & /*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*/ 1604308067 | dirty[1] & /*selected_index, table_height, scrollbar_width*/ 14 | dirty[3] & /*$$scope*/ 4) { 2678 upload_changes.$$scope = { dirty, ctx }; 2679 } 2680 2681 if (!updating_dragging && dirty[0] & /*dragging*/ 536870912) { 2682 updating_dragging = true; 2683 upload_changes.dragging = /*dragging*/ ctx[29]; 2684 add_flush_callback(() => updating_dragging = false); 2685 } 2686 2687 upload.$set(upload_changes); 2688 2689 if (!current || dirty[1] & /*table_height*/ 2) { 2690 set_style(div0, "height", /*table_height*/ ctx[32] + "px"); 2691 } 2692 2693 if (!current || dirty[0] & /*dragging*/ 536870912) { 2694 toggle_class(div0, "dragging", /*dragging*/ ctx[29]); 2695 } 2696 2697 if (!current || dirty[0] & /*wrap*/ 128) { 2698 toggle_class(div0, "no-wrap", !/*wrap*/ ctx[7]); 2699 } 2700 2701 if (/*editable*/ ctx[6]) { 2702 if (if_block2) { 2703 if_block2.p(ctx, dirty); 2704 2705 if (dirty[0] & /*editable*/ 64) { 2706 transition_in$1(if_block2, 1); 2707 } 2708 } else { 2709 if_block2 = create_if_block(ctx); 2710 if_block2.c(); 2711 transition_in$1(if_block2, 1); 2712 if_block2.m(div1, null); 2713 } 2714 } else if (if_block2) { 2715 group_outros(); 2716 2717 transition_out$1(if_block2, 1, 1, () => { 2718 if_block2 = null; 2719 }); 2720 2721 check_outros(); 2722 } 2723 2724 if (!current || dirty[0] & /*label*/ 2) { 2725 toggle_class(div1, "label", /*label*/ ctx[1] && /*label*/ ctx[1].length !== 0); 2726 } 2727 }, 2728 i(local) { 2729 if (current) return; 2730 2731 for (let i = 0; i < each_value_3.length; i += 1) { 2732 transition_in$1(each_blocks_1[i]); 2733 } 2734 2735 for (let i = 0; i < each_value_2.length; i += 1) { 2736 transition_in$1(each_blocks[i]); 2737 } 2738 2739 transition_in$1(upload.$$.fragment, local); 2740 transition_in$1(if_block2); 2741 current = true; 2742 }, 2743 o(local) { 2744 for (let i = 0; i < each_blocks_1.length; i += 1) { 2745 transition_out$1(each_blocks_1[i]); 2746 } 2747 2748 for (let i = 0; i < each_blocks.length; i += 1) { 2749 transition_out$1(each_blocks[i]); 2750 } 2751 2752 transition_out$1(upload.$$.fragment, local); 2753 transition_out$1(if_block2); 2754 current = false;
2755 }, 2756 d(detaching) { 2757 if (detaching) { 2758 detach$1(div1); 2759 } 2760 2761 if (if_block0) if_block0.d(); 2762 if (if_block1) if_block1.d(); 2763 2764 for (let i = 0; i < each_blocks_1.length; i += 1) { 2765 each_blocks_1[i].d(); 2766 } 2767 2768 for (let i = 0; i < each_blocks.length; i += 1) { 2769 each_blocks[i].d(); 2770 } 2771 2772 table_1_resize_listener(); 2773 /*table_1_binding*/ ctx[55](null); 2774 destroy_component$1(upload); 2775 /*div0_binding*/ ctx[71](null); 2776 if (if_block2) if_block2.d(); 2777 mounted = false; 2778 run_all(dispose); 2779 } 2780 }; 2781} 2782 2783function make_id() { 2784 return Math.random().toString(36).substring(2, 15); 2785} 2786 2787function guess_delimitaor(text, possibleDelimiters) { 2788 return possibleDelimiters.filter(weedOut); 2789 2790 function weedOut(delimiter) { 2791 var cache = -1; 2792 return text.split("\n").every(checkLength); 2793 2794 function checkLength(line) { 2795 if (!line) { 2796 return true; 2797 } 2798 2799 var length = line.split(delimiter).length; 2800 2801 if (cache < 0) { 2802 cache = length; 2803 } 2804 2805 return cache === length && length > 1; 2806 } 2807 } 2808} 2809 2810function data_uri_to_blob(data_uri) { 2811 const byte_str = atob(data_uri.split(",")[1]); 2812 const mime_str = data_uri.split(",")[0].split(":")[1].split(";")[0]; 2813 const ab = new ArrayBuffer(byte_str.length); 2814 const ia = new Uint8Array(ab); 2815 2816 for (let i = 0; i < byte_str.length; i++) { 2817 ia[i] = byte_str.charCodeAt(i); 2818 } 2819 2820 return new Blob([ab], { type: mime_str }); 2821} 2822 2823function instance$1($$self, $$props, $$invalidate) { 2824 let max; 2825 let selected_index; 2826 let { datatype } = $$props; 2827 let { label = null } = $$props; 2828 let { show_label = true } = $$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 let t_rect; 2846 const dispatch = createEventDispatcher(); 2847 let editing = false; 2848 const get_data_at = (row, col) => data?.[row]?.[col]?.value; 2849 let els = {}; 2850 2851 function make_headers(_head) { 2852 let _h = _head || []; 2853 2854 if (col_count[1] === "fixed" && _h.length < col_count[0]) { 2855 const fill = Array(col_count[0] - _h.length).fill("").map((_, i) => `${i + _h.length}`); 2856 _h = _h.concat(fill); 2857 } 2858 2859 if (!_h || _h.length === 0) { 2860 return Array(col_count[0]).fill(0).map((_, i) => { 2861 const _id = make_id(); 2862 $$invalidate(24, els[_id] = { cell: null, input: null }, els); 2863 return { id: _id, value: JSON.stringify(i + 1) }; 2864 }); 2865 } 2866 2867 return _h.map((h, i) => { 2868 const _id = make_id(); 2869 $$invalidate(24, els[_id] = { cell: null, input: null }, els); 2870 return { id: _id, value: h ?? "" }; 2871 }); 2872 } 2873 2874 function process_data(_values) { 2875 const data_row_length = _values.length; 2876 2877 return Array(row_count[1] === "fixed" 2878 ? row_count[0] 2879 : data_row_length < row_count[0] 2880 ? row_count[0] 2881 : data_row_length).fill(0).map((_, i) => Array(col_count[1] === "fixed" 2882 ? col_count[0] 2883 : data_row_length > 0 ? _values[0].length : headers.length).fill(0).map((_, j) => { 2884 const id = make_id(); 2885 $$invalidate(24, els[id] = els[id] || { input: null, cell: null }, els); 2886 const obj = { value: _values?.[i]?.[j] ?? "", id }; 2887 return obj; 2888 })); 2889 } 2890 2891 let _headers = make_headers(headers); 2892 let old_headers; 2893 2894 function trigger_headers() { 2895 $$invalidate(17, _headers = make_headers(headers)); 2896 $$invalidate(50, old_headers = headers.slice()); 2897 } 2898 2899 let data = [[]]; 2900 let old_val = undefined; 2901 2902 function get_sort_status(name, _sort, direction) { 2903 if (!_sort) return "none"; 2904 2905 if (headers[_sort] === name) { 2906 if (direction === "asc") return "ascending"; 2907 if (direction === "des") return "descending"; 2908 } 2909 2910 return "none"; 2911 } 2912 2913 function get_current_indices(id) { 2914 return data.reduce( 2915 (acc, arr, i) => { 2916 const j = arr.reduce((_acc, _data, k) => id === _data.id ? k : _acc, -1); 2917 return j === -1 ? acc : [i, j]; 2918 },
2919 [-1, -1] 2920 ); 2921 } 2922 2923 async function start_edit(i, j) { 2924 if (!editable || dequal(editing, [i, j])) return; 2925 $$invalidate(23, editing = [i, j]); 2926 } 2927 2928 function move_cursor(key, current_coords) { 2929 const dir = ({ 2930 ArrowRight: [0, 1], 2931 ArrowLeft: [0, -1], 2932 ArrowDown: [1, 0], 2933 ArrowUp: [-1, 0] 2934 })[key]; 2935 2936 const i = current_coords[0] + dir[0]; 2937 const j = current_coords[1] + dir[1]; 2938 2939 if (i < 0 && j <= 0) { 2940 $$invalidate(28, selected_header = j); 2941 $$invalidate(14, selected = false); 2942 } else { 2943 const is_data = data[i]?.[j]; 2944 $$invalidate(14, selected = is_data ? [i, j] : selected); 2945 } 2946 } 2947 2948 let clear_on_focus = false; 2949 2950 // eslint-disable-next-line complexity 2951 async function handle_keydown(event) { 2952 if (selected_header !== false && header_edit === false) { 2953 switch (event.key) { 2954 case "ArrowDown": 2955 $$invalidate(14, selected = [0, selected_header]); 2956 $$invalidate(28, selected_header = false); 2957 return; 2958 case "ArrowLeft": 2959 $$invalidate(28, selected_header = selected_header > 0 2960 ? selected_header - 1 2961 : selected_header); 2962 return; 2963 case "ArrowRight": 2964 $$invalidate(28, selected_header = selected_header < _headers.length - 1 2965 ? selected_header + 1 2966 : selected_header); 2967 return; 2968 case "Escape": 2969 event.preventDefault(); 2970 $$invalidate(28, selected_header = false); 2971 break; 2972 case "Enter": 2973 event.preventDefault(); 2974 break; 2975 } 2976 } 2977 2978 if (!selected) { 2979 return; 2980 } 2981 2982 const [i, j] = selected; 2983 2984 switch (event.key) { 2985 case "ArrowRight": 2986 case "ArrowLeft": 2987 case "ArrowDown": 2988 case "ArrowUp": 2989 if (editing) break; 2990 event.preventDefault(); 2991 move_cursor(event.key, [i, j]); 2992 break; 2993 case "Escape": 2994 if (!editable) break; 2995 event.preventDefault(); 2996 $$invalidate(23, editing = false); 2997 break; 2998 case "Enter": 2999 if (!editable) break; 3000 event.preventDefault(); 3001 if (event.shiftKey) { 3002 add_row(i); 3003 await tick(); 3004 $$invalidate(14, selected = [i + 1, j]); 3005 } else { 3006 if (dequal(editing, [i, j])) { 3007 $$invalidate(23, editing = false); 3008 await tick(); 3009 $$invalidate(14, selected = [i, j]); 3010 } else { 3011 $$invalidate(23, editing = [i, j]); 3012 } 3013 } 3014 break; 3015 case "Backspace": 3016 if (!editable) break; 3017 if (!editing) { 3018 event.preventDefault(); 3019 $$invalidate(18, data[i][j].value = "", data); 3020 } 3021 break; 3022 case "Delete": 3023 if (!editable) break; 3024 if (!editing) { 3025 event.preventDefault(); 3026 $$invalidate(18, data[i][j].value = "", data); 3027 } 3028 break; 3029 case "Tab": 3030 let direction = event.shiftKey ? -1 : 1; 3031 let is_data_x = data[i][j + direction]; 3032 let is_data_y = data?.[i + direction]?.[direction > 0 ? 0 : _headers.length - 1]; 3033 if (is_data_x || is_data_y) { 3034 event.preventDefault(); 3035 3036 $$invalidate(14, selected = is_data_x 3037 ? [i, j + direction] 3038 : [i + direction, direction > 0 ? 0 : _headers.length - 1]); 3039 } 3040 $$invalidate(23, editing = false); 3041 break; 3042 default: 3043 if (!editable) break; 3044 if ((!editing || editing && dequal(editing, [i, j])) && event.key.length === 1) { 3045 $$invalidate(25, clear_on_focus = true); 3046 $$invalidate(23, editing = [i, j]); 3047 } 3048 } 3049 } 3050 3051 async function handle_cell_click(i, j) { 3052 if (dequal(editing, [i, j])) return; 3053 $$invalidate(26, header_edit = false); 3054 $$invalidate(28, selected_header = false); 3055 $$invalidate(23, editing = false); 3056 $$invalidate(14, selected = [i, j]); 3057 await tick(); 3058 parent.focus(); 3059 } 3060 3061 let sort_direction; 3062 let sort_by; 3063 3064 function handle_sort(col) { 3065 if (typeof sort_by !== "number" || sort_by !== col) { 3066 $$invalidate(19, sort_direction = "asc"); 3067 $$invalidate(20, sort_by = col); 3068 } else { 3069 if (sort_direction === "asc") { 3070 $$invalidate(19, sort_direction = "des"); 3071 } else if (sort_direction === "des") { 3072 $$invalidate(19, sort_direction = "asc"); 3073 } 3074 } 3075 } 3076 3077 let header_edit; 3078 let select_on_focus = false; 3079 let selected_header = false;
3080 3081 async function edit_header(i, _select = false) { 3082 if (!editable || col_count[1] !== "dynamic" || header_edit === i) return; 3083 $$invalidate(14, selected = false); 3084 $$invalidate(28, selected_header = i); 3085 $$invalidate(26, header_edit = i); 3086 $$invalidate(27, select_on_focus = _select); 3087 } 3088 3089 function end_header_edit(event) { 3090 if (!editable) return; 3091 3092 switch (event.key) { 3093 case "Escape": 3094 case "Enter": 3095 case "Tab": 3096 event.preventDefault(); 3097 $$invalidate(14, selected = false); 3098 $$invalidate(28, selected_header = header_edit); 3099 $$invalidate(26, header_edit = false); 3100 parent.focus(); 3101 break; 3102 } 3103 } 3104 3105 async function add_row(index) { 3106 parent.focus(); 3107 if (row_count[1] !== "dynamic") return; 3108 3109 if (data.length === 0) { 3110 $$invalidate(49, values = [Array(headers.length).fill("")]); 3111 return; 3112 } 3113 3114 data.splice(index ? index + 1 : data.length, 0, Array(data[0].length).fill(0).map((_, i) => { 3115 const _id = make_id(); 3116 $$invalidate(24, els[_id] = { cell: null, input: null }, els); 3117 return { id: _id, value: "" }; 3118 })); 3119 3120 ((($$invalidate(18, data), $$invalidate(49, values)), $$invalidate(51, old_val)), $$invalidate(13, value)); 3121 $$invalidate(14, selected = [index ? index + 1 : data.length - 1, 0]); 3122 } 3123 3124 async function add_col() { 3125 parent.focus(); 3126 if (col_count[1] !== "dynamic") return; 3127 3128 for (let i = 0; i < data.length; i++) { 3129 const _id = make_id(); 3130 $$invalidate(24, els[_id] = { cell: null, input: null }, els); 3131 data[i].push({ id: _id, value: "" }); 3132 } 3133 3134 headers.push(`Header ${headers.length + 1}`); 3135 ((($$invalidate(18, data), $$invalidate(49, values)), $$invalidate(51, old_val)), $$invalidate(13, value)); 3136 (($$invalidate(48, headers), $$invalidate(13, value)), $$invalidate(49, values)); 3137 await tick(); 3138 3139 requestAnimationFrame(() => { 3140 edit_header(headers.length - 1, true); 3141 const new_w = parent.querySelectorAll("tbody")[1].offsetWidth; 3142 parent.querySelectorAll("table")[1].scrollTo({ left: new_w }); 3143 }); 3144 } 3145 3146 function handle_click_outside(event) { 3147 event.stopImmediatePropagation(); 3148 const [trigger] = event.composedPath(); 3149 3150 if (parent.contains(trigger)) { 3151 return; 3152 } 3153 3154 $$invalidate(23, editing = false); 3155 $$invalidate(26, header_edit = false); 3156 $$invalidate(28, selected_header = false); 3157 $$invalidate(14, selected = false); 3158 } 3159 3160 function blob_to_string(blob) { 3161 const reader = new FileReader(); 3162 3163 function handle_read(e) { 3164 if (!e?.target?.result || typeof e.target.result !== "string") return; 3165 const [delimiter] = guess_delimitaor(e.target.result, [",", "\t"]); 3166 const [head, ...rest] = dsvFormat(delimiter).parseRows(e.target.result); 3167 3168 $$invalidate(17, _headers = make_headers(col_count[1] === "fixed" 3169 ? head.slice(0, col_count[0]) 3170 : head)); 3171 3172 $$invalidate(49, values = rest); 3173 reader.removeEventListener("loadend", handle_read); 3174 } 3175 3176 reader.addEventListener("loadend", handle_read); 3177 reader.readAsText(blob); 3178 } 3179 3180 let dragging = false; 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(18, data), $$invalidate(49, values)), $$invalidate(51, old_val)), $$invalidate(13, value)); 3250 3251 if (id) { 3252 const [i, j] = get_current_indices(id); 3253 $$invalidate(14, 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(18, data), $$invalidate(49, values)), $$invalidate(51, old_val)), $$invalidate(13, 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(21, cells); 3284 }); 3285 } 3286 3287 function table_1_elementresizecontentbox_handler() { 3288 t_rect = ResizeObserverSingleton.entries.get(this)?.contentRect; 3289 $$invalidate(22, t_rect); 3290 } 3291 3292 function table_1_binding($$value) { 3293 binding_callbacks[$$value ? 'unshift' : 'push'](() => { 3294 table = $$value; 3295 $$invalidate(31, 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(18, data), $$invalidate(49, values)), $$invalidate(51, old_val)), $$invalidate(13, 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(24, els); 3310 } 3311 } 3312 3313 const blur_handler = () => ($$invalidate(25, 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(17, _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(24, 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(18, data), $$invalidate(49, values)), $$invalidate(51, old_val)), $$invalidate(13, value)); 3338 } 3339 3340 function virtualtable_actual_height_binding(value) { 3341 table_height = value; 3342 $$invalidate(32, table_height); 3343 } 3344 3345 function virtualtable_table_scrollbar_width_binding(value) { 3346 scrollbar_width = value; 3347 $$invalidate(33, scrollbar_width); 3348 } 3349 3350 function upload_dragging_binding(value) { 3351 dragging = value; 3352 $$invalidate(29, 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(30, 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 ('show_label' in $$props) $$invalidate(2, show_label = $$props.show_label); 3372 if ('headers' in $$props) $$invalidate(48, headers = $$props.headers); 3373 if ('value' in $$props) $$invalidate(13, value = $$props.value); 3374 if ('col_count' in $$props) $$invalidate(3, col_count = $$props.col_count); 3375 if ('row_count' in $$props) $$invalidate(4, row_count = $$props.row_count); 3376 if ('latex_delimiters' in $$props) $$invalidate(5, latex_delimiters = $$props.latex_delimiters); 3377 if ('editable' in $$props) $$invalidate(6, editable = $$props.editable); 3378 if ('wrap' in $$props) $$invalidate(7, wrap = $$props.wrap); 3379 if ('root' in $$props) $$invalidate(8, root = $$props.root); 3380 if ('i18n' in $$props) $$invalidate(9, i18n = $$props.i18n); 3381 if ('height' in $$props) $$invalidate(10, height = $$props.height); 3382 if ('line_breaks' in $$props) $$invalidate(11, line_breaks = $$props.line_breaks);
3383 if ('column_widths' in $$props) $$invalidate(12, column_widths = $$props.column_widths); 3384 }; 3385 3386 $$self.$$.update = () => { 3387 if ($$self.$$.dirty[0] & /*value*/ 8192 | $$self.$$.dirty[1] & /*values*/ 262144) { 3388 { 3389 if (value) { 3390 $$invalidate(48, headers = value.headers); 3391 $$invalidate(49, values = value.data); 3392 $$invalidate(15, display_value = value?.metadata?.display_value ?? null); 3393 $$invalidate(16, styling = value?.metadata?.styling ?? null); 3394 } else if (values === null) { 3395 $$invalidate(49, values = []); 3396 } 3397 } 3398 } 3399 3400 if ($$self.$$.dirty[0] & /*selected*/ 16384) { 3401 { 3402 if (selected !== false) { 3403 const [row, col] = selected; 3404 3405 if (!isNaN(row) && !isNaN(col)) { 3406 dispatch("select", { 3407 index: [row, col], 3408 value: get_data_at(row, col) 3409 }); 3410 } 3411 } 3412 } 3413 } 3414 3415 if ($$self.$$.dirty[1] & /*headers, old_headers*/ 655360) { 3416 { 3417 if (!dequal(headers, old_headers)) { 3418 trigger_headers(); 3419 } 3420 } 3421 } 3422 3423 if ($$self.$$.dirty[1] & /*values, old_val*/ 1310720) { 3424 if (!dequal(values, old_val)) { 3425 $$invalidate(18, data = process_data(values)); 3426 $$invalidate(51, old_val = values); 3427 } 3428 } 3429 3430 if ($$self.$$.dirty[0] & /*_headers, data, editable, display_value, styling*/ 491584) { 3431 _headers && dispatch("change", { 3432 data: data.map(r => r.map(({ value }) => value)), 3433 headers: _headers.map(h => h.value), 3434 metadata: editable ? null : { display_value, styling } 3435 }); 3436 } 3437 3438 if ($$self.$$.dirty[0] & /*data*/ 262144) { 3439 $$invalidate(35, max = get_max(data)); 3440 } 3441 3442 if ($$self.$$.dirty[0] & /*cells*/ 2097152) { 3443 cells[0] && set_cell_widths(); 3444 } 3445 3446 if ($$self.$$.dirty[0] & /*data, display_value, styling, sort_by, sort_direction*/ 1933312) { 3447 sort_data(data, display_value, styling, sort_by, sort_direction); 3448 } 3449 3450 if ($$self.$$.dirty[0] & /*selected*/ 16384) { 3451 $$invalidate(34, selected_index = !!selected && selected[0]); 3452 } 3453 }; 3454 3455 return [ 3456 datatype, 3457 label, 3458 show_label, 3459 col_count, 3460 row_count, 3461 latex_delimiters, 3462 editable, 3463 wrap, 3464 root, 3465 i18n, 3466 height, 3467 line_breaks, 3468 column_widths, 3469 value, 3470 selected, 3471 display_value, 3472 styling, 3473 _headers, 3474 data, 3475 sort_direction, 3476 sort_by, 3477 cells, 3478 t_rect, 3479 editing, 3480 els, 3481 clear_on_focus, 3482 header_edit, 3483 select_on_focus, 3484 selected_header, 3485 dragging, 3486 parent, 3487 table, 3488 table_height, 3489 scrollbar_width, 3490 selected_index, 3491 max, 3492 get_sort_status, 3493 start_edit, 3494 handle_keydown, 3495 handle_cell_click, 3496 handle_sort, 3497 edit_header, 3498 end_header_edit, 3499 add_row, 3500 add_col, 3501 handle_click_outside, 3502 blob_to_string, 3503 set_cell_widths, 3504 headers, 3505 values, 3506 old_headers, 3507 old_val, 3508 resize_handler, 3509 td_binding, 3510 table_1_elementresizecontentbox_handler, 3511 table_1_binding, 3512 editablecell_value_binding, 3513 editablecell_el_binding, 3514 blur_handler, 3515 touchstart_handler, 3516 click_handler, 3517 dblclick_handler, 3518 editablecell_value_binding_1, 3519 editablecell_el_binding_1, 3520 dblclick_handler_1, 3521 click_handler_1, 3522 virtualtable_items_binding, 3523 virtualtable_actual_height_binding, 3524 virtualtable_table_scrollbar_width_binding, 3525 upload_dragging_binding, 3526 load_handler, 3527 div0_binding, 3528 keydown_handler, 3529 click_handler_2, 3530 click_handler_3 3531 ]; 3532} 3533 3534class Table extends SvelteComponent$1 { 3535 constructor(options) { 3536 super(); 3537 3538 init$1( 3539 this, 3540 options, 3541 instance$1, 3542 create_fragment$1, 3543 safe_not_equal$1, 3544 { 3545 datatype: 0, 3546 label: 1, 3547 show_label: 2, 3548 headers: 48, 3549 value: 13, 3550 col_count: 3, 3551 row_count: 4, 3552 latex_delimiters: 5, 3553 editable: 6, 3554 wrap: 7, 3555 root: 8, 3556 i18n: 9, 3557 height: 10, 3558 line_breaks: 11, 3559 column_widths: 12 3560 }, 3561 null, 3562 [-1, -1, -1, -1] 3563 ); 3564 } 3565} 3566 3567const Table$1 = Table; 3568 3569/* home/runner/work/gradio/gradio/js/dataframe/Index.svelte generated by Svelte v4.2.2 */ 3570const { 3571 SvelteComponent, 3572 assign, 3573 create_component, 3574 destroy_component, 3575 detach, 3576 get_spread_object, 3577 get_spread_update, 3578 init, 3579 insert, 3580 is_function, 3581 mount_component, 3582 safe_not_equal, 3583 space, 3584 transition_in, 3585 transition_out 3586} = window.__gradio__svelte__internal; 3587const { afterUpdate } = window.__gradio__svelte__internal; 3588function create_default_slot(ctx) { 3589 let statustracker; 3590 let t; 3591 let table; 3592 let current; 3593 3594 const statustracker_spread_levels = [ 3595 { 3596 autoscroll: /*gradio*/ ctx[16].autoscroll 3597 }, 3598 { i18n: /*gradio*/ ctx[16].i18n }, 3599 /*loading_status*/ ctx[19] 3600 ]; 3601 3602 let statustracker_props = {}; 3603 3604 for (let i = 0; i < statustracker_spread_levels.length; i += 1) { 3605 statustracker_props = assign(statustracker_props, statustracker_spread_levels[i]); 3606 } 3607 3608 statustracker = new Static({ props: statustracker_props }); 3609 3610 table = new Table$1({ 3611 props: { 3612 root: /*root*/ ctx[13], 3613 label: /*label*/ ctx[7], 3614 show_label: /*show_label*/ ctx[8], 3615 row_count: /*row_count*/ ctx[6], 3616 col_count: /*col_count*/ ctx[5], 3617 value: /*value*/ ctx[0], 3618 headers: /*headers*/ ctx[1], 3619 wrap: /*wrap*/ ctx[9], 3620 datatype: /*datatype*/ ctx[10], 3621 latex_delimiters: /*latex_delimiters*/ ctx[17], 3622 editable: /*interactive*/ ctx[20], 3623 height: /*height*/ ctx[18], 3624 i18n: /*gradio*/ ctx[16].i18n, 3625 line_breaks: /*line_breaks*/ ctx[14], 3626 column_widths: /*column_widths*/ ctx[15] 3627 } 3628 }); 3629 3630 table.$on("change", function () { 3631 if (is_function(/*interactive*/ ctx[20] 3632 ? /*change_handler*/ ctx[23] 3633 : change_handler_1)) (/*interactive*/ ctx[20] 3634 ? /*change_handler*/ ctx[23] 3635 : change_handler_1).apply(this, arguments); 3636 }); 3637 3638 table.$on("select", /*select_handler*/ ctx[24]); 3639 3640 return { 3641 c() { 3642 create_component(statustracker.$$.fragment); 3643 t = space(); 3644 create_component(table.$$.fragment); 3645 }, 3646 m(target, anchor) { 3647 mount_component(statustracker, target, anchor); 3648 insert(target, t, anchor);
3649 mount_component(table, target, anchor); 3650 current = true; 3651 }, 3652 p(new_ctx, dirty) { 3653 ctx = new_ctx; 3654 3655 const statustracker_changes = (dirty & /*gradio, loading_status*/ 589824) 3656 ? get_spread_update(statustracker_spread_levels, [ 3657 dirty & /*gradio*/ 65536 && { 3658 autoscroll: /*gradio*/ ctx[16].autoscroll 3659 }, 3660 dirty & /*gradio*/ 65536 && { i18n: /*gradio*/ ctx[16].i18n }, 3661 dirty & /*loading_status*/ 524288 && get_spread_object(/*loading_status*/ ctx[19]) 3662 ]) 3663 : {}; 3664 3665 statustracker.$set(statustracker_changes); 3666 const table_changes = {}; 3667 if (dirty & /*root*/ 8192) table_changes.root = /*root*/ ctx[13]; 3668 if (dirty & /*label*/ 128) table_changes.label = /*label*/ ctx[7]; 3669 if (dirty & /*show_label*/ 256) table_changes.show_label = /*show_label*/ ctx[8]; 3670 if (dirty & /*row_count*/ 64) table_changes.row_count = /*row_count*/ ctx[6]; 3671 if (dirty & /*col_count*/ 32) table_changes.col_count = /*col_count*/ ctx[5]; 3672 if (dirty & /*value*/ 1) table_changes.value = /*value*/ ctx[0]; 3673 if (dirty & /*headers*/ 2) table_changes.headers = /*headers*/ ctx[1]; 3674 if (dirty & /*wrap*/ 512) table_changes.wrap = /*wrap*/ ctx[9]; 3675 if (dirty & /*datatype*/ 1024) table_changes.datatype = /*datatype*/ ctx[10]; 3676 if (dirty & /*latex_delimiters*/ 131072) table_changes.latex_delimiters = /*latex_delimiters*/ ctx[17]; 3677 if (dirty & /*interactive*/ 1048576) table_changes.editable = /*interactive*/ ctx[20]; 3678 if (dirty & /*height*/ 262144) table_changes.height = /*height*/ ctx[18]; 3679 if (dirty & /*gradio*/ 65536) table_changes.i18n = /*gradio*/ ctx[16].i18n; 3680 if (dirty & /*line_breaks*/ 16384) table_changes.line_breaks = /*line_breaks*/ ctx[14]; 3681 if (dirty & /*column_widths*/ 32768) table_changes.column_widths = /*column_widths*/ ctx[15]; 3682 table.$set(table_changes); 3683 }, 3684 i(local) { 3685 if (current) return; 3686 transition_in(statustracker.$$.fragment, local); 3687 transition_in(table.$$.fragment, local); 3688 current = true; 3689 }, 3690 o(local) { 3691 transition_out(statustracker.$$.fragment, local); 3692 transition_out(table.$$.fragment, local); 3693 current = false; 3694 }, 3695 d(detaching) { 3696 if (detaching) { 3697 detach(t); 3698 } 3699 3700 destroy_component(statustracker, detaching); 3701 destroy_component(table, detaching); 3702 } 3703 }; 3704} 3705 3706function create_fragment(ctx) { 3707 let block; 3708 let current; 3709 3710 block = new Block({ 3711 props: { 3712 visible: /*visible*/ ctx[4], 3713 padding: false, 3714 elem_id: /*elem_id*/ ctx[2], 3715 elem_classes: /*elem_classes*/ ctx[3], 3716 container: false, 3717 scale: /*scale*/ ctx[11], 3718 min_width: /*min_width*/ ctx[12], 3719 allow_overflow: false, 3720 $$slots: { default: [create_default_slot] }, 3721 $$scope: { ctx } 3722 } 3723 }); 3724 3725 return { 3726 c() { 3727 create_component(block.$$.fragment); 3728 }, 3729 m(target, anchor) { 3730 mount_component(block, target, anchor); 3731 current = true; 3732 }, 3733 p(ctx, [dirty]) { 3734 const block_changes = {}; 3735 if (dirty & /*visible*/ 16) block_changes.visible = /*visible*/ ctx[4]; 3736 if (dirty & /*elem_id*/ 4) block_changes.elem_id = /*elem_id*/ ctx[2]; 3737 if (dirty & /*elem_classes*/ 8) block_changes.elem_classes = /*elem_classes*/ ctx[3]; 3738 if (dirty & /*scale*/ 2048) block_changes.scale = /*scale*/ ctx[11]; 3739 if (dirty & /*min_width*/ 4096) block_changes.min_width = /*min_width*/ ctx[12]; 3740 3741 if (dirty & /*$$scope, root, label, show_label, row_count, col_count, value, headers, wrap, datatype, latex_delimiters, interactive, height, gradio, line_breaks, column_widths, loading_status*/ 69199843) { 3742 block_changes.$$scope = { dirty, ctx }; 3743 } 3744 3745 block.$set(block_changes); 3746 }, 3747 i(local) { 3748 if (current) return; 3749 transition_in(block.$$.fragment, local); 3750 current = true; 3751 }, 3752 o(local) { 3753 transition_out(block.$$.fragment, local); 3754 current = false; 3755 }, 3756 d(detaching) { 3757 destroy_component(block, detaching); 3758 } 3759 }; 3760} 3761 3762const change_handler_1 = () => { 3763 3764}; 3765 3766function instance($$self, $$props, $$invalidate) { 3767 let { headers = [] } = $$props; 3768 let { elem_id = "" } = $$props; 3769 let { elem_classes = [] } = $$props; 3770 let { visible = true } = $$props; 3771 3772 let { value = { 3773 data: [["", "", ""]], 3774 headers: ["1", "2", "3"], 3775 metadata: null 3776 } } = $$props; 3777 3778 let old_value = JSON.stringify(value); 3779 let { value_is_output = false } = $$props; 3780 let { col_count } = $$props; 3781 let { row_count } = $$props; 3782 let { label = null } = $$props; 3783 let { show_label = true } = $$props; 3784 let { wrap } = $$props; 3785 let { datatype } = $$props; 3786 let { scale = null } = $$props; 3787 let { min_width = undefined } = $$props; 3788 let { root } = $$props; 3789 let { line_breaks = true } = $$props; 3790 let { column_widths = [] } = $$props; 3791 let { gradio } = $$props; 3792 let { latex_delimiters } = $$props; 3793 let { height = undefined } = $$props; 3794 let { loading_status } = $$props; 3795 let { interactive } = $$props; 3796 3797 function handle_change() { 3798 gradio.dispatch("change"); 3799 3800 if (!value_is_output) { 3801 gradio.dispatch("input"); 3802 } 3803 } 3804 3805 afterUpdate(() => {
3806 $$invalidate(21, value_is_output = false); 3807 }); 3808 3809 if (Array.isArray(value) && value?.[0]?.length === 0 || value.data?.[0]?.length === 0) { 3810 value = { 3811 data: [Array(col_count?.[0] || 3).fill("")], 3812 headers: Array(col_count?.[0] || 3).fill("").map((_, i) => `${i + 1}`), 3813 metadata: null 3814 }; 3815 } 3816 3817 const change_handler = e => $$invalidate(0, value = e.detail); 3818 const select_handler = e => gradio.dispatch("select", e.detail); 3819 3820 $$self.$$set = $$props => { 3821 if ('headers' in $$props) $$invalidate(1, headers = $$props.headers); 3822 if ('elem_id' in $$props) $$invalidate(2, elem_id = $$props.elem_id); 3823 if ('elem_classes' in $$props) $$invalidate(3, elem_classes = $$props.elem_classes); 3824 if ('visible' in $$props) $$invalidate(4, visible = $$props.visible); 3825 if ('value' in $$props) $$invalidate(0, value = $$props.value); 3826 if ('value_is_output' in $$props) $$invalidate(21, value_is_output = $$props.value_is_output); 3827 if ('col_count' in $$props) $$invalidate(5, col_count = $$props.col_count); 3828 if ('row_count' in $$props) $$invali
3828date(6, row_count = $$props.row_count); 3829 if ('label' in $$props) $$invalidate(7, label = $$props.label); 3830 if ('show_label' in $$props) $$invalidate(8, show_label = $$props.show_label); 3831 if ('wrap' in $$props) $$invalidate(9, wrap = $$props.wrap); 3832 if ('datatype' in $$props) $$invalidate(10, datatype = $$props.datatype); 3833 if ('scale' in $$props) $$invalidate(11, scale = $$props.scale); 3834 if ('min_width' in $$props) $$invalidate(12, min_width = $$props.min_width); 3835 if ('root' in $$props) $$invalidate(13, root = $$props.root); 3836 if ('line_breaks' in $$props) $$invalidate(14, line_breaks = $$props.line_breaks); 3837 if ('column_widths' in $$props) $$invalidate(15, column_widths = $$props.column_widths); 3838 if ('gradio' in $$props) $$invalidate(16, gradio = $$props.gradio); 3839 if ('latex_delimiters' in $$props) $$invalidate(17, latex_delimiters = $$props.latex_delimiters); 3840 if ('height' in $$props) $$invalidate(18, height = $$props.height); 3841 if ('loading_status' in $$props) $$invalidate(19, loading_status = $$props.loading_status);
3842 if ('interactive' in $$props) $$invalidate(20, interactive = $$props.interactive); 3843 }; 3844 3845 $$self.$$.update = () => { 3846 if ($$self.$$.dirty & /*value, old_value*/ 4194305) { 3847 { 3848 if (JSON.stringify(value) !== old_value) { 3849 $$invalidate(22, old_value = JSON.stringify(value)); 3850 handle_change(); 3851 } 3852 } 3853 } 3854 }; 3855 3856 return [ 3857 value, 3858 headers, 3859 elem_id, 3860 elem_classes, 3861 visible, 3862 col_count, 3863 row_count, 3864 label, 3865 show_label, 3866 wrap, 3867 datatype, 3868 scale, 3869 min_width, 3870 root, 3871 line_breaks, 3872 column_widths, 3873 gradio, 3874 latex_delimiters, 3875 height, 3876 loading_status, 3877 interactive, 3878 value_is_output, 3879 old_value, 3880 change_handler, 3881 select_handler 3882 ]; 3883} 3884 3885class Index extends SvelteComponent { 3886 constructor(options) { 3887 super(); 3888 3889 init(this, options, instance, create_fragment, safe_not_equal, { 3890 headers: 1, 3891 elem_id: 2, 3892 elem_classes: 3, 3893 visible: 4, 3894 value: 0, 3895 value_is_output: 21, 3896 col_count: 5, 3897 row_count: 6, 3898 label: 7, 3899 show_label: 8, 3900 wrap: 9, 3901 datatype: 10, 3902 scale: 11, 3903 min_width: 12, 3904 root: 13, 3905 line_breaks: 14, 3906 column_widths: 15, 3907 gradio: 16, 3908 latex_delimiters: 17, 3909 height: 18, 3910 loading_status: 19, 3911 interactive: 20 3912 }); 3913 } 3914} 3915 3916export { Table$1 as BaseDataFrame, Index as default }; 3917//# sourceMappingURL=Index-540d264f.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.