@gradio/dataframe 0.20.2-dev.0 → 0.21.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 +66 -0
- package/Example.svelte +17 -13
- package/Index.svelte +114 -108
- package/dist/Example.svelte +26 -20
- package/dist/Example.svelte.d.ts +21 -19
- package/dist/Index.svelte +121 -97
- package/dist/Index.svelte.d.ts +4 -164
- package/dist/shared/BooleanCell.svelte +12 -9
- package/dist/shared/BooleanCell.svelte.d.ts +20 -18
- package/dist/shared/CellMenu.svelte +82 -64
- package/dist/shared/CellMenu.svelte.d.ts +39 -37
- package/dist/shared/CellMenuButton.svelte +2 -1
- package/dist/shared/CellMenuButton.svelte.d.ts +18 -16
- package/dist/shared/CellMenuIcons.svelte +2 -1
- package/dist/shared/CellMenuIcons.svelte.d.ts +18 -16
- package/dist/shared/EditableCell.svelte +97 -56
- package/dist/shared/EditableCell.svelte.d.ts +50 -48
- package/dist/shared/EmptyRowButton.svelte +2 -1
- package/dist/shared/EmptyRowButton.svelte.d.ts +18 -16
- package/dist/shared/Example.svelte +2 -1
- package/dist/shared/Example.svelte.d.ts +18 -16
- package/dist/shared/FilterMenu.svelte +53 -39
- package/dist/shared/FilterMenu.svelte.d.ts +20 -18
- package/dist/shared/RowNumber.svelte +3 -2
- package/dist/shared/RowNumber.svelte.d.ts +19 -17
- package/dist/shared/Table.svelte +821 -620
- package/dist/shared/Table.svelte.d.ts +59 -56
- package/dist/shared/TableCell.svelte +95 -50
- package/dist/shared/TableCell.svelte.d.ts +61 -59
- package/dist/shared/TableHeader.svelte +86 -58
- package/dist/shared/TableHeader.svelte.d.ts +55 -53
- package/dist/shared/Toolbar.svelte +49 -39
- package/dist/shared/Toolbar.svelte.d.ts +27 -25
- package/dist/shared/VirtualTable.svelte +207 -154
- package/dist/shared/VirtualTable.svelte.d.ts +40 -37
- package/dist/shared/icons/FilterIcon.svelte +2 -1
- package/dist/shared/icons/FilterIcon.svelte.d.ts +16 -14
- package/dist/shared/icons/Padlock.svelte.d.ts +22 -21
- package/dist/shared/icons/SelectionButtons.svelte +15 -5
- package/dist/shared/icons/SelectionButtons.svelte.d.ts +20 -18
- package/dist/shared/icons/SortArrowDown.svelte +2 -1
- package/dist/shared/icons/SortArrowDown.svelte.d.ts +18 -16
- package/dist/shared/icons/SortArrowUp.svelte +2 -1
- package/dist/shared/icons/SortArrowUp.svelte.d.ts +18 -16
- package/dist/shared/icons/SortButtonDown.svelte.d.ts +22 -21
- package/dist/shared/icons/SortButtonUp.svelte.d.ts +22 -21
- package/dist/shared/icons/SortIcon.svelte +12 -8
- package/dist/shared/icons/SortIcon.svelte.d.ts +22 -20
- package/dist/shared/utils/data_processing.d.ts +1 -1
- package/dist/standalone/Index.svelte +103 -74
- package/dist/standalone/Index.svelte.d.ts +41 -39
- package/dist/standalone/stubs/Upload.svelte +5 -4
- package/dist/standalone/stubs/Upload.svelte.d.ts +35 -25
- package/package.json +16 -15
- package/shared/Table.svelte +4 -4
- package/shared/VirtualTable.svelte +1 -1
- package/standalone/Index.svelte +16 -15
|
@@ -1,63 +1,66 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import type { SelectData } from "@gradio/utils";
|
|
3
2
|
import type { I18nFormatter } from "js/core/src/gradio_helper";
|
|
4
3
|
import { type Client } from "@gradio/client";
|
|
5
4
|
import type { Headers, DataframeValue, Datatype, EditData } from "./utils/utils";
|
|
6
5
|
import type { CellValue } from "./types";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
left: string;
|
|
18
|
-
right: string;
|
|
19
|
-
display: boolean;
|
|
20
|
-
}[];
|
|
21
|
-
components?: Record<string, any>;
|
|
22
|
-
editable?: boolean;
|
|
23
|
-
wrap?: boolean;
|
|
24
|
-
root: string;
|
|
25
|
-
i18n: I18nFormatter;
|
|
26
|
-
max_height?: number;
|
|
27
|
-
line_breaks?: boolean;
|
|
28
|
-
column_widths?: string[];
|
|
29
|
-
show_row_numbers?: boolean;
|
|
30
|
-
upload: Client["upload"];
|
|
31
|
-
stream_handler: Client["stream"];
|
|
32
|
-
buttons?: string[] | null;
|
|
33
|
-
value_is_output?: boolean;
|
|
34
|
-
max_chars?: number | undefined;
|
|
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;
|
|
6
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
7
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
8
|
+
$$bindings?: Bindings;
|
|
9
|
+
} & Exports;
|
|
10
|
+
(internal: unknown, props: Props & {
|
|
11
|
+
$$events?: Events;
|
|
12
|
+
$$slots?: Slots;
|
|
13
|
+
}): Exports & {
|
|
14
|
+
$set?: any;
|
|
15
|
+
$on?: any;
|
|
42
16
|
};
|
|
43
|
-
|
|
44
|
-
fullscreen: CustomEvent<boolean>;
|
|
45
|
-
change: CustomEvent<DataframeValue>;
|
|
46
|
-
input: CustomEvent<undefined>;
|
|
47
|
-
select: CustomEvent<SelectData>;
|
|
48
|
-
search: CustomEvent<string | null>;
|
|
49
|
-
edit: CustomEvent<EditData>;
|
|
50
|
-
} & {
|
|
51
|
-
[evt: string]: CustomEvent<any>;
|
|
52
|
-
};
|
|
53
|
-
slots: {};
|
|
54
|
-
exports?: {} | undefined;
|
|
55
|
-
bindings?: string | undefined;
|
|
56
|
-
};
|
|
57
|
-
export type TableProps = typeof __propDef.props;
|
|
58
|
-
export type TableEvents = typeof __propDef.events;
|
|
59
|
-
export type TableSlots = typeof __propDef.slots;
|
|
60
|
-
export default class Table extends SvelteComponent<TableProps, TableEvents, TableSlots> {
|
|
61
|
-
get reset_sort_state(): () => void;
|
|
17
|
+
z_$$bindings?: Bindings;
|
|
62
18
|
}
|
|
63
|
-
|
|
19
|
+
declare const Table: $$__sveltets_2_IsomorphicComponent<{
|
|
20
|
+
datatype: Datatype | Datatype[];
|
|
21
|
+
label?: string | null;
|
|
22
|
+
show_label?: boolean;
|
|
23
|
+
headers?: Headers;
|
|
24
|
+
values?: CellValue[][];
|
|
25
|
+
col_count: [number, "fixed" | "dynamic"];
|
|
26
|
+
row_count: [number, "fixed" | "dynamic"];
|
|
27
|
+
latex_delimiters: {
|
|
28
|
+
left: string;
|
|
29
|
+
right: string;
|
|
30
|
+
display: boolean;
|
|
31
|
+
}[];
|
|
32
|
+
components?: Record<string, any>;
|
|
33
|
+
editable?: boolean;
|
|
34
|
+
wrap?: boolean;
|
|
35
|
+
root: string;
|
|
36
|
+
i18n: I18nFormatter;
|
|
37
|
+
max_height?: number;
|
|
38
|
+
line_breaks?: boolean;
|
|
39
|
+
column_widths?: string[];
|
|
40
|
+
show_row_numbers?: boolean;
|
|
41
|
+
upload: Client["upload"];
|
|
42
|
+
stream_handler: Client["stream"];
|
|
43
|
+
buttons?: string[] | null;
|
|
44
|
+
value_is_output?: boolean;
|
|
45
|
+
max_chars?: number | undefined;
|
|
46
|
+
show_search?: "none" | "search" | "filter";
|
|
47
|
+
pinned_columns?: number;
|
|
48
|
+
static_columns?: (string | number)[];
|
|
49
|
+
fullscreen?: boolean;
|
|
50
|
+
display_value?: string[][] | null;
|
|
51
|
+
styling?: string[][] | null;
|
|
52
|
+
reset_sort_state?: () => void;
|
|
53
|
+
}, {
|
|
54
|
+
fullscreen: CustomEvent<boolean>;
|
|
55
|
+
change: CustomEvent<DataframeValue>;
|
|
56
|
+
input: CustomEvent<undefined>;
|
|
57
|
+
select: CustomEvent<SelectData>;
|
|
58
|
+
search: CustomEvent<string | null>;
|
|
59
|
+
edit: CustomEvent<EditData>;
|
|
60
|
+
} & {
|
|
61
|
+
[evt: string]: CustomEvent<any>;
|
|
62
|
+
}, {}, {
|
|
63
|
+
reset_sort_state: () => void;
|
|
64
|
+
}, string>;
|
|
65
|
+
type Table = InstanceType<typeof Table>;
|
|
66
|
+
export default Table;
|
|
@@ -1,53 +1,98 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export let
|
|
10
|
-
export let
|
|
11
|
-
export let
|
|
12
|
-
export let
|
|
13
|
-
export let
|
|
14
|
-
export let
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export let
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
export let
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
export let
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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 { Datatype } from "./utils/utils";
|
|
6
|
+
import type { CellValue } from "./types";
|
|
7
|
+
import { is_cell_in_selection } from "./utils/selection_utils";
|
|
8
|
+
|
|
9
|
+
export let value: CellValue;
|
|
10
|
+
export let index: number;
|
|
11
|
+
export let j: number;
|
|
12
|
+
export let actual_pinned_columns: number;
|
|
13
|
+
export let get_cell_width: (index: number) => string;
|
|
14
|
+
export let handle_cell_click: (
|
|
15
|
+
event: MouseEvent,
|
|
16
|
+
row: number,
|
|
17
|
+
col: number
|
|
18
|
+
) => void;
|
|
19
|
+
export let handle_blur: (
|
|
20
|
+
event: CustomEvent<{
|
|
21
|
+
blur_event: FocusEvent;
|
|
22
|
+
coords: [number, number];
|
|
23
|
+
}>
|
|
24
|
+
) => void;
|
|
25
|
+
export let toggle_cell_menu: (
|
|
26
|
+
event: MouseEvent,
|
|
27
|
+
row: number,
|
|
28
|
+
col: number
|
|
29
|
+
) => void;
|
|
30
|
+
export let is_cell_selected: (
|
|
31
|
+
coords: [number, number],
|
|
32
|
+
selected_cells: [number, number][]
|
|
33
|
+
) => string;
|
|
34
|
+
export let should_show_cell_menu: (
|
|
35
|
+
coords: [number, number],
|
|
36
|
+
selected_cells: [number, number][],
|
|
37
|
+
editable: boolean
|
|
38
|
+
) => boolean;
|
|
39
|
+
export let selected_cells: [number, number][];
|
|
40
|
+
export let copy_flash: boolean;
|
|
41
|
+
export let active_cell_menu: {
|
|
42
|
+
row: number;
|
|
43
|
+
col: number;
|
|
44
|
+
x: number;
|
|
45
|
+
y: number;
|
|
46
|
+
} | null;
|
|
47
|
+
export let styling: string | undefined;
|
|
48
|
+
export let latex_delimiters: {
|
|
49
|
+
left: string;
|
|
50
|
+
right: string;
|
|
51
|
+
display: boolean;
|
|
52
|
+
}[];
|
|
53
|
+
export let line_breaks: boolean;
|
|
54
|
+
export let datatype: Datatype;
|
|
55
|
+
export let editing: [number, number] | false;
|
|
56
|
+
export let max_chars: number | undefined;
|
|
57
|
+
export let editable: boolean;
|
|
58
|
+
export let is_static = false;
|
|
59
|
+
export let i18n: I18nFormatter;
|
|
60
|
+
export let components: Record<string, any> = {};
|
|
61
|
+
export let el: {
|
|
62
|
+
cell: HTMLTableCellElement | null;
|
|
63
|
+
input: HTMLTextAreaElement | null;
|
|
64
|
+
};
|
|
65
|
+
export let handle_select_column: (col: number) => void;
|
|
66
|
+
export let handle_select_row: (row: number) => void;
|
|
67
|
+
export let is_dragging: boolean;
|
|
68
|
+
export let display_value: string | undefined;
|
|
69
|
+
export let wrap = false;
|
|
70
|
+
|
|
71
|
+
function get_cell_position(col_index: number): string {
|
|
72
|
+
if (col_index >= actual_pinned_columns) {
|
|
73
|
+
return "auto";
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (col_index === 0) {
|
|
77
|
+
return "0";
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const previous_widths = Array(col_index)
|
|
81
|
+
.fill(0)
|
|
82
|
+
.map((_, idx) => {
|
|
83
|
+
return get_cell_width(idx);
|
|
84
|
+
})
|
|
85
|
+
.join(" + ");
|
|
86
|
+
|
|
87
|
+
return `calc(${previous_widths})`;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
$: cell_classes = is_cell_selected([index, j], selected_cells || []);
|
|
91
|
+
$: is_in_selection = is_cell_in_selection([index, j], selected_cells);
|
|
92
|
+
$: has_no_top = cell_classes.includes("no-top");
|
|
93
|
+
$: has_no_bottom = cell_classes.includes("no-bottom");
|
|
94
|
+
$: has_no_left = cell_classes.includes("no-left");
|
|
95
|
+
$: has_no_right = cell_classes.includes("no-right");
|
|
51
96
|
</script>
|
|
52
97
|
|
|
53
98
|
<td
|
|
@@ -1,64 +1,66 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import type { I18nFormatter } from "js/core/src/gradio_helper";
|
|
3
2
|
import type { Datatype } from "./utils/utils";
|
|
4
3
|
import type { CellValue } from "./types";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
coords: [number, number];
|
|
16
|
-
}>) => void;
|
|
17
|
-
toggle_cell_menu: (event: MouseEvent, row: number, col: number) => void;
|
|
18
|
-
is_cell_selected: (coords: [number, number], selected_cells: [number, number][]) => string;
|
|
19
|
-
should_show_cell_menu: (coords: [number, number], selected_cells: [number, number][], editable: boolean) => boolean;
|
|
20
|
-
selected_cells: [number, number][];
|
|
21
|
-
copy_flash: boolean;
|
|
22
|
-
active_cell_menu: {
|
|
23
|
-
row: number;
|
|
24
|
-
col: number;
|
|
25
|
-
x: number;
|
|
26
|
-
y: number;
|
|
27
|
-
} | null;
|
|
28
|
-
styling: string | undefined;
|
|
29
|
-
latex_delimiters: {
|
|
30
|
-
left: string;
|
|
31
|
-
right: string;
|
|
32
|
-
display: boolean;
|
|
33
|
-
}[];
|
|
34
|
-
line_breaks: boolean;
|
|
35
|
-
datatype: Datatype;
|
|
36
|
-
editing: [number, number] | false;
|
|
37
|
-
max_chars: number | undefined;
|
|
38
|
-
editable: boolean;
|
|
39
|
-
is_static?: boolean;
|
|
40
|
-
i18n: I18nFormatter;
|
|
41
|
-
components?: Record<string, any>;
|
|
42
|
-
el: {
|
|
43
|
-
cell: HTMLTableCellElement | null;
|
|
44
|
-
input: HTMLTextAreaElement | null;
|
|
45
|
-
};
|
|
46
|
-
handle_select_column: (col: number) => void;
|
|
47
|
-
handle_select_row: (row: number) => void;
|
|
48
|
-
is_dragging: boolean;
|
|
49
|
-
display_value: string | undefined;
|
|
50
|
-
wrap?: boolean;
|
|
4
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
5
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
6
|
+
$$bindings?: Bindings;
|
|
7
|
+
} & Exports;
|
|
8
|
+
(internal: unknown, props: Props & {
|
|
9
|
+
$$events?: Events;
|
|
10
|
+
$$slots?: Slots;
|
|
11
|
+
}): Exports & {
|
|
12
|
+
$set?: any;
|
|
13
|
+
$on?: any;
|
|
51
14
|
};
|
|
52
|
-
|
|
53
|
-
[evt: string]: CustomEvent<any>;
|
|
54
|
-
};
|
|
55
|
-
slots: {};
|
|
56
|
-
exports?: {} | undefined;
|
|
57
|
-
bindings?: string | undefined;
|
|
58
|
-
};
|
|
59
|
-
export type TableCellProps = typeof __propDef.props;
|
|
60
|
-
export type TableCellEvents = typeof __propDef.events;
|
|
61
|
-
export type TableCellSlots = typeof __propDef.slots;
|
|
62
|
-
export default class TableCell extends SvelteComponent<TableCellProps, TableCellEvents, TableCellSlots> {
|
|
15
|
+
z_$$bindings?: Bindings;
|
|
63
16
|
}
|
|
64
|
-
|
|
17
|
+
declare const TableCell: $$__sveltets_2_IsomorphicComponent<{
|
|
18
|
+
value: CellValue;
|
|
19
|
+
index: number;
|
|
20
|
+
j: number;
|
|
21
|
+
actual_pinned_columns: number;
|
|
22
|
+
get_cell_width: (index: number) => string;
|
|
23
|
+
handle_cell_click: (event: MouseEvent, row: number, col: number) => void;
|
|
24
|
+
handle_blur: (event: CustomEvent<{
|
|
25
|
+
blur_event: FocusEvent;
|
|
26
|
+
coords: [number, number];
|
|
27
|
+
}>) => void;
|
|
28
|
+
toggle_cell_menu: (event: MouseEvent, row: number, col: number) => void;
|
|
29
|
+
is_cell_selected: (coords: [number, number], selected_cells: [number, number][]) => string;
|
|
30
|
+
should_show_cell_menu: (coords: [number, number], selected_cells: [number, number][], editable: boolean) => boolean;
|
|
31
|
+
selected_cells: [number, number][];
|
|
32
|
+
copy_flash: boolean;
|
|
33
|
+
active_cell_menu: {
|
|
34
|
+
row: number;
|
|
35
|
+
col: number;
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
} | null;
|
|
39
|
+
styling: string | undefined;
|
|
40
|
+
latex_delimiters: {
|
|
41
|
+
left: string;
|
|
42
|
+
right: string;
|
|
43
|
+
display: boolean;
|
|
44
|
+
}[];
|
|
45
|
+
line_breaks: boolean;
|
|
46
|
+
datatype: Datatype;
|
|
47
|
+
editing: [number, number] | false;
|
|
48
|
+
max_chars: number | undefined;
|
|
49
|
+
editable: boolean;
|
|
50
|
+
is_static?: boolean;
|
|
51
|
+
i18n: I18nFormatter;
|
|
52
|
+
components?: Record<string, any>;
|
|
53
|
+
el: {
|
|
54
|
+
cell: HTMLTableCellElement | null;
|
|
55
|
+
input: HTMLTextAreaElement | null;
|
|
56
|
+
};
|
|
57
|
+
handle_select_column: (col: number) => void;
|
|
58
|
+
handle_select_row: (row: number) => void;
|
|
59
|
+
is_dragging: boolean;
|
|
60
|
+
display_value: string | undefined;
|
|
61
|
+
wrap?: boolean;
|
|
62
|
+
}, {
|
|
63
|
+
[evt: string]: CustomEvent<any>;
|
|
64
|
+
}, {}, {}, string>;
|
|
65
|
+
type TableCell = InstanceType<typeof TableCell>;
|
|
66
|
+
export default TableCell;
|
|
@@ -1,61 +1,89 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export let
|
|
15
|
-
export let
|
|
16
|
-
export let
|
|
17
|
-
export let
|
|
18
|
-
export let
|
|
19
|
-
export let
|
|
20
|
-
export let
|
|
21
|
-
export let
|
|
22
|
-
export let
|
|
23
|
-
export let
|
|
24
|
-
export let
|
|
25
|
-
export let
|
|
26
|
-
export let
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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 { get_sort_status } from "./utils/sort_utils";
|
|
6
|
+
import Padlock from "./icons/Padlock.svelte";
|
|
7
|
+
import SortArrowUp from "./icons/SortArrowUp.svelte";
|
|
8
|
+
import SortArrowDown from "./icons/SortArrowDown.svelte";
|
|
9
|
+
import type { SortDirection } from "./context/dataframe_context";
|
|
10
|
+
import CellMenuIcons from "./CellMenuIcons.svelte";
|
|
11
|
+
import type { FilterDatatype } from "./context/dataframe_context";
|
|
12
|
+
import type { Datatype } from "./utils/utils";
|
|
13
|
+
import { BaseCheckbox } from "@gradio/checkbox";
|
|
14
|
+
export let value: string;
|
|
15
|
+
export let i: number;
|
|
16
|
+
export let datatype: Datatype = "str";
|
|
17
|
+
export let actual_pinned_columns: number;
|
|
18
|
+
export let header_edit: number | false;
|
|
19
|
+
export let selected_header: number | false;
|
|
20
|
+
export let headers: string[];
|
|
21
|
+
export let get_cell_width: (index: number) => string;
|
|
22
|
+
export let handle_header_click: (event: MouseEvent, col: number) => void;
|
|
23
|
+
export let toggle_header_menu: (event: MouseEvent, col: number) => void;
|
|
24
|
+
export let end_header_edit: (event: CustomEvent<KeyboardEvent>) => void;
|
|
25
|
+
export let sort_columns: { col: number; direction: SortDirection }[] = [];
|
|
26
|
+
export let filter_columns: {
|
|
27
|
+
col: number;
|
|
28
|
+
datatype: FilterDatatype;
|
|
29
|
+
filter: string;
|
|
30
|
+
value: string;
|
|
31
|
+
}[] = [];
|
|
32
|
+
|
|
33
|
+
export let latex_delimiters: {
|
|
34
|
+
left: string;
|
|
35
|
+
right: string;
|
|
36
|
+
display: boolean;
|
|
37
|
+
}[];
|
|
38
|
+
export let line_breaks: boolean;
|
|
39
|
+
export let max_chars: number | undefined;
|
|
40
|
+
export let editable: boolean;
|
|
41
|
+
export let i18n: I18nFormatter;
|
|
42
|
+
export let el: HTMLTextAreaElement | null;
|
|
43
|
+
export let is_static: boolean;
|
|
44
|
+
export let col_count: [number, "fixed" | "dynamic"];
|
|
45
|
+
export let data: any[] = [];
|
|
46
|
+
export let on_select_all:
|
|
47
|
+
| ((col: number, checked: boolean) => void)
|
|
48
|
+
| undefined = undefined;
|
|
49
|
+
|
|
50
|
+
$: can_add_columns = col_count && col_count[1] === "dynamic";
|
|
51
|
+
$: is_bool_column = datatype === "bool";
|
|
52
|
+
|
|
53
|
+
$: select_all_state = (() => {
|
|
54
|
+
if (!is_bool_column || data.length === 0) return "unchecked";
|
|
55
|
+
const true_count = data.filter(
|
|
56
|
+
(row) => row[i]?.value === true || row[i]?.value === "true"
|
|
57
|
+
).length;
|
|
58
|
+
if (true_count === 0) return "unchecked";
|
|
59
|
+
if (true_count === data.length) return "checked";
|
|
60
|
+
return "indeterminate";
|
|
61
|
+
})();
|
|
62
|
+
|
|
63
|
+
$: sort_index = sort_columns.findIndex((item) => item.col === i);
|
|
64
|
+
$: filter_index = filter_columns.findIndex((item) => item.col === i);
|
|
65
|
+
$: sort_priority = sort_index !== -1 ? sort_index + 1 : null;
|
|
66
|
+
$: current_direction =
|
|
67
|
+
sort_index !== -1 ? sort_columns[sort_index].direction : null;
|
|
68
|
+
|
|
69
|
+
function get_header_position(col_index: number): string {
|
|
70
|
+
if (col_index >= actual_pinned_columns) {
|
|
71
|
+
return "auto";
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (col_index === 0) {
|
|
75
|
+
return "0";
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const previous_widths = Array(col_index)
|
|
79
|
+
.fill(0)
|
|
80
|
+
.map((_, idx) => {
|
|
81
|
+
return get_cell_width(idx);
|
|
82
|
+
})
|
|
83
|
+
.join(" + ");
|
|
84
|
+
|
|
85
|
+
return `calc(${previous_widths})`;
|
|
86
|
+
}
|
|
59
87
|
</script>
|
|
60
88
|
|
|
61
89
|
<th
|
|
@@ -1,59 +1,61 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import type { I18nFormatter } from "js/core/src/gradio_helper";
|
|
3
2
|
import type { SortDirection } from "./context/dataframe_context";
|
|
4
3
|
import type { FilterDatatype } from "./context/dataframe_context";
|
|
5
4
|
import type { Datatype } from "./utils/utils";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
handle_header_click: (event: MouseEvent, col: number) => void;
|
|
17
|
-
toggle_header_menu: (event: MouseEvent, col: number) => void;
|
|
18
|
-
end_header_edit: (event: CustomEvent<KeyboardEvent>) => void;
|
|
19
|
-
sort_columns?: {
|
|
20
|
-
col: number;
|
|
21
|
-
direction: SortDirection;
|
|
22
|
-
}[];
|
|
23
|
-
filter_columns?: {
|
|
24
|
-
col: number;
|
|
25
|
-
datatype: FilterDatatype;
|
|
26
|
-
filter: string;
|
|
27
|
-
value: string;
|
|
28
|
-
}[];
|
|
29
|
-
latex_delimiters: {
|
|
30
|
-
left: string;
|
|
31
|
-
right: string;
|
|
32
|
-
display: boolean;
|
|
33
|
-
}[];
|
|
34
|
-
line_breaks: boolean;
|
|
35
|
-
max_chars: number | undefined;
|
|
36
|
-
editable: boolean;
|
|
37
|
-
i18n: I18nFormatter;
|
|
38
|
-
el: HTMLTextAreaElement | null;
|
|
39
|
-
is_static: boolean;
|
|
40
|
-
col_count: [number, "fixed" | "dynamic"];
|
|
41
|
-
data?: any[];
|
|
42
|
-
on_select_all?: ((col: number, checked: boolean) => void) | undefined;
|
|
43
|
-
};
|
|
44
|
-
events: {
|
|
45
|
-
click: MouseEvent;
|
|
46
|
-
mousedown: MouseEvent;
|
|
47
|
-
} & {
|
|
48
|
-
[evt: string]: CustomEvent<any>;
|
|
5
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
6
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
7
|
+
$$bindings?: Bindings;
|
|
8
|
+
} & Exports;
|
|
9
|
+
(internal: unknown, props: Props & {
|
|
10
|
+
$$events?: Events;
|
|
11
|
+
$$slots?: Slots;
|
|
12
|
+
}): Exports & {
|
|
13
|
+
$set?: any;
|
|
14
|
+
$on?: any;
|
|
49
15
|
};
|
|
50
|
-
|
|
51
|
-
exports?: {} | undefined;
|
|
52
|
-
bindings?: string | undefined;
|
|
53
|
-
};
|
|
54
|
-
export type TableHeaderProps = typeof __propDef.props;
|
|
55
|
-
export type TableHeaderEvents = typeof __propDef.events;
|
|
56
|
-
export type TableHeaderSlots = typeof __propDef.slots;
|
|
57
|
-
export default class TableHeader extends SvelteComponent<TableHeaderProps, TableHeaderEvents, TableHeaderSlots> {
|
|
16
|
+
z_$$bindings?: Bindings;
|
|
58
17
|
}
|
|
59
|
-
|
|
18
|
+
declare const TableHeader: $$__sveltets_2_IsomorphicComponent<{
|
|
19
|
+
value: string;
|
|
20
|
+
i: number;
|
|
21
|
+
datatype?: Datatype;
|
|
22
|
+
actual_pinned_columns: number;
|
|
23
|
+
header_edit: number | false;
|
|
24
|
+
selected_header: number | false;
|
|
25
|
+
headers: string[];
|
|
26
|
+
get_cell_width: (index: number) => string;
|
|
27
|
+
handle_header_click: (event: MouseEvent, col: number) => void;
|
|
28
|
+
toggle_header_menu: (event: MouseEvent, col: number) => void;
|
|
29
|
+
end_header_edit: (event: CustomEvent<KeyboardEvent>) => void;
|
|
30
|
+
sort_columns?: {
|
|
31
|
+
col: number;
|
|
32
|
+
direction: SortDirection;
|
|
33
|
+
}[];
|
|
34
|
+
filter_columns?: {
|
|
35
|
+
col: number;
|
|
36
|
+
datatype: FilterDatatype;
|
|
37
|
+
filter: string;
|
|
38
|
+
value: string;
|
|
39
|
+
}[];
|
|
40
|
+
latex_delimiters: {
|
|
41
|
+
left: string;
|
|
42
|
+
right: string;
|
|
43
|
+
display: boolean;
|
|
44
|
+
}[];
|
|
45
|
+
line_breaks: boolean;
|
|
46
|
+
max_chars: number | undefined;
|
|
47
|
+
editable: boolean;
|
|
48
|
+
i18n: I18nFormatter;
|
|
49
|
+
el: HTMLTextAreaElement | null;
|
|
50
|
+
is_static: boolean;
|
|
51
|
+
col_count: [number, "fixed" | "dynamic"];
|
|
52
|
+
data?: any[];
|
|
53
|
+
on_select_all?: ((col: number, checked: boolean) => void) | undefined;
|
|
54
|
+
}, {
|
|
55
|
+
click: PointerEvent;
|
|
56
|
+
mousedown: MouseEvent;
|
|
57
|
+
} & {
|
|
58
|
+
[evt: string]: CustomEvent<any>;
|
|
59
|
+
}, {}, {}, string>;
|
|
60
|
+
type TableHeader = InstanceType<typeof TableHeader>;
|
|
61
|
+
export default TableHeader;
|