@gradio/dataframe 0.24.3 → 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 +21 -0
- package/Dataframe.test.ts +469 -43
- 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 +1 -2
- package/dist/shared/HeaderCell.svelte +17 -3
- package/dist/shared/HeaderCell.svelte.d.ts +3 -1
- package/dist/shared/Table.svelte +373 -140
- package/dist/shared/icons/SelectionButtons.svelte +1 -0
- package/package.json +7 -7
- package/shared/BooleanCell.svelte +1 -0
- package/shared/CellMenuButton.svelte +8 -1
- package/shared/DataCell.svelte +26 -2
- package/shared/EditableCell.svelte +1 -2
- package/shared/HeaderCell.svelte +17 -3
- package/shared/Table.svelte +373 -140
- package/shared/icons/SelectionButtons.svelte +1 -0
|
@@ -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
|
}
|
|
@@ -7,9 +7,12 @@ type $$ComponentProps = {
|
|
|
7
7
|
datatype?: Datatype;
|
|
8
8
|
row_idx: number;
|
|
9
9
|
col_idx: number;
|
|
10
|
+
aria_col_index?: number;
|
|
10
11
|
col_style?: string;
|
|
11
12
|
cell_style?: string;
|
|
12
13
|
selection_classes?: string;
|
|
14
|
+
is_active?: boolean;
|
|
15
|
+
aria_row_index: number;
|
|
13
16
|
is_editing?: boolean;
|
|
14
17
|
is_flash?: boolean;
|
|
15
18
|
is_static?: boolean;
|
|
@@ -32,6 +35,7 @@ type $$ComponentProps = {
|
|
|
32
35
|
onmousedown: (event: MouseEvent) => void;
|
|
33
36
|
ondblclick: (event: MouseEvent) => void;
|
|
34
37
|
oncontextmenu: (event: MouseEvent) => void;
|
|
38
|
+
onfocus: () => void;
|
|
35
39
|
onblur: (detail: {
|
|
36
40
|
blur_event: FocusEvent;
|
|
37
41
|
coords: [number, number];
|
|
@@ -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>
|
|
@@ -3,6 +3,7 @@ import type { SortDirection } from "./types";
|
|
|
3
3
|
type $$ComponentProps = {
|
|
4
4
|
value: string;
|
|
5
5
|
col_idx: number;
|
|
6
|
+
aria_col_index?: number;
|
|
6
7
|
is_editing?: boolean;
|
|
7
8
|
is_selected?: boolean;
|
|
8
9
|
is_static?: boolean;
|
|
@@ -25,8 +26,9 @@ type $$ComponentProps = {
|
|
|
25
26
|
i18n: I18nFormatter;
|
|
26
27
|
wrap_text?: boolean;
|
|
27
28
|
onclick: (event: MouseEvent, col: number) => void;
|
|
29
|
+
onfocus: (col: number) => void;
|
|
28
30
|
on_menu_click: (event: MouseEvent, col: number) => void;
|
|
29
|
-
on_end_edit: (
|
|
31
|
+
on_end_edit: (event: KeyboardEvent) => void;
|
|
30
32
|
on_select_all?: (col: number, checked: boolean) => void;
|
|
31
33
|
};
|
|
32
34
|
declare const HeaderCell: import("svelte").Component<$$ComponentProps, {}, "">;
|