@gradio/dataframe 0.18.8 → 0.19.1

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.
Files changed (74) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/Example.svelte +8 -8
  3. package/Index.svelte +1 -1
  4. package/README.md +232 -37
  5. package/dist/Example.svelte +8 -8
  6. package/dist/Example.svelte.d.ts +3 -1
  7. package/dist/Index.svelte.d.ts +20 -18
  8. package/dist/shared/BooleanCell.svelte +1 -2
  9. package/dist/shared/BooleanCell.svelte.d.ts +4 -2
  10. package/dist/shared/CellMenu.svelte +4 -8
  11. package/dist/shared/CellMenu.svelte.d.ts +11 -9
  12. package/dist/shared/CellMenuButton.svelte.d.ts +2 -0
  13. package/dist/shared/CellMenuIcons.svelte.d.ts +2 -0
  14. package/dist/shared/EditableCell.svelte +6 -12
  15. package/dist/shared/EditableCell.svelte.d.ts +17 -15
  16. package/dist/shared/EmptyRowButton.svelte.d.ts +2 -0
  17. package/dist/shared/Example.svelte.d.ts +2 -0
  18. package/dist/shared/FilterMenu.svelte +2 -4
  19. package/dist/shared/FilterMenu.svelte.d.ts +3 -1
  20. package/dist/shared/RowNumber.svelte.d.ts +4 -2
  21. package/dist/shared/Table.svelte +127 -157
  22. package/dist/shared/Table.svelte.d.ts +24 -22
  23. package/dist/shared/TableCell.svelte +7 -13
  24. package/dist/shared/TableCell.svelte.d.ts +6 -4
  25. package/dist/shared/TableHeader.svelte +5 -10
  26. package/dist/shared/TableHeader.svelte.d.ts +4 -2
  27. package/dist/shared/Toolbar.svelte +3 -4
  28. package/dist/shared/Toolbar.svelte.d.ts +7 -5
  29. package/dist/shared/VirtualTable.svelte +19 -16
  30. package/dist/shared/VirtualTable.svelte.d.ts +9 -6
  31. package/dist/shared/context/dataframe_context.d.ts +1 -1
  32. package/dist/shared/context/dataframe_context.js +1 -1
  33. package/dist/shared/icons/FilterIcon.svelte.d.ts +3 -3
  34. package/dist/shared/icons/Padlock.svelte.d.ts +2 -0
  35. package/dist/shared/icons/SelectionButtons.svelte +2 -4
  36. package/dist/shared/icons/SelectionButtons.svelte.d.ts +3 -1
  37. package/dist/shared/icons/SortArrowDown.svelte.d.ts +3 -1
  38. package/dist/shared/icons/SortArrowUp.svelte.d.ts +3 -1
  39. package/dist/shared/icons/SortButtonDown.svelte.d.ts +2 -0
  40. package/dist/shared/icons/SortButtonUp.svelte.d.ts +2 -0
  41. package/dist/shared/icons/SortIcon.svelte.d.ts +4 -2
  42. package/dist/shared/utils/data_processing.d.ts +1 -1
  43. package/dist/shared/utils/drag_utils.js +1 -1
  44. package/dist/shared/utils/keyboard_utils.js +5 -3
  45. package/dist/shared/{selection_utils.d.ts → utils/selection_utils.d.ts} +1 -1
  46. package/dist/shared/{utils.d.ts → utils/utils.d.ts} +2 -2
  47. package/dist/standalone/Index.svelte +660 -0
  48. package/dist/standalone/Index.svelte.d.ts +45 -0
  49. package/dist/standalone/default_i18n.d.ts +1 -0
  50. package/dist/standalone/default_i18n.js +32 -0
  51. package/dist/standalone/stubs/Upload.svelte +18 -0
  52. package/dist/standalone/stubs/Upload.svelte.d.ts +27 -0
  53. package/dist/standalone/stubs/upload.d.ts +1 -0
  54. package/dist/standalone/stubs/upload.js +1 -0
  55. package/package.json +9 -13
  56. package/shared/CellMenu.svelte +1 -1
  57. package/shared/FilterMenu.svelte +1 -2
  58. package/shared/Table.svelte +9 -7
  59. package/shared/TableCell.svelte +2 -2
  60. package/shared/Toolbar.svelte +1 -0
  61. package/shared/VirtualTable.svelte +11 -2
  62. package/shared/context/dataframe_context.ts +1 -1
  63. package/shared/utils/data_processing.ts +1 -1
  64. package/shared/utils/drag_utils.ts +1 -1
  65. package/shared/utils/keyboard_utils.ts +5 -5
  66. package/shared/{selection_utils.ts → utils/selection_utils.ts} +1 -1
  67. package/shared/{utils.ts → utils/utils.ts} +11 -2
  68. package/standalone/Index.svelte +688 -0
  69. package/standalone/default_i18n.ts +32 -0
  70. package/standalone/stubs/Upload.svelte +19 -0
  71. package/standalone/stubs/upload.ts +1 -0
  72. package/test/table_utils.test.ts +1 -1
  73. /package/dist/shared/{selection_utils.js → utils/selection_utils.js} +0 -0
  74. /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.18.8",
3
+ "version": "0.19.1",
4
4
  "description": "Gradio UI packages",
5
5
  "type": "module",
6
6
  "author": "",
@@ -10,28 +10,24 @@
10
10
  "main": "./Index.svelte",
11
11
  "dependencies": {
12
12
  "@types/d3-dsv": "^3.0.0",
13
- "@types/dompurify": "^3.0.2",
14
13
  "@types/katex": "^0.16.0",
15
14
  "d3-dsv": "^3.0.1",
16
15
  "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
16
  "@gradio/atoms": "^0.16.5",
17
+ "@gradio/button": "^0.5.11",
22
18
  "@gradio/checkbox": "^0.4.28",
19
+ "@gradio/icons": "^0.13.1",
20
+ "@gradio/markdown-code": "^0.5.1",
21
+ "@gradio/statustracker": "^0.10.18",
22
+ "@gradio/upload": "^0.16.16",
23
23
  "@gradio/client": "^1.17.1",
24
- "@gradio/icons": "^0.13.0",
25
- "@gradio/markdown-code": "^0.5.0",
26
- "@gradio/statustracker": "^0.10.17",
27
- "@gradio/upload": "^0.16.15",
28
24
  "@gradio/utils": "^0.10.2"
29
25
  },
30
26
  "exports": {
31
27
  ".": {
32
28
  "gradio": "./Index.svelte",
33
- "svelte": "./dist/Index.svelte",
34
- "types": "./dist/Index.svelte.d.ts"
29
+ "svelte": "./dist/standalone/Index.svelte",
30
+ "types": "./dist/standalone/Index.svelte.d.ts"
35
31
  },
36
32
  "./example": {
37
33
  "gradio": "./Example.svelte",
@@ -41,7 +37,7 @@
41
37
  "./package.json": "./package.json"
42
38
  },
43
39
  "peerDependencies": {
44
- "svelte": "^4.0.0"
40
+ "svelte": ">=4.0.0 <6.0.0"
45
41
  },
46
42
  "devDependencies": {
47
43
  "@gradio/preview": "^0.14.0"
@@ -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 "js/utils/src";
5
+ import type { I18nFormatter } from "@gradio/utils";
6
6
  import type {
7
7
  SortDirection,
8
8
  FilterDatatype
@@ -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: (
@@ -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 {
@@ -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;
@@ -99,6 +99,7 @@
99
99
  align-items: center;
100
100
  gap: var(--size-2);
101
101
  flex: 0 0 auto;
102
+ font-family: var(--font-sans);
102
103
  }
103
104
 
104
105
  .toolbar-buttons {
@@ -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
- Missing Table Row
229
+ <tr>
230
+ <td>Missing Table Row</td>
231
+ </tr>
223
232
  </slot>
224
233
  {/each}
225
234
  {/if}
@@ -8,7 +8,7 @@ import {
8
8
  get_next_cell_coordinates,
9
9
  get_range_selection,
10
10
  move_cursor
11
- } from "../selection_utils";
11
+ } from "../utils/selection_utils";
12
12
 
13
13
  export const DATAFRAME_KEY = Symbol("dataframe");
14
14
 
@@ -1,4 +1,4 @@
1
- import type { Headers, HeadersWithIDs } from "../utils";
1
+ import type { Headers, HeadersWithIDs } from "./utils";
2
2
 
3
3
  export function make_headers(
4
4
  _head: Headers,
@@ -1,5 +1,5 @@
1
1
  import type { CellCoordinate } from "../types";
2
- import { get_range_selection } from "../selection_utils";
2
+ import { get_range_selection } from "../utils/selection_utils";
3
3
 
4
4
  export type DragState = {
5
5
  is_dragging: boolean;
@@ -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,4 +1,4 @@
1
- import type { CellCoordinate } from "./types";
1
+ import type { CellCoordinate } from "./../types";
2
2
 
3
3
  export type CellData = { id: string; value: string | number };
4
4
 
@@ -1,6 +1,15 @@
1
1
  export type Headers = string[];
2
2
  export type Data = (string | number)[][];
3
- export type Datatype = "str" | "markdown" | "html" | "number" | "bool" | "date";
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: Metadata;
20
+ metadata?: Metadata;
12
21
  };
13
22
 
14
23
  /**