@gradio/dataframe 0.22.0 → 0.23.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.
Files changed (128) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/Dataframe.test.ts +697 -32
  3. package/Index.svelte +107 -106
  4. package/dist/Index.svelte +107 -106
  5. package/dist/Index.svelte.d.ts +0 -1
  6. package/dist/shared/BooleanCell.svelte +12 -6
  7. package/dist/shared/BooleanCell.svelte.d.ts +4 -18
  8. package/dist/shared/CellMenu.svelte +74 -49
  9. package/dist/shared/CellMenu.svelte.d.ts +5 -19
  10. package/dist/shared/CellMenuButton.svelte +3 -3
  11. package/dist/shared/CellMenuButton.svelte.d.ts +4 -18
  12. package/dist/shared/CellMenuIcons.svelte +1 -1
  13. package/dist/shared/CellMenuIcons.svelte.d.ts +4 -18
  14. package/dist/shared/DataCell.svelte +189 -0
  15. package/dist/shared/DataCell.svelte.d.ts +44 -0
  16. package/dist/shared/EditableCell.svelte +88 -64
  17. package/dist/shared/EditableCell.svelte.d.ts +8 -26
  18. package/dist/shared/EmptyRowButton.svelte +2 -2
  19. package/dist/shared/EmptyRowButton.svelte.d.ts +4 -18
  20. package/dist/shared/FilterMenu.svelte +26 -18
  21. package/dist/shared/FilterMenu.svelte.d.ts +5 -21
  22. package/dist/shared/HeaderCell.svelte +218 -0
  23. package/dist/shared/HeaderCell.svelte.d.ts +30 -0
  24. package/dist/shared/RowNumber.svelte +4 -2
  25. package/dist/shared/RowNumber.svelte.d.ts +4 -18
  26. package/dist/shared/Table.svelte +1037 -949
  27. package/dist/shared/Table.svelte.d.ts +12 -30
  28. package/dist/shared/Toolbar.svelte +32 -22
  29. package/dist/shared/Toolbar.svelte.d.ts +6 -21
  30. package/dist/shared/column_measurement.svelte.d.ts +20 -0
  31. package/dist/shared/column_measurement.svelte.js +79 -0
  32. package/dist/shared/icons/FilterIcon.svelte +14 -6
  33. package/dist/shared/icons/FilterIcon.svelte.d.ts +14 -6
  34. package/dist/shared/icons/Padlock.svelte +6 -2
  35. package/dist/shared/icons/Padlock.svelte.d.ts +4 -25
  36. package/dist/shared/icons/SelectionButtons.svelte +23 -8
  37. package/dist/shared/icons/SelectionButtons.svelte.d.ts +4 -18
  38. package/dist/shared/icons/SortButtonDown.svelte +15 -4
  39. package/dist/shared/icons/SortButtonDown.svelte.d.ts +4 -25
  40. package/dist/shared/icons/SortButtonUp.svelte +15 -5
  41. package/dist/shared/icons/SortButtonUp.svelte.d.ts +4 -25
  42. package/dist/shared/icons/SortIcon.svelte +13 -7
  43. package/dist/shared/icons/SortIcon.svelte.d.ts +7 -21
  44. package/dist/shared/tanstack/index.d.ts +3 -0
  45. package/dist/shared/tanstack/index.js +3 -0
  46. package/dist/shared/tanstack/table.svelte.d.ts +26 -0
  47. package/dist/shared/tanstack/table.svelte.js +102 -0
  48. package/dist/shared/tanstack/virtual.svelte.d.ts +14 -0
  49. package/dist/shared/tanstack/virtual.svelte.js +76 -0
  50. package/dist/shared/types.d.ts +2 -0
  51. package/dist/shared/utils/filter.d.ts +5 -0
  52. package/dist/shared/utils/filter.js +62 -0
  53. package/dist/shared/utils/selection_utils.js +1 -1
  54. package/dist/shared/utils/table_utils.d.ts +1 -14
  55. package/dist/shared/utils/table_utils.js +0 -61
  56. package/dist/standalone/Index.svelte +71 -46
  57. package/dist/standalone/Index.svelte.d.ts +4 -23
  58. package/dist/types.d.ts +32 -0
  59. package/dist/types.js +1 -0
  60. package/package.json +10 -9
  61. package/shared/BooleanCell.svelte +12 -6
  62. package/shared/CellMenu.svelte +74 -49
  63. package/shared/CellMenuButton.svelte +3 -3
  64. package/shared/CellMenuIcons.svelte +1 -1
  65. package/shared/DataCell.svelte +189 -0
  66. package/shared/EditableCell.svelte +88 -64
  67. package/shared/EmptyRowButton.svelte +2 -2
  68. package/shared/FilterMenu.svelte +26 -18
  69. package/shared/HeaderCell.svelte +218 -0
  70. package/shared/RowNumber.svelte +4 -2
  71. package/shared/Table.svelte +1037 -949
  72. package/shared/Toolbar.svelte +32 -22
  73. package/shared/column_measurement.svelte.ts +103 -0
  74. package/shared/icons/FilterIcon.svelte +14 -6
  75. package/shared/icons/Padlock.svelte +6 -2
  76. package/shared/icons/SelectionButtons.svelte +23 -8
  77. package/shared/icons/SortButtonDown.svelte +15 -4
  78. package/shared/icons/SortButtonUp.svelte +15 -5
  79. package/shared/icons/SortIcon.svelte +13 -7
  80. package/shared/tanstack/index.ts +23 -0
  81. package/shared/tanstack/table.svelte.ts +117 -0
  82. package/shared/tanstack/virtual.svelte.ts +105 -0
  83. package/shared/types.ts +3 -0
  84. package/shared/utils/filter.ts +66 -0
  85. package/shared/utils/selection_utils.ts +1 -1
  86. package/shared/utils/table_utils.ts +1 -100
  87. package/standalone/Index.svelte +71 -46
  88. package/test/filter.test.ts +350 -0
  89. package/test/selection_utils.test.ts +416 -0
  90. package/test/table_utils.test.ts +45 -112
  91. package/types.ts +34 -0
  92. package/dist/shared/TableCell.svelte +0 -330
  93. package/dist/shared/TableCell.svelte.d.ts +0 -66
  94. package/dist/shared/TableHeader.svelte +0 -344
  95. package/dist/shared/TableHeader.svelte.d.ts +0 -61
  96. package/dist/shared/VirtualTable.svelte +0 -379
  97. package/dist/shared/VirtualTable.svelte.d.ts +0 -42
  98. package/dist/shared/context/dataframe_context.d.ts +0 -180
  99. package/dist/shared/context/dataframe_context.js +0 -412
  100. package/dist/shared/icons/SortArrowDown.svelte +0 -25
  101. package/dist/shared/icons/SortArrowDown.svelte.d.ts +0 -20
  102. package/dist/shared/icons/SortArrowUp.svelte +0 -25
  103. package/dist/shared/icons/SortArrowUp.svelte.d.ts +0 -20
  104. package/dist/shared/utils/data_processing.d.ts +0 -14
  105. package/dist/shared/utils/data_processing.js +0 -47
  106. package/dist/shared/utils/drag_utils.d.ts +0 -15
  107. package/dist/shared/utils/drag_utils.js +0 -67
  108. package/dist/shared/utils/filter_utils.d.ts +0 -29
  109. package/dist/shared/utils/filter_utils.js +0 -123
  110. package/dist/shared/utils/keyboard_utils.d.ts +0 -3
  111. package/dist/shared/utils/keyboard_utils.js +0 -236
  112. package/dist/shared/utils/menu_utils.d.ts +0 -42
  113. package/dist/shared/utils/menu_utils.js +0 -58
  114. package/dist/shared/utils/sort_utils.d.ts +0 -26
  115. package/dist/shared/utils/sort_utils.js +0 -59
  116. package/shared/TableCell.svelte +0 -330
  117. package/shared/TableHeader.svelte +0 -344
  118. package/shared/VirtualTable.svelte +0 -379
  119. package/shared/context/dataframe_context.ts +0 -701
  120. package/shared/icons/SortArrowDown.svelte +0 -25
  121. package/shared/icons/SortArrowUp.svelte +0 -25
  122. package/shared/utils/data_processing.ts +0 -77
  123. package/shared/utils/drag_utils.ts +0 -105
  124. package/shared/utils/filter_utils.ts +0 -208
  125. package/shared/utils/keyboard_utils.ts +0 -309
  126. package/shared/utils/menu_utils.ts +0 -115
  127. package/shared/utils/sort_utils.ts +0 -91
  128. package/test/sort_utils.test.ts +0 -323
@@ -1,379 +0,0 @@
1
- <script lang="ts">
2
- import { onMount, tick, createEventDispatcher } from "svelte";
3
-
4
- export let items: any[][] = [];
5
-
6
- export let max_height: number;
7
- export let actual_height: number;
8
- export let table_scrollbar_width: number;
9
- export let start = 0;
10
- export let end = 20;
11
- export let selected: number | false;
12
- export let disable_scroll = false;
13
- export let show_scroll_button = false;
14
- export let viewport: HTMLTableElement;
15
- export let label: string | null = null;
16
-
17
- const dispatch = createEventDispatcher<{
18
- scroll_top: number;
19
- }>();
20
-
21
- let height = "100%";
22
-
23
- let average_height = 30;
24
- let bottom = 0;
25
- let contents: HTMLTableSectionElement;
26
- let head_height = 0;
27
- let foot_height = 0;
28
- let height_map: number[] = [];
29
- let mounted: boolean;
30
- let rows: HTMLCollectionOf<HTMLTableRowElement>;
31
- let top = 0;
32
- let viewport_height = 200;
33
- let visible: { index: number; data: any[] }[] = [];
34
- let viewport_box: DOMRectReadOnly;
35
-
36
- $: viewport_height = viewport_box?.height || 200;
37
-
38
- const is_browser = typeof window !== "undefined";
39
- const raf = is_browser
40
- ? window.requestAnimationFrame
41
- : (cb: (...args: any[]) => void) => cb();
42
-
43
- $: {
44
- if (mounted && viewport_height && viewport.offsetParent) {
45
- (sortedItems, raf(refresh_height_map));
46
- }
47
- }
48
-
49
- async function refresh_height_map(): Promise<void> {
50
- if (!viewport) {
51
- return;
52
- }
53
-
54
- if (sortedItems.length < start) {
55
- await scroll_to_index(sortedItems.length - 1, { behavior: "auto" });
56
- }
57
-
58
- const scrollTop = Math.max(0, viewport.scrollTop);
59
- show_scroll_button = scrollTop > 100;
60
- table_scrollbar_width = viewport.offsetWidth - viewport.clientWidth;
61
-
62
- // acquire height map for currently visible rows
63
- for (let v = 0; v < rows.length; v += 1) {
64
- height_map[start + v] = rows[v].getBoundingClientRect().height;
65
- }
66
- let i = 0;
67
- let y = head_height;
68
- // loop items to find new start
69
- while (i < sortedItems.length) {
70
- const row_height = height_map[i] || average_height;
71
- // keep a page of rows buffered above
72
- if (y + row_height > scrollTop - max_height) {
73
- start = i;
74
- top = y - head_height;
75
- break;
76
- }
77
- y += row_height;
78
- i += 1;
79
- }
80
-
81
- let content_height = head_height;
82
- while (i < sortedItems.length) {
83
- const row_height = height_map[i] || average_height;
84
- content_height += row_height;
85
- i += 1;
86
- // keep a page of rows buffered below
87
- if (content_height - head_height > 3 * max_height) {
88
- break;
89
- }
90
- }
91
-
92
- end = i;
93
- const remaining = sortedItems.length - end;
94
-
95
- const scrollbar_height = viewport.offsetHeight - viewport.clientHeight;
96
- if (scrollbar_height > 0) {
97
- content_height += scrollbar_height;
98
- }
99
-
100
- let filtered_height_map = height_map.filter((v) => typeof v === "number");
101
- average_height =
102
- filtered_height_map.reduce((a, b) => a + b, 0) /
103
- filtered_height_map.length || 30;
104
-
105
- bottom = remaining * average_height;
106
- if (!isFinite(bottom)) {
107
- bottom = 200000;
108
- }
109
- height_map.length = sortedItems.length;
110
- while (i < sortedItems.length) {
111
- i += 1;
112
- height_map[i] = average_height;
113
- }
114
- if (max_height && content_height > max_height) {
115
- actual_height = max_height;
116
- } else {
117
- actual_height = content_height;
118
- }
119
- }
120
-
121
- $: scroll_and_render(selected);
122
-
123
- async function scroll_and_render(n: number | false): Promise<void> {
124
- raf(async () => {
125
- if (typeof n !== "number") return;
126
- const direction = typeof n !== "number" ? false : is_in_view(n);
127
- if (direction === true) {
128
- return;
129
- }
130
- if (direction === "back") {
131
- await scroll_to_index(n, { behavior: "instant" });
132
- }
133
-
134
- if (direction === "forwards") {
135
- await scroll_to_index(n, { behavior: "instant" }, true);
136
- }
137
- });
138
- }
139
-
140
- function is_in_view(n: number): "back" | "forwards" | true {
141
- const current = rows && rows[n - start];
142
- if (!current && n < start) {
143
- return "back";
144
- }
145
- if (!current && n >= end - 1) {
146
- return "forwards";
147
- }
148
-
149
- const { top: viewport_top } = viewport.getBoundingClientRect();
150
- const { top, bottom } = current.getBoundingClientRect();
151
-
152
- if (top - viewport_top < 37) {
153
- return "back";
154
- }
155
-
156
- if (bottom - viewport_top > viewport_height) {
157
- return "forwards";
158
- }
159
-
160
- return true;
161
- }
162
-
163
- export async function scroll_to_index(
164
- index: number,
165
- opts: ScrollToOptions,
166
- align_end = false
167
- ): Promise<void> {
168
- await tick();
169
-
170
- const _itemHeight = average_height;
171
-
172
- let distance = index * _itemHeight;
173
- if (align_end) {
174
- distance = distance - viewport_height + _itemHeight + head_height;
175
- }
176
-
177
- const scrollbar_height = viewport.offsetHeight - viewport.clientHeight;
178
- if (scrollbar_height > 0) {
179
- distance += scrollbar_height;
180
- }
181
-
182
- const _opts = {
183
- top: distance,
184
- behavior: "smooth" as ScrollBehavior,
185
- ...opts
186
- };
187
-
188
- viewport.scrollTo(_opts);
189
- }
190
-
191
- $: sortedItems = items;
192
-
193
- $: visible = is_browser
194
- ? sortedItems.slice(start, end).map((data, i) => {
195
- return { index: i + start, data };
196
- })
197
- : sortedItems
198
- .slice(0, (max_height / sortedItems.length) * average_height + 1)
199
- .map((data, i) => {
200
- return { index: i + start, data };
201
- });
202
-
203
- onMount(() => {
204
- rows = contents.children as HTMLCollectionOf<HTMLTableRowElement>;
205
- mounted = true;
206
- });
207
- </script>
208
-
209
- <svelte-virtual-table-viewport>
210
- <div>
211
- <table
212
- class="table"
213
- class:disable-scroll={disable_scroll}
214
- bind:this={viewport}
215
- bind:contentRect={viewport_box}
216
- on:scroll={refresh_height_map}
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"
218
- >
219
- {#if label && label.length !== 0}
220
- <caption class="sr-only">{label}</caption>
221
- {/if}
222
- <thead class="thead" bind:offsetHeight={head_height}>
223
- <slot name="thead" />
224
- </thead>
225
- <tbody bind:this={contents} class="tbody">
226
- {#if visible.length && visible[0].data.length}
227
- {#each visible as item (item.data[0].id)}
228
- <slot name="tbody" item={item.data} index={item.index}>
229
- <tr>
230
- <td>Missing Table Row</td>
231
- </tr>
232
- </slot>
233
- {/each}
234
- {/if}
235
- </tbody>
236
- <tfoot class="tfoot" bind:offsetHeight={foot_height}>
237
- <slot name="tfoot" />
238
- </tfoot>
239
- </table>
240
- </div>
241
- </svelte-virtual-table-viewport>
242
-
243
- <style type="text/css">
244
- table {
245
- position: relative;
246
- overflow: auto;
247
- -webkit-overflow-scrolling: touch;
248
- max-height: var(--max-height);
249
- box-sizing: border-box;
250
- display: block;
251
- padding: 0;
252
- margin: 0;
253
- color: var(--body-text-color);
254
- font-size: var(--input-text-size);
255
- line-height: var(--line-md);
256
- font-family: var(--font-mono);
257
- border-spacing: 0;
258
- width: 100%;
259
- scroll-snap-type: x proximity;
260
- border-collapse: separate;
261
- scrollbar-width: thin;
262
- scrollbar-color: rgba(128, 128, 128, 0.5) transparent;
263
- }
264
-
265
- table::-webkit-scrollbar {
266
- width: 4px;
267
- height: 4px;
268
- }
269
-
270
- table::-webkit-scrollbar-track {
271
- background: transparent;
272
- }
273
-
274
- table::-webkit-scrollbar-thumb {
275
- background-color: rgba(128, 128, 128, 0.5);
276
- border-radius: 4px;
277
- }
278
-
279
- table:hover {
280
- scrollbar-color: rgba(160, 160, 160, 0.7) transparent;
281
- }
282
-
283
- table:hover::-webkit-scrollbar-thumb {
284
- background-color: rgba(160, 160, 160, 0.7);
285
- border-radius: 4px;
286
- width: 4px;
287
- }
288
-
289
- @media (hover: none) {
290
- table {
291
- scrollbar-color: rgba(160, 160, 160, 0.7) transparent;
292
- }
293
-
294
- table::-webkit-scrollbar-thumb {
295
- background-color: rgba(160, 160, 160, 0.7);
296
- border-radius: 4px;
297
- }
298
- }
299
-
300
- @media (pointer: coarse) {
301
- table::-webkit-scrollbar {
302
- width: 8px;
303
- height: 8px;
304
- }
305
- }
306
-
307
- table :is(thead, tfoot, tbody) {
308
- display: table;
309
- table-layout: fixed;
310
- width: 100%;
311
- box-sizing: border-box;
312
- }
313
-
314
- tbody {
315
- overflow-x: scroll;
316
- overflow-y: hidden;
317
- }
318
-
319
- table tbody {
320
- padding-top: var(--bw-svt-p-top);
321
- padding-bottom: var(--bw-svt-p-bottom);
322
- }
323
- tbody {
324
- position: relative;
325
- box-sizing: border-box;
326
- border: 0px solid currentColor;
327
- }
328
-
329
- tbody > :global(tr:last-child) {
330
- border: none;
331
- }
332
-
333
- table :global(td) {
334
- scroll-snap-align: start;
335
- }
336
-
337
- tbody :global(td.pinned-column) {
338
- position: sticky;
339
- z-index: 3;
340
- }
341
-
342
- tbody :global(tr:nth-child(odd)) :global(td.pinned-column) {
343
- background: var(--table-odd-background-fill);
344
- }
345
-
346
- tbody :global(tr:nth-child(even)) :global(td.pinned-column) {
347
- background: var(--table-even-background-fill);
348
- }
349
-
350
- tbody :global(td.last-pinned) {
351
- border-right: 1px solid var(--border-color-primary);
352
- }
353
-
354
- thead {
355
- position: sticky;
356
- top: 0;
357
- left: 0;
358
- background: var(--background-fill-primary);
359
- z-index: 7;
360
- }
361
-
362
- thead :global(th) {
363
- background: var(--table-even-background-fill) !important;
364
- }
365
-
366
- thead :global(th.pinned-column) {
367
- position: sticky;
368
- z-index: 7;
369
- background: var(--table-even-background-fill) !important;
370
- }
371
-
372
- thead :global(th.last-pinned) {
373
- border-right: 1px solid var(--border-color-primary);
374
- }
375
-
376
- .table.disable-scroll {
377
- overflow: hidden !important;
378
- }
379
- </style>
@@ -1,42 +0,0 @@
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;
11
- };
12
- z_$$bindings?: Bindings;
13
- }
14
- declare const VirtualTable: $$__sveltets_2_IsomorphicComponent<{
15
- items?: any[][];
16
- max_height: number;
17
- actual_height: number;
18
- table_scrollbar_width: number;
19
- start?: number;
20
- end?: number;
21
- selected: number | false;
22
- disable_scroll?: boolean;
23
- show_scroll_button?: boolean;
24
- viewport: HTMLTableElement;
25
- label?: string | null;
26
- scroll_to_index?: (index: number, opts: ScrollToOptions, align_end?: boolean) => Promise<void>;
27
- }, {
28
- scroll_top: CustomEvent<number>;
29
- } & {
30
- [evt: string]: CustomEvent<any>;
31
- }, {
32
- thead: {};
33
- tbody: {
34
- item: any[];
35
- index: number;
36
- };
37
- tfoot: {};
38
- }, {
39
- scroll_to_index: (index: number, opts: ScrollToOptions, align_end?: boolean) => Promise<void>;
40
- }, string>;
41
- type VirtualTable = InstanceType<typeof VirtualTable>;
42
- export default VirtualTable;
@@ -1,180 +0,0 @@
1
- import { writable } from "svelte/store";
2
- import type { CellValue } from "../types";
3
- import { get_next_cell_coordinates, get_range_selection, move_cursor } from "../utils/selection_utils";
4
- export declare const DATAFRAME_KEY: unique symbol;
5
- export type SortDirection = "asc" | "desc";
6
- export type FilterDatatype = "string" | "number";
7
- export type CellCoordinate = [number, number];
8
- interface DataFrameState {
9
- config: {
10
- show_fullscreen_button: boolean;
11
- show_copy_button: boolean;
12
- show_search: "none" | "search" | "filter";
13
- show_row_numbers: boolean;
14
- editable: boolean;
15
- pinned_columns: number;
16
- show_label: boolean;
17
- line_breaks: boolean;
18
- wrap: boolean;
19
- max_height: number;
20
- column_widths: string[];
21
- max_chars?: number;
22
- static_columns?: CellValue[];
23
- };
24
- current_search_query: string | null;
25
- sort_state: {
26
- sort_columns: {
27
- col: number;
28
- direction: SortDirection;
29
- }[];
30
- row_order: number[];
31
- initial_data: {
32
- data: {
33
- id: string;
34
- value: CellValue;
35
- }[][];
36
- display_value: string[][] | null;
37
- styling: string[][] | null;
38
- } | null;
39
- };
40
- filter_state: {
41
- filter_columns: {
42
- col: number;
43
- datatype: FilterDatatype;
44
- filter: string;
45
- value: string;
46
- }[];
47
- initial_data: {
48
- data: {
49
- id: string;
50
- value: CellValue;
51
- }[][];
52
- display_value: string[][] | null;
53
- styling: string[][] | null;
54
- } | null;
55
- };
56
- ui_state: {
57
- active_cell_menu: {
58
- row: number;
59
- col: number;
60
- x: number;
61
- y: number;
62
- } | null;
63
- active_header_menu: {
64
- col: number;
65
- x: number;
66
- y: number;
67
- } | null;
68
- selected_cells: CellCoordinate[];
69
- selected: CellCoordinate | false;
70
- editing: CellCoordinate | false;
71
- header_edit: number | false;
72
- selected_header: number | false;
73
- active_button: {
74
- type: "header" | "cell";
75
- row?: number;
76
- col: number;
77
- } | null;
78
- copy_flash: boolean;
79
- };
80
- }
81
- interface DataFrameActions {
82
- handle_search: (query: string | null) => void;
83
- handle_sort: (col: number, direction: SortDirection) => void;
84
- handle_filter: (col: number, datatype: FilterDatatype, filter: string, value: string) => void;
85
- get_sort_status: (name: string, headers: string[]) => "none" | "asc" | "desc";
86
- sort_data: (data: any[][], display_value: string[][] | null, styling: string[][] | null) => void;
87
- update_row_order: (data: any[][]) => void;
88
- filter_data: (data: any[][]) => any[][];
89
- add_row: (data: any[][], make_id: () => string, index?: number) => any[][];
90
- add_col: (data: any[][], headers: string[], make_id: () => string, index?: number) => {
91
- data: any[][];
92
- headers: string[];
93
- };
94
- add_row_at: (data: any[][], index: number, position: "above" | "below", make_id: () => string) => any[][];
95
- add_col_at: (data: any[][], headers: string[], index: number, position: "left" | "right", make_id: () => string) => {
96
- data: any[][];
97
- headers: string[];
98
- };
99
- delete_row: (data: any[][], index: number) => any[][];
100
- delete_col: (data: any[][], headers: string[], index: number) => {
101
- data: any[][];
102
- headers: string[];
103
- };
104
- delete_row_at: (data: any[][], index: number) => any[][];
105
- delete_col_at: (data: any[][], headers: string[], index: number) => {
106
- data: any[][];
107
- headers: string[];
108
- };
109
- trigger_change: (data: any[][], headers: any[], previous_data: any[][], previous_headers: string[], value_is_output: boolean, dispatch: (e: "change" | "input" | "edit", detail?: any) => void) => Promise<void>;
110
- reset_sort_state: () => void;
111
- reset_filter_state: () => void;
112
- set_active_cell_menu: (menu: {
113
- row: number;
114
- col: number;
115
- x: number;
116
- y: number;
117
- } | null) => void;
118
- set_active_header_menu: (menu: {
119
- col: number;
120
- x: number;
121
- y: number;
122
- } | null) => void;
123
- set_selected_cells: (cells: CellCoordinate[]) => void;
124
- set_selected: (selected: CellCoordinate | false) => void;
125
- set_editing: (editing: CellCoordinate | false) => void;
126
- clear_ui_state: () => void;
127
- set_header_edit: (header_index: number | false) => void;
128
- set_selected_header: (header_index: number | false) => void;
129
- handle_header_click: (col: number, editable: boolean) => void;
130
- end_header_edit: (key: string) => void;
131
- get_selected_cells: () => CellCoordinate[];
132
- get_active_cell_menu: () => {
133
- row: number;
134
- col: number;
135
- x: number;
136
- y: number;
137
- } | null;
138
- get_active_button: () => {
139
- type: "header" | "cell";
140
- row?: number;
141
- col: number;
142
- } | null;
143
- set_active_button: (button: {
144
- type: "header" | "cell";
145
- row?: number;
146
- col: number;
147
- } | null) => void;
148
- set_copy_flash: (value: boolean) => void;
149
- handle_cell_click: (event: MouseEvent, row: number, col: number) => void;
150
- toggle_cell_menu: (event: MouseEvent, row: number, col: number) => void;
151
- toggle_cell_button: (row: number, col: number) => void;
152
- handle_select_column: (col: number) => void;
153
- handle_select_row: (row: number) => void;
154
- get_next_cell_coordinates: typeof get_next_cell_coordinates;
155
- get_range_selection: typeof get_range_selection;
156
- move_cursor: typeof move_cursor;
157
- }
158
- export interface DataFrameContext {
159
- state: ReturnType<typeof writable<DataFrameState>>;
160
- actions: DataFrameActions;
161
- data?: any[][];
162
- headers?: {
163
- id: string;
164
- value: string;
165
- }[];
166
- display_value?: string[][] | null;
167
- styling?: string[][] | null;
168
- els?: Record<string, {
169
- cell: HTMLTableCellElement | null;
170
- input: HTMLTextAreaElement | null;
171
- }>;
172
- parent_element?: HTMLElement;
173
- get_data_at?: (row: number, col: number) => CellValue;
174
- get_column?: (col: number) => CellValue[];
175
- get_row?: (row: number) => CellValue[];
176
- dispatch?: (e: "change" | "select" | "search" | "edit", detail?: any) => void;
177
- }
178
- export declare function create_dataframe_context(config: DataFrameState["config"]): DataFrameContext;
179
- export declare function get_dataframe_context(): DataFrameContext;
180
- export {};