@gradio/dataframe 0.20.1 → 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 (58) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/Dataframe.stories.svelte +0 -25
  3. package/Example.svelte +17 -13
  4. package/Index.svelte +114 -110
  5. package/dist/Example.svelte +26 -20
  6. package/dist/Example.svelte.d.ts +21 -19
  7. package/dist/Index.svelte +121 -99
  8. package/dist/Index.svelte.d.ts +4 -168
  9. package/dist/shared/BooleanCell.svelte +12 -9
  10. package/dist/shared/BooleanCell.svelte.d.ts +20 -18
  11. package/dist/shared/CellMenu.svelte +82 -64
  12. package/dist/shared/CellMenu.svelte.d.ts +39 -37
  13. package/dist/shared/CellMenuButton.svelte +2 -1
  14. package/dist/shared/CellMenuButton.svelte.d.ts +18 -16
  15. package/dist/shared/CellMenuIcons.svelte +2 -1
  16. package/dist/shared/CellMenuIcons.svelte.d.ts +18 -16
  17. package/dist/shared/EditableCell.svelte +97 -56
  18. package/dist/shared/EditableCell.svelte.d.ts +50 -48
  19. package/dist/shared/EmptyRowButton.svelte +2 -1
  20. package/dist/shared/EmptyRowButton.svelte.d.ts +18 -16
  21. package/dist/shared/Example.svelte +2 -1
  22. package/dist/shared/Example.svelte.d.ts +18 -16
  23. package/dist/shared/FilterMenu.svelte +53 -39
  24. package/dist/shared/FilterMenu.svelte.d.ts +20 -18
  25. package/dist/shared/RowNumber.svelte +3 -2
  26. package/dist/shared/RowNumber.svelte.d.ts +19 -17
  27. package/dist/shared/Table.svelte +826 -624
  28. package/dist/shared/Table.svelte.d.ts +59 -57
  29. package/dist/shared/TableCell.svelte +95 -50
  30. package/dist/shared/TableCell.svelte.d.ts +61 -59
  31. package/dist/shared/TableHeader.svelte +86 -58
  32. package/dist/shared/TableHeader.svelte.d.ts +55 -53
  33. package/dist/shared/Toolbar.svelte +49 -39
  34. package/dist/shared/Toolbar.svelte.d.ts +27 -25
  35. package/dist/shared/VirtualTable.svelte +207 -154
  36. package/dist/shared/VirtualTable.svelte.d.ts +40 -37
  37. package/dist/shared/icons/FilterIcon.svelte +2 -1
  38. package/dist/shared/icons/FilterIcon.svelte.d.ts +16 -14
  39. package/dist/shared/icons/Padlock.svelte.d.ts +22 -21
  40. package/dist/shared/icons/SelectionButtons.svelte +15 -5
  41. package/dist/shared/icons/SelectionButtons.svelte.d.ts +20 -18
  42. package/dist/shared/icons/SortArrowDown.svelte +2 -1
  43. package/dist/shared/icons/SortArrowDown.svelte.d.ts +18 -16
  44. package/dist/shared/icons/SortArrowUp.svelte +2 -1
  45. package/dist/shared/icons/SortArrowUp.svelte.d.ts +18 -16
  46. package/dist/shared/icons/SortButtonDown.svelte.d.ts +22 -21
  47. package/dist/shared/icons/SortButtonUp.svelte.d.ts +22 -21
  48. package/dist/shared/icons/SortIcon.svelte +12 -8
  49. package/dist/shared/icons/SortIcon.svelte.d.ts +22 -20
  50. package/dist/shared/utils/data_processing.d.ts +1 -1
  51. package/dist/standalone/Index.svelte +104 -78
  52. package/dist/standalone/Index.svelte.d.ts +41 -41
  53. package/dist/standalone/stubs/Upload.svelte +5 -4
  54. package/dist/standalone/stubs/Upload.svelte.d.ts +35 -25
  55. package/package.json +15 -14
  56. package/shared/Table.svelte +13 -11
  57. package/shared/VirtualTable.svelte +1 -1
  58. package/standalone/Index.svelte +17 -19
@@ -1,41 +1,43 @@
1
- import { SvelteComponent } from "svelte";
2
1
  import type { I18nFormatter } from "@gradio/utils";
3
2
  import type { SortDirection, FilterDatatype } from "./context/dataframe_context";
4
- declare const __propDef: {
5
- props: {
6
- x: number;
7
- y: number;
8
- on_add_row_above: () => void;
9
- on_add_row_below: () => void;
10
- on_add_column_left: () => void;
11
- on_add_column_right: () => void;
12
- row: number;
13
- col_count: [number, "fixed" | "dynamic"];
14
- row_count: [number, "fixed" | "dynamic"];
15
- on_delete_row: () => void;
16
- on_delete_col: () => void;
17
- can_delete_rows: boolean;
18
- can_delete_cols: boolean;
19
- on_sort?: (direction: SortDirection) => void;
20
- on_clear_sort?: () => void;
21
- sort_direction?: SortDirection | null;
22
- sort_priority?: number | null;
23
- on_filter?: (datatype: FilterDatatype, selected_filter: string, value: string) => void;
24
- on_clear_filter?: () => void;
25
- filter_active?: boolean | null;
26
- editable?: boolean;
27
- i18n: I18nFormatter;
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;
28
13
  };
29
- events: {
30
- [evt: string]: CustomEvent<any>;
31
- };
32
- slots: {};
33
- exports?: {} | undefined;
34
- bindings?: string | undefined;
35
- };
36
- export type CellMenuProps = typeof __propDef.props;
37
- export type CellMenuEvents = typeof __propDef.events;
38
- export type CellMenuSlots = typeof __propDef.slots;
39
- export default class CellMenu extends SvelteComponent<CellMenuProps, CellMenuEvents, CellMenuSlots> {
14
+ z_$$bindings?: Bindings;
40
15
  }
41
- export {};
16
+ declare const CellMenu: $$__sveltets_2_IsomorphicComponent<{
17
+ x: number;
18
+ y: number;
19
+ on_add_row_above: () => void;
20
+ on_add_row_below: () => void;
21
+ on_add_column_left: () => void;
22
+ on_add_column_right: () => void;
23
+ row: number;
24
+ col_count: [number, "fixed" | "dynamic"];
25
+ row_count: [number, "fixed" | "dynamic"];
26
+ on_delete_row: () => void;
27
+ on_delete_col: () => void;
28
+ can_delete_rows: boolean;
29
+ can_delete_cols: boolean;
30
+ on_sort?: (direction: SortDirection) => void;
31
+ on_clear_sort?: () => void;
32
+ sort_direction?: SortDirection | null;
33
+ sort_priority?: number | null;
34
+ on_filter?: (datatype: FilterDatatype, selected_filter: string, value: string) => void;
35
+ on_clear_filter?: () => void;
36
+ filter_active?: boolean | null;
37
+ editable?: boolean;
38
+ i18n: I18nFormatter;
39
+ }, {
40
+ [evt: string]: CustomEvent<any>;
41
+ }, {}, {}, string>;
42
+ type CellMenu = InstanceType<typeof CellMenu>;
43
+ export default CellMenu;
@@ -1,4 +1,5 @@
1
- <script>export let on_click;
1
+ <script lang="ts">
2
+ export let on_click: (event: MouseEvent) => void;
2
3
  </script>
3
4
 
4
5
  <button
@@ -1,18 +1,20 @@
1
- import { SvelteComponent } from "svelte";
2
- declare const __propDef: {
3
- props: {
4
- on_click: (event: MouseEvent) => 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 CellMenuButtonProps = typeof __propDef.props;
14
- export type CellMenuButtonEvents = typeof __propDef.events;
15
- export type CellMenuButtonSlots = typeof __propDef.slots;
16
- export default class CellMenuButton extends SvelteComponent<CellMenuButtonProps, CellMenuButtonEvents, CellMenuButtonSlots> {
12
+ z_$$bindings?: Bindings;
17
13
  }
18
- export {};
14
+ declare const CellMenuButton: $$__sveltets_2_IsomorphicComponent<{
15
+ on_click: (event: MouseEvent) => void;
16
+ }, {
17
+ [evt: string]: CustomEvent<any>;
18
+ }, {}, {}, string>;
19
+ type CellMenuButton = InstanceType<typeof CellMenuButton>;
20
+ export default CellMenuButton;
@@ -1,4 +1,5 @@
1
- <script>export let icon;
1
+ <script lang="ts">
2
+ export let icon: string;
2
3
  </script>
3
4
 
4
5
  {#if icon == "add-column-right"}
@@ -1,18 +1,20 @@
1
- import { SvelteComponent } from "svelte";
2
- declare const __propDef: {
3
- props: {
4
- icon: string;
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 CellMenuIconsProps = typeof __propDef.props;
14
- export type CellMenuIconsEvents = typeof __propDef.events;
15
- export type CellMenuIconsSlots = typeof __propDef.slots;
16
- export default class CellMenuIcons extends SvelteComponent<CellMenuIconsProps, CellMenuIconsEvents, CellMenuIconsSlots> {
12
+ z_$$bindings?: Bindings;
17
13
  }
18
- export {};
14
+ declare const CellMenuIcons: $$__sveltets_2_IsomorphicComponent<{
15
+ icon: string;
16
+ }, {
17
+ [evt: string]: CustomEvent<any>;
18
+ }, {}, {}, string>;
19
+ type CellMenuIcons = InstanceType<typeof CellMenuIcons>;
20
+ export default CellMenuIcons;
@@ -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>