@gradio/dataframe 0.20.2-dev.0 → 0.21.0-dev.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.
Files changed (57) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/Example.svelte +17 -13
  3. package/Index.svelte +114 -108
  4. package/dist/Example.svelte +26 -20
  5. package/dist/Example.svelte.d.ts +21 -19
  6. package/dist/Index.svelte +121 -97
  7. package/dist/Index.svelte.d.ts +4 -164
  8. package/dist/shared/BooleanCell.svelte +12 -9
  9. package/dist/shared/BooleanCell.svelte.d.ts +20 -18
  10. package/dist/shared/CellMenu.svelte +82 -64
  11. package/dist/shared/CellMenu.svelte.d.ts +39 -37
  12. package/dist/shared/CellMenuButton.svelte +2 -1
  13. package/dist/shared/CellMenuButton.svelte.d.ts +18 -16
  14. package/dist/shared/CellMenuIcons.svelte +2 -1
  15. package/dist/shared/CellMenuIcons.svelte.d.ts +18 -16
  16. package/dist/shared/EditableCell.svelte +97 -56
  17. package/dist/shared/EditableCell.svelte.d.ts +50 -48
  18. package/dist/shared/EmptyRowButton.svelte +2 -1
  19. package/dist/shared/EmptyRowButton.svelte.d.ts +18 -16
  20. package/dist/shared/Example.svelte +2 -1
  21. package/dist/shared/Example.svelte.d.ts +18 -16
  22. package/dist/shared/FilterMenu.svelte +53 -39
  23. package/dist/shared/FilterMenu.svelte.d.ts +20 -18
  24. package/dist/shared/RowNumber.svelte +3 -2
  25. package/dist/shared/RowNumber.svelte.d.ts +19 -17
  26. package/dist/shared/Table.svelte +821 -620
  27. package/dist/shared/Table.svelte.d.ts +59 -56
  28. package/dist/shared/TableCell.svelte +95 -50
  29. package/dist/shared/TableCell.svelte.d.ts +61 -59
  30. package/dist/shared/TableHeader.svelte +86 -58
  31. package/dist/shared/TableHeader.svelte.d.ts +55 -53
  32. package/dist/shared/Toolbar.svelte +49 -39
  33. package/dist/shared/Toolbar.svelte.d.ts +27 -25
  34. package/dist/shared/VirtualTable.svelte +207 -154
  35. package/dist/shared/VirtualTable.svelte.d.ts +40 -37
  36. package/dist/shared/icons/FilterIcon.svelte +2 -1
  37. package/dist/shared/icons/FilterIcon.svelte.d.ts +16 -14
  38. package/dist/shared/icons/Padlock.svelte.d.ts +22 -21
  39. package/dist/shared/icons/SelectionButtons.svelte +15 -5
  40. package/dist/shared/icons/SelectionButtons.svelte.d.ts +20 -18
  41. package/dist/shared/icons/SortArrowDown.svelte +2 -1
  42. package/dist/shared/icons/SortArrowDown.svelte.d.ts +18 -16
  43. package/dist/shared/icons/SortArrowUp.svelte +2 -1
  44. package/dist/shared/icons/SortArrowUp.svelte.d.ts +18 -16
  45. package/dist/shared/icons/SortButtonDown.svelte.d.ts +22 -21
  46. package/dist/shared/icons/SortButtonUp.svelte.d.ts +22 -21
  47. package/dist/shared/icons/SortIcon.svelte +12 -8
  48. package/dist/shared/icons/SortIcon.svelte.d.ts +22 -20
  49. package/dist/shared/utils/data_processing.d.ts +1 -1
  50. package/dist/standalone/Index.svelte +103 -74
  51. package/dist/standalone/Index.svelte.d.ts +41 -39
  52. package/dist/standalone/stubs/Upload.svelte +5 -4
  53. package/dist/standalone/stubs/Upload.svelte.d.ts +35 -25
  54. package/package.json +15 -14
  55. package/shared/Table.svelte +4 -4
  56. package/shared/VirtualTable.svelte +1 -1
  57. package/standalone/Index.svelte +16 -15
@@ -1,59 +1,100 @@
1
- <script>import { createEventDispatcher } from "svelte";
2
- import { MarkdownCode } from "@gradio/markdown-code";
3
- import SelectionButtons from "./icons/SelectionButtons.svelte";
4
- import BooleanCell from "./BooleanCell.svelte";
5
- export let edit;
6
- export let value = "";
7
- export let display_value = null;
8
- export let styling = "";
9
- export let header = false;
10
- export let datatype = "str";
11
- export let latex_delimiters;
12
- export let line_breaks = true;
13
- export let editable = true;
14
- export let is_static = false;
15
- export let max_chars = null;
16
- export let components = {};
17
- export let i18n;
18
- export let is_dragging = false;
19
- export let wrap_text = false;
20
- export let show_selection_buttons = false;
21
- export let coords;
22
- export let on_select_column = null;
23
- export let on_select_row = null;
24
- export let el;
25
- const dispatch = createEventDispatcher();
26
- function truncate_text(text, max_length = null, is_image = false) {
27
- if (is_image) return String(text);
28
- const str = String(text);
29
- if (!max_length || max_length <= 0) return str;
30
- if (str.length <= max_length) return str;
31
- return str.slice(0, max_length) + "...";
32
- }
33
- $: should_truncate = !edit && max_chars !== null && max_chars > 0;
34
- $: display_content = editable ? value : display_value !== null ? display_value : value;
35
- $: display_text = should_truncate ? truncate_text(display_content, max_chars, datatype === "image") : display_content;
36
- function use_focus(node) {
37
- requestAnimationFrame(() => {
38
- node.focus();
39
- });
40
- return {};
41
- }
42
- function handle_blur(event) {
43
- dispatch("blur", {
44
- blur_event: event,
45
- coords
46
- });
47
- }
48
- function handle_keydown(event) {
49
- dispatch("keydown", event);
50
- }
51
- function commit_change(checked) {
52
- handle_blur({ target: { value } });
53
- }
54
- $: if (!edit) {
55
- handle_blur({ target: { value } });
56
- }
1
+ <script lang="ts">
2
+ import { createEventDispatcher } from "svelte";
3
+ import { MarkdownCode } from "@gradio/markdown-code";
4
+ import type { I18nFormatter } from "@gradio/utils";
5
+ import type { CellValue } from "./types";
6
+ import SelectionButtons from "./icons/SelectionButtons.svelte";
7
+ import BooleanCell from "./BooleanCell.svelte";
8
+
9
+ export let edit: boolean;
10
+ export let value: CellValue = "";
11
+ export let display_value: string | null = null;
12
+ export let styling = "";
13
+ export let header = false;
14
+ export let datatype:
15
+ | "str"
16
+ | "markdown"
17
+ | "html"
18
+ | "number"
19
+ | "bool"
20
+ | "date"
21
+ | "image" = "str";
22
+ export let latex_delimiters: {
23
+ left: string;
24
+ right: string;
25
+ display: boolean;
26
+ }[];
27
+ export let line_breaks = true;
28
+ export let editable = true;
29
+ export let is_static = false;
30
+ export let max_chars: number | null = null;
31
+ export let components: Record<string, any> = {};
32
+ export let i18n: I18nFormatter;
33
+ export let is_dragging = false;
34
+ export let wrap_text = false;
35
+
36
+ export let show_selection_buttons = false;
37
+ export let coords: [number, number];
38
+ export let on_select_column: ((col: number) => void) | null = null;
39
+ export let on_select_row: ((row: number) => void) | null = null;
40
+ export let el: HTMLTextAreaElement | null;
41
+
42
+ const dispatch = createEventDispatcher<{
43
+ blur: { blur_event: FocusEvent; coords: [number, number] };
44
+ keydown: KeyboardEvent;
45
+ }>();
46
+
47
+ function truncate_text(
48
+ text: CellValue,
49
+ max_length: number | null = null,
50
+ is_image = false
51
+ ): string {
52
+ if (is_image) return String(text);
53
+ const str = String(text);
54
+ if (!max_length || max_length <= 0) return str;
55
+ if (str.length <= max_length) return str;
56
+ return str.slice(0, max_length) + "...";
57
+ }
58
+
59
+ $: should_truncate = !edit && max_chars !== null && max_chars > 0;
60
+
61
+ $: display_content = editable
62
+ ? value
63
+ : display_value !== null
64
+ ? display_value
65
+ : value;
66
+
67
+ $: display_text = should_truncate
68
+ ? truncate_text(display_content, max_chars, datatype === "image")
69
+ : display_content;
70
+
71
+ function use_focus(node: HTMLTextAreaElement): any {
72
+ requestAnimationFrame(() => {
73
+ node.focus();
74
+ });
75
+
76
+ return {};
77
+ }
78
+
79
+ function handle_blur(event: FocusEvent): void {
80
+ dispatch("blur", {
81
+ blur_event: event,
82
+ coords: coords
83
+ });
84
+ }
85
+
86
+ function handle_keydown(event: KeyboardEvent): void {
87
+ dispatch("keydown", event);
88
+ }
89
+
90
+ function commit_change(checked: boolean): void {
91
+ handle_blur({ target: { value } } as unknown as FocusEvent);
92
+ }
93
+
94
+ $: if (!edit) {
95
+ // Shim blur on removal for Safari and Firefox
96
+ handle_blur({ target: { value } } as unknown as FocusEvent);
97
+ }
57
98
  </script>
58
99
 
59
100
  {#if edit && datatype !== "bool"}
@@ -1,52 +1,54 @@
1
- import { SvelteComponent } from "svelte";
2
1
  import type { I18nFormatter } from "@gradio/utils";
3
2
  import type { CellValue } from "./types";
4
- declare const __propDef: {
5
- props: {
6
- edit: boolean;
7
- value?: CellValue;
8
- display_value?: string | null;
9
- styling?: string;
10
- header?: boolean;
11
- datatype?: "str" | "markdown" | "html" | "number" | "bool" | "date" | "image";
12
- latex_delimiters: {
13
- left: string;
14
- right: string;
15
- display: boolean;
16
- }[];
17
- line_breaks?: boolean;
18
- editable?: boolean;
19
- is_static?: boolean;
20
- max_chars?: number | null;
21
- components?: Record<string, any>;
22
- i18n: I18nFormatter;
23
- is_dragging?: boolean;
24
- wrap_text?: boolean;
25
- show_selection_buttons?: boolean;
26
- coords: [number, number];
27
- on_select_column?: ((col: number) => void) | null;
28
- on_select_row?: ((row: number) => void) | null;
29
- el: HTMLTextAreaElement | null;
30
- };
31
- events: {
32
- mousedown: MouseEvent;
33
- click: MouseEvent;
34
- focus: FocusEvent;
35
- blur: CustomEvent<{
36
- blur_event: FocusEvent;
37
- coords: [number, number];
38
- }>;
39
- keydown: CustomEvent<KeyboardEvent>;
40
- } & {
41
- [evt: string]: CustomEvent<any>;
3
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
4
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
5
+ $$bindings?: Bindings;
6
+ } & Exports;
7
+ (internal: unknown, props: Props & {
8
+ $$events?: Events;
9
+ $$slots?: Slots;
10
+ }): Exports & {
11
+ $set?: any;
12
+ $on?: any;
42
13
  };
43
- slots: {};
44
- exports?: {} | undefined;
45
- bindings?: string | undefined;
46
- };
47
- export type EditableCellProps = typeof __propDef.props;
48
- export type EditableCellEvents = typeof __propDef.events;
49
- export type EditableCellSlots = typeof __propDef.slots;
50
- export default class EditableCell extends SvelteComponent<EditableCellProps, EditableCellEvents, EditableCellSlots> {
14
+ z_$$bindings?: Bindings;
51
15
  }
52
- export {};
16
+ declare const EditableCell: $$__sveltets_2_IsomorphicComponent<{
17
+ edit: boolean;
18
+ value?: CellValue;
19
+ display_value?: string | null;
20
+ styling?: string;
21
+ header?: boolean;
22
+ datatype?: "str" | "markdown" | "html" | "number" | "bool" | "date" | "image";
23
+ latex_delimiters: {
24
+ left: string;
25
+ right: string;
26
+ display: boolean;
27
+ }[];
28
+ line_breaks?: boolean;
29
+ editable?: boolean;
30
+ is_static?: boolean;
31
+ max_chars?: number | null;
32
+ components?: Record<string, any>;
33
+ i18n: I18nFormatter;
34
+ is_dragging?: boolean;
35
+ wrap_text?: boolean;
36
+ show_selection_buttons?: boolean;
37
+ coords: [number, number];
38
+ on_select_column?: ((col: number) => void) | null;
39
+ on_select_row?: ((row: number) => void) | null;
40
+ el: HTMLTextAreaElement | null;
41
+ }, {
42
+ mousedown: MouseEvent;
43
+ click: PointerEvent;
44
+ focus: FocusEvent;
45
+ blur: CustomEvent<{
46
+ blur_event: FocusEvent;
47
+ coords: [number, number];
48
+ }>;
49
+ keydown: CustomEvent<KeyboardEvent>;
50
+ } & {
51
+ [evt: string]: CustomEvent<any>;
52
+ }, {}, {}, string>;
53
+ type EditableCell = InstanceType<typeof EditableCell>;
54
+ export default EditableCell;
@@ -1,4 +1,5 @@
1
- <script>export let on_click;
1
+ <script lang="ts">
2
+ export let on_click: () => void;
2
3
  </script>
3
4
 
4
5
  <button class="add-row-button" on:click={on_click} aria-label="Add row">
@@ -1,18 +1,20 @@
1
- import { SvelteComponent } from "svelte";
2
- declare const __propDef: {
3
- props: {
4
- on_click: () => void;
1
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
2
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
+ $$bindings?: Bindings;
4
+ } & Exports;
5
+ (internal: unknown, props: Props & {
6
+ $$events?: Events;
7
+ $$slots?: Slots;
8
+ }): Exports & {
9
+ $set?: any;
10
+ $on?: any;
5
11
  };
6
- events: {
7
- [evt: string]: CustomEvent<any>;
8
- };
9
- slots: {};
10
- exports?: {} | undefined;
11
- bindings?: string | undefined;
12
- };
13
- export type EmptyRowButtonProps = typeof __propDef.props;
14
- export type EmptyRowButtonEvents = typeof __propDef.events;
15
- export type EmptyRowButtonSlots = typeof __propDef.slots;
16
- export default class EmptyRowButton extends SvelteComponent<EmptyRowButtonProps, EmptyRowButtonEvents, EmptyRowButtonSlots> {
12
+ z_$$bindings?: Bindings;
17
13
  }
18
- export {};
14
+ declare const EmptyRowButton: $$__sveltets_2_IsomorphicComponent<{
15
+ on_click: () => void;
16
+ }, {
17
+ [evt: string]: CustomEvent<any>;
18
+ }, {}, {}, string>;
19
+ type EmptyRowButton = InstanceType<typeof EmptyRowButton>;
20
+ export default EmptyRowButton;
@@ -1,4 +1,5 @@
1
- <script>export let value;
1
+ <script lang="ts">
2
+ export let value: (string | number)[][];
2
3
  </script>
3
4
 
4
5
  <table class="input-dataframe-example">
@@ -1,18 +1,20 @@
1
- import { SvelteComponent } from "svelte";
2
- declare const __propDef: {
3
- props: {
4
- value: (string | number)[][];
1
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
2
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
+ $$bindings?: Bindings;
4
+ } & Exports;
5
+ (internal: unknown, props: Props & {
6
+ $$events?: Events;
7
+ $$slots?: Slots;
8
+ }): Exports & {
9
+ $set?: any;
10
+ $on?: any;
5
11
  };
6
- events: {
7
- [evt: string]: CustomEvent<any>;
8
- };
9
- slots: {};
10
- exports?: {} | undefined;
11
- bindings?: string | undefined;
12
- };
13
- export type ExampleProps = typeof __propDef.props;
14
- export type ExampleEvents = typeof __propDef.events;
15
- export type ExampleSlots = typeof __propDef.slots;
16
- export default class Example extends SvelteComponent<ExampleProps, ExampleEvents, ExampleSlots> {
12
+ z_$$bindings?: Bindings;
17
13
  }
18
- export {};
14
+ declare const Example: $$__sveltets_2_IsomorphicComponent<{
15
+ value: (string | number)[][];
16
+ }, {
17
+ [evt: string]: CustomEvent<any>;
18
+ }, {}, {}, string>;
19
+ type Example = InstanceType<typeof Example>;
20
+ export default Example;
@@ -1,42 +1,56 @@
1
- <script>import { onMount } from "svelte";
2
- import { Check, DropdownArrow } from "@gradio/icons";
3
- export let on_filter = () => {
4
- };
5
- let menu_element;
6
- let datatype = "string";
7
- let current_filter = "Contains";
8
- let filter_dropdown_open = false;
9
- let filter_input_value = "";
10
- const filter_options = {
11
- string: [
12
- "Contains",
13
- "Does not contain",
14
- "Starts with",
15
- "Ends with",
16
- "Is",
17
- "Is not",
18
- "Is empty",
19
- "Is not empty"
20
- ],
21
- number: ["=", "\u2260", ">", "<", "\u2265", "\u2264", "Is empty", "Is not empty"]
22
- };
23
- onMount(() => {
24
- position_menu();
25
- });
26
- function position_menu() {
27
- if (!menu_element) return;
28
- const viewport_width = window.innerWidth;
29
- const viewport_height = window.innerHeight;
30
- const menu_rect = menu_element.getBoundingClientRect();
31
- const x = (viewport_width - menu_rect.width) / 2;
32
- const y = (viewport_height - menu_rect.height) / 2;
33
- menu_element.style.left = `${x}px`;
34
- menu_element.style.top = `${y}px`;
35
- }
36
- function handle_filter_input(e) {
37
- const target = e.target;
38
- filter_input_value = target.value;
39
- }
1
+ <script lang="ts">
2
+ import { onMount } from "svelte";
3
+ import { Check, DropdownArrow } from "@gradio/icons";
4
+ import type { FilterDatatype } from "./context/dataframe_context";
5
+
6
+ export let on_filter: (
7
+ datatype: FilterDatatype,
8
+ selected_filter: string,
9
+ value: string
10
+ ) => void = () => {};
11
+
12
+ let menu_element: HTMLDivElement;
13
+ let datatype: "string" | "number" = "string";
14
+ let current_filter = "Contains";
15
+ let filter_dropdown_open = false;
16
+ let filter_input_value = "";
17
+
18
+ const filter_options = {
19
+ string: [
20
+ "Contains",
21
+ "Does not contain",
22
+ "Starts with",
23
+ "Ends with",
24
+ "Is",
25
+ "Is not",
26
+ "Is empty",
27
+ "Is not empty"
28
+ ],
29
+ number: ["=", "≠", ">", "<", "≥", "≤", "Is empty", "Is not empty"]
30
+ };
31
+
32
+ onMount(() => {
33
+ position_menu();
34
+ });
35
+
36
+ function position_menu(): void {
37
+ if (!menu_element) return;
38
+
39
+ const viewport_width = window.innerWidth;
40
+ const viewport_height = window.innerHeight;
41
+ const menu_rect = menu_element.getBoundingClientRect();
42
+
43
+ const x = (viewport_width - menu_rect.width) / 2;
44
+ const y = (viewport_height - menu_rect.height) / 2;
45
+
46
+ menu_element.style.left = `${x}px`;
47
+ menu_element.style.top = `${y}px`;
48
+ }
49
+
50
+ function handle_filter_input(e: Event): void {
51
+ const target = e.target as HTMLInputElement;
52
+ filter_input_value = target.value;
53
+ }
40
54
  </script>
41
55
 
42
56
  <div>
@@ -1,21 +1,23 @@
1
- import { SvelteComponent } from "svelte";
2
1
  import type { FilterDatatype } from "./context/dataframe_context";
3
- declare const __propDef: {
4
- props: {
5
- on_filter?: (datatype: FilterDatatype, selected_filter: string, value: string) => void;
2
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
3
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
4
+ $$bindings?: Bindings;
5
+ } & Exports;
6
+ (internal: unknown, props: Props & {
7
+ $$events?: Events;
8
+ $$slots?: Slots;
9
+ }): Exports & {
10
+ $set?: any;
11
+ $on?: any;
6
12
  };
7
- events: {
8
- click: MouseEvent;
9
- } & {
10
- [evt: string]: CustomEvent<any>;
11
- };
12
- slots: {};
13
- exports?: {} | undefined;
14
- bindings?: string | undefined;
15
- };
16
- export type FilterMenuProps = typeof __propDef.props;
17
- export type FilterMenuEvents = typeof __propDef.events;
18
- export type FilterMenuSlots = typeof __propDef.slots;
19
- export default class FilterMenu extends SvelteComponent<FilterMenuProps, FilterMenuEvents, FilterMenuSlots> {
13
+ z_$$bindings?: Bindings;
20
14
  }
21
- export {};
15
+ declare const FilterMenu: $$__sveltets_2_IsomorphicComponent<{
16
+ on_filter?: (datatype: FilterDatatype, selected_filter: string, value: string) => void;
17
+ }, {
18
+ click: PointerEvent;
19
+ } & {
20
+ [evt: string]: CustomEvent<any>;
21
+ }, {}, {}, string>;
22
+ type FilterMenu = InstanceType<typeof FilterMenu>;
23
+ export default FilterMenu;
@@ -1,5 +1,6 @@
1
- <script>export let index = null;
2
- export let is_header = false;
1
+ <script lang="ts">
2
+ export let index: number | null = null;
3
+ export let is_header = false;
3
4
  </script>
4
5
 
5
6
  {#if is_header}
@@ -1,19 +1,21 @@
1
- import { SvelteComponent } from "svelte";
2
- declare const __propDef: {
3
- props: {
4
- index?: number | null;
5
- is_header?: boolean;
1
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
2
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
+ $$bindings?: Bindings;
4
+ } & Exports;
5
+ (internal: unknown, props: Props & {
6
+ $$events?: Events;
7
+ $$slots?: Slots;
8
+ }): Exports & {
9
+ $set?: any;
10
+ $on?: any;
6
11
  };
7
- events: {
8
- [evt: string]: CustomEvent<any>;
9
- };
10
- slots: {};
11
- exports?: {} | undefined;
12
- bindings?: string | undefined;
13
- };
14
- export type RowNumberProps = typeof __propDef.props;
15
- export type RowNumberEvents = typeof __propDef.events;
16
- export type RowNumberSlots = typeof __propDef.slots;
17
- export default class RowNumber extends SvelteComponent<RowNumberProps, RowNumberEvents, RowNumberSlots> {
12
+ z_$$bindings?: Bindings;
18
13
  }
19
- export {};
14
+ declare const RowNumber: $$__sveltets_2_IsomorphicComponent<{
15
+ index?: number | null;
16
+ is_header?: boolean;
17
+ }, {
18
+ [evt: string]: CustomEvent<any>;
19
+ }, {}, {}, string>;
20
+ type RowNumber = InstanceType<typeof RowNumber>;
21
+ export default RowNumber;