@gradio/dataframe 0.21.7 → 0.23.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 +27 -0
- package/Dataframe.test.ts +697 -32
- package/Index.svelte +107 -106
- package/dist/Index.svelte +107 -106
- package/dist/Index.svelte.d.ts +0 -1
- package/dist/shared/BooleanCell.svelte +12 -6
- package/dist/shared/BooleanCell.svelte.d.ts +4 -18
- package/dist/shared/CellMenu.svelte +74 -49
- package/dist/shared/CellMenu.svelte.d.ts +5 -19
- package/dist/shared/CellMenuButton.svelte +3 -3
- package/dist/shared/CellMenuButton.svelte.d.ts +4 -18
- package/dist/shared/CellMenuIcons.svelte +1 -1
- package/dist/shared/CellMenuIcons.svelte.d.ts +4 -18
- package/dist/shared/DataCell.svelte +189 -0
- package/dist/shared/DataCell.svelte.d.ts +44 -0
- package/dist/shared/EditableCell.svelte +88 -64
- package/dist/shared/EditableCell.svelte.d.ts +8 -26
- package/dist/shared/EmptyRowButton.svelte +2 -2
- package/dist/shared/EmptyRowButton.svelte.d.ts +4 -18
- package/dist/shared/FilterMenu.svelte +26 -18
- package/dist/shared/FilterMenu.svelte.d.ts +5 -21
- package/dist/shared/HeaderCell.svelte +218 -0
- package/dist/shared/HeaderCell.svelte.d.ts +30 -0
- package/dist/shared/RowNumber.svelte +4 -2
- package/dist/shared/RowNumber.svelte.d.ts +4 -18
- package/dist/shared/Table.svelte +1039 -947
- package/dist/shared/Table.svelte.d.ts +12 -30
- package/dist/shared/Toolbar.svelte +32 -22
- package/dist/shared/Toolbar.svelte.d.ts +6 -21
- package/dist/shared/column_measurement.svelte.d.ts +20 -0
- package/dist/shared/column_measurement.svelte.js +79 -0
- package/dist/shared/icons/FilterIcon.svelte +14 -6
- package/dist/shared/icons/FilterIcon.svelte.d.ts +14 -6
- package/dist/shared/icons/Padlock.svelte +6 -2
- package/dist/shared/icons/Padlock.svelte.d.ts +4 -25
- package/dist/shared/icons/SelectionButtons.svelte +23 -8
- package/dist/shared/icons/SelectionButtons.svelte.d.ts +4 -18
- package/dist/shared/icons/SortButtonDown.svelte +15 -4
- package/dist/shared/icons/SortButtonDown.svelte.d.ts +4 -25
- package/dist/shared/icons/SortButtonUp.svelte +15 -5
- package/dist/shared/icons/SortButtonUp.svelte.d.ts +4 -25
- package/dist/shared/icons/SortIcon.svelte +13 -7
- package/dist/shared/icons/SortIcon.svelte.d.ts +7 -21
- package/dist/shared/tanstack/index.d.ts +3 -0
- package/dist/shared/tanstack/index.js +3 -0
- package/dist/shared/tanstack/table.svelte.d.ts +26 -0
- package/dist/shared/tanstack/table.svelte.js +102 -0
- package/dist/shared/tanstack/virtual.svelte.d.ts +14 -0
- package/dist/shared/tanstack/virtual.svelte.js +76 -0
- package/dist/shared/types.d.ts +2 -0
- package/dist/shared/utils/filter.d.ts +5 -0
- package/dist/shared/utils/filter.js +62 -0
- package/dist/shared/utils/selection_utils.js +1 -1
- package/dist/shared/utils/table_utils.d.ts +1 -14
- package/dist/shared/utils/table_utils.js +0 -61
- package/dist/standalone/Index.svelte +71 -46
- package/dist/standalone/Index.svelte.d.ts +4 -23
- package/dist/types.d.ts +32 -0
- package/dist/types.js +1 -0
- package/package.json +12 -11
- package/shared/BooleanCell.svelte +12 -6
- package/shared/CellMenu.svelte +74 -49
- package/shared/CellMenuButton.svelte +3 -3
- package/shared/CellMenuIcons.svelte +1 -1
- package/shared/DataCell.svelte +189 -0
- package/shared/EditableCell.svelte +88 -64
- package/shared/EmptyRowButton.svelte +2 -2
- package/shared/FilterMenu.svelte +26 -18
- package/shared/HeaderCell.svelte +218 -0
- package/shared/RowNumber.svelte +4 -2
- package/shared/Table.svelte +1039 -947
- package/shared/Toolbar.svelte +32 -22
- package/shared/column_measurement.svelte.ts +103 -0
- package/shared/icons/FilterIcon.svelte +14 -6
- package/shared/icons/Padlock.svelte +6 -2
- package/shared/icons/SelectionButtons.svelte +23 -8
- package/shared/icons/SortButtonDown.svelte +15 -4
- package/shared/icons/SortButtonUp.svelte +15 -5
- package/shared/icons/SortIcon.svelte +13 -7
- package/shared/tanstack/index.ts +23 -0
- package/shared/tanstack/table.svelte.ts +117 -0
- package/shared/tanstack/virtual.svelte.ts +105 -0
- package/shared/types.ts +3 -0
- package/shared/utils/filter.ts +66 -0
- package/shared/utils/selection_utils.ts +1 -1
- package/shared/utils/table_utils.ts +1 -100
- package/standalone/Index.svelte +71 -46
- package/test/filter.test.ts +350 -0
- package/test/selection_utils.test.ts +416 -0
- package/test/table_utils.test.ts +45 -112
- package/types.ts +34 -0
- package/dist/shared/TableCell.svelte +0 -330
- package/dist/shared/TableCell.svelte.d.ts +0 -66
- package/dist/shared/TableHeader.svelte +0 -344
- package/dist/shared/TableHeader.svelte.d.ts +0 -61
- package/dist/shared/VirtualTable.svelte +0 -379
- package/dist/shared/VirtualTable.svelte.d.ts +0 -42
- package/dist/shared/context/dataframe_context.d.ts +0 -180
- package/dist/shared/context/dataframe_context.js +0 -412
- package/dist/shared/icons/SortArrowDown.svelte +0 -25
- package/dist/shared/icons/SortArrowDown.svelte.d.ts +0 -20
- package/dist/shared/icons/SortArrowUp.svelte +0 -25
- package/dist/shared/icons/SortArrowUp.svelte.d.ts +0 -20
- package/dist/shared/utils/data_processing.d.ts +0 -14
- package/dist/shared/utils/data_processing.js +0 -47
- package/dist/shared/utils/drag_utils.d.ts +0 -15
- package/dist/shared/utils/drag_utils.js +0 -67
- package/dist/shared/utils/filter_utils.d.ts +0 -29
- package/dist/shared/utils/filter_utils.js +0 -123
- package/dist/shared/utils/keyboard_utils.d.ts +0 -3
- package/dist/shared/utils/keyboard_utils.js +0 -236
- package/dist/shared/utils/menu_utils.d.ts +0 -42
- package/dist/shared/utils/menu_utils.js +0 -58
- package/dist/shared/utils/sort_utils.d.ts +0 -26
- package/dist/shared/utils/sort_utils.js +0 -59
- package/shared/TableCell.svelte +0 -330
- package/shared/TableHeader.svelte +0 -344
- package/shared/VirtualTable.svelte +0 -379
- package/shared/context/dataframe_context.ts +0 -701
- package/shared/icons/SortArrowDown.svelte +0 -25
- package/shared/icons/SortArrowUp.svelte +0 -25
- package/shared/utils/data_processing.ts +0 -77
- package/shared/utils/drag_utils.ts +0 -105
- package/shared/utils/filter_utils.ts +0 -208
- package/shared/utils/keyboard_utils.ts +0 -309
- package/shared/utils/menu_utils.ts +0 -115
- package/shared/utils/sort_utils.ts +0 -91
- package/test/sort_utils.test.ts +0 -323
|
@@ -1,48 +1,71 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { createEventDispatcher } from "svelte";
|
|
3
2
|
import { MarkdownCode } from "@gradio/markdown-code";
|
|
4
3
|
import type { I18nFormatter } from "@gradio/utils";
|
|
5
4
|
import type { CellValue } from "./types";
|
|
6
5
|
import SelectionButtons from "./icons/SelectionButtons.svelte";
|
|
7
6
|
import BooleanCell from "./BooleanCell.svelte";
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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();
|
|
46
69
|
|
|
47
70
|
function truncate_text(
|
|
48
71
|
text: CellValue,
|
|
@@ -56,17 +79,17 @@
|
|
|
56
79
|
return str.slice(0, max_length) + "...";
|
|
57
80
|
}
|
|
58
81
|
|
|
59
|
-
|
|
82
|
+
let should_truncate = $derived(!edit && max_chars !== null && max_chars > 0);
|
|
60
83
|
|
|
61
|
-
|
|
62
|
-
? value
|
|
63
|
-
|
|
64
|
-
? display_value
|
|
65
|
-
: value;
|
|
84
|
+
let display_content = $derived(
|
|
85
|
+
editable ? value : display_value !== null ? display_value : value
|
|
86
|
+
);
|
|
66
87
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
88
|
+
let display_text = $derived(
|
|
89
|
+
should_truncate
|
|
90
|
+
? truncate_text(display_content, max_chars, datatype === "image")
|
|
91
|
+
: display_content
|
|
92
|
+
);
|
|
70
93
|
|
|
71
94
|
function use_focus(node: HTMLTextAreaElement): any {
|
|
72
95
|
requestAnimationFrame(() => {
|
|
@@ -77,24 +100,26 @@
|
|
|
77
100
|
}
|
|
78
101
|
|
|
79
102
|
function handle_blur(event: FocusEvent): void {
|
|
80
|
-
|
|
103
|
+
onblur?.({
|
|
81
104
|
blur_event: event,
|
|
82
105
|
coords: coords
|
|
83
106
|
});
|
|
84
107
|
}
|
|
85
108
|
|
|
86
109
|
function handle_keydown(event: KeyboardEvent): void {
|
|
87
|
-
|
|
110
|
+
onkeydown?.(event);
|
|
88
111
|
}
|
|
89
112
|
|
|
90
113
|
function commit_change(checked: boolean): void {
|
|
91
114
|
handle_blur({ target: { value } } as unknown as FocusEvent);
|
|
92
115
|
}
|
|
93
116
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
+
});
|
|
98
123
|
</script>
|
|
99
124
|
|
|
100
125
|
{#if edit && datatype !== "bool"}
|
|
@@ -106,11 +131,11 @@
|
|
|
106
131
|
bind:value
|
|
107
132
|
class:header
|
|
108
133
|
tabindex="-1"
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
134
|
+
onblur={handle_blur}
|
|
135
|
+
onmousedown={(e: MouseEvent) => e.stopPropagation()}
|
|
136
|
+
onclick={(e: MouseEvent) => e.stopPropagation()}
|
|
112
137
|
use:use_focus
|
|
113
|
-
|
|
138
|
+
onkeydown={handle_keydown}
|
|
114
139
|
/>
|
|
115
140
|
{/if}
|
|
116
141
|
|
|
@@ -119,13 +144,13 @@
|
|
|
119
144
|
{:else}
|
|
120
145
|
<span
|
|
121
146
|
class:dragging={is_dragging}
|
|
122
|
-
|
|
147
|
+
onkeydown={handle_keydown}
|
|
123
148
|
tabindex="0"
|
|
124
149
|
role="button"
|
|
125
150
|
class:edit
|
|
126
151
|
class:expanded={edit}
|
|
127
152
|
class:multiline={header}
|
|
128
|
-
|
|
153
|
+
onfocus={(e) => e.preventDefault()}
|
|
129
154
|
style={styling}
|
|
130
155
|
data-editable={editable}
|
|
131
156
|
data-max-chars={max_chars}
|
|
@@ -135,8 +160,8 @@
|
|
|
135
160
|
class:wrap={wrap_text}
|
|
136
161
|
>
|
|
137
162
|
{#if datatype === "image" && components.image}
|
|
138
|
-
|
|
139
|
-
|
|
163
|
+
{@const ImageComponent = components.image}
|
|
164
|
+
<ImageComponent
|
|
140
165
|
value={{ url: display_text }}
|
|
141
166
|
show_label={false}
|
|
142
167
|
label="cell-image"
|
|
@@ -201,7 +226,7 @@
|
|
|
201
226
|
span {
|
|
202
227
|
flex: 1 1 0%;
|
|
203
228
|
position: relative;
|
|
204
|
-
display:
|
|
229
|
+
display: block;
|
|
205
230
|
outline: none;
|
|
206
231
|
-webkit-user-select: text;
|
|
207
232
|
-moz-user-select: text;
|
|
@@ -209,8 +234,7 @@
|
|
|
209
234
|
user-select: text;
|
|
210
235
|
cursor: text;
|
|
211
236
|
width: 100%;
|
|
212
|
-
|
|
213
|
-
overflow: hidden;
|
|
237
|
+
overflow-wrap: break-word;
|
|
214
238
|
}
|
|
215
239
|
|
|
216
240
|
span.text.expanded {
|
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
import type { I18nFormatter } from "@gradio/utils";
|
|
2
2
|
import type { CellValue } from "./types";
|
|
3
|
-
|
|
4
|
-
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
5
|
-
$$bindings?: Bindings;
|
|
6
|
-
} & Exports;
|
|
7
|
-
(internal: unknown, props: Props & {
|
|
8
|
-
$$events?: Events;
|
|
9
|
-
$$slots?: Slots;
|
|
10
|
-
}): Exports & {
|
|
11
|
-
$set?: any;
|
|
12
|
-
$on?: any;
|
|
13
|
-
};
|
|
14
|
-
z_$$bindings?: Bindings;
|
|
15
|
-
}
|
|
16
|
-
declare const EditableCell: $$__sveltets_2_IsomorphicComponent<{
|
|
3
|
+
type $$ComponentProps = {
|
|
17
4
|
edit: boolean;
|
|
18
5
|
value?: CellValue;
|
|
19
6
|
display_value?: string | null;
|
|
@@ -37,18 +24,13 @@ declare const EditableCell: $$__sveltets_2_IsomorphicComponent<{
|
|
|
37
24
|
coords: [number, number];
|
|
38
25
|
on_select_column?: ((col: number) => void) | null;
|
|
39
26
|
on_select_row?: ((row: number) => void) | null;
|
|
40
|
-
el
|
|
41
|
-
|
|
42
|
-
mousedown: MouseEvent;
|
|
43
|
-
click: PointerEvent;
|
|
44
|
-
focus: FocusEvent;
|
|
45
|
-
blur: CustomEvent<{
|
|
27
|
+
el?: HTMLTextAreaElement | null;
|
|
28
|
+
onblur?: (detail: {
|
|
46
29
|
blur_event: FocusEvent;
|
|
47
30
|
coords: [number, number];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
type EditableCell = InstanceType<typeof EditableCell>;
|
|
31
|
+
}) => void;
|
|
32
|
+
onkeydown?: (event: KeyboardEvent) => void;
|
|
33
|
+
};
|
|
34
|
+
declare const EditableCell: import("svelte").Component<$$ComponentProps, {}, "value" | "el">;
|
|
35
|
+
type EditableCell = ReturnType<typeof EditableCell>;
|
|
54
36
|
export default EditableCell;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
2
|
+
let { on_click }: { on_click: () => void } = $props();
|
|
3
3
|
</script>
|
|
4
4
|
|
|
5
|
-
<button class="add-row-button"
|
|
5
|
+
<button class="add-row-button" onclick={on_click} aria-label="Add row">
|
|
6
6
|
+
|
|
7
7
|
</button>
|
|
8
8
|
|
|
@@ -1,20 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
-
$$bindings?: Bindings;
|
|
4
|
-
} & Exports;
|
|
5
|
-
(internal: unknown, props: Props & {
|
|
6
|
-
$$events?: Events;
|
|
7
|
-
$$slots?: Slots;
|
|
8
|
-
}): Exports & {
|
|
9
|
-
$set?: any;
|
|
10
|
-
$on?: any;
|
|
11
|
-
};
|
|
12
|
-
z_$$bindings?: Bindings;
|
|
13
|
-
}
|
|
14
|
-
declare const EmptyRowButton: $$__sveltets_2_IsomorphicComponent<{
|
|
1
|
+
type $$ComponentProps = {
|
|
15
2
|
on_click: () => void;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
type EmptyRowButton = InstanceType<typeof EmptyRowButton>;
|
|
3
|
+
};
|
|
4
|
+
declare const EmptyRowButton: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
5
|
+
type EmptyRowButton = ReturnType<typeof EmptyRowButton>;
|
|
20
6
|
export default EmptyRowButton;
|
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { onMount } from "svelte";
|
|
3
3
|
import { Check, DropdownArrow } from "@gradio/icons";
|
|
4
|
-
import type { FilterDatatype } from "./
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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();
|
|
11
15
|
|
|
12
16
|
let menu_element: HTMLDivElement;
|
|
13
|
-
let datatype: "string" | "number" = "string";
|
|
14
|
-
let current_filter = "Contains";
|
|
15
|
-
let filter_dropdown_open = false;
|
|
16
|
-
let filter_input_value = "";
|
|
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("");
|
|
17
21
|
|
|
18
22
|
const filter_options = {
|
|
19
23
|
string: [
|
|
@@ -59,7 +63,8 @@
|
|
|
59
63
|
<div class="filter-datatype-container">
|
|
60
64
|
<span>Filter as</span>
|
|
61
65
|
<button
|
|
62
|
-
|
|
66
|
+
onclick={(e) => {
|
|
67
|
+
e.stopPropagation();
|
|
63
68
|
datatype = datatype === "string" ? "number" : "string";
|
|
64
69
|
current_filter = filter_options[datatype][0];
|
|
65
70
|
}}
|
|
@@ -72,8 +77,10 @@
|
|
|
72
77
|
<div class="input-container">
|
|
73
78
|
<div class="filter-dropdown">
|
|
74
79
|
<button
|
|
75
|
-
|
|
76
|
-
(
|
|
80
|
+
onclick={(e) => {
|
|
81
|
+
e.stopPropagation();
|
|
82
|
+
filter_dropdown_open = !filter_dropdown_open;
|
|
83
|
+
}}
|
|
77
84
|
aria-label={`Change filter. Using '${current_filter}'`}
|
|
78
85
|
>
|
|
79
86
|
{current_filter}
|
|
@@ -84,7 +91,8 @@
|
|
|
84
91
|
<div class="dropdown-filter-options">
|
|
85
92
|
{#each filter_options[datatype] as opt}
|
|
86
93
|
<button
|
|
87
|
-
|
|
94
|
+
onclick={(e) => {
|
|
95
|
+
e.stopPropagation();
|
|
88
96
|
current_filter = opt;
|
|
89
97
|
filter_dropdown_open = !filter_dropdown_open;
|
|
90
98
|
}}
|
|
@@ -100,8 +108,8 @@
|
|
|
100
108
|
<input
|
|
101
109
|
type="text"
|
|
102
110
|
value={filter_input_value}
|
|
103
|
-
|
|
104
|
-
|
|
111
|
+
onclick={(e) => e.stopPropagation()}
|
|
112
|
+
oninput={handle_filter_input}
|
|
105
113
|
placeholder="Type a value"
|
|
106
114
|
class="filter-input"
|
|
107
115
|
/>
|
|
@@ -109,7 +117,7 @@
|
|
|
109
117
|
|
|
110
118
|
<button
|
|
111
119
|
class="check-button"
|
|
112
|
-
|
|
120
|
+
onclick={() => on_filter(datatype, current_filter, filter_input_value)}
|
|
113
121
|
>
|
|
114
122
|
<Check />
|
|
115
123
|
</button>
|
|
@@ -1,23 +1,7 @@
|
|
|
1
|
-
import type { FilterDatatype } from "./
|
|
2
|
-
|
|
3
|
-
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
-
$$bindings?: Bindings;
|
|
5
|
-
} & Exports;
|
|
6
|
-
(internal: unknown, props: Props & {
|
|
7
|
-
$$events?: Events;
|
|
8
|
-
$$slots?: Slots;
|
|
9
|
-
}): Exports & {
|
|
10
|
-
$set?: any;
|
|
11
|
-
$on?: any;
|
|
12
|
-
};
|
|
13
|
-
z_$$bindings?: Bindings;
|
|
14
|
-
}
|
|
15
|
-
declare const FilterMenu: $$__sveltets_2_IsomorphicComponent<{
|
|
1
|
+
import type { FilterDatatype } from "./types";
|
|
2
|
+
type $$ComponentProps = {
|
|
16
3
|
on_filter?: (datatype: FilterDatatype, selected_filter: string, value: string) => void;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
[evt: string]: CustomEvent<any>;
|
|
21
|
-
}, {}, {}, string>;
|
|
22
|
-
type FilterMenu = InstanceType<typeof FilterMenu>;
|
|
4
|
+
};
|
|
5
|
+
declare const FilterMenu: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
6
|
+
type FilterMenu = ReturnType<typeof FilterMenu>;
|
|
23
7
|
export default FilterMenu;
|
|
@@ -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>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { I18nFormatter } from "js/core/src/gradio_helper";
|
|
2
|
+
import type { SortDirection } from "./types";
|
|
3
|
+
type $$ComponentProps = {
|
|
4
|
+
value: string;
|
|
5
|
+
col_idx: number;
|
|
6
|
+
is_editing?: boolean;
|
|
7
|
+
is_selected?: boolean;
|
|
8
|
+
is_static?: boolean;
|
|
9
|
+
sort_direction?: SortDirection | null;
|
|
10
|
+
sort_priority?: number | null;
|
|
11
|
+
multi_sort?: boolean;
|
|
12
|
+
is_filtered?: boolean;
|
|
13
|
+
show_menu_button?: boolean;
|
|
14
|
+
is_first_column?: boolean;
|
|
15
|
+
latex_delimiters: {
|
|
16
|
+
left: string;
|
|
17
|
+
right: string;
|
|
18
|
+
display: boolean;
|
|
19
|
+
}[];
|
|
20
|
+
line_breaks?: boolean;
|
|
21
|
+
editable?: boolean;
|
|
22
|
+
max_chars?: number | undefined;
|
|
23
|
+
i18n: I18nFormatter;
|
|
24
|
+
onclick: (event: MouseEvent, col: number) => void;
|
|
25
|
+
on_menu_click: (event: MouseEvent, col: number) => void;
|
|
26
|
+
on_end_edit: (key: string) => void;
|
|
27
|
+
};
|
|
28
|
+
declare const HeaderCell: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
29
|
+
type HeaderCell = ReturnType<typeof HeaderCell>;
|
|
30
|
+
export default HeaderCell;
|