@gradio/dataframe 0.18.1 → 0.18.3
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 +20 -0
- package/dist/shared/BooleanCell.svelte +7 -21
- package/dist/shared/Table.svelte +2 -1
- package/dist/shared/context/dataframe_context.d.ts +1 -0
- package/dist/shared/utils/drag_utils.js +6 -1
- package/dist/shared/utils/keyboard_utils.js +5 -0
- package/package.json +7 -7
- package/shared/BooleanCell.svelte +7 -23
- package/shared/Table.svelte +2 -1
- package/shared/context/dataframe_context.ts +1 -0
- package/shared/utils/drag_utils.ts +8 -1
- package/shared/utils/keyboard_utils.ts +6 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @gradio/dataframe
|
|
2
2
|
|
|
3
|
+
## 0.18.3
|
|
4
|
+
|
|
5
|
+
### Fixes
|
|
6
|
+
|
|
7
|
+
- [#11534](https://github.com/gradio-app/gradio/pull/11534) [`5259f22`](https://github.com/gradio-app/gradio/commit/5259f229939177cc2027db5164c9321566fb3eeb) - Allow changing value with single click instead of double click. Thanks @hannahblair!
|
|
8
|
+
|
|
9
|
+
### Dependency updates
|
|
10
|
+
|
|
11
|
+
- @gradio/client@1.15.6
|
|
12
|
+
- @gradio/statustracker@0.10.15
|
|
13
|
+
- @gradio/button@0.5.7
|
|
14
|
+
- @gradio/upload@0.16.11
|
|
15
|
+
- @gradio/checkbox@0.4.26
|
|
16
|
+
|
|
17
|
+
## 0.18.2
|
|
18
|
+
|
|
19
|
+
### Fixes
|
|
20
|
+
|
|
21
|
+
- [#11496](https://github.com/gradio-app/gradio/pull/11496) [`ee0da48`](https://github.com/gradio-app/gradio/commit/ee0da481446da5ffd79151a457cd3847db645bfb) - Prevent deletion of values in static columns. Thanks @hannahblair!
|
|
22
|
+
|
|
3
23
|
## 0.18.1
|
|
4
24
|
|
|
5
25
|
### Fixes
|
|
@@ -5,25 +5,13 @@ export let on_change;
|
|
|
5
5
|
$:
|
|
6
6
|
bool_value = typeof value === "string" ? value.toLowerCase() === "true" : !!value;
|
|
7
7
|
function handle_change(event) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
function handle_click(event) {
|
|
11
|
-
event.stopPropagation();
|
|
12
|
-
}
|
|
13
|
-
function handle_keydown(event) {
|
|
14
|
-
if (event.key === "Enter" || event.key === " ") {
|
|
15
|
-
event.stopPropagation();
|
|
8
|
+
if (editable) {
|
|
9
|
+
on_change(event.detail);
|
|
16
10
|
}
|
|
17
11
|
}
|
|
18
12
|
</script>
|
|
19
13
|
|
|
20
|
-
<div
|
|
21
|
-
class="bool-cell checkbox"
|
|
22
|
-
on:click={handle_click}
|
|
23
|
-
on:keydown={handle_keydown}
|
|
24
|
-
role="button"
|
|
25
|
-
tabindex="-1"
|
|
26
|
-
>
|
|
14
|
+
<div class="bool-cell" role="button" tabindex="-1">
|
|
27
15
|
<BaseCheckbox
|
|
28
16
|
bind:value={bool_value}
|
|
29
17
|
label=""
|
|
@@ -37,15 +25,13 @@ function handle_keydown(event) {
|
|
|
37
25
|
display: flex;
|
|
38
26
|
align-items: center;
|
|
39
27
|
justify-content: center;
|
|
40
|
-
width:
|
|
28
|
+
width: min-content;
|
|
41
29
|
height: var(--size-full);
|
|
42
|
-
|
|
43
|
-
.bool-cell :global(input:disabled) {
|
|
44
|
-
opacity: 0.8;
|
|
30
|
+
margin: 0 auto;
|
|
45
31
|
}
|
|
46
32
|
|
|
47
|
-
.bool-cell
|
|
48
|
-
|
|
33
|
+
.bool-cell :global(input:disabled) {
|
|
34
|
+
cursor: not-allowed;
|
|
49
35
|
}
|
|
50
36
|
|
|
51
37
|
.bool-cell :global(label) {
|
package/dist/shared/Table.svelte
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { get_range_selection } from "../selection_utils";
|
|
2
2
|
export function create_drag_handlers(state, set_is_dragging, set_selected_cells, set_selected, handle_cell_click, show_row_numbers, parent_element) {
|
|
3
3
|
const start_drag = (event, row, col) => {
|
|
4
|
+
const target = event.target;
|
|
5
|
+
const is_checkbox_click = target.type === "checkbox" ||
|
|
6
|
+
target.closest('input[type="checkbox"]') ||
|
|
7
|
+
target.closest(".bool-cell");
|
|
4
8
|
if (event.target instanceof HTMLAnchorElement ||
|
|
5
|
-
(show_row_numbers && col === -1)
|
|
9
|
+
(show_row_numbers && col === -1) ||
|
|
10
|
+
is_checkbox_click)
|
|
6
11
|
return;
|
|
7
12
|
event.preventDefault();
|
|
8
13
|
event.stopPropagation();
|
|
@@ -59,6 +59,7 @@ function handle_header_navigation(event, ctx) {
|
|
|
59
59
|
}
|
|
60
60
|
return false;
|
|
61
61
|
}
|
|
62
|
+
// eslint-disable-next-line complexity
|
|
62
63
|
function handle_delete_operation(event, ctx) {
|
|
63
64
|
if (!ctx.data || !ctx.headers || !ctx.els || !ctx.dispatch)
|
|
64
65
|
return false;
|
|
@@ -69,6 +70,10 @@ function handle_delete_operation(event, ctx) {
|
|
|
69
70
|
return false;
|
|
70
71
|
const editing = state.ui_state.editing;
|
|
71
72
|
const selected_cells = state.ui_state.selected_cells;
|
|
73
|
+
const static_columns = state.config.static_columns || [];
|
|
74
|
+
if (selected_cells.some(([_, col]) => static_columns.includes(col))) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
72
77
|
if (editing) {
|
|
73
78
|
const [row, col] = editing;
|
|
74
79
|
const input_el = ctx.els[ctx.data[row][col].id]?.input;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradio/dataframe",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.3",
|
|
4
4
|
"description": "Gradio UI packages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "",
|
|
@@ -17,15 +17,15 @@
|
|
|
17
17
|
"dompurify": "^3.0.3",
|
|
18
18
|
"katex": "^0.16.7",
|
|
19
19
|
"marked": "^12.0.0",
|
|
20
|
-
"@gradio/
|
|
21
|
-
"@gradio/
|
|
22
|
-
"@gradio/checkbox": "^0.4.25",
|
|
23
|
-
"@gradio/client": "^1.15.5",
|
|
20
|
+
"@gradio/button": "^0.5.7",
|
|
21
|
+
"@gradio/checkbox": "^0.4.26",
|
|
24
22
|
"@gradio/icons": "^0.12.0",
|
|
25
23
|
"@gradio/markdown-code": "^0.5.0",
|
|
26
|
-
"@gradio/statustracker": "^0.10.
|
|
24
|
+
"@gradio/statustracker": "^0.10.15",
|
|
25
|
+
"@gradio/upload": "^0.16.11",
|
|
27
26
|
"@gradio/utils": "^0.10.2",
|
|
28
|
-
"@gradio/
|
|
27
|
+
"@gradio/atoms": "^0.16.3",
|
|
28
|
+
"@gradio/client": "^1.15.6"
|
|
29
29
|
},
|
|
30
30
|
"exports": {
|
|
31
31
|
".": {
|
|
@@ -9,27 +9,13 @@
|
|
|
9
9
|
typeof value === "string" ? value.toLowerCase() === "true" : !!value;
|
|
10
10
|
|
|
11
11
|
function handle_change(event: CustomEvent<boolean>): void {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
function handle_click(event: MouseEvent): void {
|
|
16
|
-
event.stopPropagation();
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function handle_keydown(event: KeyboardEvent): void {
|
|
20
|
-
if (event.key === "Enter" || event.key === " ") {
|
|
21
|
-
event.stopPropagation();
|
|
12
|
+
if (editable) {
|
|
13
|
+
on_change(event.detail);
|
|
22
14
|
}
|
|
23
15
|
}
|
|
24
16
|
</script>
|
|
25
17
|
|
|
26
|
-
<div
|
|
27
|
-
class="bool-cell checkbox"
|
|
28
|
-
on:click={handle_click}
|
|
29
|
-
on:keydown={handle_keydown}
|
|
30
|
-
role="button"
|
|
31
|
-
tabindex="-1"
|
|
32
|
-
>
|
|
18
|
+
<div class="bool-cell" role="button" tabindex="-1">
|
|
33
19
|
<BaseCheckbox
|
|
34
20
|
bind:value={bool_value}
|
|
35
21
|
label=""
|
|
@@ -43,15 +29,13 @@
|
|
|
43
29
|
display: flex;
|
|
44
30
|
align-items: center;
|
|
45
31
|
justify-content: center;
|
|
46
|
-
width:
|
|
32
|
+
width: min-content;
|
|
47
33
|
height: var(--size-full);
|
|
48
|
-
|
|
49
|
-
.bool-cell :global(input:disabled) {
|
|
50
|
-
opacity: 0.8;
|
|
34
|
+
margin: 0 auto;
|
|
51
35
|
}
|
|
52
36
|
|
|
53
|
-
.bool-cell
|
|
54
|
-
|
|
37
|
+
.bool-cell :global(input:disabled) {
|
|
38
|
+
cursor: not-allowed;
|
|
55
39
|
}
|
|
56
40
|
|
|
57
41
|
.bool-cell :global(label) {
|
package/shared/Table.svelte
CHANGED
|
@@ -23,9 +23,16 @@ export function create_drag_handlers(
|
|
|
23
23
|
parent_element?: HTMLElement
|
|
24
24
|
): DragHandlers {
|
|
25
25
|
const start_drag = (event: MouseEvent, row: number, col: number): void => {
|
|
26
|
+
const target = event.target as HTMLElement;
|
|
27
|
+
const is_checkbox_click =
|
|
28
|
+
(target as HTMLInputElement).type === "checkbox" ||
|
|
29
|
+
target.closest('input[type="checkbox"]') ||
|
|
30
|
+
target.closest(".bool-cell");
|
|
31
|
+
|
|
26
32
|
if (
|
|
27
33
|
event.target instanceof HTMLAnchorElement ||
|
|
28
|
-
(show_row_numbers && col === -1)
|
|
34
|
+
(show_row_numbers && col === -1) ||
|
|
35
|
+
is_checkbox_click
|
|
29
36
|
)
|
|
30
37
|
return;
|
|
31
38
|
|
|
@@ -88,6 +88,7 @@ function handle_header_navigation(
|
|
|
88
88
|
return false;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
// eslint-disable-next-line complexity
|
|
91
92
|
function handle_delete_operation(
|
|
92
93
|
event: KeyboardEvent,
|
|
93
94
|
ctx: DataFrameContext
|
|
@@ -101,6 +102,11 @@ function handle_delete_operation(
|
|
|
101
102
|
const editing = state.ui_state.editing;
|
|
102
103
|
const selected_cells = state.ui_state.selected_cells;
|
|
103
104
|
|
|
105
|
+
const static_columns = state.config.static_columns || [];
|
|
106
|
+
if (selected_cells.some(([_, col]) => static_columns.includes(col))) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
|
|
104
110
|
if (editing) {
|
|
105
111
|
const [row, col] = editing;
|
|
106
112
|
const input_el = ctx.els[ctx.data[row][col].id]?.input;
|