@gradio/dataframe 0.17.6 → 0.17.8
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 +22 -0
- package/Dataframe.stories.svelte +7 -7
- package/dist/shared/Table.svelte +11 -5
- package/dist/shared/TableCell.svelte +3 -1
- package/dist/shared/context/dataframe_context.d.ts +2 -0
- package/dist/shared/context/dataframe_context.js +2 -0
- package/package.json +8 -8
- package/shared/Table.svelte +27 -8
- package/shared/TableCell.svelte +3 -1
- package/shared/context/dataframe_context.ts +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @gradio/dataframe
|
|
2
2
|
|
|
3
|
+
## 0.17.8
|
|
4
|
+
|
|
5
|
+
### Fixes
|
|
6
|
+
|
|
7
|
+
- [#11033](https://github.com/gradio-app/gradio/pull/11033) [`0dbc14f`](https://github.com/gradio-app/gradio/commit/0dbc14fa867ef57a2f810e0b869b7d13d98f2544) - Allow setting an empty value in `display_value` of `gr.Dataframe`. Thanks @abidlabs!
|
|
8
|
+
|
|
9
|
+
## 0.17.7
|
|
10
|
+
|
|
11
|
+
### Fixes
|
|
12
|
+
|
|
13
|
+
- [#11005](https://github.com/gradio-app/gradio/pull/11005) [`3def0ed`](https://github.com/gradio-app/gradio/commit/3def0ed9edc5a9194d69456948324ec4e2740b7d) - Ensure that the `.select()` event in `gr.DataFrame` carries the `.row_value` and `.col_value`. Thanks @abidlabs!
|
|
14
|
+
|
|
15
|
+
### Dependency updates
|
|
16
|
+
|
|
17
|
+
- @gradio/statustracker@0.10.9
|
|
18
|
+
- @gradio/atoms@0.15.2
|
|
19
|
+
- @gradio/client@1.14.2
|
|
20
|
+
- @gradio/markdown-code@0.4.3
|
|
21
|
+
- @gradio/utils@0.10.2
|
|
22
|
+
- @gradio/button@0.4.15
|
|
23
|
+
- @gradio/upload@0.16.2
|
|
24
|
+
|
|
3
25
|
## 0.17.6
|
|
4
26
|
|
|
5
27
|
### Dependency updates
|
package/Dataframe.stories.svelte
CHANGED
|
@@ -763,14 +763,14 @@
|
|
|
763
763
|
[91, 93, 90],
|
|
764
764
|
[82, 81, 83]
|
|
765
765
|
],
|
|
766
|
-
headers: ["Model A", "Model B", "
|
|
766
|
+
headers: ["Model A", "Model B", "Empty Values"],
|
|
767
767
|
display_value: [
|
|
768
|
-
["🥇 95", "92", "
|
|
769
|
-
["🥈 89", "90", "
|
|
770
|
-
["🥉 92", "88", "
|
|
771
|
-
["87", "85", "
|
|
772
|
-
["91", "93", "
|
|
773
|
-
["82", "81", "
|
|
768
|
+
["🥇 95", "92", ""],
|
|
769
|
+
["🥈 89", "90", ""],
|
|
770
|
+
["🥉 92", "88", ""],
|
|
771
|
+
["87", "85", ""],
|
|
772
|
+
["91", "93", ""],
|
|
773
|
+
["82", "81", ""]
|
|
774
774
|
],
|
|
775
775
|
label: "Model Performance with Medal Indicators",
|
|
776
776
|
col_count: [3, "dynamic"],
|
package/dist/shared/Table.svelte
CHANGED
|
@@ -95,6 +95,8 @@ $:
|
|
|
95
95
|
onMount(() => {
|
|
96
96
|
df_ctx.parent_element = parent;
|
|
97
97
|
df_ctx.get_data_at = get_data_at;
|
|
98
|
+
df_ctx.get_column = get_column;
|
|
99
|
+
df_ctx.get_row = get_row;
|
|
98
100
|
df_ctx.dispatch = dispatch;
|
|
99
101
|
init_drag_handlers();
|
|
100
102
|
const observer = new IntersectionObserver((entries) => {
|
|
@@ -146,6 +148,8 @@ onMount(() => {
|
|
|
146
148
|
);
|
|
147
149
|
});
|
|
148
150
|
const get_data_at = (row, col) => data?.[row]?.[col]?.value;
|
|
151
|
+
const get_column = (col) => data?.map((row) => row[col]?.value) ?? [];
|
|
152
|
+
const get_row = (row) => data?.[row]?.map((cell) => cell.value) ?? [];
|
|
149
153
|
$: {
|
|
150
154
|
if (!dequal(headers, old_headers)) {
|
|
151
155
|
_headers = make_headers(headers, col_count, els, make_id);
|
|
@@ -205,7 +209,7 @@ $:
|
|
|
205
209
|
row.forEach((cell, col_idx) => {
|
|
206
210
|
cell_map.set(cell.id, {
|
|
207
211
|
value: cell.value,
|
|
208
|
-
display_value: cell.display_value
|
|
212
|
+
display_value: cell.display_value !== void 0 ? cell.display_value : String(cell.value),
|
|
209
213
|
styling: styling?.[row_idx]?.[col_idx] || ""
|
|
210
214
|
});
|
|
211
215
|
});
|
|
@@ -216,7 +220,7 @@ $:
|
|
|
216
220
|
const original = cell_map.get(cell.id);
|
|
217
221
|
return {
|
|
218
222
|
...cell,
|
|
219
|
-
display_value: original?.display_value
|
|
223
|
+
display_value: original?.display_value !== void 0 ? original.display_value : String(cell.value),
|
|
220
224
|
styling: original?.styling || ""
|
|
221
225
|
};
|
|
222
226
|
})
|
|
@@ -483,7 +487,9 @@ function commit_filter() {
|
|
|
483
487
|
const styling_row = [];
|
|
484
488
|
row.forEach((cell) => {
|
|
485
489
|
data_row.push(cell.value);
|
|
486
|
-
display_row.push(
|
|
490
|
+
display_row.push(
|
|
491
|
+
cell.display_value !== void 0 ? cell.display_value : String(cell.value)
|
|
492
|
+
);
|
|
487
493
|
styling_row.push(cell.styling || "");
|
|
488
494
|
});
|
|
489
495
|
filtered_data.push(data_row);
|
|
@@ -575,10 +581,10 @@ $:
|
|
|
575
581
|
function get_cell_display_value(row, col) {
|
|
576
582
|
const is_search_active = $df_state.current_search_query !== void 0;
|
|
577
583
|
if (is_search_active && search_results?.[row]?.[col]) {
|
|
578
|
-
return search_results[row][col].display_value
|
|
584
|
+
return search_results[row][col].display_value !== void 0 ? search_results[row][col].display_value : String(search_results[row][col].value);
|
|
579
585
|
}
|
|
580
586
|
if (data?.[row]?.[col]) {
|
|
581
|
-
return data[row][col].display_value
|
|
587
|
+
return data[row][col].display_value !== void 0 ? data[row][col].display_value : String(data[row][col].value);
|
|
582
588
|
}
|
|
583
589
|
return "";
|
|
584
590
|
}
|
|
@@ -140,6 +140,8 @@ export interface DataFrameContext {
|
|
|
140
140
|
}>;
|
|
141
141
|
parent_element?: HTMLElement;
|
|
142
142
|
get_data_at?: (row: number, col: number) => string | number;
|
|
143
|
+
get_column?: (col: number) => (string | number)[];
|
|
144
|
+
get_row?: (row: number) => (string | number)[];
|
|
143
145
|
dispatch?: (e: "change" | "select" | "search", detail?: any) => void;
|
|
144
146
|
}
|
|
145
147
|
export declare function create_dataframe_context(config: DataFrameState["config"]): DataFrameContext;
|
|
@@ -237,6 +237,8 @@ function create_actions(state, context) {
|
|
|
237
237
|
}
|
|
238
238
|
context.dispatch?.("select", {
|
|
239
239
|
index: [actual_row, col],
|
|
240
|
+
col_value: context.get_column(col),
|
|
241
|
+
row_value: context.get_row(actual_row),
|
|
240
242
|
value: context.get_data_at(actual_row, col)
|
|
241
243
|
});
|
|
242
244
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradio/dataframe",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.8",
|
|
4
4
|
"description": "Gradio UI packages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "",
|
|
@@ -17,14 +17,14 @@
|
|
|
17
17
|
"dompurify": "^3.0.3",
|
|
18
18
|
"katex": "^0.16.7",
|
|
19
19
|
"marked": "^12.0.0",
|
|
20
|
-
"@gradio/
|
|
21
|
-
"@gradio/
|
|
20
|
+
"@gradio/client": "^1.14.2",
|
|
21
|
+
"@gradio/atoms": "^0.15.2",
|
|
22
22
|
"@gradio/icons": "^0.12.0",
|
|
23
|
-
"@gradio/
|
|
24
|
-
"@gradio/markdown-code": "^0.4.
|
|
25
|
-
"@gradio/statustracker": "^0.10.
|
|
26
|
-
"@gradio/upload": "^0.16.
|
|
27
|
-
"@gradio/utils": "^0.10.
|
|
23
|
+
"@gradio/button": "^0.4.15",
|
|
24
|
+
"@gradio/markdown-code": "^0.4.3",
|
|
25
|
+
"@gradio/statustracker": "^0.10.9",
|
|
26
|
+
"@gradio/upload": "^0.16.2",
|
|
27
|
+
"@gradio/utils": "^0.10.2"
|
|
28
28
|
},
|
|
29
29
|
"exports": {
|
|
30
30
|
".": {
|
package/shared/Table.svelte
CHANGED
|
@@ -111,6 +111,8 @@
|
|
|
111
111
|
onMount(() => {
|
|
112
112
|
df_ctx.parent_element = parent;
|
|
113
113
|
df_ctx.get_data_at = get_data_at;
|
|
114
|
+
df_ctx.get_column = get_column;
|
|
115
|
+
df_ctx.get_row = get_row;
|
|
114
116
|
df_ctx.dispatch = dispatch;
|
|
115
117
|
init_drag_handlers();
|
|
116
118
|
|
|
@@ -186,6 +188,12 @@
|
|
|
186
188
|
const get_data_at = (row: number, col: number): string | number =>
|
|
187
189
|
data?.[row]?.[col]?.value;
|
|
188
190
|
|
|
191
|
+
const get_column = (col: number): (string | number)[] =>
|
|
192
|
+
data?.map((row) => row[col]?.value) ?? [];
|
|
193
|
+
|
|
194
|
+
const get_row = (row: number): (string | number)[] =>
|
|
195
|
+
data?.[row]?.map((cell) => cell.value) ?? [];
|
|
196
|
+
|
|
189
197
|
$: {
|
|
190
198
|
if (!dequal(headers, old_headers)) {
|
|
191
199
|
_headers = make_headers(headers, col_count, els, make_id);
|
|
@@ -268,7 +276,10 @@
|
|
|
268
276
|
row.forEach((cell, col_idx) => {
|
|
269
277
|
cell_map.set(cell.id, {
|
|
270
278
|
value: cell.value,
|
|
271
|
-
display_value:
|
|
279
|
+
display_value:
|
|
280
|
+
cell.display_value !== undefined
|
|
281
|
+
? cell.display_value
|
|
282
|
+
: String(cell.value),
|
|
272
283
|
styling: styling?.[row_idx]?.[col_idx] || ""
|
|
273
284
|
});
|
|
274
285
|
});
|
|
@@ -281,7 +292,10 @@
|
|
|
281
292
|
const original = cell_map.get(cell.id);
|
|
282
293
|
return {
|
|
283
294
|
...cell,
|
|
284
|
-
display_value:
|
|
295
|
+
display_value:
|
|
296
|
+
original?.display_value !== undefined
|
|
297
|
+
? original.display_value
|
|
298
|
+
: String(cell.value),
|
|
285
299
|
styling: original?.styling || ""
|
|
286
300
|
};
|
|
287
301
|
})
|
|
@@ -601,7 +615,11 @@
|
|
|
601
615
|
|
|
602
616
|
row.forEach((cell) => {
|
|
603
617
|
data_row.push(cell.value);
|
|
604
|
-
display_row.push(
|
|
618
|
+
display_row.push(
|
|
619
|
+
cell.display_value !== undefined
|
|
620
|
+
? cell.display_value
|
|
621
|
+
: String(cell.value)
|
|
622
|
+
);
|
|
605
623
|
styling_row.push(cell.styling || "");
|
|
606
624
|
});
|
|
607
625
|
|
|
@@ -705,14 +723,15 @@
|
|
|
705
723
|
const is_search_active = $df_state.current_search_query !== undefined;
|
|
706
724
|
|
|
707
725
|
if (is_search_active && search_results?.[row]?.[col]) {
|
|
708
|
-
return
|
|
709
|
-
search_results[row][col].display_value
|
|
710
|
-
String(search_results[row][col].value)
|
|
711
|
-
);
|
|
726
|
+
return search_results[row][col].display_value !== undefined
|
|
727
|
+
? search_results[row][col].display_value
|
|
728
|
+
: String(search_results[row][col].value);
|
|
712
729
|
}
|
|
713
730
|
|
|
714
731
|
if (data?.[row]?.[col]) {
|
|
715
|
-
return data[row][col].display_value
|
|
732
|
+
return data[row][col].display_value !== undefined
|
|
733
|
+
? data[row][col].display_value
|
|
734
|
+
: String(data[row][col].value);
|
|
716
735
|
}
|
|
717
736
|
|
|
718
737
|
return "";
|
package/shared/TableCell.svelte
CHANGED
|
@@ -122,7 +122,9 @@
|
|
|
122
122
|
<EditableCell
|
|
123
123
|
bind:value
|
|
124
124
|
bind:el={el.input}
|
|
125
|
-
display_value={display_value
|
|
125
|
+
display_value={display_value !== undefined
|
|
126
|
+
? display_value
|
|
127
|
+
: String(value)}
|
|
126
128
|
{latex_delimiters}
|
|
127
129
|
{line_breaks}
|
|
128
130
|
{editable}
|
|
@@ -155,6 +155,8 @@ export interface DataFrameContext {
|
|
|
155
155
|
>;
|
|
156
156
|
parent_element?: HTMLElement;
|
|
157
157
|
get_data_at?: (row: number, col: number) => string | number;
|
|
158
|
+
get_column?: (col: number) => (string | number)[];
|
|
159
|
+
get_row?: (row: number) => (string | number)[];
|
|
158
160
|
dispatch?: (e: "change" | "select" | "search", detail?: any) => void;
|
|
159
161
|
}
|
|
160
162
|
|
|
@@ -467,6 +469,8 @@ function create_actions(
|
|
|
467
469
|
|
|
468
470
|
context.dispatch?.("select", {
|
|
469
471
|
index: [actual_row, col],
|
|
472
|
+
col_value: context.get_column!(col),
|
|
473
|
+
row_value: context.get_row!(actual_row),
|
|
470
474
|
value: context.get_data_at!(actual_row, col)
|
|
471
475
|
});
|
|
472
476
|
},
|