@gradio/dataframe 0.18.8 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/Example.svelte +8 -8
- package/Index.svelte +1 -1
- package/README.md +232 -37
- package/dist/Example.svelte +8 -8
- package/dist/Example.svelte.d.ts +3 -1
- package/dist/Index.svelte.d.ts +20 -18
- package/dist/shared/BooleanCell.svelte +1 -2
- package/dist/shared/BooleanCell.svelte.d.ts +4 -2
- package/dist/shared/CellMenu.svelte +4 -8
- package/dist/shared/CellMenu.svelte.d.ts +11 -9
- package/dist/shared/CellMenuButton.svelte.d.ts +2 -0
- package/dist/shared/CellMenuIcons.svelte.d.ts +2 -0
- package/dist/shared/EditableCell.svelte +6 -12
- package/dist/shared/EditableCell.svelte.d.ts +17 -15
- package/dist/shared/EmptyRowButton.svelte.d.ts +2 -0
- package/dist/shared/Example.svelte.d.ts +2 -0
- package/dist/shared/FilterMenu.svelte +2 -4
- package/dist/shared/FilterMenu.svelte.d.ts +3 -1
- package/dist/shared/RowNumber.svelte.d.ts +4 -2
- package/dist/shared/Table.svelte +127 -157
- package/dist/shared/Table.svelte.d.ts +24 -22
- package/dist/shared/TableCell.svelte +7 -13
- package/dist/shared/TableCell.svelte.d.ts +6 -4
- package/dist/shared/TableHeader.svelte +5 -10
- package/dist/shared/TableHeader.svelte.d.ts +4 -2
- package/dist/shared/Toolbar.svelte +3 -4
- package/dist/shared/Toolbar.svelte.d.ts +7 -5
- package/dist/shared/VirtualTable.svelte +19 -16
- package/dist/shared/VirtualTable.svelte.d.ts +9 -6
- package/dist/shared/context/dataframe_context.d.ts +1 -1
- package/dist/shared/context/dataframe_context.js +1 -1
- package/dist/shared/icons/FilterIcon.svelte.d.ts +3 -3
- package/dist/shared/icons/Padlock.svelte.d.ts +2 -0
- package/dist/shared/icons/SelectionButtons.svelte +2 -4
- package/dist/shared/icons/SelectionButtons.svelte.d.ts +3 -1
- package/dist/shared/icons/SortArrowDown.svelte.d.ts +3 -1
- package/dist/shared/icons/SortArrowUp.svelte.d.ts +3 -1
- package/dist/shared/icons/SortButtonDown.svelte.d.ts +2 -0
- package/dist/shared/icons/SortButtonUp.svelte.d.ts +2 -0
- package/dist/shared/icons/SortIcon.svelte.d.ts +4 -2
- package/dist/shared/utils/data_processing.d.ts +1 -1
- package/dist/shared/utils/drag_utils.js +1 -1
- package/dist/shared/utils/keyboard_utils.js +5 -3
- package/dist/shared/{selection_utils.d.ts → utils/selection_utils.d.ts} +1 -1
- package/dist/shared/{utils.d.ts → utils/utils.d.ts} +2 -2
- package/dist/standalone/Index.svelte +660 -0
- package/dist/standalone/Index.svelte.d.ts +45 -0
- package/dist/standalone/default_i18n.d.ts +1 -0
- package/dist/standalone/default_i18n.js +32 -0
- package/dist/standalone/stubs/Upload.svelte +18 -0
- package/dist/standalone/stubs/Upload.svelte.d.ts +27 -0
- package/dist/standalone/stubs/upload.d.ts +1 -0
- package/dist/standalone/stubs/upload.js +1 -0
- package/package.json +8 -11
- package/shared/CellMenu.svelte +1 -1
- package/shared/FilterMenu.svelte +1 -2
- package/shared/Table.svelte +9 -7
- package/shared/TableCell.svelte +2 -2
- package/shared/Toolbar.svelte +1 -0
- package/shared/VirtualTable.svelte +11 -2
- package/shared/context/dataframe_context.ts +1 -1
- package/shared/utils/data_processing.ts +1 -1
- package/shared/utils/drag_utils.ts +1 -1
- package/shared/utils/keyboard_utils.ts +5 -5
- package/shared/{selection_utils.ts → utils/selection_utils.ts} +1 -1
- package/shared/{utils.ts → utils/utils.ts} +11 -2
- package/standalone/Index.svelte +688 -0
- package/standalone/default_i18n.ts +32 -0
- package/standalone/stubs/Upload.svelte +19 -0
- package/standalone/stubs/upload.ts +1 -0
- package/test/table_utils.test.ts +1 -1
- /package/dist/shared/{selection_utils.js → utils/selection_utils.js} +0 -0
- /package/dist/shared/{utils.js → utils/utils.js} +0 -0
|
@@ -2,7 +2,7 @@ import { SvelteComponent } from "svelte";
|
|
|
2
2
|
import type { FilterDatatype } from "./context/dataframe_context";
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
|
-
on_filter?: (
|
|
5
|
+
on_filter?: (datatype: FilterDatatype, selected_filter: string, value: string) => void;
|
|
6
6
|
};
|
|
7
7
|
events: {
|
|
8
8
|
click: MouseEvent;
|
|
@@ -10,6 +10,8 @@ declare const __propDef: {
|
|
|
10
10
|
[evt: string]: CustomEvent<any>;
|
|
11
11
|
};
|
|
12
12
|
slots: {};
|
|
13
|
+
exports?: {} | undefined;
|
|
14
|
+
bindings?: string | undefined;
|
|
13
15
|
};
|
|
14
16
|
export type FilterMenuProps = typeof __propDef.props;
|
|
15
17
|
export type FilterMenuEvents = typeof __propDef.events;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
|
-
index?:
|
|
5
|
-
is_header?: boolean
|
|
4
|
+
index?: number | null;
|
|
5
|
+
is_header?: boolean;
|
|
6
6
|
};
|
|
7
7
|
events: {
|
|
8
8
|
[evt: string]: CustomEvent<any>;
|
|
9
9
|
};
|
|
10
10
|
slots: {};
|
|
11
|
+
exports?: {} | undefined;
|
|
12
|
+
bindings?: string | undefined;
|
|
11
13
|
};
|
|
12
14
|
export type RowNumberProps = typeof __propDef.props;
|
|
13
15
|
export type RowNumberEvents = typeof __propDef.events;
|
package/dist/shared/Table.svelte
CHANGED
|
@@ -21,14 +21,14 @@ import {
|
|
|
21
21
|
get_current_indices,
|
|
22
22
|
handle_click_outside as handle_click_outside_util,
|
|
23
23
|
calculate_selection_positions
|
|
24
|
-
} from "./selection_utils";
|
|
24
|
+
} from "./utils/selection_utils";
|
|
25
25
|
import {
|
|
26
26
|
copy_table_data,
|
|
27
27
|
get_max,
|
|
28
28
|
handle_file_upload
|
|
29
29
|
} from "./utils/table_utils";
|
|
30
30
|
import { make_headers, process_data } from "./utils/data_processing";
|
|
31
|
-
import { cast_value_to_type } from "./utils";
|
|
31
|
+
import { cast_value_to_type } from "./utils/utils";
|
|
32
32
|
import { handle_keydown, handle_cell_blur } from "./utils/keyboard_utils";
|
|
33
33
|
import {
|
|
34
34
|
create_drag_handlers
|
|
@@ -78,24 +78,15 @@ const df_ctx = create_dataframe_context({
|
|
|
78
78
|
static_columns
|
|
79
79
|
});
|
|
80
80
|
const { state: df_state, actions: df_actions } = df_ctx;
|
|
81
|
-
$:
|
|
82
|
-
|
|
83
|
-
$:
|
|
84
|
-
|
|
85
|
-
$:
|
|
86
|
-
|
|
87
|
-
$:
|
|
88
|
-
|
|
89
|
-
$:
|
|
90
|
-
selected_header = $df_state.ui_state.selected_header;
|
|
91
|
-
$:
|
|
92
|
-
active_cell_menu = $df_state.ui_state.active_cell_menu;
|
|
93
|
-
$:
|
|
94
|
-
active_header_menu = $df_state.ui_state.active_header_menu;
|
|
95
|
-
$:
|
|
96
|
-
copy_flash = $df_state.ui_state.copy_flash;
|
|
97
|
-
$:
|
|
98
|
-
actual_pinned_columns = pinned_columns && data?.[0]?.length ? Math.min(pinned_columns, data[0].length) : 0;
|
|
81
|
+
$: selected_cells = $df_state.ui_state.selected_cells;
|
|
82
|
+
$: selected = $df_state.ui_state.selected;
|
|
83
|
+
$: editing = $df_state.ui_state.editing;
|
|
84
|
+
$: header_edit = $df_state.ui_state.header_edit;
|
|
85
|
+
$: selected_header = $df_state.ui_state.selected_header;
|
|
86
|
+
$: active_cell_menu = $df_state.ui_state.active_cell_menu;
|
|
87
|
+
$: active_header_menu = $df_state.ui_state.active_header_menu;
|
|
88
|
+
$: copy_flash = $df_state.ui_state.copy_flash;
|
|
89
|
+
$: actual_pinned_columns = pinned_columns && data?.[0]?.length ? Math.min(pinned_columns, data[0].length) : 0;
|
|
99
90
|
onMount(() => {
|
|
100
91
|
df_ctx.parent_element = parent;
|
|
101
92
|
df_ctx.get_data_at = get_data_at;
|
|
@@ -169,82 +160,80 @@ function make_id() {
|
|
|
169
160
|
}
|
|
170
161
|
export let display_value = null;
|
|
171
162
|
export let styling = null;
|
|
172
|
-
$:
|
|
173
|
-
if (
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
parent.style.removeProperty(`--cell-width-${i}`);
|
|
180
|
-
}
|
|
181
|
-
last_width_data_length = 0;
|
|
182
|
-
last_width_column_count = 0;
|
|
183
|
-
width_calculated = false;
|
|
163
|
+
$: if (!dequal(values, old_val)) {
|
|
164
|
+
if (parent) {
|
|
165
|
+
const is_reset2 = values.length === 0 || values.length === 1 && values[0].length === 0;
|
|
166
|
+
const is_different_structure2 = old_val !== void 0 && (values.length !== old_val.length || values[0] && old_val[0] && values[0].length !== old_val[0].length);
|
|
167
|
+
if (is_reset2 || is_different_structure2) {
|
|
168
|
+
for (let i = 0; i < 50; i++) {
|
|
169
|
+
parent.style.removeProperty(`--cell-width-${i}`);
|
|
184
170
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
const is_different_structure = old_val !== void 0 && (values.length !== old_val.length || values[0] && old_val[0] && values[0].length !== old_val[0].length);
|
|
188
|
-
data = process_data(
|
|
189
|
-
values,
|
|
190
|
-
els,
|
|
191
|
-
data_binding,
|
|
192
|
-
make_id,
|
|
193
|
-
display_value
|
|
194
|
-
);
|
|
195
|
-
old_val = JSON.parse(JSON.stringify(values));
|
|
196
|
-
if (is_reset || is_different_structure) {
|
|
197
|
-
df_actions.reset_sort_state();
|
|
198
|
-
} else if ($df_state.sort_state.sort_columns.length > 0) {
|
|
199
|
-
sort_data(data, display_value, styling);
|
|
200
|
-
} else {
|
|
201
|
-
df_actions.handle_sort(-1, "asc");
|
|
202
|
-
df_actions.reset_sort_state();
|
|
203
|
-
}
|
|
204
|
-
if ($df_state.filter_state.filter_columns.length > 0) {
|
|
205
|
-
filter_data(data, display_value, styling);
|
|
206
|
-
} else {
|
|
207
|
-
df_actions.reset_filter_state();
|
|
208
|
-
}
|
|
209
|
-
if ($df_state.current_search_query) {
|
|
210
|
-
df_actions.handle_search(null);
|
|
211
|
-
}
|
|
212
|
-
if (parent && cells.length > 0 && (is_reset || is_different_structure)) {
|
|
171
|
+
last_width_data_length = 0;
|
|
172
|
+
last_width_column_count = 0;
|
|
213
173
|
width_calculated = false;
|
|
214
174
|
}
|
|
215
175
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
styling: styling?.[row_idx]?.[col_idx] || ""
|
|
231
|
-
});
|
|
232
|
-
});
|
|
233
|
-
});
|
|
234
|
-
const filtered = df_actions.filter_data(data);
|
|
235
|
-
search_results = filtered.map(
|
|
236
|
-
(row) => row.map((cell) => {
|
|
237
|
-
const original = cell_map.get(cell.id);
|
|
238
|
-
return {
|
|
239
|
-
...cell,
|
|
240
|
-
display_value: original?.display_value !== void 0 ? original.display_value : String(cell.value),
|
|
241
|
-
styling: original?.styling || ""
|
|
242
|
-
};
|
|
243
|
-
})
|
|
244
|
-
);
|
|
176
|
+
const is_reset = values.length === 0 || values.length === 1 && values[0].length === 0;
|
|
177
|
+
const is_different_structure = old_val !== void 0 && (values.length !== old_val.length || values[0] && old_val[0] && values[0].length !== old_val[0].length);
|
|
178
|
+
data = process_data(
|
|
179
|
+
values,
|
|
180
|
+
els,
|
|
181
|
+
data_binding,
|
|
182
|
+
make_id,
|
|
183
|
+
display_value
|
|
184
|
+
);
|
|
185
|
+
old_val = JSON.parse(JSON.stringify(values));
|
|
186
|
+
if (is_reset || is_different_structure) {
|
|
187
|
+
df_actions.reset_sort_state();
|
|
188
|
+
} else if ($df_state.sort_state.sort_columns.length > 0) {
|
|
189
|
+
sort_data(data, display_value, styling);
|
|
245
190
|
} else {
|
|
246
|
-
|
|
191
|
+
df_actions.handle_sort(-1, "asc");
|
|
192
|
+
df_actions.reset_sort_state();
|
|
247
193
|
}
|
|
194
|
+
if ($df_state.filter_state.filter_columns.length > 0) {
|
|
195
|
+
filter_data(data, display_value, styling);
|
|
196
|
+
} else {
|
|
197
|
+
df_actions.reset_filter_state();
|
|
198
|
+
}
|
|
199
|
+
if ($df_state.current_search_query) {
|
|
200
|
+
df_actions.handle_search(null);
|
|
201
|
+
}
|
|
202
|
+
if (parent && cells.length > 0 && (is_reset || is_different_structure)) {
|
|
203
|
+
width_calculated = false;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
$: if ($df_state.current_search_query !== void 0) {
|
|
207
|
+
const cell_map = /* @__PURE__ */ new Map();
|
|
208
|
+
filtered_to_original_map = [];
|
|
209
|
+
data.forEach((row, row_idx) => {
|
|
210
|
+
if (row.some(
|
|
211
|
+
(cell) => String(cell?.value).toLowerCase().includes($df_state.current_search_query?.toLowerCase() || "")
|
|
212
|
+
)) {
|
|
213
|
+
filtered_to_original_map.push(row_idx);
|
|
214
|
+
}
|
|
215
|
+
row.forEach((cell, col_idx) => {
|
|
216
|
+
cell_map.set(cell.id, {
|
|
217
|
+
value: cell.value,
|
|
218
|
+
display_value: cell.display_value !== void 0 ? cell.display_value : String(cell.value),
|
|
219
|
+
styling: styling?.[row_idx]?.[col_idx] || ""
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
const filtered = df_actions.filter_data(data);
|
|
224
|
+
search_results = filtered.map(
|
|
225
|
+
(row) => row.map((cell) => {
|
|
226
|
+
const original = cell_map.get(cell.id);
|
|
227
|
+
return {
|
|
228
|
+
...cell,
|
|
229
|
+
display_value: original?.display_value !== void 0 ? original.display_value : String(cell.value),
|
|
230
|
+
styling: original?.styling || ""
|
|
231
|
+
};
|
|
232
|
+
})
|
|
233
|
+
);
|
|
234
|
+
} else {
|
|
235
|
+
filtered_to_original_map = [];
|
|
236
|
+
}
|
|
248
237
|
let previous_headers = _headers.map((h) => h.value);
|
|
249
238
|
let previous_data = data.map((row) => row.map((cell) => String(cell.value)));
|
|
250
239
|
$: {
|
|
@@ -295,8 +284,7 @@ function clear_filter() {
|
|
|
295
284
|
filter_data(data, display_value, styling);
|
|
296
285
|
}
|
|
297
286
|
async function edit_header(i, _select = false) {
|
|
298
|
-
if (!editable || header_edit === i || col_count[1] !== "dynamic")
|
|
299
|
-
return;
|
|
287
|
+
if (!editable || header_edit === i || col_count[1] !== "dynamic") return;
|
|
300
288
|
df_actions.set_header_edit(i);
|
|
301
289
|
}
|
|
302
290
|
function handle_header_click(event, col) {
|
|
@@ -305,22 +293,19 @@ function handle_header_click(event, col) {
|
|
|
305
293
|
}
|
|
306
294
|
event.preventDefault();
|
|
307
295
|
event.stopPropagation();
|
|
308
|
-
if (!editable)
|
|
309
|
-
return;
|
|
296
|
+
if (!editable) return;
|
|
310
297
|
df_actions.set_editing(false);
|
|
311
298
|
df_actions.handle_header_click(col, editable);
|
|
312
299
|
parent.focus();
|
|
313
300
|
}
|
|
314
301
|
function end_header_edit(event) {
|
|
315
|
-
if (!editable)
|
|
316
|
-
return;
|
|
302
|
+
if (!editable) return;
|
|
317
303
|
df_actions.end_header_edit(event.detail.key);
|
|
318
304
|
parent.focus();
|
|
319
305
|
}
|
|
320
306
|
async function add_row(index) {
|
|
321
307
|
parent.focus();
|
|
322
|
-
if (row_count[1] !== "dynamic")
|
|
323
|
-
return;
|
|
308
|
+
if (row_count[1] !== "dynamic") return;
|
|
324
309
|
const new_row = Array(data[0]?.length || headers.length).fill(0).map((_, i) => {
|
|
325
310
|
const _id = make_id();
|
|
326
311
|
els[_id] = { cell: null, input: null };
|
|
@@ -337,8 +322,7 @@ async function add_row(index) {
|
|
|
337
322
|
}
|
|
338
323
|
async function add_col(index) {
|
|
339
324
|
parent.focus();
|
|
340
|
-
if (col_count[1] !== "dynamic")
|
|
341
|
-
return;
|
|
325
|
+
if (col_count[1] !== "dynamic") return;
|
|
342
326
|
const result = df_actions.add_col(data, headers, make_id, index);
|
|
343
327
|
result.data.forEach((row) => {
|
|
344
328
|
row.forEach((cell) => {
|
|
@@ -363,20 +347,17 @@ function handle_click_outside(event) {
|
|
|
363
347
|
selected_header = false;
|
|
364
348
|
}
|
|
365
349
|
}
|
|
366
|
-
$:
|
|
367
|
-
max = get_max(data);
|
|
350
|
+
$: max = get_max(data);
|
|
368
351
|
let width_calc_timeout;
|
|
369
|
-
$:
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
}
|
|
352
|
+
$: if (cells[0] && cells[0]?.clientWidth) {
|
|
353
|
+
clearTimeout(width_calc_timeout);
|
|
354
|
+
width_calc_timeout = setTimeout(() => set_cell_widths(), 100);
|
|
355
|
+
}
|
|
374
356
|
let width_calculated = false;
|
|
375
|
-
$:
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
}
|
|
357
|
+
$: if (cells[0] && !width_calculated) {
|
|
358
|
+
set_cell_widths();
|
|
359
|
+
width_calculated = true;
|
|
360
|
+
}
|
|
380
361
|
let cells = [];
|
|
381
362
|
let parent;
|
|
382
363
|
let table;
|
|
@@ -390,11 +371,13 @@ function set_cell_widths() {
|
|
|
390
371
|
if (last_width_data_length === data.length && last_width_column_count === column_count && $df_state.sort_state.sort_columns.length > 0) {
|
|
391
372
|
return;
|
|
392
373
|
}
|
|
374
|
+
if (!parent) {
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
393
377
|
last_width_data_length = data.length;
|
|
394
378
|
last_width_column_count = column_count;
|
|
395
379
|
const widths = cells.map((el) => el?.clientWidth || 0);
|
|
396
|
-
if (widths.length === 0)
|
|
397
|
-
return;
|
|
380
|
+
if (widths.length === 0) return;
|
|
398
381
|
if (show_row_numbers) {
|
|
399
382
|
parent.style.setProperty(`--cell-width-row-number`, `${widths[0]}px`);
|
|
400
383
|
}
|
|
@@ -448,8 +431,7 @@ function filter_data(_data, _display_value, _styling) {
|
|
|
448
431
|
data = result.data;
|
|
449
432
|
selected = result.selected;
|
|
450
433
|
}
|
|
451
|
-
$:
|
|
452
|
-
selected_index = !!selected && selected[0];
|
|
434
|
+
$: selected_index = !!selected && selected[0];
|
|
453
435
|
let is_visible = false;
|
|
454
436
|
const set_copy_flash = (value) => {
|
|
455
437
|
df_actions.set_copy_flash(value);
|
|
@@ -488,10 +470,8 @@ afterUpdate(() => {
|
|
|
488
470
|
value_is_output = false;
|
|
489
471
|
});
|
|
490
472
|
function delete_col_at(index) {
|
|
491
|
-
if (col_count[1] !== "dynamic")
|
|
492
|
-
|
|
493
|
-
if (data[0].length <= 1)
|
|
494
|
-
return;
|
|
473
|
+
if (col_count[1] !== "dynamic") return;
|
|
474
|
+
if (data[0].length <= 1) return;
|
|
495
475
|
const result = df_actions.delete_col_at(data, headers, index);
|
|
496
476
|
data = result.data;
|
|
497
477
|
headers = result.headers;
|
|
@@ -508,27 +488,24 @@ function delete_row_at(index) {
|
|
|
508
488
|
df_actions.set_active_header_menu(null);
|
|
509
489
|
}
|
|
510
490
|
let selected_cell_coords;
|
|
511
|
-
$:
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
positions.row_pos || "0px"
|
|
530
|
-
);
|
|
531
|
-
}
|
|
491
|
+
$: if (selected !== false) selected_cell_coords = selected;
|
|
492
|
+
$: if (selected !== false) {
|
|
493
|
+
const positions = calculate_selection_positions(
|
|
494
|
+
selected,
|
|
495
|
+
data,
|
|
496
|
+
els,
|
|
497
|
+
parent,
|
|
498
|
+
table
|
|
499
|
+
);
|
|
500
|
+
document.documentElement.style.setProperty(
|
|
501
|
+
"--selected-col-pos",
|
|
502
|
+
positions.col_pos
|
|
503
|
+
);
|
|
504
|
+
document.documentElement.style.setProperty(
|
|
505
|
+
"--selected-row-pos",
|
|
506
|
+
positions.row_pos || "0px"
|
|
507
|
+
);
|
|
508
|
+
}
|
|
532
509
|
function commit_filter() {
|
|
533
510
|
if ($df_state.current_search_query && show_search === "filter") {
|
|
534
511
|
const filtered_data = [];
|
|
@@ -620,18 +597,13 @@ function init_drag_handlers() {
|
|
|
620
597
|
parent
|
|
621
598
|
);
|
|
622
599
|
}
|
|
623
|
-
$:
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
$:
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
handle_mouse_move = drag_handlers?.handle_mouse_move || (() => {
|
|
631
|
-
});
|
|
632
|
-
$:
|
|
633
|
-
handle_mouse_up = drag_handlers?.handle_mouse_up || (() => {
|
|
634
|
-
});
|
|
600
|
+
$: if (parent) init_drag_handlers();
|
|
601
|
+
$: handle_mouse_down = drag_handlers?.handle_mouse_down || (() => {
|
|
602
|
+
});
|
|
603
|
+
$: handle_mouse_move = drag_handlers?.handle_mouse_move || (() => {
|
|
604
|
+
});
|
|
605
|
+
$: handle_mouse_up = drag_handlers?.handle_mouse_up || (() => {
|
|
606
|
+
});
|
|
635
607
|
function get_cell_display_value(row, col) {
|
|
636
608
|
const is_search_active = $df_state.current_search_query !== void 0;
|
|
637
609
|
if (is_search_active && search_results?.[row]?.[col]) {
|
|
@@ -672,7 +644,6 @@ function get_cell_display_value(row, col) {
|
|
|
672
644
|
class="table-wrap"
|
|
673
645
|
class:dragging={is_dragging}
|
|
674
646
|
class:no-wrap={!wrap}
|
|
675
|
-
style="height:{table_height}px;"
|
|
676
647
|
class:menu-open={active_cell_menu || active_header_menu}
|
|
677
648
|
on:keydown={(e) => handle_keydown(e, df_ctx)}
|
|
678
649
|
on:mousemove={handle_mouse_move}
|
|
@@ -786,11 +757,9 @@ function get_cell_display_value(row, col) {
|
|
|
786
757
|
active_header_menu !== null}
|
|
787
758
|
bind:viewport
|
|
788
759
|
bind:show_scroll_button
|
|
760
|
+
{label}
|
|
789
761
|
on:scroll_top={(_) => {}}
|
|
790
762
|
>
|
|
791
|
-
{#if label && label.length !== 0}
|
|
792
|
-
<caption class="sr-only">{label}</caption>
|
|
793
|
-
{/if}
|
|
794
763
|
<tr slot="thead">
|
|
795
764
|
{#if show_row_numbers}
|
|
796
765
|
<RowNumber is_header={true} />
|
|
@@ -1049,6 +1018,7 @@ function get_cell_display_value(row, col) {
|
|
|
1049
1018
|
.header-row .label {
|
|
1050
1019
|
flex: 1 1 auto;
|
|
1051
1020
|
margin-right: auto;
|
|
1021
|
+
font-family: var(--font-sans);
|
|
1052
1022
|
}
|
|
1053
1023
|
|
|
1054
1024
|
.header-row .label p {
|
|
@@ -2,14 +2,14 @@ import { SvelteComponent } from "svelte";
|
|
|
2
2
|
import type { SelectData } from "@gradio/utils";
|
|
3
3
|
import type { I18nFormatter } from "js/core/src/gradio_helper";
|
|
4
4
|
import { type Client } from "@gradio/client";
|
|
5
|
-
import type { Headers, DataframeValue, Datatype } from "./utils";
|
|
5
|
+
import type { Headers, DataframeValue, Datatype } from "./utils/utils";
|
|
6
6
|
declare const __propDef: {
|
|
7
7
|
props: {
|
|
8
8
|
datatype: Datatype | Datatype[];
|
|
9
|
-
label?:
|
|
10
|
-
show_label?: boolean
|
|
11
|
-
headers?: Headers
|
|
12
|
-
values?: (string | number)[][]
|
|
9
|
+
label?: string | null;
|
|
10
|
+
show_label?: boolean;
|
|
11
|
+
headers?: Headers;
|
|
12
|
+
values?: (string | number)[][];
|
|
13
13
|
col_count: [number, "fixed" | "dynamic"];
|
|
14
14
|
row_count: [number, "fixed" | "dynamic"];
|
|
15
15
|
latex_delimiters: {
|
|
@@ -17,28 +17,28 @@ declare const __propDef: {
|
|
|
17
17
|
right: string;
|
|
18
18
|
display: boolean;
|
|
19
19
|
}[];
|
|
20
|
-
components?: Record<string, any
|
|
21
|
-
editable?: boolean
|
|
22
|
-
wrap?: boolean
|
|
20
|
+
components?: Record<string, any>;
|
|
21
|
+
editable?: boolean;
|
|
22
|
+
wrap?: boolean;
|
|
23
23
|
root: string;
|
|
24
24
|
i18n: I18nFormatter;
|
|
25
|
-
max_height?: number
|
|
26
|
-
line_breaks?: boolean
|
|
27
|
-
column_widths?: string[]
|
|
28
|
-
show_row_numbers?: boolean
|
|
25
|
+
max_height?: number;
|
|
26
|
+
line_breaks?: boolean;
|
|
27
|
+
column_widths?: string[];
|
|
28
|
+
show_row_numbers?: boolean;
|
|
29
29
|
upload: Client["upload"];
|
|
30
30
|
stream_handler: Client["stream"];
|
|
31
|
-
show_fullscreen_button?: boolean
|
|
32
|
-
show_copy_button?: boolean
|
|
33
|
-
value_is_output?: boolean
|
|
31
|
+
show_fullscreen_button?: boolean;
|
|
32
|
+
show_copy_button?: boolean;
|
|
33
|
+
value_is_output?: boolean;
|
|
34
34
|
max_chars?: number | undefined;
|
|
35
|
-
show_search?:
|
|
36
|
-
pinned_columns?: number
|
|
37
|
-
static_columns?: (string | number)[]
|
|
38
|
-
fullscreen?: boolean
|
|
39
|
-
display_value?:
|
|
40
|
-
styling?:
|
|
41
|
-
reset_sort_state?: (
|
|
35
|
+
show_search?: "none" | "search" | "filter";
|
|
36
|
+
pinned_columns?: number;
|
|
37
|
+
static_columns?: (string | number)[];
|
|
38
|
+
fullscreen?: boolean;
|
|
39
|
+
display_value?: string[][] | null;
|
|
40
|
+
styling?: string[][] | null;
|
|
41
|
+
reset_sort_state?: () => void;
|
|
42
42
|
};
|
|
43
43
|
events: {
|
|
44
44
|
fullscreen: CustomEvent<boolean>;
|
|
@@ -50,6 +50,8 @@ declare const __propDef: {
|
|
|
50
50
|
[evt: string]: CustomEvent<any>;
|
|
51
51
|
};
|
|
52
52
|
slots: {};
|
|
53
|
+
exports?: {} | undefined;
|
|
54
|
+
bindings?: string | undefined;
|
|
53
55
|
};
|
|
54
56
|
export type TableProps = typeof __propDef.props;
|
|
55
57
|
export type TableEvents = typeof __propDef.events;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script>import EditableCell from "./EditableCell.svelte";
|
|
2
2
|
import CellMenuButton from "./CellMenuButton.svelte";
|
|
3
|
-
import { is_cell_in_selection } from "./selection_utils";
|
|
3
|
+
import { is_cell_in_selection } from "./utils/selection_utils";
|
|
4
4
|
export let value;
|
|
5
5
|
export let index;
|
|
6
6
|
export let j;
|
|
@@ -42,18 +42,12 @@ function get_cell_position(col_index) {
|
|
|
42
42
|
}).join(" + ");
|
|
43
43
|
return `calc(${previous_widths})`;
|
|
44
44
|
}
|
|
45
|
-
$:
|
|
46
|
-
|
|
47
|
-
$:
|
|
48
|
-
|
|
49
|
-
$:
|
|
50
|
-
|
|
51
|
-
$:
|
|
52
|
-
has_no_bottom = cell_classes.includes("no-bottom");
|
|
53
|
-
$:
|
|
54
|
-
has_no_left = cell_classes.includes("no-left");
|
|
55
|
-
$:
|
|
56
|
-
has_no_right = cell_classes.includes("no-right");
|
|
45
|
+
$: cell_classes = is_cell_selected([index, j], selected_cells || []);
|
|
46
|
+
$: is_in_selection = is_cell_in_selection([index, j], selected_cells);
|
|
47
|
+
$: has_no_top = cell_classes.includes("no-top");
|
|
48
|
+
$: has_no_bottom = cell_classes.includes("no-bottom");
|
|
49
|
+
$: has_no_left = cell_classes.includes("no-left");
|
|
50
|
+
$: has_no_right = cell_classes.includes("no-right");
|
|
57
51
|
</script>
|
|
58
52
|
|
|
59
53
|
<td
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
2
|
import type { I18nFormatter } from "js/core/src/gradio_helper";
|
|
3
|
-
import type { Datatype } from "./utils";
|
|
3
|
+
import type { Datatype } from "./utils/utils";
|
|
4
4
|
declare const __propDef: {
|
|
5
5
|
props: {
|
|
6
6
|
value: string | number;
|
|
@@ -35,9 +35,9 @@ declare const __propDef: {
|
|
|
35
35
|
editing: [number, number] | false;
|
|
36
36
|
max_chars: number | undefined;
|
|
37
37
|
editable: boolean;
|
|
38
|
-
is_static?: boolean
|
|
38
|
+
is_static?: boolean;
|
|
39
39
|
i18n: I18nFormatter;
|
|
40
|
-
components?: Record<string, any
|
|
40
|
+
components?: Record<string, any>;
|
|
41
41
|
el: {
|
|
42
42
|
cell: HTMLTableCellElement | null;
|
|
43
43
|
input: HTMLTextAreaElement | null;
|
|
@@ -46,12 +46,14 @@ declare const __propDef: {
|
|
|
46
46
|
handle_select_row: (row: number) => void;
|
|
47
47
|
is_dragging: boolean;
|
|
48
48
|
display_value: string | undefined;
|
|
49
|
-
wrap?: boolean
|
|
49
|
+
wrap?: boolean;
|
|
50
50
|
};
|
|
51
51
|
events: {
|
|
52
52
|
[evt: string]: CustomEvent<any>;
|
|
53
53
|
};
|
|
54
54
|
slots: {};
|
|
55
|
+
exports?: {} | undefined;
|
|
56
|
+
bindings?: string | undefined;
|
|
55
57
|
};
|
|
56
58
|
export type TableCellProps = typeof __propDef.props;
|
|
57
59
|
export type TableCellEvents = typeof __propDef.events;
|
|
@@ -25,16 +25,11 @@ export let i18n;
|
|
|
25
25
|
export let el;
|
|
26
26
|
export let is_static;
|
|
27
27
|
export let col_count;
|
|
28
|
-
$:
|
|
29
|
-
|
|
30
|
-
$:
|
|
31
|
-
|
|
32
|
-
$:
|
|
33
|
-
filter_index = filter_columns.findIndex((item) => item.col === i);
|
|
34
|
-
$:
|
|
35
|
-
sort_priority = sort_index !== -1 ? sort_index + 1 : null;
|
|
36
|
-
$:
|
|
37
|
-
current_direction = sort_index !== -1 ? sort_columns[sort_index].direction : null;
|
|
28
|
+
$: can_add_columns = col_count && col_count[1] === "dynamic";
|
|
29
|
+
$: sort_index = sort_columns.findIndex((item) => item.col === i);
|
|
30
|
+
$: filter_index = filter_columns.findIndex((item) => item.col === i);
|
|
31
|
+
$: sort_priority = sort_index !== -1 ? sort_index + 1 : null;
|
|
32
|
+
$: current_direction = sort_index !== -1 ? sort_columns[sort_index].direction : null;
|
|
38
33
|
function get_header_position(col_index) {
|
|
39
34
|
if (col_index >= actual_pinned_columns) {
|
|
40
35
|
return "auto";
|
|
@@ -17,13 +17,13 @@ declare const __propDef: {
|
|
|
17
17
|
sort_columns?: {
|
|
18
18
|
col: number;
|
|
19
19
|
direction: SortDirection;
|
|
20
|
-
}[]
|
|
20
|
+
}[];
|
|
21
21
|
filter_columns?: {
|
|
22
22
|
col: number;
|
|
23
23
|
datatype: FilterDatatype;
|
|
24
24
|
filter: string;
|
|
25
25
|
value: string;
|
|
26
|
-
}[]
|
|
26
|
+
}[];
|
|
27
27
|
latex_delimiters: {
|
|
28
28
|
left: string;
|
|
29
29
|
right: string;
|
|
@@ -41,6 +41,8 @@ declare const __propDef: {
|
|
|
41
41
|
[evt: string]: CustomEvent<any>;
|
|
42
42
|
};
|
|
43
43
|
slots: {};
|
|
44
|
+
exports?: {} | undefined;
|
|
45
|
+
bindings?: string | undefined;
|
|
44
46
|
};
|
|
45
47
|
export type TableHeaderProps = typeof __propDef.props;
|
|
46
48
|
export type TableHeaderEvents = typeof __propDef.events;
|
|
@@ -24,8 +24,7 @@ function handle_search_input(e) {
|
|
|
24
24
|
}
|
|
25
25
|
function copy_feedback() {
|
|
26
26
|
copied = true;
|
|
27
|
-
if (timer)
|
|
28
|
-
clearTimeout(timer);
|
|
27
|
+
if (timer) clearTimeout(timer);
|
|
29
28
|
timer = setTimeout(() => {
|
|
30
29
|
copied = false;
|
|
31
30
|
}, 2e3);
|
|
@@ -35,8 +34,7 @@ async function handle_copy() {
|
|
|
35
34
|
copy_feedback();
|
|
36
35
|
}
|
|
37
36
|
onDestroy(() => {
|
|
38
|
-
if (timer)
|
|
39
|
-
clearTimeout(timer);
|
|
37
|
+
if (timer) clearTimeout(timer);
|
|
40
38
|
});
|
|
41
39
|
</script>
|
|
42
40
|
|
|
@@ -91,6 +89,7 @@ onDestroy(() => {
|
|
|
91
89
|
align-items: center;
|
|
92
90
|
gap: var(--size-2);
|
|
93
91
|
flex: 0 0 auto;
|
|
92
|
+
font-family: var(--font-sans);
|
|
94
93
|
}
|
|
95
94
|
|
|
96
95
|
.toolbar-buttons {
|