gradio-pr-bot commited on
Commit
35b7763
·
verified ·
1 Parent(s): 39482cf

Upload folder using huggingface_hub

Browse files
Files changed (36) hide show
  1. 6.11.1/dataframe/Example.svelte +118 -0
  2. 6.11.1/dataframe/Index.svelte +129 -0
  3. 6.11.1/dataframe/package.json +52 -0
  4. 6.11.1/dataframe/shared/BooleanCell.svelte +55 -0
  5. 6.11.1/dataframe/shared/CellMenu.svelte +278 -0
  6. 6.11.1/dataframe/shared/CellMenuButton.svelte +46 -0
  7. 6.11.1/dataframe/shared/CellMenuIcons.svelte +240 -0
  8. 6.11.1/dataframe/shared/DataCell.svelte +189 -0
  9. 6.11.1/dataframe/shared/EditableCell.svelte +285 -0
  10. 6.11.1/dataframe/shared/EmptyRowButton.svelte +29 -0
  11. 6.11.1/dataframe/shared/Example.svelte +29 -0
  12. 6.11.1/dataframe/shared/FilterMenu.svelte +255 -0
  13. 6.11.1/dataframe/shared/HeaderCell.svelte +218 -0
  14. 6.11.1/dataframe/shared/RowNumber.svelte +34 -0
  15. 6.11.1/dataframe/shared/Table.svelte +1364 -0
  16. 6.11.1/dataframe/shared/Toolbar.svelte +208 -0
  17. 6.11.1/dataframe/shared/column_measurement.svelte.ts +103 -0
  18. 6.11.1/dataframe/shared/icons/FilterIcon.svelte +20 -0
  19. 6.11.1/dataframe/shared/icons/Padlock.svelte +28 -0
  20. 6.11.1/dataframe/shared/icons/SelectionButtons.svelte +108 -0
  21. 6.11.1/dataframe/shared/icons/SortButtonDown.svelte +25 -0
  22. 6.11.1/dataframe/shared/icons/SortButtonUp.svelte +25 -0
  23. 6.11.1/dataframe/shared/icons/SortIcon.svelte +78 -0
  24. 6.11.1/dataframe/shared/tanstack/index.ts +23 -0
  25. 6.11.1/dataframe/shared/tanstack/table.svelte.ts +117 -0
  26. 6.11.1/dataframe/shared/tanstack/virtual.svelte.ts +105 -0
  27. 6.11.1/dataframe/shared/types.ts +34 -0
  28. 6.11.1/dataframe/shared/utils/filter.ts +66 -0
  29. 6.11.1/dataframe/shared/utils/selection_utils.ts +234 -0
  30. 6.11.1/dataframe/shared/utils/table_utils.ts +95 -0
  31. 6.11.1/dataframe/shared/utils/utils.ts +58 -0
  32. 6.11.1/dataframe/standalone/Index.svelte +741 -0
  33. 6.11.1/dataframe/standalone/default_i18n.ts +32 -0
  34. 6.11.1/dataframe/standalone/stubs/Upload.svelte +19 -0
  35. 6.11.1/dataframe/standalone/stubs/upload.ts +1 -0
  36. 6.11.1/dataframe/types.ts +34 -0
6.11.1/dataframe/Example.svelte ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ export let value: (string | number)[][] | string;
3
+ export let type: "gallery" | "table";
4
+ export let selected = false;
5
+ export let index: number;
6
+
7
+ let hovered = false;
8
+ let loaded = Array.isArray(value);
9
+ let is_empty = loaded && (value.length === 0 || value[0].length === 0);
10
+ </script>
11
+
12
+ {#if loaded}
13
+ <!-- TODO: fix-->
14
+ <!-- svelte-ignore a11y-no-static-element-interactions-->
15
+ <div
16
+ class:table={type === "table"}
17
+ class:gallery={type === "gallery"}
18
+ class:selected
19
+ on:mouseenter={() => (hovered = true)}
20
+ on:mouseleave={() => (hovered = false)}
21
+ >
22
+ {#if typeof value === "string"}
23
+ {value}
24
+ {:else if is_empty}
25
+ <table class="">
26
+ <tbody>
27
+ <tr>
28
+ <td>Empty</td>
29
+ </tr>
30
+ </tbody>
31
+ </table>
32
+ {:else}
33
+ <table class="">
34
+ <tbody>
35
+ {#each value.slice(0, 3) as row, i}
36
+ <tr>
37
+ {#each row.slice(0, 3) as cell, j}
38
+ <td>{cell}</td>
39
+ {/each}
40
+ {#if row.length > 3}
41
+ <td>…</td>
42
+ {/if}
43
+ </tr>
44
+ {/each}
45
+ </tbody>
46
+ </table>
47
+ {#if value.length > 3}
48
+ <div
49
+ class="overlay"
50
+ class:odd={index % 2 != 0}
51
+ class:even={index % 2 == 0}
52
+ class:button={type === "gallery"}
53
+ ></div>
54
+ {/if}
55
+ {/if}
56
+ </div>
57
+ {/if}
58
+
59
+ <style>
60
+ table {
61
+ position: relative;
62
+ border-collapse: collapse;
63
+ }
64
+
65
+ td {
66
+ border: 1px solid var(--table-border-color);
67
+ padding: var(--size-2);
68
+ font-size: var(--text-sm);
69
+ font-family: var(--font-mono);
70
+ }
71
+
72
+ .selected td {
73
+ border-color: var(--border-color-accent);
74
+ }
75
+
76
+ .table {
77
+ display: inline-block;
78
+ margin: 0 auto;
79
+ }
80
+
81
+ .gallery td:first-child {
82
+ border-left: none;
83
+ }
84
+
85
+ .gallery tr:first-child td {
86
+ border-top: none;
87
+ }
88
+
89
+ .gallery td:last-child {
90
+ border-right: none;
91
+ }
92
+
93
+ .gallery tr:last-child td {
94
+ border-bottom: none;
95
+ }
96
+
97
+ .overlay {
98
+ --gradient-to: transparent;
99
+ position: absolute;
100
+ bottom: 0;
101
+ background: linear-gradient(to bottom, transparent, var(--gradient-to));
102
+ width: var(--size-full);
103
+ height: 50%;
104
+ }
105
+
106
+ /* i dont know what i've done here but it is what it is */
107
+ .odd {
108
+ --gradient-to: var(--table-even-background-fill);
109
+ }
110
+
111
+ .even {
112
+ --gradient-to: var(--table-odd-background-fill);
113
+ }
114
+
115
+ .button {
116
+ --gradient-to: var(--background-fill-primary);
117
+ }
118
+ </style>
6.11.1/dataframe/Index.svelte ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script module lang="ts">
2
+ export { default as BaseDataFrame } from "./shared/Table.svelte";
3
+ export { default as BaseExample } from "./Example.svelte";
4
+ </script>
5
+
6
+ <script lang="ts">
7
+ import { tick } from "svelte";
8
+ import Table from "./shared/Table.svelte";
9
+ import StatusTracker from "@gradio/statustracker";
10
+ import { Block } from "@gradio/atoms";
11
+ import { Gradio } from "@gradio/utils";
12
+ import type { DataframeProps, DataframeEvents } from "./types";
13
+ import { dequal } from "dequal";
14
+
15
+ let _props = $props();
16
+ const gradio = new Gradio<DataframeEvents, DataframeProps>(_props);
17
+
18
+ let fullscreen = $state(gradio.props.fullscreen ?? false);
19
+
20
+ // align datatype array to current value headers using the original
21
+ // config-time header→datatype mapping.
22
+ // when columns are hidden or reordered, positional indices shift but
23
+ // the datatype prop doesn't update, the map keeps them synced
24
+ let aligned_datatype = $derived.by(() => {
25
+ const dt = gradio.props.datatype;
26
+ if (!Array.isArray(dt)) return dt;
27
+
28
+ const config_headers: string[] | undefined = (gradio.props as any).headers;
29
+ const current_headers = gradio.props.value?.headers;
30
+ if (!config_headers || !current_headers) return dt;
31
+
32
+ const map = new Map<string, string>();
33
+ for (let i = 0; i < Math.min(config_headers.length, dt.length); i++) {
34
+ map.set(config_headers[i], dt[i]);
35
+ }
36
+ return current_headers.map(
37
+ (h: string, i: number) => map.get(h) ?? dt[i] ?? "str"
38
+ );
39
+ });
40
+
41
+ let old_value = $state(
42
+ gradio.props.value ? JSON.stringify(gradio.props.value) : null
43
+ );
44
+
45
+ function handle_change(detail: any): void {
46
+ gradio.props.value = detail;
47
+ const serialized = JSON.stringify(detail);
48
+ if (serialized !== old_value) {
49
+ old_value = serialized;
50
+ gradio.dispatch("change", detail);
51
+ }
52
+ }
53
+
54
+ function handle_input(): void {
55
+ gradio.dispatch("input");
56
+ }
57
+
58
+ function handle_select(detail: any): void {
59
+ gradio.dispatch("select", detail);
60
+ }
61
+
62
+ function handle_edit(detail: any): void {
63
+ gradio.dispatch("edit", detail);
64
+ }
65
+
66
+ $effect(() => {
67
+ const v = gradio.props.value;
68
+ if (v) {
69
+ const serialized = JSON.stringify(v);
70
+ if (serialized !== old_value) {
71
+ old_value = serialized;
72
+ gradio.dispatch("change", v);
73
+ }
74
+ }
75
+ });
76
+ </script>
77
+
78
+ <Block
79
+ visible={gradio.shared.visible}
80
+ elem_id={gradio.shared.elem_id}
81
+ elem_classes={gradio.shared.elem_classes}
82
+ scale={gradio.shared.scale}
83
+ min_width={gradio.shared.min_width}
84
+ padding={false}
85
+ container={false}
86
+ overflow_behavior="visible"
87
+ {fullscreen}
88
+ >
89
+ <StatusTracker
90
+ autoscroll={gradio.shared.autoscroll}
91
+ i18n={gradio.i18n}
92
+ {...gradio.shared.loading_status}
93
+ />
94
+ <Table
95
+ headers={gradio.props.value?.headers ?? []}
96
+ values={gradio.props.value?.data ?? []}
97
+ display_value={gradio.props.value?.metadata?.display_value ?? null}
98
+ styling={gradio.props.value?.metadata?.styling ?? null}
99
+ col_count={gradio.props.col_count}
100
+ row_count={gradio.props.row_count}
101
+ label={gradio.shared.label}
102
+ show_label={gradio.shared.show_label}
103
+ wrap={gradio.props.wrap}
104
+ datatype={aligned_datatype}
105
+ latex_delimiters={gradio.props.latex_delimiters}
106
+ max_height={gradio.props.max_height}
107
+ editable={gradio.shared.interactive ?? true}
108
+ line_breaks={gradio.props.line_breaks}
109
+ column_widths={gradio.props.column_widths ?? []}
110
+ root={gradio.shared.root}
111
+ i18n={gradio.i18n}
112
+ upload={gradio.shared.client?.upload}
113
+ stream_handler={gradio.shared.client?.stream}
114
+ buttons={gradio.props.buttons}
115
+ max_chars={gradio.props.max_chars}
116
+ show_row_numbers={gradio.props.show_row_numbers}
117
+ show_search={gradio.props.show_search}
118
+ pinned_columns={gradio.props.pinned_columns}
119
+ static_columns={gradio.props.static_columns ?? []}
120
+ {fullscreen}
121
+ onfullscreen={() => {
122
+ fullscreen = !fullscreen;
123
+ }}
124
+ onchange={handle_change}
125
+ oninput={handle_input}
126
+ onselect={handle_select}
127
+ onedit={handle_edit}
128
+ />
129
+ </Block>
6.11.1/dataframe/package.json ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@gradio/dataframe",
3
+ "version": "0.23.0",
4
+ "description": "Gradio UI packages",
5
+ "type": "module",
6
+ "author": "",
7
+ "license": "ISC",
8
+ "private": false,
9
+ "main_changeset": true,
10
+ "main": "./Index.svelte",
11
+ "dependencies": {
12
+ "@gradio/atoms": "workspace:^",
13
+ "@gradio/button": "workspace:^",
14
+ "@gradio/checkbox": "workspace:^",
15
+ "@gradio/client": "workspace:^",
16
+ "@gradio/icons": "workspace:^",
17
+ "@gradio/markdown-code": "workspace:^",
18
+ "@gradio/statustracker": "workspace:^",
19
+ "@gradio/upload": "workspace:^",
20
+ "@gradio/utils": "workspace:^",
21
+ "@types/d3-dsv": "^3.0.7",
22
+ "@types/katex": "^0.16.7",
23
+ "d3-dsv": "^3.0.1",
24
+ "dequal": "^2.0.3",
25
+ "@tanstack/table-core": "^8.21.3",
26
+ "@tanstack/virtual-core": "^3.13.6"
27
+ },
28
+ "exports": {
29
+ ".": {
30
+ "gradio": "./Index.svelte",
31
+ "svelte": "./dist/standalone/Index.svelte",
32
+ "types": "./dist/standalone/Index.svelte.d.ts"
33
+ },
34
+ "./example": {
35
+ "gradio": "./Example.svelte",
36
+ "svelte": "./dist/Example.svelte",
37
+ "types": "./dist/Example.svelte.d.ts"
38
+ },
39
+ "./package.json": "./package.json"
40
+ },
41
+ "peerDependencies": {
42
+ "svelte": ">=5.0.0"
43
+ },
44
+ "devDependencies": {
45
+ "@gradio/preview": "workspace:^"
46
+ },
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "git+https://github.com/gradio-app/gradio.git",
50
+ "directory": "js/dataframe"
51
+ }
52
+ }
6.11.1/dataframe/shared/BooleanCell.svelte ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { BaseCheckbox } from "@gradio/checkbox";
3
+
4
+ let {
5
+ value = $bindable(false),
6
+ editable = true,
7
+ on_change
8
+ }: {
9
+ value?: boolean;
10
+ editable?: boolean;
11
+ on_change: (value: boolean) => void;
12
+ } = $props();
13
+
14
+ function handle_change(val: boolean): void {
15
+ if (editable) {
16
+ on_change(val);
17
+ }
18
+ }
19
+ </script>
20
+
21
+ <div class="bool-cell" role="button" tabindex="-1">
22
+ <BaseCheckbox
23
+ bind:value
24
+ label=""
25
+ interactive={editable}
26
+ on_change={handle_change}
27
+ />
28
+ </div>
29
+
30
+ <style>
31
+ .bool-cell {
32
+ display: flex;
33
+ align-items: center;
34
+ justify-content: center;
35
+ width: min-content;
36
+ height: var(--size-full);
37
+ margin: 0 auto;
38
+ }
39
+
40
+ .bool-cell :global(input:disabled) {
41
+ cursor: not-allowed;
42
+ }
43
+
44
+ .bool-cell :global(label) {
45
+ margin: 0;
46
+ width: 100%;
47
+ display: flex;
48
+ justify-content: center;
49
+ align-items: center;
50
+ }
51
+
52
+ .bool-cell :global(span) {
53
+ display: none;
54
+ }
55
+ </style>
6.11.1/dataframe/shared/CellMenu.svelte ADDED
@@ -0,0 +1,278 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { onMount } from "svelte";
3
+ import CellMenuIcons from "./CellMenuIcons.svelte";
4
+ import FilterMenu from "./FilterMenu.svelte";
5
+ import type { I18nFormatter } from "@gradio/utils";
6
+ import type { SortDirection, FilterDatatype } from "./types";
7
+
8
+ let {
9
+ x,
10
+ y,
11
+ on_add_row_above,
12
+ on_add_row_below,
13
+ on_add_column_left,
14
+ on_add_column_right,
15
+ row,
16
+ col_count,
17
+ row_count,
18
+ on_delete_row,
19
+ on_delete_col,
20
+ can_delete_rows,
21
+ can_delete_cols,
22
+ on_sort = () => {},
23
+ on_clear_sort = () => {},
24
+ sort_direction = null,
25
+ sort_priority = null,
26
+ on_filter = () => {},
27
+ on_clear_filter = () => {},
28
+ filter_active = null,
29
+ editable = true,
30
+ i18n
31
+ }: {
32
+ x: number;
33
+ y: number;
34
+ on_add_row_above: () => void;
35
+ on_add_row_below: () => void;
36
+ on_add_column_left: () => void;
37
+ on_add_column_right: () => void;
38
+ row: number;
39
+ col_count: [number, "fixed" | "dynamic"];
40
+ row_count: [number, "fixed" | "dynamic"];
41
+ on_delete_row: () => void;
42
+ on_delete_col: () => void;
43
+ can_delete_rows: boolean;
44
+ can_delete_cols: boolean;
45
+ on_sort?: (direction: SortDirection) => void;
46
+ on_clear_sort?: () => void;
47
+ sort_direction?: SortDirection | null;
48
+ sort_priority?: number | null;
49
+ on_filter?: (
50
+ datatype: FilterDatatype,
51
+ selected_filter: string,
52
+ value: string
53
+ ) => void;
54
+ on_clear_filter?: () => void;
55
+ filter_active?: boolean | null;
56
+ editable?: boolean;
57
+ i18n: I18nFormatter;
58
+ } = $props();
59
+
60
+ let menu_element: HTMLDivElement;
61
+ let active_filter_menu: { x: number; y: number } | null = $state(null);
62
+
63
+ let is_header = $derived(row === -1);
64
+ let can_add_rows = $derived(editable && row_count[1] === "dynamic");
65
+ let can_add_columns = $derived(editable && col_count[1] === "dynamic");
66
+
67
+ onMount(() => {
68
+ position_menu();
69
+ });
70
+
71
+ function position_menu(): void {
72
+ if (!menu_element) return;
73
+
74
+ const viewport_width = window.innerWidth;
75
+ const viewport_height = window.innerHeight;
76
+ const menu_rect = menu_element.getBoundingClientRect();
77
+
78
+ let new_x = x - 30;
79
+ let new_y = y - 20;
80
+
81
+ if (new_x + menu_rect.width > viewport_width) {
82
+ new_x = x - menu_rect.width + 10;
83
+ }
84
+
85
+ if (new_y + menu_rect.height > viewport_height) {
86
+ new_y = y - menu_rect.height + 10;
87
+ }
88
+
89
+ menu_element.style.left = `${new_x}px`;
90
+ menu_element.style.top = `${new_y}px`;
91
+ }
92
+
93
+ function toggle_filter_menu(): void {
94
+ if (filter_active) {
95
+ on_filter("string", "", "");
96
+ return;
97
+ }
98
+
99
+ const menu_rect = menu_element.getBoundingClientRect();
100
+ active_filter_menu = {
101
+ x: menu_rect.right,
102
+ y: menu_rect.top + menu_rect.height / 2
103
+ };
104
+ }
105
+ </script>
106
+
107
+ <div bind:this={menu_element} class="cell-menu" role="menu">
108
+ {#if is_header}
109
+ <button
110
+ role="menuitem"
111
+ onclick={() => on_sort("asc")}
112
+ class:active={sort_direction === "asc"}
113
+ >
114
+ <CellMenuIcons icon="sort-asc" />
115
+ {i18n("dataframe.sort_ascending")}
116
+ {#if sort_direction === "asc" && sort_priority !== null}
117
+ <span class="priority">{sort_priority}</span>
118
+ {/if}
119
+ </button>
120
+ <button
121
+ role="menuitem"
122
+ onclick={() => on_sort("desc")}
123
+ class:active={sort_direction === "desc"}
124
+ >
125
+ <CellMenuIcons icon="sort-desc" />
126
+ {i18n("dataframe.sort_descending")}
127
+ {#if sort_direction === "desc" && sort_priority !== null}
128
+ <span class="priority">{sort_priority}</span>
129
+ {/if}
130
+ </button>
131
+ <button role="menuitem" onclick={on_clear_sort}>
132
+ <CellMenuIcons icon="clear-sort" />
133
+ {i18n("dataframe.clear_sort")}
134
+ </button>
135
+ <button
136
+ role="menuitem"
137
+ onclick={(e) => {
138
+ e.stopPropagation();
139
+ toggle_filter_menu();
140
+ }}
141
+ class:active={filter_active || active_filter_menu}
142
+ >
143
+ <CellMenuIcons icon="filter" />
144
+ {i18n("dataframe.filter")}
145
+ {#if filter_active}
146
+ <span class="priority">1</span>
147
+ {/if}
148
+ </button>
149
+ <button role="menuitem" onclick={on_clear_filter}>
150
+ <CellMenuIcons icon="clear-filter" />
151
+ {i18n("dataframe.clear_filter")}
152
+ </button>
153
+ {/if}
154
+
155
+ {#if !is_header && can_add_rows}
156
+ <button
157
+ role="menuitem"
158
+ onclick={() => on_add_row_above()}
159
+ aria-label="Add row above"
160
+ >
161
+ <CellMenuIcons icon="add-row-above" />
162
+ {i18n("dataframe.add_row_above")}
163
+ </button>
164
+ <button
165
+ role="menuitem"
166
+ onclick={() => on_add_row_below()}
167
+ aria-label="Add row below"
168
+ >
169
+ <CellMenuIcons icon="add-row-below" />
170
+ {i18n("dataframe.add_row_below")}
171
+ </button>
172
+ {#if can_delete_rows}
173
+ <button
174
+ role="menuitem"
175
+ onclick={on_delete_row}
176
+ class="delete"
177
+ aria-label="Delete row"
178
+ >
179
+ <CellMenuIcons icon="delete-row" />
180
+ {i18n("dataframe.delete_row")}
181
+ </button>
182
+ {/if}
183
+ {/if}
184
+ {#if can_add_columns}
185
+ <button
186
+ role="menuitem"
187
+ onclick={() => on_add_column_left()}
188
+ aria-label="Add column to the left"
189
+ >
190
+ <CellMenuIcons icon="add-column-left" />
191
+ {i18n("dataframe.add_column_left")}
192
+ </button>
193
+ <button
194
+ role="menuitem"
195
+ onclick={() => on_add_column_right()}
196
+ aria-label="Add column to the right"
197
+ >
198
+ <CellMenuIcons icon="add-column-right" />
199
+ {i18n("dataframe.add_column_right")}
200
+ </button>
201
+ {#if can_delete_cols}
202
+ <button
203
+ role="menuitem"
204
+ onclick={on_delete_col}
205
+ class="delete"
206
+ aria-label="Delete column"
207
+ >
208
+ <CellMenuIcons icon="delete-column" />
209
+ {i18n("dataframe.delete_column")}
210
+ </button>
211
+ {/if}
212
+ {/if}
213
+ </div>
214
+
215
+ {#if active_filter_menu}
216
+ <FilterMenu {on_filter} />
217
+ {/if}
218
+
219
+ <style>
220
+ .cell-menu {
221
+ position: fixed;
222
+ z-index: var(--layer-1);
223
+ background: var(--background-fill-primary);
224
+ border: 1px solid var(--border-color-primary);
225
+ border-radius: var(--radius-sm);
226
+ padding: var(--size-1);
227
+ display: flex;
228
+ flex-direction: column;
229
+ gap: var(--size-1);
230
+ box-shadow: var(--shadow-drop-lg);
231
+ min-width: 150px;
232
+ width: max-content;
233
+ }
234
+
235
+ .cell-menu button {
236
+ background: none;
237
+ border: none;
238
+ cursor: pointer;
239
+ text-align: left;
240
+ padding: var(--size-1) var(--size-2);
241
+ border-radius: var(--radius-sm);
242
+ color: var(--body-text-color);
243
+ font-size: var(--text-sm);
244
+ transition:
245
+ background-color 0.2s,
246
+ color 0.2s;
247
+ display: flex;
248
+ align-items: center;
249
+ gap: var(--size-2);
250
+ position: relative;
251
+ }
252
+
253
+ .cell-menu button.active {
254
+ background-color: var(--background-fill-secondary);
255
+ }
256
+
257
+ .cell-menu button:hover {
258
+ background-color: var(--background-fill-secondary);
259
+ }
260
+
261
+ .cell-menu button :global(svg) {
262
+ fill: currentColor;
263
+ transition: fill 0.2s;
264
+ }
265
+
266
+ .priority {
267
+ display: flex;
268
+ align-items: center;
269
+ justify-content: center;
270
+ margin-left: auto;
271
+ font-size: var(--size-2);
272
+ background-color: var(--button-secondary-background-fill);
273
+ color: var(--body-text-color);
274
+ border-radius: var(--radius-sm);
275
+ width: var(--size-2-5);
276
+ height: var(--size-2-5);
277
+ }
278
+ </style>
6.11.1/dataframe/shared/CellMenuButton.svelte ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ let { on_click }: { on_click: (event: MouseEvent) => void } = $props();
3
+ </script>
4
+
5
+ <button
6
+ aria-label="Open cell menu"
7
+ class="cell-menu-button"
8
+ aria-haspopup="menu"
9
+ onclick={on_click}
10
+ ontouchstart={(event) => {
11
+ event.preventDefault();
12
+ const touch = event.touches[0];
13
+ const mouseEvent = new MouseEvent("click", {
14
+ clientX: touch.clientX,
15
+ clientY: touch.clientY,
16
+ bubbles: true,
17
+ cancelable: true,
18
+ view: window
19
+ });
20
+ on_click(mouseEvent);
21
+ }}
22
+ >
23
+ &#8942;
24
+ </button>
25
+
26
+ <style>
27
+ .cell-menu-button {
28
+ flex-shrink: 0;
29
+ display: none;
30
+ align-items: center;
31
+ justify-content: center;
32
+ background-color: var(--block-background-fill);
33
+ border: 1px solid var(--border-color-primary);
34
+ border-radius: var(--block-radius);
35
+ width: var(--size-5);
36
+ height: var(--size-5);
37
+ min-width: var(--size-5);
38
+ padding: 0;
39
+ margin-right: var(--spacing-sm);
40
+ z-index: 2;
41
+ position: absolute;
42
+ right: var(--size-1);
43
+ top: 50%;
44
+ transform: translateY(-50%);
45
+ }
46
+ </style>
6.11.1/dataframe/shared/CellMenuIcons.svelte ADDED
@@ -0,0 +1,240 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ let { icon }: { icon: string } = $props();
3
+ </script>
4
+
5
+ {#if icon == "add-column-right"}
6
+ <svg viewBox="0 0 24 24" width="16" height="16">
7
+ <rect
8
+ x="4"
9
+ y="6"
10
+ width="4"
11
+ height="12"
12
+ stroke="currentColor"
13
+ stroke-width="2"
14
+ fill="none"
15
+ />
16
+ <path
17
+ d="M12 12H19M16 8L19 12L16 16"
18
+ stroke="currentColor"
19
+ stroke-width="2"
20
+ fill="none"
21
+ stroke-linecap="round"
22
+ />
23
+ </svg>
24
+ {:else if icon == "add-column-left"}
25
+ <svg viewBox="0 0 24 24" width="16" height="16">
26
+ <rect
27
+ x="16"
28
+ y="6"
29
+ width="4"
30
+ height="12"
31
+ stroke="currentColor"
32
+ stroke-width="2"
33
+ fill="none"
34
+ />
35
+ <path
36
+ d="M12 12H5M8 8L5 12L8 16"
37
+ stroke="currentColor"
38
+ stroke-width="2"
39
+ fill="none"
40
+ stroke-linecap="round"
41
+ />
42
+ </svg>
43
+ {:else if icon == "add-row-above"}
44
+ <svg viewBox="0 0 24 24" width="16" height="16">
45
+ <rect
46
+ x="6"
47
+ y="16"
48
+ width="12"
49
+ height="4"
50
+ stroke="currentColor"
51
+ stroke-width="2"
52
+ />
53
+ <path
54
+ d="M12 12V5M8 8L12 5L16 8"
55
+ stroke="currentColor"
56
+ stroke-width="2"
57
+ fill="none"
58
+ stroke-linecap="round"
59
+ />
60
+ </svg>
61
+ {:else if icon == "add-row-below"}
62
+ <svg viewBox="0 0 24 24" width="16" height="16">
63
+ <rect
64
+ x="6"
65
+ y="4"
66
+ width="12"
67
+ height="4"
68
+ stroke="currentColor"
69
+ stroke-width="2"
70
+ />
71
+ <path
72
+ d="M12 12V19M8 16L12 19L16 16"
73
+ stroke="currentColor"
74
+ stroke-width="2"
75
+ fill="none"
76
+ stroke-linecap="round"
77
+ />
78
+ </svg>
79
+ {:else if icon == "delete-row"}
80
+ <svg viewBox="0 0 24 24" width="16" height="16">
81
+ <rect
82
+ x="5"
83
+ y="10"
84
+ width="14"
85
+ height="4"
86
+ stroke="currentColor"
87
+ stroke-width="2"
88
+ />
89
+ <path
90
+ d="M8 7L16 17M16 7L8 17"
91
+ stroke="currentColor"
92
+ stroke-width="2"
93
+ stroke-linecap="round"
94
+ />
95
+ </svg>
96
+ {:else if icon == "delete-column"}
97
+ <svg viewBox="0 0 24 24" width="16" height="16">
98
+ <rect
99
+ x="10"
100
+ y="5"
101
+ width="4"
102
+ height="14"
103
+ stroke="currentColor"
104
+ stroke-width="2"
105
+ />
106
+ <path
107
+ d="M7 8L17 16M17 8L7 16"
108
+ stroke="currentColor"
109
+ stroke-width="2"
110
+ stroke-linecap="round"
111
+ />
112
+ </svg>
113
+ {:else if icon == "sort-asc"}
114
+ <svg viewBox="0 0 24 24" width="16" height="16">
115
+ <path
116
+ d="M8 16L12 12L16 16"
117
+ stroke="currentColor"
118
+ stroke-width="2"
119
+ fill="none"
120
+ stroke-linecap="round"
121
+ stroke-linejoin="round"
122
+ />
123
+ <path
124
+ d="M12 12V19"
125
+ stroke="currentColor"
126
+ stroke-width="2"
127
+ stroke-linecap="round"
128
+ />
129
+ <path
130
+ d="M5 7H19"
131
+ stroke="currentColor"
132
+ stroke-width="2"
133
+ stroke-linecap="round"
134
+ />
135
+ </svg>
136
+ {:else if icon == "sort-desc"}
137
+ <svg viewBox="0 0 24 24" width="16" height="16">
138
+ <path
139
+ d="M8 12L12 16L16 12"
140
+ stroke="currentColor"
141
+ stroke-width="2"
142
+ fill="none"
143
+ stroke-linecap="round"
144
+ stroke-linejoin="round"
145
+ />
146
+ <path
147
+ d="M12 16V9"
148
+ stroke="currentColor"
149
+ stroke-width="2"
150
+ stroke-linecap="round"
151
+ />
152
+ <path
153
+ d="M5 5H19"
154
+ stroke="currentColor"
155
+ stroke-width="2"
156
+ stroke-linecap="round"
157
+ />
158
+ </svg>
159
+ {:else if icon == "clear-sort"}
160
+ <svg viewBox="0 0 24 24" width="16" height="16">
161
+ <path
162
+ d="M5 5H19"
163
+ stroke="currentColor"
164
+ stroke-width="2"
165
+ stroke-linecap="round"
166
+ />
167
+ <path
168
+ d="M5 9H15"
169
+ stroke="currentColor"
170
+ stroke-width="2"
171
+ stroke-linecap="round"
172
+ />
173
+ <path
174
+ d="M5 13H11"
175
+ stroke="currentColor"
176
+ stroke-width="2"
177
+ stroke-linecap="round"
178
+ />
179
+ <path
180
+ d="M5 17H7"
181
+ stroke="currentColor"
182
+ stroke-width="2"
183
+ stroke-linecap="round"
184
+ />
185
+ <path
186
+ d="M17 17L21 21M21 17L17 21"
187
+ stroke="currentColor"
188
+ stroke-width="2"
189
+ stroke-linecap="round"
190
+ />
191
+ </svg>
192
+ {:else if icon == "filter"}
193
+ <svg viewBox="0 0 24 24" width="16" height="16">
194
+ <path
195
+ d="M5 5H19"
196
+ stroke="currentColor"
197
+ stroke-width="2"
198
+ stroke-linecap="round"
199
+ />
200
+ <path
201
+ d="M8 9H16"
202
+ stroke="currentColor"
203
+ stroke-width="2"
204
+ stroke-linecap="round"
205
+ />
206
+ <path
207
+ d="M11 13H13"
208
+ stroke="currentColor"
209
+ stroke-width="2"
210
+ stroke-linecap="round"
211
+ />
212
+ </svg>
213
+ {:else if icon == "clear-filter"}
214
+ <svg viewBox="0 0 24 24" width="16" height="16">
215
+ <path
216
+ d="M5 5H19"
217
+ stroke="currentColor"
218
+ stroke-width="2"
219
+ stroke-linecap="round"
220
+ />
221
+ <path
222
+ d="M8 9H16"
223
+ stroke="currentColor"
224
+ stroke-width="2"
225
+ stroke-linecap="round"
226
+ />
227
+ <path
228
+ d="M11 13H13"
229
+ stroke="currentColor"
230
+ stroke-width="2"
231
+ stroke-linecap="round"
232
+ />
233
+ <path
234
+ d="M17 17L21 21M21 17L17 21"
235
+ stroke="currentColor"
236
+ stroke-width="2"
237
+ stroke-linecap="round"
238
+ />
239
+ </svg>
240
+ {/if}
6.11.1/dataframe/shared/DataCell.svelte ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import EditableCell from "./EditableCell.svelte";
3
+ import CellMenuButton from "./CellMenuButton.svelte";
4
+ import type { I18nFormatter } from "js/core/src/gradio_helper";
5
+ import type { CellValue } from "./types";
6
+ import type { Datatype } from "./utils/utils";
7
+
8
+ let {
9
+ value,
10
+ display_value = null,
11
+ datatype = "str",
12
+ row_idx,
13
+ col_idx,
14
+ col_style = "",
15
+ cell_style = "",
16
+ selection_classes = "",
17
+ is_editing = false,
18
+ is_flash = false,
19
+ is_static = false,
20
+ show_menu_button = false,
21
+ show_selection_buttons = false,
22
+ is_first_column = false,
23
+ latex_delimiters,
24
+ line_breaks = true,
25
+ editable = true,
26
+ max_chars = undefined,
27
+ i18n,
28
+ components = {},
29
+ is_dragging = false,
30
+ wrap_text = false,
31
+ onmousedown,
32
+ ondblclick,
33
+ oncontextmenu,
34
+ onblur,
35
+ on_menu_click,
36
+ on_select_column,
37
+ on_select_row
38
+ }: {
39
+ value: CellValue;
40
+ display_value?: string | null;
41
+ datatype?: Datatype;
42
+ row_idx: number;
43
+ col_idx: number;
44
+ col_style?: string;
45
+ cell_style?: string;
46
+ selection_classes?: string;
47
+ is_editing?: boolean;
48
+ is_flash?: boolean;
49
+ is_static?: boolean;
50
+ show_menu_button?: boolean;
51
+ show_selection_buttons?: boolean;
52
+ is_first_column?: boolean;
53
+ latex_delimiters: { left: string; right: string; display: boolean }[];
54
+ line_breaks?: boolean;
55
+ editable?: boolean;
56
+ max_chars?: number | undefined;
57
+ i18n: I18nFormatter;
58
+ components?: Record<string, any>;
59
+ is_dragging?: boolean;
60
+ wrap_text?: boolean;
61
+ onmousedown: (event: MouseEvent) => void;
62
+ ondblclick: (event: MouseEvent) => void;
63
+ oncontextmenu: (event: MouseEvent) => void;
64
+ onblur: (detail: {
65
+ blur_event: FocusEvent;
66
+ coords: [number, number];
67
+ }) => void;
68
+ on_menu_click: (event: MouseEvent) => void;
69
+ on_select_column: (col: number) => void;
70
+ on_select_row: (row: number) => void;
71
+ } = $props();
72
+
73
+ let is_selected = $derived(selection_classes !== "");
74
+ </script>
75
+
76
+ <div
77
+ class="body-cell {selection_classes}"
78
+ class:flash={is_flash}
79
+ class:first-column={is_first_column}
80
+ data-row={row_idx}
81
+ data-col={col_idx}
82
+ data-testid={`cell-${row_idx}-${col_idx}`}
83
+ {onmousedown}
84
+ {ondblclick}
85
+ {oncontextmenu}
86
+ style="{col_style} {cell_style}"
87
+ >
88
+ <div class="cell-wrap">
89
+ <EditableCell
90
+ {value}
91
+ {display_value}
92
+ {latex_delimiters}
93
+ {line_breaks}
94
+ {editable}
95
+ {is_static}
96
+ edit={is_editing}
97
+ {datatype}
98
+ {onblur}
99
+ {max_chars}
100
+ {i18n}
101
+ {components}
102
+ {show_selection_buttons}
103
+ coords={[row_idx, col_idx]}
104
+ {on_select_column}
105
+ {on_select_row}
106
+ {is_dragging}
107
+ {wrap_text}
108
+ />
109
+ {#if show_menu_button}
110
+ <CellMenuButton on_click={on_menu_click} />
111
+ {/if}
112
+ </div>
113
+ </div>
114
+
115
+ <style>
116
+ .body-cell {
117
+ --ring-color: transparent;
118
+ outline: none;
119
+ box-shadow:
120
+ inset 1px 0 0 var(--border-color-primary),
121
+ inset 0 0 0 1px var(--ring-color);
122
+ padding: 0;
123
+ overflow: visible;
124
+ box-sizing: border-box;
125
+ }
126
+
127
+ .body-cell.first-column {
128
+ box-shadow: inset 0 0 0 1px var(--ring-color);
129
+ }
130
+
131
+ .body-cell:hover :global(.cell-menu-button),
132
+ .body-cell.cell-selected :global(.cell-menu-button) {
133
+ display: flex;
134
+ }
135
+
136
+ .body-cell.cell-selected {
137
+ --ring-color: var(--color-accent);
138
+ --sel-top: inset 0 2px 0 0 var(--ring-color);
139
+ --sel-bottom: inset 0 -2px 0 0 var(--ring-color);
140
+ --sel-left: inset 2px 0 0 0 var(--ring-color);
141
+ --sel-right: inset -2px 0 0 0 var(--ring-color);
142
+ box-shadow:
143
+ var(--sel-top), var(--sel-bottom), var(--sel-left), var(--sel-right);
144
+ z-index: 2;
145
+ position: relative;
146
+ }
147
+
148
+ .body-cell.cell-selected.no-top {
149
+ --sel-top: inset 0 0 0 0 transparent;
150
+ }
151
+ .body-cell.cell-selected.no-bottom {
152
+ --sel-bottom: inset 0 0 0 0 transparent;
153
+ }
154
+ .body-cell.cell-selected.no-left {
155
+ --sel-left: inset 0 0 0 0 transparent;
156
+ }
157
+ .body-cell.cell-selected.no-right {
158
+ --sel-right: inset 0 0 0 0 transparent;
159
+ }
160
+
161
+ .body-cell.flash.cell-selected {
162
+ animation: flash-color 700ms ease-out;
163
+ }
164
+
165
+ @keyframes flash-color {
166
+ 0%,
167
+ 30% {
168
+ background: var(--color-accent-copied);
169
+ }
170
+ 100% {
171
+ background: transparent;
172
+ }
173
+ }
174
+
175
+ .cell-wrap {
176
+ display: flex;
177
+ align-items: center;
178
+ justify-content: flex-start;
179
+ outline: none;
180
+ min-height: var(--size-9);
181
+ position: relative;
182
+ padding: var(--size-2);
183
+ box-sizing: border-box;
184
+ gap: var(--size-1);
185
+ overflow: visible;
186
+ min-width: 0;
187
+ height: 100%;
188
+ }
189
+ </style>
6.11.1/dataframe/shared/EditableCell.svelte ADDED
@@ -0,0 +1,285 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { MarkdownCode } from "@gradio/markdown-code";
3
+ import type { I18nFormatter } from "@gradio/utils";
4
+ import type { CellValue } from "./types";
5
+ import SelectionButtons from "./icons/SelectionButtons.svelte";
6
+ import BooleanCell from "./BooleanCell.svelte";
7
+
8
+ let {
9
+ edit,
10
+ value = $bindable(""),
11
+ display_value = null,
12
+ styling = "",
13
+ header = false,
14
+ datatype = "str",
15
+ latex_delimiters,
16
+ line_breaks = true,
17
+ editable = true,
18
+ is_static = false,
19
+ max_chars = null,
20
+ components = {},
21
+ i18n,
22
+ is_dragging = false,
23
+ wrap_text = false,
24
+ show_selection_buttons = false,
25
+ coords,
26
+ on_select_column = null,
27
+ on_select_row = null,
28
+ el = $bindable(null),
29
+ onblur,
30
+ onkeydown
31
+ }: {
32
+ edit: boolean;
33
+ value?: CellValue;
34
+ display_value?: string | null;
35
+ styling?: string;
36
+ header?: boolean;
37
+ datatype?:
38
+ | "str"
39
+ | "markdown"
40
+ | "html"
41
+ | "number"
42
+ | "bool"
43
+ | "date"
44
+ | "image";
45
+ latex_delimiters: {
46
+ left: string;
47
+ right: string;
48
+ display: boolean;
49
+ }[];
50
+ line_breaks?: boolean;
51
+ editable?: boolean;
52
+ is_static?: boolean;
53
+ max_chars?: number | null;
54
+ components?: Record<string, any>;
55
+ i18n: I18nFormatter;
56
+ is_dragging?: boolean;
57
+ wrap_text?: boolean;
58
+ show_selection_buttons?: boolean;
59
+ coords: [number, number];
60
+ on_select_column?: ((col: number) => void) | null;
61
+ on_select_row?: ((row: number) => void) | null;
62
+ el?: HTMLTextAreaElement | null;
63
+ onblur?: (detail: {
64
+ blur_event: FocusEvent;
65
+ coords: [number, number];
66
+ }) => void;
67
+ onkeydown?: (event: KeyboardEvent) => void;
68
+ } = $props();
69
+
70
+ function truncate_text(
71
+ text: CellValue,
72
+ max_length: number | null = null,
73
+ is_image = false
74
+ ): string {
75
+ if (is_image) return String(text);
76
+ const str = String(text);
77
+ if (!max_length || max_length <= 0) return str;
78
+ if (str.length <= max_length) return str;
79
+ return str.slice(0, max_length) + "...";
80
+ }
81
+
82
+ let should_truncate = $derived(!edit && max_chars !== null && max_chars > 0);
83
+
84
+ let display_content = $derived(
85
+ editable ? value : display_value !== null ? display_value : value
86
+ );
87
+
88
+ let display_text = $derived(
89
+ should_truncate
90
+ ? truncate_text(display_content, max_chars, datatype === "image")
91
+ : display_content
92
+ );
93
+
94
+ function use_focus(node: HTMLTextAreaElement): any {
95
+ requestAnimationFrame(() => {
96
+ node.focus();
97
+ });
98
+
99
+ return {};
100
+ }
101
+
102
+ function handle_blur(event: FocusEvent): void {
103
+ onblur?.({
104
+ blur_event: event,
105
+ coords: coords
106
+ });
107
+ }
108
+
109
+ function handle_keydown(event: KeyboardEvent): void {
110
+ onkeydown?.(event);
111
+ }
112
+
113
+ function commit_change(checked: boolean): void {
114
+ handle_blur({ target: { value } } as unknown as FocusEvent);
115
+ }
116
+
117
+ $effect(() => {
118
+ if (!edit) {
119
+ // Shim blur on removal for Safari and Firefox
120
+ handle_blur({ target: { value } } as unknown as FocusEvent);
121
+ }
122
+ });
123
+ </script>
124
+
125
+ {#if edit && datatype !== "bool"}
126
+ <textarea
127
+ readonly={is_static}
128
+ aria-readonly={is_static}
129
+ aria-label={is_static ? "Cell is read-only" : "Edit cell"}
130
+ bind:this={el}
131
+ bind:value
132
+ class:header
133
+ tabindex="-1"
134
+ onblur={handle_blur}
135
+ onmousedown={(e: MouseEvent) => e.stopPropagation()}
136
+ onclick={(e: MouseEvent) => e.stopPropagation()}
137
+ use:use_focus
138
+ onkeydown={handle_keydown}
139
+ />
140
+ {/if}
141
+
142
+ {#if datatype === "bool" && typeof value === "boolean"}
143
+ <BooleanCell bind:value {editable} on_change={commit_change} />
144
+ {:else}
145
+ <span
146
+ class:dragging={is_dragging}
147
+ onkeydown={handle_keydown}
148
+ tabindex="0"
149
+ role="button"
150
+ class:edit
151
+ class:expanded={edit}
152
+ class:multiline={header}
153
+ onfocus={(e) => e.preventDefault()}
154
+ style={styling}
155
+ data-editable={editable}
156
+ data-max-chars={max_chars}
157
+ data-expanded={edit}
158
+ placeholder=" "
159
+ class:text={datatype === "str"}
160
+ class:wrap={wrap_text}
161
+ >
162
+ {#if datatype === "image" && components.image}
163
+ {@const ImageComponent = components.image}
164
+ <ImageComponent
165
+ value={{ url: display_text }}
166
+ show_label={false}
167
+ label="cell-image"
168
+ show_download_button={false}
169
+ {i18n}
170
+ gradio={{ dispatch: () => {} }}
171
+ />
172
+ {:else if datatype === "html"}
173
+ {@html display_text}
174
+ {:else if datatype === "markdown"}
175
+ <MarkdownCode
176
+ message={display_text.toLocaleString()}
177
+ {latex_delimiters}
178
+ {line_breaks}
179
+ chatbot={false}
180
+ />
181
+ {:else}
182
+ {display_text}
183
+ {/if}
184
+ </span>
185
+ {/if}
186
+
187
+ {#if show_selection_buttons && coords && on_select_column && on_select_row}
188
+ <SelectionButtons
189
+ position="column"
190
+ {coords}
191
+ on_click={() => on_select_column(coords[1])}
192
+ />
193
+ <SelectionButtons
194
+ position="row"
195
+ {coords}
196
+ on_click={() => on_select_row(coords[0])}
197
+ />
198
+ {/if}
199
+
200
+ <style>
201
+ .dragging {
202
+ cursor: crosshair !important;
203
+ }
204
+
205
+ textarea {
206
+ position: absolute;
207
+ flex: 1 1 0%;
208
+ transform: translateX(-0.1px);
209
+ outline: none;
210
+ border: none;
211
+ background: transparent;
212
+ cursor: text;
213
+ width: calc(100% - var(--size-2));
214
+ resize: none;
215
+ height: 100%;
216
+ padding-left: 0;
217
+ font-size: inherit;
218
+ font-weight: inherit;
219
+ line-height: var(--line-lg);
220
+ }
221
+
222
+ textarea:focus {
223
+ outline: none;
224
+ }
225
+
226
+ span {
227
+ flex: 1 1 0%;
228
+ position: relative;
229
+ display: block;
230
+ outline: none;
231
+ -webkit-user-select: text;
232
+ -moz-user-select: text;
233
+ -ms-user-select: text;
234
+ user-select: text;
235
+ cursor: text;
236
+ width: 100%;
237
+ overflow-wrap: break-word;
238
+ }
239
+
240
+ span.text.expanded {
241
+ height: auto;
242
+ min-height: 100%;
243
+ white-space: pre-wrap;
244
+ word-break: break-word;
245
+ overflow: visible;
246
+ }
247
+
248
+ .multiline {
249
+ white-space: pre;
250
+ overflow: hidden;
251
+ text-overflow: ellipsis;
252
+ }
253
+
254
+ .header {
255
+ transform: translateX(0);
256
+ font-weight: var(--weight-bold);
257
+ white-space: nowrap;
258
+ overflow: hidden;
259
+ text-overflow: ellipsis;
260
+ margin-left: var(--size-1);
261
+ }
262
+
263
+ .edit {
264
+ opacity: 0;
265
+ pointer-events: none;
266
+ }
267
+
268
+ span :global(img) {
269
+ max-height: 100px;
270
+ width: auto;
271
+ object-fit: contain;
272
+ }
273
+
274
+ textarea:read-only {
275
+ cursor: not-allowed;
276
+ }
277
+
278
+ .wrap,
279
+ .wrap.expanded {
280
+ white-space: normal;
281
+ word-wrap: break-word;
282
+ overflow-wrap: break-word;
283
+ word-wrap: break-word;
284
+ }
285
+ </style>
6.11.1/dataframe/shared/EmptyRowButton.svelte ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ let { on_click }: { on_click: () => void } = $props();
3
+ </script>
4
+
5
+ <button class="add-row-button" onclick={on_click} aria-label="Add row">
6
+ +
7
+ </button>
8
+
9
+ <style>
10
+ .add-row-button {
11
+ width: 100%;
12
+ padding: var(--size-1);
13
+ background: transparent;
14
+ border: 1px dashed var(--border-color-primary);
15
+ border-radius: var(--radius-sm);
16
+ color: var(--body-text-color);
17
+ cursor: pointer;
18
+ transition: all 150ms;
19
+ margin-top: var(--size-2);
20
+ z-index: 10;
21
+ position: relative;
22
+ pointer-events: auto;
23
+ }
24
+
25
+ .add-row-button:hover {
26
+ background: var(--background-fill-secondary);
27
+ border-style: solid;
28
+ }
29
+ </style>
6.11.1/dataframe/shared/Example.svelte ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ export let value: (string | number)[][];
3
+ </script>
4
+
5
+ <table class="input-dataframe-example">
6
+ {#each value.slice(0, 3) as row}
7
+ <tr>
8
+ {#each row.slice(0, 3) as cell}
9
+ <td class="p-2">{cell}</td>
10
+ {/each}
11
+ {#if row.length > 3}
12
+ <td class="p-2">...</td>
13
+ {/if}
14
+ </tr>
15
+ {/each}
16
+ {#if value.length > 3}
17
+ <tr>
18
+ {#each Array(Math.min(4, value[0].length)) as _}
19
+ <td class="p-2">...</td>
20
+ {/each}
21
+ </tr>
22
+ {/if}
23
+ </table>
24
+
25
+ <style>
26
+ table {
27
+ border-collapse: separate;
28
+ }
29
+ </style>
6.11.1/dataframe/shared/FilterMenu.svelte ADDED
@@ -0,0 +1,255 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { onMount } from "svelte";
3
+ import { Check, DropdownArrow } from "@gradio/icons";
4
+ import type { FilterDatatype } from "./types";
5
+
6
+ let {
7
+ on_filter = () => {}
8
+ }: {
9
+ on_filter?: (
10
+ datatype: FilterDatatype,
11
+ selected_filter: string,
12
+ value: string
13
+ ) => void;
14
+ } = $props();
15
+
16
+ let menu_element: HTMLDivElement;
17
+ let datatype: "string" | "number" = $state("string");
18
+ let current_filter = $state("Contains");
19
+ let filter_dropdown_open = $state(false);
20
+ let filter_input_value = $state("");
21
+
22
+ const filter_options = {
23
+ string: [
24
+ "Contains",
25
+ "Does not contain",
26
+ "Starts with",
27
+ "Ends with",
28
+ "Is",
29
+ "Is not",
30
+ "Is empty",
31
+ "Is not empty"
32
+ ],
33
+ number: ["=", "≠", ">", "<", "≥", "≤", "Is empty", "Is not empty"]
34
+ };
35
+
36
+ onMount(() => {
37
+ position_menu();
38
+ });
39
+
40
+ function position_menu(): void {
41
+ if (!menu_element) return;
42
+
43
+ const viewport_width = window.innerWidth;
44
+ const viewport_height = window.innerHeight;
45
+ const menu_rect = menu_element.getBoundingClientRect();
46
+
47
+ const x = (viewport_width - menu_rect.width) / 2;
48
+ const y = (viewport_height - menu_rect.height) / 2;
49
+
50
+ menu_element.style.left = `${x}px`;
51
+ menu_element.style.top = `${y}px`;
52
+ }
53
+
54
+ function handle_filter_input(e: Event): void {
55
+ const target = e.target as HTMLInputElement;
56
+ filter_input_value = target.value;
57
+ }
58
+ </script>
59
+
60
+ <div>
61
+ <div class="background"></div>
62
+ <div bind:this={menu_element} class="filter-menu">
63
+ <div class="filter-datatype-container">
64
+ <span>Filter as</span>
65
+ <button
66
+ onclick={(e) => {
67
+ e.stopPropagation();
68
+ datatype = datatype === "string" ? "number" : "string";
69
+ current_filter = filter_options[datatype][0];
70
+ }}
71
+ aria-label={`Change filter type. Filtering ${datatype}s`}
72
+ >
73
+ {datatype}
74
+ </button>
75
+ </div>
76
+
77
+ <div class="input-container">
78
+ <div class="filter-dropdown">
79
+ <button
80
+ onclick={(e) => {
81
+ e.stopPropagation();
82
+ filter_dropdown_open = !filter_dropdown_open;
83
+ }}
84
+ aria-label={`Change filter. Using '${current_filter}'`}
85
+ >
86
+ {current_filter}
87
+ <DropdownArrow />
88
+ </button>
89
+
90
+ {#if filter_dropdown_open}
91
+ <div class="dropdown-filter-options">
92
+ {#each filter_options[datatype] as opt}
93
+ <button
94
+ onclick={(e) => {
95
+ e.stopPropagation();
96
+ current_filter = opt;
97
+ filter_dropdown_open = !filter_dropdown_open;
98
+ }}
99
+ class="filter-option"
100
+ >
101
+ {opt}
102
+ </button>
103
+ {/each}
104
+ </div>
105
+ {/if}
106
+ </div>
107
+
108
+ <input
109
+ type="text"
110
+ value={filter_input_value}
111
+ onclick={(e) => e.stopPropagation()}
112
+ oninput={handle_filter_input}
113
+ placeholder="Type a value"
114
+ class="filter-input"
115
+ />
116
+ </div>
117
+
118
+ <button
119
+ class="check-button"
120
+ onclick={() => on_filter(datatype, current_filter, filter_input_value)}
121
+ >
122
+ <Check />
123
+ </button>
124
+ </div>
125
+ </div>
126
+
127
+ <style>
128
+ .background {
129
+ position: fixed;
130
+ top: 0;
131
+ left: 0;
132
+ width: 100vw;
133
+ height: 100vh;
134
+ background-color: rgba(0, 0, 0, 0.4);
135
+ z-index: 20;
136
+ }
137
+
138
+ .filter-menu {
139
+ position: fixed;
140
+ background: var(--background-fill-primary);
141
+ border: 1px solid var(--border-color-primary);
142
+ border-radius: var(--radius-sm);
143
+ padding: var(--size-2);
144
+ display: flex;
145
+ flex-direction: column;
146
+ gap: var(--size-2);
147
+ box-shadow: var(--shadow-drop-lg);
148
+ width: 300px;
149
+ z-index: 21;
150
+ }
151
+
152
+ .filter-datatype-container {
153
+ display: flex;
154
+ gap: var(--size-2);
155
+ align-items: center;
156
+ }
157
+
158
+ .filter-menu span {
159
+ font-size: var(--text-sm);
160
+ color: var(--body-text-color);
161
+ }
162
+
163
+ .filter-menu button {
164
+ height: var(--size-6);
165
+ background: none;
166
+ border: 1px solid var(--border-color-primary);
167
+ border-radius: var(--radius-sm);
168
+ padding: var(--size-1) var(--size-2);
169
+ color: var(--body-text-color);
170
+ font-size: var(--text-sm);
171
+ cursor: pointer;
172
+ display: flex;
173
+ align-items: center;
174
+ justify-content: center;
175
+ gap: var(--size-2);
176
+ }
177
+
178
+ .filter-menu button:hover {
179
+ background-color: var(--background-fill-secondary);
180
+ }
181
+
182
+ .filter-input {
183
+ width: var(--size-full);
184
+ height: var(--size-6);
185
+ padding: var(--size-2);
186
+ padding-right: var(--size-8);
187
+ border: 1px solid var(--border-color-primary);
188
+ border-radius: var(--table-radius);
189
+ font-size: var(--text-sm);
190
+ color: var(--body-text-color);
191
+ background: var(--background-fill-secondary);
192
+ transition: all 0.2s ease;
193
+ }
194
+
195
+ .filter-input:hover {
196
+ border-color: var(--border-color-secondary);
197
+ background: var(--background-fill-primary);
198
+ }
199
+
200
+ .filter-input:focus {
201
+ outline: none;
202
+ border-color: var(--color-accent);
203
+ background: var(--background-fill-primary);
204
+ box-shadow: 0 0 0 1px var(--color-accent);
205
+ }
206
+
207
+ .dropdown-filter-options {
208
+ display: flex;
209
+ flex-direction: column;
210
+ background: var(--background-fill-primary);
211
+ border: 1px solid var(--border-color-primary);
212
+ border-radius: var(--radius-sm);
213
+ box-shadow: var(--shadow-drop-md);
214
+ position: absolute;
215
+ z-index: var(--layer-1);
216
+ }
217
+
218
+ .dropdown-filter-options .filter-option {
219
+ border: none;
220
+ justify-content: flex-start;
221
+ }
222
+
223
+ .input-container {
224
+ display: flex;
225
+ gap: var(--size-2);
226
+ align-items: center;
227
+ }
228
+
229
+ .input-container button {
230
+ width: 130px;
231
+ }
232
+
233
+ :global(svg.dropdown-arrow) {
234
+ width: var(--size-4);
235
+ height: var(--size-4);
236
+ margin-left: auto;
237
+ }
238
+
239
+ .filter-menu .check-button {
240
+ background: var(--color-accent);
241
+ color: white;
242
+ border: none;
243
+ width: var(--size-full);
244
+ height: var(--size-6);
245
+ border-radius: var(--radius-sm);
246
+ display: flex;
247
+ align-items: center;
248
+ justify-content: center;
249
+ padding: var(--size-1);
250
+ }
251
+
252
+ .check-button:hover {
253
+ background: var(--color-accent-soft);
254
+ }
255
+ </style>
6.11.1/dataframe/shared/HeaderCell.svelte ADDED
@@ -0,0 +1,218 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import EditableCell from "./EditableCell.svelte";
3
+ import CellMenuButton from "./CellMenuButton.svelte";
4
+ import Padlock from "./icons/Padlock.svelte";
5
+ import FilterIcon from "./icons/FilterIcon.svelte";
6
+ import SortButtonUp from "./icons/SortButtonUp.svelte";
7
+ import SortButtonDown from "./icons/SortButtonDown.svelte";
8
+ import type { I18nFormatter } from "js/core/src/gradio_helper";
9
+ import type { SortDirection } from "./types";
10
+
11
+ let {
12
+ value,
13
+ col_idx,
14
+ is_editing = false,
15
+ is_selected = false,
16
+ is_static = false,
17
+ sort_direction = null,
18
+ sort_priority = null,
19
+ multi_sort = false,
20
+ is_filtered = false,
21
+ show_menu_button = false,
22
+ is_first_column = false,
23
+ latex_delimiters,
24
+ line_breaks = true,
25
+ editable = true,
26
+ max_chars = undefined,
27
+ i18n,
28
+ onclick,
29
+ on_menu_click,
30
+ on_end_edit
31
+ }: {
32
+ value: string;
33
+ col_idx: number;
34
+ is_editing?: boolean;
35
+ is_selected?: boolean;
36
+ is_static?: boolean;
37
+ sort_direction?: SortDirection | null;
38
+ sort_priority?: number | null;
39
+ multi_sort?: boolean;
40
+ is_filtered?: boolean;
41
+ show_menu_button?: boolean;
42
+ is_first_column?: boolean;
43
+ latex_delimiters: { left: string; right: string; display: boolean }[];
44
+ line_breaks?: boolean;
45
+ editable?: boolean;
46
+ max_chars?: number | undefined;
47
+ i18n: I18nFormatter;
48
+ onclick: (event: MouseEvent, col: number) => void;
49
+ on_menu_click: (event: MouseEvent, col: number) => void;
50
+ on_end_edit: (key: string) => void;
51
+ } = $props();
52
+ </script>
53
+
54
+ <th
55
+ class="header-cell"
56
+ class:focus={is_editing || is_selected}
57
+ class:sorted={sort_direction !== null}
58
+ class:filtered={is_filtered}
59
+ class:first-column={is_first_column}
60
+ onclick={(e) => onclick(e, col_idx)}
61
+ onmousedown={(e) => {
62
+ e.preventDefault();
63
+ e.stopPropagation();
64
+ }}
65
+ title={value}
66
+ >
67
+ <div class="cell-wrap">
68
+ <div class="header-content">
69
+ <EditableCell
70
+ {value}
71
+ {latex_delimiters}
72
+ {line_breaks}
73
+ edit={is_editing}
74
+ onkeydown={(event) => {
75
+ if (["Enter", "Escape", "Tab"].includes(event.key)) {
76
+ on_end_edit(event.key);
77
+ }
78
+ }}
79
+ header
80
+ {editable}
81
+ {is_static}
82
+ {i18n}
83
+ {max_chars}
84
+ coords={[col_idx, 0]}
85
+ />
86
+ </div>
87
+ {#if sort_direction || is_filtered || is_static}
88
+ <span class="header-icons">
89
+ {#if is_filtered}
90
+ <span class="filter-indicator" aria-label="Filtered">
91
+ <FilterIcon />
92
+ </span>
93
+ {/if}
94
+ {#if sort_direction}
95
+ <span
96
+ class="sort-indicator"
97
+ aria-label="Sorted {sort_direction}ending"
98
+ >
99
+ {#if sort_direction === "asc"}
100
+ <SortButtonUp size={13} />
101
+ {:else}
102
+ <SortButtonDown size={13} />
103
+ {/if}
104
+ {#if multi_sort && sort_priority != null}
105
+ <span class="sort-priority">{sort_priority}</span>
106
+ {/if}
107
+ </span>
108
+ {/if}
109
+
110
+ {#if is_static}
111
+ <Padlock size={11} />
112
+ {/if}
113
+ </span>
114
+ {/if}
115
+ {#if show_menu_button}
116
+ <CellMenuButton on_click={(e) => on_menu_click(e, col_idx)} />
117
+ {/if}
118
+ </div>
119
+ </th>
120
+
121
+ <style>
122
+ .header-cell {
123
+ --ring-color: transparent;
124
+ position: relative;
125
+ outline: none;
126
+ box-shadow:
127
+ inset 1px 0 0 var(--border-color-primary),
128
+ inset 0 0 0 1px var(--ring-color);
129
+ padding: 0;
130
+ background: var(--table-even-background-fill) !important;
131
+ font-weight: var(--weight-bold, 700);
132
+ }
133
+
134
+ .header-cell.first-column {
135
+ box-shadow: inset 0 0 0 1px var(--ring-color);
136
+ }
137
+
138
+ .header-cell:hover :global(.cell-menu-button),
139
+ .header-cell.focus :global(.cell-menu-button) {
140
+ display: flex;
141
+ }
142
+
143
+ .header-cell.focus {
144
+ --ring-color: var(--color-accent);
145
+ box-shadow:
146
+ inset 1px 0 0 var(--border-color-primary),
147
+ inset 0 0 0 2px var(--ring-color);
148
+ z-index: 4;
149
+ }
150
+
151
+ .header-cell.focus.first-column {
152
+ box-shadow: inset 0 0 0 2px var(--ring-color);
153
+ }
154
+
155
+ .header-content {
156
+ display: flex;
157
+ align-items: center;
158
+ gap: var(--size-1);
159
+ overflow: hidden;
160
+ min-width: 0;
161
+ }
162
+
163
+ .header-icons {
164
+ display: flex;
165
+ align-items: center;
166
+ gap: 2px;
167
+ flex-shrink: 0;
168
+ margin-left: auto;
169
+ opacity: 0.6;
170
+ }
171
+
172
+ .sort-indicator {
173
+ display: flex;
174
+ align-items: center;
175
+ position: relative;
176
+ margin-left: -5px;
177
+ }
178
+
179
+ .sort-priority {
180
+ font-size: 8px;
181
+ background: var(--button-secondary-background-fill);
182
+ border-radius: var(--radius-full);
183
+ width: 12px;
184
+ height: 12px;
185
+ display: flex;
186
+ align-items: center;
187
+ justify-content: center;
188
+ line-height: 1;
189
+ }
190
+
191
+ .filter-indicator {
192
+ display: flex;
193
+ align-items: center;
194
+ width: 16px;
195
+ height: 16px;
196
+ margin-top: 3px;
197
+ }
198
+
199
+ .filter-indicator :global(svg) {
200
+ width: 100%;
201
+ height: 100%;
202
+ }
203
+
204
+ .cell-wrap {
205
+ display: flex;
206
+ align-items: center;
207
+ justify-content: flex-start;
208
+ outline: none;
209
+ min-height: var(--size-9);
210
+ position: relative;
211
+ height: 100%;
212
+ padding: var(--size-2);
213
+ box-sizing: border-box;
214
+ gap: var(--size-1);
215
+ overflow: visible;
216
+ min-width: 0;
217
+ }
218
+ </style>
6.11.1/dataframe/shared/RowNumber.svelte ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ let {
3
+ index = null,
4
+ is_header = false
5
+ }: { index?: number | null; is_header?: boolean } = $props();
6
+ </script>
7
+
8
+ {#if is_header}
9
+ <th tabindex="-1" class="row-number">
10
+ <div class="cell-wrap">
11
+ <div class="header-content">
12
+ <div class="header-text"></div>
13
+ </div>
14
+ </div>
15
+ </th>
16
+ {:else}
17
+ <td class="row-number" tabindex="-1" data-row={index} data-col="row-number">
18
+ {index !== null ? index + 1 : ""}
19
+ </td>
20
+ {/if}
21
+
22
+ <style>
23
+ .row-number {
24
+ text-align: center;
25
+ padding: var(--size-1);
26
+ min-width: var(--size-12);
27
+ width: var(--size-12);
28
+ overflow: hidden;
29
+ text-overflow: ellipsis;
30
+ white-space: nowrap;
31
+ font-weight: var(--weight-semibold);
32
+ border-right: 1px solid var(--border-color-primary);
33
+ }
34
+ </style>
6.11.1/dataframe/shared/Table.svelte ADDED
@@ -0,0 +1,1364 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import {
3
+ createSvelteTable,
4
+ createSvelteVirtualizer,
5
+ getCoreRowModel,
6
+ getSortedRowModel,
7
+ getFilteredRowModel,
8
+ type ColumnDef,
9
+ type SortingState,
10
+ type ColumnFiltersState,
11
+ type ColumnPinningState
12
+ } from "./tanstack/index.js";
13
+ import { tick, onMount } from "svelte";
14
+ import { Upload } from "@gradio/upload";
15
+
16
+ import HeaderCell from "./HeaderCell.svelte";
17
+ import DataCell from "./DataCell.svelte";
18
+ import EmptyRowButton from "./EmptyRowButton.svelte";
19
+ import type { SelectData } from "@gradio/utils";
20
+ import type { I18nFormatter } from "js/core/src/gradio_helper";
21
+ import { type Client } from "@gradio/client";
22
+ import type { Datatype, DataframeValue, EditData } from "./utils/utils";
23
+ import { cast_value_to_type } from "./utils/utils";
24
+ import CellMenu from "./CellMenu.svelte";
25
+ import Toolbar from "./Toolbar.svelte";
26
+ import type {
27
+ CellValue,
28
+ CellCoordinate,
29
+ SortDirection,
30
+ FilterDatatype
31
+ } from "./types";
32
+ import {
33
+ is_cell_in_selection,
34
+ is_cell_selected,
35
+ handle_click_outside as handle_click_outside_util
36
+ } from "./utils/selection_utils";
37
+ import { copy_table_data, handle_file_upload } from "./utils/table_utils";
38
+ import { gradio_filter_fn } from "./utils/filter";
39
+ import { create_column_measurement } from "./column_measurement.svelte.js";
40
+
41
+ let {
42
+ datatype,
43
+ label = null,
44
+ show_label = true,
45
+ headers = $bindable([]),
46
+ values = $bindable([]),
47
+ col_count,
48
+ row_count,
49
+ latex_delimiters,
50
+ components = {},
51
+ editable = true,
52
+ wrap = false,
53
+ root,
54
+ i18n,
55
+ max_height = 500,
56
+ line_breaks = true,
57
+ column_widths = [],
58
+ show_row_numbers = false,
59
+ upload,
60
+ stream_handler,
61
+ buttons = null,
62
+ value_is_output = $bindable(false),
63
+ max_chars = undefined,
64
+ show_search = "none",
65
+ pinned_columns = 0,
66
+ static_columns = [],
67
+ fullscreen = false,
68
+ display_value = null,
69
+ styling = null,
70
+ onchange,
71
+ oninput,
72
+ onselect,
73
+ onedit,
74
+ onsearch,
75
+ onfullscreen
76
+ }: {
77
+ datatype: Datatype | Datatype[];
78
+ label?: string | null;
79
+ show_label?: boolean;
80
+ headers?: (string | null)[];
81
+ values?: CellValue[][];
82
+ col_count: [number, "fixed" | "dynamic"];
83
+ row_count: [number, "fixed" | "dynamic"];
84
+ latex_delimiters: { left: string; right: string; display: boolean }[];
85
+ components?: Record<string, any>;
86
+ editable?: boolean;
87
+ wrap?: boolean;
88
+ root: string;
89
+ i18n: I18nFormatter;
90
+ max_height?: number;
91
+ line_breaks?: boolean;
92
+ column_widths?: string[];
93
+ show_row_numbers?: boolean;
94
+ upload: Client["upload"];
95
+ stream_handler: Client["stream"];
96
+ buttons?: string[] | null;
97
+ value_is_output?: boolean;
98
+ max_chars?: number | undefined;
99
+ show_search?: "none" | "search" | "filter";
100
+ pinned_columns?: number;
101
+ static_columns?: (string | number)[];
102
+ fullscreen?: boolean;
103
+ display_value?: string[][] | null;
104
+ styling?: string[][] | null;
105
+ onchange?: (detail: DataframeValue) => void;
106
+ oninput?: () => void;
107
+ onselect?: (detail: SelectData) => void;
108
+ onedit?: (detail: EditData) => void;
109
+ onsearch?: (detail: string | null) => void;
110
+ onfullscreen?: () => void;
111
+ } = $props();
112
+
113
+ type GradioRow = Record<string, CellValue> & { _index: number };
114
+
115
+ // convert values[][] into tanstack row objects
116
+ let row_data: GradioRow[] = $derived(
117
+ (values ?? []).map((row, i) => {
118
+ const obj: GradioRow = { _index: i };
119
+ (row ?? []).forEach((val, j) => {
120
+ const dtype = Array.isArray(datatype) ? datatype[j] : datatype;
121
+ obj[`col_${j}`] = cast_value_to_type(val, dtype);
122
+ });
123
+ return obj;
124
+ })
125
+ );
126
+
127
+ let resolved_headers = $derived.by(() => {
128
+ let h = headers ?? [];
129
+ if (col_count[1] === "fixed" && h.length < col_count[0]) {
130
+ h = [
131
+ ...h,
132
+ ...Array(col_count[0] - h.length)
133
+ .fill(null)
134
+ .map((_, i) => `${i + h.length}`)
135
+ ];
136
+ }
137
+ if (!h.length) {
138
+ h = Array(col_count[0])
139
+ .fill(null)
140
+ .map((_, i) => `${i}`);
141
+ }
142
+ return h.map((v) => v ?? "");
143
+ });
144
+
145
+ let column_defs: ColumnDef<GradioRow, CellValue>[] = $derived(
146
+ resolved_headers.map((header_value, j) => ({
147
+ id: `col_${j}`,
148
+ accessorKey: `col_${j}`,
149
+ header: header_value,
150
+ size: column_widths[j] ? parseInt(column_widths[j]) || 150 : 150,
151
+ minSize: 45,
152
+ filterFn: gradio_filter_fn,
153
+ meta: {
154
+ colIndex: j,
155
+ datatype: Array.isArray(datatype) ? datatype[j] : datatype,
156
+ isStatic:
157
+ static_columns.includes(j) || static_columns.includes(header_value),
158
+ isPinned: j < pinned_columns
159
+ }
160
+ }))
161
+ );
162
+
163
+ let sorting: SortingState = $state([]);
164
+ let column_filters: ColumnFiltersState = $state([]);
165
+ let global_filter: string = $state("");
166
+ let column_pinning: ColumnPinningState = $derived({
167
+ left: column_defs.filter((_, i) => i < pinned_columns).map((c) => c.id!)
168
+ });
169
+
170
+ const table = createSvelteTable<GradioRow>({
171
+ get data() {
172
+ return row_data;
173
+ },
174
+ get columns() {
175
+ return column_defs;
176
+ },
177
+ state: {
178
+ get sorting() {
179
+ return sorting;
180
+ },
181
+ get columnFilters() {
182
+ return column_filters;
183
+ },
184
+ get globalFilter() {
185
+ return global_filter;
186
+ },
187
+ get columnPinning() {
188
+ return column_pinning;
189
+ }
190
+ },
191
+ onSortingChange: (updater) => {
192
+ sorting = typeof updater === "function" ? updater(sorting) : updater;
193
+ },
194
+ onColumnFiltersChange: (updater) => {
195
+ column_filters =
196
+ typeof updater === "function" ? updater(column_filters) : updater;
197
+ },
198
+ onGlobalFilterChange: (updater) => {
199
+ global_filter =
200
+ typeof updater === "function" ? updater(global_filter) : updater;
201
+ },
202
+ getCoreRowModel: getCoreRowModel(),
203
+ getSortedRowModel: getSortedRowModel(),
204
+ getFilteredRowModel: getFilteredRowModel(),
205
+ globalFilterFn: "includesString",
206
+ enableSorting: true,
207
+ enableMultiSort: true,
208
+ maxMultiSortColCount: 3
209
+ });
210
+
211
+ let rows = $derived(table.getRowModel().rows);
212
+ let header_groups = $derived(table.getHeaderGroups());
213
+
214
+ let scroll_container: HTMLDivElement;
215
+
216
+ const virtualizer = createSvelteVirtualizer<
217
+ HTMLDivElement,
218
+ HTMLTableRowElement
219
+ >({
220
+ get count() {
221
+ return rows.length;
222
+ },
223
+ getScrollElement: () => scroll_container,
224
+ estimateSize: () => 35,
225
+ overscan: 10,
226
+ measureElement: (el, _entry, instance) => {
227
+ const h = el.getBoundingClientRect().height;
228
+ if (h > 0) return h;
229
+
230
+ const idx = el.getAttribute("data-index");
231
+ if (idx != null) {
232
+ const cached = (instance as any).itemSizeCache?.get(Number(idx));
233
+ if (typeof cached === "number") return cached;
234
+ }
235
+ return 35;
236
+ }
237
+ });
238
+
239
+ let virtual_items = $derived(virtualizer.virtualItems());
240
+ let total_size = $derived(virtualizer.totalSize());
241
+
242
+ let selected_cells: CellCoordinate[] = $state([]);
243
+ let selected: CellCoordinate | false = $state(false);
244
+ let editing: CellCoordinate | false = $state(false);
245
+ let header_edit: number | false = $state(false);
246
+ let selected_header: number | false = $state(false);
247
+ let active_cell_menu: {
248
+ row: number;
249
+ col: number;
250
+ x: number;
251
+ y: number;
252
+ } | null = $state(null);
253
+ let active_header_menu: { col: number; x: number; y: number } | null =
254
+ $state(null);
255
+ let copy_flash = $state(false);
256
+ let is_dragging = $state(false);
257
+ let show_scroll_button = $state(false);
258
+ let dragging = $state(false); // file drag
259
+
260
+ let parent: HTMLDivElement;
261
+
262
+ function get_dtype(col: number): Datatype {
263
+ return Array.isArray(datatype) ? (datatype[col] ?? "str") : datatype;
264
+ }
265
+
266
+ function get_display_value(row: number, col: number): string {
267
+ if (display_value?.[row]?.[col] !== undefined)
268
+ return display_value[row][col];
269
+ return String(values?.[row]?.[col] ?? "");
270
+ }
271
+
272
+ function get_styling(row: number, col: number): string {
273
+ return styling?.[row]?.[col] ?? "";
274
+ }
275
+
276
+ function push_change(
277
+ new_values?: CellValue[][],
278
+ new_headers?: (string | null)[]
279
+ ): void {
280
+ onchange?.({
281
+ data: new_values ?? values,
282
+ headers: (new_headers ?? resolved_headers) as string[],
283
+ metadata: null
284
+ });
285
+ if (!value_is_output) oninput?.();
286
+ value_is_output = false;
287
+ }
288
+
289
+ function handle_cell_click(
290
+ event: MouseEvent,
291
+ row: number,
292
+ col: number
293
+ ): void {
294
+ event.preventDefault();
295
+ event.stopPropagation();
296
+
297
+ const coord: CellCoordinate = [row, col];
298
+ if (event.shiftKey && selected) {
299
+ // range select
300
+ const [r1, c1] = selected;
301
+ const [r2, c2] = coord;
302
+ const new_cells: CellCoordinate[] = [];
303
+ for (let r = Math.min(r1, r2); r <= Math.max(r1, r2); r++) {
304
+ for (let c = Math.min(c1, c2); c <= Math.max(c1, c2); c++) {
305
+ new_cells.push([r, c]);
306
+ }
307
+ }
308
+ selected_cells = new_cells;
309
+ } else if (event.metaKey || event.ctrlKey) {
310
+ // toggle select
311
+ const exists = selected_cells.some(([r, c]) => r === row && c === col);
312
+ selected_cells = exists
313
+ ? selected_cells.filter(([r, c]) => !(r === row && c === col))
314
+ : [...selected_cells, coord];
315
+ } else {
316
+ selected_cells = [coord];
317
+ }
318
+
319
+ selected = coord;
320
+ header_edit = false;
321
+ selected_header = false;
322
+ active_cell_menu = null;
323
+ active_header_menu = null;
324
+
325
+ // click selects, does NOT enter edit mode (double-click or typing does)
326
+ editing = false;
327
+
328
+ onselect?.({
329
+ index: coord,
330
+ value: values?.[row]?.[col],
331
+ row_value: values?.[row] ?? [],
332
+ col_value: values?.map((r) => r[col]) ?? []
333
+ } as any);
334
+
335
+ tick().then(() => parent?.focus());
336
+ }
337
+
338
+ function handle_cell_dblclick(
339
+ event: MouseEvent,
340
+ row: number,
341
+ col: number
342
+ ): void {
343
+ event.preventDefault();
344
+ event.stopPropagation();
345
+ if (!editable) return;
346
+ const col_is_static =
347
+ static_columns.includes(col) ||
348
+ static_columns.includes(resolved_headers[col]);
349
+ if (!col_is_static) {
350
+ editing = [row, col];
351
+ }
352
+ }
353
+
354
+ function handle_blur(detail: {
355
+ blur_event: FocusEvent;
356
+ coords: [number, number];
357
+ }): void {
358
+ const { coords } = detail;
359
+ const input_el = detail.blur_event.target as HTMLTextAreaElement;
360
+ if (!input_el || input_el.value === undefined) return;
361
+
362
+ const [row, col] = coords;
363
+ const old_value = values?.[row]?.[col];
364
+ const new_value = input_el.value;
365
+
366
+ if (String(old_value) !== String(new_value)) {
367
+ const new_values = values.map((r) => [...r]);
368
+ new_values[row][col] = new_value;
369
+ values = new_values;
370
+
371
+ onedit?.({
372
+ index: [row, col],
373
+ value: new_value,
374
+ previous_value: String(old_value ?? "")
375
+ });
376
+ push_change(new_values);
377
+ }
378
+ }
379
+
380
+ function handle_header_click(event: MouseEvent, col: number): void {
381
+ if (event.target instanceof HTMLAnchorElement) return;
382
+ event.preventDefault();
383
+ event.stopPropagation();
384
+ if (!editable) return;
385
+
386
+ editing = false;
387
+ selected = false;
388
+ selected_cells = [];
389
+ active_cell_menu = null;
390
+ active_header_menu = null;
391
+ selected_header = col;
392
+ header_edit = editable ? col : false;
393
+ parent?.focus();
394
+ }
395
+
396
+ function end_header_edit(key: string): void {
397
+ if (["Escape", "Enter", "Tab"].includes(key)) {
398
+ header_edit = false;
399
+ parent?.focus();
400
+ }
401
+ }
402
+
403
+ function toggle_header_menu(event: MouseEvent, col: number): void {
404
+ event.stopPropagation();
405
+ if (active_header_menu?.col === col) {
406
+ active_header_menu = null;
407
+ } else {
408
+ const th = (event.target as HTMLElement).closest("th");
409
+ if (th) {
410
+ const rect = th.getBoundingClientRect();
411
+ active_header_menu = { col, x: rect.right, y: rect.bottom };
412
+ }
413
+ }
414
+ }
415
+
416
+ function handle_sort(col: number, direction: SortDirection): void {
417
+ const col_id = `col_${col}`;
418
+ const desc = direction === "desc";
419
+ // if already sorted this way, remove it
420
+ const existing = sorting.findIndex((s) => s.id === col_id);
421
+ if (existing >= 0 && sorting[existing].desc === desc) {
422
+ sorting = sorting.filter((s) => s.id !== col_id);
423
+ } else {
424
+ sorting = [
425
+ ...sorting.filter((s) => s.id !== col_id),
426
+ { id: col_id, desc }
427
+ ].slice(-3);
428
+ }
429
+ }
430
+
431
+ function clear_sort(): void {
432
+ sorting = [];
433
+ }
434
+
435
+ function handle_filter(
436
+ col: number,
437
+ dtype: FilterDatatype,
438
+ filter: string,
439
+ fvalue: string
440
+ ): void {
441
+ const col_id = `col_${col}`;
442
+ const existing = column_filters.findIndex((f) => f.id === col_id);
443
+ if (existing >= 0) {
444
+ column_filters = column_filters.filter((f) => f.id !== col_id);
445
+ } else {
446
+ column_filters = [
447
+ ...column_filters,
448
+ { id: col_id, value: { dtype, filter, value: fvalue } }
449
+ ];
450
+ }
451
+ }
452
+
453
+ function clear_filter(): void {
454
+ column_filters = [];
455
+ }
456
+
457
+ function handle_search(query: string | null): void {
458
+ global_filter = query ?? "";
459
+ onsearch?.(query);
460
+ }
461
+
462
+ function add_row(index?: number): void {
463
+ if (row_count[1] !== "dynamic") return;
464
+ const col_len = values[0]?.length || resolved_headers.length || 1;
465
+ const new_row: CellValue[] = Array(col_len).fill("");
466
+ const new_values = [...values];
467
+ if (index !== undefined) {
468
+ new_values.splice(index, 0, new_row);
469
+ } else {
470
+ new_values.push(new_row);
471
+ }
472
+ values = new_values;
473
+ push_change(new_values);
474
+ selected = [index ?? new_values.length - 1, 0];
475
+ parent?.focus();
476
+ }
477
+
478
+ function add_col(index?: number): void {
479
+ if (col_count[1] !== "dynamic") return;
480
+ const new_headers = [
481
+ ...(headers ?? []),
482
+ `Header ${(headers?.length ?? 0) + 1}`
483
+ ];
484
+ const new_values = values.map((row) => [...row, ""]);
485
+ if (index !== undefined) {
486
+ new_headers.splice(index, 0, new_headers.pop()!);
487
+ new_values.forEach((row) => row.splice(index, 0, row.pop()!));
488
+ }
489
+ values = new_values;
490
+ headers = new_headers;
491
+ push_change(new_values, new_headers);
492
+ parent?.focus();
493
+ }
494
+
495
+ function delete_row_at(index: number): void {
496
+ if (values.length <= 1) return;
497
+ values = [...values.slice(0, index), ...values.slice(index + 1)];
498
+ push_change(values);
499
+ active_cell_menu = null;
500
+ active_header_menu = null;
501
+ }
502
+
503
+ function delete_col_at(index: number): void {
504
+ if (col_count[1] !== "dynamic") return;
505
+ if ((values[0]?.length ?? 0) <= 1) return;
506
+ values = values.map((row) => [
507
+ ...row.slice(0, index),
508
+ ...row.slice(index + 1)
509
+ ]);
510
+ headers = [
511
+ ...(headers ?? []).slice(0, index),
512
+ ...(headers ?? []).slice(index + 1)
513
+ ];
514
+ push_change(values, headers as string[]);
515
+ active_cell_menu = null;
516
+ active_header_menu = null;
517
+ selected = false;
518
+ selected_cells = [];
519
+ editing = false;
520
+ }
521
+
522
+ function add_row_at(index: number, position: "above" | "below"): void {
523
+ add_row(position === "above" ? index : index + 1);
524
+ active_cell_menu = null;
525
+ }
526
+
527
+ function add_col_at(index: number, position: "left" | "right"): void {
528
+ add_col(position === "left" ? index : index + 1);
529
+ active_cell_menu = null;
530
+ }
531
+
532
+ // function handle_select_all(col: number, checked: boolean): void {
533
+ // values = values.map((row) => {
534
+ // const new_row = [...row];
535
+ // new_row[col] = checked;
536
+ // return new_row;
537
+ // });
538
+ // push_change(values);
539
+ // }
540
+
541
+ function commit_filter(): void {
542
+ if (!global_filter || show_search !== "filter") return;
543
+ // get the filtered rows from tanstack and push as new values
544
+ const filtered_values = rows.map((row) => {
545
+ const original_idx = row.original._index;
546
+ return values[original_idx];
547
+ });
548
+ values = filtered_values;
549
+ global_filter = "";
550
+ push_change(filtered_values);
551
+ }
552
+
553
+ async function handle_copy(): Promise<void> {
554
+ const data_for_copy = values.map((row) =>
555
+ row.map((val, j) => ({ id: `${j}`, value: val }))
556
+ );
557
+ const cells_to_copy = selected_cells.length > 0 ? selected_cells : null;
558
+ await copy_table_data(data_for_copy, cells_to_copy);
559
+ copy_flash = true;
560
+ setTimeout(() => (copy_flash = false), 800);
561
+ }
562
+
563
+ function handle_click_outside(event: Event): void {
564
+ if (handle_click_outside_util(event, parent)) {
565
+ selected_cells = [];
566
+ selected = false;
567
+ editing = false;
568
+ header_edit = false;
569
+ selected_header = false;
570
+ active_cell_menu = null;
571
+ active_header_menu = null;
572
+ }
573
+ }
574
+
575
+ function handle_keydown(e: KeyboardEvent): void {
576
+ if (!selected && selected_header === false) return;
577
+
578
+ const num_rows = rows.length;
579
+ const num_cols = resolved_headers.length;
580
+
581
+ if (selected) {
582
+ const [row, col] = selected;
583
+
584
+ switch (e.key) {
585
+ case "ArrowUp":
586
+ e.preventDefault();
587
+ if (row > 0) {
588
+ selected = [row - 1, col];
589
+ selected_cells = [selected];
590
+ editing = false;
591
+ virtualizer.instance.scrollToIndex(row - 1, { align: "auto" });
592
+ }
593
+ break;
594
+ case "ArrowDown":
595
+ e.preventDefault();
596
+ if (row < num_rows - 1) {
597
+ selected = [row + 1, col];
598
+ selected_cells = [selected];
599
+ editing = false;
600
+ virtualizer.instance.scrollToIndex(row + 1, { align: "auto" });
601
+ }
602
+ break;
603
+ case "ArrowLeft":
604
+ e.preventDefault();
605
+ if (col > 0) {
606
+ selected = [row, col - 1];
607
+ selected_cells = [selected];
608
+ editing = false;
609
+ }
610
+ break;
611
+ case "ArrowRight":
612
+ e.preventDefault();
613
+ if (col < num_cols - 1) {
614
+ selected = [row, col + 1];
615
+ selected_cells = [selected];
616
+ editing = false;
617
+ }
618
+ break;
619
+ case "Tab": {
620
+ e.preventDefault();
621
+ const was_editing = !!editing;
622
+ if (e.shiftKey) {
623
+ if (col > 0) selected = [row, col - 1];
624
+ else if (row > 0) selected = [row - 1, num_cols - 1];
625
+ } else {
626
+ if (col < num_cols - 1) selected = [row, col + 1];
627
+ else if (row < num_rows - 1) selected = [row + 1, 0];
628
+ }
629
+ selected_cells = [selected];
630
+ if (was_editing) {
631
+ const tab_col = (selected as CellCoordinate)[1];
632
+ const tab_static =
633
+ static_columns.includes(tab_col) ||
634
+ static_columns.includes(resolved_headers[tab_col]);
635
+ editing = editable && !tab_static ? selected : false;
636
+ } else {
637
+ editing = false;
638
+ }
639
+ if (!editing) tick().then(() => parent?.focus());
640
+ break;
641
+ }
642
+ case "Enter":
643
+ if (editing && e.shiftKey) {
644
+ // shift+enter inserts newline in textarea — don't intercept
645
+ return;
646
+ }
647
+ e.preventDefault();
648
+ if (editing) {
649
+ editing = false;
650
+ if (row < num_rows - 1) {
651
+ selected = [row + 1, col];
652
+ selected_cells = [selected];
653
+ }
654
+ tick().then(() => parent?.focus());
655
+ } else if (editable) {
656
+ const enter_static =
657
+ static_columns.includes(col) ||
658
+ static_columns.includes(resolved_headers[col]);
659
+ if (!enter_static) {
660
+ editing = [row, col];
661
+ }
662
+ }
663
+ break;
664
+ case "Escape":
665
+ editing = false;
666
+ tick().then(() => parent?.focus());
667
+ break;
668
+ case "Delete":
669
+ case "Backspace":
670
+ if (!editing && editable) {
671
+ e.preventDefault();
672
+ const new_values = values.map((r) => [...r]);
673
+ selected_cells.forEach(([r, c]) => {
674
+ if (!static_columns.includes(c)) {
675
+ new_values[r][c] = "";
676
+ }
677
+ });
678
+ values = new_values;
679
+ push_change(new_values);
680
+ }
681
+ break;
682
+ default:
683
+ // start editing on printable character
684
+ if (
685
+ editable &&
686
+ !editing &&
687
+ e.key.length === 1 &&
688
+ !e.ctrlKey &&
689
+ !e.metaKey &&
690
+ !static_columns.includes(col)
691
+ ) {
692
+ editing = [row, col];
693
+ }
694
+ break;
695
+ }
696
+
697
+ if ((e.ctrlKey || e.metaKey) && e.key === "c") {
698
+ handle_copy();
699
+ }
700
+ }
701
+ }
702
+
703
+ function handle_scroll(): void {
704
+ if (scroll_container) {
705
+ show_scroll_button = scroll_container.scrollTop > 100;
706
+ }
707
+ }
708
+
709
+ function scroll_to_top(): void {
710
+ scroll_container?.scrollTo({ top: 0 });
711
+ }
712
+
713
+ function toggle_cell_menu(event: MouseEvent, row: number, col: number): void {
714
+ event.stopPropagation();
715
+ if (active_cell_menu?.row === row && active_cell_menu.col === col) {
716
+ active_cell_menu = null;
717
+ } else {
718
+ const cell = (event.target as HTMLElement).closest(".body-cell, td");
719
+ if (cell) {
720
+ const rect = cell.getBoundingClientRect();
721
+ active_cell_menu = { row, col, x: rect.right, y: rect.bottom };
722
+ }
723
+ }
724
+ }
725
+
726
+ function on_file_upload(file_data: any): void {
727
+ handle_file_upload(
728
+ typeof file_data === "string" ? file_data : (file_data?.data ?? ""),
729
+ (head) => {
730
+ headers = head.map((h: any) => h ?? "");
731
+ return (headers as string[]).map((h: string, i: number) => ({
732
+ id: `h_${i}`,
733
+ value: h
734
+ }));
735
+ },
736
+ (vals) => {
737
+ values = vals;
738
+ push_change(vals, headers as string[]);
739
+ }
740
+ );
741
+ }
742
+
743
+ onMount(() => {
744
+ document.addEventListener("click", handle_click_outside);
745
+ return () => document.removeEventListener("click", handle_click_outside);
746
+ });
747
+
748
+ function measure_row(node: HTMLElement) {
749
+ tick().then(() => {
750
+ console.log("measuring");
751
+ virtualizer.instance.measureElement(node as any);
752
+ });
753
+
754
+ return {
755
+ destroy() {}
756
+ };
757
+ }
758
+
759
+ let header_row_el: HTMLTableRowElement;
760
+ let header_table_el: HTMLTableElement;
761
+
762
+ const measurement = create_column_measurement({
763
+ header_row_el: () => header_row_el,
764
+ header_table_el: () => header_table_el,
765
+ resolved_headers: () => resolved_headers,
766
+ row_data: () => row_data,
767
+ show_row_numbers: () => show_row_numbers,
768
+ column_widths: () => column_widths,
769
+ on_resize: undefined
770
+ });
771
+
772
+ let disable_scroll = $derived(
773
+ active_cell_menu !== null || active_header_menu !== null
774
+ );
775
+ let selected_index = $derived(selected !== false ? selected[0] : false);
776
+
777
+ $effect(() => {
778
+ if (typeof selected_index === "number") {
779
+ virtualizer.instance.scrollToIndex(selected_index, { align: "auto" });
780
+ }
781
+ });
782
+
783
+ function get_sort_info(col: number): {
784
+ direction: SortDirection | null;
785
+ priority: number | null;
786
+ } {
787
+ const col_id = `col_${col}`;
788
+ const idx = sorting.findIndex((s) => s.id === col_id);
789
+ if (idx === -1) return { direction: null, priority: null };
790
+ return { direction: sorting[idx].desc ? "desc" : "asc", priority: idx + 1 };
791
+ }
792
+
793
+ function get_filter_active(col: number): boolean {
794
+ return column_filters.some((f) => f.id === `col_${col}`);
795
+ }
796
+ </script>
797
+
798
+ <svelte:window
799
+ onresize={() => {
800
+ active_cell_menu = null;
801
+ active_header_menu = null;
802
+ }}
803
+ />
804
+
805
+ <div class="table-container" class:fullscreen>
806
+ {#if (label && label.length !== 0 && show_label) || (buttons === null ? true : buttons.includes("fullscreen")) || (buttons === null ? true : buttons.includes("copy")) || show_search !== "none"}
807
+ <div class="header-row">
808
+ {#if label && label.length !== 0 && show_label}
809
+ <div class="label"><p>{label}</p></div>
810
+ {/if}
811
+ <Toolbar
812
+ show_fullscreen_button={buttons === null
813
+ ? true
814
+ : buttons.includes("fullscreen")}
815
+ {fullscreen}
816
+ on_copy={handle_copy}
817
+ show_copy_button={buttons === null ? true : buttons.includes("copy")}
818
+ {show_search}
819
+ onsearch={(query) => handle_search(query)}
820
+ {onfullscreen}
821
+ on_commit_filter={commit_filter}
822
+ current_search_query={global_filter || null}
823
+ />
824
+ </div>
825
+ {/if}
826
+
827
+ <div
828
+ bind:this={parent}
829
+ class="table-wrap"
830
+ class:dragging={is_dragging}
831
+ class:no-wrap={!wrap}
832
+ class:menu-open={active_cell_menu || active_header_menu}
833
+ onkeydown={handle_keydown}
834
+ role="grid"
835
+ tabindex="0"
836
+ >
837
+ <Upload
838
+ {upload}
839
+ {stream_handler}
840
+ flex={false}
841
+ center={false}
842
+ boundedheight={false}
843
+ disable_click={true}
844
+ {root}
845
+ onload={on_file_upload}
846
+ bind:dragging
847
+ aria_label={i18n("dataframe.drop_to_upload")}
848
+ >
849
+ <div
850
+ class="virtual-table-viewport"
851
+ class:disable-scroll={disable_scroll}
852
+ bind:this={scroll_container}
853
+ onscroll={handle_scroll}
854
+ style="max-height: {max_height}px;"
855
+ role="grid"
856
+ >
857
+ {#if label && label.length !== 0}
858
+ <span class="sr-only">{label}</span>
859
+ {/if}
860
+ <!-- header row: uses table layout to auto-size columns by content -->
861
+ <table class="header-table" bind:this={header_table_el}>
862
+ <thead>
863
+ <tr bind:this={header_row_el}>
864
+ {#if show_row_numbers}
865
+ <th class="row-number-header">&nbsp;</th>
866
+ {/if}
867
+ {#each header_groups as headerGroup (headerGroup.id)}
868
+ {#each headerGroup.headers as header (header.id)}
869
+ {@const col_idx =
870
+ (header.column.columnDef.meta as any)?.colIndex ?? 0}
871
+ <HeaderCell
872
+ value={String(header.column.columnDef.header ?? "")}
873
+ {col_idx}
874
+ is_editing={header_edit === col_idx}
875
+ is_selected={selected_header === col_idx}
876
+ is_static={!!(header.column.columnDef.meta as any)
877
+ ?.isStatic}
878
+ sort_direction={get_sort_info(col_idx).direction}
879
+ sort_priority={get_sort_info(col_idx).priority}
880
+ multi_sort={sorting.length > 1}
881
+ is_filtered={get_filter_active(col_idx)}
882
+ show_menu_button={col_count[1] === "dynamic"}
883
+ is_first_column={col_idx === 0 && !show_row_numbers}
884
+ {latex_delimiters}
885
+ {line_breaks}
886
+ {editable}
887
+ {max_chars}
888
+ {i18n}
889
+ onclick={handle_header_click}
890
+ on_menu_click={toggle_header_menu}
891
+ on_end_edit={end_header_edit}
892
+ />
893
+ {/each}
894
+ {/each}
895
+ </tr>
896
+ </thead>
897
+ <!-- hidden sizing row: lets table-layout:auto consider body content widths too -->
898
+ <tbody class="sizing-body" aria-hidden="true">
899
+ {#if rows.length > 0}
900
+ {@const sizing_row = rows.reduce((widest, row) => {
901
+ const cells = row.getVisibleCells();
902
+ cells.forEach((cell, i) => {
903
+ const val = String(cell.getValue() ?? "");
904
+ if (!widest[i] || val.length > widest[i].length) {
905
+ widest[i] = val;
906
+ }
907
+ });
908
+ return widest;
909
+ }, [] as string[])}
910
+ <tr>
911
+ {#if show_row_numbers}
912
+ <td class="row-number-cell">{rows.length}</td>
913
+ {/if}
914
+ {#each sizing_row as val, ci}
915
+ {@const dtype = get_dtype(ci)}
916
+ <td
917
+ ><div class="cell-wrap">
918
+ {#if dtype === "html" || dtype === "markdown"}{@html val}{:else}{val}{/if}
919
+ </div></td
920
+ >
921
+ {/each}
922
+ </tr>
923
+ {/if}
924
+ </tbody>
925
+ </table>
926
+
927
+ <!-- table body: absolutely positioned rows (standard tanstack virtual pattern) -->
928
+ <div
929
+ class="virtual-body"
930
+ style="height: {total_size}px; position: relative; flex-shrink: 0; width: {measurement.total_header_width
931
+ ? `${measurement.total_header_width}px`
932
+ : '100%'};"
933
+ >
934
+ {#each virtual_items as virtual_row (virtual_row.key)}
935
+ {@const row = rows[virtual_row.index]}
936
+ {@const row_idx = row?.original._index ?? virtual_row.index}
937
+ {#if row}
938
+ <div
939
+ class="virtual-row"
940
+ class:row-odd={virtual_row.index % 2 !== 0}
941
+ data-index={virtual_row.index}
942
+ style="position: absolute; top: 0; left: 0; width: 100%; transform: translateY({virtual_row.start}px);{selected_cells.some(
943
+ ([r]) => r === row_idx
944
+ )
945
+ ? ' z-index: 3;'
946
+ : ''}"
947
+ use:measure_row={row}
948
+ >
949
+ {#if show_row_numbers}
950
+ <div
951
+ class="row-number-cell"
952
+ data-row={row_idx}
953
+ data-col="row-number"
954
+ style="flex: 0 0 {measurement.row_num_width}px; width: {measurement.row_num_width}px;"
955
+ >
956
+ {row_idx + 1}
957
+ </div>
958
+ {/if}
959
+ {#each row.getVisibleCells() as cell, ci (cell.id)}
960
+ {@const col_idx =
961
+ (cell.column.columnDef.meta as any)?.colIndex ?? 0}
962
+ {@const is_sel = is_cell_in_selection(
963
+ [row_idx, col_idx],
964
+ selected_cells
965
+ )}
966
+ <DataCell
967
+ value={cell.getValue() as CellValue}
968
+ display_value={get_display_value(row_idx, col_idx)}
969
+ datatype={get_dtype(col_idx)}
970
+ {row_idx}
971
+ {col_idx}
972
+ col_style={measurement.get_col_style(ci)}
973
+ cell_style={get_styling(row_idx, col_idx)}
974
+ selection_classes={is_cell_selected(
975
+ [row_idx, col_idx],
976
+ selected_cells
977
+ )}
978
+ is_editing={!!(
979
+ editing &&
980
+ editing[0] === row_idx &&
981
+ editing[1] === col_idx
982
+ )}
983
+ is_flash={copy_flash && is_sel}
984
+ is_static={!!(cell.column.columnDef.meta as any)?.isStatic}
985
+ show_menu_button={editable &&
986
+ selected_cells.length === 1 &&
987
+ selected_cells[0][0] === row_idx &&
988
+ selected_cells[0][1] === col_idx}
989
+ show_selection_buttons={selected_cells.length === 1 &&
990
+ selected_cells[0][0] === row_idx &&
991
+ selected_cells[0][1] === col_idx}
992
+ is_first_column={ci === 0 && !show_row_numbers}
993
+ {latex_delimiters}
994
+ {line_breaks}
995
+ {editable}
996
+ {max_chars}
997
+ {i18n}
998
+ {components}
999
+ {is_dragging}
1000
+ wrap_text={wrap}
1001
+ onmousedown={(e) => handle_cell_click(e, row_idx, col_idx)}
1002
+ ondblclick={(e) =>
1003
+ handle_cell_dblclick(e, row_idx, col_idx)}
1004
+ oncontextmenu={(e) => {
1005
+ e.preventDefault();
1006
+ toggle_cell_menu(e, row_idx, col_idx);
1007
+ }}
1008
+ onblur={handle_blur}
1009
+ on_menu_click={(e) => toggle_cell_menu(e, row_idx, col_idx)}
1010
+ on_select_column={(c) => {
1011
+ selected_cells = rows.map(
1012
+ (_, r) => [r, c] as CellCoordinate
1013
+ );
1014
+ selected = selected_cells[0];
1015
+ }}
1016
+ on_select_row={(r) => {
1017
+ selected_cells = resolved_headers.map(
1018
+ (_, c) => [r, c] as CellCoordinate
1019
+ );
1020
+ selected = selected_cells[0];
1021
+ }}
1022
+ />
1023
+ {/each}
1024
+ </div>
1025
+ {/if}
1026
+ {/each}
1027
+ </div>
1028
+ </div>
1029
+ </Upload>
1030
+
1031
+ {#if show_scroll_button}
1032
+ <button class="scroll-top-button" onclick={scroll_to_top}>&uarr;</button>
1033
+ {/if}
1034
+ </div>
1035
+ </div>
1036
+
1037
+ {#if active_cell_menu || active_header_menu}
1038
+ <CellMenu
1039
+ x={active_cell_menu?.x ?? active_header_menu?.x ?? 0}
1040
+ y={active_cell_menu?.y ?? active_header_menu?.y ?? 0}
1041
+ row={active_header_menu ? -1 : (active_cell_menu?.row ?? 0)}
1042
+ {col_count}
1043
+ {row_count}
1044
+ on_add_row_above={() => add_row_at(active_cell_menu?.row ?? -1, "above")}
1045
+ on_add_row_below={() => add_row_at(active_cell_menu?.row ?? -1, "below")}
1046
+ on_add_column_left={() =>
1047
+ add_col_at(
1048
+ active_cell_menu?.col ?? active_header_menu?.col ?? -1,
1049
+ "left"
1050
+ )}
1051
+ on_add_column_right={() =>
1052
+ add_col_at(
1053
+ active_cell_menu?.col ?? active_header_menu?.col ?? -1,
1054
+ "right"
1055
+ )}
1056
+ on_delete_row={() => delete_row_at(active_cell_menu?.row ?? -1)}
1057
+ on_delete_col={() =>
1058
+ delete_col_at(active_cell_menu?.col ?? active_header_menu?.col ?? -1)}
1059
+ {editable}
1060
+ can_delete_rows={!active_header_menu && values.length > 1 && editable}
1061
+ can_delete_cols={values.length > 0 &&
1062
+ (values[0]?.length ?? 0) > 1 &&
1063
+ editable}
1064
+ {i18n}
1065
+ on_sort={active_header_menu
1066
+ ? (direction) => {
1067
+ handle_sort(active_header_menu!.col, direction);
1068
+ active_header_menu = null;
1069
+ }
1070
+ : undefined}
1071
+ on_clear_sort={active_header_menu
1072
+ ? () => {
1073
+ clear_sort();
1074
+ active_header_menu = null;
1075
+ }
1076
+ : undefined}
1077
+ sort_direction={active_header_menu
1078
+ ? get_sort_info(active_header_menu.col).direction
1079
+ : null}
1080
+ sort_priority={active_header_menu
1081
+ ? get_sort_info(active_header_menu.col).priority
1082
+ : null}
1083
+ on_filter={active_header_menu
1084
+ ? (dtype, filter, fvalue) => {
1085
+ handle_filter(active_header_menu!.col, dtype, filter, fvalue);
1086
+ active_header_menu = null;
1087
+ }
1088
+ : undefined}
1089
+ on_clear_filter={active_header_menu
1090
+ ? () => {
1091
+ clear_filter();
1092
+ active_header_menu = null;
1093
+ }
1094
+ : undefined}
1095
+ filter_active={active_header_menu
1096
+ ? get_filter_active(active_header_menu.col)
1097
+ : null}
1098
+ />
1099
+ {/if}
1100
+
1101
+ {#if values.length === 0 && editable && row_count[1] === "dynamic"}
1102
+ <EmptyRowButton on_click={() => add_row()} />
1103
+ {/if}
1104
+
1105
+ <style>
1106
+ .table-container {
1107
+ display: flex;
1108
+ flex-direction: column;
1109
+ gap: var(--size-2);
1110
+ position: relative;
1111
+ max-width: 100%;
1112
+ overflow: hidden;
1113
+ }
1114
+
1115
+ .table-container.fullscreen {
1116
+ padding: var(--size-4);
1117
+ height: 100%;
1118
+ box-sizing: border-box;
1119
+ }
1120
+
1121
+ .table-container.fullscreen .table-wrap {
1122
+ flex: 1 1 auto;
1123
+ min-height: 0;
1124
+ display: flex;
1125
+ flex-direction: column;
1126
+ }
1127
+
1128
+ .table-container.fullscreen .table-wrap > :global(*) {
1129
+ flex: 1 1 auto;
1130
+ min-height: 0;
1131
+ display: flex;
1132
+ flex-direction: column;
1133
+ }
1134
+
1135
+ .table-container.fullscreen .virtual-table-viewport {
1136
+ max-height: none !important;
1137
+ flex: 1 1 auto;
1138
+ min-height: 0;
1139
+ }
1140
+
1141
+ .table-wrap {
1142
+ position: relative;
1143
+ transition: 150ms;
1144
+ width: 100%;
1145
+ }
1146
+
1147
+ /* Constrain Upload component wrapper */
1148
+ .table-wrap > :global(*) {
1149
+ max-width: 100%;
1150
+ }
1151
+
1152
+ .table-wrap.menu-open {
1153
+ overflow: hidden;
1154
+ }
1155
+
1156
+ .table-wrap:focus-within {
1157
+ outline: none;
1158
+ }
1159
+
1160
+ .table-wrap.dragging {
1161
+ cursor: crosshair !important;
1162
+ user-select: none;
1163
+ }
1164
+
1165
+ .table-wrap.dragging * {
1166
+ cursor: crosshair !important;
1167
+ user-select: none;
1168
+ }
1169
+
1170
+ .table-wrap > :global(button) {
1171
+ border: 1px solid var(--border-color-primary);
1172
+ border-radius: var(--table-radius);
1173
+ overflow: hidden;
1174
+ }
1175
+
1176
+ /* Virtual scroll container */
1177
+ .virtual-table-viewport {
1178
+ display: flex;
1179
+ flex-direction: column;
1180
+ overflow: auto;
1181
+ position: relative;
1182
+ -webkit-overflow-scrolling: touch;
1183
+ min-width: 0;
1184
+ max-width: 100%;
1185
+ scrollbar-width: thin;
1186
+ scrollbar-color: rgba(128, 128, 128, 0.5) transparent;
1187
+ }
1188
+
1189
+ .virtual-table-viewport::-webkit-scrollbar {
1190
+ width: 4px;
1191
+ height: 4px;
1192
+ }
1193
+
1194
+ .virtual-table-viewport::-webkit-scrollbar-thumb {
1195
+ background-color: rgba(128, 128, 128, 0.5);
1196
+ border-radius: 4px;
1197
+ }
1198
+
1199
+ .virtual-table-viewport:hover {
1200
+ scrollbar-color: rgba(160, 160, 160, 0.7) transparent;
1201
+ }
1202
+
1203
+ .virtual-table-viewport.disable-scroll {
1204
+ overflow: hidden !important;
1205
+ }
1206
+
1207
+ /* Header table: auto-sizes columns by content, sticky */
1208
+ .header-table {
1209
+ width: 100%;
1210
+ color: var(--body-text-color);
1211
+ font-size: var(--input-text-size);
1212
+ line-height: var(--line-md);
1213
+ font-family: var(--font-mono);
1214
+ border-spacing: 0;
1215
+ border-collapse: separate;
1216
+ table-layout: auto;
1217
+ position: sticky;
1218
+ top: 0;
1219
+ z-index: 7;
1220
+ flex-shrink: 0;
1221
+ }
1222
+
1223
+ /* Hidden sizing row — visibility:collapse hides the row but keeps column width contribution */
1224
+ .sizing-body tr {
1225
+ visibility: collapse;
1226
+ }
1227
+
1228
+ .sizing-body td {
1229
+ padding: var(--size-2);
1230
+ border: none;
1231
+ white-space: nowrap;
1232
+ }
1233
+
1234
+ /* Virtual body */
1235
+ .virtual-body {
1236
+ box-sizing: border-box;
1237
+ }
1238
+
1239
+ .virtual-row {
1240
+ display: flex;
1241
+ align-items: stretch;
1242
+ background: var(--table-odd-background-fill);
1243
+
1244
+ text-align: left;
1245
+ font-size: var(--input-text-size);
1246
+ line-height: var(--line-md);
1247
+ font-family: var(--font-mono);
1248
+ color: var(--body-text-color);
1249
+ min-height: var(--size-9);
1250
+ }
1251
+
1252
+ .virtual-row:last-child {
1253
+ border-bottom: none;
1254
+ }
1255
+
1256
+ .virtual-row.row-odd {
1257
+ background: var(--table-even-background-fill);
1258
+ }
1259
+
1260
+ .virtual-row:hover {
1261
+ background: var(--table-row-focus);
1262
+ }
1263
+
1264
+ /* Cell content wrapper (used in sizing-body) */
1265
+ .cell-wrap {
1266
+ display: flex;
1267
+ align-items: center;
1268
+ justify-content: flex-start;
1269
+ outline: none;
1270
+ min-height: var(--size-9);
1271
+ position: relative;
1272
+ height: 100%;
1273
+ padding: var(--size-2);
1274
+ box-sizing: border-box;
1275
+ gap: var(--size-1);
1276
+ overflow: visible;
1277
+ min-width: 0;
1278
+ }
1279
+
1280
+ /* Row number cells */
1281
+ .row-number-header {
1282
+ text-align: center;
1283
+ padding: var(--size-1);
1284
+ min-width: var(--size-12);
1285
+ width: var(--size-12);
1286
+ font-weight: var(--weight-semibold);
1287
+ border-right: 1px solid var(--border-color-primary);
1288
+ background: var(--table-even-background-fill) !important;
1289
+ }
1290
+
1291
+ .row-number-cell {
1292
+ text-align: center;
1293
+ padding: var(--size-1);
1294
+ min-width: var(--size-12);
1295
+ width: var(--size-12);
1296
+ flex-shrink: 0;
1297
+ overflow: hidden;
1298
+ text-overflow: ellipsis;
1299
+ white-space: nowrap;
1300
+ font-weight: var(--weight-semibold);
1301
+ border-right: 1px solid var(--border-color-primary);
1302
+ display: flex;
1303
+ align-items: center;
1304
+ justify-content: center;
1305
+ }
1306
+
1307
+ .no-wrap {
1308
+ white-space: nowrap;
1309
+ }
1310
+
1311
+ div:not(.no-wrap) :global(td) {
1312
+ overflow-wrap: anywhere;
1313
+ }
1314
+
1315
+ div.no-wrap :global(td) {
1316
+ overflow-x: hidden;
1317
+ }
1318
+
1319
+ .header-row {
1320
+ display: flex;
1321
+ justify-content: flex-end;
1322
+ align-items: center;
1323
+ gap: var(--size-2);
1324
+ min-height: var(--size-6);
1325
+ flex-wrap: nowrap;
1326
+ width: 100%;
1327
+ }
1328
+
1329
+ .header-row .label {
1330
+ flex: 1 1 auto;
1331
+ margin-right: auto;
1332
+ font-family: var(--font-sans);
1333
+ }
1334
+
1335
+ .header-row .label p {
1336
+ margin: 0;
1337
+ color: var(--block-label-text-color);
1338
+ font-size: var(--block-label-text-size);
1339
+ line-height: var(--line-sm);
1340
+ }
1341
+
1342
+ .scroll-top-button {
1343
+ position: absolute;
1344
+ right: var(--size-4);
1345
+ bottom: var(--size-4);
1346
+ width: var(--size-8);
1347
+ height: var(--size-8);
1348
+ border-radius: var(--table-radius);
1349
+ background: var(--color-accent);
1350
+ color: white;
1351
+ border: none;
1352
+ cursor: pointer;
1353
+ display: flex;
1354
+ align-items: center;
1355
+ justify-content: center;
1356
+ font-size: var(--text-lg);
1357
+ z-index: 9;
1358
+ opacity: 0.5;
1359
+ }
1360
+
1361
+ .scroll-top-button:hover {
1362
+ opacity: 1;
1363
+ }
1364
+ </style>
6.11.1/dataframe/shared/Toolbar.svelte ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { Copy, Check } from "@gradio/icons";
3
+ import { FullscreenButton } from "@gradio/atoms";
4
+ import { IconButton } from "@gradio/atoms";
5
+
6
+ let {
7
+ show_fullscreen_button = false,
8
+ show_copy_button = false,
9
+ show_search = "none",
10
+ fullscreen = false,
11
+ on_copy,
12
+ on_commit_filter,
13
+ current_search_query = null,
14
+ onsearch,
15
+ onfullscreen
16
+ }: {
17
+ show_fullscreen_button?: boolean;
18
+ show_copy_button?: boolean;
19
+ show_search?: "none" | "search" | "filter";
20
+ fullscreen?: boolean;
21
+ on_copy: () => Promise<void>;
22
+ on_commit_filter: () => void;
23
+ current_search_query?: string | null;
24
+ onsearch?: (query: string | null) => void;
25
+ onfullscreen?: () => void;
26
+ } = $props();
27
+
28
+ let copied = $state(false);
29
+ let timer: ReturnType<typeof setTimeout>;
30
+ let input_value = $state("");
31
+
32
+ function handle_search_input(e: Event): void {
33
+ const target = e.target as HTMLTextAreaElement;
34
+ input_value = target.value;
35
+ const new_query = input_value || null;
36
+ if (current_search_query !== new_query) {
37
+ current_search_query = new_query;
38
+ onsearch?.(current_search_query);
39
+ }
40
+ }
41
+
42
+ function copy_feedback(): void {
43
+ copied = true;
44
+ if (timer) clearTimeout(timer);
45
+ timer = setTimeout(() => {
46
+ copied = false;
47
+ }, 2000);
48
+ }
49
+
50
+ async function handle_copy(): Promise<void> {
51
+ await on_copy();
52
+ copy_feedback();
53
+ }
54
+
55
+ $effect(() => {
56
+ return () => {
57
+ if (timer) clearTimeout(timer);
58
+ };
59
+ });
60
+ </script>
61
+
62
+ <div class="toolbar" role="toolbar" aria-label="Table actions">
63
+ <div class="toolbar-buttons">
64
+ {#if show_search !== "none"}
65
+ <div class="search-container">
66
+ <input
67
+ type="text"
68
+ value={current_search_query || ""}
69
+ oninput={handle_search_input}
70
+ placeholder={show_search === "filter" ? "Filter..." : "Search..."}
71
+ class="search-input"
72
+ class:filter-mode={show_search === "filter"}
73
+ title={`Enter text to ${show_search} the table`}
74
+ />
75
+ {#if current_search_query && show_search === "filter"}
76
+ <button
77
+ class="toolbar-button check-button"
78
+ onclick={on_commit_filter}
79
+ aria-label="Apply filter and update dataframe values"
80
+ title="Apply filter and update dataframe values"
81
+ >
82
+ <Check />
83
+ </button>
84
+ {/if}
85
+ </div>
86
+ {/if}
87
+ {#if show_copy_button}
88
+ <IconButton
89
+ Icon={copied ? Check : Copy}
90
+ label={copied ? "Copied to clipboard" : "Copy table data"}
91
+ onclick={handle_copy}
92
+ />
93
+ {/if}
94
+ {#if show_fullscreen_button}
95
+ <FullscreenButton {fullscreen} onclick={(_fs) => onfullscreen?.()} />
96
+ {/if}
97
+ </div>
98
+ </div>
99
+
100
+ <style>
101
+ .toolbar {
102
+ display: flex;
103
+ align-items: center;
104
+ gap: var(--size-2);
105
+ flex: 0 0 auto;
106
+ font-family: var(--font-sans);
107
+ }
108
+
109
+ .toolbar-buttons {
110
+ display: flex;
111
+ gap: var(--size-1);
112
+ flex-wrap: nowrap;
113
+ align-items: center;
114
+ }
115
+
116
+ .toolbar-button {
117
+ display: flex;
118
+ align-items: center;
119
+ justify-content: center;
120
+ width: var(--size-6);
121
+ height: var(--size-6);
122
+ padding: var(--size-1);
123
+ border: none;
124
+ border-radius: var(--radius-sm);
125
+ background: transparent;
126
+ color: var(--body-text-color-subdued);
127
+ cursor: pointer;
128
+ transition: all 0.2s;
129
+ }
130
+
131
+ .toolbar-button:hover {
132
+ background: var(--background-fill-secondary);
133
+ color: var(--body-text-color);
134
+ }
135
+
136
+ .toolbar-button :global(svg) {
137
+ width: var(--size-4);
138
+ height: var(--size-4);
139
+ }
140
+
141
+ .search-container {
142
+ position: relative;
143
+ }
144
+
145
+ .search-input {
146
+ width: var(--size-full);
147
+ height: var(--size-6);
148
+ padding: var(--size-2);
149
+ padding-right: var(--size-8);
150
+ border: 1px solid var(--border-color-primary);
151
+ border-radius: var(--table-radius);
152
+ font-size: var(--text-sm);
153
+ color: var(--body-text-color);
154
+ background: var(--background-fill-secondary);
155
+ transition: all 0.2s ease;
156
+ }
157
+
158
+ .search-input:hover {
159
+ border-color: var(--border-color-secondary);
160
+ background: var(--background-fill-primary);
161
+ }
162
+
163
+ .search-input:focus {
164
+ outline: none;
165
+ border-color: var(--color-accent);
166
+ background: var(--background-fill-primary);
167
+ box-shadow: 0 0 0 1px var(--color-accent);
168
+ }
169
+
170
+ .check-button {
171
+ position: absolute;
172
+ right: var(--size-1);
173
+ top: 50%;
174
+ transform: translateY(-50%);
175
+ background: var(--color-accent);
176
+ color: white;
177
+ border: none;
178
+ width: var(--size-4);
179
+ height: var(--size-4);
180
+ border-radius: var(--radius-sm);
181
+ display: flex;
182
+ align-items: center;
183
+ justify-content: center;
184
+ padding: var(--size-1);
185
+ }
186
+
187
+ .check-button :global(svg) {
188
+ width: var(--size-3);
189
+ height: var(--size-3);
190
+ }
191
+
192
+ .check-button:hover {
193
+ background: var(--color-accent-soft);
194
+ }
195
+
196
+ .toolbar-buttons :global(.icon-button) {
197
+ background: transparent !important;
198
+ height: var(--size-6);
199
+ width: var(--size-6);
200
+ }
201
+
202
+ .toolbar-buttons :global(.icon-button:hover) {
203
+ background: var(--background-fill-secondary) !important;
204
+ color: var(--body-text-color) !important;
205
+ border: 1px solid var(--border-color-primary);
206
+ border-radius: var(--radius-sm) !important;
207
+ }
208
+ </style>
6.11.1/dataframe/shared/column_measurement.svelte.ts ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * measures header cell positions/widths and provides inline styles
3
+ * for absolutely-positioned body cells to match.
4
+ */
5
+ export function create_column_measurement(opts: {
6
+ header_row_el: () => HTMLTableRowElement | undefined;
7
+ header_table_el: () => HTMLTableElement | undefined;
8
+ resolved_headers: () => string[];
9
+ row_data: () => any[];
10
+ show_row_numbers: () => boolean;
11
+ column_widths: () => string[];
12
+ on_resize?: () => void;
13
+ }): {
14
+ readonly col_widths: number[];
15
+ readonly col_lefts: number[];
16
+ readonly total_header_width: number;
17
+ readonly header_height: number;
18
+ readonly row_num_width: number;
19
+ get_col_style: (index: number) => string;
20
+ } {
21
+ let col_widths: number[] = $state([]);
22
+ let total_header_width: number = $state(0);
23
+ let header_height: number = $state(0);
24
+
25
+ // use offsets (not just widths) avoids accumulated subpixel rounding errors
26
+ let col_lefts: number[] = $state([]);
27
+
28
+ function measure(): void {
29
+ const current_row_el = opts.header_row_el();
30
+ const current_table_el = opts.header_table_el();
31
+ if (!current_row_el) return;
32
+
33
+ const cells = current_row_el.querySelectorAll<HTMLElement>(".header-cell");
34
+ const table_rect = current_table_el?.getBoundingClientRect();
35
+ const table_left = table_rect?.left ?? 0;
36
+
37
+ col_lefts = Array.from(cells).map(
38
+ (c) => c.getBoundingClientRect().left - table_left
39
+ );
40
+ col_widths = Array.from(cells).map((c) => c.getBoundingClientRect().width);
41
+ if (current_table_el) {
42
+ total_header_width = table_rect?.width ?? 0;
43
+ header_height = table_rect?.height ?? 0;
44
+ }
45
+ opts.on_resize?.();
46
+ }
47
+
48
+ $effect(() => {
49
+ const table_el = opts.header_table_el();
50
+ const row_el = opts.header_row_el();
51
+ if (!table_el || !row_el) return;
52
+
53
+ // re-run when columns change so we observe new cells
54
+ opts.resolved_headers();
55
+
56
+ const ro = new ResizeObserver(measure);
57
+ ro.observe(table_el);
58
+
59
+ // observe individual header cells so content-driven column
60
+ // width changes (editing, data updates) trigger a re-measure
61
+ // even when the overall table dimensions stay the same
62
+ const cells = row_el.querySelectorAll<HTMLElement>(".header-cell");
63
+ cells.forEach((cell) => ro.observe(cell));
64
+
65
+ return () => ro.disconnect();
66
+ });
67
+
68
+ let row_num_width = $derived.by(() => {
69
+ if (!opts.show_row_numbers()) return 0;
70
+ const row_el = opts.header_row_el();
71
+ if (!row_el) return 0;
72
+ const el = row_el.querySelector<HTMLElement>(".row-number-header");
73
+ return el?.getBoundingClientRect().width ?? 48;
74
+ });
75
+
76
+ function get_col_style(index: number): string {
77
+ if (col_widths[index] !== undefined) {
78
+ return `width: ${col_widths[index]}px; flex: 0 0 ${col_widths[index]}px;`;
79
+ }
80
+ const user_widths = opts.column_widths();
81
+ if (user_widths[index]) return `width: ${user_widths[index]};`;
82
+ return "width: 150px;";
83
+ }
84
+
85
+ return {
86
+ get col_widths() {
87
+ return col_widths;
88
+ },
89
+ get col_lefts() {
90
+ return col_lefts;
91
+ },
92
+ get total_header_width() {
93
+ return total_header_width;
94
+ },
95
+ get header_height() {
96
+ return header_height;
97
+ },
98
+ get row_num_width() {
99
+ return row_num_width;
100
+ },
101
+ get_col_style
102
+ };
103
+ }
6.11.1/dataframe/shared/icons/FilterIcon.svelte ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <svg viewBox="0 0 24 24" width="20" height="20">
2
+ <path
3
+ d="M5 5H19"
4
+ stroke="currentColor"
5
+ stroke-width="2"
6
+ stroke-linecap="round"
7
+ />
8
+ <path
9
+ d="M8 9H16"
10
+ stroke="currentColor"
11
+ stroke-width="2"
12
+ stroke-linecap="round"
13
+ />
14
+ <path
15
+ d="M11 13H13"
16
+ stroke="currentColor"
17
+ stroke-width="2"
18
+ stroke-linecap="round"
19
+ />
20
+ </svg>
6.11.1/dataframe/shared/icons/Padlock.svelte ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ let { size = 16 } = $props();
3
+ </script>
4
+
5
+ <div class="wrapper" aria-label="Static column">
6
+ <svg
7
+ xmlns="http://www.w3.org/2000/svg"
8
+ width={size}
9
+ height={size}
10
+ viewBox="0 0 24 24"
11
+ fill="none"
12
+ stroke="currentColor"
13
+ stroke-width="2"
14
+ stroke-linecap="round"
15
+ stroke-linejoin="round"
16
+ >
17
+ <rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect>
18
+ <path d="M7 11V7a5 5 0 0 1 10 0v4"></path>
19
+ </svg>
20
+ </div>
21
+
22
+ <style>
23
+ .wrapper {
24
+ display: flex;
25
+ align-items: center;
26
+ justify-content: center;
27
+ }
28
+ </style>
6.11.1/dataframe/shared/icons/SelectionButtons.svelte ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ let {
3
+ position,
4
+ coords,
5
+ on_click = null
6
+ }: {
7
+ position: "column" | "row";
8
+ coords: [number, number];
9
+ on_click?: (() => void) | null;
10
+ } = $props();
11
+
12
+ let is_first_position = $derived(
13
+ position === "column" ? coords[0] === 0 : coords[1] === 0
14
+ );
15
+ let direction = $derived(
16
+ position === "column"
17
+ ? is_first_position
18
+ ? "down"
19
+ : "up"
20
+ : is_first_position
21
+ ? "right"
22
+ : "left"
23
+ );
24
+ </script>
25
+
26
+ <button
27
+ class="selection-button selection-button-{position} {is_first_position
28
+ ? `move-${direction}`
29
+ : ''}"
30
+ onclick={(e: MouseEvent) => {
31
+ e.stopPropagation();
32
+ on_click && on_click();
33
+ }}
34
+ aria-label={`Select ${position}`}
35
+ >
36
+ <span class={direction}>
37
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
38
+ <path
39
+ d="m16.707 13.293-4-4a1 1 0 0 0-1.414 0l-4 4A1 1 0 0 0 8 15h8a1 1 0 0 0 .707-1.707z"
40
+ data-name={direction}
41
+ />
42
+ </svg>
43
+ </span>
44
+ </button>
45
+
46
+ <style>
47
+ .selection-button {
48
+ position: absolute;
49
+ background: var(--color-accent);
50
+ width: var(--size-3);
51
+ height: var(--size-5);
52
+ color: var(--background-fill-primary);
53
+ }
54
+
55
+ .selection-button-column {
56
+ top: -15px;
57
+ left: 50%;
58
+ transform: translateX(-50%) rotate(90deg);
59
+ border-radius: var(--radius-sm) 0 0 var(--radius-sm);
60
+ }
61
+
62
+ .selection-button-row {
63
+ left: calc(var(--size-2-5) * -1);
64
+ top: 50%;
65
+ transform: translateY(-50%);
66
+ border-radius: var(--radius-sm) 0 0 var(--radius-sm);
67
+ }
68
+
69
+ .move-down {
70
+ bottom: -14px;
71
+ top: auto;
72
+ border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
73
+ }
74
+
75
+ .move-right {
76
+ left: auto;
77
+ right: calc(var(--size-2-5) * -1);
78
+ top: 50%;
79
+ transform: translateY(-50%);
80
+ border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
81
+ }
82
+
83
+ svg {
84
+ fill: currentColor;
85
+ }
86
+
87
+ span {
88
+ display: flex;
89
+ width: 100%;
90
+ height: 100%;
91
+ }
92
+
93
+ .up {
94
+ transform: rotate(-90deg);
95
+ }
96
+
97
+ .down {
98
+ transform: rotate(90deg);
99
+ }
100
+
101
+ .left {
102
+ transform: rotate(-90deg);
103
+ }
104
+
105
+ .right {
106
+ transform: rotate(90deg);
107
+ }
108
+ </style>
6.11.1/dataframe/shared/icons/SortButtonDown.svelte ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ let { size = 16 } = $props();
3
+ </script>
4
+
5
+ <svg
6
+ width={size}
7
+ height={size}
8
+ viewBox="0 0 16 16"
9
+ fill="none"
10
+ xmlns="http://www.w3.org/2000/svg"
11
+ >
12
+ <path
13
+ d="M4 8L8 12L12 8"
14
+ stroke="currentColor"
15
+ stroke-width="1.5"
16
+ stroke-linecap="round"
17
+ stroke-linejoin="round"
18
+ />
19
+ <path
20
+ d="M8 12V4"
21
+ stroke="currentColor"
22
+ stroke-width="1.5"
23
+ stroke-linecap="round"
24
+ />
25
+ </svg>
6.11.1/dataframe/shared/icons/SortButtonUp.svelte ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ let { size = 16 } = $props();
3
+ </script>
4
+
5
+ <svg
6
+ width={size}
7
+ height={size}
8
+ viewBox="0 0 16 16"
9
+ fill="none"
10
+ xmlns="http://www.w3.org/2000/svg"
11
+ >
12
+ <path
13
+ d="M4 8L8 4L12 8"
14
+ stroke="currentColor"
15
+ stroke-width="1.5"
16
+ stroke-linecap="round"
17
+ stroke-linejoin="round"
18
+ />
19
+ <path
20
+ d="M8 4V12"
21
+ stroke="currentColor"
22
+ stroke-width="1.5"
23
+ stroke-linecap="round"
24
+ />
25
+ </svg>
6.11.1/dataframe/shared/icons/SortIcon.svelte ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import type { I18nFormatter } from "@gradio/utils";
3
+ import SortButtonUp from "./SortButtonUp.svelte";
4
+ import SortButtonDown from "./SortButtonDown.svelte";
5
+ import { IconButton } from "@gradio/atoms";
6
+ type SortDirection = "asc" | "desc";
7
+
8
+ let {
9
+ direction = null,
10
+ priority = null,
11
+ i18n,
12
+ onsort
13
+ }: {
14
+ direction?: SortDirection | null;
15
+ priority?: number | null;
16
+ i18n: I18nFormatter;
17
+ onsort?: (direction: SortDirection) => void;
18
+ } = $props();
19
+ </script>
20
+
21
+ <div class="sort-icons" role="group" aria-label={i18n("dataframe.sort_column")}>
22
+ {#if (direction === "asc" || direction === "desc") && priority !== null}
23
+ <span aria-label={`Sort priority: ${priority}`} class="priority"
24
+ >{priority}</span
25
+ >
26
+ {/if}
27
+ <IconButton
28
+ size="x-small"
29
+ label={i18n("dataframe.sort_ascending")}
30
+ Icon={SortButtonUp}
31
+ highlight={direction === "asc"}
32
+ onclick={(event) => {
33
+ event.stopPropagation();
34
+ onsort?.("asc");
35
+ }}
36
+ ></IconButton>
37
+ <IconButton
38
+ size="x-small"
39
+ label={i18n("dataframe.sort_descending")}
40
+ Icon={SortButtonDown}
41
+ highlight={direction === "desc"}
42
+ onclick={(event) => {
43
+ event.stopPropagation();
44
+ onsort?.("desc");
45
+ }}
46
+ ></IconButton>
47
+ </div>
48
+
49
+ <style>
50
+ .sort-icons {
51
+ display: flex;
52
+ flex-direction: column;
53
+ gap: 0;
54
+ margin-right: var(--spacing-sm);
55
+ }
56
+
57
+ .sort-icons :global(button) {
58
+ margin-bottom: var(--spacing-xs);
59
+ border: 1px solid var(--border-color-primary);
60
+ background: unset;
61
+ }
62
+
63
+ .priority {
64
+ display: flex;
65
+ align-items: center;
66
+ justify-content: center;
67
+ position: absolute;
68
+ font-size: var(--size-2);
69
+ left: 19px;
70
+ z-index: var(--layer-3);
71
+ top: var(--spacing-xs);
72
+ background-color: var(--button-secondary-background-fill);
73
+ color: var(--body-text-color);
74
+ border-radius: var(--radius-sm);
75
+ width: var(--size-2-5);
76
+ height: var(--size-2-5);
77
+ }
78
+ </style>
6.11.1/dataframe/shared/tanstack/index.ts ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export { createSvelteTable } from "./table.svelte.js";
2
+
3
+ export { createSvelteVirtualizer, type VirtualItem } from "./virtual.svelte.js";
4
+
5
+ export {
6
+ createColumnHelper,
7
+ getCoreRowModel,
8
+ getSortedRowModel,
9
+ getFilteredRowModel,
10
+ type ColumnDef,
11
+ type TableOptions,
12
+ type Table,
13
+ type Header,
14
+ type Cell,
15
+ type Row,
16
+ type SortingState,
17
+ type ColumnFiltersState,
18
+ type ColumnPinningState,
19
+ type FilterFn,
20
+ type SortingFn,
21
+ type CellContext,
22
+ type HeaderContext
23
+ } from "@tanstack/table-core";
6.11.1/dataframe/shared/tanstack/table.svelte.ts ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import {
2
+ createTable,
3
+ type RowData,
4
+ type TableOptions,
5
+ type TableOptionsResolved,
6
+ type TableState
7
+ } from "@tanstack/table-core";
8
+
9
+ /**
10
+ * Merges objects while preserving property getters for lazy evaluation.
11
+ * Properties are defined as getters that look up values from sources in
12
+ * reverse order at access time. This is critical: it means reading a
13
+ * property from the merged result doesn't happen until the property is
14
+ * actually accessed, not when mergeObjects is called.
15
+ */
16
+ export function mergeObjects(...sources: any): any {
17
+ const target: Record<string, any> = {};
18
+ for (let i = 0; i < sources.length; i++) {
19
+ let source = sources[i];
20
+ if (typeof source === "function") source = source();
21
+ if (source) {
22
+ const descriptors = Object.getOwnPropertyDescriptors(source);
23
+ for (const key in descriptors) {
24
+ if (key in target) continue;
25
+ Object.defineProperty(target, key, {
26
+ enumerable: true,
27
+ get() {
28
+ for (let j = sources.length - 1; j >= 0; j--) {
29
+ let s = sources[j];
30
+ if (typeof s === "function") s = s();
31
+ const v = (s || {})[key];
32
+ if (v !== undefined) return v;
33
+ }
34
+ }
35
+ });
36
+ }
37
+ }
38
+ }
39
+ return target;
40
+ }
41
+
42
+ /**
43
+ * Creates a reactive TanStack Table for Svelte 5.
44
+ *
45
+ * The reactivity works through mergeObjects' lazy getters:
46
+ * - $effect.pre calls table.setOptions() with a merged object
47
+ * - The merged object has lazy getters for `data`, `columns`, `state`, etc.
48
+ * - TanStack stores this object but doesn't deep-read all properties immediately
49
+ * - When getRowModel() is called (in $derived), TanStack reads `data` and `columns`
50
+ * through the lazy getters, which read the reactive $state/$derived values
51
+ * - onStateChange fires when TanStack mutates its own state → bumps version
52
+ * - version is read by getRowModel/getHeaderGroups → $derived re-evaluates
53
+ */
54
+ export function createSvelteTable<TData extends RowData>(
55
+ options: TableOptions<TData>
56
+ ) {
57
+ const resolvedOptions: TableOptionsResolved<TData> = mergeObjects(
58
+ {
59
+ state: {},
60
+ onStateChange() {},
61
+ renderFallbackValue: null,
62
+ mergeOptions: (
63
+ defaultOptions: TableOptions<TData>,
64
+ opts: Partial<TableOptions<TData>>
65
+ ) => {
66
+ return mergeObjects(defaultOptions, opts);
67
+ }
68
+ },
69
+ options
70
+ );
71
+
72
+ const table = createTable(resolvedOptions);
73
+ let state = $state<Partial<TableState>>(table.initialState);
74
+ let version = $state(0);
75
+
76
+ function updateOptions(): void {
77
+ table.setOptions((prev) => {
78
+ // mergeObjects creates lazy getters — `state` is NOT read here,
79
+ // only when TanStack accesses the `state` property later.
80
+ return mergeObjects(prev, options, {
81
+ state: mergeObjects(state, options.state || {}),
82
+ onStateChange: (updater: any) => {
83
+ if (updater instanceof Function) state = updater(state);
84
+ else state = mergeObjects(state, updater);
85
+ version += 1;
86
+ options.onStateChange?.(updater);
87
+ }
88
+ });
89
+ });
90
+ }
91
+
92
+ // Initial sync
93
+ updateOptions();
94
+
95
+ // Re-sync when options change. Because mergeObjects uses lazy getters,
96
+ // this effect's tracked dependencies are only the properties that
97
+ // table.setOptions() eagerly reads (which is minimal — mostly just
98
+ // checking if the options object reference changed).
99
+ $effect.pre(() => {
100
+ updateOptions();
101
+ });
102
+
103
+ return {
104
+ getRowModel: () => {
105
+ void version;
106
+ return table.getRowModel();
107
+ },
108
+ getHeaderGroups: () => {
109
+ void version;
110
+ return table.getHeaderGroups();
111
+ },
112
+ getColumn: (id: string) => {
113
+ void version;
114
+ return table.getColumn(id);
115
+ }
116
+ };
117
+ }
6.11.1/dataframe/shared/tanstack/virtual.svelte.ts ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import {
2
+ Virtualizer,
3
+ elementScroll,
4
+ observeElementOffset,
5
+ observeElementRect,
6
+ type PartialKeys,
7
+ type VirtualizerOptions
8
+ } from "@tanstack/virtual-core";
9
+ import { untrack } from "svelte";
10
+
11
+ export type { VirtualItem } from "@tanstack/virtual-core";
12
+
13
+ /**
14
+ * Creates a reactive TanStack Virtualizer for Svelte 5.
15
+ *
16
+ * Returns a getter function that returns the virtualizer instance.
17
+ * Call the getter inside $derived or template expressions to create
18
+ * reactive dependencies on the virtualizer state.
19
+ */
20
+ export function createSvelteVirtualizer<
21
+ TScrollElement extends Element,
22
+ TItemElement extends Element
23
+ >(
24
+ options: PartialKeys<
25
+ VirtualizerOptions<TScrollElement, TItemElement>,
26
+ "observeElementRect" | "observeElementOffset" | "scrollToFn"
27
+ >
28
+ ): {
29
+ instance: Virtualizer<TScrollElement, TItemElement>;
30
+ virtualItems: () => ReturnType<
31
+ Virtualizer<TScrollElement, TItemElement>["getVirtualItems"]
32
+ >;
33
+ totalSize: () => number;
34
+ } {
35
+ let version = $state(0);
36
+
37
+ const virtualizer = new Virtualizer<TScrollElement, TItemElement>({
38
+ observeElementRect: observeElementRect,
39
+ observeElementOffset: observeElementOffset,
40
+ scrollToFn: elementScroll,
41
+ ...options,
42
+ onChange: (instance, sync) => {
43
+ if (sync) {
44
+ version += 1;
45
+ } else {
46
+ queueMicrotask(() => {
47
+ version += 1;
48
+ });
49
+ }
50
+ options.onChange?.(instance, sync);
51
+ }
52
+ });
53
+
54
+ $effect(() => {
55
+ const cleanup = virtualizer._didMount();
56
+ untrack(() => {
57
+ version += 1;
58
+ });
59
+ return cleanup;
60
+ });
61
+
62
+ let prev_count = 0;
63
+
64
+ $effect(() => {
65
+ const current_count = options.count;
66
+ virtualizer.setOptions({
67
+ observeElementRect: observeElementRect,
68
+ observeElementOffset: observeElementOffset,
69
+ scrollToFn: elementScroll,
70
+ ...options,
71
+ onChange: (instance, sync) => {
72
+ if (sync) {
73
+ version += 1;
74
+ } else {
75
+ queueMicrotask(() => {
76
+ version += 1;
77
+ });
78
+ }
79
+ options.onChange?.(instance, sync);
80
+ }
81
+ });
82
+
83
+ if (prev_count === 0 && current_count > 0) {
84
+ virtualizer.measure();
85
+ }
86
+ prev_count = current_count;
87
+ });
88
+
89
+ $effect.pre(() => {
90
+ void version;
91
+ virtualizer._willUpdate();
92
+ });
93
+
94
+ return {
95
+ instance: virtualizer,
96
+ virtualItems: () => {
97
+ void version;
98
+ return virtualizer.getVirtualItems();
99
+ },
100
+ totalSize: () => {
101
+ void version;
102
+ return virtualizer.getTotalSize();
103
+ }
104
+ };
105
+ }
6.11.1/dataframe/shared/types.ts ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export type CellCoordinate = [number, number];
2
+ export type EditingState = CellCoordinate | false;
3
+
4
+ export type Headers = (string | null)[];
5
+
6
+ export interface HeadersWithIDs {
7
+ id: string;
8
+ value: string;
9
+ }
10
+ [];
11
+
12
+ export type CellValue = string | number | boolean;
13
+
14
+ export interface TableCell {
15
+ id: string;
16
+ value: CellValue;
17
+ }
18
+
19
+ export type TableData = TableCell[][];
20
+
21
+ export type CountConfig = [number, "fixed" | "dynamic"];
22
+
23
+ export type ElementRefs = Record<
24
+ string,
25
+ {
26
+ cell: null | HTMLTableCellElement;
27
+ input: null | HTMLTextAreaElement;
28
+ }
29
+ >;
30
+
31
+ export type DataBinding = Record<string, TableCell>;
32
+
33
+ export type SortDirection = "asc" | "desc";
34
+ export type FilterDatatype = "string" | "number";
6.11.1/dataframe/shared/utils/filter.ts ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Custom filter function for TanStack Table that handles Gradio's
3
+ * { dtype, filter, value } column filter format.
4
+ */
5
+ export function gradio_filter_fn(
6
+ row: any,
7
+ columnId: string,
8
+ filterValue: any
9
+ ): boolean {
10
+ const { dtype, filter, value: fval } = filterValue;
11
+ const cell_value = String(row.getValue(columnId) ?? "");
12
+ const compare_val = fval ?? "";
13
+
14
+ if (dtype === "number") {
15
+ const num = parseFloat(cell_value);
16
+ const target = parseFloat(compare_val);
17
+ if (isNaN(num) || isNaN(target)) {
18
+ if (filter === "Is empty") return cell_value.trim() === "";
19
+ if (filter === "Is not empty") return cell_value.trim() !== "";
20
+ return true;
21
+ }
22
+ switch (filter) {
23
+ case "=":
24
+ return num === target;
25
+ case "≠":
26
+ return num !== target;
27
+ case ">":
28
+ return num > target;
29
+ case "<":
30
+ return num < target;
31
+ case "≥":
32
+ return num >= target;
33
+ case "≤":
34
+ return num <= target;
35
+ case "Is empty":
36
+ return cell_value.trim() === "";
37
+ case "Is not empty":
38
+ return cell_value.trim() !== "";
39
+ default:
40
+ return true;
41
+ }
42
+ }
43
+
44
+ const lower = cell_value.toLowerCase();
45
+ const target_lower = compare_val.toLowerCase();
46
+ switch (filter) {
47
+ case "Contains":
48
+ return lower.includes(target_lower);
49
+ case "Does not contain":
50
+ return !lower.includes(target_lower);
51
+ case "Starts with":
52
+ return lower.startsWith(target_lower);
53
+ case "Ends with":
54
+ return lower.endsWith(target_lower);
55
+ case "Is":
56
+ return lower === target_lower;
57
+ case "Is not":
58
+ return lower !== target_lower;
59
+ case "Is empty":
60
+ return cell_value.trim() === "";
61
+ case "Is not empty":
62
+ return cell_value.trim() !== "";
63
+ default:
64
+ return true;
65
+ }
66
+ }
6.11.1/dataframe/shared/utils/selection_utils.ts ADDED
@@ -0,0 +1,234 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { CellCoordinate, CellValue } from "./../types";
2
+
3
+ export type CellData = { id: string; value: CellValue };
4
+
5
+ export function is_cell_in_selection(
6
+ coords: [number, number],
7
+ selected_cells: [number, number][]
8
+ ): boolean {
9
+ const [row, col] = coords;
10
+ return selected_cells.some(([r, c]) => r === row && c === col);
11
+ }
12
+
13
+ export function is_cell_selected(
14
+ cell: CellCoordinate,
15
+ selected_cells: CellCoordinate[]
16
+ ): string {
17
+ const [row, col] = cell;
18
+ if (!selected_cells.some(([r, c]) => r === row && c === col)) return "";
19
+
20
+ const up = selected_cells.some(([r, c]) => r === row - 1 && c === col);
21
+ const down = selected_cells.some(([r, c]) => r === row + 1 && c === col);
22
+ const left = selected_cells.some(([r, c]) => r === row && c === col - 1);
23
+ const right = selected_cells.some(([r, c]) => r === row && c === col + 1);
24
+
25
+ return `cell-selected${up ? " no-top" : ""}${down ? " no-bottom" : ""}${left ? " no-left" : ""}${right ? " no-right" : ""}`;
26
+ }
27
+
28
+ export function get_range_selection(
29
+ start: CellCoordinate,
30
+ end: CellCoordinate
31
+ ): CellCoordinate[] {
32
+ const [start_row, start_col] = start;
33
+ const [end_row, end_col] = end;
34
+ const min_row = Math.min(start_row, end_row);
35
+ const max_row = Math.max(start_row, end_row);
36
+ const min_col = Math.min(start_col, end_col);
37
+ const max_col = Math.max(start_col, end_col);
38
+
39
+ const cells: CellCoordinate[] = [];
40
+ // add the start cell as the "anchor" cell so that when
41
+ // we press shift+arrow keys, the selection will always
42
+ // include the anchor cell.
43
+ cells.push(start);
44
+
45
+ for (let i = min_row; i <= max_row; i++) {
46
+ for (let j = min_col; j <= max_col; j++) {
47
+ if (i === start_row && j === start_col) continue;
48
+ cells.push([i, j]);
49
+ }
50
+ }
51
+ return cells;
52
+ }
53
+
54
+ export function handle_selection(
55
+ current: CellCoordinate,
56
+ selected_cells: CellCoordinate[],
57
+ event: { shiftKey: boolean; metaKey: boolean; ctrlKey: boolean }
58
+ ): CellCoordinate[] {
59
+ if (event.shiftKey && selected_cells.length > 0) {
60
+ return get_range_selection(
61
+ selected_cells[selected_cells.length - 1],
62
+ current
63
+ );
64
+ }
65
+
66
+ if (event.metaKey || event.ctrlKey) {
67
+ const is_cell_match = ([r, c]: CellCoordinate): boolean =>
68
+ r === current[0] && c === current[1];
69
+ const index = selected_cells.findIndex(is_cell_match);
70
+ return index === -1
71
+ ? [...selected_cells, current]
72
+ : selected_cells.filter((_, i) => i !== index);
73
+ }
74
+
75
+ return [current];
76
+ }
77
+
78
+ export function handle_delete_key(
79
+ data: CellData[][],
80
+ selected_cells: CellCoordinate[]
81
+ ): CellData[][] {
82
+ const new_data = data.map((row) => [...row]);
83
+ selected_cells.forEach(([row, col]) => {
84
+ if (new_data[row] && new_data[row][col]) {
85
+ new_data[row][col] = { ...new_data[row][col], value: "" };
86
+ }
87
+ });
88
+ return new_data;
89
+ }
90
+
91
+ export function should_show_cell_menu(
92
+ cell: CellCoordinate,
93
+ selected_cells: CellCoordinate[],
94
+ editable: boolean
95
+ ): boolean {
96
+ const [row, col] = cell;
97
+ return (
98
+ editable &&
99
+ selected_cells.length === 1 &&
100
+ selected_cells[0][0] === row &&
101
+ selected_cells[0][1] === col
102
+ );
103
+ }
104
+
105
+ export function get_next_cell_coordinates(
106
+ current: CellCoordinate,
107
+ data: CellData[][],
108
+ shift_key: boolean
109
+ ): CellCoordinate | false {
110
+ const [row, col] = current;
111
+ const direction = shift_key ? -1 : 1;
112
+
113
+ if (data[row]?.[col + direction]) {
114
+ return [row, col + direction];
115
+ }
116
+
117
+ const next_row = row + (direction > 0 ? 1 : 0);
118
+ const prev_row = row + (direction < 0 ? -1 : 0);
119
+
120
+ if (direction > 0 && data[next_row]?.[0]) {
121
+ return [next_row, 0];
122
+ }
123
+
124
+ if (direction < 0 && data[prev_row]?.[data[0].length - 1]) {
125
+ return [prev_row, data[0].length - 1];
126
+ }
127
+
128
+ return false;
129
+ }
130
+
131
+ export function move_cursor(
132
+ event: KeyboardEvent,
133
+ current_coords: CellCoordinate,
134
+ data: CellData[][]
135
+ ): CellCoordinate | false {
136
+ const key = event.key as "ArrowRight" | "ArrowLeft" | "ArrowDown" | "ArrowUp";
137
+ const dir = {
138
+ ArrowRight: [0, 1],
139
+ ArrowLeft: [0, -1],
140
+ ArrowDown: [1, 0],
141
+ ArrowUp: [-1, 0]
142
+ }[key];
143
+
144
+ let i, j;
145
+ if (event.metaKey || event.ctrlKey) {
146
+ if (key === "ArrowRight") {
147
+ i = current_coords[0];
148
+ j = data[0].length - 1;
149
+ } else if (key === "ArrowLeft") {
150
+ i = current_coords[0];
151
+ j = 0;
152
+ } else if (key === "ArrowDown") {
153
+ i = data.length - 1;
154
+ j = current_coords[1];
155
+ } else if (key === "ArrowUp") {
156
+ i = 0;
157
+ j = current_coords[1];
158
+ } else {
159
+ return false;
160
+ }
161
+ } else {
162
+ i = current_coords[0] + dir[0];
163
+ j = current_coords[1] + dir[1];
164
+ }
165
+
166
+ if (i < 0 && j <= 0) {
167
+ return false;
168
+ }
169
+
170
+ const is_data = data[i]?.[j];
171
+ if (is_data) {
172
+ return [i, j];
173
+ }
174
+ return false;
175
+ }
176
+
177
+ export function get_current_indices(
178
+ id: string,
179
+ data: CellData[][]
180
+ ): [number, number] {
181
+ return data.reduce(
182
+ (acc, arr, i) => {
183
+ const j = arr.reduce(
184
+ (_acc, _data, k) => (id === _data.id ? k : _acc),
185
+ -1
186
+ );
187
+ return j === -1 ? acc : [i, j];
188
+ },
189
+ [-1, -1]
190
+ );
191
+ }
192
+
193
+ export function handle_click_outside(
194
+ event: Event,
195
+ parent: HTMLElement
196
+ ): boolean {
197
+ const [trigger] = event.composedPath() as HTMLElement[];
198
+ return !parent.contains(trigger);
199
+ }
200
+
201
+ export function select_column(data: any[][], col: number): CellCoordinate[] {
202
+ return Array.from({ length: data.length }, (_, i) => [i, col]);
203
+ }
204
+
205
+ export function select_row(data: any[][], row: number): CellCoordinate[] {
206
+ return Array.from({ length: data[0].length }, (_, i) => [row, i]);
207
+ }
208
+
209
+ export function calculate_selection_positions(
210
+ selected: CellCoordinate,
211
+ data: { id: string; value: CellValue }[][],
212
+ els: Record<string, { cell: HTMLTableCellElement | null }>,
213
+ parent: HTMLElement,
214
+ table: HTMLElement
215
+ ): { col_pos: string; row_pos: string | undefined } {
216
+ const [row, col] = selected;
217
+ if (!data[row]?.[col]) {
218
+ return { col_pos: "0px", row_pos: undefined };
219
+ }
220
+
221
+ const cell_id = data[row][col].id;
222
+ const cell_el = els[cell_id]?.cell;
223
+
224
+ if (!cell_el) {
225
+ return { col_pos: "0px", row_pos: undefined };
226
+ }
227
+
228
+ const cell_rect = cell_el.getBoundingClientRect();
229
+ const table_rect = table.getBoundingClientRect();
230
+ const col_pos = `${cell_rect.left - table_rect.left + cell_rect.width / 2}px`;
231
+ const row_pos = `${cell_rect.top - table_rect.top + cell_rect.height / 2}px`;
232
+
233
+ return { col_pos, row_pos };
234
+ }
6.11.1/dataframe/shared/utils/table_utils.ts ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { CellValue, Headers, HeadersWithIDs, TableData } from "../types";
2
+ import { dsvFormat } from "d3-dsv";
3
+
4
+ export function make_cell_id(row: number, col: number): string {
5
+ return `cell-${row}-${col}`;
6
+ }
7
+
8
+ export function make_header_id(col: number): string {
9
+ return `header-${col}`;
10
+ }
11
+
12
+ export async function copy_table_data(
13
+ data: TableData,
14
+ selected_cells: [number, number][] | null
15
+ ): Promise<void> {
16
+ if (!data || !data.length) return;
17
+
18
+ const cells_to_copy =
19
+ selected_cells ||
20
+ data.flatMap((row, r) => row.map((_, c) => [r, c] as [number, number]));
21
+
22
+ const csv = cells_to_copy.reduce(
23
+ (acc: { [key: string]: { [key: string]: string } }, [row, col]) => {
24
+ acc[row] = acc[row] || {};
25
+ const value = String(data[row][col].value);
26
+ acc[row][col] =
27
+ value.includes(",") || value.includes('"') || value.includes("\n")
28
+ ? `"${value.replace(/"/g, '""')}"`
29
+ : value;
30
+ return acc;
31
+ },
32
+ {}
33
+ );
34
+
35
+ const rows = Object.keys(csv).sort((a, b) => +a - +b);
36
+ if (!rows.length) return;
37
+
38
+ const cols = Object.keys(csv[rows[0]]).sort((a, b) => +a - +b);
39
+ const text = rows
40
+ .map((r) => cols.map((c) => csv[r][c] || "").join(","))
41
+ .join("\n");
42
+
43
+ try {
44
+ await navigator.clipboard.writeText(text);
45
+ } catch (err) {
46
+ throw new Error("Failed to copy to clipboard: " + (err as Error).message);
47
+ }
48
+ }
49
+
50
+ export function guess_delimiter(
51
+ text: string,
52
+ possibleDelimiters: string[]
53
+ ): string[] {
54
+ return possibleDelimiters.filter(weedOut);
55
+
56
+ function weedOut(delimiter: string): boolean {
57
+ var cache = -1;
58
+ return text.split("\n").every(checkLength);
59
+
60
+ function checkLength(line: string): boolean {
61
+ if (!line) return true;
62
+ var length = line.split(delimiter).length;
63
+ if (cache < 0) cache = length;
64
+ return cache === length && length > 1;
65
+ }
66
+ }
67
+ }
68
+
69
+ export function data_uri_to_blob(data_uri: string): Blob {
70
+ const byte_str = atob(data_uri.split(",")[1]);
71
+ const mime_str = data_uri.split(",")[0].split(":")[1].split(";")[0];
72
+ const ab = new ArrayBuffer(byte_str.length);
73
+ const ia = new Uint8Array(ab);
74
+ for (let i = 0; i < byte_str.length; i++) {
75
+ ia[i] = byte_str.charCodeAt(i);
76
+ }
77
+ return new Blob([ab], { type: mime_str });
78
+ }
79
+
80
+ export function handle_file_upload(
81
+ data_uri: string,
82
+ update_headers: (headers: Headers) => HeadersWithIDs[],
83
+ update_values: (values: CellValue[][]) => void
84
+ ): void {
85
+ const blob = data_uri_to_blob(data_uri);
86
+ const reader = new FileReader();
87
+ reader.addEventListener("loadend", (e) => {
88
+ if (!e?.target?.result || typeof e.target.result !== "string") return;
89
+ const [delimiter] = guess_delimiter(e.target.result, [",", "\t"]);
90
+ const [head, ...rest] = dsvFormat(delimiter).parseRows(e.target.result);
91
+ update_headers(head);
92
+ update_values(rest);
93
+ });
94
+ reader.readAsText(blob);
95
+ }
6.11.1/dataframe/shared/utils/utils.ts ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { CellValue } from "../types";
2
+
3
+ export type Headers = string[];
4
+ export type Data = CellValue[][];
5
+
6
+ export type Datatype =
7
+ | "str"
8
+ | "number"
9
+ | "bool"
10
+ | "date"
11
+ | "markdown"
12
+ | "html"
13
+ | "image";
14
+
15
+ export type Metadata = {
16
+ [key: string]: string[][] | null;
17
+ } | null;
18
+ export type HeadersWithIDs = { value: string; id: string }[];
19
+ export type DataframeValue = {
20
+ data: Data;
21
+ headers: Headers;
22
+ metadata?: Metadata;
23
+ };
24
+
25
+ /**
26
+ * Coerce a value to a given type.
27
+ * @param v - The value to coerce.
28
+ * @param t - The type to coerce to.
29
+ * @returns The coerced value.
30
+ */
31
+ export function cast_value_to_type(v: any, t: Datatype): CellValue {
32
+ if (v === null || v === undefined) {
33
+ return v;
34
+ }
35
+ if (t === "number") {
36
+ const n = Number(v);
37
+ return isNaN(n) ? v : n;
38
+ }
39
+ if (t === "bool") {
40
+ if (typeof v === "boolean") return v;
41
+ if (typeof v === "number") return v !== 0;
42
+ const s = String(v).toLowerCase();
43
+ if (s === "true" || s === "1") return true;
44
+ if (s === "false" || s === "0") return false;
45
+ return v;
46
+ }
47
+ if (t === "date") {
48
+ const d = new Date(v);
49
+ return isNaN(d.getTime()) ? v : d.toISOString();
50
+ }
51
+ return v;
52
+ }
53
+
54
+ export interface EditData {
55
+ index: number | [number, number];
56
+ value: string;
57
+ previous_value: string;
58
+ }
6.11.1/dataframe/standalone/Index.svelte ADDED
@@ -0,0 +1,741 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { onMount } from "svelte";
3
+ import Table from "../shared/Table.svelte";
4
+ import type { Datatype, DataframeValue } from "../shared/utils/utils";
5
+ import type { I18nFormatter } from "@gradio/utils";
6
+ import { default_i18n } from "./default_i18n";
7
+
8
+ let {
9
+ i18n = undefined,
10
+ value = $bindable({
11
+ data: [["", "", ""]],
12
+ headers: ["1", "2", "3"],
13
+ metadata: null
14
+ }),
15
+ datatype = "str",
16
+ interactive = true,
17
+ show_row_numbers = false,
18
+ max_height = 500,
19
+ show_search = "none",
20
+ wrap = false,
21
+ line_breaks = true,
22
+ column_widths = [],
23
+ max_chars = undefined,
24
+ pinned_columns = 0,
25
+ static_columns = [],
26
+ fullscreen = $bindable(false),
27
+ label = null,
28
+ show_label = true,
29
+ latex_delimiters = [],
30
+ col_count = undefined,
31
+ row_count = undefined
32
+ }: {
33
+ i18n?: I18nFormatter | undefined;
34
+ value?: DataframeValue;
35
+ datatype?: Datatype | Datatype[];
36
+ interactive?: boolean;
37
+ show_row_numbers?: boolean;
38
+ max_height?: number;
39
+ show_search?: "none" | "search" | "filter";
40
+ wrap?: boolean;
41
+ line_breaks?: boolean;
42
+ column_widths?: string[];
43
+ max_chars?: number | undefined;
44
+ pinned_columns?: number;
45
+ static_columns?: (string | number)[];
46
+ fullscreen?: boolean;
47
+ label?: string | null;
48
+ show_label?: boolean;
49
+ latex_delimiters?: any[];
50
+ col_count?: [number, "fixed" | "dynamic"] | undefined;
51
+ row_count?: [number, "fixed" | "dynamic"] | undefined;
52
+ } = $props();
53
+
54
+ const i18n_fn = (key: string | null | undefined): string => {
55
+ if (!key) return "";
56
+ if (typeof i18n === "function") return (i18n as any)(key);
57
+ if (i18n && typeof i18n === "object")
58
+ return (i18n as any)[key] ?? default_i18n[key] ?? key;
59
+ return default_i18n[key] ?? key;
60
+ };
61
+
62
+ let resolved_row_count = $derived.by(() => {
63
+ if (
64
+ row_count &&
65
+ Array.isArray(row_count) &&
66
+ row_count.length === 2 &&
67
+ typeof row_count[0] === "number" &&
68
+ (row_count[1] === "fixed" || row_count[1] === "dynamic")
69
+ ) {
70
+ return row_count as [number, "fixed" | "dynamic"];
71
+ }
72
+ return [1, "dynamic"] as [number, "fixed" | "dynamic"];
73
+ });
74
+
75
+ let resolved_col_count_base = $derived.by(() => {
76
+ if (
77
+ col_count &&
78
+ Array.isArray(col_count) &&
79
+ col_count.length === 2 &&
80
+ typeof col_count[0] === "number" &&
81
+ (col_count[1] === "fixed" || col_count[1] === "dynamic")
82
+ ) {
83
+ return col_count as [number, "fixed" | "dynamic"];
84
+ }
85
+ const headerLength =
86
+ value && value.headers && typeof value.headers.length === "number"
87
+ ? value.headers.length
88
+ : 3;
89
+ return [headerLength, "dynamic"] as [number, "fixed" | "dynamic"];
90
+ });
91
+
92
+ let resolved_col_count = $derived.by(() => {
93
+ if (
94
+ static_columns &&
95
+ static_columns.length > 0 &&
96
+ resolved_col_count_base[1] !== "fixed"
97
+ ) {
98
+ return [resolved_col_count_base[0], "fixed"] as [
99
+ number,
100
+ "fixed" | "dynamic"
101
+ ];
102
+ }
103
+ return resolved_col_count_base;
104
+ });
105
+
106
+ let root = "";
107
+
108
+ onMount(() => {
109
+ const handler = (e: KeyboardEvent): void => {
110
+ if (e.key === "Escape") {
111
+ fullscreen = false;
112
+ }
113
+ };
114
+ window.addEventListener("keydown", handler);
115
+ return () => window.removeEventListener("keydown", handler);
116
+ });
117
+ </script>
118
+
119
+ <div class="gradio-dataframe-standalone" class:fullscreen>
120
+ <Table
121
+ values={value.data}
122
+ headers={value.headers}
123
+ display_value={value?.metadata?.display_value ?? null}
124
+ styling={value?.metadata?.styling ?? null}
125
+ {datatype}
126
+ editable={interactive}
127
+ {show_row_numbers}
128
+ {max_height}
129
+ {show_search}
130
+ buttons={null}
131
+ {wrap}
132
+ {line_breaks}
133
+ {column_widths}
134
+ {max_chars}
135
+ {pinned_columns}
136
+ {static_columns}
137
+ {fullscreen}
138
+ {label}
139
+ {show_label}
140
+ {latex_delimiters}
141
+ col_count={resolved_col_count}
142
+ row_count={resolved_row_count}
143
+ {root}
144
+ i18n={i18n_fn}
145
+ onchange={(detail) => {
146
+ value.data = detail.data;
147
+ value.headers = detail.headers;
148
+ }}
149
+ onfullscreen={() => (fullscreen = !fullscreen)}
150
+ upload={async () => null}
151
+ stream_handler={() => new EventSource("about:blank")}
152
+ />
153
+ </div>
154
+
155
+ <style>
156
+ .gradio-dataframe-standalone {
157
+ --gr-df-font-mono: unset;
158
+ --gr-df-font-sans: unset;
159
+ --gr-df-table-bg-even: unset;
160
+ --gr-df-table-bg-odd: unset;
161
+ --gr-df-table-border: unset;
162
+ --gr-df-table-radius: unset;
163
+
164
+ --gr-df-table-text: unset;
165
+ --gr-df-accent: unset;
166
+ --gr-df-accent-soft: unset;
167
+
168
+ --gr-df-input-background-fill: unset;
169
+ --gr-df-input-background-fill-focus: unset;
170
+ --gr-df-input-background-fill-hover: unset;
171
+ --gr-df-input-border-color: unset;
172
+ --gr-df-input-border-color-focus: unset;
173
+ --gr-df-input-placeholder-color: unset;
174
+ --gr-df-input-radius: unset;
175
+ --gr-df-input-text-size: unset;
176
+ --gr-df-copied-cell-color: unset;
177
+
178
+ --gr-df-checkbox-border-color: unset;
179
+ --gr-df-checkbox-background-color: unset;
180
+ --gr-df-checkbox-border-color-focus: unset;
181
+ --gr-df-checkbox-shadow: unset;
182
+ --gr-df-checkbox-border-radius: unset;
183
+
184
+ /* Dataframe-scoped defaults (only used as fallbacks) */
185
+ --df-font-mono: var(
186
+ --gr-df-font-mono,
187
+ "IBM Plex Mono",
188
+ ui-monospace,
189
+ Consolas,
190
+ monospace
191
+ );
192
+ --df-font-sans: var(
193
+ --gr-df-font-sans,
194
+ "Source Sans Pro",
195
+ ui-sans-serif,
196
+ system-ui,
197
+ sans-serif
198
+ );
199
+ --df-table-radius: var(--df-radius-sm, 4px);
200
+ --df-border-color-primary: var(--gr-df-table-border, var(--df-neutral-200));
201
+ --df-background-fill-primary: #ffffff;
202
+ --df-background-fill-secondary: #f8fafc;
203
+ --df-color-accent: #7c3aed;
204
+ --df-color-accent-soft: #f3e8ff;
205
+ --df-color-accent-copied: #faf5ff;
206
+ --df-body-text-color: #111827;
207
+ --df-block-background-fill: #ffffff;
208
+ --df-block-radius: var(--df-radius-sm, 4px);
209
+ --df-table-even-background-fill: #ffffff;
210
+ --df-table-odd-background-fill: #f9fafb;
211
+
212
+ --df-background-fill-primary-dark: var(--df-neutral-950, #0f0f11);
213
+ --df-background-fill-secondary-dark: var(--df-neutral-900, #18181b);
214
+ --df-body-text-color-dark: var(--df-neutral-100, #f4f4f5);
215
+ --df-block-background-fill-dark: var(--df-neutral-800, #27272a);
216
+ --df-table-even-background-fill-dark: var(--df-neutral-950, #0f0f11);
217
+ --df-table-odd-background-fill-dark: var(--df-neutral-900, #18181b);
218
+ --df-border-color-primary-dark: var(--df-neutral-700, #3f3f46);
219
+ --df-color-accent-dark: var(--df-primary-600, #ea580c);
220
+ --df-color-accent-soft-dark: var(--df-neutral-700, #3f3f46);
221
+ --df-radius-sm: 4px;
222
+ --df-size-1: 4px;
223
+ --df-size-2: 8px;
224
+ --df-size-4: 16px;
225
+ --df-size-6: 24px;
226
+ --df-size-8: 32px;
227
+ --df-size-12: 48px;
228
+ --df-size-3: 12px;
229
+ --df-size-5: 20px;
230
+ --df-size-7: 28px;
231
+ --df-size-9: 36px;
232
+ --df-size-10: 40px;
233
+ --df-size-11: 44px;
234
+ --df-size-14: 56px;
235
+ --df-size-px: 1px;
236
+ --df-size-full: 100%;
237
+ --df-text-sm: 12px;
238
+ --df-size-0-5: 2px;
239
+ --df-size-1-5: 6px;
240
+ --df-size-2-5: 10px;
241
+ --df-text-md: 14px;
242
+ --df-text-lg: 16px;
243
+ --df-radius-100: 100%;
244
+ --df-radius-xs: 2px;
245
+ --df-radius-sm: 4px;
246
+ --df-radius-md: 6px;
247
+ --df-radius-lg: 8px;
248
+ --df-radius-xl: 12px;
249
+ --df-radius-2xl: 16px;
250
+ --df-radius-3xl: 22px;
251
+ --df-input-text-size: var(--df-text-md, 14px);
252
+
253
+ --df-primary-50: #fff7ed;
254
+ --df-primary-100: #ffedd5;
255
+ --df-primary-200: #fed7aa;
256
+ --df-primary-300: #fdba74;
257
+ --df-primary-400: #fb923c;
258
+ --df-primary-500: #f97316;
259
+ --df-primary-600: #ea580c;
260
+
261
+ --df-neutral-50: #fafafa;
262
+ --df-neutral-100: #f4f4f5;
263
+ --df-neutral-200: #e4e4e7;
264
+ --df-neutral-300: #d4d4d8;
265
+ --df-neutral-400: #bbbbc2;
266
+ --df-neutral-500: #71717a;
267
+ --df-neutral-600: #52525b;
268
+ --df-neutral-700: #3f3f46;
269
+ --df-neutral-800: #27272a;
270
+ --df-neutral-900: #18181b;
271
+ --df-neutral-950: #0f0f11;
272
+
273
+ /* Secondary palette (scoped) */
274
+ --df-secondary-50: #eff6ff;
275
+ --df-secondary-100: #dbeafe;
276
+ --df-secondary-200: #bfdbfe;
277
+ --df-secondary-300: #93c5fd;
278
+ --df-secondary-400: #60a5fa;
279
+ --df-secondary-500: #3b82f6;
280
+
281
+ --neutral-50: var(--df-neutral-50, #f9fafb);
282
+ --neutral-100: var(--df-neutral-100, #f3f4f6);
283
+ --neutral-200: var(--df-neutral-200, #e5e7eb);
284
+ --neutral-300: var(--df-neutral-300, #d1d5db);
285
+ --neutral-400: var(--df-neutral-400, #9ca3af);
286
+ --neutral-500: var(--df-neutral-500, #6b7280);
287
+ --neutral-600: var(--df-neutral-600, #4b5563);
288
+ --neutral-700: var(--df-neutral-700, #374151);
289
+ --neutral-800: var(--df-neutral-800, #1f2937);
290
+ --neutral-900: var(--df-neutral-900, #111827);
291
+ --neutral-950: var(--df-neutral-950, #0b0f19);
292
+
293
+ --secondary-50: var(--df-secondary-50, #eff6ff);
294
+ --secondary-100: var(--df-secondary-100, #dbeafe);
295
+ --secondary-200: var(--df-secondary-200, #bfdbfe);
296
+
297
+ --df-spacing-xxs: 1px;
298
+ --df-spacing-xs: 2px;
299
+ --df-spacing-sm: 4px;
300
+ --df-spacing-md: 6px;
301
+ --df-spacing-lg: 8px;
302
+ --df-spacing-xl: 10px;
303
+ --df-spacing-xxl: 16px;
304
+
305
+ --df-radius-xxs: 1px;
306
+ --df-radius-xxl: 22px;
307
+
308
+ --df-text-xxs: 9px;
309
+ --df-text-xs: 10px;
310
+ --df-text-xl: 22px;
311
+ --df-text-xxl: 26px;
312
+
313
+ --df-body-background-fill: var(
314
+ --df-background-fill-primary,
315
+ var(--background-fill-primary, #ffffff)
316
+ );
317
+ --df-body-text-color: var(--gr-df-table-text, --df-neutral-800);
318
+ --df-body-text-size: var(--df-text-md, 14px);
319
+ --df-body-text-weight: 400;
320
+
321
+ --df-color-accent: var(--df-primary-500, #f97316);
322
+ --df-color-accent-soft: var(--df-primary-50, #fff7ed);
323
+ --df-background-fill-primary: white;
324
+ --df-background-fill-secondary: var(--df-neutral-50, #f9fafb);
325
+ --df-border-color-accent: var(--df-primary-300, #fdba74);
326
+ --df-body-text-color-subdued: var(--df-neutral-400, #9ca3af);
327
+ --df-table-text-color: var(--df-body-text-color, #111827);
328
+ --df-shadow-drop: rgba(0, 0, 0, 0.05) 0px 1px 2px 0px;
329
+ --df-shadow-drop-lg:
330
+ 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
331
+ --df-shadow-inset: rgba(0, 0, 0, 0.05) 0px 2px 4px 0px inset;
332
+ --df-shadow-spread: 3px;
333
+
334
+ --df-bw-svt-p-top: 0px;
335
+ --df-bw-svt-p-bottom: 0px;
336
+
337
+ --df-border-color-secondary: var(--df-border-color-accent, #fdba74);
338
+ --df-shadow-md:
339
+ 0 12px 16px -4px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
340
+
341
+ --df-checkbox-border-radius: var(--df-radius-sm, 4px);
342
+ --df-checkbox-shadow: none;
343
+ --df-checkbox-border-color: var(--df-neutral-300, #d4d4d8);
344
+ --df-checkbox-background-color: var(--df-background-fill-primary, #ffffff);
345
+ --df-checkbox-background-color-selected: var(
346
+ --df-color-accent,
347
+ var(--color-accent)
348
+ );
349
+ --df-checkbox-border-color-focus: var(--df-color-accent, #f97316);
350
+ --df-button-transition: none;
351
+ --df-block-background-fill: var(--df-background-fill-primary, white);
352
+ --df-block-border-color: var(
353
+ --df-border-color-primary,
354
+ var(--df-neutral-200, #e5e7eb)
355
+ );
356
+ --df-block-border-width: 1px;
357
+ --df-input-text-size: 0.95rem;
358
+ --df-line-md: 1.5;
359
+ --df-line-lg: 1.75;
360
+
361
+ --df-input-background-fill: var(--df-background-fill-primary, #ffffff);
362
+ --df-input-background-fill-focus: var(
363
+ --df-input-background-fill,
364
+ var(--df-background-fill-primary, #ffffff)
365
+ );
366
+ --df-input-background-fill-hover: var(
367
+ --df-input-background-fill,
368
+ var(--df-background-fill-primary, #ffffff)
369
+ );
370
+ --df-input-border-color: var(--df-border-color-primary, #e5e7eb);
371
+ --df-input-border-color-focus: var(--secondary-300, #93c5fd);
372
+ --df-input-border-color-hover: var(
373
+ --df-input-border-color,
374
+ var(--df-border-color-primary, #e5e7eb)
375
+ );
376
+ --df-input-border-width: 1px;
377
+ --df-input-padding: var(--df-spacing-xl, 10px);
378
+ --df-input-placeholder-color: var(--neutral-400, #9ca3af);
379
+ --df-input-radius: var(--df-radius-sm, 4px);
380
+ --df-input-shadow: none;
381
+ --df-input-shadow-focus:
382
+ 0 0 0 var(--shadow-spread, 3px) var(--secondary-50, #eff6ff),
383
+ var(--shadow-inset, rgba(0, 0, 0, 0.05) 0px 2px 4px 0px inset);
384
+
385
+ --table-radius: var(--gr-df-table-radius, var(--df-table-radius, 4px));
386
+ --table-row-hover: var(--gr-df-table-row-hover, var(--color-accent-soft));
387
+ --cell-padding: var(--gr-df-cell-padding, var(--size-2));
388
+ --df-font-size: var(--gr-df-font-size, var(--text-md));
389
+ --background-fill-primary: var(--df-background-fill-primary, #ffffff);
390
+ --background-fill-primary-dark: var(
391
+ --df-background-fill-primary-dark,
392
+ var(--neutral-950, #0f0f11)
393
+ );
394
+ --background-fill-secondary: var(--df-background-fill-secondary, #f8fafc);
395
+ --background-fill-secondary-dark: var(
396
+ --df-background-fill-secondary-dark,
397
+ var(--neutral-900, #18181b)
398
+ );
399
+ --color-accent: var(--gr-df-accent, var(--df-color-accent, #7c3aed));
400
+ --color-accent-soft: var(
401
+ --gr-df-accent-soft,
402
+ var(--df-color-accent-soft, #f3e8ff)
403
+ );
404
+ --color-accent-copied: var(
405
+ --gr-df-copied-cell-color,
406
+ var(--color-accent-soft)
407
+ );
408
+ --body-text-color: var(--df-body-text-color, #111827);
409
+ --block-background-fill: var(
410
+ --df-block-background-fill,
411
+ var(--background-fill-primary)
412
+ );
413
+ --block-radius: var(--df-block-radius, var(--radius-sm, 4px));
414
+ --table-even-background-fill: var(
415
+ --gr-df-table-bg-even,
416
+ var(--df-table-even-background-fill, #ffffff)
417
+ );
418
+ --table-odd-background-fill: var(
419
+ --gr-df-table-bg-odd,
420
+ var(--df-table-odd-background-fill, #f9fafb)
421
+ );
422
+ --border-color-primary: var(--df-border-color-primary, #e5e7eb);
423
+ --radius-sm: var(--df-radius-sm, 4px);
424
+ --size-1: var(--df-size-1, 4px);
425
+ --size-2: var(--df-size-2, 8px);
426
+ --size-3: var(--df-size-3, 12px);
427
+ --size-4: var(--df-size-4, 16px);
428
+ --size-5: var(--df-size-5, 20px);
429
+ --size-6: var(--df-size-6, 24px);
430
+ --size-7: var(--df-size-7, 28px);
431
+ --size-8: var(--df-size-8, 32px);
432
+ --size-9: var(--df-size-9, 36px);
433
+ --size-10: var(--df-size-10, 40px);
434
+ --size-11: var(--df-size-11, 44px);
435
+ --size-12: var(--df-size-12, 48px);
436
+ --size-14: var(--df-size-14, 56px);
437
+ --size-16: var(--df-size-16, 64px);
438
+ --size-20: var(--df-size-20, 80px);
439
+ --size-24: var(--df-size-24, 96px);
440
+
441
+ --size-px: var(--df-size-px, 1px);
442
+ --size-full: var(--df-size-full, 100%);
443
+ --size-0-5: var(--df-size-0-5, 2px);
444
+ --size-1-5: var(--df-size-1-5, 6px);
445
+ --size-2-5: var(--df-size-2-5, 10px);
446
+ --input-text-size: var(--df-input-text-size, 0.95rem);
447
+ --text-sm: var(--df-text-sm, 12px);
448
+ --text-md: var(--df-text-md, 14px);
449
+ --text-lg: var(--df-text-lg, 16px);
450
+ --text-xl: var(--df-text-xl, 22px);
451
+ --text-xxl: var(--df-text-xxl, 26px);
452
+
453
+ --spacing-xxs: var(--df-spacing-xxs, 1px);
454
+ --spacing-xs: var(--df-spacing-xs, 2px);
455
+ --spacing-sm: var(--df-spacing-sm, 4px);
456
+ --spacing-md: var(--df-spacing-md, 6px);
457
+ --spacing-lg: var(--df-spacing-lg, 8px);
458
+ --spacing-xl: var(--df-spacing-xl, 10px);
459
+ --spacing-xxl: var(--df-spacing-xxl, 16px);
460
+
461
+ --radius-xxs: var(--df-radius-xxs, 1px);
462
+ --radius-xs: var(--df-radius-xs, 2px);
463
+ --radius-sm: var(--df-radius-sm, 4px);
464
+ --radius-md: var(--df-radius-md, 6px);
465
+ --radius-lg: var(--df-radius-lg, 8px);
466
+ --radius-xl: var(--df-radius-xl, 12px);
467
+ --radius-2xl: var(--df-radius-2xl, 16px);
468
+ --radius-3xl: var(--df-radius-3xl, 22px);
469
+ --radius-full: var(--df-radius-full, 9999px);
470
+ --font-mono: var(--df-font-mono, "Courier New", Courier, monospace);
471
+ --font-sans: var(
472
+ --df-font-sans,
473
+ "Source Sans Pro",
474
+ ui-sans-serif,
475
+ system-ui,
476
+ sans-serif
477
+ );
478
+
479
+ --input-background-fill: var(
480
+ --gr-df-input-background-fill,
481
+ var(--df-input-background-fill, var(--background-fill-primary, #ffffff))
482
+ );
483
+ --input-background-fill-focus: var(
484
+ --gr-df-input-background-fill-focus,
485
+ var(
486
+ --df-input-background-fill-focus,
487
+ var(--input-background-fill, var(--background-fill-primary, #ffffff))
488
+ )
489
+ );
490
+ --input-background-fill-hover: var(
491
+ --gr-df-input-background-fill-hover,
492
+ var(
493
+ --df-input-background-fill-hover,
494
+ var(--input-background-fill, var(--background-fill-primary, #ffffff))
495
+ )
496
+ );
497
+ --input-border-color: var(
498
+ --gr-df-input-border-color,
499
+ var(--df-input-border-color, var(--border-color-primary, #e5e7eb))
500
+ );
501
+ --input-border-color-focus: var(
502
+ --gr-df-input-border-color-focus,
503
+ var(--df-input-border-color-focus, var(--secondary-300, #93c5fd))
504
+ );
505
+ --input-border-color-hover: var(
506
+ --gr-df-input-border-color-hover,
507
+ var(
508
+ --df-input-border-color-hover,
509
+ var(--input-border-color, var(--border-color-primary, #e5e7eb))
510
+ )
511
+ );
512
+ --input-border-width: var(
513
+ --gr-df-input-border-width,
514
+ var(--df-input-border-width, 1px)
515
+ );
516
+
517
+ --weight-bold: var(--df-weight-bold, 700);
518
+ --weight-semibold: var(--df-weight-semibold, 600);
519
+ --checkbox-border-radius: var(
520
+ --gr-df-checkbox-border-radius,
521
+ var(--df-checkbox-border-radius, var(--df-radius-sm, 4px))
522
+ );
523
+ --checkbox-shadow: var(
524
+ --gr-df-checkbox-shadow,
525
+ var(--df-checkbox-shadow, none)
526
+ );
527
+ --checkbox-border-color: var(
528
+ --gr-df-checkbox-border-color,
529
+ var(--df-checkbox-border-color, var(--df-neutral-300, #d4d4d8))
530
+ );
531
+ --checkbox-background-color: var(
532
+ --gr-df-checkbox-background-color,
533
+ var(
534
+ --df-checkbox-background-color,
535
+ var(--df-background-fill-primary, #ffffff)
536
+ )
537
+ );
538
+ --checkbox-background-color-selected: var(
539
+ --gr-df-checkbox-background-color,
540
+ var(--df-checkbox-background-color-selected, var(--color-accent))
541
+ );
542
+ --checkbox-border-color-focus: var(
543
+ --gr-df-checkbox-border-color-focus,
544
+ var(--df-checkbox-border-color-focus, var(--df-color-accent, #f97316))
545
+ );
546
+ --checkbox-check: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3e%3c/svg%3e");
547
+ --button-transition: var(--df-button-transition, none);
548
+ --max-height: var(--df-max-height, 500px);
549
+ --df-layer-1: 10;
550
+ --df-layer-2: 20;
551
+ --df-layer-3: 30;
552
+ --df-layer-4: 40;
553
+ --df-layer-5: 50;
554
+ --df-layer-below: -1;
555
+ --df-layer-top: 2147483647;
556
+
557
+ --layer-1: var(--df-layer-1, 10);
558
+ --layer-2: var(--df-layer-2, 20);
559
+ --layer-3: var(--df-layer-3, 30);
560
+ --layer-4: var(--df-layer-4, 40);
561
+ --layer-5: var(--df-layer-5, 50);
562
+ --layer-below: var(--df-layer-below, -1);
563
+ --layer-top: var(--df-layer-top, 2147483647);
564
+
565
+ --line-md: var(--df-line-md, 1.5);
566
+ --line-lg: var(--df-line-lg, 1.75);
567
+
568
+ --shadow-xs:
569
+ 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
570
+ --shadow-sm:
571
+ 0 4px 6px -2px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.06);
572
+ --shadow-md:
573
+ 0 12px 16px -4px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
574
+ --shadow-lg:
575
+ 0 20px 24px -4px rgba(0, 0, 0, 0.1), 0 8px 8px -4px rgba(0, 0, 0, 0.04);
576
+ --shadow-drop: rgba(0, 0, 0, 0.05) 0px 1px 2px 0px;
577
+ --shadow-drop-lg:
578
+ 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
579
+ --shadow-inset: rgba(0, 0, 0, 0.05) 0px 2px 4px 0px inset;
580
+ --shadow-spread: 3px;
581
+ }
582
+
583
+ .gradio-dataframe-standalone.fullscreen {
584
+ position: fixed;
585
+ top: 0;
586
+ left: 0;
587
+ width: 100vw;
588
+ height: 100vh;
589
+ z-index: 1000;
590
+ overflow: auto;
591
+ border-radius: 0;
592
+ background-color: var(--block-background-fill);
593
+ }
594
+
595
+ :global(.dark) .gradio-dataframe-standalone {
596
+ --df-background-fill-primary: var(--df-background-fill-primary-dark);
597
+ --df-background-fill-secondary: var(--df-background-fill-secondary-dark);
598
+ --df-body-text-color: var(--df-body-text-color-dark);
599
+ --df-block-background-fill: var(--df-block-background-fill-dark);
600
+ --df-table-even-background-fill: var(--df-table-even-background-fill-dark);
601
+ --df-table-odd-background-fill: var(--df-table-odd-background-fill-dark);
602
+ --df-border-color-primary: var(--df-border-color-primary-dark);
603
+ --df-color-accent: var(--df-color-accent-dark);
604
+ --df-color-accent-soft: var(--df-color-accent-soft-dark);
605
+ }
606
+
607
+ :global(.gradio-container),
608
+ :global(*),
609
+ :global(::before),
610
+ :global(::after) {
611
+ box-sizing: border-box;
612
+ border-width: 0;
613
+ border-style: solid;
614
+ }
615
+
616
+ :global(.gradio-container) :global(textarea) {
617
+ padding-top: var(--input-padding, var(--df-input-padding, 10px));
618
+ padding-bottom: var(--input-padding, var(--df-input-padding, 10px));
619
+ box-sizing: border-box;
620
+ }
621
+
622
+ :global(button),
623
+ :global(input),
624
+ :global(select),
625
+ :global(textarea) {
626
+ margin: 0;
627
+ padding: 0;
628
+ color: inherit;
629
+ font-weight: inherit;
630
+ font-size: 100%;
631
+ line-height: inherit;
632
+ font-family: inherit;
633
+ }
634
+
635
+ :global([type="text"]),
636
+ :global([type="url"]),
637
+ :global([type="number"]),
638
+ :global([multiple]),
639
+ :global(textarea),
640
+ :global(select) {
641
+ --tw-shadow: 0 0 #0000;
642
+ appearance: none;
643
+ border-width: 1px;
644
+ border-color: #6b7280;
645
+ border-radius: 0px;
646
+ background-color: #fff;
647
+ padding-top: 0.5rem;
648
+ padding-right: 0.75rem;
649
+ padding-bottom: 0.5rem;
650
+ padding-left: 0.75rem;
651
+ font-size: 1rem;
652
+ line-height: 1.5rem;
653
+ }
654
+
655
+ :global(button),
656
+ :global(input[type="button"]),
657
+ :global(input[type="submit"]) {
658
+ -webkit-appearance: button;
659
+ appearance: button;
660
+ background-image: none;
661
+ background-color: transparent;
662
+ }
663
+
664
+ :global(.sr-only) {
665
+ clip: rect(0, 0, 0, 0);
666
+ position: absolute;
667
+ margin: -1px;
668
+ border-width: 0;
669
+ padding: 0;
670
+ width: 1px;
671
+ height: 1px;
672
+ overflow: hidden;
673
+ white-space: nowrap;
674
+ }
675
+
676
+ :global(input[type="checkbox"]) {
677
+ accent-color: var(--color-accent);
678
+ }
679
+
680
+ :global(label) {
681
+ display: flex;
682
+ align-items: center;
683
+ transition: all 0.15s ease;
684
+ cursor: pointer;
685
+ /* default label color */
686
+ color: #111111;
687
+ font-weight: 400;
688
+ font-size: 14px;
689
+ line-height: 1.5;
690
+ }
691
+
692
+ :global(label) > * + * {
693
+ margin-left: 8px;
694
+ }
695
+
696
+ :global(input) {
697
+ --ring-color: transparent;
698
+ position: relative;
699
+ /* default shadow */
700
+ box-shadow: none;
701
+ border: 1px solid #888888;
702
+ border-radius: 6px;
703
+ background-color: #ffffff;
704
+ line-height: 1;
705
+ }
706
+
707
+ :global(input:checked),
708
+ :global(input:checked:hover),
709
+ :global(input:checked:focus) {
710
+ /* checked state: orange */
711
+ background-image: none;
712
+ background-color: #f97316;
713
+ border-color: #f97316;
714
+ }
715
+
716
+ :global(input:checked:focus) {
717
+ background-image: none;
718
+ background-color: #f97316;
719
+ border-color: #f97316;
720
+ }
721
+
722
+ :global(input:hover) {
723
+ border-color: #1e90ff;
724
+ background-color: #e6f0ff;
725
+ }
726
+
727
+ :global(input:focus) {
728
+ border-color: #f97316;
729
+ background-color: #fff4e6;
730
+ }
731
+
732
+ :global(input[disabled]),
733
+ :global(.disabled) {
734
+ cursor: not-allowed !important;
735
+ opacity: 0.6;
736
+ }
737
+
738
+ :global(input:hover) {
739
+ cursor: pointer;
740
+ }
741
+ </style>
6.11.1/dataframe/standalone/default_i18n.ts ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export const default_i18n: Record<string, string> = {
2
+ "dataframe.add_row_above": "Add row above",
3
+ "dataframe.add_row_below": "Add row below",
4
+ "dataframe.delete_row": "Delete row",
5
+ "dataframe.add_column_left": "Add column left",
6
+ "dataframe.add_column_right": "Add column right",
7
+ "dataframe.delete_column": "Delete column",
8
+ "dataframe.sort_asc": "Sort ascending",
9
+ "dataframe.sort_desc": "Sort descending",
10
+ "dataframe.sort_ascending": "Sort ascending",
11
+ "dataframe.sort_descending": "Sort descending",
12
+ "dataframe.clear_sort": "Clear sort",
13
+ "dataframe.filter": "Filter",
14
+ "dataframe.clear_filter": "Clear filter",
15
+ "dataframe.copy": "Copy",
16
+ "dataframe.paste": "Paste",
17
+ "dataframe.cut": "Cut",
18
+ "dataframe.select_all": "Select all",
19
+ "dataframe.fullscreen": "Fullscreen",
20
+ "dataframe.exit_fullscreen": "Exit fullscreen",
21
+ "dataframe.search": "Search",
22
+ "dataframe.export": "Export",
23
+ "dataframe.import": "Import",
24
+ "dataframe.edit": "Edit",
25
+ "dataframe.save": "Save",
26
+ "dataframe.cancel": "Cancel",
27
+ "dataframe.confirm": "Confirm",
28
+ "dataframe.reset": "Reset",
29
+ "dataframe.clear": "Clear",
30
+ "dataframe.undo": "Undo",
31
+ "dataframe.redo": "Redo"
32
+ };
6.11.1/dataframe/standalone/stubs/Upload.svelte ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ export const aria_label = "";
3
+ export const root = "";
4
+ export const upload: any = null;
5
+ export const stream_handler: any = null;
6
+ </script>
7
+
8
+ <div>
9
+ <slot />
10
+ </div>
11
+
12
+ <style>
13
+ div {
14
+ width: 100%;
15
+ border: 1px solid var(--border-color-primary);
16
+ border-radius: var(--table-radius);
17
+ overflow: hidden;
18
+ }
19
+ </style>
6.11.1/dataframe/standalone/stubs/upload.ts ADDED
@@ -0,0 +1 @@
 
 
1
+ export { default as Upload } from "./Upload.svelte";
6.11.1/dataframe/types.ts ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { SelectData } from "@gradio/utils";
2
+ import type { LoadingStatus } from "@gradio/statustracker";
3
+ import type { DataframeValue, Datatype, EditData } from "./shared/utils/utils";
4
+
5
+ export interface DataframeEvents {
6
+ change: DataframeValue;
7
+ input: never;
8
+ select: SelectData;
9
+ edit: EditData;
10
+ clear_status: LoadingStatus;
11
+ }
12
+
13
+ export interface DataframeProps {
14
+ value: DataframeValue;
15
+ col_count: [number, "fixed" | "dynamic"];
16
+ row_count: [number, "fixed" | "dynamic"];
17
+ wrap: boolean;
18
+ datatype: Datatype | Datatype[];
19
+ line_breaks: boolean;
20
+ column_widths: string[];
21
+ latex_delimiters: {
22
+ left: string;
23
+ right: string;
24
+ display: boolean;
25
+ }[];
26
+ max_height: number;
27
+ buttons: string[] | null;
28
+ max_chars: number | undefined;
29
+ show_row_numbers: boolean;
30
+ show_search: "none" | "search" | "filter";
31
+ pinned_columns: number;
32
+ static_columns: (string | number)[];
33
+ fullscreen: boolean;
34
+ }