react-glide-table 1.1.2 → 1.1.4
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/README.md +19 -5
- package/dist/compound.cjs +240 -90
- package/dist/compound.d.cts +5 -5
- package/dist/compound.d.ts +5 -5
- package/dist/compound.js +230 -80
- package/dist/core.d.cts +4 -3
- package/dist/core.d.ts +4 -3
- package/dist/index.cjs +240 -90
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +230 -80
- package/dist/{types-ByOoRY8x.d.cts → types-BfthylVR.d.cts} +44 -1
- package/dist/{types-ByOoRY8x.d.ts → types-BfthylVR.d.ts} +44 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Headless React table built on [@tanstack/react-table](https://tanstack.com/table) and [@tanstack/react-virtual](https://tanstack.com/virtual).
|
|
4
4
|
|
|
5
|
-
Primary DX is a **compound API** (`createTable` / `Table.Column`) with an unstyled semantic HTML shell. Customize with `className`
|
|
5
|
+
Primary DX is a **compound API** (`createTable` / `Table.Column`) with an unstyled semantic HTML shell. Customize with `className`, **`classNames` (Tailwind-friendly part map)**, `slots`, and column `render`. `useGlideTable` remains the lower-level escape hatch when you need full control of markup.
|
|
6
6
|
|
|
7
7
|
The package ships **no CSS** — class names like `DataTableJSX` / `data-table` are opt-in hooks for your own styles.
|
|
8
8
|
|
|
@@ -41,9 +41,15 @@ export function Products({ data }: { data: Product[] }) {
|
|
|
41
41
|
<ProductTable
|
|
42
42
|
data={data}
|
|
43
43
|
getRowId={(row) => row.id}
|
|
44
|
-
className="
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
className="rounded-lg border"
|
|
45
|
+
classNames={{
|
|
46
|
+
scroll: "max-h-[480px] overflow-auto",
|
|
47
|
+
head: "sticky top-0 z-10 bg-neutral-50",
|
|
48
|
+
headCell: "px-3 text-xs font-semibold text-neutral-500",
|
|
49
|
+
row: "hover:bg-neutral-100 data-[selected]:bg-blue-600 data-[selected]:text-white",
|
|
50
|
+
cell: "border-b border-neutral-200 px-3 text-sm",
|
|
51
|
+
toolbar: "flex items-center justify-between gap-2 p-2",
|
|
52
|
+
}}
|
|
47
53
|
>
|
|
48
54
|
<ProductTable.Header>
|
|
49
55
|
<ProductTable.Column field="name">Name</ProductTable.Column>
|
|
@@ -61,13 +67,21 @@ export function Products({ data }: { data: Product[] }) {
|
|
|
61
67
|
|
|
62
68
|
| Slot / prop | Role |
|
|
63
69
|
| --- | --- |
|
|
70
|
+
| `classNames` | Per-part Tailwind/utility classes (`root`, `scroll`, `row`, `cell`, `toolbar`, …) |
|
|
64
71
|
| `slots.Toolbar` | Top summary / actions region |
|
|
65
72
|
| `slots.Row` | Full row replacement (cells, selection, edit UI) |
|
|
66
73
|
| `slots.Pending` / `slots.Empty` | Loading and empty states |
|
|
67
|
-
| `className` / column `className` / `headerClassName` |
|
|
74
|
+
| `className` / column `className` / `headerClassName` | Extra class hooks |
|
|
68
75
|
| `labels` / `summary` / `toolbar` | Copy and slot nodes |
|
|
69
76
|
| `Column.render` | Cell content custom render |
|
|
70
77
|
|
|
78
|
+
Row/cell **state** is exposed as `data-*` attributes for Tailwind variants:
|
|
79
|
+
|
|
80
|
+
- row: `data-selected`, `data-hovered`, `data-expandable`, `data-expanded`
|
|
81
|
+
- cell: `data-merged`, `data-selection-fill`, `data-editable`, `data-editing`, …
|
|
82
|
+
|
|
83
|
+
Example: `row: "data-[selected]:bg-blue-600"`.
|
|
84
|
+
|
|
71
85
|
Row-level UI → `slots.Row`. Cell content → `Column.render`. Header/Cell are not separate slots.
|
|
72
86
|
|
|
73
87
|
## Escape hatch (`useGlideTable`)
|
package/dist/compound.cjs
CHANGED
|
@@ -28,6 +28,7 @@ module.exports = __toCommonJS(compound_exports);
|
|
|
28
28
|
|
|
29
29
|
// src/components/ui/table/components/DataTable/DataTable.tsx
|
|
30
30
|
var import_react_table3 = require("@tanstack/react-table");
|
|
31
|
+
var import_react7 = require("react");
|
|
31
32
|
|
|
32
33
|
// src/components/ui/table/components/DataTable/DataTableRow.tsx
|
|
33
34
|
var import_react_table = require("@tanstack/react-table");
|
|
@@ -736,7 +737,7 @@ function DataTableRow({
|
|
|
736
737
|
virtualIndex,
|
|
737
738
|
measureElement
|
|
738
739
|
}) {
|
|
739
|
-
const { rowSpan, selection, cellSelection, cellEdit, expand } = useDataTableRowContext();
|
|
740
|
+
const { classNames, rowSpan, selection, cellSelection, cellEdit, expand } = useDataTableRowContext();
|
|
740
741
|
const {
|
|
741
742
|
enableRowSpan,
|
|
742
743
|
primaryRowSpanKey,
|
|
@@ -814,12 +815,17 @@ function DataTableRow({
|
|
|
814
815
|
{
|
|
815
816
|
ref: measureElement,
|
|
816
817
|
"data-index": virtualIndex,
|
|
818
|
+
"data-selected": isRowSelected ? "" : void 0,
|
|
819
|
+
"data-hovered": isRowHovered || isGroupHovered ? "" : void 0,
|
|
820
|
+
"data-expandable": enableExpand && canExpand ? "" : void 0,
|
|
821
|
+
"data-expanded": isExpanded ? "" : void 0,
|
|
817
822
|
className: cn(
|
|
818
823
|
"DataTableRowJSX",
|
|
819
824
|
!enableRowSpan && ROW_HOVER_CLASS,
|
|
820
825
|
enableRowSpan && isRowHovered && !isRowSelected && ROW_HOVERED_BG_CLASS,
|
|
821
826
|
isRowSelected && "is-selected",
|
|
822
827
|
enableExpand && canExpand && "is-expandable",
|
|
828
|
+
classNames?.row,
|
|
823
829
|
getRowClassName?.(rowData, rowIndex)
|
|
824
830
|
),
|
|
825
831
|
onMouseEnter: () => onRowHover(rowIndex, rowData),
|
|
@@ -870,10 +876,19 @@ function DataTableRow({
|
|
|
870
876
|
isVisuallySelectedAt
|
|
871
877
|
);
|
|
872
878
|
const resolveCellRowIndex = (clientY, element) => getRowIndexInMergedCell(clientY, element, rowIndex, cellRowSpan);
|
|
879
|
+
const hasSelectionEdges = hasCellSelectionEdges(selectionEdgeStyle);
|
|
873
880
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
874
881
|
"td",
|
|
875
882
|
{
|
|
876
883
|
rowSpan: rowSpanInfo && rowSpanInfo.rowSpan > 1 ? rowSpanInfo.rowSpan : void 0,
|
|
884
|
+
"data-merged": isMerged && cellIndex > 0 ? "" : void 0,
|
|
885
|
+
"data-merged-edge-right": showMergedRightEdge ? "" : void 0,
|
|
886
|
+
"data-group-selected": enableRowSpan && showCellSelected ? "" : void 0,
|
|
887
|
+
"data-group-hovered": enableRowSpan && showCellHover && !showCellSelected ? "" : void 0,
|
|
888
|
+
"data-selection-fill": isCellDragSelected ? "" : void 0,
|
|
889
|
+
"data-selection-edges": hasSelectionEdges ? "" : void 0,
|
|
890
|
+
"data-editable": editable ? "" : void 0,
|
|
891
|
+
"data-editing": isEditing ? "" : void 0,
|
|
877
892
|
onMouseDown: (event) => {
|
|
878
893
|
if (isEditing) {
|
|
879
894
|
event.stopPropagation();
|
|
@@ -917,8 +932,9 @@ function DataTableRow({
|
|
|
917
932
|
enableRowSpan && showCellSelected && "is-group-selected",
|
|
918
933
|
enableRowSpan && showCellHover && !showCellSelected && "is-group-hovered",
|
|
919
934
|
isCellDragSelected && CELL_SELECTION_FILL_CLASS,
|
|
920
|
-
|
|
921
|
-
editable && "is-editable"
|
|
935
|
+
hasSelectionEdges && CELL_SELECTION_EDGES_CLASS,
|
|
936
|
+
editable && "is-editable",
|
|
937
|
+
classNames?.cell
|
|
922
938
|
),
|
|
923
939
|
children: [
|
|
924
940
|
isEditing ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
@@ -927,7 +943,11 @@ function DataTableRow({
|
|
|
927
943
|
ref: editInputRef,
|
|
928
944
|
type: editType === "number" ? "number" : "text",
|
|
929
945
|
defaultValue: draftValue,
|
|
930
|
-
className: cn(
|
|
946
|
+
className: cn(
|
|
947
|
+
"cell-edit-input",
|
|
948
|
+
CELL_ALIGN_CLASS[align],
|
|
949
|
+
classNames?.cellEditInput
|
|
950
|
+
),
|
|
931
951
|
onChange: (event) => onDraftValueChange(event.target.value),
|
|
932
952
|
onMouseDown: (event) => event.stopPropagation(),
|
|
933
953
|
onClick: (event) => event.stopPropagation(),
|
|
@@ -945,23 +965,69 @@ function DataTableRow({
|
|
|
945
965
|
onCommitEdit(event.currentTarget.value);
|
|
946
966
|
}
|
|
947
967
|
}
|
|
948
|
-
) : isExpandCell && enableExpand ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "expand-cell", children: [
|
|
949
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
968
|
+
) : isExpandCell && enableExpand ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: cn("expand-cell", classNames?.expandCell), children: [
|
|
969
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
970
|
+
"div",
|
|
971
|
+
{
|
|
972
|
+
className: cn(
|
|
973
|
+
"expand-cell-content",
|
|
974
|
+
classNames?.expandCellContent
|
|
975
|
+
),
|
|
976
|
+
children: [
|
|
977
|
+
rowLevel > 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
978
|
+
"span",
|
|
979
|
+
{
|
|
980
|
+
className: cn(
|
|
981
|
+
"expand-cell-indent",
|
|
982
|
+
classNames?.expandCellIndent
|
|
983
|
+
),
|
|
984
|
+
children: "\xB7"
|
|
985
|
+
}
|
|
986
|
+
),
|
|
987
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
988
|
+
"div",
|
|
989
|
+
{
|
|
990
|
+
className: cn(
|
|
991
|
+
"expand-cell-value",
|
|
992
|
+
classNames?.expandCellValue
|
|
993
|
+
),
|
|
994
|
+
children: (0, import_react_table.flexRender)(cell.column.columnDef.cell, cell.getContext())
|
|
995
|
+
}
|
|
996
|
+
)
|
|
997
|
+
]
|
|
998
|
+
}
|
|
999
|
+
),
|
|
953
1000
|
canExpand && expandKey && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
954
1001
|
"button",
|
|
955
1002
|
{
|
|
956
1003
|
type: "button",
|
|
957
1004
|
"aria-label": isExpanded ? collapseRowLabel : expandRowLabel,
|
|
958
|
-
className:
|
|
1005
|
+
className: cn(
|
|
1006
|
+
"expand-toggle-button",
|
|
1007
|
+
classNames?.expandToggle
|
|
1008
|
+
),
|
|
959
1009
|
onClick: (event) => {
|
|
960
1010
|
event.stopPropagation();
|
|
961
1011
|
onToggleExpand?.(expandKey);
|
|
962
1012
|
},
|
|
963
1013
|
onMouseDown: (event) => event.stopPropagation(),
|
|
964
|
-
children: isExpanded ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1014
|
+
children: isExpanded ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1015
|
+
ChevronUp,
|
|
1016
|
+
{
|
|
1017
|
+
className: cn(
|
|
1018
|
+
"expand-toggle-icon",
|
|
1019
|
+
classNames?.expandToggleIcon
|
|
1020
|
+
)
|
|
1021
|
+
}
|
|
1022
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1023
|
+
ChevronDown,
|
|
1024
|
+
{
|
|
1025
|
+
className: cn(
|
|
1026
|
+
"expand-toggle-icon",
|
|
1027
|
+
classNames?.expandToggleIcon
|
|
1028
|
+
)
|
|
1029
|
+
}
|
|
1030
|
+
)
|
|
965
1031
|
}
|
|
966
1032
|
)
|
|
967
1033
|
] }) : (0, import_react_table.flexRender)(cell.column.columnDef.cell, cell.getContext()),
|
|
@@ -969,7 +1035,7 @@ function DataTableRow({
|
|
|
969
1035
|
"div",
|
|
970
1036
|
{
|
|
971
1037
|
role: "presentation",
|
|
972
|
-
className: "fill-handle",
|
|
1038
|
+
className: cn("fill-handle", classNames?.fillHandle),
|
|
973
1039
|
onMouseDown: (event) => {
|
|
974
1040
|
event.stopPropagation();
|
|
975
1041
|
event.preventDefault();
|
|
@@ -995,7 +1061,8 @@ function DataTableToolbar({
|
|
|
995
1061
|
selectedCount,
|
|
996
1062
|
selectionLabel,
|
|
997
1063
|
toolbar,
|
|
998
|
-
className
|
|
1064
|
+
className,
|
|
1065
|
+
classNames
|
|
999
1066
|
}) {
|
|
1000
1067
|
const displayFiltered = filteredCount ?? totalCount;
|
|
1001
1068
|
const hasCount = displayFiltered !== void 0 || totalCount !== void 0;
|
|
@@ -1004,9 +1071,9 @@ function DataTableToolbar({
|
|
|
1004
1071
|
const selectionContent = selectionLabel?.(selectedCount) ?? null;
|
|
1005
1072
|
const hasSelectionContent = selectionContent !== null && selectionContent !== false && selectionContent !== void 0 && typeof selectionContent !== "boolean";
|
|
1006
1073
|
if (!hasLeftContent && !hasToolbar && !hasSelectionContent) return null;
|
|
1007
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: cn("DataTableToolbarJSX", className), children: [
|
|
1008
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "toolbar-left", children: [
|
|
1009
|
-
hasCount && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "toolbar-count", children: displayFiltered !== void 0 && totalCount !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
1074
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: cn("DataTableToolbarJSX", classNames?.toolbar, className), children: [
|
|
1075
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: cn("toolbar-left", classNames?.toolbarLeft), children: [
|
|
1076
|
+
hasCount && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: cn("toolbar-count", classNames?.toolbarCount), children: displayFiltered !== void 0 && totalCount !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
1010
1077
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "toolbar-count-primary", children: displayFiltered }),
|
|
1011
1078
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "toolbar-count-placeholder", children: [
|
|
1012
1079
|
" / ",
|
|
@@ -1015,9 +1082,9 @@ function DataTableToolbar({
|
|
|
1015
1082
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "toolbar-count-primary", children: displayFiltered ?? totalCount }) }),
|
|
1016
1083
|
summary
|
|
1017
1084
|
] }),
|
|
1018
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "toolbar-right", children: [
|
|
1019
|
-
hasSelectionContent && (typeof selectionContent === "string" || typeof selectionContent === "number" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "toolbar-selection", children: selectionContent }) : selectionContent),
|
|
1020
|
-
hasToolbar && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "toolbar-actions", children: toolbar })
|
|
1085
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: cn("toolbar-right", classNames?.toolbarRight), children: [
|
|
1086
|
+
hasSelectionContent && (typeof selectionContent === "string" || typeof selectionContent === "number" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: cn("toolbar-selection", classNames?.toolbarSelection), children: selectionContent }) : selectionContent),
|
|
1087
|
+
hasToolbar && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: cn("toolbar-actions", classNames?.toolbarActions), children: toolbar })
|
|
1021
1088
|
] })
|
|
1022
1089
|
] });
|
|
1023
1090
|
}
|
|
@@ -1629,15 +1696,36 @@ function useGlideTable(options) {
|
|
|
1629
1696
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1630
1697
|
function DefaultPending({
|
|
1631
1698
|
loadingText,
|
|
1632
|
-
className
|
|
1699
|
+
className,
|
|
1700
|
+
classNames
|
|
1633
1701
|
}) {
|
|
1634
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1702
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1703
|
+
"div",
|
|
1704
|
+
{
|
|
1705
|
+
className: cn(
|
|
1706
|
+
"DataTableJSX",
|
|
1707
|
+
"DataTableJSX--pending",
|
|
1708
|
+
classNames?.root,
|
|
1709
|
+
classNames?.pending,
|
|
1710
|
+
className
|
|
1711
|
+
),
|
|
1712
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: cn("data-table-loading-text", classNames?.loadingText), children: loadingText })
|
|
1713
|
+
}
|
|
1714
|
+
);
|
|
1635
1715
|
}
|
|
1636
1716
|
function DefaultEmpty({
|
|
1637
1717
|
emptyText,
|
|
1638
|
-
columnCount
|
|
1718
|
+
columnCount,
|
|
1719
|
+
classNames
|
|
1639
1720
|
}) {
|
|
1640
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1721
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1722
|
+
"td",
|
|
1723
|
+
{
|
|
1724
|
+
colSpan: columnCount,
|
|
1725
|
+
className: cn("data-table-empty-cell", classNames?.emptyCell),
|
|
1726
|
+
children: emptyText
|
|
1727
|
+
}
|
|
1728
|
+
) });
|
|
1641
1729
|
}
|
|
1642
1730
|
function DataTable({
|
|
1643
1731
|
isPending = false,
|
|
@@ -1646,6 +1734,7 @@ function DataTable({
|
|
|
1646
1734
|
filteredCount,
|
|
1647
1735
|
totalCount,
|
|
1648
1736
|
className,
|
|
1737
|
+
classNames,
|
|
1649
1738
|
slots,
|
|
1650
1739
|
...glideOptions
|
|
1651
1740
|
}) {
|
|
@@ -1673,8 +1762,19 @@ function DataTable({
|
|
|
1673
1762
|
const RowSlot = slots?.Row ?? DataTableRow;
|
|
1674
1763
|
const PendingSlot = slots?.Pending ?? DefaultPending;
|
|
1675
1764
|
const EmptySlot = slots?.Empty ?? DefaultEmpty;
|
|
1765
|
+
const contextValue = (0, import_react7.useMemo)(
|
|
1766
|
+
() => ({ ...rowContextValue, classNames }),
|
|
1767
|
+
[rowContextValue, classNames]
|
|
1768
|
+
);
|
|
1676
1769
|
if (isPending) {
|
|
1677
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1770
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1771
|
+
PendingSlot,
|
|
1772
|
+
{
|
|
1773
|
+
loadingText,
|
|
1774
|
+
className,
|
|
1775
|
+
classNames
|
|
1776
|
+
}
|
|
1777
|
+
);
|
|
1678
1778
|
}
|
|
1679
1779
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1680
1780
|
"div",
|
|
@@ -1682,6 +1782,7 @@ function DataTable({
|
|
|
1682
1782
|
className: cn(
|
|
1683
1783
|
"DataTableJSX",
|
|
1684
1784
|
!enableCellSelection && "DataTableJSX--no-cell-selection",
|
|
1785
|
+
classNames?.root,
|
|
1685
1786
|
className
|
|
1686
1787
|
),
|
|
1687
1788
|
children: [
|
|
@@ -1693,71 +1794,120 @@ function DataTable({
|
|
|
1693
1794
|
summary,
|
|
1694
1795
|
selectedCount,
|
|
1695
1796
|
selectionLabel,
|
|
1696
|
-
toolbar
|
|
1797
|
+
toolbar,
|
|
1798
|
+
classNames
|
|
1697
1799
|
}
|
|
1698
1800
|
),
|
|
1699
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { ref: scrollRef, className: "data-table-scroll", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1801
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { ref: scrollRef, className: cn("data-table-scroll", classNames?.scroll), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1700
1802
|
"table",
|
|
1701
1803
|
{
|
|
1702
|
-
className: "data-table",
|
|
1804
|
+
className: cn("data-table", classNames?.table),
|
|
1703
1805
|
onDragStart: enableCellSelection ? (event) => event.preventDefault() : void 0,
|
|
1704
1806
|
children: [
|
|
1705
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("thead", { className: "data-table-head", children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
"
|
|
1714
|
-
|
|
1715
|
-
|
|
1807
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("thead", { className: cn("data-table-head", classNames?.head), children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1808
|
+
"tr",
|
|
1809
|
+
{
|
|
1810
|
+
className: cn("data-table-head-row", classNames?.headRow),
|
|
1811
|
+
children: headerGroup.headers.map((header) => {
|
|
1812
|
+
const align = header.column.columnDef.meta?.align ?? "center";
|
|
1813
|
+
const headerClassName = header.column.columnDef.meta?.headerClassName;
|
|
1814
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1815
|
+
"th",
|
|
1816
|
+
{
|
|
1817
|
+
style: { width: header.getSize() !== 150 ? header.getSize() : void 0 },
|
|
1818
|
+
className: cn(
|
|
1819
|
+
"data-table-head-cell",
|
|
1820
|
+
CELL_ALIGN_CLASS[align],
|
|
1821
|
+
classNames?.headCell,
|
|
1822
|
+
headerClassName
|
|
1823
|
+
),
|
|
1824
|
+
children: header.isPlaceholder ? null : (0, import_react_table3.flexRender)(header.column.columnDef.header, header.getContext())
|
|
1825
|
+
},
|
|
1826
|
+
header.id
|
|
1827
|
+
);
|
|
1828
|
+
})
|
|
1829
|
+
},
|
|
1830
|
+
headerGroup.id
|
|
1831
|
+
)) }),
|
|
1832
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DataTableContextProvider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1833
|
+
"tbody",
|
|
1834
|
+
{
|
|
1835
|
+
onMouseLeave: clearHover,
|
|
1836
|
+
className: cn("data-table-body", classNames?.body),
|
|
1837
|
+
children: rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1838
|
+
EmptySlot,
|
|
1839
|
+
{
|
|
1840
|
+
emptyText,
|
|
1841
|
+
columnCount,
|
|
1842
|
+
classNames
|
|
1843
|
+
}
|
|
1844
|
+
) : shouldVirtualize ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
1845
|
+
paddingTop > 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1846
|
+
"tr",
|
|
1847
|
+
{
|
|
1848
|
+
"aria-hidden": true,
|
|
1849
|
+
className: cn(
|
|
1850
|
+
"data-table-virtual-spacer",
|
|
1851
|
+
classNames?.virtualSpacer
|
|
1852
|
+
),
|
|
1853
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1854
|
+
"td",
|
|
1855
|
+
{
|
|
1856
|
+
colSpan: columnCount,
|
|
1857
|
+
style: { height: paddingTop },
|
|
1858
|
+
className: cn(
|
|
1859
|
+
"data-table-virtual-spacer-cell",
|
|
1860
|
+
classNames?.virtualSpacerCell
|
|
1861
|
+
)
|
|
1862
|
+
}
|
|
1863
|
+
)
|
|
1864
|
+
}
|
|
1716
1865
|
),
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1866
|
+
virtualRows.map((virtualRow) => {
|
|
1867
|
+
const row = rows[virtualRow.index];
|
|
1868
|
+
if (!row) return null;
|
|
1869
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1870
|
+
RowSlot,
|
|
1871
|
+
{
|
|
1872
|
+
row,
|
|
1873
|
+
virtualIndex: virtualRow.index,
|
|
1874
|
+
measureElement: rowVirtualizer.measureElement,
|
|
1875
|
+
onToggleSelect: () => handleToggleSelect(row)
|
|
1876
|
+
},
|
|
1877
|
+
row.id
|
|
1878
|
+
);
|
|
1879
|
+
}),
|
|
1880
|
+
paddingBottom > 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1881
|
+
"tr",
|
|
1882
|
+
{
|
|
1883
|
+
"aria-hidden": true,
|
|
1884
|
+
className: cn(
|
|
1885
|
+
"data-table-virtual-spacer",
|
|
1886
|
+
classNames?.virtualSpacer
|
|
1887
|
+
),
|
|
1888
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1889
|
+
"td",
|
|
1890
|
+
{
|
|
1891
|
+
colSpan: columnCount,
|
|
1892
|
+
style: { height: paddingBottom },
|
|
1893
|
+
className: cn(
|
|
1894
|
+
"data-table-virtual-spacer-cell",
|
|
1895
|
+
classNames?.virtualSpacerCell
|
|
1896
|
+
)
|
|
1897
|
+
}
|
|
1898
|
+
)
|
|
1899
|
+
}
|
|
1900
|
+
)
|
|
1901
|
+
] }) : rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1735
1902
|
RowSlot,
|
|
1736
1903
|
{
|
|
1737
1904
|
row,
|
|
1738
|
-
virtualIndex: virtualRow.index,
|
|
1739
|
-
measureElement: rowVirtualizer.measureElement,
|
|
1740
1905
|
onToggleSelect: () => handleToggleSelect(row)
|
|
1741
1906
|
},
|
|
1742
1907
|
row.id
|
|
1743
|
-
)
|
|
1744
|
-
}
|
|
1745
|
-
|
|
1746
|
-
"td",
|
|
1747
|
-
{
|
|
1748
|
-
colSpan: columnCount,
|
|
1749
|
-
style: { height: paddingBottom },
|
|
1750
|
-
className: "data-table-virtual-spacer-cell"
|
|
1751
|
-
}
|
|
1752
|
-
) })
|
|
1753
|
-
] }) : rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1754
|
-
RowSlot,
|
|
1755
|
-
{
|
|
1756
|
-
row,
|
|
1757
|
-
onToggleSelect: () => handleToggleSelect(row)
|
|
1758
|
-
},
|
|
1759
|
-
row.id
|
|
1760
|
-
)) }) })
|
|
1908
|
+
))
|
|
1909
|
+
}
|
|
1910
|
+
) })
|
|
1761
1911
|
]
|
|
1762
1912
|
}
|
|
1763
1913
|
) })
|
|
@@ -1767,7 +1917,7 @@ function DataTable({
|
|
|
1767
1917
|
}
|
|
1768
1918
|
|
|
1769
1919
|
// src/components/ui/table/components/Table/Table.tsx
|
|
1770
|
-
var
|
|
1920
|
+
var import_react10 = require("react");
|
|
1771
1921
|
|
|
1772
1922
|
// src/components/ui/table/components/Table/buildColumnDef.tsx
|
|
1773
1923
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
@@ -1837,10 +1987,10 @@ function buildColumnDef(props, sort, onSort) {
|
|
|
1837
1987
|
}
|
|
1838
1988
|
|
|
1839
1989
|
// src/components/ui/table/components/Table/parseTableChildren.ts
|
|
1840
|
-
var
|
|
1990
|
+
var import_react9 = require("react");
|
|
1841
1991
|
|
|
1842
1992
|
// src/components/ui/table/components/Table/tableChildTypes.ts
|
|
1843
|
-
var
|
|
1993
|
+
var import_react8 = require("react");
|
|
1844
1994
|
var TABLE_HEADER_DISPLAY_NAME = "Table.Header";
|
|
1845
1995
|
var TABLE_BODY_DISPLAY_NAME = "Table.Body";
|
|
1846
1996
|
var TABLE_COLUMN_DISPLAY_NAME = "Table.Column";
|
|
@@ -1852,16 +2002,16 @@ function getComponentDisplayName(type) {
|
|
|
1852
2002
|
return void 0;
|
|
1853
2003
|
}
|
|
1854
2004
|
function isTableHeaderElement(child) {
|
|
1855
|
-
return (0,
|
|
2005
|
+
return (0, import_react8.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_HEADER_DISPLAY_NAME;
|
|
1856
2006
|
}
|
|
1857
2007
|
function isTableBodyElement(child) {
|
|
1858
|
-
return (0,
|
|
2008
|
+
return (0, import_react8.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_BODY_DISPLAY_NAME;
|
|
1859
2009
|
}
|
|
1860
2010
|
function isTableColumnElement(child) {
|
|
1861
|
-
return (0,
|
|
2011
|
+
return (0, import_react8.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_COLUMN_DISPLAY_NAME;
|
|
1862
2012
|
}
|
|
1863
2013
|
function isTablePaginationElement(child) {
|
|
1864
|
-
return (0,
|
|
2014
|
+
return (0, import_react8.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_PAGINATION_DISPLAY_NAME;
|
|
1865
2015
|
}
|
|
1866
2016
|
|
|
1867
2017
|
// src/components/ui/table/components/Table/parseTableChildren.ts
|
|
@@ -1871,7 +2021,7 @@ function parseTableChildren(children) {
|
|
|
1871
2021
|
body: null,
|
|
1872
2022
|
pagination: null
|
|
1873
2023
|
};
|
|
1874
|
-
for (const child of
|
|
2024
|
+
for (const child of import_react9.Children.toArray(children)) {
|
|
1875
2025
|
if (isTableHeaderElement(child)) {
|
|
1876
2026
|
slots.header = child;
|
|
1877
2027
|
continue;
|
|
@@ -1889,7 +2039,7 @@ function parseTableChildren(children) {
|
|
|
1889
2039
|
function extractColumnElements(header) {
|
|
1890
2040
|
if (!header) return [];
|
|
1891
2041
|
const { children } = header.props;
|
|
1892
|
-
return
|
|
2042
|
+
return import_react9.Children.toArray(children).filter(isTableColumnElement);
|
|
1893
2043
|
}
|
|
1894
2044
|
|
|
1895
2045
|
// src/components/ui/table/components/Table/TableBody.tsx
|
|
@@ -1996,12 +2146,12 @@ function TableRoot({
|
|
|
1996
2146
|
filteredCount,
|
|
1997
2147
|
...dataTableProps
|
|
1998
2148
|
}) {
|
|
1999
|
-
const { header, pagination: paginationElement } = (0,
|
|
2149
|
+
const { header, pagination: paginationElement } = (0, import_react10.useMemo)(
|
|
2000
2150
|
() => parseTableChildren(children),
|
|
2001
2151
|
[children]
|
|
2002
2152
|
);
|
|
2003
|
-
const [sort, setSort] = (0,
|
|
2004
|
-
const handleSort = (0,
|
|
2153
|
+
const [sort, setSort] = (0, import_react10.useState)(null);
|
|
2154
|
+
const handleSort = (0, import_react10.useCallback)((field) => {
|
|
2005
2155
|
setSort((previous) => {
|
|
2006
2156
|
if (previous?.field !== field) {
|
|
2007
2157
|
return { field, direction: "asc" };
|
|
@@ -2012,7 +2162,7 @@ function TableRoot({
|
|
|
2012
2162
|
return null;
|
|
2013
2163
|
});
|
|
2014
2164
|
}, []);
|
|
2015
|
-
const columns = (0,
|
|
2165
|
+
const columns = (0, import_react10.useMemo)(() => {
|
|
2016
2166
|
return extractColumnElements(header).map(
|
|
2017
2167
|
(columnElement) => buildColumnDef(columnElement.props, sort, handleSort)
|
|
2018
2168
|
);
|
|
@@ -2021,7 +2171,7 @@ function TableRoot({
|
|
|
2021
2171
|
const pageSize = paginationProps?.pageSize ?? 10;
|
|
2022
2172
|
const page = paginationProps?.page ?? 1;
|
|
2023
2173
|
const resolvedTotalCount = paginationProps?.totalCount ?? totalCount ?? data.length;
|
|
2024
|
-
const tableData = (0,
|
|
2174
|
+
const tableData = (0, import_react10.useMemo)(() => {
|
|
2025
2175
|
const sortedData = sortTableData(data, sort);
|
|
2026
2176
|
if (!paginationProps) return sortedData;
|
|
2027
2177
|
return paginateTableData(sortedData, page, pageSize);
|
package/dist/compound.d.cts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode, ReactElement } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
export { a as DataTableLabels,
|
|
3
|
+
import { c as DataTableProps, T as TableColumnProps, e as TableProps } from './types-BfthylVR.cjs';
|
|
4
|
+
export { a as DataTableClassNames, b as DataTableLabels, d as DataTableSlots, R as RowSelectionMode } from './types-BfthylVR.cjs';
|
|
5
5
|
export { ColumnDef, RowSelectionState } from '@tanstack/react-table';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Unstyled DataTable shell: semantic HTML + interaction behavior.
|
|
9
9
|
* Class hooks (`DataTableJSX`, `data-table`, …) are opt-in — no CSS is shipped.
|
|
10
|
-
* Customize via `className`,
|
|
11
|
-
* `summary` / `toolbar`, `Column.render`, and `slots`.
|
|
10
|
+
* Customize via `className`, `classNames` (Tailwind-friendly part map), column
|
|
11
|
+
* `className` / `headerClassName`, `labels`, `summary` / `toolbar`, `Column.render`, and `slots`.
|
|
12
12
|
*/
|
|
13
|
-
declare function DataTable<T extends Record<string, unknown>>({ isPending, summary, toolbar, filteredCount, totalCount, className, slots, ...glideOptions }: DataTableProps<T>): react.JSX.Element;
|
|
13
|
+
declare function DataTable<T extends Record<string, unknown>>({ isPending, summary, toolbar, filteredCount, totalCount, className, classNames, slots, ...glideOptions }: DataTableProps<T>): react.JSX.Element;
|
|
14
14
|
|
|
15
15
|
/** Body slot marker. DataTable renders the actual tbody. */
|
|
16
16
|
declare function TableBody(): null;
|
package/dist/compound.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode, ReactElement } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
export { a as DataTableLabels,
|
|
3
|
+
import { c as DataTableProps, T as TableColumnProps, e as TableProps } from './types-BfthylVR.js';
|
|
4
|
+
export { a as DataTableClassNames, b as DataTableLabels, d as DataTableSlots, R as RowSelectionMode } from './types-BfthylVR.js';
|
|
5
5
|
export { ColumnDef, RowSelectionState } from '@tanstack/react-table';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Unstyled DataTable shell: semantic HTML + interaction behavior.
|
|
9
9
|
* Class hooks (`DataTableJSX`, `data-table`, …) are opt-in — no CSS is shipped.
|
|
10
|
-
* Customize via `className`,
|
|
11
|
-
* `summary` / `toolbar`, `Column.render`, and `slots`.
|
|
10
|
+
* Customize via `className`, `classNames` (Tailwind-friendly part map), column
|
|
11
|
+
* `className` / `headerClassName`, `labels`, `summary` / `toolbar`, `Column.render`, and `slots`.
|
|
12
12
|
*/
|
|
13
|
-
declare function DataTable<T extends Record<string, unknown>>({ isPending, summary, toolbar, filteredCount, totalCount, className, slots, ...glideOptions }: DataTableProps<T>): react.JSX.Element;
|
|
13
|
+
declare function DataTable<T extends Record<string, unknown>>({ isPending, summary, toolbar, filteredCount, totalCount, className, classNames, slots, ...glideOptions }: DataTableProps<T>): react.JSX.Element;
|
|
14
14
|
|
|
15
15
|
/** Body slot marker. DataTable renders the actual tbody. */
|
|
16
16
|
declare function TableBody(): null;
|