@gradio/dataframe 0.24.3 → 0.24.5

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.
@@ -23,6 +23,7 @@
23
23
  bind:value
24
24
  label=""
25
25
  interactive={editable}
26
+ tab_index={-1}
26
27
  on_change={handle_change}
27
28
  />
28
29
  </div>
@@ -1,11 +1,18 @@
1
1
  <script lang="ts">
2
- let { on_click }: { on_click: (event: MouseEvent) => void } = $props();
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();
@@ -1,5 +1,6 @@
1
1
  type $$ComponentProps = {
2
2
  on_click: (event: MouseEvent) => void;
3
+ tab_index?: number;
3
4
  };
4
5
  declare const CellMenuButton: import("svelte").Component<$$ComponentProps, {}, "">;
5
6
  type CellMenuButton = ReturnType<typeof CellMenuButton>;
@@ -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
- tabindex={is_static ? -1 : undefined}
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];
@@ -175,8 +175,7 @@
175
175
  <span
176
176
  class:dragging={is_dragging}
177
177
  onkeydown={handle_keydown}
178
- tabindex="0"
179
- role="button"
178
+ tabindex="-1"
180
179
  class:edit
181
180
  class:expanded={edit}
182
181
  class:header
@@ -16,7 +16,6 @@
16
16
  color: var(--body-text-color);
17
17
  cursor: pointer;
18
18
  transition: all 150ms;
19
- margin-top: var(--size-2);
20
19
  z-index: 10;
21
20
  position: relative;
22
21
  pointer-events: auto;
@@ -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: (key: string) => void;
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
- on_end_edit(event.key);
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 on_click={(e) => on_menu_click(e, col_idx)} />
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: (key: string) => void;
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, {}, "">;