@gradio/dataframe 0.24.2 → 0.24.4
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 +33 -0
- package/Dataframe.test.ts +497 -43
- package/Example.svelte +19 -10
- package/dist/Example.svelte +19 -10
- package/dist/Example.svelte.d.ts +4 -18
- package/dist/shared/BooleanCell.svelte +1 -0
- package/dist/shared/CellMenuButton.svelte +8 -1
- package/dist/shared/CellMenuButton.svelte.d.ts +1 -0
- package/dist/shared/DataCell.svelte +26 -2
- package/dist/shared/DataCell.svelte.d.ts +4 -0
- package/dist/shared/EditableCell.svelte +6 -3
- package/dist/shared/Example.svelte +1 -1
- package/dist/shared/Example.svelte.d.ts +4 -18
- package/dist/shared/HeaderCell.svelte +17 -3
- package/dist/shared/HeaderCell.svelte.d.ts +3 -1
- package/dist/shared/Table.svelte +374 -140
- package/dist/shared/icons/SelectionButtons.svelte +1 -0
- package/dist/shared/tanstack/virtual.svelte.js +2 -2
- package/dist/standalone/stubs/Upload.svelte +12 -5
- package/dist/standalone/stubs/Upload.svelte.d.ts +8 -34
- package/package.json +8 -8
- package/shared/BooleanCell.svelte +1 -0
- package/shared/CellMenuButton.svelte +8 -1
- package/shared/DataCell.svelte +26 -2
- package/shared/EditableCell.svelte +6 -3
- package/shared/Example.svelte +1 -1
- package/shared/HeaderCell.svelte +17 -3
- package/shared/Table.svelte +374 -140
- package/shared/icons/SelectionButtons.svelte +1 -0
- package/shared/tanstack/virtual.svelte.ts +2 -2
- package/standalone/stubs/Upload.svelte +12 -5
|
@@ -53,8 +53,8 @@ export function createSvelteVirtualizer(options) {
|
|
|
53
53
|
options.onChange?.(instance, sync);
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
|
-
if (
|
|
57
|
-
|
|
56
|
+
if (current_count !== prev_count) {
|
|
57
|
+
version += 1;
|
|
58
58
|
}
|
|
59
59
|
prev_count = current_count;
|
|
60
60
|
});
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
|
|
4
|
+
let {
|
|
5
|
+
children
|
|
6
|
+
}: {
|
|
7
|
+
aria_label?: string;
|
|
8
|
+
root?: string;
|
|
9
|
+
upload?: any;
|
|
10
|
+
stream_handler?: any;
|
|
11
|
+
children?: Snippet;
|
|
12
|
+
} = $props();
|
|
6
13
|
</script>
|
|
7
14
|
|
|
8
15
|
<div>
|
|
9
|
-
|
|
16
|
+
{@render children?.()}
|
|
10
17
|
</div>
|
|
11
18
|
|
|
12
19
|
<style>
|
|
@@ -1,37 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
type $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {
|
|
15
|
-
default: any;
|
|
16
|
-
} ? Props extends Record<string, never> ? any : {
|
|
17
|
-
children?: any;
|
|
18
|
-
} : {});
|
|
19
|
-
declare const Upload: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{
|
|
20
|
-
aria_label?: "";
|
|
21
|
-
root?: "";
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
aria_label?: string;
|
|
4
|
+
root?: string;
|
|
22
5
|
upload?: any;
|
|
23
6
|
stream_handler?: any;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
}, {
|
|
29
|
-
default: {};
|
|
30
|
-
}, {
|
|
31
|
-
aria_label: "";
|
|
32
|
-
root: "";
|
|
33
|
-
upload: any;
|
|
34
|
-
stream_handler: any;
|
|
35
|
-
}, string>;
|
|
36
|
-
type Upload = InstanceType<typeof Upload>;
|
|
7
|
+
children?: Snippet;
|
|
8
|
+
};
|
|
9
|
+
declare const Upload: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
10
|
+
type Upload = ReturnType<typeof Upload>;
|
|
37
11
|
export default Upload;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradio/dataframe",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.4",
|
|
4
4
|
"description": "Gradio UI packages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "",
|
|
@@ -15,15 +15,15 @@
|
|
|
15
15
|
"dequal": "^2.0.3",
|
|
16
16
|
"@tanstack/table-core": "^8.21.3",
|
|
17
17
|
"@tanstack/virtual-core": "^3.13.6",
|
|
18
|
-
"@gradio/atoms": "^0.26.
|
|
19
|
-
"@gradio/
|
|
18
|
+
"@gradio/atoms": "^0.26.2",
|
|
19
|
+
"@gradio/checkbox": "^0.8.3",
|
|
20
20
|
"@gradio/button": "^0.8.2",
|
|
21
|
-
"@gradio/checkbox": "^0.8.2",
|
|
22
21
|
"@gradio/icons": "^0.16.0",
|
|
23
|
-
"@gradio/
|
|
24
|
-
"@gradio/
|
|
25
|
-
"@gradio/upload": "^0.18.
|
|
26
|
-
"@gradio/
|
|
22
|
+
"@gradio/client": "^2.6.0",
|
|
23
|
+
"@gradio/markdown-code": "^0.10.1",
|
|
24
|
+
"@gradio/upload": "^0.18.3",
|
|
25
|
+
"@gradio/statustracker": "^0.15.3",
|
|
26
|
+
"@gradio/utils": "^0.14.1"
|
|
27
27
|
},
|
|
28
28
|
"exports": {
|
|
29
29
|
".": {
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
let {
|
|
2
|
+
let {
|
|
3
|
+
on_click,
|
|
4
|
+
tab_index = undefined
|
|
5
|
+
}: {
|
|
6
|
+
on_click: (event: MouseEvent) => void;
|
|
7
|
+
tab_index?: number;
|
|
8
|
+
} = $props();
|
|
3
9
|
</script>
|
|
4
10
|
|
|
5
11
|
<button
|
|
6
12
|
aria-label="Open cell menu"
|
|
7
13
|
class="cell-menu-button"
|
|
8
14
|
aria-haspopup="menu"
|
|
15
|
+
tabindex={tab_index}
|
|
9
16
|
onclick={on_click}
|
|
10
17
|
ontouchstart={(event) => {
|
|
11
18
|
event.preventDefault();
|
package/shared/DataCell.svelte
CHANGED
|
@@ -11,9 +11,12 @@
|
|
|
11
11
|
datatype = "str",
|
|
12
12
|
row_idx,
|
|
13
13
|
col_idx,
|
|
14
|
+
aria_col_index = col_idx + 1,
|
|
14
15
|
col_style = "",
|
|
15
16
|
cell_style = "",
|
|
16
17
|
selection_classes = "",
|
|
18
|
+
is_active = false,
|
|
19
|
+
aria_row_index,
|
|
17
20
|
is_editing = false,
|
|
18
21
|
is_flash = false,
|
|
19
22
|
is_static = false,
|
|
@@ -32,6 +35,7 @@
|
|
|
32
35
|
onmousedown,
|
|
33
36
|
ondblclick,
|
|
34
37
|
oncontextmenu,
|
|
38
|
+
onfocus,
|
|
35
39
|
onblur,
|
|
36
40
|
on_menu_click,
|
|
37
41
|
on_select_column,
|
|
@@ -42,9 +46,12 @@
|
|
|
42
46
|
datatype?: Datatype;
|
|
43
47
|
row_idx: number;
|
|
44
48
|
col_idx: number;
|
|
49
|
+
aria_col_index?: number;
|
|
45
50
|
col_style?: string;
|
|
46
51
|
cell_style?: string;
|
|
47
52
|
selection_classes?: string;
|
|
53
|
+
is_active?: boolean;
|
|
54
|
+
aria_row_index: number;
|
|
48
55
|
is_editing?: boolean;
|
|
49
56
|
is_flash?: boolean;
|
|
50
57
|
is_static?: boolean;
|
|
@@ -63,6 +70,7 @@
|
|
|
63
70
|
onmousedown: (event: MouseEvent) => void;
|
|
64
71
|
ondblclick: (event: MouseEvent) => void;
|
|
65
72
|
oncontextmenu: (event: MouseEvent) => void;
|
|
73
|
+
onfocus: () => void;
|
|
66
74
|
onblur: (detail: {
|
|
67
75
|
blur_event: FocusEvent;
|
|
68
76
|
coords: [number, number];
|
|
@@ -98,10 +106,15 @@
|
|
|
98
106
|
data-row={row_idx}
|
|
99
107
|
data-col={col_idx}
|
|
100
108
|
data-testid={`cell-${row_idx}-${col_idx}`}
|
|
101
|
-
|
|
109
|
+
role="gridcell"
|
|
110
|
+
aria-rowindex={aria_row_index}
|
|
111
|
+
aria-colindex={aria_col_index}
|
|
112
|
+
aria-selected={is_selected}
|
|
113
|
+
tabindex={is_active ? 0 : -1}
|
|
102
114
|
{onmousedown}
|
|
103
115
|
{ondblclick}
|
|
104
116
|
{oncontextmenu}
|
|
117
|
+
{onfocus}
|
|
105
118
|
style="{col_style} {cell_style}"
|
|
106
119
|
>
|
|
107
120
|
<div class="cell-wrap" bind:this={wrap_el} style={locked_height}>
|
|
@@ -127,7 +140,7 @@
|
|
|
127
140
|
expanded={is_solo}
|
|
128
141
|
/>
|
|
129
142
|
{#if show_menu_button}
|
|
130
|
-
<CellMenuButton on_click={on_menu_click} />
|
|
143
|
+
<CellMenuButton on_click={on_menu_click} tab_index={-1} />
|
|
131
144
|
{/if}
|
|
132
145
|
</div>
|
|
133
146
|
</div>
|
|
@@ -146,6 +159,17 @@
|
|
|
146
159
|
min-width: 0;
|
|
147
160
|
}
|
|
148
161
|
|
|
162
|
+
.body-cell:focus-visible {
|
|
163
|
+
outline: 2px solid var(--color-accent);
|
|
164
|
+
outline-offset: -2px;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
@media (forced-colors: active) {
|
|
168
|
+
.body-cell:focus-visible {
|
|
169
|
+
outline-color: CanvasText;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
149
173
|
.body-cell.static {
|
|
150
174
|
user-select: text;
|
|
151
175
|
}
|
|
@@ -106,7 +106,10 @@
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
// grow the edit-mode textarea to fit its content so the overlay
|
|
109
|
-
// expands the same way the display span does.
|
|
109
|
+
// expands the same way the display span does. `rows="1"` on the element
|
|
110
|
+
// matters: without it `height: auto` falls back to the HTML default of two
|
|
111
|
+
// rows, so scrollHeight reports two lines and a single-line cell renders an
|
|
112
|
+
// edit box roughly twice the row height.
|
|
110
113
|
function use_autosize(node: HTMLTextAreaElement): any {
|
|
111
114
|
function resize(): void {
|
|
112
115
|
node.style.height = "auto";
|
|
@@ -151,6 +154,7 @@
|
|
|
151
154
|
readonly={is_static}
|
|
152
155
|
aria-readonly={is_static}
|
|
153
156
|
aria-label={is_static ? "Cell is read-only" : "Edit cell"}
|
|
157
|
+
rows="1"
|
|
154
158
|
bind:this={el}
|
|
155
159
|
bind:value
|
|
156
160
|
class:header
|
|
@@ -171,8 +175,7 @@
|
|
|
171
175
|
<span
|
|
172
176
|
class:dragging={is_dragging}
|
|
173
177
|
onkeydown={handle_keydown}
|
|
174
|
-
tabindex="
|
|
175
|
-
role="button"
|
|
178
|
+
tabindex="-1"
|
|
176
179
|
class:edit
|
|
177
180
|
class:expanded={edit}
|
|
178
181
|
class:header
|
package/shared/Example.svelte
CHANGED
package/shared/HeaderCell.svelte
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
let {
|
|
13
13
|
value,
|
|
14
14
|
col_idx,
|
|
15
|
+
aria_col_index = col_idx + 1,
|
|
15
16
|
is_editing = false,
|
|
16
17
|
is_selected = false,
|
|
17
18
|
is_static = false,
|
|
@@ -30,12 +31,14 @@
|
|
|
30
31
|
i18n,
|
|
31
32
|
wrap_text = false,
|
|
32
33
|
onclick,
|
|
34
|
+
onfocus,
|
|
33
35
|
on_menu_click,
|
|
34
36
|
on_end_edit,
|
|
35
37
|
on_select_all
|
|
36
38
|
}: {
|
|
37
39
|
value: string;
|
|
38
40
|
col_idx: number;
|
|
41
|
+
aria_col_index?: number;
|
|
39
42
|
is_editing?: boolean;
|
|
40
43
|
is_selected?: boolean;
|
|
41
44
|
is_static?: boolean;
|
|
@@ -54,8 +57,9 @@
|
|
|
54
57
|
i18n: I18nFormatter;
|
|
55
58
|
wrap_text?: boolean;
|
|
56
59
|
onclick: (event: MouseEvent, col: number) => void;
|
|
60
|
+
onfocus: (col: number) => void;
|
|
57
61
|
on_menu_click: (event: MouseEvent, col: number) => void;
|
|
58
|
-
on_end_edit: (
|
|
62
|
+
on_end_edit: (event: KeyboardEvent) => void;
|
|
59
63
|
on_select_all?: (col: number, checked: boolean) => void;
|
|
60
64
|
} = $props();
|
|
61
65
|
|
|
@@ -71,6 +75,11 @@
|
|
|
71
75
|
class:filtered={is_filtered}
|
|
72
76
|
class:first-column={is_first_column}
|
|
73
77
|
data-heading={col_idx}
|
|
78
|
+
data-testid={`header-${col_idx}`}
|
|
79
|
+
role="columnheader"
|
|
80
|
+
aria-colindex={aria_col_index}
|
|
81
|
+
tabindex={is_selected ? 0 : -1}
|
|
82
|
+
onfocus={() => onfocus(col_idx)}
|
|
74
83
|
onclick={(e) => onclick(e, col_idx)}
|
|
75
84
|
onmousedown={(e) => {
|
|
76
85
|
e.preventDefault();
|
|
@@ -94,6 +103,7 @@
|
|
|
94
103
|
indeterminate={select_all_state === "indeterminate"}
|
|
95
104
|
label={`Toggle all: ${value}`}
|
|
96
105
|
interactive={true}
|
|
106
|
+
tab_index={-1}
|
|
97
107
|
on_select={() =>
|
|
98
108
|
on_select_all?.(col_idx, select_all_state !== "checked")}
|
|
99
109
|
/>
|
|
@@ -106,7 +116,8 @@
|
|
|
106
116
|
edit={is_editing}
|
|
107
117
|
onkeydown={(event) => {
|
|
108
118
|
if (["Enter", "Escape", "Tab"].includes(event.key)) {
|
|
109
|
-
|
|
119
|
+
event.stopPropagation();
|
|
120
|
+
on_end_edit(event);
|
|
110
121
|
}
|
|
111
122
|
}}
|
|
112
123
|
header
|
|
@@ -148,7 +159,10 @@
|
|
|
148
159
|
</span>
|
|
149
160
|
{/if}
|
|
150
161
|
{#if show_menu_button}
|
|
151
|
-
<CellMenuButton
|
|
162
|
+
<CellMenuButton
|
|
163
|
+
on_click={(e) => on_menu_click(e, col_idx)}
|
|
164
|
+
tab_index={-1}
|
|
165
|
+
/>
|
|
152
166
|
{/if}
|
|
153
167
|
</div>
|
|
154
168
|
</th>
|