@gradio/dataframe 0.16.4 → 0.17.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 +36 -0
- package/Dataframe.stories.svelte +202 -9
- package/Index.svelte +7 -13
- package/dist/Index.svelte +5 -9
- package/dist/Index.svelte.d.ts +9 -2
- package/dist/shared/CellMenu.svelte +53 -1
- package/dist/shared/CellMenu.svelte.d.ts +5 -0
- package/dist/shared/CellMenuButton.svelte +44 -0
- package/dist/shared/CellMenuButton.svelte.d.ts +16 -0
- package/dist/shared/CellMenuIcons.svelte +79 -0
- package/dist/shared/EditableCell.svelte +83 -14
- package/dist/shared/EditableCell.svelte.d.ts +12 -3
- package/dist/shared/EmptyRowButton.svelte +28 -0
- package/dist/shared/EmptyRowButton.svelte.d.ts +16 -0
- package/dist/shared/RowNumber.svelte +40 -0
- package/dist/shared/RowNumber.svelte.d.ts +17 -0
- package/dist/shared/Table.svelte +543 -1110
- package/dist/shared/Table.svelte.d.ts +4 -0
- package/dist/shared/TableCell.svelte +291 -0
- package/dist/shared/TableCell.svelte.d.ts +57 -0
- package/dist/shared/TableHeader.svelte +239 -0
- package/dist/shared/TableHeader.svelte.d.ts +45 -0
- package/dist/shared/Toolbar.svelte +18 -8
- package/dist/shared/VirtualTable.svelte +66 -19
- package/dist/shared/VirtualTable.svelte.d.ts +4 -0
- package/dist/shared/context/keyboard_context.d.ts +37 -0
- package/dist/shared/context/keyboard_context.js +12 -0
- package/dist/shared/context/selection_context.d.ts +32 -0
- package/dist/shared/context/selection_context.js +107 -0
- package/dist/shared/context/table_context.d.ts +141 -0
- package/dist/shared/context/table_context.js +375 -0
- package/dist/shared/icons/Padlock.svelte +24 -0
- package/dist/shared/icons/Padlock.svelte.d.ts +23 -0
- package/dist/shared/icons/SelectionButtons.svelte +85 -0
- package/dist/shared/icons/SelectionButtons.svelte.d.ts +18 -0
- package/dist/shared/icons/SortArrowDown.svelte +24 -0
- package/dist/shared/icons/SortArrowDown.svelte.d.ts +16 -0
- package/dist/shared/icons/SortArrowUp.svelte +24 -0
- package/dist/shared/icons/SortArrowUp.svelte.d.ts +16 -0
- package/dist/shared/icons/SortButtonDown.svelte +14 -0
- package/dist/shared/icons/SortButtonDown.svelte.d.ts +23 -0
- package/dist/shared/icons/SortButtonUp.svelte +15 -0
- package/dist/shared/icons/SortButtonUp.svelte.d.ts +23 -0
- package/dist/shared/icons/SortIcon.svelte +46 -68
- package/dist/shared/icons/SortIcon.svelte.d.ts +3 -2
- package/dist/shared/selection_utils.d.ts +2 -1
- package/dist/shared/selection_utils.js +39 -10
- package/dist/shared/utils/data_processing.d.ts +13 -0
- package/dist/shared/utils/data_processing.js +45 -0
- package/dist/shared/utils/drag_utils.d.ts +15 -0
- package/dist/shared/utils/drag_utils.js +57 -0
- package/dist/shared/utils/keyboard_utils.d.ts +2 -0
- package/dist/shared/utils/keyboard_utils.js +186 -0
- package/dist/shared/utils/sort_utils.d.ts +9 -3
- package/dist/shared/utils/sort_utils.js +30 -24
- package/dist/shared/utils/table_utils.d.ts +6 -5
- package/dist/shared/utils/table_utils.js +13 -56
- package/package.json +9 -9
- package/shared/CellMenu.svelte +52 -1
- package/shared/CellMenuButton.svelte +45 -0
- package/shared/CellMenuIcons.svelte +79 -0
- package/shared/EditableCell.svelte +97 -18
- package/shared/EmptyRowButton.svelte +29 -0
- package/shared/RowNumber.svelte +41 -0
- package/shared/Table.svelte +568 -1223
- package/shared/TableCell.svelte +324 -0
- package/shared/TableHeader.svelte +256 -0
- package/shared/Toolbar.svelte +19 -8
- package/shared/VirtualTable.svelte +72 -19
- package/shared/context/keyboard_context.ts +65 -0
- package/shared/context/selection_context.ts +168 -0
- package/shared/context/table_context.ts +625 -0
- package/shared/icons/Padlock.svelte +24 -0
- package/shared/icons/SelectionButtons.svelte +93 -0
- package/shared/icons/SortArrowDown.svelte +25 -0
- package/shared/icons/SortArrowUp.svelte +25 -0
- package/shared/icons/SortButtonDown.svelte +14 -0
- package/shared/icons/SortButtonUp.svelte +15 -0
- package/shared/icons/SortIcon.svelte +47 -70
- package/shared/selection_utils.ts +39 -13
- package/shared/utils/data_processing.ts +72 -0
- package/shared/utils/drag_utils.ts +92 -0
- package/shared/utils/keyboard_utils.ts +238 -0
- package/shared/utils/sort_utils.test.ts +262 -14
- package/shared/utils/sort_utils.ts +39 -31
- package/shared/utils/table_utils.test.ts +66 -45
- package/shared/utils/table_utils.ts +16 -86
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# @gradio/dataframe
|
|
2
2
|
|
|
3
|
+
## 0.17.0
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- [#10784](https://github.com/gradio-app/gradio/pull/10784) [`6812544`](https://github.com/gradio-app/gradio/commit/681254453a15dadde068feaec176bb984710292b) - On Windows OS, hide `gr.Dataframe` scrollbars while keeping scrolling functionality. Thanks @abidlabs!
|
|
8
|
+
- [#10802](https://github.com/gradio-app/gradio/pull/10802) [`9ec8898`](https://github.com/gradio-app/gradio/commit/9ec8898c0f5753fb548a89f9804b71b69797d00c) - Fix excess scroll bug in dataframe. Thanks @hannahblair!
|
|
9
|
+
- [#10805](https://github.com/gradio-app/gradio/pull/10805) [`8d03368`](https://github.com/gradio-app/gradio/commit/8d03368243b6365d279563cf38a18b67a0efaf69) - Fix max characters in non-editable dataframes. Thanks @hannahblair!
|
|
10
|
+
- [#10787](https://github.com/gradio-app/gradio/pull/10787) [`b3e8c26`](https://github.com/gradio-app/gradio/commit/b3e8c263be51f9553e9f19939be0f880092b44c9) - Implement cell selection via drag in dataframe. Thanks @hannahblair!
|
|
11
|
+
- [#10734](https://github.com/gradio-app/gradio/pull/10734) [`c44b8f4`](https://github.com/gradio-app/gradio/commit/c44b8f47b927258552af61c3af06f2e30449f571) - Add `static_columns` param for interactive dataframes. Thanks @hannahblair!
|
|
12
|
+
- [#10778](https://github.com/gradio-app/gradio/pull/10778) [`373007b`](https://github.com/gradio-app/gradio/commit/373007b3e9d019ee41589d1dbb09a7511a024a51) - Allow sorting by multiple columns in dataframe. Thanks @hannahblair!
|
|
13
|
+
- [#10804](https://github.com/gradio-app/gradio/pull/10804) [`39c30be`](https://github.com/gradio-app/gradio/commit/39c30be1628028a86400c1e4b993db51e91b2580) - Add parent focus for drag selection. Thanks @hannahblair!
|
|
14
|
+
- [#10777](https://github.com/gradio-app/gradio/pull/10777) [`3b48367`](https://github.com/gradio-app/gradio/commit/3b483672f4778f5b19d2f529328c1f71b3742f45) - Allow navigating down from header cells, as well as support cmd/ctrl + arrow keys. Thanks @abidlabs!
|
|
15
|
+
- [#10776](https://github.com/gradio-app/gradio/pull/10776) [`85f6132`](https://github.com/gradio-app/gradio/commit/85f6132f1f9f653329edfa22f627e342e8b42731) - Fix cell selection when using shift + arrow keys. Thanks @abidlabs!
|
|
16
|
+
|
|
17
|
+
### Fixes
|
|
18
|
+
|
|
19
|
+
- [#10757](https://github.com/gradio-app/gradio/pull/10757) [`b4342d2`](https://github.com/gradio-app/gradio/commit/b4342d24a88acaa4ed4028c8fdd44eea0d1b8b57) - Fix dataframe search and filter functionality. Thanks @hannahblair!
|
|
20
|
+
- [#10786](https://github.com/gradio-app/gradio/pull/10786) [`88941b6`](https://github.com/gradio-app/gradio/commit/88941b655e708ab14611341ed3fe57452fbbfc58) - Remove fixed layouts from dataframe. Thanks @hannahblair!
|
|
21
|
+
- [#10631](https://github.com/gradio-app/gradio/pull/10631) [`b5ca1dc`](https://github.com/gradio-app/gradio/commit/b5ca1dcfdf496292eade31347ae1974d3a0976c4) - Refactor `gr.Dataframe`. Thanks @hannahblair!
|
|
22
|
+
|
|
23
|
+
### Dependency updates
|
|
24
|
+
|
|
25
|
+
- @gradio/upload@0.15.5
|
|
26
|
+
- @gradio/statustracker@0.10.5
|
|
27
|
+
- @gradio/button@0.4.10
|
|
28
|
+
- @gradio/atoms@0.14.0
|
|
29
|
+
- @gradio/markdown-code@0.4.1
|
|
30
|
+
|
|
31
|
+
## 0.16.5
|
|
32
|
+
|
|
33
|
+
### Dependency updates
|
|
34
|
+
|
|
35
|
+
- @gradio/client@1.13.1
|
|
36
|
+
- @gradio/upload@0.15.4
|
|
37
|
+
- @gradio/button@0.4.9
|
|
38
|
+
|
|
3
39
|
## 0.16.4
|
|
4
40
|
|
|
5
41
|
### Dependency updates
|
package/Dataframe.stories.svelte
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { userEvent } from "@storybook/test";
|
|
7
7
|
import { get } from "svelte/store";
|
|
8
8
|
import { format } from "svelte-i18n";
|
|
9
|
+
import Image from "@gradio/image";
|
|
9
10
|
</script>
|
|
10
11
|
|
|
11
12
|
<Meta
|
|
@@ -219,6 +220,18 @@
|
|
|
219
220
|
}}
|
|
220
221
|
/>
|
|
221
222
|
|
|
223
|
+
<Story
|
|
224
|
+
name="Interactive dataframe with zero row count"
|
|
225
|
+
args={{
|
|
226
|
+
values: [],
|
|
227
|
+
headers: ["Narrow", "Wide", "Half"],
|
|
228
|
+
label: "Test scores",
|
|
229
|
+
col_count: [0, "dynamic"],
|
|
230
|
+
row_count: [0, "dynamic"],
|
|
231
|
+
editable: true
|
|
232
|
+
}}
|
|
233
|
+
/>
|
|
234
|
+
|
|
222
235
|
<Story
|
|
223
236
|
name="Dataframe with link"
|
|
224
237
|
args={{
|
|
@@ -249,9 +262,8 @@
|
|
|
249
262
|
const cell_400 = canvas.getAllByRole("cell")[5];
|
|
250
263
|
await userEvent.click(cell_400);
|
|
251
264
|
|
|
252
|
-
const open_dialog_btn =
|
|
253
|
-
|
|
254
|
-
});
|
|
265
|
+
const open_dialog_btn =
|
|
266
|
+
await within(cell_400).findByLabelText("Open cell menu");
|
|
255
267
|
await userEvent.click(open_dialog_btn);
|
|
256
268
|
|
|
257
269
|
const add_row_btn = canvas.getByText("Add row above");
|
|
@@ -417,6 +429,31 @@
|
|
|
417
429
|
}}
|
|
418
430
|
/>
|
|
419
431
|
|
|
432
|
+
<Story
|
|
433
|
+
name="Dataframe with custom components"
|
|
434
|
+
args={{
|
|
435
|
+
values: [
|
|
436
|
+
[
|
|
437
|
+
"Absol G",
|
|
438
|
+
70,
|
|
439
|
+
"https://images.pokemontcg.io/pl3/1_hires.png",
|
|
440
|
+
"pl3-1",
|
|
441
|
+
"Supreme Victors"
|
|
442
|
+
]
|
|
443
|
+
],
|
|
444
|
+
datatype: ["str", "number", "image", "str", "str"],
|
|
445
|
+
headers: ["Pokemon", "HP", "Image", "ID", "Set"],
|
|
446
|
+
label: "Pokemon Cards",
|
|
447
|
+
col_count: [5, "fixed"],
|
|
448
|
+
row_count: [1, "dynamic"],
|
|
449
|
+
interactive: true,
|
|
450
|
+
editable: true,
|
|
451
|
+
components: {
|
|
452
|
+
image: Image
|
|
453
|
+
}
|
|
454
|
+
}}
|
|
455
|
+
/>
|
|
456
|
+
|
|
420
457
|
<Story
|
|
421
458
|
name="Dataframe with row and column selection"
|
|
422
459
|
args={{
|
|
@@ -441,16 +478,16 @@
|
|
|
441
478
|
const cells = canvas.getAllByRole("cell");
|
|
442
479
|
await user.click(cells[5]); // Click cell with value 6
|
|
443
480
|
|
|
444
|
-
const row_button = await canvas.
|
|
481
|
+
const row_button = await canvas.findAllByRole("button", {
|
|
445
482
|
name: "Select row"
|
|
446
|
-
});
|
|
483
|
+
})[0];
|
|
447
484
|
await user.click(row_button);
|
|
448
485
|
|
|
449
486
|
await user.click(cells[6]);
|
|
450
487
|
|
|
451
|
-
const col_button = await canvas.
|
|
488
|
+
const col_button = await canvas.findAllByRole("button", {
|
|
452
489
|
name: "Select column"
|
|
453
|
-
});
|
|
490
|
+
})[0];
|
|
454
491
|
await user.click(col_button);
|
|
455
492
|
|
|
456
493
|
await user.keyboard("{Delete}");
|
|
@@ -513,7 +550,7 @@
|
|
|
513
550
|
const canvas = within(canvasElement);
|
|
514
551
|
const user = userEvent.setup();
|
|
515
552
|
|
|
516
|
-
const search_input = canvas.getByPlaceholderText("
|
|
553
|
+
const search_input = canvas.getByPlaceholderText("Filter...");
|
|
517
554
|
await user.type(search_input, "Pet");
|
|
518
555
|
|
|
519
556
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
@@ -528,7 +565,7 @@
|
|
|
528
565
|
/>
|
|
529
566
|
|
|
530
567
|
<Story
|
|
531
|
-
name="Dataframe with
|
|
568
|
+
name="Dataframe with pinned columns"
|
|
532
569
|
args={{
|
|
533
570
|
values: [
|
|
534
571
|
["ID", "Name", "Age", "City", "Country", "Score"],
|
|
@@ -547,3 +584,159 @@
|
|
|
547
584
|
editable: false
|
|
548
585
|
}}
|
|
549
586
|
/>
|
|
587
|
+
|
|
588
|
+
<Story
|
|
589
|
+
name="Dataframe with pixel and percentage column widths set"
|
|
590
|
+
args={{
|
|
591
|
+
values: [
|
|
592
|
+
[1, 2, 3, 4, 5],
|
|
593
|
+
[6, 7, 8, 9, 10]
|
|
594
|
+
],
|
|
595
|
+
headers: ["10%", "50%", "40%", "100px", "100px"],
|
|
596
|
+
col_count: [5, "dynamic"],
|
|
597
|
+
row_count: [2, "dynamic"],
|
|
598
|
+
column_widths: ["10%", "50%", "40%", "100px", "100px"]
|
|
599
|
+
}}
|
|
600
|
+
/>
|
|
601
|
+
|
|
602
|
+
<Story
|
|
603
|
+
name="Dataframe with drag selection"
|
|
604
|
+
args={{
|
|
605
|
+
values: [
|
|
606
|
+
[1, 2, 3, 4, 5],
|
|
607
|
+
[6, 7, 8, 9, 10],
|
|
608
|
+
[11, 12, 13, 14, 15],
|
|
609
|
+
[16, 17, 18, 19, 20],
|
|
610
|
+
[21, 22, 23, 24, 25]
|
|
611
|
+
],
|
|
612
|
+
headers: ["A", "B", "C", "D", "E"],
|
|
613
|
+
label: "Drag Selection Demo",
|
|
614
|
+
col_count: [5, "dynamic"],
|
|
615
|
+
row_count: [5, "dynamic"],
|
|
616
|
+
editable: true
|
|
617
|
+
}}
|
|
618
|
+
play={async ({ canvasElement }) => {
|
|
619
|
+
const canvas = within(canvasElement);
|
|
620
|
+
const user = userEvent.setup();
|
|
621
|
+
|
|
622
|
+
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
623
|
+
|
|
624
|
+
const table = canvas.getByRole("grid");
|
|
625
|
+
const cells = canvas.getAllByRole("cell");
|
|
626
|
+
const startCell = cells[6];
|
|
627
|
+
const startRect = startCell.getBoundingClientRect();
|
|
628
|
+
const startX = startRect.left + startRect.width / 2;
|
|
629
|
+
const startY = startRect.top + startRect.height / 2;
|
|
630
|
+
|
|
631
|
+
const endCell = cells[18];
|
|
632
|
+
const endRect = endCell.getBoundingClientRect();
|
|
633
|
+
const endX = endRect.left + endRect.width / 2;
|
|
634
|
+
const endY = endRect.top + endRect.height / 2;
|
|
635
|
+
|
|
636
|
+
await user.pointer({
|
|
637
|
+
keys: "[MouseLeft>]",
|
|
638
|
+
target: startCell,
|
|
639
|
+
coords: { clientX: startX, clientY: startY }
|
|
640
|
+
});
|
|
641
|
+
|
|
642
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
643
|
+
|
|
644
|
+
const midX1 = startX + (endX - startX) / 3;
|
|
645
|
+
const midY1 = startY + (endY - startY) / 3;
|
|
646
|
+
await user.pointer({
|
|
647
|
+
target: table,
|
|
648
|
+
coords: { clientX: midX1, clientY: midY1 }
|
|
649
|
+
});
|
|
650
|
+
|
|
651
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
652
|
+
|
|
653
|
+
const midX2 = startX + ((endX - startX) * 2) / 3;
|
|
654
|
+
const midY2 = startY + ((endY - startY) * 2) / 3;
|
|
655
|
+
await user.pointer({
|
|
656
|
+
target: table,
|
|
657
|
+
coords: { clientX: midX2, clientY: midY2 }
|
|
658
|
+
});
|
|
659
|
+
|
|
660
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
661
|
+
|
|
662
|
+
await user.pointer({
|
|
663
|
+
target: endCell,
|
|
664
|
+
coords: { clientX: endX, clientY: endY }
|
|
665
|
+
});
|
|
666
|
+
|
|
667
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
668
|
+
|
|
669
|
+
await user.pointer({
|
|
670
|
+
keys: "[/MouseLeft]"
|
|
671
|
+
});
|
|
672
|
+
|
|
673
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
674
|
+
}}
|
|
675
|
+
/>
|
|
676
|
+
|
|
677
|
+
<Story
|
|
678
|
+
name="Dataframe with sorting by multiple columns"
|
|
679
|
+
args={{
|
|
680
|
+
values: [
|
|
681
|
+
[1, 2, 3],
|
|
682
|
+
[4, 5, 6],
|
|
683
|
+
[7, 8, 9]
|
|
684
|
+
],
|
|
685
|
+
headers: ["A", "B", "C"],
|
|
686
|
+
col_count: [3, "dynamic"],
|
|
687
|
+
row_count: [3, "dynamic"],
|
|
688
|
+
editable: true,
|
|
689
|
+
sort_columns: [
|
|
690
|
+
{ col: 0, direction: "asc" },
|
|
691
|
+
{ col: 1, direction: "desc" }
|
|
692
|
+
],
|
|
693
|
+
sort_state: {
|
|
694
|
+
sort_columns: [
|
|
695
|
+
{ col: 0, direction: "asc" },
|
|
696
|
+
{ col: 1, direction: "desc" }
|
|
697
|
+
],
|
|
698
|
+
row_order: [0, 1, 2]
|
|
699
|
+
}
|
|
700
|
+
}}
|
|
701
|
+
play={async ({ canvasElement }) => {
|
|
702
|
+
const canvas = within(canvasElement);
|
|
703
|
+
const user = userEvent.setup();
|
|
704
|
+
|
|
705
|
+
const header_1 = canvas.getAllByText("A")[1];
|
|
706
|
+
await userEvent.click(header_1);
|
|
707
|
+
|
|
708
|
+
const cell_menu_button = canvas.getAllByLabelText("Open cell menu")[0];
|
|
709
|
+
await userEvent.click(cell_menu_button);
|
|
710
|
+
|
|
711
|
+
const sort_ascending_button = canvas.getByRole("button", {
|
|
712
|
+
name: "Sort ascending"
|
|
713
|
+
});
|
|
714
|
+
await userEvent.click(sort_ascending_button);
|
|
715
|
+
|
|
716
|
+
const header_2 = canvas.getAllByText("B")[1];
|
|
717
|
+
await userEvent.click(header_2);
|
|
718
|
+
|
|
719
|
+
const cell_menu_button_2 = canvas.getAllByLabelText("Open cell menu")[1];
|
|
720
|
+
await userEvent.click(cell_menu_button_2);
|
|
721
|
+
|
|
722
|
+
const sort_descending_button = canvas.getByRole("button", {
|
|
723
|
+
name: "Sort descending"
|
|
724
|
+
});
|
|
725
|
+
await userEvent.click(sort_descending_button);
|
|
726
|
+
|
|
727
|
+
const header_3 = canvas.getAllByText("C")[1];
|
|
728
|
+
await userEvent.click(header_3);
|
|
729
|
+
|
|
730
|
+
const cell_menu_button_3 = canvas.getAllByLabelText("Open cell menu")[2];
|
|
731
|
+
await userEvent.click(cell_menu_button_3);
|
|
732
|
+
|
|
733
|
+
const sort_ascending_button_3 = canvas.getByRole("button", {
|
|
734
|
+
name: "Sort ascending"
|
|
735
|
+
});
|
|
736
|
+
await userEvent.click(sort_ascending_button_3);
|
|
737
|
+
|
|
738
|
+
await userEvent.click(header_3);
|
|
739
|
+
await userEvent.click(cell_menu_button_3);
|
|
740
|
+
await userEvent.click(canvas.getByText("Clear sort"));
|
|
741
|
+
}}
|
|
742
|
+
/>
|
package/Index.svelte
CHANGED
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
import { StatusTracker } from "@gradio/statustracker";
|
|
13
13
|
import type { LoadingStatus } from "@gradio/statustracker";
|
|
14
14
|
import type { Headers, Datatype, DataframeValue } from "./shared/utils";
|
|
15
|
+
import Image from "@gradio/image";
|
|
16
|
+
|
|
15
17
|
export let headers: Headers = [];
|
|
16
18
|
export let elem_id = "";
|
|
17
19
|
export let elem_classes: string[] = [];
|
|
@@ -39,6 +41,7 @@
|
|
|
39
41
|
select: SelectData;
|
|
40
42
|
input: never;
|
|
41
43
|
clear_status: LoadingStatus;
|
|
44
|
+
search: string | null;
|
|
42
45
|
}>;
|
|
43
46
|
export let latex_delimiters: {
|
|
44
47
|
left: string;
|
|
@@ -53,18 +56,8 @@
|
|
|
53
56
|
export let show_copy_button = false;
|
|
54
57
|
export let show_row_numbers = false;
|
|
55
58
|
export let show_search: "none" | "search" | "filter" = "none";
|
|
56
|
-
|
|
57
|
-
let search_query: string | null = null;
|
|
58
|
-
$: filtered_cell_values = search_query
|
|
59
|
-
? value.data?.filter((row) =>
|
|
60
|
-
row.some(
|
|
61
|
-
(cell) =>
|
|
62
|
-
search_query &&
|
|
63
|
-
String(cell).toLowerCase().includes(search_query.toLowerCase())
|
|
64
|
-
)
|
|
65
|
-
)
|
|
66
|
-
: null;
|
|
67
59
|
export let pinned_columns = 0;
|
|
60
|
+
export let static_columns: (string | number)[] = [];
|
|
68
61
|
|
|
69
62
|
$: _headers = [...(value.headers || headers)];
|
|
70
63
|
$: display_value = value?.metadata?.display_value
|
|
@@ -98,7 +91,7 @@
|
|
|
98
91
|
{show_label}
|
|
99
92
|
{row_count}
|
|
100
93
|
{col_count}
|
|
101
|
-
values={
|
|
94
|
+
values={value.data}
|
|
102
95
|
{display_value}
|
|
103
96
|
{styling}
|
|
104
97
|
headers={_headers}
|
|
@@ -109,7 +102,6 @@
|
|
|
109
102
|
}}
|
|
110
103
|
on:input={(e) => gradio.dispatch("input")}
|
|
111
104
|
on:select={(e) => gradio.dispatch("select", e.detail)}
|
|
112
|
-
on:search={(e) => (search_query = e.detail)}
|
|
113
105
|
{wrap}
|
|
114
106
|
{datatype}
|
|
115
107
|
{latex_delimiters}
|
|
@@ -127,5 +119,7 @@
|
|
|
127
119
|
{show_row_numbers}
|
|
128
120
|
{show_search}
|
|
129
121
|
{pinned_columns}
|
|
122
|
+
components={{ image: Image }}
|
|
123
|
+
{static_columns}
|
|
130
124
|
/>
|
|
131
125
|
</Block>
|
package/dist/Index.svelte
CHANGED
|
@@ -7,6 +7,7 @@ export { default as BaseExample } from "./Example.svelte";
|
|
|
7
7
|
<script>import { Block } from "@gradio/atoms";
|
|
8
8
|
import Table from "./shared/Table.svelte";
|
|
9
9
|
import { StatusTracker } from "@gradio/statustracker";
|
|
10
|
+
import Image from "@gradio/image";
|
|
10
11
|
export let headers = [];
|
|
11
12
|
export let elem_id = "";
|
|
12
13
|
export let elem_classes = [];
|
|
@@ -38,14 +39,8 @@ export let max_chars = void 0;
|
|
|
38
39
|
export let show_copy_button = false;
|
|
39
40
|
export let show_row_numbers = false;
|
|
40
41
|
export let show_search = "none";
|
|
41
|
-
let search_query = null;
|
|
42
|
-
$:
|
|
43
|
-
filtered_cell_values = search_query ? value.data?.filter(
|
|
44
|
-
(row) => row.some(
|
|
45
|
-
(cell) => search_query && String(cell).toLowerCase().includes(search_query.toLowerCase())
|
|
46
|
-
)
|
|
47
|
-
) : null;
|
|
48
42
|
export let pinned_columns = 0;
|
|
43
|
+
export let static_columns = [];
|
|
49
44
|
$:
|
|
50
45
|
_headers = [...value.headers || headers];
|
|
51
46
|
$:
|
|
@@ -76,7 +71,7 @@ $:
|
|
|
76
71
|
{show_label}
|
|
77
72
|
{row_count}
|
|
78
73
|
{col_count}
|
|
79
|
-
values={
|
|
74
|
+
values={value.data}
|
|
80
75
|
{display_value}
|
|
81
76
|
{styling}
|
|
82
77
|
headers={_headers}
|
|
@@ -87,7 +82,6 @@ $:
|
|
|
87
82
|
}}
|
|
88
83
|
on:input={(e) => gradio.dispatch("input")}
|
|
89
84
|
on:select={(e) => gradio.dispatch("select", e.detail)}
|
|
90
|
-
on:search={(e) => (search_query = e.detail)}
|
|
91
85
|
{wrap}
|
|
92
86
|
{datatype}
|
|
93
87
|
{latex_delimiters}
|
|
@@ -105,5 +99,7 @@ $:
|
|
|
105
99
|
{show_row_numbers}
|
|
106
100
|
{show_search}
|
|
107
101
|
{pinned_columns}
|
|
102
|
+
components={{ image: Image }}
|
|
103
|
+
{static_columns}
|
|
108
104
|
/>
|
|
109
105
|
</Block>
|
package/dist/Index.svelte.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ declare const __propDef: {
|
|
|
28
28
|
select: SelectData;
|
|
29
29
|
input: never;
|
|
30
30
|
clear_status: LoadingStatus;
|
|
31
|
+
search: string | null;
|
|
31
32
|
}>;
|
|
32
33
|
latex_delimiters: {
|
|
33
34
|
left: string;
|
|
@@ -43,6 +44,7 @@ declare const __propDef: {
|
|
|
43
44
|
show_row_numbers?: boolean | undefined;
|
|
44
45
|
show_search?: ("none" | "search" | "filter") | undefined;
|
|
45
46
|
pinned_columns?: number | undefined;
|
|
47
|
+
static_columns?: (string | number)[] | undefined;
|
|
46
48
|
};
|
|
47
49
|
events: {
|
|
48
50
|
[evt: string]: CustomEvent<any>;
|
|
@@ -109,6 +111,7 @@ export default class Index extends SvelteComponent<IndexProps, IndexEvents, Inde
|
|
|
109
111
|
select: SelectData;
|
|
110
112
|
input: never;
|
|
111
113
|
clear_status: LoadingStatus;
|
|
114
|
+
search: string | null;
|
|
112
115
|
}>;
|
|
113
116
|
/**accessor*/
|
|
114
117
|
set gradio(_: Gradio<{
|
|
@@ -116,6 +119,7 @@ export default class Index extends SvelteComponent<IndexProps, IndexEvents, Inde
|
|
|
116
119
|
select: SelectData;
|
|
117
120
|
input: never;
|
|
118
121
|
clear_status: LoadingStatus;
|
|
122
|
+
search: string | null;
|
|
119
123
|
}>);
|
|
120
124
|
get latex_delimiters(): {
|
|
121
125
|
left: string;
|
|
@@ -149,10 +153,13 @@ export default class Index extends SvelteComponent<IndexProps, IndexEvents, Inde
|
|
|
149
153
|
get show_row_numbers(): boolean | undefined;
|
|
150
154
|
/**accessor*/
|
|
151
155
|
set show_row_numbers(_: boolean | undefined);
|
|
152
|
-
get show_search(): "
|
|
156
|
+
get show_search(): "none" | "filter" | "search" | undefined;
|
|
153
157
|
/**accessor*/
|
|
154
|
-
set show_search(_: "
|
|
158
|
+
set show_search(_: "none" | "filter" | "search" | undefined);
|
|
155
159
|
get pinned_columns(): number | undefined;
|
|
156
160
|
/**accessor*/
|
|
157
161
|
set pinned_columns(_: number | undefined);
|
|
162
|
+
get static_columns(): (string | number)[] | undefined;
|
|
163
|
+
/**accessor*/
|
|
164
|
+
set static_columns(_: (string | number)[] | undefined);
|
|
158
165
|
}
|
|
@@ -13,6 +13,12 @@ export let on_delete_row;
|
|
|
13
13
|
export let on_delete_col;
|
|
14
14
|
export let can_delete_rows;
|
|
15
15
|
export let can_delete_cols;
|
|
16
|
+
export let on_sort = () => {
|
|
17
|
+
};
|
|
18
|
+
export let on_clear_sort = () => {
|
|
19
|
+
};
|
|
20
|
+
export let sort_direction = null;
|
|
21
|
+
export let sort_priority = null;
|
|
16
22
|
export let i18n;
|
|
17
23
|
let menu_element;
|
|
18
24
|
$:
|
|
@@ -44,6 +50,33 @@ function position_menu() {
|
|
|
44
50
|
</script>
|
|
45
51
|
|
|
46
52
|
<div bind:this={menu_element} class="cell-menu">
|
|
53
|
+
{#if is_header}
|
|
54
|
+
<button
|
|
55
|
+
on:click={() => on_sort("asc")}
|
|
56
|
+
class:active={sort_direction === "asc"}
|
|
57
|
+
>
|
|
58
|
+
<CellMenuIcons icon="sort-asc" />
|
|
59
|
+
{i18n("dataframe.sort_ascending")}
|
|
60
|
+
{#if sort_direction === "asc" && sort_priority !== null}
|
|
61
|
+
<span class="priority">{sort_priority}</span>
|
|
62
|
+
{/if}
|
|
63
|
+
</button>
|
|
64
|
+
<button
|
|
65
|
+
on:click={() => on_sort("desc")}
|
|
66
|
+
class:active={sort_direction === "desc"}
|
|
67
|
+
>
|
|
68
|
+
<CellMenuIcons icon="sort-desc" />
|
|
69
|
+
{i18n("dataframe.sort_descending")}
|
|
70
|
+
{#if sort_direction === "desc" && sort_priority !== null}
|
|
71
|
+
<span class="priority">{sort_priority}</span>
|
|
72
|
+
{/if}
|
|
73
|
+
</button>
|
|
74
|
+
<button on:click={on_clear_sort}>
|
|
75
|
+
<CellMenuIcons icon="clear-sort" />
|
|
76
|
+
{i18n("dataframe.clear_sort")}
|
|
77
|
+
</button>
|
|
78
|
+
{/if}
|
|
79
|
+
|
|
47
80
|
{#if !is_header && can_add_rows}
|
|
48
81
|
<button on:click={() => on_add_row_above()}>
|
|
49
82
|
<CellMenuIcons icon="add-row-above" />
|
|
@@ -81,7 +114,7 @@ function position_menu() {
|
|
|
81
114
|
<style>
|
|
82
115
|
.cell-menu {
|
|
83
116
|
position: fixed;
|
|
84
|
-
z-index:
|
|
117
|
+
z-index: 9;
|
|
85
118
|
background: var(--background-fill-primary);
|
|
86
119
|
border: 1px solid var(--border-color-primary);
|
|
87
120
|
border-radius: var(--radius-sm);
|
|
@@ -91,6 +124,7 @@ function position_menu() {
|
|
|
91
124
|
gap: var(--size-1);
|
|
92
125
|
box-shadow: var(--shadow-drop-lg);
|
|
93
126
|
min-width: 150px;
|
|
127
|
+
z-index: var(--layer-1);
|
|
94
128
|
}
|
|
95
129
|
|
|
96
130
|
.cell-menu button {
|
|
@@ -108,6 +142,11 @@ function position_menu() {
|
|
|
108
142
|
display: flex;
|
|
109
143
|
align-items: center;
|
|
110
144
|
gap: var(--size-2);
|
|
145
|
+
position: relative;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.cell-menu button.active {
|
|
149
|
+
background-color: var(--background-fill-secondary);
|
|
111
150
|
}
|
|
112
151
|
|
|
113
152
|
.cell-menu button:hover {
|
|
@@ -118,4 +157,17 @@ function position_menu() {
|
|
|
118
157
|
fill: currentColor;
|
|
119
158
|
transition: fill 0.2s;
|
|
120
159
|
}
|
|
160
|
+
|
|
161
|
+
.priority {
|
|
162
|
+
display: flex;
|
|
163
|
+
align-items: center;
|
|
164
|
+
justify-content: center;
|
|
165
|
+
margin-left: auto;
|
|
166
|
+
font-size: var(--size-2);
|
|
167
|
+
background-color: var(--button-secondary-background-fill);
|
|
168
|
+
color: var(--body-text-color);
|
|
169
|
+
border-radius: var(--radius-sm);
|
|
170
|
+
width: var(--size-2-5);
|
|
171
|
+
height: var(--size-2-5);
|
|
172
|
+
}
|
|
121
173
|
</style>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
2
|
import type { I18nFormatter } from "js/utils/src";
|
|
3
|
+
import type { SortDirection } from "./context/table_context";
|
|
3
4
|
declare const __propDef: {
|
|
4
5
|
props: {
|
|
5
6
|
x: number;
|
|
@@ -15,6 +16,10 @@ declare const __propDef: {
|
|
|
15
16
|
on_delete_col: () => void;
|
|
16
17
|
can_delete_rows: boolean;
|
|
17
18
|
can_delete_cols: boolean;
|
|
19
|
+
on_sort?: ((direction: SortDirection) => void) | undefined;
|
|
20
|
+
on_clear_sort?: (() => void) | undefined;
|
|
21
|
+
sort_direction?: (SortDirection | null) | undefined;
|
|
22
|
+
sort_priority?: (number | null) | undefined;
|
|
18
23
|
i18n: I18nFormatter;
|
|
19
24
|
};
|
|
20
25
|
events: {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<script>export let on_click;
|
|
2
|
+
</script>
|
|
3
|
+
|
|
4
|
+
<button
|
|
5
|
+
aria-label="Open cell menu"
|
|
6
|
+
class="cell-menu-button"
|
|
7
|
+
on:click={on_click}
|
|
8
|
+
on:touchstart={(event) => {
|
|
9
|
+
event.preventDefault();
|
|
10
|
+
const touch = event.touches[0];
|
|
11
|
+
const mouseEvent = new MouseEvent("click", {
|
|
12
|
+
clientX: touch.clientX,
|
|
13
|
+
clientY: touch.clientY,
|
|
14
|
+
bubbles: true,
|
|
15
|
+
cancelable: true,
|
|
16
|
+
view: window
|
|
17
|
+
});
|
|
18
|
+
on_click(mouseEvent);
|
|
19
|
+
}}
|
|
20
|
+
>
|
|
21
|
+
⋮
|
|
22
|
+
</button>
|
|
23
|
+
|
|
24
|
+
<style>
|
|
25
|
+
.cell-menu-button {
|
|
26
|
+
flex-shrink: 0;
|
|
27
|
+
display: none;
|
|
28
|
+
align-items: center;
|
|
29
|
+
justify-content: center;
|
|
30
|
+
background-color: var(--block-background-fill);
|
|
31
|
+
border: 1px solid var(--border-color-primary);
|
|
32
|
+
border-radius: var(--block-radius);
|
|
33
|
+
width: var(--size-5);
|
|
34
|
+
height: var(--size-5);
|
|
35
|
+
min-width: var(--size-5);
|
|
36
|
+
padding: 0;
|
|
37
|
+
margin-right: var(--spacing-sm);
|
|
38
|
+
z-index: 2;
|
|
39
|
+
position: absolute;
|
|
40
|
+
right: var(--size-1);
|
|
41
|
+
top: 50%;
|
|
42
|
+
transform: translateY(-50%);
|
|
43
|
+
}
|
|
44
|
+
</style>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
on_click: (event: MouseEvent) => void;
|
|
5
|
+
};
|
|
6
|
+
events: {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
};
|
|
9
|
+
slots: {};
|
|
10
|
+
};
|
|
11
|
+
export type CellMenuButtonProps = typeof __propDef.props;
|
|
12
|
+
export type CellMenuButtonEvents = typeof __propDef.events;
|
|
13
|
+
export type CellMenuButtonSlots = typeof __propDef.slots;
|
|
14
|
+
export default class CellMenuButton extends SvelteComponent<CellMenuButtonProps, CellMenuButtonEvents, CellMenuButtonSlots> {
|
|
15
|
+
}
|
|
16
|
+
export {};
|