@gradio/dataframe 0.18.8 → 0.19.0
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 +12 -0
- package/Example.svelte +8 -8
- package/Index.svelte +1 -1
- package/README.md +232 -37
- package/dist/Example.svelte +8 -8
- package/dist/Example.svelte.d.ts +3 -1
- package/dist/Index.svelte.d.ts +20 -18
- package/dist/shared/BooleanCell.svelte +1 -2
- package/dist/shared/BooleanCell.svelte.d.ts +4 -2
- package/dist/shared/CellMenu.svelte +4 -8
- package/dist/shared/CellMenu.svelte.d.ts +11 -9
- package/dist/shared/CellMenuButton.svelte.d.ts +2 -0
- package/dist/shared/CellMenuIcons.svelte.d.ts +2 -0
- package/dist/shared/EditableCell.svelte +6 -12
- package/dist/shared/EditableCell.svelte.d.ts +17 -15
- package/dist/shared/EmptyRowButton.svelte.d.ts +2 -0
- package/dist/shared/Example.svelte.d.ts +2 -0
- package/dist/shared/FilterMenu.svelte +2 -4
- package/dist/shared/FilterMenu.svelte.d.ts +3 -1
- package/dist/shared/RowNumber.svelte.d.ts +4 -2
- package/dist/shared/Table.svelte +127 -157
- package/dist/shared/Table.svelte.d.ts +24 -22
- package/dist/shared/TableCell.svelte +7 -13
- package/dist/shared/TableCell.svelte.d.ts +6 -4
- package/dist/shared/TableHeader.svelte +5 -10
- package/dist/shared/TableHeader.svelte.d.ts +4 -2
- package/dist/shared/Toolbar.svelte +3 -4
- package/dist/shared/Toolbar.svelte.d.ts +7 -5
- package/dist/shared/VirtualTable.svelte +19 -16
- package/dist/shared/VirtualTable.svelte.d.ts +9 -6
- package/dist/shared/context/dataframe_context.d.ts +1 -1
- package/dist/shared/context/dataframe_context.js +1 -1
- package/dist/shared/icons/FilterIcon.svelte.d.ts +3 -3
- package/dist/shared/icons/Padlock.svelte.d.ts +2 -0
- package/dist/shared/icons/SelectionButtons.svelte +2 -4
- package/dist/shared/icons/SelectionButtons.svelte.d.ts +3 -1
- package/dist/shared/icons/SortArrowDown.svelte.d.ts +3 -1
- package/dist/shared/icons/SortArrowUp.svelte.d.ts +3 -1
- package/dist/shared/icons/SortButtonDown.svelte.d.ts +2 -0
- package/dist/shared/icons/SortButtonUp.svelte.d.ts +2 -0
- package/dist/shared/icons/SortIcon.svelte.d.ts +4 -2
- package/dist/shared/utils/data_processing.d.ts +1 -1
- package/dist/shared/utils/drag_utils.js +1 -1
- package/dist/shared/utils/keyboard_utils.js +5 -3
- package/dist/shared/{selection_utils.d.ts → utils/selection_utils.d.ts} +1 -1
- package/dist/shared/{utils.d.ts → utils/utils.d.ts} +2 -2
- package/dist/standalone/Index.svelte +660 -0
- package/dist/standalone/Index.svelte.d.ts +45 -0
- package/dist/standalone/default_i18n.d.ts +1 -0
- package/dist/standalone/default_i18n.js +32 -0
- package/dist/standalone/stubs/Upload.svelte +18 -0
- package/dist/standalone/stubs/Upload.svelte.d.ts +27 -0
- package/dist/standalone/stubs/upload.d.ts +1 -0
- package/dist/standalone/stubs/upload.js +1 -0
- package/package.json +8 -11
- package/shared/CellMenu.svelte +1 -1
- package/shared/FilterMenu.svelte +1 -2
- package/shared/Table.svelte +9 -7
- package/shared/TableCell.svelte +2 -2
- package/shared/Toolbar.svelte +1 -0
- package/shared/VirtualTable.svelte +11 -2
- package/shared/context/dataframe_context.ts +1 -1
- package/shared/utils/data_processing.ts +1 -1
- package/shared/utils/drag_utils.ts +1 -1
- package/shared/utils/keyboard_utils.ts +5 -5
- package/shared/{selection_utils.ts → utils/selection_utils.ts} +1 -1
- package/shared/{utils.ts → utils/utils.ts} +11 -2
- package/standalone/Index.svelte +688 -0
- package/standalone/default_i18n.ts +32 -0
- package/standalone/stubs/Upload.svelte +19 -0
- package/standalone/stubs/upload.ts +1 -0
- package/test/table_utils.test.ts +1 -1
- /package/dist/shared/{selection_utils.js → utils/selection_utils.js} +0 -0
- /package/dist/shared/{utils.js → utils/utils.js} +0 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export const default_i18n = {
|
|
2
|
+
"dataframe.add_row_above": "Add row above",
|
|
3
|
+
"dataframe.add_row_below": "Add row below",
|
|
4
|
+
"dataframe.delete_row": "Delete row",
|
|
5
|
+
"dataframe.add_column_left": "Add column left",
|
|
6
|
+
"dataframe.add_column_right": "Add column right",
|
|
7
|
+
"dataframe.delete_column": "Delete column",
|
|
8
|
+
"dataframe.sort_asc": "Sort ascending",
|
|
9
|
+
"dataframe.sort_desc": "Sort descending",
|
|
10
|
+
"dataframe.sort_ascending": "Sort ascending",
|
|
11
|
+
"dataframe.sort_descending": "Sort descending",
|
|
12
|
+
"dataframe.clear_sort": "Clear sort",
|
|
13
|
+
"dataframe.filter": "Filter",
|
|
14
|
+
"dataframe.clear_filter": "Clear filter",
|
|
15
|
+
"dataframe.copy": "Copy",
|
|
16
|
+
"dataframe.paste": "Paste",
|
|
17
|
+
"dataframe.cut": "Cut",
|
|
18
|
+
"dataframe.select_all": "Select all",
|
|
19
|
+
"dataframe.fullscreen": "Fullscreen",
|
|
20
|
+
"dataframe.exit_fullscreen": "Exit fullscreen",
|
|
21
|
+
"dataframe.search": "Search",
|
|
22
|
+
"dataframe.export": "Export",
|
|
23
|
+
"dataframe.import": "Import",
|
|
24
|
+
"dataframe.edit": "Edit",
|
|
25
|
+
"dataframe.save": "Save",
|
|
26
|
+
"dataframe.cancel": "Cancel",
|
|
27
|
+
"dataframe.confirm": "Confirm",
|
|
28
|
+
"dataframe.reset": "Reset",
|
|
29
|
+
"dataframe.clear": "Clear",
|
|
30
|
+
"dataframe.undo": "Undo",
|
|
31
|
+
"dataframe.redo": "Redo"
|
|
32
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script>export const aria_label = "";
|
|
2
|
+
export const root = "";
|
|
3
|
+
export const upload = null;
|
|
4
|
+
export const stream_handler = null;
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<div>
|
|
8
|
+
<slot />
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
<style>
|
|
12
|
+
div {
|
|
13
|
+
width: 100%;
|
|
14
|
+
border: 1px solid var(--border-color-primary);
|
|
15
|
+
border-radius: var(--table-radius);
|
|
16
|
+
overflow: hidden;
|
|
17
|
+
}
|
|
18
|
+
</style>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
aria_label?: "";
|
|
5
|
+
root?: "";
|
|
6
|
+
upload?: any;
|
|
7
|
+
stream_handler?: any;
|
|
8
|
+
};
|
|
9
|
+
events: {
|
|
10
|
+
[evt: string]: CustomEvent<any>;
|
|
11
|
+
};
|
|
12
|
+
slots: {
|
|
13
|
+
default: {};
|
|
14
|
+
};
|
|
15
|
+
exports?: {} | undefined;
|
|
16
|
+
bindings?: string | undefined;
|
|
17
|
+
};
|
|
18
|
+
export type UploadProps = typeof __propDef.props;
|
|
19
|
+
export type UploadEvents = typeof __propDef.events;
|
|
20
|
+
export type UploadSlots = typeof __propDef.slots;
|
|
21
|
+
export default class Upload extends SvelteComponent<UploadProps, UploadEvents, UploadSlots> {
|
|
22
|
+
get aria_label(): "";
|
|
23
|
+
get root(): "";
|
|
24
|
+
get upload(): any;
|
|
25
|
+
get stream_handler(): any;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Upload } from "./Upload.svelte";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Upload } from "./Upload.svelte";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradio/dataframe",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "Gradio UI packages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "",
|
|
@@ -14,24 +14,21 @@
|
|
|
14
14
|
"@types/katex": "^0.16.0",
|
|
15
15
|
"d3-dsv": "^3.0.1",
|
|
16
16
|
"dequal": "^2.0.2",
|
|
17
|
-
"dompurify": "^3.0.3",
|
|
18
|
-
"katex": "^0.16.7",
|
|
19
|
-
"marked": "^12.0.0",
|
|
20
|
-
"@gradio/button": "^0.5.11",
|
|
21
17
|
"@gradio/atoms": "^0.16.5",
|
|
18
|
+
"@gradio/button": "^0.5.11",
|
|
22
19
|
"@gradio/checkbox": "^0.4.28",
|
|
23
|
-
"@gradio/
|
|
24
|
-
"@gradio/icons": "^0.13.0",
|
|
20
|
+
"@gradio/icons": "^0.13.1",
|
|
25
21
|
"@gradio/markdown-code": "^0.5.0",
|
|
26
22
|
"@gradio/statustracker": "^0.10.17",
|
|
27
|
-
"@gradio/upload": "^0.16.
|
|
23
|
+
"@gradio/upload": "^0.16.16",
|
|
24
|
+
"@gradio/client": "^1.17.1",
|
|
28
25
|
"@gradio/utils": "^0.10.2"
|
|
29
26
|
},
|
|
30
27
|
"exports": {
|
|
31
28
|
".": {
|
|
32
29
|
"gradio": "./Index.svelte",
|
|
33
|
-
"svelte": "./dist/Index.svelte",
|
|
34
|
-
"types": "./dist/Index.svelte.d.ts"
|
|
30
|
+
"svelte": "./dist/standalone/Index.svelte",
|
|
31
|
+
"types": "./dist/standalone/Index.svelte.d.ts"
|
|
35
32
|
},
|
|
36
33
|
"./example": {
|
|
37
34
|
"gradio": "./Example.svelte",
|
|
@@ -41,7 +38,7 @@
|
|
|
41
38
|
"./package.json": "./package.json"
|
|
42
39
|
},
|
|
43
40
|
"peerDependencies": {
|
|
44
|
-
"svelte": "
|
|
41
|
+
"svelte": ">=4.0.0 <6.0.0"
|
|
45
42
|
},
|
|
46
43
|
"devDependencies": {
|
|
47
44
|
"@gradio/preview": "^0.14.0"
|
package/shared/CellMenu.svelte
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { onMount } from "svelte";
|
|
3
3
|
import CellMenuIcons from "./CellMenuIcons.svelte";
|
|
4
4
|
import FilterMenu from "./FilterMenu.svelte";
|
|
5
|
-
import type { I18nFormatter } from "
|
|
5
|
+
import type { I18nFormatter } from "@gradio/utils";
|
|
6
6
|
import type {
|
|
7
7
|
SortDirection,
|
|
8
8
|
FilterDatatype
|
package/shared/FilterMenu.svelte
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { onMount } from "svelte";
|
|
3
|
-
import { Check } from "@gradio/icons";
|
|
4
|
-
import DropdownArrow from "../../icons/src/DropdownArrow.svelte";
|
|
3
|
+
import { Check, DropdownArrow } from "@gradio/icons";
|
|
5
4
|
import type { FilterDatatype } from "./context/dataframe_context";
|
|
6
5
|
|
|
7
6
|
export let on_filter: (
|
package/shared/Table.svelte
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
import type { I18nFormatter } from "js/core/src/gradio_helper";
|
|
21
21
|
import { type Client } from "@gradio/client";
|
|
22
22
|
import VirtualTable from "./VirtualTable.svelte";
|
|
23
|
-
import type { Headers, DataframeValue, Datatype } from "./utils";
|
|
23
|
+
import type { Headers, DataframeValue, Datatype } from "./utils/utils";
|
|
24
24
|
import CellMenu from "./CellMenu.svelte";
|
|
25
25
|
import Toolbar from "./Toolbar.svelte";
|
|
26
26
|
import type { CellCoordinate } from "./types";
|
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
get_current_indices,
|
|
31
31
|
handle_click_outside as handle_click_outside_util,
|
|
32
32
|
calculate_selection_positions
|
|
33
|
-
} from "./selection_utils";
|
|
33
|
+
} from "./utils/selection_utils";
|
|
34
34
|
import {
|
|
35
35
|
copy_table_data,
|
|
36
36
|
get_max,
|
|
37
37
|
handle_file_upload
|
|
38
38
|
} from "./utils/table_utils";
|
|
39
39
|
import { make_headers, process_data } from "./utils/data_processing";
|
|
40
|
-
import { cast_value_to_type } from "./utils";
|
|
40
|
+
import { cast_value_to_type } from "./utils/utils";
|
|
41
41
|
import { handle_keydown, handle_cell_blur } from "./utils/keyboard_utils";
|
|
42
42
|
import {
|
|
43
43
|
create_drag_handlers,
|
|
@@ -500,6 +500,10 @@
|
|
|
500
500
|
return;
|
|
501
501
|
}
|
|
502
502
|
|
|
503
|
+
if (!parent) {
|
|
504
|
+
return;
|
|
505
|
+
}
|
|
506
|
+
|
|
503
507
|
last_width_data_length = data.length;
|
|
504
508
|
last_width_column_count = column_count;
|
|
505
509
|
|
|
@@ -834,7 +838,6 @@
|
|
|
834
838
|
class="table-wrap"
|
|
835
839
|
class:dragging={is_dragging}
|
|
836
840
|
class:no-wrap={!wrap}
|
|
837
|
-
style="height:{table_height}px;"
|
|
838
841
|
class:menu-open={active_cell_menu || active_header_menu}
|
|
839
842
|
on:keydown={(e) => handle_keydown(e, df_ctx)}
|
|
840
843
|
on:mousemove={handle_mouse_move}
|
|
@@ -948,11 +951,9 @@
|
|
|
948
951
|
active_header_menu !== null}
|
|
949
952
|
bind:viewport
|
|
950
953
|
bind:show_scroll_button
|
|
954
|
+
{label}
|
|
951
955
|
on:scroll_top={(_) => {}}
|
|
952
956
|
>
|
|
953
|
-
{#if label && label.length !== 0}
|
|
954
|
-
<caption class="sr-only">{label}</caption>
|
|
955
|
-
{/if}
|
|
956
957
|
<tr slot="thead">
|
|
957
958
|
{#if show_row_numbers}
|
|
958
959
|
<RowNumber is_header={true} />
|
|
@@ -1211,6 +1212,7 @@
|
|
|
1211
1212
|
.header-row .label {
|
|
1212
1213
|
flex: 1 1 auto;
|
|
1213
1214
|
margin-right: auto;
|
|
1215
|
+
font-family: var(--font-sans);
|
|
1214
1216
|
}
|
|
1215
1217
|
|
|
1216
1218
|
.header-row .label p {
|
package/shared/TableCell.svelte
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import EditableCell from "./EditableCell.svelte";
|
|
3
3
|
import CellMenuButton from "./CellMenuButton.svelte";
|
|
4
4
|
import type { I18nFormatter } from "js/core/src/gradio_helper";
|
|
5
|
-
import type { Datatype } from "./utils";
|
|
6
|
-
import { is_cell_in_selection } from "./selection_utils";
|
|
5
|
+
import type { Datatype } from "./utils/utils";
|
|
6
|
+
import { is_cell_in_selection } from "./utils/selection_utils";
|
|
7
7
|
|
|
8
8
|
export let value: string | number;
|
|
9
9
|
export let index: number;
|
package/shared/Toolbar.svelte
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { onMount, tick, createEventDispatcher } from "svelte";
|
|
3
|
-
import { _ } from "svelte-i18n";
|
|
4
3
|
|
|
5
4
|
export let items: any[][] = [];
|
|
6
5
|
|
|
@@ -13,6 +12,7 @@
|
|
|
13
12
|
export let disable_scroll = false;
|
|
14
13
|
export let show_scroll_button = false;
|
|
15
14
|
export let viewport: HTMLTableElement;
|
|
15
|
+
export let label: string | null = null;
|
|
16
16
|
|
|
17
17
|
const dispatch = createEventDispatcher<{
|
|
18
18
|
scroll_top: number;
|
|
@@ -47,6 +47,10 @@
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
async function refresh_height_map(): Promise<void> {
|
|
50
|
+
if (!viewport) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
50
54
|
if (sortedItems.length < start) {
|
|
51
55
|
await scroll_to_index(sortedItems.length - 1, { behavior: "auto" });
|
|
52
56
|
}
|
|
@@ -212,6 +216,9 @@
|
|
|
212
216
|
on:scroll={refresh_height_map}
|
|
213
217
|
style="height: {height}; --bw-svt-p-top: {top}px; --bw-svt-p-bottom: {bottom}px; --bw-svt-head-height: {head_height}px; --bw-svt-foot-height: {foot_height}px; --bw-svt-avg-row-height: {average_height}px; --max-height: {max_height}px"
|
|
214
218
|
>
|
|
219
|
+
{#if label && label.length !== 0}
|
|
220
|
+
<caption class="sr-only">{label}</caption>
|
|
221
|
+
{/if}
|
|
215
222
|
<thead class="thead" bind:offsetHeight={head_height}>
|
|
216
223
|
<slot name="thead" />
|
|
217
224
|
</thead>
|
|
@@ -219,7 +226,9 @@
|
|
|
219
226
|
{#if visible.length && visible[0].data.length}
|
|
220
227
|
{#each visible as item (item.data[0].id)}
|
|
221
228
|
<slot name="tbody" item={item.data} index={item.index}>
|
|
222
|
-
|
|
229
|
+
<tr>
|
|
230
|
+
<td>Missing Table Row</td>
|
|
231
|
+
</tr>
|
|
223
232
|
</slot>
|
|
224
233
|
{/each}
|
|
225
234
|
{/if}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { dequal } from "dequal/lite";
|
|
2
|
-
import { handle_delete_key } from "../selection_utils";
|
|
2
|
+
import { handle_delete_key } from "../utils/selection_utils";
|
|
3
3
|
import type { DataFrameContext } from "../context/dataframe_context";
|
|
4
4
|
import { tick } from "svelte";
|
|
5
5
|
import { get } from "svelte/store";
|
|
@@ -15,6 +15,9 @@ async function save_cell_value(
|
|
|
15
15
|
|
|
16
16
|
const old_value = ctx.data[row][col].value;
|
|
17
17
|
ctx.data[row][col].value = input_value;
|
|
18
|
+
if (ctx.data[row][col].display_value !== undefined) {
|
|
19
|
+
ctx.data[row][col].display_value = input_value;
|
|
20
|
+
}
|
|
18
21
|
|
|
19
22
|
if (old_value !== input_value && ctx.dispatch) {
|
|
20
23
|
ctx.dispatch("change", {
|
|
@@ -243,10 +246,7 @@ function handle_default_key(
|
|
|
243
246
|
|
|
244
247
|
const editing = state.ui_state.editing;
|
|
245
248
|
|
|
246
|
-
if (
|
|
247
|
-
(!editing || (editing && dequal(editing, [i, j]))) &&
|
|
248
|
-
event.key.length === 1
|
|
249
|
-
) {
|
|
249
|
+
if (event.key.length === 1 && (!editing || !dequal(editing, [i, j]))) {
|
|
250
250
|
ctx.actions.set_editing([i, j]);
|
|
251
251
|
return true;
|
|
252
252
|
}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
export type Headers = string[];
|
|
2
2
|
export type Data = (string | number)[][];
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
export type Datatype =
|
|
5
|
+
| "str"
|
|
6
|
+
| "number"
|
|
7
|
+
| "bool"
|
|
8
|
+
| "date"
|
|
9
|
+
| "markdown"
|
|
10
|
+
| "html"
|
|
11
|
+
| "image";
|
|
12
|
+
|
|
4
13
|
export type Metadata = {
|
|
5
14
|
[key: string]: string[][] | null;
|
|
6
15
|
} | null;
|
|
@@ -8,7 +17,7 @@ export type HeadersWithIDs = { value: string; id: string }[];
|
|
|
8
17
|
export type DataframeValue = {
|
|
9
18
|
data: Data;
|
|
10
19
|
headers: Headers;
|
|
11
|
-
metadata
|
|
20
|
+
metadata?: Metadata;
|
|
12
21
|
};
|
|
13
22
|
|
|
14
23
|
/**
|